2 * This file is part of ofono-qt
4 * Copyright (C) 2010-2011 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 "ofonosupplementaryservices.h"
28 #include "ofonointerface.h"
30 #define REQUEST_TIMEOUT 60000
32 OfonoSupplementaryServices::OfonoSupplementaryServices(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
33 : OfonoModemInterface(modemSetting, modemPath, "org.ofono.SupplementaryServices", OfonoGetAllOnStartup, parent)
36 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
37 this, SLOT(propertyChanged(const QString&, const QVariant&)));
38 QDBusConnection::systemBus().connect("org.ofono", path(), m_if->ifname(),
39 "NotificationReceived",
41 SIGNAL(notificationReceived(QString)));
42 QDBusConnection::systemBus().connect("org.ofono", path(), m_if->ifname(),
45 SIGNAL(requestReceived(QString)));
48 OfonoSupplementaryServices::~OfonoSupplementaryServices()
52 void OfonoSupplementaryServices::initiate(const QString &command)
56 request = QDBusMessage::createMethodCall("org.ofono",
57 path(), m_if->ifname(),
61 QDBusConnection::systemBus().callWithCallback(request, this,
62 SLOT(initiateResp(QString, QDBusVariant)),
63 SLOT(initiateErr(const QDBusError&)),
67 void OfonoSupplementaryServices::respond(const QString &reply)
71 request = QDBusMessage::createMethodCall("org.ofono",
72 path(), m_if->ifname(),
76 QDBusConnection::systemBus().callWithCallback(request, this,
77 SLOT(respondResp(QString)),
78 SLOT(respondErr(const QDBusError&)),
82 void OfonoSupplementaryServices::cancel()
86 request = QDBusMessage::createMethodCall("org.ofono",
87 path(), m_if->ifname(),
90 QDBusConnection::systemBus().callWithCallback(request, this,
92 SLOT(cancelErr(const QDBusError&)),
96 QString OfonoSupplementaryServices::state() const
98 return m_if->properties()["State"].value<QString>();
101 void OfonoSupplementaryServices::propertyChanged(const QString& property, const QVariant& value)
103 if (property == "State") {
104 emit stateChanged(value.value<QString>());
108 void OfonoSupplementaryServices::initiateResp(QString message, QDBusVariant details)
110 const QDBusArgument argument = details.variant().value<QDBusArgument>();
111 if (message == "USSD") {
112 QString ussdResp = details.variant().toString();
113 emit initiateUSSDComplete(ussdResp);
114 } else if (message == "CallBarring") {
115 QString ssOp, cbService;
117 argument.beginStructure();
118 argument >> ssOp >> cbService >> cbMap;
119 argument.endStructure();
120 emit barringComplete(ssOp, cbService, cbMap);
121 } else if (message == "CallForwarding") {
122 QString ssOp, cfService;
124 argument.beginStructure();
125 argument >> ssOp >> cfService >> cfMap;
126 argument.endStructure();
127 emit forwardingComplete(ssOp, cfService, cfMap);
128 } else if (message == "CallWaiting") {
131 argument.beginStructure();
132 argument >> ssOp >> cwMap;
133 argument.endStructure();
134 emit waitingComplete(ssOp, cwMap);
135 } else if (message == "CallingLinePresentation") {
136 QString ssOp, status;
137 argument.beginStructure();
138 argument >> ssOp >> status;
139 argument.endStructure();
140 emit callingLinePresentationComplete(ssOp, status);
141 } else if (message == "ConnectedLinePresentation") {
142 QString ssOp, status;
143 argument.beginStructure();
144 argument >> ssOp >> status;
145 argument.endStructure();
146 emit connectedLinePresentationComplete(ssOp, status);
147 } else if (message == "CallingLineRestriction") {
148 QString ssOp, status;
149 argument.beginStructure();
150 argument >> ssOp >> status;
151 argument.endStructure();
152 emit callingLineRestrictionComplete(ssOp, status);
153 } else if (message == "ConnectedLineRestriction") {
154 QString ssOp, status;
155 argument.beginStructure();
156 argument >> ssOp >> status;
157 argument.endStructure();
158 emit connectedLineRestrictionComplete(ssOp, status);
160 m_if->setError(QString(), QString("Unknown initiate response"));
161 emit initiateFailed();
165 void OfonoSupplementaryServices::initiateErr(QDBusError error)
167 m_if->setError(error.name(), error.message());
168 emit initiateFailed();
172 void OfonoSupplementaryServices::respondResp(QString message)
174 emit respondComplete(TRUE, message);
177 void OfonoSupplementaryServices::respondErr(QDBusError error)
179 m_if->setError(error.name(), error.message());
180 emit respondComplete(FALSE, QString());
183 void OfonoSupplementaryServices::cancelResp()
185 emit cancelComplete(TRUE);
188 void OfonoSupplementaryServices::cancelErr(QDBusError error)
190 m_if->setError(error.name(), error.message());
191 emit cancelComplete(FALSE);