[gnome-pilot/dbus] Rework dbus method org.gnome.GnomePilot.Daemon.GetPilotsByUseLogin
- From: Halton Huo <haltonhuo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-pilot/dbus] Rework dbus method org.gnome.GnomePilot.Daemon.GetPilotsByUseLogin
- Date: Wed, 17 Mar 2010 07:11:39 +0000 (UTC)
commit 94dd4ada6ec1fa4b4dbf6506718e6294de365996
Author: Halton Huo <halton huo sun com>
Date: Wed Mar 17 13:25:01 2010 +0800
Rework dbus method org.gnome.GnomePilot.Daemon.GetPilotsByUseLogin
Remove argument --listpilots1 from gpilotd-client since --listpilots
actually calls GetPilotsByUseName.
gpilotd/gnome-pilot-client.gob | 21 ++++++-------------
gpilotd/gpilot-daemon.c | 4 +-
gpilotd/gpilot-daemon.h | 2 +-
utils/gpilotd-client.c | 42 ----------------------------------------
4 files changed, 10 insertions(+), 59 deletions(-)
---
diff --git a/gpilotd/gnome-pilot-client.gob b/gpilotd/gnome-pilot-client.gob
index 3dc2051..f78ea86 100644
--- a/gpilotd/gnome-pilot-client.gob
+++ b/gpilotd/gnome-pilot-client.gob
@@ -1074,8 +1074,8 @@ error: if (file_copied == FALSE) {
GList **output (check null)) onerror GPILOTD_ERR_INVAL {
GError *error;
gboolean res;
- GPtrArray *arr;
- int i;
+ char **arr;
+ char **p;
#ifndef G_DISABLE_CHECKS
if (*output != NULL) {
@@ -1086,14 +1086,12 @@ error: if (file_copied == FALSE) {
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_STRV, &arr,
G_TYPE_INVALID);
if (!res) {
@@ -1103,19 +1101,14 @@ error: if (file_copied == FALSE) {
}
(*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) ) {
+ for (p = arr; p != NULL && *p != NULL; p++) {
+ if (IS_STR_SET (*p) ) {
(*output) = g_list_append ((*output),
- g_strdup (str_tmp));
+ g_strdup (*p));
}
- g_free (str_tmp);
- str_tmp = NULL;
}
- g_ptr_array_free (arr, TRUE);
+ g_strfreev (arr);
return GPILOTD_OK;
}
diff --git a/gpilotd/gpilot-daemon.c b/gpilotd/gpilot-daemon.c
index 0bf34e6..a851ede 100644
--- a/gpilotd/gpilot-daemon.c
+++ b/gpilotd/gpilot-daemon.c
@@ -2082,7 +2082,6 @@ gpilot_daemon_get_pilots_by_user_name (GpilotDaemon *daemon,
{
int i;
GList *l;
- int count;
GList *matches;
g_return_val_if_fail (GPILOT_IS_DAEMON (daemon), FALSE);
@@ -2117,11 +2116,12 @@ dbus-send --session --dest=org.gnome.GnomePilot \
--type=method_call --print-reply \
/org/gnome/GnomePilot/Daemon \
org.gnome.GnomePilot.Daemon.GetPilotsByUserLogin
+string:'foo'
*/
gboolean
gpilot_daemon_get_pilots_by_user_login (GpilotDaemon *daemon,
const char *uid,
- GPtrArray **pilots,
+ char ***pilots,
GError **error)
{
int i;
diff --git a/gpilotd/gpilot-daemon.h b/gpilotd/gpilot-daemon.h
index 2d5db0d..8ff9db2 100644
--- a/gpilotd/gpilot-daemon.h
+++ b/gpilotd/gpilot-daemon.h
@@ -218,7 +218,7 @@ gboolean gpilot_daemon_get_pilots_by_user_name
gboolean gpilot_daemon_get_pilots_by_user_login
(GpilotDaemon *daemon,
const char *uid,
- GPtrArray **pilots,
+ char ***pilots,
GError **error);
gboolean gpilot_daemon_get_user_name_by_pilot_name
(GpilotDaemon *daemon,
diff --git a/utils/gpilotd-client.c b/utils/gpilotd-client.c
index f50a433..bf4b22c 100644
--- a/utils/gpilotd-client.c
+++ b/utils/gpilotd-client.c
@@ -32,7 +32,6 @@ char
*arg_conduit = NULL,
*arg_cradle = NULL,
*arg_list_by_login = NULL,
- *arg_list_by_username = NULL,
*arg_pilot = NULL;
GList *outstanding_requests;
@@ -53,7 +52,6 @@ static GOptionEntry options[] = {
{"monitor", 'm', 0, G_OPTION_ARG_NONE, &arg_monitor, N_("Monitor the specified PDA's actions"), NULL},
{"monitorall", 'A', 0, G_OPTION_ARG_NONE, &arg_monitorall, N_("Monitor all PDAs"), NULL},
{"listpilots", '\0', 0, G_OPTION_ARG_STRING, &arg_list_by_login, N_("list PDAs by login (all for all pilots)"), N_("LOGIN")},
- {"listpilots1", '\0', 0, G_OPTION_ARG_STRING, &arg_list_by_username, N_("list PDAs by username (all for all pilots)"), N_("USERNAME")},
{"pilot", '\0', 0, G_OPTION_ARG_STRING, &arg_pilot, N_("Specify PDA to operate on (defaults to MyPDA)"), N_("PILOTNAME")},
{"cradle", '\0', 0, G_OPTION_ARG_STRING, &arg_cradle, N_("Specify a cradle to operate on (defaults to Cradle0)"), N_("CRADLENAME")},
{"listusers", '\0', 0, G_OPTION_ARG_NONE, &arg_listusers, N_("List users"), NULL},
@@ -210,43 +208,6 @@ static void list_by_login (void) {
}
}
-static void list_by_username (void) {
- GList *list = NULL, *ptr;
- gint *ids = NULL;
- gint idx;
-
- if (strcmp (arg_list_by_username, "all")==0) {
- gnome_pilot_client_get_pilots (gpc, &list);
- gnome_pilot_client_get_pilot_ids (gpc, &ids);
- } else {
- gnome_pilot_client_get_pilots_by_user_name (gpc, arg_list_by_username, &list);
- }
- if (list) {
- idx = 0;
- for (ptr = list; ptr; ptr = ptr->next ) {
- if (ids) {
- char *user = NULL;
- char *uid = NULL;
- gnome_pilot_client_get_user_name_by_pilot_name (gpc,
- (char*)ptr->data,
- &user);
- gnome_pilot_client_get_user_login_by_pilot_name (gpc,
- (char*)ptr->data,
- &uid);
- g_message ("%s is %d, owned by %s aka %s",
- (char*)ptr->data,
- ids[idx],
- user, uid);
- } else {
- g_message ("Pilot : %s", (char*)ptr->data);
- }
- idx++;
- }
- } else {
- g_message ("No pilots");
- }
-}
-
static void
print_err (gint err, gint outstanding_request) {
stay_alive = FALSE;
@@ -473,9 +434,6 @@ main (int argc, char *argv[]) {
list_bases ();
} else if (arg_list_by_login) {
list_by_login ();
- } else if (arg_list_by_username) {
- g_debug ("%s", arg_list_by_username);
- list_by_username ();
} else if (arg_monitor) {
g_message ("Monitor on %s",arg_pilot);
/*TODO turn on notify with dbus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]