From 3096166d9f66a25d9f74924b66fdd19624364593 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 9 Mar 2014 18:53:22 +0000 Subject: fix for tabSRMM sub selection git-svn-id: http://svn.miranda-ng.org/main/trunk@8519 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/commonheaders.h | 1 + plugins/TabSRMM/src/contactcache.cpp | 37 +++++++++++++++--------------------- plugins/TabSRMM/src/contactcache.h | 18 +++++++++--------- 3 files changed, 25 insertions(+), 31 deletions(-) (limited to 'plugins') diff --git a/plugins/TabSRMM/src/commonheaders.h b/plugins/TabSRMM/src/commonheaders.h index 60470d7e59..35a57c36b3 100644 --- a/plugins/TabSRMM/src/commonheaders.h +++ b/plugins/TabSRMM/src/commonheaders.h @@ -86,6 +86,7 @@ #include #include #include +#include #include #include diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp index 605a3bcfa2..6761c68114 100644 --- a/plugins/TabSRMM/src/contactcache.cpp +++ b/plugins/TabSRMM/src/contactcache.cpp @@ -37,17 +37,19 @@ static OBJLIST arContacts(50, NumericKeySortT); +static DBCachedContact ccInvalid = { 0 }; + CContactCache::CContactCache(const MCONTACT hContact) { m_hContact = hContact; m_wOldStatus = m_wStatus = ID_STATUS_OFFLINE; if (hContact) { - m_szProto = ::GetContactProto(m_hContact); + cc = db_get_contact(hContact); initPhaseTwo(); } else { - m_szProto = C_INVALID_PROTO; + cc = &ccInvalid; m_szAccount = C_INVALID_ACCOUNT; m_isMeta = false; m_Valid = false; @@ -61,23 +63,22 @@ CContactCache::CContactCache(const MCONTACT hContact) void CContactCache::initPhaseTwo() { m_szAccount = 0; - if (m_szProto) { - PROTOACCOUNT *acc = reinterpret_cast(::CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)m_szProto)); + if (cc->szProto) { + PROTOACCOUNT *acc = reinterpret_cast(::CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)cc->szProto)); if (acc && acc->tszAccountName) m_szAccount = acc->tszAccountName; } - m_Valid = (m_szProto != 0 && m_szAccount != 0) ? true : false; + m_Valid = (cc->szProto != 0 && m_szAccount != 0) ? true : false; if (m_Valid) { - m_isMeta = PluginConfig.bMetaEnabled && !strcmp(m_szProto, META_PROTO); - m_isSubcontact = db_mc_isSub(m_hContact) != 0; + m_isMeta = PluginConfig.bMetaEnabled && !strcmp(cc->szProto, META_PROTO); if (m_isMeta) updateMeta(true); updateState(); updateFavorite(); } else { - m_szProto = C_INVALID_PROTO; + cc->szProto = C_INVALID_PROTO; m_szAccount = C_INVALID_ACCOUNT; m_isMeta = false; } @@ -91,7 +92,6 @@ void CContactCache::resetMeta() { m_isMeta = false; m_szMetaProto = 0; - m_hSubContact = 0; initPhaseTwo(); } @@ -139,7 +139,7 @@ bool CContactCache::updateStatus() return false; m_wOldStatus = m_wStatus; - m_wStatus = (WORD)db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE); + m_wStatus = (WORD)db_get_w(m_hContact, cc->szProto, "Status", ID_STATUS_OFFLINE); return m_wOldStatus != m_wStatus; } @@ -150,14 +150,7 @@ bool CContactCache::updateStatus() */ void CContactCache::updateMeta(bool fForce) { - if (!m_Valid) - return; - - MCONTACT hSubContact = CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)m_hContact, 0); - if (hSubContact && (hSubContact != m_hSubContact || fForce)) { - m_hSubContact = hSubContact; - m_szMetaProto = GetContactProto(m_hSubContact); - } + m_szMetaProto = (m_Valid) ? GetContactProto(cc->pSubs[cc->nDefault]) : NULL; } /** @@ -456,7 +449,7 @@ void CContactCache::updateStatusMsg(const char *szKey) if (m_ListeningInfo) mir_free(m_ListeningInfo); m_ListeningInfo = 0; - ptrT szListeningTo(db_get_tsa(m_hContact, m_szProto, "ListeningTo")); + ptrT szListeningTo(db_get_tsa(m_hContact, cc->szProto, "ListeningTo")); if (szListeningTo != 0 && *szListeningTo) m_ListeningInfo = szListeningTo.detouch(); } @@ -464,11 +457,11 @@ void CContactCache::updateStatusMsg(const char *szKey) if (m_xStatusMsg) mir_free(m_xStatusMsg); m_xStatusMsg = 0; - ptrT szXStatusMsg(db_get_tsa(m_hContact, m_szProto, "XStatusMsg")); + ptrT szXStatusMsg(db_get_tsa(m_hContact, cc->szProto, "XStatusMsg")); if (szXStatusMsg != 0 && *szXStatusMsg) m_xStatusMsg = szXStatusMsg.detouch(); } - m_xStatus = db_get_b(m_hContact, m_szProto, "XStatusId", 0); + m_xStatus = db_get_b(m_hContact, cc->szProto, "XStatusId", 0); } /** @@ -564,7 +557,7 @@ TCHAR* CContactCache::getNormalizedStatusMsg(const TCHAR *src, bool fStripAll) HICON CContactCache::getIcon(int& iSize) const { if (!m_dat || !m_hwnd) - return LoadSkinnedProtoIcon(m_szProto, m_wStatus); + return LoadSkinnedProtoIcon(cc->szProto, m_wStatus); if (m_dat->dwFlags & MWF_ERRORSTATE) return PluginConfig.g_iconErr; diff --git a/plugins/TabSRMM/src/contactcache.h b/plugins/TabSRMM/src/contactcache.h index 193acb8ec9..141f93e52c 100644 --- a/plugins/TabSRMM/src/contactcache.h +++ b/plugins/TabSRMM/src/contactcache.h @@ -77,12 +77,12 @@ struct CContactCache : public MZeroedObject const WORD getOldStatus() const { return m_wOldStatus; } const TCHAR* getNick() const { return m_szNick; } const MCONTACT getContact() const { return m_hContact; } - const MCONTACT getActiveContact() const { return m_isMeta ? (m_hSubContact ? m_hSubContact : m_hContact) : m_hContact; } + const MCONTACT getActiveContact() const { return m_isMeta ? cc->nDefault : m_hContact; } const DWORD getIdleTS() const { return m_idleTS; } - const char* getProto() const { return m_szProto; } - const char* getActiveProto() const { return m_isMeta ? (m_szMetaProto ? m_szMetaProto : m_szProto) : m_szProto; } + const char* getProto() const { return cc->szProto; } + const char* getActiveProto() const { return m_isMeta ? (m_szMetaProto ? m_szMetaProto : cc->szProto) : cc->szProto; } bool isMeta() const { return m_isMeta; } - bool isSubContact() const { return m_isSubcontact; } + bool isSubContact() const { return cc->IsSub(); } bool isFavorite() const { return m_isFavorite; } bool isRecent() const { return m_isRecent; } const TCHAR* getRealAccount() const { return m_szAccount ? m_szAccount : C_INVALID_ACCOUNT; } @@ -133,15 +133,14 @@ private: void releaseAlloced(); MCONTACT m_hContact; - MCONTACT m_hSubContact; WORD m_wStatus, m_wOldStatus; - char* m_szProto, *m_szMetaProto; - TCHAR* m_szAccount; + char *m_szMetaProto; + TCHAR *m_szAccount; TCHAR m_szNick[80], m_szUIN[80]; - TCHAR* m_szStatusMsg, *m_xStatusMsg, *m_ListeningInfo; + TCHAR *m_szStatusMsg, *m_xStatusMsg, *m_ListeningInfo; BYTE m_xStatus; DWORD m_idleTS; - bool m_isMeta, m_isSubcontact; + bool m_isMeta; bool m_Valid; bool m_isFavorite; bool m_isRecent; @@ -152,6 +151,7 @@ private: TWindowData *m_dat; TSessionStats *m_stats; TInputHistory *m_history; + DBCachedContact *cc; }; #endif /* __CONTACTCACHE_H */ -- cgit v1.2.3