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

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
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
=== added file 'assets/message_watermark.png'
0Binary files assets/message_watermark.png 1970-01-01 00:00:00 +0000 and assets/message_watermark.png 2015-12-09 13:28:53 +0000 differ0Binary 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
=== modified file 'handler/Handler.xml'
--- handler/Handler.xml 2015-11-17 17:23:54 +0000
+++ handler/Handler.xml 2015-12-09 13:28:53 +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-09 13:28:53 +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-09 13:28:53 +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-11-17 17:23:54 +0000
+++ handler/texthandler.cpp 2015-12-09 13:28:53 +0000
@@ -1,8 +1,9 @@
1/*1/*
2 * Copyright (C) 2012-2013 Canonical, Ltd.2 * Copyright (C) 2012-2015 Canonical, Ltd.
3 *3 *
4 * Authors:4 * Authors:
5 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>5 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
6 * Tiago Salem Herrmann <tiago.herrmann@canonical.com>
6 *7 *
7 * This file is part of telephony-service.8 * This file is part of telephony-service.
8 *9 *
@@ -32,12 +33,20 @@
3233
33#define SMIL_TEXT_REGION "<region id=\"Text\" width=\"100%\" height=\"100%\" fit=\"scroll\" />"34#define SMIL_TEXT_REGION "<region id=\"Text\" width=\"100%\" height=\"100%\" fit=\"scroll\" />"
34#define SMIL_IMAGE_REGION "<region id=\"Image\" width=\"100%\" height=\"100%\" fit=\"meet\" />"35#define SMIL_IMAGE_REGION "<region id=\"Image\" width=\"100%\" height=\"100%\" fit=\"meet\" />"
36#define SMIL_VIDEO_REGION "<region id=\"Video\" width=\"100%\" height=\"100%\" fit=\"meet\" />"
37#define SMIL_AUDIO_REGION "<region id=\"Audio\" width=\"100%\" height=\"100%\" fit=\"meet\" />"
35#define SMIL_TEXT_PART "<par dur=\"3s\">\38#define SMIL_TEXT_PART "<par dur=\"3s\">\
36 <text src=\"cid:%1\" region=\"Text\" />\39 <text src=\"cid:%1\" region=\"Text\" />\
37 </par>"40 </par>"
38#define SMIL_IMAGE_PART "<par dur=\"5000ms\">\41#define SMIL_IMAGE_PART "<par dur=\"5000ms\">\
39 <img src=\"cid:%1\" region=\"Image\" />\42 <img src=\"cid:%1\" region=\"Image\" />\
40 </par>"43 </par>"
44#define SMIL_VIDEO_PART "<par>\
45 <video src=\"cid:%1\" region=\"Video\" />\
46 </par>"
47#define SMIL_AUDIO_PART "<par>\
48 <audio src=\"cid:%1\" region=\"Audio\" />\
49 </par>"
4150
42#define SMIL_FILE "<smil>\51#define SMIL_FILE "<smil>\
43 <head>\52 <head>\
@@ -139,7 +148,7 @@
139 // start chatting to the contacts148 // start chatting to the contacts
140 Q_FOREACH(Tp::ContactPtr contact, contacts) {149 Q_FOREACH(Tp::ContactPtr contact, contacts) {
141 // hold the ContactPtr to make sure its refcounting stays bigger than 0150 // hold the ContactPtr to make sure its refcounting stays bigger than 0
142 mContacts[contact->id()] = contact;151 mContacts[account->uniqueIdentifier()][contact->id()] = contact;
143 }152 }
144}153}
145154
@@ -148,7 +157,7 @@
148 Tp::MessagePartList message;157 Tp::MessagePartList message;
149 Tp::MessagePart header;158 Tp::MessagePart header;
150 QString smil, regions, parts;159 QString smil, regions, parts;
151 bool hasImage = false, hasText = false, isMMS = false;160 bool hasImage = false, hasText = false, hasVideo = false, hasAudio = false, isMMS = false;
152161
153 AccountEntry *account = TelepathyHelper::instance()->accountForId(pendingMessage.accountId);162 AccountEntry *account = TelepathyHelper::instance()->accountForId(pendingMessage.accountId);
154 if (!account) {163 if (!account) {
@@ -207,6 +216,16 @@
207 fileData = attachmentFile.readAll();216 fileData = attachmentFile.readAll();
208 }217 }
209 }218 }
219 } else if (attachment.contentType.startsWith("video/")) {
220 if (isMMS) {
221 hasVideo = true;
222 parts += QString(SMIL_VIDEO_PART).arg(attachment.id);
223 }
224 } else if (attachment.contentType.startsWith("audio/")) {
225 if (isMMS) {
226 hasAudio = true;
227 parts += QString(SMIL_AUDIO_PART).arg(attachment.id);
228 }
210 } else if (attachment.contentType.startsWith("text/plain")) {229 } else if (attachment.contentType.startsWith("text/plain")) {
211 if (isMMS) {230 if (isMMS) {
212 hasText = true;231 hasText = true;
@@ -230,6 +249,14 @@
230 attachmentFile.remove();249 attachmentFile.remove();
231 }250 }
232251
252 if (hasVideo) {
253 regions += QString(SMIL_VIDEO_REGION);
254 }
255
256 if (hasAudio) {
257 regions += QString(SMIL_AUDIO_REGION);
258 }
259
233 if (hasText) {260 if (hasText) {
234 regions += QString(SMIL_TEXT_REGION);261 regions += QString(SMIL_TEXT_REGION);
235 }262 }
@@ -274,28 +301,54 @@
274 return message;301 return message;
275}302}
276303
277void 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)
278{305{
279 AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId);306 AccountEntry *account = TelepathyHelper::instance()->accountForId(accountId);
280 if (!account) {307 if (!account) {
281 // account does not exist308 // account does not exist
282 return;309 return QString();
283 }310 }
284311
285 // check if the message should be sent via multimedia account312 // check if the message should be sent via multimedia account
286 if (account->type() == AccountEntry::PhoneAccount) {313 // we just use fallback to 1-1 chats
287 // we just use fallback to 1-1 chats314 if (account->type() == AccountEntry::PhoneAccount && recipients.size() == 1) {
288 if (recipients.size() == 1) {315 Q_FOREACH(AccountEntry *newAccount, TelepathyHelper::instance()->accounts()) {
289316 // TODO: we have to find the multimedia account that matches the same phone number,
290 Q_FOREACH(AccountEntry *newAccount, TelepathyHelper::instance()->accounts()) {317 // but for now we just pick any multimedia connected account
291 // TODO: we have to find the multimedia account that matches the same phone number, 318 if (newAccount->type() != AccountEntry::MultimediaAccount) {
292 // but for now we just pick any multimedia connected account319 continue;
293 if (newAccount->type() == AccountEntry::MultimediaAccount) {320 }
294 if (newAccount->connected()) {321 // FIXME: the fallback implementation needs to be changed to use protocol info and create a map of
295 account = newAccount;322 // accounts. Also, it needs to check connection capabilities to determine if we can send message
296 break;323 // to offline contacts.
297 }324 bool shouldFallback = false;
298 }325 // if the account is offline, dont fallback to this account
326 if (!newAccount->connected()) {
327 continue;
328 }
329 QList<Tp::TextChannelPtr> channels = existingChannels(recipients, newAccount->accountId());
330 // check if we have a channel for this contact already and get the contact pointer from there,
331 // this way we avoid doing the while(op->isFinished()) all the time
332 if (!channels.isEmpty()) {
333 // if the contact is known, force fallback to this account
334 Tp::Presence presence = channels.first()->targetContact()->presence();
335 shouldFallback = (presence.type() == Tp::ConnectionPresenceTypeAvailable ||
336 presence.type() == Tp::ConnectionPresenceTypeOffline);
337 } else {
338 Tp::PendingOperation *op = newAccount->account()->connection()->contactManager()->contactsForIdentifiers(recipients);
339 while (!op->isFinished()) {
340 qApp->processEvents();
341 }
342 Tp::PendingContacts *pc = qobject_cast<Tp::PendingContacts*>(op);
343 if (pc) {
344 Tp::Presence presence = pc->contacts().first()->presence();
345 shouldFallback = (presence.type() == Tp::ConnectionPresenceTypeAvailable ||
346 presence.type() == Tp::ConnectionPresenceTypeOffline);
347 }
348 }
349 if (shouldFallback) {
350 account = newAccount;
351 break;
299 }352 }
300 }353 }
301 }354 }
@@ -304,21 +357,24 @@
304 QStringList sortedRecipients = recipients;357 QStringList sortedRecipients = recipients;
305 sortedRecipients.sort();358 sortedRecipients.sort();
306 PendingMessage pendingMessage = {account->accountId(), sortedRecipients, message, attachments, properties};359 PendingMessage pendingMessage = {account->accountId(), sortedRecipients, message, attachments, properties};
360
307 if (!account->connected()) {361 if (!account->connected()) {
308 mPendingMessages.append(pendingMessage);362 mPendingMessages.append(pendingMessage);
309 return;363 return account->accountId();
310 }364 }
311365
312 QList<Tp::TextChannelPtr> channels = existingChannels(recipients, account->accountId());366 QList<Tp::TextChannelPtr> channels = existingChannels(recipients, account->accountId());
313 if (channels.isEmpty()) {367 if (channels.isEmpty()) {
314 mPendingMessages.append(pendingMessage);368 mPendingMessages.append(pendingMessage);
315 startChat(sortedRecipients, account->accountId());369 startChat(sortedRecipients, account->accountId());
316 return;370 return account->accountId();
317 }371 }
318372
319 connect(channels.last()->send(buildMessage(pendingMessage)),373 connect(channels.last()->send(buildMessage(pendingMessage)),
320 SIGNAL(finished(Tp::PendingOperation*)),374 SIGNAL(finished(Tp::PendingOperation*)),
321 SLOT(onMessageSent(Tp::PendingOperation*)));375 SLOT(onMessageSent(Tp::PendingOperation*)));
376
377 return account->accountId();
322}378}
323379
324void TextHandler::acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId)380void TextHandler::acknowledgeMessages(const QStringList &recipients, const QStringList &messageIds, const QString &accountId)
@@ -351,12 +407,26 @@
351 }407 }
352}408}
353409
410void TextHandler::onTextChannelInvalidated()
411{
412 Tp::TextChannelPtr textChannel(qobject_cast<Tp::TextChannel*>(sender()));
413 mChannels.removeAll(textChannel);
414 AccountEntry *account = TelepathyHelper::instance()->accountForConnection(textChannel->connection());
415 if (account) {
416 mContacts.remove(account->accountId());
417 }
418}
419
354void TextHandler::onTextChannelAvailable(Tp::TextChannelPtr channel)420void TextHandler::onTextChannelAvailable(Tp::TextChannelPtr channel)
355{421{
356 AccountEntry *account = TelepathyHelper::instance()->accountForConnection(channel->connection());422 AccountEntry *account = TelepathyHelper::instance()->accountForConnection(channel->connection());
357 if (!account) {423 if (!account) {
358 return;424 return;
359 }425 }
426 connect(channel.data(),
427 SIGNAL(invalidated(Tp::DBusProxy*,const QString&, const QString&)),
428 SLOT(onTextChannelInvalidated()));
429
360 QString accountId = account->accountId();430 QString accountId = account->accountId();
361 mChannels.append(channel);431 mChannels.append(channel);
362432
363433
=== modified file 'handler/texthandler.h'
--- handler/texthandler.h 2015-11-17 17:23:54 +0000
+++ handler/texthandler.h 2015-12-09 13:28:53 +0000
@@ -47,12 +47,13 @@
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
54protected Q_SLOTS:54protected Q_SLOTS:
55 void onTextChannelAvailable(Tp::TextChannelPtr channel);55 void onTextChannelAvailable(Tp::TextChannelPtr channel);
56 void onTextChannelInvalidated();
56 void onContactsAvailable(Tp::PendingOperation *op);57 void onContactsAvailable(Tp::PendingOperation *op);
57 void onMessageSent(Tp::PendingOperation *op);58 void onMessageSent(Tp::PendingOperation *op);
58 void onConnectedChanged();59 void onConnectedChanged();
@@ -65,7 +66,7 @@
65 Tp::MessagePartList buildMessage(const PendingMessage &pendingMessage);66 Tp::MessagePartList buildMessage(const PendingMessage &pendingMessage);
6667
67 QList<Tp::TextChannelPtr> mChannels;68 QList<Tp::TextChannelPtr> mChannels;
68 QMap<QString, Tp::ContactPtr> mContacts;69 QMap<QString, QMap<QString, Tp::ContactPtr> > mContacts;
69 QList<PendingMessage> mPendingMessages;70 QList<PendingMessage> mPendingMessages;
70};71};
7172
7273
=== modified file 'libtelephonyservice/chatmanager.cpp'
--- libtelephonyservice/chatmanager.cpp 2015-11-17 17:23:54 +0000
+++ libtelephonyservice/chatmanager.cpp 2015-12-09 13:28:53 +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-09 13:28:53 +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 'libtelephonyservice/protocol.cpp'
--- libtelephonyservice/protocol.cpp 2015-06-10 21:05:50 +0000
+++ libtelephonyservice/protocol.cpp 2015-12-09 13:28:53 +0000
@@ -3,6 +3,7 @@
3 *3 *
4 * Authors:4 * Authors:
5 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>5 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
6 * Tiago Salem Herrmann <tiago.herrmann@canonical.com>
6 *7 *
7 * This file is part of telephony-service.8 * This file is part of telephony-service.
8 *9 *
@@ -23,8 +24,8 @@
23#include <QFileInfo>24#include <QFileInfo>
24#include <QSettings>25#include <QSettings>
2526
26Protocol::Protocol(const QString &name, Features features, const QString &fallbackProtocol, QObject *parent)27Protocol::Protocol(const QString &name, Features features, const QString &fallbackProtocol, const QString &backgroundImage, const QString &icon, const QString &serviceName, QObject *parent)
27: QObject(parent), mName(name), mFeatures(features), mFallbackProtocol(fallbackProtocol)28: QObject(parent), mName(name), mFeatures(features), mFallbackProtocol(fallbackProtocol), mBackgroundImage(backgroundImage), mIcon(icon), mServiceName(serviceName)
28{29{
29}30}
3031
@@ -33,6 +34,16 @@
33 return mName;34 return mName;
34}35}
3536
37QString Protocol::icon() const
38{
39 return mIcon;
40}
41
42QString Protocol::serviceName() const
43{
44 return mServiceName;
45}
46
36Protocol::Features Protocol::features() const47Protocol::Features Protocol::features() const
37{48{
38 return mFeatures;49 return mFeatures;
@@ -43,6 +54,11 @@
43 return mFallbackProtocol;54 return mFallbackProtocol;
44}55}
4556
57QString Protocol::backgroundImage() const
58{
59 return mBackgroundImage;
60}
61
46Protocol *Protocol::fromFile(const QString &fileName)62Protocol *Protocol::fromFile(const QString &fileName)
47{63{
48 QFileInfo file(fileName);64 QFileInfo file(fileName);
@@ -52,6 +68,7 @@
5268
53 QString protocolName = file.baseName();69 QString protocolName = file.baseName();
54 QSettings settings(fileName, QSettings::IniFormat);70 QSettings settings(fileName, QSettings::IniFormat);
71 settings.setIniCodec("UTF-8");
55 settings.beginGroup("Protocol");72 settings.beginGroup("Protocol");
56 QString name = settings.value("Name", protocolName).toString();73 QString name = settings.value("Name", protocolName).toString();
57 QStringList featureList = settings.value("Features").toStringList();74 QStringList featureList = settings.value("Features").toStringList();
@@ -64,6 +81,9 @@
64 }81 }
65 }82 }
66 QString fallbackProtocol = settings.value("FallbackProtocol").toString();83 QString fallbackProtocol = settings.value("FallbackProtocol").toString();
84 QString backgroundImage = settings.value("BackgroundImage").toString();
85 QString icon = settings.value("Icon").toString();
86 QString serviceName = settings.value("ServiceName").toString();
6787
68 return new Protocol(name, features, fallbackProtocol);88 return new Protocol(name, features, fallbackProtocol, backgroundImage, icon, serviceName);
69}89}
7090
=== modified file 'libtelephonyservice/protocol.h'
--- libtelephonyservice/protocol.h 2015-06-10 21:05:50 +0000
+++ libtelephonyservice/protocol.h 2015-12-09 13:28:53 +0000
@@ -3,6 +3,7 @@
3 *3 *
4 * Authors:4 * Authors:
5 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>5 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
6 * Tiago Salem Herrmann <tiago.herrmann@canonical.com>
6 *7 *
7 * This file is part of telephony-service.8 * This file is part of telephony-service.
8 *9 *
@@ -36,6 +37,16 @@
3637
37 /// @brief the fallback protocol to be used for operations that support it (mainly text features)38 /// @brief the fallback protocol to be used for operations that support it (mainly text features)
38 Q_PROPERTY(QString fallbackProtocol READ fallbackProtocol CONSTANT)39 Q_PROPERTY(QString fallbackProtocol READ fallbackProtocol CONSTANT)
40
41 /// @brief the file path for the image that represents this protocol
42 Q_PROPERTY(QString backgroundImage READ backgroundImage CONSTANT)
43
44 /// @brief the file path for the image that represents this protocol
45 Q_PROPERTY(QString icon READ icon CONSTANT)
46
47 /// @brief the title that represents this protocol
48 Q_PROPERTY(QString serviceName READ serviceName CONSTANT)
49
39public:50public:
40 enum Feature {51 enum Feature {
41 TextChats = 0x1,52 TextChats = 0x1,
@@ -46,18 +57,24 @@
46 QString name() const;57 QString name() const;
47 Features features() const;58 Features features() const;
48 QString fallbackProtocol() const;59 QString fallbackProtocol() const;
60 QString backgroundImage() const;
61 QString icon() const;
62 QString serviceName() const;
4963
50 static Protocol *fromFile(const QString &fileName);64 static Protocol *fromFile(const QString &fileName);
5165
52 friend class ProtocolManager;66 friend class ProtocolManager;
5367
54protected:68protected:
55 explicit Protocol(const QString &name, Features features, const QString &fallbackProtocol = QString::null, QObject *parent = 0);69 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);
5670
57private:71private:
58 QString mName;72 QString mName;
59 Features mFeatures;73 Features mFeatures;
60 QString mFallbackProtocol;74 QString mFallbackProtocol;
75 QString mBackgroundImage;
76 QString mIcon;
77 QString mServiceName;
61};78};
6279
63typedef QList<Protocol*> Protocols;80typedef QList<Protocol*> Protocols;
6481
=== added file 'protocols/multimedia.protocol'
--- protocols/multimedia.protocol 1970-01-01 00:00:00 +0000
+++ protocols/multimedia.protocol 2015-12-09 13:28:53 +0000
@@ -0,0 +1,4 @@
1[Protocol]
2Name=multimedia
3Features=text
4FallbackProtocol=ofono
05
=== removed file 'protocols/multimedia.protocol'
--- protocols/multimedia.protocol 2015-06-11 16:48:18 +0000
+++ protocols/multimedia.protocol 1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
1[Protocol]
2Name=multimedia
3Features=text
4FallbackProtocol=ofono
50
=== modified file 'protocols/ofono.protocol'
--- protocols/ofono.protocol 2015-06-10 21:05:50 +0000
+++ protocols/ofono.protocol 2015-12-09 13:28:53 +0000
@@ -2,3 +2,4 @@
2Name=ofono2Name=ofono
3Features=text,voice3Features=text,voice
4FallbackProtocol=4FallbackProtocol=
5BackgroundImage=/usr/share/telephony-service/assets/message_watermark.png
56
=== modified file 'tests/common/mock/MockConnection.xml'
--- tests/common/mock/MockConnection.xml 2015-11-17 17:23:54 +0000
+++ tests/common/mock/MockConnection.xml 2015-12-09 13:28:53 +0000
@@ -210,9 +210,12 @@
210 A message was sent from the client.210 A message was sent from the client.
211 ]]></dox:d>211 ]]></dox:d>
212 <arg name="message" type="s"/>212 <arg name="message" type="s"/>
213 <arg name="attachments" type="av"/>
213 <arg name="properties" type="a{sv}"/>214 <arg name="properties" type="a{sv}"/>
214 <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/>215 <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantList"/>
215 <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/>216 <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantList"/>
217 <annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QVariantMap"/>
218 <annotation name="org.qtproject.QtDBus.QtTypeName.Out2" value="QVariantMap"/>
216 </signal>219 </signal>
217 <signal name="CallReceived">220 <signal name="CallReceived">
218 <dox:d><![CDATA[221 <dox:d><![CDATA[
219222
=== modified file 'tests/common/mock/connection.cpp'
--- tests/common/mock/connection.cpp 2015-11-17 17:23:54 +0000
+++ tests/common/mock/connection.cpp 2015-12-09 13:28:53 +0000
@@ -371,7 +371,7 @@
371 MockTextChannel *channel = new MockTextChannel(this, recipients, targetHandle);371 MockTextChannel *channel = new MockTextChannel(this, recipients, targetHandle);
372 QObject::connect(channel, SIGNAL(messageRead(QString)), SLOT(onMessageRead(QString)));372 QObject::connect(channel, SIGNAL(messageRead(QString)), SLOT(onMessageRead(QString)));
373 QObject::connect(channel, SIGNAL(destroyed()), SLOT(onTextChannelClosed()));373 QObject::connect(channel, SIGNAL(destroyed()), SLOT(onTextChannelClosed()));
374 QObject::connect(channel, SIGNAL(messageSent(QString,QVariantMap)), SIGNAL(messageSent(QString,QVariantMap)));374 QObject::connect(channel, SIGNAL(messageSent(QString,QVariantList,QVariantMap)), SIGNAL(messageSent(QString,QVariantList,QVariantMap)));
375 qDebug() << channel;375 qDebug() << channel;
376 mTextChannels << channel;376 mTextChannels << channel;
377 return channel->baseChannel();377 return channel->baseChannel();
378378
=== modified file 'tests/common/mock/connection.h'
--- tests/common/mock/connection.h 2015-11-17 17:23:54 +0000
+++ tests/common/mock/connection.h 2015-12-09 13:28:53 +0000
@@ -110,7 +110,7 @@
110110
111Q_SIGNALS:111Q_SIGNALS:
112 void messageRead(const QString &messageId);112 void messageRead(const QString &messageId);
113 void messageSent(const QString &message, const QVariantMap &info);113 void messageSent(const QString &message, const QVariantList &attachments, const QVariantMap &info);
114 void callReceived(const QString &callerId);114 void callReceived(const QString &callerId);
115 void callEnded(const QString &callerId);115 void callEnded(const QString &callerId);
116 void callStateChanged(const QString &callerId, const QString &objectPath, const QString &state);116 void callStateChanged(const QString &callerId, const QString &objectPath, const QString &state);
117117
=== modified file 'tests/common/mock/mockconnectiondbus.cpp'
--- tests/common/mock/mockconnectiondbus.cpp 2015-11-17 17:23:54 +0000
+++ tests/common/mock/mockconnectiondbus.cpp 2015-12-09 13:28:53 +0000
@@ -32,8 +32,8 @@
32 SIGNAL(messageRead(QString)),32 SIGNAL(messageRead(QString)),
33 SIGNAL(MessageRead(QString)));33 SIGNAL(MessageRead(QString)));
34 connect(mConnection,34 connect(mConnection,
35 SIGNAL(messageSent(QString,QVariantMap)),35 SIGNAL(messageSent(QString,QVariantList,QVariantMap)),
36 SIGNAL(MessageSent(QString,QVariantMap)));36 SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
37 connect(mConnection,37 connect(mConnection,
38 SIGNAL(callReceived(QString)),38 SIGNAL(callReceived(QString)),
39 SIGNAL(CallReceived(QString)));39 SIGNAL(CallReceived(QString)));
4040
=== modified file 'tests/common/mock/mockconnectiondbus.h'
--- tests/common/mock/mockconnectiondbus.h 2015-11-17 17:23:54 +0000
+++ tests/common/mock/mockconnectiondbus.h 2015-12-09 13:28:53 +0000
@@ -71,7 +71,7 @@
71Q_SIGNALS:71Q_SIGNALS:
72 // signals that will be relayed into the bus72 // signals that will be relayed into the bus
73 void MessageRead(const QString &messageId);73 void MessageRead(const QString &messageId);
74 void MessageSent(const QString &mesasge, const QVariantMap &properties);74 void MessageSent(const QString &message, const QVariantList &attachments, const QVariantMap &properties);
75 void CallReceived(const QString &callerId);75 void CallReceived(const QString &callerId);
76 void CallEnded(const QString &callerId);76 void CallEnded(const QString &callerId);
77 void CallStateChanged(const QString &callerId, const QString &objectPath, const QString &state);77 void CallStateChanged(const QString &callerId, const QString &objectPath, const QString &state);
7878
=== modified file 'tests/common/mock/textchannel.cpp'
--- tests/common/mock/textchannel.cpp 2015-11-17 14:30:19 +0000
+++ tests/common/mock/textchannel.cpp 2015-12-09 13:28:53 +0000
@@ -105,13 +105,12 @@
105QString MockTextChannel::sendMessage(const Tp::MessagePartList& message, uint flags, Tp::DBusError* error)105QString MockTextChannel::sendMessage(const Tp::MessagePartList& message, uint flags, Tp::DBusError* error)
106{106{
107 Tp::MessagePart header = message.at(0);107 Tp::MessagePart header = message.at(0);
108 Tp::MessagePart body = message.at(1);
109108
110 static int serial = 0;109 static int serial = 0;
111110
112 // FIXME: check what other data we need to emit in the signal111 // FIXME: check what other data we need to emit in the signal
113 QString id = QString("sentmessage%1").arg(serial++);112 QString id = QString("sentmessage%1").arg(serial++);
114 QString messageText = body["content"].variant().toString();113 QString messageText;
115 QVariantMap properties;114 QVariantMap properties;
116 QMap<QString, QDBusVariant>::const_iterator it = header.constBegin();115 QMap<QString, QDBusVariant>::const_iterator it = header.constBegin();
117 while (it != header.constEnd()) {116 while (it != header.constEnd()) {
@@ -122,7 +121,24 @@
122 properties["Recipients"] = mRecipients;121 properties["Recipients"] = mRecipients;
123 properties["Id"] = id;122 properties["Id"] = id;
124123
125 Q_EMIT messageSent(messageText, properties);124 QVariantList attachments;
125 Tp::MessagePartList messageList = message;
126 messageList.pop_front();
127 Q_FOREACH(const Tp::MessagePart& messagePart, messageList) {
128 QVariantMap attachment;
129 if (messagePart.contains("content-type") && messagePart["content-type"].variant().toString().startsWith("text/")) {
130 messageText = messagePart["content"].variant().toString();
131 continue;
132 }
133 QMap<QString, QDBusVariant>::const_iterator it = messagePart.constBegin();
134 while (it != messagePart.constEnd()) {
135 attachment[it.key()] = it.value().variant().toString();
136 it++;
137 }
138 attachments << attachment;
139 }
140
141 Q_EMIT messageSent(messageText, attachments, properties);
126142
127 QTimer *deliveryReportTimer = new QTimer(this);143 QTimer *deliveryReportTimer = new QTimer(this);
128 deliveryReportTimer->setSingleShot(true);144 deliveryReportTimer->setSingleShot(true);
129145
=== modified file 'tests/common/mock/textchannel.h'
--- tests/common/mock/textchannel.h 2015-03-20 19:00:21 +0000
+++ tests/common/mock/textchannel.h 2015-12-09 13:28:53 +0000
@@ -54,7 +54,7 @@
5454
55Q_SIGNALS:55Q_SIGNALS:
56 void messageRead(const QString &id);56 void messageRead(const QString &id);
57 void messageSent(const QString &message, const QVariantMap &info);57 void messageSent(const QString &message, const QVariantList &attachments, const QVariantMap &info);
5858
59private:59private:
60 ~MockTextChannel();60 ~MockTextChannel();
6161
=== modified file 'tests/handler/HandlerTest.cpp'
--- tests/handler/HandlerTest.cpp 2015-10-09 16:13:30 +0000
+++ tests/handler/HandlerTest.cpp 2015-12-09 13:28:53 +0000
@@ -41,10 +41,12 @@
41 void testCallProperties();41 void testCallProperties();
42 void testConferenceCall();42 void testConferenceCall();
43 void testSendMessage();43 void testSendMessage();
44 void testSendMessageWithAttachments();
44 void testAcknowledgeMessage();45 void testAcknowledgeMessage();
45 void testAcknowledgeAllMessages();46 void testAcknowledgeAllMessages();
46 void testActiveCallIndicator();47 void testActiveCallIndicator();
47 void testNotApprovedChannels();48 void testNotApprovedChannels();
49 void testMultimediaFallback();
4850
49private:51private:
50 void registerApprover();52 void registerApprover();
@@ -53,6 +55,11 @@
53 Approver *mApprover;55 Approver *mApprover;
54 MockController *mMockController;56 MockController *mMockController;
55 Tp::AccountPtr mTpAccount;57 Tp::AccountPtr mTpAccount;
58 MockController *mMultimediaMockController;
59 Tp::AccountPtr mMultimediaTpAccount;
60 MockController *mOfonoMockController;
61 Tp::AccountPtr mOfonoTpAccount;
62
56};63};
5764
58void HandlerTest::initTestCase()65void HandlerTest::initTestCase()
@@ -71,12 +78,20 @@
7178
72 // and create the mock controller79 // and create the mock controller
73 mMockController = new MockController("mock", this);80 mMockController = new MockController("mock", this);
81
82 mOfonoTpAccount = addAccount("mock", "ofono", "the account");
83 mOfonoMockController = new MockController("ofono", this);
84
85 mMultimediaTpAccount = addAccount("mock", "multimedia", "the account");
86 mMultimediaMockController = new MockController("multimedia", this);
74}87}
7588
76void HandlerTest::cleanup()89void HandlerTest::cleanup()
77{90{
78 doCleanup();91 doCleanup();
79 mMockController->deleteLater();92 mMockController->deleteLater();
93 mMultimediaMockController->deleteLater();
94 mOfonoMockController->deleteLater();
80}95}
8196
82void HandlerTest::testMakingCalls()97void HandlerTest::testMakingCalls()
@@ -275,7 +290,7 @@
275{290{
276 QString recipient("22222222");291 QString recipient("22222222");
277 QString message("Hello, world!");292 QString message("Hello, world!");
278 QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantMap)));293 QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
279 // FIXME: add support for multiple accounts294 // FIXME: add support for multiple accounts
280 HandlerController::instance()->sendMessage(mTpAccount->uniqueIdentifier(), QStringList() << recipient, message);295 HandlerController::instance()->sendMessage(mTpAccount->uniqueIdentifier(), QStringList() << recipient, message);
281 TRY_COMPARE(messageSentSpy.count(), 1);296 TRY_COMPARE(messageSentSpy.count(), 1);
@@ -286,6 +301,31 @@
286 QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient);301 QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient);
287}302}
288303
304void HandlerTest::testSendMessageWithAttachments()
305{
306 QString recipient("22222222");
307 QString message("Hello, world!");
308 QSignalSpy messageSentSpy(mMultimediaMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
309
310 QTemporaryFile outputFile("audioXXXXXX.ogg");
311 outputFile.open();
312 AttachmentStruct attachment{"id", "audio/ogg", outputFile.fileName()};
313 HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message, AttachmentList() << attachment);
314 TRY_COMPARE(messageSentSpy.count(), 1);
315 outputFile.close();
316
317 QString sentMessage = messageSentSpy.first()[0].toString();
318 QVariantMap messageProperties = messageSentSpy.first()[2].value<QVariantMap>();
319 QCOMPARE(sentMessage, message);
320 QCOMPARE(messageProperties["Recipients"].value<QStringList>().count(), 1);
321 QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient);
322
323 QVariantList messageAttachments = qdbus_cast<QVariantList>(messageSentSpy.first()[1]);
324 QVariantMap firstAttachment = qdbus_cast<QVariantMap>(messageAttachments.first());
325 QCOMPARE(firstAttachment["content-type"].toString(), QString("audio/ogg"));
326 QCOMPARE(firstAttachment["identifier"].toString(), QString("id"));
327}
328
289void HandlerTest::testAcknowledgeMessage()329void HandlerTest::testAcknowledgeMessage()
290{330{
291 // if we register the observer before this test, other tests fail331 // if we register the observer before this test, other tests fail
@@ -293,7 +333,7 @@
293 QString recipient("84376666");333 QString recipient("84376666");
294 QString recipient2("+554184376666");334 QString recipient2("+554184376666");
295 QString message("Hello, world!");335 QString message("Hello, world!");
296 QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantMap)));336 QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
297337
298 // first send a message to a certain number so the handler request one channel338 // first send a message to a certain number so the handler request one channel
299 HandlerController::instance()->sendMessage(mTpAccount->uniqueIdentifier(), QStringList() << recipient, message);339 HandlerController::instance()->sendMessage(mTpAccount->uniqueIdentifier(), QStringList() << recipient, message);
@@ -327,7 +367,7 @@
327 QString recipient2("+554198437666");367 QString recipient2("+554198437666");
328 QString message("Hello, world! %1");368 QString message("Hello, world! %1");
329 int messageCount = 10;369 int messageCount = 10;
330 QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantMap)));370 QSignalSpy messageSentSpy(mMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
331371
332 // first send a message to a certain number so the handler request one channel372 // first send a message to a certain number so the handler request one channel
333 HandlerController::instance()->sendMessage(mTpAccount->uniqueIdentifier(), QStringList() << recipient, message);373 HandlerController::instance()->sendMessage(mTpAccount->uniqueIdentifier(), QStringList() << recipient, message);
@@ -403,6 +443,44 @@
403 QCOMPARE(callStateSpy.last()[2].toString(), QString("initialised"));443 QCOMPARE(callStateSpy.last()[2].toString(), QString("initialised"));
404}444}
405445
446void HandlerTest::testMultimediaFallback()
447{
448 QString recipient("22222222");
449 QString message("Hello, world!");
450 mMultimediaMockController->SetContactPresence(recipient, Tp::ConnectionPresenceTypeAvailable, "available", "");
451 // We have to make sure the handler already has the new state
452 QTest::qWait(1000);
453
454 QSignalSpy messageSentOfonoSpy(mOfonoMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
455 QSignalSpy messageSentMultimediaSpy(mMultimediaMockController, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
456
457 QString accountId = HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message);
458 QCOMPARE(accountId, mMultimediaTpAccount->uniqueIdentifier());
459 TRY_COMPARE(messageSentMultimediaSpy.count(), 1);
460 QCOMPARE(messageSentOfonoSpy.count(), 0);
461 QString sentMessage = messageSentMultimediaSpy.first().first().toString();
462 QVariantMap messageProperties = messageSentMultimediaSpy.first().last().value<QVariantMap>();
463 QCOMPARE(sentMessage, message);
464 QCOMPARE(messageProperties["Recipients"].value<QStringList>().count(), 1);
465 QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient);
466
467 messageSentMultimediaSpy.clear();
468 messageSentOfonoSpy.clear();
469
470 mMultimediaMockController->SetContactPresence(recipient, Tp::ConnectionPresenceTypeUnknown, "offline", "");
471 // We have to make sure the handler already has the new state
472 QTest::qWait(1000);
473 HandlerController::instance()->sendMessage(mOfonoTpAccount->uniqueIdentifier(), QStringList() << recipient, message);
474 TRY_COMPARE(messageSentOfonoSpy.count(), 1);
475 QCOMPARE(messageSentMultimediaSpy.count(), 0);
476
477 sentMessage = messageSentOfonoSpy.first().first().toString();
478 messageProperties = messageSentOfonoSpy.first().last().value<QVariantMap>();
479 QCOMPARE(sentMessage, message);
480 QCOMPARE(messageProperties["Recipients"].value<QStringList>().count(), 1);
481 QCOMPARE(messageProperties["Recipients"].value<QStringList>().first(), recipient);
482}
483
406void HandlerTest::registerApprover()484void HandlerTest::registerApprover()
407{485{
408 // register the approver486 // register the approver
409487
=== modified file 'tests/handler/handlercontroller.cpp'
--- tests/handler/handlercontroller.cpp 2015-08-09 03:49:08 +0000
+++ tests/handler/handlercontroller.cpp 2015-12-09 13:28:53 +0000
@@ -73,6 +73,11 @@
73 return map["CallIndicatorVisible"].toBool();73 return map["CallIndicatorVisible"].toBool();
74}74}
7575
76void HandlerController::startChat(const QString &accountId, const QStringList &recipients)
77{
78 mHandlerInterface.call("StartChat", accountId, recipients);
79}
80
76void HandlerController::startCall(const QString &number, const QString &accountId)81void HandlerController::startCall(const QString &number, const QString &accountId)
77{82{
78 mHandlerInterface.call("StartCall", number, accountId);83 mHandlerInterface.call("StartCall", number, accountId);
@@ -124,9 +129,13 @@
124 mHandlerInterface.call("SplitCall", objectPath);129 mHandlerInterface.call("SplitCall", objectPath);
125}130}
126131
127void 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)
128{133{
129 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();
130}139}
131140
132void HandlerController::acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId)141void HandlerController::acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId)
133142
=== modified file 'tests/handler/handlercontroller.h'
--- tests/handler/handlercontroller.h 2015-08-09 03:49:08 +0000
+++ tests/handler/handlercontroller.h 2015-12-09 13:28:53 +0000
@@ -36,6 +36,7 @@
3636
37public Q_SLOTS:37public Q_SLOTS:
38 // call methods38 // call methods
39 void startChat(const QString &accountId, const QStringList &recipients);
39 void startCall(const QString &number, const QString &accountId);40 void startCall(const QString &number, const QString &accountId);
40 void hangUpCall(const QString &objectPath);41 void hangUpCall(const QString &objectPath);
41 void setHold(const QString &objectPath, bool hold);42 void setHold(const QString &objectPath, bool hold);
@@ -50,7 +51,7 @@
50 void splitCall(const QString &objectPath);51 void splitCall(const QString &objectPath);
5152
52 // messaging methods53 // messaging methods
53 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());
54 void acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId);55 void acknowledgeMessages(const QString &number, const QStringList &messageIds, const QString &accountId);
5556
56 // active call indicator57 // active call indicator
5758
=== modified file 'tests/libtelephonyservice/ChatManagerTest.cpp'
--- tests/libtelephonyservice/ChatManagerTest.cpp 2015-11-17 14:30:19 +0000
+++ tests/libtelephonyservice/ChatManagerTest.cpp 2015-12-09 13:28:53 +0000
@@ -101,14 +101,14 @@
101 qSort(recipients);101 qSort(recipients);
102102
103 MockController *controller = accountId.startsWith("mock/mock") ? mGenericMockController : mPhoneMockController;103 MockController *controller = accountId.startsWith("mock/mock") ? mGenericMockController : mPhoneMockController;
104 QSignalSpy controllerMessageSentSpy(controller, SIGNAL(MessageSent(QString,QVariantMap)));104 QSignalSpy controllerMessageSentSpy(controller, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
105 QSignalSpy messageSentSpy(ChatManager::instance(), SIGNAL(messageSent(QStringList,QString)));105 QSignalSpy messageSentSpy(ChatManager::instance(), SIGNAL(messageSent(QStringList,QString)));
106106
107 ChatManager::instance()->sendMessage(accountId, recipients, message);107 ChatManager::instance()->sendMessage(accountId, recipients, message);
108108
109 TRY_COMPARE(controllerMessageSentSpy.count(), 1);109 TRY_COMPARE(controllerMessageSentSpy.count(), 1);
110 QString messageText = controllerMessageSentSpy.first()[0].toString();110 QString messageText = controllerMessageSentSpy.first()[0].toString();
111 QVariantMap messageProperties = controllerMessageSentSpy.first()[1].toMap();111 QVariantMap messageProperties = controllerMessageSentSpy.first()[2].toMap();
112 QStringList messageRecipients = messageProperties["Recipients"].toStringList();112 QStringList messageRecipients = messageProperties["Recipients"].toStringList();
113 qSort(messageRecipients);113 qSort(messageRecipients);
114 QCOMPARE(messageText, message);114 QCOMPARE(messageText, message);
@@ -218,7 +218,7 @@
218218
219 MockController *controller = accountId.startsWith("mock/mock") ? mGenericMockController : mPhoneMockController;219 MockController *controller = accountId.startsWith("mock/mock") ? mGenericMockController : mPhoneMockController;
220220
221 QSignalSpy controllerMessageSentSpy(controller, SIGNAL(MessageSent(QString,QVariantMap)));221 QSignalSpy controllerMessageSentSpy(controller, SIGNAL(MessageSent(QString,QVariantList,QVariantMap)));
222222
223 QVariantList attachmentList;223 QVariantList attachmentList;
224 QVariantList attachment;224 QVariantList attachment;
@@ -230,7 +230,7 @@
230230
231 TRY_COMPARE(controllerMessageSentSpy.count(), 1);231 TRY_COMPARE(controllerMessageSentSpy.count(), 1);
232 QString messageText = controllerMessageSentSpy.first()[0].toString();232 QString messageText = controllerMessageSentSpy.first()[0].toString();
233 QVariantMap messageProperties = controllerMessageSentSpy.first()[1].toMap();233 QVariantMap messageProperties = controllerMessageSentSpy.first()[2].toMap();
234 QStringList messageRecipients = messageProperties["Recipients"].toStringList();234 QStringList messageRecipients = messageProperties["Recipients"].toStringList();
235 qSort(messageRecipients);235 qSort(messageRecipients);
236 QCOMPARE(messageText, message);236 QCOMPARE(messageText, message);
237237
=== modified file 'tests/libtelephonyservice/ProtocolTest.cpp'
--- tests/libtelephonyservice/ProtocolTest.cpp 2015-06-10 22:04:22 +0000
+++ tests/libtelephonyservice/ProtocolTest.cpp 2015-12-09 13:28:53 +0000
@@ -27,8 +27,8 @@
27{27{
28 Q_OBJECT28 Q_OBJECT
29public:29public:
30 TestProtocol(const QString &name, Protocol::Features features, const QString &fallbackProtocol, QObject *parent = 0)30 TestProtocol(const QString &name, Protocol::Features features, const QString &fallbackProtocol, const QString &backgroundFile, const QString &icon, const QString &serviceName = QString::null, QObject *parent = 0)
31 : Protocol(name, features, fallbackProtocol, parent) { }31 : Protocol(name, features, fallbackProtocol, backgroundFile, icon, serviceName, parent) { }
32};32};
3333
34class ProtocolTest : public QObject34class ProtocolTest : public QObject
@@ -45,11 +45,17 @@
45 QString name("foobar");45 QString name("foobar");
46 Protocol::Features features(Protocol::TextChats);46 Protocol::Features features(Protocol::TextChats);
47 QString fallbackProtocol("theFallback");47 QString fallbackProtocol("theFallback");
48 QString backgroundImage("/tmp/background.png");
49 QString icon("/tmp/icon.png");
50 QString serviceName("The service");
4851
49 TestProtocol protocol(name, features, fallbackProtocol, this);52 TestProtocol protocol(name, features, fallbackProtocol, backgroundImage, icon, serviceName, this);
50 QCOMPARE(protocol.name(), name);53 QCOMPARE(protocol.name(), name);
51 QCOMPARE(protocol.features(), features);54 QCOMPARE(protocol.features(), features);
52 QCOMPARE(protocol.fallbackProtocol(), fallbackProtocol);55 QCOMPARE(protocol.fallbackProtocol(), fallbackProtocol);
56 QCOMPARE(protocol.backgroundImage(), backgroundImage);
57 QCOMPARE(protocol.icon(), icon);
58 QCOMPARE(protocol.serviceName(), serviceName);
53 QCOMPARE(protocol.parent(), this);59 QCOMPARE(protocol.parent(), this);
54}60}
5561
@@ -65,6 +71,9 @@
65 QCOMPARE(protocol->name(), QString("foo"));71 QCOMPARE(protocol->name(), QString("foo"));
66 QCOMPARE(protocol->features(), Protocol::Features(Protocol::TextChats | Protocol::VoiceCalls));72 QCOMPARE(protocol->features(), Protocol::Features(Protocol::TextChats | Protocol::VoiceCalls));
67 QCOMPARE(protocol->fallbackProtocol(), QString("bar"));73 QCOMPARE(protocol->fallbackProtocol(), QString("bar"));
74 QCOMPARE(protocol->backgroundImage(), QString("/tmp/background.png"));
75 QCOMPARE(protocol->icon(), QString("/tmp/icon.png"));
76 QCOMPARE(protocol->serviceName(), QString("The Service"));
68}77}
6978
70QTEST_MAIN(ProtocolTest)79QTEST_MAIN(ProtocolTest)
7180
=== modified file 'tests/libtelephonyservice/testProtocols/foo.protocol'
--- tests/libtelephonyservice/testProtocols/foo.protocol 2015-06-10 22:04:22 +0000
+++ tests/libtelephonyservice/testProtocols/foo.protocol 2015-12-09 13:28:53 +0000
@@ -2,3 +2,6 @@
2Name=foo2Name=foo
3Features=text,voice3Features=text,voice
4FallbackProtocol=bar4FallbackProtocol=bar
5BackgroundImage=/tmp/background.png
6Icon=/tmp/icon.png
7ServiceName=The Service

Subscribers

People subscribed via source and target branches