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
1=== modified file 'handler/Handler.xml'
2--- handler/Handler.xml 2015-11-17 17:23:54 +0000
3+++ handler/Handler.xml 2015-12-14 16:55:11 +0000
4@@ -19,6 +19,7 @@
5 <arg name="recipients" type="as" direction="in"/>
6 <arg name="message" type="s" direction="in"/>
7 <arg name="attachments" type="a(sss)" direction="in"/>
8+ <arg name="accountIdOut" type="s" direction="out"/>
9 <annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="AttachmentList"/>
10 <arg name="properties" type="a{sv}" direction="in"/>
11 <annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QVariantMap"/>
12
13=== modified file 'handler/handlerdbus.cpp'
14--- handler/handlerdbus.cpp 2015-11-17 17:23:54 +0000
15+++ handler/handlerdbus.cpp 2015-12-14 16:55:11 +0000
16@@ -93,9 +93,9 @@
17 return true;
18 }
19
20-void HandlerDBus::SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)
21+QString HandlerDBus::SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)
22 {
23- TextHandler::instance()->sendMessage(accountId, recipients, message, attachments, properties);
24+ return TextHandler::instance()->sendMessage(accountId, recipients, message, attachments, properties);
25 }
26
27 void HandlerDBus::AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId)
28
29=== modified file 'handler/handlerdbus.h'
30--- handler/handlerdbus.h 2015-11-17 17:23:54 +0000
31+++ handler/handlerdbus.h 2015-12-14 16:55:11 +0000
32@@ -55,7 +55,7 @@
33 bool connectToBus();
34
35 // messages related
36- Q_NOREPLY void SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties);
37+ QString SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties);
38 Q_NOREPLY void AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId);
39 Q_NOREPLY void StartChat(const QString &accountId, const QStringList &participants);
40 Q_NOREPLY void StartChatRoom(const QString &accountId, const QStringList &initialParticipants, const QVariantMap &properties);
41
42=== modified file 'handler/texthandler.cpp'
43--- handler/texthandler.cpp 2015-12-14 16:55:11 +0000
44+++ handler/texthandler.cpp 2015-12-14 16:55:11 +0000
45@@ -301,12 +301,12 @@
46 return message;
47 }
48
49-void TextHandler::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)
50+QString TextHandler::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)
51 {
52 AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId);
53 if (!account) {
54 // account does not exist
55- return;
56+ return QString();
57 }
58
59 // check if the message should be sent via multimedia account
60@@ -360,19 +360,21 @@
61
62 if (!account->connected()) {
63 mPendingMessages.append(pendingMessage);
64- return;
65+ return account->accountId();
66 }
67
68 QList<Tp::TextChannelPtr> channels = existingChannels(recipients, account->accountId());
69 if (channels.isEmpty()) {
70 mPendingMessages.append(pendingMessage);
71 startChat(sortedRecipients, account->accountId());
72- return;
73+ return account->accountId();
74 }
75
76 connect(channels.last()->send(buildMessage(pendingMessage)),
77 SIGNAL(finished(Tp::PendingOperation*)),
78 SLOT(onMessageSent(Tp::PendingOperation*)));
79+
80+ return account->accountId();
81 }
82
83 void TextHandler::acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId)
84
85=== modified file 'handler/texthandler.h'
86--- handler/texthandler.h 2015-12-14 16:55:11 +0000
87+++ handler/texthandler.h 2015-12-14 16:55:11 +0000
88@@ -47,7 +47,7 @@
89 void startChat(const Tp::AccountPtr &account, const Tp::Contacts &contacts);
90
91 public Q_SLOTS:
92- void sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties);
93+ QString sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties);
94 void acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId);
95 void acknowledgeAllMessages(const QStringList &recipients, const QString &accountId);
96
97
98=== modified file 'libtelephonyservice/chatmanager.cpp'
99--- libtelephonyservice/chatmanager.cpp 2015-11-17 17:23:54 +0000
100+++ libtelephonyservice/chatmanager.cpp 2015-12-14 16:55:11 +0000
101@@ -95,12 +95,12 @@
102 return manager;
103 }
104
105-void ChatManager::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments, const QVariantMap &properties)
106+QString ChatManager::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments, const QVariantMap &properties)
107 {
108 AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId);
109
110 if (!account) {
111- return;
112+ return QString();
113 }
114
115 // check if files should be copied to a temporary location before passing them to handler
116@@ -121,16 +121,16 @@
117 tmpFile.setAutoRemove(false);
118 if (!tmpFile.open()) {
119 qWarning() << "Unable to create a temporary file";
120- return;
121+ return QString();
122 }
123 QFile originalFile(list.at(2).toString());
124 if (!originalFile.open(QIODevice::ReadOnly)) {
125 qWarning() << "Attachment file not found";
126- return;
127+ return QString();
128 }
129 if (tmpFile.write(originalFile.readAll()) == -1) {
130 qWarning() << "Failed to write attachment to a temporary file";
131- return;
132+ return QString();
133 }
134 newAttachment.filePath = tmpFile.fileName();
135 tmpFile.close();
136@@ -142,7 +142,11 @@
137 }
138
139 QDBusInterface *phoneAppHandler = TelepathyHelper::instance()->handlerInterface();
140- phoneAppHandler->call("SendMessage", account->accountId(), recipients, message, QVariant::fromValue(newAttachments), properties);
141+ QDBusReply<QString> reply = phoneAppHandler->call("SendMessage", account->accountId(), recipients, message, QVariant::fromValue(newAttachments), properties);
142+ if (reply.isValid()) {
143+ return reply.value();
144+ }
145+ return QString();
146 }
147
148 void ChatManager::onTextChannelAvailable(Tp::TextChannelPtr channel)
149
150=== modified file 'libtelephonyservice/chatmanager.h'
151--- libtelephonyservice/chatmanager.h 2015-11-17 17:23:54 +0000
152+++ libtelephonyservice/chatmanager.h 2015-12-14 16:55:11 +0000
153@@ -39,7 +39,7 @@
154 public:
155 static ChatManager *instance();
156
157- Q_INVOKABLE void sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments = QVariant(), const QVariantMap &properties = QVariantMap());
158+ Q_INVOKABLE QString sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments = QVariant(), const QVariantMap &properties = QVariantMap());
159 Q_INVOKABLE ChatEntry *chatEntryForParticipants(const QString &accountId, const QStringList &participants, bool create = false);
160 Q_INVOKABLE ChatEntry *chatEntryForChatRoom(const QString &accountId, const QVariantMap &properties, bool create);
161
162
163=== modified file 'tests/handler/HandlerTest.cpp'
164--- tests/handler/HandlerTest.cpp 2015-12-14 16:55:11 +0000
165+++ tests/handler/HandlerTest.cpp 2015-12-14 16:55:11 +0000
166@@ -454,7 +454,8 @@
167 QSignalSpy messageSentOfonoSpy(mOfonoMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
168 QSignalSpy messageSentMultimediaSpy(mMultimediaMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
169
170- HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message);
171+ QString accountId = HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message);
172+ QCOMPARE(accountId, mMultimediaTpAccount->uniqueIdentifier());
173 TRY_COMPARE(messageSentMultimediaSpy.count(), 1);
174 QCOMPARE(messageSentOfonoSpy.count(), 0);
175 QString sentMessage = messageSentMultimediaSpy.first().first().toString();
176
177=== modified file 'tests/handler/handlercontroller.cpp'
178--- tests/handler/handlercontroller.cpp 2015-12-14 16:55:11 +0000
179+++ tests/handler/handlercontroller.cpp 2015-12-14 16:55:11 +0000
180@@ -129,9 +129,13 @@
181 mHandlerInterface.call("SplitCall", objectPath);
182 }
183
184-void HandlerController::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)
185+QString HandlerController::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties)
186 {
187- mHandlerInterface.call("SendMessage", accountId, recipients, message, QVariant::fromValue(attachments), properties);
188+ QDBusReply<QString> reply = mHandlerInterface.call("SendMessage", accountId, recipients, message, QVariant::fromValue(attachments), properties);
189+ if (reply.isValid()) {
190+ return reply.value();
191+ }
192+ return QString();
193 }
194
195 void HandlerController::acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId)
196
197=== modified file 'tests/handler/handlercontroller.h'
198--- tests/handler/handlercontroller.h 2015-12-14 16:55:11 +0000
199+++ tests/handler/handlercontroller.h 2015-12-14 16:55:11 +0000
200@@ -51,7 +51,7 @@
201 void splitCall(const QString &objectPath);
202
203 // messaging methods
204- void sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments = AttachmentList(), const QVariantMap &properties = QVariantMap());
205+ QString sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments = AttachmentList(), const QVariantMap &properties = QVariantMap());
206 void acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId);
207
208 // active call indicator

Subscribers

People subscribed via source and target branches

to all changes: