From 1dcacffc325e50754d4cc3338822d1f03c8b6e45 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 30 Jan 2005 23:06:32 +0000 Subject: 2005-01-30 Havoc Pennington * glib/dbus-glib.c (dbus_g_pending_call_set_notify): new function (dbus_g_pending_call_cancel): new function * dbus/dbus-glib.h: move GType decls for connection/message here; * dbus/dbus-glib.c: move all the g_type and ref/unref stuff in here, just kind of rationalizing how we handle all that * tools/dbus-names-model.c: new file for a tree model listing the services on a bus * tools/dbus-tree-view.c (model_new): use proper typing on the model rows --- dbus/dbus-glib-lowlevel.h | 15 ++++++--------- dbus/dbus-glib.h | 35 +++++++++++++++++++++++++++++------ dbus/dbus-pending-call.c | 10 +++++----- 3 files changed, 40 insertions(+), 20 deletions(-) (limited to 'dbus') diff --git a/dbus/dbus-glib-lowlevel.h b/dbus/dbus-glib-lowlevel.h index a689a926..94132151 100644 --- a/dbus/dbus-glib-lowlevel.h +++ b/dbus/dbus-glib-lowlevel.h @@ -32,15 +32,12 @@ G_BEGIN_DECLS void dbus_set_g_error (GError **gerror, DBusError *derror); -#define DBUS_TYPE_CONNECTION (dbus_connection_get_g_type ()) -#define DBUS_TYPE_MESSAGE (dbus_message_get_g_type ()) -GType dbus_connection_get_g_type (void) G_GNUC_CONST; -GType dbus_message_get_g_type (void) G_GNUC_CONST; - -#define DBUS_TYPE_G_CONNECTION (dbus_g_connection_get_g_type ()) -#define DBUS_TYPE_G_MESSAGE (dbus_g_message_get_g_type ()) -GType dbus_g_connection_get_g_type (void) G_GNUC_CONST; -GType dbus_g_message_get_g_type (void) G_GNUC_CONST; +#define DBUS_TYPE_CONNECTION (dbus_connection_get_g_type ()) +#define DBUS_TYPE_MESSAGE (dbus_message_get_g_type ()) +#define DBUS_TYPE_PENDING_CALL (dbus_pending_call_get_g_type ()) +GType dbus_connection_get_g_type (void) G_GNUC_CONST; +GType dbus_message_get_g_type (void) G_GNUC_CONST; +GType dbus_pending_call_get_g_type (void) G_GNUC_CONST; void dbus_connection_setup_with_g_main (DBusConnection *connection, GMainContext *context); diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h index 3e73b98f..6c3c3c5f 100644 --- a/dbus/dbus-glib.h +++ b/dbus/dbus-glib.h @@ -34,11 +34,11 @@ G_BEGIN_DECLS /** - * Convert to DBusConnection with dbus_g_connection_get_connection() + * Convert to DBusConnection with dbus_g_connection_get_connection() in dbus-glib-lowlevel.h */ typedef struct DBusGConnection DBusGConnection; /** - * Convert to DBusMessage with dbus_g_message_get_message() + * Convert to DBusMessage with dbus_g_message_get_message() in dbus-glib-lowlevel.h */ typedef struct DBusGMessage DBusGMessage; /** @@ -46,7 +46,33 @@ typedef struct DBusGMessage DBusGMessage; */ typedef struct DBusGPendingCall DBusGPendingCall; -void dbus_g_connection_flush (DBusGConnection *connection); +typedef void (* DBusGPendingCallNotify) (DBusGPendingCall *pending, + void *user_data); + + +#define DBUS_TYPE_G_CONNECTION (dbus_g_connection_get_g_type ()) +#define DBUS_TYPE_G_MESSAGE (dbus_g_message_get_g_type ()) +#define DBUS_TYPE_G_PENDING_CALL (dbus_g_message_get_g_type ()) +GType dbus_g_connection_get_g_type (void) G_GNUC_CONST; +GType dbus_g_message_get_g_type (void) G_GNUC_CONST; +GType dbus_g_pending_call_get_g_type (void) G_GNUC_CONST; + + +DBusGConnection* dbus_g_connection_ref (DBusGConnection *connection); +void dbus_g_connection_unref (DBusGConnection *connection); +DBusGPendingCall* dbus_g_pending_call_ref (DBusGPendingCall *call); +void dbus_g_pending_call_unref (DBusGPendingCall *call); +DBusGMessage* dbus_g_message_ref (DBusGMessage *message); +void dbus_g_message_unref (DBusGMessage *message); + +void dbus_g_connection_flush (DBusGConnection *connection); + +void dbus_g_pending_call_set_notify (DBusGPendingCall *call, + DBusGPendingCallNotify callback, + void *callback_data, + GDestroyNotify free_data_func); +void dbus_g_pending_call_cancel (DBusGPendingCall *call); + GQuark dbus_g_error_quark (void); #define DBUS_GERROR dbus_g_error_quark () @@ -147,9 +173,6 @@ void dbus_g_proxy_call_no_reply (DBusGProxy *proxy, ...); const char* dbus_g_proxy_get_bus_name (DBusGProxy *proxy); -DBusGPendingCall* dbus_g_pending_call_ref (DBusGPendingCall *call); -void dbus_g_pending_call_unref (DBusGPendingCall *call); - #undef DBUS_INSIDE_DBUS_GLIB_H G_END_DECLS diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c index d0403b03..b69f7c3e 100644 --- a/dbus/dbus-pending-call.c +++ b/dbus/dbus-pending-call.c @@ -227,11 +227,11 @@ dbus_pending_call_set_notify (DBusPendingCall *pending, } /** - * Cancels the pending call, such that any reply - * or error received will just be ignored. - * Drops at least one reference to the #DBusPendingCall - * so will free the call if nobody else is holding - * a reference. + * Cancels the pending call, such that any reply or error received + * will just be ignored. Drops the dbus library's internal reference + * to the #DBusPendingCall so will free the call if nobody else is + * holding a reference. However you usually get a reference + * from dbus_connection_send() so probably your app owns a ref also. * * @param pending the pending call */ -- cgit