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
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-02-07 20:03:39 +0000
3+++ CMakeLists.txt 2014-04-02 22:00:18 +0000
4@@ -97,6 +97,7 @@
5 pendingmessagesmanager.cpp
6 phoneutils.cpp
7 sqlitedatabase.cpp
8+ ussdiface.cpp
9 ${telepathyfono_RES})
10
11 if(USE_PULSEAUDIO)
12
13=== modified file 'connection.cpp'
14--- connection.cpp 2014-03-19 02:36:35 +0000
15+++ connection.cpp 2014-04-02 22:00:18 +0000
16@@ -153,6 +153,7 @@
17 mOfonoCallVolume = new OfonoCallVolume(setting, modemPath);
18 mOfonoNetworkRegistration = new OfonoNetworkRegistration(setting, modemPath);
19 mOfonoMessageWaiting = new OfonoMessageWaiting(setting, modemPath);
20+ mOfonoSupplementaryServices = new OfonoSupplementaryServices(setting, modemPath);
21
22 setSelfHandle(newHandle("<SelfHandle>"));
23
24@@ -203,6 +204,14 @@
25 voicemailIface->setVoicemailNumberCallback(Tp::memFun(this,&oFonoConnection::voicemailNumber));
26 plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(voicemailIface));
27
28+ supplementaryServicesIface = BaseConnectionUSSDInterface::create();
29+ supplementaryServicesIface->setInitiateCallback(Tp::memFun(this,&oFonoConnection::USSDInitiate));
30+ supplementaryServicesIface->setRespondCallback(Tp::memFun(this,&oFonoConnection::USSDRespond));
31+ supplementaryServicesIface->setCancelCallback(Tp::memFun(this,&oFonoConnection::USSDCancel));
32+ supplementaryServicesIface->StateChanged(mOfonoSupplementaryServices->state());
33+ supplementaryServicesIface->setSerial(mOfonoSupplementaryServices->modem()->serial());
34+ plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(supplementaryServicesIface));
35+
36 // Set Presence
37 Tp::SimpleStatusSpec presenceOnline;
38 presenceOnline.type = Tp::ConnectionPresenceTypeAvailable;
39@@ -226,6 +235,7 @@
40 if (mOfonoVoiceCallManager->modem()) {
41 validModem = mOfonoVoiceCallManager->modem()->isValid();
42 if (validModem) {
43+ supplementaryServicesIface->setSerial(mOfonoSupplementaryServices->modem()->serial());
44 QObject::connect(mOfonoVoiceCallManager->modem(), SIGNAL(onlineChanged(bool)), SLOT(onValidityChanged(bool)));
45 }
46 }
47@@ -246,7 +256,7 @@
48 QObject::connect(mOfonoNetworkRegistration, SIGNAL(statusChanged(QString)), SLOT(onOfonoNetworkRegistrationChanged(QString)));
49 QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailMessageCountChanged(int)), voicemailIface.data(), SLOT(setVoicemailCount(int)));
50 QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailWaitingChanged(bool)), voicemailIface.data(), SLOT(setVoicemailIndicator(bool)));
51-
52+
53 QObject::connect(mRegisterTimer, SIGNAL(timeout()), SLOT(onTryRegister()));
54
55 QObject::connect(mMmsdManager, SIGNAL(serviceAdded(const QString&)), SLOT(onMMSDServiceAdded(const QString&)));
56@@ -256,6 +266,38 @@
57 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callAdded(QString,QVariantMap)), SLOT(updateAudioRoute()));
58 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callRemoved(QString)), SLOT(updateAudioRoute()));
59
60+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(notificationReceived(const QString &)), supplementaryServicesIface.data(), SLOT(NotificationReceived(const QString &)));
61+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(requestReceived(const QString &)), supplementaryServicesIface.data(), SLOT(RequestReceived(const QString &)));
62+
63+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(initiateUSSDComplete(const QString &)), supplementaryServicesIface.data(), SLOT(InitiateUSSDComplete(const QString &)));
64+
65+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(barringComplete(const QString &, const QString &, const QVariantMap &)),
66+ supplementaryServicesIface.data(), SLOT(BarringComplete(const QString &, const QString &, const QVariantMap &)));
67+
68+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(forwardingComplete(const QString &, const QString &, const QVariantMap &)),
69+ supplementaryServicesIface.data(), SLOT(ForwardingComplete(const QString &, const QString &, const QVariantMap &)));
70+
71+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(waitingComplete(const QString &, const QVariantMap &)),
72+ supplementaryServicesIface.data(), SLOT(WaitingComplete(const QString &, const QVariantMap &)));
73+
74+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(callingLinePresentationComplete(const QString &, const QString &)),
75+ supplementaryServicesIface.data(), SLOT(CallingLinePresentationComplete(const QString &, const QString &)));
76+
77+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(connectedLinePresentationComplete(const QString &, const QString &)),
78+ supplementaryServicesIface.data(), SLOT(ConnectedLinePresentationComplete(const QString &, const QString &)));
79+
80+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(callingLineRestrictionComplete(const QString &, const QString &)),
81+ supplementaryServicesIface.data(), SLOT(CallingLineRestrictionComplete(const QString &, const QString &)));
82+
83+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(connectedLineRestrictionComplete(const QString &, const QString &)),
84+ supplementaryServicesIface.data(), SLOT(ConnectedLineRestrictionComplete(const QString &, const QString &)));
85+
86+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(initiateFailed()), supplementaryServicesIface.data(), SLOT(InitiateFailed()));
87+
88+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(stateChanged(const QString&)), supplementaryServicesIface.data(), SLOT(StateChanged(const QString&)));
89+
90+ QObject::connect(mOfonoSupplementaryServices, SIGNAL(respondComplete(bool, const QString &)), supplementaryServicesIface.data(), SLOT(RespondComplete(bool, const QString &)));
91+
92 // workaround: we can't add services here as tp-ofono interfaces are not exposed on dbus
93 // todo: use QDBusServiceWatcher
94 QTimer::singleShot(1000, this, SLOT(onCheckMMSServices()));
95@@ -493,6 +535,7 @@
96 qDebug() << "validityChanged" << valid << "is network registered: " << isNetworkRegistered() << mRequestedSelfPresence.type;
97 QObject::disconnect(mOfonoVoiceCallManager->modem(), 0,0,0);
98 QObject::connect(mOfonoVoiceCallManager->modem(), SIGNAL(onlineChanged(bool)), SLOT(onValidityChanged(bool)));
99+ supplementaryServicesIface->setSerial(mOfonoSupplementaryServices->modem()->serial());
100 if (!isNetworkRegistered() && mRequestedSelfPresence.type == Tp::ConnectionPresenceTypeAvailable) {
101 setOnline(false);
102 onTryRegister();
103@@ -933,6 +976,21 @@
104 }
105 }
106
107+void oFonoConnection::USSDInitiate(const QString &command, Tp::DBusError *error)
108+{
109+ mOfonoSupplementaryServices->initiate(command);
110+}
111+
112+void oFonoConnection::USSDRespond(const QString &reply, Tp::DBusError *error)
113+{
114+ mOfonoSupplementaryServices->respond(reply);
115+}
116+
117+void oFonoConnection::USSDCancel(Tp::DBusError *error)
118+{
119+ mOfonoSupplementaryServices->cancel();
120+}
121+
122 void oFonoConnection::updateAudioRoute()
123 {
124 QByteArray pulseAudioDisabled = qgetenv("PA_DISABLED");
125
126=== modified file 'connection.h'
127--- connection.h 2014-02-14 17:48:08 +0000
128+++ connection.h 2014-04-02 22:00:18 +0000
129@@ -37,6 +37,7 @@
130 #include <ofonocallvolume.h>
131 #include <ofononetworkregistration.h>
132 #include <ofonomessagewaiting.h>
133+#include <ofonosupplementaryservices.h>
134
135 // telepathy-ofono
136 #include "ofonotextchannel.h"
137@@ -46,6 +47,7 @@
138 #include "mmsdmessage.h"
139 #include "dbustypes.h"
140 #include "speakeriface.h"
141+#include "ussdiface.h"
142
143 class oFonoConnection;
144 class oFonoTextChannel;
145@@ -76,11 +78,15 @@
146 bool voicemailIndicator(Tp::DBusError *error);
147 QString voicemailNumber(Tp::DBusError *error);
148 uint voicemailCount(Tp::DBusError *error);
149+ void USSDInitiate(const QString &command, Tp::DBusError *error);
150+ void USSDRespond(const QString &reply, Tp::DBusError *error);
151+ void USSDCancel(Tp::DBusError *error);
152
153 Tp::BaseConnectionRequestsInterfacePtr requestsIface;
154 Tp::BaseConnectionSimplePresenceInterfacePtr simplePresenceIface;
155 Tp::BaseConnectionContactsInterfacePtr contactsIface;
156 BaseConnectionVoicemailInterfacePtr voicemailIface;
157+ BaseConnectionUSSDInterfacePtr supplementaryServicesIface;
158 uint newHandle(const QString &identifier);
159
160 OfonoMessageManager *messageManager();
161@@ -144,6 +150,7 @@
162 OfonoCallVolume *mOfonoCallVolume;
163 OfonoNetworkRegistration *mOfonoNetworkRegistration;
164 OfonoMessageWaiting *mOfonoMessageWaiting;
165+ OfonoSupplementaryServices *mOfonoSupplementaryServices;
166 uint mHandleCount;
167 Tp::SimplePresence mSelfPresence;
168 Tp::SimplePresence mRequestedSelfPresence;
169
170=== modified file 'tests/dbus-test-wrapper.sh.in'
171--- tests/dbus-test-wrapper.sh.in 2014-02-19 16:08:33 +0000
172+++ tests/dbus-test-wrapper.sh.in 2014-04-02 22:00:18 +0000
173@@ -11,6 +11,7 @@
174 # we need to set this otherwise mission-control doesn't work properly
175 dconf write /org/gnome/empathy/use-conn false
176
177+export PA_DISABLED=1
178 # start telepathy-ofono with the ofono-qt mock library
179 LD_PRELOAD=@CMAKE_CURRENT_BINARY_DIR@/mock/libofono-qt.so ${CMAKE_BINARY_DIR}/telepathy-ofono &
180
181
182=== added file 'ussdiface.cpp'
183--- ussdiface.cpp 1970-01-01 00:00:00 +0000
184+++ ussdiface.cpp 2014-04-02 22:00:18 +0000
185@@ -0,0 +1,311 @@
186+/**
187+ * Copyright (C) 2013 Canonical, Ltd.
188+ *
189+ * This program is free software: you can redistribute it and/or modify it under
190+ * the terms of the GNU Lesser General Public License version 3, as published by
191+ * the Free Software Foundation.
192+ *
193+ * This program is distributed in the hope that it will be useful, but WITHOUT
194+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
195+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
196+ * Lesser General Public License for more details.
197+ *
198+ * You should have received a copy of the GNU Lesser General Public License
199+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
200+ *
201+ * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
202+ */
203+
204+#include <QDebug>
205+
206+#include <TelepathyQt/Constants>
207+#include <TelepathyQt/DBusObject>
208+
209+#include "ussdiface.h"
210+
211+// Conn.I.USSD
212+BaseConnectionUSSDInterface::Adaptee::Adaptee(BaseConnectionUSSDInterface *interface)
213+ : QObject(interface),
214+ mInterface(interface)
215+{
216+}
217+
218+
219+struct TP_QT_NO_EXPORT BaseConnectionUSSDInterface::Private {
220+ Private(BaseConnectionUSSDInterface *parent)
221+ : adaptee(new BaseConnectionUSSDInterface::Adaptee(parent)) {
222+ }
223+ QString state;
224+ QString serial;
225+ InitiateCallback initiateCB;
226+ RespondCallback respondCB;
227+ CancelCallback cancelCB;
228+ BaseConnectionUSSDInterface::Adaptee *adaptee;
229+};
230+
231+BaseConnectionUSSDInterface::Adaptee::~Adaptee()
232+{
233+}
234+
235+void BaseConnectionUSSDInterface::Adaptee::initiate(const QString &command, const ConnectionInterfaceUSSDAdaptor::InitiateContextPtr &context)
236+{
237+ if (!mInterface->mPriv->initiateCB.isValid()) {
238+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
239+ return;
240+ }
241+ Tp::DBusError error;
242+ mInterface->mPriv->initiateCB(command, &error);
243+ if (error.isValid()) {
244+ context->setFinishedWithError(error.name(), error.message());
245+ return;
246+ }
247+ context->setFinished();
248+}
249+
250+void BaseConnectionUSSDInterface::Adaptee::respond(const QString &reply, const ConnectionInterfaceUSSDAdaptor::RespondContextPtr &context)
251+{
252+ if (!mInterface->mPriv->respondCB.isValid()) {
253+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
254+ return;
255+ }
256+ Tp::DBusError error;
257+ mInterface->mPriv->respondCB(reply, &error);
258+ if (error.isValid()) {
259+ context->setFinishedWithError(error.name(), error.message());
260+ return;
261+ }
262+ context->setFinished();
263+}
264+
265+void BaseConnectionUSSDInterface::Adaptee::cancel(const ConnectionInterfaceUSSDAdaptor::CancelContextPtr &context)
266+{
267+ if (!mInterface->mPriv->cancelCB.isValid()) {
268+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
269+ return;
270+ }
271+ Tp::DBusError error;
272+ mInterface->mPriv->cancelCB(&error);
273+ if (error.isValid()) {
274+ context->setFinishedWithError(error.name(), error.message());
275+ return;
276+ }
277+ context->setFinished();
278+}
279+
280+BaseConnectionUSSDInterface::BaseConnectionUSSDInterface()
281+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_USSD),
282+ mPriv(new Private(this))
283+{
284+}
285+
286+BaseConnectionUSSDInterface::~BaseConnectionUSSDInterface()
287+{
288+ delete mPriv;
289+}
290+
291+void BaseConnectionUSSDInterface::setInitiateCallback(const InitiateCallback &cb)
292+{
293+ mPriv->initiateCB = cb;
294+}
295+
296+void BaseConnectionUSSDInterface::setRespondCallback(const RespondCallback &cb)
297+{
298+ mPriv->respondCB = cb;
299+}
300+
301+void BaseConnectionUSSDInterface::setCancelCallback(const CancelCallback &cb)
302+{
303+ mPriv->cancelCB = cb;
304+}
305+
306+QString BaseConnectionUSSDInterface::state() const
307+{
308+ return mPriv->state;
309+}
310+
311+void BaseConnectionUSSDInterface::setSerial(const QString &serial) const
312+{
313+ mPriv->serial = serial;
314+}
315+
316+
317+QString BaseConnectionUSSDInterface::serial() const
318+{
319+ return mPriv->serial;
320+}
321+
322+void BaseConnectionUSSDInterface::StateChanged(const QString &state)
323+{
324+ mPriv->state = state;
325+ Q_EMIT mPriv->adaptee->stateChanged(state);
326+}
327+
328+void BaseConnectionUSSDInterface::InitiateUSSDComplete(const QString &ussdResp)
329+{
330+ Q_EMIT mPriv->adaptee->initiateUSSDComplete(ussdResp);
331+}
332+
333+void BaseConnectionUSSDInterface::RespondComplete(bool success, const QString &ussdResp)
334+{
335+ Q_EMIT mPriv->adaptee->respondComplete(success, ussdResp);
336+}
337+
338+void BaseConnectionUSSDInterface::BarringComplete(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap)
339+{
340+ Q_EMIT mPriv->adaptee->barringComplete(ssOp, cbService, cbMap);
341+}
342+
343+void BaseConnectionUSSDInterface::ForwardingComplete(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap)
344+{
345+ Q_EMIT mPriv->adaptee->forwardingComplete(ssOp, cfService, cfMap);
346+}
347+
348+void BaseConnectionUSSDInterface::WaitingComplete(const QString &ssOp, const QVariantMap &cwMap)
349+{
350+ Q_EMIT mPriv->adaptee->waitingComplete(ssOp, cwMap);
351+}
352+
353+void BaseConnectionUSSDInterface::CallingLinePresentationComplete(const QString &ssOp, const QString &status)
354+{
355+ Q_EMIT mPriv->adaptee->callingLinePresentationComplete(ssOp, status);
356+}
357+
358+void BaseConnectionUSSDInterface::ConnectedLinePresentationComplete(const QString &ssOp, const QString &status)
359+{
360+ Q_EMIT mPriv->adaptee->connectedLinePresentationComplete(ssOp, status);
361+}
362+
363+void BaseConnectionUSSDInterface::CallingLineRestrictionComplete(const QString &ssOp, const QString &status)
364+{
365+ Q_EMIT mPriv->adaptee->callingLineRestrictionComplete(ssOp, status);
366+}
367+
368+void BaseConnectionUSSDInterface::ConnectedLineRestrictionComplete(const QString &ssOp, const QString &status)
369+{
370+ Q_EMIT mPriv->adaptee->connectedLineRestrictionComplete(ssOp, status);
371+}
372+
373+void BaseConnectionUSSDInterface::InitiateFailed()
374+{
375+ Q_EMIT mPriv->adaptee->initiateFailed();
376+}
377+
378+void BaseConnectionUSSDInterface::NotificationReceived(const QString &message)
379+{
380+ Q_EMIT mPriv->adaptee->notificationReceived(message);
381+}
382+
383+void BaseConnectionUSSDInterface::RequestReceived(const QString &message)
384+{
385+ Q_EMIT mPriv->adaptee->requestReceived(message);
386+}
387+
388+
389+QVariantMap BaseConnectionUSSDInterface::immutableProperties() const
390+{
391+ QVariantMap map;
392+ return map;
393+}
394+
395+void BaseConnectionUSSDInterface::createAdaptor()
396+{
397+ (void) new ConnectionInterfaceUSSDAdaptor(dbusObject()->dbusConnection(),
398+ mPriv->adaptee, dbusObject());
399+}
400+
401+
402+ConnectionInterfaceUSSDAdaptor::ConnectionInterfaceUSSDAdaptor(const QDBusConnection& bus, QObject* adaptee, QObject* parent)
403+ : Tp::AbstractAdaptor(bus, adaptee, parent)
404+{
405+ connect(adaptee, SIGNAL(notificationReceived(const QString &)), SIGNAL(NotificationReceived(const QString &)));
406+ connect(adaptee, SIGNAL(requestReceived(const QString &)), SIGNAL(RequestReceived(const QString &)));
407+
408+ connect(adaptee, SIGNAL(initiateUSSDComplete(const QString &)), SIGNAL(InitiateUSSDComplete(const QString &)));
409+
410+ connect(adaptee, SIGNAL(barringComplete(const QString &, const QString &, const QVariantMap &)),
411+ SIGNAL(BarringComplete(const QString &, const QString &, const QVariantMap &)));
412+
413+ connect(adaptee, SIGNAL(forwardingComplete(const QString &, const QString &, const QVariantMap &)),
414+ SIGNAL(ForwardingComplete(const QString &, const QString &, const QVariantMap &)));
415+
416+ connect(adaptee, SIGNAL(waitingComplete(const QString &, const QVariantMap &)),
417+ SIGNAL(WaitingComplete(const QString &, const QVariantMap &)));
418+
419+ connect(adaptee, SIGNAL(callingLinePresentationComplete(const QString &, const QString &)),
420+ SIGNAL(CallingLinePresentationComplete(const QString &, const QString &)));
421+
422+ connect(adaptee, SIGNAL(connectedLinePresentationComplete(const QString &, const QString &)),
423+ SIGNAL(ConnectedLinePresentationComplete(const QString &, const QString &)));
424+
425+ connect(adaptee, SIGNAL(callingLineRestrictionComplete(const QString &, const QString &)),
426+ SIGNAL(CallingLineRestrictionComplete(const QString &, const QString &)));
427+
428+ connect(adaptee, SIGNAL(connectedLineRestrictionComplete(const QString &, const QString &)),
429+ SIGNAL(ConnectedLineRestrictionComplete(const QString &, const QString &)));
430+
431+ connect(adaptee, SIGNAL(initiateFailed()), SIGNAL(InitiateFailed()));
432+
433+ connect(adaptee, SIGNAL(stateChanged(const QString&)), SIGNAL(StateChanged(const QString&)));
434+
435+ connect(adaptee, SIGNAL(respondComplete(bool, const QString &)), SIGNAL(RespondComplete(bool, const QString &)));
436+}
437+
438+ConnectionInterfaceUSSDAdaptor::~ConnectionInterfaceUSSDAdaptor()
439+{
440+}
441+
442+void ConnectionInterfaceUSSDAdaptor::Initiate(const QString &command, const QDBusMessage& dbusMessage)
443+{
444+ if (!adaptee()->metaObject()->indexOfMethod("initiate(const QString &,ConnectionInterfaceUSSDAdaptor::InitiateContextPtr)") == -1) {
445+ dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
446+ return;
447+ }
448+
449+ InitiateContextPtr ctx = InitiateContextPtr(
450+ new Tp::MethodInvocationContext< >(dbusConnection(), dbusMessage));
451+ QMetaObject::invokeMethod(adaptee(), "initiate",
452+ Q_ARG(QString, command),
453+ Q_ARG(ConnectionInterfaceUSSDAdaptor::InitiateContextPtr, ctx));
454+ return;
455+}
456+
457+void ConnectionInterfaceUSSDAdaptor::Respond(const QString &reply, const QDBusMessage& dbusMessage)
458+{
459+ if (!adaptee()->metaObject()->indexOfMethod("respond(QConnectionInterfaceUSSDAdaptor::RespondContextPtr)") == -1) {
460+ dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
461+ return;
462+ }
463+
464+ RespondContextPtr ctx = RespondContextPtr(
465+ new Tp::MethodInvocationContext< >(dbusConnection(), dbusMessage));
466+ QMetaObject::invokeMethod(adaptee(), "respond",
467+ Q_ARG(QString, reply),
468+ Q_ARG(ConnectionInterfaceUSSDAdaptor::RespondContextPtr, ctx));
469+ return;
470+}
471+
472+void ConnectionInterfaceUSSDAdaptor::Cancel(const QDBusMessage& dbusMessage)
473+{
474+ if (!adaptee()->metaObject()->indexOfMethod("cancel(ConnectionInterfaceUSSDAdaptor::CancelContextPtr)") == -1) {
475+ dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
476+ return;
477+ }
478+
479+ CancelContextPtr ctx = CancelContextPtr(
480+ new Tp::MethodInvocationContext< >(dbusConnection(), dbusMessage));
481+ QMetaObject::invokeMethod(adaptee(), "cancel",
482+ Q_ARG(ConnectionInterfaceUSSDAdaptor::CancelContextPtr, ctx));
483+ return;
484+}
485+
486+QString ConnectionInterfaceUSSDAdaptor::Serial() const
487+{
488+ return qvariant_cast< QString >(adaptee()->property("serial"));
489+}
490+
491+
492+QString ConnectionInterfaceUSSDAdaptor::State() const
493+{
494+ return qvariant_cast< QString >(adaptee()->property("state"));
495+}
496+
497
498=== added file 'ussdiface.h'
499--- ussdiface.h 1970-01-01 00:00:00 +0000
500+++ ussdiface.h 2014-04-02 22:00:18 +0000
501@@ -0,0 +1,243 @@
502+/**
503+ * Copyright (C) 2013 Canonical, Ltd.
504+ *
505+ * This program is free software: you can redistribute it and/or modify it under
506+ * the terms of the GNU Lesser General Public License version 3, as published by
507+ * the Free Software Foundation.
508+ *
509+ * This program is distributed in the hope that it will be useful, but WITHOUT
510+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
511+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
512+ * Lesser General Public License for more details.
513+ *
514+ * You should have received a copy of the GNU Lesser General Public License
515+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
516+ *
517+ * Authors: Tiago Salem Herrmann <tiago.herrmann@canonical.com>
518+ */
519+
520+#ifndef OFONOUSSDIFACE_H
521+#define OFONOUSSDIFACE_H
522+
523+// telepathy-qt
524+#include <TelepathyQt/Constants>
525+#include <TelepathyQt/BaseConnection>
526+#include <TelepathyQt/AbstractAdaptor>
527+#include <TelepathyQt/DBusError>
528+#include <TelepathyQt/Callbacks>
529+
530+class BaseConnectionUSSDInterface;
531+
532+typedef Tp::SharedPtr<BaseConnectionUSSDInterface> BaseConnectionUSSDInterfacePtr;
533+
534+#define TP_QT_IFACE_CONNECTION_USSD "com.canonical.Telephony.USSD"
535+
536+class TP_QT_EXPORT BaseConnectionUSSDInterface : public Tp::AbstractConnectionInterface
537+{
538+ Q_OBJECT
539+ Q_DISABLE_COPY(BaseConnectionUSSDInterface)
540+
541+public:
542+ static BaseConnectionUSSDInterfacePtr create() {
543+ return BaseConnectionUSSDInterfacePtr(new BaseConnectionUSSDInterface());
544+ }
545+ template<typename BaseConnectionUSSDInterfaceSubclass>
546+ static Tp::SharedPtr<BaseConnectionUSSDInterfaceSubclass> create() {
547+ return Tp::SharedPtr<BaseConnectionUSSDInterfaceSubclass>(
548+ new BaseConnectionUSSDInterfaceSubclass());
549+ }
550+ QVariantMap immutableProperties() const;
551+ virtual ~BaseConnectionUSSDInterface();
552+
553+ typedef Tp::Callback2<void, const QString&, Tp::DBusError*> InitiateCallback;
554+ void setInitiateCallback(const InitiateCallback &cb);
555+
556+ typedef Tp::Callback2<void, const QString&, Tp::DBusError*> RespondCallback;
557+ void setRespondCallback(const RespondCallback &cb);
558+
559+ typedef Tp::Callback1<void, Tp::DBusError*> CancelCallback;
560+ void setCancelCallback(const CancelCallback &cb);
561+
562+
563+ QString state() const;
564+ QString serial() const;
565+ void setSerial(const QString& serial) const;
566+
567+public Q_SLOTS:
568+ void NotificationReceived(const QString &message);
569+ void RequestReceived(const QString &message);
570+
571+ void InitiateUSSDComplete(const QString &ussdResp);
572+ void RespondComplete(bool success, const QString &ussdResp);
573+ void BarringComplete(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap);
574+ void ForwardingComplete(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap);
575+ void WaitingComplete(const QString &ssOp, const QVariantMap &cwMap);
576+ void CallingLinePresentationComplete(const QString &ssOp, const QString &status);
577+ void ConnectedLinePresentationComplete(const QString &ssOp, const QString &status);
578+ void CallingLineRestrictionComplete(const QString &ssOp, const QString &status);
579+ void ConnectedLineRestrictionComplete(const QString &ssOp, const QString &status);
580+ void InitiateFailed();
581+ void StateChanged(const QString &state);
582+
583+protected:
584+ BaseConnectionUSSDInterface();
585+
586+private:
587+ void createAdaptor();
588+
589+ class Adaptee;
590+ friend class Adaptee;
591+ struct Private;
592+ friend struct Private;
593+ Private *mPriv;
594+};
595+
596+
597+class TP_QT_EXPORT ConnectionInterfaceUSSDAdaptor : public Tp::AbstractAdaptor
598+{
599+ Q_OBJECT
600+ Q_CLASSINFO("D-Bus Interface", TP_QT_IFACE_CONNECTION_USSD)
601+ Q_CLASSINFO("D-Bus Introspection", ""
602+" <interface name=\"com.canonical.Telephony.USSD\">\n"
603+" <property access=\"read\" type=\"s\" name=\"State\"/>\n"
604+" <property access=\"read\" type=\"s\" name=\"Serial\"/>\n"
605+" <method name=\"Initiate\">\n"
606+" <arg direction=\"in\" type=\"s\" name=\"command\"/>\n"
607+" </method>\n"
608+" <method name=\"Respond\">\n"
609+" <arg direction=\"in\" type=\"s\" name=\"reply\"/>\n"
610+" </method>\n"
611+" <method name=\"Cancel\" />\n"
612+" <signal name=\"NotificationReceived\">\n"
613+" <arg type=\"s\" name=\"message\"/>\n"
614+" </signal>\n"
615+" <signal name=\"RequestReceived\">\n"
616+" <arg type=\"s\" name=\"message\"/>\n"
617+" </signal>\n"
618+" <signal name=\"InitiateUSSDComplete\">\n"
619+" <arg type=\"s\" name=\"response\"/>\n"
620+" </signal>\n"
621+" <signal name=\"RespondComplete\">\n"
622+" <arg type=\"b\" name=\"success\"/>\n"
623+" <arg type=\"s\" name=\"response\"/>\n"
624+" </signal>\n"
625+" <signal name=\"BarringComplete\">\n"
626+" <arg type=\"s\" name=\"ssOp\"/>\n"
627+" <arg type=\"s\" name=\"cbService\"/>\n"
628+" <arg type=\"a{sv}\" name=\"cbMap\"/>\n"
629+" </signal>\n"
630+" <signal name=\"ForwardingComplete\">\n"
631+" <arg type=\"s\" name=\"ssOp\"/>\n"
632+" <arg type=\"s\" name=\"cfService\"/>\n"
633+" <arg type=\"a{sv}\" name=\"cfMap\"/>\n"
634+" </signal>\n"
635+" <signal name=\"WaitingComplete\">\n"
636+" <arg type=\"s\" name=\"ssOp\"/>\n"
637+" <arg type=\"a{sv}\" name=\"cwMap\"/>\n"
638+" </signal>\n"
639+" <signal name=\"CallingLinePresentationComplete\">\n"
640+" <arg type=\"s\" name=\"ssOp\"/>\n"
641+" <arg type=\"s\" name=\"status\"/>\n"
642+" </signal>\n"
643+" <signal name=\"ConnectedLinePresentationComplete\">\n"
644+" <arg type=\"s\" name=\"ssOp\"/>\n"
645+" <arg type=\"s\" name=\"status\"/>\n"
646+" </signal>\n"
647+" <signal name=\"CallingLineRestrictionComplete\">\n"
648+" <arg type=\"s\" name=\"ssOp\"/>\n"
649+" <arg type=\"s\" name=\"status\"/>\n"
650+" </signal>\n"
651+" <signal name=\"ConnectedLineRestrictionComplete\">\n"
652+" <arg type=\"s\" name=\"ssOp\"/>\n"
653+" <arg type=\"s\" name=\"status\"/>\n"
654+" </signal>\n"
655+" <signal name=\"InitiateFailed\" />\n"
656+" <signal name=\"StateChanged\">\n"
657+" <arg type=\"s\" name=\"state\"/>\n"
658+" </signal>\n"
659+" </interface>\n"
660+"")
661+ Q_PROPERTY(QString State READ State)
662+ Q_PROPERTY(QString Serial READ Serial)
663+
664+public:
665+ ConnectionInterfaceUSSDAdaptor(const QDBusConnection& dbusConnection, QObject* adaptee, QObject* parent);
666+ virtual ~ConnectionInterfaceUSSDAdaptor();
667+
668+ typedef Tp::MethodInvocationContextPtr< > InitiateContextPtr;
669+ typedef Tp::MethodInvocationContextPtr< > RespondContextPtr;
670+ typedef Tp::MethodInvocationContextPtr< > CancelContextPtr;
671+
672+public Q_SLOTS: // METHODS
673+ void Initiate(const QString &command, const QDBusMessage& dbusMessage);
674+ void Respond(const QString &reply, const QDBusMessage& dbusMessage);
675+ void Cancel(const QDBusMessage& dbusMessage);
676+
677+ QString State() const;
678+ QString Serial() const;
679+
680+Q_SIGNALS: // SIGNALS
681+ void NotificationReceived(const QString &message);
682+ void RequestReceived(const QString &message);
683+
684+ void InitiateUSSDComplete(const QString &ussdResp);
685+ void RespondComplete(bool success, const QString &ussdResp);
686+ void BarringComplete(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap);
687+ void ForwardingComplete(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap);
688+ void WaitingComplete(const QString &ssOp, const QVariantMap &cwMap);
689+ void CallingLinePresentationComplete(const QString &ssOp, const QString &status);
690+ void ConnectedLinePresentationComplete(const QString &ssOp, const QString &status);
691+ void CallingLineRestrictionComplete(const QString &ssOp, const QString &status);
692+ void ConnectedLineRestrictionComplete(const QString &ssOp, const QString &status);
693+ void InitiateFailed();
694+
695+ void StateChanged(const QString &state);
696+};
697+
698+
699+class TP_QT_NO_EXPORT BaseConnectionUSSDInterface::Adaptee : public QObject
700+{
701+ Q_OBJECT
702+ Q_PROPERTY(QString state READ state)
703+ Q_PROPERTY(QString serial READ serial)
704+
705+public:
706+ Adaptee(BaseConnectionUSSDInterface *interface);
707+ ~Adaptee();
708+ QString state() const
709+ {
710+ return mInterface->state();
711+ }
712+ QString serial() const
713+ {
714+ return mInterface->serial();
715+ }
716+
717+
718+private Q_SLOTS:
719+ void initiate(const QString &command, const ConnectionInterfaceUSSDAdaptor::InitiateContextPtr &context);
720+ void respond(const QString &reply, const ConnectionInterfaceUSSDAdaptor::RespondContextPtr &context);
721+ void cancel(const ConnectionInterfaceUSSDAdaptor::CancelContextPtr &context);
722+
723+Q_SIGNALS:
724+ void notificationReceived(const QString &message);
725+ void requestReceived(const QString &message);
726+
727+ void initiateUSSDComplete(const QString &ussdResp);
728+ void barringComplete(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap);
729+ void forwardingComplete(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap);
730+ void waitingComplete(const QString &ssOp, const QVariantMap &cwMap);
731+ void callingLinePresentationComplete(const QString &ssOp, const QString &status);
732+ void connectedLinePresentationComplete(const QString &ssOp, const QString &status);
733+ void callingLineRestrictionComplete(const QString &ssOp, const QString &status);
734+ void connectedLineRestrictionComplete(const QString &ssOp, const QString &status);
735+ void initiateFailed();
736+ void respondComplete(bool success, const QString &response);
737+
738+ void stateChanged(const QString &state);
739+
740+public:
741+ BaseConnectionUSSDInterface *mInterface;
742+};
743+
744+#endif

Subscribers

People subscribed via source and target branches