Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2010
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.02 KB | None | 0 0
  1. #include "main.h"
  2. #include <dbus/dbus.h>
  3. #include <dbus/dbus-glib-lowlevel.h>
  4. #include <dbus/dbus-glib.h>
  5. #include <dbus/dbus-glib-bindings.h>
  6. #include "powerview-application-presence.h"
  7. #include "powerview-application-presence-glue.h"
  8. #include <unistd.h>
  9.  
  10. // http://live.gnome.org/DBusGlibBindings
  11. // http://moblin.org/documentation/moblin-sdk/coding-tutorials/d-bus-overview
  12. // http://dbus.freedesktop.org/doc/dbus-tutorial.html
  13. // http://library.gnome.org/devel/dbus-glib/unstable/dbus-glib-DBusGProxy.html#dbus-g-proxy-new-for-name
  14. // http://library.gnome.org/devel/dbus-glib/unstable/index.html
  15. // http://library.gnome.org/devel/dbus-glib/unstable/dbus-glib-DBus-GObject-related-functions.html
  16. // dbus_g_method_return (context, pong_str);
  17.  
  18. static gpointer
  19. dbus_register_object (DBusGConnection *connection,
  20.                       DBusGProxy *proxy,
  21.                       GType object_type,
  22.                       const DBusGObjectInfo *info,
  23.                       const gchar *path)
  24. {
  25.         GObject *object = g_object_new (object_type, NULL);
  26.         dbus_g_object_type_install_info (object_type, info);
  27.         dbus_g_connection_register_g_object (connection, path, object);
  28.         return object;
  29. }
  30.  
  31. static DBusGConnection* dbus = NULL;
  32. DBusGProxy* proxy = NULL;
  33.  
  34. int
  35. main (int argc, char *argv[])
  36. {
  37.     guint   result;
  38.     GError* error = NULL;
  39.     PowerviewApplicationPresence * obj = NULL;
  40.    
  41.    
  42.     /*
  43.      * Prior to any use of the type system, g_type_init() or gtk_init() has to
  44.      * be called to initialize the type system and assorted other code portions
  45.      * (such as the various fundamental type implementations or the signal
  46.      * system).
  47.      */
  48.     gtk_init(&argc,&argv);
  49.    
  50.    
  51.     gchar* bus_name = g_strdup_printf("org.maskwa.PowerviewApplicationPresence_%d",getpid());
  52.    
  53.    
  54.    
  55.     dbus = dbus_g_bus_get(DBUS_BUS_SESSION,&error);
  56.     if (NULL != error) {
  57.         g_error("error establishing dbus connection %s",error->message);
  58.         g_error_free(error);
  59.         return 1;
  60.     }
  61.    
  62.     proxy = dbus_g_proxy_new_for_name(dbus,
  63.         DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
  64.    
  65.     org_freedesktop_DBus_request_name(proxy,
  66.                 bus_name,
  67.                 DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);
  68.    
  69.     obj = dbus_register_object (dbus,
  70.                 proxy,
  71.                 POWERVIEW_TYPE_APPLICATION_PRESENCE,
  72.                 &dbus_glib_powerview_application_presence_object_info,
  73.                 "/org/maskwa/powerview_application_presence");
  74.    
  75.    
  76.     // use this to investigate signals:
  77.     // http://developer.pidgin.im/wiki/DbusHowto
  78.    
  79.    
  80.    
  81.    
  82.     //g_signal_emit_by_name(obj,"application_identifier_changed","some new crazy aid",NULL);
  83.    
  84.     /*dbus_g_proxy_call(proxy, "ApplicationIdentifierChanged", &error, G_TYPE_STRING, "some new crazy aid",G_TYPE_INVALID);
  85.     if (error != NULL) {
  86.         g_warning("dbus_g_proxy_call error %s",error->message);
  87.     }*/
  88.    
  89.     gtk_main();
  90.    
  91.    
  92.    
  93.     if (NULL != bus_name) g_free(bus_name);
  94.    
  95.    
  96.     return 0;
  97. }
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement