[gnome-pilot/dbus] Rework dbus method calls:
- From: Halton Huo <haltonhuo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-pilot/dbus] Rework dbus method calls:
- Date: Wed, 17 Mar 2010 10:35:10 +0000 (UTC)
commit e73e8cfe15bc2ddb7a5f7bc2dc87a7d00ad36144
Author: Halton Huo <halton huo sun com>
Date: Wed Mar 17 18:31:07 2010 +0800
Rework dbus method calls:
RequestInstall
RequestRestore
RequestConduit
Tested with
gpilotd_client --pilot=MyPDA --install=/tmp/1
gpilotd_client --pilot=MyPDA --restore=/tmp/dir1
gpilotd_client --pilot=MyPDA --conduit=Test
gpilotd/gnome-pilot-client.gob | 39 ++++++++++----------------
gpilotd/gpilot-daemon.c | 59 +++++++++++++++++++++++++--------------
2 files changed, 53 insertions(+), 45 deletions(-)
---
diff --git a/gpilotd/gnome-pilot-client.gob b/gpilotd/gnome-pilot-client.gob
index 2c29a12..e12c6a8 100644
--- a/gpilotd/gnome-pilot-client.gob
+++ b/gpilotd/gnome-pilot-client.gob
@@ -399,16 +399,13 @@ class Gnome:Pilot:Client from Gtk:Object {
public gint pause_daemon (self) onerror GPILOTD_ERR_INVAL {
GError *error;
gboolean res;
- gboolean pause;
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_BOOLEAN, TRUE,
G_TYPE_INVALID,
G_TYPE_INVALID);
@@ -424,16 +421,13 @@ class Gnome:Pilot:Client from Gtk:Object {
public gint unpause_daemon (self) onerror GPILOTD_ERR_INVAL {
GError *error;
gboolean res;
- gboolean pause;
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_BOOLEAN, FALSE,
G_TYPE_INVALID,
G_TYPE_INVALID);
@@ -521,8 +515,8 @@ class Gnome:Pilot:Client from Gtk:Object {
&error,
G_TYPE_STRING, pilot_id,
G_TYPE_STRING, directory,
- G_TYPE_UINT, &survival,
- G_TYPE_UINT, &timeout,
+ G_TYPE_UINT, survival,
+ G_TYPE_UINT, timeout,
G_TYPE_INVALID,
G_TYPE_UINT, &val,
G_TYPE_INVALID);
@@ -584,7 +578,7 @@ class Gnome:Pilot:Client from Gtk:Object {
}
src_gfile = g_file_new_for_path (infile_with_path);
- dest_gfile = g_file_new_for_path (filename_uri);
+ dest_gfile = g_file_new_for_uri (filename_uri);
/*
g_message ("from : \"%s\"", infile_with_path);
@@ -623,8 +617,8 @@ error: if (file_copied == FALSE) {
G_TYPE_STRING, pilot_name,
G_TYPE_STRING, filename,
G_TYPE_STRING, infile,
- G_TYPE_UINT, &survival,
- G_TYPE_UINT, &timeout,
+ G_TYPE_UINT, survival,
+ G_TYPE_UINT, timeout,
G_TYPE_INVALID,
G_TYPE_UINT, &val,
G_TYPE_INVALID);
@@ -800,7 +794,7 @@ error: if (file_copied == FALSE) {
res = dbus_g_proxy_call (self->proxy,
"RemoveRequest",
&error,
- G_TYPE_UINT, &handle,
+ G_TYPE_UINT, handle,
G_TYPE_INVALID,
G_TYPE_INVALID);
@@ -831,15 +825,15 @@ error: if (file_copied == FALSE) {
&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_UINT, operation,
+ G_TYPE_UINT, survival,
+ G_TYPE_UINT, timeout,
G_TYPE_INVALID,
G_TYPE_UINT, &val,
G_TYPE_INVALID);
if (!res) {
- g_warning ("Unable to GetSystemInfo for pilot %s: %s", pilot_name, error->message);
+ g_warning ("Unable to RequestConduit for pilot %s: %s", pilot_name, error->message);
g_error_free (error);
return GPILOTD_ERR_FAILED;
}
@@ -869,8 +863,7 @@ error: if (file_copied == FALSE) {
"GetUsers",
&error,
G_TYPE_INVALID,
- G_TYPE_STRV,
- &arr,
+ G_TYPE_STRV, &arr,
G_TYPE_INVALID);
if (!res) {
@@ -955,8 +948,7 @@ error: if (file_copied == FALSE) {
"GetCradles",
&error,
G_TYPE_INVALID,
- G_TYPE_STRV,
- &arr,
+ G_TYPE_STRV, &arr,
G_TYPE_INVALID);
if (!res) {
@@ -997,8 +989,7 @@ error: if (file_copied == FALSE) {
"GetPilots",
&error,
G_TYPE_INVALID,
- G_TYPE_STRV,
- &arr,
+ G_TYPE_STRV, &arr,
G_TYPE_INVALID);
if (!res) {
diff --git a/gpilotd/gpilot-daemon.c b/gpilotd/gpilot-daemon.c
index 4426e05..add5f95 100644
--- a/gpilotd/gpilot-daemon.c
+++ b/gpilotd/gpilot-daemon.c
@@ -1705,6 +1705,15 @@ gpilot_daemon_noop (GpilotDaemon *daemon)
}
/* request operations */
+/*
+Example:
+dbus-send --session --dest=org.gnome.GnomePilot \
+--type=method_call --print-reply \
+/org/gnome/GnomePilot/Daemon \
+org.gnome.GnomePilot.Daemon.RequestInstall \
+string:'MyPDA' string:'/tmp/1' string:'/tmp/1' \
+uint32:0 uint32:0
+*/
gboolean
gpilot_daemon_request_install (GpilotDaemon *daemon,
const char *pilot_name,
@@ -1717,15 +1726,11 @@ gpilot_daemon_request_install (GpilotDaemon *daemon,
{
GpilotDaemonPrivate *priv;
GPilotRequest req;
- gchar *client_id;
gboolean ret;
ret = FALSE;
priv = daemon->priv;
- /* TODO
- GET_AND_CHECK_CLIENT_ID(client_id,cb,0);
- */
-
+
LOG (("request_install(pilot_name=%s (%d),filename=%s,survival=%d,timeout=%d)",
pilot_name,
pilot_id_from_name (pilot_name, priv->gpilotd_context),
@@ -1755,7 +1760,7 @@ gpilot_daemon_request_install (GpilotDaemon *daemon,
req.timeout = survival==GNOME_Pilot_PERSISTENT?0:timeout;
req.cradle = NULL;
- req.client_id = g_strdup (client_id);
+ req.client_id = g_strdup ("");
req.parameters.install.filename = g_strdup (filename);
req.parameters.install.description = g_strdup (description);
@@ -1763,10 +1768,18 @@ gpilot_daemon_request_install (GpilotDaemon *daemon,
ret = TRUE;
out:
- g_free (client_id);
return ret;
}
+/*
+Example:
+dbus-send --session --dest=org.gnome.GnomePilot \
+--type=method_call --print-reply \
+/org/gnome/GnomePilot/Daemon \
+org.gnome.GnomePilot.Daemon.RequestRestore \
+string:'MyPDA' string:'/tmp/dir1' \
+uint32:0 uint32:0
+*/
gboolean
gpilot_daemon_request_restore (GpilotDaemon *daemon,
const char *pilot_name,
@@ -1778,16 +1791,11 @@ gpilot_daemon_request_restore (GpilotDaemon *daemon,
{
GpilotDaemonPrivate *priv;
GPilotRequest req;
- gchar *client_id;
gboolean ret;
ret = FALSE;
priv = daemon->priv;
- /* TODO
- GET_AND_CHECK_CLIENT_ID(client_id,cb,0);
- */
-
LOG (("request_restore(pilot_name=%s (%d), directory=%s,survival=%d,timeout=%d)",
pilot_name,
pilot_id_from_name (pilot_name, priv->gpilotd_context),
@@ -1816,7 +1824,7 @@ gpilot_daemon_request_restore (GpilotDaemon *daemon,
req.timeout = survival==GNOME_Pilot_PERSISTENT?0:timeout;
req.cradle = NULL;
- req.client_id = g_strdup(client_id);
+ req.client_id = g_strdup ("");
req.parameters.restore.directory = g_strdup(directory);
@@ -1824,10 +1832,18 @@ gpilot_daemon_request_restore (GpilotDaemon *daemon,
ret = TRUE;
out:
- g_free(client_id);
return ret;
}
+/*
+Example:
+dbus-send --session --dest=org.gnome.GnomePilot \
+--type=method_call --print-reply \
+/org/gnome/GnomePilot/Daemon \
+org.gnome.GnomePilot.Daemon.RequestConduit \
+string:'MyPDA' string:'Test' \
+uint32:0 uint32:0 uint32:0
+*/
gboolean
gpilot_daemon_request_conduit (GpilotDaemon *daemon,
const char *pilot_name,
@@ -1840,16 +1856,11 @@ gpilot_daemon_request_conduit (GpilotDaemon *daemon,
{
GpilotDaemonPrivate *priv;
GPilotRequest req;
- gchar *client_id;
gboolean ret;
ret = FALSE;
priv = daemon->priv;
- /* TODO
- GET_AND_CHECK_CLIENT_ID(client_id,cb,0);
- */
-
LOG (("request_conduit(pilot=%s (%d), conduit=%s)",
pilot_name,
pilot_id_from_name (pilot_name, priv->gpilotd_context),
@@ -1868,7 +1879,7 @@ gpilot_daemon_request_conduit (GpilotDaemon *daemon,
req.type = GREQ_CONDUIT;
req.timeout = survival==GNOME_Pilot_PERSISTENT?0:timeout;
req.cradle = NULL;
- req.client_id = g_strdup(client_id);
+ req.client_id = g_strdup("");
req.parameters.conduit.name = g_strdup (conduit_name);
switch (operation) {
@@ -1897,10 +1908,16 @@ gpilot_daemon_request_conduit (GpilotDaemon *daemon,
ret = TRUE;
out:
- g_free(client_id);
return ret;
}
+/* Example:
+dbus-send --session --dest=org.gnome.GnomePilot \
+--type=method_call --print-reply \
+/org/gnome/GnomePilot/Daemon \
+org.gnome.GnomePilot.Daemon.RemoveRequest \
+uint32:1
+*/
gboolean
gpilot_daemon_remove_request (GpilotDaemon *daemon,
unsigned long handle,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]