From: Marcel Holtmann Date: Sun, 23 Nov 2008 13:50:56 +0000 (+0100) Subject: Provide connection element and its interface X-Git-Tag: 2.0_alpha~4595 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1530b2ba9dba6e2231dd5de39d73150266121f6;p=framework%2Fconnectivity%2Fconnman.git Provide connection element and its interface --- diff --git a/include/element.h b/include/element.h index 96031db..55f9593 100644 --- a/include/element.h +++ b/include/element.h @@ -57,7 +57,7 @@ enum connman_element_type { CONNMAN_ELEMENT_TYPE_ZEROCONF = 9, CONNMAN_ELEMENT_TYPE_RESOLVER = 10, - CONNMAN_ELEMENT_TYPE_INTERNET = 42, + CONNMAN_ELEMENT_TYPE_CONNECTION = 42, }; enum connman_element_subtype { diff --git a/plugins/resolvconf.c b/plugins/resolvconf.c index 814bbeb..f81d106 100644 --- a/plugins/resolvconf.c +++ b/plugins/resolvconf.c @@ -68,7 +68,7 @@ static int resolvconf_probe(struct connman_element *element) internet = connman_element_create(NULL); - internet->type = CONNMAN_ELEMENT_TYPE_INTERNET; + internet->type = CONNMAN_ELEMENT_TYPE_CONNECTION; connman_element_register(internet, element); diff --git a/plugins/resolvfile.c b/plugins/resolvfile.c index 0920441..54ad41b 100644 --- a/plugins/resolvfile.c +++ b/plugins/resolvfile.c @@ -65,7 +65,7 @@ static int resolvfile_probe(struct connman_element *element) internet = connman_element_create(NULL); - internet->type = CONNMAN_ELEMENT_TYPE_INTERNET; + internet->type = CONNMAN_ELEMENT_TYPE_CONNECTION; connman_element_register(internet, element); diff --git a/src/element.c b/src/element.c index 005626d..d3040cc 100644 --- a/src/element.c +++ b/src/element.c @@ -119,8 +119,8 @@ static const char *type2string(enum connman_element_type type) return "zeroconf"; case CONNMAN_ELEMENT_TYPE_RESOLVER: return "resolver"; - case CONNMAN_ELEMENT_TYPE_INTERNET: - return "internet"; + case CONNMAN_ELEMENT_TYPE_CONNECTION: + return "connection"; } return NULL; @@ -319,6 +319,33 @@ static DBusMessage *get_network_properties(DBusConnection *conn, return reply; } +static DBusMessage *get_connection_properties(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct connman_element *element = 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); + + add_common_properties(element, &dict); + + dbus_message_iter_close_container(&array, &dict); + + return reply; +} + static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -505,6 +532,11 @@ static GDBusMethodTable network_methods[] = { { }, }; +static GDBusMethodTable connection_methods[] = { + { "GetProperties", "", "a{sv}", get_connection_properties }, + { }, +}; + struct append_filter { enum connman_element_type type; DBusMessageIter *iter; @@ -1369,6 +1401,15 @@ static void register_element(gpointer data, gpointer user_data) element->path); } + if (element->type == CONNMAN_ELEMENT_TYPE_CONNECTION) { + if (g_dbus_register_interface(connection, element->path, + CONNMAN_CONNECTION_INTERFACE, + connection_methods, element_signals, + NULL, element, NULL) == FALSE) + connman_error("Failed to register %s connection", + element->path); + } + g_dbus_emit_signal(connection, CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "ElementAdded", DBUS_TYPE_OBJECT_PATH, &element->path, @@ -1428,6 +1469,10 @@ static gboolean remove_element(GNode *node, gpointer user_data) DBUS_TYPE_OBJECT_PATH, &element->path, DBUS_TYPE_INVALID); + if (element->type == CONNMAN_ELEMENT_TYPE_CONNECTION) + g_dbus_unregister_interface(connection, element->path, + CONNMAN_CONNECTION_INTERFACE); + if (element->type == CONNMAN_ELEMENT_TYPE_NETWORK) g_dbus_unregister_interface(connection, element->path, CONNMAN_NETWORK_INTERFACE); diff --git a/src/manager.c b/src/manager.c index 9de73e0..58f2982 100644 --- a/src/manager.c +++ b/src/manager.c @@ -96,7 +96,7 @@ static void append_connections(DBusMessageIter *dict) dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH_AS_STRING, &iter); - __connman_element_list(CONNMAN_ELEMENT_TYPE_INTERNET, &iter); + __connman_element_list(CONNMAN_ELEMENT_TYPE_CONNECTION, &iter); dbus_message_iter_close_container(&value, &iter);