You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/09/27 00:27:41 UTC

[04/10] git commit: added Network APIs for FirefoxOS

added Network APIs for FirefoxOS


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/c7425809
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/tree/c7425809
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/diff/c7425809

Branch: refs/heads/master
Commit: c7425809161ef27e050abf1c943f9dfde0c8eed0
Parents: cb86c07
Author: hermwong <he...@gmail.com>
Authored: Tue Sep 17 15:39:55 2013 -0700
Committer: hermwong <he...@gmail.com>
Committed: Tue Sep 17 15:39:55 2013 -0700

----------------------------------------------------------------------
 plugin.xml                    | 12 +++++---
 src/firefoxos/NetworkProxy.js | 60 ++++++++++++++++++++++++++++++++++++++
 src/firefoxos/network.js      | 29 ------------------
 3 files changed, 68 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/c7425809/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 8eb5e0b..ec76477 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -20,12 +20,16 @@ xmlns:android="http://schemas.android.com/apk/res/android"
     </js-module>
                 
     <!-- firefoxos --> 
+    <!-- firefoxos -->
     <platform name="firefoxos">
         <config-file target="config.xml" parent="/*">
-            <param name="firefox-package" value="Network" />
-        </config-file>                                      
-        
-        <source-file src="src/firefoxos/network.js" target-dir="src/firefoxos" />
+            <feature name="Network">
+                <param name="firefoxos-package" value="Network" />
+            </feature>
+        </config-file>                                         
+        <js-module src="src/firefoxos/NetworkProxy.js" name="NetworkProxy">
+            <runs />
+        </js-module>
     </platform>
             
     <!-- android -->

http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/c7425809/src/firefoxos/NetworkProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/NetworkProxy.js b/src/firefoxos/NetworkProxy.js
new file mode 100644
index 0000000..831706b
--- /dev/null
+++ b/src/firefoxos/NetworkProxy.js
@@ -0,0 +1,60 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ *
+*/
+                                    
+/*
+  Network API overview: http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/Overview.html
+
+*/
+
+
+var cordova = require('cordova');
+
+module.exports = {                                    
+    
+    var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; 
+    
+    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);
+    }
+};
+
+require("cordova/firefoxos/commandProxy").add("Network", module.exports);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/c7425809/src/firefoxos/network.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/network.js b/src/firefoxos/network.js
deleted file mode 100644
index e4298a0..0000000
--- a/src/firefoxos/network.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- *
-*/
-
-var cordova = require('cordova');
-
-module.exports = {
-    getConnectionInfo: function (win, fail, args) {   
-        var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
-        win(connection.bandwidth);
-    }
-};
\ No newline at end of file