~ci-train-bot/history-service/history-service-ubuntu-zesty-2629

« back to all changes in this revision

Viewing changes to Ubuntu/History/historygroupedthreadsmodel.cpp

  • Committer: Bileto Bot
  • Author(s): Gustavo Pichorim Boiko
  • Date: 2017-03-23 01:28:52 UTC
  • mfrom: (230.2.35 staging)
  • Revision ID: ci-train-bot@canonical.com-20170323012852-vzmjcare13zofbna
- Adapt to support VOIP accounts.
- Improve the notifications of participants changing
- Only start saving information events about contacts joining and leaving after the self contact is in the local list of participants.
- Improve Roles management performance by caching the retrieved data.
- Mark entire conversations as read.
- Allow pass multiple fields on sort clause.
- Reduce the dbus traffic when marking messages and threads as read.
- Use a QLockFile to ensure there will be only one instance of the daemon per user. As we now delay the registration on dbus, sometimes we ended up having two instances of the daeon running (because of dbus activation). This change makes sure that won't happen.
- Do not load the participants from threads automatically. If the client really needs it, it can use the newly added API to fetch the participants.
- Make it possible to debug sqlite commands.

Approved by: system-apps-ci-bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
    }
200
200
}
201
201
 
 
202
History::Threads HistoryGroupedThreadsModel::restoreParticipants(const History::Threads &oldThreads, const History::Threads &newThreads)
 
203
{
 
204
    History::Threads updated = newThreads;
 
205
    for(History::Thread &thread : updated) {
 
206
        if (!thread.participants().isEmpty()) {
 
207
            continue;
 
208
        }
 
209
        int i = oldThreads.indexOf(thread);
 
210
        if (i >=0) {
 
211
            thread.addParticipants(oldThreads[i].participants());
 
212
        }
 
213
    }
 
214
    return updated;
 
215
}
 
216
 
202
217
void HistoryGroupedThreadsModel::updateQuery()
203
218
{
204
219
    // remove all entries and call the query update
217
232
        processThreadGrouping(thread);
218
233
    }
219
234
 
 
235
    fetchParticipantsIfNeeded(threads);
220
236
    notifyDataChanged();
221
237
}
222
238
 
225
241
    Q_FOREACH(const History::Thread &thread, threads) {
226
242
        processThreadGrouping(thread);
227
243
    }
228
 
 
 
244
    fetchParticipantsIfNeeded(threads);
229
245
    notifyDataChanged();
230
246
}
231
247
 
238
254
    notifyDataChanged();
239
255
}
240
256
 
 
257
void HistoryGroupedThreadsModel::onThreadParticipantsChanged(const History::Thread &thread, const History::Participants &added, const History::Participants &removed, const History::Participants &modified)
 
258
{
 
259
    int pos = existingPositionForEntry(thread);
 
260
    if (pos >= 0) {
 
261
        HistoryThreadGroup &group = mGroups[pos];
 
262
        if (group.displayedThread == thread) {
 
263
            group.displayedThread.removeParticipants(removed);
 
264
            group.displayedThread.removeParticipants(modified);
 
265
            group.displayedThread.addParticipants(added);
 
266
            group.displayedThread.addParticipants(modified);
 
267
        }
 
268
 
 
269
        Q_FOREACH(const History::Thread &existingThread, group.threads) {
 
270
            if (existingThread == thread) {
 
271
                History::Thread modifiedThread = existingThread;
 
272
                group.threads.removeOne(existingThread);
 
273
                modifiedThread.removeParticipants(removed);
 
274
                modifiedThread.removeParticipants(modified);
 
275
                modifiedThread.addParticipants(added);
 
276
                modifiedThread.addParticipants(modified);
 
277
                group.threads.append(modifiedThread);
 
278
            }
 
279
        }
 
280
        QModelIndex idx = index(pos);
 
281
        Q_EMIT dataChanged(idx, idx);
 
282
    }
 
283
 
 
284
    // watch the contact info for the received participants
 
285
    Q_FOREACH(const History::Participant &participant, added) {
 
286
        watchContactInfo(thread.accountId(), participant.identifier(), participant.properties());
 
287
    }
 
288
    Q_FOREACH(const History::Participant &participant, modified) {
 
289
        watchContactInfo(thread.accountId(), participant.identifier(), participant.properties());
 
290
    }
 
291
}
 
292
 
241
293
void HistoryGroupedThreadsModel::processThreadGrouping(const History::Thread &thread)
242
294
{
243
295
    QVariantMap queryProperties;
262
314
    }
263
315
 
264
316
    HistoryThreadGroup &group = mGroups[pos];
265
 
    group.threads = groupedThread.groupedThreads();
 
317
    group.threads = restoreParticipants(group.threads, groupedThread.groupedThreads());
266
318
 
267
319
    updateDisplayedThread(group);
268
320
    markGroupAsChanged(group);