summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-server.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-02-26 06:37:46 +0000
committerHavoc Pennington <hp@redhat.com>2005-02-26 06:37:46 +0000
commitee27481d7b7d6d9a4f41b7d641a2618dedf676dd (patch)
tree73590d01384d365c867ffa7d43e28a9b2a432c87 /dbus/dbus-server.c
parent7ce7502e1ae23766ba40105327de787c2d1cef9d (diff)
2005-02-26 Havoc Pennington <hp@redhat.com>
* doc/TODO: remove the "guid" item * test/glib/test-profile.c (no_bus_thread_func): use open_private (with_bus_thread_func): use open_private * dbus/dbus-connection.c (dbus_connection_open_private): new function that works like the old dbus_connection_open() (dbus_connection_open): now returns an existing connection if possible * dbus/dbus-server-unix.c (handle_new_client_fd_and_unlock): pass through the GUID to the transport * dbus/dbus-server.c (_dbus_server_init_base): keep around the GUID in hex-encoded form. * dbus/dbus-server-debug-pipe.c (_dbus_transport_debug_pipe_new): pass GUID argument in to the transport * dbus/dbus-transport-unix.c (_dbus_transport_new_for_fd): add guid argument * dbus/dbus-transport.c (_dbus_transport_init_base): add guid argument * dbus/dbus-auth.c (_dbus_auth_server_new): add guid argument
Diffstat (limited to 'dbus/dbus-server.c')
-rw-r--r--dbus/dbus-server.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c
index 20fb5f3c..0a3b522d 100644
--- a/dbus/dbus-server.c
+++ b/dbus/dbus-server.c
@@ -75,33 +75,30 @@ init_guid (DBusGUID *guid)
*/
static char*
copy_address_with_guid_appended (const DBusString *address,
- const DBusGUID *guid)
+ const DBusString *guid_hex)
{
DBusString with_guid;
- DBusString guid_str;
char *retval;
if (!_dbus_string_init (&with_guid))
return NULL;
- _dbus_string_init_const_len (&guid_str, guid->as_bytes,
- sizeof (guid->as_bytes));
-
- if (!_dbus_string_copy (address, 0, &with_guid, 0) ||
+ if (!_dbus_string_copy (address, 0, &with_guid,
+ _dbus_string_get_length (&with_guid)) ||
!_dbus_string_append (&with_guid, ",guid=") ||
- !_dbus_string_hex_encode (&guid_str, 0,
- &with_guid, _dbus_string_get_length (&with_guid)))
+ !_dbus_string_copy (guid_hex, 0,
+ &with_guid, _dbus_string_get_length (&with_guid)))
{
_dbus_string_free (&with_guid);
return NULL;
}
retval = NULL;
- _dbus_string_copy_data (&with_guid, &retval);
+ _dbus_string_steal_data (&with_guid, &retval);
_dbus_string_free (&with_guid);
- return retval; /* may be NULL if copy failed */
+ return retval; /* may be NULL if steal_data failed */
}
/**
@@ -117,7 +114,9 @@ dbus_bool_t
_dbus_server_init_base (DBusServer *server,
const DBusServerVTable *vtable,
const DBusString *address)
-{
+{
+ DBusString guid_raw;
+
server->vtable = vtable;
server->refcount.value = 1;
@@ -125,10 +124,20 @@ _dbus_server_init_base (DBusServer *server,
server->watches = NULL;
server->timeouts = NULL;
+ if (!_dbus_string_init (&server->guid_hex))
+ return FALSE;
+
init_guid (&server->guid);
+ _dbus_string_init_const_len (&guid_raw, 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)))
+ goto failed;
+
server->address = copy_address_with_guid_appended (address,
- &server->guid);
+ &server->guid_hex);
if (server->address == NULL)
goto failed;
@@ -171,6 +180,7 @@ _dbus_server_init_base (DBusServer *server,
dbus_free (server->address);
server->address = NULL;
}
+ _dbus_string_free (&server->guid_hex);
return FALSE;
}
@@ -205,6 +215,8 @@ _dbus_server_finalize_base (DBusServer *server)
dbus_free (server->address);
dbus_free_string_array (server->auth_mechanisms);
+
+ _dbus_string_free (&server->guid_hex);
}