diff options
author | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-05-08 13:48:37 +0000 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.dentz@openbossa.org> | 2007-05-08 13:48:37 +0000 |
commit | 4cf3d33cf13dcb613bb50026a1908d18ee7b7f16 (patch) | |
tree | 4602e37ea0aaa4c2d06cfb1aa7e57f0160a08570 /network/manager.c | |
parent | 331abb4c83b5c6690093ec0807d01823e4548865 (diff) |
Fix server load from storage and add FindServer to API.
Diffstat (limited to 'network/manager.c')
-rw-r--r-- | network/manager.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/network/manager.c b/network/manager.c index cc13ed62..720f4eb1 100644 --- a/network/manager.c +++ b/network/manager.c @@ -431,6 +431,45 @@ static DBusHandlerResult create_server(DBusConnection *conn, return create_path(conn, msg, path, "ServerCreated"); } +static DBusHandlerResult find_server(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 = server_paths; list; list = list->next) { + path = (const char *) list->data; + if (server_find_data(conn, path, pattern) == 0) + break; + } + + if (list == NULL) { + err_failed(conn, msg, "No such server"); + 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 remove_server(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -561,6 +600,9 @@ static DBusHandlerResult manager_message(DBusConnection *conn, if (strcmp(member, "CreateServer") == 0) return create_server(conn, msg, data); + if (strcmp(member, "FindServer") == 0) + return find_server(conn, msg, data); + if (strcmp(member, "RemoveServer") == 0) return remove_server(conn, msg, data); |