Merge lp:~phablet-team/messaging-framework/include-message-when-group-cancelled into lp:messaging-framework

Proposed by Roberto Mier Escandon
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 61
Merged at revision: 59
Proposed branch: lp:~phablet-team/messaging-framework/include-message-when-group-cancelled
Merge into: lp:messaging-framework
Diff against target: 304 lines (+63/-89)
6 files modified
debian/changelog (+7/-0)
include/messaging/group_manager.h (+8/-11)
include/messaging/qt/tp/text_channel.h (+9/-14)
src/CMakeLists.txt (+1/-0)
src/messaging/group_manager.cpp (+4/-17)
src/messaging/qt/tp/text_channel.cpp (+34/-47)
To merge this branch: bzr merge lp:~phablet-team/messaging-framework/include-message-when-group-cancelled
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
system-apps-ci-bot continuous-integration Approve
Review via email: mp+304000@code.launchpad.net

Commit message

Simplified Api for having only one callback for all possible group cancelled cases
added more enum cases as cancel reason

NOTE: this branch should be landed along with https://code.launchpad.net/~ningbo-team/ningbo/refine-error-messages/+merge/303998

Description of the change

Simplified Api for having only one callback for all possible group cancelled cases
added more enum cases as cancel reason

NOTE: this branch should be landed along with https://code.launchpad.net/~ningbo-team/ningbo/refine-error-messages/+merge/303998

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

PASSED: Continuous integration, rev:60
https://jenkins.canonical.com/system-apps/job/lp-messaging-framework-ci/45/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1321
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/298
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1321
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1185
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1185
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1185
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1165
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1165
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1165
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1165
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1165
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1165
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1165
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1165
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1165/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1165
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1165/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
61. By Roberto Mier Escandon

delay the close to let the events get to the client before the channel is closed

Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :

PASSED: Continuous integration, rev:61
https://jenkins.canonical.com/system-apps/job/lp-messaging-framework-ci/46/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build/1331
    SUCCESS: https://jenkins.canonical.com/system-apps/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=default/301
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-0-fetch/1331
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=vivid+overlay/1194
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=xenial+overlay/1194
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-1-sourcepkg/release=yakkety/1194
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1174
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1174/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1174
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1174/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1174
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=amd64,release=yakkety/1174/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1174
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1174/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1174
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1174/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1174
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=armhf,release=yakkety/1174/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1174
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=vivid+overlay/1174/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1174
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=xenial+overlay/1174/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1174
        deb: https://jenkins.canonical.com/system-apps/job/build-2-binpkg/arch=i386,release=yakkety/1174/artifact/output/*zip*/output.zip

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

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

tested and works fine.
code looks good too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-08-16 20:11:02 +0000
3+++ debian/changelog 2016-08-26 14:12:00 +0000
4@@ -1,3 +1,10 @@
5+messaging-framework (0.1-1ubuntu25) vivid; urgency=medium
6+
7+ * Fixed self handle included in members
8+ * Simplified group cancelled api callbacks reducing them to only one
9+
10+ -- Roberto Mier Escandon <roberto.escandon@canonical.com> Thu, 25 Aug 2016 22:06:07 +0200
11+
12 messaging-framework (0.1-1ubuntu24) vivid; urgency=medium
13
14 * Implemented code to update group member roles in client
15
16=== modified file 'include/messaging/group_manager.h'
17--- include/messaging/group_manager.h 2016-08-23 22:33:39 +0000
18+++ include/messaging/group_manager.h 2016-08-26 14:12:00 +0000
19@@ -42,10 +42,12 @@
20
21 enum class CancelGroupReason
22 {
23- None,
24- Kicked,
25- Gone,
26- Error
27+ None, ///< No or unknown reason
28+ Error, ///< Generic error makes this group temporally or permanent unavaliable for us
29+ Rejected, ///< Group creation or rejoin was rejected
30+ Kicked, ///< We were expelled from group
31+ Gone, ///< Group is gone in server side and is not available anymore
32+ Leave ///< We leave the group
33 };
34
35 /// @brief GroupManager models a textual group conversation.
36@@ -59,9 +61,7 @@
37 virtual ~Observer() = default;
38
39 virtual void on_group_created() = 0;
40- virtual void on_group_creation_rejected() = 0;
41- virtual void on_group_cancelled(CancelGroupReason reason) = 0;
42- virtual void on_group_quit() = 0;
43+ virtual void on_group_cancelled(CancelGroupReason reason, const std::string &message) = 0;
44 virtual void on_group_title_changed(const std::string& new_title,
45 const Member& actor,
46 const std::chrono::system_clock::time_point& when) = 0;
47@@ -116,10 +116,7 @@
48 void validate_observer();
49
50 void announce_group_created();
51- //TODO TRACE maybe a reason as parameter for knowing the rejected cause?
52- void announce_group_creation_rejected();
53- void announce_group_cancelled(CancelGroupReason reason);
54- void announce_group_quit();
55+ void announce_group_cancelled(CancelGroupReason reason, const std::string& message);
56 void announce_group_title_changed(const std::string& new_title,
57 const Member& actor = Member{std::string{}},
58 const std::chrono::system_clock::time_point& when = std::chrono::system_clock::now());
59
60=== modified file 'include/messaging/qt/tp/text_channel.h'
61--- include/messaging/qt/tp/text_channel.h 2016-08-16 16:31:31 +0000
62+++ include/messaging/qt/tp/text_channel.h 2016-08-26 14:12:00 +0000
63@@ -20,7 +20,11 @@
64 #include <messaging/chat.h>
65 #include <messaging/messenger.h>
66 #include <messaging/qt/runtime.h>
67+
68+#include <messaging/qt/tp/interfaces/base_channel_destroyable.h>
69+#include <messaging/qt/tp/interfaces/base_channel_roles.h>
70 #include <messaging/qt/tp/interfaces/types.h>
71+#include <messaging/qt/tp/interfaces/constants.h>
72
73 #include <TelepathyQt/BaseChannel>
74 #include <TelepathyQt/Types>
75@@ -45,6 +49,7 @@
76 , public messaging::Chat::Observer
77 , public messaging::GroupManager::Observer
78 {
79+ Q_OBJECT
80 public:
81 /// @brief Safes us some typing.
82 typedef Tp::SharedPtr<TextChannel> Ptr;
83@@ -72,14 +77,8 @@
84 /// @brief on_group_created when the group has been created ok in the server
85 void on_group_created() override;
86
87- /// @brief on_group_creation_rejected when the group creation has been rejected by the server
88- void on_group_creation_rejected() override;
89-
90 /// @brief on_group_cancelled when the group is no longer valid
91- void on_group_cancelled(CancelGroupReason reason) override;
92-
93- /// @brief on_group_quit when confirmed leaving a group
94- void on_group_quit() override;
95+ void on_group_cancelled(CancelGroupReason reason, const std::string &message) override;
96
97 /// @brief on_group_title_changed when group title has changed in the server
98 void on_group_title_changed(const std::string& new_title,
99@@ -107,6 +106,8 @@
100 /// @brief on_participant_ends_typing is invoked when a participant in this chat ends composing a message
101 void on_participant_ends_typing(const std::shared_ptr<User> &user) override;
102
103+public Q_SLOTS:
104+ void delay_close();
105
106 private:
107 TextChannel(Connection* tp_connection,
108@@ -143,14 +144,8 @@
109 /// @brief on_group_created when the group has been created ok in the server
110 void on_group_created() override;
111
112- /// @brief on_group_creation_rejected when the group creation has been rejected by the server
113- void on_group_creation_rejected() override;
114-
115 /// @brief on_group_cancelled when the group is no longer valid
116- void on_group_cancelled(CancelGroupReason reason) override;
117-
118- /// @brief on_group_quit when confirmed leaving a group
119- void on_group_quit() override;
120+ void on_group_cancelled(CancelGroupReason reason, const std::string &message) override;
121
122 /// @brief on_group_title_changed when group title has changed in the server
123 void on_group_title_changed(const std::string& new_title,
124
125=== modified file 'src/CMakeLists.txt'
126--- src/CMakeLists.txt 2016-08-11 21:39:57 +0000
127+++ src/CMakeLists.txt 2016-08-26 14:12:00 +0000
128@@ -4,6 +4,7 @@
129 qt5_wrap_cpp(MESSAGING_FW_MOCS ${CMAKE_SOURCE_DIR}/include/messaging/qt/network_monitor.h
130 ${CMAKE_SOURCE_DIR}/include/messaging/qt/tp/protocol.h
131 ${CMAKE_SOURCE_DIR}/include/messaging/qt/tp/connection.h
132+ ${CMAKE_SOURCE_DIR}/include/messaging/qt/tp/text_channel.h
133 ${CMAKE_SOURCE_DIR}/include/messaging/qt/tp/interfaces/base_channel_destroyable.h
134 ${CMAKE_SOURCE_DIR}/include/messaging/qt/tp/interfaces/base_channel_destroyable_internal.h
135 ${CMAKE_SOURCE_DIR}/include/messaging/qt/tp/interfaces/base_channel_roles.h
136
137=== modified file 'src/messaging/group_manager.cpp'
138--- src/messaging/group_manager.cpp 2016-08-16 14:47:42 +0000
139+++ src/messaging/group_manager.cpp 2016-08-26 14:12:00 +0000
140@@ -58,23 +58,10 @@
141 impl->observer->on_group_created();
142 }
143
144-void messaging::GroupManager::announce_group_creation_rejected()
145-{
146- validate_observer();
147- impl->observer->on_group_creation_rejected();
148-}
149-
150-
151-void messaging::GroupManager::announce_group_cancelled(CancelGroupReason reason)
152-{
153- validate_observer();
154- impl->observer->on_group_cancelled(reason);
155-}
156-
157-void messaging::GroupManager::announce_group_quit()
158-{
159- validate_observer();
160- impl->observer->on_group_quit();
161+void messaging::GroupManager::announce_group_cancelled(CancelGroupReason reason, const std::string &message)
162+{
163+ validate_observer();
164+ impl->observer->on_group_cancelled(reason, message);
165 }
166
167 void messaging::GroupManager::announce_group_title_changed(const std::string &new_title,
168
169=== modified file 'src/messaging/qt/tp/text_channel.cpp'
170--- src/messaging/qt/tp/text_channel.cpp 2016-08-24 20:10:27 +0000
171+++ src/messaging/qt/tp/text_channel.cpp 2016-08-26 14:12:00 +0000
172@@ -19,11 +19,6 @@
173 #include <messaging/qt/tp/connection.h>
174 #include <messaging/qt/tp/message.h>
175
176-#include <messaging/qt/tp/interfaces/base_channel_destroyable.h>
177-#include <messaging/qt/tp/interfaces/base_channel_roles.h>
178-#include <messaging/qt/tp/interfaces/types.h>
179-#include <messaging/qt/tp/interfaces/constants.h>
180-
181 #include <messaging/qt/variant.h>
182
183 #include <messaging/connection.h>
184@@ -178,27 +173,11 @@
185 });
186 }
187
188-void mqt::tp::TextChannel::Observer::on_group_creation_rejected()
189-{
190- auto sp = shared_from_this();
191- runtime->enter_with_task([sp](){
192- sp->tc->on_group_creation_rejected();
193- });
194-}
195-
196-void mqt::tp::TextChannel::Observer::on_group_cancelled(CancelGroupReason reason)
197-{
198- auto thiz = shared_from_this();
199- runtime->enter_with_task([thiz, reason]() {
200- thiz->tc->on_group_cancelled(reason);
201- });
202-}
203-
204-void mqt::tp::TextChannel::Observer::on_group_quit()
205-{
206- auto thiz = shared_from_this();
207- runtime->enter_with_task([thiz]() {
208- thiz->tc->on_group_quit();
209+void mqt::tp::TextChannel::Observer::on_group_cancelled(CancelGroupReason reason, const std::string &message)
210+{
211+ auto thiz = shared_from_this();
212+ runtime->enter_with_task([thiz, reason, message]() {
213+ thiz->tc->on_group_cancelled(reason, message);
214 });
215 }
216
217@@ -612,12 +591,6 @@
218
219 }
220
221-void mqt::tp::TextChannel::on_group_creation_rejected()
222-{
223- LOG(INFO) << __PRETTY_FUNCTION__ ;
224- close_channel_with_reason(Tp::ChannelGroupChangeReasonError, "Group creation rejected");
225-}
226-
227 void mqt::tp::TextChannel::close_channel_with_reason(uint reason, const QString &message)
228 {
229 // At this point, self handle should be removed from the group members, providing one of the reasons
230@@ -637,11 +610,18 @@
231
232 group_interface->setMembers(members, details);
233
234+ // It is needed to delay the close channel action to be sure the events related with previous action of removing
235+ // self handle from members are sent to clients and processed before the channel expires.
236+ QTimer::singleShot(2000, this, SLOT(delay_close()));
237+
238+}
239+
240+void mqt::tp::TextChannel::delay_close()
241+{
242 close();
243 }
244
245-
246-void mqt::tp::TextChannel::on_group_cancelled(CancelGroupReason cancel_reason)
247+void mqt::tp::TextChannel::on_group_cancelled(CancelGroupReason cancel_reason, const std::string &cancel_message)
248 {
249 LOG(INFO) << __PRETTY_FUNCTION__;
250
251@@ -649,18 +629,25 @@
252 QString message;
253 switch (cancel_reason)
254 {
255+ case CancelGroupReason::Error:
256+ reason = Tp::ChannelGroupChangeReasonError;
257+ message = "Group is closed due to an error";
258+ break;
259+ case CancelGroupReason::Rejected:
260+ reason = Tp::ChannelGroupChangeReasonError;
261+ message = "Group creation rejected";
262+ break;
263+ case CancelGroupReason::Kicked:
264+ reason = Tp::ChannelGroupChangeReasonKicked;
265+ message = "You were expelled from group";
266+ break;
267 case CancelGroupReason::Gone:
268 reason = Tp::ChannelGroupChangeReasonBanned;
269 message = "Group not available anymore";
270 break;
271- case CancelGroupReason::Kicked:
272- reason = Tp::ChannelGroupChangeReasonKicked;
273- message = "You were expelled from group";
274- break;
275- case CancelGroupReason::Error:
276- reason = Tp::ChannelGroupChangeReasonError;
277- message = "Group is closed due to an error";
278- break;
279+ case CancelGroupReason::Leave:
280+ reason = Tp::ChannelGroupChangeReasonNone;
281+ message = "Quit group";
282 case CancelGroupReason::None:
283 default:
284 reason = Tp::ChannelGroupChangeReasonNone;
285@@ -668,14 +655,14 @@
286 break;
287 }
288
289+ // cancel message overwrites default one in case it is not empty
290+ if (not cancel_message.empty()) {
291+ message = QString::fromStdString(cancel_message);
292+ }
293+
294 close_channel_with_reason(reason, message);
295 }
296
297-void mqt::tp::TextChannel::on_group_quit()
298-{
299- close_channel_with_reason(Tp::ChannelGroupChangeReasonNone, "Quit group");
300-}
301-
302 void mqt::tp::TextChannel::on_group_title_changed(const std::string &new_title,
303 const Member& actor,
304 const std::chrono::system_clock::time_point& when)

Subscribers

People subscribed via source and target branches

to all changes: