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

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Bill Filler
Approved revision: 1121
Merged at revision: 1121
Proposed branch: lp:~boiko/telephony-service/remove_messages_from_menu
Merge into: lp:telephony-service
Diff against target: 165 lines (+70/-1)
8 files modified
handler/Handler.xml (+8/-0)
handler/handlerdbus.cpp (+5/-0)
handler/handlerdbus.h (+1/-0)
handler/texthandler.cpp (+12/-0)
handler/texthandler.h (+1/-0)
libtelephonyservice/chatmanager.cpp (+6/-0)
libtelephonyservice/chatmanager.h (+2/-1)
tests/handler/HandlerTest.cpp (+35/-0)
To merge this branch: bzr merge lp:~boiko/telephony-service/remove_messages_from_menu
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Tiago Salem Herrmann (community) Needs Fixing
Review via email: mp+270119@code.launchpad.net

Commit message

Make it possible to acknowledge all pending messages of a given conversation
at once.

Description of the change

Make it possible to acknowledge all pending messages of a given conversation
at once.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1120. By Gustavo Pichorim Boiko

Registering/unregistering the observers multiple times in the test is making it
fail. Leave it registered for now.

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

Just one small remark and one question.

review: Needs Fixing
1121. By Gustavo Pichorim Boiko

Make the ack call asynchronous and fix a typo.

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

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 2015-01-19 21:14:26 +0000
3+++ handler/Handler.xml 2015-09-21 19:32:25 +0000
4@@ -44,6 +44,14 @@
5 <arg name="messageIds" type="as" direction="in"/>
6 <arg name="accountId" type="s" direction="in"/>
7 </method>
8+ <method name="AcknowledgeAllMessages">
9+ <dox:d><![CDATA[
10+ Request all messages messages from the given numbers to be acknowledged
11+ ]]></dox:d>
12+ <arg name="numbers" type="as" direction="in"/>
13+ <arg name="accountId" type="s" direction="in"/>
14+ </method>
15+
16
17 <!-- Call Related -->
18 <method name="StartCall">
19
20=== modified file 'handler/handlerdbus.cpp'
21--- handler/handlerdbus.cpp 2015-01-19 21:14:26 +0000
22+++ handler/handlerdbus.cpp 2015-09-21 19:32:25 +0000
23@@ -114,6 +114,11 @@
24 TextHandler::instance()->acknowledgeMessages(numbers, messageIds, accountId);
25 }
26
27+void HandlerDBus::AcknowledgeAllMessages(const QStringList &numbers, const QString &accountId)
28+{
29+ TextHandler::instance()->acknowledgeAllMessages(numbers, accountId);
30+}
31+
32 void HandlerDBus::StartCall(const QString &number, const QString &accountId)
33 {
34 CallHandler::instance()->startCall(number, accountId);
35
36=== modified file 'handler/handlerdbus.h'
37--- handler/handlerdbus.h 2015-01-19 21:14:26 +0000
38+++ handler/handlerdbus.h 2015-09-21 19:32:25 +0000
39@@ -59,6 +59,7 @@
40 Q_NOREPLY void SendSilentMessage(const QStringList &number, const QString &message, const QString &accountId);
41 Q_NOREPLY void SendMMS(const QStringList &numbers, const AttachmentList &attachments, const QString &accountId);
42 Q_NOREPLY void AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId);
43+ Q_NOREPLY void AcknowledgeAllMessages(const QStringList &numbers, const QString &accountId);
44
45 // call related
46 Q_NOREPLY void StartCall(const QString &number, const QString &accountId);
47
48=== modified file 'handler/texthandler.cpp'
49--- handler/texthandler.cpp 2015-08-18 13:19:43 +0000
50+++ handler/texthandler.cpp 2015-09-21 19:32:25 +0000
51@@ -323,6 +323,18 @@
52 }
53 }
54
55+void TextHandler::acknowledgeAllMessages(const QStringList &recipients, const QString &accountId)
56+{
57+ QList<Tp::TextChannelPtr> channels = existingChannels(recipients, accountId);
58+ if (channels.isEmpty()) {
59+ return;
60+ }
61+
62+ Q_FOREACH(const Tp::TextChannelPtr &channel, channels) {
63+ channel->acknowledge(channel->messageQueue());
64+ }
65+}
66+
67 void TextHandler::onTextChannelAvailable(Tp::TextChannelPtr channel)
68 {
69 AccountEntry *account = TelepathyHelper::instance()->accountForConnection(channel->connection());
70
71=== modified file 'handler/texthandler.h'
72--- handler/texthandler.h 2015-08-18 13:19:43 +0000
73+++ handler/texthandler.h 2015-09-21 19:32:25 +0000
74@@ -41,6 +41,7 @@
75 void sendSilentMessage(const QStringList &recipients, const QString &message, const QString &accountId);
76 void sendMMS(const QStringList &recipients, const AttachmentList &attachments, const QString &accountId);
77 void acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId);
78+ void acknowledgeAllMessages(const QStringList &recipients, const QString &accountId);
79
80 protected Q_SLOTS:
81 void onTextChannelAvailable(Tp::TextChannelPtr channel);
82
83=== modified file 'libtelephonyservice/chatmanager.cpp'
84--- libtelephonyservice/chatmanager.cpp 2015-03-10 21:41:45 +0000
85+++ libtelephonyservice/chatmanager.cpp 2015-09-21 19:32:25 +0000
86@@ -204,6 +204,12 @@
87 mMessagesToAck[account->accountId()][recipients].append(messageId);
88 }
89
90+void ChatManager::acknowledgeAllMessages(const QStringList &recipients, const QString &accountId)
91+{
92+ QDBusInterface *phoneAppHandler = TelepathyHelper::instance()->handlerInterface();
93+ phoneAppHandler->asyncCall("AcknowledgeAllMessages", recipients, accountId);
94+}
95+
96 void ChatManager::onAckTimerTriggered()
97 {
98 // ack all pending messages
99
100=== modified file 'libtelephonyservice/chatmanager.h'
101--- libtelephonyservice/chatmanager.h 2015-03-10 22:03:10 +0000
102+++ libtelephonyservice/chatmanager.h 2015-09-21 19:32:25 +0000
103@@ -47,7 +47,8 @@
104 void onMessageReceived(const Tp::ReceivedMessage &message);
105 void onMessageSent(const Tp::Message &sentMessage, const Tp::MessageSendingFlags flags, const QString &message);
106
107- void acknowledgeMessage(const QStringList &recipients, const QString &messageId, const QString &accountId = QString::null);
108+ void acknowledgeMessage(const QStringList &recipients, const QString &messageId, const QString &accountId);
109+ void acknowledgeAllMessages(const QStringList &recipients, const QString &accountId);
110
111 protected Q_SLOTS:
112 void onAckTimerTriggered();
113
114=== modified file 'tests/handler/HandlerTest.cpp'
115--- tests/handler/HandlerTest.cpp 2015-08-18 13:19:43 +0000
116+++ tests/handler/HandlerTest.cpp 2015-09-21 19:32:25 +0000
117@@ -42,6 +42,7 @@
118 void testConferenceCall();
119 void testSendMessage();
120 void testAcknowledgeMessage();
121+ void testAcknowledgeAllMessages();
122 void testActiveCallIndicator();
123 void testNotApprovedChannels();
124
125@@ -319,6 +320,40 @@
126 QCOMPARE(messageReadSpy.first()[0].toString(), receivedMessageId);
127 }
128
129+void HandlerTest::testAcknowledgeAllMessages()
130+{
131+ // FIXME: we assume the observer is already registered from the test above
132+ QString recipient("98437666");
133+ QString recipient2("+554198437666");
134+ QString message("Hello, world! %1");
135+ int messageCount = 10;
136+ QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantMap)));
137+
138+ // first send a message to a certain number so the handler request one channel
139+ HandlerController::instance()->sendMessage(recipient, message, mTpAccount->uniqueIdentifier());
140+ TRY_COMPARE(messageSentSpy.count(), 1);
141+
142+ QSignalSpy messageReceivedSpy(ChatManager::instance(), SIGNAL(messageReceived(QString,QString,QDateTime,QString,bool)));
143+
144+ // now receive some messages from a very similar number so CM creates another
145+ // channel and the handler needs to deal with both
146+ QVariantMap properties;
147+ properties["Sender"] = recipient2;
148+ properties["Recipients"] = (QStringList() << recipient2);
149+ for (int i = 0; i < messageCount; ++i) {
150+ mMockController->PlaceIncomingMessage(message.arg(QString::number(i)), properties);
151+ }
152+
153+ TRY_COMPARE(messageReceivedSpy.count(), messageCount);
154+
155+ // then acknowledge the messages that arrived in the second channel and make sure handler
156+ // does the right thing
157+ QSignalSpy messageReadSpy(mMockController, SIGNAL(MessageRead(QString)));
158+ ChatManager::instance()->acknowledgeAllMessages(properties["Recipients"].toStringList(), mTpAccount->uniqueIdentifier());
159+
160+ TRY_COMPARE(messageReadSpy.count(), messageCount);
161+}
162+
163 void HandlerTest::testActiveCallIndicator()
164 {
165 // start by making sure the property is false by default

Subscribers

People subscribed via source and target branches