summaryrefslogtreecommitdiff
path: root/bus/driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'bus/driver.c')
-rw-r--r--bus/driver.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/bus/driver.c b/bus/driver.c
index f5d3ebe2..9551f3d4 100644
--- a/bus/driver.c
+++ b/bus/driver.c
@@ -41,17 +41,32 @@
#include <string.h>
static DBusConnection *
+bus_driver_get_owner_of_name (DBusConnection *connection,
+ const char *name)
+{
+ BusRegistry *registry;
+ BusService *serv;
+ DBusString str;
+
+ registry = bus_connection_get_registry (connection);
+ _dbus_string_init_const (&str, name);
+ serv = bus_registry_lookup (registry, &str);
+
+ if (serv == NULL)
+ return NULL;
+
+ return bus_service_get_primary_owners_connection (serv);
+}
+
+static DBusConnection *
bus_driver_get_conn_helper (DBusConnection *connection,
DBusMessage *message,
const char *what_we_want,
const char **name_p,
DBusError *error)
{
- const char *name;
- BusRegistry *registry;
- BusService *serv;
- DBusString str;
DBusConnection *conn;
+ const char *name;
if (!dbus_message_get_args (message, error,
DBUS_TYPE_STRING, &name,
@@ -61,11 +76,9 @@ bus_driver_get_conn_helper (DBusConnection *connection,
_dbus_assert (name != NULL);
_dbus_verbose ("asked for %s of connection %s\n", what_we_want, name);
- registry = bus_connection_get_registry (connection);
- _dbus_string_init_const (&str, name);
- serv = bus_registry_lookup (registry, &str);
+ conn = bus_driver_get_owner_of_name (connection, name);
- if (serv == NULL)
+ if (conn == NULL)
{
dbus_set_error (error, DBUS_ERROR_NAME_HAS_NO_OWNER,
"Could not get %s of name '%s': no such name",
@@ -73,9 +86,6 @@ bus_driver_get_conn_helper (DBusConnection *connection,
return NULL;
}
- conn = bus_service_get_primary_owners_connection (serv);
- _dbus_assert (conn != NULL);
-
if (name_p != NULL)
*name_p = name;