summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-network-information
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-network-information')
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md2
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/LICENSE0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/NOTICE0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/README.md187
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md177
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/de/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/de/index.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/es/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/es/index.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/fr/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/fr/index.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/it/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/it/index.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/ja/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/ja/index.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/ko/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/ko/index.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/pl/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/pl/index.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/ru/index.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/zh/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/doc/zh/index.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/package.json18
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/plugin.xml12
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-network-information/src/android/NetworkManager.java72
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js2
-rw-r--r--StoneIsland/plugins/cordova-plugin-network-information/src/browser/network.js48
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js7
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m31
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m6
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js3
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js7
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/tests/plugin.xml2
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js3
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/www/Connection.js0
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-network-information/www/browser/network.js92
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-network-information/www/network.js0
42 files changed, 429 insertions, 240 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md
index f7dbcaba..4c8e6a5e 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/CONTRIBUTING.md
@@ -27,7 +27,7 @@ There are multiple ways to contribute: report bugs, improve the docs, and
contribute code.
For instructions on this, start with the
-[contribution overview](http://cordova.apache.org/#contribute).
+[contribution overview](http://cordova.apache.org/contribute/).
The details are explained there, but the important items are:
- Sign and submit an Apache ICLA (Contributor License Agreement).
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/LICENSE b/StoneIsland/plugins/cordova-plugin-network-information/LICENSE
index 7a4a3ea2..7a4a3ea2 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/LICENSE
+++ b/StoneIsland/plugins/cordova-plugin-network-information/LICENSE
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/NOTICE b/StoneIsland/plugins/cordova-plugin-network-information/NOTICE
index fb19cbdb..fb19cbdb 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/NOTICE
+++ b/StoneIsland/plugins/cordova-plugin-network-information/NOTICE
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/README.md b/StoneIsland/plugins/cordova-plugin-network-information/README.md
index c78f3b02..394058c4 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/README.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/README.md
@@ -1,3 +1,7 @@
+---
+title: Network Information
+description: Get information about wireless connectivity.
+---
<!--
# license: Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -17,15 +21,24 @@
# under the License.
-->
+|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI |
+|:-:|:-:|:-:|:-:|:-:|:-:|
+|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-network-information/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-network-information/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-network-information/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-network-information/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-network-information)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-network-information/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-network-information)|
+
# cordova-plugin-network-information
-[![Build Status](https://travis-ci.org/apache/cordova-plugin-network-information.svg)](https://travis-ci.org/apache/cordova-plugin-network-information)
This plugin provides an implementation of an old version of the
[Network Information API](http://www.w3.org/TR/2011/WD-netinfo-api-20110607/).
It provides information about the device's cellular and
wifi connection, and whether the device has an internet connection.
+> To get a few ideas how to use the plugin, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content.
+
+Report issues with this plugin on the [Apache Cordova issue tracker][Apache Cordova issue tracker].
+
+##<a name="reference"></a>Reference
+
## Installation
cordova plugin add cordova-plugin-network-information
@@ -68,24 +81,25 @@ connection state, and type of connection.
### Quick Example
- function checkConnection() {
- var networkState = navigator.connection.type;
-
- var states = {};
- states[Connection.UNKNOWN] = 'Unknown connection';
- states[Connection.ETHERNET] = 'Ethernet connection';
- states[Connection.WIFI] = 'WiFi connection';
- states[Connection.CELL_2G] = 'Cell 2G connection';
- states[Connection.CELL_3G] = 'Cell 3G connection';
- states[Connection.CELL_4G] = 'Cell 4G connection';
- states[Connection.CELL] = 'Cell generic connection';
- states[Connection.NONE] = 'No network connection';
+```js
+function checkConnection() {
+ var networkState = navigator.connection.type;
- alert('Connection type: ' + states[networkState]);
- }
+ var states = {};
+ states[Connection.UNKNOWN] = 'Unknown connection';
+ states[Connection.ETHERNET] = 'Ethernet connection';
+ states[Connection.WIFI] = 'WiFi connection';
+ states[Connection.CELL_2G] = 'Cell 2G connection';
+ states[Connection.CELL_3G] = 'Cell 3G connection';
+ states[Connection.CELL_4G] = 'Cell 4G connection';
+ states[Connection.CELL] = 'Cell generic connection';
+ states[Connection.NONE] = 'No network connection';
- checkConnection();
+ alert('Connection type: ' + states[networkState]);
+}
+checkConnection();
+```
### API Change
@@ -97,7 +111,7 @@ eventually be removed.
### iOS Quirks
-- iOS can't detect the type of cellular network connection.
+- <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
@@ -147,12 +161,13 @@ attach an event listener once the `deviceready` event fires.
### Quick Example
- document.addEventListener("offline", onOffline, false);
-
- function onOffline() {
- // Handle the offline event
- }
+```js
+document.addEventListener("offline", onOffline, false);
+function onOffline() {
+ // Handle the offline event
+}
+```
### iOS Quirks
@@ -186,12 +201,13 @@ attach an event listener once the `deviceready` event fires.
### Quick Example
- document.addEventListener("online", onOnline, false);
-
- function onOnline() {
- // Handle the online event
- }
+```js
+document.addEventListener("online", onOnline, false);
+function onOnline() {
+ // Handle the online event
+}
+```
### iOS Quirks
@@ -206,3 +222,120 @@ When running in the Emulator, the `connection.status` is always unknown, so this
### 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.
+
+To start with, create a new FileEntry object (data.txt) to use for sample data. Call this function from the `deviceready` handler.
+
+>*Note* This code example requires the File plugin.
+
+```js
+var dataFileEntry;
+
+function createSomeData() {
+
+ window.requestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fs) {
+
+ console.log('file system open: ' + fs.name);
+ // Creates a new file or returns an existing file.
+ fs.root.getFile("data.txt", { create: true, exclusive: false }, function (fileEntry) {
+
+ dataFileEntry = fileEntry;
+
+ }, onErrorCreateFile);
+
+ }, onErrorLoadFs);
+}
+```
+
+Next, add listeners for the online and offline events in the `deviceready` handler.
+
+```js
+document.addEventListener("offline", onOffline, false);
+document.addEventListener("online", onOnline, false);
+```
+
+The app's `onOnline` function handles the online event. In the event handler, check the current network state. In this app, treat any connection type as good except Connection.NONE. If you have a connection, you try to upload a file.
+
+```js
+function onOnline() {
+ // Handle the online event
+ var networkState = navigator.connection.type;
+
+ if (networkState !== Connection.NONE) {
+ if (dataFileEntry) {
+ tryToUploadFile();
+ }
+ }
+ display('Connection type: ' + networkState);
+}
+```
+
+When the online event fires in the preceding code, call the app's `tryToUploadFile` function.
+
+If the FileTransfer object's upload function fails, call the app's `offlineWrite` function to save the current data somewhere.
+
+>*Note* This example requires the FileTransfer plugin.
+
+```js
+function tryToUploadFile() {
+ // !! Assumes variable fileURL contains a valid URL to a text file on the device,
+ var fileURL = getDataFileEntry().toURL();
+
+ var success = function (r) {
+ console.log("Response = " + r.response);
+ display("Uploaded. Response: " + r.response);
+ }
+
+ var fail = function (error) {
+ console.log("An error has occurred: Code = " + error.code);
+ offlineWrite("Failed to upload: some offline data");
+ }
+
+ var options = new FileUploadOptions();
+ options.fileKey = "file";
+ options.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
+ options.mimeType = "text/plain";
+
+ var ft = new FileTransfer();
+ // Make sure you add the domain of your server URL to the
+ // Content-Security-Policy <meta> element in index.html.
+ ft.upload(fileURL, encodeURI(SERVER), success, fail, options);
+};
+```
+
+Here is the code for the `offlineWrite` function.
+
+>*Note* This code examples requires the File plugin.
+
+```js
+function offlineWrite(offlineData) {
+ // Create a FileWriter object for our FileEntry.
+ dataFileEntry.createWriter(function (fileWriter) {
+
+ fileWriter.onwriteend = function () {
+ console.log("Successful file write...");
+ display(offlineData);
+ };
+
+ fileWriter.onerror = function (e) {
+ console.log("Failed file write: " + e.toString());
+ };
+
+ fileWriter.write(offlineData);
+ });
+}
+```
+
+If the offline event occurs, just do something like notify the user (for this example, just log it).
+
+```js
+function onOffline() {
+ // Handle the offline event
+ console.log("lost connection");
+}
+```
+
+[Apache Cordova issue tracker]: https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Network%20Information%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md
index 06bc5090..7ff57bd6 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/RELEASENOTES.md
@@ -20,97 +20,128 @@
-->
# Release Notes
-### 0.2.1 (Sept 5, 2013)
-* CB-4432 copyright notice change
+### 1.3.0 (Sep 08, 2016)
+* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
+* [CB-11734](https://issues.apache.org/jira/browse/CB-11734) Network Plugin uses `Android Log class` and not `Cordova LOG class`
+* [CB-11300](https://issues.apache.org/jira/browse/CB-11300) (**android**) Recognize `2G`, `3G` and `4G` network connection subtype names
+* Update `NetworkManager.java`
+* Detection of Ethernet Network Type on **Android**
+* fixed two potential memory leaks when doing Analyze on **iOS 9**
+* [CB-11384](https://issues.apache.org/jira/browse/CB-11384) **android**: Does not pass sonarqube scan
+* Add badges for paramedic builds on Jenkins
+* Add pull request template.
+* Readme: Add fenced code blocks with langauage hints
+* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
-### 0.2.3 (Sept 25, 2013)
-* CB-4889 bumping&resetting version
-* [windows8] commandProxy was moved
-* CB-4889 renaming org.apache.cordova.core.network-information to org.apache.cordova.network-information
-* removed duplicate comment line from plugin.xml
-* added Network APIs for FirefoxOS
-* Rename CHANGELOG.md -> RELEASENOTES.md
-* [CB-4752] Incremented plugin version on dev branch.
-
-### 0.2.4 (Oct 28, 2013)
-* CB-5128: add repo + issue tag to plugin.xml for network information plugin
-* [CB-4915] Incremented plugin version on dev branch.
+### 1.2.1 (Apr 15, 2016)
+* [CB-10763](https://issues.apache.org/jira/browse/CB-10763) Remove emoji in `cordova-plugin-network-information`
+* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins
-### 0.2.5 (Dec 4, 2013)
-* [ubuntu] specify policy_group
-* add ubuntu platform
-* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos'
+### 1.2.0 (Jan 15, 2016)
+* Adding `CoreTelephony` to `plugin.xml`
+* Adding notification for `CT radio` information
+* Adding `CT radio` information
+* [CB-10160](https://issues.apache.org/jira/browse/CB-10160) Fixed the case mismatch issue
-### 0.2.6 (Jan 02, 2014)
-* CB-5658 Add doc/index.md for netinfo plugin
+### 1.1.0 (Nov 18, 2015)
+* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
+* Fixing contribute link.
+* These notifications are objects so their address always evaluates to true.
+* Update `NetworkManager.java`
+* [CB-9542](https://issues.apache.org/jira/browse/CB-9542) `Browser Proxy` not defined correctly
+* Solved `toLowerCase` issue with `Locale.US`
-### 0.2.7 (Feb 05, 2014)
-* Initial implementation of Tizen plugin.
+### 1.0.1 (Jun 17, 2015)
+* Adding .ratignore file.
+* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-network-information documentation translation: cordova-plugin-network-information
+* fix npm md issue
-### 0.2.8 (Apr 17, 2014)
-* CB-6342: [iOS] iOS reports a cellular connection even when in Airplane mode
-* CB-6422: [windows8] use cordova/exec/proxy
-* CB-6460: Update license headers
-* CB-6465: Add license headers to Tizen code
-* Add NOTICE file
+### 1.0.0 (Apr 15, 2015)
+* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
+* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name
+* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id
+* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id
+* [CB-8185](https://issues.apache.org/jira/browse/CB-8185) Fixes typo in `cordova.platformId`
+* Use TRAVIS_BUILD_DIR, install paramedic by npm
+* [CB-8185](https://issues.apache.org/jira/browse/CB-8185) Use `navigator.onLine` as connection information source on browser platform
+* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
+* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of initWebView method
+* [CB-8573](https://issues.apache.org/jira/browse/CB-8573) Integrate TravisCI
+* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-network-information documentation translation: cordova-plugin-network-information
+* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
-### 0.2.9 (Jun 05, 2014)
-* updated notice file to include missing license
-* Cached extra info to better detect changes.
-* CB-6809 Add license to CONTRIBUTING.md
-* CB-6491 add CONTRIBUTING.md
-* CB-6350 - Fix networkStatusForFlags return value type to work with 64-bit iOS (closes #8)
-* Initial version of firefox os network information plugin
-* there was an error in the object definition
+### 0.2.15 (Feb 04, 2015)
+* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Network status change support on Windows
+* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Fixes the way we detect online status on Windows
+* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Add Windows platform quirks
+* [CB-8384](https://issues.apache.org/jira/browse/CB-8384) Add Windows section to Network Information plugin
-### 0.2.10 (Jun 24, 2014)
-* CB-6907: [android] Don't crash on startup if no networks available
+### 0.2.14 (Dec 02, 2014)
+* [CB-7976](https://issues.apache.org/jira/browse/CB-7976) **Android**: Use webView's context rather than Activity's context for intent receiver
+* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-network-information documentation translation: cordova-plugin-network-information
-### 0.2.11 (Aug 06, 2014)
-* **FFOS** update NetworkProxy.js
-* CB-6127 Updated translations for docs
-* CB-7019 Updated version and RELEASENOTES.md for release 0.2.10
-* Fixed docs for online/offline event being backwards
+### 0.2.13 (Oct 03, 2014)
+* [CB-7595](https://issues.apache.org/jira/browse/CB-7595): Android L changes the type from Mobile to Cellular, I'm pretty sure this isn't documented
### 0.2.12 (Sep 17, 2014)
-* CB-7471 cordova-plugin-network-information documentation translation
+* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-network-information documentation translation
* Fix network information type exception on fxos 2
* Added support for the browser
-* CB-6724 added documentation for manual tests
+* [CB-6724](https://issues.apache.org/jira/browse/CB-6724) added documentation for manual tests
* remove reference to test assets, they are optional
* Renamed test dir and added nested plugin.xml
-* CB-6964 ported manual tests
+* [CB-6964](https://issues.apache.org/jira/browse/CB-6964) ported manual tests
* Port network tests to plugin-test-framework
* Fix naviagtor typo
-### 0.2.13 (Oct 03, 2014)
-* CB-7595: Android L changes the type from Mobile to Cellular, I'm pretty sure this isn't documented
+### 0.2.11 (Aug 06, 2014)
+* **FFOS** update NetworkProxy.js
+* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
+* [CB-7019](https://issues.apache.org/jira/browse/CB-7019) Updated version and RELEASENOTES.md for release 0.2.10
+* Fixed docs for online/offline event being backwards
-### 0.2.14 (Dec 02, 2014)
-* CB-7976 **Android**: Use webView's context rather than Activity's context for intent receiver
-* CB-7700 cordova-plugin-network-information documentation translation: cordova-plugin-network-information
+### 0.2.10 (Jun 24, 2014)
+* [CB-6907](https://issues.apache.org/jira/browse/CB-6907): [android] Don't crash on startup if no networks available
-### 0.2.15 (Feb 04, 2015)
-* CB-8384 Network status change support on Windows
-* CB-8384 Fixes the way we detect online status on Windows
-* CB-8384 Add Windows platform quirks
-* CB-8384 Add Windows section to Network Information plugin
+### 0.2.9 (Jun 05, 2014)
+* updated notice file to include missing license
+* Cached extra info to better detect changes.
+* [CB-6809](https://issues.apache.org/jira/browse/CB-6809) Add license to CONTRIBUTING.md
+* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
+* [CB-6350](https://issues.apache.org/jira/browse/CB-6350) - Fix networkStatusForFlags return value type to work with 64-bit iOS (closes #8)
+* Initial version of firefox os network information plugin
+* there was an error in the object definition
-### 1.0.0 (Apr 15, 2015)
-* CB-8746 gave plugin major version bump
-* CB-8683 changed plugin-id to pacakge-name
-* CB-8653 properly updated translated docs to use new id
-* CB-8653 updated translated docs to use new id
-* CB-8185 Fixes typo in `cordova.platformId`
-* Use TRAVIS_BUILD_DIR, install paramedic by npm
-* CB-8185 Use `navigator.onLine` as connection information source on browser platform
-* CB-8653 Updated Readme
-* CB-8659: ios: 4.0.x Compatibility: Remove use of initWebView method
-* CB-8573 Integrate TravisCI
-* CB-8438 cordova-plugin-network-information documentation translation: cordova-plugin-network-information
-* CB-8538 Added package.json file
+### 0.2.8 (Apr 17, 2014)
+* [CB-6342](https://issues.apache.org/jira/browse/CB-6342): [iOS] iOS reports a cellular connection even when in Airplane mode
+* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy
+* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
+* [CB-6465](https://issues.apache.org/jira/browse/CB-6465): Add license headers to Tizen code
+* Add NOTICE file
-### 1.0.1 (Jun 17, 2015)
-* Adding .ratignore file.
-* CB-9128 cordova-plugin-network-information documentation translation: cordova-plugin-network-information
-* fix npm md issue
+### 0.2.7 (Feb 05, 2014)
+* Initial implementation of Tizen plugin.
+
+### 0.2.6 (Jan 02, 2014)
+* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for netinfo plugin
+
+### 0.2.5 (Dec 4, 2013)
+* [ubuntu] specify policy_group
+* add ubuntu platform
+* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos'
+
+### 0.2.4 (Oct 28, 2013)
+* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): add repo + issue tag to plugin.xml for network information plugin
+* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
+
+### 0.2.3 (Sept 25, 2013)
+* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version
+* [windows8] commandProxy was moved
+* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.network-information to org.apache.cordova.network-information
+* removed duplicate comment line from plugin.xml
+* added Network APIs for FirefoxOS
+* Rename CHANGELOG.md -> RELEASENOTES.md
+* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
+
+### 0.2.1 (Sept 5, 2013)
+* [CB-4432](https://issues.apache.org/jira/browse/CB-4432) copyright notice change
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/de/README.md
index f6292b27..f6292b27 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/de/README.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/de/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/de/index.md
index 537328a6..537328a6 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/de/index.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/de/index.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/es/README.md
index 4e30593d..4e30593d 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/es/README.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/es/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/es/index.md
index 65158ef5..65158ef5 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/es/index.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/es/index.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/README.md
index 8f2b82cc..8f2b82cc 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/README.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/index.md
index e49c5d52..e49c5d52 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/index.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/fr/index.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/it/README.md
index f4343594..f4343594 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/it/README.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/it/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/it/index.md
index e1917195..e1917195 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/it/index.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/it/index.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/README.md
index 797b7413..797b7413 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/README.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/index.md
index 71b6f82e..71b6f82e 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/index.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/ja/index.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/README.md
index a6675391..a6675391 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/README.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/index.md
index cb4c727a..cb4c727a 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/index.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/ko/index.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/README.md
index 4b66cbb4..4b66cbb4 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/README.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/index.md
index a42b973c..a42b973c 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/index.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/pl/index.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/ru/index.md
index 481c1b18..481c1b18 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/ru/index.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/ru/index.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/README.md
index 09e11e7e..09e11e7e 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/README.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/index.md
index 2041467e..2041467e 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/index.md
+++ b/StoneIsland/plugins/cordova-plugin-network-information/doc/zh/index.md
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/package.json b/StoneIsland/plugins/cordova-plugin-network-information/package.json
index 452db88b..fd804b86 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/package.json
+++ b/StoneIsland/plugins/cordova-plugin-network-information/package.json
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-network-information",
- "version": "1.0.1",
+ "version": "1.3.0",
"description": "Cordova Network Information Plugin",
"cordova": {
"id": "cordova-plugin-network-information",
@@ -41,6 +41,20 @@
"cordova-tizen",
"cordova-browser"
],
+ "scripts": {
+ "test": "npm run jshint",
+ "jshint": "jshint www && jshint src && jshint tests"
+ },
"author": "Apache Software Foundation",
- "license": "Apache 2.0"
+ "license": "Apache-2.0",
+ "engines": {
+ "cordovaDependencies": {
+ "2.0.0": {
+ "cordova": ">100"
+ }
+ }
+ },
+ "devDependencies": {
+ "jshint": "^2.6.0"
+ }
}
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/plugin.xml b/StoneIsland/plugins/cordova-plugin-network-information/plugin.xml
index e0ed97fc..29922293 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/plugin.xml
+++ b/StoneIsland/plugins/cordova-plugin-network-information/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.0.1">
+ version="1.3.0">
<name>Network Information</name>
<description>Cordova Network Information Plugin</description>
@@ -103,6 +103,7 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<header-file src="src/ios/CDVReachability.h" />
<source-file src="src/ios/CDVReachability.m" />
<framework src="SystemConfiguration.framework" weak="true" />
+ <framework src="CoreTelephony.framework" />
</platform>
<!-- blackberry10 -->
@@ -146,14 +147,14 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<!-- windows8 -->
<platform name="windows8">
<js-module src="src/windows/NetworkInfoProxy.js" name="NetworkInfoProxy">
- <merges target="" />
+ <runs/>
</js-module>
</platform>
<!-- windows -->
<platform name="windows">
<js-module src="src/windows/NetworkInfoProxy.js" name="NetworkInfoProxy">
- <merges target="" />
+ <runs/>
</js-module>
</platform>
@@ -166,9 +167,8 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<!-- browser -->
<platform name="browser">
- <js-module src="www/browser/network.js" name="browserNetwork">
- <clobbers target="navigator.connection" />
- <clobbers target="navigator.network.connection" />
+ <js-module src="src/browser/network.js" name="NetworkInfoProxy">
+ <runs/>
</js-module>
</platform>
</plugin>
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/android/NetworkManager.java b/StoneIsland/plugins/cordova-plugin-network-information/src/android/NetworkManager.java
index 4c85ddab..614b6e7b 100755
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/android/NetworkManager.java
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/android/NetworkManager.java
@@ -21,6 +21,7 @@ package org.apache.cordova.networkinformation;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.LOG;
import org.apache.cordova.PluginResult;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
@@ -33,7 +34,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
-import android.util.Log;
+
+import java.util.Locale;
public class NetworkManager extends CordovaPlugin {
@@ -45,14 +47,16 @@ public class NetworkManager extends CordovaPlugin {
public static final String WIMAX = "wimax";
// mobile
public static final String MOBILE = "mobile";
-
- // Android L calls this Cellular, because I have no idea!
+
+ // Android L calls this Cellular, because I have no idea!
public static final String CELLULAR = "cellular";
// 2G network types
+ public static final String TWO_G = "2g";
public static final String GSM = "gsm";
public static final String GPRS = "gprs";
public static final String EDGE = "edge";
// 3G network types
+ public static final String THREE_G = "3g";
public static final String CDMA = "cdma";
public static final String UMTS = "umts";
public static final String HSPA = "hspa";
@@ -61,12 +65,14 @@ public class NetworkManager extends CordovaPlugin {
public static final String ONEXRTT = "1xrtt";
public static final String EHRPD = "ehrpd";
// 4G network types
+ public static final String FOUR_G = "4g";
public static final String LTE = "lte";
public static final String UMB = "umb";
public static final String HSPA_PLUS = "hspa+";
// return type
public static final String TYPE_UNKNOWN = "unknown";
public static final String TYPE_ETHERNET = "ethernet";
+ public static final String TYPE_ETHERNET_SHORT = "eth";
public static final String TYPE_WIFI = "wifi";
public static final String TYPE_2G = "2g";
public static final String TYPE_3G = "3g";
@@ -125,7 +131,9 @@ public class NetworkManager extends CordovaPlugin {
String connectionType = "";
try {
connectionType = this.getConnectionInfo(info).get("type").toString();
- } catch (JSONException e) { }
+ } catch (JSONException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
+ }
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, connectionType);
pluginResult.setKeepCallback(true);
@@ -143,7 +151,7 @@ public class NetworkManager extends CordovaPlugin {
try {
webView.getContext().unregisterReceiver(this.receiver);
} catch (Exception e) {
- Log.e(LOG_TAG, "Error unregistering network receiver: " + e.getMessage(), e);
+ LOG.e(LOG_TAG, "Error unregistering network receiver: " + e.getMessage(), e);
} finally {
receiver = null;
}
@@ -169,7 +177,9 @@ public class NetworkManager extends CordovaPlugin {
String connectionType = "";
try {
connectionType = thisInfo.get("type").toString();
- } catch (JSONException e) { }
+ } catch (JSONException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
+ }
sendUpdate(connectionType);
lastInfo = thisInfo;
@@ -196,15 +206,17 @@ public class NetworkManager extends CordovaPlugin {
extraInfo = info.getExtraInfo();
}
- Log.d("CordovaNetworkManager", "Connection Type: " + type);
- Log.d("CordovaNetworkManager", "Connection Extra Info: " + extraInfo);
+ LOG.d(LOG_TAG, "Connection Type: " + type);
+ LOG.d(LOG_TAG, "Connection Extra Info: " + extraInfo);
JSONObject connectionInfo = new JSONObject();
try {
connectionInfo.put("type", type);
connectionInfo.put("extraInfo", extraInfo);
- } catch (JSONException e) { }
+ } catch (JSONException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
+ }
return connectionInfo;
}
@@ -231,30 +243,38 @@ public class NetworkManager extends CordovaPlugin {
*/
private String getType(NetworkInfo info) {
if (info != null) {
- String type = info.getTypeName();
+ String type = info.getTypeName().toLowerCase(Locale.US);
- if (type.toLowerCase().equals(WIFI)) {
+ LOG.d(LOG_TAG, "toLower : " + type.toLowerCase());
+ LOG.d(LOG_TAG, "wifi : " + WIFI);
+ if (type.equals(WIFI)) {
return TYPE_WIFI;
}
- else if (type.toLowerCase().equals(MOBILE) || type.toLowerCase().equals(CELLULAR)) {
- type = info.getSubtypeName();
- if (type.toLowerCase().equals(GSM) ||
- type.toLowerCase().equals(GPRS) ||
- type.toLowerCase().equals(EDGE)) {
+ else if (type.toLowerCase().equals(TYPE_ETHERNET) || type.toLowerCase().startsWith(TYPE_ETHERNET_SHORT)) {
+ return TYPE_ETHERNET;
+ }
+ else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
+ type = info.getSubtypeName().toLowerCase(Locale.US);
+ if (type.equals(GSM) ||
+ type.equals(GPRS) ||
+ type.equals(EDGE) ||
+ type.equals(TWO_G)) {
return TYPE_2G;
}
- else if (type.toLowerCase().startsWith(CDMA) ||
- type.toLowerCase().equals(UMTS) ||
- type.toLowerCase().equals(ONEXRTT) ||
- type.toLowerCase().equals(EHRPD) ||
- type.toLowerCase().equals(HSUPA) ||
- type.toLowerCase().equals(HSDPA) ||
- type.toLowerCase().equals(HSPA)) {
+ else if (type.startsWith(CDMA) ||
+ type.equals(UMTS) ||
+ type.equals(ONEXRTT) ||
+ type.equals(EHRPD) ||
+ type.equals(HSUPA) ||
+ type.equals(HSDPA) ||
+ type.equals(HSPA) ||
+ type.equals(THREE_G)) {
return TYPE_3G;
}
- else if (type.toLowerCase().equals(LTE) ||
- type.toLowerCase().equals(UMB) ||
- type.toLowerCase().equals(HSPA_PLUS)) {
+ else if (type.equals(LTE) ||
+ type.equals(UMB) ||
+ type.equals(HSPA_PLUS) ||
+ type.equals(FOUR_G)) {
return TYPE_4G;
}
}
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js b/StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js
index d47d840e..c6cd00a9 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/blackberry10/index.js
@@ -19,6 +19,8 @@
*
*/
+/* 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) {
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/browser/network.js b/StoneIsland/plugins/cordova-plugin-network-information/src/browser/network.js
new file mode 100644
index 00000000..8a6ddb0e
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/browser/network.js
@@ -0,0 +1,48 @@
+/*
+ * 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'),
+ proxy = require("cordova/exec/proxy"),
+ Connection = require('./Connection');
+
+var type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE;
+
+// Subscribe to 'native' online/offline events
+function onStatusChange(evt) {
+ type = navigator.onLine ? Connection.UNKNOWN : Connection.NONE;
+ // force async
+ setTimeout(function(){
+ cordova.fireDocumentEvent(evt.type);
+ },0);
+}
+
+window.addEventListener('online', onStatusChange);
+window.addEventListener('offline', onStatusChange);
+
+proxy.add("NetworkStatus", {
+ getConnectionInfo:function(cbSuccess) {
+ // force async
+ setTimeout(function(){
+ cbSuccess(type);
+ },0);
+ }
+});
+
+
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js b/StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js
index 40d61637..8c82557d 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/firefoxos/NetworkProxy.js
@@ -24,8 +24,7 @@
and http://w3c.github.io/netinfo/
*/
-var cordova = require('cordova'),
- Connection = require('./Connection'),
+var Connection = require('./Connection'),
modulemapper = require('cordova/modulemapper');
var origConnection = modulemapper.getOriginalSymbol(window, 'navigator.connection');
@@ -47,7 +46,7 @@ module.exports = {
metered = connection.metered,
type = connection.type;
- if (type != undefined) {
+ if (type !== undefined) {
// For more information see:
// https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API
@@ -65,7 +64,7 @@ module.exports = {
connectionType = Connection.NONE;
break;
}
- } else if (bandwidth != undefined && metered != undefined) {
+ } else if (bandwidth !== undefined && metered !== undefined) {
/*
bandwidth of type double, readonly
The user agent must set the value of the bandwidth attribute to:
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h
index 8add0279..8add0279 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.h
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m
index 37497675..6715322a 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVConnection.m
@@ -16,6 +16,7 @@
specific language governing permissions and limitations
under the License.
*/
+#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import "CDVConnection.h"
#import "CDVReachability.h"
@@ -57,6 +58,32 @@
if (isConnectionRequired) {
return @"none";
} else {
+ if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending) {
+ CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
+ if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyGPRS]) {
+ return @"2g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyEdge]) {
+ return @"2g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyWCDMA]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSDPA]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyHSUPA]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyeHRPD]) {
+ return @"3g";
+ } else if ([telephonyInfo.currentRadioAccessTechnology isEqualToString:CTRadioAccessTechnologyLTE]) {
+ return @"4g";
+ }
+ }
return @"cellular";
}
}
@@ -118,7 +145,9 @@
[self.internetReach startNotifier];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
name:kReachabilityChangedNotification object:nil];
- if (&UIApplicationDidEnterBackgroundNotification && &UIApplicationWillEnterForegroundNotification) {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateConnectionType:)
+ name:CTRadioAccessTechnologyDidChangeNotification object:nil];
+ if (UIApplicationDidEnterBackgroundNotification && UIApplicationWillEnterForegroundNotification) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
}
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h
index 01a95c35..01a95c35 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.h
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m
index c60261ae..1399867e 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ios/CDVReachability.m
@@ -142,6 +142,9 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe
retVal->reachabilityRef = reachability;
retVal->localWiFiRef = NO;
}
+ else {
+ CFRelease(reachability);
+ }
}
return retVal;
}
@@ -156,6 +159,9 @@ static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkRe
retVal->reachabilityRef = reachability;
retVal->localWiFiRef = NO;
}
+ else {
+ CFRelease(reachability);
+ }
}
return retVal;
}
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js b/StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js
index cd9506e1..d2de2ccc 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/tizen/NetworkProxy.js
@@ -19,7 +19,8 @@
*
*/
-var cordova = require('cordova');
+/* global tizen */
+
var Connection = require('./Connection');
module.exports = {
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp b/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp
index 8fdb4949..8fdb4949 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.cpp
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h b/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h
index aca20e7b..aca20e7b 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/ubuntu/network_information.h
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js b/StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js
index 27ad2f06..92153c7b 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/windows/NetworkInfoProxy.js
@@ -21,15 +21,10 @@
/*global Windows:true */
-var cordova = require('cordova');
var Connection = require('./Connection');
var winNetConn = Windows.Networking.Connectivity;
var networkInfo = winNetConn.NetworkInformation;
-var networkCostInfo = winNetConn.NetworkCostType;
-var networkConnectivityInfo = winNetConn.NetworkConnectivityLevel;
-var networkAuthenticationInfo = winNetConn.NetworkAuthenticationType;
-var networkEncryptionInfo = winNetConn.NetworkEncryptionType;
function getCurrrentConnectionType() {
@@ -76,7 +71,7 @@ module.exports = {
{
var reportConnectionInfoOnce = function () {
win(getCurrrentConnectionType(), { keepCallback: true });
- }
+ };
// report current connection type
setTimeout(reportConnectionInfoOnce, 0);
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs b/StoneIsland/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs
index 12eb061d..12eb061d 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs
+++ b/StoneIsland/plugins/cordova-plugin-network-information/src/wp/NetworkStatus.cs
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-network-information/tests/plugin.xml
index 8df4769c..c4b03c26 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/tests/plugin.xml
+++ b/StoneIsland/plugins/cordova-plugin-network-information/tests/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-tests"
- version="1.0.1">
+ version="1.3.0">
<name>Cordova Network Information Plugin Tests</name>
<license>Apache 2.0</license>
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js b/StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js
index 23be97ac..07f4b27f 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js
+++ b/StoneIsland/plugins/cordova-plugin-network-information/tests/tests.js
@@ -19,6 +19,9 @@
*
*/
+/* jshint jasmine: true */
+/* global Connection */
+
exports.defineAutoTests = function () {
describe('Network (navigator.connection)', function () {
it("network.spec.1 should exist", function () {
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/www/Connection.js b/StoneIsland/plugins/cordova-plugin-network-information/www/Connection.js
index f20a485c..f20a485c 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/www/Connection.js
+++ b/StoneIsland/plugins/cordova-plugin-network-information/www/Connection.js
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/www/browser/network.js b/StoneIsland/plugins/cordova-plugin-network-information/www/browser/network.js
deleted file mode 100755
index 72ec5139..00000000
--- a/StoneIsland/plugins/cordova-plugin-network-information/www/browser/network.js
+++ /dev/null
@@ -1,92 +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 module, require*/
-
-var cordova = require('cordova'),
- Connection = require('./Connection');
-
-var DOCUMENT_EVENTS_CHECK_INTERVAL = 500; // ms
-// Flag that indicates that ew need to re-fire online/offline events at document level
-// (Workaround for Chrome, since it fires such events only for window object)
-var NEED_FIRE_DOCUMENT_EVENT_MANUALLY = false;
-
-function NetworkConnection() {
- this.type = Connection.UNKNOWN;
-}
-
-/**
- * Get connection info
- *
- * @param {Function} successCallback The function to call when the Connection data is available
- */
-NetworkConnection.prototype.getInfo = function(successCallback) {
- successCallback(this.type);
-};
-
-Object.defineProperty(NetworkConnection.prototype, 'type', {
- get: function () {
- // It is not possible to determine real connection type in browser
- // so we always report Connection.UNKNOWN when online
- return (window.navigator.onLine === false ? Connection.NONE : Connection.UNKNOWN);
- },
- configurable: true,
- enumerable: true
-});
-
-// This function tries to detect if document online/offline events is being fired
-// after corresponding window events, and if not, then fires them manually
-// This is workaround for Chrome, which fires only window online/offline events
-// and regarding to plugin spec we need these events at document object
-var eventRedirectHandler = function (e) {
- // NEED_FIRE_DOCUMENT_EVENT_MANUALLY flag is already set,
- // just fire corresponding document event and return
- if (NEED_FIRE_DOCUMENT_EVENT_MANUALLY) {
- cordova.fireDocumentEvent(e.type);
- return;
- }
-
- // Flag that indicates whether corresponding document even is fired
- var documentStateEventFired = false;
- var setDocumentStateEventFired = function() {
- documentStateEventFired = true;
- };
- document.addEventListener(e.type, setDocumentStateEventFired);
- setTimeout(function () {
- // Remove unnecessary listener
- document.removeEventListener(e.type, setDocumentStateEventFired);
- // if document event hasn't been fired in specified interval (500 ms by default),
- // then we're in chrome and need to fire it manually
- if (!documentStateEventFired) {
- NEED_FIRE_DOCUMENT_EVENT_MANUALLY = true;
- cordova.fireDocumentEvent(e.type);
- }
- }, DOCUMENT_EVENTS_CHECK_INTERVAL);
-};
-
-// Subscribe to native online/offline events
-window.addEventListener('online', eventRedirectHandler);
-window.addEventListener('offline', eventRedirectHandler);
-
-var me = new NetworkConnection();
-
-require("cordova/exec/proxy").add("NetworkStatus", { getConnectionInfo: me.getConnectionInfo });
-
-module.exports = me;
diff --git a/StoneIsland/plugins/cordova-plugin-network-information/www/network.js b/StoneIsland/plugins/cordova-plugin-network-information/www/network.js
index ac792d8c..ac792d8c 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-network-information/www/network.js
+++ b/StoneIsland/plugins/cordova-plugin-network-information/www/network.js