summaryrefslogtreecommitdiffstats
path: root/src/sbus
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2014-12-10 19:24:58 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-01-23 21:29:17 +0100
commit9fa95168d80beba04b333b06edc492ecb8b085a1 (patch)
tree00071230415551a49b871f95a60f62ea392a8113 /src/sbus
parentd6ddc35574ba897cf9b5de3350086d9d8604f06f (diff)
downloadsssd-9fa95168d80beba04b333b06edc492ecb8b085a1.tar.gz
sssd-9fa95168d80beba04b333b06edc492ecb8b085a1.tar.xz
sssd-9fa95168d80beba04b333b06edc492ecb8b085a1.zip
sbus: add new iface via sbus_conn_register_iface()
Rename sbus_conn_add_interface() to sbus_conn_register_iface() and remove sbus_new_interface() calls since it is just one more unnecessary call outside the sbus code. The function sbus_new_interface() is made static and used directly in sbus_conn_register_iface(). The name was chosen to better describe what the function is doing. That it registers an interface on a given object path. The same interface can be used with different paths so it is not really about adding an interface. Preparation for: https://fedorahosted.org/sssd/ticket/2339 Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/sbus')
-rw-r--r--src/sbus/sssd_dbus.h31
-rw-r--r--src/sbus/sssd_dbus_connection.c19
2 files changed, 26 insertions, 24 deletions
diff --git a/src/sbus/sssd_dbus.h b/src/sbus/sssd_dbus.h
index 5b128eaed..7552fbcf1 100644
--- a/src/sbus/sssd_dbus.h
+++ b/src/sbus/sssd_dbus.h
@@ -113,21 +113,6 @@ struct sbus_interface {
void *instance_data;
};
-/*
- * Creates a new struct sbus_interface instance to be exported by a DBus
- * service.
- *
- * Pass the result to sbus_conn_add_interface(). The interface
- * will be exported at @object_path. The method handlers are represented by
- * @iface_vtable. @instance_data contains additional caller specific data
- * which is made available to handlers.
- */
-struct sbus_interface *
-sbus_new_interface(TALLOC_CTX *mem_ctx,
- const char *object_path,
- struct sbus_vtable *iface_vtable,
- void *instance_data);
-
/* Server Functions */
int sbus_new_server(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -170,9 +155,21 @@ int sbus_init_connection(TALLOC_CTX *ctx,
struct sbus_connection **_conn);
DBusConnection *sbus_get_connection(struct sbus_connection *conn);
+
void sbus_disconnect(struct sbus_connection *conn);
-int sbus_conn_add_interface(struct sbus_connection *conn,
- struct sbus_interface *intf);
+
+/*
+ * Register a new interface to be available at given object path.
+ *
+ * The interface will be exported at @object_path. The method handlers are
+ * represented by @iface_vtable. @pvt contains additional caller specific data
+ * which is made available to handlers.
+ */
+int sbus_conn_register_iface(struct sbus_connection *conn,
+ struct sbus_vtable *iface_vtable,
+ const char *object_path,
+ void *pvt);
+
bool sbus_conn_disconnecting(struct sbus_connection *conn);
/* max_retries < 0: retry forever
diff --git a/src/sbus/sssd_dbus_connection.c b/src/sbus/sssd_dbus_connection.c
index 6102ef9ae..7fded56bc 100644
--- a/src/sbus/sssd_dbus_connection.c
+++ b/src/sbus/sssd_dbus_connection.c
@@ -565,7 +565,7 @@ fail:
sbus_request_finish(dbus_req, reply);
}
-struct sbus_interface *
+static struct sbus_interface *
sbus_new_interface(TALLOC_CTX *mem_ctx,
const char *object_path,
struct sbus_vtable *iface_vtable,
@@ -606,18 +606,23 @@ static char *sbus_iface_get_reg_path(TALLOC_CTX *mem_ctx,
return reg_path;
}
-/* Adds a new D-BUS path message handler to the connection
- * Note: this must be a unique path.
- */
-int sbus_conn_add_interface(struct sbus_connection *conn,
- struct sbus_interface *intf)
+int sbus_conn_register_iface(struct sbus_connection *conn,
+ struct sbus_vtable *iface_vtable,
+ const char *object_path,
+ void *pvt)
{
struct sbus_interface_p *intf_p;
+ struct sbus_interface *intf;
dbus_bool_t dbret;
const char *path;
bool fallback;
- if (!conn || !intf || !intf->vtable || !intf->vtable->meta) {
+ intf = sbus_new_interface(conn, object_path, iface_vtable, pvt);
+ if (intf == NULL) {
+ return ENOMEM;
+ }
+
+ if (!conn || !intf->vtable || !intf->vtable->meta) {
return EINVAL;
}