From 21bc5f8f834fd4cf2b961264c2f258f6f3dd09e3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 4 Nov 2012 19:54:17 +0000 Subject: replacement for the old clist interface code git-svn-id: http://svn.miranda-ng.org/main/trunk@2192 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/src/icq_servlist.cpp | 52 ++++++++------------------------ protocols/IcqOscarJ/src/init.cpp | 3 ++ 2 files changed, 15 insertions(+), 40 deletions(-) (limited to 'protocols/IcqOscarJ/src') diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp index 4afdeae7e4..ee0355443a 100644 --- a/protocols/IcqOscarJ/src/icq_servlist.cpp +++ b/protocols/IcqOscarJ/src/icq_servlist.cpp @@ -1609,53 +1609,25 @@ int CIcqProto::getCListGroupHandle(const char *szGroup) //!! this function is not thread-safe due to the use of cli->pfnGetGroupName() int CIcqProto::getCListGroupExists(const char *szGroup) { - int hGroup = 0; - CLIST_INTERFACE *clint = NULL; - - if (!szGroup) return 0; - - if (ServiceExists(MS_CLIST_RETRIEVE_INTERFACE)) - clint = (CLIST_INTERFACE*)CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, 0); - - if (clint && clint->version >= 1) - { // we've got clist interface, use it - int size = strlennull(szGroup) + 2; - TCHAR *tszGroup = (TCHAR*)_alloca(size * sizeof(TCHAR)); - - if (utf8_to_tchar_static(szGroup, tszGroup, size)) - for (int i = 1; TRUE; i++) - { - TCHAR *tszGroupName = (TCHAR*)clint->pfnGetGroupName(i, NULL); - - if (!tszGroupName) break; - - if (!_tcscmp(tszGroup, tszGroupName)) - { // we have found the group - hGroup = i; - break; - } - } - } - else - { // old ansi version - no other way - int size = strlennull(szGroup) + 2; - char *aszGroup = (char*)_alloca(size); - - utf8_decode_static(szGroup, aszGroup, size); + if (!szGroup) + return 0; - for (int i = 1; TRUE; i++) - { - char *paszGroup = (char*)CallService(MS_CLIST_GROUPGETNAME, i, 0); + int hGroup = 0; + int size = strlennull(szGroup) + 2; + TCHAR *tszGroup = (TCHAR*)_alloca(size * sizeof(TCHAR)); - if (!paszGroup) break; + if (utf8_to_tchar_static(szGroup, tszGroup, size)) + for (int i = 1; TRUE; i++) { + TCHAR *tszGroupName = (TCHAR*)pcli->pfnGetGroupName(i, NULL); + if (!tszGroupName) + break; - if (!strcmpnull(aszGroup, paszGroup)) - { // we found the group + if (!_tcscmp(tszGroup, tszGroupName)) { + // we have found the group hGroup = i; break; } } - } return hGroup; } diff --git a/protocols/IcqOscarJ/src/init.cpp b/protocols/IcqOscarJ/src/init.cpp index ab4bae973a..b2bf2bbc7e 100644 --- a/protocols/IcqOscarJ/src/init.cpp +++ b/protocols/IcqOscarJ/src/init.cpp @@ -32,6 +32,7 @@ HINSTANCE hInst; int hLangpack; +CLIST_INTERFACE *pcli; IcqIconHandle hStaticIcons[4]; HANDLE hExtraXStatus; @@ -85,6 +86,8 @@ extern "C" int __declspec(dllexport) Load(void) srand(time(NULL)); _tzset(); + pcli = (CLIST_INTERFACE*)CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)hInst); + // Register the module PROTOCOLDESCRIPTOR pd = {0}; pd.cbSize = sizeof(pd); -- cgit v1.2.3