summaryrefslogtreecommitdiff
path: root/server/dbus
diff options
context:
space:
mode:
Diffstat (limited to 'server/dbus')
-rw-r--r--server/dbus/sssd_dbus.h60
-rw-r--r--server/dbus/sssd_dbus_common.c8
-rw-r--r--server/dbus/sssd_dbus_connection.c190
-rw-r--r--server/dbus/sssd_dbus_private.h8
-rw-r--r--server/dbus/sssd_dbus_server.c100
-rw-r--r--server/dbus/tests/test_client.c24
6 files changed, 194 insertions, 196 deletions
diff --git a/server/dbus/sssd_dbus.h b/server/dbus/sssd_dbus.h
index 2b8a7787..1bd062d4 100644
--- a/server/dbus/sssd_dbus.h
+++ b/server/dbus/sssd_dbus.h
@@ -21,68 +21,66 @@
#ifndef _SSSD_DBUS_H_
#define _SSSD_DBUS_H_
-struct dbus_connection_toplevel_context;
-typedef int (*sssd_dbus_msg_handler_fn)(DBusMessage *msg, void *data,
+struct sbus_conn_ctx;
+typedef int (*sbus_msg_handler_fn)(DBusMessage *msg, void *data,
DBusMessage **reply);
/*
- * sssd_dbus_connection_destructor_fn
+ * sbus_conn_destructor_fn
* Function to be called when a connection is finalized
*/
-typedef int (*sssd_dbus_connection_destructor_fn)(
+typedef int (*sbus_conn_destructor_fn)(
void *ctx);
/*
- * sssd_dbus_server_connection_init_fn
+ * sbus_server_conn_init_fn
* Set up function for connection-specific activities
- * This function should define the sssd_dbus_connection_destructor_fn
+ * This function should define the sbus_conn_destructor_fn
* for this connection at a minimum
*/
-typedef int (*sssd_dbus_server_connection_init_fn)(
- struct dbus_connection_toplevel_context *dct_ctx);
-
-extern int connection_type_slot;
+typedef int (*sbus_server_conn_init_fn)(
+ struct sbus_conn_ctx *dct_ctx);
enum {
- DBUS_CONNECTION_TYPE_PRIVATE = 1,
- DBUS_CONNECTION_TYPE_SHARED
+ SBUS_CONN_TYPE_PRIVATE = 1,
+ SBUS_CONN_TYPE_SHARED
};
-struct sssd_dbus_method {
+struct sbus_method {
const char *method;
- sssd_dbus_msg_handler_fn fn;
+ sbus_msg_handler_fn fn;
};
-struct sssd_dbus_method_ctx {
- struct sssd_dbus_method_ctx *prev, *next;
+struct sbus_method_ctx {
+ struct sbus_method_ctx *prev, *next;
/*struct event_context *ev;*/
char *interface;
char *path;
/* If a non-default message_handler is desired, set it in this
- * object before calling dbus_connection_add_method_ctx()
+ * object before calling sbus_conn_add_method_ctx()
* Otherwise it will default to message_handler() in
* sssd_dbus_connection.c
*/
DBusObjectPathMessageFunction message_handler;
- struct sssd_dbus_method *methods;
+ struct sbus_method *methods;
};
/* Server Functions */
-int sssd_new_dbus_server(struct event_context *ev, struct sssd_dbus_method_ctx *ctx, const char *address, sssd_dbus_server_connection_init_fn init_fn);
+int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, const char *address, sbus_server_conn_init_fn init_fn);
/* Connection Functions */
-int sssd_new_dbus_connection(TALLOC_CTX *ctx, struct event_context *ev, const char *address,
- struct dbus_connection_toplevel_context **dct_ctx,
- sssd_dbus_connection_destructor_fn destructor);
-
-void sssd_dbus_connection_set_destructor(struct dbus_connection_toplevel_context *dct_ctx,
- sssd_dbus_connection_destructor_fn destructor);
-int default_connection_destructor(void *ctx);
-
-DBusConnection *sssd_get_dbus_connection(struct dbus_connection_toplevel_context *dct_ctx);
-void sssd_dbus_disconnect (struct dbus_connection_toplevel_context *dct_ctx);
-void sssd_connection_set_private_data(struct dbus_connection_toplevel_context *dct_ctx, void *private);
-int dbus_connection_add_method_ctx(struct dbus_connection_toplevel_context *dct_ctx, struct sssd_dbus_method_ctx *method_ctx);
+int sbus_new_connection(TALLOC_CTX *ctx, struct event_context *ev, const char *address,
+ struct sbus_conn_ctx **dct_ctx,
+ sbus_conn_destructor_fn destructor);
+
+void sbus_conn_set_destructor(struct sbus_conn_ctx *dct_ctx,
+ sbus_conn_destructor_fn destructor);
+int sbus_default_connection_destructor(void *ctx);
+
+DBusConnection *sbus_get_connection(struct sbus_conn_ctx *dct_ctx);
+void sbus_disconnect (struct sbus_conn_ctx *dct_ctx);
+void sbus_conn_set_private_data(struct sbus_conn_ctx *dct_ctx, void *private);
+int sbus_conn_add_method_ctx(struct sbus_conn_ctx *dct_ctx, struct sbus_method_ctx *method_ctx);
#endif /* _SSSD_DBUS_H_*/
diff --git a/server/dbus/sssd_dbus_common.c b/server/dbus/sssd_dbus_common.c
index c7af4b0b..0ea66ccb 100644
--- a/server/dbus/sssd_dbus_common.c
+++ b/server/dbus/sssd_dbus_common.c
@@ -15,11 +15,11 @@ struct timeval _dbus_timeout_get_interval_tv(int interval) {
}
/*
- * remove_watch
+ * sbus_remove_watch
* Hook for D-BUS to remove file descriptor-based events
* from the libevents mainloop
*/
-void remove_watch(DBusWatch *watch, void *data) {
+void sbus_remove_watch(DBusWatch *watch, void *data) {
struct fd_event *fde;
DEBUG(2, ("%lX\n", watch));
@@ -32,10 +32,10 @@ void remove_watch(DBusWatch *watch, void *data) {
/*
- * remove_timeout
+ * sbus_remove_timeout
* Hook for D-BUS to remove time-based events from the mainloop
*/
-void remove_timeout(DBusTimeout *timeout, void *data) {
+void sbus_remove_timeout(DBusTimeout *timeout, void *data) {
struct timed_event *te;
te = talloc_get_type(dbus_timeout_get_data(timeout), struct timed_event);
diff --git a/server/dbus/sssd_dbus_connection.c b/server/dbus/sssd_dbus_connection.c
index e9289e04..3a169f79 100644
--- a/server/dbus/sssd_dbus_connection.c
+++ b/server/dbus/sssd_dbus_connection.c
@@ -8,38 +8,38 @@
/* Types */
struct dbus_ctx_list;
-struct dbus_connection_toplevel_context {
+struct sbus_conn_ctx {
DBusConnection *conn;
struct event_context *ev;
int connection_type;
int disconnect;
- struct sssd_dbus_method_ctx *method_ctx_list;
- sssd_dbus_connection_destructor_fn destructor;
+ struct sbus_method_ctx *method_ctx_list;
+ sbus_conn_destructor_fn destructor;
void *private; /* Private data for this connection */
};
-struct dbus_connection_watch_context {
+struct sbus_conn_watch_ctx {
DBusWatch *watch;
int fd;
struct fd_event *fde;
- struct dbus_connection_toplevel_context *top;
+ struct sbus_conn_ctx *top;
};
-struct dbus_connection_timeout_context {
+struct sbus_conn_timeout_ctx {
DBusTimeout *timeout;
struct timed_event *te;
- struct dbus_connection_toplevel_context *top;
+ struct sbus_conn_ctx *top;
};
-static int method_list_contains_path(struct sssd_dbus_method_ctx *list, struct sssd_dbus_method_ctx *method);
-static void sssd_unregister_object_paths(struct dbus_connection_toplevel_context *dct_ctx);
+static int _method_list_contains_path(struct sbus_method_ctx *list, struct sbus_method_ctx *method);
+static void sbus_unreg_object_paths(struct sbus_conn_ctx *dct_ctx);
-static void do_dispatch(struct event_context *ev,
+static void sbus_dispatch(struct event_context *ev,
struct timed_event *te,
struct timeval tv, void *data)
{
struct timed_event *new_event;
- struct dbus_connection_toplevel_context *dct_ctx;
+ struct sbus_conn_ctx *dct_ctx;
DBusConnection *conn;
int ret;
@@ -47,7 +47,7 @@ static void do_dispatch(struct event_context *ev,
return;
}
- dct_ctx = talloc_get_type(data, struct dbus_connection_toplevel_context);
+ dct_ctx = talloc_get_type(data, struct sbus_conn_ctx);
conn = dct_ctx->conn;
DEBUG(3, ("conn: %lX\n", conn));
@@ -77,7 +77,7 @@ static void do_dispatch(struct event_context *ev,
*/
ret = dbus_connection_get_dispatch_status(conn);
if (ret != DBUS_DISPATCH_COMPLETE) {
- new_event = event_add_timed(ev, ev, tv, do_dispatch, dct_ctx);
+ new_event = event_add_timed(ev, dct_ctx, tv, sbus_dispatch, dct_ctx);
if (new_event == NULL) {
DEBUG(0,("Could not add dispatch event!\n"));
@@ -91,12 +91,12 @@ static void do_dispatch(struct event_context *ev,
* dbus_connection_read_write_handler
* Callback for D-BUS to handle messages on a file-descriptor
*/
-static void dbus_connection_read_write_handler(struct event_context *ev,
+static void sbus_conn_read_write_handler(struct event_context *ev,
struct fd_event *fde,
uint16_t flags, void *data)
{
- struct dbus_connection_watch_context *conn_w_ctx;
- conn_w_ctx = talloc_get_type(data, struct dbus_connection_watch_context);
+ struct sbus_conn_watch_ctx *conn_w_ctx;
+ conn_w_ctx = talloc_get_type(data, struct sbus_conn_watch_ctx);
DEBUG(0,("Connection is open for read/write.\n"));
dbus_connection_ref(conn_w_ctx->top->conn);
@@ -114,20 +114,20 @@ static void dbus_connection_read_write_handler(struct event_context *ev,
* Set up hooks into the libevents mainloop for
* D-BUS to add file descriptor-based events
*/
-static dbus_bool_t add_connection_watch(DBusWatch *watch, void *data)
+static dbus_bool_t sbus_add_conn_watch(DBusWatch *watch, void *data)
{
unsigned int flags;
unsigned int event_flags;
- struct dbus_connection_toplevel_context *dt_ctx;
- struct dbus_connection_watch_context *conn_w_ctx;
+ struct sbus_conn_ctx *dt_ctx;
+ struct sbus_conn_watch_ctx *conn_w_ctx;
if (!dbus_watch_get_enabled(watch)) {
return TRUE;
}
- dt_ctx = talloc_get_type(data, struct dbus_connection_toplevel_context);
+ dt_ctx = talloc_get_type(data, struct sbus_conn_ctx);
- conn_w_ctx = talloc_zero(dt_ctx, struct dbus_connection_watch_context);
+ conn_w_ctx = talloc_zero(dt_ctx, struct sbus_conn_watch_ctx);
conn_w_ctx->top = dt_ctx;
conn_w_ctx->watch = watch;
@@ -150,7 +150,7 @@ static dbus_bool_t add_connection_watch(DBusWatch *watch, void *data)
/* Add the file descriptor to the event loop */
conn_w_ctx->fde = event_add_fd(conn_w_ctx->top->ev, conn_w_ctx,
conn_w_ctx->fd, event_flags,
- dbus_connection_read_write_handler,
+ sbus_conn_read_write_handler,
conn_w_ctx);
/* Save the event to the watch object so it can be removed later */
@@ -164,12 +164,12 @@ static dbus_bool_t add_connection_watch(DBusWatch *watch, void *data)
* Hook for D-BUS to toggle the enabled/disabled state of
* an event in the mainloop
*/
-static void toggle_connection_watch(DBusWatch *watch, void *data)
+static void sbus_toggle_conn_watch(DBusWatch *watch, void *data)
{
if (dbus_watch_get_enabled(watch)) {
- add_connection_watch(watch, data);
+ sbus_add_conn_watch(watch, data);
} else {
- remove_watch(watch, data);
+ sbus_remove_watch(watch, data);
}
}
@@ -177,12 +177,12 @@ static void toggle_connection_watch(DBusWatch *watch, void *data)
* dbus_connection_timeout_handler
* Callback for D-BUS to handle timed events
*/
-static void dbus_connection_timeout_handler(struct event_context *ev,
+static void sbus_conn_timeout_handler(struct event_context *ev,
struct timed_event *te,
struct timeval t, void *data)
{
- struct dbus_connection_timeout_context *conn_t_ctx;
- conn_t_ctx = talloc_get_type(data, struct dbus_connection_timeout_context);
+ struct sbus_conn_timeout_ctx *conn_t_ctx;
+ conn_t_ctx = talloc_get_type(data, struct sbus_conn_timeout_ctx);
dbus_timeout_handle(conn_t_ctx->timeout);
}
@@ -192,18 +192,18 @@ static void dbus_connection_timeout_handler(struct event_context *ev,
* add_connection_timeout
* Hook for D-BUS to add time-based events to the mainloop
*/
-static dbus_bool_t add_connection_timeout(DBusTimeout *timeout, void *data)
+static dbus_bool_t sbus_add_conn_timeout(DBusTimeout *timeout, void *data)
{
- struct dbus_connection_toplevel_context *dt_ctx;
- struct dbus_connection_timeout_context *conn_t_ctx;
+ struct sbus_conn_ctx *dt_ctx;
+ struct sbus_conn_timeout_ctx *conn_t_ctx;
struct timeval tv;
if (!dbus_timeout_get_enabled(timeout))
return TRUE;
- dt_ctx = talloc_get_type(data, struct dbus_connection_toplevel_context);
+ dt_ctx = talloc_get_type(data, struct sbus_conn_ctx);
- conn_t_ctx = talloc_zero(dt_ctx,struct dbus_connection_timeout_context);
+ conn_t_ctx = talloc_zero(dt_ctx,struct sbus_conn_timeout_ctx);
conn_t_ctx->top = dt_ctx;
conn_t_ctx->timeout = timeout;
@@ -213,7 +213,7 @@ static dbus_bool_t add_connection_timeout(DBusTimeout *timeout, void *data)
gettimeofday(&rightnow, NULL);
conn_t_ctx->te = event_add_timed(conn_t_ctx->top->ev, conn_t_ctx, tv,
- dbus_connection_timeout_handler, conn_t_ctx);
+ sbus_conn_timeout_handler, conn_t_ctx);
/* Save the event to the watch object so it can be removed later */
dbus_timeout_set_data(conn_t_ctx->timeout,conn_t_ctx->te,NULL);
@@ -222,16 +222,16 @@ static dbus_bool_t add_connection_timeout(DBusTimeout *timeout, void *data)
}
/*
- * toggle_connection_timeout
+ * sbus_toggle_conn_timeout
* Hook for D-BUS to toggle the enabled/disabled state of a mainloop
* event
*/
-void toggle_connection_timeout(DBusTimeout *timeout, void *data)
+void sbus_toggle_conn_timeout(DBusTimeout *timeout, void *data)
{
if (dbus_timeout_get_enabled(timeout)) {
- add_connection_timeout(timeout, data);
+ sbus_add_conn_timeout(timeout, data);
} else {
- remove_timeout(timeout, data);
+ sbus_remove_timeout(timeout, data);
}
}
@@ -242,17 +242,17 @@ void toggle_connection_timeout(DBusTimeout *timeout, void *data)
* timed event to perform the dispatch during the next iteration
* through the mainloop
*/
-static void dbus_connection_wakeup_main(void *data) {
- struct dbus_connection_toplevel_context *dct_ctx;
+static void sbus_conn_wakeup_main(void *data) {
+ struct sbus_conn_ctx *dct_ctx;
struct timeval tv;
struct timed_event *te;
- dct_ctx = talloc_get_type(data, struct dbus_connection_toplevel_context);
+ dct_ctx = talloc_get_type(data, struct sbus_conn_ctx);
gettimeofday(&tv, NULL);
/* D-BUS calls this function when it is time to do a dispatch */
- te = event_add_timed(dct_ctx->ev, dct_ctx->ev,
- tv, do_dispatch, dct_ctx);
+ te = event_add_timed(dct_ctx->ev, dct_ctx,
+ tv, sbus_dispatch, dct_ctx);
if (te == NULL) {
DEBUG(0,("Could not add dispatch event!\n"));
exit(1);
@@ -264,36 +264,36 @@ static void dbus_connection_wakeup_main(void *data) {
* Set up a D-BUS connection to use the libevents mainloop
* for handling file descriptor and timed events
*/
-int sssd_add_dbus_connection(TALLOC_CTX *ctx,
- struct event_context *ev,
- DBusConnection *dbus_conn,
- struct dbus_connection_toplevel_context **dct_ctx,
- int connection_type)
+int sbus_add_connection(TALLOC_CTX *ctx,
+ struct event_context *ev,
+ DBusConnection *dbus_conn,
+ struct sbus_conn_ctx **dct_ctx,
+ int connection_type)
{
dbus_bool_t dbret;
- struct dbus_connection_toplevel_context *dt_ctx;
+ struct sbus_conn_ctx *dt_ctx;
DEBUG(0,("Adding connection %lX\n", dbus_conn));
- dt_ctx = talloc_zero(ctx, struct dbus_connection_toplevel_context);
+ dt_ctx = talloc_zero(ctx, struct sbus_conn_ctx);
dt_ctx->ev = ev;
dt_ctx->conn = dbus_conn;
dt_ctx->connection_type = connection_type;
dt_ctx->disconnect = 0;
- /* This will be replaced on the first call to dbus_connection_add_method_ctx() */
+ /* This will be replaced on the first call to sbus_conn_add_method_ctx() */
dt_ctx->method_ctx_list = NULL;
/*
* Set the default destructor
* Connections can override this with
- * sssd_dbus_connection_set_destructor
+ * sbus_conn_set_destructor
*/
- sssd_dbus_connection_set_destructor(dt_ctx, NULL);
+ sbus_conn_set_destructor(dt_ctx, NULL);
/* Set up DBusWatch functions */
dbret = dbus_connection_set_watch_functions(dt_ctx->conn,
- add_connection_watch,
- remove_watch,
- toggle_connection_watch,
+ sbus_add_conn_watch,
+ sbus_remove_watch,
+ sbus_toggle_conn_watch,
dt_ctx, NULL);
if (!dbret) {
DEBUG(0,("Error setting up D-BUS connection watch functions\n"));
@@ -302,9 +302,9 @@ int sssd_add_dbus_connection(TALLOC_CTX *ctx,
/* Set up DBusTimeout functions */
dbret = dbus_connection_set_timeout_functions(dt_ctx->conn,
- add_connection_timeout,
- remove_timeout,
- toggle_connection_timeout,
+ sbus_add_conn_timeout,
+ sbus_remove_timeout,
+ sbus_toggle_conn_timeout,
dt_ctx, NULL);
if (!dbret) {
DEBUG(0,("Error setting up D-BUS server timeout functions\n"));
@@ -314,7 +314,7 @@ int sssd_add_dbus_connection(TALLOC_CTX *ctx,
/* Set up dispatch handler */
dbus_connection_set_wakeup_main_function(dt_ctx->conn,
- dbus_connection_wakeup_main,
+ sbus_conn_wakeup_main,
dt_ctx, NULL);
/* Set up any method_contexts passed in */
@@ -324,7 +324,7 @@ int sssd_add_dbus_connection(TALLOC_CTX *ctx,
* If there are no messages to be dispatched, this will do
* nothing.
*/
- dbus_connection_wakeup_main(dt_ctx);
+ sbus_conn_wakeup_main(dt_ctx);
/* Return the new toplevel object */
*dct_ctx = dt_ctx;
@@ -332,12 +332,12 @@ int sssd_add_dbus_connection(TALLOC_CTX *ctx,
return EOK;
}
-/*int sssd_new_dbus_connection(struct sssd_dbus_method_ctx *ctx, const char *address,
+/*int sbus_new_connection(struct sbus_method_ctx *ctx, const char *address,
DBusConnection **connection,
- sssd_dbus_connection_destructor_fn destructor)*/
-int sssd_new_dbus_connection(TALLOC_CTX *ctx, struct event_context *ev, const char *address,
- struct dbus_connection_toplevel_context **dct_ctx,
- sssd_dbus_connection_destructor_fn destructor)
+ sbus_conn_destructor_fn destructor)*/
+int sbus_new_connection(TALLOC_CTX *ctx, struct event_context *ev, const char *address,
+ struct sbus_conn_ctx **dct_ctx,
+ sbus_conn_destructor_fn destructor)
{
DBusConnection *dbus_conn;
DBusError dbus_error;
@@ -353,7 +353,7 @@ int sssd_new_dbus_connection(TALLOC_CTX *ctx, struct event_context *ev, const ch
return EIO;
}
- ret = sssd_add_dbus_connection(ctx, ev, dbus_conn, dct_ctx, DBUS_CONNECTION_TYPE_SHARED);
+ ret = sbus_add_connection(ctx, ev, dbus_conn, dct_ctx, SBUS_CONN_TYPE_SHARED);
if (ret != EOK) {
/* FIXME: release resources */
}
@@ -361,23 +361,23 @@ int sssd_new_dbus_connection(TALLOC_CTX *ctx, struct event_context *ev, const ch
dbus_connection_set_exit_on_disconnect((*dct_ctx)->conn, FALSE);
/* Set connection destructor */
- sssd_dbus_connection_set_destructor(*dct_ctx, destructor);
+ sbus_conn_set_destructor(*dct_ctx, destructor);
return ret;
}
/*
- * sssd_dbus_connection_set_destructor
+ * sbus_conn_set_destructor
* Configures a callback to clean up this connection when it
* is finalized.
- * @param dct_ctx The dbus_connection_toplevel_context created
+ * @param dct_ctx The sbus_conn_ctx created
* when this connection was established
* @param destructor The destructor function that should be
* called when the connection is finalized. If passed NULL,
* this will reset the connection to the default destructor.
*/
-void sssd_dbus_connection_set_destructor(struct dbus_connection_toplevel_context *dct_ctx,
- sssd_dbus_connection_destructor_fn destructor) {
+void sbus_conn_set_destructor(struct sbus_conn_ctx *dct_ctx,
+ sbus_conn_destructor_fn destructor) {
if (!dct_ctx) {
return;
}
@@ -386,15 +386,15 @@ void sssd_dbus_connection_set_destructor(struct dbus_connection_toplevel_context
/* TODO: Should we try to handle the talloc_destructor too? */
}
-int default_connection_destructor(void *ctx) {
- struct dbus_connection_toplevel_context *dct_ctx;
- dct_ctx = talloc_get_type(ctx, struct dbus_connection_toplevel_context);
+int sbus_default_connection_destructor(void *ctx) {
+ struct sbus_conn_ctx *dct_ctx;
+ dct_ctx = talloc_get_type(ctx, struct sbus_conn_ctx);
DEBUG(3, ("Invoking default destructor on connection %lX\n", dct_ctx->conn));
- if (dct_ctx->connection_type == DBUS_CONNECTION_TYPE_PRIVATE) {
+ if (dct_ctx->connection_type == SBUS_CONN_TYPE_PRIVATE) {
/* Private connections must be closed explicitly */
dbus_connection_close(dct_ctx->conn);
- } else if (dct_ctx->connection_type == DBUS_CONNECTION_TYPE_SHARED) {
+ } else if (dct_ctx->connection_type == SBUS_CONN_TYPE_SHARED) {
/* Shared connections are destroyed when their last reference is removed */
}
else {
@@ -404,7 +404,7 @@ int default_connection_destructor(void *ctx) {
}
/* Remove object path */
-
+ /* TODO: Remove object paths */
dbus_connection_unref(dct_ctx->conn);
@@ -412,15 +412,15 @@ int default_connection_destructor(void *ctx) {
}
/*
- * sssd_get_dbus_connection
+ * sbus_get_connection
* Utility function to retreive the DBusConnection object
- * from a dbus_connection_toplevel_context
+ * from a sbus_conn_ctx
*/
-DBusConnection *sssd_get_dbus_connection(struct dbus_connection_toplevel_context *dct_ctx) {
+DBusConnection *sbus_get_connection(struct sbus_conn_ctx *dct_ctx) {
return dct_ctx->conn;
}
-void sssd_dbus_disconnect (struct dbus_connection_toplevel_context *dct_ctx) {
+void sbus_disconnect (struct sbus_conn_ctx *dct_ctx) {
if (dct_ctx == NULL) {
return;
}
@@ -435,7 +435,7 @@ void sssd_dbus_disconnect (struct dbus_connection_toplevel_context *dct_ctx) {
}
/* Unregister object paths */
- sssd_unregister_object_paths(dct_ctx);
+ sbus_unreg_object_paths(dct_ctx);
/* Disable watch functions */
dbus_connection_set_watch_functions(dct_ctx->conn,
@@ -453,7 +453,7 @@ void sssd_dbus_disconnect (struct dbus_connection_toplevel_context *dct_ctx) {
dbus_connection_set_wakeup_main_function(dct_ctx->conn, NULL, NULL, NULL);
/* Finalize the connection */
- default_connection_destructor(dct_ctx);
+ sbus_default_connection_destructor(dct_ctx);
dbus_connection_unref(dct_ctx->conn);
DEBUG(2,("Disconnected %lX\n", dct_ctx->conn));
}
@@ -465,14 +465,14 @@ static DBusHandlerResult message_handler(DBusConnection *conn,
DBusMessage *message,
void *user_data)
{
- struct sssd_dbus_method_ctx *ctx;
+ struct sbus_method_ctx *ctx;
const char *method;
const char *path;
const char *msg_interface;
DBusMessage *reply = NULL;
int i, ret;
- ctx = talloc_get_type(user_data, struct sssd_dbus_method_ctx);
+ ctx = talloc_get_type(user_data, struct sbus_method_ctx);
method = dbus_message_get_member(message);
path = dbus_message_get_path(message);
@@ -497,7 +497,7 @@ static DBusHandlerResult message_handler(DBusConnection *conn,
/* FIXME: check if we didn't find any matching method */
}
- DEBUG(2, ("Method %s complete. Reply %sneeded.\n", method, reply?"":"not "));
+ DEBUG(2, ("Method %s complete. Reply was %srequested.\n", method, reply?"":"not "));
if (reply) {
dbus_connection_send(conn, reply, NULL);
@@ -511,14 +511,14 @@ static DBusHandlerResult message_handler(DBusConnection *conn,
/* Adds a new D-BUS path message handler to the connection
* Note: this must be a unique path.
*/
-int dbus_connection_add_method_ctx(struct dbus_connection_toplevel_context *dct_ctx, struct sssd_dbus_method_ctx *method_ctx) {
+int sbus_conn_add_method_ctx(struct sbus_conn_ctx *dct_ctx, struct sbus_method_ctx *method_ctx) {
DBusObjectPathVTable *connection_vtable;
dbus_bool_t dbret;
if (!method_ctx) {
return EINVAL;
}
- if (method_list_contains_path(dct_ctx->method_ctx_list, method_ctx)) {
+ if (_method_list_contains_path(dct_ctx->method_ctx_list, method_ctx)) {
return EINVAL;
}
@@ -540,8 +540,8 @@ int dbus_connection_add_method_ctx(struct dbus_connection_toplevel_context *dct_
return EOK;
}
-static int method_list_contains_path(struct sssd_dbus_method_ctx *list, struct sssd_dbus_method_ctx *method) {
- struct sssd_dbus_method_ctx *iter;
+static int _method_list_contains_path(struct sbus_method_ctx *list, struct sbus_method_ctx *method) {
+ struct sbus_method_ctx *iter;
if (!list || !method) {
return 0; /* FALSE */
@@ -558,9 +558,9 @@ static int method_list_contains_path(struct sssd_dbus_method_ctx *list, struct s
return 0; /* FALSE */
}
-static void sssd_unregister_object_paths(struct dbus_connection_toplevel_context *dct_ctx) {
- struct sssd_dbus_method_ctx *iter = dct_ctx->method_ctx_list;
- struct sssd_dbus_method_ctx *purge;
+static void sbus_unreg_object_paths(struct sbus_conn_ctx *dct_ctx) {
+ struct sbus_method_ctx *iter = dct_ctx->method_ctx_list;
+ struct sbus_method_ctx *purge;
while(iter != NULL) {
dbus_connection_unregister_object_path(dct_ctx->conn, iter->path);
@@ -571,6 +571,6 @@ static void sssd_unregister_object_paths(struct dbus_connection_toplevel_context
}
}
-void sssd_connection_set_private_data(struct dbus_connection_toplevel_context *dct_ctx, void *private) {
+void sbus_conn_set_private_data(struct sbus_conn_ctx *dct_ctx, void *private) {
dct_ctx->private = private;
}
diff --git a/server/dbus/sssd_dbus_private.h b/server/dbus/sssd_dbus_private.h
index ea1b719b..d102c8c9 100644
--- a/server/dbus/sssd_dbus_private.h
+++ b/server/dbus/sssd_dbus_private.h
@@ -1,14 +1,14 @@
#ifndef _SSSD_DBUS_PRIVATE_H_
#define _SSSD_DBUS_PRIVATE_H_
-int sssd_add_dbus_connection(TALLOC_CTX *ctx,
+int sbus_add_connection(TALLOC_CTX *ctx,
struct event_context *ev,
DBusConnection *dbus_conn,
- struct dbus_connection_toplevel_context **dct_ctx,
+ struct sbus_conn_ctx **dct_ctx,
int connection_type);
struct timeval _dbus_timeout_get_interval_tv(int interval);
-void remove_watch(DBusWatch *watch, void *data);
-void remove_timeout(DBusTimeout *timeout, void *data);
+void sbus_remove_watch(DBusWatch *watch, void *data);
+void sbus_remove_timeout(DBusTimeout *timeout, void *data);
#endif /* _SSSD_DBUS_PRIVATE_H_ */
diff --git a/server/dbus/sssd_dbus_server.c b/server/dbus/sssd_dbus_server.c
index 8bdccf8e..633e4b7e 100644
--- a/server/dbus/sssd_dbus_server.c
+++ b/server/dbus/sssd_dbus_server.c
@@ -26,7 +26,7 @@
#include "dbus/sssd_dbus_private.h"
/* Types */
-struct dbus_server_toplevel_context {
+struct sbus_srv_ctx {
DBusServer *server;
/*
* sd_ctx here describes the object path that will be
@@ -38,35 +38,35 @@ struct dbus_server_toplevel_context {
* simplicity's sake)
*/
struct event_context *ev;
- struct sssd_dbus_method_ctx *sd_ctx;
- sssd_dbus_server_connection_init_fn init_fn;
+ struct sbus_method_ctx *sd_ctx;
+ sbus_server_conn_init_fn init_fn;
};
-struct dbus_server_watch_context {
+struct sbus_srv_watch_ctx {
DBusWatch *watch;
int fd;
struct fd_event *fde;
- struct dbus_server_toplevel_context *top;
+ struct sbus_srv_ctx *top;
};
-struct dbus_server_timeout_context {
+struct dbus_srv_timeout_ctx {
DBusTimeout *timeout;
struct timed_event *te;
- struct dbus_server_toplevel_context *top;
+ struct sbus_srv_ctx *top;
};
-static int dbus_server_destructor(void **server);
+static int sbus_server_destructor(void **server);
/*
* dbus_server_read_write_handler
* Callback for D-BUS to handle messages on a file-descriptor
*/
-static void dbus_server_read_write_handler(struct event_context *ev,
+static void sbus_srv_read_write_handler(struct event_context *ev,
struct fd_event *fde,
uint16_t flags, void *data)
{
- struct dbus_server_watch_context *svw_ctx;
- svw_ctx = talloc_get_type(data, struct dbus_server_watch_context);
+ struct sbus_srv_watch_ctx *svw_ctx;
+ svw_ctx = talloc_get_type(data, struct sbus_srv_watch_ctx);
dbus_server_ref(svw_ctx->top->server);
if (flags & EVENT_FD_READ) {
@@ -83,20 +83,20 @@ static void dbus_server_read_write_handler(struct event_context *ev,
* Set up hooks into the libevents mainloop for
* D-BUS to add file descriptor-based events
*/
-static dbus_bool_t add_server_watch(DBusWatch *watch, void *data)
+static dbus_bool_t sbus_add_srv_watch(DBusWatch *watch, void *data)
{
unsigned int flags;
unsigned int event_flags;
- struct dbus_server_toplevel_context *dt_ctx;
- struct dbus_server_watch_context *svw_ctx;
+ struct sbus_srv_ctx *dt_ctx;
+ struct sbus_srv_watch_ctx *svw_ctx;
if (!dbus_watch_get_enabled(watch)) {
return FALSE;
}
- dt_ctx = talloc_get_type(data, struct dbus_server_toplevel_context);
+ dt_ctx = talloc_get_type(data, struct sbus_srv_ctx);
- svw_ctx = talloc_zero(dt_ctx, struct dbus_server_watch_context);
+ svw_ctx = talloc_zero(dt_ctx, struct sbus_srv_watch_ctx);
svw_ctx->top = dt_ctx;
svw_ctx->watch = watch;
@@ -115,7 +115,7 @@ static dbus_bool_t add_server_watch(DBusWatch *watch, void *data)
DEBUG(2,("%lX: %d, %d=%s\n", watch, svw_ctx->fd, event_flags, event_flags==EVENT_FD_READ?"READ":"WRITE"));
svw_ctx->fde = event_add_fd(dt_ctx->ev, svw_ctx, svw_ctx->fd,
- event_flags, dbus_server_read_write_handler,
+ event_flags, sbus_srv_read_write_handler,
svw_ctx);
/* Save the event to the watch object so it can be removed later */
@@ -129,21 +129,21 @@ static dbus_bool_t add_server_watch(DBusWatch *watch, void *data)
* Hook for D-BUS to toggle the enabled/disabled state of
* an event in the mainloop
*/
-static void toggle_server_watch(DBusWatch *watch, void *data)
+static void sbus_toggle_srv_watch(DBusWatch *watch, void *data)
{
if (dbus_watch_get_enabled(watch)) {
- add_server_watch(watch, data);
+ sbus_add_srv_watch(watch, data);
} else {
- remove_watch(watch, data);
+ sbus_remove_watch(watch, data);
}
}
-static void dbus_server_timeout_handler(struct event_context *ev,
+static void sbus_srv_timeout_handler(struct event_context *ev,
struct timed_event *te,
struct timeval t, void *data)
{
- struct dbus_server_timeout_context *svt_ctx;
- svt_ctx = talloc_get_type(data, struct dbus_server_timeout_context);
+ struct dbus_srv_timeout_ctx *svt_ctx;
+ svt_ctx = talloc_get_type(data, struct dbus_srv_timeout_ctx);
dbus_timeout_handle(svt_ctx->timeout);
}
@@ -151,25 +151,25 @@ static void dbus_server_timeout_handler(struct event_context *ev,
* add_server_timeout
* Hook for D-BUS to add time-based events to the mainloop
*/
-static dbus_bool_t add_server_timeout(DBusTimeout *timeout, void *data)
+static dbus_bool_t sbus_add_srv_timeout(DBusTimeout *timeout, void *data)
{
- struct dbus_server_toplevel_context *dt_ctx;
- struct dbus_server_timeout_context *svt_ctx;
+ struct sbus_srv_ctx *dt_ctx;
+ struct dbus_srv_timeout_ctx *svt_ctx;
struct timeval tv;
if (!dbus_timeout_get_enabled(timeout))
return TRUE;
- dt_ctx = talloc_get_type(data, struct dbus_server_toplevel_context);
+ dt_ctx = talloc_get_type(data, struct sbus_srv_ctx);
- svt_ctx = talloc_zero(dt_ctx,struct dbus_server_timeout_context);
+ svt_ctx = talloc_zero(dt_ctx,struct dbus_srv_timeout_ctx);
svt_ctx->top = dt_ctx;
svt_ctx->timeout = timeout;
tv = _dbus_timeout_get_interval_tv(dbus_timeout_get_interval(timeout));
svt_ctx->te = event_add_timed(dt_ctx->ev, svt_ctx, tv,
- dbus_server_timeout_handler, svt_ctx);
+ sbus_srv_timeout_handler, svt_ctx);
/* Save the event to the watch object so it can be removed later */
dbus_timeout_set_data(svt_ctx->timeout, svt_ctx->te, NULL);
@@ -182,12 +182,12 @@ static dbus_bool_t add_server_timeout(DBusTimeout *timeout, void *data)
* Hook for D-BUS to toggle the enabled/disabled state of a mainloop
* event
*/
-static void toggle_server_timeout(DBusTimeout *timeout, void *data)
+static void sbus_toggle_srv_timeout(DBusTimeout *timeout, void *data)
{
if (dbus_timeout_get_enabled(timeout)) {
- add_server_timeout(timeout, data);
+ sbus_add_srv_timeout(timeout, data);
} else {
- remove_timeout(timeout, data);
+ sbus_remove_timeout(timeout, data);
}
}
@@ -198,23 +198,23 @@ static void toggle_server_timeout(DBusTimeout *timeout, void *data)
* new connection or else close the connection with
* dbus_connection_close()
*/
-static void new_connection_callback(DBusServer *server, DBusConnection *conn,
+static void sbus_server_init_new_connection(DBusServer *server, DBusConnection *conn,
void *data)
{
- struct dbus_server_toplevel_context *dst_ctx;
- struct dbus_connection_toplevel_context *dct_ctx;
- struct sssd_dbus_method_ctx *iter;
+ struct sbus_srv_ctx *dst_ctx;
+ struct sbus_conn_ctx *dct_ctx;
+ struct sbus_method_ctx *iter;
/*DBusObjectPathVTable *connection_vtable;*/
int ret;
DEBUG(0,("Entering.\n"));
- dst_ctx = talloc_get_type(data,struct dbus_server_toplevel_context);
+ dst_ctx = talloc_get_type(data,struct sbus_srv_ctx);
if(dst_ctx == NULL) {
return;
}
DEBUG(0,("Adding connection %lX.\n", conn));
- ret = sssd_add_dbus_connection(dst_ctx, dst_ctx->ev, conn, &dct_ctx, DBUS_CONNECTION_TYPE_PRIVATE);
+ ret = sbus_add_connection(dst_ctx, dst_ctx->ev, conn, &dct_ctx, SBUS_CONN_TYPE_PRIVATE);
if (ret != 0) {
dbus_connection_close(conn);
DEBUG(0,("Closing connection (failed setup)"));
@@ -228,7 +228,7 @@ static void new_connection_callback(DBusServer *server, DBusConnection *conn,
/* Set up global methods */
iter = dst_ctx->sd_ctx;
while (iter != NULL) {
- dbus_connection_add_method_ctx(dct_ctx, iter);
+ sbus_conn_add_method_ctx(dct_ctx, iter);
iter = iter->next;
}
@@ -248,9 +248,9 @@ static void new_connection_callback(DBusServer *server, DBusConnection *conn,
* Set up a D-BUS server, integrate with the event loop
* for handling file descriptor and timed events
*/
-int sssd_new_dbus_server(struct event_context *ev, struct sssd_dbus_method_ctx *ctx, const char *address, sssd_dbus_server_connection_init_fn init_fn)
+int sbus_new_server(struct event_context *ev, struct sbus_method_ctx *ctx, const char *address, sbus_server_conn_init_fn init_fn)
{
- struct dbus_server_toplevel_context *dst_ctx;
+ struct sbus_srv_ctx *dst_ctx;
DBusServer *dbus_server;
DBusServer **dbus_server_talloc;
DBusError dbus_error;
@@ -268,12 +268,12 @@ int sssd_new_dbus_server(struct event_context *ev, struct sssd_dbus_method_ctx *
DEBUG(2, ("D-BUS Server listening on %s\n",
dbus_server_get_address(dbus_server)));
- dst_ctx = talloc_zero(ev, struct dbus_server_toplevel_context);
+ dst_ctx = talloc_zero(ev, struct sbus_srv_ctx);
if (!dst_ctx) {
return ENOMEM;
}
- dbus_server_talloc = talloc_takeover(ctx, dbus_server, dbus_server_destructor);
+ dbus_server_talloc = talloc_takeover(ctx, dbus_server, sbus_server_destructor);
dst_ctx->ev = ev;
dst_ctx->server = dbus_server;
dst_ctx->sd_ctx = ctx;
@@ -281,12 +281,12 @@ int sssd_new_dbus_server(struct event_context *ev, struct sssd_dbus_method_ctx *
/* Set up D-BUS new connection handler */
dbus_server_set_new_connection_function(dst_ctx->server,
- new_connection_callback,
+ sbus_server_init_new_connection,
dst_ctx, NULL);
/* Set up DBusWatch functions */
- dbret = dbus_server_set_watch_functions(dst_ctx->server, add_server_watch,
- remove_watch, toggle_server_watch,
+ dbret = dbus_server_set_watch_functions(dst_ctx->server, sbus_add_srv_watch,
+ sbus_remove_watch, sbus_toggle_srv_watch,
dst_ctx, NULL);
if (!dbret) {
DEBUG(0, ("Error setting up D-BUS server watch functions"));
@@ -296,9 +296,9 @@ int sssd_new_dbus_server(struct event_context *ev, struct sssd_dbus_method_ctx *
/* Set up DBusTimeout functions */
dbret = dbus_server_set_timeout_functions(dst_ctx->server,
- add_server_timeout,
- remove_timeout,
- toggle_server_timeout,
+ sbus_add_srv_timeout,
+ sbus_remove_timeout,
+ sbus_toggle_srv_timeout,
dst_ctx, NULL);
if (!dbret) {
DEBUG(0,("Error setting up D-BUS server timeout functions"));
@@ -310,7 +310,7 @@ int sssd_new_dbus_server(struct event_context *ev, struct sssd_dbus_method_ctx *
return EOK;
}
-static int dbus_server_destructor(void **server) {
+static int sbus_server_destructor(void **server) {
dbus_server_disconnect(*server);
return 0;
}
diff --git a/server/dbus/tests/test_client.c b/server/dbus/tests/test_client.c
index daf80db9..34e74018 100644
--- a/server/dbus/tests/test_client.c
+++ b/server/dbus/tests/test_client.c
@@ -24,15 +24,15 @@
#define SERVICE_METHOD_IDENTITY "getIdentity"
struct test_cli_ctx {
- struct sssd_dbus_method_ctx *sd_ctx;
+ struct sbus_method_ctx *sd_ctx;
/*DBusConnection *conn;*/
struct event_context *ev;
- struct dbus_connection_toplevel_context *dct_ctx;
+ struct sbus_conn_ctx *dct_ctx;
};
static int provide_identity(DBusMessage *message, void *data, DBusMessage **r);
-struct sssd_dbus_method monitor_service_methods [] = {
+struct sbus_method monitor_service_methods [] = {
{SERVICE_METHOD_IDENTITY, provide_identity},
{NULL, NULL}
};
@@ -92,7 +92,7 @@ static void test_timed_handler(struct event_context *ev,
struct timeval tv, void *data)
{
struct test_cli_ctx *test_ctx;
- struct sssd_dbus_method_ctx *ctx;
+ struct sbus_method_ctx *ctx;
DBusPendingCall *pending_reply;
DBusMessage *vmsg;
DBusError error;
@@ -109,7 +109,7 @@ static void test_timed_handler(struct event_context *ev,
ctx->path, ctx->interface,
MONITOR_METHOD_VERSION);
- dbret = dbus_connection_send_with_reply(sssd_get_dbus_connection(test_ctx->dct_ctx), vmsg,
+ dbret = dbus_connection_send_with_reply(sbus_get_connection(test_ctx->dct_ctx), vmsg,
&pending_reply, -1);
if (!dbret) {
/* Critical failure */
@@ -142,9 +142,9 @@ static void request_version_timed(struct test_cli_ctx *ctx)
int main (int argc, const char *argv[])
{
struct event_context *event_ctx;
- struct sssd_dbus_method_ctx *ctx;
+ struct sbus_method_ctx *ctx;
struct test_cli_ctx *test_ctx;
- struct sssd_dbus_method_ctx *service_methods;
+ struct sbus_method_ctx *service_methods;
int ret;
event_ctx = event_context_init(talloc_autofree_context());
@@ -153,7 +153,7 @@ int main (int argc, const char *argv[])
exit(1);
}
- ctx = talloc_zero(event_ctx, struct sssd_dbus_method_ctx);
+ ctx = talloc_zero(event_ctx, struct sbus_method_ctx);
if (!ctx) {
printf("Out of memory!?\n");
exit(1);
@@ -173,14 +173,14 @@ int main (int argc, const char *argv[])
exit(1);
}
- ret = sssd_new_dbus_connection(test_ctx, test_ctx->ev, DBUS_ADDRESS, &(test_ctx->dct_ctx), NULL);
+ ret = sbus_new_connection(test_ctx, test_ctx->ev, DBUS_ADDRESS, &(test_ctx->dct_ctx), NULL);
if (ret != EOK) {
exit(1);
}
test_ctx->sd_ctx = ctx;
- dbus_connection_set_exit_on_disconnect(sssd_get_dbus_connection(test_ctx->dct_ctx), TRUE);
+ dbus_connection_set_exit_on_disconnect(sbus_get_connection(test_ctx->dct_ctx), TRUE);
/* Set up a timed event to request the server version every
* five seconds and print it to the screen.
@@ -188,11 +188,11 @@ int main (int argc, const char *argv[])
request_version_timed(test_ctx);
/* Set up handler for service methods */
- service_methods = talloc_zero(test_ctx, struct sssd_dbus_method_ctx);
+ service_methods = talloc_zero(test_ctx, struct sbus_method_ctx);
service_methods->interface = talloc_strdup(service_methods, SERVICE_INTERFACE);
service_methods->path = talloc_strdup(service_methods, SERVICE_PATH);
service_methods->methods = monitor_service_methods;
- dbus_connection_add_method_ctx(test_ctx->dct_ctx, service_methods);
+ sbus_conn_add_method_ctx(test_ctx->dct_ctx, service_methods);
/* Enter the main loop (and hopefully never return) */
event_loop_wait(event_ctx);