diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-05-01 17:36:54 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-05-01 17:36:54 +0000 |
commit | f05b9d3834fb8f587987026f8ffde549fa6497d3 (patch) | |
tree | 11ec32647e2265b94ceb594f43025aa03c43f674 | |
parent | 66570ffe00f40c03ea3ae4fa7e62eea5697a7262 (diff) |
serial: Added ListPorts
-rw-r--r-- | serial/manager.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/serial/manager.c b/serial/manager.c index cbd1ea21..9c920a2f 100644 --- a/serial/manager.c +++ b/serial/manager.c @@ -285,7 +285,27 @@ static DBusHandlerResult remove_port(DBusConnection *conn, static DBusHandlerResult list_ports(DBusConnection *conn, DBusMessage *msg, void *data) { - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + DBusMessage *reply; + DBusMessageIter iter; + DBusMessageIter array_iter; + GSList *l; + + 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 = port_paths; l; l= l->next) { + dbus_message_iter_append_basic(&array_iter, + DBUS_TYPE_STRING, &l->data); + } + + dbus_message_iter_close_container(&iter, &array_iter); + + return send_message_and_unref(conn, reply); } static DBusHandlerResult manager_message(DBusConnection *conn, |