Merge lp:~phablet-team/telephony-service/protocols-through-dbus into lp:telephony-service

Proposed by Roberto Mier Escandon
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 1227
Merged at revision: 1222
Proposed branch: lp:~phablet-team/telephony-service/protocols-through-dbus
Merge into: lp:telephony-service
Prerequisite: lp:~phablet-team/telephony-service/fix-hardcoded-paths
Diff against target: 523 lines (+235/-16)
14 files modified
handler/Handler.xml (+15/-0)
handler/handlerdbus.cpp (+14/-0)
handler/handlerdbus.h (+3/-0)
libtelephonyservice/accountentry.cpp (+3/-0)
libtelephonyservice/dbustypes.h (+25/-1)
libtelephonyservice/protocol.cpp (+38/-6)
libtelephonyservice/protocol.h (+16/-1)
libtelephonyservice/protocolmanager.cpp (+69/-6)
libtelephonyservice/protocolmanager.h (+1/-0)
tests/handler/HandlerTest.cpp (+29/-0)
tests/handler/handlercontroller.cpp (+12/-0)
tests/handler/handlercontroller.h (+4/-0)
tests/libtelephonyservice/CMakeLists.txt (+4/-2)
tests/libtelephonyservice/ProtocolManagerTest.cpp (+2/-0)
To merge this branch: bzr merge lp:~phablet-team/telephony-service/protocols-through-dbus
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
system-apps-ci-bot continuous-integration Needs Fixing
Review via email: mp+312358@code.launchpad.net

Commit message

Requesting protocols from qml plugin using DBus in case protocols dir folder does not exits.
This is needed in snappy to access available protocols from applications.

Description of the change

Requesting protocols from qml plugin using DBus in case protocols dir folder does not exits.
This is needed in snappy to access available protocols from applications.

To post a comment you must log in.
1225. By Roberto Mier Escandon

removed not needed protocol manager test dependency

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1224
https://jenkins.canonical.com/system-apps/job/lp-telephony-service-ci/92/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2107/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2110
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1938/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1938/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-telephony-service-ci/92/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1225
https://jenkins.canonical.com/system-apps/job/lp-telephony-service-ci/93/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2109/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2112
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1940/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1940/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1940/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1940/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1940/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1940/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1940/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1940/console
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1940/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-telephony-service-ci/93/rebuild

review: Needs Fixing (continuous-integration)
1226. By Tiago Salem Herrmann

merge parent branch

1227. By Tiago Salem Herrmann

avoid crash by replacing mProtocol with new instances when protocols change

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:1227
https://jenkins.canonical.com/system-apps/job/lp-telephony-service-ci/94/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/2124/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/2127
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1955
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1955/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1955
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1955/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=zesty/1955/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1955
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1955/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1955
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1955/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=zesty/1955/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1955
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1955/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1955/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1955
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=zesty/1955/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-telephony-service-ci/94/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

looks good to me.
thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'handler/Handler.xml'
2--- handler/Handler.xml 2016-11-23 19:28:18 +0000
3+++ handler/Handler.xml 2016-12-06 17:32:46 +0000
4@@ -173,6 +173,13 @@
5 <arg name="properties" type="a{sv}" direction="out"/>
6 <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
7 </method>
8+ <method name="GetProtocols">
9+ <dox:d><![CDATA[
10+ Get the list of current available protocols
11+ ]]></dox:d>
12+ <arg name="result" type="a(sussss)" direction="out"/>
13+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="ProtocolList"/>
14+ </method>
15 <signal name="CallPropertiesChanged">
16 <dox:d><![CDATA[
17 The properties of a given call changed.
18@@ -202,5 +209,13 @@
19 ]]></dox:d>
20 <arg name="visible" type="b"/>
21 </signal>
22+ <signal name="ProtocolsChanged">
23+ <dox:d><![CDATA[
24+ The protocols files in protocols dir have changed
25+ ]]></dox:d>
26+ <arg name="protocols" type="a(sussss)"/>
27+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="ProtocolList"/>
28+ <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="ProtocolList"/>
29+ </signal>
30 </interface>
31 </node>
32
33=== modified file 'handler/handlerdbus.cpp'
34--- handler/handlerdbus.cpp 2016-11-23 19:28:18 +0000
35+++ handler/handlerdbus.cpp 2016-12-06 17:32:46 +0000
36@@ -26,6 +26,8 @@
37 #include "handleradaptor.h"
38 #include "texthandler.h"
39 #include "telepathyhelper.h"
40+#include "protocolmanager.h"
41+#include <config.h>
42
43 // Qt
44 #include <QtDBus/QDBusConnection>
45@@ -35,6 +37,9 @@
46
47 HandlerDBus::HandlerDBus(QObject* parent) : QObject(parent), mCallIndicatorVisible(false)
48 {
49+ qDBusRegisterMetaType<ProtocolList>();
50+ qDBusRegisterMetaType<ProtocolStruct>();
51+
52 connect(CallHandler::instance(),
53 SIGNAL(callPropertiesChanged(QString,QVariantMap)),
54 SIGNAL(CallPropertiesChanged(QString,QVariantMap)));
55@@ -44,6 +49,10 @@
56 connect(CallHandler::instance(),
57 SIGNAL(conferenceCallRequestFinished(bool)),
58 SIGNAL(ConferenceCallRequestFinished(bool)));
59+ connect(ProtocolManager::instance(),
60+ &ProtocolManager::protocolsChanged, [this]() {
61+ Q_EMIT ProtocolsChanged(ProtocolManager::instance()->protocols().dbusType());
62+ });
63 }
64
65 HandlerDBus::~HandlerDBus()
66@@ -81,6 +90,11 @@
67 Q_EMIT CallIndicatorVisibleChanged(visible);
68 }
69
70+ProtocolList HandlerDBus::GetProtocols()
71+{
72+ return ProtocolManager::instance()->protocols().dbusType();
73+}
74+
75 QString HandlerDBus::registerObject(QObject *object, const QString &path)
76 {
77 QString fullPath = QString("%1/%2").arg(DBUS_OBJECT_PATH, path);
78
79=== modified file 'handler/handlerdbus.h'
80--- handler/handlerdbus.h 2016-11-23 19:28:18 +0000
81+++ handler/handlerdbus.h 2016-12-06 17:32:46 +0000
82@@ -50,6 +50,8 @@
83 bool IsReady();
84 bool callIndicatorVisible() const;
85 void setCallIndicatorVisible(bool visible);
86+ // configuration related
87+ ProtocolList GetProtocols();
88
89 QString registerObject(QObject *object, const QString &path);
90 void unregisterObject(const QString &path);
91@@ -89,6 +91,7 @@
92 void CallIndicatorVisibleChanged(bool visible);
93 void ConferenceCallRequestFinished(bool succeeded);
94 void CallHoldingFailed(const QString &objectPath);
95+ void ProtocolsChanged(const ProtocolList &protocols);
96
97 private:
98 bool mCallIndicatorVisible;
99
100=== modified file 'libtelephonyservice/accountentry.cpp'
101--- libtelephonyservice/accountentry.cpp 2016-10-05 19:15:39 +0000
102+++ libtelephonyservice/accountentry.cpp 2016-12-06 17:32:46 +0000
103@@ -186,6 +186,9 @@
104 }
105
106 mProtocol = ProtocolManager::instance()->protocolByName(mAccount->protocolName());
107+ connect(ProtocolManager::instance(), &ProtocolManager::protocolsChanged, [=]() {
108+ mProtocol = ProtocolManager::instance()->protocolByName(mAccount->protocolName());
109+ });
110
111 connect(this, &AccountEntry::addressableVCardFieldsChanged, &AccountEntry::usePhoneNumbersChanged);
112
113
114=== modified file 'libtelephonyservice/dbustypes.h'
115--- libtelephonyservice/dbustypes.h 2014-05-23 12:56:52 +0000
116+++ libtelephonyservice/dbustypes.h 2016-12-06 17:32:46 +0000
117@@ -19,6 +19,9 @@
118 #ifndef DBUSTYPES
119 #define DBUSTYPES
120
121+#include <QDBusObjectPath>
122+#include <QDBusArgument>
123+
124 struct MessageStruct {
125 QDBusObjectPath path;
126 QVariantMap properties;
127@@ -30,16 +33,37 @@
128 QString filePath;
129 };
130
131+struct ProtocolStruct {
132+ QString name;
133+ uint features;
134+ QString fallbackProtocol;
135+ uint fallbackMatchRule;
136+ QString fallbackSourceProperty;
137+ QString fallbackDestinationProperty;
138+ bool showOnSelector;
139+ bool showOnlineStatus;
140+ QString backgroundImage;
141+ QString icon;
142+ QString serviceName;
143+ QString serviceDisplayName;
144+};
145+
146 typedef QList<AttachmentStruct> AttachmentList;
147 Q_DECLARE_METATYPE(AttachmentStruct)
148 Q_DECLARE_METATYPE(AttachmentList)
149
150-
151 typedef QList<MessageStruct> MessageList;
152 Q_DECLARE_METATYPE(MessageStruct)
153 Q_DECLARE_METATYPE(MessageList)
154
155+typedef QList<ProtocolStruct> ProtocolList;
156+Q_DECLARE_METATYPE(ProtocolStruct)
157+Q_DECLARE_METATYPE(ProtocolList)
158+
159 QDBusArgument &operator<<(QDBusArgument &argument, const AttachmentStruct &attachment);
160 const QDBusArgument &operator>>(const QDBusArgument &argument, AttachmentStruct &attachment);
161
162+QDBusArgument &operator<<(QDBusArgument &argument, const ProtocolStruct &protocol);
163+const QDBusArgument &operator>>(const QDBusArgument &argument, ProtocolStruct &protocol);
164+
165 #endif
166
167=== modified file 'libtelephonyservice/protocol.cpp'
168--- libtelephonyservice/protocol.cpp 2016-11-23 19:28:18 +0000
169+++ libtelephonyservice/protocol.cpp 2016-12-06 17:32:46 +0000
170@@ -21,10 +21,28 @@
171 */
172
173 #include "protocol.h"
174+#include "dbustypes.h"
175 #include <QFileInfo>
176 #include <QSettings>
177
178-Protocol::Protocol(const QString &name, Features features,
179+Protocol::Protocol(const ProtocolStruct & protocol)
180+ : mName(protocol.name)
181+ , mFeatures(protocol.features)
182+ , mFallbackProtocol(protocol.fallbackProtocol)
183+ , mFallbackMatchRule((MatchRule)protocol.fallbackMatchRule)
184+ , mFallbackSourceProperty(protocol.fallbackSourceProperty)
185+ , mFallbackDestinationProperty(protocol.fallbackDestinationProperty)
186+ , mShowOnSelector(protocol.showOnSelector)
187+ , mShowOnlineStatus(protocol.showOnlineStatus)
188+ , mBackgroundImage(protocol.backgroundImage)
189+ , mIcon(protocol.icon)
190+ , mServiceName(protocol.serviceName)
191+ , mServiceDisplayName(protocol.serviceDisplayName)
192+{
193+}
194+
195+Protocol::Protocol(const QString &name,
196+ Features features,
197 const QString &fallbackProtocol,
198 MatchRule fallbackMatchRule,
199 const QString &fallbackSourceProperty,
200@@ -36,11 +54,25 @@
201 const QString &serviceName,
202 const QString &serviceDisplayName,
203 QObject *parent)
204-: QObject(parent), mName(name), mFeatures(features), mFallbackProtocol(fallbackProtocol), mFallbackMatchRule(fallbackMatchRule),
205- mFallbackSourceProperty(fallbackSourceProperty), mFallbackDestinationProperty(fallbackDestinationProperty),
206- mShowOnSelector(showOnSelector), mShowOnlineStatus(showOnlineStatus), mBackgroundImage(backgroundImage), mIcon(icon),
207- mServiceName(serviceName), mServiceDisplayName(serviceDisplayName)
208-{
209+ : QObject(parent)
210+ , mName(name)
211+ , mFeatures(features)
212+ , mFallbackProtocol(fallbackProtocol)
213+ , mFallbackMatchRule(fallbackMatchRule)
214+ , mFallbackSourceProperty(fallbackSourceProperty)
215+ , mFallbackDestinationProperty(fallbackDestinationProperty)
216+ , mShowOnSelector(showOnSelector)
217+ , mShowOnlineStatus(showOnlineStatus)
218+ , mBackgroundImage(backgroundImage)
219+ , mIcon(icon)
220+ , mServiceName(serviceName)
221+ , mServiceDisplayName(serviceDisplayName)
222+{
223+}
224+
225+ProtocolStruct Protocol::dbusType()
226+{
227+ return ProtocolStruct{mName, static_cast<uint>(mFeatures), mFallbackProtocol, static_cast<uint>(mFallbackMatchRule), mFallbackSourceProperty, mFallbackDestinationProperty, mShowOnSelector, mShowOnlineStatus, mBackgroundImage, mIcon, mServiceName, mServiceDisplayName};
228 }
229
230 QString Protocol::name() const
231
232=== modified file 'libtelephonyservice/protocol.h'
233--- libtelephonyservice/protocol.h 2016-11-23 19:28:18 +0000
234+++ libtelephonyservice/protocol.h 2016-12-06 17:32:46 +0000
235@@ -23,6 +23,7 @@
236 #ifndef PROTOCOL_H
237 #define PROTOCOL_H
238
239+#include "dbustypes.h"
240 #include <QObject>
241
242 /// @brief describes one protocol and the features it supports
243@@ -73,6 +74,8 @@
244 };
245 Q_DECLARE_FLAGS(Features, Feature)
246
247+ Protocol(const ProtocolStruct& protocolStruct);
248+
249 enum MatchRule {
250 MatchAny,
251 MatchProperties
252@@ -92,6 +95,7 @@
253 QString serviceDisplayName() const;
254
255 static Protocol *fromFile(const QString &fileName);
256+ ProtocolStruct dbusType();
257
258 friend class ProtocolManager;
259
260@@ -124,6 +128,17 @@
261 QString mServiceDisplayName;
262 };
263
264-typedef QList<Protocol*> Protocols;
265+class Protocols : public QList<Protocol*>
266+{
267+public:
268+ ProtocolList dbusType() {
269+ // return list of DBus types
270+ ProtocolList protocolList;
271+ Q_FOREACH(Protocol *protocol, *this) {
272+ protocolList << protocol->dbusType();
273+ }
274+ return protocolList;
275+ }
276+};
277
278 #endif // PROTOCOL_H
279
280=== modified file 'libtelephonyservice/protocolmanager.cpp'
281--- libtelephonyservice/protocolmanager.cpp 2015-06-15 13:52:56 +0000
282+++ libtelephonyservice/protocolmanager.cpp 2016-12-06 17:32:46 +0000
283@@ -20,17 +20,70 @@
284 */
285
286 #include "protocolmanager.h"
287+#include "telepathyhelper.h"
288 #include "config.h"
289+#include "dbustypes.h"
290 #include <QDir>
291-
292+#include <QDBusMetaType>
293+
294+QDBusArgument &operator<<(QDBusArgument &argument, const ProtocolStruct &protocol)
295+{
296+ argument.beginStructure();
297+ argument << protocol.name << protocol.features << protocol.fallbackProtocol << protocol.backgroundImage << protocol.icon << protocol.serviceName;
298+ argument.endStructure();
299+ return argument;
300+}
301+
302+const QDBusArgument &operator>>(const QDBusArgument &argument, ProtocolStruct &protocol)
303+{
304+ argument.beginStructure();
305+ argument >> protocol.name >> protocol.features >> protocol.fallbackProtocol >> protocol.backgroundImage >> protocol.icon >> protocol.serviceName;
306+ argument.endStructure();
307+ return argument;
308+}
309+
310+/**
311+ * Protocol Manager acts in two senses. If protocols dir is accessible it takes info from there and exposes it thtrough DBus (handler will be accessible
312+ * in this case). Otherwise, it queries for protocols through DBus, avoiding accessing disk to get that information. This last is useful in confined
313+ * environments where info could only be accessible by DBus
314+ */
315 ProtocolManager::ProtocolManager(const QString &dir, QObject *parent) :
316 QObject(parent), mProtocolsDir(dir)
317 {
318- mFileWatcher.addPath(mProtocolsDir);
319- connect(&mFileWatcher,
320- SIGNAL(directoryChanged(QString)),
321- SLOT(loadSupportedProtocols()));
322- loadSupportedProtocols();
323+ QDir d(mProtocolsDir);
324+ // read from disk and emit signal of available protocols in case protocols directory exists (We are servers)
325+ if (d.exists()) {
326+ mFileWatcher.addPath(mProtocolsDir);
327+ connect(&mFileWatcher,
328+ SIGNAL(directoryChanged(QString)),
329+ SLOT(loadSupportedProtocols()));
330+ loadSupportedProtocols();
331+ } else {
332+ // register DBus types and query protocols info through DBus in case protocols directory does not exists (We are clients)
333+ qDBusRegisterMetaType<ProtocolList>();
334+ qDBusRegisterMetaType<ProtocolStruct>();
335+
336+ //TODO make DBus call to get the protocols
337+ QDBusInterface *interface = TelepathyHelper::instance()->handlerInterface();
338+
339+ if (!interface) {
340+ return;
341+ }
342+
343+ connect(interface,
344+ SIGNAL(ProtocolsChanged(ProtocolList)),
345+ SLOT(onProtocolsChanged(ProtocolList)));
346+
347+ QDBusReply<ProtocolList> reply = interface->call("GetProtocols");
348+ if (!reply.isValid()) {
349+ return;
350+ }
351+
352+ mProtocols.clear();
353+ Q_FOREACH (const ProtocolStruct& protocol, reply.value()) {
354+ mProtocols << new Protocol(protocol);
355+ }
356+ }
357 }
358
359 ProtocolManager *ProtocolManager::instance()
360@@ -163,3 +216,13 @@
361
362 Q_EMIT protocolsChanged();
363 }
364+
365+void ProtocolManager::onProtocolsChanged(const ProtocolList &protocolList)
366+{
367+ mProtocols.clear();
368+ Q_FOREACH (const ProtocolStruct &protocol, protocolList) {
369+ mProtocols << new Protocol(protocol);
370+ }
371+
372+ Q_EMIT protocolsChanged();
373+}
374
375=== modified file 'libtelephonyservice/protocolmanager.h'
376--- libtelephonyservice/protocolmanager.h 2015-06-15 13:52:56 +0000
377+++ libtelephonyservice/protocolmanager.h 2016-12-06 17:32:46 +0000
378@@ -90,6 +90,7 @@
379
380 protected Q_SLOTS:
381 void loadSupportedProtocols();
382+ void onProtocolsChanged(const ProtocolList &protocolList);
383
384 protected:
385 explicit ProtocolManager(const QString &dir, QObject *parent = 0);
386
387=== modified file 'tests/handler/HandlerTest.cpp'
388--- tests/handler/HandlerTest.cpp 2016-10-29 01:42:11 +0000
389+++ tests/handler/HandlerTest.cpp 2016-12-06 17:32:46 +0000
390@@ -27,6 +27,8 @@
391 #include "accountentry.h"
392 #include "accountentryfactory.h"
393 #include "telepathyhelper.h"
394+#include "protocolmanager.h"
395+#include <config.h>
396
397 Q_DECLARE_METATYPE(Tp::TextChannelPtr)
398
399@@ -38,6 +40,8 @@
400 void initTestCase();
401 void init();
402 void cleanup();
403+ void testGetProtocols();
404+ void testGetProtocolsChangesThroughDBus();
405 void testMakingCalls();
406 void testHangUpCall();
407 void testCallHold();
408@@ -68,6 +72,9 @@
409
410 void HandlerTest::initTestCase()
411 {
412+ qDBusRegisterMetaType<ProtocolList>();
413+ qDBusRegisterMetaType<ProtocolStruct>();
414+
415 initialize();
416
417 QSignalSpy setupReadySpy(TelepathyHelper::instance(), SIGNAL(setupReady()));
418@@ -100,6 +107,28 @@
419 mOfonoMockController->deleteLater();
420 }
421
422+void HandlerTest::testGetProtocols()
423+{
424+ Protocols protocols = ProtocolManager::instance()->protocols();
425+ ProtocolList protocolList = HandlerController::instance()->getProtocols();
426+ for (int i = 0; i < protocols.count(); ++i) {
427+ QCOMPARE(protocols[i]->name(), protocolList.at(i).name);
428+ }
429+}
430+
431+void HandlerTest::testGetProtocolsChangesThroughDBus()
432+{
433+ QSignalSpy protocolsChangedSpy(HandlerController::instance(), SIGNAL(protocolsChanged(ProtocolList)));
434+
435+ QTemporaryFile f;
436+ f.setFileTemplate(protocolsDir() + "/");
437+ if (f.open()) {
438+ f.close();
439+ }
440+
441+ QTRY_COMPARE(protocolsChangedSpy.count(), 1);
442+}
443+
444 void HandlerTest::testMakingCalls()
445 {
446 QString callerId("1234567");
447
448=== modified file 'tests/handler/handlercontroller.cpp'
449--- tests/handler/handlercontroller.cpp 2016-11-23 19:28:18 +0000
450+++ tests/handler/handlercontroller.cpp 2016-12-06 17:32:46 +0000
451@@ -46,6 +46,9 @@
452 connect(&mHandlerInterface,
453 SIGNAL(CallIndicatorVisibleChanged(bool)),
454 SIGNAL(callIndicatorVisibleChanged(bool)));
455+ connect(&mHandlerInterface,
456+ SIGNAL(ProtocolsChanged(ProtocolList)),
457+ SIGNAL(protocolsChanged(ProtocolList)));
458 }
459
460 QVariantMap HandlerController::getCallProperties(const QString &objectPath)
461@@ -159,3 +162,12 @@
462 "com.canonical.TelephonyServiceHandler",
463 "CallIndicatorVisible", QVariant::fromValue(QDBusVariant(visible)));
464 }
465+
466+ProtocolList HandlerController::getProtocols()
467+{
468+ QDBusReply<ProtocolList> reply = mHandlerInterface.call("GetProtocols");
469+ if (reply.isValid()) {
470+ return reply.value();
471+ }
472+ return ProtocolList();
473+}
474
475=== modified file 'tests/handler/handlercontroller.h'
476--- tests/handler/handlercontroller.h 2016-11-23 19:28:18 +0000
477+++ tests/handler/handlercontroller.h 2016-12-06 17:32:46 +0000
478@@ -57,9 +57,13 @@
479 // active call indicator
480 void setCallIndicatorVisible(bool visible);
481
482+ // protocols
483+ ProtocolList getProtocols();
484+
485 Q_SIGNALS:
486 void callPropertiesChanged(const QString &objectPath, const QVariantMap &properties);
487 void callIndicatorVisibleChanged(bool visible);
488+ void protocolsChanged(ProtocolList);
489
490 private:
491 explicit HandlerController(QObject *parent = 0);
492
493=== modified file 'tests/libtelephonyservice/CMakeLists.txt'
494--- tests/libtelephonyservice/CMakeLists.txt 2016-11-04 22:32:50 +0000
495+++ tests/libtelephonyservice/CMakeLists.txt 2016-12-06 17:32:46 +0000
496@@ -54,10 +54,12 @@
497 SOURCES ProtocolTest.cpp ${LIBTELEPHONYSERVICE_DIR}/protocol.cpp
498 ENVIRONMENT TELEPHONY_SERVICE_PROTOCOLS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/testProtocols)
499 generate_test(ProtocolManagerTest
500- SOURCES ProtocolManagerTest.cpp ${LIBTELEPHONYSERVICE_DIR}/protocol.cpp ${LIBTELEPHONYSERVICE_DIR}/protocolmanager.cpp
501- QT5_MODULES Core Qml Test
502+ SOURCES ProtocolManagerTest.cpp
503+ QT5_MODULES Core Qml Test DBus Contacts
504+ LIBRARIES telepathy-qt5 telephonyservice
505 ENVIRONMENT TELEPHONY_SERVICE_PROTOCOLS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/testProtocols)
506
507+
508 generate_telepathy_test(AccountEntryFactoryTest SOURCES AccountEntryFactoryTest.cpp)
509 generate_telepathy_test(AccountEntryTest SOURCES AccountEntryTest.cpp)
510 generate_telepathy_test(CallEntryTest SOURCES CallEntryTest.cpp)
511
512=== modified file 'tests/libtelephonyservice/ProtocolManagerTest.cpp'
513--- tests/libtelephonyservice/ProtocolManagerTest.cpp 2015-06-15 13:52:56 +0000
514+++ tests/libtelephonyservice/ProtocolManagerTest.cpp 2016-12-06 17:32:46 +0000
515@@ -21,6 +21,8 @@
516 #include <QTemporaryDir>
517 #include <QDir>
518 #include <QFile>
519+#include <QDBusInterface>
520+#include <QDBusMetaType>
521
522 #include "config.h"
523 #include "protocolmanager.h"

Subscribers

People subscribed via source and target branches

to all changes: