210
210
QString QOfonoWrapper::homeMcc(const QString &modemPath)
212
212
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
213
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_SIM_MANAGER_INTERFACE(), QString(QStringLiteral("GetProperties"))));
213
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_SIM_MANAGER_INTERFACE(), QStringLiteral("GetProperties")));
215
return reply.value().value(QString(QStringLiteral("MobileCountryCode"))).toString();
215
return reply.value().value(QStringLiteral("MobileCountryCode")).toString();
218
218
QString QOfonoWrapper::homeMnc(const QString &modemPath)
220
220
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
221
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_SIM_MANAGER_INTERFACE(), QString(QStringLiteral("GetProperties"))));
221
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_SIM_MANAGER_INTERFACE(), QStringLiteral("GetProperties")));
223
return reply.value().value(QString(QStringLiteral("MobileNetworkCode"))).toString();
223
return reply.value().value(QStringLiteral("MobileNetworkCode")).toString();
226
226
QString QOfonoWrapper::imsi(const QString &modemPath)
228
228
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
229
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_SIM_MANAGER_INTERFACE(), QString(QStringLiteral("GetProperties"))));
229
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_SIM_MANAGER_INTERFACE(), QStringLiteral("GetProperties")));
231
return reply.value().value(QString(QStringLiteral("SubscriberIdentity"))).toString();
231
return reply.value().value(QStringLiteral("SubscriberIdentity")).toString();
234
234
// Modem Interface
235
235
QString QOfonoWrapper::imei(const QString &modemPath)
237
237
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
238
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_MODEM_INTERFACE(), QString(QStringLiteral(("GetProperties")))));
238
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_MODEM_INTERFACE(), QStringLiteral("GetProperties")));
240
return reply.value().value(QString(QStringLiteral("Serial"))).toString();
240
return reply.value().value(QStringLiteral("Serial")).toString();
243
243
void QOfonoWrapper::connectNotify(const QMetaMethod &signal)
256
256
if (signal == networkInterfaceCountChangedSignal) {
257
257
allModemPaths = getAllModems();
258
258
QDBusConnection::systemBus().connect(*OFONO_SERVICE(), *OFONO_MANAGER_PATH(), *OFONO_MANAGER_INTERFACE(),
259
QString(QStringLiteral("ModemAdded")),
259
QStringLiteral("ModemAdded"),
260
260
this, SLOT(onOfonoModemAdded(QDBusObjectPath)));
261
261
QDBusConnection::systemBus().connect(*OFONO_SERVICE(), *OFONO_MANAGER_PATH(), *OFONO_MANAGER_INTERFACE(),
262
QString(QStringLiteral("ModemRemoved")),
262
QStringLiteral("ModemRemoved"),
263
263
this, SLOT(onOfonoModemRemoved(QDBusObjectPath)));
264
264
watchAllModems = true;
265
265
} else if (signal == currentMobileCountryCodeChangedSignal
266
266
|| signal == currentMobileNetworkCodeChangedSignal
267
|| signal == currentNetworkModeChangedSignal
267
268
|| signal == cellIdChangedSignal
268
269
|| signal == currentCellDataTechnologyChangedSignal
269
270
|| signal == locationAreaCodeChangedSignal
314
315
if (signal == networkInterfaceCountChangedSignal) {
315
316
QDBusConnection::systemBus().disconnect(*OFONO_SERVICE(), *OFONO_MANAGER_PATH(), *OFONO_MANAGER_INTERFACE(),
316
QString(QStringLiteral("ModemAdded")),
317
QStringLiteral("ModemAdded"),
317
318
this, SLOT(onOfonoModemAdded(QDBusObjectPath)));
318
319
QDBusConnection::systemBus().disconnect(*OFONO_SERVICE(), *OFONO_MANAGER_PATH(), *OFONO_MANAGER_INTERFACE(),
319
QString(QStringLiteral("ModemRemoved")),
320
QStringLiteral("ModemRemoved"),
320
321
this, SLOT(onOfonoModemRemoved(QDBusObjectPath)));
321
322
watchAllModems = false;
322
} else if (signal == currentMobileCountryCodeChanged
323
} else if (signal == currentMobileCountryCodeChangedSignal
323
324
|| signal == currentMobileNetworkCodeChangedSignal
325
|| signal == currentNetworkModeChangedSignal
324
326
|| signal == cellIdChangedSignal
325
327
|| signal == currentCellDataTechnologyChangedSignal
326
328
|| signal == locationAreaCodeChangedSignal
364
366
int interface = allModems().indexOf(message().path());
366
if (property == QString(QStringLiteral("MobileCountryCode")))
368
if (property == QStringLiteral("MobileCountryCode"))
367
369
emit currentMobileCountryCodeChanged(interface, value.variant().toString());
368
else if (property == QString(QStringLiteral("MobileNetworkCode")))
370
else if (property == QStringLiteral("MobileNetworkCode"))
369
371
emit currentMobileNetworkCodeChanged(interface, value.variant().toString());
370
else if (property == QString(QStringLiteral("CellId")))
372
else if (property == QStringLiteral("CellId"))
371
373
emit cellIdChanged(interface, value.variant().toString());
372
else if (property == QString(QStringLiteral("Technology")))
374
else if (property == QStringLiteral("Technology"))
373
375
emit currentCellDataTechnologyChanged(interface, technologyStringToEnum(value.variant().toString()));
374
else if (property == QString(QStringLiteral("LocationAreaCode")))
376
else if (property == QStringLiteral("LocationAreaCode"))
375
377
emit locationAreaCodeChanged(interface, value.variant().toString());
376
else if (property == QString(QStringLiteral("Name")))
378
else if (property == QStringLiteral("Name"))
377
379
emit networkNameChanged(technologyToMode(currentTechnology(message().path())), interface, value.variant().toString());
378
else if (property == QString(QStringLiteral("Strength")))
380
else if (property == QStringLiteral("Strength"))
379
381
emit networkSignalStrengthChanged(technologyToMode(currentTechnology(message().path())), interface, value.variant().toInt());
380
else if (property == QString(QStringLiteral("Status")))
382
else if (property == QStringLiteral("Status"))
381
383
emit networkStatusChanged(technologyToMode(currentTechnology(message().path())), interface, statusStringToEnum(value.variant().toString()));
384
386
QNetworkInfo::CellDataTechnology QOfonoWrapper::technologyStringToEnum(const QString &technology)
386
if (technology == QString(QStringLiteral("edge")))
388
if (technology == QStringLiteral("edge"))
387
389
return QNetworkInfo::EdgeDataTechnology;
388
else if (technology == QString(QStringLiteral("umts")))
390
else if (technology == QStringLiteral("umts"))
389
391
return QNetworkInfo::UmtsDataTechnology;
390
else if (technology == QString(QStringLiteral("hspa")))
392
else if (technology == QStringLiteral("hspa"))
391
393
return QNetworkInfo::HspaDataTechnology;
393
395
return QNetworkInfo::UnknownDataTechnology;
396
398
QNetworkInfo::NetworkMode QOfonoWrapper::technologyToMode(const QString &technology)
398
if (technology == QString(QStringLiteral("lte"))) {
400
if (technology == QStringLiteral("lte")) {
399
401
return QNetworkInfo::LteMode;
400
} else if (technology == QString(QStringLiteral("hspa"))) {
402
} else if (technology == QStringLiteral("hspa")) {
401
403
return QNetworkInfo::WcdmaMode;
402
} else if (technology == QString(QStringLiteral("gsm"))
403
|| technology == QString(QStringLiteral("edge"))
404
|| technology == QString(QStringLiteral("umts"))) {
404
} else if (technology == QStringLiteral("gsm")
405
|| technology == QStringLiteral("edge")
406
|| technology == QStringLiteral("umts")) {
405
407
return QNetworkInfo::GsmMode;
407
409
return QNetworkInfo::CdmaMode;
411
413
QNetworkInfo::NetworkStatus QOfonoWrapper::statusStringToEnum(const QString &status)
413
if (status == QString(QStringLiteral("unregistered")))
415
if (status == QStringLiteral("unregistered"))
414
416
return QNetworkInfo::NoNetworkAvailable;
415
else if (status == QString(QStringLiteral("registered")))
417
else if (status == QStringLiteral("registered"))
416
418
return QNetworkInfo::HomeNetwork;
417
else if (status == QString(QStringLiteral("searching")))
419
else if (status == QStringLiteral("searching"))
418
420
return QNetworkInfo::Searching;
419
else if (status == QString(QStringLiteral("denied")))
421
else if (status == QStringLiteral("denied"))
420
422
return QNetworkInfo::Denied;
421
else if (status == QString(QStringLiteral("roaming")))
423
else if (status == QStringLiteral("roaming"))
422
424
return QNetworkInfo::Roaming;
424
426
return QNetworkInfo::UnknownStatus;
427
429
QString QOfonoWrapper::currentTechnology(const QString &modemPath)
429
431
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
430
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QString(QStringLiteral("GetProperties"))));
432
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QStringLiteral("GetProperties")));
432
return reply.value().value(QString(QStringLiteral("Technology"))).toString();
434
return reply.value().value(QStringLiteral("Technology")).toString();
435
437
// Manager Interface
436
438
QStringList QOfonoWrapper::getAllModems()
438
440
QDBusReply<QOfonoPropertyMap> reply = QDBusConnection::systemBus().call(
439
QDBusMessage::createMethodCall(*OFONO_SERVICE(), *OFONO_MANAGER_PATH(), *OFONO_MANAGER_INTERFACE(), QString(QStringLiteral("GetModems"))));
441
QDBusMessage::createMethodCall(*OFONO_SERVICE(), *OFONO_MANAGER_PATH(), *OFONO_MANAGER_INTERFACE(), QStringLiteral("GetModems")));
441
443
QStringList modems;
442
444
if (reply.isValid()) {
450
452
int QOfonoWrapper::getSignalStrength(const QString &modemPath)
452
454
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
453
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QString(QStringLiteral("GetProperties"))));
455
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QStringLiteral("GetProperties")));
455
return reply.value().value(QString(QStringLiteral("Strength"))).toInt();
457
return reply.value().value(QStringLiteral("Strength")).toInt();
458
460
QNetworkInfo::CellDataTechnology QOfonoWrapper::getCurrentCellDataTechnology(const QString &modemPath)
463
465
QNetworkInfo::NetworkStatus QOfonoWrapper::getNetworkStatus(const QString &modemPath)
465
467
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
466
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QString(QStringLiteral("GetProperties"))));
468
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QStringLiteral("GetProperties")));
468
return statusStringToEnum(reply.value().value(QString(QStringLiteral("Status"))).toString());
470
return statusStringToEnum(reply.value().value(QStringLiteral("Status")).toString());
471
473
QString QOfonoWrapper::getCellId(const QString &modemPath)
473
475
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
474
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QString(QStringLiteral("GetProperties"))));
476
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QStringLiteral("GetProperties")));
476
return reply.value().value(QString(QStringLiteral("CellId"))).toString();
478
return reply.value().value(QStringLiteral("CellId")).toString();
479
481
QString QOfonoWrapper::getCurrentMcc(const QString &modemPath)
481
483
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
482
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QString(QStringLiteral("GetProperties"))));
484
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QStringLiteral("GetProperties")));
484
return reply.value().value(QString(QStringLiteral("MobileCountryCode"))).toString();
486
return reply.value().value(QStringLiteral("MobileCountryCode")).toString();
487
489
QString QOfonoWrapper::getCurrentMnc(const QString &modemPath)
489
491
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
490
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QString(QStringLiteral("GetProperties"))));
492
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QStringLiteral("GetProperties")));
492
return reply.value().value(QString(QStringLiteral("MobileNetworkCode"))).toString();
494
return reply.value().value(QStringLiteral("MobileNetworkCode")).toString();
495
497
QString QOfonoWrapper::getLac(const QString &modemPath)
497
499
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
498
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QString(QStringLiteral("GetProperties"))));
500
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QStringLiteral("GetProperties")));
500
return reply.value().value(QString(QStringLiteral("LocationAreaCode"))).toString();
502
return reply.value().value(QStringLiteral("LocationAreaCode")).toString();
503
505
QString QOfonoWrapper::getOperatorName(const QString &modemPath)
505
507
QDBusReply<QVariantMap> reply = QDBusConnection::systemBus().call(
506
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QString(QStringLiteral("GetProperties"))));
508
QDBusMessage::createMethodCall(*OFONO_SERVICE(), modemPath, *OFONO_NETWORK_REGISTRATION_INTERFACE(), QStringLiteral("GetProperties")));
508
return reply.value().value(QString(QStringLiteral("Name"))).toString();
510
return reply.value().value(QStringLiteral("Name")).toString();