From 0a4edf42be37bf12786e668837488ce074f476f2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 19 Nov 2012 14:06:55 +0000 Subject: more cleaning of icons' names git-svn-id: http://svn.miranda-ng.org/main/trunk@2372 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/FingerPrintModPlus/src/fingerprint.cpp | 2 +- plugins/SecureIM/src/crypt_icons.cpp | 2 +- plugins/UserInfoEx/src/Flags/svc_flags.cpp | 18 ++------ plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp | 58 ++++++++++++------------ plugins/UserInfoEx/src/Flags/svc_flagsicons.h | 3 +- protocols/AimOscar/src/theme.cpp | 60 +++++++------------------ protocols/IcqOscarJ/src/icq_xstatus.cpp | 8 +--- protocols/JabberG/src/jabber_xstatus.cpp | 4 +- protocols/MRA/src/Mra_functions.cpp | 5 --- protocols/Quotes/src/ExtraImages.cpp | 13 +++--- protocols/Quotes/src/IconLib.cpp | 38 ++++++---------- src/modules/extraicons/DefaultExtraIcons.cpp | 13 ++---- 12 files changed, 81 insertions(+), 143 deletions(-) diff --git a/plugins/FingerPrintModPlus/src/fingerprint.cpp b/plugins/FingerPrintModPlus/src/fingerprint.cpp index 54db722e3b..8b4b542064 100644 --- a/plugins/FingerPrintModPlus/src/fingerprint.cpp +++ b/plugins/FingerPrintModPlus/src/fingerprint.cpp @@ -165,7 +165,7 @@ int FASTCALL ApplyFingerprintImage(HANDLE hContact, LPTSTR szMirVer) if (szMirVer) hImage = GetIconIndexFromFI(szMirVer); - ExtraIcon_SetIcon(hExtraIcon,hContact,hImage); + ExtraIcon_SetIcon(hExtraIcon, hContact, hImage); return 0; } diff --git a/plugins/SecureIM/src/crypt_icons.cpp b/plugins/SecureIM/src/crypt_icons.cpp index ed0b68d15a..0c87625c07 100644 --- a/plugins/SecureIM/src/crypt_icons.cpp +++ b/plugins/SecureIM/src/crypt_icons.cpp @@ -47,7 +47,7 @@ HICON mode2icon(int mode,int type) { } // обновляет иконки в clist и в messagew -void ShowStatusIcon(HANDLE hContact,int mode) +void ShowStatusIcon(HANDLE hContact, int mode) { HANDLE hMC = getMetaContact(hContact); diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp index e3b59f47f8..95d0259ce4 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp @@ -235,12 +235,7 @@ static void CALLBACK SetExtraImage(LPARAM lParam) { /* get contact's country */ int countryNumber = ServiceDetectContactOriginCountry((WPARAM)lParam,0); - if (countryNumber != 0xFFFF || gFlagsOpts.bUseUnknownFlag) { - char szId[20]; - mir_snprintf(szId, SIZEOF(szId), (countryNumber == 0xFFFF) ? "%s_0x%X" : "%s_%i","flags", countryNumber); /* buffer safe */ - ExtraIcon_SetIcon(hExtraIconSvc, (HANDLE)lParam, szId); - } - else ExtraIcon_Clear(hExtraIconSvc, (HANDLE)lParam); + ExtraIcon_SetIcon(hExtraIconSvc, (HANDLE)lParam, (countryNumber != 0xFFFF || gFlagsOpts.bUseUnknownFlag) ? LoadFlagHandle(countryNumber) : NULL); } static void CALLBACK RemoveExtraImages(LPARAM lParam) @@ -314,8 +309,7 @@ VOID SvcFlagsEnableExtraIcons(BYTE bColumn, BOOLEAN bUpdateDB) // Flags is on if (gFlagsOpts.bShowExtraImgFlag) { - if(hExtraIconSvc == INVALID_HANDLE_VALUE) { - char szId[20]; + if (hExtraIconSvc == INVALID_HANDLE_VALUE) { //get local langID for descIcon (try to use user local Flag as icon) DWORD langid = 0; int r = GetLocaleInfo( @@ -324,13 +318,9 @@ VOID SvcFlagsEnableExtraIcons(BYTE bColumn, BOOLEAN bUpdateDB) (LPTSTR)&langid, sizeof(langid)/sizeof(TCHAR)); if (!CallService(MS_UTILS_GETCOUNTRYBYNUMBER,langid,0)) langid = 1; - EXTRAICON_INFO ico = { sizeof(ico) }; - ico.type = EXTRAICON_TYPE_ICOLIB; - ico.name = "Flags"; - ico.description = "Flags (uinfoex)"; + char szId[20]; 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); + hExtraIconSvc = ExtraIcon_Register("Flags", "Flags (uinfoex)", szId); if (hExtraIconSvc) HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnExtraIconSvcChanged); } diff --git a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp index d7119cd75e..fe4ce708bb 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp @@ -138,22 +138,30 @@ static int CountryNumberToBitmapIndex(int countryNumber) HICON LoadFlag(int countryNumber) { - char szId[20],*szCountry; /* create identifier */ - szCountry=(char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber,0); - if(szCountry == NULL) - szCountry=(char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber=0xFFFF,0); + char *szCountry = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber,0); + if (szCountry == NULL) + szCountry = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber=0xFFFF,0); - wsprintfA(szId,(countryNumber==0xFFFF)?"%s_0x%X":"%s_%i","flags",countryNumber); /* buffer safe */ + char szId[20]; + wsprintfA(szId,(countryNumber==0xFFFF) ? "%s_0x%X" : "%s_%i","flags",countryNumber); /* buffer safe */ return Skin_GetIcon(szId); } +HANDLE LoadFlagHandle(int countryNumber) +{ + if (phIconHandles == NULL) + return NULL; + + return phIconHandles[ CountryNumberToIndex(countryNumber) ]; +} + int CountryNumberToIndex(int countryNumber) { - int i,nf=0; - for(i=0;iFI_Unload(dib_ico); return; } - //FIP->FI_SaveU(fif,dib_ico,_T("d:\\CD-Archiv\\Miranda\\trunk\\miranda\\bin9\\Debug Unicode\\Plugins\\dib_ico.bmp"),0); } else { FIP->FI_Unload(dib); @@ -404,29 +411,22 @@ VOID InitIcons() DeleteObject(hScrBM); hScrBM = NULL; DeleteObject(hbmMask); hbmMask = NULL; - if(himl!=NULL) { - phIconHandles=(HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE)); - if(phIconHandles!=NULL) { + if (himl != NULL) { + phIconHandles = (HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE)); + if (phIconHandles != NULL) { char szId[20]; - int i,index; - SKINICONDESC skid; - - /* register icons */ - ZeroMemory(&skid,sizeof(skid)); - skid.cbSize = sizeof(skid); - skid.ptszSection = LPGENT("Country Flags"); - skid.pszName = szId; // name to refer to icon when playing and in db - //skid.pszDefaultFile = NULL; // default icon file to use - //skid.iDefaultIndex = NULL; // index of icon in default file - skid.cx = GetSystemMetrics(SM_CXSMICON); - skid.cy = GetSystemMetrics(SM_CYSMICON); - skid.flags = SIDF_SORTED|SIDF_TCHAR; - - for(i=0;igetByte(hContact, "ChatRoom", 0)) return; unsigned i = ppro->getByte(hContact, AIM_KEY_AC, 0) - 1; - - if (i < 5) { - char name[64]; - mir_snprintf(name, sizeof(name), "AIM_%s", extra_AT_icon_name[i]); - ExtraIcon_SetIcon(hExtraAT, hContact, name); - } - else ExtraIcon_Clear(hExtraAT, hContact); + ExtraIcon_SetIcon(hExtraAT, hContact, (i < 5) ? GetIconHandle(extra_AT_icon_name[i]) : NULL); } static void set_ES_icon(CAimProto* ppro, HANDLE hContact) @@ -188,13 +169,7 @@ static void set_ES_icon(CAimProto* ppro, HANDLE hContact) if (ppro->getByte(hContact, "ChatRoom", 0)) return; unsigned i = ppro->getByte(hContact, AIM_KEY_ET, 0) - 1; - - if (i < 2) { - char name[64]; - mir_snprintf(name, sizeof(name), "AIM_%s", extra_ES_icon_name[i]); - ExtraIcon_SetIcon(hExtraES, hContact, name); - } - else ExtraIcon_Clear(hExtraES, hContact); + ExtraIcon_SetIcon(hExtraAT, hContact, (i < 2) ? GetIconHandle(extra_ES_icon_name[i]) : NULL); } void set_contact_icon(CAimProto* ppro, HANDLE hContact) @@ -206,10 +181,9 @@ void set_contact_icon(CAimProto* ppro, HANDLE hContact) void remove_AT_icons(CAimProto* ppro) { HANDLE hContact = db_find_first(); - while (hContact) - { + while (hContact) { if (ppro->is_my_contact(hContact) && !ppro->getByte(hContact, "ChatRoom", 0)) - clear_AT_icon(hContact); + ExtraIcon_Clear(hExtraAT, hContact); hContact = db_find_next(hContact); } @@ -218,10 +192,10 @@ void remove_AT_icons(CAimProto* ppro) void remove_ES_icons(CAimProto* ppro) { HANDLE hContact = db_find_first(); - while (hContact) - { + while (hContact) { if (ppro->is_my_contact(hContact) && !ppro->getByte(hContact, "ChatRoom", 0)) - clear_ES_icon(hContact); + ExtraIcon_Clear(hExtraES, hContact); + hContact = db_find_next(hContact); } } @@ -229,8 +203,7 @@ void remove_ES_icons(CAimProto* ppro) void add_AT_icons(CAimProto* ppro) { HANDLE hContact = db_find_first(); - while (hContact) - { + while (hContact) { if (ppro->is_my_contact(hContact)) set_AT_icon(ppro, hContact); @@ -241,8 +214,7 @@ void add_AT_icons(CAimProto* ppro) void add_ES_icons(CAimProto* ppro) { HANDLE hContact = db_find_first(); - while (hContact) - { + while (hContact) { if (ppro->is_my_contact(hContact)) set_ES_icon(ppro, hContact); diff --git a/protocols/IcqOscarJ/src/icq_xstatus.cpp b/protocols/IcqOscarJ/src/icq_xstatus.cpp index ab612f30b3..9802b1dee7 100644 --- a/protocols/IcqOscarJ/src/icq_xstatus.cpp +++ b/protocols/IcqOscarJ/src/icq_xstatus.cpp @@ -182,13 +182,7 @@ void releaseXStatusIcon(int bStatus, UINT flags) void setContactExtraIcon(HANDLE hContact, int xstatus) { - if (xstatus <= 0) - ExtraIcon_Clear(hExtraXStatus, hContact); - else { - char szTemp[MAX_PATH]; - null_snprintf(szTemp, sizeof(szTemp), "icq_xstatus%d", xstatus-1); - ExtraIcon_SetIcon(hExtraXStatus, hContact, szTemp); - } + ExtraIcon_SetIcon(hExtraXStatus, hContact, (xstatus > 0) ? hXStatusIcons[xstatus-1]->Handle() : NULL); } #define NULLCAP {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index 7c96e536f1..4f6e625fcd 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -683,7 +683,7 @@ void CPepMood::ResetExtraIcon(HANDLE hContact) void CPepMood::SetExtraIcon(HANDLE hContact, char *szMood) { - ExtraIcon_SetIcon(hExtraMood, hContact, szMood == NULL ? NULL : g_MoodIcons.GetIcolibName(szMood)); + ExtraIcon_SetIcon(hExtraMood, hContact, szMood == NULL ? NULL : g_MoodIcons.GetIcolibHandle(szMood)); } void CPepMood::SetMood(HANDLE hContact, const TCHAR *szMood, const TCHAR *szText) @@ -1075,7 +1075,7 @@ void CPepActivity::ResetExtraIcon(HANDLE hContact) void CPepActivity::SetExtraIcon(HANDLE hContact, char *szActivity) { - ExtraIcon_SetIcon(hExtraActivity, hContact, szActivity == NULL ? NULL : g_ActivityIcons.GetIcolibName(szActivity)); + ExtraIcon_SetIcon(hExtraActivity, hContact, szActivity == NULL ? NULL : g_ActivityIcons.GetIcolibHandle(szActivity)); } void CPepActivity::SetActivity(HANDLE hContact, LPCTSTR szFirst, LPCTSTR szSecond, LPCTSTR szText) diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 07ed22270d..5c6905df7e 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -1153,11 +1153,6 @@ void CMraProto::CListShowMenuItem(HANDLE hMenuItem, BOOL bShow) CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuItem, (LPARAM)&mi); } -int ExtraSetIcon(HANDLE hExtraIcon, HANDLE hContact, HANDLE hImage) -{ - return ExtraIcon_SetIcon(hExtraIcon, hContact, hImage); -} - size_t CopyNumber(LPCVOID lpcOutBuff, LPCVOID lpcBuff, size_t dwLen) { BYTE btChar; diff --git a/protocols/Quotes/src/ExtraImages.cpp b/protocols/Quotes/src/ExtraImages.cpp index 1fbc6d21ff..a89032e53c 100644 --- a/protocols/Quotes/src/ExtraImages.cpp +++ b/protocols/Quotes/src/ExtraImages.cpp @@ -7,6 +7,7 @@ #include "IQuotesProvider.h" #include "Log.h" #include "DBUtils.h" +#include "resource.h" CExtraImages::CExtraImages() : m_hExtraIcons(ExtraIcon_Register(ICON_STR_QUOTE,QUOTES_PROTOCOL_NAME,Quotes_MakeIconName(ICON_STR_MAIN).c_str())), @@ -36,19 +37,21 @@ bool CExtraImages::SetContactExtraImage(HANDLE hContact,EImageIndex nIndex)const if (!m_hExtraIcons) return false; - std::string sIconName; + HANDLE hIcolib; switch(nIndex) { case eiUp: - sIconName = Quotes_MakeIconName(ICON_STR_QUOTE_UP); + hIcolib = Quotes_GetIconHandle(IDI_ICON_UP); break; case eiDown: - sIconName = Quotes_MakeIconName(ICON_STR_QUOTE_DOWN); + hIcolib = Quotes_GetIconHandle(IDI_ICON_DOWN); break; case eiNotChanged: - sIconName = Quotes_MakeIconName(ICON_STR_QUOTE_NOT_CHANGED); + hIcolib = Quotes_GetIconHandle(IDI_ICON_NOTCHANGED); break; + default: + hIcolib = NULL; } - return (0 == ExtraIcon_SetIcon(m_hExtraIcons,hContact,sIconName.c_str())); + return ExtraIcon_SetIcon(m_hExtraIcons, hContact, hIcolib) == 0; } int QuotesEventFunc_onExtraImageApply(WPARAM wp,LPARAM lp) diff --git a/protocols/Quotes/src/IconLib.cpp b/protocols/Quotes/src/IconLib.cpp index 530d1defd3..9ac96599a5 100644 --- a/protocols/Quotes/src/IconLib.cpp +++ b/protocols/Quotes/src/IconLib.cpp @@ -17,26 +17,25 @@ namespace { struct CIconList { - TCHAR* szDescr; + TCHAR* szDescr; char* szName; int defIconID; -// TCHAR* szSection; HANDLE hIconLibItem; }; CIconList iconList[] = { - {_T("Protocol icon"),ICON_STR_MAIN,IDI_ICON_MAIN}, - {_T("Quote/Rate up"),ICON_STR_QUOTE_UP,IDI_ICON_UP}, - {_T("Quote/Rate down"),ICON_STR_QUOTE_DOWN,IDI_ICON_DOWN}, - {_T("Quote/Rate not changed"),ICON_STR_QUOTE_NOT_CHANGED,IDI_ICON_NOTCHANGED}, - {_T("Quote Section"),ICON_STR_SECTION,IDI_ICON_SECTION}, - {_T("Quote"),ICON_STR_QUOTE,IDI_ICON_QUOTE}, - {_T("Currency Converter"),ICON_STR_CURRENCY_CONVERTER,IDI_ICON_CURRENCY_CONVERTER}, - {_T("Refresh"),ICON_STR_REFRESH,IDI_ICON_REFRESH}, - {_T("Export"),ICON_STR_EXPORT,IDI_ICON_EXPORT}, - {_T("Swap button"),ICON_STR_SWAP,IDI_ICON_SWAP}, - {_T("Import"),ICON_STR_IMPORT,IDI_ICON_IMPORT}, + { _T("Protocol icon"), ICON_STR_MAIN, IDI_ICON_MAIN }, + { _T("Quote/Rate up"), ICON_STR_QUOTE_UP, IDI_ICON_UP }, + { _T("Quote/Rate down"), ICON_STR_QUOTE_DOWN, IDI_ICON_DOWN }, + { _T("Quote/Rate not changed"), ICON_STR_QUOTE_NOT_CHANGED, IDI_ICON_NOTCHANGED }, + { _T("Quote Section"), ICON_STR_SECTION, IDI_ICON_SECTION }, + { _T("Quote"), ICON_STR_QUOTE, IDI_ICON_QUOTE }, + { _T("Currency Converter"), ICON_STR_CURRENCY_CONVERTER, IDI_ICON_CURRENCY_CONVERTER }, + { _T("Refresh"), ICON_STR_REFRESH, IDI_ICON_REFRESH }, + { _T("Export"), ICON_STR_EXPORT, IDI_ICON_EXPORT }, + { _T("Swap button"), ICON_STR_SWAP, IDI_ICON_SWAP }, + { _T("Import"), ICON_STR_IMPORT, IDI_ICON_IMPORT } }; } @@ -54,18 +53,7 @@ void Quotes_IconsInit() sid.flags = SIDF_ALL_TCHAR; sid.ptszSection = A2T(QUOTES_PROTOCOL_NAME); -// TCHAR* szRootSection = TranslateTS(A2T(QUOTES_PROTOCOL_NAME)); - - for ( int i = 0; i < SIZEOF(iconList); i++ ) - { -// char szSettingName[100]; -// TCHAR szSectionName[100]; -// mir_snprintf( szSettingName, sizeof( szSettingName ),"%s_%s",QUOTES_PROTOCOL_NAME, iconList[i].szName ); -// { -// mir_sntprintf( szSectionName, SIZEOF( szSectionName ),_T("%s/%s"), TranslateT("Protocols"), szRootSection); -// sid.ptszSection = szSectionName; -// } - + for (int i = 0; i < SIZEOF(iconList); i++) { std::string sName = Quotes_MakeIconName( iconList[i].szName); sid.pszName = const_cast(sName.c_str()); sid.ptszDescription = iconList[i].szDescr; diff --git a/src/modules/extraicons/DefaultExtraIcons.cpp b/src/modules/extraicons/DefaultExtraIcons.cpp index 5a7917a331..5e5c3da926 100644 --- a/src/modules/extraicons/DefaultExtraIcons.cpp +++ b/src/modules/extraicons/DefaultExtraIcons.cpp @@ -76,23 +76,18 @@ static void SetVisibility(HANDLE hContact, int apparentMode, BOOL clear) if (apparentMode == ID_STATUS_OFFLINE) ico = "ChatActivity"; - if (ico == NULL && !clear) - return; - - ExtraIcon_SetIcon(hExtraChat, hContact, ico); + if (ico != NULL || clear) + ExtraIcon_SetIcon(hExtraChat, hContact, ico); } else { // Not chat if (apparentMode == ID_STATUS_OFFLINE) ico = "core_main_47"; - else if (apparentMode == ID_STATUS_ONLINE) ico = "core_main_46"; - if (ico == NULL && !clear) - return; - - ExtraIcon_SetIcon(hExtraVisibility, hContact, ico); + if (ico != NULL || clear) + ExtraIcon_SetIcon(hExtraVisibility, hContact, ico); } } -- cgit v1.2.3