[gnome-pilot/dbus] Convert corba to dbus calls in gnome-pilot-client.gob
- From: Halton Huo <haltonhuo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-pilot/dbus] Convert corba to dbus calls in gnome-pilot-client.gob
- Date: Mon, 8 Mar 2010 03:44:21 +0000 (UTC)
commit cd5d6cf8a4441f5068593f5777f005a934f008a9
Author: Halton Huo <halton huo sun com>
Date: Thu Mar 4 17:30:56 2010 +0800
Convert corba to dbus calls in gnome-pilot-client.gob
.gitignore | 1 +
gpilotd/gnome-pilot-client.gob | 1415 +++++++++++++++++++++++-----------------
gpilotd/gpilot-daemon.c | 5 +-
gpilotd/gpilot-daemon.h | 25 +-
gpilotd/gpilot-daemon.xml | 2 +-
5 files changed, 843 insertions(+), 605 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b60e21b..171ef96 100644
--- a/.gitignore
+++ b/.gitignore
@@ -92,3 +92,4 @@ utils/gpilotdcm-client
po/*.gmo
cscope*
*.swp
+*.bak
diff --git a/gpilotd/gnome-pilot-client.gob b/gpilotd/gnome-pilot-client.gob
index 3608db7..2cd9165 100644
--- a/gpilotd/gnome-pilot-client.gob
+++ b/gpilotd/gnome-pilot-client.gob
@@ -18,6 +18,7 @@
* Boston, MA 02111-1307, USA.
*
* Authors: Eskil Heyn Olsen <eskil eskil org>
+ * Halton Huo <haltonhuo gnome org>
*
*/
@@ -40,13 +41,20 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <gtk/gtkobject.h>
-#include <bonobo-activation/bonobo-activation.h>
-#include <libbonobo.h>
-#include <gpilotd/gnome-pilot.h>
+#include <sys/types.h>
+#include <signal.h>
#include <glib.h>
#include <gio/gio.h>
+#include <gtk/gtkobject.h>
+
+#include <gpilotd/gpilot-daemon.h>
+
+#define GP_DBUS_NAME "org.gnome.GPilotd"
+#define GP_DBUS_PATH "/org/gnome/GPilotd"
+#define GP_DBUS_INTERFACE "org.gnome.GPilotd"
+
+#define IS_STR_SET(x) (x != NULL && x[0] != '\0')
enum GPilotdErrCode {
GPILOTD_OK=0,
@@ -60,315 +68,199 @@ enum GPilotdErrCode {
%{
-#include <sys/types.h>
-#include <signal.h>
-
-typedef struct {
- POA_GNOME_Pilot_Client servant;
- GnomePilotClient *self;
-} GnomePilotClientServant;
-
-GnomePilotClient* get_self (PortableServer_Servant servant);
pid_t gpilotd_get_pid (void);
-PortableServer_ServantBase__epv base_epv = {
- NULL,
- NULL,
- NULL
-};
-
-static POA_GNOME_Pilot_Client__epv gnome_pilot_client_epv;
-static POA_GNOME_Pilot_Client__vepv gnome_pilot_client_vepv = { &base_epv, &gnome_pilot_client_epv };
-
-enum get_triple_ptr_action {
- GPILOTD_APP_PILOT_NAMES,
- GPILOTD_APP_PILOT_IDS,
- GPILOTD_APP_PILOTS_BY_NAME,
- GPILOTD_APP_PILOTS_BY_LOGIN,
- GPILOTD_APP_USER_NAMES,
- GPILOTD_APP_DATABASES_FROM_CACHE,
- GPILOTD_APP_CRADLES
-};
-
%}
class Gnome:Pilot:Client from Gtk:Object {
- public GNOME_Pilot_Daemon gpilotddaemon;
- public GNOME_Pilot_Client gpilotdclient;
- public CORBA_Environment ev;
- public CORBA_char *client_id;
- public CORBA_ORB orb;
+ public gchar *client_id;
+ public DBusGConnection *connection;
+ public DBusGProxy *proxy;
class_init (class) {
- }
-
- private void init_corba_class (self) {
- static gboolean inited = FALSE;
+ GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
- if (inited==FALSE) {
- self->client_id = NULL;
- inited = TRUE;
- gnome_pilot_client_epv._get_client_id = self_corba_get_client_id;
- gnome_pilot_client_epv._set_client_id = self_corba_set_client_id;
- gnome_pilot_client_epv.connect = self_corba_connect;
- gnome_pilot_client_epv.disconnect = self_corba_disconnect;
- gnome_pilot_client_epv.request_completed = self_corba_request_completed;
- gnome_pilot_client_epv.userinfo_requested = self_corba_user_info_requested;
- gnome_pilot_client_epv.sysinfo_requested = self_corba_system_info_requested;
- gnome_pilot_client_epv.conduit_start = self_corba_conduit_start;
- gnome_pilot_client_epv.conduit_end = self_corba_conduit_end;
- gnome_pilot_client_epv.overall_progress = self_corba_overall_progress;
- gnome_pilot_client_epv.conduit_progress = self_corba_conduit_progress;
- gnome_pilot_client_epv.conduit_message = self_corba_conduit_message;
- gnome_pilot_client_epv.daemon_message = self_corba_daemon_message;
- gnome_pilot_client_epv.daemon_error = self_corba_daemon_error;
- gnome_pilot_client_epv.conduit_error = self_corba_conduit_error;
- gnome_pilot_client_epv.pause = self_corba_pause;
- }
+ /*
+ 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) {
- int argc=0;
- char *argv=NULL;
- CORBA_Environment *ev;
- PortableServer_POA the_poa;
- GnomePilotClientServant *gnome_pilot_client_servant;
-
- ev = &(self->ev);
- self_init_corba_class (self);
-
- CORBA_exception_init (ev);
-
- if (!bonobo_activation_is_initialized ())
- self->orb = bonobo_activation_init (argc, &argv);
- else
- self->orb = bonobo_activation_orb_get ();
-
- g_assert (self->orb!=NULL);
-
- gnome_pilot_client_servant = g_new0(GnomePilotClientServant,1);
- gnome_pilot_client_servant->servant.vepv =
- &gnome_pilot_client_vepv;
- gnome_pilot_client_servant->self = self;
-
- the_poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references (self->orb,"RootPOA",ev);
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",
- __FILE__,__LINE__,
- CORBA_exception_id (ev));
- CORBA_exception_free (ev);
- }
+ self->client_id = NULL;
+ }
- PortableServer_POAManager_activate (PortableServer_POA__get_the_POAManager (the_poa, ev), ev);
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",
- __FILE__,__LINE__,
- CORBA_exception_id (ev));
- CORBA_exception_free (ev);
- }
+ public GtkObject*
+ new (void) {
+ GError *error;
+ GnomePilotClient *ret;
- POA_GNOME_Pilot_Client__init ((PortableServer_Servant)gnome_pilot_client_servant,ev);
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",
- __FILE__,__LINE__,
- CORBA_exception_id (ev));
- CORBA_exception_free (ev);
- }
+ error = NULL;
+ ret = GET_NEW;
- CORBA_free (
- PortableServer_POA_activate_object (the_poa,
- gnome_pilot_client_servant,
- ev)
- );
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",
- __FILE__,__LINE__,
- CORBA_exception_id (ev));
- CORBA_exception_free (ev);
+ ret->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (ret->connection == NULL) {
+ if (error != NULL) {
+ g_critical ("error getting session bus: %s", error->message);
+ g_error_free (error);
}
-
- self->gpilotdclient =
- PortableServer_POA_servant_to_reference (the_poa,
- gnome_pilot_client_servant,
- ev);
- if (ev->_major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (ev));
- CORBA_exception_free (ev);
- }
- }
+ return NULL;
+ }
- public GtkObject*
- new (void) {
- GnomePilotClient *ret = GET_NEW;
return GTK_OBJECT (ret);
}
- public void destroy (self) {
+ public void destroy (self) {
+ self->proxy = NULL;
g_free (self->client_id);
/* FIXME: ick, what more to do here ? */
- }
+ }
- public gint connect_to_daemon (self) {
- Bonobo_ServerInfoList *list;
- CORBA_Environment *ev;
-
- ev = &(self->ev);
- list = bonobo_activation_query ("repo_ids.has ('IDL:GNOME/Pilot/Daemon:2.0')", NULL, ev);
- if (list->_length == 0) {
- return GPILOTD_ERR_NOT_CONNECTED;
- } else {
- Bonobo_ServerInfo info;
- info = list->_buffer[0];
- g_message ("Activating object %s", info.iid);
- self->gpilotddaemon = bonobo_activation_activate_from_id (info.iid,
- Bonobo_ACTIVATION_FLAG_NO_LOCAL, NULL, NULL);
+ public gint connect_to_daemon (self) {
+ if (!self->proxy) {
+ self->proxy = dbus_g_proxy_new_for_name (
+ self->connection,
+ GP_DBUS_NAME,
+ GP_DBUS_PATH,
+ GP_DBUS_INTERFACE);
}
- CORBA_free (list);
- CORBA_exception_free (ev);
-
- if (self->gpilotddaemon == NULL) return GPILOTD_ERR_NOT_CONNECTED;
+ if (self->proxy == NULL)
+ return GPILOTD_ERR_NOT_CONNECTED;
return GPILOTD_OK;
}
- private CORBA_char*
- corba_get_client_id (PortableServer_Servant servant,
- CORBA_Environment *ev) {
- gchar *id;
- id = get_self (servant)->client_id;
- if (id==NULL) return CORBA_string_dup ("");
- return CORBA_string_dup (id);
+ private gchar*
+ dbus_get_client_id (self) {
+ return g_strdup (self->client_id);
}
private void
- corba_set_client_id (PortableServer_Servant servant,
- const CORBA_char *id,
- CORBA_Environment *ev) {
- if (get_self (servant)->client_id!=NULL) {
- /* throw exception */
- g_assert (0);
- } get_self (servant)->client_id = g_strdup (id);
+ dbus_set_client_id (self,
+ const gchar *id) {
+ g_free (self->client_id);
+ self->client_id = g_strdup (id);
}
private void
- corba_connect (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const GNOME_Pilot_UserInfo *user,
- CORBA_Environment *ev) {
- self_pilot_connect (get_self (servant),pilot_id,user);
+ dbus_connect (self,
+ const gchar *pilot_id,
+ const UserInfo *user) {
+ self_pilot_connect (self, pilot_id, user);
}
private void
- corba_disconnect (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- CORBA_Environment *ev) {
- self_pilot_disconnect (get_self (servant),pilot_id);
+ dbus_disconnect (self,
+ const gchar *pilot_id) {
+ self_pilot_disconnect (self, pilot_id);
}
private void
- corba_request_completed (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- CORBA_unsigned_long id,
- CORBA_Environment *ev) {
- self_completed_request (get_self (servant),pilot_id,id);
+ dbus_request_completed (self,
+ const gchar *pilot_id,
+ unsigned long id) {
+ self_completed_request (self,pilot_id,id);
}
private void
- corba_user_info_requested (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const GNOME_Pilot_UserInfo *user,
- CORBA_Environment *ev) {
- self_user_info (get_self (servant),pilot_id,user);
+ dbus_user_info_requested (self,
+ const gchar *pilot_id,
+ const UserInfo *user) {
+ self_user_info (self,pilot_id,user);
}
private void
- corba_system_info_requested (PortableServer_Servant servant,
- const CORBA_char *device,
- const GNOME_Pilot_SysInfo *sysinfo,
- CORBA_Environment *ev) {
- self_system_info (get_self (servant),device,sysinfo);
+ dbus_system_info_requested (self,
+ const gchar *device,
+ const SysInfo *sysinfo) {
+ self_system_info (self,device,sysinfo);
}
private void
- corba_conduit_start (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const CORBA_char *conduit_name,
- const CORBA_char *database,
- CORBA_Environment *ev) {
- self_start_conduit (get_self (servant),pilot_id,conduit_name,database);
+ dbus_conduit_start (self,
+ const gchar *pilot_id,
+ const gchar *conduit_name,
+ const gchar *database) {
+ self_start_conduit (self,pilot_id,conduit_name,database);
}
private void
- corba_conduit_end (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const CORBA_char *conduit_name,
- CORBA_Environment *ev) {
- self_end_conduit (get_self (servant),pilot_id,conduit_name);
+ dbus_conduit_end (self,
+ const gchar *pilot_id,
+ const gchar *conduit_name) {
+ self_end_conduit (self,pilot_id,conduit_name);
}
private void
- corba_overall_progress (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const CORBA_unsigned_long current,
- const CORBA_unsigned_long total,
- CORBA_Environment *ev) {
- self_progress_overall (get_self (servant),pilot_id, current, total);
+ dbus_overall_progress (self,
+ const gchar *pilot_id,
+ const unsigned long current,
+ const unsigned long total) {
+ self_progress_overall (self,pilot_id, current, total);
}
private void
- corba_conduit_progress (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const CORBA_char *conduit_name,
- const CORBA_unsigned_long current,
- const CORBA_unsigned_long total,
- CORBA_Environment *ev) {
- self_progress_conduit (get_self (servant),pilot_id,conduit_name,current,total);
+ dbus_conduit_progress (self,
+ const gchar *pilot_id,
+ const gchar *conduit_name,
+ const unsigned long current,
+ const unsigned long total) {
+ self_progress_conduit (self,pilot_id,conduit_name,current,total);
}
private void
- corba_conduit_message (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const CORBA_char *conduit_name,
- const CORBA_char *message,
- CORBA_Environment *ev) {
- self_message_conduit (get_self (servant),pilot_id,conduit_name,message);
+ dbus_conduit_message (self,
+ const gchar *pilot_id,
+ const gchar *conduit_name,
+ const gchar *message) {
+ self_message_conduit (self,pilot_id,conduit_name,message);
}
private void
- corba_daemon_message (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const CORBA_char *conduit_name,
- const CORBA_char *message,
- CORBA_Environment *ev) {
- self_message_daemon (get_self (servant),pilot_id,conduit_name,message);
+ dbus_daemon_message (self,
+ const gchar *pilot_id,
+ const gchar *conduit_name,
+ const gchar *message) {
+ self_message_daemon (self,pilot_id,conduit_name,message);
}
private void
- corba_daemon_error (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const CORBA_char *message,
- CORBA_Environment *ev) {
- self_error_daemon (get_self (servant), pilot_id, message);
+ dbus_daemon_error (self,
+ const gchar *pilot_id,
+ const gchar *message) {
+ self_error_daemon (self, pilot_id, message);
}
private void
- corba_conduit_error (PortableServer_Servant servant,
- const CORBA_char *pilot_id,
- const CORBA_char *conduit_name,
- const CORBA_char *message,
- CORBA_Environment *ev) {
- self_error_conduit (get_self (servant),pilot_id,conduit_name,message);
+ dbus_conduit_error (self,
+ const gchar *pilot_id,
+ const gchar *conduit_name,
+ const gchar *message) {
+ self_error_conduit (self,pilot_id,conduit_name,message);
}
private void
- corba_pause (PortableServer_Servant servant,
- const CORBA_boolean on_off,
- CORBA_Environment *ev) {
- self_daemon_pause (get_self (servant), on_off);
+ dbus_pause (self,
+ gboolean on_off) {
+ self_daemon_pause (self, on_off);
}
signal first NONE (POINTER,POINTER)
- void pilot_connect (self, const gchar *pilot_name, const GNOME_Pilot_UserInfo *userinfo) {
+ void pilot_connect (self, const gchar *pilot_name, const UserInfo *userinfo) {
return;
}
@@ -383,12 +275,12 @@ class Gnome:Pilot:Client from Gtk:Object {
}
signal first NONE (POINTER,POINTER)
- void user_info (self, const gchar *device, const GNOME_Pilot_UserInfo *userinfo) {
+ void user_info (self, const gchar *device, const UserInfo *userinfo) {
return;
}
signal first NONE (POINTER,POINTER)
- void system_info (self, const gchar *device, const GNOME_Pilot_SysInfo *sysinfo) {
+ void system_info (self, const gchar *device, const SysInfo *sysinfo) {
return;
}
@@ -439,36 +331,71 @@ class Gnome:Pilot:Client from Gtk:Object {
}
public gint pause_daemon (self) onerror GPILOTD_ERR_INVAL {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
+ GError *error;
+ gboolean res;
+ gboolean pause;
- GNOME_Pilot_Daemon_pause (self->gpilotddaemon,TRUE,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ pause = TRUE;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "Pause",
+ &error,
+ G_TYPE_BOOLEAN, &pause,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to pause daemon : %s", error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
+
return GPILOTD_OK;
}
public gint unpause_daemon (self) onerror GPILOTD_ERR_INVAL {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
+ GError *error;
+ gboolean res;
+ gboolean pause;
- GNOME_Pilot_Daemon_pause (self->gpilotddaemon,FALSE,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ pause = FALSE;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "Pause",
+ &error,
+ G_TYPE_BOOLEAN, &pause,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to unpause daemon : %s", error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
+
return GPILOTD_OK;
}
public gint reread_config (self) onerror GPILOTD_ERR_INVAL {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
+ GError *error;
+ gboolean res;
- GNOME_Pilot_Daemon_reread_config (self->gpilotddaemon, &self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "RereadConfig",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to reread config : %s", error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
@@ -476,14 +403,24 @@ class Gnome:Pilot:Client from Gtk:Object {
}
public gint noop (self) onerror GPILOTD_ERR_INVAL {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
+ GError *error;
+ gboolean res;
- GNOME_Pilot_Daemon_noop (self->gpilotddaemon, &self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
- return GPILOTD_ERR_NOT_CONNECTED;
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "Noop",
+ &error,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to noop : %s", error->message);
+ g_error_free (error);
+ return GPILOTD_ERR_FAILED;
}
+
return GPILOTD_OK;
}
@@ -502,14 +439,28 @@ class Gnome:Pilot:Client from Gtk:Object {
public gint monitor_on (self,
const gchar *pilot_id (check null)) onerror GPILOTD_ERR_INVAL {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
- GNOME_Pilot_Daemon_monitor_on (self->gpilotddaemon,self->gpilotdclient,pilot_id,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ GError *error;
+ gboolean res;
+ gboolean on;
+
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ on = TRUE;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "Monitor",
+ &error,
+ G_TYPE_STRING, pilot_id,
+ G_TYPE_BOOLEAN, &on,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to turn off monitor for pilot %s: %s", pilot_id, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
+
return GPILOTD_OK;
}
@@ -529,15 +480,28 @@ class Gnome:Pilot:Client from Gtk:Object {
public gint monitor_off (self,
const gchar *pilot_id (check null)) onerror GPILOTD_ERR_INVAL {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
+ GError *error;
+ gboolean res;
+ gboolean on;
- GNOME_Pilot_Daemon_monitor_off (self->gpilotddaemon,self->gpilotdclient,pilot_id,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ on = FALSE;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "Monitor",
+ &error,
+ G_TYPE_STRING, pilot_id,
+ G_TYPE_BOOLEAN, &on,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to turn off monitor for pilot %s: %s", pilot_id, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
+
return GPILOTD_OK;
}
@@ -549,75 +513,97 @@ class Gnome:Pilot:Client from Gtk:Object {
if (self_get_pilots (self,&pilots) != GPILOTD_OK) return GPILOTD_ERR_FAILED;
for (ptr = pilots; ptr; ptr = ptr->next) {
- ret = self_monitor_on (self,(gchar*)ptr->data);
+ ret = self_monitor_off (self,(gchar*)ptr->data);
}
g_list_foreach (pilots,(GFunc)g_free,NULL);
return ret;
}
public gint notify_on (self,
- GNOME_Pilot_EventType type) {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
-
- GNOME_Pilot_Daemon_notify_on (self->gpilotddaemon,type,self->gpilotdclient,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ EventType type) {
+ GError *error;
+ gboolean res;
+ gboolean on;
+
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ on = TRUE;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "EventNotify",
+ &error,
+ G_TYPE_INT, &type,
+ G_TYPE_BOOLEAN, &on,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to turn on notification for event %d: %s", type, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
+
return GPILOTD_OK;
}
public gint notify_off (self,
- GNOME_Pilot_EventType type) onerror GPILOTD_ERR_INVAL {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
-
- GNOME_Pilot_Daemon_notify_off (self->gpilotddaemon,type,self->gpilotdclient,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ EventType type) onerror GPILOTD_ERR_INVAL {
+ GError *error;
+ gboolean res;
+ gboolean on;
+
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ on = FALSE;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "EventNotify",
+ &error,
+ G_TYPE_INT, &type,
+ G_TYPE_BOOLEAN, &on,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to turn on notification for event %d: %s", type, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
+
return GPILOTD_OK;
}
public gint restore (self,
const gchar *pilot_id (check null),
const gchar *directory (check null),
- GNOME_Pilot_Survival survival,
+ Survival survival,
gint timeout (check >= 0),
gint *handle) onerror GPILOTD_ERR_INVAL {
- gint val;
-
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
-
- val = GNOME_Pilot_Daemon_request_restore (self->gpilotddaemon,
- self->gpilotdclient,
- pilot_id,
- directory,
- survival,
- timeout,
- &self->ev);
- switch (self->ev._major) {
- case CORBA_SYSTEM_EXCEPTION:
- case CORBA_USER_EXCEPTION: {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- if (strcmp (ex_GNOME_Pilot_MissingFile,CORBA_exception_id (&self->ev))==0) {
- g_warning ("Missing file");
- }
- CORBA_exception_free (&self->ev);
+ GError *error;
+ gboolean res;
+ gint val;
+
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "RequestRestore",
+ &error,
+ G_TYPE_STRING, pilot_id,
+ G_TYPE_STRING, directory,
+ G_TYPE_UINT, &survival,
+ G_TYPE_UINT, &timeout,
+ G_TYPE_INVALID,
+ G_TYPE_ULONG, &val,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to RequestRestore for pilot %s: %s", pilot_id, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
- break;
- }
- case CORBA_NO_EXCEPTION:
- default:
- break;
}
- if (handle!=NULL) *handle = val;
+ if (handle != NULL) *handle = val;
return GPILOTD_OK;
}
@@ -625,21 +611,20 @@ class Gnome:Pilot:Client from Gtk:Object {
public gint install_file (self,
const gchar *pilot_name (check null),
const gchar *infile (check null),
- GNOME_Pilot_Survival survival,
+ Survival survival,
gint timeout (check >=0),
gint *handle) onerror GPILOTD_ERR_INVAL {
- gint val;
+ gint val;
+ gboolean res;
gboolean file_copied = FALSE;
- gchar *filename;
+ gchar *filename;
+ GError *error;
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
-
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
/* g_message ("Installing %s to %s", infile, pilot_name); */
{
gboolean result;
- GError *err;
GFileCopyFlags copy_options = G_FILE_COPY_OVERWRITE;
GFile *src_gfile;
GFile *dest_gfile;
@@ -681,13 +666,13 @@ class Gnome:Pilot:Client from Gtk:Object {
NULL,
NULL,
self,
- &err);
+ &error);
if (result) {
file_copied = TRUE;
} else {
g_message("VFS Error: %s\n",
- err->message);
+ error->message);
file_copied = FALSE;
}
g_free (filename_uri);
@@ -701,35 +686,26 @@ error: if (file_copied == FALSE) {
return GPILOTD_ERR_FAILED;
}
- val = GNOME_Pilot_Daemon_request_install (self->gpilotddaemon,
- self->gpilotdclient,
- pilot_name,
- filename,
- infile,
- survival,
- timeout,
- &self->ev);
- switch (self->ev._major) {
- case CORBA_NO_EXCEPTION:
- break;
- case CORBA_SYSTEM_EXCEPTION:
- case CORBA_USER_EXCEPTION:
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
-
- if (strcmp (ex_GNOME_Pilot_MissingFile,CORBA_exception_id (&self->ev))==0) {
- g_warning ("Missing file");
- } else {
- unlink (filename);
- }
- CORBA_exception_free (&self->ev);
- free (filename);
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "RequestInstall",
+ &error,
+ G_TYPE_STRING, pilot_name,
+ G_TYPE_STRING, filename,
+ G_TYPE_STRING, infile,
+ G_TYPE_UINT, &survival,
+ G_TYPE_UINT, &timeout,
+ G_TYPE_INVALID,
+ G_TYPE_ULONG, &val,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to RequestInstall for pilot %s: %s", pilot_name, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
- break;
- default:
- break;
}
- if (handle!=NULL) *handle = val;
+ if (handle != NULL) *handle = val;
free (filename);
return GPILOTD_OK;
@@ -737,310 +713,546 @@ error: if (file_copied == FALSE) {
public gint get_user_info (self,
gchar *cradle_name (check null),
- GNOME_Pilot_Survival survival,
+ Survival survival,
gint timeout (check >= 0),
gint *handle) onerror GPILOTD_ERR_INVAL {
- gint val;
-
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
-
- val = GNOME_Pilot_Daemon_get_user_info (self->gpilotddaemon,
- self->gpilotdclient,
- cradle_name,
- survival,
- timeout,
- &self->ev);
-
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ gint val;
+ GError *error;
+ gboolean res;
+
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "GetUserInfo",
+ &error,
+ G_TYPE_STRING, cradle_name,
+ G_TYPE_UINT, &survival,
+ G_TYPE_UINT, &timeout,
+ G_TYPE_INVALID,
+ G_TYPE_ULONG, &val,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetUserInfo for cradle %s: %s", cradle_name, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
- if (handle!=NULL) *handle =val;
+ if (handle != NULL) *handle =val;
return GPILOTD_OK;
}
public gint set_user_info (self,
gchar *cradle_name (check null),
- GNOME_Pilot_UserInfo user,
+ UserInfo user,
gboolean continue_sync,
- GNOME_Pilot_Survival survival,
+ Survival survival,
gint timeout (check >= 0),
gint *handle) onerror GPILOTD_ERR_INVAL {
- gint val;
-
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
-
- val = GNOME_Pilot_Daemon_set_user_info (self->gpilotddaemon,
- self->gpilotdclient,
- &user,
- cradle_name,
- continue_sync,
- survival,
- timeout,
- &self->ev);
-
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ gint val;
+ GError *error;
+ gboolean res;
+
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "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_STRING, user.username,
+ G_TYPE_INVALID,
+ G_TYPE_ULONG, &val,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to SetUserInfo for cradle %s: %s", cradle_name, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
- if (handle!=NULL) *handle =val;
+ if (handle != NULL) *handle =val;
return GPILOTD_OK;
}
public gint get_system_info (self,
gchar *cradle_name (check null),
- GNOME_Pilot_Survival survival,
+ Survival survival,
gint timeout,
gint *handle) onerror GPILOTD_ERR_INVAL {
- gint val;
-
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
-
- val = GNOME_Pilot_Daemon_get_system_info (self->gpilotddaemon,
- self->gpilotdclient,
- cradle_name,
- survival,
- timeout,
- &self->ev);
-
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ gint val;
+ GError *error;
+ gboolean res;
+
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "GetSystemInfo",
+ &error,
+ G_TYPE_STRING, cradle_name,
+ G_TYPE_UINT, &survival,
+ G_TYPE_UINT, &timeout,
+ G_TYPE_INVALID,
+ G_TYPE_ULONG, &val,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetSystemInfo for cradle %s: %s", cradle_name, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
- if (handle!=NULL) *handle =val;
+ if (handle != NULL) *handle =val;
return GPILOTD_OK;
}
public gint remove_request (self,
gint handle) onerror GPILOTD_ERR_INVAL {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
-
- GNOME_Pilot_Daemon_remove_request (self->gpilotddaemon,handle,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ GError *error;
+ gboolean res;
+
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "RemoveRequest",
+ &error,
+ G_TYPE_UINT, &handle,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to RemoveRequest for handle %d: %s", handle, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
+
return GPILOTD_OK;
}
public gint conduit (self,
const gchar *pilot_name (check null),
const gchar *conduit_name (check null),
- GNOME_Pilot_ConduitOperation operation,
- GNOME_Pilot_Survival survival,
+ ConduitOperation operation,
+ Survival survival,
gint timeout (check >= 0),
gint *handle) onerror GPILOTD_ERR_INVAL {
- gint val;
-
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
- g_return_val_if_fail (self->gpilotdclient!=NULL, GPILOTD_ERR_INTERNAL);
-
- val = GNOME_Pilot_Daemon_request_conduit (self->gpilotddaemon,
- self->gpilotdclient,
- pilot_name,
- conduit_name,
- operation,
- survival,
- timeout,
- &self->ev);
-
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ gint val;
+ GError *error;
+ gboolean res;
+
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "RequestConduit",
+ &error,
+ G_TYPE_STRING, pilot_name,
+ G_TYPE_STRING, conduit_name,
+ G_TYPE_UINT, &operation,
+ G_TYPE_UINT, &survival,
+ G_TYPE_UINT, &timeout,
+ G_TYPE_INVALID,
+ G_TYPE_ULONG, &val,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetSystemInfo for pilot %s: %s", pilot_name, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
- if (handle!=NULL) *handle =val;
+ if (handle != NULL) *handle =val;
return GPILOTD_OK;
}
- private gint get_triple_ptr (self,
- enum get_triple_ptr_action action,
- const gchar *name,
- GList **output (check null)) onerror GPILOTD_ERR_INVAL {
- GNOME_Pilot_StringSequence *seq=NULL;
- GNOME_Pilot_LongSequence *seq_long=NULL;
-
+ public gint get_users (self,
+ GList **output (check null)) onerror GPILOTD_ERR_INVAL {
+ GError *error;
+ gboolean res;
+ GPtrArray *arr;
+ int i;
+
#ifndef G_DISABLE_CHECKS
- if (*output!=NULL) {
- g_warning ("%s:%d: get_triple_ptr called with non-null pointer for output, leak-alert!",
+ if (*output != NULL) {
+ g_warning ("%s:%d: get_users called with non-null pointer for output, leak-alert!",
__FILE__,__LINE__);
}
#endif
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ arr = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "GetPilots",
+ &error,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
+ &arr,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetPilots %s", error->message);
+ g_error_free (error);
+ return GPILOTD_ERR_FAILED;
+ }
(*output) = NULL;
+ for (i = 0; i < arr->len; i++) {
+ char *str_tmp;
- switch (action) {
- case GPILOTD_APP_PILOT_NAMES:
- seq = GNOME_Pilot_Daemon_get_pilots (self->gpilotddaemon, &self->ev);
- break;
- case GPILOTD_APP_PILOT_IDS:
- seq_long = GNOME_Pilot_Daemon_get_pilot_ids (self->gpilotddaemon, &self->ev);
- break;
- case GPILOTD_APP_PILOTS_BY_NAME:
- seq = GNOME_Pilot_Daemon_get_pilots_by_user_name (self->gpilotddaemon,name,&self->ev);
- break;
- case GPILOTD_APP_PILOTS_BY_LOGIN:
- seq = GNOME_Pilot_Daemon_get_pilots_by_user_login (self->gpilotddaemon,name,&self->ev);
- break;
- case GPILOTD_APP_USER_NAMES:
- seq = GNOME_Pilot_Daemon_get_users (self->gpilotddaemon,&self->ev);
- break;
- case GPILOTD_APP_DATABASES_FROM_CACHE:
- seq = GNOME_Pilot_Daemon_get_databases_from_cache (self->gpilotddaemon,name,&self->ev);
- break;
- case GPILOTD_APP_CRADLES:
- seq = GNOME_Pilot_Daemon_get_cradles (self->gpilotddaemon,&self->ev);
- break;
- }
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
- return GPILOTD_ERR_FAILED;
- }
- if (seq && seq->_length>0) {
- int i;
- for (i=0;i<seq->_length;i++) {
- if (strlen (seq->_buffer[i]))
- (*output) = g_list_append ((*output),g_strdup (seq->_buffer[i]));
- }
- }
- if (seq_long && seq_long->_length>0) {
- int i;
- for (i=0;i<seq_long->_length;i++) {
+ str_tmp = g_ptr_array_index (arr, i);
+ if (IS_STR_SET (str_tmp) ) {
(*output) = g_list_append ((*output),
- GINT_TO_POINTER (seq_long->_buffer[i]));
+ g_strdup (str_tmp));
}
- }
-
- CORBA_free (seq);
- CORBA_free (seq_long);
+ g_free (str_tmp);
+ str_tmp = NULL;
+ }
- return GPILOTD_OK;
- }
+ g_ptr_array_free (arr, TRUE);
- public gint get_users (self,
- GList **output (check null)) onerror GPILOTD_ERR_INVAL {
- return self_get_triple_ptr (self,GPILOTD_APP_USER_NAMES,NULL,output);
+ return GPILOTD_OK;
}
public gint get_databases_from_cache (self,
const gchar *pilot_name,
GList **output (check null)) onerror GPILOTD_ERR_INVAL {
- return self_get_triple_ptr (self,GPILOTD_APP_DATABASES_FROM_CACHE,pilot_name,output);
+ GError *error;
+ gboolean res;
+ GPtrArray *arr;
+ int i;
+
+#ifndef G_DISABLE_CHECKS
+ if (*output != NULL) {
+ g_warning ("%s:%d: get_databases_from_cache called with non-null pointer for output, leak-alert!",
+ __FILE__,__LINE__);
+ }
+#endif
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ arr = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "GetDatabasesFromCache",
+ &error,
+ G_TYPE_STRING, pilot_name,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
+ &arr,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetDatabasesFromCache %s : %s", pilot_name, error->message);
+ g_error_free (error);
+ return GPILOTD_ERR_FAILED;
+ }
+
+ (*output) = NULL;
+ for (i = 0; i < arr->len; i++) {
+ char *str_tmp;
+
+ str_tmp = g_ptr_array_index (arr, i);
+ if (IS_STR_SET (str_tmp) ) {
+ (*output) = g_list_append ((*output),
+ g_strdup (str_tmp));
+ }
+ g_free (str_tmp);
+ str_tmp = NULL;
+ }
+
+ g_ptr_array_free (arr, TRUE);
+ return GPILOTD_OK;
}
public gint get_cradles (self,
GList **output (check null)) onerror GPILOTD_ERR_INVAL {
- return self_get_triple_ptr (self,GPILOTD_APP_CRADLES,NULL,output);
+ GError *error;
+ gboolean res;
+ GPtrArray *arr;
+ int i;
+
+#ifndef G_DISABLE_CHECKS
+ if (*output != NULL) {
+ g_warning ("%s:%d: get_cradles called with non-null pointer for output, leak-alert!",
+ __FILE__,__LINE__);
+ }
+#endif
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ arr = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "GetCradles",
+ &error,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
+ &arr,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetCradles: %s", error->message);
+ g_error_free (error);
+ return GPILOTD_ERR_FAILED;
+ }
+
+ (*output) = NULL;
+ for (i = 0; i < arr->len; i++) {
+ char *str_tmp;
+
+ str_tmp = g_ptr_array_index (arr, i);
+ if (IS_STR_SET (str_tmp) ) {
+ (*output) = g_list_append ((*output),
+ g_strdup (str_tmp));
+ }
+ g_free (str_tmp);
+ str_tmp = NULL;
+ }
+
+ g_ptr_array_free (arr, TRUE);
+ return GPILOTD_OK;
}
public gint get_pilots (self,
GList **output (check null)) onerror GPILOTD_ERR_INVAL {
- return self_get_triple_ptr (self,GPILOTD_APP_PILOT_NAMES,NULL,output);
+ GError *error;
+ gboolean res;
+ GPtrArray *arr;
+ int i;
+
+#ifndef G_DISABLE_CHECKS
+ if (*output != NULL) {
+ g_warning ("%s:%d: get_pilots called with non-null pointer for output, leak-alert!",
+ __FILE__,__LINE__);
+ }
+#endif
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ arr = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "GetPilots",
+ &error,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
+ &arr,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetPilots: %s", error->message);
+ g_error_free (error);
+ return GPILOTD_ERR_FAILED;
+ }
+
+ (*output) = NULL;
+ for (i = 0; i < arr->len; i++) {
+ char *str_tmp;
+
+ str_tmp = g_ptr_array_index (arr, i);
+ if (IS_STR_SET (str_tmp) ) {
+ (*output) = g_list_append ((*output),
+ g_strdup (str_tmp));
+ }
+ g_free (str_tmp);
+ str_tmp = NULL;
+ }
+
+ g_ptr_array_free (arr, TRUE);
+ return GPILOTD_OK;
}
public gint get_pilot_ids (self,
gint **output (check null)) onerror GPILOTD_ERR_INVAL {
- GList *long_output = NULL, *ptr;
- gint result, idx;
+ GError *error;
+ gboolean res;
+ GPtrArray *arr;
+ int i;
- result = self_get_triple_ptr (self, GPILOTD_APP_PILOT_IDS, NULL, &long_output);
+#ifndef G_DISABLE_CHECKS
+ if (*output != NULL) {
+ g_warning ("%s:%d: get_pilot_ids called with non-null pointer for output, leak-alert!",
+ __FILE__,__LINE__);
+ }
+#endif
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ arr = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "GetPilotIDs",
+ &error,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_UINT),
+ &arr,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetPilotIDs: %s", error->message);
+ g_error_free (error);
+ return GPILOTD_ERR_FAILED;
+ }
- (*output) = g_new0 (int, g_list_length (long_output));
- idx = 0;
- for (ptr = long_output; ptr; ptr = g_list_next (ptr)) {
- (*output)[idx] = GPOINTER_TO_INT (ptr->data);
- idx++;
+ (*output) = g_new0 (int, g_list_length (arr->len));
+ for (i = 0; i < arr->len; i++) {
+ (*output)[i] = GPOINTER_TO_INT (g_ptr_array_index (arr, i));
}
- g_list_free (long_output);
- return result;
+ g_ptr_array_free (arr, TRUE);
+ return GPILOTD_OK;
}
public gint get_pilots_by_user_name (self,
const gchar *name (check null),
GList **output (check null)) onerror GPILOTD_ERR_INVAL {
- return self_get_triple_ptr (self,GPILOTD_APP_PILOTS_BY_NAME,name,output);
+ GError *error;
+ gboolean res;
+ GPtrArray *arr;
+ int i;
+
+#ifndef G_DISABLE_CHECKS
+ if (*output != NULL) {
+ g_warning ("%s:%d: get_pilots_by_user_name called with non-null pointer for output, leak-alert!",
+ __FILE__,__LINE__);
+ }
+#endif
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ arr = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "GetPilotsByUserName",
+ &error,
+ G_TYPE_STRING, name,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
+ &arr,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetPilotsByUserName %s : %s", name, error->message);
+ g_error_free (error);
+ return GPILOTD_ERR_FAILED;
+ }
+
+ (*output) = NULL;
+ for (i = 0; i < arr->len; i++) {
+ char *str_tmp;
+
+ str_tmp = g_ptr_array_index (arr, i);
+ if (IS_STR_SET (str_tmp) ) {
+ (*output) = g_list_append ((*output),
+ g_strdup (str_tmp));
+ }
+ g_free (str_tmp);
+ str_tmp = NULL;
+ }
+
+ g_ptr_array_free (arr, TRUE);
+ return GPILOTD_OK;
}
public gint get_pilots_by_user_login (self,
const gchar *login (check null),
GList **output (check null)) onerror GPILOTD_ERR_INVAL {
- return self_get_triple_ptr (self,GPILOTD_APP_PILOTS_BY_LOGIN,login,output);
- }
+ GError *error;
+ gboolean res;
+ GPtrArray *arr;
+ int i;
- public gint get_user_name_by_pilot_name (self,
- const gchar *pilot_name (check null),
- gchar **output (check null)) onerror GPILOTD_ERR_INVAL {
- CORBA_char *user_name = NULL;
-
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
#ifndef G_DISABLE_CHECKS
- if (*output!=NULL) {
- g_warning ("%s:%d: get_user_name_by_pilot_name called with non-null pointer for output, leak-alert!",
+ if (*output != NULL) {
+ g_warning ("%s:%d: get_pilots_by_user_login called with non-null pointer for output, leak-alert!",
__FILE__,__LINE__);
}
#endif
- user_name = GNOME_Pilot_Daemon_get_user_name_by_pilot_name (self->gpilotddaemon,
- pilot_name,
- &self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__,
- CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ g_return_val_if_fail (self->proxy != NULL, GPILOTD_ERR_NOT_CONNECTED);
+ error = NULL;
+ arr = NULL;
+
+ res = dbus_g_proxy_call (self->proxy,
+ "GetPilotsByUserLogin",
+ &error,
+ G_TYPE_STRING, login,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
+ &arr,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetPilotsByUserLogin %s : %s", login, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
-
- *output = g_strdup (user_name);
- CORBA_free (user_name);
- return GPILOTD_OK;
+ (*output) = NULL;
+ for (i = 0; i < arr->len; i++) {
+ char *str_tmp;
+
+ str_tmp = g_ptr_array_index (arr, i);
+ if (IS_STR_SET (str_tmp) ) {
+ (*output) = g_list_append ((*output),
+ g_strdup (str_tmp));
+ }
+ g_free (str_tmp);
+ str_tmp = NULL;
+ }
+
+ g_ptr_array_free (arr, TRUE);
+ return GPILOTD_OK;
+ }
+
+ public gint get_user_name_by_pilot_name (self,
+ const gchar *pilot_name (check null),
+ gchar **output (check null)) onerror GPILOTD_ERR_INVAL {
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "GetUserNameByPilotName",
+ &error,
+ G_TYPE_STRING, pilot_name,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, output,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetUserNameByPilotName %s : %s", pilot_name, error->message);
+ g_error_free (error);
+ return GPILOTD_ERR_FAILED;
+ }
+
+ return GPILOTD_OK;
}
public gint get_user_login_by_pilot_name (self,
const gchar *pilot_name (check null),
gchar **output (check null)) onerror GPILOTD_ERR_INVAL {
- CORBA_char *user_login = NULL;
-
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
-#ifndef G_DISABLE_CHECKS
- if (*output!=NULL) {
- g_warning ("%s:%d: get_user_login_by_pilot_name called with non-null pointer for output, leak-alert!",
- __FILE__,__LINE__);
- }
-#endif
- user_login = GNOME_Pilot_Daemon_get_user_login_by_pilot_name (self->gpilotddaemon,
- pilot_name,
- &self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__,
- CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "GetUserLoginByPilotName",
+ &error,
+ G_TYPE_STRING, pilot_name,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, output,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetUserLoginByPilotName %s : %s", pilot_name, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
-
- *output = g_strdup (user_login);
- CORBA_free (user_login);
- return GPILOTD_OK;
+ return GPILOTD_OK;
}
/* Output must be a pointer to a gchar*, and *output should be
@@ -1050,31 +1262,31 @@ error: if (file_copied == FALSE) {
public gint get_pilot_base_dir_by_name (self,
const gchar *pilot_name (check null),
gchar **output (check null)) onerror GPILOTD_ERR_INVAL {
- CORBA_char *basedir;
-
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
-#ifndef G_DISABLE_CHECKS
- if (*output!=NULL) {
- g_warning ("%s:%d: get_pilot_base_dir_by_name called with non-null pointer for output, leak-alert!",
- __FILE__,__LINE__);
- }
-#endif
- basedir = GNOME_Pilot_Daemon_get_pilot_base_dir (self->gpilotddaemon,pilot_name,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "GetPilotBaseDir",
+ &error,
+ G_TYPE_STRING, pilot_name,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, output,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetPilotBaseDir %s : %s", pilot_name, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
-
- *output = g_strdup (basedir);
- CORBA_free (basedir);
-
- if (strlen (*output)==0) {
+
+ if (!IS_STR_SET (*output)) {
g_free (*output);
- *output = g_strdup_printf ("%s/%s",g_get_home_dir (),pilot_name);
+ *output = g_strdup_printf ("%s/%s",g_get_home_dir (),
+ pilot_name);
}
- return GPILOTD_OK;
+ return GPILOTD_OK;
}
public gint get_pilot_base_dir_by_id (self,
@@ -1083,12 +1295,12 @@ error: if (file_copied == FALSE) {
gchar *pilot_name;
gint return_code;
- return_code = self_get_pilot_name_by_id (self,pilot_id,&pilot_name);
- if (return_code!=GPILOTD_OK) {
+ return_code = self_get_pilot_name_by_id (self, pilot_id, &pilot_name);
+ if (return_code != GPILOTD_OK) {
return return_code;
}
- return_code = self_get_pilot_base_dir_by_name (self,pilot_name,output);
+ return_code = self_get_pilot_base_dir_by_name (self, pilot_name, output);
g_free (pilot_name);
return return_code;
}
@@ -1097,39 +1309,49 @@ error: if (file_copied == FALSE) {
public gint get_pilot_id_by_name (self,
const gchar *pilot_name (check null),
guint32 *output (check null)) onerror GPILOTD_ERR_INVAL {
- g_return_val_if_fail (self->gpilotddaemon!=NULL, GPILOTD_ERR_NOT_CONNECTED);
-
- *output = GNOME_Pilot_Daemon_get_pilot_id_from_name (self->gpilotddaemon,pilot_name,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "GetPilotIdFromName",
+ &error,
+ G_TYPE_STRING, pilot_name,
+ G_TYPE_INVALID,
+ G_TYPE_INT, output,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetPilotIdFromName %s : %s", pilot_name, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
-
- return GPILOTD_OK;
+
+ return GPILOTD_OK;
}
public gint get_pilot_name_by_id (self,
guint32 pilot_id,
gchar **output (check null)) onerror GPILOTD_ERR_INVAL {
- CORBA_char *name;
-#ifndef G_DISABLE_CHECKS
- if (*output!=NULL) {
- g_warning ("%s:%d: get_pilot_name_by_id called with non-null pointer for output, leak-alert!",
- __FILE__,__LINE__);
- }
-#endif
- name = GNOME_Pilot_Daemon_get_pilot_name_from_id (self->gpilotddaemon,pilot_id,&self->ev);
- if (self->ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("%s:%d: Caught exception: %s",__FILE__,__LINE__, CORBA_exception_id (&self->ev));
- CORBA_exception_free (&self->ev);
+ GError *error;
+ gboolean res;
+
+ error = NULL;
+ res = dbus_g_proxy_call (self->proxy,
+ "GetPilotNameFromId",
+ &error,
+ G_TYPE_INT, &pilot_id,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, output,
+ G_TYPE_INVALID);
+
+ if (!res) {
+ g_warning ("Unable to GetPilotNameFromId %d : %s", pilot_id, error->message);
+ g_error_free (error);
return GPILOTD_ERR_FAILED;
}
-
- *output = g_strdup (name);
- CORBA_free (name);
-
- if (output==NULL || strlen (*output)==0) {
+
+ if (!IS_STR_SET (output)) {
g_free (*output);
return GPILOTD_ERR_FAILED;
}
@@ -1176,11 +1398,4 @@ gpilotd_get_pid (void)
}
}
-GnomePilotClient *
-get_self (PortableServer_Servant servant) {
- GnomePilotClientServant *s;
- s = (GnomePilotClientServant*)servant;
- return s->self;
-}
-
%}
diff --git a/gpilotd/gpilot-daemon.c b/gpilotd/gpilot-daemon.c
index a53504b..db4d6ea 100644
--- a/gpilotd/gpilot-daemon.c
+++ b/gpilotd/gpilot-daemon.c
@@ -98,7 +98,7 @@ match_pilot_userID (const GPilotPilot *p,
return -1;
}
-static guint32
+guint32
pilot_id_from_name (const gchar *name,
GPilotContext *context)
{
@@ -110,7 +110,7 @@ pilot_id_from_name (const gchar *name,
return 0;
}
-static gchar*
+gchar*
pilot_name_from_id (guint32 id,
GPilotContext *context)
{
@@ -124,7 +124,6 @@ pilot_name_from_id (guint32 id,
return NULL;
}
-
GQuark
gpilot_daemon_error_quark (void)
{
diff --git a/gpilotd/gpilot-daemon.h b/gpilotd/gpilot-daemon.h
index 8bcfb47..1569fc4 100644
--- a/gpilotd/gpilot-daemon.h
+++ b/gpilotd/gpilot-daemon.h
@@ -22,10 +22,12 @@
#ifndef __GPILOT_DAEMON_H
#define __GPILOT_DAEMON_H
+G_BEGIN_DECLS
+
#include <glib-object.h>
#include <dbus/dbus-glib.h>
-G_BEGIN_DECLS
+#include "gnome-pilot-structures.h"
#define GPILOT_TYPE_DAEMON (gpilot_daemon_get_type ())
#define GPILOT_DAEMON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPILOT_TYPE_DAEMON, GpilotDaemon))
@@ -52,6 +54,21 @@ typedef struct
const char *user);
} GpilotDaemonClass;
+typedef struct {
+ unsigned long userID;
+ gchar *username;
+} UserInfo;
+
+typedef struct {
+ long romSize;
+ long ramSize;
+ long ramFree;
+ char *name;
+ char *manufacturer;
+ long creation;
+ long romVersion;
+} SysInfo;
+
typedef enum
{
IMMEDIATE,
@@ -219,6 +236,12 @@ gboolean gpilot_daemon_event_notify (GpilotDaemon *daemon,
EventType event_type,
gboolean on,
GError **error);
+
+/* general functions */
+guint32 pilot_id_from_name (const gchar *name,
+ GPilotContext *context);
+gchar* pilot_name_from_id (guint32 id,
+ GPilotContext *context);
G_END_DECLS
#endif /* __GPILOT_DAEMON_H */
diff --git a/gpilotd/gpilot-daemon.xml b/gpilotd/gpilot-daemon.xml
index a67cc71..4aa4c3a 100644
--- a/gpilotd/gpilot-daemon.xml
+++ b/gpilotd/gpilot-daemon.xml
@@ -295,7 +295,7 @@
<doc:summary>The pilot name.</doc:summary>
</doc:doc>
</arg>
- <arg name="uid" direction="out" type="u">
+ <arg name="uid" direction="out" type="s">
<doc:doc>
<doc:summary>The returned user id.</doc:summary>
</doc:doc>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]