dbus/tools print-introspect.c, 1.2, 1.3 dbus-viewer.c, 1.13, 1.14 dbus-send.c, 1.17, 1.18 dbus-print-message.h, 1.1, 1.2 dbus-print-message.c, 1.7, 1.8 dbus-names-model.c, 1.7, 1.8 dbus-monitor.c, 1.13, 1.14

Colin Walters walters at freedesktop.org
Wed Jul 6 14:27:47 PDT 2005


Update of /cvs/dbus/dbus/tools
In directory gabe:/tmp/cvs-serv26636/tools

Modified Files:
	print-introspect.c dbus-viewer.c dbus-send.c 
	dbus-print-message.h dbus-print-message.c dbus-names-model.c 
	dbus-monitor.c 
Log Message:
2005-07-06  Colin Walters  <walters at verbum.org>

	* dbus/dbus-glib.h (DBusGPendingCall, DBusGPendingCallNotify)
	(DBUS_TYPE_G_PENDING_CALL, dbus_g_pending_call_get_g_type)
	(dbus_g_pending_call_ref, dbus_g_pending_call_unref): Delete.
	(dbus_g_pending_call_set_notify, dbus_g_pending_call_cancel):
	Delete in favor of dbus_g_proxy_begin_call and
	dbus_g_proxy_cancel_call.
	(DBusGProxyCall, DBusGProxyCallNotify): New.
	(dbus_g_proxy_begin_call): Change prototype to take callback, user
	data, and destroy function.  This replaces
	dbus_g_pending_call_set_notify.
	(dbus_g_proxy_cancel_call): Prototype.
	(DBusGAsyncData): Delete, shouldn't be needed anymore.

	* glib/dbus-gproxy.c (struct _DBusGProxy): Add call_id_counter and
	pending_calls map.
	(struct _DBusGProxyManager): Add bus_proxy member, which is an
	internal proxy for calls to the bus. Remove
	pending_nameowner_calls, now the internal proxy keeps track.
	(dbus_g_proxy_manager_unref): Unref bus proxy, remove reference to
	pending_nameowner_calls.
	(got_name_owner_cb): Update prototype, and use
	dbus_g_proxy_end_call.
	(got_name_owner_cb): Remove reference to pending_nameowner_calls.
	(dbus_g_proxy_manager_register): Delete directly libdbus code in
	favor of using internal proxy.
	(dbus_g_proxy_manager_unregister): Update to use
	dbus_g_proxy_cancel_call for any pending GetNameOwner call.
	(dbus_g_proxy_init): Initialize pending calls map.
	(dbus_g_proxy_constructor): New.
	(dbus_g_proxy_class_init): Add get/set property functions,
	constructor, and add NAME, PATH, and INTERFACE properties.
	(cancel_pending_call): New function.
	(dbus_g_proxy_dispose): Iterate over any outstanding calls and
	cancel them.
	(dbus_g_proxy_set_property, dbus_g_proxy_get_property): New.
	(GPendingNotifyClosure): New structure.
	(d_pending_call_notify, d_pending_call_free): Moved here from
	dbus-glib.c.
	(DBUS_G_VALUE_ARRAY_COLLECT_ALL): Moved around to satisfy function
	ordering.
	(manager_begin_bus_call): New internal function for talking to
	internal bus proxy.
	(dbus_g_proxy_new): Construct object using GObjet properties.
	(dbus_g_proxy_begin_call_internal): Update to take user data, etc.
	Create closure of same, and insert call into map of pending calls.
	(dbus_g_proxy_end_call_internal): Take call id instead of pending
	call.  Look up pending call in current set.  Remove it when we've
	completed.
	(dbus_g_pending_call_end, dbus_g_proxy_end_call_internal): Delete.
	(dbus_g_proxy_begin_call): Change API to take callback, user data,
	and destroy function directly.
	(dbus_g_proxy_end_call): Update to take DBusGProxyCall.
	(dbus_g_proxy_call): Invoke with NULL callback.
	(dbus_g_proxy_cancel_call): New function, replaces
	dbus_g_pending_call_cancel.

	* glib/dbus-gparser.c (validate_signature): Fix call to
	dbus_set_g_error.

	* glib/dbus-gobject.c (dbus_g_object_type_dbus_metadata_quark):
	New quark for attaching metadata to GType.
	(info_hash): Delete.
	(lookup_object_info): Look up using quark.
	(dbus_g_object_type_install_info): Check that a type is classed,
	not that it's an object.  Also just install type data using quark
	instead of using global hash.

	* glib/dbus-glib.c (dbus_g_pending_call_ref) 
	(dbus_g_pending_call_unref, dbus_pending_call_get_g_type)
	(GPendingNotifyClosure): Delete.
	(d_pending_call_notify, d_pending_call_free): Move to dbus-gproxy.c.
	(dbus_g_pending_call_set_notify, dbus_g_pending_call_cancel): Delete.

	* glib/dbus-binding-tool-glib.c (generate_client_glue): Disable async
	client method generation until we can fix it...
	
	* tools/dbus-viewer.c (load_child_nodes): Use dbus_g_proxy_call.
	(load_from_service_thread_func): Ditto.

	* tools/dbus-names-model.c (struct NamesModel): Hold
	DBusGProxyCall.
	(have_names_notify): Update prototype, use
	dbus_g_proxy_cancel_call.
	(names_model_reload): Update for new dbus_g_proxy_begin_call API.

	* tools/dbus-monitor.c (filter_func): Update for print_message
	API change.

	* test/glib/test-dbus-glib.c: Add more tests for async
	invocations.  Update many begin_call/end_call pairs to just use
	dbus_g_proxy_call.

	* tools/dbus-send.c (main): Add --print-reply=literal mode.  This
	allows us to dump print-introspect.c.

	* tools/dbus-print-message.h (print_message): Add literal argument
	to print_message which is intended to allow printing arguments without
	metadata like "string=".

	* tools/dbus-print-message.c (print_iter): Add literal argument.
	(print_message): Allow printing string messages literally.


Index: print-introspect.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/print-introspect.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- print-introspect.c	13 Jun 2005 03:01:17 -0000	1.2
+++ print-introspect.c	6 Jul 2005 21:27:45 -0000	1.3
@@ -37,7 +37,6 @@
 {
   DBusGConnection *connection;
   DBusGProxy *proxy;
-  DBusGPendingCall *call;
   GError *error;
   const char *service;
   const char *path;
@@ -64,9 +63,10 @@
   proxy = dbus_g_proxy_new_for_name (connection,
 				     service, path,
 				     DBUS_INTERFACE_INTROSPECTABLE);
-  call = dbus_g_proxy_begin_call (proxy, "Introspect", G_TYPE_INVALID);
-  if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING,
-			      &introspect_data, G_TYPE_INVALID))
+  if (!dbus_g_proxy_call (proxy, "Introspect",  &error,
+			  G_TYPE_INVALID,
+			  G_TYPE_STRING, &introspect_data,
+			  G_TYPE_INVALID))
     {
       fprintf (stderr, "Failed to get introspection data: %s\n",
                error->message);

Index: dbus-viewer.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-viewer.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- dbus-viewer.c	13 Jun 2005 03:01:17 -0000	1.13
+++ dbus-viewer.c	6 Jul 2005 21:27:45 -0000	1.14
@@ -147,14 +147,12 @@
   while (tmp != NULL)
     {
       DBusGProxy *proxy;
-      DBusGPendingCall *call;
       char *data;
       NodeInfo *child;
       NodeInfo *complete_child;
       int save_len;
 
       complete_child = NULL;
-      call = NULL;
       
       child = tmp->data;
 
@@ -183,17 +181,11 @@
             goto done;
         }
   
-      call = dbus_g_proxy_begin_call (proxy, "Introspect",
-                                      G_TYPE_INVALID);
-      
-      data = NULL;
-      if (!dbus_g_proxy_end_call (proxy, call, error, G_TYPE_STRING, &data,
-                                  G_TYPE_INVALID))
-	{
-	  call = NULL;
+      if (!dbus_g_proxy_call (proxy, "Introspect", error,
+			      G_TYPE_STRING, &data,
+			      G_TYPE_INVALID,
+			      G_TYPE_INVALID))
 	  goto done;
-	}
-      call = NULL;
       
       complete_child = description_load_from_string (data, -1, error);
       g_free (data);
@@ -204,8 +196,6 @@
         }
       
     done:
-      if (call)
-        dbus_g_pending_call_unref (call);
       g_object_unref (proxy);
 
       if (complete_child == NULL)
@@ -271,7 +261,6 @@
 load_from_service_thread_func (void *thread_data)
 {  
   DBusGProxy *root_proxy;
-  DBusGPendingCall *call;
   const char *data;
   NodeInfo *node;
   GString *path;
@@ -280,7 +269,6 @@
   lfsd = thread_data;
 
   node = NULL;
-  call = NULL;
   path = NULL;
  
 #if 1
@@ -304,19 +292,15 @@
     }
 #endif
   
-  call = dbus_g_proxy_begin_call (root_proxy, "Introspect",
-                                  G_TYPE_INVALID);
-
-  data = NULL;
-  if (!dbus_g_proxy_end_call (root_proxy, call, &lfsd->error, G_TYPE_STRING, &data,
-                              G_TYPE_INVALID))
+  if (!dbus_g_proxy_call (root_proxy, "Introspect", &lfsd->error,
+			  G_TYPE_INVALID,
+			  G_TYPE_STRING, &data,
+			  G_TYPE_INVALID))
     {
-      call = NULL;
       g_printerr ("Failed to Introspect() %s\n",
-                  dbus_g_proxy_get_bus_name (root_proxy));
+		  dbus_g_proxy_get_bus_name (root_proxy));
       goto out;
     }
-  call = NULL;
 
   node = description_load_from_string (data, -1, &lfsd->error);
 
@@ -338,9 +322,6 @@
     }
   
  out:
-  if (call)
-    dbus_g_pending_call_unref (call);
-    
   g_object_unref (root_proxy);
 
   if (path)

Index: dbus-send.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-send.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- dbus-send.c	29 Jun 2005 16:58:59 -0000	1.17
+++ dbus-send.c	6 Jul 2005 21:27:45 -0000	1.18
@@ -32,7 +32,7 @@
 static void
 usage (int ecode)
 {
-  fprintf (stderr, "Usage: %s [--help] [--system | --session] [--dest=NAME] [--type=TYPE] [--print-reply] [--reply-timeout=MSEC] <destination object path> <message name> [contents ...]\n", appname);
+  fprintf (stderr, "Usage: %s [--help] [--system | --session] [--dest=NAME] [--type=TYPE] [--print-reply=(literal)] [--reply-timeout=MSEC] <destination object path> <message name> [contents ...]\n", appname);
   exit (ecode);
 }
 
@@ -183,6 +183,7 @@
   DBusError error;
   DBusMessage *message;
   int print_reply;
+  int print_reply_literal;
   int reply_timeout;
   DBusMessageIter iter;
   int i;
@@ -199,6 +200,7 @@
     usage (1);
 
   print_reply = FALSE;
+  print_reply_literal = FALSE;
   reply_timeout = -1;
   
   for (i = 1; i < argc && name == NULL; i++)
@@ -209,10 +211,12 @@
 	type = DBUS_BUS_SYSTEM;
       else if (strcmp (arg, "--session") == 0)
 	type = DBUS_BUS_SESSION;
-      else if (strcmp (arg, "--print-reply") == 0)
+      else if (strncmp (arg, "--print-reply", 13) == 0)
 	{
 	  print_reply = TRUE;
 	  message_type = DBUS_MESSAGE_TYPE_METHOD_CALL;
+	  if (*(arg + 13) != '\0')
+	    print_reply_literal = TRUE;
 	}
       else if (strstr (arg, "--reply-timeout=") == arg)
 	{
@@ -436,7 +440,7 @@
 
       if (reply)
         {
-          print_message (reply);
+          print_message (reply, print_reply_literal);
           dbus_message_unref (reply);
         }
     }

Index: dbus-print-message.h
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-print-message.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbus-print-message.h	16 May 2003 20:09:25 -0000	1.1
+++ dbus-print-message.h	6 Jul 2005 21:27:45 -0000	1.2
@@ -26,6 +26,6 @@
 #include <string.h>
 #include <dbus/dbus.h>
 
-void print_message (DBusMessage *message);
+void print_message (DBusMessage *message, dbus_bool_t literal);
 
 #endif /* DBUS_PRINT_MESSAGE_H */

Index: dbus-print-message.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-print-message.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbus-print-message.c	16 Jun 2005 04:48:10 -0000	1.7
+++ dbus-print-message.c	6 Jul 2005 21:27:45 -0000	1.8
@@ -40,7 +40,7 @@
 }
 
 static void
-print_iter (DBusMessageIter *iter, int depth)
+print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
 {
   do
     {
@@ -62,7 +62,11 @@
 	{
 	case DBUS_TYPE_STRING:
           dbus_message_iter_get_basic (iter, &str);
-	  printf ("string \"%s\"\n", str);
+	  if (!literal)
+	    printf ("string \"");
+	  printf ("%s", str);
+	  if (!literal)
+	    printf ("\"\n");
 	  break;
 
 	case DBUS_TYPE_INT32:
@@ -97,7 +101,7 @@
 	    dbus_message_iter_recurse (iter, &subiter);
 
 	    printf ("variant:");
-	    print_iter (&subiter, depth);
+	    print_iter (&subiter, literal, depth);
 	    break;
 	  }
 	case DBUS_TYPE_ARRAY:
@@ -110,7 +114,7 @@
 	    printf("[");
 	    while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID)
 	      {
-		print_iter (&subiter, depth);
+		print_iter (&subiter, literal, depth);
 		dbus_message_iter_next (&subiter);
 		if (dbus_message_iter_get_arg_type (&subiter) != DBUS_TYPE_INVALID)
 		  printf (",");
@@ -125,9 +129,9 @@
 	    dbus_message_iter_recurse (iter, &subiter);
 
 	    printf("{");
-	    print_iter (&subiter, depth);
+	    print_iter (&subiter, literal, depth);
 	    dbus_message_iter_next (&subiter);
-	    print_iter (&subiter, depth);
+	    print_iter (&subiter, literal, depth);
 	    printf("}");
 	    break;
 	  }
@@ -141,7 +145,7 @@
 }
 
 void
-print_message (DBusMessage *message)
+print_message (DBusMessage *message, dbus_bool_t literal)
 {
   DBusMessageIter iter;
   const char *sender;
@@ -151,37 +155,40 @@
   message_type = dbus_message_get_type (message);
   sender = dbus_message_get_sender (message);
   destination = dbus_message_get_destination (message);
-
-  printf ("%s sender=%s -> dest=%s",
-          type_to_name (message_type),
-          sender ? sender : "(null sender)",
-          destination ? destination : "(null destination)");
-         
-  switch (message_type)
+  
+  if (!literal)
     {
-    case DBUS_MESSAGE_TYPE_METHOD_CALL:
-    case DBUS_MESSAGE_TYPE_SIGNAL:
-      printf (" interface=%s; member=%s\n",
-              dbus_message_get_interface (message),
-              dbus_message_get_member (message));
-      break;
+      printf ("%s sender=%s -> dest=%s",
+	      type_to_name (message_type),
+	      sender ? sender : "(null sender)",
+	      destination ? destination : "(null destination)");
+  
+      switch (message_type)
+	{
+	case DBUS_MESSAGE_TYPE_METHOD_CALL:
+	case DBUS_MESSAGE_TYPE_SIGNAL:
+	  printf (" interface=%s; member=%s\n",
+		  dbus_message_get_interface (message),
+		  dbus_message_get_member (message));
+	  break;
       
-    case DBUS_MESSAGE_TYPE_METHOD_RETURN:
-      printf ("\n");
-      break;
+	case DBUS_MESSAGE_TYPE_METHOD_RETURN:
+	  printf ("\n");
+	  break;
 
-    case DBUS_MESSAGE_TYPE_ERROR:
-      printf (" error_name=%s\n",
-              dbus_message_get_error_name (message));
-      break;
+	case DBUS_MESSAGE_TYPE_ERROR:
+	  printf (" error_name=%s\n",
+		  dbus_message_get_error_name (message));
+	  break;
 
-    default:
-      printf ("\n");
-      break;
+	default:
+	  printf ("\n");
+	  break;
+	}
     }
 
   dbus_message_iter_init (message, &iter);
-  print_iter (&iter, 1);
+  print_iter (&iter, literal, 1);
   
 }
 

Index: dbus-names-model.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-names-model.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbus-names-model.c	17 Jun 2005 17:10:41 -0000	1.7
+++ dbus-names-model.c	6 Jul 2005 21:27:45 -0000	1.8
@@ -43,7 +43,7 @@
   GtkListStore parent;
   DBusGConnection *connection;
   DBusGProxy *driver_proxy;
-  DBusGPendingCall *pending_list_names;
+  DBusGProxyCall *pending_list_names;
 };
 
 struct NamesModelClass
@@ -59,7 +59,8 @@
 #define NAMES_MODEL_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NAMES_MODEL, NamesModelClass))
 
 static void
-have_names_notify (DBusGPendingCall *call,
+have_names_notify (DBusGProxy       *proxy,
+		   DBusGProxyCall   *call,
                    void             *data)
 {
   NamesModel *names_model;
@@ -69,7 +70,7 @@
 
   names_model = NAMES_MODEL (data);
 
-  g_assert (names_model->pending_list_names);
+  g_assert (names_model->pending_list_names == call);
   g_assert (names_model->driver_proxy);
 
   names = NULL;
@@ -195,8 +196,8 @@
 
   if (names_model->pending_list_names)
     {
-      dbus_g_pending_call_cancel (names_model->pending_list_names);
-      dbus_g_pending_call_unref (names_model->pending_list_names);
+      dbus_g_proxy_cancel_call (names_model->driver_proxy,
+				names_model->pending_list_names);
       names_model->pending_list_names = NULL;
     }
   
@@ -208,10 +209,8 @@
   names_model->pending_list_names =
     dbus_g_proxy_begin_call (names_model->driver_proxy,
                              "ListNames",
+			     have_names_notify, names_model, NULL,
                              G_TYPE_INVALID);
-
-  dbus_g_pending_call_set_notify (names_model->pending_list_names,
-                                  have_names_notify, names_model, NULL);
 }
 
 static void

Index: dbus-monitor.c
===================================================================
RCS file: /cvs/dbus/dbus/tools/dbus-monitor.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- dbus-monitor.c	17 Feb 2005 21:19:48 -0000	1.13
+++ dbus-monitor.c	6 Jul 2005 21:27:45 -0000	1.14
@@ -32,7 +32,7 @@
              DBusMessage        *message,
              void               *user_data)
 {
-  print_message (message);
+  print_message (message, FALSE);
   
   if (dbus_message_is_signal (message,
                               DBUS_INTERFACE_LOCAL,



More information about the dbus-commit mailing list