2 * This file is part of ofono-qt
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Kanavin <alexander.kanavin@nokia.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"
30 OfonoSimManager::OfonoSimManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
31 : OfonoModemInterface(modemSetting, modemPath, "org.ofono.SimManager", OfonoInterface::GetAllOnStartup, parent)
33 connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
34 this, SLOT(propertyChanged(const QString&, const QVariant&)));
35 connect(this, SIGNAL(setPropertyFailed(const QString&)),
36 this, SLOT(setPropertyFailed(const QString&)));
40 OfonoSimManager::~OfonoSimManager()
44 void OfonoSimManager::requestChangePin(const QString &pintype, const QString &oldpin, const QString &newpin)
48 request = QDBusMessage::createMethodCall("org.ofono",
51 request << pintype << oldpin << newpin;
53 QDBusConnection::systemBus().callWithCallback(request, this,
54 SLOT(changePinResp()),
55 SLOT(changePinErr(const QDBusError&)));
58 void OfonoSimManager::requestEnterPin(const QString &pintype, const QString &pin)
62 request = QDBusMessage::createMethodCall("org.ofono",
65 request << pintype << pin;
67 QDBusConnection::systemBus().callWithCallback(request, this,
69 SLOT(enterPinErr(const QDBusError&)));
72 void OfonoSimManager::requestResetPin(const QString &pintype, const QString &puk, const QString &newpin)
76 request = QDBusMessage::createMethodCall("org.ofono",
79 request << pintype << puk << newpin;
81 QDBusConnection::systemBus().callWithCallback(request, this,
83 SLOT(resetPinErr(const QDBusError&)));
86 void OfonoSimManager::requestLockPin(const QString &pintype, const QString &pin)
90 request = QDBusMessage::createMethodCall("org.ofono",
93 request << pintype << pin;
95 QDBusConnection::systemBus().callWithCallback(request, this,
97 SLOT(lockPinErr(const QDBusError&)));
100 void OfonoSimManager::requestUnlockPin(const QString &pintype, const QString &pin)
102 QDBusMessage request;
104 request = QDBusMessage::createMethodCall("org.ofono",
107 request << pintype << pin;
109 QDBusConnection::systemBus().callWithCallback(request, this,
110 SLOT(unlockPinResp()),
111 SLOT(unlockPinErr(const QDBusError&)));
114 void OfonoSimManager::setSubscriberNumbers(const QStringList &numbers)
116 setProperty("SubscriberNumbers", qVariantFromValue(numbers));
119 bool OfonoSimManager::present() const
121 return properties()["Present"].value<bool>();
124 QString OfonoSimManager::subscriberIdentity() const
126 return properties()["SubscriberIdentity"].value<QString>();
129 QString OfonoSimManager::mobileCountryCode() const
131 return properties()["MobileCountryCode"].value<QString>();
134 QString OfonoSimManager::mobileNetworkCode() const
136 return properties()["MobileNetworkCode"].value<QString>();
139 QStringList OfonoSimManager::subscriberNumbers() const
141 return properties()["SubscriberNumbers"].value<QStringList>();
144 QMap<QString, QString> OfonoSimManager::serviceNumbers() const
146 QMap<QString, QString> map;
147 properties()["ServiceNumbers"].value<QDBusArgument>() >> map;
151 QString OfonoSimManager::pinRequired() const
153 return properties()["PinRequired"].value<QString>();
156 QStringList OfonoSimManager::lockedPins() const
158 return properties()["LockedPins"].value<QStringList>();
161 QString OfonoSimManager::cardIdentifier() const
163 return properties()["CardIdentifier"].value<QString>();
166 QStringList OfonoSimManager::preferredLanguages() const
168 return properties()["PreferredLanguages"].value<QStringList>();
172 void OfonoSimManager::propertyChanged(const QString& property, const QVariant& value)
174 if (property == "Present") {
175 emit presenceChanged(value.value<bool>());
176 } else if (property == "SubscriberIdentity") {
177 emit subscriberIdentityChanged(value.value<QString>());
178 } else if (property == "MobileCountryCode") {
179 emit mobileCountryCodeChanged(value.value<QString>());
180 } else if (property == "MobileNetworkCode") {
181 emit mobileNetworkCodeChanged(value.value<QString>());
182 } else if (property == "SubscriberNumbers") {
183 emit subscriberNumbersChanged(value.value<QStringList>());
184 } else if (property == "ServiceNumbers") {
185 QMap<QString, QString> map;
186 value.value<QDBusArgument>() >> map;
187 emit serviceNumbersChanged(map);
188 } else if (property == "PinRequired") {
189 emit pinRequiredChanged(value.value<QString>());
190 } else if (property == "LockedPins") {
191 emit lockedPinsChanged(value.value<QStringList>());
192 } else if (property == "CardIdentifier") {
193 emit cardIdentifierChanged(value.value<QString>());
194 } else if (property == "PreferredLanguages") {
195 emit preferredLanguagesChanged(value.value<QStringList>());
199 void OfonoSimManager::setPropertyFailed(const QString& property)
201 if (property == "SubscriberNumbers")
202 emit setSubscriberNumbersFailed();
205 void OfonoSimManager::changePinResp()
207 emit changePinComplete(TRUE);
210 void OfonoSimManager::changePinErr(QDBusError error)
212 qDebug() << "ChangePin failed" << error;
213 m_errorName = error.name();
214 m_errorMessage = error.message();
215 emit changePinComplete(FALSE);
218 void OfonoSimManager::enterPinResp()
220 emit enterPinComplete(TRUE);
223 void OfonoSimManager::enterPinErr(QDBusError error)
225 qDebug() << "EnterPin failed" << error;
226 m_errorName = error.name();
227 m_errorMessage = error.message();
228 emit enterPinComplete(FALSE);
231 void OfonoSimManager::resetPinResp()
233 emit resetPinComplete(TRUE);
236 void OfonoSimManager::resetPinErr(QDBusError error)
238 qDebug() << "ResetPin failed" << error;
239 m_errorName = error.name();
240 m_errorMessage = error.message();
241 emit resetPinComplete(FALSE);
244 void OfonoSimManager::lockPinResp()
246 emit lockPinComplete(TRUE);
248 void OfonoSimManager::lockPinErr(QDBusError error)
250 qDebug() << "LockPin failed" << error;
251 m_errorName = error.name();
252 m_errorMessage = error.message();
253 emit lockPinComplete(FALSE);
256 void OfonoSimManager::unlockPinResp()
258 emit unlockPinComplete(TRUE);
260 void OfonoSimManager::unlockPinErr(QDBusError error)
262 qDebug() << "UnlockPin failed" << error;
263 m_errorName = error.name();
264 m_errorMessage = error.message();
265 emit unlockPinComplete(FALSE);