incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [5/9] js commit: add online and offline events
Date Wed, 17 Oct 2012 20:38:34 GMT
add online and offline events

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

Branch: refs/heads/master
Commit: deafc223892898b2827cea67eb82d4210e64deaf
Parents: 3fdb1e1
Author: wangmingfeng <mingfengwang01@gmail.com>
Authored: Fri Oct 12 14:34:12 2012 +0800
Committer: wangmingfeng <mingfengwang01@gmail.com>
Committed: Fri Oct 12 14:34:12 2012 +0800

----------------------------------------------------------------------
 lib/windows8/plugin/windows8/NetworkStatusProxy.js |   46 +++++++++------
 1 files changed, 28 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/deafc223/lib/windows8/plugin/windows8/NetworkStatusProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/NetworkStatusProxy.js b/lib/windows8/plugin/windows8/NetworkStatusProxy.js
index 6916d0a..de76784 100644
--- a/lib/windows8/plugin/windows8/NetworkStatusProxy.js
+++ b/lib/windows8/plugin/windows8/NetworkStatusProxy.js
@@ -1,8 +1,7 @@
-
 /*global Windows:true */
 
 var cordova = require('cordova');
-
+var Connection = require('cordova/plugin/Connection');
 
 module.exports = {
 
@@ -15,23 +14,30 @@ module.exports = {
         var networkAuthenticationInfo = winNetConn.NetworkAuthenticationType;
         var networkEncryptionInfo = winNetConn.NetworkEncryptionType;
 
+        var connectionType;
+
         var profile = Windows.Networking.Connectivity.NetworkInformation.getInternetConnectionProfile();
         if(profile) {
-        var conLevel = profile.getNetworkConnectivityLevel();
-
-        switch (conLevel) {
-            case Windows.Networking.Connectivity.NetworkConnectivityLevel.none:
-                break;
-            case Windows.Networking.Connectivity.NetworkConnectivityLevel.localAccess:
-                break;
-            case Windows.Networking.Connectivity.NetworkConnectivityLevel.internetAccess:
-                break;
-            case Windows.Networking.Connectivity.NetworkConnectivityLevel.constrainedInternetAccess:
-                break;
+            var conLevel = profile.getNetworkConnectivityLevel();
+            var interfaceType = profile.networkAdapter.ianaInterfaceType;
+
+            if (conLevel == Windows.Networking.Connectivity.NetworkConnectivityLevel.none)
{
+                connectionType = Connection.NONE;
+            }
+            else {
+                switch (interfaceType) {
+                    case 71:
+                        connectionType = Connection.WIFI;
+                        break;
+                    case 6:
+                        connectionType = Connection.ETHERNET;
+                        break;
+                    default:
+                        connectionType = Connection.UNKNOWN;
+                        break;
+                }
+            }
         }
-    }
-
-
         // FYI
         //Connection.UNKNOWN  'Unknown connection';
         //Connection.ETHERNET 'Ethernet connection';
@@ -41,8 +47,12 @@ module.exports = {
         //Connection.CELL_4G  'Cell 4G connection';
         //Connection.NONE     'No network connection';
 
-        setTimeout(function(){
-            win("wifi");
+        setTimeout(function () {
+            if (connectionType) {
+                win(connectionType);
+            } else {
+                win(Connection.NONE);
+            }
         },0);
     }
 


Mime
View raw message