[gnome-pilot/dbus] Rework dbus method org.gnome.GnomePilot.Daemon.GetDatabasesFromCache
- From: Halton Huo <haltonhuo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-pilot/dbus] Rework dbus method org.gnome.GnomePilot.Daemon.GetDatabasesFromCache
- Date: Wed, 17 Mar 2010 07:11:44 +0000 (UTC)
commit ed78ce73637d53de1237ae7c9a4a7a0572cd1ff0
Author: Halton Huo <halton huo sun com>
Date: Wed Mar 17 15:08:55 2010 +0800
Rework dbus method org.gnome.GnomePilot.Daemon.GetDatabasesFromCache
Test following methods:
GetPilotIdFromName
GetPilotNameFromId
GetPilotBaseDir
GetDatabasesFromCache
gpilotd/gnome-pilot-client.gob | 25 +++++++++----------------
gpilotd/gpilot-daemon.c | 11 +++++------
gpilotd/gpilot-daemon.h | 2 +-
3 files changed, 15 insertions(+), 23 deletions(-)
---
diff --git a/gpilotd/gnome-pilot-client.gob b/gpilotd/gnome-pilot-client.gob
index f78ea86..2fa6eac 100644
--- a/gpilotd/gnome-pilot-client.gob
+++ b/gpilotd/gnome-pilot-client.gob
@@ -855,8 +855,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) {
@@ -867,14 +867,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,
"GetDatabasesFromCache",
&error,
G_TYPE_STRING, pilot_name,
G_TYPE_INVALID,
- dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
- &arr,
+ G_TYPE_STRV, &arr,
G_TYPE_INVALID);
if (!res) {
@@ -884,19 +882,14 @@ error: if (file_copied == FALSE) {
}
(*output) = NULL;
- for (i = 0; i < arr->len; i++) {
- char *str_tmp;
+ for (p = arr; p != NULL && *p != NULL; p++) {
+ if (IS_STR_SET (*p) ) {
+ (*output) = g_list_append ((*output), g_strdup (*p));
+ }
+ }
- 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);
+ g_strfreev (arr);
return GPILOTD_OK;
}
diff --git a/gpilotd/gpilot-daemon.c b/gpilotd/gpilot-daemon.c
index a851ede..c768472 100644
--- a/gpilotd/gpilot-daemon.c
+++ b/gpilotd/gpilot-daemon.c
@@ -2235,7 +2235,7 @@ gpilot_daemon_get_pilot_name_from_id (GpilotDaemon *daemon,
GError **error)
{
gchar *tmp;
- LOG(("corba: get_pilot_name_from_id(id=%d)",pilot_name));
+ LOG(("get_pilot_name_from_id(id=%d)", pilot_id));
*pilot_name = pilot_name_from_id (pilot_id,
daemon->priv->gpilotd_context);
@@ -2245,7 +2245,7 @@ gpilot_daemon_get_pilot_name_from_id (GpilotDaemon *daemon,
gboolean
gpilot_daemon_get_databases_from_cache (GpilotDaemon *daemon,
const char *pilot_name,
- GPtrArray **databases,
+ char ***databases,
GError **error)
{
int i;
@@ -2264,8 +2264,6 @@ gpilot_daemon_get_databases_from_cache (GpilotDaemon *daemon,
if (databases == NULL)
return FALSE;
- *databases = g_ptr_array_new ();
-
pilot_id = pilot_id_from_name (pilot_name,
daemon->priv->gpilotd_context);
@@ -2281,10 +2279,11 @@ gpilot_daemon_get_databases_from_cache (GpilotDaemon *daemon,
kfile = get_pilot_cache_kfile (pilot_id);
arr = g_key_file_get_string_list (kfile, "Databases",
"databases", &num_bases, NULL);
+ *databases = g_new (char *, num_bases + 1);
for (i=0; i<num_bases; i++) {
- g_ptr_array_add (*databases,
- g_strdup (arr[i]));
+ *databases[i] = g_strdup (arr[i]);
}
+ *databases[num_bases] = NULL;
ret = TRUE;
out:
diff --git a/gpilotd/gpilot-daemon.h b/gpilotd/gpilot-daemon.h
index 8ff9db2..4b333de 100644
--- a/gpilotd/gpilot-daemon.h
+++ b/gpilotd/gpilot-daemon.h
@@ -248,7 +248,7 @@ gboolean gpilot_daemon_get_pilot_name_from_id
gboolean gpilot_daemon_get_databases_from_cache
(GpilotDaemon *daemon,
const char *pilot_name,
- GPtrArray **databases,
+ char ***databases,
GError **error);
/* admin operations */
gboolean gpilot_daemon_get_user_info (GpilotDaemon *daemon,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]