From 31b191bc8ddb639e488ab8306f71ac1dbabf16f0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 3 Nov 2012 17:32:37 +0000 Subject: removing built-in Clist Modern extra icons part I git-svn-id: http://svn.miranda-ng.org/main/trunk@2167 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/UserInfoEx/src/Flags/svc_flags.cpp | 249 +++++++---------------------- 1 file changed, 62 insertions(+), 187 deletions(-) (limited to 'plugins/UserInfoEx/src/Flags') diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp index 8999df2cca..359d574b30 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp @@ -52,7 +52,6 @@ static HANDLE hMsgWndEventHook = NULL; static HANDLE hIconsChangedHook = NULL; static HANDLE hSettingChangedHook = NULL; -static HANDLE hExtraIconSvcHook = NULL; static HANDLE hOptInitHook = NULL; static int OnContactSettingChanged(WPARAM wParam,LPARAM lParam); @@ -233,136 +232,58 @@ static INT_PTR ServiceDetectContactOriginCountry(WPARAM wParam,LPARAM lParam) * Clist Extra Image functions ***********************************************************************************************************/ -static void CALLBACK SetExtraImage(LPARAM lParam) { +static void CALLBACK SetExtraImage(LPARAM lParam) +{ /* get contact's country */ int countryNumber = ServiceDetectContactOriginCountry((WPARAM)lParam,0);; - //use ExtraIconsService ? - if (myGlobals.ExtraIconsServiceExist) { - EXTRAICON ico; - ico.cbSize = sizeof(ico); - ico.hContact = (HANDLE)lParam; - ico.hExtraIcon = hExtraIconSvc; - ico.icoName = (char*)0; //preset - if(countryNumber!=0xFFFF || gFlagsOpts.bUseUnknownFlag) { - char szId[20]; - mir_snprintf(szId, SIZEOF(szId), (countryNumber==0xFFFF)?"%s_0x%X":"%s_%i","flags",countryNumber); /* buffer safe */ - ico.icoName = szId; - } - CallService(MS_EXTRAICON_SET_ICON, (WPARAM)&ico, 0); - } - //use Clist ExtraImageService - else if(gFlagsOpts.bShowExtraImgFlag) { - int index; - IconExtraColumn iec; - iec.cbSize = sizeof(iec); - iec.ColumnType = gFlagsOpts.idExtraColumn; - iec.hImage = INVALID_HANDLE_VALUE; //preset - /* get icon for contact */ - if(phExtraImageList!=NULL) { /* too early? */ - if(countryNumber!=0xFFFF || gFlagsOpts.bUseUnknownFlag) { - index = CountryNumberToIndex(countryNumber); - /* icon not add to clist extra image list? */ - if(phExtraImageList[index]==INVALID_HANDLE_VALUE) { - HICON hIcon=LoadFlag(countryNumber); // Returned HICON SHOULDN'T be destroyed, it is managed by IcoLib - if(hIcon!=NULL) { - phExtraImageList[index]=(HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON,(WPARAM)hIcon,0); - Skin_ReleaseIcon(hIcon); /* does NULL check */ - } - } - iec.hImage=phExtraImageList[index]; - } - } - //Set icon for contact at needed column - CallService(MS_CLIST_EXTRA_SET_ICON,(WPARAM)lParam,(LPARAM)&iec); + + EXTRAICON ico = { sizeof(ico) }; + ico.hContact = (HANDLE)lParam; + ico.hExtraIcon = hExtraIconSvc; + ico.icoName = (char*)0; //preset + if (countryNumber != 0xFFFF || gFlagsOpts.bUseUnknownFlag) { + char szId[20]; + mir_snprintf(szId, SIZEOF(szId), (countryNumber==0xFFFF)?"%s_0x%X":"%s_%i","flags",countryNumber); /* buffer safe */ + ico.icoName = szId; } + CallService(MS_EXTRAICON_SET_ICON, (WPARAM)&ico, 0); } -static void CALLBACK RemoveExtraImages(LPARAM lParam) { - register HANDLE hContact; - //use ExtraIconsService ? - if (myGlobals.ExtraIconsServiceExist) { - EXTRAICON ico; - ico.cbSize = sizeof(ico); - ico.hExtraIcon = hExtraIconSvc; - ico.icoName = (char *)0; /* invalidate icon for contact*/ - /* enum all contacts */ - for (hContact = DB::Contact::FindFirst(); hContact != NULL; hContact = DB::Contact::FindNext(hContact)) { - ico.hContact = hContact; - CallService(MS_EXTRAICON_SET_ICON, (WPARAM)&ico, 0); - } - } - //use Clist ExtraImageService - else { - IconExtraColumn iec; - iec.cbSize = sizeof(iec); - iec.ColumnType = gFlagsOpts.idExtraColumn; - iec.hImage = INVALID_HANDLE_VALUE; - /* enum all contacts */ - for (hContact = DB::Contact::FindFirst(); hContact != NULL; hContact = DB::Contact::FindNext(hContact)) { - /* invalidate icon for contact*/ - CallService(MS_CLIST_EXTRA_SET_ICON,(WPARAM)hContact,(LPARAM)&iec); - } +static void CALLBACK RemoveExtraImages(LPARAM lParam) +{ + EXTRAICON ico = { sizeof(ico) }; + ico.hExtraIcon = hExtraIconSvc; + ico.icoName = 0; /* invalidate icon for contact*/ + /* enum all contacts */ + for (HANDLE hContact = DB::Contact::FindFirst(); hContact != NULL; hContact = DB::Contact::FindNext(hContact)) { + ico.hContact = hContact; + CallService(MS_EXTRAICON_SET_ICON, (WPARAM)&ico, 0); } } // always call in context of main thread -void EnsureExtraImages() //garantieren - sicherstellen - updaten +void EnsureExtraImages() { - register HANDLE hContact; - //use Clist ExtraImageService? - if (!myGlobals.ExtraIconsServiceExist) { - BYTE idExtraColumnNew = DB::Setting::GetByte(MODNAMEFLAGS,"ExtraImgFlagColumn",SETTING_EXTRAIMGFLAGCOLUMN_DEFAULT); - if(idExtraColumnNew != gFlagsOpts.idExtraColumn) { - /* clear previous column */ - RemoveExtraImages(0); - gFlagsOpts.idExtraColumn = idExtraColumnNew; - /* clear new column */ - RemoveExtraImages(0); - } - } - /* enum all contacts */ - for (hContact = DB::Contact::FindFirst(); hContact != NULL; hContact = DB::Contact::FindNext(hContact)) { - /* update icon */ + for (HANDLE hContact = DB::Contact::FindFirst(); hContact != NULL; hContact = DB::Contact::FindNext(hContact)) CallFunctionBuffered(SetExtraImage,(LPARAM)hContact,TRUE,EXTRAIMAGE_REFRESHDELAY); - } } static void CALLBACK UpdateExtraImages(LPARAM lParam) { if (!lParam) - RemoveExtraImages(0); - else EnsureExtraImages(); - -/* if (!myGlobals.ExtraIconsServiceExist && !gFlagsOpts.bShowExtraImgFlag) - RemoveExtraImages(); - else EnsureExtraImages(); */ -} - -//hookProc ME_CLIST_EXTRA_LIST_REBUILD -static int OnCListRebuildIcons(WPARAM wParam,LPARAM lParam) { - OutputDebugStringA("REBUILD EXTRA\n"); - //use ExtraIconsService ? - if(myGlobals.ExtraIconsServiceExist) return 0; //delete ? - //use Clist ExtraImageService - if(phExtraImageList!=NULL) { - /* invalidate icons */ - for(int i=0;iszModule, "ExtraIcons") && @@ -396,8 +317,8 @@ static int OnExtraIconSvcChanged(WPARAM wParam,LPARAM lParam) { return 0; } -VOID SvcFlagsEnableExtraIcons(BYTE bColumn, BOOLEAN bUpdateDB) { - if (!myGlobals.HaveCListExtraIcons) return; +VOID SvcFlagsEnableExtraIcons(BYTE bColumn, BOOLEAN bUpdateDB) +{ gFlagsOpts.bShowExtraImgFlag = (bColumn!=((BYTE)-1)); if (bUpdateDB) { if(gFlagsOpts.bShowExtraImgFlag) DB::Setting::WriteByte(MODNAMEFLAGS,"ExtraImgFlagColumn", bColumn); @@ -406,73 +327,33 @@ VOID SvcFlagsEnableExtraIcons(BYTE bColumn, BOOLEAN bUpdateDB) { // Flags is on if (gFlagsOpts.bShowExtraImgFlag) { - //use ExtraIconsService ? - if(myGlobals.ExtraIconsServiceExist) { - if(hExtraIconSvc == INVALID_HANDLE_VALUE) { - char szId[20]; - //get local langID for descIcon (try to use user local Flag as icon) - DWORD langid = 0; - int r = GetLocaleInfo( - LOCALE_USER_DEFAULT, - LOCALE_ICOUNTRY | LOCALE_RETURN_NUMBER , - (LPTSTR)&langid, sizeof(langid)/sizeof(TCHAR)); - if (!CallService(MS_UTILS_GETCOUNTRYBYNUMBER,langid,0)) langid = 1; - - EXTRAICON_INFO ico = {0}; - ico.cbSize = sizeof(ico); - ico.type = EXTRAICON_TYPE_ICOLIB; - ico.name = "Flags"; - ico.description = "Flags (uinfoex)"; - mir_snprintf(szId, SIZEOF(szId), (langid==0xFFFF)?"%s_0x%X":"%s_%i","flags",langid); /* buffer safe */ - ico.descIcon = szId; - hExtraIconSvc=(HANDLE)CallService(MS_EXTRAICON_REGISTER, (WPARAM)&ico, 0); - if(hExtraIconSvc) - hExtraIconSvcHook = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnExtraIconSvcChanged); - - } - } - //use Clist ExtraImageService - else { - if(phExtraImageList == NULL){ - phExtraImageList = (HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE)); - /* invalidate icons */ - if(phExtraImageList!=NULL) - for(int i=0;i