Merge lp:~boiko/telephony-service/protocol_background_and_overlay into lp:telephony-service
- protocol_background_and_overlay
- Merge into trunk
Proposed by
Gustavo Pichorim Boiko
Status: | Superseded |
---|---|
Proposed branch: | lp:~boiko/telephony-service/protocol_background_and_overlay |
Merge into: | lp:telephony-service |
Diff against target: |
930 lines (+293/-64) 24 files modified
handler/Handler.xml (+1/-0) handler/handlerdbus.cpp (+2/-2) handler/handlerdbus.h (+1/-1) handler/texthandler.cpp (+90/-20) handler/texthandler.h (+3/-2) libtelephonyservice/chatmanager.cpp (+10/-6) libtelephonyservice/chatmanager.h (+1/-1) libtelephonyservice/protocol.cpp (+23/-3) libtelephonyservice/protocol.h (+18/-1) protocols/multimedia.protocol (+0/-4) protocols/ofono.protocol (+1/-0) tests/common/mock/MockConnection.xml (+5/-2) tests/common/mock/connection.cpp (+1/-1) tests/common/mock/connection.h (+1/-1) tests/common/mock/mockconnectiondbus.cpp (+2/-2) tests/common/mock/mockconnectiondbus.h (+1/-1) tests/common/mock/textchannel.cpp (+19/-3) tests/common/mock/textchannel.h (+1/-1) tests/handler/HandlerTest.cpp (+81/-3) tests/handler/handlercontroller.cpp (+11/-2) tests/handler/handlercontroller.h (+2/-1) tests/libtelephonyservice/ChatManagerTest.cpp (+4/-4) tests/libtelephonyservice/ProtocolTest.cpp (+12/-3) tests/libtelephonyservice/testProtocols/foo.protocol (+3/-0) |
To merge this branch: | bzr merge lp:~boiko/telephony-service/protocol_background_and_overlay |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tiago Salem Herrmann (community) | Approve | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Review via email: mp+278643@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-12-09.
Commit message
Expose extra information about the protocols we support.
Description of the change
Expose extra information about the protocols we support.
To post a comment you must log in.
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 : | # |
Looks good.
review:
Approve
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote : | # |
Ops, actually, removing the multimedia.protocol file make lots of tests fail.
review:
Needs Fixing
- 1147. By Gustavo Pichorim Boiko
-
Re-add the multimedia protocol.
Revision history for this message
Tiago Salem Herrmann (tiagosh) : | # |
review:
Needs Fixing
- 1148. By Gustavo Pichorim Boiko
-
Rename property.
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote : | # |
looks good now.
Thanks.
review:
Approve
- 1149. By Gustavo Pichorim Boiko
-
Merge parent branch
- 1150. By Gustavo Pichorim Boiko
-
Merge parent
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'assets/message_watermark.png' |
2 | Binary files assets/message_watermark.png 1970-01-01 00:00:00 +0000 and assets/message_watermark.png 2015-12-09 13:28:53 +0000 differ |
3 | === modified file 'handler/Handler.xml' |
4 | --- handler/Handler.xml 2015-11-17 17:23:54 +0000 |
5 | +++ handler/Handler.xml 2015-12-09 13:28:53 +0000 |
6 | @@ -19,6 +19,7 @@ |
7 | <arg name="recipients" type="as" direction="in"/> |
8 | <arg name="message" type="s" direction="in"/> |
9 | <arg name="attachments" type="a(sss)" direction="in"/> |
10 | + <arg name="accountIdOut" type="s" direction="out"/> |
11 | <annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="AttachmentList"/> |
12 | <arg name="properties" type="a{sv}" direction="in"/> |
13 | <annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QVariantMap"/> |
14 | |
15 | === modified file 'handler/handlerdbus.cpp' |
16 | --- handler/handlerdbus.cpp 2015-11-17 17:23:54 +0000 |
17 | +++ handler/handlerdbus.cpp 2015-12-09 13:28:53 +0000 |
18 | @@ -93,9 +93,9 @@ |
19 | return true; |
20 | } |
21 | |
22 | -void HandlerDBus::SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties) |
23 | +QString HandlerDBus::SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties) |
24 | { |
25 | - TextHandler::instance()->sendMessage(accountId, recipients, message, attachments, properties); |
26 | + return TextHandler::instance()->sendMessage(accountId, recipients, message, attachments, properties); |
27 | } |
28 | |
29 | void HandlerDBus::AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId) |
30 | |
31 | === modified file 'handler/handlerdbus.h' |
32 | --- handler/handlerdbus.h 2015-11-17 17:23:54 +0000 |
33 | +++ handler/handlerdbus.h 2015-12-09 13:28:53 +0000 |
34 | @@ -55,7 +55,7 @@ |
35 | bool connectToBus(); |
36 | |
37 | // messages related |
38 | - Q_NOREPLY void SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties); |
39 | + QString SendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties); |
40 | Q_NOREPLY void AcknowledgeMessages(const QStringList &numbers, const QStringList &messageIds, const QString &accountId); |
41 | Q_NOREPLY void StartChat(const QString &accountId, const QStringList &participants); |
42 | Q_NOREPLY void StartChatRoom(const QString &accountId, const QStringList &initialParticipants, const QVariantMap &properties); |
43 | |
44 | === modified file 'handler/texthandler.cpp' |
45 | --- handler/texthandler.cpp 2015-11-17 17:23:54 +0000 |
46 | +++ handler/texthandler.cpp 2015-12-09 13:28:53 +0000 |
47 | @@ -1,8 +1,9 @@ |
48 | /* |
49 | - * Copyright (C) 2012-2013 Canonical, Ltd. |
50 | + * Copyright (C) 2012-2015 Canonical, Ltd. |
51 | * |
52 | * Authors: |
53 | * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> |
54 | + * Tiago Salem Herrmann <tiago.herrmann@canonical.com> |
55 | * |
56 | * This file is part of telephony-service. |
57 | * |
58 | @@ -32,12 +33,20 @@ |
59 | |
60 | #define SMIL_TEXT_REGION "<region id=\"Text\" width=\"100%\" height=\"100%\" fit=\"scroll\" />" |
61 | #define SMIL_IMAGE_REGION "<region id=\"Image\" width=\"100%\" height=\"100%\" fit=\"meet\" />" |
62 | +#define SMIL_VIDEO_REGION "<region id=\"Video\" width=\"100%\" height=\"100%\" fit=\"meet\" />" |
63 | +#define SMIL_AUDIO_REGION "<region id=\"Audio\" width=\"100%\" height=\"100%\" fit=\"meet\" />" |
64 | #define SMIL_TEXT_PART "<par dur=\"3s\">\ |
65 | <text src=\"cid:%1\" region=\"Text\" />\ |
66 | </par>" |
67 | #define SMIL_IMAGE_PART "<par dur=\"5000ms\">\ |
68 | <img src=\"cid:%1\" region=\"Image\" />\ |
69 | </par>" |
70 | +#define SMIL_VIDEO_PART "<par>\ |
71 | + <video src=\"cid:%1\" region=\"Video\" />\ |
72 | + </par>" |
73 | +#define SMIL_AUDIO_PART "<par>\ |
74 | + <audio src=\"cid:%1\" region=\"Audio\" />\ |
75 | + </par>" |
76 | |
77 | #define SMIL_FILE "<smil>\ |
78 | <head>\ |
79 | @@ -139,7 +148,7 @@ |
80 | // start chatting to the contacts |
81 | Q_FOREACH(Tp::ContactPtr contact, contacts) { |
82 | // hold the ContactPtr to make sure its refcounting stays bigger than 0 |
83 | - mContacts[contact->id()] = contact; |
84 | + mContacts[account->uniqueIdentifier()][contact->id()] = contact; |
85 | } |
86 | } |
87 | |
88 | @@ -148,7 +157,7 @@ |
89 | Tp::MessagePartList message; |
90 | Tp::MessagePart header; |
91 | QString smil, regions, parts; |
92 | - bool hasImage = false, hasText = false, isMMS = false; |
93 | + bool hasImage = false, hasText = false, hasVideo = false, hasAudio = false, isMMS = false; |
94 | |
95 | AccountEntry *account = TelepathyHelper::instance()->accountForId(pendingMessage.accountId); |
96 | if (!account) { |
97 | @@ -207,6 +216,16 @@ |
98 | fileData = attachmentFile.readAll(); |
99 | } |
100 | } |
101 | + } else if (attachment.contentType.startsWith("video/")) { |
102 | + if (isMMS) { |
103 | + hasVideo = true; |
104 | + parts += QString(SMIL_VIDEO_PART).arg(attachment.id); |
105 | + } |
106 | + } else if (attachment.contentType.startsWith("audio/")) { |
107 | + if (isMMS) { |
108 | + hasAudio = true; |
109 | + parts += QString(SMIL_AUDIO_PART).arg(attachment.id); |
110 | + } |
111 | } else if (attachment.contentType.startsWith("text/plain")) { |
112 | if (isMMS) { |
113 | hasText = true; |
114 | @@ -230,6 +249,14 @@ |
115 | attachmentFile.remove(); |
116 | } |
117 | |
118 | + if (hasVideo) { |
119 | + regions += QString(SMIL_VIDEO_REGION); |
120 | + } |
121 | + |
122 | + if (hasAudio) { |
123 | + regions += QString(SMIL_AUDIO_REGION); |
124 | + } |
125 | + |
126 | if (hasText) { |
127 | regions += QString(SMIL_TEXT_REGION); |
128 | } |
129 | @@ -274,28 +301,54 @@ |
130 | return message; |
131 | } |
132 | |
133 | -void TextHandler::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties) |
134 | +QString TextHandler::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties) |
135 | { |
136 | AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId); |
137 | if (!account) { |
138 | // account does not exist |
139 | - return; |
140 | + return QString(); |
141 | } |
142 | |
143 | // check if the message should be sent via multimedia account |
144 | - if (account->type() == AccountEntry::PhoneAccount) { |
145 | - // we just use fallback to 1-1 chats |
146 | - if (recipients.size() == 1) { |
147 | - |
148 | - Q_FOREACH(AccountEntry *newAccount, TelepathyHelper::instance()->accounts()) { |
149 | - // TODO: we have to find the multimedia account that matches the same phone number, |
150 | - // but for now we just pick any multimedia connected account |
151 | - if (newAccount->type() == AccountEntry::MultimediaAccount) { |
152 | - if (newAccount->connected()) { |
153 | - account = newAccount; |
154 | - break; |
155 | - } |
156 | - } |
157 | + // we just use fallback to 1-1 chats |
158 | + if (account->type() == AccountEntry::PhoneAccount && recipients.size() == 1) { |
159 | + Q_FOREACH(AccountEntry *newAccount, TelepathyHelper::instance()->accounts()) { |
160 | + // TODO: we have to find the multimedia account that matches the same phone number, |
161 | + // but for now we just pick any multimedia connected account |
162 | + if (newAccount->type() != AccountEntry::MultimediaAccount) { |
163 | + continue; |
164 | + } |
165 | + // FIXME: the fallback implementation needs to be changed to use protocol info and create a map of |
166 | + // accounts. Also, it needs to check connection capabilities to determine if we can send message |
167 | + // to offline contacts. |
168 | + bool shouldFallback = false; |
169 | + // if the account is offline, dont fallback to this account |
170 | + if (!newAccount->connected()) { |
171 | + continue; |
172 | + } |
173 | + QList<Tp::TextChannelPtr> channels = existingChannels(recipients, newAccount->accountId()); |
174 | + // check if we have a channel for this contact already and get the contact pointer from there, |
175 | + // this way we avoid doing the while(op->isFinished()) all the time |
176 | + if (!channels.isEmpty()) { |
177 | + // if the contact is known, force fallback to this account |
178 | + Tp::Presence presence = channels.first()->targetContact()->presence(); |
179 | + shouldFallback = (presence.type() == Tp::ConnectionPresenceTypeAvailable || |
180 | + presence.type() == Tp::ConnectionPresenceTypeOffline); |
181 | + } else { |
182 | + Tp::PendingOperation *op = newAccount->account()->connection()->contactManager()->contactsForIdentifiers(recipients); |
183 | + while (!op->isFinished()) { |
184 | + qApp->processEvents(); |
185 | + } |
186 | + Tp::PendingContacts *pc = qobject_cast<Tp::PendingContacts*>(op); |
187 | + if (pc) { |
188 | + Tp::Presence presence = pc->contacts().first()->presence(); |
189 | + shouldFallback = (presence.type() == Tp::ConnectionPresenceTypeAvailable || |
190 | + presence.type() == Tp::ConnectionPresenceTypeOffline); |
191 | + } |
192 | + } |
193 | + if (shouldFallback) { |
194 | + account = newAccount; |
195 | + break; |
196 | } |
197 | } |
198 | } |
199 | @@ -304,21 +357,24 @@ |
200 | QStringList sortedRecipients = recipients; |
201 | sortedRecipients.sort(); |
202 | PendingMessage pendingMessage = {account->accountId(), sortedRecipients, message, attachments, properties}; |
203 | + |
204 | if (!account->connected()) { |
205 | mPendingMessages.append(pendingMessage); |
206 | - return; |
207 | + return account->accountId(); |
208 | } |
209 | |
210 | QList<Tp::TextChannelPtr> channels = existingChannels(recipients, account->accountId()); |
211 | if (channels.isEmpty()) { |
212 | mPendingMessages.append(pendingMessage); |
213 | startChat(sortedRecipients, account->accountId()); |
214 | - return; |
215 | + return account->accountId(); |
216 | } |
217 | |
218 | connect(channels.last()->send(buildMessage(pendingMessage)), |
219 | SIGNAL(finished(Tp::PendingOperation*)), |
220 | SLOT(onMessageSent(Tp::PendingOperation*))); |
221 | + |
222 | + return account->accountId(); |
223 | } |
224 | |
225 | void TextHandler::acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId) |
226 | @@ -351,12 +407,26 @@ |
227 | } |
228 | } |
229 | |
230 | +void TextHandler::onTextChannelInvalidated() |
231 | +{ |
232 | + Tp::TextChannelPtr textChannel(qobject_cast<Tp::TextChannel*>(sender())); |
233 | + mChannels.removeAll(textChannel); |
234 | + AccountEntry *account = TelepathyHelper::instance()->accountForConnection(textChannel->connection()); |
235 | + if (account) { |
236 | + mContacts.remove(account->accountId()); |
237 | + } |
238 | +} |
239 | + |
240 | void TextHandler::onTextChannelAvailable(Tp::TextChannelPtr channel) |
241 | { |
242 | AccountEntry *account = TelepathyHelper::instance()->accountForConnection(channel->connection()); |
243 | if (!account) { |
244 | return; |
245 | } |
246 | + connect(channel.data(), |
247 | + SIGNAL(invalidated(Tp::DBusProxy*,const QString&, const QString&)), |
248 | + SLOT(onTextChannelInvalidated())); |
249 | + |
250 | QString accountId = account->accountId(); |
251 | mChannels.append(channel); |
252 | |
253 | |
254 | === modified file 'handler/texthandler.h' |
255 | --- handler/texthandler.h 2015-11-17 17:23:54 +0000 |
256 | +++ handler/texthandler.h 2015-12-09 13:28:53 +0000 |
257 | @@ -47,12 +47,13 @@ |
258 | void startChat(const Tp::AccountPtr &account, const Tp::Contacts &contacts); |
259 | |
260 | public Q_SLOTS: |
261 | - void sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties); |
262 | + QString sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties); |
263 | void acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId); |
264 | void acknowledgeAllMessages(const QStringList &recipients, const QString &accountId); |
265 | |
266 | protected Q_SLOTS: |
267 | void onTextChannelAvailable(Tp::TextChannelPtr channel); |
268 | + void onTextChannelInvalidated(); |
269 | void onContactsAvailable(Tp::PendingOperation *op); |
270 | void onMessageSent(Tp::PendingOperation *op); |
271 | void onConnectedChanged(); |
272 | @@ -65,7 +66,7 @@ |
273 | Tp::MessagePartList buildMessage(const PendingMessage &pendingMessage); |
274 | |
275 | QList<Tp::TextChannelPtr> mChannels; |
276 | - QMap<QString, Tp::ContactPtr> mContacts; |
277 | + QMap<QString, QMap<QString, Tp::ContactPtr> > mContacts; |
278 | QList<PendingMessage> mPendingMessages; |
279 | }; |
280 | |
281 | |
282 | === modified file 'libtelephonyservice/chatmanager.cpp' |
283 | --- libtelephonyservice/chatmanager.cpp 2015-11-17 17:23:54 +0000 |
284 | +++ libtelephonyservice/chatmanager.cpp 2015-12-09 13:28:53 +0000 |
285 | @@ -95,12 +95,12 @@ |
286 | return manager; |
287 | } |
288 | |
289 | -void ChatManager::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments, const QVariantMap &properties) |
290 | +QString ChatManager::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments, const QVariantMap &properties) |
291 | { |
292 | AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId); |
293 | |
294 | if (!account) { |
295 | - return; |
296 | + return QString(); |
297 | } |
298 | |
299 | // check if files should be copied to a temporary location before passing them to handler |
300 | @@ -121,16 +121,16 @@ |
301 | tmpFile.setAutoRemove(false); |
302 | if (!tmpFile.open()) { |
303 | qWarning() << "Unable to create a temporary file"; |
304 | - return; |
305 | + return QString(); |
306 | } |
307 | QFile originalFile(list.at(2).toString()); |
308 | if (!originalFile.open(QIODevice::ReadOnly)) { |
309 | qWarning() << "Attachment file not found"; |
310 | - return; |
311 | + return QString(); |
312 | } |
313 | if (tmpFile.write(originalFile.readAll()) == -1) { |
314 | qWarning() << "Failed to write attachment to a temporary file"; |
315 | - return; |
316 | + return QString(); |
317 | } |
318 | newAttachment.filePath = tmpFile.fileName(); |
319 | tmpFile.close(); |
320 | @@ -142,7 +142,11 @@ |
321 | } |
322 | |
323 | QDBusInterface *phoneAppHandler = TelepathyHelper::instance()->handlerInterface(); |
324 | - phoneAppHandler->call("SendMessage", account->accountId(), recipients, message, QVariant::fromValue(newAttachments), properties); |
325 | + QDBusReply<QString> reply = phoneAppHandler->call("SendMessage", account->accountId(), recipients, message, QVariant::fromValue(newAttachments), properties); |
326 | + if (reply.isValid()) { |
327 | + return reply.value(); |
328 | + } |
329 | + return QString(); |
330 | } |
331 | |
332 | void ChatManager::onTextChannelAvailable(Tp::TextChannelPtr channel) |
333 | |
334 | === modified file 'libtelephonyservice/chatmanager.h' |
335 | --- libtelephonyservice/chatmanager.h 2015-11-17 17:23:54 +0000 |
336 | +++ libtelephonyservice/chatmanager.h 2015-12-09 13:28:53 +0000 |
337 | @@ -39,7 +39,7 @@ |
338 | public: |
339 | static ChatManager *instance(); |
340 | |
341 | - Q_INVOKABLE void sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments = QVariant(), const QVariantMap &properties = QVariantMap()); |
342 | + Q_INVOKABLE QString sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const QVariant &attachments = QVariant(), const QVariantMap &properties = QVariantMap()); |
343 | Q_INVOKABLE ChatEntry *chatEntryForParticipants(const QString &accountId, const QStringList &participants, bool create = false); |
344 | Q_INVOKABLE ChatEntry *chatEntryForChatRoom(const QString &accountId, const QVariantMap &properties, bool create); |
345 | |
346 | |
347 | === modified file 'libtelephonyservice/protocol.cpp' |
348 | --- libtelephonyservice/protocol.cpp 2015-06-10 21:05:50 +0000 |
349 | +++ libtelephonyservice/protocol.cpp 2015-12-09 13:28:53 +0000 |
350 | @@ -3,6 +3,7 @@ |
351 | * |
352 | * Authors: |
353 | * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> |
354 | + * Tiago Salem Herrmann <tiago.herrmann@canonical.com> |
355 | * |
356 | * This file is part of telephony-service. |
357 | * |
358 | @@ -23,8 +24,8 @@ |
359 | #include <QFileInfo> |
360 | #include <QSettings> |
361 | |
362 | -Protocol::Protocol(const QString &name, Features features, const QString &fallbackProtocol, QObject *parent) |
363 | -: QObject(parent), mName(name), mFeatures(features), mFallbackProtocol(fallbackProtocol) |
364 | +Protocol::Protocol(const QString &name, Features features, const QString &fallbackProtocol, const QString &backgroundImage, const QString &icon, const QString &serviceName, QObject *parent) |
365 | +: QObject(parent), mName(name), mFeatures(features), mFallbackProtocol(fallbackProtocol), mBackgroundImage(backgroundImage), mIcon(icon), mServiceName(serviceName) |
366 | { |
367 | } |
368 | |
369 | @@ -33,6 +34,16 @@ |
370 | return mName; |
371 | } |
372 | |
373 | +QString Protocol::icon() const |
374 | +{ |
375 | + return mIcon; |
376 | +} |
377 | + |
378 | +QString Protocol::serviceName() const |
379 | +{ |
380 | + return mServiceName; |
381 | +} |
382 | + |
383 | Protocol::Features Protocol::features() const |
384 | { |
385 | return mFeatures; |
386 | @@ -43,6 +54,11 @@ |
387 | return mFallbackProtocol; |
388 | } |
389 | |
390 | +QString Protocol::backgroundImage() const |
391 | +{ |
392 | + return mBackgroundImage; |
393 | +} |
394 | + |
395 | Protocol *Protocol::fromFile(const QString &fileName) |
396 | { |
397 | QFileInfo file(fileName); |
398 | @@ -52,6 +68,7 @@ |
399 | |
400 | QString protocolName = file.baseName(); |
401 | QSettings settings(fileName, QSettings::IniFormat); |
402 | + settings.setIniCodec("UTF-8"); |
403 | settings.beginGroup("Protocol"); |
404 | QString name = settings.value("Name", protocolName).toString(); |
405 | QStringList featureList = settings.value("Features").toStringList(); |
406 | @@ -64,6 +81,9 @@ |
407 | } |
408 | } |
409 | QString fallbackProtocol = settings.value("FallbackProtocol").toString(); |
410 | + QString backgroundImage = settings.value("BackgroundImage").toString(); |
411 | + QString icon = settings.value("Icon").toString(); |
412 | + QString serviceName = settings.value("ServiceName").toString(); |
413 | |
414 | - return new Protocol(name, features, fallbackProtocol); |
415 | + return new Protocol(name, features, fallbackProtocol, backgroundImage, icon, serviceName); |
416 | } |
417 | |
418 | === modified file 'libtelephonyservice/protocol.h' |
419 | --- libtelephonyservice/protocol.h 2015-06-10 21:05:50 +0000 |
420 | +++ libtelephonyservice/protocol.h 2015-12-09 13:28:53 +0000 |
421 | @@ -3,6 +3,7 @@ |
422 | * |
423 | * Authors: |
424 | * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> |
425 | + * Tiago Salem Herrmann <tiago.herrmann@canonical.com> |
426 | * |
427 | * This file is part of telephony-service. |
428 | * |
429 | @@ -36,6 +37,16 @@ |
430 | |
431 | /// @brief the fallback protocol to be used for operations that support it (mainly text features) |
432 | Q_PROPERTY(QString fallbackProtocol READ fallbackProtocol CONSTANT) |
433 | + |
434 | + /// @brief the file path for the image that represents this protocol |
435 | + Q_PROPERTY(QString backgroundImage READ backgroundImage CONSTANT) |
436 | + |
437 | + /// @brief the file path for the image that represents this protocol |
438 | + Q_PROPERTY(QString icon READ icon CONSTANT) |
439 | + |
440 | + /// @brief the title that represents this protocol |
441 | + Q_PROPERTY(QString serviceName READ serviceName CONSTANT) |
442 | + |
443 | public: |
444 | enum Feature { |
445 | TextChats = 0x1, |
446 | @@ -46,18 +57,24 @@ |
447 | QString name() const; |
448 | Features features() const; |
449 | QString fallbackProtocol() const; |
450 | + QString backgroundImage() const; |
451 | + QString icon() const; |
452 | + QString serviceName() const; |
453 | |
454 | static Protocol *fromFile(const QString &fileName); |
455 | |
456 | friend class ProtocolManager; |
457 | |
458 | protected: |
459 | - explicit Protocol(const QString &name, Features features, const QString &fallbackProtocol = QString::null, QObject *parent = 0); |
460 | + explicit Protocol(const QString &name, Features features, const QString &fallbackProtocol = QString::null, const QString &backgroundImage = QString::null, const QString &icon = QString::null, const QString &serviceName = QString::null, QObject *parent = 0); |
461 | |
462 | private: |
463 | QString mName; |
464 | Features mFeatures; |
465 | QString mFallbackProtocol; |
466 | + QString mBackgroundImage; |
467 | + QString mIcon; |
468 | + QString mServiceName; |
469 | }; |
470 | |
471 | typedef QList<Protocol*> Protocols; |
472 | |
473 | === added file 'protocols/multimedia.protocol' |
474 | --- protocols/multimedia.protocol 1970-01-01 00:00:00 +0000 |
475 | +++ protocols/multimedia.protocol 2015-12-09 13:28:53 +0000 |
476 | @@ -0,0 +1,4 @@ |
477 | +[Protocol] |
478 | +Name=multimedia |
479 | +Features=text |
480 | +FallbackProtocol=ofono |
481 | |
482 | === removed file 'protocols/multimedia.protocol' |
483 | --- protocols/multimedia.protocol 2015-06-11 16:48:18 +0000 |
484 | +++ protocols/multimedia.protocol 1970-01-01 00:00:00 +0000 |
485 | @@ -1,4 +0,0 @@ |
486 | -[Protocol] |
487 | -Name=multimedia |
488 | -Features=text |
489 | -FallbackProtocol=ofono |
490 | |
491 | === modified file 'protocols/ofono.protocol' |
492 | --- protocols/ofono.protocol 2015-06-10 21:05:50 +0000 |
493 | +++ protocols/ofono.protocol 2015-12-09 13:28:53 +0000 |
494 | @@ -2,3 +2,4 @@ |
495 | Name=ofono |
496 | Features=text,voice |
497 | FallbackProtocol= |
498 | +BackgroundImage=/usr/share/telephony-service/assets/message_watermark.png |
499 | |
500 | === modified file 'tests/common/mock/MockConnection.xml' |
501 | --- tests/common/mock/MockConnection.xml 2015-11-17 17:23:54 +0000 |
502 | +++ tests/common/mock/MockConnection.xml 2015-12-09 13:28:53 +0000 |
503 | @@ -210,9 +210,12 @@ |
504 | A message was sent from the client. |
505 | ]]></dox:d> |
506 | <arg name="message" type="s"/> |
507 | + <arg name="attachments" type="av"/> |
508 | <arg name="properties" type="a{sv}"/> |
509 | - <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/> |
510 | - <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/> |
511 | + <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantList"/> |
512 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantList"/> |
513 | + <annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QVariantMap"/> |
514 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out2" value="QVariantMap"/> |
515 | </signal> |
516 | <signal name="CallReceived"> |
517 | <dox:d><![CDATA[ |
518 | |
519 | === modified file 'tests/common/mock/connection.cpp' |
520 | --- tests/common/mock/connection.cpp 2015-11-17 17:23:54 +0000 |
521 | +++ tests/common/mock/connection.cpp 2015-12-09 13:28:53 +0000 |
522 | @@ -371,7 +371,7 @@ |
523 | MockTextChannel *channel = new MockTextChannel(this, recipients, targetHandle); |
524 | QObject::connect(channel, SIGNAL(messageRead(QString)), SLOT(onMessageRead(QString))); |
525 | QObject::connect(channel, SIGNAL(destroyed()), SLOT(onTextChannelClosed())); |
526 | - QObject::connect(channel, SIGNAL(messageSent(QString,QVariantMap)), SIGNAL(messageSent(QString,QVariantMap))); |
527 | + QObject::connect(channel, SIGNAL(messageSent(QString,QVariantList,QVariantMap)), SIGNAL(messageSent(QString,QVariantList,QVariantMap))); |
528 | qDebug() << channel; |
529 | mTextChannels << channel; |
530 | return channel->baseChannel(); |
531 | |
532 | === modified file 'tests/common/mock/connection.h' |
533 | --- tests/common/mock/connection.h 2015-11-17 17:23:54 +0000 |
534 | +++ tests/common/mock/connection.h 2015-12-09 13:28:53 +0000 |
535 | @@ -110,7 +110,7 @@ |
536 | |
537 | Q_SIGNALS: |
538 | void messageRead(const QString &messageId); |
539 | - void messageSent(const QString &message, const QVariantMap &info); |
540 | + void messageSent(const QString &message, const QVariantList &attachments, const QVariantMap &info); |
541 | void callReceived(const QString &callerId); |
542 | void callEnded(const QString &callerId); |
543 | void callStateChanged(const QString &callerId, const QString &objectPath, const QString &state); |
544 | |
545 | === modified file 'tests/common/mock/mockconnectiondbus.cpp' |
546 | --- tests/common/mock/mockconnectiondbus.cpp 2015-11-17 17:23:54 +0000 |
547 | +++ tests/common/mock/mockconnectiondbus.cpp 2015-12-09 13:28:53 +0000 |
548 | @@ -32,8 +32,8 @@ |
549 | SIGNAL(messageRead(QString)), |
550 | SIGNAL(MessageRead(QString))); |
551 | connect(mConnection, |
552 | - SIGNAL(messageSent(QString,QVariantMap)), |
553 | - SIGNAL(MessageSent(QString,QVariantMap))); |
554 | + SIGNAL(messageSent(QString,QVariantList,QVariantMap)), |
555 | + SIGNAL(MessageSent(QString,QVariantList,QVariantMap))); |
556 | connect(mConnection, |
557 | SIGNAL(callReceived(QString)), |
558 | SIGNAL(CallReceived(QString))); |
559 | |
560 | === modified file 'tests/common/mock/mockconnectiondbus.h' |
561 | --- tests/common/mock/mockconnectiondbus.h 2015-11-17 17:23:54 +0000 |
562 | +++ tests/common/mock/mockconnectiondbus.h 2015-12-09 13:28:53 +0000 |
563 | @@ -71,7 +71,7 @@ |
564 | Q_SIGNALS: |
565 | // signals that will be relayed into the bus |
566 | void MessageRead(const QString &messageId); |
567 | - void MessageSent(const QString &mesasge, const QVariantMap &properties); |
568 | + void MessageSent(const QString &message, const QVariantList &attachments, const QVariantMap &properties); |
569 | void CallReceived(const QString &callerId); |
570 | void CallEnded(const QString &callerId); |
571 | void CallStateChanged(const QString &callerId, const QString &objectPath, const QString &state); |
572 | |
573 | === modified file 'tests/common/mock/textchannel.cpp' |
574 | --- tests/common/mock/textchannel.cpp 2015-11-17 14:30:19 +0000 |
575 | +++ tests/common/mock/textchannel.cpp 2015-12-09 13:28:53 +0000 |
576 | @@ -105,13 +105,12 @@ |
577 | QString MockTextChannel::sendMessage(const Tp::MessagePartList& message, uint flags, Tp::DBusError* error) |
578 | { |
579 | Tp::MessagePart header = message.at(0); |
580 | - Tp::MessagePart body = message.at(1); |
581 | |
582 | static int serial = 0; |
583 | |
584 | // FIXME: check what other data we need to emit in the signal |
585 | QString id = QString("sentmessage%1").arg(serial++); |
586 | - QString messageText = body["content"].variant().toString(); |
587 | + QString messageText; |
588 | QVariantMap properties; |
589 | QMap<QString, QDBusVariant>::const_iterator it = header.constBegin(); |
590 | while (it != header.constEnd()) { |
591 | @@ -122,7 +121,24 @@ |
592 | properties["Recipients"] = mRecipients; |
593 | properties["Id"] = id; |
594 | |
595 | - Q_EMIT messageSent(messageText, properties); |
596 | + QVariantList attachments; |
597 | + Tp::MessagePartList messageList = message; |
598 | + messageList.pop_front(); |
599 | + Q_FOREACH(const Tp::MessagePart& messagePart, messageList) { |
600 | + QVariantMap attachment; |
601 | + if (messagePart.contains("content-type") && messagePart["content-type"].variant().toString().startsWith("text/")) { |
602 | + messageText = messagePart["content"].variant().toString(); |
603 | + continue; |
604 | + } |
605 | + QMap<QString, QDBusVariant>::const_iterator it = messagePart.constBegin(); |
606 | + while (it != messagePart.constEnd()) { |
607 | + attachment[it.key()] = it.value().variant().toString(); |
608 | + it++; |
609 | + } |
610 | + attachments << attachment; |
611 | + } |
612 | + |
613 | + Q_EMIT messageSent(messageText, attachments, properties); |
614 | |
615 | QTimer *deliveryReportTimer = new QTimer(this); |
616 | deliveryReportTimer->setSingleShot(true); |
617 | |
618 | === modified file 'tests/common/mock/textchannel.h' |
619 | --- tests/common/mock/textchannel.h 2015-03-20 19:00:21 +0000 |
620 | +++ tests/common/mock/textchannel.h 2015-12-09 13:28:53 +0000 |
621 | @@ -54,7 +54,7 @@ |
622 | |
623 | Q_SIGNALS: |
624 | void messageRead(const QString &id); |
625 | - void messageSent(const QString &message, const QVariantMap &info); |
626 | + void messageSent(const QString &message, const QVariantList &attachments, const QVariantMap &info); |
627 | |
628 | private: |
629 | ~MockTextChannel(); |
630 | |
631 | === modified file 'tests/handler/HandlerTest.cpp' |
632 | --- tests/handler/HandlerTest.cpp 2015-10-09 16:13:30 +0000 |
633 | +++ tests/handler/HandlerTest.cpp 2015-12-09 13:28:53 +0000 |
634 | @@ -41,10 +41,12 @@ |
635 | void testCallProperties(); |
636 | void testConferenceCall(); |
637 | void testSendMessage(); |
638 | + void testSendMessageWithAttachments(); |
639 | void testAcknowledgeMessage(); |
640 | void testAcknowledgeAllMessages(); |
641 | void testActiveCallIndicator(); |
642 | void testNotApprovedChannels(); |
643 | + void testMultimediaFallback(); |
644 | |
645 | private: |
646 | void registerApprover(); |
647 | @@ -53,6 +55,11 @@ |
648 | Approver *mApprover; |
649 | MockController *mMockController; |
650 | Tp::AccountPtr mTpAccount; |
651 | + MockController *mMultimediaMockController; |
652 | + Tp::AccountPtr mMultimediaTpAccount; |
653 | + MockController *mOfonoMockController; |
654 | + Tp::AccountPtr mOfonoTpAccount; |
655 | + |
656 | }; |
657 | |
658 | void HandlerTest::initTestCase() |
659 | @@ -71,12 +78,20 @@ |
660 | |
661 | // and create the mock controller |
662 | mMockController = new MockController("mock", this); |
663 | + |
664 | + mOfonoTpAccount = addAccount("mock", "ofono", "the account"); |
665 | + mOfonoMockController = new MockController("ofono", this); |
666 | + |
667 | + mMultimediaTpAccount = addAccount("mock", "multimedia", "the account"); |
668 | + mMultimediaMockController = new MockController("multimedia", this); |
669 | } |
670 | |
671 | void HandlerTest::cleanup() |
672 | { |
673 | doCleanup(); |
674 | mMockController->deleteLater(); |
675 | + mMultimediaMockController->deleteLater(); |
676 | + mOfonoMockController->deleteLater(); |
677 | } |
678 | |
679 | void HandlerTest::testMakingCalls() |
680 | @@ -275,7 +290,7 @@ |
681 | { |
682 | QString recipient("22222222"); |
683 | QString message("Hello, world!"); |
684 | - QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantMap))); |
685 | + QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap))); |
686 | // FIXME: add support for multiple accounts |
687 | HandlerController::instance()->sendMessage(mTpAccount->uniqueIdentifier(), QStringList() << recipient, message); |
688 | TRY_COMPARE(messageSentSpy.count(), 1); |
689 | @@ -286,6 +301,31 @@ |
690 | QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient); |
691 | } |
692 | |
693 | +void HandlerTest::testSendMessageWithAttachments() |
694 | +{ |
695 | + QString recipient("22222222"); |
696 | + QString message("Hello, world!"); |
697 | + QSignalSpy messageSentSpy(mMultimediaMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap))); |
698 | + |
699 | + QTemporaryFile outputFile("audioXXXXXX.ogg"); |
700 | + outputFile.open(); |
701 | + AttachmentStruct attachment{"id", "audio/ogg", outputFile.fileName()}; |
702 | + HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message, AttachmentList() << attachment); |
703 | + TRY_COMPARE(messageSentSpy.count(), 1); |
704 | + outputFile.close(); |
705 | + |
706 | + QString sentMessage = messageSentSpy.first()[0].toString(); |
707 | + QVariantMap messageProperties = messageSentSpy.first()[2].value<QVariantMap>(); |
708 | + QCOMPARE(sentMessage, message); |
709 | + QCOMPARE(messageProperties["Recipients"].value<QStringList>().count(), 1); |
710 | + QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient); |
711 | + |
712 | + QVariantList messageAttachments = qdbus_cast<QVariantList>(messageSentSpy.first()[1]); |
713 | + QVariantMap firstAttachment = qdbus_cast<QVariantMap>(messageAttachments.first()); |
714 | + QCOMPARE(firstAttachment["content-type"].toString(), QString("audio/ogg")); |
715 | + QCOMPARE(firstAttachment["identifier"].toString(), QString("id")); |
716 | +} |
717 | + |
718 | void HandlerTest::testAcknowledgeMessage() |
719 | { |
720 | // if we register the observer before this test, other tests fail |
721 | @@ -293,7 +333,7 @@ |
722 | QString recipient("84376666"); |
723 | QString recipient2("+554184376666"); |
724 | QString message("Hello, world!"); |
725 | - QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantMap))); |
726 | + QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap))); |
727 | |
728 | // first send a message to a certain number so the handler request one channel |
729 | HandlerController::instance()->sendMessage(mTpAccount->uniqueIdentifier(), QStringList() << recipient, message); |
730 | @@ -327,7 +367,7 @@ |
731 | QString recipient2("+554198437666"); |
732 | QString message("Hello, world! %1"); |
733 | int messageCount = 10; |
734 | - QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantMap))); |
735 | + QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap))); |
736 | |
737 | // first send a message to a certain number so the handler request one channel |
738 | HandlerController::instance()->sendMessage(mTpAccount->uniqueIdentifier(), QStringList() << recipient, message); |
739 | @@ -403,6 +443,44 @@ |
740 | QCOMPARE(callStateSpy.last()[2].toString(), QString("initialised")); |
741 | } |
742 | |
743 | +void HandlerTest::testMultimediaFallback() |
744 | +{ |
745 | + QString recipient("22222222"); |
746 | + QString message("Hello, world!"); |
747 | + mMultimediaMockController->SetContactPresence(recipient, Tp::ConnectionPresenceTypeAvailable, "available", ""); |
748 | + // We have to make sure the handler already has the new state |
749 | + QTest::qWait(1000); |
750 | + |
751 | + QSignalSpy messageSentOfonoSpy(mOfonoMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap))); |
752 | + QSignalSpy messageSentMultimediaSpy(mMultimediaMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap))); |
753 | + |
754 | + QString accountId = HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message); |
755 | + QCOMPARE(accountId, mMultimediaTpAccount->uniqueIdentifier()); |
756 | + TRY_COMPARE(messageSentMultimediaSpy.count(), 1); |
757 | + QCOMPARE(messageSentOfonoSpy.count(), 0); |
758 | + QString sentMessage = messageSentMultimediaSpy.first().first().toString(); |
759 | + QVariantMap messageProperties = messageSentMultimediaSpy.first().last().value<QVariantMap>(); |
760 | + QCOMPARE(sentMessage, message); |
761 | + QCOMPARE(messageProperties["Recipients"].value<QStringList>().count(), 1); |
762 | + QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient); |
763 | + |
764 | + messageSentMultimediaSpy.clear(); |
765 | + messageSentOfonoSpy.clear(); |
766 | + |
767 | + mMultimediaMockController->SetContactPresence(recipient, Tp::ConnectionPresenceTypeUnknown, "offline", ""); |
768 | + // We have to make sure the handler already has the new state |
769 | + QTest::qWait(1000); |
770 | + HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message); |
771 | + TRY_COMPARE(messageSentOfonoSpy.count(), 1); |
772 | + QCOMPARE(messageSentMultimediaSpy.count(), 0); |
773 | + |
774 | + sentMessage = messageSentOfonoSpy.first().first().toString(); |
775 | + messageProperties = messageSentOfonoSpy.first().last().value<QVariantMap>(); |
776 | + QCOMPARE(sentMessage, message); |
777 | + QCOMPARE(messageProperties["Recipients"].value<QStringList>().count(), 1); |
778 | + QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient); |
779 | +} |
780 | + |
781 | void HandlerTest::registerApprover() |
782 | { |
783 | // register the approver |
784 | |
785 | === modified file 'tests/handler/handlercontroller.cpp' |
786 | --- tests/handler/handlercontroller.cpp 2015-08-09 03:49:08 +0000 |
787 | +++ tests/handler/handlercontroller.cpp 2015-12-09 13:28:53 +0000 |
788 | @@ -73,6 +73,11 @@ |
789 | return map["CallIndicatorVisible"].toBool(); |
790 | } |
791 | |
792 | +void HandlerController::startChat(const QString &accountId, const QStringList &recipients) |
793 | +{ |
794 | + mHandlerInterface.call("StartChat", accountId, recipients); |
795 | +} |
796 | + |
797 | void HandlerController::startCall(const QString &number, const QString &accountId) |
798 | { |
799 | mHandlerInterface.call("StartCall", number, accountId); |
800 | @@ -124,9 +129,13 @@ |
801 | mHandlerInterface.call("SplitCall", objectPath); |
802 | } |
803 | |
804 | -void HandlerController::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties) |
805 | +QString HandlerController::sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments, const QVariantMap &properties) |
806 | { |
807 | - mHandlerInterface.call("SendMessage", accountId, recipients, message, QVariant::fromValue(attachments), properties); |
808 | + QDBusReply<QString> reply = mHandlerInterface.call("SendMessage", accountId, recipients, message, QVariant::fromValue(attachments), properties); |
809 | + if (reply.isValid()) { |
810 | + return reply.value(); |
811 | + } |
812 | + return QString(); |
813 | } |
814 | |
815 | void HandlerController::acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId) |
816 | |
817 | === modified file 'tests/handler/handlercontroller.h' |
818 | --- tests/handler/handlercontroller.h 2015-08-09 03:49:08 +0000 |
819 | +++ tests/handler/handlercontroller.h 2015-12-09 13:28:53 +0000 |
820 | @@ -36,6 +36,7 @@ |
821 | |
822 | public Q_SLOTS: |
823 | // call methods |
824 | + void startChat(const QString &accountId, const QStringList &recipients); |
825 | void startCall(const QString &number, const QString &accountId); |
826 | void hangUpCall(const QString &objectPath); |
827 | void setHold(const QString &objectPath, bool hold); |
828 | @@ -50,7 +51,7 @@ |
829 | void splitCall(const QString &objectPath); |
830 | |
831 | // messaging methods |
832 | - void sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments = AttachmentList(), const QVariantMap &properties = QVariantMap()); |
833 | + QString sendMessage(const QString &accountId, const QStringList &recipients, const QString &message, const AttachmentList &attachments = AttachmentList(), const QVariantMap &properties = QVariantMap()); |
834 | void acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId); |
835 | |
836 | // active call indicator |
837 | |
838 | === modified file 'tests/libtelephonyservice/ChatManagerTest.cpp' |
839 | --- tests/libtelephonyservice/ChatManagerTest.cpp 2015-11-17 14:30:19 +0000 |
840 | +++ tests/libtelephonyservice/ChatManagerTest.cpp 2015-12-09 13:28:53 +0000 |
841 | @@ -101,14 +101,14 @@ |
842 | qSort(recipients); |
843 | |
844 | MockController *controller = accountId.startsWith("mock/mock") ? mGenericMockController : mPhoneMockController; |
845 | - QSignalSpy controllerMessageSentSpy(controller, SIGNAL(MessageSent(QString,QVariantMap))); |
846 | + QSignalSpy controllerMessageSentSpy(controller, SIGNAL(MessageSent(QString,QVariantList,QVariantMap))); |
847 | QSignalSpy messageSentSpy(ChatManager::instance(), SIGNAL(messageSent(QStringList,QString))); |
848 | |
849 | ChatManager::instance()->sendMessage(accountId, recipients, message); |
850 | |
851 | TRY_COMPARE(controllerMessageSentSpy.count(), 1); |
852 | QString messageText = controllerMessageSentSpy.first()[0].toString(); |
853 | - QVariantMap messageProperties = controllerMessageSentSpy.first()[1].toMap(); |
854 | + QVariantMap messageProperties = controllerMessageSentSpy.first()[2].toMap(); |
855 | QStringList messageRecipients = messageProperties["Recipients"].toStringList(); |
856 | qSort(messageRecipients); |
857 | QCOMPARE(messageText, message); |
858 | @@ -218,7 +218,7 @@ |
859 | |
860 | MockController *controller = accountId.startsWith("mock/mock") ? mGenericMockController : mPhoneMockController; |
861 | |
862 | - QSignalSpy controllerMessageSentSpy(controller, SIGNAL(MessageSent(QString,QVariantMap))); |
863 | + QSignalSpy controllerMessageSentSpy(controller, SIGNAL(MessageSent(QString,QVariantList,QVariantMap))); |
864 | |
865 | QVariantList attachmentList; |
866 | QVariantList attachment; |
867 | @@ -230,7 +230,7 @@ |
868 | |
869 | TRY_COMPARE(controllerMessageSentSpy.count(), 1); |
870 | QString messageText = controllerMessageSentSpy.first()[0].toString(); |
871 | - QVariantMap messageProperties = controllerMessageSentSpy.first()[1].toMap(); |
872 | + QVariantMap messageProperties = controllerMessageSentSpy.first()[2].toMap(); |
873 | QStringList messageRecipients = messageProperties["Recipients"].toStringList(); |
874 | qSort(messageRecipients); |
875 | QCOMPARE(messageText, message); |
876 | |
877 | === modified file 'tests/libtelephonyservice/ProtocolTest.cpp' |
878 | --- tests/libtelephonyservice/ProtocolTest.cpp 2015-06-10 22:04:22 +0000 |
879 | +++ tests/libtelephonyservice/ProtocolTest.cpp 2015-12-09 13:28:53 +0000 |
880 | @@ -27,8 +27,8 @@ |
881 | { |
882 | Q_OBJECT |
883 | public: |
884 | - TestProtocol(const QString &name, Protocol::Features features, const QString &fallbackProtocol, QObject *parent = 0) |
885 | - : Protocol(name, features, fallbackProtocol, parent) { } |
886 | + TestProtocol(const QString &name, Protocol::Features features, const QString &fallbackProtocol, const QString &backgroundFile, const QString &icon, const QString &serviceName = QString::null, QObject *parent = 0) |
887 | + : Protocol(name, features, fallbackProtocol, backgroundFile, icon, serviceName, parent) { } |
888 | }; |
889 | |
890 | class ProtocolTest : public QObject |
891 | @@ -45,11 +45,17 @@ |
892 | QString name("foobar"); |
893 | Protocol::Features features(Protocol::TextChats); |
894 | QString fallbackProtocol("theFallback"); |
895 | + QString backgroundImage("/tmp/background.png"); |
896 | + QString icon("/tmp/icon.png"); |
897 | + QString serviceName("The service"); |
898 | |
899 | - TestProtocol protocol(name, features, fallbackProtocol, this); |
900 | + TestProtocol protocol(name, features, fallbackProtocol, backgroundImage, icon, serviceName, this); |
901 | QCOMPARE(protocol.name(), name); |
902 | QCOMPARE(protocol.features(), features); |
903 | QCOMPARE(protocol.fallbackProtocol(), fallbackProtocol); |
904 | + QCOMPARE(protocol.backgroundImage(), backgroundImage); |
905 | + QCOMPARE(protocol.icon(), icon); |
906 | + QCOMPARE(protocol.serviceName(), serviceName); |
907 | QCOMPARE(protocol.parent(), this); |
908 | } |
909 | |
910 | @@ -65,6 +71,9 @@ |
911 | QCOMPARE(protocol->name(), QString("foo")); |
912 | QCOMPARE(protocol->features(), Protocol::Features(Protocol::TextChats | Protocol::VoiceCalls)); |
913 | QCOMPARE(protocol->fallbackProtocol(), QString("bar")); |
914 | + QCOMPARE(protocol->backgroundImage(), QString("/tmp/background.png")); |
915 | + QCOMPARE(protocol->icon(), QString("/tmp/icon.png")); |
916 | + QCOMPARE(protocol->serviceName(), QString("The Service")); |
917 | } |
918 | |
919 | QTEST_MAIN(ProtocolTest) |
920 | |
921 | === modified file 'tests/libtelephonyservice/testProtocols/foo.protocol' |
922 | --- tests/libtelephonyservice/testProtocols/foo.protocol 2015-06-10 22:04:22 +0000 |
923 | +++ tests/libtelephonyservice/testProtocols/foo.protocol 2015-12-09 13:28:53 +0000 |
924 | @@ -2,3 +2,6 @@ |
925 | Name=foo |
926 | Features=text,voice |
927 | FallbackProtocol=bar |
928 | +BackgroundImage=/tmp/background.png |
929 | +Icon=/tmp/icon.png |
930 | +ServiceName=The Service |
FAILED: Continuous integration, rev:1146 jenkins. qa.ubuntu. com/job/ telephony- service- ci/623/ jenkins. qa.ubuntu. com/job/ telephony- service- vivid-amd64- ci/295/ console jenkins. qa.ubuntu. com/job/ telephony- service- vivid-armhf- ci/291/ console jenkins. qa.ubuntu. com/job/ telephony- service- vivid-i386- ci/291/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/telephony- service- ci/623/ rebuild
http://