[Galago-commits] r2836 - in trunk/libgalago: . libgalago
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Mon Jun 12 01:30:59 PDT 2006
Author: chipx86
Date: 2006-06-12 01:30:50 -0700 (Mon, 12 Jun 2006)
New Revision: 2836
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-dbus.c
trunk/libgalago/libgalago/galago-private.h
trunk/libgalago/libgalago/galago-service.c
Log:
Calls should now return registered call handles, and they should be cancellable. This is not yet tested.
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2006-06-12 07:26:58 UTC (rev 2835)
+++ trunk/libgalago/ChangeLog 2006-06-12 08:30:50 UTC (rev 2836)
@@ -1,3 +1,11 @@
+Mon Jun 12 01:29:58 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-dbus.c:
+ * libgalago/galago-private.h:
+ * libgalago/galago-service.c:
+ - Calls should now return registered call handles, and they should be
+ cancellable. This is not yet tested.
+
Mon Jun 12 00:25:24 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* docs/reference/tmpl/galago-service.sgml:
Modified: trunk/libgalago/libgalago/galago-dbus.c
===================================================================
--- trunk/libgalago/libgalago/galago-dbus.c 2006-06-12 07:26:58 UTC (rev 2835)
+++ trunk/libgalago/libgalago/galago-dbus.c 2006-06-12 08:30:50 UTC (rev 2836)
@@ -35,9 +35,14 @@
GList *return_types;
PendingCallCb cb;
gpointer user_data;
+ GalagoCallHandle handle;
} PendingCallData;
+G_LOCK_DEFINE_STATIC(_calls_lock);
+static guint _next_call_handle = 1;
+static GHashTable *_active_calls = NULL;
+
static void
pending_call_data_free(PendingCallData *data)
{
@@ -51,7 +56,62 @@
g_free(data);
}
+/**
+ * galago_call_cancel:
+ * @handle: The call handle to cancel.
+ *
+ * Cancels an asynchronous call.
+ */
+void
+galago_call_cancel(GalagoCallHandle handle)
+{
+ DBusPendingCall *call;
+ G_LOCK(_calls_lock);
+
+ call = g_hash_table_lookup(_active_calls, GINT_TO_POINTER(handle));
+
+ if (call != NULL)
+ {
+ g_hash_table_remove(_active_calls, GINT_TO_POINTER(handle));
+ dbus_pending_call_cancel(call);
+ }
+
+ G_UNLOCK(_calls_lock);
+}
+
+GalagoCallHandle
+galago_calls_request_dummy_handle(void)
+{
+ GalagoCallHandle handle;
+
+ G_LOCK(_calls_lock);
+ handle = _next_call_handle++;
+ G_UNLOCK(_calls_lock);
+
+ return handle;
+}
+
+static GalagoCallHandle
+galago_calls_request_handle(DBusPendingCall *call)
+{
+ GalagoCallHandle handle;
+
+ g_return_val_if_fail(call != NULL, GALAGO_CALL_HANDLE_INVALID);
+
+ G_LOCK(_calls_lock);
+
+ if (_active_calls == NULL)
+ _active_calls = g_hash_table_new(g_direct_hash, g_direct_equal);
+
+ handle = _next_call_handle++;
+ g_hash_table_insert(_active_calls, GINT_TO_POINTER(handle), call);
+
+ G_UNLOCK(_calls_lock);
+
+ return handle;
+}
+
/**
* galago_dbus_message_iter_append_string_or_nil
* @iter: The message iterator.
@@ -752,6 +812,10 @@
if (reply != NULL)
dbus_message_unref(reply);
+ G_LOCK(_calls_lock);
+ g_hash_table_remove(_active_calls, GINT_TO_POINTER(call_data->handle));
+ G_UNLOCK(_calls_lock);
+
dbus_pending_call_unref(call);
}
@@ -761,7 +825,8 @@
GList *return_types,
va_list args,
PendingCallCb cb,
- gpointer user_data)
+ gpointer user_data,
+ GalagoCallHandle *handle)
{
DBusMessage *message = NULL;
DBusError error;
@@ -813,7 +878,11 @@
call_data->return_types = return_types;
call_data->cb = cb;
call_data->user_data = user_data;
+ call_data->handle = galago_calls_request_handle(call);
+ if (handle != NULL)
+ *handle = call_data->handle;
+
dbus_connection_send_with_reply(galago_get_dbus_conn(),
message, &call, -1);
dbus_pending_call_set_notify(call, pending_call_done_cb, call_data,
@@ -855,7 +924,7 @@
va_start(args, return_types);
list = galago_dbus_send_message_with_reply_list_vargs(object, name,
return_types, args,
- NULL, NULL);
+ NULL, NULL, NULL);
va_end(args);
return list;
@@ -886,7 +955,8 @@
va_start(args, return_type);
list = galago_dbus_send_message_with_reply_list_vargs(
- object, name, g_list_append(NULL, return_type), args, NULL, NULL);
+ object, name, g_list_append(NULL, return_type), args,
+ NULL, NULL, NULL);
va_end(args);
if (list != NULL)
@@ -934,7 +1004,7 @@
GalagoValue *return_type, ...)
{
va_list args;
- GalagoCallHandle handle = 1; /* XXX */
+ GalagoCallHandle handle;
GClosure *closure;
closure = g_cclosure_new(cb, user_data, (GClosureNotify)destroy_data);
@@ -946,7 +1016,7 @@
va_start(args, 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);
+ galago_dbus_send_message_with_reply_async_cb, closure, &handle);
va_end(args);
return handle;
Modified: trunk/libgalago/libgalago/galago-private.h
===================================================================
--- trunk/libgalago/libgalago/galago-private.h 2006-06-12 07:26:58 UTC (rev 2835)
+++ trunk/libgalago/libgalago/galago-private.h 2006-06-12 08:30:50 UTC (rev 2836)
@@ -122,4 +122,6 @@
GalagoPresence *_galago_presence_new(GalagoAccount *account,
const char *obj_path);
+GalagoCallHandle galago_calls_request_dummy_handle(void);
+
#endif /* _GALAGO_PRIVATE_H_ */
Modified: trunk/libgalago/libgalago/galago-service.c
===================================================================
--- trunk/libgalago/libgalago/galago-service.c 2006-06-12 07:26:58 UTC (rev 2835)
+++ trunk/libgalago/libgalago/galago-service.c 2006-06-12 08:30:50 UTC (rev 2836)
@@ -661,6 +661,7 @@
* @username: The account's username.
* @cb: The callback function that will be passed the account.
* @user_data: Custom data to pass to the callback function.
+ * @free_func: Optional function to free @user_data when the request completes.
*
* Asynchronously retrieves the account with the specified username from
* a service.
@@ -711,8 +712,7 @@
if (account != NULL)
{
cb((GalagoService *)service, account, user_data);
- //handle = galago_calls_request_dummy_handle();
- handle = 1;
+ handle = galago_calls_request_dummy_handle();
}
else if (GALAGO_OBJECT_IS_REMOTE(service) && !galago_is_daemon() &&
galago_is_connected())
More information about the galago-commits
mailing list