nemomobile/libcommhistory — pull request #68 by special (2014-01-28 08:35:04+00:00)
Title: [libcommhistory] Resolve contacts before inserting events in EventModel

Review https://github.com/nemomobile/libcommhistory/pull/67 first, as this PR builds on it. fbcd510 is the first new commit. Read below, then review commits in sequence for the most pleasant experience.

Currently, events are inserted into an EventModel immediately after query/add/update. If contact resolution is necessary afterwards, it's done asynchronously and the event gets dataChanged afterwards. This is inefficient, causes model data to jump around during population, and provides no way to tell when contact resolution is finished.

This introduces ContactResolver as an alternate API to ContactListener. It takes an ordered list of events, resolves matching contacts, and emits a signal when all events are resolved (or unknown). It is currently implemented using ContactListener, but should later start querying libcontacts directly for better efficiency. My intent is to eventually deprecate ContactListener.

EventModel is then ported to use that API, and subclasses of EventModel are ported to those changes. RecentContactsModel especially benefits.

The only externally visible change is that executeQuery (and the various getEvents methods that call it) will no longer fill the model synchronously when contact resolution is enabled. SyncQuery mode is no longer allowed with contact resolution; but this already wasn't very functional, because contacts cannot be resolved synchronously.

I did not significantly clean up EventModelPrivate's API. I expect that to need more changes when asynchronous queries are re-introduced, so it's not worth doing now. There are some ugly parts as a result.

Existing tests all pass, except for some failures in RecentContactsModel that were already present (which I will look into separately). More to come..