summaryrefslogtreecommitdiffstats
path: root/network/manager.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-04-12 18:15:13 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-04-12 18:15:13 +0000
commit1cbec5ebe8d67b1b4dcef1768efde2ac1ac51970 (patch)
treeb9ef527b7d3ff317db1cad71d5c17661dfdcad07 /network/manager.c
parenta07ea139e52ab9733f6d1e9f0ab2e0bf232059ef (diff)
Add FindConnection method, bug fixes for disconnect events.
Diffstat (limited to 'network/manager.c')
-rw-r--r--network/manager.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/network/manager.c b/network/manager.c
index 491b3845..d2b627db 100644
--- a/network/manager.c
+++ b/network/manager.c
@@ -519,6 +519,45 @@ static DBusHandlerResult list_connections(DBusConnection *conn,
return list_paths(conn, msg, connection_paths);
}
+static DBusHandlerResult find_connection(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBusError derr;
+ const char *pattern;
+ const char *path;
+ GSList *list;
+ DBusMessage *reply;
+
+ dbus_error_init(&derr);
+ if (!dbus_message_get_args(msg, &derr,
+ DBUS_TYPE_STRING, &pattern,
+ DBUS_TYPE_INVALID)) {
+ err_invalid_args(conn, msg, derr.message);
+ dbus_error_free(&derr);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ for (list = connection_paths; list; list = list->next) {
+ path = (const char *) list->data;
+ if (connection_find_data(conn, path, pattern) == 0)
+ break;
+ }
+
+ if (list == NULL) {
+ err_failed(conn, msg, "No such connection");
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ dbus_message_append_args(reply, DBUS_TYPE_STRING, &path,
+ DBUS_TYPE_INVALID);
+
+ return send_message_and_unref(conn, reply);
+}
+
static DBusHandlerResult create_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -594,6 +633,9 @@ static DBusHandlerResult manager_message(DBusConnection *conn,
if (strcmp(member, "ListConnections") == 0)
return list_connections(conn, msg, data);
+ if (strcmp(member, "FindConnection") == 0)
+ return find_connection(conn, msg, data);
+
if (strcmp(member, "CreateConnection") == 0)
return create_connection(conn, msg, data);