Added API for enabling tethering accepted/tizen/ivi accepted/tizen_ivi_release tizen_ivi_release accepted/tizen/ivi/20140123.222913 accepted/tizen/ivi/20140308.005500 accepted/tizen/ivi/release/20140312.113719 submit/tizen/20140123.215424 submit/tizen/20140307.080756 submit/tizen_ivi_release/20140312.071515
authorOto Ciulis <oto.ciulis@ixonos.com>
Mon, 9 Dec 2013 12:58:40 +0000 (04:58 -0800)
committerOssama Othman <ossama.othman@intel.com>
Thu, 23 Jan 2014 21:52:45 +0000 (13:52 -0800)
Change-Id: Iab08af56c29ec596022df96a1cf4a61c45fd4a70
Signed-off-by: Oto Ciulis <oto.ciulis@ixonos.com>
packaging/settingsd.changes
plugins/connman/connman_manager.cpp
plugins/connman/technology.cpp
plugins/connman/technology.hpp
tests/settings_test.cpp

index 721dc9d..3880866 100644 (file)
@@ -1,3 +1,8 @@
+* Thu Jan 23 2014 Ossama Othman <ossama.othman@intel.com> submit/tizen/20131219.042933@47492bc
+- Added API for enabling tethering
+- Added autoconnect property settings for services
+- Add support for removing WiFi connections.  Fixes TIVI-2326.
+
 * Mon Dec 16 2013 Ossama Othman <ossama.othman@intel.com> accepted/tizen/ivi/20131214.022856@134a223
 - Bump to version 0.4.1.
 - [connman] Fixed connection information clean-up.
index f6d1abc..38788e0 100644 (file)
@@ -252,7 +252,7 @@ ivi::settings::connman_manager::handle_request(
   if (name != nullptr) {
     if (strcmp(name, "get_technologies") == 0)
       get_technologies(response);
-    if (strcmp(name, "get_services") == 0)
+    else if (strcmp(name, "get_services") == 0)
       get_services(response);
     else {
       response.send_error(
index aa61b98..ef093ce 100644 (file)
@@ -34,7 +34,6 @@
 
 #include <cstring>
 
-
 ivi::settings::technology::technology(char const * path,
                                       GDBusConnection * connection,
                                       connman_manager & manager)
@@ -57,6 +56,8 @@ ivi::settings::technology::handle_request(char const * name,
       set_powered(reader, response);
     else if (strcmp(name, "scan") == 0)
       scan(reader, response);
+    else if (strcmp(name, "tethering") == 0)
+      set_tethering(reader, response);
     else {
       response.send_error(
         std::string("Unrecognized connman technology request name: ")
@@ -136,6 +137,103 @@ ivi::settings::technology::set_powered(JsonReader * reader,
 }
 
 void
+ivi::settings::technology::set_tethering(JsonReader * reader,
+                                  response_callback & response)
+{
+  char const * ssid = nullptr;
+  char const * password = nullptr;
+  bool enabled = false, have_password = true, have_ssid = true;
+  constexpr char const identifier[] = "TetheringIdentifier";
+  constexpr char const passphrase[] = "TetheringPassphrase";
+  constexpr char const tethering[] = "Tethering";
+
+  if (json_reader_read_member(reader, "enabled")) {
+    enabled = json_reader_get_boolean_value(reader);
+    json_reader_end_element(reader);
+
+    // In case that we are enabling tethering we need to setup also SSID and passphrase
+    // Otherwise those values are not required
+    if (enabled) {
+      have_ssid = json_reader_read_member(reader, "ssid");
+      if (have_ssid) {
+        ssid = json_reader_get_string_value(reader);
+      }
+      json_reader_end_element(reader);
+
+      have_password = json_reader_read_member(reader, "password");
+      if (have_password) {
+        password = json_reader_get_string_value(reader);
+      }
+      json_reader_end_element(reader);
+    }
+
+    if (have_ssid && have_password) {
+      GError * identifier_error = nullptr, *passphrase_error = nullptr, *enabled_error = nullptr;
+      bool identifier_res = true, passphrase_res = true, enabled_res;
+
+      enabled_res = this->set_property(tethering, g_variant_new_boolean(enabled), response, enabled_error);
+
+      if (enabled && enabled_res) {
+        passphrase_res = this->set_property(passphrase, g_variant_new_string(password), response, passphrase_error);
+        identifier_res = this->set_property(identifier, g_variant_new_string(ssid), response, identifier_error);
+      }
+
+      if (enabled_res && identifier_res && passphrase_res) {
+        response.send_response(
+          [enabled](JsonBuilder * builder)
+          {
+            json_builder_set_member_name(builder, "value");
+            json_builder_add_boolean_value(builder, enabled);
+          });
+      } else {
+        std::string failed_part;
+        GError *error;
+
+        if (!enabled_res) {
+          error = enabled_error;
+          failed_part = std::string("status");
+        } else if (!identifier_res) {
+          error = identifier_error;
+          failed_part = std::string("identifier");
+        } else {
+          error = passphrase_error;
+          failed_part = std::string("passphrase");
+        }
+
+        if (error != nullptr) {
+          unique_ptr<GError> safe_error(error);
+          response.send_error(
+            std::string("Unable to set connman::technology tethering ")
+            + failed_part
+            + std::string(": ")
+            + enabled_error->message);
+        } else {
+          response.send_error(std::string("Malformed connman::technology tethering value ") + failed_part);
+        }
+      }
+    } else if (!have_ssid) {
+      response.send_error("connman::technology tether ssid parameter is null.");
+    } else {
+      response.send_error("connman::technology tether password parameter is null.");
+    }
+  } else {
+    response.send_error("connman::technology tether enabled parameter is null.");
+  }
+}
+
+bool
+ivi::settings::technology::set_property(char const * name,
+                                   GVariant * value,
+                                   response_callback /* response */,
+                                   GError *& error)
+{
+  unique_ptr<GVariant> const ret(
+    connman_.set_property(name, value, error));
+
+  return ret != nullptr;
+}
+
+void
 ivi::settings::technology::scan(JsonReader * reader,
                                 response_callback & response)
 {
index 5008eb5..0c4cb97 100644 (file)
@@ -88,6 +88,11 @@ namespace ivi
       void set_powered(JsonReader * reader,
                        response_callback &response);
 
+
+      /// Set technology to tethering mode
+      void set_tethering(JsonReader * reader,
+                         response_callback &response);
+
       /**
        * Scan for services that implement the technology, e.g. WiFi
        * access points.
@@ -110,6 +115,11 @@ namespace ivi
                               GVariantType const * type,
                               response_callback & response);
 
+      bool set_property(char const * name,
+                        GVariant * value,
+                        response_callback response,
+                        GError *& error);
+
     private:
 
       /// The proxy used to access the connman Technology D-Bus API.
index 7af9804..2c34abc 100644 (file)
@@ -58,6 +58,13 @@ namespace
       //"    \"value\": null"
       //"}";
 
+      // "{"
+      // "    \"type\": \"connman::technology\","
+      // "    \"transactionid\": \"3b5c9ebe-23fa-6b58-3f50-1203d7641441\","
+      // "    \"name\": \"tethering\","
+      // "    \"value\": { \"path\": \"/net/connman/technology/wifi\", \"ssid\" : \"ivi-poc\", \"password\": \"ivipoc-123\", \"enabled\": true }"
+      // "}";
+
       "{"
       "    \"type\": \"connman::service\","
       "    \"transactionid\": \"fnord\","