Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DEAAE10CC3 for ; Thu, 5 Dec 2013 01:00:00 +0000 (UTC) Received: (qmail 54711 invoked by uid 500); 5 Dec 2013 01:00:00 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 54691 invoked by uid 500); 5 Dec 2013 01:00:00 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 54683 invoked by uid 99); 5 Dec 2013 01:00:00 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Dec 2013 01:00:00 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 67C9F320970; Thu, 5 Dec 2013 01:00:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: steven@apache.org To: commits@cordova.apache.org Date: Thu, 05 Dec 2013 01:00:00 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/6] git commit: add ubuntu platform Updated Branches: refs/heads/master f1a99e72f -> 8a48f84fc add ubuntu platform 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/43245253 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/tree/43245253 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/diff/43245253 Branch: refs/heads/master Commit: 43245253e82c7195619062b4d6a33b15e82004ca Parents: 9d39644 Author: Maxim Ermilov Authored: Sun Sep 22 08:40:51 2013 +0400 Committer: Maxim Ermilov Committed: Sun Sep 22 08:40:51 2013 +0400 ---------------------------------------------------------------------- plugin.xml | 6 ++++ src/ubuntu/network_information.cpp | 63 +++++++++++++++++++++++++++++++++ src/ubuntu/network_information.h | 47 ++++++++++++++++++++++++ 3 files changed, 116 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/43245253/plugin.xml ---------------------------------------------------------------------- diff --git a/plugin.xml b/plugin.xml index a4cf518..2ab1a1d 100644 --- a/plugin.xml +++ b/plugin.xml @@ -44,6 +44,12 @@ xmlns:android="http://schemas.android.com/apk/res/android" + + + + + + http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/43245253/src/ubuntu/network_information.cpp ---------------------------------------------------------------------- diff --git a/src/ubuntu/network_information.cpp b/src/ubuntu/network_information.cpp new file mode 100644 index 0000000..8fdb494 --- /dev/null +++ b/src/ubuntu/network_information.cpp @@ -0,0 +1,63 @@ +/* + * 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); +} http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/43245253/src/ubuntu/network_information.h ---------------------------------------------------------------------- diff --git a/src/ubuntu/network_information.h b/src/ubuntu/network_information.h new file mode 100644 index 0000000..aca20e7 --- /dev/null +++ b/src/ubuntu/network_information.h @@ -0,0 +1,47 @@ +/* + * 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 + +#include +#include + +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