summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-26 16:50:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-26 16:50:14 +0000
commitc992cb2fdc11f1cac4bc5cbce26e8e2bb3b57da0 (patch)
tree697bdbf38a8a1f6b828a8bfbd08a478e19a82c6b
parentf616294363c642d138f9dc0ef6eceae639e2434c (diff)
- microkernel addded;
- version bumped to 0.92.2 git-svn-id: http://svn.miranda-ng.org/main/trunk@641 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--bin10/build.no2
-rw-r--r--bin10/lib/Miranda32.libbin0 -> 1984 bytes
-rw-r--r--bin10/lib/mir_core.libbin0 -> 21918 bytes
-rw-r--r--bin10/lib/mir_core64.libbin0 -> 20132 bytes
-rw-r--r--bin10/mir_full.sln22
-rw-r--r--bin10/miranda32.sln10
-rw-r--r--include/m_core.h396
-rw-r--r--include/m_langpack.h99
-rw-r--r--include/m_protomod.h2
-rw-r--r--include/m_protosvc.h2
-rw-r--r--include/m_system.h102
-rw-r--r--include/m_system_cpp.h106
-rw-r--r--include/m_utils.h62
-rw-r--r--include/newpluginapi.h60
-rw-r--r--plugins/BasicHistory/zip/iowin32.c4
-rw-r--r--plugins/Chat/chat.h1
-rw-r--r--plugins/Chat/options.cpp1
-rw-r--r--plugins/Clist_classic/clistopts.cpp4
-rw-r--r--plugins/Clist_modern/modern_aniavatars.cpp22
-rw-r--r--plugins/Clist_modern/modern_cachefuncs.cpp20
-rw-r--r--plugins/Clist_modern/modern_clc.cpp2
-rw-r--r--plugins/Clist_modern/modern_clcitems.cpp4
-rw-r--r--plugins/Clist_modern/modern_clcmsgs.cpp6
-rw-r--r--plugins/Clist_modern/modern_clistsettings.cpp10
-rw-r--r--plugins/Clist_modern/modern_commonheaders.cpp6
-rw-r--r--plugins/Clist_modern/modern_skinengine.cpp40
-rw-r--r--plugins/Clist_modern/modern_toolbar.cpp20
-rw-r--r--plugins/Clist_modern/modern_xptheme.cpp10
-rw-r--r--plugins/Clist_mw/clc.cpp2
-rw-r--r--plugins/Clist_mw/clcidents.cpp8
-rw-r--r--plugins/Clist_mw/clistsettings.cpp6
-rw-r--r--plugins/Clist_nicer/INCLUDE/clc.h3
-rw-r--r--plugins/Clist_nicer/SRC/clc.cpp4
-rw-r--r--plugins/ContactsPlus/utils.cpp12
-rw-r--r--plugins/Db3x/dbcontacts.cpp18
-rw-r--r--plugins/Db3x/dbsettings.cpp22
-rw-r--r--plugins/Db3x_mmap/dbcontacts.cpp14
-rw-r--r--plugins/Db3x_mmap/dbmodulechain.cpp16
-rw-r--r--plugins/Db3x_mmap/dbsettings.cpp28
-rw-r--r--plugins/Db_autobackups/headers.h8
-rw-r--r--plugins/Db_autobackups/options.cpp1
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/dbtool.h17
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters3
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/encryption.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/finished.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/langpack.cpp388
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/main.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/openerror.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/progress.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/utf.cpp376
-rw-r--r--plugins/Dbx_mmap_SA/Dbtool/wizard.cpp5
-rw-r--r--plugins/Dbx_mmap_SA/commonheaders.h3
-rw-r--r--plugins/Dbx_mmap_SA/dialogs.cpp2
-rw-r--r--plugins/IEView/HTMLBuilder.cpp8
-rw-r--r--plugins/IEView/ieview_main.cpp1
-rw-r--r--plugins/LangMan/common.h4
-rw-r--r--plugins/LangMan/options.cpp2
-rw-r--r--plugins/MirOTR/libgcrypt-1.4.6/cipher/cipher.c8
-rw-r--r--plugins/Popup/src/main.cpp1
-rw-r--r--plugins/SRMM/cmdlist.cpp14
-rw-r--r--plugins/SRMM/msgdialog.cpp2
-rw-r--r--plugins/SRMM/richutil.cpp10
-rw-r--r--plugins/Scriver/msglog.cpp2
-rw-r--r--plugins/Scriver/richutil.cpp10
-rw-r--r--plugins/Scriver/utils.cpp2
-rw-r--r--plugins/SmileyAdd/regexp/WCPattern.cpp2
-rw-r--r--plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters3
-rw-r--r--plugins/Svc_dbepp/exportimport.cpp13
-rw-r--r--plugins/Svc_dbepp/headers.h3
-rw-r--r--plugins/Svc_dbepp/watchedvars.cpp47
-rw-r--r--plugins/TabSRMM/chat/message.cpp2
-rw-r--r--plugins/TabSRMM/chat/tools.cpp4
-rw-r--r--plugins/TabSRMM/include/mim.h18
-rw-r--r--plugins/TabSRMM/src/buttonsbar.cpp32
-rw-r--r--plugins/TabSRMM/src/globals.cpp2
-rw-r--r--plugins/TabSRMM/src/infopanel.cpp2
-rw-r--r--plugins/TabSRMM/src/mim.cpp42
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp8
-rw-r--r--plugins/TabSRMM/src/sendlater.cpp6
-rw-r--r--plugins/TabSRMM/src/sendqueue.cpp8
-rw-r--r--plugins/TabSRMM/src/srmm.cpp2
-rw-r--r--plugins/TabSRMM/src/themeio.cpp12
-rw-r--r--plugins/TabSRMM/src/utils.cpp2
-rw-r--r--plugins/TipperYM/mir_smileys.cpp12
-rw-r--r--plugins/UserInfoEx/classMTime.cpp5
-rw-r--r--plugins/UserInfoEx/commonheaders.cpp1
-rw-r--r--plugins/UserInfoEx/init.cpp1
-rw-r--r--plugins/Variables/tokenregister.cpp10
-rw-r--r--plugins/helpers/gen_helpers.cpp134
-rw-r--r--plugins/helpers/gen_helpers.h4
-rw-r--r--plugins/mir_core/commonheaders.cpp2
-rw-r--r--plugins/mir_core/commonheaders.h63
-rw-r--r--plugins/mir_core/langpack.cpp630
-rw-r--r--plugins/mir_core/lists.cpp278
-rw-r--r--plugins/mir_core/memory.cpp280
-rw-r--r--plugins/mir_core/mir_core.def5
-rw-r--r--plugins/mir_core/mir_core_10.vcxproj218
-rw-r--r--plugins/mir_core/mir_core_10.vcxproj.filters64
-rw-r--r--plugins/mir_core/miranda.cpp398
-rw-r--r--plugins/mir_core/miranda.h131
-rw-r--r--plugins/mir_core/modules.cpp644
-rw-r--r--plugins/mir_core/path.cpp210
-rw-r--r--plugins/mir_core/timezones.cpp224
-rw-r--r--plugins/mir_core/utf.cpp406
-rw-r--r--plugins/mir_core/utils.cpp150
-rw-r--r--protocols/Gadu-Gadu/gg.c14
-rw-r--r--protocols/IRCG/irc.h1
-rw-r--r--protocols/IRCG/tools.cpp12
-rw-r--r--protocols/IcqOscarJ/init.cpp3
-rw-r--r--protocols/JabberG/jabber.h2
-rw-r--r--protocols/JabberG/jabber_chat.cpp2
-rw-r--r--protocols/JabberG/jabber_libstr.cpp26
-rw-r--r--protocols/JabberG/jabber_menu.cpp36
-rw-r--r--protocols/JabberG/jabber_thread.cpp4
-rw-r--r--protocols/MSN/msn_chat.cpp2
-rw-r--r--protocols/MSN/msn_global.h12
-rw-r--r--protocols/MSN/msn_libstr.cpp45
-rw-r--r--protocols/MSN/msn_mail.cpp2
-rw-r--r--src/core/commonheaders.h5
-rw-r--r--src/core/miranda.cpp396
-rw-r--r--src/core/miranda.h109
-rw-r--r--src/core/modules.cpp632
-rw-r--r--src/miranda32_10.vcxproj.filters27
-rw-r--r--src/modules/addcontact/addcontact.cpp14
-rw-r--r--src/modules/autoaway/autoaway.cpp4
-rw-r--r--src/modules/button/button.cpp2
-rw-r--r--src/modules/clist/clc.cpp4
-rw-r--r--src/modules/clist/clcfiledrop.cpp2
-rw-r--r--src/modules/clist/clistmenus.cpp22
-rw-r--r--src/modules/clist/clistmod.cpp2
-rw-r--r--src/modules/clist/clisttray.cpp22
-rw-r--r--src/modules/clist/clui.cpp10
-rw-r--r--src/modules/clist/cluiservices.cpp2
-rw-r--r--src/modules/clist/genmenu.cpp2
-rw-r--r--src/modules/clist/genmenuopt.cpp2
-rw-r--r--src/modules/contacts/contacts.cpp12
-rw-r--r--src/modules/database/database.cpp6
-rw-r--r--src/modules/database/dbini.cpp27
-rw-r--r--src/modules/database/dbutils.cpp2
-rw-r--r--src/modules/database/profilemanager.cpp12
-rw-r--r--src/modules/findadd/findadd.cpp38
-rw-r--r--src/modules/findadd/searchresults.cpp14
-rw-r--r--src/modules/fonts/FontOptions.cpp14
-rw-r--r--src/modules/fonts/FontService.h6
-rw-r--r--src/modules/fonts/services.cpp38
-rw-r--r--src/modules/help/about.cpp6
-rw-r--r--src/modules/help/help.cpp2
-rw-r--r--src/modules/history/history.cpp6
-rw-r--r--src/modules/icolib/IcoLib.h2
-rw-r--r--src/modules/icolib/skin2icons.cpp6
-rw-r--r--src/modules/icolib/skin2opts.cpp10
-rw-r--r--src/modules/idle/idle.cpp4
-rw-r--r--src/modules/ignore/ignore.cpp8
-rw-r--r--src/modules/langpack/lpservices.cpp143
-rw-r--r--src/modules/netlib/netliblog.cpp22
-rw-r--r--src/modules/netlib/netlibopts.cpp2
-rw-r--r--src/modules/netlib/netlibsock.cpp11
-rw-r--r--src/modules/options/descbutton.cpp2
-rw-r--r--src/modules/options/filter.cpp2
-rw-r--r--src/modules/options/filter.h5
-rw-r--r--src/modules/options/headerbar.cpp2
-rw-r--r--src/modules/options/iconheader.cpp2
-rw-r--r--src/modules/options/options.cpp18
-rw-r--r--src/modules/plugins/newplugins.cpp98
-rw-r--r--src/modules/plugins/pluginopts.cpp2
-rw-r--r--src/modules/plugins/plugins.h2
-rw-r--r--src/modules/protocols/protoaccs.cpp6
-rw-r--r--src/modules/protocols/protochains.cpp4
-rw-r--r--src/modules/protocols/protocols.cpp381
-rw-r--r--src/modules/protocols/protoopts.cpp10
-rw-r--r--src/modules/skin/hotkey_opts.cpp2
-rw-r--r--src/modules/skin/hotkeys.cpp4
-rw-r--r--src/modules/skin/skin.h4
-rw-r--r--src/modules/skin/skinicons.cpp8
-rw-r--r--src/modules/skin/sounds.cpp14
-rw-r--r--src/modules/srauth/auth.cpp4
-rw-r--r--src/modules/srauth/authdialogs.cpp16
-rw-r--r--src/modules/srawaymsg/awaymsg.cpp6
-rw-r--r--src/modules/srawaymsg/sendmsg.cpp20
-rw-r--r--src/modules/srfile/file.cpp14
-rw-r--r--src/modules/srfile/fileexistsdlg.cpp2
-rw-r--r--src/modules/srfile/fileopts.cpp2
-rw-r--r--src/modules/srfile/filerecvdlg.cpp2
-rw-r--r--src/modules/srfile/filesenddlg.cpp2
-rw-r--r--src/modules/srfile/filexferdlg.cpp16
-rw-r--r--src/modules/srfile/ftmanager.cpp8
-rw-r--r--src/modules/srurl/url.cpp6
-rw-r--r--src/modules/srurl/urldialogs.cpp6
-rw-r--r--src/modules/updatenotify/updatenotify.cpp6
-rw-r--r--src/modules/userinfo/contactinfo.cpp6
-rw-r--r--src/modules/userinfo/stdinfo.cpp8
-rw-r--r--src/modules/userinfo/userinfo.cpp4
-rw-r--r--src/modules/utils/bmpfilter.cpp4
-rw-r--r--src/modules/utils/colourpicker.cpp4
-rw-r--r--src/modules/utils/hyperlink.cpp2
-rw-r--r--src/modules/utils/path.cpp205
-rw-r--r--src/modules/utils/timezones.cpp6
-rw-r--r--src/modules/utils/utils.cpp94
-rw-r--r--src/modules/visibility/visibility.cpp4
-rw-r--r--tools/dbtool/cleaning.cpp2
-rw-r--r--tools/dbtool/dbtool.h19
-rw-r--r--tools/dbtool/dbtool_10.vcxproj.filters3
-rw-r--r--tools/dbtool/eventchain.cpp2
-rw-r--r--tools/dbtool/fileaccess.cpp2
-rw-r--r--tools/dbtool/finished.cpp2
-rw-r--r--tools/dbtool/main.cpp4
-rw-r--r--tools/dbtool/openerror.cpp2
-rw-r--r--tools/dbtool/progress.cpp2
-rw-r--r--tools/dbtool/selectdb.cpp2
-rw-r--r--tools/dbtool/utf.cpp376
-rw-r--r--tools/dbtool/wizard.cpp5
215 files changed, 5052 insertions, 4300 deletions
diff --git a/bin10/build.no b/bin10/build.no
index 20a401d944..f6407facc9 100644
--- a/bin10/build.no
+++ b/bin10/build.no
@@ -1 +1 @@
-0 92 1 \ No newline at end of file
+0 92 2 \ No newline at end of file
diff --git a/bin10/lib/Miranda32.lib b/bin10/lib/Miranda32.lib
new file mode 100644
index 0000000000..310b8f690e
--- /dev/null
+++ b/bin10/lib/Miranda32.lib
Binary files differ
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib
new file mode 100644
index 0000000000..7a238b682c
--- /dev/null
+++ b/bin10/lib/mir_core.lib
Binary files differ
diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib
new file mode 100644
index 0000000000..c22d8a8c42
--- /dev/null
+++ b/bin10/lib/mir_core64.lib
Binary files differ
diff --git a/bin10/mir_full.sln b/bin10/mir_full.sln
index 5cf24ea8ab..fb30934085 100644
--- a/bin10/mir_full.sln
+++ b/bin10/mir_full.sln
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+# Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AVS", "..\plugins\AVS\avs_10.vcxproj", "{7711F563-6473-4ABD-B5E3-477CE8384AD6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chat", "..\plugins\Chat\chat_10.vcxproj", "{268BD296-8DD3-4715-A386-CF120398EC98}"
@@ -330,6 +330,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Clist_classic", "..\plugins
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NewEventNotify", "..\plugins\NewEventNotify\neweventnotify.vcxproj", "{2E0A2793-94C3-82E7-2AB0-FD421816CFBF}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mir_core", "..\plugins\mir_core\mir_core_10.vcxproj", "{D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -1052,12 +1054,10 @@ Global
{576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|x64.Build.0 = Release|x64
{4C1CE389-7129-45FC-83C2-E9C310AC0427}.Debug|Win32.ActiveCfg = Debug|Win32
{4C1CE389-7129-45FC-83C2-E9C310AC0427}.Debug|Win32.Build.0 = Debug|Win32
- {4C1CE389-7129-45FC-83C2-E9C310AC0427}.Debug|x64.ActiveCfg = Debug|x64
- {4C1CE389-7129-45FC-83C2-E9C310AC0427}.Debug|x64.Build.0 = Debug|x64
+ {4C1CE389-7129-45FC-83C2-E9C310AC0427}.Debug|x64.ActiveCfg = Debug|Win32
{4C1CE389-7129-45FC-83C2-E9C310AC0427}.Release|Win32.ActiveCfg = Release|Win32
{4C1CE389-7129-45FC-83C2-E9C310AC0427}.Release|Win32.Build.0 = Release|Win32
- {4C1CE389-7129-45FC-83C2-E9C310AC0427}.Release|x64.ActiveCfg = Release|x64
- {4C1CE389-7129-45FC-83C2-E9C310AC0427}.Release|x64.Build.0 = Release|x64
+ {4C1CE389-7129-45FC-83C2-E9C310AC0427}.Release|x64.ActiveCfg = Release|Win32
{5DB86086-10E9-42E7-AC90-503D2678C2A2}.Debug|Win32.ActiveCfg = Debug|Win32
{5DB86086-10E9-42E7-AC90-503D2678C2A2}.Debug|Win32.Build.0 = Debug|Win32
{5DB86086-10E9-42E7-AC90-503D2678C2A2}.Debug|x64.ActiveCfg = Debug|x64
@@ -1632,12 +1632,10 @@ Global
{1423FC8F-AA52-4562-8275-4BF0838CA378}.Release|x64.Build.0 = Release|x64
{53F841E8-284F-4545-9176-B131896E43F8}.Debug|Win32.ActiveCfg = Debug|Win32
{53F841E8-284F-4545-9176-B131896E43F8}.Debug|Win32.Build.0 = Debug|Win32
- {53F841E8-284F-4545-9176-B131896E43F8}.Debug|x64.ActiveCfg = Debug|x64
- {53F841E8-284F-4545-9176-B131896E43F8}.Debug|x64.Build.0 = Debug|x64
+ {53F841E8-284F-4545-9176-B131896E43F8}.Debug|x64.ActiveCfg = Debug|Win32
{53F841E8-284F-4545-9176-B131896E43F8}.Release|Win32.ActiveCfg = Release|Win32
{53F841E8-284F-4545-9176-B131896E43F8}.Release|Win32.Build.0 = Release|Win32
- {53F841E8-284F-4545-9176-B131896E43F8}.Release|x64.ActiveCfg = Release|x64
- {53F841E8-284F-4545-9176-B131896E43F8}.Release|x64.Build.0 = Release|x64
+ {53F841E8-284F-4545-9176-B131896E43F8}.Release|x64.ActiveCfg = Release|Win32
{E71C1722-A41D-4475-87F4-29961A3654BB}.Debug|Win32.ActiveCfg = Debug|Win32
{E71C1722-A41D-4475-87F4-29961A3654BB}.Debug|Win32.Build.0 = Debug|Win32
{E71C1722-A41D-4475-87F4-29961A3654BB}.Debug|x64.ActiveCfg = Debug|x64
@@ -1654,6 +1652,12 @@ Global
{2E0A2793-94C3-82E7-2AB0-FD421816CFBF}.Release|Win32.Build.0 = Release|Win32
{2E0A2793-94C3-82E7-2AB0-FD421816CFBF}.Release|x64.ActiveCfg = Release|x64
{2E0A2793-94C3-82E7-2AB0-FD421816CFBF}.Release|x64.Build.0 = Release|x64
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Debug|Win32.ActiveCfg = Debug|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Debug|Win32.Build.0 = Debug|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Debug|x64.ActiveCfg = Debug|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Release|Win32.ActiveCfg = Release|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Release|Win32.Build.0 = Release|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/bin10/miranda32.sln b/bin10/miranda32.sln
index d79ca5327a..79cc4a8631 100644
--- a/bin10/miranda32.sln
+++ b/bin10/miranda32.sln
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+# Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AVS", "..\plugins\AVS\avs_10.vcxproj", "{7711F563-6473-4ABD-B5E3-477CE8384AD6}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Chat", "..\plugins\Chat\chat_10.vcxproj", "{268BD296-8DD3-4715-A386-CF120398EC98}"
@@ -74,6 +74,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Toolbar_icons", "..\plugins
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Clist_classic", "..\plugins\Clist_classic\clist_10.vcxproj", "{E71C1722-A41D-4475-87F4-29961A3654BB}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mir_core", "..\plugins\mir_core\mir_core_10.vcxproj", "{D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -378,6 +380,12 @@ Global
{E71C1722-A41D-4475-87F4-29961A3654BB}.Release|Win32.Build.0 = Release|Win32
{E71C1722-A41D-4475-87F4-29961A3654BB}.Release|x64.ActiveCfg = Release|x64
{E71C1722-A41D-4475-87F4-29961A3654BB}.Release|x64.Build.0 = Release|x64
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Debug|Win32.ActiveCfg = Debug|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Debug|Win32.Build.0 = Debug|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Debug|x64.ActiveCfg = Debug|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Release|Win32.ActiveCfg = Release|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Release|Win32.Build.0 = Release|Win32
+ {D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/include/m_core.h b/include/m_core.h
new file mode 100644
index 0000000000..0aeff8ae2f
--- /dev/null
+++ b/include/m_core.h
@@ -0,0 +1,396 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2008 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_CORE_H__
+#define M_CORE_H__ 1
+
+#ifdef MIR_CORE_EXPORTS
+ #define MIR_CORE_DLL(T) __declspec(dllexport) T __cdecl
+#else
+ #define MIR_CORE_DLL(T) __declspec(dllimport) T __cdecl
+#endif
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// events, hooks & services
+
+#define MAXMODULELABELLENGTH 64
+
+typedef int (*MIRANDAHOOK)(WPARAM, LPARAM);
+typedef int (*MIRANDAHOOKPARAM)(WPARAM, LPARAM, LPARAM);
+typedef int (*MIRANDAHOOKOBJ)(void*, WPARAM, LPARAM);
+typedef int (*MIRANDAHOOKOBJPARAM)(void*, WPARAM, LPARAM, LPARAM);
+
+typedef INT_PTR (*MIRANDASERVICE)(WPARAM, LPARAM);
+typedef INT_PTR (*MIRANDASERVICEPARAM)(WPARAM, LPARAM, LPARAM);
+typedef INT_PTR (*MIRANDASERVICEOBJ)(void*, LPARAM, LPARAM);
+typedef INT_PTR (*MIRANDASERVICEOBJPARAM)(void*, WPARAM, LPARAM, LPARAM);
+
+#ifdef _WIN64
+ #define CALLSERVICE_NOTFOUND ((INT_PTR)0x8000000000000000)
+#else
+ #define CALLSERVICE_NOTFOUND ((int)0x80000000)
+#endif
+
+MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name);
+MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent);
+MIR_CORE_DLL(int) SetHookDefaultForHookableEvent(HANDLE hEvent, MIRANDAHOOK pfnHook);
+MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(int) CallHookSubscribers(HANDLE hEvent, WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(int) NotifyEventHooks(HANDLE hEvent, WPARAM wParam, LPARAM lParam);
+
+MIR_CORE_DLL(HANDLE) HookEvent(const char* name, MIRANDAHOOK hookProc);
+MIR_CORE_DLL(HANDLE) HookEventParam(const char* name, MIRANDAHOOKPARAM hookProc, LPARAM lParam);
+MIR_CORE_DLL(HANDLE) HookEventObj(const char* name, MIRANDAHOOKOBJ hookProc, void* object);
+MIR_CORE_DLL(HANDLE) HookEventObjParam(const char* name, MIRANDAHOOKOBJPARAM hookProc, void* object, LPARAM lParam);
+MIR_CORE_DLL(HANDLE) HookEventMessage(const char* name, HWND hwnd, UINT message);
+MIR_CORE_DLL(int) UnhookEvent(HANDLE hHook);
+MIR_CORE_DLL(void) KillObjectEventHooks(void* pObject);
+MIR_CORE_DLL(void) KillModuleEventHooks(HINSTANCE pModule);
+
+MIR_CORE_DLL(HANDLE) CreateServiceFunction(const char *name, MIRANDASERVICE serviceProc);
+MIR_CORE_DLL(HANDLE) CreateServiceFunctionParam(const char *name, MIRANDASERVICEPARAM serviceProc, LPARAM lParam);
+MIR_CORE_DLL(HANDLE) CreateServiceFunctionObj(const char *name, MIRANDASERVICEOBJ serviceProc, void* object);
+MIR_CORE_DLL(HANDLE) CreateServiceFunctionObjParam(const char *name, MIRANDASERVICEOBJPARAM serviceProc, void* object, LPARAM lParam);
+MIR_CORE_DLL(int) DestroyServiceFunction(HANDLE hService);
+MIR_CORE_DLL(int) ServiceExists(const char *name);
+
+MIR_CORE_DLL(INT_PTR) CallService(const char *name, WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(INT_PTR) CallServiceSync(const char *name, WPARAM wParam, LPARAM lParam);
+
+MIR_CORE_DLL(int) CallFunctionAsync(void (__stdcall *func)(void *), void *arg);
+MIR_CORE_DLL(void) KillModuleServices(HINSTANCE hInst);
+MIR_CORE_DLL(void) KillObjectServices(void* pObject);
+
+#if defined(_STATIC)
+__declspec(dllexport) INT_PTR CallContactService(HANDLE, const char *, WPARAM, LPARAM);
+__declspec(dllexport) INT_PTR CallProtoService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam);
+#else
+MIR_CORE_DLL(INT_PTR) CallContactService(HANDLE, const char *, WPARAM, LPARAM);
+MIR_CORE_DLL(INT_PTR) CallProtoService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam);
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// exceptions
+
+typedef DWORD (__cdecl *pfnExceptionFilter)(DWORD code, EXCEPTION_POINTERS* info);
+
+MIR_CORE_DLL(pfnExceptionFilter) GetExceptionFilter(void);
+MIR_CORE_DLL(pfnExceptionFilter) SetExceptionFilter(pfnExceptionFilter pMirandaExceptFilter);
+
+///////////////////////////////////////////////////////////////////////////////
+// language packs support
+
+#define LANG_UNICODE 0x1000
+
+extern int hLangpack;
+
+MIR_CORE_DLL(void) LangPackDropUnusedItems(void);
+MIR_CORE_DLL(int) LangPackGetDefaultCodePage( void );
+MIR_CORE_DLL(int) LangPackGetDefaultLocale(void);
+MIR_CORE_DLL(TCHAR*) LangPackPcharToTchar(const char* pszStr);
+
+MIR_CORE_DLL(int) LoadLangPack(const TCHAR *szLangPack);
+MIR_CORE_DLL(void) ReloadLangpack(TCHAR *pszStr);
+
+MIR_CORE_DLL(char*) TranslateA_LP(const char* str, int hLang);
+MIR_CORE_DLL(WCHAR*) TranslateW_LP(const WCHAR* str, int hLang);
+MIR_CORE_DLL(void) TranslateMenu_LP(HMENU, int hLang);
+MIR_CORE_DLL(void) TranslateDialog_LP(HWND hDlg, int hLang);
+
+#define Translate(s) TranslateA_LP(s, hLangpack)
+#define TranslateW(s) TranslateW_LP(s, hLangpack)
+#define TranslateMenu(h) TranslateMenu_LP(h,hLangpack)
+#define TranslateDialogDefault(h) TranslateDialog_LP(h,hLangpack)
+
+#ifdef _UNICODE
+ #define TranslateT(s) TranslateW_LP(_T(s),hLangpack)
+ #define TranslateTS(s) TranslateW_LP(s,hLangpack)
+ #define TranslateTH(l,s) TranslateW_LP(s,l)
+#else
+ #define TranslateT(s) TranslateA_LP(s,hLangpack)
+ #define TranslateTS(s) TranslateA_LP(s,hLangpack)
+ #define TranslateTH(l,s) TranslateA_LP(s,l)
+#endif
+
+MIR_CORE_DLL(unsigned int) mir_hash(const void * key, unsigned int len);
+
+#pragma optimize("gt", on)
+__inline unsigned int mir_hashstr(const char * key)
+{
+ if (key == NULL) return 0;
+ else {
+ unsigned int len = (unsigned int)strlen((const char*)key);
+ return mir_hash(key, len);
+} }
+
+__inline unsigned int mir_hashstrW(const wchar_t * key)
+{
+ if (key == NULL) return 0;
+ else {
+ unsigned int len = (unsigned int)wcslen((const wchar_t*)key);
+ return mir_hash(key, len * sizeof(wchar_t));
+} }
+#pragma optimize("", on)
+
+#define mir_hashstrT mir_hashstrW
+
+///////////////////////////////////////////////////////////////////////////////
+// lists
+
+typedef int (*FSortFunc)(void*, void*); // sort function prototype
+
+// Assumes first 32 bit value of the data is the numeric key
+// and uses it to perform sort/search operations, this results
+// in much better performance as no compare function calls needed
+// Incredibly useful for Hash Tables
+#define NumericKeySort (FSortFunc)(void*) -1
+#define HandleKeySort (FSortFunc)(void*) -2
+#define PtrKeySort (FSortFunc)(void*) -3
+
+typedef struct
+{
+ void** items;
+ int realCount;
+ int limit;
+ int increment;
+
+ FSortFunc sortFunc;
+}
+ SortedList;
+
+MIR_CORE_DLL(SortedList*) List_Create(int p_limit, int p_increment);
+MIR_CORE_DLL(void) List_Destroy(SortedList* p_list);
+MIR_CORE_DLL(void*) List_Find(SortedList* p_list, void* p_value);
+MIR_CORE_DLL(int) List_GetIndex(SortedList* p_list, void* p_value, int* p_index);
+MIR_CORE_DLL(int) List_IndexOf(SortedList* p_list, void* p_value);
+MIR_CORE_DLL(int) List_Insert(SortedList* p_list, void* p_value, int p_index);
+MIR_CORE_DLL(int) List_InsertPtr(SortedList* list, void* p);
+MIR_CORE_DLL(int) List_Remove(SortedList* p_list, int index);
+MIR_CORE_DLL(int) List_RemovePtr(SortedList* list, void* p);
+MIR_CORE_DLL(void) List_Copy(SortedList* s, SortedList* d, size_t itemSize);
+MIR_CORE_DLL(void) List_ObjCopy(SortedList* s, SortedList* d, size_t itemSize);
+
+///////////////////////////////////////////////////////////////////////////////
+// memory functions
+
+MIR_CORE_DLL(void*) mir_alloc(size_t);
+MIR_CORE_DLL(void*) mir_calloc(size_t);
+MIR_CORE_DLL(void*) mir_realloc(void* ptr, size_t);
+MIR_CORE_DLL(void) mir_free(void* ptr);
+MIR_CORE_DLL(char*) mir_strdup(const char* str);
+MIR_CORE_DLL(WCHAR*) mir_wstrdup(const WCHAR* str);
+MIR_CORE_DLL(char*) mir_strndup(const char* str, size_t len);
+
+///////////////////////////////////////////////////////////////////////////////
+// modules
+
+MIR_CORE_DLL(void) RegisterModule(HINSTANCE hInst);
+MIR_CORE_DLL(void) UnregisterModule(HINSTANCE hInst);
+
+MIR_CORE_DLL(HINSTANCE) GetInstByAddress(void* codePtr);
+
+///////////////////////////////////////////////////////////////////////////////
+// path utils
+
+MIR_CORE_DLL(void) CreatePathToFile(char* wszFilePath);
+MIR_CORE_DLL(int) CreateDirectoryTree(const char* szDir);
+MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, char* base);
+MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut);
+
+MIR_CORE_DLL(void) CreatePathToFileW(WCHAR* wszFilePath);
+MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR* szDir);
+MIR_CORE_DLL(int) PathToAbsoluteW(const WCHAR *pSrc, WCHAR *pOut, WCHAR* base);
+MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut);
+
+#define CreatePathToFileT CreatePathToFileW
+#define CreateDirectoryTreeT CreateDirectoryTreeW
+#define PathToAbsoluteT PathToAbsoluteW
+#define PathToRelativeT PathToRelativeW
+
+///////////////////////////////////////////////////////////////////////////////
+// print functions
+
+MIR_CORE_DLL(int) mir_snprintf(char *buffer, size_t count, const char* fmt, ...);
+MIR_CORE_DLL(int) mir_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...);
+MIR_CORE_DLL(int) mir_vsnprintf(char *buffer, size_t count, const char* fmt, va_list va);
+MIR_CORE_DLL(int) mir_vsntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, va_list va);
+
+///////////////////////////////////////////////////////////////////////////////
+// strings
+
+MIR_CORE_DLL(char*) rtrim(char *str);
+MIR_CORE_DLL(WCHAR*) wrtrim(WCHAR *str);
+
+#ifdef _UNICODE
+ #define trtrim wrtrim
+#else
+ #define trtrim rtrim
+#endif
+
+MIR_CORE_DLL(char*) ltrim(char *str); // returns pointer to the beginning of string
+MIR_CORE_DLL(char*) ltrimp(char *str); // returns pointer to the trimmed portion of string
+
+MIR_CORE_DLL(int) wildcmp(char *name, char *mask);
+
+__inline char* lrtrim(char* str) { return ltrim(rtrim(str)); };
+__inline char* lrtrimp(char* str) { return ltrimp(rtrim(str)); };
+
+///////////////////////////////////////////////////////////////////////////////
+// text conversion functions
+
+#ifdef _UNICODE
+ #define mir_t2a(s) mir_u2a(s)
+ #define mir_a2t(s) mir_a2u(s)
+ #define mir_t2u(s) mir_wstrdup(s)
+ #define mir_u2t(s) mir_wstrdup(s)
+
+ #define mir_t2a_cp(s,c) mir_u2a_cp(s,c)
+ #define mir_a2t_cp(s,c) mir_a2u_cp(s,c)
+ #define mir_t2u_cp(s,c) mir_wstrdup(s)
+ #define mir_u2t_cp(s,c) mir_wstrdup(s)
+
+ #define mir_tstrdup mir_wstrdup
+#else
+ #define mir_t2a(s) mir_strdup(s)
+ #define mir_a2t(s) mir_strdup(s)
+ #define mir_t2u(s) mir_a2u(s)
+ #define mir_u2t(s) mir_u2a(s)
+
+ #define mir_t2a_cp(s,c) mir_strdup(s)
+ #define mir_a2t_cp(s,c) mir_strdup(s)
+ #define mir_t2u_cp(s,c) mir_a2u_cp(s,c)
+ #define mir_u2t_cp(s,c) mir_u2a_cp(s,c)
+
+ #define mir_tstrdup mir_strdup
+#endif
+
+MIR_CORE_DLL(WCHAR*) mir_a2u_cp(const char* src, int codepage);
+MIR_CORE_DLL(WCHAR*) mir_a2u(const char* src);
+MIR_CORE_DLL(char*) mir_u2a_cp(const wchar_t* src, int codepage);
+MIR_CORE_DLL(char*) mir_u2a(const wchar_t* src);
+
+#if defined(__cplusplus)
+
+class _A2T
+{
+ TCHAR* buf;
+
+public:
+ __forceinline _A2T(const char* s) : buf(mir_a2t(s)) {}
+ __forceinline _A2T(const char* s, int cp) : buf(mir_a2t_cp(s, cp)) {}
+ ~_A2T() { mir_free(buf); }
+
+ __forceinline operator TCHAR*() const
+ { return buf;
+ }
+};
+
+class _T2A
+{
+ char* buf;
+
+public:
+ __forceinline _T2A(const TCHAR* s) : buf(mir_t2a(s)) {}
+ __forceinline _T2A(const TCHAR* s, int cp) : buf(mir_t2a_cp(s, cp)) {}
+ __forceinline ~_T2A() { mir_free(buf); }
+
+ __forceinline operator char*() const
+ { return buf;
+ }
+};
+
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// threads
+
+MIR_CORE_DLL(INT_PTR) UnwindThreadPush(WPARAM wParam, LPARAM lParam);
+MIR_CORE_DLL(INT_PTR) UnwindThreadPop(WPARAM, LPARAM);
+MIR_CORE_DLL(void) UnwindThreadWait(void);
+
+MIR_CORE_DLL(UINT_PTR) forkthread( void (__cdecl *threadcode)(void*), unsigned long stacksize, void *arg);
+MIR_CORE_DLL(UINT_PTR) forkthreadex(void *sec, unsigned stacksize, unsigned (__stdcall *threadcode)(void*), void* owner, void *arg, unsigned *thraddr);
+
+MIR_CORE_DLL(void) KillObjectThreads(void* pObject);
+
+///////////////////////////////////////////////////////////////////////////////
+// utf8 interface
+
+MIR_CORE_DLL(char*) Utf8Decode(char* str, wchar_t** ucs2);
+MIR_CORE_DLL(char*) Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2);
+
+MIR_CORE_DLL(wchar_t*) Utf8DecodeW(const char* str);
+
+MIR_CORE_DLL(char*) Utf8Encode(const char* str);
+MIR_CORE_DLL(char*) Utf8EncodeCP(const char* src, int codepage);
+
+MIR_CORE_DLL(char*) Utf8EncodeW(const wchar_t* str);
+
+MIR_CORE_DLL(int) Ucs2toUtf8Len(const wchar_t *src);
+
+#define Utf8DecodeT Utf8DecodeW
+#define Utf8EncodeT Utf8EncodeW
+
+#define mir_utf8decode(A, B) Utf8Decode(A, B)
+#define mir_utf8decodecp(A, B, C) Utf8DecodeCP(A, B, C)
+#define mir_utf8decodeW(A) Utf8DecodeW(A)
+#define mir_utf8encode(A) Utf8Encode(A)
+#define mir_utf8encodecp(A, B) Utf8EncodeCP(A, B)
+#define mir_utf8encodeW(A) Utf8EncodeW(A)
+#define mir_utf8lenW(A) Ucs2toUtf8Len(A)
+
+__forceinline char* mir_utf8decodeA(const char* src)
+{
+ char* tmp = mir_strdup(src);
+ mir_utf8decode(tmp, NULL);
+ return tmp;
+}
+
+#if defined(_UNICODE)
+ #define mir_utf8decodeT mir_utf8decodeW
+ #define mir_utf8encodeT mir_utf8encodeW
+#else
+ #define mir_utf8decodeT mir_utf8decodeA
+ #define mir_utf8encodeT mir_utf8encode
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+
+#if defined(__cplusplus)
+}
+#endif
+
+#ifndef MIR_CORE_EXPORTS
+ #if !defined( _WIN64 )
+ #pragma comment(lib, "mir_core.lib")
+ #else
+ #pragma comment(lib, "mir_core64.lib")
+ #endif
+#endif
+
+#endif // M_CORE_H
diff --git a/include/m_langpack.h b/include/m_langpack.h
index d1dfb9d326..efcca8d27c 100644
--- a/include/m_langpack.h
+++ b/include/m_langpack.h
@@ -24,12 +24,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef M_LANGPACK_H__
#define M_LANGPACK_H__
+#if !defined(M_CORE_H__)
+ #include <m_core.h>
+#endif
+
#if !defined(_STATIC)
#define MIRANDA_CUSTOM_LP
#endif
-#define LANG_UNICODE 0x1000
-
//translates a single string into the user's local language v0.1.1.0+
//wParam=0
//lParam=(LPARAM)(const char*)szEnglish
@@ -41,38 +43,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//these versions, I pity them.
#define MS_LANGPACK_TRANSLATESTRING "LangPack/TranslateString"
-#if defined(MIRANDA_CUSTOM_LP)
-
-extern int hLangpack;
-
-__inline static char* Translate(const char* str)
-{ return (char*)CallService(MS_LANGPACK_TRANSLATESTRING, hLangpack, (LPARAM)(str));
-}
-
-__inline static WCHAR* TranslateW(const WCHAR* str)
-{ return (WCHAR*)CallService(MS_LANGPACK_TRANSLATESTRING, hLangpack+LANG_UNICODE, (LPARAM)(str));
-}
-
-#else
-
-__inline static char* Translate(const char* str)
-{ return (char*)CallService(MS_LANGPACK_TRANSLATESTRING, 0, (LPARAM)(str));
-}
-
-__inline static WCHAR* TranslateW(const WCHAR* str)
-{ return (WCHAR*)CallService(MS_LANGPACK_TRANSLATESTRING, LANG_UNICODE, (LPARAM)(str));
-}
-
-#endif
-
-#ifdef _UNICODE
- #define TranslateT(s) TranslateW(_T(s))
- #define TranslateTS(s) TranslateW(s)
-#else
- #define TranslateT(s) Translate(s)
- #define TranslateTS(s) Translate(s)
-#endif
-
// If you're storing some string for calling later-on Translate or using it
// with an API call that does translation automatically marked with
// [TRANSLATED-BY-CORE] please wrap it with one of LPGEN macros in order to
@@ -86,71 +56,12 @@ __inline static WCHAR* TranslateW(const WCHAR* str)
#endif
//Those macros do NOTHING. They are just markers for lpgen.pl.
-//translates a dialog into the user's local language v0.1.1.0+
-//wParam=0
-//lParam=(LPARAM)(LANGPACKTRANSLATEDIALOG*)&lptd
-//returns 0 on success, nonzero on failure
-//This service only knows about the following controls:
-//Window titles, STATIC, EDIT, Hyperlink, BUTTON
-typedef struct {
- int cbSize;
- DWORD flags;
- HWND hwndDlg;
- const int *ignoreControls; //zero-terminated list of control IDs *not* to
- //translate
-} LANGPACKTRANSLATEDIALOG;
-#define LPTDF_NOIGNOREEDIT 1 //translate all edit controls. By default
- //non-read-only edit controls are not translated
-#define LPTDF_NOTITLE 2 //do not translate the title of the dialog
-
-#define MS_LANGPACK_TRANSLATEDIALOG "LangPack/TranslateDialog"
-
-#if defined(MIRANDA_CUSTOM_LP)
-
-__inline static INT_PTR TranslateDialogDefault(HWND hwndDlg)
-{
- LANGPACKTRANSLATEDIALOG lptd;
- lptd.cbSize=sizeof(lptd);
- lptd.flags=hLangpack;
- lptd.hwndDlg=hwndDlg;
- lptd.ignoreControls=NULL;
- return CallService(MS_LANGPACK_TRANSLATEDIALOG, 0, (LPARAM)&lptd);
-}
-
-#else
-
-__inline static INT_PTR TranslateDialogDefault(HWND hwndDlg)
-{
- LANGPACKTRANSLATEDIALOG lptd;
- lptd.cbSize=sizeof(lptd);
- lptd.flags=0;
- lptd.hwndDlg=hwndDlg;
- lptd.ignoreControls=NULL;
- return CallService(MS_LANGPACK_TRANSLATEDIALOG, 0, (LPARAM)&lptd);
-}
-
-#endif
-
//translates a menu into the user's local language v0.1.1.0+
//wParam=(WPARAM)(HMENU)hMenu
//lParam=langpack handle (v.0.10.0+)
//returns 0 on success, nonzero on failure
#define MS_LANGPACK_TRANSLATEMENU "LangPack/TranslateMenu"
-#if defined(MIRANDA_CUSTOM_LP)
-
-__inline static INT_PTR TranslateMenu(HMENU hMenu)
-{ return CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)hMenu, hLangpack);
-}
-
-#else
-
-__inline static INT_PTR TranslateMenu(HMENU hMenu)
-{ return CallService(MS_LANGPACK_TRANSLATEMENU, (LPARAM)hMenu, 0);
-}
-
-#endif
-
//returns the codepage used in the language pack v0.4.3.0+
//wParam=0
//lParam=0
@@ -191,7 +102,7 @@ __inline static INT_PTR Langpack_PCharToTChar(const char* str)
#define MS_LANGPACK_REGISTER "LangPack/Register"
#if defined(MIRANDA_CUSTOM_LP)
-__forceinline void mir_getLP(const PLUGININFOEX* pInfo)
+__inline static void mir_getLP(const PLUGININFOEX* pInfo)
{ CallService(MS_LANGPACK_REGISTER, (WPARAM)&hLangpack, (LPARAM)pInfo);
}
#endif
diff --git a/include/m_protomod.h b/include/m_protomod.h
index ee28bf232d..bce86385d6 100644
--- a/include/m_protomod.h
+++ b/include/m_protomod.h
@@ -61,7 +61,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//Create a protocol service
//Protocol services are called with wParam and lParam as standard if they are
-//to be called with CallProtoService() (as PS_ services are)
+//to be called with CallProtoServiceInt(NULL,) (as PS_ services are)
//If they are called with CallContactService() (PSS_ and PSR_ services) then
//they are called with lParam=(CCSDATA*)&ccs and wParam an opaque internal
//reference that should be passed unchanged to MS_PROTO_CHAIN*.
diff --git a/include/m_protosvc.h b/include/m_protosvc.h
index b8259911ff..f7ce4f26e9 100644
--- a/include/m_protosvc.h
+++ b/include/m_protosvc.h
@@ -43,7 +43,7 @@ convert Unicode to ANSI and call the appropriate service.
*/
/*************************** NON-CONTACT SERVICES ************************/
-//these should be called with CallProtoService()
+//these should be called with CallProtoServiceInt(NULL,)
//Get the capability flags of the module.
//wParam=flagNum
diff --git a/include/m_system.h b/include/m_system.h
index d17896a0a5..ffca735b4a 100644
--- a/include/m_system.h
+++ b/include/m_system.h
@@ -25,8 +25,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <tchar.h>
+#include <m_core.h>
+
#ifndef MIRANDANAME
- #define MIRANDANAME "Miranda IM"
+ #define MIRANDANAME "Miranda IM"
#endif
#ifndef MIRANDACLASS
#define MIRANDACLASS "Miranda"
@@ -164,73 +166,15 @@ struct MM_INTERFACE
__forceinline INT_PTR mir_getMMI(struct MM_INTERFACE* dest)
{
- dest->cbSize = sizeof(*dest);
- return CallService(MS_SYSTEM_GET_MMI, 0, (LPARAM)dest);
+ return 0;
}
-#ifndef _STATIC
- extern struct MM_INTERFACE mmi;
- #define mir_alloc(n) mmi.mmi_malloc(n)
- #define mir_free(ptr) mmi.mmi_free(ptr)
- #define mir_realloc(ptr, size) mmi.mmi_realloc(ptr, size)
-
- #define mir_calloc(n) mmi.mmi_calloc(n)
- #define mir_strdup(str) mmi.mmi_strdup(str)
- #define mir_wstrdup(str) mmi.mmi_wstrdup(str)
- #define mir_snprintf mmi.mir_snprintf
- #define mir_sntprintf mmi.mir_sntprintf
- #define mir_vsnprintf mmi.mir_vsnprintf
- #define mir_vsntprintf mmi.mir_vsntprintf
-
- #define mir_a2u_cp(src, cp) mmi.mir_a2u_cp(src, cp)
- #define mir_a2u(src) mmi.mir_a2u(src)
- #define mir_u2a_cp(src, cp) mmi.mir_u2a_cp(src, cp)
- #define mir_u2a(src) mmi.mir_u2a(src)
-#else
- char* mir_strdup(const char *src);
- WCHAR* mir_wstrdup(const WCHAR *src);
-#endif
-
-#if defined(_UNICODE)
- #define mir_tstrdup mir_wstrdup
-#else
- #define mir_tstrdup mir_strdup
-#endif
-
-#define miranda_sys_free mir_free
-#define memoryManagerInterface mmi
-
/* Returns the pointer to the simple lists manager.
If the sortFunc member of the list gets assigned, the list becomes sorted
wParam=0, lParam = (LPARAM)LIST_INTERFACE*
*/
-#define LIST_INTERFACE_V1_SIZE (sizeof(size_t)+7*sizeof(void*))
-#define LIST_INTERFACE_V2_SIZE (sizeof(size_t)+9*sizeof(void*))
-#define LIST_INTERFACE_V3_SIZE (sizeof(size_t)+11*sizeof(void*))
-
-typedef int (*FSortFunc)(void*, void*);
-
-// Assumes first 32 bit value of the data is the numeric key
-// and uses it to perform sort/search operations, this results
-// in much better performance as no compare function calls needed
-// Incredibly useful for Hash Tables
-#define NumericKeySort (FSortFunc)(void*) -1
-#define HandleKeySort (FSortFunc)(void*) -2
-#define PtrKeySort (FSortFunc)(void*) -3
-
-typedef struct
-{
- void** items;
- int realCount;
- int limit;
- int increment;
-
- FSortFunc sortFunc;
-}
- SortedList;
-
struct LIST_INTERFACE
{
size_t cbSize;
@@ -255,8 +199,7 @@ struct LIST_INTERFACE
__forceinline INT_PTR mir_getLI(struct LIST_INTERFACE* dest)
{
- dest->cbSize = sizeof(*dest);
- return CallService(MS_SYSTEM_GET_LI, 0, (LPARAM)dest);
+ return 0;
}
/*
@@ -301,35 +244,9 @@ struct UTF8_INTERFACE
__forceinline INT_PTR mir_getUTFI(struct UTF8_INTERFACE* dest)
{
- dest->cbSize = sizeof(*dest);
- return CallService(MS_SYSTEM_GET_UTFI, 0, (LPARAM)dest);
+ return 0;
}
-extern struct UTF8_INTERFACE utfi;
-
-#define mir_utf8decode(A, B) utfi.utf8_decode(A, B)
-#define mir_utf8decodecp(A, B, C) utfi.utf8_decodecp(A, B, C)
-#define mir_utf8decodeW(A) utfi.utf8_decodeW(A)
-#define mir_utf8encode(A) utfi.utf8_encode(A)
-#define mir_utf8encodecp(A, B) utfi.utf8_encodecp(A, B)
-#define mir_utf8encodeW(A) utfi.utf8_encodeW(A)
-#define mir_utf8lenW(A) utfi.utf8_lenW(A)
-
-__forceinline char* mir_utf8decodeA(const char* src)
-{
- char* tmp = mir_strdup(src);
- mir_utf8decode(tmp, NULL);
- return tmp;
-}
-
-#if defined(_UNICODE)
- #define mir_utf8decodeT mir_utf8decodeW
- #define mir_utf8encodeT mir_utf8encodeW
-#else
- #define mir_utf8decodeT mir_utf8decodeA
- #define mir_utf8encodeT mir_utf8encode
-#endif
-
/*
-- Thread Safety --
@@ -608,19 +525,16 @@ obtain this filter and call it inside the __except section
0.8.0+ addition (2008/07/20)
*/
-typedef DWORD (__cdecl *pfnExceptionFilter)(DWORD code, EXCEPTION_POINTERS* info);
-
#define MS_SYSTEM_GETEXCEPTFILTER "System/GetExceptFilter"
__inline static pfnExceptionFilter Miranda_GetExceptFilter(void)
-{ return (pfnExceptionFilter)CallService(MS_SYSTEM_GETEXCEPTFILTER, 0, 0);
+{ return GetExceptionFilter();
}
#define MS_SYSTEM_SETEXCEPTFILTER "System/SetExceptFilter"
__inline static pfnExceptionFilter Miranda_SetExceptFilter(pfnExceptionFilter foo)
-{ return (pfnExceptionFilter)CallService(MS_SYSTEM_SETEXCEPTFILTER, 0, (LPARAM)foo);
+{ return SetExceptionFilter(foo);
}
-
#endif // M_SYSTEM_H
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h
index c0e448fec3..086eba0fc3 100644
--- a/include/m_system_cpp.h
+++ b/include/m_system_cpp.h
@@ -70,59 +70,31 @@ template<class T> struct LIST
__inline int getCount(void) const { return count; }
__inline T** getArray(void) const { return items; }
- #if defined(_STATIC)
- __inline LIST(const LIST& x)
- { items = NULL;
- List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
- }
-
- __inline LIST& operator=(const LIST& x)
- { destroy();
- List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
- return *this;
- }
-
- __inline int getIndex(T* p) const
- { int idx;
- return ( !List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
- }
-
- __inline void destroy(void) { List_Destroy((SortedList*)this); }
-
- __inline T* find(T* p) { return (T*)List_Find((SortedList*)this, p); }
- __inline int indexOf(T* p) { return List_IndexOf((SortedList*)this, p); }
- __inline int insert(T* p, int idx) { return List_Insert((SortedList*)this, p, idx); }
- __inline int remove(int idx) { return List_Remove((SortedList*)this, idx); }
-
- __inline int insert(T* p) { return List_InsertPtr((SortedList*)this, p); }
- __inline int remove(T* p) { return List_RemovePtr((SortedList*)this, p); }
- #else
- __inline LIST(const LIST& x)
- { items = NULL;
- li.List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
- }
-
- __inline LIST& operator=(const LIST& x)
- { destroy();
- li.List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
- return *this;
- }
+ __inline LIST(const LIST& x)
+ { items = NULL;
+ List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
+ }
+
+ __inline LIST& operator=(const LIST& x)
+ { destroy();
+ List_Copy((SortedList*)&x, (SortedList*)this, sizeof(T));
+ return *this;
+ }
- __inline int getIndex(T* p) const
- { int idx;
- return ( !li.List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
- }
+ __inline int getIndex(T* p) const
+ { int idx;
+ return ( !List_GetIndex((SortedList*)this, p, &idx)) ? -1 : idx;
+ }
- __inline void destroy(void) { li.List_Destroy((SortedList*)this); }
+ __inline void destroy(void) { List_Destroy((SortedList*)this); }
- __inline T* find(T* p) { return (T*)li.List_Find((SortedList*)this, p); }
- __inline int indexOf(T* p) { return li.List_IndexOf((SortedList*)this, p); }
- __inline int insert(T* p, int idx) { return li.List_Insert((SortedList*)this, p, idx); }
- __inline int remove(int idx) { return li.List_Remove((SortedList*)this, idx); }
+ __inline T* find(T* p) { return (T*)List_Find((SortedList*)this, p); }
+ __inline int indexOf(T* p) { return List_IndexOf((SortedList*)this, p); }
+ __inline int insert(T* p, int idx) { return List_Insert((SortedList*)this, p, idx); }
+ __inline int remove(int idx) { return List_Remove((SortedList*)this, idx); }
- __inline int insert(T* p) { return li.List_InsertPtr((SortedList*)this, p); }
- __inline int remove(T* p) { return li.List_RemovePtr((SortedList*)this, p); }
- #endif
+ __inline int insert(T* p) { return List_InsertPtr((SortedList*)this, p); }
+ __inline int remove(T* p) { return List_RemovePtr((SortedList*)this, p); }
protected:
T** items;
@@ -145,29 +117,18 @@ template<class T> struct OBJLIST : public LIST<T>
__inline OBJLIST(const OBJLIST& x) :
LIST<T>(x.increment, x.sortFunc)
{ items = NULL;
- #if defined(_STATIC)
- List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #else
- li.List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #endif
+ List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
}
__inline OBJLIST& operator=(const OBJLIST& x)
{ destroy();
- #if defined(_STATIC)
- List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #else
- li.List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
- #endif
+ List_ObjCopy((SortedList*)&x, (SortedList*)this, sizeof(T));
return *this;
}
~OBJLIST()
{
- #if !defined(_STATIC)
- if (li.cbSize != 0)
- #endif
- destroy();
+ destroy();
}
__inline void destroy(void)
@@ -175,30 +136,17 @@ template<class T> struct OBJLIST : public LIST<T>
for (int i=0; i < this->count; i++)
delete this->items[i];
- #if defined(_STATIC)
- List_Destroy((SortedList*)this);
- #else
- li.List_Destroy((SortedList*)this);
- #endif
+ List_Destroy((SortedList*)this);
}
__inline int remove(int idx) {
delete this->items[idx];
- #if defined(_STATIC)
- return List_Remove((SortedList*)this, idx);
- #else
- return li.List_Remove((SortedList*)this, idx);
- #endif
+ return List_Remove((SortedList*)this, idx);
}
__inline int remove(T* p)
{
- #if defined(_STATIC)
- if (li.List_RemovePtr((SortedList*)this, p) != -1)
- #else
- if (li.List_RemovePtr((SortedList*)this, p) != -1)
- #endif
- {
+ if (List_RemovePtr((SortedList*)this, p) != -1) {
delete p;
return 1;
}
diff --git a/include/m_utils.h b/include/m_utils.h
index b8366f31a9..ad8b99e46d 100644
--- a/include/m_utils.h
+++ b/include/m_utils.h
@@ -518,66 +518,4 @@ extern struct SHA1_INTERFACE sha1i;
#define TCHAR_STR_PARAM "%s"
#endif
-#ifdef _UNICODE
- #define mir_t2a(s) mir_u2a(s)
- #define mir_a2t(s) mir_a2u(s)
- #define mir_t2u(s) mir_wstrdup(s)
- #define mir_u2t(s) mir_wstrdup(s)
-
- #define mir_t2a_cp(s,c) mir_u2a_cp(s,c)
- #define mir_a2t_cp(s,c) mir_a2u_cp(s,c)
- #define mir_t2u_cp(s,c) mir_wstrdup(s)
- #define mir_u2t_cp(s,c) mir_wstrdup(s)
-#else
- #define mir_t2a(s) mir_strdup(s)
- #define mir_a2t(s) mir_strdup(s)
- #define mir_t2u(s) mir_a2u(s)
- #define mir_u2t(s) mir_u2a(s)
-
- #define mir_t2a_cp(s,c) mir_strdup(s)
- #define mir_a2t_cp(s,c) mir_strdup(s)
- #define mir_t2u_cp(s,c) mir_a2u_cp(s,c)
- #define mir_u2t_cp(s,c) mir_u2a_cp(s,c)
-#endif
-
-#if defined(__cplusplus)
-
-#ifdef _STATIC
- void mir_free(void*);
- WCHAR* mir_a2u_cp(const char* src, int codepage);
- WCHAR* mir_a2u(const char* src);
- char* mir_u2a_cp(const wchar_t* src, int codepage);
- char* mir_u2a(const wchar_t* src);
-#endif
-
-class _A2T
-{
- TCHAR* buf;
-
-public:
- __forceinline _A2T(const char* s) : buf(mir_a2t(s)) {}
- __forceinline _A2T(const char* s, int cp) : buf(mir_a2t_cp(s, cp)) {}
- ~_A2T() { mir_free(buf); }
-
- __forceinline operator TCHAR*() const
- { return buf;
- }
-};
-
-class _T2A
-{
- char* buf;
-
-public:
- __forceinline _T2A(const TCHAR* s) : buf(mir_t2a(s)) {}
- __forceinline _T2A(const TCHAR* s, int cp) : buf(mir_t2a_cp(s, cp)) {}
- __forceinline ~_T2A() { mir_free(buf); }
-
- __forceinline operator char*() const
- { return buf;
- }
-};
-
-#endif
-
#endif // M_UTILS_H__
diff --git a/include/newpluginapi.h b/include/newpluginapi.h
index 0f2a6aa8d7..c539b9222b 100644
--- a/include/newpluginapi.h
+++ b/include/newpluginapi.h
@@ -24,7 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef M_NEWPLUGINAPI_H__
#define M_NEWPLUGINAPI_H__
-#include "m_plugins.h"
+#include <m_core.h>
+#include <m_plugins.h>
#define PLUGIN_MAKE_VERSION(a, b, c, d) (((((DWORD)(a))&0xFF)<<24)|((((DWORD)(b))&0xFF)<<16)|((((DWORD)(c))&0xFF)<<8)|(((DWORD)(d))&0xFF))
#define MAXMODULELABELLENGTH 64
@@ -100,7 +101,8 @@ typedef struct _MUUID {
/* Each service mode plugin must implement MS_SERVICEMODE_LAUNCH */
#define MS_SERVICEMODE_LAUNCH "ServiceMode/Launch"
-typedef struct {
+typedef struct PLUGININFOEX_tag
+{
int cbSize;
char *shortName;
DWORD version;
@@ -115,7 +117,8 @@ typedef struct {
//with the implication that this plugin provides back-end-compatible features
/*********** WILL BE DEPRECATED in 0.8 * *************/
MUUID uuid; // Not required until 0.8.
-} PLUGININFOEX;
+}
+ PLUGININFOEX;
//Miranda/System/LoadModule event
//called when a plugin is being loaded dynamically
@@ -129,25 +132,6 @@ typedef struct {
//lParam=HINSTANCE of the plugin to be unloaded
#define ME_SYSTEM_MODULEUNLOAD "Miranda/System/UnloadModule"
-#ifndef MODULES_H_
- typedef int (*MIRANDAHOOK)(WPARAM, LPARAM);
- typedef int (*MIRANDAHOOKPARAM)(WPARAM, LPARAM, LPARAM);
- typedef int (*MIRANDAHOOKOBJ)(void*, WPARAM, LPARAM);
- typedef int (*MIRANDAHOOKOBJPARAM)(void*, WPARAM, LPARAM, LPARAM);
-
- typedef INT_PTR (*MIRANDASERVICE)(WPARAM, LPARAM);
- typedef INT_PTR (*MIRANDASERVICEPARAM)(WPARAM, LPARAM, LPARAM);
- typedef INT_PTR (*MIRANDASERVICEOBJ)(void*, WPARAM, LPARAM);
- typedef INT_PTR (*MIRANDASERVICEOBJPARAM)(void*, WPARAM, LPARAM, LPARAM);
-
-#ifdef _WIN64
- #define CALLSERVICE_NOTFOUND ((INT_PTR)0x8000000000000000)
-#else
- #define CALLSERVICE_NOTFOUND ((int)0x80000000)
-#endif
-
-#endif
-
//see modules.h for what all this stuff is
typedef struct tagPLUGINLINK {
HANDLE (*CreateHookableEvent)(const char *);
@@ -177,38 +161,6 @@ typedef struct tagPLUGINLINK {
void (*KillObjectEventHooks)(void *);
} PLUGINLINK;
-#ifndef MODULES_H_
- #ifndef NODEFINEDLINKFUNCTIONS
- //relies on a global variable 'pluginLink' in the plugins
- extern PLUGINLINK *pluginLink;
- #define CreateHookableEvent(a) pluginLink->CreateHookableEvent(a)
- #define DestroyHookableEvent(a) pluginLink->DestroyHookableEvent(a)
- #define NotifyEventHooks(a, b, c) pluginLink->NotifyEventHooks(a, b, c)
- #define HookEventMessage(a, b, c) pluginLink->HookEventMessage(a, b, c)
- #define HookEvent(a, b) pluginLink->HookEvent(a, b)
- #define UnhookEvent(a) pluginLink->UnhookEvent(a)
- #define CreateServiceFunction(a, b) pluginLink->CreateServiceFunction(a, b)
- #define CreateTransientServiceFunction(a, b) pluginLink->CreateTransientServiceFunction(a, b)
- #define DestroyServiceFunction(a) pluginLink->DestroyServiceFunction(a)
- #define CallService(a, b, c) pluginLink->CallService(a, b, c)
- #define ServiceExists(a) pluginLink->ServiceExists(a)
- #define CallServiceSync(a, b, c) pluginLink->CallServiceSync(a, b, c)
- #define CallFunctionAsync(a, b) pluginLink->CallFunctionAsync(a, b)
- #define SetHookDefaultForHookableEvent(a, b) pluginLink->SetHookDefaultForHookableEvent(a, b)
- #define CreateServiceFunctionParam(a, b, c) pluginLink->CreateServiceFunctionParam(a, b, c)
- #define NotifyEventHooksDirect(a, b, c) pluginLink->NotifyEventHooksDirect(a, b, c)
- #define CallProtoService(a, b, c, d) pluginLink->CallProtoService(a, b, c, d)
- #define CallContactService(a, b, c, d) pluginLink->CallContactService(a, b, c, d)
- #define HookEventParam(a, b, c) pluginLink->HookEventParam(a, b, c)
- #define HookEventObj(a, b, c) pluginLink->HookEventObj(a, b, c)
- #define HookEventObjParam(a, b, c, d) pluginLink->HookEventObjParam(a, b, c, d)
- #define CreateServiceFunctionObj(a, b, c) pluginLink->CreateServiceFunctionObj(a, b, c)
- #define CreateServiceFunctionObjParam(a, b, c, d) pluginLink->CreateServiceFunctionObjParam(a, b, c, d)
- #define KillObjectServices(a) pluginLink->KillObjectServices(a)
- #define KillObjectEventHooks(a) pluginLink->KillObjectEventHooks(a)
- #endif
-#endif
-
/*
Database plugin stuff
*/
diff --git a/plugins/BasicHistory/zip/iowin32.c b/plugins/BasicHistory/zip/iowin32.c
index 6a2a883be7..e697b7154d 100644
--- a/plugins/BasicHistory/zip/iowin32.c
+++ b/plugins/BasicHistory/zip/iowin32.c
@@ -228,7 +228,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
ret = (ZPOS64_T)-1;
}
else
- ret=li.QuadPart;
+ ret = li.QuadPart;
}
return ret;
}
@@ -236,7 +236,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin)
{
- DWORD dwMoveMethod=0xFFFFFFFF;
+ DWORD dwMoveMethod = 0xFFFFFFFF;
HANDLE hFile = NULL;
long ret=-1;
diff --git a/plugins/Chat/chat.h b/plugins/Chat/chat.h
index ca73960017..b30f741da2 100644
--- a/plugins/Chat/chat.h
+++ b/plugins/Chat/chat.h
@@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_stdhdr.h>
+#include <shlobj.h>
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
diff --git a/plugins/Chat/options.cpp b/plugins/Chat/options.cpp
index f8def495a0..381054d5ca 100644
--- a/plugins/Chat/options.cpp
+++ b/plugins/Chat/options.cpp
@@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "resource.h"
#include "chat.h"
-#include <shlobj.h>
#include <m_fontservice.h>
diff --git a/plugins/Clist_classic/clistopts.cpp b/plugins/Clist_classic/clistopts.cpp
index 9a787df82b..83079d6d75 100644
--- a/plugins/Clist_classic/clistopts.cpp
+++ b/plugins/Clist_classic/clistopts.cpp
@@ -127,9 +127,9 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM) TranslateT("Global"));
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM) 0);
for (i = 0; i < count; i++) {
- if (!IsAccountEnabled(accs[i]) || CallProtoService( accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
+ if (!IsAccountEnabled(accs[i]) || CallProtoService( accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
continue;
- item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM) accs[i]->tszAccountName);
+ item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM) accs[i]->tszAccountName);
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM) accs[i]);
if (dbv.type == DBVT_ASCIIZ && !lstrcmpA(dbv.pszVal, accs[i]->szModuleName))
SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, item, 0);
diff --git a/plugins/Clist_modern/modern_aniavatars.cpp b/plugins/Clist_modern/modern_aniavatars.cpp
index ae57520fa2..9c6dbdcb35 100644
--- a/plugins/Clist_modern/modern_aniavatars.cpp
+++ b/plugins/Clist_modern/modern_aniavatars.cpp
@@ -209,8 +209,8 @@ int AniAva_InitModule()
RegisterClassEx(&wc);
}
InitializeCriticalSection(&AniAva.CS);
- AniAva.Objects=li.List_Create(0,2);
- AniAva.AniAvatarList=li.List_Create(0,1);
+ AniAva.Objects=List_Create(0,2);
+ AniAva.AniAvatarList=List_Create(0,1);
AniAva.AniAvatarList->sortFunc=_AniAva_SortAvatarInfo;
AniAva.bModuleStarted=TRUE;
AniAva.hExitEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
@@ -238,7 +238,7 @@ int AniAva_UnloadModule()
}
mir_free(AniAva.Objects->items[i]);
}
- li.List_Destroy(AniAva.Objects);
+ List_Destroy(AniAva.Objects);
mir_free(AniAva.Objects);
for (i=0; i<AniAva.AniAvatarList->realCount; i++)
@@ -248,7 +248,7 @@ int AniAva_UnloadModule()
if (aai->pFrameDelays) free(aai->pFrameDelays);
mir_free(aai);
}
- li.List_Destroy(AniAva.AniAvatarList);
+ List_Destroy(AniAva.AniAvatarList);
mir_free(AniAva.AniAvatarList);
_AniAva_RemoveAniAvaDC(&AniAva);
SetEvent(AniAva.hExitEvent);
@@ -328,7 +328,7 @@ int AniAva_AddAvatar(HANDLE hContact, TCHAR * szFilename, int width, int heigth)
pavi->hWindow = NULL;
pavi->hContact = hContact;
pavi->bInvalidPos = 0;
- li.List_Insert( AniAva.Objects, pavi, AniAva.Objects->realCount);
+ List_Insert( AniAva.Objects, pavi, AniAva.Objects->realCount);
}
//change avatar
pavi->bToBeDeleted=FALSE;
@@ -511,7 +511,7 @@ int AniAva_RemoveInvalidatedAvatars()
pai->hWindow=NULL;
if (!keepAvatar) _AniAva_RealRemoveAvatar(pai->dwAvatarUniqId);
mir_free(pai);
- li.List_Remove(AniAva.Objects,i);
+ List_Remove(AniAva.Objects,i);
i--;
}
}
@@ -635,7 +635,7 @@ static void _AniAva_RealRemoveAvatar(DWORD UniqueID)
#ifdef _DEBUG
__AniAva_DebugRenderStrip();
#endif
- li.List_Remove(AniAva.AniAvatarList, j);
+ List_Remove(AniAva.AniAvatarList, j);
mir_free(aai);
_AniAva_ResumePainting();
break;
@@ -671,7 +671,7 @@ static int _AniAva_LoadAvatarFromImage(TCHAR * szFileName, int width, int height
aai.FrameSize.cx=width;
aai.FrameSize.cy=height;
- if (!li.List_GetIndex(AniAva.AniAvatarList,(void*)&aai,&idx)) idx=-1;
+ if (!List_GetIndex(AniAva.AniAvatarList,(void*)&aai,&idx)) idx=-1;
if (idx==-1) //item not present in list
{
HBITMAP hBitmap=NULL;
@@ -749,8 +749,8 @@ static int _AniAva_LoadAvatarFromImage(TCHAR * szFileName, int width, int height
{
//add to list
int idx=AniAva.AniAvatarList->realCount;
- li.List_GetIndex(AniAva.AniAvatarList, paai,&idx);
- li.List_Insert(AniAva.AniAvatarList, (void*)paai, idx);
+ List_GetIndex(AniAva.AniAvatarList, paai,&idx);
+ List_Insert(AniAva.AniAvatarList, (void*)paai, idx);
}
return paai->dwAvatarUniqId;
}
@@ -1000,7 +1000,7 @@ static void _AniAva_ReduceAvatarImages(int startY, int dY, BOOL bDestroyWindow)
{
_AniAva_DestroyAvatarWindow(pai->hWindow);
mir_free(pai);
- li.List_Remove(AniAva.Objects,i);
+ List_Remove(AniAva.Objects,i);
i--;
}
}
diff --git a/plugins/Clist_modern/modern_cachefuncs.cpp b/plugins/Clist_modern/modern_cachefuncs.cpp
index 0a741adb90..444fef27d7 100644
--- a/plugins/Clist_modern/modern_cachefuncs.cpp
+++ b/plugins/Clist_modern/modern_cachefuncs.cpp
@@ -96,7 +96,7 @@ void CSmileyString::AddListeningToIcon(struct SHORTDATA *dat, PDNCE pdnce, TCHAR
int text_size = (int)_tcslen( szText );
- plText = li.List_Create( 0, 1 );
+ plText = List_Create( 0, 1 );
// Add Icon
{
@@ -126,7 +126,7 @@ void CSmileyString::AddListeningToIcon(struct SHORTDATA *dat, PDNCE pdnce, TCHAR
dat->text_smiley_height = max(piece->smiley_height, dat->text_smiley_height);
iMaxSmileyHeight = max(piece->smiley_height, iMaxSmileyHeight);
- li.List_Insert( plText, piece, plText->realCount);
+ List_Insert( plText, piece, plText->realCount);
}
// Add text
@@ -136,7 +136,7 @@ void CSmileyString::AddListeningToIcon(struct SHORTDATA *dat, PDNCE pdnce, TCHAR
piece->type = TEXT_PIECE_TYPE_TEXT;
piece->start_pos = 0;
piece->len = text_size;
- li.List_Insert( plText, piece, plText->realCount);
+ List_Insert( plText, piece, plText->realCount);
}
}
@@ -145,7 +145,7 @@ void CSmileyString::_CopySmileyList( SortedList *plInput )
// ASSERT( plText == NULL );
if ( !plInput || plInput->realCount == 0 ) return;
- plText=li.List_Create( 0, 1 );
+ plText=List_Create( 0, 1 );
for ( int i = 0; i < plInput->realCount; i++ )
{
ClcContactTextPiece *pieceFrom=(ClcContactTextPiece *) plInput->items[i];
@@ -155,7 +155,7 @@ void CSmileyString::_CopySmileyList( SortedList *plInput )
*piece=*pieceFrom;
if ( pieceFrom->type == TEXT_PIECE_TYPE_SMILEY)
piece->smiley = CopyIcon( pieceFrom->smiley );
- li.List_Insert( plText, piece, plText->realCount );
+ List_Insert( plText, piece, plText->realCount );
}
}
}
@@ -188,7 +188,7 @@ void CSmileyString::DestroySmileyList()
}
}
}
- li.List_Destroy( plText );
+ List_Destroy( plText );
}
mir_free(plText);
@@ -247,7 +247,7 @@ void CSmileyString::ReplaceSmileys(struct SHORTDATA *dat, PDNCE pdnce, TCHAR * s
}
// Lets add smileys
- plText = li.List_Create( 0, 1 );
+ plText = List_Create( 0, 1 );
for (unsigned i = 0; i < sp.numSmileys; ++i)
{
@@ -261,7 +261,7 @@ void CSmileyString::ReplaceSmileys(struct SHORTDATA *dat, PDNCE pdnce, TCHAR * s
piece->type = TEXT_PIECE_TYPE_TEXT;
piece->start_pos = last_pos ;//sp.str - text;
piece->len = spr[i].startChar - last_pos;
- li.List_Insert(plText, piece, plText->realCount);
+ List_Insert(plText, piece, plText->realCount);
}
// Add smiley
@@ -291,7 +291,7 @@ void CSmileyString::ReplaceSmileys(struct SHORTDATA *dat, PDNCE pdnce, TCHAR * s
dat->text_smiley_height = max( piece->smiley_height, dat->text_smiley_height );
iMaxSmileyHeight = max( piece->smiley_height, iMaxSmileyHeight );
- li.List_Insert(plText, piece, plText->realCount);
+ List_Insert(plText, piece, plText->realCount);
}
}
// Get next
@@ -308,7 +308,7 @@ void CSmileyString::ReplaceSmileys(struct SHORTDATA *dat, PDNCE pdnce, TCHAR * s
piece->start_pos = last_pos;
piece->len = text_size-last_pos;
- li.List_Insert(plText, piece, plText->realCount);
+ List_Insert(plText, piece, plText->realCount);
}
}
diff --git a/plugins/Clist_modern/modern_clc.cpp b/plugins/Clist_modern/modern_clc.cpp
index e4626ceb63..40cd285410 100644
--- a/plugins/Clist_modern/modern_clc.cpp
+++ b/plugins/Clist_modern/modern_clc.cpp
@@ -1781,7 +1781,7 @@ static LRESULT clcOnIntmIconChanged(struct ClcData *dat, HWND hwnd, UINT msg, WP
if (hSelItem) {
struct ClcGroup *selgroup;
if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL))
- dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, li.List_IndexOf(( SortedList* )&selgroup->cl, selcontact));
+ dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf(( SortedList* )&selgroup->cl, selcontact));
else
dat->selection = -1;
}
diff --git a/plugins/Clist_modern/modern_clcitems.cpp b/plugins/Clist_modern/modern_clcitems.cpp
index 89e0395129..0ceff512f9 100644
--- a/plugins/Clist_modern/modern_clcitems.cpp
+++ b/plugins/Clist_modern/modern_clcitems.cpp
@@ -345,11 +345,11 @@ int RestoreSelection( struct ClcData *dat, HANDLE hSelected )
if ( !selcontact->isSubcontact )
{
- dat->selection = pcli->pfnGetRowsPriorTo( &dat->list, selgroup, li.List_IndexOf((SortedList*)&selgroup->cl, selcontact ));
+ dat->selection = pcli->pfnGetRowsPriorTo( &dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact ));
}
else
{
- dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, li.List_IndexOf((SortedList*)&selgroup->cl, selcontact->subcontacts ));
+ dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact->subcontacts ));
if (dat->selection != -1 )
dat->selection += selcontact->isSubcontact;
diff --git a/plugins/Clist_modern/modern_clcmsgs.cpp b/plugins/Clist_modern/modern_clcmsgs.cpp
index 6a444d32ac..872b24c6c4 100644
--- a/plugins/Clist_modern/modern_clcmsgs.cpp
+++ b/plugins/Clist_modern/modern_clcmsgs.cpp
@@ -122,7 +122,7 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd,struct ClcData *dat,UINT msg,WPARA
if (wParam != CLGN_ROOT) {
if (!pcli->pfnFindItem(hwnd, dat, (HANDLE) lParam, &contact, &group, NULL))
return (LRESULT) (HANDLE) NULL;
- i = li.List_IndexOf((SortedList*)&group->cl,contact);
+ i = List_IndexOf((SortedList*)&group->cl,contact);
if (i<0) return 0;
}
switch (wParam)
@@ -204,12 +204,12 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd,struct ClcData *dat,UINT msg,WPARA
if (!contact->isSubcontact)
{
- index=li.List_IndexOf((SortedList*)&group->cl,contact);
+ index=List_IndexOf((SortedList*)&group->cl,contact);
mainindex=index;
}
else
{
- index=li.List_IndexOf((SortedList*)&group->cl,contact->subcontacts);
+ index=List_IndexOf((SortedList*)&group->cl,contact->subcontacts);
mainindex=index;
index+=contact->isSubcontact;
}
diff --git a/plugins/Clist_modern/modern_clistsettings.cpp b/plugins/Clist_modern/modern_clistsettings.cpp
index 759b1ed8e3..9a7bacff7a 100644
--- a/plugins/Clist_modern/modern_clistsettings.cpp
+++ b/plugins/Clist_modern/modern_clistsettings.cpp
@@ -68,7 +68,7 @@ void InitDisplayNameCache(void)
int i=0;
InitCacheAsync();
InitAwayMsgModule();
- clistCache = li.List_Create( 0, 50 );
+ clistCache = List_Create( 0, 50 );
clistCache->sortFunc = handleCompare;
}
void FreeDisplayNameCache()
@@ -82,7 +82,7 @@ void FreeDisplayNameCache()
mir_free_and_nill( clistCache->items[i] );
}
- li.List_Destroy( clistCache );
+ List_Destroy( clistCache );
mir_free_and_nill(clistCache);
clistCache = NULL;
}
@@ -94,9 +94,9 @@ ClcCacheEntryBase* cliGetCacheEntry(HANDLE hContact)
ClcCacheEntryBase* p;
int idx;
if (!clistCache) return NULL;
- if ( !li.List_GetIndex( clistCache, &hContact, &idx )) {
+ if ( !List_GetIndex( clistCache, &hContact, &idx )) {
if (( p = pcli->pfnCreateCacheItem( hContact )) != NULL ) {
- li.List_Insert( clistCache, p, idx );
+ List_Insert( clistCache, p, idx );
pcli->pfnInvalidateDisplayNameCacheEntry( hContact );
}
}
@@ -246,7 +246,7 @@ void FreeDisplayNameCache(SortedList *list)
FreeDisplayNameCacheItem(( pdisplayNameCacheEntry )list->items[i] );
mir_free_and_nill(list->items[i]);
}
- li.List_Destroy(list);
+ List_Destroy(list);
}
*/
diff --git a/plugins/Clist_modern/modern_commonheaders.cpp b/plugins/Clist_modern/modern_commonheaders.cpp
index eb78d351c7..4cf9009138 100644
--- a/plugins/Clist_modern/modern_commonheaders.cpp
+++ b/plugins/Clist_modern/modern_commonheaders.cpp
@@ -316,7 +316,7 @@ void li_ListDestruct(SortedList *pList, ItemDestuctor pItemDestructor)
int i=0;
if (!pList) return;
for (i=0; i<pList->realCount; i++) pItemDestructor(pList->items[i]);
- li.List_Destroy(pList);
+ List_Destroy(pList);
mir_free(pList);
}
@@ -325,13 +325,13 @@ void li_RemoveDestruct(SortedList *pList, int index, ItemDestuctor pItemDestruct
if (index>=0 && index<pList->realCount)
{
pItemDestructor(pList->items[index]);
- li.List_Remove(pList, index);
+ List_Remove(pList, index);
}
}
void li_RemovePtrDestruct(SortedList *pList, void * ptr, ItemDestuctor pItemDestructor)
{
- if (li.List_RemovePtr(pList, ptr))
+ if (List_RemovePtr(pList, ptr))
pItemDestructor(ptr);
}
diff --git a/plugins/Clist_modern/modern_skinengine.cpp b/plugins/Clist_modern/modern_skinengine.cpp
index 7753867a9f..b9b9f8dbaf 100644
--- a/plugins/Clist_modern/modern_skinengine.cpp
+++ b/plugins/Clist_modern/modern_skinengine.cpp
@@ -526,7 +526,7 @@ int SkinEngineUnloadModule()
EFFECTSSTACKITEM * effect=(EFFECTSSTACKITEM*)(pEffectStack->items[i]);
mir_free_and_nill(effect);
}
- li.List_Destroy(pEffectStack);
+ List_Destroy(pEffectStack);
mir_free_and_nill(pEffectStack);
}
if (g_pCachedWindow)
@@ -623,7 +623,7 @@ HDC ske_RequestBufferDC(HDC hdcOwner, int dcID, int width, int height, BOOL fCle
DCBUFFER * pBuf;
if (BufferList==NULL)
{
- BufferList=li.List_Create(0,2);
+ BufferList=List_Create(0,2);
BufferList->sortFunc=SortBufferList;
InitializeCriticalSection(&BufferListCS);
}
@@ -632,7 +632,7 @@ HDC ske_RequestBufferDC(HDC hdcOwner, int dcID, int width, int height, BOOL fCle
buf.hdcOwnedBy=hdcOwner;
buf.nUsageID=dcID;
buf.hDC=NULL;
- pBuf=(DCBUFFER*)li.List_Find(BufferList,(void*)&buf);
+ pBuf=(DCBUFFER*)List_Find(BufferList,(void*)&buf);
if (!pBuf)
{
//if not found - allocate it
@@ -644,7 +644,7 @@ HDC ske_RequestBufferDC(HDC hdcOwner, int dcID, int width, int height, BOOL fCle
pBuf->hDC=CreateCompatibleDC(hdcOwner);
pBuf->oldBitmap=(HBITMAP)SelectObject(pBuf->hDC,pBuf->hBitmap);
pBuf->dwDestroyAfterTime=0;
- li.List_InsertPtr(BufferList,pBuf);
+ List_InsertPtr(BufferList,pBuf);
}
else
{
@@ -690,7 +690,7 @@ int ske_ReleaseBufferDC(HDC hDC, int keepTime)
DeleteObject(pBuf->hBitmap);
DeleteDC(pBuf->hDC);
mir_free(pBuf);
- li.List_Remove(BufferList,i);
+ List_Remove(BufferList,i);
i--;
}
}
@@ -2191,13 +2191,13 @@ int ske_UnloadSkin(SKINOBJECTSLIST * Skin)
mir_free_and_nill(sf);
}
}
- li.List_Destroy(gl_plSkinFonts);
+ List_Destroy(gl_plSkinFonts);
mir_free_and_nill(gl_plSkinFonts);
}
}
if (Skin->szSkinPlace) mir_free_and_nill(Skin->szSkinPlace);
- if (Skin->pTextList) li.List_Destroy(Skin->pTextList);
+ if (Skin->pTextList) List_Destroy(Skin->pTextList);
mir_free_and_nill(Skin->pTextList);
ModernSkinButtonDeleteAll();
if (Skin->dwObjLPAlocated==0) { ske_UnlockSkin(); return 0;}
@@ -2229,7 +2229,7 @@ int ske_UnloadSkin(SKINOBJECTSLIST * Skin)
mir_free_and_nill(gt);
}
}
- li.List_Destroy(dt->plTextList);
+ List_Destroy(dt->plTextList);
mir_free_and_nill(dt->plTextList);
}
}
@@ -2328,10 +2328,10 @@ static void ske_LinkSkinObjects(SKINOBJECTSLIST * pObjectList)
{
if (!globj->plTextList)
{
- globj->plTextList=li.List_Create(0,1);
+ globj->plTextList=List_Create(0,1);
globj->plTextList->sortFunc=ske_SortTextGlyphObjectFunc;
}
- li.List_Insert(globj->plTextList,(void*)glText,globj->plTextList->realCount);
+ List_Insert(globj->plTextList,(void*)glText,globj->plTextList->realCount);
qsort(globj->plTextList->items,globj->plTextList->realCount,sizeof(void*),(int(*)(const void*, const void*))globj->plTextList->sortFunc);
pObjectList->pTextList->items[i]=NULL;
}
@@ -2348,7 +2348,7 @@ static void ske_LinkSkinObjects(SKINOBJECTSLIST * pObjectList)
}
}
}
- li.List_Destroy(pObjectList->pTextList);
+ List_Destroy(pObjectList->pTextList);
mir_free_and_nill(pObjectList->pTextList);
}
}
@@ -2754,7 +2754,7 @@ BOOL ske_ResetTextEffect(HDC hdc)
{
EFFECTSSTACKITEM * effect=(EFFECTSSTACKITEM*)(pEffectStack->items[i]);
mir_free_and_nill(effect);
- li.List_Remove(pEffectStack,i);
+ List_Remove(pEffectStack,i);
return TRUE;
}
return FALSE;
@@ -2766,7 +2766,7 @@ BOOL ske_SelectTextEffect(HDC hdc, BYTE EffectID, DWORD FirstColor, DWORD Second
if (EffectID==-1) return ske_ResetTextEffect(hdc);
if (!pEffectStack)
{
- pEffectStack=li.List_Create(0,1);
+ pEffectStack=List_Create(0,1);
}
{
int i;
@@ -2786,7 +2786,7 @@ BOOL ske_SelectTextEffect(HDC hdc, BYTE EffectID, DWORD FirstColor, DWORD Second
effect->EffectID=EffectID;
effect->FirstColor=FirstColor;
effect->SecondColor=SecondColor;
- li.List_Insert(pEffectStack, effect, 0);
+ List_Insert(pEffectStack, effect, 0);
return TRUE;
}
return FALSE;
@@ -4359,7 +4359,7 @@ static void OLDske_AddParseTextGlyphObject(char * szGlyphTextID,char * szDefineS
if (!globj->plTextList)
{
- globj->plTextList=li.List_Create(0,1);
+ globj->plTextList=List_Create(0,1);
globj->plTextList->sortFunc=ske_SortTextGlyphObjectFunc;
}
glText=(GLYPHTEXT*)mir_calloc(sizeof(GLYPHTEXT));
@@ -4387,7 +4387,7 @@ static void OLDske_AddParseTextGlyphObject(char * szGlyphTextID,char * szDefineS
glText->dwShadow=ske_HexToARGB(GetParamN(szDefineString,buf,sizeof(buf),8,',',TRUE));
glText->stValueText=mir_a2u(GetParamN(szDefineString,buf,sizeof(buf),9,',',TRUE));
glText->stText=ske_ParseText(glText->stValueText);
- li.List_Insert(globj->plTextList,(void*)glText,globj->plTextList->realCount);
+ List_Insert(globj->plTextList,(void*)glText,globj->plTextList->realCount);
qsort(globj->plTextList->items,globj->plTextList->realCount,sizeof(void*),(int(*)(const void*, const void*))globj->plTextList->sortFunc);
}
}
@@ -4428,8 +4428,8 @@ static void ske_AddParseTextGlyphObject(char * szGlyphTextID,char * szDefineStri
glText->stText=ske_ParseText(glText->stValueText);
if (!Skin->pTextList)
- Skin->pTextList=li.List_Create(0,1);
- li.List_InsertPtr(Skin->pTextList,glText);
+ Skin->pTextList=List_Create(0,1);
+ List_InsertPtr(Skin->pTextList,glText);
}
}
@@ -4477,10 +4477,10 @@ static void ske_AddParseSkinFont(char * szFontID,char * szDefineString,SKINOBJEC
{
sf->szFontID=mir_strdup(szFontID);
if (!gl_plSkinFonts)
- gl_plSkinFonts=li.List_Create(0,1);
+ gl_plSkinFonts=List_Create(0,1);
if (gl_plSkinFonts)
{
- li.List_Insert(gl_plSkinFonts,(void*)sf,gl_plSkinFonts->realCount);
+ List_Insert(gl_plSkinFonts,(void*)sf,gl_plSkinFonts->realCount);
}
}
diff --git a/plugins/Clist_modern/modern_toolbar.cpp b/plugins/Clist_modern/modern_toolbar.cpp
index 7720bae7fd..56078d03cc 100644
--- a/plugins/Clist_modern/modern_toolbar.cpp
+++ b/plugins/Clist_modern/modern_toolbar.cpp
@@ -192,7 +192,7 @@ HRESULT ToolbarLoadModule()
RegisterClass(&wndclass);
}
}
- tbdat.listOfButtons=li.List_Create(0,1);
+ tbdat.listOfButtons=List_Create(0,1);
InitializeCriticalSection(&tbdat.cs);
return S_OK;
}
@@ -322,7 +322,7 @@ static INT_PTR svcToolBarAddButton(WPARAM wParam, LPARAM lParam)
mtbi->bVisible = bVisible;
mtbi->bPanelID = bPanel;
- li.List_InsertPtr(tbdat.listOfButtons,mtbi);
+ List_InsertPtr(tbdat.listOfButtons,mtbi);
if (mtbi->bVisible)
result=(INT_PTR)ToolBar_AddButtonToBars(mtbi);
@@ -798,7 +798,7 @@ static LRESULT CALLBACK ToolBar_WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM
pMTBInfo->wLastHeight=Frame.height;
pMTBInfo->nLineCount = 1;
- pMTBInfo->pButtonList=li.List_Create(0,1);
+ pMTBInfo->pButtonList=List_Create(0,1);
Frame.name=(char*) lpcs->lpCreateParams;
hFrame=(HANDLE)CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&Frame,(LPARAM)0);
@@ -879,7 +879,7 @@ static LRESULT CALLBACK ToolBar_WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM
xpt_FreeThemeForWindow(hwnd);
WindowList_Remove( tbdat.hToolBarWindowList, hwnd );
SendMessage(hwnd, MTBM_REMOVE_ALL_BUTTONS, 0, 0 );
- li.List_Destroy( pMTBInfo->pButtonList );
+ List_Destroy( pMTBInfo->pButtonList );
mir_free( pMTBInfo->pButtonList );
SetWindowLongPtr( hwnd, GWLP_USERDATA, 0 );
mir_free( pMTBInfo );
@@ -902,7 +902,7 @@ static LRESULT CALLBACK ToolBar_WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM
mtbi->hWindow=hwndButton;
mtbi->hwndToolBar=hwnd;
- li.List_Insert(pMTBInfo->pButtonList, mtbi, pMTBInfo->pButtonList->realCount); //just insert pointer. such object are managed in global tbbutton list
+ List_Insert(pMTBInfo->pButtonList, mtbi, pMTBInfo->pButtonList->realCount); //just insert pointer. such object are managed in global tbbutton list
if (hwndButton)
{
char * buttonId=(char *)_alloca(sizeof("ToolBar.")+strlen(mtbi->szButtonID)+2);
@@ -930,9 +930,9 @@ static LRESULT CALLBACK ToolBar_WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM
mtbi->hwndToolBar = NULL;
}
}
- li.List_Destroy( pMTBInfo->pButtonList );
+ List_Destroy( pMTBInfo->pButtonList );
mir_free( pMTBInfo->pButtonList );
- pMTBInfo->pButtonList=li.List_Create(0,1);
+ pMTBInfo->pButtonList=List_Create(0,1);
break;
}
case WM_SIZE:
@@ -1072,14 +1072,14 @@ static LRESULT CALLBACK ToolBar_WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM
mtbi=(MTB_BUTTONINFO*)pMTBInfo->pButtonList->items[i];
if (mtbi==(MTB_BUTTONINFO*)wParam)
{
- li.List_Remove(pMTBInfo->pButtonList,i);
+ List_Remove(pMTBInfo->pButtonList,i);
for (int j=0; j<tbdat.listOfButtons->realCount; j++)
if (mtbi==(MTB_BUTTONINFO*)tbdat.listOfButtons->items[j])
{
- li.List_Remove(tbdat.listOfButtons,j);
+ List_Remove(tbdat.listOfButtons,j);
break;
}
- li.List_RemovePtr(tbdat.listOfButtons,mtbi);
+ List_RemovePtr(tbdat.listOfButtons,mtbi);
delete_MTB_BUTTONINFO((void*)mtbi);
mtbi=NULL;
pcli->pfnInvalidateRect(hwnd, NULL, FALSE);
diff --git a/plugins/Clist_modern/modern_xptheme.cpp b/plugins/Clist_modern/modern_xptheme.cpp
index 599cb55010..53b9b7541e 100644
--- a/plugins/Clist_modern/modern_xptheme.cpp
+++ b/plugins/Clist_modern/modern_xptheme.cpp
@@ -87,7 +87,7 @@ HRESULT XPThemesLoadModule()
if (_xpt_ThemeSupport())
{
InitializeCriticalSection(&xptCS);
- xptObjectList=li.List_Create(0,1);
+ xptObjectList=List_Create(0,1);
xptModuleLoaded=TRUE;
}
return S_OK;
@@ -126,7 +126,7 @@ BOOL xpt_IsValidHandle(XPTHANDLE xptHandle)
if (!xptHandle) return FALSE;
xptlock();
{
- if (li.List_IndexOf(xptObjectList, (void*)xptHandle)!=-1)
+ if (List_IndexOf(xptObjectList, (void*)xptHandle)!=-1)
res=TRUE;
}
xptunlock();
@@ -143,7 +143,7 @@ XPTHANDLE xpt_AddThemeHandle(HWND hwnd, LPCWSTR className)
xptObject->lpcwClassObject=className;
xptObject->hOwnerWindow=hwnd;
_sttXptReloadThemeData(xptObject);
- li.List_InsertPtr(xptObjectList, (void*)xptObject);
+ List_InsertPtr(xptObjectList, (void*)xptObject);
res=(XPTHANDLE)xptObject;
}
xptunlock();
@@ -159,7 +159,7 @@ void xpt_FreeThemeHandle(XPTHANDLE xptHandle)
XPTObject* xptObject=(XPTObject*)xptHandle;
_sttXptCloseThemeData(xptObject);
_sttXptObjectDestructor((void *) xptHandle);
- li.List_Remove(xptObjectList, li.List_IndexOf(xptObjectList,(void *) xptHandle));
+ List_Remove(xptObjectList, List_IndexOf(xptObjectList,(void *) xptHandle));
}
xptunlock();
}
@@ -176,7 +176,7 @@ void xpt_FreeThemeForWindow(HWND hwnd)
{
_sttXptCloseThemeData(xptObject);
_sttXptObjectDestructor((void *) xptObject);
- li.List_Remove(xptObjectList, i);
+ List_Remove(xptObjectList, i);
}
else
i++;
diff --git a/plugins/Clist_mw/clc.cpp b/plugins/Clist_mw/clc.cpp
index 4975eda998..d238f5a6bb 100644
--- a/plugins/Clist_mw/clc.cpp
+++ b/plugins/Clist_mw/clc.cpp
@@ -199,7 +199,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
if (hSelItem) {
struct ClcGroup *selgroup;
if (FindItem(hwnd,dat,hSelItem,&selcontact,&selgroup,NULL))
- dat->selection = GetRowsPriorTo(&dat->list,selgroup,li.List_IndexOf((SortedList*)&selgroup->cl, selcontact));
+ dat->selection = GetRowsPriorTo(&dat->list,selgroup,List_IndexOf((SortedList*)&selgroup->cl, selcontact));
else
dat->selection = -1;
}
diff --git a/plugins/Clist_mw/clcidents.cpp b/plugins/Clist_mw/clcidents.cpp
index 1cc940db2b..58517fa8c0 100644
--- a/plugins/Clist_mw/clcidents.cpp
+++ b/plugins/Clist_mw/clcidents.cpp
@@ -87,16 +87,16 @@ pdisplayNameCacheEntry GetCLCFullCacheEntry(struct ClcData *dat,HANDLE hContact)
displayNameCacheEntry dnce;
dnce.hContact = hContact;
- displayNameCacheEntry *pdnce = (displayNameCacheEntry*)li.List_Find(&dat->lCLCContactsCache,&dnce);
+ displayNameCacheEntry *pdnce = (displayNameCacheEntry*)List_Find(&dat->lCLCContactsCache,&dnce);
if (pdnce == NULL) {
pdnce = (displayNameCacheEntry*)mir_calloc(sizeof(displayNameCacheEntry));
pdnce->hContact = hContact;
int idx;
- li.List_GetIndex(&dat->lCLCContactsCache,pdnce,&idx);
- li.List_Insert(&dat->lCLCContactsCache,pdnce,idx);
+ List_GetIndex(&dat->lCLCContactsCache,pdnce,&idx);
+ List_Insert(&dat->lCLCContactsCache,pdnce,idx);
- displayNameCacheEntry *pdnce2 = (displayNameCacheEntry*)li.List_Find(&dat->lCLCContactsCache,&dnce);//for check
+ displayNameCacheEntry *pdnce2 = (displayNameCacheEntry*)List_Find(&dat->lCLCContactsCache,&dnce);//for check
if (pdnce2->hContact != pdnce->hContact)
return NULL;
diff --git a/plugins/Clist_mw/clistsettings.cpp b/plugins/Clist_mw/clistsettings.cpp
index 25206e86ba..fcfbb58992 100644
--- a/plugins/Clist_mw/clistsettings.cpp
+++ b/plugins/Clist_mw/clistsettings.cpp
@@ -53,8 +53,8 @@ void InitDisplayNameCache(SortedList *list)
displayNameCacheEntry *pdnce = (pdisplayNameCacheEntry)mir_calloc(sizeof(displayNameCacheEntry));
pdnce->hContact = hContact;
InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,0);
- li.List_GetIndex(list,pdnce,&idx);
- li.List_Insert(list,pdnce,idx);
+ List_GetIndex(list,pdnce,&idx);
+ List_Insert(list,pdnce,idx);
hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
i++;
} }
@@ -77,7 +77,7 @@ void FreeDisplayNameCache(SortedList *list)
mir_free(list->items[i]);
}
- li.List_Destroy(list);
+ List_Destroy(list);
}
void CheckPDNCE(ClcCacheEntryBase *_pdnce)
diff --git a/plugins/Clist_nicer/INCLUDE/clc.h b/plugins/Clist_nicer/INCLUDE/clc.h
index fb412f46a5..27cb5d9a62 100644
--- a/plugins/Clist_nicer/INCLUDE/clc.h
+++ b/plugins/Clist_nicer/INCLUDE/clc.h
@@ -533,9 +533,6 @@ void ClearIcons(int mode);
void SkinDrawBg(HWND hwnd, HDC hdc);
int GetBasicFontID(struct ClcContact * contact);
extern int __fastcall CLVM_GetContactHiddenStatus(HANDLE hContact, char *szStatus, struct ClcData *dat);
-void Utf8Decode( char* str, wchar_t** ucs2 );
-char* Utf8Encode( const char* src );
-//int _DebugPopup(HANDLE hContact, const char *fmt, ...);
void CreateViewModeFrame();
int GetExtraCache(HANDLE hContact, char *szProto);
void ReloadExtraInfo(HANDLE hContact);
diff --git a/plugins/Clist_nicer/SRC/clc.cpp b/plugins/Clist_nicer/SRC/clc.cpp
index 439221be8d..17af82664b 100644
--- a/plugins/Clist_nicer/SRC/clc.cpp
+++ b/plugins/Clist_nicer/SRC/clc.cpp
@@ -404,7 +404,7 @@ LBL_Def:
if (hSelItem) {
struct ClcGroup *selgroup;
if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL))
- dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, li.List_IndexOf((SortedList*) & selgroup->cl, selcontact));
+ dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*) & selgroup->cl, selcontact));
else
dat->selection = -1;
}
@@ -573,7 +573,7 @@ LBL_Def:
if (contact == 0 || group == 0)
break;
- iItem = pcli->pfnGetRowsPriorTo(&dat->list, group, li.List_IndexOf((SortedList*) & group->cl, contact));
+ iItem = pcli->pfnGetRowsPriorTo(&dat->list, group, List_IndexOf((SortedList*) & group->cl, contact));
pcli->pfnInvalidateItem(hwnd, dat, iItem);
goto LBL_Def;
}
diff --git a/plugins/ContactsPlus/utils.cpp b/plugins/ContactsPlus/utils.cpp
index 43e8bed305..3bf63cf139 100644
--- a/plugins/ContactsPlus/utils.cpp
+++ b/plugins/ContactsPlus/utils.cpp
@@ -213,18 +213,6 @@ int DBWriteContactSettingStringT(HANDLE hContact, const char *szModule, const ch
-int __fastcall SRCTranslateDialog(HWND hwndDlg)
-{
- LANGPACKTRANSLATEDIALOG lptd;
-
- lptd.cbSize=sizeof(lptd);
- lptd.flags=0;
- lptd.hwndDlg=hwndDlg;
- lptd.ignoreControls=NULL;
- return CallService(MS_LANGPACK_TRANSLATEDIALOG,0,(LPARAM)&lptd);
-}
-
-
void DialogAddContactExecute(HWND hwndDlg, HANDLE hNewContact)
{
ADDCONTACTSTRUCT acs={0};
diff --git a/plugins/Db3x/dbcontacts.cpp b/plugins/Db3x/dbcontacts.cpp
index 2918ba122b..ef128a491e 100644
--- a/plugins/Db3x/dbcontacts.cpp
+++ b/plugins/Db3x/dbcontacts.cpp
@@ -99,7 +99,7 @@ static INT_PTR FindNextContact(WPARAM wParam,LPARAM lParam)
VLtemp.hContact = (HANDLE)wParam;
EnterCriticalSection(&csDbAccess);
while ( VLtemp.hContact ) {
- if ( li.List_GetIndex(&lContacts,&VLtemp,&index)) {
+ if ( List_GetIndex(&lContacts,&VLtemp,&index)) {
VL = ( DBCachedContactValueList* )lContacts.items[index];
if (VL->hNext != NULL) {
if (!lParam || CheckProto(VL->hNext,(const char*)lParam)) {
@@ -118,7 +118,7 @@ static INT_PTR FindNextContact(WPARAM wParam,LPARAM lParam)
if ( VL == NULL ) {
VL = (DBCachedContactValueList*)HeapAlloc(hCacheHeap,HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
VL->hContact = VLtemp.hContact;
- li.List_Insert(&lContacts,VL,index);
+ List_Insert(&lContacts,VL,index);
}
VL->hNext = (HANDLE)dbc->ofsNext;
if (VL->hNext != NULL && (!lParam || CheckProto(VL->hNext,(const char*)lParam))) {
@@ -160,7 +160,7 @@ static INT_PTR DeleteContact(WPARAM wParam,LPARAM lParam)
{ DBCachedContactValueList VLtemp;
VLtemp.hContact = (HANDLE)wParam;
- if ( li.List_GetIndex(&lContacts,&VLtemp,&index))
+ if ( List_GetIndex(&lContacts,&VLtemp,&index))
{
DBCachedContactValueList *VL = ( DBCachedContactValueList* )lContacts.items[index];
DBCachedContactValue* V = VL->first;
@@ -173,7 +173,7 @@ static INT_PTR DeleteContact(WPARAM wParam,LPARAM lParam)
}
HeapFree( hCacheHeap, 0, VL );
- li.List_Remove(&lContacts,index);
+ List_Remove(&lContacts,index);
} }
dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
@@ -214,7 +214,7 @@ static INT_PTR DeleteContact(WPARAM wParam,LPARAM lParam)
{
DBCachedContactValueList VLtemp;
VLtemp.hContact = (HANDLE)ofsThis;
- if ( li.List_GetIndex(&lContacts,&VLtemp,&index))
+ if ( List_GetIndex(&lContacts,&VLtemp,&index))
{
DBCachedContactValueList *VL = ( DBCachedContactValueList* )lContacts.items[index];
VL->hNext = ( HANDLE )ofsNext;
@@ -257,8 +257,8 @@ static INT_PTR AddContact(WPARAM wParam,LPARAM lParam)
DBCachedContactValueList *VL = (DBCachedContactValueList*)HeapAlloc(hCacheHeap,HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
VL->hContact = (HANDLE)ofsNew;
- li.List_GetIndex(&lContacts,VL,&index);
- li.List_Insert(&lContacts,VL,index);
+ List_GetIndex(&lContacts,VL,&index);
+ List_Insert(&lContacts,VL,index);
}
LeaveCriticalSection(&csDbAccess);
@@ -277,7 +277,7 @@ static INT_PTR IsDbContact(WPARAM wParam,LPARAM lParam)
int index;
DBCachedContactValueList VLtemp,*VL;
VLtemp.hContact = (HANDLE)wParam;
- if ( li.List_GetIndex(&lContacts,&VLtemp,&index))
+ if ( List_GetIndex(&lContacts,&VLtemp,&index))
ret = TRUE;
else {
dbc=*(struct DBContact*)DBRead(ofsContact,sizeof(struct DBContact),NULL);
@@ -286,7 +286,7 @@ static INT_PTR IsDbContact(WPARAM wParam,LPARAM lParam)
if (ret) {
VL = (DBCachedContactValueList*)HeapAlloc(hCacheHeap,HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
VL->hContact = (HANDLE)wParam;
- li.List_Insert(&lContacts,VL,index);
+ List_Insert(&lContacts,VL,index);
} } }
LeaveCriticalSection(&csDbAccess);
diff --git a/plugins/Db3x/dbsettings.cpp b/plugins/Db3x/dbsettings.cpp
index c9cd3d01f7..ad7e470650 100644
--- a/plugins/Db3x/dbsettings.cpp
+++ b/plugins/Db3x/dbsettings.cpp
@@ -91,7 +91,7 @@ static char* InsertCachedSetting( const char* szName, size_t cbNameLen, int inde
char* newValue = (char*)HeapAlloc( hCacheHeap, 0, cbNameLen );
*newValue = 0;
strcpy(newValue+1,szName+1);
- li.List_Insert(&lSettings,newValue,index);
+ List_Insert(&lSettings,newValue,index);
return newValue;
}
@@ -108,7 +108,7 @@ static char* GetCachedSetting(const char *szModuleName,const char *szSettingName
if (lastsetting && strcmp(szFullName+1,lastsetting) == 0)
return lastsetting;
- if ( li.List_GetIndex(&lSettings, szFullName, &index))
+ if ( List_GetIndex(&lSettings, szFullName, &index))
lastsetting = (char*)lSettings.items[index] + 1;
else
lastsetting = InsertCachedSetting( szFullName, moduleNameLen+settingNameLen+3, index )+1;
@@ -150,11 +150,11 @@ static DBVARIANT* GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllo
if ( hContact == 0 ) {
DBCachedGlobalValue Vtemp, *V;
Vtemp.name = szSetting;
- if ( li.List_GetIndex(&lGlobalSettings,&Vtemp,&index)) {
+ if ( List_GetIndex(&lGlobalSettings,&Vtemp,&index)) {
V = (DBCachedGlobalValue*)lGlobalSettings.items[index];
if ( bAllocate == -1 ) {
FreeCachedVariant( &V->value );
- li.List_Remove(&lGlobalSettings,index);
+ List_Remove(&lGlobalSettings,index);
HeapFree(hCacheHeap,0,V);
return NULL;
} }
@@ -164,7 +164,7 @@ static DBVARIANT* GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllo
V = (DBCachedGlobalValue*)HeapAlloc(hCacheHeap,HEAP_ZERO_MEMORY,sizeof(DBCachedGlobalValue));
V->name = szSetting;
- li.List_Insert(&lGlobalSettings,V,index);
+ List_Insert(&lGlobalSettings,V,index);
}
return &V->value;
@@ -174,7 +174,7 @@ static DBVARIANT* GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllo
DBCachedContactValueList VLtemp,*VL;
VLtemp.hContact=hContact;
- if ( li.List_GetIndex(&lContacts,&VLtemp,&index)) {
+ if ( List_GetIndex(&lContacts,&VLtemp,&index)) {
VL = (DBCachedContactValueList*)lContacts.items[index];
}
else {
@@ -183,7 +183,7 @@ static DBVARIANT* GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllo
VL = (DBCachedContactValueList*)HeapAlloc(hCacheHeap,HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
VL->hContact = hContact;
- li.List_Insert(&lContacts,VL,index);
+ List_Insert(&lContacts,VL,index);
}
for ( V = VL->first; V != NULL; V = V->next)
@@ -501,7 +501,7 @@ static INT_PTR SetSettingResident(WPARAM wParam,LPARAM lParam)
strcpy( szTemp+1, ( char* )lParam );
EnterCriticalSection(&csDbAccess);
- if ( !li.List_GetIndex( &lSettings, szTemp, &idx ))
+ if ( !List_GetIndex( &lSettings, szTemp, &idx ))
szSetting = InsertCachedSetting( szTemp, cbSettingNameLen+2, idx );
else
szSetting = (char *)lSettings.items[idx];
@@ -968,7 +968,7 @@ int InitSettings(void)
void UninitSettings(void)
{
HeapDestroy(hCacheHeap);
- li.List_Destroy(&lContacts);
- li.List_Destroy(&lSettings);
- li.List_Destroy(&lGlobalSettings);
+ List_Destroy(&lContacts);
+ List_Destroy(&lSettings);
+ List_Destroy(&lGlobalSettings);
}
diff --git a/plugins/Db3x_mmap/dbcontacts.cpp b/plugins/Db3x_mmap/dbcontacts.cpp
index 51e533266d..0afd3469ab 100644
--- a/plugins/Db3x_mmap/dbcontacts.cpp
+++ b/plugins/Db3x_mmap/dbcontacts.cpp
@@ -62,8 +62,8 @@ DBCachedContactValueList* AddToCachedContactList(HANDLE hContact, int index)
DBCachedContactValueList* VL;
VL = (DBCachedContactValueList*)HeapAlloc(hCacheHeap,HEAP_ZERO_MEMORY,sizeof(DBCachedContactValueList));
VL->hContact = hContact;
- if (index == -1) li.List_GetIndex(&lContacts,VL,&index);
- li.List_Insert(&lContacts,VL,index);
+ if (index == -1) List_GetIndex(&lContacts,VL,&index);
+ List_Insert(&lContacts,VL,index);
return VL;
}
@@ -115,7 +115,7 @@ static INT_PTR FindNextContact(WPARAM wParam,LPARAM lParam)
VLtemp.hContact = (HANDLE)wParam;
EnterCriticalSection(&csDbAccess);
while(VLtemp.hContact) {
- if ( li.List_GetIndex(&lContacts,&VLtemp,&index)) {
+ if ( List_GetIndex(&lContacts,&VLtemp,&index)) {
VL = ( DBCachedContactValueList* )lContacts.items[index];
if (VL->hNext != NULL) {
if (!lParam || CheckProto(VL->hNext,(const char*)lParam)) {
@@ -174,7 +174,7 @@ static INT_PTR DeleteContact(WPARAM wParam,LPARAM lParam)
{ DBCachedContactValueList VLtemp;
VLtemp.hContact = (HANDLE)wParam;
- if ( li.List_GetIndex(&lContacts,&VLtemp,&index))
+ if ( List_GetIndex(&lContacts,&VLtemp,&index))
{
DBCachedContactValueList *VL = ( DBCachedContactValueList* )lContacts.items[index];
DBCachedContactValue* V = VL->first;
@@ -188,7 +188,7 @@ static INT_PTR DeleteContact(WPARAM wParam,LPARAM lParam)
if (VLtemp.hContact == hLastCachedContact)
hLastCachedContact = NULL;
- li.List_Remove(&lContacts,index);
+ List_Remove(&lContacts,index);
} }
dbc=(struct DBContact*)DBRead(wParam,sizeof(struct DBContact),NULL);
@@ -229,7 +229,7 @@ static INT_PTR DeleteContact(WPARAM wParam,LPARAM lParam)
{
DBCachedContactValueList VLtemp;
VLtemp.hContact = (HANDLE)ofsThis;
- if ( li.List_GetIndex(&lContacts,&VLtemp,&index))
+ if ( List_GetIndex(&lContacts,&VLtemp,&index))
{
DBCachedContactValueList *VL = ( DBCachedContactValueList* )lContacts.items[index];
VL->hNext = ( HANDLE )ofsNext;
@@ -285,7 +285,7 @@ static INT_PTR IsDbContact(WPARAM wParam,LPARAM lParam)
int index;
DBCachedContactValueList VLtemp;
VLtemp.hContact = (HANDLE)wParam;
- if ( li.List_GetIndex(&lContacts,&VLtemp,&index))
+ if ( List_GetIndex(&lContacts,&VLtemp,&index))
ret = TRUE;
else {
dbc=(struct DBContact*)DBRead(ofsContact,sizeof(struct DBContact),NULL);
diff --git a/plugins/Db3x_mmap/dbmodulechain.cpp b/plugins/Db3x_mmap/dbmodulechain.cpp
index 671a239d48..5ad05b5abd 100644
--- a/plugins/Db3x_mmap/dbmodulechain.cpp
+++ b/plugins/Db3x_mmap/dbmodulechain.cpp
@@ -50,15 +50,15 @@ void AddToList(char *name, DWORD len, DWORD ofs)
mn->name = name;
mn->ofs = ofs;
- if (li.List_GetIndex(&lMods,mn,&index))
+ if (List_GetIndex(&lMods,mn,&index))
DatabaseCorruption( _T("%s (Module Name not unique)"));
- li.List_Insert(&lMods,mn,index);
+ List_Insert(&lMods,mn,index);
- if (li.List_GetIndex(&lOfs,mn,&index))
+ if (List_GetIndex(&lOfs,mn,&index))
DatabaseCorruption( _T("%s (Module Offset not unique)"));
- li.List_Insert(&lOfs,mn,index);
+ List_Insert(&lOfs,mn,index);
}
@@ -98,8 +98,8 @@ int InitModuleNames(void)
void UninitModuleNames(void)
{
HeapDestroy(hModHeap);
- li.List_Destroy(&lMods);
- li.List_Destroy(&lOfs);
+ List_Destroy(&lMods);
+ List_Destroy(&lOfs);
}
static DWORD FindExistingModuleNameOfs(const char *szName)
@@ -114,7 +114,7 @@ static DWORD FindExistingModuleNameOfs(const char *szName)
if (lastmn && ModCompare(&mn,lastmn) == 0)
return lastmn->ofs;
- if (li.List_GetIndex(&lMods,&mn,&index)) {
+ if (List_GetIndex(&lMods,&mn,&index)) {
pmn = (ModuleName*)lMods.items[index];
lastmn = pmn;
return pmn->ofs;
@@ -168,7 +168,7 @@ char *GetModuleNameByOfs(DWORD ofs)
mn.name = NULL;
mn.ofs = ofs;
- if (li.List_GetIndex(&lOfs,&mn,&index)) {
+ if (List_GetIndex(&lOfs,&mn,&index)) {
pmn = (ModuleName*)lOfs.items[index];
lastmn = pmn;
return pmn->name;
diff --git a/plugins/Db3x_mmap/dbsettings.cpp b/plugins/Db3x_mmap/dbsettings.cpp
index 90dfecd727..7f7687ab4c 100644
--- a/plugins/Db3x_mmap/dbsettings.cpp
+++ b/plugins/Db3x_mmap/dbsettings.cpp
@@ -64,7 +64,7 @@ static char* InsertCachedSetting( const char* szName, size_t cbNameLen, int inde
char* newValue = (char*)HeapAlloc( hCacheHeap, 0, cbNameLen );
*newValue = 0;
strcpy(newValue+1,szName+1);
- li.List_Insert(&lSettings,newValue,index);
+ List_Insert(&lSettings,newValue,index);
return newValue;
}
@@ -81,7 +81,7 @@ static char* GetCachedSetting(const char *szModuleName,const char *szSettingName
if (lastsetting && strcmp(szFullName+1,lastsetting) == 0)
return lastsetting;
- if (li.List_GetIndex(&lSettings,szFullName,&index))
+ if (List_GetIndex(&lSettings,szFullName,&index))
lastsetting = (char*)lSettings.items[index]+1;
else
lastsetting = InsertCachedSetting( szFullName, settingNameLen+moduleNameLen+3, index )+1;
@@ -129,11 +129,11 @@ static DBVARIANT* GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllo
if ( hContact == 0 ) {
DBCachedGlobalValue Vtemp, *V;
Vtemp.name = szSetting;
- if ( li.List_GetIndex(&lGlobalSettings,&Vtemp,&index)) {
+ if ( List_GetIndex(&lGlobalSettings,&Vtemp,&index)) {
V = (DBCachedGlobalValue*)lGlobalSettings.items[index];
if ( bAllocate == -1 ) {
FreeCachedVariant( &V->value );
- li.List_Remove(&lGlobalSettings,index);
+ List_Remove(&lGlobalSettings,index);
HeapFree(hCacheHeap,0,V);
return NULL;
} }
@@ -143,7 +143,7 @@ static DBVARIANT* GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllo
V = (DBCachedGlobalValue*)HeapAlloc(hCacheHeap,HEAP_ZERO_MEMORY,sizeof(DBCachedGlobalValue));
V->name = szSetting;
- li.List_Insert(&lGlobalSettings,V,index);
+ List_Insert(&lGlobalSettings,V,index);
}
return &V->value;
@@ -158,7 +158,7 @@ static DBVARIANT* GetCachedValuePtr( HANDLE hContact, char* szSetting, int bAllo
else {
VLtemp.hContact=hContact;
- if ( !li.List_GetIndex(&lContacts,&VLtemp,&index))
+ if ( !List_GetIndex(&lContacts,&VLtemp,&index))
{
if ( bAllocate != 1 )
return NULL;
@@ -512,20 +512,20 @@ static INT_PTR SetSettingResident(WPARAM wParam,LPARAM lParam)
strcpy( szTemp+1, ( char* )lParam );
EnterCriticalSection(&csDbAccess);
- if ( !li.List_GetIndex( &lSettings, szTemp, &idx ))
+ if ( !List_GetIndex( &lSettings, szTemp, &idx ))
szSetting = InsertCachedSetting( szTemp, cbSettingNameLen, idx );
else
szSetting = (char *)lSettings.items[idx];
*szSetting = (char)wParam;
- if ( !li.List_GetIndex( &lResidentSettings, szSetting+1, &idx ))
+ if ( !List_GetIndex( &lResidentSettings, szSetting+1, &idx ))
{
if (wParam)
- li.List_Insert(&lResidentSettings,szSetting+1,idx);
+ List_Insert(&lResidentSettings,szSetting+1,idx);
}
else if (!wParam)
- li.List_Remove(&lResidentSettings,idx);
+ List_Remove(&lResidentSettings,idx);
LeaveCriticalSection(&csDbAccess);
}
@@ -1006,8 +1006,8 @@ int InitSettings(void)
void UninitSettings(void)
{
HeapDestroy(hCacheHeap);
- li.List_Destroy(&lContacts);
- li.List_Destroy(&lSettings);
- li.List_Destroy(&lGlobalSettings);
- li.List_Destroy(&lResidentSettings);
+ List_Destroy(&lContacts);
+ List_Destroy(&lSettings);
+ List_Destroy(&lGlobalSettings);
+ List_Destroy(&lResidentSettings);
}
diff --git a/plugins/Db_autobackups/headers.h b/plugins/Db_autobackups/headers.h
index 41da04b69b..93cc6fbc73 100644
--- a/plugins/Db_autobackups/headers.h
+++ b/plugins/Db_autobackups/headers.h
@@ -6,13 +6,14 @@
#include <m_stdhdr.h>
#include <windows.h>
-#include <newpluginapi.h>
-#include <win2k.h>
+#include <shlobj.h>
#include <time.h>
#include <commctrl.h>
+
+#include <m_system.h>
+#include <newpluginapi.h>
#include <m_clist.h>
#include <m_plugins.h>
-#include <m_system.h>
#include <m_database.h>
#include <m_langpack.h>
#include <m_utils.h>
@@ -20,6 +21,7 @@
#include <m_popup.h>
#include <m_icolib.h>
#include "m_folders.h"
+#include <win2k.h>
#include "options.h"
#include "resource.h"
diff --git a/plugins/Db_autobackups/options.cpp b/plugins/Db_autobackups/options.cpp
index 161d94ae4b..ef94ab8872 100644
--- a/plugins/Db_autobackups/options.cpp
+++ b/plugins/Db_autobackups/options.cpp
@@ -1,5 +1,4 @@
#include "headers.h"
-#include <shlobj.h>
Options options;
static HWND hPathTip;
diff --git a/plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp b/plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp
index efbbde1640..a16a11e7ac 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/cleaning.cpp
@@ -29,7 +29,7 @@ INT_PTR CALLBACK CleaningDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa
EnableWindow(GetDlgItem(hdlg,IDC_ERASEHISTORY),!opts.bAggressive);
CheckDlgButton(hdlg,IDC_MARKREAD,opts.bMarkRead);
CheckDlgButton(hdlg,IDC_CONVERTUTF,opts.bConvertUtf);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WZN_PAGECHANGING:
opts.bEraseHistory=IsDlgButtonChecked(hdlg,IDC_ERASEHISTORY)&&!opts.bAggressive;
diff --git a/plugins/Dbx_mmap_SA/Dbtool/dbtool.h b/plugins/Dbx_mmap_SA/Dbtool/dbtool.h
index 63b6b4ccf1..dd6af38cd5 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/dbtool.h
+++ b/plugins/Dbx_mmap_SA/Dbtool/dbtool.h
@@ -34,9 +34,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <time.h>
#include <win2k.h>
-//#include <newpluginapi.h> // Only needed to keep m_database.h happy
-#define CallService(a,b,c) 1
-
#include "m_database.h"
#include "database.h" // Note: This is a copy of database.h from the Miranda IM v0.3 tree.
// Remember to update this when releasing new dbtool versions.
@@ -104,18 +101,4 @@ DWORD ConvertModuleNameOfs(DWORD ofsOld);
void FreeModuleChain();
extern BOOL bEncrypted;
-int TranslateDialog(HWND hwndDlg);
-void LoadLangPackModule(void);
-void UnloadLangPackModule(void);
-
-char* LangPackTranslateString(const char *szEnglish, const int W);
-__inline LPSTR Translate(LPSTR source)
-{ return ( LPSTR )LangPackTranslateString( source, 0 );
-}
-
-#define TranslateT(s) (TCHAR*)LangPackTranslateString((LPCSTR)_T(s),1)
-#define TranslateTS(s) (TCHAR*)LangPackTranslateString((LPCSTR)s,1)
-
-char* Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2);
-char* Utf8EncodeUcs2(const wchar_t* src);
bool is_utf8_string(const char* str);
diff --git a/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters b/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters
index 202d0b374d..1c054474cd 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters
+++ b/plugins/Dbx_mmap_SA/Dbtool/dbtool_sa_10.vcxproj.filters
@@ -24,9 +24,6 @@
<ClCompile Include="disk.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="langpack.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/Dbx_mmap_SA/Dbtool/encryption.cpp b/plugins/Dbx_mmap_SA/Dbtool/encryption.cpp
index 3d00d70880..4f5c0a18b6 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/encryption.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/encryption.cpp
@@ -230,7 +230,7 @@ BOOL CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
HWND hwndCtrl;
// if(pluginLink && ServiceExists(MS_LANGPACK_TRANSLATEDIALOG))
- TranslateDialog(hDlg);
+ TranslateDialogDefault(hDlg);
if(lParam && !wrongPass) SetDlgItemTextA(hDlg, IDC_DBNAME, (LPCSTR)lParam);
if(wrongPass)
diff --git a/plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp b/plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp
index 2b9ba5098a..3c9e37668a 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/eventchain.cpp
@@ -49,7 +49,7 @@ static void ConvertOldEvent( DBEvent*& dbei )
}
if ( msglenW > 0 && msglenW <= msglen ) {
- char* utf8str = Utf8EncodeUcs2(( WCHAR* )&dbei->blob[ msglen ] );
+ char* utf8str = Utf8EncodeW(( WCHAR* )&dbei->blob[ msglen ] );
dbei->cbBlob = (DWORD)strlen( utf8str )+1;
dbei->flags |= DBEF_UTF;
if (offsetof(DBEvent,blob)+dbei->cbBlob > memsize) {
diff --git a/plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp b/plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp
index 2fdd16c082..d904daf5b9 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/fileaccess.cpp
@@ -29,7 +29,7 @@ INT_PTR CALLBACK FileAccessDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
CheckDlgButton(hdlg,IDC_BACKUP,opts.bBackup);
CheckDlgButton(hdlg,IDC_AGGRESSIVE,opts.bAggressive);
SendMessage(hdlg,WM_COMMAND,MAKEWPARAM(IDC_CHECKONLY,BN_CLICKED),0);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WZN_PAGECHANGING:
opts.bCheckOnly=IsDlgButtonChecked(hdlg,IDC_CHECKONLY);
diff --git a/plugins/Dbx_mmap_SA/Dbtool/finished.cpp b/plugins/Dbx_mmap_SA/Dbtool/finished.cpp
index 1716f72dd4..08d0f5c893 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/finished.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/finished.cpp
@@ -36,7 +36,7 @@ INT_PTR CALLBACK FinishedDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa
SetDlgItemText(hdlg,IDC_BACKUPFILE,opts.backupFilename);
}
else ShowWindow(GetDlgItem(hdlg,IDC_STBACKUP),FALSE);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WM_LAUNCHMIRANDA:
if(IsDlgButtonChecked(hdlg,IDC_LAUNCHMIRANDA)) {
diff --git a/plugins/Dbx_mmap_SA/Dbtool/langpack.cpp b/plugins/Dbx_mmap_SA/Dbtool/langpack.cpp
deleted file mode 100644
index 7f2627cd11..0000000000
--- a/plugins/Dbx_mmap_SA/Dbtool/langpack.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2011 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.
-*/
-
-#include "dbtool.h"
-
-struct LangPackEntry {
- unsigned linePos;
- DWORD englishHash;
- char *english; //not currently used, the hash does everything
- char *local;
- wchar_t *wlocal;
-};
-
-struct LangPackStruct {
- TCHAR filename[MAX_PATH];
- char language[64];
- char lastModifiedUsing[64];
- char authors[256];
- char authorEmail[128];
- struct LangPackEntry *entry;
- int entryCount;
- LCID localeID;
- UINT defaultANSICp;
-} static langPack;
-
-static void TrimString(char *str)
-{
- size_t start, len = strlen(str);
- while(str[0] && (unsigned char)str[len-1] <= ' ') str[--len] = 0;
- for (start = 0; str[start] && (unsigned char)str[start] <= ' '; start++);
- memmove(str, str + start, len - start + 1);
-}
-
-static void TrimStringSimple(char *str)
-{
- size_t len = strlen(str);
- if (str[len-1] == '\n') str[--len] = '\0';
- if (str[len-1] == '\r') str[len-1] = '\0';
-}
-
-static int IsEmpty(char *str)
-{
- int i = 0;
-
- while (str[i])
- {
- if (str[i] != ' ' && str[i] != '\r' && str[i] != '\n')
- return 0;
- i++;
- }
- return 1;
-}
-
-void ConvertBackslashes(char *str, UINT fileCp)
-{
- char *pstr;
- for (pstr = str; *pstr; pstr = CharNextExA(fileCp, pstr, 0))
- {
- if ( *pstr == '\\' )
- {
- switch( pstr[1] )
- {
- case 'n': *pstr = '\n'; break;
- case 't': *pstr = '\t'; break;
- case 'r': *pstr = '\r'; break;
- default: *pstr = pstr[1]; break;
- }
- memmove(pstr+1, pstr+2, strlen(pstr+2) + 1);
- }
- }
-}
-
-#ifdef _DEBUG
-#pragma optimize( "gt", on )
-#endif
-
-// MurmurHash2
-unsigned int __fastcall hash(const void * key, unsigned int len)
-{
- // 'm' and 'r' are mixing constants generated offline.
- // They're not really 'magic', they just happen to work well.
- const unsigned int m = 0x5bd1e995;
- const int r = 24;
-
- // Initialize the hash to a 'random' value
- unsigned int h = len;
-
- // Mix 4 bytes at a time into the hash
- const unsigned char * data = (const unsigned char *)key;
-
- while(len >= 4)
- {
- unsigned int k = *(unsigned int *)data;
-
- k *= m;
- k ^= k >> r;
- k *= m;
-
- h *= m;
- h ^= k;
-
- data += 4;
- len -= 4;
- }
-
- // Handle the last few bytes of the input array
- switch(len)
- {
- case 3: h ^= data[2] << 16;
- case 2: h ^= data[1] << 8;
- case 1: h ^= data[0];
- h *= m;
- };
-
- // Do a few final mixes of the hash to ensure the last few
- // bytes are well-incorporated.
- h ^= h >> 13;
- h *= m;
- h ^= h >> 15;
-
- return h;
-}
-
-unsigned int __fastcall hashstrW(const char * key)
-{
- if (key == NULL) return 0;
- const unsigned int len = (unsigned int)wcslen((const wchar_t*)key);
- char* buf = (char*)alloca(len + 1);
- for (unsigned i = 0; i <= len ; ++i)
- buf[i] = key[i << 1];
- return hash(buf, len);
-}
-
-__inline unsigned int hashstr(const char * key)
-{
- if (key == NULL) return 0;
- const unsigned int len = (unsigned int)strlen((const char*)key);
- return hash(key, len);
-}
-
-#ifdef _DEBUG
-#pragma optimize( "", on )
-#endif
-
-static int SortLangPackHashesProc(struct LangPackEntry *arg1,struct LangPackEntry *arg2)
-{
- if(arg1->englishHash<arg2->englishHash) return -1;
- if(arg1->englishHash>arg2->englishHash) return 1;
- /* both source strings of the same hash (may not be the same string thou) put
- the one that was written first to be found first */
- if(arg1->linePos<arg2->linePos) return -1;
- if(arg1->linePos>arg2->linePos) return 1;
- return 0;
-}
-
-
-static int SortLangPackHashesProc2(struct LangPackEntry *arg1,struct LangPackEntry *arg2)
-{
- if(arg1->englishHash<arg2->englishHash) return -1;
- if(arg1->englishHash>arg2->englishHash) return 1;
- return 0;
-}
-
-static int LoadLangPack(const TCHAR *szLangPack)
-{
- FILE *fp;
- char line[4096] = "";
- char *pszColon;
- char *pszLine;
- int entriesAlloced;
- int startOfLine=0;
- unsigned int linePos=1;
- LCID langID;
- UINT fileCp = CP_ACP;
-
- lstrcpy(langPack.filename,szLangPack);
- fp = _tfopen(szLangPack,_T("rt"));
- if(fp==NULL) return 1;
- fgets(line,sizeof(line),fp);
- size_t lineLen = strlen(line);
- if (lineLen >= 3 && line[0]=='\xef' && line[1]=='\xbb' && line[2]=='\xbf')
- {
- fileCp = CP_UTF8;
- memmove(line, line + 3, lineLen - 2);
- }
- TrimString(line);
- if(lstrcmpA(line,"Miranda Language Pack Version 1")) {fclose(fp); return 2;}
- //headers
- while(!feof(fp)) {
- startOfLine=ftell(fp);
- if(fgets(line,sizeof(line),fp)==NULL) break;
- TrimString(line);
- if(IsEmpty(line) || line[0]==';' || line[0]==0) continue;
- if(line[0]=='[') break;
- pszColon=strchr(line,':');
- if(pszColon==NULL) {fclose(fp); return 3;}
- *pszColon=0;
- if (!lstrcmpA(line,"Language")) {_snprintf(langPack.language,sizeof(langPack.language),"%s",pszColon+1); TrimString(langPack.language);}
- else if (!lstrcmpA(line,"Last-Modified-Using")) {_snprintf(langPack.lastModifiedUsing,sizeof(langPack.lastModifiedUsing),"%s",pszColon+1); TrimString(langPack.lastModifiedUsing);}
- else if (!lstrcmpA(line,"Authors")) {_snprintf(langPack.authors,sizeof(langPack.authors),"%s",pszColon+1); TrimString(langPack.authors);}
- else if (!lstrcmpA(line,"Author-email")) {_snprintf(langPack.authorEmail,sizeof(langPack.authorEmail),"%s",pszColon+1); TrimString(langPack.authorEmail);}
- else if (!lstrcmpA(line, "Locale")) {
- char szBuf[20], *stopped;
-
- TrimString(pszColon + 1);
- langID = (USHORT)strtol(pszColon + 1, &stopped, 16);
- langPack.localeID = MAKELCID(langID, 0);
- GetLocaleInfoA(langPack.localeID, LOCALE_IDEFAULTANSICODEPAGE, szBuf, 10);
- szBuf[5] = 0; // codepages have max. 5 digits
- langPack.defaultANSICp = atoi(szBuf);
- if (fileCp == CP_ACP)
- fileCp = langPack.defaultANSICp;
- }
- }
-
- //body
- fseek(fp,startOfLine,SEEK_SET);
- entriesAlloced=0;
- while(!feof(fp)) {
- if(fgets(line,sizeof(line),fp)==NULL) break;
- if(IsEmpty(line) || line[0]==';' || line[0]==0) continue;
- TrimStringSimple(line);
- ConvertBackslashes(line, fileCp);
- if(line[0]=='[' && line[lstrlenA(line)-1]==']') {
- if(langPack.entryCount && langPack.entry[langPack.entryCount-1].local==NULL) {
- if(langPack.entry[langPack.entryCount-1].english!=NULL) free(langPack.entry[langPack.entryCount-1].english);
- langPack.entryCount--;
- }
- pszLine = line+1;
- line[lstrlenA(line)-1]='\0';
- TrimStringSimple(line);
- if (++langPack.entryCount>entriesAlloced) {
- entriesAlloced+=128;
- langPack.entry=(struct LangPackEntry*)realloc(langPack.entry,sizeof(struct LangPackEntry)*entriesAlloced);
- }
- langPack.entry[langPack.entryCount-1].english=NULL;
- langPack.entry[langPack.entryCount-1].englishHash=hashstr(pszLine);
- langPack.entry[langPack.entryCount-1].local=NULL;
- langPack.entry[langPack.entryCount-1].wlocal = NULL;
- langPack.entry[langPack.entryCount-1].linePos=linePos++;
- }
- else if(langPack.entryCount) {
- struct LangPackEntry* E = &langPack.entry[langPack.entryCount-1];
-
- if(E->local==NULL) {
- E->local = _strdup(line);
- if (fileCp == CP_UTF8)
- Utf8DecodeCP(E->local, langPack.defaultANSICp, NULL);
-
- {
- int iNeeded = MultiByteToWideChar(fileCp, 0, line, -1, 0, 0);
- E->wlocal = (wchar_t *)malloc((iNeeded+1) * sizeof(wchar_t));
- MultiByteToWideChar(fileCp, 0, line, -1, E->wlocal, iNeeded);
- }
- }
- else {
- size_t iOldLenA = strlen(E->local);
- E->local = (char*)realloc(E->local, iOldLenA + strlen(line) + 2);
- strcat(E->local, "\n");
- strcat(E->local, line);
- if (fileCp == CP_UTF8)
- Utf8DecodeCP(E->local + iOldLenA + 1, langPack.defaultANSICp, NULL);
- {
- int iNeeded = MultiByteToWideChar(fileCp, 0, line, -1, 0, 0);
- size_t iOldLen = wcslen(E->wlocal);
- E->wlocal = (wchar_t*)realloc(E->wlocal, ( sizeof(wchar_t) * ( iOldLen + iNeeded + 2)));
- wcscat(E->wlocal, L"\n");
- MultiByteToWideChar(fileCp, 0, line, -1, E->wlocal + iOldLen+1, iNeeded);
- }
- }
- }
- }
- fclose(fp);
-
- qsort(langPack.entry,langPack.entryCount,sizeof(LangPackEntry),(int(*)(const void*,const void*))SortLangPackHashesProc);
-
- return 0;
-}
-
-char *LangPackTranslateString(const char *szEnglish, const int W)
-{
- struct LangPackEntry key,*entry;
-
- if ( langPack.entryCount == 0 || szEnglish == NULL ) return (char*)szEnglish;
-
- key.englishHash = W ? hashstrW(szEnglish) : hashstr(szEnglish);
- entry=(struct LangPackEntry*)bsearch(&key,langPack.entry,langPack.entryCount,sizeof(struct LangPackEntry),(int(*)(const void*,const void*))SortLangPackHashesProc2);
- if(entry==NULL) return (char*)szEnglish;
- while(entry>langPack.entry)
- {
- entry--;
- if(entry->englishHash!=key.englishHash) {
- entry++;
- return W ? (char *)entry->wlocal : entry->local;
- }
- }
- return W ? (char *)entry->wlocal : entry->local;
-}
-
-#define FLAGS 1
-
-static void TranslateWindow( HWND hwnd )
-{
- TCHAR title[2048];
- GetWindowText(hwnd, title, SIZEOF( title ));
- {
- TCHAR* result = ( TCHAR* )LangPackTranslateString(( char* )title, FLAGS );
- if ( result != title )
- SetWindowText(hwnd, result );
-} }
-
-static BOOL CALLBACK TranslateDialogEnumProc(HWND hwnd,LPARAM lParam)
-{
- TCHAR szClass[32];
- int id = GetDlgCtrlID( hwnd );
-
- GetClassName(hwnd,szClass,SIZEOF(szClass));
- if (!lstrcmpi(szClass,_T("static")) || !lstrcmpi(szClass,_T("hyperlink")) || !lstrcmpi(szClass,_T("button")) || !lstrcmpi(szClass,_T("MButtonClass")))
- TranslateWindow(hwnd);
- else if (!lstrcmpi(szClass,_T("edit"))) {
- if ( GetWindowLongPtr(hwnd,GWL_STYLE)&ES_READONLY)
- TranslateWindow(hwnd);
- }
- return TRUE;
-}
-
-int TranslateDialog( HWND hwndDlg )
-{
- TranslateWindow( hwndDlg );
- EnumChildWindows( hwndDlg,TranslateDialogEnumProc,0);
- return 0;
-}
-
-void LoadLangPackModule(void)
-{
- HANDLE hFind;
- TCHAR szSearch[MAX_PATH], *str2, szLangPack[MAX_PATH];
- WIN32_FIND_DATA fd;
-
- GetModuleFileName(GetModuleHandle(NULL),szSearch,MAX_PATH);
- str2 = _tcsrchr(szSearch, '\\');
- if (str2) *str2 = 0; else str2 = szSearch;
- _tcscat(szSearch, _T("\\langpack_*.txt"));
- hFind = FindFirstFile(szSearch, &fd);
- if (hFind != INVALID_HANDLE_VALUE)
- {
- FindClose(hFind);
-
- _tcscpy(str2 + 1, fd.cFileName);
- _tcscpy(szLangPack, szSearch);
- LoadLangPack(szLangPack);
- }
-}
-
-void UnloadLangPackModule(void)
-{
- for (int i = 0; i < langPack.entryCount; i++) {
- free(langPack.entry[i].english);
- free(langPack.entry[i].local);
- free(langPack.entry[i].wlocal);
- }
- if (langPack.entryCount) {
- free(langPack.entry);
- langPack.entry=0;
- langPack.entryCount=0;
- }
-}
-
diff --git a/plugins/Dbx_mmap_SA/Dbtool/main.cpp b/plugins/Dbx_mmap_SA/Dbtool/main.cpp
index 014881e34d..bdfb5ce706 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/main.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/main.cpp
@@ -19,13 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "dbtool.h"
HINSTANCE hInst;
+int hLangpack=0;
DbToolOptions opts = {0};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
hInst=hInstance;
- LoadLangPackModule();
InitCommonControls();
DialogBox(hInst,MAKEINTRESOURCE(IDD_WIZARD),NULL,WizardDlgProc);
return 0;
diff --git a/plugins/Dbx_mmap_SA/Dbtool/openerror.cpp b/plugins/Dbx_mmap_SA/Dbtool/openerror.cpp
index 292d688be7..1fa2964c20 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/openerror.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/openerror.cpp
@@ -31,7 +31,7 @@ INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lP
}
if(opts.error==ERROR_SHARING_VIOLATION) ShowWindow(GetDlgItem(hdlg,IDC_INUSE),SW_SHOW);
SetWindowLongPtr( GetDlgItem( hdlg, IDC_FILE ), GWL_STYLE, GetWindowLongPtr( GetDlgItem( hdlg, IDC_FILE ), GWL_STYLE ) | SS_PATHELLIPSIS );
- TranslateDialog( hdlg );
+ TranslateDialogDefault( hdlg );
SetDlgItemText( hdlg, IDC_FILE, opts.filename );
return TRUE;
case WM_COMMAND:
diff --git a/plugins/Dbx_mmap_SA/Dbtool/progress.cpp b/plugins/Dbx_mmap_SA/Dbtool/progress.cpp
index caca179482..5ddb8bd985 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/progress.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/progress.cpp
@@ -104,7 +104,7 @@ INT_PTR CALLBACK ProgressDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa
manualAbort=0;
hEventRun=CreateEvent(NULL,TRUE,TRUE,NULL);
hEventAbort=CreateEvent(NULL,TRUE,FALSE,NULL);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
_beginthread(WorkerThread,0,NULL);
return TRUE;
case WM_MEASUREITEM:
diff --git a/plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp b/plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp
index 9b1a08640e..9db3517816 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/selectdb.cpp
@@ -209,7 +209,7 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa
CloseHandle( opts.hFile );
opts.hFile = NULL;
}
- TranslateDialog( hdlg );
+ TranslateDialogDefault( hdlg );
return TRUE;
}
diff --git a/plugins/Dbx_mmap_SA/Dbtool/utf.cpp b/plugins/Dbx_mmap_SA/Dbtool/utf.cpp
index 157d5d00f5..c56db053d8 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/utf.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/utf.cpp
@@ -26,382 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "dbtool.h"
-/* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */
-static const char utf8_length[128] =
-{
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80-0x8f */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90-0x9f */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xa0-0xaf */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xb0-0xbf */
- 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xc0-0xcf */
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xd0-0xdf */
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 0xe0-0xef */
- 3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0 /* 0xf0-0xff */
-};
-
-/* first byte mask depending on UTF-8 sequence length */
-static const unsigned char utf8_mask[4] = { 0x7f, 0x1f, 0x0f, 0x07 };
-
-/* minimum Unicode value depending on UTF-8 sequence length */
-static const unsigned int utf8_minval[4] = { 0x0, 0x80, 0x800, 0x10000 };
-
-
-/* get the next char value taking surrogates into account */
-static unsigned int getSurrogateValue(const wchar_t *src, unsigned int srclen)
-{
- if (src[0] >= 0xd800 && src[0] <= 0xdfff) /* surrogate pair */
- {
- if (src[0] > 0xdbff || /* invalid high surrogate */
- srclen <= 1 || /* missing low surrogate */
- src[1] < 0xdc00 || src[1] > 0xdfff) /* invalid low surrogate */
- return 0;
- return 0x10000 + ((src[0] & 0x3ff) << 10) + (src[1] & 0x3ff);
- }
- return src[0];
-}
-
-/* query necessary dst length for src string */
-static int Ucs2toUtf8Len(const wchar_t *src, unsigned int srclen)
-{
- int len;
- unsigned int val;
-
- for (len = 0; srclen; srclen--, src++)
- {
- if (*src < 0x80) /* 0x00-0x7f: 1 byte */
- {
- len++;
- continue;
- }
- if (*src < 0x800) /* 0x80-0x7ff: 2 bytes */
- {
- len += 2;
- continue;
- }
- if (!(val = getSurrogateValue(src, srclen)))
- {
- return -2;
- }
- if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
- len += 3;
- else /* 0x10000-0x10ffff: 4 bytes */
- {
- len += 4;
- src++;
- srclen--;
- }
- }
- return len;
-}
-
-int Ucs2toUtf8Len(const wchar_t *src)
-{
- if ( src == 0 )
- return 0;
-
- return Ucs2toUtf8Len( src, (int)wcslen( src ));
-}
-
-/* wide char to UTF-8 string conversion */
-/* return -1 on dst buffer overflow, -2 on invalid input char */
-int Ucs2toUtf8(const wchar_t *src, int srclen, char *dst, int dstlen)
-{
- int len;
-
- for (len = dstlen; srclen; srclen--, src++)
- {
- WCHAR ch = *src;
- unsigned int val;
-
- if (ch < 0x80) /* 0x00-0x7f: 1 byte */
- {
- if (!len--) return -1; /* overflow */
- *dst++ = ch;
- continue;
- }
-
- if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */
- {
- if ((len -= 2) < 0) return -1; /* overflow */
- dst[1] = 0x80 | (ch & 0x3f);
- ch >>= 6;
- dst[0] = 0xc0 | ch;
- dst += 2;
- continue;
- }
-
- if (!(val = getSurrogateValue(src, srclen)))
- {
- return -2;
- }
-
- if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
- {
- if ((len -= 3) < 0) return -1; /* overflow */
- dst[2] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[1] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[0] = 0xe0 | val;
- dst += 3;
- }
- else /* 0x10000-0x10ffff: 4 bytes */
- {
- if ((len -= 4) < 0) return -1; /* overflow */
- dst[3] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[2] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[1] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[0] = 0xf0 | val;
- dst += 4;
- src++;
- srclen--;
- }
- }
- return dstlen - len;
-}
-
-/* helper for the various utf8 mbstowcs functions */
-static unsigned int decodeUtf8Char(unsigned char ch, const char **str, const char *strend)
-{
- unsigned int len = utf8_length[ch-0x80];
- unsigned int res = ch & utf8_mask[len];
- const char *end = *str + len;
-
- if (end > strend) return ~0;
- switch(len)
- {
- case 3:
- if ((ch = end[-3] ^ 0x80) >= 0x40) break;
- res = (res << 6) | ch;
- (*str)++;
- case 2:
- if ((ch = end[-2] ^ 0x80) >= 0x40) break;
- res = (res << 6) | ch;
- (*str)++;
- case 1:
- if ((ch = end[-1] ^ 0x80) >= 0x40) break;
- res = (res << 6) | ch;
- (*str)++;
- if (res < utf8_minval[len]) break;
- return res;
- }
- return ~0;
-}
-
-/* query necessary dst length for src string */
-static inline int Utf8toUcs2Len(const char *src, int srclen)
-{
- int ret = 0;
- unsigned int res;
- const char *srcend = src + srclen;
-
- while (src < srcend)
- {
- unsigned char ch = *src++;
- if (ch < 0x80) /* special fast case for 7-bit ASCII */
- {
- ret++;
- continue;
- }
- if ((res = decodeUtf8Char(ch, &src, srcend)) <= 0x10ffff)
- {
- if (res > 0xffff) ret++;
- ret++;
- }
- else return -2; /* bad char */
- /* otherwise ignore it */
- }
- return ret;
-}
-
-/* UTF-8 to wide char string conversion */
-/* return -1 on dst buffer overflow, -2 on invalid input char */
-int Utf8toUcs2(const char *src, int srclen, wchar_t *dst, int dstlen)
-{
- unsigned int res;
- const char *srcend = src + srclen;
- wchar_t *dstend = dst + dstlen;
-
- while ((dst < dstend) && (src < srcend))
- {
- unsigned char ch = *src++;
- if (ch < 0x80) /* special fast case for 7-bit ASCII */
- {
- *dst++ = ch;
- continue;
- }
- if ((res = decodeUtf8Char(ch, &src, srcend)) <= 0xffff)
- {
- *dst++ = res;
- }
- else if (res <= 0x10ffff) /* we need surrogates */
- {
- if (dst == dstend - 1) return -1; /* overflow */
- res -= 0x10000;
- *dst++ = 0xd800 | (res >> 10);
- *dst++ = 0xdc00 | (res & 0x3ff);
- }
- else return -2; /* bad char */
- /* otherwise ignore it */
- }
- if (src < srcend) return -1; /* overflow */
- return dstlen - (dstend - dst);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Decode - converts UTF8-encoded string to the UCS2/MBCS format
-
-char* Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2)
-{
- int len;
- bool needs_free = false;
- wchar_t* tempBuf = NULL;
- if ( ucs2 )
- *ucs2 = NULL;
-
- if (str == NULL)
- return NULL;
-
- len = (int)strlen(str);
-
- if (len < 2) {
- if (ucs2 != NULL) {
- *ucs2 = tempBuf = (wchar_t*)malloc((len + 1) * sizeof(wchar_t));
- MultiByteToWideChar(codepage, 0, str, len, tempBuf, len);
- tempBuf[len] = 0;
- }
- return str;
- }
-
- int destlen = Utf8toUcs2Len(str, len);
- if (destlen < 0)
- return NULL;
-
- if (ucs2 == NULL) {
- __try
- {
- tempBuf = (wchar_t*)alloca((destlen + 1) * sizeof(wchar_t));
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- tempBuf = NULL;
- needs_free = true;
- }
- }
-
- if ( tempBuf == NULL ) {
- tempBuf = (wchar_t*)malloc((destlen + 1) * sizeof(wchar_t));
- if ( tempBuf == NULL )
- return NULL;
- }
-
- Utf8toUcs2(str, len, tempBuf, destlen);
- tempBuf[destlen] = 0;
- WideCharToMultiByte(codepage, 0, tempBuf, -1, str, len + 1, "?", NULL);
-
- if (ucs2)
- *ucs2 = tempBuf;
- else if (needs_free)
- free(tempBuf);
-
- return str;
-}
-
-wchar_t* Utf8DecodeUcs2(const char* str)
-{
- if (str == NULL)
- return NULL;
-
- int len = (int)strlen(str);
-
- int destlen = Utf8toUcs2Len(str, len);
- if (destlen < 0) return NULL;
-
- wchar_t* ucs2 = (wchar_t*)malloc((destlen + 1) * sizeof(wchar_t));
- if (ucs2 == NULL) return NULL;
-
- if (Utf8toUcs2(str, len, ucs2, destlen) >= 0)
- {
- ucs2[destlen] = 0;
- return ucs2;
- }
-
- free(ucs2);
-
- return NULL;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Encode - converts MBCS string to the UTF8-encoded format
-
-char* Utf8EncodeCP(const char* src, int codepage)
-{
- int len;
- bool needs_free = false;
- char* result = NULL;
- wchar_t* tempBuf;
-
- if (src == NULL)
- return NULL;
-
- len = (int)strlen(src);
-
- __try
- {
- tempBuf = (wchar_t*)alloca((len + 1) * sizeof(wchar_t));
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- tempBuf = (wchar_t*)malloc((len + 1) * sizeof(wchar_t));
- if (tempBuf == NULL) return NULL;
- needs_free = true;
- }
-
- len = MultiByteToWideChar(codepage, 0, src, -1, tempBuf, len + 1);
-
- int destlen = Ucs2toUtf8Len(tempBuf, len);
- if (destlen >= 0)
- {
- result = (char*)malloc(destlen + 1);
- if (result)
- {
- Ucs2toUtf8(tempBuf, len, result, destlen);
- result[destlen] = 0;
- }
- }
-
- if (needs_free)
- free(tempBuf);
-
- return result;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Encode - converts UCS2 string to the UTF8-encoded format
-
-char* Utf8EncodeUcs2(const wchar_t* src)
-{
- if (src == NULL)
- return NULL;
-
- int len = (int)wcslen(src);
-
- int destlen = Ucs2toUtf8Len(src, len);
- if (destlen < 0) return NULL;
-
- char* result = (char*)malloc(destlen + 1);
- if (result == NULL)
- return NULL;
-
- Ucs2toUtf8(src, len, result, destlen);
- result[destlen] = 0;
-
- return result;
-}
-
bool is_utf8_string(const char* str)
{
int expect_bytes = 0, utf_found = 0;
diff --git a/plugins/Dbx_mmap_SA/Dbtool/wizard.cpp b/plugins/Dbx_mmap_SA/Dbtool/wizard.cpp
index ab3c46f360..8f3a9d5ca8 100644
--- a/plugins/Dbx_mmap_SA/Dbtool/wizard.cpp
+++ b/plugins/Dbx_mmap_SA/Dbtool/wizard.cpp
@@ -97,7 +97,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPara
SendMessage(hdlg,WM_SETICON,ICON_SMALL,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(IDI_DBTOOL)));
hdlgPage=NULL;
SendMessage(hdlg,WZM_GOTOPAGE,IDD_WELCOME,(LPARAM)WelcomeDlgProc);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WZM_GOTOPAGE:
if(hdlgPage!=NULL) DestroyWindow(hdlgPage);
@@ -106,7 +106,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPara
EnableWindow(GetDlgItem(hdlg,IDCANCEL),TRUE);
SetDlgItemText(hdlg,IDCANCEL,TranslateT("Cancel"));
hdlgPage=CreateDialog(hInst,MAKEINTRESOURCE(wParam),hdlg,(DLGPROC)lParam);
- TranslateDialog(hdlgPage);
+ TranslateDialogDefault(hdlgPage);
SetWindowPos(hdlgPage,0,0,0,0,0,SWP_NOZORDER|SWP_NOSIZE);
ShowWindow(hdlgPage,SW_SHOW);
break;
@@ -129,7 +129,6 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPara
if (opts.hOutFile)
CloseHandle(opts.hOutFile);
DestroyWindow(hdlgPage);
- UnloadLangPackModule();
if(hBoldFont!=NULL) DeleteObject(hBoldFont);
if(hEmfHeaderLogo!=NULL) DeleteEnhMetaFile(hEmfHeaderLogo);
break;
diff --git a/plugins/Dbx_mmap_SA/commonheaders.h b/plugins/Dbx_mmap_SA/commonheaders.h
index 6d5dcd8d21..065fc3ab3e 100644
--- a/plugins/Dbx_mmap_SA/commonheaders.h
+++ b/plugins/Dbx_mmap_SA/commonheaders.h
@@ -29,8 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//windows headers
#include <windows.h>
-
+#include <shlobj.h>
#include <commctrl.h>
+
#include <stdio.h>
#include <string.h>
#include <time.h>
diff --git a/plugins/Dbx_mmap_SA/dialogs.cpp b/plugins/Dbx_mmap_SA/dialogs.cpp
index ffa0516fae..d8878a2dd1 100644
--- a/plugins/Dbx_mmap_SA/dialogs.cpp
+++ b/plugins/Dbx_mmap_SA/dialogs.cpp
@@ -4,8 +4,6 @@
#include <m_options.h>
#include <m_icolib.h>
-#include <shlobj.h>
-
#define MS_DB_CHANGEPASSWORD "DB/ChangePassword"
extern char encryptKey[255];
diff --git a/plugins/IEView/HTMLBuilder.cpp b/plugins/IEView/HTMLBuilder.cpp
index 9fa9e24824..e4211cac74 100644
--- a/plugins/IEView/HTMLBuilder.cpp
+++ b/plugins/IEView/HTMLBuilder.cpp
@@ -222,7 +222,7 @@ void HTMLBuilder::getUINs(HANDLE hContact, char *&uinIn, char *&uinOut) {
switch (ci.type) {
case CNFT_ASCIIZ:
mir_snprintf(buf, sizeof(buf), "%s", ci.pszVal);
- miranda_sys_free(ci.pszVal);
+ mir_free(ci.pszVal);
break;
case CNFT_DWORD:
mir_snprintf(buf, sizeof(buf), "%u", ci.dVal);
@@ -236,7 +236,7 @@ void HTMLBuilder::getUINs(HANDLE hContact, char *&uinIn, char *&uinOut) {
switch (ci.type) {
case CNFT_ASCIIZ:
mir_snprintf(buf, sizeof(buf), "%s", ci.pszVal);
- miranda_sys_free(ci.pszVal);
+ mir_free(ci.pszVal);
break;
case CNFT_DWORD:
mir_snprintf(buf, sizeof(buf), "%u", ci.dVal);
@@ -266,7 +266,7 @@ wchar_t *HTMLBuilder::getContactName(HANDLE hContact, const char* szProto) {
} else {
szName = Utils::dupString((wchar_t *)ci.pszVal);
}
- miranda_sys_free(ci.pszVal);
+ mir_free(ci.pszVal);
}
}
}
@@ -276,7 +276,7 @@ wchar_t *HTMLBuilder::getContactName(HANDLE hContact, const char* szProto) {
if (ci.type == CNFT_ASCIIZ) {
if (ci.pszVal) {
szName = Utils::convertToWCS((char *)ci.pszVal);
- miranda_sys_free(ci.pszVal);
+ mir_free(ci.pszVal);
}
}
}
diff --git a/plugins/IEView/ieview_main.cpp b/plugins/IEView/ieview_main.cpp
index cc0facd49b..3f0aa95289 100644
--- a/plugins/IEView/ieview_main.cpp
+++ b/plugins/IEView/ieview_main.cpp
@@ -86,7 +86,6 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
_strupr(ieviewModuleName);
pluginLink = link;
- mir_getMMI( &mmi );
mir_getLP(&pluginInfoEx);
Utils::hookEvent_Ex(ME_OPT_INITIALISE, IEViewOptInit);
diff --git a/plugins/LangMan/common.h b/plugins/LangMan/common.h
index 1f47d8ef75..4ac9deb5b5 100644
--- a/plugins/LangMan/common.h
+++ b/plugins/LangMan/common.h
@@ -26,7 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#pragma warning(disable:4201) /* nonstandard extension used : nameless struct/union */
#include <commctrl.h>
#pragma warning(default:4201) /* nonstandard extension used : nameless struct/union */
-#include <win2k.h>
+#include <ShlObj.h>
+#include <vsstyle.h>
#include <tchar.h>
#include <stdio.h> /* for mir_snprintf() */
@@ -44,6 +45,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_flags.h>
#include <m_netlib.h>
#include <m_clist.h>
+#include <win2k.h>
#include "langpack.h"
#include "options.h"
diff --git a/plugins/LangMan/options.cpp b/plugins/LangMan/options.cpp
index a3347c7ac6..72f78dd597 100644
--- a/plugins/LangMan/options.cpp
+++ b/plugins/LangMan/options.cpp
@@ -20,8 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "common.h"
-#include <ShlObj.h>
-#include <vsstyle.h>
extern HINSTANCE hInst;
static HANDLE hHookOptInit;
diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/cipher.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/cipher.c
index 8cfe54fce1..f692159e2e 100644
--- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/cipher.c
+++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/cipher.c
@@ -321,11 +321,11 @@ gcry_cipher_lookup_func_name (void *spec, void *data)
gcry_cipher_spec_t *cipher = (gcry_cipher_spec_t *) spec;
char *name = (char *) data;
const char **aliases = cipher->aliases;
- int i, ret = ! stricmp (name, cipher->name);
+ int i, ret = !_stricmp (name, cipher->name);
if (aliases)
for (i = 0; aliases[i] && (! ret); i++)
- ret = ! stricmp (name, aliases[i]);
+ ret = !_stricmp (name, aliases[i]);
return ret;
}
@@ -341,7 +341,7 @@ gcry_cipher_lookup_func_oid (void *spec, void *data)
if (oid_specs)
for (i = 0; oid_specs[i].oid && (! ret); i++)
- if (! stricmp (oid, oid_specs[i].oid))
+ if (!_stricmp (oid, oid_specs[i].oid))
ret = 1;
return ret;
@@ -437,7 +437,7 @@ search_oid (const char *oid, int *algorithm, gcry_cipher_oid_spec_t *oid_spec)
int i;
for (i = 0; cipher->oids[i].oid && !ret; i++)
- if (! stricmp (oid, cipher->oids[i].oid))
+ if (!_stricmp (oid, cipher->oids[i].oid))
{
if (algorithm)
*algorithm = module->mod_id;
diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp
index 84b1921aa2..06779ef5d5 100644
--- a/plugins/Popup/src/main.cpp
+++ b/plugins/Popup/src/main.cpp
@@ -504,7 +504,6 @@ MIRAPI int Load(PLUGINLINK *link)
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, FALSE, 0);
mir_getLI (&li);
- mir_getMMI (&mmi);
mir_getUTFI (&utfi);
mir_getMTI (&MText);
mir_getLP(&pluginInfoEx);
diff --git a/plugins/SRMM/cmdlist.cpp b/plugins/SRMM/cmdlist.cpp
index 1034b57949..91d082fc74 100644
--- a/plugins/SRMM/cmdlist.cpp
+++ b/plugins/SRMM/cmdlist.cpp
@@ -31,13 +31,13 @@ int tcmdlist_append(SortedList *list, TCHAR *data)
TCmdList* n = (TCmdList*)list->items[0];
mir_free(n->szCmd);
mir_free(n);
- li.List_Remove(list, 0);
+ List_Remove(list, 0);
}
new_list = (TCmdList*)mir_alloc(sizeof(TCmdList));
new_list->szCmd = mir_tstrdup(data);
- li.List_InsertPtr(list, new_list);
+ List_InsertPtr(list, new_list);
return list->realCount - 1;
}
@@ -52,7 +52,7 @@ void tcmdlist_free(SortedList *list)
mir_free(n[i]->szCmd);
mir_free(n[i]);
}
- li.List_Destroy(list);
+ List_Destroy(list);
mir_free(list);
}
@@ -78,7 +78,7 @@ static VOID CALLBACK MsgTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTi
tmlst = (TMsgQueue**)alloca((msgQueue.realCount - i) * sizeof(TMsgQueue*));
tmlst[ntl++] = item;
- li.List_Remove(&msgQueue, i--);
+ List_Remove(&msgQueue, i--);
}
}
LeaveCriticalSection(&csMsgQueue);
@@ -99,7 +99,7 @@ void msgQueue_add(HANDLE hContact, HANDLE id, const TCHAR* szMsg, HANDLE hDbEven
EnterCriticalSection(&csMsgQueue);
if (!msgQueue.realCount && !timerId)
timerId = SetTimer(NULL, 0, 5000, MsgTimer);
- li.List_InsertPtr(&msgQueue, item);
+ List_InsertPtr(&msgQueue, item);
LeaveCriticalSection(&csMsgQueue);
}
@@ -116,7 +116,7 @@ void msgQueue_processack(HANDLE hContact, HANDLE id, BOOL success, const char* s
item = (TMsgQueue*)msgQueue.items[i];
if (item->hContact == hContact && item->id == id)
{
- li.List_Remove(&msgQueue, i);
+ List_Remove(&msgQueue, i);
if (!msgQueue.realCount && timerId)
{
@@ -158,7 +158,7 @@ void msgQueue_destroy(void)
mir_free(item->szMsg);
mir_free(item);
}
- li.List_Destroy(&msgQueue);
+ List_Destroy(&msgQueue);
LeaveCriticalSection(&csMsgQueue);
diff --git a/plugins/SRMM/msgdialog.cpp b/plugins/SRMM/msgdialog.cpp
index 6726dc4258..df25b409e0 100644
--- a/plugins/SRMM/msgdialog.cpp
+++ b/plugins/SRMM/msgdialog.cpp
@@ -784,7 +784,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
dat->wStatus = ID_STATUS_OFFLINE;
dat->wOldStatus = dat->wStatus;
dat->splitterPos = (int) DBGetContactSettingDword(DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT)?dat->hContact:NULL, SRMMMOD, "splitterPos", (DWORD) - 1);
- dat->cmdList = li.List_Create(0, 20);
+ dat->cmdList = List_Create(0, 20);
dat->cmdListInd = -1;
dat->nTypeMode = PROTOTYPE_SELFTYPING_OFF;
SetTimer(hwndDlg, TIMERID_TYPE, 1000, NULL);
diff --git a/plugins/SRMM/richutil.cpp b/plugins/SRMM/richutil.cpp
index 92065ca0c8..7f77c98fa8 100644
--- a/plugins/SRMM/richutil.cpp
+++ b/plugins/SRMM/richutil.cpp
@@ -94,7 +94,7 @@ void RichUtil_Load(void)
void RichUtil_Unload(void)
{
- li.List_Destroy(&sListInt);
+ List_Destroy(&sListInt);
DeleteCriticalSection(&csRich);
if (mTheme)
FreeLibrary(mTheme);
@@ -112,8 +112,8 @@ int RichUtil_SubClass(HWND hwndEdit)
ru->hasUglyBorder = 0;
EnterCriticalSection(&csRich);
- if (!li.List_GetIndex(&sListInt, ru, &idx))
- li.List_Insert(&sListInt, ru, idx);
+ if (!List_GetIndex(&sListInt, ru, &idx))
+ List_Insert(&sListInt, ru, idx);
LeaveCriticalSection(&csRich);
ru->origProc = (WNDPROC)SetWindowLongPtr(ru->hwnd, GWLP_WNDPROC, (LONG_PTR)&RichUtil_Proc);
@@ -128,7 +128,7 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
TRichUtil *ru;
EnterCriticalSection(&csRich);
- ru = (TRichUtil *)li.List_Find(&sListInt, (TRichUtil*)&hwnd);
+ ru = (TRichUtil *)List_Find(&sListInt, (TRichUtil*)&hwnd);
LeaveCriticalSection(&csRich);
if (ru == NULL) return 0;
@@ -246,7 +246,7 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
}
EnterCriticalSection(&csRich);
- li.List_RemovePtr(&sListInt, ru);
+ List_RemovePtr(&sListInt, ru);
LeaveCriticalSection(&csRich);
mir_free(ru);
diff --git a/plugins/Scriver/msglog.cpp b/plugins/Scriver/msglog.cpp
index eaf139ce02..bb768cbb95 100644
--- a/plugins/Scriver/msglog.cpp
+++ b/plugins/Scriver/msglog.cpp
@@ -111,7 +111,7 @@ TCHAR *GetNickname(HANDLE hContact, const char* szProto) {
szName = a2t((char *)ci.pszVal);
}
- miranda_sys_free(ci.pszVal);
+ mir_free(ci.pszVal);
if (szName != NULL) {
return szName;
}
diff --git a/plugins/Scriver/richutil.cpp b/plugins/Scriver/richutil.cpp
index 52dff7505f..069d0cfaac 100644
--- a/plugins/Scriver/richutil.cpp
+++ b/plugins/Scriver/richutil.cpp
@@ -100,7 +100,7 @@ void RichUtil_Load(void)
void RichUtil_Unload(void)
{
- li.List_Destroy(&sListInt);
+ List_Destroy(&sListInt);
DeleteCriticalSection(&csRich);
if (mTheme)
FreeLibrary(mTheme);
@@ -118,8 +118,8 @@ int RichUtil_SubClass(HWND hwndEdit)
ru->hasUglyBorder = 0;
EnterCriticalSection(&csRich);
- if (!li.List_GetIndex(&sListInt, ru, &idx))
- li.List_Insert(&sListInt, ru, idx);
+ if (!List_GetIndex(&sListInt, ru, &idx))
+ List_Insert(&sListInt, ru, idx);
LeaveCriticalSection(&csRich);
ru->origProc = (WNDPROC)SetWindowLongPtr(ru->hwnd, GWLP_WNDPROC, (LONG_PTR)&RichUtil_Proc);
@@ -137,7 +137,7 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
tru.hwnd = hwnd;
EnterCriticalSection(&csRich);
- if (li.List_GetIndex(&sListInt, &tru, &idx))
+ if (List_GetIndex(&sListInt, &tru, &idx))
ru = (TRichUtil*)sListInt.items[idx];
LeaveCriticalSection(&csRich);
@@ -242,7 +242,7 @@ static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
}
EnterCriticalSection(&csRich);
- li.List_Remove(&sListInt, idx);
+ List_Remove(&sListInt, idx);
LeaveCriticalSection(&csRich);
mir_free(ru);
diff --git a/plugins/Scriver/utils.cpp b/plugins/Scriver/utils.cpp
index e9a9dacad2..3551119adc 100644
--- a/plugins/Scriver/utils.cpp
+++ b/plugins/Scriver/utils.cpp
@@ -545,7 +545,7 @@ void GetContactUniqueId(struct SrmmWindowData *dat, char *buf, int maxlen) {
switch (ci.type) {
case CNFT_ASCIIZ:
mir_snprintf(buf, maxlen, "%s", ci.pszVal);
- miranda_sys_free(ci.pszVal);
+ mir_free(ci.pszVal);
break;
case CNFT_DWORD:
mir_snprintf(buf, maxlen, "%u", ci.dVal);
diff --git a/plugins/SmileyAdd/regexp/WCPattern.cpp b/plugins/SmileyAdd/regexp/WCPattern.cpp
index d396bd187d..25f379f5e4 100644
--- a/plugins/SmileyAdd/regexp/WCPattern.cpp
+++ b/plugins/SmileyAdd/regexp/WCPattern.cpp
@@ -117,7 +117,7 @@ bkstring WCPattern::classUnion (bkstring s1, bkstring s2) const
wchar_t * out = new wchar_t[66000];
std::sort(s1.begin(), s1.end());
std::sort(s2.begin(), s2.end());
- *std::set_union(s1.begin(), s1.end(), s2.begin(), s2.end(), out) = 0;
+ wchar_t* p = std::set_union(s1.begin(), s1.end(), s2.begin(), s2.end(), out); *p = 0;
bkstring ret = out;
delete [] out;
return ret;
diff --git a/plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters b/plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters
index 7b41fd05dd..f0f8d79957 100644
--- a/plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters
+++ b/plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters
@@ -36,9 +36,6 @@
<ClCompile Include="modules.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="threads.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="modsettingenum.cpp">
<Filter>Source Files\ModSetting Enuming</Filter>
</ClCompile>
diff --git a/plugins/Svc_dbepp/exportimport.cpp b/plugins/Svc_dbepp/exportimport.cpp
index 14faf47198..ad9f508a21 100644
--- a/plugins/Svc_dbepp/exportimport.cpp
+++ b/plugins/Svc_dbepp/exportimport.cpp
@@ -365,19 +365,6 @@ HANDLE CheckNewContact(char *myProto, char *uid, char *myName)
}
-TCHAR* __stdcall rtrim(TCHAR *string)
-{
- TCHAR* p = string + _tcslen(string) - 1;
-
- while (p >= string) {
- if (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r')
- break;
-
- *p-- = 0;
- }
- return string;
-}
-
HANDLE Clist_GroupExists(WCHAR *tszGroup)
{
unsigned int i = 0;
diff --git a/plugins/Svc_dbepp/headers.h b/plugins/Svc_dbepp/headers.h
index 57663f56e1..e90738306b 100644
--- a/plugins/Svc_dbepp/headers.h
+++ b/plugins/Svc_dbepp/headers.h
@@ -211,9 +211,6 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di);
void freeTree(HWND hwnd2Tree, HANDLE hContact);
int findItemInTree(HWND hwnd2Tree, HANDLE hContact, char* module);
-// threads.c
-unsigned long forkthread ( void (__cdecl *threadcode)(void*),unsigned long stacksize,void *arg) ;
-
// settinglist.c
void setupSettingsList(HWND hwnd2List);
void saveListSettings(HWND hwnd2List);
diff --git a/plugins/Svc_dbepp/watchedvars.cpp b/plugins/Svc_dbepp/watchedvars.cpp
index 083a23b4b2..b7d2cf6b73 100644
--- a/plugins/Svc_dbepp/watchedvars.cpp
+++ b/plugins/Svc_dbepp/watchedvars.cpp
@@ -204,15 +204,8 @@ INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),4,&sLC);
PopulateWatchedWindow(GetDlgItem(hwnd, IDC_VARS));
-/* if (DBGetContactSettingByte("NULL", modname, "LoadWatchesOnStartup",0))
- {
- MENUITEMINFO mmi;
- mmi.cbSize = sizeof(MENUITEMINFO);
- mmi.fMask = MIIM_STATE;
- mmi.fState = MFS_CHECKED;
- SetMenuItemInfo(GetMenu(hwnd), MENU_LOADAUTOMATCIALLY, FALSE, &mmi);
- }
-*/ TranslateMenu(GetMenu(hwnd));
+
+ TranslateMenu(GetMenu(hwnd));
TranslateMenu(GetSubMenu(GetMenu(hwnd),0));
TranslateDialogDefault(hwnd);
// do the icon
@@ -247,43 +240,17 @@ INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case MENU_REMALL_WATCHES:
freeAllWatches();
ListView_DeleteAllItems(GetDlgItem(hwnd, IDC_VARS));
- break;
+ break;
case MENU_EXIT:
case IDCANCEL:
hwnd2watchedVarsWindow = 0;
DestroyWindow(hwnd);
- break;
+ break;
case MENU_REFRESH:
PopulateWatchedWindow(GetDlgItem(hwnd, IDC_VARS));
- break;
- /* case MENU_LOADAUTOMATCIALLY:
- {
- MENUITEMINFO mmi;
- mmi.cbSize = sizeof(MENUITEMINFO);
- mmi.fMask = MIIM_STATE;
- GetMenuItemInfo(GetSubMenu(GetMenu(hwnd),2), MENU_LOADAUTOMATCIALLY, FALSE, &mmi);
- if (mmi.fState == MFS_CHECKED)
- {
- mmi.fState = MFS_UNCHECKED;
- DBWriteContactSettingByte(NULL,modname, "LoadWatchesOnStartup", 0);
- SetMenuItemInfo(GetSubMenu(GetMenu(hwnd),2), MENU_LOADAUTOMATCIALLY, FALSE, &mmi);
- }
- else if (mmi.fState == MFS_UNCHECKED)
- {
- mmi.fState = MFS_CHECKED;
- DBWriteContactSettingByte(NULL,modname, "LoadWatchesOnStartup", 1);
- SetMenuItemInfo(GetSubMenu(GetMenu(hwnd),2), MENU_LOADAUTOMATCIALLY, FALSE, &mmi);
- }
- }
- break;
- case MENU_SAVE_WATCHES:
- saveWatchedList();
- break;
- case MENU_LOAD_WATCHES:
- loadWatchedList();
- break;
- */ }
- break;
+ }
+ break;
+
case WM_NOTIFY:
switch(LOWORD(wParam))
{
diff --git a/plugins/TabSRMM/chat/message.cpp b/plugins/TabSRMM/chat/message.cpp
index 0a7f56b594..d8682bb1da 100644
--- a/plugins/TabSRMM/chat/message.cpp
+++ b/plugins/TabSRMM/chat/message.cpp
@@ -294,7 +294,7 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO* si)
}
mir_free(pIndex);
- ptszResult = M->utf8_decodeW(pszText);
+ ptszResult = mir_utf8decodeW(pszText);
return ptszResult;
}
diff --git a/plugins/TabSRMM/chat/tools.cpp b/plugins/TabSRMM/chat/tools.cpp
index 3d8d54b381..04fba1aa40 100644
--- a/plugins/TabSRMM/chat/tools.cpp
+++ b/plugins/TabSRMM/chat/tools.cpp
@@ -1159,7 +1159,7 @@ TCHAR* a2tf(const TCHAR* str, int flags, DWORD cp)
TCHAR *result;
if (cp == CP_UTF8)
- return(M->utf8_decodeW((char *)str));
+ return(mir_utf8decodeW((char *)str));
if (cp == 0)
cp = PluginConfig.m_LangPackCP; // CallService( MS_LANGPACK_GETCODEPAGE, 0, 0 );
@@ -1182,7 +1182,7 @@ static char* u2a(const wchar_t* src, DWORD cp)
if (cp == 0)
cp = PluginConfig.m_LangPackCP;
else if (cp == CP_UTF8)
- return(M->utf8_encodeW(src));
+ return(mir_utf8encodeT(src));
cbLen = WideCharToMultiByte(cp, 0, src, -1, NULL, 0, NULL, NULL);
result = (char*)mir_alloc(cbLen + 1);
diff --git a/plugins/TabSRMM/include/mim.h b/plugins/TabSRMM/include/mim.h
index 286848aa11..9ce72e3e69 100644
--- a/plugins/TabSRMM/include/mim.h
+++ b/plugins/TabSRMM/include/mim.h
@@ -43,7 +43,7 @@ extern FI_INTERFACE *FIF;
* Win32 API definitions of functions dynamically obtained via GetProcAddress()
* - uxtheme
* - dwmapi
- * - some GDI functions (AlphaBlend()..)
+ * - some GDI functions (AlphaBlend()..)
*/
typedef BOOL (WINAPI *SMI)( HMENU hmenu, LPCMENUINFO lpcmi );
typedef HRESULT (WINAPI *DEFICA)(HWND hwnd, const MARGINS *margins);
@@ -97,7 +97,6 @@ class CMimAPI
public:
CMimAPI()
{
- GetUTFI();
InitPaths();
InitAPI();
getAeroState();
@@ -149,19 +148,6 @@ public:
INT_PTR FASTCALL WriteTString (const HANDLE hContact, const char *szModule, const char *szSetting, const TCHAR *st) const;
/*
- * utf helpers
- */
-
- char* FASTCALL utf8_decode (char* str, wchar_t** ucs2) const;
- char* FASTCALL utf8_decodecp (char* str, int codepage, wchar_t** ucs2) const;
- char* FASTCALL utf8_encode (const char* src) const;
- char* FASTCALL utf8_encodecp (const char* src, int codepage) const;
- char* FASTCALL utf8_encodeW (const wchar_t* src) const;
- char* FASTCALL utf8_encodeT (const TCHAR* src) const;
- TCHAR* FASTCALL utf8_decodeT (const char* src) const;
- wchar_t* FASTCALL utf8_decodeW (const char* str) const;
-
- /*
* path utilities
*/
@@ -277,7 +263,6 @@ public:
static bool m_shutDown, m_haveBufferedPaint;
private:
- UTF8_INTERFACE m_utfi;
TCHAR m_szProfilePath[MAX_PATH + 2], m_szSkinsPath[MAX_PATH + 2], m_szSavedAvatarsPath[MAX_PATH + 2], m_szChatLogsPath[MAX_PATH + 2];
HMODULE m_hUxTheme, m_hDwmApi;
bool m_VsAPI;
@@ -292,7 +277,6 @@ private:
HANDLE m_hChatLogLock;
void InitAPI();
- void GetUTFI();
void InitPaths();
private:
diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp
index 2f2c59ad6e..8822e094fd 100644
--- a/plugins/TabSRMM/src/buttonsbar.cpp
+++ b/plugins/TabSRMM/src/buttonsbar.cpp
@@ -41,7 +41,7 @@ static void li_ListDestruct(SortedList *pList, ItemDestuctor pItemDestructor)
int i = 0;
if (!pList) return;
for (i = 0; i < pList->realCount; i++) pItemDestructor(pList->items[i]);
- li.List_Destroy(pList);
+ List_Destroy(pList);
mir_free(pList);
}
@@ -49,13 +49,13 @@ static void li_RemoveDestruct(SortedList *pList, int index, ItemDestuctor pItemD
{
if (index >= 0 && index < pList->realCount) {
pItemDestructor(pList->items[index]);
- li.List_Remove(pList, index);
+ List_Remove(pList, index);
}
}
static void li_RemovePtrDestruct(SortedList *pList, void * ptr, ItemDestuctor pItemDestructor)
{
- if (li.List_RemovePtr(pList, ptr))
+ if (List_RemovePtr(pList, ptr))
pItemDestructor(ptr);
}
@@ -137,8 +137,8 @@ static int Hlp_RemoveDatabaseSettings(HANDLE hContact, char *szModule, char *szP
void CB_InitCustomButtons()
{
- LButtonsList = li.List_Create(0, 1);
- RButtonsList = li.List_Create(0, 1);
+ LButtonsList = List_Create(0, 1);
+ RButtonsList = List_Create(0, 1);
InitializeCriticalSection(&ToolBarCS);
dwSepCount = M->GetDword("TabSRMM_Toolbar", "SeparatorsCount", 0);
@@ -228,9 +228,9 @@ void CB_ReInitCustomButtons()
cbd->opFlags ^= BBSF_NTBSWAPED;
if (!(cbd->opFlags&BBSF_NTBDESTRUCT))
- li.List_InsertPtr(RButtonsList, cbd);
+ List_InsertPtr(RButtonsList, cbd);
- li.List_Remove(LButtonsList, i);
+ List_Remove(LButtonsList, i);
i--;
}
}
@@ -241,9 +241,9 @@ void CB_ReInitCustomButtons()
cbd->opFlags ^= BBSF_NTBSWAPED;
if (!(cbd->opFlags&BBSF_NTBDESTRUCT))
- li.List_InsertPtr(LButtonsList, cbd);
+ List_InsertPtr(LButtonsList, cbd);
- li.List_Remove(RButtonsList, i);
+ List_Remove(RButtonsList, i);
i--;
}
}
@@ -257,8 +257,8 @@ void CB_HardReInit()
EnterCriticalSection(&ToolBarCS);
li_ListDestruct(LButtonsList, listdestructor);
li_ListDestruct(RButtonsList, listdestructor);
- LButtonsList = li.List_Create(0, 1);
- RButtonsList = li.List_Create(0, 1);
+ LButtonsList = List_Create(0, 1);
+ RButtonsList = List_Create(0, 1);
LeaveCriticalSection(&ToolBarCS);
LastCID = 4000;
dwSepCount = 0;
@@ -313,9 +313,9 @@ static INT_PTR CB_AddButton(WPARAM wParam, LPARAM lParam)
CB_GetButtonSettings(NULL, cbd);
if (cbd->bLSided)
- li.List_InsertPtr(LButtonsList, cbd);
+ List_InsertPtr(LButtonsList, cbd);
else if (cbd->bRSided)
- li.List_InsertPtr(RButtonsList, cbd);
+ List_InsertPtr(RButtonsList, cbd);
else return 1;
if (cbd->dwButtonCID != cbd->dwButtonOrigID)
@@ -415,7 +415,7 @@ static INT_PTR CB_RemoveButton(WPARAM wParam, LPARAM lParam)
if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
tempCID = cbd->dwButtonCID;
dwFlags = cbd->bLSided ? BBBF_ISLSIDEBUTTON : BBBF_ISRSIDEBUTTON;
- li.List_Remove(LButtonsList, i);
+ List_Remove(LButtonsList, i);
i--;
}
}
@@ -427,7 +427,7 @@ static INT_PTR CB_RemoveButton(WPARAM wParam, LPARAM lParam)
if (!strcmp(cbd->pszModuleName, bbdi->pszModuleName) && (cbd->dwButtonOrigID == bbdi->dwButtonID)) {
tempCID = cbd->dwButtonCID;
dwFlags = cbd->bLSided ? BBBF_ISLSIDEBUTTON : BBBF_ISRSIDEBUTTON;
- li.List_Remove(RButtonsList, i);
+ List_Remove(RButtonsList, i);
i--;
}
}
@@ -1420,7 +1420,7 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l
cbd->pszModuleName = "Tabsrmm_sep";
cbd->iButtonWidth = 22;
cbd->opFlags = BBSF_NTBDESTRUCT;
- li.List_InsertPtr(LButtonsList, cbd);
+ List_InsertPtr(LButtonsList, cbd);
tvis.hParent = NULL;
tvis.hInsertAfter = hti;
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp
index a1c7d1033e..aa242d977c 100644
--- a/plugins/TabSRMM/src/globals.cpp
+++ b/plugins/TabSRMM/src/globals.cpp
@@ -825,7 +825,7 @@ void CGlobals::logStatusChange(WPARAM wParam, const CContactCache *c)
mir_sntprintf(buffer, safe_sizeof(buffer), TranslateT("changed status from %s to %s."), szOldStatus, szNewStatus);
}
- char *szMsg = M->utf8_encodeT(buffer);
+ char *szMsg = mir_utf8encodeT(buffer);
dbei.pBlob = (PBYTE)szMsg;
dbei.cbBlob = lstrlenA(szMsg) + 1;
diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp
index 11ede3460e..95b5375132 100644
--- a/plugins/TabSRMM/src/infopanel.cpp
+++ b/plugins/TabSRMM/src/infopanel.cpp
@@ -1389,7 +1389,7 @@ CTip::CTip(const HWND hwndParent, const HANDLE hContact, const TCHAR *pszText, c
m_hContact = hContact;
if(pszText)
- m_pszText = M->utf8_encodeT(pszText);
+ m_pszText = mir_utf8encodeT(pszText);
else
m_pszText = 0;
m_panel = panel;
diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp
index dfd38998fd..dd4999d480 100644
--- a/plugins/TabSRMM/src/mim.cpp
+++ b/plugins/TabSRMM/src/mim.cpp
@@ -182,48 +182,6 @@ INT_PTR CMimAPI::WriteTString(const HANDLE hContact, const char *szModule = 0, c
return(DBWriteContactSettingTString(hContact, szModule, szSetting, str));
}
-void CMimAPI::GetUTFI()
-{
- mir_getUTFI(&m_utfi);
-}
-char *CMimAPI::utf8_decode(char* str, wchar_t** ucs2) const
-{
- return(m_utfi.utf8_decode(str, ucs2));
-}
-char *CMimAPI::utf8_decodecp(char* str, int codepage, wchar_t** ucs2 ) const
-{
- return(m_utfi.utf8_decodecp(str, codepage, ucs2));
-}
-char *CMimAPI::utf8_encode(const char* src) const
-{
- return(m_utfi.utf8_encode(src));
-}
-
-char *CMimAPI::utf8_encodecp(const char* src, int codepage) const
-{
- return(m_utfi.utf8_encodecp(src, codepage));
-}
-
-char *CMimAPI::utf8_encodeW(const wchar_t* src) const
-{
- return(m_utfi.utf8_encodeW(src));
-}
-
-char *CMimAPI::utf8_encodeT(const TCHAR* src) const
-{
- return(m_utfi.utf8_encodeW(src));
-}
-
-TCHAR *CMimAPI::utf8_decodeT(const char* src) const
-{
- return(m_utfi.utf8_decodeW(src));
-}
-
-wchar_t *CMimAPI::utf8_decodeW(const char* str) const
-{
- return(m_utfi.utf8_decodeW(str));
-}
-
/**
* Case insensitive _tcsstr
*
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 9f59917293..5699b03e3c 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -3009,7 +3009,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
streamOut = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_MESSAGE), dat, final_sendformat ? 0 : (CP_UTF8 << 16) | (SF_TEXT | SF_USECODEPAGE));
if (streamOut != NULL) {
- decoded = M->utf8_decodeW(streamOut);
+ decoded = mir_utf8decodeW(streamOut);
if (decoded != NULL) {
char* utfResult = NULL;
if (final_sendformat)
@@ -3022,7 +3022,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
memRequired = bufSize + ((lstrlenW(decoded) + 1) * sizeof(WCHAR));
} else {
flags |= PREF_UTF;
- utfResult = M->utf8_encodeW(decoded);
+ utfResult = mir_utf8encodeT(decoded);
memRequired = (int)(strlen(utfResult)) + 1;
}
@@ -3158,7 +3158,7 @@ quote_from_last:
CallService(MS_DB_EVENT_GET, (WPARAM)hDBEvent, (LPARAM)&dbei);
iSize = (int)(strlen((char *)dbei.pBlob)) + 1;
if (dbei.flags & DBEF_UTF) {
- szConverted = M->utf8_decodeW((char*)szText);
+ szConverted = mir_utf8decodeW((char*)szText);
iAlloced = TRUE;
} else {
if (iSize != dbei.cbBlob)
@@ -3188,7 +3188,7 @@ quote_from_last:
} else {
wchar_t *converted = 0;
szFromStream = Message_GetFromStream(GetDlgItem(hwndDlg, IDC_LOG), dat, SF_TEXT | SF_USECODEPAGE | SFF_SELECTION);
- converted = M->utf8_decodeW(szFromStream);
+ converted = mir_utf8decodeW(szFromStream);
Utils::FilterEventMarkers(converted);
szQuoted = QuoteText(converted, iCharsPerLine, 0);
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)szQuoted);
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp
index 4490f8b2e6..1cc4a68785 100644
--- a/plugins/TabSRMM/src/sendlater.cpp
+++ b/plugins/TabSRMM/src/sendlater.cpp
@@ -367,7 +367,7 @@ int CSendLater::addJob(const char *szSetting, LPARAM lParam)
* construct conventional send buffer
*/
- szAnsi = M->utf8_decodecp(szOrig_Utf, CP_ACP, &szWchar);
+ szAnsi = mir_utf8decodecp(szOrig_Utf, CP_ACP, &szWchar);
iLen = lstrlenA(szAnsi);
if(szWchar)
required = iLen + 1 + ((lstrlenW(szWchar) + 1) * sizeof(wchar_t));
@@ -640,7 +640,7 @@ void CSendLater::qMgrFillList(bool fClear)
lvItem.iSubItem = 1;
::SendMessage(m_hwndList, LVM_SETITEM, 0, reinterpret_cast<LPARAM>(&lvItem));
- TCHAR* msg = M->utf8_decodeT((*it)->sendBuffer);
+ TCHAR* msg = mir_utf8decodeT((*it)->sendBuffer);
TCHAR* preview = Utils::GetPreviewWithEllipsis(msg, 255);
lvItem.pszText = preview;
lvItem.iSubItem = 2;
@@ -919,7 +919,7 @@ INT_PTR CALLBACK CSendLater::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
job->writeFlags();
break;
case ID_QUEUEMANAGER_COPYMESSAGETOCLIPBOARD: {
- TCHAR *msg = M->utf8_decodeT(job->sendBuffer);
+ TCHAR *msg = mir_utf8decodeT(job->sendBuffer);
Utils::CopyToClipBoard(msg, m_hwndDlg);
mir_free(msg);
break;
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp
index baf1289713..e3d22eb415 100644
--- a/plugins/TabSRMM/src/sendqueue.cpp
+++ b/plugins/TabSRMM/src/sendqueue.cpp
@@ -364,7 +364,7 @@ int SendQueue::getSendLength(const int iEntry, int sendMode)
char *utf8;
iLen = lstrlenA(m_jobs[iEntry].sendBuffer);
wszBuf = (WCHAR *) & m_jobs[iEntry].sendBuffer[iLen + 1];
- utf8 = M->utf8_encodeW(wszBuf);
+ utf8 = mir_utf8encodeT(wszBuf);
m_jobs[iEntry].iSendLength = lstrlenA(utf8);
mir_free(utf8);
return(m_jobs[iEntry].iSendLength);
@@ -901,7 +901,7 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, HANDLE hContact, boo
else
szNote = TranslateT("The send later feature is not available on this protocol.");
- char *utfText = M->utf8_encodeT(szNote);
+ char *utfText = mir_utf8encodeT(szNote);
DBEVENTINFO dbei;
dbei.cbSize = sizeof(dbei);
dbei.eventType = EVENTTYPE_MESSAGE;
@@ -943,7 +943,7 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, HANDLE hContact, boo
mir_sntprintf(tszHeader, safe_sizeof(tszHeader), _T("M%d|"), time(0));
if(job->dwFlags & PREF_UTF || !(job->dwFlags & PREF_UNICODE)) {
- char *utf_header = M->utf8_encodeT(tszHeader);
+ char *utf_header = mir_utf8encodeT(tszHeader);
UINT required = lstrlenA(utf_header) + lstrlenA(job->sendBuffer) + 10;
char *tszMsg = reinterpret_cast<char *>(mir_alloc(required));
@@ -969,7 +969,7 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, HANDLE hContact, boo
mir_sntprintf(tszMsg, required, _T("%s%s"), wszMsg, tszHeader);
else
mir_sntprintf(tszMsg, required, _T("%s%s"), tszHeader, wszMsg);
- char *utf = M->utf8_encodeT(tszMsg);
+ char *utf = mir_utf8encodeT(tszMsg);
if(fIsSendLater)
DBWriteContactSettingString(hContact ? hContact : job->hOwner, "SendLater", szKeyName, utf);
else
diff --git a/plugins/TabSRMM/src/srmm.cpp b/plugins/TabSRMM/src/srmm.cpp
index ebb6cb002c..7e009b436b 100644
--- a/plugins/TabSRMM/src/srmm.cpp
+++ b/plugins/TabSRMM/src/srmm.cpp
@@ -164,7 +164,7 @@ int _DebugTraceW(const wchar_t *fmt, ...)
mir_snprintf(szLogFileName, MAX_PATH, "%s\\%s", szDataPath, "tabsrmm_debug.log");
f = fopen(szLogFileName, "a+");
if (f) {
- char *szDebug = M->utf8_encodeW(debug);
+ char *szDebug = mir_utf8encodeT(debug);
fputs(tszTime, f);
fputs(szDebug, f);
fputs("\n", f);
diff --git a/plugins/TabSRMM/src/themeio.cpp b/plugins/TabSRMM/src/themeio.cpp
index 2eb29884dd..b5998c2fe9 100644
--- a/plugins/TabSRMM/src/themeio.cpp
+++ b/plugins/TabSRMM/src/themeio.cpp
@@ -234,15 +234,15 @@ void TSAPI WriteThemeToINI(const TCHAR *szIniFilenameT, struct TWindowData *dat)
for (i = 0; i <= TMPL_ERRMSG; i++) {
char *encoded;
if (dat == 0)
- encoded = M->utf8_encodeW(LTR_Active.szTemplates[i]);
+ encoded = mir_utf8encodeT(LTR_Active.szTemplates[i]);
else
- encoded = M->utf8_encodeW(dat->pContainer->ltr_templates->szTemplates[i]);
+ encoded = mir_utf8encodeT(dat->pContainer->ltr_templates->szTemplates[i]);
WritePrivateProfileStringA("Templates", TemplateNames[i], encoded, szIniFilename);
mir_free(encoded);
if (dat == 0)
- encoded = M->utf8_encodeW(RTL_Active.szTemplates[i]);
+ encoded = mir_utf8encodeT(RTL_Active.szTemplates[i]);
else
- encoded = M->utf8_encodeW(dat->pContainer->rtl_templates->szTemplates[i]);
+ encoded = mir_utf8encodeT(dat->pContainer->rtl_templates->szTemplates[i]);
WritePrivateProfileStringA("RTLTemplates", TemplateNames[i], encoded, szIniFilename);
mir_free(encoded);
}
@@ -406,7 +406,7 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in
if (strcmp(szTemplateBuffer, "[undef]")) {
if (dat == 0)
DBWriteContactSettingStringUtf(NULL, TEMPLATES_MODULE, TemplateNames[i], szTemplateBuffer);
- decoded = M->utf8_decodeW(szTemplateBuffer);
+ decoded = mir_utf8decodeW(szTemplateBuffer);
if (dat == 0)
mir_sntprintf(LTR_Active.szTemplates[i], TEMPLATE_LENGTH, L"%s", decoded);
else
@@ -419,7 +419,7 @@ void TSAPI ReadThemeFromINI(const TCHAR *szIniFilenameT, TContainerData *dat, in
if (strcmp(szTemplateBuffer, "[undef]")) {
if (dat == 0)
DBWriteContactSettingStringUtf(NULL, RTLTEMPLATES_MODULE, TemplateNames[i], szTemplateBuffer);
- decoded = M->utf8_decodeW(szTemplateBuffer);
+ decoded = mir_utf8decodeW(szTemplateBuffer);
if (dat == 0)
mir_sntprintf(RTL_Active.szTemplates[i], TEMPLATE_LENGTH, L"%s", decoded);
else
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp
index e80882a456..bfe5f0cb7b 100644
--- a/plugins/TabSRMM/src/utils.cpp
+++ b/plugins/TabSRMM/src/utils.cpp
@@ -1412,7 +1412,7 @@ INT_PTR CALLBACK CWarning::dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
str->insert(pos, L"\\line ");
}
- char *utf8 = M->utf8_encodeT(str->c_str());
+ char *utf8 = mir_utf8encodeT(str->c_str());
::SendDlgItemMessage(hwnd, IDC_WARNTEXT, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)utf8);
mir_free(utf8);
delete str;
diff --git a/plugins/TipperYM/mir_smileys.cpp b/plugins/TipperYM/mir_smileys.cpp
index 23fce34db2..5af05c4b22 100644
--- a/plugins/TipperYM/mir_smileys.cpp
+++ b/plugins/TipperYM/mir_smileys.cpp
@@ -354,8 +354,8 @@ void DestroySmileyList(SortedList* p_list)
}
}
}
- li.List_Destroy(p_list); //this free the p_list->items member
- mir_free(p_list); //this free the p_list itself (alloc by li.List_Create)
+ List_Destroy(p_list); //this free the p_list->items member
+ mir_free(p_list); //this free the p_list itself (alloc by List_Create)
}
// Generete the list of smileys / text to be drawn
@@ -388,7 +388,7 @@ SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protoco
return NULL;
// Lets add smileys
- SortedList *plText = li.List_Create(0, 10);
+ SortedList *plText = List_Create(0, 10);
TCHAR *word_start, *word_end;
TCHAR *smiley_start, *smiley_end;
@@ -428,7 +428,7 @@ SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protoco
piece->type = TEXT_PIECE_TYPE_TEXT;
piece->start_pos = word_start - text;
piece->len = word_end - word_start;
- li.List_Insert(plText, piece, plText->realCount);
+ List_Insert(plText, piece, plText->realCount);
word_start = word_end;
}
}
@@ -458,7 +458,7 @@ SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protoco
}
*max_smiley_height = max(piece->smiley_height, *max_smiley_height);
- li.List_Insert(plText, piece, plText->realCount);
+ List_Insert(plText, piece, plText->realCount);
}
word_start = word_end = smiley_end;
@@ -480,7 +480,7 @@ SortedList *ReplaceSmileys(const TCHAR *text, int text_size, const char *protoco
piece->type = TEXT_PIECE_TYPE_TEXT;
piece->start_pos = word_start - text;
piece->len = word_end - word_start;
- li.List_Insert(plText, piece, plText->realCount);
+ List_Insert(plText, piece, plText->realCount);
word_start = word_end;
}
diff --git a/plugins/UserInfoEx/classMTime.cpp b/plugins/UserInfoEx/classMTime.cpp
index 6e03c02eaf..3b1dd2e081 100644
--- a/plugins/UserInfoEx/classMTime.cpp
+++ b/plugins/UserInfoEx/classMTime.cpp
@@ -291,9 +291,9 @@ DWORD MTime::TimeStamp() const
li.QuadPart /= 10000000i64;
li.QuadPart -= 11644473600i64;
- if (li.QuadPart < 0) {
+ if (li.QuadPart < 0)
return 0;
- }
+
return (DWORD)li.QuadPart;
}
@@ -372,7 +372,6 @@ WORD MTime::DateFormatLong(LPTSTR ptszTimeFormat, WORD cchTimeFormat)
VOID MTime::FromStampAsUTC(const DWORD dwTimeStamp)
{
LARGE_INTEGER li;
-
li.QuadPart = (dwTimeStamp + 11644473600i64) * 10000000i64;
Set(li, FALSE);
}
diff --git a/plugins/UserInfoEx/commonheaders.cpp b/plugins/UserInfoEx/commonheaders.cpp
index a69a664168..f74cb2261e 100644
--- a/plugins/UserInfoEx/commonheaders.cpp
+++ b/plugins/UserInfoEx/commonheaders.cpp
@@ -30,7 +30,6 @@ Last change by : $Author: ing.u.horn $
#include "commonheaders.h"
// global:
-PLUGINLINK* pluginLink = NULL;
HINSTANCE ghInst = NULL;
MM_INTERFACE mmi; //memory interface
UTF8_INTERFACE utfi; //utf8 interface
diff --git a/plugins/UserInfoEx/init.cpp b/plugins/UserInfoEx/init.cpp
index 0054755e33..1cab813504 100644
--- a/plugins/UserInfoEx/init.cpp
+++ b/plugins/UserInfoEx/init.cpp
@@ -72,6 +72,7 @@ static HANDLE ghModernToolBarLoaded = NULL;
static HANDLE ghShutdownHook = NULL;
static HANDLE ghPrebuildStatusMenu = NULL;
int hLangpack;
+PLUGINLINK* pluginLink = NULL;
/*
============================================================================================
diff --git a/plugins/Variables/tokenregister.cpp b/plugins/Variables/tokenregister.cpp
index 56d30ffc30..54a40a5147 100644
--- a/plugins/Variables/tokenregister.cpp
+++ b/plugins/Variables/tokenregister.cpp
@@ -48,7 +48,7 @@ static TokenRegisterEntry* FindTokenRegisterByName(TCHAR *name)
int idx;
TokenRegisterEntry temp;
temp.nameHash = NameHashFunction( name );
- if ( li.List_GetIndex(( SortedList* )&tokens, &temp, &idx ))
+ if ( List_GetIndex(( SortedList* )&tokens, &temp, &idx ))
return tokens.items[ idx ];
return NULL;
@@ -81,7 +81,7 @@ int deRegisterToken(TCHAR *token) {
return -1;
}
- li.List_RemovePtr(( SortedList* )&tokens, tre );
+ List_RemovePtr(( SortedList* )&tokens, tre );
LeaveCriticalSection(&csRegister);
if ( !( tre->tr.flags & TRF_PARSEFUNC ) && tre->tr.szService != NULL )
@@ -151,8 +151,8 @@ INT_PTR registerToken(WPARAM wParam, LPARAM lParam)
tre->tr.szCleanupService = _strdup( newVr->szCleanupService );
EnterCriticalSection(&csRegister);
- li.List_GetIndex(( SortedList* )&tokens, tre, &idx );
- li.List_Insert(( SortedList* )&tokens, tre, idx );
+ List_GetIndex(( SortedList* )&tokens, tre, &idx );
+ List_Insert(( SortedList* )&tokens, tre, idx );
LeaveCriticalSection(&csRegister);
return 0;
@@ -316,7 +316,7 @@ int deinitTokenRegister()
free( tre );
}
- li.List_Destroy(( SortedList* )&tokens );
+ List_Destroy(( SortedList* )&tokens );
LeaveCriticalSection(&csRegister);
DeleteCriticalSection(&csRegister);
diff --git a/plugins/helpers/gen_helpers.cpp b/plugins/helpers/gen_helpers.cpp
index a792493284..87dd135c6f 100644
--- a/plugins/helpers/gen_helpers.cpp
+++ b/plugins/helpers/gen_helpers.cpp
@@ -267,140 +267,6 @@ TCHAR *itot(int num) {
}
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Decode - converts UTF8-encoded string to the UCS2/MBCS format
-
-void Utf8Decode( char* str, wchar_t** ucs2 )
-{
- if ( str == NULL )
- return;
-
- size_t len = strlen( str );
- if ( len < 2 ) {
- if ( ucs2 != NULL ) {
- *ucs2 = ( wchar_t* )malloc(( len+1 )*sizeof( wchar_t ));
- MultiByteToWideChar( CP_ACP, 0, str, len, *ucs2, len );
- ( *ucs2 )[ len ] = 0;
- }
- return;
- }
-
- wchar_t* tempBuf = ( wchar_t* )alloca(( len+1 )*sizeof( wchar_t ));
- {
- wchar_t* d = tempBuf;
- BYTE* s = ( BYTE* )str;
-
- while( *s )
- {
- if (( *s & 0x80 ) == 0 ) {
- *d++ = *s++;
- continue;
- }
-
- if (( s[0] & 0xE0 ) == 0xE0 && ( s[1] & 0xC0 ) == 0x80 && ( s[2] & 0xC0 ) == 0x80 ) {
- *d++ = (( WORD )( s[0] & 0x0F) << 12 ) + ( WORD )(( s[1] & 0x3F ) << 6 ) + ( WORD )( s[2] & 0x3F );
- s += 3;
- continue;
- }
-
- if (( s[0] & 0xE0 ) == 0xC0 && ( s[1] & 0xC0 ) == 0x80 ) {
- *d++ = ( WORD )(( s[0] & 0x1F ) << 6 ) + ( WORD )( s[1] & 0x3F );
- s += 2;
- continue;
- }
-
- *d++ = *s++;
- }
-
- *d = 0;
- }
-
- if ( ucs2 != NULL ) {
- int fullLen = ( len+1 )*sizeof( wchar_t );
- *ucs2 = ( wchar_t* )malloc( fullLen );
- memcpy( *ucs2, tempBuf, fullLen );
- }
-
- WideCharToMultiByte( CP_ACP, 0, tempBuf, -1, str, len, NULL, NULL );
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Encode - converts MBCS string to the UTF8-encoded format
-
-char* Utf8Encode( const char* src )
-{
- if ( src == NULL )
- return NULL;
-
- size_t len = strlen( src );
- char* result = ( char* )malloc( len*3 + 1 );
- if ( result == NULL )
- return NULL;
-
- wchar_t* tempBuf = ( wchar_t* )alloca(( len+1 )*sizeof( wchar_t ));
- MultiByteToWideChar( CP_ACP, 0, src, -1, tempBuf, len );
- tempBuf[ len ] = 0;
- {
- wchar_t* s = tempBuf;
- BYTE* d = ( BYTE* )result;
-
- while( *s ) {
- int U = *s++;
-
- if ( U < 0x80 ) {
- *d++ = ( BYTE )U;
- }
- else if ( U < 0x800 ) {
- *d++ = 0xC0 + (( U >> 6 ) & 0x3F );
- *d++ = 0x80 + ( U & 0x003F );
- }
- else {
- *d++ = 0xE0 + ( U >> 12 );
- *d++ = 0x80 + (( U >> 6 ) & 0x3F );
- *d++ = 0x80 + ( U & 0x3F );
- } }
-
- *d = 0;
- }
-
- return result;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Encode - converts UCS2 string to the UTF8-encoded format
-
-char* Utf8EncodeUcs2( const wchar_t* src )
-{
- int len = wcslen( src );
- char* result = ( char* )malloc( len*3 + 1 );
- if ( result == NULL )
- return NULL;
-
- { const wchar_t* s = src;
- BYTE* d = ( BYTE* )result;
-
- while( *s ) {
- int U = *s++;
-
- if ( U < 0x80 ) {
- *d++ = ( BYTE )U;
- }
- else if ( U < 0x800 ) {
- *d++ = 0xC0 + (( U >> 6 ) & 0x3F );
- *d++ = 0x80 + ( U & 0x003F );
- }
- else {
- *d++ = 0xE0 + ( U >> 12 );
- *d++ = 0x80 + (( U >> 6 ) & 0x3F );
- *d++ = 0x80 + ( U & 0x3F );
- } }
-
- *d = 0;
- }
-
- return result;
-}
-
// Helper functions that need MODULENAME
#define SETTING_NOENCODINGCHECK "NoEncodingCheck"
diff --git a/plugins/helpers/gen_helpers.h b/plugins/helpers/gen_helpers.h
index 8f4d91b940..110ea9d30a 100644
--- a/plugins/helpers/gen_helpers.h
+++ b/plugins/helpers/gen_helpers.h
@@ -33,10 +33,6 @@ wchar_t* a2u( char* src );
int ttoi(TCHAR *string);
TCHAR *itot(int num);
-char* Utf8EncodeUcs2( const wchar_t* src );
-char* Utf8Encode( const char* src );
-void Utf8Decode( char* str, wchar_t** ucs2 );
-
#define MAX_DEBUG 1024
#define __LOGLEVEL_DEBUG 10
diff --git a/plugins/mir_core/commonheaders.cpp b/plugins/mir_core/commonheaders.cpp
new file mode 100644
index 0000000000..95b2201163
--- /dev/null
+++ b/plugins/mir_core/commonheaders.cpp
@@ -0,0 +1,2 @@
+#include "commonheaders.h"
+
diff --git a/plugins/mir_core/commonheaders.h b/plugins/mir_core/commonheaders.h
new file mode 100644
index 0000000000..2d04e12f4b
--- /dev/null
+++ b/plugins/mir_core/commonheaders.h
@@ -0,0 +1,63 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 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.
+*/
+
+#define MIRANDA_VER 0x0A00
+
+#define WINVER 0x0700
+#define _WIN32_WINNT 0x0700
+#define _WIN32_IE 0x0601
+
+#define INCL_WINSOCK_API_TYPEDEFS 1
+
+#include "m_stdhdr.h"
+
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <windows.h>
+#include <windowsx.h>
+#include <shlobj.h>
+#include <uxtheme.h>
+#include <commctrl.h>
+#include <vssym32.h>
+
+#include <stdio.h>
+#include <time.h>
+#include <stddef.h>
+#include <process.h>
+#include <io.h>
+#include <limits.h>
+#include <string.h>
+#include <locale.h>
+#include <direct.h>
+
+#include <win2k.h>
+
+#include <m_system.h>
+#include <m_system_cpp.h>
+#include <m_database.h>
+#include <newpluginapi.h>
+
+#include "miranda.h"
+
+#include <m_ssl.h>
+#include <m_xml.h>
diff --git a/plugins/mir_core/langpack.cpp b/plugins/mir_core/langpack.cpp
new file mode 100644
index 0000000000..d38dd6807d
--- /dev/null
+++ b/plugins/mir_core/langpack.cpp
@@ -0,0 +1,630 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 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.
+*/
+#include "commonheaders.h"
+
+#define LANGPACK_BUF_SIZE 4000
+
+static int CompareMuuids(const LangPackMuuid* p1, const LangPackMuuid* p2)
+{
+ return memcmp(&p1->muuid, &p2->muuid, sizeof(MUUID));
+}
+
+static LIST<LangPackMuuid> lMuuids(10, CompareMuuids);
+static LangPackMuuid* pCurrentMuuid = NULL;
+
+static BOOL bModuleInitialized = FALSE;
+
+struct LangPackEntry {
+ DWORD englishHash;
+ char *local;
+ wchar_t *wlocal;
+ LangPackMuuid* pMuuid;
+ LangPackEntry* pNext; // for langpack items with the same hash value
+};
+
+struct LangPackStruct {
+ TCHAR filename[MAX_PATH];
+ TCHAR filePath[MAX_PATH];
+ char language[64];
+ char lastModifiedUsing[64];
+ char authors[256];
+ char authorEmail[128];
+ LangPackEntry *entry;
+ int entryCount, entriesAlloced;
+ LCID localeID;
+ UINT defaultANSICp;
+} static langPack;
+
+static int IsEmpty(char *str)
+{
+ int i = 0;
+
+ while (str[i])
+ {
+ if (str[i] != ' ' && str[i] != '\r' && str[i] != '\n')
+ return 0;
+ i++;
+ }
+ return 1;
+}
+
+static void ConvertBackslashes(char *str, UINT fileCp)
+{
+ char *pstr;
+ for (pstr = str; *pstr; pstr = CharNextExA(fileCp, pstr, 0)) {
+ if (*pstr == '\\') {
+ switch(pstr[1]) {
+ case 'n': *pstr = '\n'; break;
+ case 't': *pstr = '\t'; break;
+ case 'r': *pstr = '\r'; break;
+ default: *pstr = pstr[1]; break;
+ }
+ memmove(pstr+1, pstr+2, strlen(pstr+2) + 1);
+} } }
+
+#ifdef _DEBUG
+//#pragma optimize("gt", on)
+#endif
+
+// MurmurHash2
+MIR_CORE_DLL(unsigned int) mir_hash(const void * key, unsigned int len)
+{
+ // 'm' and 'r' are mixing constants generated offline.
+ // They're not really 'magic', they just happen to work well.
+ const unsigned int m = 0x5bd1e995;
+ const int r = 24;
+
+ // Initialize the hash to a 'random' value
+ unsigned int h = len;
+
+ // Mix 4 bytes at a time into the hash
+ const unsigned char * data = (const unsigned char *)key;
+
+ while (len >= 4)
+ {
+ unsigned int k = *(unsigned int *)data;
+
+ k *= m;
+ k ^= k >> r;
+ k *= m;
+
+ h *= m;
+ h ^= k;
+
+ data += 4;
+ len -= 4;
+ }
+
+ // Handle the last few bytes of the input array
+ switch(len)
+ {
+ case 3: h ^= data[2] << 16;
+ case 2: h ^= data[1] << 8;
+ case 1: h ^= data[0];
+ h *= m;
+ };
+
+ // Do a few final mixes of the hash to ensure the last few
+ // bytes are well-incorporated.
+ h ^= h >> 13;
+ h *= m;
+ h ^= h >> 15;
+
+ return h;
+}
+
+static int SortLangPackHashesProc(LangPackEntry *arg1, LangPackEntry *arg2)
+{
+ if (arg1->englishHash < arg2->englishHash) return -1;
+ if (arg1->englishHash > arg2->englishHash) return 1;
+
+ return (arg1->pMuuid < arg2->pMuuid) ? -1 : 1;
+}
+
+static void swapBytes(void* p, size_t iSize)
+{
+ char *head = (char *)p; // here
+ char *tail = head + iSize - 1;
+
+ for (; tail > head; --tail, ++head) {
+ char temp = *head;
+ *head = *tail;
+ *tail = temp;
+ }
+}
+
+static bool EnterMuuid(const char* p, MUUID& result)
+{
+ if (*p++ != '{')
+ return false;
+
+ BYTE* d = (BYTE*)&result;
+
+ for (int nBytes = 0; *p && nBytes < 24; p++) {
+ if (*p == '-')
+ continue;
+
+ if (*p == '}')
+ break;
+
+ if ( !isxdigit(*p))
+ return false;
+
+ if ( !isxdigit(p[1]))
+ return false;
+
+ int c = 0;
+ if (sscanf(p, "%2x", &c) != 1)
+ return false;
+
+ *d++ = (BYTE)c;
+ nBytes++;
+ p++;
+ }
+
+ if (*p != '}')
+ return false;
+
+ swapBytes(&result.a, sizeof(result.a));
+ swapBytes(&result.b, sizeof(result.b));
+ swapBytes(&result.c, sizeof(result.c));
+ return true;
+}
+
+static void LoadLangPackFile(FILE* fp, char* line, UINT fileCp)
+{
+ while ( !feof(fp)) {
+ if (fgets(line, LANGPACK_BUF_SIZE, fp) == NULL)
+ break;
+
+ if (IsEmpty(line) || line[0] == ';' || line[0] == 0)
+ continue;
+
+ rtrim(line);
+
+ if (line[0] == '#') {
+ strlwr(line);
+
+ if ( !memcmp(line+1, "include", 7)) {
+ TCHAR tszFileName[ MAX_PATH ];
+ TCHAR* fileName = mir_a2t(ltrim(line+9));
+ mir_sntprintf(tszFileName, SIZEOF(tszFileName), _T("%s%s"), langPack.filePath, fileName);
+ mir_free(fileName);
+
+ FILE* p = _tfopen(tszFileName, _T("r"));
+ if (p) {
+ line[0] = 0;
+ fgets(line, SIZEOF(line), p);
+
+ UINT fileCp = CP_ACP;
+ if (strlen(line) >= 3 && line[0] == '\xef' && line[1] == '\xbb' && line[2] == '\xbf')
+ {
+ fileCp = CP_UTF8;
+ fseek(p, 3, SEEK_SET);
+ }
+ else
+ {
+ fileCp = langPack.defaultANSICp;
+ fseek(p, 0, SEEK_SET);
+ }
+
+ LoadLangPackFile(p, line, fileCp);
+ fclose(p);
+ }
+ }
+ else if ( !memcmp(line+1, "muuid", 5)) {
+ MUUID t;
+ if ( !EnterMuuid(line+7, t))
+ continue;
+
+ LangPackMuuid* pNew = (LangPackMuuid*)mir_alloc(sizeof(LangPackMuuid));
+ memcpy(&pNew->muuid, &t, sizeof(t));
+ pNew->pInfo = NULL;
+ lMuuids.insert(pNew);
+ pCurrentMuuid = pNew;
+ }
+
+ continue;
+ }
+
+ ConvertBackslashes(line, fileCp);
+
+ if (line[0] == '[' && line[ lstrlenA(line)-1 ] == ']') {
+ if (langPack.entryCount && langPack.entry[ langPack.entryCount-1].local == NULL)
+ langPack.entryCount--;
+
+ char* pszLine = line+1;
+ line[ lstrlenA(line)-1 ] = '\0';
+ if (++langPack.entryCount > langPack.entriesAlloced) {
+ langPack.entriesAlloced += 128;
+ langPack.entry = (LangPackEntry*)mir_realloc(langPack.entry, sizeof(LangPackEntry)*langPack.entriesAlloced);
+ }
+
+ LangPackEntry* E = &langPack.entry[ langPack.entryCount-1 ];
+ E->englishHash = mir_hashstr(pszLine);
+ E->local = NULL;
+ E->wlocal = NULL;
+ E->pMuuid = pCurrentMuuid;
+ E->pNext = NULL;
+ continue;
+ }
+
+ if ( !langPack.entryCount)
+ continue;
+
+ LangPackEntry* E = &langPack.entry[ langPack.entryCount-1 ];
+ if (E->local == NULL) {
+ E->local = mir_strdup(line);
+ if (fileCp == CP_UTF8)
+ Utf8DecodeCP(E->local, langPack.defaultANSICp, NULL);
+
+ int iNeeded = MultiByteToWideChar(fileCp, 0, line, -1, 0, 0);
+ E->wlocal = (wchar_t *)mir_alloc((iNeeded+1) * sizeof(wchar_t));
+ MultiByteToWideChar(fileCp, 0, line, -1, E->wlocal, iNeeded);
+ }
+ else {
+ size_t iOldLenA = strlen(E->local);
+ E->local = (char*)mir_realloc(E->local, iOldLenA + strlen(line) + 2);
+ strcat(E->local, "\n");
+ strcat(E->local, line);
+
+ if (fileCp == CP_UTF8)
+ Utf8DecodeCP(E->local + iOldLenA + 1, langPack.defaultANSICp, NULL);
+
+ int iNeeded = MultiByteToWideChar(fileCp, 0, line, -1, 0, 0);
+ size_t iOldLen = wcslen(E->wlocal);
+ E->wlocal = (wchar_t*)mir_realloc(E->wlocal, (sizeof(wchar_t) * (iOldLen + iNeeded + 2)));
+ wcscat(E->wlocal, L"\n");
+ MultiByteToWideChar(fileCp, 0, line, -1, E->wlocal + iOldLen + 1, iNeeded);
+ }
+ }
+}
+
+MIR_CORE_DLL(int) LoadLangPack(const TCHAR *szLangPack)
+{
+ int startOfLine=0;
+ USHORT langID;
+
+ lstrcpy(langPack.filename, szLangPack);
+ lstrcpy(langPack.filePath, szLangPack);
+ TCHAR* p = _tcsrchr(langPack.filePath, '\\');
+ if (p)
+ p[1] = 0;
+
+ FILE *fp = _tfopen(szLangPack, _T("rt"));
+ if (fp == NULL)
+ return 1;
+
+ char line[ LANGPACK_BUF_SIZE ] = "";
+ fgets(line, SIZEOF(line), fp);
+
+ UINT fileCp = CP_ACP;
+ size_t lineLen = strlen(line);
+ if (lineLen >= 3 && line[0] == '\xef' && line[1] == '\xbb' && line[2] == '\xbf')
+ {
+ fileCp = CP_UTF8;
+ memmove(line, line + 3, lineLen - 2);
+ }
+
+ lrtrim(line);
+ if (lstrcmpA(line, "Miranda Language Pack Version 1")) {
+ fclose(fp);
+ return 2;
+ }
+
+ //headers
+ while ( !feof(fp)) {
+ startOfLine = ftell(fp);
+ if (fgets(line, SIZEOF(line), fp) == NULL)
+ break;
+
+ lrtrim(line);
+ if (IsEmpty(line) || line[0] == ';' || line[0] == 0)
+ continue;
+
+ if (line[0] == '[' || line[0] == '#')
+ break;
+
+ char* pszColon = strchr(line, ':');
+ if (pszColon == NULL) {
+ fclose(fp);
+ return 3;
+ }
+
+ *pszColon++ = 0;
+ if ( !lstrcmpA(line, "Language")) {mir_snprintf(langPack.language, sizeof(langPack.language), "%s", pszColon); lrtrim(langPack.language);}
+ else if ( !lstrcmpA(line, "Last-Modified-Using")) {mir_snprintf(langPack.lastModifiedUsing, sizeof(langPack.lastModifiedUsing), "%s", pszColon); lrtrim(langPack.lastModifiedUsing);}
+ else if ( !lstrcmpA(line, "Authors")) {mir_snprintf(langPack.authors, sizeof(langPack.authors), "%s", pszColon); lrtrim(langPack.authors);}
+ else if ( !lstrcmpA(line, "Author-email")) {mir_snprintf(langPack.authorEmail, sizeof(langPack.authorEmail), "%s", pszColon); lrtrim(langPack.authorEmail);}
+ else if ( !lstrcmpA(line, "Locale")) {
+ char szBuf[20], *stopped;
+
+ lrtrim(pszColon + 1);
+ langID = (USHORT)strtol(pszColon, &stopped, 16);
+ langPack.localeID = MAKELCID(langID, 0);
+ GetLocaleInfoA(langPack.localeID, LOCALE_IDEFAULTANSICODEPAGE, szBuf, 10);
+ szBuf[5] = 0; // codepages have max. 5 digits
+ langPack.defaultANSICp = atoi(szBuf);
+ if (fileCp == CP_ACP)
+ fileCp = langPack.defaultANSICp;
+ }
+ }
+
+ //body
+ fseek(fp, startOfLine, SEEK_SET);
+ langPack.entriesAlloced = 0;
+
+ LoadLangPackFile(fp, line, fileCp);
+ fclose(fp);
+ pCurrentMuuid = NULL;
+
+ qsort(langPack.entry, langPack.entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int SortLangPackHashesProc2(LangPackEntry *arg1, LangPackEntry *arg2)
+{
+ if (arg1->englishHash < arg2->englishHash) return -1;
+ if (arg1->englishHash > arg2->englishHash) return 1;
+ return 0;
+}
+
+static char *LangPackTranslateString(LangPackMuuid* pUuid, const char *szEnglish, const int W)
+{
+ if (langPack.entryCount == 0 || szEnglish == NULL)
+ return (char*)szEnglish;
+
+ LangPackEntry key, *entry;
+ key.englishHash = W ? mir_hashstrW((WCHAR*)szEnglish) : mir_hashstr(szEnglish);
+ entry = (LangPackEntry*)bsearch(&key, langPack.entry, langPack.entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc2);
+ if (entry == NULL)
+ return (char*)szEnglish;
+
+ // try to find the exact match, otherwise the first entry will be returned
+ if (pUuid) {
+ for (LangPackEntry* p = entry->pNext; p != NULL; p = p->pNext) {
+ if (p->pMuuid == pUuid) {
+ entry = p;
+ break;
+ } } }
+
+ return W ? (char *)entry->wlocal : entry->local;
+}
+
+MIR_CORE_DLL(int) LangPackGetDefaultCodePage()
+{
+ return langPack.defaultANSICp;
+}
+
+MIR_CORE_DLL(int) LangPackGetDefaultLocale()
+{
+ return (langPack.localeID == 0) ? LOCALE_USER_DEFAULT : langPack.localeID;
+}
+
+MIR_CORE_DLL(TCHAR*) LangPackPcharToTchar(const char* pszStr)
+{
+ if (pszStr == NULL)
+ return NULL;
+
+ { int len = (int)strlen(pszStr);
+ TCHAR* result = (TCHAR*)alloca((len+1)*sizeof(TCHAR));
+ MultiByteToWideChar(LangPackGetDefaultCodePage(), 0, pszStr, -1, result, len);
+ result[len] = 0;
+ return mir_wstrdup(TranslateW(result));
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_CORE_DLL(char*) TranslateA_LP(const char* str, int hLangpack)
+{
+ return (char*)LangPackTranslateString(LangPackLookupUuid(hLangpack), str, FALSE);
+}
+
+MIR_CORE_DLL(WCHAR*) TranslateW_LP(const WCHAR* str, int hLangpack)
+{
+ return (WCHAR*)LangPackTranslateString(LangPackLookupUuid(hLangpack), (LPCSTR)str, TRUE);
+}
+
+MIR_CORE_DLL(void) TranslateMenu_LP(HMENU hMenu, int hLangpack)
+{
+ LangPackMuuid* uuid = LangPackLookupUuid(hLangpack);
+
+ MENUITEMINFO mii;
+ mii.cbSize = MENUITEMINFO_V4_SIZE;
+ for (int i = GetMenuItemCount(hMenu)-1; i >= 0; i--) {
+ TCHAR str[256];
+ mii.fMask = MIIM_TYPE|MIIM_SUBMENU;
+ mii.dwTypeData = (TCHAR*)str;
+ mii.cch = SIZEOF(str);
+ GetMenuItemInfo(hMenu, i, TRUE, &mii);
+
+ if (mii.cch && mii.dwTypeData) {
+ TCHAR* result = (TCHAR*)LangPackTranslateString(uuid, (const char*)mii.dwTypeData, TRUE);
+ if (result != mii.dwTypeData) {
+ mii.dwTypeData = result;
+ mii.fMask = MIIM_TYPE;
+ SetMenuItemInfo(hMenu, i, TRUE, &mii);
+ } }
+
+ if (mii.hSubMenu != NULL) TranslateMenu_LP(mii.hSubMenu, hLangpack);
+ }
+}
+
+static void TranslateWindow(LangPackMuuid* pUuid, HWND hwnd)
+{
+ TCHAR title[2048];
+ GetWindowText(hwnd, title, SIZEOF(title));
+
+ TCHAR* result = (TCHAR*)LangPackTranslateString(pUuid, (const char*)title, TRUE);
+ if (result != title)
+ SetWindowText(hwnd, result);
+}
+
+struct LANGPACKTRANSLATEDIALOG
+{
+ HWND hwndDlg;
+ int hLangpack;
+};
+
+static BOOL CALLBACK TranslateDialogEnumProc(HWND hwnd, LPARAM lParam)
+{
+ int hLangpack = (int)lParam;
+ TCHAR szClass[32];
+ int id = GetDlgCtrlID(hwnd);
+
+ LangPackMuuid* uuid = LangPackLookupUuid(hLangpack);
+
+ GetClassName(hwnd, szClass, SIZEOF(szClass));
+ if ( !lstrcmpi(szClass, _T("static")) || !lstrcmpi(szClass, _T("hyperlink")) || !lstrcmpi(szClass, _T("button")) || !lstrcmpi(szClass, _T("MButtonClass")) || !lstrcmpi(szClass, _T("MHeaderbarCtrl")))
+ TranslateWindow(uuid, hwnd);
+ else if ( !lstrcmpi(szClass, _T("edit"))) {
+ if (GetWindowLongPtr(hwnd, GWL_STYLE) & ES_READONLY)
+ TranslateWindow(uuid, hwnd);
+ }
+ return TRUE;
+}
+
+MIR_CORE_DLL(void) TranslateDialog_LP(HWND hDlg, int hLangpack)
+{
+ TranslateWindow(LangPackLookupUuid(hLangpack), hDlg);
+ EnumChildWindows(hDlg, TranslateDialogEnumProc, hLangpack);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_CORE_DLL(LangPackMuuid*) LangPackLookupUuid(WPARAM wParam)
+{
+ int idx = (wParam >> 16) & 0xFFFF;
+ return (idx > 0 && idx <= lMuuids.getCount()) ? lMuuids[ idx-1 ] : NULL;
+}
+
+MIR_CORE_DLL(int) LangPackMarkPluginLoaded(PLUGININFOEX* pInfo)
+{
+ LangPackMuuid tmp; tmp.muuid = pInfo->uuid;
+ int idx = lMuuids.getIndex(&tmp);
+ if (idx == -1)
+ return 0;
+
+ lMuuids[ idx ]->pInfo = pInfo;
+ return (idx+1) << 16;
+}
+
+MIR_CORE_DLL(void) LangPackDropUnusedItems(void)
+{
+ if (langPack.entryCount == 0)
+ return;
+
+ LangPackEntry *s = langPack.entry+1, *d = s, *pLast = langPack.entry;
+ DWORD dwSavedHash = langPack.entry->englishHash;
+ bool bSortNeeded = false;
+
+ for (int i=1; i < langPack.entryCount; i++, s++) {
+ if (s->pMuuid != NULL && s->pMuuid->pInfo == NULL)
+ s->pMuuid = NULL;
+
+ if (s->englishHash != dwSavedHash) {
+ pLast = d;
+ if (s != d)
+ *d++ = *s;
+ else
+ d++;
+ dwSavedHash = s->englishHash;
+ }
+ else {
+ bSortNeeded = true;
+ LangPackEntry* p = (LangPackEntry*)mir_alloc(sizeof(LangPackEntry));
+ *p = *s;
+ pLast->pNext = p; pLast = p;
+ }
+ }
+
+ if (bSortNeeded) {
+ langPack.entryCount = (int)(d - langPack.entry);
+ qsort(langPack.entry, langPack.entryCount, sizeof(LangPackEntry), (int(*)(const void*, const void*))SortLangPackHashesProc);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int LoadLangPackModule(void)
+{
+ bModuleInitialized = TRUE;
+
+ ZeroMemory(&langPack, sizeof(langPack));
+
+ TCHAR szSearch[MAX_PATH];
+ PathToAbsoluteT(_T("langpack_*.txt"), szSearch, NULL);
+
+ WIN32_FIND_DATA fd;
+ HANDLE hFind = FindFirstFile(szSearch, &fd);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ PathToAbsoluteT(fd.cFileName, szSearch, NULL);
+ FindClose(hFind);
+ LoadLangPack(szSearch);
+ }
+ return 0;
+}
+
+void UnloadLangPackModule()
+{
+ if ( !bModuleInitialized) return;
+
+ int i;
+ for (i=0; i < lMuuids.getCount(); i++)
+ mir_free(lMuuids[i]);
+ lMuuids.destroy();
+
+ LangPackEntry* p = langPack.entry;
+ for (i=0; i < langPack.entryCount; i++, p++) {
+ if (p->pNext != NULL) {
+ for (LangPackEntry* p1 = p->pNext; p1 != NULL;) {
+ LangPackEntry* p2 = p1; p1 = p1->pNext;
+ mir_free(p2->local);
+ mir_free(p2->wlocal);
+ mir_free(p2);
+ } }
+
+ mir_free(p->local);
+ mir_free(p->wlocal);
+ }
+
+ if (langPack.entryCount) {
+ mir_free(langPack.entry);
+ langPack.entry=0;
+ langPack.entryCount=0;
+} }
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_CORE_DLL(void) ReloadLangpack(TCHAR *pszStr)
+{
+ if (pszStr == NULL)
+ pszStr = langPack.filename;
+
+ UnloadLangPackModule();
+ LoadLangPack(pszStr);
+ LangPackDropUnusedItems();
+}
diff --git a/plugins/mir_core/lists.cpp b/plugins/mir_core/lists.cpp
new file mode 100644
index 0000000000..e4996fc156
--- /dev/null
+++ b/plugins/mir_core/lists.cpp
@@ -0,0 +1,278 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 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.
+*/
+
+#include "commonheaders.h"
+
+/* a simple sorted list implementation */
+
+MIR_CORE_DLL(SortedList*) List_Create(int p_limit, int p_increment)
+{
+ SortedList* result = (SortedList*)mir_calloc(sizeof(SortedList));
+ if (result == NULL)
+ return(NULL);
+
+ result->increment = p_increment;
+ result->limit = p_limit;
+ return(result);
+}
+
+MIR_CORE_DLL(void) List_Destroy(SortedList* p_list)
+{
+ if (p_list == NULL)
+ return;
+
+ if (p_list->items != NULL) {
+ mir_free(p_list->items);
+ p_list->items = NULL;
+ }
+
+ p_list->realCount = p_list->limit = 0;
+}
+
+MIR_CORE_DLL(void*) List_Find(SortedList* p_list, void* p_value)
+{
+ int index;
+
+ if ( !List_GetIndex(p_list, p_value, &index))
+ return(NULL);
+
+ return(p_list->items[ index ]);
+}
+
+#ifdef _DEBUG
+#pragma optimize("gt", on)
+#endif
+
+MIR_CORE_DLL(int) List_GetIndex(SortedList* p_list, void* p_value, int* p_index)
+{
+ if (p_value == NULL)
+ {
+ *p_index = -1;
+ return 0;
+ }
+
+ switch ((INT_PTR)p_list->sortFunc)
+ {
+ case 0:
+ break;
+
+ case HandleKeySort:
+#ifdef _WIN64
+ {
+ const unsigned __int64 val = *(unsigned __int64 *)p_value;
+ int low = 0;
+ int high = p_list->realCount - 1;
+
+ while (low <= high)
+ {
+ int i = (low + high) / 2;
+ unsigned __int64 vali = *(unsigned __int64 *)p_list->items[i];
+ if (vali == val)
+ {
+ *p_index = i;
+ return 1;
+ }
+
+ if (vali < val)
+ low = i + 1;
+ else
+ high = i - 1;
+ }
+
+ *p_index = low;
+ }
+ break;
+#endif
+
+ case NumericKeySort:
+ {
+ const unsigned val = *(unsigned *)p_value;
+ int low = 0;
+ int high = p_list->realCount - 1;
+
+ while (low <= high)
+ {
+ int i = (low + high) / 2;
+ unsigned vali = *(unsigned *)p_list->items[i];
+ if (vali == val)
+ {
+ *p_index = i;
+ return 1;
+ }
+
+ if (vali < val)
+ low = i + 1;
+ else
+ high = i - 1;
+ }
+
+ *p_index = low;
+ }
+ break;
+
+ case PtrKeySort:
+ {
+ int low = 0;
+ int high = p_list->realCount - 1;
+
+ while (low <= high)
+ {
+ int i = (low + high) / 2;
+ const void* vali = p_list->items[i];
+ if (vali == p_value)
+ {
+ *p_index = i;
+ return 1;
+ }
+
+ if (vali < p_value)
+ low = i + 1;
+ else
+ high = i - 1;
+ }
+
+ *p_index = low;
+ }
+ break;
+
+ default:
+ {
+ int low = 0;
+ int high = p_list->realCount - 1;
+
+ while (low <= high)
+ {
+ int i = (low + high) / 2;
+ int result = p_list->sortFunc(p_list->items[i], p_value);
+ if (result == 0)
+ {
+ *p_index = i;
+ return 1;
+ }
+
+ if (result < 0)
+ low = i + 1;
+ else
+ high = i - 1;
+ }
+
+ *p_index = low;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+MIR_CORE_DLL(int) List_IndexOf(SortedList* p_list, void* p_value)
+{
+ if (p_value == NULL)
+ return -1;
+
+ int i;
+ for (i=0; i < p_list->realCount; i++)
+ if (p_list->items[i] == p_value)
+ return i;
+
+ return -1;
+}
+
+#ifdef _DEBUG
+#pragma optimize("", on)
+#endif
+
+MIR_CORE_DLL(int) List_Insert(SortedList* p_list, void* p_value, int p_index)
+{
+ if (p_value == NULL || p_index > p_list->realCount)
+ return 0;
+
+ if (p_list->realCount == p_list->limit)
+ {
+ p_list->items = (void**)mir_realloc(p_list->items, sizeof(void*)*(p_list->realCount + p_list->increment));
+ p_list->limit += p_list->increment;
+ }
+
+ if (p_index < p_list->realCount)
+ memmove(p_list->items+p_index+1, p_list->items+p_index, sizeof(void*)*(p_list->realCount-p_index));
+
+ p_list->realCount++;
+
+ p_list->items[ p_index ] = p_value;
+ return 1;
+}
+
+MIR_CORE_DLL(int) List_InsertPtr(SortedList* list, void* p)
+{
+ if (p == NULL)
+ return -1;
+
+ int idx = list->realCount;
+ List_GetIndex(list, p, &idx);
+ return List_Insert(list, p, idx);
+}
+
+MIR_CORE_DLL(int) List_Remove(SortedList* p_list, int index)
+{
+ if (index < 0 || index > p_list->realCount)
+ return(0);
+
+ p_list->realCount--;
+ if (p_list->realCount > index)
+ {
+ memmove(p_list->items+index, p_list->items+index+1, sizeof(void*)*(p_list->realCount-index));
+ p_list->items[ p_list->realCount ] = NULL;
+ }
+
+ return 1;
+}
+
+MIR_CORE_DLL(int) List_RemovePtr(SortedList* list, void* p)
+{
+ int idx = -1;
+ if (List_GetIndex(list, p, &idx))
+ List_Remove(list, idx);
+
+ return idx;
+}
+
+MIR_CORE_DLL(void) List_Copy(SortedList* s, SortedList* d, size_t itemSize)
+{
+ d->increment = s->increment;
+ d->limit = s->limit;
+ d->realCount = s->realCount;
+ d->items = (void**)mir_alloc( sizeof(void*) * d->realCount);
+ memcpy(d->items, s->items, sizeof(void*) * d->realCount);
+}
+
+MIR_CORE_DLL(void) List_ObjCopy(SortedList* s, SortedList* d, size_t itemSize)
+{
+ int i;
+
+ d->increment = s->increment;
+ d->sortFunc = s->sortFunc;
+
+ for (i = 0; i < s->realCount; i++) {
+ void* item = new char[ itemSize ];
+ memcpy(item, s->items[i], itemSize);
+ List_Insert(d, item, i);
+} }
diff --git a/plugins/mir_core/memory.cpp b/plugins/mir_core/memory.cpp
new file mode 100644
index 0000000000..25b4d880c2
--- /dev/null
+++ b/plugins/mir_core/memory.cpp
@@ -0,0 +1,280 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 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.
+*/
+
+#include "commonheaders.h"
+
+#define BLOCK_ALLOCED 0xABBABABA
+#define BLOCK_FREED 0xDEADBEEF
+
+static int CheckBlock(void* blk)
+{
+ int result = FALSE;
+ char* p = (char*)blk - sizeof(DWORD)*2;
+ DWORD size, *b, *e;
+
+ __try
+ {
+ size = *(DWORD*)p;
+ b = (DWORD*)&p[ sizeof(DWORD) ];
+ e = (DWORD*)&p[ sizeof(DWORD)*2 + size ];
+
+ if (*b != BLOCK_ALLOCED || *e != BLOCK_ALLOCED)
+ {
+ if (*b == BLOCK_FREED && *e == BLOCK_FREED)
+ OutputDebugStringA("memory block is already deleted\n");
+ else
+ OutputDebugStringA("memory block is corrupted\n");
+ #if defined(_DEBUG)
+ DebugBreak();
+ #endif
+ }
+ else result = TRUE;
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+ OutputDebugStringA("access violation during checking memory block\n");
+ #if defined(_DEBUG)
+ DebugBreak();
+ #endif
+ }
+
+ return result;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(void*) mir_alloc(size_t size)
+{
+ if (size == 0)
+ return NULL;
+ {
+ char* p = (char*)malloc(size + sizeof(DWORD)*3);
+ if (p == NULL) {
+ OutputDebugStringA("memory overflow\n");
+ #if defined(_DEBUG)
+ DebugBreak();
+ #endif
+ return NULL;
+ }
+
+ *(DWORD*)p = (DWORD)size;
+ *(DWORD*)&p[ sizeof(DWORD) ] = BLOCK_ALLOCED;
+ *(DWORD*)&p[ size + sizeof(DWORD)*2 ] = BLOCK_ALLOCED;
+ return p + sizeof(DWORD)*2;
+} }
+
+/******************************************************************************/
+
+MIR_CORE_DLL(void*) mir_calloc(size_t size)
+{
+ void* p = mir_alloc(size);
+ if (p != NULL)
+ memset(p, 0, size);
+ return p;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(void*) mir_realloc(void* ptr, size_t size)
+{
+ char* p;
+
+ if (ptr != NULL) {
+ if ( !CheckBlock(ptr))
+ return NULL;
+ p = (char*)ptr - sizeof(DWORD)*2;
+ }
+ else p = NULL;
+
+ p = (char*)realloc(p, size + sizeof(DWORD)*3);
+ if (p == NULL) {
+ OutputDebugStringA("memory overflow\n");
+ #if defined(_DEBUG)
+ DebugBreak();
+ #endif
+ return NULL;
+ }
+
+ *(DWORD*)p = (DWORD)size;
+ *(DWORD*)&p[ sizeof(DWORD) ] = BLOCK_ALLOCED;
+ *(DWORD*)&p[ size + sizeof(DWORD)*2 ] = BLOCK_ALLOCED;
+ return p + sizeof(DWORD)*2;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(void) mir_free(void* ptr)
+{
+ char* p;
+ DWORD size;
+
+ if (ptr == NULL)
+ return;
+ if ( !CheckBlock(ptr))
+ return;
+
+ p = (char*)ptr - sizeof(DWORD)*2;
+ size = *(DWORD*)p;
+ *(DWORD*)&p[ sizeof(DWORD) ] = BLOCK_FREED;
+ *(DWORD*)&p[ size + sizeof(DWORD)*2 ] = BLOCK_FREED;
+ free(p);
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(char*) mir_strdup(const char* str)
+{
+ if (str != NULL) {
+ char* p = (char*)mir_alloc(strlen(str)+1);
+ if (p)
+ strcpy(p, str);
+ return p;
+ }
+ return NULL;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(char*) mir_strndup(const char* str, size_t len)
+{
+ if (str != NULL && len != 0) {
+ char* p = (char*)mir_alloc(len + 1);
+ if ( !p) {
+ memcpy(p, str, len);
+ p[ len ] = 0;
+ }
+ return p;
+ }
+ return NULL;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(WCHAR*) mir_wstrdup(const WCHAR* str)
+{
+ if (str != NULL) {
+ WCHAR* p = (WCHAR*)mir_alloc(sizeof(WCHAR)*(wcslen(str)+1));
+ if (p)
+ wcscpy(p, str);
+ return p;
+ }
+ return NULL;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(int) mir_snprintf(char *buffer, size_t count, const char* fmt, ...)
+{
+ va_list va;
+ int len;
+
+ va_start(va, fmt);
+ len = _vsnprintf(buffer, count-1, fmt, va);
+ va_end(va);
+ buffer[count-1] = 0;
+ return len;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(int) mir_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...)
+{
+ va_list va;
+ int len;
+
+ va_start(va, fmt);
+ len = _vsntprintf(buffer, count-1, fmt, va);
+ va_end(va);
+ buffer[count-1] = 0;
+ return len;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(int) mir_vsnprintf(char *buffer, size_t count, const char* fmt, va_list va)
+{
+ int len;
+
+ len = _vsnprintf(buffer, count-1, fmt, va);
+ buffer[count-1] = 0;
+ return len;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(int) mir_vsntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, va_list va)
+{
+ int len;
+
+ len = _vsntprintf(buffer, count-1, fmt, va);
+ buffer[count-1] = 0;
+ return len;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(wchar_t*) mir_a2u_cp(const char* src, int codepage)
+{
+ if (src == NULL)
+ return NULL;
+
+ int cbLen = MultiByteToWideChar(codepage, 0, src, -1, NULL, 0);
+ wchar_t* result = (wchar_t*)mir_alloc(sizeof(wchar_t)*(cbLen+1));
+ if (result == NULL)
+ return NULL;
+
+ MultiByteToWideChar(codepage, 0, src, -1, result, cbLen);
+ result[ cbLen ] = 0;
+ return result;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(wchar_t*) mir_a2u(const char* src)
+{
+ return mir_a2u_cp(src, LangPackGetDefaultCodePage());
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(char*) mir_u2a_cp(const wchar_t* src, int codepage)
+{
+ if (src == NULL)
+ return NULL;
+
+ int cbLen = WideCharToMultiByte(codepage, 0, src, -1, NULL, 0, NULL, NULL);
+ char* result = (char*)mir_alloc(cbLen+1);
+ if (result == NULL)
+ return NULL;
+
+ WideCharToMultiByte(codepage, 0, src, -1, result, cbLen, NULL, NULL);
+ result[ cbLen ] = 0;
+ return result;
+}
+
+/******************************************************************************/
+
+MIR_CORE_DLL(char*) mir_u2a(const wchar_t* src)
+{
+ return mir_u2a_cp(src, LangPackGetDefaultCodePage());
+}
diff --git a/plugins/mir_core/mir_core.def b/plugins/mir_core/mir_core.def
new file mode 100644
index 0000000000..78e8323ff8
--- /dev/null
+++ b/plugins/mir_core/mir_core.def
@@ -0,0 +1,5 @@
+LIBRARY mir_core
+
+EXPORTS
+ CallContactService @1
+ CallProtoService @2
diff --git a/plugins/mir_core/mir_core_10.vcxproj b/plugins/mir_core/mir_core_10.vcxproj
new file mode 100644
index 0000000000..ba1b174e58
--- /dev/null
+++ b/plugins/mir_core/mir_core_10.vcxproj
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\include\m_core.h" />
+ <ClInclude Include="..\..\include\m_system.h" />
+ <ClInclude Include="commonheaders.h" />
+ <ClInclude Include="forkthread.h" />
+ <ClInclude Include="miranda.h" />
+ <ClInclude Include="modules.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="commonheaders.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="langpack.cpp" />
+ <ClCompile Include="lists.cpp" />
+ <ClCompile Include="memory.cpp" />
+ <ClCompile Include="miranda.cpp" />
+ <ClCompile Include="modules.cpp" />
+ <ClCompile Include="path.cpp" />
+ <ClCompile Include="timezones.cpp" />
+ <ClCompile Include="utf.cpp" />
+ <ClCompile Include="utils.cpp" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>mir_core</ProjectName>
+ <ProjectGuid>{D9EFEA4B-B817-4DE1-BD62-68A5DB8F5F60}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30128.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;MIR_CORE_EXPORTS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <ModuleDefinitionFile>mir_core.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;winmm.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;MIR_CORE_EXPORTS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <ModuleDefinitionFile>
+ </ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;winmm.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>false</ExceptionHandling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;MIR_CORE_EXPORTS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <ModuleDefinitionFile>mir_core.def</ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalDependencies>miranda32.lib;ws2_32.lib;comctl32.lib;winmm.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>false</ExceptionHandling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;MIR_CORE_EXPORTS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <ModuleDefinitionFile>
+ </ModuleDefinitionFile>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalDependencies>miranda64.lib;ws2_32.lib;comctl32.lib;winmm.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/plugins/mir_core/mir_core_10.vcxproj.filters b/plugins/mir_core/mir_core_10.vcxproj.filters
new file mode 100644
index 0000000000..30facd3a4c
--- /dev/null
+++ b/plugins/mir_core/mir_core_10.vcxproj.filters
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{bf74d1c9-acd8-4fba-837d-734f024521c9}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{a578a180-0eb9-4c3e-b4ae-0eaefa01d207}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="commonheaders.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="memory.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="miranda.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="modules.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="lists.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="langpack.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="utf.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="utils.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="path.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="timezones.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="commonheaders.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="modules.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="forkthread.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\m_core.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="miranda.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\m_system.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/plugins/mir_core/miranda.cpp b/plugins/mir_core/miranda.cpp
new file mode 100644
index 0000000000..1e714089d1
--- /dev/null
+++ b/plugins/mir_core/miranda.cpp
@@ -0,0 +1,398 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2012 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.
+
+*/
+
+#include "commonheaders.h"
+
+HWND hAPCWindow = NULL;
+
+int InitPathUtils(void);
+void RecalculateTime(void);
+
+HANDLE hStackMutex, hThreadQueueEmpty;
+int hLangpack = 0;
+HINSTANCE hInst = 0;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// exception handling
+
+static DWORD __cdecl sttDefaultFilter(DWORD, EXCEPTION_POINTERS*)
+{
+ return EXCEPTION_EXECUTE_HANDLER;
+}
+
+pfnExceptionFilter pMirandaExceptFilter = sttDefaultFilter;
+
+MIR_CORE_DLL(pfnExceptionFilter) GetExceptionFilter()
+{
+ return pMirandaExceptFilter;
+}
+
+MIR_CORE_DLL(pfnExceptionFilter) SetExceptionFilter(pfnExceptionFilter pMirandaExceptFilter)
+{
+ pfnExceptionFilter oldOne = pMirandaExceptFilter;
+ if (pMirandaExceptFilter != 0)
+ pMirandaExceptFilter = pMirandaExceptFilter;
+ return oldOne;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// thread support functions
+
+struct THREAD_WAIT_ENTRY
+{
+ DWORD dwThreadId; // valid if hThread isn't signalled
+ HANDLE hThread;
+ HINSTANCE hOwner;
+ void* pObject;
+ PVOID addr;
+};
+
+static LIST<THREAD_WAIT_ENTRY> threads(10, NumericKeySortT);
+
+struct FORK_ARG {
+ HANDLE hEvent;
+ pThreadFunc threadcode;
+ pThreadFuncEx threadcodeex;
+ void *arg, *owner;
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// forkthread - starts a new thread
+
+void __cdecl forkthread_r(void * arg)
+{
+ struct FORK_ARG * fa = (struct FORK_ARG *) arg;
+ void (*callercode)(void*)=fa->threadcode;
+ void * cookie=fa->arg;
+ CallService(MS_SYSTEM_THREAD_PUSH, 0, (LPARAM)callercode);
+ SetEvent(fa->hEvent);
+ __try
+ {
+ callercode(cookie);
+ }
+ __except(pMirandaExceptFilter(GetExceptionCode(), GetExceptionInformation()))
+ {
+ }
+
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+ CallService(MS_SYSTEM_THREAD_POP, 0, 0);
+ return;
+}
+
+MIR_CORE_DLL(UINT_PTR) forkthread( void (__cdecl *threadcode)(void*), unsigned long stacksize, void *arg)
+{
+ UINT_PTR rc;
+ struct FORK_ARG fa;
+ fa.hEvent=CreateEvent(NULL, FALSE, FALSE, NULL);
+ fa.threadcode=threadcode;
+ fa.arg=arg;
+ rc=_beginthread(forkthread_r, stacksize, &fa);
+ if ((UINT_PTR)-1L != rc)
+ WaitForSingleObject(fa.hEvent, INFINITE);
+
+ CloseHandle(fa.hEvent);
+ return rc;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// forkthreadex - starts a new thread with the extended info and returns the thread id
+
+unsigned __stdcall forkthreadex_r(void * arg)
+{
+ struct FORK_ARG *fa = (struct FORK_ARG *)arg;
+ pThreadFuncEx threadcode = fa->threadcodeex;
+ pThreadFuncOwner threadcodeex = (pThreadFuncOwner)fa->threadcodeex;
+ void *cookie = fa->arg;
+ void *owner = fa->owner;
+ unsigned long rc = 0;
+
+ CallService(MS_SYSTEM_THREAD_PUSH, (WPARAM)fa->owner, (LPARAM)threadcode);
+ SetEvent(fa->hEvent);
+ __try
+ {
+ if (owner)
+ rc = threadcodeex(owner, cookie);
+ else
+ rc = threadcode(cookie);
+ }
+ __except(pMirandaExceptFilter(GetExceptionCode(), GetExceptionInformation()))
+ {
+ }
+
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+ CallService(MS_SYSTEM_THREAD_POP, 0, 0);
+ return rc;
+}
+
+MIR_CORE_DLL(UINT_PTR) forkthreadex(
+ void *sec,
+ unsigned stacksize,
+ unsigned (__stdcall *threadcode)(void*),
+ void* owner,
+ void *arg,
+ unsigned *thraddr)
+{
+ UINT_PTR rc;
+ struct FORK_ARG fa = { 0 };
+ fa.threadcodeex = threadcode;
+ fa.arg = arg;
+ fa.owner = owner;
+ fa.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ rc = _beginthreadex(sec, stacksize, forkthreadex_r, (void *)&fa, 0, thraddr);
+ if (rc)
+ WaitForSingleObject(fa.hEvent, INFINITE);
+
+ CloseHandle(fa.hEvent);
+ return rc;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// APC and mutex functions
+
+static void __stdcall DummyAPCFunc(ULONG_PTR)
+{
+ /* called in the context of thread that cleared it's APC queue */
+ return;
+}
+
+static int MirandaWaitForMutex(HANDLE hEvent)
+{
+ for (;;) {
+ // will get WAIT_IO_COMPLETE for QueueUserAPC() which isnt a result
+ DWORD rc = MsgWaitForMultipleObjectsEx(1, &hEvent, INFINITE, QS_ALLINPUT, MWMO_ALERTABLE);
+ if (rc == WAIT_OBJECT_0 + 1) {
+ MSG msg;
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ if (IsDialogMessage(msg.hwnd, &msg)) continue;
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ else if (rc == WAIT_OBJECT_0) { // got object
+ return 1;
+ }
+ else if (rc == WAIT_ABANDONED_0 || rc == WAIT_FAILED)
+ return 0;
+ }
+}
+
+static void CALLBACK KillAllThreads(HWND, UINT, UINT_PTR, DWORD)
+{
+ if ( MirandaWaitForMutex(hStackMutex)) {
+ for (int j=0; j < threads.getCount(); j++) {
+ THREAD_WAIT_ENTRY* p = threads[j];
+ char szModuleName[ MAX_PATH ];
+ GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
+ TerminateThread(p->hThread, 9999);
+ CloseHandle(p->hThread);
+ mir_free(p);
+ }
+
+ threads.destroy();
+
+ ReleaseMutex(hStackMutex);
+ SetEvent(hThreadQueueEmpty);
+ }
+}
+
+MIR_CORE_DLL(void) KillObjectThreads(void* owner)
+{
+ if (owner == NULL)
+ return;
+
+ WaitForSingleObject(hStackMutex, INFINITE);
+
+ HANDLE* threadPool = (HANDLE*)alloca(threads.getCount()*sizeof(HANDLE));
+ int threadCount = 0;
+
+ for (int j = threads.getCount(); j--;) {
+ THREAD_WAIT_ENTRY* p = threads[j];
+ if (p->pObject == owner)
+ threadPool[ threadCount++ ] = p->hThread;
+ }
+ ReleaseMutex(hStackMutex);
+
+ // is there anything to kill?
+ if (threadCount > 0) {
+ if ( WaitForMultipleObjects(threadCount, threadPool, TRUE, 5000) == WAIT_TIMEOUT) {
+ // forcibly kill all remaining threads after 5 secs
+ WaitForSingleObject(hStackMutex, INFINITE);
+ for (int j = threads.getCount()-1; j >= 0; j--) {
+ THREAD_WAIT_ENTRY* p = threads[j];
+ if (p->pObject == owner) {
+ TerminateThread(p->hThread, 9999);
+ CloseHandle(p->hThread);
+ threads.remove(j);
+ mir_free(p);
+ }
+ }
+ ReleaseMutex(hStackMutex);
+ }
+ }
+}
+
+MIR_CORE_DLL(void) UnwindThreadWait(void)
+{
+ // acquire the list and wake up any alertable threads
+ if ( MirandaWaitForMutex(hStackMutex)) {
+ int j;
+ for (j=0; j < threads.getCount(); j++)
+ QueueUserAPC(DummyAPCFunc, threads[j]->hThread, 0);
+ ReleaseMutex(hStackMutex);
+ }
+
+ // give all unclosed threads 5 seconds to close
+ SetTimer(NULL, 0, 5000, KillAllThreads);
+
+ // wait til the thread list is empty
+ MirandaWaitForMutex(hThreadQueueEmpty);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+typedef LONG (WINAPI *pNtQIT)(HANDLE, LONG, PVOID, ULONG, PULONG);
+#define ThreadQuerySetWin32StartAddress 9
+
+MIR_CORE_DLL(void*) GetCurrentThreadEntryPoint()
+{
+ LONG ntStatus;
+ HANDLE hDupHandle, hCurrentProcess;
+ DWORD_PTR dwStartAddress;
+
+ pNtQIT NtQueryInformationThread = (pNtQIT)GetProcAddress(GetModuleHandle(_T("ntdll.dll")), "NtQueryInformationThread");
+ if (NtQueryInformationThread == NULL)
+ return 0;
+
+ hCurrentProcess = GetCurrentProcess();
+ if ( !DuplicateHandle(hCurrentProcess, GetCurrentThread(), hCurrentProcess, &hDupHandle, THREAD_QUERY_INFORMATION, FALSE, 0)) {
+ SetLastError(ERROR_ACCESS_DENIED);
+ return NULL;
+ }
+ ntStatus = NtQueryInformationThread(hDupHandle, ThreadQuerySetWin32StartAddress, &dwStartAddress, sizeof(DWORD_PTR), NULL);
+ CloseHandle(hDupHandle);
+
+ if (ntStatus != ERROR_SUCCESS) return 0;
+ return (void*)dwStartAddress;
+}
+
+MIR_CORE_DLL(INT_PTR) UnwindThreadPush(WPARAM wParam, LPARAM lParam)
+{
+ ResetEvent(hThreadQueueEmpty); // thread list is not empty
+ if ( WaitForSingleObject(hStackMutex, INFINITE) == WAIT_OBJECT_0) {
+ THREAD_WAIT_ENTRY* p = (THREAD_WAIT_ENTRY*)mir_calloc(sizeof(THREAD_WAIT_ENTRY));
+
+ DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &p->hThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
+ p->dwThreadId = GetCurrentThreadId();
+ p->pObject = (void*)wParam;
+ p->hOwner = GetInstByAddress((void*)lParam);
+ p->addr = (void*)lParam;
+ threads.insert(p);
+
+ ReleaseMutex(hStackMutex);
+ }
+ return 0;
+}
+
+MIR_CORE_DLL(INT_PTR) UnwindThreadPop(WPARAM, LPARAM)
+{
+ if ( WaitForSingleObject(hStackMutex, INFINITE) == WAIT_OBJECT_0) {
+ DWORD dwThreadId = GetCurrentThreadId();
+ for (int j=0; j < threads.getCount(); j++) {
+ THREAD_WAIT_ENTRY* p = threads[j];
+ if (p->dwThreadId == dwThreadId) {
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+ CloseHandle(p->hThread);
+ threads.remove(j);
+ mir_free(p);
+
+ if ( !threads.getCount()) {
+ threads.destroy();
+ ReleaseMutex(hStackMutex);
+ SetEvent(hThreadQueueEmpty); // thread list is empty now
+ return 0;
+ }
+
+ ReleaseMutex(hStackMutex);
+ return 0;
+ }
+ }
+ ReleaseMutex(hStackMutex);
+ }
+ return 1;
+}
+
+static LRESULT CALLBACK APCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ if (msg == WM_NULL) SleepEx(0, TRUE);
+ if (msg == WM_TIMECHANGE) RecalculateTime();
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// module init
+
+static void LoadSystemModule(void)
+{
+ INITCOMMONCONTROLSEX icce = {0};
+ icce.dwSize = sizeof(icce);
+ icce.dwICC = ICC_WIN95_CLASSES | ICC_USEREX_CLASSES;
+ InitCommonControlsEx(&icce);
+
+ if ( IsWinVerXPPlus()) {
+ hAPCWindow=CreateWindowEx(0, _T("ComboLBox"), NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
+ SetClassLongPtr(hAPCWindow, GCL_STYLE, GetClassLongPtr(hAPCWindow, GCL_STYLE) | CS_DROPSHADOW);
+ DestroyWindow(hAPCWindow);
+ hAPCWindow = NULL;
+ }
+
+ hAPCWindow = CreateWindowEx(0, _T("STATIC"), NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
+ SetWindowLongPtr(hAPCWindow, GWLP_WNDPROC, (LONG_PTR)APCWndProc);
+ hStackMutex = CreateMutex(NULL, FALSE, NULL);
+
+ InitPathUtils();
+ LoadLangPackModule();
+ InitialiseModularEngine();
+ InitTimeZones();
+}
+
+static void UnloadSystemModule(void)
+{
+ DestroyModularEngine();
+ UnloadLangPackModule();
+ UninitTimeZones();
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// entry point
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ if (fdwReason == DLL_PROCESS_ATTACH) {
+ hInst = hinstDLL;
+ LoadSystemModule();
+ }
+ else if(fdwReason == DLL_PROCESS_DETACH)
+ UnloadSystemModule();
+ return TRUE;
+}
diff --git a/plugins/mir_core/miranda.h b/plugins/mir_core/miranda.h
new file mode 100644
index 0000000000..3b639ac4aa
--- /dev/null
+++ b/plugins/mir_core/miranda.h
@@ -0,0 +1,131 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 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.
+*/
+
+#define NEWSTR_ALLOCA(A) (A == NULL)?NULL:strcpy((char*)alloca(strlen(A)+1), A)
+#define NEWTSTR_ALLOCA(A) (A == NULL)?NULL:_tcscpy((TCHAR*)alloca((_tcslen(A)+1)* sizeof(TCHAR)), A)
+
+struct LangPackMuuid
+{
+ MUUID muuid;
+ PLUGININFOEX* pInfo;
+};
+
+MIR_CORE_DLL(int) LangPackMarkPluginLoaded(PLUGININFOEX* pInfo);
+
+MIR_CORE_DLL(LangPackMuuid*) LangPackLookupUuid(WPARAM wParam);
+
+int LoadLangPackModule(void);
+void UnloadLangPackModule(void);
+
+int InitialiseModularEngine(void);
+void DestroyModularEngine(void);
+
+void InitTimeZones(void);
+void UninitTimeZones(void);
+
+int InitPathUtils(void);
+
+extern HINSTANCE hInst;
+
+/**** modules.cpp **********************************************************************/
+
+struct THookSubscriber
+{
+ HINSTANCE hOwner;
+ int type;
+ union {
+ struct {
+ union {
+ MIRANDAHOOK pfnHook;
+ MIRANDAHOOKPARAM pfnHookParam;
+ MIRANDAHOOKOBJ pfnHookObj;
+ MIRANDAHOOKOBJPARAM pfnHookObjParam;
+ };
+ void* object;
+ LPARAM lParam;
+ };
+ struct {
+ HWND hwnd;
+ UINT message;
+ };
+ };
+};
+
+struct THook
+{
+ char name[ MAXMODULELABELLENGTH ];
+ int id;
+ int subscriberCount;
+ THookSubscriber* subscriber;
+ MIRANDAHOOK pfnHook;
+ CRITICAL_SECTION csHook;
+};
+
+/**** langpack.cpp *********************************************************************/
+
+char* LangPackTranslateString(struct LangPackMuuid* pUuid, const char *szEnglish, const int W);
+TCHAR* LangPackTranslateStringT(int hLangpack, const TCHAR* tszEnglish);
+
+/**** options.cpp **********************************************************************/
+
+HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name);
+
+/**** utils.cpp ************************************************************************/
+
+void HotkeyToName(TCHAR *buf, int size, BYTE shift, BYTE key);
+WORD GetHotkeyValue(INT_PTR idHotkey);
+
+HBITMAP ConvertIconToBitmap(HICON hIcon, HIMAGELIST hIml, int iconId);
+
+class StrConvUT
+{
+private:
+ wchar_t* m_body;
+
+public:
+ StrConvUT(const char* pSrc) :
+ m_body(mir_a2u(pSrc)) {}
+
+ ~StrConvUT() { mir_free(m_body); }
+ operator const wchar_t* () const { return m_body; }
+};
+
+class StrConvAT
+{
+private:
+ char* m_body;
+
+public:
+ StrConvAT(const wchar_t* pSrc) :
+ m_body(mir_u2a(pSrc)) {}
+
+ ~StrConvAT() { mir_free(m_body); }
+ operator const char* () const { return m_body; }
+ operator const wchar_t* () const { return (wchar_t*)m_body; } // type cast to fake the interface definition
+ operator const LPARAM () const { return (LPARAM)m_body; }
+};
+
+#define StrConvT(x) StrConvUT(x)
+#define StrConvTu(x) x
+#define StrConvA(x) StrConvAT(x)
+#define StrConvU(x) x
diff --git a/plugins/mir_core/modules.cpp b/plugins/mir_core/modules.cpp
new file mode 100644
index 0000000000..6a9aa54bcb
--- /dev/null
+++ b/plugins/mir_core/modules.cpp
@@ -0,0 +1,644 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 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.
+*/
+
+#include "commonheaders.h"
+#include <m_plugins.h>
+
+// list of hooks
+
+static int compareHooks(const THook* p1, const THook* p2)
+{
+ return strcmp(p1->name, p2->name);
+}
+
+static LIST<THook> hooks(50, compareHooks);
+
+struct THookToMainThreadItem
+{
+ THook* hook;
+ HANDLE hDoneEvent;
+ WPARAM wParam;
+ LPARAM lParam;
+ int result;
+};
+
+// list of services
+
+struct TService
+{
+ DWORD nameHash;
+ HINSTANCE hOwner;
+ union {
+ MIRANDASERVICE pfnService;
+ MIRANDASERVICEPARAM pfnServiceParam;
+ MIRANDASERVICEOBJ pfnServiceObj;
+ MIRANDASERVICEOBJPARAM pfnServiceObjParam;
+ };
+ int flags;
+ LPARAM lParam;
+ void* object;
+ char name[1];
+};
+
+LIST<TService> services(100, NumericKeySortT);
+
+typedef struct
+{
+ HANDLE hDoneEvent;
+ WPARAM wParam;
+ LPARAM lParam;
+ int result;
+ const char *name;
+}
+ TServiceToMainThreadItem;
+
+// other static variables
+static BOOL bServiceMode = FALSE;
+static CRITICAL_SECTION csHooks, csServices;
+static DWORD mainThreadId;
+static int hookId = 1;
+static HANDLE hMainThread;
+static HANDLE hMissingService;
+static THook *pLastHook = NULL;
+
+///////////////////////////////////////////////////////////////////////////////
+// HOOKS
+
+MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name)
+{
+ THook* ret;
+ int idx;
+
+ if (name == NULL)
+ return NULL;
+
+ EnterCriticalSection(&csHooks);
+ if ((idx = hooks.getIndex((THook*)name)) != -1) {
+ LeaveCriticalSection(&csHooks);
+ return NULL;
+ }
+
+ ret = (THook*)mir_alloc(sizeof(THook));
+ strncpy(ret->name, name, sizeof(ret->name)); ret->name[ MAXMODULELABELLENGTH-1 ] = 0;
+ ret->id = hookId++;
+ ret->subscriberCount = 0;
+ ret->subscriber = NULL;
+ ret->pfnHook = NULL;
+ InitializeCriticalSection(&ret->csHook);
+ hooks.insert(ret);
+
+ LeaveCriticalSection(&csHooks);
+ return (HANDLE)ret;
+}
+
+MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent)
+{
+ EnterCriticalSection(&csHooks);
+ if (pLastHook == (THook*)hEvent)
+ pLastHook = NULL;
+
+ int idx;
+ if ((idx = hooks.getIndex((THook*)hEvent)) == -1) {
+ LeaveCriticalSection(&csHooks);
+ return 1;
+ }
+
+ THook* p = hooks[idx];
+ if (p->subscriberCount) {
+ mir_free(p->subscriber);
+ p->subscriber = NULL;
+ p->subscriberCount = 0;
+ }
+ hooks.remove(idx);
+ DeleteCriticalSection(&p->csHook);
+ mir_free(p);
+
+ LeaveCriticalSection(&csHooks);
+ return 0;
+}
+
+MIR_CORE_DLL(int) SetHookDefaultForHookableEvent(HANDLE hEvent, MIRANDAHOOK pfnHook)
+{
+ THook* p = (THook*)hEvent;
+
+ EnterCriticalSection(&csHooks);
+ if (hooks.getIndex(p) != -1)
+ p->pfnHook = pfnHook;
+ LeaveCriticalSection(&csHooks);
+ return 0;
+}
+
+MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wParam, LPARAM lParam)
+{
+ int returnVal = 0;
+ THook* p = (THook*)hEvent;
+ if (p == NULL)
+ return -1;
+
+ EnterCriticalSection(&p->csHook);
+ for (int i = 0; i < p->subscriberCount; i++) {
+ THookSubscriber* s = &p->subscriber[i];
+ if (s->hOwner != hInst)
+ continue;
+
+ switch (s->type) {
+ case 1: returnVal = s->pfnHook(wParam, lParam); break;
+ case 2: returnVal = s->pfnHookParam(wParam, lParam, s->lParam); break;
+ case 3: returnVal = s->pfnHookObj(s->object, wParam, lParam); break;
+ case 4: returnVal = s->pfnHookObjParam(s->object, wParam, lParam, s->lParam); break;
+ case 5: returnVal = SendMessage(s->hwnd, s->message, wParam, lParam); break;
+ default: continue;
+ }
+ if (returnVal)
+ break;
+ }
+
+ if (p->subscriberCount == 0 && p->pfnHook != 0)
+ returnVal = p->pfnHook(wParam, lParam);
+
+ LeaveCriticalSection(&p->csHook);
+ return returnVal;
+}
+
+MIR_CORE_DLL(int) CallHookSubscribers(HANDLE hEvent, WPARAM wParam, LPARAM lParam)
+{
+ int returnVal = 0;
+ THook* p = (THook*)hEvent;
+ if (p == NULL)
+ return -1;
+
+ EnterCriticalSection(&p->csHook);
+
+ // NOTE: We've got the critical section while all this lot are called. That's mostly safe, though.
+ for (int i = 0; i < p->subscriberCount; i++) {
+ THookSubscriber* s = &p->subscriber[i];
+ switch (s->type) {
+ case 1: returnVal = s->pfnHook(wParam, lParam); break;
+ case 2: returnVal = s->pfnHookParam(wParam, lParam, s->lParam); break;
+ case 3: returnVal = s->pfnHookObj(s->object, wParam, lParam); break;
+ case 4: returnVal = s->pfnHookObjParam(s->object, wParam, lParam, s->lParam); break;
+ case 5: returnVal = SendMessage(s->hwnd, s->message, wParam, lParam); break;
+ default: continue;
+ }
+ if (returnVal)
+ break;
+ }
+
+ // check for no hooks and call the default hook if any
+ if (p->subscriberCount == 0 && p->pfnHook != 0)
+ returnVal = p->pfnHook(wParam, lParam);
+
+ LeaveCriticalSection(&p->csHook);
+ return returnVal;
+}
+
+static int checkHook(HANDLE hHook)
+{
+ if (hHook == NULL)
+ return -1;
+
+ EnterCriticalSection(&csHooks);
+ if (pLastHook != hHook || !pLastHook) {
+ if (hooks.getIndex((THook*)hHook) == -1) {
+ LeaveCriticalSection(&csHooks);
+ return -1;
+ }
+ pLastHook = (THook*)hHook;
+ }
+ LeaveCriticalSection(&csHooks);
+ return 0;
+}
+
+static void CALLBACK HookToMainAPCFunc(ULONG_PTR dwParam)
+{
+ THookToMainThreadItem* item = (THookToMainThreadItem*)dwParam;
+
+ if (checkHook(item->hook) == -1)
+ item->result = -1;
+ else
+ item->result = CallHookSubscribers(item->hook, item->wParam, item->lParam);
+ SetEvent(item->hDoneEvent);
+}
+
+MIR_CORE_DLL(int) NotifyEventHooks(HANDLE hEvent, WPARAM wParam, LPARAM lParam)
+{
+ extern HWND hAPCWindow;
+
+ if ( GetCurrentThreadId() != mainThreadId) {
+ THookToMainThreadItem item;
+
+ item.hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ item.hook = (THook*)hEvent;
+ item.wParam = wParam;
+ item.lParam = lParam;
+
+ QueueUserAPC(HookToMainAPCFunc, hMainThread, (ULONG_PTR)&item);
+ PostMessage(hAPCWindow, WM_NULL, 0, 0); // let it process APC even if we're in a common dialog
+ WaitForSingleObject(item.hDoneEvent, INFINITE);
+ CloseHandle(item.hDoneEvent);
+ return item.result;
+ }
+
+ return (checkHook(hEvent) == -1) ? -1 : CallHookSubscribers(hEvent, wParam, lParam);
+}
+
+static HANDLE HookEventInt(int type, const char* name, MIRANDAHOOK hookProc, void* object, LPARAM lParam)
+{
+ int idx;
+ THook* p;
+ HANDLE ret;
+
+ EnterCriticalSection(&csHooks);
+ if ((idx = hooks.getIndex((THook*)name)) == -1) {
+ #ifdef _DEBUG
+ OutputDebugStringA("Attempt to hook: \t");
+ OutputDebugStringA(name);
+ OutputDebugStringA("\n");
+ #endif
+ LeaveCriticalSection(&csHooks);
+ return NULL;
+ }
+
+ p = hooks[ idx ];
+ p->subscriber = (THookSubscriber*)mir_realloc(p->subscriber, sizeof(THookSubscriber)*(p->subscriberCount+1));
+ p->subscriber[ p->subscriberCount ].type = type;
+ p->subscriber[ p->subscriberCount ].pfnHook = hookProc;
+ p->subscriber[ p->subscriberCount ].object = object;
+ p->subscriber[ p->subscriberCount ].lParam = lParam;
+ p->subscriber[ p->subscriberCount ].hOwner = GetInstByAddress(hookProc);
+ p->subscriberCount++;
+
+ ret = (HANDLE)((p->id << 16) | p->subscriberCount);
+ LeaveCriticalSection(&csHooks);
+ return ret;
+}
+
+MIR_CORE_DLL(HANDLE) HookEvent(const char* name, MIRANDAHOOK hookProc)
+{
+ return HookEventInt(1, name, hookProc, 0, 0);
+}
+
+MIR_CORE_DLL(HANDLE) HookEventParam(const char* name, MIRANDAHOOKPARAM hookProc, LPARAM lParam)
+{
+ return HookEventInt(2, name, (MIRANDAHOOK)hookProc, 0, lParam);
+}
+
+MIR_CORE_DLL(HANDLE) HookEventObj(const char* name, MIRANDAHOOKOBJ hookProc, void* object)
+{
+ return HookEventInt(3, name, (MIRANDAHOOK)hookProc, object, 0);
+}
+
+MIR_CORE_DLL(HANDLE) HookEventObjParam(const char* name, MIRANDAHOOKOBJPARAM hookProc, void* object, LPARAM lParam)
+{
+ return HookEventInt(4, name, (MIRANDAHOOK)hookProc, object, lParam);
+}
+
+MIR_CORE_DLL(HANDLE) HookEventMessage(const char* name, HWND hwnd, UINT message)
+{
+ int idx;
+ THook* p;
+ HANDLE ret;
+
+ EnterCriticalSection(&csHooks);
+ if ((idx = hooks.getIndex((THook*)name)) == -1) {
+ #ifdef _DEBUG
+ MessageBoxA(NULL, "Attempt to hook non-existant event", name, MB_OK);
+ #endif
+ LeaveCriticalSection(&csHooks);
+ return NULL;
+ }
+
+ p = hooks[ idx ];
+ p->subscriber = (THookSubscriber*)mir_realloc(p->subscriber, sizeof(THookSubscriber)*(p->subscriberCount+1));
+ p->subscriber[ p->subscriberCount ].type = 5;
+ p->subscriber[ p->subscriberCount ].hwnd = hwnd;
+ p->subscriber[ p->subscriberCount ].message = message;
+ p->subscriberCount++;
+
+ ret = (HANDLE)((p->id << 16) | p->subscriberCount);
+ LeaveCriticalSection(&csHooks);
+ return ret;
+}
+
+MIR_CORE_DLL(int) UnhookEvent(HANDLE hHook)
+{
+ int i;
+ THook* p = NULL;
+
+ int hookId = (int)hHook >> 16;
+ int subscriberId = ((int)hHook & 0xFFFF) - 1;
+
+ if (hHook == NULL) return 0;
+
+ EnterCriticalSection(&csHooks);
+ for (i = 0; i < hooks.getCount(); i++) {
+ if (hooks[i]->id == hookId) {
+ p = hooks[i];
+ break;
+ } }
+
+ if (p == NULL) {
+ LeaveCriticalSection(&csHooks);
+ return 1;
+ }
+
+ if (subscriberId >= p->subscriberCount || subscriberId < 0) {
+ LeaveCriticalSection(&csHooks);
+ return 1;
+ }
+
+ p->subscriber[subscriberId].type = 0;
+ p->subscriber[subscriberId].pfnHook = NULL;
+ p->subscriber[subscriberId].hOwner = NULL;
+ while (p->subscriberCount && p->subscriber[p->subscriberCount-1].type == 0)
+ p->subscriberCount--;
+ if (p->subscriberCount == 0) {
+ if (p->subscriber) mir_free(p->subscriber);
+ p->subscriber = NULL;
+ }
+ LeaveCriticalSection(&csHooks);
+ return 0;
+}
+
+MIR_CORE_DLL(void) KillModuleEventHooks(HINSTANCE hInst)
+{
+ int i, j;
+
+ EnterCriticalSection(&csHooks);
+ for (i = hooks.getCount()-1; i >= 0; i--) {
+ if (hooks[i]->subscriberCount == 0)
+ continue;
+
+ for (j = hooks[i]->subscriberCount-1; j >= 0; j--) {
+ if (hooks[i]->subscriber[j].hOwner == hInst) {
+ char szModuleName[ MAX_PATH ];
+ GetModuleFileNameA(hooks[i]->subscriber[j].hOwner, szModuleName, sizeof(szModuleName));
+ UnhookEvent((HANDLE)((hooks[i]->id << 16) + j + 1));
+ if (hooks[i]->subscriberCount == 0)
+ break;
+ } } }
+
+ LeaveCriticalSection(&csHooks);
+}
+
+MIR_CORE_DLL(void) KillObjectEventHooks(void* pObject)
+{
+ int i, j;
+
+ EnterCriticalSection(&csHooks);
+ for (i = hooks.getCount()-1; i >= 0; i--) {
+ if (hooks[i]->subscriberCount == 0)
+ continue;
+
+ for (j = hooks[i]->subscriberCount-1; j >= 0; j--) {
+ if (hooks[i]->subscriber[j].object == pObject) {
+ UnhookEvent((HANDLE)((hooks[i]->id << 16) + j + 1));
+ if (hooks[i]->subscriberCount == 0)
+ break;
+ } } }
+
+ LeaveCriticalSection(&csHooks);
+}
+
+/////////////////////SERVICES
+
+static __inline TService* FindServiceByName(const char *name)
+{
+ unsigned hash = mir_hashstr(name);
+ return services.find((TService*)&hash);
+}
+
+static HANDLE CreateServiceInt(int type, const char *name, MIRANDASERVICE serviceProc, void* object, LPARAM lParam)
+{
+ if (name == NULL)
+ return NULL;
+
+ TService tmp;
+ tmp.nameHash = mir_hashstr(name);
+
+ EnterCriticalSection(&csServices);
+
+ if (services.getIndex(&tmp) != -1) {
+ LeaveCriticalSection(&csServices);
+ return NULL;
+ }
+
+ TService* p = (TService*)mir_alloc(sizeof(*p) + strlen(name));
+ strcpy(p->name, name);
+ p->nameHash = tmp.nameHash;
+ p->pfnService = serviceProc;
+ p->hOwner = GetInstByAddress(serviceProc);
+ p->flags = type;
+ p->lParam = lParam;
+ p->object = object;
+ services.insert(p);
+
+ LeaveCriticalSection(&csServices);
+ return (HANDLE)tmp.nameHash;
+}
+
+MIR_CORE_DLL(HANDLE) CreateServiceFunction(const char *name, MIRANDASERVICE serviceProc)
+{
+ return CreateServiceInt(0, name, serviceProc, 0, 0);
+}
+
+MIR_CORE_DLL(HANDLE) CreateServiceFunctionParam(const char *name, MIRANDASERVICEPARAM serviceProc, LPARAM lParam)
+{
+ return CreateServiceInt(1, name, (MIRANDASERVICE)serviceProc, 0, lParam);
+}
+
+MIR_CORE_DLL(HANDLE) CreateServiceFunctionObj(const char *name, MIRANDASERVICEOBJ serviceProc, void* object)
+{
+ return CreateServiceInt(2, name, (MIRANDASERVICE)serviceProc, object, 0);
+}
+
+MIR_CORE_DLL(HANDLE) CreateServiceFunctionObjParam(const char *name, MIRANDASERVICEOBJPARAM serviceProc, void* object, LPARAM lParam)
+{
+ return CreateServiceInt(3, name, (MIRANDASERVICE)serviceProc, object, lParam);
+}
+
+MIR_CORE_DLL(int) DestroyServiceFunction(HANDLE hService)
+{
+ int idx;
+
+ EnterCriticalSection(&csServices);
+ if ((idx = services.getIndex((TService*)&hService)) != -1) {
+ mir_free(services[idx]);
+ services.remove(idx);
+ }
+
+ LeaveCriticalSection(&csServices);
+ return 0;
+}
+
+MIR_CORE_DLL(int) ServiceExists(const char *name)
+{
+ if (name == NULL)
+ return FALSE;
+
+ EnterCriticalSection(&csServices);
+ int ret = FindServiceByName(name) != NULL;
+ LeaveCriticalSection(&csServices);
+ return ret;
+}
+
+MIR_CORE_DLL(INT_PTR) CallService(const char *name, WPARAM wParam, LPARAM lParam)
+{
+ #ifdef _DEBUG
+ if (name == NULL) {
+ MessageBoxA(0, "Someone tried to CallService(NULL, ..) see stack trace for details", "", 0);
+ DebugBreak();
+ return CALLSERVICE_NOTFOUND;
+ }
+ #else
+ if (name == NULL) return CALLSERVICE_NOTFOUND;
+ #endif
+
+ EnterCriticalSection(&csServices);
+ TService *pService = FindServiceByName(name);
+ if (pService == NULL) {
+ LeaveCriticalSection(&csServices);
+ #ifdef _DEBUG
+ OutputDebugStringA("Missing service called: \t");
+ OutputDebugStringA(name);
+ OutputDebugStringA("\n");
+ #endif
+
+ return CALLSERVICE_NOTFOUND;
+ }
+
+ MIRANDASERVICE pfnService = pService->pfnService;
+ int flags = pService->flags;
+ LPARAM fnParam = pService->lParam;
+ void* object = pService->object;
+ LeaveCriticalSection(&csServices);
+ switch(flags) {
+ case 1: return ((MIRANDASERVICEPARAM)pfnService)(wParam, lParam, fnParam);
+ case 2: return ((MIRANDASERVICEOBJ)pfnService)(object, wParam, lParam);
+ case 3: return ((MIRANDASERVICEOBJPARAM)pfnService)(object, wParam, lParam, fnParam);
+ default: return pfnService(wParam, lParam);
+} }
+
+static void CALLBACK CallServiceToMainAPCFunc(ULONG_PTR dwParam)
+{
+ TServiceToMainThreadItem *item = (TServiceToMainThreadItem*) dwParam;
+ item->result = CallService(item->name, item->wParam, item->lParam);
+ SetEvent(item->hDoneEvent);
+}
+
+MIR_CORE_DLL(INT_PTR) CallServiceSync(const char *name, WPARAM wParam, LPARAM lParam)
+{
+ extern HWND hAPCWindow;
+
+ if (name == NULL) return CALLSERVICE_NOTFOUND;
+ // the service is looked up within the main thread, since the time it takes
+ // for the APC queue to clear the service being called maybe removed.
+ // even thou it may exists before the call, the critsec can't be locked between calls.
+ if (GetCurrentThreadId() != mainThreadId) {
+ TServiceToMainThreadItem item;
+ item.wParam = wParam;
+ item.lParam = lParam;
+ item.name = name;
+ item.hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ QueueUserAPC(CallServiceToMainAPCFunc, hMainThread, (ULONG_PTR) &item);
+ PostMessage(hAPCWindow, WM_NULL, 0, 0); // let this get processed in its own time
+ WaitForSingleObject(item.hDoneEvent, INFINITE);
+ CloseHandle(item.hDoneEvent);
+ return item.result;
+ }
+
+ return CallService(name, wParam, lParam);
+}
+
+MIR_CORE_DLL(int) CallFunctionAsync(void (__stdcall *func)(void *), void *arg)
+{
+ extern HWND hAPCWindow;
+ int r = QueueUserAPC((void (__stdcall *)(ULONG_PTR))func, hMainThread, (ULONG_PTR)arg);
+ PostMessage(hAPCWindow, WM_NULL, 0, 0);
+ return r;
+}
+
+MIR_CORE_DLL(void) KillModuleServices(HINSTANCE hInst)
+{
+ int i;
+
+ EnterCriticalSection(&csServices);
+ for (i = services.getCount()-1; i >= 0; i--) {
+ if (services[i]->hOwner == hInst) {
+ char szModuleName[ MAX_PATH ];
+ GetModuleFileNameA(services[i]->hOwner, szModuleName, sizeof(szModuleName));
+ DestroyServiceFunction((HANDLE)services[i]->nameHash);
+ } }
+
+ LeaveCriticalSection(&csServices);
+}
+
+MIR_CORE_DLL(void) KillObjectServices(void* pObject)
+{
+ int i;
+
+ EnterCriticalSection(&csServices);
+ for (i = services.getCount()-1; i >= 0; i--)
+ if (services[i]->object == pObject)
+ DestroyServiceFunction((HANDLE)services[i]->nameHash);
+
+ LeaveCriticalSection(&csServices);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+int InitialiseModularEngine(void)
+{
+ InitializeCriticalSection(&csHooks);
+ InitializeCriticalSection(&csServices);
+
+ mainThreadId = GetCurrentThreadId();
+ DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
+
+ hMissingService = CreateHookableEvent(ME_SYSTEM_MISSINGSERVICE);
+ return 0;
+}
+
+void DestroyModularEngine(void)
+{
+ EnterCriticalSection(&csHooks);
+ for (int i=0; i < hooks.getCount(); i++) {
+ THook* p = hooks[i];
+ if (p->subscriberCount)
+ mir_free(p->subscriber);
+ DeleteCriticalSection(&p->csHook);
+ mir_free(p);
+ }
+ hooks.destroy();
+ LeaveCriticalSection(&csHooks);
+ DeleteCriticalSection(&csHooks);
+
+ EnterCriticalSection(&csServices);
+ for (int j=0; j < services.getCount(); j++)
+ mir_free(services[j]);
+
+ services.destroy();
+ LeaveCriticalSection(&csServices);
+ DeleteCriticalSection(&csServices);
+ CloseHandle(hMainThread);
+}
diff --git a/plugins/mir_core/path.cpp b/plugins/mir_core/path.cpp
new file mode 100644
index 0000000000..fada3dcd18
--- /dev/null
+++ b/plugins/mir_core/path.cpp
@@ -0,0 +1,210 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 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.
+*/
+#include "commonheaders.h"
+
+static char szMirandaPath[MAX_PATH];
+static char szMirandaPathLower[MAX_PATH];
+static TCHAR szMirandaPathW[MAX_PATH];
+static TCHAR szMirandaPathWLower[MAX_PATH];
+
+static int pathIsAbsolute(const char *path)
+{
+ if (strlen(path) <= 2)
+ return 0;
+ if ((path[1] == ':' && path[2] == '\\') || (path[0] == '\\' && path[1] == '\\'))
+ return 1;
+ return 0;
+}
+
+MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut)
+{
+ if ( !pSrc || !strlen(pSrc) || strlen(pSrc)>MAX_PATH) return 0;
+ if ( !pathIsAbsolute(pSrc)) {
+ mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
+ return (int)strlen(pOut);
+ }
+
+ char szTmp[MAX_PATH];
+ mir_snprintf(szTmp, SIZEOF(szTmp), "%s", pSrc);
+ _strlwr(szTmp);
+ if (strstr(szTmp, szMirandaPathLower)) {
+ mir_snprintf(pOut, MAX_PATH, "%s", pSrc+strlen(szMirandaPathLower));
+ return (int)strlen(pOut);
+ }
+ else {
+ mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
+ return (int)strlen(pOut);
+ }
+}
+
+MIR_CORE_DLL(int) PathToAbsolute(const char *pSrc, char *pOut, char* base)
+{
+ if ( !pSrc || !strlen(pSrc) || strlen(pSrc) > MAX_PATH)
+ return 0;
+
+ if (base == NULL)
+ base = szMirandaPath;
+
+ char buf[MAX_PATH];
+ if (pSrc[0] < ' ')
+ return mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
+ else if (pathIsAbsolute(pSrc))
+ return GetFullPathNameA(pSrc, MAX_PATH, pOut, NULL);
+ else if (pSrc[0] != '\\')
+ mir_snprintf(buf, MAX_PATH, "%s%s", base, pSrc);
+ else
+ mir_snprintf(buf, MAX_PATH, "%s%s", base, pSrc+1);
+
+ return GetFullPathNameA(buf, MAX_PATH, pOut, NULL);
+}
+
+MIR_CORE_DLL(void) CreatePathToFile(char* szFilePath)
+{
+ char* pszLastBackslash = strrchr(szFilePath, '\\');
+ if (pszLastBackslash == NULL)
+ return;
+
+ *pszLastBackslash = '\0';
+ CreateDirectoryTree(szFilePath);
+ *pszLastBackslash = '\\';
+}
+
+MIR_CORE_DLL(int) CreateDirectoryTree(const char *szDir)
+{
+ DWORD dwAttributes;
+ char *pszLastBackslash, szTestDir[ MAX_PATH ];
+
+ lstrcpynA(szTestDir, szDir, SIZEOF(szTestDir));
+ if ((dwAttributes = GetFileAttributesA(szTestDir)) != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ return 0;
+
+ pszLastBackslash = strrchr(szTestDir, '\\');
+ if (pszLastBackslash == NULL)
+ return 0;
+
+ *pszLastBackslash = '\0';
+ CreateDirectoryTree(szTestDir);
+ *pszLastBackslash = '\\';
+ return (CreateDirectoryA(szTestDir, NULL) == 0) ? GetLastError() : 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+static int pathIsAbsoluteW(const TCHAR *path)
+{
+ if (lstrlen(path) <= 2)
+ return 0;
+ if ((path[1] == ':' && path[2] == '\\') || (path[0] == '\\' && path[1] == '\\'))
+ return 1;
+ return 0;
+}
+
+MIR_CORE_DLL(int) PathToRelativeW(const WCHAR *pSrc, WCHAR *pOut)
+{
+ if ( !pSrc || !lstrlen(pSrc) || lstrlen(pSrc) > MAX_PATH)
+ return 0;
+
+ if ( !pathIsAbsoluteW(pSrc))
+ mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
+ else {
+ TCHAR szTmp[MAX_PATH];
+
+ mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s"), pSrc);
+ _tcslwr(szTmp);
+ if (_tcsstr(szTmp, szMirandaPathWLower))
+ mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc+lstrlen(szMirandaPathWLower));
+ else
+ mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
+ }
+ return lstrlen(pOut);
+}
+
+MIR_CORE_DLL(int) PathToAbsoluteW(const TCHAR *pSrc, TCHAR *pOut, TCHAR* base)
+{
+ if ( !pSrc || !wcslen(pSrc) || wcslen(pSrc) > MAX_PATH)
+ return 0;
+
+ if (base == NULL)
+ base = szMirandaPathW;
+
+ TCHAR buf[MAX_PATH];
+ if (pSrc[0] < ' ')
+ return mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
+ else if (pathIsAbsoluteW(pSrc))
+ return GetFullPathName(pSrc, MAX_PATH, pOut, NULL);
+ else if (pSrc[0] != '\\')
+ mir_sntprintf(buf, MAX_PATH, _T("%s%s"), base, pSrc);
+ else
+ mir_sntprintf(buf, MAX_PATH, _T("%s%s"), base, pSrc+1);
+
+ return GetFullPathName(buf, MAX_PATH, pOut, NULL);
+}
+
+MIR_CORE_DLL(void) CreatePathToFileW(WCHAR* wszFilePath)
+{
+ WCHAR* pszLastBackslash = wcsrchr(wszFilePath, '\\');
+ if (pszLastBackslash == NULL)
+ return;
+
+ *pszLastBackslash = '\0';
+ CreateDirectoryTreeW(wszFilePath);
+ *pszLastBackslash = '\\';
+}
+
+MIR_CORE_DLL(int) CreateDirectoryTreeW(const WCHAR* szDir)
+{
+ DWORD dwAttributes;
+ WCHAR* pszLastBackslash, szTestDir[ MAX_PATH ];
+
+ lstrcpynW(szTestDir, szDir, SIZEOF(szTestDir));
+ if ((dwAttributes = GetFileAttributesW(szTestDir)) != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ return 0;
+
+ pszLastBackslash = wcsrchr(szTestDir, '\\');
+ if (pszLastBackslash == NULL)
+ return 0;
+
+ *pszLastBackslash = '\0';
+ CreateDirectoryTreeW(szTestDir);
+ *pszLastBackslash = '\\';
+ return (CreateDirectoryW(szTestDir, NULL) == 0) ? GetLastError() : 0;
+}
+
+int InitPathUtils(void)
+{
+ char *p = 0;
+ GetModuleFileNameA(hInst, szMirandaPath, SIZEOF(szMirandaPath));
+ p = strrchr(szMirandaPath, '\\');
+ if (p)
+ p[1] = 0;
+ mir_snprintf(szMirandaPathLower, MAX_PATH, "%s", szMirandaPath);
+ _strlwr(szMirandaPathLower);
+
+ GetModuleFileName(hInst, szMirandaPathW, SIZEOF(szMirandaPathW));
+ TCHAR *tp = _tcsrchr(szMirandaPathW, '\\');
+ if (tp)
+ tp[1] = 0;
+ mir_sntprintf(szMirandaPathWLower, SIZEOF(szMirandaPathWLower), _T("%s"), szMirandaPathW);
+ _tcslwr(szMirandaPathWLower);
+ return 0;
+}
diff --git a/plugins/mir_core/timezones.cpp b/plugins/mir_core/timezones.cpp
new file mode 100644
index 0000000000..24340cd3d8
--- /dev/null
+++ b/plugins/mir_core/timezones.cpp
@@ -0,0 +1,224 @@
+/*
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2010 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.
+
+implements services to handle location - based timezones, instead of
+simple UTC offsets.
+*/
+
+#include "commonheaders.h"
+
+#include <m_timezones.h>
+
+typedef DWORD (WINAPI *pfnGetDynamicTimeZoneInformation_t)(DYNAMIC_TIME_ZONE_INFORMATION *pdtzi);
+static pfnGetDynamicTimeZoneInformation_t pfnGetDynamicTimeZoneInformation;
+
+typedef HRESULT (WINAPI *pfnSHLoadIndirectString_t)(LPCWSTR pszSource, LPWSTR pszOutBuf, UINT cchOutBuf, void **ppvReserved);
+static pfnSHLoadIndirectString_t pfnSHLoadIndirectString;
+
+typedef LANGID (WINAPI *pfnGetUserDefaultUILanguage_t)(void);
+static pfnGetUserDefaultUILanguage_t pfnGetUserDefaultUILanguage;
+
+typedef LANGID (WINAPI *pfnGetSystemDefaultUILanguage_t)(void);
+static pfnGetSystemDefaultUILanguage_t pfnGetSystemDefaultUILanguage;
+
+typedef LPARAM (WINAPI *pfnSendMessageW_t)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
+static pfnSendMessageW_t pfnSendMessageW;
+
+typedef struct _REG_TZI_FORMAT
+{
+ LONG Bias;
+ LONG StandardBias;
+ LONG DaylightBias;
+ SYSTEMTIME StandardDate;
+ SYSTEMTIME DaylightDate;
+} REG_TZI_FORMAT;
+
+#define MIM_TZ_DISPLAYLEN 128
+
+struct MIM_TIMEZONE
+{
+ unsigned hash;
+ int offset;
+
+ TCHAR tszName[MIM_TZ_NAMELEN]; // windows name for the time zone
+ wchar_t szDisplay[MIM_TZ_DISPLAYLEN]; // more descriptive display name (that's what usually appears in dialogs)
+ // every hour should be sufficient.
+ TIME_ZONE_INFORMATION tzi;
+
+ static int compareBias(const MIM_TIMEZONE* p1, const MIM_TIMEZONE* p2)
+ { return p2->tzi.Bias - p1->tzi.Bias; }
+};
+
+typedef struct
+{
+ DWORD timestamp; // last time updated
+ MIM_TIMEZONE myTZ; // set to my own timezone
+} TZ_INT_INFO;
+
+static TZ_INT_INFO myInfo;
+bool muiInstalled;
+
+static OBJLIST<MIM_TIMEZONE> g_timezones(55, NumericKeySortT);
+static LIST<MIM_TIMEZONE> g_timezonesBias(55, MIM_TIMEZONE::compareBias);
+
+void FormatTime (const SYSTEMTIME *st, const TCHAR *szFormat, TCHAR *szDest, int cbDest);
+void UnixTimeToFileTime(time_t ts, LPFILETIME pft);
+time_t FileTimeToUnixTime(LPFILETIME pft);
+
+#define fnSystemTimeToTzSpecificLocalTime SystemTimeToTzSpecificLocalTime
+
+void GetLocalizedString(HKEY hSubKey, const TCHAR *szName, wchar_t *szBuf, DWORD cbLen)
+{
+ szBuf[0] = 0;
+ if (muiInstalled)
+ {
+ TCHAR tszTempBuf[MIM_TZ_NAMELEN], tszName[30];
+ mir_sntprintf(tszName, SIZEOF(tszName), _T("MUI_%s"), szName);
+ DWORD dwLength = cbLen * sizeof(TCHAR);
+ if (ERROR_SUCCESS == RegQueryValueEx(hSubKey, tszName, NULL, NULL, (unsigned char *)tszTempBuf, &dwLength))
+ {
+ tszTempBuf[min(dwLength / sizeof(TCHAR), cbLen - 1)] = 0;
+ if (pfnSHLoadIndirectString)
+ pfnSHLoadIndirectString(StrConvU(tszTempBuf), szBuf, cbLen, NULL);
+ }
+ }
+ if (szBuf[0] == 0)
+ {
+ DWORD dwLength = cbLen * sizeof(wchar_t);
+
+
+ RegQueryValueEx(hSubKey, szName, NULL, NULL, (unsigned char *)szBuf, &dwLength);
+ szBuf[min(dwLength / sizeof(TCHAR), cbLen - 1)] = 0;
+ }
+}
+
+void RecalculateTime(void)
+{
+ GetTimeZoneInformation(&myInfo.myTZ.tzi);
+ myInfo.timestamp = time(NULL);
+ myInfo.myTZ.offset = INT_MIN;
+
+ bool found = false;
+ DYNAMIC_TIME_ZONE_INFORMATION dtzi;
+
+ if (pfnGetDynamicTimeZoneInformation && pfnGetDynamicTimeZoneInformation(&dtzi) != TIME_ZONE_ID_INVALID)
+ {
+ TCHAR *myTzKey = mir_u2t(dtzi.TimeZoneKeyName);
+ _tcscpy(myInfo.myTZ.tszName, myTzKey);
+ mir_free(myTzKey);
+ found = true;
+ }
+
+ for (int i = 0; i < g_timezones.getCount(); ++i)
+ {
+ MIM_TIMEZONE &tz = g_timezones[i];
+ if (tz.offset != INT_MIN) tz.offset = INT_MIN;
+
+ if ( !found)
+ {
+ if ( !wcscmp(tz.tzi.StandardName, myInfo.myTZ.tzi.StandardName) ||
+ !wcscmp(tz.tzi.DaylightName, myInfo.myTZ.tzi.DaylightName))
+ {
+ _tcscpy(myInfo.myTZ.tszName, tz.tszName);
+ found = true;
+ }
+ }
+ }
+}
+
+void InitTimeZones(void)
+{
+ REG_TZI_FORMAT tzi;
+ HKEY hKey;
+
+ const TCHAR *tszKey = IsWinVerNT() ?
+ _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones") :
+ _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Time Zones");
+
+ /*
+ * use GetDynamicTimeZoneInformation() on Vista+ - this will return a structure with
+ * the registry key name, so finding our own time zone later will be MUCH easier for
+ * localized systems or systems with a MUI pack installed
+ */
+ if (IsWinVerVistaPlus())
+ pfnGetDynamicTimeZoneInformation = (pfnGetDynamicTimeZoneInformation_t)GetProcAddress(GetModuleHandle(_T("kernel32")), "GetDynamicTimeZoneInformation");
+
+ if (IsWinVer2000Plus())
+ {
+ pfnSHLoadIndirectString = (pfnSHLoadIndirectString_t)GetProcAddress(GetModuleHandle(_T("shlwapi")), "SHLoadIndirectString");
+ pfnGetSystemDefaultUILanguage = (pfnGetSystemDefaultUILanguage_t)GetProcAddress(GetModuleHandle(_T("kernel32")), "GetSystemDefaultUILanguage");
+ pfnGetUserDefaultUILanguage = (pfnGetUserDefaultUILanguage_t)GetProcAddress(GetModuleHandle(_T("kernel32")), "GetUserDefaultUILanguage");
+ muiInstalled = pfnSHLoadIndirectString && pfnGetSystemDefaultUILanguage() != pfnGetUserDefaultUILanguage();
+ }
+
+ pfnSendMessageW = (pfnSendMessageW_t)GetProcAddress(GetModuleHandle(_T("user32")), "SendMessageW");
+
+ if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, tszKey, 0, KEY_ENUMERATE_SUB_KEYS, &hKey))
+ {
+ DWORD dwIndex = 0;
+ HKEY hSubKey;
+ TCHAR tszName[MIM_TZ_NAMELEN];
+
+ DWORD dwSize = SIZEOF(tszName);
+ while (ERROR_NO_MORE_ITEMS != RegEnumKeyEx(hKey, dwIndex++, tszName, &dwSize, NULL, NULL, 0, NULL))
+ {
+ if (ERROR_SUCCESS == RegOpenKeyEx(hKey, tszName, 0, KEY_QUERY_VALUE, &hSubKey))
+ {
+ dwSize = sizeof(tszName);
+
+ DWORD dwLength = sizeof(tzi);
+ if (ERROR_SUCCESS != RegQueryValueEx(hSubKey, _T("TZI"), NULL, NULL, (unsigned char *)&tzi, &dwLength))
+ continue;
+
+ MIM_TIMEZONE *tz = new MIM_TIMEZONE;
+
+ tz->tzi.Bias = tzi.Bias;
+ tz->tzi.StandardDate = tzi.StandardDate;
+ tz->tzi.StandardBias = tzi.StandardBias;
+ tz->tzi.DaylightDate = tzi.DaylightDate;
+ tz->tzi.DaylightBias = tzi.DaylightBias;
+
+ _tcscpy(tz->tszName, tszName);
+ tz->hash = mir_hashstrT(tszName);
+ tz->offset = INT_MIN;
+
+ GetLocalizedString(hSubKey, _T("Display"), tz->szDisplay, SIZEOF(tz->szDisplay));
+ GetLocalizedString(hSubKey, _T("Std"), tz->tzi.StandardName, SIZEOF(tz->tzi.StandardName));
+ GetLocalizedString(hSubKey, _T("Dlt"), tz->tzi.DaylightName, SIZEOF(tz->tzi.DaylightName));
+
+ g_timezones.insert(tz);
+ g_timezonesBias.insert(tz);
+
+ RegCloseKey(hSubKey);
+ }
+ dwSize = SIZEOF(tszName);
+ }
+ RegCloseKey(hKey);
+ }
+
+ RecalculateTime();
+}
+
+void UninitTimeZones(void)
+{
+ g_timezonesBias.destroy();
+ g_timezones.destroy();
+}
diff --git a/plugins/mir_core/utf.cpp b/plugins/mir_core/utf.cpp
new file mode 100644
index 0000000000..5ec6042758
--- /dev/null
+++ b/plugins/mir_core/utf.cpp
@@ -0,0 +1,406 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+ Copyright 2000 Alexandre Julliard of Wine project
+ (UTF-8 conversion routines)
+
+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 "commonheaders.h"
+
+/* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */
+static const char utf8_length[128] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80-0x8f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90-0x9f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0-0xaf */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0-0xbf */
+ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xc0-0xcf */
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xd0-0xdf */
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xe0-0xef */
+ 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xf0-0xff */
+};
+
+/* first byte mask depending on UTF-8 sequence length */
+static const unsigned char utf8_mask[4] = { 0x7f, 0x1f, 0x0f, 0x07 };
+
+/* minimum Unicode value depending on UTF-8 sequence length */
+static const unsigned int utf8_minval[4] = { 0x0, 0x80, 0x800, 0x10000 };
+
+/* get the next char value taking surrogates into account */
+static unsigned int getSurrogateValue(const wchar_t *src, unsigned int srclen)
+{
+ if (src[0] >= 0xd800 && src[0] <= 0xdfff) { /* surrogate pair */
+ if (src[0] > 0xdbff || /* invalid high surrogate */
+ srclen <= 1 || /* missing low surrogate */
+ src[1] < 0xdc00 || src[1] > 0xdfff) /* invalid low surrogate */
+ return 0;
+ return 0x10000 + ((src[0] & 0x3ff) << 10) + (src[1] & 0x3ff);
+ }
+ return src[0];
+}
+
+/* query necessary dst length for src string */
+static int Ucs2toUtf8Len(const wchar_t *src, unsigned int srclen)
+{
+ int len;
+ unsigned int val;
+
+ for (len = 0; srclen; srclen--, src++) {
+ if (*src < 0x80) { /* 0x00-0x7f: 1 byte */
+ len++;
+ continue;
+ }
+ if (*src < 0x800) { /* 0x80-0x7ff: 2 bytes */
+ len += 2;
+ continue;
+ }
+ if ( !(val = getSurrogateValue(src, srclen)))
+ return -2;
+
+ if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
+ len += 3;
+ else { /* 0x10000-0x10ffff: 4 bytes */
+ len += 4;
+ src++;
+ srclen--;
+ }
+ }
+ return len;
+}
+
+MIR_CORE_DLL(int) Ucs2toUtf8Len(const wchar_t *src)
+{
+ if (src == 0)
+ return 0;
+
+ return Ucs2toUtf8Len(src, (int)wcslen(src));
+}
+
+/* wide char to UTF-8 string conversion */
+/* return -1 on dst buffer overflow, -2 on invalid input char */
+int Ucs2toUtf8(const wchar_t *src, int srclen, char *dst, int dstlen)
+{
+ int len;
+
+ for (len = dstlen; srclen; srclen--, src++)
+ {
+ WCHAR ch = *src;
+ unsigned int val;
+
+ if (ch < 0x80) /* 0x00-0x7f: 1 byte */
+ {
+ if ( !len--) return -1; /* overflow */
+ *dst++ = ch;
+ continue;
+ }
+
+ if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */
+ {
+ if ((len -= 2) < 0) return -1; /* overflow */
+ dst[1] = 0x80 | (ch & 0x3f);
+ ch >>= 6;
+ dst[0] = 0xc0 | ch;
+ dst += 2;
+ continue;
+ }
+
+ if ( !(val = getSurrogateValue(src, srclen)))
+ {
+ return -2;
+ }
+
+ if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
+ {
+ if ((len -= 3) < 0) return -1; /* overflow */
+ dst[2] = 0x80 | (val & 0x3f);
+ val >>= 6;
+ dst[1] = 0x80 | (val & 0x3f);
+ val >>= 6;
+ dst[0] = 0xe0 | val;
+ dst += 3;
+ }
+ else /* 0x10000-0x10ffff: 4 bytes */
+ {
+ if ((len -= 4) < 0) return -1; /* overflow */
+ dst[3] = 0x80 | (val & 0x3f);
+ val >>= 6;
+ dst[2] = 0x80 | (val & 0x3f);
+ val >>= 6;
+ dst[1] = 0x80 | (val & 0x3f);
+ val >>= 6;
+ dst[0] = 0xf0 | val;
+ dst += 4;
+ src++;
+ srclen--;
+ }
+ }
+ return dstlen - len;
+}
+
+/* helper for the various utf8 mbstowcs functions */
+static unsigned int decodeUtf8Char(unsigned char ch, const char **str, const char *strend)
+{
+ unsigned int len = utf8_length[ch-0x80];
+ unsigned int res = ch & utf8_mask[len];
+ const char *end = *str + len;
+
+ if (end > strend) return ~0;
+ switch(len)
+ {
+ case 3:
+ if ((ch = end[-3] ^ 0x80) >= 0x40) break;
+ res = (res << 6) | ch;
+ (*str)++;
+ case 2:
+ if ((ch = end[-2] ^ 0x80) >= 0x40) break;
+ res = (res << 6) | ch;
+ (*str)++;
+ case 1:
+ if ((ch = end[-1] ^ 0x80) >= 0x40) break;
+ res = (res << 6) | ch;
+ (*str)++;
+ if (res < utf8_minval[len]) break;
+ return res;
+ }
+ return ~0;
+}
+
+/* query necessary dst length for src string */
+static inline int Utf8toUcs2Len(const char *src, int srclen)
+{
+ int ret = 0;
+ unsigned int res;
+ const char *srcend = src + srclen;
+
+ while (src < srcend)
+ {
+ unsigned char ch = *src++;
+ if (ch < 0x80) /* special fast case for 7-bit ASCII */
+ {
+ ret++;
+ continue;
+ }
+ if ((res = decodeUtf8Char(ch, &src, srcend)) <= 0x10ffff)
+ {
+ if (res > 0xffff) ret++;
+ ret++;
+ }
+ else return -2; /* bad char */
+ /* otherwise ignore it */
+ }
+ return ret;
+}
+
+/* UTF-8 to wide char string conversion */
+/* return -1 on dst buffer overflow, -2 on invalid input char */
+int Utf8toUcs2(const char *src, int srclen, wchar_t *dst, int dstlen)
+{
+ unsigned int res;
+ const char *srcend = src + srclen;
+ wchar_t *dstend = dst + dstlen;
+
+ while ((dst < dstend) && (src < srcend))
+ {
+ unsigned char ch = *src++;
+ if (ch < 0x80) /* special fast case for 7-bit ASCII */
+ {
+ *dst++ = ch;
+ continue;
+ }
+ if ((res = decodeUtf8Char(ch, &src, srcend)) <= 0xffff)
+ {
+ *dst++ = res;
+ }
+ else if (res <= 0x10ffff) /* we need surrogates */
+ {
+ if (dst == dstend - 1) return -1; /* overflow */
+ res -= 0x10000;
+ *dst++ = 0xd800 | (res >> 10);
+ *dst++ = 0xdc00 | (res & 0x3ff);
+ }
+ else return -2; /* bad char */
+ /* otherwise ignore it */
+ }
+ if (src < srcend) return -1; /* overflow */
+ return dstlen - (dstend - dst);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Utf8Decode - converts UTF8-encoded string to the UCS2/MBCS format
+
+MIR_CORE_DLL(char*) Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2)
+{
+ int len;
+ bool needs_free = false;
+ wchar_t* tempBuf = NULL;
+ if (ucs2)
+ *ucs2 = NULL;
+
+ if (str == NULL)
+ return NULL;
+
+ len = (int)strlen(str);
+
+ if (len < 2) {
+ if (ucs2 != NULL) {
+ *ucs2 = tempBuf = (wchar_t*)mir_alloc((len + 1) * sizeof(wchar_t));
+ MultiByteToWideChar(codepage, 0, str, len, tempBuf, len);
+ tempBuf[len] = 0;
+ }
+ return str;
+ }
+
+ int destlen = Utf8toUcs2Len(str, len);
+ if (destlen < 0)
+ return NULL;
+
+ if (ucs2 == NULL) {
+ __try
+ {
+ tempBuf = (wchar_t*)alloca((destlen + 1) * sizeof(wchar_t));
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+ tempBuf = NULL;
+ needs_free = true;
+ }
+ }
+
+ if (tempBuf == NULL) {
+ tempBuf = (wchar_t*)mir_alloc((destlen + 1) * sizeof(wchar_t));
+ if (tempBuf == NULL)
+ return NULL;
+ }
+
+ Utf8toUcs2(str, len, tempBuf, destlen);
+ tempBuf[destlen] = 0;
+ WideCharToMultiByte(codepage, 0, tempBuf, -1, str, len + 1, "?", NULL);
+
+ if (ucs2)
+ *ucs2 = tempBuf;
+ else if (needs_free)
+ mir_free(tempBuf);
+
+ return str;
+}
+
+MIR_CORE_DLL(char*) Utf8Decode(char* str, wchar_t** ucs2)
+{
+ return Utf8DecodeCP(str, LangPackGetDefaultCodePage(), ucs2);
+}
+
+MIR_CORE_DLL(wchar_t*) Utf8DecodeW(const char* str)
+{
+ if (str == NULL)
+ return NULL;
+
+ int len = (int)strlen(str);
+
+ int destlen = Utf8toUcs2Len(str, len);
+ if (destlen < 0) return NULL;
+
+ wchar_t* ucs2 = (wchar_t*)mir_alloc((destlen + 1) * sizeof(wchar_t));
+ if (ucs2 == NULL) return NULL;
+
+ if (Utf8toUcs2(str, len, ucs2, destlen) >= 0)
+ {
+ ucs2[destlen] = 0;
+ return ucs2;
+ }
+
+ mir_free(ucs2);
+
+ return NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Utf8Encode - converts MBCS string to the UTF8-encoded format
+
+MIR_CORE_DLL(char*) Utf8EncodeCP(const char* src, int codepage)
+{
+ int len;
+ bool needs_free = false;
+ char* result = NULL;
+ wchar_t* tempBuf;
+
+ if (src == NULL)
+ return NULL;
+
+ len = (int)strlen(src);
+
+ __try
+ {
+ tempBuf = (wchar_t*)alloca((len + 1) * sizeof(wchar_t));
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+ tempBuf = (wchar_t*)mir_alloc((len + 1) * sizeof(wchar_t));
+ if (tempBuf == NULL) return NULL;
+ needs_free = true;
+ }
+
+ len = MultiByteToWideChar(codepage, 0, src, -1, tempBuf, len + 1);
+
+ int destlen = Ucs2toUtf8Len(tempBuf, len);
+ if (destlen >= 0)
+ {
+ result = (char*)mir_alloc(destlen + 1);
+ if (result)
+ {
+ Ucs2toUtf8(tempBuf, len, result, destlen);
+ result[destlen] = 0;
+ }
+ }
+
+ if (needs_free)
+ mir_free(tempBuf);
+
+ return result;
+}
+
+MIR_CORE_DLL(char*) Utf8Encode(const char* src)
+{
+ return Utf8EncodeCP(src, LangPackGetDefaultCodePage());
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Utf8Encode - converts UCS2 string to the UTF8-encoded format
+
+MIR_CORE_DLL(char*) Utf8EncodeW(const wchar_t* src)
+{
+ if (src == NULL)
+ return NULL;
+
+ int len = (int)wcslen(src);
+
+ int destlen = Ucs2toUtf8Len(src, len);
+ if (destlen < 0) return NULL;
+
+ char* result = (char*)mir_alloc(destlen + 1);
+ if (result == NULL)
+ return NULL;
+
+ Ucs2toUtf8(src, len, result, destlen);
+ result[destlen] = 0;
+
+ return result;
+}
diff --git a/plugins/mir_core/utils.cpp b/plugins/mir_core/utils.cpp
new file mode 100644
index 0000000000..f0fcdcfa07
--- /dev/null
+++ b/plugins/mir_core/utils.cpp
@@ -0,0 +1,150 @@
+/*
+
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2009 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.
+*/
+
+#include "commonheaders.h"
+
+MIR_CORE_DLL(char*) rtrim(char* str)
+{
+ if (str == NULL)
+ return NULL;
+
+ char* p = strchr(str, 0);
+ while (--p >= str) {
+ switch (*p) {
+ case ' ': case '\t': case '\n': case '\r':
+ *p = 0; break;
+ default:
+ return str;
+ }
+ }
+ return str;
+}
+
+MIR_CORE_DLL(WCHAR*) wrtrim(WCHAR *str)
+{
+ if (str == NULL)
+ return NULL;
+
+ WCHAR* p = _tcschr(str, 0);
+ while (--p >= str) {
+ switch (*p) {
+ case ' ': case '\t': case '\n': case '\r':
+ *p = 0; break;
+ default:
+ return str;
+ }
+ }
+ return str;
+}
+
+MIR_CORE_DLL(char*) ltrim(char* str)
+{
+ if (str == NULL)
+ return NULL;
+
+ char* p = str;
+ for (;;) {
+ switch (*p) {
+ case ' ': case '\t': case '\n': case '\r':
+ ++p; break;
+ default:
+ memmove(str, p, strlen(p) + 1);
+ return str;
+ }
+ }
+}
+
+MIR_CORE_DLL(char*) ltrimp(char* str)
+{
+ if (str == NULL)
+ return NULL;
+
+ char* p = str;
+ for (;;) {
+ switch (*p) {
+ case ' ': case '\t': case '\n': case '\r':
+ ++p; break;
+ default:
+ return p;
+ }
+ }
+}
+
+MIR_CORE_DLL(int) wildcmp(char * name, char * mask)
+{
+ char * last='\0';
+ for (;; mask++, name++) {
+ if (*mask != '?' && *mask != *name) break;
+ if (*name == '\0') return ((BOOL)!*mask);
+ }
+ if (*mask != '*') return FALSE;
+ for (;; mask++, name++){
+ while (*mask == '*') {
+ last = mask++;
+ if (*mask == '\0') return ((BOOL)!*mask); /* true */
+ }
+ if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
+ if (*mask != '?' && *mask != *name) name -= (size_t)(mask - last) - 1, mask = last;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+static int sttComparePlugins(const HINSTANCE__* p1, const HINSTANCE__* p2)
+{
+ if (p1 == p2)
+ return 0;
+
+ return (p1 < p2) ? -1 : 1;
+}
+
+static LIST<HINSTANCE__> pluginListAddr(10, sttComparePlugins);
+
+MIR_CORE_DLL(void) RegisterModule(HINSTANCE hInst)
+{
+ pluginListAddr.insert(hInst);
+}
+
+MIR_CORE_DLL(void) UnregisterModule(HINSTANCE hInst)
+{
+ pluginListAddr.remove(hInst);
+}
+
+MIR_CORE_DLL(HINSTANCE) GetInstByAddress(void* codePtr)
+{
+ if (pluginListAddr.getCount() == 0)
+ return NULL;
+
+ int idx;
+ List_GetIndex((SortedList*)&pluginListAddr, &codePtr, &idx);
+ if (idx > 0)
+ idx--;
+
+ HINSTANCE result = pluginListAddr[idx];
+ if (result < hInst && codePtr > hInst)
+ result = hInst;
+ else if (idx == 0 && codePtr < (void*)result)
+ result = NULL;
+
+ return result;
+}
diff --git a/protocols/Gadu-Gadu/gg.c b/protocols/Gadu-Gadu/gg.c
index 8e573ba6ce..6cb5abf554 100644
--- a/protocols/Gadu-Gadu/gg.c
+++ b/protocols/Gadu-Gadu/gg.c
@@ -452,6 +452,7 @@ static GGPROTO *gg_proto_init(const char* pszProtoName, const TCHAR* tszUserName
DWORD dwVersion;
GGPROTO *gg = (GGPROTO *)mir_alloc(sizeof(GGPROTO));
char szVer[MAX_PATH];
+ char name[128];
NETLIBUSER nlu = { 0 };
ZeroMemory(gg, sizeof(GGPROTO));
@@ -486,16 +487,9 @@ static GGPROTO *gg_proto_init(const char* pszProtoName, const TCHAR* tszUserName
nlu.cbSize = sizeof(nlu);
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS;
nlu.szSettingsModule = gg->proto.m_szModuleName;
- if (gg->unicode_core) {
- WCHAR name[128];
- _snwprintf(name, SIZEOF(name), TranslateW(L"%s connection"), gg->proto.m_tszUserName);
- nlu.ptszDescriptiveName = (TCHAR *)name;
- nlu.flags |= NUF_UNICODE;
- } else {
- char name[128];
- mir_snprintf(name, SIZEOF(name), Translate("%s connection"), gg->proto.m_tszUserName);
- nlu.ptszDescriptiveName = name;
- }
+ mir_snprintf(name, SIZEOF(name), Translate("%s connection"), gg->proto.m_tszUserName);
+ nlu.ptszDescriptiveName = name;
+
gg->netlib = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
// Register services
diff --git a/protocols/IRCG/irc.h b/protocols/IRCG/irc.h
index 823efec68e..41591b388a 100644
--- a/protocols/IRCG/irc.h
+++ b/protocols/IRCG/irc.h
@@ -727,7 +727,6 @@ const TCHAR* __stdcall GetWordAddress(const TCHAR* text, int index);
void __stdcall RemoveLinebreaks( CMString& Message );
TCHAR* __stdcall my_strstri(const TCHAR *s1, const TCHAR *s2) ;
TCHAR* __stdcall DoColorCodes (const TCHAR* text, bool bStrip, bool bReplacePercent);
-char* __stdcall rtrim( char *string );
String& __stdcall ReplaceString (String& text, const char* replaceme, const char* newword);
String __stdcall GetWord(const char* text, int index);
diff --git a/protocols/IRCG/tools.cpp b/protocols/IRCG/tools.cpp
index d9218b2b42..83ac7ae60f 100644
--- a/protocols/IRCG/tools.cpp
+++ b/protocols/IRCG/tools.cpp
@@ -149,18 +149,6 @@ void CIrcProto::IrcHookEvent( const char* szEvent, IrcEventFunc pFunc )
::HookEventObj( szEvent, ( MIRANDAHOOKOBJ )*( void** )&pFunc, this );
}
-char* __stdcall rtrim( char *string )
-{
- char* p = string + strlen( string ) - 1;
- while ( p >= string ) {
- if ( *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r' )
- break;
-
- *p-- = 0;
- }
- return string;
-}
-
CMString __stdcall GetWord(const TCHAR* text, int index)
{
if ( text && *text ) {
diff --git a/protocols/IcqOscarJ/init.cpp b/protocols/IcqOscarJ/init.cpp
index ada5e55a93..2e05d249ab 100644
--- a/protocols/IcqOscarJ/init.cpp
+++ b/protocols/IcqOscarJ/init.cpp
@@ -111,9 +111,6 @@ static int OnModulesLoaded( WPARAM, LPARAM )
extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
{
pluginLink = link;
- mir_getLI( &li );
- mir_getMMI( &mmi );
- mir_getUTFI( &utfi );
mir_getMD5I( &md5i );
mir_getLP( &pluginInfo );
diff --git a/protocols/JabberG/jabber.h b/protocols/JabberG/jabber.h
index d3b13bf447..6cc58b4fb4 100644
--- a/protocols/JabberG/jabber.h
+++ b/protocols/JabberG/jabber.h
@@ -655,8 +655,6 @@ int ReloadIconsEventHook(WPARAM wParam, LPARAM lParam);
void __stdcall replaceStr( char*& dest, const char* src );
void __stdcall replaceStr( WCHAR*& dest, const WCHAR* src );
int lstrcmp_null(const TCHAR *s1, const TCHAR *s2);
-char* __stdcall rtrim( char *string );
-TCHAR* __stdcall rtrim( TCHAR *string );
//---- jabber_menu.c ------------------------------------------------
diff --git a/protocols/JabberG/jabber_chat.cpp b/protocols/JabberG/jabber_chat.cpp
index fc2662f94c..ac17a992b1 100644
--- a/protocols/JabberG/jabber_chat.cpp
+++ b/protocols/JabberG/jabber_chat.cpp
@@ -1532,7 +1532,7 @@ int CJabberProto::JabberGcEventHook(WPARAM, LPARAM lParam)
switch ( gch->pDest->iType ) {
case GC_USER_MESSAGE:
if ( gch->pszText && lstrlen( gch->ptszText) > 0 ) {
- rtrim( gch->ptszText );
+ trtrim( gch->ptszText );
if ( m_bJabberOnline ) {
TCHAR* buf = NEWTSTR_ALLOCA(gch->ptszText);
diff --git a/protocols/JabberG/jabber_libstr.cpp b/protocols/JabberG/jabber_libstr.cpp
index 78565bfa1a..955e949d1e 100644
--- a/protocols/JabberG/jabber_libstr.cpp
+++ b/protocols/JabberG/jabber_libstr.cpp
@@ -42,19 +42,6 @@ void __stdcall replaceStr( WCHAR*& dest, const WCHAR* src )
dest = ( src != NULL ) ? mir_wstrdup( src ) : NULL;
}
-char* __stdcall rtrim( char *string )
-{
- char* p = string + strlen( string ) - 1;
-
- while ( p >= string ) {
- if ( *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r' )
- break;
-
- *p-- = 0;
- }
- return string;
-}
-
int lstrcmp_null(const TCHAR *s1, const TCHAR *s2)
{
if (!s1 && !s2) return 0;
@@ -62,16 +49,3 @@ int lstrcmp_null(const TCHAR *s1, const TCHAR *s2)
if (!s2) return 1;
return lstrcmp(s1, s2);
}
-
-TCHAR* __stdcall rtrim( TCHAR *string )
-{
- TCHAR* p = string + _tcslen( string ) - 1;
-
- while ( p >= string ) {
- if ( *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r' )
- break;
-
- *p-- = 0;
- }
- return string;
-}
diff --git a/protocols/JabberG/jabber_menu.cpp b/protocols/JabberG/jabber_menu.cpp
index b489a793d8..e0c99757b3 100644
--- a/protocols/JabberG/jabber_menu.cpp
+++ b/protocols/JabberG/jabber_menu.cpp
@@ -204,7 +204,7 @@ void g_MenuInit( void )
hPrebuildMenuHook = HookEvent( ME_CLIST_PREBUILDCONTACTMENU, JabberPrebuildContactMenu );
- li.List_InsertPtr( &arServices, CreateServiceFunction( "Jabber/MenuChoose", JabberMenuChooseService ));
+ List_InsertPtr( &arServices, CreateServiceFunction( "Jabber/MenuChoose", JabberMenuChooseService ));
TMenuParam mnu = {0};
mnu.cbSize = sizeof(mnu);
@@ -233,7 +233,7 @@ void g_MenuInit( void )
mi.icolibItem = g_GetIconHandle( IDI_REQUEST );
mi.pszService = "Jabber/ReqAuth";
g_hMenuRequestAuth = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuHandleRequestAuth ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuHandleRequestAuth ));
// "Grant authorization"
mi.pszService = "Jabber/GrantAuth";
@@ -241,7 +241,7 @@ void g_MenuInit( void )
mi.position = -2000001001;
mi.icolibItem = g_GetIconHandle( IDI_GRANT );
g_hMenuGrantAuth = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuHandleGrantAuth ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuHandleGrantAuth ));
// Revoke auth
mi.pszService = "Jabber/RevokeAuth";
@@ -249,7 +249,7 @@ void g_MenuInit( void )
mi.position = -2000001002;
mi.icolibItem = g_GetIconHandle( IDI_AUTHREVOKE );
g_hMenuRevokeAuth = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuRevokeAuth ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuRevokeAuth ));
// "Convert Chat/Contact"
mi.pszService = "Jabber/ConvertChatContact";
@@ -257,7 +257,7 @@ void g_MenuInit( void )
mi.position = -1999901004;
mi.icolibItem = g_GetIconHandle( IDI_USER2ROOM );
g_hMenuConvert = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuConvertChatContact ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuConvertChatContact ));
// "Add to roster"
mi.pszService = "Jabber/AddToRoster";
@@ -265,7 +265,7 @@ void g_MenuInit( void )
mi.position = -1999901005;
mi.icolibItem = g_GetIconHandle( IDI_ADDROSTER );
g_hMenuRosterAdd = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuRosterAdd ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuRosterAdd ));
// "Add to Bookmarks"
mi.pszService = "Jabber/AddToBookmarks";
@@ -273,7 +273,7 @@ void g_MenuInit( void )
mi.position = -1999901006;
mi.icolibItem = g_GetIconHandle( IDI_BOOKMARKS);
g_hMenuAddBookmark = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuBookmarkAdd ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuBookmarkAdd ));
// Login/logout
mi.pszService = "Jabber/TransportLogin";
@@ -281,7 +281,7 @@ void g_MenuInit( void )
mi.position = -1999901007;
mi.icolibItem = g_GetIconHandle( IDI_LOGIN );
g_hMenuLogin = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuTransportLogin ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuTransportLogin ));
// Retrieve nicks
mi.pszService = "Jabber/TransportGetNicks";
@@ -289,7 +289,7 @@ void g_MenuInit( void )
mi.position = -1999901008;
mi.icolibItem = g_GetIconHandle( IDI_REFRESH );
g_hMenuRefresh = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuTransportResolve ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuTransportResolve ));
// Run Commands
mi.pszService = "Jabber/RunCommands";
@@ -297,7 +297,7 @@ void g_MenuInit( void )
mi.position = -1999901009;
mi.icolibItem = g_GetIconHandle( IDI_COMMAND );
g_hMenuCommands = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberContactMenuRunCommands ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberContactMenuRunCommands ));
// Send Note
mi.pszService = "Jabber/SendNote";
@@ -305,7 +305,7 @@ void g_MenuInit( void )
mi.position = -1999901010;
mi.icolibItem = g_GetIconHandle( IDI_SEND_NOTE);
g_hMenuSendNote = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuSendNote ));
+ List_InsertPtr( &arServices, CreateServiceFunction( mi.pszService, JabberMenuSendNote ));
// Direct Presence
mi.pszService = "Jabber/DirectPresenceDummySvc";
@@ -328,7 +328,7 @@ void g_MenuInit( void )
mi.hParentMenu = g_hMenuDirectPresence[0];
mi.icolibItem = LoadSkinnedIcon(PresenceModeArray[i].icon);
g_hMenuDirectPresence[i+1] = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleDirectPresence, PresenceModeArray[i].mode ));
+ List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleDirectPresence, PresenceModeArray[i].mode ));
}
mi.flags &= ~CMIF_ROOTHANDLE;
@@ -349,7 +349,7 @@ void g_MenuInit( void )
mi.icolibItem = g_GetIconHandle( IDI_JABBER );
mi.flags |= CMIF_ROOTHANDLE;
g_hMenuResourcesActive = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_LASTSEEN ));
+ List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_LASTSEEN ));
mi.pszService = "Jabber/UseResource_server";
mi.pszName = LPGEN("Server's Choice");
@@ -357,7 +357,7 @@ void g_MenuInit( void )
mi.pszPopupName = (char *)g_hMenuResourcesRoot;
mi.icolibItem = g_GetIconHandle( IDI_NODE_SERVER );
g_hMenuResourcesServer = Menu_AddContactMenuItem(&mi);
- li.List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_SERVER ));
+ List_InsertPtr( &arServices, CreateServiceFunctionParam( mi.pszService, JabberMenuHandleResource, MENUITEM_SERVER ));
}
void g_MenuUninit( void )
@@ -374,7 +374,7 @@ void g_MenuUninit( void )
UnhookEvent( hPrebuildMenuHook );
for (int i = 0; i < arServices.realCount; i++)
DestroyServiceFunction( arServices.items[i] );
- li.List_Destroy( &arServices );
+ List_Destroy( &arServices );
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -988,20 +988,20 @@ int g_OnModernToolbarInit(WPARAM, LPARAM)
button.defPos = 1000;
button.tbbFlags = TBBF_SHOWTOOLTIP|TBBF_VISIBLE;
- li.List_InsertPtr( &arServices, CreateServiceFunction("JABBER/*/Groupchat", g_ToolbarHandleJoinGroupchat ));
+ List_InsertPtr( &arServices, CreateServiceFunction("JABBER/*/Groupchat", g_ToolbarHandleJoinGroupchat ));
button.pszButtonID = button.pszServiceName = "JABBER/*/Groupchat";
button.pszTooltipUp = button.pszTooltipUp = button.pszButtonName = "Join conference";
button.hSecondaryIconHandle = button.hPrimaryIconHandle = (HANDLE)g_GetIconHandle(IDI_GROUP);
JCallService(MS_TB_ADDBUTTON, 0, (LPARAM)&button);
- li.List_InsertPtr( &arServices, CreateServiceFunction("JABBER/*/Bookmarks", g_ToolbarHandleBookmarks ));
+ List_InsertPtr( &arServices, CreateServiceFunction("JABBER/*/Bookmarks", g_ToolbarHandleBookmarks ));
button.pszButtonID = button.pszServiceName = "JABBER/*/Bookmarks";
button.pszTooltipUp = button.pszTooltipUp = button.pszButtonName = "Open bookmarks";
button.hSecondaryIconHandle = button.hPrimaryIconHandle = (HANDLE)g_GetIconHandle(IDI_BOOKMARKS);
button.defPos++;
JCallService(MS_TB_ADDBUTTON, 0, (LPARAM)&button);
- li.List_InsertPtr( &arServices, CreateServiceFunction("JABBER/*/ServiceDiscovery", g_ToolbarHandleServiceDiscovery ));
+ List_InsertPtr( &arServices, CreateServiceFunction("JABBER/*/ServiceDiscovery", g_ToolbarHandleServiceDiscovery ));
button.pszButtonID = button.pszServiceName = "JABBER/*/ServiceDiscovery";
button.pszTooltipUp = button.pszTooltipUp = button.pszButtonName = "Service discovery";
button.hSecondaryIconHandle = button.hPrimaryIconHandle = (HANDLE)g_GetIconHandle(IDI_SERVICE_DISCOVERY);
diff --git a/protocols/JabberG/jabber_thread.cpp b/protocols/JabberG/jabber_thread.cpp
index 5635c10a57..4bd558b048 100644
--- a/protocols/JabberG/jabber_thread.cpp
+++ b/protocols/JabberG/jabber_thread.cpp
@@ -289,7 +289,7 @@ LBL_Exit:
JFreeVariant( &dbv );
}
- if ( *rtrim(info->username) == '\0' ) {
+ if ( *trtrim(info->username) == '\0' ) {
DWORD dwSize = SIZEOF( info->username );
if ( GetUserName( info->username, &dwSize ))
JSetStringT( NULL, "LoginName", info->username );
@@ -297,7 +297,7 @@ LBL_Exit:
info->username[0] = 0;
}
- if ( *rtrim(info->username) == '\0' ) {
+ if ( *trtrim(info->username) == '\0' ) {
Log( "Thread ended, login name is not configured" );
JSendBroadcast( NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID );
LBL_FatalError:
diff --git a/protocols/MSN/msn_chat.cpp b/protocols/MSN/msn_chat.cpp
index 490f1d453c..eb3411d4ce 100644
--- a/protocols/MSN/msn_chat.cpp
+++ b/protocols/MSN/msn_chat.cpp
@@ -345,7 +345,7 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam)
ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID);
if (thread)
{
- rtrim(gch->ptszText); // remove the ending linebreak
+ trtrim(gch->ptszText); // remove the ending linebreak
TCHAR* pszMsg = UnEscapeChatTags(NEWTSTR_ALLOCA(gch->ptszText));
thread->sendMessage('N', NULL, NETID_MSN, UTF8(pszMsg), 0);
diff --git a/protocols/MSN/msn_global.h b/protocols/MSN/msn_global.h
index 306244f896..2b2ef91a70 100644
--- a/protocols/MSN/msn_global.h
+++ b/protocols/MSN/msn_global.h
@@ -212,12 +212,6 @@ void overrideStr(TCHAR*& dest, const TCHAR* src, bool unicode, const TCHAR* de
void replaceStr(char*& dest, const char* src);
void replaceStr(wchar_t*& dest, const wchar_t* src);
-char* __fastcall ltrimp(char* str);
-char* __fastcall rtrim(char* string);
-wchar_t* __fastcall rtrim(wchar_t* string);
-
-__inline char* lrtrimp(char* str) { return ltrimp(rtrim(str)); };
-
char* arrayToHex(BYTE* data, size_t datasz);
inline unsigned short _htons(unsigned short s)
@@ -260,7 +254,7 @@ struct STRLIST : public LIST<char>
for (int i=0; i < count; i++)
mir_free(items[i]);
- li.List_Destroy((SortedList*)this);
+ List_Destroy((SortedList*)this);
}
int insertn(const char* p) { return insert(mir_strdup(p)); }
@@ -268,13 +262,13 @@ struct STRLIST : public LIST<char>
int remove(int idx)
{
mir_free(items[idx]);
- return li.List_Remove((SortedList*)this, idx);
+ return List_Remove((SortedList*)this, idx);
}
int remove(const char* p)
{
int idx;
- return li.List_GetIndex((SortedList*)this, (char*)p, &idx) == 1 ? remove(idx) : -1;
+ return List_GetIndex((SortedList*)this, (char*)p, &idx) == 1 ? remove(idx) : -1;
}
};
diff --git a/protocols/MSN/msn_libstr.cpp b/protocols/MSN/msn_libstr.cpp
index 50756b7ccd..9cb83bbb63 100644
--- a/protocols/MSN/msn_libstr.cpp
+++ b/protocols/MSN/msn_libstr.cpp
@@ -57,51 +57,6 @@ void overrideStr(TCHAR*& dest, const TCHAR* src, bool unicode, const TCHAR* def)
dest = mir_tstrdup(def);
}
-char* __fastcall ltrimp(char* str)
-{
- if (str == NULL) return NULL;
- char* p = str;
-
- for (;;)
- {
- switch (*p)
- {
- case ' ': case '\t': case '\n': case '\r':
- ++p; break;
- default:
- return p;
- }
- }
-}
-
-char* __fastcall rtrim(char *string)
-{
- char* p = string + strlen(string) - 1;
-
- while (p >= string)
- {
- if (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r')
- break;
-
- *p-- = 0;
- }
- return string;
-}
-
-wchar_t* __fastcall rtrim(wchar_t* string)
-{
- wchar_t* p = string + wcslen(string) - 1;
-
- while (p >= string)
- {
- if (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r')
- break;
-
- *p-- = 0;
- }
- return string;
-}
-
char* arrayToHex(BYTE* data, size_t datasz)
{
char* res = (char*)mir_alloc(2 * datasz + 1);
diff --git a/protocols/MSN/msn_mail.cpp b/protocols/MSN/msn_mail.cpp
index 52d3fcb12b..57996b65ac 100644
--- a/protocols/MSN/msn_mail.cpp
+++ b/protocols/MSN/msn_mail.cpp
@@ -416,7 +416,7 @@ void CMsnProto::displayEmailCount(HANDLE hContact)
}
while (ch && !_istdigit(ch[1]));
if (ch) *ch = 0;
- rtrim(name);
+ trtrim(name);
TCHAR szNick[128];
mir_sntprintf(szNick, SIZEOF(szNick),
diff --git a/src/core/commonheaders.h b/src/core/commonheaders.h
index e47ba25fb3..5e6c25da62 100644
--- a/src/core/commonheaders.h
+++ b/src/core/commonheaders.h
@@ -56,10 +56,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <win2k.h>
-#include "modules.h"
-
#include <m_system.h>
#include <m_system_cpp.h>
+#include <m_core.h>
#include <newpluginapi.h>
#include <m_database.h>
#include <m_clc.h>
@@ -94,8 +93,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_timezones.h>
#include "miranda.h"
-#include "forkthread.h"
-#include "../modules/database/dblists.h"
#include <m_ssl.h>
#include <m_netlib.h>
diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp
index 8678524411..baf786a8d3 100644
--- a/src/core/miranda.cpp
+++ b/src/core/miranda.cpp
@@ -27,15 +27,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MMI_SIZE_V1 (4*sizeof(void*))
#define MMI_SIZE_V2 (7*sizeof(void*))
-int InitPathUtils(void);
-int InitialiseModularEngine(void);
int LoadDefaultModules(void);
-void DestroyModularEngine(void);
void UnloadNewPluginsModule(void);
void UnloadDefaultModules(void);
-void RecalculateTime(void);
-
-HINSTANCE GetInstByAddress(void* codePtr);
pfnMyMonitorFromPoint MyMonitorFromPoint;
pfnMyMonitorFromRect MyMonitorFromRect;
@@ -84,106 +78,31 @@ LPFN_WSAADDRESSTOSTRINGA MyWSAAddressToString;
ITaskbarList3 * pTaskbarInterface;
-static DWORD MsgWaitForMultipleObjectsExWorkaround(DWORD nCount, const HANDLE *pHandles,
- DWORD dwMsecs, DWORD dwWakeMask, DWORD dwFlags);
-
HANDLE hOkToExitEvent, hModulesLoadedEvent;
HANDLE hShutdownEvent, hPreShutdownEvent;
static HANDLE hWaitObjects[MAXIMUM_WAIT_OBJECTS-1];
static char *pszWaitServices[MAXIMUM_WAIT_OBJECTS-1];
static int waitObjectCount = 0;
-HANDLE hStackMutex, hMirandaShutdown, hThreadQueueEmpty;
-HINSTANCE hMirandaInst;
+HANDLE hMirandaShutdown, hThreadQueueEmpty;
+HINSTANCE hInst;
int hLangpack = 0;
/////////////////////////////////////////////////////////////////////////////////////////
// exception handling
-static DWORD __cdecl sttDefaultFilter(DWORD, EXCEPTION_POINTERS*)
-{
- return EXCEPTION_EXECUTE_HANDLER;
-}
-
-pfnExceptionFilter pMirandaExceptFilter = sttDefaultFilter;
-
-static INT_PTR GetExceptionFilter(WPARAM, LPARAM)
+static INT_PTR srvGetExceptionFilter(WPARAM, LPARAM)
{
- return (INT_PTR)pMirandaExceptFilter;
+ return (INT_PTR)GetExceptionFilter();
}
-static INT_PTR SetExceptionFilter(WPARAM, LPARAM lParam)
+static INT_PTR srvSetExceptionFilter(WPARAM, LPARAM lParam)
{
- pfnExceptionFilter oldOne = pMirandaExceptFilter;
- if (lParam != 0)
- pMirandaExceptFilter = (pfnExceptionFilter)lParam;
- return (INT_PTR)oldOne;
+ return (INT_PTR)SetExceptionFilter((pfnExceptionFilter)lParam);
}
/////////////////////////////////////////////////////////////////////////////////////////
-// thread support functions
-
-typedef struct
-{
- DWORD dwThreadId; // valid if hThread isn't signalled
- HANDLE hThread;
- HINSTANCE hOwner;
- void* pObject;
- PVOID addr;
-}
-THREAD_WAIT_ENTRY;
-
-static LIST<THREAD_WAIT_ENTRY> threads(10, NumericKeySortT);
-
-struct FORK_ARG {
- HANDLE hEvent;
- pThreadFunc threadcode;
- pThreadFuncEx threadcodeex;
- void *arg, *owner;
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
// forkthread - starts a new thread
-void __cdecl forkthread_r(void * arg)
-{
- struct FORK_ARG * fa = (struct FORK_ARG *) arg;
- void (*callercode)(void*)=fa->threadcode;
- void * cookie=fa->arg;
- CallService(MS_SYSTEM_THREAD_PUSH, 0, (LPARAM)callercode);
- SetEvent(fa->hEvent);
- __try
- {
- callercode(cookie);
- }
- __except(pMirandaExceptFilter(GetExceptionCode(), GetExceptionInformation()))
- {
- Netlib_Logf(NULL, "Unhandled exception in thread %x", GetCurrentThreadId());
- }
-
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
- CallService(MS_SYSTEM_THREAD_POP, 0, 0);
- return;
-}
-
-UINT_PTR forkthread (
- void (__cdecl *threadcode)(void*),
- unsigned long stacksize,
- void *arg
- )
-{
- UINT_PTR rc;
- struct FORK_ARG fa;
- fa.hEvent=CreateEvent(NULL, FALSE, FALSE, NULL);
- fa.threadcode=threadcode;
- fa.arg=arg;
- rc=_beginthread(forkthread_r, stacksize, &fa);
- if ((UINT_PTR)-1L != rc)
- WaitForSingleObject(fa.hEvent, INFINITE);
-
- CloseHandle(fa.hEvent);
- return rc;
-}
-
static INT_PTR ForkThreadService(WPARAM wParam, LPARAM lParam)
{
return (INT_PTR)forkthread((pThreadFunc)wParam, 0, (void*)lParam);
@@ -192,56 +111,6 @@ static INT_PTR ForkThreadService(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
// forkthreadex - starts a new thread with the extended info and returns the thread id
-unsigned __stdcall forkthreadex_r(void * arg)
-{
- struct FORK_ARG *fa = (struct FORK_ARG *)arg;
- pThreadFuncEx threadcode = fa->threadcodeex;
- pThreadFuncOwner threadcodeex = (pThreadFuncOwner)fa->threadcodeex;
- void *cookie = fa->arg;
- void *owner = fa->owner;
- unsigned long rc = 0;
-
- CallService(MS_SYSTEM_THREAD_PUSH, (WPARAM)fa->owner, (LPARAM)threadcode);
- SetEvent(fa->hEvent);
- __try
- {
- if (owner)
- rc = threadcodeex(owner, cookie);
- else
- rc = threadcode(cookie);
- }
- __except(pMirandaExceptFilter(GetExceptionCode(), GetExceptionInformation()))
- {
- Netlib_Logf(NULL, "Unhandled exception in thread %x", GetCurrentThreadId());
- }
-
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
- CallService(MS_SYSTEM_THREAD_POP, 0, 0);
- return rc;
-}
-
-UINT_PTR forkthreadex(
- void *sec,
- unsigned stacksize,
- unsigned (__stdcall *threadcode)(void*),
- void* owner,
- void *arg,
- unsigned *thraddr)
-{
- UINT_PTR rc;
- struct FORK_ARG fa = { 0 };
- fa.threadcodeex = threadcode;
- fa.arg = arg;
- fa.owner = owner;
- fa.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- rc = _beginthreadex(sec, stacksize, forkthreadex_r, (void *)&fa, 0, thraddr);
- if (rc)
- WaitForSingleObject(fa.hEvent, INFINITE);
-
- CloseHandle(fa.hEvent);
- return rc;
-}
-
static INT_PTR ForkThreadServiceEx(WPARAM wParam, LPARAM lParam)
{
FORK_THREADEX_PARAMS* params = (FORK_THREADEX_PARAMS*)lParam;
@@ -253,108 +122,6 @@ static INT_PTR ForkThreadServiceEx(WPARAM wParam, LPARAM lParam)
}
/////////////////////////////////////////////////////////////////////////////////////////
-// APC and mutex functions
-
-static void __stdcall DummyAPCFunc(ULONG_PTR)
-{
- /* called in the context of thread that cleared it's APC queue */
- return;
-}
-
-static int MirandaWaitForMutex(HANDLE hEvent)
-{
- for (;;) {
- // will get WAIT_IO_COMPLETE for QueueUserAPC() which isnt a result
- DWORD rc = MsgWaitForMultipleObjectsExWorkaround(1, &hEvent, INFINITE, QS_ALLINPUT, MWMO_ALERTABLE);
- if (rc == WAIT_OBJECT_0 + 1) {
- MSG msg;
- while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
- if (IsDialogMessage(msg.hwnd, &msg)) continue;
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- } else if (rc == WAIT_OBJECT_0) {
- // got object
- return 1;
- } else if (rc == WAIT_ABANDONED_0 || rc == WAIT_FAILED) return 0;
- }
-}
-
-VOID CALLBACK KillAllThreads(HWND, UINT, UINT_PTR, DWORD)
-{
- if ( MirandaWaitForMutex(hStackMutex)) {
- for (int j=0; j < threads.getCount(); j++) {
- THREAD_WAIT_ENTRY* p = threads[j];
- char szModuleName[ MAX_PATH ];
- GetModuleFileNameA(p->hOwner, szModuleName, sizeof(szModuleName));
- Netlib_Logf(NULL, "Thread %p was abnormally terminated because module '%s' didn't release it. Entry point: %p",
- p->hThread, szModuleName, p->addr);
- TerminateThread(p->hThread, 9999);
- CloseHandle(p->hThread);
- mir_free(p);
- }
-
- threads.destroy();
-
- ReleaseMutex(hStackMutex);
- SetEvent(hThreadQueueEmpty);
- }
-}
-
-void KillObjectThreads(void* owner)
-{
- if (owner == NULL)
- return;
-
- WaitForSingleObject(hStackMutex, INFINITE);
-
- HANDLE* threadPool = (HANDLE*)alloca(threads.getCount()*sizeof(HANDLE));
- int threadCount = 0;
-
- for (int j = threads.getCount(); j--;) {
- THREAD_WAIT_ENTRY* p = threads[j];
- if (p->pObject == owner)
- threadPool[ threadCount++ ] = p->hThread;
- }
- ReleaseMutex(hStackMutex);
-
- // is there anything to kill?
- if (threadCount > 0) {
- if ( WaitForMultipleObjects(threadCount, threadPool, TRUE, 5000) == WAIT_TIMEOUT) {
- // forcibly kill all remaining threads after 5 secs
- WaitForSingleObject(hStackMutex, INFINITE);
- for (int j = threads.getCount()-1; j >= 0; j--) {
- THREAD_WAIT_ENTRY* p = threads[j];
- if (p->pObject == owner) {
- TerminateThread(p->hThread, 9999);
- CloseHandle(p->hThread);
- threads.remove(j);
- mir_free(p);
- }
- }
- ReleaseMutex(hStackMutex);
- }
- }
-}
-
-static void UnwindThreadWait(void)
-{
- // acquire the list and wake up any alertable threads
- if ( MirandaWaitForMutex(hStackMutex)) {
- int j;
- for (j=0; j < threads.getCount(); j++)
- QueueUserAPC(DummyAPCFunc, threads[j]->hThread, 0);
- ReleaseMutex(hStackMutex);
- }
-
- // give all unclosed threads 5 seconds to close
- SetTimer(NULL, 0, 5000, KillAllThreads);
-
- // wait til the thread list is empty
- MirandaWaitForMutex(hThreadQueueEmpty);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
typedef LONG (WINAPI *pNtQIT)(HANDLE, LONG, PVOID, ULONG, PULONG);
#define ThreadQuerySetWin32StartAddress 9
@@ -380,55 +147,6 @@ void* GetCurrentThreadEntryPoint()
return (void*)dwStartAddress;
}
-INT_PTR UnwindThreadPush(WPARAM wParam, LPARAM lParam)
-{
- ResetEvent(hThreadQueueEmpty); // thread list is not empty
- if ( WaitForSingleObject(hStackMutex, INFINITE) == WAIT_OBJECT_0) {
- THREAD_WAIT_ENTRY* p = (THREAD_WAIT_ENTRY*)mir_calloc(sizeof(THREAD_WAIT_ENTRY));
-
- DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &p->hThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
- p->dwThreadId = GetCurrentThreadId();
- p->pObject = (void*)wParam;
- p->hOwner = GetInstByAddress((void*)lParam);
- p->addr = (void*)lParam;
- threads.insert(p);
-
- //Netlib_Logf(NULL, "*** pushing thread %x[%x] (%d)", hThread, GetCurrentThreadId(), threads.count);
- ReleaseMutex(hStackMutex);
- } //if
- return 0;
-}
-
-INT_PTR UnwindThreadPop(WPARAM, LPARAM)
-{
- if ( WaitForSingleObject(hStackMutex, INFINITE) == WAIT_OBJECT_0) {
- DWORD dwThreadId=GetCurrentThreadId();
- int j;
- //Netlib_Logf(NULL, "*** popping thread %x, %d threads left", dwThreadId, threads.count);
- for (j=0; j < threads.getCount(); j++) {
- THREAD_WAIT_ENTRY* p = threads[j];
- if (p->dwThreadId == dwThreadId) {
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
- CloseHandle(p->hThread);
- threads.remove(j);
- mir_free(p);
-
- if ( !threads.getCount()) {
- threads.destroy();
- ReleaseMutex(hStackMutex);
- SetEvent(hThreadQueueEmpty); // thread list is empty now
- return 0;
- }
-
- ReleaseMutex(hStackMutex);
- return 0;
- } //if
- } //for
- ReleaseMutex(hStackMutex);
- } //if
- return 1;
-}
-
INT_PTR MirandaIsTerminated(WPARAM, LPARAM)
{
return WaitForSingleObject(hMirandaShutdown, 0) == WAIT_OBJECT_0;
@@ -449,14 +167,6 @@ static void __cdecl compactHeapsThread(void*)
} //while
}
-LRESULT CALLBACK APCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (msg == WM_NULL) SleepEx(0, TRUE);
- if (msg == WM_TIMECHANGE) RecalculateTime();
- return DefWindowProc(hwnd, msg, wParam, lParam);
-}
-
-HWND hAPCWindow=NULL;
void (*SetIdleCallback) (void)=NULL;
static INT_PTR SystemSetIdleCallback(WPARAM, LPARAM lParam)
@@ -485,17 +195,6 @@ static INT_PTR SystemGetIdle(WPARAM, LPARAM lParam)
return 0;
}
-static DWORD MsgWaitForMultipleObjectsExWorkaround(DWORD nCount, const HANDLE *pHandles,
- DWORD dwMsecs, DWORD dwWakeMask, DWORD dwFlags)
-{
- DWORD rc;
- if (msgWaitForMultipleObjectsEx != NULL)
- return msgWaitForMultipleObjectsEx(nCount, pHandles, dwMsecs, dwWakeMask, dwFlags);
- rc=MsgWaitForMultipleObjects(nCount, pHandles, FALSE, 50, QS_ALLINPUT);
- if (rc == WAIT_TIMEOUT) rc=WaitForMultipleObjectsEx(nCount, pHandles, FALSE, 20, TRUE);
- return rc;
-}
-
static int SystemShutdownProc(WPARAM, LPARAM)
{
UnloadDefaultModules();
@@ -545,7 +244,7 @@ void ParseCommandLine()
if (p) {
HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, atol(p+9));
if (hProcess) {
- DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_WAITRESTART), NULL, WaitForProcessDlgProc, (LPARAM)hProcess);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WAITRESTART), NULL, WaitForProcessDlgProc, (LPARAM)hProcess);
CloseHandle(hProcess);
}
}
@@ -558,7 +257,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
HMODULE hUser32, hThemeAPI, hDwmApi, hShFolder = NULL;
int result = 0;
- hMirandaInst = hInstance;
+ hInst = hInstance;
setlocale(LC_ALL, "");
@@ -635,9 +334,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
if ( IsWinVer7Plus())
CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&pTaskbarInterface);
- InitialiseModularEngine();
-// ParseCommandLine();
-
if ( LoadDefaultModules()) {
NotifyEventHooks(hShutdownEvent, 0, 0);
UnloadDefaultModules();
@@ -659,7 +355,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
MSG msg;
DWORD rc;
BOOL dying=FALSE;
- rc=MsgWaitForMultipleObjectsExWorkaround(waitObjectCount, hWaitObjects, INFINITE, QS_ALLINPUT, MWMO_ALERTABLE);
+ rc = MsgWaitForMultipleObjectsEx(waitObjectCount, hWaitObjects, INFINITE, QS_ALLINPUT, MWMO_ALERTABLE);
if (rc >= WAIT_OBJECT_0 && rc < WAIT_OBJECT_0 + waitObjectCount) {
rc -= WAIT_OBJECT_0;
CallService(pszWaitServices[rc], (WPARAM) hWaitObjects[rc], 0);
@@ -697,11 +393,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
exit:
UnloadNewPluginsModule();
- DestroyModularEngine();
- CloseHandle(hStackMutex);
CloseHandle(hMirandaShutdown);
CloseHandle(hThreadQueueEmpty);
- DestroyWindow(hAPCWindow);
if (pTaskbarInterface)
pTaskbarInterface->Release();
@@ -769,7 +462,7 @@ static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam)
INT_PTR WaitOnHandle(WPARAM wParam, LPARAM lParam)
{
- if (waitObjectCount>=MAXIMUM_WAIT_OBJECTS-1)
+ if (waitObjectCount >= MAXIMUM_WAIT_OBJECTS-1)
return 1;
hWaitObjects[waitObjectCount] = (HANDLE)wParam;
@@ -842,26 +535,18 @@ INT_PTR GetListInterface(WPARAM, LPARAM lParam)
if (li == NULL)
return 1;
- switch(li->cbSize) {
- case LIST_INTERFACE_V3_SIZE:
- li->List_Copy = List_Copy;
- li->List_ObjCopy = List_ObjCopy;
-
- case LIST_INTERFACE_V2_SIZE:
- li->List_InsertPtr = List_InsertPtr;
- li->List_RemovePtr = List_RemovePtr;
-
- case LIST_INTERFACE_V1_SIZE:
- li->List_Create = List_Create;
- li->List_Destroy = List_Destroy;
- li->List_Find = List_Find;
- li->List_GetIndex = List_GetIndex;
- li->List_Insert = List_Insert;
- li->List_Remove = List_Remove;
- li->List_IndexOf = List_IndexOf;
- return 0;
- }
- return 1;
+ li->List_Copy = List_Copy;
+ li->List_ObjCopy = List_ObjCopy;
+ li->List_InsertPtr = List_InsertPtr;
+ li->List_RemovePtr = List_RemovePtr;
+ li->List_Create = List_Create;
+ li->List_Destroy = List_Destroy;
+ li->List_Find = List_Find;
+ li->List_GetIndex = List_GetIndex;
+ li->List_Insert = List_Insert;
+ li->List_Remove = List_Remove;
+ li->List_IndexOf = List_IndexOf;
+ return 0;
}
INT_PTR GetUtfInterface(WPARAM, LPARAM lParam)
@@ -884,9 +569,9 @@ INT_PTR GetUtfInterface(WPARAM, LPARAM lParam)
utfi->utf8_decodecp = Utf8DecodeCP;
utfi->utf8_encode = Utf8Encode;
utfi->utf8_encodecp = Utf8EncodeCP;
- utfi->utf8_encodeW = Utf8EncodeUcs2;
+ utfi->utf8_encodeW = Utf8EncodeW;
if (utfi->cbSize > UTF8_INTERFACE_SIZEOF_V1)
- utfi->utf8_decodeW = Utf8DecodeUcs2;
+ utfi->utf8_decodeW = Utf8DecodeW;
if (utfi->cbSize > UTF8_INTERFACE_SIZEOF_V2)
utfi->utf8_lenW = Ucs2toUtf8Len;
@@ -895,28 +580,13 @@ INT_PTR GetUtfInterface(WPARAM, LPARAM lParam)
int LoadSystemModule(void)
{
- INITCOMMONCONTROLSEX icce = {0};
- icce.dwSize = sizeof(icce);
- icce.dwICC = ICC_WIN95_CLASSES | ICC_USEREX_CLASSES;
- InitCommonControlsEx(&icce);
+ hMirandaShutdown = CreateEvent(NULL, TRUE, FALSE, NULL);
+ hThreadQueueEmpty = CreateEvent(NULL, TRUE, TRUE, NULL);
- if ( IsWinVerXPPlus()) {
- hAPCWindow=CreateWindowEx(0, _T("ComboLBox"), NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
- SetClassLongPtr(hAPCWindow, GCL_STYLE, GetClassLongPtr(hAPCWindow, GCL_STYLE) | CS_DROPSHADOW);
- DestroyWindow(hAPCWindow);
- hAPCWindow = NULL;
- }
-
- hAPCWindow=CreateWindowEx(0, _T("STATIC"), NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); // lame
- SetWindowLongPtr(hAPCWindow, GWLP_WNDPROC, (LONG_PTR)APCWndProc);
- hStackMutex=CreateMutex(NULL, FALSE, NULL);
- hMirandaShutdown=CreateEvent(NULL, TRUE, FALSE, NULL);
- hThreadQueueEmpty=CreateEvent(NULL, TRUE, TRUE, NULL);
-
- hShutdownEvent=CreateHookableEvent(ME_SYSTEM_SHUTDOWN);
- hPreShutdownEvent=CreateHookableEvent(ME_SYSTEM_PRESHUTDOWN);
- hModulesLoadedEvent=CreateHookableEvent(ME_SYSTEM_MODULESLOADED);
- hOkToExitEvent=CreateHookableEvent(ME_SYSTEM_OKTOEXIT);
+ hShutdownEvent = CreateHookableEvent(ME_SYSTEM_SHUTDOWN);
+ hPreShutdownEvent = CreateHookableEvent(ME_SYSTEM_PRESHUTDOWN);
+ hModulesLoadedEvent = CreateHookableEvent(ME_SYSTEM_MODULESLOADED);
+ hOkToExitEvent = CreateHookableEvent(ME_SYSTEM_OKTOEXIT);
CreateServiceFunction(MS_SYSTEM_FORK_THREAD, ForkThreadService);
CreateServiceFunction(MS_SYSTEM_FORK_THREAD_EX, ForkThreadServiceEx);
@@ -931,9 +601,7 @@ int LoadSystemModule(void)
CreateServiceFunction(MS_SYSTEM_GET_LI, GetListInterface);
CreateServiceFunction(MS_SYSTEM_GET_MMI, GetMemoryManagerInterface);
CreateServiceFunction(MS_SYSTEM_GET_UTFI, GetUtfInterface);
- CreateServiceFunction(MS_SYSTEM_GETEXCEPTFILTER, GetExceptionFilter);
- CreateServiceFunction(MS_SYSTEM_SETEXCEPTFILTER, SetExceptionFilter);
-
- InitPathUtils();
+ CreateServiceFunction(MS_SYSTEM_GETEXCEPTFILTER, srvGetExceptionFilter);
+ CreateServiceFunction(MS_SYSTEM_SETEXCEPTFILTER, srvSetExceptionFilter);
return 0;
}
diff --git a/src/core/miranda.h b/src/core/miranda.h
index 40329e5013..7dfba64a66 100644
--- a/src/core/miranda.h
+++ b/src/core/miranda.h
@@ -115,51 +115,13 @@ extern LPFN_WSAADDRESSTOSTRINGA MyWSAAddressToString;
void PushFileEvent(HANDLE hContact, HANDLE hdbe, LPARAM lParam);
-/**** memory.cpp ***********************************************************************/
-
-#ifdef _STATIC
-void* mir_alloc(size_t);
-void* mir_calloc(size_t);
-void* mir_realloc(void* ptr, size_t);
-void mir_free(void* ptr);
-char* mir_strdup(const char* str);
-WCHAR* mir_wstrdup(const WCHAR* str);
-char* mir_strndup(const char* str, size_t len);
-
-int mir_snprintf(char *buffer, size_t count, const char* fmt, ...);
-int mir_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...);
-int mir_vsnprintf(char *buffer, size_t count, const char* fmt, va_list va);
-int mir_vsntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, va_list va);
-
-WCHAR* mir_a2u_cp(const char* src, int codepage);
-WCHAR* mir_a2u(const char* src);
-char* mir_u2a_cp(const wchar_t* src, int codepage);
-char* mir_u2a(const wchar_t* src);
-#endif
-
/**** miranda.cpp **********************************************************************/
-extern HINSTANCE hMirandaInst;
+extern HINSTANCE hInst;
extern HANDLE hOkToExitEvent, hModulesLoadedEvent;
-extern pfnExceptionFilter pMirandaExceptFilter;
-
-/**** modules.cpp **********************************************************************/
-
-int CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wParam, LPARAM lParam);
-void KillModuleEventHooks(HINSTANCE);
-void KillModuleServices(HINSTANCE);
-
-void KillObjectEventHooks(void* pObject);
-void KillObjectServices(void* pObject);
-void KillObjectThreads(void* pObject);
/**** utf.cpp **************************************************************************/
-char* Utf8Decode(char* str, wchar_t** ucs2);
-char* Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2);
-
-wchar_t* Utf8DecodeUcs2(const char* str);
-
__forceinline char* Utf8DecodeA(const char* src)
{
char* tmp = mir_strdup(src);
@@ -167,62 +129,12 @@ __forceinline char* Utf8DecodeA(const char* src)
return tmp;
}
-
-char* Utf8Encode(const char* str);
-char* Utf8EncodeCP(const char* src, int codepage);
-
-char* Utf8EncodeUcs2(const wchar_t* str);
-
-int Ucs2toUtf8Len(const wchar_t *src);
-
-#define Utf8DecodeT Utf8DecodeUcs2
-#define Utf8EncodeT Utf8EncodeUcs2
-
-/**** langpack.cpp *********************************************************************/
-
-int LangPackGetDefaultCodePage();
-int LangPackGetDefaultLocale();
-TCHAR* LangPackPcharToTchar(const char* pszStr);
-char* LangPackTranslateString(struct LangPackMuuid* pUuid, const char *szEnglish, const int W);
-TCHAR* LangPackTranslateStringT(int hLangpack, const TCHAR* tszEnglish);
-
-unsigned int __fastcall hash(const void * key, unsigned int len);
-
-#pragma optimize("gt", on)
-__inline unsigned int hashstr(const char * key)
-{
- if (key == NULL) return 0;
- const unsigned int len = (unsigned int)strlen((const char*)key);
- return hash(key, len);
-}
-
-__inline unsigned int hashstr(const wchar_t * key)
-{
- if (key == NULL) return 0;
- const unsigned int len = (unsigned int)wcslen((const wchar_t*)key);
- return hash(key, len * sizeof(wchar_t));
-}
#pragma optimize("", on)
/**** options.cpp **********************************************************************/
HTREEITEM FindNamedTreeItemAtRoot(HWND hwndTree, const TCHAR* name);
-/**** path.cpp *************************************************************************/
-
-void CreatePathToFile(char* wszFilePath);
-void CreatePathToFileW(WCHAR* wszFilePath);
-
-int CreateDirectoryTree(const char *szDir);
-int CreateDirectoryTreeW(const WCHAR *szDir);
-
-int pathToAbsolute(const char *pSrc, char *pOut, char* base);
-int pathToAbsoluteW(const TCHAR *pSrc, TCHAR *pOut, TCHAR* base);
-
-#define pathToAbsoluteT pathToAbsoluteW
-#define CreatePathToFileT CreatePathToFileW
-#define CreateDirectoryTreeT CreateDirectoryTreeW
-
/**** skin2icons.cpp *******************************************************************/
HANDLE IcoLib_AddNewIcon(int hLangpack, SKINICONDESC* sid);
@@ -294,25 +206,10 @@ void OpenAccountOptions(PROTOACCOUNT* pa);
void LoadDbAccounts(void);
void WriteDbAccounts(void);
-INT_PTR CallProtoServiceInt(HANDLE hContact, const char* szModule, const char* szService, WPARAM, LPARAM);
-INT_PTR CallContactService(HANDLE hContact, const char *szProtoService, WPARAM, LPARAM);
-
-__inline static INT_PTR CallProtoService(const char* szModule, const char* szService, WPARAM wParam, LPARAM lParam)
-{
- return CallProtoServiceInt(NULL, szModule, szService, wParam, lParam);
-}
+INT_PTR CallProtoServiceInt(HANDLE hContact, const char* szModule, const char* szService, WPARAM wParam, LPARAM lParam);
/**** utils.cpp ************************************************************************/
-char* __fastcall rtrim(char* str);
-TCHAR* __fastcall rtrim(TCHAR* str);
-char* __fastcall ltrim(char* str);
-char* __fastcall ltrimp(char* str);
-__inline char* lrtrim(char* str) { return ltrim(rtrim(str)); };
-__inline char* lrtrimp(char* str) { return ltrimp(rtrim(str)); };
-
-bool __fastcall wildcmp(char * name, char * mask);
-
void HotkeyToName(TCHAR *buf, int size, BYTE shift, BYTE key);
WORD GetHotkeyValue(INT_PTR idHotkey);
@@ -350,5 +247,3 @@ public:
#define StrConvTu(x) x
#define StrConvA(x) StrConvAT(x)
#define StrConvU(x) x
-
-
diff --git a/src/core/modules.cpp b/src/core/modules.cpp
index ba846d0fd4..11e93f1354 100644
--- a/src/core/modules.cpp
+++ b/src/core/modules.cpp
@@ -2,7 +2,7 @@
Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 Miranda ICQ/IM project,
+Copyright 2000-2009 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
@@ -11,7 +11,7 @@ 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,
+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.
@@ -23,66 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
#include <m_plugins.h>
-// list of hooks
-
-static int compareHooks(const THook* p1, const THook* p2)
-{
- return strcmp(p1->name, p2->name);
-}
-
-static LIST<THook> hooks(50, compareHooks);
-
-struct THookToMainThreadItem
-{
- THook* hook;
- HANDLE hDoneEvent;
- WPARAM wParam;
- LPARAM lParam;
- int result;
-};
-
-// list of services
-
-struct TService
-{
- DWORD nameHash;
- HINSTANCE hOwner;
- union {
- MIRANDASERVICE pfnService;
- MIRANDASERVICEPARAM pfnServiceParam;
- MIRANDASERVICEOBJ pfnServiceObj;
- MIRANDASERVICEOBJPARAM pfnServiceObjParam;
- };
- int flags;
- LPARAM lParam;
- void* object;
- char name[1];
-};
-
-LIST<TService> services(100, NumericKeySortT);
-
-typedef struct
-{
- HANDLE hDoneEvent;
- WPARAM wParam;
- LPARAM lParam;
- int result;
- const char *name;
-}
- TServiceToMainThreadItem;
-
// other static variables
static BOOL bServiceMode = FALSE;
-static CRITICAL_SECTION csHooks, csServices;
static DWORD mainThreadId;
-static int hookId = 1;
static HANDLE hMainThread;
static HANDLE hMissingService;
-static THook *pLastHook = NULL;
-
-HINSTANCE GetInstByAddress(void* codePtr);
-
-void LangPackDropUnusedItems(void);
void ParseCommandLine(); // core: IDD_WAITRESTART
int LoadSystemModule(void); // core: m_system.h services
@@ -134,7 +79,6 @@ void UnloadClcModule(void);
void UnloadContactListModule(void);
void UnloadEventsModule(void);
void UnloadIdleModule(void);
-void UnloadLangPackModule(void);
void UnloadSslModule(void);
void UnloadNetlibModule(void);
void UnloadNewPlugins(void);
@@ -236,576 +180,4 @@ void UnloadDefaultModules(void)
UnloadUpdateNotifyModule();
UnloadNetlibModule();
UnloadSslModule();
- UnloadLangPackModule();
-}
-
-int InitialiseModularEngine(void)
-{
- InitializeCriticalSection(&csHooks);
- InitializeCriticalSection(&csServices);
-
- mainThreadId=GetCurrentThreadId();
- DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, 0, FALSE, DUPLICATE_SAME_ACCESS);
-
- hMissingService = CreateHookableEvent(ME_SYSTEM_MISSINGSERVICE);
- return 0;
-}
-
-void DestroyModularEngine(void)
-{
- int i;
- THook* p;
- EnterCriticalSection(&csHooks);
- for (i=0; i < hooks.getCount(); i++) {
- p = hooks[i];
- if (p->subscriberCount)
- mir_free(p->subscriber);
- DeleteCriticalSection(&p->csHook);
- mir_free(p);
- }
- hooks.destroy();
- LeaveCriticalSection(&csHooks);
- DeleteCriticalSection(&csHooks);
-
- EnterCriticalSection(&csServices);
- for (i=0; i < services.getCount(); i++)
- mir_free(services[i]);
-
- services.destroy();
- LeaveCriticalSection(&csServices);
- DeleteCriticalSection(&csServices);
- CloseHandle(hMainThread);
-}
-
-///////////////////////////////HOOKS
-
-HANDLE CreateHookableEvent(const char *name)
-{
- THook* ret;
- int idx;
-
- if (name == NULL)
- return NULL;
-
- EnterCriticalSection(&csHooks);
- if ((idx = hooks.getIndex((THook*)name)) != -1) {
- LeaveCriticalSection(&csHooks);
- return NULL;
- }
-
- ret = (THook*)mir_alloc(sizeof(THook));
- strncpy(ret->name, name, sizeof(ret->name)); ret->name[ MAXMODULELABELLENGTH-1 ] = 0;
- ret->id = hookId++;
- ret->subscriberCount = 0;
- ret->subscriber = NULL;
- ret->pfnHook = NULL;
- InitializeCriticalSection(&ret->csHook);
- hooks.insert(ret);
-
- LeaveCriticalSection(&csHooks);
- return (HANDLE)ret;
-}
-
-int DestroyHookableEvent(HANDLE hEvent)
-{
- int idx;
- THook* p;
-
- EnterCriticalSection(&csHooks);
- if (pLastHook == (THook*)hEvent)
- pLastHook = NULL;
-
- if ((idx = hooks.getIndex((THook*)hEvent)) == -1) {
- LeaveCriticalSection(&csHooks);
- return 1;
- }
- p = hooks[idx];
- if (p->subscriberCount) {
- mir_free(p->subscriber);
- p->subscriber = NULL;
- p->subscriberCount = 0;
- }
- hooks.remove(idx);
- DeleteCriticalSection(&p->csHook);
- mir_free(p);
-
- LeaveCriticalSection(&csHooks);
- return 0;
-}
-
-int SetHookDefaultForHookableEvent(HANDLE hEvent, MIRANDAHOOK pfnHook)
-{
- THook* p = (THook*)hEvent;
-
- EnterCriticalSection(&csHooks);
- if (hooks.getIndex(p) != -1)
- p->pfnHook = pfnHook;
- LeaveCriticalSection(&csHooks);
- return 0;
-}
-
-int CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wParam, LPARAM lParam)
-{
- int returnVal = 0;
- THook* p = (THook*)hEvent;
- if (p == NULL)
- return -1;
-
- EnterCriticalSection(&p->csHook);
- for (int i = 0; i < p->subscriberCount; i++) {
- THookSubscriber* s = &p->subscriber[i];
- if (s->hOwner != hInst)
- continue;
-
- switch (s->type) {
- case 1: returnVal = s->pfnHook(wParam, lParam); break;
- case 2: returnVal = s->pfnHookParam(wParam, lParam, s->lParam); break;
- case 3: returnVal = s->pfnHookObj(s->object, wParam, lParam); break;
- case 4: returnVal = s->pfnHookObjParam(s->object, wParam, lParam, s->lParam); break;
- case 5: returnVal = SendMessage(s->hwnd, s->message, wParam, lParam); break;
- default: continue;
- }
- if (returnVal)
- break;
- }
-
- if (p->subscriberCount == 0 && p->pfnHook != 0)
- returnVal = p->pfnHook(wParam, lParam);
-
- LeaveCriticalSection(&p->csHook);
- return returnVal;
-}
-
-int CallHookSubscribers(HANDLE hEvent, WPARAM wParam, LPARAM lParam)
-{
- int returnVal = 0;
- THook* p = (THook*)hEvent;
- if (p == NULL)
- return -1;
-
- EnterCriticalSection(&p->csHook);
-
- // NOTE: We've got the critical section while all this lot are called. That's mostly safe, though.
- for (int i = 0; i < p->subscriberCount; i++) {
- THookSubscriber* s = &p->subscriber[i];
- switch (s->type) {
- case 1: returnVal = s->pfnHook(wParam, lParam); break;
- case 2: returnVal = s->pfnHookParam(wParam, lParam, s->lParam); break;
- case 3: returnVal = s->pfnHookObj(s->object, wParam, lParam); break;
- case 4: returnVal = s->pfnHookObjParam(s->object, wParam, lParam, s->lParam); break;
- case 5: returnVal = SendMessage(s->hwnd, s->message, wParam, lParam); break;
- default: continue;
- }
- if (returnVal)
- break;
- }
-
- // check for no hooks and call the default hook if any
- if (p->subscriberCount == 0 && p->pfnHook != 0)
- returnVal = p->pfnHook(wParam, lParam);
-
- LeaveCriticalSection(&p->csHook);
- return returnVal;
-}
-
-static int checkHook(HANDLE hHook)
-{
- if (hHook == NULL)
- return -1;
-
- EnterCriticalSection(&csHooks);
- if (pLastHook != hHook || !pLastHook) {
- if (hooks.getIndex((THook*)hHook) == -1) {
- LeaveCriticalSection(&csHooks);
- return -1;
- }
- pLastHook = (THook*)hHook;
- }
- LeaveCriticalSection(&csHooks);
- return 0;
-}
-
-static void CALLBACK HookToMainAPCFunc(ULONG_PTR dwParam)
-{
- THookToMainThreadItem* item = (THookToMainThreadItem*)dwParam;
-
- if (checkHook(item->hook) == -1)
- item->result = -1;
- else
- item->result = CallHookSubscribers(item->hook, item->wParam, item->lParam);
- SetEvent(item->hDoneEvent);
-}
-
-int NotifyEventHooks(HANDLE hEvent, WPARAM wParam, LPARAM lParam)
-{
- extern HWND hAPCWindow;
-
- if ( GetCurrentThreadId() != mainThreadId) {
- THookToMainThreadItem item;
-
- item.hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- item.hook = (THook*)hEvent;
- item.wParam = wParam;
- item.lParam = lParam;
-
- QueueUserAPC(HookToMainAPCFunc, hMainThread, (ULONG_PTR)&item);
- PostMessage(hAPCWindow, WM_NULL, 0, 0); // let it process APC even if we're in a common dialog
- WaitForSingleObject(item.hDoneEvent, INFINITE);
- CloseHandle(item.hDoneEvent);
- return item.result;
- }
-
- return (checkHook(hEvent) == -1) ? -1 : CallHookSubscribers(hEvent, wParam, lParam);
-}
-
-static HANDLE HookEventInt(int type, const char* name, MIRANDAHOOK hookProc, void* object, LPARAM lParam)
-{
- int idx;
- THook* p;
- HANDLE ret;
-
- EnterCriticalSection(&csHooks);
- if ((idx = hooks.getIndex((THook*)name)) == -1) {
- #ifdef _DEBUG
- OutputDebugStringA("Attempt to hook: \t");
- OutputDebugStringA(name);
- OutputDebugStringA("\n");
- #endif
- LeaveCriticalSection(&csHooks);
- return NULL;
- }
-
- p = hooks[ idx ];
- p->subscriber = (THookSubscriber*)mir_realloc(p->subscriber, sizeof(THookSubscriber)*(p->subscriberCount+1));
- p->subscriber[ p->subscriberCount ].type = type;
- p->subscriber[ p->subscriberCount ].pfnHook = hookProc;
- p->subscriber[ p->subscriberCount ].object = object;
- p->subscriber[ p->subscriberCount ].lParam = lParam;
- p->subscriber[ p->subscriberCount ].hOwner = GetInstByAddress(hookProc);
- p->subscriberCount++;
-
- ret = (HANDLE)((p->id << 16) | p->subscriberCount);
- LeaveCriticalSection(&csHooks);
- return ret;
-}
-
-HANDLE HookEvent(const char* name, MIRANDAHOOK hookProc)
-{
- return HookEventInt(1, name, hookProc, 0, 0);
-}
-
-HANDLE HookEventParam(const char* name, MIRANDAHOOKPARAM hookProc, LPARAM lParam)
-{
- return HookEventInt(2, name, (MIRANDAHOOK)hookProc, 0, lParam);
-}
-
-HANDLE HookEventObj(const char* name, MIRANDAHOOKOBJ hookProc, void* object)
-{
- return HookEventInt(3, name, (MIRANDAHOOK)hookProc, object, 0);
-}
-
-HANDLE HookEventObjParam(const char* name, MIRANDAHOOKOBJPARAM hookProc, void* object, LPARAM lParam)
-{
- return HookEventInt(4, name, (MIRANDAHOOK)hookProc, object, lParam);
-}
-
-HANDLE HookEventMessage(const char* name, HWND hwnd, UINT message)
-{
- int idx;
- THook* p;
- HANDLE ret;
-
- EnterCriticalSection(&csHooks);
- if ((idx = hooks.getIndex((THook*)name)) == -1) {
- #ifdef _DEBUG
- MessageBoxA(NULL, "Attempt to hook non-existant event", name, MB_OK);
- #endif
- LeaveCriticalSection(&csHooks);
- return NULL;
- }
-
- p = hooks[ idx ];
- p->subscriber = (THookSubscriber*)mir_realloc(p->subscriber, sizeof(THookSubscriber)*(p->subscriberCount+1));
- p->subscriber[ p->subscriberCount ].type = 5;
- p->subscriber[ p->subscriberCount ].hwnd = hwnd;
- p->subscriber[ p->subscriberCount ].message = message;
- p->subscriberCount++;
-
- ret = (HANDLE)((p->id << 16) | p->subscriberCount);
- LeaveCriticalSection(&csHooks);
- return ret;
-}
-
-int UnhookEvent(HANDLE hHook)
-{
- int i;
- THook* p = NULL;
-
- int hookId = (int)hHook >> 16;
- int subscriberId = ((int)hHook & 0xFFFF) - 1;
-
- if (hHook == NULL) return 0;
-
- EnterCriticalSection(&csHooks);
- for (i = 0; i < hooks.getCount(); i++) {
- if (hooks[i]->id == hookId) {
- p = hooks[i];
- break;
- } }
-
- if (p == NULL) {
- LeaveCriticalSection(&csHooks);
- return 1;
- }
-
- if (subscriberId >= p->subscriberCount || subscriberId < 0) {
- LeaveCriticalSection(&csHooks);
- return 1;
- }
-
- p->subscriber[subscriberId].type = 0;
- p->subscriber[subscriberId].pfnHook = NULL;
- p->subscriber[subscriberId].hOwner = NULL;
- while (p->subscriberCount && p->subscriber[p->subscriberCount-1].type == 0)
- p->subscriberCount--;
- if (p->subscriberCount == 0) {
- if (p->subscriber) mir_free(p->subscriber);
- p->subscriber = NULL;
- }
- LeaveCriticalSection(&csHooks);
- return 0;
-}
-
-void KillModuleEventHooks(HINSTANCE hInst)
-{
- int i, j;
-
- EnterCriticalSection(&csHooks);
- for (i = hooks.getCount()-1; i >= 0; i--) {
- if (hooks[i]->subscriberCount == 0)
- continue;
-
- for (j = hooks[i]->subscriberCount-1; j >= 0; j--) {
- if (hooks[i]->subscriber[j].hOwner == hInst) {
- char szModuleName[ MAX_PATH ];
- GetModuleFileNameA(hooks[i]->subscriber[j].hOwner, szModuleName, sizeof(szModuleName));
- Netlib_Logf(NULL, "A hook %08x for event '%s' was abnormally deleted because module '%s' didn't released it",
- hooks[i]->subscriber[j].pfnHook, hooks[i]->name, szModuleName);
- UnhookEvent((HANDLE)((hooks[i]->id << 16) + j + 1));
- if (hooks[i]->subscriberCount == 0)
- break;
- } } }
-
- LeaveCriticalSection(&csHooks);
-}
-
-void KillObjectEventHooks(void* pObject)
-{
- int i, j;
-
- EnterCriticalSection(&csHooks);
- for (i = hooks.getCount()-1; i >= 0; i--) {
- if (hooks[i]->subscriberCount == 0)
- continue;
-
- for (j = hooks[i]->subscriberCount-1; j >= 0; j--) {
- if (hooks[i]->subscriber[j].object == pObject) {
- UnhookEvent((HANDLE)((hooks[i]->id << 16) + j + 1));
- if (hooks[i]->subscriberCount == 0)
- break;
- } } }
-
- LeaveCriticalSection(&csHooks);
-}
-
-/////////////////////SERVICES
-
-static __inline TService* FindServiceByName(const char *name)
-{
- unsigned hash = hashstr(name);
- return services.find((TService*)&hash);
-}
-
-static HANDLE CreateServiceInt(int type, const char *name, MIRANDASERVICE serviceProc, void* object, LPARAM lParam)
-{
- if (name == NULL)
- return NULL;
-
- TService tmp;
- tmp.nameHash = hashstr(name);
-
- EnterCriticalSection(&csServices);
-
- if (services.getIndex(&tmp) != -1) {
- LeaveCriticalSection(&csServices);
- return NULL;
- }
-
- TService* p = (TService*)mir_alloc(sizeof(*p) + strlen(name));
- strcpy(p->name, name);
- p->nameHash = tmp.nameHash;
- p->pfnService = serviceProc;
- p->hOwner = GetInstByAddress(serviceProc);
- p->flags = type;
- p->lParam = lParam;
- p->object = object;
- services.insert(p);
-
- LeaveCriticalSection(&csServices);
- return (HANDLE)tmp.nameHash;
-}
-
-HANDLE CreateServiceFunction(const char *name, MIRANDASERVICE serviceProc)
-{
- return CreateServiceInt(0, name, serviceProc, 0, 0);
-}
-
-HANDLE CreateServiceFunctionParam(const char *name, MIRANDASERVICEPARAM serviceProc, LPARAM lParam)
-{
- return CreateServiceInt(1, name, (MIRANDASERVICE)serviceProc, 0, lParam);
-}
-
-HANDLE CreateServiceFunctionObj(const char *name, MIRANDASERVICEOBJ serviceProc, void* object)
-{
- return CreateServiceInt(2, name, (MIRANDASERVICE)serviceProc, object, 0);
-}
-
-HANDLE CreateServiceFunctionObjParam(const char *name, MIRANDASERVICEOBJPARAM serviceProc, void* object, LPARAM lParam)
-{
- return CreateServiceInt(3, name, (MIRANDASERVICE)serviceProc, object, lParam);
-}
-
-int DestroyServiceFunction(HANDLE hService)
-{
- int idx;
-
- EnterCriticalSection(&csServices);
- if ((idx = services.getIndex((TService*)&hService)) != -1) {
- mir_free(services[idx]);
- services.remove(idx);
- }
-
- LeaveCriticalSection(&csServices);
- return 0;
-}
-
-int ServiceExists(const char *name)
-{
- if (name == NULL)
- return FALSE;
-
- EnterCriticalSection(&csServices);
- int ret = FindServiceByName(name) != NULL;
- LeaveCriticalSection(&csServices);
- return ret;
-}
-
-INT_PTR CallService(const char *name, WPARAM wParam, LPARAM lParam)
-{
- #ifdef _DEBUG
- if (name == NULL) {
- MessageBoxA(0, "Someone tried to CallService(NULL, ..) see stack trace for details", "", 0);
- DebugBreak();
- return CALLSERVICE_NOTFOUND;
- }
- #else
- if (name == NULL) return CALLSERVICE_NOTFOUND;
- #endif
-
- EnterCriticalSection(&csServices);
- TService *pService = FindServiceByName(name);
- if (pService == NULL) {
- LeaveCriticalSection(&csServices);
- #ifdef _DEBUG
- //MessageBoxA(NULL, "Attempt to call non-existant service", name, MB_OK);
- OutputDebugStringA("Missing service called: \t");
- OutputDebugStringA(name);
- OutputDebugStringA("\n");
- #endif
-/* { MISSING_SERVICE_PARAMS params = { name, wParam, lParam };
- int result = NotifyEventHooks(hMissingService, 0, (LPARAM)&params);
- if (result != 0)
- return params.lParam;
- } */
- return CALLSERVICE_NOTFOUND;
- }
-
- MIRANDASERVICE pfnService = pService->pfnService;
- int flags = pService->flags;
- LPARAM fnParam = pService->lParam;
- void* object = pService->object;
- LeaveCriticalSection(&csServices);
- switch(flags) {
- case 1: return ((MIRANDASERVICEPARAM)pfnService)(wParam, lParam, fnParam);
- case 2: return ((MIRANDASERVICEOBJ)pfnService)(object, wParam, lParam);
- case 3: return ((MIRANDASERVICEOBJPARAM)pfnService)(object, wParam, lParam, fnParam);
- default: return pfnService(wParam, lParam);
-} }
-
-static void CALLBACK CallServiceToMainAPCFunc(ULONG_PTR dwParam)
-{
- TServiceToMainThreadItem *item = (TServiceToMainThreadItem*) dwParam;
- item->result = CallService(item->name, item->wParam, item->lParam);
- SetEvent(item->hDoneEvent);
-}
-
-INT_PTR CallServiceSync(const char *name, WPARAM wParam, LPARAM lParam)
-{
- extern HWND hAPCWindow;
-
- if (name == NULL) return CALLSERVICE_NOTFOUND;
- // the service is looked up within the main thread, since the time it takes
- // for the APC queue to clear the service being called maybe removed.
- // even thou it may exists before the call, the critsec can't be locked between calls.
- if (GetCurrentThreadId() != mainThreadId) {
- TServiceToMainThreadItem item;
- item.wParam = wParam;
- item.lParam = lParam;
- item.name = name;
- item.hDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- QueueUserAPC(CallServiceToMainAPCFunc, hMainThread, (ULONG_PTR) &item);
- PostMessage(hAPCWindow, WM_NULL, 0, 0); // let this get processed in its own time
- WaitForSingleObject(item.hDoneEvent, INFINITE);
- CloseHandle(item.hDoneEvent);
- return item.result;
- }
-
- return CallService(name, wParam, lParam);
-}
-
-int CallFunctionAsync(void (__stdcall *func)(void *), void *arg)
-{
- extern HWND hAPCWindow;
- int r = QueueUserAPC((void (__stdcall *)(ULONG_PTR))func, hMainThread, (ULONG_PTR)arg);
- PostMessage(hAPCWindow, WM_NULL, 0, 0);
- return r;
-}
-
-void KillModuleServices(HINSTANCE hInst)
-{
- int i;
-
- EnterCriticalSection(&csServices);
- for (i = services.getCount()-1; i >= 0; i--) {
- if (services[i]->hOwner == hInst) {
- char szModuleName[ MAX_PATH ];
- GetModuleFileNameA(services[i]->hOwner, szModuleName, sizeof(szModuleName));
- Netlib_Logf(NULL, "A service function '%s' was abnormally deleted because module '%s' didn't released it",
- services[i]->name, szModuleName);
- DestroyServiceFunction((HANDLE)services[i]->nameHash);
- } }
-
- LeaveCriticalSection(&csServices);
-}
-
-void KillObjectServices(void* pObject)
-{
- int i;
-
- EnterCriticalSection(&csServices);
- for (i = services.getCount()-1; i >= 0; i--)
- if (services[i]->object == pObject)
- DestroyServiceFunction((HANDLE)services[i]->nameHash);
-
- LeaveCriticalSection(&csServices);
}
diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters
index a0ba3df139..ce44b856ae 100644
--- a/src/miranda32_10.vcxproj.filters
+++ b/src/miranda32_10.vcxproj.filters
@@ -219,18 +219,9 @@
<ClInclude Include="core\commonheaders.h">
<Filter>Core</Filter>
</ClInclude>
- <ClInclude Include="core\forkthread.h">
- <Filter>Core</Filter>
- </ClInclude>
<ClInclude Include="core\miranda.h">
<Filter>Core</Filter>
</ClInclude>
- <ClInclude Include="core\modules.h">
- <Filter>Core</Filter>
- </ClInclude>
- <ClInclude Include="modules\database\dblists.h">
- <Filter>Modules\database</Filter>
- </ClInclude>
<ClInclude Include="modules\database\profilemanager.h">
<Filter>Modules\database</Filter>
</ClInclude>
@@ -323,9 +314,6 @@
<ClCompile Include="core\commonheaders.cpp">
<Filter>Core</Filter>
</ClCompile>
- <ClCompile Include="core\memory.cpp">
- <Filter>Core</Filter>
- </ClCompile>
<ClCompile Include="core\miranda.cpp">
<Filter>Core</Filter>
</ClCompile>
@@ -350,9 +338,6 @@
<ClCompile Include="modules\database\dbini.cpp">
<Filter>Modules\database</Filter>
</ClCompile>
- <ClCompile Include="modules\database\dblists.cpp">
- <Filter>Modules\database</Filter>
- </ClCompile>
<ClCompile Include="modules\database\dbutils.cpp">
<Filter>Modules\database</Filter>
</ClCompile>
@@ -380,9 +365,6 @@
<ClCompile Include="modules\ignore\ignore.cpp">
<Filter>Modules\ignore</Filter>
</ClCompile>
- <ClCompile Include="modules\langpack\langpack.cpp">
- <Filter>Modules\langpack</Filter>
- </ClCompile>
<ClCompile Include="modules\langpack\lpservices.cpp">
<Filter>Modules\langpack</Filter>
</ClCompile>
@@ -548,12 +530,6 @@
<ClCompile Include="modules\utils\sha1.cpp">
<Filter>Modules\utils</Filter>
</ClCompile>
- <ClCompile Include="modules\utils\utf.cpp">
- <Filter>Modules\utils</Filter>
- </ClCompile>
- <ClCompile Include="modules\utils\utils.cpp">
- <Filter>Modules\utils</Filter>
- </ClCompile>
<ClCompile Include="modules\utils\windowlist.cpp">
<Filter>Modules\utils</Filter>
</ClCompile>
@@ -701,6 +677,9 @@
<ClCompile Include="modules\json\json.cpp">
<Filter>Modules\json</Filter>
</ClCompile>
+ <ClCompile Include="modules\utils\utils.cpp">
+ <Filter>Modules\utils</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\_blank.ico">
diff --git a/src/modules/addcontact/addcontact.cpp b/src/modules/addcontact/addcontact.cpp
index f1a2e6330d..ce03278281 100644
--- a/src/modules/addcontact/addcontact.cpp
+++ b/src/modules/addcontact/addcontact.cpp
@@ -107,7 +107,7 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp
CheckDlgButton(hdlg, IDC_ADDED, BST_CHECKED);
CheckDlgButton(hdlg, IDC_AUTH, BST_CHECKED);
- DWORD flags = (acs->szProto) ? CallProtoService(acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0) : 0;
+ DWORD flags = (acs->szProto) ? CallProtoServiceInt(NULL,acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0) : 0;
if (flags&PF4_FORCEADDED) { // force you were added requests for this protocol
EnableWindow(GetDlgItem(hdlg, IDC_ADDED), FALSE);
}
@@ -133,7 +133,7 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp
{
case IDC_AUTH:
{
- DWORD flags = CallProtoService(acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0);
+ DWORD flags = CallProtoServiceInt(NULL,acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0);
if (flags & PF4_NOCUSTOMAUTH) {
EnableWindow(GetDlgItem(hdlg, IDC_AUTHREQ), FALSE);
EnableWindow(GetDlgItem(hdlg, IDC_AUTHGB), FALSE);
@@ -154,12 +154,12 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
CallService(MS_DB_EVENT_GET, (WPARAM)acs->handle, (LPARAM)&dbei);
- hContact = (HANDLE)CallProtoService(dbei.szModule, PS_ADDTOLISTBYEVENT, 0, (LPARAM)acs->handle);
+ hContact = (HANDLE)CallProtoServiceInt(NULL,dbei.szModule, PS_ADDTOLISTBYEVENT, 0, (LPARAM)acs->handle);
}
break;
case HANDLE_SEARCHRESULT:
- hContact = (HANDLE)CallProtoService(acs->szProto, PS_ADDTOLIST, 0, (LPARAM)acs->psr);
+ hContact = (HANDLE)CallProtoServiceInt(NULL,acs->szProto, PS_ADDTOLIST, 0, (LPARAM)acs->psr);
break;
case HANDLE_CONTACT:
@@ -188,7 +188,7 @@ INT_PTR CALLBACK AddContactDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp
if (IsDlgButtonChecked(hdlg, IDC_AUTH))
{
- DWORD flags = CallProtoService(acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0);
+ DWORD flags = CallProtoServiceInt(NULL,acs->szProto, PS_GETCAPS, PFLAGNUM_4, 0);
if (flags & PF4_NOCUSTOMAUTH)
CallContactService(hContact, PSS_AUTHREQUESTT, 0, 0);
else
@@ -256,9 +256,9 @@ INT_PTR AddContactDialog(WPARAM wParam, LPARAM lParam)
}
if (wParam)
- DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)wParam, AddContactDlgProc, (LPARAM)acs);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)wParam, AddContactDlgProc, (LPARAM)acs);
else
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)wParam, AddContactDlgProc, (LPARAM)acs);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDCONTACT), (HWND)wParam, AddContactDlgProc, (LPARAM)acs);
return 0;
}
return 1;
diff --git a/src/modules/autoaway/autoaway.cpp b/src/modules/autoaway/autoaway.cpp
index 767800d014..764cd3e965 100644
--- a/src/modules/autoaway/autoaway.cpp
+++ b/src/modules/autoaway/autoaway.cpp
@@ -41,8 +41,8 @@ static int AutoAwayEvent(WPARAM, LPARAM lParam)
if ( !Proto_IsAccountEnabled(pa) || Proto_IsAccountLocked(pa)) continue;
- int statusbits = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
- int currentstatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
+ int statusbits = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0);
+ int currentstatus = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0);
int status = mii.aaStatus;
if ( !(statusbits & Proto_Status2Flag(status))) {
// the protocol doesnt support the given status
diff --git a/src/modules/button/button.cpp b/src/modules/button/button.cpp
index 756740eefa..8889af9bf5 100644
--- a/src/modules/button/button.cpp
+++ b/src/modules/button/button.cpp
@@ -495,7 +495,7 @@ static LRESULT CALLBACK MButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, L
else {
TTooltips *ptt = (TTooltips*)mir_alloc(sizeof(TTooltips));
ptt->ThreadId = tt.ThreadId;
- ptt->hwnd = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), TTS_ALWAYSTIP, 0, 0, 0, 0, NULL, NULL, hMirandaInst, NULL);
+ ptt->hwnd = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), TTS_ALWAYSTIP, 0, 0, 0, 0, NULL, NULL, hInst, NULL);
lToolTips.insert(ptt);
bct->hwndToolTips = ptt->hwnd;
}
diff --git a/src/modules/clist/clc.cpp b/src/modules/clist/clc.cpp
index d68ad5a9b8..8a50469245 100644
--- a/src/modules/clist/clc.cpp
+++ b/src/modules/clist/clc.cpp
@@ -99,7 +99,7 @@ static int ClcSettingChanged(WPARAM wParam, LPARAM lParam)
// something is being written to a protocol module
if ( !strcmp(szProto, cws->szModule)) {
// was a unique setting key written?
- id = (char *) CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ id = (char *) CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if ((INT_PTR) id != CALLSERVICE_NOTFOUND && id != NULL && !strcmp(id, cws->szSetting))
cli.pfnClcBroadcast(INTM_PROTOCHANGED, wParam, lParam);
}
@@ -129,7 +129,7 @@ static int ClcAccountsChanged(WPARAM, LPARAM)
for (i = 0, cnt = 0; i < accounts.getCount(); ++i) {
if (Proto_IsAccountEnabled(accounts[i])) {
cli.clcProto[cnt].szProto = accounts[i]->szModuleName;
- cli.clcProto[cnt].dwStatus = CallProtoService(accounts[i]->szModuleName, PS_GETSTATUS, 0, 0);
+ cli.clcProto[cnt].dwStatus = CallProtoServiceInt(NULL,accounts[i]->szModuleName, PS_GETSTATUS, 0, 0);
++cnt;
}
}
diff --git a/src/modules/clist/clcfiledrop.cpp b/src/modules/clist/clcfiledrop.cpp
index 8af901284b..5c64082215 100644
--- a/src/modules/clist/clcfiledrop.cpp
+++ b/src/modules/clist/clcfiledrop.cpp
@@ -82,7 +82,7 @@ static HANDLE HContactFromPoint(HWND hwnd, struct ClcData *dat, int x, int y, in
szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) contact->hContact, 0);
if (szProto == NULL)
return NULL;
- protoCaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ protoCaps = CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0);
if ( !(protoCaps & PF1_FILESEND))
return NULL;
if (ID_STATUS_OFFLINE == DBGetContactSettingWord(contact->hContact, szProto, "Status", ID_STATUS_OFFLINE))
diff --git a/src/modules/clist/clistmenus.cpp b/src/modules/clist/clistmenus.cpp
index f05f9c13ae..dc9c4a69e2 100644
--- a/src/modules/clist/clistmenus.cpp
+++ b/src/modules/clist/clistmenus.cpp
@@ -171,8 +171,8 @@ int GetAverageMode(int* pNetProtoCount = NULL)
netProtoCount++;
if (averageMode == 0)
- averageMode = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
- else if (averageMode > 0 && averageMode != CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0)) {
+ averageMode = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0);
+ else if (averageMode > 0 && averageMode != CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0)) {
averageMode = -1;
if (pNetProtoCount == NULL) break;
}
@@ -449,12 +449,12 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM)
StatusMenuExecParam *smep = (StatusMenuExecParam*)pcpp->MenuItemOwnerData;
if (smep && !smep->status && smep->custom) {
if (wildcmp(smep->svc, "*XStatus*")) {
- int XStatus = CallProtoService(smep->proto, "/GetXStatus", 0, 0);
+ int XStatus = CallProtoServiceInt(NULL,smep->proto, "/GetXStatus", 0, 0);
char buf[255];
mir_snprintf(buf, sizeof(buf), "*XStatus%d", XStatus);
- bool check = wildcmp(smep->svc, buf);
- bool reset = wildcmp(smep->svc, "*XStatus0");
+ bool check = wildcmp(smep->svc, buf) != 0;
+ bool reset = wildcmp(smep->svc, "*XStatus0") != 0;
if (check)
timi->mi.flags |= CMIF_CHECKED;
@@ -467,7 +467,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM)
CLISTMENUITEM mi2 = {0};
mi2.cbSize = sizeof(mi2);
mi2.flags = CMIM_NAME | CMIF_TCHAR;
- mi2.ptszName = LangPackTranslateStringT(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.ptszName : LPGENT("Custom status"));
+ mi2.ptszName = TranslateTH(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.ptszName : LPGENT("Custom status"));
timiParent = MO_GetIntMenuItem(timi->mi.root);
@@ -510,7 +510,7 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM)
} } }
}
else if (smep && smep->status && !smep->custom) {
- int curProtoStatus = (smep->proto) ? CallProtoService(smep->proto, PS_GETSTATUS, 0, 0) : GetAverageMode();
+ int curProtoStatus = (smep->proto) ? CallProtoServiceInt(NULL,smep->proto, PS_GETSTATUS, 0, 0) : GetAverageMode();
if (smep->status == curProtoStatus)
timi->mi.flags |= CMIF_CHECKED;
else
@@ -531,13 +531,13 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM)
if (Proto_GetAccount(prot) == NULL)
return TRUE;
- if ((curProtoStatus = CallProtoService(prot, PS_GETSTATUS, 0, 0)) == CALLSERVICE_NOTFOUND)
+ if ((curProtoStatus = CallProtoServiceInt(NULL,prot, PS_GETSTATUS, 0, 0)) == CALLSERVICE_NOTFOUND)
curProtoStatus = 0;
if (curProtoStatus >= ID_STATUS_OFFLINE && curProtoStatus < ID_STATUS_IDLE)
timi->mi.hIcon = LoadSkinProtoIcon(prot, curProtoStatus);
else {
- timi->mi.hIcon=(HICON)CallProtoService(prot, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
+ timi->mi.hIcon=(HICON)CallProtoServiceInt(NULL,prot, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
if (timi->mi.hIcon == (HICON)CALLSERVICE_NOTFOUND)
timi->mi.hIcon = NULL;
else
@@ -574,7 +574,7 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM)
int i=(DBGetContactSettingByte(NULL, prot, "LockMainStatus", 0)?0:1);
DBWriteContactSettingByte(NULL, prot, "LockMainStatus", (BYTE)i);
- CallProtoService(smep->proto, PS_GETNAME, (WPARAM)SIZEOF(szHumanName), (LPARAM)szHumanName);
+ CallProtoServiceInt(NULL,smep->proto, PS_GETNAME, (WPARAM)SIZEOF(szHumanName), (LPARAM)szHumanName);
pimi = MO_GetIntMenuItem((HGENMENU)smep->protoindex);
PMO_IntMenuItem root = (PMO_IntMenuItem)pimi->mi.root;
mir_free(pimi->mi.pszName);
@@ -874,7 +874,7 @@ void RebuildMenuOrder(void)
tmi.cbSize = sizeof(tmi);
tmi.flags = CMIF_TCHAR | CMIF_ROOTHANDLE | CMIF_KEEPUNTRANSLATED;
tmi.position = pos++;
- tmi.hIcon = ic = (HICON)CallProtoService(pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
+ tmi.hIcon = ic = (HICON)CallProtoServiceInt(NULL,pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
if (Proto_IsAccountLocked(pa) && cli.bDisplayLocked) {
mir_sntprintf(tbuf, SIZEOF(tbuf), LPGENT("%s (locked)"), pa->tszAccountName);
diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp
index 26ad72ae7c..84d587db97 100644
--- a/src/modules/clist/clistmod.cpp
+++ b/src/modules/clist/clistmod.cpp
@@ -146,7 +146,7 @@ static int ProtocolAck(WPARAM, LPARAM lParam)
if ((int) ack->hProcess < ID_STATUS_ONLINE && ack->lParam >= ID_STATUS_ONLINE) {
DWORD caps;
- caps = (DWORD) CallProtoService(ack->szModule, PS_GETCAPS, PFLAGNUM_1, 0);
+ caps = (DWORD) CallProtoServiceInt(NULL,ack->szModule, PS_GETCAPS, PFLAGNUM_1, 0);
if (caps & PF1_SERVERCLIST) {
HANDLE hContact;
char *szProto;
diff --git a/src/modules/clist/clisttray.cpp b/src/modules/clist/clisttray.cpp
index 608f692028..013a639168 100644
--- a/src/modules/clist/clisttray.cpp
+++ b/src/modules/clist/clisttray.cpp
@@ -53,13 +53,13 @@ static TCHAR* sttGetXStatus(const char* szProto)
{
TCHAR* result = NULL;
- if (CallProtoService(szProto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) {
+ if (CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) {
char str[MAXMODULELABELLENGTH];
mir_snprintf(str, sizeof(str), "%s/GetXStatus", szProto);
if (ServiceExists(str)) {
char* dbTitle = "XStatusName";
char* dbTitle2 = NULL;
- int xstatus = CallProtoService(szProto, "/GetXStatus", (WPARAM)&dbTitle, (LPARAM)&dbTitle2);
+ int xstatus = CallProtoServiceInt(NULL,szProto, "/GetXStatus", (WPARAM)&dbTitle, (LPARAM)&dbTitle2);
if (dbTitle && xstatus) {
DBVARIANT dbv={0};
if ( !DBGetContactSettingTString(NULL, szProto, dbTitle, &dbv)) {
@@ -123,7 +123,7 @@ TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto)
if ( !cli.pfnGetProtocolVisibility(pa->szModuleName))
continue;
- szStatus = cli.pfnGetStatusModeDescription(CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0), 0);
+ szStatus = cli.pfnGetStatusModeDescription(CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0), 0);
if ( !szStatus)
continue;
@@ -156,7 +156,7 @@ TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto)
else {
if ((pa = Proto_GetAccount(szProto)) != NULL) {
ProtoXStatus = sttGetXStatus(szProto);
- szStatus = cli.pfnGetStatusModeDescription(CallProtoService(szProto, PS_GETSTATUS, 0, 0), 0);
+ szStatus = cli.pfnGetStatusModeDescription(CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0), 0);
if (szPrefix && szPrefix[0]) {
if (DBGetContactSettingByte(NULL, "CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT)) {
if (mToolTipTrayTips) {
@@ -281,7 +281,7 @@ int fnTrayIconInit(HWND hwnd)
else
szProto = NULL;
- cli.pfnTrayIconAdd(hwnd, NULL, szProto, szProto ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0));
+ cli.pfnTrayIconAdd(hwnd, NULL, szProto, szProto ? CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0));
DBFreeVariant(&dbv);
}
else if (trayIconSetting == SETTING_TRAYICON_MULTI &&
@@ -295,7 +295,7 @@ int fnTrayIconInit(HWND hwnd)
{
PROTOACCOUNT* pa = accounts[j];
if (cli.pfnGetProtocolVisibility(pa->szModuleName))
- cli.pfnTrayIconAdd(hwnd, pa->szModuleName, NULL, CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0));
+ cli.pfnTrayIconAdd(hwnd, pa->szModuleName, NULL, CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0));
}
}
}
@@ -498,7 +498,7 @@ VOID CALLBACK fnTrayCycleTimerProc(HWND, UINT, UINT_PTR, DWORD)
{
DestroyIcon(cli.trayIcon[0].hBaseIcon);
cli.trayIcon[0].hBaseIcon = cli.pfnGetIconFromStatusMode(NULL, accounts[cycleStep]->szModuleName,
- CallProtoService(accounts[cycleStep]->szModuleName, PS_GETSTATUS, 0, 0));
+ CallProtoServiceInt(NULL,accounts[cycleStep]->szModuleName, PS_GETSTATUS, 0, 0));
if (cli.trayIcon[0].isBase)
cli.pfnTrayIconUpdate(cli.trayIcon[0].hBaseIcon, NULL, NULL, 1);
}
@@ -534,7 +534,7 @@ void fnTrayIconUpdateBase(const char *szChangedProto)
if (trayIconSetting == SETTING_TRAYICON_MULTI) {
if (DBGetContactSettingByte(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))
//changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode((char*)szChangedProto, NULL, averageMode), (char*)szChangedProto);
- changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);
+ changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);
else if (cli.trayIcon && cli.trayIcon[0].szProto != NULL) {
cli.pfnTrayIconDestroy(hwnd);
cli.pfnTrayIconInit(hwnd);
@@ -555,7 +555,7 @@ void fnTrayIconUpdateBase(const char *szChangedProto)
szProto = NULL;
else
szProto = dbv.pszVal;
- changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szProto, szProto ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0)), szProto);
+ changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szProto, szProto ? CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0)), szProto);
DBFreeVariant(&dbv);
break;
}
@@ -564,7 +564,7 @@ void fnTrayIconUpdateBase(const char *szChangedProto)
SetTimer(NULL, 0, DBGetContactSettingWord(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, cli.pfnTrayCycleTimerProc);
changed =
cli.pfnTrayIconSetBaseInfo(ImageList_GetIcon
- (hCListImages, cli.pfnIconFromStatusMode(szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0), NULL),
+ (hCListImages, cli.pfnIconFromStatusMode(szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0), NULL),
ILD_NORMAL), NULL);
break;
case SETTING_TRAYICON_MULTI:
@@ -572,7 +572,7 @@ void fnTrayIconUpdateBase(const char *szChangedProto)
cli.pfnTrayIconRemove(NULL, NULL);
}
else if ((cli.trayIconCount > 1 || netProtoCount == 1) || DBGetContactSettingByte(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))
- changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);
+ changed = cli.pfnTrayIconSetBaseInfo(cli.pfnGetIconFromStatusMode(NULL, szChangedProto, CallProtoServiceInt(NULL,szChangedProto, PS_GETSTATUS, 0, 0)), (char*)szChangedProto);
else {
cli.pfnTrayIconDestroy(hwnd);
cli.pfnTrayIconInit(hwnd);
diff --git a/src/modules/clist/clui.cpp b/src/modules/clist/clui.cpp
index 78ed09174d..8524a4cf3a 100644
--- a/src/modules/clist/clui.cpp
+++ b/src/modules/clist/clui.cpp
@@ -76,7 +76,7 @@ static void DisconnectAll()
{
int nProto;
for (nProto = 0; nProto < accounts.getCount(); nProto++)
- CallProtoService(accounts[nProto]->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0);
+ CallProtoServiceInt(NULL,accounts[nProto]->szModuleName, PS_SETSTATUS, ID_STATUS_OFFLINE, 0);
}
static int CluiIconsChanged(WPARAM, LPARAM)
@@ -183,7 +183,7 @@ static INT_PTR MenuItem_DeleteContact(WPARAM wParam, LPARAM lParam)
if (DBGetContactSettingByte(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT) &&
!(GetKeyState(VK_SHIFT)&0x8000))
// Ask user for confirmation, and if the contact should be archived (hidden, not deleted)
- action = DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_DELETECONTACT), (HWND) lParam, AskForConfirmationDlgProc, wParam);
+ action = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DELETECONTACT), (HWND) lParam, AskForConfirmationDlgProc, wParam);
else
action = IDYES;
@@ -197,11 +197,11 @@ static INT_PTR MenuItem_DeleteContact(WPARAM wParam, LPARAM lParam)
// Check if protocol uses server side lists
DWORD caps;
- caps = (DWORD) CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ caps = (DWORD) CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0);
if (caps & PF1_SERVERCLIST) {
int status;
- status = CallProtoService(szProto, PS_GETSTATUS, 0, 0);
+ status = CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0);
if (status == ID_STATUS_OFFLINE || (status >= ID_STATUS_CONNECTING && status < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) {
// Set a flag so we remember to delete the contact when the protocol goes online the next time
DBWriteContactSettingByte((HANDLE) wParam, "CList", "Delete", 1);
@@ -1042,7 +1042,7 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
int status, x;
SIZE textSize;
BYTE showOpts = DBGetContactSettingByte(NULL, "CLUI", "SBarShow", 1);
- status = CallProtoService(szProto, PS_GETSTATUS, 0, 0);
+ status = CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0);
SetBkMode(dis->hDC, TRANSPARENT);
x = dis->rcItem.left;
if (showOpts & 1) {
diff --git a/src/modules/clist/cluiservices.cpp b/src/modules/clist/cluiservices.cpp
index e1123ecd05..30f1a55322 100644
--- a/src/modules/clist/cluiservices.cpp
+++ b/src/modules/clist/cluiservices.cpp
@@ -199,7 +199,7 @@ void fnCluiProtocolStatusChanged(int, const char*)
x += GetSystemMetrics(SM_CXBORDER) * 4; // The SB panel doesnt allocate enough room
}
if (showOpts & 4) {
- TCHAR* modeDescr = cli.pfnGetStatusModeDescription(CallProtoService(cli.menuProtos[i].szProto, PS_GETSTATUS, 0, 0), 0);
+ TCHAR* modeDescr = cli.pfnGetStatusModeDescription(CallProtoServiceInt(NULL,cli.menuProtos[i].szProto, PS_GETSTATUS, 0, 0), 0);
GetTextExtentPoint32(hdc, modeDescr, lstrlen(modeDescr), &textSize);
x += textSize.cx;
x += GetSystemMetrics(SM_CXBORDER) * 4; // The SB panel doesnt allocate enough room
diff --git a/src/modules/clist/genmenu.cpp b/src/modules/clist/genmenu.cpp
index b6f78c80ef..ff6ead1d75 100644
--- a/src/modules/clist/genmenu.cpp
+++ b/src/modules/clist/genmenu.cpp
@@ -77,7 +77,7 @@ LPTSTR GetMenuItemText(PMO_IntMenuItem pimi)
if (pimi->mi.flags & CMIF_KEEPUNTRANSLATED)
return pimi->mi.ptszName;
- return LangPackTranslateStringT(pimi->mi.hLangpack, pimi->mi.ptszName);
+ return TranslateTH(pimi->mi.hLangpack, pimi->mi.ptszName);
}
PMO_IntMenuItem MO_RecursiveWalkMenu(PMO_IntMenuItem parent, pfnWalkFunc func, void* param)
diff --git a/src/modules/clist/genmenuopt.cpp b/src/modules/clist/genmenuopt.cpp
index e16fd49d18..c2ecc3f18b 100644
--- a/src/modules/clist/genmenuopt.cpp
+++ b/src/modules/clist/genmenuopt.cpp
@@ -849,7 +849,7 @@ int GenMenuOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize=sizeof(odp);
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszGroup = LPGEN("Customize");
odp.position = -1000000000;
diff --git a/src/modules/contacts/contacts.cpp b/src/modules/contacts/contacts.cpp
index f6cbc2c889..096725972a 100644
--- a/src/modules/contacts/contacts.cpp
+++ b/src/modules/contacts/contacts.cpp
@@ -34,12 +34,12 @@ BYTE nameOrder[NAMEORDERCOUNT];
static int GetDatabaseString(CONTACTINFO *ci, const char* setting, DBVARIANT* dbv)
{
- if (strcmp(ci->szProto, "CList") && CallProtoService(ci->szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC)
+ if (strcmp(ci->szProto, "CList") && CallProtoServiceInt(NULL,ci->szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC)
{
DBCONTACTGETSETTING cgs = { ci->szProto, setting, dbv };
dbv->type = (ci->dwFlag & CNF_UNICODE) ? DBVT_WCHAR : DBVT_ASCIIZ;
- int res = CallProtoService(ci->szProto, PS_GETINFOSETTING, (WPARAM)ci->hContact, (LPARAM)&cgs);
+ int res = CallProtoServiceInt(NULL,ci->szProto, PS_GETINFOSETTING, (WPARAM)ci->hContact, (LPARAM)&cgs);
if (res != CALLSERVICE_NOTFOUND) return res;
}
@@ -197,7 +197,7 @@ static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) {
case CNF_UNIQUEID:
{
- char *uid = (char*)CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ char *uid = (char*)CallProtoServiceInt(NULL,ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid)
if ( !ProcessDatabaseValueDefault(ci, uid))
return 0;
@@ -208,7 +208,7 @@ static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) {
{
if ( !ProcessDatabaseValueDefault(ci, "display_uid"))
return 0;
- char *uid = (char*)CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ char *uid = (char*)CallProtoServiceInt(NULL,ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid)
if ( !ProcessDatabaseValueDefault(ci, uid))
return 0;
@@ -252,7 +252,7 @@ static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) {
case 5: // Unique id
{
// protocol must define a PFLAG_UNIQUEIDSETTING
- char *uid = (char*)CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ char *uid = (char*)CallProtoServiceInt(NULL,ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) {
if ( !GetDatabaseString(ci, uid, &dbv)) {
if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD) {
@@ -482,7 +482,7 @@ static int ContactOptInit(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.position = -1000000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_CONTACT);
odp.pszGroup = LPGEN("Customize");
odp.pszTitle = LPGEN("Contacts");
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp
index 407cc4b4b2..c8743b3b30 100644
--- a/src/modules/database/database.cpp
+++ b/src/modules/database/database.cpp
@@ -77,7 +77,7 @@ int getProfilePath(TCHAR * buf, size_t cch)
_tcscpy(profiledir, _T("%miranda_path%\\Profiles"));
TCHAR* exprofiledir = Utils_ReplaceVarsT(profiledir);
- size_t len = pathToAbsoluteT(exprofiledir, buf, NULL);
+ size_t len = PathToAbsoluteT(exprofiledir, buf, NULL);
mir_free(exprofiledir);
if (buf[len-1] == '/' || buf[len-1] == '\\')
@@ -184,7 +184,7 @@ void getProfileCmdLine(TCHAR * szProfile, size_t cch, TCHAR * profiledir)
p = _tcsrchr(profileName, '.'); if (p) *p = 0;
mir_sntprintf(newProfileDir, cch, _T("%s\\%s\\"), profiledir, profileName);
- pathToAbsoluteT(buf, szProfile, newProfileDir);
+ PathToAbsoluteT(buf, szProfile, newProfileDir);
if (_tcschr(buf, '\\'))
{
@@ -511,7 +511,7 @@ static int FindMirandaForProfile(TCHAR * szProfile)
int LoadDatabaseModule(void)
{
TCHAR szProfile[MAX_PATH];
- pathToAbsoluteT(_T("."), szProfile, NULL);
+ PathToAbsoluteT(_T("."), szProfile, NULL);
_tchdir(szProfile);
szProfile[0] = 0;
diff --git a/src/modules/database/dbini.cpp b/src/modules/database/dbini.cpp
index e8836114c1..af15390857 100644
--- a/src/modules/database/dbini.cpp
+++ b/src/modules/database/dbini.cpp
@@ -193,7 +193,20 @@ int SettingsEnumProc(const char *szSetting, LPARAM lParam)
return 0;
}
-void ConvertBackslashes(char *, UINT);
+static void ConvertBackslashes(char *str, UINT fileCp)
+{
+ char *pstr;
+ for (pstr = str; *pstr; pstr = CharNextExA(fileCp, pstr, 0)) {
+ if (*pstr == '\\') {
+ switch(pstr[1]) {
+ case 'n': *pstr = '\n'; break;
+ case 't': *pstr = '\t'; break;
+ case 'r': *pstr = '\r'; break;
+ default: *pstr = pstr[1]; break;
+ }
+ memmove(pstr+1, pstr+2, strlen(pstr+2) + 1);
+} } }
+
static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsafeSections, int secur, bool secFN)
{
FILE *fp = _tfopen(szIniPath, _T("rt"));
@@ -286,7 +299,7 @@ static void ProcessIniFile(TCHAR* szIniPath, char *szSafeSections, char *szUnsaf
warnInfo.szValue=szValue;
warnInfo.warnNoMore=0;
warnInfo.cancel=0;
- if (warnThisSection && IDNO == DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_WARNINICHANGE), NULL, WarnIniChangeDlgProc, (LPARAM)&warnInfo))
+ if (warnThisSection && IDNO == DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WARNINICHANGE), NULL, WarnIniChangeDlgProc, (LPARAM)&warnInfo))
continue;
if (warnInfo.cancel)
break;
@@ -392,14 +405,14 @@ static void DoAutoExec(void)
if (dbCreated && szOnCreateFilename[0]) {
str2 = Utils_ReplaceVarsT(szOnCreateFilename);
- pathToAbsoluteT(str2, szIniPath, NULL);
+ PathToAbsoluteT(str2, szIniPath, NULL);
mir_free(str2);
ProcessIniFile(szIniPath, szSafeSections, szUnsafeSections, 0, 1);
}
str2 = Utils_ReplaceVarsT(szFindPath);
- pathToAbsoluteT(str2, szFindPath, NULL);
+ PathToAbsoluteT(str2, szFindPath, NULL);
mir_free(str2);
WIN32_FIND_DATA fd;
@@ -419,7 +432,7 @@ static void DoAutoExec(void)
mir_sntprintf(szIniPath, SIZEOF(szIniPath), _T("%s%s"), szFindPath, fd.cFileName);
if ( !lstrcmpi(szUse, _T("prompt")) && !secFN) {
- int result=DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_INSTALLINI), NULL, InstallIniDlgProc, (LPARAM)szIniPath);
+ int result=DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INSTALLINI), NULL, InstallIniDlgProc, (LPARAM)szIniPath);
if (result == IDC_NOTOALL) break;
if (result == IDCANCEL) continue;
}
@@ -451,7 +464,7 @@ static void DoAutoExec(void)
MoveFile(szIniPath, szNewPath);
}
else if ( !lstrcmpi(szOnCompletion, _T("ask")))
- DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_INIIMPORTDONE), NULL, IniImportDoneDlgProc, (LPARAM)szIniPath);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INIIMPORTDONE), NULL, IniImportDoneDlgProc, (LPARAM)szIniPath);
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
@@ -473,7 +486,7 @@ int InitIni(void)
bModuleInitialized = true;
DoAutoExec();
- pathToAbsoluteT(_T("."), szMirandaDir, NULL);
+ PathToAbsoluteT(_T("."), szMirandaDir, NULL);
hIniChangeNotification=FindFirstChangeNotification(szMirandaDir, 0, FILE_NOTIFY_CHANGE_FILE_NAME);
if (hIniChangeNotification != INVALID_HANDLE_VALUE) {
CreateServiceFunction("DB/Ini/CheckImportNow", CheckIniImportNow);
diff --git a/src/modules/database/dbutils.cpp b/src/modules/database/dbutils.cpp
index dede30691b..54b352bb4d 100644
--- a/src/modules/database/dbutils.cpp
+++ b/src/modules/database/dbutils.cpp
@@ -207,7 +207,7 @@ static INT_PTR DbEventGetStringT(WPARAM wParam, LPARAM lParam)
char* string = (char*)lParam;
if (dbei->flags & DBEF_UTF)
- return (INT_PTR)Utf8DecodeUcs2(string);
+ return (INT_PTR)Utf8DecodeW(string);
return (INT_PTR)mir_a2t(string);
}
diff --git a/src/modules/database/profilemanager.cpp b/src/modules/database/profilemanager.cpp
index 1ddccf0c95..898fc323d6 100644
--- a/src/modules/database/profilemanager.cpp
+++ b/src/modules/database/profilemanager.cpp
@@ -312,11 +312,11 @@ BOOL EnumProfilesForList(TCHAR * fullpath, TCHAR * profile, LPARAM lParam)
} }
item2.iSubItem = 3;
- item2.pszText = rtrim(_tctime(&statbuf.st_ctime));
+ item2.pszText = trtrim(_tctime(&statbuf.st_ctime));
SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item2);
item2.iSubItem = 4;
- item2.pszText = rtrim(_tctime(&statbuf.st_mtime));
+ item2.pszText = trtrim(_tctime(&statbuf.st_mtime));
SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item2);
}
return TRUE;
@@ -537,8 +537,8 @@ static INT_PTR CALLBACK DlgProfileManager(HWND hwndDlg, UINT msg, WPARAM wParam,
struct DlgProfData * prof = (struct DlgProfData *)lParam;
PROPSHEETHEADER *psh = prof->psh;
TranslateDialogDefault(hwndDlg);
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadImage(hMirandaInst, MAKEINTRESOURCE(IDI_USERDETAILS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadImage(hMirandaInst, MAKEINTRESOURCE(IDI_USERDETAILS), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_USERDETAILS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_USERDETAILS), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0));
dat = (struct DetailsData*)mir_alloc(sizeof(struct DetailsData));
dat->prof = prof;
prof->hwndOK = GetDlgItem(hwndDlg, IDOK);
@@ -805,7 +805,7 @@ int getProfileManager(PROFILEMANAGERDATA * pd)
odp.pszTitle = LPGEN("My Profiles");
odp.pfnDlgProc = DlgProfileSelect;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROFILE_SELECTION);
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
AddProfileManagerPage(&opi, &odp);
odp.pszTitle = LPGEN("New Profile");
@@ -825,7 +825,7 @@ int getProfileManager(PROFILEMANAGERDATA * pd)
DlgProfData prof;
prof.pd = pd;
prof.psh = &psh;
- int rc = DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_PROFILEMANAGER), NULL, DlgProfileManager, (LPARAM)&prof);
+ int rc = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PROFILEMANAGER), NULL, DlgProfileManager, (LPARAM)&prof);
if (rc != -1)
for (int i=0; i < opi.pageCount; i++) {
diff --git a/src/modules/findadd/findadd.cpp b/src/modules/findadd/findadd.cpp
index 4763836180..297b418067 100644
--- a/src/modules/findadd/findadd.cpp
+++ b/src/modules/findadd/findadd.cpp
@@ -194,7 +194,7 @@ static void ShowAdvancedSearchDlg(HWND hwndDlg, struct FindAddDlgData *dat)
if (szProto == NULL) return;
if (dat->hwndAdvSearch == NULL) {
RECT rc;
- dat->hwndAdvSearch=(HWND)CallProtoService(szProto, PS_CREATEADVSEARCHUI, 0, (LPARAM)hwndDlg);
+ dat->hwndAdvSearch=(HWND)CallProtoServiceInt(NULL,szProto, PS_CREATEADVSEARCHUI, 0, (LPARAM)hwndDlg);
GetWindowRect(GetDlgItem(hwndDlg, IDC_RESULTS), &rc);
SetWindowPos(dat->hwndAdvSearch, 0, rc.left, rc.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
}
@@ -225,7 +225,7 @@ static void ShowTinySearchDlg(HWND hwndDlg, struct FindAddDlgData *dat)
char *szProto=(char*)SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_GETCURSEL, 0, 0), 0);
if (szProto == NULL) return;
if (dat->hwndTinySearch == NULL) {
- dat->hwndTinySearch=(HWND)CallProtoService(szProto, PS_CREATEADVSEARCHUI, 0, (LPARAM)/*GetDlgItem(*/hwndDlg/*, IDC_TINYEXTENDEDGROUP)*/);
+ dat->hwndTinySearch=(HWND)CallProtoServiceInt(NULL,szProto, PS_CREATEADVSEARCHUI, 0, (LPARAM)/*GetDlgItem(*/hwndDlg/*, IDC_TINYEXTENDEDGROUP)*/);
if (dat->hwndTinySearch)
ReposTinySearchDlg(hwndDlg, dat);
else
@@ -291,8 +291,8 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
dat->notSearchedYet=1;
dat->iLastColumnSortIndex=1;
dat->bSortAscending=1;
- dat->hBmpSortUp=(HBITMAP)LoadImage(hMirandaInst, MAKEINTRESOURCE(IDB_SORTCOLUP), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
- dat->hBmpSortDown=(HBITMAP)LoadImage(hMirandaInst, MAKEINTRESOURCE(IDB_SORTCOLDOWN), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
+ dat->hBmpSortUp=(HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(IDB_SORTCOLUP), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
+ dat->hBmpSortDown=(HBITMAP)LoadImage(hInst, MAKEINTRESOURCE(IDB_SORTCOLDOWN), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
SendDlgItemMessage(hwndDlg, IDC_MOREOPTIONS, BUTTONSETARROW, 1, 0);
ListView_SetExtendedListViewStyle(hwndList, LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP);
@@ -344,7 +344,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
for (i=0, netProtoCount=0; i < accounts.getCount(); i++) {
if ( !Proto_IsAccountEnabled(accounts[i])) continue;
- DWORD caps = (DWORD)CallProtoService(accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ DWORD caps = (DWORD)CallProtoServiceInt(NULL,accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (caps & PF1_BASICSEARCH || caps & PF1_EXTSEARCH || caps & PF1_SEARCHBYEMAIL || caps & PF1_SEARCHBYNAME)
netProtoCount++;
}
@@ -366,14 +366,14 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
for (i=0; i < accounts.getCount(); i++) {
PROTOACCOUNT* pa = accounts[i];
if ( !Proto_IsAccountEnabled(pa)) continue;
- DWORD caps=(DWORD)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ DWORD caps=(DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if ( !(caps&PF1_BASICSEARCH) && !(caps&PF1_EXTSEARCH) && !(caps&PF1_SEARCHBYEMAIL) && !(caps&PF1_SEARCHBYNAME))
continue;
cbei.pszText = pa->tszAccountName;
GetTextExtentPoint32(hdc, cbei.pszText, lstrlen(cbei.pszText), &textSize);
if (textSize.cx>cbwidth) cbwidth = textSize.cx;
- hIcon=(HICON)CallProtoService(pa->szModuleName, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
+ hIcon=(HICON)CallProtoServiceInt(NULL,pa->szModuleName, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
cbei.iImage=cbei.iSelectedImage=ImageList_AddIcon(dat->himlComboIcons, hIcon);
DestroyIcon(hIcon);
cbei.lParam=(LPARAM)pa->szModuleName;
@@ -398,7 +398,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{ UTILRESIZEDIALOG urd={0};
urd.cbSize=sizeof(urd);
urd.hwndDlg=hwndDlg;
- urd.hInstance=hMirandaInst;
+ urd.hInstance=hInst;
urd.lpTemplate=MAKEINTRESOURCEA(IDD_FINDADD);
urd.lParam=(LPARAM)dat;
urd.pfnResizer=FindAddDlgResizer;
@@ -452,13 +452,13 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
for (i=0; i < accounts.getCount(); i++) {
PROTOACCOUNT* pa = accounts[i];
if ( !Proto_IsAccountEnabled(pa)) continue;
- protoCaps=(DWORD)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ protoCaps=(DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail=1;
if (protoCaps&PF1_SEARCHBYNAME) dat->showName=1;
}
}
else {
- protoCaps=(DWORD)CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ protoCaps=(DWORD)CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0);
if (protoCaps&PF1_BASICSEARCH) dat->showProtoId=1;
if (protoCaps&PF1_SEARCHBYEMAIL) dat->showEmail=1;
if (protoCaps&PF1_SEARCHBYNAME) dat->showName=1;
@@ -467,7 +467,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (protoCaps&PF1_USERIDISEMAIL && dat->showProtoId) {dat->showProtoId=0; dat->showEmail=1;}
if (dat->showProtoId) {
char *szUniqueId;
- szUniqueId=(char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0);
+ szUniqueId=(char*)CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0);
if (szUniqueId) {
#if defined(_UNICODE)
TCHAR* p = mir_a2u(szUniqueId);
@@ -518,7 +518,8 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendMessage(hwndDlg, WM_SIZE, 0, 0);
SendMessage(hwndDlg, WM_GETMINMAXINFO, 0, (LPARAM)&mmi);
GetWindowRect(hwndDlg, &rc);
- if (rc.bottom-rc.top<mmi.ptMinTrackSize.y) SetWindowPos(hwndDlg, 0, 0, 0, rc.right-rc.left, mmi.ptMinTrackSize.y, SWP_NOZORDER|SWP_NOMOVE);
+ if (rc.bottom-rc.top<mmi.ptMinTrackSize.y)
+ SetWindowPos(hwndDlg, 0, 0, 0, rc.right-rc.left, mmi.ptMinTrackSize.y, SWP_NOZORDER|SWP_NOMOVE);
break;
}
case WM_TIMER:
@@ -657,7 +658,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
else if (IsDlgButtonChecked(hwndDlg, IDC_BYPROTOID)) {
TCHAR str[256];
GetDlgItemText(hwndDlg, IDC_PROTOID, str, SIZEOF(str));
- rtrim(str);
+ trtrim(str);
if (str[0] == 0)
MessageBox(hwndDlg, sttErrMsg, sttErrTitle, MB_OK);
else
@@ -666,7 +667,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
else if (IsDlgButtonChecked(hwndDlg, IDC_BYEMAIL)) {
TCHAR str[256];
GetDlgItemText(hwndDlg, IDC_EMAIL, str, SIZEOF(str));
- rtrim(str);
+ trtrim(str);
if (str[0] == 0)
MessageBox(hwndDlg, sttErrMsg, sttErrTitle, MB_OK);
else
@@ -726,7 +727,8 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
TCHAR str[256];
GetDlgItemText(hwndDlg, IDC_PROTOID, str, SIZEOF(str));
- if (*rtrim(str) == 0) break;
+ if (*trtrim(str) == 0)
+ break;
PROTOSEARCHRESULT psr = {0};
psr.cbSize = sizeof(psr);
@@ -975,12 +977,12 @@ static INT_PTR FindAddCommand(WPARAM, LPARAM)
for (i=0, netProtoCount=0; i < accounts.getCount(); i++) {
PROTOACCOUNT* pa = accounts[i];
if ( !Proto_IsAccountEnabled(pa)) continue;
- int protoCaps=CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ int protoCaps=CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (protoCaps&PF1_BASICSEARCH || protoCaps&PF1_SEARCHBYEMAIL || protoCaps&PF1_SEARCHBYNAME
|| protoCaps&PF1_EXTSEARCHUI) netProtoCount++;
}
if (netProtoCount > 0)
- hwndFindAdd=CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_FINDADD), NULL, DlgProcFindAdd);
+ hwndFindAdd=CreateDialog(hInst, MAKEINTRESOURCE(IDD_FINDADD), NULL, DlgProcFindAdd);
}
return 0;
}
@@ -1018,7 +1020,7 @@ static int OnSystemModulesLoaded(WPARAM, LPARAM)
// Make sure we have some networks to search on.
for (i=0, netProtoCount=0; i < accounts.getCount(); i++) {
PROTOACCOUNT* pa = accounts[i];
- int protoCaps = CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ int protoCaps = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if (protoCaps & (PF1_BASICSEARCH | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME | PF1_EXTSEARCHUI))
netProtoCount++;
}
diff --git a/src/modules/findadd/searchresults.cpp b/src/modules/findadd/searchresults.cpp
index 2422f262d1..5352bfd6a7 100644
--- a/src/modules/findadd/searchresults.cpp
+++ b/src/modules/findadd/searchresults.cpp
@@ -87,7 +87,7 @@ void LoadColumnSizes(HWND hwndResults, const char *szProto)
if (szProto)
{
bNeedsFree = TRUE;
- lvc.pszText = mir_a2t((char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0));
+ lvc.pszText = mir_a2t((char*)CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAG_UNIQUEIDTEXT, 0));
}
else
lvc.pszText = _T("ID");
@@ -215,9 +215,9 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha
for (i=0; i < accounts.getCount();i++) {
PROTOACCOUNT* pa = accounts[i];
if ( !Proto_IsAccountEnabled(pa)) continue;
- DWORD caps=(DWORD)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ DWORD caps=(DWORD)CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
if ( !(caps&requiredCapability)) continue;
- dat->search[dat->searchCount].hProcess = (HANDLE)CallProtoService(pa->szModuleName, szSearchService, 0, (LPARAM)pvSearchParams);
+ dat->search[dat->searchCount].hProcess = (HANDLE)CallProtoServiceInt(NULL,pa->szModuleName, szSearchService, 0, (LPARAM)pvSearchParams);
dat->search[dat->searchCount].szProto = pa->szModuleName;
if (dat->search[dat->searchCount].hProcess == NULL) failures++;
else dat->searchCount++;
@@ -234,7 +234,7 @@ int BeginSearch(HWND, struct FindAddDlgData *dat, const char *szProto, const cha
else {
dat->search=(struct ProtoSearchInfo*)mir_alloc(sizeof(struct ProtoSearchInfo));
dat->searchCount=1;
- dat->search[0].hProcess=(HANDLE)CallProtoService(szProto, szSearchService, 0, (LPARAM)pvSearchParams);
+ dat->search[0].hProcess=(HANDLE)CallProtoServiceInt(NULL,szProto, szSearchService, 0, (LPARAM)pvSearchParams);
dat->search[0].szProto=szProto;
if (dat->search[0].hProcess == NULL) {
//infuriatingly vague error message. fixme.
@@ -358,7 +358,7 @@ void ShowMoreOptionsMenu(HWND hwndDlg, int x, int y)
lsr=(struct ListSearchResult*)lvi.lParam;
}
- hMenu=LoadMenu(hMirandaInst, MAKEINTRESOURCE(IDR_CONTEXT));
+ hMenu=LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT));
hPopupMenu=GetSubMenu(hMenu, 4);
TranslateMenu(hPopupMenu);
commandId=TrackPopupMenu(hPopupMenu, TPM_RIGHTBUTTON|TPM_RETURNCMD, x, y, 0, hwndDlg, NULL);
@@ -375,13 +375,13 @@ void ShowMoreOptionsMenu(HWND hwndDlg, int x, int y)
}
case IDC_DETAILS:
{ HANDLE hContact;
- hContact=(HANDLE)CallProtoService(lsr->szProto, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&lsr->psr);
+ hContact=(HANDLE)CallProtoServiceInt(NULL,lsr->szProto, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&lsr->psr);
CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
break;
}
case IDC_SENDMESSAGE:
{ HANDLE hContact;
- hContact=(HANDLE)CallProtoService(lsr->szProto, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&lsr->psr);
+ hContact=(HANDLE)CallProtoServiceInt(NULL,lsr->szProto, PS_ADDTOLIST, PALF_TEMPORARY, (LPARAM)&lsr->psr);
CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, (LPARAM)(const char*)NULL);
break;
}
diff --git a/src/modules/fonts/FontOptions.cpp b/src/modules/fonts/FontOptions.cpp
index c026e26d72..8c82f5ac91 100644
--- a/src/modules/fonts/FontOptions.cpp
+++ b/src/modules/fonts/FontOptions.cpp
@@ -371,7 +371,7 @@ static void sttFsuiCreateSettingsTreeNode(HWND hwndTree, const TCHAR *groupName,
if (sectionName = _tcschr(sectionName, '/'))
*sectionName = 0;
- pItemName = LangPackTranslateStringT(hLangpack, pItemName);
+ pItemName = TranslateTH(hLangpack, pItemName);
hItem = sttFindNamedTreeItemAt(hwndTree, hSection, pItemName);
if ( !sectionName || !hItem) {
@@ -528,7 +528,7 @@ static INT_PTR CALLBACK ChooseEffectDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wPar
static BOOL ChooseEffectDialog(HWND hwndParent, FONTEFFECT * es)
{
- return (DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_CHOOSE_FONT_EFFECT), hwndParent, ChooseEffectDlgProc, (LPARAM) es) == IDOK);
+ return (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CHOOSE_FONT_EFFECT), hwndParent, ChooseEffectDlgProc, (LPARAM) es) == IDOK);
}
static void sttSaveFontData(HWND hwndDlg, FontInternal &F)
@@ -1014,14 +1014,14 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
{
cf.Flags = CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_EFFECTS | CF_ENABLETEMPLATE | CF_ENABLEHOOK;
// use custom font dialog to disable colour selection
- cf.hInstance = hMirandaInst;
+ cf.hInstance = hInst;
cf.lpTemplateName = MAKEINTRESOURCE(IDD_CUSTOM_FONT);
cf.lpfnHook = CFHookProc;
}
else if (F.flags & FIDF_DISABLESTYLES) { // no style selection, mutually exclusive with FIDF_ALLOWEFFECTS
cf.Flags = CF_FORCEFONTEXIST | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_ENABLETEMPLATE | CF_ENABLEHOOK | CF_TTONLY | CF_NOOEMFONTS;
cf.lCustData = F.flags;
- cf.hInstance = hMirandaInst;
+ cf.hInstance = hInst;
cf.lpTemplateName = MAKEINTRESOURCE(IDD_CUSTOM_FONT);
cf.lpfnHook = CFHookProc;
lf.lfWeight = FW_NORMAL;
@@ -1284,7 +1284,7 @@ int OptInit(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = {0};
odp.cbSize = sizeof(odp);
odp.position = -790000000;
- odp.hInstance = hMirandaInst;;
+ odp.hInstance = hInst;;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FONTS);
odp.pszTitle = LPGEN("Fonts & Colors");
odp.pszGroup = LPGEN("Customize");
@@ -1390,7 +1390,7 @@ static INT_PTR CALLBACK DlgProcModernOptions(HWND hwndDlg, UINT msg, WPARAM wPar
if (pf->flags & FIDF_ALLOWEFFECTS) {
cf.Flags |= CF_EFFECTS | CF_ENABLETEMPLATE | CF_ENABLEHOOK;
// use custom font dialog to disable colour selection
- cf.hInstance = hMirandaInst;
+ cf.hInstance = hInst;
cf.lpTemplateName = MAKEINTRESOURCE(IDD_CUSTOM_FONT);
cf.lpfnHook = CFHookProc;
}
@@ -1452,7 +1452,7 @@ int FontsModernOptInit(WPARAM wParam, LPARAM lParam)
obj.cbSize = sizeof(obj);
obj.dwFlags = MODEROPT_FLG_TCHAR|MODEROPT_FLG_NORESIZE;
obj.hIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
- obj.hInstance = hMirandaInst;
+ obj.hInstance = hInst;
obj.iSection = MODERNOPT_PAGE_SKINS;
obj.iType = MODERNOPT_TYPE_SUBSECTIONPAGE;
obj.iBoldControls = iBoldControls;
diff --git a/src/modules/fonts/FontService.h b/src/modules/fonts/FontService.h
index 8042d668bf..578649f13b 100644
--- a/src/modules/fonts/FontService.h
+++ b/src/modules/fonts/FontService.h
@@ -30,7 +30,7 @@ struct FontInternal : public FontIDT
FontSettingsT value;
int hLangpack;
- __inline TCHAR* getName() const { return LangPackTranslateStringT(hLangpack, name); }
+ __inline TCHAR* getName() const { return TranslateTH(hLangpack, name); }
__inline bool isHeader() const
{
@@ -46,7 +46,7 @@ struct FontInternal : public FontIDT
struct ColourInternal : public ColourIDT
{
- __inline TCHAR* getName() const { return LangPackTranslateStringT(hLangpack, name); }
+ __inline TCHAR* getName() const { return TranslateTH(hLangpack, name); }
COLORREF value;
int hLangpack;
@@ -54,7 +54,7 @@ struct ColourInternal : public ColourIDT
struct EffectInternal : public EffectIDT
{
- __inline TCHAR* getName() const { return LangPackTranslateStringT(hLangpack, name); }
+ __inline TCHAR* getName() const { return TranslateTH(hLangpack, name); }
int hLangpack;
};
diff --git a/src/modules/fonts/services.cpp b/src/modules/fonts/services.cpp
index 09ac106fb5..adc5d216f2 100644
--- a/src/modules/fonts/services.cpp
+++ b/src/modules/fonts/services.cpp
@@ -297,22 +297,21 @@ static int sttRegisterFontWorker(FontIDW* font_id, int hLangpack)
char idstr[256];
mir_snprintf(idstr, SIZEOF(idstr), "%sFlags", font_id->prefix);
DBWriteContactSettingDword(0, font_id->dbSettingsGroup, idstr, font_id->flags);
- {
- FontInternal* newItem = new FontInternal;
- memset(newItem, 0, sizeof(FontIDW));
- memcpy(newItem, font_id, font_id->cbSize);
-
- if ( !lstrcmp(newItem->deffontsettings.szFace, _T("MS Shell Dlg"))) {
- LOGFONT lf;
- SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE);
- lstrcpyn(newItem->deffontsettings.szFace, lf.lfFaceName, SIZEOF(newItem->deffontsettings.szFace));
- if ( !newItem->deffontsettings.size)
- newItem->deffontsettings.size = lf.lfHeight;
- }
-
- UpdateFontSettings(font_id, &newItem->value);
- font_id_list.insert(newItem);
+
+ FontInternal* newItem = new FontInternal;
+ memset(newItem, 0, sizeof(FontIDW));
+ memcpy(newItem, font_id, font_id->cbSize);
+
+ if ( !lstrcmp(newItem->deffontsettings.szFace, _T("MS Shell Dlg"))) {
+ LOGFONT lf;
+ SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf, FALSE);
+ lstrcpyn(newItem->deffontsettings.szFace, lf.lfFaceName, SIZEOF(newItem->deffontsettings.szFace));
+ if ( !newItem->deffontsettings.size)
+ newItem->deffontsettings.size = lf.lfHeight;
}
+
+ UpdateFontSettings(font_id, &newItem->value);
+ font_id_list.insert(newItem);
return 0;
}
@@ -344,7 +343,8 @@ static INT_PTR sttGetFontWorker(FontIDW* font_id, LOGFONT* lf)
}
return colour;
- } }
+ }
+ }
GetDefaultFontSetting(lf, &colour);
return colour;
@@ -358,9 +358,10 @@ INT_PTR GetFontW(WPARAM wParam, LPARAM lParam)
INT_PTR GetFont(WPARAM wParam, LPARAM lParam)
{
FontIDW temp;
- LOGFONT lftemp;
- if ( !ConvertFontID((FontID*)wParam, &temp)) return -1;
+ if ( !ConvertFontID((FontID*)wParam, &temp))
+ return -1;
+ LOGFONT lftemp;
int ret = sttGetFontWorker(&temp, &lftemp);
ConvertLOGFONT(&lftemp, (LOGFONTA*)lParam);
return ret;
@@ -436,7 +437,6 @@ INT_PTR GetColour(WPARAM wParam, LPARAM)
void UpdateEffectSettings(EffectIDW* effect_id, FONTEFFECT* effectsettings)
{
char str[256];
-
mir_snprintf(str, SIZEOF(str), "%sEffect", effect_id->setting);
effectsettings->effectIndex = DBGetContactSettingByte(NULL, effect_id->dbSettingsGroup, str, effect_id->defeffect.effectIndex);
diff --git a/src/modules/help/about.cpp b/src/modules/help/about.cpp
index 2d7616c0ed..93f869466a 100644
--- a/src/modules/help/about.cpp
+++ b/src/modules/help/about.cpp
@@ -67,9 +67,9 @@ INT_PTR CALLBACK DlgProcAbout(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
}
ShowWindow(GetDlgItem(hwndDlg, IDC_CREDITSFILE), SW_HIDE);
{
- HRSRC hResInfo = FindResource(hMirandaInst, MAKEINTRESOURCE(IDR_CREDITS), _T("TEXT"));
- DWORD ResSize = SizeofResource(hMirandaInst, hResInfo);
- HGLOBAL hRes = LoadResource(hMirandaInst, hResInfo);
+ HRSRC hResInfo = FindResource(hInst, MAKEINTRESOURCE(IDR_CREDITS), _T("TEXT"));
+ DWORD ResSize = SizeofResource(hInst, hResInfo);
+ HGLOBAL hRes = LoadResource(hInst, hResInfo);
char* pszMsg = (char*)LockResource(hRes);
if (pszMsg)
{
diff --git a/src/modules/help/help.cpp b/src/modules/help/help.cpp
index 33b37e86b0..a1984ca32e 100644
--- a/src/modules/help/help.cpp
+++ b/src/modules/help/help.cpp
@@ -34,7 +34,7 @@ static INT_PTR AboutCommand(WPARAM wParam, LPARAM)
SetFocus(hAboutDlg);
return 0;
}
- hAboutDlg=CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)wParam, DlgProcAbout);
+ hAboutDlg=CreateDialog(hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)wParam, DlgProcAbout);
return 0;
}
diff --git a/src/modules/history/history.cpp b/src/modules/history/history.cpp
index 8e759f471c..218b040d01 100644
--- a/src/modules/history/history.cpp
+++ b/src/modules/history/history.cpp
@@ -39,7 +39,7 @@ static INT_PTR UserHistoryCommand(WPARAM wParam, LPARAM)
SetFocus(hwnd);
return 0;
}
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_HISTORY), NULL, DlgProcHistory, wParam);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HISTORY), NULL, DlgProcHistory, wParam);
return 0;
}
@@ -290,7 +290,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP
UTILRESIZEDIALOG urd={0};
urd.cbSize=sizeof(urd);
urd.hwndDlg=hwndDlg;
- urd.hInstance=hMirandaInst;
+ urd.hInstance=hInst;
urd.lpTemplate=MAKEINTRESOURCEA(IDD_HISTORY);
urd.lParam=(LPARAM)NULL;
urd.pfnResizer=HistoryDlgResizer;
@@ -305,7 +305,7 @@ static INT_PTR CALLBACK DlgProcHistory(HWND hwndDlg, UINT msg, WPARAM wParam, LP
return TRUE;
case IDC_FIND:
- ShowWindow(CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_HISTORY_FIND), hwndDlg, DlgProcHistoryFind, (LPARAM)hwndDlg), SW_SHOW);
+ ShowWindow(CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_HISTORY_FIND), hwndDlg, DlgProcHistoryFind, (LPARAM)hwndDlg), SW_SHOW);
return TRUE;
case IDC_DELETEHISTORY:
diff --git a/src/modules/icolib/IcoLib.h b/src/modules/icolib/IcoLib.h
index 30121729a8..550de7ad9b 100644
--- a/src/modules/icolib/IcoLib.h
+++ b/src/modules/icolib/IcoLib.h
@@ -75,7 +75,7 @@ struct IconItem
HICON temp_icon;
BOOL temp_reset;
- __inline TCHAR* getDescr() const { return LangPackTranslateStringT(hLangpack, description); }
+ __inline TCHAR* getDescr() const { return TranslateTH(hLangpack, description); }
};
// extracticon.c
diff --git a/src/modules/icolib/skin2icons.cpp b/src/modules/icolib/skin2icons.cpp
index 2d6d9ab9cd..7001bbae3b 100644
--- a/src/modules/icolib/skin2icons.cpp
+++ b/src/modules/icolib/skin2icons.cpp
@@ -112,7 +112,7 @@ IconSourceFile* IconSourceFile_Get(const TCHAR* file, bool isPath)
return NULL;
if (isPath)
- pathToAbsoluteT(file, fileFull, NULL);
+ PathToAbsoluteT(file, fileFull, NULL);
/// TODO: convert path to long - eliminate duplicate items
else
_tcscpy(fileFull, file);
@@ -534,9 +534,9 @@ HANDLE IcoLib_AddNewIcon(int hLangpack, SKINICONDESC* sid)
if (sid->pszDefaultFile) {
WCHAR fileFull[ MAX_PATH ];
if (utf_path)
- pathToAbsoluteT(sid->pwszDefaultFile, fileFull, NULL);
+ PathToAbsoluteT(sid->pwszDefaultFile, fileFull, NULL);
else
- pathToAbsoluteT( StrConvT(sid->pszDefaultFile), fileFull, NULL);
+ PathToAbsoluteT( StrConvT(sid->pszDefaultFile), fileFull, NULL);
item->default_file = mir_wstrdup(fileFull);
}
item->default_indx = sid->iDefaultIndex;
diff --git a/src/modules/icolib/skin2opts.cpp b/src/modules/icolib/skin2opts.cpp
index 0d230d7930..9c6f3f2a41 100644
--- a/src/modules/icolib/skin2opts.cpp
+++ b/src/modules/icolib/skin2opts.cpp
@@ -56,7 +56,7 @@ static HICON ExtractIconFromPath(const TCHAR *path, int cxIcon, int cyIcon)
n = _ttoi(comma+1);
*comma = 0;
}
- pathToAbsoluteT(file, fileFull, NULL);
+ PathToAbsoluteT(file, fileFull, NULL);
hIcon = NULL;
//SHOULD BE REPLACED WITH GOOD ENOUGH FUNCTION
@@ -242,7 +242,7 @@ static int OpenPopupMenu(HWND hwndDlg)
int cmd;
GetCursorPos(&pt);
- hMenu = LoadMenu(hMirandaInst, MAKEINTRESOURCE(IDR_ICOLIB_CONTEXT));
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_ICOLIB_CONTEXT));
hPopup = GetSubMenu(hMenu, 0);
TranslateMenu(hPopup);
cmd = TrackPopupMenu(hPopup, TPM_RIGHTBUTTON|TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
@@ -586,7 +586,7 @@ INT_PTR CALLBACK DlgProcIconImport(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
if ( !IsIconic(hwndDlg)) {
UTILRESIZEDIALOG urd = {0};
urd.cbSize = sizeof(urd);
- urd.hInstance = hMirandaInst;
+ urd.hInstance = hInst;
urd.hwndDlg = hwndDlg;
urd.lParam = 0; // user-defined
urd.lpTemplate = MAKEINTRESOURCEA(IDD_ICOLIB_IMPORT);
@@ -856,7 +856,7 @@ INT_PTR CALLBACK DlgProcIcoLibOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
case WM_COMMAND:
if (LOWORD(wParam) == IDC_IMPORT) {
- dat->hwndIndex = CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_ICOLIB_IMPORT), GetParent(hwndDlg), DlgProcIconImport, (LPARAM)hwndDlg);
+ dat->hwndIndex = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ICOLIB_IMPORT), GetParent(hwndDlg), DlgProcIconImport, (LPARAM)hwndDlg);
EnableWindow((HWND)lParam, FALSE);
}
else if (LOWORD(wParam) == IDC_GETMORE) {
@@ -1037,7 +1037,7 @@ int SkinOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = {0};
odp.cbSize = sizeof(odp);
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.flags = ODPF_BOLDGROUPS;
odp.position = -180000000;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_ICOLIB);
diff --git a/src/modules/idle/idle.cpp b/src/modules/idle/idle.cpp
index d502e99e13..2577812207 100644
--- a/src/modules/idle/idle.cpp
+++ b/src/modules/idle/idle.cpp
@@ -441,7 +441,7 @@ static int IdleOptInit(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.position = 100000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_IDLE);
odp.pszGroup = LPGEN("Status");
odp.pszTitle = LPGEN("Idle");
@@ -477,7 +477,7 @@ static int IdleModernOptInit(WPARAM wParam, LPARAM)
MODERNOPTOBJECT obj = {0};
obj.cbSize = sizeof(obj);
- obj.hInstance = hMirandaInst;
+ obj.hInstance = hInst;
obj.dwFlags = MODEROPT_FLG_TCHAR | MODEROPT_FLG_NORESIZE;
obj.iSection = MODERNOPT_PAGE_STATUS;
obj.iType = MODERNOPT_TYPE_SECTIONPAGE;
diff --git a/src/modules/ignore/ignore.cpp b/src/modules/ignore/ignore.cpp
index bc9cf143f8..b5b88343d0 100644
--- a/src/modules/ignore/ignore.cpp
+++ b/src/modules/ignore/ignore.cpp
@@ -178,8 +178,8 @@ static void SetAllContactIcons(HWND hwndList)
szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
if (szProto == NULL) proto1Caps=proto4Caps=0;
else {
- proto1Caps=CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
- proto4Caps=CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0);
+ proto1Caps=CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ proto4Caps=CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_4, 0);
}
InitialiseItem(hwndList, hContact, hItem, proto1Caps, proto4Caps);
if ( !DBGetContactSettingByte(hContact, "CList", "Hidden", 0))
@@ -345,7 +345,7 @@ static int IgnoreOptInitialise(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.position = 900000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_IGNORE);
odp.pszTitle = LPGEN("Ignore");
odp.pszGroup = LPGEN("Events");
@@ -437,7 +437,7 @@ static int IgnoreModernOptInit(WPARAM wParam, LPARAM)
MODERNOPTOBJECT obj = {0};
obj.cbSize = sizeof(obj);
- obj.hInstance = hMirandaInst;
+ obj.hInstance = hInst;
obj.dwFlags = MODEROPT_FLG_TCHAR;
obj.iSection = MODERNOPT_PAGE_IGNORE;
obj.iType = MODERNOPT_TYPE_SECTIONPAGE;
diff --git a/src/modules/langpack/lpservices.cpp b/src/modules/langpack/lpservices.cpp
index 983d069fda..af4262783c 100644
--- a/src/modules/langpack/lpservices.cpp
+++ b/src/modules/langpack/lpservices.cpp
@@ -2,8 +2,8 @@
Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2009 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
+Copyright 2000-2009 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
@@ -11,7 +11,7 @@ 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,
+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.
@@ -22,104 +22,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "..\..\core\commonheaders.h"
-#define FLAGS LANG_UNICODE
-
-LangPackMuuid* __fastcall LangPackLookupUuid(WPARAM);
-int LangPackMarkPluginLoaded(PLUGININFOEX* pInfo);
+MIR_CORE_DLL(int) LangPackMarkPluginLoaded(PLUGININFOEX* pInfo);
/////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR TranslateString(WPARAM wParam, LPARAM lParam)
-{
- return (INT_PTR)LangPackTranslateString(LangPackLookupUuid(wParam), (const char *)lParam, (wParam & LANG_UNICODE) ? 1 : 0);
-}
-
-TCHAR* LangPackTranslateStringT(int hLangpack, const TCHAR* tszEnglish)
+static INT_PTR srvTranslateString(WPARAM wParam, LPARAM lParam)
{
- LangPackMuuid* pUuid = (hLangpack) ? LangPackLookupUuid(hLangpack) : 0;
- return (TCHAR*)LangPackTranslateString(pUuid, (LPCSTR)tszEnglish, 1);
+ if (wParam & LANG_UNICODE)
+ return (INT_PTR)TranslateW_LP((const WCHAR*)lParam, wParam);
+ return (INT_PTR)TranslateA_LP((const char *)lParam, wParam);
}
/////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR TranslateMenu(WPARAM wParam, LPARAM lParam)
-{
- HMENU hMenu = (HMENU)wParam;
- LangPackMuuid* uuid = LangPackLookupUuid(lParam);
-
- MENUITEMINFO mii;
- mii.cbSize = MENUITEMINFO_V4_SIZE;
- for (int i = GetMenuItemCount(hMenu)-1; i >= 0; i--) {
- TCHAR str[256];
- mii.fMask = MIIM_TYPE|MIIM_SUBMENU;
- mii.dwTypeData = (TCHAR*)str;
- mii.cch = SIZEOF(str);
- GetMenuItemInfo(hMenu, i, TRUE, &mii);
-
- if (mii.cch && mii.dwTypeData) {
- TCHAR* result = (TCHAR*)LangPackTranslateString(uuid, (const char*)mii.dwTypeData, FLAGS);
- if (result != mii.dwTypeData) {
- mii.dwTypeData = result;
- mii.fMask = MIIM_TYPE;
- SetMenuItemInfo(hMenu, i, TRUE, &mii);
- } }
-
- if (mii.hSubMenu != NULL) TranslateMenu((WPARAM)mii.hSubMenu, lParam);
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static void TranslateWindow(LangPackMuuid* pUuid, HWND hwnd)
-{
- TCHAR title[2048];
- GetWindowText(hwnd, title, SIZEOF(title));
- {
- TCHAR* result = (TCHAR*)LangPackTranslateString(pUuid, (const char*)title, FLAGS);
- if (result != title)
- SetWindowText(hwnd, result);
-} }
-
-static BOOL CALLBACK TranslateDialogEnumProc(HWND hwnd, LPARAM lParam)
-{
- LANGPACKTRANSLATEDIALOG *lptd = (LANGPACKTRANSLATEDIALOG*)lParam;
- TCHAR szClass[32];
- int i, id = GetDlgCtrlID(hwnd);
-
- if (lptd->ignoreControls != NULL)
- for (i=0; lptd->ignoreControls[i]; i++)
- if (lptd->ignoreControls[i] == id)
- return TRUE;
-
- LangPackMuuid* uuid = LangPackLookupUuid(lptd->flags);
-
- GetClassName(hwnd, szClass, SIZEOF(szClass));
- if ( !lstrcmpi(szClass, _T("static")) || !lstrcmpi(szClass, _T("hyperlink")) || !lstrcmpi(szClass, _T("button")) || !lstrcmpi(szClass, _T("MButtonClass")) || !lstrcmpi(szClass, _T("MHeaderbarCtrl")))
- TranslateWindow(uuid, hwnd);
- else if ( !lstrcmpi(szClass, _T("edit"))) {
- if (lptd->flags & LPTDF_NOIGNOREEDIT || GetWindowLongPtr(hwnd, GWL_STYLE) & ES_READONLY)
- TranslateWindow(uuid, hwnd);
- }
- return TRUE;
-}
-
-static INT_PTR TranslateDialog(WPARAM wParam, LPARAM lParam)
+static INT_PTR srvTranslateMenu(WPARAM wParam, LPARAM lParam)
{
- LANGPACKTRANSLATEDIALOG *lptd = (LANGPACKTRANSLATEDIALOG*)lParam;
- if (lptd == NULL || lptd->cbSize != sizeof(LANGPACKTRANSLATEDIALOG))
- return 1;
-
- if ( !(lptd->flags & LPTDF_NOTITLE))
- TranslateWindow(LangPackLookupUuid(lptd->flags), lptd->hwndDlg);
-
- EnumChildWindows(lptd->hwndDlg, TranslateDialogEnumProc, lParam);
+ TranslateMenu_LP((HMENU)wParam, lParam);
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR LPRegister(WPARAM wParam, LPARAM lParam)
+static INT_PTR srvRegisterLP(WPARAM wParam, LPARAM lParam)
{
*(int*)wParam = LangPackMarkPluginLoaded((PLUGININFOEX*)lParam);
return 0;
@@ -127,50 +51,51 @@ static INT_PTR LPRegister(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR GetDefaultCodePage(WPARAM, LPARAM)
+static INT_PTR srvGetDefaultCodePage(WPARAM, LPARAM)
{
return LangPackGetDefaultCodePage();
}
/////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR GetDefaultLocale(WPARAM, LPARAM)
+static INT_PTR srvGetDefaultLocale(WPARAM, LPARAM)
{
return LangPackGetDefaultLocale();
}
/////////////////////////////////////////////////////////////////////////////////////////
-static INT_PTR PcharToTchar(WPARAM wParam, LPARAM lParam)
+static INT_PTR srvPcharToTchar(WPARAM wParam, LPARAM lParam)
{
char* pszStr = (char*)lParam;
if (pszStr == NULL)
return NULL;
- LangPackMuuid* uuid = LangPackLookupUuid(wParam);
-
- { int len = (int)strlen(pszStr);
- TCHAR* result = (TCHAR*)alloca((len+1)*sizeof(TCHAR));
- MultiByteToWideChar(LangPackGetDefaultCodePage(), 0, pszStr, -1, result, len);
- result[len] = 0;
- return (INT_PTR)mir_wstrdup((wchar_t*)LangPackTranslateString(uuid, (char*)result, 1));
- }
+ int len = (int)strlen(pszStr);
+ TCHAR* result = (TCHAR*)alloca((len+1)*sizeof(TCHAR));
+ MultiByteToWideChar(LangPackGetDefaultCodePage(), 0, pszStr, -1, result, len);
+ result[len] = 0;
+ return (INT_PTR)mir_wstrdup( TranslateW_LP(result, wParam));
}
/////////////////////////////////////////////////////////////////////////////////////////
-INT_PTR ReloadLangpack(WPARAM wParam, LPARAM lParam);
+INT_PTR srvReloadLangpack(WPARAM wParam, LPARAM lParam)
+{
+ ReloadLangpack(( TCHAR* )lParam);
+ return 0;
+}
-int LoadLangPackServices(void)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int LoadLangPackModule(void)
{
- CreateServiceFunction(MS_LANGPACK_TRANSLATESTRING, TranslateString);
- CreateServiceFunction(MS_LANGPACK_TRANSLATEMENU, TranslateMenu);
- CreateServiceFunction(MS_LANGPACK_TRANSLATEDIALOG, TranslateDialog);
- CreateServiceFunction(MS_LANGPACK_GETCODEPAGE, GetDefaultCodePage);
- CreateServiceFunction(MS_LANGPACK_GETLOCALE, GetDefaultLocale);
- CreateServiceFunction(MS_LANGPACK_PCHARTOTCHAR, PcharToTchar);
- CreateServiceFunction(MS_LANGPACK_REGISTER, LPRegister);
- CreateServiceFunction(MS_LANGPACK_RELOAD, ReloadLangpack);
+ CreateServiceFunction(MS_LANGPACK_TRANSLATESTRING, srvTranslateString);
+ CreateServiceFunction(MS_LANGPACK_TRANSLATEMENU, srvTranslateMenu);
+ CreateServiceFunction(MS_LANGPACK_GETCODEPAGE, srvGetDefaultCodePage);
+ CreateServiceFunction(MS_LANGPACK_GETLOCALE, srvGetDefaultLocale);
+ CreateServiceFunction(MS_LANGPACK_PCHARTOTCHAR, srvPcharToTchar);
+ CreateServiceFunction(MS_LANGPACK_REGISTER, srvRegisterLP);
+ CreateServiceFunction(MS_LANGPACK_RELOAD, srvReloadLangpack);
return 0;
}
-
diff --git a/src/modules/netlib/netliblog.cpp b/src/modules/netlib/netliblog.cpp
index 5c4656fd90..3e1265d4dd 100644
--- a/src/modules/netlib/netliblog.cpp
+++ b/src/modules/netlib/netliblog.cpp
@@ -146,7 +146,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
GetWindowText((HWND)lParam, path, MAX_PATH);
TCHAR *pszNewPath = Utils_ReplaceVarsT(path);
- pathToAbsoluteT(pszNewPath, path, NULL);
+ PathToAbsoluteT(pszNewPath, path, NULL);
SetDlgItemText(hwndDlg, IDC_PATH, path);
mir_free(pszNewPath);
}
@@ -299,7 +299,7 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
void NetlibLogShowOptions(void)
{
if (logOptions.hwndOpts == NULL)
- logOptions.hwndOpts=CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_NETLIBLOGOPTS), NULL, LogOptionsDlgProc);
+ logOptions.hwndOpts=CreateDialog(hInst, MAKEINTRESOURCE(IDD_NETLIBLOGOPTS), NULL, LogOptionsDlgProc);
SetForegroundWindow(logOptions.hwndOpts);
}
@@ -397,11 +397,8 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
LeaveCriticalSection(&logOptions.cs);
}
- if (((THook*)hLogEvent)->subscriberCount)
- {
- LOGMSG logMsg = { szHead, pszMsg };
- CallHookSubscribers(hLogEvent, (WPARAM)nlu, (LPARAM)&logMsg);
- }
+ LOGMSG logMsg = { szHead, pszMsg };
+ CallHookSubscribers(hLogEvent, (WPARAM)nlu, (LPARAM)&logMsg);
SetLastError(dwOriginalLastError);
return 1;
@@ -410,7 +407,7 @@ static INT_PTR NetlibLog(WPARAM wParam, LPARAM lParam)
static INT_PTR NetlibLogW(WPARAM wParam, LPARAM lParam)
{
const wchar_t *pszMsg = (const wchar_t*)lParam;
- char* szMsg = Utf8EncodeUcs2(pszMsg);
+ char* szMsg = Utf8EncodeW(pszMsg);
INT_PTR res = NetlibLog(wParam, (LPARAM)szMsg);
mir_free(szMsg);
return res;
@@ -454,12 +451,9 @@ void NetlibDumpData(struct NetlibConnection *nlc, PBYTE buf, int len, int sent,
return;
// Check user's log settings
- if ( !(logOptions.toOutputDebugString ||
- ((THook*)hLogEvent)->subscriberCount ||
- (logOptions.toFile && logOptions.szFile[0])))
+ if ( !(logOptions.toOutputDebugString || (logOptions.toFile && logOptions.szFile[0])))
return;
- if ((sent && !logOptions.dumpSent) ||
- ( !sent && !logOptions.dumpRecv))
+ if ((sent && !logOptions.dumpSent) || (!sent && !logOptions.dumpRecv))
return;
if ((flags & MSG_DUMPPROXY) && !logOptions.dumpProxy)
return;
@@ -593,7 +587,7 @@ void NetlibLogInit(void)
TCHAR *pszNewPath = Utils_ReplaceVarsT(dbv.ptszVal);
TCHAR path[MAX_PATH];
- pathToAbsoluteT(pszNewPath, path, NULL);
+ PathToAbsoluteT(pszNewPath, path, NULL);
logOptions.szFile = mir_tstrdup(path);
mir_free(pszNewPath);
diff --git a/src/modules/netlib/netlibopts.cpp b/src/modules/netlib/netlibopts.cpp
index 20e90d9932..34a07d6df7 100644
--- a/src/modules/netlib/netlibopts.cpp
+++ b/src/modules/netlib/netlibopts.cpp
@@ -546,7 +546,7 @@ int NetlibOptInitialise(WPARAM wParam, LPARAM)
odp.cbSize = sizeof(odp);
odp.position = 900000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NETLIB);
odp.pszTitle = LPGEN("Network");
odp.pfnDlgProc = DlgProcNetlibOpts;
diff --git a/src/modules/netlib/netlibsock.cpp b/src/modules/netlib/netlibsock.cpp
index eabbc79484..30db9ce256 100644
--- a/src/modules/netlib/netlibsock.cpp
+++ b/src/modules/netlib/netlibsock.cpp
@@ -58,11 +58,9 @@ INT_PTR NetlibSend(WPARAM wParam, LPARAM lParam)
}
NetlibLeaveNestedCS(&nlc->ncsSend);
- if (((THook*)hSendEvent)->subscriberCount)
- {
- NETLIBNOTIFY nln = { nlb, result };
- CallHookSubscribers(hSendEvent, (WPARAM)&nln, (LPARAM)&nlc->nlu->user);
- }
+ NETLIBNOTIFY nln = { nlb, result };
+ CallHookSubscribers(hSendEvent, (WPARAM)&nln, (LPARAM)&nlc->nlu->user);
+
return result;
}
@@ -95,8 +93,7 @@ INT_PTR NetlibRecv(WPARAM wParam, LPARAM lParam)
NetlibDumpData(nlc, (PBYTE)nlb->buf, recvResult, 0, nlb->flags);
- if ((nlb->flags & MSG_PEEK) == 0 && ((THook*)hRecvEvent)->subscriberCount)
- {
+ if ((nlb->flags & MSG_PEEK) == 0) {
NETLIBNOTIFY nln = { nlb, recvResult };
CallHookSubscribers(hRecvEvent, (WPARAM)&nln, (LPARAM)&nlc->nlu->user);
}
diff --git a/src/modules/options/descbutton.cpp b/src/modules/options/descbutton.cpp
index d4ceed2d44..813779f375 100644
--- a/src/modules/options/descbutton.cpp
+++ b/src/modules/options/descbutton.cpp
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
#include "m_descbutton.h"
-extern HINSTANCE hMirandaInst;
+extern HINSTANCE hInst;
////////////////////////////////////////////////////////////////////////////////////
// Internals
diff --git a/src/modules/options/filter.cpp b/src/modules/options/filter.cpp
index 2ea0aa4752..8b72f4e67d 100644
--- a/src/modules/options/filter.cpp
+++ b/src/modules/options/filter.cpp
@@ -192,7 +192,7 @@ static int OnOptionsInitialise(WPARAM wParam, LPARAM)
odp.cbSize = sizeof(odp);
odp.position = -190000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_KEYWORDFILTER);
odp.pszTitle = LPGEN("Options search");
odp.pszGroup = LPGEN("Customize");
diff --git a/src/modules/options/filter.h b/src/modules/options/filter.h
index d64801eee5..ced8845b95 100644
--- a/src/modules/options/filter.h
+++ b/src/modules/options/filter.h
@@ -98,10 +98,5 @@ public:
~CPageList() {};
};
-
-
-int LangPackGetDefaultLocale();
-
-
#endif //M_OPTIONS_FILTERING_H
diff --git a/src/modules/options/headerbar.cpp b/src/modules/options/headerbar.cpp
index 66661b9983..44a729089d 100644
--- a/src/modules/options/headerbar.cpp
+++ b/src/modules/options/headerbar.cpp
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
#include "m_iconheader.h"
-extern HINSTANCE hMirandaInst;
+extern HINSTANCE hInst;
static BOOL IsAeroMode()
diff --git a/src/modules/options/iconheader.cpp b/src/modules/options/iconheader.cpp
index 01a3bc99bf..e3f27c8289 100644
--- a/src/modules/options/iconheader.cpp
+++ b/src/modules/options/iconheader.cpp
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "m_iconheader.h"
-extern HINSTANCE hMirandaInst;
+extern HINSTANCE hInst;
static BOOL IsAeroMode()
{
diff --git a/src/modules/options/options.cpp b/src/modules/options/options.cpp
index aa6180a972..e949ff31c5 100644
--- a/src/modules/options/options.cpp
+++ b/src/modules/options/options.cpp
@@ -236,7 +236,7 @@ static TCHAR *GetPluginName(HINSTANCE hInstance, TCHAR *buffer, int size)
PageHash GetPluginPageHash(const OptionsPageData *page)
{
- return hashstr(page->ptszGroup) + hashstr(page->ptszTitle) + hashstr(page->ptszTab);
+ return mir_hashstrT(page->ptszGroup) + mir_hashstrT(page->ptszTitle) + mir_hashstrT(page->ptszTab);
}
static void FindFilterStrings(int enableKeywordFiltering, int current, HWND hWndParent, const OptionsPageData *page)
@@ -497,7 +497,7 @@ static void FillFilterCombo(int enableKeywordFiltering, HWND hDlg, OptionsDlgDat
int index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_ADDSTRING, (WPARAM)0, (LPARAM)TranslateTS(ALL_MODULES_FILTER));
SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_SETITEMDATA, (WPARAM)index, (LPARAM)NULL);
index = SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_ADDSTRING, (WPARAM)0, (LPARAM)TranslateTS(CORE_MODULES_FILTER));
- SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_SETITEMDATA, (WPARAM)index, (LPARAM)hMirandaInst);
+ SendDlgItemMessage(hDlg, IDC_KEYWORD_FILTER, (UINT) CB_SETITEMDATA, (WPARAM)index, (LPARAM)hInst);
TCHAR* tszModuleName = (TCHAR*)alloca(MAX_PATH*sizeof(TCHAR));
for (int i = 0; i < dat->arOpd.getCount(); i++) {
TCHAR * dllName = NULL;
@@ -507,7 +507,7 @@ static void FillFilterCombo(int enableKeywordFiltering, HWND hDlg, OptionsDlgDat
if ( !enableKeywordFiltering)
FindFilterStrings(enableKeywordFiltering, FALSE, hDlg, dat->arOpd[i]); // only modules name (fast enougth)
- if (inst == hMirandaInst) continue;
+ if (inst == hInst) continue;
for (j = 0; j<countKnownInst; j++)
if (KnownInstances[j] == inst) break;
if (j != countKnownInst) continue;
@@ -839,9 +839,9 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
continue;
OptionsPageData* opd = dat->arOpd[i];
- TCHAR* ptszGroup = LangPackTranslateStringT(opd->hLangpack, opd->ptszGroup);
- TCHAR* ptszTitle = LangPackTranslateStringT(opd->hLangpack, opd->ptszTitle);
- TCHAR* ptszTab = LangPackTranslateStringT(opd->hLangpack, opd->ptszTab);
+ TCHAR* ptszGroup = TranslateTH(opd->hLangpack, opd->ptszGroup);
+ TCHAR* ptszTitle = TranslateTH(opd->hLangpack, opd->ptszTitle);
+ TCHAR* ptszTab = TranslateTH(opd->hLangpack, opd->ptszTab);
tvis.hParent = NULL;
if (FilterInst != NULL) {
@@ -1089,7 +1089,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hdlg, UINT message, WPARAM wParam, L
if ( lstrcmp(opd->ptszTitle, p->ptszTitle) || lstrcmpnull(opd->ptszGroup, p->ptszGroup))
continue;
- tie.pszText = LangPackTranslateStringT(opd->hLangpack, opd->ptszTab);
+ tie.pszText = TranslateTH(opd->hLangpack, opd->ptszTab);
tie.lParam = i;
TabCtrl_InsertItem(hwndTab, pages, &tie);
if ( !lstrcmp(opd->ptszTab, p->ptszTab))
@@ -1390,7 +1390,7 @@ void OpenAccountOptions(PROTOACCOUNT* pa)
psh.pStartPage = (LPCTSTR)&ood;
psh.pszCaption = tszTitle;
psh.ppsp = (PROPSHEETPAGE*)opi.odp;
- hwndOptions = CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_OPTIONSPAGE), NULL, OptionsDlgProc, (LPARAM)&psh);
+ hwndOptions = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_OPTIONSPAGE), NULL, OptionsDlgProc, (LPARAM)&psh);
mir_free((void*)ood.pszPage);
FreeOptionsData(&opi);
} }
@@ -1436,7 +1436,7 @@ static void OpenOptionsNow(const char *pszGroup, const char *pszPage, const char
psh.pszCaption = TranslateT("Miranda IM Options");
psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell
- hwndOptions = CreateDialogParam(hMirandaInst,
+ hwndOptions = CreateDialogParam(hInst,
MAKEINTRESOURCE(bSinglePage ? IDD_OPTIONSPAGE : IDD_OPTIONS),
NULL, OptionsDlgProc, (LPARAM)&psh);
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp
index 64eff30f5b..391e76408d 100644
--- a/src/modules/plugins/newplugins.cpp
+++ b/src/modules/plugins/newplugins.cpp
@@ -2,7 +2,7 @@
Miranda IM: the free IM client for Microsoft* Windows*
-Copyright 2000-2010 Miranda ICQ/IM project,
+Copyright 2000-2010 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
@@ -11,7 +11,7 @@ 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,
+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.
@@ -23,19 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
#include "plugins.h"
-static int sttComparePlugins(const pluginEntry* p1, const pluginEntry* p2)
-{
- if (p1->bpi.hInst == p2->bpi.hInst)
- return 0;
-
- return (p1->bpi.hInst < p2->bpi.hInst) ? -1 : 1;
-}
-
static int sttComparePluginsByName(const pluginEntry* p1, const pluginEntry* p2)
{ return lstrcmp(p1->pluginname, p2->pluginname);
}
-LIST<pluginEntry> pluginList(10, sttComparePluginsByName), pluginListAddr(10, sttComparePlugins);
+LIST<pluginEntry> pluginList(10, sttComparePluginsByName);
/////////////////////////////////////////////////////////////////////////////////////////
@@ -44,8 +36,8 @@ LIST<pluginEntry> pluginList(10, sttComparePluginsByName), pluginListAddr(10, st
struct PluginUUIDList {
MUUID uuid;
DWORD maxVersion;
-}
-static const pluginBannedList[] =
+}
+static const pluginBannedList[] =
{
{{0x7f65393b, 0x7771, 0x4f3f, { 0xa9, 0xeb, 0x5d, 0xba, 0xf2, 0xb3, 0x61, 0xf1 }}, MAX_MIR_VER}, // png2dib
{{0xe00f1643, 0x263c, 0x4599, { 0xb8, 0x4b, 0x05, 0x3e, 0x5c, 0x51, 0x1d, 0x28 }}, MAX_MIR_VER}, // loadavatars (unicode)
@@ -73,8 +65,6 @@ void UninitIni(void);
#define PLUGINDISABLELIST "PluginDisable"
-int CallHookSubscribers(HANDLE hEvent, WPARAM wParam, LPARAM lParam);
-
int LoadDatabaseModule(void);
char* GetPluginNameByInstance(HINSTANCE hInstance)
@@ -89,29 +79,6 @@ char* GetPluginNameByInstance(HINSTANCE hInstance)
return NULL;
}
-HINSTANCE GetInstByAddress(void* codePtr)
-{
- int idx;
- HINSTANCE result;
- pluginEntry p; p.bpi.hInst = (HINSTANCE)codePtr;
-
- if (pluginListAddr.getCount() == 0)
- return NULL;
-
- List_GetIndex((SortedList*)&pluginListAddr, &p, &idx);
- if (idx > 0)
- idx--;
-
- result = pluginListAddr[idx]->bpi.hInst;
-
- if (result < hMirandaInst && codePtr > hMirandaInst)
- result = hMirandaInst;
- else if (idx == 0 && codePtr < (void*)result)
- result = NULL;
-
- return result;
-}
-
int equalUUID(const MUUID& u1, const MUUID& u2)
{
return memcmp(&u1, &u2, sizeof(MUUID))?0:1;
@@ -159,22 +126,22 @@ static int isPluginBanned(MUUID u1, DWORD dwVersion)
* historyeditor added by nightwish - plugin is problematic and can ruin database as it does not understand UTF-8 message
* storage
*/
-
-static const TCHAR* modulesToSkip[] =
-{
- _T("autoloadavatars.dll"), _T("multiwindow.dll"), _T("fontservice.dll"),
- _T("icolib.dll"), _T("historyeditor.dll")
+
+static const TCHAR* modulesToSkip[] =
+{
+ _T("autoloadavatars.dll"), _T("multiwindow.dll"), _T("fontservice.dll"),
+ _T("icolib.dll"), _T("historyeditor.dll")
};
// The following plugins will be checked for a valid MUUID or they will not be loaded
-static const TCHAR* expiredModulesToSkip[] =
-{
- _T("scriver.dll"), _T("nconvers.dll"), _T("tabsrmm.dll"), _T("nhistory.dll"),
- _T("historypp.dll"), _T("help.dll"), _T("loadavatars.dll"), _T("tabsrmm_unicode.dll"),
- _T("clist_nicer_plus.dll"), _T("changeinfo.dll"), _T("png2dib.dll"), _T("dbx_mmap.dll"),
- _T("dbx_3x.dll"), _T("sramm.dll"), _T("srmm_mod.dll"), _T("srmm_mod (no Unicode).dll"),
- _T("singlemodeSRMM.dll"), _T("msg_export.dll"), _T("clist_modern.dll"),
- _T("clist_nicer.dll")
+static const TCHAR* expiredModulesToSkip[] =
+{
+ _T("scriver.dll"), _T("nconvers.dll"), _T("tabsrmm.dll"), _T("nhistory.dll"),
+ _T("historypp.dll"), _T("help.dll"), _T("loadavatars.dll"), _T("tabsrmm_unicode.dll"),
+ _T("clist_nicer_plus.dll"), _T("changeinfo.dll"), _T("png2dib.dll"), _T("dbx_mmap.dll"),
+ _T("dbx_3x.dll"), _T("sramm.dll"), _T("srmm_mod.dll"), _T("srmm_mod (no Unicode).dll"),
+ _T("singlemodeSRMM.dll"), _T("msg_export.dll"), _T("clist_modern.dll"),
+ _T("clist_nicer.dll")
};
static int checkPI(BASIC_PLUGIN_INFO* bpi, PLUGININFOEX* pi)
@@ -191,16 +158,16 @@ static int checkPI(BASIC_PLUGIN_INFO* bpi, PLUGININFOEX* pi)
bHasValidInfo = TRUE;
}
-
+
if ( !bHasValidInfo)
return FALSE;
- if (pi->shortName == NULL || pi->description == NULL || pi->author == NULL ||
+ if (pi->shortName == NULL || pi->description == NULL || pi->author == NULL ||
pi->authorEmail == NULL || pi->copyright == NULL || pi->homepage == NULL)
return FALSE;
- if (pi->replacesDefaultModule > DEFMOD_HIGHEST ||
- pi->replacesDefaultModule == DEFMOD_REMOVED_UIPLUGINOPTS ||
+ if (pi->replacesDefaultModule > DEFMOD_HIGHEST ||
+ pi->replacesDefaultModule == DEFMOD_REMOVED_UIPLUGINOPTS ||
pi->replacesDefaultModule == DEFMOD_REMOVED_PROTOCOLNETLIB)
return FALSE;
@@ -342,8 +309,8 @@ void Plugin_Uninit(pluginEntry* p, bool bDynamic)
FreeLibrary(p->bpi.hInst);
ZeroMemory(&p->bpi, sizeof(p->bpi));
}
+ UnregisterModule(p->bpi.hInst);
pluginList.remove(p);
- pluginListAddr.remove(p);
}
void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam)
@@ -494,7 +461,7 @@ int isPluginOnWhiteList(const TCHAR* pluginname)
if (MessageBox(NULL, buf, TranslateT("Re-enable Miranda plugin?"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
SetPluginOnWhiteList(pluginname, 1);
rc = 0;
- }
+ }
}
return rc == 0;
@@ -526,16 +493,16 @@ bool TryLoadPlugin(pluginEntry *p, bool bDynamic)
return false;
}
- pluginListAddr.insert(p);
+ RegisterModule(p->bpi.hInst);
if (bpi.Load(&pluginCoreLink) != 0)
return false;
-
+
p->pclass |= PCLASS_LOADED;
if (rm) pluginDefModList[rm]=p;
}
}
else if (p->bpi.hInst != NULL) {
- pluginListAddr.insert(p);
+ RegisterModule(p->bpi.hInst);
p->pclass |= PCLASS_LOADED;
}
return true;
@@ -552,7 +519,7 @@ static pluginEntry* getCListModule(TCHAR * exe, TCHAR * slice, int useWhiteList)
if (checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_CLIST)) {
p->bpi = bpi;
p->pclass |= PCLASS_LAST | PCLASS_OK | PCLASS_BASICAPI;
- pluginListAddr.insert(p);
+ RegisterModule(p->bpi.hInst);
if (bpi.clistlink(&pluginCoreLink) == 0) {
p->bpi = bpi;
p->pclass |= PCLASS_LOADED;
@@ -575,7 +542,7 @@ int UnloadPlugin(TCHAR* buf, int bufLen)
GetModuleFileName(p->bpi.hInst, buf, bufLen);
Plugin_Uninit(p);
return TRUE;
- }
+ }
}
return FALSE;
@@ -625,7 +592,7 @@ int LoadServiceModePlugin(void)
p->pclass |= PCLASS_LOADED;
if (CallService(MS_SERVICEMODE_LAUNCH, 0, 0) != CALLSERVICE_NOTFOUND)
return 1;
-
+
MessageBox(NULL, TranslateT("Unable to load plugin in Service Mode!"), p->pluginname, 0);
return -1;
}
@@ -672,7 +639,7 @@ int LoadNewPluginsModule(void)
askAboutIgnoredPlugins=(UINT) GetPrivateProfileInt(_T("PluginLoader"), _T("AskAboutIgnoredPlugins"), 0, mirandabootini);
// if Crash Dumper is present, load it to provide Crash Reports
- if (pluginList_crshdmp != NULL && isPluginOnWhiteList(pluginList_crshdmp->pluginname))
+ if (pluginList_crshdmp != NULL && isPluginOnWhiteList(pluginList_crshdmp->pluginname))
{
if (pluginList_crshdmp->bpi.Load(&pluginCoreLink) == 0)
pluginList_crshdmp->pclass |= PCLASS_LOADED | PCLASS_LAST;
@@ -775,7 +742,7 @@ int LoadNewPluginsModuleInfos(void)
pluginCoreLink.KillObjectEventHooks = KillObjectEventHooks;
// remember where the mirandaboot.ini goes
- pathToAbsoluteT(_T("mirandaboot.ini"), mirandabootini, NULL);
+ PathToAbsoluteT(_T("mirandaboot.ini"), mirandabootini, NULL);
// look for all *.dll's
enumPlugins(scanPluginsDir, 0, 0);
// the database will select which db plugin to use, or fail if no profile is selected
@@ -817,6 +784,5 @@ void UnloadNewPluginsModule(void)
hPluginListHeap=0;
pluginList.destroy();
- pluginListAddr.destroy();
UninitIni();
}
diff --git a/src/modules/plugins/pluginopts.cpp b/src/modules/plugins/pluginopts.cpp
index b87c86b8e5..a62dc08378 100644
--- a/src/modules/plugins/pluginopts.cpp
+++ b/src/modules/plugins/pluginopts.cpp
@@ -403,7 +403,7 @@ int PluginOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pfnDlgProc = DlgPluginOpt;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_PLUGINS);
odp.position = 1300000000;
diff --git a/src/modules/plugins/plugins.h b/src/modules/plugins/plugins.h
index 6b03fad7c0..fe6de60b8c 100644
--- a/src/modules/plugins/plugins.h
+++ b/src/modules/plugins/plugins.h
@@ -50,7 +50,7 @@ struct pluginEntry
pluginEntry* nextclass;
};
-extern LIST<pluginEntry> pluginList, pluginListAddr;
+extern LIST<pluginEntry> pluginList;
extern MUUID miid_last;
int PluginOptionsInit(WPARAM, LPARAM);
diff --git a/src/modules/protocols/protoaccs.cpp b/src/modules/protocols/protoaccs.cpp
index 891474baed..4846d84b87 100644
--- a/src/modules/protocols/protoaccs.cpp
+++ b/src/modules/protocols/protoaccs.cpp
@@ -375,7 +375,7 @@ static INT_PTR stub43(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam)
PROTO_AVATAR_INFORMATIONW tmp = { 0 };
tmp.cbSize = sizeof(tmp);
tmp.hContact = p->hContact;
- int result = CallProtoService(ppi->m_szModuleName, PS_GETAVATARINFOW, wParam, (LPARAM)&tmp);
+ int result = CallProtoServiceInt(NULL,ppi->m_szModuleName, PS_GETAVATARINFOW, wParam, (LPARAM)&tmp);
p->format = tmp.format;
@@ -390,7 +390,7 @@ static INT_PTR stub43(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam)
static INT_PTR stub44(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam)
{
wchar_t* buf = (wchar_t*)_alloca(sizeof(wchar_t) * (lParam + 1));
- int result = CallProtoService(ppi->m_szModuleName, PS_GETMYAVATARW, WPARAM(buf), lParam);
+ int result = CallProtoServiceInt(NULL,ppi->m_szModuleName, PS_GETMYAVATARW, WPARAM(buf), lParam);
if (result == 0)
{
wchar_t* filename = (wchar_t*)_alloca(sizeof(wchar_t) * (lParam + 1));
@@ -405,7 +405,7 @@ static INT_PTR stub44(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam)
static INT_PTR stub45(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam)
{
- return CallProtoService(ppi->m_szModuleName, PS_SETMYAVATARW, wParam, (LPARAM)(LPCTSTR)StrConvT((char*)lParam));
+ return CallProtoServiceInt(NULL,ppi->m_szModuleName, PS_SETMYAVATARW, wParam, (LPARAM)(LPCTSTR)StrConvT((char*)lParam));
}
diff --git a/src/modules/protocols/protochains.cpp b/src/modules/protocols/protochains.cpp
index 73a12d2bd5..05d39b07e4 100644
--- a/src/modules/protocols/protochains.cpp
+++ b/src/modules/protocols/protochains.cpp
@@ -42,7 +42,7 @@ INT_PTR Proto_CallContactService(WPARAM wParam, LPARAM lParam)
if (DBGetContactSettingString(ccs->hContact, "_Filter", str, &dbv))
break;
- if ((ret = CallProtoService(dbv.pszVal, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) {
+ if ((ret = CallProtoServiceInt(NULL,dbv.pszVal, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) {
//chain was started, exit
mir_free(dbv.pszVal);
return ret;
@@ -93,7 +93,7 @@ static INT_PTR CallRecvChain(WPARAM wParam, LPARAM lParam)
if (DBGetContactSettingString(ccs->hContact, "_Filter", str, &dbv)) //never happens
return 1;
- if ((ret = CallProtoService(dbv.pszVal, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) {
+ if ((ret = CallProtoServiceInt(NULL,dbv.pszVal, ccs->szProtoService, i+1, lParam)) != CALLSERVICE_NOTFOUND) {
//chain was started, exit
mir_free(dbv.pszVal);
return ret;
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp
index 1ec4872e23..69f3c846cd 100644
--- a/src/modules/protocols/protocols.cpp
+++ b/src/modules/protocols/protocols.cpp
@@ -262,7 +262,7 @@ static int Proto_ValidTypingContact(HANDLE hContact, char *szProto)
if ( !hContact || !szProto)
return 0;
- return (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_SUPPORTTYPING) ? 1 : 0;
+ return (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_SUPPORTTYPING) ? 1 : 0;
}
static INT_PTR Proto_SelfIsTyping(WPARAM wParam, LPARAM lParam)
@@ -273,7 +273,7 @@ static INT_PTR Proto_SelfIsTyping(WPARAM wParam, LPARAM lParam)
return 0;
if (Proto_ValidTypingContact((HANDLE)wParam, szProto))
- CallProtoService(szProto, PSS_USERISTYPING, wParam, lParam);
+ CallProtoServiceInt(NULL,szProto, PSS_USERISTYPING, wParam, lParam);
}
return 0;
@@ -300,7 +300,7 @@ static INT_PTR Proto_ContactIsTyping(WPARAM wParam, LPARAM lParam)
void Proto_SetStatus(const char* szProto, unsigned status)
{
- if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)
+ if (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND)
{
TCHAR* awayMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGW, (WPARAM) status, (LPARAM) szProto);
if ((INT_PTR)awayMsg == CALLSERVICE_NOTFOUND)
@@ -314,10 +314,10 @@ void Proto_SetStatus(const char* szProto, unsigned status)
}
if ((INT_PTR)awayMsg != CALLSERVICE_NOTFOUND)
{
- CallProtoService(szProto, PS_SETAWAYMSGT, status, (LPARAM) awayMsg);
+ CallProtoServiceInt(NULL,szProto, PS_SETAWAYMSGT, status, (LPARAM) awayMsg);
mir_free(awayMsg);
} }
- CallProtoService(szProto, PS_SETSTATUS, status, 0);
+ CallProtoServiceInt(NULL,szProto, PS_SETSTATUS, status, 0);
}
@@ -398,6 +398,11 @@ static INT_PTR srvProto_IsAccountLocked(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
+INT_PTR CallProtoService(const char* szModule, const char* szService, WPARAM wParam, LPARAM lParam)
+{
+ return CallProtoServiceInt(NULL, szModule, szService, wParam, lParam);
+}
+
INT_PTR CallProtoServiceInt(HANDLE hContact, const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam)
{
PROTOACCOUNT* pa = Proto_GetAccount(szModule);
@@ -405,196 +410,186 @@ INT_PTR CallProtoServiceInt(HANDLE hContact, const char *szModule, const char *s
PROTO_INTERFACE* ppi;
if ((ppi = pa->ppro) == NULL)
return CALLSERVICE_NOTFOUND;
- else {
- TServiceListItem *item = serviceItems.find((TServiceListItem*)&szService);
- if (item) {
- switch(item->id) {
- case 1:
-
- if (ppi->m_iVersion > 1 || !(((PROTOSEARCHRESULT*)lParam)->flags & PSR_UNICODE))
- return (INT_PTR)ppi->AddToList(wParam, (PROTOSEARCHRESULT*)lParam);
- else {
- PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)lParam;
- PROTOSEARCHRESULT *psra =(PROTOSEARCHRESULT*)mir_alloc(psr->cbSize);
- memcpy(psra, psr, psr->cbSize);
- psra->nick = (PROTOCHAR*)mir_u2a(psr->nick);
- psra->firstName = (PROTOCHAR*)mir_u2a(psr->firstName);
- psra->lastName = (PROTOCHAR*)mir_u2a(psr->lastName);
- psra->email = (PROTOCHAR*)mir_u2a(psr->email);
+
+ TServiceListItem *item = serviceItems.find((TServiceListItem*)&szService);
+ if (item) {
+ switch(item->id) {
+ case 1:
+ if (ppi->m_iVersion > 1 || !(((PROTOSEARCHRESULT*)lParam)->flags & PSR_UNICODE))
+ return (INT_PTR)ppi->AddToList(wParam, (PROTOSEARCHRESULT*)lParam);
+ else {
+ PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)lParam;
+ PROTOSEARCHRESULT *psra =(PROTOSEARCHRESULT*)mir_alloc(psr->cbSize);
+ memcpy(psra, psr, psr->cbSize);
+ psra->nick = (PROTOCHAR*)mir_u2a(psr->nick);
+ psra->firstName = (PROTOCHAR*)mir_u2a(psr->firstName);
+ psra->lastName = (PROTOCHAR*)mir_u2a(psr->lastName);
+ psra->email = (PROTOCHAR*)mir_u2a(psr->email);
- INT_PTR res = (INT_PTR)ppi->AddToList(wParam, psra);
+ INT_PTR res = (INT_PTR)ppi->AddToList(wParam, psra);
- mir_free(psra->nick);
- mir_free(psra->firstName);
- mir_free(psra->lastName);
- mir_free(psra->email);
- mir_free(psra);
+ mir_free(psra->nick);
+ mir_free(psra->firstName);
+ mir_free(psra->lastName);
+ mir_free(psra->email);
+ mir_free(psra);
- return res;
- }
-
- case 2: return (INT_PTR)ppi->AddToListByEvent(LOWORD(wParam), HIWORD(wParam), (HANDLE)lParam);
- case 3: return (INT_PTR)ppi->Authorize((HANDLE)wParam);
- case 4:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, StrConvT((char*)lParam));
- else
- return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, (PROTOCHAR*)lParam);
- case 5: return (INT_PTR)ppi->AuthRecv(hContact, (PROTORECVEVENT*)lParam);
- case 6:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->AuthRequest(hContact, StrConvT((char*)lParam));
- else
- return (INT_PTR)ppi->AuthRequest(hContact, (PROTOCHAR*)lParam);
- case 7: return (INT_PTR)ppi->ChangeInfo(wParam, (void*)lParam);
- case 8:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, StrConvT((char*)lParam));
- else
- return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, (PROTOCHAR*)lParam);
- case 9: return (INT_PTR)ppi->FileCancel(hContact, (HANDLE)wParam);
- case 10:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, StrConvT((char*)lParam));
- else
- return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, (PROTOCHAR*)lParam);
- case 11: {
- PROTOFILERESUME* pfr = (PROTOFILERESUME*)lParam;
-
- if (ppi->m_iVersion > 1) {
- PROTOCHAR* szFname = mir_a2t((char*)pfr->szFilename);
- INT_PTR res = (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action,
- (const PROTOCHAR**)&szFname);
- mir_free((PROTOCHAR*)pfr->szFilename);
- pfr->szFilename = (PROTOCHAR*)mir_t2a(szFname); mir_free(szFname);
- }
- else
-
- return (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action,
- (const PROTOCHAR**)&pfr->szFilename);
- }
- case 12: return (INT_PTR)ppi->GetCaps(wParam, (HANDLE)lParam);
- case 13: return (INT_PTR)ppi->GetIcon(wParam);
- case 14: return (INT_PTR)ppi->GetInfo(hContact, wParam);;
- case 15:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->SearchBasic(StrConvT((char*)lParam));
- else
- return (INT_PTR)ppi->SearchBasic((TCHAR*)lParam);
- case 16:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->SearchByEmail(StrConvT((char*)lParam));
- else
- return (INT_PTR)ppi->SearchByEmail((TCHAR*)lParam);
- case 17: {
- PROTOSEARCHBYNAME* psbn = (PROTOSEARCHBYNAME*)lParam;
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->SearchByName(StrConvT((char*)psbn->pszNick),
- StrConvT((char*)psbn->pszFirstName), StrConvT((char*)psbn->pszLastName));
- else
- return (INT_PTR)ppi->SearchByName(psbn->pszNick, psbn->pszFirstName, psbn->pszLastName);
- }
- case 18: return (INT_PTR)ppi->SearchAdvanced((HWND)lParam);
- case 19: return (INT_PTR)ppi->CreateExtendedSearchUI ((HWND)lParam);
- case 20: return (INT_PTR)ppi->RecvContacts(hContact, (PROTORECVEVENT*)lParam);
- case 21: return (INT_PTR)ppi->RecvFile(hContact, (PROTOFILEEVENT*)lParam);
- case 22: return (INT_PTR)ppi->RecvMsg(hContact, (PROTORECVEVENT*)lParam);
- case 23: return (INT_PTR)ppi->RecvUrl(hContact, (PROTORECVEVENT*)lParam);
- case 24: return (INT_PTR)ppi->SendContacts(hContact, LOWORD(wParam), HIWORD(wParam),
- (HANDLE*)lParam);
- case 25:
-
- if (ppi->m_iVersion > 1) {
- TCHAR** files = Proto_FilesMatrixU((char**)lParam);
- INT_PTR res = (INT_PTR)ppi->SendFile(hContact, StrConvT((char*)wParam), (TCHAR**)files);
- if (res == 0) FreeFilesMatrix(&files);
- return res;
- }
- else
-
- return (INT_PTR)ppi->SendFile(hContact, (TCHAR*)wParam, (TCHAR**)lParam);
- case 26: return (INT_PTR)ppi->SendMsg(hContact, wParam, (const char*)lParam);
- case 27: return (INT_PTR)ppi->SendUrl(hContact, wParam, (const char*)lParam);
- case 28: return (INT_PTR)ppi->SetApparentMode(hContact, wParam);
- case 29: return (INT_PTR)ppi->SetStatus(wParam);
- case 30: return (INT_PTR)ppi->GetAwayMsg(hContact);
- case 31: return (INT_PTR)ppi->RecvAwayMsg(hContact, wParam, (PROTORECVEVENT*)lParam);
- case 32: return (INT_PTR)ppi->SendAwayMsg(hContact, (HANDLE)wParam, (const char*)lParam);
- case 33:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->SetAwayMsg(wParam, StrConvT((char*)lParam));
- else
- return (INT_PTR)ppi->SetAwayMsg(wParam, (TCHAR*)lParam);
- case 34: return (INT_PTR)ppi->UserIsTyping((HANDLE)wParam, lParam);
- case 35: lstrcpynA((char*)lParam, ppi->m_szModuleName, wParam); return 0;
- case 36: return ppi->m_iStatus;
-
-
- case 100:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->SetAwayMsg(wParam, (TCHAR*)lParam);
- else
- return (INT_PTR)ppi->SetAwayMsg(wParam, StrConvA((TCHAR*)lParam));
- case 102:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->SendFile(hContact, (TCHAR*)wParam, (TCHAR**)lParam);
- else {
- char** files = Proto_FilesMatrixA((TCHAR**)lParam);
- INT_PTR res = (INT_PTR)ppi->SendFile(hContact, StrConvA((TCHAR*)wParam), (TCHAR**)files);
- if (res == 0) FreeFilesMatrix((TCHAR***)&files);
- return res;
- }
- case 103:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, (TCHAR*)lParam);
- else
- return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, StrConvA((TCHAR*)lParam));
- case 104:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, (TCHAR*)lParam);
- else
- return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, StrConvA((TCHAR*)lParam));
- case 105: {
- PROTOFILERESUME* pfr = (PROTOFILERESUME*)lParam;
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action,
- (const PROTOCHAR**)&pfr->szFilename);
- else {
- char* szFname = mir_t2a(pfr->szFilename);
- INT_PTR res = (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action,
- (const PROTOCHAR**)&szFname);
- mir_free(szFname);
- } }
- case 106:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->AuthRequest(hContact, (const TCHAR*)lParam);
- else
- return (INT_PTR)ppi->AuthRequest(hContact, StrConvA((const TCHAR*)lParam));
- case 107:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, (const TCHAR*)lParam);
- else
- return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, StrConvA((const TCHAR*)lParam));
- case 108:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->SearchBasic((const TCHAR*)lParam);
- else
- return (INT_PTR)ppi->SearchBasic(StrConvA((const TCHAR*)lParam));
- case 109: {
- PROTOSEARCHBYNAME* psbn = (PROTOSEARCHBYNAME*)lParam;
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->SearchByName(psbn->pszNick, psbn->pszFirstName, psbn->pszLastName);
- else
- return (INT_PTR)ppi->SearchByName(StrConvA((TCHAR*)psbn->pszNick),
- StrConvA((TCHAR*)psbn->pszFirstName), StrConvA((TCHAR*)psbn->pszLastName));
- }
- case 110:
- if (ppi->m_iVersion > 1)
- return (INT_PTR)ppi->SearchByEmail((const TCHAR*)lParam);
- else
- return (INT_PTR)ppi->SearchByEmail(StrConvA((const TCHAR*)lParam));
-
- } } } }
+ return res;
+ }
+
+ case 2: return (INT_PTR)ppi->AddToListByEvent(LOWORD(wParam), HIWORD(wParam), (HANDLE)lParam);
+ case 3: return (INT_PTR)ppi->Authorize((HANDLE)wParam);
+ case 4:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, StrConvT((char*)lParam));
+ else
+ return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, (PROTOCHAR*)lParam);
+ case 5: return (INT_PTR)ppi->AuthRecv(hContact, (PROTORECVEVENT*)lParam);
+ case 6:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->AuthRequest(hContact, StrConvT((char*)lParam));
+ else
+ return (INT_PTR)ppi->AuthRequest(hContact, (PROTOCHAR*)lParam);
+ case 7: return (INT_PTR)ppi->ChangeInfo(wParam, (void*)lParam);
+ case 8:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, StrConvT((char*)lParam));
+ else
+ return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, (PROTOCHAR*)lParam);
+ case 9: return (INT_PTR)ppi->FileCancel(hContact, (HANDLE)wParam);
+ case 10:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, StrConvT((char*)lParam));
+ else
+ return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, (PROTOCHAR*)lParam);
+ case 11: {
+ PROTOFILERESUME* pfr = (PROTOFILERESUME*)lParam;
+ if (ppi->m_iVersion > 1) {
+ PROTOCHAR* szFname = mir_a2t((char*)pfr->szFilename);
+ INT_PTR res = (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action, (const PROTOCHAR**)&szFname);
+ mir_free((PROTOCHAR*)pfr->szFilename);
+ pfr->szFilename = (PROTOCHAR*)mir_t2a(szFname); mir_free(szFname);
+ }
+ else
+ return (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action, (const PROTOCHAR**)&pfr->szFilename);
+ }
+ case 12: return (INT_PTR)ppi->GetCaps(wParam, (HANDLE)lParam);
+ case 13: return (INT_PTR)ppi->GetIcon(wParam);
+ case 14: return (INT_PTR)ppi->GetInfo(hContact, wParam);;
+ case 15:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->SearchBasic(StrConvT((char*)lParam));
+ else
+ return (INT_PTR)ppi->SearchBasic((TCHAR*)lParam);
+ case 16:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->SearchByEmail(StrConvT((char*)lParam));
+ else
+ return (INT_PTR)ppi->SearchByEmail((TCHAR*)lParam);
+ case 17: {
+ PROTOSEARCHBYNAME* psbn = (PROTOSEARCHBYNAME*)lParam;
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->SearchByName(StrConvT((char*)psbn->pszNick),
+ StrConvT((char*)psbn->pszFirstName), StrConvT((char*)psbn->pszLastName));
+ else
+ return (INT_PTR)ppi->SearchByName(psbn->pszNick, psbn->pszFirstName, psbn->pszLastName);
+ }
+ case 18: return (INT_PTR)ppi->SearchAdvanced((HWND)lParam);
+ case 19: return (INT_PTR)ppi->CreateExtendedSearchUI ((HWND)lParam);
+ case 20: return (INT_PTR)ppi->RecvContacts(hContact, (PROTORECVEVENT*)lParam);
+ case 21: return (INT_PTR)ppi->RecvFile(hContact, (PROTOFILEEVENT*)lParam);
+ case 22: return (INT_PTR)ppi->RecvMsg(hContact, (PROTORECVEVENT*)lParam);
+ case 23: return (INT_PTR)ppi->RecvUrl(hContact, (PROTORECVEVENT*)lParam);
+ case 24: return (INT_PTR)ppi->SendContacts(hContact, LOWORD(wParam), HIWORD(wParam), (HANDLE*)lParam);
+ case 25:
+ if (ppi->m_iVersion > 1) {
+ TCHAR** files = Proto_FilesMatrixU((char**)lParam);
+ INT_PTR res = (INT_PTR)ppi->SendFile(hContact, StrConvT((char*)wParam), (TCHAR**)files);
+ if (res == 0) FreeFilesMatrix(&files);
+ return res;
+ }
+ else return (INT_PTR)ppi->SendFile(hContact, (TCHAR*)wParam, (TCHAR**)lParam);
+
+ case 26: return (INT_PTR)ppi->SendMsg(hContact, wParam, (const char*)lParam);
+ case 27: return (INT_PTR)ppi->SendUrl(hContact, wParam, (const char*)lParam);
+ case 28: return (INT_PTR)ppi->SetApparentMode(hContact, wParam);
+ case 29: return (INT_PTR)ppi->SetStatus(wParam);
+ case 30: return (INT_PTR)ppi->GetAwayMsg(hContact);
+ case 31: return (INT_PTR)ppi->RecvAwayMsg(hContact, wParam, (PROTORECVEVENT*)lParam);
+ case 32: return (INT_PTR)ppi->SendAwayMsg(hContact, (HANDLE)wParam, (const char*)lParam);
+ case 33:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->SetAwayMsg(wParam, StrConvT((char*)lParam));
+ else
+ return (INT_PTR)ppi->SetAwayMsg(wParam, (TCHAR*)lParam);
+ case 34: return (INT_PTR)ppi->UserIsTyping((HANDLE)wParam, lParam);
+ case 35: lstrcpynA((char*)lParam, ppi->m_szModuleName, wParam); return 0;
+ case 36: return ppi->m_iStatus;
+
+ case 100:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->SetAwayMsg(wParam, (TCHAR*)lParam);
+ else
+ return (INT_PTR)ppi->SetAwayMsg(wParam, StrConvA((TCHAR*)lParam));
+ case 102:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->SendFile(hContact, (TCHAR*)wParam, (TCHAR**)lParam);
+ else {
+ char** files = Proto_FilesMatrixA((TCHAR**)lParam);
+ INT_PTR res = (INT_PTR)ppi->SendFile(hContact, StrConvA((TCHAR*)wParam), (TCHAR**)files);
+ if (res == 0) FreeFilesMatrix((TCHAR***)&files);
+ return res;
+ }
+ case 103:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, (TCHAR*)lParam);
+ else
+ return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, StrConvA((TCHAR*)lParam));
+ case 104:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, (TCHAR*)lParam);
+ else
+ return (INT_PTR)ppi->FileDeny(hContact, (HANDLE)wParam, StrConvA((TCHAR*)lParam));
+ case 105: {
+ PROTOFILERESUME* pfr = (PROTOFILERESUME*)lParam;
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action,
+ (const PROTOCHAR**)&pfr->szFilename);
+ else {
+ char* szFname = mir_t2a(pfr->szFilename);
+ INT_PTR res = (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action,
+ (const PROTOCHAR**)&szFname);
+ mir_free(szFname);
+ } }
+ case 106:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->AuthRequest(hContact, (const TCHAR*)lParam);
+ else
+ return (INT_PTR)ppi->AuthRequest(hContact, StrConvA((const TCHAR*)lParam));
+ case 107:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, (const TCHAR*)lParam);
+ else
+ return (INT_PTR)ppi->AuthDeny((HANDLE)wParam, StrConvA((const TCHAR*)lParam));
+ case 108:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->SearchBasic((const TCHAR*)lParam);
+ else
+ return (INT_PTR)ppi->SearchBasic(StrConvA((const TCHAR*)lParam));
+ case 109: {
+ PROTOSEARCHBYNAME* psbn = (PROTOSEARCHBYNAME*)lParam;
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->SearchByName(psbn->pszNick, psbn->pszFirstName, psbn->pszLastName);
+ else
+ return (INT_PTR)ppi->SearchByName(StrConvA((TCHAR*)psbn->pszNick),
+ StrConvA((TCHAR*)psbn->pszFirstName), StrConvA((TCHAR*)psbn->pszLastName));
+ }
+ case 110:
+ if (ppi->m_iVersion > 1)
+ return (INT_PTR)ppi->SearchByEmail((const TCHAR*)lParam);
+ else
+ return (INT_PTR)ppi->SearchByEmail(StrConvA((const TCHAR*)lParam));
+ } } }
if ( !strcmp(szService, PS_ADDTOLIST)) {
@@ -618,10 +613,8 @@ INT_PTR CallProtoServiceInt(HANDLE hContact, const char *szModule, const char *s
}
}
-
INT_PTR res = MyCallProtoService(szModule, szService, wParam, lParam);
-
if (res == CALLSERVICE_NOTFOUND && pa && pa->bOldProto && pa->ppro && strchr(szService, 'W')) {
TServiceListItem *item = serviceItems.find((TServiceListItem*)&szService);
if ( !item) return res;
diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp
index 9339c1e282..007e827388 100644
--- a/src/modules/protocols/protoopts.cpp
+++ b/src/modules/protocols/protoopts.cpp
@@ -339,7 +339,7 @@ static LRESULT CALLBACK AccListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
rc.bottom = rc.top + max(GetSystemMetrics(SM_CXSMICON), parentDat->titleHeight) + 4 - 1;
++rc.top; --rc.right;
- dat->hwndEdit = CreateWindow(_T("EDIT"), pa->tszAccountName, WS_CHILD|WS_BORDER|ES_AUTOHSCROLL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hwnd, NULL, hMirandaInst, NULL);
+ dat->hwndEdit = CreateWindow(_T("EDIT"), pa->tszAccountName, WS_CHILD|WS_BORDER|ES_AUTOHSCROLL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hwnd, NULL, hInst, NULL);
SetWindowLongPtr(dat->hwndEdit, GWLP_USERDATA, SetWindowLongPtr(dat->hwndEdit, GWLP_WNDPROC, (LONG_PTR)sttEditSubclassProc));
SendMessage(dat->hwndEdit, WM_SETFONT, (WPARAM)parentDat->hfntTitle, 0);
SendMessage(dat->hwndEdit, EM_SETMARGINS, EC_LEFTMARGIN|EC_RIGHTMARGIN|EC_USEFONTINFO, 0);
@@ -781,7 +781,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
}
else pa->type = PROTOTYPE_DISPROTO; }
else {
- DWORD dwStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
+ DWORD dwStatus = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0);
if (dwStatus >= ID_STATUS_ONLINE) {
if (IDCANCEL == ::MessageBox(hwndDlg,
TranslateT("Account is online. Disable account?"),
@@ -829,7 +829,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
case IDC_ADD:
{
AccFormDlgParam param = { PRAC_ADDED, NULL };
- if (IDOK == DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)&param))
+ if (IDOK == DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)&param))
SendMessage(hwndDlg, WM_MY_REFRESH, 0, 0);
}
break;
@@ -904,7 +904,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
int idx = ListBox_GetCurSel(hList);
if (idx != -1) {
AccFormDlgParam param = { PRAC_UPGRADED, (PROTOACCOUNT*)ListBox_GetItemData(hList, idx) };
- DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)&param);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ACCFORM), hwndDlg, AccFormDlgProc, (LPARAM)&param);
} }
break;
@@ -1024,7 +1024,7 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
static INT_PTR OptProtosShow(WPARAM, LPARAM)
{
if ( !hAccMgr)
- hAccMgr = CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_ACCMGR), NULL, AccMgrDlgProc, 0);
+ hAccMgr = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ACCMGR), NULL, AccMgrDlgProc, 0);
ShowWindow(hAccMgr, SW_RESTORE);
SetForegroundWindow(hAccMgr);
diff --git a/src/modules/skin/hotkey_opts.cpp b/src/modules/skin/hotkey_opts.cpp
index 929bb8be74..6bebcdc273 100644
--- a/src/modules/skin/hotkey_opts.cpp
+++ b/src/modules/skin/hotkey_opts.cpp
@@ -1005,7 +1005,7 @@ int HotkeyOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = {0};
odp.cbSize = sizeof(odp);
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.flags = ODPF_BOLDGROUPS;
odp.position = -180000000;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_HOTKEYS);
diff --git a/src/modules/skin/hotkeys.cpp b/src/modules/skin/hotkeys.cpp
index 76a31b6f2e..a36dd152d1 100644
--- a/src/modules/skin/hotkeys.cpp
+++ b/src/modules/skin/hotkeys.cpp
@@ -332,7 +332,7 @@ int LoadSkinHotkeys(void)
wcl.style = 0;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
- wcl.hInstance = hMirandaInst;
+ wcl.hInstance = hInst;
wcl.hIcon = NULL;
wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
@@ -343,7 +343,7 @@ int LoadSkinHotkeys(void)
g_pid = GetCurrentProcessId();
- g_hwndHotkeyHost = CreateWindow(_T("MirandaHotkeyHostWnd"), NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, hMirandaInst, NULL);
+ g_hwndHotkeyHost = CreateWindow(_T("MirandaHotkeyHostWnd"), NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, hInst, NULL);
SetWindowPos(g_hwndHotkeyHost, 0, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_DEFERERASE|SWP_NOSENDCHANGING|SWP_HIDEWINDOW);
hhkKeyboard = SetWindowsHookEx(WH_KEYBOARD, sttKeyboardProc, NULL, GetCurrentThreadId());
diff --git a/src/modules/skin/skin.h b/src/modules/skin/skin.h
index 274b0d82df..bd8783e17d 100644
--- a/src/modules/skin/skin.h
+++ b/src/modules/skin/skin.h
@@ -56,8 +56,8 @@ struct THotkeyItem
bool UnregisterHotkey; // valid only during WM_APP message in options UI, used to remove unregistered hotkeys from options
- __inline TCHAR* getSection() const { return LangPackTranslateStringT(hLangpack, ptszSection); }
- __inline TCHAR* getDescr() const { return LangPackTranslateStringT(hLangpack, ptszDescription); }
+ __inline TCHAR* getSection() const { return TranslateTH(hLangpack, ptszSection); }
+ __inline TCHAR* getDescr() const { return TranslateTH(hLangpack, ptszDescription); }
};
extern LIST<THotkeyItem> hotkeys;
diff --git a/src/modules/skin/skinicons.cpp b/src/modules/skin/skinicons.cpp
index 24138e0000..509135ae20 100644
--- a/src/modules/skin/skinicons.cpp
+++ b/src/modules/skin/skinicons.cpp
@@ -135,7 +135,7 @@ HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpIconName, BOOL bShared)
{
HICON hResIcon = bShared ? LoadSmallIcon(hInstance, lpIconName) : LoadSmallIconShared(hInstance, lpIconName);
if ( !hResIcon) { //Icon not found in hInstance lets try to load it from core
- HINSTANCE hCoreInstance=hMirandaInst;
+ HINSTANCE hCoreInstance=hInst;
if (hCoreInstance != hInstance)
hResIcon = bShared ? LoadSmallIcon(hCoreInstance, lpIconName) : LoadSmallIconShared(hCoreInstance, lpIconName);
}
@@ -144,7 +144,7 @@ HICON LoadIconEx(HINSTANCE hInstance, LPCTSTR lpIconName, BOOL bShared)
int ImageList_AddIcon_NotShared(HIMAGELIST hIml, LPCTSTR szResource)
{
- HICON hTempIcon=LoadIconEx(hMirandaInst, szResource, 0);
+ HICON hTempIcon=LoadIconEx(hInst, szResource, 0);
int res = ImageList_AddIcon(hIml, hTempIcon);
Safe_DestroyIcon(hTempIcon);
return res;
@@ -222,7 +222,7 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big)
int i, statusIndx = -1;
char iconName[MAX_PATH];
HICON hIcon;
- DWORD caps2 = (szProto == NULL) ? (DWORD)-1 : CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0);
+ DWORD caps2 = (szProto == NULL) ? (DWORD)-1 : CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_2, 0);
if (status >= ID_STATUS_CONNECTING && status < ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES) {
mir_snprintf(iconName, SIZEOF(iconName), "%s%d", mainIconsFmt, 7);
@@ -276,7 +276,7 @@ HICON LoadSkinProtoIcon(const char* szProto, int status, bool big)
sid.cbSize = sizeof(sid);
sid.flags = SIDF_ALL_TCHAR;
- GetModuleFileName(hMirandaInst, szPath, MAX_PATH);
+ GetModuleFileName(hInst, szPath, MAX_PATH);
str = _tcsrchr(szPath, '\\');
if (str != NULL)
*str = 0;
diff --git a/src/modules/skin/sounds.cpp b/src/modules/skin/sounds.cpp
index 94da829145..24b4e44476 100644
--- a/src/modules/skin/sounds.cpp
+++ b/src/modules/skin/sounds.cpp
@@ -30,8 +30,8 @@ struct SoundItem
TCHAR* ptszTempFile;
int hLangpack;
- __inline TCHAR* getSection() const { return LangPackTranslateStringT(hLangpack, ptszSection); }
- __inline TCHAR* getDescr() const { return LangPackTranslateStringT(hLangpack, ptszDescription); }
+ __inline TCHAR* getSection() const { return TranslateTH(hLangpack, ptszSection); }
+ __inline TCHAR* getDescr() const { return TranslateTH(hLangpack, ptszDescription); }
__inline void clear(void)
{
@@ -112,7 +112,7 @@ static INT_PTR ServiceSkinPlaySound(WPARAM, LPARAM lParam)
DBVARIANT dbv;
if ( DBGetContactSettingTString(NULL, "SkinSounds", pszSoundName, &dbv) == 0) {
TCHAR szFull[MAX_PATH];
- pathToAbsoluteT(dbv.ptszVal, szFull, NULL);
+ PathToAbsoluteT(dbv.ptszVal, szFull, NULL);
NotifyEventHooks(hPlayEvent, 0, (LPARAM)szFull);
DBFreeVariant(&dbv);
}
@@ -236,7 +236,7 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
DBVARIANT dbv;
if ( !DBGetContactSettingTString(NULL, "SkinSounds", arSounds[tvi.lParam].name, &dbv)) {
TCHAR szPathFull[MAX_PATH];
- pathToAbsoluteT(dbv.ptszVal, szPathFull, NULL);
+ PathToAbsoluteT(dbv.ptszVal, szPathFull, NULL);
NotifyEventHooks(hPlayEvent, 1, (LPARAM)szPathFull);
DBFreeVariant(&dbv);
}
@@ -266,12 +266,12 @@ INT_PTR CALLBACK DlgProcSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
if (DBGetContactSettingByte(NULL, "SkinSoundsOff", snd.name, 0) == 0) {
DBVARIANT dbv;
if (DBGetContactSettingTString(NULL, "SkinSounds", snd.name, &dbv) == 0) {
- pathToAbsoluteT(dbv.ptszVal, strdir, NULL);
+ PathToAbsoluteT(dbv.ptszVal, strdir, NULL);
DBFreeVariant(&dbv);
} } }
mir_sntprintf(strFull, SIZEOF(strFull), _T("%s"), snd.ptszTempFile ? snd.ptszTempFile : _T(""));
- pathToAbsoluteT(strFull, strdir, NULL);
+ PathToAbsoluteT(strFull, strdir, NULL);
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
@@ -411,7 +411,7 @@ static int SkinOptionsInit(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.position = -200000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SOUND);
odp.pszGroup = LPGEN("Customize");
odp.pszTitle = LPGEN("Sounds");
diff --git a/src/modules/srauth/auth.cpp b/src/modules/srauth/auth.cpp
index c8257c3e20..61dedc06be 100644
--- a/src/modules/srauth/auth.cpp
+++ b/src/modules/srauth/auth.cpp
@@ -30,14 +30,14 @@ INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
INT_PTR ShowReqWindow(WPARAM, LPARAM lParam)
{
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_AUTHREQ), NULL, DlgProcAuthReq,
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_AUTHREQ), NULL, DlgProcAuthReq,
(LPARAM)((CLISTEVENT *)lParam)->hDbEvent);
return 0;
}
INT_PTR ShowAddedWindow(WPARAM, LPARAM lParam)
{
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_ADDED), NULL, DlgProcAdded,
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDED), NULL, DlgProcAdded,
(LPARAM)((CLISTEVENT *)lParam)->hDbEvent);
return 0;
}
diff --git a/src/modules/srauth/authdialogs.cpp b/src/modules/srauth/authdialogs.cpp
index b5693e01dd..7a19f54642 100644
--- a/src/modules/srauth/authdialogs.cpp
+++ b/src/modules/srauth/authdialogs.cpp
@@ -52,8 +52,8 @@ INT_PTR CALLBACK DlgProcAdded(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
char* last = first + strlen(first) + 1;
char* email = last + strlen(last) + 1;
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0));
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoServiceInt(NULL,dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0));
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoServiceInt(NULL,dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0));
PROTOACCOUNT* acc = Proto_GetAccount(dbei.szModule);
@@ -184,8 +184,8 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
email = last + strlen(last) + 1;
reason = email + strlen(email) + 1;
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0));
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, CallProtoServiceInt(NULL,dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0));
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, CallProtoServiceInt(NULL,dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0));
PROTOACCOUNT* acc = Proto_GetAccount(dbei.szModule);
@@ -234,7 +234,7 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE);
SendDlgItemMessage(hwndDlg, IDC_DENYREASON, EM_LIMITTEXT, 255, 0);
- if (CallProtoService(dbei.szModule, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_NOAUTHDENYREASON)
+ if (CallProtoServiceInt(NULL,dbei.szModule, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_NOAUTHDENYREASON)
{
EnableWindow(GetDlgItem(hwndDlg, IDC_DENYREASON), FALSE);
SetDlgItemText(hwndDlg, IDC_DENYREASON, TranslateT("Feature is not supported by protocol"));
@@ -267,7 +267,7 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei);
- CallProtoService(dbei.szModule, PS_AUTHALLOW, (WPARAM)hDbEvent, 0);
+ CallProtoServiceInt(NULL,dbei.szModule, PS_AUTHALLOW, (WPARAM)hDbEvent, 0);
if (IsDlgButtonChecked(hwndDlg, IDC_ADDCHECK))
{
@@ -291,10 +291,10 @@ INT_PTR CALLBACK DlgProcAuthReq(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
{
TCHAR szReason[256];
GetDlgItemText(hwndDlg, IDC_DENYREASON, szReason, SIZEOF(szReason));
- CallProtoService(dbei.szModule, PS_AUTHDENYT, (WPARAM)hDbEvent, (LPARAM)szReason);
+ CallProtoServiceInt(NULL,dbei.szModule, PS_AUTHDENYT, (WPARAM)hDbEvent, (LPARAM)szReason);
}
else
- CallProtoService(dbei.szModule, PS_AUTHDENYT, (WPARAM)hDbEvent, 0);
+ CallProtoServiceInt(NULL,dbei.szModule, PS_AUTHDENYT, (WPARAM)hDbEvent, 0);
}
DestroyWindow(hwndDlg);
break;;
diff --git a/src/modules/srawaymsg/awaymsg.cpp b/src/modules/srawaymsg/awaymsg.cpp
index e480dab74a..82ea8f2121 100644
--- a/src/modules/srawaymsg/awaymsg.cpp
+++ b/src/modules/srawaymsg/awaymsg.cpp
@@ -125,7 +125,7 @@ static INT_PTR GetMessageCommand(WPARAM wParam, LPARAM)
SetForegroundWindow(hwnd);
SetFocus(hwnd);
}
- else CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_READAWAYMSG), NULL, ReadAwayMsgDlgProc, wParam);
+ else CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_READAWAYMSG), NULL, ReadAwayMsgDlgProc, wParam);
return 0;
}
@@ -146,8 +146,8 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM)
int status = DBGetContactSettingWord((HANDLE)wParam, szProto, "Status", ID_STATUS_OFFLINE);
mir_sntprintf(str, SIZEOF(str), TranslateT("Re&ad %s Message"), cli.pfnGetStatusModeDescription(status, 0));
clmi.ptszName = str;
- if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV) {
- if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(status)) {
+ if (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV) {
+ if (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(status)) {
clmi.flags = CMIM_FLAGS | CMIM_NAME | CMIF_NOTOFFLINE | CMIM_ICON | CMIF_TCHAR;
clmi.hIcon = LoadSkinProtoIcon(szProto, status);
} } } }
diff --git a/src/modules/srawaymsg/sendmsg.cpp b/src/modules/srawaymsg/sendmsg.cpp
index d11f80715a..843b43f64f 100644
--- a/src/modules/srawaymsg/sendmsg.cpp
+++ b/src/modules/srawaymsg/sendmsg.cpp
@@ -73,7 +73,7 @@ static TCHAR* GetAwayMessage(int statusMode, char *szProto)
{
DBVARIANT dbv;
- if (szProto && !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode)))
+ if (szProto && !(CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode)))
return NULL;
if (DBGetContactSettingByte(NULL, "SRAway", StatusModeToDbSetting(statusMode, "Ignore"), 0))
@@ -176,13 +176,13 @@ void ChangeAllProtoMessages(char *szProto, int statusMode, TCHAR *msg)
{
PROTOACCOUNT* pa = accounts[i];
if ( !Proto_IsAccountEnabled(pa)) continue;
- if ((CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) &&
+ if ((CallProtoServiceInt(NULL,pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) &&
!Proto_IsAccountLocked(pa))
- CallProtoService(pa->szModuleName, PS_SETAWAYMSGT, statusMode, (LPARAM)msg);
+ CallProtoServiceInt(NULL,pa->szModuleName, PS_SETAWAYMSGT, statusMode, (LPARAM)msg);
}
}
else
- CallProtoService(szProto, PS_SETAWAYMSGT, statusMode, (LPARAM)msg);
+ CallProtoServiceInt(NULL,szProto, PS_SETAWAYMSGT, statusMode, (LPARAM)msg);
}
struct SetAwayMsgData
@@ -323,8 +323,8 @@ static int StatusModeChange(WPARAM wParam, LPARAM lParam)
else
{
// If its a single protocol check the PFLAGNUM_3 for the single protocol
- if ( !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) ||
- !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode)))
+ if ( !(CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) ||
+ !(CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode)))
return 0;
}
@@ -346,7 +346,7 @@ static int StatusModeChange(WPARAM wParam, LPARAM lParam)
newdat->statusMode = statusMode;
if (hwndStatusMsg)
DestroyWindow(hwndStatusMsg);
- hwndStatusMsg = CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_SETAWAYMSG),
+ hwndStatusMsg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETAWAYMSG),
NULL, SetAwayMsgDlgProc, (LPARAM)newdat);
}
return 0;
@@ -547,7 +547,7 @@ static int AwayMsgOptInitialise(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.position = 870000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_AWAYMSG);
odp.pszTitle = LPGEN("Status Messages");
odp.pszGroup = LPGEN("Status");
@@ -570,7 +570,7 @@ static int AwayMsgSendModernOptInit(WPARAM wParam, LPARAM)
MODERNOPTOBJECT obj = {0};
obj.cbSize = sizeof(obj);
- obj.hInstance = hMirandaInst;
+ obj.hInstance = hInst;
obj.dwFlags = MODEROPT_FLG_TCHAR | MODEROPT_FLG_NORESIZE;
obj.iSection = MODERNOPT_PAGE_STATUS;
obj.iType = MODERNOPT_TYPE_SECTIONPAGE;
@@ -590,7 +590,7 @@ static int AwayMsgSendAccountsChanged(WPARAM, LPARAM)
for (int i=0; i < accounts.getCount(); i++)
{
if ( !Proto_IsAccountEnabled(accounts[i])) continue;
- protoModeMsgFlags |= CallProtoService(accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
+ protoModeMsgFlags |= CallProtoServiceInt(NULL,accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
}
return 0;
diff --git a/src/modules/srfile/file.cpp b/src/modules/srfile/file.cpp
index 6f3b3e0ddf..b398294c8d 100644
--- a/src/modules/srfile/file.cpp
+++ b/src/modules/srfile/file.cpp
@@ -33,7 +33,7 @@ static INT_PTR SendFileCommand(WPARAM wParam, LPARAM)
struct FileSendData fsd;
fsd.hContact=(HANDLE)wParam;
fsd.ppFiles=NULL;
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd);
return 0;
}
@@ -52,7 +52,7 @@ static INT_PTR SendSpecificFiles(WPARAM wParam, LPARAM lParam)
fsd.ppFiles[i] = (const TCHAR*)mir_a2t(ppFiles[i]);
fsd.ppFiles[ count ] = NULL;
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd);
for (int j=0; j < count; j++)
mir_free((void*)fsd.ppFiles[j]);
return 0;
@@ -63,7 +63,7 @@ static INT_PTR SendSpecificFilesT(WPARAM wParam, LPARAM lParam)
FileSendData fsd;
fsd.hContact=(HANDLE)wParam;
fsd.ppFiles=(const TCHAR**)lParam;
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILESEND), NULL, DlgProcSendFile, (LPARAM)&fsd);
return 0;
}
@@ -79,7 +79,7 @@ static INT_PTR GetReceivedFilesFolder(WPARAM wParam, LPARAM lParam)
static INT_PTR RecvFileCommand(WPARAM, LPARAM lParam)
{
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILERECV), NULL, DlgProcRecvFile, lParam);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILERECV), NULL, DlgProcRecvFile, lParam);
return 0;
}
@@ -91,7 +91,7 @@ void PushFileEvent(HANDLE hContact, HANDLE hdbe, LPARAM lParam)
cle.hDbEvent = hdbe;
cle.lParam = lParam;
if (DBGetContactSettingByte(NULL, "SRFile", "AutoAccept", 0) && !DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)) {
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILERECV), NULL, DlgProcRecvFile, (LPARAM)&cle);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILERECV), NULL, DlgProcRecvFile, (LPARAM)&cle);
}
else {
SkinPlaySound("RecvFile");
@@ -284,8 +284,8 @@ static int SRFilePreBuildMenu(WPARAM wParam, LPARAM)
char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
if (szProto != NULL) {
- if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_FILESEND) {
- if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_OFFLINEFILES)
+ if (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_FILESEND) {
+ if (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_OFFLINEFILES)
mi.flags = CMIM_FLAGS;
else if (DBGetContactSettingWord((HANDLE)wParam, szProto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
mi.flags = CMIM_FLAGS;
diff --git a/src/modules/srfile/fileexistsdlg.cpp b/src/modules/srfile/fileexistsdlg.cpp
index d98ce59f78..1975226b90 100644
--- a/src/modules/srfile/fileexistsdlg.cpp
+++ b/src/modules/srfile/fileexistsdlg.cpp
@@ -189,7 +189,7 @@ void __cdecl LoadIconsAndTypesThread(void* param)
else {
iconIndex = _ttoi(pszComma+1); *pszComma='\0';
}
- hIcon = ExtractIcon(hMirandaInst, szIconFile, iconIndex);
+ hIcon = ExtractIcon(hInst, szIconFile, iconIndex);
if (hIcon)
fileInfo.hIcon = hIcon;
}
diff --git a/src/modules/srfile/fileopts.cpp b/src/modules/srfile/fileopts.cpp
index e68781da7c..b8c8c0133a 100644
--- a/src/modules/srfile/fileopts.cpp
+++ b/src/modules/srfile/fileopts.cpp
@@ -234,7 +234,7 @@ int FileOptInitialise(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = {0};
odp.cbSize = sizeof(odp);
odp.position = 900000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FILETRANSFER);
odp.pszTitle = LPGEN("File Transfers");
odp.pszGroup = LPGEN("Events");
diff --git a/src/modules/srfile/filerecvdlg.cpp b/src/modules/srfile/filerecvdlg.cpp
index 61f2c29153..7249291b6d 100644
--- a/src/modules/srfile/filerecvdlg.cpp
+++ b/src/modules/srfile/filerecvdlg.cpp
@@ -330,7 +330,7 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
if (szProto) {
HICON hIcon;
- hIcon=(HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
+ hIcon=(HICON)CallProtoServiceInt(NULL,szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
if (hIcon) {
DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
DestroyIcon(hIcon);
diff --git a/src/modules/srfile/filesenddlg.cpp b/src/modules/srfile/filesenddlg.cpp
index d1d0f26c16..92875ddbdb 100644
--- a/src/modules/srfile/filesenddlg.cpp
+++ b/src/modules/srfile/filesenddlg.cpp
@@ -281,7 +281,7 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0);
if (szProto) {
- HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
+ HICON hIcon = (HICON)CallProtoServiceInt(NULL,szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
if (hIcon) {
DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
DestroyIcon(hIcon);
diff --git a/src/modules/srfile/filexferdlg.cpp b/src/modules/srfile/filexferdlg.cpp
index 743e220051..3dc4e27bd5 100644
--- a/src/modules/srfile/filexferdlg.cpp
+++ b/src/modules/srfile/filexferdlg.cpp
@@ -45,7 +45,7 @@ struct virusscanthreadstartinfo {
TCHAR* PFTS_StringToTchar(int flags, const PROTOCHAR* s)
{
if (flags & PFTS_UTF)
- return Utf8DecodeUcs2((char*)s);
+ return Utf8DecodeW((char*)s);
else if (flags & PFTS_UNICODE)
return mir_tstrdup(s);
else
@@ -55,7 +55,7 @@ TCHAR* PFTS_StringToTchar(int flags, const PROTOCHAR* s)
int PFTS_CompareWithTchar(PROTOFILETRANSFERSTATUS* ft, const PROTOCHAR* s, TCHAR* r)
{
if (ft->flags & PFTS_UTF) {
- TCHAR* ts = Utf8DecodeUcs2((char*)s);
+ TCHAR* ts = Utf8DecodeW((char*)s);
int res = _tcscmp(ts, r);
mir_free(ts);
return res;
@@ -314,14 +314,14 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (dat->bytesRecvedHistory[0] == dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1])
lstrcpy(szTime, _T("??:??:??"));
else {
- li.QuadPart=BIGI(10000000)*(dat->transferStatus.currentFileSize-dat->transferStatus.currentFileProgress)*dat->bytesRecvedHistorySize/(dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]);
- ft.dwHighDateTime=li.HighPart; ft.dwLowDateTime=li.LowPart;
+ li.QuadPart = BIGI(10000000)*(dat->transferStatus.currentFileSize-dat->transferStatus.currentFileProgress)*dat->bytesRecvedHistorySize/(dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]);
+ ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart;
FileTimeToSystemTime(&ft, &st);
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime));
}
if (dat->bytesRecvedHistory[0] != dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]) {
li.QuadPart=BIGI(10000000)*(dat->transferStatus.totalBytes-dat->transferStatus.totalProgress)*dat->bytesRecvedHistorySize/(dat->bytesRecvedHistory[0]-dat->bytesRecvedHistory[dat->bytesRecvedHistorySize-1]);
- ft.dwHighDateTime=li.HighPart; ft.dwLowDateTime=li.LowPart;
+ ft.dwHighDateTime = li.HighPart; ft.dwLowDateTime = li.LowPart;
FileTimeToSystemTime(&ft, &st);
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER, &st, NULL, szTime, SIZEOF(szTime));
}
@@ -502,7 +502,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
break;
}
mir_free(szOriginalFilename);
- CallProtoService(szProto, PS_FILERESUMET, (WPARAM)dat->fs, (LPARAM)pfr);
+ CallProtoServiceInt(NULL,szProto, PS_FILERESUMET, (WPARAM)dat->fs, (LPARAM)pfr);
if (pfr->szFilename) mir_free((char*)pfr->szFilename);
mir_free(pfr);
break;
@@ -556,7 +556,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (dat->resumeBehaviour == FILERESUME_ASK) {
TDlgProcFileExistsParam param = { hwndDlg, fts };
ShowWindow(hwndDlg, SW_SHOWNORMAL);
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILEEXISTS), hwndDlg, DlgProcFileExists, (LPARAM)&param);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILEEXISTS), hwndDlg, DlgProcFileExists, (LPARAM)&param);
EnableWindow(hwndDlg, FALSE);
}
else {
@@ -720,7 +720,7 @@ INT_PTR CALLBACK DlgProcFileTransfer(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
UTILRESIZEDIALOG urd={0};
urd.cbSize=sizeof(urd);
urd.hwndDlg=hwndDlg;
- urd.hInstance=hMirandaInst;
+ urd.hInstance=hInst;
urd.lpTemplate=MAKEINTRESOURCEA(IDD_FILETRANSFERINFO);
urd.pfnResizer=FileTransferDlgResizer;
CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
diff --git a/src/modules/srfile/ftmanager.cpp b/src/modules/srfile/ftmanager.cpp
index 08b4a9e59c..7e0dcfc9cc 100644
--- a/src/modules/srfile/ftmanager.cpp
+++ b/src/modules/srfile/ftmanager.cpp
@@ -313,8 +313,8 @@ static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
dat->hhkPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwnd, M_PRESHUTDOWN);
- dat->hwndIncoming = CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc);
- dat->hwndOutgoing = CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc);
+ dat->hwndIncoming = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc);
+ dat->hwndOutgoing = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc);
ShowWindow(dat->hwndIncoming, SW_SHOW);
tci.mask = TCIF_PARAM|TCIF_TEXT;
@@ -537,7 +537,7 @@ HWND FtMgr_Show(bool bForceActivate, bool bFromMenu)
bool bJustCreated = (hwndFtMgr == NULL);
if (bJustCreated)
{
- hwndFtMgr = CreateDialog(hMirandaInst, MAKEINTRESOURCE(IDD_FTMGR), NULL, FtMgrDlgProc);
+ hwndFtMgr = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTMGR), NULL, FtMgrDlgProc);
}
if (bFromMenu) /* lqbe */
{
@@ -584,7 +584,7 @@ HWND FtMgr_AddTransfer(FileDlgData *fdd)
TFtMgrData *dat = (TFtMgrData*)GetWindowLongPtr(FtMgr_Show(bForceActivate, false), GWLP_USERDATA);
if (dat == NULL) return NULL;
HWND hwndBox = fdd->send ? dat->hwndOutgoing : dat->hwndIncoming;
- HWND hwndFt = CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_FILETRANSFERINFO), hwndBox, DlgProcFileTransfer, (LPARAM)fdd);
+ HWND hwndFt = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILETRANSFERINFO), hwndBox, DlgProcFileTransfer, (LPARAM)fdd);
ShowWindow(hwndFt, SW_SHOWNA);
SendMessage(hwndBox, WM_FT_ADD, 0, (LPARAM)hwndFt);
FtMgr_ShowPage(fdd->send ? 1 : 0);
diff --git a/src/modules/srurl/url.cpp b/src/modules/srurl/url.cpp
index 4eafff94a2..fe790330c0 100644
--- a/src/modules/srurl/url.cpp
+++ b/src/modules/srurl/url.cpp
@@ -34,7 +34,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
static INT_PTR ReadUrlCommand(WPARAM, LPARAM lParam)
{
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_URLRECV), NULL, DlgProcUrlRecv, lParam);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_URLRECV), NULL, DlgProcUrlRecv, lParam);
return 0;
}
@@ -66,7 +66,7 @@ static int UrlEventAdded(WPARAM wParam, LPARAM lParam)
static INT_PTR SendUrlCommand(WPARAM wParam, LPARAM)
{
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_URLSEND), NULL, DlgProcUrlSend, wParam);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_URLSEND), NULL, DlgProcUrlSend, wParam);
return 0;
}
@@ -121,7 +121,7 @@ static int SRUrlPreBuildMenu(WPARAM wParam, LPARAM)
char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
if (szProto != NULL)
- if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_URLSEND)
+ if (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_URLSEND)
mi.flags = CMIM_FLAGS;
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hSRUrlMenuItem, (LPARAM)&mi);
diff --git a/src/modules/srurl/urldialogs.cpp b/src/modules/srurl/urldialogs.cpp
index 6e26068ce8..6fb5e7f33a 100644
--- a/src/modules/srurl/urldialogs.cpp
+++ b/src/modules/srurl/urldialogs.cpp
@@ -145,7 +145,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (szProto) {
HICON hIcon;
- hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
+ hIcon = (HICON)CallProtoServiceInt(NULL,szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
if (hIcon) {
DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
DestroyIcon(hIcon);
@@ -166,7 +166,7 @@ INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
RECT rc;
char url[256];
- hMenu=LoadMenu(hMirandaInst, MAKEINTRESOURCE(IDR_CONTEXT));
+ hMenu=LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT));
hSubMenu=GetSubMenu(hMenu, 6);
TranslateMenu(hSubMenu);
GetWindowRect((HWND)lParam, &rc);
@@ -524,7 +524,7 @@ INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) {
char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0);
if (szProto) {
- HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
+ HICON hIcon = (HICON)CallProtoServiceInt(NULL,szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0);
if (hIcon) {
DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
DestroyIcon(hIcon);
diff --git a/src/modules/updatenotify/updatenotify.cpp b/src/modules/updatenotify/updatenotify.cpp
index e27bd5503e..184f46a42b 100644
--- a/src/modules/updatenotify/updatenotify.cpp
+++ b/src/modules/updatenotify/updatenotify.cpp
@@ -138,7 +138,7 @@ static int UpdateNotifyOptInit(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.position = 100000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_UPDATENOTIFY);
odp.pszGroup = LPGEN("Events");
odp.pszTitle = LPGEN("Update Notify");
@@ -162,7 +162,7 @@ static INT_PTR UpdateNotifyMenuCommand(WPARAM, LPARAM) {
DBWriteContactSettingDword(NULL, UN_MOD, UN_CURRENTVERSIONFND, und.reqTime);
}
und.isManual = 1;
- DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_UPDATE_NOTIFY), 0, UpdateNotifyProc, (LPARAM)&und);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE_NOTIFY), 0, UpdateNotifyProc, (LPARAM)&und);
hwndManualUpdateDlg = 0;
return 0;
}
@@ -517,7 +517,7 @@ static void UpdateNotifyPerform(void *)
if (notify) {
DBWriteContactSettingString(NULL, UN_MOD, UN_CURRENTVERSION, und.versionReal);
DBWriteContactSettingDword(NULL, UN_MOD, UN_CURRENTVERSIONFND, und.reqTime);
- DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(IDD_UPDATE_NOTIFY), 0, UpdateNotifyProc, (LPARAM)&und);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE_NOTIFY), 0, UpdateNotifyProc, (LPARAM)&und);
hwndUpdateDlg = 0;
}
}
diff --git a/src/modules/userinfo/contactinfo.cpp b/src/modules/userinfo/contactinfo.cpp
index f83c1c5a5c..64c84cf221 100644
--- a/src/modules/userinfo/contactinfo.cpp
+++ b/src/modules/userinfo/contactinfo.cpp
@@ -209,7 +209,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
if (hHandCursor == NULL) {
if (IsWinVer2000Plus()) hHandCursor=LoadCursor(NULL, IDC_HAND);
- else hHandCursor=LoadCursor(hMirandaInst, MAKEINTRESOURCE(IDC_HYPERLINKHAND));
+ else hHandCursor=LoadCursor(hInst, MAKEINTRESOURCE(IDC_HYPERLINKHAND));
}
TranslateDialogDefault(hwndDlg);
{ LVCOLUMN lvc;
@@ -441,7 +441,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
char szNewData[256]="", idstr[33];
int i;
DBVARIANT dbv;
- if (IDOK != DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szNewData))
+ if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szNewData))
break;
for (i=0;;i++) {
mir_snprintf(idstr, SIZEOF(idstr), szIdTemplate, i);
@@ -477,7 +477,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (DBGetContactSettingString(hContact, "UserInfo", idstr, &dbv)) break;
lstrcpynA(szText, dbv.pszVal, SIZEOF(szText));
DBFreeVariant(&dbv);
- if (IDOK != DialogBoxParam(hMirandaInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szText))
+ if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szText))
break;
DBWriteContactSettingString(hContact, "UserInfo", idstr, szText);
SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
diff --git a/src/modules/userinfo/stdinfo.cpp b/src/modules/userinfo/stdinfo.cpp
index 40f749efdf..42f2b3241d 100644
--- a/src/modules/userinfo/stdinfo.cpp
+++ b/src/modules/userinfo/stdinfo.cpp
@@ -38,7 +38,7 @@ static int Proto_GetContactInfoSetting(HANDLE hContact, const char *szProto, con
DBCONTACTGETSETTING cgs={szModule, szSetting, dbv};
dbv->type=(BYTE)nType;
- return CallProtoService(szProto, PS_GETINFOSETTING, (WPARAM)hContact, (LPARAM)&cgs);
+ return CallProtoServiceInt(NULL,szProto, PS_GETINFOSETTING, (WPARAM)hContact, (LPARAM)&cgs);
}
static void Proto_FreeInfoVariant(DBVARIANT *dbv)
@@ -69,7 +69,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, HANDLE hContact, char *szModule,
TCHAR* ptstr = NULL;
int unspecified=0;
char* szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- bool proto_service = szProto && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC);
+ bool proto_service = szProto && (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC);
dbv.type=DBVT_DELETED;
if (szModule == NULL) unspecified=1;
@@ -385,7 +385,7 @@ static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,
if (hContact != NULL) {
char *szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
if (szProto == NULL) break;
- bool proto_service = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) == PF4_INFOSETTINGSVC;
+ bool proto_service = (CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) == PF4_INFOSETTINGSVC;
SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "Homepage", SVS_ZEROISUNSPEC);
//past
@@ -570,7 +570,7 @@ int DetailsInit(WPARAM wParam, LPARAM lParam)
odp.cbSize = sizeof(odp);
odp.hIcon = NULL;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.flags = 0;
odp.pfnDlgProc = SummaryDlgProc;
diff --git a/src/modules/userinfo/userinfo.cpp b/src/modules/userinfo/userinfo.cpp
index 599902f9ad..c636534b19 100644
--- a/src/modules/userinfo/userinfo.cpp
+++ b/src/modules/userinfo/userinfo.cpp
@@ -100,7 +100,7 @@ static INT_PTR ShowDetailsDialogCommand(WPARAM wParam, LPARAM)
psh.pszCaption = (TCHAR*)wParam; //more abuses of structure: this is hContact
psh.ppsp = (PROPSHEETPAGE*)opi.odp; //blatent misuse of the structure, but what the hell
- CreateDialogParam(hMirandaInst, MAKEINTRESOURCE(IDD_DETAILS), NULL, DlgProcDetails, (LPARAM)&psh);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DETAILS), NULL, DlgProcDetails, (LPARAM)&psh);
for (i=0;i<opi.pageCount;i++) {
//cleanup moved to WM_DESTROY
//mir_free((char*)opi.odp[i].pszTitle);
@@ -397,7 +397,7 @@ static INT_PTR CALLBACK DlgProcDetails(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (dat->hContact != NULL) {
szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0);
if (szProto == NULL) {EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE); break;}
- if (CallProtoService(szProto, PS_GETSTATUS, 0, 0)<ID_STATUS_ONLINE) EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
+ if (CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0)<ID_STATUS_ONLINE) EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), FALSE);
else EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE), !IsWindowVisible(GetDlgItem(hwndDlg, IDC_UPDATING)));
}
break;
diff --git a/src/modules/utils/bmpfilter.cpp b/src/modules/utils/bmpfilter.cpp
index 2e656dbf63..46db86baaf 100644
--- a/src/modules/utils/bmpfilter.cpp
+++ b/src/modules/utils/bmpfilter.cpp
@@ -36,7 +36,7 @@ static INT_PTR sttBitmapLoader(const TCHAR* ptszFileName)
short picType;
TCHAR szFilename[MAX_PATH];
- if ( !pathToAbsoluteT(ptszFileName, szFilename, NULL))
+ if ( !PathToAbsoluteT(ptszFileName, szFilename, NULL))
mir_sntprintf(szFilename, SIZEOF(szFilename), _T("%s"), ptszFileName);
int filenameLen = lstrlen(szFilename);
@@ -48,7 +48,7 @@ static INT_PTR sttBitmapLoader(const TCHAR* ptszFileName)
if ( !lstrcmpi(pszExt, _T(".bmp")) || !lstrcmpi(pszExt, _T(".rle"))) {
//LoadImage can do this much faster
- return (INT_PTR)LoadImage(hMirandaInst, szFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
+ return (INT_PTR)LoadImage(hInst, szFilename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
}
if ( !lstrcmpi(pszExt, _T(".png"))) {
diff --git a/src/modules/utils/colourpicker.cpp b/src/modules/utils/colourpicker.cpp
index 731f61f1e1..dd31bf7155 100644
--- a/src/modules/utils/colourpicker.cpp
+++ b/src/modules/utils/colourpicker.cpp
@@ -47,7 +47,7 @@ static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd, UINT message, WPARAM wPar
custColours[0]=GetWindowLongPtr(hwnd, sizeof(COLORREF));
cc.lStructSize=sizeof(CHOOSECOLOR);
cc.hwndOwner=hwnd;
- cc.hInstance=(HWND)hMirandaInst;
+ cc.hInstance=(HWND)hInst;
cc.rgbResult=GetWindowLongPtr(hwnd, 0);
cc.lpCustColors=custColours;
cc.Flags=CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT;
@@ -95,7 +95,7 @@ int InitColourPicker(void)
wcl.lpfnWndProc=ColourPickerWndProc;
wcl.cbClsExtra=0;
wcl.cbWndExtra=sizeof(COLORREF)*2;
- wcl.hInstance=hMirandaInst;
+ wcl.hInstance=hInst;
wcl.hCursor=NULL;
wcl.lpszClassName=WNDCLASS_COLOURPICKER;
wcl.hbrBackground=(HBRUSH)(COLOR_BTNFACE+1);
diff --git a/src/modules/utils/hyperlink.cpp b/src/modules/utils/hyperlink.cpp
index 2705347f36..ae372a9017 100644
--- a/src/modules/utils/hyperlink.cpp
+++ b/src/modules/utils/hyperlink.cpp
@@ -261,7 +261,7 @@ int InitHyperlink(void)
wcl.lpfnWndProc=HyperlinkWndProc;
wcl.cbClsExtra=0;
wcl.cbWndExtra=sizeof(struct HyperlinkWndData*);
- wcl.hInstance=hMirandaInst;
+ wcl.hInstance=hInst;
if (IsWinVer2000Plus()) wcl.hCursor=NULL;
else wcl.hCursor=LoadCursor(wcl.hInstance, MAKEINTRESOURCE(IDC_HYPERLINKHAND));
wcl.lpszClassName=WNDCLASS_HYPERLINK;
diff --git a/src/modules/utils/path.cpp b/src/modules/utils/path.cpp
index b31267ad2a..bf875f9d74 100644
--- a/src/modules/utils/path.cpp
+++ b/src/modules/utils/path.cpp
@@ -26,99 +26,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern TCHAR g_profileDir[MAX_PATH];
-static char szMirandaPath[MAX_PATH];
-static char szMirandaPathLower[MAX_PATH];
-
static INT_PTR replaceVars(WPARAM wParam, LPARAM lParam);
-static int pathIsAbsolute(const char *path)
-{
- if (strlen(path) <= 2)
- return 0;
- if ((path[1] == ':' && path[2] == '\\') || (path[0] == '\\' && path[1] == '\\'))
- return 1;
- return 0;
-}
-
static INT_PTR pathToRelative(WPARAM wParam, LPARAM lParam)
{
- char *pSrc = (char*)wParam;
- char *pOut = (char*)lParam;
- if ( !pSrc || !strlen(pSrc) || strlen(pSrc)>MAX_PATH) return 0;
- if ( !pathIsAbsolute(pSrc)) {
- mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
- return strlen(pOut);
- }
- else {
- char szTmp[MAX_PATH];
-
- mir_snprintf(szTmp, SIZEOF(szTmp), "%s", pSrc);
- _strlwr(szTmp);
- if (strstr(szTmp, szMirandaPathLower)) {
- mir_snprintf(pOut, MAX_PATH, "%s", pSrc+strlen(szMirandaPathLower));
- return strlen(pOut);
- }
- else {
- mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
- return strlen(pOut);
- }
- }
-}
-
-int pathToAbsolute(const char *pSrc, char *pOut, char* base)
-{
- if ( !pSrc || !strlen(pSrc) || strlen(pSrc) > MAX_PATH)
- return 0;
-
- if (base == NULL)
- base = szMirandaPath;
-
- char buf[MAX_PATH];
- if (pSrc[0] < ' ')
- return mir_snprintf(pOut, MAX_PATH, "%s", pSrc);
- else if (pathIsAbsolute(pSrc))
- return GetFullPathNameA(pSrc, MAX_PATH, pOut, NULL);
- else if (pSrc[0] != '\\')
- mir_snprintf(buf, MAX_PATH, "%s%s", base, pSrc);
- else
- mir_snprintf(buf, MAX_PATH, "%s%s", base, pSrc+1);
-
- return GetFullPathNameA(buf, MAX_PATH, pOut, NULL);
+ return PathToRelative((char*)wParam, (char*)lParam);
}
static INT_PTR pathToAbsolute(WPARAM wParam, LPARAM lParam)
{
- return pathToAbsolute((char*)wParam, (char*)lParam, szMirandaPath);
-}
-
-void CreatePathToFile(char* szFilePath)
-{
- char* pszLastBackslash = strrchr(szFilePath, '\\');
- if (pszLastBackslash == NULL)
- return;
-
- *pszLastBackslash = '\0';
- CreateDirectoryTree(szFilePath);
- *pszLastBackslash = '\\';
-}
-
-int CreateDirectoryTree(const char *szDir)
-{
- DWORD dwAttributes;
- char *pszLastBackslash, szTestDir[ MAX_PATH ];
-
- lstrcpynA(szTestDir, szDir, SIZEOF(szTestDir));
- if ((dwAttributes = GetFileAttributesA(szTestDir)) != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
- return 0;
-
- pszLastBackslash = strrchr(szTestDir, '\\');
- if (pszLastBackslash == NULL)
- return 0;
-
- *pszLastBackslash = '\0';
- CreateDirectoryTree(szTestDir);
- *pszLastBackslash = '\\';
- return (CreateDirectoryA(szTestDir, NULL) == 0) ? GetLastError() : 0;
+ return PathToAbsolute((char*)wParam, (char*)lParam, NULL);
}
static INT_PTR createDirTree(WPARAM, LPARAM lParam)
@@ -129,94 +46,14 @@ static INT_PTR createDirTree(WPARAM, LPARAM lParam)
return CreateDirectoryTree((char*)lParam);
}
-static TCHAR szMirandaPathW[MAX_PATH];
-static TCHAR szMirandaPathWLower[MAX_PATH];
-
-static int pathIsAbsoluteW(const TCHAR *path)
-{
- if (lstrlen(path) <= 2)
- return 0;
- if ((path[1] == ':' && path[2] == '\\') || (path[0] == '\\' && path[1] == '\\'))
- return 1;
- return 0;
-}
-
static INT_PTR pathToRelativeW(WPARAM wParam, LPARAM lParam)
{
- TCHAR *pSrc = (TCHAR*)wParam;
- TCHAR *pOut = (TCHAR*)lParam;
- if ( !pSrc || !lstrlen(pSrc) || lstrlen(pSrc) > MAX_PATH)
- return 0;
-
- if ( !pathIsAbsoluteW(pSrc))
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
- else {
- TCHAR szTmp[MAX_PATH];
-
- mir_sntprintf(szTmp, SIZEOF(szTmp), _T("%s"), pSrc);
- _tcslwr(szTmp);
- if (_tcsstr(szTmp, szMirandaPathWLower))
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc+lstrlen(szMirandaPathWLower));
- else
- mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
- }
- return lstrlen(pOut);
-}
-
-int pathToAbsoluteW(const TCHAR *pSrc, TCHAR *pOut, TCHAR* base)
-{
- if ( !pSrc || !wcslen(pSrc) || wcslen(pSrc) > MAX_PATH)
- return 0;
-
- if (base == NULL)
- base = szMirandaPathW;
-
- TCHAR buf[MAX_PATH];
- if (pSrc[0] < ' ')
- return mir_sntprintf(pOut, MAX_PATH, _T("%s"), pSrc);
- else if (pathIsAbsoluteW(pSrc))
- return GetFullPathName(pSrc, MAX_PATH, pOut, NULL);
- else if (pSrc[0] != '\\')
- mir_sntprintf(buf, MAX_PATH, _T("%s%s"), base, pSrc);
- else
- mir_sntprintf(buf, MAX_PATH, _T("%s%s"), base, pSrc+1);
-
- return GetFullPathName(buf, MAX_PATH, pOut, NULL);
+ return PathToRelativeW((WCHAR*)wParam, (WCHAR*)lParam );
}
static INT_PTR pathToAbsoluteW(WPARAM wParam, LPARAM lParam)
{
- return pathToAbsoluteW((TCHAR*)wParam, (TCHAR*)lParam, szMirandaPathW);
-}
-
-void CreatePathToFileW(WCHAR* wszFilePath)
-{
- WCHAR* pszLastBackslash = wcsrchr(wszFilePath, '\\');
- if (pszLastBackslash == NULL)
- return;
-
- *pszLastBackslash = '\0';
- CreateDirectoryTreeW(wszFilePath);
- *pszLastBackslash = '\\';
-}
-
-int CreateDirectoryTreeW(const WCHAR* szDir)
-{
- DWORD dwAttributes;
- WCHAR* pszLastBackslash, szTestDir[ MAX_PATH ];
-
- lstrcpynW(szTestDir, szDir, SIZEOF(szTestDir));
- if ((dwAttributes = GetFileAttributesW(szTestDir)) != INVALID_FILE_ATTRIBUTES && (dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
- return 0;
-
- pszLastBackslash = wcsrchr(szTestDir, '\\');
- if (pszLastBackslash == NULL)
- return 0;
-
- *pszLastBackslash = '\0';
- CreateDirectoryTreeW(szTestDir);
- *pszLastBackslash = '\\';
- return (CreateDirectoryW(szTestDir, NULL) == 0) ? GetLastError() : 0;
+ return PathToAbsoluteW((WCHAR*)wParam, (WCHAR*)lParam, NULL);
}
static INT_PTR createDirTreeW(WPARAM, LPARAM lParam)
@@ -227,20 +64,6 @@ static INT_PTR createDirTreeW(WPARAM, LPARAM lParam)
return CreateDirectoryTreeW((WCHAR*)lParam);
}
-int InitPathUtilsW(void)
-{
- GetModuleFileName(hMirandaInst, szMirandaPathW, SIZEOF(szMirandaPathW));
- TCHAR *p = _tcsrchr(szMirandaPathW, '\\');
- if (p)
- p[1] = 0;
- mir_sntprintf(szMirandaPathWLower, SIZEOF(szMirandaPathWLower), _T("%s"), szMirandaPathW);
- _tcslwr(szMirandaPathWLower);
- CreateServiceFunction(MS_UTILS_PATHTORELATIVEW, pathToRelativeW);
- CreateServiceFunction(MS_UTILS_PATHTOABSOLUTEW, pathToAbsoluteW);
- CreateServiceFunction(MS_UTILS_CREATEDIRTREEW, createDirTreeW);
- return 0;
-}
-
TCHAR *GetContactID(HANDLE hContact)
{
TCHAR *theValue = {0};
@@ -251,7 +74,7 @@ TCHAR *GetContactID(HANDLE hContact)
theValue = (TCHAR *)mir_tstrdup(dbv.ptszVal);
DBFreeVariant(&dbv);
return theValue;
- } }
+ } }
else {
CONTACTINFO ci = {0};
ci.cbSize = sizeof(ci);
@@ -266,7 +89,7 @@ TCHAR *GetContactID(HANDLE hContact)
case CNFT_DWORD:
return _itot(ci.dVal, (TCHAR *)mir_alloc(sizeof(TCHAR)*32), 10);
break;
- } } }
+ } } }
return NULL;
}
@@ -574,17 +397,15 @@ static INT_PTR replaceVars(WPARAM wParam, LPARAM lParam)
int InitPathUtils(void)
{
- char *p = 0;
- GetModuleFileNameA(hMirandaInst, szMirandaPath, SIZEOF(szMirandaPath));
- p = strrchr(szMirandaPath, '\\');
- if (p)
- p[1] = 0;
- mir_snprintf(szMirandaPathLower, MAX_PATH, "%s", szMirandaPath);
- _strlwr(szMirandaPathLower);
CreateServiceFunction(MS_UTILS_PATHTORELATIVE, pathToRelative);
+ CreateServiceFunction(MS_UTILS_PATHTORELATIVEW, pathToRelativeW);
+
CreateServiceFunction(MS_UTILS_PATHTOABSOLUTE, pathToAbsolute);
+ CreateServiceFunction(MS_UTILS_PATHTOABSOLUTEW, pathToAbsoluteW);
+
CreateServiceFunction(MS_UTILS_CREATEDIRTREE, createDirTree);
- CreateServiceFunction(MS_UTILS_REPLACEVARS, replaceVars);
+ CreateServiceFunction(MS_UTILS_CREATEDIRTREEW, createDirTreeW);
- return InitPathUtilsW();
+ CreateServiceFunction(MS_UTILS_REPLACEVARS, replaceVars);
+ return 0;
}
diff --git a/src/modules/utils/timezones.cpp b/src/modules/utils/timezones.cpp
index 05e83afa51..d90a303e49 100644
--- a/src/modules/utils/timezones.cpp
+++ b/src/modules/utils/timezones.cpp
@@ -169,7 +169,7 @@ static HANDLE timeapiGetInfoByName(LPCTSTR tszName, DWORD dwFlags)
return (dwFlags & TZF_DIFONLY) ? NULL : &myInfo.myTZ;
MIM_TIMEZONE tzsearch;
- tzsearch.hash = hashstr(tszName);
+ tzsearch.hash = mir_hashstrT(tszName);
MIM_TIMEZONE *tz = g_timezones.find(&tzsearch);
if (tz == NULL)
@@ -381,7 +381,7 @@ static int timeapiSelectListItem(HANDLE hContact, HWND hWnd, DWORD dwFlags)
DBVARIANT dbv;
if ( !DBGetContactSettingTString(hContact, "UserInfo", "TzName", &dbv))
{
- unsigned hash = hashstr(dbv.ptszVal);
+ unsigned hash = mir_hashstrT(dbv.ptszVal);
for (int i = 0; i < g_timezonesBias.getCount(); ++i)
{
if (hash == g_timezonesBias[i]->hash)
@@ -607,7 +607,7 @@ void InitTimeZones(void)
tz->tzi.DaylightBias = tzi.DaylightBias;
_tcscpy(tz->tszName, tszName);
- tz->hash = hashstr(tszName);
+ tz->hash = mir_hashstrT(tszName);
tz->offset = INT_MIN;
GetLocalizedString(hSubKey, _T("Display"), tz->szDisplay, SIZEOF(tz->szDisplay));
diff --git a/src/modules/utils/utils.cpp b/src/modules/utils/utils.cpp
index c9c1e3a65e..964e9a920f 100644
--- a/src/modules/utils/utils.cpp
+++ b/src/modules/utils/utils.cpp
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
INT_PTR ResizeDialog(WPARAM wParam, LPARAM lParam);
int InitOpenUrl(void);
int InitWindowList(void);
+int InitPathUtils(void);
void FreeWindowList(void);
int InitHyperlink(void);
int InitColourPicker(void);
@@ -461,98 +462,6 @@ static INT_PTR GenerateRandom(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-char* __fastcall rtrim(char* str)
-{
- if (str == NULL) return NULL;
- char* p = strchr(str, 0);
- while (--p >= str)
- {
- switch (*p)
- {
- case ' ': case '\t': case '\n': case '\r':
- *p = 0; break;
- default:
- return str;
- }
- }
- return str;
-}
-
-TCHAR* __fastcall rtrim(TCHAR *str)
-{
- if (str == NULL) return NULL;
- TCHAR* p = _tcschr(str, 0);
- while (--p >= str)
- {
- switch (*p)
- {
- case ' ': case '\t': case '\n': case '\r':
- *p = 0; break;
- default:
- return str;
- }
- }
- return str;
-}
-
-char* __fastcall ltrim(char* str)
-{
- if (str == NULL) return NULL;
- char* p = str;
-
- for (;;)
- {
- switch (*p)
- {
- case ' ': case '\t': case '\n': case '\r':
- ++p; break;
- default:
- memmove(str, p, strlen(p) + 1);
- return str;
- }
- }
-}
-
-char* __fastcall ltrimp(char* str)
-{
- if (str == NULL) return NULL;
- char* p = str;
-
- for (;;)
- {
- switch (*p)
- {
- case ' ': case '\t': case '\n': case '\r':
- ++p; break;
- default:
- return p;
- }
- }
-}
-
-bool __fastcall wildcmp(char * name, char * mask)
-{
- char * last='\0';
- for (;; mask++, name++)
- {
- if (*mask != '?' && *mask != *name) break;
- if (*name == '\0') return ((BOOL)!*mask);
- }
- if (*mask != '*') return FALSE;
- for (;; mask++, name++)
- {
- while (*mask == '*')
- {
- last = mask++;
- if (*mask == '\0') return ((BOOL)!*mask); /* true */
- }
- if (*name == '\0') return ((BOOL)!*mask); /* *mask == EOS */
- if (*mask != '?' && *mask != *name) name -= (size_t)(mask - last) - 1, mask = last;
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
int LoadUtilsModule(void)
{
bModuleInitialized = TRUE;
@@ -570,6 +479,7 @@ int LoadUtilsModule(void)
InitOpenUrl();
InitWindowList();
InitHyperlink();
+ InitPathUtils();
InitColourPicker();
InitBitmapFilter();
InitXmlApi();
diff --git a/src/modules/visibility/visibility.cpp b/src/modules/visibility/visibility.cpp
index 9575830f63..b7e67a2cd4 100644
--- a/src/modules/visibility/visibility.cpp
+++ b/src/modules/visibility/visibility.cpp
@@ -111,7 +111,7 @@ static void SetAllContactIcons(HWND hwndList)
szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
if (szProto == NULL) {flags=0; status=0;}
else {
- flags=CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ flags=CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0);
status=DBGetContactSettingWord(hContact, szProto, "ApparentMode", 0);
}
if (flags&PF1_INVISLIST) {
@@ -280,7 +280,7 @@ static int VisibilityOptInitialise(WPARAM wParam, LPARAM)
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.position = 850000000;
- odp.hInstance = hMirandaInst;
+ odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_VISIBILITY);
odp.pszTitle = LPGEN("Visibility");
odp.pszGroup = LPGEN("Status");
diff --git a/tools/dbtool/cleaning.cpp b/tools/dbtool/cleaning.cpp
index efbbde1640..a16a11e7ac 100644
--- a/tools/dbtool/cleaning.cpp
+++ b/tools/dbtool/cleaning.cpp
@@ -29,7 +29,7 @@ INT_PTR CALLBACK CleaningDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa
EnableWindow(GetDlgItem(hdlg,IDC_ERASEHISTORY),!opts.bAggressive);
CheckDlgButton(hdlg,IDC_MARKREAD,opts.bMarkRead);
CheckDlgButton(hdlg,IDC_CONVERTUTF,opts.bConvertUtf);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WZN_PAGECHANGING:
opts.bEraseHistory=IsDlgButtonChecked(hdlg,IDC_ERASEHISTORY)&&!opts.bAggressive;
diff --git a/tools/dbtool/dbtool.h b/tools/dbtool/dbtool.h
index 6bc7591392..c674445a39 100644
--- a/tools/dbtool/dbtool.h
+++ b/tools/dbtool/dbtool.h
@@ -33,10 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <commctrl.h>
#include <time.h>
-//#include <newpluginapi.h> // Only needed to keep m_database.h happy
-#define CallService(a,b,c) 1
-
-#include "../../include/m_database.h"
+#include <m_database.h>
#include "database.h" // Note: This is a copy of database.h from the Miranda IM v0.3 tree.
// Remember to update this when releasing new dbtool versions.
#include "resource.h"
@@ -105,19 +102,5 @@ int SignatureValid(DWORD ofs,DWORD signature);
DWORD ConvertModuleNameOfs(DWORD ofsOld);
void FreeModuleChain();
-int TranslateDialog(HWND hwndDlg);
-void LoadLangPackModule(void);
-void UnloadLangPackModule(void);
-
-char* LangPackTranslateString(const char *szEnglish, const int W);
-__inline LPSTR Translate(LPSTR source)
-{ return ( LPSTR )LangPackTranslateString( source, 0 );
-}
-
-#define TranslateT(s) (TCHAR*)LangPackTranslateString((LPCSTR)_T(s),1)
-#define TranslateTS(s) (TCHAR*)LangPackTranslateString((LPCSTR)s,1)
-
-char* Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2);
-char* Utf8EncodeUcs2(const wchar_t* src);
bool is_utf8_string(const char* str);
diff --git a/tools/dbtool/dbtool_10.vcxproj.filters b/tools/dbtool/dbtool_10.vcxproj.filters
index 1a3e2bf55e..a3aa9aa299 100644
--- a/tools/dbtool/dbtool_10.vcxproj.filters
+++ b/tools/dbtool/dbtool_10.vcxproj.filters
@@ -24,9 +24,6 @@
<ClCompile Include="disk.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="langpack.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/tools/dbtool/eventchain.cpp b/tools/dbtool/eventchain.cpp
index 8760363287..8d319a5201 100644
--- a/tools/dbtool/eventchain.cpp
+++ b/tools/dbtool/eventchain.cpp
@@ -49,7 +49,7 @@ static void ConvertOldEvent( DBEvent*& dbei )
}
if ( msglenW > 0 && msglenW <= msglen ) {
- char* utf8str = Utf8EncodeUcs2(( WCHAR* )&dbei->blob[ msglen ] );
+ char* utf8str = Utf8EncodeW(( WCHAR* )&dbei->blob[ msglen ] );
dbei->cbBlob = (DWORD)strlen( utf8str )+1;
dbei->flags |= DBEF_UTF;
if (offsetof(DBEvent,blob)+dbei->cbBlob > memsize) {
diff --git a/tools/dbtool/fileaccess.cpp b/tools/dbtool/fileaccess.cpp
index 2fdd16c082..d904daf5b9 100644
--- a/tools/dbtool/fileaccess.cpp
+++ b/tools/dbtool/fileaccess.cpp
@@ -29,7 +29,7 @@ INT_PTR CALLBACK FileAccessDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM l
CheckDlgButton(hdlg,IDC_BACKUP,opts.bBackup);
CheckDlgButton(hdlg,IDC_AGGRESSIVE,opts.bAggressive);
SendMessage(hdlg,WM_COMMAND,MAKEWPARAM(IDC_CHECKONLY,BN_CLICKED),0);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WZN_PAGECHANGING:
opts.bCheckOnly=IsDlgButtonChecked(hdlg,IDC_CHECKONLY);
diff --git a/tools/dbtool/finished.cpp b/tools/dbtool/finished.cpp
index 7457d8b7d4..03e4004268 100644
--- a/tools/dbtool/finished.cpp
+++ b/tools/dbtool/finished.cpp
@@ -36,7 +36,7 @@ INT_PTR CALLBACK FinishedDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa
SetDlgItemText(hdlg,IDC_BACKUPFILE,opts.backupFilename);
}
else ShowWindow(GetDlgItem(hdlg,IDC_STBACKUP),FALSE);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WM_LAUNCHMIRANDA:
if(IsDlgButtonChecked(hdlg,IDC_LAUNCHMIRANDA)) {
diff --git a/tools/dbtool/main.cpp b/tools/dbtool/main.cpp
index 014881e34d..fb4657fc53 100644
--- a/tools/dbtool/main.cpp
+++ b/tools/dbtool/main.cpp
@@ -19,13 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "dbtool.h"
HINSTANCE hInst;
+int hLangpack=0;
DbToolOptions opts = {0};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
- hInst=hInstance;
- LoadLangPackModule();
+ hInst = hInstance;
InitCommonControls();
DialogBox(hInst,MAKEINTRESOURCE(IDD_WIZARD),NULL,WizardDlgProc);
return 0;
diff --git a/tools/dbtool/openerror.cpp b/tools/dbtool/openerror.cpp
index 292d688be7..1fa2964c20 100644
--- a/tools/dbtool/openerror.cpp
+++ b/tools/dbtool/openerror.cpp
@@ -31,7 +31,7 @@ INT_PTR CALLBACK OpenErrorDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lP
}
if(opts.error==ERROR_SHARING_VIOLATION) ShowWindow(GetDlgItem(hdlg,IDC_INUSE),SW_SHOW);
SetWindowLongPtr( GetDlgItem( hdlg, IDC_FILE ), GWL_STYLE, GetWindowLongPtr( GetDlgItem( hdlg, IDC_FILE ), GWL_STYLE ) | SS_PATHELLIPSIS );
- TranslateDialog( hdlg );
+ TranslateDialogDefault( hdlg );
SetDlgItemText( hdlg, IDC_FILE, opts.filename );
return TRUE;
case WM_COMMAND:
diff --git a/tools/dbtool/progress.cpp b/tools/dbtool/progress.cpp
index 4b7d7979b4..67c463ec77 100644
--- a/tools/dbtool/progress.cpp
+++ b/tools/dbtool/progress.cpp
@@ -104,7 +104,7 @@ INT_PTR CALLBACK ProgressDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa
manualAbort=0;
hEventRun=CreateEvent(NULL,TRUE,TRUE,NULL);
hEventAbort=CreateEvent(NULL,TRUE,FALSE,NULL);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
_beginthread(WorkerThread,0,NULL);
return TRUE;
case WM_MEASUREITEM:
diff --git a/tools/dbtool/selectdb.cpp b/tools/dbtool/selectdb.cpp
index 5bfd817cf5..761d3af1d0 100644
--- a/tools/dbtool/selectdb.cpp
+++ b/tools/dbtool/selectdb.cpp
@@ -209,7 +209,7 @@ INT_PTR CALLBACK SelectDbDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPa
CloseHandle( opts.hFile );
opts.hFile = NULL;
}
- TranslateDialog( hdlg );
+ TranslateDialogDefault( hdlg );
return TRUE;
}
diff --git a/tools/dbtool/utf.cpp b/tools/dbtool/utf.cpp
index 157d5d00f5..c56db053d8 100644
--- a/tools/dbtool/utf.cpp
+++ b/tools/dbtool/utf.cpp
@@ -26,382 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "dbtool.h"
-/* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */
-static const char utf8_length[128] =
-{
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80-0x8f */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90-0x9f */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xa0-0xaf */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xb0-0xbf */
- 0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xc0-0xcf */
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xd0-0xdf */
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 0xe0-0xef */
- 3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0 /* 0xf0-0xff */
-};
-
-/* first byte mask depending on UTF-8 sequence length */
-static const unsigned char utf8_mask[4] = { 0x7f, 0x1f, 0x0f, 0x07 };
-
-/* minimum Unicode value depending on UTF-8 sequence length */
-static const unsigned int utf8_minval[4] = { 0x0, 0x80, 0x800, 0x10000 };
-
-
-/* get the next char value taking surrogates into account */
-static unsigned int getSurrogateValue(const wchar_t *src, unsigned int srclen)
-{
- if (src[0] >= 0xd800 && src[0] <= 0xdfff) /* surrogate pair */
- {
- if (src[0] > 0xdbff || /* invalid high surrogate */
- srclen <= 1 || /* missing low surrogate */
- src[1] < 0xdc00 || src[1] > 0xdfff) /* invalid low surrogate */
- return 0;
- return 0x10000 + ((src[0] & 0x3ff) << 10) + (src[1] & 0x3ff);
- }
- return src[0];
-}
-
-/* query necessary dst length for src string */
-static int Ucs2toUtf8Len(const wchar_t *src, unsigned int srclen)
-{
- int len;
- unsigned int val;
-
- for (len = 0; srclen; srclen--, src++)
- {
- if (*src < 0x80) /* 0x00-0x7f: 1 byte */
- {
- len++;
- continue;
- }
- if (*src < 0x800) /* 0x80-0x7ff: 2 bytes */
- {
- len += 2;
- continue;
- }
- if (!(val = getSurrogateValue(src, srclen)))
- {
- return -2;
- }
- if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
- len += 3;
- else /* 0x10000-0x10ffff: 4 bytes */
- {
- len += 4;
- src++;
- srclen--;
- }
- }
- return len;
-}
-
-int Ucs2toUtf8Len(const wchar_t *src)
-{
- if ( src == 0 )
- return 0;
-
- return Ucs2toUtf8Len( src, (int)wcslen( src ));
-}
-
-/* wide char to UTF-8 string conversion */
-/* return -1 on dst buffer overflow, -2 on invalid input char */
-int Ucs2toUtf8(const wchar_t *src, int srclen, char *dst, int dstlen)
-{
- int len;
-
- for (len = dstlen; srclen; srclen--, src++)
- {
- WCHAR ch = *src;
- unsigned int val;
-
- if (ch < 0x80) /* 0x00-0x7f: 1 byte */
- {
- if (!len--) return -1; /* overflow */
- *dst++ = ch;
- continue;
- }
-
- if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */
- {
- if ((len -= 2) < 0) return -1; /* overflow */
- dst[1] = 0x80 | (ch & 0x3f);
- ch >>= 6;
- dst[0] = 0xc0 | ch;
- dst += 2;
- continue;
- }
-
- if (!(val = getSurrogateValue(src, srclen)))
- {
- return -2;
- }
-
- if (val < 0x10000) /* 0x800-0xffff: 3 bytes */
- {
- if ((len -= 3) < 0) return -1; /* overflow */
- dst[2] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[1] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[0] = 0xe0 | val;
- dst += 3;
- }
- else /* 0x10000-0x10ffff: 4 bytes */
- {
- if ((len -= 4) < 0) return -1; /* overflow */
- dst[3] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[2] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[1] = 0x80 | (val & 0x3f);
- val >>= 6;
- dst[0] = 0xf0 | val;
- dst += 4;
- src++;
- srclen--;
- }
- }
- return dstlen - len;
-}
-
-/* helper for the various utf8 mbstowcs functions */
-static unsigned int decodeUtf8Char(unsigned char ch, const char **str, const char *strend)
-{
- unsigned int len = utf8_length[ch-0x80];
- unsigned int res = ch & utf8_mask[len];
- const char *end = *str + len;
-
- if (end > strend) return ~0;
- switch(len)
- {
- case 3:
- if ((ch = end[-3] ^ 0x80) >= 0x40) break;
- res = (res << 6) | ch;
- (*str)++;
- case 2:
- if ((ch = end[-2] ^ 0x80) >= 0x40) break;
- res = (res << 6) | ch;
- (*str)++;
- case 1:
- if ((ch = end[-1] ^ 0x80) >= 0x40) break;
- res = (res << 6) | ch;
- (*str)++;
- if (res < utf8_minval[len]) break;
- return res;
- }
- return ~0;
-}
-
-/* query necessary dst length for src string */
-static inline int Utf8toUcs2Len(const char *src, int srclen)
-{
- int ret = 0;
- unsigned int res;
- const char *srcend = src + srclen;
-
- while (src < srcend)
- {
- unsigned char ch = *src++;
- if (ch < 0x80) /* special fast case for 7-bit ASCII */
- {
- ret++;
- continue;
- }
- if ((res = decodeUtf8Char(ch, &src, srcend)) <= 0x10ffff)
- {
- if (res > 0xffff) ret++;
- ret++;
- }
- else return -2; /* bad char */
- /* otherwise ignore it */
- }
- return ret;
-}
-
-/* UTF-8 to wide char string conversion */
-/* return -1 on dst buffer overflow, -2 on invalid input char */
-int Utf8toUcs2(const char *src, int srclen, wchar_t *dst, int dstlen)
-{
- unsigned int res;
- const char *srcend = src + srclen;
- wchar_t *dstend = dst + dstlen;
-
- while ((dst < dstend) && (src < srcend))
- {
- unsigned char ch = *src++;
- if (ch < 0x80) /* special fast case for 7-bit ASCII */
- {
- *dst++ = ch;
- continue;
- }
- if ((res = decodeUtf8Char(ch, &src, srcend)) <= 0xffff)
- {
- *dst++ = res;
- }
- else if (res <= 0x10ffff) /* we need surrogates */
- {
- if (dst == dstend - 1) return -1; /* overflow */
- res -= 0x10000;
- *dst++ = 0xd800 | (res >> 10);
- *dst++ = 0xdc00 | (res & 0x3ff);
- }
- else return -2; /* bad char */
- /* otherwise ignore it */
- }
- if (src < srcend) return -1; /* overflow */
- return dstlen - (dstend - dst);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Decode - converts UTF8-encoded string to the UCS2/MBCS format
-
-char* Utf8DecodeCP(char* str, int codepage, wchar_t** ucs2)
-{
- int len;
- bool needs_free = false;
- wchar_t* tempBuf = NULL;
- if ( ucs2 )
- *ucs2 = NULL;
-
- if (str == NULL)
- return NULL;
-
- len = (int)strlen(str);
-
- if (len < 2) {
- if (ucs2 != NULL) {
- *ucs2 = tempBuf = (wchar_t*)malloc((len + 1) * sizeof(wchar_t));
- MultiByteToWideChar(codepage, 0, str, len, tempBuf, len);
- tempBuf[len] = 0;
- }
- return str;
- }
-
- int destlen = Utf8toUcs2Len(str, len);
- if (destlen < 0)
- return NULL;
-
- if (ucs2 == NULL) {
- __try
- {
- tempBuf = (wchar_t*)alloca((destlen + 1) * sizeof(wchar_t));
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- tempBuf = NULL;
- needs_free = true;
- }
- }
-
- if ( tempBuf == NULL ) {
- tempBuf = (wchar_t*)malloc((destlen + 1) * sizeof(wchar_t));
- if ( tempBuf == NULL )
- return NULL;
- }
-
- Utf8toUcs2(str, len, tempBuf, destlen);
- tempBuf[destlen] = 0;
- WideCharToMultiByte(codepage, 0, tempBuf, -1, str, len + 1, "?", NULL);
-
- if (ucs2)
- *ucs2 = tempBuf;
- else if (needs_free)
- free(tempBuf);
-
- return str;
-}
-
-wchar_t* Utf8DecodeUcs2(const char* str)
-{
- if (str == NULL)
- return NULL;
-
- int len = (int)strlen(str);
-
- int destlen = Utf8toUcs2Len(str, len);
- if (destlen < 0) return NULL;
-
- wchar_t* ucs2 = (wchar_t*)malloc((destlen + 1) * sizeof(wchar_t));
- if (ucs2 == NULL) return NULL;
-
- if (Utf8toUcs2(str, len, ucs2, destlen) >= 0)
- {
- ucs2[destlen] = 0;
- return ucs2;
- }
-
- free(ucs2);
-
- return NULL;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Encode - converts MBCS string to the UTF8-encoded format
-
-char* Utf8EncodeCP(const char* src, int codepage)
-{
- int len;
- bool needs_free = false;
- char* result = NULL;
- wchar_t* tempBuf;
-
- if (src == NULL)
- return NULL;
-
- len = (int)strlen(src);
-
- __try
- {
- tempBuf = (wchar_t*)alloca((len + 1) * sizeof(wchar_t));
- }
- __except(EXCEPTION_EXECUTE_HANDLER)
- {
- tempBuf = (wchar_t*)malloc((len + 1) * sizeof(wchar_t));
- if (tempBuf == NULL) return NULL;
- needs_free = true;
- }
-
- len = MultiByteToWideChar(codepage, 0, src, -1, tempBuf, len + 1);
-
- int destlen = Ucs2toUtf8Len(tempBuf, len);
- if (destlen >= 0)
- {
- result = (char*)malloc(destlen + 1);
- if (result)
- {
- Ucs2toUtf8(tempBuf, len, result, destlen);
- result[destlen] = 0;
- }
- }
-
- if (needs_free)
- free(tempBuf);
-
- return result;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Utf8Encode - converts UCS2 string to the UTF8-encoded format
-
-char* Utf8EncodeUcs2(const wchar_t* src)
-{
- if (src == NULL)
- return NULL;
-
- int len = (int)wcslen(src);
-
- int destlen = Ucs2toUtf8Len(src, len);
- if (destlen < 0) return NULL;
-
- char* result = (char*)malloc(destlen + 1);
- if (result == NULL)
- return NULL;
-
- Ucs2toUtf8(src, len, result, destlen);
- result[destlen] = 0;
-
- return result;
-}
-
bool is_utf8_string(const char* str)
{
int expect_bytes = 0, utf_found = 0;
diff --git a/tools/dbtool/wizard.cpp b/tools/dbtool/wizard.cpp
index 49e20b9e2e..10c711cd0f 100644
--- a/tools/dbtool/wizard.cpp
+++ b/tools/dbtool/wizard.cpp
@@ -97,7 +97,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPara
SendMessage(hdlg,WM_SETICON,ICON_SMALL,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(IDI_DBTOOL)));
hdlgPage=NULL;
SendMessage(hdlg,WZM_GOTOPAGE,IDD_WELCOME,(LPARAM)WelcomeDlgProc);
- TranslateDialog(hdlg);
+ TranslateDialogDefault(hdlg);
return TRUE;
case WZM_GOTOPAGE:
if(hdlgPage!=NULL) DestroyWindow(hdlgPage);
@@ -106,7 +106,7 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPara
EnableWindow(GetDlgItem(hdlg,IDCANCEL),TRUE);
SetDlgItemText(hdlg,IDCANCEL,TranslateT("Cancel"));
hdlgPage=CreateDialog(hInst,MAKEINTRESOURCE(wParam),hdlg,(DLGPROC)lParam);
- TranslateDialog(hdlgPage);
+ TranslateDialogDefault(hdlgPage);
SetWindowPos(hdlgPage,0,0,0,0,0,SWP_NOZORDER|SWP_NOSIZE);
ShowWindow(hdlgPage,SW_SHOW);
break;
@@ -129,7 +129,6 @@ INT_PTR CALLBACK WizardDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lPara
if (opts.hOutFile)
CloseHandle(opts.hOutFile);
DestroyWindow(hdlgPage);
- UnloadLangPackModule();
if(hBoldFont!=NULL) DeleteObject(hBoldFont);
if(hEmfHeaderLogo!=NULL) DeleteEnhMetaFile(hEmfHeaderLogo);
break;