Tethering: Add hidden access point support in technology
[platform/upstream/connman.git] / src / technology.c
index be66c3a..679c779 100644 (file)
@@ -66,6 +66,7 @@ struct connman_technology {
                                              */
        char *tethering_ident;
        char *tethering_passphrase;
+       bool tethering_hidden;
 
        bool enable_persistent; /* Save the tech state */
 
@@ -177,6 +178,9 @@ static void technology_save(struct connman_technology *technology)
        g_key_file_set_boolean(keyfile, identifier, "Tethering",
                                technology->tethering_persistent);
 
+       g_key_file_set_boolean(keyfile, identifier, "Hidden",
+                               technology->tethering_hidden);
+
        if (technology->tethering_ident)
                g_key_file_set_string(keyfile, identifier,
                                        "Tethering.Identifier",
@@ -233,9 +237,11 @@ static int set_tethering(struct connman_technology *technology,
        int err;
        const char *ident, *passphrase, *bridge;
        GSList *tech_drivers;
+       bool hidden;
 
        ident = technology->tethering_ident;
        passphrase = technology->tethering_passphrase;
+       hidden = technology->tethering_hidden;
 
        __sync_synchronize();
        if (!technology->enabled)
@@ -256,7 +262,7 @@ static int set_tethering(struct connman_technology *technology,
                        continue;
 
                err = driver->set_tethering(technology, ident, passphrase,
-                               bridge, enabled);
+                               bridge, enabled, hidden);
 
                if (result == -EINPROGRESS)
                        continue;
@@ -523,6 +529,11 @@ static void append_properties(DBusMessageIter *iter,
                                        DBUS_TYPE_STRING,
                                        &technology->tethering_passphrase);
 
+       val = technology->tethering_hidden;
+       connman_dbus_dict_append_basic(&dict, "Hidden",
+                                       DBUS_TYPE_BOOLEAN,
+                                       &val);
+
        connman_dbus_dict_close(iter, &dict);
 }
 
@@ -936,6 +947,25 @@ static DBusMessage *set_property(DBusConnection *conn,
                                                &technology->tethering_passphrase);
                        }
                }
+       } else if (g_str_equal(name, "Hidden")) {
+               dbus_bool_t hidden;
+
+               if (type != DBUS_TYPE_BOOLEAN)
+                       return __connman_error_invalid_arguments(msg);
+
+               dbus_message_iter_get_basic(&value, &hidden);
+
+               if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
+                       return __connman_error_not_supported(msg);
+
+               technology->tethering_hidden = hidden;
+               technology_save(technology);
+
+               connman_dbus_property_changed_basic(technology->path,
+                                       CONNMAN_TECHNOLOGY_INTERFACE,
+                                       "Hidden",
+                                       DBUS_TYPE_BOOLEAN,
+                                       &hidden);
        } else if (g_str_equal(name, "Powered")) {
                dbus_bool_t enable;
 
@@ -1204,6 +1234,7 @@ static struct connman_technology *technology_get(enum connman_service_type type)
 
        technology->refcount = 1;
        technology->type = type;
+       technology->tethering_hidden = FALSE;
        technology->path = g_strdup_printf("%s/technology/%s",
                                                        CONNMAN_PATH, str);
        if (type == CONNMAN_SERVICE_TYPE_P2P) {