Merge lp:~phablet-team/telepathy-ofono/generate-ids-for-room-channels into lp:telepathy-ofono/staging

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 183
Merged at revision: 182
Proposed branch: lp:~phablet-team/telepathy-ofono/generate-ids-for-room-channels
Merge into: lp:telepathy-ofono/staging
Diff against target: 81 lines (+28/-10)
1 file modified
connection.cpp (+28/-10)
To merge this branch: bzr merge lp:~phablet-team/telepathy-ofono/generate-ids-for-room-channels
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+310357@code.launchpad.net

Commit message

Generate Ids for non existing room channels and fill participants based on targetId when provided.

Description of the change

Generate Ids for non existing room channels and fill participants based on targetId when provided.

To post a comment you must log in.
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Just one small request, looks good otherwise.

review: Needs Fixing
183. By Tiago Salem Herrmann

Also check if targetId does not start with mms:

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good now!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'connection.cpp'
2--- connection.cpp 2016-10-28 02:28:53 +0000
3+++ connection.cpp 2016-11-09 19:40:45 +0000
4@@ -748,6 +748,17 @@
5 uint targetHandle = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")).toUInt();
6 QString targetId = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")).toString();
7 bool isRoom = request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_ROOM + QLatin1String(".RoomName"));
8+ QStringList initialInviteeIDs;
9+ if (request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeIDs"))) {
10+ initialInviteeIDs = qdbus_cast<QStringList>(request[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeIDs")]);
11+ } else if (targetHandleType == Tp::HandleTypeRoom && !targetId.isEmpty()) {
12+ // workaround to fill participants when not provided on new groups
13+ // this case can happen on existing groups automatically transformed from None to Room
14+ MMSGroup group = MMSGroupCache::existingGroup(targetId);
15+ if (group.members.isEmpty() && targetId.contains("%") && !targetId.startsWith("mms:")) {
16+ initialInviteeIDs = targetId.split("%");
17+ }
18+ }
19
20 if (mSelfPresence.type != Tp::ConnectionPresenceTypeAvailable) {
21 error->set(TP_QT_ERROR_NETWORK_ERROR, "No network available");
22@@ -756,31 +767,35 @@
23
24 QStringList phoneNumbers;
25 bool flash = false;
26- if (request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeIDs"))) {
27- QStringList newPhoneNumbers = qdbus_cast<QStringList>(request[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeIDs")]);
28+ if (!initialInviteeIDs.isEmpty()) {
29 Tp::UIntList handles;
30- Q_FOREACH(const QString& number, newPhoneNumbers) {
31+ Q_FOREACH(const QString& number, initialInviteeIDs) {
32 handles << ensureHandle(number);
33 }
34 phoneNumbers << inspectHandles(Tp::HandleTypeContact, handles, error);
35 } else if (request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles"))) {
36 phoneNumbers << inspectHandles(Tp::HandleTypeContact, qdbus_cast<Tp::UIntList>(request[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles")]), error);
37- };
38+ }
39
40 // if the handle type is none and RoomName is present, we should try to find an existing MMS group
41 if (targetHandleType == Tp::HandleTypeNone && isRoom) {
42 MMSGroup group = MMSGroupCache::existingGroup(phoneNumbers);
43 if (!group.groupId.isEmpty()) {
44 targetId = group.groupId;
45- targetHandleType = Tp::HandleTypeRoom;
46 }
47+ targetHandleType = Tp::HandleTypeRoom;
48 } else if (targetHandleType == Tp::HandleTypeRoom) {
49 if (targetId.isEmpty()) {
50 targetId = mGroupHandles.value(targetHandle);
51 }
52 // we got the groupId, now lookup the members and subject in the cache
53 MMSGroup group = MMSGroupCache::existingGroup(targetId);
54- if (group.groupId.isEmpty()) {
55+ if (group.groupId.isEmpty() && !initialInviteeIDs.isEmpty()) {
56+ // save new group if we have initial invitee ids and no group is found in cache
57+ group.groupId = targetId;
58+ group.members = phoneNumbers;
59+ MMSGroupCache::saveGroup(group);
60+ } else if (group.groupId.isEmpty()) {
61 error->set(TP_QT_ERROR_INVALID_HANDLE, "MMS Group not found in cache.");
62 return Tp::BaseChannelPtr();
63 }
64@@ -814,10 +829,13 @@
65 // FIXME(MMSGroup): if targetId is empty, this means this is a new group, so we need to
66 // generate the group ID, probably something like "mms:<hash of member IDs>".
67 // Also, we need to call MMSGroupCache::saveGroup() to save the group in the cache
68- MMSGroup group;
69- group.groupId = MMSGroupCache::generateId(phoneNumbers);
70- group.members = phoneNumbers;
71- MMSGroupCache::saveGroup(group);
72+ if (targetId.isEmpty()) {
73+ MMSGroup group;
74+ group.groupId = MMSGroupCache::generateId(phoneNumbers);
75+ group.members = phoneNumbers;
76+ targetId = group.groupId;
77+ MMSGroupCache::saveGroup(group);
78+ }
79 channel = new oFonoTextChannel(this, targetId, phoneNumbers);
80 } else {
81 channel = new oFonoTextChannel(this, QString(), phoneNumbers, flash);

Subscribers

People subscribed via source and target branches

to all changes: