Added support for autoconnect for connman services 59/16059/1 accepted/tizen/ivi/20140205.225825 submit/tizen/20140205.212746
authorJimmy Huang <jimmy.huang@intel.com>
Wed, 5 Feb 2014 21:10:29 +0000 (13:10 -0800)
committerJimmy Huang <jimmy.huang@intel.com>
Wed, 5 Feb 2014 21:12:09 +0000 (13:12 -0800)
Change-Id: I31cd9494cd10d9750ee24a6c7d55eb47623c312c
Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
js/api-connman.js
js/panel-connman.js
js/websocket.js
packaging/Settings.changes

index c991f25..8236d2a 100644 (file)
@@ -91,6 +91,17 @@ settings.connman = (function() {
         wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN_SERVICE, 'disconnect', [this.id, null], success_cb, error_cb);
     };
 
+    ConnmanService.prototype.setAutoConnect = function(autoconnect, success_cb, error_cb) {
+        if (wsAPI === undefined) return;
+
+        var value = {
+            'path': this.id,
+            'enable': autoconnect
+        };
+
+        wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN_SERVICE, 'autoconnect', value, success_cb, error_cb);
+    };
+
     function getTechnologies(success_cb, error_cb) {
         if (wsAPI === undefined) return;
         wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN_MANAGER, 'get_technologies', null, function(results) {
index 3277b58..76f840c 100644 (file)
@@ -599,10 +599,45 @@ function connmanConstructServicePanel(service) {
         }
     }
     html += '<li id="connman_service_connected"><h2>Connected: ' + status_connected + '</h2></li>';
-    html += '<li id="connman_service_autoconnect"><h2>AutoConnect: ' + service.prop.AutoConnect + '</h2></li>';
     html += '</ul>';
     $('#page_connman_service_content').append(html).trigger('create');
     $('#listview_connman_services').listview('refresh');
+
+    var html = '<ul data-role="listview" data-inset="true" class="ui-listview ui-listview-inset">';
+    html += '<li data-role="fieldcontain">';
+    html += '<label for="toggle_autoconnect" class="ui-slider">Auto Connect</label>';
+    html += '<select data-role="slider" name="toggle_autoconnect" ';
+    html += 'id="toggle_autoconnect" class="ui-slider-switch">';
+    html += '<option value="off">Off</option>';
+    html += '<option value="on">On</option>';
+    html += '</select></li></ul>';
+    $('#page_connman_service_content').append(html).trigger('create');
+
+    if (service.prop.AutoConnect) {
+        $('#toggle_autoconnect').val('on').slider('refresh');
+    } else {
+        $('#toggle_autoconnect').val('off').slider('refresh');
+    }
+
+    $('#toggle_autoconnect').change(function() {
+        if ($('#toggle_autoconnect').val() === 'on') {
+            service.setAutoConnect(true, function() {
+                /* success */
+                console.log('Successfully enabled autoconnect for ' + service.prop.Name);
+            }, function(e) {
+                /* error */
+                console.log('Cannot enable autoconnect: ' + e);
+            });
+        } else {
+            service.setAutoConnect(false, function() {
+                /* success */
+                console.log('Successfully disabled autoconnect for ' + service.prop.Name);
+            }, function(e) {
+                /* error */
+                console.log('Cannot disable autoconnect: ' + e);
+            });
+        }
+    });
 }
 
 function connmanUpdateServicePanel(service) {
index 4229a2d..ec54a7b 100644 (file)
@@ -513,6 +513,9 @@ var wsAPI = (function() {
                                     fireEvent(WS_EVENT_TYPE.CONNMAN, msg.value[0], 'PropertyChanged', ["Connected", false]);
                                 }, 2000);
                                 return;
+                            } else if (msg.name === 'autoconnect') {
+                                call.successCB();
+                                return;
                             } else {
                                 if (call.errorCB) {
                                     call.errorCB('Unsupported request: ' + msg.name + ', ' + msg.value);
index 75f1cc5..7f192e4 100644 (file)
@@ -1,3 +1,6 @@
+* Wed Feb 05 2014 Jimmy Huang <jimmy.huang@intel.com> accepted/tizen/ivi/20140110.224142@9df45ae
+- Added support for autoconnect for connman services
+
 * Wed Feb 05 2014 Jimmy Huang <jimmy.huang@intel.com> accepted/tizen/ivi/20140110.224142@b921b34
 - Fixes TIVI-2499