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
=== modified file 'connection.cpp'
--- connection.cpp 2016-10-28 02:28:53 +0000
+++ connection.cpp 2016-11-09 19:40:45 +0000
@@ -748,6 +748,17 @@
748 uint targetHandle = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")).toUInt();748 uint targetHandle = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle")).toUInt();
749 QString targetId = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")).toString();749 QString targetId = request.value(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID")).toString();
750 bool isRoom = request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_ROOM + QLatin1String(".RoomName"));750 bool isRoom = request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_ROOM + QLatin1String(".RoomName"));
751 QStringList initialInviteeIDs;
752 if (request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeIDs"))) {
753 initialInviteeIDs = qdbus_cast<QStringList>(request[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeIDs")]);
754 } else if (targetHandleType == Tp::HandleTypeRoom && !targetId.isEmpty()) {
755 // workaround to fill participants when not provided on new groups
756 // this case can happen on existing groups automatically transformed from None to Room
757 MMSGroup group = MMSGroupCache::existingGroup(targetId);
758 if (group.members.isEmpty() && targetId.contains("%") && !targetId.startsWith("mms:")) {
759 initialInviteeIDs = targetId.split("%");
760 }
761 }
751762
752 if (mSelfPresence.type != Tp::ConnectionPresenceTypeAvailable) {763 if (mSelfPresence.type != Tp::ConnectionPresenceTypeAvailable) {
753 error->set(TP_QT_ERROR_NETWORK_ERROR, "No network available");764 error->set(TP_QT_ERROR_NETWORK_ERROR, "No network available");
@@ -756,31 +767,35 @@
756767
757 QStringList phoneNumbers;768 QStringList phoneNumbers;
758 bool flash = false;769 bool flash = false;
759 if (request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeIDs"))) {770 if (!initialInviteeIDs.isEmpty()) {
760 QStringList newPhoneNumbers = qdbus_cast<QStringList>(request[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeIDs")]);
761 Tp::UIntList handles;771 Tp::UIntList handles;
762 Q_FOREACH(const QString& number, newPhoneNumbers) {772 Q_FOREACH(const QString& number, initialInviteeIDs) {
763 handles << ensureHandle(number);773 handles << ensureHandle(number);
764 }774 }
765 phoneNumbers << inspectHandles(Tp::HandleTypeContact, handles, error);775 phoneNumbers << inspectHandles(Tp::HandleTypeContact, handles, error);
766 } else if (request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles"))) {776 } else if (request.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles"))) {
767 phoneNumbers << inspectHandles(Tp::HandleTypeContact, qdbus_cast<Tp::UIntList>(request[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles")]), error);777 phoneNumbers << inspectHandles(Tp::HandleTypeContact, qdbus_cast<Tp::UIntList>(request[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles")]), error);
768 };778 }
769779
770 // if the handle type is none and RoomName is present, we should try to find an existing MMS group780 // if the handle type is none and RoomName is present, we should try to find an existing MMS group
771 if (targetHandleType == Tp::HandleTypeNone && isRoom) {781 if (targetHandleType == Tp::HandleTypeNone && isRoom) {
772 MMSGroup group = MMSGroupCache::existingGroup(phoneNumbers);782 MMSGroup group = MMSGroupCache::existingGroup(phoneNumbers);
773 if (!group.groupId.isEmpty()) {783 if (!group.groupId.isEmpty()) {
774 targetId = group.groupId;784 targetId = group.groupId;
775 targetHandleType = Tp::HandleTypeRoom;
776 }785 }
786 targetHandleType = Tp::HandleTypeRoom;
777 } else if (targetHandleType == Tp::HandleTypeRoom) {787 } else if (targetHandleType == Tp::HandleTypeRoom) {
778 if (targetId.isEmpty()) {788 if (targetId.isEmpty()) {
779 targetId = mGroupHandles.value(targetHandle);789 targetId = mGroupHandles.value(targetHandle);
780 }790 }
781 // we got the groupId, now lookup the members and subject in the cache791 // we got the groupId, now lookup the members and subject in the cache
782 MMSGroup group = MMSGroupCache::existingGroup(targetId);792 MMSGroup group = MMSGroupCache::existingGroup(targetId);
783 if (group.groupId.isEmpty()) {793 if (group.groupId.isEmpty() && !initialInviteeIDs.isEmpty()) {
794 // save new group if we have initial invitee ids and no group is found in cache
795 group.groupId = targetId;
796 group.members = phoneNumbers;
797 MMSGroupCache::saveGroup(group);
798 } else if (group.groupId.isEmpty()) {
784 error->set(TP_QT_ERROR_INVALID_HANDLE, "MMS Group not found in cache.");799 error->set(TP_QT_ERROR_INVALID_HANDLE, "MMS Group not found in cache.");
785 return Tp::BaseChannelPtr();800 return Tp::BaseChannelPtr();
786 }801 }
@@ -814,10 +829,13 @@
814 // FIXME(MMSGroup): if targetId is empty, this means this is a new group, so we need to829 // FIXME(MMSGroup): if targetId is empty, this means this is a new group, so we need to
815 // generate the group ID, probably something like "mms:<hash of member IDs>".830 // generate the group ID, probably something like "mms:<hash of member IDs>".
816 // Also, we need to call MMSGroupCache::saveGroup() to save the group in the cache831 // Also, we need to call MMSGroupCache::saveGroup() to save the group in the cache
817 MMSGroup group;832 if (targetId.isEmpty()) {
818 group.groupId = MMSGroupCache::generateId(phoneNumbers);833 MMSGroup group;
819 group.members = phoneNumbers;834 group.groupId = MMSGroupCache::generateId(phoneNumbers);
820 MMSGroupCache::saveGroup(group);835 group.members = phoneNumbers;
836 targetId = group.groupId;
837 MMSGroupCache::saveGroup(group);
838 }
821 channel = new oFonoTextChannel(this, targetId, phoneNumbers);839 channel = new oFonoTextChannel(this, targetId, phoneNumbers);
822 } else {840 } else {
823 channel = new oFonoTextChannel(this, QString(), phoneNumbers, flash);841 channel = new oFonoTextChannel(this, QString(), phoneNumbers, flash);

Subscribers

People subscribed via source and target branches

to all changes: