summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-03-15 13:42:30 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-03-15 13:42:30 +0000
commit9411bce4baf65cc7891f6899cb602a96c4ac26b3 (patch)
treed7c6d51fd7aa034ea7c91e56d2ae707427cb4ac4
parent7e39b983e5cead54bca67953aa92f6ecb4d78fa2 (diff)
Network: Added ListServers
-rw-r--r--network/manager.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/network/manager.c b/network/manager.c
index 982eb015..8487bbb1 100644
--- a/network/manager.c
+++ b/network/manager.c
@@ -59,7 +59,30 @@ static DBusHandlerResult err_unknown_connection(DBusConnection *conn,
static DBusHandlerResult list_servers(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ struct manager *mgr = data;
+ DBusMessage *reply;
+ GSList *l;
+ DBusMessageIter iter;
+ DBusMessageIter array_iter;
+
+ reply = dbus_message_new_method_return(msg);
+ if (!reply)
+ return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+ dbus_message_iter_init_append(reply, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING, &array_iter);
+
+ for (l = mgr->servers; l; l = l->next) {
+ const char *server = l->data;
+
+ dbus_message_iter_append_basic(&array_iter,
+ DBUS_TYPE_STRING, &server);
+ }
+
+ dbus_message_iter_close_container(&iter, &array_iter);
+
+ return send_message_and_unref(conn, reply);
}
static DBusHandlerResult create_server(DBusConnection *conn,