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
=== modified file 'handler/Handler.xml'
--- handler/Handler.xml 2015-01-19 21:14:26 +0000
+++ handler/Handler.xml 2015-09-21 19:32:25 +0000
@@ -44,6 +44,14 @@
44 <arg name="messageIds" type="as" direction="in"/>44 <arg name="messageIds" type="as" direction="in"/>
45 <arg name="accountId" type="s" direction="in"/>45 <arg name="accountId" type="s" direction="in"/>
46 </method>46 </method>
47 <method name="AcknowledgeAllMessages">
48 <dox:d><![CDATA[
49 Request all messages messages from the given numbers to be acknowledged
50 ]]></dox:d>
51 <arg name="numbers" type="as" direction="in"/>
52 <arg name="accountId" type="s" direction="in"/>
53 </method>
54
4755
48 <!-- Call Related -->56 <!-- Call Related -->
49 <method name="StartCall">57 <method name="StartCall">
5058
=== modified file 'handler/handlerdbus.cpp'
--- handler/handlerdbus.cpp 2015-01-19 21:14:26 +0000
+++ handler/handlerdbus.cpp 2015-09-21 19:32:25 +0000
@@ -114,6 +114,11 @@
114 TextHandler::instance()->acknowledgeMessages(numbers, messageIds, accountId);114 TextHandler::instance()->acknowledgeMessages(numbers, messageIds, accountId);
115}115}
116116
117void HandlerDBus::AcknowledgeAllMessages(const QStringList &numbers, const QString &accountId)
118{
119 TextHandler::instance()->acknowledgeAllMessages(numbers, accountId);
120}
121
117void HandlerDBus::StartCall(const QString &number, const QString &accountId)122void HandlerDBus::StartCall(const QString &number, const QString &accountId)
118{123{
119 CallHandler::instance()->startCall(number, accountId);124 CallHandler::instance()->startCall(number, accountId);
120125
=== modified file 'handler/handlerdbus.h'
--- handler/handlerdbus.h 2015-01-19 21:14:26 +0000
+++ handler/handlerdbus.h 2015-09-21 19:32:25 +0000
@@ -59,6 +59,7 @@
59 Q_NOREPLY void SendSilentMessage(const QStringList &number, const QString &message, const QString &accountId);59 Q_NOREPLY void SendSilentMessage(const QStringList &number, const QString &message, const QString &accountId);
60 Q_NOREPLY void SendMMS(const QStringList &numbers, const AttachmentList &attachments, const QString &accountId);60 Q_NOREPLY void SendMMS(const QStringList &numbers, const AttachmentList &attachments, const QString &accountId);
61 Q_NOREPLY void AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId);61 Q_NOREPLY void AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId);
62 Q_NOREPLY void AcknowledgeAllMessages(const QStringList &numbers, const QString &accountId);
6263
63 // call related64 // call related
64 Q_NOREPLY void StartCall(const QString &number, const QString &accountId);65 Q_NOREPLY void StartCall(const QString &number, const QString &accountId);
6566
=== modified file 'handler/texthandler.cpp'
--- handler/texthandler.cpp 2015-08-18 13:19:43 +0000
+++ handler/texthandler.cpp 2015-09-21 19:32:25 +0000
@@ -323,6 +323,18 @@
323 }323 }
324}324}
325325
326void TextHandler::acknowledgeAllMessages(const QStringList &recipients, const QString &accountId)
327{
328 QList<Tp::TextChannelPtr> channels = existingChannels(recipients, accountId);
329 if (channels.isEmpty()) {
330 return;
331 }
332
333 Q_FOREACH(const Tp::TextChannelPtr &channel, channels) {
334 channel->acknowledge(channel->messageQueue());
335 }
336}
337
326void TextHandler::onTextChannelAvailable(Tp::TextChannelPtr channel)338void TextHandler::onTextChannelAvailable(Tp::TextChannelPtr channel)
327{339{
328 AccountEntry *account = TelepathyHelper::instance()->accountForConnection(channel->connection());340 AccountEntry *account = TelepathyHelper::instance()->accountForConnection(channel->connection());
329341
=== modified file 'handler/texthandler.h'
--- handler/texthandler.h 2015-08-18 13:19:43 +0000
+++ handler/texthandler.h 2015-09-21 19:32:25 +0000
@@ -41,6 +41,7 @@
41 void sendSilentMessage(const QStringList &recipients, const QString &message, const QString &accountId);41 void sendSilentMessage(const QStringList &recipients, const QString &message, const QString &accountId);
42 void sendMMS(const QStringList &recipients, const AttachmentList &attachments, const QString &accountId);42 void sendMMS(const QStringList &recipients, const AttachmentList &attachments, const QString &accountId);
43 void acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId);43 void acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId);
44 void acknowledgeAllMessages(const QStringList &recipients, const QString &accountId);
4445
45protected Q_SLOTS:46protected Q_SLOTS:
46 void onTextChannelAvailable(Tp::TextChannelPtr channel);47 void onTextChannelAvailable(Tp::TextChannelPtr channel);
4748
=== modified file 'libtelephonyservice/chatmanager.cpp'
--- libtelephonyservice/chatmanager.cpp 2015-03-10 21:41:45 +0000
+++ libtelephonyservice/chatmanager.cpp 2015-09-21 19:32:25 +0000
@@ -204,6 +204,12 @@
204 mMessagesToAck[account->accountId()][recipients].append(messageId);204 mMessagesToAck[account->accountId()][recipients].append(messageId);
205}205}
206206
207void ChatManager::acknowledgeAllMessages(const QStringList &recipients, const QString &accountId)
208{
209 QDBusInterface *phoneAppHandler = TelepathyHelper::instance()->handlerInterface();
210 phoneAppHandler->asyncCall("AcknowledgeAllMessages", recipients, accountId);
211}
212
207void ChatManager::onAckTimerTriggered()213void ChatManager::onAckTimerTriggered()
208{214{
209 // ack all pending messages215 // ack all pending messages
210216
=== modified file 'libtelephonyservice/chatmanager.h'
--- libtelephonyservice/chatmanager.h 2015-03-10 22:03:10 +0000
+++ libtelephonyservice/chatmanager.h 2015-09-21 19:32:25 +0000
@@ -47,7 +47,8 @@
47 void onMessageReceived(const Tp::ReceivedMessage &message);47 void onMessageReceived(const Tp::ReceivedMessage &message);
48 void onMessageSent(const Tp::Message &sentMessage, const Tp::MessageSendingFlags flags, const QString &message);48 void onMessageSent(const Tp::Message &sentMessage, const Tp::MessageSendingFlags flags, const QString &message);
4949
50 void acknowledgeMessage(const QStringList &recipients, const QString &messageId, const QString &accountId = QString::null);50 void acknowledgeMessage(const QStringList &recipients, const QString &messageId, const QString &accountId);
51 void acknowledgeAllMessages(const QStringList &recipients, const QString &accountId);
5152
52protected Q_SLOTS:53protected Q_SLOTS:
53 void onAckTimerTriggered();54 void onAckTimerTriggered();
5455
=== modified file 'tests/handler/HandlerTest.cpp'
--- tests/handler/HandlerTest.cpp 2015-08-18 13:19:43 +0000
+++ tests/handler/HandlerTest.cpp 2015-09-21 19:32:25 +0000
@@ -42,6 +42,7 @@
42 void testConferenceCall();42 void testConferenceCall();
43 void testSendMessage();43 void testSendMessage();
44 void testAcknowledgeMessage();44 void testAcknowledgeMessage();
45 void testAcknowledgeAllMessages();
45 void testActiveCallIndicator();46 void testActiveCallIndicator();
46 void testNotApprovedChannels();47 void testNotApprovedChannels();
4748
@@ -319,6 +320,40 @@
319 QCOMPARE(messageReadSpy.first()[0].toString(), receivedMessageId);320 QCOMPARE(messageReadSpy.first()[0].toString(), receivedMessageId);
320}321}
321322
323void HandlerTest::testAcknowledgeAllMessages()
324{
325 // FIXME: we assume the observer is already registered from the test above
326 QString recipient("98437666");
327 QString recipient2("+554198437666");
328 QString message("Hello, world! %1");
329 int messageCount = 10;
330 QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantMap)));
331
332 // first send a message to a certain number so the handler request one channel
333 HandlerController::instance()->sendMessage(recipient, message, mTpAccount->uniqueIdentifier());
334 TRY_COMPARE(messageSentSpy.count(), 1);
335
336 QSignalSpy messageReceivedSpy(ChatManager::instance(), SIGNAL(messageReceived(QString,QString,QDateTime,QString,bool)));
337
338 // now receive some messages from a very similar number so CM creates another
339 // channel and the handler needs to deal with both
340 QVariantMap properties;
341 properties["Sender"] = recipient2;
342 properties["Recipients"] = (QStringList() << recipient2);
343 for (int i = 0; i < messageCount; ++i) {
344 mMockController->PlaceIncomingMessage(message.arg(QString::number(i)), properties);
345 }
346
347 TRY_COMPARE(messageReceivedSpy.count(), messageCount);
348
349 // then acknowledge the messages that arrived in the second channel and make sure handler
350 // does the right thing
351 QSignalSpy messageReadSpy(mMockController, SIGNAL(MessageRead(QString)));
352 ChatManager::instance()->acknowledgeAllMessages(properties["Recipients"].toStringList(), mTpAccount->uniqueIdentifier());
353
354 TRY_COMPARE(messageReadSpy.count(), messageCount);
355}
356
322void HandlerTest::testActiveCallIndicator()357void HandlerTest::testActiveCallIndicator()
323{358{
324 // start by making sure the property is false by default359 // start by making sure the property is false by default

Subscribers

People subscribed via source and target branches