summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama.othman@intel.com>2014-03-24 10:49:10 -0700
committerOssama Othman <ossama.othman@intel.com>2014-03-24 15:57:35 -0700
commit2948e5a54d469e19fd1e245688572b336647191b (patch)
tree5d61dc38cf0ccc2c5d9184c5d1c5e4367b4ca30d
parent6a4055720591fe0077bc33574c43b817e94c20e7 (diff)
downloadsettings-daemon-2948e5a54d469e19fd1e245688572b336647191b.tar.gz
settings-daemon-2948e5a54d469e19fd1e245688572b336647191b.tar.bz2
settings-daemon-2948e5a54d469e19fd1e245688572b336647191b.zip
This change fixes tethering configuration. Tethering identifer and passphrase existence are no longer enforced by settingsd. It is up to the calling application to handle connman tethering errors relayed by settingsd. A memory leak was also fixed. Change-Id: I18f417a5286528a7254c15e50823613c7ac76b2b Signed-off-by: Ossama Othman <ossama.othman@intel.com>
-rw-r--r--configure.ac2
-rw-r--r--packaging/settingsd.changes3
-rw-r--r--packaging/settingsd.spec2
-rw-r--r--plugins/connman/technology.cpp175
4 files changed, 108 insertions, 74 deletions
diff --git a/configure.ac b/configure.ac
index 2bc6ecd..83221e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
])
-AC_INIT([settingsd], [0.4.1], [ossama.othman@intel.com])
+AC_INIT([settingsd], [0.4.2], [ossama.othman@intel.com])
AM_INIT_AUTOMAKE([1.11.1 foreign -Wall -Werror -Wno-portability silent-rules])
LT_INIT([disable-static dlopen])
diff --git a/packaging/settingsd.changes b/packaging/settingsd.changes
index 3880866..4effcd7 100644
--- a/packaging/settingsd.changes
+++ b/packaging/settingsd.changes
@@ -1,3 +1,6 @@
+* Mon Mar 24 2014 Ossama Othman <ossama.othman@intel.com> accepted/tizen/ivi/release/20140312.113719@c944784
+- [TIVI-2848] Fix tethering configuration.
+
* 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
diff --git a/packaging/settingsd.spec b/packaging/settingsd.spec
index b245158..babd1ce 100644
--- a/packaging/settingsd.spec
+++ b/packaging/settingsd.spec
@@ -1,6 +1,6 @@
Name: settingsd
Summary: Tizen IVI Settings Daemon
-Version: 0.4.1
+Version: 0.4.2
Release: 1
Group: Application Framework/Settings
License: LGPL-2.1
diff --git a/plugins/connman/technology.cpp b/plugins/connman/technology.cpp
index ef093ce..13711ba 100644
--- a/plugins/connman/technology.cpp
+++ b/plugins/connman/technology.cpp
@@ -138,86 +138,117 @@ ivi::settings::technology::set_powered(JsonReader * reader,
void
ivi::settings::technology::set_tethering(JsonReader * reader,
- response_callback & response)
+ 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")) {
+ bool const have_enabled = json_reader_read_member(reader, "enabled");
+ bool enabled = false;
+ if (have_enabled) {
enabled = json_reader_get_boolean_value(reader);
json_reader_end_element(reader);
+ } else {
+ response.send_error(
+ "connman::technology tether \"enabled\" parameter is null.");
+ // We have to call json_reader_end_element() before we return
+ json_reader_end_element(reader);
+ return;
+ }
+
+ unique_ptr<GError> identifier_error;
+ unique_ptr<GError> passphrase_error;
+ bool identifier_res = true; // Identifier not always needed.
+ bool passphrase_res = true; // Passphrase not always needed.
+
+ // Check if we have a tethering identifier and passphrase if we are
+ // enabling tethering.
+ if (enabled) {
+ // --------------------
+ // Tethering identifier
+ // --------------------
+ char const * ssid = nullptr;
+ if (json_reader_read_member(reader, "ssid")) {
+ ssid = json_reader_get_string_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 (ssid != nullptr) {
+ constexpr char const identifier[] = "TetheringIdentifier";
+ GError * error = nullptr;
+ identifier_res = this->set_property(identifier,
+ g_variant_new_string(ssid),
+ response,
+ error);
+ identifier_error.reset(error);
}
- 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.");
+ // --------------------
+ // Tethering passphrase
+ // --------------------
+ char const * password = nullptr;
+ if (json_reader_read_member(reader, "password")) {
+ password = json_reader_get_string_value(reader);
+ }
+ json_reader_end_element(reader);
+
+ if (password != nullptr) {
+ constexpr char const passphrase[] = "TetheringPassphrase";
+ GError * error = nullptr;
+ passphrase_res = this->set_property(passphrase,
+ g_variant_new_string(password),
+ response,
+ error);
+ passphrase_error.reset(error);
}
+ }
+
+ // ----------------
+ // Tethering status
+ // ----------------
+ // Set "enabled" after passphrase and SSID have been set.
+ // Otherwise Connman may issue an invalid argument error.
+ constexpr char const tethering[] = "Tethering";
+ bool enabled_res = false;
+ GError * error = nullptr;
+ enabled_res = this->set_property(tethering,
+ g_variant_new_boolean(enabled),
+ response,
+ error);
+ unique_ptr<GError> enabled_error(error);
+
+ // ----------------------------
+ // Send final response or 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 {
- response.send_error("connman::technology tether enabled parameter is null.");
+ char const * failed_part = nullptr;
+ error = nullptr;
+
+ if (!enabled_res) {
+ error = enabled_error.get();
+ failed_part = "status";
+ } else if (!identifier_res) {
+ error = identifier_error.get();
+ failed_part = "identifier";
+ } else if (!passphrase_res) {
+ error = passphrase_error.get();
+ failed_part = "passphrase";
+ }
+
+ if (error != nullptr) {
+ response.send_error(
+ std::string("Unable to set connman::technology tethering ")
+ + failed_part
+ + std::string(": ")
+ + error->message);
+ } else {
+ response.send_error(
+ std::string("Malformed connman::technology tethering ")
+ + failed_part);
+ }
}
}