From 2cdd9ae1c6bbd4c19dcf3393db1943c1dff39604 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 8 Aug 2016 11:12:32 +0000 Subject: more cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@17170 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/contactcache.cpp | 20 ++++++--------- plugins/TabSRMM/src/contactcache.h | 10 ++++---- plugins/TabSRMM/src/globals.cpp | 48 +++++++++++++++++------------------- 3 files changed, 36 insertions(+), 42 deletions(-) (limited to 'plugins') diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp index afe9bd384c..b2ac11e277 100644 --- a/plugins/TabSRMM/src/contactcache.cpp +++ b/plugins/TabSRMM/src/contactcache.cpp @@ -38,7 +38,7 @@ static DBCachedContact ccInvalid; CContactCache::CContactCache(MCONTACT hContact) { m_hContact = hContact; - m_wStatus = m_wOldStatus = ID_STATUS_OFFLINE; + m_iStatus = m_iOldStatus = ID_STATUS_OFFLINE; if (hContact) { if ((cc = db_get_contact(hContact)) != NULL) { @@ -88,7 +88,7 @@ void CContactCache::resetMeta() { m_isMeta = false; m_szMetaProto = 0; - m_wMetaStatus = ID_STATUS_OFFLINE; + m_iMetaStatus = ID_STATUS_OFFLINE; initPhaseTwo(); } @@ -135,7 +135,7 @@ void CContactCache::updateMeta() MCONTACT hOldSub = m_hSub; m_hSub = db_mc_getSrmmSub(cc->contactID); m_szMetaProto = GetContactProto(m_hSub); - m_wMetaStatus = (WORD)db_get_w(m_hSub, m_szMetaProto, "Status", ID_STATUS_OFFLINE); + m_iMetaStatus = (WORD)db_get_w(m_hSub, m_szMetaProto, "Status", ID_STATUS_OFFLINE); PROTOACCOUNT *pa = Proto_GetAccount(m_szMetaProto); if (pa) m_szAccount = pa->tszAccountName; @@ -148,7 +148,7 @@ void CContactCache::updateMeta() else { m_hSub = 0; m_szMetaProto = NULL; - m_wMetaStatus = ID_STATUS_OFFLINE; + m_iMetaStatus = ID_STATUS_OFFLINE; m_xStatus = 0; } } @@ -578,13 +578,9 @@ size_t CContactCache::getMaxMessageLength() return m_nMax; } -int CContactCache::getStatus() const +bool CContactCache::updateStatus(int iStatus) { - return db_get_w(getActiveContact(), getActiveProto(), "Status", ID_STATUS_OFFLINE); -} - -void CContactCache::updateStatus() -{ - m_wOldStatus = m_wStatus; - m_wStatus = getStatus(); + m_iOldStatus = m_iStatus; + m_iStatus = iStatus; + return m_iOldStatus != iStatus; } diff --git a/plugins/TabSRMM/src/contactcache.h b/plugins/TabSRMM/src/contactcache.h index 0c3ce81892..8e5c2afef4 100644 --- a/plugins/TabSRMM/src/contactcache.h +++ b/plugins/TabSRMM/src/contactcache.h @@ -65,8 +65,9 @@ struct CContactCache : public MZeroedObject } __forceinline bool isValid() const { return m_Valid; } - __forceinline WORD getActiveStatus() const { return m_isMeta ? m_wMetaStatus : getStatus(); } - __forceinline WORD getOldStatus() const { return m_wOldStatus; } + __forceinline int getStatus() const { return m_iStatus; } + __forceinline int getActiveStatus() const { return m_isMeta ? m_iMetaStatus : getStatus(); } + __forceinline int getOldStatus() const { return m_iOldStatus; } __forceinline LPCWSTR getNick() const { return m_szNick; } __forceinline MCONTACT getContact() const { return m_hContact; } __forceinline MCONTACT getActiveContact() const { return (m_isMeta) ? m_hSub : m_hContact; } @@ -94,12 +95,11 @@ struct CContactCache : public MZeroedObject __forceinline TWindowData* getDat() const { return m_dat; } size_t getMaxMessageLength(); - int getStatus() const; void updateStats(int iType, size_t value = 0); //////////////////////////////////////////////////////////////////////////// - void updateStatus(); + bool updateStatus(int iStatus); void updateState(); bool updateNick(); void updateMeta(); @@ -129,7 +129,7 @@ private: void releaseAlloced(); MCONTACT m_hContact, m_hSub; - WORD m_wStatus, m_wOldStatus, m_wMetaStatus; + int m_iStatus, m_iOldStatus, m_iMetaStatus; char *m_szMetaProto; wchar_t *m_szAccount; wchar_t m_szNick[80], m_szUIN[80]; diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp index 79cbc76fb5..3cdb3315ac 100644 --- a/plugins/TabSRMM/src/globals.cpp +++ b/plugins/TabSRMM/src/globals.cpp @@ -380,16 +380,15 @@ int CGlobals::DBSettingChanged(WPARAM hContact, LPARAM lParam) return 0; if (!strcmp(cws->szModule, META_PROTO)) - if (hContact != 0 && !strcmp(setting, "Nick")) // filter out this setting to avoid infinite loops while trying to obtain the most online contact + if (!strcmp(setting, "Nick")) // filter out this setting to avoid infinite loops while trying to obtain the most online contact return 0; HWND hwnd = M.FindWindow(hContact); - bool fChanged = false, fNickChanged = false, fExtendedStatusChange = false; - if (!strcmp(cws->szSetting, "Status")) { - c->updateStatus(); - fChanged = true; - } - fNickChanged = c->updateNick(); + bool fChanged = false, fExtendedStatusChange = false; + if (!strcmp(cws->szSetting, "Status")) + fChanged = c->updateStatus(cws->value.wVal); + + fChanged |= c->updateNick(); if (strlen(setting) > 6 && strlen(setting) < 9 && !strncmp(setting, "Status", 6)) { fChanged = true; @@ -406,26 +405,25 @@ int CGlobals::DBSettingChanged(WPARAM hContact, LPARAM lParam) PostMessage(hwnd, DM_UPDATEUIN, 0, 0); } - if (hwnd == NULL) - return 0; - - if (!strcmp(setting, "MirVer")) - PostMessage(hwnd, DM_CLIENTCHANGED, 0, 0); - if (fChanged || fNickChanged || fExtendedStatusChange) - PostMessage(hwnd, DM_UPDATETITLE, 0, 1); - if (fExtendedStatusChange) - PostMessage(hwnd, DM_UPDATESTATUSMSG, 0, 0); - if (fChanged) { - if (c->getStatus() == ID_STATUS_OFFLINE) { // clear typing notification in the status bar when contact goes offline - TWindowData *dat = c->getDat(); - if (dat) { - dat->nTypeSecs = 0; - dat->bShowTyping = 0; - dat->szStatusBar[0] = 0; - PostMessage(c->getHwnd(), DM_UPDATELASTMESSAGE, 0, 0); + if (hwnd != NULL) { + if (!strcmp(setting, "MirVer")) + PostMessage(hwnd, DM_CLIENTCHANGED, 0, 0); + if (fChanged || fExtendedStatusChange) + PostMessage(hwnd, DM_UPDATETITLE, 0, 1); + if (fExtendedStatusChange) + PostMessage(hwnd, DM_UPDATESTATUSMSG, 0, 0); + if (fChanged) { + if (c->getStatus() == ID_STATUS_OFFLINE) { // clear typing notification in the status bar when contact goes offline + TWindowData *dat = c->getDat(); + if (dat) { + dat->nTypeSecs = 0; + dat->bShowTyping = 0; + dat->szStatusBar[0] = 0; + PostMessage(c->getHwnd(), DM_UPDATELASTMESSAGE, 0, 0); + } } + PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_LOGSTATUSCHANGE, MAKELONG(c->getStatus(), c->getOldStatus()), (LPARAM)c); } - PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_LOGSTATUSCHANGE, MAKELONG(c->getStatus(), c->getOldStatus()), (LPARAM)c); } return 0; -- cgit v1.2.3