Merge lp:~phablet-team/history-service/improve_participant_changes_notification into lp:history-service/staging
- improve_participant_changes_notification
- Merge into staging
Proposed by
Gustavo Pichorim Boiko
Status: | Merged |
---|---|
Approved by: | Gustavo Pichorim Boiko |
Approved revision: | 258 |
Merged at revision: | 256 |
Proposed branch: | lp:~phablet-team/history-service/improve_participant_changes_notification |
Merge into: | lp:history-service/staging |
Prerequisite: | lp:~phablet-team/history-service/voip_support |
Diff against target: |
703 lines (+219/-37) 21 files modified
Ubuntu/History/historythreadmodel.cpp (+18/-0) Ubuntu/History/historythreadmodel.h (+1/-0) daemon/HistoryService.xml (+13/-0) daemon/historydaemon.cpp (+63/-29) daemon/historydaemon.h (+6/-6) daemon/historyservicedbus.cpp (+8/-0) daemon/historyservicedbus.h (+8/-0) plugins/sqlite/sqlitehistoryplugin.cpp (+7/-2) src/manager.cpp (+3/-0) src/manager.h (+1/-0) src/managerdbus.cpp (+17/-0) src/managerdbus_p.h (+8/-0) src/participant.cpp (+9/-0) src/participant.h (+1/-0) src/thread.cpp (+16/-0) src/thread.h (+2/-0) src/threadview.cpp (+15/-0) src/threadview.h (+8/-0) src/threadview_p.h (+4/-0) src/utils.cpp (+10/-0) src/utils_p.h (+1/-0) |
To merge this branch: | bzr merge lp:~phablet-team/history-service/improve_participant_changes_notification |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gustavo Pichorim Boiko (community) | Approve | ||
Review via email: mp+320636@code.launchpad.net |
This proposal supersedes a proposal from 2017-02-01.
Commit message
Improve the notifications of participants changing
Description of the change
Improve the notifications of participants changing
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Ubuntu/History/historythreadmodel.cpp' |
2 | --- Ubuntu/History/historythreadmodel.cpp 2016-06-17 01:49:46 +0000 |
3 | +++ Ubuntu/History/historythreadmodel.cpp 2017-03-22 14:00:18 +0000 |
4 | @@ -294,6 +294,10 @@ |
5 | SIGNAL(threadsRemoved(History::Threads)), |
6 | SLOT(onThreadsRemoved(History::Threads))); |
7 | connect(mThreadView.data(), |
8 | + SIGNAL(threadParticipantsChanged(History::Thread, History::Participants, History::Participants, History::Participants)), |
9 | + SLOT(onThreadParticipantsChanged(History::Thread, History::Participants, History::Participants, History::Participants))); |
10 | + |
11 | + connect(mThreadView.data(), |
12 | SIGNAL(invalidated()), |
13 | SLOT(triggerQueryUpdate())); |
14 | |
15 | @@ -311,6 +315,20 @@ |
16 | fetchMore(QModelIndex()); |
17 | } |
18 | |
19 | + |
20 | +void HistoryThreadModel::onThreadParticipantsChanged(const History::Thread &thread, const History::Participants &added, const History::Participants &removed, const History::Participants &modified) |
21 | +{ |
22 | + int pos = mThreads.indexOf(thread); |
23 | + if (pos >= 0) { |
24 | + mThreads[pos].removeParticipants(removed); |
25 | + mThreads[pos].removeParticipants(modified); |
26 | + mThreads[pos].addParticipants(added); |
27 | + mThreads[pos].addParticipants(modified); |
28 | + QModelIndex idx = index(pos); |
29 | + Q_EMIT dataChanged(idx, idx); |
30 | + } |
31 | +} |
32 | + |
33 | void HistoryThreadModel::onThreadsAdded(const History::Threads &threads) |
34 | { |
35 | if (threads.isEmpty()) { |
36 | |
37 | === modified file 'Ubuntu/History/historythreadmodel.h' |
38 | --- Ubuntu/History/historythreadmodel.h 2016-06-17 01:49:46 +0000 |
39 | +++ Ubuntu/History/historythreadmodel.h 2017-03-22 14:00:18 +0000 |
40 | @@ -76,6 +76,7 @@ |
41 | virtual void onThreadsAdded(const History::Threads &threads); |
42 | virtual void onThreadsModified(const History::Threads &threads); |
43 | virtual void onThreadsRemoved(const History::Threads &threads); |
44 | + virtual void onThreadParticipantsChanged(const History::Thread &thread, const History::Participants &added, const History::Participants &removed, const History::Participants &modified); |
45 | |
46 | protected: |
47 | History::Threads fetchNextPage(); |
48 | |
49 | === modified file 'daemon/HistoryService.xml' |
50 | --- daemon/HistoryService.xml 2016-04-15 22:23:21 +0000 |
51 | +++ daemon/HistoryService.xml 2017-03-22 14:00:18 +0000 |
52 | @@ -159,5 +159,18 @@ |
53 | <arg name="events" type="a(a{sv})"/> |
54 | <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QList < QVariantMap >"/> |
55 | </signal> |
56 | + <signal name="ThreadParticipantsChanged"> |
57 | + <dox:d><![CDATA[ |
58 | + Participants changed in a certain thread changed. |
59 | + ]]></dox:d> |
60 | + <arg name="thread" type="a{sv}"/> |
61 | + <arg name="added" type="a(a{sv})"/> |
62 | + <arg name="removed" type="a(a{sv})"/> |
63 | + <arg name="modified" type="a(a{sv})"/> |
64 | + <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/> |
65 | + <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QList < QVariantMap >"/> |
66 | + <annotation name="org.qtproject.QtDBus.QtTypeName.In2" value="QList < QVariantMap >"/> |
67 | + <annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QList < QVariantMap >"/> |
68 | + </signal> |
69 | </interface> |
70 | </node> |
71 | |
72 | === modified file 'daemon/historydaemon.cpp' |
73 | --- daemon/historydaemon.cpp 2017-03-22 14:00:18 +0000 |
74 | +++ daemon/historydaemon.cpp 2017-03-22 14:00:18 +0000 |
75 | @@ -187,6 +187,7 @@ |
76 | QVariantMap properties; |
77 | QVariantList participants; |
78 | QStringList participantIds; |
79 | + QString accountId = textChannel->property(History::FieldAccountId).toString(); |
80 | |
81 | ChannelInterfaceRolesInterface *roles_interface = textChannel->optionalInterface<ChannelInterfaceRolesInterface>(); |
82 | RolesMap roles; |
83 | @@ -197,7 +198,7 @@ |
84 | Q_FOREACH(const Tp::ContactPtr contact, textChannel->groupContacts(false)) { |
85 | QVariantMap contactProperties; |
86 | contactProperties[History::FieldAlias] = contact->alias(); |
87 | - contactProperties[History::FieldAccountId] = textChannel->property(History::FieldAccountId).toString(); |
88 | + contactProperties[History::FieldAccountId] = accountId; |
89 | contactProperties[History::FieldIdentifier] = contact->id(); |
90 | contactProperties[History::FieldParticipantState] = History::ParticipantStateRegular; |
91 | contactProperties[History::FieldParticipantRoles] = roles[contact->handle().at(0)]; |
92 | @@ -208,7 +209,7 @@ |
93 | Q_FOREACH(const Tp::ContactPtr contact, textChannel->groupRemotePendingContacts(false)) { |
94 | QVariantMap contactProperties; |
95 | contactProperties[History::FieldAlias] = contact->alias(); |
96 | - contactProperties[History::FieldAccountId] = textChannel->property(History::FieldAccountId).toString(); |
97 | + contactProperties[History::FieldAccountId] = accountId; |
98 | contactProperties[History::FieldIdentifier] = contact->id(); |
99 | contactProperties[History::FieldParticipantState] = History::ParticipantStateRemotePending; |
100 | contactProperties[History::FieldParticipantRoles] = roles[contact->handle().at(0)]; |
101 | @@ -219,7 +220,7 @@ |
102 | Q_FOREACH(const Tp::ContactPtr contact, textChannel->groupLocalPendingContacts(false)) { |
103 | QVariantMap contactProperties; |
104 | contactProperties[History::FieldAlias] = contact->alias(); |
105 | - contactProperties[History::FieldAccountId] = textChannel->property(History::FieldAccountId).toString(); |
106 | + contactProperties[History::FieldAccountId] = accountId; |
107 | contactProperties[History::FieldIdentifier] = contact->id(); |
108 | contactProperties[History::FieldParticipantState] = History::ParticipantStateLocalPending; |
109 | contactProperties[History::FieldParticipantRoles] = roles[contact->handle().at(0)]; |
110 | @@ -231,7 +232,7 @@ |
111 | textChannel->targetContact() == textChannel->connection()->selfContact()) { |
112 | QVariantMap contactProperties; |
113 | contactProperties[History::FieldAlias] = textChannel->targetContact()->alias(); |
114 | - contactProperties[History::FieldAccountId] = textChannel->property(History::FieldAccountId).toString(); |
115 | + contactProperties[History::FieldAccountId] = accountId; |
116 | contactProperties[History::FieldIdentifier] = textChannel->targetContact()->id(); |
117 | contactProperties[History::FieldParticipantState] = History::ParticipantStateRegular; |
118 | participantIds << textChannel->targetContact()->id(); |
119 | @@ -370,7 +371,7 @@ |
120 | return mBackend->getSingleEvent((History::EventType)type, accountId, threadId, eventId); |
121 | } |
122 | |
123 | -bool HistoryDaemon::writeEvents(const QList<QVariantMap> &events, const QVariantMap &properties) |
124 | +bool HistoryDaemon::writeEvents(const QList<QVariantMap> &events, const QVariantMap &properties, bool notify) |
125 | { |
126 | if (!mBackend) { |
127 | return false; |
128 | @@ -427,13 +428,13 @@ |
129 | mBackend->endBatchOperation(); |
130 | |
131 | // and last but not least, notify the results |
132 | - if (!newEvents.isEmpty()) { |
133 | + if (!newEvents.isEmpty() && notify) { |
134 | mDBus.notifyEventsAdded(newEvents); |
135 | } |
136 | - if (!modifiedEvents.isEmpty()) { |
137 | + if (!modifiedEvents.isEmpty() && notify) { |
138 | mDBus.notifyEventsModified(modifiedEvents); |
139 | } |
140 | - if (!threads.isEmpty()) { |
141 | + if (!threads.isEmpty() && notify) { |
142 | mDBus.notifyThreadsModified(threads.values()); |
143 | } |
144 | return true; |
145 | @@ -619,6 +620,7 @@ |
146 | // for Rooms we need to explicitly create the thread to allow users to send messages to groups even |
147 | // before they receive any message. |
148 | // for other types, we can wait until messages are received |
149 | + bool notify = false; |
150 | if (channel->targetHandleType() == Tp::HandleTypeRoom) { |
151 | QString accountId = channel->property(History::FieldAccountId).toString(); |
152 | QVariantMap properties = propertiesFromChannel(channel); |
153 | @@ -640,12 +642,13 @@ |
154 | |
155 | // write information event including all initial invitees |
156 | Q_FOREACH(const Tp::ContactPtr contact, channel->groupRemotePendingContacts(false)) { |
157 | - writeInformationEvent(thread, History::InformationTypeInvitationSent, contact->alias()); |
158 | + writeInformationEvent(thread, History::InformationTypeInvitationSent, contact->alias(), QString(), QString(), false); |
159 | } |
160 | |
161 | // update participants only if the thread is not available previously. Otherwise we'll wait for membersChanged event |
162 | // for reflect in conversation information events for modified participants. |
163 | - updateRoomParticipants(channel); |
164 | + updateRoomParticipants(channel, false); |
165 | + notify = true; |
166 | } |
167 | |
168 | // write an entry saying you joined the group if 'joined' flag in thread is false and modify that flag. |
169 | @@ -656,7 +659,8 @@ |
170 | writeInformationEvent(thread, History::InformationTypeSelfJoined); |
171 | } |
172 | // update backend |
173 | - updateRoomProperties(channel, QVariantMap{{"Joined", true}}); |
174 | + updateRoomProperties(channel, QVariantMap{{"Joined", true}}, false); |
175 | + notify = true; |
176 | } |
177 | |
178 | Tp::AbstractInterface *room_interface = channel->optionalInterface<Tp::Client::ChannelInterfaceRoomInterface>(); |
179 | @@ -684,6 +688,10 @@ |
180 | |
181 | connect(roles_interface, SIGNAL(RolesChanged(const HandleRolesMap&, const HandleRolesMap&)), SLOT(onRolesChanged(const HandleRolesMap&, const HandleRolesMap&))); |
182 | } |
183 | + |
184 | + if (notify) { |
185 | + updateRoomParticipants(channel, true); |
186 | + } |
187 | } |
188 | |
189 | void HistoryDaemon::onGroupMembersChanged(const Tp::Contacts &groupMembersAdded, |
190 | @@ -710,18 +718,33 @@ |
191 | matchFlagsForChannel(channel), |
192 | false); |
193 | if (!thread.isEmpty()) { |
194 | + QList<QVariantMap> added; |
195 | + QList<QVariantMap> removed; |
196 | + QList<QVariantMap> modified; |
197 | if (hasRemotePendingMembersAdded) { |
198 | Q_FOREACH (const Tp::ContactPtr& contact, groupRemotePendingMembersAdded) { |
199 | if (!foundInThread(contact, thread)) { |
200 | - writeInformationEvent(thread, History::InformationTypeInvitationSent, contact->alias()); |
201 | + writeInformationEvent(thread, History::InformationTypeInvitationSent, contact->alias(), QString(), QString(), true); |
202 | + QVariantMap participant; |
203 | + participant[History::FieldIdentifier] = contact->id(); |
204 | + participant[History::FieldAlias] = contact->alias(); |
205 | + participant[History::FieldParticipantState] = History::ParticipantStateRemotePending; |
206 | + added << participant; |
207 | } |
208 | } |
209 | + |
210 | } |
211 | if (hasMembersAdded) { |
212 | Q_FOREACH (const Tp::ContactPtr& contact, groupMembersAdded) { |
213 | // if this member was not previously regular member in thread, notify about his join |
214 | if (!foundAsMemberInThread(contact, thread)) { |
215 | - writeInformationEvent(thread, History::InformationTypeJoined, contact->alias()); |
216 | + writeInformationEvent(thread, History::InformationTypeJoined, contact->alias(), QString(), QString(), true); |
217 | + |
218 | + QVariantMap participant; |
219 | + participant[History::FieldIdentifier] = contact->id(); |
220 | + participant[History::FieldAlias] = contact->alias(); |
221 | + participant[History::FieldParticipantState] = History::ParticipantStateRegular; |
222 | + added << participant; |
223 | } |
224 | } |
225 | } |
226 | @@ -742,25 +765,30 @@ |
227 | } |
228 | writeInformationEvent(thread, type); |
229 | // update backend |
230 | - updateRoomProperties(channel, QVariantMap{{"Joined", false}}); |
231 | + updateRoomProperties(channel, QVariantMap{{"Joined", false}}, true); |
232 | } |
233 | else // don't notify any other group member removal if we are leaving the group |
234 | { |
235 | Q_FOREACH (const Tp::ContactPtr& contact, groupMembersRemoved) { |
236 | // inform about removed members other than us |
237 | if (contact->id() != channel->groupSelfContact()->id()) { |
238 | - writeInformationEvent(thread, History::InformationTypeLeaving, contact->alias()); |
239 | + writeInformationEvent(thread, History::InformationTypeLeaving, contact->alias(), QString(), QString(), true); |
240 | } |
241 | + QVariantMap participant; |
242 | + participant[History::FieldIdentifier] = contact->id(); |
243 | + participant[History::FieldAlias] = contact->alias(); |
244 | + removed << participant; |
245 | } |
246 | } |
247 | } |
248 | + mDBus.notifyThreadParticipantsChanged(thread, added, removed, QList<QVariantMap>()); |
249 | } |
250 | } |
251 | |
252 | - updateRoomParticipants(channel); |
253 | + updateRoomParticipants(channel, true); |
254 | } |
255 | |
256 | -void HistoryDaemon::updateRoomParticipants(const Tp::TextChannelPtr channel) |
257 | +void HistoryDaemon::updateRoomParticipants(const Tp::TextChannelPtr channel, bool notify) |
258 | { |
259 | if (!channel) { |
260 | return; |
261 | @@ -810,12 +838,14 @@ |
262 | QString accountId = channel->property(History::FieldAccountId).toString(); |
263 | QString threadId = channel->targetId(); |
264 | if (mBackend->updateRoomParticipants(accountId, threadId, History::EventTypeText, participants)) { |
265 | - QVariantMap updatedThread = getSingleThread(History::EventTypeText, accountId, threadId, QVariantMap()); |
266 | - mDBus.notifyThreadsModified(QList<QVariantMap>() << updatedThread); |
267 | + if (notify) { |
268 | + QVariantMap updatedThread = getSingleThread(History::EventTypeText, accountId, threadId, QVariantMap()); |
269 | + mDBus.notifyThreadsModified(QList<QVariantMap>() << updatedThread); |
270 | + } |
271 | } |
272 | } |
273 | |
274 | -void HistoryDaemon::updateRoomRoles(const Tp::TextChannelPtr &channel, const RolesMap &rolesMap) |
275 | +void HistoryDaemon::updateRoomRoles(const Tp::TextChannelPtr &channel, const RolesMap &rolesMap, bool notify) |
276 | { |
277 | if (!channel) { |
278 | return; |
279 | @@ -840,8 +870,10 @@ |
280 | QString accountId = channel->property(History::FieldAccountId).toString(); |
281 | QString threadId = channel->targetId(); |
282 | if (mBackend->updateRoomParticipantsRoles(accountId, threadId, History::EventTypeText, participantsRoles)) { |
283 | - QVariantMap updatedThread = getSingleThread(History::EventTypeText, accountId, threadId, QVariantMap()); |
284 | - mDBus.notifyThreadsModified(QList<QVariantMap>() << updatedThread); |
285 | + if (notify) { |
286 | + QVariantMap updatedThread = getSingleThread(History::EventTypeText, accountId, threadId, QVariantMap()); |
287 | + mDBus.notifyThreadsModified(QList<QVariantMap>() << updatedThread); |
288 | + } |
289 | } |
290 | |
291 | // update self roles in room properties |
292 | @@ -864,19 +896,21 @@ |
293 | updateRoomProperties(accountId, threadId, type, properties, invalidated); |
294 | } |
295 | |
296 | -void HistoryDaemon::updateRoomProperties(const Tp::TextChannelPtr &channel, const QVariantMap &properties) |
297 | +void HistoryDaemon::updateRoomProperties(const Tp::TextChannelPtr &channel, const QVariantMap &properties, bool notify) |
298 | { |
299 | QString accountId = channel->property(History::FieldAccountId).toString(); |
300 | QString threadId = channel->targetId(); |
301 | History::EventType type = History::EventTypeText; |
302 | - updateRoomProperties(accountId, threadId, type, properties, QStringList()); |
303 | + updateRoomProperties(accountId, threadId, type, properties, QStringList(), notify); |
304 | } |
305 | |
306 | -void HistoryDaemon::updateRoomProperties(const QString &accountId, const QString &threadId, History::EventType type, const QVariantMap &properties, const QStringList &invalidated) |
307 | +void HistoryDaemon::updateRoomProperties(const QString &accountId, const QString &threadId, History::EventType type, const QVariantMap &properties, const QStringList &invalidated, bool notify) |
308 | { |
309 | if (mBackend->updateRoomInfo(accountId, threadId, type, properties, invalidated)) { |
310 | - QVariantMap thread = getSingleThread(type, accountId, threadId, QVariantMap()); |
311 | - mDBus.notifyThreadsModified(QList<QVariantMap>() << thread); |
312 | + if (notify) { |
313 | + QVariantMap thread = getSingleThread(type, accountId, threadId, QVariantMap()); |
314 | + mDBus.notifyThreadsModified(QList<QVariantMap>() << thread); |
315 | + } |
316 | } |
317 | } |
318 | |
319 | @@ -1190,7 +1224,7 @@ |
320 | return reply.value(); |
321 | } |
322 | |
323 | -void HistoryDaemon::writeInformationEvent(const QVariantMap &thread, History::InformationType type, const QString &subject, const QString &sender, const QString &text) |
324 | +void HistoryDaemon::writeInformationEvent(const QVariantMap &thread, History::InformationType type, const QString &subject, const QString &sender, const QString &text, bool notify) |
325 | { |
326 | History::TextEvent historyEvent = History::TextEvent(thread[History::FieldAccountId].toString(), |
327 | thread[History::FieldThreadId].toString(), |
328 | @@ -1206,7 +1240,7 @@ |
329 | QDateTime::currentDateTime(), |
330 | subject, |
331 | type); |
332 | - writeEvents(QList<QVariantMap>() << historyEvent.properties(), thread); |
333 | + writeEvents(QList<QVariantMap>() << historyEvent.properties(), thread, notify); |
334 | } |
335 | |
336 | void HistoryDaemon::writeRoomChangesInformationEvents(const QVariantMap &thread, const QVariantMap &interfaceProperties) |
337 | |
338 | === modified file 'daemon/historydaemon.h' |
339 | --- daemon/historydaemon.h 2017-03-22 14:00:18 +0000 |
340 | +++ daemon/historydaemon.h 2017-03-22 14:00:18 +0000 |
341 | @@ -54,7 +54,7 @@ |
342 | QVariantMap getSingleEvent(int type, const QString &accountId, const QString &threadId, const QString &eventId); |
343 | QVariantMap getSingleEventFromTextChannel(const Tp::TextChannelPtr textChannel, const QString &messageId); |
344 | |
345 | - bool writeEvents(const QList<QVariantMap> &events, const QVariantMap &properties); |
346 | + bool writeEvents(const QList<QVariantMap> &events, const QVariantMap &properties, bool notify = true); |
347 | bool removeEvents(const QList<QVariantMap> &events); |
348 | bool removeThreads(const QList<QVariantMap> &threads); |
349 | |
350 | @@ -73,14 +73,14 @@ |
351 | |
352 | protected: |
353 | History::MatchFlags matchFlagsForChannel(const Tp::ChannelPtr &channel); |
354 | - void updateRoomParticipants(const Tp::TextChannelPtr channel); |
355 | - void updateRoomRoles(const Tp::TextChannelPtr &channel, const RolesMap &rolesMap); |
356 | + void updateRoomParticipants(const Tp::TextChannelPtr channel, bool notify = true); |
357 | + void updateRoomRoles(const Tp::TextChannelPtr &channel, const RolesMap &rolesMap, bool notify = true); |
358 | QString hashThread(const QVariantMap &thread); |
359 | static QVariantMap getInterfaceProperties(const Tp::AbstractInterface *interface); |
360 | - void updateRoomProperties(const Tp::TextChannelPtr &channel, const QVariantMap &properties); |
361 | - void updateRoomProperties(const QString &accountId, const QString &threadId, History::EventType type, const QVariantMap &properties, const QStringList &invalidated); |
362 | + void updateRoomProperties(const Tp::TextChannelPtr &channel, const QVariantMap &properties, bool notify = true); |
363 | + void updateRoomProperties(const QString &accountId, const QString &threadId, History::EventType type, const QVariantMap &properties, const QStringList &invalidated, bool notify = true); |
364 | |
365 | - void writeInformationEvent(const QVariantMap &thread, History::InformationType type, const QString &subject = QString(), const QString &sender = QString("self"), const QString &text = QString()); |
366 | + void writeInformationEvent(const QVariantMap &thread, History::InformationType type, const QString &subject = QString(), const QString &sender = QString("self"), const QString &text = QString(), bool notify = true); |
367 | |
368 | void writeRoomChangesInformationEvents(const QVariantMap &thread, const QVariantMap &interfaceProperties); |
369 | void writeRolesInformationEvents(const QVariantMap &thread, const Tp::ChannelPtr &channel, const RolesMap &rolesMap); |
370 | |
371 | === modified file 'daemon/historyservicedbus.cpp' |
372 | --- daemon/historyservicedbus.cpp 2016-11-24 01:56:01 +0000 |
373 | +++ daemon/historyservicedbus.cpp 2017-03-22 14:00:18 +0000 |
374 | @@ -75,6 +75,14 @@ |
375 | Q_EMIT EventsRemoved(events); |
376 | } |
377 | |
378 | +void HistoryServiceDBus::notifyThreadParticipantsChanged(const QVariantMap &thread, |
379 | + const QList<QVariantMap> &added, |
380 | + const QList<QVariantMap> &removed, |
381 | + const QList<QVariantMap> &modified) |
382 | +{ |
383 | + Q_EMIT ThreadParticipantsChanged(thread, added, removed, modified); |
384 | +} |
385 | + |
386 | QVariantMap HistoryServiceDBus::ThreadForProperties(const QString &accountId, |
387 | int type, |
388 | const QVariantMap &properties, |
389 | |
390 | === modified file 'daemon/historyservicedbus.h' |
391 | --- daemon/historyservicedbus.h 2016-06-17 01:49:46 +0000 |
392 | +++ daemon/historyservicedbus.h 2017-03-22 14:00:18 +0000 |
393 | @@ -39,6 +39,10 @@ |
394 | void notifyThreadsAdded(const QList<QVariantMap> &threads); |
395 | void notifyThreadsModified(const QList<QVariantMap> &threads); |
396 | void notifyThreadsRemoved(const QList<QVariantMap> &threads); |
397 | + void notifyThreadParticipantsChanged(const QVariantMap &thread, |
398 | + const QList<QVariantMap> &added, |
399 | + const QList<QVariantMap> &removed, |
400 | + const QList<QVariantMap> &modified); |
401 | |
402 | void notifyEventsAdded(const QList<QVariantMap> &events); |
403 | void notifyEventsModified(const QList<QVariantMap> &events); |
404 | @@ -70,6 +74,10 @@ |
405 | void ThreadsAdded(const QList<QVariantMap> &threads); |
406 | void ThreadsModified(const QList<QVariantMap> &threads); |
407 | void ThreadsRemoved(const QList<QVariantMap> &threads); |
408 | + void ThreadParticipantsChanged(const QVariantMap &thread, |
409 | + const QList<QVariantMap> &added, |
410 | + const QList<QVariantMap> &removed, |
411 | + const QList<QVariantMap> &modified); |
412 | |
413 | void EventsAdded(const QList<QVariantMap> &events); |
414 | void EventsModified(const QList<QVariantMap> &events); |
415 | |
416 | === modified file 'plugins/sqlite/sqlitehistoryplugin.cpp' |
417 | --- plugins/sqlite/sqlitehistoryplugin.cpp 2016-11-24 01:50:48 +0000 |
418 | +++ plugins/sqlite/sqlitehistoryplugin.cpp 2017-03-22 14:00:18 +0000 |
419 | @@ -1290,6 +1290,9 @@ |
420 | chatRoomInfo["SelfRoles"] = query1.value(20).toInt(); |
421 | |
422 | thread[History::FieldChatRoomInfo] = chatRoomInfo; |
423 | + if (!History::Utils::shouldIncludeParticipants(thread)) { |
424 | + thread.remove(History::FieldParticipants); |
425 | + } |
426 | } |
427 | break; |
428 | case History::EventTypeVoice: |
429 | @@ -1353,8 +1356,10 @@ |
430 | event[History::FieldSenderId] = query.value(3); |
431 | event[History::FieldTimestamp] = toLocalTimeString(query.value(4).toDateTime()); |
432 | event[History::FieldNewEvent] = query.value(5).toBool(); |
433 | - QStringList participants = query.value(6).toString().split("|,|"); |
434 | - event[History::FieldParticipants] = History::ContactMatcher::instance()->contactInfo(accountId, participants, true); |
435 | + if (type != History::EventTypeText) { |
436 | + QStringList participants = query.value(6).toString().split("|,|"); |
437 | + event[History::FieldParticipants] = History::ContactMatcher::instance()->contactInfo(accountId, participants, true); |
438 | + } |
439 | |
440 | switch (type) { |
441 | case History::EventTypeText: |
442 | |
443 | === modified file 'src/manager.cpp' |
444 | --- src/manager.cpp 2016-06-17 01:49:46 +0000 |
445 | +++ src/manager.cpp 2017-03-22 14:00:18 +0000 |
446 | @@ -65,6 +65,9 @@ |
447 | SIGNAL(threadsRemoved(History::Threads)), |
448 | SIGNAL(threadsRemoved(History::Threads))); |
449 | connect(d->dbus.data(), |
450 | + SIGNAL(threadParticipantsChanged(History::Thread, History::Participants, History::Participants, History::Participants)), |
451 | + SIGNAL(threadParticipantsChanged(History::Thread, History::Participants, History::Participants, History::Participants))); |
452 | + connect(d->dbus.data(), |
453 | SIGNAL(eventsAdded(History::Events)), |
454 | SIGNAL(eventsAdded(History::Events))); |
455 | connect(d->dbus.data(), |
456 | |
457 | === modified file 'src/manager.h' |
458 | --- src/manager.h 2016-06-17 01:49:46 +0000 |
459 | +++ src/manager.h 2017-03-22 14:00:18 +0000 |
460 | @@ -79,6 +79,7 @@ |
461 | void threadsAdded(const History::Threads &threads); |
462 | void threadsModified(const History::Threads &threads); |
463 | void threadsRemoved(const History::Threads &threads); |
464 | + void threadParticipantsChanged(const History::Thread &thread, const History::Participants &added, const History::Participants &removed, const History::Participants &modified); |
465 | |
466 | void eventsAdded(const History::Events &events); |
467 | void eventsModified(const History::Events &events); |
468 | |
469 | === modified file 'src/managerdbus.cpp' |
470 | --- src/managerdbus.cpp 2016-06-17 01:49:46 +0000 |
471 | +++ src/managerdbus.cpp 2017-03-22 14:00:18 +0000 |
472 | @@ -50,6 +50,12 @@ |
473 | connection.connect(DBusService, DBusObjectPath, DBusInterface, "ThreadsRemoved", |
474 | this, SLOT(onThreadsRemoved(QList<QVariantMap>))); |
475 | |
476 | + connection.connect(DBusService, DBusObjectPath, DBusInterface, "ThreadParticipantsChanged", |
477 | + this, SLOT(onThreadParticipantsChanged(QVariantMap, |
478 | + QList<QVariantMap>, |
479 | + QList<QVariantMap>, |
480 | + QList<QVariantMap>))); |
481 | + |
482 | connection.connect(DBusService, DBusObjectPath, DBusInterface, "EventsAdded", |
483 | this, SLOT(onEventsAdded(QList<QVariantMap>))); |
484 | connection.connect(DBusService, DBusObjectPath, DBusInterface, "EventsModified", |
485 | @@ -168,6 +174,17 @@ |
486 | Q_EMIT threadsRemoved(threadsFromProperties(threads)); |
487 | } |
488 | |
489 | +void ManagerDBus::onThreadParticipantsChanged(const QVariantMap &thread, |
490 | + const QList<QVariantMap> &added, |
491 | + const QList<QVariantMap> &removed, |
492 | + const QList<QVariantMap> &modified) |
493 | +{ |
494 | + Q_EMIT threadParticipantsChanged(threadsFromProperties(QList<QVariantMap>() << thread).first(), |
495 | + Participants::fromVariantMapList(added), |
496 | + Participants::fromVariantMapList(removed), |
497 | + Participants::fromVariantMapList(modified)); |
498 | +} |
499 | + |
500 | void ManagerDBus::onEventsAdded(const QList<QVariantMap> &events) |
501 | { |
502 | Q_EMIT eventsAdded(eventsFromProperties(events)); |
503 | |
504 | === modified file 'src/managerdbus_p.h' |
505 | --- src/managerdbus_p.h 2016-06-17 01:49:46 +0000 |
506 | +++ src/managerdbus_p.h 2017-03-22 14:00:18 +0000 |
507 | @@ -62,6 +62,10 @@ |
508 | void threadsAdded(const History::Threads &threads); |
509 | void threadsModified(const History::Threads &threads); |
510 | void threadsRemoved(const History::Threads &threads); |
511 | + void threadParticipantsChanged(const History::Thread &thread, |
512 | + const History::Participants &added, |
513 | + const History::Participants &removed, |
514 | + const History::Participants &modified); |
515 | |
516 | void eventsAdded(const History::Events &events); |
517 | void eventsModified(const History::Events &events); |
518 | @@ -71,6 +75,10 @@ |
519 | void onThreadsAdded(const QList<QVariantMap> &threads); |
520 | void onThreadsModified(const QList<QVariantMap> &threads); |
521 | void onThreadsRemoved(const QList<QVariantMap> &threads); |
522 | + void onThreadParticipantsChanged(const QVariantMap &thread, |
523 | + const QList<QVariantMap> &added, |
524 | + const QList<QVariantMap> &removed, |
525 | + const QList<QVariantMap> &modified); |
526 | |
527 | void onEventsAdded(const QList<QVariantMap> &events); |
528 | void onEventsModified(const QList<QVariantMap> &events); |
529 | |
530 | === modified file 'src/participant.cpp' |
531 | --- src/participant.cpp 2016-11-24 01:04:37 +0000 |
532 | +++ src/participant.cpp 2017-03-22 14:00:18 +0000 |
533 | @@ -233,6 +233,15 @@ |
534 | return participants; |
535 | } |
536 | |
537 | +Participants Participants::fromVariantMapList(const QList<QVariantMap> &list) |
538 | +{ |
539 | + Participants participants; |
540 | + Q_FOREACH(const QVariantMap& entry, list) { |
541 | + participants << Participant::fromProperties(entry); |
542 | + } |
543 | + return participants; |
544 | +} |
545 | + |
546 | QVariantList Participants::toVariantList() const |
547 | { |
548 | QVariantList list; |
549 | |
550 | === modified file 'src/participant.h' |
551 | --- src/participant.h 2016-11-24 01:04:37 +0000 |
552 | +++ src/participant.h 2017-03-22 14:00:18 +0000 |
553 | @@ -79,6 +79,7 @@ |
554 | QStringList identifiers() const; |
555 | static Participants fromVariant(const QVariant &variant); |
556 | static Participants fromVariantList(const QVariantList &list); |
557 | + static Participants fromVariantMapList(const QList<QVariantMap> &list); |
558 | static Participants fromStringList(const QStringList &list); |
559 | QVariantList toVariantList() const; |
560 | History::Participants filterByState(uint state) const; |
561 | |
562 | === modified file 'src/thread.cpp' |
563 | --- src/thread.cpp 2016-07-12 02:08:11 +0000 |
564 | +++ src/thread.cpp 2017-03-22 14:00:18 +0000 |
565 | @@ -192,6 +192,22 @@ |
566 | return selfData < otherData; |
567 | } |
568 | |
569 | +void Thread::removeParticipants(const Participants &participants) |
570 | +{ |
571 | + Q_D(Thread); |
572 | + Q_FOREACH(const Participant &participant, participants) { |
573 | + d->participants.removeAll(participant); |
574 | + } |
575 | +} |
576 | + |
577 | +void Thread::addParticipants(const Participants &participants) |
578 | +{ |
579 | + Q_D(Thread); |
580 | + Q_FOREACH(const Participant &participant, participants) { |
581 | + d->participants.append(participant); |
582 | + } |
583 | +} |
584 | + |
585 | QVariantMap Thread::properties() const |
586 | { |
587 | Q_D(const Thread); |
588 | |
589 | === modified file 'src/thread.h' |
590 | --- src/thread.h 2016-07-12 01:59:06 +0000 |
591 | +++ src/thread.h 2017-03-22 14:00:18 +0000 |
592 | @@ -73,6 +73,8 @@ |
593 | ChatType chatType() const; |
594 | Threads groupedThreads() const; |
595 | QVariantMap chatRoomInfo() const; |
596 | + void addParticipants(const History::Participants &participants); |
597 | + void removeParticipants(const History::Participants &participants); |
598 | |
599 | bool isNull() const; |
600 | bool operator==(const Thread &other) const; |
601 | |
602 | === modified file 'src/threadview.cpp' |
603 | --- src/threadview.cpp 2015-10-01 19:44:45 +0000 |
604 | +++ src/threadview.cpp 2017-03-22 14:00:18 +0000 |
605 | @@ -89,6 +89,18 @@ |
606 | } |
607 | } |
608 | |
609 | +void ThreadViewPrivate::_d_threadParticipantsChanged(const History::Thread &thread, |
610 | + const History::Participants &added, |
611 | + const History::Participants &removed, |
612 | + const History::Participants &modified) |
613 | +{ |
614 | + Q_Q(ThreadView); |
615 | + Threads filtered = filteredThreads(History::Threads() << thread); |
616 | + if (!filtered.isEmpty()) { |
617 | + Q_EMIT q->threadParticipantsChanged(filtered.first(), added, removed, modified); |
618 | + } |
619 | +} |
620 | + |
621 | // ------------- ThreadView ------------------------------------------------------- |
622 | |
623 | ThreadView::ThreadView(History::EventType type, |
624 | @@ -132,6 +144,9 @@ |
625 | connect(Manager::instance(), |
626 | SIGNAL(threadsRemoved(History::Threads)), |
627 | SLOT(_d_threadsRemoved(History::Threads))); |
628 | + connect(Manager::instance(), |
629 | + SIGNAL(threadParticipantsChanged(History::Thread, History::Participants, History::Participants, History::Participants)), |
630 | + SLOT(_d_threadParticipantsChanged(History::Thread, History::Participants, History::Participants, History::Participants))); |
631 | } |
632 | |
633 | ThreadView::~ThreadView() |
634 | |
635 | === modified file 'src/threadview.h' |
636 | --- src/threadview.h 2015-09-21 20:05:06 +0000 |
637 | +++ src/threadview.h 2017-03-22 14:00:18 +0000 |
638 | @@ -52,12 +52,20 @@ |
639 | void threadsAdded(const History::Threads &threads); |
640 | void threadsModified(const History::Threads &threads); |
641 | void threadsRemoved(const History::Threads &threads); |
642 | + void threadParticipantsChanged(const History::Thread &thread, |
643 | + const History::Participants &added, |
644 | + const History::Participants &removed, |
645 | + const History::Participants &modified); |
646 | void invalidated(); |
647 | |
648 | private: |
649 | Q_PRIVATE_SLOT(d_func(), void _d_threadsAdded(const History::Threads &threads)) |
650 | Q_PRIVATE_SLOT(d_func(), void _d_threadsModified(const History::Threads &threads)) |
651 | Q_PRIVATE_SLOT(d_func(), void _d_threadsRemoved(const History::Threads &threads)) |
652 | + Q_PRIVATE_SLOT(d_func(), void _d_threadParticipantsChanged(const History::Thread &thread, |
653 | + const History::Participants &added, |
654 | + const History::Participants &removed, |
655 | + const History::Participants &modified)) |
656 | QScopedPointer<ThreadViewPrivate> d_ptr; |
657 | |
658 | }; |
659 | |
660 | === modified file 'src/threadview_p.h' |
661 | --- src/threadview_p.h 2013-09-17 21:33:34 +0000 |
662 | +++ src/threadview_p.h 2017-03-22 14:00:18 +0000 |
663 | @@ -50,6 +50,10 @@ |
664 | void _d_threadsAdded(const History::Threads &threads); |
665 | void _d_threadsModified(const History::Threads &threads); |
666 | void _d_threadsRemoved(const History::Threads &threads); |
667 | + void _d_threadParticipantsChanged(const History::Thread &thread, |
668 | + const History::Participants &added, |
669 | + const History::Participants &removed, |
670 | + const History::Participants &modified); |
671 | |
672 | ThreadView *q_ptr; |
673 | }; |
674 | |
675 | === modified file 'src/utils.cpp' |
676 | --- src/utils.cpp 2017-03-22 14:00:18 +0000 |
677 | +++ src/utils.cpp 2017-03-22 14:00:18 +0000 |
678 | @@ -176,4 +176,14 @@ |
679 | return QVariant(); |
680 | } |
681 | |
682 | +bool Utils::shouldIncludeParticipants(const Thread &thread) |
683 | +{ |
684 | + // FIXME |
685 | + // this is obviously incorrect. we have to query the protocol files as a final solution |
686 | + if (protocolFromAccountId(thread.accountId()) == "irc") { |
687 | + return thread.chatType() != History::ChatTypeRoom; |
688 | + } |
689 | + return true; |
690 | +} |
691 | + |
692 | } |
693 | |
694 | === modified file 'src/utils_p.h' |
695 | --- src/utils_p.h 2016-11-08 16:02:18 +0000 |
696 | +++ src/utils_p.h 2017-03-22 14:00:18 +0000 |
697 | @@ -36,6 +36,7 @@ |
698 | static bool compareParticipants(const QStringList &participants1, const QStringList &participants2, MatchFlags flags); |
699 | static bool compareNormalizedParticipants(const QStringList &participants1, const QStringList &participants2, MatchFlags flags); |
700 | static bool shouldGroupThread(const Thread &thread); |
701 | + static bool shouldIncludeParticipants(const Thread &thread); |
702 | static QString normalizeId(const QString &accountId, const QString &id); |
703 | static QVariant getUserValue(const QString &interface, const QString &propName); |
704 |
Looks good!