From 680873487c4a7987012606119a744e5ca725ad30 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 13 Apr 2019 20:22:59 +0300 Subject: merge with trunk --- include/delphi/m_api.pas | 12 +- include/delphi/m_helpers.inc | 31 - include/delphi/m_iconheader.inc | 54 - include/delphi/m_skin.inc | 3 - include/m_extraicons.h | 4 +- include/m_icolib.h | 6 + include/m_iconheader.h | 79 -- include/m_jabber.h | 4 - include/m_skin.h | 1 - include/newpluginapi.h | 13 + libs/win32/mir_app.lib | Bin 189458 -> 191388 bytes libs/win64/mir_app.lib | Bin 185326 -> 187274 bytes plugins/AuthState/src/main.cpp | 2 +- plugins/CrashDumper/src/crshdmp.cpp | 22 +- plugins/CrashDumper/src/crshdmp_icons.cpp | 18 - plugins/CrashDumper/src/stdafx.h | 2 - plugins/CrashDumper/src/ui.cpp | 4 +- plugins/FTPFileYM/src/manager.cpp | 8 +- plugins/FingerprintNG/src/fingerprint.cpp | 6 +- plugins/HistorySweeperLight/src/main.cpp | 8 +- plugins/HistorySweeperLight/src/options.cpp | 74 +- plugins/HistorySweeperLight/src/stdafx.h | 3 - plugins/IEView/src/Options.cpp | 6 +- plugins/Import/src/main.cpp | 2 +- plugins/Import/src/stdafx.h | 1 - plugins/Import/src/utils.cpp | 9 - plugins/Import/src/wizard.cpp | 2 +- plugins/KeyboardNotify/src/ignore.cpp | 14 +- plugins/KeyboardNotify/src/stdafx.h | 1 + plugins/MenuItemEx/res/resource.rc | 24 +- plugins/MenuItemEx/src/images.cpp | 26 +- plugins/MenuItemEx/src/images.h | 3 +- plugins/MenuItemEx/src/main.cpp | 107 +- plugins/MenuItemEx/src/resource.h | 24 +- plugins/MirLua/src/Modules/m_icolib.cpp | 4 +- plugins/MirLua/src/icons.cpp | 18 - plugins/MirLua/src/options.cpp | 10 +- plugins/MirLua/src/stdafx.h | 2 - plugins/NewXstatusNotify/src/indsnd.cpp | 4 +- plugins/NoHistory/src/dllmain.cpp | 12 +- plugins/NoHistory/src/icons.cpp | 14 - plugins/NoHistory/src/icons.h | 2 - plugins/NoHistory/src/options.cpp | 9 +- plugins/Popup/src/actions.cpp | 18 +- plugins/Popup/src/history.cpp | 2 +- plugins/Popup/src/icons.cpp | 40 +- plugins/Popup/src/icons.h | 37 - plugins/Popup/src/main.cpp | 4 +- plugins/Popup/src/notifications.cpp | 6 +- plugins/Popup/src/opt_adv.cpp | 2 +- plugins/Popup/src/opt_class.cpp | 4 +- plugins/Popup/src/opt_contacts.cpp | 18 +- plugins/Popup/src/opt_gen.cpp | 6 +- plugins/Popup/src/opt_skins.cpp | 2 +- plugins/Popup/src/popup_wnd2.cpp | 18 +- plugins/Popup/src/services.cpp | 6 +- plugins/Popup/src/srmm_menu.cpp | 4 +- plugins/Popup/src/stdafx.h | 3 +- plugins/Scriver/src/chat_main.cpp | 3 +- plugins/Scriver/src/chat_window.cpp | 10 +- plugins/Scriver/src/globals.cpp | 145 ++- plugins/Scriver/src/globals.h | 1 - plugins/Scriver/src/msgdialog.cpp | 8 +- plugins/Scriver/src/msglog.cpp | 6 +- plugins/Scriver/src/msgs.cpp | 6 +- plugins/SecureIM/src/loadicons.cpp | 2 +- plugins/SimpleStatusMsg/src/awaymsg.cpp | 4 +- plugins/SimpleStatusMsg/src/main.cpp | 6 +- plugins/SimpleStatusMsg/src/msgbox.cpp | 42 +- plugins/SimpleStatusMsg/src/simplestatusmsg.h | 5 +- plugins/SimpleStatusMsg/src/utils.cpp | 31 +- plugins/StartupSilence/src/main.cpp | 24 +- plugins/StartupSilence/src/stdafx.h | 11 +- plugins/UserInfoEx/src/classMAnnivDate.cpp | 34 +- plugins/UserInfoEx/src/ctrl_button.cpp | 2 +- plugins/UserInfoEx/src/ctrl_contact.cpp | 1220 ++++++++++---------- plugins/UserInfoEx/src/ctrl_contact.h | 26 +- plugins/UserInfoEx/src/dlg_anniversarylist.cpp | 2 +- plugins/UserInfoEx/src/dlg_msgbox.cpp | 26 +- plugins/UserInfoEx/src/dlg_propsheet.cpp | 24 +- .../UserInfoEx/src/ex_import/dlg_ExImModules.cpp | 278 +++-- .../UserInfoEx/src/ex_import/dlg_ExImProgress.cpp | 6 +- plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp | 8 +- plugins/UserInfoEx/src/init.cpp | 6 +- plugins/UserInfoEx/src/mir_icolib.cpp | 162 +-- plugins/UserInfoEx/src/mir_icolib.h | 94 +- plugins/UserInfoEx/src/mir_menuitems.cpp | 52 +- plugins/UserInfoEx/src/psp_anniversary.cpp | 12 +- plugins/UserInfoEx/src/psp_contact.cpp | 40 +- plugins/UserInfoEx/src/psp_general.cpp | 6 +- plugins/UserInfoEx/src/psp_options.cpp | 6 +- plugins/UserInfoEx/src/psp_origin.cpp | 4 +- plugins/UserInfoEx/src/svc_email.cpp | 6 +- plugins/UserInfoEx/src/svc_gender.cpp | 12 +- plugins/UserInfoEx/src/svc_homepage.cpp | 6 +- plugins/UserInfoEx/src/svc_phone.cpp | 12 +- plugins/UserInfoEx/src/svc_refreshci.cpp | 16 +- plugins/UserInfoEx/src/svc_reminder.cpp | 48 +- .../CloudFile/src/Services/dropbox_service.cpp | 2 +- .../CloudFile/src/Services/google_service.cpp | 2 +- .../CloudFile/src/Services/microsoft_service.cpp | 2 +- .../CloudFile/src/Services/yandex_service.cpp | 2 +- protocols/CloudFile/src/icons.cpp | 34 +- protocols/CloudFile/src/menus.cpp | 4 +- protocols/CloudFile/src/srmm.cpp | 2 +- protocols/CloudFile/src/stdafx.h | 3 - protocols/Dummy/res/resource.aps | Bin 3608 -> 0 bytes protocols/FacebookRM/src/captcha.cpp | 2 +- protocols/FacebookRM/src/dialogs.cpp | 4 +- protocols/FacebookRM/src/process.cpp | 2 +- protocols/FacebookRM/src/proto.cpp | 20 +- protocols/FacebookRM/src/theme.cpp | 27 +- protocols/FacebookRM/src/theme.h | 2 - protocols/Gadu-Gadu/src/core.cpp | 4 +- protocols/Gadu-Gadu/src/gg.h | 3 - protocols/Gadu-Gadu/src/groupchat.cpp | 2 +- protocols/Gadu-Gadu/src/icolib.cpp | 24 - protocols/Gadu-Gadu/src/image.cpp | 18 +- protocols/Gadu-Gadu/src/popups.cpp | 3 +- protocols/Gadu-Gadu/src/sessions.cpp | 2 +- protocols/Gadu-Gadu/src/userutils.cpp | 2 +- protocols/ICQ-WIM/src/ignore.cpp | 2 +- protocols/IRCG/src/clist.cpp | 2 +- protocols/IRCG/src/ircproto.cpp | 2 +- protocols/IRCG/src/options.cpp | 36 +- protocols/IRCG/src/services.cpp | 18 +- protocols/IRCG/src/stdafx.h | 2 - protocols/IRCG/src/windows.cpp | 22 +- .../JabberG/jabber_xstatus/res/JABBER_XSTATUS.rc | 324 +++--- protocols/JabberG/src/jabber.cpp | 4 + protocols/JabberG/src/jabber_adhoc.cpp | 10 +- protocols/JabberG/src/jabber_api.cpp | 11 - protocols/JabberG/src/jabber_bookmarks.cpp | 6 +- protocols/JabberG/src/jabber_byte.cpp | 13 +- protocols/JabberG/src/jabber_caps.cpp | 6 +- protocols/JabberG/src/jabber_chat.cpp | 6 +- protocols/JabberG/src/jabber_console.cpp | 32 +- protocols/JabberG/src/jabber_disco.cpp | 129 +-- protocols/JabberG/src/jabber_frame.cpp | 2 +- protocols/JabberG/src/jabber_ft.cpp | 14 +- protocols/JabberG/src/jabber_groupchat.cpp | 16 +- protocols/JabberG/src/jabber_ibb.cpp | 4 +- protocols/JabberG/src/jabber_icolib.cpp | 63 +- protocols/JabberG/src/jabber_iq.cpp | 7 +- protocols/JabberG/src/jabber_iq.h | 4 +- protocols/JabberG/src/jabber_iq_handlers.cpp | 2 +- protocols/JabberG/src/jabber_iqid.cpp | 24 +- protocols/JabberG/src/jabber_iqid_muc.cpp | 12 +- protocols/JabberG/src/jabber_menu.cpp | 52 +- protocols/JabberG/src/jabber_misc.cpp | 2 +- protocols/JabberG/src/jabber_notes.cpp | 6 +- protocols/JabberG/src/jabber_omemo.cpp | 2 +- protocols/JabberG/src/jabber_opttree.cpp | 14 +- protocols/JabberG/src/jabber_password.cpp | 2 +- protocols/JabberG/src/jabber_privacy.cpp | 83 +- protocols/JabberG/src/jabber_proto.cpp | 29 +- protocols/JabberG/src/jabber_proto.h | 8 +- protocols/JabberG/src/jabber_roster.cpp | 2 +- protocols/JabberG/src/jabber_svc.cpp | 2 +- protocols/JabberG/src/jabber_thread.cpp | 11 +- protocols/JabberG/src/jabber_treelist.cpp | 6 +- protocols/JabberG/src/jabber_userinfo.cpp | 20 +- protocols/JabberG/src/jabber_util.cpp | 17 +- protocols/JabberG/src/jabber_vcard.cpp | 10 +- protocols/JabberG/src/jabber_xml.cpp | 5 +- protocols/JabberG/src/jabber_xml.h | 1 + protocols/JabberG/src/jabber_xstatus.cpp | 4 +- protocols/JabberG/src/stdafx.h | 14 +- protocols/MSN/src/msn_lists.cpp | 23 +- protocols/MSN/src/msn_menu.cpp | 12 +- protocols/MSN/src/msn_misc.cpp | 2 +- protocols/MSN/src/msn_opts.cpp | 27 +- protocols/MSN/src/stdafx.h | 4 - protocols/MinecraftDynmap/src/dialogs.cpp | 47 +- protocols/MinecraftDynmap/src/dialogs.h | 2 - protocols/NewsAggregator/Res/Resource.rc | 1 + protocols/NewsAggregator/Src/Icons.cpp | 18 +- protocols/NewsAggregator/Src/Menus.cpp | 12 +- protocols/NewsAggregator/Src/Services.cpp | 10 +- protocols/NewsAggregator/Src/resource.h | 1 + protocols/NewsAggregator/Src/stdafx.h | 2 - protocols/Omegle/src/communication.cpp | 8 +- protocols/Omegle/src/theme.cpp | 9 - protocols/Omegle/src/theme.h | 1 - protocols/Sametime/src/conference.cpp | 4 +- protocols/Sametime/src/sametime.cpp | 22 - protocols/Sametime/src/sametime.h | 4 - protocols/Sametime/src/sametime_session.cpp | 2 +- protocols/Sametime/src/utils.cpp | 8 +- protocols/SkypeWeb/src/skype_events.cpp | 4 +- protocols/SkypeWeb/src/skype_icons.cpp | 16 - protocols/SkypeWeb/src/skype_menus.cpp | 8 +- protocols/SkypeWeb/src/skype_popups.cpp | 6 +- protocols/SkypeWeb/src/skype_proto.h | 4 - protocols/SkypeWeb/src/skype_trouter.cpp | 2 +- protocols/Tox/src/tox_icons.cpp | 16 - protocols/Tox/src/tox_messages.cpp | 2 +- protocols/Tox/src/tox_proto.h | 4 - protocols/VKontakte/src/misc.cpp | 11 +- protocols/VKontakte/src/vk.h | 1 - protocols/VKontakte/src/vk_chats.cpp | 14 +- protocols/VKontakte/src/vk_dialogs.cpp | 4 +- protocols/VKontakte/src/vk_feed.cpp | 2 +- protocols/VKontakte/src/vk_proto.cpp | 50 +- protocols/Weather/src/stdafx.h | 3 - protocols/Weather/src/weather.cpp | 4 +- protocols/Weather/src/weather_icons.cpp | 23 - protocols/Weather/src/weather_ini.cpp | 2 +- protocols/Weather/src/weather_mwin.cpp | 2 +- protocols/Weather/src/weather_svcs.cpp | 32 +- protocols/YAMN/src/browser/badconnect.cpp | 6 +- protocols/YAMN/src/browser/mailbrowser.cpp | 18 +- protocols/YAMN/src/main.cpp | 18 +- protocols/YAMN/src/proto/pop3/pop3opt.cpp | 57 +- protocols/YAMN/src/services.cpp | 4 +- protocols/YAMN/src/stdafx.h | 3 - src/core/stdmsg/src/chat_options.cpp | 91 +- src/core/stdmsg/src/chat_window.cpp | 12 +- src/core/stdmsg/src/msgs.cpp | 16 +- src/core/stdmsg/src/stdafx.h | 2 - src/core/stdmsg/src/tabs.cpp | 2 +- src/mir_app/src/CMPluginBase.cpp | 36 +- src/mir_app/src/clistmod.cpp | 2 +- src/mir_app/src/descbutton.cpp | 2 - src/mir_app/src/ei_baseIcon.cpp | 21 +- src/mir_app/src/ei_callbackIcon.cpp | 2 +- src/mir_app/src/ei_defaulticons.cpp | 8 +- src/mir_app/src/ei_groupIcon.cpp | 8 +- src/mir_app/src/ei_icolibIcon.cpp | 2 +- src/mir_app/src/ei_options.cpp | 11 +- src/mir_app/src/ei_services.cpp | 14 +- src/mir_app/src/extraicons.h | 24 +- src/mir_app/src/findadd.cpp | 2 +- src/mir_app/src/headerbar.cpp | 31 +- src/mir_app/src/hotkey_opts.cpp | 16 +- src/mir_app/src/icolib.cpp | 3 + src/mir_app/src/iconheader.cpp | 525 --------- src/mir_app/src/ignore.cpp | 16 +- src/mir_app/src/menu_utils.cpp | 2 +- src/mir_app/src/mir_app.def | 10 +- src/mir_app/src/mir_app64.def | 10 +- src/mir_app/src/miranda.h | 3 - src/mir_app/src/modules.cpp | 2 - src/mir_app/src/newplugins.cpp | 6 +- src/mir_app/src/pluginopts.cpp | 4 +- src/mir_app/src/skinicons.cpp | 25 +- src/mir_app/src/visibility.cpp | 6 +- 247 files changed, 2272 insertions(+), 3636 deletions(-) delete mode 100644 include/delphi/m_iconheader.inc delete mode 100644 include/m_iconheader.h delete mode 100644 plugins/Popup/src/icons.h delete mode 100644 protocols/Dummy/res/resource.aps delete mode 100644 src/mir_app/src/iconheader.cpp diff --git a/include/delphi/m_api.pas b/include/delphi/m_api.pas index 66cefac276..6237eaaa56 100644 --- a/include/delphi/m_api.pas +++ b/include/delphi/m_api.pas @@ -142,13 +142,19 @@ type type PCMPlugin = ^CMPlugin; - CMPlugin = record + CMPlugin = packed record vft : pointer; // virtual function table + m_hInst : THANDLE; m_szModule : PAnsiChar; m_pInfo : PPLUGININFOEX; m_hLogger : THANDLE; - m_hLang : int; + + blabla1 : pointer; // emulator of icon's list + blabla2 : integer; + blabla3 : integer; + blabla4 : integer; + blabla5 : pointer; end; //----- Fork enchancement ----- @@ -219,7 +225,6 @@ var {$include m_history.inc} {$include m_hotkeys.inc} {$include m_icolib.inc} - {$include m_iconheader.inc} {$include m_ignore.inc} {$include m_imgsrvc.inc} {$include m_json.inc} @@ -253,6 +258,7 @@ implementation initialization g_plugin.m_hInst := hInstance; g_plugin.m_pInfo := @PluginInfo; + g_plugin.blabla4 := 10; RegisterPlugin(g_plugin); finalization diff --git a/include/delphi/m_helpers.inc b/include/delphi/m_helpers.inc index 1b1d95c378..d240073501 100644 --- a/include/delphi/m_helpers.inc +++ b/include/delphi/m_helpers.inc @@ -57,9 +57,6 @@ function TopToolbar_AddButton(pButton:PTTBButton):THANDLE; function Options_Open(group,page,tab:PWideChar):int_ptr; -procedure MIcoTab_AddItem (hwnd:HWND; lptzName:PAnsiChar; hIcon:HICON; data:LPARAM; bSharedIcon:bool); -procedure MIcoTab_AddItemW(hwnd:HWND; lptzName:PWideChar; hIcon:HICON; data:LPARAM; bSharedIcon:bool); - {$ELSE} function _Srmm_AddButton(bbdi:pBBButton; pPlugin:Pointer) : integer; stdcall; @@ -335,34 +332,6 @@ begin result:=_Options_Open(group,page,tab,@g_plugin); end; -procedure MIcoTab_AddItem(hwnd:HWND; lptzName:PAnsiChar; hIcon:HICON; data:LPARAM; bSharedIcon:bool); -var - mit:tMIcoTab; -begin - if bSharedIcon then - mit.flag := MITCF_SHAREDICON - else - mit.flag := 0; - mit.hIcon := hIcon; - mit.szName.a := lptzName; - mit.data := data; - SendMessage(hwnd, ITCM_ADDITEM, WPARAM(@mit), 0); -end; - -procedure MIcoTab_AddItemW(hwnd:HWND; lptzName:PWideChar; hIcon:HICON; data:LPARAM; bSharedIcon:bool); -var - mit:tMIcoTab; -begin - if bSharedIcon then - mit.flag := MITCF_SHAREDICON or MITCF_UNICODE - else - mit.flag := MITCF_UNICODE; - mit.hIcon := hIcon; - mit.szName.w := lptzName; - mit.data := data; - SendMessage(hwnd, ITCM_ADDITEM, WPARAM(@mit), 0); -end; - procedure Srmm_AddButton(bbdi:pBBButton); begin _Srmm_AddButton(bbdi,@g_plugin); diff --git a/include/delphi/m_iconheader.inc b/include/delphi/m_iconheader.inc deleted file mode 100644 index ad1633d6b6..0000000000 --- a/include/delphi/m_iconheader.inc +++ /dev/null @@ -1,54 +0,0 @@ -{ -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2007 Artem Shpynov -Copyright 2000-2007 Miranda ICQ/IM project, - -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -} - -{$IFNDEF M_ICONHEADER} -{$DEFINE M_ICONHEADER} - -const - MIRANDAICOTABCLASS = 'MirandaIcoTabClass'; - - MITCF_SHAREDICON = $01; - MITCF_UNICODE = $02; - - ITCM_FIRST = (WM_USER+1024); - ITCM_LAST = (ITCM_FIRST+64); - - ITCM_SETBACKGROUND = (ITCM_FIRST+1); //LPARAM is HBITMAP - ITCM_ADDITEM = (ITCM_FIRST+2); //LPARAM is pointer to MIcoTab - ITCM_SETSEL = (ITCM_FIRST+3); //WPARAM is new selected index - ITCM_GETSEL = (ITCM_FIRST+4); //result is selected item index - ITCM_GETITEMDATA = (ITCM_FIRST+5); //WPARAM is item index, result is custom data - - ITCN_SELCHANGED = 1; - ITCN_SELCHANGEDKBD = 2; -// structure is used for storing info about single tab -type - TMIcoTab = record - hIcon :HICON; - szName:TChar; - flag :dword; - data :LPARAM; - end; - -{$ENDIF} diff --git a/include/delphi/m_skin.inc b/include/delphi/m_skin.inc index b1cf7e3acc..27c3d8a86e 100644 --- a/include/delphi/m_skin.inc +++ b/include/delphi/m_skin.inc @@ -95,9 +95,6 @@ function Skin_LoadIcon(iconId:int; big:byte) : HICON; stdcall; function Skin_GetIconHandle(iconId:int) : THANDLE; stdcall; external AppDLL name 'Skin_GetIconHandle'; -function Skin_GetIconName(iconId:int) : PAnsiChar; stdcall; - external AppDLL name 'Skin_GetIconName'; - // status mode icons. NOTE: These are deprecated in favour of LoadSkinnedProtoIcon() const SKINICON_STATUS_OFFLINE = 0; diff --git a/include/m_extraicons.h b/include/m_extraicons.h index 30f306b1f4..d5a4c39ee9 100644 --- a/include/m_extraicons.h +++ b/include/m_extraicons.h @@ -109,10 +109,10 @@ EXTERN_C MIR_APP_DLL(void) KillModuleExtraIcons(HPLUGIN pPlugin); #define EIF_DISABLED_BY_DEFAULT 0x0001 -EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallback(const char *name, const char *description, const char *descIcon, +EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallback(const char *name, const char *description, HANDLE descIcon, MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick = nullptr, LPARAM onClickParam = 0, int flags = 0); -EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, const char *descIcon = nullptr, +EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, HANDLE descIcon = nullptr, MIRANDAHOOKPARAM OnClick = nullptr, LPARAM onClickParam = 0, int flags = 0); ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/include/m_icolib.h b/include/m_icolib.h index b63fc4abf0..e8a0ec3704 100644 --- a/include/m_icolib.h +++ b/include/m_icolib.h @@ -110,6 +110,12 @@ MIR_APP_DLL(void) Window_SetSkinIcon_IcoLib(HWND hWnd, int iconId); MIR_APP_DLL(void) Window_SetProtoIcon_IcoLib(HWND hWnd, const char *szProto, int iconId); MIR_APP_DLL(void) Window_FreeIcon_IcoLib(HWND hWnd); +/////////////////////////////////////////////////////////////////////////////// +// Helper to add an icolib's icon to a HIMAGELIST + +MIR_APP_DLL(int) ImageList_AddSkinIcon(HIMAGELIST hIml, int iconId); +MIR_APP_DLL(int) ImageList_AddProtoIcon(HIMAGELIST hIml, const char *szProto, int iconId); + /////////////////////////////////////////////////////////////////////////////// // Icons' change notification event diff --git a/include/m_iconheader.h b/include/m_iconheader.h deleted file mode 100644 index 48355c2ef5..0000000000 --- a/include/m_iconheader.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (C) 2012-19 Miranda NG team (https://miranda-ng.org) -Copyright (c) 2000-2007 Miranda ICQ/IM project, -Copyright (c) 2007 Artem Shpynov - -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef M_ICONHEADER_H__ -#define M_ICONHEADER_H__ 1 - -#define MIRANDAICOTABCLASS L"MirandaIcoTabClass" - -#define MITCF_SHAREDICON 0x01 -#define MITCF_UNICODE 0x02 - -#define ITCM_FIRST (WM_USER+1024) -#define ITCM_LAST (ITCM_FIRST+64) - -#define ITCM_SETBACKGROUND (ITCM_FIRST+1) //LPARAM is HBITMAP -#define ITCM_ADDITEM (ITCM_FIRST+2) //LPARAM is pointer to MIcoTab -#define ITCM_SETSEL (ITCM_FIRST+3) //WPARAM is new selected index -#define ITCM_GETSEL (ITCM_FIRST+4) //result is selected item index -#define ITCM_GETITEMDATA (ITCM_FIRST+5) //WPARAM is item index, result is custom data - -#define ITCN_SELCHANGED 1 -#define ITCN_SELCHANGEDKBD 2 - -// structure is used for storing info about single tab -typedef struct { - HICON hIcon; - union { - wchar_t *tcsName; - wchar_t *lptzName; - char *lpzName; - wchar_t *lpwzName; - }; - DWORD flag; - LPARAM data; -} MIcoTab; - -#define MIcoTab_SetBackground(hwnd, hBmp) \ - (SendMessage((hwnd), ITCM_SETBACKGROUND, 0, (LPARAM)(hBmp))) -#define MIcoTab_SetSel(hwnd, idx) \ - (SendMessage((hwnd), ITCM_SETSEL, (idx), 0)) -#define MIcoTab_GetSel(hwnd) \ - (SendMessage((hwnd), ITCM_GETSEL, 0, 0)) -#define MIcoTab_GetItemData(hwnd, idx) \ - (SendMessage((hwnd), ITCM_GETITEMDATA, (idx), 0)) - -static __forceinline void MIcoTab_AddItem(HWND hwnd, wchar_t *lptzName, HICON hIcon, LPARAM data, BOOL bSharedIcon) -{ - MIcoTab mit = {0}; - mit.flag = (bSharedIcon?MITCF_SHAREDICON:0)| MITCF_UNICODE; - mit.hIcon = hIcon; - mit.tcsName = lptzName; - mit.data = data; - SendMessage(hwnd, ITCM_ADDITEM, (WPARAM)&mit, 0); -} - -#endif // M_ICONHEADER_H__ diff --git a/include/m_jabber.h b/include/m_jabber.h index fdb865ec6b..c2e91e9833 100644 --- a/include/m_jabber.h +++ b/include/m_jabber.h @@ -129,10 +129,6 @@ struct IJabberInterface // Registers incoming handler. iIqTypes is a combination of JABBER_IQ_TYPE_* flags. Returns handler handle on success or NULL on error. virtual HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, LPCSTR szXmlns, LPCSTR szTag, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0; - // Registers temporary handler for incoming stanza of type iIqType with id iIqId. iIqTypes is a combination of JABBER_IQ_TYPE_* flags. Returns handler handle on success or NULL on error. - // If dwTimeout milliseconds pass and no Iq stanza with the specified iIqId is received, Jabber plugin will call Func() with NULL node. - virtual HJHANDLER STDMETHODCALLTYPE AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, int iIqId, void *pUserData = nullptr, DWORD dwTimeout = 30000, int iPriority = JH_PRIORITY_DEFAULT) = 0; - // Registers handler for outgoing nodes. Returns handler handle on success or NULL on error. // Return FALSE in the handler to continue, or TRUE to abort sending. virtual HJHANDLER STDMETHODCALLTYPE AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) = 0; diff --git a/include/m_skin.h b/include/m_skin.h index 33f110e017..5d0e7f05bb 100644 --- a/include/m_skin.h +++ b/include/m_skin.h @@ -96,7 +96,6 @@ EXTERN_C MIR_APP_DLL(HICON) Skin_LoadIcon(int idx, bool big = false); EXTERN_C MIR_APP_DLL(HANDLE) Skin_GetIconHandle(int idx); -EXTERN_C MIR_APP_DLL(char*) Skin_GetIconName(int idx); // status mode icons. NOTE: These are deprecated in favour of LoadSkinProtoIcon() #define SKINICON_STATUS_OFFLINE 0 diff --git a/include/newpluginapi.h b/include/newpluginapi.h index 32ed951999..153da7936e 100644 --- a/include/newpluginapi.h +++ b/include/newpluginapi.h @@ -25,6 +25,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_NEWPLUGINAPI_H__ #define M_NEWPLUGINAPI_H__ +#if !defined(HIMAGELIST) +typedef struct _IMAGELIST* HIMAGELIST; +#endif + #include #include @@ -151,6 +155,8 @@ typedef int(*pfnUninitProto)(PROTO_INTERFACE*); #pragma warning(push) #pragma warning(disable:4275) +struct IcolibItem; + class MIR_APP_EXPORT CMPluginBase : public MNonCopyable { void tryOpenLog(); @@ -160,6 +166,7 @@ protected: const char *m_szModuleName; const PLUGININFOEX &m_pInfo; HANDLE m_hLogger = nullptr; + LIST m_arIcons; CMPluginBase(const char *moduleName, const PLUGININFOEX &pInfo); ~CMPluginBase(); @@ -172,6 +179,12 @@ public: void debugLogA(LPCSTR szFormat, ...); void debugLogW(LPCWSTR wszFormat, ...); + __forceinline void addIcolib(HANDLE hIcolib) { m_arIcons.insert((IcolibItem*)hIcolib); } + int addImgListIcon(HIMAGELIST himl, int iconId); + HICON getIcon(int iconId, bool big = false); + HANDLE getIconHandle(int iconId); + void releaseIcon(int iconId, bool big = false); + __forceinline const PLUGININFOEX& getInfo() const { return m_pInfo; } __forceinline const char* getModule() const { return m_szModuleName; } diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index a8eeec60e4..78fc2dc1c6 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index a6bc69ad41..dcf8312d8f 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/plugins/AuthState/src/main.cpp b/plugins/AuthState/src/main.cpp index ffc7e229f5..fe60e1c114 100644 --- a/plugins/AuthState/src/main.cpp +++ b/plugins/AuthState/src/main.cpp @@ -152,7 +152,7 @@ int onPrebuildContactMenu(WPARAM hContact, LPARAM) int onModulesLoaded(WPARAM, LPARAM) { // extra icons - hExtraIcon = ExtraIcon_RegisterIcolib("authstate", LPGEN("Auth state"), iconList[ICON_BOTH].szName); + hExtraIcon = ExtraIcon_RegisterIcolib("authstate", LPGEN("Auth state"), iconList[ICON_BOTH].hIcolib); // Set initial value for all contacts for (auto &hContact : Contacts()) diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index 7d9baf7c23..24eb33fd0b 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -184,24 +184,24 @@ static int ToolbarModulesLoaded(WPARAM, LPARAM) TTBButton ttb = {}; ttb.pszService = MS_CRASHDUMPER_STORETOCLIP; ttb.name = ttb.pszTooltipUp = LPGEN("Version Information To Clipboard"); - ttb.hIconHandleUp = GetIconHandle(IDI_VITOCLIP); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_VITOCLIP); ttb.dwFlags = TTBBF_VISIBLE; g_plugin.addTTB(&ttb); ttb.pszService = MS_CRASHDUMPER_STORETOFILE; ttb.name = ttb.pszTooltipUp = LPGEN("Version Information To File"); - ttb.hIconHandleUp = GetIconHandle(IDI_VITOFILE); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_VITOFILE); ttb.dwFlags = 0; g_plugin.addTTB(&ttb); ttb.pszService = MS_CRASHDUMPER_VIEWINFO; ttb.name = ttb.pszTooltipUp = LPGEN("Show Version Information"); - ttb.hIconHandleUp = GetIconHandle(IDI_VISHOW); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_VISHOW); g_plugin.addTTB(&ttb); ttb.pszService = MS_CRASHDUMPER_UPLOAD; ttb.name = ttb.pszTooltipUp = LPGEN("Upload Version Information"); - ttb.hIconHandleUp = GetIconHandle(IDI_VIUPLOAD); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_VIUPLOAD); g_plugin.addTTB(&ttb); return 0; } @@ -224,48 +224,48 @@ static int ModulesLoaded(WPARAM, LPARAM) } CMenuItem mi(&g_plugin); - mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Version Information"), 2000089999, GetIconHandle(IDI_VI)); + mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Version Information"), 2000089999, g_plugin.getIconHandle(IDI_VI)); Menu_ConfigureItem(mi.root, MCI_OPT_UID, "9A7A9C76-7FD8-4C05-B402-6C46060C2D78"); SET_UID(mi, 0x52930e40, 0xb2ee, 0x4433, 0xad, 0x77, 0xf5, 0x42, 0xe, 0xf6, 0x57, 0xc1); mi.position = 2000089995; mi.name.a = LPGEN("Copy to clipboard"); - mi.hIcolibItem = GetIconHandle(IDI_VITOCLIP); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_VITOCLIP); mi.pszService = MS_CRASHDUMPER_STORETOCLIP; Menu_AddMainMenuItem(&mi); SET_UID(mi, 0x54109094, 0x494e, 0x4535, 0x9c, 0x3a, 0xf6, 0x9e, 0x9a, 0xf7, 0xcd, 0xbe); mi.position = 2000089996; mi.name.a = LPGEN("Store to file"); - mi.hIcolibItem = GetIconHandle(IDI_VITOFILE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_VITOFILE); mi.pszService = MS_CRASHDUMPER_STORETOFILE; Menu_AddMainMenuItem(&mi); SET_UID(mi, 0x4004f9ee, 0x2c5a, 0x420a, 0xb1, 0x54, 0x3e, 0x47, 0xc1, 0xde, 0x46, 0xec); mi.position = 2000089997; mi.name.a = LPGEN("Show"); - mi.hIcolibItem = GetIconHandle(IDI_VISHOW); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_VISHOW); mi.pszService = MS_CRASHDUMPER_VIEWINFO; Menu_AddMainMenuItem(&mi); SET_UID(mi, 0x8526469a, 0x8ab4, 0x4dd4, 0xad, 0xbf, 0x51, 0xfd, 0x71, 0x10, 0xd3, 0x3c); mi.position = 2000089998; mi.name.a = LPGEN("Show with DLLs"); - mi.hIcolibItem = GetIconHandle(IDI_VIUPLOAD); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_VIUPLOAD); mi.pszService = MS_CRASHDUMPER_VIEWINFO; Menu_ConfigureItem(Menu_AddMainMenuItem(&mi), MCI_OPT_EXECPARAM, 1); SET_UID(mi, 0xc6e3b558, 0xe1e8, 0x4cce, 0x96, 0x8, 0xc6, 0x89, 0x1b, 0x79, 0xf3, 0x7e); mi.position = 2000089999; mi.name.a = LPGEN("Upload"); - mi.hIcolibItem = GetIconHandle(IDI_VIUPLOAD); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_VIUPLOAD); mi.pszService = MS_CRASHDUMPER_UPLOAD; Menu_AddMainMenuItem(&mi); SET_UID(mi, 0xa23da95a, 0x7624, 0x4343, 0x8c, 0xc0, 0xa6, 0x16, 0xbc, 0x30, 0x13, 0x8c); mi.position = 2000089999; mi.name.a = LPGEN("Copy link to clipboard"); - mi.hIcolibItem = GetIconHandle(IDI_LINKTOCLIP);//need icon + mi.hIcolibItem = g_plugin.getIconHandle(IDI_LINKTOCLIP);//need icon mi.pszService = MS_CRASHDUMPER_URLTOCLIP; Menu_AddMainMenuItem(&mi); diff --git a/plugins/CrashDumper/src/crshdmp_icons.cpp b/plugins/CrashDumper/src/crshdmp_icons.cpp index e1dcd040ca..909b90d505 100644 --- a/plugins/CrashDumper/src/crshdmp_icons.cpp +++ b/plugins/CrashDumper/src/crshdmp_icons.cpp @@ -32,21 +32,3 @@ void InitIcons(void) { g_plugin.registerIcon(LPGEN("Crash Dumper"), iconList, MODULENAME); } - -HICON LoadIconEx(int iconId, bool big) -{ - for (int i = 0; i < _countof(iconList); i++) - if (iconList[i].defIconID == iconId) - return IcoLib_GetIconByHandle(iconList[i].hIcolib, big); - - return nullptr; -} - -HANDLE GetIconHandle(int iconId) -{ - for (int i = 0; i < _countof(iconList); i++) - if (iconList[i].defIconID == iconId) - return iconList[i].hIcolib; - - return nullptr; -} diff --git a/plugins/CrashDumper/src/stdafx.h b/plugins/CrashDumper/src/stdafx.h index c6ace054d4..588c8ce737 100644 --- a/plugins/CrashDumper/src/stdafx.h +++ b/plugins/CrashDumper/src/stdafx.h @@ -150,8 +150,6 @@ void OpenAuthUrl(const char* url); void __cdecl VersionInfoUploadThread(void* arg); void InitIcons(void); -HICON LoadIconEx(int iconId, bool big = false); -HANDLE GetIconHandle(int iconId); int OptionsInit(WPARAM wParam, LPARAM); INT_PTR ViewVersionInfo(WPARAM wParam, LPARAM); diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index 67a73d1bb7..50c7dd944c 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -44,7 +44,7 @@ public: bool OnInitDialog() override { - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_VI)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_VI)); { CHARFORMAT2 chf; chf.cbSize = sizeof(chf); @@ -317,7 +317,7 @@ void ShowMessage(int type, const wchar_t *format, ...) va_end(va); mir_wstrcpy(ppd.lpwzContactName, _A2W(MODULENAME)); - ppd.lchIcon = LoadIconEx(IDI_VI); + ppd.lchIcon = g_plugin.getIcon(IDI_VI); ppd.PluginWindowProc = DlgProcPopup; ppd.PluginData = (void*)type; PUAddPopupW(&ppd); diff --git a/plugins/FTPFileYM/src/manager.cpp b/plugins/FTPFileYM/src/manager.cpp index c4ea35a8f3..98f6818a23 100644 --- a/plugins/FTPFileYM/src/manager.cpp +++ b/plugins/FTPFileYM/src/manager.cpp @@ -66,10 +66,10 @@ void Manager::initImageList() char buff[256]; m_himlStates = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, ServerList::FTP_COUNT + 4, 0); - ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE)); // image index 0 is useless for INDEXTOSTATEIMAGEMASK - ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE)); - ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_NOTICK)); - ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_TICK)); + ImageList_AddSkinIcon(m_himlStates, SKINICON_OTHER_DELETE); // image index 0 is useless for INDEXTOSTATEIMAGEMASK + ImageList_AddSkinIcon(m_himlStates, SKINICON_OTHER_DELETE); + ImageList_AddSkinIcon(m_himlStates, SKINICON_OTHER_NOTICK); + ImageList_AddSkinIcon(m_himlStates, SKINICON_OTHER_TICK); for (int i = 0; i < ServerList::FTP_COUNT; i++) { mir_snprintf(buff, "ftp%d", i); diff --git a/plugins/FingerprintNG/src/fingerprint.cpp b/plugins/FingerprintNG/src/fingerprint.cpp index c0ac0410c9..83ae37180d 100644 --- a/plugins/FingerprintNG/src/fingerprint.cpp +++ b/plugins/FingerprintNG/src/fingerprint.cpp @@ -887,6 +887,9 @@ int OnModulesLoaded(WPARAM, LPARAM) RegisterIcons(); + hExtraIcon = ExtraIcon_RegisterCallback("Client", LPGEN("Fingerprint"), "client_Miranda_unknown", + OnExtraIconListRebuild, OnExtraImageApply, OnExtraIconClick); + if (g_plugin.getByte("StatusBarIcon", 1)) { StatusIconData sid = {}; sid.szModule = MODULENAME; @@ -907,7 +910,4 @@ void InitFingerModule() CreateServiceFunction(MS_FP_SAMECLIENTSW, ServiceSameClientsW); CreateServiceFunction(MS_FP_GETCLIENTDESCRW, ServiceGetClientDescrW); CreateServiceFunction(MS_FP_GETCLIENTICONW, ServiceGetClientIconW); - - hExtraIcon = ExtraIcon_RegisterCallback("Client", LPGEN("Fingerprint"), "client_Miranda_unknown", - OnExtraIconListRebuild, OnExtraImageApply, OnExtraIconClick); } diff --git a/plugins/HistorySweeperLight/src/main.cpp b/plugins/HistorySweeperLight/src/main.cpp index 7d4ecd5311..416c83f319 100644 --- a/plugins/HistorySweeperLight/src/main.cpp +++ b/plugins/HistorySweeperLight/src/main.cpp @@ -70,7 +70,7 @@ static int OnModulesLoaded(WPARAM, LPARAM) StatusIconData sid = {}; sid.szModule = MODULENAME; - sid.hIcon = LoadIconEx("actG"); + sid.hIcon = g_plugin.getIcon(IDI_ACTG); if (sweep == 0) sid.szTooltip.w = LPGENW("Keep all events"); else if (sweep == 1) @@ -84,17 +84,17 @@ static int OnModulesLoaded(WPARAM, LPARAM) Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 1; - sid.hIcon = LoadIconEx("act1"); + sid.hIcon = g_plugin.getIcon(IDI_ACT1); sid.szTooltip.w = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]; Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 2; - sid.hIcon = LoadIconEx("act2"); + sid.hIcon = g_plugin.getIcon(IDI_ACT2); sid.szTooltip.w = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]; Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 3; - sid.hIcon = LoadIconEx("actDel"); + sid.hIcon = g_plugin.getIcon(IDI_ACTDEL); sid.szTooltip.w = LPGENW("Delete all events"); Srmm_AddIcon(&sid, &g_plugin); diff --git a/plugins/HistorySweeperLight/src/options.cpp b/plugins/HistorySweeperLight/src/options.cpp index 4dc71814f8..50db5990f5 100644 --- a/plugins/HistorySweeperLight/src/options.cpp +++ b/plugins/HistorySweeperLight/src/options.cpp @@ -21,6 +21,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" +///////////////////////////////////////////////////////////////////////////////////////// + +static IconItem iconList[] = +{ + { LPGEN("Default Action"), "actG", IDI_ACTG }, + { LPGEN("Action 1"), "act1", IDI_ACT1 }, + { LPGEN("Action 2"), "act2", IDI_ACT2 }, + { LPGEN("Delete All"), "actDel", IDI_ACTDEL } +}; + +static HANDLE hIconLibItem[_countof(iconList)]; + +void InitIcons(void) +{ + g_plugin.registerIcon(MODULENAME, iconList, MODULENAME); +} + +///////////////////////////////////////////////////////////////////////////////////////// + // Time Stamps strings wchar_t* time_stamp_strings[] = { @@ -44,44 +63,6 @@ wchar_t* keep_strings[] = LPGENW("Keep 50 last events") }; -static IconItem iconList[] = -{ - { LPGEN("Default Action"), "actG", IDI_ACTG }, - { LPGEN("Action 1"), "act1", IDI_ACT1 }, - { LPGEN("Action 2"), "act2", IDI_ACT2 }, - { LPGEN("Delete All"), "actDel", IDI_ACTDEL } -}; - -static HANDLE hIconLibItem[_countof(iconList)]; - -void InitIcons(void) -{ - g_plugin.registerIcon(MODULENAME, iconList, MODULENAME); -} - -HICON LoadIconEx(const char* name) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", MODULENAME, name); - return IcoLib_GetIcon(szSettingName); -} - -HANDLE GetIconHandle(const char* name) -{ - for (auto &it : iconList) - if (mir_strcmp(it.szName, name) == 0) - return ⁢ - - return nullptr; -} - -void ReleaseIconEx(const char* name) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", MODULENAME, name); - IcoLib_Release(szSettingName); -} - HANDLE hAllContacts, hSystemHistory; static void ShowAllContactIcons(HWND hwndList) @@ -182,20 +163,17 @@ INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) TranslateDialogDefault(hwndDlg); { HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, 2, 2); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_SMALLDOT); - HICON hIcon = Skin_LoadIcon(SKINICON_OTHER_SMALLDOT); - ImageList_AddIcon(hIml, hIcon); - IcoLib_ReleaseIcon(hIcon); - - hIcon = LoadIconEx("act1"); + HICON hIcon = g_plugin.getIcon(IDI_ACT1); ImageList_AddIcon(hIml, hIcon); SendDlgItemMessage(hwndDlg, IDC_ACT1, STM_SETICON, (WPARAM)hIcon, 0); - hIcon = LoadIconEx("act2"); + hIcon = g_plugin.getIcon(IDI_ACT2); ImageList_AddIcon(hIml, hIcon); SendDlgItemMessage(hwndDlg, IDC_ACT2, STM_SETICON, (WPARAM)hIcon, 0); - hIcon = LoadIconEx("actDel"); + hIcon = g_plugin.getIcon(IDI_ACTDEL); ImageList_AddIcon(hIml, hIcon); SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); @@ -206,9 +184,9 @@ INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) case WM_DESTROY: ImageList_Destroy((HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0)); - ReleaseIconEx("act1"); - ReleaseIconEx("act2"); - ReleaseIconEx("actDel"); + g_plugin.releaseIcon(IDI_ACT1); + g_plugin.releaseIcon(IDI_ACT2); + g_plugin.releaseIcon(IDI_ACTDEL); break; case WM_COMMAND: diff --git a/plugins/HistorySweeperLight/src/stdafx.h b/plugins/HistorySweeperLight/src/stdafx.h index 5d68a9c2bb..73df99ec90 100644 --- a/plugins/HistorySweeperLight/src/stdafx.h +++ b/plugins/HistorySweeperLight/src/stdafx.h @@ -60,9 +60,6 @@ extern wchar_t* time_stamp_strings[]; extern wchar_t* keep_strings[]; int HSOptInitialise(WPARAM wParam, LPARAM lParam); void InitIcons(void); -void ReleaseIconEx(const char* name); -HICON LoadIconEx(const char* name); -HANDLE GetIconHandle(const char* name); // historysweeper.c void ShutdownAction(void); diff --git a/plugins/IEView/src/Options.cpp b/plugins/IEView/src/Options.cpp index b4dc6a1f85..e5bcbb89f8 100644 --- a/plugins/IEView/src/Options.cpp +++ b/plugins/IEView/src/Options.cpp @@ -287,11 +287,7 @@ static void RefreshProtoIcons() ImageList_AddIcon(hProtocolImageList, hIcon); DestroyIcon(hIcon); } - else { - hIcon = (HICON)Skin_LoadIcon(SKINICON_OTHER_MIRANDA); - ImageList_AddIcon(hProtocolImageList, hIcon); - IcoLib_ReleaseIcon(hIcon); - } + else ImageList_AddSkinIcon(hProtocolImageList, SKINICON_OTHER_MIRANDA); } } diff --git a/plugins/Import/src/main.cpp b/plugins/Import/src/main.cpp index 7c48eab1ff..046d463f39 100644 --- a/plugins/Import/src/main.cpp +++ b/plugins/Import/src/main.cpp @@ -62,7 +62,7 @@ static int ModulesLoaded(WPARAM, LPARAM) // menu item CMenuItem mi(&g_plugin); SET_UID(mi, 0x20ffaf55, 0xafa0, 0x4da3, 0xa9, 0x46, 0x20, 0x51, 0xa0, 0x24, 0xb, 0x41); - mi.hIcolibItem = GetIconHandle(IDI_IMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT); mi.name.a = LPGEN("&Import..."); mi.position = 500050000; mi.pszService = MS_IMPORT_SERVICE; diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h index 415eed700a..85e8f728d3 100644 --- a/plugins/Import/src/stdafx.h +++ b/plugins/Import/src/stdafx.h @@ -201,7 +201,6 @@ extern bool g_bServiceMode, g_bSendQuit; extern int g_iImportOptions; extern MCONTACT g_hImportContact; -HANDLE GetIconHandle(int iIconId); void RegisterIcons(void); void RegisterMContacts(); diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp index efff680e92..51965cacef 100644 --- a/plugins/Import/src/utils.cpp +++ b/plugins/Import/src/utils.cpp @@ -187,15 +187,6 @@ static IconItem iconList[] = { LPGEN("Import..."), "import_main", IDI_IMPORT } }; -HANDLE GetIconHandle(int iIconId) -{ - for (auto &it : iconList) - if (it.defIconID == iIconId) - return it.hIcolib; - - return nullptr; -} - void RegisterIcons() { g_plugin.registerIcon("Import", iconList); diff --git a/plugins/Import/src/wizard.cpp b/plugins/Import/src/wizard.cpp index 15669a0b35..2767a2ffc2 100644 --- a/plugins/Import/src/wizard.cpp +++ b/plugins/Import/src/wizard.cpp @@ -120,7 +120,7 @@ public: { Utils_RestoreWindowPosition(m_hwnd, 0, IMPORT_MODULE, "wiz"); - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_IMPORT)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_IMPORT)); g_hwndWizard = m_hwnd; if (m_pFirstPage) diff --git a/plugins/KeyboardNotify/src/ignore.cpp b/plugins/KeyboardNotify/src/ignore.cpp index bf8f81bdcf..fd9808108c 100644 --- a/plugins/KeyboardNotify/src/ignore.cpp +++ b/plugins/KeyboardNotify/src/ignore.cpp @@ -195,13 +195,13 @@ INT_PTR CALLBACK DlgProcIgnoreOptions(HWND hwndDlg, UINT msg, WPARAM, LPARAM lPa TranslateDialogDefault(hwndDlg); { HIMAGELIST hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 3+IGNOREEVENT_MAX, 3+IGNOREEVENT_MAX); - ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); - ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_FILLEDBLOB)); - ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_EMPTYBLOB)); - ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_EVENT_MESSAGE)); - ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_EVENT_URL)); - ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_EVENT_FILE)); - ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_MIRANDA)); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_SMALLDOT); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_FILLEDBLOB); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_EMPTYBLOB); + ImageList_AddSkinIcon(hIml, SKINICON_EVENT_MESSAGE); + ImageList_AddSkinIcon(hIml, SKINICON_EVENT_URL); + ImageList_AddSkinIcon(hIml, SKINICON_EVENT_FILE); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_MIRANDA); SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); for (int i=0; i < _countof(hIcons); i++) hIcons[i] = ImageList_GetIcon(hIml, 1+i, ILD_NORMAL); diff --git a/plugins/KeyboardNotify/src/stdafx.h b/plugins/KeyboardNotify/src/stdafx.h index 3b01954284..cce961e02f 100644 --- a/plugins/KeyboardNotify/src/stdafx.h +++ b/plugins/KeyboardNotify/src/stdafx.h @@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include #include #include diff --git a/plugins/MenuItemEx/res/resource.rc b/plugins/MenuItemEx/res/resource.rc index 3ca94c4cd4..d14c78be5d 100644 --- a/plugins/MenuItemEx/res/resource.rc +++ b/plugins/MenuItemEx/res/resource.rc @@ -26,18 +26,18 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -IDI_ICON0 ICON "hide_from_list.ico" -IDI_ICON1 ICON "Always Visible.ico" -IDI_ICON2 ICON "Never Visible.ico" -IDI_ICON3 ICON "copyid_overlay.ico" -IDI_ICON6 ICON "change_proto.ico" -IDI_ICON7 ICON "ignore_list.ico" -IDI_ICON8 ICON "show_in_list.ico" -IDI_ICON9 ICON "msg_status.ico" -IDI_ICON10 ICON "msg_xstatus.ico" -IDI_ICON11 ICON "copyip_overlay.ico" -IDI_ICON12 ICON "recv_files.ico" -IDI_ICON13 ICON "CopyMirVer.ico" +IDI_HIDE ICON "hide_from_list.ico" +IDI_VISIBLE ICON "Always Visible.ico" +IDI_INVISIBLE ICON "Never Visible.ico" +IDI_COPYID ICON "copyid_overlay.ico" +IDI_PROTOCOL ICON "change_proto.ico" +IDI_IGNORE ICON "ignore_list.ico" +IDI_SHOWINLIST ICON "show_in_list.ico" +IDI_COPYSTATUS ICON "msg_status.ico" +IDI_COPYXSTATUS ICON "msg_xstatus.ico" +IDI_COPYIP ICON "copyip_overlay.ico" +IDI_BROWSE ICON "recv_files.ico" +IDI_MIRVER ICON "CopyMirVer.ico" ///////////////////////////////////////////////////////////////////////////// // diff --git a/plugins/MenuItemEx/src/images.cpp b/plugins/MenuItemEx/src/images.cpp index f59b4c2c4e..4d2189a8d9 100644 --- a/plugins/MenuItemEx/src/images.cpp +++ b/plugins/MenuItemEx/src/images.cpp @@ -304,33 +304,30 @@ HICON MakeHalfAlphaIcon(HICON SourceIcon) //} -HICON BindOverlayIcon(HICON SourceIcon, LPCSTR OverlayIconName) +HICON BindOverlayIcon(HICON SourceIcon, int iIcon) { + HICON TempIcon = CopyIcon(SourceIcon); ICONINFO OverlayIconInfo, TargetIconInfo; - BITMAP OverlayBitmapInfo, TargetBitmapInfo; - HBITMAP OldOverlayBitmap, OldTargetBitmap; - HICON OverlayIcon, TargetIcon, TempIcon; - HDC OverlayDC, TargetDC; - BLENDFUNCTION bf = { 0, 0, 255, 1 }; - - TempIcon = CopyIcon(SourceIcon); if (!GetIconInfo(TempIcon, &TargetIconInfo)) return nullptr; MakeBitmap32(&TargetIconInfo.hbmColor); CorrectBitmap32Alpha(TargetIconInfo.hbmColor, FALSE); + + BITMAP OverlayBitmapInfo, TargetBitmapInfo; GetObject(TargetIconInfo.hbmColor, sizeof(BITMAP), &TargetBitmapInfo); - OverlayIcon = IcoLib_GetIcon(OverlayIconName); + HICON OverlayIcon = g_plugin.getIcon(iIcon); if (!GetIconInfo(OverlayIcon, &OverlayIconInfo) || !GetObject(OverlayIconInfo.hbmColor, sizeof(BITMAP), &OverlayBitmapInfo)) return nullptr; - TargetDC = CreateCompatibleDC(nullptr); - OldTargetBitmap = (HBITMAP)SelectObject(TargetDC, TargetIconInfo.hbmColor); + HDC TargetDC = CreateCompatibleDC(nullptr); + HBITMAP OldTargetBitmap = (HBITMAP)SelectObject(TargetDC, TargetIconInfo.hbmColor); - OverlayDC = CreateCompatibleDC(nullptr); - OldOverlayBitmap = (HBITMAP)SelectObject(OverlayDC, OverlayIconInfo.hbmColor); + HDC OverlayDC = CreateCompatibleDC(nullptr); + HBITMAP OldOverlayBitmap = (HBITMAP)SelectObject(OverlayDC, OverlayIconInfo.hbmColor); + BLENDFUNCTION bf = { 0, 0, 255, 1 }; AlphaBlend(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight, OverlayDC, 0, 0, OverlayBitmapInfo.bmWidth, OverlayBitmapInfo.bmHeight, bf); @@ -340,9 +337,8 @@ HICON BindOverlayIcon(HICON SourceIcon, LPCSTR OverlayIconName) BitBlt(TargetDC, 0, 0, TargetBitmapInfo.bmWidth, TargetBitmapInfo.bmHeight, OverlayDC, 0, 0, SRCCOPY); - TargetIcon = CreateIconIndirect(&TargetIconInfo); + HICON TargetIcon = CreateIconIndirect(&TargetIconInfo); DestroyIcon(TempIcon); - //DestroyIcon(OverlayIcon); SelectObject(TargetDC, OldTargetBitmap); DeleteObject(TargetIconInfo.hbmColor); diff --git a/plugins/MenuItemEx/src/images.h b/plugins/MenuItemEx/src/images.h index c935ec8659..5c4cf01060 100644 --- a/plugins/MenuItemEx/src/images.h +++ b/plugins/MenuItemEx/src/images.h @@ -1,8 +1,7 @@ #ifndef __IMAGE_UTILS_H__ #define __IMAGE_UTILS_H__ -HICON BindOverlayIcon(HICON, LPCSTR); -//HICON MakeGrayscaleIcon(HICON); +HICON BindOverlayIcon(HICON, int iIcon); HICON MakeHalfAlphaIcon(HICON); #endif // __IMAGE_UTILS_H__ diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index 48d89f3b61..5a1c87ab99 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -22,13 +22,31 @@ PROTOACCOUNT **accs; int protoCount; CMPlugin g_plugin; -struct { +static IconItem iconList[] = +{ + { LPGEN("Hide from list"), "hidefl", IDI_HIDE }, + { LPGEN("Always visible"), "vis", IDI_VISIBLE }, + { LPGEN("Never visible"), "invis", IDI_INVISIBLE }, + { LPGEN("Copy ID"), "copyid", IDI_COPYID }, + { LPGEN("Copy to Account"), "protocol", IDI_PROTOCOL }, + { LPGEN("Ignore"), "ignore", IDI_IGNORE }, + { LPGEN("Show in list"), "showil", IDI_SHOWINLIST }, + { LPGEN("Copy Status Message"), "copysm1", IDI_COPYSTATUS }, + { LPGEN("Copy xStatus Message"), "copysm2", IDI_COPYXSTATUS }, + { LPGEN("Copy IP"), "copyip", IDI_COPYIP }, + { LPGEN("Browse Received Files"), "recfiles", IDI_BROWSE }, + { LPGEN("Copy MirVer"), "copymver", IDI_MIRVER }, +}; + +struct +{ char *module; char *name; wchar_t *fullName; char flag; } -static const statusMsg[] = { +static const statusMsg[] = +{ { "CList", "StatusMsg", LPGENW("Status message"), 1 }, { nullptr, "XStatusName", LPGENW("xStatus title"), 4 }, { nullptr, "XStatusMsg", LPGENW("xStatus message"), 2 }, @@ -37,25 +55,8 @@ static const statusMsg[] = { { "AdvStatus", "activity/text", LPGENW("Activity text"), 8 } }; -static IconItem iconList[] = { - { LPGEN("Hide from list"), "miex_hidefl", IDI_ICON0 }, - { LPGEN("Show in list"), "miex_showil", IDI_ICON8 }, - { LPGEN("Always visible"), "miex_vis", IDI_ICON1 }, - { LPGEN("Never visible"), "miex_invis", IDI_ICON2 }, - { LPGEN("Copy to Account"), "miex_protocol", IDI_ICON6 }, - { LPGEN("Ignore"), "miex_ignore", IDI_ICON7 }, - { LPGEN("Browse Received Files"), "miex_recfiles", IDI_ICON12 }, - { LPGEN("Copy MirVer"), "miex_copymver", IDI_ICON13 } -}; - -static IconItem overlayIconList[] = { - { LPGEN("Copy ID"), "miex_copyid", IDI_ICON3 }, - { LPGEN("Copy Status Message"), "miex_copysm1", IDI_ICON9 }, - { LPGEN("Copy xStatus Message"), "miex_copysm2", IDI_ICON10 }, - { LPGEN("Copy IP"), "miex_copyip", IDI_ICON11 } -}; - -struct { +struct +{ wchar_t* name; int type; int icon; @@ -86,16 +87,19 @@ PLUGININFOEX pluginInfoEx = { CMPlugin::CMPlugin() : PLUGIN(MODULENAME, pluginInfoEx) -{} +{ +} ///////////////////////////////////////////////////////////////////////////////////////// -struct ModSetLinkLinkItem { // code from dbe++ plugin by Bio +struct ModSetLinkLinkItem +{ // code from dbe++ plugin by Bio char *name; BYTE *next; //struct ModSetLinkLinkItem }; -struct ModuleSettingLL { +struct ModuleSettingLL +{ struct ModSetLinkLinkItem *first; struct ModSetLinkLinkItem *last; }; @@ -108,16 +112,14 @@ static int GetSetting(MCONTACT hContact, const char *szModule, const char *szSet static int enumModulesSettingsProc(const char *szName, void *lParam) { ModuleSettingLL *msll = (ModuleSettingLL *)lParam; - if (!msll->first) - { + if (!msll->first) { msll->first = (struct ModSetLinkLinkItem *)malloc(sizeof(struct ModSetLinkLinkItem)); if (!msll->first) return 1; msll->first->name = _strdup(szName); msll->first->next = nullptr; msll->last = msll->first; } - else - { + else { struct ModSetLinkLinkItem *item = (struct ModSetLinkLinkItem *)malloc(sizeof(struct ModSetLinkLinkItem)); if (!item) return 1; msll->last->next = (BYTE*)item; @@ -130,22 +132,18 @@ static int enumModulesSettingsProc(const char *szName, void *lParam) static void FreeModuleSettingLL(ModuleSettingLL* msll) { - if (msll) - { + if (msll) { struct ModSetLinkLinkItem *item = msll->first; struct ModSetLinkLinkItem *temp; - while (item) - { - if (item->name) - { + while (item) { + if (item->name) { free(item->name); item->name = nullptr; } temp = item; item = (struct ModSetLinkLinkItem *)item->next; - if (temp) - { + if (temp) { free(temp); temp = nullptr; } @@ -410,7 +408,7 @@ static void ModifyCopyID(MCONTACT hContact, BOOL bShowID, BOOL bTrimID) HICON hIconCID = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); { - HICON hIcon = BindOverlayIcon(hIconCID, "miex_copyid"); + HICON hIcon = BindOverlayIcon(hIconCID, IDI_COPYID); DestroyIcon(hIconCID); hIconCID = hIcon; } @@ -444,7 +442,7 @@ static void ModifyStatusMsg(MCONTACT hContact) HICON hIconSMsg = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); { - HICON hIcon = BindOverlayIcon(hIconSMsg, (StatusMsgExists(hContact) & 2) ? "miex_copysm2" : "miex_copysm1"); + HICON hIcon = BindOverlayIcon(hIconSMsg, (StatusMsgExists(hContact) & 2) ? IDI_COPYXSTATUS : IDI_COPYSTATUS); DestroyIcon(hIconSMsg); hIconSMsg = hIcon; } @@ -463,7 +461,7 @@ static void ModifyCopyIP(MCONTACT hContact) HICON hIconCIP = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); { - HICON hIcon = BindOverlayIcon(hIconCIP, "miex_copyip"); + HICON hIcon = BindOverlayIcon(hIconCIP, IDI_COPYIP); DestroyIcon(hIconCIP); hIconCIP = hIcon; } @@ -778,10 +776,8 @@ static int EnumProtoSubmenu(WPARAM, LPARAM) int pos = 1000; if (protoCount) // remove old items { - for (int i = 0; i < protoCount; i++) - { - if (hProtoItem[i]) - { + for (int i = 0; i < protoCount; i++) { + if (hProtoItem[i]) { Menu_RemoveItem(hProtoItem[i]); hProtoItem[i] = nullptr; } @@ -790,8 +786,7 @@ static int EnumProtoSubmenu(WPARAM, LPARAM) Proto_EnumAccounts(&protoCount, &accs); if (protoCount > MAX_PROTOS) protoCount = MAX_PROTOS; - for (int i = 0; i < protoCount; i++) - { + for (int i = 0; i < protoCount; i++) { hProtoItem[i] = AddSubmenuItem(hmenuProto, accs[i]->tszAccountName, Skin_LoadProtoIcon(accs[i]->szModuleName, ID_STATUS_ONLINE), CMIF_SYSTEM | CMIF_KEEPUNTRANSLATED, MS_PROTO, pos++, (INT_PTR)accs[i]->szModuleName); @@ -824,8 +819,7 @@ static int TabsrmmButtonsInit(WPARAM, LPARAM) static void TabsrmmButtonsModify(MCONTACT hContact) { - if (!DirectoryExists(hContact)) - { + if (!DirectoryExists(hContact)) { BBButton bbd = {}; bbd.pszModuleName = MODULENAME; bbd.bbbFlags = BBSF_DISABLED | BBSF_HIDDEN; @@ -873,7 +867,7 @@ static int PluginInit(WPARAM, LPARAM) mi.position++; mi.name.w = LPGENW("Ignore"); mi.pszService = nullptr; - mi.hIcolibItem = IcoLib_GetIcon("miex_ignore"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_IGNORE); hmenuIgnore = Menu_AddContactMenuItem(&mi); hIgnoreItem[0] = AddSubmenuItem(hmenuIgnore, ii[0].name, Skin_LoadIcon(ii[0].icon), 0, MS_IGNORE, pos, ii[0].type); @@ -881,7 +875,7 @@ static int PluginInit(WPARAM, LPARAM) for (int i = 1; i < _countof(ii); i++) hIgnoreItem[i] = AddSubmenuItem(hmenuIgnore, ii[i].name, Skin_LoadIcon(ii[i].icon), 0, MS_IGNORE, pos++, ii[i].type); - AddSubmenuItem(hmenuIgnore, LPGENW("Open ignore settings"), IcoLib_GetIcon("miex_ignore"), 0, MS_OPENIGNORE, pos, 0); + AddSubmenuItem(hmenuIgnore, LPGENW("Open ignore settings"), g_plugin.getIcon(IDI_IGNORE), 0, MS_OPENIGNORE, pos, 0); pos += 100000; // insert separator @@ -889,7 +883,7 @@ static int PluginInit(WPARAM, LPARAM) mi.position++; mi.name.w = LPGENW("Copy to Account"); mi.pszService = MS_PROTO; - mi.hIcolibItem = IcoLib_GetIcon("miex_protocol"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_PROTOCOL); hmenuProto = Menu_AddContactMenuItem(&mi); EnumProtoSubmenu(0, 0); @@ -906,7 +900,7 @@ static int PluginInit(WPARAM, LPARAM) mi.position++; mi.name.w = LPGENW("Browse Received Files"); mi.pszService = MS_RECVFILES; - mi.hIcolibItem = IcoLib_GetIcon("miex_recfiles"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BROWSE); hmenuRecvFiles = Menu_AddContactMenuItem(&mi); SET_UID(mi, 0xf750f36b, 0x284f, 0x4841, 0x83, 0x18, 0xc7, 0x10, 0x4, 0x73, 0xea, 0x22); @@ -928,9 +922,9 @@ static int PluginInit(WPARAM, LPARAM) mi.pszService = MS_COPYMIRVER; hmenuCopyMirVer = Menu_AddContactMenuItem(&mi); - hIcons[0] = IcoLib_GetIcon("miex_copymver"); - hIcons[1] = IcoLib_GetIcon("miex_vis"); - hIcons[2] = IcoLib_GetIcon("miex_invis"); + hIcons[0] = g_plugin.getIcon(IDI_MIRVER); + hIcons[1] = g_plugin.getIcon(IDI_VISIBLE); + hIcons[2] = g_plugin.getIcon(IDI_INVISIBLE); hIcons[3] = MakeHalfAlphaIcon(hIcons[1]); hIcons[4] = MakeHalfAlphaIcon(hIcons[2]); @@ -940,10 +934,11 @@ static int PluginInit(WPARAM, LPARAM) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + int CMPlugin::Load() { - g_plugin.registerIcon(LPGEN("MenuItemEx"), iconList); - g_plugin.registerIcon(LPGEN("MenuItemEx"), overlayIconList); + g_plugin.registerIcon(LPGEN("MenuItemEx"), iconList, "miex"); CreateServiceFunction(MS_SETINVIS, onSetInvis); CreateServiceFunction(MS_SETVIS, onSetVis); diff --git a/plugins/MenuItemEx/src/resource.h b/plugins/MenuItemEx/src/resource.h index 1b51b15fe4..2cc96bb73b 100644 --- a/plugins/MenuItemEx/src/resource.h +++ b/plugins/MenuItemEx/src/resource.h @@ -4,18 +4,18 @@ // #define IDD_OPTIONS 101 #define IDD_AUTHREQ 103 -#define IDI_ICON0 110 -#define IDI_ICON1 111 -#define IDI_ICON2 112 -#define IDI_ICON3 113 -#define IDI_ICON6 116 -#define IDI_ICON7 117 -#define IDI_ICON8 118 -#define IDI_ICON9 119 -#define IDI_ICON10 120 -#define IDI_ICON11 121 -#define IDI_ICON12 122 -#define IDI_ICON13 123 +#define IDI_HIDE 110 +#define IDI_VISIBLE 111 +#define IDI_INVISIBLE 112 +#define IDI_COPYID 113 +#define IDI_PROTOCOL 116 +#define IDI_IGNORE 117 +#define IDI_SHOWINLIST 118 +#define IDI_COPYSTATUS 119 +#define IDI_COPYXSTATUS 120 +#define IDI_COPYIP 121 +#define IDI_BROWSE 122 +#define IDI_MIRVER 123 #define IDC_VIS 1000 #define IDC_REASON 1001 #define IDC_HIDE 1002 diff --git a/plugins/MirLua/src/Modules/m_icolib.cpp b/plugins/MirLua/src/Modules/m_icolib.cpp index 3f94e26894..97fa50ccb3 100644 --- a/plugins/MirLua/src/Modules/m_icolib.cpp +++ b/plugins/MirLua/src/Modules/m_icolib.cpp @@ -57,7 +57,7 @@ static int lua_AddIcon(lua_State *L) sid.description.w = mir_utf8decodeW(luaL_checkstring(L, 2)); sid.section.w = mir_utf8decodeW(luaL_optstring(L, 3, MODULENAME)); sid.defaultFile.w = mir_utf8decodeW(lua_tostring(L, 4)); - sid.hDefaultIcon = GetIcon(IDI_SCRIPT); + sid.hDefaultIcon = g_plugin.getIcon(IDI_SCRIPT); if (sid.defaultFile.w == nullptr) { sid.defaultFile.w = (wchar_t*)mir_calloc(MAX_PATH + 1); @@ -133,7 +133,7 @@ static int lua_RemoveIcon(lua_State *L) static luaL_Reg icolibApi[] = { { "AddIcon", lua_AddIcon }, - { "GetIcon", lua_GetIcon }, + { "g_plugin.getIcon", lua_GetIcon }, { "GetHandle", lua_GetIconHandle }, { "GetIconHandle", lua_GetIconHandle }, { "RemoveIcon", lua_RemoveIcon }, diff --git a/plugins/MirLua/src/icons.cpp b/plugins/MirLua/src/icons.cpp index 52940084f3..74e4d28136 100644 --- a/plugins/MirLua/src/icons.cpp +++ b/plugins/MirLua/src/icons.cpp @@ -14,21 +14,3 @@ void LoadIcons() { g_plugin.registerIcon(MODULENAME, Icons, MODULENAME); } - -HICON GetIcon(int iconId) -{ - for (auto &it : Icons) - if (it.defIconID == iconId) - return IcoLib_GetIconByHandle(it.hIcolib); - - return nullptr; -} - -HANDLE GetIconHandle(int iconId) -{ - for (auto &it : Icons) - if (it.defIconID == iconId) - return it.hIcolib; - - return nullptr; -} \ No newline at end of file diff --git a/plugins/MirLua/src/options.cpp b/plugins/MirLua/src/options.cpp index 83a8b9d7c8..f96a4a15a3 100644 --- a/plugins/MirLua/src/options.cpp +++ b/plugins/MirLua/src/options.cpp @@ -50,11 +50,11 @@ bool CMLuaOptionsMain::OnInitDialog() m_scriptsList.SetExtendedListViewStyle(LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_INFOTIP); HIMAGELIST hImageList = m_scriptsList.CreateImageList(LVSIL_SMALL); - ImageList_AddIcon(hImageList, GetIcon(IDI_LOADED)); - ImageList_AddIcon(hImageList, GetIcon(IDI_FAILED)); - ImageList_AddIcon(hImageList, GetIcon(IDI_OPEN)); - ImageList_AddIcon(hImageList, GetIcon(IDI_RELOAD)); - ImageList_AddIcon(hImageList, GetIcon(IDI_COMPILE)); + ImageList_AddIcon(hImageList, g_plugin.getIcon(IDI_LOADED)); + ImageList_AddIcon(hImageList, g_plugin.getIcon(IDI_FAILED)); + ImageList_AddIcon(hImageList, g_plugin.getIcon(IDI_OPEN)); + ImageList_AddIcon(hImageList, g_plugin.getIcon(IDI_RELOAD)); + ImageList_AddIcon(hImageList, g_plugin.getIcon(IDI_COMPILE)); wchar_t scriptDir[MAX_PATH]; FoldersGetCustomPathT(g_hScriptsFolder, scriptDir, _countof(scriptDir), VARSW(MIRLUA_PATHT)); diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index cd4873de17..9c88b62ad4 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -72,8 +72,6 @@ void LoadNetlib(); void UnloadNetlib(); void LoadIcons(); -HICON GetIcon(int iconId); -HANDLE GetIconHandle(int iconId); /* utils */ diff --git a/plugins/NewXstatusNotify/src/indsnd.cpp b/plugins/NewXstatusNotify/src/indsnd.cpp index fc5b01d5e7..1dbbf99795 100644 --- a/plugins/NewXstatusNotify/src/indsnd.cpp +++ b/plugins/NewXstatusNotify/src/indsnd.cpp @@ -95,7 +95,7 @@ HIMAGELIST GetStatusIconsImgList(char *szProto) if (hList != nullptr) { for (int i = ID_STATUS_MIN; i <= ID_STATUS_MAX; i++) ImageList_AddIcon(hList, Skin_LoadProtoIcon(szProto, i)); - ImageList_AddIcon(hList, Skin_LoadIcon(SKINICON_OTHER_USERONLINE)); + ImageList_AddSkinIcon(hList, SKINICON_OTHER_USERONLINE); } } @@ -439,7 +439,7 @@ INT_PTR CALLBACK DlgProcFiltering(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) ImageList_AddIcon(hImageList, IcoLib_GetIconByHandle(iconList[ICO_ENABLEALL].hIcolib)); SendDlgItemMessage(hwndDlg, IDC_ENABLEALLICON, STM_SETICON, (WPARAM)ImageList_GetIcon(hImageList, EXTRA_IMAGE_ENABLEALL, ILD_NORMAL), 0); - ImageList_AddIcon(hImageList, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); + ImageList_AddSkinIcon(hImageList, SKINICON_OTHER_SMALLDOT); SendDlgItemMessage(hwndDlg, IDC_INDSNDLIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hImageList); SendDlgItemMessage(hwndDlg, IDC_INDSNDLIST, CLM_SETEXTRACOLUMNS, 8, 0); diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp index 08412fae4f..d2a8de5f9e 100644 --- a/plugins/NoHistory/src/dllmain.cpp +++ b/plugins/NoHistory/src/dllmain.cpp @@ -142,9 +142,9 @@ int PrebuildContactMenu(WPARAM hContact, LPARAM) Menu_ShowItem(hMenuToggle, false); else { if (remove) - Menu_ModifyItem(hMenuToggle, LPGENW("Enable History"), hIconKeep); + Menu_ModifyItem(hMenuToggle, LPGENW("Enable History"), g_plugin.getIconHandle(IDI_HKEEP)); else - Menu_ModifyItem(hMenuToggle, LPGENW("Disable History"), hIconRemove); + Menu_ModifyItem(hMenuToggle, LPGENW("Disable History"), g_plugin.getIconHandle(IDI_HREMOVE)); } Menu_ShowItem(hMenuClear, !chat_room && db_event_count(hContact) > 0); @@ -210,12 +210,12 @@ void SrmmMenu_Load() sid.dwId = 0; sid.szTooltip.a = LPGEN("History Enabled"); - sid.hIcon = sid.hIconDisabled = hIconKeep; + sid.hIcon = sid.hIconDisabled = g_plugin.getIcon(IDI_HKEEP); Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 1; sid.szTooltip.a = LPGEN("History Disabled"); - sid.hIcon = sid.hIconDisabled = hIconRemove; + sid.hIcon = sid.hIconDisabled = g_plugin.getIcon(IDI_HREMOVE); Srmm_AddIcon(&sid, &g_plugin); // hook the window events so that we can can change the status of the icon @@ -235,14 +235,14 @@ static int ModulesLoaded(WPARAM, LPARAM) mi.position = -300010; mi.name.w = LPGENW("Disable History"); mi.pszService = MS_NOHISTORY_TOGGLE; - mi.hIcolibItem = hIconRemove; + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HREMOVE); hMenuToggle = Menu_AddContactMenuItem(&mi); SET_UID(mi, 0x1c4b1c21, 0xc0d1, 0x44d1, 0xb5, 0x3c, 0xc7, 0x8d, 0xcf, 0x96, 0x51, 0xd7); mi.position = -300005; mi.name.w = LPGENW("Clear History"); mi.pszService = MS_NOHISTORY_CLEAR; - mi.hIcolibItem = hIconClear; + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HCLEAR); hMenuClear = Menu_AddContactMenuItem(&mi); // add icon to srmm status icons diff --git a/plugins/NoHistory/src/icons.cpp b/plugins/NoHistory/src/icons.cpp index b24cadf3c2..3b8dfbf2b6 100644 --- a/plugins/NoHistory/src/icons.cpp +++ b/plugins/NoHistory/src/icons.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" -HICON hIconRemove, hIconKeep, hIconClear; - static IconItem iconList[] = { { LPGEN("Disable"), "remove", IDI_HREMOVE }, @@ -9,19 +7,7 @@ static IconItem iconList[] = { LPGEN("Clear"), "clear", IDI_HCLEAR }, }; -int ReloadIcons(WPARAM, LPARAM) -{ - hIconRemove = IcoLib_GetIconByHandle(iconList[0].hIcolib); - hIconKeep = IcoLib_GetIconByHandle(iconList[1].hIcolib); - hIconClear = IcoLib_GetIconByHandle(iconList[2].hIcolib); - return 0; -} - void InitIcons() { g_plugin.registerIcon(LPGEN("No History"), iconList, MODULENAME); - - ReloadIcons(0, 0); - - HookEvent(ME_SKIN_ICONSCHANGED, ReloadIcons); } diff --git a/plugins/NoHistory/src/icons.h b/plugins/NoHistory/src/icons.h index cfd2288c52..911549a8cd 100644 --- a/plugins/NoHistory/src/icons.h +++ b/plugins/NoHistory/src/icons.h @@ -1,8 +1,6 @@ #ifndef _ICONS_INC #define _ICONS_INC -extern HICON hIconRemove, hIconKeep, hIconClear; - void InitIcons(); #endif diff --git a/plugins/NoHistory/src/options.cpp b/plugins/NoHistory/src/options.cpp index c7e2a35027..3107787b21 100644 --- a/plugins/NoHistory/src/options.cpp +++ b/plugins/NoHistory/src/options.cpp @@ -102,11 +102,12 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA hwndList = GetDlgItem(hwndDlg, IDC_LIST); { HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2); - ImageList_AddIcon(hIml, hIconKeep); - ImageList_AddIcon(hIml, hIconRemove); + g_plugin.addImgListIcon(hIml, IDI_HKEEP); + g_plugin.addImgListIcon(hIml, IDI_HREMOVE); SendMessage(hwndList, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); - SendDlgItemMessage(hwndDlg, IDC_PIC_KEEP, STM_SETICON, (WPARAM)hIconKeep, 0); - SendDlgItemMessage(hwndDlg, IDC_PIC_REMOVE, STM_SETICON, (WPARAM)hIconRemove, 0); + + SendDlgItemMessage(hwndDlg, IDC_PIC_KEEP, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_HKEEP), 0); + SendDlgItemMessage(hwndDlg, IDC_PIC_REMOVE, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_HREMOVE), 0); } ResetListOptions(hwndList); SendMessage(hwndList, CLM_SETEXTRACOLUMNS, 1, 0); diff --git a/plugins/Popup/src/actions.cpp b/plugins/Popup/src/actions.cpp index 867e4d48bf..8b5d58d027 100644 --- a/plugins/Popup/src/actions.cpp +++ b/plugins/Popup/src/actions.cpp @@ -35,14 +35,14 @@ void LoadActions() { POPUPACTION actions[] = { - { sizeof(POPUPACTION), LoadIconEx(IDI_ACT_REPLY), LPGEN("General") "/" LPGEN("Quick reply"), 0 }, - { sizeof(POPUPACTION), LoadIconEx(IDI_ACT_MESSAGE), LPGEN("General") "/" LPGEN("Send message"), 0 }, - { sizeof(POPUPACTION), LoadIconEx(IDI_ACT_INFO), LPGEN("General") "/" LPGEN("User details"), 0 }, - { sizeof(POPUPACTION), LoadIconEx(IDI_ACT_MENU), LPGEN("General") "/" LPGEN("Contact menu"), 0 }, - { sizeof(POPUPACTION), LoadIconEx(IDI_ACT_ADD), LPGEN("General") "/" LPGEN("Add permanently"), 0 }, - { sizeof(POPUPACTION), LoadIconEx(IDI_ACT_PIN), LPGEN("General") "/" LPGEN("Pin popup"), 0 }, - { sizeof(POPUPACTION), LoadIconEx(IDI_ACT_CLOSE), LPGEN("General") "/" LPGEN("Dismiss popup"), 0 }, - { sizeof(POPUPACTION), LoadIconEx(IDI_ACT_COPY), LPGEN("General") "/" LPGEN("Copy to clipboard"), 0 }, + { sizeof(POPUPACTION), g_plugin.getIcon(IDI_ACT_REPLY), LPGEN("General") "/" LPGEN("Quick reply"), 0 }, + { sizeof(POPUPACTION), g_plugin.getIcon(IDI_ACT_MESSAGE), LPGEN("General") "/" LPGEN("Send message"), 0 }, + { sizeof(POPUPACTION), g_plugin.getIcon(IDI_ACT_INFO), LPGEN("General") "/" LPGEN("User details"), 0 }, + { sizeof(POPUPACTION), g_plugin.getIcon(IDI_ACT_MENU), LPGEN("General") "/" LPGEN("Contact menu"), 0 }, + { sizeof(POPUPACTION), g_plugin.getIcon(IDI_ACT_ADD), LPGEN("General") "/" LPGEN("Add permanently"), 0 }, + { sizeof(POPUPACTION), g_plugin.getIcon(IDI_ACT_PIN), LPGEN("General") "/" LPGEN("Pin popup"), 0 }, + { sizeof(POPUPACTION), g_plugin.getIcon(IDI_ACT_CLOSE), LPGEN("General") "/" LPGEN("Dismiss popup"), 0 }, + { sizeof(POPUPACTION), g_plugin.getIcon(IDI_ACT_COPY), LPGEN("General") "/" LPGEN("Copy to clipboard"), 0 }, }; for (auto &it : actions) @@ -181,7 +181,7 @@ INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM TranslateDialogDefault(hwnd); - SendDlgItemMessage(hwnd, IDC_ICO_INFO, STM_SETICON, (WPARAM)LoadIconEx(IDI_MB_INFO), 0); + SendDlgItemMessage(hwnd, IDC_ICO_INFO, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_MB_INFO), 0); CheckDlgButton(hwnd, IDC_CHK_ENABLEACTIONS, PopupOptions.actions & ACT_ENABLE ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwnd, IDC_CHK_IMCONTACTSONLY, PopupOptions.actions & ACT_DEF_IMONLY ? BST_CHECKED : BST_UNCHECKED); diff --git a/plugins/Popup/src/history.cpp b/plugins/Popup/src/history.cpp index dd9f6afa62..db4f52baa2 100644 --- a/plugins/Popup/src/history.cpp +++ b/plugins/Popup/src/history.cpp @@ -132,7 +132,7 @@ static INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lPara ListBox_SetItemData(hwndList, ListBox_AddString(hwndList, L""), 0); } - Window_SetIcon_IcoLib(hwnd, GetIconHandle(IDI_HISTORY)); + Window_SetIcon_IcoLib(hwnd, g_plugin.getIconHandle(IDI_HISTORY)); if (gbHppInstalled && PopupOptions.UseHppHistoryLog) { logType = LOG_HPP; diff --git a/plugins/Popup/src/icons.cpp b/plugins/Popup/src/icons.cpp index 083593ac11..7e0df28a29 100644 --- a/plugins/Popup/src/icons.cpp +++ b/plugins/Popup/src/icons.cpp @@ -66,41 +66,7 @@ static IconItem iconList3[] = void InitIcons() { - g_plugin.registerIcon(SECT_POPUP, iconList1, MODULENAME); - g_plugin.registerIcon(SECT_POPUP SECT_POPUP_OPT, iconList2, MODULENAME); - g_plugin.registerIcon(SECT_POPUP SECT_POPUP_ACT, iconList3, MODULENAME); -} - -HICON LoadIconEx(int iconId, bool big) -{ - for (auto &it : iconList1) - if (it.defIconID == iconId) - return IcoLib_GetIconByHandle(it.hIcolib, big); - - for (auto &it : iconList2) - if (it.defIconID == iconId) - return IcoLib_GetIconByHandle(it.hIcolib, big); - - for (auto &it : iconList3) - if (it.defIconID == iconId) - return IcoLib_GetIconByHandle(it.hIcolib, big); - - return nullptr; -} - -HANDLE GetIconHandle(int iconId) -{ - for (auto &it : iconList1) - if (it.defIconID == iconId) - return it.hIcolib; - - for (auto &it : iconList2) - if (it.defIconID == iconId) - return it.hIcolib; - - for (auto &it : iconList3) - if (it.defIconID == iconId) - return it.hIcolib; - - return nullptr; + g_plugin.registerIcon(MODULNAME_PLU, iconList1, MODULENAME); + g_plugin.registerIcon(MODULNAME_PLU "/Options", iconList2, MODULENAME); + g_plugin.registerIcon(MODULNAME_PLU "/Actions", iconList3, MODULENAME); } diff --git a/plugins/Popup/src/icons.h b/plugins/Popup/src/icons.h deleted file mode 100644 index ad7ee64153..0000000000 --- a/plugins/Popup/src/icons.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -Popup Plus plugin for Miranda IM - -Copyright © 2002 Luca Santarelli, -© 2004-2007 Victor Pavlychko -© 2010 MPK -© 2010 Merlin_de - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef __icons_h__ -#define __icons_h__ - -//ICONS -#define SECT_POPUP MODULNAME_PLU -#define SECT_POPUP_ACT "/Actions" -#define SECT_POPUP_OPT "/Options" -#define SECT_POPUP_MISC "/Misc" - -void InitIcons(); -HICON LoadIconEx(int iconId, bool big = false); -HANDLE GetIconHandle(int iconid); - -#endif // __icons_h__ diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp index 7dbf9a39fb..05923e9312 100644 --- a/plugins/Popup/src/main.cpp +++ b/plugins/Popup/src/main.cpp @@ -114,7 +114,7 @@ static int IconsChanged(WPARAM, LPARAM) Menu_ModifyItem(hMenuItem, nullptr, hIcon); Menu_ModifyItem(hMenuRoot, nullptr, hIcon); - Menu_ModifyItem(hMenuItemHistory, nullptr, GetIconHandle(IDI_HISTORY)); + Menu_ModifyItem(hMenuItemHistory, nullptr, g_plugin.getIconHandle(IDI_HISTORY)); return 0; } @@ -191,7 +191,7 @@ void InitMenuItems(void) CreateServiceFunction(mi.pszService, svcShowHistory); mi.position = 1000000000; mi.name.w = LPGENW("Popup history"); - mi.hIcolibItem = GetIconHandle(IDI_HISTORY); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HISTORY); hMenuItemHistory = Menu_AddMainMenuItem(&mi); } diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index 48dc3c4f5c..c6a507893a 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -46,7 +46,7 @@ void LoadNotifications() mir_strncpy(notification.lpzGroup, "Misc", sizeof(notification.lpzName)); mir_strncpy(notification.lpzName, "Warning", sizeof(notification.lpzName)); - notification.lchIcoLib = GetIconHandle(IDI_MB_WARN); + notification.lchIcoLib = g_plugin.getIconHandle(IDI_MB_WARN); notification.colorBack = RGB(210, 210, 150); notification.colorText = RGB(0, 0, 0); notification.iSeconds = 10; @@ -54,7 +54,7 @@ void LoadNotifications() mir_strncpy(notification.lpzGroup, "Misc", sizeof(notification.lpzName)); mir_strncpy(notification.lpzName, "Notification", sizeof(notification.lpzName)); - notification.lchIcoLib = GetIconHandle(IDI_MB_INFO); + notification.lchIcoLib = g_plugin.getIconHandle(IDI_MB_INFO); notification.colorBack = RGB(230, 230, 230); notification.colorText = RGB(0, 0, 0); notification.iSeconds = 7; @@ -62,7 +62,7 @@ void LoadNotifications() mir_strncpy(notification.lpzGroup, "Misc", sizeof(notification.lpzName)); mir_strncpy(notification.lpzName, "Error", sizeof(notification.lpzName)); - notification.lchIcoLib = GetIconHandle(IDI_MB_STOP); + notification.lchIcoLib = g_plugin.getIconHandle(IDI_MB_STOP); notification.colorBack = RGB(191, 0, 0); notification.colorText = RGB(255, 245, 225); notification.iSeconds = -1; diff --git a/plugins/Popup/src/opt_adv.cpp b/plugins/Popup/src/opt_adv.cpp index 04dfe50948..a6bb89eacd 100644 --- a/plugins/Popup/src/opt_adv.cpp +++ b/plugins/Popup/src/opt_adv.cpp @@ -112,7 +112,7 @@ INT_PTR CALLBACK DlgProcPopupAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM HWND hCtrl = GetDlgItem(hwnd, IDC_SHOWHISTORY); SendMessage(hCtrl, BUTTONSETASFLATBTN, TRUE, 0); SendMessage(hCtrl, BUTTONADDTOOLTIP, (WPARAM)Translate("Popup history"), 0); - SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(IDI_HISTORY)); + SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_HISTORY)); EnableWindow(GetDlgItem(hwnd, IDC_HISTORY_STATIC1), PopupOptions.EnableHistory); EnableWindow(GetDlgItem(hwnd, IDC_HISTORYSIZE), PopupOptions.EnableHistory); diff --git a/plugins/Popup/src/opt_class.cpp b/plugins/Popup/src/opt_class.cpp index f68cca8e11..d2eb116c6e 100644 --- a/plugins/Popup/src/opt_class.cpp +++ b/plugins/Popup/src/opt_class.cpp @@ -178,7 +178,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l TreeView_DeleteAllItems(hwndTree); // Treeview create image list HIMAGELIST hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR | ILC_COLOR32 | ILC_MASK, 5, num_classes + 1); - ImageList_ReplaceIcon(hImgLst, -1, LoadIconEx(IDI_OPT_GROUP)); + ImageList_ReplaceIcon(hImgLst, -1, g_plugin.getIcon(IDI_OPT_GROUP)); TreeView_SetImageList(hwndTree, hImgLst, TVSIL_NORMAL); for (auto &p : gTreeData) { @@ -218,7 +218,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l (WPARAM)Translate(it.title), 0); } // info icon - SendDlgItemMessage(hwnd, IDC_ICO_INFO, STM_SETICON, (WPARAM)LoadIconEx(IDI_MB_INFO), 0); + SendDlgItemMessage(hwnd, IDC_ICO_INFO, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_MB_INFO), 0); // more button EnableWindow(GetDlgItem(hwnd, IDC_MORE), FALSE); // preview button diff --git a/plugins/Popup/src/opt_contacts.cpp b/plugins/Popup/src/opt_contacts.cpp index af65fe46f5..55b17d1655 100644 --- a/plugins/Popup/src/opt_contacts.cpp +++ b/plugins/Popup/src/opt_contacts.cpp @@ -46,17 +46,17 @@ INT_PTR CALLBACK DlgProcContactOpts(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) case WM_INITDIALOG: TranslateDialogDefault(hwnd); - SendDlgItemMessage(hwnd, IDC_ICO_AUTO, STM_SETICON, (WPARAM)LoadIconEx(IDI_ACT_OK), 0); - SendDlgItemMessage(hwnd, IDC_ICO_FAVORITE, STM_SETICON, (WPARAM)LoadIconEx(IDI_OPT_FAVORITE), 0); - SendDlgItemMessage(hwnd, IDC_ICO_FULLSCREEN, STM_SETICON, (WPARAM)LoadIconEx(IDI_OPT_FULLSCREEN), 0); - SendDlgItemMessage(hwnd, IDC_ICO_BLOCK, STM_SETICON, (WPARAM)LoadIconEx(IDI_OPT_BLOCK), 0); + SendDlgItemMessage(hwnd, IDC_ICO_AUTO, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_ACT_OK), 0); + SendDlgItemMessage(hwnd, IDC_ICO_FAVORITE, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_OPT_FAVORITE), 0); + SendDlgItemMessage(hwnd, IDC_ICO_FULLSCREEN, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_OPT_FULLSCREEN), 0); + SendDlgItemMessage(hwnd, IDC_ICO_BLOCK, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_OPT_BLOCK), 0); { HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 5, 5); - ImageList_AddIcon(hIml, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); - ImageList_AddIcon(hIml, LoadIconEx(IDI_ACT_OK)); - ImageList_AddIcon(hIml, LoadIconEx(IDI_OPT_FAVORITE)); - ImageList_AddIcon(hIml, LoadIconEx(IDI_OPT_FULLSCREEN)); - ImageList_AddIcon(hIml, LoadIconEx(IDI_OPT_BLOCK)); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_SMALLDOT); + g_plugin.addImgListIcon(hIml, IDI_ACT_OK); + g_plugin.addImgListIcon(hIml, IDI_OPT_FAVORITE); + g_plugin.addImgListIcon(hIml, IDI_OPT_FULLSCREEN); + g_plugin.addImgListIcon(hIml, IDI_OPT_BLOCK); SendDlgItemMessage(hwnd, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); SendDlgItemMessage(hwnd, IDC_LIST, CLM_SETEXTRACOLUMNS, 4 /*_countof(sttIcons)*/, 0); sttResetListOptions(GetDlgItem(hwnd, IDC_LIST)); diff --git a/plugins/Popup/src/opt_gen.cpp b/plugins/Popup/src/opt_gen.cpp index ebe0c4d6e0..6503332b2c 100644 --- a/plugins/Popup/src/opt_gen.cpp +++ b/plugins/Popup/src/opt_gen.cpp @@ -181,7 +181,7 @@ INT_PTR CALLBACK DlgProcPopupGeneral(HWND hwnd, UINT msg, WPARAM wParam, LPARAM HWND hCtrl = GetDlgItem(hwnd, IDC_CUSTOMPOS); SendMessage(hCtrl, BUTTONSETASFLATBTN, TRUE, 0); SendMessage(hCtrl, BUTTONADDTOOLTIP, (WPARAM)L"Popup area", BATF_UNICODE); - SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(IDI_RESIZE)); + SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_RESIZE)); } // Spreading combobox { @@ -623,11 +623,11 @@ INT_PTR CALLBACK PositionBoxDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SendDlgItemMessage(hwndDlg, IDOK, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDOK, BUTTONADDTOOLTIP, (WPARAM)L"OK", BATF_UNICODE); - SendDlgItemMessage(hwndDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(IDI_ACT_OK)); + SendDlgItemMessage(hwndDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_ACT_OK)); SendDlgItemMessage(hwndDlg, IDCANCEL, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(hwndDlg, IDCANCEL, BUTTONADDTOOLTIP, (WPARAM)L"Cancel", BATF_UNICODE); - SendDlgItemMessage(hwndDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(IDI_ACT_CLOSE)); + SendDlgItemMessage(hwndDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_ACT_CLOSE)); SetDlgItemInt(hwndDlg, IDC_TXT_TOP, PopupOptions.gapTop, FALSE); SetDlgItemInt(hwndDlg, IDC_TXT_BOTTOM, PopupOptions.gapBottom, FALSE); diff --git a/plugins/Popup/src/opt_skins.cpp b/plugins/Popup/src/opt_skins.cpp index 458cf19f6a..43267d16b4 100644 --- a/plugins/Popup/src/opt_skins.cpp +++ b/plugins/Popup/src/opt_skins.cpp @@ -348,7 +348,7 @@ INT_PTR CALLBACK DlgProcPopSkinsOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR // Skin List reload button SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(IDI_RELOAD)); + SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_RELOAD)); SendDlgItemMessage(hwndDlg, IDC_BTN_RELOAD, BUTTONADDTOOLTIP, (WPARAM)Translate("Refresh List"), 0); // Skin Option List diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index 1f7fa7b44c..16c0c2c5de 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -544,7 +544,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) if (enableDefaultUsr && isIm && IsActionEnabled("General/Quick reply")) { m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); - m_actions[iAction].actionA.lchIcon = LoadIconEx(IDI_ACT_REPLY, iconSize); + m_actions[iAction].actionA.lchIcon = g_plugin.getIcon(IDI_ACT_REPLY, iconSize); mir_strcpy(m_actions[iAction].actionA.lpzTitle, "General/Quick reply"); m_actions[iAction].actionA.wParam = 0; m_actions[iAction].actionA.lParam = ACT_DEF_REPLY; @@ -553,7 +553,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) if (enableDefaultUsr && isIm && IsActionEnabled("General/Send message")) { m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); - m_actions[iAction].actionA.lchIcon = LoadIconEx(IDI_ACT_MESSAGE, iconSize); + m_actions[iAction].actionA.lchIcon = g_plugin.getIcon(IDI_ACT_MESSAGE, iconSize); mir_strcpy(m_actions[iAction].actionA.lpzTitle, "General/Send message"); m_actions[iAction].actionA.wParam = 0; m_actions[iAction].actionA.lParam = ACT_DEF_MESSAGE; @@ -562,7 +562,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) if (enableDefaultUsr && IsActionEnabled("General/User details")) { m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); - m_actions[iAction].actionA.lchIcon = LoadIconEx(IDI_ACT_INFO, iconSize); + m_actions[iAction].actionA.lchIcon = g_plugin.getIcon(IDI_ACT_INFO, iconSize); mir_strcpy(m_actions[iAction].actionA.lpzTitle, "General/User details"); m_actions[iAction].actionA.wParam = 0; m_actions[iAction].actionA.lParam = ACT_DEF_DETAILS; @@ -571,7 +571,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) if (enableDefaultUsr && IsActionEnabled("General/Contact menu")) { m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); - m_actions[iAction].actionA.lchIcon = LoadIconEx(IDI_ACT_MENU, iconSize); + m_actions[iAction].actionA.lchIcon = g_plugin.getIcon(IDI_ACT_MENU, iconSize); mir_strcpy(m_actions[iAction].actionA.lpzTitle, "General/Contact menu"); m_actions[iAction].actionA.wParam = 0; m_actions[iAction].actionA.lParam = ACT_DEF_MENU; @@ -580,7 +580,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) if (enableDefaultUsr && db_get_b(m_hContact, "CList", "NotOnList", 0) && IsActionEnabled("General/Add permanently")) { m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); - m_actions[iAction].actionA.lchIcon = LoadIconEx(IDI_ACT_ADD, iconSize); + m_actions[iAction].actionA.lchIcon = g_plugin.getIcon(IDI_ACT_ADD, iconSize); mir_strcpy(m_actions[iAction].actionA.lpzTitle, "General/Add permanently"); m_actions[iAction].actionA.wParam = 0; m_actions[iAction].actionA.lParam = ACT_DEF_ADD; @@ -589,7 +589,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) if (enableDefaultGen && (m_iTimeout != -1) && IsActionEnabled("General/Pin popup")) { m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); - m_actions[iAction].actionA.lchIcon = m_bIsPinned ? LoadIconEx(IDI_ACT_PINNED, iconSize) : LoadIconEx(IDI_ACT_PIN, iconSize); + m_actions[iAction].actionA.lchIcon = m_bIsPinned ? g_plugin.getIcon(IDI_ACT_PINNED, iconSize) : g_plugin.getIcon(IDI_ACT_PIN, iconSize); mir_strcpy(m_actions[iAction].actionA.lpzTitle, "General/Pin popup"); m_actions[iAction].actionA.wParam = 0; m_actions[iAction].actionA.lParam = ACT_DEF_PIN; @@ -598,7 +598,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) if (enableDefaultGen && IsActionEnabled("General/Dismiss popup")) { m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); - m_actions[iAction].actionA.lchIcon = LoadIconEx(IDI_ACT_CLOSE, iconSize); + m_actions[iAction].actionA.lchIcon = g_plugin.getIcon(IDI_ACT_CLOSE, iconSize); mir_strcpy(m_actions[iAction].actionA.lpzTitle, "General/Dismiss popup"); m_actions[iAction].actionA.wParam = 0; m_actions[iAction].actionA.lParam = ACT_DEF_DISMISS; @@ -607,7 +607,7 @@ int PopupWnd2::fixActions(POPUPACTION *theActions, int count) if (enableDefaultGen && IsActionEnabled("General/Copy to clipboard")) { m_actions[iAction].actionA.cbSize = sizeof(POPUPACTION); - m_actions[iAction].actionA.lchIcon = LoadIconEx(IDI_ACT_COPY, iconSize); + m_actions[iAction].actionA.lchIcon = g_plugin.getIcon(IDI_ACT_COPY, iconSize); mir_strcpy(m_actions[iAction].actionA.lpzTitle, "General/Copy to clipboard"); m_actions[iAction].actionA.wParam = 0; m_actions[iAction].actionA.lParam = ACT_DEF_COPY; @@ -941,7 +941,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara m_bIsPinned = !m_bIsPinned; { bool iconSize = PopupOptions.actions & ACT_LARGE ? TRUE : FALSE; - PUModifyActionIcon(m_hwnd, wParam, lParam, m_bIsPinned ? LoadIconEx(IDI_ACT_PINNED, iconSize) : LoadIconEx(IDI_ACT_PIN, iconSize)); + PUModifyActionIcon(m_hwnd, wParam, lParam, m_bIsPinned ? g_plugin.getIcon(IDI_ACT_PINNED, iconSize) : g_plugin.getIcon(IDI_ACT_PIN, iconSize)); } break; diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index 9a87bbcf81..cafe1a5093 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -237,21 +237,21 @@ INT_PTR Popup_ShowMessageW(WPARAM wParam, LPARAM lParam) ppd2.szText.w = (wchar_t*)wParam; switch (lParam & 0x7fffffff) { case SM_ERROR: - ppd2.lchIcon = LoadIconEx(IDI_MB_STOP, 0); + ppd2.lchIcon = g_plugin.getIcon(IDI_MB_STOP, 0); ppd2.colorBack = RGB(191, 0, 0); ppd2.colorText = RGB(255, 245, 225); ppd2.lchNotification = g_hntfError; ppd2.szTitle.w = TranslateT("Error"); break; case SM_WARNING: - ppd2.lchIcon = LoadIconEx(IDI_MB_WARN, 0); + ppd2.lchIcon = g_plugin.getIcon(IDI_MB_WARN, 0); ppd2.colorBack = RGB(210, 210, 150); ppd2.colorText = RGB(0, 0, 0); ppd2.lchNotification = g_hntfWarning; ppd2.szTitle.w = TranslateT("Warning"); break; case SM_NOTIFY: - ppd2.lchIcon = LoadIconEx(IDI_MB_INFO, 0); + ppd2.lchIcon = g_plugin.getIcon(IDI_MB_INFO, 0); ppd2.colorBack = RGB(230, 230, 230); ppd2.colorText = RGB(0, 0, 0); ppd2.lchNotification = g_hntfNotification; diff --git a/plugins/Popup/src/srmm_menu.cpp b/plugins/Popup/src/srmm_menu.cpp index 885bb4fa38..cf52439b79 100644 --- a/plugins/Popup/src/srmm_menu.cpp +++ b/plugins/Popup/src/srmm_menu.cpp @@ -108,12 +108,12 @@ void SrmmMenu_Load() sid.dwId = 1; sid.szTooltip.a = LPGEN("Popup Mode: Favorite"); - sid.hIcon = sid.hIconDisabled = LoadIconEx(IDI_OPT_FAVORITE); + sid.hIcon = sid.hIconDisabled = g_plugin.getIcon(IDI_OPT_FAVORITE); Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 2; sid.szTooltip.a = LPGEN("Popup Mode: Ignore fullscreen"); - sid.hIcon = sid.hIconDisabled = LoadIconEx(IDI_OPT_FULLSCREEN); + sid.hIcon = sid.hIconDisabled = g_plugin.getIcon(IDI_OPT_FULLSCREEN); Srmm_AddIcon(&sid, &g_plugin); sid.dwId = 3; diff --git a/plugins/Popup/src/stdafx.h b/plugins/Popup/src/stdafx.h index d91eb951ec..f463dd9f86 100644 --- a/plugins/Popup/src/stdafx.h +++ b/plugins/Popup/src/stdafx.h @@ -123,7 +123,6 @@ struct CMPlugin : public PLUGIN #include "services.h" #include "srmm_menu.h" #include "bitmap_funcs.h" -#include "icons.h" #include "font.h" #include "formula.h" #include "skin.h" @@ -141,4 +140,6 @@ struct CMPlugin : public PLUGIN INT_PTR svcEnableDisableMenuCommand(WPARAM, LPARAM); +void InitIcons(); + #endif //HEADERS_H diff --git a/plugins/Scriver/src/chat_main.cpp b/plugins/Scriver/src/chat_main.cpp index 9bd5f5b4f2..6fdf6ac8bc 100644 --- a/plugins/Scriver/src/chat_main.cpp +++ b/plugins/Scriver/src/chat_main.cpp @@ -88,8 +88,7 @@ static MODULEINFO* MM_CreateModule() static void OnCreateModule(MODULEINFO *mi) { HIMAGELIST hList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 0); - - int overlayIcon = ImageList_AddIcon(hList, GetCachedIcon("chat_overlay")); + int overlayIcon = g_plugin.addImgListIcon(hList, IDI_OVERLAY); ImageList_SetOverlayImage(hList, overlayIcon, 1); int index = ImageList_AddIcon(hList, Skin_LoadProtoIcon(mi->pszModule, ID_STATUS_ONLINE)); diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp index d3b8863594..9b31e2e3bc 100644 --- a/plugins/Scriver/src/chat_window.cpp +++ b/plugins/Scriver/src/chat_window.cpp @@ -346,7 +346,7 @@ void CChatRoomDlg::onClick_ShowList(CCtrlButton *pButton) return; m_bNicklistEnabled = !m_bNicklistEnabled; - pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bNicklistEnabled ? "chat_nicklist" : "chat_nicklist2")); + pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(m_bNicklistEnabled ? IDI_NICKLIST : IDI_NICKLIST2)); ScrollToBottom(); Resize(); } @@ -357,7 +357,7 @@ void CChatRoomDlg::onClick_Filter(CCtrlButton *pButton) return; m_bFilterEnabled = !m_bFilterEnabled; - pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bFilterEnabled ? "chat_filter" : "chat_filter2")); + pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(m_bFilterEnabled ? IDI_FILTER : IDI_FILTER2)); if (m_bFilterEnabled && db_get_b(0, CHAT_MODULE, "RightClickFilter", 0) == 0) ShowFilterMenu(); else @@ -450,8 +450,8 @@ void CChatRoomDlg::UpdateNickList() void CChatRoomDlg::UpdateOptions() { - m_btnNickList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bNicklistEnabled ? "chat_nicklist" : "chat_nicklist2")); - m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetCachedIcon(m_bFilterEnabled ? "chat_filter" : "chat_filter2")); + m_btnNickList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(m_bNicklistEnabled ? IDI_NICKLIST : IDI_NICKLIST2)); + m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(m_bFilterEnabled ? IDI_FILTER : IDI_FILTER2)); m_btnBold.Enable(m_si->pMI->bBold); m_btnItalic.Enable(m_si->pMI->bItalics); @@ -523,7 +523,7 @@ void CChatRoomDlg::UpdateTitle() TitleBarData tbd = {}; tbd.hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? m_si->pMI->hOnlineIcon : m_si->pMI->hOfflineIcon; tbd.hIconBig = (m_si->wStatus == ID_STATUS_ONLINE) ? m_si->pMI->hOnlineIconBig : m_si->pMI->hOfflineIconBig; - tbd.hIconNot = (m_si->wState & (GC_EVENT_HIGHLIGHT | STATE_TALK)) ? GetCachedIcon("chat_overlay") : nullptr; + tbd.hIconNot = (m_si->wState & (GC_EVENT_HIGHLIGHT | STATE_TALK)) ? g_plugin.getIcon(IDI_OVERLAY) : nullptr; int nUsers = m_si->getUserList().getCount(); wchar_t szTemp[512]; diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index 6a06f414d7..0e4ba89823 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -25,86 +25,86 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. GlobalMessageData g_dat; -static const char *buttonIcons[] = +static int buttonIcons[] = { - "scriver_CLOSEX", "scriver_QUOTE", "scriver_ADD", nullptr, - "scriver_USERDETAILS", "scriver_HISTORY", "scriver_SEND" + IDI_CLOSEX, IDI_QUOTE, IDI_ADDCONTACT, 0, + IDI_USERDETAILS, IDI_HISTORY, IDI_SEND }; -static const char *chatButtonIcons[] = +static int chatButtonIcons[] = { - "scriver_CLOSEX", "chat_bold", "chat_italics", "chat_underline", - "chat_fgcol", "chat_bkgcol", "chat_history", "chat_filter", - "chat_settings", "chat_nicklist", "scriver_SEND" + IDI_CLOSEX, IDI_BBOLD, IDI_BITALICS, IDI_BUNDERLINE, + IDI_COLOR, IDI_BKGCOLOR, IDI_HISTORY, IDI_FILTER, + IDI_TOPICBUT, IDI_NICKLIST, IDI_SEND }; static IconItem iconList1[] = { - { LPGEN("Add contact"), "scriver_ADD", IDI_ADDCONTACT }, // 1 - { LPGEN("User's details"), "scriver_USERDETAILS", IDI_USERDETAILS }, // 2 - { LPGEN("User's history"), "scriver_HISTORY", IDI_HISTORY }, // 3 - { LPGEN("Send message"), "scriver_SEND", IDI_SEND }, // 4 - { LPGEN("Smiley button"), "scriver_SMILEY", IDI_SMILEY }, // 5 - { LPGEN("User is typing"), "scriver_TYPING", IDI_TYPING }, // 6 - { LPGEN("Typing notification off"), "scriver_TYPINGOFF", IDI_TYPINGOFF }, // 7 - { LPGEN("Sending"), "scriver_DELIVERING", IDI_TIMESTAMP }, // 8 - { LPGEN("Quote button"), "scriver_QUOTE", IDI_QUOTE }, // 9 - { LPGEN("Close button"), "scriver_CLOSEX", IDI_CLOSEX }, // 10 - { LPGEN("Icon overlay"), "scriver_OVERLAY", IDI_OVERLAY }, // 11 - { LPGEN("Incoming message (10x10)"),"scriver_INCOMING", IDI_INCOMING, 10}, // 12 - { LPGEN("Outgoing message (10x10)"),"scriver_OUTGOING", IDI_OUTGOING, 10}, // 13 - { LPGEN("Notice (10x10)"), "scriver_NOTICE", IDI_NOTICE, 10}, // 14 + { LPGEN("Add contact"), "ADD", IDI_ADDCONTACT }, // 1 + { LPGEN("User's details"), "USERDETAILS", IDI_USERDETAILS }, // 2 + { LPGEN("User's history"), "HISTORY", IDI_HISTORY }, // 3 + { LPGEN("Send message"), "SEND", IDI_SEND }, // 4 + { LPGEN("Smiley button"), "SMILEY", IDI_SMILEY }, // 5 + { LPGEN("User is typing"), "TYPING", IDI_TYPING }, // 6 + { LPGEN("Typing notification off"), "TYPINGOFF", IDI_TYPINGOFF }, // 7 + { LPGEN("Sending"), "DELIVERING", IDI_TIMESTAMP }, // 8 + { LPGEN("Quote button"), "QUOTE", IDI_QUOTE }, // 9 + { LPGEN("Close button"), "CLOSEX", IDI_CLOSEX }, // 10 + { LPGEN("Icon overlay"), "OVERLAY", IDI_OVERLAY }, // 11 + { LPGEN("Incoming message (10x10)"),"INCOMING", IDI_INCOMING, 10}, // 12 + { LPGEN("Outgoing message (10x10)"),"OUTGOING", IDI_OUTGOING, 10}, // 13 + { LPGEN("Notice (10x10)"), "NOTICE", IDI_NOTICE, 10}, // 14 }; static IconItem iconList2[] = { - { LPGEN("Window Icon"), "chat_window", IDI_CHANMGR }, // 1 - { LPGEN("Text color"), "chat_fgcol", IDI_COLOR }, // 2 - { LPGEN("Background color") , "chat_bkgcol", IDI_BKGCOLOR }, // 3 - { LPGEN("Bold"), "chat_bold", IDI_BBOLD }, // 4 - { LPGEN("Italics"), "chat_italics", IDI_BITALICS }, // 5 - { LPGEN("Underlined"), "chat_underline", IDI_BUNDERLINE }, // 6 - { LPGEN("Smiley button"), "chat_smiley", IDI_SMILEY }, // 7 - { LPGEN("Room history"), "chat_history", IDI_HISTORY }, // 8 - { LPGEN("Room settings"), "chat_settings", IDI_TOPICBUT }, // 9 - { LPGEN("Event filter disabled"), "chat_filter", IDI_FILTER }, // 10 - { LPGEN("Event filter enabled"), "chat_filter2", IDI_FILTER2 }, // 11 - { LPGEN("Hide nick list"), "chat_nicklist", IDI_NICKLIST }, // 12 - { LPGEN("Show nick list"), "chat_nicklist2", IDI_NICKLIST2 }, // 13 - { LPGEN("Icon overlay"), "chat_overlay", IDI_OVERLAY }, // 14 - { LPGEN("Status 1 (10x10)"), "chat_status0", IDI_STATUS0, 10}, // 15 - { LPGEN("Status 2 (10x10)"), "chat_status1", IDI_STATUS1, 10}, // 16 - { LPGEN("Status 3 (10x10)"), "chat_status2", IDI_STATUS2, 10}, // 17 - { LPGEN("Status 4 (10x10)"), "chat_status3", IDI_STATUS3, 10}, // 18 - { LPGEN("Status 5 (10x10)"), "chat_status4", IDI_STATUS4, 10}, // 19 - { LPGEN("Status 6 (10x10)"), "chat_status5", IDI_STATUS5, 10}, // 20 + { LPGEN("Window Icon"), "window", IDI_CHANMGR }, // 1 + { LPGEN("Text color"), "fgcol", IDI_COLOR }, // 2 + { LPGEN("Background color") , "bkgcol", IDI_BKGCOLOR }, // 3 + { LPGEN("Bold"), "bold", IDI_BBOLD }, // 4 + { LPGEN("Italics"), "italics", IDI_BITALICS }, // 5 + { LPGEN("Underlined"), "underline", IDI_BUNDERLINE }, // 6 + { LPGEN("Smiley button"), "smiley", IDI_SMILEY }, // 7 + { LPGEN("Room history"), "history", IDI_HISTORY }, // 8 + { LPGEN("Room settings"), "settings", IDI_TOPICBUT }, // 9 + { LPGEN("Event filter disabled"), "filter", IDI_FILTER }, // 10 + { LPGEN("Event filter enabled"), "filter2", IDI_FILTER2 }, // 11 + { LPGEN("Hide nick list"), "nicklist", IDI_NICKLIST }, // 12 + { LPGEN("Show nick list"), "nicklist2", IDI_NICKLIST2 }, // 13 + { LPGEN("Icon overlay"), "overlay", IDI_OVERLAY }, // 14 + { LPGEN("Status 1 (10x10)"), "status0", IDI_STATUS0, 10}, // 15 + { LPGEN("Status 2 (10x10)"), "status1", IDI_STATUS1, 10}, // 16 + { LPGEN("Status 3 (10x10)"), "status2", IDI_STATUS2, 10}, // 17 + { LPGEN("Status 4 (10x10)"), "status3", IDI_STATUS3, 10}, // 18 + { LPGEN("Status 5 (10x10)"), "status4", IDI_STATUS4, 10}, // 19 + { LPGEN("Status 6 (10x10)"), "status5", IDI_STATUS5, 10}, // 20 }; static IconItem iconList3[] = { - { LPGEN("Message in (10x10)"), "chat_log_message_in", IDI_INCOMING, 10}, // 1 - { LPGEN("Message out (10x10)"), "chat_log_message_out", IDI_OUTGOING, 10}, // 2 - { LPGEN("Action (10x10)"), "chat_log_action", IDI_ACTION, 10}, // 3 - { LPGEN("Add Status (10x10)"), "chat_log_addstatus", IDI_ADDSTATUS,10}, // 4 - { LPGEN("Remove status (10x10)"), "chat_log_removestatus", IDI_REMSTATUS,10}, // 5 - { LPGEN("Join (10x10)"), "chat_log_join", IDI_JOIN, 10}, // 6 - { LPGEN("Leave (10x10)"), "chat_log_part", IDI_PART, 10}, // 7 - { LPGEN("Quit (10x10)"), "chat_log_quit", IDI_QUIT, 10}, // 8 - { LPGEN("Kick (10x10)"), "chat_log_kick", IDI_KICK, 10}, // 9 - { LPGEN("Nickchange (10x10)"), "chat_log_nick", IDI_NICK, 10}, // 10 - { LPGEN("Notice (10x10)"), "chat_log_notice", IDI_CHAT_NOTICE, 10}, // 11 - { LPGEN("Topic (10x10)"), "chat_log_topic", IDI_TOPIC, 10}, // 12 - { LPGEN("Highlight (10x10)"), "chat_log_highlight", IDI_NOTICE, 10}, // 13 - { LPGEN("Information (10x10)"), "chat_log_info", IDI_INFO, 10}, // 14 + { LPGEN("Message in (10x10)"), "log_message_in", IDI_INCOMING, 10}, // 1 + { LPGEN("Message out (10x10)"), "log_message_out", IDI_OUTGOING, 10}, // 2 + { LPGEN("Action (10x10)"), "log_action", IDI_ACTION, 10}, // 3 + { LPGEN("Add Status (10x10)"), "log_addstatus", IDI_ADDSTATUS,10}, // 4 + { LPGEN("Remove status (10x10)"), "log_removestatus", IDI_REMSTATUS,10}, // 5 + { LPGEN("Join (10x10)"), "log_join", IDI_JOIN, 10}, // 6 + { LPGEN("Leave (10x10)"), "log_part", IDI_PART, 10}, // 7 + { LPGEN("Quit (10x10)"), "log_quit", IDI_QUIT, 10}, // 8 + { LPGEN("Kick (10x10)"), "log_kick", IDI_KICK, 10}, // 9 + { LPGEN("Nickchange (10x10)"), "log_nick", IDI_NICK, 10}, // 10 + { LPGEN("Notice (10x10)"), "log_notice", IDI_CHAT_NOTICE, 10}, // 11 + { LPGEN("Topic (10x10)"), "log_topic", IDI_TOPIC, 10}, // 12 + { LPGEN("Highlight (10x10)"), "log_highlight", IDI_NOTICE, 10}, // 13 + { LPGEN("Information (10x10)"), "log_info", IDI_INFO, 10}, // 14 }; void RegisterIcons(void) { HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged); - g_plugin.registerIcon(LPGEN("Single Messaging"), iconList1); - g_plugin.registerIcon(LPGEN("Group chats"), iconList2); - g_plugin.registerIcon(LPGEN("Single Messaging"), iconList3); + g_plugin.registerIcon(LPGEN("Single Messaging"), iconList1, "scriver"); + g_plugin.registerIcon(LPGEN("Group chats"), iconList2, "chat"); + g_plugin.registerIcon(LPGEN("Single Messaging"), iconList3, "chat"); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -215,23 +215,6 @@ void ReleaseIcons() IcoLib_ReleaseIcon(g_dat.hIconChatBig); } -HICON GetCachedIcon(const char *name) -{ - for (auto &it : iconList1) - if (!mir_strcmp(it.szName, name)) - return IcoLib_GetIconByHandle(it.hIcolib); - - for (auto &it : iconList2) - if (!mir_strcmp(it.szName, name)) - return IcoLib_GetIconByHandle(it.hIcolib); - - for (auto &it : iconList3) - if (!mir_strcmp(it.szName, name)) - return IcoLib_GetIconByHandle(it.hIcolib); - - return nullptr; -} - void LoadGlobalIcons() { g_dat.hMsgIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); @@ -244,18 +227,20 @@ void LoadGlobalIcons() ImageList_RemoveAll(g_dat.hSearchEngineIconList); for (auto &it : buttonIcons) { - if (it == nullptr) + if (it == 0) ImageList_AddIcon_ProtoEx(g_dat.hButtonIconList, nullptr, ID_STATUS_OFFLINE); else - ImageList_AddIcon(g_dat.hButtonIconList, GetCachedIcon(it)); + g_plugin.addImgListIcon(g_dat.hButtonIconList, it); } for (auto &it : chatButtonIcons) - ImageList_AddIcon(g_dat.hChatButtonIconList, GetCachedIcon(it)); + g_plugin.addImgListIcon(g_dat.hChatButtonIconList, it); - ImageList_AddIcon(g_dat.hHelperIconList, GetCachedIcon("scriver_OVERLAY")); - int overlayIcon = ImageList_AddIcon(g_dat.hHelperIconList, GetCachedIcon("scriver_OVERLAY")); + g_plugin.addImgListIcon(g_dat.hHelperIconList, IDI_OVERLAY); + + int overlayIcon = g_plugin.addImgListIcon(g_dat.hHelperIconList, IDI_OVERLAY); ImageList_SetOverlayImage(g_dat.hHelperIconList, overlayIcon, 1); + for (int i = IDI_GOOGLE; i < IDI_LASTICON; i++) { HICON hIcon = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(i), IMAGE_ICON, 0, 0, 0); ImageList_AddIcon(g_dat.hSearchEngineIconList, hIcon); diff --git a/plugins/Scriver/src/globals.h b/plugins/Scriver/src/globals.h index 7bb80122aa..da1b381213 100644 --- a/plugins/Scriver/src/globals.h +++ b/plugins/Scriver/src/globals.h @@ -128,7 +128,6 @@ void ReloadGlobals(); void RegisterIcons(); void ReleaseIcons(); void LoadGlobalIcons(); -HICON GetCachedIcon(const char *name); void RegisterFontServiceFonts(); int ImageList_AddIcon_Ex(HIMAGELIST hIml, int id); diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 91db9a165a..9444c5078b 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -584,7 +584,7 @@ void CSrmmWindow::onChanged_Splitter(CSplitter *pSplitter) HICON CSrmmWindow::GetTabIcon() { if (m_bShowTyping) - return GetCachedIcon("scriver_TYPING"); + return g_plugin.getIcon(IDI_TYPING); if (m_iShowUnread != 0) return m_hStatusIconOverlay; @@ -595,7 +595,7 @@ HICON CSrmmWindow::GetTabIcon() void CSrmmWindow::GetTitlebarIcon(TitleBarData *tbd) { if (m_bShowTyping && (g_dat.flags2 & SMF2_SHOWTYPINGWIN)) - tbd->hIconNot = tbd->hIcon = GetCachedIcon("scriver_TYPING"); + tbd->hIconNot = tbd->hIcon = g_plugin.getIcon(IDI_TYPING); else if (m_iShowUnread && (GetActiveWindow() != m_hwndParent || GetForegroundWindow() != m_hwndParent)) { tbd->hIcon = m_hStatusIcon; tbd->hIconNot = g_dat.hMsgIcon; @@ -747,12 +747,12 @@ void CSrmmWindow::UpdateStatusBar() StatusBarData sbd = { 0 }; sbd.iFlags = SBDF_TEXT | SBDF_ICON; if (m_iMessagesInProgress && (g_dat.flags & SMF_SHOWPROGRESS)) { - sbd.hIcon = GetCachedIcon("scriver_DELIVERING"); + sbd.hIcon = g_plugin.getIcon(IDI_TIMESTAMP); sbd.pszText = szText; mir_snwprintf(szText, TranslateT("Sending in progress: %d message(s) left..."), m_iMessagesInProgress); } else if (m_nTypeSecs) { - sbd.hIcon = GetCachedIcon("scriver_TYPING"); + sbd.hIcon = g_plugin.getIcon(IDI_TYPING); sbd.pszText = szText; mir_snwprintf(szText, TranslateT("%s is typing a message..."), Clist_GetContactDisplayName(m_hContact)); m_nTypeSecs--; diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index bcea9f130e..67de067e91 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -793,17 +793,17 @@ void LoadMsgLogIcons(void) for (int i = 0; i < _countof(pLogIconBmpBits); i++) { switch (i) { case LOGICON_MSG_IN: - ImageList_AddIcon(g_hImageList, GetCachedIcon("scriver_INCOMING")); + g_plugin.addImgListIcon(g_hImageList, IDI_INCOMING); hIcon = ImageList_GetIcon(g_hImageList, LOGICON_MSG_IN, ILD_NORMAL); hBrush = hInBkgBrush; break; case LOGICON_MSG_OUT: - ImageList_AddIcon(g_hImageList, GetCachedIcon("scriver_OUTGOING")); + g_plugin.addImgListIcon(g_hImageList, IDI_OUTGOING); hIcon = ImageList_GetIcon(g_hImageList, LOGICON_MSG_OUT, ILD_NORMAL); hBrush = hOutBkgBrush; break; case LOGICON_MSG_NOTICE: - ImageList_AddIcon(g_hImageList, GetCachedIcon("scriver_NOTICE")); + g_plugin.addImgListIcon(g_hImageList, IDI_NOTICE); hIcon = ImageList_GetIcon(g_hImageList, LOGICON_MSG_NOTICE, ILD_NORMAL); hBrush = hBkgBrush; break; diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 8355dc8868..5b16986d68 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -205,7 +205,7 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam) cle.hContact = hContact; cle.hDbEvent = 1; cle.flags = CLEF_ONLYAFEW | CLEF_UNICODE; - cle.hIcon = GetCachedIcon("scriver_TYPING"); + cle.hIcon = g_plugin.getIcon(IDI_TYPING); cle.pszService = MS_MSG_TYPINGMESSAGE; cle.szTooltip.w = szTip; g_clistApi.pfnAddEvent(&cle); @@ -402,8 +402,8 @@ static void RegisterStatusIcons() StatusIconData sid = {}; sid.szModule = SRMM_MODULE; sid.dwId = 1; - sid.hIcon = GetCachedIcon("scriver_TYPING"); - sid.hIconDisabled = GetCachedIcon("scriver_TYPINGOFF"); + sid.hIcon = g_plugin.getIcon(IDI_TYPING); + sid.hIconDisabled = g_plugin.getIcon(IDI_TYPINGOFF); sid.flags = MBF_HIDDEN; Srmm_AddIcon(&sid, &g_plugin); } diff --git a/plugins/SecureIM/src/loadicons.cpp b/plugins/SecureIM/src/loadicons.cpp index 6ae33f233d..5a1eea67a3 100644 --- a/plugins/SecureIM/src/loadicons.cpp +++ b/plugins/SecureIM/src/loadicons.cpp @@ -42,7 +42,7 @@ static icons[] = { IDI_OV_RSA, TBL_ICO, ICO_OV_RSA, MODULENAME "/" LPGEN("Overlays"), "sim_ov_rsa", LPGEN("RSA/AES mode") }, }; -HINSTANCE LoadIconsPack(const char* szIconsPack) +HINSTANCE LoadIconsPack(const char *szIconsPack) { HINSTANCE hNewIconInst = LoadLibrary(szIconsPack); if (hNewIconInst != nullptr) { diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp index d5ce014c16..0e0b646b29 100644 --- a/plugins/SimpleStatusMsg/src/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp @@ -353,7 +353,7 @@ int LoadAwayMsgModule(void) SET_UID(mi, 0x311124e9, 0xb477, 0x42ef, 0x84, 0xd2, 0xc, 0x6c, 0x50, 0x3f, 0x4a, 0x84); CreateServiceFunction(MS_SIMPLESTATUSMSG_COPYMSG, CopyAwayMsgCommand); mi.position = -2000006000; - mi.hIcolibItem = GetIconHandle(IDI_COPY); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_COPY); mi.name.w = LPGENW("Copy Away message"); mi.pszService = MS_SIMPLESTATUSMSG_COPYMSG; hCopyMsgMenuItem = Menu_AddContactMenuItem(&mi); @@ -361,7 +361,7 @@ int LoadAwayMsgModule(void) SET_UID(mi, 0xe2c75070, 0x455d, 0x455f, 0xbf, 0x53, 0x86, 0x64, 0xbc, 0x14, 0xa1, 0xbe); CreateServiceFunction(MS_SIMPLESTATUSMSG_GOTOURLMSG, GoToURLMsgCommand); mi.position = -2000007000; - mi.hIcolibItem = GetIconHandle(IDI_GOTOURL); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_GOTOURL); mi.name.w = LPGENW("&Go to URL in Away message"); mi.pszService = MS_SIMPLESTATUSMSG_GOTOURLMSG; hGoToURLMenuItem = Menu_AddContactMenuItem(&mi); diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index a72084c738..ff3b8dde0e 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -1221,13 +1221,13 @@ VOID CALLBACK UpdateMsgTimerProc(HWND, UINT, UINT_PTR, DWORD) static int AddTopToolbarButton(WPARAM, LPARAM) { TTBButton tbb = {}; - tbb.hIconHandleUp = tbb.hIconHandleDn = GetIconHandle(IDI_CSMSG); + tbb.hIconHandleUp = tbb.hIconHandleDn = g_plugin.getIconHandle(IDI_CSMSG); tbb.pszService = MS_SIMPLESTATUSMSG_SHOWDIALOGINT; tbb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; tbb.name = tbb.pszTooltipUp = LPGEN("Change status message"); hTTBButton = g_plugin.addTTB(&tbb); - ReleaseIconEx("csmsg"); + g_plugin.releaseIcon(IDI_CSMSG); return 0; } @@ -1270,7 +1270,7 @@ static int ChangeStatusMsgPrebuild(WPARAM, LPARAM) mi.flags = CMIF_UNICODE; if (!g_plugin.getByte("ShowStatusMenuItem", 1)) mi.flags |= CMIF_HIDDEN; - mi.hIcolibItem = GetIconHandle(IDI_CSMSG); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_CSMSG); mi.pszService = MS_SIMPLESTATUSMSG_SHOWDIALOGINT; mi.name.w = LPGENW("Status message..."); mi.position = 2000200000; diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp index 4ae688bf8c..248c97eeb8 100644 --- a/plugins/SimpleStatusMsg/src/msgbox.cpp +++ b/plugins/SimpleStatusMsg/src/msgbox.cpp @@ -943,11 +943,11 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA copy_init_data->m_bOnStartup = init_data->m_bOnStartup; //Load Icons - copy_init_data->icon[I_ICON_DEL] = LoadIconEx("cross"); - copy_init_data->icon[I_ICON_HIST] = LoadIconEx("recent"); - copy_init_data->icon[I_ICON_MSG] = LoadIconEx("predef"); - copy_init_data->icon[I_ICON_ADD] = LoadIconEx("add"); - copy_init_data->icon[I_ICON_CLEAR] = LoadIconEx("clear"); + copy_init_data->icon[I_ICON_DEL] = g_plugin.getIcon(IDI_CROSS); + copy_init_data->icon[I_ICON_HIST] = g_plugin.getIcon(IDI_HISTORY); + copy_init_data->icon[I_ICON_MSG] = g_plugin.getIcon(IDI_MESSAGE); + copy_init_data->icon[I_ICON_ADD] = g_plugin.getIcon(IDI_PLUS); + copy_init_data->icon[I_ICON_CLEAR] = g_plugin.getIcon(IDI_CHIST); if (copy_init_data->m_iDlgFlags & DLG_SHOW_STATUS_ICONS) copy_init_data->status_icons = AddStatusIconsToImageList(init_data->m_szProto, copy_init_data->m_iStatusModes); if (copy_init_data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) @@ -1542,16 +1542,18 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA break; case DM_SIMPAWAY_CHANGEICONS: - ReleaseIconEx("cross"); - ReleaseIconEx("recent"); - ReleaseIconEx("predef"); - ReleaseIconEx("add"); - ReleaseIconEx("clear"); - msgbox_data->icon[I_ICON_DEL] = LoadIconEx("cross"); - msgbox_data->icon[I_ICON_HIST] = LoadIconEx("recent"); - msgbox_data->icon[I_ICON_MSG] = LoadIconEx("predef"); - msgbox_data->icon[I_ICON_ADD] = LoadIconEx("add"); - msgbox_data->icon[I_ICON_CLEAR] = LoadIconEx("clear"); + g_plugin.releaseIcon(IDI_CROSS); + g_plugin.releaseIcon(IDI_HISTORY); + g_plugin.releaseIcon(IDI_MESSAGE); + g_plugin.releaseIcon(IDI_PLUS); + g_plugin.releaseIcon(IDI_CHIST); + + msgbox_data->icon[I_ICON_DEL] = g_plugin.getIcon(IDI_CROSS); + msgbox_data->icon[I_ICON_HIST] = g_plugin.getIcon(IDI_HISTORY); + msgbox_data->icon[I_ICON_MSG] = g_plugin.getIcon(IDI_MESSAGE); + msgbox_data->icon[I_ICON_ADD] = g_plugin.getIcon(IDI_PLUS); + msgbox_data->icon[I_ICON_CLEAR] = g_plugin.getIcon(IDI_CHIST); + if (msgbox_data->m_iDlgFlags & DLG_SHOW_LIST_ICONS) for (int i = 0; i < 5; ++i) ImageList_ReplaceIcon(msgbox_data->other_icons, i, msgbox_data->icon[i]); @@ -1602,11 +1604,11 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA ImageList_Destroy(msgbox_data->status_icons); ImageList_Destroy(msgbox_data->other_icons); - ReleaseIconEx("cross"); - ReleaseIconEx("recent"); - ReleaseIconEx("predef"); - ReleaseIconEx("add"); - ReleaseIconEx("clear"); + g_plugin.releaseIcon(IDI_CROSS); + g_plugin.releaseIcon(IDI_HISTORY); + g_plugin.releaseIcon(IDI_MESSAGE); + g_plugin.releaseIcon(IDI_PLUS); + g_plugin.releaseIcon(IDI_CHIST); Window_FreeIcon_IcoLib(hwndDlg); hwndSAMsgDialog = nullptr; diff --git a/plugins/SimpleStatusMsg/src/simplestatusmsg.h b/plugins/SimpleStatusMsg/src/simplestatusmsg.h index 08b03f1d15..a18012a5fe 100644 --- a/plugins/SimpleStatusMsg/src/simplestatusmsg.h +++ b/plugins/SimpleStatusMsg/src/simplestatusmsg.h @@ -89,11 +89,10 @@ int InitOptions(WPARAM wParam, LPARAM lParam); /* utils.cpp */ void IconsInit(void); -HICON LoadIconEx(const char* name); -HANDLE GetIconHandle(int iconId); -void ReleaseIconEx(const char* name); + HANDLE HookProtoEvent(const char *szModule, const char *szEvent, MIRANDAHOOKPARAM hookProc); void UnhookProtoEvents(void); + int GetRandom(int from, int to); const wchar_t *GetDefaultMessage(int status); const char *StatusModeToDbSetting(int status, const char *suffix); diff --git a/plugins/SimpleStatusMsg/src/utils.cpp b/plugins/SimpleStatusMsg/src/utils.cpp index 00e507f834..a3ba96c977 100644 --- a/plugins/SimpleStatusMsg/src/utils.cpp +++ b/plugins/SimpleStatusMsg/src/utils.cpp @@ -20,8 +20,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "stdafx.h" -static LIST arProtoHooks(5); - static IconItem iconList[] = { { LPGEN("Delete selected"), "cross", IDI_CROSS }, @@ -30,7 +28,7 @@ static IconItem iconList[] = { LPGEN("Add to predefined"), "add", IDI_PLUS }, { LPGEN("Clear history"), "clear", IDI_CHIST }, { LPGEN("Copy Away message"), "copy", IDI_COPY }, - { LPGEN("Change status message"), "csmsg", IDI_CSMSG, }, + { LPGEN("Change status message"), "csmsg", IDI_CSMSG }, { LPGEN("Go to URL in Away message"), "gotourl", IDI_GOTOURL } }; @@ -39,28 +37,9 @@ void IconsInit(void) g_plugin.registerIcon(LPGEN("Simple Status Message"), iconList, MODULENAME); } -HICON LoadIconEx(const char *name) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "SimpleStatusMsg_%s", name); - return IcoLib_GetIcon(szSettingName); -} - -HANDLE GetIconHandle(int iconId) -{ - for (int i = 0; i < _countof(iconList); i++) - if (iconList[i].defIconID == iconId) - return iconList[i].hIcolib; - - return nullptr; -} +///////////////////////////////////////////////////////////////////////////////////////// -void ReleaseIconEx(const char *name) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "SimpleStatusMsg_%s", name); - IcoLib_Release(szSettingName); -} +static LIST arProtoHooks(5); HANDLE HookProtoEvent(const char *szModule, const char *szEvent, MIRANDAHOOKPARAM hookProc) { @@ -78,7 +57,9 @@ void UnhookProtoEvents(void) arProtoHooks.destroy(); } +///////////////////////////////////////////////////////////////////////////////////////// // Generate random number in a specified range + int GetRandom(int from, int to) { if ((to - from) < 1) @@ -88,7 +69,9 @@ int GetRandom(int from, int to) return ((randnum % (to - from + 1)) + from); } +///////////////////////////////////////////////////////////////////////////////////////// // From SRAway module + const wchar_t *GetDefaultMessage(int status) { switch (status) { diff --git a/plugins/StartupSilence/src/main.cpp b/plugins/StartupSilence/src/main.cpp index e2f8ab22be..5a2241f494 100644 --- a/plugins/StartupSilence/src/main.cpp +++ b/plugins/StartupSilence/src/main.cpp @@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CMPlugin g_plugin; HGENMENU hSSMenuToggleOnOff; -HANDLE GetIconHandle(char *szIcon); HANDLE hOptionsInitialize; HANDLE hTTBarloaded = nullptr; HANDLE Buttons = nullptr; @@ -93,7 +92,7 @@ static void __cdecl AdvSt(void*) if (PopUp == 1) { lpwzText = NonStatusAllow == 1 ? ALL_DISABLED_FLT : ALL_DISABLED; - ppd.lchIcon = IcoLib_GetIconByHandle((NonStatusAllow == 1) ? GetIconHandle(ALL_ENABLED_FLT) : GetIconHandle(MENU_NAME)); + ppd.lchIcon = IcoLib_GetIconByHandle((NonStatusAllow == 1) ? g_plugin.getIconHandle(IDI_SSFILTEREDON) : g_plugin.getIconHandle(IDI_SSICON)); ppd.lchContact = NULL; ppd.iSeconds = PopUpTime; wcsncpy_s(ppd.lpwzText, lpwzText, _TRUNCATE); @@ -108,7 +107,7 @@ static void __cdecl AdvSt(void*) if (PopUp == 1) { lpwzText = (DefEnabled == 1 && DefPopup == 1) ? TranslateT(ALL_ENABLED_FLT) : ALL_ENABLED; - ppd.lchIcon = IcoLib_GetIconByHandle((DefEnabled == 1 && DefPopup == 1) ? GetIconHandle(ALL_ENABLED_FLT) : GetIconHandle(MENU_NAME)); + ppd.lchIcon = IcoLib_GetIconByHandle((DefEnabled == 1 && DefPopup == 1) ? g_plugin.getIconHandle(IDI_SSFILTEREDON) : g_plugin.getIconHandle(IDI_SSICON)); wcsncpy_s(ppd.lpwzText, lpwzText, _TRUNCATE); PUAddPopupW(&ppd); } @@ -213,7 +212,7 @@ static INT_PTR StartupSilenceEnabled(WPARAM, LPARAM) if (PopUp == 1) { wchar_t * lpwzText = Enabled == 1 ? S_MODE_CHANGEDON : S_MODE_CHANGEDOFF; POPUPDATAW ppd; - ppd.lchIcon = IcoLib_GetIconByHandle((Enabled == 1) ? GetIconHandle(ENABLE_SILENCE) : GetIconHandle(DISABLE_SILENCE)); + ppd.lchIcon = IcoLib_GetIconByHandle((Enabled == 1) ? g_plugin.getIconHandle(IDI_SSENABLE) : g_plugin.getIconHandle(IDI_SSDISABLE)); ppd.lchContact = NULL; ppd.iSeconds = PopUpTime; wcsncpy_s(ppd.lpwzText, lpwzText, _TRUNCATE); @@ -237,7 +236,7 @@ static INT_PTR InitMenu() CMenuItem mi(&g_plugin); SET_UID(mi, 0x9100c881, 0x6f76, 0x4cb5, 0x97, 0x66, 0xeb, 0xf5, 0xc5, 0x22, 0x46, 0x1f); mi.position = 100000000; - mi.hIcolibItem = GetIconHandle(MENU_NAME); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_SSICON); mi.name.a = MENU_NAME; mi.pszService = SS_SERVICE_NAME; hSSMenuToggleOnOff = Menu_AddMainMenuItem(&mi); @@ -248,9 +247,9 @@ static INT_PTR InitMenu() void UpdateMenu() { if (Enabled == 1) - Menu_ModifyItem(hSSMenuToggleOnOff, _A2W(DISABLE_SILENCE), GetIconHandle(DISABLE_SILENCE)); + Menu_ModifyItem(hSSMenuToggleOnOff, _A2W(DISABLE_SILENCE), g_plugin.getIconHandle(IDI_SSDISABLE)); else - Menu_ModifyItem(hSSMenuToggleOnOff, _A2W(ENABLE_SILENCE), GetIconHandle(ENABLE_SILENCE)); + Menu_ModifyItem(hSSMenuToggleOnOff, _A2W(ENABLE_SILENCE), g_plugin.getIconHandle(IDI_SSENABLE)); UpdateTTB(); } @@ -266,8 +265,8 @@ static int CreateTTButtons(WPARAM, LPARAM) TTBButton ttb = {}; ttb.dwFlags = (Enabled == 1 ? 0 : TTBBF_PUSHED) | TTBBF_VISIBLE | TTBBF_ASPUSHBUTTON; ttb.pszService = SS_SERVICE_NAME; - ttb.hIconHandleDn = GetIconHandle(DISABLE_SILENCETTB); - ttb.hIconHandleUp = GetIconHandle(ENABLE_SILENCETTB); + ttb.hIconHandleDn = g_plugin.getIconHandle(IDI_SSDISABLETTB); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_SSENABLETTB); ttb.name = TTBNAME; ttb.pszTooltipUp = SS_IS_ON; ttb.pszTooltipDn = SS_IS_OFF; @@ -284,13 +283,6 @@ void RemoveTTButtons() ttbButtons.destroy(); } -HANDLE GetIconHandle(char *szIcon) -{ - char szSettingName[64]; - mir_snprintf(szSettingName, "%s_%s", MENU_NAME, szIcon); - return IcoLib_GetIconHandle(szSettingName); -} - static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { diff --git a/plugins/StartupSilence/src/stdafx.h b/plugins/StartupSilence/src/stdafx.h index 0eff5b5fce..97a37291c3 100644 --- a/plugins/StartupSilence/src/stdafx.h +++ b/plugins/StartupSilence/src/stdafx.h @@ -67,11 +67,12 @@ struct CMPlugin : public PLUGIN #define NEEDTTBMOD TranslateT("You have to install TopToolBar plugin to use this option.") #define NEEDPOPUP TranslateT("You have to install popup plugin to use this option.") -static IconItem iconList[] = { - { MENU_NAME, MENU_NAME, IDI_SSICON}, - { ALL_ENABLED_FLT, ALL_ENABLED_FLT, IDI_SSFILTEREDON}, - { DISABLE_SILENCE, DISABLE_SILENCE, IDI_SSDISABLE}, - { ENABLE_SILENCE, ENABLE_SILENCE, IDI_SSENABLE} +static IconItem iconList[] = +{ + { MENU_NAME, MENU_NAME, IDI_SSICON }, + { ALL_ENABLED_FLT, ALL_ENABLED_FLT, IDI_SSFILTEREDON }, + { DISABLE_SILENCE, DISABLE_SILENCE, IDI_SSDISABLE }, + { ENABLE_SILENCE, ENABLE_SILENCE, IDI_SSENABLE } }; static IconItem iconttbList[] = { diff --git a/plugins/UserInfoEx/src/classMAnnivDate.cpp b/plugins/UserInfoEx/src/classMAnnivDate.cpp index 69d0aad715..fc32530755 100644 --- a/plugins/UserInfoEx/src/classMAnnivDate.cpp +++ b/plugins/UserInfoEx/src/classMAnnivDate.cpp @@ -215,23 +215,23 @@ struct WORD startDays; WORD endDays; LPCTSTR szZodiac; - LPCSTR szZodiacIcon; + int szZodiacIcon; } static zodiac[] = { - { 80, 110, LPGENW("Aries"), ICO_ZOD_ARIES }, // Widder - { 111, 140, LPGENW("Taurus"), ICO_ZOD_TAURUS }, // Stier - { 141, 172, LPGENW("Gemini"), ICO_ZOD_GEMINI }, // Zwillinge - { 173, 203, LPGENW("Cancer"), ICO_ZOD_CANCER }, // Krebs - { 204, 235, LPGENW("Leo"), ICO_ZOD_LEO }, // Löwe - { 236, 266, LPGENW("Virgo"), ICO_ZOD_VIRGO }, // Jungfrau - { 267, 296, LPGENW("Libra"), ICO_ZOD_LIBRA }, // Waage - { 297, 326, LPGENW("Scorpio"), ICO_ZOD_SCORPIO }, // Scorpion - { 327, 355, LPGENW("Sagittarius"), ICO_ZOD_SAGITTARIUS }, // Schütze - { 356, 364, LPGENW("Capricorn"), ICO_ZOD_CAPRICORN }, // Steinbock - { 1, 19, LPGENW("Capricorn"), ICO_ZOD_CAPRICORN }, // Steinbock - { 20, 49, LPGENW("Aquarius"), ICO_ZOD_AQUARIUS }, // Wassermann - { 50, 79, LPGENW("Pisces"), ICO_ZOD_PISCES }, // Fische - { 0, 0, nullptr, "" } // end of array + { 80, 110, LPGENW("Aries"), IDI_ZOD_ARIES }, // Widder + { 111, 140, LPGENW("Taurus"), IDI_ZOD_TAURUS }, // Stier + { 141, 172, LPGENW("Gemini"), IDI_ZOD_GEMINI }, // Zwillinge + { 173, 203, LPGENW("Cancer"), IDI_ZOD_CANCER }, // Krebs + { 204, 235, LPGENW("Leo"), IDI_ZOD_LEO }, // Löwe + { 236, 266, LPGENW("Virgo"), IDI_ZOD_VIRGO }, // Jungfrau + { 267, 296, LPGENW("Libra"), IDI_ZOD_LIBRA }, // Waage + { 297, 326, LPGENW("Scorpio"), IDI_ZOD_SCORPIO }, // Scorpion + { 327, 355, LPGENW("Sagittarius"), IDI_ZOD_SAGITTARIUS }, // Schütze + { 356, 364, LPGENW("Capricorn"), IDI_ZOD_CAPRICORN }, // Steinbock + { 1, 19, LPGENW("Capricorn"), IDI_ZOD_CAPRICORN }, // Steinbock + { 20, 49, LPGENW("Aquarius"), IDI_ZOD_AQUARIUS }, // Wassermann + { 50, 79, LPGENW("Pisces"), IDI_ZOD_PISCES }, // Fische + { 0, 0, nullptr, 0 } // end of array }; MZodiac MAnnivDate::Zodiac() @@ -242,7 +242,7 @@ MZodiac MAnnivDate::Zodiac() for (i = 0; i < 13 && (wDays < zodiac[i].startDays || wDays > zodiac[i].endDays); i++); MZodiac mZodiac; - mZodiac.hIcon = IcoLib_GetIcon(zodiac[i].szZodiacIcon); + mZodiac.hIcon = g_plugin.getIcon(zodiac[i].szZodiacIcon); mZodiac.pszName = zodiac[i].szZodiac; return mZodiac; } @@ -692,7 +692,7 @@ static WORD AskUser(MCONTACT hContact, MAnnivDate *pOldCustomDate, MAnnivDate *p MB.cbSize = sizeof(MSGBOX); MB.hParent = nullptr; - MB.hiLogo = IcoLib_GetIcon(ICO_DLG_ANNIVERSARY); + MB.hiLogo = g_plugin.getIcon(IDI_ANNIVERSARY); MB.hiMsg = nullptr; MB.uType = MB_YESALLNO|MB_ICON_QUESTION|MB_INFOBAR|MB_NOPOPUP; MB.ptszTitle = LPGENW("Update custom birthday"); diff --git a/plugins/UserInfoEx/src/ctrl_button.cpp b/plugins/UserInfoEx/src/ctrl_button.cpp index 6f88bd700b..07ba971802 100644 --- a/plugins/UserInfoEx/src/ctrl_button.cpp +++ b/plugins/UserInfoEx/src/ctrl_button.cpp @@ -371,7 +371,7 @@ static LRESULT CALLBACK Button_WndProc(HWND hwndBtn, UINT uMsg, WPARAM wParam, L bct->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); bct->dwStyle = cs->style; if (cs->style & MBS_DOWNARROW) - bct->arrow = IcoLib_GetIcon(ICO_BTN_DOWNARROW); + bct->arrow = g_plugin.getIcon(IDI_BTN_DOWNARROW); LoadTheme(bct); SetWindowLongPtr(hwndBtn, 0, (LONG_PTR)bct); if (cs->lpszName) SetWindowText(hwndBtn, cs->lpszName); diff --git a/plugins/UserInfoEx/src/ctrl_contact.cpp b/plugins/UserInfoEx/src/ctrl_contact.cpp index d8084daaed..95abf7ae15 100644 --- a/plugins/UserInfoEx/src/ctrl_contact.cpp +++ b/plugins/UserInfoEx/src/ctrl_contact.cpp @@ -37,11 +37,11 @@ typedef struct TCbExItem DWORD dwID; wchar_t szCat[MAX_CAT]; LPTSTR pszVal; - LPCSTR pszIcon; + int iIcon; HICON hIcon; } CBEXITEMINTERN, *LPCBEXITEMINTERN; -typedef struct TComboEx +typedef struct TComboEx { LPCBEXITEMINTERN pItems; int numItems; @@ -72,12 +72,12 @@ static int CheckPhoneSyntax(LPTSTR pszSrc, LPTSTR szNumber, WORD cchNumber, int& { int lenNum = 0; BYTE hasLeftBreaket = FALSE, - hasRightBreaket = FALSE; + hasRightBreaket = FALSE; if (!szNumber || !pszSrc || !*pszSrc || !cchNumber) return 0; *szNumber = 0; errorPos = -1; - + if (*pszSrc != '+') { errorPos = 2; // set cursor after first digit *(szNumber + lenNum++) = '+'; @@ -87,47 +87,47 @@ static int CheckPhoneSyntax(LPTSTR pszSrc, LPTSTR szNumber, WORD cchNumber, int& for (; lenNum < cchNumber - 1 && *pszSrc != 0; pszSrc++) { switch (*pszSrc) { - case '(': - if (hasLeftBreaket) { - if (errorPos == -1) errorPos = lenNum; - break; - } - if (*(szNumber + lenNum - 1) != ' ') { - *(szNumber + lenNum++) = ' '; - if (errorPos == -1) errorPos = lenNum + 1; - } - *(szNumber + lenNum++) = *pszSrc; - hasLeftBreaket = TRUE; + case '(': + if (hasLeftBreaket) { + if (errorPos == -1) errorPos = lenNum; break; + } + if (*(szNumber + lenNum - 1) != ' ') { + *(szNumber + lenNum++) = ' '; + if (errorPos == -1) errorPos = lenNum + 1; + } + *(szNumber + lenNum++) = *pszSrc; + hasLeftBreaket = TRUE; + break; - case ')': - if (hasRightBreaket) { - if (errorPos == -1) errorPos = lenNum; - break; - } - *(szNumber + lenNum++) = *pszSrc; - if (*(pszSrc + 1) != ' ') { - *(szNumber + lenNum++) = ' '; - if (errorPos == -1) errorPos = lenNum; - } - hasRightBreaket = TRUE; + case ')': + if (hasRightBreaket) { + if (errorPos == -1) errorPos = lenNum; break; + } + *(szNumber + lenNum++) = *pszSrc; + if (*(pszSrc + 1) != ' ') { + *(szNumber + lenNum++) = ' '; + if (errorPos == -1) errorPos = lenNum; + } + hasRightBreaket = TRUE; + break; - case ' ': - if (*(szNumber + lenNum - 1) != ' ') { - *(szNumber + lenNum++) = *pszSrc; - } - else - if (errorPos == -1) errorPos = lenNum; - break; + case ' ': + if (*(szNumber + lenNum - 1) != ' ') { + *(szNumber + lenNum++) = *pszSrc; + } + else + if (errorPos == -1) errorPos = lenNum; + break; - default: - if (*pszSrc >= '0' && *pszSrc <= '9' || *pszSrc == '-') { - *(szNumber + lenNum++) = *pszSrc; - } - // remember first error position - else if (errorPos == -1) errorPos = lenNum; - break; + default: + if (*pszSrc >= '0' && *pszSrc <= '9' || *pszSrc == '-') { + *(szNumber + lenNum++) = *pszSrc; + } + // remember first error position + else if (errorPos == -1) errorPos = lenNum; + break; } } *(szNumber + lenNum) = 0; @@ -142,19 +142,19 @@ static int CheckPhoneSyntax(LPTSTR pszSrc, LPTSTR szNumber, WORD cchNumber, int& **/ static INT_PTR CALLBACK DlgProc_EMail(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - LPCBEXITEM cbi = (LPCBEXITEM)GetUserData(hDlg); + CBEXITEM *cbi = (CBEXITEM*)GetUserData(hDlg); switch (msg) { case WM_INITDIALOG: - cbi = (LPCBEXITEM)lParam; + cbi = (CBEXITEM*)lParam; if (!cbi) return FALSE; SetUserData(hDlg, lParam); - SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)IcoLib_GetIcon(ICO_DLG_EMAIL, TRUE)); + SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)g_plugin.getIcon(IDI_DLG_EMAIL, true)); if (g_plugin.getByte(SET_ICONS_BUTTONS, 1)) { - SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_OK)); - SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_CANCEL)); + SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_OK)); + SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_CLOSE)); } if (*cbi->pszVal) @@ -186,7 +186,8 @@ static INT_PTR CALLBACK DlgProc_EMail(HWND hDlg, UINT msg, WPARAM wParam, LPARAM case WM_COMMAND: switch (LOWORD(wParam)) { - case IDOK: { + case IDOK: + { if (HIWORD(wParam) == BN_CLICKED) { if (cbi->pszVal && cbi->ccVal > 0) GetDlgItemText(hDlg, EDIT_EMAIL, cbi->pszVal, cbi->ccVal); @@ -195,26 +196,27 @@ static INT_PTR CALLBACK DlgProc_EMail(HWND hDlg, UINT msg, WPARAM wParam, LPARAM } break; } - case IDCANCEL: { - if (HIWORD(wParam) == BN_CLICKED) + case IDCANCEL: + { + if (HIWORD(wParam) == BN_CLICKED) EndDialog(hDlg, LOWORD(wParam)); break; } - case EDIT_EMAIL: - if (HIWORD(wParam) == EN_UPDATE) { - wchar_t szText[MAXDATASIZE]; - LPTSTR pszAdd, pszDot; - if (PtrIsValid(cbi)) { - GetWindowText((HWND)lParam, szText, _countof(szText)); - EnableWindow(GetDlgItem(hDlg, IDOK), - ((pszAdd = wcschr(szText, '@')) && + case EDIT_EMAIL: + if (HIWORD(wParam) == EN_UPDATE) { + wchar_t szText[MAXDATASIZE]; + LPTSTR pszAdd, pszDot; + if (PtrIsValid(cbi)) { + GetWindowText((HWND)lParam, szText, _countof(szText)); + EnableWindow(GetDlgItem(hDlg, IDOK), + ((pszAdd = wcschr(szText, '@')) && *(pszAdd + 1) != '.' && (pszDot = wcschr(pszAdd, '.')) && *(pszDot + 1) && mir_wstrcmp(szText, cbi->pszVal))); - } } - break; + } + break; } break; } @@ -229,7 +231,7 @@ static INT_PTR CALLBACK DlgProc_EMail(HWND hDlg, UINT msg, WPARAM wParam, LPARAM **/ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - LPCBEXITEM cbi = (LPCBEXITEM)GetUserData(hDlg); + CBEXITEM *cbi = (CBEXITEM*)GetUserData(hDlg); static int noRecursion = 0; switch (msg) { @@ -239,14 +241,14 @@ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam LPIDSTRLIST pCountries; HWND hCombo = GetDlgItem(hDlg, EDIT_COUNTRY); - cbi = (LPCBEXITEM)lParam; + cbi = (CBEXITEM*)lParam; if (!cbi) return FALSE; SetUserData(hDlg, lParam); - SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)IcoLib_GetIcon(ICO_DLG_PHONE, TRUE)); + SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)g_plugin.getIcon(IDI_DLG_PHONE, TRUE)); if (g_plugin.getByte(SET_ICONS_BUTTONS, 1)) { - SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_OK)); - SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_CANCEL)); + SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_OK)); + SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_CLOSE)); } // translate Userinfo buttons @@ -290,28 +292,28 @@ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam case WM_COMMAND: switch (LOWORD(wParam)) { - case IDOK: - if (HIWORD(wParam) == BN_CLICKED) { - wchar_t szText[MAXDATASIZE]; - int errorPos; - - if (!GetDlgItemText(hDlg, EDIT_PHONE, szText, _countof(szText)) || !CheckPhoneSyntax(szText, cbi->pszVal, cbi->ccVal, errorPos) || errorPos > -1) { - MsgErr(hDlg, TranslateT("The phone number should start with a + and consist of\nnumbers, spaces, brackets and hyphens only.")); - break; - } - // save category string - GetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat, cbi->ccCat); + case IDOK: + if (HIWORD(wParam) == BN_CLICKED) { + wchar_t szText[MAXDATASIZE]; + int errorPos; - // save SMS flag - if ((int)IsDlgButtonChecked(hDlg, CHECK_SMS) != ((cbi->wFlags & CBEXIF_SMS) == CBEXIF_SMS)) - cbi->wFlags ^= CBEXIF_SMS; + if (!GetDlgItemText(hDlg, EDIT_PHONE, szText, _countof(szText)) || !CheckPhoneSyntax(szText, cbi->pszVal, cbi->ccVal, errorPos) || errorPos > -1) { + MsgErr(hDlg, TranslateT("The phone number should start with a + and consist of\nnumbers, spaces, brackets and hyphens only.")); + break; } - __fallthrough; + // save category string + GetDlgItemText(hDlg, EDIT_CATEGORY, cbi->pszCat, cbi->ccCat); - case IDCANCEL: - if (HIWORD(wParam) == BN_CLICKED) - EndDialog(hDlg, wParam); - break; + // save SMS flag + if ((int)IsDlgButtonChecked(hDlg, CHECK_SMS) != ((cbi->wFlags & CBEXIF_SMS) == CBEXIF_SMS)) + cbi->wFlags ^= CBEXIF_SMS; + } + __fallthrough; + + case IDCANCEL: + if (HIWORD(wParam) == BN_CLICKED) + EndDialog(hDlg, wParam); + break; case EDIT_COUNTRY: if (HIWORD(wParam) != CBN_SELCHANGE) @@ -396,156 +398,156 @@ INT_PTR CALLBACK DlgProc_Phone(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam * lParam - message specific * return: message specific **/ -static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { LPCBEX cbex = (LPCBEX)GetWindowLongPtr(hwnd, 0); switch (msg) { - /** - * name: WM_NCCREATE - * desc: is called to initiate the window creation - * param: wParam - not used - * lParam - pointer to a CREATESTRUCT - * - * return: FALSE on error, TRUE if initialisation was ok - **/ - case WM_NCCREATE: - { - LPCREATESTRUCT cs = (LPCREATESTRUCT)lParam; - - if (!(cbex = (LPCBEX)mir_calloc(1*sizeof(CBEX)))) - return FALSE; - SetWindowLongPtr(hwnd, 0, (LONG_PTR)cbex); - cbex->bLocked = 1; - cbex->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); - cbex->hInstance = cs->hInstance; - cbex->iSelectedItem = -1; - cbex->rect.left = cs->x; - cbex->rect.top = cs->y; - cbex->rect.right = cs->x + cs->cx; - cbex->rect.bottom = cs->y + cs->cy; - return TRUE; - } - - /** + /** * name: WM_NCCREATE - * desc: is called to create all subitems + * desc: is called to initiate the window creation * param: wParam - not used - * lParam - not used + * lParam - pointer to a CREATESTRUCT * * return: FALSE on error, TRUE if initialisation was ok **/ + case WM_NCCREATE: + { + LPCREATESTRUCT cs = (LPCREATESTRUCT)lParam; + + if (!(cbex = (LPCBEX)mir_calloc(1 * sizeof(CBEX)))) + return FALSE; + SetWindowLongPtr(hwnd, 0, (LONG_PTR)cbex); + cbex->bLocked = 1; + cbex->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + cbex->hInstance = cs->hInstance; + cbex->iSelectedItem = -1; + cbex->rect.left = cs->x; + cbex->rect.top = cs->y; + cbex->rect.right = cs->x + cs->cx; + cbex->rect.bottom = cs->y + cs->cy; + return TRUE; + } + + /** + * name: WM_NCCREATE + * desc: is called to create all subitems + * param: wParam - not used + * lParam - not used + * + * return: FALSE on error, TRUE if initialisation was ok + **/ case WM_CREATE: - { - WORD wHeight = (WORD)(cbex->rect.bottom - cbex->rect.top); - WORD wWidth = 130; - WORD x = 0; + { + WORD wHeight = (WORD)(cbex->rect.bottom - cbex->rect.top); + WORD wWidth = 130; + WORD x = 0; - if (!(cbex->hBtnEdit = CreateWindowEx(WS_EX_NOPARENTNOTIFY, - UINFOBUTTONCLASS, + if (!(cbex->hBtnEdit = CreateWindowEx(WS_EX_NOPARENTNOTIFY, + UINFOBUTTONCLASS, L"none", - WS_VISIBLE|WS_CHILD|WS_TABSTOP, 0, 0, + WS_VISIBLE | WS_CHILD | WS_TABSTOP, 0, 0, wWidth, wHeight, hwnd, nullptr, cbex->hInstance, nullptr))) { - cbex->bLocked = 0; - return FALSE; - } - x += wWidth + 2; - wWidth = wHeight; - if (!(cbex->hBtnMenu = CreateWindowEx(WS_EX_NOPARENTNOTIFY, + cbex->bLocked = 0; + return FALSE; + } + x += wWidth + 2; + wWidth = wHeight; + if (!(cbex->hBtnMenu = CreateWindowEx(WS_EX_NOPARENTNOTIFY, UINFOBUTTONCLASS, nullptr, - WS_VISIBLE|WS_CHILD|WS_TABSTOP|MBS_PUSHBUTTON|MBS_DOWNARROW, + WS_VISIBLE | WS_CHILD | WS_TABSTOP | MBS_PUSHBUTTON | MBS_DOWNARROW, x, 0, wWidth, wHeight, hwnd, nullptr, cbex->hInstance, nullptr))) { - DestroyWindow(cbex->hBtnEdit); - cbex->bLocked = 0; - return FALSE; - } - x += wWidth + 2; - wWidth = (WORD)(cbex->rect.right - cbex->rect.left - x - (2 * (wHeight + 2))); - if (!(cbex->hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, - L"Edit", + DestroyWindow(cbex->hBtnEdit); + cbex->bLocked = 0; + return FALSE; + } + x += wWidth + 2; + wWidth = (WORD)(cbex->rect.right - cbex->rect.left - x - (2 * (wHeight + 2))); + if (!(cbex->hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, + L"Edit", nullptr, - WS_VISIBLE|WS_CHILD|WS_TABSTOP|ES_AUTOHSCROLL, + WS_VISIBLE | WS_CHILD | WS_TABSTOP | ES_AUTOHSCROLL, x, 1, - wWidth, wHeight - 2, + wWidth, wHeight - 2, hwnd, nullptr, cbex->hInstance, nullptr))) { - DestroyWindow(cbex->hBtnEdit); - DestroyWindow(cbex->hBtnMenu); - cbex->bLocked = 0; - return FALSE; - } - x += wWidth + 2; - wWidth = wHeight; - if (!(cbex->hBtnAdd = CreateWindowEx(WS_EX_NOPARENTNOTIFY, + DestroyWindow(cbex->hBtnEdit); + DestroyWindow(cbex->hBtnMenu); + cbex->bLocked = 0; + return FALSE; + } + x += wWidth + 2; + wWidth = wHeight; + if (!(cbex->hBtnAdd = CreateWindowEx(WS_EX_NOPARENTNOTIFY, UINFOBUTTONCLASS, nullptr, - WS_VISIBLE|WS_CHILD|WS_TABSTOP|MBS_FLAT, + WS_VISIBLE | WS_CHILD | WS_TABSTOP | MBS_FLAT, x, 0, wWidth, wHeight, hwnd, nullptr, cbex->hInstance, nullptr))) { - DestroyWindow(cbex->hBtnEdit); - DestroyWindow(cbex->hBtnMenu); - DestroyWindow(cbex->hEdit); - cbex->bLocked = 0; - return FALSE; - } - x += wWidth + 2; - if (!(cbex->hBtnDel = CreateWindowEx(WS_EX_NOPARENTNOTIFY, + DestroyWindow(cbex->hBtnEdit); + DestroyWindow(cbex->hBtnMenu); + DestroyWindow(cbex->hEdit); + cbex->bLocked = 0; + return FALSE; + } + x += wWidth + 2; + if (!(cbex->hBtnDel = CreateWindowEx(WS_EX_NOPARENTNOTIFY, UINFOBUTTONCLASS, nullptr, - WS_VISIBLE|WS_CHILD|WS_TABSTOP|MBS_FLAT, + WS_VISIBLE | WS_CHILD | WS_TABSTOP | MBS_FLAT, x, 0, wWidth, wHeight, hwnd, nullptr, cbex->hInstance, nullptr))) { - DestroyWindow(cbex->hBtnEdit); - DestroyWindow(cbex->hBtnMenu); - DestroyWindow(cbex->hEdit); - DestroyWindow(cbex->hBtnAdd); + DestroyWindow(cbex->hBtnEdit); + DestroyWindow(cbex->hBtnMenu); + DestroyWindow(cbex->hEdit); + DestroyWindow(cbex->hBtnAdd); + cbex->bLocked = 0; + return FALSE; + } + + // set ids + SetWindowLongPtr(cbex->hBtnEdit, GWLP_ID, BTN_EDIT); + SetWindowLongPtr(cbex->hBtnMenu, GWLP_ID, BTN_MENU); + SetWindowLongPtr(cbex->hEdit, GWLP_ID, EDIT_VALUE); + SetWindowLongPtr(cbex->hBtnAdd, GWLP_ID, BTN_ADD); + SetWindowLongPtr(cbex->hBtnDel, GWLP_ID, BTN_DEL); + // set fonts & maximum edit control charachters + SendMessage(cbex->hEdit, WM_SETFONT, (WPARAM)cbex->hFont, NULL); + SendMessage(cbex->hEdit, EM_LIMITTEXT, (WPARAM)MAXDATASIZE, NULL); + // add tooltips + SendMessage(cbex->hBtnMenu, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Choose the item to display"), MBBF_TCHAR); + SendMessage(cbex->hBtnEdit, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Edit the currently displayed item"), MBBF_TCHAR); + SendMessage(cbex->hBtnAdd, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Add a new custom item"), MBBF_TCHAR); + SendMessage(cbex->hBtnDel, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete the selected item"), MBBF_TCHAR); + // reload icons + CtrlContactWndProc(hwnd, WM_SETICON, NULL, NULL); cbex->bLocked = 0; - return FALSE; + return TRUE; } - // set ids - SetWindowLongPtr(cbex->hBtnEdit, GWLP_ID, BTN_EDIT); - SetWindowLongPtr(cbex->hBtnMenu, GWLP_ID, BTN_MENU); - SetWindowLongPtr(cbex->hEdit, GWLP_ID, EDIT_VALUE); - SetWindowLongPtr(cbex->hBtnAdd, GWLP_ID, BTN_ADD); - SetWindowLongPtr(cbex->hBtnDel, GWLP_ID, BTN_DEL); - // set fonts & maximum edit control charachters - SendMessage(cbex->hEdit, WM_SETFONT, (WPARAM)cbex->hFont, NULL); - SendMessage(cbex->hEdit, EM_LIMITTEXT, (WPARAM)MAXDATASIZE, NULL); - // add tooltips - SendMessage(cbex->hBtnMenu, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Choose the item to display"), MBBF_TCHAR); - SendMessage(cbex->hBtnEdit, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Edit the currently displayed item"), MBBF_TCHAR); - SendMessage(cbex->hBtnAdd, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Add a new custom item"), MBBF_TCHAR); - SendMessage(cbex->hBtnDel, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete the selected item"), MBBF_TCHAR); - // reload icons - CtrlContactWndProc(hwnd, WM_SETICON, NULL, NULL); - cbex->bLocked = 0; - return TRUE; - } - - /** - * name: WM_DESTROY - * desc: default destroy message, so clear up memory - * param: wParam - not used - * lParam - not used - * return: return value of DefWindowProc - **/ + /** + * name: WM_DESTROY + * desc: default destroy message, so clear up memory + * param: wParam - not used + * lParam - not used + * return: return value of DefWindowProc + **/ case WM_DESTROY: CtrlContactWndProc(hwnd, CBEXM_DELALLITEMS, NULL, NULL); DestroyWindow(cbex->hBtnEdit); @@ -556,15 +558,15 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L MIR_FREE(cbex); break; - /** - * name: WM_CTLCOLOREDIT - * desc: is called on a paint message for a dialog item to determine its colour scheme - * param: wParam - pointer to a HDC - * lParam - pointer to a HWND - * return: a brush - **/ + /** + * name: WM_CTLCOLOREDIT + * desc: is called on a paint message for a dialog item to determine its colour scheme + * param: wParam - pointer to a HDC + * lParam - pointer to a HWND + * return: a brush + **/ case WM_CTLCOLOREDIT: - if (!g_plugin.getByte(SET_PROPSHEET_SHOWCOLOURS, 1) || (HWND)lParam != cbex->hEdit || !cbex->pItems || cbex->iSelectedItem < 0) + if (!g_plugin.getByte(SET_PROPSHEET_SHOWCOLOURS, 1) || (HWND)lParam != cbex->hEdit || !cbex->pItems || cbex->iSelectedItem < 0) break; return Ctrl_SetTextColour((HDC)wParam, cbex->pItems[cbex->iSelectedItem].wFlags); @@ -572,39 +574,39 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L if ((HWND)lParam == cbex->hEdit) return (INT_PTR)GetSysColor(COLOR_WINDOW); return FALSE; - /** - * name: WM_SETICON - * desc: updates the icons of this control - * param: wParam - not used - * lParam - not used - * return: always 0 - **/ + /** + * name: WM_SETICON + * desc: updates the icons of this control + * param: wParam - not used + * lParam - not used + * return: always 0 + **/ case WM_SETICON: - { - HICON hIcon = IcoLib_GetIcon(ICO_BTN_ADD); - SendMessage(cbex->hBtnAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - SetWindowText(cbex->hBtnAdd, (hIcon ? L"" : L"+")); + { + HICON hIcon = g_plugin.getIcon(IDI_BTN_ADD); + SendMessage(cbex->hBtnAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + SetWindowText(cbex->hBtnAdd, (hIcon ? L"" : L"+")); - hIcon = IcoLib_GetIcon(ICO_BTN_DELETE); - SendMessage(cbex->hBtnDel, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); - SetWindowText(cbex->hBtnDel, (hIcon ? L"" : L"-")); + hIcon = g_plugin.getIcon(IDI_BTN_DELETE); + SendMessage(cbex->hBtnDel, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); + SetWindowText(cbex->hBtnDel, (hIcon ? L"" : L"-")); - if (cbex->pItems && cbex->numItems > 0) { - for (int i = 0; i < cbex->numItems; i++) - cbex->pItems[i].hIcon = IcoLib_GetIcon(cbex->pItems[i].pszIcon); + if (cbex->pItems && cbex->numItems > 0) { + for (int i = 0; i < cbex->numItems; i++) + cbex->pItems[i].hIcon = g_plugin.getIcon(cbex->pItems[i].iIcon); - if (cbex->iSelectedItem >= 0 && cbex->iSelectedItem < cbex->numItems) - SendMessage(cbex->hBtnEdit, BM_SETIMAGE, IMAGE_ICON, (LPARAM)cbex->pItems[cbex->iSelectedItem].hIcon); + if (cbex->iSelectedItem >= 0 && cbex->iSelectedItem < cbex->numItems) + SendMessage(cbex->hBtnEdit, BM_SETIMAGE, IMAGE_ICON, (LPARAM)cbex->pItems[cbex->iSelectedItem].hIcon); + } + return 0; } - return 0; - } case WM_COMMAND: switch (LOWORD(wParam)) { - /** - * name: BTN_MENU - * desc: the button to dropdown the list to show all items is pressed - **/ + /** + * name: BTN_MENU + * desc: the button to dropdown the list to show all items is pressed + **/ case BTN_MENU: if (HIWORD(wParam) == BN_CLICKED) { POINT pt = { 0, 0 }; @@ -617,7 +619,7 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof(mii); - mii.fMask = MIIM_ID|MIIM_STRING|MIIM_FTYPE|MIIM_STATE; + mii.fMask = MIIM_ID | MIIM_STRING | MIIM_FTYPE | MIIM_STATE; mii.fType = MFT_STRING; // insert the items @@ -642,7 +644,7 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } ClientToScreen((HWND)lParam, &pt); GetClientRect((HWND)lParam, &rc); - i = TrackPopupMenuEx(hMenu, TPM_RIGHTALIGN|TPM_RETURNCMD, pt.x + rc.right, pt.y + rc.bottom, hwnd, nullptr); + i = TrackPopupMenuEx(hMenu, TPM_RIGHTALIGN | TPM_RETURNCMD, pt.x + rc.right, pt.y + rc.bottom, hwnd, nullptr); SendMessage(cbex->hBtnMenu, BM_SETCHECK, NULL, NULL); if (i >= CBEXM_MENIITEMFIRST && i < CBEXM_MENIITEMFIRST + cbex->numItems) { CtrlContactWndProc(hwnd, CBEXM_SETCURSEL, (WPARAM)i - CBEXM_MENIITEMFIRST, NULL); @@ -652,10 +654,10 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } break; - /** - * name: BTN_ADD - * desc: the button to add a new entry is pressed - **/ + /** + * name: BTN_ADD + * desc: the button to add a new entry is pressed + **/ case BTN_ADD: if (HIWORD(wParam) == BN_CLICKED) { DLGPROC dlgProc; @@ -668,24 +670,24 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L SetFocus((HWND)lParam); if (!(hDlgDetails = GetParent(GetParent(hwnd)))) return 1; if (SendMessage(hDlgDetails, PSM_ISLOCKED, NULL, NULL)) return 0; - + switch (GetWindowLongPtr(hwnd, GWLP_ID)) { - case EDIT_PHONE: - dlgID = IDD_ADDPHONE; - dlgProc = DlgProc_Phone; - cbi.pszIcon = ICO_BTN_CUSTOMPHONE; - break; - case EDIT_EMAIL: - dlgID = IDD_ADDEMAIL; - dlgProc = DlgProc_EMail; - cbi.pszIcon = ICO_BTN_EMAIL; - break; - default: - return 1; + case EDIT_PHONE: + dlgID = IDD_ADDPHONE; + dlgProc = DlgProc_Phone; + cbi.iIcon = IDI_BTN_CUSTOMPHONE; + break; + case EDIT_EMAIL: + dlgID = IDD_ADDEMAIL; + dlgProc = DlgProc_EMail; + cbi.iIcon = IDI_BTN_EMAIL; + break; + default: + return 1; } - + cbi.iItem = -1; - cbi.wMask = CBEXIM_CAT|CBEXIM_VAL|CBEXIM_FLAGS|CBEXIM_ICONTEXT; + cbi.wMask = CBEXIM_CAT | CBEXIM_VAL | CBEXIM_FLAGS | CBEXIM_ICONTEXT; cbi.pszCat = szCat; cbi.pszVal = szVal; cbi.ccCat = MAX_CAT; @@ -695,7 +697,7 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(dlgID), GetParent(hwnd), dlgProc, (LPARAM)&cbi) == IDOK) { MCONTACT hContact = NULL; - + SendMessage(hDlgDetails, PSM_GETCONTACT, NULL, (LPARAM)&hContact); if (hContact) cbi.wFlags |= CTRLF_HASCUSTOM; cbi.wFlags |= CTRLF_CHANGED; @@ -709,10 +711,10 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } break; - /** - * name: BTN_EDIT - * desc: the button to edit an existing entry is pressed - **/ + /** + * name: BTN_EDIT + * desc: the button to edit an existing entry is pressed + **/ case BTN_EDIT: if (HIWORD(wParam) == BN_CLICKED) { DLGPROC dlgProc; @@ -728,20 +730,20 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L if (!cbex->pItems || cbex->iSelectedItem == -1) return 0; switch (GetWindowLongPtr(hwnd, GWLP_ID)) { - case EDIT_PHONE: - dlgID = IDD_ADDPHONE; - dlgProc = DlgProc_Phone; - break; - case EDIT_EMAIL: - dlgID = IDD_ADDEMAIL; - dlgProc = DlgProc_EMail; - break; - default: - return 1; + case EDIT_PHONE: + dlgID = IDD_ADDPHONE; + dlgProc = DlgProc_Phone; + break; + case EDIT_EMAIL: + dlgID = IDD_ADDEMAIL; + dlgProc = DlgProc_EMail; + break; + default: + return 1; } cbi.iItem = cbex->iSelectedItem; cbi.dwID = 0; - cbi.wMask = CBEXIM_CAT|CBEXIM_VAL|CBEXIM_FLAGS; + cbi.wMask = CBEXIM_CAT | CBEXIM_VAL | CBEXIM_FLAGS; cbi.pszCat = szCat; cbi.pszVal = szVal; cbi.ccCat = MAX_CAT; @@ -765,32 +767,31 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } break; - /** - * name: BTN_DEL - * desc: the button to delete an existing entry is pressed - **/ + /** + * name: BTN_DEL + * desc: the button to delete an existing entry is pressed + **/ case BTN_DEL: if (HIWORD(wParam) == BN_CLICKED) { HWND hDlgDetails; MSGBOX mBox; wchar_t szMsg[MAXDATASIZE]; - + SetFocus((HWND)lParam); if (!(hDlgDetails = GetParent(GetParent(hwnd))) || - SendMessage(hDlgDetails, PSM_ISLOCKED, NULL, NULL) || - !cbex->pItems || - cbex->iSelectedItem < 0 || - cbex->iSelectedItem >= cbex->numItems || - FAILED(mir_snwprintf(szMsg, TranslateT("Do you really want to delete the current selected item?\n\t%s\n\t%s"), + SendMessage(hDlgDetails, PSM_ISLOCKED, NULL, NULL) || + !cbex->pItems || + cbex->iSelectedItem < 0 || + cbex->iSelectedItem >= cbex->numItems || + FAILED(mir_snwprintf(szMsg, TranslateT("Do you really want to delete the current selected item?\n\t%s\n\t%s"), cbex->pItems[cbex->iSelectedItem].szCat, cbex->pItems[cbex->iSelectedItem].pszVal)) - ) - { - return 1; + ) { + return 1; } mBox.cbSize = sizeof(MSGBOX); mBox.hParent = hDlgDetails; - mBox.hiLogo = IcoLib_GetIcon(ICO_DLG_PHONE); - mBox.uType = MB_YESNO|MB_ICON_QUESTION|MB_NOPOPUP; + mBox.hiLogo = g_plugin.getIcon(IDI_DLG_PHONE); + mBox.uType = MB_YESNO | MB_ICON_QUESTION | MB_NOPOPUP; mBox.ptszTitle = TranslateT("Delete"); mBox.ptszMsg = szMsg; if (IDYES == MsgBoxService(NULL, (LPARAM)&mBox)) { @@ -802,16 +803,16 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L cbex->pItems[cbex->iSelectedItem].wFlags |= CTRLF_CHANGED; } // clear values for customized database entry - else - if (cbex->pItems[cbex->iSelectedItem].dwID != 0) { - MIR_FREE(cbex->pItems[cbex->iSelectedItem].pszVal); - *cbex->pItems[cbex->iSelectedItem].szCat = 0; - cbex->pItems[cbex->iSelectedItem].wFlags |= CTRLF_CHANGED|CBEXIF_DELETED; - CtrlContactWndProc(hwnd, CBEXM_SETCURSEL, cbex->iSelectedItem - 1, FALSE); - } - // delete default entry else - CtrlContactWndProc(hwnd, CBEXM_DELITEM, NULL, cbex->iSelectedItem); + if (cbex->pItems[cbex->iSelectedItem].dwID != 0) { + MIR_FREE(cbex->pItems[cbex->iSelectedItem].pszVal); + *cbex->pItems[cbex->iSelectedItem].szCat = 0; + cbex->pItems[cbex->iSelectedItem].wFlags |= CTRLF_CHANGED | CBEXIF_DELETED; + CtrlContactWndProc(hwnd, CBEXM_SETCURSEL, cbex->iSelectedItem - 1, FALSE); + } + // delete default entry + else + CtrlContactWndProc(hwnd, CBEXM_DELITEM, NULL, cbex->iSelectedItem); SendMessage(hDlgDetails, PSM_CHANGED, NULL, NULL); cbex->bIsChanged = TRUE; @@ -820,30 +821,30 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } break; - /** - * name: EDIT_VALUE - * desc: the edit control wants us to act - **/ + /** + * name: EDIT_VALUE + * desc: the edit control wants us to act + **/ case EDIT_VALUE: switch (HIWORD(wParam)) { - case EN_UPDATE: + case EN_UPDATE: { wchar_t szVal[MAXDATASIZE] = { 0 }; int ccVal; MCONTACT hContact; HWND hDlgDetails = GetParent(GetParent(hwnd)); - + EnableWindow(cbex->hBtnDel, GetWindowTextLength(cbex->hEdit) > 0); if (SendMessage(hDlgDetails, PSM_ISLOCKED, NULL, NULL) || - cbex->bLocked || - !cbex->pItems || - cbex->iSelectedItem < 0 || + cbex->bLocked || + !cbex->pItems || + cbex->iSelectedItem < 0 || cbex->iSelectedItem >= cbex->numItems) return 1; // get the edit control's text value and check it for syntax switch (GetWindowLongPtr(hwnd, GWLP_ID)) { - case EDIT_PHONE: + case EDIT_PHONE: { int errorPos; wchar_t szEdit[MAXDATASIZE]; @@ -856,17 +857,17 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } break; } - case EDIT_EMAIL: - ccVal = GetWindowText(cbex->hEdit, szVal, _countof(szVal)); - break; - default: - ccVal = GetWindowText(cbex->hEdit, szVal, _countof(szVal)); - break; + case EDIT_EMAIL: + ccVal = GetWindowText(cbex->hEdit, szVal, _countof(szVal)); + break; + default: + ccVal = GetWindowText(cbex->hEdit, szVal, _countof(szVal)); + break; } - + SendMessage(hDlgDetails, PSM_GETCONTACT, NULL, (LPARAM)&hContact); if ((cbex->pItems[cbex->iSelectedItem].wFlags & CTRLF_CHANGED) && !(hContact && (cbex->pItems[cbex->iSelectedItem].wFlags & CTRLF_HASCUSTOM))) return 0; - + if (*szVal == 0 || !cbex->pItems[cbex->iSelectedItem].pszVal || mir_wstrcmp(szVal, cbex->pItems[cbex->iSelectedItem].pszVal)) { cbex->pItems[cbex->iSelectedItem].wFlags |= CTRLF_CHANGED; cbex->pItems[cbex->iSelectedItem].wFlags |= (hContact ? CTRLF_HASCUSTOM : CTRLF_HASPROTO); @@ -876,10 +877,10 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } return 0; } - case EN_KILLFOCUS: + case EN_KILLFOCUS: { int ccText; - + if (!cbex->pItems || cbex->iSelectedItem < 0 || cbex->iSelectedItem >= cbex->numItems) return 1; if (!(cbex->pItems[cbex->iSelectedItem].wFlags & CTRLF_CHANGED)) return 0; @@ -895,10 +896,10 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L cbex->bIsChanged = TRUE; } else - if (cbex->pItems[cbex->iSelectedItem].pszVal = (LPTSTR)mir_realloc(cbex->pItems[cbex->iSelectedItem].pszVal, (ccText + 2) * sizeof(wchar_t))) { - cbex->pItems[cbex->iSelectedItem].pszVal[ccText + 1] = 0; - GetWindowText(cbex->hEdit, cbex->pItems[cbex->iSelectedItem].pszVal, ccText + 1); - } + if (cbex->pItems[cbex->iSelectedItem].pszVal = (LPTSTR)mir_realloc(cbex->pItems[cbex->iSelectedItem].pszVal, (ccText + 2) * sizeof(wchar_t))) { + cbex->pItems[cbex->iSelectedItem].pszVal[ccText + 1] = 0; + GetWindowText(cbex->hEdit, cbex->pItems[cbex->iSelectedItem].pszVal, ccText + 1); + } return 0; } } @@ -906,237 +907,237 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } break; - /** - * name: CBEXM_ADDITEM - * desc: add a item to the control - * param: wParam - not used - * lParam - (LPCBEXITEM)&item - * return: CB_ERR on failure, new item index if successful - **/ + /** + * name: CBEXM_ADDITEM + * desc: add a item to the control + * param: wParam - not used + * lParam - (LPCBEXITEM)&item + * return: CB_ERR on failure, new item index if successful + **/ case CBEXM_ADDITEM: - { - LPCBEXITEM pItem = (LPCBEXITEM)lParam; - - if (!pItem) return FALSE; - - // if an item with the id of pItem exists, change it instead of adding a new one - // but only if it has not been changed by the user yet. - if ((pItem->wMask & CBEXIM_ID) && cbex->pItems && pItem->dwID != 0) { - int iIndex; - - for (iIndex = 0; iIndex < cbex->numItems; iIndex++) { - if (cbex->pItems[iIndex].dwID == pItem->dwID) { - pItem->iItem = iIndex; - if (cbex->pItems[iIndex].wFlags & CTRLF_CHANGED) - pItem->wFlags |= CTRLF_CHANGED; - else - CtrlContactWndProc(hwnd, CBEXM_SETITEM, 0, lParam); - return iIndex; - } - } - } + { + CBEXITEM *pItem = (CBEXITEM*)lParam; - // add a new item to the combobox - if (!(cbex->pItems = (LPCBEXITEMINTERN)mir_realloc(cbex->pItems, (cbex->numItems + 1) * sizeof(CBEXITEMINTERN)))) { - cbex->numItems = 0; - return CB_ERR; - } - - // set the ID - cbex->pItems[cbex->numItems].dwID = (pItem->wMask & CBEXIM_ID) ? pItem->dwID : 0; + if (!pItem) return FALSE; - // set category string - if (!pItem->pszCat || !pItem->pszCat[0] || !mir_wstrncpy(cbex->pItems[cbex->numItems].szCat, pItem->pszCat, MAX_CAT)) { - mir_snwprintf(cbex->pItems[cbex->numItems].szCat, L"%s %d", TranslateT("Other"), ++cbex->numOther); - } + // if an item with the id of pItem exists, change it instead of adding a new one + // but only if it has not been changed by the user yet. + if ((pItem->wMask & CBEXIM_ID) && cbex->pItems && pItem->dwID != 0) { + int iIndex; - // set value string - if ((pItem->wMask & CBEXIM_VAL) && pItem->pszVal && pItem->pszVal[0]) - cbex->pItems[cbex->numItems].pszVal = mir_wstrdup(pItem->pszVal); - else - cbex->pItems[cbex->numItems].pszVal = nullptr; - // set icon - if ((pItem->wMask & CBEXIM_ICONTEXT) && pItem->pszIcon) { - cbex->pItems[cbex->numItems].pszIcon = pItem->pszIcon; - cbex->pItems[cbex->numItems].hIcon = IcoLib_GetIcon(pItem->pszIcon); - } - // set flags - cbex->pItems[cbex->numItems].wFlags = (pItem->wMask & CBEXIM_CAT) ? pItem->wFlags : 0; - - cbex->numItems++; - return cbex->numItems; - } + for (iIndex = 0; iIndex < cbex->numItems; iIndex++) { + if (cbex->pItems[iIndex].dwID == pItem->dwID) { + pItem->iItem = iIndex; + if (cbex->pItems[iIndex].wFlags & CTRLF_CHANGED) + pItem->wFlags |= CTRLF_CHANGED; + else + CtrlContactWndProc(hwnd, CBEXM_SETITEM, 0, lParam); + return iIndex; + } + } + } - /** - * name: CBEXM_SETITEM - * desc: Set an item's information of the control. - * If iItem member of CBEXITEM is -1, the currently selected item is changed. - * param: wParam - not used - * lParam - (LPCBEXITEM)&item - * return: CB_ERR on failure, new item index if successful - **/ - case CBEXM_SETITEM: - { - LPCBEXITEM pItem = (LPCBEXITEM)lParam; + // add a new item to the combobox + if (!(cbex->pItems = (LPCBEXITEMINTERN)mir_realloc(cbex->pItems, (cbex->numItems + 1) * sizeof(CBEXITEMINTERN)))) { + cbex->numItems = 0; + return CB_ERR; + } - if (!PtrIsValid(pItem) || !pItem->wMask || !PtrIsValid(cbex->pItems)) return FALSE; - if (pItem->iItem == -1) pItem->iItem = cbex->iSelectedItem; - if (pItem->iItem < 0 || pItem->iItem >= cbex->numItems) return FALSE; + // set the ID + cbex->pItems[cbex->numItems].dwID = (pItem->wMask & CBEXIM_ID) ? pItem->dwID : 0; - // set new category string - if (pItem->wMask & CBEXIM_CAT) { // set category string - if (!pItem->pszCat || !pItem->pszCat[0] || !mir_wstrncpy(cbex->pItems[pItem->iItem].szCat, pItem->pszCat, _countof(cbex->pItems[pItem->iItem].szCat))) - mir_snwprintf(cbex->pItems[pItem->iItem].szCat, L"%s %d", TranslateT("Other"), ++cbex->numOther); - if (pItem->iItem == cbex->iSelectedItem) - SetWindowText(cbex->hBtnEdit, cbex->pItems[pItem->iItem].szCat); - } - // set new value - if (pItem->wMask & CBEXIM_VAL) { - MIR_FREE(cbex->pItems[pItem->iItem].pszVal); - if (pItem->pszVal && pItem->pszVal[0]) - cbex->pItems[pItem->iItem].pszVal = mir_wstrdup(pItem->pszVal); - if (pItem->iItem == cbex->iSelectedItem) - SetWindowText(cbex->hEdit, cbex->pItems[pItem->iItem].pszVal ? cbex->pItems[pItem->iItem].pszVal : L""); - } + if (!pItem->pszCat || !pItem->pszCat[0] || !mir_wstrncpy(cbex->pItems[cbex->numItems].szCat, pItem->pszCat, MAX_CAT)) { + mir_snwprintf(cbex->pItems[cbex->numItems].szCat, L"%s %d", TranslateT("Other"), ++cbex->numOther); + } - // set icon - if ((pItem->wMask & CBEXIM_ICONTEXT) && pItem->pszIcon) { - cbex->pItems[pItem->iItem].pszIcon = pItem->pszIcon; - cbex->pItems[pItem->iItem].hIcon = IcoLib_GetIcon(pItem->pszIcon); - if (pItem->iItem == cbex->iSelectedItem) - SendMessage(cbex->hBtnEdit, BM_SETIMAGE, IMAGE_ICON, (LPARAM)cbex->pItems[pItem->iItem].hIcon); + // set value string + if ((pItem->wMask & CBEXIM_VAL) && pItem->pszVal && pItem->pszVal[0]) + cbex->pItems[cbex->numItems].pszVal = mir_wstrdup(pItem->pszVal); + else + cbex->pItems[cbex->numItems].pszVal = nullptr; + // set icon + if ((pItem->wMask & CBEXIM_ICONTEXT) && pItem->iIcon) { + cbex->pItems[cbex->numItems].iIcon = pItem->iIcon; + cbex->pItems[cbex->numItems].hIcon = g_plugin.getIcon(pItem->iIcon); + } + // set flags + cbex->pItems[cbex->numItems].wFlags = (pItem->wMask & CBEXIM_CAT) ? pItem->wFlags : 0; + + cbex->numItems++; + return cbex->numItems; } - if (pItem->wMask & CBEXIM_FLAGS) { - cbex->pItems[pItem->iItem].wFlags = pItem->wFlags; - CtrlContactWndProc(hwnd, CBEXM_ENABLEITEM, NULL, NULL); + + /** + * name: CBEXM_SETITEM + * desc: Set an item's information of the control. + * If iItem member of CBEXITEM is -1, the currently selected item is changed. + * param: wParam - not used + * lParam - (LPCBEXITEM)&item + * return: CB_ERR on failure, new item index if successful + **/ + case CBEXM_SETITEM: + { + CBEXITEM *pItem = (CBEXITEM *)lParam; + + if (!PtrIsValid(pItem) || !pItem->wMask || !PtrIsValid(cbex->pItems)) return FALSE; + if (pItem->iItem == -1) pItem->iItem = cbex->iSelectedItem; + if (pItem->iItem < 0 || pItem->iItem >= cbex->numItems) return FALSE; + + // set new category string + if (pItem->wMask & CBEXIM_CAT) { + // set category string + if (!pItem->pszCat || !pItem->pszCat[0] || !mir_wstrncpy(cbex->pItems[pItem->iItem].szCat, pItem->pszCat, _countof(cbex->pItems[pItem->iItem].szCat))) + mir_snwprintf(cbex->pItems[pItem->iItem].szCat, L"%s %d", TranslateT("Other"), ++cbex->numOther); + if (pItem->iItem == cbex->iSelectedItem) + SetWindowText(cbex->hBtnEdit, cbex->pItems[pItem->iItem].szCat); + } + // set new value + if (pItem->wMask & CBEXIM_VAL) { + MIR_FREE(cbex->pItems[pItem->iItem].pszVal); + if (pItem->pszVal && pItem->pszVal[0]) + cbex->pItems[pItem->iItem].pszVal = mir_wstrdup(pItem->pszVal); + if (pItem->iItem == cbex->iSelectedItem) + SetWindowText(cbex->hEdit, cbex->pItems[pItem->iItem].pszVal ? cbex->pItems[pItem->iItem].pszVal : L""); + } + + // set icon + if ((pItem->wMask & CBEXIM_ICONTEXT) && pItem->iIcon) { + cbex->pItems[pItem->iItem].iIcon = pItem->iIcon; + cbex->pItems[pItem->iItem].hIcon = g_plugin.getIcon(pItem->iIcon); + if (pItem->iItem == cbex->iSelectedItem) + SendMessage(cbex->hBtnEdit, BM_SETIMAGE, IMAGE_ICON, (LPARAM)cbex->pItems[pItem->iItem].hIcon); + } + if (pItem->wMask & CBEXIM_FLAGS) { + cbex->pItems[pItem->iItem].wFlags = pItem->wFlags; + CtrlContactWndProc(hwnd, CBEXM_ENABLEITEM, NULL, NULL); + } + return TRUE; } - return TRUE; - } - /** - * name: CBEXM_GETITEM - * desc: Get an item from the control. - * If iItem member of CBEXITEM is -1, the currently selected item is returned. - * param: wParam - not used - * lParam - (LPCBEXITEM)&item - * return: CB_ERR on failure, new item index if successful - **/ + /** + * name: CBEXM_GETITEM + * desc: Get an item from the control. + * If iItem member of CBEXITEM is -1, the currently selected item is returned. + * param: wParam - not used + * lParam - (LPCBEXITEM)&item + * return: CB_ERR on failure, new item index if successful + **/ case CBEXM_GETITEM: - { - LPCBEXITEM pItem = (LPCBEXITEM)lParam; + { + CBEXITEM *pItem = (CBEXITEM *)lParam; - if (!pItem || !cbex->pItems) return FALSE; - - // try to find item by id - if ((pItem->wMask & CBEXIM_ID) && pItem->dwID != 0) { - int i; + if (!pItem || !cbex->pItems) return FALSE; - for (i = 0; i < cbex->numItems; i++) { - if (cbex->pItems[i].dwID == pItem->dwID) - break; + // try to find item by id + if ((pItem->wMask & CBEXIM_ID) && pItem->dwID != 0) { + int i; + + for (i = 0; i < cbex->numItems; i++) { + if (cbex->pItems[i].dwID == pItem->dwID) + break; + } + pItem->iItem = i; } - pItem->iItem = i; - } - else - if (pItem->iItem == -1) pItem->iItem = cbex->iSelectedItem; - if (pItem->iItem < 0 || pItem->iItem >= cbex->numItems) return FALSE; - - // return only currently selected itemindex - if (!pItem->wMask) return TRUE; - // return the unique id - if (pItem->wMask & CBEXIM_ID) - pItem->dwID = cbex->pItems[pItem->iItem].dwID; - // return category string - if ((pItem->wMask & CBEXIM_CAT) && pItem->pszCat) { - if (*cbex->pItems[pItem->iItem].szCat != 0) - mir_wstrncpy(pItem->pszCat, cbex->pItems[pItem->iItem].szCat, pItem->ccCat - 1); - else - *pItem->pszCat = 0; - } - // return value string - if ((pItem->wMask & CBEXIM_VAL) && pItem->pszVal) { - if (cbex->pItems[pItem->iItem].pszVal) - mir_wstrncpy(pItem->pszVal, cbex->pItems[pItem->iItem].pszVal, pItem->ccVal - 1); else - *pItem->pszVal = 0; + if (pItem->iItem == -1) pItem->iItem = cbex->iSelectedItem; + if (pItem->iItem < 0 || pItem->iItem >= cbex->numItems) return FALSE; + + // return only currently selected itemindex + if (!pItem->wMask) return TRUE; + // return the unique id + if (pItem->wMask & CBEXIM_ID) + pItem->dwID = cbex->pItems[pItem->iItem].dwID; + // return category string + if ((pItem->wMask & CBEXIM_CAT) && pItem->pszCat) { + if (*cbex->pItems[pItem->iItem].szCat != 0) + mir_wstrncpy(pItem->pszCat, cbex->pItems[pItem->iItem].szCat, pItem->ccCat - 1); + else + *pItem->pszCat = 0; + } + // return value string + if ((pItem->wMask & CBEXIM_VAL) && pItem->pszVal) { + if (cbex->pItems[pItem->iItem].pszVal) + mir_wstrncpy(pItem->pszVal, cbex->pItems[pItem->iItem].pszVal, pItem->ccVal - 1); + else + *pItem->pszVal = 0; + } + // return the icon + if (pItem->wMask & CBEXIM_ICONTEXT) + pItem->iIcon = cbex->pItems[pItem->iItem].iIcon; + // return the flags + if (pItem->wMask & CBEXIM_FLAGS) + pItem->wFlags = cbex->pItems[pItem->iItem].wFlags; + return TRUE; } - // return the icon - if (pItem->wMask & CBEXIM_ICONTEXT) - pItem->pszIcon = cbex->pItems[pItem->iItem].pszIcon; - // return the flags - if (pItem->wMask & CBEXIM_FLAGS) - pItem->wFlags = cbex->pItems[pItem->iItem].wFlags; - return TRUE; - } - /** - * name: CBEXM_DELITEM - * desc: delete an item from the control - * param: wParam - not used - * lParam - item index - * return: CB_ERR on failure, new item index if successful - **/ + /** + * name: CBEXM_DELITEM + * desc: delete an item from the control + * param: wParam - not used + * lParam - item index + * return: CB_ERR on failure, new item index if successful + **/ case CBEXM_DELITEM: - { - if (!cbex->pItems || (int)lParam < 0 || (int)lParam >= cbex->numItems || (cbex->pItems[lParam].wFlags & CBEXIF_CATREADONLY)) - return FALSE; - MIR_FREE(cbex->pItems[(int)lParam].pszVal); - memmove(cbex->pItems + (int)lParam, - cbex->pItems + (int)lParam + 1, - (cbex->numItems - (int)lParam - 1) * sizeof(CBEXITEMINTERN)); - cbex->numItems--; - memset((cbex->pItems + cbex->numItems), 0, sizeof(CBEXITEMINTERN)); - CtrlContactWndProc(hwnd, CBEXM_SETCURSEL, lParam - 1, FALSE); - return TRUE; - } + { + if (!cbex->pItems || (int)lParam < 0 || (int)lParam >= cbex->numItems || (cbex->pItems[lParam].wFlags & CBEXIF_CATREADONLY)) + return FALSE; + MIR_FREE(cbex->pItems[(int)lParam].pszVal); + memmove(cbex->pItems + (int)lParam, + cbex->pItems + (int)lParam + 1, + (cbex->numItems - (int)lParam - 1) * sizeof(CBEXITEMINTERN)); + cbex->numItems--; + memset((cbex->pItems + cbex->numItems), 0, sizeof(CBEXITEMINTERN)); + CtrlContactWndProc(hwnd, CBEXM_SETCURSEL, lParam - 1, FALSE); + return TRUE; + } - /** - * name: CBEXM_DELITEM - * desc: delete an item from the control - * param: wParam - not used - * lParam - item index - * return: CB_ERR on failure, new item index if successful - **/ + /** + * name: CBEXM_DELITEM + * desc: delete an item from the control + * param: wParam - not used + * lParam - item index + * return: CB_ERR on failure, new item index if successful + **/ case CBEXM_DELALLITEMS: - { - int i; + { + int i; - if (PtrIsValid(cbex)) { - if (PtrIsValid(cbex->pItems)) { - for (i = 0; i < cbex->numItems; i++) { - MIR_FREE(cbex->pItems[i].pszVal); + if (PtrIsValid(cbex)) { + if (PtrIsValid(cbex->pItems)) { + for (i = 0; i < cbex->numItems; i++) { + MIR_FREE(cbex->pItems[i].pszVal); + } + MIR_FREE(cbex->pItems); + cbex->pItems = nullptr; } - MIR_FREE(cbex->pItems); - cbex->pItems = nullptr; + cbex->numItems = 0; + cbex->iSelectedItem = -1; + SetWindowText(cbex->hEdit, L""); + SetWindowText(cbex->hBtnEdit, L""); + SendMessage(cbex->hBtnEdit, WM_SETICON, NULL, NULL); } - cbex->numItems = 0; - cbex->iSelectedItem = -1; - SetWindowText(cbex->hEdit, L""); - SetWindowText(cbex->hBtnEdit, L""); - SendMessage(cbex->hBtnEdit, WM_SETICON, NULL, NULL); + return TRUE; } - return TRUE; - } - /** - * name: CBEXM_ENABLEITEM - * desc: enables or disables the current item - * param: wParam - not used - * lParam - not used - * return: always 0 - **/ + /** + * name: CBEXM_ENABLEITEM + * desc: enables or disables the current item + * param: wParam - not used + * lParam - not used + * return: always 0 + **/ case CBEXM_ENABLEITEM: if (cbex->iSelectedItem >= 0 && cbex->iSelectedItem < cbex->numItems) { MCONTACT hContact; BYTE bEnabled; - + PSGetContact(GetParent(hwnd), hContact); - bEnabled = !hContact || - (cbex->pItems[cbex->iSelectedItem].wFlags & CTRLF_HASCUSTOM) || - !(cbex->pItems[cbex->iSelectedItem].wFlags & (CTRLF_HASPROTO|CTRLF_HASMETA)) || - !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0); + bEnabled = !hContact || + (cbex->pItems[cbex->iSelectedItem].wFlags & CTRLF_HASCUSTOM) || + !(cbex->pItems[cbex->iSelectedItem].wFlags & (CTRLF_HASPROTO | CTRLF_HASMETA)) || + !g_plugin.getByte(SET_PROPSHEET_PCBIREADONLY, 0); EnableWindow(cbex->hBtnEdit, bEnabled); EnableWindow(cbex->hBtnDel, bEnabled && GetWindowTextLength(cbex->hEdit) > 0); @@ -1144,72 +1145,72 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L } break; - /** - * name: CBEXM_ISCHANGED - * desc: returns whether the control contains changed values or not - * param: wParam - not used - * lParam - not used - * return: TRUE if control was changed, FALSE if nothing was edited - **/ + /** + * name: CBEXM_ISCHANGED + * desc: returns whether the control contains changed values or not + * param: wParam - not used + * lParam - not used + * return: TRUE if control was changed, FALSE if nothing was edited + **/ case CBEXM_ISCHANGED: return cbex->bIsChanged; - /** - * name: CBEXM_RESETCHANGED - * desc: resets changed flag to FALSE - * param: wParam - not used - * lParam - not used - * return: always FALSE - **/ + /** + * name: CBEXM_RESETCHANGED + * desc: resets changed flag to FALSE + * param: wParam - not used + * lParam - not used + * return: always FALSE + **/ case CBEXM_RESETCHANGED: cbex->bIsChanged = 0; return 0; - /** - * name: CBEXM_SETCURSEL - * desc: selects a certain item - * param: wParam - index of the item to select - * lParam - (BYTE)bValid - if TRUE, the next item with a value is selected - * return: always FALSE - **/ + /** + * name: CBEXM_SETCURSEL + * desc: selects a certain item + * param: wParam - index of the item to select + * lParam - (BYTE)bValid - if TRUE, the next item with a value is selected + * return: always FALSE + **/ case CBEXM_SETCURSEL: - { - int i; - - if (!cbex->pItems) return 1; - if ((int)wParam < 0 || (int)wParam >= cbex->numItems) wParam = max(cbex->iSelectedItem, 0); - cbex->bLocked = 1; - - if ((BYTE)lParam == TRUE) { - i = (int)wParam; - - cbex->iSelectedItem = (int)wParam; - while (i < cbex->numItems) { - if (cbex->pItems[i].pszVal && *cbex->pItems[i].pszVal) { - cbex->iSelectedItem = i; - break; + { + int i; + + if (!cbex->pItems) return 1; + if ((int)wParam < 0 || (int)wParam >= cbex->numItems) wParam = max(cbex->iSelectedItem, 0); + cbex->bLocked = 1; + + if ((BYTE)lParam == TRUE) { + i = (int)wParam; + + cbex->iSelectedItem = (int)wParam; + while (i < cbex->numItems) { + if (cbex->pItems[i].pszVal && *cbex->pItems[i].pszVal) { + cbex->iSelectedItem = i; + break; + } + i++; } - i++; - } - } - else { - // search for the next none deleted item - for (i = (int)wParam; i < cbex->numItems && *cbex->pItems[i].szCat == 0; i++); - if (i == cbex->numItems && (int)wParam > 0) { - for (i = 0; i < (int)wParam && *cbex->pItems[i].szCat == 0; i++); - cbex->iSelectedItem = i == (int)wParam ? 0 : i; } - else - cbex->iSelectedItem = i; + else { + // search for the next none deleted item + for (i = (int)wParam; i < cbex->numItems && *cbex->pItems[i].szCat == 0; i++); + if (i == cbex->numItems && (int)wParam > 0) { + for (i = 0; i < (int)wParam && *cbex->pItems[i].szCat == 0; i++); + cbex->iSelectedItem = i == (int)wParam ? 0 : i; + } + else + cbex->iSelectedItem = i; + } + SetWindowText(cbex->hBtnEdit, cbex->pItems[cbex->iSelectedItem].szCat); + SetWindowText(cbex->hEdit, cbex->pItems[cbex->iSelectedItem].pszVal ? cbex->pItems[cbex->iSelectedItem].pszVal : L""); + SendMessage(cbex->hBtnEdit, BM_SETIMAGE, IMAGE_ICON, (LPARAM)cbex->pItems[cbex->iSelectedItem].hIcon); + CtrlContactWndProc(hwnd, CBEXM_ENABLEITEM, NULL, NULL); + cbex->bLocked = 0; + return 0; } - SetWindowText(cbex->hBtnEdit, cbex->pItems[cbex->iSelectedItem].szCat); - SetWindowText(cbex->hEdit, cbex->pItems[cbex->iSelectedItem].pszVal ? cbex->pItems[cbex->iSelectedItem].pszVal : L""); - SendMessage(cbex->hBtnEdit, BM_SETIMAGE, IMAGE_ICON, (LPARAM)cbex->pItems[cbex->iSelectedItem].hIcon); - CtrlContactWndProc(hwnd, CBEXM_ENABLEITEM, NULL, NULL); - cbex->bLocked = 0; - return 0; - } case CBEXM_SORT: if (cbex->numItems > 4) { qsort(cbex->pItems + 3, cbex->numItems - 3, sizeof(CBEXITEMINTERN), compareProc); @@ -1249,20 +1250,20 @@ int CtrlContactUnLoadModule() int CtrlContactLoadModule() { WNDCLASSEX wc; - + memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - wc.lpszClassName = UINFOCOMBOEXCLASS; - wc.lpfnWndProc = CtrlContactWndProc; - wc.hCursor = LoadCursor(nullptr, IDC_ARROW); - wc.cbWndExtra = sizeof(LPCBEX); - wc.hbrBackground = (HBRUSH)GetStockObject(COLOR_WINDOW); - wc.style = CS_GLOBALCLASS; + wc.cbSize = sizeof(wc); + wc.lpszClassName = UINFOCOMBOEXCLASS; + wc.lpfnWndProc = CtrlContactWndProc; + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.cbWndExtra = sizeof(LPCBEX); + wc.hbrBackground = (HBRUSH)GetStockObject(COLOR_WINDOW); + wc.style = CS_GLOBALCLASS; RegisterClassEx(&wc); return 0; } - + /** * name: CtrlContactAddItemFromDB * desc: add a item read from db to the combobox @@ -1278,20 +1279,20 @@ int CtrlContactLoadModule() * FALSE - if item is added or updated successfully **/ int CtrlContactAddItemFromDB( - HWND hCtrl, - LPCSTR szIcon, - LPTSTR szItem, - MCONTACT hContact, - LPCSTR pszModule, - LPCSTR pszProto, - LPCSTR szSettingVal) + HWND hCtrl, + int iIcon, + LPTSTR szItem, + MCONTACT hContact, + LPCSTR pszModule, + LPCSTR pszProto, + LPCSTR szSettingVal) { DBVARIANT dbv; CBEXITEM cbi; cbi.pszVal = nullptr; cbi.dwID = mir_hashstr(szSettingVal); - cbi.wFlags = CBEXIF_CATREADONLY|DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, szSettingVal, &dbv); + cbi.wFlags = CBEXIF_CATREADONLY | DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, szSettingVal, &dbv); if (dbv.type >= DBVT_WCHAR) { // no value read from database if (cbi.wFlags == CBEXIF_CATREADONLY) @@ -1307,7 +1308,7 @@ int CtrlContactAddItemFromDB( cbi.pszCat = szItem; cbi.iItem = -1; cbi.wMask = CBEXIM_ALL; - cbi.pszIcon = szIcon; + cbi.iIcon = iIcon; SendMessage(hCtrl, CBEXM_ADDITEM, NULL, (LPARAM)&cbi); db_free(&dbv); return (cbi.wFlags & CTRLF_CHANGED) == CTRLF_CHANGED; @@ -1328,14 +1329,14 @@ int CtrlContactAddItemFromDB( * FALSE - if all items were added or updated successfully **/ int CtrlContactAddMyItemsFromDB( - HWND hCtrl, - LPCSTR szIcon, - WORD wForcedFlags, - MCONTACT hContact, - LPCSTR pszModule, - LPCSTR pszProto, - LPCSTR szFormatCat, - LPCSTR szFormatVal) + HWND hCtrl, + int iIcon, + WORD wForcedFlags, + MCONTACT hContact, + LPCSTR pszModule, + LPCSTR pszProto, + LPCSTR szFormatCat, + LPCSTR szFormatVal) { CBEXITEM cbi; DBVARIANT dbv; @@ -1347,13 +1348,12 @@ int CtrlContactAddMyItemsFromDB( memset(&cbi, 0, sizeof(cbi)); cbi.iItem = -1; cbi.wMask = CBEXIM_ALL; - cbi.pszIcon = szIcon; + cbi.iIcon = iIcon; for (i = 0; SUCCEEDED(mir_snprintf(pszSetting, szFormatVal, i)) && (cbi.wFlags = DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, pszSetting, &dbv)); - i++) - { + i++) { // read value cbi.dwID = mir_hashstr(pszSetting); cbi.pszVal = dbv.pwszVal; @@ -1367,10 +1367,10 @@ int CtrlContactAddMyItemsFromDB( dbv.type = DBVT_DELETED; } else - if (cbi.wFlags & CTRLF_HASPROTO) { - if (DB::Setting::GetTString(hContact, pszProto, pszSetting, &dbv)) - dbv.type = DBVT_DELETED; - } + if (cbi.wFlags & CTRLF_HASPROTO) { + if (DB::Setting::GetTString(hContact, pszProto, pszSetting, &dbv)) + dbv.type = DBVT_DELETED; + } if (dbv.type > DBVT_DELETED && dbv.pwszVal && *dbv.pwszVal) { cbi.pszCat = dbv.pwszVal; @@ -1383,12 +1383,12 @@ int CtrlContactAddMyItemsFromDB( *sms = 0; } cbi.wFlags |= wForcedFlags; - if (CB_ERR == SendMessage(hCtrl, CBEXM_ADDITEM, NULL, (LPARAM)&cbi)) + if (CB_ERR == SendMessage(hCtrl, CBEXM_ADDITEM, NULL, (LPARAM)&cbi)) break; bAnyItemIsChanged |= (cbi.wFlags & CTRLF_CHANGED) == CTRLF_CHANGED; - if (cbi.pszCat) { + if (cbi.pszCat) { mir_free(cbi.pszCat); - cbi.pszCat = nullptr; + cbi.pszCat = nullptr; } if (cbi.pszVal) { mir_free(cbi.pszVal); @@ -1406,18 +1406,18 @@ int CtrlContactAddMyItemsFromDB( * return: always 0 **/ int CtrlContactWriteItemToDB( - HWND hCtrl, - MCONTACT hContact, - LPCSTR pszModule, - LPCSTR pszProto, - LPCSTR pszSetting) + HWND hCtrl, + MCONTACT hContact, + LPCSTR pszModule, + LPCSTR pszProto, + LPCSTR pszSetting) { wchar_t szVal[MAXDATASIZE]; CBEXITEM cbi; if (!CtrlContactWndProc(hCtrl, CBEXM_ISCHANGED, NULL, NULL)) return 1; - cbi.wMask = CBEXIM_ID|CBEXIM_VAL|CBEXIM_FLAGS; + cbi.wMask = CBEXIM_ID | CBEXIM_VAL | CBEXIM_FLAGS; cbi.pszVal = szVal; cbi.ccVal = MAXDATASIZE - 4; cbi.iItem = 0; @@ -1447,13 +1447,13 @@ int CtrlContactWriteItemToDB( * return: always 0 **/ int CtrlContactWriteMyItemsToDB( - HWND hCtrl, - int iFirstItem, - MCONTACT hContact, - LPCSTR pszModule, - LPCSTR pszProto, - LPCSTR szFormatCat, - LPCSTR szFormatVal) + HWND hCtrl, + int iFirstItem, + MCONTACT hContact, + LPCSTR pszModule, + LPCSTR pszProto, + LPCSTR szFormatCat, + LPCSTR szFormatVal) { CHAR pszSetting[MAXSETTING]; wchar_t szCat[MAX_CAT]; @@ -1465,17 +1465,17 @@ int CtrlContactWriteMyItemsToDB( if (!CtrlContactWndProc(hCtrl, CBEXM_ISCHANGED, NULL, NULL)) return 1; if (!hContact && !(pszModule = pszProto)) return 1; - + pszOther = TranslateT("Other"); ccOther = mir_wstrlen(pszOther); - cbi.wMask = CBEXIM_CAT|CBEXIM_VAL|CBEXIM_FLAGS; + cbi.wMask = CBEXIM_CAT | CBEXIM_VAL | CBEXIM_FLAGS; cbi.pszCat = szCat; cbi.ccCat = MAX_CAT; cbi.pszVal = szVal; cbi.ccVal = MAXDATASIZE - 4; cbi.iItem = iFirstItem; cbi.dwID = 0; - + while (CtrlContactWndProc(hCtrl, CBEXM_GETITEM, NULL, (LPARAM)&cbi) && cbi.iItem < 50) { if (!(cbi.wFlags & CBEXIF_DELETED) && *szVal) { if (cbi.wFlags & CBEXIF_SMS) { @@ -1492,10 +1492,10 @@ int CtrlContactWriteMyItemsToDB( cbi.wFlags &= ~CTRLF_CHANGED; cbi.wMask = CBEXIM_FLAGS; CtrlContactWndProc(hCtrl, CBEXM_SETITEM, NULL, (LPARAM)&cbi); - cbi.wMask = CBEXIM_CAT|CBEXIM_VAL|CBEXIM_FLAGS; + cbi.wMask = CBEXIM_CAT | CBEXIM_VAL | CBEXIM_FLAGS; i++; } - + cbi.iItem++; } DB::Setting::DeleteArray(hContact, pszModule, szFormatCat, i); diff --git a/plugins/UserInfoEx/src/ctrl_contact.h b/plugins/UserInfoEx/src/ctrl_contact.h index 6216035542..df3e9f8858 100644 --- a/plugins/UserInfoEx/src/ctrl_contact.h +++ b/plugins/UserInfoEx/src/ctrl_contact.h @@ -54,23 +54,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CBEXIF_SMS (CTRLF_FIRST * 2) #define CBEXIF_DELETED (CTRLF_FIRST * 4) -typedef struct TComboExItem +struct CBEXITEM { - WORD wMask; // determines which element of this structure is valid - WORD wFlags; // standard control flags - int iItem; // position of the item in the data array - DWORD dwID; // unique number for each setting read from db to identify it, new entries have dwID = 0 - LPTSTR pszCat; // pointer to a descriptive category string to set or retrieve for the data entry - WORD ccCat; - LPTSTR pszVal; - WORD ccVal; - LPCSTR pszIcon; -} CBEXITEM, *LPCBEXITEM; + WORD wMask; // determines which element of this structure is valid + WORD wFlags; // standard control flags + int iItem; // position of the item in the data array + DWORD dwID; // unique number for each setting read from db to identify it, new entries have dwID = 0 + LPTSTR pszCat; // pointer to a descriptive category string to set or retrieve for the data entry + WORD ccCat; + LPTSTR pszVal; + WORD ccVal; + int iIcon; +}; int CtrlContactLoadModule(); int CtrlContactUnLoadModule(); -int CtrlContactAddItemFromDB(HWND hCtrl, LPCSTR szIcon, LPTSTR szItem, MCONTACT hContact, LPCSTR pszModule, LPCSTR pszProto, LPCSTR szSettingVal); -int CtrlContactAddMyItemsFromDB(HWND hCtrl, LPCSTR szIcon, WORD wForcedFlags, MCONTACT hContact, LPCSTR pszModule, LPCSTR pszProto, LPCSTR szFormatCat, LPCSTR szFormatVal); +int CtrlContactAddItemFromDB(HWND hCtrl, int iIcon, LPTSTR szItem, MCONTACT hContact, LPCSTR pszModule, LPCSTR pszProto, LPCSTR szSettingVal); +int CtrlContactAddMyItemsFromDB(HWND hCtrl, int iIcon, WORD wForcedFlags, MCONTACT hContact, LPCSTR pszModule, LPCSTR pszProto, LPCSTR szFormatCat, LPCSTR szFormatVal); int CtrlContactWriteItemToDB(HWND hCtrl, MCONTACT hContact, LPCSTR pszModule, LPCSTR pszProto, LPCSTR pszSetting); int CtrlContactWriteMyItemsToDB(HWND hCtrl, int iFirstItem, MCONTACT hContact, LPCSTR pszModule, LPCSTR pszProto, LPCSTR szFormatCat, LPCSTR szFormatVal); diff --git a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp index 3c3993eb9b..0533f11e57 100644 --- a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp +++ b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp @@ -283,7 +283,7 @@ class CAnnivList break; // set icons - hIcon = IcoLib_GetIcon(ICO_DLG_ANNIVERSARY); + hIcon = g_plugin.getIcon(IDI_ANNIVERSARY); SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)hIcon); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); diff --git a/plugins/UserInfoEx/src/dlg_msgbox.cpp b/plugins/UserInfoEx/src/dlg_msgbox.cpp index 80d049ec74..f335833190 100644 --- a/plugins/UserInfoEx/src/dlg_msgbox.cpp +++ b/plugins/UserInfoEx/src/dlg_msgbox.cpp @@ -107,53 +107,53 @@ static void MakePopupAction(POPUPACTION &pa, int id) switch (id) { case IDOK: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_OK); mir_strcpy(pa.lpzTitle, MODULENAME"/Ok"); break; case IDCLOSE: case IDCANCEL: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_CLOSE); mir_strcpy(pa.lpzTitle, MODULENAME"/Cancel"); break; case IDABORT: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_CLOSE); mir_strcpy(pa.lpzTitle, MODULENAME"/Abort"); break; case IDRETRY: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_UPDATE); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_UPDATE); mir_strcpy(pa.lpzTitle, MODULENAME"/Retry"); break; case IDIGNORE: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_OK); mir_strcpy(pa.lpzTitle, MODULENAME"/Ignore"); break; case IDYES: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_OK); mir_strcpy(pa.lpzTitle, MODULENAME"/Yes"); break; case IDNO: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_CLOSE); mir_strcpy(pa.lpzTitle, MODULENAME"/No"); break; case IDHELP: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_CLOSE); mir_strcpy(pa.lpzTitle, MODULENAME"/Help"); break; case IDALL: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_OK); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_OK); mir_strcpy(pa.lpzTitle, MODULENAME"/All"); break; case IDNONE: - pa.lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + pa.lchIcon = g_plugin.getIcon(IDI_BTN_CLOSE); mir_strcpy(pa.lpzTitle, MODULENAME"/None"); } } @@ -198,7 +198,7 @@ static INT_PTR CALLBACK MsgBoxProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l // set infobar's logo icon SendDlgItemMessage(hDlg, ICO_DLGLOGO, STM_SETIMAGE, IMAGE_ICON, - (pMsgBox->hiLogo ? (LPARAM)pMsgBox->hiLogo : (LPARAM)IcoLib_GetIcon(ICO_DLG_DETAILS,TRUE))); + (pMsgBox->hiLogo ? (LPARAM)pMsgBox->hiLogo : (LPARAM)g_plugin.getIcon(IDI_DLG_DETAILS, true))); // enable headerbar ShowWindow(GetDlgItem(hDlg, TXT_NAME), SW_SHOW); @@ -667,7 +667,7 @@ INT_PTR CALLBACK MsgBox(HWND hParent, UINT uType, LPCTSTR pszTitle, LPCTSTR pszI MSGBOX mb = { 0 }; mb.cbSize = sizeof(MSGBOX); mb.hParent = hParent; - mb.hiLogo = IcoLib_GetIcon(ICO_COMMON_MAIN); + mb.hiLogo = g_plugin.getIcon(IDI_MAIN); mb.hiMsg = nullptr; mb.ptszTitle = TranslateW(pszTitle); mb.ptszInfoText = TranslateW(pszInfo); @@ -694,7 +694,7 @@ INT_PTR CALLBACK MsgErr(HWND hParent, LPCTSTR pszFormat, ...) MSGBOX mb = {0}; mb.cbSize = sizeof(MSGBOX); mb.hParent = hParent; - mb.hiLogo = IcoLib_GetIcon(ICO_COMMON_MAIN); + mb.hiLogo = g_plugin.getIcon(IDI_MAIN); mb.hiMsg = nullptr; mb.ptszTitle = tszTitle; mb.ptszMsg = tszMsg; diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp index 4356f92b7b..666dbf5235 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.cpp +++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp @@ -240,9 +240,9 @@ static INT_PTR ShowDialog(WPARAM wParam, LPARAM) return 1; } - HICON hDefIcon = IcoLib_GetIcon(ICO_TREE_DEFAULT); + HICON hDefIcon = g_plugin.getIcon(IDI_LST_FOLDER); if (!hDefIcon) - hDefIcon = (HICON)IcoLib_GetIcon(ICO_COMMON_DEFAULT, false); + hDefIcon = (HICON)g_plugin.getIcon(IDI_DEFAULT, false); // add the default icon to imagelist ImageList_AddIcon(psh._hImages, hDefIcon); @@ -486,9 +486,9 @@ void DlgContactInfoInitTreeIcons() metrics.x = GetSystemMetrics(SM_CXSMICON); metrics.y = GetSystemMetrics(SM_CYSMICON); if (psh._hImages = ImageList_Create(metrics.x, metrics.y, ILC_COLOR32 | ILC_MASK, 0, 1)) { - HICON hDefIcon = IcoLib_GetIcon(ICO_TREE_DEFAULT); + HICON hDefIcon = g_plugin.getIcon(IDI_LST_FOLDER); if (!hDefIcon) - hDefIcon = (HICON)IcoLib_GetIcon(ICO_COMMON_DEFAULT, false); + hDefIcon = (HICON)g_plugin.getIcon(IDI_DEFAULT, false); // add the default icon to imagelist ImageList_AddIcon(psh._hImages, hDefIcon); @@ -590,7 +590,7 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar ShowWindow(GetDlgItem(hDlg, IDC_PAGETITLEBG2), !IsAeroMode()); // set icons - Window_SetIcon_IcoLib(hDlg, IcoLib_GetIconHandle(ICO_COMMON_MAIN)); + Window_SetIcon_IcoLib(hDlg, g_plugin.getIconHandle(IDI_MAIN)); DlgProc(hDlg, HM_RELOADICONS, NULL, NULL); // load basic protocol for current contact (for faster load later on and better handling for owner protocol) @@ -908,11 +908,11 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar HWND hCtrl; HICON hIcon; static const ICONCTRL idIcon[] = { - { ICO_DLG_DETAILS, STM_SETIMAGE, ICO_DLGLOGO }, - { ICO_BTN_UPDATE, BM_SETIMAGE, BTN_UPDATE }, - { ICO_BTN_OK, BM_SETIMAGE, IDOK }, - { ICO_BTN_CANCEL, BM_SETIMAGE, IDCANCEL }, - { ICO_BTN_APPLY, BM_SETIMAGE, IDAPPLY } + { IDI_DLG_DETAILS, STM_SETIMAGE, ICO_DLGLOGO }, + { IDI_BTN_UPDATE, BM_SETIMAGE, BTN_UPDATE }, + { IDI_BTN_OK, BM_SETIMAGE, IDOK }, + { IDI_BTN_CLOSE, BM_SETIMAGE, IDCANCEL }, + { IDI_BTN_APPLY, BM_SETIMAGE, IDAPPLY } }; const int numIconsToSet = g_plugin.getByte(SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 1; @@ -920,12 +920,12 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet); if (hCtrl = GetDlgItem(hDlg, BTN_IMPORT)) { - hIcon = IcoLib_GetIcon(ICO_BTN_IMPORT); + hIcon = g_plugin.getIcon(IDI_IMPORT); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetWindowText(hCtrl, hIcon ? L"" : L"I"); } if (hCtrl = GetDlgItem(hDlg, BTN_EXPORT)) { - hIcon = IcoLib_GetIcon(ICO_BTN_EXPORT); + hIcon = g_plugin.getIcon(IDI_EXPORT); SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetWindowText(hCtrl, hIcon ? L"" : L"E"); } diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp index 689e72c564..9a8e0f11d9 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImModules.cpp @@ -25,7 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * typedefs ***********************************************************************************************************/ -typedef struct { +typedef struct +{ lpExImParam ExImContact; DB::CEnumList* pModules; } EXPORTDATA, *LPEXPORTDATA; @@ -34,14 +35,14 @@ typedef struct { * modules stuff ***********************************************************************************************************/ -/** - * name: ExportTree_AppendModuleList - * desc: according to the checked list items create the module list for exporting - * param: hTree - handle to the window of the treeview - * hParent - parent tree item for the item to add - * pModules - module list to fill - * return: nothing - **/ + /** + * name: ExportTree_AppendModuleList + * desc: according to the checked list items create the module list for exporting + * param: hTree - handle to the window of the treeview + * hParent - parent tree item for the item to add + * pModules - module list to fill + * return: nothing + **/ void ExportTree_AppendModuleList(HWND hTree, HTREEITEM hParent, DB::CEnumList* pModules) { TVITEMA tvi; @@ -51,7 +52,7 @@ void ExportTree_AppendModuleList(HWND hTree, HTREEITEM hParent, DB::CEnumList* p CHAR szModule[MAXSETTING]; // add optional items - tvi.mask = TVIF_STATE|TVIF_TEXT; + tvi.mask = TVIF_STATE | TVIF_TEXT; tvi.stateMask = TVIS_STATEIMAGEMASK; tvi.pszText = szModule; tvi.cchTextMax = _countof(szModule); @@ -62,9 +63,8 @@ void ExportTree_AppendModuleList(HWND hTree, HTREEITEM hParent, DB::CEnumList* p ( tvi.state == INDEXTOSTATEIMAGEMASK(0) || tvi.state == INDEXTOSTATEIMAGEMASK(2) - ) - ) - { + ) + ) { pModules->Insert(tvi.pszText); } } @@ -93,8 +93,7 @@ HTREEITEM ExportTree_FindItem(HWND hTree, HTREEITEM hParent, LPSTR pszText) for (tvi.hItem = TreeView_GetChild(hTree, hParent); tvi.hItem != nullptr; - tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem)) - { + tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem)) { if (SendMessageA(hTree, TVM_GETITEMA, NULL, (LPARAM)&tvi) && !mir_strcmpi(tvi.pszText, pszText)) return tvi.hItem; } @@ -109,7 +108,7 @@ HTREEITEM ExportTree_FindItem(HWND hTree, HTREEITEM hParent, LPSTR pszText) * pszDesc - item label * bUseImages - icons are loaded * bState - 0-hide checkbox/1-unchecked/2-checked - * return: return handle to added treeitem + * return: return handle to added treeitem **/ HTREEITEM ExportTree_AddItem(HWND hTree, HTREEITEM hParent, LPSTR pszDesc, BYTE bUseImages, BYTE bState) { @@ -120,7 +119,7 @@ HTREEITEM ExportTree_AddItem(HWND hTree, HTREEITEM hParent, LPSTR pszDesc, BYTE tvii.hInsertAfter = TVI_SORT; tvii.itemex.mask = TVIF_TEXT; if (bUseImages) { - tvii.itemex.mask |= TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvii.itemex.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvii.itemex.iImage = tvii.itemex.iSelectedImage = 1; } tvii.itemex.pszText = pszDesc; @@ -143,7 +142,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar LPEXPORTDATA pDat = (LPEXPORTDATA)GetUserData(hDlg); switch (uMsg) { - case WM_INITDIALOG: + case WM_INITDIALOG: { BYTE bImagesLoaded = 0; @@ -155,17 +154,17 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar // init the datastructure if (!(pDat = (LPEXPORTDATA)mir_alloc(sizeof(EXPORTDATA)))) return FALSE; - pDat->ExImContact = ((LPEXPORTDATA)lParam)->ExImContact; - pDat->pModules = ((LPEXPORTDATA)lParam)->pModules; + pDat->ExImContact = ((LPEXPORTDATA)lParam)->ExImContact; + pDat->pModules = ((LPEXPORTDATA)lParam)->pModules; SetUserData(hDlg, pDat); // set icons { const ICONCTRL idIcon[] = { - { ICO_DLG_EXPORT, WM_SETICON, NULL }, - { ICO_DLG_EXPORT, STM_SETIMAGE, ICO_DLGLOGO }, - { ICO_BTN_EXPORT, BM_SETIMAGE, IDOK }, - { ICO_BTN_CANCEL, BM_SETIMAGE, IDCANCEL } + { IDI_EXPORT, WM_SETICON, NULL }, + { IDI_EXPORT, STM_SETIMAGE, ICO_DLGLOGO }, + { IDI_EXPORT, BM_SETIMAGE, IDOK }, + { IDI_BTN_CLOSE, BM_SETIMAGE, IDCANCEL } }; const int numIconsToSet = g_plugin.getByte(SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 2; IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet); @@ -174,15 +173,13 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (GetVersionEx(&osvi)) { - HIMAGELIST hImages = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON), - ((osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 5 && osvi.dwMinorVersion >= 1) ? ILC_COLOR32 : ILC_COLOR16)|ILC_MASK,0, 1); - if (hImages != nullptr) - { + HIMAGELIST hImages = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), + ((osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 5 && osvi.dwMinorVersion >= 1) ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 0, 1); + if (hImages != nullptr) { SendMessage(hTree, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)hImages); - - HICON hIcon; - bImagesLoaded = ((((hIcon = IcoLib_GetIcon(ICO_LST_MODULES)) != nullptr) && 0 == ImageList_AddIcon(hImages, hIcon)) - && (((hIcon = IcoLib_GetIcon(ICO_LST_FOLDER)) != nullptr) && 1 == ImageList_AddIcon(hImages, hIcon))); + g_plugin.addImgListIcon(hImages, IDI_LST_MODULES); + g_plugin.addImgListIcon(hImages, IDI_LST_FOLDER); + bImagesLoaded = true; } } } @@ -195,29 +192,29 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar } // Set the Window Title and description { - LPCTSTR name = nullptr; - wchar_t oldTitle[MAXDATASIZE], - newTitle[MAXDATASIZE]; + LPCTSTR name = nullptr; + wchar_t oldTitle[MAXDATASIZE], + newTitle[MAXDATASIZE]; switch (pDat->ExImContact->Typ) { - case EXIM_ALL: - case EXIM_GROUP: - name = TranslateT("All Contacts"); - break; - case EXIM_CONTACT: - if (pDat->ExImContact->hContact == NULL) { - name = TranslateT("Owner"); - } - else { - name = Clist_GetContactDisplayName(pDat->ExImContact->hContact); - } - break; - case EXIM_SUBGROUP: - name = (LPCTSTR) pDat->ExImContact->ptszName; - break; - case EXIM_ACCOUNT: - PROTOACCOUNT* acc = Proto_GetAccount(pDat->ExImContact->pszName); - name = (LPCTSTR) acc->tszAccountName; - break; + case EXIM_ALL: + case EXIM_GROUP: + name = TranslateT("All Contacts"); + break; + case EXIM_CONTACT: + if (pDat->ExImContact->hContact == NULL) { + name = TranslateT("Owner"); + } + else { + name = Clist_GetContactDisplayName(pDat->ExImContact->hContact); + } + break; + case EXIM_SUBGROUP: + name = (LPCTSTR)pDat->ExImContact->ptszName; + break; + case EXIM_ACCOUNT: + PROTOACCOUNT* acc = Proto_GetAccount(pDat->ExImContact->pszName); + name = (LPCTSTR)acc->tszAccountName; + break; } TranslateDialogDefault(hDlg); //to translate oldTitle GetWindowText(hDlg, oldTitle, _countof(oldTitle)); @@ -241,11 +238,11 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar // add items that are always exported tviiT.hParent = TVI_ROOT; tviiT.hInsertAfter = TVI_FIRST; - tviiT.itemex.mask = TVIF_TEXT|TVIF_STATE; + tviiT.itemex.mask = TVIF_TEXT | TVIF_STATE; tviiT.itemex.pszText = TranslateT("Required modules"); tviiT.itemex.state = tviiT.itemex.stateMask = TVIS_EXPANDED; if (bImagesLoaded) { - tviiT.itemex.mask |= TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tviiT.itemex.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE; tviiT.itemex.iImage = tviiT.itemex.iSelectedImage = 0; } if (hItemEssential = TreeView_InsertItem(hTree, &tviiT)) { @@ -275,8 +272,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar if (!Modules.EnumModules()) // init Modul list { - for (auto &p : Modules) - { + for (auto &p : Modules) { /*Filter/ if (!DB::Module::IsMeta(p))/end Filter*/ { @@ -284,44 +280,38 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar if (pDat->ExImContact->Typ != EXIM_CONTACT) // TRUE = All Contacts { MCONTACT hContact; - - for (hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) - { + + for (hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) { // ignore empty modules if (!DB::Module::IsEmpty(hContact, p)) { pszProto = Proto_GetBaseAccountName(hContact); // Filter by mode - switch (pDat->ExImContact->Typ) - { - case EXIM_ALL: - case EXIM_GROUP: - break; - case EXIM_SUBGROUP: - if (mir_wstrncmp(pDat->ExImContact->ptszName, DB::Setting::GetTString(hContact, "CList", "Group"), mir_wstrlen(pDat->ExImContact->ptszName))) { - continue; - } - break; - case EXIM_ACCOUNT: - if (mir_strcmp(pDat->ExImContact->pszName, pszProto)) { - continue; - } - break; + switch (pDat->ExImContact->Typ) { + case EXIM_ALL: + case EXIM_GROUP: + break; + case EXIM_SUBGROUP: + if (mir_wstrncmp(pDat->ExImContact->ptszName, DB::Setting::GetTString(hContact, "CList", "Group"), mir_wstrlen(pDat->ExImContact->ptszName))) { + continue; + } + break; + case EXIM_ACCOUNT: + if (mir_strcmp(pDat->ExImContact->pszName, pszProto)) { + continue; + } + break; } // contact's base protocol is to be added to the treeview uniquely - if (!mir_strcmpi(p, pszProto)) - { + if (!mir_strcmpi(p, pszProto)) { if (!ExportTree_FindItem(hTree, hItemEssential, p)) - { ExportTree_AddItem(hTree, hItemEssential, p, bImagesLoaded, 0); - } break; } // add optional module, which is valid for at least one contact /*/Filter/*/ - if (mir_strcmpi(p, USERINFO) && mir_strcmpi(p, MOD_MBIRTHDAY) && mir_strcmpi(p, META_PROTO)) - { + if (mir_strcmpi(p, USERINFO) && mir_strcmpi(p, MOD_MBIRTHDAY) && mir_strcmpi(p, META_PROTO)) { ExportTree_AddItem(hTree, hItemOptional, p, bImagesLoaded, 1); break; } @@ -336,8 +326,7 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar (!pDat->ExImContact->hContact || mir_strcmpi(p, pszProto)) && //mir_strcmpi(p, "Protocol") && mir_strcmpi(p, USERINFO) && - mir_strcmpi(p, MOD_MBIRTHDAY)) - { + mir_strcmpi(p, MOD_MBIRTHDAY)) { ExportTree_AddItem(hTree, hItemOptional, (LPSTR)p, bImagesLoaded, 1); } } // end @@ -346,74 +335,72 @@ INT_PTR CALLBACK SelectModulesToExport_DlgProc(HWND hDlg, UINT uMsg, WPARAM wPar } } TranslateDialogDefault(hDlg); - return TRUE; } - case WM_CTLCOLORSTATIC: - if (GetDlgItem(hDlg, STATIC_WHITERECT) == (HWND)lParam || GetDlgItem(hDlg, ICO_DLGLOGO) == (HWND)lParam) { - SetBkColor((HDC)wParam, RGB(255, 255, 255)); - return (INT_PTR)GetStockObject(WHITE_BRUSH); - } - SetBkMode((HDC)wParam, TRANSPARENT); - return (INT_PTR)GetStockObject(NULL_BRUSH); - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - { - HWND hTree = GetDlgItem(hDlg, IDC_TREE); - HTREEITEM hParent; - - // search the tree item of optional items - for (hParent = TreeView_GetRoot(hTree); - hParent != nullptr; - hParent = TreeView_GetNextSibling(hTree, hParent)) - { - ExportTree_AppendModuleList(hTree, hParent, pDat->pModules); - } - return EndDialog(hDlg, IDOK); + return TRUE; + + case WM_CTLCOLORSTATIC: + if (GetDlgItem(hDlg, STATIC_WHITERECT) == (HWND)lParam || GetDlgItem(hDlg, ICO_DLGLOGO) == (HWND)lParam) { + SetBkColor((HDC)wParam, RGB(255, 255, 255)); + return (INT_PTR)GetStockObject(WHITE_BRUSH); + } + SetBkMode((HDC)wParam, TRANSPARENT); + return (INT_PTR)GetStockObject(NULL_BRUSH); + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + { + HWND hTree = GetDlgItem(hDlg, IDC_TREE); + HTREEITEM hParent; + + // search the tree item of optional items + for (hParent = TreeView_GetRoot(hTree); + hParent != nullptr; + hParent = TreeView_GetNextSibling(hTree, hParent)) { + ExportTree_AppendModuleList(hTree, hParent, pDat->pModules); } - case IDCANCEL: - return EndDialog(hDlg, IDCANCEL); - - case BTN_CHECK: - case BTN_UNCHECK: - { - HWND hTree = GetDlgItem(hDlg, IDC_TREE); - LPCSTR pszRoot = Translate("Optional modules"); - TVITEMA tvi; - CHAR szText[128]; - - tvi.mask = TVIF_TEXT; - tvi.pszText = szText; - tvi.cchTextMax = _countof(szText); - - // search the tree item of optional items - for (tvi.hItem = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_ROOT, NULL); - tvi.hItem != nullptr && SendMessageA(hTree, TVM_GETITEMA, 0, (LPARAM)&tvi); - tvi.hItem = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)tvi.hItem)) - { - if (!mir_strcmpi(tvi.pszText, pszRoot)) { - tvi.mask = TVIF_STATE; - tvi.state = INDEXTOSTATEIMAGEMASK(LOWORD(wParam) == BTN_UNCHECK ? 1 : 2); - tvi.stateMask = TVIS_STATEIMAGEMASK; - - for (tvi.hItem = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)tvi.hItem); - tvi.hItem != nullptr; - tvi.hItem = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)tvi.hItem)) - { - SendMessageA(hTree, TVM_SETITEMA, NULL, (LPARAM)&tvi); - } - break; + return EndDialog(hDlg, IDOK); + } + case IDCANCEL: + return EndDialog(hDlg, IDCANCEL); + + case BTN_CHECK: + case BTN_UNCHECK: + { + HWND hTree = GetDlgItem(hDlg, IDC_TREE); + LPCSTR pszRoot = Translate("Optional modules"); + TVITEMA tvi; + CHAR szText[128]; + + tvi.mask = TVIF_TEXT; + tvi.pszText = szText; + tvi.cchTextMax = _countof(szText); + + // search the tree item of optional items + for (tvi.hItem = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_ROOT, NULL); + tvi.hItem != nullptr && SendMessageA(hTree, TVM_GETITEMA, 0, (LPARAM)&tvi); + tvi.hItem = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)tvi.hItem)) { + if (!mir_strcmpi(tvi.pszText, pszRoot)) { + tvi.mask = TVIF_STATE; + tvi.state = INDEXTOSTATEIMAGEMASK(LOWORD(wParam) == BTN_UNCHECK ? 1 : 2); + tvi.stateMask = TVIS_STATEIMAGEMASK; + + for (tvi.hItem = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)tvi.hItem); + tvi.hItem != nullptr; + tvi.hItem = (HTREEITEM)SendMessageA(hTree, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)tvi.hItem)) { + SendMessageA(hTree, TVM_SETITEMA, NULL, (LPARAM)&tvi); } + break; } - break; } + break; } - break; + } + break; - case WM_DESTROY: - mir_free(pDat); - break; + case WM_DESTROY: + mir_free(pDat); + break; } return 0; } @@ -434,4 +421,3 @@ int DlgExImModules_SelectModulesToExport(lpExImParam ExImContact, DB::CEnumList* dat.pModules = pModules; return (IDOK != DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_EXPORT), hParent, SelectModulesToExport_DlgProc, (LPARAM)&dat)); } - diff --git a/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp b/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp index 8e4ca959ae..3535f8d261 100644 --- a/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp +++ b/plugins/UserInfoEx/src/ex_import/dlg_ExImProgress.cpp @@ -38,9 +38,9 @@ INT_PTR CALLBACK DlgProcProgress(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPar case WM_INITDIALOG: { const ICONCTRL idIcon[] = { - { ICO_DLG_IMPORT, WM_SETICON, NULL }, - { ICO_DLG_IMPORT, STM_SETIMAGE, ICO_DLGLOGO }, - { ICO_BTN_CANCEL, BM_SETIMAGE, IDCANCEL } + { IDI_IMPORT, WM_SETICON, NULL }, + { IDI_IMPORT, STM_SETIMAGE, ICO_DLGLOGO }, + { IDI_BTN_CLOSE, BM_SETIMAGE, IDCANCEL } }; const int numIconsToSet = g_plugin.getByte(SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 2; IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet); diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp index 67344160c0..8dd883c6c8 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp @@ -30,10 +30,10 @@ INT_PTR CALLBACK DlgProc_DataHistory(HWND hDlg, UINT msg, WPARAM wParam, LPARAM TranslateDialogDefault(hDlg); { const ICONCTRL idIcon[] = { - { ICO_DLG_EXPORT, WM_SETICON, NULL }, - { ICO_DLG_EXPORT, STM_SETIMAGE, ICO_DLGLOGO }, - { ICO_BTN_EXPORT, BM_SETIMAGE, IDOK }, - { ICO_BTN_CANCEL, BM_SETIMAGE, IDCANCEL } + { IDI_EXPORT, WM_SETICON, NULL }, + { IDI_EXPORT, STM_SETIMAGE, ICO_DLGLOGO }, + { IDI_EXPORT, BM_SETIMAGE, IDOK }, + { IDI_BTN_CLOSE, BM_SETIMAGE, IDCANCEL } }; const int numIconsToSet = g_plugin.getByte(SET_ICONS_BUTTONS, 1) ? _countof(idIcon) : 2; IcoLib_SetCtrlIcons(hDlg, idIcon, numIconsToSet); diff --git a/plugins/UserInfoEx/src/init.cpp b/plugins/UserInfoEx/src/init.cpp index 6d017b966f..cc5389422a 100644 --- a/plugins/UserInfoEx/src/init.cpp +++ b/plugins/UserInfoEx/src/init.cpp @@ -67,18 +67,18 @@ static int OnTopToolBarLoaded(WPARAM, LPARAM) TTBButton ttb = {}; ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; ttb.pszService = MS_USERINFO_SHOWDIALOG; - ttb.hIconHandleUp = IcoLib_GetIconHandle(ICO_COMMON_MAIN); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_MAIN); ttb.name = ttb.pszTooltipUp = LPGEN("User &details"); g_plugin.addTTB(&ttb); ttb.dwFlags = TTBBF_SHOWTOOLTIP; ttb.pszService = MS_USERINFO_REMINDER_LIST; - ttb.hIconHandleUp = IcoLib_GetIconHandle(ICO_COMMON_ANNIVERSARY); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_ANNIVERSARY); ttb.name = ttb.pszTooltipUp = LPGEN("Anniversary list"); g_plugin.addTTB(&ttb); ttb.pszService = MS_USERINFO_REMINDER_CHECK; - ttb.hIconHandleUp = IcoLib_GetIconHandle(ICO_COMMON_BIRTHDAY); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_BIRTHDAY); ttb.name = ttb.pszTooltipUp = LPGEN("Check anniversaries"); g_plugin.addTTB(&ttb); return 0; diff --git a/plugins/UserInfoEx/src/mir_icolib.cpp b/plugins/UserInfoEx/src/mir_icolib.cpp index a703d3d457..8d13206a7c 100644 --- a/plugins/UserInfoEx/src/mir_icolib.cpp +++ b/plugins/UserInfoEx/src/mir_icolib.cpp @@ -23,109 +23,109 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static IconItem common[] = { - { LPGEN("Main"), ICO_COMMON_MAIN, IDI_MAIN }, - { LPGEN("Default"), ICO_COMMON_DEFAULT, IDI_DEFAULT } + { LPGEN("Main"), "common_main", IDI_MAIN }, + { LPGEN("Default"), "common_default", IDI_DEFAULT } }; static IconItem icons1[] = { // common - { ICO_COMMON_IM, LPGEN("IM naming"), IDI_MIRANDA }, - { ICO_COMMON_PASSWORD, LPGEN("Password"), IDI_PASSWORD }, - { ICO_COMMON_FEMALE, LPGEN("Female"), IDI_FEMALE }, - { ICO_COMMON_MALE, LPGEN("Male"), IDI_MALE }, - { ICO_COMMON_BIRTHDAY, LPGEN("Birthday"), IDI_BIRTHDAY }, - { ICO_COMMON_CLOCK, LPGEN("Timezone"), IDI_CLOCK, 32 }, - { ICO_COMMON_MARITAL, LPGEN("Marital status"), IDI_MARITAL }, - { ICO_COMMON_ADDRESS, LPGEN("Address"), IDI_TREE_ADDRESS }, - { ICO_COMMON_ANNIVERSARY,LPGEN("Anniversary"), IDI_ANNIVERSARY }, + { "common_im", LPGEN("IM naming"), IDI_MIRANDA }, + { "common_password", LPGEN("Password"), IDI_PASSWORD }, + { "common_female", LPGEN("Female"), IDI_FEMALE }, + { "common_male", LPGEN("Male"), IDI_MALE }, + { "common_birthday", LPGEN("Birthday"), IDI_BIRTHDAY }, + { "common_clock", LPGEN("Timezone"), IDI_CLOCK, 32 }, + { "common_marital", LPGEN("Marital status"), IDI_MARITAL }, + { "common_address", LPGEN("Address"), IDI_TREE_ADDRESS }, + { "common_anniversary", LPGEN("Anniversary"), IDI_ANNIVERSARY }, // zodiac - { ICO_ZOD_AQUARIUS, LPGEN("Aquarius"), IDI_ZOD_AQUARIUS, 128 }, - { ICO_ZOD_ARIES, LPGEN("Aries"), IDI_ZOD_ARIES, 128 }, - { ICO_ZOD_CANCER, LPGEN("Cancer"), IDI_ZOD_CANCER, 128 }, - { ICO_ZOD_CAPRICORN, LPGEN("Capricorn"), IDI_ZOD_CAPRICORN, 128 }, - { ICO_ZOD_GEMINI, LPGEN("Gemini"), IDI_ZOD_GEMINI, 128 }, - { ICO_ZOD_LEO, LPGEN("Leo"), IDI_ZOD_LEO, 128 }, - { ICO_ZOD_LIBRA, LPGEN("Libra"), IDI_ZOD_LIBRA, 128 }, - { ICO_ZOD_PISCES, LPGEN("Pisces"), IDI_ZOD_PISCES, 128 }, - { ICO_ZOD_SAGITTARIUS, LPGEN("Sagittarius"), IDI_ZOD_SAGITTARIUS, 128 }, - { ICO_ZOD_SCORPIO, LPGEN("Scorpio"), IDI_ZOD_SCORPIO, 128 }, - { ICO_ZOD_TAURUS, LPGEN("Taurus"), IDI_ZOD_TAURUS, 128 }, - { ICO_ZOD_VIRGO, LPGEN("Virgo"), IDI_ZOD_VIRGO, 128 }, + { "zod_aquarius", LPGEN("Aquarius"), IDI_ZOD_AQUARIUS, 128 }, + { "zod_aries", LPGEN("Aries"), IDI_ZOD_ARIES, 128 }, + { "zod_cancer", LPGEN("Cancer"), IDI_ZOD_CANCER, 128 }, + { "zod_capricorn", LPGEN("Capricorn"), IDI_ZOD_CAPRICORN, 128 }, + { "zod_gemini", LPGEN("Gemini"), IDI_ZOD_GEMINI, 128 }, + { "zod_leo", LPGEN("Leo"), IDI_ZOD_LEO, 128 }, + { "zod_libra", LPGEN("Libra"), IDI_ZOD_LIBRA, 128 }, + { "zod_pisces", LPGEN("Pisces"), IDI_ZOD_PISCES, 128 }, + { "zod_sagittarius", LPGEN("Sagittarius"), IDI_ZOD_SAGITTARIUS, 128 }, + { "zod_scorpio", LPGEN("Scorpio"), IDI_ZOD_SCORPIO, 128 }, + { "zod_taurus", LPGEN("Taurus"), IDI_ZOD_TAURUS, 128 }, + { "zod_virgo", LPGEN("Virgo"), IDI_ZOD_VIRGO, 128 }, // lists - { ICO_LST_MODULES, LPGEN("Export: modules"), IDI_LST_MODULES }, - { ICO_LST_FOLDER, LPGEN("Export: folder"), IDI_LST_FOLDER }, + { "lst_modules", LPGEN("Export: modules"), IDI_LST_MODULES }, + { "lst_folder", LPGEN("Export: folder"), IDI_LST_FOLDER }, }; static IconItem icons2[] = { // tree - { ICO_TREE_DEFAULT, LPGEN("Default"), IDI_LST_FOLDER }, + { "tree_default", LPGEN("Default"), IDI_LST_FOLDER }, }; static IconItem icons3[] = { // dialogs - { ICO_DLG_DETAILS, LPGEN("Details info bar"), IDI_DLG_DETAILS, 48 }, - { ICO_DLG_PHONE, LPGEN("Phone info bar"), IDI_DLG_PHONE, 32 }, - { ICO_DLG_EMAIL, LPGEN("E-mail info bar"), IDI_DLG_EMAIL, 32 }, - { ICO_DLG_EXPORT, LPGEN("Export VCard"), IDI_EXPORT, 32 }, - { ICO_DLG_IMPORT, LPGEN("Import VCard"), IDI_IMPORT, 32 }, - { ICO_DLG_ANNIVERSARY, LPGEN("Anniversary info bar"), IDI_ANNIVERSARY, 32 }, + { "dlg_details", LPGEN("Details info bar"), IDI_DLG_DETAILS, 48 }, + { "dlg_phone", LPGEN("Phone info bar"), IDI_DLG_PHONE, 32 }, + { "dlg_email", LPGEN("E-mail info bar"), IDI_DLG_EMAIL, 32 }, + { "dlg_export", LPGEN("Export VCard"), IDI_EXPORT, 32 }, + { "dlg_import", LPGEN("Import VCard"), IDI_IMPORT, 32 }, + { "dlg_anniversary", LPGEN("Anniversary info bar"), IDI_ANNIVERSARY, 32 }, }; static IconItem icons4[] = { // button icons - { ICO_BTN_UPDATE, LPGEN("Update"), IDI_BTN_UPDATE }, - { ICO_BTN_IMPORT, LPGEN("Import"), IDI_IMPORT }, - { ICO_BTN_EXPORT, LPGEN("Export"), IDI_EXPORT }, - { ICO_BTN_OK, LPGEN("OK"), IDI_BTN_OK }, - { ICO_BTN_CANCEL, LPGEN("Cancel"), IDI_BTN_CLOSE }, - { ICO_BTN_APPLY, LPGEN("Apply"), IDI_BTN_APPLY }, - { ICO_BTN_GOTO, LPGEN("Goto"), IDI_BTN_GOTO }, - { ICO_BTN_PHONE, LPGEN("Phone"), IDI_BTN_PHONE }, - { ICO_BTN_FAX, LPGEN("Fax"), IDI_BTN_FAX }, - { ICO_BTN_CELLULAR, LPGEN("Cellular"), IDI_BTN_CELLULAR }, - { ICO_BTN_CUSTOMPHONE, LPGEN("Custom phone"), IDI_BTN_CUSTOMPHONE }, - { ICO_BTN_EMAIL, LPGEN("E-mail"), IDI_BTN_EMAIL }, - { ICO_BTN_DOWNARROW, LPGEN("Down arrow"), IDI_BTN_DOWNARROW }, - { ICO_BTN_ADD, LPGEN("Add"), IDI_BTN_ADD }, - { ICO_BTN_EDIT, LPGEN("Edit"), IDI_BTN_EDIT }, - { ICO_BTN_DELETE, LPGEN("Delete"), IDI_BTN_DELETE }, - { ICO_BTN_SEARCH, LPGEN("Search"), IDI_SEARCH }, - { ICO_BTN_EXIMPORT, LPGEN("Export/import"), IDI_BTN_EXIMPORT }, - { ICO_BTN_BDAY_BACKUP, LPGEN("Backup birthday"), IDI_BTN_BIRTHDAY_BACKUP }, + { "btn_update", LPGEN("Update"), IDI_BTN_UPDATE }, + { "btn_import", LPGEN("Import"), IDI_IMPORT }, + { "btn_export", LPGEN("Export"), IDI_EXPORT }, + { "btn_ok", LPGEN("OK"), IDI_BTN_OK }, + { "btn_cancel", LPGEN("Cancel"), IDI_BTN_CLOSE }, + { "btn_apply", LPGEN("Apply"), IDI_BTN_APPLY }, + { "btn_goto", LPGEN("Goto"), IDI_BTN_GOTO }, + { "btn_phone", LPGEN("Phone"), IDI_BTN_PHONE }, + { "btn_fax", LPGEN("Fax"), IDI_BTN_FAX }, + { "btn_cellular", LPGEN("Cellular"), IDI_BTN_CELLULAR }, + { "btn_customphone", LPGEN("Custom phone"), IDI_BTN_CUSTOMPHONE }, + { "btn_email", LPGEN("E-mail"), IDI_BTN_EMAIL }, + { "btn_downarrow", LPGEN("Down arrow"), IDI_BTN_DOWNARROW }, + { "btn_add", LPGEN("Add"), IDI_BTN_ADD }, + { "btn_edit", LPGEN("Edit"), IDI_BTN_EDIT }, + { "btn_delete", LPGEN("Delete"), IDI_BTN_DELETE }, + { "btn_search", LPGEN("Search"), IDI_SEARCH }, + { "btn_eximport", LPGEN("Export/import"), IDI_BTN_EXIMPORT }, + { "btn_bdaybackup", LPGEN("Backup birthday"), IDI_BTN_BIRTHDAY_BACKUP }, }; static IconItem icons5[] = { // birthday and anniversary - { ICO_RMD_DTB0, LPGEN("Birthday today"), IDI_RMD_DTB0 }, - { ICO_RMD_DTB1, LPGEN("Birthday tomorrow"), IDI_RMD_DTB1 }, - { ICO_RMD_DTB2, LPGEN("Birthday in 2 days"), IDI_RMD_DTB2 }, - { ICO_RMD_DTB3, LPGEN("Birthday in 3 days"), IDI_RMD_DTB3 }, - { ICO_RMD_DTB4, LPGEN("Birthday in 4 days"), IDI_RMD_DTB4 }, - { ICO_RMD_DTB5, LPGEN("Birthday in 5 days"), IDI_RMD_DTB5 }, - { ICO_RMD_DTB6, LPGEN("Birthday in 6 days"), IDI_RMD_DTB6 }, - { ICO_RMD_DTB7, LPGEN("Birthday in 7 days"), IDI_RMD_DTB7 }, - { ICO_RMD_DTB8, LPGEN("Birthday in 8 days"), IDI_RMD_DTB8 }, - { ICO_RMD_DTB9, LPGEN("Birthday in 9 days"), IDI_RMD_DTB9 }, - { ICO_RMD_DTBX, LPGEN("Birthday later"), IDI_RMD_DTBX }, - - { ICO_RMD_DTA0, LPGEN("Anniversary today"), IDI_RMD_DTA0 }, - { ICO_RMD_DTA1, LPGEN("Anniversary tomorrow"), IDI_RMD_DTA1 }, - { ICO_RMD_DTA2, LPGEN("Anniversary in 2 days"), IDI_RMD_DTA2 }, - { ICO_RMD_DTA3, LPGEN("Anniversary in 3 days"), IDI_RMD_DTA3 }, - { ICO_RMD_DTA4, LPGEN("Anniversary in 4 days"), IDI_RMD_DTA4 }, - { ICO_RMD_DTA5, LPGEN("Anniversary in 5 days"), IDI_RMD_DTA5 }, - { ICO_RMD_DTA6, LPGEN("Anniversary in 6 days"), IDI_RMD_DTA6 }, - { ICO_RMD_DTA7, LPGEN("Anniversary in 7 days"), IDI_RMD_DTA7 }, - { ICO_RMD_DTA8, LPGEN("Anniversary in 8 days"), IDI_RMD_DTA8 }, - { ICO_RMD_DTA9, LPGEN("Anniversary in 9 days"), IDI_RMD_DTA9 }, - { ICO_RMD_DTAX, LPGEN("Anniversary later"), IDI_RMD_DTAX }, + { "rmd_dtb0", LPGEN("Birthday today"), IDI_RMD_DTB0 }, + { "rmd_dtb1", LPGEN("Birthday tomorrow"), IDI_RMD_DTB1 }, + { "rmd_dtb2", LPGEN("Birthday in 2 days"), IDI_RMD_DTB2 }, + { "rmd_dtb3", LPGEN("Birthday in 3 days"), IDI_RMD_DTB3 }, + { "rmd_dtb4", LPGEN("Birthday in 4 days"), IDI_RMD_DTB4 }, + { "rmd_dtb5", LPGEN("Birthday in 5 days"), IDI_RMD_DTB5 }, + { "rmd_dtb6", LPGEN("Birthday in 6 days"), IDI_RMD_DTB6 }, + { "rmd_dtb7", LPGEN("Birthday in 7 days"), IDI_RMD_DTB7 }, + { "rmd_dtb8", LPGEN("Birthday in 8 days"), IDI_RMD_DTB8 }, + { "rmd_dtb9", LPGEN("Birthday in 9 days"), IDI_RMD_DTB9 }, + { "rmd_dtbx", LPGEN("Birthday later"), IDI_RMD_DTBX }, + + { "rmd_dta0", LPGEN("Anniversary today"), IDI_RMD_DTA0 }, + { "rmd_dta1", LPGEN("Anniversary tomorrow"), IDI_RMD_DTA1 }, + { "rmd_dta2", LPGEN("Anniversary in 2 days"), IDI_RMD_DTA2 }, + { "rmd_dta3", LPGEN("Anniversary in 3 days"), IDI_RMD_DTA3 }, + { "rmd_dta4", LPGEN("Anniversary in 4 days"), IDI_RMD_DTA4 }, + { "rmd_dta5", LPGEN("Anniversary in 5 days"), IDI_RMD_DTA5 }, + { "rmd_dta6", LPGEN("Anniversary in 6 days"), IDI_RMD_DTA6 }, + { "rmd_dta7", LPGEN("Anniversary in 7 days"), IDI_RMD_DTA7 }, + { "rmd_dta8", LPGEN("Anniversary in 8 days"), IDI_RMD_DTA8 }, + { "rmd_dta9", LPGEN("Anniversary in 9 days"), IDI_RMD_DTA9 }, + { "rmd_dtax", LPGEN("Anniversary later"), IDI_RMD_DTAX }, }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -182,7 +182,7 @@ static HINSTANCE IcoLib_CheckIconPackVersion(wchar_t *szIconPack) void IcoLib_SetCtrlIcons(HWND hDlg, const ICONCTRL *pCtrl, BYTE numCtrls) { for (int i = 0; i < numCtrls; i++) { - HICON hIcon = IcoLib_GetIcon(pCtrl[i].pszIcon); + HICON hIcon = g_plugin.getIcon(pCtrl[i].iIcon); if (!pCtrl[i].idCtrl) { SendMessage(hDlg, pCtrl[i].Message, ICON_BIG, (LPARAM)hIcon); continue; @@ -206,16 +206,16 @@ void IcoLib_SetCtrlIcons(HWND hDlg, const ICONCTRL *pCtrl, BYTE numCtrls) void IcoLib_LoadModule() { - g_plugin.registerIcon(SECT_COMMON, common); + g_plugin.registerIcon(SECT_COMMON, common, MODULENAME); wchar_t *szDefaultFile = IcoLib_GetDefaultIconFileName(); HINSTANCE hIconPack = IcoLib_CheckIconPackVersion(szDefaultFile); if (hIconPack) { - Icon_Register(hIconPack, SECT_COMMON, icons1, _countof(icons1), 0, &g_plugin); - Icon_Register(hIconPack, SECT_TREE, icons2, _countof(icons2), 0, &g_plugin); - Icon_Register(hIconPack, SECT_DLG, icons3, _countof(icons3), 0, &g_plugin); - Icon_Register(hIconPack, SECT_BUTTONS, icons4, _countof(icons4), 0, &g_plugin); - Icon_Register(hIconPack, SECT_REMIND, icons5, _countof(icons5), 0, &g_plugin); + Icon_Register(hIconPack, SECT_COMMON, icons1, _countof(icons1), MODULENAME, &g_plugin); + Icon_Register(hIconPack, SECT_TREE, icons2, _countof(icons2), MODULENAME, &g_plugin); + Icon_Register(hIconPack, SECT_DLG, icons3, _countof(icons3), MODULENAME, &g_plugin); + Icon_Register(hIconPack, SECT_BUTTONS, icons4, _countof(icons4), MODULENAME, &g_plugin); + Icon_Register(hIconPack, SECT_REMIND, icons5, _countof(icons5), MODULENAME, &g_plugin); FreeLibrary(hIconPack); } } diff --git a/plugins/UserInfoEx/src/mir_icolib.h b/plugins/UserInfoEx/src/mir_icolib.h index de9424ac25..e632d47394 100644 --- a/plugins/UserInfoEx/src/mir_icolib.h +++ b/plugins/UserInfoEx/src/mir_icolib.h @@ -29,101 +29,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SECT_TREE LPGEN("Extended user info") "/" LPGEN("Treeview") #define SECT_REMIND LPGEN("Extended user info") "/" LPGEN("Reminder") -// icons -#define ICO_COMMON_MAIN MODULENAME"_common_main" -#define ICO_COMMON_DEFAULT MODULENAME"_common_default" -#define ICO_COMMON_IM MODULENAME"_common_im" -#define ICO_COMMON_FEMALE MODULENAME"_common_female" -#define ICO_COMMON_MALE MODULENAME"_common_male" -#define ICO_COMMON_BIRTHDAY MODULENAME"_common_birthday" -#define ICO_COMMON_ANNIVERSARY MODULENAME"_common_anniversary" -#define ICO_COMMON_CLOCK MODULENAME"_common_clock" -#define ICO_COMMON_MARITAL MODULENAME"_common_marital" -#define ICO_COMMON_PASSWORD MODULENAME"_common_password" -#define ICO_COMMON_ADDRESS MODULENAME"_common_address" -#define ICO_DLG_DETAILS MODULENAME"_dlg_details" -#define ICO_DLG_PHONE MODULENAME"_dlg_phone" -#define ICO_DLG_EMAIL MODULENAME"_dlg_email" -#define ICO_DLG_EXPORT MODULENAME"_dlg_export" -#define ICO_DLG_IMPORT MODULENAME"_dlg_import" -#define ICO_DLG_ANNIVERSARY MODULENAME"_dlg_anniversary" -#define ICO_DLG_SEARCH MODULENAME"_dlg_search" -#define ICO_LST_MODULES MODULENAME"_lst_modules" -#define ICO_LST_FOLDER MODULENAME"_lst_folder" -#define ICO_BTN_UPDATE MODULENAME"_btn_update" -#define ICO_BTN_OK MODULENAME"_btn_ok" -#define ICO_BTN_CANCEL MODULENAME"_btn_cancel" -#define ICO_BTN_APPLY MODULENAME"_btn_apply" -#define ICO_BTN_GOTO MODULENAME"_btn_goto" -#define ICO_BTN_ADD MODULENAME"_btn_add" -#define ICO_BTN_EDIT MODULENAME"_btn_edit" -#define ICO_BTN_DELETE MODULENAME"_btn_delete" -#define ICO_BTN_IMPORT MODULENAME"_btn_import" -#define ICO_BTN_EXPORT MODULENAME"_btn_export" -#define ICO_BTN_NOTES MODULENAME"_btn_notes" -#define ICO_BTN_ABOUT MODULENAME"_btn_about" -#define ICO_BTN_PROFILE MODULENAME"_btn_profile" -#define ICO_BTN_DOWNARROW MODULENAME"_btn_downarrow" -#define ICO_BTN_PHONE MODULENAME"_btn_phone" -#define ICO_BTN_FAX MODULENAME"_btn_fax" -#define ICO_BTN_CELLULAR MODULENAME"_btn_cellular" -#define ICO_BTN_CUSTOMPHONE MODULENAME"_btn_customphone" -#define ICO_BTN_EMAIL MODULENAME"_btn_email" -#define ICO_BTN_SEARCH MODULENAME"_btn_search" -#define ICO_BTN_EXIMPORT MODULENAME"_btn_eximport" -#define ICO_BTN_BDAY_BACKUP MODULENAME"_btn_bdaybackup" -#define ICO_BTN_YES MODULENAME"_btn_yes" -#define ICO_BTN_NO MODULENAME"_btn_no" -#define ICO_BTN_IGNORE MODULENAME"_btn_ignore" -#define ICO_ZOD_AQUARIUS MODULENAME"_zod_aquarius" -#define ICO_ZOD_ARIES MODULENAME"_zod_aries" -#define ICO_ZOD_CANCER MODULENAME"_zod_cancer" -#define ICO_ZOD_CAPRICORN MODULENAME"_zod_capricorn" -#define ICO_ZOD_GEMINI MODULENAME"_zod_gemini" -#define ICO_ZOD_LEO MODULENAME"_zod_leo" -#define ICO_ZOD_LIBRA MODULENAME"_zod_libra" -#define ICO_ZOD_PISCES MODULENAME"_zod_pisces" -#define ICO_ZOD_SAGITTARIUS MODULENAME"_zod_sagittarius" -#define ICO_ZOD_SCORPIO MODULENAME"_zod_scorpio" -#define ICO_ZOD_TAURUS MODULENAME"_zod_taurus" -#define ICO_ZOD_VIRGO MODULENAME"_zod_virgo" -#define ICO_TREE_DEFAULT MODULENAME"_tree_default" - -#define ICO_RMD_DTB0 MODULENAME"_rmd_dtb0" -#define ICO_RMD_DTB1 MODULENAME"_rmd_dtb1" -#define ICO_RMD_DTB2 MODULENAME"_rmd_dtb2" -#define ICO_RMD_DTB3 MODULENAME"_rmd_dtb3" -#define ICO_RMD_DTB4 MODULENAME"_rmd_dtb4" -#define ICO_RMD_DTB5 MODULENAME"_rmd_dtb5" -#define ICO_RMD_DTB6 MODULENAME"_rmd_dtb6" -#define ICO_RMD_DTB7 MODULENAME"_rmd_dtb7" -#define ICO_RMD_DTB8 MODULENAME"_rmd_dtb8" -#define ICO_RMD_DTB9 MODULENAME"_rmd_dtb9" -#define ICO_RMD_DTBX MODULENAME"_rmd_dtbx" - -#define ICO_RMD_DTA0 MODULENAME"_rmd_dta0" -#define ICO_RMD_DTA1 MODULENAME"_rmd_dta1" -#define ICO_RMD_DTA2 MODULENAME"_rmd_dta2" -#define ICO_RMD_DTA3 MODULENAME"_rmd_dta3" -#define ICO_RMD_DTA4 MODULENAME"_rmd_dta4" -#define ICO_RMD_DTA5 MODULENAME"_rmd_dta5" -#define ICO_RMD_DTA6 MODULENAME"_rmd_dta6" -#define ICO_RMD_DTA7 MODULENAME"_rmd_dta7" -#define ICO_RMD_DTA8 MODULENAME"_rmd_dta8" -#define ICO_RMD_DTA9 MODULENAME"_rmd_dta9" -#define ICO_RMD_DTAX MODULENAME"_rmd_dtax" - #define SET_ICONS_CHECKFILEVERSION "CheckIconPackVersion" #define SET_ICONS_BUTTONS "ButtonIcons" #define ICONINDEX(id) max((min((id), IDI_LASTICON)) - IDI_FIRST_ICON, 0) -typedef struct TIconCtrl +struct ICONCTRL { - LPCSTR pszIcon; - UINT Message; - WORD idCtrl; -} ICONCTRL, *LPICONCTRL; + int iIcon; + UINT Message; + WORD idCtrl; +}; LPTSTR IcoLib_GetDefaultIconFileName(); void IcoLib_SetCtrlIcons(HWND hDlg, const ICONCTRL* pCtrl, BYTE numCtrls); diff --git a/plugins/UserInfoEx/src/mir_menuitems.cpp b/plugins/UserInfoEx/src/mir_menuitems.cpp index 8b33978a46..f3c1c6200c 100644 --- a/plugins/UserInfoEx/src/mir_menuitems.cpp +++ b/plugins/UserInfoEx/src/mir_menuitems.cpp @@ -96,7 +96,7 @@ void RebuildContact() //cascade all SET_UID(mi, 0xeb3736b6, 0x3b6, 0x40fa, 0xa7, 0xe5, 0xbb, 0x40, 0xeb, 0x55, 0xf7, 0x84); mi.position = 1000050000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_COMMON_MAIN); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAIN); mi.name.a = MODULELONGNAME; mhRoot = Menu_AddContactMenuItem(&mi); hMenuItem[0] = mhRoot; @@ -106,7 +106,7 @@ void RebuildContact() //cascade Ex/Import SET_UID(mi, 0x100de420, 0x4835, 0x4f8d, 0xbd, 0x58, 0x4f, 0x31, 0xcc, 0xe6, 0xc1, 0xa8); mi.position = 1000050100; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXIMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_EXIMPORT); mi.name.a = LPGEN("Export/import contact"); mhExIm = Menu_AddContactMenuItem(&mi); hMenuItem[0] = mhExIm; @@ -123,7 +123,7 @@ void RebuildContact() mi.pszService = MS_USERINFO_SHOWDIALOG; mi.name.a = LPGEN("User &details"); mi.position = 1000050000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_COMMON_MAIN); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAIN); hMenuItem[1] = Menu_AddContactMenuItem(&mi); Menu_ConfigureItem(hMenuItem[1], MCI_OPT_HOTKEY, MAKELPARAM(VK_F3, MOD_ALT)); @@ -136,7 +136,7 @@ void RebuildContact() mi.pszService = MS_USERINFO_VCARD_EXPORT; mi.name.a = mhExIm != NULL ? LPGEN("&Export") : LPGEN("&Export user details"); mi.position = 1000050200; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORT); hMenuItem[2] = Menu_AddContactMenuItem(&mi); // Import @@ -144,7 +144,7 @@ void RebuildContact() mi.pszService = MS_USERINFO_VCARD_IMPORT; mi.name.a = mhExIm != NULL ? LPGEN("&Import") : LPGEN("&Import user details"); mi.position = 1000050300; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_IMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT); hMenuItem[3] = Menu_AddContactMenuItem(&mi); } @@ -188,7 +188,7 @@ void RebuildMain() //cascade all SET_UID(mi, 0x17d277d5, 0x2772, 0x40c6, 0xbd, 0xbb, 0x2c, 0x3a, 0xcc, 0xda, 0xc, 0x72); mi.position = 500050000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_COMMON_MAIN); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAIN); mi.name.a = MODULELONGNAME; mhRoot = Menu_AddMainMenuItem(&mi); hMenuItem[item++] = mhRoot; @@ -198,7 +198,7 @@ void RebuildMain() //cascade Ex/Import SET_UID(mi, 0x80666af7, 0x1c92, 0x4ea6, 0xa8, 0xdc, 0x25, 0x88, 0x88, 0x27, 0x92, 0x68); mi.position = 500050000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXIMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_EXIMPORT); mi.name.a = LPGEN("Export/import contact"); mhExIm = Menu_AddMainMenuItem(&mi); hMenuItem[item++] = mhExIm; @@ -215,7 +215,7 @@ void RebuildMain() mi.pszService = MS_USERINFO_SHOWDIALOG; mi.name.a = LPGEN("View/change my &details..."); mi.position = 500050000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_COMMON_MAIN); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAIN); hMenuItem[item++] = Menu_AddMainMenuItem(&mi); // VCard's Ex/Import menuitems @@ -226,7 +226,7 @@ void RebuildMain() mi.pszService = MS_USERINFO_VCARD_EXPORTALL; mi.name.a = LPGEN("Export all contacts"); mi.position = 500150000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORT); hMenuItem[item++] = Menu_AddMainMenuItem(&mi); // Import @@ -234,7 +234,7 @@ void RebuildMain() mi.pszService = MS_USERINFO_VCARD_IMPORTALL; mi.name.a = LPGEN("Import all contacts"); mi.position = 500151000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_IMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT); hMenuItem[item++] = Menu_AddMainMenuItem(&mi); // reminder @@ -248,7 +248,7 @@ void RebuildMain() mi.pszService = MS_USERINFO_REMINDER_AGGRASIVEBACKUP; mi.name.a = LPGEN("Backup birthdays"); mi.position = 500253000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_BDAY_BACKUP); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_BIRTHDAY_BACKUP); hMenuItem[item++] = Menu_AddMainMenuItem(&mi); // Check anniversaries @@ -256,7 +256,7 @@ void RebuildMain() mi.pszService = MS_USERINFO_REMINDER_CHECK; mi.name.a = LPGEN("Check anniversaries"); mi.position = 500251000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_SEARCH); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_SEARCH); hMenuItem[item++] = Menu_AddMainMenuItem(&mi); } else { @@ -269,7 +269,7 @@ void RebuildMain() mi.pszService = MS_USERINFO_REFRESH; mi.name.a = LPGEN("Refresh contact details"); mi.position = 500254000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_UPDATE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_UPDATE); hMenuItem[item++] = Menu_AddMainMenuItem(&mi); // anniversary list @@ -277,7 +277,7 @@ void RebuildMain() mi.pszService = MS_USERINFO_REMINDER_LIST; mi.name.a = LPGEN("Anniversary list"); mi.position = 500252000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_COMMON_ANNIVERSARY); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ANNIVERSARY); hMenuItem[item++] = Menu_AddMainMenuItem(&mi); } @@ -326,7 +326,7 @@ void RebuildGroup() //cascade all SET_UID(mi, 0xfefe20db, 0x431f, 0x4fef, 0x9d, 0xa6, 0x70, 0xcd, 0x25, 0xf1, 0x2f, 0x1d); mi.position = 250000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_COMMON_MAIN); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAIN); mi.name.a = MODULELONGNAME; mhRoot = Menu_AddGroupMenuItem(&mi); hMenuItem[item++] = mhRoot; @@ -336,7 +336,7 @@ void RebuildGroup() //cascade Ex/Import SET_UID(mi, 0x3ec4da1, 0x8a1a, 0x4734, 0xba, 0x99, 0x7, 0x9c, 0x2, 0x46, 0xff, 0xec); mi.position = 250100; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXIMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_EXIMPORT); mi.name.a = LPGEN("Export/import contact"); mhExIm = Menu_AddGroupMenuItem(&mi); hMenuItem[item++] = mhExIm; @@ -355,7 +355,7 @@ void RebuildGroup() mi.pszService = MS_USERINFO_VCARD_EXPORTALL; mi.name.a = LPGEN("Export all contacts"); mi.position = 250200; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORT); hMenuItem[item++] = Menu_AddGroupMenuItem(&mi); // Import @@ -363,7 +363,7 @@ void RebuildGroup() mi.pszService = MS_USERINFO_VCARD_IMPORTALL; mi.name.a = LPGEN("Import all contacts"); mi.position = 250300; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_IMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT); hMenuItem[item++] = Menu_AddGroupMenuItem(&mi); } @@ -418,7 +418,7 @@ void RebuildSubGroup() //cascade all SET_UID(mi, 0x77b46004, 0xe845, 0x41f4, 0x9a, 0x56, 0x72, 0xd9, 0xa5, 0x61, 0x4d, 0x5); mi.position = 1050000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_COMMON_MAIN); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAIN); mi.name.a = MODULELONGNAME; mhRoot = Menu_AddSubGroupMenuItem(&mi); hMenuItem[item++] = mhRoot; @@ -428,7 +428,7 @@ void RebuildSubGroup() //cascade Ex/Import SET_UID(mi, 0xac5e810b, 0x4b41, 0x477c, 0x98, 0xfe, 0x8, 0x88, 0xec, 0x6f, 0xc3, 0xcf); mi.position = 1050100; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXIMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_EXIMPORT); mi.name.a = LPGEN("Export/import group"); mhExIm = Menu_AddSubGroupMenuItem(&mi); hMenuItem[item++] = mhExIm; @@ -448,7 +448,7 @@ void RebuildSubGroup() if (!ServiceExists(mi.pszService)) CreateServiceFunction(mi.pszService, svcExIm_Group_Service); mi.name.a = mhExIm != NULL ? LPGEN("&Export") : LPGEN("&Export group"); mi.position = 1050200; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORT); gmp.wParam = TRUE; hMenuItem[item++] = Menu_AddSubGroupMenuItem(&mi, &gmp); @@ -458,7 +458,7 @@ void RebuildSubGroup() if (!ServiceExists(mi.pszService)) CreateServiceFunction(mi.pszService, svcExIm_Group_Service); mi.name.a = mhExIm != NULL ? LPGEN("&Import") : LPGEN("&Import group"); mi.position = 1050300; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_IMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT); gmp.wParam = FALSE; hMenuItem[item++] = Menu_AddSubGroupMenuItem(&mi, &gmp); } @@ -539,7 +539,7 @@ INT_PTR RebuildAccount(WPARAM, LPARAM lParam) case 5: // cascade all mi.position = 50100; - mi.hIcolibItem = IcoLib_GetIcon(ICO_COMMON_MAIN); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAIN); mi.name.a = MODULELONGNAME; hMenuItemAccount[mItems*i + item] = Menu_AddStatusMenuItem(&mi, pa->szModuleName); mhRoot = hMenuItemAccount[mItems*i + item++]; @@ -548,7 +548,7 @@ INT_PTR RebuildAccount(WPARAM, LPARAM lParam) case 9: // cascade Ex/Import mi.position = 50100; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXIMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_EXIMPORT); mi.name.a = LPGEN("Export/import"); hMenuItemAccount[mItems*i + item] = Menu_AddStatusMenuItem(&mi, pa->szModuleName); mhRoot = hMenuItemAccount[mItems*i + item++]; @@ -567,7 +567,7 @@ INT_PTR RebuildAccount(WPARAM, LPARAM lParam) CreateServiceFunction(mi.pszService, svcExIm_Account_Service); mi.name.a = LPGEN("&Export xml"); mi.position = 50200; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EXPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORT); hMenuItemAccount[mItems*i + item++] = Menu_AddStatusMenuItem(&mi, pa->szModuleName); // Import @@ -575,7 +575,7 @@ INT_PTR RebuildAccount(WPARAM, LPARAM lParam) CreateServiceFunction(mi.pszService, svcExIm_Account_Service); mi.name.a = LPGEN("&Import xml"); mi.position = 50300; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_IMPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT); hMenuItemAccount[mItems*i + item++] = Menu_AddStatusMenuItem(&mi, pa->szModuleName); } return 0; diff --git a/plugins/UserInfoEx/src/psp_anniversary.cpp b/plugins/UserInfoEx/src/psp_anniversary.cpp index a75ad3d52f..a185512b59 100644 --- a/plugins/UserInfoEx/src/psp_anniversary.cpp +++ b/plugins/UserInfoEx/src/psp_anniversary.cpp @@ -45,10 +45,10 @@ static INT_PTR CALLBACK DlgProc_AnniversaryEditor(HWND hDlg, UINT uMsg, WPARAM w // set icons if (g_plugin.getByte(SET_ICONS_BUTTONS, 1)) { - SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_OK)); - SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_BTN_CANCEL)); + SendDlgItemMessage(hDlg, IDOK, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_OK)); + SendDlgItemMessage(hDlg, IDCANCEL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BTN_CLOSE)); } - SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)IcoLib_GetIcon(ICO_DLG_ANNIVERSARY, TRUE)); + SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)g_plugin.getIcon(IDI_ANNIVERSARY, true)); // translate controls SendDlgItemMessage(hDlg, IDOK, BUTTONTRANSLATE, NULL, NULL); @@ -146,9 +146,9 @@ INT_PTR CALLBACK PSPProcAnniversary(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM case PSN_ICONCHANGED: { const ICONCTRL idIcon[] = { - { ICO_COMMON_BIRTHDAY, STM_SETIMAGE, ICO_BIRTHDAY }, - { ICO_BTN_ADD, BM_SETIMAGE, BTN_ADD }, - { ICO_BTN_DELETE, BM_SETIMAGE, BTN_DELETE } + { IDI_BIRTHDAY, STM_SETIMAGE, ICO_BIRTHDAY }, + { IDI_BTN_ADD, BM_SETIMAGE, BTN_ADD }, + { IDI_BTN_DELETE, BM_SETIMAGE, BTN_DELETE } }; IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon)); } diff --git a/plugins/UserInfoEx/src/psp_contact.cpp b/plugins/UserInfoEx/src/psp_contact.cpp index 75eb8909ec..0a2f3c857e 100644 --- a/plugins/UserInfoEx/src/psp_contact.cpp +++ b/plugins/UserInfoEx/src/psp_contact.cpp @@ -84,18 +84,18 @@ INT_PTR CALLBACK PSPProcContactHome(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM // phone numbers hCtrl = GetDlgItem(hDlg, EDIT_PHONE); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), hContact, USERINFO, pszProto, SET_CONTACT_PHONE); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_FAX, TranslateT(SET_CONTACT_FAX), hContact, USERINFO, pszProto, SET_CONTACT_FAX); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR); - bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, ICO_BTN_CUSTOMPHONE, 0, hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), hContact, USERINFO, pszProto, SET_CONTACT_PHONE); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), hContact, USERINFO, pszProto, SET_CONTACT_FAX); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), hContact, USERINFO, pszProto, SET_CONTACT_CELLULAR); + bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, hContact, USERINFO, pszProto, SET_CONTACT_MYPHONE_CAT, SET_CONTACT_MYPHONE_VAL); SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE); // emails hCtrl = GetDlgItem(hDlg, EDIT_EMAIL); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_EMAIL, TranslateT("Primary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_EMAIL, TranslateT("Secondary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_EMAIL, TranslateT("Tertiary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1); - bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, ICO_BTN_EMAIL, 0, hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL0); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_EMAIL1); + bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, hContact, USERINFO, pszProto, SET_CONTACT_MYEMAIL_CAT, SET_CONTACT_MYEMAIL_VAL); SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0); } @@ -124,11 +124,11 @@ INT_PTR CALLBACK PSPProcContactHome(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM case PSN_ICONCHANGED: { - HICON hIcon = IcoLib_GetIcon(ICO_BTN_GOTO); + HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO); SendDlgItemMessage(hDlg, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetDlgItemText(hDlg, BTN_GOTO, hIcon ? L"" : L"->"); - hIcon = IcoLib_GetIcon(ICO_COMMON_ADDRESS); + hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS); SendDlgItemMessage(hDlg, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); ShowWindow(GetDlgItem(hDlg, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE); @@ -228,18 +228,18 @@ INT_PTR CALLBACK PSPProcContactWork(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM // phone numbers hCtrl = GetDlgItem(hDlg, EDIT_PHONE); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_FAX, TranslateT(SET_CONTACT_FAX), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR); - bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, ICO_BTN_CUSTOMPHONE, 0, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_PHONE, TranslateT(SET_CONTACT_PHONE), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_PHONE); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_FAX, TranslateT(SET_CONTACT_FAX), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_FAX); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_CELLULAR, TranslateT(SET_CONTACT_CELLULAR), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_CELLULAR); + bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_CUSTOMPHONE, 0, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYPHONE_CAT, SET_CONTACT_COMPANY_MYPHONE_VAL); SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE); // emails hCtrl = GetDlgItem(hDlg, EDIT_EMAIL); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_EMAIL, TranslateT("Primary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_EMAIL, TranslateT("Secondary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0); - bChanged |= CtrlContactAddItemFromDB(hCtrl, ICO_BTN_EMAIL, TranslateT("Tertiary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1); - bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, ICO_BTN_EMAIL, 0, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Primary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Secondary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL0); + bChanged |= CtrlContactAddItemFromDB(hCtrl, IDI_BTN_EMAIL, TranslateT("Tertiary e-mail"), hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_EMAIL1); + bChanged |= CtrlContactAddMyItemsFromDB(hCtrl, IDI_BTN_EMAIL, 0, hContact, USERINFO, pszProto, SET_CONTACT_COMPANY_MYEMAIL_CAT, SET_CONTACT_COMPANY_MYEMAIL_VAL); SendMessage(hCtrl, CBEXM_SETCURSEL, (WPARAM)-1, TRUE); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, bChanged ? PSP_CHANGED : 0); } @@ -268,11 +268,11 @@ INT_PTR CALLBACK PSPProcContactWork(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM case PSN_ICONCHANGED: { - HICON hIcon = IcoLib_GetIcon(ICO_BTN_GOTO); + HICON hIcon = g_plugin.getIcon(IDI_BTN_GOTO); SendDlgItemMessage(hDlg, BTN_GOTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); SetDlgItemText(hDlg, BTN_GOTO, hIcon ? L"" : L"->"); - hIcon = IcoLib_GetIcon(ICO_COMMON_ADDRESS); + hIcon = g_plugin.getIcon(IDI_TREE_ADDRESS); SendDlgItemMessage(hDlg, ICO_ADDRESS, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); ShowWindow(GetDlgItem(hDlg, ICO_ADDRESS), hIcon ? SW_SHOW : SW_HIDE); diff --git a/plugins/UserInfoEx/src/psp_general.cpp b/plugins/UserInfoEx/src/psp_general.cpp index 3dc0e6de02..fbfc25c044 100644 --- a/plugins/UserInfoEx/src/psp_general.cpp +++ b/plugins/UserInfoEx/src/psp_general.cpp @@ -127,9 +127,9 @@ INT_PTR CALLBACK PSPProcGeneral(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case PSN_ICONCHANGED: { const ICONCTRL idIcon[] = { - { ICO_COMMON_FEMALE, STM_SETIMAGE, ICO_FEMALE }, - { ICO_COMMON_MALE, STM_SETIMAGE, ICO_MALE }, - { ICO_COMMON_MARITAL, STM_SETIMAGE, ICO_MARITAL }, + { IDI_FEMALE, STM_SETIMAGE, ICO_FEMALE }, + { IDI_MALE, STM_SETIMAGE, ICO_MALE }, + { IDI_MARITAL, STM_SETIMAGE, ICO_MARITAL }, }; IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon)); } diff --git a/plugins/UserInfoEx/src/psp_options.cpp b/plugins/UserInfoEx/src/psp_options.cpp index 9d8d704089..06bf4e6e1b 100644 --- a/plugins/UserInfoEx/src/psp_options.cpp +++ b/plugins/UserInfoEx/src/psp_options.cpp @@ -590,7 +590,7 @@ static INT_PTR CALLBACK DlgProc_ReminderOpts(HWND hDlg, UINT uMsg, WPARAM wParam TranslateDialogDefault(hDlg); ShowWindow(GetDlgItem(hDlg, CHECK_REMIND_SECURED), SW_SHOW); - SendDlgItemMessage(hDlg, ICO_BIRTHDAY, STM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(ICO_DLG_ANNIVERSARY, TRUE)); + SendDlgItemMessage(hDlg, ICO_BIRTHDAY, STM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_ANNIVERSARY, true)); // set colours SendDlgItemMessage(hDlg, EDIT_REMIND, EM_LIMITTEXT, 2, 0); @@ -888,7 +888,7 @@ static INT_PTR CALLBACK DlgProc_Popups(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR // Birthday mir_wstrncpy(ppd.lpwzContactName, TranslateT("Birthday"), _countof(ppd.lpwzContactName)); - ppd.lchIcon = IcoLib_GetIcon(ICO_RMD_DTB0); + ppd.lchIcon = g_plugin.getIcon(IDI_RMD_DTB0); if (IsDlgButtonChecked(hDlg, CHECK_OPT_POPUP_WINCLR)) { ppd.colorBack = GetSysColor(COLOR_BTNFACE); ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); @@ -901,7 +901,7 @@ static INT_PTR CALLBACK DlgProc_Popups(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR // Anniversary mir_wstrncpy(ppd.lpwzContactName, TranslateT("Anniversary"), _countof(ppd.lpwzContactName)); - ppd.lchIcon = IcoLib_GetIcon(ICO_RMD_DTAX); + ppd.lchIcon = g_plugin.getIcon(IDI_RMD_DTAX); if (IsDlgButtonChecked(hDlg, CHECK_OPT_POPUP_WINCLR)) { ppd.colorBack = GetSysColor(COLOR_BTNFACE); ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); diff --git a/plugins/UserInfoEx/src/psp_origin.cpp b/plugins/UserInfoEx/src/psp_origin.cpp index 5c804278d4..2d8d48faa5 100644 --- a/plugins/UserInfoEx/src/psp_origin.cpp +++ b/plugins/UserInfoEx/src/psp_origin.cpp @@ -106,8 +106,8 @@ INT_PTR CALLBACK PSPProcOrigin(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara case PSN_ICONCHANGED: { const ICONCTRL idIcon[] = { - { ICO_COMMON_ADDRESS, STM_SETIMAGE, ICO_ADDRESS }, - { ICO_COMMON_CLOCK, STM_SETIMAGE, ICO_CLOCK }, + { IDI_TREE_ADDRESS, STM_SETIMAGE, ICO_ADDRESS }, + { IDI_CLOCK, STM_SETIMAGE, ICO_CLOCK }, }; IcoLib_SetCtrlIcons(hDlg, idIcon, _countof(idIcon)); diff --git a/plugins/UserInfoEx/src/svc_email.cpp b/plugins/UserInfoEx/src/svc_email.cpp index 7652aba64f..2195bf7064 100644 --- a/plugins/UserInfoEx/src/svc_email.cpp +++ b/plugins/UserInfoEx/src/svc_email.cpp @@ -127,7 +127,7 @@ static INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam) static int OnCListApplyIcons(WPARAM wParam, LPARAM) { LPSTR val = Get(wParam); - ExtraIcon_SetIconByName(ghExtraIconSvc, wParam, (val) ? ICO_BTN_EMAIL : nullptr); + ExtraIcon_SetIcon(ghExtraIconSvc, wParam, (val) ? g_plugin.getIconHandle(IDI_DLG_EMAIL) : nullptr); mir_free(val); return 0; } @@ -186,7 +186,7 @@ void SvcEMailRebuildMenu() CMenuItem mi(&g_plugin); SET_UID(mi, 0x61d8e25a, 0x92e, 0x4470, 0x84, 0x57, 0x5e, 0x52, 0x17, 0x7f, 0xfa, 0x3); mi.position = -2000010000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_EMAIL); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_DLG_EMAIL); mi.name.a = "&E-mail"; mi.pszService = MS_EMAIL_SENDEMAIL; ghMenuItem = Menu_AddContactMenuItem(&mi); @@ -229,7 +229,7 @@ bool SvcEMailEnableExtraIcons(bool bEnable, bool bUpdateDB) hApplyIconHook = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, OnCListApplyIcons); if (ghExtraIconSvc == INVALID_HANDLE_VALUE) - ghExtraIconSvc = ExtraIcon_RegisterIcolib("email", LPGEN("E-mail (UInfoEx)"), ICO_BTN_EMAIL); + ghExtraIconSvc = ExtraIcon_RegisterIcolib("email", LPGEN("E-mail (UInfoEx)"), g_plugin.getIconHandle(IDI_BTN_EMAIL)); } else { // E-mail uncheckt if (hChangedHook) { diff --git a/plugins/UserInfoEx/src/svc_gender.cpp b/plugins/UserInfoEx/src/svc_gender.cpp index bd57c715c5..39a6c19af1 100644 --- a/plugins/UserInfoEx/src/svc_gender.cpp +++ b/plugins/UserInfoEx/src/svc_gender.cpp @@ -72,13 +72,13 @@ BYTE GenderOf(MCONTACT hContact) static int OnCListApplyIcons(MCONTACT hContact, LPARAM) { if (ghExtraIconSvc != INVALID_HANDLE_VALUE) { - char *icoName; + HANDLE hIcon; switch (GenderOf(hContact)) { - case 'M': icoName = ICO_COMMON_MALE; break; - case 'F': icoName = ICO_COMMON_FEMALE; break; - default: icoName = nullptr; + case 'M': hIcon = g_plugin.getIconHandle(IDI_MALE); break; + case 'F': hIcon = g_plugin.getIconHandle(IDI_FEMALE); break; + default: hIcon = nullptr; } - ExtraIcon_SetIconByName(ghExtraIconSvc, hContact, icoName); + ExtraIcon_SetIcon(ghExtraIconSvc, hContact, hIcon); } return 0; } @@ -117,7 +117,7 @@ bool SvcGenderEnableExtraIcons(bool bEnable, bool bUpdateDB) if (g_eiGender) { // Gender checked or dropdown select if (ghExtraIconSvc == INVALID_HANDLE_VALUE) - ghExtraIconSvc = ExtraIcon_RegisterIcolib("gender", LPGEN("Gender (UInfoEx)"), ICO_COMMON_MALE); + ghExtraIconSvc = ExtraIcon_RegisterIcolib("gender", LPGEN("Gender (UInfoEx)"), g_plugin.getIconHandle(IDI_MALE)); // hook events if (hChangedHook == nullptr) diff --git a/plugins/UserInfoEx/src/svc_homepage.cpp b/plugins/UserInfoEx/src/svc_homepage.cpp index 8361873cb6..21822d1dd2 100644 --- a/plugins/UserInfoEx/src/svc_homepage.cpp +++ b/plugins/UserInfoEx/src/svc_homepage.cpp @@ -93,7 +93,7 @@ static int OnCListApplyIcons(MCONTACT hContact, LPARAM) { LPSTR val = Get(hContact); if (ghExtraIconSvc != INVALID_HANDLE_VALUE) - ExtraIcon_SetIconByName(ghExtraIconSvc, hContact, (val) ? ICO_BTN_GOTO : nullptr); + ExtraIcon_SetIcon(ghExtraIconSvc, hContact, (val) ? g_plugin.getIconHandle(IDI_BTN_GOTO) : nullptr); MIR_FREE(val); return 0; } @@ -156,7 +156,7 @@ void SvcHomepageRebuildMenu() CMenuItem mi(&g_plugin); SET_UID(mi, 0xdb78c16e, 0x50db, 0x4a40, 0x80, 0x0, 0xd1, 0xa4, 0x1c, 0x1b, 0xa3, 0x2d); mi.position = -2000010000; - mi.hIcolibItem = IcoLib_GetIcon(ICO_BTN_GOTO); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BTN_GOTO); mi.name.a = LPGEN("&Homepage"); mi.pszService = MS_USERINFO_HOMEPAGE_OPENURL; ghMenuItem = Menu_AddContactMenuItem(&mi); @@ -189,7 +189,7 @@ bool SvcHomepageEnableExtraIcons(bool bEnable, bool bUpdateDB) hApplyIconHook = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, (MIRANDAHOOK)OnCListApplyIcons); if (ghExtraIconSvc == INVALID_HANDLE_VALUE) - ghExtraIconSvc = ExtraIcon_RegisterIcolib("homepage", LPGEN("Homepage (UInfoEx)"), ICO_BTN_GOTO); + ghExtraIconSvc = ExtraIcon_RegisterIcolib("homepage", LPGEN("Homepage (UInfoEx)"), g_plugin.getIconHandle(IDI_BTN_GOTO)); } else { if (hChangedHook) { diff --git a/plugins/UserInfoEx/src/svc_phone.cpp b/plugins/UserInfoEx/src/svc_phone.cpp index 49215d1471..97d436a458 100644 --- a/plugins/UserInfoEx/src/svc_phone.cpp +++ b/plugins/UserInfoEx/src/svc_phone.cpp @@ -88,13 +88,13 @@ static INT_PTR Get(MCONTACT hContact) static int OnCListApplyIcons(MCONTACT hContact, LPARAM) { - char *icoName; + HANDLE hIcon; switch (Get(hContact)) { - case PHONE_NORMAL: icoName = ICO_BTN_PHONE; break; - case PHONE_SMS: icoName = ICO_BTN_CELLULAR; break; - default: icoName = nullptr; + case PHONE_NORMAL: hIcon = g_plugin.getIconHandle(IDI_BTN_PHONE); break; + case PHONE_SMS: hIcon = g_plugin.getIconHandle(IDI_BTN_CELLULAR); break; + default: hIcon = nullptr; } - ExtraIcon_SetIconByName(ghExtraIconSvc, hContact, icoName); + ExtraIcon_SetIcon(ghExtraIconSvc, hContact, hIcon); return 0; } @@ -146,7 +146,7 @@ bool SvcPhoneEnableExtraIcons(bool bEnable, bool bUpdateDB) hApplyIconHook = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, (MIRANDAHOOK)OnCListApplyIcons); if (ghExtraIconSvc == INVALID_HANDLE_VALUE) - ghExtraIconSvc = ExtraIcon_RegisterIcolib("sms", LPGEN("Phone (UInfoEx)"), ICO_BTN_CELLULAR); + ghExtraIconSvc = ExtraIcon_RegisterIcolib("sms", LPGEN("Phone (UInfoEx)"), g_plugin.getIconHandle(IDI_BTN_CELLULAR)); } else { if (hChangedHook) { diff --git a/plugins/UserInfoEx/src/svc_refreshci.cpp b/plugins/UserInfoEx/src/svc_refreshci.cpp index 0d7bc2b4de..9b28bfe730 100644 --- a/plugins/UserInfoEx/src/svc_refreshci.cpp +++ b/plugins/UserInfoEx/src/svc_refreshci.cpp @@ -221,9 +221,9 @@ class CDlgUpdProgress : public CUpdProgress case WM_INITDIALOG: { const ICONCTRL idIcon[] = { - { ICO_BTN_UPDATE, WM_SETICON, NULL }, - { ICO_BTN_DOWNARROW, BM_SETIMAGE, IDSKIP }, - { ICO_BTN_CANCEL, BM_SETIMAGE, IDCANCEL } + { IDI_BTN_UPDATE, WM_SETICON, NULL }, + { IDI_BTN_DOWNARROW, BM_SETIMAGE, IDSKIP }, + { IDI_BTN_CLOSE, BM_SETIMAGE, IDCANCEL } }; IcoLib_SetCtrlIcons(hWnd, idIcon, g_plugin.getByte(SET_ICONS_BUTTONS, 1) ? 2 : 1); @@ -373,7 +373,7 @@ public: _popupButtons[0].cbSize = sizeof(POPUPACTION); _popupButtons[0].flags = PAF_ENABLED; - _popupButtons[0].lchIcon = IcoLib_GetIcon(ICO_BTN_DOWNARROW); + _popupButtons[0].lchIcon = g_plugin.getIcon(IDI_BTN_DOWNARROW); _popupButtons[0].wParam = MAKEWORD(IDSKIP, BN_CLICKED); _popupButtons[0].lParam = NULL; mir_strcpy(_popupButtons[0].lpzTitle, MODULENAME"/Hide"); @@ -381,7 +381,7 @@ public: // cancel button _popupButtons[1].cbSize = sizeof(POPUPACTION); _popupButtons[1].flags = PAF_ENABLED; - _popupButtons[1].lchIcon = IcoLib_GetIcon(ICO_BTN_CANCEL); + _popupButtons[1].lchIcon = g_plugin.getIcon(IDI_BTN_CLOSE); _popupButtons[1].wParam = MAKEWORD(IDCANCEL, BN_CLICKED); _popupButtons[1].lParam = NULL; mir_strcpy(_popupButtons[1].lpzTitle, MODULENAME"/Cancel"); @@ -394,7 +394,7 @@ public: virtual HWND Create(LPCTSTR szTitle, PUpdCallback pFnCallBack) { POPUPDATAW ppd; - ppd.lchIcon = IcoLib_GetIcon(ICO_BTN_UPDATE); + ppd.lchIcon = g_plugin.getIcon(IDI_BTN_UPDATE); ppd.iSeconds = -1; ppd.PluginData = this; ppd.PluginWindowProc = CPopupUpdProgress::WndProc; @@ -565,7 +565,7 @@ class CContactUpdater : public CContactQueue // reset menu if (hMenuItemRefresh) - Menu_ModifyItem(hMenuItemRefresh, LPGENW("Refresh contact details"), IcoLib_GetIconHandle(ICO_BTN_UPDATE)); + Menu_ModifyItem(hMenuItemRefresh, LPGENW("Refresh contact details"), g_plugin.getIconHandle(IDI_BTN_UPDATE)); } /** @@ -645,7 +645,7 @@ public: // if there are contacts in the queue, change the main menu item to indicate it is meant for canceling. if (hMenuItemRefresh && Size() > 0) - Menu_ModifyItem(hMenuItemRefresh, LPGENW("Abort Refreshing Contact Details"), IcoLib_GetIconHandle(ICO_BTN_CANCEL)); + Menu_ModifyItem(hMenuItemRefresh, LPGENW("Abort Refreshing Contact Details"), g_plugin.getIconHandle(IDI_BTN_CLOSE)); } void Cancel() diff --git a/plugins/UserInfoEx/src/svc_reminder.cpp b/plugins/UserInfoEx/src/svc_reminder.cpp index 6f6b207e52..93ec9fbad0 100644 --- a/plugins/UserInfoEx/src/svc_reminder.cpp +++ b/plugins/UserInfoEx/src/svc_reminder.cpp @@ -141,25 +141,19 @@ static HICON GetAnnivIcon(const CEvent &evt) { HICON hIcon = nullptr; - CHAR szIcon[MAXSETTING]; - switch (evt._eType) { case CEvent::BIRTHDAY: if (evt._wDaysLeft > 9) - hIcon = IcoLib_GetIcon(ICO_RMD_DTBX); - else { - mir_snprintf(szIcon, MODULENAME"_rmd_dtb%u", evt._wDaysLeft); - hIcon = IcoLib_GetIcon(szIcon); - } + hIcon = g_plugin.getIcon(IDI_RMD_DTBX); + else + hIcon = g_plugin.getIcon(IDI_RMD_DTB0 + evt._wDaysLeft); break; case CEvent::ANNIVERSARY: if (evt._wDaysLeft > 9) - hIcon = IcoLib_GetIcon(ICO_RMD_DTAX); - else { - mir_snprintf(szIcon, MODULENAME"_rmd_dta%u", evt._wDaysLeft); - hIcon = IcoLib_GetIcon(szIcon); - } + hIcon = g_plugin.getIcon(IDI_RMD_DTAX); + else + hIcon = g_plugin.getIcon(IDI_RMD_DTA0 + evt._wDaysLeft); } return hIcon; } @@ -176,31 +170,27 @@ static HICON GetAnnivIcon(const CEvent &evt) static void NotifyWithExtraIcon(MCONTACT hContact, const CEvent &evt) { if (gRemindOpts.bCListExtraIcon) { - char szIcon[MAXSETTING], *icoName; - + int iIcon; + switch (evt._eType) { case CEvent::BIRTHDAY: if (evt._wDaysLeft > 9) - icoName = ICO_RMD_DTAX; - else { - mir_snprintf(szIcon, MODULENAME"_rmd_dtb%u", evt._wDaysLeft); - icoName = szIcon; - } + iIcon = IDI_RMD_DTBX; + else + iIcon = IDI_RMD_DTB0 + evt._wDaysLeft; break; case CEvent::ANNIVERSARY: if (evt._wDaysLeft > 9) - icoName = ICO_RMD_DTAX; - else { - mir_snprintf(szIcon, MODULENAME"_rmd_dta%u", evt._wDaysLeft); - icoName = szIcon; - } + iIcon = IDI_RMD_DTAX; + else + iIcon = IDI_RMD_DTA0 + evt._wDaysLeft; break; default: return; } - ExtraIcon_SetIconByName(ExtraIcon, hContact, icoName); + ExtraIcon_SetIcon(ExtraIcon, hContact, g_plugin.getIconHandle(iIcon)); } } @@ -318,12 +308,12 @@ static void NotifyFlashCListIcon(MCONTACT hContact, const CEvent &evt) switch (evt._eType) { case CEvent::BIRTHDAY: mir_snwprintf(szMsg, TranslateT("%s has %s today."), Clist_GetContactDisplayName(hContact), TranslateT("Birthday")); - cle.hIcon = IcoLib_GetIcon(ICO_COMMON_BIRTHDAY); + cle.hIcon = g_plugin.getIcon(IDI_BIRTHDAY); break; case CEvent::ANNIVERSARY: mir_snwprintf(szMsg, TranslateT("%s has %s today."), Clist_GetContactDisplayName(hContact), TranslateT("an anniversary")); - cle.hIcon = IcoLib_GetIcon(ICO_COMMON_ANNIVERSARY); + cle.hIcon = g_plugin.getIcon(IDI_ANNIVERSARY); break; default: @@ -714,7 +704,7 @@ static INT_PTR BackupBirthdayService(WPARAM hContact, LPARAM lParam) MSGBOX mBox; mBox.cbSize = sizeof(MSGBOX); mBox.hParent = nullptr; - mBox.hiLogo = IcoLib_GetIcon(ICO_COMMON_BIRTHDAY); + mBox.hiLogo = g_plugin.getIcon(IDI_BIRTHDAY); mBox.uType = MB_ICON_INFO; mBox.ptszTitle = TranslateT("Update custom birthday"); mBox.ptszMsg = TranslateT("Backing up and syncing all birthdays complete!"); @@ -884,7 +874,7 @@ void SvcReminderLoadModule(void) g_plugin.addHotkey(&hk); if (g_plugin.getByte(SET_REMIND_ENABLED, DEFVAL_REMIND_ENABLED) != REMIND_OFF && ExtraIcon == INVALID_HANDLE_VALUE) - ExtraIcon = ExtraIcon_RegisterIcolib("Reminder", LPGEN("Reminder (UInfoEx)"), ICO_COMMON_ANNIVERSARY); + ExtraIcon = ExtraIcon_RegisterIcolib("Reminder", LPGEN("Reminder (UInfoEx)"), g_plugin.getIconHandle(IDI_ANNIVERSARY)); } /** diff --git a/protocols/CloudFile/src/Services/dropbox_service.cpp b/protocols/CloudFile/src/Services/dropbox_service.cpp index a2cfa5a2e5..f4b9a22b3d 100644 --- a/protocols/CloudFile/src/Services/dropbox_service.cpp +++ b/protocols/CloudFile/src/Services/dropbox_service.cpp @@ -18,7 +18,7 @@ g_pluginDropbox; CDropboxService::CDropboxService(const char *protoName, const wchar_t *userName) : CCloudService(protoName, userName, &g_pluginDropbox) { - m_hProtoIcon = GetIconHandle(IDI_DROPBOX); + m_hProtoIcon = g_plugin.getIconHandle(IDI_DROPBOX); } CDropboxService* CDropboxService::Init(const char *moduleName, const wchar_t *userName) diff --git a/protocols/CloudFile/src/Services/google_service.cpp b/protocols/CloudFile/src/Services/google_service.cpp index 536d2ff65e..db4cfc1cbd 100644 --- a/protocols/CloudFile/src/Services/google_service.cpp +++ b/protocols/CloudFile/src/Services/google_service.cpp @@ -19,7 +19,7 @@ g_pluginGoogle; CGDriveService::CGDriveService(const char *protoName, const wchar_t *userName) : CCloudService(protoName, userName, &g_pluginGoogle) { - m_hProtoIcon = GetIconHandle(IDI_GDRIVE); + m_hProtoIcon = g_plugin.getIconHandle(IDI_GDRIVE); } CGDriveService* CGDriveService::Init(const char *moduleName, const wchar_t *userName) diff --git a/protocols/CloudFile/src/Services/microsoft_service.cpp b/protocols/CloudFile/src/Services/microsoft_service.cpp index 992312e2a8..27ec0df7fb 100644 --- a/protocols/CloudFile/src/Services/microsoft_service.cpp +++ b/protocols/CloudFile/src/Services/microsoft_service.cpp @@ -18,7 +18,7 @@ g_pluginOnedrive; COneDriveService::COneDriveService(const char *protoName, const wchar_t *userName) : CCloudService(protoName, userName, &g_pluginOnedrive) { - m_hProtoIcon = GetIconHandle(IDI_ONEDRIVE); + m_hProtoIcon = g_plugin.getIconHandle(IDI_ONEDRIVE); } COneDriveService* COneDriveService::Init(const char *moduleName, const wchar_t *userName) diff --git a/protocols/CloudFile/src/Services/yandex_service.cpp b/protocols/CloudFile/src/Services/yandex_service.cpp index 4bd0210ca1..816e6ea5e4 100644 --- a/protocols/CloudFile/src/Services/yandex_service.cpp +++ b/protocols/CloudFile/src/Services/yandex_service.cpp @@ -18,7 +18,7 @@ g_pluginYandex; CYandexService::CYandexService(const char *protoName, const wchar_t *userName) : CCloudService(protoName, userName, &g_pluginYandex) { - m_hProtoIcon = GetIconHandle(IDI_YADISK); + m_hProtoIcon = g_plugin.getIconHandle(IDI_YADISK); } CYandexService* CYandexService::Init(const char *moduleName, const wchar_t *userName) diff --git a/protocols/CloudFile/src/icons.cpp b/protocols/CloudFile/src/icons.cpp index 001df50240..0b42ad77fc 100644 --- a/protocols/CloudFile/src/icons.cpp +++ b/protocols/CloudFile/src/icons.cpp @@ -2,38 +2,14 @@ static IconItem iconList[] = { - { LPGEN("Upload file(s)"), "upload", IDI_UPLOAD }, - { LPGEN("Dropbox"), "dropbox", IDI_DROPBOX }, - { LPGEN("Google Drive"), "gdrive", IDI_GDRIVE }, - { LPGEN("OneDrive"), "onedrive", IDI_ONEDRIVE }, - { LPGEN("Yandex.Disk"), "yadisk", IDI_YADISK } + { LPGEN("Upload file(s)"), "upload", IDI_UPLOAD }, + { LPGEN("Dropbox"), "dropbox", IDI_DROPBOX }, + { LPGEN("Google Drive"), "gdrive", IDI_GDRIVE }, + { LPGEN("OneDrive"), "onedrive", IDI_ONEDRIVE }, + { LPGEN("Yandex.Disk"), "yadisk", IDI_YADISK } }; void InitializeIcons() { g_plugin.registerIcon("Protocols/" MODULENAME, iconList, MODULENAME); } - -HANDLE GetIconHandle(int iconId) -{ - for (auto &it : iconList) - if (it.defIconID == iconId) - return it.hIcolib; - return nullptr; -} - -HANDLE GetIconHandle(const char *name) -{ - for (auto &it : iconList) - if (mir_strcmpi(it.szName, name) == 0) - return it.hIcolib; - return nullptr; -} - -HICON LoadIconEx(int iconId, bool big) -{ - for (auto &it : iconList) - if (it.defIconID == iconId) - return IcoLib_GetIconByHandle(it.hIcolib, big); - return nullptr; -} \ No newline at end of file diff --git a/protocols/CloudFile/src/menus.cpp b/protocols/CloudFile/src/menus.cpp index 3ca1b085b9..33fe369406 100644 --- a/protocols/CloudFile/src/menus.cpp +++ b/protocols/CloudFile/src/menus.cpp @@ -26,7 +26,7 @@ void InitializeMenus() } mi.position = -2000019999; - mi.hIcon = LoadIconEx(IDI_UPLOAD); + mi.hIcon = g_plugin.getIcon(IDI_UPLOAD); hContactMenu = Menu_AddContactMenuItem(&mi); } @@ -39,7 +39,7 @@ void CCloudService::OnModulesLoaded() mi.flags = CMIF_SYSTEM | CMIF_UNICODE; mi.name.w = (wchar_t*)GetUserName(); mi.position = Services.getCount(); - mi.hIcolibItem = GetIconHandle(GetIconId()); + mi.hIcolibItem = g_plugin.getIconHandle(GetIconId()); Menu_AddContactMenuItem(&mi); CreateServiceFunctionObj(mi.pszService, UploadMenuCommand, this); diff --git a/protocols/CloudFile/src/srmm.cpp b/protocols/CloudFile/src/srmm.cpp index b4d44c9fdd..161ddfffd0 100644 --- a/protocols/CloudFile/src/srmm.cpp +++ b/protocols/CloudFile/src/srmm.cpp @@ -8,7 +8,7 @@ int OnSrmmToolbarLoaded(WPARAM, LPARAM) CMStringW tooltip(FORMAT, TranslateT("Upload files to...")); bbd.pwszTooltip = tooltip; - bbd.hIcon = GetIconHandle(IDI_UPLOAD); + bbd.hIcon = g_plugin.getIconHandle(IDI_UPLOAD); bbd.dwButtonID = BBB_ID_FILE_SEND; bbd.dwDefPos = 100 + bbd.dwButtonID; Srmm_AddButton(&bbd, &g_plugin); diff --git a/protocols/CloudFile/src/stdafx.h b/protocols/CloudFile/src/stdafx.h index 58801c4a34..c0bb92b713 100644 --- a/protocols/CloudFile/src/stdafx.h +++ b/protocols/CloudFile/src/stdafx.h @@ -81,9 +81,6 @@ int OnModulesLoaded(WPARAM, LPARAM); // icons void InitializeIcons(); -HANDLE GetIconHandle(int iconId); -HANDLE GetIconHandle(const char *name); -HICON LoadIconEx(int iconId, bool big = false); // menus extern HGENMENU hContactMenu; diff --git a/protocols/Dummy/res/resource.aps b/protocols/Dummy/res/resource.aps deleted file mode 100644 index 10cecfb374..0000000000 Binary files a/protocols/Dummy/res/resource.aps and /dev/null differ diff --git a/protocols/FacebookRM/src/captcha.cpp b/protocols/FacebookRM/src/captcha.cpp index 367a03bb66..6c9d2335a6 100644 --- a/protocols/FacebookRM/src/captcha.cpp +++ b/protocols/FacebookRM/src/captcha.cpp @@ -39,7 +39,7 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - Window_SetIcon_IcoLib(hwndDlg, GetIconHandle("key")); + Window_SetIcon_IcoLib(hwndDlg, g_plugin.getIconHandle(IDI_KEYS)); params = (CAPTCHA_FORM_PARAMS*)lParam; SetDlgItemText(hwndDlg, IDC_INSTRUCTION, TranslateT("Enter the text you see")); diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index d29d84b1b9..0c7c9616dd 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -212,7 +212,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara { TranslateDialogDefault(hwnd); - Window_SetIcon_IcoLib(hwnd, GetIconHandle("mind")); + Window_SetIcon_IcoLib(hwnd, g_plugin.getIconHandle(IDI_MIND)); data = reinterpret_cast(lparam); @@ -634,7 +634,7 @@ CFacebookGuardDialog::CFacebookGuardDialog(FacebookProto *proto, const char *fb_ bool CFacebookGuardDialog::OnInitDialog() { - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle("facebook")); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_FACEBOOK)); SendMessage(m_text.GetHwnd(), EM_LIMITTEXT, 6, 0); diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index b63006bea3..29c1fac120 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -324,7 +324,7 @@ void FacebookProto::LoadHistory(void *pParam) POPUPDATAW ppd; ppd.iSeconds = 5; ppd.lchContact = hContact; - ppd.lchIcon = IcoLib_GetIconByHandle(GetIconHandle("conversation")); // TODO: Use better icon + ppd.lchIcon = IcoLib_GetIconByHandle(g_plugin.getIconHandle(IDI_CONVERSATION)); // TODO: Use better icon wcsncpy(ppd.lpwzContactName, m_tszUserName, MAX_CONTACTNAME); wcsncpy(ppd.lpwzText, TranslateT("Loading history started."), MAX_SECONDLINE); diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index fef127544d..d2221ae899 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -104,7 +104,7 @@ FacebookProto::FacebookProto(const char* proto_name, const wchar_t* username) : evtype.module = m_szModuleName; evtype.eventType = FACEBOOK_EVENTTYPE_CALL; evtype.descr = LPGEN("Video call"); - evtype.eventIcon = GetIconHandle("facebook"); + evtype.eventIcon = g_plugin.getIconHandle(IDI_FACEBOOK); evtype.flags = DETF_HISTORY | DETF_MSGWINDOW; DbEvent_RegisterType(&evtype); } @@ -454,7 +454,7 @@ int FacebookProto::OnToolbarInit(WPARAM, LPARAM) ttb.pszService = service; ttb.pszTooltipUp = ttb.name = LPGEN("Share status..."); - ttb.hIconHandleUp = IcoLib_GetIconByHandle(GetIconHandle("mind")); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_MIND); g_plugin.addTTB(&ttb); return 0; @@ -926,7 +926,7 @@ void FacebookProto::InitPopups() // Client mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Client errors")); mir_snprintf(name, "%s_%s", m_szModuleName, "Client"); - ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("facebook")); + ppc.hIcon = g_plugin.getIcon(IDI_FACEBOOK); ppc.colorBack = RGB(191, 0, 0); // red ppc.colorText = RGB(255, 255, 255); // white popupClasses.push_back(Popup_RegisterClass(&ppc)); @@ -934,7 +934,7 @@ void FacebookProto::InitPopups() // Newsfeeds mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Wall posts")); mir_snprintf(name, "%s_%s", m_szModuleName, "Newsfeed"); - ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("newsfeed")); + ppc.hIcon = g_plugin.getIcon(IDI_NEWSFEED); ppc.colorBack = RGB(255, 255, 255); // white ppc.colorText = RGB(0, 0, 0); // black popupClasses.push_back(Popup_RegisterClass(&ppc)); @@ -942,7 +942,7 @@ void FacebookProto::InitPopups() // Notifications mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Notifications")); mir_snprintf(name, "%s_%s", m_szModuleName, "Notification"); - ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("notification")); + ppc.hIcon = g_plugin.getIcon(IDI_NOTIFICATION); ppc.colorBack = RGB(59, 89, 152); // Facebook's blue ppc.colorText = RGB(255, 255, 255); // white popupClasses.push_back(Popup_RegisterClass(&ppc)); @@ -950,7 +950,7 @@ void FacebookProto::InitPopups() // Others mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Other events")); mir_snprintf(name, "%s_%s", m_szModuleName, "Other"); - ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("facebook")); + ppc.hIcon = g_plugin.getIcon(IDI_FACEBOOK); ppc.colorBack = RGB(255, 255, 255); // white ppc.colorText = RGB(0, 0, 0); // black popupClasses.push_back(Popup_RegisterClass(&ppc)); @@ -958,7 +958,7 @@ void FacebookProto::InitPopups() // Friendship changes mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Friendship events")); mir_snprintf(name, "%s_%s", m_szModuleName, "Friendship"); - ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("friendship")); + ppc.hIcon = g_plugin.getIcon(IDI_FRIENDS); ppc.colorBack = RGB(47, 71, 122); // Facebook's darker blue ppc.colorText = RGB(255, 255, 255); // white popupClasses.push_back(Popup_RegisterClass(&ppc)); @@ -966,7 +966,7 @@ void FacebookProto::InitPopups() // Ticker mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Real-time friends activity")); mir_snprintf(name, "%s_%s", m_szModuleName, "Ticker"); - ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("newsfeed")); + ppc.hIcon = g_plugin.getIcon(IDI_NEWSFEED); ppc.colorBack = RGB(255, 255, 255); // white ppc.colorText = RGB(0, 0, 0); // black popupClasses.push_back(Popup_RegisterClass(&ppc)); @@ -974,7 +974,7 @@ void FacebookProto::InitPopups() // On this day (memories) mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Memories")); mir_snprintf(name, "%s_%s", m_szModuleName, "Memories"); - ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle("memories")); + ppc.hIcon = g_plugin.getIcon(IDI_MEMORIES); ppc.colorBack = RGB(255, 255, 255); // white ppc.colorText = RGB(0, 0, 0); // black popupClasses.push_back(Popup_RegisterClass(&ppc)); @@ -1039,7 +1039,7 @@ void FacebookProto::MessageRead(MCONTACT hContact) wchar_t ttime[64]; wcsftime(ttime, _countof(ttime), L"%X", localtime(&time)); - HICON hIcon = IcoLib_GetIconByHandle(GetIconHandle("read")); + HICON hIcon = g_plugin.getIcon(IDI_READ); if (isChatRoom(hContact)) { // Load readers names diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp index 9fd5413896..be9a232bc1 100644 --- a/protocols/FacebookRM/src/theme.cpp +++ b/protocols/FacebookRM/src/theme.cpp @@ -57,15 +57,6 @@ void InitIcons(void) g_plugin.registerIcon("Protocols/Facebook", icons, "Facebook"); } -HANDLE GetIconHandle(const char* name) -{ - for (auto &it : icons) - if (mir_strcmp(it.szName, name) == 0) - return it.hIcolib; - - return nullptr; -} - // Helper functions template INT_PTR GlobalService(WPARAM wParam, LPARAM lParam) @@ -107,7 +98,7 @@ void InitContactMenus() SET_UID(mi, 0x1e9d0534, 0xc319, 0x42a2, 0xbe, 0xd5, 0x1e, 0xae, 0xe1, 0x54, 0xd, 0x89); mi.position = -2000006001; - mi.hIcolibItem = GetIconHandle("friendship"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_FRIENDS); mi.name.a = LPGEN("Visit friendship details"); mi.pszService = "FacebookProto/VisitFriendship"; CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::VisitFriendship>); @@ -115,7 +106,7 @@ void InitContactMenus() SET_UID(mi, 0xd3bfd7d6, 0x43c3, 0x4b05, 0x81, 0x40, 0xc8, 0xbe, 0x81, 0xd9, 0x95, 0xff); mi.position = -2000006002; - mi.hIcolibItem = GetIconHandle("conversation"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_CONVERSATION); mi.name.a = LPGEN("Visit conversation"); mi.pszService = "FacebookProto/VisitConversation"; CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::VisitConversation>); @@ -123,7 +114,7 @@ void InitContactMenus() SET_UID(mi, 0xc631b2ea, 0xa133, 0x4cc9, 0x81, 0x1e, 0xad, 0x8f, 0x36, 0x5c, 0x74, 0xbf); mi.position = -2000006003; - mi.hIcolibItem = GetIconHandle("mind"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MIND); mi.name.a = LPGEN("Share status..."); mi.pszService = "FacebookProto/Mind"; CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::OnMind>); @@ -131,7 +122,7 @@ void InitContactMenus() SET_UID(mi, 0x10ce2dbf, 0x8acf, 0x4f51, 0x89, 0x76, 0xd9, 0x67, 0xef, 0x69, 0x1d, 0x9d); mi.position = -2000006004; - mi.hIcolibItem = GetIconHandle("poke"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_POKE); mi.name.a = LPGEN("Poke"); mi.pszService = "FacebookProto/Poke"; CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::Poke>); @@ -139,7 +130,7 @@ void InitContactMenus() SET_UID(mi, 0x58e75db0, 0xb9e0, 0x4aa8, 0xbb, 0x42, 0x8d, 0x7d, 0xd1, 0xf6, 0x8e, 0x99); mi.position = -2000006005; - mi.hIcolibItem = GetIconHandle("conversation"); // TODO: Use better icon + mi.hIcolibItem = g_plugin.getIconHandle(IDI_CONVERSATION); // TODO: Use better icon mi.name.a = LPGEN("Load history"); mi.pszService = "FacebookProto/LoadHistory"; CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::LoadHistory>); @@ -200,7 +191,7 @@ void FacebookProto::OnBuildProtoMenu() mi.pszService = "/Mind"; CreateProtoService(mi.pszService, &FacebookProto::OnMind); mi.name.a = LPGEN("Share status..."); - mi.hIcolibItem = GetIconHandle("mind"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MIND); m_hStatusMind = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = "/VisitProfile"; @@ -229,19 +220,19 @@ void FacebookProto::OnBuildProtoMenu() mi.pszService = "/CheckNewsfeeds"; CreateProtoService(mi.pszService, &FacebookProto::CheckNewsfeeds); mi.name.a = LPGEN("Check newsfeeds"); - mi.hIcolibItem = GetIconHandle("newsfeed"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_NEWSFEED); Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = "/CheckMemories"; CreateProtoService(mi.pszService, &FacebookProto::CheckMemories); mi.name.a = LPGEN("Check memories"); - mi.hIcolibItem = GetIconHandle("memories"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MEMORIES); Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = "/CheckNotifications"; CreateProtoService(mi.pszService, &FacebookProto::CheckNotifications); mi.name.a = LPGEN("Check notifications"); - mi.hIcolibItem = GetIconHandle("notification"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_NOTIFICATION); Menu_AddProtoMenuItem(&mi, m_szModuleName); } diff --git a/protocols/FacebookRM/src/theme.h b/protocols/FacebookRM/src/theme.h index 71dfff4ffb..550816f565 100644 --- a/protocols/FacebookRM/src/theme.h +++ b/protocols/FacebookRM/src/theme.h @@ -23,6 +23,4 @@ along with this program. If not, see . #pragma once void InitIcons(void); -HANDLE GetIconHandle(const char *name); - void InitContactMenus(void); diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 4807733917..7653d48e17 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -993,14 +993,14 @@ retry: CLISTEVENT cle = { 0 }; cle.hContact = hContact; - cle.hIcon = LoadIconEx("image", FALSE); + cle.hIcon = g_plugin.getIcon(IDI_IMAGE); cle.flags = CLEF_URGENT; cle.hDbEvent = -98; cle.lParam = (LPARAM)img; cle.pszService = service; cle.szTooltip.a = Translate("Incoming image"); g_clistApi.pfnAddEvent(&cle); - ReleaseIconEx("image", FALSE); + g_plugin.releaseIcon(IDI_IMAGE); } } break; diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h index 5ffd8c2d0a..5f88e07527 100644 --- a/protocols/Gadu-Gadu/src/gg.h +++ b/protocols/Gadu-Gadu/src/gg.h @@ -283,9 +283,6 @@ char *gg_avatarhash(char *param); /* IcoLib functions */ void gg_icolib_init(); -HICON LoadIconEx(const char* name, bool big); -HANDLE GetIconHandle(int iconId); -void ReleaseIconEx(const char* name, bool big); /* URI parser functions */ void gg_links_instancemenu_init(); diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 648bb662a0..693216babe 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -415,7 +415,7 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa { SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)lParam); TranslateDialogDefault(hwndDlg); - Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_CONFERENCE)); + Window_SetIcon_IcoLib(hwndDlg, g_plugin.getIconHandle(IDI_CONFERENCE)); gg_gc_resetclistopts(GetDlgItem(hwndDlg, IDC_CLIST)); // Hook MetaContacts event (if available) diff --git a/protocols/Gadu-Gadu/src/icolib.cpp b/protocols/Gadu-Gadu/src/icolib.cpp index 23189ef17c..db210254ed 100644 --- a/protocols/Gadu-Gadu/src/icolib.cpp +++ b/protocols/Gadu-Gadu/src/icolib.cpp @@ -45,27 +45,3 @@ void gg_icolib_init() { g_plugin.registerIcon("Protocols/" GGDEF_PROTO, iconList, GGDEF_PROTO); } - -HICON LoadIconEx(const char* name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", GGDEF_PROTO, name); - - return IcoLib_GetIcon(szSettingName, big); -} - -HANDLE GetIconHandle(int iconId) -{ - for (const auto &icon : iconList) - if (icon.defIconID == iconId) - return icon.hIcolib; - - return nullptr; -} - -void ReleaseIconEx(const char* name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", GGDEF_PROTO, name); - IcoLib_Release(szSettingName, big); -} diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 2585155bcd..787cb69c56 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -405,23 +405,23 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP // Making buttons flat SendDlgItemMessage(hwndDlg, IDC_IMG_PREV, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_IMG_PREV, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("previous", FALSE)); + SendDlgItemMessage(hwndDlg, IDC_IMG_PREV, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_PREV)); SendDlgItemMessage(hwndDlg, IDC_IMG_PREV, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Previous image"), BATF_UNICODE); SendDlgItemMessage(hwndDlg, IDC_IMG_NEXT, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_IMG_NEXT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("next", FALSE)); + SendDlgItemMessage(hwndDlg, IDC_IMG_NEXT, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_NEXT)); SendDlgItemMessage(hwndDlg, IDC_IMG_NEXT, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Next image"), BATF_UNICODE); SendDlgItemMessage(hwndDlg, IDC_IMG_SAVE, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_IMG_SAVE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("save", FALSE)); + SendDlgItemMessage(hwndDlg, IDC_IMG_SAVE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_SAVE)); SendDlgItemMessage(hwndDlg, IDC_IMG_SAVE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Save image to disk"), BATF_UNICODE); SendDlgItemMessage(hwndDlg, IDC_IMG_DELETE, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_IMG_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("delete", FALSE)); + SendDlgItemMessage(hwndDlg, IDC_IMG_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_DELETE)); SendDlgItemMessage(hwndDlg, IDC_IMG_DELETE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete image from the list"), BATF_UNICODE); // Set main window image - Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_IMAGE)); + Window_SetIcon_IcoLib(hwndDlg, g_plugin.getIconHandle(IDI_IMAGE)); wchar_t *szName = Clist_GetContactDisplayName(dat->hContact), szTitle[128]; if (dat->bReceiving) @@ -522,10 +522,10 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP img = img->lpNext; gg_img_releasepicture(temp); } - ReleaseIconEx("previous", FALSE); - ReleaseIconEx("next", FALSE); - ReleaseIconEx("delete", FALSE); - ReleaseIconEx("save", FALSE); + g_plugin.releaseIcon(IDI_PREV); + g_plugin.releaseIcon(IDI_NEXT); + g_plugin.releaseIcon(IDI_DELETE); + g_plugin.releaseIcon(IDI_SAVE); Window_FreeIcon_IcoLib(hwndDlg); gg->gg_EnterCriticalSection(&gg->img_mutex, "gg_img_dlgproc", 58, "img_mutex", 1); list_remove(&gg->imagedlgs, dat, 1); diff --git a/protocols/Gadu-Gadu/src/popups.cpp b/protocols/Gadu-Gadu/src/popups.cpp index 8fcf1a00ff..8d6d96e7f9 100644 --- a/protocols/Gadu-Gadu/src/popups.cpp +++ b/protocols/Gadu-Gadu/src/popups.cpp @@ -86,8 +86,7 @@ void GaduProto::initpopups() mir_snwprintf(szDescr, L"%s/%s", m_tszUserName, TranslateT("Notifications")); puc.colorBack = RGB(173, 206, 247); puc.colorText = GetSysColor(COLOR_WINDOWTEXT); - puc.hIcon = CopyIcon(LoadIconEx("main", FALSE)); - ReleaseIconEx("main", FALSE); + puc.hIcon = g_plugin.getIcon(IDI_GG); puc.iSeconds = 4; hPopupNotify = Popup_RegisterClass(&puc); diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp index 6d7ae4893e..6c71aeab95 100644 --- a/protocols/Gadu-Gadu/src/sessions.cpp +++ b/protocols/Gadu-Gadu/src/sessions.cpp @@ -169,7 +169,7 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w GetWindowText(hwndDlg, oldTitle, _countof(oldTitle)); mir_snwprintf(newTitle, oldTitle, gg->m_tszUserName); SetWindowText(hwndDlg, newTitle); - Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_SESSIONS)); + Window_SetIcon_IcoLib(hwndDlg, g_plugin.getIconHandle(IDI_SESSIONS)); if (hHandCursor == nullptr) hHandCursor = LoadCursor(nullptr, IDC_HAND); diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp index dd3a8d5d7f..8b51ba24b1 100644 --- a/protocols/Gadu-Gadu/src/userutils.cpp +++ b/protocols/Gadu-Gadu/src/userutils.cpp @@ -213,7 +213,7 @@ INT_PTR CALLBACK gg_userutildlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); - Window_SetIcon_IcoLib(hwndDlg, GetIconHandle(IDI_SETTINGS)); + Window_SetIcon_IcoLib(hwndDlg, g_plugin.getIconHandle(IDI_SETTINGS)); dat = (GGUSERUTILDLGDATA *)lParam; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); if (dat) SetDlgItemTextA(hwndDlg, IDC_EMAIL, dat->email); // Readup email diff --git a/protocols/ICQ-WIM/src/ignore.cpp b/protocols/ICQ-WIM/src/ignore.cpp index 63bcc48d72..66501858df 100644 --- a/protocols/ICQ-WIM/src/ignore.cpp +++ b/protocols/ICQ-WIM/src/ignore.cpp @@ -38,7 +38,7 @@ public: bool OnInitDialog() override { HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0); - ImageList_AddIcon(hImageList, IcoLib_GetIcon(Skin_GetIconName(SKINICON_OTHER_DELETE))); + ImageList_AddIcon(hImageList, Skin_LoadIcon(SKINICON_OTHER_DELETE)); m_list.SetImageList(hImageList, LVSIL_SMALL); m_list.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES | LVS_EX_GRIDLINES); diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp index 4cffc5dd14..02739d42e0 100644 --- a/protocols/IRCG/src/clist.cpp +++ b/protocols/IRCG/src/clist.cpp @@ -66,7 +66,7 @@ BOOL CIrcProto::CList_AddDCCChat(const CMStringW& name, const CMStringW& hostmas cle.hContact = hContact; cle.hDbEvent = -100; cle.flags = CLEF_UNICODE; - cle.hIcon = LoadIconEx(IDI_DCC); + cle.hIcon = g_plugin.getIcon(IDI_DCC); mir_snprintf(szService, "%s/DblClickEvent", m_szModuleName); cle.pszService = szService; mir_snwprintf(szNick, TranslateT("CTCP chat request from %s"), name.c_str()); diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index 83225e0699..d05c5a5027 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -706,7 +706,7 @@ int CIrcProto::SetStatusInternal(int iNewStatus, bool bIsInternal) SetWindowTextA(hwnd, "Miranda IRC"); SetDlgItemText(hwnd, IDC_TEXT, TranslateT("Please choose an IRC-network to go online. This network will be the default.")); SetDlgItemText(hwnd, IDC_CAPTION, TranslateT("Default network")); - Window_SetIcon_IcoLib(hwnd, GetIconHandle(IDI_MAIN)); + Window_SetIcon_IcoLib(hwnd, g_plugin.getIconHandle(IDI_MAIN)); ShowWindow(hwnd, SW_SHOW); SetActiveWindow(hwnd); } diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index accfb1ac39..1ce7754a22 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -212,24 +212,6 @@ void InitIcons(void) g_plugin.registerIcon("Protocols/IRC", iconList, "IRC"); } -HICON LoadIconEx(int iconId, bool big) -{ - for (auto &it : iconList) - if (it.defIconID == iconId) - return IcoLib_GetIconByHandle(it.hIcolib, big); - - return nullptr; -} - -HANDLE GetIconHandle(int iconId) -{ - for (auto &it : iconList) - if (it.defIconID == iconId) - return it.hIcolib; - - return nullptr; -} - ///////////////////////////////////////////////////////////////////////////////////////// // code page handler @@ -437,16 +419,16 @@ static TDbSetting ConnectSettings[] = { FIELD_OFFSET(CIrcProto, m_autoOnlineNotification), "AutoOnlineNotification", DBVT_BYTE }, }; -CConnectPrefsDlg::CConnectPrefsDlg(CIrcProto* _pro) +CConnectPrefsDlg::CConnectPrefsDlg(CIrcProto *_pro) : CProtoDlgBase(_pro, IDD_PREFS_CONNECT), m_serverCombo(this, IDC_SERVERCOMBO), m_server(this, IDC_SERVER), m_port(this, IDC_PORT), m_port2(this, IDC_PORT2), m_pass(this, IDC_PASS), - m_add(this, IDC_ADDSERVER, LoadIconEx(IDI_ADD), LPGEN("Add a new network")), - m_edit(this, IDC_EDITSERVER, LoadIconEx(IDI_EDIT), LPGEN("Edit this network")), - m_del(this, IDC_DELETESERVER, LoadIconEx(IDI_DELETE), LPGEN("Delete this network")), + m_add(this, IDC_ADDSERVER, g_plugin.getIcon(IDI_ADD), LPGEN("Add a new network")), + m_edit(this, IDC_EDITSERVER, g_plugin.getIcon(IDI_EDIT), LPGEN("Edit this network")), + m_del(this, IDC_DELETESERVER, g_plugin.getIcon(IDI_DELETE), LPGEN("Delete this network")), m_nick(this, IDC_NICK), m_nick2(this, IDC_NICK2), m_name(this, IDC_NAME), @@ -989,8 +971,8 @@ COtherPrefsDlg::COtherPrefsDlg(CIrcProto *_pro) : m_autodetect(this, IDC_UTF_AUTODETECT), m_quitMessage(this, IDC_QUITMESSAGE), m_alias(this, IDC_ALIASEDIT), - m_add(this, IDC_ADD, LoadIconEx(IDI_ADD), LPGEN("Click to set commands that will be performed for this event")), - m_delete(this, IDC_DELETE, LoadIconEx(IDI_DELETE), LPGEN("Click to delete the commands for this event")), + m_add(this, IDC_ADD, g_plugin.getIcon(IDI_ADD), LPGEN("Click to set commands that will be performed for this event")), + m_delete(this, IDC_DELETE, g_plugin.getIcon(IDI_DELETE), LPGEN("Click to delete the commands for this event")), m_performlistModified(false) { m_performCombo.OnChange = Callback(this, &COtherPrefsDlg::OnPerformCombo); @@ -1395,9 +1377,9 @@ void CIrcProto::RewriteIgnoreSettings(void) CIgnorePrefsDlg::CIgnorePrefsDlg(CIrcProto* _pro) : CProtoDlgBase(_pro, IDD_PREFS_IGNORE), m_list(this, IDC_LIST), - m_add(this, IDC_ADD, LoadIconEx(IDI_ADD), LPGEN("Add new ignore")), - m_edit(this, IDC_EDIT, LoadIconEx(IDI_EDIT), LPGEN("Edit this ignore")), - m_del(this, IDC_DELETE, LoadIconEx(IDI_DELETE), LPGEN("Delete this ignore")), + m_add(this, IDC_ADD, g_plugin.getIcon(IDI_ADD), LPGEN("Add new ignore")), + m_edit(this, IDC_EDIT, g_plugin.getIcon(IDI_EDIT), LPGEN("Edit this ignore")), + m_del(this, IDC_DELETE, g_plugin.getIcon(IDI_DELETE), LPGEN("Delete this ignore")), m_enable(this, IDC_ENABLEIGNORE), m_ignoreChat(this, IDC_IGNORECHAT), m_ignoreFile(this, IDC_IGNOREFILE), diff --git a/protocols/IRCG/src/services.cpp b/protocols/IRCG/src/services.cpp index fe3908b465..8b91562f6f 100644 --- a/protocols/IRCG/src/services.cpp +++ b/protocols/IRCG/src/services.cpp @@ -27,7 +27,7 @@ void CIrcProto::OnBuildProtoMenu() mi.root = Menu_GetProtocolRoot(this); mi.name.a = LPGEN("&Quick connect"); - mi.hIcolibItem = GetIconHandle(IDI_QUICK); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_QUICK); mi.pszService = IRC_QUICKCONNECT; mi.position = 201001; hMenuQuick = Menu_AddProtoMenuItem(&mi, m_szModuleName); @@ -41,20 +41,20 @@ void CIrcProto::OnBuildProtoMenu() hMenuJoin = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.name.a = LPGEN("&Change your nickname"); - mi.hIcolibItem = GetIconHandle(IDI_RENAME); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_RENAME); mi.pszService = IRC_CHANGENICK; mi.position = 201003; hMenuNick = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.name.a = LPGEN("Show the &list of available channels"); - mi.hIcolibItem = GetIconHandle(IDI_LIST); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_LIST); mi.pszService = IRC_SHOWLIST; mi.position = 201004; hMenuList = Menu_AddProtoMenuItem(&mi, m_szModuleName); if (m_useServer) mi.flags &= ~CMIF_GRAYED; mi.name.a = LPGEN("&Show the server window"); - mi.hIcolibItem = GetIconHandle(IDI_SERVER); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_SERVER); mi.pszService = IRC_SHOWSERVER; mi.position = 201005; hMenuServer = Menu_AddProtoMenuItem(&mi, m_szModuleName); @@ -109,7 +109,7 @@ void InitContactMenus(void) SET_UID(mi, 0x5f01196f, 0xfbcd, 0x4034, 0xbd, 0x90, 0x12, 0xa0, 0x20, 0x68, 0x15, 0xc0); mi.name.a = LPGEN("Channel &settings"); - mi.hIcolibItem = GetIconHandle(IDI_MANAGER); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MANAGER); mir_strcpy(d, IRC_UM_CHANSETTINGS); mi.position = 500090002; hUMenuChanSettings = Menu_AddContactMenuItem(&mi); @@ -117,7 +117,7 @@ void InitContactMenus(void) SET_UID(mi, 0x778eb1f6, 0x73c4, 0x4951, 0xb2, 0xca, 0xa1, 0x69, 0x94, 0x7b, 0xb7, 0x87); mi.name.a = LPGEN("&WhoIs info"); - mi.hIcolibItem = GetIconHandle(IDI_WHOIS); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_WHOIS); mir_strcpy(d, IRC_UM_WHOIS); mi.position = 500090001; hUMenuWhois = Menu_AddContactMenuItem(&mi); @@ -125,7 +125,7 @@ void InitContactMenus(void) SET_UID(mi, 0x1c51ae05, 0x9eee, 0x4887, 0x88, 0x96, 0x55, 0xd2, 0xdd, 0xf9, 0x25, 0x6f); mi.name.a = LPGEN("Di&sconnect"); - mi.hIcolibItem = GetIconHandle(IDI_DELETE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_DELETE); mir_strcpy(d, IRC_UM_DISCONNECT); mi.position = 500090001; hUMenuDisconnect = Menu_AddContactMenuItem(&mi); @@ -133,7 +133,7 @@ void InitContactMenus(void) SET_UID(mi, 0xc6169b8f, 0x53ab, 0x4242, 0xbe, 0x90, 0xe2, 0x4a, 0xa5, 0x73, 0x88, 0x32); mi.name.a = LPGEN("&Add to ignore list"); - mi.hIcolibItem = GetIconHandle(IDI_BLOCK); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BLOCK); mir_strcpy(d, IRC_UM_IGNORE); mi.position = 500090002; hUMenuIgnore = Menu_AddContactMenuItem(&mi); @@ -324,7 +324,7 @@ INT_PTR __cdecl CIrcProto::OnQuickConnectMenuCommand(WPARAM, LPARAM) SetWindowText(m_quickDlg->GetHwnd(), TranslateT("Quick connect")); SetDlgItemText(m_quickDlg->GetHwnd(), IDC_TEXT, TranslateT("Please select IRC network and enter the password if needed")); SetDlgItemText(m_quickDlg->GetHwnd(), IDC_CAPTION, TranslateT("Quick connect")); - Window_SetIcon_IcoLib(m_quickDlg->GetHwnd(), GetIconHandle(IDI_QUICK)); + Window_SetIcon_IcoLib(m_quickDlg->GetHwnd(), g_plugin.getIconHandle(IDI_QUICK)); } ShowWindow(m_quickDlg->GetHwnd(), SW_SHOW); diff --git a/protocols/IRCG/src/stdafx.h b/protocols/IRCG/src/stdafx.h index 37343328b9..4f79b0249a 100644 --- a/protocols/IRCG/src/stdafx.h +++ b/protocols/IRCG/src/stdafx.h @@ -219,8 +219,6 @@ void InitContactMenus(void); void UninitContactMenus(void); void InitIcons(void); -HICON LoadIconEx(int iIndex, bool big = false); -HANDLE GetIconHandle(int iconId); // tools.cpp int __stdcall WCCmp(const wchar_t* wild, const wchar_t* string); diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp index 252417b914..c1f4aa254b 100644 --- a/protocols/IRCG/src/windows.cpp +++ b/protocols/IRCG/src/windows.cpp @@ -87,7 +87,7 @@ bool CWhoisDlg::OnInitDialog() CCoolIrcDlg::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_WHOIS)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_WHOIS)); return true; } @@ -210,7 +210,7 @@ CNickDlg::CNickDlg(CIrcProto *_pro) bool CNickDlg::OnInitDialog() { CCoolIrcDlg::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_RENAME)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_RENAME)); DBVARIANT dbv; if (!m_proto->getWString("RecentNicks", &dbv)) { @@ -296,7 +296,7 @@ bool CListDlg::OnInitDialog() m_list.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); m_list2.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_LIST)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_LIST)); m_status.SetText(TranslateT("Please wait...")); return true; } @@ -724,7 +724,7 @@ bool CQuestionDlg::OnInitDialog() { CCoolIrcDlg::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_IRCQUESTION)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_IRCQUESTION)); return true; } @@ -808,11 +808,11 @@ CManagerDlg::CManagerDlg(CIrcProto *_pro) m_limit(this, IDC_LIMIT), m_topic(this, IDC_TOPIC), - m_add(this, IDC_ADD, LoadIconEx(IDI_ADD), LPGEN("Add ban/invite/exception")), - m_edit(this, IDC_EDIT, LoadIconEx(IDI_EDIT), LPGEN("Edit selected ban/invite/exception")), - m_remove(this, IDC_REMOVE, LoadIconEx(IDI_DELETE), LPGEN("Delete selected ban/invite/exception")), - m_applyModes(this, IDC_APPLYMODES, LoadIconEx(IDI_APPLY), LPGEN("Set these modes for the channel")), - m_applyTopic(this, IDC_APPLYTOPIC, LoadIconEx(IDI_APPLY), LPGEN("Set this topic for the channel")), + m_add(this, IDC_ADD, g_plugin.getIcon(IDI_ADD), LPGEN("Add ban/invite/exception")), + m_edit(this, IDC_EDIT, g_plugin.getIcon(IDI_EDIT), LPGEN("Edit selected ban/invite/exception")), + m_remove(this, IDC_REMOVE, g_plugin.getIcon(IDI_DELETE), LPGEN("Delete selected ban/invite/exception")), + m_applyModes(this, IDC_APPLYMODES, g_plugin.getIcon(IDI_APPLY), LPGEN("Set these modes for the channel")), + m_applyTopic(this, IDC_APPLYTOPIC, g_plugin.getIcon(IDI_APPLY), LPGEN("Set this topic for the channel")), m_radio1(this, IDC_RADIO1), m_radio2(this, IDC_RADIO2), @@ -885,7 +885,7 @@ bool CManagerDlg::OnInitDialog() HWND hwndEdit = ChildWindowFromPoint(m_topic.GetHwnd(), pt); mir_subclassWindow(hwndEdit, MgrEditSubclassProc); - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_MANAGER)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_MANAGER)); m_list.SendMsg(LB_SETHORIZONTALEXTENT, 750, NULL); m_radio1.SetState(true); @@ -1398,7 +1398,7 @@ bool CCoolIrcDlg::OnInitDialog() hFont = CreateFontIndirect(&lf); SendDlgItemMessage(m_hwnd, IDC_CAPTION, WM_SETFONT, (WPARAM)hFont, 0); - SendDlgItemMessage(m_hwnd, IDC_LOGO, STM_SETICON, (LPARAM)(HICON)LoadIconEx(IDI_LOGO), 0); + SendDlgItemMessage(m_hwnd, IDC_LOGO, STM_SETICON, (LPARAM)(HICON)g_plugin.getIcon(IDI_LOGO), 0); return true; } diff --git a/protocols/JabberG/jabber_xstatus/res/JABBER_XSTATUS.rc b/protocols/JabberG/jabber_xstatus/res/JABBER_XSTATUS.rc index 40eb3e2084..5e3f300d2c 100644 --- a/protocols/JabberG/jabber_xstatus/res/JABBER_XSTATUS.rc +++ b/protocols/JabberG/jabber_xstatus/res/JABBER_XSTATUS.rc @@ -26,170 +26,170 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -201 ICON "moods/afraid.ico" -202 ICON "moods/amazed.ico" -203 ICON "moods/amorous.ico" -204 ICON "moods/angry.ico" -205 ICON "moods/annoyed.ico" -206 ICON "moods/anxious.ico" -207 ICON "moods/aroused.ico" -208 ICON "moods/ashamed.ico" -209 ICON "moods/bored.ico" -210 ICON "moods/brave.ico" -211 ICON "moods/calm.ico" -212 ICON "moods/cautious.ico" -213 ICON "moods/cold.ico" -214 ICON "moods/confident.ico" -215 ICON "moods/confused.ico" -216 ICON "moods/contemplative.ico" -217 ICON "moods/contented.ico" -218 ICON "moods/cranky.ico" -219 ICON "moods/crazy.ico" -220 ICON "moods/creative.ico" -221 ICON "moods/curious.ico" -222 ICON "moods/dejected.ico" -223 ICON "moods/depressed.ico" -224 ICON "moods/disappointed.ico" -225 ICON "moods/disgusted.ico" -226 ICON "moods/dismayed.ico" -227 ICON "moods/distracted.ico" -228 ICON "moods/embarrassed.ico" -229 ICON "moods/envious.ico" -230 ICON "moods/excited.ico" -231 ICON "moods/flirtatious.ico" -232 ICON "moods/frustrated.ico" -233 ICON "moods/grateful.ico" -234 ICON "moods/grieving.ico" -235 ICON "moods/grumpy.ico" -236 ICON "moods/guilty.ico" -237 ICON "moods/happy.ico" -238 ICON "moods/hopeful.ico" -239 ICON "moods/hot.ico" -240 ICON "moods/humbled.ico" -241 ICON "moods/humiliated.ico" -242 ICON "moods/hungry.ico" -243 ICON "moods/hurt.ico" -244 ICON "moods/impressed.ico" -245 ICON "moods/in_awe.ico" -246 ICON "moods/in_love.ico" -247 ICON "moods/indignant.ico" -248 ICON "moods/interested.ico" -249 ICON "moods/intoxicated.ico" -250 ICON "moods/invincible.ico" -251 ICON "moods/jealous.ico" -252 ICON "moods/lonely.ico" -253 ICON "moods/lost.ico" -254 ICON "moods/lucky.ico" -255 ICON "moods/mean.ico" -256 ICON "moods/moody.ico" -257 ICON "moods/nervous.ico" -258 ICON "moods/neutral.ico" -259 ICON "moods/offended.ico" -260 ICON "moods/outraged.ico" -261 ICON "moods/playful.ico" -262 ICON "moods/proud.ico" -263 ICON "moods/relaxed.ico" -264 ICON "moods/relieved.ico" -265 ICON "moods/remorseful.ico" -266 ICON "moods/restless.ico" -267 ICON "moods/sad.ico" -268 ICON "moods/sarcastic.ico" -269 ICON "moods/satisfied.ico" -270 ICON "moods/serious.ico" -271 ICON "moods/shocked.ico" -272 ICON "moods/shy.ico" -273 ICON "moods/sick.ico" -274 ICON "moods/sleepy.ico" -275 ICON "moods/spontaneous.ico" -276 ICON "moods/stressed.ico" -277 ICON "moods/strong.ico" -278 ICON "moods/surprised.ico" -279 ICON "moods/thankful.ico" -280 ICON "moods/thirsty.ico" -281 ICON "moods/tired.ico" -282 ICON "moods/undefined.ico" -283 ICON "moods/weak.ico" -284 ICON "moods/worried.ico" +1201 ICON "moods/afraid.ico" +1202 ICON "moods/amazed.ico" +1203 ICON "moods/amorous.ico" +1204 ICON "moods/angry.ico" +1205 ICON "moods/annoyed.ico" +1206 ICON "moods/anxious.ico" +1207 ICON "moods/aroused.ico" +1208 ICON "moods/ashamed.ico" +1209 ICON "moods/bored.ico" +1210 ICON "moods/brave.ico" +1211 ICON "moods/calm.ico" +1212 ICON "moods/cautious.ico" +1213 ICON "moods/cold.ico" +1214 ICON "moods/confident.ico" +1215 ICON "moods/confused.ico" +1216 ICON "moods/contemplative.ico" +1217 ICON "moods/contented.ico" +1218 ICON "moods/cranky.ico" +1219 ICON "moods/crazy.ico" +1220 ICON "moods/creative.ico" +1221 ICON "moods/curious.ico" +1222 ICON "moods/dejected.ico" +1223 ICON "moods/depressed.ico" +1224 ICON "moods/disappointed.ico" +1225 ICON "moods/disgusted.ico" +1226 ICON "moods/dismayed.ico" +1227 ICON "moods/distracted.ico" +1228 ICON "moods/embarrassed.ico" +1229 ICON "moods/envious.ico" +1230 ICON "moods/excited.ico" +1231 ICON "moods/flirtatious.ico" +1232 ICON "moods/frustrated.ico" +1233 ICON "moods/grateful.ico" +1234 ICON "moods/grieving.ico" +1235 ICON "moods/grumpy.ico" +1236 ICON "moods/guilty.ico" +1237 ICON "moods/happy.ico" +1238 ICON "moods/hopeful.ico" +1239 ICON "moods/hot.ico" +1240 ICON "moods/humbled.ico" +1241 ICON "moods/humiliated.ico" +1242 ICON "moods/hungry.ico" +1243 ICON "moods/hurt.ico" +1244 ICON "moods/impressed.ico" +1245 ICON "moods/in_awe.ico" +1246 ICON "moods/in_love.ico" +1247 ICON "moods/indignant.ico" +1248 ICON "moods/interested.ico" +1249 ICON "moods/intoxicated.ico" +1250 ICON "moods/invincible.ico" +1251 ICON "moods/jealous.ico" +1252 ICON "moods/lonely.ico" +1253 ICON "moods/lost.ico" +1254 ICON "moods/lucky.ico" +1255 ICON "moods/mean.ico" +1256 ICON "moods/moody.ico" +1257 ICON "moods/nervous.ico" +1258 ICON "moods/neutral.ico" +1259 ICON "moods/offended.ico" +1260 ICON "moods/outraged.ico" +1261 ICON "moods/playful.ico" +1262 ICON "moods/proud.ico" +1263 ICON "moods/relaxed.ico" +1264 ICON "moods/relieved.ico" +1265 ICON "moods/remorseful.ico" +1266 ICON "moods/restless.ico" +1267 ICON "moods/sad.ico" +1268 ICON "moods/sarcastic.ico" +1269 ICON "moods/satisfied.ico" +1270 ICON "moods/serious.ico" +1271 ICON "moods/shocked.ico" +1272 ICON "moods/shy.ico" +1273 ICON "moods/sick.ico" +1274 ICON "moods/sleepy.ico" +1275 ICON "moods/spontaneous.ico" +1276 ICON "moods/stressed.ico" +1277 ICON "moods/strong.ico" +1278 ICON "moods/surprised.ico" +1279 ICON "moods/thankful.ico" +1280 ICON "moods/thirsty.ico" +1281 ICON "moods/tired.ico" +1282 ICON "moods/undefined.ico" +1283 ICON "moods/weak.ico" +1284 ICON "moods/worried.ico" -300 ICON "activities/doing_chores.ico" -301 ICON "activities/buying_groceries.ico" -302 ICON "activities/cleaning.ico" -303 ICON "activities/cooking.ico" -304 ICON "activities/doing_maintenance.ico" -305 ICON "activities/doing_the_dishes.ico" -306 ICON "activities/doing_the_laundry.ico" -307 ICON "activities/gardening.ico" -308 ICON "activities/running_an_errand.ico" -309 ICON "activities/walking_the_dog.ico" -320 ICON "activities/drinking.ico" -321 ICON "activities/having_a_beer.ico" -322 ICON "activities/having_coffee.ico" -323 ICON "activities/having_tea.ico" -340 ICON "activities/eating.ico" -341 ICON "activities/having_a_snack.ico" -342 ICON "activities/having_breakfast.ico" -343 ICON "activities/having_dinner.ico" -344 ICON "activities/having_lunch.ico" -360 ICON "activities/exercising.ico" -361 ICON "activities/cycling.ico" -362 ICON "activities/dancing.ico" -363 ICON "activities/hiking.ico" -364 ICON "activities/jogging.ico" -365 ICON "activities/playing_sports.ico" -366 ICON "activities/running.ico" -367 ICON "activities/skiing.ico" -368 ICON "activities/swimming.ico" -369 ICON "activities/working_out.ico" -380 ICON "activities/grooming.ico" -381 ICON "activities/at_the_spa.ico" -382 ICON "activities/brushing_teeth.ico" -383 ICON "activities/getting_a_haircut.ico" -384 ICON "activities/shaving.ico" -385 ICON "activities/taking_a_bath.ico" -386 ICON "activities/taking_a_shower.ico" -400 ICON "activities/having_appointment.ico" -420 ICON "activities/inactive.ico" -421 ICON "activities/day_off.ico" -422 ICON "activities/hanging_out.ico" -423 ICON "activities/hiding.ico" -424 ICON "activities/on_vacation.ico" -425 ICON "activities/praying.ico" -426 ICON "activities/scheduled_holiday.ico" -427 ICON "activities/sleeping.ico" -428 ICON "activities/thinking.ico" -440 ICON "activities/relaxing.ico" -441 ICON "activities/fishing.ico" -442 ICON "activities/gaming.ico" -443 ICON "activities/going_out.ico" -444 ICON "activities/partying.ico" -445 ICON "activities/reading.ico" -446 ICON "activities/rehearsing.ico" -447 ICON "activities/shopping.ico" -448 ICON "activities/smoking.ico" -449 ICON "activities/socializing.ico" -450 ICON "activities/sunbathing.ico" -451 ICON "activities/watching_tv.ico" -452 ICON "activities/watching_a_movie.ico" -460 ICON "activities/talking.ico" -461 ICON "activities/in_real_life.ico" -462 ICON "activities/on_the_phone.ico" -463 ICON "activities/on_video_phone.ico" -480 ICON "activities/traveling.ico" -481 ICON "activities/commuting.ico" -482 ICON "activities/cycling.ico" -483 ICON "activities/driving.ico" -484 ICON "activities/in_a_car.ico" -485 ICON "activities/on_a_bus.ico" -486 ICON "activities/on_a_plane.ico" -487 ICON "activities/on_a_train.ico" -488 ICON "activities/on_a_trip.ico" -489 ICON "activities/walking.ico" -500 ICON "activities/working.ico" -501 ICON "activities/coding.ico" -502 ICON "activities/in_a_meeting.ico" -503 ICON "activities/studying.ico" -504 ICON "activities/writing.ico" +1300 ICON "activities/doing_chores.ico" +1301 ICON "activities/buying_groceries.ico" +1302 ICON "activities/cleaning.ico" +1303 ICON "activities/cooking.ico" +1304 ICON "activities/doing_maintenance.ico" +1305 ICON "activities/doing_the_dishes.ico" +1306 ICON "activities/doing_the_laundry.ico" +1307 ICON "activities/gardening.ico" +1308 ICON "activities/running_an_errand.ico" +1309 ICON "activities/walking_the_dog.ico" +1320 ICON "activities/drinking.ico" +1321 ICON "activities/having_a_beer.ico" +1322 ICON "activities/having_coffee.ico" +1323 ICON "activities/having_tea.ico" +1340 ICON "activities/eating.ico" +1341 ICON "activities/having_a_snack.ico" +1342 ICON "activities/having_breakfast.ico" +1343 ICON "activities/having_dinner.ico" +1344 ICON "activities/having_lunch.ico" +1360 ICON "activities/exercising.ico" +1361 ICON "activities/cycling.ico" +1362 ICON "activities/dancing.ico" +1363 ICON "activities/hiking.ico" +1364 ICON "activities/jogging.ico" +1365 ICON "activities/playing_sports.ico" +1366 ICON "activities/running.ico" +1367 ICON "activities/skiing.ico" +1368 ICON "activities/swimming.ico" +1369 ICON "activities/working_out.ico" +1380 ICON "activities/grooming.ico" +1381 ICON "activities/at_the_spa.ico" +1382 ICON "activities/brushing_teeth.ico" +1383 ICON "activities/getting_a_haircut.ico" +1384 ICON "activities/shaving.ico" +1385 ICON "activities/taking_a_bath.ico" +1386 ICON "activities/taking_a_shower.ico" +1400 ICON "activities/having_appointment.ico" +1420 ICON "activities/inactive.ico" +1421 ICON "activities/day_off.ico" +1422 ICON "activities/hanging_out.ico" +1423 ICON "activities/hiding.ico" +1424 ICON "activities/on_vacation.ico" +1425 ICON "activities/praying.ico" +1426 ICON "activities/scheduled_holiday.ico" +1427 ICON "activities/sleeping.ico" +1428 ICON "activities/thinking.ico" +1440 ICON "activities/relaxing.ico" +1441 ICON "activities/fishing.ico" +1442 ICON "activities/gaming.ico" +1443 ICON "activities/going_out.ico" +1444 ICON "activities/partying.ico" +1445 ICON "activities/reading.ico" +1446 ICON "activities/rehearsing.ico" +1447 ICON "activities/shopping.ico" +1448 ICON "activities/smoking.ico" +1449 ICON "activities/socializing.ico" +1450 ICON "activities/sunbathing.ico" +1451 ICON "activities/watching_tv.ico" +1452 ICON "activities/watching_a_movie.ico" +1460 ICON "activities/talking.ico" +1461 ICON "activities/in_real_life.ico" +1462 ICON "activities/on_the_phone.ico" +1463 ICON "activities/on_video_phone.ico" +1480 ICON "activities/traveling.ico" +1481 ICON "activities/commuting.ico" +1482 ICON "activities/cycling.ico" +1483 ICON "activities/driving.ico" +1484 ICON "activities/in_a_car.ico" +1485 ICON "activities/on_a_bus.ico" +1486 ICON "activities/on_a_plane.ico" +1487 ICON "activities/on_a_train.ico" +1488 ICON "activities/on_a_trip.ico" +1489 ICON "activities/walking.ico" +1500 ICON "activities/working.ico" +1501 ICON "activities/coding.ico" +1502 ICON "activities/in_a_meeting.ico" +1503 ICON "activities/studying.ico" +1504 ICON "activities/writing.ico" diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index 2317ee00e8..854d565e1f 100755 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -156,6 +156,10 @@ int CMPlugin::Load() bPlatform = 0; #endif + char tmp[8]; + Utils_GetRandom(tmp, sizeof(tmp)); + bin2hex(tmp, sizeof(tmp), szRandom); + Miranda_GetVersionText(szCoreVersion, _countof(szCoreVersion)); CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&g_cbCountries, (LPARAM)&g_countries); diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp index 66a0ac71ef..4685038a02 100644 --- a/protocols/JabberG/src/jabber_adhoc.cpp +++ b/protocols/JabberG/src/jabber_adhoc.cpp @@ -103,7 +103,7 @@ void CJabberProto::OnIqResult_CommandExecution(const TiXmlElement *iqNode, CJabb void CJabberProto::AdHoc_RequestListOfCommands(char *szResponder, HWND hwndDlg) { - m_ThreadInfo->send(XmlNodeIq(AddIQ(&CJabberProto::OnIqResult_ListOfCommands, JABBER_IQ_TYPE_GET, szResponder, 0, -1, hwndDlg)) + m_ThreadInfo->send(XmlNodeIq(AddIQ(&CJabberProto::OnIqResult_ListOfCommands, JABBER_IQ_TYPE_GET, szResponder, hwndDlg)) << XQUERY(JABBER_FEAT_DISCO_ITEMS) << XATTR("node", JABBER_FEAT_COMMANDS)); } @@ -118,7 +118,7 @@ int CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, char*, JabberAdHocData *dat if (node) { const char *jid2 = XmlGetAttr(itemNode, "jid"); m_ThreadInfo->send( - XmlNodeIq(AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, jid2, 0, -1, hwndDlg)) + XmlNodeIq(AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, jid2, hwndDlg)) << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", node) << XATTR("action", "execute")); EnableDlgItem(hwndDlg, IDC_SUBMIT, FALSE); @@ -279,7 +279,7 @@ int CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData *dat, ch auto *xNode = XmlFirstChild(commandNode, "x"); const char *jid2 = XmlGetAttr(dat->AdHocNode, "from"); - XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, jid2, 0, -1, hwndDlg)); + XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, jid2, hwndDlg)); TiXmlElement *command = iq << XCHILDNS("command", JABBER_FEAT_COMMANDS); const char *sessionId = XmlGetAttr(commandNode, "sessionid"); @@ -341,7 +341,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA dat->proto = pStartupParams->m_pProto; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - Window_SetIcon_IcoLib(hwndDlg, g_GetIconHandle(IDI_COMMAND)); + Window_SetIcon_IcoLib(hwndDlg, g_plugin.getIconHandle(IDI_GROUP)); dat->proto->m_hwndCommandWindow = hwndDlg; TranslateDialogDefault(hwndDlg); @@ -371,7 +371,7 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA } else { dat->proto->m_ThreadInfo->send( - XmlNodeIq(dat->proto->AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, pStartupParams->m_szJid, 0, -1, hwndDlg)) + XmlNodeIq(dat->proto->AddIQ(&CJabberProto::OnIqResult_CommandExecution, JABBER_IQ_TYPE_SET, pStartupParams->m_szJid, hwndDlg)) << XCHILDNS("command", JABBER_FEAT_COMMANDS) << XATTR("node", pStartupParams->m_szNode) << XATTR("action", "execute")); diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp index 4d52cfa41b..42c91b1ce8 100644 --- a/protocols/JabberG/src/jabber_api.cpp +++ b/protocols/JabberG/src/jabber_api.cpp @@ -163,17 +163,6 @@ HJHANDLER CJabberProto::AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, con return (HJHANDLER)m_iqManager.AddPermanentHandler(&CJabberProto::ExternalIqHandler, iIqTypes, 0, szXmlns, FALSE, szTag, d, free, iPriority); } -HJHANDLER CJabberProto::AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, int iIqId, void *pUserData, DWORD dwTimeout, int iPriority) -{ - sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData)); - d->Func = Func; - d->pUserData = pUserData; - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::ExternalTempIqHandler, iIqTypes, nullptr, 0, iIqId, d, iPriority); - if (pInfo && dwTimeout > 0) - pInfo->SetTimeout(dwTimeout); - return (HJHANDLER)pInfo; -} - HJHANDLER CJabberProto::AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) { sHandlerData *d = (sHandlerData*)malloc(sizeof(sHandlerData)); diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp index 87ac8971f8..b3d8e0e791 100644 --- a/protocols/JabberG/src/jabber_bookmarks.cpp +++ b/protocols/JabberG/src/jabber_bookmarks.cpp @@ -186,7 +186,7 @@ public: { CSuper::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_BOOKMARKS)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_BOOKMARKS)); m_btnAdd.Disable(); m_btnEdit.Disable(); @@ -195,8 +195,8 @@ public: m_lvBookmarks.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP | LVS_EX_DOUBLEBUFFER); HIMAGELIST hIml = m_lvBookmarks.CreateImageList(LVSIL_SMALL); - ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("group")); - ImageList_AddIcon_Icolib(hIml, Skin_LoadIcon(SKINICON_EVENT_URL)); + g_plugin.addImgListIcon(hIml, IDI_GROUP); + ImageList_AddSkinIcon(hIml, SKINICON_EVENT_URL); m_lvBookmarks.AddColumn(0, TranslateT("Bookmark Name"), m_proto->getWord("bookmarksWnd_cx0", 120)); m_lvBookmarks.AddColumn(1, TranslateT("Address (JID or URL)"), m_proto->getWord("bookmarksWnd_cx1", 210)); diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp index 5d89502c94..c72ebaaea6 100644 --- a/protocols/JabberG/src/jabber_byte.cpp +++ b/protocols/JabberG/src/jabber_byte.cpp @@ -161,7 +161,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) jbt->szProxyJid = nullptr; jbt->hProxyEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::IqResultProxyDiscovery, JABBER_IQ_TYPE_GET, proxyJid, 0, -1, jbt); + CJabberIqInfo *pInfo = AddIQ(&CJabberProto::IqResultProxyDiscovery, JABBER_IQ_TYPE_GET, proxyJid, jbt); nIqId = pInfo->GetIqId(); XmlNodeIq iq(pInfo); iq << XQUERY(JABBER_FEAT_BYTESTREAMS); @@ -184,7 +184,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) } } - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::ByteInitiateResult, JABBER_IQ_TYPE_SET, jbt->dstJID, 0, -1, jbt); + CJabberIqInfo *pInfo = AddIQ(&CJabberProto::ByteInitiateResult, JABBER_IQ_TYPE_SET, jbt->dstJID, jbt); nIqId = pInfo->GetIqId(); char szPort[8]; { @@ -538,18 +538,15 @@ int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jb jbt->hProxyEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); jbt->bStreamActivated = FALSE; - int iqId = SerialNext(); + auto *pIq = AddIQ(&CJabberProto::IqResultStreamActivate, JABBER_IQ_TYPE_SET, jbt->streamhostJID); char listJid[256]; - mir_snprintf(listJid, "ftproxy_%d", iqId); + mir_snprintf(listJid, "ftproxy_%d", pIq->GetIqId()); JABBER_LIST_ITEM *item = ListAdd(LIST_FTIQID, listJid); item->jbt = jbt; - m_ThreadInfo->send( - XmlNodeIq(AddIQ(&CJabberProto::IqResultStreamActivate, JABBER_IQ_TYPE_SET, jbt->streamhostJID, 0, iqId)) - << XQUERY(JABBER_FEAT_BYTESTREAMS) << XATTR("sid", jbt->sid) << XCHILD("activate", jbt->dstJID)); - + m_ThreadInfo->send(XmlNodeIq(pIq) << XQUERY(JABBER_FEAT_BYTESTREAMS) << XATTR("sid", jbt->sid) << XCHILD("activate", jbt->dstJID)); WaitForSingleObject(jbt->hProxyEvent, INFINITE); CloseHandle(jbt->hProxyEvent); diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index 50a94e6204..b4c4ad2923 100755 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -264,7 +264,8 @@ JabberCapsBits CJabberProto::GetResourceCapabilities(const char *jid, pResourceS if (jcbMainCaps == JABBER_RESOURCE_CAPS_UNINIT) { // send disco#info query - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE); + CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, jid); + pInfo->SetParamsToParse(JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE); pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT); pCaps->SetCaps(JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId()); r->m_dwDiscoInfoRequestTime = pInfo->GetRequestTime(); @@ -318,7 +319,8 @@ JabberCapsBits CJabberProto::GetResourceCapabilities(const char *jid, pResourceS void CJabberProto::RequestOldCapsInfo(pResourceStatus &r, const char *fullJid) { - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE); + CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid); + pInfo->SetParamsToParse(JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE); pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT); r->m_dwDiscoInfoRequestTime = pInfo->GetRequestTime(); diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 1a70cecb22..9b4dc70a54 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -689,7 +689,7 @@ public: m_newJids(1), m_btnInvite(this, IDC_INVITE), m_txtNewJid(this, IDC_NEWJID), - m_btnAddJid(this, IDC_ADDJID, ppro->LoadIconEx("addroster"), "Add"), + m_btnAddJid(this, IDC_ADDJID, g_plugin.getIcon(IDI_ADDCONTACT), "Add"), m_txtReason(this, IDC_REASON), m_clc(this, IDC_CLIST) { @@ -713,7 +713,7 @@ public: CSuper::OnInitDialog(); SetDlgItemText(m_hwnd, IDC_HEADERBAR, CMStringW(FORMAT, TranslateT("Invite Users to\n%s"), m_room)); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_GROUP)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_GROUP)); SetWindowLongPtr(m_clc.GetHwnd(), GWL_STYLE, GetWindowLongPtr(m_clc.GetHwnd(), GWL_STYLE) | CLS_SHOWHIDDEN | CLS_HIDEOFFLINE | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES); @@ -819,7 +819,7 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); dat = (TUserInfoData *)lParam; - Window_SetIcon_IcoLib(hwndDlg, g_GetIconHandle(IDI_GROUP)); + Window_SetIcon_IcoLib(hwndDlg, g_plugin.getIconHandle(IDI_GROUP)); { LOGFONT lf; GetObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_TXT_NICK, WM_GETFONT, 0, 0), sizeof(lf), &lf); diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp index 80510be24f..6c1de0b61a 100644 --- a/protocols/JabberG/src/jabber_console.cpp +++ b/protocols/JabberG/src/jabber_console.cpp @@ -298,14 +298,14 @@ struct { int type; wchar_t *title; - char *icon; + int icon; } static filter_modes[] = { - { TFilterInfo::T_JID, L"JID", "main" }, - { TFilterInfo::T_XMLNS, L"xmlns", "xmlconsole" }, - { TFilterInfo::T_ANY, L"all attributes", "sd_filter_apply" }, - { TFilterInfo::T_OFF, L"disabled", "sd_filter_reset" }, + { TFilterInfo::T_JID, L"JID", IDI_JABBER }, + { TFilterInfo::T_XMLNS, L"xmlns", IDI_CONSOLE }, + { TFilterInfo::T_ANY, L"all attributes", IDI_FILTER_APPLY }, + { TFilterInfo::T_OFF, L"disabled", IDI_FILTER_RESET }, }; class CJabberDlgConsole : public CJabberDlgBase @@ -321,7 +321,7 @@ public: { CSuper::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_CONSOLE)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_CONSOLE)); SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_SETEDITSTYLE, SES_EXTENDBACKCOLOR, SES_EXTENDBACKCOLOR); SendDlgItemMessage(m_hwnd, IDC_CONSOLE, EM_EXLIMITTEXT, 0, 0x80000000); @@ -342,21 +342,21 @@ public: { int idc; char *title; - char *icon; + int icon; bool push; BOOL pushed; } static buttons[] = { - { IDC_BTN_MSG, "Messages", "pl_msg_allow", true, m_proto->m_filterInfo.msg}, - { IDC_BTN_PRESENCE, "Presences", "pl_prin_allow", true, m_proto->m_filterInfo.presence}, - { IDC_BTN_IQ, "Queries", "pl_iq_allow", true, m_proto->m_filterInfo.iq}, - { IDC_BTN_FILTER, "Filter mode", "sd_filter_apply", true, FALSE}, - { IDC_BTN_FILTER_REFRESH, "Refresh list", "sd_nav_refresh", false, FALSE}, + { IDC_BTN_MSG, "Messages", IDI_PL_MSG_ALLOW, true, m_proto->m_filterInfo.msg }, + { IDC_BTN_PRESENCE, "Presences", IDI_PL_PRIN_ALLOW, true, m_proto->m_filterInfo.presence }, + { IDC_BTN_IQ, "Queries", IDI_PL_QUERY_ALLOW, true, m_proto->m_filterInfo.iq }, + { IDC_BTN_FILTER, "Filter mode", IDI_FILTER_APPLY, true, false }, + { IDC_BTN_FILTER_REFRESH, "Refresh list", IDI_NAV_REFRESH, false, false }, }; for (auto &it : buttons) { - SendDlgItemMessage(m_hwnd, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)); + SendDlgItemMessage(m_hwnd, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(it.icon)); SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(m_hwnd, it.idc, BUTTONADDTOOLTIP, (WPARAM)it.title, 0); if (it.push) @@ -367,8 +367,8 @@ public: for (auto &it : filter_modes) if (it.type == m_proto->m_filterInfo.type) { - IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon))); - SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)); + IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(it.icon))); + SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(it.icon)); break; } @@ -527,7 +527,7 @@ public: m_proto->m_filterInfo.type = (TFilterInfo::Type)(res - 1); for (auto &it : filter_modes) { if (it.type == m_proto->m_filterInfo.type) { - IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon))); + IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(it.icon))); break; } } diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index 30d9ea5519..c299941589 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -51,57 +51,51 @@ static DWORD sttLastAutoDisco = 0; enum { SD_OVERLAY_NONE, SD_OVERLAY_FAIL, SD_OVERLAY_PROGRESS, SD_OVERLAY_REGISTERED }; -static struct +struct { char *feature; char *category; char *type; - char *iconName; + int iconRes; int iconIndex; int listIndex; -} sttNodeIcons[] = +} +static sttNodeIcons[] = { // standard identities: http://www.xmpp.org/registrar/disco-categories.html#directory - {nullptr, "account", nullptr, nullptr, SKINICON_STATUS_ONLINE}, - {nullptr, "auth", nullptr, "key", 0}, - {nullptr, "automation", nullptr, "adhoc", 0}, - {nullptr, "client", nullptr, nullptr, SKINICON_STATUS_ONLINE}, - {nullptr, "collaboration", nullptr, "group", 0}, - {nullptr, "conference", nullptr, "group", 0}, - - {nullptr, "directory", "chatroom", "group", 0}, - {nullptr, "directory", "group", "group", 0}, - {nullptr, "directory", "user", nullptr, SKINICON_OTHER_FINDUSER}, - {nullptr, "directory", nullptr, nullptr, SKINICON_OTHER_SEARCHALL}, - - {nullptr, "gateway", "aim", "AIM", SKINICON_STATUS_ONLINE}, - {nullptr, "gateway", "gadu-gadu", "GG", SKINICON_STATUS_ONLINE}, - {nullptr, "gateway", "icq", "ICQ", SKINICON_STATUS_ONLINE}, - {nullptr, "gateway", "msn", "MSN", SKINICON_STATUS_ONLINE}, - {nullptr, "gateway", "qq", "QQ", SKINICON_STATUS_ONLINE}, - {nullptr, "gateway", "tlen", "TLEN", SKINICON_STATUS_ONLINE}, - {nullptr, "gateway", "yahoo", "YAHOO", SKINICON_STATUS_ONLINE}, - {nullptr, "gateway", nullptr, "Agents", 0}, - - {nullptr, "headline", "rss", "node_rss", 0}, - {nullptr, "headline", "weather", "node_weather", 0}, - - {nullptr, "proxy", nullptr, nullptr, SKINICON_EVENT_FILE}, - - {nullptr, "server", nullptr, "node_server", 0}, - - {nullptr, "store", nullptr, "node_store", 0}, - - // icons for non-standard identities - {nullptr, "x-service", "x-rss", "node_rss", 0}, - {nullptr, "application", "x-weather", "node_weather", 0}, - {nullptr, "user", nullptr, nullptr, SKINICON_STATUS_ONLINE}, - - // icon suggestions based on supported features - {"jabber:iq:gateway", nullptr, nullptr, "Agents", 0}, - {"jabber:iq:search", nullptr, nullptr, nullptr, SKINICON_OTHER_FINDUSER}, - {JABBER_FEAT_COMMANDS, nullptr, nullptr, "adhoc", 0}, - {JABBER_FEAT_REGISTER, nullptr, nullptr, "key", 0}, + {nullptr, "account", nullptr, 0, SKINICON_STATUS_ONLINE}, + {nullptr, "auth", nullptr, IDI_KEYS, 0}, + {nullptr, "automation", nullptr, IDI_COMMAND, 0}, + {nullptr, "client", nullptr, 0, SKINICON_STATUS_ONLINE}, + {nullptr, "collaboration", nullptr, IDI_GROUP, 0}, + {nullptr, "conference", nullptr, IDI_GROUP, 0}, + + {nullptr, "directory", "chatroom", IDI_GROUP, 0}, + {nullptr, "directory", "group", IDI_GROUP, 0}, + {nullptr, "directory", "user", 0, SKINICON_OTHER_FINDUSER}, + {nullptr, "directory", nullptr, 0, SKINICON_OTHER_SEARCHALL}, + + {nullptr, "gateway", nullptr, IDI_AGENTS, 0}, + + {nullptr, "headline", "rss", IDI_NODE_RSS, 0}, + {nullptr, "headline", "weather", IDI_NODE_WEATHER, 0}, + + {nullptr, "proxy", nullptr, 0, SKINICON_EVENT_FILE}, + + {nullptr, "server", nullptr, IDI_NODE_SERVER, 0}, + + {nullptr, "store", nullptr, IDI_NODE_STORE, 0}, + + // icons for non-standard identities + {nullptr, "x-service", "x-rss", IDI_NODE_RSS, 0}, + {nullptr, "application", "x-weather", IDI_NODE_WEATHER, 0}, + {nullptr, "user", nullptr, 0, SKINICON_STATUS_ONLINE}, + + // icon suggestions based on supported features + {"jabber:iq:gateway", nullptr, nullptr, IDI_AGENTS, 0}, + {"jabber:iq:search", nullptr, nullptr, 0, SKINICON_OTHER_FINDUSER}, + {JABBER_FEAT_COMMANDS, nullptr, nullptr, IDI_COMMAND, 0}, + {JABBER_FEAT_REGISTER, nullptr, nullptr, IDI_KEYS, 0}, }; void CJabberProto::OnIqResultServiceDiscoveryInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) @@ -181,12 +175,12 @@ void CJabberProto::OnIqResultServiceDiscoveryItems(const TiXmlElement *iqNode, C void CJabberProto::OnIqResultServiceDiscoveryRootInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { - if (!pInfo->m_pUserData) return; + if (!pInfo->GetUserData()) return; mir_cslockfull lck(m_SDManager.cs()); if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) { for (auto *feature : TiXmlFilter(XmlFirstChild(iqNode, "query"), "feature")) { - if (!mir_strcmp(XmlGetAttr(feature, "var"), (char*)pInfo->m_pUserData)) { + if (!mir_strcmp(XmlGetAttr(feature, "var"), (char*)pInfo->GetUserData())) { CJabberSDNode *pNode = m_SDManager.AddPrimaryNode(pInfo->GetReceiver(), XmlGetAttr(iqNode, "node")); SendBothRequests(pNode); break; @@ -200,7 +194,7 @@ void CJabberProto::OnIqResultServiceDiscoveryRootInfo(const TiXmlElement *iqNode void CJabberProto::OnIqResultServiceDiscoveryRootItems(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { - if (!pInfo->m_pUserData) + if (!pInfo->GetUserData()) return; TiXmlDocument packet; @@ -209,8 +203,7 @@ void CJabberProto::OnIqResultServiceDiscoveryRootItems(const TiXmlElement *iqNod for (auto *item : TiXmlFilter(XmlFirstChild(iqNode, "query"), "item")) { const char *szJid = XmlGetAttr(item, "jid"); const char *szNode = XmlGetAttr(item, "node"); - CJabberIqInfo *pNewInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid); - pNewInfo->m_pUserData = pInfo->m_pUserData; + CJabberIqInfo *pNewInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootInfo, JABBER_IQ_TYPE_GET, szJid, pInfo->GetUserData()); pNewInfo->SetTimeout(30000); XmlNodeIq iq(pNewInfo); @@ -341,16 +334,14 @@ void CJabberProto::PerformBrowse(HWND hwndDlg) } } else if (!mir_wstrcmp(szJid, _T(SD_FAKEJID_CONFERENCES))) { - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, m_ThreadInfo->conn.server); - pInfo->m_pUserData = (void*)JABBER_FEAT_MUC; + CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, m_ThreadInfo->conn.server, (void*)JABBER_FEAT_MUC); pInfo->SetTimeout(30000); XmlNodeIq iq(pInfo); iq << XQUERY(JABBER_FEAT_DISCO_ITEMS); m_ThreadInfo->send(iq); } else if (!mir_wstrcmp(szJid, _T(SD_FAKEJID_AGENTS))) { - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, m_ThreadInfo->conn.server); - pInfo->m_pUserData = (void*)L"jabber:iq:gateway"; + CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultServiceDiscoveryRootItems, JABBER_IQ_TYPE_GET, m_ThreadInfo->conn.server, L"jabber:iq:gateway"); pInfo->SetTimeout(30000); XmlNodeIq iq(pInfo); iq << XQUERY(JABBER_FEAT_DISCO_ITEMS); @@ -423,7 +414,7 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode) } for (auto &it : sttNodeIcons) { - if (!it.iconIndex && !it.iconName) + if (!it.iconIndex && !it.iconRes) continue; if (it.category) { @@ -506,12 +497,12 @@ public: CJabberDlgDiscovery(CJabberProto *proto, char *jid) : CJabberDlgBase(proto, IDD_SERVICE_DISCOVERY), m_jid(jid), - m_btnViewAsTree(this, IDC_BTN_VIEWTREE, proto->LoadIconEx("sd_view_tree"), "View as tree"), - m_btnViewAsList(this, IDC_BTN_VIEWLIST, proto->LoadIconEx("sd_view_list"), "View as list"), - m_btnGoHome(this, IDC_BTN_NAVHOME, proto->LoadIconEx("sd_nav_home"), "Navigate home"), - m_btnBookmarks(this, IDC_BTN_FAVORITE, proto->LoadIconEx("bookmarks"), "Favorites"), - m_btnRefresh(this, IDC_BTN_REFRESH, proto->LoadIconEx("sd_nav_refresh"), "Refresh node"), - m_btnBrowse(this, IDC_BUTTON_BROWSE, proto->LoadIconEx("sd_browse"), "Browse"), + m_btnViewAsTree(this, IDC_BTN_VIEWTREE, g_plugin.getIcon(IDI_VIEW_TREE), "View as tree"), + m_btnViewAsList(this, IDC_BTN_VIEWLIST, g_plugin.getIcon(IDI_VIEW_LIST), "View as list"), + m_btnGoHome(this, IDC_BTN_NAVHOME, g_plugin.getIcon(IDI_NAV_HOME), "Navigate home"), + m_btnBookmarks(this, IDC_BTN_FAVORITE, g_plugin.getIcon(IDI_BOOKMARKS), "Favorites"), + m_btnRefresh(this, IDC_BTN_REFRESH, g_plugin.getIcon(IDI_NAV_REFRESH), "Refresh node"), + m_btnBrowse(this, IDC_BUTTON_BROWSE, g_plugin.getIcon(IDI_BROWSE), "Browse"), m_lstDiscoTree(this, IDC_TREE_DISCO), m_filter(this, IDC_FILTER) { @@ -529,7 +520,7 @@ public: { CSuper::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_SERVICE_DISCOVERY)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_SERVICE_DISCOVERY)); if (m_jid) { SetDlgItemTextUtf(m_hwnd, IDC_COMBO_JID, m_jid); @@ -572,25 +563,19 @@ public: ListView_InsertColumn(hwndList, 2, &lvc); TreeList_Create(hwndList); - TreeList_AddIcon(hwndList, m_proto->LoadIconEx("main"), 0); + TreeList_AddIcon(hwndList, g_plugin.getIcon(IDI_JABBER), 0); for (auto &it : sttNodeIcons) { - bool needDestroy = false; HICON hIcon; - if ((it.iconIndex == SKINICON_STATUS_ONLINE) && it.iconName) { - hIcon = (HICON)CallProtoService(it.iconName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0); - needDestroy = true; - } - else if (it.iconName) - hIcon = m_proto->LoadIconEx(it.iconName); + if (it.iconRes) + hIcon = g_plugin.getIcon(it.iconRes); else if (it.iconIndex) hIcon = Skin_LoadIcon(it.iconIndex); else continue; it.listIndex = TreeList_AddIcon(hwndList, hIcon, 0); - if (needDestroy) DestroyIcon(hIcon); } - TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_fail"), SD_OVERLAY_FAIL); - TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_progress"), SD_OVERLAY_PROGRESS); - TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_ok"), SD_OVERLAY_REGISTERED); + TreeList_AddIcon(hwndList, g_plugin.getIcon(IDI_DISCO_FAIL), SD_OVERLAY_FAIL); + TreeList_AddIcon(hwndList, g_plugin.getIcon(IDI_DISCO_PROGRESS), SD_OVERLAY_PROGRESS); + TreeList_AddIcon(hwndList, g_plugin.getIcon(IDI_DISCO_OK), SD_OVERLAY_REGISTERED); TreeList_SetMode(hwndList, m_proto->getByte("discoWnd_useTree", 1) ? TLM_TREE : TLM_REPORT); diff --git a/protocols/JabberG/src/jabber_frame.cpp b/protocols/JabberG/src/jabber_frame.cpp index 4ce01e3396..fcc0d2eed1 100644 --- a/protocols/JabberG/src/jabber_frame.cpp +++ b/protocols/JabberG/src/jabber_frame.cpp @@ -102,7 +102,7 @@ CJabberInfoFrame::CJabberInfoFrame(CJabberProto *proto) : SetWindowPos(m_hwndToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); CreateInfoItem("$", true); - UpdateInfoItem("$", proto->GetIconHandle(IDI_JABBER), proto->m_tszUserName); + UpdateInfoItem("$", proto->m_hProtoIcon, proto->m_tszUserName); CreateInfoItem("$/JID", true); UpdateInfoItem("$/JID", Skin_GetIconHandle(SKINICON_OTHER_USERDETAILS), L"Offline"); diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index c63f50aa96..e832925e2a 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -97,7 +97,9 @@ void CJabberProto::FtInitiate(char* jid, filetransfer *ft) if (wchar_t *p = wcsrchr(filename, '\\')) filename = p + 1; - XmlNodeIq iq(AddIQ(&CJabberProto::OnFtSiResult, JABBER_IQ_TYPE_SET, MakeJid(jid, rs), JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO, -1, ft)); + auto *pIq = AddIQ(&CJabberProto::OnFtSiResult, JABBER_IQ_TYPE_SET, MakeJid(jid, rs), ft); + pIq->SetParamsToParse(JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_TO); + XmlNodeIq iq(pIq); TiXmlElement *si = iq << XCHILDNS("si", JABBER_FEAT_SI) << XATTR("id", sid) << XATTR("mime-type", "binary/octet-stream") << XATTR("profile", JABBER_FEAT_SI_FT); si << XCHILDNS("file", JABBER_FEAT_SI_FT) << XATTR("name", T2Utf(filename)) @@ -124,7 +126,7 @@ void CJabberProto::OnFtSiResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo if (!ft) return; - if ((pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) && pInfo->m_szFrom && pInfo->m_szTo) { + if ((pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) && pInfo->GetFrom() && pInfo->GetTo()) { if (auto *siNode = XmlFirstChild(iqNode, "si")) { // fix for very smart clients, like gajim BOOL bDirect = m_bBsDirect; @@ -138,8 +140,8 @@ void CJabberProto::OnFtSiResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo // Start Bytestream session JABBER_BYTE_TRANSFER *jbt = new JABBER_BYTE_TRANSFER; memset(jbt, 0, sizeof(JABBER_BYTE_TRANSFER)); - jbt->srcJID = mir_strdup(pInfo->m_szTo); - jbt->dstJID = mir_strdup(pInfo->m_szFrom); + jbt->srcJID = mir_strdup(pInfo->GetTo()); + jbt->dstJID = mir_strdup(pInfo->GetFrom()); jbt->sid = mir_strdup(ft->sid); jbt->pfnSend = &CJabberProto::FtSend; jbt->pfnFinal = &CJabberProto::FtSendFinal; @@ -151,8 +153,8 @@ void CJabberProto::OnFtSiResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo else if (!mir_strcmp(valueNode->GetText(), JABBER_FEAT_IBB)) { JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)mir_alloc(sizeof(JABBER_IBB_TRANSFER)); memset(jibb, 0, sizeof(JABBER_IBB_TRANSFER)); - jibb->srcJID = mir_strdup(pInfo->m_szTo); - jibb->dstJID = mir_strdup(pInfo->m_szFrom); + jibb->srcJID = mir_strdup(pInfo->GetTo()); + jibb->dstJID = mir_strdup(pInfo->GetFrom()); jibb->sid = mir_strdup(ft->sid); jibb->pfnSend = &CJabberProto::FtIbbSend; jibb->pfnFinal = &CJabberProto::FtSendFinal; diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 3fba354194..7e18ceae1b 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -403,7 +403,7 @@ public: { CSuper::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_GROUP)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_GROUP)); JabberGcRecentInfo *pInfo = nullptr; if (m_jid) @@ -443,7 +443,7 @@ public: lf.lfWeight = FW_BOLD; SendDlgItemMessage(m_hwnd, IDC_TXT_RECENT, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE); - SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx("bookmarks")); + SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_BOOKMARKS)); SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONADDTOOLTIP, (WPARAM)"Bookmarks", 0); SendDlgItemMessage(m_hwnd, IDC_BOOKMARKS, BUTTONSETASPUSHBTN, TRUE, 0); @@ -561,16 +561,16 @@ public: SetTextColor(lpdis->hDC, clLine2); DrawText(lpdis->hDC, info->line2, -1, &rc, DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS); - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("group"), 16, 16, 0, nullptr, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, g_plugin.getIcon(IDI_GROUP), 16, 16, 0, nullptr, DI_NORMAL); switch (info->overlay) { case RoomInfo::ROOM_WAIT: - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_progress"), 16, 16, 0, nullptr, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, g_plugin.getIcon(IDI_DISCO_PROGRESS), 16, 16, 0, nullptr, DI_NORMAL); break; case RoomInfo::ROOM_FAIL: - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_fail"), 16, 16, 0, nullptr, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, g_plugin.getIcon(IDI_DISCO_FAIL), 16, 16, 0, nullptr, DI_NORMAL); break; case RoomInfo::ROOM_BOOKMARK: - DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, m_proto->LoadIconEx("disco_ok"), 16, 16, 0, nullptr, DI_NORMAL); + DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 1, lpdis->rcItem.top + 1, g_plugin.getIcon(IDI_DISCO_OK), 16, 16, 0, nullptr, DI_NORMAL); break; } } @@ -613,7 +613,7 @@ public: if (*server) { sttRoomListAppend(GetDlgItem(m_hwnd, IDC_ROOM), RoomInfo::ROOM_WAIT, TranslateT("Loading..."), TranslateT("Please wait for room list to download."), L""); - CJabberIqInfo *pInfo = m_proto->AddIQ(&CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, T2Utf(server), 0, -1, (void*)GetDlgItem(m_hwnd, IDC_ROOM)); + CJabberIqInfo *pInfo = m_proto->AddIQ(&CJabberProto::OnIqResultDiscovery, JABBER_IQ_TYPE_GET, T2Utf(server), (void*)GetDlgItem(m_hwnd, IDC_ROOM)); pInfo->SetTimeout(30000); XmlNodeIq iq(pInfo); iq << XQUERY(JABBER_FEAT_DISCO_ITEMS); @@ -1145,7 +1145,7 @@ public: SetDlgItemTextUtf(m_hwnd, IDC_REASON, m_reason); SetDlgItemTextUtf(m_hwnd, IDC_NICK, JabberNickFromJID(m_proto->m_szJabberJID)); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_GROUP)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_GROUP)); SetFocus(GetDlgItem(m_hwnd, IDC_NICK)); return true; diff --git a/protocols/JabberG/src/jabber_ibb.cpp b/protocols/JabberG/src/jabber_ibb.cpp index c0eadf883e..59edaf6a5f 100644 --- a/protocols/JabberG/src/jabber_ibb.cpp +++ b/protocols/JabberG/src/jabber_ibb.cpp @@ -98,7 +98,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) jibb->state = JIBB_SENDING; m_ThreadInfo->send( - XmlNodeIq(AddIQ(&CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb)) + XmlNodeIq(AddIQ(&CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, jibb)) << XCHILDNS("open", JABBER_FEAT_IBB) << XATTR("sid", jibb->sid) << XATTRI("block-size", JABBER_IBB_BLOCK_SIZE) << XATTR("stanza", "message")); @@ -115,7 +115,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) jibb->hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); m_ThreadInfo->send( - XmlNodeIq(AddIQ(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb)) + XmlNodeIq(AddIQ(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, jibb)) << XCHILDNS("close", JABBER_FEAT_IBB) << XATTR("sid", jibb->sid)); WaitForSingleObject(jibb->hEvent, INFINITE); diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index ec8fdfedc8..e3b9b58054 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -172,25 +172,6 @@ void CJabberProto::IconsInit(void) m_transportProtoTableStartIndex[i] = -1; } -HANDLE CJabberProto::GetIconHandle(int iconId) -{ - if (iconId == IDI_JABBER) - return m_hProtoIcon; - - return g_GetIconHandle(iconId); -} - -HICON CJabberProto::LoadIconEx(const char* name, bool big) -{ - if (HICON result = g_LoadIconEx(name, big)) - return result; - - if (!mir_strcmp(name, "main")) - return IcoLib_GetIconByHandle(m_hProtoIcon, big); - - return nullptr; -} - ///////////////////////////////////////////////////////////////////////////////////////// // internal functions @@ -456,7 +437,7 @@ void CJabberProto::CheckAllContactsAreTransported() static IconItem sharedIconList1[] = { - { LPGEN("Jabber"), "jabber", IDI_JABBER }, + { LPGEN("Jabber"), "jabber", IDI_JABBER }, { LPGEN("Privacy Lists"), "privacylists", IDI_PRIVACY_LISTS }, { LPGEN("Bookmarks"), "bookmarks", IDI_BOOKMARKS }, { LPGEN("Notes"), "notes", IDI_NOTES }, @@ -522,42 +503,8 @@ static IconItem sharedIconList4[] = void g_IconsInit() { - g_plugin.registerIcon(LPGEN("Protocols") "/" LPGEN("Jabber"), sharedIconList1, GLOBAL_SETTING_PREFIX); - g_plugin.registerIcon(LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs"), sharedIconList2, GLOBAL_SETTING_PREFIX); - g_plugin.registerIcon(LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs") "/" LPGEN("Discovery"), sharedIconList3, GLOBAL_SETTING_PREFIX); - g_plugin.registerIcon(LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs") "/" LPGEN("Privacy"), sharedIconList4, GLOBAL_SETTING_PREFIX); -} - -HANDLE g_GetIconHandle(int iconId) -{ - for (auto &it : sharedIconList1) - if (it.defIconID == iconId) - return it.hIcolib; - - for (auto &it : sharedIconList2) - if (it.defIconID == iconId) - return it.hIcolib; - - for (auto &it : sharedIconList3) - if (it.defIconID == iconId) - return it.hIcolib; - - for (auto &it : sharedIconList4) - if (it.defIconID == iconId) - return it.hIcolib; - - return nullptr; -} - -HICON g_LoadIconEx(const char* name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", GLOBAL_SETTING_PREFIX, name); - return IcoLib_GetIcon(szSettingName, big); -} - -void ImageList_AddIcon_Icolib(HIMAGELIST hIml, HICON hIcon) -{ - ImageList_AddIcon(hIml, hIcon); - IcoLib_ReleaseIcon(hIcon); + g_plugin.registerIcon(LPGEN("Protocols") "/" LPGEN("Jabber"), sharedIconList1, GLOBAL_SETTING_MODULE); + g_plugin.registerIcon(LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs"), sharedIconList2, GLOBAL_SETTING_MODULE); + g_plugin.registerIcon(LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs") "/" LPGEN("Discovery"), sharedIconList3, GLOBAL_SETTING_MODULE); + g_plugin.registerIcon(LPGEN("Protocols") "/" LPGEN("Jabber") "/" LPGEN("Dialogs") "/" LPGEN("Privacy"), sharedIconList4, GLOBAL_SETTING_MODULE); } diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp index ca1f0b1e17..fc0f50d997 100644 --- a/protocols/JabberG/src/jabber_iq.cpp +++ b/protocols/JabberG/src/jabber_iq.cpp @@ -201,15 +201,12 @@ void CJabberIqManager::ExpireAll() ExpireInfo(pInfo); } -CJabberIqInfo* CJabberIqManager::AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const char *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority) +CJabberIqInfo* CJabberIqManager::AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const char *szReceiver, void *pUserData, int iPriority) { CJabberIqInfo *pInfo = new CJabberIqInfo(); pInfo->m_pHandler = pHandler; - if (nIqId == -1) - nIqId = ppro->SerialNext(); - pInfo->m_nIqId = nIqId; + pInfo->m_nIqId = ppro->SerialNext(); pInfo->m_nIqType = nIqType; - pInfo->m_dwParamsToParse = dwParamsToParse; pInfo->m_pUserData = pUserData; pInfo->m_dwRequestTime = GetTickCount(); pInfo->m_dwTimeout = JABBER_DEFAULT_IQ_REQUEST_TIMEOUT; diff --git a/protocols/JabberG/src/jabber_iq.h b/protocols/JabberG/src/jabber_iq.h index f7210f45eb..f457a55496 100644 --- a/protocols/JabberG/src/jabber_iq.h +++ b/protocols/JabberG/src/jabber_iq.h @@ -61,8 +61,6 @@ protected: DWORD m_dwTimeout; char* m_szReceiver; int m_iPriority; - -public: void* m_pUserData; int m_nIqType; const char* m_szFrom; @@ -166,7 +164,7 @@ public: void Shutdown(); // fucking params, maybe just return CJabberIqRequestInfo pointer ? - CJabberIqInfo* AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const char *szReceiver, DWORD dwParamsToParse, int nIqId, void *pUserData, int iPriority); + CJabberIqInfo* AddHandler(JABBER_IQ_HANDLER pHandler, int nIqType, const char *szReceiver, void *pUserData, int iPriority); CJabberIqPermanentInfo* AddPermanentHandler(JABBER_PERMANENT_IQ_HANDLER pHandler, int nIqTypes, DWORD dwParamsToParse, const char *szXmlns, BOOL bAllowPartialNs, const char *szTag, void *pUserData = nullptr, IQ_USER_DATA_FREE_FUNC pUserDataFree = nullptr, int iPriority = JH_PRIORITY_DEFAULT); // returns TRUE when pInfo found, or FALSE otherwise diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index 8686e1f314..bed8949e14 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -431,7 +431,7 @@ BOOL CJabberProto::AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams) mir_snprintf(szService, "%s%s", m_szModuleName, JS_HTTP_AUTH); CLISTEVENT cle = {}; - cle.hIcon = (HICON)LoadIconEx("openid"); + cle.hIcon = g_plugin.getIcon(IDI_HTTP_AUTH); cle.flags = CLEF_PROTOCOLGLOBAL | CLEF_UNICODE; cle.hDbEvent = -99; cle.lParam = (LPARAM)pParams; diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 5b82a7d45b..e5a231f64c 100755 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -105,7 +105,7 @@ void CJabberProto::OnIqResultNestedRosterGroups(const TiXmlElement *iqNode, CJab // roster request char *szUserData = mir_strdup(szGroupDelimiter ? szGroupDelimiter : "\\"); m_ThreadInfo->send( - XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, nullptr, 0, -1, (void*)szUserData)) + XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, nullptr, szUserData)) << XCHILDNS("query", JABBER_FEAT_IQ_ROSTER)); } @@ -1505,12 +1505,12 @@ void CJabberProto::OnIqResultSetBookmarks(const TiXmlElement *iqNode, CJabberIqI // last activity (XEP-0012) support void CJabberProto::OnIqResultLastActivity(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { - pResourceStatus r(ResourceInfoFromJID(pInfo->m_szFrom)); + pResourceStatus r(ResourceInfoFromJID(pInfo->GetFrom())); if (r == nullptr) return; time_t lastActivity = -1; - if (pInfo->m_nIqType == JABBER_IQ_TYPE_RESULT) { + if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) { if (auto *xmlLast = XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_LAST_ACTIVITY)) { int nSeconds = xmlLast->IntAttribute("seconds"); lastActivity = (nSeconds == 0) ? 0 : time(0) - nSeconds; @@ -1528,10 +1528,10 @@ void CJabberProto::OnIqResultLastActivity(const TiXmlElement *iqNode, CJabberIqI // entity time (XEP-0202) support void CJabberProto::OnIqResultEntityTime(const TiXmlElement *pIqNode, CJabberIqInfo *pInfo) { - if (!pInfo->m_hContact) + if (!pInfo->GetHContact()) return; - if (pInfo->m_nIqType == JABBER_IQ_TYPE_RESULT) { + if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) { auto *xmlTime = XmlGetChildByTag(pIqNode, "time", "xmlns", JABBER_FEAT_ENTITY_TIME); if (xmlTime) { const char *szTzo = XmlGetChildText(xmlTime, "tzo"); @@ -1544,22 +1544,22 @@ void CJabberProto::OnIqResultEntityTime(const TiXmlElement *pIqNode, CJabberIqIn if (GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_DAYLIGHT) nTz -= tzinfo.DaylightBias / 30; - setByte(pInfo->m_hContact, "Timezone", (signed char)nTz); + setByte(pInfo->GetHContact(), "Timezone", (signed char)nTz); const char *szTz = XmlGetChildText(xmlTime, "tz"); if (szTz) - setUString(pInfo->m_hContact, "TzName", szTz); + setUString(pInfo->GetHContact(), "TzName", szTz); else - delSetting(pInfo->m_hContact, "TzName"); + delSetting(pInfo->GetHContact(), "TzName"); return; } } } - else if (pInfo->m_nIqType == JABBER_IQ_TYPE_ERROR) { - if (getWord(pInfo->m_hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) + else if (pInfo->GetIqType() == JABBER_IQ_TYPE_ERROR) { + if (getWord(pInfo->GetHContact(), "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) return; } - delSetting(pInfo->m_hContact, "Timezone"); - delSetting(pInfo->m_hContact, "TzName"); + delSetting(pInfo->GetHContact(), "Timezone"); + delSetting(pInfo->GetHContact(), "TzName"); } diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp index 6cc9421c32..3079cfa96a 100644 --- a/protocols/JabberG/src/jabber_iqid_muc.cpp +++ b/protocols/JabberG/src/jabber_iqid_muc.cpp @@ -59,13 +59,13 @@ struct { int idc; char *title; - char *icon; + int icon; bool push; } static buttons[] = { - { IDC_BTN_FILTERAPPLY, "Apply filter", "sd_filter_apply", false }, - { IDC_BTN_FILTERRESET, "Reset filter", "sd_filter_reset", false }, + { IDC_BTN_FILTERAPPLY, "Apply filter", IDI_FILTER_APPLY, false }, + { IDC_BTN_FILTERRESET, "Reset filter", IDI_FILTER_RESET, false }, }; class CJabberMucJidListDlg : public CJabberDlgBase @@ -180,8 +180,8 @@ public: bool OnInitDialog() override { HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 2, 0); - ImageList_AddIcon(hImageList, g_LoadIconEx("delete")); - ImageList_AddIcon(hImageList, g_LoadIconEx("addcontact")); + g_plugin.addImgListIcon(hImageList, IDI_DELETE); + g_plugin.addImgListIcon(hImageList, IDI_ADDCONTACT); m_list.SetImageList(hImageList, LVSIL_SMALL); m_list.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES | LVS_EX_GRIDLINES); @@ -197,7 +197,7 @@ public: Refresh(m_info); for (auto &it : buttons) { - SendDlgItemMessage(m_hwnd, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)); + SendDlgItemMessage(m_hwnd, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(it.icon)); SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASFLATBTN, TRUE, 0); SendDlgItemMessage(m_hwnd, it.idc, BUTTONADDTOOLTIP, (WPARAM)it.title, 0); if (it.push) diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index f1cbdcbae9..d0ec3b9dae 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -170,7 +170,7 @@ void g_MenuInit(void) mi.pszService = "Jabber/ConvertChatContact"; mi.name.a = LPGEN("Convert"); mi.position = -1999901004; - mi.hIcolibItem = g_GetIconHandle(IDI_USER2ROOM); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_USER2ROOM); g_hMenuConvert = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuConvertChatContact); @@ -188,7 +188,7 @@ void g_MenuInit(void) mi.pszService = "Jabber/AddToBookmarks"; mi.name.a = LPGEN("Add to Bookmarks"); mi.position = -1999901006; - mi.hIcolibItem = g_GetIconHandle(IDI_BOOKMARKS); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BOOKMARKS); g_hMenuAddBookmark = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuBookmarkAdd); @@ -197,7 +197,7 @@ void g_MenuInit(void) mi.pszService = "Jabber/TransportLogin"; mi.name.a = LPGEN("Login/logout"); mi.position = -1999901007; - mi.hIcolibItem = g_GetIconHandle(IDI_LOGIN); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_LOGIN); g_hMenuLogin = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuTransportLogin); @@ -206,7 +206,7 @@ void g_MenuInit(void) mi.pszService = "Jabber/TransportGetNicks"; mi.name.a = LPGEN("Resolve nicks"); mi.position = -1999901008; - mi.hIcolibItem = g_GetIconHandle(IDI_REFRESH); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_REFRESH); g_hMenuRefresh = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuTransportResolve); @@ -215,7 +215,7 @@ void g_MenuInit(void) mi.pszService = "Jabber/RunCommands"; mi.name.a = LPGEN("Commands"); mi.position = -1999901009; - mi.hIcolibItem = g_GetIconHandle(IDI_COMMAND); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_COMMAND); g_hMenuCommands = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberContactMenuRunCommands); @@ -224,7 +224,7 @@ void g_MenuInit(void) mi.pszService = "Jabber/SendNote"; mi.name.a = LPGEN("Send Note"); mi.position = -1999901010; - mi.hIcolibItem = g_GetIconHandle(IDI_SEND_NOTE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_SEND_NOTE); g_hMenuSendNote = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, JabberMenuSendNote); @@ -235,7 +235,7 @@ void g_MenuInit(void) mi.pszService = "Jabber/DirectPresenceDummySvc"; mi.name.a = LPGEN("Send Presence"); mi.position = -1999901011; - mi.hIcolibItem = g_GetIconHandle(IDI_NOTES); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_NOTES); g_hMenuDirectPresence[0] = Menu_AddContactMenuItem(&mi); UNSET_UID(mi); @@ -261,7 +261,7 @@ void g_MenuInit(void) mi.pszService = "Jabber/ResourceSelectorDummySvc"; mi.name.a = LPGEN("Jabber Resource"); mi.position = -1999901011; - mi.hIcolibItem = g_GetIconHandle(IDI_JABBER); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_JABBER); g_hMenuResourcesRoot = Menu_AddContactMenuItem(&mi); UNSET_UID(mi); @@ -270,14 +270,14 @@ void g_MenuInit(void) mi.pszService = "Jabber/UseResource_last"; mi.name.a = LPGEN("Last Active"); mi.position = -1999901000; - mi.hIcolibItem = g_GetIconHandle(IDI_JABBER); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_JABBER); g_hMenuResourcesActive = Menu_AddContactMenuItem(&mi); CreateServiceFunctionParam(mi.pszService, JabberMenuHandleResource, MENUITEM_LASTSEEN); mi.pszService = "Jabber/UseResource_server"; mi.name.a = LPGEN("Server's Choice"); mi.position = -1999901000; - mi.hIcolibItem = g_GetIconHandle(IDI_NODE_SERVER); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_NODE_SERVER); g_hMenuResourcesServer = Menu_AddContactMenuItem(&mi); CreateServiceFunctionParam(mi.pszService, JabberMenuHandleResource, MENUITEM_SERVER); } @@ -541,14 +541,14 @@ void CJabberProto::OnBuildProtoMenu() CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleBookmarks); mi.name.a = LPGEN("Bookmarks"); mi.position = 200001; - mi.hIcolibItem = GetIconHandle(IDI_BOOKMARKS); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BOOKMARKS); m_hMenuBookmarks = Menu_AddProtoMenuItem(&mi, m_szModuleName); // "Services..." mi.pszService = nullptr; mi.name.a = LPGEN("Services..."); mi.position = 200003; - mi.hIcolibItem = GetIconHandle(IDI_SERVICE_DISCOVERY); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_SERVICE_DISCOVERY); HGENMENU hMenuServicesRoot = Menu_AddProtoMenuItem(&mi, m_szModuleName); // "Service Discovery..." @@ -557,35 +557,35 @@ void CJabberProto::OnBuildProtoMenu() CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleServiceDiscovery); mi.name.a = LPGEN("Service Discovery"); mi.position = 2000050001; - mi.hIcolibItem = GetIconHandle(IDI_SERVICE_DISCOVERY); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_SERVICE_DISCOVERY); m_hMenuServiceDiscovery = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = "/SD/MyTransports"; CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleServiceDiscoveryMyTransports); mi.name.a = LPGEN("Registered Transports"); mi.position = 2000050003; - mi.hIcolibItem = GetIconHandle(IDI_TRANSPORTL); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_TRANSPORTL); m_hMenuSDMyTransports = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = "/SD/Transports"; CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleServiceDiscoveryTransports); mi.name.a = LPGEN("Local Server Transports"); mi.position = 2000050004; - mi.hIcolibItem = GetIconHandle(IDI_TRANSPORT); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_TRANSPORT); m_hMenuSDTransports = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = "/SD/Conferences"; CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleServiceDiscoveryConferences); mi.name.a = LPGEN("Browse chatrooms"); mi.position = 2000050005; - mi.hIcolibItem = GetIconHandle(IDI_GROUP); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_GROUP); m_hMenuSDConferences = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = "/Groupchat"; CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleJoinGroupchat); mi.name.a = LPGEN("Create/Join group chat"); mi.position = 2000050006; - mi.hIcolibItem = GetIconHandle(IDI_GROUP); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_GROUP); m_hMenuGroupchat = Menu_AddProtoMenuItem(&mi, m_szModuleName); // "Change Password..." @@ -593,7 +593,7 @@ void CJabberProto::OnBuildProtoMenu() CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleChangePassword); mi.name.a = LPGEN("Change Password"); mi.position = 2000050007; - mi.hIcolibItem = GetIconHandle(IDI_KEYS); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_KEYS); m_hMenuChangePassword = Menu_AddProtoMenuItem(&mi, m_szModuleName); // "Roster editor" @@ -601,7 +601,7 @@ void CJabberProto::OnBuildProtoMenu() CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleRosterControl); mi.name.a = LPGEN("Roster editor"); mi.position = 2000050009; - mi.hIcolibItem = GetIconHandle(IDI_AGENTS); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_AGENTS); m_hMenuRosterControl = Menu_AddProtoMenuItem(&mi, m_szModuleName); // "XML Console" @@ -609,14 +609,14 @@ void CJabberProto::OnBuildProtoMenu() CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleConsole); mi.name.a = LPGEN("XML Console"); mi.position = 2000050010; - mi.hIcolibItem = GetIconHandle(IDI_CONSOLE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_CONSOLE); Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = "/Notes"; CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandleNotes); mi.name.a = LPGEN("Notes"); mi.position = 2000050011; - mi.hIcolibItem = GetIconHandle(IDI_NOTES); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_NOTES); m_hMenuNotes = Menu_AddProtoMenuItem(&mi, m_szModuleName); BuildPrivacyMenu(); @@ -694,11 +694,11 @@ void CJabberProto::BuildPriorityMenu() mir_snprintf(srvFce, "/menuSetPriority/%d", steps[i]); if (steps[i] > 0) { mir_snwprintf(szName, TranslateT("Increase priority by %d"), steps[i]); - mi.hIcolibItem = GetIconHandle(IDI_ARROW_UP); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ARROW_UP); } else { mir_snwprintf(szName, TranslateT("Decrease priority by %d"), -steps[i]); - mi.hIcolibItem = GetIconHandle(IDI_ARROW_DOWN); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ARROW_DOWN); } if (needServices) @@ -799,19 +799,19 @@ int g_OnToolbarInit(WPARAM, LPARAM) CreateServiceFunction("JABBER/*/Groupchat", g_ToolbarHandleJoinGroupchat); ttb.pszService = "JABBER/*/Groupchat"; ttb.pszTooltipUp = ttb.name = LPGEN("Join conference"); - ttb.hIconHandleUp = g_GetIconHandle(IDI_GROUP); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_GROUP); g_plugin.addTTB(&ttb); CreateServiceFunction("JABBER/*/Bookmarks", g_ToolbarHandleBookmarks); ttb.pszService = "JABBER/*/Bookmarks"; ttb.pszTooltipUp = ttb.name = LPGEN("Open bookmarks"); - ttb.hIconHandleUp = g_GetIconHandle(IDI_BOOKMARKS); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_BOOKMARKS); g_plugin.addTTB(&ttb); CreateServiceFunction("JABBER/*/ServiceDiscovery", g_ToolbarHandleServiceDiscovery); ttb.pszService = "JABBER/*/ServiceDiscovery"; ttb.pszTooltipUp = ttb.name = LPGEN("Service discovery"); - ttb.hIconHandleUp = g_GetIconHandle(IDI_SERVICE_DISCOVERY); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_SERVICE_DISCOVERY); g_plugin.addTTB(&ttb); return 0; } diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 7f6ccc3d53..434394c7da 100755 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -412,7 +412,7 @@ void CJabberProto::InitPopups(void) mir_snprintf(name, "%s_%s", m_szModuleName, "Error"); mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Errors")); - ppc.hIcon = LoadIconEx("main"); + ppc.hIcon = IcoLib_GetIconByHandle(m_hProtoIcon); ppc.colorBack = RGB(191, 0, 0); //Red ppc.colorText = RGB(255, 245, 225); //Yellow ppc.iSeconds = 60; diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp index 0956b06bfc..11e1f98a54 100644 --- a/protocols/JabberG/src/jabber_notes.cpp +++ b/protocols/JabberG/src/jabber_notes.cpp @@ -178,7 +178,7 @@ public: bool OnInitDialog() override { CSuper::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_NOTES)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_NOTES)); if (m_fnProcess) { CMStringW buf; @@ -507,7 +507,7 @@ public: bool OnInitDialog() override { CSuper::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_NOTES)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_NOTES)); LOGFONT lf, lfTmp; m_hfntNormal = (HFONT)GetStockObject(DEFAULT_GUI_FONT); @@ -723,7 +723,7 @@ bool CJabberProto::OnIncomingNote(const char *szFrom, const TiXmlElement *hXml) mir_snprintf(szService, "%s%s", m_szModuleName, JS_INCOMING_NOTE_EVENT); CLISTEVENT cle = {}; - cle.hIcon = (HICON)LoadIconEx("notes"); + cle.hIcon = g_plugin.getIcon(IDI_NOTES); cle.flags = CLEF_PROTOCOLGLOBAL | CLEF_UNICODE; cle.hDbEvent = -99; cle.lParam = (LPARAM)pItem; diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index dce6f4cc7e..cab97f697d 100755 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -1934,7 +1934,7 @@ bool CJabberProto::OmemoCheckSession(MCONTACT hContact) while (id) { if (!checked) { pending_check = true; - XmlNodeIq iq(AddIQ(&CJabberProto::OmemoOnIqResultGetBundle, JABBER_IQ_TYPE_GET, nullptr, 0UL, -1, &id)); + XmlNodeIq iq(AddIQ(&CJabberProto::OmemoOnIqResultGetBundle, JABBER_IQ_TYPE_GET, nullptr, &id)); char szBareJid[JABBER_MAX_JID_LEN]; iq << XATTR("from", JabberStripJid(m_ThreadInfo->fullJID, szBareJid, _countof_portable(szBareJid))); diff --git a/protocols/JabberG/src/jabber_opttree.cpp b/protocols/JabberG/src/jabber_opttree.cpp index c8bda4c769..f8c5ed2379 100644 --- a/protocols/JabberG/src/jabber_opttree.cpp +++ b/protocols/JabberG/src/jabber_opttree.cpp @@ -97,13 +97,13 @@ void CCtrlTreeOpts::OnInit() DeleteAllItems(); hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR | ILC_COLOR32 | ILC_MASK, 5, 1); - ImageList_AddIcon_Icolib(hImgLst, Skin_LoadIcon(SKINICON_OTHER_MIRANDA)); - ImageList_AddIcon_Icolib(hImgLst, Skin_LoadIcon(SKINICON_OTHER_TICK)); // check on - ImageList_AddIcon_Icolib(hImgLst, Skin_LoadIcon(SKINICON_OTHER_NOTICK)); // check off - ImageList_AddIcon_Icolib(hImgLst, Skin_LoadIcon(SKINICON_OTHER_TICK)); // radio on - ImageList_AddIcon_Icolib(hImgLst, Skin_LoadIcon(SKINICON_OTHER_NOTICK)); // radio on - ImageList_AddIcon_Icolib(hImgLst, Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN)); - ImageList_AddIcon_Icolib(hImgLst, Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT)); + ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_MIRANDA); + ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_TICK); // check on + ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_NOTICK); // check off + ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_TICK); // radio on + ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_NOTICK); // radio on + ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_GROUPOPEN); + ImageList_AddSkinIcon(hImgLst, SKINICON_OTHER_GROUPSHUT); SetImageList(hImgLst, TVSIL_NORMAL); /* build options tree. based on code from IcoLib */ diff --git a/protocols/JabberG/src/jabber_password.cpp b/protocols/JabberG/src/jabber_password.cpp index 4ad8974619..b80679f565 100644 --- a/protocols/JabberG/src/jabber_password.cpp +++ b/protocols/JabberG/src/jabber_password.cpp @@ -41,7 +41,7 @@ public: bool OnInitDialog() override { m_proto->m_hwndJabberChangePassword = m_hwnd; - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_KEYS)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_KEYS)); if (m_proto->m_bJabberOnline && m_proto->m_ThreadInfo != nullptr) { char text[1024]; diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index 5cc56e0e84..14508b7c92 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -46,12 +46,11 @@ BOOL CJabberProto::OnIqRequestPrivacyLists(const TiXmlElement*, CJabberIqInfo *p void CJabberProto::OnIqResultPrivacyListModify(const TiXmlElement*, CJabberIqInfo *pInfo) { - if (!pInfo->m_pUserData) + CPrivacyListModifyUserParam *pParam = (CPrivacyListModifyUserParam *)pInfo->GetUserData(); + if (pParam == nullptr) return; - CPrivacyListModifyUserParam *pParam = (CPrivacyListModifyUserParam *)pInfo->m_pUserData; - - if (pInfo->m_nIqType != JABBER_IQ_TYPE_RESULT) + if (pInfo->GetIqType() != JABBER_IQ_TYPE_RESULT) pParam->m_bAllOk = FALSE; InterlockedDecrement(&pParam->m_dwCount); @@ -243,7 +242,7 @@ void CJabberProto::OnIqResultPrivacyListDefault(const TiXmlElement *iqNode, CJab void CJabberProto::OnIqResultPrivacyLists(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { - if (pInfo->m_nIqType != JABBER_IQ_TYPE_RESULT) + if (pInfo->GetIqType() != JABBER_IQ_TYPE_RESULT) return; auto *query = XmlFirstChild(iqNode, "query"); @@ -357,10 +356,10 @@ public: m_proto->m_hwndPrivacyRule = m_hwnd; - SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_msg_allow"), 0); - SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_iq_allow"), 0); - SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_prin_allow"), 0); - SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEOUT, STM_SETICON, (WPARAM)m_proto->LoadIconEx("pl_prout_allow"), 0); + SendDlgItemMessage(m_hwnd, IDC_ICO_MESSAGE, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_PL_MSG_ALLOW), 0); + SendDlgItemMessage(m_hwnd, IDC_ICO_QUERY, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_PL_QUERY_ALLOW), 0); + SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEIN, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_PL_PRIN_ALLOW), 0); + SendDlgItemMessage(m_hwnd, IDC_ICO_PRESENCEOUT, STM_SETICON, (WPARAM)g_plugin.getIcon(IDI_PL_PROUT_ALLOW), 0); wchar_t *szTypes[] = { L"JID", L"Group", L"Subscription", L"Any" }; int i, nTypes[] = { Jid, Group, Subscription, Else }; @@ -832,11 +831,11 @@ class CJabberDlgPrivacyLists : public CJabberDlgBase } DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, - m_proto->LoadIconEx("main"), 16, 16, 0, nullptr, DI_NORMAL); + IcoLib_GetIconByHandle(m_proto->m_hProtoIcon), 16, 16, 0, nullptr, DI_NORMAL); if (pRule) DrawIconEx(lpdis->hDC, lpdis->rcItem.left + 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, - m_proto->LoadIconEx(pRule->GetAction() ? "disco_ok" : "disco_fail"), + g_plugin.getIcon(pRule->GetAction() ? IDI_DISCO_OK : IDI_DISCO_FAIL), 16, 16, 0, nullptr, DI_NORMAL); if (lpdis->itemState & ODS_FOCUS) { @@ -915,12 +914,12 @@ class CJabberDlgPrivacyLists : public CJabberDlgBase DrawNextRulePart(lpdis->hDC, clLine2, TranslateT(" (default)"), &rc); DrawIconEx(lpdis->hDC, lpdis->rcItem.right - 16 - 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, - m_proto->LoadIconEx(bActive ? "pl_list_active" : "pl_list_any"), + g_plugin.getIcon(bActive ? IDI_PL_LIST_ACTIVE : IDI_PL_LIST_ANY), 16, 16, 0, nullptr, DI_NORMAL); if (bDefault) DrawIconEx(lpdis->hDC, lpdis->rcItem.right - 16 - 4, (lpdis->rcItem.top + lpdis->rcItem.bottom - 16) / 2, - m_proto->LoadIconEx("disco_ok"), + g_plugin.getIcon(IDI_DISCO_OK), 16, 16, 0, nullptr, DI_NORMAL); if (hfnt) @@ -1271,16 +1270,16 @@ lbl_return: public: CJabberDlgPrivacyLists(CJabberProto *proto) : CSuper(proto, IDD_PRIVACY_LISTS), - m_btnSimple(this, IDC_BTN_SIMPLE, proto->LoadIconEx("group"), LPGEN("Simple mode")), - m_btnAdvanced(this, IDC_BTN_ADVANCED, proto->LoadIconEx("sd_view_list"), LPGEN("Advanced mode")), - m_btnAddJid(this, IDC_ADDJID, proto->LoadIconEx("addroster"), LPGEN("Add JID")), - m_btnActivate(this, IDC_ACTIVATE, proto->LoadIconEx("pl_list_active"), LPGEN("Activate")), - m_btnSetDefault(this, IDC_SET_DEFAULT, proto->LoadIconEx("pl_list_default"), LPGEN("Set default")), + m_btnSimple(this, IDC_BTN_SIMPLE, g_plugin.getIcon(IDI_GROUP), LPGEN("Simple mode")), + m_btnAdvanced(this, IDC_BTN_ADVANCED, g_plugin.getIcon(IDI_VIEW_LIST), LPGEN("Advanced mode")), + m_btnAddJid(this, IDC_ADDJID, g_plugin.getIcon(IDI_ADDCONTACT), LPGEN("Add JID")), + m_btnActivate(this, IDC_ACTIVATE, g_plugin.getIcon(IDI_PL_LIST_ACTIVE), LPGEN("Activate")), + m_btnSetDefault(this, IDC_SET_DEFAULT, g_plugin.getIcon(IDI_PL_LIST_DEFAULT), LPGEN("Set default")), m_btnEditRule(this, IDC_EDIT_RULE, SKINICON_OTHER_RENAME, LPGEN("Edit rule")), m_btnAddRule(this, IDC_ADD_RULE, SKINICON_OTHER_ADDCONTACT, LPGEN("Add rule")), m_btnRemoveRule(this, IDC_REMOVE_RULE, SKINICON_OTHER_DELETE, LPGEN("Delete rule")), - m_btnUpRule(this, IDC_UP_RULE, proto->LoadIconEx("arrow_up"), LPGEN("Move rule up")), - m_btnDownRule(this, IDC_DOWN_RULE, proto->LoadIconEx("arrow_down"), LPGEN("Move rule down")), + m_btnUpRule(this, IDC_UP_RULE, g_plugin.getIcon(IDI_ARROW_UP), LPGEN("Move rule up")), + m_btnDownRule(this, IDC_DOWN_RULE, g_plugin.getIcon(IDI_ARROW_DOWN), LPGEN("Move rule down")), m_btnAddList(this, IDC_ADD_LIST, SKINICON_OTHER_ADDCONTACT, LPGEN("Add list...")), m_btnRemoveList(this, IDC_REMOVE_LIST, SKINICON_OTHER_DELETE, LPGEN("Remove list")), m_btnApply(this, IDC_APPLY), @@ -1318,7 +1317,7 @@ public: { CSuper::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_PRIVACY_LISTS)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_PRIVACY_LISTS)); EnableWindow(GetDlgItem(m_hwnd, IDC_ADD_RULE), FALSE); EnableWindow(GetDlgItem(m_hwnd, IDC_EDIT_RULE), FALSE); @@ -1340,15 +1339,15 @@ public: m_clcClist.SetExStyle(CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT); HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 9, 9); - ImageList_AddIcon_Icolib(hIml, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); - ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_msg_allow")); - ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_msg_deny")); - ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prin_allow")); - ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prin_deny")); - ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prout_allow")); - ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_prout_deny")); - ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_iq_allow")); - ImageList_AddIcon_Icolib(hIml, m_proto->LoadIconEx("pl_iq_deny")); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_SMALLDOT); + g_plugin.addImgListIcon(hIml, IDI_PL_MSG_ALLOW); + g_plugin.addImgListIcon(hIml, IDI_PL_MSG_DENY); + g_plugin.addImgListIcon(hIml, IDI_PL_PRIN_ALLOW); + g_plugin.addImgListIcon(hIml, IDI_PL_PRIN_DENY); + g_plugin.addImgListIcon(hIml, IDI_PL_PROUT_ALLOW); + g_plugin.addImgListIcon(hIml, IDI_PL_PROUT_DENY); + g_plugin.addImgListIcon(hIml, IDI_PL_QUERY_ALLOW); + g_plugin.addImgListIcon(hIml, IDI_PL_QUERY_DENY); m_clcClist.SetExtraImageList(hIml); m_clcClist.SetExtraColumns(4); @@ -1530,15 +1529,15 @@ public: struct { wchar_t *textEng; - char *icon; + int icon; wchar_t *text; } static drawItems[] = { - { LPGENW("Message"), "pl_msg_allow" }, - { LPGENW("Presence (in)"), "pl_prin_allow" }, - { LPGENW("Presence (out)"), "pl_prout_allow" }, - { LPGENW("Query"), "pl_iq_allow" } + { LPGENW("Message"), IDI_PL_MSG_ALLOW }, + { LPGENW("Presence (in)"), IDI_PL_PRIN_ALLOW }, + { LPGENW("Presence (out)"), IDI_PL_PROUT_ALLOW }, + { LPGENW("Query"), IDI_PL_QUERY_ALLOW } }; LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; @@ -1561,7 +1560,7 @@ public: rc.left = (rc.left + rc.right - totalWidth) / 2; for (auto &it : drawItems) { - DrawIconEx(lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, m_proto->LoadIconEx(it.icon), + DrawIconEx(lpdis->hDC, rc.left, (rc.top + rc.bottom - 16) / 2, g_plugin.getIcon(it.icon), 16, 16, 0, nullptr, DI_NORMAL); rc.left += 18; DrawNextRulePart(lpdis->hDC, clText, it.text, &rc); @@ -1621,7 +1620,7 @@ public: } EnableWindow(GetDlgItem(m_hwnd, IDC_ACTIVATE), FALSE); SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ACTIVATE), GWLP_USERDATA, (LONG_PTR)pList); - XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList)); + XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, pList)); TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS); TiXmlElement *active = query << XCHILD("active"); if (pList) @@ -1648,7 +1647,7 @@ public: EnableWindow(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), FALSE); SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), GWLP_USERDATA, (LONG_PTR)pList); - XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList)); + XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, nullptr, pList)); TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS); TiXmlElement *defaultTag = query << XCHILD("default"); if (pList) @@ -1878,7 +1877,7 @@ public: pUserData->m_dwCount++; - XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pUserData)); + XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListModify, JABBER_IQ_TYPE_SET, nullptr, pUserData)); TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS); TiXmlElement *listTag = query << XCHILD("list") << XATTR("name", pList->GetListName()); @@ -2006,7 +2005,7 @@ INT_PTR __cdecl CJabberProto::menuSetPrivacyList(WPARAM, LPARAM, LPARAM iList) pList = pList->GetNext(); } - XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, 0, -1, pList)); + XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, nullptr, pList)); TiXmlElement *query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS); TiXmlElement *active = query << XCHILD("active"); if (pList) @@ -2024,7 +2023,7 @@ void CJabberProto::BuildPrivacyMenu() { CMenuItem mi(&g_plugin); mi.position = 200005; - mi.hIcolibItem = GetIconHandle(IDI_AGENTS); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_AGENTS); mi.flags = CMIF_UNMOVABLE | CMIF_HIDDEN; mi.name.a = LPGEN("Privacy Lists"); mi.root = m_hMenuRoot; @@ -2034,7 +2033,7 @@ void CJabberProto::BuildPrivacyMenu() CreateProtoService(mi.pszService, &CJabberProto::OnMenuHandlePrivacyLists); mi.position = 3000040000; mi.flags = CMIF_UNMOVABLE | CMIF_UNICODE; - mi.hIcolibItem = GetIconHandle(IDI_PRIVACY_LISTS); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_PRIVACY_LISTS); mi.name.w = LPGENW("List Editor..."); mi.root = m_hPrivacyMenuRoot; Menu_AddProtoMenuItem(&mi, m_szModuleName); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 005311104f..ec65a52654 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -281,7 +281,7 @@ void CJabberProto::OnModulesLoaded() StatusIconData sid = {}; sid.szModule = m_szModuleName; - sid.hIcon = LoadIconEx("main"); + sid.hIcon = IcoLib_GetIconByHandle(m_hProtoIcon); sid.flags = MBF_HIDDEN; sid.szTooltip.a = LPGEN("Jabber Resource"); Srmm_AddIcon(&sid, &g_plugin); @@ -613,12 +613,14 @@ int CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/) JabberStripJid(jid, szBareJid, _countof(szBareJid)); if (m_ThreadInfo) { - m_ThreadInfo->send( - XmlNodeIq(AddIQ(&CJabberProto::OnIqResultEntityTime, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_HCONTACT)) - << XCHILDNS("time", JABBER_FEAT_ENTITY_TIME)); + auto *pInfo = AddIQ(&CJabberProto::OnIqResultEntityTime, JABBER_IQ_TYPE_GET, jid); + pInfo->SetParamsToParse(JABBER_IQ_PARSE_HCONTACT); + m_ThreadInfo->send(XmlNodeIq(pInfo) << XCHILDNS("time", JABBER_FEAT_ENTITY_TIME)); // XEP-0012, last logoff time - m_ThreadInfo->send(XmlNodeIq(AddIQ(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, jid, JABBER_IQ_PARSE_FROM)) << XQUERY(JABBER_FEAT_LAST_ACTIVITY)); + pInfo = AddIQ(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, jid); + pInfo->SetParamsToParse(JABBER_IQ_PARSE_FROM); + m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(JABBER_FEAT_LAST_ACTIVITY)); JABBER_LIST_ITEM *item = nullptr; if ((item = ListGetItemPtr(LIST_VCARD_TEMP, jid)) == nullptr) @@ -643,14 +645,17 @@ int CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/) pResourceStatus r(it); CMStringA tmp(MakeJid(szBareJid, r->m_szResourceName)); - if (r->m_jcbCachedCaps & JABBER_CAPS_DISCO_INFO) - m_ThreadInfo->send( - XmlNodeIq(AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT)) - << XQUERY(JABBER_FEAT_DISCO_INFO)); + if (r->m_jcbCachedCaps & JABBER_CAPS_DISCO_INFO) { + pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, tmp); + pInfo->SetParamsToParse(JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT); + m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(JABBER_FEAT_DISCO_INFO)); + } - if (mir_strcmp(tmp, jid)) // skip current resource, we've already sent this iq to it - m_ThreadInfo->send( - XmlNodeIq(AddIQ(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM)) << XQUERY(JABBER_FEAT_LAST_ACTIVITY)); + if (mir_strcmp(tmp, jid)) { // skip current resource, we've already sent this iq to it + pInfo = AddIQ(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp); + pInfo->SetParamsToParse(JABBER_IQ_PARSE_FROM); + m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(JABBER_FEAT_LAST_ACTIVITY)); + } } } } diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 40227f952c..d91582c5eb 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -482,8 +482,6 @@ struct CJabberProto : public PROTO, public IJabberInterface int* m_transportProtoTableStartIndex; void IconsInit(void); - HANDLE GetIconHandle(int iconId); - HICON LoadIconEx(const char* name, bool big = false); int LoadAdvancedIcons(int iID); int GetTransportProtoID(char* TransportDomain); int GetTransportStatusIconIndex(int iID, int Status); @@ -493,9 +491,9 @@ struct CJabberProto : public PROTO, public IJabberInterface //---- jabber_iq.c ------------------------------------------------------------------- - __forceinline CJabberIqInfo* AddIQ(JABBER_IQ_HANDLER pHandler, int nIqType = JABBER_IQ_TYPE_GET, const char *szReceiver = nullptr, DWORD dwParamsToParse = 0, int nIqId = -1, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) + __forceinline CJabberIqInfo* AddIQ(JABBER_IQ_HANDLER pHandler, int nIqType = JABBER_IQ_TYPE_GET, const char *szReceiver = nullptr, void *pUserData = nullptr, int iPriority = JH_PRIORITY_DEFAULT) { - return m_iqManager.AddHandler(pHandler, nIqType, szReceiver, dwParamsToParse, nIqId, pUserData, iPriority); + return m_iqManager.AddHandler(pHandler, nIqType, szReceiver, pUserData, iPriority); } void __cdecl ExpirerThread(void*); @@ -837,7 +835,6 @@ struct CJabberProto : public PROTO, public IJabberInterface //---- jabber_xml.c ------------------------------------------------------------------ - int OnXmlParse(char* buffer); void OnConsoleProcessXml(const TiXmlElement *node, DWORD flags); //---- jabber_xmlns.c ---------------------------------------------------------------- @@ -905,7 +902,6 @@ public: HJHANDLER STDMETHODCALLTYPE AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) override; HJHANDLER STDMETHODCALLTYPE AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority) override; HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority) override; - HJHANDLER STDMETHODCALLTYPE AddTemporaryIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, int iIqId, void *pUserData, DWORD dwTimeout, int iPriority) override; HJHANDLER STDMETHODCALLTYPE AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) override; int STDMETHODCALLTYPE RemoveHandler(HJHANDLER hHandler) override; diff --git a/protocols/JabberG/src/jabber_roster.cpp b/protocols/JabberG/src/jabber_roster.cpp index 727f77ea9a..c248722229 100644 --- a/protocols/JabberG/src/jabber_roster.cpp +++ b/protocols/JabberG/src/jabber_roster.cpp @@ -236,7 +236,7 @@ public: bool OnInitDialog() override { - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_AGENTS)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_AGENTS)); Utils_RestoreWindowPosition(m_hwnd, 0, m_proto->m_szModuleName, "rosterCtrlWnd_"); diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 8ac857be1b..15061de69d 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -583,7 +583,7 @@ public: { CSuper::OnInitDialog(); - Window_SetIcon_IcoLib(m_hwnd, g_GetIconHandle(IDI_OPEN)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_OPEN)); SetDlgItemTextUtf(m_hwnd, IDC_TXT_URL, m_pParams->m_szUrl); SetDlgItemTextUtf(m_hwnd, IDC_TXT_FROM, m_pParams->m_szFrom); diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 486fd6fbcc..880e6eb0f9 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -424,13 +424,13 @@ LBL_FatalError: else if (nSelRes == 0) { if (m_bSendKeepAlive) { if (info.jabberServerCaps & JABBER_CAPS_PING) { - CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnPingReply, JABBER_IQ_TYPE_GET, nullptr, 0, -1, this); + CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnPingReply, JABBER_IQ_TYPE_GET, nullptr, this); pInfo->SetTimeout(m_iConnectionKeepAliveTimeout); info.send(XmlNodeIq(pInfo) << XATTR("from", info.fullJID) << XCHILDNS("ping", JABBER_FEAT_PING)); } } - else - info.send(" \t "); //TODO: why do we need this ? + else info.send(" \t "); + if (m_bEnableStreamMgmt) m_StrmMgmt.RequestAck(); } @@ -1298,9 +1298,8 @@ void CJabberProto::OnProcessMessage(const TiXmlElement *node, ThreadData *info) auto *idNode = XmlFirstChild(xNode, "id"); if (XmlFirstChild(xNode, "delivered") != nullptr || XmlFirstChild(xNode, "offline") != nullptr) { int id = -1; - if (idNode != nullptr && idNode->GetText() != nullptr) - if (!strncmp(idNode->GetText(), JABBER_IQID, mir_strlen(JABBER_IQID))) - id = atoi((idNode->GetText()) + mir_strlen(JABBER_IQID)); + if (idNode != nullptr) + id = JabberGetPacketID(idNode->GetText()); if (id != -1) ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id, 0); diff --git a/protocols/JabberG/src/jabber_treelist.cpp b/protocols/JabberG/src/jabber_treelist.cpp index c228169c17..b8588ef601 100644 --- a/protocols/JabberG/src/jabber_treelist.cpp +++ b/protocols/JabberG/src/jabber_treelist.cpp @@ -138,9 +138,9 @@ void TreeList_Create(HWND hwnd) ListView_SetImageList(hwnd, hIml, LVSIL_SMALL); hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 2, 1); - ImageList_AddIcon_Icolib(hIml, Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN)); - ImageList_AddIcon_Icolib(hIml, Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT)); - ImageList_AddIcon_Icolib(hIml, Skin_LoadIcon(SKINICON_OTHER_DOWNARROW)); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_GROUPOPEN); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_GROUPSHUT); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_DOWNARROW); ListView_SetImageList(hwnd, hIml, LVSIL_STATE); } diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index 16a0097a95..0488052609 100755 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -233,7 +233,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti // caps JabberCapsBits jcb = ppro->GetResourceCapabilities(MakeJid(item->jid, r->m_szResourceName), r); if (!(jcb & JABBER_RESOURCE_CAPS_ERROR)) { - HTREEITEM htiCaps = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), nullptr, TranslateU("Client capabilities"), sttInfoLineId(resource, INFOLINE_CAPS)); + HTREEITEM htiCaps = sttFillInfoLine(hwndTree, htiResource, IcoLib_GetIconByHandle(ppro->m_hProtoIcon), nullptr, TranslateU("Client capabilities"), sttInfoLineId(resource, INFOLINE_CAPS)); int i; for (i = 0; i < g_cJabberFeatCapPairs; i++) if (jcb & g_JabberFeatCapPairs[i].jcbCap) { @@ -258,7 +258,7 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti } // Software info - HTREEITEM htiSoftwareInfo = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), nullptr, TranslateU("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION)); + HTREEITEM htiSoftwareInfo = sttFillInfoLine(hwndTree, htiResource, IcoLib_GetIconByHandle(ppro->m_hProtoIcon), nullptr, TranslateU("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION)); int nLineId = 0; if (CJabberClientPartialCaps *pCaps = r->m_pCaps) { if (pCaps->GetOs()) @@ -300,7 +300,7 @@ static void sttFillUserInfo(CJabberProto *ppro, HWND hwndTree, JABBER_LIST_ITEM sttCleanupInfo(hwndTree, 0); - HTREEITEM htiRoot = sttFillInfoLine(hwndTree, nullptr, ppro->LoadIconEx("main"), L"JID", item->jid, sttInfoLineId(0, INFOLINE_NAME), true); + HTREEITEM htiRoot = sttFillInfoLine(hwndTree, nullptr, IcoLib_GetIconByHandle(ppro->m_hProtoIcon), L"JID", item->jid, sttInfoLineId(0, INFOLINE_NAME), true); if (MCONTACT hContact = ppro->HContactFromJID(item->jid)) { sttFillAdvStatusInfo(ppro, hwndTree, htiRoot, sttInfoLineId(0, INFOLINE_MOOD), hContact, TranslateT("Mood"), ADVSTATUS_MOOD); @@ -403,12 +403,12 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa memset(dat, 0, sizeof(JabberUserInfoDlgData)); dat->resourcesCount = -1; dat->hContact = lParam; - { - GetClientRect(hwndDlg, &rc); - MoveWindow(GetDlgItem(hwndDlg, IDC_TV_INFO), 5, 5, rc.right - 10, rc.bottom - 10, TRUE); + GetClientRect(hwndDlg, &rc); + MoveWindow(GetDlgItem(hwndDlg, IDC_TV_INFO), 5, 5, rc.right - 10, rc.bottom - 10, TRUE); + { HIMAGELIST himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR | ILC_COLOR32 | ILC_MASK, 5, 1); - ImageList_AddIcon_Icolib(himl, Skin_LoadIcon(SKINICON_OTHER_SMALLDOT)); + ImageList_AddSkinIcon(himl, SKINICON_OTHER_SMALLDOT); TreeView_SetImageList(GetDlgItem(hwndDlg, IDC_TV_INFO), himl, TVSIL_NORMAL); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); @@ -439,8 +439,8 @@ static INT_PTR CALLBACK JabberUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa if (dat->item == nullptr) { HWND hwndTree = GetDlgItem(hwndDlg, IDC_TV_INFO); TreeView_DeleteAllItems(hwndTree); - HTREEITEM htiRoot = sttFillInfoLine(hwndTree, nullptr, dat->ppro->LoadIconEx("main"), L"JID", jid, sttInfoLineId(0, INFOLINE_NAME), true); - sttFillInfoLine(hwndTree, htiRoot, dat->ppro->LoadIconEx("vcard"), nullptr, TranslateU("Please switch online to see more details.")); + HTREEITEM htiRoot = sttFillInfoLine(hwndTree, nullptr, IcoLib_GetIconByHandle(dat->ppro->m_hProtoIcon), L"JID", jid, sttInfoLineId(0, INFOLINE_NAME), true); + sttFillInfoLine(hwndTree, htiRoot, g_plugin.getIcon(IDI_VCARD), nullptr, TranslateU("Please switch online to see more details.")); break; } } @@ -570,7 +570,7 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP photoInfo->ppro = nullptr; photoInfo->hBitmap = nullptr; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)photoInfo); - SendDlgItemMessage(hwndDlg, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_LoadIconEx("save")); + SendDlgItemMessage(hwndDlg, IDC_SAVE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_SAVE)); SendDlgItemMessage(hwndDlg, IDC_SAVE, BUTTONSETASFLATBTN, TRUE, 0); ShowWindow(GetDlgItem(hwndDlg, IDC_LOAD), SW_HIDE); ShowWindow(GetDlgItem(hwndDlg, IDC_DELETE), SW_HIDE); diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 981610f811..b1169e26ab 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -514,12 +514,11 @@ void CJabberProto::SendPresence(int status, bool bSendToAll) /////////////////////////////////////////////////////////////////////////////// // JabberGetPacketID - converts the xml id attribute into an integer -int JabberGetPacketID(const TiXmlElement *n) +int JabberGetPacketID(const char *str) { - const char *str = XmlGetAttr(n, "id"); - if (str) - if (!strncmp(str, JABBER_IQID, _countof(JABBER_IQID) - 1)) - return atoi(str + _countof(JABBER_IQID) - 1); + if (mir_strlen(str) >= 20) + if (!memcmp(str, "mir", 3) && !memcmp(g_plugin.szRandom, str+3, 16) && str[19] == '_') + return atoi(str + 20); return -1; } @@ -527,7 +526,7 @@ int JabberGetPacketID(const TiXmlElement *n) char* JabberId2string(int id) { char text[100]; - mir_snprintf(text, JABBER_IQID "%d", id); + mir_snprintf(text, "mir%s_%d", g_plugin.szRandom, id); return mir_strdup(text); } @@ -693,7 +692,7 @@ static VOID CALLBACK sttRebuildInfoFrameApcProc(void* param) else { ppro->m_pInfoFrame->RemoveInfoItem("$/PEP/"); ppro->m_pInfoFrame->CreateInfoItem("$/PEP", false); - ppro->m_pInfoFrame->UpdateInfoItem("$/PEP", ppro->GetIconHandle(IDI_PL_LIST_ANY), TranslateT("Advanced Status")); + ppro->m_pInfoFrame->UpdateInfoItem("$/PEP", g_plugin.getIconHandle(IDI_PL_LIST_ANY), TranslateT("Advanced Status")); ppro->m_pInfoFrame->CreateInfoItem("$/PEP/mood", true); ppro->m_pInfoFrame->SetInfoItemCallback("$/PEP/mood", &CJabberProto::InfoFrame_OnUserMood); @@ -706,7 +705,7 @@ static VOID CALLBACK sttRebuildInfoFrameApcProc(void* param) ppro->m_pInfoFrame->RemoveInfoItem("$/Transports/"); ppro->m_pInfoFrame->CreateInfoItem("$/Transports", false); - ppro->m_pInfoFrame->UpdateInfoItem("$/Transports", ppro->GetIconHandle(IDI_TRANSPORT), TranslateT("Transports")); + ppro->m_pInfoFrame->UpdateInfoItem("$/Transports", g_plugin.getIconHandle(IDI_TRANSPORT), TranslateT("Transports")); JABBER_LIST_ITEM *item = nullptr; LISTFOREACH(i, ppro, LIST_ROSTER) @@ -720,7 +719,7 @@ static VOID CALLBACK sttRebuildInfoFrameApcProc(void* param) char name[128]; mir_snprintf(name, "$/Transports/%s", item->jid); ppro->m_pInfoFrame->CreateInfoItem(name, true, hContact); - ppro->m_pInfoFrame->UpdateInfoItem(name, ppro->GetIconHandle(IDI_TRANSPORTL), (wchar_t *)item->jid); + ppro->m_pInfoFrame->UpdateInfoItem(name, g_plugin.getIconHandle(IDI_TRANSPORTL), (wchar_t *)item->jid); ppro->m_pInfoFrame->SetInfoItemCallback(name, &CJabberProto::InfoFrame_OnTransport); } } diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index a8ba50067c..1dc02d045d 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -264,9 +264,9 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_INITDIALOG: if (!lParam) break; // Launched from userinfo TranslateDialogDefault(hwndDlg); - SendDlgItemMessage(hwndDlg, IDC_LOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_LoadIconEx("open")); + SendDlgItemMessage(hwndDlg, IDC_LOAD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_OPEN)); SendDlgItemMessage(hwndDlg, IDC_LOAD, BUTTONSETASFLATBTN, TRUE, 0); - SendDlgItemMessage(hwndDlg, IDC_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_LoadIconEx("delete")); + SendDlgItemMessage(hwndDlg, IDC_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(IDI_DELETE)); SendDlgItemMessage(hwndDlg, IDC_DELETE, BUTTONSETASFLATBTN, TRUE, 0); ShowWindow(GetDlgItem(hwndDlg, IDC_SAVE), SW_HIDE); { @@ -804,11 +804,11 @@ static INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lP ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc); if (nm->nmcd.lItemlParam == -1 && nm->iSubItem == 3) - hIcon = g_LoadIconEx("addcontact"); + hIcon = g_plugin.getIcon(IDI_ADDCONTACT); else if (nm->iSubItem == 2 && nm->nmcd.lItemlParam != -1) - hIcon = g_LoadIconEx("edit"); + hIcon = g_plugin.getIcon(IDI_EDIT); else if (nm->iSubItem == 3 && nm->nmcd.lItemlParam != -1) - hIcon = g_LoadIconEx("delete"); + hIcon = g_plugin.getIcon(IDI_DELETE); else break; DrawIconEx(nm->nmcd.hdc, (rc.left + rc.right - GetSystemMetrics(SM_CXSMICON)) / 2, (rc.top + rc.bottom - GetSystemMetrics(SM_CYSMICON)) / 2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, nullptr, DI_NORMAL); SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT); diff --git a/protocols/JabberG/src/jabber_xml.cpp b/protocols/JabberG/src/jabber_xml.cpp index 6fa1c31610..b981aab7fb 100644 --- a/protocols/JabberG/src/jabber_xml.cpp +++ b/protocols/JabberG/src/jabber_xml.cpp @@ -129,8 +129,5 @@ TiXmlElement* __fastcall operator<<(TiXmlElement *node, const XQUERY &child) void XmlAddAttrID(TiXmlElement *hXml, int id) { - char text[100]; - mir_snprintf(text, JABBER_IQID "%d", id); - hXml->SetAttribute("id", text); + hXml->SetAttribute("id", ptrA(JabberId2string(id)).get()); } - diff --git a/protocols/JabberG/src/jabber_xml.h b/protocols/JabberG/src/jabber_xml.h index 230be83e14..d0babbcfb4 100644 --- a/protocols/JabberG/src/jabber_xml.h +++ b/protocols/JabberG/src/jabber_xml.h @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define _JABBER_XML_H_ void XmlAddAttrID(TiXmlElement*, int id); + class XmlNode : public TiXmlDocument, private MNonCopyable { protected: diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index 6f2b8a80fe..af69115cf2 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -760,7 +760,7 @@ void CPepMood::UpdateMenuView() /////////////////////////////////////////////////////////////////////////////// // CPepActivity -#define ACTIVITY_ICON(section, item) -(300 + (section) * 20 + (item)) +#define ACTIVITY_ICON(section, item) -(1300 + (section) * 20 + (item)) struct { @@ -1499,7 +1499,7 @@ void g_XstatusIconsInit() mir_wstrcpy(szSection, L"Protocols/Jabber/" LPGENW("Moods")); for (int i = 1; i < _countof(g_arrMoods); i++) - g_MoodIcons.RegisterIcon(g_arrMoods[i].szTag, szFile, -(200 + i), szSection, TranslateW(g_arrMoods[i].szName)); + g_MoodIcons.RegisterIcon(g_arrMoods[i].szTag, szFile, -(1200 + i), szSection, TranslateW(g_arrMoods[i].szName)); mir_wstrcpy(szSection, L"Protocols/Jabber/" LPGENW("Activities")); for (int k = 0; k < _countof(g_arrActivities); k++) { diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index f319bb16d2..d7710f32a6 100755 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -116,6 +116,8 @@ struct CJabberProto; struct CMPlugin : public ACCPROTOPLUGIN { + char szRandom[17]; + CMPlugin(); int Load() override; @@ -147,11 +149,9 @@ protected: * Global constants *******************************************************************/ -#define GLOBAL_SETTING_PREFIX "JABBER" #define GLOBAL_SETTING_MODULE "JABBER" #define JABBER_DEFAULT_PORT 5222 -#define JABBER_IQID "mir_" #define JABBER_MAX_JID_LEN 1024 #define JABBER_GC_MSG_QUIT LPGEN("I'm happy Miranda NG user. Get it at https://miranda-ng.org/.") @@ -672,10 +672,6 @@ public: void g_IconsInit(); void g_XstatusIconsInit(); void g_XstatusIconsUninit(); -HANDLE g_GetIconHandle(int iconId); -HICON g_LoadIconEx(const char* name, bool big = false); - -void ImageList_AddIcon_Icolib(HIMAGELIST hIml, HICON hIcon); //---- jabber_libstr.c ---------------------------------------------- @@ -751,9 +747,13 @@ void JabberHttpUrlDecode(wchar_t *str); int JabberCombineStatus(int status1, int status2); time_t JabberIsoToUnixTime(const char *stamp); char* JabberStripJid(const char *jid, char *dest, size_t destLen); -int JabberGetPacketID(const TiXmlElement *n); +int JabberGetPacketID(const char*); char* JabberId2string(int id); +__inline int JabberGetPacketID(const TiXmlElement *n) +{ return JabberGetPacketID(XmlGetAttr(n, "id")); +} + char* time2str(time_t _time, char *buf, size_t bufLen); time_t str2time(const char*); diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp index c91e7d68ab..841ad32122 100644 --- a/protocols/MSN/src/msn_lists.cpp +++ b/protocols/MSN/src/msn_lists.cpp @@ -471,28 +471,25 @@ INT_PTR CALLBACK DlgProcMsnServLists(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, 5, 5); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_SMALLDOT); - HICON hIcon = Skin_LoadIcon(SKINICON_OTHER_SMALLDOT); - ImageList_AddIcon(hIml, hIcon); - IcoLib_ReleaseIcon(hIcon); - - hIcon = LoadIconEx("list_lc"); + HICON hIcon = g_plugin.getIcon(IDI_LIST_LC); ImageList_AddIcon(hIml, hIcon); SendDlgItemMessage(hwndDlg, IDC_ICON_LC, STM_SETICON, (WPARAM)hIcon, 0); - hIcon = LoadIconEx("list_fl"); + hIcon = g_plugin.getIcon(IDI_LIST_FL); ImageList_AddIcon(hIml, hIcon); SendDlgItemMessage(hwndDlg, IDC_ICON_FL, STM_SETICON, (WPARAM)hIcon, 0); - hIcon = LoadIconEx("list_al"); + hIcon = g_plugin.getIcon(IDI_LIST_AL); ImageList_AddIcon(hIml, hIcon); SendDlgItemMessage(hwndDlg, IDC_ICON_AL, STM_SETICON, (WPARAM)hIcon, 0); - hIcon = LoadIconEx("list_bl"); + hIcon = g_plugin.getIcon(IDI_LIST_BL); ImageList_AddIcon(hIml, hIcon); SendDlgItemMessage(hwndDlg, IDC_ICON_BL, STM_SETICON, (WPARAM)hIcon, 0); - hIcon = LoadIconEx("list_rl"); + hIcon = g_plugin.getIcon(IDI_LIST_RL); ImageList_AddIcon(hIml, hIcon); SendDlgItemMessage(hwndDlg, IDC_ICON_RL, STM_SETICON, (WPARAM)hIcon, 0); @@ -568,10 +565,10 @@ INT_PTR CALLBACK DlgProcMsnServLists(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case WM_DESTROY: HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0); ImageList_Destroy(hIml); - ReleaseIconEx("list_fl"); - ReleaseIconEx("list_al"); - ReleaseIconEx("list_bl"); - ReleaseIconEx("list_rl"); + g_plugin.releaseIcon(IDI_LIST_FL); + g_plugin.releaseIcon(IDI_LIST_AL); + g_plugin.releaseIcon(IDI_LIST_BL); + g_plugin.releaseIcon(IDI_LIST_RL); break; } diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp index 70c00d637f..fb55661a93 100644 --- a/protocols/MSN/src/msn_menu.cpp +++ b/protocols/MSN/src/msn_menu.cpp @@ -147,28 +147,28 @@ void CMsnProto::OnBuildProtoMenu(void) mi.pszService = MSN_INVITE; CreateProtoService(mi.pszService, &CMsnProto::MsnInviteCommand); mi.position = 201002; - mi.hIcolibItem = GetIconHandle(IDI_INVITE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_INVITE); mi.name.a = LPGEN("Create &Chat"); menuItemsMain[0] = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = MS_GOTO_INBOX; CreateProtoService(mi.pszService, &CMsnProto::MsnGotoInbox); mi.position = 201003; - mi.hIcolibItem = GetIconHandle(IDI_INBOX); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_INBOX); mi.name.a = LPGEN("Display &Hotmail Inbox"); menuItemsMain[1] = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = MS_EDIT_PROFILE; CreateProtoService(mi.pszService, &CMsnProto::MsnEditProfile); mi.position = 201004; - mi.hIcolibItem = GetIconHandle(IDI_PROFILE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_PROFILE); mi.name.a = LPGEN("View &Profile"); menuItemsMain[2] = Menu_AddProtoMenuItem(&mi, m_szModuleName); mi.pszService = MS_EDIT_ALERTS; CreateProtoService(mi.pszService, &CMsnProto::MsnSetupAlerts); mi.position = 201004; - mi.hIcolibItem = GetIconHandle(IDI_PROFILE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_PROFILE); mi.name.a = LPGEN("Setup Live &Alerts"); menuItemsMain[3] = Menu_AddProtoMenuItem(&mi, m_szModuleName); @@ -232,7 +232,7 @@ void MSN_InitContactMenu(void) mir_strcpy(tDest, MSN_BLOCK); CreateServiceFunction(servicefunction, MsnMenuBlockCommand); mi.position = -500050000; - mi.hIcolibItem = GetIconHandle(IDI_MSNBLOCK); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MSNBLOCK); mi.name.a = LPGEN("&Block"); hBlockMenuItem = Menu_AddContactMenuItem(&mi); @@ -240,7 +240,7 @@ void MSN_InitContactMenu(void) mir_strcpy(tDest, MSN_VIEW_PROFILE); CreateServiceFunction(servicefunction, MsnMenuViewProfile); mi.position = -500050003; - mi.hIcolibItem = GetIconHandle(IDI_PROFILE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_PROFILE); mi.name.a = LPGEN("View &Profile"); hLiveSpaceMenuItem = Menu_AddContactMenuItem(&mi); diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 8d62b4984d..03f595147f 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -795,7 +795,7 @@ void CMsnProto::InitPopups(void) POPUPCLASS ppc = { sizeof(ppc) }; ppc.flags = PCF_UNICODE; ppc.PluginWindowProc = NullWindowProc; - ppc.hIcon = LoadIconEx("main"); + ppc.hIcon = g_plugin.getIcon(IDI_MSN); ppc.pszName = name; ppc.pszDescription.w = desc; diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp index d348961550..7ee0dfca33 100644 --- a/protocols/MSN/src/msn_opts.cpp +++ b/protocols/MSN/src/msn_opts.cpp @@ -50,31 +50,6 @@ void MsnInitIcons(void) g_plugin.registerIcon("Protocols/MSN", iconList, "MSN"); } -HICON LoadIconEx(const char* name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "MSN_%s", name); - return IcoLib_GetIcon(szSettingName, big); -} - -HANDLE GetIconHandle(int iconId) -{ - for (auto &it : iconList) - if (it.defIconID == iconId) - return it.hIcolib; - - return nullptr; -} - -void ReleaseIconEx(const char* name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "MSN_%s", name); - IcoLib_Release(szSettingName, big); -} - -INT_PTR CALLBACK DlgProcMsnServLists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - ///////////////////////////////////////////////////////////////////////////////////////// // MSN Options dialog procedure @@ -589,6 +564,8 @@ INT_PTR CALLBACK DlgDeleteContactUI(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ///////////////////////////////////////////////////////////////////////////////////////// // Initialize options pages +INT_PTR CALLBACK DlgProcMsnServLists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + int CMsnProto::OnOptionsInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = {}; diff --git a/protocols/MSN/src/stdafx.h b/protocols/MSN/src/stdafx.h index e4b3b8e4fc..9340fe47c1 100644 --- a/protocols/MSN/src/stdafx.h +++ b/protocols/MSN/src/stdafx.h @@ -225,10 +225,6 @@ unsigned MSN_GenRandom(void); void MSN_InitContactMenu(void); void MSN_RemoveContactMenus(void); -HANDLE GetIconHandle(int iconId); -HICON LoadIconEx(const char* name, bool big = false); -void ReleaseIconEx(const char* name, bool big = false); - void MsnInitIcons(void); int sttDivideWords(char* parBuffer, int parMinItems, char** parDest); diff --git a/protocols/MinecraftDynmap/src/dialogs.cpp b/protocols/MinecraftDynmap/src/dialogs.cpp index 3639e3cc6b..b74debb644 100644 --- a/protocols/MinecraftDynmap/src/dialogs.cpp +++ b/protocols/MinecraftDynmap/src/dialogs.cpp @@ -24,26 +24,18 @@ along with this program. If not, see . // Icons -static IconItem iconList[] = { +static IconItem iconList[] = +{ { "proto", LPGEN("Protocol icon"), IDI_PROTO }, }; static HANDLE hIconLibItem[_countof(iconList)]; -void InitIcons(void) { +void InitIcons(void) +{ g_plugin.registerIcon("Protocols/MinecraftDynmap", iconList, "MinecraftDynmap"); } -HANDLE GetIconHandle(const char* name) { - for (size_t i = 0; i < _countof(iconList); i++) { - if (strcmp(iconList[i].szName, name) == 0) { - return hIconLibItem[i]; - } - } - return nullptr; -} - - // Dialogs static void LoadDBText(MinecraftDynmapProto* ppro, HWND hwnd, int idCtrl, const char* szSetting) @@ -55,14 +47,13 @@ static void LoadDBText(MinecraftDynmapProto* ppro, HWND hwnd, int idCtrl, const static void StoreDBText(MinecraftDynmapProto* ppro, HWND hwnd, int idCtrl, const char* szSetting) { - wchar_t tstr[250+1]; + wchar_t tstr[250 + 1]; GetDlgItemText(hwnd, idCtrl, tstr, _countof(tstr)); - if (tstr[0] != '\0') { + if (tstr[0] != '\0') db_set_ws(0, ppro->m_szModuleName, szSetting, tstr); - } else { + else db_unset(0, ppro->m_szModuleName, szSetting); - } } @@ -70,36 +61,31 @@ INT_PTR CALLBACK MinecraftDynmapAccountProc(HWND hwnd, UINT message, WPARAM wpar { MinecraftDynmapProto *proto; - switch (message) - { - + switch (message) { case WM_INITDIALOG: TranslateDialogDefault(hwnd); proto = reinterpret_cast(lparam); - SetWindowLongPtr(hwnd,GWLP_USERDATA,lparam); + SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam); LoadDBText(proto, hwnd, IDC_SERVER, MINECRAFTDYNMAP_KEY_SERVER); LoadDBText(proto, hwnd, IDC_NAME, MINECRAFTDYNMAP_KEY_NAME); - return TRUE; case WM_COMMAND: switch (LOWORD(wparam)) { - case IDC_NAME: { - if (HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus()) { - return TRUE; - } else { - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - } - break; - } + case IDC_NAME: + if (HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus()) + return TRUE; + + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + break; } break; case WM_NOTIFY: if (reinterpret_cast(lparam)->code == PSN_APPLY) { - proto = reinterpret_cast(GetWindowLongPtr(hwnd,GWLP_USERDATA)); + proto = reinterpret_cast(GetWindowLongPtr(hwnd, GWLP_USERDATA)); StoreDBText(proto, hwnd, IDC_SERVER, MINECRAFTDYNMAP_KEY_SERVER); StoreDBText(proto, hwnd, IDC_NAME, MINECRAFTDYNMAP_KEY_NAME); @@ -107,7 +93,6 @@ INT_PTR CALLBACK MinecraftDynmapAccountProc(HWND hwnd, UINT message, WPARAM wpar return TRUE; } break; - } return FALSE; } diff --git a/protocols/MinecraftDynmap/src/dialogs.h b/protocols/MinecraftDynmap/src/dialogs.h index d80024c8cf..b7f2dd5be7 100644 --- a/protocols/MinecraftDynmap/src/dialogs.h +++ b/protocols/MinecraftDynmap/src/dialogs.h @@ -23,7 +23,5 @@ along with this program. If not, see . #pragma once void InitIcons(void); -HANDLE GetIconHandle(const char *name); INT_PTR CALLBACK MinecraftDynmapAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); -INT_PTR CALLBACK MinecraftDynmapOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); diff --git a/protocols/NewsAggregator/Res/Resource.rc b/protocols/NewsAggregator/Res/Resource.rc index eb7688640f..9b8b50cfaa 100644 --- a/protocols/NewsAggregator/Res/Resource.rc +++ b/protocols/NewsAggregator/Res/Resource.rc @@ -28,6 +28,7 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT // remains consistent on all systems. IDI_ICON ICON "Main.ico" IDI_CHECKALL ICON "CheckAll.ico" +IDI_CHECKFEED ICON "CheckAll.ico" IDI_ADDFEED ICON "AddFeed.ico" IDI_IMPORTFEEDS ICON "Import.ico" IDI_EXPORTFEEDS ICON "Export.ico" diff --git a/protocols/NewsAggregator/Src/Icons.cpp b/protocols/NewsAggregator/Src/Icons.cpp index b9cdeb6166..f1525282b0 100644 --- a/protocols/NewsAggregator/Src/Icons.cpp +++ b/protocols/NewsAggregator/Src/Icons.cpp @@ -26,7 +26,7 @@ static IconItem iconList[] = { LPGEN("Add Feed"), "addfeed", IDI_ADDFEED}, { LPGEN("Import Feeds"), "importfeeds", IDI_IMPORTFEEDS}, { LPGEN("Export Feeds"), "exportfeeds", IDI_EXPORTFEEDS}, - { LPGEN("Check Feed"), "checkfeed", IDI_CHECKALL}, + { LPGEN("Check Feed"), "checkfeed", IDI_CHECKFEED}, { LPGEN("Auto Update Enabled"), "enabled", IDI_ENABLED}, { LPGEN("Auto Update Disabled"), "disabled", IDI_DISABLED} }; @@ -35,19 +35,3 @@ void InitIcons() { g_plugin.registerIcon(LPGEN("News Aggregator"), iconList, MODULENAME); } - -HICON LoadIconEx(const char *name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", MODULENAME, name); - return IcoLib_GetIcon(szSettingName, big); -} - -HANDLE GetIconHandle(const char *name) -{ - for (int i=0; i < _countof(iconList); i++) - if ( !mir_strcmp(iconList[i].szName, name)) - return iconList[i].hIcolib; - - return nullptr; -} diff --git a/protocols/NewsAggregator/Src/Menus.cpp b/protocols/NewsAggregator/Src/Menus.cpp index 7770e843eb..16bd7163ef 100644 --- a/protocols/NewsAggregator/Src/Menus.cpp +++ b/protocols/NewsAggregator/Src/Menus.cpp @@ -34,7 +34,7 @@ void InitMenu() mi.name.w = LPGENW("Auto Update Enabled"); else mi.name.w = LPGENW("Auto Update Disabled"); - mi.hIcolibItem = GetIconHandle("main"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ICON); mi.pszService = MS_NEWSAGGREGATOR_ENABLED; hService2[0] = Menu_AddMainMenuItem(&mi); @@ -46,21 +46,21 @@ void InitMenu() SET_UID(mi, 0xb876484d, 0x28aa, 0x4e03, 0x9e, 0x98, 0xed, 0xbc, 0xd1, 0xcf, 0x31, 0x80); mi.position = 20100002; - mi.hIcolibItem = GetIconHandle("addfeed"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ADDFEED); mi.name.w = LPGENW("Add Feed"); mi.pszService = MS_NEWSAGGREGATOR_ADDFEED; hService2[2] = Menu_AddMainMenuItem(&mi); SET_UID(mi, 0x600bf2c2, 0xa974, 0x44d3, 0x98, 0xf9, 0xe6, 0x65, 0x7c, 0x1f, 0x63, 0x37); mi.position = 20100003; - mi.hIcolibItem = GetIconHandle("importfeeds"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORTFEEDS); mi.name.w = LPGENW("Import Feeds"); mi.pszService = MS_NEWSAGGREGATOR_IMPORTFEEDS; hService2[3] = Menu_AddMainMenuItem(&mi); SET_UID(mi, 0xc09c8119, 0x64c2, 0x49bd, 0x81, 0xf, 0x54, 0x20, 0x69, 0xd7, 0x30, 0xcf); mi.position = 20100004; - mi.hIcolibItem = GetIconHandle("exportfeeds"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORTFEEDS); mi.name.w = LPGENW("Export Feeds"); mi.pszService = MS_NEWSAGGREGATOR_EXPORTFEEDS; hService2[4] = Menu_AddMainMenuItem(&mi); @@ -69,7 +69,7 @@ void InitMenu() SET_UID(mi, 0x92be499c, 0x928c, 0x4789, 0x8f, 0x36, 0x28, 0xa2, 0x9f, 0xb7, 0x1a, 0x97); mi.root = nullptr; mi.position = -0x7FFFFFFA; - mi.hIcolibItem = GetIconHandle("checkfeed"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_CHECKFEED); mi.name.w = LPGENW("Check feed"); mi.pszService = MS_NEWSAGGREGATOR_CHECKFEED; hService2[5] = Menu_AddContactMenuItem(&mi, MODULENAME); @@ -79,5 +79,5 @@ void InitMenu() mi.pszService = MS_NEWSAGGREGATOR_CHANGEFEED; hService2[6] = Menu_AddContactMenuItem(&mi, MODULENAME); - Menu_ModifyItem(hService2[0], nullptr, GetIconHandle(g_plugin.getByte("AutoUpdate", 1) ? "enabled" : "disabled")); + Menu_ModifyItem(hService2[0], nullptr, g_plugin.getIconHandle(g_plugin.getByte("AutoUpdate", 1) ? IDI_ENABLED : IDI_DISABLED)); } diff --git a/protocols/NewsAggregator/Src/Services.cpp b/protocols/NewsAggregator/Src/Services.cpp index b5b8c9f028..9183607841 100644 --- a/protocols/NewsAggregator/Src/Services.cpp +++ b/protocols/NewsAggregator/Src/Services.cpp @@ -113,7 +113,7 @@ INT_PTR NewsAggrGetStatus(WPARAM, LPARAM) INT_PTR NewsAggrLoadIcon(WPARAM wParam, LPARAM) { - return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(LoadIconEx("main", FALSE)) : 0; + return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(g_plugin.getIcon(IDI_ICON)) : 0; } static void __cdecl AckThreadProc(void *param) @@ -230,9 +230,9 @@ INT_PTR NewsAggrRecvMessage(WPARAM, LPARAM lParam) void UpdateMenu(bool State) { if (!State) // to enable auto-update - Menu_ModifyItem(hService2[0], LPGENW("Auto Update Enabled"), GetIconHandle("enabled")); + Menu_ModifyItem(hService2[0], LPGENW("Auto Update Enabled"), g_plugin.getIconHandle(IDI_ENABLED)); else // to disable auto-update - Menu_ModifyItem(hService2[0], LPGENW("Auto Update Disabled"), GetIconHandle("disabled")); + Menu_ModifyItem(hService2[0], LPGENW("Auto Update Disabled"), g_plugin.getIconHandle(IDI_DISABLED)); CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTBButton, State ? TTBST_PUSHED : 0); g_plugin.setByte("AutoUpdate", !State); @@ -253,8 +253,8 @@ int OnToolbarLoaded(WPARAM, LPARAM) ttb.pszService = MS_NEWSAGGREGATOR_ENABLED; ttb.pszTooltipUp = LPGEN("Auto Update Enabled"); ttb.pszTooltipDn = LPGEN("Auto Update Disabled"); - ttb.hIconHandleUp = GetIconHandle("enabled"); - ttb.hIconHandleDn = GetIconHandle("disabled"); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_ENABLED); + ttb.hIconHandleDn = g_plugin.getIconHandle(IDI_DISABLED); ttb.dwFlags = (g_plugin.getByte("AutoUpdate", 1) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE; hTBButton = g_plugin.addTTB(&ttb); return 0; diff --git a/protocols/NewsAggregator/Src/resource.h b/protocols/NewsAggregator/Src/resource.h index 131a0844ba..6067cef8bf 100644 --- a/protocols/NewsAggregator/Src/resource.h +++ b/protocols/NewsAggregator/Src/resource.h @@ -4,6 +4,7 @@ // #define IDD_OPTIONS 101 #define IDD_AUTHENTICATION 102 +#define IDI_CHECKFEED 108 #define IDI_ICON 109 #define IDD_ADDFEED 110 #define IDI_CHECKALL 111 diff --git a/protocols/NewsAggregator/Src/stdafx.h b/protocols/NewsAggregator/Src/stdafx.h index 819e96d69f..e2af12c08c 100644 --- a/protocols/NewsAggregator/Src/stdafx.h +++ b/protocols/NewsAggregator/Src/stdafx.h @@ -101,8 +101,6 @@ void NetlibInit(); void NetlibUnInit(); void InitMenu(); void InitIcons(); -HICON LoadIconEx(const char* name, bool big); -HANDLE GetIconHandle(const char* name); INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam); INT_PTR NewsAggrGetCaps(WPARAM wp, LPARAM lp); diff --git a/protocols/Omegle/src/communication.cpp b/protocols/Omegle/src/communication.cpp index 7741802cd4..a7b6c7960b 100644 --- a/protocols/Omegle/src/communication.cpp +++ b/protocols/Omegle/src/communication.cpp @@ -558,18 +558,14 @@ bool Omegle_client::events() Skin_PlaySound("StrangerTyp"); ptrW who(name == "spyTyping" ? json_as_string(json_at(item, 1)) : mir_wstrdup(L"Stranger")); - Srmm_SetStatusText(parent->GetChatHandle(), - CMStringW(FORMAT, TranslateT("%s is typing."), TranslateW(who)), - IcoLib_GetIconByHandle(GetIconHandle("typing_on"))); + Srmm_SetStatusText(parent->GetChatHandle(), CMStringW(FORMAT, TranslateT("%s is typing."), TranslateW(who)), g_plugin.getIcon(IDI_TYPING_ON)); } else if (name == "stoppedTyping" || name == "spyStoppedTyping") { // Stranger stopped typing, not supported by chat module yet Skin_PlaySound("StrangerTypStop"); ptrW who(name == "spyTyping" ? json_as_string(json_at(item, 1)) : mir_wstrdup(L"Stranger")); - Srmm_SetStatusText(parent->GetChatHandle(), - CMStringW(FORMAT, TranslateT("%s stopped typing."), TranslateW(who)), - IcoLib_GetIconByHandle(GetIconHandle("typing_off"))); + Srmm_SetStatusText(parent->GetChatHandle(), CMStringW(FORMAT, TranslateT("%s stopped typing."), TranslateW(who)), g_plugin.getIcon(IDI_TYPING_OFF)); } else if (name == "gotMessage") { Srmm_SetStatusText(parent->GetChatHandle(), nullptr); diff --git a/protocols/Omegle/src/theme.cpp b/protocols/Omegle/src/theme.cpp index 7473c69c3b..d76b4f6eb5 100644 --- a/protocols/Omegle/src/theme.cpp +++ b/protocols/Omegle/src/theme.cpp @@ -33,12 +33,3 @@ void InitIcons(void) { g_plugin.registerIcon("Protocols/Omegle", iconList, "Omegle"); } - -HANDLE GetIconHandle(const char* name) -{ - for (auto &it : iconList) - if (mir_strcmp(it.szName, name) == 0) - return it.hIcolib; - - return nullptr; -} diff --git a/protocols/Omegle/src/theme.h b/protocols/Omegle/src/theme.h index 9d3116e5eb..af39882941 100644 --- a/protocols/Omegle/src/theme.h +++ b/protocols/Omegle/src/theme.h @@ -23,4 +23,3 @@ along with this program. If not, see . #pragma once void InitIcons(void); -HANDLE GetIconHandle(const char *name); diff --git a/protocols/Sametime/src/conference.cpp b/protocols/Sametime/src/conference.cpp index 19cfa0cc16..dcba8b5dd6 100644 --- a/protocols/Sametime/src/conference.cpp +++ b/protocols/Sametime/src/conference.cpp @@ -455,13 +455,13 @@ void CSametimeProto::InitConferenceMenu() SET_UID(mi, 0x98cf8a8c, 0x75ba, 0x46f2, 0xa3, 0x35, 0x65, 0x46, 0x4a, 0x38, 0x20, 0x7d); mi.name.w = LPGENW("Leave conference"); mi.pszService = MS_SAMETIME_MENULEAVECHAT; - mi.hIcolibItem = GetIconHandle(IDI_ICON_LEAVE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ICON_LEAVE); hLeaveChatMenuItem = Menu_AddContactMenuItem(&mi, m_szModuleName); SET_UID(mi, 0x45501e10, 0x2914, 0x4daa, 0xb4, 0xcf, 0x83, 0x8a, 0x6a, 0x14, 0xd, 0x7); mi.name.w = LPGENW("Start conference"); mi.pszService = MS_SAMETIME_MENUCREATECHAT; - mi.hIcolibItem = GetIconHandle(IDI_ICON_INVITE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ICON_INVITE); hCreateChatMenuItem = Menu_AddContactMenuItem(&mi, m_szModuleName); HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CSametimeProto::PrebuildContactMenu); diff --git a/protocols/Sametime/src/sametime.cpp b/protocols/Sametime/src/sametime.cpp index ab7dce7818..189e877a66 100644 --- a/protocols/Sametime/src/sametime.cpp +++ b/protocols/Sametime/src/sametime.cpp @@ -86,28 +86,6 @@ void SametimeInitIcons(void) g_plugin.registerIcon("Protocols/Sametime", iconList, "SAMETIME"); } -HANDLE GetIconHandle(int iconId) -{ - for (int i = 0; i < _countof(iconList); i++) - if (iconList[i].defIconID == iconId) - return iconList[i].hIcolib; - return nullptr; -} - -HICON LoadIconEx(const char* name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", "SAMETIME", name); - return IcoLib_GetIcon(szSettingName, big); -} - -void ReleaseIconEx(const char* name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", "SAMETIME", name); - IcoLib_Release(szSettingName, big); -} - // Copied from MSN plugin - sent acks need to be from different thread void __cdecl sttFakeAckInfoSuccessThread(TFakeAckParams* tParam) { diff --git a/protocols/Sametime/src/sametime.h b/protocols/Sametime/src/sametime.h index ca84829906..2714779be2 100644 --- a/protocols/Sametime/src/sametime.h +++ b/protocols/Sametime/src/sametime.h @@ -41,10 +41,6 @@ INT_PTR CALLBACK CALLBACK SearchDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam void mwResolve_handler_callback(mwServiceResolve* srvc, guint32 id, guint32 code, GList* results, gpointer data); void SametimeInitIcons(void); -HANDLE GetIconHandle(int iconId); -HICON LoadIconEx(const char* name, bool big); -void ReleaseIconEx(const char* name, bool big); - // services (async thread functions) struct TFakeAckParams diff --git a/protocols/Sametime/src/sametime_session.cpp b/protocols/Sametime/src/sametime_session.cpp index 4634782034..79dfa47224 100644 --- a/protocols/Sametime/src/sametime_session.cpp +++ b/protocols/Sametime/src/sametime_session.cpp @@ -567,6 +567,6 @@ void CSametimeProto::InitSessionMenu() mi.position = 2000060000; mi.name.w = LPGENW("Send announcement..."); mi.pszService = MS_SAMETIME_MENUANNOUNCESESSION; - mi.hIcolibItem = GetIconHandle(IDI_ICON_ANNOUNCE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ICON_ANNOUNCE); Menu_AddContactMenuItem(&mi, m_szModuleName); } diff --git a/protocols/Sametime/src/utils.cpp b/protocols/Sametime/src/utils.cpp index 368a9cc093..5644c72342 100644 --- a/protocols/Sametime/src/utils.cpp +++ b/protocols/Sametime/src/utils.cpp @@ -42,8 +42,8 @@ void CSametimeProto::RegisterPopups() mir_snprintf(szName, "%s_%s", m_szModuleName, "Notify"); mir_snwprintf(szDescr, L"%s/%s", m_tszUserName, TranslateT("Notifications")); - puc.hIcon = CopyIcon(LoadIconEx("notify", FALSE)); - ReleaseIconEx("notify", FALSE); + puc.hIcon = CopyIcon(g_plugin.getIcon(IDI_ICON_NOTIFY)); + g_plugin.releaseIcon(IDI_ICON_NOTIFY); puc.iSeconds = 8; puc.colorBack = GetSysColor(COLOR_BTNFACE); puc.colorText = GetSysColor(COLOR_WINDOWTEXT); @@ -51,8 +51,8 @@ void CSametimeProto::RegisterPopups() mir_snprintf(szName, "%s_%s", m_szModuleName, "Error"); mir_snwprintf(szDescr, L"%s/%s", m_tszUserName, TranslateT("Errors")); - puc.hIcon = CopyIcon(LoadIconEx("error", FALSE)); - ReleaseIconEx("error", FALSE); + puc.hIcon = CopyIcon(g_plugin.getIcon(IDI_ICON_ERROR, FALSE)); + g_plugin.releaseIcon(IDI_ICON_ERROR); puc.iSeconds = 10; puc.colorBack = GetSysColor(COLOR_BTNFACE); puc.colorText = GetSysColor(COLOR_WINDOWTEXT); diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp index f5124b96da..60e51ce522 100644 --- a/protocols/SkypeWeb/src/skype_events.cpp +++ b/protocols/SkypeWeb/src/skype_events.cpp @@ -130,11 +130,11 @@ INT_PTR CSkypeProto::EventGetIcon(WPARAM flags, LPARAM pEvent) switch (dbei->eventType) { case SKYPE_DB_EVENT_TYPE_CALL_INFO: case SKYPE_DB_EVENT_TYPE_INCOMING_CALL: - icon = GetIcon(IDI_CALL); + icon = g_plugin.getIcon(IDI_CALL); break; case SKYPE_DB_EVENT_TYPE_ACTION: - icon = GetIcon(IDI_ACTION_ME); + icon = g_plugin.getIcon(IDI_ACTION_ME); break; case SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO: diff --git a/protocols/SkypeWeb/src/skype_icons.cpp b/protocols/SkypeWeb/src/skype_icons.cpp index 31024801f0..dcbeec6f64 100644 --- a/protocols/SkypeWeb/src/skype_icons.cpp +++ b/protocols/SkypeWeb/src/skype_icons.cpp @@ -34,19 +34,3 @@ void CSkypeProto::InitIcons() { g_plugin.registerIcon(LPGEN("Protocols") "/" MODULE, iconList, MODULE); } - -HICON CSkypeProto::GetIcon(int iconId) -{ - for (auto &it : iconList) - if (it.defIconID == iconId) - return IcoLib_GetIconByHandle(it.hIcolib); - return nullptr; -} - -HANDLE CSkypeProto::GetIconHandle(int iconId) -{ - for (auto &it : iconList) - if (it.defIconID == iconId) - return it.hIcolib; - return nullptr; -} diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp index 9f9a3975bc..04ad6194d4 100644 --- a/protocols/SkypeWeb/src/skype_menus.cpp +++ b/protocols/SkypeWeb/src/skype_menus.cpp @@ -64,7 +64,7 @@ void CSkypeProto::InitMenus() mi.pszService = MODULE"/GetHistory"; mi.name.w = LPGENW("Get server history"); mi.position = CMI_POSITION + CMI_GETSERVERHISTORY; - mi.hIcolibItem = GetIconHandle(IDI_SYNCHISTORY); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_SYNCHISTORY); SET_UID(mi, 0xc9a64e98, 0x9257, 0x4b52, 0x98, 0xdd, 0x7f, 0x56, 0xb3, 0x90, 0xe3, 0xde); ContactMenuItems[CMI_GETSERVERHISTORY] = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::GetContactHistory>); @@ -72,7 +72,7 @@ void CSkypeProto::InitMenus() mi.pszService = MODULE"/BlockContact"; mi.name.w = LPGENW("Block contact"); mi.position = CMI_POSITION + CMI_BLOCK; - mi.hIcolibItem = GetIconHandle(IDI_BLOCKUSER); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BLOCKUSER); SET_UID(mi, 0xc6169b8f, 0x53ab, 0x4242, 0xbe, 0x90, 0xe2, 0x4a, 0xa5, 0x73, 0x88, 0x32); ContactMenuItems[CMI_BLOCK] = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::BlockContact>); @@ -80,7 +80,7 @@ void CSkypeProto::InitMenus() mi.pszService = MODULE"/UnblockContact"; mi.name.w = LPGENW("Unblock contact"); mi.position = CMI_POSITION + CMI_UNBLOCK; - mi.hIcolibItem = GetIconHandle(IDI_UNBLOCKUSER); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_UNBLOCKUSER); SET_UID(mi, 0x88542f43, 0x7448, 0x48d0, 0x81, 0xa3, 0x26, 0x0, 0x4f, 0x37, 0xee, 0xe0); ContactMenuItems[CMI_UNBLOCK] = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::UnblockContact>); @@ -95,6 +95,6 @@ void CSkypeProto::OnBuildProtoMenu() CreateProtoService(mi.pszService, &CSkypeProto::SvcCreateChat); mi.name.a = LPGEN("Create new chat"); mi.position = SMI_POSITION + SMI_CREATECHAT; - mi.hIcolibItem = GetIconHandle(IDI_CONFERENCE); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_CONFERENCE); Menu_AddProtoMenuItem(&mi, m_szModuleName); } diff --git a/protocols/SkypeWeb/src/skype_popups.cpp b/protocols/SkypeWeb/src/skype_popups.cpp index f279a936b5..e147cd3936 100644 --- a/protocols/SkypeWeb/src/skype_popups.cpp +++ b/protocols/SkypeWeb/src/skype_popups.cpp @@ -12,7 +12,7 @@ void CSkypeProto::InitPopups() mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Notifications")); mir_snprintf(name, "%s_%s", m_szModuleName, "Notification"); - ppc.hIcon = GetIcon(IDI_NOTIFY); + ppc.hIcon = g_plugin.getIcon(IDI_NOTIFY); ppc.colorBack = RGB(255, 255, 255); ppc.colorText = RGB(0, 0, 0); ppc.iSeconds = 5; @@ -20,7 +20,7 @@ void CSkypeProto::InitPopups() mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Errors")); mir_snprintf(name, "%s_%s", m_szModuleName, "Error"); - ppc.hIcon = GetIcon(IDI_ERRORICON); + ppc.hIcon = g_plugin.getIcon(IDI_ERRORICON); ppc.colorBack = RGB(255, 255, 255); ppc.colorText = RGB(0, 0, 0); ppc.iSeconds = -1; @@ -28,7 +28,7 @@ void CSkypeProto::InitPopups() mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Calls")); mir_snprintf(name, "%s_%s", m_szModuleName, "Call"); - ppc.hIcon = GetIcon(IDI_CALL); + ppc.hIcon = g_plugin.getIcon(IDI_CALL); ppc.colorBack = RGB(255, 255, 255); ppc.colorText = RGB(0, 0, 0); ppc.iSeconds = 30; diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 7a15904c76..1414d38855 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -195,10 +195,6 @@ private: requestQueue->Send(request, SkypeHttpResponse, delegate); } - // icons - static HICON GetIcon(int iconId); - static HANDLE GetIconHandle(int iconId); - // menus static HGENMENU ContactMenuItems[CMI_MAX]; int OnPrebuildContactMenu(WPARAM hContact, LPARAM); diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp index b88dbe1c5d..1207beec23 100644 --- a/protocols/SkypeWeb/src/skype_trouter.cpp +++ b/protocols/SkypeWeb/src/skype_trouter.cpp @@ -194,7 +194,7 @@ void CSkypeProto::OnTrouterEvent(const JSONNode &body, const JSONNode &) cle.hContact = hContact; cle.hDbEvent = hEvent; cle.lParam = SKYPE_DB_EVENT_TYPE_INCOMING_CALL; - cle.hIcon = GetIcon(IDI_CALL); + cle.hIcon = g_plugin.getIcon(IDI_CALL); CMStringA service(FORMAT, "%s/IncomingCallCLE", GetContactProto(hContact)); cle.pszService = service.GetBuffer(); diff --git a/protocols/Tox/src/tox_icons.cpp b/protocols/Tox/src/tox_icons.cpp index 83c8f10f2b..50d11f5303 100644 --- a/protocols/Tox/src/tox_icons.cpp +++ b/protocols/Tox/src/tox_icons.cpp @@ -11,19 +11,3 @@ void CToxProto::InitIcons() { g_plugin.registerIcon(LPGEN("Protocols") "/" MODULE, iconList, MODULE); } - -HANDLE CToxProto::GetIconHandle(int iconId) -{ - for (auto &it : iconList) - if (it.defIconID == iconId) - return it.hIcolib; - return nullptr; -} - -HICON CToxProto::GetIcon(int iconId) -{ - for (auto &it : iconList) - if (it.defIconID == iconId) - return IcoLib_GetIconByHandle(it.hIcolib); - return nullptr; -} diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp index ef75bfaf38..cd327a7146 100644 --- a/protocols/Tox/src/tox_messages.cpp +++ b/protocols/Tox/src/tox_messages.cpp @@ -18,7 +18,7 @@ INT_PTR CToxProto::EventGetIcon(WPARAM wParam, LPARAM lParam) switch (dbei->eventType) { case DB_EVENT_ACTION: - icon = GetIcon(IDI_ME); + icon = g_plugin.getIcon(IDI_ME); break; default: diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index bcd95434c0..62ecf196e8 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -122,10 +122,6 @@ private: // netlib void InitNetlib(); - // icons - static HANDLE GetIconHandle(int iconId); - static HICON GetIcon(int iconId); - // menus static HGENMENU ContactMenuItems[CMI_MAX]; int __cdecl OnPrebuildContactMenu(WPARAM hContact, LPARAM); diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 0b55ba50a4..6b299829a4 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -82,15 +82,6 @@ void InitIcons() g_plugin.registerIcon(LPGEN("Protocols") "/" LPGEN("VKontakte"), iconList, "VKontakte"); } -HANDLE GetIconHandle(int iCommand) -{ - for (auto &it : iconList) - if (it.defIconID == iCommand) - return it.hIcolib; - - return nullptr; -} - ///////////////////////////////////////////////////////////////////////////////////////// char* ExpUrlEncode(const char *szUrl, bool strict) @@ -765,7 +756,7 @@ void CVkProto::SetSrmmReadStatus(MCONTACT hContact) _wcsftime_l(ttime, _countof(ttime), L"%X - %x", localtime(&time), locale); _free_locale(locale); - Srmm_SetStatusText(hContact, CMStringW(FORMAT, TranslateT("Message read: %s"), ttime), IcoLib_GetIconByHandle(GetIconHandle(IDI_READMSG))); + Srmm_SetStatusText(hContact, CMStringW(FORMAT, TranslateT("Message read: %s"), ttime), g_plugin.getIcon(IDI_READMSG)); } void CVkProto::MarkDialogAsRead(MCONTACT hContact) diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index acc4ae940f..8c3d8e14d9 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -108,7 +108,6 @@ LPCSTR findHeader(NETLIBHTTPREQUEST *hdr, LPCSTR szField); bool wlstrstr(wchar_t *_s1, wchar_t *_s2); void InitIcons(void); -HANDLE GetIconHandle(int iCommand); char* ExpUrlEncode(const char *szUrl, bool strict = false); diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 0ade10a53c..ce8afc5a67 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -546,9 +546,12 @@ void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch) CVkInviteChatForm dlg(this); if (dlg.DoModal() && dlg.m_hContact != 0) { LONG uid = getDword(dlg.m_hContact, "ID", VK_INVALID_USER); - if (uid != VK_INVALID_USER) + + if (uid < 0) + MsgPopup(TranslateT("Adding bots to MUC is not supported"), TranslateT("Not supported")); + else if (uid != VK_INVALID_USER) Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.addChatUser.json", true, &CVkProto::OnReceiveSmth) - << INT_PARAM("user_id", uid < 0 ? 1000000000 - uid : uid) + << INT_PARAM("user_id", uid) << INT_PARAM("chat_id", cc->m_iChatId)); } } @@ -761,9 +764,14 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch) if (!IsOnline()) return; + if (cu->m_uid < 0) { + MsgPopup(TranslateT("Kick bots is not supported"), TranslateT("Not supported")); + return; + } + Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.removeChatUser.json", true, &CVkProto::OnReceiveSmth) << INT_PARAM("chat_id", cc->m_iChatId) - << INT_PARAM("user_id", cu->m_uid < 0 ? 1000000000 - cu->m_uid : cu->m_uid)); + << INT_PARAM("user_id", cu->m_uid)); cu->m_bUnknown = true; break; diff --git a/protocols/VKontakte/src/vk_dialogs.cpp b/protocols/VKontakte/src/vk_dialogs.cpp index 3ccf89ab6a..8616098d7f 100644 --- a/protocols/VKontakte/src/vk_dialogs.cpp +++ b/protocols/VKontakte/src/vk_dialogs.cpp @@ -34,7 +34,7 @@ CVkCaptchaForm::CVkCaptchaForm(CVkProto *proto, CAPTCHA_FORM_PARAMS *param) : bool CVkCaptchaForm::OnInitDialog() { - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_KEYS)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_KEYS)); m_btnOk.Disable(); m_btnOpenInBrowser.Enable((m_param->bmp != nullptr)); @@ -118,7 +118,7 @@ CVkWallPostForm::CVkWallPostForm(CVkProto *proto, WALLPOST_FORM_PARAMS *param) : bool CVkWallPostForm::OnInitDialog() { - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_WALL)); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_WALL)); CMStringW wszTitle(FORMAT, TranslateT("Wall message for %s"), m_param->pwszNick); SetCaption(wszTitle); diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 1489553ef4..9034495659 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -76,7 +76,7 @@ void CVkProto::AddCListEvent(bool bNews) MCONTACT hContact = FindUser(VK_FEED_USER, true); CLISTEVENT cle = {}; - cle.hIcon = IcoLib_GetIconByHandle(GetIconHandle(IDI_NOTIFICATION)); + cle.hIcon = g_plugin.getIcon(IDI_NOTIFICATION); cle.pszService = MS_MSG_READMESSAGE; cle.flags = CLEF_URGENT | CLEF_UNICODE; cle.hContact = hContact; diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 66b176cae1..a15749e750 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -160,7 +160,7 @@ void CVkProto::InitMenus() if (m_vkOptions.bShowProtoMenuItem1) { mi.pszService = PS_SETSTATUSMSG; mi.position = 10009 + PMI_SETSTATUSMSG; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_STATUS)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_STATUS); mi.name.a = LPGEN("Status message"); SET_UID(mi, 0x696bd932, 0xeee4, 0x4c4c, 0xa6, 0xf8, 0xb3, 0x72, 0xdf, 0xc6, 0xfa, 0xd1); m_hProtoMenuItems[PMI_SETSTATUSMSG] = Menu_AddProtoMenuItem(&mi, m_szModuleName); @@ -169,7 +169,7 @@ void CVkProto::InitMenus() if (m_vkOptions.bShowProtoMenuItem2) { mi.pszService = PS_WALLPOST; mi.position = 10009 + PMI_WALLPOST; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_WALL)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_WALL); mi.name.a = LPGEN("Send message to my wall"); SET_UID(mi, 0x50a80044, 0xdddd, 0x47e6, 0x9e, 0x90, 0x32, 0x7b, 0x88, 0x13, 0x21, 0x4e); m_hProtoMenuItems[PMI_WALLPOST] = Menu_AddProtoMenuItem(&mi, m_szModuleName); @@ -178,7 +178,7 @@ void CVkProto::InitMenus() if (m_vkOptions.bShowProtoMenuItem3) { mi.pszService = PS_LOADVKNEWS; mi.position = 10009 + PMI_LOADVKNEWS; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_NOTIFICATION)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_NOTIFICATION); mi.name.a = LPGEN("Load news from VK"); SET_UID(mi, 0x7c449456, 0xb731, 0x48cc, 0x9c, 0x4e, 0x20, 0xe4, 0x66, 0x7a, 0x16, 0x23); m_hProtoMenuItems[PMI_LOADVKNEWS] = Menu_AddProtoMenuItem(&mi, m_szModuleName); @@ -187,7 +187,7 @@ void CVkProto::InitMenus() if (m_vkOptions.bShowProtoMenuItem4) { mi.pszService = PS_GETALLSERVERHISTORY; mi.position = 10009 + PMI_GETALLSERVERHISTORY; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HISTORY); mi.name.a = LPGEN("Load history for all contacts from VK"); SET_UID(mi, 0xe5028605, 0x92eb, 0x4956, 0xa0, 0xd0, 0x53, 0xb, 0x11, 0x44, 0x8f, 0x14); m_hProtoMenuItems[PMI_GETALLSERVERHISTORY] = Menu_AddProtoMenuItem(&mi, m_szModuleName); @@ -196,7 +196,7 @@ void CVkProto::InitMenus() if (m_vkOptions.bShowProtoMenuItem5) { mi.pszService = PS_WIPENONFRIENDS; mi.position = 10009 + PMI_WIPENONFRIENDS; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_FRIENDDEL)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_FRIENDDEL); mi.name.a = LPGEN("Wipe contacts missing in friend list"); SET_UID(mi, 0xcfe99159, 0xf237, 0x4546, 0x80, 0x3e, 0x51, 0x88, 0x26, 0x55, 0xdc, 0x5f); m_hProtoMenuItems[PMI_WIPENONFRIENDS] = Menu_AddProtoMenuItem(&mi, m_szModuleName); @@ -205,7 +205,7 @@ void CVkProto::InitMenus() if (m_vkOptions.bShowProtoMenuItem6) { mi.pszService = PS_VISITPROFILE; mi.position = 10009 + PMI_VISITPROFILE; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_VISITPROFILE)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_VISITPROFILE); mi.name.a = LPGEN("Visit profile"); SET_UID(mi, 0x9550515e, 0x2a45, 0x4913, 0x95, 0x1a, 0x1e, 0xfa, 0x7, 0xc6, 0x2d, 0x60); m_hProtoMenuItems[PMI_VISITPROFILE] = Menu_AddProtoMenuItem(&mi, m_szModuleName); @@ -217,70 +217,70 @@ void CVkProto::InitMenus() mi.pszService = PS_VISITPROFILE; mi.position = -200001000 + CMI_VISITPROFILE; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_VISITPROFILE)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_VISITPROFILE); mi.name.w = LPGENW("Visit profile"); SET_UID(mi, 0x828cc50e, 0x398d, 0x43a2, 0xbf, 0xd3, 0xa9, 0x96, 0x47, 0x9d, 0x52, 0xff); m_hContactMenuItems[CMI_VISITPROFILE] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_MARKMESSAGESASREAD; mi.position = -200001000 + CMI_MARKMESSAGESASREAD; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_MARKMESSAGESASREAD)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MARKMESSAGESASREAD); mi.name.w = LPGENW("Mark messages as read"); SET_UID(mi, 0x2587a649, 0xe5d5, 0x4e90, 0x8b, 0x35, 0x81, 0x4c, 0xb1, 0x5, 0x94, 0x7); m_hContactMenuItems[CMI_MARKMESSAGESASREAD] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_WALLPOST; mi.position = -200001000 + CMI_WALLPOST; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_WALL)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_WALL); mi.name.w = LPGENW("Send message to user's wall"); SET_UID(mi, 0xd8841aaf, 0x15f6, 0x4be9, 0x9f, 0x4f, 0x16, 0xa9, 0x47, 0x6a, 0x19, 0x81); m_hContactMenuItems[CMI_WALLPOST] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_ADDASFRIEND; mi.position = -200001000 + CMI_ADDASFRIEND; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_FRIENDADD)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_FRIENDADD); mi.name.w = LPGENW("Add as friend"); SET_UID(mi, 0xf11b9a7f, 0x569, 0x4023, 0xb0, 0xd6, 0xa3, 0x16, 0xf6, 0xd4, 0xfb, 0xb5); m_hContactMenuItems[CMI_ADDASFRIEND] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_DELETEFRIEND; mi.position = -200001000 + CMI_DELETEFRIEND; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_FRIENDDEL)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_FRIENDDEL); mi.name.w = LPGENW("Delete from friend list"); SET_UID(mi, 0x1e26514, 0x854f, 0x4e60, 0x8c, 0xf8, 0xab, 0xaa, 0xe0, 0xc3, 0xa5, 0xa7); m_hContactMenuItems[CMI_DELETEFRIEND] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_BANUSER; mi.position = -200001000 + CMI_BANUSER; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_BAN)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BAN); mi.name.w = LPGENW("Ban user"); SET_UID(mi, 0x7ba06bab, 0xf770, 0x4938, 0x9c, 0x76, 0xef, 0x40, 0xbc, 0x55, 0x0, 0x9b); m_hContactMenuItems[CMI_BANUSER] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_REPORTABUSE; mi.position = -200001000 + CMI_REPORTABUSE; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_ABUSE)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ABUSE); mi.name.w = LPGENW("Report abuse"); SET_UID(mi, 0x56454cb9, 0xd80, 0x4050, 0xbe, 0xfc, 0x2c, 0xf6, 0x10, 0x2a, 0x7d, 0x19); m_hContactMenuItems[CMI_REPORTABUSE] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_DESTROYKICKCHAT; mi.position = -200001000 + CMI_DESTROYKICKCHAT; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_FRIENDDEL)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_FRIENDDEL); mi.name.w = LPGENW("Destroy room"); SET_UID(mi, 0x4fa6e75a, 0x30cd, 0x4482, 0xae, 0x8f, 0x0, 0x38, 0xd0, 0x17, 0x33, 0xcd); m_hContactMenuItems[CMI_DESTROYKICKCHAT] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_OPENBROADCAST; mi.position = -200001000 + CMI_OPENBROADCAST; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_BROADCAST)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_BROADCAST); mi.name.w = LPGENW("Open broadcast"); SET_UID(mi, 0x85251a06, 0xf734, 0x4985, 0x8c, 0x36, 0x6f, 0x66, 0x46, 0xf9, 0xa0, 0x10); m_hContactMenuItems[CMI_OPENBROADCAST] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_LOADVKNEWS; mi.position = -200001000 + CMI_LOADVKNEWS; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_NOTIFICATION)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_NOTIFICATION); mi.name.w = LPGENW("Load news from VK"); SET_UID(mi, 0xe1f6888b, 0x21ae, 0x409f, 0x82, 0xa2, 0x7b, 0x72, 0xef, 0x47, 0x9, 0xc0); m_hContactMenuItems[CMI_LOADVKNEWS] = Menu_AddContactMenuItem(&mi, m_szModuleName); @@ -288,7 +288,7 @@ void CVkProto::InitMenus() // Sync history menu mi.pszService = PS_GETSERVERHISTORY; mi.position = -200001000 + CMI_GETSERVERHISTORY; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HISTORY); mi.name.w = LPGENW("Reload messages from vk.com..."); SET_UID(mi, 0xc6b59e9f, 0x5250, 0x4146, 0xb6, 0xf3, 0x2d, 0xe1, 0x4, 0x3b, 0x95, 0xf5); m_hContactMenuItems[CMI_GETSERVERHISTORY] = Menu_AddContactMenuItem(&mi, m_szModuleName); @@ -297,42 +297,42 @@ void CVkProto::InitMenus() mi.pszService = PS_GETSERVERHISTORYLAST1DAY; mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST1DAY; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HISTORY); mi.name.w = LPGENW("for last 1 day"); SET_UID(mi, 0x508dce88, 0x1a9a, 0x4dd7, 0x90, 0xf4, 0x41, 0x35, 0x7b, 0xc3, 0x17, 0xed); m_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST1DAY] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_GETSERVERHISTORYLAST3DAY; mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST3DAY; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HISTORY); mi.name.w = LPGENW("for last 3 days"); SET_UID(mi, 0x9a878764, 0x5bbf, 0x433a, 0xbd, 0x50, 0xa9, 0xb9, 0x16, 0x1f, 0x99, 0x29); m_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST3DAY] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_GETSERVERHISTORYLAST7DAY; mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST7DAY; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HISTORY); mi.name.w = LPGENW("for last week"); SET_UID(mi, 0xc6482460, 0xd280, 0x4596, 0x97, 0x4b, 0xf7, 0xfa, 0x6d, 0xe, 0xd5, 0xda); m_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST7DAY] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_GETSERVERHISTORYLAST30DAY; mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST30DAY; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HISTORY); mi.name.w = LPGENW("for last 30 days"); SET_UID(mi, 0xc48e8a9f, 0x2860, 0x4d5b, 0xa8, 0xdf, 0xb8, 0x3f, 0xdf, 0x7b, 0xa2, 0xba); m_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST30DAY] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_GETSERVERHISTORYLAST90DAY; mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETSERVERHISTORYLAST90DAY; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HISTORY); mi.name.w = LPGENW("for last 90 days"); SET_UID(mi, 0xd8e30530, 0xa585, 0x4672, 0xa6, 0x39, 0x18, 0xc9, 0xc9, 0xcb, 0xc7, 0x7d); m_hContactHistoryMenuItems[CHMI_GETSERVERHISTORYLAST90DAY] = Menu_AddContactMenuItem(&mi, m_szModuleName); mi.pszService = PS_GETALLSERVERHISTORYFORCONTACT; mi.position = -200001000 + CMI_GETSERVERHISTORY + 100 + CHMI_GETALLSERVERHISTORYFORCONTACT; - mi.hIcolibItem = IcoLib_GetIconByHandle(GetIconHandle(IDI_HISTORY)); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_HISTORY); mi.name.w = LPGENW("for all time"); SET_UID(mi, 0xaee3d02b, 0x3667, 0x47c8, 0x9f, 0x43, 0x14, 0xb7, 0xab, 0x52, 0x14, 0x94); m_hContactHistoryMenuItems[CHMI_GETALLSERVERHISTORYFORCONTACT] = Menu_AddContactMenuItem(&mi, m_szModuleName); @@ -424,7 +424,7 @@ void CVkProto::InitPopups(void) mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Notifications")); mir_snprintf(name, "%s_%s", m_szModuleName, "Notification"); - ppc.hIcon = IcoLib_GetIconByHandle(GetIconHandle(IDI_NOTIFICATION)); + ppc.hIcon = g_plugin.getIcon(IDI_NOTIFICATION); ppc.colorBack = RGB(190, 225, 255); // Blue ppc.colorText = RGB(255, 255, 255); // White ppc.iSeconds = 4; @@ -531,7 +531,7 @@ int CVkProto::AuthRequest(MCONTACT hContact, const wchar_t *message) return 1; if (userID < 0) - userID = 1000000000 - userID; + return 1; wchar_t msg[501] = { 0 }; diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h index eee562a9ed..9affd13abb 100644 --- a/protocols/Weather/src/stdafx.h +++ b/protocols/Weather/src/stdafx.h @@ -531,9 +531,6 @@ int BriefInfo(WPARAM wParam, LPARAM lParam); INT_PTR BriefInfoSvc(WPARAM wParam, LPARAM lParam); void InitIcons(void); -HICON LoadIconEx(const char* name, bool big); -HANDLE GetIconHandle(const char* name); -void ReleaseIconEx(HICON hIcon); //============ Plugin Class ============ diff --git a/protocols/Weather/src/weather.cpp b/protocols/Weather/src/weather.cpp index 742f860967..812e0ce26c 100644 --- a/protocols/Weather/src/weather.cpp +++ b/protocols/Weather/src/weather.cpp @@ -109,8 +109,8 @@ int OnToolbarLoaded(WPARAM, LPARAM) ttb.pszService = MS_WEATHER_ENABLED; ttb.pszTooltipUp = LPGEN("Auto Update Enabled"); ttb.pszTooltipDn = LPGEN("Auto Update Disabled"); - ttb.hIconHandleUp = GetIconHandle("main"); - ttb.hIconHandleDn = GetIconHandle("disabled"); + ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_ICON); + ttb.hIconHandleDn = g_plugin.getIconHandle(IDI_DISABLED); ttb.dwFlags = (g_plugin.getByte("AutoUpdate", 1) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE; hTBButton = g_plugin.addTTB(&ttb); return 0; diff --git a/protocols/Weather/src/weather_icons.cpp b/protocols/Weather/src/weather_icons.cpp index 3e043d9280..5e993cd443 100644 --- a/protocols/Weather/src/weather_icons.cpp +++ b/protocols/Weather/src/weather_icons.cpp @@ -20,8 +20,6 @@ along with this program. If not, see . #include "stdafx.h" -HANDLE hIcoLibIconsChanged = nullptr; - static IconItem iconList[] = { { LPGEN("Protocol icon"), "main", IDI_ICON }, @@ -41,24 +39,3 @@ void InitIcons(void) { g_plugin.registerIcon(MODULENAME, iconList, MODULENAME); } - -HICON LoadIconEx(const char* name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, "%s_%s", MODULENAME, name); - return IcoLib_GetIcon(szSettingName, big); -} - -HANDLE GetIconHandle(const char* name) -{ - for (auto &it : iconList) - if (mir_strcmp(it.szName, name) == 0) - return it.hIcolib; - - return nullptr; -} - -void ReleaseIconEx(HICON hIcon) -{ - IcoLib_ReleaseIcon(hIcon); -} diff --git a/protocols/Weather/src/weather_ini.cpp b/protocols/Weather/src/weather_ini.cpp index 000eab1bc9..bd60fcaaa0 100644 --- a/protocols/Weather/src/weather_ini.cpp +++ b/protocols/Weather/src/weather_ini.cpp @@ -163,7 +163,7 @@ static INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SendDlgItemMessage(hwndDlg, IDC_STEP4, BUTTONSETASFLATBTN, TRUE, 0); // set icons - Window_SetIcon_IcoLib(hwndDlg, GetIconHandle("main")); + Window_SetIcon_IcoLib(hwndDlg, g_plugin.getIconHandle(IDI_ICON)); WindowList_Add(hWindowList, hwndDlg); ShowWindow(hwndDlg, SW_SHOW); diff --git a/protocols/Weather/src/weather_mwin.cpp b/protocols/Weather/src/weather_mwin.cpp index a240b01421..1c1a7b7896 100644 --- a/protocols/Weather/src/weather_mwin.cpp +++ b/protocols/Weather/src/weather_mwin.cpp @@ -241,7 +241,7 @@ static void addWindow(MCONTACT hContact) CLISTFrame Frame = { 0 }; Frame.szName.w = winname; - Frame.hIcon = LoadIconEx("main", FALSE); + Frame.hIcon = g_plugin.getIcon(IDI_ICON); Frame.cbSize = sizeof(Frame); Frame.hWnd = hWnd; Frame.align = alBottom; diff --git a/protocols/Weather/src/weather_svcs.cpp b/protocols/Weather/src/weather_svcs.cpp index 4119eab464..2ef10fffa9 100644 --- a/protocols/Weather/src/weather_svcs.cpp +++ b/protocols/Weather/src/weather_svcs.cpp @@ -99,7 +99,7 @@ INT_PTR WeatherGetStatus(WPARAM, LPARAM) // protocol service function to get the icon of the protocol INT_PTR WeatherLoadIcon(WPARAM wParam, LPARAM) { - return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(LoadIconEx("main", FALSE)) : 0; + return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(g_plugin.getIcon(IDI_ICON)) : 0; } static void __cdecl AckThreadProc(HANDLE param) @@ -220,11 +220,11 @@ void UpdateMenu(BOOL State) g_plugin.setByte("AutoUpdate", (BYTE)State); if (State) { // to enable auto-update - Menu_ModifyItem(hEnableDisableMenu, LPGENW("Auto Update Enabled"), GetIconHandle("main")); + Menu_ModifyItem(hEnableDisableMenu, LPGENW("Auto Update Enabled"), g_plugin.getIconHandle(IDI_ICON)); opt.AutoUpdate = 1; } else { // to disable auto-update - Menu_ModifyItem(hEnableDisableMenu, LPGENW("Auto Update Disabled"), GetIconHandle("disabled")); + Menu_ModifyItem(hEnableDisableMenu, LPGENW("Auto Update Disabled"), g_plugin.getIconHandle(IDI_DISABLED)); opt.AutoUpdate = 0; } @@ -238,9 +238,9 @@ void UpdatePopupMenu(BOOL State) g_plugin.setByte("UsePopup", (BYTE)opt.UsePopup); if (State) // to enable popup - Menu_ModifyItem(hEnableDisablePopupMenu, LPGENW("Disable &weather notification"), GetIconHandle("popup")); + Menu_ModifyItem(hEnableDisablePopupMenu, LPGENW("Disable &weather notification"), g_plugin.getIconHandle(IDI_POPUP)); else // to disable popup - Menu_ModifyItem(hEnableDisablePopupMenu, LPGENW("Enable &weather notification"), GetIconHandle("nopopup")); + Menu_ModifyItem(hEnableDisablePopupMenu, LPGENW("Enable &weather notification"), g_plugin.getIconHandle(IDI_NOPOPUP)); } // update the weather auto-update menu item when click on it @@ -267,7 +267,7 @@ void AddMenuItems(void) SET_UID(mi, 0x266ef52b, 0x869a, 0x4cac, 0xa9, 0xf8, 0xea, 0x5b, 0xb8, 0xab, 0xe0, 0x24); CreateServiceFunction(MS_WEATHER_UPDATE, UpdateSingleStation); mi.position = -0x7FFFFFFA; - mi.hIcolibItem = GetIconHandle("update"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_UPDATE); mi.name.a = LPGEN("Update Weather"); mi.pszService = MS_WEATHER_UPDATE; Menu_AddContactMenuItem(&mi, MODULENAME); @@ -275,7 +275,7 @@ void AddMenuItems(void) SET_UID(mi, 0x45361b4, 0x8de, 0x44b4, 0x8f, 0x11, 0x9b, 0xe9, 0x6e, 0xa8, 0x83, 0x54); CreateServiceFunction(MS_WEATHER_REFRESH, UpdateSingleRemove); mi.position = -0x7FFFFFF9; - mi.hIcolibItem = GetIconHandle("update2"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_UPDATE2); mi.name.a = LPGEN("Remove Old Data then Update"); mi.pszService = MS_WEATHER_REFRESH; Menu_AddContactMenuItem(&mi, MODULENAME); @@ -283,7 +283,7 @@ void AddMenuItems(void) SET_UID(mi, 0x4232975e, 0xb181, 0x46a5, 0xb7, 0x6e, 0xd2, 0x5f, 0xef, 0xb8, 0xc4, 0x4d); CreateServiceFunction(MS_WEATHER_BRIEF, BriefInfoSvc); mi.position = -0x7FFFFFF8; - mi.hIcolibItem = GetIconHandle("brief"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_S); mi.name.a = LPGEN("Brief Information"); mi.pszService = MS_WEATHER_BRIEF; Menu_AddContactMenuItem(&mi, MODULENAME); @@ -291,7 +291,7 @@ void AddMenuItems(void) SET_UID(mi, 0x3d6ed729, 0xd49a, 0x4ae9, 0x8e, 0x2, 0x9f, 0xe0, 0xf0, 0x2c, 0xcc, 0xb1); CreateServiceFunction(MS_WEATHER_COMPLETE, LoadForecast); mi.position = -0x7FFFFFF7; - mi.hIcolibItem = GetIconHandle("read"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_READ); mi.name.a = LPGEN("Read Complete Forecast"); mi.pszService = MS_WEATHER_COMPLETE; Menu_AddContactMenuItem(&mi, MODULENAME); @@ -299,7 +299,7 @@ void AddMenuItems(void) SET_UID(mi, 0xc4b6c5e0, 0x13c3, 0x4e02, 0x8a, 0xeb, 0xeb, 0x8a, 0xe2, 0x66, 0x40, 0xd4); CreateServiceFunction(MS_WEATHER_MAP, WeatherMap); mi.position = -0x7FFFFFF6; - mi.hIcolibItem = GetIconHandle("map"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_MAP); mi.name.a = LPGEN("Weather Map"); mi.pszService = MS_WEATHER_MAP; Menu_AddContactMenuItem(&mi, MODULENAME); @@ -307,7 +307,7 @@ void AddMenuItems(void) SET_UID(mi, 0xee3ad7f4, 0x3377, 0x4e4c, 0x8f, 0x3c, 0x3b, 0xf5, 0xd4, 0x86, 0x28, 0x25); CreateServiceFunction(MS_WEATHER_LOG, ViewLog); mi.position = -0x7FFFFFF5; - mi.hIcolibItem = GetIconHandle("log"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_LOG); mi.name.a = LPGEN("View Log"); mi.pszService = MS_WEATHER_LOG; Menu_AddContactMenuItem(&mi, MODULENAME); @@ -315,7 +315,7 @@ void AddMenuItems(void) SET_UID(mi, 0x1b01cd6a, 0xe5ee, 0x42b4, 0xa1, 0x6d, 0x43, 0xb9, 0x4, 0x58, 0x43, 0x2e); CreateServiceFunction(MS_WEATHER_EDIT, EditSettings); mi.position = -0x7FFFFFF4; - mi.hIcolibItem = GetIconHandle("edit"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_EDIT); mi.name.a = LPGEN("Edit Settings"); mi.pszService = MS_WEATHER_EDIT; Menu_AddContactMenuItem(&mi, MODULENAME); @@ -327,7 +327,7 @@ void AddMenuItems(void) SET_UID(mi, 0x5ad16188, 0xe0a0, 0x4c31, 0x85, 0xc3, 0xe4, 0x85, 0x79, 0x7e, 0x4b, 0x9c); CreateServiceFunction(MS_WEATHER_ENABLED, EnableDisableCmd); mi.name.a = LPGEN("Enable/Disable Weather Update"); - mi.hIcolibItem = GetIconHandle("main"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_ICON); mi.position = 10100001; mi.pszService = MS_WEATHER_ENABLED; hEnableDisableMenu = Menu_AddMainMenuItem(&mi); @@ -336,7 +336,7 @@ void AddMenuItems(void) SET_UID(mi, 0x2b1c2054, 0x2991, 0x4025, 0x87, 0x73, 0xb6, 0xf7, 0x85, 0xac, 0xc7, 0x37); CreateServiceFunction(MS_WEATHER_UPDATEALL, UpdateAllInfo); mi.position = 20100001; - mi.hIcolibItem = GetIconHandle("update"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_UPDATE); mi.name.a = LPGEN("Update All Weather"); mi.pszService = MS_WEATHER_UPDATEALL; Menu_AddMainMenuItem(&mi); @@ -344,7 +344,7 @@ void AddMenuItems(void) SET_UID(mi, 0x8234c00e, 0x788e, 0x424f, 0xbc, 0xc4, 0x2, 0xfd, 0x67, 0x58, 0x2d, 0x19); CreateServiceFunction(MS_WEATHER_REFRESHALL, UpdateAllRemove); mi.position = 20100002; - mi.hIcolibItem = GetIconHandle("update2"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_UPDATE2); mi.name.a = LPGEN("Remove Old Data then Update All"); mi.pszService = MS_WEATHER_REFRESHALL; Menu_AddMainMenuItem(&mi); @@ -352,7 +352,7 @@ void AddMenuItems(void) SET_UID(mi, 0xdc5411cb, 0xb7c7, 0x443b, 0x88, 0x5a, 0x90, 0x24, 0x43, 0xde, 0x54, 0x3e); CreateServiceFunction(MODULENAME "/PopupMenu", MenuitemNotifyCmd); mi.name.a = LPGEN("Weather Notification"); - mi.hIcolibItem = GetIconHandle("popup"); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_POPUP); mi.position = 0; mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0); mi.pszService = MODULENAME "/PopupMenu"; diff --git a/protocols/YAMN/src/browser/badconnect.cpp b/protocols/YAMN/src/browser/badconnect.cpp index 678eb1f337..86e202d2e6 100644 --- a/protocols/YAMN/src/browser/badconnect.cpp +++ b/protocols/YAMN/src/browser/badconnect.cpp @@ -109,7 +109,7 @@ INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg, UINT msg, WPARAM wParam, LP ShowIco = ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO; if (ShowPopup) { - BadConnectPopup.lchIcon = g_LoadIconEx(3); + BadConnectPopup.lchIcon = g_plugin.getIcon(IDI_BADCONNECT); BadConnectPopup.colorBack = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupB : GetSysColor(COLOR_BTNFACE); BadConnectPopup.colorText = ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopupT : GetSysColor(COLOR_WINDOWTEXT); BadConnectPopup.iSeconds = ActualAccount->BadConnectN.PopupTime; @@ -220,7 +220,7 @@ void __cdecl BadConnection(void *Param) __try { hBadConnect = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DLGBADCONNECT), nullptr, DlgProcYAMNBadConnection, (LPARAM)&MyParam); - Window_SetIcon_IcoLib(hBadConnect, g_GetIconHandle(3)); + Window_SetIcon_IcoLib(hBadConnect, g_plugin.getIconHandle(IDI_BADCONNECT)); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile, "BadConnect:ActualAccountSO-read wait\n"); @@ -244,7 +244,7 @@ void __cdecl BadConnection(void *Param) NOTIFYICONDATA nid = {}; nid.cbSize = sizeof(nid); nid.hWnd = hBadConnect; - nid.hIcon = g_LoadIconEx(3); + nid.hIcon = g_plugin.getIcon(IDI_BADCONNECT); nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uCallbackMessage = WM_YAMN_NOTIFYICON; mir_snwprintf(nid.szTip, L"%S%s", ActualAccount->Name, TranslateT(" - connection error")); diff --git a/protocols/YAMN/src/browser/mailbrowser.cpp b/protocols/YAMN/src/browser/mailbrowser.cpp index 6321141135..b225516021 100644 --- a/protocols/YAMN/src/browser/mailbrowser.cpp +++ b/protocols/YAMN/src/browser/mailbrowser.cpp @@ -497,7 +497,7 @@ int AddNewMailsToListView(HWND hListView, CAccount *ActualAccount, DWORD nflags) POPUPDATAW NewMailPopup = {}; NewMailPopup.lchContact = (ActualAccount->hContact != NULL) ? ActualAccount->hContact : (UINT_PTR)ActualAccount; - NewMailPopup.lchIcon = g_LoadIconEx(2); + NewMailPopup.lchIcon = g_plugin.getIcon(IDI_NEWMAIL); if (nflags & YAMN_ACC_POPC) { NewMailPopup.colorBack = ActualAccount->NewMailN.PopupB; NewMailPopup.colorText = ActualAccount->NewMailN.PopupT; @@ -640,7 +640,7 @@ void DoMailActions(HWND hDlg, CAccount *ActualAccount, struct CMailNumbers *MN, CLISTEVENT evt = {}; evt.flags = CLEF_UNICODE; evt.hContact = ActualAccount->hContact; - evt.hIcon = g_LoadIconEx(2); + evt.hIcon = g_plugin.getIcon(IDI_NEWMAIL); evt.hDbEvent = ActualAccount->hContact; evt.lParam = ActualAccount->hContact; evt.pszService = MS_YAMN_CLISTDBLCLICK; @@ -659,7 +659,7 @@ void DoMailActions(HWND hDlg, CAccount *ActualAccount, struct CMailNumbers *MN, POPUPDATAW NewMailPopup; NewMailPopup.lchContact = (ActualAccount->hContact != NULL) ? ActualAccount->hContact : (UINT_PTR)ActualAccount; - NewMailPopup.lchIcon = g_LoadIconEx(2); + NewMailPopup.lchIcon = g_plugin.getIcon(IDI_NEWMAIL); if (nflags & YAMN_ACC_POPC) { NewMailPopup.colorBack = ActualAccount->NewMailN.PopupB; NewMailPopup.colorText = ActualAccount->NewMailN.PopupT; @@ -701,7 +701,7 @@ void DoMailActions(HWND hDlg, CAccount *ActualAccount, struct CMailNumbers *MN, SendDlgItemMessageW(hDlg, IDC_LISTMAILS, LVM_SCROLL, 0, (LPARAM)0x7ffffff); if ((nflags & YAMN_ACC_ICO) && (MN->Real.SysTrayUC + MN->Virtual.SysTrayUC)) { - nid.hIcon = g_LoadIconEx(2); + nid.hIcon = g_plugin.getIcon(IDI_NEWMAIL); nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uCallbackMessage = WM_YAMN_NOTIFYICON; mir_snwprintf(nid.szTip, L"%S %s", ActualAccount->Name, TranslateT("- new mail message(s)")); @@ -747,7 +747,7 @@ void DoMailActions(HWND hDlg, CAccount *ActualAccount, struct CMailNumbers *MN, POPUPDATAW NoNewMailPopup = {}; NoNewMailPopup.lchContact = (ActualAccount->hContact != NULL) ? ActualAccount->hContact : (UINT_PTR)ActualAccount; - NoNewMailPopup.lchIcon = g_LoadIconEx(1); + NoNewMailPopup.lchIcon = g_plugin.getIcon(IDI_LAUNCHAPP); if (nflags & YAMN_ACC_POPC) { NoNewMailPopup.colorBack = ActualAccount->NoNewMailN.PopupB; NoNewMailPopup.colorText = ActualAccount->NoNewMailN.PopupT; @@ -1261,7 +1261,7 @@ INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg, UINT msg, WPARAM wParam, LPAR HWND hListView = GetDlgItem(hDlg, IDC_LISTHEADERS); mir_subclassWindow(GetDlgItem(hDlg, IDC_SPLITTER), SplitterSubclassProc); SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)MailParam); - Window_SetIcon_IcoLib(hDlg, g_GetIconHandle(2)); + Window_SetIcon_IcoLib(hDlg, g_plugin.getIconHandle(IDI_NEWMAIL)); ListView_SetUnicodeFormat(hListView, TRUE); ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT); @@ -2083,9 +2083,9 @@ INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg, UINT msg, WPARAM wParam, LPAR nid.uID = 0; nid.uFlags = NIF_ICON; if (mwui->TrayIconState == 0) - nid.hIcon = g_LoadIconEx(0); + nid.hIcon = g_plugin.getIcon(IDI_CHECKMAIL); else - nid.hIcon = g_LoadIconEx(2); + nid.hIcon = g_plugin.getIcon(IDI_NEWMAIL); Shell_NotifyIcon(NIM_MODIFY, &nid); mwui->TrayIconState = !mwui->TrayIconState; // UpdateWindow(hDlg); @@ -2320,7 +2320,7 @@ void __cdecl MailBrowser(void *Param) if ((hMailBrowser == nullptr) && ((MyParam.nflags & YAMN_ACC_MSG) || (MyParam.nflags & YAMN_ACC_ICO) || (MyParam.nnflags & YAMN_ACC_MSG))) { hMailBrowser = CreateDialogParamW(g_plugin.getInst(), MAKEINTRESOURCEW(IDD_DLGVIEWMESSAGES), nullptr, DlgProcYAMNMailBrowser, (LPARAM)&MyParam); - Window_SetIcon_IcoLib(hMailBrowser, g_GetIconHandle(2)); + Window_SetIcon_IcoLib(hMailBrowser, g_plugin.getIconHandle(IDI_NEWMAIL)); MoveWindow(hMailBrowser, PosX, PosY, SizeX, SizeY, TRUE); } diff --git a/protocols/YAMN/src/main.cpp b/protocols/YAMN/src/main.cpp index 9bdbf83504..d214f5e982 100644 --- a/protocols/YAMN/src/main.cpp +++ b/protocols/YAMN/src/main.cpp @@ -126,7 +126,7 @@ int SystemModulesLoaded(WPARAM, LPARAM) SET_UID(mi, 0xa01ff3d9, 0x53cb, 0x4406, 0x85, 0xd9, 0xf1, 0x90, 0x3a, 0x94, 0xed, 0xf4); mi.position = 0xb0000000; - mi.hIcolibItem = g_GetIconHandle(0); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_CHECKMAIL); mi.name.a = LPGEN("Check &mail (All Account)"); mi.pszService = MS_YAMN_FORCECHECK; hMenuItemMain = Menu_AddMainMenuItem(&mi); @@ -137,7 +137,7 @@ int SystemModulesLoaded(WPARAM, LPARAM) hMenuItemCont = Menu_AddContactMenuItem(&mi, YAMN_DBMODULE); SET_UID(mi, 0x147c7800, 0x12d0, 0x4209, 0xab, 0xcc, 0xfa, 0x64, 0xc6, 0xb0, 0xa6, 0xeb); - mi.hIcolibItem = g_GetIconHandle(1); + mi.hIcolibItem = g_plugin.getIconHandle(IDI_LAUNCHAPP); mi.name.a = LPGEN("Launch application"); mi.pszService = MS_YAMN_CLISTCONTEXTAPP; hMenuItemContApp = Menu_AddContactMenuItem(&mi, YAMN_DBMODULE); @@ -166,20 +166,6 @@ void LoadIcons() g_plugin.registerIcon("YAMN", iconList); } -HANDLE WINAPI g_GetIconHandle(int idx) -{ - if (idx >= _countof(iconList)) - return nullptr; - return iconList[idx].hIcolib; -} - -HICON WINAPI g_LoadIconEx(int idx, bool big) -{ - if (idx >= _countof(iconList)) - return nullptr; - return IcoLib_GetIcon(iconList[idx].szName, big); -} - static void LoadPlugins() { wchar_t szSearchPath[MAX_PATH]; diff --git a/protocols/YAMN/src/proto/pop3/pop3opt.cpp b/protocols/YAMN/src/proto/pop3/pop3opt.cpp index 83551a631c..4d4993de70 100644 --- a/protocols/YAMN/src/proto/pop3/pop3opt.cpp +++ b/protocols/YAMN/src/proto/pop3/pop3opt.cpp @@ -1248,6 +1248,7 @@ INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg, UINT msg, WPARAM wParam, LPARAM case IDC_RADIOPOP1: Changed = TRUE; break; + case IDC_CPB: case IDC_CPT: case IDC_CPFB: @@ -1256,6 +1257,7 @@ INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg, UINT msg, WPARAM wParam, LPARAM case IDC_CPNT: if (HIWORD(wParam) != CPN_COLOURCHANGED) break; + case IDC_CHECKCOL: case IDC_CHECKFCOL: case IDC_CHECKNCOL: @@ -1269,25 +1271,12 @@ INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg, UINT msg, WPARAM wParam, LPARAM break; case IDC_PREVIEW: - { + if (IsDlgButtonChecked(hDlg, IDC_CHECKPOP) == BST_CHECKED) { POPUPDATAW Tester = {}; - POPUPDATAW TesterF = {}; - POPUPDATAW TesterN = {}; - BOOL TesterC = (IsDlgButtonChecked(hDlg, IDC_CHECKCOL) == BST_CHECKED); - BOOL TesterFC = (IsDlgButtonChecked(hDlg, IDC_CHECKFCOL) == BST_CHECKED); - BOOL TesterNC = (IsDlgButtonChecked(hDlg, IDC_CHECKNCOL) == BST_CHECKED); - - Tester.lchIcon = g_LoadIconEx(2); - TesterF.lchIcon = g_LoadIconEx(3); - TesterN.lchIcon = g_LoadIconEx(1); - + Tester.lchIcon = g_plugin.getIcon(IDI_NEWMAIL); mir_wstrncpy(Tester.lpwzContactName, TranslateT("Account Test"), MAX_CONTACTNAME); - mir_wstrncpy(TesterF.lpwzContactName, TranslateT("Account Test (failed)"), MAX_CONTACTNAME); - mir_wstrncpy(TesterN.lpwzContactName, TranslateT("Account Test"), MAX_CONTACTNAME); mir_wstrncpy(Tester.lpwzText, TranslateT("You have N new mail messages"), MAX_SECONDLINE); - mir_wstrncpy(TesterF.lpwzText, TranslateT("Connection failed message"), MAX_SECONDLINE); - mir_wstrncpy(TesterN.lpwzText, TranslateT("No new mail message"), MAX_SECONDLINE); - if (TesterC) { + if (IsDlgButtonChecked(hDlg, IDC_CHECKCOL) == BST_CHECKED) { Tester.colorBack = SendDlgItemMessage(hDlg, IDC_CPB, CPM_GETCOLOUR, 0, 0); Tester.colorText = SendDlgItemMessage(hDlg, IDC_CPT, CPM_GETCOLOUR, 0, 0); } @@ -1295,7 +1284,14 @@ INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg, UINT msg, WPARAM wParam, LPARAM Tester.colorBack = GetSysColor(COLOR_BTNFACE); Tester.colorText = GetSysColor(COLOR_WINDOWTEXT); } - if (TesterFC) { + PUAddPopupW(&Tester); + } + if (IsDlgButtonChecked(hDlg, IDC_CHECKFPOP) == BST_CHECKED) { + POPUPDATAW TesterF = {}; + TesterF.lchIcon = g_plugin.getIcon(IDI_BADCONNECT); + mir_wstrncpy(TesterF.lpwzContactName, TranslateT("Account Test (failed)"), MAX_CONTACTNAME); + mir_wstrncpy(TesterF.lpwzText, TranslateT("Connection failed message"), MAX_SECONDLINE); + if (IsDlgButtonChecked(hDlg, IDC_CHECKFCOL) == BST_CHECKED) { TesterF.colorBack = SendDlgItemMessage(hDlg, IDC_CPFB, CPM_GETCOLOUR, 0, 0); TesterF.colorText = SendDlgItemMessage(hDlg, IDC_CPFT, CPM_GETCOLOUR, 0, 0); } @@ -1303,7 +1299,14 @@ INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg, UINT msg, WPARAM wParam, LPARAM TesterF.colorBack = GetSysColor(COLOR_BTNFACE); TesterF.colorText = GetSysColor(COLOR_WINDOWTEXT); } - if (TesterNC) { + PUAddPopupW(&TesterF); + } + if (IsDlgButtonChecked(hDlg, IDC_CHECKNPOP) == BST_CHECKED) { + POPUPDATAW TesterN = {}; + TesterN.lchIcon = g_plugin.getIcon(IDI_LAUNCHAPP); + mir_wstrncpy(TesterN.lpwzContactName, TranslateT("Account Test"), MAX_CONTACTNAME); + mir_wstrncpy(TesterN.lpwzText, TranslateT("No new mail message"), MAX_SECONDLINE); + if (IsDlgButtonChecked(hDlg, IDC_CHECKNCOL) == BST_CHECKED) { TesterN.colorBack = SendDlgItemMessage(hDlg, IDC_CPNB, CPM_GETCOLOUR, 0, 0); TesterN.colorText = SendDlgItemMessage(hDlg, IDC_CPNT, CPM_GETCOLOUR, 0, 0); } @@ -1311,25 +1314,15 @@ INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg, UINT msg, WPARAM wParam, LPARAM TesterN.colorBack = GetSysColor(COLOR_BTNFACE); TesterN.colorText = GetSysColor(COLOR_WINDOWTEXT); } - Tester.PluginWindowProc = nullptr; - TesterF.PluginWindowProc = nullptr; - TesterN.PluginWindowProc = nullptr; - Tester.PluginData = nullptr; - TesterF.PluginData = nullptr; - TesterN.PluginData = nullptr; - - if (IsDlgButtonChecked(hDlg, IDC_CHECKPOP) == BST_CHECKED) - PUAddPopupW(&Tester); - if (IsDlgButtonChecked(hDlg, IDC_CHECKFPOP) == BST_CHECKED) - PUAddPopupW(&TesterF); - if (IsDlgButtonChecked(hDlg, IDC_CHECKNPOP) == BST_CHECKED) - PUAddPopupW(&TesterN); - Changed = TRUE; + PUAddPopupW(&TesterN); } + Changed = TRUE; break; + case IDC_CHECKKBN: Changed = TRUE; break; + case IDC_CHECKPOP: Changed = TRUE; EnableWindow(GetDlgItem(hDlg, IDC_CHECKCOL), IsDlgButtonChecked(hDlg, IDC_CHECKPOP) == BST_CHECKED); diff --git a/protocols/YAMN/src/services.cpp b/protocols/YAMN/src/services.cpp index 3ddae133c6..771367d479 100644 --- a/protocols/YAMN/src/services.cpp +++ b/protocols/YAMN/src/services.cpp @@ -44,7 +44,7 @@ static INT_PTR Service_GetName(WPARAM wParam, LPARAM lParam) static INT_PTR Service_LoadIcon(WPARAM wParam, LPARAM) { if (LOWORD(wParam) == PLI_PROTOCOL) - return (INT_PTR)CopyIcon(g_LoadIconEx(0)); // noone cares about other than PLI_PROTOCOL + return (INT_PTR)CopyIcon(g_plugin.getIcon(IDI_CHECKMAIL)); // noone cares about other than PLI_PROTOCOL return (INT_PTR)(HICON)NULL; } @@ -297,7 +297,7 @@ int AddTopToolbarIcon(WPARAM, LPARAM) TTBButton btn = {}; btn.pszService = MS_YAMN_FORCECHECK; btn.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; - btn.hIconHandleUp = btn.hIconHandleDn = g_GetIconHandle(0); + btn.hIconHandleUp = btn.hIconHandleDn = g_plugin.getIconHandle(IDI_CHECKMAIL); btn.name = btn.pszTooltipUp = LPGEN("Check mail"); hTTButton = g_plugin.addTTB(&btn); } diff --git a/protocols/YAMN/src/stdafx.h b/protocols/YAMN/src/stdafx.h index f0919e24b8..44bb1037dd 100644 --- a/protocols/YAMN/src/stdafx.h +++ b/protocols/YAMN/src/stdafx.h @@ -178,9 +178,6 @@ extern HANDLE hTTButton; extern HCURSOR hCurSplitNS, hCurSplitWE; extern UINT SecTimer; -HANDLE WINAPI g_GetIconHandle(int idx); -HICON WINAPI g_LoadIconEx(int idx, bool big = false); - //From synchro.cpp void WINAPI DeleteMessagesToEndFcn(CAccount *Account, HYAMNMAIL From); DWORD WINAPI WaitToWriteFcn(PSWMRG SObject, PSCOUNTER SCounter = nullptr); diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp index ded9c7b1c7..0248407244 100644 --- a/src/core/stdmsg/src/chat_options.cpp +++ b/src/core/stdmsg/src/chat_options.cpp @@ -137,67 +137,52 @@ static INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM p static IconItem iconList1[] = { - { LPGEN("Window icon"), "chat_window", IDI_CHANMGR, 0 }, - { LPGEN("Text color"), "chat_fgcol", IDI_COLOR, 0 }, - { LPGEN("Background color"), "chat_bkgcol", IDI_BKGCOLOR, 0 }, - { LPGEN("Bold"), "chat_bold", IDI_BBOLD, 0 }, - { LPGEN("Italics"), "chat_italics", IDI_BITALICS, 0 }, - { LPGEN("Underlined"), "chat_underline", IDI_BUNDERLINE, 0 }, - { LPGEN("Smiley button"), "chat_smiley", IDI_BSMILEY, 0 }, - { LPGEN("Room history"), "chat_history", IDI_HISTORY, 0 }, - { LPGEN("Room settings"), "chat_settings", IDI_TOPICBUT, 0 }, - { LPGEN("Event filter disabled"), "chat_filter", IDI_FILTER, 0 }, - { LPGEN("Event filter enabled"), "chat_filter2", IDI_FILTER2, 0 }, - { LPGEN("Hide nick list"), "chat_nicklist", IDI_NICKLIST, 0 }, - { LPGEN("Show nick list"), "chat_nicklist2", IDI_NICKLIST2, 0 }, - { LPGEN("Icon overlay"), "chat_overlay", IDI_OVERLAY, 0 }, - { LPGEN("Close"), "chat_close", IDI_CLOSE, 0 }, - - { LPGEN("Status 1 (10x10)"), "chat_status0", IDI_STATUS0, 10 }, - { LPGEN("Status 2 (10x10)"), "chat_status1", IDI_STATUS1, 10 }, - { LPGEN("Status 3 (10x10)"), "chat_status2", IDI_STATUS2, 10 }, - { LPGEN("Status 4 (10x10)"), "chat_status3", IDI_STATUS3, 10 }, - { LPGEN("Status 5 (10x10)"), "chat_status4", IDI_STATUS4, 10 }, - { LPGEN("Status 6 (10x10)"), "chat_status5", IDI_STATUS5, 10 } + { LPGEN("Window icon"), "window", IDI_CHANMGR }, + { LPGEN("Text color"), "fgcol", IDI_COLOR }, + { LPGEN("Background color"), "bkgcol", IDI_BKGCOLOR }, + { LPGEN("Bold"), "bold", IDI_BBOLD }, + { LPGEN("Italics"), "italics", IDI_BITALICS }, + { LPGEN("Underlined"), "underline", IDI_BUNDERLINE }, + { LPGEN("Smiley button"), "smiley", IDI_BSMILEY }, + { LPGEN("Room history"), "history", IDI_HISTORY }, + { LPGEN("Room settings"), "settings", IDI_TOPICBUT }, + { LPGEN("Event filter disabled"), "filter", IDI_FILTER }, + { LPGEN("Event filter enabled"), "filter2", IDI_FILTER2 }, + { LPGEN("Hide nick list"), "nicklist", IDI_NICKLIST }, + { LPGEN("Show nick list"), "nicklist2", IDI_NICKLIST2 }, + { LPGEN("Icon overlay"), "overlay", IDI_OVERLAY }, + { LPGEN("Close"), "close", IDI_CLOSE }, + + { LPGEN("Status 1 (10x10)"), "status0", IDI_STATUS0, 10 }, + { LPGEN("Status 2 (10x10)"), "status1", IDI_STATUS1, 10 }, + { LPGEN("Status 3 (10x10)"), "status2", IDI_STATUS2, 10 }, + { LPGEN("Status 4 (10x10)"), "status3", IDI_STATUS3, 10 }, + { LPGEN("Status 5 (10x10)"), "status4", IDI_STATUS4, 10 }, + { LPGEN("Status 6 (10x10)"), "status5", IDI_STATUS5, 10 } }; static IconItem iconList2[] = { - { LPGEN("Message in (10x10)"), "chat_log_message_in", IDI_MESSAGE, 10 }, - { LPGEN("Message out (10x10)"), "chat_log_message_out", IDI_MESSAGEOUT, 10 }, - { LPGEN("Action (10x10)"), "chat_log_action", IDI_ACTION, 10 }, - { LPGEN("Add status (10x10)"), "chat_log_addstatus", IDI_ADDSTATUS, 10 }, - { LPGEN("Remove status (10x10)"), "chat_log_removestatus", IDI_REMSTATUS, 10 }, - { LPGEN("Join (10x10)"), "chat_log_join", IDI_JOIN, 10 }, - { LPGEN("Leave (10x10)"), "chat_log_part", IDI_PART, 10 }, - { LPGEN("Quit (10x10)"), "chat_log_quit", IDI_QUIT, 10 }, - { LPGEN("Kick (10x10)"), "chat_log_kick", IDI_KICK, 10 }, - { LPGEN("Nick change (10x10)"), "chat_log_nick", IDI_NICK, 10 }, - { LPGEN("Notice (10x10)"), "chat_log_notice", IDI_NOTICE, 10 }, - { LPGEN("Topic (10x10)"), "chat_log_topic", IDI_TOPIC, 10 }, - { LPGEN("Highlight (10x10)"), "chat_log_highlight", IDI_HIGHLIGHT, 10 }, - { LPGEN("Information (10x10)"), "chat_log_info", IDI_INFO, 10 } + { LPGEN("Message in (10x10)"), "log_message_in", IDI_MESSAGE, 10 }, + { LPGEN("Message out (10x10)"), "log_message_out", IDI_MESSAGEOUT, 10 }, + { LPGEN("Action (10x10)"), "log_action", IDI_ACTION, 10 }, + { LPGEN("Add status (10x10)"), "log_addstatus", IDI_ADDSTATUS, 10 }, + { LPGEN("Remove status (10x10)"), "log_removestatus", IDI_REMSTATUS, 10 }, + { LPGEN("Join (10x10)"), "log_join", IDI_JOIN, 10 }, + { LPGEN("Leave (10x10)"), "log_part", IDI_PART, 10 }, + { LPGEN("Quit (10x10)"), "log_quit", IDI_QUIT, 10 }, + { LPGEN("Kick (10x10)"), "log_kick", IDI_KICK, 10 }, + { LPGEN("Nick change (10x10)"), "log_nick", IDI_NICK, 10 }, + { LPGEN("Notice (10x10)"), "log_notice", IDI_NOTICE, 10 }, + { LPGEN("Topic (10x10)"), "log_topic", IDI_TOPIC, 10 }, + { LPGEN("Highlight (10x10)"), "log_highlight", IDI_HIGHLIGHT, 10 }, + { LPGEN("Information (10x10)"), "log_info", IDI_INFO, 10 } }; void AddIcons(void) { - g_plugin.registerIcon(LPGEN("Messaging") "/" LPGEN("Group chats"), iconList1); - g_plugin.registerIcon(LPGEN("Messaging") "/" LPGEN("Group chats log"), iconList2); -} - -// load icons from the skinning module if available -HICON LoadIconEx(const char *pszIcoLibName, bool big) -{ - char szTemp[256]; - mir_snprintf(szTemp, "chat_%s", pszIcoLibName); - return IcoLib_GetIcon(szTemp, big); -} - -HANDLE GetIconHandle(const char *pszIcoLibName) -{ - char szTemp[256]; - mir_snprintf(szTemp, "chat_%s", pszIcoLibName); - return IcoLib_GetIconHandle(szTemp); + g_plugin.registerIcon(LPGEN("Messaging") "/" LPGEN("Group chats"), iconList1, "chat"); + g_plugin.registerIcon(LPGEN("Messaging") "/" LPGEN("Group chats log"), iconList2, "chat"); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 1ea4206a6d..02662b6d9a 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -113,7 +113,7 @@ void CChatRoomDlg::onClick_Filter(CCtrlButton *pButton) return; m_bFilterEnabled = !m_bFilterEnabled; - m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bFilterEnabled ? "filter" : "filter2", FALSE)); + m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(m_bFilterEnabled ? IDI_FILTER : IDI_FILTER2, FALSE)); if (m_bFilterEnabled && db_get_b(0, CHAT_MODULE, "RightClickFilter", 0) == 0) ShowFilterMenu(); else @@ -126,7 +126,7 @@ void CChatRoomDlg::onClick_NickList(CCtrlButton *pButton) return; m_bNicklistEnabled = !m_bNicklistEnabled; - pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bNicklistEnabled ? "nicklist" : "nicklist2", FALSE)); + pButton->SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(m_bNicklistEnabled ? IDI_NICKLIST : IDI_NICKLIST2, FALSE)); ScrollToBottom(); Resize(); @@ -271,8 +271,8 @@ void CChatRoomDlg::UpdateNickList() void CChatRoomDlg::UpdateOptions() { - m_btnNickList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bNicklistEnabled ? "nicklist" : "nicklist2", FALSE)); - m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bFilterEnabled ? "filter" : "filter2", FALSE)); + m_btnNickList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(m_bNicklistEnabled ? IDI_NICKLIST : IDI_NICKLIST2, FALSE)); + m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(m_bFilterEnabled ? IDI_FILTER : IDI_FILTER2, FALSE)); MODULEINFO *mi = m_si->pMI; EnableWindow(m_btnBold.GetHwnd(), mi->bBold); @@ -291,7 +291,7 @@ void CChatRoomDlg::UpdateOptions() SendMessage(m_pOwner->m_hwndStatus, SB_SETICON, 0, (LPARAM)hIcon); - Window_SetIcon_IcoLib(m_pOwner->GetHwnd(), GetIconHandle("window")); + Window_SetIcon_IcoLib(m_pOwner->GetHwnd(), g_plugin.getIconHandle(IDI_CHANMGR)); m_log.SendMsg(EM_SETBKGNDCOLOR, 0, g_Settings.crLogBackground); @@ -1141,7 +1141,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) break; case DM_UPDATETITLE: - if (lParam == 0 || lParam == m_hContact) + if (lParam == 0 || lParam == (LPARAM)m_hContact) UpdateTitle(); break; diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index ac88cf3e9c..84fad84fba 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -387,35 +387,35 @@ int RegisterToolbarIcons(WPARAM, LPARAM) bbd.bbbFlags = BBBF_ISPUSHBUTTON | BBBF_ISCHATBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_SRMM_BOLD; bbd.dwDefPos = 10; - bbd.hIcon = GetIconHandle("bold"); + bbd.hIcon = g_plugin.getIconHandle(IDI_BBOLD); bbd.pwszText = LPGENW("&Bold"); bbd.pwszTooltip = LPGENW("Make the text bold (Ctrl+B)"); Srmm_AddButton(&bbd, &g_plugin); bbd.dwButtonID = IDC_SRMM_ITALICS; bbd.dwDefPos = 15; - bbd.hIcon = GetIconHandle("italics"); + bbd.hIcon = g_plugin.getIconHandle(IDI_BITALICS); bbd.pwszText = LPGENW("&Italic"); bbd.pwszTooltip = LPGENW("Make the text italicized (Ctrl+I)"); Srmm_AddButton(&bbd, &g_plugin); bbd.dwButtonID = IDC_SRMM_UNDERLINE; bbd.dwDefPos = 20; - bbd.hIcon = GetIconHandle("underline"); + bbd.hIcon = g_plugin.getIconHandle(IDI_BUNDERLINE); bbd.pwszText = LPGENW("&Underline"); bbd.pwszTooltip = LPGENW("Make the text underlined (Ctrl+U)"); Srmm_AddButton(&bbd, &g_plugin); bbd.dwButtonID = IDC_SRMM_COLOR; bbd.dwDefPos = 25; - bbd.hIcon = GetIconHandle("fgcol"); + bbd.hIcon = g_plugin.getIconHandle(IDI_COLOR); bbd.pwszText = LPGENW("&Color"); bbd.pwszTooltip = LPGENW("Select a foreground color for the text (Ctrl+K)"); Srmm_AddButton(&bbd, &g_plugin); bbd.dwButtonID = IDC_SRMM_BKGCOLOR; bbd.dwDefPos = 30; - bbd.hIcon = GetIconHandle("bkgcol"); + bbd.hIcon = g_plugin.getIconHandle(IDI_BKGCOLOR); bbd.pwszText = LPGENW("&Background color"); bbd.pwszTooltip = LPGENW("Select a background color for the text (Ctrl+L)"); Srmm_AddButton(&bbd, &g_plugin); @@ -423,21 +423,21 @@ int RegisterToolbarIcons(WPARAM, LPARAM) bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON | BBBF_CREATEBYID; bbd.dwButtonID = IDC_SRMM_CHANMGR; bbd.dwDefPos = 30; - bbd.hIcon = GetIconHandle("settings"); + bbd.hIcon = g_plugin.getIconHandle(IDI_TOPICBUT); bbd.pwszText = LPGENW("&Room settings"); bbd.pwszTooltip = LPGENW("Control this room (Ctrl+O)"); Srmm_AddButton(&bbd, &g_plugin); bbd.dwButtonID = IDC_SRMM_SHOWNICKLIST; bbd.dwDefPos = 20; - bbd.hIcon = GetIconHandle("nicklist"); + bbd.hIcon = g_plugin.getIconHandle(IDI_NICKLIST); bbd.pwszText = LPGENW("&Show/hide nick list"); bbd.pwszTooltip = LPGENW("Show/hide the nick list (Ctrl+N)"); Srmm_AddButton(&bbd, &g_plugin); bbd.dwButtonID = IDC_SRMM_FILTER; bbd.dwDefPos = 10; - bbd.hIcon = GetIconHandle("filter"); + bbd.hIcon = g_plugin.getIconHandle(IDI_FILTER); bbd.pwszText = LPGENW("&Filter"); bbd.pwszTooltip = LPGENW("Enable/disable the event filter (Ctrl+F)"); Srmm_AddButton(&bbd, &g_plugin); diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index 37e5664275..b24778cf89 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -134,8 +134,6 @@ SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si); // options.cpp void AddIcons(void); -HICON LoadIconEx(const char *pszIcoLibName, bool big); -HANDLE GetIconHandle(const char *pszIcolibName); // tools.cpp void SetButtonsPos(HWND hwndDlg, bool bIsChat); diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index f295a01338..a5f12c1c1b 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -279,7 +279,7 @@ void CTabbedWindow::FixTabIcons(CMsgDialog *pDlg) if (g_dat.bUseStatusWinIcon) Window_SetProtoIcon_IcoLib(m_hwnd, pDlg->GetProto(), pDlg->GetStatus()); else if (pDlg->isChat()) - Window_SetIcon_IcoLib(m_hwnd, GetIconHandle("window")); + Window_SetIcon_IcoLib(m_hwnd, g_plugin.getIconHandle(IDI_CHANMGR)); else Window_SetSkinIcon_IcoLib(m_hwnd, SKINICON_EVENT_MESSAGE); } diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp index 062d89471e..3ced1cf459 100644 --- a/src/mir_app/src/CMPluginBase.cpp +++ b/src/mir_app/src/CMPluginBase.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" #include "plugins.h" +#include "IcoLib.h" static int sttFakeID = -100; @@ -111,9 +112,15 @@ EXTERN_C MIR_APP_DLL(void) UnregisterPlugin(CMPluginBase *pPlugin) ///////////////////////////////////////////////////////////////////////////////////////// +static int CompareIcons(const IcolibItem *p1, const IcolibItem *p2) +{ + return p1->default_indx - p2->default_indx; +} + CMPluginBase::CMPluginBase(const char *moduleName, const PLUGININFOEX &pInfo) : m_szModuleName(moduleName), - m_pInfo(pInfo) + m_pInfo(pInfo), + m_arIcons(10, CompareIcons) { if (m_hInst != nullptr) g_arPlugins.insert(this); @@ -272,6 +279,33 @@ void CMPluginBase::debugLogW(LPCWSTR wszFormat, ...) ///////////////////////////////////////////////////////////////////////////////////////// +int CMPluginBase::addImgListIcon(HIMAGELIST himl, int iconId) +{ + HICON hIcon = getIcon(iconId); + int ret = ::ImageList_AddIcon(himl, hIcon); + IcoLib_ReleaseIcon(hIcon); + return ret; +} + +HICON CMPluginBase::getIcon(int iconId, bool big) +{ + return IcoLib_GetIconByHandle(getIconHandle(iconId), big); +} + +HANDLE CMPluginBase::getIconHandle(int iconId) +{ + IcolibItem *p = (IcolibItem*)alloca(sizeof(IcolibItem)); + p->default_indx = -iconId; + return m_arIcons.find(p); +} + +void CMPluginBase::releaseIcon(int iconId, bool big) +{ + IcoLib_ReleaseIcon(getIcon(iconId), big); +} + +///////////////////////////////////////////////////////////////////////////////////////// + void CMPluginBase::RegisterProtocol(int type, pfnInitProto fnInit, pfnUninitProto fnUninit) { if (isPluginBanned(m_pInfo.uuid)) diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp index e56308f232..ed4c445e2a 100644 --- a/src/mir_app/src/clistmod.cpp +++ b/src/mir_app/src/clistmod.cpp @@ -135,7 +135,7 @@ MIR_APP_DLL(int) Clist_GetContactIcon(MCONTACT hContact) static void AddProtoIconIndex(PROTOACCOUNT *pa) { for (auto &it : g_statuses) { - int iImg = ImageList_AddIcon_ProtoIconLibLoaded(hCListImages, pa->szModuleName, it.iStatus); + int iImg = ImageList_AddProtoIcon(hCListImages, pa->szModuleName, it.iStatus); if (it.iStatus == ID_STATUS_OFFLINE) pa->iIconBase = iImg; } diff --git a/src/mir_app/src/descbutton.cpp b/src/mir_app/src/descbutton.cpp index 965024ff65..0e737c2d33 100644 --- a/src/mir_app/src/descbutton.cpp +++ b/src/mir_app/src/descbutton.cpp @@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" #include "m_descbutton.h" -extern HINSTANCE hInst; - //////////////////////////////////////////////////////////////////////////////////// // Internals diff --git a/src/mir_app/src/ei_baseIcon.cpp b/src/mir_app/src/ei_baseIcon.cpp index bc60215be9..0cca055e09 100644 --- a/src/mir_app/src/ei_baseIcon.cpp +++ b/src/mir_app/src/ei_baseIcon.cpp @@ -23,13 +23,16 @@ Boston, MA 02111-1307, USA. #include "extraicons.h" -BaseExtraIcon::BaseExtraIcon(const char *name, const wchar_t *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param) : +BaseExtraIcon::BaseExtraIcon(const char *name, const wchar_t *description, HANDLE descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param) : ExtraIcon(name), m_OnClick(OnClick), m_onClickParam(param), m_tszDescription(mir_wstrdup(description)), - m_szDescIcon(mir_strdup(descIcon)) + m_hDescIcon(descIcon) { + if (!IcoLib_IsManaged((HICON)descIcon)) + m_hDescIcon = IcoLib_GetIconHandle((const char *)descIcon); + m_id = registeredExtraIcons.getCount() + 1; } @@ -48,19 +51,9 @@ const wchar_t* BaseExtraIcon::getDescription() const return TranslateW_LP(m_tszDescription, m_pPlugin); } -void BaseExtraIcon::setDescription(const wchar_t *desc) -{ - m_tszDescription = mir_wstrdup(desc); -} - -const char* BaseExtraIcon::getDescIcon() const -{ - return m_szDescIcon; -} - -void BaseExtraIcon::setDescIcon(const char *icon) +HANDLE BaseExtraIcon::getDescIcon() const { - m_szDescIcon = mir_strdup(icon); + return m_hDescIcon; } void BaseExtraIcon::onClick(MCONTACT hContact) diff --git a/src/mir_app/src/ei_callbackIcon.cpp b/src/mir_app/src/ei_callbackIcon.cpp index 262ccc347d..2eb223c121 100644 --- a/src/mir_app/src/ei_callbackIcon.cpp +++ b/src/mir_app/src/ei_callbackIcon.cpp @@ -23,7 +23,7 @@ Boston, MA 02111-1307, USA. #include "extraicons.h" -CallbackExtraIcon::CallbackExtraIcon(const char *_name, const wchar_t *_description, const char *_descIcon, +CallbackExtraIcon::CallbackExtraIcon(const char *_name, const wchar_t *_description, HANDLE _descIcon, MIRANDAHOOK _RebuildIcons, MIRANDAHOOK _ApplyIcon, MIRANDAHOOKPARAM _OnClick, LPARAM _param) : BaseExtraIcon(_name, _description, _descIcon, _OnClick, _param), m_pfnRebuildIcons(_RebuildIcons), m_pfnApplyIcon(_ApplyIcon), m_needToRebuild(true) diff --git a/src/mir_app/src/ei_defaulticons.cpp b/src/mir_app/src/ei_defaulticons.cpp index 39cb7c273a..300e36bcdd 100644 --- a/src/mir_app/src/ei_defaulticons.cpp +++ b/src/mir_app/src/ei_defaulticons.cpp @@ -290,17 +290,17 @@ static int ProtocolOnClick(WPARAM wParam, LPARAM, LPARAM) void DefaultExtraIcons_Load() { hExtraChat = ExtraIcon_RegisterIcolib("chat_activity", LPGEN("Chat activity"), "ChatActivity"); - hExtraVisibility = ExtraIcon_RegisterIcolib("visibility", "Visibility", Skin_GetIconName(SKINICON_OTHER_VISIBLE_ALL)); + hExtraVisibility = ExtraIcon_RegisterIcolib("visibility", "Visibility", Skin_GetIconHandle(SKINICON_OTHER_VISIBLE_ALL)); hExtraGender = ExtraIcon_RegisterIcolib("gender", "Gender", "gender_male", nullptr, 0, EIF_DISABLED_BY_DEFAULT); - hExtraProto = ExtraIcon_RegisterCallback("protocol", "Account", Skin_GetIconName(SKINICON_OTHER_ACCMGR), + hExtraProto = ExtraIcon_RegisterCallback("protocol", "Account", Skin_GetIconHandle(SKINICON_OTHER_ACCMGR), &ProtocolRebuildIcons, &ProtocolApplyIcon, &ProtocolOnClick, 0, EIF_DISABLED_BY_DEFAULT); for (auto &p : infos) { p.hIcolib = Skin_GetIconHandle(p.iSkinIcon); if (p.OnClick) - p.hExtraIcon = ExtraIcon_RegisterIcolib(p.name, p.desc, Skin_GetIconName(p.iSkinIcon), DefaultOnClick, (LPARAM)&p, p.flags); + p.hExtraIcon = ExtraIcon_RegisterIcolib(p.name, p.desc, Skin_GetIconHandle(p.iSkinIcon), DefaultOnClick, (LPARAM)&p, p.flags); else - p.hExtraIcon = ExtraIcon_RegisterIcolib(p.name, p.desc, Skin_GetIconName(p.iSkinIcon), nullptr, 0, p.flags); + p.hExtraIcon = ExtraIcon_RegisterIcolib(p.name, p.desc, Skin_GetIconHandle(p.iSkinIcon), nullptr, 0, p.flags); } for (auto &hContact : Contacts()) { diff --git a/src/mir_app/src/ei_groupIcon.cpp b/src/mir_app/src/ei_groupIcon.cpp index fffea046f7..0f1313d297 100644 --- a/src/mir_app/src/ei_groupIcon.cpp +++ b/src/mir_app/src/ei_groupIcon.cpp @@ -177,13 +177,13 @@ const wchar_t* ExtraIconGroup::getDescription() const return m_tszDescription; } -const char *ExtraIconGroup::getDescIcon() const +HANDLE ExtraIconGroup::getDescIcon() const { for (auto &p : m_items) - if (!IsEmpty(p->getDescIcon())) - return p->getDescIcon(); + if (HANDLE ret = p->getDescIcon()) + return ret; - return ""; + return nullptr; } int ExtraIconGroup::getType() const diff --git a/src/mir_app/src/ei_icolibIcon.cpp b/src/mir_app/src/ei_icolibIcon.cpp index df9b33da05..bdb3b16125 100644 --- a/src/mir_app/src/ei_icolibIcon.cpp +++ b/src/mir_app/src/ei_icolibIcon.cpp @@ -26,7 +26,7 @@ Boston, MA 02111-1307, USA. #include "IcoLib.h" -IcolibExtraIcon::IcolibExtraIcon(const char *_name, const wchar_t *_description, const char *_descIcon, MIRANDAHOOKPARAM _OnClick, LPARAM _param) : +IcolibExtraIcon::IcolibExtraIcon(const char *_name, const wchar_t *_description, HANDLE _descIcon, MIRANDAHOOKPARAM _OnClick, LPARAM _param) : BaseExtraIcon(_name, _description, _descIcon, _OnClick, _param) { db_set_resident(EI_MODULE_NAME, _name); diff --git a/src/mir_app/src/ei_options.cpp b/src/mir_app/src/ei_options.cpp index 64137ece40..12621029be 100644 --- a/src/mir_app/src/ei_options.cpp +++ b/src/mir_app/src/ei_options.cpp @@ -117,7 +117,7 @@ class CExtraIconOptsDlg : public CDlgBase BaseExtraIcon *extra = registeredExtraIcons[group.data[i] - 1]; ids->add(extra->getID()); - if (img == 0 && !IsEmpty(extra->getDescIcon())) + if (img == 0 && extra->getDescIcon() != nullptr) img = extra->getID(); if (i > 0) @@ -414,23 +414,20 @@ public: void BuildIconList() { HIMAGELIST hImageList = ImageList_Create(g_iIconSX, g_iIconSX, ILC_COLOR32 | ILC_MASK, 2, 2); - - HICON hBlankIcon = (HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, g_iIconSX, g_iIconSX, 0); - ImageList_AddIcon(hImageList, hBlankIcon); + ImageList_AddIcon_NotShared(hImageList, MAKEINTRESOURCE(IDI_BLANK)); for (auto &extra : registeredExtraIcons) { extra->setID(registeredExtraIcons.indexOf(&extra)+1); - HICON hIcon = IcoLib_GetIcon(extra->getDescIcon()); + HICON hIcon = IcoLib_GetIconByHandle(extra->getDescIcon()); if (hIcon == nullptr) - ImageList_AddIcon(hImageList, hBlankIcon); + ImageList_AddIcon_NotShared(hImageList, MAKEINTRESOURCE(IDI_BLANK)); else { ImageList_AddIcon(hImageList, hIcon); IcoLib_ReleaseIcon(hIcon); } } m_tree.SetImageList(hImageList, TVSIL_NORMAL); - DestroyIcon(hBlankIcon); for (auto &extra : extraIconsBySlot) { if (extra->getType() == EXTRAICON_TYPE_GROUP) { diff --git a/src/mir_app/src/ei_services.cpp b/src/mir_app/src/ei_services.cpp index 65cab195c6..ab09af39ca 100644 --- a/src/mir_app/src/ei_services.cpp +++ b/src/mir_app/src/ei_services.cpp @@ -350,9 +350,8 @@ static void EI_PostCreate(BaseExtraIcon *extra, const char *name, int flags) } } -EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallback(const char *name, const char *description, const char *descIcon, - MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, - MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int flags) +EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallback(const char *name, const char *description, HANDLE descIcon, + MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int flags) { // EXTRAICON_TYPE_CALLBACK if (IsEmpty(name) || IsEmpty(description)) @@ -367,14 +366,13 @@ EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallback(const char *name, const ptrW tszDesc(mir_a2u(description)); - BaseExtraIcon *extra = new CallbackExtraIcon(name, tszDesc, descIcon == nullptr ? "" : descIcon, RebuildIcons, ApplyIcon, OnClick, onClickParam); + BaseExtraIcon *extra = new CallbackExtraIcon(name, tszDesc, descIcon, RebuildIcons, ApplyIcon, OnClick, onClickParam); extra->m_pPlugin = &GetPluginByInstance(GetInstByAddress(RebuildIcons)); EI_PostCreate(extra, name, flags); return extra; } -EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, const char *descIcon, - MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int flags) +EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, HANDLE descIcon, MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int flags) { if (IsEmpty(name) || IsEmpty(description)) return nullptr; @@ -387,7 +385,7 @@ EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const ch return nullptr; // Found one, now merge it - if (!IsEmpty(descIcon)) + if (descIcon) extra->setDescIcon(descIcon); if (OnClick != nullptr) @@ -401,7 +399,7 @@ EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const ch } } else { - extra = new IcolibExtraIcon(name, tszDesc, descIcon == nullptr ? "" : descIcon, OnClick, onClickParam); + extra = new IcolibExtraIcon(name, tszDesc, descIcon, OnClick, onClickParam); extra->m_pPlugin = &GetPluginByInstance(GetInstByAddress((void*)name)); EI_PostCreate(extra, name, flags); } diff --git a/src/mir_app/src/extraicons.h b/src/mir_app/src/extraicons.h index 9c72dc3bad..67838ebdf0 100644 --- a/src/mir_app/src/extraicons.h +++ b/src/mir_app/src/extraicons.h @@ -60,7 +60,7 @@ public: virtual const char *getName() const; virtual const wchar_t *getDescription() const = 0; - virtual const char *getDescIcon() const = 0; + virtual HANDLE getDescIcon() const = 0; virtual int getType() const = 0; virtual int getSlot() const; @@ -91,13 +91,19 @@ protected: class BaseExtraIcon : public ExtraIcon { public: - BaseExtraIcon(const char *name, const wchar_t *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param); + BaseExtraIcon(const char *name, const wchar_t *description, HANDLE descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param); virtual ~BaseExtraIcon(); virtual const wchar_t* getDescription() const; - virtual void setDescription(const wchar_t *desc); - virtual const char* getDescIcon() const; - virtual void setDescIcon(const char *icon); + virtual void setDescription(const wchar_t *desc) { + m_tszDescription = mir_wstrdup(desc); + } + + virtual HANDLE getDescIcon() const; + void setDescIcon(HANDLE icon) { + m_hDescIcon = icon; + } + virtual int getType() const = 0; virtual void onClick(MCONTACT hContact); @@ -107,7 +113,7 @@ public: protected: ptrW m_tszDescription; - ptrA m_szDescIcon; + HANDLE m_hDescIcon; MIRANDAHOOKPARAM m_OnClick; LPARAM m_onClickParam; }; @@ -118,7 +124,7 @@ protected: class CallbackExtraIcon : public BaseExtraIcon { public: - CallbackExtraIcon(const char *name, const wchar_t *description, const char *descIcon, + CallbackExtraIcon(const char *name, const wchar_t *description, HANDLE descIcon, MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick, LPARAM param); virtual ~CallbackExtraIcon(); @@ -143,7 +149,7 @@ private: class IcolibExtraIcon : public BaseExtraIcon { public: - IcolibExtraIcon(const char *name, const wchar_t *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param); + IcolibExtraIcon(const char *name, const wchar_t *description, HANDLE descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param); virtual ~IcolibExtraIcon(); virtual int getType() const; @@ -175,7 +181,7 @@ public: virtual int setIconByName(MCONTACT hContact, const char *icon); virtual const wchar_t* getDescription() const; - virtual const char* getDescIcon() const; + virtual HANDLE getDescIcon() const; virtual int getType() const; virtual int getPosition() const; diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp index fdd69d0ef4..aca9b86624 100644 --- a/src/mir_app/src/findadd.cpp +++ b/src/mir_app/src/findadd.cpp @@ -390,7 +390,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetTextExtentPoint32(hdc, cbei.pszText, (int)mir_wstrlen(cbei.pszText), &textSize); if (textSize.cx > cbwidth) cbwidth = textSize.cx; - cbei.iImage = cbei.iSelectedImage = ImageList_AddIcon_IconLibLoaded(dat->himlComboIcons, SKINICON_OTHER_SEARCHALL); + cbei.iImage = cbei.iSelectedImage = ImageList_AddSkinIcon(dat->himlComboIcons, SKINICON_OTHER_SEARCHALL); cbei.lParam = 0; SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CBEM_INSERTITEM, 0, (LPARAM)&cbei); cbei.iItem++; diff --git a/src/mir_app/src/headerbar.cpp b/src/mir_app/src/headerbar.cpp index 1257f67144..d317b789ed 100644 --- a/src/mir_app/src/headerbar.cpp +++ b/src/mir_app/src/headerbar.cpp @@ -24,9 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "stdafx.h" -#include "m_iconheader.h" - -extern HINSTANCE hInst; static BOOL IsAeroMode() { @@ -42,8 +39,6 @@ static BOOL IsVSMode() //////////////////////////////////////////////////////////////////////////////////// // Internals -static LRESULT CALLBACK MHeaderbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - // structure is used for storing list of tab info struct MHeaderbarCtrl : public MZeroedObject { @@ -68,19 +63,6 @@ struct MHeaderbarCtrl : public MZeroedObject HFONT hFont; }; -int LoadHeaderbarModule() -{ - WNDCLASSEX wc = { 0 }; - wc.cbSize = sizeof(wc); - wc.lpszClassName = L"MHeaderbarCtrl"; - wc.lpfnWndProc = MHeaderbarWndProc; - wc.hCursor = LoadCursor(nullptr, IDC_ARROW); - wc.cbWndExtra = sizeof(MHeaderbarCtrl*); - wc.style = CS_GLOBALCLASS|CS_SAVEBITS; - RegisterClassEx(&wc); - return 0; -} - static void MHeaderbar_SetupColors(MHeaderbarCtrl *dat) { COLORREF cl = GetSysColor(COLOR_WINDOW); @@ -342,3 +324,16 @@ static LRESULT CALLBACK MHeaderbarWndProc(HWND hwndDlg, UINT msg, WPARAM wParam } return DefWindowProc(hwndDlg, msg, wParam, lParam); } + +int LoadHeaderbarModule() +{ + WNDCLASSEX wc = { 0 }; + wc.cbSize = sizeof(wc); + wc.lpszClassName = L"MHeaderbarCtrl"; + wc.lpfnWndProc = MHeaderbarWndProc; + wc.hCursor = LoadCursor(nullptr, IDC_ARROW); + wc.cbWndExtra = sizeof(MHeaderbarCtrl*); + wc.style = CS_GLOBALCLASS | CS_SAVEBITS; + RegisterClassEx(&wc); + return 0; +} diff --git a/src/mir_app/src/hotkey_opts.cpp b/src/mir_app/src/hotkey_opts.cpp index ac1e2b23c4..58d07e1e5c 100644 --- a/src/mir_app/src/hotkey_opts.cpp +++ b/src/mir_app/src/hotkey_opts.cpp @@ -472,14 +472,14 @@ static INT_PTR CALLBACK sttOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, Hotkey_Subclass(GetDlgItem(hwndDlg, IDC_HOTKEY)); { HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 3, 1); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOWS); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_MIRANDA); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_WINDOW); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ADDCONTACT); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_DELETE); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNDO); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPOPEN); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_GROUPSHUT); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_WINDOWS); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_MIRANDA); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_WINDOW); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_ADDCONTACT); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_DELETE); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_UNDO); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_GROUPOPEN); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_GROUPSHUT); ListView_SetImageList(hwndHotkey, hIml, LVSIL_SMALL); } ListView_SetExtendedListViewStyle(hwndHotkey, LVS_EX_CHECKBOXES | LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP); diff --git a/src/mir_app/src/icolib.cpp b/src/mir_app/src/icolib.cpp index e8605688c4..6069202925 100644 --- a/src/mir_app/src/icolib.cpp +++ b/src/mir_app/src/icolib.cpp @@ -522,6 +522,9 @@ MIR_APP_DLL(HANDLE) IcoLib_AddIcon(const SKINICONDESC *sid, HPLUGIN pPlugin) if (item->section) item->section->flags = sid->flags & SIDF_SORTED; + if (pPlugin && item->default_indx) + ((CMPluginBase*)pPlugin)->addIcolib(item); + return item; } diff --git a/src/mir_app/src/iconheader.cpp b/src/mir_app/src/iconheader.cpp deleted file mode 100644 index 4ded67b2d9..0000000000 --- a/src/mir_app/src/iconheader.cpp +++ /dev/null @@ -1,525 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (C) 2012-19 Miranda NG team (https://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -Copyright (c) 2007 Artem Shpynov -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "stdafx.h" -#include "m_iconheader.h" - -extern HINSTANCE hInst; - -static BOOL IsAeroMode() -{ - BOOL result; - return dwmIsCompositionEnabled && (dwmIsCompositionEnabled(&result) == S_OK) && result; -} - -static BOOL IsVSMode() -{ - return IsWinVerVistaPlus() && IsThemeActive(); -} - -//////////////////////////////////////////////////////////////////////////////////// -// Internals - -#define ITC_BORDER_SIZE 3 - -// structure is used for storing list of tab info -struct MIcoTabCtrl : public MZeroedObject -{ - MIcoTabCtrl() : pList(1) {} - - HWND hwnd; - int nSelectedIdx, nHotIdx; - LIST pList; - - // UI info - BOOL bMouseInside; - RECT rc; - int width, height; - int itemWidth, itemHeight; - - //background bitmap - HBITMAP hBkgBmp; - HBITMAP hBkgOldBmp; - HDC hBkgDC; - SIZE BkgSize; - - // control colors - RGBQUAD rgbBkgTop, rgbBkgBottom; - RGBQUAD rgbSelTop, rgbSelBottom; - RGBQUAD rgbHotTop, rgbHotBottom; - COLORREF clText; - COLORREF clSelText, clSelBorder; - COLORREF clHotText, clHotBorder; - - // fonts - HFONT hFont; -}; - -typedef void (*ItemDestuctor)(void*); - -static void MITListDestructor(void * adr) -{ - MIcoTab *mit = (MIcoTab *)adr; - mir_free(mit->tcsName); - if (mit->hIcon && !(mit->flag&MITCF_SHAREDICON)) - DestroyIcon(mit->hIcon); - mir_free(adr); -} - -void li_ListDestruct(LIST &pList, ItemDestuctor pItemDestructor) -{ - for (auto &p : pList) - pItemDestructor(p); - pList.destroy(); -} - -static void MIcoTab_SetupColors(MIcoTabCtrl *dat) -{ - COLORREF cl = GetSysColor(COLOR_WINDOW); - dat->rgbBkgBottom.rgbRed = (dat->rgbBkgTop.rgbRed = GetRValue(cl)) * .95; - dat->rgbBkgBottom.rgbGreen = (dat->rgbBkgTop.rgbGreen = GetGValue(cl)) * .95; - dat->rgbBkgBottom.rgbBlue = (dat->rgbBkgTop.rgbBlue = GetBValue(cl)) * .95; - - cl = GetSysColor(COLOR_HIGHLIGHT); - dat->rgbSelTop.rgbRed = (dat->rgbSelBottom.rgbRed = GetRValue(cl)) * .75; - dat->rgbSelTop.rgbGreen = (dat->rgbSelBottom.rgbGreen = GetGValue(cl)) * .75; - dat->rgbSelTop.rgbBlue = (dat->rgbSelBottom.rgbBlue = GetBValue(cl)) * .75; - - dat->rgbHotTop.rgbRed = (dat->rgbSelTop.rgbRed + 255) / 2; - dat->rgbHotTop.rgbGreen = (dat->rgbSelTop.rgbGreen + 255) / 2; - dat->rgbHotTop.rgbBlue = (dat->rgbSelTop.rgbBlue + 255) / 2; - - dat->rgbHotBottom.rgbRed = (dat->rgbSelBottom.rgbRed + 255) / 2; - dat->rgbHotBottom.rgbGreen = (dat->rgbSelBottom.rgbGreen + 255) / 2; - dat->rgbHotBottom.rgbBlue = (dat->rgbSelBottom.rgbBlue + 255) / 2; - - dat->clText = GetSysColor(COLOR_WINDOWTEXT); - dat->clSelText = GetSysColor(COLOR_HIGHLIGHTTEXT); - dat->clSelBorder = RGB(dat->rgbSelTop.rgbRed, dat->rgbSelTop.rgbGreen, dat->rgbSelTop.rgbBlue); - dat->clHotBorder = RGB(dat->rgbHotTop.rgbRed, dat->rgbHotTop.rgbGreen, dat->rgbHotTop.rgbBlue); - - if (!dat->hFont) - dat->hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); -} - -static void MIcoTab_FillRect(HDC hdc, int x, int y, int width, int height, COLORREF cl) -{ - int oldMode = SetBkMode(hdc, OPAQUE); - COLORREF oldColor = SetBkColor(hdc, cl); - - RECT rc; SetRect(&rc, x, y, x + width, y + height); - ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, "", 0, nullptr); - - SetBkMode(hdc, oldMode); - SetBkColor(hdc, oldColor); -} - -static void MIcoTab_DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1) -{ - int oldMode = SetBkMode(hdc, OPAQUE); - COLORREF oldColor = SetBkColor(hdc, 0); - - RECT rc; - SetRect(&rc, x, 0, x + width, 0); - - for (int i = y + height; --i >= y;) { - COLORREF color = RGB( - ((height - i - 1)*rgb0->rgbRed + i*rgb1->rgbRed) / height, - ((height - i - 1)*rgb0->rgbGreen + i*rgb1->rgbGreen) / height, - ((height - i - 1)*rgb0->rgbBlue + i*rgb1->rgbBlue) / height); - rc.top = rc.bottom = i; - ++rc.bottom; - SetBkColor(hdc, color); - ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, "", 0, nullptr); - } - - SetBkMode(hdc, oldMode); - SetBkColor(hdc, oldColor); -} - -static void MIcoTab_DrawItem(HWND hwnd, HDC hdc, MIcoTabCtrl *dat, MIcoTab *tab, int i) -{ - int iTopSpace = IsAeroMode() ? 0 : ITC_BORDER_SIZE; - int itemX = ITC_BORDER_SIZE + dat->itemWidth * i; - int iconTop = iTopSpace + 5; - int textTop = iconTop + 32 + 3; - - HFONT hFntSave = nullptr; - - if (dat->nSelectedIdx == i) { - LOGFONT lf; - GetObject(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf); - lf.lfWeight = FW_BOLD; - hFntSave = (HFONT)SelectObject(hdc, CreateFontIndirect(&lf)); - - if (IsVSMode()) { - RECT rc; - rc.left = itemX; - rc.top = iTopSpace; - rc.right = itemX + dat->itemWidth; - rc.bottom = iTopSpace + dat->itemHeight; - HANDLE hTheme = OpenThemeData(hwnd, L"ListView"); - if (dat->nHotIdx == i || GetFocus() == hwnd) - DrawThemeBackground(hTheme, hdc, LVP_LISTITEM, LISS_HOTSELECTED, &rc, nullptr); - else - DrawThemeBackground(hTheme, hdc, LVP_LISTITEM, LISS_SELECTED, &rc, nullptr); - - CloseThemeData(hTheme); - } - else { - MIcoTab_FillRect(hdc, itemX, ITC_BORDER_SIZE, dat->itemWidth, dat->itemHeight, dat->clSelBorder); - MIcoTab_DrawGradient(hdc, itemX + 1, ITC_BORDER_SIZE + 1, dat->itemWidth - 2, dat->itemHeight - 2, &dat->rgbSelTop, &dat->rgbSelBottom); - } - SetTextColor(hdc, dat->clSelText); - } - else if (dat->nHotIdx == i) { - if (IsVSMode()) { - RECT rc; - rc.left = itemX; - rc.top = iTopSpace; - rc.right = itemX + dat->itemWidth; - rc.bottom = iTopSpace + dat->itemHeight; - SetWindowTheme(hwnd, L"explorer", nullptr); - HANDLE hTheme = OpenThemeData(hwnd, L"ListView"); - DrawThemeBackground(hTheme, hdc, LVP_LISTITEM, LISS_HOT, &rc, nullptr); - CloseThemeData(hTheme); - } - else { - MIcoTab_FillRect(hdc, itemX, ITC_BORDER_SIZE, dat->itemWidth, dat->itemHeight, dat->clHotBorder); - MIcoTab_DrawGradient(hdc, itemX + 1, ITC_BORDER_SIZE + 1, dat->itemWidth - 2, dat->itemHeight - 2, &dat->rgbHotTop, &dat->rgbHotBottom); - } - SetTextColor(hdc, dat->clHotText); - } - else SetTextColor(hdc, dat->clText); - - RECT textRect; - textRect.left = itemX; - textRect.right = itemX + dat->itemWidth; - textRect.top = textTop; - textRect.bottom = iconTop + dat->itemHeight; - DrawIcon(hdc, itemX + dat->itemWidth / 2 - 16, iconTop, tab->hIcon); - - if (IsVSMode()) { - DTTOPTS dto = { 0 }; - dto.dwSize = sizeof(dto); - dto.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE; - dto.iGlowSize = 10; - HANDLE hTheme = OpenThemeData(hwnd, L"Window"); - drawThemeTextEx(hTheme, hdc, WP_CAPTION, CS_ACTIVE, tab->tcsName, -1, DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS, &textRect, &dto); - CloseThemeData(hTheme); - } - else DrawText(hdc, tab->tcsName, -1, &textRect, DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS); - - if (hFntSave) - DeleteObject(SelectObject(hdc, hFntSave)); -} - -static LRESULT MIcoTab_OnPaint(HWND hwndDlg, MIcoTabCtrl *mit) -{ - PAINTSTRUCT ps; - - HDC hdc = BeginPaint(hwndDlg, &ps); - HDC tempDC = CreateCompatibleDC(hdc); - - BITMAPINFO bmi = { 0 }; - bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi.bmiHeader.biWidth = mit->width; - bmi.bmiHeader.biHeight = -mit->height; // we need this for DrawThemeTextEx - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = 32; - bmi.bmiHeader.biCompression = BI_RGB; - HBITMAP hBmp = CreateDIBSection(tempDC, &bmi, DIB_RGB_COLORS, nullptr, nullptr, 0); - - HBITMAP hOldBmp = (HBITMAP)SelectObject(tempDC, hBmp); - - if (IsAeroMode()) { - RECT temprc; - temprc.left = 0; - temprc.right = mit->width; - temprc.top = 0; - temprc.bottom = mit->width; - FillRect(tempDC, &temprc, (HBRUSH)GetStockObject(BLACK_BRUSH)); - } - else { - if (mit->hBkgBmp) - StretchBlt(tempDC, 0, 0, mit->width, mit->height, mit->hBkgDC, 0, 0, mit->BkgSize.cx, mit->BkgSize.cy, SRCCOPY); - else { - if (IsVSMode()) - MIcoTab_FillRect(tempDC, 0, 0, mit->width, mit->height, GetSysColor(COLOR_WINDOW)); - else - MIcoTab_DrawGradient(tempDC, 0, 0, mit->width, mit->height, &mit->rgbBkgTop, &mit->rgbBkgBottom); - - MIcoTab_FillRect(tempDC, 0, mit->height - 2, mit->width, 1, GetSysColor(COLOR_BTNSHADOW)); - MIcoTab_FillRect(tempDC, 0, mit->height - 1, mit->width, 1, GetSysColor(COLOR_BTNHIGHLIGHT)); - } - } - - //Draw Items - HFONT hFont = mit->hFont; - HFONT hOldFont = (HFONT)SelectObject(tempDC, hFont); - SetBkMode(tempDC, TRANSPARENT); - - for (int i = 0; i < mit->pList.getCount(); i++) - MIcoTab_DrawItem(hwndDlg, tempDC, mit, mit->pList[i], i); - - //Copy to output - BitBlt(hdc, mit->rc.left, mit->rc.top, mit->width, mit->height, tempDC, 0, 0, SRCCOPY); - SelectObject(tempDC, hOldBmp); - DeleteObject(hBmp); - SelectObject(tempDC, hOldFont); - DeleteDC(tempDC); - - EndPaint(hwndDlg, &ps); - - return TRUE; -} - -static LRESULT CALLBACK MIcoTabWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - MIcoTabCtrl* itc = (MIcoTabCtrl *)GetWindowLongPtr(hwndDlg, 0); - switch (uMsg) { - case WM_NCCREATE: - itc = new MIcoTabCtrl; //(MIcoTabCtrl*)mir_alloc(sizeof(MIcoTabCtrl)); - itc->nSelectedIdx = -1; - itc->nHotIdx = -1; - itc->bMouseInside = FALSE; - SetWindowLongPtr(hwndDlg, 0, (LONG_PTR)itc); - MIcoTab_SetupColors(itc); - - if (IsAeroMode()) { - RECT rc; - GetWindowRect(hwndDlg, &rc); - - MARGINS margins = { 0, 0, rc.bottom - rc.top, 0 }; - dwmExtendFrameIntoClientArea(GetParent(hwndDlg), &margins); - } - - return TRUE; - - case WM_SETFONT: - itc->hFont = (HFONT)wParam; - break; - - case WM_SIZE: - GetClientRect(hwndDlg, &itc->rc); - itc->width = itc->rc.right - itc->rc.left; - itc->height = itc->rc.bottom - itc->rc.top; - - if (itc->pList.getCount()) { - itc->itemWidth = (itc->width - 2 * ITC_BORDER_SIZE) / itc->pList.getCount(); - itc->itemHeight = itc->height - 2 * ITC_BORDER_SIZE - 2; - } - else itc->itemWidth = itc->itemHeight = 0; - return TRUE; - - case WM_THEMECHANGED: - case WM_STYLECHANGED: - MIcoTab_SetupColors(itc); - return TRUE; - - case WM_MOUSEMOVE: - if (!itc->bMouseInside) { - TRACKMOUSEEVENT tme = { 0 }; - tme.cbSize = sizeof(tme); - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = hwndDlg; - _TrackMouseEvent(&tme); - itc->bMouseInside = TRUE; - } - - itc->nHotIdx = -1; - if (itc->itemWidth != 0) { - int idx = (LOWORD(lParam) - ITC_BORDER_SIZE) / itc->itemWidth; - if (idx >= itc->pList.getCount()) - itc->nHotIdx = idx; - } - RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE); - return 0; - - case WM_MOUSELEAVE: - itc->bMouseInside = FALSE; - itc->nHotIdx = -1; - RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE); - return 0; - - case WM_LBUTTONUP: - if ((itc->nHotIdx >= 0) && (itc->nHotIdx != itc->nSelectedIdx)) { - itc->nSelectedIdx = itc->nHotIdx; - SetWindowText(hwndDlg, itc->pList[itc->nSelectedIdx]->tcsName); - RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE); - SendMessage(GetParent(hwndDlg), WM_COMMAND, - MAKEWPARAM(GetWindowLongPtr(hwndDlg, GWL_ID), ITCN_SELCHANGED), - itc->nSelectedIdx); - } - return 0; - - case WM_SETFOCUS: - case WM_KILLFOCUS: - RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE); - break; - - case WM_MOUSEACTIVATE: - SetFocus(hwndDlg); - return MA_ACTIVATE; - - case WM_GETDLGCODE: - if (lParam) { - MSG *msg = (MSG *)lParam; - if (msg->message == WM_KEYDOWN) { - if (msg->wParam == VK_TAB) - return 0; - if (msg->wParam == VK_ESCAPE) - return 0; - } - else if (msg->message == WM_CHAR) { - if (msg->wParam == '\t') - return 0; - if (msg->wParam == 27) - return 0; - } - } - return DLGC_WANTMESSAGE; - - case WM_KEYDOWN: - { - int newIdx = itc->nSelectedIdx; - switch (wParam) { - case VK_NEXT: - case VK_RIGHT: - newIdx++; - break; - case VK_PRIOR: - case VK_LEFT: - newIdx--; - break; - } - if (newIdx >= 0 && newIdx < itc->pList.getCount() && newIdx != itc->nSelectedIdx) { - itc->nSelectedIdx = newIdx; - SetWindowText(hwndDlg, itc->pList[itc->nSelectedIdx]->tcsName); - RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE); - SendMessage(GetParent(hwndDlg), WM_COMMAND, - MAKEWPARAM(GetWindowLongPtr(hwndDlg, GWL_ID), ITCN_SELCHANGEDKBD), - itc->nSelectedIdx); - } - } - return 0; - - case WM_ERASEBKGND: - return 1; - - case WM_NCPAINT: - InvalidateRect(hwndDlg, nullptr, FALSE); - break; - - case WM_PAINT: - MIcoTab_OnPaint(hwndDlg, itc); - break; - - case ITCM_SETBACKGROUND: - itc->hBkgBmp = (HBITMAP)lParam; - if (!itc->hBkgDC) - itc->hBkgDC = CreateCompatibleDC(nullptr); - itc->hBkgOldBmp = (HBITMAP)SelectObject(itc->hBkgDC, itc->hBkgBmp); - { - BITMAPINFO bmp; - GetObject(itc->hBkgBmp, sizeof(bmp), &bmp); - itc->BkgSize.cx = bmp.bmiHeader.biWidth; - itc->BkgSize.cy = bmp.bmiHeader.biHeight; - } - return TRUE; - - case ITCM_ADDITEM: - { - MIcoTab* pMit = (MIcoTab *)wParam; - if (!pMit) - return FALSE; - - MIcoTab* pListMit = (MIcoTab *)mir_calloc(sizeof(MIcoTab)); - pListMit->flag = pMit->flag; - pListMit->data = pMit->data; - if (pMit->flag & MITCF_UNICODE) - pListMit->tcsName = mir_wstrdup(pMit->lpwzName); - else - pListMit->tcsName = mir_a2u(pMit->lpzName); - if (pMit->hIcon) { - if (pListMit->flag&MITCF_SHAREDICON) - pListMit->hIcon = pMit->hIcon; - else - pListMit->hIcon = CopyIcon(pMit->hIcon); - } - itc->pList.insert(pListMit); - - itc->itemWidth = (itc->width - 2 * ITC_BORDER_SIZE) / itc->pList.getCount(); - itc->itemHeight = itc->height - 2 * ITC_BORDER_SIZE - 2; - - RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE); - } - return TRUE; - - case ITCM_SETSEL: - if ((int)wParam >= 0 && (int)wParam < itc->pList.getCount()) { - itc->nSelectedIdx = wParam; - SetWindowText(hwndDlg, itc->pList[itc->nSelectedIdx]->tcsName); - RedrawWindow(hwndDlg, nullptr, nullptr, RDW_INVALIDATE); - SendMessage(GetParent(hwndDlg), WM_COMMAND, - MAKEWPARAM(GetWindowLongPtr(hwndDlg, GWL_ID), ITCN_SELCHANGED), - itc->nSelectedIdx); - } - return TRUE; - - case ITCM_GETSEL: - return itc->nSelectedIdx; - - case ITCM_GETITEMDATA: - if ((int)wParam >= 0 && (int)wParam < itc->pList.getCount()) - return ((MIcoTab *)itc->pList[wParam])->data; - return 0; - - case WM_DESTROY: - if (itc->hBkgDC) { - SelectObject(itc->hBkgDC, itc->hBkgOldBmp); - DeleteDC(itc->hBkgDC); - } - li_ListDestruct(itc->pList, MITListDestructor); - delete itc; - return TRUE; - } - return DefWindowProc(hwndDlg, uMsg, wParam, lParam); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int LoadIcoTabsModule() -{ - WNDCLASSEX wc = {}; - wc.cbSize = sizeof(wc); - wc.lpszClassName = MIRANDAICOTABCLASS; - wc.lpfnWndProc = MIcoTabWndProc; - wc.hCursor = LoadCursor(nullptr, IDC_ARROW); - wc.cbWndExtra = sizeof(MIcoTabCtrl*); - wc.style = CS_GLOBALCLASS; - RegisterClassEx(&wc); - return 0; -} diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp index 10ee55d64e..82a3772d17 100644 --- a/src/mir_app/src/ignore.cpp +++ b/src/mir_app/src/ignore.cpp @@ -208,14 +208,14 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM TranslateDialogDefault(hwndDlg); { HIMAGELIST hIml = ImageList_Create(g_iIconSX, g_iIconSY, ILC_COLOR32 | ILC_MASK, 3 + IGNOREEVENT_MAX, 3 + IGNOREEVENT_MAX); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_SMALLDOT); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_FILLEDBLOB); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_EMPTYBLOB); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_EVENT_MESSAGE); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_EVENT_FILE); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_USERONLINE); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_AUTH_REQUEST); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_TYPING); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_SMALLDOT); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_FILLEDBLOB); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_EMPTYBLOB); + ImageList_AddSkinIcon(hIml, SKINICON_EVENT_MESSAGE); + ImageList_AddSkinIcon(hIml, SKINICON_EVENT_FILE); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_USERONLINE); + ImageList_AddSkinIcon(hIml, SKINICON_AUTH_REQUEST); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_TYPING); SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); for (int i = 0; i < _countof(hIcons); i++) diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp index b2328884d0..56681136af 100644 --- a/src/mir_app/src/menu_utils.cpp +++ b/src/mir_app/src/menu_utils.cpp @@ -1240,7 +1240,7 @@ static int MO_RegisterIcon(TMO_IntMenuItem *pmi, void*) sid.pszName = iconame; sid.description.w = descr; sid.hDefaultIcon = hIcon; - pmi->hIcolibItem = IcoLib_AddIcon(&sid, 0); + pmi->hIcolibItem = IcoLib_AddIcon(&sid, pmi->mi.pPlugin); Safe_DestroyIcon(hIcon); if (hIcon = IcoLib_GetIcon(iconame)) { diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index b99133764f..c04d269389 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -14,7 +14,7 @@ IcoLib_GetIconHandle @12 IcoLib_IsManaged @13 IcoLib_ReleaseIcon @14 Window_FreeIcon_IcoLib @15 -Window_SetSkinIcon_IcoLib @16 +Window_SetSkinIcon_IcoLib @16 Window_SetProtoIcon_IcoLib @17 ProtoServiceExists @18 mir_main @19 @@ -22,7 +22,6 @@ IcoLib_RemoveIcon @20 IcoLib_RemoveIconByHandle @21 IcoLib_Release @22 IcoLib_AddRef @23 -Skin_GetIconName @24 ??0CProtoIntDlgBase@@QAE@ABV0@@Z @25 NONAME ??0CProtoIntDlgBase@@QAE@PAUPROTO_INTERFACE@@H@Z @26 NONAME ??0PROTO_INTERFACE@@QAE@ABU0@@Z @27 NONAME @@ -675,3 +674,10 @@ Popup_Add @764 Popup_Change @765 Skin_GetProtoIcon @766 Srmm_SetIconFlags @767 +?addIcolib@CMPluginBase@@QAEXPAX@Z @768 NONAME +?getIcon@CMPluginBase@@QAEPAUHICON__@@H_N@Z @769 NONAME +?getIconHandle@CMPluginBase@@QAEPAXH@Z @770 NONAME +?releaseIcon@CMPluginBase@@QAEXH_N@Z @771 NONAME +?addImgListIcon@CMPluginBase@@QAEHPAU_IMAGELIST@@H@Z @772 NONAME +ImageList_AddProtoIcon @773 +ImageList_AddSkinIcon @774 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 9b8928ccae..06c417483d 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -14,7 +14,7 @@ IcoLib_GetIconHandle @12 IcoLib_IsManaged @13 IcoLib_ReleaseIcon @14 Window_FreeIcon_IcoLib @15 -Window_SetSkinIcon_IcoLib @16 +Window_SetSkinIcon_IcoLib @16 Window_SetProtoIcon_IcoLib @17 ProtoServiceExists @18 mir_main @19 @@ -22,7 +22,6 @@ IcoLib_RemoveIcon @20 IcoLib_RemoveIconByHandle @21 IcoLib_Release @22 IcoLib_AddRef @23 -Skin_GetIconName @24 ??0CProtoIntDlgBase@@QEAA@AEBV0@@Z @25 NONAME ??0CProtoIntDlgBase@@QEAA@PEAUPROTO_INTERFACE@@H@Z @26 NONAME ??0PROTO_INTERFACE@@QEAA@AEBU0@@Z @27 NONAME @@ -675,3 +674,10 @@ Popup_Add @764 Popup_Change @765 Skin_GetProtoIcon @766 Srmm_SetIconFlags @767 +?addIcolib@CMPluginBase@@QEAAXPEAX@Z @768 NONAME +?getIcon@CMPluginBase@@QEAAPEAUHICON__@@H_N@Z @769 NONAME +?getIconHandle@CMPluginBase@@QEAAPEAXH@Z @770 NONAME +?releaseIcon@CMPluginBase@@QEAAXH_N@Z @771 NONAME +?addImgListIcon@CMPluginBase@@QEAAHPEAU_IMAGELIST@@H@Z @772 NONAME +ImageList_AddProtoIcon @773 +ImageList_AddSkinIcon @774 diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index 0a737d81c7..cd25f39443 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -103,10 +103,7 @@ extern int g_iIconX, g_iIconY, g_iIconSX, g_iIconSY; HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpIconName, BOOL bShared); int ImageList_AddIcon_NotShared(HIMAGELIST hIml, LPCTSTR szResource); -int ImageList_ReplaceIcon_NotShared(HIMAGELIST hIml, int iIndex, HINSTANCE hInstance, LPCTSTR szResource); -int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId); -int ImageList_AddIcon_ProtoIconLibLoaded(HIMAGELIST hIml, const char *szProto, int iconId); int ImageList_ReplaceIcon_IconLibLoaded(HIMAGELIST hIml, int nIndex, HICON hIcon); #define Safe_DestroyIcon(hIcon) if (hIcon) DestroyIcon(hIcon) diff --git a/src/mir_app/src/modules.cpp b/src/mir_app/src/modules.cpp index 1f66b311f5..8bc7678013 100644 --- a/src/mir_app/src/modules.cpp +++ b/src/mir_app/src/modules.cpp @@ -76,7 +76,6 @@ void UnloadSkinHotkeys(void); void UnloadSrmmModule(void); void UnloadUtilsModule(void); -int LoadIcoTabsModule(); int LoadHeaderbarModule(); int LoadDescButtonModule(); @@ -87,7 +86,6 @@ int LoadDefaultModules(void) if (LoadLangPackModule()) return 1; // langpack will be a system module in the new order so this is moved here if (CheckRestart()) return 1; if (LoadUtilsModule()) return 1; - if (LoadIcoTabsModule()) return 1; if (LoadHeaderbarModule()) return 1; if (LoadDbintfModule()) return 1; diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp index 4164f19ecc..72014fb9b7 100644 --- a/src/mir_app/src/newplugins.cpp +++ b/src/mir_app/src/newplugins.cpp @@ -528,11 +528,11 @@ static bool loadClistModule(wchar_t *exe, pluginEntry *p) // now all core skin icons are loaded via icon lib. so lets release them for (auto &it : g_statuses) - ImageList_AddIcon_IconLibLoaded(hCListImages, it.iSkinIcon); + ImageList_AddSkinIcon(hCListImages, it.iSkinIcon); // see IMAGE_GROUP... in clist.h if you add more images above here - ImageList_AddIcon_IconLibLoaded(hCListImages, SKINICON_OTHER_GROUPOPEN); - ImageList_AddIcon_IconLibLoaded(hCListImages, SKINICON_OTHER_GROUPSHUT); + ImageList_AddSkinIcon(hCListImages, SKINICON_OTHER_GROUPOPEN); + ImageList_AddSkinIcon(hCListImages, SKINICON_OTHER_GROUPSHUT); if (p->load() == 0) { p->bLoaded = true; diff --git a/src/mir_app/src/pluginopts.cpp b/src/mir_app/src/pluginopts.cpp index d7248a08b4..226fe9a9b2 100644 --- a/src/mir_app/src/pluginopts.cpp +++ b/src/mir_app/src/pluginopts.cpp @@ -290,8 +290,8 @@ public: bool OnInitDialog() override { HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ANSI); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_UNICODE); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_ANSI); m_plugList.SetImageList(hIml, LVSIL_SMALL); LVCOLUMN col; diff --git a/src/mir_app/src/skinicons.cpp b/src/mir_app/src/skinicons.cpp index 8daff88fa2..5c5c4b5a2b 100644 --- a/src/mir_app/src/skinicons.cpp +++ b/src/mir_app/src/skinicons.cpp @@ -159,7 +159,7 @@ int ImageList_AddIcon_NotShared(HIMAGELIST hIml, LPCTSTR szResource) return res; } -int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId) +MIR_APP_DLL(int) ImageList_AddSkinIcon(HIMAGELIST hIml, int iconId) { HICON hIcon = Skin_LoadIcon(iconId); int res = ImageList_AddIcon(hIml, hIcon); @@ -167,7 +167,7 @@ int ImageList_AddIcon_IconLibLoaded(HIMAGELIST hIml, int iconId) return res; } -int ImageList_AddIcon_ProtoIconLibLoaded(HIMAGELIST hIml, const char *szProto, int iconId) +MIR_APP_DLL(int) ImageList_AddProtoIcon(HIMAGELIST hIml, const char *szProto, int iconId) { HICON hIcon = Skin_LoadProtoIcon(szProto, iconId); int res = ImageList_AddIcon(hIml, hIcon); @@ -175,14 +175,6 @@ int ImageList_AddIcon_ProtoIconLibLoaded(HIMAGELIST hIml, const char *szProto, i return res; } -int ImageList_ReplaceIcon_NotShared(HIMAGELIST hIml, int iIndex, HINSTANCE hInstance, LPCTSTR szResource) -{ - HICON hTempIcon = LoadIconEx(hInstance, szResource, 0); - int res = ImageList_ReplaceIcon(hIml, iIndex, hTempIcon); - Safe_DestroyIcon(hTempIcon); - return res; -} - int ImageList_ReplaceIcon_IconLibLoaded(HIMAGELIST hIml, int nIndex, HICON hIcon) { int res = ImageList_ReplaceIcon(hIml, nIndex, hIcon); @@ -357,19 +349,6 @@ MIR_APP_DLL(HANDLE) Skin_GetIconHandle(int idx) return nullptr; } -MIR_APP_DLL(char*) Skin_GetIconName(int idx) -{ - static char szIconName[100]; - - for (int i = 0; i < _countof(mainIcons); i++) { - if (idx == mainIcons[i].id) { - mir_snprintf(szIconName, "%s%d", mainIconsFmt, i); - return szIconName; - } - } - return nullptr; -} - MIR_APP_DLL(HICON) Skin_LoadIcon(int idx, bool big) { // Query for global status icons diff --git a/src/mir_app/src/visibility.cpp b/src/mir_app/src/visibility.cpp index e4bc479b61..f3a36df1de 100644 --- a/src/mir_app/src/visibility.cpp +++ b/src/mir_app/src/visibility.cpp @@ -139,9 +139,9 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP TranslateDialogDefault(hwndDlg); hIml = ImageList_Create(g_iIconSX, g_iIconSY, ILC_COLOR32 | ILC_MASK, 3, 3); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_SMALLDOT); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_VISIBLE_ALL); - ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_INVISIBLE_ALL); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_SMALLDOT); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_VISIBLE_ALL); + ImageList_AddSkinIcon(hIml, SKINICON_OTHER_INVISIBLE_ALL); SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml); hVisibleIcon = ImageList_GetIcon(hIml, 1, ILD_NORMAL); SendDlgItemMessage(hwndDlg, IDC_VISIBLEICON, STM_SETICON, (WPARAM)hVisibleIcon, 0); -- cgit v1.2.3