You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/05/07 17:13:50 UTC

[03/50] [abbrv] webworks commit: Add NetworkStatus plugin

Add NetworkStatus plugin

Reviewed by Gord Tanner <gt...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/cd754d0c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/cd754d0c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/cd754d0c

Branch: refs/heads/future
Commit: cd754d0c6770ff568eca53c3413716e81a601731
Parents: 187db1a
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Mar 19 13:44:19 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 10:13:28 2013 -0400

----------------------------------------------------------------------
 .../project/plugins/NetworkStatus/index.js         |   58 +++++++++++++++
 blackberry10/javascript/cordova.blackberry10.js    |   18 +----
 2 files changed, 60 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/cd754d0c/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
new file mode 100644
index 0000000..f96efe9
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/NetworkStatus/index.js
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//map from BB10 to cordova connection types:
+//https://github.com/apache/cordova-js/blob/master/lib/common/plugin/Connection.js
+function mapConnectionType(con) {
+    switch (con.type) {
+    case 'wired':
+        return 'ethernet';
+    case 'wifi':
+        return 'wifi';
+    case 'none':
+        return 'none';
+    case 'cellular':
+        switch (con.technology) {
+        case 'edge':
+        case 'gsm':
+            return '2g';
+        case 'evdo':
+            return '3g';
+        case 'umts':
+            return '3g';
+        case 'lte':
+            return '4g';
+        }
+        return "cellular";
+    }
+    return 'unknown';
+}
+
+function currentConnectionType() {
+    try {
+        //possible for webplatform to throw pps exception
+        return mapConnectionType(qnx.webplatform.device.activeConnection || { type : 'none' });
+    } 
+    catch (e) {
+        return 'unknown';
+    }
+}
+
+module.exports = {
+    getConnectionInfo: function (success, fail, args, env) {
+        success(currentConnectionType());
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/cd754d0c/blackberry10/javascript/cordova.blackberry10.js
----------------------------------------------------------------------
diff --git a/blackberry10/javascript/cordova.blackberry10.js b/blackberry10/javascript/cordova.blackberry10.js
index 5479211..2c169c5 100644
--- a/blackberry10/javascript/cordova.blackberry10.js
+++ b/blackberry10/javascript/cordova.blackberry10.js
@@ -1,8 +1,8 @@
 // Platform: blackberry10
 
-// commit e14d644ae4300282e837c6621522bd3895f556e5
+// commit 81a30b465c3f84cc020dda5a7ede6e83a8e44385
 
-// File generated at :: Mon Mar 18 2013 21:49:25 GMT-0400 (EDT)
+// File generated at :: Tue Mar 19 2013 13:22:52 GMT-0400 (EDT)
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one
@@ -4784,7 +4784,6 @@ define("cordova/plugin/blackberry10/manager", function(require, exports, module)
 
 var cordova = require('cordova'),
     plugins = {
-        'NetworkStatus' : require('cordova/plugin/blackberry10/network'),
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Battery' : require('cordova/plugin/blackberry10/battery'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
@@ -4994,19 +4993,6 @@ module.exports = {
 
 });
 
-// file: lib/blackberry10/plugin/blackberry10/network.js
-define("cordova/plugin/blackberry10/network", function(require, exports, module) {
-
-var cordova = require('cordova');
-
-module.exports = {
-    getConnectionInfo: function (args, win, fail) {
-        return { "status": cordova.callbackStatus.OK, "message": blackberry.connection.type};
-    }
-};
-
-});
-
 // file: lib/blackberry10/plugin/blackberry10/notification.js
 define("cordova/plugin/blackberry10/notification", function(require, exports, module) {