int main (int argc, char *argv[]) { guint owner_id; GMainLoop *loop; g_type_init (); /* We are lazy here - we don't want to manually provide * the introspection data structures - so we just build * them from XML. */ introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); g_assert (introspection_data != NULL); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, "org.gtk.GDBus.TestServer", G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); g_bus_unown_name (owner_id); g_dbus_node_info_unref (introspection_data); return 0; }
static GDBusInterfaceInfo * org_gtk_Menus_get_interface (void) { static GDBusInterfaceInfo *interface_info; if (interface_info == NULL) { GError *error = NULL; GDBusNodeInfo *info; info = g_dbus_node_info_new_for_xml ("<node>" " <interface name='org.gtk.Menus'>" " <method name='Start'>" " <arg type='au' name='groups' direction='in'/>" " <arg type='a(uuaa{sv})' name='content' direction='out'/>" " </method>" " <method name='End'>" " <arg type='au' name='groups' direction='in'/>" " </method>" " <signal name='Changed'>" " arg type='a(uuuuaa{sv})' name='changes'/>" " </signal>" " </interface>" "</node>", &error); if (info == NULL) g_error ("%s\n", error->message); interface_info = g_dbus_node_info_lookup_interface (info, "org.gtk.Menus"); g_assert (interface_info != NULL); g_dbus_interface_info_ref (interface_info); g_dbus_node_info_unref (info); } return interface_info; }
void dt_dbus_destroy(const dt_dbus_t *dbus) { g_bus_unown_name(dbus->owner_id); g_dbus_node_info_unref(dbus->introspection_data); g_free((dt_dbus_t*)dbus); }
static void daemon_read_extension_file (GHashTable *ifaces, const gchar *filename) { GError *error = NULL; GDBusNodeInfo *node; gchar *contents; gint i; if (!g_file_get_contents (filename, &contents, NULL, &error)) { g_warning ("Unable to read extension file %s: %s. Ignoring.", filename, error->message); g_error_free (error); return; } node = g_dbus_node_info_new_for_xml (contents, &error); if (node) { for (i = 0; node->interfaces && node->interfaces[i]; i++) daemon_maybe_add_extension_interface (ifaces, node->interfaces[i]); g_dbus_node_info_unref (node); } else { g_warning ("Failed to parse file %s: %s", filename, error->message); g_error_free (error); } g_free (contents); }
int main(int argc, char * argv[]) { guint owner_id; GMainLoop *loop; introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); g_assert (introspection_data != NULL); printf("g_bus_own_name\n"); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, GSTSWITCH_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, &bus_acquired_cb, &bus_name_acquired_cb, &bus_name_lost_cb, /*user_data*/ NULL, /*user_data_free_func*/ NULL); printf("g_bus_own_name done, entering mainloop\n"); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); g_bus_unown_name (owner_id); g_dbus_node_info_unref (introspection_data); return 0; }
/** * Free one of the allocated proxies. */ void loudbus_proxy_free (LouDBusProxy *proxy) { // Sanity check 1. Make sure that it's not NULL. if (proxy == NULL) return; // Sanity check 2. Make sure that it's really an LouDBusProxy. if (! loudbus_proxy_validate (proxy)) return; // Clear the signature (so that we don't identify this as a // LouDBusProxy in the future). proxy->signature = 0; // Clear the proxy. if (proxy->proxy != NULL) { g_object_unref (proxy->proxy); proxy->proxy = NULL; } // if (proxy->proxy != NULL) // Clear the node information. if (proxy->ninfo != NULL) { g_dbus_node_info_unref (proxy->ninfo); proxy->ninfo = NULL; } // if (proxy->ninfo != NULL) // Clear the interface information proxy->iinfo = NULL; // Part of the node info, so not freed separately. // And free the enclosing structure g_free (proxy); } // loudbus_proxy_free
LouDBusProxy * loudbus_proxy_new (gchar *service, gchar *object, gchar *interface, GError **errorp) { LouDBusProxy *proxy; // The proxy we're creating // Allocate space for the struct. proxy = g_malloc0 (sizeof (LouDBusProxy)); if (proxy == NULL) { LOG ("loudbus_proxy_new: Could not allocate proxy."); return NULL; } // if (proxy == NULL) LOG ("Creating proxy for (%s,%s,%s)", service, object, interface); proxy->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, NULL, service, object, interface, NULL, errorp); if (proxy->proxy == NULL) { LOG ("loudbus_proxy_new: Could not build proxy."); g_free (proxy); return NULL; } // if we failed to create the proxy. // Get the node information proxy->ninfo = g_dbus_proxy_get_node_info (proxy->proxy); if (proxy->ninfo == NULL) { LOG ("loudbus_proxy_new: Could not get node info."); g_object_unref (proxy->proxy); g_free (proxy); return NULL; } // if we failed to get node information // Get the interface information proxy->iinfo = g_dbus_node_info_lookup_interface(proxy->ninfo, interface); if (proxy->iinfo == NULL) { LOG ("loudbus_proxy_new: Could not get interface info."); g_object_unref (proxy->proxy); g_dbus_node_info_unref (proxy->ninfo); g_free (proxy); return NULL; } // if we failed to get interface information // We will be looking stuff up in the interface, so build a cache g_dbus_interface_info_cache_build (proxy->iinfo); // Set the signature proxy->signature = loudbus_proxy_signature (); // And we seem to be done return proxy; } // loudbus_proxy_new
void dbus_tear_down(int owner_id) { if (introspection_data) g_dbus_node_info_unref(introspection_data); g_bus_unown_name(owner_id); }
static void tracker_controller_dbus_stop (TrackerController *controller) { TrackerControllerPrivate *priv; priv = controller->priv; if (priv->registration_id != 0) { g_dbus_connection_unregister_object (priv->d_connection, priv->registration_id); } if (priv->bus_name_id != 0) { g_bus_unown_name (priv->bus_name_id); } if (priv->introspection_data) { g_dbus_node_info_unref (priv->introspection_data); } if (priv->d_connection) { g_object_unref (priv->d_connection); } if (priv->connection) { g_object_unref (priv->connection); } }
static void appfinder_gdbus_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_data) { guint register_id; GDBusNodeInfo *info; GError *error = NULL; info = g_dbus_node_info_new_for_xml (appfinder_gdbus_introspection_xml, NULL); g_assert (info != NULL); g_assert (*info->interfaces != NULL); register_id = g_dbus_connection_register_object (connection, APPFINDER_DBUS_PATH, *info->interfaces, /* first iface */ &appfinder_gdbus_vtable, user_data, NULL, &error); APPFINDER_DEBUG ("registered interface with id %d", register_id); if (register_id == 0) { g_message ("Failed to register object: %s", error->message); g_error_free (error); } g_dbus_node_info_unref (info); }
static int _CtSgwGetNumOfNodes(const char *service_name, const char *object_path) { GDBusNodeInfo *node_info; GVariant *result; const gchar *xml_data; GError *error = NULL; int n = 0; result = g_dbus_connection_call_sync (sgw_dbus_service_context->connection, service_name, object_path, "org.freedesktop.DBus.Introspectable", "Introspect", NULL, G_VARIANT_TYPE("(s)"), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); g_assert_nonnull(result); g_variant_get (result, "(&s)", &xml_data); node_info = g_dbus_node_info_new_for_xml (xml_data, &error); g_assert_no_error (error); g_assert_nonnull(node_info); for (n = 0; node_info->nodes != NULL && node_info->nodes[n] != NULL; n++) { ;//do nothing } g_variant_unref(result); g_dbus_node_info_unref (node_info); return n; }
/* Destroy a service object */ void service_free(struct service *service) { START_FUNC g_bus_unown_name(service->owner_id); g_dbus_node_info_unref(service->introspection_data); g_free(service); END_FUNC }
void pp_dbusinput_free (DbusInput *self) { if (self->connection) g_object_unref (self->connection); g_dbus_node_info_unref (self->introspection_data); }
void AbstractDBusInterface::registerObject() { if(!mConnection) { throw std::runtime_error("forgot to call setDBusConnection on AbstractDBusInterface"); } if(introspectionXml.empty()) { cerr<<"no interface to export: "<<mInterfaceName<<endl; throw -1; } if(!boost::algorithm::ends_with(introspectionXml,"</node>")) { introspectionXml += "</interface>" "</node>"; } GError* error=NULL; GDBusNodeInfo* introspection = g_dbus_node_info_new_for_xml(introspectionXml.c_str(), &error); if(!introspection || error) { DebugOut(DebugOut::Error)<<"Error in "<<__FILE__<<" - "<<__FUNCTION__<<":"<<__LINE__<<endl; DebugOut(DebugOut::Error)<<error->message<<endl; DebugOut(DebugOut::Error)<<"probably bad xml:"<<endl; DebugOut(DebugOut::Error)<<introspectionXml<<endl; g_error_free(error); return; } GDBusInterfaceInfo* mInterfaceInfo = g_dbus_node_info_lookup_interface(introspection, mInterfaceName.c_str()); const GDBusInterfaceVTable vtable = { handleMyMethodCall, nullptr, nullptr }; GError* error2=NULL; DebugOut()<<"registering DBus path: "<<mObjectPath<<endl; regId = g_dbus_connection_register_object(mConnection, mObjectPath.c_str(), mInterfaceInfo, &vtable, this, NULL, &error2); g_dbus_node_info_unref(introspection); if(error2) { DebugOut(DebugOut::Error)<<error2->message<<endl; g_error_free(error2); } if(regId == 0) { DebugOut(DebugOut::Error)<<"We failed to register on DBus"<<endl; } }
gboolean close_dlna (SnappyMP * mp) { g_bus_unown_name (mp->owner_id); g_dbus_node_info_unref (introspection_data); g_free (mp->name); return TRUE; }
static void fr_application_finalize (GObject *object) { FrApplication *self = FR_APPLICATION (object); if (self->introspection_data != NULL) g_dbus_node_info_unref (self->introspection_data); if (self->owner_id != 0) g_bus_unown_name (self->owner_id); G_OBJECT_CLASS (fr_application_parent_class)->finalize (object); }
static void tts_cleanup(wrtc_t *wrtc) { if (wrtc->gtts != 0) { g_dbus_connection_unregister_object(wrtc->gdbus, wrtc->gtts); wrtc->gtts = 0; } if (wrtc->intr != NULL) { g_dbus_node_info_unref(wrtc->intr); wrtc->intr = NULL; } }
static void bus_acquired_cb (GDBusConnection *connection, const char *name, gpointer user_data) { static const char dbus_introspection_xml[] = "<node name='/org/mate/Terminal'>" "<interface name='org.mate.Terminal.Factory'>" "<method name='HandleArguments'>" "<arg type='ay' name='working_directory' direction='in' />" "<arg type='ay' name='display_name' direction='in' />" "<arg type='ay' name='startup_id' direction='in' />" "<arg type='ay' name='environment' direction='in' />" "<arg type='i' name='workspace' direction='in' />" "<arg type='ay' name='arguments' direction='in' />" "</method>" "</interface>" "</node>"; static const GDBusInterfaceVTable interface_vtable = { method_call_cb, NULL, NULL, }; OwnData *data = (OwnData *) user_data; GDBusNodeInfo *introspection_data; guint registration_id; GError *error = NULL; _terminal_debug_print (TERMINAL_DEBUG_FACTORY, "Bus %s acquired\n", name); introspection_data = g_dbus_node_info_new_for_xml (dbus_introspection_xml, NULL); g_assert (introspection_data != NULL); registration_id = g_dbus_connection_register_object (connection, TERMINAL_FACTORY_SERVICE_PATH, introspection_data->interfaces[0], &interface_vtable, NULL, NULL, &error); g_dbus_node_info_unref (introspection_data); if (registration_id == 0) { g_printerr ("Failed to register object: %s\n", error->message); g_error_free (error); data->exit_code = EXIT_FAILURE; gtk_main_quit (); } }
/** * urf_device_dispose: **/ static void urf_device_dispose (GObject *object) { UrfDevicePrivate *priv = URF_DEVICE_GET_PRIVATE (object); if (priv->introspection_data) { g_dbus_node_info_unref (priv->introspection_data); priv->introspection_data = NULL; } if (priv->connection) { g_object_unref (priv->connection); priv->connection = NULL; } if (priv->introspection_data) { g_dbus_node_info_unref (priv->introspection_data); priv->introspection_data = NULL; } G_OBJECT_CLASS(urf_device_parent_class)->dispose(object); }
static void prv_connector_shutdown(void) { DLEYNA_LOG_DEBUG("Enter"); if (g_context.objects) g_hash_table_unref(g_context.objects); if (g_context.clients) g_hash_table_unref(g_context.clients); prv_connector_disconnect(); if (g_context.connection) g_object_unref(g_context.connection); if (g_context.server_node_info) g_dbus_node_info_unref(g_context.server_node_info); if (g_context.root_node_info) g_dbus_node_info_unref(g_context.root_node_info); DLEYNA_LOG_DEBUG("Exit"); }
int main (int argc, char *argv[]) { GOptionContext *context = NULL; GError *error = NULL; guint owner_id; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); context = g_option_context_new (N_("- Create and modify an archive")); g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (! g_option_context_parse (context, &argc, &argv, &error)) { g_critical ("Failed to parse arguments: %s", error->message); g_error_free (error); g_option_context_free (context); return EXIT_FAILURE; } g_option_context_free (context); g_set_application_name (_("File Roller")); gtk_window_set_default_icon_name ("file-roller"); gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), PKG_DATA_DIR G_DIR_SEPARATOR_S "icons"); introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); g_assert (introspection_data != NULL); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, FR_SERVICE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); gtk_main (); g_bus_unown_name (owner_id); g_dbus_node_info_unref (introspection_data); return 0; }
static void mex_mpris_plugin_finalize (GObject *object) { MexMprisPluginPrivate *priv = MEX_MPRIS_PLUGIN (object)->priv; if (priv->connection) g_object_unref (priv->connection); g_dbus_node_info_unref (priv->introspection_data); if (priv->mimes_supported) g_strfreev (priv->mimes_supported); G_OBJECT_CLASS (mex_mpris_plugin_parent_class)->finalize (object); }
static void hev_dbus_interface_test_finalize(GObject *obj) { HevDBusInterfaceTest *self = HEV_DBUS_INTERFACE_TEST(obj); HevDBusInterfaceTestPrivate *priv = HEV_DBUS_INTERFACE_TEST_GET_PRIVATE(self); g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); if(priv->node_info) { g_dbus_node_info_unref(priv->node_info); priv->node_info = NULL; } G_OBJECT_CLASS(hev_dbus_interface_test_parent_class)->finalize(obj); }
static void infinoted_plugin_dbus_bus_acquired_func(GDBusConnection* connection, const gchar* name, gpointer user_data) { GDBusNodeInfo* node_info; GDBusInterfaceInfo* interface_info; GDBusInterfaceVTable vtable; GError* error; node_info = g_dbus_node_info_new_for_xml( infinoted_plugin_dbus_introspection, NULL ); g_assert(node_info != NULL); interface_info = g_dbus_node_info_lookup_interface( node_info, "org.infinote.server" ); g_assert(interface_info != NULL); vtable.method_call = infinoted_plugin_dbus_method_call_func; vtable.get_property = NULL; vtable.set_property = NULL; error = NULL; g_dbus_connection_register_object( connection, "/org/infinote/infinoted", interface_info, &vtable, user_data, NULL, &error ); if(error != NULL) { g_warning("Failed to register D-Bus object: %s\n", error->message); g_error_free(error); error = NULL; } g_dbus_node_info_unref(node_info); }
void register_agent_callbacks(gboolean interactive_console, GHashTable *pin_dictonary, gpointer main_loop_object, GError **error) { GDBusInterfaceVTable bt_agent_table; memset(&bt_agent_table, 0x0, sizeof(bt_agent_table)); if(pin_dictonary) _pin_hash_table = pin_dictonary; if(main_loop_object) _mainloop = (GMainLoop *) main_loop_object; _interactive = interactive_console; GDBusNodeInfo *bt_agent_node_info = g_dbus_node_info_new_for_xml(_bt_agent_introspect_xml, error); GDBusInterfaceInfo *bt_agent_interface_info = g_dbus_node_info_lookup_interface(bt_agent_node_info, AGENT_DBUS_INTERFACE); bt_agent_table.method_call = _bt_agent_method_call_func; _bt_agent_registration_id = g_dbus_connection_register_object(g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, error), AGENT_PATH, bt_agent_interface_info, &bt_agent_table, NULL, _bt_agent_g_destroy_notify, error); g_dbus_node_info_unref(bt_agent_node_info); }
int main (int argc, char **argv) { guint owner_id; GMainLoop *loop; g_type_init (); introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL); g_assert (introspection_data != NULL); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, "org.myapp.JelariServer", G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); g_print ("\n Owner id is %d ", owner_id); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); g_bus_unown_name (owner_id); g_dbus_node_info_unref (introspection_data); }
static void finalize(GObject* object) { ZathuraDbus* dbus = ZATHURA_DBUS(object); private_t* priv = GET_PRIVATE(dbus); if (priv->connection != NULL && priv->registration_id > 0) { g_dbus_connection_unregister_object(priv->connection, priv->registration_id); } if (priv->owner_id > 0) { g_bus_unown_name(priv->owner_id); } if (priv->introspection_data != NULL) { g_dbus_node_info_unref(priv->introspection_data); } G_OBJECT_CLASS(zathura_dbus_parent_class)->finalize(object); }
gint main (gint argc, gchar **argv) { GMainLoop *loop; guint owner_id; g_set_prgname ("atril-daemon"); g_type_init (); loop = g_main_loop_new (NULL, FALSE); pending_invocations = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, NULL); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, EV_DBUS_DAEMON_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, bus_acquired_cb, name_acquired_cb, name_lost_cb, g_main_loop_ref (loop), (GDestroyNotify) g_main_loop_unref); g_main_loop_run (loop); g_bus_unown_name (owner_id); g_main_loop_unref (loop); if (introspection_data) g_dbus_node_info_unref (introspection_data); g_list_foreach (ev_daemon_docs, (GFunc)ev_doc_free, NULL); g_list_free (ev_daemon_docs); g_hash_table_destroy (pending_invocations); return 0; }
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); }
int main() { guint owner_id; GMainLoop *loop; g_type_init(); introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL); g_assert(introspection_data != NULL); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, BusName, G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); loop = g_main_loop_new(NULL, FALSE); g_main_loop_run(loop); g_bus_unown_name(owner_id); g_dbus_node_info_unref(introspection_data); return 0; }