- Settings will now use the new settings daemon protocols for connman-related apis
- Connman settings supports thew new get_technologies and get_services requests
Change-Id: I0b12321080183695bb5259d1b7a615070ace46a5
Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
<ul data-role="listview" data-inset="true" class="ui-listview ui-listview-inset">
<li data-role="fieldcontain">
<label for="select_timezone" class="select">Time zone:</label>
- <select name="select_timezone" id="select_timezone" data-native-menu="false">
+ <select name="select_timezone" id="select_timezone">
<option value="Pacific/Midway">(GMT-11:00) Midway Island, Samoa</option>
<option value="America/Adak">(GMT-10:00) Hawaii-Aleutian</option>
<option value="Etc/GMT+10">(GMT-10:00) Hawaii</option>
var me = this;
this.setPowerInProgress = true;
setTimeout(function() {
- wsAPI.sendRequest(me.prop.Type, 'enable', powered, function() {
+ wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN_TECHNOLOGY, 'enable', [me.id, powered], function() {
me.setPowerInProgress = false;
success_cb();
}, function(e) {
'Type': this.prop.EncryptionMode,
'Passphrase': passphrase
}]
- wsAPI.sendRequest(WS_REQUEST_TYPE.WIFI, 'connect', info, success_cb, error_cb);
+ wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN_SERVICE, 'connect', info, success_cb, error_cb);
};
ConnmanService.prototype.disconnect = function(success_cb, error_cb) {
if (wsAPI === undefined) return;
- wsAPI.sendRequest(WS_REQUEST_TYPE.WIFI, 'disconnect', this.id, success_cb, error_cb);
+ wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN_SERVICE, 'disconnect', [this.id, null], success_cb, error_cb);
};
function getTechnologies(success_cb, error_cb) {
- wsAPI.sendRequest('connman', 'getTechnologies', null, function(results) {
- success_cb(results);
- }, function(error) {
- console.log('getTechnologies not implemented in settingsd, using pre-defined values');
- var results = [
- ['/net/connman/technology/ethernet',
- {
- 'Name': 'Wired',
- 'Type': 'ethernet',
- }],
- ['/net/connman/technology/wifi',
- {
- 'Name': 'WiFi',
- 'Type': 'wifi',
- }],
- ['/net/connman/technology/bluetooth',
- {
- 'Name': 'Bluetooth',
- 'Type': 'bluetooth',
- }]
- ];
-
- var technologies = [];
- for (var i = 0; i < results.length; i++) {
- var technology = new settings.connman.ConnmanTechnology(results[i][0], results[i][1]);
- technologies.push(technology);
+ if (wsAPI === undefined) return;
+ wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN_MANAGER, 'get_technologies', null, function(results) {
+ if (results.length >= 0 && results[0].length >= 0 && results[0][0][0] === undefined) {
+ error_cb('Cannot parse technologies');
+ return;
}
+ var technologies_list = results[0];
+
+ try {
+ var technologies = [];
+ for (var i = 0; i < technologies_list.length; i++) {
+ if (technologies_list[i][0] === undefined || technologies_list[i][1] === undefined) {
+ console.log('Badly form json message: ' + json_msg);
+ }
+
+ var technology = new settings.connman.ConnmanTechnology(technologies_list[i][0], technologies_list[i][1]);
+ technologies.push(technology);
+ }
+ } catch (e) {
+ error_cb(e);
+ }
success_cb(technologies);
- });
+ }, error_cb);
}
function getServices(success_cb, error_cb) {
- return this.scan(success_cb, error_cb);
-
- wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN, 'getServices', null, function(results) {
+ if (wsAPI === undefined) return;
+ wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN_MANAGER, 'get_services', null, function(results) {
if (results.length >= 0 && results[0].length >= 0 && results[0][0][0] === undefined) {
- error_cb('Cannot parse getServices results');
+ error_cb('Cannot parse get_services results');
return;
}
}, error_cb);
}
- function scan(success_cb, error_cb) {
+ function scan(technology, success_cb, error_cb) {
if (wsAPI === undefined) return;
- wsAPI.sendRequest(WS_REQUEST_TYPE.WIFI, 'scan', null, function(results) {
+ wsAPI.sendRequest(WS_REQUEST_TYPE.CONNMAN_TECHNOLOGY, 'scan', [technology, null], function(results) {
if (results.length >= 0 && results[0].length >= 0 && results[0][0][0] === undefined) {
error_cb('Cannot parse scan results');
return;
var services_list = results[0];
try {
- var results = [];
+ var services = [];
for (var i = 0; i < services_list.length; i++) {
if (services_list[i][0] === undefined || services_list[i][1] === undefined) {
console.log('Badly form json message: ' + json_msg);
}
var service = new settings.connman.ConnmanService(services_list[i][0], services_list[i][1]);
- results.push(service);
+ services.push(service);
}
} catch (e) {
error_cb(e);
}
- success_cb(results);
+ success_cb(services);
}, error_cb);
};
}
function bluetoothEventReceived(event) {
- if (event.type !== WS_EVENT_TYPE.BLUETOOTH && event.type !== WS_EVENT_TYPE.CONNMAN) return;
- if ($.mobile.activePage.attr('id') !== 'page_bluetooth' || $.mobile.activePage.attr('id') !== 'page_bluetooth_detail') {
- return;
- }
+ if (event.type === WS_EVENT_TYPE.BLUETOOTH || event.type === WS_EVENT_TYPE.CONNMAN) {
+ if ($.mobile.activePage.attr('id') !== 'page_bluetooth' || $.mobile.activePage.attr('id') !== 'page_bluetooth_detail') {
+ return;
+ }
- if (event.id === '/net/connman/technology/bluetooth' && event.name === 'PropertyChanged') {
- bluetoothHandlePropertyChanged(event.value);
- } else {
- console.log('Unsupported bluetooth event received: ' + event.name);
+ if (event.type === WS_EVENT_TYPE.CONNMAN && event.id === '/net/connman/technology/bluetooth' && event.name === 'PropertyChanged') {
+ bluetoothHandlePropertyChanged(event.value);
+ } else if (event.type === WS_EVENT_TYPE.SYNC) {
+
+ } else {
+ console.log('Unsupported bluetooth event received: ' + event.name);
+ }
}
}
connmanConstructTechnologyElement(technology);
}
}
+ }, function(e) {
+ showMsg('Error', e);
});
});
$('#button_connman_refresh').on('click', function() {
/* connman only supports wifi scan */
- connmanScan('wifi');
+ if ($('#toggle_connman_wifi').val() === 'on') {
+ connmanScan('/net/connman/technology/wifi');
+ } else {
+ connmanSync(null, function(e) {
+ showMsg('Error', e);
+ });
+ }
});
$('#button_connman_wifi_add').on('click', function() {
return;
}
- if (security !== 'None' && passcode === '') {
+ if (security !== 'none' && passcode === '') {
showMsg('Error', 'Enter passphrase');
return;
}
hideSpinner();
console.log('Go back to Connman page');
$.mobile.changePage('#page_connman');
- }, null);
+ }, function(e) {
+ showMsg('Error', e);
+ });
}, function(e) {
/* error */
hideSpinner();
});
}, function(e) {
hideSpinner();
- showMsg('Error', e);
+ showMsg('Error', e);
});
});
}
function connmanEventReceived(event) {
- if (event.type !== WS_EVENT_TYPE.CONNMAN) return;
- if ($.mobile.activePage.attr('id') !== 'page_connman' && $.mobile.activePage.attr('id') !== 'page_connman_service') {
- return;
- }
+ if (event.type === WS_EVENT_TYPE.CONNMAN) {
+ if ($.mobile.activePage.attr('id') !== 'page_connman' && $.mobile.activePage.attr('id') !== 'page_connman_service') {
+ return;
+ }
- if (event.name === 'ServicesChanged') {
- connmanHandleServicesChanged(event.id, event.value);
- } else if (event.name === 'PropertyChanged') {
- connmanHandlePropertyChanged(event.id, event.value);
- } else {
- console.log('Unsupported event received: ' + event.name);
+ if (event.name === 'ServicesChanged') {
+ connmanHandleServicesChanged(event.id, event.value);
+ } else if (event.name === 'PropertyChanged') {
+ connmanHandlePropertyChanged(event.id, event.value);
+ } else {
+ console.log('Unsupported event received: ' + event.name);
+ }
}
}
if (technology === 'wifi') {
setTimeout(function() {
/* add a 1 sec delay */
- connmanScan(technology);
+ connmanScan(id);
}, 1000);
}
} else {
} else if (property[0] === 'Connected') {
/* unknown service has changed, sync Connman */
console.log('Unknown service connected property changed');
- connmanSync(null, null);
+ connmanSync(null, function(e) {
+ showMsg('Error', e);
+ });
}
}
}
function connmanScan(technology) {
- if (technology !== 'wifi') {
+ if (technology !== '/net/connman/technology/wifi') {
/* Connman only supports wifi scan */
return;
}
showSpinner(false, 'Scanning...');
$('#toggle_connman_wifi').slider('disable');
$('#toggle_connman_wifi').slider('refresh');
- settings.connman.scan(function(services) {
+ settings.connman.scan(technology, function(services) {
hideSpinner();
connmanScanInProgress = false;
$('#toggle_connman_wifi').slider('enable');
if (technology.prop.Powered) {
connmanToggleOn(technology.prop.Type);
if ($('ul#listview_services_available li').length === 0) {
- connmanScan(technology.prop.Type);
+ /* connman only supports wifi scan */
+ if (technology.prop.Type === 'wifi') {
+ connmanScan(technology.id);
+ } else {
+ connmanSync(null, function(e) {
+ showMsg('Error', e);
+ });
+ }
}
} else {
connmanToggleOff(technology.prop.Type);
if (technology.prop.Type === 'wifi') {
setTimeout(function() {
/* add a 1 sec delay */
- connmanScan(technology.prop.Type);
+ connmanScan(technology.id);
}, 1000);
}
console.log('Successfully enabled connman technology ' + technology.prop.Type);
/* success */
connmanSync(function() {
hideSpinner();
- }, null)
+ }, function(e) {
+ showMsg('Error', e);
+ })
}, function(e) {
/* error */
hideSpinner();
*/
function jqId(id) {
- if (id == undefined) return null;
+ if (!id) return null;
/* replace colons and spaces with dash for jquery ids */
return '#' + id.replace(/:| |\//g, '-');
var ERROR_SETTINGSD_DISCONNECTED = 'Settings daemon is not connected';
var WS_REQUEST_TYPE = {
- CONNMAN: "connman::manager",
- WIFI: "wifi",
+ CONNMAN_MANAGER: "connman::manager",
+ CONNMAN_TECHNOLOGY: "connman::technology",
+ CONNMAN_SERVICE: "connman::service",
BLUETOOTH: "bluetooth",
DISPLAY: "display",
SOUND: "sound",
};
var WS_EVENT_TYPE = {
- CONNMAN: "connman::manager",
- WIFI: "wifi",
+ CONNMAN: "connman",
BLUETOOTH: "bluetooth",
DISPLAY: "display",
SOUND: "sound",
}
if (response.value.object_path === '/' || response.value.object_path.indexOf('/net/connman/technology/') >= 0) {
- fireEvent(WS_REQUEST_TYPE.CONNMAN, response.value.object_path, response.value.signal_name, response.value.parameters);
+ fireEvent(WS_EVENT_TYPE.CONNMAN, response.value.object_path, response.value.signal_name, response.value.parameters);
} else {
console.error('Unrecognized event object_path, skipping');
}
+* Wed Nov 27 2013 Jimmy Huang <jimmy.huang@intel.com> ivi_oct_m2@d39bf75
+- Updated connman and bluetooth settings to the new connman protocols in settings-daemon
+
* Fri Nov 15 2013 Jimmy Huang <jimmy.huang@intel.com> submit/tizen_ivi_milestone/20131113.054020@1cf567d
- Refactor WiFi module