summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-transport.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-03-31 08:19:50 +0000
committerHavoc Pennington <hp@redhat.com>2003-03-31 08:19:50 +0000
commit29c71168cd17b11eed65023c97aff401d5305b01 (patch)
tree431a05106d857cf38abbdea74a375326f395485e /dbus/dbus-transport.c
parentbc86794f23fa538a405813fb61b531c2eacc9ae1 (diff)
2003-03-31 Havoc Pennington <hp@pobox.com>
* dbus/dbus-transport-unix.c (_dbus_transport_new_for_domain_socket) (_dbus_transport_new_for_tcp_socket): these didn't need the "server" argument since they are always client side * dbus/dbus-server.c (dbus_server_get_address): new function * bus/main.c (main): take the configuration file as an argument. * test/data/valid-config-files/debug-allow-all.conf: new file to use with dispatch.c tests for example * bus/test-main.c (main): require test data dir * bus/bus.c (bus_context_new): change this to take a configuration file name as argument * doc/config-file.txt (Elements): add <servicedir> * bus/system.conf, bus/session.conf: new files * dbus/dbus-bus.c (dbus_bus_get): look for system bus on well-known socket if none set * configure.in: create system.conf and session.conf
Diffstat (limited to 'dbus/dbus-transport.c')
-rw-r--r--dbus/dbus-transport.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c
index 41466ec9..a7aecc3f 100644
--- a/dbus/dbus-transport.c
+++ b/dbus/dbus-transport.c
@@ -82,16 +82,19 @@ live_messages_size_notify (DBusCounter *counter,
* @param transport the transport being created.
* @param vtable the subclass vtable.
* @param server #TRUE if this transport is on the server side of a connection
+ * @param address the address of the transport
* @returns #TRUE on success.
*/
dbus_bool_t
_dbus_transport_init_base (DBusTransport *transport,
const DBusTransportVTable *vtable,
- dbus_bool_t server)
+ dbus_bool_t server,
+ const DBusString *address)
{
DBusMessageLoader *loader;
DBusAuth *auth;
DBusCounter *counter;
+ char *address_copy;
loader = _dbus_message_loader_new ();
if (loader == NULL)
@@ -113,6 +116,24 @@ _dbus_transport_init_base (DBusTransport *transport,
_dbus_auth_unref (auth);
_dbus_message_loader_unref (loader);
return FALSE;
+ }
+
+ if (server)
+ {
+ _dbus_assert (address == NULL);
+ address_copy = NULL;
+ }
+ else
+ {
+ _dbus_assert (address != NULL);
+
+ if (!_dbus_string_copy_data (address, &address_copy))
+ {
+ _dbus_counter_unref (counter);
+ _dbus_auth_unref (auth);
+ _dbus_message_loader_unref (loader);
+ return FALSE;
+ }
}
transport->refcount = 1;
@@ -126,7 +147,8 @@ _dbus_transport_init_base (DBusTransport *transport,
transport->send_credentials_pending = !server;
transport->receive_credentials_pending = server;
transport->is_server = server;
-
+ transport->address = address_copy;
+
transport->unix_user_function = NULL;
transport->unix_user_data = NULL;
transport->free_unix_user_data = NULL;
@@ -144,6 +166,9 @@ _dbus_transport_init_base (DBusTransport *transport,
transport->max_live_messages_size,
live_messages_size_notify,
transport);
+
+ if (transport->address)
+ _dbus_verbose ("Initialized transport on address %s\n", transport->address);
return TRUE;
}
@@ -168,6 +193,7 @@ _dbus_transport_finalize_base (DBusTransport *transport)
_dbus_counter_set_notify (transport->live_messages_size,
0, NULL, NULL);
_dbus_counter_unref (transport->live_messages_size);
+ dbus_free (transport->address);
}
/**
@@ -217,7 +243,7 @@ _dbus_transport_open (const char *address,
goto bad_address;
}
- transport = _dbus_transport_new_for_domain_socket (path, FALSE, error);
+ transport = _dbus_transport_new_for_domain_socket (path, error);
}
else if (strcmp (method, "tcp") == 0)
{
@@ -244,7 +270,7 @@ _dbus_transport_open (const char *address,
goto bad_address;
}
- transport = _dbus_transport_new_for_tcp_socket (host, lport, FALSE, error);
+ transport = _dbus_transport_new_for_tcp_socket (host, lport, error);
}
#ifdef DBUS_BUILD_TESTS
else if (strcmp (method, "debug") == 0)
@@ -461,6 +487,19 @@ _dbus_transport_get_is_authenticated (DBusTransport *transport)
}
/**
+ * Gets the address of a transport. It will be
+ * #NULL for a server-side transport.
+ *
+ * @param transport the transport
+ * @returns transport's address
+ */
+const char*
+_dbus_transport_get_address (DBusTransport *transport)
+{
+ return transport->address;
+}
+
+/**
* Handles a watch by reading data, writing data, or disconnecting
* the transport, as appropriate for the given condition.
*