You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by he...@apache.org on 2014/04/25 22:23:58 UTC

[1/5] git commit: there was an error in the object definition

Repository: cordova-plugin-network-information
Updated Branches:
  refs/heads/master e0d3ae00b -> 7b4c96ec7


there was an error in the object definition


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/commit/37047348
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/tree/37047348
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/diff/37047348

Branch: refs/heads/master
Commit: 37047348db396c3f1176d860436a03e400b7a659
Parents: cd67d7a
Author: Piotr Zalewa <zalun@ubuntu.(none)>
Authored: Sat Mar 15 18:44:57 2014 -0700
Committer: Piotr Zalewa <zalun@ubuntu.(none)>
Committed: Sat Mar 15 18:44:57 2014 -0700

----------------------------------------------------------------------
 src/firefoxos/NetworkProxy.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/37047348/src/firefoxos/NetworkProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/NetworkProxy.js b/src/firefoxos/NetworkProxy.js
index 831706b..ec315d2 100644
--- a/src/firefoxos/NetworkProxy.js
+++ b/src/firefoxos/NetworkProxy.js
@@ -26,10 +26,10 @@
 
 
 var cordova = require('cordova');
+var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; 
 
 module.exports = {                                    
     
-    var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; 
     
     getConnectionInfo: function (win, fail, args) {      
         /*
@@ -57,4 +57,4 @@ module.exports = {
     }
 };
 
-require("cordova/firefoxos/commandProxy").add("Network", module.exports);
\ No newline at end of file
+require("cordova/firefoxos/commandProxy").add("Network", module.exports);


[5/5] git commit: merged apache/dev

Posted by he...@apache.org.
merged apache/dev


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/commit/7b4c96ec
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/tree/7b4c96ec
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/diff/7b4c96ec

Branch: refs/heads/master
Commit: 7b4c96ec721c59f8de3dc6a13a6d8bb70bf71993
Parents: 1fa3ae6 e0d3ae0
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Wed Apr 23 11:08:24 2014 -0400
Committer: Piotr Zalewa <pi...@zalewa.info>
Committed: Wed Apr 23 11:08:24 2014 -0400

----------------------------------------------------------------------
 RELEASENOTES.md                  |  7 +++++++
 plugin.xml                       | 20 +++++++++++++++++++-
 src/ios/CDVConnection.m          | 10 ++++++++--
 src/ios/CDVReachability.m        |  2 +-
 src/tizen/NetworkProxy.js        | 21 +++++++++++++++++++++
 src/windows8/NetworkInfoProxy.js |  2 +-
 6 files changed, 57 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/7b4c96ec/plugin.xml
----------------------------------------------------------------------


[2/5] git commit: Merge pull request #1 from zalun/fix_firefoxos

Posted by he...@apache.org.
Merge pull request #1 from zalun/fix_firefoxos

there was an error in the object definition

Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/commit/f973965a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/tree/f973965a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/diff/f973965a

Branch: refs/heads/master
Commit: f973965a03f3e59ebb3ec93aee6f132c2f271d00
Parents: d2cd2fb 3704734
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Mon Mar 17 21:06:31 2014 +0000
Committer: Piotr Zalewa <pi...@zalewa.info>
Committed: Mon Mar 17 21:06:31 2014 +0000

----------------------------------------------------------------------
 src/firefoxos/NetworkProxy.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[4/5] git commit: Merge pull request #3 from rodms10/dev

Posted by he...@apache.org.
Merge pull request #3 from rodms10/dev

Initial version of firefox os network information plugin

Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/commit/1fa3ae6e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/tree/1fa3ae6e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/diff/1fa3ae6e

Branch: refs/heads/master
Commit: 1fa3ae6e47ab26c11e69721807a8ea42d8723f81
Parents: f973965 4400503
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Mon Apr 14 12:36:32 2014 +0200
Committer: Piotr Zalewa <pi...@zalewa.info>
Committed: Mon Apr 14 12:36:32 2014 +0200

----------------------------------------------------------------------
 doc/index.md                  |  6 +++
 plugin.xml                    |  5 --
 src/firefoxos/NetworkProxy.js | 97 +++++++++++++++++++++++++-------------
 3 files changed, 69 insertions(+), 39 deletions(-)
----------------------------------------------------------------------



[3/5] git commit: Initial version of firefox os network information plugin

Posted by he...@apache.org.
Initial version of firefox os network information plugin


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/commit/44005034
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/tree/44005034
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/diff/44005034

Branch: refs/heads/master
Commit: 44005034004559bb798f402b4ef177f5f70167d8
Parents: f973965
Author: Rodrigo Silveira <ro...@outlook.com>
Authored: Mon Apr 7 11:32:28 2014 -0700
Committer: Rodrigo Silveira <ro...@outlook.com>
Committed: Wed Apr 9 15:16:23 2014 -0700

----------------------------------------------------------------------
 doc/index.md                  |  6 +++
 plugin.xml                    |  5 --
 src/firefoxos/NetworkProxy.js | 97 +++++++++++++++++++++++++-------------
 3 files changed, 69 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/44005034/doc/index.md
----------------------------------------------------------------------
diff --git a/doc/index.md b/doc/index.md
index d283483..8c48ffe 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -37,6 +37,7 @@ wifi connection, and whether the device has an internet connection.
 - Windows Phone 7 and 8
 - Tizen
 - Windows 8
+- Firefox OS
 
 # Connection
 
@@ -108,6 +109,11 @@ eventually be removed.
 - Tizen can only detect a WiFi or cellular connection.
     - `navigator.connection.type` is set to `Connection.CELL_2G` for all cellular data.
 
+### Firefox OS Quirks
+
+- Firefox OS can't detect the type of cellular network connection.
+    - `navigator.connection.type` is set to `Connection.CELL` for all cellular data.
+
 # Network-related Events
 
 ## offline

http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/44005034/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 5b3d869..1baf979 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -23,11 +23,6 @@ xmlns:android="http://schemas.android.com/apk/res/android"
 
     <!-- firefoxos -->
     <platform name="firefoxos">
-        <config-file target="config.xml" parent="/*">
-            <feature name="Network">
-                <param name="firefoxos-package" value="Network" />
-            </feature>
-        </config-file>
         <js-module src="src/firefoxos/NetworkProxy.js" name="NetworkProxy">
             <runs />
         </js-module>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/44005034/src/firefoxos/NetworkProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/NetworkProxy.js b/src/firefoxos/NetworkProxy.js
index ec315d2..f4e8208 100644
--- a/src/firefoxos/NetworkProxy.js
+++ b/src/firefoxos/NetworkProxy.js
@@ -17,44 +17,73 @@
  * specific language governing permissions and limitations
  * under the License.
  *
-*/
-                                    
-/*
-  Network API overview: http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/Overview.html
+ */
 
+/*
+  Network API overview: http://www.w3.org/TR/netinfo-api/
+  and http://w3c.github.io/netinfo/
 */
 
+var cordova = require('cordova'),
+    Connection = require('./Connection'),
+    modulemapper = require('cordova/modulemapper');
+
+var origConnection = modulemapper.getOriginalSymbol(window, 'navigator.connection');
+
+module.exports = {
 
-var cordova = require('cordova');
-var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; 
-
-module.exports = {                                    
-    
-    
-    getConnectionInfo: function (win, fail, args) {      
-        /*
-        bandwidth of type double, readonly
-        The user agent must set the value of the bandwidth attribute to:
-            0 if the user is currently offline;
-            Infinity if the bandwidth is unknown;
-            an estimation of the current bandwidth in MB/s (Megabytes per seconds) available for communication with the browsing context active document's domain.
-        */
-        win(connection.bandwidth);
-    },  
-    
-    isMetered: function (win, fail, args) {  
-        /*
-        readonly attribute boolean metered
-            A connection is metered when the user's connection is subject to a limitation from his Internet Service Provider strong enough to request web applications to be careful with the bandwidth usage.
-
-            What is a metered connection is voluntarily left to the user agent to judge. It would not be possible to give an exhaustive list of limitations considered strong enough to flag the connection as metered and even if doable, some limitations can be considered strong or weak depending on the context.
-            Examples of metered connections are mobile connections with a small bandwidth quota or connections with a pay-per use plan.
-            The user agent MUST set the value of the metered attribute to true if the connection with the browsing context active document's domain is metered and false otherwise. If the implementation is not able to know the status of the connection or if the user is offline, the value MUST be set to false.
-
-            If unable to know if a connection is metered, a user agent could ask the user about the status of his current connection.
-        */
-        win(connection.metered);
+  getConnectionInfo: function(successCallback, errorCallback) {
+    var connection = origConnection || navigator.mozConnection,
+      connectionType = Connection.UNKNOWN,
+      bandwidth = connection.bandwidth,
+      metered = connection.metered,
+      type = connection.type;
+
+    if (type != undefined) {
+      // For more information see:
+      // https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API
+
+      switch(type) {
+        case "cellular":
+          connectionType = Connection.CELL;
+          break;
+        case "ethernet":
+          connectionType = Connection.ETHERNET;
+          break;
+        case "wifi":
+          connectionType = Connection.WIFI;
+          break;
+        case "none":
+          connectionType = Connection.NONE;
+          break;
+      }
+    } else if (bandwidth != undefined && metered != undefined) {
+      /*
+      bandwidth of type double, readonly
+      The user agent must set the value of the bandwidth attribute to:
+      0 if the user is currently offline;
+      Infinity if the bandwidth is unknown;
+      an estimation of the current bandwidth in MB/s (Megabytes per seconds)
+      available for communication with the browsing context active document's
+      domain.
+
+      For more information see:
+      https://developer.mozilla.org/en-US/docs/Web/API/Connection
+      */
+
+      if (bandwidth === 0) {
+        connectionType = Connection.NONE;
+      } else if (metered && isFinite(bandwidth)) {
+        connectionType = Connection.CELL;
+      } else if (!metered && isFinite(bandwidth)) {
+        connectionType = Connection.WIFI;
+      }
     }
+
+    setTimeout(function() {
+      successCallback(connectionType);
+    }, 0);
+  }
 };
 
-require("cordova/firefoxos/commandProxy").add("Network", module.exports);
+require("cordova/firefoxos/commandProxy").add("NetworkStatus", module.exports);
\ No newline at end of file