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"
28 #include "ofonointerface.h"
30 OfonoSimManager::OfonoSimManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
31 : OfonoModemInterface(modemSetting, modemPath, "org.ofono.SimManager", OfonoGetAllOnStartup, parent)
33 qRegisterMetaType<OfonoServiceNumbers>("OfonoServiceNumbers");
34 qRegisterMetaType<OfonoPinRetries>("OfonoPinRetries");
35 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
36 this, SLOT(propertyChanged(const QString&, const QVariant&)));
37 connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
38 this, SLOT(setPropertyFailed(const QString&)));
42 OfonoSimManager::~OfonoSimManager()
46 void OfonoSimManager::changePin(const QString &pintype, const QString &oldpin, const QString &newpin)
50 request = QDBusMessage::createMethodCall("org.ofono",
51 path(), m_if->ifname(),
53 request << pintype << oldpin << newpin;
55 QDBusConnection::systemBus().callWithCallback(request, this,
56 SLOT(changePinResp()),
57 SLOT(changePinErr(const QDBusError&)));
60 void OfonoSimManager::enterPin(const QString &pintype, const QString &pin)
64 request = QDBusMessage::createMethodCall("org.ofono",
65 path(), m_if->ifname(),
67 request << pintype << pin;
69 QDBusConnection::systemBus().callWithCallback(request, this,
71 SLOT(enterPinErr(const QDBusError&)));
74 void OfonoSimManager::resetPin(const QString &pintype, const QString &puk, const QString &newpin)
78 request = QDBusMessage::createMethodCall("org.ofono",
79 path(), m_if->ifname(),
81 request << pintype << puk << newpin;
83 QDBusConnection::systemBus().callWithCallback(request, this,
85 SLOT(resetPinErr(const QDBusError&)));
88 void OfonoSimManager::lockPin(const QString &pintype, const QString &pin)
92 request = QDBusMessage::createMethodCall("org.ofono",
93 path(), m_if->ifname(),
95 request << pintype << pin;
97 QDBusConnection::systemBus().callWithCallback(request, this,
99 SLOT(lockPinErr(const QDBusError&)));
102 void OfonoSimManager::unlockPin(const QString &pintype, const QString &pin)
104 QDBusMessage request;
106 request = QDBusMessage::createMethodCall("org.ofono",
107 path(), m_if->ifname(),
109 request << pintype << pin;
111 QDBusConnection::systemBus().callWithCallback(request, this,
112 SLOT(unlockPinResp()),
113 SLOT(unlockPinErr(const QDBusError&)));
116 void OfonoSimManager::setSubscriberNumbers(const QStringList &numbers)
118 m_if->setProperty("SubscriberNumbers", qVariantFromValue(numbers));
121 bool OfonoSimManager::present() const
123 return m_if->properties()["Present"].value<bool>();
126 QString OfonoSimManager::subscriberIdentity() const
128 return m_if->properties()["SubscriberIdentity"].value<QString>();
131 QString OfonoSimManager::mobileCountryCode() const
133 return m_if->properties()["MobileCountryCode"].value<QString>();
136 QString OfonoSimManager::mobileNetworkCode() const
138 return m_if->properties()["MobileNetworkCode"].value<QString>();
141 QStringList OfonoSimManager::subscriberNumbers() const
143 return m_if->properties()["SubscriberNumbers"].value<QStringList>();
146 OfonoServiceNumbers OfonoSimManager::serviceNumbers() const
148 OfonoServiceNumbers map;
149 m_if->properties()["ServiceNumbers"].value<QDBusArgument>() >> map;
153 QString OfonoSimManager::pinRequired() const
155 return m_if->properties()["PinRequired"].value<QString>();
158 QStringList OfonoSimManager::lockedPins() const
160 return m_if->properties()["LockedPins"].value<QStringList>();
163 QString OfonoSimManager::cardIdentifier() const
165 return m_if->properties()["CardIdentifier"].value<QString>();
168 QStringList OfonoSimManager::preferredLanguages() const
170 return m_if->properties()["PreferredLanguages"].value<QStringList>();
173 OfonoPinRetries OfonoSimManager::pinRetries() const
175 OfonoPinRetries retries;
176 m_if->properties()["Retries"].value<QDBusArgument>() >> retries;
180 void OfonoSimManager::propertyChanged(const QString& property, const QVariant& value)
182 if (property == "Present") {
183 emit presenceChanged(value.value<bool>());
184 } else if (property == "SubscriberIdentity") {
185 emit subscriberIdentityChanged(value.value<QString>());
186 } else if (property == "MobileCountryCode") {
187 emit mobileCountryCodeChanged(value.value<QString>());
188 } else if (property == "MobileNetworkCode") {
189 emit mobileNetworkCodeChanged(value.value<QString>());
190 } else if (property == "SubscriberNumbers") {
191 emit subscriberNumbersChanged(value.value<QStringList>());
192 } else if (property == "ServiceNumbers") {
193 OfonoServiceNumbers map;
194 value.value<QDBusArgument>() >> map;
195 emit serviceNumbersChanged(map);
196 } else if (property == "PinRequired") {
197 emit pinRequiredChanged(value.value<QString>());
198 } else if (property == "LockedPins") {
199 emit lockedPinsChanged(value.value<QStringList>());
200 } else if (property == "CardIdentifier") {
201 emit cardIdentifierChanged(value.value<QString>());
202 } else if (property == "PreferredLanguages") {
203 emit preferredLanguagesChanged(value.value<QStringList>());
204 } else if (property == "Retries") {
205 OfonoPinRetries retries;
206 value.value<QDBusArgument>() >> retries;
207 emit pinRetriesChanged(retries);
211 void OfonoSimManager::setPropertyFailed(const QString& property)
213 if (property == "SubscriberNumbers")
214 emit setSubscriberNumbersFailed();
217 void OfonoSimManager::changePinResp()
219 emit changePinComplete(TRUE);
222 void OfonoSimManager::changePinErr(QDBusError error)
224 m_if->setError(error.name(), error.message());
225 emit changePinComplete(FALSE);
228 void OfonoSimManager::enterPinResp()
230 emit enterPinComplete(TRUE);
233 void OfonoSimManager::enterPinErr(QDBusError error)
235 m_if->setError(error.name(), error.message());
236 emit enterPinComplete(FALSE);
239 void OfonoSimManager::resetPinResp()
241 emit resetPinComplete(TRUE);
244 void OfonoSimManager::resetPinErr(QDBusError error)
246 m_if->setError(error.name(), error.message());
247 emit resetPinComplete(FALSE);
250 void OfonoSimManager::lockPinResp()
252 emit lockPinComplete(TRUE);
254 void OfonoSimManager::lockPinErr(QDBusError error)
256 m_if->setError(error.name(), error.message());
257 emit lockPinComplete(FALSE);
260 void OfonoSimManager::unlockPinResp()
262 emit unlockPinComplete(TRUE);
264 void OfonoSimManager::unlockPinErr(QDBusError error)
266 m_if->setError(error.name(), error.message());
267 emit unlockPinComplete(FALSE);