dbus/glib dbus-glib.c, 1.3, 1.4 dbus-gmain.c, 1.36, 1.37 dbus-gproxy.c, 1.15, 1.16

Havoc Pennington hp at freedesktop.org
Sun Jan 30 15:06:34 PST 2005


Update of /cvs/dbus/dbus/glib
In directory gabe:/tmp/cvs-serv17174/glib

Modified Files:
	dbus-glib.c dbus-gmain.c dbus-gproxy.c 
Log Message:
2005-01-30  Havoc Pennington  <hp at redhat.com>

	* 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



Index: dbus-glib.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-glib.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dbus-glib.c	16 Jan 2005 15:51:55 -0000	1.3
+++ dbus-glib.c	30 Jan 2005 23:06:32 -0000	1.4
@@ -47,6 +47,341 @@
   dbus_connection_flush (DBUS_CONNECTION_FROM_G_CONNECTION (connection));
 }
 
+/**
+ * Increment refcount on a #DBusGConnection
+ * 
+ * @param connection the connection to ref
+ * @returns the connection that was ref'd
+ */
+DBusGConnection*
+dbus_g_connection_ref (DBusGConnection *gconnection)
+{
+  DBusConnection *c;
+
+  c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
+  dbus_connection_ref (c);
+  return gconnection;
+}
+
+
+/**
+ * Decrement refcount on a #DBusGConnection
+ * 
+ * @param connection the connection to unref
+ */
+void
+dbus_g_connection_unref (DBusGConnection *gconnection)
+{
+  DBusConnection *c;
+
+  c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
+  dbus_connection_unref (c);
+}
+
+
+/**
+ * Increment refcount on a #DBusGMessage
+ * 
+ * @param message the message to ref
+ * @returns the message that was ref'd
+ */
+DBusGMessage*
+dbus_g_message_ref (DBusGMessage *gmessage)
+{
+  DBusMessage *c;
+
+  c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
+  dbus_message_ref (c);
+  return gmessage;
+}
+
+/**
+ * Decrement refcount on a #DBusGMessage
+ * 
+ * @param message the message to unref
+ */
+void
+dbus_g_message_unref (DBusGMessage *gmessage)
+{
+  DBusMessage *c;
+
+  c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
+  dbus_message_unref (c);
+}
+
+/**
+ * Increments refcount on a pending call.
+ *
+ * @param call the call
+ * @returns the same call
+ */
+DBusGPendingCall*
+dbus_g_pending_call_ref (DBusGPendingCall  *call)
+{
+  dbus_pending_call_ref (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call));
+  return call;
+}
+
+/**
+ * Decrements refcount on a pending call.
+ *
+ * @param call the call
+ */
+void
+dbus_g_pending_call_unref (DBusGPendingCall  *call)
+{
+  dbus_pending_call_unref (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call));
+}
+
+/**
+ * The implementation of DBUS_GERROR error domain. See documentation
+ * for GError in GLib reference manual.
+ *
+ * @returns the error domain quark for use with GError
+ */
+GQuark
+dbus_g_error_quark (void)
+{
+  static GQuark quark = 0;
+  if (quark == 0)
+    quark = g_quark_from_static_string ("g-exec-error-quark");
+  return quark;
+}
+
+
+/**
+ * Set a GError return location from a DBusError.
+ *
+ * @todo expand the DBUS_GERROR enum and take advantage of it here
+ * 
+ * @param gerror location to store a GError, or #NULL
+ * @param derror the DBusError
+ */
+void
+dbus_set_g_error (GError   **gerror,
+                  DBusError *derror)
+{
+  g_return_if_fail (derror != NULL);
+  g_return_if_fail (dbus_error_is_set (derror));
+  
+  g_set_error (gerror, DBUS_GERROR,
+               DBUS_GERROR_FAILED,
+               _("D-BUS error %s: %s"),
+               derror->name, derror->message);  
+}
+
+/**
+ * Get the GLib type ID for a DBusConnection boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_connection_get_g_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("DBusConnection",
+                                             (GBoxedCopyFunc) dbus_connection_ref,
+                                             (GBoxedFreeFunc) dbus_connection_unref);
+
+  return our_type;
+}
+
+/**
+ * Get the GLib type ID for a DBusMessage boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_message_get_g_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("DBusMessage",
+                                             (GBoxedCopyFunc) dbus_message_ref,
+                                             (GBoxedFreeFunc) dbus_message_unref);
+
+  return our_type;
+}
+
+/**
+ * Get the GLib type ID for a DBusPendingCall boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_pending_call_get_g_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("DBusPendingCall",
+                                             (GBoxedCopyFunc) dbus_pending_call_ref,
+                                             (GBoxedFreeFunc) dbus_pending_call_unref);
+
+  return our_type;
+}
+
+/**
+ * Get the GLib type ID for a DBusGConnection boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_g_connection_get_g_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("DBusGConnection",
+                                             (GBoxedCopyFunc) dbus_g_connection_ref,
+                                             (GBoxedFreeFunc) dbus_g_connection_unref);
+
+  return our_type;
+}
+
+/**
+ * Get the GLib type ID for a DBusGMessage boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_g_message_get_g_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("DBusGMessage",
+                                             (GBoxedCopyFunc) dbus_g_message_ref,
+                                             (GBoxedFreeFunc) dbus_g_message_unref);
+
+  return our_type;
+}
+
+/**
+ * Get the GLib type ID for a DBusGPendingCall boxed type.
+ *
+ * @returns GLib type
+ */
+GType
+dbus_g_pending_call_get_g_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("DBusGPendingCall",
+                                             (GBoxedCopyFunc) dbus_g_pending_call_ref,
+                                             (GBoxedFreeFunc) dbus_g_pending_call_unref);
+
+  return our_type;
+}
+
+/**
+ * Get the DBusConnection corresponding to this DBusGConnection.
+ * The return value does not have its refcount incremented.
+ *
+ * @returns DBusConnection 
+ */
+DBusConnection*
+dbus_g_connection_get_connection (DBusGConnection *gconnection)
+{
+  return DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
+}
+
+/**
+ * Get the DBusMessage corresponding to this DBusGMessage.
+ * The return value does not have its refcount incremented.
+ *
+ * @returns DBusMessage 
+ */
+DBusMessage*
+dbus_g_message_get_message (DBusGMessage *gmessage)
+{
+  return DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
+}
+
+typedef struct
+{
+  DBusGPendingCallNotify func;
+  void *data;
+  GDestroyNotify free_data_func;
+} GPendingNotifyClosure;
+
+static void
+d_pending_call_notify (DBusPendingCall *dcall,
+                       void            *data)
+{
+  GPendingNotifyClosure *closure = data;
+  DBusGPendingCall *gcall = DBUS_G_PENDING_CALL_FROM_PENDING_CALL (dcall);
+
+  (* closure->func) (gcall, closure->data);
+}
+
+static void
+d_pending_call_free (void *data)
+{
+  GPendingNotifyClosure *closure = data;
+  
+  if (closure->free_data_func)
+    (* closure->free_data_func) (closure->data);
+
+  g_free (closure);
+}
+  
+/**
+ * Sets up a notification to be invoked when the pending call
+ * is ready to be ended without blocking.
+ * You can call dbus_g_proxy_end_call() at any time,
+ * but it will block if no reply or error has been received yet.
+ * This function lets you handle the reply asynchronously.
+ *
+ * @param call the pending call
+ * @param callback the callback
+ * @param callback_data data for the callback
+ * @param free_data_func free the callback data with this
+ */
+void
+dbus_g_pending_call_set_notify (DBusGPendingCall      *call,
+                                DBusGPendingCallNotify callback,
+                                void                  *callback_data,
+                                GDestroyNotify         free_data_func)
+{
+  GPendingNotifyClosure *closure;
+  DBusPendingCall *dcall;
+
+  g_return_if_fail (callback != NULL);
+  
+  closure = g_new (GPendingNotifyClosure, 1);
+
+  closure->func = callback;
+  closure->data = callback_data;
+  closure->free_data_func = free_data_func;
+
+  dcall = DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call);
+  dbus_pending_call_set_notify (dcall, d_pending_call_notify,
+                                closure,
+                                d_pending_call_free);
+}
+
+/**
+ * Cancels a pending call. Does not affect the reference count
+ * of the call, but it means you will never be notified of call
+ * completion, and can't call dbus_g_proxy_end_call().
+ *
+ * @param call the call
+ */
+void
+dbus_g_pending_call_cancel (DBusGPendingCall *call)
+{
+  DBusPendingCall *dcall;
+  
+  dcall = DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call);
+
+  dbus_pending_call_cancel (dcall);
+}
+
 /** @} */ /* end of public API */
 
 

Index: dbus-gmain.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gmain.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- dbus-gmain.c	30 Jan 2005 20:06:52 -0000	1.36
+++ dbus-gmain.c	30 Jan 2005 23:06:32 -0000	1.37
@@ -731,178 +731,6 @@
   return DBUS_G_CONNECTION_FROM_CONNECTION (connection);
 }
 
-/**
- * The implementation of DBUS_GERROR error domain. See documentation
- * for GError in GLib reference manual.
- *
- * @returns the error domain quark for use with GError
- */
-GQuark
-dbus_g_error_quark (void)
-{
-  static GQuark quark = 0;
-  if (quark == 0)
-    quark = g_quark_from_static_string ("g-exec-error-quark");
-  return quark;
-}
-
-
-/**
- * Set a GError return location from a DBusError.
- *
- * @todo expand the DBUS_GERROR enum and take advantage of it here
- * 
- * @param gerror location to store a GError, or #NULL
- * @param derror the DBusError
- */
-void
-dbus_set_g_error (GError   **gerror,
-                  DBusError *derror)
-{
-  g_return_if_fail (derror != NULL);
-  g_return_if_fail (dbus_error_is_set (derror));
-  
-  g_set_error (gerror, DBUS_GERROR,
-               DBUS_GERROR_FAILED,
-               _("D-BUS error %s: %s"),
-               derror->name, derror->message);  
-}
-
-/**
- * Get the GLib type ID for a DBusConnection boxed type.
- *
- * @returns GLib type
- */
-GType
-dbus_connection_get_g_type (void)
-{
-  static GType our_type = 0;
-  
-  if (our_type == 0)
-    our_type = g_boxed_type_register_static ("DBusConnection",
-                                             (GBoxedCopyFunc) dbus_connection_ref,
-                                             (GBoxedFreeFunc) dbus_connection_unref);
-
-  return our_type;
-}
-
-/**
- * Get the GLib type ID for a DBusMessage boxed type.
- *
- * @returns GLib type
- */
-GType
-dbus_message_get_g_type (void)
-{
-  static GType our_type = 0;
-  
-  if (our_type == 0)
-    our_type = g_boxed_type_register_static ("DBusMessage",
-                                             (GBoxedCopyFunc) dbus_message_ref,
-                                             (GBoxedFreeFunc) dbus_message_unref);
-
-  return our_type;
-}
-
-static DBusGConnection*
-dbus_g_connection_ref (DBusGConnection *gconnection)
-{
-  DBusConnection *c;
-
-  c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
-  dbus_connection_ref (c);
-  return gconnection;
-}
-
-static void
-dbus_g_connection_unref (DBusGConnection *gconnection)
-{
-  DBusConnection *c;
-
-  c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
-  dbus_connection_unref (c);
-}
-
-
-static DBusGMessage*
-dbus_g_message_ref (DBusGMessage *gmessage)
-{
-  DBusMessage *c;
-
-  c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
-  dbus_message_ref (c);
-  return gmessage;
-}
-
-static void
-dbus_g_message_unref (DBusGMessage *gmessage)
-{
-  DBusMessage *c;
-
-  c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
-  dbus_message_unref (c);
-}
-
-/**
- * Get the GLib type ID for a DBusGConnection boxed type.
- *
- * @returns GLib type
- */
-GType
-dbus_g_connection_get_g_type (void)
-{
-  static GType our_type = 0;
-  
-  if (our_type == 0)
-    our_type = g_boxed_type_register_static ("DBusGConnection",
-                                             (GBoxedCopyFunc) dbus_g_connection_ref,
-                                             (GBoxedFreeFunc) dbus_g_connection_unref);
-
-  return our_type;
-}
-
-/**
- * Get the GLib type ID for a DBusGMessage boxed type.
- *
- * @returns GLib type
- */
-GType
-dbus_g_message_get_g_type (void)
-{
-  static GType our_type = 0;
-  
-  if (our_type == 0)
-    our_type = g_boxed_type_register_static ("DBusGMessage",
-                                             (GBoxedCopyFunc) dbus_g_message_ref,
-                                             (GBoxedFreeFunc) dbus_g_message_unref);
-
-  return our_type;
-}
-
-/**
- * Get the DBusConnection corresponding to this DBusGConnection.
- * The return value does not have its refcount incremented.
- *
- * @returns DBusConnection 
- */
-DBusConnection*
-dbus_g_connection_get_connection (DBusGConnection *gconnection)
-{
-  return DBUS_CONNECTION_FROM_G_CONNECTION (gconnection);
-}
-
-/**
- * Get the DBusMessage corresponding to this DBusGMessage.
- * The return value does not have its refcount incremented.
- *
- * @returns DBusMessage 
- */
-DBusMessage*
-dbus_g_message_get_message (DBusGMessage *gmessage)
-{
-  return DBUS_MESSAGE_FROM_G_MESSAGE (gmessage);
-}
-
 /** @} */ /* end of public API */
 
 #ifdef DBUS_BUILD_TESTS

Index: dbus-gproxy.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gproxy.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- dbus-gproxy.c	30 Jan 2005 05:18:44 -0000	1.15
+++ dbus-gproxy.c	30 Jan 2005 23:06:32 -0000	1.16
@@ -1122,10 +1122,8 @@
  * Collects the results of a method call. The method call was normally
  * initiated with dbus_g_proxy_end_call(). This function will block if
  * the results haven't yet been received; use
- * dbus_pending_call_set_notify() to be notified asynchronously that a
- * pending call has been completed. Use
- * dbus_pending_call_get_completed() to check whether a call has been
- * completed. If it's completed, it will not block.
+ * dbus_g_pending_call_set_notify() to be notified asynchronously that a
+ * pending call has been completed. If it's completed, it will not block.
  *
  * If the call results in an error, the error is set as normal for
  * GError and the function returns #FALSE.
@@ -1135,7 +1133,7 @@
  * The list should be terminated with #DBUS_TYPE_INVALID.
  *
  * This function doesn't affect the reference count of the
- * #DBusPendingCall, the caller of dbus_g_proxy_begin_call() still owns
+ * #DBusGPendingCall, the caller of dbus_g_proxy_begin_call() still owns
  * a reference.
  *
  * @todo this should be changed to make a g_malloc() copy of the
@@ -1247,30 +1245,6 @@
 }
 
 /**
- * Increments refcount on a pending call.
- *
- * @param call the call
- * @returns the same call
- */
-DBusGPendingCall*
-dbus_g_pending_call_ref (DBusGPendingCall  *call)
-{
-  dbus_pending_call_ref (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call));
-  return call;
-}
-
-/**
- * Decrements refcount on a pending call.
- *
- * @param call the call
- */
-void
-dbus_g_pending_call_unref (DBusGPendingCall  *call)
-{
-  dbus_pending_call_unref (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call));
-}
-
-/**
  * Sends a message to the interface we're proxying for.  Does not
  * block or wait for a reply. The message is only actually written out
  * when you return to the main loop or block in



More information about the dbus-commit mailing list