From c1cbb2cddc3421b3e19db84664f39da6560a6cb5 Mon Sep 17 00:00:00 2001 From: Jimmy Huang Date: Thu, 21 Nov 2013 13:48:22 -0800 Subject: [PATCH] Refactored event subscription calls to use websocket Change-Id: Idb5d68713a489cd67931a2c0c4690b37718a679e Signed-off-by: Jimmy Huang --- js/api-bluetooth.js | 10 ---------- js/api-connman.js | 11 ----------- js/main.js | 4 ++-- js/panel-bluetooth.js | 2 +- js/panel-connman.js | 2 +- 5 files changed, 4 insertions(+), 25 deletions(-) diff --git a/js/api-bluetooth.js b/js/api-bluetooth.js index 55ed44e..2b35c73 100644 --- a/js/api-bluetooth.js +++ b/js/api-bluetooth.js @@ -123,14 +123,6 @@ settings.bluetooth = (function() { }); } - function subscribeEvents(event_callback) { - wsAPI.subscribeEvents(event_callback); - } - - function unsubscribeEvents(event_callback) { - wsAPI.unsubscribeEvents(event_callback); - } - function getDefaultAdapter() { try { if (tizen.bluetooth.getDefaultAdapter() == null) { @@ -148,8 +140,6 @@ settings.bluetooth = (function() { return { BluetoothAdapter: BluetoothAdapter, BluetoothDevice: BluetoothDevice, - subscribeEvents: subscribeEvents, - unsubscribeEvents: unsubscribeEvents, getDefaultAdapter: getDefaultAdapter }; })(); \ No newline at end of file diff --git a/js/api-connman.js b/js/api-connman.js index 08b8660..aef05be 100644 --- a/js/api-connman.js +++ b/js/api-connman.js @@ -87,15 +87,6 @@ settings.connman = (function() { wsAPI.sendRequest(WS_REQUEST_TYPE.WIFI, 'disconnect', this.id, success_cb, error_cb); }; - /* global functions */ - function subscribeEvents(callback) { - wsAPI.subscribeEvents(callback); - } - - function unsubscribeEvents(callback) { - wsAPI.unsubscribeEvents(callback); - } - function getTechnologies(success_cb, error_cb) { wsAPI.sendRequest('connman', 'getTechnologies', null, function(results) { success_cb(results); @@ -187,8 +178,6 @@ settings.connman = (function() { return { ConnmanTechnology: ConnmanTechnology, ConnmanService: ConnmanService, - subscribeEvents: subscribeEvents, - unsubscribeEvents: unsubscribeEvents, getTechnologies: getTechnologies, getServices: getServices, scan: scan diff --git a/js/main.js b/js/main.js index 3c16653..a229978 100644 --- a/js/main.js +++ b/js/main.js @@ -37,10 +37,10 @@ /* TODO: unsubscribe events if neccessary */ if (data.prevPage.attr('id') === 'page_connman') { console.log('Connman settings exited'); - settings.connman.unsubscribeEvents(connmanEventReceived); + wsAPI.unsubscribeEvents(connmanEventReceived); } else if (data.prevPage.attr('id') === 'page_bluetooth') { console.log('Bluetooth settings exited'); - settings.bluetooth.unsubscribeEvents(bluetoothEventReceived); + wsAPI.unsubscribeEvents(bluetoothEventReceived); } else if (data.prevPage.attr('id') === 'page_datetime') { console.log('Date and Time settings exited'); } diff --git a/js/panel-bluetooth.js b/js/panel-bluetooth.js index c2aeb84..dfbfa6d 100644 --- a/js/panel-bluetooth.js +++ b/js/panel-bluetooth.js @@ -13,7 +13,7 @@ function bluetoothPanelInit() { $('#page_bluetooth').on('pageshow', function(event, data) { if (data.prevPage.attr('id') === 'page_bluetooth_detail') return; - settings.bluetooth.subscribeEvents(bluetoothEventReceived); + wsAPI.subscribeEvents(bluetoothEventReceived); var adapter = settings.bluetooth.getDefaultAdapter(); if (adapter === null) { showMsg('Error', 'Bluetooth adapter not found'); diff --git a/js/panel-connman.js b/js/panel-connman.js index bf6fa80..384ccc0 100644 --- a/js/panel-connman.js +++ b/js/panel-connman.js @@ -14,7 +14,7 @@ function connmanPanelInit() { $('#page_connman').on('pageshow', function(event, data) { if (data.prevPage.attr('id') === 'page_connman_service') return; - settings.connman.subscribeEvents(connmanEventReceived); + wsAPI.subscribeEvents(connmanEventReceived); console.log('Get all the available technologies'); $('#connman_technologies').html(''); -- 2.7.4