[Galago-commits] r2834 - in trunk/libgalago: . libgalago tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sun Jun 11 22:16:53 PDT 2006
Author: chipx86
Date: 2006-06-11 22:16:50 -0700 (Sun, 11 Jun 2006)
New Revision: 2834
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-dbus.c
trunk/libgalago/libgalago/galago-dbus.h
trunk/libgalago/libgalago/galago-service.c
trunk/libgalago/tests/check-libgalago.c
Log:
Add working asynchronous account retrieval! Most of the code is now in place to implement the other async functions. It just needs to return proper call IDs and allow cancelling a request.
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2006-06-12 03:34:15 UTC (rev 2833)
+++ trunk/libgalago/ChangeLog 2006-06-12 05:16:50 UTC (rev 2834)
@@ -1,3 +1,13 @@
+Sun Jun 11 22:15:48 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-dbus.c:
+ * libgalago/galago-dbus.h:
+ * libgalago/galago-service.c:
+ * tests/check-libgalago.c:
+ - Add working asynchronous account retrieval! Most of the code is now
+ in place to implement the other async functions. It just needs to
+ return proper call IDs and allow cancelling a request.
+
Sun Jun 11 20:05:29 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* libgalago/galago-account.c:
Modified: trunk/libgalago/libgalago/galago-dbus.c
===================================================================
--- trunk/libgalago/libgalago/galago-dbus.c 2006-06-12 03:34:15 UTC (rev 2833)
+++ trunk/libgalago/libgalago/galago-dbus.c 2006-06-12 05:16:50 UTC (rev 2834)
@@ -753,7 +753,6 @@
dbus_message_unref(reply);
dbus_pending_call_unref(call);
- pending_call_data_free(call_data);
}
static GList *
@@ -900,18 +899,54 @@
return retval;
}
+static void
+galago_dbus_send_message_with_reply_async_cb(const GalagoObject *object,
+ GList *list,
+ gpointer user_data)
+{
+ GClosure *closure = (GClosure *)user_data;
+ GValue params[2] = {{0, }, {0, }};
+
+ /* For now.. */
+ g_assert(g_list_length(list) == 1);
+ g_assert(list != NULL);
+ g_assert(GALAGO_IS_OBJECT(list->data));
+
+ g_value_init(¶ms[0], G_TYPE_FROM_INSTANCE(object));
+ g_value_set_instance(¶ms[0], (gpointer)object);
+
+ g_value_init(¶ms[1], G_TYPE_FROM_INSTANCE(list->data));
+ g_value_set_instance(¶ms[1], list->data);
+
+ g_closure_invoke(closure, NULL, 2, params, NULL);
+ g_closure_unref(closure);
+
+ g_value_unset(¶ms[0]);
+ g_value_unset(¶ms[1]);
+}
+
GalagoCallHandle
galago_dbus_send_message_with_reply_async(const GalagoObject *object,
const char *name,
GCallback cb, gpointer user_data,
+ GFreeFunc destroy_data,
+ GClosureMarshal marshal,
GalagoValue *return_type, ...)
{
va_list args;
GalagoCallHandle handle = 1; /* XXX */
- GList *return_types = NULL;
+ GClosure *closure;
+ closure = g_cclosure_new(cb, user_data, (GClosureNotify)destroy_data);
+ g_closure_ref(closure);
+ g_closure_sink(closure);
+ g_closure_set_marshal(closure, marshal);
+ g_object_watch_closure(G_OBJECT(object), closure);
+
va_start(args, return_type);
- return_types = g_list_append(return_types, return_type);
+ galago_dbus_send_message_with_reply_list_vargs(
+ object, name, g_list_append(NULL, return_type), args,
+ galago_dbus_send_message_with_reply_async_cb, closure);
va_end(args);
return handle;
Modified: trunk/libgalago/libgalago/galago-dbus.h
===================================================================
--- trunk/libgalago/libgalago/galago-dbus.h 2006-06-12 03:34:15 UTC (rev 2833)
+++ trunk/libgalago/libgalago/galago-dbus.h 2006-06-12 05:16:50 UTC (rev 2834)
@@ -72,6 +72,8 @@
const char *name,
GCallback cb,
gpointer user_data,
+ GFreeFunc destroy_data,
+ GClosureMarshal marshal,
GalagoValue *return_value, ...);
void galago_dbus_object_push_full(GalagoObject *object);
Modified: trunk/libgalago/libgalago/galago-service.c
===================================================================
--- trunk/libgalago/libgalago/galago-service.c 2006-06-12 03:34:15 UTC (rev 2833)
+++ trunk/libgalago/libgalago/galago-service.c 2006-06-12 05:16:50 UTC (rev 2834)
@@ -715,36 +715,14 @@
handle = 1;
}
else if (GALAGO_OBJECT_IS_REMOTE(service) && !galago_is_daemon() &&
- !galago_is_connected())
+ galago_is_connected())
{
-#if 0
- DBusMessage *message;
- DBusPendingCall *call;
- GalagoClosure *closure;
-
- message = galago_dbus_message_new_method_call_args(
- GALAGO_OBJECT(service), "GetAccount", TRUE,
+ handle = galago_dbus_send_message_with_reply_async(
+ GALAGO_OBJECT(service), "GetAccount", cb, user_data, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ galago_value_new_object(GALAGO_TYPE_ACCOUNT, NULL),
galago_value_new(GALAGO_VALUE_TYPE_STRING, &username, NULL),
NULL);
-
- g_return_val_if_fail(message != NULL, GALAGO_CALL_HANDLE_INVALID);
-
- /* TODO: Assign a call handle to return. */
- handle = 1;
- dbus_connection_send_with_reply(galago_get_dbus_conn(), message,
- &call, -1);
- dbus_message_unref(message);
- //handle = galago_calls_request_handle(call);
-
- closure = (GalagoClosure *)g_closure_new_simple(sizeof(GalagoClosure),
- user_data);
- closure->callback = cb;
- closure->src_object = GALAGO_OBJECT(service);
- g_closure_set_marshal((GClosure *)closure,
- g_cclosure_marshal_VOID__POINTER);
-
- dbus_pending_call_set_notify(call, _happy_notify_func, closure, g_free);
-#endif
}
return handle;
Modified: trunk/libgalago/tests/check-libgalago.c
===================================================================
--- trunk/libgalago/tests/check-libgalago.c 2006-06-12 03:34:15 UTC (rev 2833)
+++ trunk/libgalago/tests/check-libgalago.c 2006-06-12 05:16:50 UTC (rev 2834)
@@ -382,10 +382,14 @@
account_received_cb(GalagoService *service, GalagoAccount *account,
GMainLoop *loop)
{
- fail_unless(account != NULL &&
+ fail_unless(service != NULL && GALAGO_IS_SERVICE(service) &&
+ !strcmp(galago_service_get_id(service), "aim"),
+ "Retrieved incorrect service parameter.");
+
+ fail_unless(account != NULL && GALAGO_IS_ACCOUNT(account) &&
!strcmp(galago_account_get_username(account), "GalagoAIMUser"),
- "Couldn't get account GalagoAIMUser. "
- "Is presence-feed running?");
+ "Retrieved incorrect account parameter.");
+
g_main_loop_quit(loop);
}
More information about the galago-commits
mailing list