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 "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,
91 SLOT(cancelResp(QString)),
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") {
113 argument >> ussdResp;
114 emit initiateUSSDComplete(ussdResp);
115 } else if (message == "CallBarring") {
116 QString ssOp, cbService;
118 argument.beginStructure();
119 argument >> ssOp >> cbService >> cbMap;
120 argument.endStructure();
121 emit barringComplete(ssOp, cbService, cbMap);
122 } else if (message == "CallForwarding") {
123 QString ssOp, cfService;
125 argument.beginStructure();
126 argument >> ssOp >> cfService >> cfMap;
127 argument.endStructure();
128 emit forwardingComplete(ssOp, cfService, cfMap);
129 } else if (message == "CallWaiting") {
132 argument.beginStructure();
133 argument >> ssOp >> cwMap;
134 argument.endStructure();
135 emit waitingComplete(ssOp, cwMap);
136 } else if (message == "CallingLinePresentation") {
137 QString ssOp, status;
138 argument.beginStructure();
139 argument >> ssOp >> status;
140 argument.endStructure();
141 emit callingLinePresentationComplete(ssOp, status);
142 } else if (message == "CalledLinePresentation") {
143 QString ssOp, status;
144 argument.beginStructure();
145 argument >> ssOp >> status;
146 argument.endStructure();
147 emit calledLinePresentationComplete(ssOp, status);
148 } else if (message == "CallingLineRestriction") {
149 QString ssOp, status;
150 argument.beginStructure();
151 argument >> ssOp >> status;
152 argument.endStructure();
153 emit callingLineRestrictionComplete(ssOp, status);
154 } else if (message == "CalledLineRestriction") {
155 QString ssOp, status;
156 argument.beginStructure();
157 argument >> ssOp >> status;
158 argument.endStructure();
159 emit calledLineRestrictionComplete(ssOp, status);
163 void OfonoSupplementaryServices::initiateErr(QDBusError error)
165 qDebug() << "Initiate failed" << error;
166 m_if->setError(error.name(), error.message());
167 emit initiateFailed();
171 void OfonoSupplementaryServices::respondResp(QString message)
173 emit respondComplete(TRUE, message);
176 void OfonoSupplementaryServices::respondErr(QDBusError error)
178 qDebug() << "Respond failed" << 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 qDebug() << "Cancel failed" << error;
191 m_if->setError(error.name(), error.message());
192 emit cancelComplete(FALSE);