summaryrefslogtreecommitdiff
path: root/src/modules/protocols/protochains.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-10-30 20:09:34 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-10-30 20:09:34 +0000
commit0edc13560169b35dc38e2923f0d240531221cd03 (patch)
treef9612a145ab9a864f188815bfb289a6e74c4431e /src/modules/protocols/protochains.cpp
parentcdff820aeb7d935d18fb66027102f69ec96bf92c (diff)
- contact's base proto is cached now
- settings cache structure had been changed git-svn-id: http://svn.miranda-ng.org/main/trunk@2119 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/protocols/protochains.cpp')
-rw-r--r--src/modules/protocols/protochains.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/modules/protocols/protochains.cpp b/src/modules/protocols/protochains.cpp
index 4fe8820e18..977ba9090c 100644
--- a/src/modules/protocols/protochains.cpp
+++ b/src/modules/protocols/protochains.cpp
@@ -28,6 +28,18 @@ extern LIST<PROTOCOLDESCRIPTOR> filters;
static int GetProtocolP(HANDLE hContact, char *szBuf, int cbLen)
{
+ if (currDb == NULL)
+ return 1;
+
+ DBCachedContact *cc = currDb->m_cache->GetCachedContact(hContact);
+ if (cc == NULL)
+ cc = currDb->m_cache->AddContactToCache(hContact);
+ if (cc->szProto != NULL) {
+ strncpy(szBuf, cc->szProto, cbLen);
+ szBuf[cbLen-1] = 0;
+ return 0;
+ }
+
DBVARIANT dbv;
dbv.type = DBVT_ASCIIZ;
dbv.pszVal = szBuf;
@@ -37,7 +49,11 @@ static int GetProtocolP(HANDLE hContact, char *szBuf, int cbLen)
dbcgs.pValue = &dbv;
dbcgs.szModule = "Protocol";
dbcgs.szSetting = "p";
- return (int)CallService(MS_DB_CONTACT_GETSETTINGSTATIC, (WPARAM)hContact, (LPARAM)&dbcgs);
+
+ int res = currDb->GetContactSettingStatic(hContact, &dbcgs);
+ if (res == 0 && !cc->szProto)
+ cc->szProto = currDb->m_cache->GetCachedSetting(NULL, szBuf, 0, strlen(szBuf));
+ return res;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -154,9 +170,12 @@ static INT_PTR Proto_ChainRecv(WPARAM wParam, LPARAM lParam)
PROTOACCOUNT* __fastcall Proto_GetAccount(HANDLE hContact)
{
+ if (hContact == NULL)
+ return NULL;
+
char szProto[40];
if ( GetProtocolP(hContact, szProto, sizeof(szProto)))
- return 0;
+ return NULL;
return Proto_GetAccount(szProto);
}