From 0edc13560169b35dc38e2923f0d240531221cd03 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 30 Oct 2012 20:09:34 +0000 Subject: - 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 --- src/modules/protocols/protochains.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/modules/protocols') 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 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); } -- cgit v1.2.3