Merge lp:~phablet-team/messaging-framework/enable_message_broadcast into lp:messaging-framework

Proposed by Roberto Mier Escandon
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 67
Merged at revision: 66
Proposed branch: lp:~phablet-team/messaging-framework/enable_message_broadcast
Merge into: lp:messaging-framework
Prerequisite: lp:~phablet-team/messaging-framework/fix-roles-interface-event
Diff against target: 411 lines (+199/-76)
8 files modified
include/messaging/broadcast.h (+45/-0)
include/messaging/group_starter.h (+5/-0)
include/messaging/recipient.h (+2/-1)
src/CMakeLists.txt (+1/-0)
src/messaging/broadcast.cpp (+37/-0)
src/messaging/qt/tp/connection.cpp (+84/-73)
src/messaging/qt/tp/text_channel.cpp (+24/-2)
tests/mock_group_starter.h (+1/-0)
To merge this branch: bzr merge lp:~phablet-team/messaging-framework/enable_message_broadcast
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Approve
Tiago Salem Herrmann (community) Approve
Review via email: mp+307017@code.launchpad.net

This proposal supersedes a proposal from 2016-09-17.

Commit message

Add a broadcast recipient type and make it possible to use broadcast text
channels.

Description of the change

Add a broadcast recipient type and make it possible to use broadcast text
channels.

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

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

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

review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:63
https://jenkins.canonical.com/system-apps/job/lp-messaging-framework-ci/76/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1542
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/356
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1542
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1390
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1390/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1390
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1390/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1390
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1390/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1390
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1390/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1390
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1390/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1390
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1390/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1390
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1390/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1390
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1390/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1390
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1390/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:64
https://jenkins.canonical.com/system-apps/job/lp-messaging-framework-ci/83/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1634
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/387
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1634
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1481
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1481
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1481
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1481
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1481
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1481
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1481
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1481
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1481/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1481
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1481/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote : Posted in a previous version of this proposal

PASSED: Continuous integration, rev:65
https://jenkins.canonical.com/system-apps/job/lp-messaging-framework-ci/84/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1647
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/393
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1647
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1493
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1493/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1493
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1493/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1493
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1493/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1493
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1493/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1493
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1493/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1493
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1493/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1493
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1493/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1493
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1493/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1493
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1493/artifact/output/*zip*/output.zip

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

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

PASSED: Continuous integration, rev:67
https://jenkins.canonical.com/system-apps/job/lp-messaging-framework-ci/85/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1650
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/395
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1650
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1496
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1496/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1496
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1496/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1496
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1496/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1496
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1496/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1496
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1496/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1496
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1496/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1496
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1496/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1496
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1496/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1496
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1496/artifact/output/*zip*/output.zip

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

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

works fine. broadcast messages are getting correctly sent as sms.
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
1=== added file 'include/messaging/broadcast.h'
2--- include/messaging/broadcast.h 1970-01-01 00:00:00 +0000
3+++ include/messaging/broadcast.h 2016-09-28 12:29:15 +0000
4@@ -0,0 +1,45 @@
5+/*
6+ * Copyright © 2016 Canonical Ltd.
7+ *
8+ * This program is free software: you can redistribute it and/or modify it
9+ * under the terms of the GNU Lesser General Public License version 3,
10+ * as published by the Free Software Foundation.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21+#ifndef BROADCAST_H
22+#define BROADCAST_H
23+
24+#include <messaging/recipient.h>
25+#include <messaging/member.h>
26+#include <messaging/members.h>
27+
28+namespace messaging
29+{
30+
31+class MESSAGING_FW_PUBLIC Broadcast : public Recipient
32+{
33+public:
34+ Broadcast(const std::string &id, const Members &members = Members{});
35+
36+ RecipientType type() const override;
37+ Members members() const;
38+
39+ typedef std::shared_ptr<Broadcast> shared_ptr;
40+private:
41+ /// @cond
42+ struct Private;
43+ std::shared_ptr<Private> impl;
44+ /// @endcond
45+};
46+
47+}
48+
49+#endif // BROADCAST_H
50
51=== modified file 'include/messaging/group_starter.h'
52--- include/messaging/group_starter.h 2016-06-14 14:25:54 +0000
53+++ include/messaging/group_starter.h 2016-09-28 12:29:15 +0000
54@@ -4,6 +4,7 @@
55 #include <messaging/visibility.h>
56 #include <messaging/non_copyable.h>
57 #include <messaging/non_movable.h>
58+#include <messaging/members.h>
59
60 #include <memory>
61
62@@ -12,6 +13,7 @@
63
64 class Group;
65 class GroupManager;
66+class Broadcast;
67
68 /// @brief GroupStarter models the object for group creation
69 class MESSAGING_FW_PUBLIC GroupStarter : public NonCopyable, NonMovable
70@@ -31,6 +33,9 @@
71 /// @brief reject_group rejects establishing a group with the parameter
72 virtual void reject_group(const std::shared_ptr<Group> &group) = 0;
73
74+ /// @brief create_broadcast creates a broadcast group where sending messages to several recipients
75+ virtual std::shared_ptr<Broadcast> create_broadcast(const Members& recipients) = 0;
76+
77 protected:
78 /// @brief GroupStarter constructs a new instance.
79 GroupStarter() = default;
80
81=== modified file 'include/messaging/recipient.h'
82--- include/messaging/recipient.h 2016-03-30 19:19:19 +0000
83+++ include/messaging/recipient.h 2016-09-28 12:29:15 +0000
84@@ -26,7 +26,8 @@
85 enum RecipientType
86 {
87 user, ///< the peer is a user
88- group ///< the peer is a group
89+ group, ///< the peer is a group
90+ broadcast ///< the peer is a broadcast group
91 };
92
93 class MESSAGING_FW_PUBLIC Recipient
94
95=== modified file 'src/CMakeLists.txt'
96--- src/CMakeLists.txt 2016-09-05 15:10:42 +0000
97+++ src/CMakeLists.txt 2016-09-28 12:29:15 +0000
98@@ -18,6 +18,7 @@
99
100 messaging/associative_connector_factory.cpp
101 messaging/boost/variant.cpp
102+ messaging/broadcast.cpp
103 messaging/chat.cpp
104 messaging/group.cpp
105 messaging/group_manager.cpp
106
107=== added file 'src/messaging/broadcast.cpp'
108--- src/messaging/broadcast.cpp 1970-01-01 00:00:00 +0000
109+++ src/messaging/broadcast.cpp 2016-09-28 12:29:15 +0000
110@@ -0,0 +1,37 @@
111+/*
112+ * Copyright © 2016 Canonical Ltd.
113+ *
114+ * This program is free software: you can redistribute it and/or modify it
115+ * under the terms of the GNU Lesser General Public License version 3,
116+ * as published by the Free Software Foundation.
117+ *
118+ * This program is distributed in the hope that it will be useful,
119+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
120+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
121+ * GNU Lesser General Public License for more details.
122+ *
123+ * You should have received a copy of the GNU Lesser General Public License
124+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
125+ */
126+
127+#include <messaging/broadcast.h>
128+
129+struct messaging::Broadcast::Private
130+{
131+ messaging::Members members;
132+};
133+
134+messaging::Broadcast::Broadcast(const std::string &id, const messaging::Members &members)
135+ : Recipient{id}, impl{new Private{members}}
136+{
137+}
138+
139+messaging::RecipientType messaging::Broadcast::type() const
140+{
141+ return messaging::RecipientType::broadcast;
142+}
143+
144+messaging::Members messaging::Broadcast::members() const
145+{
146+ return impl->members;
147+}
148
149=== modified file 'src/messaging/qt/tp/connection.cpp'
150--- src/messaging/qt/tp/connection.cpp 2016-09-14 09:46:24 +0000
151+++ src/messaging/qt/tp/connection.cpp 2016-09-28 12:29:15 +0000
152@@ -22,6 +22,7 @@
153 #include <messaging/qt/tp/interfaces/base_channel_destroyable.h>
154 #include <messaging/qt/tp/interfaces/base_channel_roles.h>
155
156+#include <messaging/broadcast.h>
157 #include <messaging/message.h>
158 #include <messaging/presence_status_not_supported.h>
159 #include <messaging/user.h>
160@@ -685,12 +686,15 @@
161 break;
162 }
163 case Tp::HandleTypeNone: {
164- // This is the case of creating a group from the app. There is not type for the handle of the channel to be created when
165+ bool is_room = hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_ROOM + QLatin1String(".RoomName"));
166+
167+ // There are two possible cases in which handle type is going to be none: chat rooms and broadcast channels.
168+ // For broadcast channels the handle type will remain as none during the entire channel lifetime. For chat rooms
169+ // once the creation is finished, the type will change to room.
170+ // For the chat room case, this code will be called when creating a group from the app.
171+ // There is not type for the handle of the channel to be created when
172 // received the request. We have to switch to Room type and get the provided information
173-
174 messaging::Members initial_invitees;
175- std::string title;
176- auto additional_properties = VariantMap{};
177 if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeIDs")))
178 {
179 QStringList initial_invitees_ids =
180@@ -711,85 +715,92 @@
181 //FIXME: get contact attribute display name for the user second param
182 //FIXME: consider here if needed to provide initial roles to members
183 initial_invitees.push_back(std::make_shared<Member>(normalized_id,
184- PendingStatus::Remote,
185+ is_room ? PendingStatus::Remote : PendingStatus::None,
186 Flags<Role>(Role::Member),
187 std::string{}/* display_name*/ ));
188 }
189 }
190
191- if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_ROOM_CONFIG + QLatin1String(".Title")))
192- {
193- title = hints[TP_QT_IFACE_CHANNEL_INTERFACE_ROOM_CONFIG + QLatin1String(".Title")].toString().toStdString();
194- }
195-
196 // check if the client requested a chat room
197- if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_ROOM + QLatin1String(".RoomName")))
198+ // if so, create the group related stuff
199+ if (is_room)
200 {
201 target_handle_type = Tp::HandleTypeRoom;
202- }
203-
204- std::string initiator_handle;
205- if (hints.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".InitiatorHandle")))
206- {
207- initiator_handle = hints[TP_QT_IFACE_CHANNEL + QLatin1String(".InitiatorHandle")].toString().toStdString();
208- }
209-
210- if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_SUBJECT + QLatin1String(".Subject")))
211- {
212- additional_properties[Group::SUBJECT] =
213- std::make_shared<messaging::BoostVariant>(
214- hints[TP_QT_IFACE_CHANNEL_INTERFACE_SUBJECT + QLatin1String(".Subject")].toString().toStdString());
215- }
216-
217- //FIXME: fill group title parameter when got somehow
218- // create initial group recipient with no identifier for plugin to create the group
219- recipient = std::make_shared<messaging::Group>(
220- std::string{} /* no id exists yet */,
221- initial_invitees,
222- title,
223- std::make_shared<messaging::Member>(initiator_handle),
224- additional_properties);
225-
226- try
227- {
228- std::shared_ptr<GroupStarter> group_starter = connection->group_starter();
229- messaging::Group::shared_ptr group = std::dynamic_pointer_cast<messaging::Group>(recipient);
230- group_manager = group_starter->create_group(group);
231- if (group_manager->group_id().empty())
232- {
233- LOG(ERROR) << "Group creation rejected";
234- error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");
235- return Tp::BaseChannelPtr{};
236- }
237-
238- // update recipient with id, title and members
239- auto additional_properties = group->additional_properties();
240- if (not group_manager->group_subject().empty()) {
241- additional_properties[Group::SUBJECT] = std::make_shared<messaging::BoostVariant>(group_manager->group_subject());
242- }
243+
244+ std::string title;
245+ auto additional_properties = VariantMap{};
246+
247+ if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_ROOM_CONFIG + QLatin1String(".Title")))
248+ {
249+ title = hints[TP_QT_IFACE_CHANNEL_INTERFACE_ROOM_CONFIG + QLatin1String(".Title")].toString().toStdString();
250+ }
251+
252+ std::string initiator_handle;
253+ if (hints.contains(TP_QT_IFACE_CHANNEL + QLatin1String(".InitiatorHandle")))
254+ {
255+ initiator_handle = hints[TP_QT_IFACE_CHANNEL + QLatin1String(".InitiatorHandle")].toString().toStdString();
256+ }
257+
258+ if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_SUBJECT + QLatin1String(".Subject")))
259+ {
260+ additional_properties[Group::SUBJECT] =
261+ std::make_shared<messaging::BoostVariant>(
262+ hints[TP_QT_IFACE_CHANNEL_INTERFACE_SUBJECT + QLatin1String(".Subject")].toString().toStdString());
263+ }
264+
265+ // create initial group recipient with no identifier for plugin to create the group
266 recipient = std::make_shared<messaging::Group>(
267- group_manager->group_id(),
268- group_manager->members(),
269- group_manager->group_title(),
270- group_manager->group_creator(),
271+ std::string{} /* no id exists yet */,
272+ initial_invitees,
273+ title,
274+ std::make_shared<messaging::Member>(initiator_handle),
275 additional_properties);
276- }
277- catch (const std::exception &e)
278- {
279- LOG(ERROR) << "Group creation rejected, " << e.what();
280- error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");
281- return Tp::BaseChannelPtr{};
282- }
283- catch (...)
284- {
285- LOG(ERROR) << "Group creation rejected";
286- error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");
287- return Tp::BaseChannelPtr{};
288- }
289-
290- // request handle from group_manager id, filled with the group id after calling start_group()
291- Tp::DBusError error;
292- target_handle = request_handles(Tp::HandleTypeRoom, QStringList() << QString::fromStdString(group_manager->group_id()), &error)[0];
293+ try
294+ {
295+ std::shared_ptr<GroupStarter> group_starter = connection->group_starter();
296+ messaging::Group::shared_ptr group = std::dynamic_pointer_cast<messaging::Group>(recipient);
297+ group_manager = group_starter->create_group(group);
298+
299+ if (group_manager->group_id().empty())
300+ {
301+ LOG(ERROR) << "Group creation rejected";
302+ error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");
303+ return Tp::BaseChannelPtr{};
304+ }
305+
306+ // update recipient with id, title, members and additional properties
307+ auto additional_properties = group->additional_properties();
308+ if (not group_manager->group_subject().empty()) {
309+ additional_properties[Group::SUBJECT] = std::make_shared<messaging::BoostVariant>(group_manager->group_subject());
310+ }
311+ recipient = std::make_shared<messaging::Group>(
312+ group_manager->group_id(),
313+ group_manager->members(),
314+ group_manager->group_title(),
315+ group_manager->group_creator(),
316+ additional_properties);
317+ }
318+ catch (const std::exception &e)
319+ {
320+ LOG(ERROR) << "Group creation rejected, " << e.what();
321+ error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");
322+ return Tp::BaseChannelPtr{};
323+ }
324+ catch (...)
325+ {
326+ LOG(ERROR) << "Group creation rejected";
327+ error->set(TP_QT_ERROR_CANCELLED, "Group creation rejected");
328+ return Tp::BaseChannelPtr{};
329+ }
330+
331+ // request handle from group_manager id, filled with the group id after calling start_group()
332+ Tp::DBusError error;
333+ target_handle = request_handles(Tp::HandleTypeRoom, QStringList() << QString::fromStdString(group_manager->group_id()), &error)[0];
334+ } else {
335+ // if not, consider this a broadcast channel
336+ std::shared_ptr<GroupStarter> group_starter = connection->group_starter();
337+ recipient = group_starter->create_broadcast(initial_invitees);
338+ }
339 break;
340 }
341 default:
342
343=== modified file 'src/messaging/qt/tp/text_channel.cpp'
344--- src/messaging/qt/tp/text_channel.cpp 2016-09-28 12:29:15 +0000
345+++ src/messaging/qt/tp/text_channel.cpp 2016-09-28 12:29:15 +0000
346@@ -22,6 +22,7 @@
347
348 #include <messaging/qt/variant.h>
349
350+#include <messaging/broadcast.h>
351 #include <messaging/connection.h>
352 #include <messaging/group.h>
353 #include <messaging/messenger.h>
354@@ -387,7 +388,7 @@
355 group_interface->setGroupFlags(groupFlags);
356
357 roles_interface = interfaces::BaseChannelRolesInterface::create();
358-
359+
360 // we need to plug this interface here to avoid a crash
361 plug_interface_if_available(group_interface);
362
363@@ -396,6 +397,24 @@
364 // we need to set the initial group members
365 on_members_updated(group->initial_invitees());
366 }
367+ else if (recipient->type() == RecipientType::broadcast)
368+ {
369+ messaging::Broadcast::shared_ptr broadcast = std::dynamic_pointer_cast<messaging::Broadcast>(recipient);
370+ // for broadcast channels we just need to plug the group interface with limited capabilities
371+ Tp::ChannelGroupFlags groupFlags = Tp::ChannelGroupFlagHandleOwnersNotAvailable |
372+ Tp::ChannelGroupFlagMembersChangedDetailed |
373+ Tp::ChannelGroupFlagProperties;
374+ group_interface = Tp::BaseChannelGroupInterface::create();
375+ group_interface->setGroupFlags(groupFlags);
376+
377+ // we need to plug this interface here to avoid a crash
378+ plug_interface_if_available(group_interface);
379+
380+ destroyable_interface = mqt::tp::interfaces::BaseChannelDestroyableInterface::create();
381+
382+ // we need to set the initial group members
383+ on_members_updated(broadcast->members());
384+ }
385
386 chat_state_interface = Tp::BaseChannelChatStateInterface::create();
387
388@@ -810,7 +829,10 @@
389 handles << tp_connection->selfHandle();
390
391 group_interface->setMembers(handles, local_info_list, remote_handles, /* details */ QVariantMap());
392- roles_interface->setRoles(roles_map);
393+ if (!roles_interface.isNull())
394+ {
395+ roles_interface->setRoles(roles_map);
396+ }
397 }
398
399 /*!
400
401=== modified file 'tests/mock_group_starter.h'
402--- tests/mock_group_starter.h 2016-06-14 14:25:54 +0000
403+++ tests/mock_group_starter.h 2016-09-28 12:29:15 +0000
404@@ -17,6 +17,7 @@
405 MOCK_METHOD1(accept_group, std::shared_ptr<messaging::GroupManager>(const std::shared_ptr<messaging::Group>&));
406 MOCK_METHOD1(rejoin_group, std::shared_ptr<messaging::GroupManager>(const std::shared_ptr<messaging::Group>&));
407 MOCK_METHOD1(reject_group, void(const std::shared_ptr<messaging::Group>&));
408+ MOCK_METHOD1(create_broadcast, std::shared_ptr<messaging::Broadcast>(const messaging::Members&));
409 };
410
411 }

Subscribers

People subscribed via source and target branches

to all changes: