| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2018 Canonical, Ltd. and/or its subsidiary(-ies). |
| 4 |
** Copyright (C) 2018 The Qt Company Ltd and/or its subsidiary(-ies). |
| 5 |
** Contact: http://www.qt-project.org/legal |
| 6 |
** |
| 7 |
** This file is part of the QtSystems module of the Qt Toolkit. |
| 8 |
** |
| 9 |
** $QT_BEGIN_LICENSE:LGPL$ |
| 10 |
** Commercial License Usage |
| 11 |
** Licensees holding valid commercial Qt licenses may use this file in |
| 12 |
** accordance with the commercial license agreement provided with the |
| 13 |
** Software or, alternatively, in accordance with the terms contained in |
| 14 |
** a written agreement between you and The Qt Company. For licensing terms |
| 15 |
** and conditions see https://www.qt.io/terms-conditions. For further |
| 16 |
** information use the contact form at https://www.qt.io/contact-us. |
| 17 |
** |
| 18 |
** GNU Lesser General Public License Usage |
| 19 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
| 20 |
** General Public License version 3 as published by the Free Software |
| 21 |
** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 22 |
** packaging of this file. Please review the following information to |
| 23 |
** ensure the GNU Lesser General Public License version 3 requirements |
| 24 |
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 25 |
** |
| 26 |
** GNU General Public License Usage |
| 27 |
** Alternatively, this file may be used under the terms of the GNU |
| 28 |
** General Public License version 2.0 or (at your option) the GNU General |
| 29 |
** Public license version 3 or any later version approved by the KDE Free |
| 30 |
** Qt Foundation. The licenses are as published by the Free Software |
| 31 |
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 32 |
** included in the packaging of this file. Please review the following |
| 33 |
** information to ensure the GNU General Public License requirements will |
| 34 |
** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 35 |
** https://www.gnu.org/licenses/gpl-3.0.html. |
| 36 |
** |
| 37 |
** $QT_END_LICENSE$ |
| 38 |
** |
| 39 |
****************************************************************************/ |
| 40 |
|
| 41 |
#include "lomirinetworkinfo_p.h" |
| 42 |
|
| 43 |
QT_BEGIN_NAMESPACE |
| 44 |
|
| 45 |
/*! |
| 46 |
\qmltype NetworkInfo |
| 47 |
\instantiates LomiriDeclarativeNetworkInfo |
| 48 |
\inqmlmodule QtSystemInfo |
| 49 |
\ingroup qml-systeminfo |
| 50 |
\brief The NetworkInfo element provides various information about the network status. |
| 51 |
*/ |
| 52 |
|
| 53 |
/*! |
| 54 |
\internal |
| 55 |
*/ |
| 56 |
LomiriDeclarativeNetworkInfo::LomiriDeclarativeNetworkInfo(QObject *parent) |
| 57 |
: QObject(parent) |
| 58 |
, networkInfo(new LomiriNetworkInfo(this)) |
| 59 |
, isMonitorCurrentNetworkMode(false) |
| 60 |
, isMonitorNetworkSignalStrength(false) |
| 61 |
, isMonitorNetworkInterfaceCount(false) |
| 62 |
, isMonitorCurrentCellDataTechnology(false) |
| 63 |
, isMonitorNetworkStatus(false) |
| 64 |
, isMonitorCellId(false) |
| 65 |
, isMonitorCurrentMobileCountryCode(false) |
| 66 |
, isMonitorCurrentMobileNetworkCode(false) |
| 67 |
, isMonitorLocationAreaCode(false) |
| 68 |
, isMonitorNetworkName(false) |
| 69 |
{ |
| 70 |
connect(networkInfo, SIGNAL(networkInterfaceCountChanged(LomiriNetworkInfo::NetworkMode,int)), |
| 71 |
this, SLOT(_q_networkInterfaceCountChanged(LomiriNetworkInfo::NetworkMode,int))); |
| 72 |
connect(networkInfo, SIGNAL(currentCellDataTechnologyChanged(int,LomiriNetworkInfo::CellDataTechnology)), |
| 73 |
this, SLOT(_q_currentCellDataTechnologyChanged(int,LomiriNetworkInfo::CellDataTechnology))); |
| 74 |
connect(networkInfo, SIGNAL(cellIdChanged(int,QString)), this, SIGNAL(cellIdChanged(int,QString))); |
| 75 |
connect(networkInfo, SIGNAL(currentMobileCountryCodeChanged(int,QString)), |
| 76 |
this, SIGNAL(currentMobileCountryCodeChanged(int,QString))); |
| 77 |
connect(networkInfo, SIGNAL(currentMobileNetworkCodeChanged(int,QString)), |
| 78 |
this, SIGNAL(currentMobileNetworkCodeChanged(int,QString))); |
| 79 |
connect(networkInfo, SIGNAL(locationAreaCodeChanged(int,QString)), |
| 80 |
this, SIGNAL(locationAreaCodeChanged(int,QString))); |
| 81 |
} |
| 82 |
|
| 83 |
/*! |
| 84 |
\internal |
| 85 |
*/ |
| 86 |
LomiriDeclarativeNetworkInfo::~LomiriDeclarativeNetworkInfo() |
| 87 |
{ |
| 88 |
} |
| 89 |
|
| 90 |
/*! |
| 91 |
\qmlproperty bool NetworkInfo::monitorCurrentNetworkMode |
| 92 |
|
| 93 |
This property holds whether or not monitor the change of current network mode. |
| 94 |
*/ |
| 95 |
bool LomiriDeclarativeNetworkInfo::monitorCurrentNetworkMode() const |
| 96 |
{ |
| 97 |
return isMonitorCurrentNetworkMode; |
| 98 |
} |
| 99 |
|
| 100 |
void LomiriDeclarativeNetworkInfo::setMonitorCurrentNetworkMode(bool monitor) |
| 101 |
{ |
| 102 |
if (monitor != isMonitorCurrentNetworkMode) { |
| 103 |
isMonitorCurrentNetworkMode = monitor; |
| 104 |
if (monitor) { |
| 105 |
connect(networkInfo, SIGNAL(currentNetworkModeChanged(LomiriNetworkInfo::NetworkMode)), |
| 106 |
this, SIGNAL(currentNetworkModeChanged())); |
| 107 |
} else { |
| 108 |
disconnect(networkInfo, SIGNAL(currentNetworkModeChanged(LomiriNetworkInfo::NetworkMode)), |
| 109 |
this, SIGNAL(currentNetworkModeChanged())); |
| 110 |
} |
| 111 |
Q_EMIT monitorCurrentNetworkModeChanged(); |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
/*! |
| 116 |
\qmlproperty enumeration NetworkInfo::currentNetworkMode |
| 117 |
|
| 118 |
This property holds the current network mode. Possible values are: |
| 119 |
\list |
| 120 |
\li NetworkInfo.UnknownMode - The network is unknown or an error occured. |
| 121 |
\li NetworkInfo.GsmMode - Global System for Mobile (GSM) network. |
| 122 |
\li NetworkInfo.CdmaMode - Code Division Multiple Access (CDMA) network. |
| 123 |
\li NetworkInfo.WcdmaMode - Wideband Code Division Multiple Access (WCDMA) network. |
| 124 |
\li NetworkInfo.WlanMode - Wireless local area network (WLAN) network. |
| 125 |
\li NetworkInfo.EthernetMode - Local area network (LAN), or Ethernet network. |
| 126 |
\li NetworkInfo.BluetoothMode - Bluetooth network. |
| 127 |
\li NetworkInfo.WimaxMode - Worldwide Interoperability for Microwave Access (WiMAX) network. |
| 128 |
\li NetworkInfo.LteMode - 3GPP Long Term Evolution (LTE) network. |
| 129 |
\li NetworkInfo.TdscdmaMode - Time Division Synchronous Code Division Multiple Access (TD-SCDMA) network. |
| 130 |
\endlist |
| 131 |
*/ |
| 132 |
LomiriDeclarativeNetworkInfo::NetworkMode LomiriDeclarativeNetworkInfo::currentNetworkMode() const |
| 133 |
{ |
| 134 |
return static_cast<LomiriDeclarativeNetworkInfo::NetworkMode>(networkInfo->currentNetworkMode()); |
| 135 |
} |
| 136 |
|
| 137 |
/*! |
| 138 |
\qmlproperty bool NetworkInfo::monitorNetworkSignalStrength |
| 139 |
|
| 140 |
This property holds whether or not monitor the change of network signal strength. |
| 141 |
*/ |
| 142 |
bool LomiriDeclarativeNetworkInfo::monitorNetworkSignalStrength() const |
| 143 |
{ |
| 144 |
return isMonitorNetworkSignalStrength; |
| 145 |
} |
| 146 |
|
| 147 |
void LomiriDeclarativeNetworkInfo::setMonitorNetworkSignalStrength(bool monitor) |
| 148 |
{ |
| 149 |
if (monitor != isMonitorNetworkSignalStrength) { |
| 150 |
isMonitorNetworkSignalStrength = monitor; |
| 151 |
if (monitor) { |
| 152 |
connect(networkInfo, SIGNAL(networkSignalStrengthChanged(LomiriNetworkInfo::NetworkMode,int,int)), |
| 153 |
this, SLOT(_q_networkSignalStrengthChanged(LomiriNetworkInfo::NetworkMode,int,int))); |
| 154 |
} else { |
| 155 |
disconnect(networkInfo, SIGNAL(networkSignalStrengthChanged(LomiriNetworkInfo::NetworkMode,int,int)), |
| 156 |
this, SLOT(_q_networkSignalStrengthChanged(LomiriNetworkInfo::NetworkMode,int,int))); |
| 157 |
} |
| 158 |
Q_EMIT monitorNetworkSignalStrengthChanged(); |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
/*! |
| 163 |
\qmlmethod int NetworkInfo::networkSignalStrength(NetworkMode mode, int interface) |
| 164 |
|
| 165 |
Returns the signal strength of the given \a mode and \a interface. If the information |
| 166 |
is not available, or error occurs, -1 is returned. |
| 167 |
*/ |
| 168 |
int LomiriDeclarativeNetworkInfo::networkSignalStrength(NetworkMode mode, int interface) const |
| 169 |
{ |
| 170 |
return networkInfo->networkSignalStrength(static_cast<LomiriNetworkInfo::NetworkMode>(mode), interface); |
| 171 |
} |
| 172 |
|
| 173 |
/*! |
| 174 |
\qmlsignal NetworkInfo::onNetworkSignalStrengthChanged(NetworkMode mode, int interfaceIndex, int strength) |
| 175 |
|
| 176 |
This handler is called whenever the signal strength for the \a interfaceIndex of \a mode has changed |
| 177 |
to \a strength. Note that it won't be called until monitorNetworkSignalStrength is set true. |
| 178 |
|
| 179 |
\sa networkSignalStrength, monitorNetworkSignalStrength |
| 180 |
*/ |
| 181 |
void LomiriDeclarativeNetworkInfo::_q_networkSignalStrengthChanged(LomiriNetworkInfo::NetworkMode mode, int interface, int strength) |
| 182 |
{ |
| 183 |
Q_EMIT networkSignalStrengthChanged(static_cast<NetworkMode>(mode), interface, strength); |
| 184 |
} |
| 185 |
|
| 186 |
/*! |
| 187 |
\qmlproperty bool NetworkInfo::monitorNetworkInterfaceCount |
| 188 |
|
| 189 |
This property is obsoleted, and will be removed soon. You don't need to use it at all. |
| 190 |
*/ |
| 191 |
bool LomiriDeclarativeNetworkInfo::monitorNetworkInterfaceCount() const |
| 192 |
{ |
| 193 |
return isMonitorNetworkInterfaceCount; |
| 194 |
} |
| 195 |
|
| 196 |
void LomiriDeclarativeNetworkInfo::setMonitorNetworkInterfaceCount(bool monitor) |
| 197 |
{ |
| 198 |
if (monitor != isMonitorNetworkInterfaceCount) { |
| 199 |
isMonitorNetworkInterfaceCount = monitor; |
| 200 |
if (monitor) { |
| 201 |
connect(networkInfo, SIGNAL(networkInterfaceCountChanged(LomiriNetworkInfo::NetworkMode,int)), |
| 202 |
this, SLOT(_q_networkInterfaceCountChanged(LomiriNetworkInfo::NetworkMode,int))); |
| 203 |
} else { |
| 204 |
disconnect(networkInfo, SIGNAL(networkInterfaceCountChanged(LomiriNetworkInfo::NetworkMode,int)), |
| 205 |
this, SLOT(_q_networkInterfaceCountChanged(LomiriNetworkInfo::NetworkMode,int))); |
| 206 |
} |
| 207 |
Q_EMIT monitorNetworkInterfaceCountChanged(); |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
/*! |
| 212 |
\qmlmethod int NetworkInfo::networkInterfaceCount(NetworkMode mode) |
| 213 |
|
| 214 |
Returns the interface count of the given \a mode. |
| 215 |
*/ |
| 216 |
int LomiriDeclarativeNetworkInfo::networkInterfaceCount(NetworkMode mode) const |
| 217 |
{ |
| 218 |
return networkInfo->networkInterfaceCount(static_cast<LomiriNetworkInfo::NetworkMode>(mode)); |
| 219 |
} |
| 220 |
|
| 221 |
/*! |
| 222 |
\qmlsignal NetworkInfo::onNetworkInterfaceCountChanged(NetworkMode mode, int count) |
| 223 |
|
| 224 |
This handler is called whenever the number of interfaces of \a mode has changed to \a count. |
| 225 |
Note that it won't called until monitorNetworkInterfaceCount is set true. |
| 226 |
|
| 227 |
\sa networkInterfaceCount, monitorNetworkInterfaceCount |
| 228 |
*/ |
| 229 |
void LomiriDeclarativeNetworkInfo::_q_networkInterfaceCountChanged(LomiriNetworkInfo::NetworkMode mode, int count) |
| 230 |
{ |
| 231 |
Q_EMIT networkInterfaceCountChanged(static_cast<NetworkMode>(mode), count); |
| 232 |
} |
| 233 |
|
| 234 |
/*! |
| 235 |
\qmlproperty bool NetworkInfo::monitorCurrentCellDataTechnology |
| 236 |
|
| 237 |
This property is obsoleted, and will be removed soon. You don't need to use it at all. |
| 238 |
*/ |
| 239 |
bool LomiriDeclarativeNetworkInfo::monitorCurrentCellDataTechnology() const |
| 240 |
{ |
| 241 |
return isMonitorCurrentCellDataTechnology; |
| 242 |
} |
| 243 |
|
| 244 |
void LomiriDeclarativeNetworkInfo::setMonitorCurrentCellDataTechnology(bool monitor) |
| 245 |
{ |
| 246 |
if (monitor != isMonitorCurrentCellDataTechnology) { |
| 247 |
isMonitorCurrentCellDataTechnology = monitor; |
| 248 |
if (monitor) { |
| 249 |
connect(networkInfo, SIGNAL(currentCellDataTechnologyChanged(int,LomiriNetworkInfo::CellDataTechnology)), |
| 250 |
this, SLOT(_q_currentCellDataTechnologyChanged(int,LomiriNetworkInfo::CellDataTechnology))); |
| 251 |
} else { |
| 252 |
disconnect(networkInfo, SIGNAL(currentCellDataTechnologyChanged(int,LomiriNetworkInfo::CellDataTechnology)), |
| 253 |
this, SLOT(_q_currentCellDataTechnologyChanged(int,LomiriNetworkInfo::CellDataTechnology))); |
| 254 |
} |
| 255 |
Q_EMIT monitorCurrentCellDataTechnologyChanged(); |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
/*! |
| 260 |
\qmlmethod CellDataTechnology NetworkInfo::currentCellDataTechnology(int interface) |
| 261 |
|
| 262 |
Returns the current cell data technology of the given \a interface. Possible values are: |
| 263 |
\list |
| 264 |
\li NetworkInfo.UnknownDataTechnology - The cellular technology is unknown or an error occured. |
| 265 |
\li NetworkInfo.GprsDataTechnology - General Packet Radio Service (GPRS) data service. |
| 266 |
\li NetworkInfo.EdgeDataTechnology - Enhanced Data Rates for GSM Evolution (EDGE) data service. |
| 267 |
\li NetworkInfo.UmtsDataTechnology - Universal Mobile Telecommunications System (UMTS) data service. |
| 268 |
\li NetworkInfo.HspaDataTechnology - High Speed Packet Access (HSPA) data service. |
| 269 |
\endlist |
| 270 |
*/ |
| 271 |
int LomiriDeclarativeNetworkInfo::currentCellDataTechnology(int interface) const |
| 272 |
{ |
| 273 |
return networkInfo->currentCellDataTechnology(interface); |
| 274 |
} |
| 275 |
|
| 276 |
/*! |
| 277 |
\qmlsignal NetworkInfo::onCurrentCellDataTechnologyChanged(int interfaceIndex, CellDataTechnology tech) |
| 278 |
|
| 279 |
This handler is called whenever the cell data technology of \a interfaceIndex has been changed to \a tech. |
| 280 |
Note that the signal won't emit until monitorCurrentCellDataTechnology is set true. |
| 281 |
|
| 282 |
\sa currentCellDataTechnology, monitorCurrentCellDataTechnology |
| 283 |
*/ |
| 284 |
void LomiriDeclarativeNetworkInfo::_q_currentCellDataTechnologyChanged(int interface, LomiriNetworkInfo::CellDataTechnology tech) |
| 285 |
{ |
| 286 |
Q_EMIT currentCellDataTechnologyChanged(interface, static_cast<CellDataTechnology>(tech)); |
| 287 |
} |
| 288 |
|
| 289 |
/*! |
| 290 |
\qmlproperty bool NetworkInfo::monitorNetworkStatus |
| 291 |
|
| 292 |
This property holds whether or not monitor the network status. |
| 293 |
*/ |
| 294 |
bool LomiriDeclarativeNetworkInfo::monitorNetworkStatus() const |
| 295 |
{ |
| 296 |
return isMonitorNetworkStatus; |
| 297 |
} |
| 298 |
|
| 299 |
void LomiriDeclarativeNetworkInfo::setMonitorNetworkStatus(bool monitor) |
| 300 |
{ |
| 301 |
if (monitor != isMonitorNetworkStatus) { |
| 302 |
isMonitorNetworkStatus = monitor; |
| 303 |
if (monitor) { |
| 304 |
connect(networkInfo, SIGNAL(networkStatusChanged(LomiriNetworkInfo::NetworkMode,int,LomiriNetworkInfo::NetworkStatus)), |
| 305 |
this, SLOT(_q_networkStatusChanged(LomiriNetworkInfo::NetworkMode,int,LomiriNetworkInfo::NetworkStatus))); |
| 306 |
} else { |
| 307 |
disconnect(networkInfo, SIGNAL(networkStatusChanged(LomiriNetworkInfo::NetworkMode,int,LomiriNetworkInfo::NetworkStatus)), |
| 308 |
this, SLOT(_q_networkStatusChanged(LomiriNetworkInfo::NetworkMode,int,LomiriNetworkInfo::NetworkStatus))); |
| 309 |
} |
| 310 |
Q_EMIT monitorNetworkStatusChanged(); |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
/*! |
| 315 |
\qmlmethod NetworkStatus NetworkInfo::networkStatus(NetworkMode mode, int interface) |
| 316 |
|
| 317 |
Returns the status of the given \a mode and \a interface. Possible values are: |
| 318 |
\list |
| 319 |
\li NetworkInfo.UnknownStatus - The status is unknown or an error occured. |
| 320 |
\li NetworkInfo.NoNetworkAvailable - There is no network available. |
| 321 |
\li NetworkInfo.EmergencyOnly - The network only allows emergency calls. |
| 322 |
\li NetworkInfo.Searching - The device is searching or connecting to the network. |
| 323 |
\li NetworkInfo.Busy - The network is too busy to be connected. |
| 324 |
\li NetworkInfo.Denied - The connection to the network has been denied. |
| 325 |
\li NetworkInfo.HomeNetwork - The device is connected to the home network. |
| 326 |
\li NetworkInfo.Roaming - The device is connected to some roaming network. |
| 327 |
\endlist |
| 328 |
*/ |
| 329 |
int LomiriDeclarativeNetworkInfo::networkStatus(LomiriDeclarativeNetworkInfo::NetworkMode mode, int interface) const |
| 330 |
{ |
| 331 |
return networkInfo->networkStatus(static_cast<LomiriNetworkInfo::NetworkMode>(mode), interface); |
| 332 |
} |
| 333 |
|
| 334 |
/*! |
| 335 |
\qmlsignal NetworkInfo::onNetworkStatusChanged(NetworkMode mode, int interfaceIndex, NetworkStatus status) |
| 336 |
|
| 337 |
This handler is called whenever the status of \a mode and \a interfaceIndex has been changed to \a status. |
| 338 |
Note that it won't be called until monitorNetworkStatus is set true. |
| 339 |
|
| 340 |
\sa networkStatus, monitorNetworkStatus |
| 341 |
*/ |
| 342 |
void LomiriDeclarativeNetworkInfo::_q_networkStatusChanged(LomiriNetworkInfo::NetworkMode mode, int interface, LomiriNetworkInfo::NetworkStatus status) |
| 343 |
{ |
| 344 |
Q_EMIT networkStatusChanged(static_cast<NetworkMode>(mode), interface, static_cast<NetworkStatus>(status)); |
| 345 |
} |
| 346 |
|
| 347 |
/*! |
| 348 |
\qmlproperty bool NetworkInfo::monitorCellId |
| 349 |
|
| 350 |
This property is obsoleted, and will be removed soon. You don't need to use it at all. |
| 351 |
*/ |
| 352 |
bool LomiriDeclarativeNetworkInfo::monitorCellId() const |
| 353 |
{ |
| 354 |
return isMonitorCellId; |
| 355 |
} |
| 356 |
|
| 357 |
void LomiriDeclarativeNetworkInfo::setMonitorCellId(bool monitor) |
| 358 |
{ |
| 359 |
if (monitor != isMonitorCellId) { |
| 360 |
isMonitorCellId = monitor; |
| 361 |
if (monitor) { |
| 362 |
connect(networkInfo, SIGNAL(cellIdChanged(int,QString)), |
| 363 |
this, SIGNAL(cellIdChanged(int,QString))); |
| 364 |
} else { |
| 365 |
disconnect(networkInfo, SIGNAL(cellIdChanged(int,QString)), |
| 366 |
this, SIGNAL(cellIdChanged(int,QString))); |
| 367 |
} |
| 368 |
Q_EMIT monitorCellIdChanged(); |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
/*! |
| 373 |
\qmlmethod string NetworkInfo::cellId(int interface) |
| 374 |
|
| 375 |
Returns the cell ID of the given \a interface. If this information |
| 376 |
is not available or error occurs, an empty string is returned. |
| 377 |
|
| 378 |
\sa onCellIdChanged |
| 379 |
*/ |
| 380 |
QString LomiriDeclarativeNetworkInfo::cellId(int interface) const |
| 381 |
{ |
| 382 |
return networkInfo->cellId(interface); |
| 383 |
} |
| 384 |
|
| 385 |
/*! |
| 386 |
\qmlsignal NetworkInfo::onCellIdChanged(int interfaceIndex, string id) |
| 387 |
|
| 388 |
This handler is called whenever the cell ID of \a interfaceIndex has been changed to \a id. |
| 389 |
Note that it won't be called unless monitorCellId is set true. |
| 390 |
|
| 391 |
\sa cellId, monitorCellId |
| 392 |
*/ |
| 393 |
|
| 394 |
/*! |
| 395 |
\qmlproperty bool NetworkInfo::monitorCurrentMobileCountryCode |
| 396 |
|
| 397 |
This property is obsoleted, and will be removed soon. You don't need to use it at all. |
| 398 |
*/ |
| 399 |
bool LomiriDeclarativeNetworkInfo::monitorCurrentMobileCountryCode() const |
| 400 |
{ |
| 401 |
return isMonitorCurrentMobileCountryCode; |
| 402 |
} |
| 403 |
|
| 404 |
void LomiriDeclarativeNetworkInfo::setMonitorCurrentMobileCountryCode(bool monitor) |
| 405 |
{ |
| 406 |
if (monitor != isMonitorCurrentMobileCountryCode) { |
| 407 |
isMonitorCurrentMobileCountryCode = monitor; |
| 408 |
if (monitor) { |
| 409 |
connect(networkInfo, SIGNAL(currentMobileCountryCodeChanged(int,QString)), |
| 410 |
this, SIGNAL(currentMobileCountryCodeChanged(int,QString))); |
| 411 |
} else { |
| 412 |
disconnect(networkInfo, SIGNAL(currentMobileCountryCodeChanged(int,QString)), |
| 413 |
this, SIGNAL(currentMobileCountryCodeChanged(int,QString))); |
| 414 |
} |
| 415 |
Q_EMIT monitorCurrentMobileCountryCodeChanged(); |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
/*! |
| 420 |
\qmlmethod string NetworkInfo::currentMobileCountryCode(int interface) |
| 421 |
|
| 422 |
Returns the current mobile country code of the given \a interface. If this information |
| 423 |
is not available or error occurs, an empty string is returned. |
| 424 |
*/ |
| 425 |
QString LomiriDeclarativeNetworkInfo::currentMobileCountryCode(int interface) const |
| 426 |
{ |
| 427 |
return networkInfo->currentMobileCountryCode(interface); |
| 428 |
} |
| 429 |
|
| 430 |
/*! |
| 431 |
\qmlsignal NetworkInfo::onCurrentMobileCountryCodeChanged(int interfaceIndex, string mcc) |
| 432 |
|
| 433 |
This handler is called whenever the current mobile country code of \a interfaceIndex has been changed |
| 434 |
to \a mcc. Note that it won't be called unless monitorCurrentMobileCountryCode is set true. |
| 435 |
|
| 436 |
\sa currentMobileCountryCode, monitorCurrentMobileCountryCode |
| 437 |
*/ |
| 438 |
|
| 439 |
/*! |
| 440 |
\qmlproperty bool NetworkInfo::monitorCurrentMobileNetworkCode |
| 441 |
|
| 442 |
This property is obsoleted, and will be removed soon. You don't need to use it at all. |
| 443 |
*/ |
| 444 |
bool LomiriDeclarativeNetworkInfo::monitorCurrentMobileNetworkCode() const |
| 445 |
{ |
| 446 |
return isMonitorCurrentMobileNetworkCode; |
| 447 |
} |
| 448 |
|
| 449 |
void LomiriDeclarativeNetworkInfo::setMonitorCurrentMobileNetworkCode(bool monitor) |
| 450 |
{ |
| 451 |
if (monitor != isMonitorCurrentMobileNetworkCode) { |
| 452 |
isMonitorCurrentMobileNetworkCode = monitor; |
| 453 |
if (monitor) { |
| 454 |
connect(networkInfo, SIGNAL(currentMobileNetworkCodeChanged(int,QString)), |
| 455 |
this, SIGNAL(currentMobileNetworkCodeChanged(int,QString))); |
| 456 |
} else { |
| 457 |
disconnect(networkInfo, SIGNAL(currentMobileNetworkCodeChanged(int,QString)), |
| 458 |
this, SIGNAL(currentMobileNetworkCodeChanged(int,QString))); |
| 459 |
} |
| 460 |
Q_EMIT monitorCurrentMobileNetworkCodeChanged(); |
| 461 |
} |
| 462 |
} |
| 463 |
|
| 464 |
/*! |
| 465 |
\qmlmethod string NetworkInfo::currentMobileNetworkCode(int interface) |
| 466 |
|
| 467 |
Returns the current mobile network code of the given \a interface. If this information |
| 468 |
is not available or error occurs, an empty string is returned. |
| 469 |
*/ |
| 470 |
QString LomiriDeclarativeNetworkInfo::currentMobileNetworkCode(int interface) const |
| 471 |
{ |
| 472 |
return networkInfo->currentMobileNetworkCode(interface); |
| 473 |
} |
| 474 |
|
| 475 |
/*! |
| 476 |
\qmlsignal NetworkInfo::onCurrentMobileNetworkCodeChanged(int interfaceIndex, string mnc) |
| 477 |
|
| 478 |
This handler is called whenever the current mobile network code of \a interfaceIndex has been changed |
| 479 |
to \a mnc. Note that it won't be called unless monitorCurrentMobileNetworkCode is set true. |
| 480 |
|
| 481 |
\sa currentMobileNetworkCode, monitorCurrentMobileNetworkCode |
| 482 |
*/ |
| 483 |
|
| 484 |
/*! |
| 485 |
\qmlproperty bool NetworkInfo::monitorLocationAreaCode |
| 486 |
|
| 487 |
This property is obsoleted, and will be removed soon. You don't need to use it at all. |
| 488 |
*/ |
| 489 |
bool LomiriDeclarativeNetworkInfo::monitorLocationAreaCode() const |
| 490 |
{ |
| 491 |
return isMonitorLocationAreaCode; |
| 492 |
} |
| 493 |
|
| 494 |
void LomiriDeclarativeNetworkInfo::setMonitorLocationAreaCode(bool monitor) |
| 495 |
{ |
| 496 |
if (monitor != isMonitorLocationAreaCode) { |
| 497 |
isMonitorLocationAreaCode = monitor; |
| 498 |
if (monitor) { |
| 499 |
connect(networkInfo, SIGNAL(locationAreaCodeChanged(int,QString)), |
| 500 |
this, SIGNAL(locationAreaCodeChanged(int,QString))); |
| 501 |
} else { |
| 502 |
disconnect(networkInfo, SIGNAL(locationAreaCodeChanged(int,QString)), |
| 503 |
this, SIGNAL(locationAreaCodeChanged(int,QString))); |
| 504 |
} |
| 505 |
Q_EMIT monitorLocationAreaCodeChanged(); |
| 506 |
} |
| 507 |
} |
| 508 |
|
| 509 |
/*! |
| 510 |
\qmlmethod string NetworkInfo::locationAreaCode(int interface) |
| 511 |
|
| 512 |
Returns the location area code of the given \a interface. If this information |
| 513 |
is not available or error occurs, an empty string is returned. |
| 514 |
*/ |
| 515 |
QString LomiriDeclarativeNetworkInfo::locationAreaCode(int interface) const |
| 516 |
{ |
| 517 |
return networkInfo->locationAreaCode(interface); |
| 518 |
} |
| 519 |
|
| 520 |
/*! |
| 521 |
\qmlsignal NetworkInfo::onLocationAreaCodeChanged(int interfaceIndex, string lac) |
| 522 |
|
| 523 |
This handler is called whenever the location area code of \a interfaceIndex has been changed to \a lac. |
| 524 |
Note that it won't be called unless monitorLocationAreaCode is set true. |
| 525 |
|
| 526 |
\sa locationAreaCode, monitorLocationAreaCode |
| 527 |
*/ |
| 528 |
|
| 529 |
/*! |
| 530 |
\qmlproperty bool NetworkInfo::monitorNetworkName |
| 531 |
|
| 532 |
This property holds whether or not monitor the change of network names. |
| 533 |
*/ |
| 534 |
bool LomiriDeclarativeNetworkInfo::monitorNetworkName() const |
| 535 |
{ |
| 536 |
return isMonitorNetworkName; |
| 537 |
} |
| 538 |
|
| 539 |
void LomiriDeclarativeNetworkInfo::setMonitorNetworkName(bool monitor) |
| 540 |
{ |
| 541 |
if (monitor != isMonitorNetworkName) { |
| 542 |
isMonitorNetworkName = monitor; |
| 543 |
if (monitor) { |
| 544 |
connect(networkInfo, SIGNAL(networkNameChanged(LomiriNetworkInfo::NetworkMode,int,QString)), |
| 545 |
this, SLOT(_q_networkNameChanged(LomiriNetworkInfo::NetworkMode,int,QString))); |
| 546 |
} else { |
| 547 |
disconnect(networkInfo, SIGNAL(networkNameChanged(LomiriNetworkInfo::NetworkMode,int,QString)), |
| 548 |
this, SLOT(_q_networkNameChanged(LomiriNetworkInfo::NetworkMode,int,QString))); |
| 549 |
} |
| 550 |
Q_EMIT monitorNetworkNameChanged(); |
| 551 |
} |
| 552 |
} |
| 553 |
|
| 554 |
/*! |
| 555 |
\qmlmethod string NetworkInfo::networkName(NetworkMode mode, int interface) |
| 556 |
|
| 557 |
Returns the name of the given \a mode and \a interface. If the information is not available, |
| 558 |
or an error occurs, an empty string is returned. |
| 559 |
|
| 560 |
In case of WLAN, the SSID is returned; for Ethernet, the domain name is returned if available. |
| 561 |
*/ |
| 562 |
QString LomiriDeclarativeNetworkInfo::networkName(NetworkMode mode, int interface) const |
| 563 |
{ |
| 564 |
return networkInfo->networkName(static_cast<LomiriNetworkInfo::NetworkMode>(mode), interface); |
| 565 |
} |
| 566 |
|
| 567 |
/*! |
| 568 |
\qmlsignal NetworkInfo::onNetworkNameChanged(NetworkMode mode, int interfaceIndex, string name) |
| 569 |
|
| 570 |
This handler is called whenever the network name of \a mode and \a interfaceIndex has been changed |
| 571 |
to \a name. Note that it won't called until monitorNetworkName is set true. |
| 572 |
|
| 573 |
\sa networkName, monitorNetworkName |
| 574 |
*/ |
| 575 |
void LomiriDeclarativeNetworkInfo::_q_networkNameChanged(LomiriNetworkInfo::NetworkMode mode, int interface, const QString &name) |
| 576 |
{ |
| 577 |
Q_EMIT networkNameChanged(static_cast<NetworkMode>(mode), interface, name); |
| 578 |
} |
| 579 |
|
| 580 |
/*! |
| 581 |
\qmlmethod string NetworkInfo::macAddress(NetworkMode mode, int interface) |
| 582 |
|
| 583 |
Returns the MAC address for \a interface of \a mode. If the MAC address is not available or error |
| 584 |
occurs, an empty string is returned. |
| 585 |
*/ |
| 586 |
QString LomiriDeclarativeNetworkInfo::macAddress(LomiriDeclarativeNetworkInfo::NetworkMode mode, int interface) const |
| 587 |
{ |
| 588 |
return networkInfo->macAddress(static_cast<LomiriNetworkInfo::NetworkMode>(mode), interface); |
| 589 |
} |
| 590 |
|
| 591 |
/*! |
| 592 |
\qmlmethod string NetworkInfo::homeMobileCountryCode(int interface) |
| 593 |
|
| 594 |
Returns the home Mobile Country Code (MCC) for \a interface. An empty string is returned if the |
| 595 |
information is not available or on error. |
| 596 |
*/ |
| 597 |
QString LomiriDeclarativeNetworkInfo::homeMobileCountryCode(int interface) const |
| 598 |
{ |
| 599 |
return networkInfo->homeMobileCountryCode(interface); |
| 600 |
} |
| 601 |
|
| 602 |
/*! |
| 603 |
\qmlmethod string NetworkInfo::homeMobileNetworkCode(int interface) |
| 604 |
|
| 605 |
Returns the home Mobile Network Code (MNC) for \a interface. An empty string is returned if the |
| 606 |
information is not available or on error. |
| 607 |
*/ |
| 608 |
QString LomiriDeclarativeNetworkInfo::homeMobileNetworkCode(int interface) const |
| 609 |
{ |
| 610 |
return networkInfo->homeMobileNetworkCode(interface); |
| 611 |
} |
| 612 |
|
| 613 |
/*! |
| 614 |
\qmlmethod string NetworkInfo::imsi(int interface) |
| 615 |
|
| 616 |
Returns the International Mobile Subscriber Identity (IMSI) for \a interface. If this information is |
| 617 |
not available, or error occurs, an empty string is returned. |
| 618 |
*/ |
| 619 |
QString LomiriDeclarativeNetworkInfo::imsi(int interface) const |
| 620 |
{ |
| 621 |
return networkInfo->imsi(interface); |
| 622 |
} |
| 623 |
|
| 624 |
QT_END_NAMESPACE |