Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."


Today's Topics:

   1. [RFC v0 06/10] iwd: Add Agent support (Daniel Wagner)
   2. [RFC v0 07/10] iwd: Register technology, device and network
      driver stub (Daniel Wagner)
   3. [RFC v0 08/10] iwd: Add/remove ConnMan devices (Daniel Wagner)
   4. [RFC v0 09/10] iwd: Add/remove ConnMan networks (Daniel Wagner)
   5. Re: [PATCH] ntp: clear ADJ_MAXERROR to keep STA_UNSYNC
      cleared after jump adjust (Daniel Wagner)


----------------------------------------------------------------------

Message: 1
Date: Thu, 10 Nov 2016 13:43:07 +0100
From: Daniel Wagner <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Subject: [RFC v0 06/10] iwd: Add Agent support
Message-ID: <[email protected]>

From: Daniel Wagner <[email protected]>

---
 plugins/iwd.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 129 insertions(+)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index 4036ad276a37..c9535407d918 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -34,9 +34,11 @@
 
 static DBusConnection *connection;
 static GDBusClient *client;
+static GDBusProxy *agent_proxy;
 static GHashTable *adapters;
 static GHashTable *devices;
 static GHashTable *networks;
+static bool agent_registered;
 
 #define IWD_SERVICE                    "net.connman.iwd"
 #define IWD_PATH                       "/"
@@ -45,6 +47,10 @@ static GHashTable *networks;
 #define IWD_DEVICE_INTERFACE           "net.connman.iwd.Device"
 #define IWD_NETWORK_INTERFACE          "net.connman.iwd.Network"
 
+#define IWD_AGENT_INTERFACE            "net.connman.iwd.Agent"
+#define IWD_AGENT_ERROR_INTERFACE      "net.connman.iwd.Agent.Error"
+#define AGENT_PATH                     "/net/connman/iwd_agent"
+
 enum iwd_device_state {
        IWD_DEVICE_STATE_UNKNOWN,
        IWD_DEVICE_STATE_CONNECTED,
@@ -372,12 +378,133 @@ static void create_device(GDBusProxy *proxy)
                        device_property_change, NULL);
 }
 
+static void unregister_agent();
+
+static DBusMessage *agent_release_method(DBusConnection *dbus_conn,
+                                       DBusMessage *message, void *user_data)
+{
+       unregister_agent();
+       return g_dbus_create_reply(message, DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *get_reply_on_error(DBusMessage *message, int error)
+{
+       return g_dbus_create_error(message,
+               IWD_AGENT_ERROR_INTERFACE ".Failed", "Invalid parameters");
+}
+
+static DBusMessage *agent_request_passphrase(DBusConnection *dbus_conn,
+                                               DBusMessage *message,
+                                               void *user_data)
+{
+       struct iwd_network *iwdn;
+       DBusMessageIter iter;
+       const char *path, *passwd;
+
+       DBG("");
+
+       dbus_message_iter_init(message, &iter);
+
+       if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_OBJECT_PATH)
+               return get_reply_on_error(message, EINVAL);
+
+       dbus_message_iter_get_basic(&iter, &path);
+
+       iwdn = g_hash_table_lookup(networks, path);
+       if (!iwdn)
+               return get_reply_on_error(message, EINVAL);
+
+       passwd = "mysecret";
+
+       return g_dbus_create_reply(message, DBUS_TYPE_STRING, &passwd,
+                                       DBUS_TYPE_INVALID);
+}
+
+static DBusMessage *agent_cancel(DBusConnection *dbus_conn,
+                                       DBusMessage *message, void *user_data)
+{
+       DBusMessageIter iter;
+       const char *reason;
+
+       dbus_message_iter_init(message, &iter);
+
+       if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+               return get_reply_on_error(message, EINVAL);
+
+       dbus_message_iter_get_basic(&iter, &reason);
+
+       DBG("cancel: %s", reason);
+       /* XXX stop connection attempt, which one? */
+
+       return g_dbus_create_reply(message, DBUS_TYPE_INVALID);
+}
+
+static const GDBusMethodTable agent_methods[] = {
+       { GDBUS_METHOD("Release", NULL, NULL, agent_release_method) },
+       { GDBUS_METHOD("RequestPassphrase",
+                       GDBUS_ARGS({ "path", "o" }),
+                       GDBUS_ARGS({ "passphrase", "s" }),
+                       agent_request_passphrase)},
+       { GDBUS_METHOD("Cancel",
+                       GDBUS_ARGS({ "reason", "s" }),
+                       NULL, agent_cancel) },
+       { },
+};
+
+
+static void agent_register_builder(DBusMessageIter *iter, void *user_data)
+{
+       const char *path = AGENT_PATH;
+
+       dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,
+                               &path);
+}
+
 static void register_agent(GDBusProxy *proxy)
 {
+       if (g_dbus_proxy_method_call(proxy,
+                                       "RegisterAgent",
+                                       agent_register_builder,
+                                       NULL, NULL, NULL))
+               return;
+
+       agent_proxy = proxy;
 }
 
 static void unregister_agent()
 {
+       if (!agent_proxy)
+               return;
+
+       if (g_dbus_proxy_method_call(agent_proxy,
+                                       "UnregisterAgent",
+                                       agent_register_builder,
+                                       NULL, NULL, NULL))
+
+       g_dbus_proxy_unref(agent_proxy);
+       agent_proxy = NULL;
+}
+
+static void iwd_is_present(DBusConnection *conn, void *user_data)
+{
+       if (agent_registered)
+               return;
+
+       if (!g_dbus_register_interface(connection, AGENT_PATH,
+                                       IWD_AGENT_INTERFACE, agent_methods,
+                                       NULL, NULL, NULL, NULL))
+               return;
+
+       agent_registered = true;
+}
+
+static void iwd_is_out(DBusConnection *conn, void *user_data)
+{
+       if (agent_registered) {
+               g_dbus_unregister_interface(connection,
+                                       AGENT_PATH, IWD_AGENT_INTERFACE);
+               agent_registered = false;
+       }
 }
 
 static void create_network(GDBusProxy *proxy)
@@ -486,6 +613,8 @@ static int iwd_init(void)
                goto out;
        }
 
+       g_dbus_client_set_connect_watch(client, iwd_is_present, NULL);
+       g_dbus_client_set_disconnect_watch(client, iwd_is_out, NULL);
        g_dbus_client_set_proxy_handlers(client, object_added, object_removed,
                        NULL, NULL);
 
-- 
2.7.4


------------------------------

Message: 2
Date: Thu, 10 Nov 2016 13:43:08 +0100
From: Daniel Wagner <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Subject: [RFC v0 07/10] iwd: Register technology, device and network
        driver stub
Message-ID: <[email protected]>

From: Daniel Wagner <[email protected]>

---
 plugins/iwd.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index c9535407d918..8e9d71ae46e7 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -30,6 +30,8 @@
 #define CONNMAN_API_SUBJECT_TO_CHANGE
 #include <connman/plugin.h>
 #include <connman/dbus.h>
+#include <connman/network.h>
+#include <connman/technology.h>
 #include <gdbus.h>
 
 static DBusConnection *connection;
@@ -138,6 +140,91 @@ static bool proxy_get_bool(GDBusProxy *proxy, const char 
*property)
        return value;
 }
 
+static int cm_network_probe(struct connman_network *network)
+{
+       return -EOPNOTSUPP;
+}
+
+static void cm_network_remove(struct connman_network *network)
+{
+}
+
+static int cm_network_connect(struct connman_network *network)
+{
+       return -EINPROGRESS;
+}
+
+static int cm_network_disconnect(struct connman_network *network)
+{
+       return -EINPROGRESS;
+}
+
+static struct connman_network_driver network_driver = {
+       .name           = "iwd",
+       .type           = CONNMAN_NETWORK_TYPE_WIFI,
+       .probe          = cm_network_probe,
+       .remove         = cm_network_remove,
+       .connect        = cm_network_connect,
+       .disconnect     = cm_network_disconnect,
+};
+
+static int cm_device_probe(struct connman_device *device)
+{
+       return -EOPNOTSUPP;
+}
+
+static void cm_device_remove(struct connman_device *device)
+{
+}
+
+static int set_device_powered(struct connman_device *device, bool powered)
+{
+       return -EINPROGRESS;
+}
+
+static int cm_device_enable(struct connman_device *device)
+{
+       return set_device_powered(device, true);
+}
+
+static int cm_device_disable(struct connman_device *device)
+{
+       return set_device_powered(device, false);
+}
+
+static struct connman_device_driver device_driver = {
+       .name           = "iwd",
+       .type           = CONNMAN_DEVICE_TYPE_WIFI,
+       .probe          = cm_device_probe,
+       .remove         = cm_device_remove,
+       .enable         = cm_device_enable,
+       .disable        = cm_device_disable,
+};
+
+static int cm_tech_probe(struct connman_technology *technology)
+{
+       return 0;
+}
+
+static void cm_tech_remove(struct connman_technology *technology)
+{
+}
+
+static int cm_tech_set_tethering(struct connman_technology *technology,
+               const char *identifier, const char *passphrase,
+               const char *bridge, bool enabled)
+{
+       return 0;
+}
+
+static struct connman_technology_driver tech_driver = {
+       .name           = "iwd",
+       .type           = CONNMAN_SERVICE_TYPE_WIFI,
+       .probe          = cm_tech_probe,
+       .remove         = cm_tech_remove,
+       .set_tethering  = cm_tech_set_tethering,
+};
+
 static void adapter_property_change(GDBusProxy *proxy, const char *name,
                DBusMessageIter *iter, void *user_data)
 {
@@ -606,6 +693,24 @@ static int iwd_init(void)
        networks = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
                        network_free);
 
+       if (connman_technology_driver_register(&tech_driver) < 0) {
+               connman_warn("Failed to initialize technology for IWD");
+               goto out;
+       }
+
+       if (connman_device_driver_register(&device_driver) < 0) {
+               connman_warn("Failed to initialize device driver for "
+                               IWD_SERVICE);
+               connman_technology_driver_unregister(&tech_driver);
+               goto out;
+       }
+
+       if (connman_network_driver_register(&network_driver) < 0) {
+               connman_technology_driver_unregister(&tech_driver);
+               connman_device_driver_unregister(&device_driver);
+               goto out;
+       }
+
        client = g_dbus_client_new(connection, IWD_SERVICE, IWD_PATH);
        if (!client) {
                connman_warn("Failed to initialize D-Bus client for "
@@ -640,6 +745,10 @@ static void iwd_exit(void)
 {
        g_dbus_client_unref(client);
 
+       connman_network_driver_unregister(&network_driver);
+       connman_device_driver_unregister(&device_driver);
+       connman_technology_driver_unregister(&tech_driver);
+
        g_hash_table_destroy(networks);
        g_hash_table_destroy(devices);
        g_hash_table_destroy(adapters);
-- 
2.7.4


------------------------------

Message: 3
Date: Thu, 10 Nov 2016 13:43:09 +0100
From: Daniel Wagner <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Subject: [RFC v0 08/10] iwd: Add/remove ConnMan devices
Message-ID: <[email protected]>

From: Daniel Wagner <[email protected]>

---
 plugins/iwd.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index 8e9d71ae46e7..587a2de17ed0 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -26,12 +26,14 @@
 #include <errno.h>
 #include <string.h>
 #include <stdbool.h>
+#include <linux/if_ether.h>
 
 #define CONNMAN_API_SUBJECT_TO_CHANGE
 #include <connman/plugin.h>
 #include <connman/dbus.h>
 #include <connman/network.h>
 #include <connman/technology.h>
+#include <connman/inet.h>
 #include <gdbus.h>
 
 static DBusConnection *connection;
@@ -76,6 +78,8 @@ struct iwd_device {
        enum iwd_device_state state;
        bool powered;
        bool scanning;
+
+       struct connman_device *device;
 };
 
 struct iwd_network {
@@ -140,6 +144,17 @@ static bool proxy_get_bool(GDBusProxy *proxy, const char 
*property)
        return value;
 }
 
+static void address2ident(const char *address, char *ident)
+{
+       int i;
+
+       for (i = 0; i < ETH_ALEN; i++) {
+               ident[i * 2] = address[i * 3];
+               ident[i * 2 + 1] = address[i * 3 + 1];
+       }
+       ident[ETH_ALEN * 2] = '\0';
+}
+
 static int cm_network_probe(struct connman_network *network)
 {
        return -EOPNOTSUPP;
@@ -170,6 +185,18 @@ static struct connman_network_driver network_driver = {
 
 static int cm_device_probe(struct connman_device *device)
 {
+       GHashTableIter iter;
+       gpointer key, value;
+
+       g_hash_table_iter_init(&iter, devices);
+
+       while (g_hash_table_iter_next(&iter, &key, &value)) {
+               struct iwd_device *iwdd = value;
+
+               if (device == iwdd->device)
+                       return 0;
+       }
+
        return -EOPNOTSUPP;
 }
 
@@ -177,8 +204,51 @@ static void cm_device_remove(struct connman_device *device)
 {
 }
 
+struct dev_cb_data {
+       char *path;
+       bool powered;
+};
+
+static void device_powered_cb(const DBusError *error, void *user_data)
+{
+       struct dev_cb_data *cbd = user_data;
+       struct iwd_device *iwdd;;
+
+       iwdd = g_hash_table_lookup(devices, cbd->path);
+       if (!iwdd)
+               goto out;
+
+       if (dbus_error_is_set(error)) {
+               connman_warn("WiFi device %s not enabled %s",
+                               cbd->path, error->message);
+               goto out;
+       }
+
+       connman_device_set_powered(iwdd->device, cbd->powered);
+out:
+       g_free(cbd->path);
+}
+
 static int set_device_powered(struct connman_device *device, bool powered)
 {
+       struct iwd_device *iwdd = connman_device_get_data(device);
+       dbus_bool_t device_powered = powered;
+       struct dev_cb_data *cbd;
+       const char *path;
+
+       path = g_dbus_proxy_get_path(iwdd->proxy);
+
+       if (proxy_get_bool(iwdd->proxy, "Powered"))
+               return -EALREADY;
+
+       cbd = g_new(struct dev_cb_data, 1);
+       cbd->path = g_strdup(path);
+       cbd->powered = powered;
+
+       g_dbus_proxy_set_property_basic(iwdd->proxy, "Powered",
+                       DBUS_TYPE_BOOLEAN, &device_powered,
+                       device_powered_cb, cbd, g_free);
+
        return -EINPROGRESS;
 }
 
@@ -225,6 +295,36 @@ static struct connman_technology_driver tech_driver = {
        .set_tethering  = cm_tech_set_tethering,
 };
 
+static void add_device(const char *path, struct iwd_device *iwdd)
+{
+       char ident[ETH_ALEN * 2 + 1];
+
+       iwdd->device = connman_device_create("wifi", CONNMAN_DEVICE_TYPE_WIFI);
+       if (!iwdd->device)
+               return;
+
+       connman_device_set_data(iwdd->device, iwdd);
+
+       address2ident(iwdd->address, ident);
+       connman_device_set_ident(iwdd->device, ident);
+
+       if (connman_device_register(iwdd->device) < 0) {
+               g_hash_table_remove(devices, path);
+               return;
+       }
+
+       connman_device_set_powered(iwdd->device, iwdd->powered);
+}
+
+static void remove_device(struct iwd_device *iwdd)
+{
+       if (!iwdd->device)
+               return;
+
+       connman_device_unref(iwdd->device);
+       iwdd->device = NULL;
+}
+
 static void adapter_property_change(GDBusProxy *proxy, const char *name,
                DBusMessageIter *iter, void *user_data)
 {
@@ -358,6 +458,8 @@ static void device_free(gpointer data)
                iwdd->proxy = NULL;
        }
 
+       remove_device(iwdd);
+
        g_free(iwdd->adapter);
        g_free(iwdd->name);
        g_free(iwdd->address);
@@ -463,6 +565,8 @@ static void create_device(GDBusProxy *proxy)
 
        g_dbus_proxy_set_property_watch(iwdd->proxy,
                        device_property_change, NULL);
+
+       add_device(path, iwdd);
 }
 
 static void unregister_agent();
-- 
2.7.4


------------------------------

Message: 4
Date: Thu, 10 Nov 2016 13:43:10 +0100
From: Daniel Wagner <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Subject: [RFC v0 09/10] iwd: Add/remove ConnMan networks
Message-ID: <[email protected]>

From: Daniel Wagner <[email protected]>

---
 plugins/iwd.c | 232 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 231 insertions(+), 1 deletion(-)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index 587a2de17ed0..5be385f10e06 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -88,6 +88,8 @@ struct iwd_network {
        char *name;
        char *type;
        bool connected;
+
+       struct connman_network *network;
 };
 
 static enum iwd_device_state string2state(const char *str)
@@ -157,20 +159,156 @@ static void address2ident(const char *address, char 
*ident)
 
 static int cm_network_probe(struct connman_network *network)
 {
+       GHashTableIter iter;
+       gpointer key, value;
+
+       g_hash_table_iter_init(&iter, networks);
+
+       while (g_hash_table_iter_next(&iter, &key, &value)) {
+               struct iwd_network *iwdn = value;
+
+               if (network == iwdn->network)
+                       return 0;
+       }
+
        return -EOPNOTSUPP;
 }
 
 static void cm_network_remove(struct connman_network *network)
 {
+       struct connman_device *device;
+       struct iwd_network *iwdn;
+
+       iwdn = connman_network_get_data(network);
+       if (iwdn)
+               iwdn->network = NULL;
+
+       device = connman_network_get_device(network);
+       if (device)
+               connman_device_remove_network(device, network);
+
+       connman_network_set_data(network, NULL);
+       connman_network_unref(network);
+}
+
+static void update_network_connected(struct iwd_network *iwdn)
+{
+       struct iwd_device *iwdd;
+       int index;
+
+       iwdd = g_hash_table_lookup(devices, iwdn->device);
+       if (!iwdd)
+               return;
+
+       index = connman_inet_ifindex(iwdd->name);
+       if (index < 0)
+               return;
+
+       DBG("interface name %s index %d", iwdd->name, index);
+       connman_network_set_index(iwdn->network, index);
+       connman_network_set_connected(iwdn->network, true);
+}
+
+static void update_network_disconnected(struct iwd_network *iwdn)
+{
+       DBG("interface name %s", iwdn->name);
+       connman_network_set_connectable(iwdn->network, false);
+       connman_network_set_connected(iwdn->network, false);
+}
+
+static void cm_network_connect_cb(DBusMessage *message, void *user_data)
+{
+       const char *path = user_data;
+       struct iwd_network *iwdn;
+
+       iwdn = g_hash_table_lookup(networks, path);
+       if (!iwdn)
+               return;
+
+       if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
+               const char *dbus_error = dbus_message_get_error_name(message);
+
+               if (!strcmp(dbus_error, "net.connman.iwd.InProgress"))
+                       return;
+
+               DBG("%s connect failed: %s", path, dbus_error);
+               connman_network_set_error(iwdn->network,
+                                       CONNMAN_NETWORK_ERROR_CONNECT_FAIL);
+               return;
+       }
+
+       update_network_connected(iwdn);
 }
 
 static int cm_network_connect(struct connman_network *network)
 {
+       struct iwd_network *iwdn = connman_network_get_data(network);
+       const char *path;
+
+       if (!iwdn)
+               return -EINVAL;
+
+       path = g_dbus_proxy_get_path(iwdn->proxy);
+
+       if (!g_dbus_proxy_method_call(iwdn->proxy, "Connect",
+                       NULL, cm_network_connect_cb,
+                       g_strdup(path), g_free))
+               return -EIO;
+
+       connman_network_set_connectable(iwdn->network, true);
+       connman_network_set_associating(iwdn->network, true);
+
        return -EINPROGRESS;
 }
 
+static void cm_network_disconnect_cb(DBusMessage *message, void *user_data)
+{
+       const char *path = user_data;
+       struct iwd_network *iwdn;
+
+       iwdn = g_hash_table_lookup(networks, path);
+       if (!iwdn)
+               return;
+
+       if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
+               const char *dbus_error = dbus_message_get_error_name(message);
+
+               if (!strcmp(dbus_error, "net.connman.iwd.NotConnected")) {
+                       /* fall through */
+               } else {
+                       DBG("%s disconnect failed: %s", path, dbus_error);
+                       return;
+               }
+       }
+
+       /*
+        * We end up in a tight loop in the error case. That is
+        * when we can't connect, bail out in cm_network_connect_cb() with
+        * an error.
+        */
+       if (connman_network_get_connected(iwdn->network))
+               update_network_disconnected(iwdn);
+}
+
 static int cm_network_disconnect(struct connman_network *network)
 {
+       struct iwd_network *iwdn = connman_network_get_data(network);
+       struct iwd_device *iwdd;
+       const char *path;
+
+       if (!iwdn)
+               return -EINVAL;
+
+       path = g_dbus_proxy_get_path(iwdn->proxy);
+
+       iwdd = g_hash_table_lookup(devices, iwdn->device);
+       if (!iwdd)
+               return -EIO;
+
+       if (!g_dbus_proxy_method_call(iwdd->proxy, "Disconnect",
+                       NULL, cm_network_disconnect_cb, g_strdup(path), g_free))
+               return -EIO;
+
        return -EINPROGRESS;
 }
 
@@ -295,6 +433,89 @@ static struct connman_technology_driver tech_driver = {
        .set_tethering  = cm_tech_set_tethering,
 };
 
+static unsigned char calculate_strength(int strength)
+{
+       unsigned char res;
+
+       /*
+        * Network's maximum signal strength expressed in 100 * dBm.
+        * The value is the range of 0 (strongest signal) to -10000
+        * (weakest signal)
+        *
+        * ConnMan expects it in the range from 100 (strongest) to 0
+        * (weakest).
+        */
+       res = (unsigned char)((strength * -10000) / 100);
+
+       return res;
+}
+
+static void add_network(const char *path, struct iwd_network *iwdn)
+{
+       struct iwd_device *iwdd;
+       const char *identifier;
+
+       iwdd = g_hash_table_lookup(devices, iwdn->device);
+       if (!iwdd)
+               return;
+
+       identifier = strrchr(path, '/');
+       identifier++; /* strip leading slash as well */
+       iwdn->network = connman_network_create(identifier,
+                                       CONNMAN_NETWORK_TYPE_WIFI);
+       connman_network_set_data(iwdn->network, iwdn);
+
+       connman_network_set_name(iwdn->network, iwdn->name);
+       connman_network_set_blob(iwdn->network, "WiFi.SSID", iwdn->name,
+                                       strlen(iwdn->name));
+       connman_network_set_string(iwdn->network, "WiFi.Security",
+                                       iwdn->type);
+
+       /* XXX yeah we just happen to know that this works */
+       connman_network_set_bool(iwdn->network, "WiFi.WPS", true);
+
+       /*
+        * XXX we need to extract the signal strength from
+        * Getorderednetworks() and somehow update it perodically.
+        *
+        * Or we just look for the scanning property:
+        *
+        * plugins/iwd.c:device_property_change() /phy4/10 scanning 0
+        * plugins/iwd.c:device_property_change() /phy4/10 scanning 1
+        * plugins/iwd.c:device_property_change() /phy4/10 scanning 0
+        * plugins/iwd.c:device_property_change() /phy4/10 scanning 1
+        *
+        * If scanning 1 -> 0 -> Getorderednetworks()
+        */
+       connman_network_set_strength(iwdn->network,
+                                       calculate_strength(-4200));
+
+       if (connman_device_add_network(iwdd->device, iwdn->network) < 0) {
+               connman_network_unref(iwdn->network);
+               iwdn->network = NULL;
+       }
+
+       connman_network_set_available(iwdn->network, true);
+       connman_network_set_group(iwdn->network, identifier);
+}
+
+static void remove_network(struct iwd_network *iwdn)
+{
+       struct iwd_device *iwdd;
+
+       /* We don't have a network pointer if this network is not connected */
+       if (!iwdn->network)
+               return;
+
+       iwdd = g_hash_table_lookup(devices, iwdn->device);
+       if (iwdd && iwdd->device)
+               /* connman_device_remove_network() will unref the network */
+               connman_device_remove_network(iwdd->device, iwdn->network);
+       else
+               connman_network_unref(iwdn->network);
+       iwdn->network = NULL;
+}
+
 static void add_device(const char *path, struct iwd_device *iwdd)
 {
        char ident[ETH_ALEN * 2 + 1];
@@ -424,6 +645,11 @@ static void network_property_change(GDBusProxy *proxy, 
const char *name,
                iwdn->connected = connected;
 
                DBG("%s connected %d", path, iwdn->connected);
+
+               if (iwdn->connected)
+                       update_network_connected(iwdn);
+               else
+                       update_network_disconnected(iwdn);
        } else if (!strcmp(name, "Type")) {
                const char *type;
 
@@ -475,6 +701,8 @@ static void network_free(gpointer data)
                iwdn->proxy = NULL;
        }
 
+       remove_network(iwdn);
+
        g_free(iwdn->device);
        g_free(iwdn->name);
        g_free(iwdn->type);
@@ -605,7 +833,7 @@ static DBusMessage *agent_request_passphrase(DBusConnection 
*dbus_conn,
        if (!iwdn)
                return get_reply_on_error(message, EINVAL);
 
-       passwd = "mysecret";
+       passwd = connman_network_get_string(iwdn->network, "WiFi.Passphrase");
 
        return g_dbus_create_reply(message, DBUS_TYPE_STRING, &passwd,
                                        DBUS_TYPE_INVALID);
@@ -733,6 +961,8 @@ static void create_network(GDBusProxy *proxy)
 
        g_dbus_proxy_set_property_watch(network->proxy,
                        network_property_change, NULL);
+
+       add_network(path, network);
 }
 
 static void object_added(GDBusProxy *proxy, void *user_data)
-- 
2.7.4


------------------------------

Message: 5
Date: Thu, 10 Nov 2016 13:51:27 +0100
From: Daniel Wagner <[email protected]>
To: Patrik Flykt <[email protected]>, Alexander Kochetkov
        <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] ntp: clear ADJ_MAXERROR to keep STA_UNSYNC
        cleared after jump adjust
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed

On 11/10/2016 07:46 AM, Patrik Flykt wrote:
> On Wed, 2016-11-09 at 14:22 +0100, Daniel Wagner wrote:
>
>> Thanks for your patch. Since I have no clue how this stuff works I
>> would like an ACK from Jukka who did some work in the past and seem
>> to understand it.
>
> Patch looks fine to me. Should not work any more worse than the current
> implementation. ACK from me.

I completely agree. Patch applied.

cheers,
daniel


------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 13, Issue 10
***************************************

Reply via email to