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
=== modified file 'handler/Handler.xml'
--- handler/Handler.xml 2014-04-25 20:47:01 +0000
+++ handler/Handler.xml 2014-06-18 13:32:24 +0000
@@ -124,5 +124,13 @@
124 <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>124 <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>
125 <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>125 <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>
126 </signal>126 </signal>
127 <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
128 <property name="CallIndicatorVisible" type="b" access="readwrite"/>
129 <signal name="CallIndicatorVisibleChanged">
130 <dox:d><![CDATA[
131 The call indicator visibility has changed
132 ]]></dox:d>
133 <arg name="visible" type="b"/>
134 </signal>
127 </interface>135 </interface>
128</node>136</node>
129137
=== modified file 'handler/handlerdbus.cpp'
--- handler/handlerdbus.cpp 2014-04-25 20:47:01 +0000
+++ handler/handlerdbus.cpp 2014-06-18 13:32:24 +0000
@@ -33,7 +33,7 @@
33static const char* DBUS_SERVICE = "com.canonical.TelephonyServiceHandler";33static const char* DBUS_SERVICE = "com.canonical.TelephonyServiceHandler";
34static const char* DBUS_OBJECT_PATH = "/com/canonical/TelephonyServiceHandler";34static const char* DBUS_OBJECT_PATH = "/com/canonical/TelephonyServiceHandler";
3535
36HandlerDBus::HandlerDBus(QObject* parent) : QObject(parent)36HandlerDBus::HandlerDBus(QObject* parent) : QObject(parent), mCallIndicatorVisible(false)
37{37{
38 connect(CallHandler::instance(),38 connect(CallHandler::instance(),
39 SIGNAL(callPropertiesChanged(QString,QVariantMap)),39 SIGNAL(callPropertiesChanged(QString,QVariantMap)),
@@ -64,6 +64,17 @@
64 return TelepathyHelper::instance()->connected();64 return TelepathyHelper::instance()->connected();
65}65}
6666
67bool HandlerDBus::callIndicatorVisible() const
68{
69 return mCallIndicatorVisible;
70}
71
72void HandlerDBus::setCallIndicatorVisible(bool visible)
73{
74 mCallIndicatorVisible = visible;
75 Q_EMIT CallIndicatorVisibleChanged(visible);
76}
77
67bool HandlerDBus::connectToBus()78bool HandlerDBus::connectToBus()
68{79{
69 bool ok = QDBusConnection::sessionBus().registerService(DBUS_SERVICE);80 bool ok = QDBusConnection::sessionBus().registerService(DBUS_SERVICE);
7081
=== modified file 'handler/handlerdbus.h'
--- handler/handlerdbus.h 2014-04-25 20:47:01 +0000
+++ handler/handlerdbus.h 2014-06-18 13:32:24 +0000
@@ -34,6 +34,10 @@
34class HandlerDBus : public QObject, protected QDBusContext34class HandlerDBus : public QObject, protected QDBusContext
35{35{
36 Q_OBJECT36 Q_OBJECT
37 Q_PROPERTY(bool CallIndicatorVisible
38 READ callIndicatorVisible
39 WRITE setCallIndicatorVisible
40 NOTIFY CallIndicatorVisibleChanged)
3741
38public:42public:
39 HandlerDBus(QObject* parent=0);43 HandlerDBus(QObject* parent=0);
@@ -43,6 +47,8 @@
43 bool HasCalls();47 bool HasCalls();
44 QStringList AccountIds();48 QStringList AccountIds();
45 bool IsConnected();49 bool IsConnected();
50 bool callIndicatorVisible() const;
51 void setCallIndicatorVisible(bool visible);
4652
47public Q_SLOTS:53public Q_SLOTS:
48 bool connectToBus();54 bool connectToBus();
@@ -67,6 +73,10 @@
67Q_SIGNALS:73Q_SIGNALS:
68 void onMessageSent(const QString &number, const QString &message);74 void onMessageSent(const QString &number, const QString &message);
69 void CallPropertiesChanged(const QString &objectPath, const QVariantMap &properties);75 void CallPropertiesChanged(const QString &objectPath, const QVariantMap &properties);
76 void CallIndicatorVisibleChanged(bool visible);
77
78private:
79 bool mCallIndicatorVisible;
70};80};
7181
72#endif // HANDLERDBUS_H82#endif // HANDLERDBUS_H
7383
=== modified file 'handler/tests/HandlerTest.cpp'
--- handler/tests/HandlerTest.cpp 2014-04-09 16:46:29 +0000
+++ handler/tests/HandlerTest.cpp 2014-06-18 13:32:24 +0000
@@ -35,6 +35,7 @@
35 void testCallProperties();35 void testCallProperties();
36 void testConferenceCall();36 void testConferenceCall();
37 void testSendMessage();37 void testSendMessage();
38 void testActiveCallIndicator();
3839
39private:40private:
40 void waitForCallActive(const QString &callerId);41 void waitForCallActive(const QString &callerId);
@@ -258,6 +259,26 @@
258 QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient);259 QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient);
259}260}
260261
262void HandlerTest::testActiveCallIndicator()
263{
264 // start by making sure the property is false by default
265 QVERIFY(!HandlerController::instance()->callIndicatorVisible());
266 QSignalSpy spy(HandlerController::instance(), SIGNAL(callIndicatorVisibleChanged(bool)));
267
268 // set the property to true
269 HandlerController::instance()->setCallIndicatorVisible(true);
270 QTRY_COMPARE(spy.count(), 1);
271 QVERIFY(spy.first().first().toBool());
272 QVERIFY(HandlerController::instance()->callIndicatorVisible());
273
274 // and back to false
275 spy.clear();
276 HandlerController::instance()->setCallIndicatorVisible(false);
277 QTRY_COMPARE(spy.count(), 1);
278 QVERIFY(!spy.first().first().toBool());
279 QVERIFY(!HandlerController::instance()->callIndicatorVisible());
280}
281
261void HandlerTest::waitForCallActive(const QString &callerId)282void HandlerTest::waitForCallActive(const QString &callerId)
262{283{
263 // wait until the call state is "accepted"284 // wait until the call state is "accepted"
264285
=== modified file 'handler/tests/handlercontroller.cpp'
--- handler/tests/handlercontroller.cpp 2014-03-20 21:03:26 +0000
+++ handler/tests/handlercontroller.cpp 2014-06-18 13:32:24 +0000
@@ -20,6 +20,7 @@
20#include <QStringList>20#include <QStringList>
21#include "handlercontroller.h"21#include "handlercontroller.h"
22#include <QDBusReply>22#include <QDBusReply>
23#include <QDebug>
2324
24#define HANDLER_SERVICE "com.canonical.TelephonyServiceHandler"25#define HANDLER_SERVICE "com.canonical.TelephonyServiceHandler"
25#define HANDLER_OBJECT "/com/canonical/TelephonyServiceHandler"26#define HANDLER_OBJECT "/com/canonical/TelephonyServiceHandler"
@@ -38,6 +39,9 @@
38 connect(&mHandlerInterface,39 connect(&mHandlerInterface,
39 SIGNAL(CallPropertiesChanged(QString, QVariantMap)),40 SIGNAL(CallPropertiesChanged(QString, QVariantMap)),
40 SIGNAL(callPropertiesChanged(QString, QVariantMap)));41 SIGNAL(callPropertiesChanged(QString, QVariantMap)));
42 connect(&mHandlerInterface,
43 SIGNAL(CallIndicatorVisibleChanged(bool)),
44 SIGNAL(callIndicatorVisibleChanged(bool)));
41}45}
4246
43QVariantMap HandlerController::getCallProperties(const QString &objectPath)47QVariantMap HandlerController::getCallProperties(const QString &objectPath)
@@ -51,6 +55,20 @@
51 return properties;55 return properties;
52}56}
5357
58bool HandlerController::callIndicatorVisible()
59{
60 QDBusInterface handlerPropertiesInterface("com.canonical.TelephonyServiceHandler",
61 "/com/canonical/TelephonyServiceHandler",
62 "org.freedesktop.DBus.Properties");
63 QDBusReply<QVariantMap> reply = handlerPropertiesInterface.call("GetAll", "com.canonical.TelephonyServiceHandler");
64 if (!reply.isValid()) {
65 return false;
66 }
67
68 QVariantMap map = reply.value();
69 return map["CallIndicatorVisible"].toBool();
70}
71
54void HandlerController::startCall(const QString &number, const QString &accountId)72void HandlerController::startCall(const QString &number, const QString &accountId)
55{73{
56 mHandlerInterface.call("StartCall", number, accountId);74 mHandlerInterface.call("StartCall", number, accountId);
@@ -105,3 +123,13 @@
105{123{
106 mHandlerInterface.call("AcknowledgeMessages", number, messageIds, accountId);124 mHandlerInterface.call("AcknowledgeMessages", number, messageIds, accountId);
107}125}
126
127void HandlerController::setCallIndicatorVisible(bool visible)
128{
129 QDBusInterface handlerPropertiesInterface("com.canonical.TelephonyServiceHandler",
130 "/com/canonical/TelephonyServiceHandler",
131 "org.freedesktop.DBus.Properties");
132 handlerPropertiesInterface.call("Set",
133 "com.canonical.TelephonyServiceHandler",
134 "CallIndicatorVisible", QVariant::fromValue(QDBusVariant(visible)));
135}
108136
=== modified file 'handler/tests/handlercontroller.h'
--- handler/tests/handlercontroller.h 2014-03-20 21:03:26 +0000
+++ handler/tests/handlercontroller.h 2014-06-18 13:32:24 +0000
@@ -30,6 +30,7 @@
30 static HandlerController *instance();30 static HandlerController *instance();
3131
32 QVariantMap getCallProperties(const QString &objectPath);32 QVariantMap getCallProperties(const QString &objectPath);
33 bool callIndicatorVisible();
3334
34public Q_SLOTS:35public Q_SLOTS:
35 // call methods36 // call methods
@@ -49,8 +50,12 @@
49 void sendMessage(const QString &number, const QString &message, const QString &accountId);50 void sendMessage(const QString &number, const QString &message, const QString &accountId);
50 void acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId);51 void acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId);
5152
53 // active call indicator
54 void setCallIndicatorVisible(bool visible);
55
52Q_SIGNALS:56Q_SIGNALS:
53 void callPropertiesChanged(const QString &objectPath, const QVariantMap &properties);57 void callPropertiesChanged(const QString &objectPath, const QVariantMap &properties);
58 void callIndicatorVisibleChanged(bool visible);
5459
55private:60private:
56 explicit HandlerController(QObject *parent = 0);61 explicit HandlerController(QObject *parent = 0);
5762
=== modified file 'libtelephonyservice/callmanager.cpp'
--- libtelephonyservice/callmanager.cpp 2014-06-04 21:10:36 +0000
+++ libtelephonyservice/callmanager.cpp 2014-06-18 13:32:24 +0000
@@ -44,6 +44,46 @@
44 connect(TelepathyHelper::instance(), SIGNAL(connectedChanged()), SLOT(onConnectedChanged()));44 connect(TelepathyHelper::instance(), SIGNAL(connectedChanged()), SLOT(onConnectedChanged()));
45 connect(TelepathyHelper::instance(), SIGNAL(channelObserverUnregistered()), SLOT(onChannelObserverUnregistered()));45 connect(TelepathyHelper::instance(), SIGNAL(channelObserverUnregistered()), SLOT(onChannelObserverUnregistered()));
46 connect(this, SIGNAL(hasCallsChanged()), SIGNAL(callsChanged()));46 connect(this, SIGNAL(hasCallsChanged()), SIGNAL(callsChanged()));
47 connect(this, &CallManager::hasCallsChanged, [this] {
48 Q_EMIT this->callIndicatorVisibleChanged(this->callIndicatorVisible());
49 });
50
51 refreshProperties();
52
53 // connect the dbus signal
54 QDBusConnection connection = QDBusConnection::sessionBus();
55 connection.connect("com.canonical.TelephonyServiceHandler",
56 "/com/canonical/TelephonyServiceHandler",
57 "com.canonical.TelephonyServiceHandler",
58 "CallIndicatorVisibleChanged",
59 this, SLOT(onCallIndicatorVisibleChanged(bool)));
60}
61
62void CallManager::refreshProperties()
63{
64 QDBusInterface handlerPropertiesInterface("com.canonical.TelephonyServiceHandler",
65 "/com/canonical/TelephonyServiceHandler",
66 "org.freedesktop.DBus.Properties");
67 QDBusReply<QVariantMap> reply = handlerPropertiesInterface.call("GetAll",
68 "com.canonical.TelephonyServiceHandler");
69 if (!reply.isValid()) {
70 qWarning() << "Failed to refresh the properties from the handler";
71 return;
72 }
73
74 QVariantMap map = reply.value();
75 mCallIndicatorVisible = map["CallIndicatorVisible"].toBool();
76 Q_EMIT callIndicatorVisibleChanged(mCallIndicatorVisible);
77}
78
79void CallManager::setDBusProperty(const QString &name, const QVariant &value)
80{
81 QDBusInterface handlerPropertiesInterface("com.canonical.TelephonyServiceHandler",
82 "/com/canonical/TelephonyServiceHandler",
83 "org.freedesktop.DBus.Properties");
84 handlerPropertiesInterface.call("Set",
85 "com.canonical.TelephonyServiceHandler",
86 name, QVariant::fromValue(QDBusVariant(value)));
47}87}
4888
49QList<CallEntry *> CallManager::takeCalls(const QList<Tp::ChannelPtr> callChannels)89QList<CallEntry *> CallManager::takeCalls(const QList<Tp::ChannelPtr> callChannels)
@@ -85,6 +125,16 @@
85 Q_EMIT backgroundCallChanged();125 Q_EMIT backgroundCallChanged();
86}126}
87127
128bool CallManager::callIndicatorVisible() const
129{
130 return hasCalls() && mCallIndicatorVisible;
131}
132
133void CallManager::setCallIndicatorVisible(bool visible)
134{
135 setDBusProperty("CallIndicatorVisible", visible);
136}
137
88void CallManager::setupCallEntry(CallEntry *entry)138void CallManager::setupCallEntry(CallEntry *entry)
89{139{
90 connect(entry,140 connect(entry,
@@ -150,6 +200,12 @@
150 }200 }
151}201}
152202
203void CallManager::onCallIndicatorVisibleChanged(bool visible)
204{
205 mCallIndicatorVisible = visible;
206 Q_EMIT callIndicatorVisibleChanged(visible);
207}
208
153CallEntry *CallManager::foregroundCall() const209CallEntry *CallManager::foregroundCall() const
154{210{
155 CallEntry *call = 0;211 CallEntry *call = 0;
156212
=== modified file 'libtelephonyservice/callmanager.h'
--- libtelephonyservice/callmanager.h 2014-03-31 19:01:42 +0000
+++ libtelephonyservice/callmanager.h 2014-06-18 13:32:24 +0000
@@ -53,6 +53,10 @@
53 Q_PROPERTY(QQmlListProperty<CallEntry> calls53 Q_PROPERTY(QQmlListProperty<CallEntry> calls
54 READ calls54 READ calls
55 NOTIFY callsChanged)55 NOTIFY callsChanged)
56 Q_PROPERTY(bool callIndicatorVisible
57 READ callIndicatorVisible
58 WRITE setCallIndicatorVisible
59 NOTIFY callIndicatorVisibleChanged)
5660
57public:61public:
58 static CallManager *instance();62 static CallManager *instance();
@@ -72,6 +76,10 @@
72 QList<CallEntry*> takeCalls(const QList<Tp::ChannelPtr> callChannels);76 QList<CallEntry*> takeCalls(const QList<Tp::ChannelPtr> callChannels);
73 void addCalls(const QList<CallEntry*> entries);77 void addCalls(const QList<CallEntry*> entries);
7478
79 // call indicator related
80 bool callIndicatorVisible() const;
81 void setCallIndicatorVisible(bool visible);
82
75 // QQmlListProperty helpers83 // QQmlListProperty helpers
76 static int callsCount(QQmlListProperty<CallEntry> *p);84 static int callsCount(QQmlListProperty<CallEntry> *p);
77 static CallEntry* callAt(QQmlListProperty<CallEntry> *p, int index);85 static CallEntry* callAt(QQmlListProperty<CallEntry> *p, int index);
@@ -85,22 +93,26 @@
85 void hasBackgroundCallChanged();93 void hasBackgroundCallChanged();
86 void speakerChanged();94 void speakerChanged();
87 void voicemailNumberChanged();95 void voicemailNumberChanged();
96 void callIndicatorVisibleChanged(bool visible);
8897
89public Q_SLOTS:98public Q_SLOTS:
90 void onCallChannelAvailable(Tp::CallChannelPtr channel);99 void onCallChannelAvailable(Tp::CallChannelPtr channel);
91 void onChannelObserverUnregistered();100 void onChannelObserverUnregistered();
92 void onCallEnded();101 void onCallEnded();
93 void onConnectedChanged();102 void onConnectedChanged();
103 void onCallIndicatorVisibleChanged(bool visible);
94104
95private:105private:
96 explicit CallManager(QObject *parent = 0);106 explicit CallManager(QObject *parent = 0);
97 void refreshProperties();107 void refreshProperties();
108 void setDBusProperty(const QString &name, const QVariant &value);
98 void setupCallEntry(CallEntry *entry);109 void setupCallEntry(CallEntry *entry);
99110
100 mutable QList<CallEntry*> mCallEntries;111 mutable QList<CallEntry*> mCallEntries;
101 QString mVoicemailNumber;112 QString mVoicemailNumber;
102 bool mNeedsUpdate;113 bool mNeedsUpdate;
103 CallEntry *mConferenceCall;114 CallEntry *mConferenceCall;
115 bool mCallIndicatorVisible;
104};116};
105117
106#endif // CALLMANAGER_H118#endif // CALLMANAGER_H

Subscribers

People subscribed via source and target branches