diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-12-15 02:57:43 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-12-15 02:57:43 +0100 |
commit | 5ba07041179215daa35b2ea208ef5969ad8cf25f (patch) | |
tree | a8520f08846c73b39e83655e74feae5a37519040 | |
parent | 5f9427b70d3e710e02179f11d39e9407be049632 (diff) | |
download | connman-5ba07041179215daa35b2ea208ef5969ad8cf25f.tar.gz connman-5ba07041179215daa35b2ea208ef5969ad8cf25f.tar.bz2 connman-5ba07041179215daa35b2ea208ef5969ad8cf25f.zip |
Add signal strength to connection objects
-rw-r--r-- | doc/connection-api.txt | 6 | ||||
-rw-r--r-- | include/element.h | 1 | ||||
-rw-r--r-- | src/element.c | 20 |
3 files changed, 27 insertions, 0 deletions
diff --git a/doc/connection-api.txt b/doc/connection-api.txt index e2cf4746..7356b348 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 bc03011a..48e46f20 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 d1e6de3e..a78a2bed 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"); } |