You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2013/07/09 01:03:48 UTC

git commit: [CB-4123] remove dupe code

Updated Branches:
  refs/heads/master f4d804c71 -> 4c73c90b4


[CB-4123] remove dupe code


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

Branch: refs/heads/master
Commit: 4c73c90b4b5cf0d8c88695f9218b640c17d4593d
Parents: f4d804c
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Jul 8 16:03:14 2013 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Jul 8 16:03:14 2013 -0700

----------------------------------------------------------------------
 plugin.xml               |   4 +-
 src/wp/NetworkStatus.cs  | 129 ++++++++++++++++++++++++++++++++++++++++++
 src/wp7/NetworkStatus.cs | 129 ------------------------------------------
 src/wp8/NetworkStatus.cs | 129 ------------------------------------------
 4 files changed, 131 insertions(+), 260 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/4c73c90b/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 65421b9..c880552 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -57,7 +57,7 @@
             <Capability Name="ID_CAP_NETWORKING" />
         </config-file>
 
-        <source-file src="src/wp7/NetworkStatus.cs" />
+        <source-file src="src/wp/NetworkStatus.cs" />
     </platform>
 
     <!-- wp8 -->
@@ -72,7 +72,7 @@
             <Capability Name="ID_CAP_NETWORKING" />
         </config-file>
 
-        <source-file src="src/wp8/NetworkStatus.cs" />
+        <source-file src="src/wp/NetworkStatus.cs" />
     </platform>
 
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/4c73c90b/src/wp/NetworkStatus.cs
----------------------------------------------------------------------
diff --git a/src/wp/NetworkStatus.cs b/src/wp/NetworkStatus.cs
new file mode 100644
index 0000000..12eb061
--- /dev/null
+++ b/src/wp/NetworkStatus.cs
@@ -0,0 +1,129 @@
+/*  
+	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.
+*/
+
+using System;
+using System.Diagnostics;
+using System.Net;
+using System.Net.NetworkInformation;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using Microsoft.Phone.Net.NetworkInformation;
+
+namespace WPCordovaClassLib.Cordova.Commands
+{
+
+    // http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation(v=VS.92).aspx
+    // http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation.devicenetworkinformation(v=VS.92).aspx
+
+    public class NetworkStatus : BaseCommand
+    {
+        const string UNKNOWN = "unknown";
+        const string ETHERNET = "ethernet";
+        const string WIFI = "wifi";
+        const string CELL_2G = "2g";
+        const string CELL_3G = "3g";
+        const string CELL_4G = "4g";
+        const string NONE = "none";
+        const string CELL = "cellular";
+
+        private bool HasCallback = false;
+
+        public NetworkStatus()
+        {
+            DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler<NetworkNotificationEventArgs>(ChangeDetected);
+        }
+
+        public override void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e)
+        {
+            this.getConnectionInfo("");
+        }
+
+        public void getConnectionInfo(string empty)
+        {
+            HasCallback = true;
+            updateConnectionType(checkConnectionType());
+        }
+
+        private string checkConnectionType()
+        {
+            if (DeviceNetworkInformation.IsNetworkAvailable)
+            {
+                if (DeviceNetworkInformation.IsWiFiEnabled)
+                {
+                    return WIFI;
+                }
+                else
+                {
+                    return DeviceNetworkInformation.IsCellularDataEnabled ? CELL : UNKNOWN;
+                }
+            }
+            return NONE;
+        }
+
+        private string checkConnectionType(NetworkInterfaceSubType type)
+        {
+            switch (type)
+            {
+                case NetworkInterfaceSubType.Cellular_1XRTT: //cell
+                case NetworkInterfaceSubType.Cellular_GPRS: //cell
+                    return CELL;
+                case NetworkInterfaceSubType.Cellular_EDGE: //2
+                    return CELL_2G;
+                case NetworkInterfaceSubType.Cellular_3G:
+                case NetworkInterfaceSubType.Cellular_EVDO: //3
+                case NetworkInterfaceSubType.Cellular_EVDV: //3 
+                case NetworkInterfaceSubType.Cellular_HSPA: //3
+                    return CELL_3G;
+                case NetworkInterfaceSubType.WiFi:
+                    return WIFI;
+                case NetworkInterfaceSubType.Unknown:
+                case NetworkInterfaceSubType.Desktop_PassThru:
+                default:
+                    return UNKNOWN;
+            }
+        }
+
+        void ChangeDetected(object sender, NetworkNotificationEventArgs e)
+        {
+            switch (e.NotificationType)
+            {
+                case NetworkNotificationType.InterfaceConnected:
+                    updateConnectionType(checkConnectionType(e.NetworkInterface.InterfaceSubtype));
+                    break;
+                case NetworkNotificationType.InterfaceDisconnected:
+                    updateConnectionType(NONE);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        private void updateConnectionType(string type)
+        {
+            // This should also implicitly fire offline/online events as that is handled on the JS side
+            if (this.HasCallback)
+            {
+                PluginResult result = new PluginResult(PluginResult.Status.OK, type);
+                result.KeepCallback = true;
+                DispatchCommandResult(result);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/4c73c90b/src/wp7/NetworkStatus.cs
----------------------------------------------------------------------
diff --git a/src/wp7/NetworkStatus.cs b/src/wp7/NetworkStatus.cs
deleted file mode 100644
index b016f5a..0000000
--- a/src/wp7/NetworkStatus.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-/*  
-    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.
-*/
-
-using System;
-using System.Diagnostics;
-using System.Net;
-using System.Net.NetworkInformation;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using Microsoft.Phone.Net.NetworkInformation;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
-
-    // http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation(v=VS.92).aspx
-    // http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation.devicenetworkinformation(v=VS.92).aspx
-
-    public class NetworkStatus : BaseCommand
-    {
-        const string UNKNOWN = "unknown";
-        const string ETHERNET = "ethernet";
-        const string WIFI = "wifi";
-        const string CELL_2G = "2g";
-        const string CELL_3G = "3g";
-        const string CELL_4G = "4g";
-        const string NONE = "none";
-        const string CELL = "cellular";
-
-        private bool HasCallback = false;
-
-        public NetworkStatus()
-        {
-            DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler<NetworkNotificationEventArgs>(ChangeDetected);
-        }
-
-        public override void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e)
-        {
-            this.getConnectionInfo("");
-        }
-
-        public void getConnectionInfo(string empty)
-        {
-            HasCallback = true;
-            updateConnectionType(checkConnectionType());
-        }
-
-        private string checkConnectionType()
-        {
-            if (DeviceNetworkInformation.IsNetworkAvailable)
-            {
-                if (DeviceNetworkInformation.IsWiFiEnabled)
-                {
-                    return WIFI;
-                }
-                else
-                {
-                    return DeviceNetworkInformation.IsCellularDataEnabled ? CELL : UNKNOWN;
-                }
-            }
-            return NONE;
-        }
-
-        private string checkConnectionType(NetworkInterfaceSubType type)
-        {
-            switch (type)
-            {
-                case NetworkInterfaceSubType.Cellular_1XRTT: //cell
-                case NetworkInterfaceSubType.Cellular_GPRS: //cell
-                    return CELL;
-                case NetworkInterfaceSubType.Cellular_EDGE: //2
-                    return CELL_2G;
-                case NetworkInterfaceSubType.Cellular_3G:
-                case NetworkInterfaceSubType.Cellular_EVDO: //3
-                case NetworkInterfaceSubType.Cellular_EVDV: //3 
-                case NetworkInterfaceSubType.Cellular_HSPA: //3
-                    return CELL_3G;
-                case NetworkInterfaceSubType.WiFi:
-                    return WIFI;
-                case NetworkInterfaceSubType.Unknown:
-                case NetworkInterfaceSubType.Desktop_PassThru:
-                default:
-                    return UNKNOWN;
-            }
-        }
-
-        void ChangeDetected(object sender, NetworkNotificationEventArgs e)
-        {
-            switch (e.NotificationType)
-            {
-                case NetworkNotificationType.InterfaceConnected:
-                    updateConnectionType(checkConnectionType(e.NetworkInterface.InterfaceSubtype));
-                    break;
-                case NetworkNotificationType.InterfaceDisconnected:
-                    updateConnectionType(NONE);
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        private void updateConnectionType(string type)
-        {
-            // This should also implicitly fire offline/online events as that is handled on the JS side
-            if (this.HasCallback)
-            {
-                PluginResult result = new PluginResult(PluginResult.Status.OK, type);
-                result.KeepCallback = true;
-                DispatchCommandResult(result);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/4c73c90b/src/wp8/NetworkStatus.cs
----------------------------------------------------------------------
diff --git a/src/wp8/NetworkStatus.cs b/src/wp8/NetworkStatus.cs
deleted file mode 100644
index 12eb061..0000000
--- a/src/wp8/NetworkStatus.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-/*  
-	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.
-*/
-
-using System;
-using System.Diagnostics;
-using System.Net;
-using System.Net.NetworkInformation;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using Microsoft.Phone.Net.NetworkInformation;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
-
-    // http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation(v=VS.92).aspx
-    // http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation.devicenetworkinformation(v=VS.92).aspx
-
-    public class NetworkStatus : BaseCommand
-    {
-        const string UNKNOWN = "unknown";
-        const string ETHERNET = "ethernet";
-        const string WIFI = "wifi";
-        const string CELL_2G = "2g";
-        const string CELL_3G = "3g";
-        const string CELL_4G = "4g";
-        const string NONE = "none";
-        const string CELL = "cellular";
-
-        private bool HasCallback = false;
-
-        public NetworkStatus()
-        {
-            DeviceNetworkInformation.NetworkAvailabilityChanged += new EventHandler<NetworkNotificationEventArgs>(ChangeDetected);
-        }
-
-        public override void OnResume(object sender, Microsoft.Phone.Shell.ActivatedEventArgs e)
-        {
-            this.getConnectionInfo("");
-        }
-
-        public void getConnectionInfo(string empty)
-        {
-            HasCallback = true;
-            updateConnectionType(checkConnectionType());
-        }
-
-        private string checkConnectionType()
-        {
-            if (DeviceNetworkInformation.IsNetworkAvailable)
-            {
-                if (DeviceNetworkInformation.IsWiFiEnabled)
-                {
-                    return WIFI;
-                }
-                else
-                {
-                    return DeviceNetworkInformation.IsCellularDataEnabled ? CELL : UNKNOWN;
-                }
-            }
-            return NONE;
-        }
-
-        private string checkConnectionType(NetworkInterfaceSubType type)
-        {
-            switch (type)
-            {
-                case NetworkInterfaceSubType.Cellular_1XRTT: //cell
-                case NetworkInterfaceSubType.Cellular_GPRS: //cell
-                    return CELL;
-                case NetworkInterfaceSubType.Cellular_EDGE: //2
-                    return CELL_2G;
-                case NetworkInterfaceSubType.Cellular_3G:
-                case NetworkInterfaceSubType.Cellular_EVDO: //3
-                case NetworkInterfaceSubType.Cellular_EVDV: //3 
-                case NetworkInterfaceSubType.Cellular_HSPA: //3
-                    return CELL_3G;
-                case NetworkInterfaceSubType.WiFi:
-                    return WIFI;
-                case NetworkInterfaceSubType.Unknown:
-                case NetworkInterfaceSubType.Desktop_PassThru:
-                default:
-                    return UNKNOWN;
-            }
-        }
-
-        void ChangeDetected(object sender, NetworkNotificationEventArgs e)
-        {
-            switch (e.NotificationType)
-            {
-                case NetworkNotificationType.InterfaceConnected:
-                    updateConnectionType(checkConnectionType(e.NetworkInterface.InterfaceSubtype));
-                    break;
-                case NetworkNotificationType.InterfaceDisconnected:
-                    updateConnectionType(NONE);
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        private void updateConnectionType(string type)
-        {
-            // This should also implicitly fire offline/online events as that is handled on the JS side
-            if (this.HasCallback)
-            {
-                PluginResult result = new PluginResult(PluginResult.Status.OK, type);
-                result.KeepCallback = true;
-                DispatchCommandResult(result);
-            }
-        }
-    }
-}