2006-09-30 Havoc Pennington <hp@redhat.com>
[platform/upstream/dbus.git] / dbus / dbus-server.c
index 7a140fd..3b9ee34 100644 (file)
  * @{
  */
 
-static void
-init_guid (DBusGUID *guid)
-{
-  long now;
-  char *p;
-  int ts_size;
-
-  _dbus_get_current_time (&now, NULL);
-
-  guid->as_uint32s[0] = now;
-
-  ts_size = sizeof (guid->as_uint32s[0]);
-  p = ((char*)guid->as_bytes) + ts_size;
-  
-  _dbus_generate_random_bytes_buffer (p,
-                                      sizeof (guid->as_bytes) - ts_size);
-}
-
 /* this is a little fragile since it assumes the address doesn't
  * already have a guid, but it shouldn't
  */
@@ -116,8 +98,6 @@ _dbus_server_init_base (DBusServer             *server,
                         const DBusServerVTable *vtable,
                         const DBusString       *address)
 {
-  DBusString guid_raw;
-  
   server->vtable = vtable;
   server->refcount.value = 1;
 
@@ -128,13 +108,9 @@ _dbus_server_init_base (DBusServer             *server,
   if (!_dbus_string_init (&server->guid_hex))
     return FALSE;
 
-  init_guid (&server->guid);
+  _dbus_generate_uuid (&server->guid);
 
-  _dbus_string_init_const_len (&guid_raw, (signed char*) server->guid.as_bytes,
-                               sizeof (server->guid.as_bytes));
-  if (!_dbus_string_hex_encode (&guid_raw, 0,
-                                &server->guid_hex,
-                                _dbus_string_get_length (&server->guid_hex)))
+  if (!_dbus_uuid_encode (&server->guid, &server->guid_hex))
     goto failed;
   
   server->address = copy_address_with_guid_appended (address,
@@ -442,22 +418,6 @@ _dbus_server_toggle_timeout (DBusServer  *server,
                             enabled);
 }
 
-void
-_dbus_server_set_bad_address (DBusError *error,
-                              const char *address_problem_type,
-                              const char *address_problem_field,
-                              const char *address_problem_other)
-{
-  if (address_problem_type != NULL)
-    dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
-                    "Server address of type %s was missing argument %s",
-                    address_problem_type, address_problem_field);
-  else
-    dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
-                    "Could not parse server address: %s",
-                    address_problem_other);
-}
-
 /** @} */
 
 /**
@@ -493,7 +453,11 @@ static const struct {
 
 /**
  * Listens for new connections on the given address.
- * Returns #NULL if listening fails for any reason.
+ * If there are multiple address entries in the address,
+ * tries each one and listens on the first one that
+ * works.
+ * 
+ * Returns #NULL and sets error if listening fails for any reason.
  * Otherwise returns a new #DBusServer.
  * dbus_server_set_new_connection_function() and
  * dbus_server_set_watch_functions() should be called