This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 doc/connection-api.txt |    6 ++++++
 include/element.h      |    1 +
 plugins/wifi.c         |   17 ++++++++++++-----
 src/element.c          |   35 ++++++++++++++++++++++++++++++++++-
 test/test-manager      |    8 +++++++-
 5 files changed, 60 insertions(+), 7 deletions(-)

New commits:
commit 91b02d3430e53b5bf7d974e37cd60102a93f92ad
Author: Marcel Holtmann <[email protected]>
Date:   Mon Dec 15 03:24:03 2008 +0100

    Only update signal strength when it changes

commit 9d1ab587994ff1cab91c4cace94ed76114059a50
Author: Marcel Holtmann <[email protected]>
Date:   Mon Dec 15 03:18:38 2008 +0100

    Indicate when signal strength of connection changes

commit 305e8edb2cb751597b8bbafd40acf10c57b32454
Author: Marcel Holtmann <[email protected]>
Date:   Mon Dec 15 03:17:31 2008 +0100

    Trigger update process after scan results

commit 1020d4fff525b3618d19b9ad178fcca0da3ebc55
Author: Marcel Holtmann <[email protected]>
Date:   Mon Dec 15 02:58:16 2008 +0100

    Make signal strength value available

commit 5ba07041179215daa35b2ea208ef5969ad8cf25f
Author: Marcel Holtmann <[email protected]>
Date:   Mon Dec 15 02:57:43 2008 +0100

    Add signal strength to connection objects

commit 5f9427b70d3e710e02179f11d39e9407be049632
Author: Marcel Holtmann <[email protected]>
Date:   Mon Dec 15 02:55:35 2008 +0100

    Handle signal strength property


Diff in this email is a maximum of 400 lines.
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/plugins/wifi.c b/plugins/wifi.c
index 70e19e9..b7eea7b 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -299,7 +299,6 @@ static void scan_result(struct connman_element *device,
 {
        struct wifi_data *data = connman_element_get_data(device);
        struct connman_element *element;
-       guint8 strength = network->quality;
        gchar *temp;
        int i;
 
@@ -351,18 +350,26 @@ static void scan_result(struct connman_element *device,
                        element->wifi.security = g_strdup(security);
                }
 
+               element->strength = network->quality;
+
                connman_element_add_static_property(element, "Strength",
-                                               DBUS_TYPE_BYTE, &strength);
+                                       DBUS_TYPE_BYTE, &element->strength);
 
                DBG("%s (%s) strength %d", network->identifier,
-                                       element->wifi.security, strength);
+                               element->wifi.security, element->strength);
 
                connman_element_register(element, device);
        } else {
                data->pending = g_slist_remove(data->pending, element);
 
-               connman_element_set_static_property(element, "Strength",
-                                               DBUS_TYPE_BYTE, &strength);
+               if (element->strength != network->quality) {
+                       element->strength = network->quality;
+
+                       connman_element_set_static_property(element, "Strength",
+                                       DBUS_TYPE_BYTE, &element->strength);
+
+                       connman_element_update(element);
+               }
        }
 
        data->current = g_slist_append(data->current, element);
diff --git a/src/element.c b/src/element.c
index d1e6de3..72f4026 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);
@@ -1134,6 +1139,9 @@ static void emit_property_changed(DBusConnection *conn,
        case CONNMAN_ELEMENT_TYPE_NETWORK:
                iface = CONNMAN_NETWORK_INTERFACE;
                break;
+       case CONNMAN_ELEMENT_TYPE_CONNECTION:
+               iface = CONNMAN_CONNECTION_INTERFACE;
+               break;
        default:
                return;
        }
@@ -1739,6 +1747,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 +1827,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");
                }
@@ -1964,12 +1987,22 @@ void connman_element_unregister_children(struct 
connman_element *element)
 static gboolean update_element(GNode *node, gpointer user_data)
 {
        struct connman_element *element = node->data;
+       struct connman_element *root = user_data;
 
        DBG("element %p name %s", element, element->name);
 
        if (element->driver && element->driver->update)
                element->driver->update(element);
 
+       if (element->type == CONNMAN_ELEMENT_TYPE_CONNECTION &&
+                               root->type == CONNMAN_ELEMENT_TYPE_NETWORK) {
+               if (element->strength != root->strength) {
+                       element->strength = root->strength;
+                       emit_property_changed(connection, element, "Strength",
+                                       DBUS_TYPE_BYTE, &element->strength);
+               }
+       }
+
        return FALSE;
 }
 
@@ -1983,7 +2016,7 @@ void connman_element_update(struct connman_element 
*element)
 
        if (node != NULL)
                g_node_traverse(node, G_PRE_ORDER,
-                               G_TRAVERSE_ALL, -1, update_element, NULL);
+                               G_TRAVERSE_ALL, -1, update_element, element);
 }
 
 int connman_element_set_enabled(struct connman_element *element,
diff --git a/test/test-manager b/test/test-manager
index afeb110..c99b54b 100755
--- a/test/test-manager
+++ b/test/test-manager
@@ -30,7 +30,13 @@ def print_properties(key, value):
                for key in properties.keys():
                        if (key == "Networks"):
                                continue
-                       print "        %s = %s" % (key, properties[key])
+
+                       if (key == "Strength"):
+                               val = int(properties[key])
+                       else:
+                               val = str(properties[key])
+
+                       print "        %s = %s" % (key, val)
 
                if "Networks" in properties.keys():
                        list = ""
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits

Reply via email to