From 0c2c5a7c7c0e035415e420037c78a40ecae223c1 Mon Sep 17 00:00:00 2001 From: Matt Vogt Date: Thu, 5 Dec 2013 15:03:12 -0800 Subject: [PATCH] [libcontacts] Track whether contacts have valid IM accounts Although QContactStatusFlags reports whether an account has any IM accounts configured, we need to also know whether any of those accounts are connected to valid telepathy accounts. --- src/seasidecache.cpp | 10 ++++++++++ src/seasidecache.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/seasidecache.cpp b/src/seasidecache.cpp index 0e4750e..9b48790 100644 --- a/src/seasidecache.cpp +++ b/src/seasidecache.cpp @@ -1854,6 +1854,9 @@ bool SeasideCache::updateContactIndexing(const QContact &oldContact, const QCont oldAddresses.insert(address); } + // Keep track of whether this contact has any valid IM accounts + bool hasValid = false; + foreach (const QContactOnlineAccount &account, contact.details()) { const StringPair address(addressPair(account)); if (!validAddressPair(address)) @@ -1865,6 +1868,13 @@ bool SeasideCache::updateContactIndexing(const QContact &oldContact, const QCont } m_onlineAccountIds[address] = iid; + hasValid = true; + } + + if (hasValid) { + item->statusFlags |= HasValidOnlineAccount; + } else { + item->statusFlags &= ~HasValidOnlineAccount; } if (!oldAddresses.isEmpty()) { diff --git a/src/seasidecache.h b/src/seasidecache.h index 07420e7..51ec97a 100644 --- a/src/seasidecache.h +++ b/src/seasidecache.h @@ -117,6 +117,11 @@ class CONTACTCACHE_EXPORT SeasideCache : public QObject ContactComplete }; + enum { + // Must be after the highest bit used in QContactStatusFlags::Flag + HasValidOnlineAccount = (QContactStatusFlags::IsOnline << 1) + }; + struct ItemData { virtual ~ItemData() {}