Merge pull request #59 from maverickmishra/master
CB-13663 : Removed deprecated platforms
diff --git a/README.md b/README.md
index 4ee2bb0..1bcb8f3 100644
--- a/README.md
+++ b/README.md
@@ -45,15 +45,10 @@
## Supported Platforms
-- Amazon Fire OS
- Android
-- BlackBerry 10
- Browser
- iOS
-- Windows Phone 7 and 8
-- Tizen
- Windows
-- Firefox OS
# Connection
@@ -114,27 +109,10 @@
- <iOS7 can't detect the type of cellular network connection.
- `navigator.connection.type` is set to `Connection.CELL` for all cellular data.
-### Windows Phone Quirks
-
-- When running in the emulator, always detects `navigator.connection.type` as `Connection.UNKNOWN`.
-
-- Windows Phone can't detect the type of cellular network connection.
- - `navigator.connection.type` is set to `Connection.CELL` for all cellular data.
-
### Windows Quirks
- When running in the Phone 8.1 emulator, always detects `navigator.connection.type` as `Connection.ETHERNET`.
-### Tizen Quirks
-
-- 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.
-
### Browser Quirks
- Browser can't detect the type of network connection.
@@ -173,14 +151,6 @@
During initial startup, the first offline event (if applicable) takes at least a second to fire.
-### Windows Phone 7 Quirks
-
-When running in the Emulator, the `connection.status` is always unknown, so this event does _not_ fire.
-
-### Windows Phone 8 Quirks
-
-The Emulator reports the connection type as `Cellular`, which does not change, so the event does _not_ fire.
-
## online
This event fires when an application goes online, and the device
@@ -215,14 +185,6 @@
at least a second to fire, prior to which `connection.type` is
`UNKNOWN`.
-### Windows Phone 7 Quirks
-
-When running in the Emulator, the `connection.status` is always unknown, so this event does _not_ fire.
-
-### Windows Phone 8 Quirks
-
-The Emulator reports the connection type as `Cellular`, which does not change, so events does _not_ fire.
-
## Sample: Upload a File Depending on your Network State <a name="sample"></a>
The code examples in this section show examples of changing app behavior using the online and offline events and your network connection status.
diff --git a/package.json b/package.json
index 73b253d..74998a1 100644
--- a/package.json
+++ b/package.json
@@ -1,22 +1,14 @@
{
"name": "cordova-plugin-network-information",
- "version": "1.3.5-dev",
+ "version": "2.0.0-dev",
"description": "Cordova Network Information Plugin",
"types": "./types/index.d.ts",
"cordova": {
"id": "cordova-plugin-network-information",
"platforms": [
- "firefoxos",
"android",
- "amazon-fireos",
- "ubuntu",
"ios",
- "blackberry10",
- "wp7",
- "wp8",
- "windows8",
"windows",
- "tizen",
"browser"
]
},
@@ -32,17 +24,9 @@
"network",
"information",
"ecosystem:cordova",
- "cordova-firefoxos",
"cordova-android",
- "cordova-amazon-fireos",
- "cordova-ubuntu",
"cordova-ios",
- "cordova-blackberry10",
- "cordova-wp7",
- "cordova-wp8",
- "cordova-windows8",
"cordova-windows",
- "cordova-tizen",
"cordova-browser"
],
"scripts": {
diff --git a/plugin.xml b/plugin.xml
index 95f3f31..ce2cea0 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -21,7 +21,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-network-information"
- version="1.3.5-dev">
+ version="2.0.0-dev">
<name>Network Information</name>
<description>Cordova Network Information Plugin</description>
@@ -39,12 +39,6 @@
<clobbers target="Connection" />
</js-module>
- <!-- firefoxos -->
- <platform name="firefoxos">
- <js-module src="src/firefoxos/NetworkProxy.js" name="NetworkProxy">
- <runs />
- </js-module>
- </platform>
<!-- android -->
<platform name="android">
@@ -62,34 +56,6 @@
</platform>
- <!-- amazon-fireos -->
- <platform name="amazon-fireos">
- <config-file target="res/xml/config.xml" parent="/*">
- <feature name="NetworkStatus">
- <param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager"/>
- </feature>
- </config-file>
-
- <config-file target="AndroidManifest.xml" parent="/*">
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- </config-file>
-
- <source-file src="src/android/NetworkManager.java" target-dir="src/org/apache/cordova/networkinformation" />
-
- </platform>
-
-
- <!-- ubuntu -->
- <platform name="ubuntu">
- <config-file target="config.xml" parent="/*">
- <feature name="Camera">
- <param policy_group="connectivity" policy_version="1" />
- </feature>
- </config-file>
- <header-file src="src/ubuntu/network_information.h" />
- <source-file src="src/ubuntu/network_information.cpp" />
- </platform>
-
<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
@@ -106,51 +72,6 @@
<framework src="CoreTelephony.framework" />
</platform>
- <!-- blackberry10 -->
- <platform name="blackberry10">
- <source-file src="src/blackberry10/index.js" target-dir="NetworkStatus" />
- <config-file target="www/config.xml" parent="/widget">
- <feature name="NetworkStatus" value="NetworkStatus"/>
- </config-file>
- </platform>
-
- <!-- wp7 -->
- <platform name="wp7">
- <config-file target="config.xml" parent="/*">
- <feature name="NetworkStatus">
- <param name="wp-package" value="NetworkStatus"/>
- </feature>
- </config-file>
-
- <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
- <Capability Name="ID_CAP_NETWORKING" />
- </config-file>
-
- <source-file src="src/wp/NetworkStatus.cs" />
- </platform>
-
- <!-- wp8 -->
- <platform name="wp8">
- <config-file target="config.xml" parent="/*">
- <feature name="NetworkStatus">
- <param name="wp-package" value="NetworkStatus"/>
- </feature>
- </config-file>
-
- <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
- <Capability Name="ID_CAP_NETWORKING" />
- </config-file>
-
- <source-file src="src/wp/NetworkStatus.cs" />
- </platform>
-
- <!-- windows8 -->
- <platform name="windows8">
- <js-module src="src/windows/NetworkInfoProxy.js" name="NetworkInfoProxy">
- <runs/>
- </js-module>
- </platform>
-
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/NetworkInfoProxy.js" name="NetworkInfoProxy">
@@ -158,13 +79,6 @@
</js-module>
</platform>
- <!-- tizen -->
- <platform name="tizen">
- <js-module src="src/tizen/NetworkProxy.js" name="NetworkProxy">
- <runs />
- </js-module>
- </platform>
-
<!-- browser -->
<platform name="browser">
<js-module src="src/browser/network.js" name="NetworkInfoProxy">
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
deleted file mode 100644
index 1c8588b..0000000
--- a/src/blackberry10/index.js
+++ /dev/null
@@ -1,65 +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.
- *
-*/
-
-/* global PluginResult */
-
-// map from BB10 to cordova connection types:
-// https://github.com/apache/cordova-js/blob/master/lib/common/plugin/Connection.js
-function mapConnectionType (con) {
- switch (con.type) {
- case 'wired':
- return 'ethernet';
- case 'wifi':
- return 'wifi';
- case 'none':
- return 'none';
- case 'cellular':
- switch (con.technology) {
- case 'edge':
- case 'gsm':
- return '2g';
- case 'evdo':
- return '3g';
- case 'umts':
- return '3g';
- case 'lte':
- return '4g';
- }
- return 'cellular';
- }
- return 'unknown';
-}
-
-function currentConnectionType () {
- try {
- // possible for webplatform to throw pps exception
- return mapConnectionType(window.qnx.webplatform.device.activeConnection || { type: 'none' });
- } catch (e) {
- return 'unknown';
- }
-}
-
-module.exports = {
- getConnectionInfo: function (success, fail, args, env) {
- var result = new PluginResult(args, env);
- result.ok(currentConnectionType());
- }
-};
diff --git a/src/firefoxos/NetworkProxy.js b/src/firefoxos/NetworkProxy.js
deleted file mode 100644
index 7d49b96..0000000
--- a/src/firefoxos/NetworkProxy.js
+++ /dev/null
@@ -1,96 +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.
- *
- */
-
-/*
- Network API overview: http://www.w3.org/TR/netinfo-api/
- and http://w3c.github.io/netinfo/
-*/
-
-var Connection = require('./Connection');
-var modulemapper = require('cordova/modulemapper');
-
-var origConnection = modulemapper.getOriginalSymbol(window, 'navigator.connection');
-
-module.exports = {
-
- getConnectionInfo: function (successCallback, errorCallback) {
- var connection = origConnection || navigator.mozConnection;
- var connectionType = Connection.UNKNOWN;
-
- if (!connection) {
- setTimeout(function () {
- successCallback(connectionType);
- }, 0);
- return;
- }
-
- var bandwidth = connection.bandwidth;
- var metered = connection.metered;
- var 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/exec/proxy').add('NetworkStatus', module.exports);
diff --git a/src/tizen/NetworkProxy.js b/src/tizen/NetworkProxy.js
deleted file mode 100644
index 63684d1..0000000
--- a/src/tizen/NetworkProxy.js
+++ /dev/null
@@ -1,89 +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.
- *
-*/
-
-/* global tizen */
-
-var Connection = require('./Connection');
-
-module.exports = {
- getConnectionInfo: function (successCallback, errorCallback) {
- var cncType = Connection.NONE;
- var infoCount = 0;
- var deviceCapabilities = null;
- var timerId = 0;
- var timeout = 300;
-
- function connectionCB () {
- if (timerId !== null) {
- clearTimeout(timerId);
- timerId = null;
- }
-
- infoCount++;
-
- if (infoCount > 1) {
- if (successCallback) {
- successCallback(cncType);
- }
- }
- }
-
- function errorCB (error) {
- console.log('Error: ' + error.code + ',' + error.name + ',' + error.message);
-
- if (errorCallback) {
- errorCallback();
- }
- }
-
- function wifiSuccessCB (wifi) {
- if ((wifi.status === 'ON') && (wifi.ipAddress.length !== 0)) {
- cncType = Connection.WIFI;
- }
- connectionCB();
- }
-
- function cellularSuccessCB (cell) {
- if ((cncType === Connection.NONE) && (cell.status === 'ON') && (cell.ipAddress.length !== 0)) {
- cncType = Connection.CELL_2G;
- }
- connectionCB();
- }
-
- deviceCapabilities = tizen.systeminfo.getCapabilities();
-
- timerId = setTimeout(function () {
- timerId = null;
- infoCount = 1;
- connectionCB();
- }, timeout);
-
- if (deviceCapabilities.wifi) {
- tizen.systeminfo.getPropertyValue('WIFI_NETWORK', wifiSuccessCB, errorCB);
- }
-
- if (deviceCapabilities.telephony) {
- tizen.systeminfo.getPropertyValue('CELLULAR_NETWORK', cellularSuccessCB, errorCB);
- }
- }
-};
-
-require('cordova/tizen/commandProxy').add('NetworkStatus', module.exports);
diff --git a/src/ubuntu/network_information.cpp b/src/ubuntu/network_information.cpp
deleted file mode 100644
index 8fdb494..0000000
--- a/src/ubuntu/network_information.cpp
+++ /dev/null
@@ -1,63 +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.
- */
-
-#include "network_information.h"
-
-void NetworkInformation::getConnectionInfo(int scId, int ecId) {
- Q_UNUSED(ecId);
-
- QString result;
- QNetworkInfo::NetworkMode networkMode = m_systemNetworkInfo.currentNetworkMode();
- QNetworkInfo::NetworkStatus networkStatus = m_systemNetworkInfo.networkStatus(networkMode, 0);
- QNetworkInfo::CellDataTechnology cellDataTechnology = m_systemNetworkInfo.currentCellDataTechnology(0);
-
- if (networkStatus == QNetworkInfo::NoNetworkAvailable)
- result = "Connection.NONE";
-
- switch (networkMode) {
- case QNetworkInfo::WimaxMode:
- case QNetworkInfo::WlanMode:
- result = "Connection.WIFI";
- break;
- case QNetworkInfo::EthernetMode:
- result = "Connection.ETHERNET";
- break;
- case QNetworkInfo::LteMode:
- result = "Connection.CELL_4G";
- break;
- case QNetworkInfo::GsmMode:
- case QNetworkInfo::CdmaMode:
- case QNetworkInfo::TdscdmaMode:
- case QNetworkInfo::WcdmaMode:
- switch (cellDataTechnology) {
- case QNetworkInfo::UmtsDataTechnology:
- case QNetworkInfo::HspaDataTechnology:
- result = "Connection.CELL_3G";
- break;
- case QNetworkInfo::EdgeDataTechnology:
- case QNetworkInfo::GprsDataTechnology:
- result = "Connection.CELL_2G";
- break;
- case QNetworkInfo::UnknownDataTechnology:
- result = "Connection.UNKNOWN";
- break;
- }
- case QNetworkInfo::BluetoothMode:
- case QNetworkInfo::UnknownMode:
- result = "Connection.UNKNOWN";
- break;
- }
-
- this->callback(scId, result);
-}
diff --git a/src/ubuntu/network_information.h b/src/ubuntu/network_information.h
deleted file mode 100644
index aca20e7..0000000
--- a/src/ubuntu/network_information.h
+++ /dev/null
@@ -1,47 +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.
- */
-
-#ifndef NETWORK_INFORMATION_H
-#define NETWORK_INFORMATION_H
-
-#include <cplugin.h>
-
-#include <QtSystemInfo>
-#include <QtCore>
-
-class NetworkInformation: public CPlugin {
- Q_OBJECT
-public:
- explicit NetworkInformation(Cordova *cordova): CPlugin(cordova) {}
-
- virtual const QString fullName() override {
- return NetworkInformation::fullID();
- }
-
- virtual const QString shortName() override {
- return "Connection";
- }
-
- static const QString fullID() {
- return "NetworkStatus";
- }
-
-public slots:
- void getConnectionInfo(int scId, int ecId);
-
-private:
- QNetworkInfo m_systemNetworkInfo;
-};
-
-#endif
diff --git a/src/wp/NetworkStatus.cs b/src/wp/NetworkStatus.cs
deleted file mode 100644
index 12eb061..0000000
--- a/src/wp/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);
- }
- }
- }
-}