Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 21F0ED413 for ; Wed, 17 Oct 2012 20:38:35 +0000 (UTC) Received: (qmail 64566 invoked by uid 500); 17 Oct 2012 20:38:35 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 64468 invoked by uid 500); 17 Oct 2012 20:38:34 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 64419 invoked by uid 99); 17 Oct 2012 20:38:34 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Oct 2012 20:38:34 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8328C93B7; Wed, 17 Oct 2012 20:38:34 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: purplecabbage@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [5/9] js commit: add online and offline events Message-Id: <20121017203834.8328C93B7@tyr.zones.apache.org> Date: Wed, 17 Oct 2012 20:38:34 +0000 (UTC) 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 Authored: Fri Oct 12 14:34:12 2012 +0800 Committer: wangmingfeng 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); }