From: Marcel Holtmann Date: Mon, 15 Dec 2008 01:57:43 +0000 (+0100) Subject: Add signal strength to connection objects X-Git-Tag: 0.4~19 X-Git-Url: http://git.maemo.org/git/?p=connman;a=commitdiff_plain;h=5ba07041179215daa35b2ea208ef5969ad8cf25f Add signal strength to connection objects --- diff --git a/doc/connection-api.txt b/doc/connection-api.txt index e2cf474..7356b34 100644 --- a/doc/connection-api.txt +++ b/doc/connection-api.txt @@ -21,6 +21,12 @@ Properties string Type [readonly] The connection type (for example wifi etc.) + uint8 Strength [readonly] + + Indicates the signal strength of the connection. + + This property is optional and not always present. + string IPv4.Method [readonly] Indicates the way how the IPv4 settings were diff --git a/include/element.h b/include/element.h index bc03011..48e46f2 100644 --- a/include/element.h +++ b/include/element.h @@ -93,6 +93,7 @@ struct connman_element { gboolean available; gboolean remember; guint16 priority; + guint8 strength; gchar *devname; struct connman_element *parent; diff --git a/src/element.c b/src/element.c index d1e6de3..a78a2be 100644 --- a/src/element.c +++ b/src/element.c @@ -705,6 +705,11 @@ static DBusMessage *connection_get_properties(DBusConnection *conn, connman_dbus_dict_append_variant(&dict, "Type", DBUS_TYPE_STRING, &str); + if (element->subtype == CONNMAN_ELEMENT_SUBTYPE_WIFI || + element->subtype == CONNMAN_ELEMENT_SUBTYPE_WIMAX) + connman_dbus_dict_append_variant(&dict, "Strength", + DBUS_TYPE_BYTE, &element->strength); + add_common_properties(element, &dict); dbus_message_iter_close_container(&array, &dict); @@ -1739,6 +1744,20 @@ static void emit_state_change(DBusConnection *conn, const char *state) g_dbus_send_message(conn, signal); } +static void set_signal_strength(struct connman_element *connection) +{ + struct connman_element *element = connection; + + while (element != NULL) { + if (element->type == CONNMAN_ELEMENT_TYPE_NETWORK) { + connection->strength = element->strength; + break; + } + + element = element->parent; + } +} + static void register_element(gpointer data, gpointer user_data) { struct connman_element *element = data; @@ -1805,6 +1824,7 @@ static void register_element(gpointer data, gpointer user_data) connman_error("Failed to register %s connection", element->path); else { + set_signal_strength(element); emit_connections_signal(connection); emit_state_change(connection, "online"); }