summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-08-02 15:14:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-08-02 15:14:37 +0000
commitc3a6ce0476f75bd3b5df4e721e8d0bcb6e3a8989 (patch)
tree3313bba2a9e5e5c0bd5d5a05738d558943890df7 /plugins/TabSRMM
parent88f7ddde0024f0bac97fe06b6529ebb3241b626e (diff)
- unused parameter removed;
- function updateMeta() made more intellectual: if the sub's change detected, it'd renew all dependent info git-svn-id: http://svn.miranda-ng.org/main/trunk@10022 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r--plugins/TabSRMM/src/contactcache.cpp24
-rw-r--r--plugins/TabSRMM/src/contactcache.h6
-rw-r--r--plugins/TabSRMM/src/globals.cpp9
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp5
4 files changed, 22 insertions, 22 deletions
diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp
index 026f351f62..68078159fd 100644
--- a/plugins/TabSRMM/src/contactcache.cpp
+++ b/plugins/TabSRMM/src/contactcache.cpp
@@ -73,7 +73,7 @@ void CContactCache::initPhaseTwo()
if (m_Valid) {
m_isMeta = db_mc_isMeta(cc->contactID) != 0; // don't use cc->IsMeta() here
if (m_isMeta)
- updateMeta(true);
+ updateMeta();
updateState();
updateFavorite();
}
@@ -149,15 +149,22 @@ bool CContactCache::updateStatus()
* MC protocol fires one of its events OR when a relevant database value changes
* in the master contact.
*/
-void CContactCache::updateMeta(bool fForce)
+void CContactCache::updateMeta()
{
if (m_Valid) {
- MCONTACT hSub = db_mc_getSrmmSub(cc->contactID);
- m_szMetaProto = GetContactProto(hSub);
- m_wMetaStatus = (WORD)db_get_w(hSub, m_szMetaProto, "Status", ID_STATUS_OFFLINE);
- m_xStatus = (WORD)db_get_w(hSub, m_szMetaProto, "XStatusId", ID_STATUS_OFFLINE);
+ 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);
+
+ if (hOldSub != m_hSub) {
+ updateStatus();
+ updateNick();
+ updateUIN();
+ }
}
else {
+ m_hSub = 0;
m_szMetaProto = NULL;
m_wMetaStatus = ID_STATUS_OFFLINE;
m_xStatus = 0;
@@ -609,8 +616,3 @@ int CContactCache::getMaxMessageLength()
}
return m_nMax;
}
-
-const MCONTACT CContactCache::getActiveContact() const
-{
- return (m_isMeta) ? db_mc_getSrmmSub(m_hContact) : m_hContact;
-}
diff --git a/plugins/TabSRMM/src/contactcache.h b/plugins/TabSRMM/src/contactcache.h
index d38a622d6c..746bfb05df 100644
--- a/plugins/TabSRMM/src/contactcache.h
+++ b/plugins/TabSRMM/src/contactcache.h
@@ -77,7 +77,7 @@ 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;
+ const MCONTACT getActiveContact() const { return (m_isMeta) ? m_hSub : m_hContact; }
const DWORD getIdleTS() const { return m_idleTS; }
const char* getProto() const { return cc->szProto; }
const char* getActiveProto() const { return m_isMeta ? (m_szMetaProto ? m_szMetaProto : cc->szProto) : cc->szProto; }
@@ -106,7 +106,7 @@ struct CContactCache : public MZeroedObject
void updateState();
bool updateStatus();
bool updateNick();
- void updateMeta(bool fForce = false);
+ void updateMeta();
bool updateUIN();
void updateStatusMsg(const char *szKey = 0);
void setWindowData(const HWND hwnd = 0, TWindowData *dat = 0);
@@ -132,7 +132,7 @@ private:
void allocHistory();
void releaseAlloced();
- MCONTACT m_hContact;
+ MCONTACT m_hContact, m_hSub;
WORD m_wStatus, m_wOldStatus, m_wMetaStatus;
char *m_szMetaProto;
TCHAR *m_szAccount;
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp
index 54d0b9da6c..718b289fe3 100644
--- a/plugins/TabSRMM/src/globals.cpp
+++ b/plugins/TabSRMM/src/globals.cpp
@@ -433,10 +433,8 @@ int CGlobals::DBSettingChanged(WPARAM hContact, LPARAM lParam)
}
if (lstrlenA(setting) > 6 && lstrlenA(setting) < 9 && !strncmp(setting, "Status", 6)) {
fChanged = true;
- if (c) {
- c->updateMeta(true);
- c->updateUIN();
- }
+ if (c)
+ c->updateMeta();
}
else if (!strcmp(setting, "MirVer"))
PostMessage(hwnd, DM_CLIENTCHANGED, 0, 0);
@@ -495,9 +493,8 @@ int CGlobals::MetaContactEvent(WPARAM hContact, LPARAM lParam)
if (hContact) {
CContactCache *c = CContactCache::getContactCache(hContact);
if (c) {
- c->updateMeta(true);
+ c->updateMeta();
if (c->getHwnd()) {
- c->updateUIN(); // only do this for open windows, not needed normally
::PostMessage(c->getHwnd(), DM_UPDATETITLE, 0, 0);
::PostMessage(c->getHwnd(), DM_UPDATEPICLAYOUT, 0, 0);
}
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 9406db148b..467d2990dc 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -1227,8 +1227,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
dat->szProto = const_cast<char *>(dat->cache->getProto());
dat->bIsMeta = dat->cache->isMeta();
if (dat->bIsMeta)
- dat->cache->updateMeta(true);
- dat->cache->updateUIN();
+ dat->cache->updateMeta();
+ else
+ dat->cache->updateUIN();
if (dat->hContact && dat->szProto != NULL) {
dat->wStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE);