Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "main.h"
- #include <dbus/dbus.h>
- #include <dbus/dbus-glib-lowlevel.h>
- #include <dbus/dbus-glib.h>
- #include <dbus/dbus-glib-bindings.h>
- #include "powerview-application-presence.h"
- #include "powerview-application-presence-glue.h"
- #include <unistd.h>
- // http://live.gnome.org/DBusGlibBindings
- // http://moblin.org/documentation/moblin-sdk/coding-tutorials/d-bus-overview
- // http://dbus.freedesktop.org/doc/dbus-tutorial.html
- // http://library.gnome.org/devel/dbus-glib/unstable/dbus-glib-DBusGProxy.html#dbus-g-proxy-new-for-name
- // http://library.gnome.org/devel/dbus-glib/unstable/index.html
- // http://library.gnome.org/devel/dbus-glib/unstable/dbus-glib-DBus-GObject-related-functions.html
- // dbus_g_method_return (context, pong_str);
- static gpointer
- dbus_register_object (DBusGConnection *connection,
- DBusGProxy *proxy,
- GType object_type,
- const DBusGObjectInfo *info,
- const gchar *path)
- {
- GObject *object = g_object_new (object_type, NULL);
- dbus_g_object_type_install_info (object_type, info);
- dbus_g_connection_register_g_object (connection, path, object);
- return object;
- }
- static DBusGConnection* dbus = NULL;
- DBusGProxy* proxy = NULL;
- int
- main (int argc, char *argv[])
- {
- guint result;
- GError* error = NULL;
- PowerviewApplicationPresence * obj = NULL;
- /*
- * Prior to any use of the type system, g_type_init() or gtk_init() has to
- * be called to initialize the type system and assorted other code portions
- * (such as the various fundamental type implementations or the signal
- * system).
- */
- gtk_init(&argc,&argv);
- gchar* bus_name = g_strdup_printf("org.maskwa.PowerviewApplicationPresence_%d",getpid());
- dbus = dbus_g_bus_get(DBUS_BUS_SESSION,&error);
- if (NULL != error) {
- g_error("error establishing dbus connection %s",error->message);
- g_error_free(error);
- return 1;
- }
- proxy = dbus_g_proxy_new_for_name(dbus,
- DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- org_freedesktop_DBus_request_name(proxy,
- bus_name,
- DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);
- obj = dbus_register_object (dbus,
- proxy,
- POWERVIEW_TYPE_APPLICATION_PRESENCE,
- &dbus_glib_powerview_application_presence_object_info,
- "/org/maskwa/powerview_application_presence");
- // use this to investigate signals:
- // http://developer.pidgin.im/wiki/DbusHowto
- //g_signal_emit_by_name(obj,"application_identifier_changed","some new crazy aid",NULL);
- /*dbus_g_proxy_call(proxy, "ApplicationIdentifierChanged", &error, G_TYPE_STRING, "some new crazy aid",G_TYPE_INVALID);
- if (error != NULL) {
- g_warning("dbus_g_proxy_call error %s",error->message);
- }*/
- gtk_main();
- if (NULL != bus_name) g_free(bus_name);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement