Merge lp:~boiko/telephony-service/active_call_indicator into lp:telephony-service

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 820
Merged at revision: 831
Proposed branch: lp:~boiko/telephony-service/active_call_indicator
Merge into: lp:telephony-service
Diff against target: 338 lines (+152/-1)
8 files modified
handler/Handler.xml (+8/-0)
handler/handlerdbus.cpp (+12/-1)
handler/handlerdbus.h (+10/-0)
handler/tests/HandlerTest.cpp (+21/-0)
handler/tests/handlercontroller.cpp (+28/-0)
handler/tests/handlercontroller.h (+5/-0)
libtelephonyservice/callmanager.cpp (+56/-0)
libtelephonyservice/callmanager.h (+12/-0)
To merge this branch: bzr merge lp:~boiko/telephony-service/active_call_indicator
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+223556@code.launchpad.net

Commit message

Add the callIndicatorVisible property to callManager so that dialer-app can control the active call indicator visibility.

Description of the change

Add the callIndicatorVisible property to callManager so that dialer-app can control the active call indicator visibility.

== Checklist ==
Are there any related MPs required for this MP to build/function as expected? Please list.
No

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/telephony-service) 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
Tiago Salem Herrmann (tiagosh) wrote :

Looks good.

----

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

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 2014-04-25 20:47:01 +0000
3+++ handler/Handler.xml 2014-06-18 13:32:24 +0000
4@@ -124,5 +124,13 @@
5 <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>
6 <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
7 </signal>
8+ <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
9+ <property name="CallIndicatorVisible" type="b" access="readwrite"/>
10+ <signal name="CallIndicatorVisibleChanged">
11+ <dox:d><![CDATA[
12+ The call indicator visibility has changed
13+ ]]></dox:d>
14+ <arg name="visible" type="b"/>
15+ </signal>
16 </interface>
17 </node>
18
19=== modified file 'handler/handlerdbus.cpp'
20--- handler/handlerdbus.cpp 2014-04-25 20:47:01 +0000
21+++ handler/handlerdbus.cpp 2014-06-18 13:32:24 +0000
22@@ -33,7 +33,7 @@
23 static const char* DBUS_SERVICE = "com.canonical.TelephonyServiceHandler";
24 static const char* DBUS_OBJECT_PATH = "/com/canonical/TelephonyServiceHandler";
25
26-HandlerDBus::HandlerDBus(QObject* parent) : QObject(parent)
27+HandlerDBus::HandlerDBus(QObject* parent) : QObject(parent), mCallIndicatorVisible(false)
28 {
29 connect(CallHandler::instance(),
30 SIGNAL(callPropertiesChanged(QString,QVariantMap)),
31@@ -64,6 +64,17 @@
32 return TelepathyHelper::instance()->connected();
33 }
34
35+bool HandlerDBus::callIndicatorVisible() const
36+{
37+ return mCallIndicatorVisible;
38+}
39+
40+void HandlerDBus::setCallIndicatorVisible(bool visible)
41+{
42+ mCallIndicatorVisible = visible;
43+ Q_EMIT CallIndicatorVisibleChanged(visible);
44+}
45+
46 bool HandlerDBus::connectToBus()
47 {
48 bool ok = QDBusConnection::sessionBus().registerService(DBUS_SERVICE);
49
50=== modified file 'handler/handlerdbus.h'
51--- handler/handlerdbus.h 2014-04-25 20:47:01 +0000
52+++ handler/handlerdbus.h 2014-06-18 13:32:24 +0000
53@@ -34,6 +34,10 @@
54 class HandlerDBus : public QObject, protected QDBusContext
55 {
56 Q_OBJECT
57+ Q_PROPERTY(bool CallIndicatorVisible
58+ READ callIndicatorVisible
59+ WRITE setCallIndicatorVisible
60+ NOTIFY CallIndicatorVisibleChanged)
61
62 public:
63 HandlerDBus(QObject* parent=0);
64@@ -43,6 +47,8 @@
65 bool HasCalls();
66 QStringList AccountIds();
67 bool IsConnected();
68+ bool callIndicatorVisible() const;
69+ void setCallIndicatorVisible(bool visible);
70
71 public Q_SLOTS:
72 bool connectToBus();
73@@ -67,6 +73,10 @@
74 Q_SIGNALS:
75 void onMessageSent(const QString &number, const QString &message);
76 void CallPropertiesChanged(const QString &objectPath, const QVariantMap &properties);
77+ void CallIndicatorVisibleChanged(bool visible);
78+
79+private:
80+ bool mCallIndicatorVisible;
81 };
82
83 #endif // HANDLERDBUS_H
84
85=== modified file 'handler/tests/HandlerTest.cpp'
86--- handler/tests/HandlerTest.cpp 2014-04-09 16:46:29 +0000
87+++ handler/tests/HandlerTest.cpp 2014-06-18 13:32:24 +0000
88@@ -35,6 +35,7 @@
89 void testCallProperties();
90 void testConferenceCall();
91 void testSendMessage();
92+ void testActiveCallIndicator();
93
94 private:
95 void waitForCallActive(const QString &callerId);
96@@ -258,6 +259,26 @@
97 QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient);
98 }
99
100+void HandlerTest::testActiveCallIndicator()
101+{
102+ // start by making sure the property is false by default
103+ QVERIFY(!HandlerController::instance()->callIndicatorVisible());
104+ QSignalSpy spy(HandlerController::instance(), SIGNAL(callIndicatorVisibleChanged(bool)));
105+
106+ // set the property to true
107+ HandlerController::instance()->setCallIndicatorVisible(true);
108+ QTRY_COMPARE(spy.count(), 1);
109+ QVERIFY(spy.first().first().toBool());
110+ QVERIFY(HandlerController::instance()->callIndicatorVisible());
111+
112+ // and back to false
113+ spy.clear();
114+ HandlerController::instance()->setCallIndicatorVisible(false);
115+ QTRY_COMPARE(spy.count(), 1);
116+ QVERIFY(!spy.first().first().toBool());
117+ QVERIFY(!HandlerController::instance()->callIndicatorVisible());
118+}
119+
120 void HandlerTest::waitForCallActive(const QString &callerId)
121 {
122 // wait until the call state is "accepted"
123
124=== modified file 'handler/tests/handlercontroller.cpp'
125--- handler/tests/handlercontroller.cpp 2014-03-20 21:03:26 +0000
126+++ handler/tests/handlercontroller.cpp 2014-06-18 13:32:24 +0000
127@@ -20,6 +20,7 @@
128 #include <QStringList>
129 #include "handlercontroller.h"
130 #include <QDBusReply>
131+#include <QDebug>
132
133 #define HANDLER_SERVICE "com.canonical.TelephonyServiceHandler"
134 #define HANDLER_OBJECT "/com/canonical/TelephonyServiceHandler"
135@@ -38,6 +39,9 @@
136 connect(&mHandlerInterface,
137 SIGNAL(CallPropertiesChanged(QString, QVariantMap)),
138 SIGNAL(callPropertiesChanged(QString, QVariantMap)));
139+ connect(&mHandlerInterface,
140+ SIGNAL(CallIndicatorVisibleChanged(bool)),
141+ SIGNAL(callIndicatorVisibleChanged(bool)));
142 }
143
144 QVariantMap HandlerController::getCallProperties(const QString &objectPath)
145@@ -51,6 +55,20 @@
146 return properties;
147 }
148
149+bool HandlerController::callIndicatorVisible()
150+{
151+ QDBusInterface handlerPropertiesInterface("com.canonical.TelephonyServiceHandler",
152+ "/com/canonical/TelephonyServiceHandler",
153+ "org.freedesktop.DBus.Properties");
154+ QDBusReply<QVariantMap> reply = handlerPropertiesInterface.call("GetAll", "com.canonical.TelephonyServiceHandler");
155+ if (!reply.isValid()) {
156+ return false;
157+ }
158+
159+ QVariantMap map = reply.value();
160+ return map["CallIndicatorVisible"].toBool();
161+}
162+
163 void HandlerController::startCall(const QString &number, const QString &accountId)
164 {
165 mHandlerInterface.call("StartCall", number, accountId);
166@@ -105,3 +123,13 @@
167 {
168 mHandlerInterface.call("AcknowledgeMessages", number, messageIds, accountId);
169 }
170+
171+void HandlerController::setCallIndicatorVisible(bool visible)
172+{
173+ QDBusInterface handlerPropertiesInterface("com.canonical.TelephonyServiceHandler",
174+ "/com/canonical/TelephonyServiceHandler",
175+ "org.freedesktop.DBus.Properties");
176+ handlerPropertiesInterface.call("Set",
177+ "com.canonical.TelephonyServiceHandler",
178+ "CallIndicatorVisible", QVariant::fromValue(QDBusVariant(visible)));
179+}
180
181=== modified file 'handler/tests/handlercontroller.h'
182--- handler/tests/handlercontroller.h 2014-03-20 21:03:26 +0000
183+++ handler/tests/handlercontroller.h 2014-06-18 13:32:24 +0000
184@@ -30,6 +30,7 @@
185 static HandlerController *instance();
186
187 QVariantMap getCallProperties(const QString &objectPath);
188+ bool callIndicatorVisible();
189
190 public Q_SLOTS:
191 // call methods
192@@ -49,8 +50,12 @@
193 void sendMessage(const QString &number, const QString &message, const QString &accountId);
194 void acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId);
195
196+ // active call indicator
197+ void setCallIndicatorVisible(bool visible);
198+
199 Q_SIGNALS:
200 void callPropertiesChanged(const QString &objectPath, const QVariantMap &properties);
201+ void callIndicatorVisibleChanged(bool visible);
202
203 private:
204 explicit HandlerController(QObject *parent = 0);
205
206=== modified file 'libtelephonyservice/callmanager.cpp'
207--- libtelephonyservice/callmanager.cpp 2014-06-04 21:10:36 +0000
208+++ libtelephonyservice/callmanager.cpp 2014-06-18 13:32:24 +0000
209@@ -44,6 +44,46 @@
210 connect(TelepathyHelper::instance(), SIGNAL(connectedChanged()), SLOT(onConnectedChanged()));
211 connect(TelepathyHelper::instance(), SIGNAL(channelObserverUnregistered()), SLOT(onChannelObserverUnregistered()));
212 connect(this, SIGNAL(hasCallsChanged()), SIGNAL(callsChanged()));
213+ connect(this, &CallManager::hasCallsChanged, [this] {
214+ Q_EMIT this->callIndicatorVisibleChanged(this->callIndicatorVisible());
215+ });
216+
217+ refreshProperties();
218+
219+ // connect the dbus signal
220+ QDBusConnection connection = QDBusConnection::sessionBus();
221+ connection.connect("com.canonical.TelephonyServiceHandler",
222+ "/com/canonical/TelephonyServiceHandler",
223+ "com.canonical.TelephonyServiceHandler",
224+ "CallIndicatorVisibleChanged",
225+ this, SLOT(onCallIndicatorVisibleChanged(bool)));
226+}
227+
228+void CallManager::refreshProperties()
229+{
230+ QDBusInterface handlerPropertiesInterface("com.canonical.TelephonyServiceHandler",
231+ "/com/canonical/TelephonyServiceHandler",
232+ "org.freedesktop.DBus.Properties");
233+ QDBusReply<QVariantMap> reply = handlerPropertiesInterface.call("GetAll",
234+ "com.canonical.TelephonyServiceHandler");
235+ if (!reply.isValid()) {
236+ qWarning() << "Failed to refresh the properties from the handler";
237+ return;
238+ }
239+
240+ QVariantMap map = reply.value();
241+ mCallIndicatorVisible = map["CallIndicatorVisible"].toBool();
242+ Q_EMIT callIndicatorVisibleChanged(mCallIndicatorVisible);
243+}
244+
245+void CallManager::setDBusProperty(const QString &name, const QVariant &value)
246+{
247+ QDBusInterface handlerPropertiesInterface("com.canonical.TelephonyServiceHandler",
248+ "/com/canonical/TelephonyServiceHandler",
249+ "org.freedesktop.DBus.Properties");
250+ handlerPropertiesInterface.call("Set",
251+ "com.canonical.TelephonyServiceHandler",
252+ name, QVariant::fromValue(QDBusVariant(value)));
253 }
254
255 QList<CallEntry *> CallManager::takeCalls(const QList<Tp::ChannelPtr> callChannels)
256@@ -85,6 +125,16 @@
257 Q_EMIT backgroundCallChanged();
258 }
259
260+bool CallManager::callIndicatorVisible() const
261+{
262+ return hasCalls() && mCallIndicatorVisible;
263+}
264+
265+void CallManager::setCallIndicatorVisible(bool visible)
266+{
267+ setDBusProperty("CallIndicatorVisible", visible);
268+}
269+
270 void CallManager::setupCallEntry(CallEntry *entry)
271 {
272 connect(entry,
273@@ -150,6 +200,12 @@
274 }
275 }
276
277+void CallManager::onCallIndicatorVisibleChanged(bool visible)
278+{
279+ mCallIndicatorVisible = visible;
280+ Q_EMIT callIndicatorVisibleChanged(visible);
281+}
282+
283 CallEntry *CallManager::foregroundCall() const
284 {
285 CallEntry *call = 0;
286
287=== modified file 'libtelephonyservice/callmanager.h'
288--- libtelephonyservice/callmanager.h 2014-03-31 19:01:42 +0000
289+++ libtelephonyservice/callmanager.h 2014-06-18 13:32:24 +0000
290@@ -53,6 +53,10 @@
291 Q_PROPERTY(QQmlListProperty<CallEntry> calls
292 READ calls
293 NOTIFY callsChanged)
294+ Q_PROPERTY(bool callIndicatorVisible
295+ READ callIndicatorVisible
296+ WRITE setCallIndicatorVisible
297+ NOTIFY callIndicatorVisibleChanged)
298
299 public:
300 static CallManager *instance();
301@@ -72,6 +76,10 @@
302 QList<CallEntry*> takeCalls(const QList<Tp::ChannelPtr> callChannels);
303 void addCalls(const QList<CallEntry*> entries);
304
305+ // call indicator related
306+ bool callIndicatorVisible() const;
307+ void setCallIndicatorVisible(bool visible);
308+
309 // QQmlListProperty helpers
310 static int callsCount(QQmlListProperty<CallEntry> *p);
311 static CallEntry* callAt(QQmlListProperty<CallEntry> *p, int index);
312@@ -85,22 +93,26 @@
313 void hasBackgroundCallChanged();
314 void speakerChanged();
315 void voicemailNumberChanged();
316+ void callIndicatorVisibleChanged(bool visible);
317
318 public Q_SLOTS:
319 void onCallChannelAvailable(Tp::CallChannelPtr channel);
320 void onChannelObserverUnregistered();
321 void onCallEnded();
322 void onConnectedChanged();
323+ void onCallIndicatorVisibleChanged(bool visible);
324
325 private:
326 explicit CallManager(QObject *parent = 0);
327 void refreshProperties();
328+ void setDBusProperty(const QString &name, const QVariant &value);
329 void setupCallEntry(CallEntry *entry);
330
331 mutable QList<CallEntry*> mCallEntries;
332 QString mVoicemailNumber;
333 bool mNeedsUpdate;
334 CallEntry *mConferenceCall;
335+ bool mCallIndicatorVisible;
336 };
337
338 #endif // CALLMANAGER_H

Subscribers

People subscribed via source and target branches