Merge lp:~phablet-team/telephony-service/return_fallback_accountId into lp:telephony-service

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 1155
Merged at revision: 1165
Proposed branch: lp:~phablet-team/telephony-service/return_fallback_accountId
Merge into: lp:telephony-service
Prerequisite: lp:~phablet-team/telephony-service/mms_video_support
Diff against target: 208 lines (+31/-19)
10 files modified
handler/Handler.xml (+1/-0)
handler/handlerdbus.cpp (+2/-2)
handler/handlerdbus.h (+1/-1)
handler/texthandler.cpp (+6/-4)
handler/texthandler.h (+1/-1)
libtelephonyservice/chatmanager.cpp (+10/-6)
libtelephonyservice/chatmanager.h (+1/-1)
tests/handler/HandlerTest.cpp (+2/-1)
tests/handler/handlercontroller.cpp (+6/-2)
tests/handler/handlercontroller.h (+1/-1)
To merge this branch: bzr merge lp:~phablet-team/telephony-service/return_fallback_accountId
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+280477@code.launchpad.net

Commit message

Make sendMessage() return the actual accountId used to send the message.

Description of the change

Make sendMessage() return the actual accountId used to send the message.

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
Gustavo Pichorim Boiko (boiko) wrote :

Looks good!

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 2015-11-17 17:23:54 +0000
+++ handler/Handler.xml 2015-12-14 16:55:11 +0000
@@ -19,6 +19,7 @@
19 <arg name="recipients" type="as" direction="in"/>19 <arg name="recipients" type="as" direction="in"/>
20 <arg name="message" type="s" direction="in"/>20 <arg name="message" type="s" direction="in"/>
21 <arg name="attachments" type="a(sss)" direction="in"/>21 <arg name="attachments" type="a(sss)" direction="in"/>
22 <arg name="accountIdOut" type="s" direction="out"/>
22 <annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="AttachmentList"/>23 <annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="AttachmentList"/>
23 <arg name="properties" type="a{sv}" direction="in"/>24 <arg name="properties" type="a{sv}" direction="in"/>
24 <annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QVariantMap"/>25 <annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QVariantMap"/>
2526
=== modified file 'handler/handlerdbus.cpp'
--- handler/handlerdbus.cpp 2015-11-17 17:23:54 +0000
+++ handler/handlerdbus.cpp 2015-12-14 16:55:11 +0000
@@ -93,9 +93,9 @@
93 return true;93 return true;
94}94}
9595
96void HandlerDBus::SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)96QString HandlerDBus::SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)
97{97{
98 TextHandler::instance()->sendMessage(accountId, recipients, message, attachments, properties);98 return TextHandler::instance()->sendMessage(accountId, recipients, message, attachments, properties);
99}99}
100100
101void HandlerDBus::AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId)101void HandlerDBus::AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId)
102102
=== modified file 'handler/handlerdbus.h'
--- handler/handlerdbus.h 2015-11-17 17:23:54 +0000
+++ handler/handlerdbus.h 2015-12-14 16:55:11 +0000
@@ -55,7 +55,7 @@
55 bool connectToBus();55 bool connectToBus();
5656
57 // messages related57 // messages related
58 Q_NOREPLY void SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties);58 QString SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties);
59 Q_NOREPLY void AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId);59 Q_NOREPLY void AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId);
60 Q_NOREPLY void StartChat(const QString &accountId, const QStringList &participants);60 Q_NOREPLY void StartChat(const QString &accountId, const QStringList &participants);
61 Q_NOREPLY void StartChatRoom(const QString &accountId, const QStringList &initialParticipants, const QVariantMap &properties);61 Q_NOREPLY void StartChatRoom(const QString &accountId, const QStringList &initialParticipants, const QVariantMap &properties);
6262
=== modified file 'handler/texthandler.cpp'
--- handler/texthandler.cpp 2015-12-14 16:55:11 +0000
+++ handler/texthandler.cpp 2015-12-14 16:55:11 +0000
@@ -301,12 +301,12 @@
301 return message;301 return message;
302}302}
303303
304void TextHandler::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)304QString TextHandler::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)
305{305{
306 AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId);306 AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId);
307 if (!account) {307 if (!account) {
308 // account does not exist308 // account does not exist
309 return;309 return QString();
310 }310 }
311311
312 // check if the message should be sent via multimedia account312 // check if the message should be sent via multimedia account
@@ -360,19 +360,21 @@
360360
361 if (!account->connected()) {361 if (!account->connected()) {
362 mPendingMessages.append(pendingMessage);362 mPendingMessages.append(pendingMessage);
363 return;363 return account->accountId();
364 }364 }
365365
366 QList<Tp::TextChannelPtr> channels = existingChannels(recipients, account->accountId());366 QList<Tp::TextChannelPtr> channels = existingChannels(recipients, account->accountId());
367 if (channels.isEmpty()) {367 if (channels.isEmpty()) {
368 mPendingMessages.append(pendingMessage);368 mPendingMessages.append(pendingMessage);
369 startChat(sortedRecipients, account->accountId());369 startChat(sortedRecipients, account->accountId());
370 return;370 return account->accountId();
371 }371 }
372372
373 connect(channels.last()->send(buildMessage(pendingMessage)),373 connect(channels.last()->send(buildMessage(pendingMessage)),
374 SIGNAL(finished(Tp::PendingOperation*)),374 SIGNAL(finished(Tp::PendingOperation*)),
375 SLOT(onMessageSent(Tp::PendingOperation*)));375 SLOT(onMessageSent(Tp::PendingOperation*)));
376
377 return account->accountId();
376}378}
377379
378void TextHandler::acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId)380void TextHandler::acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId)
379381
=== modified file 'handler/texthandler.h'
--- handler/texthandler.h 2015-12-14 16:55:11 +0000
+++ handler/texthandler.h 2015-12-14 16:55:11 +0000
@@ -47,7 +47,7 @@
47 void startChat(const Tp::AccountPtr &account, const Tp::Contacts &contacts);47 void startChat(const Tp::AccountPtr &account, const Tp::Contacts &contacts);
4848
49public Q_SLOTS:49public Q_SLOTS:
50 void sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties);50 QString sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties);
51 void acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId);51 void acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId);
52 void acknowledgeAllMessages(const QStringList &recipients, const QString &accountId);52 void acknowledgeAllMessages(const QStringList &recipients, const QString &accountId);
5353
5454
=== modified file 'libtelephonyservice/chatmanager.cpp'
--- libtelephonyservice/chatmanager.cpp 2015-11-17 17:23:54 +0000
+++ libtelephonyservice/chatmanager.cpp 2015-12-14 16:55:11 +0000
@@ -95,12 +95,12 @@
95 return manager;95 return manager;
96}96}
9797
98void ChatManager::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments, const QVariantMap &properties)98QString ChatManager::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments, const QVariantMap &properties)
99{99{
100 AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId);100 AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId);
101101
102 if (!account) {102 if (!account) {
103 return;103 return QString();
104 }104 }
105105
106 // check if files should be copied to a temporary location before passing them to handler106 // check if files should be copied to a temporary location before passing them to handler
@@ -121,16 +121,16 @@
121 tmpFile.setAutoRemove(false);121 tmpFile.setAutoRemove(false);
122 if (!tmpFile.open()) {122 if (!tmpFile.open()) {
123 qWarning() << "Unable to create a temporary file";123 qWarning() << "Unable to create a temporary file";
124 return;124 return QString();
125 }125 }
126 QFile originalFile(list.at(2).toString());126 QFile originalFile(list.at(2).toString());
127 if (!originalFile.open(QIODevice::ReadOnly)) {127 if (!originalFile.open(QIODevice::ReadOnly)) {
128 qWarning() << "Attachment file not found";128 qWarning() << "Attachment file not found";
129 return;129 return QString();
130 }130 }
131 if (tmpFile.write(originalFile.readAll()) == -1) {131 if (tmpFile.write(originalFile.readAll()) == -1) {
132 qWarning() << "Failed to write attachment to a temporary file";132 qWarning() << "Failed to write attachment to a temporary file";
133 return;133 return QString();
134 }134 }
135 newAttachment.filePath = tmpFile.fileName();135 newAttachment.filePath = tmpFile.fileName();
136 tmpFile.close();136 tmpFile.close();
@@ -142,7 +142,11 @@
142 }142 }
143143
144 QDBusInterface *phoneAppHandler = TelepathyHelper::instance()->handlerInterface();144 QDBusInterface *phoneAppHandler = TelepathyHelper::instance()->handlerInterface();
145 phoneAppHandler->call("SendMessage", account->accountId(), recipients, message, QVariant::fromValue(newAttachments), properties);145 QDBusReply<QString> reply = phoneAppHandler->call("SendMessage", account->accountId(), recipients, message, QVariant::fromValue(newAttachments), properties);
146 if (reply.isValid()) {
147 return reply.value();
148 }
149 return QString();
146}150}
147151
148void ChatManager::onTextChannelAvailable(Tp::TextChannelPtr channel)152void ChatManager::onTextChannelAvailable(Tp::TextChannelPtr channel)
149153
=== modified file 'libtelephonyservice/chatmanager.h'
--- libtelephonyservice/chatmanager.h 2015-11-17 17:23:54 +0000
+++ libtelephonyservice/chatmanager.h 2015-12-14 16:55:11 +0000
@@ -39,7 +39,7 @@
39public:39public:
40 static ChatManager *instance();40 static ChatManager *instance();
4141
42 Q_INVOKABLE void sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments = QVariant(), const QVariantMap &properties = QVariantMap());42 Q_INVOKABLE QString sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments = QVariant(), const QVariantMap &properties = QVariantMap());
43 Q_INVOKABLE ChatEntry *chatEntryForParticipants(const QString &accountId, const QStringList &participants, bool create = false);43 Q_INVOKABLE ChatEntry *chatEntryForParticipants(const QString &accountId, const QStringList &participants, bool create = false);
44 Q_INVOKABLE ChatEntry *chatEntryForChatRoom(const QString &accountId, const QVariantMap &properties, bool create);44 Q_INVOKABLE ChatEntry *chatEntryForChatRoom(const QString &accountId, const QVariantMap &properties, bool create);
4545
4646
=== modified file 'tests/handler/HandlerTest.cpp'
--- tests/handler/HandlerTest.cpp 2015-12-14 16:55:11 +0000
+++ tests/handler/HandlerTest.cpp 2015-12-14 16:55:11 +0000
@@ -454,7 +454,8 @@
454 QSignalSpy messageSentOfonoSpy(mOfonoMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));454 QSignalSpy messageSentOfonoSpy(mOfonoMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
455 QSignalSpy messageSentMultimediaSpy(mMultimediaMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));455 QSignalSpy messageSentMultimediaSpy(mMultimediaMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
456456
457 HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message);457 QString accountId = HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message);
458 QCOMPARE(accountId, mMultimediaTpAccount->uniqueIdentifier());
458 TRY_COMPARE(messageSentMultimediaSpy.count(), 1);459 TRY_COMPARE(messageSentMultimediaSpy.count(), 1);
459 QCOMPARE(messageSentOfonoSpy.count(), 0);460 QCOMPARE(messageSentOfonoSpy.count(), 0);
460 QString sentMessage = messageSentMultimediaSpy.first().first().toString();461 QString sentMessage = messageSentMultimediaSpy.first().first().toString();
461462
=== modified file 'tests/handler/handlercontroller.cpp'
--- tests/handler/handlercontroller.cpp 2015-12-14 16:55:11 +0000
+++ tests/handler/handlercontroller.cpp 2015-12-14 16:55:11 +0000
@@ -129,9 +129,13 @@
129 mHandlerInterface.call("SplitCall", objectPath);129 mHandlerInterface.call("SplitCall", objectPath);
130}130}
131131
132void HandlerController::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)132QString HandlerController::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)
133{133{
134 mHandlerInterface.call("SendMessage", accountId, recipients, message, QVariant::fromValue(attachments), properties);134 QDBusReply<QString> reply = mHandlerInterface.call("SendMessage", accountId, recipients, message, QVariant::fromValue(attachments), properties);
135 if (reply.isValid()) {
136 return reply.value();
137 }
138 return QString();
135}139}
136140
137void HandlerController::acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId)141void HandlerController::acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId)
138142
=== modified file 'tests/handler/handlercontroller.h'
--- tests/handler/handlercontroller.h 2015-12-14 16:55:11 +0000
+++ tests/handler/handlercontroller.h 2015-12-14 16:55:11 +0000
@@ -51,7 +51,7 @@
51 void splitCall(const QString &objectPath);51 void splitCall(const QString &objectPath);
5252
53 // messaging methods53 // messaging methods
54 void sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments = AttachmentList(), const QVariantMap &properties = QVariantMap());54 QString sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments = AttachmentList(), const QVariantMap &properties = QVariantMap());
55 void acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId);55 void acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId);
5656
57 // active call indicator57 // active call indicator

Subscribers

People subscribed via source and target branches

to all changes: