dbus/bus activation.c, 1.36, 1.37 connection.c, 1.56, 1.57 dispatch.c, 1.64, 1.65 driver.c, 1.57, 1.58 services.c, 1.27, 1.28 signals.c, 1.9, 1.10

Havoc Pennington hp@freedesktop.org
Fri Jan 14 23:15:40 PST 2005


Update of /cvs/dbus/dbus/bus
In directory gabe:/tmp/cvs-serv28195/bus

Modified Files:
	activation.c connection.c dispatch.c driver.c services.c 
	signals.c 
Log Message:
2005-01-15  Havoc Pennington  <hp@redhat.com>

	* Land the new message args API and type system.

	This patch is huge, but the public API change is not 
	really large. The set of D-BUS types has changed somewhat, 
	and the arg "getters" are more geared toward language bindings;
	they don't make a copy, etc.

	There are also some known issues. See these emails for details
	on this huge patch:
	http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
        http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
	
	* dbus/dbus-marshal-*: all the new stuff

	* dbus/dbus-message.c: basically rewritten

	* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
	freed blocks to be all non-nul bytes so using freed memory is less
	likely to work right

	* dbus/dbus-internals.c (_dbus_test_oom_handling): add
	DBUS_FAIL_MALLOC=N environment variable, so you can do
	DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
	DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
	thorough.

	* qt/message.cpp: port to the new message args API
	(operator<<): use str.utf8() rather than str.unicode()
	(pretty sure this is right from the Qt docs?)

	* glib/dbus-gvalue.c: port to the new message args API

	* bus/dispatch.c, bus/driver.c: port to the new message args API

	* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
	"locked" flag to TRUE and align_offset to 0; I guess we never
	looked at these anyhow, but seems cleaner.

	* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
	move allocation padding macro to this header; use it to implement
	(_DBUS_STRING_STATIC): ability to declare a static string.

	* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
	change to return TRUE if the interface is not set.

	* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
	to dbus-marshal-validate.[hc]

	* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
	dbus-internals.c

	* dbus/Makefile.am: cut over from dbus-marshal.[hc]
	to dbus-marshal-*.[hc]

	* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
	function here from dbus-marshal.c



Index: activation.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/activation.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- activation.c	10 Aug 2004 03:06:59 -0000	1.36
+++ activation.c	15 Jan 2005 07:15:38 -0000	1.37
@@ -93,6 +93,7 @@
   unsigned int timeout_added : 1;
 } BusPendingActivation;
 
+#if 0
 static BusServiceDirectory *
 bus_service_directory_ref (BusServiceDirectory *dir)
 {
@@ -102,6 +103,7 @@
 
   return dir;
 }
+#endif
 
 static void
 bus_service_directory_unref (BusServiceDirectory *dir)
@@ -909,15 +911,19 @@
 	  /* Only send activation replies to regular activation requests. */
 	  if (!entry->auto_activation)
 	    {
+              dbus_uint32_t result;
+              
 	      message = dbus_message_new_method_return (entry->activation_message);
 	      if (!message)
 		{
 		  BUS_SET_OOM (error);
 		  goto error;
 		}
-	      
+
+              result = DBUS_ACTIVATION_REPLY_ACTIVATED;
+              
 	      if (!dbus_message_append_args (message,
-					     DBUS_TYPE_UINT32, DBUS_ACTIVATION_REPLY_ACTIVATED,
+					     DBUS_TYPE_UINT32, &result,
 					     DBUS_TYPE_INVALID))
 		{
 		  dbus_message_unref (message);
@@ -1328,6 +1334,8 @@
       _dbus_string_init_const (&service_str, service_name);
       if (bus_registry_lookup (bus_context_get_registry (activation->context), &service_str) != NULL)
         {
+          dbus_uint32_t result;
+          
           _dbus_verbose ("Service \"%s\" is already active\n", service_name);
       
           message = dbus_message_new_method_return (activation_message);
@@ -1339,8 +1347,10 @@
               return FALSE;
             }
 
+          result = DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE;
+          
           if (!dbus_message_append_args (message,
-                                         DBUS_TYPE_UINT32, DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE, 
+                                         DBUS_TYPE_UINT32, &result,
                                          DBUS_TYPE_INVALID))
             {
               _dbus_verbose ("No memory to set args of reply to activate message\n");

Index: connection.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/connection.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- connection.c	10 Aug 2004 03:06:59 -0000	1.56
+++ connection.c	15 Jan 2005 07:15:38 -0000	1.57
@@ -1398,6 +1398,7 @@
   DBusMessage *message;
   DBusMessageIter iter;
   dbus_bool_t retval;
+  const char *errmsg;
 
   retval = FALSE;
   
@@ -1414,9 +1415,10 @@
   if (!dbus_message_set_error_name (message,
                                     DBUS_ERROR_NO_REPLY))
     goto out;
-  
+
+  errmsg = "Message did not receive a reply (timeout by message bus)";
   dbus_message_append_iter_init (message, &iter);
-  if (!dbus_message_iter_append_string (&iter, "Message did not receive a reply (timeout by message bus)"))
+  if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errmsg))
     goto out;
     
   if (!bus_transaction_send_from_driver (transaction, pending->will_get_reply,

Index: dispatch.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/dispatch.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- dispatch.c	26 Nov 2004 01:53:13 -0000	1.64
+++ dispatch.c	15 Jan 2005 07:15:38 -0000	1.65
@@ -2,7 +2,7 @@
 /* dispatch.c  Message dispatcher
  *
  * Copyright (C) 2003  CodeFactory AB
- * Copyright (C) 2003, 2004  Red Hat, Inc.
+ * Copyright (C) 2003, 2004, 2005  Red Hat, Inc.
  * Copyright (C) 2004  Imendio HB
  *
  * Licensed under the Academic Free License version 2.1
@@ -526,7 +526,7 @@
   CheckServiceOwnerChangedData *d = data;
   DBusMessage *message;
   DBusError error;
-  char *service_name, *old_owner, *new_owner;
+  const char *service_name, *old_owner, *new_owner;
 
   if (d->expected_kind == SERVICE_CREATED 
       && connection == d->skip_connection)
@@ -567,9 +567,6 @@
 	{
 	  if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
 	    {
-              dbus_free (service_name);
-              dbus_free (old_owner);
-              dbus_free (new_owner);
               dbus_error_free (&error);
               _dbus_wait_for_memory ();              
               goto reget_service_info_data;
@@ -609,9 +606,6 @@
   d->failed = FALSE;
   
  out:
-  dbus_free (service_name);
-  dbus_free (old_owner);
-  dbus_free (new_owner);
   dbus_error_free (&error);
   
   if (message)
@@ -725,7 +719,11 @@
                             &nmd);
   
   if (nmd.failed)
-    return FALSE;
+    {
+      _dbus_verbose ("%s: leftover message found\n",
+                     _DBUS_FUNCTION_NAME);
+      return FALSE;
+    }
   else
     return TRUE;
 }
@@ -738,17 +736,19 @@
                      DBusConnection *connection)
 {
   DBusMessage *message;
+  DBusMessage *name_message;
   dbus_uint32_t serial;
   dbus_bool_t retval;
   DBusError error;
-  char *name;
-  char *acquired;
+  const char *name;
+  const char *acquired;
 
   retval = FALSE;
   dbus_error_init (&error);
   name = NULL;
   acquired = NULL;
   message = NULL;
+  name_message = NULL;
 
   _dbus_verbose ("check_hello_message for %p\n", connection);
   
@@ -889,9 +889,10 @@
       
       if (socd.failed)
         goto out;
-      
+
+      name_message = message;
       /* Client should also have gotten ServiceAcquired */
-      dbus_message_unref (message);
+
       message = pop_message_waiting_for_memory (connection);
       if (message == NULL)
         {
@@ -935,6 +936,7 @@
                       acquired, name);
           goto out;
         }
+      acquired = NULL;
     }
 
   if (!check_no_leftovers (context))
@@ -943,13 +945,15 @@
   retval = TRUE;
   
  out:
-  dbus_error_free (&error);
+  _dbus_verbose ("ending %s retval = %d\n", _DBUS_FUNCTION_NAME, retval);
   
-  dbus_free (name);
-  dbus_free (acquired);
+  dbus_error_free (&error);
   
   if (message)
     dbus_message_unref (message);
+
+  if (name_message)
+    dbus_message_unref (name_message);
   
   return retval;
 }
@@ -1075,7 +1079,7 @@
   base_service_name = dbus_bus_get_base_service (connection);
 
   if (!dbus_message_append_args (message, 
-                                 DBUS_TYPE_STRING, base_service_name,
+                                 DBUS_TYPE_STRING, &base_service_name,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (message);
@@ -1212,7 +1216,7 @@
   base_service_name = dbus_bus_get_base_service (connection);
 
   if (!dbus_message_append_args (message, 
-                                 DBUS_TYPE_STRING, base_service_name,
+                                 DBUS_TYPE_STRING, &base_service_name,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (message);
@@ -1344,6 +1348,7 @@
   dbus_bool_t retval;
   dbus_uint32_t serial;
   DBusError error;
+  const char *empty = "";
 
   retval = FALSE;
   dbus_error_init (&error);
@@ -1360,7 +1365,7 @@
     return TRUE;
 
   /* empty string match rule matches everything */
-  if (!dbus_message_append_args (message, DBUS_TYPE_STRING, "",
+  if (!dbus_message_append_args (message, DBUS_TYPE_STRING, &empty,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (message);
@@ -1525,6 +1530,8 @@
   DBusMessage *message;
   dbus_uint32_t serial;
   dbus_bool_t retval;
+  const char *nonexistent = NONEXISTENT_SERVICE_NAME;
+  dbus_uint32_t flags;
   
   message = dbus_message_new_method_call (DBUS_SERVICE_ORG_FREEDESKTOP_DBUS,
                                           DBUS_PATH_ORG_FREEDESKTOP_DBUS,
@@ -1534,9 +1541,10 @@
   if (message == NULL)
     return TRUE;
 
+  flags = 0;
   if (!dbus_message_append_args (message,
-                                 DBUS_TYPE_STRING, NONEXISTENT_SERVICE_NAME,
-                                 DBUS_TYPE_UINT32, 0,
+                                 DBUS_TYPE_STRING, &nonexistent,
+                                 DBUS_TYPE_UINT32, &flags,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (message);
@@ -1715,12 +1723,12 @@
 check_base_service_activated (BusContext     *context,
                               DBusConnection *connection,
                               DBusMessage    *initial_message,
-                              char          **base_service_p)
+                              const char    **base_service_p)
 {
   DBusMessage *message;
   dbus_bool_t retval;
   DBusError error;
-  char *base_service, *base_service_from_bus, *old_owner;
+  const char *base_service, *base_service_from_bus, *old_owner;
   
   retval = FALSE;
   
@@ -1752,9 +1760,6 @@
           if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
             {
               dbus_error_free (&error);
-              dbus_free (base_service);
-              dbus_free (old_owner);
-              dbus_free (base_service_from_bus);
               _dbus_wait_for_memory ();
               goto reget_service_name_arg;
             }
@@ -1805,20 +1810,14 @@
       goto out;
     }
 
-  retval = TRUE;
-
   if (base_service_p)
-    {
-      *base_service_p = base_service;
-      base_service = NULL;
-    }
+    *base_service_p = base_service;
+
+  retval = TRUE;
   
  out:
   if (message)
     dbus_message_unref (message);
-  dbus_free (base_service);
-  dbus_free (base_service_from_bus);
-  dbus_free (old_owner);
   dbus_error_free (&error);
 
   return retval;
@@ -1848,7 +1847,7 @@
                               "ServiceOwnerChanged"))
     {
       CheckServiceOwnerChangedData socd;
-      char *service_name, *base_service_from_bus, *old_owner;
+      const char *service_name, *base_service_from_bus, *old_owner;
 
     reget_service_name_arg:
       service_name = NULL;
@@ -1864,9 +1863,6 @@
           if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
             {
               dbus_error_free (&error);
- 	      dbus_free (service_name);
- 	      dbus_free (old_owner);
- 	      dbus_free (base_service_from_bus);
               _dbus_wait_for_memory ();
               goto reget_service_name_arg;
             }
@@ -1875,9 +1871,6 @@
               _dbus_warn ("Message %s doesn't have a service name: %s\n",
                           "ServiceOwnerChanged (creation)",
                           error.message);
- 	      dbus_free (service_name);
- 	      dbus_free (old_owner);
- 	      dbus_free (base_service_from_bus);
               goto out;
             }
         }
@@ -1886,9 +1879,6 @@
         {
           _dbus_warn ("Expected to see service %s created, saw %s instead\n",
                       activated_name, service_name);
-          dbus_free (service_name);
-          dbus_free (old_owner);
-          dbus_free (base_service_from_bus);
           goto out;
         }
 
@@ -1896,23 +1886,16 @@
         {
           _dbus_warn ("ServiceOwnerChanged reports wrong base service: %s owner, expected %s instead\n",
                       base_service_from_bus, base_service_name);
-          dbus_free (service_name);
-          dbus_free (old_owner);
-          dbus_free (base_service_from_bus);
           goto out;
         }
-      dbus_free (base_service_from_bus);
 
       if (old_owner[0])
         {
           _dbus_warn ("expected a %s, got a %s\n",
                       "ServiceOwnerChanged (creation)",
                       "ServiceOwnerChanged (change)");
-          dbus_free (service_name);
-          dbus_free (old_owner);
           goto out;
         }
-      dbus_free (old_owner);
 
       socd.expected_kind = SERVICE_CREATED;
       socd.skip_connection = connection;
@@ -1920,13 +1903,15 @@
       socd.expected_service_name = service_name;
       bus_test_clients_foreach (check_service_owner_changed_foreach,
                                 &socd);
-
-      dbus_free (service_name);
           
       if (socd.failed)
         goto out;
           
       dbus_message_unref (message);
+      service_name = NULL;
+      old_owner = NULL;
+      base_service_from_bus = NULL;
+      
       message = pop_message_waiting_for_memory (connection);
       if (message == NULL)
         {
@@ -2018,7 +2003,7 @@
                               DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
                               "ServiceOwnerChanged"))
     {
-      char *service_name;
+      const char *service_name;
       CheckServiceOwnerChangedData socd;
       
     reget_service_name_arg:
@@ -2046,7 +2031,6 @@
         {
           _dbus_warn ("Expected to see service %s created, saw %s instead\n",
                       activated_name, service_name);
-          dbus_free (service_name);
           goto out;
         }
       
@@ -2057,8 +2041,6 @@
       bus_test_clients_foreach (check_service_owner_changed_foreach,
 				&socd);
       
-      dbus_free (service_name);
-      
       if (socd.failed)
         goto out;
       
@@ -2068,6 +2050,7 @@
       
       dbus_message_unref (message);
       message = NULL;
+      service_name = NULL;
     }
   else
     {
@@ -2245,7 +2228,7 @@
       if (!dbus_message_is_error (message,
                                   DBUS_ERROR_NO_REPLY))
         {
-          warn_unexpected (connection, NULL,
+          warn_unexpected (connection, message,
                            "NoReply error from Exit() method call");
           goto out;
         }
@@ -2355,7 +2338,7 @@
                               "ServiceOwnerChanged"))
     {
       DBusError error;
-      char *service_name, *old_owner, *new_owner;
+      const char *service_name, *old_owner, *new_owner;
       dbus_error_init (&error);
 
     reget_service_info_data:
@@ -2373,9 +2356,6 @@
           if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
             {
               dbus_error_free (&error);
-              dbus_free (service_name);
-              dbus_free (old_owner);
-              dbus_free (new_owner);
               goto reget_service_info_data;
             }
           else
@@ -2391,9 +2371,6 @@
       else
         message_kind = GOT_SOMETHING_ELSE;
 
-      dbus_free (service_name);
-      dbus_free (old_owner);
-      dbus_free (new_owner);
       dbus_error_free (&error);
     }
   else if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR)
@@ -2414,11 +2391,14 @@
                                    DBusConnection *connection)
 {
   DBusMessage *message;
+  DBusMessage *base_service_message;
+  const char *base_service;
   dbus_uint32_t serial;
   dbus_bool_t retval;
-  char *base_service;
+  const char *existent = EXISTENT_SERVICE_NAME;
+  dbus_uint32_t flags;
 
-  base_service = NULL;
+  base_service_message = NULL;
   
   message = dbus_message_new_method_call (DBUS_SERVICE_ORG_FREEDESKTOP_DBUS,
                                           DBUS_PATH_ORG_FREEDESKTOP_DBUS,
@@ -2428,9 +2408,10 @@
   if (message == NULL)
     return TRUE;
 
+  flags = 0;
   if (!dbus_message_append_args (message,
-                                 DBUS_TYPE_STRING, EXISTENT_SERVICE_NAME,
-                                 DBUS_TYPE_UINT32, 0,
+                                 DBUS_TYPE_STRING, &existent,
+                                 DBUS_TYPE_UINT32, &flags,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (message);
@@ -2511,7 +2492,7 @@
                                          message, &base_service))
         goto out;
 
-      dbus_message_unref (message);
+      base_service_message = message;
       message = NULL;
 
       /* We may need to block here for the test service to exit or finish up */
@@ -2620,8 +2601,8 @@
   if (message)
     dbus_message_unref (message);
 
-  if (base_service)
-    dbus_free (base_service);
+  if (base_service_message)
+    dbus_message_unref (base_service_message);
   
   return retval;
 }
@@ -2636,6 +2617,8 @@
   DBusMessage *message;
   dbus_uint32_t serial;
   dbus_bool_t retval;
+  const char *segv_service;
+  dbus_uint32_t flags;
   
   message = dbus_message_new_method_call (DBUS_SERVICE_ORG_FREEDESKTOP_DBUS,
                                           DBUS_PATH_ORG_FREEDESKTOP_DBUS,
@@ -2645,10 +2628,11 @@
   if (message == NULL)
     return TRUE;
 
+  segv_service = "org.freedesktop.DBus.TestSuiteSegfaultService";
+  flags = 0;
   if (!dbus_message_append_args (message,
-                                 DBUS_TYPE_STRING,
-                                 "org.freedesktop.DBus.TestSuiteSegfaultService",
-                                 DBUS_TYPE_UINT32, 0,
+                                 DBUS_TYPE_STRING, &segv_service,
+                                 DBUS_TYPE_UINT32, &flags,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (message);
@@ -2833,11 +2817,13 @@
 					DBusConnection *connection)
 {
   DBusMessage *message;
+  DBusMessage *base_service_message;
   dbus_uint32_t serial;
   dbus_bool_t retval;
-  char *base_service;
+  const char *base_service;
+  const char *text;
 
-  base_service = NULL;
+  base_service_message = NULL;
 
   message = dbus_message_new_method_call (EXISTENT_SERVICE_NAME,
                                           "/org/freedesktop/TestSuite",
@@ -2849,8 +2835,9 @@
 
   dbus_message_set_auto_activation (message, TRUE);
 
+  text = TEST_ECHO_MESSAGE;
   if (!dbus_message_append_args (message,
-                                 DBUS_TYPE_STRING, TEST_ECHO_MESSAGE,
+                                 DBUS_TYPE_STRING, &text,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (message);
@@ -2902,7 +2889,7 @@
                                          message, &base_service))
 	goto out;
 
-      dbus_message_unref (message);
+      base_service_message = message;
       message = NULL;
 
       /* We may need to block here for the test service to exit or finish up */
@@ -3010,8 +2997,8 @@
   if (message)
     dbus_message_unref (message);
 
-  if (base_service)
-    dbus_free (base_service);
+  if (base_service_message)
+    dbus_message_unref (base_service_message);
 
   return retval;
 }

Index: driver.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/driver.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- driver.c	26 Nov 2004 01:53:13 -0000	1.57
+++ driver.c	15 Jan 2005 07:15:38 -0000	1.58
@@ -47,10 +47,11 @@
 {
   DBusMessage *message;
   dbus_bool_t retval;
-  const char null_service[] = { '\000' };
+  const char *null_service;
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
-  
+
+  null_service = "";
   _dbus_verbose ("sending service owner changed: %s [%s -> %s]\n",
                  service_name, 
                  old_owner ? old_owner : null_service, 
@@ -70,9 +71,9 @@
     goto oom;
 
   if (!dbus_message_append_args (message,
-                                 DBUS_TYPE_STRING, service_name,
-                                 DBUS_TYPE_STRING, old_owner ? old_owner : null_service,
-                                 DBUS_TYPE_STRING, new_owner ? new_owner : null_service,
+                                 DBUS_TYPE_STRING, &service_name,
+                                 DBUS_TYPE_STRING, old_owner ? &old_owner : &null_service,
+                                 DBUS_TYPE_STRING, new_owner ? &new_owner : &null_service,
                                  DBUS_TYPE_INVALID))
     goto oom;
 
@@ -111,7 +112,7 @@
   
   if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) ||
       !dbus_message_append_args (message,
-                                 DBUS_TYPE_STRING, service_name,
+                                 DBUS_TYPE_STRING, &service_name,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (message);
@@ -154,7 +155,7 @@
   
   if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) ||
       !dbus_message_append_args (message,
-                                 DBUS_TYPE_STRING, service_name,
+                                 DBUS_TYPE_STRING, &service_name,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (message);
@@ -341,7 +342,7 @@
     }
   
   if (!dbus_message_append_args (welcome,
-                                 DBUS_TYPE_STRING, name,
+                                 DBUS_TYPE_STRING, &name,
                                  DBUS_TYPE_INVALID))
     {
       dbus_message_unref (welcome);
@@ -374,6 +375,9 @@
   int len;
   char **services;
   BusRegistry *registry;
+  int i;
+  DBusMessageIter iter;
+  DBusMessageIter sub;
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   
@@ -392,10 +396,12 @@
       BUS_SET_OOM (error);
       return FALSE;
     }
+
+  dbus_message_append_iter_init (reply, &iter);
   
-  if (!dbus_message_append_args (reply,
-                                 DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, services, len,
-                                 DBUS_TYPE_INVALID))
+  if (!dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY,
+                                         DBUS_TYPE_STRING_AS_STRING,
+                                         &sub))
     {
       dbus_free_string_array (services);
       dbus_message_unref (reply);
@@ -403,6 +409,28 @@
       return FALSE;
     }
 
+  i = 0;
+  while (i < len)
+    {
+      if (!dbus_message_iter_append_basic (&sub, DBUS_TYPE_STRING,
+                                           &services[i]))
+        {
+          dbus_free_string_array (services);
+          dbus_message_unref (reply);
+          BUS_SET_OOM (error);
+          return FALSE;
+        }
+      ++i;
+    }
+
+  if (!dbus_message_iter_close_container (&iter, &sub))
+    {
+      dbus_free_string_array (services);
+      dbus_message_unref (reply);
+      BUS_SET_OOM (error);
+      return FALSE;
+    }
+  
   dbus_free_string_array (services);
   
   if (!bus_transaction_send_from_driver (transaction, connection, reply))
@@ -426,7 +454,7 @@
 {
   DBusMessage *reply;
   DBusString service_name;
-  char *name;
+  const char *name;
   int service_reply;
   dbus_uint32_t flags;
   dbus_bool_t retval;
@@ -462,7 +490,7 @@
       goto out;
     }
 
-  if (!dbus_message_append_args (reply, DBUS_TYPE_UINT32, service_reply, DBUS_TYPE_INVALID))
+  if (!dbus_message_append_args (reply, DBUS_TYPE_UINT32, &service_reply, DBUS_TYPE_INVALID))
     {
       BUS_SET_OOM (error);
       goto out;
@@ -477,7 +505,6 @@
   retval = TRUE;
   
  out:
-  dbus_free (name);
   if (reply)
     dbus_message_unref (reply);
   return retval;
@@ -492,8 +519,8 @@
   DBusMessage *reply;
   DBusString service_name;
   BusService *service;
-  dbus_bool_t service_exists;
-  char *name;
+  unsigned char service_exists;
+  const char *name;
   dbus_bool_t retval;
   BusRegistry *registry;
 
@@ -527,7 +554,7 @@
     }
 
   if (!dbus_message_append_args (reply,
-                                 DBUS_TYPE_BOOLEAN, service_exists,
+                                 DBUS_TYPE_BOOLEAN, &service_exists,
                                  0))
     {
       BUS_SET_OOM (error);
@@ -545,7 +572,6 @@
  out:
   if (reply)
     dbus_message_unref (reply);
-  dbus_free (name);
 
   return retval;
 }
@@ -557,7 +583,7 @@
                                     DBusError      *error)
 {
   dbus_uint32_t flags;
-  char *name;
+  const char *name;
   dbus_bool_t retval;
   BusActivation *activation;
 
@@ -588,7 +614,6 @@
   retval = TRUE;
   
  out:
-  dbus_free (name);
   return retval;
 }
 
@@ -626,7 +651,7 @@
                              DBusError      *error)
 {
   BusMatchRule *rule;
-  char *text;
+  const char *text;
   DBusString str;
   BusMatchmaker *matchmaker;
   
@@ -677,7 +702,6 @@
     }
   
   bus_match_rule_unref (rule);
-  dbus_free (text);
   
   return TRUE;
 
@@ -685,8 +709,6 @@
   _DBUS_ASSERT_ERROR_IS_SET (error);
   if (rule)
     bus_match_rule_unref (rule);
-  if (text)
-    dbus_free (text);
   return FALSE;
 }
 
@@ -697,7 +719,7 @@
                                 DBusError      *error)
 {
   BusMatchRule *rule;
-  char *text;
+  const char *text;
   DBusString str;
   BusMatchmaker *matchmaker;
   
@@ -733,7 +755,6 @@
     goto failed;
 
   bus_match_rule_unref (rule);
-  dbus_free (text);
   
   return TRUE;
 
@@ -741,8 +762,6 @@
   _DBUS_ASSERT_ERROR_IS_SET (error);
   if (rule)
     bus_match_rule_unref (rule);
-  if (text)
-    dbus_free (text);
   return FALSE;
 }
 
@@ -752,7 +771,7 @@
 				     DBusMessage    *message,
 				     DBusError      *error)
 {
-  char *text;
+  const char *text;
   const char *base_name;
   DBusString str;
   BusRegistry *registry;
@@ -796,7 +815,7 @@
     goto oom;
 
   if (! dbus_message_append_args (reply, 
-				  DBUS_TYPE_STRING, base_name,
+				  DBUS_TYPE_STRING, &base_name,
 				  DBUS_TYPE_INVALID))
     goto oom;
   
@@ -804,7 +823,6 @@
     goto oom;
 
   dbus_message_unref (reply);
-  dbus_free (text);
 
   return TRUE;
 
@@ -815,7 +833,6 @@
   _DBUS_ASSERT_ERROR_IS_SET (error);
   if (reply)
     dbus_message_unref (reply);
-  dbus_free (text);
   return FALSE;
 }
 
@@ -825,13 +842,14 @@
                                             DBusMessage    *message,
                                             DBusError      *error)
 {
-  char *service;
+  const char *service;
   DBusString str;
   BusRegistry *registry;
   BusService *serv;
   DBusConnection *conn;
   DBusMessage *reply;
   unsigned long uid;
+  dbus_uint32_t uid32;
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
@@ -871,8 +889,9 @@
       goto failed;
     }
 
+  uid32 = uid;
   if (! dbus_message_append_args (reply,
-                                  DBUS_TYPE_UINT32, (dbus_uint32_t) uid,
+                                  DBUS_TYPE_UINT32, &uid32,
                                   DBUS_TYPE_INVALID))
     goto oom;
 
@@ -880,7 +899,6 @@
     goto oom;
 
   dbus_message_unref (reply);
-  dbus_free (service);
 
   return TRUE;
 
@@ -891,7 +909,6 @@
   _DBUS_ASSERT_ERROR_IS_SET (error);
   if (reply)
     dbus_message_unref (reply);
-  dbus_free (service);
   return FALSE;
 }
 
@@ -901,13 +918,14 @@
 						  DBusMessage    *message,
 						  DBusError      *error)
 {
-  char *service;
+  const char *service;
   DBusString str;
   BusRegistry *registry;
   BusService *serv;
   DBusConnection *conn;
   DBusMessage *reply;
   unsigned long pid;
+  dbus_uint32_t pid32;
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
@@ -947,8 +965,9 @@
       goto failed;
     }
 
+  pid32 = pid;
   if (! dbus_message_append_args (reply,
-                                  DBUS_TYPE_UINT32, (dbus_uint32_t) pid,
+                                  DBUS_TYPE_UINT32, &pid32,
                                   DBUS_TYPE_INVALID))
     goto oom;
 
@@ -956,7 +975,6 @@
     goto oom;
 
   dbus_message_unref (reply);
-  dbus_free (service);
 
   return TRUE;
 
@@ -967,7 +985,6 @@
   _DBUS_ASSERT_ERROR_IS_SET (error);
   if (reply)
     dbus_message_unref (reply);
-  dbus_free (service);
   return FALSE;
 }
 

Index: services.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/services.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- services.c	9 Nov 2004 06:11:33 -0000	1.27
+++ services.c	15 Jan 2005 07:15:38 -0000	1.28
@@ -156,13 +156,18 @@
 
   service->registry = registry;  
   service->refcount = 1;
-  
+
+  _dbus_verbose ("copying string %p '%s' to service->name\n",
+                 service_name, _dbus_string_get_const_data (service_name));
   if (!_dbus_string_copy_data (service_name, &service->name))
     {
       _dbus_mem_pool_dealloc (registry->service_pool, service);
       BUS_SET_OOM (error);
       return NULL;
     }
+  _dbus_verbose ("copied string %p '%s' to '%s'\n",
+                 service_name, _dbus_string_get_const_data (service_name),
+                 service->name);
 
   if (!bus_driver_send_service_owner_changed (service->name, 
 					      NULL,

Index: signals.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/signals.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- signals.c	27 Sep 2004 10:01:18 -0000	1.9
+++ signals.c	15 Jan 2005 07:15:38 -0000	1.10
@@ -23,6 +23,7 @@
 #include "signals.h"
 #include "services.h"
 #include "utils.h"
+#include <dbus/dbus-marshal-validate.h>
 
 struct BusMatchRule
 {
@@ -656,7 +657,7 @@
               goto failed;
             }
 
-          if (!_dbus_string_validate_service (&tmp_str, 0, len))
+          if (!_dbus_validate_service (&tmp_str, 0, len))
             {
               dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
                               "Sender service name '%s' is invalid\n", value);
@@ -678,7 +679,7 @@
               goto failed;
             }
 
-          if (!_dbus_string_validate_interface (&tmp_str, 0, len))
+          if (!_dbus_validate_interface (&tmp_str, 0, len))
             {
               dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
                               "Interface name '%s' is invalid\n", value);
@@ -700,7 +701,7 @@
               goto failed;
             }
 
-          if (!_dbus_string_validate_member (&tmp_str, 0, len))
+          if (!_dbus_validate_member (&tmp_str, 0, len))
             {
               dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
                               "Member name '%s' is invalid\n", value);
@@ -722,7 +723,7 @@
               goto failed;
             }
 
-          if (!_dbus_string_validate_path (&tmp_str, 0, len))
+          if (!_dbus_validate_path (&tmp_str, 0, len))
             {
               dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
                               "Path '%s' is invalid\n", value);
@@ -744,7 +745,7 @@
               goto failed;
             }
 
-          if (!_dbus_string_validate_service (&tmp_str, 0, len))
+          if (!_dbus_validate_service (&tmp_str, 0, len))
             {
               dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
                               "Destination service name '%s' is invalid\n", value);



More information about the dbus-commit mailing list