Merge lp:~tiagosh/telephony-service/waiting-tone into lp:telephony-service

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Bill Filler
Approved revision: 952
Merged at revision: 951
Proposed branch: lp:~tiagosh/telephony-service/waiting-tone
Merge into: lp:telephony-service
Diff against target: 208 lines (+83/-30)
4 files modified
approver/approver.cpp (+8/-2)
handler/callhandler.cpp (+4/-0)
libtelephonyservice/tonegenerator.cpp (+63/-27)
libtelephonyservice/tonegenerator.h (+8/-1)
To merge this branch: bzr merge lp:~tiagosh/telephony-service/waiting-tone
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+238508@code.launchpad.net

Commit message

- Emit a sound feedback when all calls are ended
- Play a waiting tone instead of regular ringtone for waiting calls.

Description of the change

- Emit a sound feedback when all calls are ended
- Play a waiting tone instead of regular ringtone for waiting calls.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
952. By Tiago Salem Herrmann

play 3 bips only when remote side hangs up

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'approver/approver.cpp'
2--- approver/approver.cpp 2014-07-22 10:57:54 +0000
3+++ approver/approver.cpp 2014-10-16 17:05:00 +0000
4@@ -30,6 +30,7 @@
5 #include "ringtone.h"
6 #include "callmanager.h"
7 #include "callentry.h"
8+#include "tonegenerator.h"
9
10 #include <QContactAvatar>
11 #include <QContactFetchRequest>
12@@ -325,8 +326,12 @@
13 g_error_free (error);
14 }
15
16- // play a ringtone
17- Ringtone::instance()->playIncomingCallSound();
18+ if (CallManager::instance()->hasCalls()) {
19+ ToneGenerator::instance()->playWaitingTone();
20+ } else {
21+ // play a ringtone
22+ Ringtone::instance()->playIncomingCallSound();
23+ }
24
25 if (!CallManager::instance()->hasCalls() && GreeterContacts::instance()->incomingCallVibrate()) {
26 mVibrateEffect.setDuration(2000);
27@@ -531,6 +536,7 @@
28 }
29
30 Ringtone::instance()->stopIncomingCallSound();
31+ ToneGenerator::instance()->stopWaitingTone();
32 mVibrateTimer.stop();
33 // WORKAROUND: the ubuntu qt sensors backend does not support setPeriod() and stop(),
34 // so we invoke a short vibration to simulate a stop() call
35
36=== modified file 'handler/callhandler.cpp'
37--- handler/callhandler.cpp 2014-09-05 19:02:25 +0000
38+++ handler/callhandler.cpp 2014-10-16 17:05:00 +0000
39@@ -319,6 +319,10 @@
40 }
41
42 mCallChannels.removeAll(channel);
43+
44+ if (mCallChannels.isEmpty()) {
45+ ToneGenerator::instance()->playCallEndedTone();
46+ }
47 }
48
49 void CallHandler::onCallStateChanged(Tp::CallState state)
50
51=== modified file 'libtelephonyservice/tonegenerator.cpp'
52--- libtelephonyservice/tonegenerator.cpp 2014-08-01 07:54:22 +0000
53+++ libtelephonyservice/tonegenerator.cpp 2014-10-16 17:05:00 +0000
54@@ -33,15 +33,17 @@
55 #define TONEGEN_DBUS_IFACE_NAME TONEGEN_DBUS_SERVICE_NAME
56
57 ToneGenerator::ToneGenerator(QObject *parent) :
58- QObject(parent), mPlaybackTimer(nullptr)
59+ QObject(parent), mDTMFPlaybackTimer(nullptr), mWaitingPlaybackTimer(new QTimer(this))
60 {
61+ // the waiting tone is played in loop
62+ connect(mWaitingPlaybackTimer, SIGNAL(timeout()), this, SLOT(playWaitingTone()));
63+ mWaitingPlaybackTimer->setSingleShot(true);
64 }
65
66 ToneGenerator::~ToneGenerator()
67 {
68- if (mPlaybackTimer && mPlaybackTimer->isActive()) {
69- this->stopDTMFTone();
70- }
71+ this->stopDTMFTone();
72+ this->stopWaitingTone();
73 }
74
75 ToneGenerator *ToneGenerator::instance()
76@@ -50,21 +52,8 @@
77 return self;
78 }
79
80-void ToneGenerator::playDTMFTone(uint key)
81+bool ToneGenerator::startEventTone(uint key)
82 {
83- if (!mPlaybackTimer) {
84- mPlaybackTimer = new QTimer(this);
85- mPlaybackTimer->setSingleShot(true);
86- connect(mPlaybackTimer, SIGNAL(timeout()), this, SLOT(stopDTMFTone()));
87- }
88- if (mPlaybackTimer->isActive()) {
89- qDebug() << "Already playing a tone, ignore.";
90- return;
91- }
92- if (key > 11) {
93- qDebug() << "Invalid DTMF tone, ignore.";
94- return;
95- }
96 QDBusMessage startMsg = QDBusMessage::createMethodCall(
97 TONEGEN_DBUS_SERVICE_NAME,
98 TONEGEN_DBUS_OBJ_PATH,
99@@ -75,12 +64,30 @@
100 toneArgs << QVariant((int)0); // volume is ignored
101 toneArgs << QVariant((uint)0); // duration is ignored
102 startMsg.setArguments(toneArgs);
103- if (QDBusConnection::sessionBus().send(startMsg)) {
104- mPlaybackTimer->start(DTMF_LOCAL_PLAYBACK_DURATION);
105- }
106-}
107-
108-void ToneGenerator::stopDTMFTone()
109+ return QDBusConnection::sessionBus().send(startMsg);
110+}
111+
112+void ToneGenerator::playDTMFTone(uint key)
113+{
114+ if (!mDTMFPlaybackTimer) {
115+ mDTMFPlaybackTimer = new QTimer(this);
116+ mDTMFPlaybackTimer->setSingleShot(true);
117+ connect(mDTMFPlaybackTimer, SIGNAL(timeout()), this, SLOT(stopDTMFTone()));
118+ }
119+ if (mDTMFPlaybackTimer->isActive()) {
120+ qDebug() << "Already playing a tone, ignore.";
121+ return;
122+ }
123+ if (key > 11) {
124+ qDebug() << "Invalid DTMF tone, ignore.";
125+ return;
126+ }
127+ if (startEventTone(key)) {
128+ mDTMFPlaybackTimer->start(DTMF_LOCAL_PLAYBACK_DURATION);
129+ }
130+}
131+
132+void ToneGenerator::stopTone()
133 {
134 QDBusConnection::sessionBus().send(
135 QDBusMessage::createMethodCall(
136@@ -88,7 +95,36 @@
137 TONEGEN_DBUS_OBJ_PATH,
138 TONEGEN_DBUS_IFACE_NAME,
139 "StopTone" ));
140- if (mPlaybackTimer) {
141- mPlaybackTimer->stop();
142- }
143+}
144+
145+void ToneGenerator::stopDTMFTone()
146+{
147+ stopTone();
148+ if (mDTMFPlaybackTimer) {
149+ mDTMFPlaybackTimer->stop();
150+ }
151+
152+}
153+
154+void ToneGenerator::playWaitingTone()
155+{
156+ if (mWaitingPlaybackTimer->isActive()) {
157+ stopTone();
158+ }
159+
160+ if (startEventTone((uint)79)) {
161+ mWaitingPlaybackTimer->start(WAITING_PLAYBACK_DURATION);
162+ }
163+}
164+
165+void ToneGenerator::stopWaitingTone()
166+{
167+ stopTone();
168+ mWaitingPlaybackTimer->stop();
169+}
170+
171+void ToneGenerator::playCallEndedTone()
172+{
173+ startEventTone((uint)257);
174+ QTimer::singleShot(2000, this, SLOT(stopTone()));
175 }
176
177=== modified file 'libtelephonyservice/tonegenerator.h'
178--- libtelephonyservice/tonegenerator.h 2014-07-26 10:06:37 +0000
179+++ libtelephonyservice/tonegenerator.h 2014-10-16 17:05:00 +0000
180@@ -28,6 +28,7 @@
181 class QTimer;
182
183 static const int DTMF_LOCAL_PLAYBACK_DURATION = 200; /* in milliseconds */
184+static const int WAITING_PLAYBACK_DURATION = 8000; /* in milliseconds */
185
186 class ToneGenerator : public QObject
187 {
188@@ -41,13 +42,19 @@
189 * Valid tones: 0..9 (number keys), 10 (*), 11 (#)
190 */
191 void playDTMFTone(uint key);
192+ void playWaitingTone();
193+ void stopWaitingTone();
194+ void playCallEndedTone();
195
196 private Q_SLOTS:
197+ void stopTone();
198 void stopDTMFTone();
199+ bool startEventTone(uint key);
200
201 private:
202 explicit ToneGenerator(QObject *parent = 0);
203- QTimer* mPlaybackTimer;
204+ QTimer* mDTMFPlaybackTimer;
205+ QTimer* mWaitingPlaybackTimer;
206 };
207
208 #endif // TONEGENERATOR_H

Subscribers

People subscribed via source and target branches