2
* This file is part of ofono-qt
4
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: Alexander Kanavin <alex.kanavin@gmail.com>
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public License
10
* version 2.1 as published by the Free Software Foundation.
12
* This library is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24
#include <QtDBus/QtDBus>
25
#include <QtCore/QObject>
27
#include "ofonosimmanager.h"
28
#include "ofonointerface.h"
29
#include "simmanagerprivate.h"
31
OfonoSimManager::OfonoSimManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
32
: OfonoModemInterface(modemSetting, modemPath, "org.ofono.SimManager", OfonoGetAllOnStartup, parent)
34
qRegisterMetaType<OfonoServiceNumbers>("OfonoServiceNumbers");
35
qRegisterMetaType<OfonoPinRetries>("OfonoPinRetries");
37
m_if->setPath(OFONO_MOCK_SIM_MANAGER_OBJECT);
38
if (!simManagerData.keys().contains(modem()->path())) {
39
simManagerData[modem()->path()] = new SimManagerPrivate();
42
connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
43
this, SLOT(propertyChanged(const QString&, const QVariant&)));
44
connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
45
this, SLOT(setPropertyFailed(const QString&)));
49
OfonoSimManager::~OfonoSimManager()
53
void OfonoSimManager::changePin(const QString &pintype, const QString &oldpin, const QString &newpin)
57
request = QDBusMessage::createMethodCall("org.ofono",
58
path(), m_if->ifname(),
60
request << pintype << oldpin << newpin;
62
QDBusConnection::sessionBus().callWithCallback(request, this,
63
SLOT(changePinResp()),
64
SLOT(changePinErr(const QDBusError&)));
67
void OfonoSimManager::enterPin(const QString &pintype, const QString &pin)
71
request = QDBusMessage::createMethodCall("org.ofono",
72
path(), m_if->ifname(),
74
request << pintype << pin;
76
QDBusConnection::sessionBus().callWithCallback(request, this,
78
SLOT(enterPinErr(const QDBusError&)));
81
void OfonoSimManager::resetPin(const QString &pintype, const QString &puk, const QString &newpin)
85
request = QDBusMessage::createMethodCall("org.ofono",
86
path(), m_if->ifname(),
88
request << pintype << puk << newpin;
90
QDBusConnection::sessionBus().callWithCallback(request, this,
92
SLOT(resetPinErr(const QDBusError&)));
95
void OfonoSimManager::lockPin(const QString &pintype, const QString &pin)
99
request = QDBusMessage::createMethodCall("org.ofono",
100
path(), m_if->ifname(),
102
request << pintype << pin;
104
QDBusConnection::sessionBus().callWithCallback(request, this,
106
SLOT(lockPinErr(const QDBusError&)));
109
void OfonoSimManager::unlockPin(const QString &pintype, const QString &pin)
111
QDBusMessage request;
113
request = QDBusMessage::createMethodCall("org.ofono",
114
path(), m_if->ifname(),
116
request << pintype << pin;
118
QDBusConnection::sessionBus().callWithCallback(request, this,
119
SLOT(unlockPinResp()),
120
SLOT(unlockPinErr(const QDBusError&)));
123
void OfonoSimManager::getIcon(quint8 id)
125
QDBusMessage request;
127
request = QDBusMessage::createMethodCall("org.ofono",
128
path(), m_if->ifname(),
130
request << qVariantFromValue(id);
132
QDBusConnection::sessionBus().callWithCallback(request, this,
133
SLOT(getIconResp(QByteArray)),
134
SLOT(getIconErr(const QDBusError&)));
137
void OfonoSimManager::setSubscriberNumbers(const QStringList &numbers)
139
m_if->setProperty("SubscriberNumbers", qVariantFromValue(numbers));
142
bool OfonoSimManager::present() const
144
return m_if->properties()["Present"].value<bool>();
147
QString OfonoSimManager::subscriberIdentity() const
149
return m_if->properties()["SubscriberIdentity"].value<QString>();
152
QString OfonoSimManager::mobileCountryCode() const
154
return m_if->properties()["MobileCountryCode"].value<QString>();
157
QString OfonoSimManager::mobileNetworkCode() const
159
return m_if->properties()["MobileNetworkCode"].value<QString>();
162
QStringList OfonoSimManager::subscriberNumbers() const
164
return m_if->properties()["SubscriberNumbers"].value<QStringList>();
167
OfonoServiceNumbers OfonoSimManager::serviceNumbers() const
169
OfonoServiceNumbers map;
170
m_if->properties()["ServiceNumbers"].value<QDBusArgument>() >> map;
174
QString OfonoSimManager::pinRequired() const
176
return m_if->properties()["PinRequired"].value<QString>();
179
QStringList OfonoSimManager::lockedPins() const
181
return m_if->properties()["LockedPins"].value<QStringList>();
184
QString OfonoSimManager::cardIdentifier() const
186
return m_if->properties()["CardIdentifier"].value<QString>();
189
QStringList OfonoSimManager::preferredLanguages() const
191
return m_if->properties()["PreferredLanguages"].value<QStringList>();
194
OfonoPinRetries OfonoSimManager::pinRetries() const
196
OfonoPinRetries retries;
197
m_if->properties()["Retries"].value<QDBusArgument>() >> retries;
201
bool OfonoSimManager::fixedDialing() const
203
return m_if->properties()["FixedDialing"].value<bool>();
206
bool OfonoSimManager::barredDialing() const
208
return m_if->properties()["BarredDialing"].value<bool>();
211
void OfonoSimManager::propertyChanged(const QString& property, const QVariant& value)
213
if (property == "Present") {
214
Q_EMIT presenceChanged(value.value<bool>());
215
} else if (property == "SubscriberIdentity") {
216
Q_EMIT subscriberIdentityChanged(value.value<QString>());
217
} else if (property == "MobileCountryCode") {
218
Q_EMIT mobileCountryCodeChanged(value.value<QString>());
219
} else if (property == "MobileNetworkCode") {
220
Q_EMIT mobileNetworkCodeChanged(value.value<QString>());
221
} else if (property == "SubscriberNumbers") {
222
Q_EMIT subscriberNumbersChanged(value.value<QStringList>());
223
} else if (property == "ServiceNumbers") {
224
OfonoServiceNumbers map;
225
value.value<QDBusArgument>() >> map;
226
Q_EMIT serviceNumbersChanged(map);
227
} else if (property == "PinRequired") {
228
Q_EMIT pinRequiredChanged(value.value<QString>());
229
} else if (property == "LockedPins") {
230
Q_EMIT lockedPinsChanged(value.value<QStringList>());
231
} else if (property == "CardIdentifier") {
232
Q_EMIT cardIdentifierChanged(value.value<QString>());
233
} else if (property == "PreferredLanguages") {
234
Q_EMIT preferredLanguagesChanged(value.value<QStringList>());
235
} else if (property == "Retries") {
236
OfonoPinRetries retries;
237
value.value<QDBusArgument>() >> retries;
238
Q_EMIT pinRetriesChanged(retries);
239
} else if (property == "FixedDialing") {
240
Q_EMIT fixedDialingChanged(value.value<bool>());
241
} else if (property == "BarredDialing") {
242
Q_EMIT barredDialingChanged(value.value<bool>());
246
void OfonoSimManager::setPropertyFailed(const QString& property)
248
if (property == "SubscriberNumbers")
249
Q_EMIT setSubscriberNumbersFailed();
252
void OfonoSimManager::changePinResp()
254
Q_EMIT changePinComplete(true);
257
void OfonoSimManager::changePinErr(QDBusError error)
259
m_if->setError(error.name(), error.message());
260
Q_EMIT changePinComplete(false);
263
void OfonoSimManager::enterPinResp()
265
Q_EMIT enterPinComplete(true);
268
void OfonoSimManager::enterPinErr(QDBusError error)
270
m_if->setError(error.name(), error.message());
271
Q_EMIT enterPinComplete(false);
274
void OfonoSimManager::resetPinResp()
276
Q_EMIT resetPinComplete(true);
279
void OfonoSimManager::resetPinErr(QDBusError error)
281
m_if->setError(error.name(), error.message());
282
Q_EMIT resetPinComplete(false);
285
void OfonoSimManager::lockPinResp()
287
Q_EMIT lockPinComplete(true);
289
void OfonoSimManager::lockPinErr(QDBusError error)
291
m_if->setError(error.name(), error.message());
292
Q_EMIT lockPinComplete(false);
295
void OfonoSimManager::unlockPinResp()
297
Q_EMIT unlockPinComplete(true);
299
void OfonoSimManager::unlockPinErr(QDBusError error)
301
m_if->setError(error.name(), error.message());
302
Q_EMIT unlockPinComplete(false);
305
void OfonoSimManager::getIconResp(QByteArray icon)
307
Q_EMIT getIconComplete(true, icon);
309
void OfonoSimManager::getIconErr(QDBusError error)
311
m_if->setError(error.name(), error.message());
312
Q_EMIT getIconComplete(false, QByteArray());