Merge lp:~tiagosh/telepathy-ofono/ussd into lp:telepathy-ofono

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 74
Merged at revision: 73
Proposed branch: lp:~tiagosh/telepathy-ofono/ussd
Merge into: lp:telepathy-ofono
Diff against target: 744 lines (+622/-1)
6 files modified
CMakeLists.txt (+1/-0)
connection.cpp (+59/-1)
connection.h (+7/-0)
tests/dbus-test-wrapper.sh.in (+1/-0)
ussdiface.cpp (+311/-0)
ussdiface.h (+243/-0)
To merge this branch: bzr merge lp:~tiagosh/telepathy-ofono/ussd
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+213936@code.launchpad.net

Commit message

Add initial USSD support

Description of the change

Add initial USSD support

--------------
Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~tiagosh/telephony-service/ussd/+merge/213935
https://code.launchpad.net/~tiagosh/dialer-app/ussd/+merge/213934

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/telepathy-ofono) on device or emulator?
Yes

If you changed the UI, was the change specified/approved by design?
N/A

If you changed the packaging (debian), did you subscribe a core-dev to this MP?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did CI run pass? If not, please explain why.
Yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

Code looks good and works as expected!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-02-07 20:03:39 +0000
+++ CMakeLists.txt 2014-04-02 22:00:18 +0000
@@ -97,6 +97,7 @@
97 pendingmessagesmanager.cpp97 pendingmessagesmanager.cpp
98 phoneutils.cpp98 phoneutils.cpp
99 sqlitedatabase.cpp99 sqlitedatabase.cpp
100 ussdiface.cpp
100 ${telepathyfono_RES})101 ${telepathyfono_RES})
101102
102if(USE_PULSEAUDIO)103if(USE_PULSEAUDIO)
103104
=== modified file 'connection.cpp'
--- connection.cpp 2014-03-19 02:36:35 +0000
+++ connection.cpp 2014-04-02 22:00:18 +0000
@@ -153,6 +153,7 @@
153 mOfonoCallVolume = new OfonoCallVolume(setting, modemPath);153 mOfonoCallVolume = new OfonoCallVolume(setting, modemPath);
154 mOfonoNetworkRegistration = new OfonoNetworkRegistration(setting, modemPath);154 mOfonoNetworkRegistration = new OfonoNetworkRegistration(setting, modemPath);
155 mOfonoMessageWaiting = new OfonoMessageWaiting(setting, modemPath);155 mOfonoMessageWaiting = new OfonoMessageWaiting(setting, modemPath);
156 mOfonoSupplementaryServices = new OfonoSupplementaryServices(setting, modemPath);
156157
157 setSelfHandle(newHandle("<SelfHandle>"));158 setSelfHandle(newHandle("<SelfHandle>"));
158159
@@ -203,6 +204,14 @@
203 voicemailIface->setVoicemailNumberCallback(Tp::memFun(this,&oFonoConnection::voicemailNumber));204 voicemailIface->setVoicemailNumberCallback(Tp::memFun(this,&oFonoConnection::voicemailNumber));
204 plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(voicemailIface));205 plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(voicemailIface));
205206
207 supplementaryServicesIface = BaseConnectionUSSDInterface::create();
208 supplementaryServicesIface->setInitiateCallback(Tp::memFun(this,&oFonoConnection::USSDInitiate));
209 supplementaryServicesIface->setRespondCallback(Tp::memFun(this,&oFonoConnection::USSDRespond));
210 supplementaryServicesIface->setCancelCallback(Tp::memFun(this,&oFonoConnection::USSDCancel));
211 supplementaryServicesIface->StateChanged(mOfonoSupplementaryServices->state());
212 supplementaryServicesIface->setSerial(mOfonoSupplementaryServices->modem()->serial());
213 plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(supplementaryServicesIface));
214
206 // Set Presence215 // Set Presence
207 Tp::SimpleStatusSpec presenceOnline;216 Tp::SimpleStatusSpec presenceOnline;
208 presenceOnline.type = Tp::ConnectionPresenceTypeAvailable;217 presenceOnline.type = Tp::ConnectionPresenceTypeAvailable;
@@ -226,6 +235,7 @@
226 if (mOfonoVoiceCallManager->modem()) {235 if (mOfonoVoiceCallManager->modem()) {
227 validModem = mOfonoVoiceCallManager->modem()->isValid();236 validModem = mOfonoVoiceCallManager->modem()->isValid();
228 if (validModem) {237 if (validModem) {
238 supplementaryServicesIface->setSerial(mOfonoSupplementaryServices->modem()->serial());
229 QObject::connect(mOfonoVoiceCallManager->modem(), SIGNAL(onlineChanged(bool)), SLOT(onValidityChanged(bool)));239 QObject::connect(mOfonoVoiceCallManager->modem(), SIGNAL(onlineChanged(bool)), SLOT(onValidityChanged(bool)));
230 }240 }
231 }241 }
@@ -246,7 +256,7 @@
246 QObject::connect(mOfonoNetworkRegistration, SIGNAL(statusChanged(QString)), SLOT(onOfonoNetworkRegistrationChanged(QString)));256 QObject::connect(mOfonoNetworkRegistration, SIGNAL(statusChanged(QString)), SLOT(onOfonoNetworkRegistrationChanged(QString)));
247 QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailMessageCountChanged(int)), voicemailIface.data(), SLOT(setVoicemailCount(int)));257 QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailMessageCountChanged(int)), voicemailIface.data(), SLOT(setVoicemailCount(int)));
248 QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailWaitingChanged(bool)), voicemailIface.data(), SLOT(setVoicemailIndicator(bool)));258 QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailWaitingChanged(bool)), voicemailIface.data(), SLOT(setVoicemailIndicator(bool)));
249259
250 QObject::connect(mRegisterTimer, SIGNAL(timeout()), SLOT(onTryRegister()));260 QObject::connect(mRegisterTimer, SIGNAL(timeout()), SLOT(onTryRegister()));
251261
252 QObject::connect(mMmsdManager, SIGNAL(serviceAdded(const QString&)), SLOT(onMMSDServiceAdded(const QString&)));262 QObject::connect(mMmsdManager, SIGNAL(serviceAdded(const QString&)), SLOT(onMMSDServiceAdded(const QString&)));
@@ -256,6 +266,38 @@
256 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callAdded(QString,QVariantMap)), SLOT(updateAudioRoute()));266 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callAdded(QString,QVariantMap)), SLOT(updateAudioRoute()));
257 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callRemoved(QString)), SLOT(updateAudioRoute()));267 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callRemoved(QString)), SLOT(updateAudioRoute()));
258268
269 QObject::connect(mOfonoSupplementaryServices, SIGNAL(notificationReceived(const QString &)), supplementaryServicesIface.data(), SLOT(NotificationReceived(const QString &)));
270 QObject::connect(mOfonoSupplementaryServices, SIGNAL(requestReceived(const QString &)), supplementaryServicesIface.data(), SLOT(RequestReceived(const QString &)));
271
272 QObject::connect(mOfonoSupplementaryServices, SIGNAL(initiateUSSDComplete(const QString &)), supplementaryServicesIface.data(), SLOT(InitiateUSSDComplete(const QString &)));
273
274 QObject::connect(mOfonoSupplementaryServices, SIGNAL(barringComplete(const QString &, const QString &, const QVariantMap &)),
275 supplementaryServicesIface.data(), SLOT(BarringComplete(const QString &, const QString &, const QVariantMap &)));
276
277 QObject::connect(mOfonoSupplementaryServices, SIGNAL(forwardingComplete(const QString &, const QString &, const QVariantMap &)),
278 supplementaryServicesIface.data(), SLOT(ForwardingComplete(const QString &, const QString &, const QVariantMap &)));
279
280 QObject::connect(mOfonoSupplementaryServices, SIGNAL(waitingComplete(const QString &, const QVariantMap &)),
281 supplementaryServicesIface.data(), SLOT(WaitingComplete(const QString &, const QVariantMap &)));
282
283 QObject::connect(mOfonoSupplementaryServices, SIGNAL(callingLinePresentationComplete(const QString &, const QString &)),
284 supplementaryServicesIface.data(), SLOT(CallingLinePresentationComplete(const QString &, const QString &)));
285
286 QObject::connect(mOfonoSupplementaryServices, SIGNAL(connectedLinePresentationComplete(const QString &, const QString &)),
287 supplementaryServicesIface.data(), SLOT(ConnectedLinePresentationComplete(const QString &, const QString &)));
288
289 QObject::connect(mOfonoSupplementaryServices, SIGNAL(callingLineRestrictionComplete(const QString &, const QString &)),
290 supplementaryServicesIface.data(), SLOT(CallingLineRestrictionComplete(const QString &, const QString &)));
291
292 QObject::connect(mOfonoSupplementaryServices, SIGNAL(connectedLineRestrictionComplete(const QString &, const QString &)),
293 supplementaryServicesIface.data(), SLOT(ConnectedLineRestrictionComplete(const QString &, const QString &)));
294
295 QObject::connect(mOfonoSupplementaryServices, SIGNAL(initiateFailed()), supplementaryServicesIface.data(), SLOT(InitiateFailed()));
296
297 QObject::connect(mOfonoSupplementaryServices, SIGNAL(stateChanged(const QString&)), supplementaryServicesIface.data(), SLOT(StateChanged(const QString&)));
298
299 QObject::connect(mOfonoSupplementaryServices, SIGNAL(respondComplete(bool, const QString &)), supplementaryServicesIface.data(), SLOT(RespondComplete(bool, const QString &)));
300
259 // workaround: we can't add services here as tp-ofono interfaces are not exposed on dbus301 // workaround: we can't add services here as tp-ofono interfaces are not exposed on dbus
260 // todo: use QDBusServiceWatcher302 // todo: use QDBusServiceWatcher
261 QTimer::singleShot(1000, this, SLOT(onCheckMMSServices()));303 QTimer::singleShot(1000, this, SLOT(onCheckMMSServices()));
@@ -493,6 +535,7 @@
493 qDebug() << "validityChanged" << valid << "is network registered: " << isNetworkRegistered() << mRequestedSelfPresence.type;535 qDebug() << "validityChanged" << valid << "is network registered: " << isNetworkRegistered() << mRequestedSelfPresence.type;
494 QObject::disconnect(mOfonoVoiceCallManager->modem(), 0,0,0);536 QObject::disconnect(mOfonoVoiceCallManager->modem(), 0,0,0);
495 QObject::connect(mOfonoVoiceCallManager->modem(), SIGNAL(onlineChanged(bool)), SLOT(onValidityChanged(bool)));537 QObject::connect(mOfonoVoiceCallManager->modem(), SIGNAL(onlineChanged(bool)), SLOT(onValidityChanged(bool)));
538 supplementaryServicesIface->setSerial(mOfonoSupplementaryServices->modem()->serial());
496 if (!isNetworkRegistered() && mRequestedSelfPresence.type == Tp::ConnectionPresenceTypeAvailable) {539 if (!isNetworkRegistered() && mRequestedSelfPresence.type == Tp::ConnectionPresenceTypeAvailable) {
497 setOnline(false);540 setOnline(false);
498 onTryRegister();541 onTryRegister();
@@ -933,6 +976,21 @@
933 }976 }
934}977}
935978
979void oFonoConnection::USSDInitiate(const QString &command, Tp::DBusError *error)
980{
981 mOfonoSupplementaryServices->initiate(command);
982}
983
984void oFonoConnection::USSDRespond(const QString &reply, Tp::DBusError *error)
985{
986 mOfonoSupplementaryServices->respond(reply);
987}
988
989void oFonoConnection::USSDCancel(Tp::DBusError *error)
990{
991 mOfonoSupplementaryServices->cancel();
992}
993
936void oFonoConnection::updateAudioRoute()994void oFonoConnection::updateAudioRoute()
937{995{
938 QByteArray pulseAudioDisabled = qgetenv("PA_DISABLED");996 QByteArray pulseAudioDisabled = qgetenv("PA_DISABLED");
939997
=== modified file 'connection.h'
--- connection.h 2014-02-14 17:48:08 +0000
+++ connection.h 2014-04-02 22:00:18 +0000
@@ -37,6 +37,7 @@
37#include <ofonocallvolume.h>37#include <ofonocallvolume.h>
38#include <ofononetworkregistration.h>38#include <ofononetworkregistration.h>
39#include <ofonomessagewaiting.h>39#include <ofonomessagewaiting.h>
40#include <ofonosupplementaryservices.h>
4041
41// telepathy-ofono42// telepathy-ofono
42#include "ofonotextchannel.h"43#include "ofonotextchannel.h"
@@ -46,6 +47,7 @@
46#include "mmsdmessage.h"47#include "mmsdmessage.h"
47#include "dbustypes.h"48#include "dbustypes.h"
48#include "speakeriface.h"49#include "speakeriface.h"
50#include "ussdiface.h"
4951
50class oFonoConnection;52class oFonoConnection;
51class oFonoTextChannel;53class oFonoTextChannel;
@@ -76,11 +78,15 @@
76 bool voicemailIndicator(Tp::DBusError *error);78 bool voicemailIndicator(Tp::DBusError *error);
77 QString voicemailNumber(Tp::DBusError *error);79 QString voicemailNumber(Tp::DBusError *error);
78 uint voicemailCount(Tp::DBusError *error);80 uint voicemailCount(Tp::DBusError *error);
81 void USSDInitiate(const QString &command, Tp::DBusError *error);
82 void USSDRespond(const QString &reply, Tp::DBusError *error);
83 void USSDCancel(Tp::DBusError *error);
7984
80 Tp::BaseConnectionRequestsInterfacePtr requestsIface;85 Tp::BaseConnectionRequestsInterfacePtr requestsIface;
81 Tp::BaseConnectionSimplePresenceInterfacePtr simplePresenceIface;86 Tp::BaseConnectionSimplePresenceInterfacePtr simplePresenceIface;
82 Tp::BaseConnectionContactsInterfacePtr contactsIface;87 Tp::BaseConnectionContactsInterfacePtr contactsIface;
83 BaseConnectionVoicemailInterfacePtr voicemailIface;88 BaseConnectionVoicemailInterfacePtr voicemailIface;
89 BaseConnectionUSSDInterfacePtr supplementaryServicesIface;
84 uint newHandle(const QString &identifier);90 uint newHandle(const QString &identifier);
8591
86 OfonoMessageManager *messageManager();92 OfonoMessageManager *messageManager();
@@ -144,6 +150,7 @@
144 OfonoCallVolume *mOfonoCallVolume;150 OfonoCallVolume *mOfonoCallVolume;
145 OfonoNetworkRegistration *mOfonoNetworkRegistration;151 OfonoNetworkRegistration *mOfonoNetworkRegistration;
146 OfonoMessageWaiting *mOfonoMessageWaiting;152 OfonoMessageWaiting *mOfonoMessageWaiting;
153 OfonoSupplementaryServices *mOfonoSupplementaryServices;
147 uint mHandleCount;154 uint mHandleCount;
148 Tp::SimplePresence mSelfPresence;155 Tp::SimplePresence mSelfPresence;
149 Tp::SimplePresence mRequestedSelfPresence;156 Tp::SimplePresence mRequestedSelfPresence;
150157
=== modified file 'tests/dbus-test-wrapper.sh.in'
--- tests/dbus-test-wrapper.sh.in 2014-02-19 16:08:33 +0000
+++ tests/dbus-test-wrapper.sh.in 2014-04-02 22:00:18 +0000
@@ -11,6 +11,7 @@
11# we need to set this otherwise mission-control doesn't work properly11# we need to set this otherwise mission-control doesn't work properly
12dconf write /org/gnome/empathy/use-conn false12dconf write /org/gnome/empathy/use-conn false
1313
14export PA_DISABLED=1
14# start telepathy-ofono with the ofono-qt mock library15# start telepathy-ofono with the ofono-qt mock library
15LD_PRELOAD=@CMAKE_CURRENT_BINARY_DIR@/mock/libofono-qt.so ${CMAKE_BINARY_DIR}/telepathy-ofono &16LD_PRELOAD=@CMAKE_CURRENT_BINARY_DIR@/mock/libofono-qt.so ${CMAKE_BINARY_DIR}/telepathy-ofono &
1617
1718
=== added file 'ussdiface.cpp'
--- ussdiface.cpp 1970-01-01 00:00:00 +0000
+++ ussdiface.cpp 2014-04-02 22:00:18 +0000
@@ -0,0 +1,311 @@
1/**
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
17 */
18
19#include <QDebug>
20
21#include <TelepathyQt/Constants>
22#include <TelepathyQt/DBusObject>
23
24#include "ussdiface.h"
25
26// Conn.I.USSD
27BaseConnectionUSSDInterface::Adaptee::Adaptee(BaseConnectionUSSDInterface *interface)
28 : QObject(interface),
29 mInterface(interface)
30{
31}
32
33
34struct TP_QT_NO_EXPORT BaseConnectionUSSDInterface::Private {
35 Private(BaseConnectionUSSDInterface *parent)
36 : adaptee(new BaseConnectionUSSDInterface::Adaptee(parent)) {
37 }
38 QString state;
39 QString serial;
40 InitiateCallback initiateCB;
41 RespondCallback respondCB;
42 CancelCallback cancelCB;
43 BaseConnectionUSSDInterface::Adaptee *adaptee;
44};
45
46BaseConnectionUSSDInterface::Adaptee::~Adaptee()
47{
48}
49
50void BaseConnectionUSSDInterface::Adaptee::initiate(const QString &command, const ConnectionInterfaceUSSDAdaptor::InitiateContextPtr &context)
51{
52 if (!mInterface->mPriv->initiateCB.isValid()) {
53 context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
54 return;
55 }
56 Tp::DBusError error;
57 mInterface->mPriv->initiateCB(command, &error);
58 if (error.isValid()) {
59 context->setFinishedWithError(error.name(), error.message());
60 return;
61 }
62 context->setFinished();
63}
64
65void BaseConnectionUSSDInterface::Adaptee::respond(const QString &reply, const ConnectionInterfaceUSSDAdaptor::RespondContextPtr &context)
66{
67 if (!mInterface->mPriv->respondCB.isValid()) {
68 context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
69 return;
70 }
71 Tp::DBusError error;
72 mInterface->mPriv->respondCB(reply, &error);
73 if (error.isValid()) {
74 context->setFinishedWithError(error.name(), error.message());
75 return;
76 }
77 context->setFinished();
78}
79
80void BaseConnectionUSSDInterface::Adaptee::cancel(const ConnectionInterfaceUSSDAdaptor::CancelContextPtr &context)
81{
82 if (!mInterface->mPriv->cancelCB.isValid()) {
83 context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
84 return;
85 }
86 Tp::DBusError error;
87 mInterface->mPriv->cancelCB(&error);
88 if (error.isValid()) {
89 context->setFinishedWithError(error.name(), error.message());
90 return;
91 }
92 context->setFinished();
93}
94
95BaseConnectionUSSDInterface::BaseConnectionUSSDInterface()
96 : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_USSD),
97 mPriv(new Private(this))
98{
99}
100
101BaseConnectionUSSDInterface::~BaseConnectionUSSDInterface()
102{
103 delete mPriv;
104}
105
106void BaseConnectionUSSDInterface::setInitiateCallback(const InitiateCallback &cb)
107{
108 mPriv->initiateCB = cb;
109}
110
111void BaseConnectionUSSDInterface::setRespondCallback(const RespondCallback &cb)
112{
113 mPriv->respondCB = cb;
114}
115
116void BaseConnectionUSSDInterface::setCancelCallback(const CancelCallback &cb)
117{
118 mPriv->cancelCB = cb;
119}
120
121QString BaseConnectionUSSDInterface::state() const
122{
123 return mPriv->state;
124}
125
126void BaseConnectionUSSDInterface::setSerial(const QString &serial) const
127{
128 mPriv->serial = serial;
129}
130
131
132QString BaseConnectionUSSDInterface::serial() const
133{
134 return mPriv->serial;
135}
136
137void BaseConnectionUSSDInterface::StateChanged(const QString &state)
138{
139 mPriv->state = state;
140 Q_EMIT mPriv->adaptee->stateChanged(state);
141}
142
143void BaseConnectionUSSDInterface::InitiateUSSDComplete(const QString &ussdResp)
144{
145 Q_EMIT mPriv->adaptee->initiateUSSDComplete(ussdResp);
146}
147
148void BaseConnectionUSSDInterface::RespondComplete(bool success, const QString &ussdResp)
149{
150 Q_EMIT mPriv->adaptee->respondComplete(success, ussdResp);
151}
152
153void BaseConnectionUSSDInterface::BarringComplete(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap)
154{
155 Q_EMIT mPriv->adaptee->barringComplete(ssOp, cbService, cbMap);
156}
157
158void BaseConnectionUSSDInterface::ForwardingComplete(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap)
159{
160 Q_EMIT mPriv->adaptee->forwardingComplete(ssOp, cfService, cfMap);
161}
162
163void BaseConnectionUSSDInterface::WaitingComplete(const QString &ssOp, const QVariantMap &cwMap)
164{
165 Q_EMIT mPriv->adaptee->waitingComplete(ssOp, cwMap);
166}
167
168void BaseConnectionUSSDInterface::CallingLinePresentationComplete(const QString &ssOp, const QString &status)
169{
170 Q_EMIT mPriv->adaptee->callingLinePresentationComplete(ssOp, status);
171}
172
173void BaseConnectionUSSDInterface::ConnectedLinePresentationComplete(const QString &ssOp, const QString &status)
174{
175 Q_EMIT mPriv->adaptee->connectedLinePresentationComplete(ssOp, status);
176}
177
178void BaseConnectionUSSDInterface::CallingLineRestrictionComplete(const QString &ssOp, const QString &status)
179{
180 Q_EMIT mPriv->adaptee->callingLineRestrictionComplete(ssOp, status);
181}
182
183void BaseConnectionUSSDInterface::ConnectedLineRestrictionComplete(const QString &ssOp, const QString &status)
184{
185 Q_EMIT mPriv->adaptee->connectedLineRestrictionComplete(ssOp, status);
186}
187
188void BaseConnectionUSSDInterface::InitiateFailed()
189{
190 Q_EMIT mPriv->adaptee->initiateFailed();
191}
192
193void BaseConnectionUSSDInterface::NotificationReceived(const QString &message)
194{
195 Q_EMIT mPriv->adaptee->notificationReceived(message);
196}
197
198void BaseConnectionUSSDInterface::RequestReceived(const QString &message)
199{
200 Q_EMIT mPriv->adaptee->requestReceived(message);
201}
202
203
204QVariantMap BaseConnectionUSSDInterface::immutableProperties() const
205{
206 QVariantMap map;
207 return map;
208}
209
210void BaseConnectionUSSDInterface::createAdaptor()
211{
212 (void) new ConnectionInterfaceUSSDAdaptor(dbusObject()->dbusConnection(),
213 mPriv->adaptee, dbusObject());
214}
215
216
217ConnectionInterfaceUSSDAdaptor::ConnectionInterfaceUSSDAdaptor(const QDBusConnection& bus, QObject* adaptee, QObject* parent)
218 : Tp::AbstractAdaptor(bus, adaptee, parent)
219{
220 connect(adaptee, SIGNAL(notificationReceived(const QString &)), SIGNAL(NotificationReceived(const QString &)));
221 connect(adaptee, SIGNAL(requestReceived(const QString &)), SIGNAL(RequestReceived(const QString &)));
222
223 connect(adaptee, SIGNAL(initiateUSSDComplete(const QString &)), SIGNAL(InitiateUSSDComplete(const QString &)));
224
225 connect(adaptee, SIGNAL(barringComplete(const QString &, const QString &, const QVariantMap &)),
226 SIGNAL(BarringComplete(const QString &, const QString &, const QVariantMap &)));
227
228 connect(adaptee, SIGNAL(forwardingComplete(const QString &, const QString &, const QVariantMap &)),
229 SIGNAL(ForwardingComplete(const QString &, const QString &, const QVariantMap &)));
230
231 connect(adaptee, SIGNAL(waitingComplete(const QString &, const QVariantMap &)),
232 SIGNAL(WaitingComplete(const QString &, const QVariantMap &)));
233
234 connect(adaptee, SIGNAL(callingLinePresentationComplete(const QString &, const QString &)),
235 SIGNAL(CallingLinePresentationComplete(const QString &, const QString &)));
236
237 connect(adaptee, SIGNAL(connectedLinePresentationComplete(const QString &, const QString &)),
238 SIGNAL(ConnectedLinePresentationComplete(const QString &, const QString &)));
239
240 connect(adaptee, SIGNAL(callingLineRestrictionComplete(const QString &, const QString &)),
241 SIGNAL(CallingLineRestrictionComplete(const QString &, const QString &)));
242
243 connect(adaptee, SIGNAL(connectedLineRestrictionComplete(const QString &, const QString &)),
244 SIGNAL(ConnectedLineRestrictionComplete(const QString &, const QString &)));
245
246 connect(adaptee, SIGNAL(initiateFailed()), SIGNAL(InitiateFailed()));
247
248 connect(adaptee, SIGNAL(stateChanged(const QString&)), SIGNAL(StateChanged(const QString&)));
249
250 connect(adaptee, SIGNAL(respondComplete(bool, const QString &)), SIGNAL(RespondComplete(bool, const QString &)));
251}
252
253ConnectionInterfaceUSSDAdaptor::~ConnectionInterfaceUSSDAdaptor()
254{
255}
256
257void ConnectionInterfaceUSSDAdaptor::Initiate(const QString &command, const QDBusMessage& dbusMessage)
258{
259 if (!adaptee()->metaObject()->indexOfMethod("initiate(const QString &,ConnectionInterfaceUSSDAdaptor::InitiateContextPtr)") == -1) {
260 dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
261 return;
262 }
263
264 InitiateContextPtr ctx = InitiateContextPtr(
265 new Tp::MethodInvocationContext< >(dbusConnection(), dbusMessage));
266 QMetaObject::invokeMethod(adaptee(), "initiate",
267 Q_ARG(QString, command),
268 Q_ARG(ConnectionInterfaceUSSDAdaptor::InitiateContextPtr, ctx));
269 return;
270}
271
272void ConnectionInterfaceUSSDAdaptor::Respond(const QString &reply, const QDBusMessage& dbusMessage)
273{
274 if (!adaptee()->metaObject()->indexOfMethod("respond(QConnectionInterfaceUSSDAdaptor::RespondContextPtr)") == -1) {
275 dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
276 return;
277 }
278
279 RespondContextPtr ctx = RespondContextPtr(
280 new Tp::MethodInvocationContext< >(dbusConnection(), dbusMessage));
281 QMetaObject::invokeMethod(adaptee(), "respond",
282 Q_ARG(QString, reply),
283 Q_ARG(ConnectionInterfaceUSSDAdaptor::RespondContextPtr, ctx));
284 return;
285}
286
287void ConnectionInterfaceUSSDAdaptor::Cancel(const QDBusMessage& dbusMessage)
288{
289 if (!adaptee()->metaObject()->indexOfMethod("cancel(ConnectionInterfaceUSSDAdaptor::CancelContextPtr)") == -1) {
290 dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
291 return;
292 }
293
294 CancelContextPtr ctx = CancelContextPtr(
295 new Tp::MethodInvocationContext< >(dbusConnection(), dbusMessage));
296 QMetaObject::invokeMethod(adaptee(), "cancel",
297 Q_ARG(ConnectionInterfaceUSSDAdaptor::CancelContextPtr, ctx));
298 return;
299}
300
301QString ConnectionInterfaceUSSDAdaptor::Serial() const
302{
303 return qvariant_cast< QString >(adaptee()->property("serial"));
304}
305
306
307QString ConnectionInterfaceUSSDAdaptor::State() const
308{
309 return qvariant_cast< QString >(adaptee()->property("state"));
310}
311
0312
=== added file 'ussdiface.h'
--- ussdiface.h 1970-01-01 00:00:00 +0000
+++ ussdiface.h 2014-04-02 22:00:18 +0000
@@ -0,0 +1,243 @@
1/**
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
17 */
18
19#ifndef OFONOUSSDIFACE_H
20#define OFONOUSSDIFACE_H
21
22// telepathy-qt
23#include <TelepathyQt/Constants>
24#include <TelepathyQt/BaseConnection>
25#include <TelepathyQt/AbstractAdaptor>
26#include <TelepathyQt/DBusError>
27#include <TelepathyQt/Callbacks>
28
29class BaseConnectionUSSDInterface;
30
31typedef Tp::SharedPtr<BaseConnectionUSSDInterface> BaseConnectionUSSDInterfacePtr;
32
33#define TP_QT_IFACE_CONNECTION_USSD "com.canonical.Telephony.USSD"
34
35class TP_QT_EXPORT BaseConnectionUSSDInterface : public Tp::AbstractConnectionInterface
36{
37 Q_OBJECT
38 Q_DISABLE_COPY(BaseConnectionUSSDInterface)
39
40public:
41 static BaseConnectionUSSDInterfacePtr create() {
42 return BaseConnectionUSSDInterfacePtr(new BaseConnectionUSSDInterface());
43 }
44 template<typename BaseConnectionUSSDInterfaceSubclass>
45 static Tp::SharedPtr<BaseConnectionUSSDInterfaceSubclass> create() {
46 return Tp::SharedPtr<BaseConnectionUSSDInterfaceSubclass>(
47 new BaseConnectionUSSDInterfaceSubclass());
48 }
49 QVariantMap immutableProperties() const;
50 virtual ~BaseConnectionUSSDInterface();
51
52 typedef Tp::Callback2<void, const QString&, Tp::DBusError*> InitiateCallback;
53 void setInitiateCallback(const InitiateCallback &cb);
54
55 typedef Tp::Callback2<void, const QString&, Tp::DBusError*> RespondCallback;
56 void setRespondCallback(const RespondCallback &cb);
57
58 typedef Tp::Callback1<void, Tp::DBusError*> CancelCallback;
59 void setCancelCallback(const CancelCallback &cb);
60
61
62 QString state() const;
63 QString serial() const;
64 void setSerial(const QString& serial) const;
65
66public Q_SLOTS:
67 void NotificationReceived(const QString &message);
68 void RequestReceived(const QString &message);
69
70 void InitiateUSSDComplete(const QString &ussdResp);
71 void RespondComplete(bool success, const QString &ussdResp);
72 void BarringComplete(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap);
73 void ForwardingComplete(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap);
74 void WaitingComplete(const QString &ssOp, const QVariantMap &cwMap);
75 void CallingLinePresentationComplete(const QString &ssOp, const QString &status);
76 void ConnectedLinePresentationComplete(const QString &ssOp, const QString &status);
77 void CallingLineRestrictionComplete(const QString &ssOp, const QString &status);
78 void ConnectedLineRestrictionComplete(const QString &ssOp, const QString &status);
79 void InitiateFailed();
80 void StateChanged(const QString &state);
81
82protected:
83 BaseConnectionUSSDInterface();
84
85private:
86 void createAdaptor();
87
88 class Adaptee;
89 friend class Adaptee;
90 struct Private;
91 friend struct Private;
92 Private *mPriv;
93};
94
95
96class TP_QT_EXPORT ConnectionInterfaceUSSDAdaptor : public Tp::AbstractAdaptor
97{
98 Q_OBJECT
99 Q_CLASSINFO("D-Bus Interface", TP_QT_IFACE_CONNECTION_USSD)
100 Q_CLASSINFO("D-Bus Introspection", ""
101" <interface name=\"com.canonical.Telephony.USSD\">\n"
102" <property access=\"read\" type=\"s\" name=\"State\"/>\n"
103" <property access=\"read\" type=\"s\" name=\"Serial\"/>\n"
104" <method name=\"Initiate\">\n"
105" <arg direction=\"in\" type=\"s\" name=\"command\"/>\n"
106" </method>\n"
107" <method name=\"Respond\">\n"
108" <arg direction=\"in\" type=\"s\" name=\"reply\"/>\n"
109" </method>\n"
110" <method name=\"Cancel\" />\n"
111" <signal name=\"NotificationReceived\">\n"
112" <arg type=\"s\" name=\"message\"/>\n"
113" </signal>\n"
114" <signal name=\"RequestReceived\">\n"
115" <arg type=\"s\" name=\"message\"/>\n"
116" </signal>\n"
117" <signal name=\"InitiateUSSDComplete\">\n"
118" <arg type=\"s\" name=\"response\"/>\n"
119" </signal>\n"
120" <signal name=\"RespondComplete\">\n"
121" <arg type=\"b\" name=\"success\"/>\n"
122" <arg type=\"s\" name=\"response\"/>\n"
123" </signal>\n"
124" <signal name=\"BarringComplete\">\n"
125" <arg type=\"s\" name=\"ssOp\"/>\n"
126" <arg type=\"s\" name=\"cbService\"/>\n"
127" <arg type=\"a{sv}\" name=\"cbMap\"/>\n"
128" </signal>\n"
129" <signal name=\"ForwardingComplete\">\n"
130" <arg type=\"s\" name=\"ssOp\"/>\n"
131" <arg type=\"s\" name=\"cfService\"/>\n"
132" <arg type=\"a{sv}\" name=\"cfMap\"/>\n"
133" </signal>\n"
134" <signal name=\"WaitingComplete\">\n"
135" <arg type=\"s\" name=\"ssOp\"/>\n"
136" <arg type=\"a{sv}\" name=\"cwMap\"/>\n"
137" </signal>\n"
138" <signal name=\"CallingLinePresentationComplete\">\n"
139" <arg type=\"s\" name=\"ssOp\"/>\n"
140" <arg type=\"s\" name=\"status\"/>\n"
141" </signal>\n"
142" <signal name=\"ConnectedLinePresentationComplete\">\n"
143" <arg type=\"s\" name=\"ssOp\"/>\n"
144" <arg type=\"s\" name=\"status\"/>\n"
145" </signal>\n"
146" <signal name=\"CallingLineRestrictionComplete\">\n"
147" <arg type=\"s\" name=\"ssOp\"/>\n"
148" <arg type=\"s\" name=\"status\"/>\n"
149" </signal>\n"
150" <signal name=\"ConnectedLineRestrictionComplete\">\n"
151" <arg type=\"s\" name=\"ssOp\"/>\n"
152" <arg type=\"s\" name=\"status\"/>\n"
153" </signal>\n"
154" <signal name=\"InitiateFailed\" />\n"
155" <signal name=\"StateChanged\">\n"
156" <arg type=\"s\" name=\"state\"/>\n"
157" </signal>\n"
158" </interface>\n"
159"")
160 Q_PROPERTY(QString State READ State)
161 Q_PROPERTY(QString Serial READ Serial)
162
163public:
164 ConnectionInterfaceUSSDAdaptor(const QDBusConnection& dbusConnection, QObject* adaptee, QObject* parent);
165 virtual ~ConnectionInterfaceUSSDAdaptor();
166
167 typedef Tp::MethodInvocationContextPtr< > InitiateContextPtr;
168 typedef Tp::MethodInvocationContextPtr< > RespondContextPtr;
169 typedef Tp::MethodInvocationContextPtr< > CancelContextPtr;
170
171public Q_SLOTS: // METHODS
172 void Initiate(const QString &command, const QDBusMessage& dbusMessage);
173 void Respond(const QString &reply, const QDBusMessage& dbusMessage);
174 void Cancel(const QDBusMessage& dbusMessage);
175
176 QString State() const;
177 QString Serial() const;
178
179Q_SIGNALS: // SIGNALS
180 void NotificationReceived(const QString &message);
181 void RequestReceived(const QString &message);
182
183 void InitiateUSSDComplete(const QString &ussdResp);
184 void RespondComplete(bool success, const QString &ussdResp);
185 void BarringComplete(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap);
186 void ForwardingComplete(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap);
187 void WaitingComplete(const QString &ssOp, const QVariantMap &cwMap);
188 void CallingLinePresentationComplete(const QString &ssOp, const QString &status);
189 void ConnectedLinePresentationComplete(const QString &ssOp, const QString &status);
190 void CallingLineRestrictionComplete(const QString &ssOp, const QString &status);
191 void ConnectedLineRestrictionComplete(const QString &ssOp, const QString &status);
192 void InitiateFailed();
193
194 void StateChanged(const QString &state);
195};
196
197
198class TP_QT_NO_EXPORT BaseConnectionUSSDInterface::Adaptee : public QObject
199{
200 Q_OBJECT
201 Q_PROPERTY(QString state READ state)
202 Q_PROPERTY(QString serial READ serial)
203
204public:
205 Adaptee(BaseConnectionUSSDInterface *interface);
206 ~Adaptee();
207 QString state() const
208 {
209 return mInterface->state();
210 }
211 QString serial() const
212 {
213 return mInterface->serial();
214 }
215
216
217private Q_SLOTS:
218 void initiate(const QString &command, const ConnectionInterfaceUSSDAdaptor::InitiateContextPtr &context);
219 void respond(const QString &reply, const ConnectionInterfaceUSSDAdaptor::RespondContextPtr &context);
220 void cancel(const ConnectionInterfaceUSSDAdaptor::CancelContextPtr &context);
221
222Q_SIGNALS:
223 void notificationReceived(const QString &message);
224 void requestReceived(const QString &message);
225
226 void initiateUSSDComplete(const QString &ussdResp);
227 void barringComplete(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap);
228 void forwardingComplete(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap);
229 void waitingComplete(const QString &ssOp, const QVariantMap &cwMap);
230 void callingLinePresentationComplete(const QString &ssOp, const QString &status);
231 void connectedLinePresentationComplete(const QString &ssOp, const QString &status);
232 void callingLineRestrictionComplete(const QString &ssOp, const QString &status);
233 void connectedLineRestrictionComplete(const QString &ssOp, const QString &status);
234 void initiateFailed();
235 void respondComplete(bool success, const QString &response);
236
237 void stateChanged(const QString &state);
238
239public:
240 BaseConnectionUSSDInterface *mInterface;
241};
242
243#endif

Subscribers

People subscribed via source and target branches