Merge lp:~phablet-team/messaging-framework/last-minute-fixes into lp:messaging-framework

Proposed by Roberto Mier Escandon
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 75
Merged at revision: 68
Proposed branch: lp:~phablet-team/messaging-framework/last-minute-fixes
Merge into: lp:messaging-framework
Prerequisite: lp:~phablet-team/messaging-framework/self-id
Diff against target: 136 lines (+29/-14)
5 files modified
include/messaging/group_manager.h (+3/-0)
include/messaging/qt/tp/text_channel.h (+1/-0)
src/messaging/qt/tp/connection.cpp (+5/-4)
src/messaging/qt/tp/text_channel.cpp (+19/-10)
tests/mock_group_manager.h (+1/-0)
To merge this branch: bzr merge lp:~phablet-team/messaging-framework/last-minute-fixes
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Approve
Tiago Salem Herrmann (community) Approve
Review via email: mp+308008@code.launchpad.net

Commit message

Bunch of last minute fixes:
- adding selfID along with selfHandle
- using connection->group_admin_ids to know who are the admins, and compare with selfID to know if we are admin also, instead of querying existing members and guess.

NOTE: This branch should be landed along with https://code.launchpad.net/~ningbo-team/ningbo/last-minute-fixes/+merge/308007

Description of the change

Bunch of last minute fixes:
- adding selfID along with selfHandle
- using connection->group_admin_ids to know who are the admins, and compare with selfID to know if we are admin also, instead of querying existing members and guess.

NOTE: This branch should be landed along with https://code.launchpad.net/~ningbo-team/ningbo/last-minute-fixes/+merge/308007

To post a comment you must log in.
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

FAILED: Continuous integration, rev:75
https://jenkins.canonical.com/system-apps/job/lp-messaging-framework-ci/87/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/system-apps/job/build/1834/console
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1835
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1675
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1675/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1675
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1675/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1675
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1675/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1675
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1675/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1675
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1675/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1675
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1675/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1675
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1675/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1675
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1675/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1675/console

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-apps/job/lp-messaging-framework-ci/87/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

there was only one bug leading to a crash when using broadcast chats, but it is now fixed.
thanks.

review: Approve
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/messaging/group_manager.h'
--- include/messaging/group_manager.h 2016-09-14 07:44:10 +0000
+++ include/messaging/group_manager.h 2016-10-12 14:43:53 +0000
@@ -105,6 +105,9 @@
105 /// @brief creator returns the creator of the group being managed105 /// @brief creator returns the creator of the group being managed
106 virtual std::shared_ptr<Member> group_creator() = 0;106 virtual std::shared_ptr<Member> group_creator() = 0;
107107
108 /// @brief group_admins returns the list of admin identifiers
109 virtual std::set<std::string> group_admins() = 0;
110
108 /// @brief members returns current participants in the group.111 /// @brief members returns current participants in the group.
109 virtual Members members() = 0;112 virtual Members members() = 0;
110113
111114
=== modified file 'include/messaging/qt/tp/text_channel.h'
--- include/messaging/qt/tp/text_channel.h 2016-09-07 08:22:52 +0000
+++ include/messaging/qt/tp/text_channel.h 2016-10-12 14:43:53 +0000
@@ -211,6 +211,7 @@
211 void register_callbacks_once();211 void register_callbacks_once();
212 void plug_interfaces_once();212 void plug_interfaces_once();
213 void plug_interface_if_available(const Tp::AbstractChannelInterfacePtr &interface);213 void plug_interface_if_available(const Tp::AbstractChannelInterfacePtr &interface);
214 bool self_is_admin();
214215
215 Tp::BaseChannelTextTypePtr text_type_interface;216 Tp::BaseChannelTextTypePtr text_type_interface;
216 Tp::BaseChannelMessagesInterfacePtr messages_interface;217 Tp::BaseChannelMessagesInterfacePtr messages_interface;
217218
=== modified file 'src/messaging/qt/tp/connection.cpp'
--- src/messaging/qt/tp/connection.cpp 2016-10-12 14:43:53 +0000
+++ src/messaging/qt/tp/connection.cpp 2016-10-12 14:43:53 +0000
@@ -155,7 +155,8 @@
155 qRegisterMetaType<messaging::Recipient::shared_ptr>();155 qRegisterMetaType<messaging::Recipient::shared_ptr>();
156156
157 setSelfHandle(1);157 setSelfHandle(1);
158 handles_.insert(HandleIdPair(1, QString::fromStdString(connection->self_identifier())));158 setSelfID(QString::fromStdString(connection->normalize_identifier(connection->self_identifier())));
159 handles_.insert(HandleIdPair(selfHandle(), selfID()));
159160
160 // Wire up the actual request for connecting.161 // Wire up the actual request for connecting.
161 setConnectCallback(Tp::memFun(this, &tp::Connection::connect));162 setConnectCallback(Tp::memFun(this, &tp::Connection::connect));
@@ -594,7 +595,7 @@
594 {595 {
595 std::shared_ptr<GroupStarter> group_starter = connection->group_starter();596 std::shared_ptr<GroupStarter> group_starter = connection->group_starter();
596 group_manager = group_starter->accept_group(group);597 group_manager = group_starter->accept_group(group);
597 if (group_manager->group_id().empty())598 if (not group_manager || group_manager->group_id().empty())
598 {599 {
599 LOG(ERROR) << "Group creation rejected";600 LOG(ERROR) << "Group creation rejected";
600 error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");601 error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");
@@ -649,7 +650,7 @@
649 messaging::Group::shared_ptr group = std::dynamic_pointer_cast<messaging::Group>(recipient);650 messaging::Group::shared_ptr group = std::dynamic_pointer_cast<messaging::Group>(recipient);
650 group_manager = group_starter->rejoin_group(group);651 group_manager = group_starter->rejoin_group(group);
651652
652 if (group_manager->group_id().empty())653 if (not group_manager || group_manager->group_id().empty())
653 {654 {
654 LOG(ERROR) << "Group rejoin rejected";655 LOG(ERROR) << "Group rejoin rejected";
655 error->set(TP_QT_ERROR_CANCELLED, "Group rejoin rejected");656 error->set(TP_QT_ERROR_CANCELLED, "Group rejoin rejected");
@@ -761,7 +762,7 @@
761 messaging::Group::shared_ptr group = std::dynamic_pointer_cast<messaging::Group>(recipient);762 messaging::Group::shared_ptr group = std::dynamic_pointer_cast<messaging::Group>(recipient);
762 group_manager = group_starter->create_group(group);763 group_manager = group_starter->create_group(group);
763764
764 if (group_manager->group_id().empty())765 if (not group_manager || group_manager->group_id().empty())
765 {766 {
766 LOG(ERROR) << "Group creation rejected";767 LOG(ERROR) << "Group creation rejected";
767 error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");768 error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");
768769
=== modified file 'src/messaging/qt/tp/text_channel.cpp'
--- src/messaging/qt/tp/text_channel.cpp 2016-10-12 14:43:53 +0000
+++ src/messaging/qt/tp/text_channel.cpp 2016-10-12 14:43:53 +0000
@@ -757,10 +757,6 @@
757 QStringList member_ids;757 QStringList member_ids;
758 QStringList remote_member_ids;758 QStringList remote_member_ids;
759 interfaces::HandleRolesMap roles_map;759 interfaces::HandleRolesMap roles_map;
760 // flag assuming there is at least one admin (See if this is happening in all protocols and if this solution
761 // is valid for all them). In case any of the participants have admin role, we set it to self handle and add
762 // that to updating roles.
763 bool found_admin = false;
764760
765 for (auto member : received_members) {761 for (auto member : received_members) {
766762
@@ -800,11 +796,6 @@
800 }796 }
801 }797 }
802798
803 // search for admin in current member roles
804 if (member->roles().is_set(Role::Admin)) {
805 found_admin = true;
806 }
807
808 // add current member roles to map799 // add current member roles to map
809 roles_map[handle] = member->roles().underlying_type();800 roles_map[handle] = member->roles().underlying_type();
810 }801 }
@@ -816,7 +807,7 @@
816807
817 // if not found admin, add admin role to ourselves808 // if not found admin, add admin role to ourselves
818 interfaces::ChannelRoles self_roles(interfaces::ChannelRole::ChannelRoleMember);809 interfaces::ChannelRoles self_roles(interfaces::ChannelRole::ChannelRoleMember);
819 if (not found_admin) {810 if (self_is_admin()) {
820 self_roles |= interfaces::ChannelRole::ChannelRoleAdmin;811 self_roles |= interfaces::ChannelRole::ChannelRoleAdmin;
821 }812 }
822 roles_map[tp_connection->selfHandle()] = static_cast<uint>(self_roles);813 roles_map[tp_connection->selfHandle()] = static_cast<uint>(self_roles);
@@ -1191,3 +1182,21 @@
1191 }1182 }
1192 plugInterface(interface);1183 plugInterface(interface);
1193}1184}
1185
1186bool mqt::tp::TextChannel::self_is_admin()
1187{
1188 std::shared_ptr<messaging::GroupManager> group_manager = chat->interface<GroupManager>();
1189 if (!group_manager) {
1190 return false;
1191 }
1192 std::set<std::string> admins = group_manager->group_admins();
1193 std::string self_id = tp_connection->selfID().toStdString();
1194
1195 for (const std::string &admin : admins) {
1196 if (admin == self_id) {
1197 return true;
1198 }
1199 }
1200
1201 return false;
1202}
11941203
=== modified file 'tests/mock_group_manager.h'
--- tests/mock_group_manager.h 2016-09-14 07:36:33 +0000
+++ tests/mock_group_manager.h 2016-10-12 14:43:53 +0000
@@ -48,6 +48,7 @@
48 MOCK_METHOD0(group_title, std::string());48 MOCK_METHOD0(group_title, std::string());
49 MOCK_METHOD0(group_subject, std::string());49 MOCK_METHOD0(group_subject, std::string());
50 MOCK_METHOD0(group_creator, std::shared_ptr<messaging::Member>());50 MOCK_METHOD0(group_creator, std::shared_ptr<messaging::Member>());
51 MOCK_METHOD0(group_admins, std::set<std::string>());
51 MOCK_METHOD0(members, messaging::Members());52 MOCK_METHOD0(members, messaging::Members());
52 MOCK_METHOD1(set_observer, void(const std::shared_ptr<Observer>&));53 MOCK_METHOD1(set_observer, void(const std::shared_ptr<Observer>&));
53 MOCK_METHOD1(on_plugged, void(const std::weak_ptr<messaging::HasInterfaces>&));54 MOCK_METHOD1(on_plugged, void(const std::weak_ptr<messaging::HasInterfaces>&));

Subscribers

People subscribed via source and target branches

to all changes: