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"
29 #define REQUEST_TIMEOUT 60000
31 OfonoSupplementaryServices::OfonoSupplementaryServices(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
32 : OfonoModemInterface(modemSetting, modemPath, "org.ofono.SupplementaryServices", OfonoInterface::GetAllOnStartup, parent)
35 connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
36 this, SLOT(propertyChanged(const QString&, const QVariant&)));
37 QDBusConnection::systemBus().connect("org.ofono", path(), ifname(),
38 "NotificationReceived",
40 SIGNAL(notificationReceived(QString)));
41 QDBusConnection::systemBus().connect("org.ofono", path(), ifname(),
44 SIGNAL(requestReceived(QString)));
47 OfonoSupplementaryServices::~OfonoSupplementaryServices()
51 void OfonoSupplementaryServices::requestInitiate(const QString &command)
55 request = QDBusMessage::createMethodCall("org.ofono",
60 QDBusConnection::systemBus().callWithCallback(request, this,
61 SLOT(initiateResp(QString, QDBusVariant)),
62 SLOT(initiateErr(const QDBusError&)),
66 void OfonoSupplementaryServices::requestRespond(const QString &reply)
70 request = QDBusMessage::createMethodCall("org.ofono",
75 QDBusConnection::systemBus().callWithCallback(request, this,
76 SLOT(respondResp(QString)),
77 SLOT(respondErr(const QDBusError&)),
81 void OfonoSupplementaryServices::requestCancel()
85 request = QDBusMessage::createMethodCall("org.ofono",
89 QDBusConnection::systemBus().callWithCallback(request, this,
90 SLOT(cancelResp(QString)),
91 SLOT(cancelErr(const QDBusError&)),
95 QString OfonoSupplementaryServices::state() const
97 return properties()["State"].value<QString>();
100 void OfonoSupplementaryServices::propertyChanged(const QString& property, const QVariant& value)
102 if (property == "State") {
103 emit stateChanged(value.value<QString>());
107 void OfonoSupplementaryServices::initiateResp(QString message, QDBusVariant details)
109 const QDBusArgument argument = details.variant().value<QDBusArgument>();
110 if (message == "USSD") {
112 argument >> ussdResp;
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 == "CalledLinePresentation") {
142 QString ssOp, status;
143 argument.beginStructure();
144 argument >> ssOp >> status;
145 argument.endStructure();
146 emit calledLinePresentationComplete(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 == "CalledLineRestriction") {
154 QString ssOp, status;
155 argument.beginStructure();
156 argument >> ssOp >> status;
157 argument.endStructure();
158 emit calledLineRestrictionComplete(ssOp, status);
162 void OfonoSupplementaryServices::initiateErr(QDBusError error)
164 qDebug() << "Initiate failed" << error;
165 m_errorName = error.name();
166 m_errorMessage = 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_errorName = error.name();
180 m_errorMessage = error.message();
181 emit respondComplete(FALSE, QString());
184 void OfonoSupplementaryServices::cancelResp()
186 emit cancelComplete(TRUE);
189 void OfonoSupplementaryServices::cancelErr(QDBusError error)
191 qDebug() << "Cancel failed" << error;
192 m_errorName = error.name();
193 m_errorMessage = error.message();
194 emit cancelComplete(FALSE);