From 95aa036670a1ce2c461ffd9bd3a586d191ee4675 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 19 Jul 2012 22:48:01 +0000 Subject: - various icolib fixes; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@1061 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AuthState/src/main.cpp | 12 +-- plugins/BASS_interface/src/Main.cpp | 12 +-- plugins/BossKeyPlus/src/BossKey.cpp | 4 +- plugins/BuddyExpectator/src/BuddyExpectator.cpp | 36 ++++--- plugins/Chat/src/options.cpp | 24 ++--- plugins/Clist_modern/src/modern_clcitems.cpp | 21 ++-- plugins/Clist_nicer/SRC/clui.cpp | 7 +- plugins/Console/src/Console.cpp | 6 +- plugins/CountryFlags/src/icons.cpp | 60 ++++++----- plugins/Db_autobackups/main.cpp | 5 +- plugins/Dbx_mmap_SA/dialogs.cpp | 16 +-- plugins/ExtraIcons/src/options.cpp | 2 +- plugins/ExtraIcons/src/usedIcons.cpp | 2 +- plugins/Gender/main.cpp | 5 +- plugins/HistorySweeperLight/options.cpp | 10 +- plugins/IgnoreState/main.cpp | 1 - plugins/ListeningTo/listeningto.cpp | 4 +- plugins/MenuItemEx/main.cpp | 3 +- plugins/MetaContacts/icons.cpp | 48 +++------ plugins/MetaContacts/meta_services.cpp | 2 - plugins/MetaContacts/metacontacts.h | 2 +- plugins/SRMM/globals.cpp | 14 ++- plugins/Scriver/globals.cpp | 127 ++++++++++++------------ plugins/SpellChecker/ardialog.cpp | 2 +- plugins/SpellChecker/options.cpp | 2 +- plugins/SpellChecker/spellchecker.cpp | 4 +- plugins/TabSRMM/src/msgs.cpp | 20 ++-- plugins/Utils/mir_icons.cpp | 46 +++------ plugins/Utils/mir_icons.h | 4 +- plugins/Utils/mir_options.cpp | 2 +- protocols/AimOscar/theme.cpp | 3 +- protocols/Gadu-Gadu/icolib.cpp | 54 +++++----- protocols/IRCG/options.cpp | 44 ++++---- protocols/IcqOscarJ/iconlib.cpp | 1 - protocols/JabberG/jabber_icolib.cpp | 19 ++-- protocols/MSN/msn_opts.cpp | 7 +- protocols/Yahoo/icolib.cpp | 4 +- 37 files changed, 290 insertions(+), 345 deletions(-) diff --git a/plugins/AuthState/src/main.cpp b/plugins/AuthState/src/main.cpp index 8494d0b9a3..29224bd3d3 100644 --- a/plugins/AuthState/src/main.cpp +++ b/plugins/AuthState/src/main.cpp @@ -219,14 +219,14 @@ int onPrebuildContactMenu(WPARAM wParam, LPARAM lParam) int onModulesLoaded(WPARAM wParam,LPARAM lParam) { // IcoLib support - SKINICONDESC sid = {0}; - ZeroMemory(&sid, sizeof(sid)); TCHAR szFile[MAX_PATH]; + GetModuleFileName(g_hInst, szFile, MAX_PATH); + + SKINICONDESC sid = {0}; sid.cbSize = sizeof(sid); sid.flags = SIDF_ALL_TCHAR; sid.ptszSection = _T("Auth State"); - GetModuleFileName(g_hInst, szFile, MAX_PATH); sid.ptszDefaultFile = szFile; sid.ptszDescription = _T("Auth"); @@ -246,12 +246,10 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) // extra icons hExtraIcon = ExtraIcon_Register("authstate", "Auth State", "authgrant_icon"); - if (hExtraIcon != NULL) - { + if (hExtraIcon != NULL) { // Set initial value for all contacts HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while (hContact != NULL) - { + while (hContact != NULL) { onExtraImageApplying((WPARAM)hContact, 1); hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); } diff --git a/plugins/BASS_interface/src/Main.cpp b/plugins/BASS_interface/src/Main.cpp index 2be38e4028..828babac15 100644 --- a/plugins/BASS_interface/src/Main.cpp +++ b/plugins/BASS_interface/src/Main.cpp @@ -311,21 +311,21 @@ static HANDLE hIconLibItem[SIZEOF(iconList)]; void InitIcons(void) { - int i; char szSettingName[100]; SKINICONDESC sid = {0}; TCHAR szFile[MAX_PATH]; - + TCHAR szFile[MAX_PATH]; GetModuleFileName(hInst, szFile, SIZEOF(szFile)); + SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); sid.ptszDefaultFile = szFile; sid.cx = sid.cy = 16; - sid.pszName = szSettingName; sid.pszSection = ModuleName; sid.flags = SIDF_PATH_TCHAR; - for (i = 0; i < SIZEOF(iconList); i++) - { + for (int i=0; i < SIZEOF(iconList); i++) { + char szSettingName[100]; mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", ModuleName, iconList[i].szName); - + + sid.pszName = szSettingName; sid.pszDescription = (char*)iconList[i].szDescr; sid.iDefaultIndex = -iconList[i].defIconID; hIconLibItem[i] = Skin_AddIcon(&sid); diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp index cba063070e..5d4d6d4c21 100644 --- a/plugins/BossKeyPlus/src/BossKey.cpp +++ b/plugins/BossKeyPlus/src/BossKey.cpp @@ -602,21 +602,19 @@ static TCHAR *GetBossKeyText(void) static int IcoLibInit (void) // Icolib support { - SKINICONDESC sid = {0}; TCHAR tszFile[MAX_PATH]; GetModuleFileName(g_hInstance, tszFile, MAX_PATH); + SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); sid.flags = SIDF_ALL_TCHAR; sid.ptszDefaultFile = tszFile; sid.cx = sid.cy = 16; sid.ptszSection = _T("BossKey"); - sid.pszName = "hidemim"; sid.ptszDescription = _T("Hide Miranda IM"); sid.iDefaultIndex = -IDI_DLGPASSWD; g_hIcon = Skin_AddIcon(&sid); - return 0; } diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index ff0382bd61..9ef2779a02 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -742,10 +742,11 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) g_IECClear.hImage = (HANDLE) -1; } + TCHAR szFile[MAX_PATH]; + GetModuleFileNameA(hInst, szFile, MAX_PATH); + // IcoLib support SKINICONDESC sid = {0}; - char szFile[MAX_PATH]; - GetModuleFileNameA(hInst, szFile, MAX_PATH); sid.pszDefaultFile = szFile; sid.cbSize = sizeof(sid); sid.pszSection = "BuddyExpectator"; @@ -776,12 +777,12 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) Skin_AddIcon(&sid); hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onIconsChanged); - + onIconsChanged(0,0); - + if (options.enableMissYou) { hPrebuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPrebuildContactMenu); - + CLISTMENUITEM mi = {0}; mi.cbSize = sizeof(CLISTMENUITEM); mi.flags = CMIF_ICONFROMICOLIB; @@ -791,23 +792,22 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) mi.pszService = "BuddyExpectator/actionMissYouClick"; hContactMenu = Menu_AddContactMenuItem(&mi); } - - + missyouactions[0].cbSize = sizeof(POPUPACTION); missyouactions[0].lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"disabled_icon"); lstrcpy(missyouactions[0].lpzTitle, Translate("Disable Miss You")); missyouactions[0].wParam = missyouactions[0].lParam = 1; - + hideactions[0].cbSize = sizeof(POPUPACTION); hideactions[0].lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"hide_icon"); lstrcpy(hideactions[0].lpzTitle, Translate("Hide contact")); hideactions[0].wParam = hideactions[0].lParam = 2; - + hideactions[1].cbSize = sizeof(POPUPACTION); hideactions[1].lchIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)"neverhide_icon"); lstrcpy(hideactions[1].lpzTitle, Translate("Never hide this contact")); hideactions[1].wParam = hideactions[1].lParam = 3; - + return 0; } @@ -825,8 +825,8 @@ int ContactAdded(WPARAM wParam, LPARAM lParam) int onSystemOKToExit(WPARAM wParam,LPARAM lParam) { UnhookEvent(hEventContactSetting); - UnhookEvent(hEventContactAdded); - UnhookEvent(hEventUserInfoInit); + UnhookEvent(hEventContactAdded); + UnhookEvent(hEventUserInfoInit); if (hPrebuildContactMenu) UnhookEvent(hPrebuildContactMenu); UnhookEvent(hIcoLibIconsChanged); UnhookEvent(hModulesLoaded); @@ -834,19 +834,19 @@ int onSystemOKToExit(WPARAM wParam,LPARAM lParam) UnhookEvent(hSystemOKToExit); UnhookEvent(hHookExtraIconsRebuild); UnhookEvent(hHookExtraIconsApply); - + DestroyServiceFunction(hContactReturnedAction); DestroyServiceFunction(hContactStillAbsentAction); DestroyServiceFunction(hMissYouAction); DestroyServiceFunction(hMenuMissYouClick); DeinitOptions(); - + if (hIcoLibIconsChanged) CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); else DestroyIcon(hIcon); - + return 0; } @@ -873,9 +873,8 @@ extern "C" int __declspec(dllexport) Load(void) DBVARIANT dbv; HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); DWORD current_time = (DWORD)time(0); - while (hContact != 0) - { - if (!DBGetContactSetting(hContact, MODULE_NAME, "CreationTime", &dbv)) + while (hContact != 0) { + if ( !DBGetContactSetting(hContact, MODULE_NAME, "CreationTime", &dbv)) DBFreeVariant(&dbv); else DBWriteContactSettingDword(hContact, MODULE_NAME, "CreationTime", current_time); @@ -892,4 +891,3 @@ extern "C" int __declspec(dllexport) Unload(void) return 0; } - diff --git a/plugins/Chat/src/options.cpp b/plugins/Chat/src/options.cpp index 381054d5ca..89d39d7f47 100644 --- a/plugins/Chat/src/options.cpp +++ b/plugins/Chat/src/options.cpp @@ -429,9 +429,9 @@ void RegisterFonts( void ) struct { int size; - const char* szSection; - const char* szDescr; - const char* szName; + char* szSection; + char* szDescr; + char* szName; int defIconID; } static const iconList[] = @@ -477,19 +477,19 @@ static const iconList[] = void AddIcons(void) { - int i; - SKINICONDESC sid = {0}; - char szFile[MAX_PATH]; - GetModuleFileNameA(g_hInst, szFile, MAX_PATH); + TCHAR szFile[MAX_PATH]; + GetModuleFileName(g_hInst, szFile, MAX_PATH); + SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); - sid.pszDefaultFile = szFile; + sid.ptszDefaultFile = szFile; + sid.flags = SIDF_PATH_TCHAR; - for ( i = 0; i < SIZEOF(iconList); i++ ) { + for (int i = 0; i < SIZEOF(iconList); i++ ) { sid.cx = sid.cy = iconList[i].size; - sid.pszSection = (char*)iconList[i].szSection; - sid.pszDescription = (char*)iconList[i].szDescr; - sid.pszName = (char*)iconList[i].szName; + sid.pszSection = iconList[i].szSection; + sid.pszDescription = iconList[i].szDescr; + sid.pszName = iconList[i].szName; sid.iDefaultIndex = -iconList[i].defIconID; Skin_AddIcon(&sid); } } diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index 2325cef988..b8b99a48e5 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -754,7 +754,7 @@ int __fastcall CLVM_GetContactHiddenStatus(HANDLE hContact, char *szProto, struc char szTemp[64]; TCHAR szGroupMask[256]; DWORD dwLocalMask; - PDNCE pdnce = (PDNCE)pcli->pfnGetCacheEntry(hContact); + PDNCE pdnce = (PDNCE)pcli->pfnGetCacheEntry(hContact); BOOL fEmbedded = dat->force_in_dialog; // always hide subcontacts (but show them on embedded contact lists) @@ -766,18 +766,15 @@ int __fastcall CLVM_GetContactHiddenStatus(HANDLE hContact, char *szProto, struc } if (g_CluiData.bMetaAvail && dat != NULL && dat->IsMetaContactsEnabled && g_szMetaModuleName && db_get_b(hContact, g_szMetaModuleName, "IsSubcontact", 0)) return -1; //subcontact - if (pdnce && pdnce->isUnknown && !fEmbedded) - return 1; //'Unknown Contact' - if (pdnce && g_CluiData.bFilterEffective && !fEmbedded) - { + if (pdnce && pdnce->isUnknown && !fEmbedded) + return 1; //'Unknown Contact' + if (pdnce && g_CluiData.bFilterEffective && !fEmbedded) { if (szProto == NULL) szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); // check stickies first (priority), only if we really have stickies defined (CLVM_STICKY_CONTACTS is set). - if (g_CluiData.bFilterEffective & CLVM_STICKY_CONTACTS) - { + if (g_CluiData.bFilterEffective & CLVM_STICKY_CONTACTS) { if ((dwLocalMask = db_get_dw(hContact, CLVM_MODULE, g_CluiData.current_viewmode, 0)) != 0) { - if (g_CluiData.bFilterEffective & CLVM_FILTER_STICKYSTATUS) - { + if (g_CluiData.bFilterEffective & CLVM_FILTER_STICKYSTATUS) { WORD wStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); return !((1 << (wStatus - ID_STATUS_OFFLINE)) & HIWORD(dwLocalMask)); } @@ -804,12 +801,10 @@ int __fastcall CLVM_GetContactHiddenStatus(HANDLE hContact, char *szProto, struc WORD wStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); filterResult = (g_CluiData.filterFlags & CLVM_GROUPSTATUS_OP) ? ((filterResult | ((1 << (wStatus - ID_STATUS_OFFLINE)) & g_CluiData.statusMaskFilter ? 1 : 0))) : (filterResult & ((1 << (wStatus - ID_STATUS_OFFLINE)) & g_CluiData.statusMaskFilter ? 1 : 0)); } - if (g_CluiData.bFilterEffective & CLVM_FILTER_LASTMSG) - { + if (g_CluiData.bFilterEffective & CLVM_FILTER_LASTMSG) { DWORD now; PDNCE pdnce = (PDNCE)pcli->pfnGetCacheEntry(hContact); - if (pdnce) - { + if (pdnce) { now = g_CluiData.t_now; now -= g_CluiData.lastMsgFilter; if (g_CluiData.bFilterEffective & CLVM_FILTER_LASTMSG_OLDERTHAN) diff --git a/plugins/Clist_nicer/SRC/clui.cpp b/plugins/Clist_nicer/SRC/clui.cpp index b25888de02..d8ddd2076b 100644 --- a/plugins/Clist_nicer/SRC/clui.cpp +++ b/plugins/Clist_nicer/SRC/clui.cpp @@ -310,12 +310,10 @@ static void InitIcoLib() TCHAR szFilename[MAX_PATH]; GetModuleFileName(g_hInst, szFilename, MAX_PATH); - SKINICONDESC sid = {0}; int i, version = 0; char szBuffer[128]; - int p_count = 0; - PROTOACCOUNT **accs = NULL; + SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); sid.flags = SIDF_PATH_TCHAR; sid.pszSection = LPGEN("CList - Nicer/Default"); @@ -350,6 +348,9 @@ static void InitIcoLib() Skin_AddIcon(&sid); } sid.ptszSection = LPGENT("CList - Nicer/Connecting Icons"); + + PROTOACCOUNT **accs = NULL; + int p_count = 0; ProtoEnumAccounts( &p_count, &accs ); for (i = 0; i < p_count; i++) { TCHAR szDescr[128]; diff --git a/plugins/Console/src/Console.cpp b/plugins/Console/src/Console.cpp index 05c0c35801..d22446be2c 100644 --- a/plugins/Console/src/Console.cpp +++ b/plugins/Console/src/Console.cpp @@ -121,13 +121,13 @@ static int OnTTBLoaded(WPARAM wParam,LPARAM lParam) int state = IsWindowVisible(hwndConsole); - TTBButton ttbb = {0}; + TTBButton ttbb = { 0 }; ttbb.cbSize = sizeof(ttbb); - TCHAR szModuleFileName[MAX_PATH]={0}; + TCHAR szModuleFileName[MAX_PATH]; GetModuleFileName(hInst, szModuleFileName, SIZEOF(szModuleFileName)); - SKINICONDESC sid={0}; + SKINICONDESC sid = { 0 }; sid.cbSize = sizeof(sid); sid.pszSection = "Console"; sid.ptszDefaultFile = szModuleFileName; diff --git a/plugins/CountryFlags/src/icons.cpp b/plugins/CountryFlags/src/icons.cpp index 3b456a4d11..cde97ff74e 100644 --- a/plugins/CountryFlags/src/icons.cpp +++ b/plugins/CountryFlags/src/icons.cpp @@ -226,53 +226,51 @@ static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam) void InitIcons(void) { - HIMAGELIST himl; - SKINICONDESC sid; char szId[20]; - int i,index; - HICON hIcon; WCHAR szName[64]; - LCID locale; - locale=(LCID)CallService(MS_LANGPACK_GETLOCALE,0,0); - + LCID locale = (LCID)CallService(MS_LANGPACK_GETLOCALE,0,0); /* register icons */ - ZeroMemory(&sid,sizeof(sid)); - sid.cbSize=sizeof(sid); - sid.pszName=szId; - sid.cx=GetSystemMetrics(SM_CXSMICON); - sid.cy=GetSystemMetrics(SM_CYSMICON); - sid.flags=SIDF_SORTED|SIDF_TCHAR; - sid.ptszSection=TranslateT("Country Flags"); + SKINICONDESC sid = { 0 }; + sid.cbSize = sizeof(sid); + sid.pszName = szId; + sid.cx = GetSystemMetrics(SM_CXSMICON); + sid.cy = GetSystemMetrics(SM_CYSMICON); + sid.flags = SIDF_SORTED | SIDF_TCHAR; + sid.ptszSection = TranslateT("Country Flags"); + /* all those flag icons do not need any transparency mask (flags are always opaque), * storing them in a large bitmap to reduce file size */ - himl=ImageList_LoadImage(hInst,MAKEINTRESOURCE(IDB_FLAGS),sid.cx,0,CLR_NONE,IMAGE_BITMAP,LR_CREATEDIBSECTION); - if(himl!=NULL) { - phIconHandles=(HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE)); - if(phIconHandles!=NULL) - for(i=0;ihImage == (HANDLE) -1) icon->hImage = NULL; - IcoLib_ReleaseIcon(hIcon); + Skin_ReleaseIcon(hIcon); } } diff --git a/plugins/Gender/main.cpp b/plugins/Gender/main.cpp index 62825459f6..5e5f1f4992 100644 --- a/plugins/Gender/main.cpp +++ b/plugins/Gender/main.cpp @@ -258,13 +258,14 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) if (bContactMenuItems) hHookPrebuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPrebuildContactMenu); bMetaAvail = (ServiceExists(MS_MC_GETMETACONTACT) != 0); + TCHAR szFile[MAX_PATH]; + GetModuleFileName(g_hInst, szFile, MAX_PATH); + //IcoLib support SKINICONDESC sid = {0}; sid.cbSize = sizeof(sid); sid.flags = SIDF_ALL_TCHAR; sid.ptszSection = LPGENT("Gender"); - TCHAR szFile[MAX_PATH]; - GetModuleFileName(g_hInst, szFile, MAX_PATH); sid.ptszDefaultFile = szFile; sid.ptszDescription = LPGENT("Male"); diff --git a/plugins/HistorySweeperLight/options.cpp b/plugins/HistorySweeperLight/options.cpp index f98f5dc67c..2963f8bb2b 100644 --- a/plugins/HistorySweeperLight/options.cpp +++ b/plugins/HistorySweeperLight/options.cpp @@ -62,20 +62,20 @@ static HANDLE hIconLibItem[SIZEOF(iconList)]; void InitIcons(void) { - int i; char szSettingName[100]; SKINICONDESC sid = {0}; TCHAR szFile[MAX_PATH]; - + TCHAR szFile[MAX_PATH]; GetModuleFileName(hInst, szFile, SIZEOF(szFile)); + SKINICONDESC sid = { 0 }; sid.cbSize = sizeof(SKINICONDESC); sid.ptszDefaultFile = szFile; sid.cx = sid.cy = 16; - sid.pszName = szSettingName; sid.pszSection = ModuleName; sid.flags = SIDF_PATH_TCHAR; - for (i = 0; i < SIZEOF(iconList); i++) - { + for (int i=0; i < SIZEOF(iconList); i++) { + char szSettingName[100]; mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", ModuleName, iconList[i].szName); + sid.pszName = szSettingName; sid.pszDescription = (char*)iconList[i].szDescr; sid.iDefaultIndex = -iconList[i].defIconID; diff --git a/plugins/IgnoreState/main.cpp b/plugins/IgnoreState/main.cpp index abc95bda11..c68e6f6d2d 100644 --- a/plugins/IgnoreState/main.cpp +++ b/plugins/IgnoreState/main.cpp @@ -197,7 +197,6 @@ static VOID init_icolib (void) sid.iDefaultIndex = -iconList[i].defIconID; iconList[i].hIconLibItem = Skin_AddIcon(&sid); } -// hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onExtraImageListRebuild); } VOID fill_filter(void) diff --git a/plugins/ListeningTo/listeningto.cpp b/plugins/ListeningTo/listeningto.cpp index 0a6fecb66c..36df33520f 100644 --- a/plugins/ListeningTo/listeningto.cpp +++ b/plugins/ListeningTo/listeningto.cpp @@ -313,8 +313,8 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) // add our modules to the KnownModules list CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME, 0); - hIcon1 = IcoLib_Register("listening_to_icon", _T("ListeningTo"), _T("Listening to (enabled)"), IDI_LISTENINGTO); - hIcon2 = IcoLib_Register("listening_off_icon", _T("ListeningTo"), _T("Listening to (disabled)"), IDI_LISTENINGOFF); + hIcon1 = IcoLib_Register("listening_to_icon", "ListeningTo", "Listening to (enabled)", IDI_LISTENINGTO); + hIcon2 = IcoLib_Register("listening_off_icon", "ListeningTo", "Listening to (disabled)", IDI_LISTENINGOFF); // Extra icon support hExtraIcon = ExtraIcon_Register(MODULE_NAME, "Listening to music", "listening_to_icon"); diff --git a/plugins/MenuItemEx/main.cpp b/plugins/MenuItemEx/main.cpp index 3b24d1e0f9..ed053b2223 100644 --- a/plugins/MenuItemEx/main.cpp +++ b/plugins/MenuItemEx/main.cpp @@ -233,17 +233,16 @@ void RenameDbProto(HANDLE hContact, HANDLE hContactNew, char* oldName, char* new static void IconsInit() { int i; - SKINICONDESC sid = {0}; TCHAR tszFile[MAX_PATH]; GetModuleFileName(hinstance, tszFile, MAX_PATH); + SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); sid.flags = SIDF_ALL_TCHAR; sid.ptszDefaultFile = tszFile; sid.cx = sid.cy = 16; sid.ptszSection = LPGENT(MODULENAME); - for ( i = 0; i < SIZEOF(iconList); i++ ) { sid.pszName = iconList[i].szName; sid.ptszDescription = iconList[i].szDescr; diff --git a/plugins/MetaContacts/icons.cpp b/plugins/MetaContacts/icons.cpp index 829636be1f..e6cbc9a3a3 100644 --- a/plugins/MetaContacts/icons.cpp +++ b/plugins/MetaContacts/icons.cpp @@ -1,8 +1,5 @@ #include "metacontacts.h" -HANDLE hIcoLibIconsChanged = NULL; - - typedef struct { char* szDescr; char* szName; @@ -20,26 +17,18 @@ static IconStruct iconList[] = { }; -HICON LoadIconEx(IconIndex i) { - HICON hIcon; - - if (hIcoLibIconsChanged) - hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)iconList[(int)i].szName); - else - hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(iconList[(int)i].defIconID), IMAGE_ICON, 0, 0, 0); - - return hIcon; +HICON LoadIconEx(IconIndex i) +{ + return Skin_GetIcon(iconList[i].szName); } - -void ReleaseIconEx(HICON hIcon) { - if (hIcoLibIconsChanged) - CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); - else - DestroyIcon(hIcon); +void ReleaseIconEx(HICON hIcon) +{ + Skin_ReleaseIcon(hIcon); } -int ReloadIcons(WPARAM wParam, LPARAM lParam) { +int ReloadIcons(WPARAM wParam, LPARAM lParam) +{ // fix menu icons CLISTMENUITEM menu = {0}; @@ -73,29 +62,24 @@ int ReloadIcons(WPARAM wParam, LPARAM lParam) { return 0; } -void InitIcons(void) { +void InitIcons(void) +{ + TCHAR path[MAX_PATH]; + GetModuleFileName(hInstance, path, SIZEOF(path)); + SKINICONDESC sid = {0}; - char path[MAX_PATH]; - int i; - sid.cbSize = sizeof(SKINICONDESC); sid.pszSection = META_PROTO; sid.pszDefaultFile = path; - GetModuleFileName(hInstance, path, sizeof(path)); - for (i = 0; i < sizeof(iconList) / sizeof(IconStruct); ++i) - { - sid.pszDescription = Translate(iconList[i].szDescr); + for (int i=0; i < SIZEOF(iconList); ++i) { + sid.pszDescription = iconList[i].szDescr; sid.pszName = iconList[i].szName; sid.iDefaultIndex = -iconList[i].defIconID; Skin_AddIcon(&sid); } - hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons); + HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons); ReloadIcons(0, 0); } - -void DeinitIcons(void) { - if (hIcoLibIconsChanged) UnhookEvent(hIcoLibIconsChanged); -} diff --git a/plugins/MetaContacts/meta_services.cpp b/plugins/MetaContacts/meta_services.cpp index 1fe1d9af4d..94aea51fc9 100644 --- a/plugins/MetaContacts/meta_services.cpp +++ b/plugins/MetaContacts/meta_services.cpp @@ -2072,6 +2072,4 @@ void Meta_CloseHandles() // lets leave them, hey? (why?) for (i=0;i #include #include +#include #define META_PROTO "MetaContacts" #define META_FILTER "MetaContactsFilter" @@ -224,7 +225,6 @@ INT_PTR MyDBGetContactSetting(HANDLE hContact, const char *szModule, const char // IcoLib support void InitIcons(void); -void DeinitIcons(void); typedef enum {I_MENUOFF, I_MENU, I_CONVERT, I_ADD, I_EDIT, I_SETDEFAULT, I_REMOVE} IconIndex; HICON LoadIconEx(IconIndex i); diff --git a/plugins/SRMM/globals.cpp b/plugins/SRMM/globals.cpp index 802bc9fccc..e6d0175f1c 100644 --- a/plugins/SRMM/globals.cpp +++ b/plugins/SRMM/globals.cpp @@ -28,8 +28,8 @@ static int AvatarChanged(WPARAM wParam, LPARAM lParam); typedef struct IconDefStruct { - const char *szName; - const char *szDescr; + char *szName; + char *szDescr; int defIconID; } IconList; @@ -45,13 +45,12 @@ HANDLE hIconLibItem[SIZEOF(iconList)]; static void InitIcons(void) { - TCHAR szFile[MAX_PATH]; char szSettingName[100]; - SKINICONDESC sid = {0}; - unsigned i; + TCHAR szFile[MAX_PATH]; GetModuleFileName(g_hInst, szFile, SIZEOF(szFile)); + SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); sid.ptszDefaultFile = szFile; sid.pszName = szSettingName; @@ -59,10 +58,9 @@ static void InitIcons(void) sid.flags = SIDF_PATH_TCHAR; sid.cx = 10; sid.cy = 10; - for (i = 0; i < SIZEOF(iconList); i++) - { + for (int i=0; i < SIZEOF(iconList); i++) { mir_snprintf(szSettingName, sizeof(szSettingName), "SRMM_%s", iconList[i].szName); - sid.pszDescription = (char*)iconList[i].szDescr; + sid.pszDescription = iconList[i].szDescr; sid.iDefaultIndex = -iconList[i].defIconID; hIconLibItem[i] = Skin_AddIcon(&sid); } diff --git a/plugins/Scriver/globals.cpp b/plugins/Scriver/globals.cpp index a9cfb0bf47..9a81ebcdbb 100644 --- a/plugins/Scriver/globals.cpp +++ b/plugins/Scriver/globals.cpp @@ -45,64 +45,64 @@ static const char *chatButtonIcons[] = {"scriver_CLOSEX", typedef struct IconDefStruct { - const TCHAR* section; - const char *name; - int defaultIndex; - const TCHAR *description; + char* section; + char *name; + int defaultIndex; + char *description; int size; } IconDef; static const IconDef iconList[] = { - {LPGENT("Single Messaging"), "scriver_ADD", IDI_ADDCONTACT, LPGENT("Add contact")}, - {LPGENT("Single Messaging"), "scriver_USERDETAILS", IDI_USERDETAILS, LPGENT("User's details")}, - {LPGENT("Single Messaging"), "scriver_HISTORY", IDI_HISTORY, LPGENT("User's history")}, - {LPGENT("Single Messaging"), "scriver_SEND", IDI_SEND, LPGENT("Send message")}, - {LPGENT("Single Messaging"), "scriver_SMILEY", IDI_SMILEY, LPGENT("Smiley button")}, - {LPGENT("Single Messaging"), "scriver_TYPING", IDI_TYPING, LPGENT("User is typing")}, - {LPGENT("Single Messaging"), "scriver_TYPINGOFF", IDI_TYPINGOFF, LPGENT("Typing notification off")}, - {LPGENT("Single Messaging"), "scriver_UNICODEON", IDI_UNICODEON, LPGENT("Unicode is on")}, - {LPGENT("Single Messaging"), "scriver_UNICODEOFF", IDI_UNICODEOFF, LPGENT("Unicode is off")}, - {LPGENT("Single Messaging"), "scriver_DELIVERING", IDI_TIMESTAMP, LPGENT("Sending")}, - {LPGENT("Single Messaging"), "scriver_QUOTE", IDI_QUOTE, LPGENT("Quote button")}, - {LPGENT("Single Messaging"), "scriver_CLOSEX", IDI_CLOSEX, LPGENT("Close button")}, - {LPGENT("Single Messaging"), "scriver_OVERLAY", IDI_OVERLAY, LPGENT("Icon overlay")}, - {LPGENT("Single Messaging"), "scriver_INCOMING", IDI_INCOMING, LPGENT("Incoming message (10x10)"),10}, - {LPGENT("Single Messaging"), "scriver_OUTGOING", IDI_OUTGOING, LPGENT("Outgoing message (10x10)"),10}, - {LPGENT("Single Messaging"), "scriver_NOTICE", IDI_NOTICE, LPGENT("Notice (10x10)"),10}, - {LPGENT("Group Chats"), "chat_window", IDI_CHANMGR, LPGENT("Window Icon")}, - {LPGENT("Group Chats"), "chat_fgcol", IDI_COLOR, LPGENT("Text colour")}, - {LPGENT("Group Chats"), "chat_bkgcol", IDI_BKGCOLOR, LPGENT("Background colour")}, - {LPGENT("Group Chats"), "chat_bold", IDI_BBOLD, LPGENT("Bold")}, - {LPGENT("Group Chats"), "chat_italics", IDI_BITALICS, LPGENT("Italics")}, - {LPGENT("Group Chats"), "chat_underline", IDI_BUNDERLINE, LPGENT("Underlined")}, - {LPGENT("Group Chats"), "chat_smiley", IDI_SMILEY, LPGENT("Smiley button")}, - {LPGENT("Group Chats"), "chat_history", IDI_HISTORY, LPGENT("Room history")}, - {LPGENT("Group Chats"), "chat_settings", IDI_TOPICBUT, LPGENT("Room settings")}, - {LPGENT("Group Chats"), "chat_filter", IDI_FILTER, LPGENT("Event filter disabled")}, - {LPGENT("Group Chats"), "chat_filter2", IDI_FILTER2, LPGENT("Event filter enabled")}, - {LPGENT("Group Chats"), "chat_nicklist", IDI_NICKLIST, LPGENT("Hide userlist")}, - {LPGENT("Group Chats"), "chat_nicklist2", IDI_NICKLIST2, LPGENT("Show userlist")}, - {LPGENT("Group Chats"), "chat_overlay", IDI_OVERLAY, LPGENT("Icon overlay")}, - {LPGENT("Group Chats"), "chat_status0", IDI_STATUS0, LPGENT("Status 1 (10x10)"),10}, - {LPGENT("Group Chats"), "chat_status1", IDI_STATUS1, LPGENT("Status 2 (10x10"),10}, - {LPGENT("Group Chats"), "chat_status2", IDI_STATUS2, LPGENT("Status 3 (10x10)"),10}, - {LPGENT("Group Chats"), "chat_status3", IDI_STATUS3, LPGENT("Status 4 (10x10)"),10}, - {LPGENT("Group Chats"), "chat_status4", IDI_STATUS4, LPGENT("Status 5 (10x10)"),10}, - {LPGENT("Group Chats"), "chat_status5", IDI_STATUS5, LPGENT("Status 6 (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_message_in", IDI_INCOMING, LPGENT("Message in (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_message_out", IDI_OUTGOING, LPGENT("Message out (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_action", IDI_ACTION, LPGENT("Action (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_addstatus", IDI_ADDSTATUS, LPGENT("Add Status (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_removestatus", IDI_REMSTATUS, LPGENT("Remove status (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_join", IDI_JOIN, LPGENT("Join (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_part", IDI_PART, LPGENT("Leave (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_quit", IDI_QUIT, LPGENT("Quit (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_kick", IDI_KICK, LPGENT("Kick (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_nick", IDI_NICK, LPGENT("Nickchange (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_notice", IDI_CHAT_NOTICE, LPGENT("Notice (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_topic", IDI_TOPIC, LPGENT("Topic (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_highlight", IDI_NOTICE, LPGENT("Highlight (10x10)"),10}, - {LPGENT("Group Chats Log"), "chat_log_info", IDI_INFO, LPGENT("Information (10x10)"),10} + {LPGEN("Single Messaging"), "scriver_ADD", IDI_ADDCONTACT, LPGEN("Add contact")}, + {LPGEN("Single Messaging"), "scriver_USERDETAILS", IDI_USERDETAILS, LPGEN("User's details")}, + {LPGEN("Single Messaging"), "scriver_HISTORY", IDI_HISTORY, LPGEN("User's history")}, + {LPGEN("Single Messaging"), "scriver_SEND", IDI_SEND, LPGEN("Send message")}, + {LPGEN("Single Messaging"), "scriver_SMILEY", IDI_SMILEY, LPGEN("Smiley button")}, + {LPGEN("Single Messaging"), "scriver_TYPING", IDI_TYPING, LPGEN("User is typing")}, + {LPGEN("Single Messaging"), "scriver_TYPINGOFF", IDI_TYPINGOFF, LPGEN("Typing notification off")}, + {LPGEN("Single Messaging"), "scriver_UNICODEON", IDI_UNICODEON, LPGEN("Unicode is on")}, + {LPGEN("Single Messaging"), "scriver_UNICODEOFF", IDI_UNICODEOFF, LPGEN("Unicode is off")}, + {LPGEN("Single Messaging"), "scriver_DELIVERING", IDI_TIMESTAMP, LPGEN("Sending")}, + {LPGEN("Single Messaging"), "scriver_QUOTE", IDI_QUOTE, LPGEN("Quote button")}, + {LPGEN("Single Messaging"), "scriver_CLOSEX", IDI_CLOSEX, LPGEN("Close button")}, + {LPGEN("Single Messaging"), "scriver_OVERLAY", IDI_OVERLAY, LPGEN("Icon overlay")}, + {LPGEN("Single Messaging"), "scriver_INCOMING", IDI_INCOMING, LPGEN("Incoming message (10x10)"),10}, + {LPGEN("Single Messaging"), "scriver_OUTGOING", IDI_OUTGOING, LPGEN("Outgoing message (10x10)"),10}, + {LPGEN("Single Messaging"), "scriver_NOTICE", IDI_NOTICE, LPGEN("Notice (10x10)"),10}, + {LPGEN("Group Chats"), "chat_window", IDI_CHANMGR, LPGEN("Window Icon")}, + {LPGEN("Group Chats"), "chat_fgcol", IDI_COLOR, LPGEN("Text colour")}, + {LPGEN("Group Chats"), "chat_bkgcol", IDI_BKGCOLOR, LPGEN("Background colour")}, + {LPGEN("Group Chats"), "chat_bold", IDI_BBOLD, LPGEN("Bold")}, + {LPGEN("Group Chats"), "chat_italics", IDI_BITALICS, LPGEN("Italics")}, + {LPGEN("Group Chats"), "chat_underline", IDI_BUNDERLINE, LPGEN("Underlined")}, + {LPGEN("Group Chats"), "chat_smiley", IDI_SMILEY, LPGEN("Smiley button")}, + {LPGEN("Group Chats"), "chat_history", IDI_HISTORY, LPGEN("Room history")}, + {LPGEN("Group Chats"), "chat_settings", IDI_TOPICBUT, LPGEN("Room settings")}, + {LPGEN("Group Chats"), "chat_filter", IDI_FILTER, LPGEN("Event filter disabled")}, + {LPGEN("Group Chats"), "chat_filter2", IDI_FILTER2, LPGEN("Event filter enabled")}, + {LPGEN("Group Chats"), "chat_nicklist", IDI_NICKLIST, LPGEN("Hide userlist")}, + {LPGEN("Group Chats"), "chat_nicklist2", IDI_NICKLIST2, LPGEN("Show userlist")}, + {LPGEN("Group Chats"), "chat_overlay", IDI_OVERLAY, LPGEN("Icon overlay")}, + {LPGEN("Group Chats"), "chat_status0", IDI_STATUS0, LPGEN("Status 1 (10x10)"),10}, + {LPGEN("Group Chats"), "chat_status1", IDI_STATUS1, LPGEN("Status 2 (10x10"),10}, + {LPGEN("Group Chats"), "chat_status2", IDI_STATUS2, LPGEN("Status 3 (10x10)"),10}, + {LPGEN("Group Chats"), "chat_status3", IDI_STATUS3, LPGEN("Status 4 (10x10)"),10}, + {LPGEN("Group Chats"), "chat_status4", IDI_STATUS4, LPGEN("Status 5 (10x10)"),10}, + {LPGEN("Group Chats"), "chat_status5", IDI_STATUS5, LPGEN("Status 6 (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_message_in", IDI_INCOMING, LPGEN("Message in (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_message_out", IDI_OUTGOING, LPGEN("Message out (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_action", IDI_ACTION, LPGEN("Action (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_addstatus", IDI_ADDSTATUS, LPGEN("Add Status (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_removestatus", IDI_REMSTATUS, LPGEN("Remove status (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_join", IDI_JOIN, LPGEN("Join (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_part", IDI_PART, LPGEN("Leave (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_quit", IDI_QUIT, LPGEN("Quit (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_kick", IDI_KICK, LPGEN("Kick (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_nick", IDI_NICK, LPGEN("Nickchange (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_notice", IDI_CHAT_NOTICE, LPGEN("Notice (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_topic", IDI_TOPIC, LPGEN("Topic (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_highlight", IDI_NOTICE, LPGEN("Highlight (10x10)"),10}, + {LPGEN("Group Chats Log"), "chat_log_info", IDI_INFO, LPGEN("Information (10x10)"),10} }; HICON hIconList[SIZEOF(iconList)]; @@ -154,22 +154,23 @@ int ImageList_AddIcon_ProtoEx(HIMAGELIST hIml, const char* szProto, int status) void RegisterIcons(void) { - SKINICONDESC sid = { 0 }; - TCHAR path[MAX_PATH]; - TCHAR tTemp[500]; - int i; hEventSkin2IconsChanged = HookEvent_Ex(ME_SKIN2_ICONSCHANGED, IconsChanged); + + TCHAR path[MAX_PATH]; + char szSection[200]; GetModuleFileName(g_hInst, path, MAX_PATH); + + SKINICONDESC sid = { 0 }; sid.cbSize = sizeof(SKINICONDESC); - sid.flags = SIDF_ALL_TCHAR; + sid.flags = SIDF_PATH_TCHAR; sid.ptszDefaultFile = path; - sid.ptszSection = tTemp; - for (i = 0; i < SIZEOF(iconList); i++) { - mir_sntprintf(tTemp, SIZEOF(tTemp), _T("%s/%s"), LPGENT("Messaging"), iconList[i].section); + sid.pszSection = szSection; + for (int i = 0; i < SIZEOF(iconList); i++) { + mir_snprintf(szSection, SIZEOF(szSection), "%s/%s", LPGEN("Messaging"), iconList[i].section); sid.pszName = (char*)iconList[i].name; sid.cx = sid.cy = iconList[i].size; sid.iDefaultIndex = -iconList[i].defaultIndex; - sid.ptszDescription = (TCHAR*)iconList[i].description; + sid.pszDescription = iconList[i].description; Skin_AddIcon(&sid); } } diff --git a/plugins/SpellChecker/ardialog.cpp b/plugins/SpellChecker/ardialog.cpp index dc8a24cd43..6a08585ea1 100644 --- a/plugins/SpellChecker/ardialog.cpp +++ b/plugins/SpellChecker/ardialog.cpp @@ -193,7 +193,7 @@ static INT_PTR CALLBACK AddReplacementDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa HICON hIcon = IcoLib_LoadIcon("spellchecker_enabled"); SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon); - IcoLib_ReleaseIcon(hIcon); + Skin_ReleaseIcon(hIcon); SendDlgItemMessage(hwndDlg, IDC_OLD, EM_LIMITTEXT, 256, 0); SendDlgItemMessage(hwndDlg, IDC_NEW, EM_LIMITTEXT, 256, 0); diff --git a/plugins/SpellChecker/options.cpp b/plugins/SpellChecker/options.cpp index 4c8b299266..28886b1126 100644 --- a/plugins/SpellChecker/options.cpp +++ b/plugins/SpellChecker/options.cpp @@ -175,7 +175,7 @@ static void DrawItem(HWND hwndDlg, LPDRAWITEMSTRUCT lpdis, Dictionary *dict) rc.left += ICON_SIZE + 4; - IcoLib_ReleaseIcon(hFlag); + Skin_ReleaseIcon(hFlag); } // Draw text diff --git a/plugins/SpellChecker/spellchecker.cpp b/plugins/SpellChecker/spellchecker.cpp index f11ad5b2fb..a126070604 100644 --- a/plugins/SpellChecker/spellchecker.cpp +++ b/plugins/SpellChecker/spellchecker.cpp @@ -250,7 +250,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) if (hFlag != NULL) { // Already registered - IcoLib_ReleaseIcon(hFlag); + Skin_ReleaseIcon(hFlag); continue; } @@ -2135,7 +2135,7 @@ LRESULT CALLBACK MenuWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) rc.top = (lpdis->rcItem.bottom + lpdis->rcItem.top - ICON_SIZE) / 2; DrawIconEx(lpdis->hDC, rc.left, rc.top, hFlag, 16, 16, 0, NULL, DI_NORMAL); - IcoLib_ReleaseIcon(hFlag); + Skin_ReleaseIcon(hFlag); rc.left += ICON_SIZE + 4; diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index 4593a3ea43..1a5a9780d0 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -1046,26 +1046,27 @@ static int GetIconPackVersion(HMODULE hDLL) static int TSAPI SetupIconLibConfig() { - SKINICONDESC sid = { 0 }; - char szFilename[MAX_PATH]; int i = 0, j = 2, version = 0, n = 0; - strncpy(szFilename, "icons\\tabsrmm_icons.dll", MAX_PATH); - g_hIconDLL = LoadLibraryA(szFilename); + TCHAR szFilename[MAX_PATH]; + _tcsncpy(szFilename, _T("icons\\tabsrmm_icons.dll"), MAX_PATH); + g_hIconDLL = LoadLibrary(szFilename); if (g_hIconDLL == 0) { CWarning::show(CWarning::WARN_ICONPACKMISSING, CWarning::CWF_NOALLOWHIDE|MB_ICONERROR|MB_OK); return 0; } - GetModuleFileNameA(g_hIconDLL, szFilename, MAX_PATH); + GetModuleFileName(g_hIconDLL, szFilename, MAX_PATH); if (PluginConfig.m_chat_enabled) Chat_AddIcons(); version = GetIconPackVersion(g_hIconDLL); FreeLibrary(g_hIconDLL); g_hIconDLL = 0; + SKINICONDESC sid = { 0 }; sid.cbSize = sizeof(SKINICONDESC); - sid.pszDefaultFile = szFilename; + sid.ptszDefaultFile = szFilename; + sid.flags = SIDF_PATH_TCHAR; while (ICONBLOCKS[n].szSection) { i = 0; @@ -1075,7 +1076,7 @@ static int TSAPI SetupIconLibConfig() sid.pszDescription = ICONBLOCKS[n].idesc[i].szDesc; sid.iDefaultIndex = ICONBLOCKS[n].idesc[i].uId == -IDI_HISTORY ? 0 : ICONBLOCKS[n].idesc[i].uId; // workaround problem /w icoLib and a resource id of 1 (actually, a Windows problem) i++; - if (n>0&&n<4) + if (n > 0 && n < 4) PluginConfig.g_buttonBarIconHandles[j++] = Skin_AddIcon(&sid); else Skin_AddIcon(&sid); @@ -1084,13 +1085,12 @@ static int TSAPI SetupIconLibConfig() } sid.pszSection = "TabSRMM/Default"; - sid.pszName = "tabSRMM_clock_symbol"; sid.pszDescription = "Clock symbol (for the info panel clock)"; sid.iDefaultIndex = -IDI_CLOCK; Skin_AddIcon(&sid); - strncpy(szFilename, "plugins\\tabsrmm.dll", MAX_PATH); + _tcsncpy(szFilename, _T("plugins\\tabsrmm.dll"), MAX_PATH); sid.pszName = "tabSRMM_overlay_disabled"; sid.pszDescription = "Feature disabled (used as overlay)"; @@ -1101,8 +1101,6 @@ static int TSAPI SetupIconLibConfig() sid.pszDescription = "Feature enabled (used as overlay)"; sid.iDefaultIndex = -IDI_FEATURE_ENABLED; Skin_AddIcon(&sid); - - return 1; } diff --git a/plugins/Utils/mir_icons.cpp b/plugins/Utils/mir_icons.cpp index bab0674d35..00adda0614 100644 --- a/plugins/Utils/mir_icons.cpp +++ b/plugins/Utils/mir_icons.cpp @@ -29,15 +29,11 @@ extern HINSTANCE hInst; HICON IcoLib_LoadIcon(const char *iconName, BOOL copy) { - if (!ServiceExists(MS_SKIN2_GETICON)) - return NULL; - if (iconName == NULL || iconName[0] == 0) return NULL; HICON hIcon = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM) iconName); - if (copy && hIcon != NULL) - { + if (copy && hIcon != NULL) { hIcon = CopyIcon(hIcon); CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0); } @@ -46,40 +42,30 @@ HICON IcoLib_LoadIcon(const char *iconName, BOOL copy) void IcoLib_ReleaseIcon(const char *iconName) { - if (ServiceExists(MS_SKIN2_RELEASEICON)) - CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM) iconName); + CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM) iconName); } - void IcoLib_ReleaseIcon(HICON hIcon) { - if (ServiceExists(MS_SKIN2_RELEASEICON)) - CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0); + CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0); } - -HANDLE IcoLib_Register(char *name, TCHAR *section, TCHAR *description, int id) +HANDLE IcoLib_Register(char *name, char *section, char *description, int id) { - HICON hIcon = (HICON) CallService(MS_SKIN2_GETICON, 0, (LPARAM) name); - if (hIcon != NULL) { - CallService(MS_SKIN2_RELEASEICON, (WPARAM) hIcon, 0); - return NULL; - } + HANDLE hIcon = Skin_GetIconHandle(name); + if (hIcon != NULL) + return hIcon; + + TCHAR tszFile[MAX_PATH]; + GetModuleFileName(hInst, tszFile, MAX_PATH); SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); - sid.flags = SIDF_TCHAR; + sid.flags = SIDF_PATH_TCHAR; sid.pszName = name; - sid.ptszSection = section; - sid.ptszDescription = description; - - int cx = GetSystemMetrics(SM_CXSMICON); - sid.hDefaultIcon = (HICON) LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, cx, cx, LR_DEFAULTCOLOR | LR_SHARED); - HANDLE hRes = Skin_AddIcon(&sid); - - if (sid.hDefaultIcon) - DestroyIcon(sid.hDefaultIcon); - - return hRes; + sid.pszSection = section; + sid.pszDescription = description; + sid.ptszDefaultFile = tszFile; + sid.iDefaultIndex = -id; + return Skin_AddIcon(&sid); } - diff --git a/plugins/Utils/mir_icons.h b/plugins/Utils/mir_icons.h index e1e1a918a3..7e88d5f61c 100644 --- a/plugins/Utils/mir_icons.h +++ b/plugins/Utils/mir_icons.h @@ -23,10 +23,8 @@ Boston, MA 02111-1307, USA. #define _CRT_SECURE_NO_WARNINGS -HANDLE IcoLib_Register(char *name, TCHAR *section, TCHAR *description, int id); +HANDLE IcoLib_Register(char *name, char *section, char *description, int id); HICON IcoLib_LoadIcon(const char *iconName, BOOL copy = FALSE); -void IcoLib_ReleaseIcon(const char *iconName); -void IcoLib_ReleaseIcon(HICON hIcon); #endif // __MIR_ICONS_H__ diff --git a/plugins/Utils/mir_options.cpp b/plugins/Utils/mir_options.cpp index 493f01f527..ad3322e38a 100644 --- a/plugins/Utils/mir_options.cpp +++ b/plugins/Utils/mir_options.cpp @@ -581,7 +581,7 @@ INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, cha { NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; - if(IsWindowVisible(GetDlgItem(hwndDlg, ctrl->nID)) && ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)) + if (IsWindowVisible(GetDlgItem(hwndDlg, ctrl->nID)) && ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; diff --git a/protocols/AimOscar/theme.cpp b/protocols/AimOscar/theme.cpp index e0bf133f61..9217c68d1c 100644 --- a/protocols/AimOscar/theme.cpp +++ b/protocols/AimOscar/theme.cpp @@ -83,8 +83,7 @@ void InitIcons(void) sid.pszSection = szSectionName; sid.flags = SIDF_PATH_TCHAR; - for (int i = 0; i < SIZEOF(iconList); i++) - { + for (int i = 0; i < SIZEOF(iconList); i++) { mir_snprintf(szSettingName, sizeof(szSettingName), "AIM_%s", iconList[i].szName); if (iconList[i].szSection) diff --git a/protocols/Gadu-Gadu/icolib.cpp b/protocols/Gadu-Gadu/icolib.cpp index 58d5c2fe2a..f99540ac76 100644 --- a/protocols/Gadu-Gadu/icolib.cpp +++ b/protocols/Gadu-Gadu/icolib.cpp @@ -22,48 +22,48 @@ struct tagiconList { - const char* szDescr; - const char* szName; - int defIconID; + char* szDescr; + char* szName; + int defIconID; } static const iconList[] = { - { LPGEN("Protocol icon"), "main", IDI_GG }, - { LPGEN("Import list from server"), "importserver", IDI_IMPORT_SERVER }, - { LPGEN("Import list from text file"), "importtext", IDI_IMPORT_TEXT }, - { LPGEN("Remove list from server"), "removeserver", IDI_REMOVE_SERVER }, - { LPGEN("Export list to server"), "exportserver", IDI_EXPORT_SERVER }, - { LPGEN("Export list to text file"), "exporttext", IDI_EXPORT_TEXT }, - { LPGEN("Account settings"), "settings", IDI_SETTINGS }, - { LPGEN("Contact list"), "list", IDI_LIST }, - { LPGEN("Block user"), "block", IDI_BLOCK }, - { LPGEN("Previous image"), "previous", IDI_PREV }, - { LPGEN("Next image"), "next", IDI_NEXT }, - { LPGEN("Send image"), "image", IDI_IMAGE }, - { LPGEN("Save image"), "save", IDI_SAVE }, - { LPGEN("Delete image"), "delete", IDI_DELETE }, - { LPGEN("Open new conference"), "conference", IDI_CONFERENCE }, - { LPGEN("Clear ignored conferences"), "clearignored", IDI_CLEAR_CONFERENCE }, - { LPGEN("Concurrent sessions"), "sessions", IDI_SESSIONS } + { LPGEN("Protocol icon"), "main", IDI_GG }, + { LPGEN("Import list from server"), "importserver", IDI_IMPORT_SERVER }, + { LPGEN("Import list from text file"), "importtext", IDI_IMPORT_TEXT }, + { LPGEN("Remove list from server"), "removeserver", IDI_REMOVE_SERVER }, + { LPGEN("Export list to server"), "exportserver", IDI_EXPORT_SERVER }, + { LPGEN("Export list to text file"), "exporttext", IDI_EXPORT_TEXT }, + { LPGEN("Account settings"), "settings", IDI_SETTINGS }, + { LPGEN("Contact list"), "list", IDI_LIST }, + { LPGEN("Block user"), "block", IDI_BLOCK }, + { LPGEN("Previous image"), "previous", IDI_PREV }, + { LPGEN("Next image"), "next", IDI_NEXT }, + { LPGEN("Send image"), "image", IDI_IMAGE }, + { LPGEN("Save image"), "save", IDI_SAVE }, + { LPGEN("Delete image"), "delete", IDI_DELETE }, + { LPGEN("Open new conference"), "conference", IDI_CONFERENCE }, + { LPGEN("Clear ignored conferences"), "clearignored", IDI_CLEAR_CONFERENCE }, + { LPGEN("Concurrent sessions"), "sessions", IDI_SESSIONS } }; HANDLE hIconLibItem[SIZEOF(iconList)]; void gg_icolib_init() { - SKINICONDESC sid = {0}; - char szFile[MAX_PATH]; - char szSectionName[100]; - int i; + TCHAR szFile[MAX_PATH]; + GetModuleFileName(hInstance, szFile, MAX_PATH); + char szSectionName[100]; mir_snprintf(szSectionName, sizeof( szSectionName ), "%s/%s", LPGEN("Protocols"), LPGEN(GGDEF_PROTO)); - GetModuleFileNameA(hInstance, szFile, MAX_PATH); + SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); - sid.pszDefaultFile = szFile; + sid.ptszDefaultFile = szFile; sid.pszSection = szSectionName; + sid.flags = SIDF_PATH_TCHAR; - for(i = 0; i < SIZEOF(iconList); i++) { + for (int i = 0; i < SIZEOF(iconList); i++) { char szSettingName[100]; mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", GGDEF_PROTO, iconList[i].szName); sid.pszName = szSettingName; diff --git a/protocols/IRCG/options.cpp b/protocols/IRCG/options.cpp index e3f8bd1746..ae727d5443 100644 --- a/protocols/IRCG/options.cpp +++ b/protocols/IRCG/options.cpp @@ -193,41 +193,41 @@ static void removeSpaces( TCHAR* p ) struct { - TCHAR* szDescr; + char* szDescr; char* szName; int iSize; int defIconID; } static iconList[] = { - { LPGENT("Main"), "main", 0, IDI_MAIN }, - { LPGENT("Add"), "add", 0, IDI_ADD }, - { LPGENT("Apply"), "apply", 0, IDI_APPLY }, - { LPGENT("Rename"), "rename", 0, IDI_RENAME }, - { LPGENT("Edit"), "edit", 0, IDI_EDIT }, - { LPGENT("Cancel"), "delete", 0, IDI_DELETE }, - { LPGENT("Ignore"), "block", 0, IDI_BLOCK }, - { LPGENT("Channel list"), "list", 0, IDI_LIST }, - { LPGENT("Channel manager"), "manager", 0, IDI_MANAGER }, - { LPGENT("Quick connect"), "quick", 0, IDI_QUICK }, - { LPGENT("Server window"), "server", 0, IDI_SERVER }, - { LPGENT("Show channel"), "show", 0, IDI_SHOW }, - { LPGENT("Question"), "question", 0, IDI_IRCQUESTION}, - { LPGENT("WhoIs"), "whois", 0, IDI_WHOIS }, - { LPGENT("Incoming DCC Chat"), "dcc", 0, IDI_DCC }, - { LPGENT("Logo (48x48)"), "logo", 48, IDI_LOGO } + { LPGEN("Main"), "main", 0, IDI_MAIN }, + { LPGEN("Add"), "add", 0, IDI_ADD }, + { LPGEN("Apply"), "apply", 0, IDI_APPLY }, + { LPGEN("Rename"), "rename", 0, IDI_RENAME }, + { LPGEN("Edit"), "edit", 0, IDI_EDIT }, + { LPGEN("Cancel"), "delete", 0, IDI_DELETE }, + { LPGEN("Ignore"), "block", 0, IDI_BLOCK }, + { LPGEN("Channel list"), "list", 0, IDI_LIST }, + { LPGEN("Channel manager"), "manager", 0, IDI_MANAGER }, + { LPGEN("Quick connect"), "quick", 0, IDI_QUICK }, + { LPGEN("Server window"), "server", 0, IDI_SERVER }, + { LPGEN("Show channel"), "show", 0, IDI_SHOW }, + { LPGEN("Question"), "question", 0, IDI_IRCQUESTION}, + { LPGEN("WhoIs"), "whois", 0, IDI_WHOIS }, + { LPGEN("Incoming DCC Chat"), "dcc", 0, IDI_DCC }, + { LPGEN("Logo (48x48)"), "logo", 48, IDI_LOGO } }; void AddIcons(void) { - char szFile[MAX_PATH]; - GetModuleFileNameA(hInst, szFile, MAX_PATH); + TCHAR szFile[MAX_PATH]; + GetModuleFileName(hInst, szFile, MAX_PATH); SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); sid.ptszSection = _T("Protocols/IRC"); - sid.pszDefaultFile = szFile; - sid.flags = SIDF_TCHAR; + sid.ptszDefaultFile = szFile; + sid.flags = SIDF_PATH_TCHAR; hIconLibItems = new HANDLE[ SIZEOF(iconList) ]; // add them one by one @@ -235,7 +235,7 @@ void AddIcons(void) char szTemp[255]; mir_snprintf(szTemp, sizeof(szTemp), "IRC_%s", iconList[i].szName ); sid.pszName = szTemp; - sid.ptszDescription = iconList[i].szDescr; + sid.pszDescription = iconList[i].szDescr; sid.iDefaultIndex = -iconList[i].defIconID; sid.cx = sid.cy = iconList[i].iSize; hIconLibItems[i] = Skin_AddIcon(&sid ); diff --git a/protocols/IcqOscarJ/iconlib.cpp b/protocols/IcqOscarJ/iconlib.cpp index 3c6408c60d..7c93bae17a 100644 --- a/protocols/IcqOscarJ/iconlib.cpp +++ b/protocols/IcqOscarJ/iconlib.cpp @@ -30,7 +30,6 @@ #include "icqoscar.h" #include "m_icolib.h" - IcqIconHandle IconLibDefine(const char *desc, const char *section, const char *module, const char *ident, const TCHAR *def_file, int def_idx) { SKINICONDESC sid = {0}; diff --git a/protocols/JabberG/jabber_icolib.cpp b/protocols/JabberG/jabber_icolib.cpp index 029a4be6c9..04609604f4 100644 --- a/protocols/JabberG/jabber_icolib.cpp +++ b/protocols/JabberG/jabber_icolib.cpp @@ -283,9 +283,7 @@ void CJabberProto::IconsInit( void ) mir_sntprintf( tmp, SIZEOF(tmp), _T(TCHAR_STR_PARAM), iconList[i].szDescr ); mir_sntprintf( szDescription, SIZEOF(szDescription), tmp, m_tszUserName ); } - else { - mir_sntprintf( szDescription, SIZEOF(szDescription), _T(TCHAR_STR_PARAM), iconList[i].szDescr ); - } + else mir_sntprintf( szDescription, SIZEOF(szDescription), _T(TCHAR_STR_PARAM), iconList[i].szDescr ); mir_snprintf( szSettingName, SIZEOF(szSettingName), "%s_%s", m_szModuleName, iconList[i].szName ); @@ -412,10 +410,10 @@ static HICON LoadTransportIcon(char *filename,int i,char *IconName,TCHAR *SectNa sid.cbSize = sizeof(sid); sid.hDefaultIcon = (has_proto_icon)?NULL:(HICON)CallService(MS_SKIN_LOADPROTOICON,(WPARAM)NULL,(LPARAM)(-internalidx)); sid.ptszSection = SectName; - sid.pszName=IconName; - sid.ptszDescription=Description; - sid.pszDefaultFile=szMyPath; - sid.iDefaultIndex=i; + sid.pszName = IconName; + sid.ptszDescription = Description; + sid.pszDefaultFile = szMyPath; + sid.iDefaultIndex = i; sid.flags = SIDF_TCHAR; Skin_AddIcon(&sid); } @@ -661,12 +659,13 @@ static TIconListItem sharedIconList[] = static void sttProcessIcons( int iAmount ) { - char szFile[MAX_PATH]; - GetModuleFileNameA(hInst, szFile, MAX_PATH); + TCHAR szFile[MAX_PATH]; + GetModuleFileName(hInst, szFile, MAX_PATH); SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); - sid.pszDefaultFile = szFile; + sid.ptszDefaultFile = szFile; + sid.flags = SIDF_PATH_TCHAR; char szRootSection[100]; mir_snprintf( szRootSection, SIZEOF(szRootSection), "%s/%s", LPGEN("Protocols"), LPGEN("Jabber")); diff --git a/protocols/MSN/msn_opts.cpp b/protocols/MSN/msn_opts.cpp index b611b2559a..b2fd4a9f8c 100644 --- a/protocols/MSN/msn_opts.cpp +++ b/protocols/MSN/msn_opts.cpp @@ -55,10 +55,10 @@ HANDLE hIconLibItem[SIZEOF(iconList)]; void MsnInitIcons(void) { TCHAR szFile[MAX_PATH]; - char szSectionName[100]; + GetModuleFileName(hInst, szFile, SIZEOF(szFile)); + char szSectionName[100]; mir_snprintf(szSectionName, sizeof(szSectionName), "%s/%s", LPGEN("Protocols"), LPGEN("MSN")); - GetModuleFileName(hInst, szFile, SIZEOF(szFile)); SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); @@ -66,8 +66,7 @@ void MsnInitIcons(void) sid.pszSection = szSectionName; sid.flags = SIDF_PATH_TCHAR; - for (unsigned i = 0; i < SIZEOF(iconList); i++) - { + for (int i = 0; i < SIZEOF(iconList); i++) { char szSettingName[100]; mir_snprintf(szSettingName, sizeof(szSettingName), "MSN_%s", iconList[i].szName); sid.pszName = szSettingName; diff --git a/protocols/Yahoo/icolib.cpp b/protocols/Yahoo/icolib.cpp index 868624380e..edb364eece 100644 --- a/protocols/Yahoo/icolib.cpp +++ b/protocols/Yahoo/icolib.cpp @@ -38,10 +38,10 @@ HANDLE hIconLibItem[SIZEOF(iconList)]; void CYahooProto::IconsInit( void ) { TCHAR szFile[MAX_PATH]; + GetModuleFileName(hInstance, szFile, SIZEOF(szFile)); + char szSectionName[100]; - mir_snprintf(szSectionName, sizeof(szSectionName), "%s/%s", LPGEN("Protocols"), LPGEN("YAHOO")); - GetModuleFileName(hInstance, szFile, SIZEOF(szFile)); SKINICONDESC sid = {0}; sid.cbSize = sizeof(SKINICONDESC); -- cgit v1.2.3