source: trunk/src/plugins/bearer/connman/qofonoservice_linux.cpp

Last change on this file was 846, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 30.2 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation (qt-info@nokia.com)
6**
7** This file is part of the plugins of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <QObject>
43#include <QList>
44#include <QtDBus/QtDBus>
45#include <QtDBus/QDBusConnection>
46#include <QtDBus/QDBusError>
47#include <QtDBus/QDBusInterface>
48#include <QtDBus/QDBusMessage>
49#include <QtDBus/QDBusReply>
50#include <QtDBus/QDBusPendingCallWatcher>
51#include <QtDBus/QDBusObjectPath>
52#include <QtDBus/QDBusPendingCall>
53
54#include "qofonoservice_linux_p.h"
55
56
57QT_BEGIN_NAMESPACE
58static QDBusConnection dbusConnection = QDBusConnection::systemBus();
59
60
61QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent)
62 : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
63 QLatin1String(OFONO_MANAGER_PATH),
64 OFONO_MANAGER_INTERFACE,
65 QDBusConnection::systemBus(), parent)
66{
67}
68
69QOfonoManagerInterface::~QOfonoManagerInterface()
70{
71}
72
73QList <QDBusObjectPath> QOfonoManagerInterface::getModems()
74{
75 QVariant var = getProperty("Modems");
76 return qdbus_cast<QList<QDBusObjectPath> >(var);
77}
78
79QDBusObjectPath QOfonoManagerInterface::currentModem()
80{
81 QList<QDBusObjectPath> modems = getModems();
82 foreach(const QDBusObjectPath modem, modems) {
83 QOfonoModemInterface device(modem.path());
84 if(device.isPowered() && device.isOnline())
85 return modem;;
86 }
87 return QDBusObjectPath();
88}
89
90
91void QOfonoManagerInterface::connectNotify(const char *signal)
92{
93if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
94 if(!connection().connect(QLatin1String(OFONO_SERVICE),
95 QLatin1String(OFONO_MANAGER_PATH),
96 QLatin1String(OFONO_MANAGER_INTERFACE),
97 QLatin1String("PropertyChanged"),
98 this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
99 qWarning() << "PropertyCHanged not connected";
100 }
101 }
102
103 if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
104 QOfonoDBusHelper *helper;
105 helper = new QOfonoDBusHelper(this);
106
107 dbusConnection.connect(QLatin1String(OFONO_SERVICE),
108 QLatin1String(OFONO_MANAGER_PATH),
109 QLatin1String(OFONO_MANAGER_INTERFACE),
110 QLatin1String("PropertyChanged"),
111 helper,SLOT(propertyChanged(QString,QDBusVariant)));
112
113
114 QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
115 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
116 }
117}
118
119void QOfonoManagerInterface::disconnectNotify(const char *signal)
120{
121 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
122
123 }
124}
125
126QVariant QOfonoManagerInterface::getProperty(const QString &property)
127{
128 QVariantMap map = getProperties();
129 if (map.contains(property)) {
130 return map.value(property);
131 } else {
132 qDebug() << Q_FUNC_INFO << "does not contain" << property;
133 }
134 return QVariant();
135}
136
137QVariantMap QOfonoManagerInterface::getProperties()
138{
139 QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
140 if(reply.isValid())
141 return reply.value();
142 else
143 return QVariantMap();
144}
145
146QOfonoDBusHelper::QOfonoDBusHelper(QObject * parent)
147 : QObject(parent)
148{
149}
150
151QOfonoDBusHelper::~QOfonoDBusHelper()
152{
153}
154
155void QOfonoDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var)
156{
157 QDBusMessage msg = this->message();
158 Q_EMIT propertyChangedContext(msg.path() ,item, var);
159}
160
161
162QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent)
163 : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
164 dbusPathName,
165 OFONO_MODEM_INTERFACE,
166 QDBusConnection::systemBus(), parent)
167{
168}
169
170QOfonoModemInterface::~QOfonoModemInterface()
171{
172}
173
174bool QOfonoModemInterface::isPowered()
175{
176 QVariant var = getProperty("Powered");
177 return qdbus_cast<bool>(var);
178}
179
180bool QOfonoModemInterface::isOnline()
181{
182 QVariant var = getProperty("Online");
183 return qdbus_cast<bool>(var);
184}
185
186QString QOfonoModemInterface::getName()
187{
188 QVariant var = getProperty("Name");
189 return qdbus_cast<QString>(var);
190}
191
192QString QOfonoModemInterface::getManufacturer()
193{
194 QVariant var = getProperty("Manufacturer");
195 return qdbus_cast<QString>(var);
196
197}
198
199QString QOfonoModemInterface::getModel()
200{
201
202 QVariant var = getProperty("Model");
203 return qdbus_cast<QString>(var);
204}
205
206QString QOfonoModemInterface::getRevision()
207{
208 QVariant var = getProperty("Revision");
209 return qdbus_cast<QString>(var);
210
211}
212QString QOfonoModemInterface::getSerial()
213{
214 QVariant var = getProperty("Serial");
215 return qdbus_cast<QString>(var);
216
217}
218
219QStringList QOfonoModemInterface::getFeatures()
220{
221 //sms, sim
222 QVariant var = getProperty("Features");
223 return qdbus_cast<QStringList>(var);
224}
225
226QStringList QOfonoModemInterface::getInterfaces()
227{
228 QVariant var = getProperty("Interfaces");
229 return qdbus_cast<QStringList>(var);
230}
231
232QString QOfonoModemInterface::defaultInterface()
233{
234 foreach(const QString &modem,getInterfaces()) {
235 return modem;
236 }
237 return QString();
238}
239
240
241void QOfonoModemInterface::connectNotify(const char *signal)
242{
243 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
244 if(!connection().connect(QLatin1String(OFONO_SERVICE),
245 this->path(),
246 QLatin1String(OFONO_MODEM_INTERFACE),
247 QLatin1String("PropertyChanged"),
248 this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
249 qWarning() << "PropertyCHanged not connected";
250 }
251 }
252
253 if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
254 QOfonoDBusHelper *helper;
255 helper = new QOfonoDBusHelper(this);
256
257 dbusConnection.connect(QLatin1String(OFONO_SERVICE),
258 this->path(),
259 QLatin1String(OFONO_MODEM_INTERFACE),
260 QLatin1String("PropertyChanged"),
261 helper,SLOT(propertyChanged(QString,QDBusVariant)));
262
263
264 QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
265 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
266 }}
267
268void QOfonoModemInterface::disconnectNotify(const char *signal)
269{
270 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
271
272 }
273}
274
275QVariantMap QOfonoModemInterface::getProperties()
276{
277 QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
278 return reply.value();
279}
280
281QVariant QOfonoModemInterface::getProperty(const QString &property)
282{
283 QVariant var;
284 QVariantMap map = getProperties();
285 if (map.contains(property)) {
286 var = map.value(property);
287 } else {
288 qDebug() << Q_FUNC_INFO << "does not contain" << property;
289 }
290 return var;
291}
292
293
294QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent)
295 : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
296 dbusPathName,
297 OFONO_NETWORK_REGISTRATION_INTERFACE,
298 QDBusConnection::systemBus(), parent)
299{
300}
301
302QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface()
303{
304}
305
306QString QOfonoNetworkRegistrationInterface::getStatus()
307{
308 /*
309 "unregistered" Not registered to any network
310 "registered" Registered to home network
311 "searching" Not registered, but searching
312 "denied" Registration has been denied
313 "unknown" Status is unknown
314 "roaming" Registered, but roaming*/
315 QVariant var = getProperty("Status");
316 return qdbus_cast<QString>(var);
317}
318
319quint16 QOfonoNetworkRegistrationInterface::getLac()
320{
321 QVariant var = getProperty("LocationAreaCode");
322 return var.value<quint16>();
323}
324
325
326quint32 QOfonoNetworkRegistrationInterface::getCellId()
327{
328 QVariant var = getProperty("CellId");
329 return var.value<quint32>();
330}
331
332QString QOfonoNetworkRegistrationInterface::getTechnology()
333{
334 // "gsm", "edge", "umts", "hspa","lte"
335 QVariant var = getProperty("Technology");
336 return qdbus_cast<QString>(var);
337}
338
339QString QOfonoNetworkRegistrationInterface::getOperatorName()
340{
341 QVariant var = getProperty("Name");
342 return qdbus_cast<QString>(var);
343}
344
345int QOfonoNetworkRegistrationInterface::getSignalStrength()
346{
347 QVariant var = getProperty("Strength");
348 return qdbus_cast<int>(var);
349
350}
351
352QString QOfonoNetworkRegistrationInterface::getBaseStation()
353{
354 QVariant var = getProperty("BaseStation");
355 return qdbus_cast<QString>(var);
356}
357
358QList <QDBusObjectPath> QOfonoNetworkRegistrationInterface::getOperators()
359{
360 QVariant var = getProperty("Operators");
361 return qdbus_cast<QList <QDBusObjectPath> >(var);
362}
363
364void QOfonoNetworkRegistrationInterface::connectNotify(const char *signal)
365{
366if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
367 if(!connection().connect(QLatin1String(OFONO_SERVICE),
368 this->path(),
369 QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE),
370 QLatin1String("PropertyChanged"),
371 this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
372 qWarning() << "PropertyCHanged not connected";
373 }
374 }
375
376 if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
377 QOfonoDBusHelper *helper;
378 helper = new QOfonoDBusHelper(this);
379
380 dbusConnection.connect(QLatin1String(OFONO_SERVICE),
381 this->path(),
382 QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE),
383 QLatin1String("PropertyChanged"),
384 helper,SLOT(propertyChanged(QString,QDBusVariant)));
385
386
387 QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
388 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
389 }
390}
391
392void QOfonoNetworkRegistrationInterface::disconnectNotify(const char *signal)
393{
394 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
395
396 }
397}
398
399QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property)
400{
401 QVariant var;
402 QVariantMap map = getProperties();
403 if (map.contains(property)) {
404 var = map.value(property);
405 } else {
406 qDebug() << Q_FUNC_INFO << "does not contain" << property;
407 }
408 return var;
409}
410
411QVariantMap QOfonoNetworkRegistrationInterface::getProperties()
412{
413 QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
414 return reply.value();
415}
416
417
418
419QOfonoNetworkOperatorInterface::QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent)
420 : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
421 dbusPathName,
422 OFONO_NETWORK_OPERATOR_INTERFACE,
423 QDBusConnection::systemBus(), parent)
424{
425}
426
427QOfonoNetworkOperatorInterface::~QOfonoNetworkOperatorInterface()
428{
429}
430
431QString QOfonoNetworkOperatorInterface::getName()
432{
433 QVariant var = getProperty("Name");
434 return qdbus_cast<QString>(var);
435}
436
437QString QOfonoNetworkOperatorInterface::getStatus()
438{
439 // "unknown", "available", "current" and "forbidden"
440 QVariant var = getProperty("Status");
441 return qdbus_cast<QString>(var);
442}
443
444QString QOfonoNetworkOperatorInterface::getMcc()
445{
446 QVariant var = getProperty("MobileCountryCode");
447 return qdbus_cast<QString>(var);
448}
449
450QString QOfonoNetworkOperatorInterface::getMnc()
451{
452 QVariant var = getProperty("MobileNetworkCode");
453 return qdbus_cast<QString>(var);
454}
455
456QStringList QOfonoNetworkOperatorInterface::getTechnologies()
457{
458 QVariant var = getProperty("Technologies");
459 return qdbus_cast<QStringList>(var);
460}
461
462void QOfonoNetworkOperatorInterface::connectNotify(const char *signal)
463{
464if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
465 if(!connection().connect(QLatin1String(OFONO_SERVICE),
466 this->path(),
467 QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE),
468 QLatin1String("PropertyChanged"),
469 this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
470 qWarning() << "PropertyCHanged not connected";
471 }
472 }
473
474 if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
475 QOfonoDBusHelper *helper;
476 helper = new QOfonoDBusHelper(this);
477
478 dbusConnection.connect(QLatin1String(OFONO_SERVICE),
479 this->path(),
480 QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE),
481 QLatin1String("PropertyChanged"),
482 helper,SLOT(propertyChanged(QString,QDBusVariant)));
483
484
485 QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
486 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
487 }
488}
489
490void QOfonoNetworkOperatorInterface::disconnectNotify(const char *signal)
491{
492 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
493
494 }
495}
496
497QVariant QOfonoNetworkOperatorInterface::getProperty(const QString &property)
498{
499 QVariant var;
500 QVariantMap map = getProperties();
501 if (map.contains(property)) {
502 var = map.value(property);
503 } else {
504 qDebug() << Q_FUNC_INFO << "does not contain" << property;
505 }
506 return var;
507}
508
509QVariantMap QOfonoNetworkOperatorInterface::getProperties()
510{
511 QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
512 return reply.value();
513}
514
515QOfonoSimInterface::QOfonoSimInterface(const QString &dbusPathName, QObject *parent)
516 : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
517 dbusPathName,
518 OFONO_SIM_MANAGER_INTERFACE,
519 QDBusConnection::systemBus(), parent)
520{
521}
522
523QOfonoSimInterface::~QOfonoSimInterface()
524{
525}
526
527bool QOfonoSimInterface::isPresent()
528{
529 QVariant var = getProperty("Present");
530 return qdbus_cast<bool>(var);
531}
532
533QString QOfonoSimInterface::getHomeMcc()
534{
535 QVariant var = getProperty("MobileCountryCode");
536 return qdbus_cast<QString>(var);
537}
538
539QString QOfonoSimInterface::getHomeMnc()
540{
541 QVariant var = getProperty("MobileNetworkCode");
542 return qdbus_cast<QString>(var);
543}
544
545// QStringList subscriberNumbers();
546// QMap<QString,QString> serviceNumbers();
547QString QOfonoSimInterface::pinRequired()
548{
549 QVariant var = getProperty("PinRequired");
550 return qdbus_cast<QString>(var);
551}
552
553QString QOfonoSimInterface::lockedPins()
554{
555 QVariant var = getProperty("LockedPins");
556 return qdbus_cast<QString>(var);
557}
558
559QString QOfonoSimInterface::cardIdentifier()
560{
561 QVariant var = getProperty("CardIdentifier");
562 return qdbus_cast<QString>(var);
563}
564
565void QOfonoSimInterface::connectNotify(const char *signal)
566{
567if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
568 if(!connection().connect(QLatin1String(OFONO_SERVICE),
569 this->path(),
570 QLatin1String(OFONO_SIM_MANAGER_INTERFACE),
571 QLatin1String("PropertyChanged"),
572 this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
573 qWarning() << "PropertyCHanged not connected";
574 }
575 }
576
577 if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
578 QOfonoDBusHelper *helper;
579 helper = new QOfonoDBusHelper(this);
580
581 dbusConnection.connect(QLatin1String(OFONO_SERVICE),
582 this->path(),
583 QLatin1String(OFONO_SIM_MANAGER_INTERFACE),
584 QLatin1String("PropertyChanged"),
585 helper,SLOT(propertyChanged(QString,QDBusVariant)));
586
587
588 QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
589 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
590 }
591}
592
593void QOfonoSimInterface::disconnectNotify(const char *signal)
594{
595 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
596
597 }
598}
599
600QVariant QOfonoSimInterface::getProperty(const QString &property)
601{
602 QVariant var;
603 QVariantMap map = getProperties();
604 if (map.contains(property)) {
605 var = map.value(property);
606 } else {
607 qDebug() << Q_FUNC_INFO << "does not contain" << property;
608 }
609 return var;
610}
611
612QVariantMap QOfonoSimInterface::getProperties()
613{
614 QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
615 return reply.value();
616}
617
618QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent)
619 : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
620 dbusPathName,
621 OFONO_DATA_CONNECTION_MANAGER_INTERFACE,
622 QDBusConnection::systemBus(), parent)
623{
624}
625
626QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface()
627{
628}
629
630QList<QDBusObjectPath> QOfonoDataConnectionManagerInterface::getPrimaryContexts()
631{
632 QVariant var = getProperty("PrimaryContexts");
633 return qdbus_cast<QList<QDBusObjectPath> >(var);
634}
635
636bool QOfonoDataConnectionManagerInterface::isAttached()
637{
638 QVariant var = getProperty("Attached");
639 return qdbus_cast<bool>(var);
640}
641
642bool QOfonoDataConnectionManagerInterface::isRoamingAllowed()
643{
644 QVariant var = getProperty("RoamingAllowed");
645 return qdbus_cast<bool>(var);
646}
647
648bool QOfonoDataConnectionManagerInterface::isPowered()
649{
650 QVariant var = getProperty("Powered");
651 return qdbus_cast<bool>(var);
652}
653
654void QOfonoDataConnectionManagerInterface::connectNotify(const char *signal)
655{
656if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
657 if(!connection().connect(QLatin1String(OFONO_SERVICE),
658 this->path(),
659 QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE),
660 QLatin1String("PropertyChanged"),
661 this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
662 qWarning() << "PropertyCHanged not connected";
663 }
664 }
665
666 if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
667 QOfonoDBusHelper *helper;
668 helper = new QOfonoDBusHelper(this);
669
670 dbusConnection.connect(QLatin1String(OFONO_SERVICE),
671 this->path(),
672 QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE),
673 QLatin1String("PropertyChanged"),
674 helper,SLOT(propertyChanged(QString,QDBusVariant)));
675
676
677 QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
678 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
679 }
680}
681
682void QOfonoDataConnectionManagerInterface::disconnectNotify(const char *signal)
683{
684 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
685
686 }
687}
688
689QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property)
690{
691 QVariant var;
692 QVariantMap map = getProperties();
693 if (map.contains(property)) {
694 var = map.value(property);
695 } else {
696 qDebug() << Q_FUNC_INFO << "does not contain" << property;
697 }
698 return var;
699}
700
701QVariantMap QOfonoDataConnectionManagerInterface::getProperties()
702{
703 QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
704 return reply.value();
705}
706
707QOfonoPrimaryDataContextInterface::QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent)
708 : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
709 dbusPathName,
710 OFONO_DATA_CONTEXT_INTERFACE,
711 QDBusConnection::systemBus(), parent)
712{
713}
714
715QOfonoPrimaryDataContextInterface::~QOfonoPrimaryDataContextInterface()
716{
717}
718
719bool QOfonoPrimaryDataContextInterface::isActive()
720{
721 QVariant var = getProperty("Active");
722 return qdbus_cast<bool>(var);
723}
724
725QString QOfonoPrimaryDataContextInterface::getApName()
726{
727 QVariant var = getProperty("AccessPointName");
728 return qdbus_cast<QString>(var);
729}
730
731QString QOfonoPrimaryDataContextInterface::getType()
732{
733 QVariant var = getProperty("Type");
734 return qdbus_cast<QString>(var);
735}
736
737QString QOfonoPrimaryDataContextInterface::getName()
738{
739 QVariant var = getProperty("Name");
740 return qdbus_cast<QString>(var);
741}
742
743QVariantMap QOfonoPrimaryDataContextInterface::getSettings()
744{
745 QVariant var = getProperty("Settings");
746 return qdbus_cast<QVariantMap>(var);
747}
748
749QString QOfonoPrimaryDataContextInterface::getInterface()
750{
751 QVariant var = getProperty("Interface");
752 return qdbus_cast<QString>(var);
753}
754
755QString QOfonoPrimaryDataContextInterface::getAddress()
756{
757 QVariant var = getProperty("Address");
758 return qdbus_cast<QString>(var);
759}
760
761bool QOfonoPrimaryDataContextInterface::setActive(bool on)
762{
763// this->setProperty("Active", QVariant(on));
764
765 return setProp("Active", qVariantFromValue(on));
766}
767
768bool QOfonoPrimaryDataContextInterface::setApn(const QString &name)
769{
770 return setProp("AccessPointName", QVariant::fromValue(name));
771}
772
773void QOfonoPrimaryDataContextInterface::connectNotify(const char *signal)
774{
775if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
776 if(!connection().connect(QLatin1String(OFONO_SERVICE),
777 this->path(),
778 QLatin1String(OFONO_DATA_CONTEXT_INTERFACE),
779 QLatin1String("PropertyChanged"),
780 this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
781 qWarning() << "PropertyCHanged not connected";
782 }
783 }
784
785 if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
786 QOfonoDBusHelper *helper;
787 helper = new QOfonoDBusHelper(this);
788
789 dbusConnection.connect(QLatin1String(OFONO_SERVICE),
790 this->path(),
791 QLatin1String(OFONO_DATA_CONTEXT_INTERFACE),
792 QLatin1String("PropertyChanged"),
793 helper,SLOT(propertyChanged(QString,QDBusVariant)));
794
795
796 QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
797 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
798 }
799}
800
801void QOfonoPrimaryDataContextInterface::disconnectNotify(const char *signal)
802{
803 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
804
805 }
806}
807
808QVariant QOfonoPrimaryDataContextInterface::getProperty(const QString &property)
809{
810 QVariant var;
811 QVariantMap map = getProperties();
812 if (map.contains(property)) {
813 var = map.value(property);
814 } else {
815 qDebug() << Q_FUNC_INFO << "does not contain" << property;
816 }
817 return var;
818}
819
820QVariantMap QOfonoPrimaryDataContextInterface::getProperties()
821{
822 QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
823 return reply.value();
824}
825
826bool QOfonoPrimaryDataContextInterface::setProp(const QString &property, const QVariant &var)
827{
828 QList<QVariant> args;
829 args << qVariantFromValue(property) << qVariantFromValue(QDBusVariant(var));
830
831 QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,
832 QLatin1String("SetProperty"),
833 args);
834 bool ok = true;
835 if(reply.type() != QDBusMessage::ReplyMessage) {
836 qWarning() << reply.errorMessage();
837 ok = false;
838 }
839 qWarning() << reply.errorMessage();
840 return ok;
841}
842
843QOfonoSmsInterface::QOfonoSmsInterface(const QString &dbusPathName, QObject *parent)
844 : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
845 dbusPathName,
846 OFONO_SMS_MANAGER_INTERFACE,
847 QDBusConnection::systemBus(), parent)
848{
849}
850
851QOfonoSmsInterface::~QOfonoSmsInterface()
852{
853}
854
855void QOfonoSmsInterface::connectNotify(const char *signal)
856{
857 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
858 if(!connection().connect(QLatin1String(OFONO_SERVICE),
859 this->path(),
860 QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
861 QLatin1String("PropertyChanged"),
862 this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
863 qWarning() << "PropertyCHanged not connected";
864 }
865 }
866
867 if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) {
868 QOfonoDBusHelper *helper;
869 helper = new QOfonoDBusHelper(this);
870
871 dbusConnection.connect(QLatin1String(OFONO_SERVICE),
872 this->path(),
873 QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
874 QLatin1String("PropertyChanged"),
875 helper,SLOT(propertyChanged(QString,QDBusVariant)));
876
877
878 QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
879 this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
880 }
881
882 if (QLatin1String(signal) == SIGNAL(immediateMessage(QString,QVariantMap))) {
883 if(!connection().connect(QLatin1String(OFONO_SERVICE),
884 this->path(),
885 QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
886 QLatin1String("ImmediateMessage"),
887 this,SIGNAL(immediateMessage(QString,QVariantMap )))) {
888 qWarning() << "PropertyCHanged not connected";
889 }
890 }
891
892 if (QLatin1String(signal) == SIGNAL(incomingMessage(QString,QVariantMap))) {
893 if(!connection().connect(QLatin1String(OFONO_SERVICE),
894 this->path(),
895 QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
896 QLatin1String("IncomingMessage"),
897 this,SIGNAL(incomingMessage(QString,QVariantMap)))) {
898 qWarning() << "PropertyCHanged not connected";
899 }
900 }
901}
902
903void QOfonoSmsInterface::disconnectNotify(const char *signal)
904{
905 if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) {
906
907 }
908}
909
910QVariant QOfonoSmsInterface::getProperty(const QString &property)
911{
912 QVariant var;
913 QVariantMap map = getProperties();
914 if (map.contains(property)) {
915 var = map.value(property);
916 } else {
917 qDebug() << Q_FUNC_INFO << "does not contain" << property;
918 }
919 return var;
920}
921
922QVariantMap QOfonoSmsInterface::getProperties()
923{
924 QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
925 return reply.value();
926}
927
928void QOfonoSmsInterface::sendMessage(const QString &to, const QString &message)
929{
930 QDBusReply<QString> reply = this->call(QLatin1String("SendMessage"),
931 QVariant::fromValue(to),
932 QVariant::fromValue(message));
933 bool ok = true;
934 if(reply.error().type() == QDBusError::InvalidArgs) {
935 qWarning() << reply.error().message();
936 ok = false;
937 }
938}
939
940QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.