コード例 #1
0
ファイル: gypsy-server.c プロジェクト: ahsparrow/gypsy
static void
dispose (GObject *object)
{
	GypsyServerPrivate *priv = GET_PRIVATE (object);

	if (priv->connection) {
		dbus_g_connection_unref (priv->connection);
		priv->connection = NULL;
	}

	((GObjectClass *) gypsy_server_parent_class)->dispose (object);
}
コード例 #2
0
void teardown() {

    g_object_unref(source);
    source = NULL;
    g_object_unref(player);
    player = NULL;
    g_object_unref(demux);
    demux = NULL;

    dbus_g_connection_unref(connection);
    connection = NULL;
}
コード例 #3
0
NS_IMETHODIMP
nsGIOService::OrgFreedesktopFileManager1ShowItems(const nsACString& aPath)
{
#ifndef MOZ_ENABLE_DBUS
  return NS_ERROR_FAILURE;
#else
  GError* error = nullptr;
  static bool org_freedesktop_FileManager1_exists = true;

  if (!org_freedesktop_FileManager1_exists) {
    return NS_ERROR_NOT_AVAILABLE;
  }

  DBusGConnection* dbusGConnection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);

  if (!dbusGConnection) {
    if (error) {
      g_printerr("Failed to open connection to session bus: %s\n", error->message);
      g_error_free(error);
    }
    return NS_ERROR_FAILURE;
  }

  char *uri = g_filename_to_uri(PromiseFlatCString(aPath).get(), nullptr, nullptr);
  if (uri == nullptr) {
    return NS_ERROR_FAILURE;
  }

  DBusConnection* dbusConnection = dbus_g_connection_get_connection(dbusGConnection);
  // Make sure we do not exit the entire program if DBus connection get lost.
  dbus_connection_set_exit_on_disconnect(dbusConnection, false);

  DBusGProxy* dbusGProxy = dbus_g_proxy_new_for_name(dbusGConnection,
                                                     "org.freedesktop.FileManager1",
                                                     "/org/freedesktop/FileManager1",
                                                     "org.freedesktop.FileManager1");

  const char *uris[2] = { uri, nullptr };
  gboolean rv_dbus_call = dbus_g_proxy_call (dbusGProxy, "ShowItems", nullptr, G_TYPE_STRV, uris,
                                             G_TYPE_STRING, "", G_TYPE_INVALID, G_TYPE_INVALID);

  g_object_unref(dbusGProxy);
  dbus_g_connection_unref(dbusGConnection);
  g_free(uri);

  if (!rv_dbus_call) {
    org_freedesktop_FileManager1_exists = false;
    return NS_ERROR_NOT_AVAILABLE;
  }

  return NS_OK;
#endif
}
/* To support the BOT  */
BT_EXPORT_API int bluetooth_obex_server_init_without_agent(const char *dst_path)
{
	DBG("+\n");

	int ret = BLUETOOTH_ERROR_NONE;
	DBusGConnection *conn = NULL;

	_bluetooth_internal_session_init();

	if (FALSE == _bluetooth_internal_is_adapter_enabled()) {
		DBG("Adapter not enabled");
		return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
	}

	if (g_obex_server_info.obex_server_agent) {
		DBG("Agent already registered");
		return BLUETOOTH_ERROR_AGENT_ALREADY_EXIST;
	}

	if (NULL == dst_path) {
		DBG("Invalid Param");
		return BLUETOOTH_ERROR_INVALID_PARAM;
	}

	/* Get the session bus. This bus reff will be unref during deinit */
	conn = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);

	if (conn == NULL) {
		DBG("conn is NULL\n");
		return BLUETOOTH_ERROR_NO_RESOURCES;
	}

	/* Send deinit signal (To deinit the native Obex server) */
	__bt_send_deinit_message();

	g_dst_path = g_strdup(dst_path);

	ret = __bt_obex_agent_register(&g_obex_server_info, conn);

	if (ret != BLUETOOTH_ERROR_NONE) {
		g_free(g_dst_path);
		dbus_g_connection_unref(conn);
		g_obex_server_info.bus = NULL;
		g_dst_path = NULL;
	} else {
		ret = __register_agent_authorize_signal(&g_obex_server_info);
	}

	DBG("- \n");

	return ret;
}
コード例 #5
0
static void
dispose (GObject *object)
{
	NMSettingsServicePrivate *priv = NM_SETTINGS_SERVICE_GET_PRIVATE (object);

	if (!priv->disposed) {
		priv->disposed = TRUE;
		if (priv->bus)
			dbus_g_connection_unref (priv->bus);
	}

	G_OBJECT_CLASS (nm_settings_service_parent_class)->dispose (object);
}
/* To support the BOT  */
BT_EXPORT_API int bluetooth_obex_server_reject_connection(void)
{
	DBG("+");

	int ret = BLUETOOTH_ERROR_NONE;
	DBusGConnection *conn = NULL;
	DBusGProxy *agent_proxy = NULL;

	conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL);

	if (conn == NULL) {
		DBG("conn is NULL\n");
		return BLUETOOTH_ERROR_NO_RESOURCES;
	}

	agent_proxy = dbus_g_proxy_new_for_name(conn,
			    "org.bluez.frwk_agent",
			    "/org/bluez/agent/frwk_agent",
			    "org.bluez.Agent");

	if (agent_proxy == NULL) {
		DBG("agent proxy is NULL");
		dbus_g_connection_unref(conn);
		return BLUETOOTH_ERROR_INTERNAL;
	}

	if (!dbus_g_proxy_call(agent_proxy, "ReplyAuthorize", NULL,
			  G_TYPE_UINT, BT_REJECT,
			  G_TYPE_INVALID, G_TYPE_INVALID)) {
		DBG("Fail to ReplyAuthorize");
		ret = BLUETOOTH_ERROR_INTERNAL;
	}

	g_object_unref(agent_proxy);
	dbus_g_connection_unref(conn);

	DBG("-");
	return ret;
}
コード例 #7
0
ファイル: get_caller_info.c プロジェクト: lcp/glib_fun
static char *
get_session (pid_t calling_pid)
{
	DBusGConnection *connection;
	DBusGProxy *proxy;
	char *session_id;
	GError *error = NULL;
	gboolean ret;

	connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
	if (error != NULL) {
		g_warning ("Failed to get bus: %s", error->message);
		g_error_free (error);
		return NULL;
	}

	proxy = dbus_g_proxy_new_for_name (connection,
					   "org.freedesktop.ConsoleKit",
					   "/org/freedesktop/ConsoleKit/Manager",
					   "org.freedesktop.ConsoleKit.Manager");

	ret = dbus_g_proxy_call (proxy, "GetSessionForUnixProcess", &error,
				 G_TYPE_UINT, calling_pid,
				 G_TYPE_INVALID,
				 DBUS_TYPE_G_OBJECT_PATH, &session_id,
				 G_TYPE_INVALID);
	if (!ret) {
		/* DBus might time out, which is okay */
		if (g_error_matches (error, DBUS_GERROR, DBUS_GERROR_NO_REPLY)) {
			g_debug ("DBUS timed out, but recovering");
			goto out;
		}

		/* an actual error */
		g_warning ("Couldn't sent GetSessionForUnixProcess: %s", error->message);
		session_id = NULL;
		goto out;
	}

	session_id = g_strdup (session_id);

out:
	if (error != NULL)
		g_error_free (error);
	if (connection != NULL)
		dbus_g_connection_unref (connection);
	if (proxy != NULL)
		g_object_unref (proxy);

	return session_id;
}
コード例 #8
0
static void
names_model_set_connection (NamesModel      *names_model,
                            DBusGConnection *connection)
{
  g_return_if_fail (IS_NAMES_MODEL (names_model));
  
  if (connection == names_model->connection)
    return;

  if (names_model->connection)
    {
      dbus_g_proxy_disconnect_signal (names_model->driver_proxy,
                                      "NameOwnerChanged",
                                      G_CALLBACK (name_owner_changed),
                                      names_model);
      
      g_object_unref (names_model->driver_proxy);
      names_model->driver_proxy = NULL;
      dbus_g_connection_unref (names_model->connection);
      names_model->connection = NULL;
    }
  
  if (connection)
    {
      names_model->connection = connection;
      dbus_g_connection_ref (names_model->connection);
      
      names_model->driver_proxy =
        dbus_g_proxy_new_for_name (names_model->connection,
                                   DBUS_SERVICE_DBUS,
                                   DBUS_PATH_DBUS,
                                   DBUS_INTERFACE_DBUS);
      g_assert (names_model->driver_proxy);

      dbus_g_proxy_add_signal (names_model->driver_proxy,
                               "NameOwnerChanged",
                               G_TYPE_STRING,
                               G_TYPE_STRING,
                               G_TYPE_STRING,
			       G_TYPE_INVALID);
      
      dbus_g_proxy_connect_signal (names_model->driver_proxy,
                                   "NameOwnerChanged", 
                                   G_CALLBACK (name_owner_changed),
                                   names_model,
                                   NULL);
    }

  names_model_reload (names_model);
}
コード例 #9
0
static void
xfpm_info_free (XfpmInfo *info)
{
    if ( info->bus ) 
	dbus_g_connection_unref (info->bus);
	
    if ( info->power_proxy )
	g_object_unref (info->power_proxy);
	
    if ( info->wakeups_proxy )
	g_object_unref (info->wakeups_proxy);
	
    g_free (info);
}
コード例 #10
0
static void
mnb_panel_oop_dispose (GObject *self)
{
  MnbPanelOopPrivate *priv   = MNB_PANEL_OOP (self)->priv;
  DBusGProxy         *proxy  = priv->proxy;

  if (proxy)
    {
      dbus_g_proxy_disconnect_signal (proxy, "RequestFocus",
                                   G_CALLBACK (mnb_panel_oop_request_focus_cb),
                                   self);

      dbus_g_proxy_disconnect_signal (proxy, "RequestButtonStyle",
                             G_CALLBACK (mnb_panel_oop_request_button_style_cb),
                             self);

      dbus_g_proxy_disconnect_signal (proxy, "RequestButtonState",
                             G_CALLBACK (mnb_panel_oop_request_button_state_cb),
                             self);

      dbus_g_proxy_disconnect_signal (proxy, "RequestModality",
                             G_CALLBACK (mnb_panel_oop_request_modality_cb),
                             self);

      dbus_g_proxy_disconnect_signal (proxy, "RequestTooltip",
                                  G_CALLBACK (mnb_panel_oop_request_tooltip_cb),
                                  self);
      g_object_unref (proxy);
      priv->proxy = NULL;
    }

  if (priv->proxy_for_owner)
    g_object_weak_unref (G_OBJECT (priv->proxy_for_owner),
                         mnb_panel_oop_dbus_proxy_weak_notify_cb, self);

  if (priv->dbus_conn)
    {
      dbus_g_connection_unref (priv->dbus_conn);
      priv->dbus_conn = NULL;
    }

  if (priv->button)
    {
      priv->button = NULL;
    }

  g_signal_emit (self, signals[DESTROY], 0);

  G_OBJECT_CLASS (mnb_panel_oop_parent_class)->dispose (self);
}
コード例 #11
0
/**
 * Finalize this object.
 */
static void
glim_counter_factory_finalize (GObject *obj)
{
  GlimCounterFactory *self = GLIM_COUNTER_FACTORY (obj);

  // Deallocate allocated fields
  if (self->connection != NULL)
    {
      dbus_g_connection_unref (self->connection);
      self->connection = NULL;
    }

  (G_OBJECT_CLASS (glim_counter_factory_parent_class))->finalize (obj);
} // glim_counter_factory_finalize
コード例 #12
0
static void
hd_search_service_dispose (GObject *object)
{
  HDSearchService *search_service = HD_SEARCH_SERVICE (object);
  HDSearchServicePrivate *priv = search_service->priv;

  if (priv->tracker_proxy)
    priv->tracker_proxy = (g_object_unref (priv->tracker_proxy), NULL);

  if (priv->session_dbus)
    priv->session_dbus = (dbus_g_connection_unref (priv->session_dbus), NULL);

  G_OBJECT_CLASS (hd_search_service_parent_class)->dispose (object);
}
コード例 #13
0
ファイル: galeon-dbus.c プロジェクト: GNOME/galeon
static void
galeon_dbus_shutdown (GaleonDbus *dbus)
{
	GaleonDbusPrivate *priv = dbus->priv;

	// LOG ("GaleonDbus shutdown");

	if (priv->session_reconnect_timeout_id != 0)
	{
		g_source_remove (priv->session_reconnect_timeout_id);
		priv->session_reconnect_timeout_id = 0;
	}

	if (priv->system_reconnect_timeout_id != 0)
	{
		g_source_remove (priv->system_reconnect_timeout_id);
		priv->system_reconnect_timeout_id = 0;
	}

	if (priv->session_bus)
	{
		dbus_connection_remove_filter
			(dbus_g_connection_get_connection (priv->session_bus),
			 session_filter_func, dbus);
		dbus_g_connection_unref (priv->session_bus);
		priv->session_bus = NULL;
	}

        if (priv->system_bus)
	{
		dbus_connection_remove_filter
			(dbus_g_connection_get_connection (priv->system_bus),
			 system_filter_func, dbus);
		dbus_g_connection_unref (priv->system_bus);
		priv->system_bus = NULL;
	}
}
コード例 #14
0
ファイル: nm-tool.c プロジェクト: alfmatos/NetworkManager
static gboolean
get_all_connections (void)
{
	GError *error = NULL;
	DBusGConnection *bus;
	DBusGProxy *proxy = NULL;
	GPtrArray *paths = NULL;
	int i;
	gboolean sucess = FALSE;

	bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
	if (error || !bus) {
		g_warning ("error: could not connect to dbus");
		goto out;
	}

	proxy = dbus_g_proxy_new_for_name (bus,
	                                   NM_DBUS_SERVICE,
	                                   NM_DBUS_PATH_SETTINGS,
	                                   NM_DBUS_IFACE_SETTINGS);
	if (!proxy) {
		g_warning ("error: failed to create DBus proxy for settings service");
		goto out;
	}

	if (!dbus_g_proxy_call (proxy, "ListConnections", &error,
                                G_TYPE_INVALID,
                                DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH, &paths,
                                G_TYPE_INVALID)) {
		/* No connections or settings service may not be running */
		g_clear_error (&error);
		goto out;
	}

	connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);

	for (i = 0; paths && (i < paths->len); i++)
		get_one_connection (bus, g_ptr_array_index (paths, i), connections);

	sucess = TRUE;

out:
	if (bus)
		dbus_g_connection_unref (bus);
	if (proxy)
		g_object_unref (proxy);

	return sucess;
}
コード例 #15
0
ファイル: vim-widget.c プロジェクト: GunioRobot/vimjuta
static void
vim_widget_finalize (GObject *object)
{
	VimWidget* widget = VIM_WIDGET (object);
    VimWidgetClass* klass = VIM_WIDGET_CLASS (g_type_class_peek (VIM_TYPE_WIDGET));
	VimWidgetPrivate *priv = widget->priv;
	
	dbus_g_connection_unref (priv->conn);
	g_object_unref (priv->dbus_proxy);
	g_object_unref (priv->proxy);

	g_free (widget->priv);
	klass->widget = NULL;
	parent_class->finalize (object);
}
コード例 #16
0
int main()
{
    g_type_init();
    ctx = JSGlobalContextCreate(NULL);

    DBusGConnection *con = dbus_g_bus_get(DBUS_BUS_SESSION,  NULL);

    JSObjectRef obj = get_dbus_object(ctx, con,
            "org.gnome.Shell", "/org/gnome/Shell",
            "org.gnome.Shell");

    dbus_g_connection_unref(con);
    JSGlobalContextRelease(ctx);
    /*dbus_object_info_free(info);*/
}
コード例 #17
0
int main (int argc, char *argv[])
{
	DBusGConnection *bus;
	NMClient *client;
	const GPtrArray *devices;
	int i;

	/* Initialize GType system */
	g_type_init ();

	/* Get system bus */
	bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);

	/* Get NMClient object */
	client = nm_client_new ();
	if (!client) {
		dbus_g_connection_unref (bus);
		g_message ("Error: Could not create NMClient.");
		return EXIT_FAILURE;
	}

	/* Get all devices managed by NetworkManager */
	devices = nm_client_get_devices (client);

	/* Go through the array and process Wi-Fi devices */
	for (i = 0; devices && (i < devices->len); i++) {
		NMDevice *device = g_ptr_array_index (devices, i);
		if (NM_IS_DEVICE_WIFI (device))
			show_wifi_device_info (device);
	}

	g_object_unref (client);
	dbus_g_connection_unref (bus);

	return EXIT_SUCCESS;
}
コード例 #18
0
ファイル: tones.c プロジェクト: matthewvogt/telepathy-ring
static void
modem_tones_finalize(GObject *object)
{
  ModemTones *self = MODEM_TONES(object);
  ModemTonesPrivate *priv = self->priv;

  g_timer_destroy(priv->timer);
  ngf_client_destroy(priv->ngf);
  g_hash_table_destroy(priv->notify_map);
  dbus_g_connection_unref(priv->connection);

  memset(priv, 0, (sizeof *priv));

  G_OBJECT_CLASS(modem_tones_parent_class)->finalize(object);
}
コード例 #19
0
ファイル: kone_dbus_server.c プロジェクト: ngg/roccat-tools
gboolean kone_dbus_server_connect(KoneDBusServer *dbus_server) {
	DBusGConnection *connection;
	GError *error = NULL;

	connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
	if (!connection) {
		g_warning(_("Could not get dbus: %s"), error->message);
		return FALSE;
	}

	dbus_g_connection_register_g_object(connection, KONE_DBUS_SERVER_PATH, (GObject *)dbus_server);
	dbus_g_connection_unref(connection);

	return TRUE;
}
コード例 #20
0
ファイル: bt-widget.c プロジェクト: pavlix/nm-applet
static void
device_removed (const char *bdaddr)
{
	GError *error = NULL;
	DBusGConnection *bus;
	RemoveInfo *info;
	struct ether_addr *addr;
	NmaBtDevice *device;

	g_message ("Device '%s' was removed; deleting connections", bdaddr);

	/* Remove any connections associated with the deleted device */

	addr = ether_aton (bdaddr);
	if (!addr) {
		g_warning ("Failed to convert Bluetooth address '%s'", bdaddr);
		return;
	}

	bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
	if (error || !bus) {
		g_warning ("%s: failed to get a connection to D-Bus! %s", __func__,
		           error ? error->message : "(unknown)");
		g_clear_error (&error);
		return;
	}

	info = g_malloc0 (sizeof (RemoveInfo));
	info->settings = nm_remote_settings_new (bus);

	info->bdaddr = g_byte_array_sized_new (ETH_ALEN);
	g_byte_array_append (info->bdaddr, (const guint8 *) addr->ether_addr_octet, ETH_ALEN);

	info->str_bdaddr = g_strdup (bdaddr);
	info->timeout_id = g_timeout_add_seconds (15, remove_timeout, info);

	g_signal_connect (info->settings,
	                  NM_REMOTE_SETTINGS_CONNECTIONS_READ,
	                  G_CALLBACK (remove_connections_read),
	                  info);

	dbus_g_connection_unref (bus);

	/* Kill the device */
	device = get_device (bdaddr);
	if (device)
		remove_device (device);
}
コード例 #21
0
gboolean
gupnp_network_manager_is_available (GMainContext *main_context)
{
        DBusConnection *connection;
        DBusError derror;
        DBusGConnection *gconnection;
        DBusGProxy *dbus_proxy;
        GError *error = NULL;
        gboolean ret = FALSE;

        /* Do fake open to initialize types */
        dbus_g_connection_open ("", NULL);
        dbus_error_init (&derror);
        connection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &derror);
        if (connection == NULL) {
                g_message ("Failed to connect to System Bus: %s",
                           derror.message);
                return FALSE;
        }

        dbus_connection_setup_with_g_main (connection, main_context);
        gconnection = dbus_connection_get_g_connection (connection);

        dbus_proxy = dbus_g_proxy_new_for_name (gconnection,
                                                DBUS_SERVICE_DBUS,
                                                DBUS_PATH_DBUS,
                                                DBUS_INTERFACE_DBUS);

        if (!dbus_g_proxy_call (dbus_proxy,
                                "NameHasOwner",
                                &error,
                                G_TYPE_STRING, DBUS_SERVICE_NM,
                                G_TYPE_INVALID,
                                G_TYPE_BOOLEAN, &ret,
                                G_TYPE_INVALID)) {
                g_warning ("%s.NameHasOwner() failed: %s",
                           DBUS_INTERFACE_DBUS,
                           error->message);
                g_error_free (error);
        }

        g_object_unref (dbus_proxy);
        dbus_connection_close (connection);
        dbus_g_connection_unref (gconnection);

        return ret;
}
static void
dispose (GObject *object)
{
	SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (object);
	SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
	NMInotifyHelper *ih;

	if (priv->bus) {
		dbus_g_connection_unref (priv->bus);
		priv->bus = NULL;
	}

	if (priv->ih_event_id) {
		ih = nm_inotify_helper_get ();

		g_signal_handler_disconnect (ih, priv->ih_event_id);
		priv->ih_event_id = 0;

		if (priv->sc_network_wd >= 0)
			nm_inotify_helper_remove_watch (ih, priv->sc_network_wd);
	}

	if (priv->hostname_monitor) {
		if (priv->hostname_monitor_id)
			g_signal_handler_disconnect (priv->hostname_monitor, priv->hostname_monitor_id);

		g_file_monitor_cancel (priv->hostname_monitor);
		g_object_unref (priv->hostname_monitor);
	}

	g_free (priv->hostname);

	if (priv->connections) {
		g_hash_table_destroy (priv->connections);
		priv->connections = NULL;
	}

	if (priv->ifcfg_monitor) {
		if (priv->ifcfg_monitor_id)
			g_signal_handler_disconnect (priv->ifcfg_monitor, priv->ifcfg_monitor_id);

		g_file_monitor_cancel (priv->ifcfg_monitor);
		g_object_unref (priv->ifcfg_monitor);
	}

	G_OBJECT_CLASS (sc_plugin_ifcfg_parent_class)->dispose (object);
}
コード例 #23
0
int main()
{
	DBusGConnection *connection;
	GError *error;
	DBusGProxy *proxy;
	DBusGProxyCall* call;
	
	gint res;
	gint res1 = 0;
	
	g_type_init ();
	
	error = NULL;
	connection = dbus_g_bus_get (DBUS_BUS_SESSION,
	                           &error);
	if (connection == NULL)
	{
		std_log(LOG_FILENAME_LINE, "Failed to open connection to bus: %s\n",
	              error->message);
	  g_error_free (error);
	  create_xml(1);
	  exit (1);
	}
	
	proxy = dbus_g_proxy_new_for_name (connection,
	        "com.example.DBusGlibObject1",
	        "/com/example/DBusGlibObject1",
	        "com.example.DBusGlibObject1");
	
	call = dbus_g_proxy_begin_call_with_timeout(proxy, "Simple_method", simple_method_reply_handler, &res1, NULL, 10000, G_TYPE_INT, 5, G_TYPE_INVALID, G_TYPE_INT, &res, G_TYPE_INVALID);
	
	mainLoop = g_main_loop_new(NULL,FALSE);
	g_main_loop_run(mainLoop);
		
	std_log(LOG_FILENAME_LINE, "res = %d, res1 = %d", res, res1);
	if(res1 != 9090)
		{
		std_log(LOG_FILENAME_LINE, "return value is not matching.");
		create_xml(1);
		return 1;
		}
	
	dbus_g_connection_unref(connection);
	std_log(LOG_FILENAME_LINE, "Test Successful");
	create_xml(0);
	return 0;
}
コード例 #24
0
ファイル: mbm_gpsd.c プロジェクト: flyzjhz/Mbm-gpsd
static gboolean dbus_init (GMainLoop * loop)
{
	DBusGConnection *connection;
	DBusGProxy *proxy;
	GError *err = NULL;
	int request_name_result;

	connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
	if (!connection) {
		g_warning ("Could not get the system bus. Make sure "
				   "the message bus daemon is running! Message: %s",
				   err->message);
		g_error_free (err);
		return FALSE;
	}

	proxy = dbus_g_proxy_new_for_name (connection, DBUS_FDO_NAME,
									   DBUS_FDO_PATH,
									   DBUS_FDO_INTERFACE);

	if (!dbus_g_proxy_call (proxy, "RequestName", &err, G_TYPE_STRING,
							MBM_DBUS_SERVICE, G_TYPE_UINT,
							DBUS_NAME_FLAG_DO_NOT_QUEUE, G_TYPE_INVALID,
							G_TYPE_UINT, &request_name_result,
							G_TYPE_INVALID)) {
		g_warning ("Could not acquire the %s service.\n" "  Message: '%s'",
				   MBM_DBUS_SERVICE, err->message);
		g_error_free (err);
		goto err;
	}

	if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
		g_warning ("Could not acquire the MBM GPS service "
				   "as it is already taken. Return: %d", request_name_result);
		goto err;
	}

	g_signal_connect (proxy, "destroy", G_CALLBACK (destroy_cb), loop);

	return TRUE;

  err:dbus_g_connection_unref (connection);
	g_object_unref (proxy);

	return FALSE;
}
コード例 #25
0
ファイル: udisks.c プロジェクト: jmattsson/wmvolman
static DBusHandlerResult signal_filter(DBusConnection *connection, DBusMessage *message, void *user_data)
{
	if (dbus_message_get_type(message) != DBUS_MESSAGE_TYPE_SIGNAL)
		return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;

	if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
		g_message("Disconnected from DBus");
		g_object_unref(udisks_proxy);
		udisks_proxy = NULL;
		dbus_g_connection_unref(dbus_bus);
		dbus_bus = NULL;
		g_timeout_add(1000, reinit_udisks_connection, NULL);
		return DBUS_HANDLER_RESULT_HANDLED;
	}

	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
コード例 #26
0
static DBusGProxy *
connect_gnome_screensaverd (MexScreensaver *self)
{
 MexScreensaverPrivate *priv = MEX_SCREENSAVER (self)->priv;

 DBusGConnection *dbus_connection;
 DBusGProxy *proxy;
 GError *error=NULL;

 dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);

 if (dbus_connection == NULL)
   {
     g_warning ("Failed to connect to dbus %s\n",
                (error) ? error->message : "");
     if (error)
       g_error_free (error);

     return NULL;
   }

 /* Try with gnome 2 api first. gnome_version 0 is the default
  * representing the undetermined state
  */
 if (priv->gnome_version == 2 || priv->gnome_version == 0)
   {
     proxy = dbus_g_proxy_new_for_name (dbus_connection,
                                        "org.gnome.ScreenSaver",
                                        "/org/gnome/ScreenSaver",
                                        "org.gnome.ScreenSaver");
   }

 /* The gnome 2 api didn't work and we've been called again with version 3 */
 if (priv->gnome_version == 3)
   {
     proxy = dbus_g_proxy_new_for_name (dbus_connection,
                                        "org.gnome.SessionManager",
                                        "/org/gnome/SessionManager",
                                        "org.gnome.SessionManager");
   }

 dbus_g_connection_unref (dbus_connection);

 return proxy;
}
コード例 #27
0
static void
cdma_device_info_free (gpointer data)
{
	CdmaDeviceInfo *info = data;

	if (info->props_proxy)
		g_object_unref (info->props_proxy);
	if (info->cdma_proxy)
		g_object_unref (info->cdma_proxy);
	if (info->bus)
		dbus_g_connection_unref (info->bus);
	if (info->poll_id)
		g_source_remove (info->poll_id);
	if (info->mobile_providers_database)
		g_object_unref (info->mobile_providers_database);
	g_free (info->provider_name);
	memset (info, 0, sizeof (CdmaDeviceInfo));
	g_free (info);
}
コード例 #28
0
ファイル: urf-killswitch.c プロジェクト: lexical/urfkill
/**
 * urf_killswitch_dispose:
 **/
static void
urf_killswitch_dispose (GObject *object)
{
	UrfKillswitch *killswitch = URF_KILLSWITCH (object);
	UrfKillswitchPrivate *priv = killswitch->priv;

	if (priv->connection) {
		dbus_g_connection_unref (priv->connection);
		priv->connection = NULL;
	}

	if (priv->devices) {
		g_list_foreach (priv->devices, (GFunc) g_object_unref, NULL);
		g_list_free (priv->devices);
		priv->devices = NULL;
	}

	G_OBJECT_CLASS (urf_killswitch_parent_class)->dispose (object);
}
コード例 #29
0
ファイル: theme-util.c プロジェクト: dnk/mate-control-center
void theme_install_file(GtkWindow* parent, const gchar* path)
{
	DBusGConnection* connection;
	DBusGProxy* proxy;
	GError* error = NULL;
	gboolean ret;

	connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);

	if (connection == NULL)
	{
		g_warning("Could not get session bus");
		return;
	}

	proxy = dbus_g_proxy_new_for_name(connection,
		"org.freedesktop.PackageKit",
		"/org/freedesktop/PackageKit",
		"org.freedesktop.PackageKit");


	ret = dbus_g_proxy_call(proxy, "InstallProvideFile", &error,
		G_TYPE_STRING, path,
		G_TYPE_INVALID, G_TYPE_INVALID);

	g_object_unref(proxy);

	if (!ret)
	{
		GtkWidget* dialog = gtk_message_dialog_new(NULL,
			GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_MESSAGE_ERROR,
			GTK_BUTTONS_OK,
			_("Could not install theme engine"));
		gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG (dialog), "%s", error->message);

		gtk_dialog_run(GTK_DIALOG(dialog));
		gtk_widget_destroy(dialog);
		g_error_free(error);
	}

	dbus_g_connection_unref(connection);
}
コード例 #30
0
ファイル: mojito-client-service.c プロジェクト: lcp/mojito
static void
mojito_client_service_dispose (GObject *object)
{
  MojitoClientServicePrivate *priv = GET_PRIVATE (object);
  gint i = 0;

  if (priv->connection)
  {
    dbus_g_connection_unref (priv->connection);
    priv->connection = NULL;
  }

  for (i = 0; i < LAST_IFACE; i++)
  {
    g_object_unref (priv->proxies[i]);
    priv->proxies[i] = NULL;
  }

  G_OBJECT_CLASS (mojito_client_service_parent_class)->dispose (object);
}