From: Marcel Holtmann Date: Wed, 19 Nov 2008 09:15:25 +0000 (+0100) Subject: Use properties for profiles, devices and connections X-Git-Tag: accepted/2.0alpha-wayland/20121110.002834~4617 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d5ab53c5c005439464c684ed3402d81598c5aea;p=profile%2Fivi%2Fconnman.git Use properties for profiles, devices and connections --- diff --git a/src/manager.c b/src/manager.c index d4098da..a9a52ea 100644 --- a/src/manager.c +++ b/src/manager.c @@ -27,10 +27,10 @@ #include "connman.h" -static void append_elements(DBusMessageIter *dict) +static void append_devices(DBusMessageIter *dict) { DBusMessageIter entry, value, iter; - const char *key = "Elements"; + const char *key = "Devices"; dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry); @@ -44,7 +44,59 @@ static void append_elements(DBusMessageIter *dict) dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter); - __connman_element_list(CONNMAN_ELEMENT_TYPE_UNKNOWN, &iter); + __connman_element_list(CONNMAN_ELEMENT_TYPE_DEVICE, &iter); + + dbus_message_iter_close_container(&value, &iter); + + dbus_message_iter_close_container(&entry, &value); + + dbus_message_iter_close_container(dict, &entry); +} + +static void append_connections(DBusMessageIter *dict) +{ + DBusMessageIter entry, value, iter; + const char *key = "Connections"; + + 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_INTERNET, &iter); + + dbus_message_iter_close_container(&value, &iter); + + dbus_message_iter_close_container(&entry, &value); + + dbus_message_iter_close_container(dict, &entry); +} + +static void append_profiles(DBusMessageIter *dict) +{ + DBusMessageIter entry, value, iter; + const char *key = "Profiles"; + + 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_profile_list(&iter); dbus_message_iter_close_container(&value, &iter); @@ -72,7 +124,10 @@ static DBusMessage *get_properties(DBusConnection *conn, DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict); - append_elements(&dict); + append_profiles(&dict); + + append_devices(&dict); + append_connections(&dict); dbus_message_iter_close_container(&array, &dict); @@ -127,30 +182,6 @@ static DBusMessage *unregister_agent(DBusConnection *conn, return reply; } -static DBusMessage *list_profiles(DBusConnection *conn, - DBusMessage *msg, void *data) -{ - DBusMessage *reply; - DBusMessageIter array, iter; - - 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_TYPE_OBJECT_PATH_AS_STRING, &iter); - - __connman_profile_list(&iter); - - dbus_message_iter_close_container(&array, &iter); - - return reply; -} - static DBusMessage *list_elements(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -179,7 +210,6 @@ static GDBusMethodTable manager_methods[] = { { "GetProperties", "", "a{sv}", get_properties }, { "RegisterAgent", "o", "", register_agent }, { "UnregisterAgent", "o", "", unregister_agent }, - { "ListProfiles", "", "ao", list_profiles }, { "ListElements", "", "ao", list_elements }, { }, }; diff --git a/test/list-devices b/test/list-devices index 3c1b82e..d7b9331 100755 --- a/test/list-devices +++ b/test/list-devices @@ -7,15 +7,13 @@ bus = dbus.SystemBus() manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"), "org.moblin.connman.Manager") -elements = manager.ListElements() +properties = manager.GetProperties() -for path in elements: +for path in properties["Devices"]: element = dbus.Interface(bus.get_object("org.moblin.connman", path), "org.moblin.connman.Element") properties = element.GetProperties() - if (properties["Type"] != "device"): - continue print "[ %s ]" % (path) diff --git a/test/list-profiles b/test/list-profiles index fcf1830..025f3cf 100755 --- a/test/list-profiles +++ b/test/list-profiles @@ -7,9 +7,9 @@ bus = dbus.SystemBus() manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"), "org.moblin.connman.Manager") -profiles = manager.ListProfiles() +properties = manager.GetProperties() -for path in profiles: +for path in properties["Profiles"]: print "[ %s ]" % (path) element = dbus.Interface(bus.get_object("org.moblin.connman", path),