From: Marcel Holtmann Date: Tue, 14 Oct 2008 15:13:42 +0000 (+0200) Subject: Add method and signal for property handling X-Git-Tag: 0.1~147 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2be75e86beed6bee061266354854dd5bd5d0204b;p=platform%2Fupstream%2Fconnman.git Add method and signal for property handling --- diff --git a/src/manager.c b/src/manager.c index 27f6fc5..d4098da 100644 --- a/src/manager.c +++ b/src/manager.c @@ -27,6 +27,58 @@ #include "connman.h" +static void append_elements(DBusMessageIter *dict) +{ + DBusMessageIter entry, value, iter; + const char *key = "Elements"; + + dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, + NULL, &entry); + + dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key); + + dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, + DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_OBJECT_PATH_AS_STRING, + &value); + + dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, + DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter); + + __connman_element_list(CONNMAN_ELEMENT_TYPE_UNKNOWN, &iter); + + dbus_message_iter_close_container(&value, &iter); + + dbus_message_iter_close_container(&entry, &value); + + dbus_message_iter_close_container(dict, &entry); +} + +static DBusMessage *get_properties(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + DBusMessageIter array, dict; + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append(reply, &array); + + dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); + + append_elements(&dict); + + dbus_message_iter_close_container(&array, &dict); + + return reply; +} + static DBusMessage *register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -124,17 +176,19 @@ static DBusMessage *list_elements(DBusConnection *conn, } static GDBusMethodTable manager_methods[] = { - { "RegisterAgent", "o", "", register_agent }, - { "UnregisterAgent", "o", "", unregister_agent }, - { "ListProfiles", "", "ao", list_profiles }, - { "ListElements", "", "ao", list_elements }, + { "GetProperties", "", "a{sv}", get_properties }, + { "RegisterAgent", "o", "", register_agent }, + { "UnregisterAgent", "o", "", unregister_agent }, + { "ListProfiles", "", "ao", list_profiles }, + { "ListElements", "", "ao", list_elements }, { }, }; static GDBusSignalTable manager_signals[] = { - { "ElementAdded", "o" }, - { "ElementUpdated", "o" }, - { "ElementRemoved", "o" }, + { "PropertyChanged", "sv" }, + { "ElementAdded", "o" }, + { "ElementUpdated", "o" }, + { "ElementRemoved", "o" }, { }, };