2003-04-27 Havoc Pennington <hp@pobox.com>
[platform/upstream/dbus.git] / bus / driver.c
index bc58f55..3c4847b 100644 (file)
@@ -49,8 +49,8 @@ bus_driver_send_service_deleted (const char     *service_name,
   
   _dbus_verbose ("sending service deleted: %s\n", service_name);
 
-  message = dbus_message_new (DBUS_SERVICE_BROADCAST,
-                              DBUS_MESSAGE_SERVICE_DELETED);
+  message = dbus_message_new (DBUS_MESSAGE_SERVICE_DELETED,
+                              DBUS_SERVICE_BROADCAST);
   if (message == NULL)
     {
       BUS_SET_OOM (error);
@@ -83,8 +83,8 @@ bus_driver_send_service_created (const char     *service_name,
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   
-  message = dbus_message_new (DBUS_SERVICE_BROADCAST,
-                              DBUS_MESSAGE_SERVICE_CREATED);
+  message = dbus_message_new (DBUS_MESSAGE_SERVICE_CREATED,
+                              DBUS_SERVICE_BROADCAST);
   if (message == NULL)
     {
       BUS_SET_OOM (error);
@@ -123,8 +123,8 @@ bus_driver_send_service_lost (DBusConnection *connection,
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   
-  message = dbus_message_new (bus_connection_get_name (connection),
-                              DBUS_MESSAGE_SERVICE_LOST);
+  message = dbus_message_new (DBUS_MESSAGE_SERVICE_LOST,
+                              bus_connection_get_name (connection));
   if (message == NULL)
     {
       BUS_SET_OOM (error);
@@ -163,8 +163,9 @@ bus_driver_send_service_acquired (DBusConnection *connection,
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   
-  message = dbus_message_new (bus_connection_get_name (connection),
-                              DBUS_MESSAGE_SERVICE_ACQUIRED);
+  message = dbus_message_new (DBUS_MESSAGE_SERVICE_ACQUIRED,
+                              bus_connection_get_name (connection));
+
   if (message == NULL)
     {
       BUS_SET_OOM (error);
@@ -203,10 +204,11 @@ create_unique_client_name (BusRegistry *registry,
    * for INT_MAX * INT_MAX combinations, should be pretty safe against
    * wraparound.
    */
+  /* FIXME these should be in BusRegistry rather than static vars */
   static int next_major_number = 0;
   static int next_minor_number = 0;
   int len;
-
+  
   len = _dbus_string_get_length (str);
   
   while (TRUE)
@@ -296,9 +298,9 @@ bus_driver_handle_hello (DBusConnection *connection,
       goto out_0;
     }
 
-  if (!bus_connection_set_name (connection, &unique_name))
+  if (!bus_connection_complete (connection, &unique_name, error))
     {
-      BUS_SET_OOM (error);
+      _DBUS_ASSERT_ERROR_IS_SET (error);
       goto out_0;
     }
   
@@ -625,15 +627,8 @@ bus_driver_handle_message (DBusConnection *connection,
   name = dbus_message_get_name (message);
   sender = dbus_message_get_sender (message);
 
-  if (sender == NULL && (strcmp (name, DBUS_MESSAGE_HELLO) != 0))
-    {
-      dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
-                      "Client tried to send a message other than %s without being registered",
-                      DBUS_MESSAGE_HELLO);
-
-      dbus_connection_disconnect (connection);
-      return FALSE;
-    }
+  /* security checks should have kept this from getting here */
+  _dbus_assert (sender != NULL || strcmp (name, DBUS_MESSAGE_HELLO) == 0);
 
   if (dbus_message_get_reply_serial (message) == 0)
     {