void App::init() { // only init once if (m_init) { return; } GDBusConnection* connection = ibus_bus_get_connection (m_bus); g_dbus_connection_signal_subscribe (connection, "org.freedesktop.DBus", "org.freedesktop.DBus", "NameAcquired", "/org/freedesktop/DBus", IBUS_SERVICE_PANEL, G_DBUS_SIGNAL_FLAGS_NONE, name_acquired_cb, this, NULL); g_dbus_connection_signal_subscribe (connection, "org.freedesktop.DBus", "org.freedesktop.DBus", "NameLost", "/org/freedesktop/DBus", IBUS_SERVICE_PANEL, G_DBUS_SIGNAL_FLAGS_NONE, name_lost_cb, this, NULL); ibus_bus_request_name (m_bus, IBUS_SERVICE_PANEL, IBUS_BUS_NAME_FLAG_ALLOW_REPLACEMENT | IBUS_BUS_NAME_FLAG_REPLACE_EXISTING); m_init = true; }
static void signals_subscribe(LoginKitManager *interface) { GDBusConnection *bus; bus = bus_get(); if (NULL == bus) return; g_added_signal = g_dbus_connection_signal_subscribe( bus, "org.freedesktop.ConsoleKit", "org.freedesktop.ConsoleKit.Manager", "SeatAdded", "/org/freedesktop/Consolekit", NULL, G_DBUS_SIGNAL_FLAGS_NONE, on_seat_added, interface, NULL); g_removed_signal = g_dbus_connection_signal_subscribe( bus, "org.freedesktop.ConsoleKit", "org.freedesktop.ConsoleKit.Manager", "SeatRemoved", "/org/freedesktop/Consolekit", NULL, G_DBUS_SIGNAL_FLAGS_NONE, on_seat_removed, interface, NULL); }
static void _manager_subscribe_seat_changes (TlmManager *manager) { TlmManagerPrivate *priv = manager->priv; priv->seat_added_id = g_dbus_connection_signal_subscribe ( priv->connection, LOGIND_BUS_NAME, LOGIND_MANAGER_IFACE, "SeatNew", LOGIND_OBJECT_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE, _manager_on_seat_added, manager, NULL); priv->seat_removed_id = g_dbus_connection_signal_subscribe ( priv->connection, LOGIND_BUS_NAME, LOGIND_MANAGER_IFACE, "SeatRemoved", LOGIND_OBJECT_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE, _manager_on_seat_removed, manager, NULL); }
static void CALESubscribeToSignals(CALEContext * context, GDBusConnection * connection, GDBusObjectManager * object_manager) { static char const om_interface[] = "org.freedesktop.DBus.ObjectManager"; /* Subscribe to D-Bus signals that will allow us to detect changes in BlueZ adapter and device properties. */ guint const interfaces_added_sub_id = g_dbus_connection_signal_subscribe( connection, NULL, // sender om_interface, "InterfacesAdded", NULL, // object path NULL, // arg0 G_DBUS_SIGNAL_FLAGS_NONE, CALEOnInterfacesAdded, NULL, // user_data NULL); guint const interfaces_removed_sub_id = g_dbus_connection_signal_subscribe( connection, NULL, // sender om_interface, "InterfacesRemoved", NULL, // object path NULL, // arg0 G_DBUS_SIGNAL_FLAGS_NONE, CALEOnInterfacesRemoved, NULL, // user_data NULL); g_signal_connect(object_manager, "interface-proxy-properties-changed", G_CALLBACK(CALEOnInterfaceProxyPropertiesChanged), context); ca_mutex_lock(context->lock); context->interfaces_added_sub_id = interfaces_added_sub_id; context->interfaces_removed_sub_id = interfaces_removed_sub_id; ca_mutex_unlock(context->lock); }
void listen_primary_changed_signal(GDBusSignalCallback handler, gpointer data, GDestroyNotify data_free_func) { GError* err = NULL; static GDBusConnection* conn = NULL; if (conn == NULL ) { conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &err); } if (err != NULL) { g_warning("[%s] get dbus failed: %s\n", __func__, err->message); g_clear_error(&err); return; } add_watch(conn, DISPLAY_PATH, DISPLAY_INTERFACE, PRIMARY_CHANGED_SIGNAL); g_dbus_connection_signal_subscribe(conn, DISPLAY_NAME, DISPLAY_INTERFACE, PRIMARY_CHANGED_SIGNAL, DISPLAY_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE, handler, data, data_free_func); }
static void on_proxy_created(GDBusProxy *new_proxy, GAsyncResult *result, gpointer data) { GError *error = NULL; GDBusProxy *proxy; GDBusConnection *connection; proxy = g_dbus_proxy_new_finish(result, &error); if (!proxy) { if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_warning("Error creating web extension proxy: %s", error->message); } g_error_free(error); /* TODO cancel the dbus connection - use cancelable */ return; } connection = g_dbus_proxy_get_connection(proxy); g_dbus_connection_signal_subscribe(connection, NULL, VB_WEBEXTENSION_INTERFACE, "PageCreated", VB_WEBEXTENSION_OBJECT_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)on_web_extension_page_created, proxy, NULL); }
static void cm_service_use (GUPnPConnmanManager *manager, CMService *cm_service) { GDBusConnection *connection; connection = g_dbus_proxy_get_connection (cm_service->proxy); cm_service->sig_prop_id = g_dbus_connection_signal_subscribe ( connection, CM_DBUS_CONNMAN_NAME, CM_DBUS_SERVICE_INTERFACE, "PropertyChanged", g_dbus_proxy_get_object_path (cm_service->proxy), NULL, G_DBUS_SIGNAL_FLAGS_NONE, on_service_property_signal, cm_service, NULL); g_dbus_proxy_call (cm_service->proxy, "GetProperties", NULL, G_DBUS_CALL_FLAGS_NONE, -1, cm_service->cancellable, get_properties_cb, cm_service); if (cm_service->current == CM_SERVICE_STATE_ACTIVE) if (service_context_create (cm_service) == FALSE) cm_service->current = CM_SERVICE_STATE_INACTIVE; }
static Login1Seat * add_seat (Login1Service *service, const gchar *id, const gchar *path) { Login1Seat *seat; GVariant *result; GError *error = NULL; seat = g_object_new (LOGIN1_SEAT_TYPE, NULL); seat->priv->connection = g_object_ref (service->priv->connection); seat->priv->id = g_strdup (id); seat->priv->path = g_strdup (path); seat->priv->signal_id = g_dbus_connection_signal_subscribe (seat->priv->connection, LOGIN1_SERVICE_NAME, "org.freedesktop.DBus.Properties", "PropertiesChanged", path, "org.freedesktop.login1.Seat", G_DBUS_SIGNAL_FLAGS_NONE, seat_properties_changed_cb, g_object_ref (seat), g_object_unref); /* Get properties for this seat */ result = g_dbus_connection_call_sync (seat->priv->connection, LOGIN1_SERVICE_NAME, path, "org.freedesktop.DBus.Properties", "GetAll", g_variant_new ("(s)", "org.freedesktop.login1.Seat"), G_VARIANT_TYPE ("(a{sv})"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error) g_warning ("Failed to get seat properties: %s", error->message); g_clear_error (&error); if (result) { GVariantIter *properties; const gchar *name; GVariant *value; g_variant_get (result, "(a{sv})", &properties); while (g_variant_iter_loop (properties, "{&sv}", &name, &value)) { if (strcmp (name, "CanGraphical") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) seat->priv->can_graphical = g_variant_get_boolean (value); else if (strcmp (name, "CanMultiSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) seat->priv->can_multi_session = g_variant_get_boolean (value); } g_variant_iter_free (properties); g_variant_unref (result); } service->priv->seats = g_list_append (service->priv->seats, seat); return seat; }
static void init_connman_manager (GUPnPConnmanManager *manager) { GUPnPConnmanManagerPrivate *priv; GError *error = NULL; GDBusConnection *connection; priv = manager->priv; priv->manager_proxy = g_dbus_proxy_new_for_bus_sync ( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, NULL, CM_DBUS_CONNMAN_NAME, CM_DBUS_MANAGER_PATH, CM_DBUS_MANAGER_INTERFACE, NULL, &error); if (error != NULL) { g_warning ("Failed to connect to Connman: %s", error->message); g_error_free (error); return; } connection = g_dbus_proxy_get_connection (priv->manager_proxy); if (connection == NULL) { g_warning ("Failed to get DBus Connection"); g_object_unref (priv->manager_proxy); priv->manager_proxy = NULL; return; } g_dbus_proxy_call (priv->manager_proxy, "GetServices", NULL, G_DBUS_CALL_FLAGS_NONE, -1, priv->cancellable, get_services_cb, manager); priv->sig_change_id = g_dbus_connection_signal_subscribe ( connection, CM_DBUS_CONNMAN_NAME, CM_DBUS_MANAGER_INTERFACE, "ServicesChanged", CM_DBUS_MANAGER_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE, on_manager_svc_changed_signal, manager, NULL); }
gboolean login1_service_connect (Login1Service *service) { GVariant *result; GVariantIter *seat_iter; const gchar *id, *path; GError *error = NULL; g_return_val_if_fail (service != NULL, FALSE); if (service->priv->connected) return TRUE; service->priv->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (error) g_warning ("Failed to get system bus: %s", error->message); g_clear_error (&error); if (!service->priv->connection) return FALSE; service->priv->signal_id = g_dbus_connection_signal_subscribe (service->priv->connection, LOGIN1_SERVICE_NAME, LOGIN1_MANAGER_INTERFACE_NAME, NULL, LOGIN1_OBJECT_NAME, NULL, G_DBUS_SIGNAL_FLAGS_NONE, signal_cb, g_object_ref (service), g_object_unref); result = g_dbus_connection_call_sync (service->priv->connection, LOGIN1_SERVICE_NAME, LOGIN1_OBJECT_NAME, LOGIN1_MANAGER_INTERFACE_NAME, "ListSeats", g_variant_new ("()"), G_VARIANT_TYPE ("(a(so))"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (error) g_warning ("Failed to get list of logind seats: %s", error->message); g_clear_error (&error); if (!result) return FALSE; g_variant_get (result, "(a(so))", &seat_iter); while (g_variant_iter_loop (seat_iter, "(&s&o)", &id, &path)) add_seat (service, id, path); g_variant_iter_free (seat_iter); g_variant_unref (result); service->priv->connected = TRUE; return TRUE; }
static void g_dbus_menu_path_activate (GDBusMenuPath *path) { if (path->active++ == 0) path->watch_id = g_dbus_connection_signal_subscribe (path->id->connection, path->id->bus_name, "org.gtk.Menus", "Changed", path->id->object_path, NULL, G_DBUS_SIGNAL_FLAGS_NONE, g_dbus_menu_path_signal, path, NULL); }
static void realms_constructed (GObject *_object) { Realms *realms = REALMS (_object); GError *error = NULL; realms->realmd = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, 0, NULL, "org.freedesktop.realmd", "/org/freedesktop/realmd", "org.freedesktop.realmd.Provider", NULL, &error); if (error) { g_warning ("Unable to create realmd proxy: %s", error->message); g_error_free (error); return; } clear_invocation (realms); GDBusConnection *connection; connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (error == NULL) { g_dbus_connection_signal_subscribe (connection, "org.freedesktop.realmd", "org.freedesktop.realmd.Service", "Diagnostics", "/org/freedesktop/realmd", NULL, G_DBUS_SIGNAL_FLAGS_NONE, on_diagnostics_signal, realms, NULL); } else { g_warning ("Unable to subscribe to realmd diagnostics: %s (%s, %d)", error->message, g_quark_to_string (error->domain), error->code); g_error_free (error); } if (G_OBJECT_CLASS (realms_parent_class)->constructed != NULL) G_OBJECT_CLASS (realms_parent_class)->constructed (_object); g_signal_connect (realms->realmd, "g-properties-changed", G_CALLBACK (on_properties_changed), realms); update_realms (realms); }
static void open_file_msg_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { FilechooserPortalData *data = user_data; GtkFileChooserNative *self = data->self; GDBusMessage *reply; GError *error = NULL; reply = g_dbus_connection_send_message_with_reply_finish (data->connection, res, &error); if (reply && g_dbus_message_to_gerror (reply, &error)) g_clear_object (&reply); if (reply == NULL) { if (!data->hidden) _gtk_native_dialog_emit_response (GTK_NATIVE_DIALOG (self), GTK_RESPONSE_DELETE_EVENT); g_warning ("Can't open portal file chooser: %s", error->message); g_error_free (error); filechooser_portal_data_free (data); self->mode_data = NULL; return; } g_variant_get_child (g_dbus_message_get_body (reply), 0, "o", &data->portal_handle); if (data->hidden) { /* The dialog was hidden before we got the handle, close it now */ send_close (data); filechooser_portal_data_free (data); self->mode_data = NULL; } else { data->portal_response_signal_id = g_dbus_connection_signal_subscribe (data->connection, "org.freedesktop.portal.Desktop", "org.freedesktop.portal.Request", "Response", data->portal_handle, NULL, G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE, response_cb, self, NULL); } g_object_unref (reply); }
guint eas_gdbus_progress_subscribe (struct eas_gdbus_client *client, const gchar *interface, const gchar *signal, const gchar *object) { return g_dbus_connection_signal_subscribe (client->connection, EAS_SERVICE_NAME, interface, signal, object, NULL, G_DBUS_SIGNAL_FLAGS_NONE, progress_signal_handler, client, NULL); }
void xdp_connection_track_name_owners (GDBusConnection *connection) { g_dbus_connection_signal_subscribe (connection, "org.freedesktop.DBus", "org.freedesktop.DBus", "NameOwnerChanged", "/org/freedesktop/DBus", NULL, G_DBUS_SIGNAL_FLAGS_NONE, name_owner_changed, NULL, NULL); }
/** * Helper class implementing the remote API to control the icons in the * launcher. Also known as the com.canonical.Unity.LauncherEntry DBus API. * It enables clients to dynamically control their launcher icons by * adding a counter, progress indicator, or emblem to it. It also supports * adding a quicklist menu by means of the dbusmenu library. * * We take care to print out any client side errors or oddities in detail, * in order to help third party developers as much as possible when integrating * with Unity. */ LauncherEntryRemoteModel::LauncherEntryRemoteModel() : _launcher_entry_dbus_signal_id(0) , _dbus_name_owner_changed_signal_id(0) { glib::Error error; _conn = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error); if (error) { LOG_ERROR(logger) << "Unable to connect to session bus: " << error.Message(); return; } /* Listen for *all* signals on the "com.canonical.Unity.LauncherEntry" * interface, no matter who the sender is */ _launcher_entry_dbus_signal_id = g_dbus_connection_signal_subscribe(_conn, nullptr, // sender "com.canonical.Unity.LauncherEntry", // iface nullptr, // member nullptr, // path nullptr, // arg0 G_DBUS_SIGNAL_FLAGS_NONE, &OnEntrySignalReceived, this, nullptr); _dbus_name_owner_changed_signal_id = g_dbus_connection_signal_subscribe(_conn, "org.freedesktop.DBus", // sender "org.freedesktop.DBus", // interface "NameOwnerChanged", // member "/org/freedesktop/DBus", // path nullptr, // arg0 G_DBUS_SIGNAL_FLAGS_NONE, &OnDBusNameOwnerChanged, this, nullptr); }
static void reader_engine_init (ReaderEngine *engine) { ReaderEnginePrivate *priv; priv = reader_engine_get_instance_private (engine); /* TODO error handling */ priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); priv->tracker = tracker_sparql_connection_get (NULL, NULL); priv->data = gtk_list_store_new (EXTRA_COLUMN_LAST, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_LONG, G_TYPE_BOOLEAN, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_POINTER); g_dbus_connection_signal_subscribe (priv->connection, TRACKER_DBUS_SERVICE, TRACKER_DBUS_INTERFACE_RESOURCES, "GraphUpdated", TRACKER_DBUS_OBJECT_RESOURCES, "http://www.tracker-project.org/temp/mfo#FeedChannel", G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback) on_channel_update, engine, NULL); g_dbus_connection_signal_subscribe (priv->connection, TRACKER_DBUS_SERVICE, TRACKER_DBUS_INTERFACE_RESOURCES, "GraphUpdated", TRACKER_DBUS_OBJECT_RESOURCES, "http://www.tracker-project.org/temp/mfo#FeedMessage", G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback) on_message_update, engine, NULL); collect_channels (engine, NULL); }
static void g_dbus_action_group_async_init (GDBusActionGroup *group) { if (group->subscription_id != 0) return; group->subscription_id = g_dbus_connection_signal_subscribe (group->connection, group->bus_name, "org.gtk.Actions", "Changed", group->object_path, NULL, G_DBUS_SIGNAL_FLAGS_NONE, g_dbus_action_group_changed, group, NULL); g_dbus_connection_call (group->connection, group->bus_name, group->object_path, "org.gtk.Actions", "DescribeAll", NULL, G_VARIANT_TYPE ("(a{s(bgav)})"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, g_dbus_action_group_describe_all_done, g_object_ref (group)); }
static void gdm_local_display_factory_start_monitor (GdmLocalDisplayFactory *factory) { factory->priv->seat_new_id = g_dbus_connection_signal_subscribe (factory->priv->connection, "org.freedesktop.login1", "org.freedesktop.login1.Manager", "SeatNew", "/org/freedesktop/login1", NULL, G_DBUS_SIGNAL_FLAGS_NONE, on_seat_new, g_object_ref (factory), g_object_unref); factory->priv->seat_removed_id = g_dbus_connection_signal_subscribe (factory->priv->connection, "org.freedesktop.login1", "org.freedesktop.login1.Manager", "SeatRemoved", "/org/freedesktop/login1", NULL, G_DBUS_SIGNAL_FLAGS_NONE, on_seat_removed, g_object_ref (factory), g_object_unref); }
void grl_tracker_source_dbus_start_watch (void) { GDBusConnection *connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); tracker_dbus_signal_id = g_dbus_connection_signal_subscribe (connection, TRACKER_DBUS_SERVICE, TRACKER_DBUS_INTERFACE_RESOURCES, "GraphUpdated", TRACKER_DBUS_OBJECT_RESOURCES, NULL, G_DBUS_SIGNAL_FLAGS_NONE, tracker_dbus_signal_cb, NULL, NULL); }
static gboolean store_init (void) { GError *error = NULL; if (connection && proxy) { return TRUE; } connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); if (!connection) { g_critical ("Could not connect to the D-Bus session bus, %s", error ? error->message : "no error given."); g_clear_error (&error); return FALSE; } proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, NULL, "org.freedesktop.Tracker1", "/org/freedesktop/Tracker1/Status", "org.freedesktop.Tracker1.Status", NULL, &error); if (error) { g_critical ("Could not create proxy on the D-Bus session bus, %s", error ? error->message : "no error given."); g_clear_error (&error); return FALSE; } g_dbus_connection_signal_subscribe (connection, "org.freedesktop.Tracker1", "org.freedesktop.Tracker1.Status", "Progress", "/org/freedesktop/Tracker1/Status", NULL, G_DBUS_SIGNAL_FLAGS_NONE, store_progress, NULL, NULL); return TRUE; }
static void new_connection_cb (NMBusManager *mgr, GDBusConnection *connection, GDBusObjectManager *manager, NMDhcpListener *self) { NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self); guint id; id = g_dbus_connection_signal_subscribe (connection, NULL, NM_DHCP_CLIENT_DBUS_IFACE, "Event", NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE, handle_event, self, NULL); g_hash_table_insert (priv->signal_handlers, connection, GUINT_TO_POINTER (id)); }
static void got_bus (GObject *object, GAsyncResult *result, gpointer user_data) { GDBusConnection *connection; NamespaceWatcher *watcher; GError *error = NULL; connection = g_bus_get_finish (result, &error); if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_error_free (error); return; } watcher = user_data; if (connection == NULL) { namespace_watcher_stop (watcher); return; } watcher->connection = connection; g_signal_connect (watcher->connection, "closed", G_CALLBACK (connection_closed), watcher); #ifdef HAVE_NEW_GLIB // G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE is only available since Glib 2.38, LMDE uses 2.36 so we test the version of Glib here. watcher->subscription_id = g_dbus_connection_signal_subscribe (watcher->connection, "org.freedesktop.DBus", "org.freedesktop.DBus", "NameOwnerChanged", "/org/freedesktop/DBus", watcher->name_space, G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE, name_owner_changed, watcher, NULL); #endif /* HAVE_NEW_GLIB */ g_dbus_connection_call (watcher->connection, "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "ListNames", NULL, G_VARIANT_TYPE ("(as)"), G_DBUS_CALL_FLAGS_NONE, -1, watcher->cancellable, names_listed, watcher); }
static void has_connection (Client *client) { /* listen for disconnection */ client->disconnected_signal_handler_id = g_signal_connect (client->connection, "closed", G_CALLBACK (on_connection_disconnected), GUINT_TO_POINTER (client->id)); /* start listening to NameOwnerChanged messages immediately */ client->name_owner_changed_subscription_id = g_dbus_connection_signal_subscribe (client->connection, "org.freedesktop.DBus", /* name */ "org.freedesktop.DBus", /* if */ "NameOwnerChanged", /* signal */ "/org/freedesktop/DBus", /* path */ client->name, G_DBUS_SIGNAL_FLAGS_NONE, on_name_owner_changed, GUINT_TO_POINTER (client->id), NULL); if (client->flags & G_BUS_NAME_WATCHER_FLAGS_AUTO_START) { g_dbus_connection_call (client->connection, "org.freedesktop.DBus", /* bus name */ "/org/freedesktop/DBus", /* object path */ "org.freedesktop.DBus", /* interface name */ "StartServiceByName", /* method name */ g_variant_new ("(su)", client->name, 0), G_VARIANT_TYPE ("(u)"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, (GAsyncReadyCallback) start_service_by_name_cb, client_ref (client)); } else { /* check owner */ invoke_get_name_owner (client); } }
guint bluez_register_disconnect_handler(GDBusConnection* conn, char* device_path) { guint signal_id = g_dbus_connection_signal_subscribe(conn, "org.bluez", "org.bluez.Device", "PropertyChanged", device_path, "Connected", G_DBUS_SIGNAL_FLAGS_NONE, bluez_handle_disconnect, device_path, NULL); if(signal_id <= 0) { g_printerr("g_dbus_connection_signal_subscribe failed: %d\n", signal_id); } return signal_id; }
static void testDocumentLoadedSignal(WebViewTest* test, gconstpointer) { GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy("org.webkit.gtk.WebExtensionTest", "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", test->m_mainLoop)); GDBusConnection* connection = g_dbus_proxy_get_connection(proxy.get()); guint id = g_dbus_connection_signal_subscribe(connection, 0, "org.webkit.gtk.WebExtensionTest", "DocumentLoaded", "/org/webkit/gtk/WebExtensionTest", 0, G_DBUS_SIGNAL_FLAGS_NONE, reinterpret_cast<GDBusSignalCallback>(documentLoadedCallback), test, 0); g_assert(id); test->loadHtml("<html><head><title>WebKitGTK+ Web Extensions Test</title></head><body></body></html>", 0); g_main_loop_run(test->m_mainLoop); g_dbus_connection_signal_unsubscribe(connection, id); }
AutomotiveManager::AutomotiveManager(GDBusConnection *connection) :mConnection(connection) { GError* error = NULL; GDBusNodeInfo* introspection = g_dbus_node_info_new_for_xml(introspection_xml, &error); GDBusInterfaceInfo* mInterfaceInfo = g_dbus_node_info_lookup_interface(introspection, "org.automotive.Manager"); regId = g_dbus_connection_register_object(mConnection, "/", mInterfaceInfo, &interfaceVTable, this, NULL, &error); g_dbus_node_info_unref(introspection); if(error){ g_error_free(error); throw -1; } g_assert(regId > 0); g_dbus_connection_signal_subscribe(g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL,NULL), "org.freedesktop.DBus", "org.freedesktop.DBus", "NameOwnerChanged", "/org/freedesktop/DBus", NULL, G_DBUS_SIGNAL_FLAGS_NONE, signalCallback, this, NULL); }
static void ephy_embed_shell_setup_web_extensions_connection (EphyEmbedShell *shell) { EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell); priv->bus = g_application_get_dbus_connection (G_APPLICATION (shell)); if (!priv->bus) { g_warning ("Application not connected to session bus"); return; } priv->web_extensions_page_created_signal_id = g_dbus_connection_signal_subscribe (priv->bus, NULL, EPHY_WEB_EXTENSION_INTERFACE, "PageCreated", EPHY_WEB_EXTENSION_OBJECT_PATH, NULL, G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)web_extension_page_created, shell, NULL); }
static void prepare_print_called (GObject *source, GAsyncResult *result, gpointer data) { PortalData *portal = data; GError *error = NULL; const char *handle = NULL; GVariant *ret; ret = g_dbus_proxy_call_finish (portal->proxy, result, &error); if (ret == NULL) { if (portal->op->priv->error == NULL) portal->op->priv->error = g_error_copy (error); g_error_free (error); if (portal->loop) g_main_loop_quit (portal->loop); return; } else g_variant_get (ret, "(&o)", &handle); portal->response_signal_id = g_dbus_connection_signal_subscribe (g_dbus_proxy_get_connection (G_DBUS_PROXY (portal->proxy)), "org.freedesktop.portal.Desktop", "org.freedesktop.portal.Request", "Response", handle, NULL, G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE, prepare_print_response, portal, NULL); g_variant_unref (ret); }
int main(int argc, char **argv) { GMainLoop *loop; GDBusConnection *conn; GError *error; guint subscr; loop = g_main_loop_new(NULL, FALSE); error = NULL; conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); if (UNLIKELY(!conn)) { PTYWATCH_ERROR("Failed to get bus: %s\n", error->message); g_error_free(error); return -1; } subscr = g_dbus_connection_signal_subscribe(conn, NULL, /* sender */ "org.freedesktop.PtyWatchDbusSignal", /* interface */ NULL, /* member */ "/org/freedesktop/PtyWatchDbusSignal", /* object path */ NULL, /* arg0 */ G_DBUS_SIGNAL_FLAGS_NONE, On_Caught_Signal, argv[1], NULL); g_main_loop_run(loop); g_dbus_connection_signal_unsubscribe(conn, subscr); g_object_unref(G_OBJECT(conn)); g_main_loop_unref(loop); return 0; }