[Galago-commits] r2840 - in trunk/libgalago: . libgalago tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Mon Jun 12 01:49:06 PDT 2006
Author: chipx86
Date: 2006-06-12 01:49:02 -0700 (Mon, 12 Jun 2006)
New Revision: 2840
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-core.c
trunk/libgalago/libgalago/galago-core.h
trunk/libgalago/libgalago/galago-service.h
trunk/libgalago/tests/check-libgalago.c
Log:
Implemented galago_get_service_async().
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2006-06-12 08:35:22 UTC (rev 2839)
+++ trunk/libgalago/ChangeLog 2006-06-12 08:49:02 UTC (rev 2840)
@@ -1,3 +1,11 @@
+Mon Jun 12 01:48:44 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-core.c:
+ * libgalago/galago-core.h:
+ * libgalago/galago-service.h:
+ * tests/check-libgalago.c:
+ - Implemented galago_get_service_async().
+
Mon Jun 12 01:34:56 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* libgalago/galago-dbus.c:
Modified: trunk/libgalago/libgalago/galago-core.c
===================================================================
--- trunk/libgalago/libgalago/galago-core.c 2006-06-12 08:35:22 UTC (rev 2839)
+++ trunk/libgalago/libgalago/galago-core.c 2006-06-12 08:49:02 UTC (rev 2840)
@@ -1243,6 +1243,43 @@
return service;
}
+GalagoCallHandle
+galago_get_service_async(const char *id,
+ GalagoCoreServiceCb cb,
+ gpointer user_data,
+ GFreeFunc free_func)
+{
+ GalagoService *service;
+ GalagoCallHandle handle = GALAGO_CALL_HANDLE_INVALID;
+
+ g_return_val_if_fail(galago_is_initted(), handle);
+ g_return_val_if_fail(id != NULL && *id != '\0', handle);
+ g_return_val_if_fail(cb != NULL, handle);
+
+ galago_context_push(galago_object_get_context(GALAGO_OBJECT(_core)));
+
+ service = galago_context_get_service(id, GALAGO_REMOTE);
+
+ if (service != NULL)
+ {
+ cb(_core, service, user_data);
+ handle = galago_calls_request_dummy_handle();
+ }
+ else if (!galago_is_daemon() && galago_is_connected())
+ {
+ handle = galago_dbus_send_message_with_reply_async(
+ GALAGO_OBJECT(_core), "GetService", G_CALLBACK(cb),
+ user_data, free_func, g_cclosure_marshal_VOID__POINTER,
+ galago_value_new_object(GALAGO_TYPE_SERVICE, NULL),
+ galago_value_new(GALAGO_VALUE_TYPE_STRING, &id, NULL),
+ NULL);
+ }
+
+ galago_context_pop();
+
+ return handle;
+}
+
/**
* galago_get_services
* @origin: The desired origin.
Modified: trunk/libgalago/libgalago/galago-core.h
===================================================================
--- trunk/libgalago/libgalago/galago-core.h 2006-06-12 08:35:22 UTC (rev 2839)
+++ trunk/libgalago/libgalago/galago-core.h 2006-06-12 08:49:02 UTC (rev 2840)
@@ -50,6 +50,8 @@
typedef struct _GalagoCoreClass GalagoCoreClass;
typedef struct _GalagoCorePrivate GalagoCorePrivate;
+typedef void (*GalagoCoreServiceCb)(GalagoCore *, GalagoService *, gpointer);
+
typedef enum
{
GALAGO_INIT_CLIENT = 0,
@@ -58,7 +60,6 @@
} GalagoInitFlags;
-
struct _GalagoCore
{
GalagoObject parent_object;
@@ -110,6 +111,10 @@
GalagoServiceFlags flags);
GalagoService *galago_get_service(const char *id, GalagoOrigin origin,
gboolean query);
+GalagoCallHandle galago_get_service_async(const char *id,
+ GalagoCoreServiceCb cb,
+ gpointer user_data,
+ GFreeFunc free_func);
GList *galago_get_services(GalagoOrigin origin, gboolean query);
GalagoPerson *galago_create_person(const char *uid);
Modified: trunk/libgalago/libgalago/galago-service.h
===================================================================
--- trunk/libgalago/libgalago/galago-service.h 2006-06-12 08:35:22 UTC (rev 2839)
+++ trunk/libgalago/libgalago/galago-service.h 2006-06-12 08:49:02 UTC (rev 2840)
@@ -35,6 +35,7 @@
/* Strip a slash and everything after it during normalization. */
GALAGO_STRIP_SLASH = 1 << 2
+
} GalagoServiceFlags;
#include <libgalago/galago-account.h>
Modified: trunk/libgalago/tests/check-libgalago.c
===================================================================
--- trunk/libgalago/tests/check-libgalago.c 2006-06-12 08:35:22 UTC (rev 2839)
+++ trunk/libgalago/tests/check-libgalago.c 2006-06-12 08:49:02 UTC (rev 2840)
@@ -379,6 +379,31 @@
* Test asynchronous calls
**************************************************************************/
static void
+service_received_cb(GalagoCore *core, GalagoService *service,
+ gpointer user_data)
+{
+ GMainLoop *loop = (GMainLoop *)user_data;
+
+ fail_unless(service != NULL && GALAGO_IS_SERVICE(service) &&
+ !strcmp(galago_service_get_id(service), "aim"),
+ "Retrieved incorrect service parameter.");
+
+ g_main_loop_quit(loop);
+}
+
+START_TEST(test_core_get_service_async)
+{
+ GMainLoop *loop;
+
+ loop = g_main_loop_new(NULL, FALSE);
+ galago_init("check-libgalago", GALAGO_INIT_CLIENT);
+ galago_get_service_async("aim", service_received_cb, loop, NULL);
+ g_main_loop_run(loop);
+}
+END_TEST
+
+
+static void
account_received_cb(GalagoService *service, GalagoAccount *account,
gpointer user_data)
{
@@ -468,6 +493,7 @@
ADD_TCASE("service_get_account", test_service_get_account);
/* Test asynchronous queries */
+ ADD_TCASE("core_get_service_async", test_core_get_service_async);
ADD_TCASE("service_get_account_async", test_service_get_account_async);
return s;
More information about the galago-commits
mailing list