~ubuntu-branches/ubuntu/utopic/qtsystems-opensource-src/utopic-proposed

« back to all changes in this revision

Viewing changes to src/systeminfo/linux/qofonowrapper.cpp

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-07-12 13:41:02 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130712134102-o5l4izefcde4dyab
Tags: 5.0~git20130712-0ubuntu1
* Configure with CONFIG+=ofono (LP: #1199185)
* New upstream snapshot fa61ba41b962aa66bf6dc62ce62ce0734063abf9.
  - Fixes oFono segfault (LP: #1199813)
  - Remove some of the examples that aren't installed anymore
* Add Vcs-Bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
210
210
QString QOfonoWrapper::homeMcc(const QString &modemPath)
211
211
{
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")));
214
214
 
215
 
    return reply.value().value(QString(QStringLiteral("MobileCountryCode"))).toString();
 
215
    return reply.value().value(QStringLiteral("MobileCountryCode")).toString();
216
216
}
217
217
 
218
218
QString QOfonoWrapper::homeMnc(const QString &modemPath)
219
219
{
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")));
222
222
 
223
 
    return reply.value().value(QString(QStringLiteral("MobileNetworkCode"))).toString();
 
223
    return reply.value().value(QStringLiteral("MobileNetworkCode")).toString();
224
224
}
225
225
 
226
226
QString QOfonoWrapper::imsi(const QString &modemPath)
227
227
{
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")));
230
230
 
231
 
    return reply.value().value(QString(QStringLiteral("SubscriberIdentity"))).toString();
 
231
    return reply.value().value(QStringLiteral("SubscriberIdentity")).toString();
232
232
}
233
233
 
234
234
// Modem Interface
235
235
QString QOfonoWrapper::imei(const QString &modemPath)
236
236
{
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")));
239
239
 
240
 
    return reply.value().value(QString(QStringLiteral("Serial"))).toString();
 
240
    return reply.value().value(QStringLiteral("Serial")).toString();
241
241
}
242
242
 
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
291
292
            QDBusConnection::systemBus().connect(*OFONO_SERVICE(),
292
293
                                                 modem,
293
294
                                                 *OFONO_NETWORK_REGISTRATION_INTERFACE(),
294
 
                                                 QString(QStringLiteral("PropertyChanged")),
 
295
                                                 QStringLiteral("PropertyChanged"),
295
296
                                                 this, SLOT(onOfonoPropertyChanged(QString,QDBusVariant)));
296
297
        }
297
298
        watchProperties = true;
313
314
 
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
332
334
            QDBusConnection::systemBus().disconnect(*OFONO_SERVICE(),
333
335
                                                    modem,
334
336
                                                    *OFONO_NETWORK_REGISTRATION_INTERFACE(),
335
 
                                                    QString(QStringLiteral("PropertyChanged")),
 
337
                                                    QStringLiteral("PropertyChanged"),
336
338
                                                    this, SLOT(onOfonoPropertyChanged(QString,QDBusVariant)));
337
339
        }
338
340
    }
363
365
 
364
366
    int interface = allModems().indexOf(message().path());
365
367
 
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()));
382
384
}
383
385
 
384
386
QNetworkInfo::CellDataTechnology QOfonoWrapper::technologyStringToEnum(const QString &technology)
385
387
{
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;
392
394
    else
393
395
        return QNetworkInfo::UnknownDataTechnology;
395
397
 
396
398
QNetworkInfo::NetworkMode QOfonoWrapper::technologyToMode(const QString &technology)
397
399
{
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;
406
408
    } else {
407
409
        return QNetworkInfo::CdmaMode;
410
412
 
411
413
QNetworkInfo::NetworkStatus QOfonoWrapper::statusStringToEnum(const QString &status)
412
414
{
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;
423
425
    else
424
426
        return QNetworkInfo::UnknownStatus;
427
429
QString QOfonoWrapper::currentTechnology(const QString &modemPath)
428
430
{
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")));
431
433
 
432
 
    return reply.value().value(QString(QStringLiteral("Technology"))).toString();
 
434
    return reply.value().value(QStringLiteral("Technology")).toString();
433
435
}
434
436
 
435
437
// Manager Interface
436
438
QStringList QOfonoWrapper::getAllModems()
437
439
{
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")));
440
442
 
441
443
    QStringList modems;
442
444
    if (reply.isValid()) {
450
452
int QOfonoWrapper::getSignalStrength(const QString &modemPath)
451
453
{
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")));
454
456
 
455
 
    return reply.value().value(QString(QStringLiteral("Strength"))).toInt();
 
457
    return reply.value().value(QStringLiteral("Strength")).toInt();
456
458
}
457
459
 
458
460
QNetworkInfo::CellDataTechnology QOfonoWrapper::getCurrentCellDataTechnology(const QString &modemPath)
463
465
QNetworkInfo::NetworkStatus QOfonoWrapper::getNetworkStatus(const QString &modemPath)
464
466
{
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")));
467
469
 
468
 
    return statusStringToEnum(reply.value().value(QString(QStringLiteral("Status"))).toString());
 
470
    return statusStringToEnum(reply.value().value(QStringLiteral("Status")).toString());
469
471
}
470
472
 
471
473
QString QOfonoWrapper::getCellId(const QString &modemPath)
472
474
{
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")));
475
477
 
476
 
    return reply.value().value(QString(QStringLiteral("CellId"))).toString();
 
478
    return reply.value().value(QStringLiteral("CellId")).toString();
477
479
}
478
480
 
479
481
QString QOfonoWrapper::getCurrentMcc(const QString &modemPath)
480
482
{
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")));
483
485
 
484
 
    return reply.value().value(QString(QStringLiteral("MobileCountryCode"))).toString();
 
486
    return reply.value().value(QStringLiteral("MobileCountryCode")).toString();
485
487
}
486
488
 
487
489
QString QOfonoWrapper::getCurrentMnc(const QString &modemPath)
488
490
{
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")));
491
493
 
492
 
    return reply.value().value(QString(QStringLiteral("MobileNetworkCode"))).toString();
 
494
    return reply.value().value(QStringLiteral("MobileNetworkCode")).toString();
493
495
}
494
496
 
495
497
QString QOfonoWrapper::getLac(const QString &modemPath)
496
498
{
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")));
499
501
 
500
 
    return reply.value().value(QString(QStringLiteral("LocationAreaCode"))).toString();
 
502
    return reply.value().value(QStringLiteral("LocationAreaCode")).toString();
501
503
}
502
504
 
503
505
QString QOfonoWrapper::getOperatorName(const QString &modemPath)
504
506
{
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")));
507
509
 
508
 
    return reply.value().value(QString(QStringLiteral("Name"))).toString();
 
510
    return reply.value().value(QStringLiteral("Name")).toString();
509
511
}
510
512
 
511
513
QT_END_NAMESPACE