[gnome-pilot/dbus] Done on get info method calls:



commit 3ad2531d3e239c070b2b605e3238910d1c390c86
Author: Halton Huo <halton huo sun com>
Date:   Mon Mar 15 18:25:30 2010 +0800

    Done on get info method calls:
    
      org.gnome.GnomePilot.Daemon.GetUserInfo
      org.gnome.GnomePilot.Daemon.GetSystemInfo
    
    Done on get info signals:
      UserInfoRequested
      SysInfoRequested
      RequestCompleted
    
    Tested with gpilotd-control-applet

 gpilotd/Makefile.am            |    4 +-
 gpilotd/gnome-pilot-client.gob |  176 ++++++++++++++++++++++++++++------------
 gpilotd/gpilot-daemon.c        |   55 ++++++++++---
 gpilotd/gpilot-daemon.h        |    4 +-
 gpilotd/gpilot-daemon.xml      |    4 +-
 gpilotd/gpmarshal.list         |    2 +-
 6 files changed, 177 insertions(+), 68 deletions(-)
---
diff --git a/gpilotd/Makefile.am b/gpilotd/Makefile.am
index 4df19b0..a2bb3a8 100644
--- a/gpilotd/Makefile.am
+++ b/gpilotd/Makefile.am
@@ -104,7 +104,7 @@ DBUS_SRCLIST = 		\
 	gpilot-daemon-glue.h \
 	$(NULL)
 
-BUILT_SOURCES = $(DBUS_SRCLIST) $(GOB_BUILT_SRCS) gpmarshal.c gpmarshal.h
+BUILT_SOURCES = $(DBUS_SRCLIST) $(GOB_BUILT_SRCS)
 
 gpilot-daemon-glue.h: gpilot-daemon.xml
 	dbus-binding-tool --prefix=gpilot_daemon --mode=glib-server $< > gpilot-daemon-glue.h
@@ -134,6 +134,8 @@ libgpilotdcm_la_LDFLAGS = \
 
 libgpilotd_la_SOURCES = 		\
 	$(GOB_LIBGPILOTD_BUILT_SRCS)	\
+	gpmarshal.c 			\
+	gpmarshal.h			\
 	$(NULL)
 
 libgpilotdincludedir = $(includedir)/gpilotd
diff --git a/gpilotd/gnome-pilot-client.gob b/gpilotd/gnome-pilot-client.gob
index 836db79..c576c37 100644
--- a/gpilotd/gnome-pilot-client.gob
+++ b/gpilotd/gnome-pilot-client.gob
@@ -48,7 +48,8 @@
 #include <gio/gio.h>
 #include <gtk/gtkobject.h>
 
-#include <gpilotd/gpilot-daemon.h>
+#include "gpilotd/gpilot-daemon.h"
+#include "gpilotd/gpmarshal.h"
 
 #define GP_DBUS_NAME              "org.gnome.GnomePilot"
 #define GP_DBUS_PATH              "/org/gnome/GnomePilot/Daemon"
@@ -73,35 +74,15 @@ pid_t gpilotd_get_pid (void);
 %}
 
 class Gnome:Pilot:Client from Gtk:Object {
-	public gchar *client_id;
 	public DBusGConnection *connection;
 	public DBusGProxy *proxy;
 
 	class_init (class) {
 		GtkObjectClass   *object_class = GTK_OBJECT_CLASS (class);
-		
-	/*
-		object_class->_get_client_id = self_dbus_get_client_id;
-		object_class->_set_client_id = self_dbus_set_client_id;
-		object_class->connect = self_dbus_connect;
-		object_class->disconnect = self_dbus_disconnect;
-		object_class->request_completed = self_dbus_request_completed;
-		object_class->userinfo_requested = self_dbus_user_info_requested;
-		object_class->sysinfo_requested = self_dbus_system_info_requested;
-		object_class->conduit_start = self_dbus_conduit_start;
-		object_class->conduit_end = self_dbus_conduit_end;
-		object_class->overall_progress = self_dbus_overall_progress;
-		object_class->conduit_progress = self_dbus_conduit_progress;
-		object_class->conduit_message = self_dbus_conduit_message;
-		object_class->daemon_message = self_dbus_daemon_message;
-		object_class->daemon_error = self_dbus_daemon_error;
-		object_class->conduit_error = self_dbus_conduit_error;
-		object_class->pause = self_dbus_pause;
-	*/
 	}
 
 	init (self) {
-		self->client_id = NULL;
+
 	}
 
 	public GtkObject*
@@ -126,7 +107,6 @@ class Gnome:Pilot:Client from Gtk:Object {
 
 	public void destroy (self) {
 		self->proxy = NULL;
-		g_free (self->client_id);
 		/* FIXME: ick, what more to do here ? */
 	}
 	
@@ -141,19 +121,24 @@ class Gnome:Pilot:Client from Gtk:Object {
 
 		if (self->proxy == NULL)
 			return GPILOTD_ERR_NOT_CONNECTED;
-		return GPILOTD_OK;
-	}
 
-	private gchar*
-	dbus_get_client_id (self) {
-		return g_strdup (self->client_id);
-	}
-	
-	private void
-	dbus_set_client_id (self,
-			    const gchar *id) {
-		g_free (self->client_id);
-		self->client_id = g_strdup (id);
+                dbus_g_object_register_marshaller (gp_marshal_VOID__STRING_UINT,
+                                           G_TYPE_NONE,
+                                           G_TYPE_STRING,
+                                           G_TYPE_INT,
+                                           G_TYPE_INVALID);
+                dbus_g_proxy_add_signal (self->proxy,
+                                         "RequestCompleted",
+                                         G_TYPE_STRING,
+                                         G_TYPE_INT,
+                                         G_TYPE_INVALID);
+                dbus_g_proxy_connect_signal (self->proxy,
+                                     "RequestCompleted",
+                                     G_CALLBACK (self_dbus_request_completed),
+                                     self,
+                                     NULL);
+
+		return GPILOTD_OK;
 	}
 
 	private void
@@ -170,24 +155,61 @@ class Gnome:Pilot:Client from Gtk:Object {
 	}
  
 	private void
-	dbus_request_completed (self,
+	dbus_request_completed (DBusGProxy  *proxy,
 				const gchar *pilot_id,				
-				unsigned long id) {
-		self_completed_request (self,pilot_id,id);
+				guint32      id,
+                                gpointer     data) {
+                Self *self = SELF(data);
+
+                g_debug ("Get signal 'RequestCompleted'");
+		self_completed_request (self, pilot_id, id);
 	}
 
-	private void
-	dbus_user_info_requested (self,
-				  const gchar *pilot_id,
-				  const GNOME_Pilot_UserInfo *user) {
-		self_user_info (self,pilot_id,user);
+	public void
+	dbus_user_info_requested (DBusGProxy  *proxy,
+                                  const gchar *pilot_id,
+                                  guint32      uid,
+				  const gchar *username,
+                                  gpointer     data) {
+                Self *self = SELF(data);
+                GNOME_Pilot_UserInfo user;
+
+                g_debug ("Get signal 'UserInfoRequested'");
+                user.userID = uid;
+                user.username = g_strdup (username);
+
+		self_user_info (self, pilot_id, &user);
+
+                g_free (user.username);
 	}
 
 	private void
-	dbus_system_info_requested (self,
-				    const gchar *device,				
-				    const GNOME_Pilot_SysInfo *sysinfo) {
-		self_system_info (self,device,sysinfo);
+	dbus_system_info_requested (DBusGProxy  *proxy,
+                                    const gchar *device,
+				    guint32      rom_size,
+				    guint32      ram_size,
+				    guint32      ram_free,
+				    const gchar *name,
+				    const gchar *manufacturer,
+				    guint32      creation,
+				    guint32      rom_version,
+                                    gpointer     data) {
+                Self *self = SELF(data);
+                GNOME_Pilot_SysInfo sysinfo;
+
+                g_debug ("Get signal 'SysInfoRequested'");
+                sysinfo.romSize = rom_size;
+                sysinfo.ramSize = ram_size;
+                sysinfo.ramFree = ram_free;
+                sysinfo.name = g_strdup (name);
+                sysinfo.manufacturer = g_strdup (manufacturer);
+                sysinfo.creation = creation;
+                sysinfo.romVersion = rom_version;
+
+		self_system_info (self, device, &sysinfo);
+
+                g_free (sysinfo.name);
+                g_free (sysinfo.manufacturer);
 	}
 
 	private void
@@ -303,7 +325,9 @@ class Gnome:Pilot:Client from Gtk:Object {
 	void progress_overall (self, 
 			       const gchar *pilot_name,
 			       guint current, guint total)
-	{}
+	{
+                return;
+        }
 
 	signal first NONE (POINTER,POINTER,POINTER)
 	void message_conduit (self, const gchar *pilot_name, const gchar *conduit_name, const gchar *message) {
@@ -721,6 +745,25 @@ error:		if (file_copied == FALSE) {
 		gboolean  res;
 
 		g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+
+                dbus_g_object_register_marshaller (gp_marshal_VOID__STRING_UINT_STRING,
+                                           G_TYPE_NONE,
+                                           G_TYPE_STRING,
+                                           G_TYPE_INT,
+                                           G_TYPE_STRING,
+                                           G_TYPE_INVALID);
+                dbus_g_proxy_add_signal (self->proxy,
+                                         "UserInfoRequested",
+                                         G_TYPE_STRING,
+                                         G_TYPE_INT,
+                                         G_TYPE_STRING,
+                                         G_TYPE_INVALID);
+                dbus_g_proxy_connect_signal (self->proxy,
+                                     "UserInfoRequested",
+                                     G_CALLBACK (self_dbus_user_info_requested),
+                                     self,
+                                     NULL);
+
 		error = NULL;
 		res = dbus_g_proxy_call (self->proxy,
 					"GetUserInfo",
@@ -760,10 +803,10 @@ error:		if (file_copied == FALSE) {
 					"SetUserInfo",
 					&error,
 					G_TYPE_STRING, cradle_name,
-					G_TYPE_BOOLEAN, &continue_sync,
-					G_TYPE_UINT, &survival,
-					G_TYPE_UINT, &timeout,
-					G_TYPE_UINT, &(user.userID),
+					G_TYPE_BOOLEAN, continue_sync,
+					G_TYPE_UINT, survival,
+					G_TYPE_UINT, timeout,
+					G_TYPE_UINT, user.userID,
 					G_TYPE_STRING, user.username,
 					G_TYPE_INVALID,
 					G_TYPE_UINT, &val,
@@ -790,6 +833,35 @@ error:		if (file_copied == FALSE) {
 		gboolean  res;
 
 		g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+
+                dbus_g_object_register_marshaller (gp_marshal_VOID__STRING_UINT_UINT_UINT_STRING_STRING_UINT_UINT,
+                                           G_TYPE_NONE,
+                                           G_TYPE_STRING,
+                                           G_TYPE_INT,
+                                           G_TYPE_INT,
+                                           G_TYPE_INT,
+                                           G_TYPE_STRING,
+                                           G_TYPE_STRING,
+                                           G_TYPE_INT,
+                                           G_TYPE_INT,
+                                           G_TYPE_INVALID);
+                dbus_g_proxy_add_signal (self->proxy,
+                                         "SysInfoRequested",
+                                         G_TYPE_STRING,
+                                         G_TYPE_INT,
+                                         G_TYPE_INT,
+                                         G_TYPE_INT,
+                                         G_TYPE_STRING,
+                                         G_TYPE_STRING,
+                                         G_TYPE_INT,
+                                         G_TYPE_INT,
+                                         G_TYPE_INVALID);
+                dbus_g_proxy_connect_signal (self->proxy,
+                                     "SysInfoRequested",
+                                     G_CALLBACK (self_dbus_system_info_requested),
+                                     self,
+                                     NULL);
+
 		error = NULL;
 		res = dbus_g_proxy_call (self->proxy,
 					"GetSystemInfo",
diff --git a/gpilotd/gpilot-daemon.c b/gpilotd/gpilot-daemon.c
index 695a8fd..a680cf6 100644
--- a/gpilotd/gpilot-daemon.c
+++ b/gpilotd/gpilot-daemon.c
@@ -2786,15 +2786,10 @@ dbus_notify_completion (GPilotRequest **req)
         DBusMessageIter iter;
         gchar          *pilot_name;
 
-        GpilotDaemon   *daemon;
-
-        daemon = GPILOT_DAEMON (daemon_object);
         g_return_if_fail(req!=NULL);
         g_return_if_fail(*req!=NULL);
 
-        /* resolve pilot id */
-        pilot_name = pilot_name_from_id ((*req)->pilot_id, 
-                                         daemon->priv->gpilotd_context);
+        pilot_name = g_strdup ((*req)->cradle);
 
         message = dbus_message_new_signal (GP_DBUS_PATH,
                                            GP_DBUS_INTERFACE,
@@ -2811,6 +2806,7 @@ dbus_notify_completion (GPilotRequest **req)
         dbus_connection_unref (connection);
         dbus_message_unref (message);
 
+        gpc_queue_purge_request (req);
         g_free (pilot_name);
 }
 
@@ -2821,6 +2817,11 @@ dbus_notify_userinfo (struct PilotUser    user_info,
         DBusMessage    *message;
         DBusConnection *connection;
         DBusMessageIter iter;
+        gchar          *username;
+
+        /* do a strcpy for username to sending sending too long
+         string by dbus */
+        username = g_strdup (user_info.username);
 
         message = dbus_message_new_signal (GP_DBUS_PATH,
                                            GP_DBUS_INTERFACE,
@@ -2831,12 +2832,14 @@ dbus_notify_userinfo (struct PilotUser    user_info,
         dbus_message_iter_init_append (message, &iter);
         dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &(*req)->cradle);
         dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &user_info.userID);
-        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &user_info.username);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &username);
 
         connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
         dbus_connection_send (connection, message, NULL);
         dbus_connection_unref (connection);
         dbus_message_unref (message);
+
+        g_free (username);
 }
 
 void
@@ -2845,8 +2848,40 @@ dbus_notify_sysinfo (const gchar      *pilot_id,
                      struct CardInfo   cardinfo,
                      GPilotRequest   **req)
 {
-}
+        GNOME_Pilot_SysInfo _sysinfo;
+        DBusMessage    *message;
+        DBusConnection *connection;
+        DBusMessageIter iter;
+
+        _sysinfo.romSize = cardinfo.romSize/1024;
+        _sysinfo.ramSize = cardinfo.ramSize/1024;
+        _sysinfo.ramFree = cardinfo.ramFree/1024;
+        _sysinfo.name = g_strdup (cardinfo.name);
+        _sysinfo.manufacturer = g_strdup (cardinfo.manufacturer);
+        _sysinfo.creation = cardinfo.creation;
+        _sysinfo.romVersion = sysinfo.romVersion;
 
+        message = dbus_message_new_signal (GP_DBUS_PATH,
+                                           GP_DBUS_INTERFACE,
+                                           "SysInfoRequested");
+
+        dbus_message_set_destination (message, GP_DBUS_NAME);
+
+        dbus_message_iter_init_append (message, &iter);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &pilot_id);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &_sysinfo.romSize);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &_sysinfo.ramSize);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &_sysinfo.ramFree);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &_sysinfo.name);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &_sysinfo.manufacturer);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &_sysinfo.creation);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &_sysinfo.romVersion);
+
+        connection = dbus_bus_get (DBUS_BUS_SESSION, NULL);
+        dbus_connection_send (connection, message, NULL);
+        dbus_connection_unref (connection);
+        dbus_message_unref (message);
+}
 
 void
 dbus_notify_conduit_start (const gchar              *pilot_id,
@@ -3009,7 +3044,7 @@ gpilot_daemon_class_init (GpilotDaemonClass *klass)
                                             G_STRUCT_OFFSET (GpilotDaemonClass, sys_info_requested),
                                             NULL,
                                             NULL,
-                                            gp_marshal_VOID__STRING_UINT_UINT_UINT_STRING_STRING_STRING_UINT,
+                                            gp_marshal_VOID__STRING_UINT_UINT_UINT_STRING_STRING_UINT_UINT,
                                             G_TYPE_NONE,
                                             8,
                                             G_TYPE_STRING,
@@ -3018,7 +3053,7 @@ gpilot_daemon_class_init (GpilotDaemonClass *klass)
                                             G_TYPE_UINT,
                                             G_TYPE_STRING,
                                             G_TYPE_STRING,
-                                            G_TYPE_STRING,
+                                            G_TYPE_UINT,
                                             G_TYPE_UINT);
         signals [CONDUIT_START] = g_signal_new ("conduit-start",
                                             G_TYPE_FROM_CLASS (object_class),
diff --git a/gpilotd/gpilot-daemon.h b/gpilotd/gpilot-daemon.h
index 7af15e1..c816d84 100644
--- a/gpilotd/gpilot-daemon.h
+++ b/gpilotd/gpilot-daemon.h
@@ -63,14 +63,14 @@ typedef struct
                                               const char     *device,
                                               unsigned long   uid,
                                               const char     *username);
-        void          (* sys_info_requested)  (GpilotDaemon   *gpilot,
+        void          (* sys_info_requested) (GpilotDaemon   *gpilot,
                                               const char     *pilot_id,
                                               int             rom_size,
                                               int             ram_size,
                                               int             ram_free,
                                               const char     *name,
                                               const char     *manufacturer,
-                                              const char     *creation,
+                                              int             creation,
                                               int             rom_version);
         void          (* conduit_start)      (GpilotDaemon   *gpilot,
                                               const char     *pilot_id,
diff --git a/gpilotd/gpilot-daemon.xml b/gpilotd/gpilot-daemon.xml
index 3d92cd8..1b1c069 100644
--- a/gpilotd/gpilot-daemon.xml
+++ b/gpilotd/gpilot-daemon.xml
@@ -428,12 +428,12 @@
           <doc:summary>The time out by second.</doc:summary>
         </doc:doc>
       </arg>
-      <arg name="uid" direction="out" type="u">
+      <arg name="uid" direction="in" type="u">
         <doc:doc>
           <doc:summary>The returned user id.</doc:summary>
         </doc:doc>
       </arg>
-      <arg name="username" direction="out" type="s">
+      <arg name="username" direction="in" type="s">
         <doc:doc>
           <doc:summary>The returned user name.</doc:summary>
         </doc:doc>
diff --git a/gpilotd/gpmarshal.list b/gpilotd/gpmarshal.list
index 8c6b7bb..29c6e6c 100644
--- a/gpilotd/gpmarshal.list
+++ b/gpilotd/gpmarshal.list
@@ -13,4 +13,4 @@ VOID:STRING,UINT,STRING
 VOID:STRING,STRING,STRING
 VOID:STRING,STRING,UINT,UINT
 VOID:STRING,UINT,UINT
-VOID:STRING,UINT,UINT,UINT,STRING,STRING,STRING,UINT
+VOID:STRING,UINT,UINT,UINT,STRING,STRING,UINT,UINT



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