gnome-session r4799 - in branches/dbus_based: . gnome-session



Author: mccann
Date: Tue Jul 15 18:07:52 2008
New Revision: 4799
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4799&view=rev

Log:
2008-07-15  William Jon McCann  <jmccann redhat com>

	* gnome-session/Makefile.am:
	* gnome-session/gsm-client.c (register_client),
	(gsm_client_constructor), (gsm_client_class_init):
	* gnome-session/gsm-client.xml:
	Register each client object with the bus.



Added:
   branches/dbus_based/gnome-session/gsm-client.xml
Modified:
   branches/dbus_based/ChangeLog
   branches/dbus_based/gnome-session/Makefile.am
   branches/dbus_based/gnome-session/gsm-client.c
   branches/dbus_based/gnome-session/gsm-client.h

Modified: branches/dbus_based/gnome-session/Makefile.am
==============================================================================
--- branches/dbus_based/gnome-session/Makefile.am	(original)
+++ branches/dbus_based/gnome-session/Makefile.am	Tue Jul 15 18:07:52 2008
@@ -114,10 +114,15 @@
 gsm-manager-glue.h: gsm-manager.xml Makefile.am
 	dbus-binding-tool --prefix=gsm_manager --mode=glib-server --output=gsm-manager-glue.h $(srcdir)/gsm-manager.xml
 
+gsm-client-glue.h: gsm-client.xml Makefile.am
+	dbus-binding-tool --prefix=gsm_client --mode=glib-server --output=gsm-client-glue.h $(srcdir)/gsm-client.xml
+
 BUILT_SOURCES =			\
 	gsm-marshal.c           \
 	gsm-marshal.h           \
-	gsm-manager-glue.h
+	gsm-manager-glue.h	\
+	gsm-client-glue.h	\
+	$(NULL)
 
 CLEANFILES =					\
 	$(BUILT_SOURCES)

Modified: branches/dbus_based/gnome-session/gsm-client.c
==============================================================================
--- branches/dbus_based/gnome-session/gsm-client.c	(original)
+++ branches/dbus_based/gnome-session/gsm-client.c	Tue Jul 15 18:07:52 2008
@@ -23,7 +23,10 @@
 #include "config.h"
 #endif
 
+#include <dbus/dbus-glib.h>
+
 #include "gsm-client.h"
+#include "gsm-client-glue.h"
 
 static guint32 client_serial = 1;
 
@@ -31,10 +34,11 @@
 
 struct GsmClientPrivate
 {
-        char *id;
-        char *client_id;
-        char *app_id;
-        int   status;
+        char            *id;
+        char            *client_id;
+        char            *app_id;
+        int              status;
+        DBusGConnection *connection;
 };
 
 enum {
@@ -68,12 +72,34 @@
         return serial;
 }
 
+static gboolean
+register_client (GsmClient *client)
+{
+        GError *error;
+
+        error = NULL;
+        client->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+        if (client->priv->connection == NULL) {
+                if (error != NULL) {
+                        g_critical ("error getting session bus: %s", error->message);
+                        g_error_free (error);
+                }
+                return FALSE;
+        }
+
+        dbus_g_connection_register_g_object (client->priv->connection, client->priv->id, G_OBJECT (client));
+
+        return TRUE;
+}
+
+
 static GObject *
 gsm_client_constructor (GType                  type,
                         guint                  n_construct_properties,
                         GObjectConstructParam *construct_properties)
 {
-        GsmClient      *client;
+        GsmClient *client;
+        gboolean   res;
 
         client = GSM_CLIENT (G_OBJECT_CLASS (gsm_client_parent_class)->constructor (type,
                                                                                     n_construct_properties,
@@ -82,12 +108,11 @@
         g_free (client->priv->id);
         client->priv->id = g_strdup_printf ("/org/gnome/SessionManager/Client%u", get_next_client_serial ());
 
-#if 0
         res = register_client (client);
         if (! res) {
                 g_warning ("Unable to register client with session bus");
         }
-#endif
+
         return G_OBJECT (client);
 }
 
@@ -246,6 +271,8 @@
                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
         g_type_class_add_private (klass, sizeof (GsmClientPrivate));
+
+        dbus_g_object_type_install_info (GSM_TYPE_CLIENT, &dbus_glib_gsm_client_object_info);
 }
 
 const char *

Modified: branches/dbus_based/gnome-session/gsm-client.h
==============================================================================
--- branches/dbus_based/gnome-session/gsm-client.h	(original)
+++ branches/dbus_based/gnome-session/gsm-client.h	Tue Jul 15 18:07:52 2008
@@ -57,7 +57,7 @@
         GObjectClass parent_class;
 
         /* signals */
-        void     (*disconnected)            (GsmClient *client);
+        void         (*disconnected)        (GsmClient *client);
 
         /* virtual methods */
         void         (*notify_session_over) (GsmClient *client);

Added: branches/dbus_based/gnome-session/gsm-client.xml
==============================================================================
--- (empty file)
+++ branches/dbus_based/gnome-session/gsm-client.xml	Tue Jul 15 18:07:52 2008
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+<node>
+  <interface name="org.gnome.SessionManager.Client">
+
+    <signal name="Stop">
+    </signal>
+
+  </interface>
+</node>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]