Refactored event subscription calls to use websocket 28/12728/1
authorJimmy Huang <jimmy.huang@intel.com>
Thu, 21 Nov 2013 21:48:22 +0000 (13:48 -0800)
committerJimmy Huang <jimmy.huang@intel.com>
Thu, 21 Nov 2013 21:50:59 +0000 (13:50 -0800)
Change-Id: Idb5d68713a489cd67931a2c0c4690b37718a679e
Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
js/api-bluetooth.js
js/api-connman.js
js/main.js
js/panel-bluetooth.js
js/panel-connman.js

index 55ed44e..2b35c73 100644 (file)
@@ -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
index 08b8660..aef05be 100644 (file)
@@ -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
index 3c16653..a229978 100644 (file)
                 /* 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');
                 }
index c2aeb84..dfbfa6d 100644 (file)
@@ -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');
index bf6fa80..384ccc0 100644 (file)
@@ -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('');