Merge lp:~tiagosh/telephony-service/fix-1398427 into lp:telephony-service

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 996
Merged at revision: 994
Proposed branch: lp:~tiagosh/telephony-service/fix-1398427
Merge into: lp:telephony-service
Diff against target: 299 lines (+106/-8)
10 files modified
approver/Approver.xml (+7/-0)
approver/approver.cpp (+53/-2)
approver/approver.h (+4/-0)
approver/approverdbus.cpp (+6/-1)
approver/approverdbus.h (+5/-1)
approver/main.cpp (+4/-4)
libtelephonyservice/callmanager.cpp (+11/-0)
libtelephonyservice/callmanager.h (+1/-0)
libtelephonyservice/telepathyhelper.cpp (+13/-0)
libtelephonyservice/telepathyhelper.h (+2/-0)
To merge this branch: bzr merge lp:~tiagosh/telephony-service/fix-1398427
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Michał Sawicz Approve
Review via email: mp+246224@code.launchpad.net

Commit message

Expose HandleMediaKey(bool doubleClick) to DBus.

Description of the change

Expose HandleMediaKey(bool doubleClick) to DBus.
This is going to be called by unity8.

--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 UI labels, did you update the pot file?
N/A

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

To post a comment you must log in.
Revision history for this message
Michał Sawicz (saviq) wrote :

Hey, do you think it'd make sense for you to return true/false depending on whether you accepted (consumed/reacted to) the event? We could fall back to other consumers then.

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
992. By Tiago Salem Herrmann

Return a bool value in HandleMediaKey to indicate if the event will be handled by the approver.

Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

> Hey, do you think it'd make sense for you to return true/false depending on
> whether you accepted (consumed/reacted to) the event? We could fall back to
> other consumers then.

Yes, good idea. Just changed the code to match your suggestion.

993. By Tiago Salem Herrmann

export handleMediaKey(bool) to qml plugin

994. By Tiago Salem Herrmann

cache hasCalls value

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
995. By Tiago Salem Herrmann

change return name

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
996. By Tiago Salem Herrmann

- change approver bus name to fix dbus activation
- use a global timer and always return right away on HandleMediaKey()

Revision history for this message
Michał Sawicz (saviq) wrote :

Great, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (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.
No, but that's because the tests are being run twice, and in the second run it failed.

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
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Hmm... this seems to crash unity8 when I call:

callManager.handleMediaKey(false)

997. By Tiago Salem Herrmann

use mApproverInterface instead of mHandlerInterface

Revision history for this message
Michael Zanetti (mzanetti) wrote :

Tried the current build from silo 19 (should be rev 997) but it still crashes with this backtrace:

http://paste.ubuntu.com/9755185/

review: Needs Fixing
998. By Tiago Salem Herrmann

initialize variable

Revision history for this message
Michael Zanetti (mzanetti) wrote :

this works for me now

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'approver/Approver.xml'
--- approver/Approver.xml 2014-01-20 12:57:43 +0000
+++ approver/Approver.xml 2015-01-15 14:17:50 +0000
@@ -27,5 +27,12 @@
27 this method has no effect.27 this method has no effect.
28 ]]></dox:d>28 ]]></dox:d>
29 </method>29 </method>
30 <method name="HandleMediaKey">
31 <dox:d><![CDATA[
32 Handle events generated by media key buttons usually present on headsets.
33 ]]></dox:d>
34 <arg name="doubleClick" type="b" direction="in"/>
35 <arg name="accepted" type="b" direction="out"/>
36 </method>
30 </interface>37 </interface>
31</node>38</node>
3239
=== modified file 'approver/approver.cpp'
--- approver/approver.cpp 2015-01-08 01:05:51 +0000
+++ approver/approver.cpp 2015-01-15 14:17:50 +0000
@@ -32,6 +32,7 @@
32#include "callmanager.h"32#include "callmanager.h"
33#include "callentry.h"33#include "callentry.h"
34#include "tonegenerator.h"34#include "tonegenerator.h"
35#include "telepathyhelper.h"
3536
36#include <QContactAvatar>37#include <QContactAvatar>
37#include <QContactDisplayLabel>38#include <QContactDisplayLabel>
@@ -54,18 +55,20 @@
5455
55Approver::Approver()56Approver::Approver()
56: Tp::AbstractClientApprover(channelFilters()),57: Tp::AbstractClientApprover(channelFilters()),
57 mPendingSnapDecision(NULL)58 mPendingSnapDecision(NULL),
59 mSettleTimer(new QTimer(this))
58{60{
59 mDefaultTitle = C::gettext("Unknown caller");61 mDefaultTitle = C::gettext("Unknown caller");
60 mDefaultIcon = QUrl(telephonyServiceDir() + "assets/avatar-default@18.png").toEncoded();62 mDefaultIcon = QUrl(telephonyServiceDir() + "assets/avatar-default@18.png").toEncoded();
6163
62 ApproverDBus *dbus = new ApproverDBus();64 ApproverDBus *dbus = new ApproverDBus(this);
63 connect(dbus,65 connect(dbus,
64 SIGNAL(acceptCallRequested()),66 SIGNAL(acceptCallRequested()),
65 SLOT(onAcceptCallRequested()));67 SLOT(onAcceptCallRequested()));
66 connect(dbus,68 connect(dbus,
67 SIGNAL(rejectCallRequested()),69 SIGNAL(rejectCallRequested()),
68 SLOT(onRejectCallRequested()));70 SLOT(onRejectCallRequested()));
71
69 dbus->connectToBus();72 dbus->connectToBus();
7073
71 if (GreeterContacts::isGreeterMode()) {74 if (GreeterContacts::isGreeterMode()) {
@@ -79,6 +82,17 @@
79 mRejectActions["rejectMessage1"] = C::gettext("I'm busy at the moment. I'll call later.");82 mRejectActions["rejectMessage1"] = C::gettext("I'm busy at the moment. I'll call later.");
80 mRejectActions["rejectMessage2"] = C::gettext("I'm running late, on my way now.");83 mRejectActions["rejectMessage2"] = C::gettext("I'm running late, on my way now.");
81 mRejectActions["rejectMessage3"] = C::gettext("Please call me back later.");84 mRejectActions["rejectMessage3"] = C::gettext("Please call me back later.");
85
86 mSettleTimer->setInterval(500);
87 mSettleTimer->setSingleShot(true);
88 connect(mSettleTimer, SIGNAL(timeout()), this, SLOT(onSettleTimerTimeout()));
89 mSettleTimer->start();
90}
91
92void Approver::onSettleTimerTimeout()
93{
94 mSettleTimer->deleteLater();
95 mSettleTimer = NULL;
82}96}
8397
84Approver::~Approver()98Approver::~Approver()
@@ -663,3 +677,40 @@
663 }677 }
664}678}
665679
680bool Approver::handleMediaKey(bool doubleClick)
681{
682 Q_UNUSED(doubleClick)
683
684 // hasCalls gets the value from handler, so even if CallManager isn't ready right now, we know
685 // if the event will be handled later
686 bool accepted = mPendingSnapDecision || CallManager::instance()->hasCalls();
687
688 // FIXME: Telepathy-qt does not let us know if existing channels are being recovered,
689 // so if this is the first run, call this method again when mSettleTimer is done
690 if (mSettleTimer) {
691 QObject::connect(mSettleTimer, &QTimer::timeout, [=]() {
692 handleMediaKey(doubleClick);
693 });
694 return accepted;
695 }
696
697 // postpone this to avoid blocking dbus method callers
698 QMetaObject::invokeMethod(this, "processHandleMediaKey", Qt::QueuedConnection, Q_ARG(bool, doubleClick));
699 return accepted;
700}
701
702void Approver::processHandleMediaKey(bool doubleClick)
703{
704 Q_UNUSED(doubleClick)
705
706 if (mPendingSnapDecision) {
707 onAcceptCallRequested();
708 } else if (CallManager::instance()->hasCalls()) {
709 // if there is no incoming call, we have to hangup the current active call
710 CallEntry *call = CallManager::instance()->foregroundCall();
711 if (call) {
712 call->endCall();
713 }
714 }
715}
716
666717
=== modified file 'approver/approver.h'
--- approver/approver.h 2014-10-09 19:32:20 +0000
+++ approver/approver.h 2015-01-15 14:17:50 +0000
@@ -56,6 +56,7 @@
56 bool showSnapDecision(const Tp::ChannelDispatchOperationPtr dispatchOperation,56 bool showSnapDecision(const Tp::ChannelDispatchOperationPtr dispatchOperation,
57 const Tp::ChannelPtr channel,57 const Tp::ChannelPtr channel,
58 const QContact &contact = QContact());58 const QContact &contact = QContact());
59 bool handleMediaKey(bool doubleClick);
5960
60protected:61protected:
61 Tp::ChannelDispatchOperationPtr dispatchOperationForIncomingCall();62 Tp::ChannelDispatchOperationPtr dispatchOperationForIncomingCall();
@@ -71,6 +72,8 @@
71 void onAcceptCallRequested();72 void onAcceptCallRequested();
72 void onRejectCallRequested();73 void onRejectCallRequested();
73 void updateNotification(const QtContacts::QContact &contact);74 void updateNotification(const QtContacts::QContact &contact);
75 void onSettleTimerTimeout();
76 void processHandleMediaKey(bool doubleClick);
7477
75private:78private:
76 QList<Tp::ChannelDispatchOperationPtr> mDispatchOps;79 QList<Tp::ChannelDispatchOperationPtr> mDispatchOps;
@@ -81,6 +84,7 @@
81 QString mCachedBody;84 QString mCachedBody;
82 QFeedbackHapticsEffect mVibrateEffect;85 QFeedbackHapticsEffect mVibrateEffect;
83 QTimer mVibrateTimer;86 QTimer mVibrateTimer;
87 QTimer *mSettleTimer;
84 QMap<QString,QString> mRejectActions;88 QMap<QString,QString> mRejectActions;
85};89};
8690
8791
=== modified file 'approver/approverdbus.cpp'
--- approver/approverdbus.cpp 2014-01-20 12:57:43 +0000
+++ approver/approverdbus.cpp 2015-01-15 14:17:50 +0000
@@ -29,7 +29,7 @@
29static const char* DBUS_SERVICE = "com.canonical.Approver";29static const char* DBUS_SERVICE = "com.canonical.Approver";
30static const char* DBUS_OBJECT_PATH = "/com/canonical/Approver";30static const char* DBUS_OBJECT_PATH = "/com/canonical/Approver";
3131
32ApproverDBus::ApproverDBus(QObject* parent) : QObject(parent)32ApproverDBus::ApproverDBus(Approver *approver, QObject* parent) : QObject(parent), mApprover(approver)
33{33{
34}34}
3535
@@ -64,3 +64,8 @@
64{64{
65 Q_EMIT rejectCallRequested();65 Q_EMIT rejectCallRequested();
66}66}
67
68bool ApproverDBus::HandleMediaKey(bool doubleClick)
69{
70 return mApprover->handleMediaKey(doubleClick);
71}
6772
=== modified file 'approver/approverdbus.h'
--- approver/approverdbus.h 2014-01-20 12:57:43 +0000
+++ approver/approverdbus.h 2015-01-15 14:17:50 +0000
@@ -26,6 +26,7 @@
26#include <QtCore/QObject>26#include <QtCore/QObject>
27#include <QtDBus/QDBusContext>27#include <QtDBus/QDBusContext>
28#include "chatmanager.h"28#include "chatmanager.h"
29#include "approver.h"
2930
30/**31/**
31 * DBus interface for the phone approver32 * DBus interface for the phone approver
@@ -35,7 +36,7 @@
35 Q_OBJECT36 Q_OBJECT
3637
37public:38public:
38 ApproverDBus(QObject* parent=0);39 ApproverDBus(Approver *approver, QObject* parent=0);
39 ~ApproverDBus();40 ~ApproverDBus();
4041
41 bool connectToBus();42 bool connectToBus();
@@ -44,11 +45,14 @@
44 Q_NOREPLY void HangUpAndAcceptCall();45 Q_NOREPLY void HangUpAndAcceptCall();
45 Q_NOREPLY void AcceptCall();46 Q_NOREPLY void AcceptCall();
46 Q_NOREPLY void RejectCall();47 Q_NOREPLY void RejectCall();
48 bool HandleMediaKey(bool doubleClick);
4749
48Q_SIGNALS:50Q_SIGNALS:
49 void hangUpAndAcceptCallRequested();51 void hangUpAndAcceptCallRequested();
50 void acceptCallRequested();52 void acceptCallRequested();
51 void rejectCallRequested();53 void rejectCallRequested();
54private:
55 Approver *mApprover;
52};56};
5357
54#endif // APPROVERDBUS_H58#endif // APPROVERDBUS_H
5559
=== modified file 'approver/main.cpp'
--- approver/main.cpp 2015-01-08 01:05:51 +0000
+++ approver/main.cpp 2015-01-15 14:17:50 +0000
@@ -58,11 +58,11 @@
58 qputenv("UBUNTU_PLATFORM_API_BACKEND", "touch_mirclient");58 qputenv("UBUNTU_PLATFORM_API_BACKEND", "touch_mirclient");
59#endif59#endif
6060
61 // register the approver61 QObject::connect(TelepathyHelper::instance(), &TelepathyHelper::setupReady, []() {
62 Approver *approver = new Approver();62 // register the approver
63 QObject::connect(TelepathyHelper::instance(), &TelepathyHelper::setupReady, [approver]() {63 TelepathyHelper::instance()->registerChannelObserver("TelephonyServiceObserver");
64 Approver *approver = new Approver();
64 TelepathyHelper::instance()->registerClient(approver, "TelephonyServiceApprover");65 TelepathyHelper::instance()->registerClient(approver, "TelephonyServiceApprover");
65 TelepathyHelper::instance()->registerChannelObserver("TelephonyServiceObserver");
66 });66 });
6767
68 return app.exec();68 return app.exec();
6969
=== modified file 'libtelephonyservice/callmanager.cpp'
--- libtelephonyservice/callmanager.cpp 2014-09-11 18:12:50 +0000
+++ libtelephonyservice/callmanager.cpp 2015-01-15 14:17:50 +0000
@@ -380,3 +380,14 @@
380 /* calling without channel, DTMF tone is played only locally */380 /* calling without channel, DTMF tone is played only locally */
381 phoneAppHandler->call("SendDTMF", "" , key);381 phoneAppHandler->call("SendDTMF", "" , key);
382}382}
383
384bool CallManager::handleMediaKey(bool doubleClick)
385{
386 QDBusInterface *approverInterface = TelepathyHelper::instance()->approverInterface();
387 QDBusReply<bool> reply = approverInterface->call("HandleMediaKey", doubleClick);
388 if (reply.isValid()) {
389 return reply.value();
390 }
391 return false;
392}
393
383394
=== modified file 'libtelephonyservice/callmanager.h'
--- libtelephonyservice/callmanager.h 2014-08-22 19:01:46 +0000
+++ libtelephonyservice/callmanager.h 2015-01-15 14:17:50 +0000
@@ -61,6 +61,7 @@
61 Q_INVOKABLE void mergeCalls(CallEntry *firstCall, CallEntry *secondCall);61 Q_INVOKABLE void mergeCalls(CallEntry *firstCall, CallEntry *secondCall);
62 Q_INVOKABLE void splitCall(CallEntry *callEntry);62 Q_INVOKABLE void splitCall(CallEntry *callEntry);
63 Q_INVOKABLE void playTone(const QString &key);63 Q_INVOKABLE void playTone(const QString &key);
64 Q_INVOKABLE bool handleMediaKey(bool doubleClick);
6465
65 CallEntry *foregroundCall() const;66 CallEntry *foregroundCall() const;
66 CallEntry *backgroundCall() const;67 CallEntry *backgroundCall() const;
6768
=== modified file 'libtelephonyservice/telepathyhelper.cpp'
--- libtelephonyservice/telepathyhelper.cpp 2014-12-17 12:54:52 +0000
+++ libtelephonyservice/telepathyhelper.cpp 2015-01-15 14:17:50 +0000
@@ -43,6 +43,7 @@
43 mFirstTime(true),43 mFirstTime(true),
44 mConnected(false),44 mConnected(false),
45 mHandlerInterface(0),45 mHandlerInterface(0),
46 mApproverInterface(0),
46 mDefaultSimSettings(new QGSettings("com.ubuntu.phone")),47 mDefaultSimSettings(new QGSettings("com.ubuntu.phone")),
47 mFlightModeInterface("org.freedesktop.URfkill",48 mFlightModeInterface("org.freedesktop.URfkill",
48 "/org/freedesktop/URfkill",49 "/org/freedesktop/URfkill",
@@ -172,6 +173,18 @@
172 return mHandlerInterface;173 return mHandlerInterface;
173}174}
174175
176QDBusInterface *TelepathyHelper::approverInterface() const
177{
178 if (!mApproverInterface) {
179 mApproverInterface = new QDBusInterface("org.freedesktop.Telepathy.Client.TelephonyServiceApprover",
180 "/com/canonical/Approver",
181 "com.canonical.TelephonyServiceApprover",
182 QDBusConnection::sessionBus(),
183 const_cast<TelepathyHelper*>(this));
184 }
185 return mApproverInterface;
186}
187
175bool TelepathyHelper::connected() const188bool TelepathyHelper::connected() const
176{189{
177 if (QCoreApplication::applicationName() != "telephony-service-handler" &&190 if (QCoreApplication::applicationName() != "telephony-service-handler" &&
178191
=== modified file 'libtelephonyservice/telepathyhelper.h'
--- libtelephonyservice/telepathyhelper.h 2014-12-17 12:54:52 +0000
+++ libtelephonyservice/telepathyhelper.h 2015-01-15 14:17:50 +0000
@@ -67,6 +67,7 @@
67 QQmlListProperty<AccountEntry> qmlActiveAccounts();67 QQmlListProperty<AccountEntry> qmlActiveAccounts();
68 ChannelObserver *channelObserver() const;68 ChannelObserver *channelObserver() const;
69 QDBusInterface *handlerInterface() const;69 QDBusInterface *handlerInterface() const;
70 QDBusInterface *approverInterface() const;
70 AccountEntry *defaultMessagingAccount() const;71 AccountEntry *defaultMessagingAccount() const;
71 AccountEntry *defaultCallAccount() const;72 AccountEntry *defaultCallAccount() const;
7273
@@ -136,6 +137,7 @@
136 bool mFirstTime;137 bool mFirstTime;
137 bool mConnected;138 bool mConnected;
138 mutable QDBusInterface *mHandlerInterface;139 mutable QDBusInterface *mHandlerInterface;
140 mutable QDBusInterface *mApproverInterface;
139 QGSettings *mDefaultSimSettings;141 QGSettings *mDefaultSimSettings;
140 QDBusInterface mFlightModeInterface;142 QDBusInterface mFlightModeInterface;
141};143};

Subscribers

People subscribed via source and target branches