From cea2cbc276fc337f95ab665bd766c5a467980e4e Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sun, 20 May 2012 18:11:52 +0000 Subject: project fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@103 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Bonsai/Bonsai.cpp | 136 ++++++ plugins/Bonsai/Bonsai.filters | 95 ++++ plugins/Bonsai/Bonsai.html | 11 - plugins/Bonsai/Bonsai.rc | 121 +++++ plugins/Bonsai/Bonsai.sln | 5 +- plugins/Bonsai/Bonsai.vcxproj | 220 +++++++++ plugins/Bonsai/FixOptions/Bonsai.cpp | 136 ------ plugins/Bonsai/FixOptions/Bonsai.rc | 121 ----- plugins/Bonsai/FixOptions/FixOptions.vcxproj | 217 --------- .../Bonsai/FixOptions/FixOptions.vcxproj.filters | 95 ---- plugins/Bonsai/FixOptions/OptArrange.rc | 111 ----- plugins/Bonsai/FixOptions/commonheaders.h | 92 ---- plugins/Bonsai/FixOptions/dlg_handlers.cpp | 456 ------------------ plugins/Bonsai/FixOptions/dlg_handlers.h | 50 -- plugins/Bonsai/FixOptions/hooked_events.cpp | 92 ---- plugins/Bonsai/FixOptions/hooked_events.h | 39 -- plugins/Bonsai/FixOptions/icons/hidden.bmp | Bin 822 -> 0 bytes plugins/Bonsai/FixOptions/icons/modified.bmp | Bin 822 -> 0 bytes plugins/Bonsai/FixOptions/icons/newlymodified.bmp | Bin 1062 -> 0 bytes plugins/Bonsai/FixOptions/icons/unmodified.bmp | Bin 822 -> 0 bytes plugins/Bonsai/FixOptions/list.cpp | 228 --------- plugins/Bonsai/FixOptions/list.h | 94 ---- plugins/Bonsai/FixOptions/resource.h | 28 -- plugins/Bonsai/FixOptions/services.cpp | 192 -------- plugins/Bonsai/FixOptions/services.h | 40 -- plugins/Bonsai/FixOptions/utils.cpp | 527 --------------------- plugins/Bonsai/FixOptions/utils.h | 64 --- plugins/Bonsai/FixOptions/version.h | 49 -- plugins/Bonsai/FixOptions/version.rc | 100 ---- plugins/Bonsai/OptArrange.rc | 111 +++++ plugins/Bonsai/commonheaders.h | 92 ++++ plugins/Bonsai/dlg_handlers.cpp | 456 ++++++++++++++++++ plugins/Bonsai/dlg_handlers.h | 50 ++ plugins/Bonsai/files_release.txt | 1 - plugins/Bonsai/files_releasex64.txt | 1 - plugins/Bonsai/files_source.txt | 3 - plugins/Bonsai/hooked_events.cpp | 92 ++++ plugins/Bonsai/hooked_events.h | 39 ++ plugins/Bonsai/icons/hidden.bmp | Bin 0 -> 822 bytes plugins/Bonsai/icons/modified.bmp | Bin 0 -> 822 bytes plugins/Bonsai/icons/newlymodified.bmp | Bin 0 -> 1062 bytes plugins/Bonsai/icons/unmodified.bmp | Bin 0 -> 822 bytes plugins/Bonsai/list.cpp | 228 +++++++++ plugins/Bonsai/list.h | 94 ++++ plugins/Bonsai/pack source.bat | 8 - plugins/Bonsai/pack symbols.bat | 9 - plugins/Bonsai/pack x64.bat | 10 - plugins/Bonsai/pack.bat | 10 - plugins/Bonsai/resource.h | 28 ++ plugins/Bonsai/screenshot.png | Bin 56668 -> 0 bytes plugins/Bonsai/services.cpp | 192 ++++++++ plugins/Bonsai/services.h | 40 ++ plugins/Bonsai/symbols_exclude.txt | 1 - plugins/Bonsai/utils.cpp | 527 +++++++++++++++++++++ plugins/Bonsai/utils.h | 64 +++ plugins/Bonsai/version.h | 49 ++ plugins/Bonsai/version.rc | 100 ++++ 57 files changed, 2738 insertions(+), 2786 deletions(-) create mode 100644 plugins/Bonsai/Bonsai.cpp create mode 100644 plugins/Bonsai/Bonsai.filters delete mode 100644 plugins/Bonsai/Bonsai.html create mode 100644 plugins/Bonsai/Bonsai.rc create mode 100644 plugins/Bonsai/Bonsai.vcxproj delete mode 100644 plugins/Bonsai/FixOptions/Bonsai.cpp delete mode 100644 plugins/Bonsai/FixOptions/Bonsai.rc delete mode 100644 plugins/Bonsai/FixOptions/FixOptions.vcxproj delete mode 100644 plugins/Bonsai/FixOptions/FixOptions.vcxproj.filters delete mode 100644 plugins/Bonsai/FixOptions/OptArrange.rc delete mode 100644 plugins/Bonsai/FixOptions/commonheaders.h delete mode 100644 plugins/Bonsai/FixOptions/dlg_handlers.cpp delete mode 100644 plugins/Bonsai/FixOptions/dlg_handlers.h delete mode 100644 plugins/Bonsai/FixOptions/hooked_events.cpp delete mode 100644 plugins/Bonsai/FixOptions/hooked_events.h delete mode 100644 plugins/Bonsai/FixOptions/icons/hidden.bmp delete mode 100644 plugins/Bonsai/FixOptions/icons/modified.bmp delete mode 100644 plugins/Bonsai/FixOptions/icons/newlymodified.bmp delete mode 100644 plugins/Bonsai/FixOptions/icons/unmodified.bmp delete mode 100644 plugins/Bonsai/FixOptions/list.cpp delete mode 100644 plugins/Bonsai/FixOptions/list.h delete mode 100644 plugins/Bonsai/FixOptions/resource.h delete mode 100644 plugins/Bonsai/FixOptions/services.cpp delete mode 100644 plugins/Bonsai/FixOptions/services.h delete mode 100644 plugins/Bonsai/FixOptions/utils.cpp delete mode 100644 plugins/Bonsai/FixOptions/utils.h delete mode 100644 plugins/Bonsai/FixOptions/version.h delete mode 100644 plugins/Bonsai/FixOptions/version.rc create mode 100644 plugins/Bonsai/OptArrange.rc create mode 100644 plugins/Bonsai/commonheaders.h create mode 100644 plugins/Bonsai/dlg_handlers.cpp create mode 100644 plugins/Bonsai/dlg_handlers.h delete mode 100644 plugins/Bonsai/files_release.txt delete mode 100644 plugins/Bonsai/files_releasex64.txt delete mode 100644 plugins/Bonsai/files_source.txt create mode 100644 plugins/Bonsai/hooked_events.cpp create mode 100644 plugins/Bonsai/hooked_events.h create mode 100644 plugins/Bonsai/icons/hidden.bmp create mode 100644 plugins/Bonsai/icons/modified.bmp create mode 100644 plugins/Bonsai/icons/newlymodified.bmp create mode 100644 plugins/Bonsai/icons/unmodified.bmp create mode 100644 plugins/Bonsai/list.cpp create mode 100644 plugins/Bonsai/list.h delete mode 100644 plugins/Bonsai/pack source.bat delete mode 100644 plugins/Bonsai/pack symbols.bat delete mode 100644 plugins/Bonsai/pack x64.bat delete mode 100644 plugins/Bonsai/pack.bat create mode 100644 plugins/Bonsai/resource.h delete mode 100644 plugins/Bonsai/screenshot.png create mode 100644 plugins/Bonsai/services.cpp create mode 100644 plugins/Bonsai/services.h delete mode 100644 plugins/Bonsai/symbols_exclude.txt create mode 100644 plugins/Bonsai/utils.cpp create mode 100644 plugins/Bonsai/utils.h create mode 100644 plugins/Bonsai/version.h create mode 100644 plugins/Bonsai/version.rc (limited to 'plugins/Bonsai') diff --git a/plugins/Bonsai/Bonsai.cpp b/plugins/Bonsai/Bonsai.cpp new file mode 100644 index 0000000000..bea3156f89 --- /dev/null +++ b/plugins/Bonsai/Bonsai.cpp @@ -0,0 +1,136 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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 ICON_SIZE 16 + +char ModuleName[] = "Bonsai"; +HINSTANCE hInstance; +int bUseANSIStrings = 0; + +HBITMAP hbModified = NULL; +HBITMAP hbUnmodified = NULL; +HBITMAP hbHidden = NULL; +HBITMAP hbNewlyModified = NULL; +HIMAGELIST imgList = NULL; + +PLUGINLINK *pluginLink; +int hLangpack; +struct MM_INTERFACE mmi; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_DISPLAY_NAME, + VERSION, + __DESC, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + 1, //unicode aware + 0, + {0x2fe47261, 0x7f38, 0x45f4, {0x8f, 0xac, 0xb8, 0x7e, 0x97, 0x4a, 0x13, 0x50}} //{2fe47261-7f38-45f4-8fac-b87e974a1350} + }; //not used + +OLD_MIRANDAPLUGININFO_SUPPORT; + +extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion) +{ +// Log("%s", "Entering function " __FUNCTION__); +// Log("%s", "Leaving function " __FUNCTION__); + if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 6, 0, 0)) + { + return NULL; + } + return &pluginInfo; +} + +static const MUUID interfaces[] = {MIID_BONSAI, MIID_LAST}; + +extern "C" __declspec(dllexport) const MUUID *MirandaPluginInterfaces() +{ + return interfaces; +} + +extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) +{ + INITCOMMONCONTROLSEX icex; + icex.dwSize = sizeof(INITCOMMONCONTROLSEX); + icex.dwICC = ICC_LISTVIEW_CLASSES; + + InitCommonControls(); + + LogInit(); + + pluginLink = link; + mir_getMMI(&mmi); + mir_getLP(&pluginInfo); + + InitServices(); + + HookEvents(); + + hbModified = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MODIFIED)); + hbUnmodified = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UNMODIFIED)); + hbHidden = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_HIDDEN)); + hbNewlyModified = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_NEWLYMODIFIED)); + imgList = ImageList_Create(ICON_SIZE, ICON_SIZE, ILC_COLORDDB | ILC_MASK, 2, 1); + ImageList_AddMasked(imgList, hbUnmodified, RGB(255, 0, 255)); + ImageList_AddMasked(imgList, hbModified, RGB(255, 0, 255)); + ImageList_AddMasked(imgList, hbHidden, RGB(255, 0, 255)); + ImageList_AddMasked(imgList, hbNewlyModified, RGB(255, 0, 255)); + + //are we running on Windows 98 ? + OSVERSIONINFO vi = {0}; + vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&vi); + bUseANSIStrings = (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 0 : 1; + char mirVer[512]; + CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(mirVer), (LPARAM) mirVer); + _strlwr(mirVer); + bUseANSIStrings = (strstr(mirVer, "unicode") == NULL) ? 1 : bUseANSIStrings; + Log("Windows 98 ? %d", bUseANSIStrings); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload() +{ + DestroyServices(); + + UnhookEvents(); + + ImageList_Destroy(imgList); + + return 0; +} + +bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInstance = hinstDLL; + if (fdwReason == DLL_PROCESS_ATTACH) + { + DisableThreadLibraryCalls(hinstDLL); + } + + return TRUE; +} + diff --git a/plugins/Bonsai/Bonsai.filters b/plugins/Bonsai/Bonsai.filters new file mode 100644 index 0000000000..3bb27e93ca --- /dev/null +++ b/plugins/Bonsai/Bonsai.filters @@ -0,0 +1,95 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + \ No newline at end of file diff --git a/plugins/Bonsai/Bonsai.html b/plugins/Bonsai/Bonsai.html deleted file mode 100644 index 37c9753ac2..0000000000 --- a/plugins/Bonsai/Bonsai.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -
-

Bonsai Test Page

- -

Bonsai version 0.0.2.5

-

Bonsai.zip

-
- - diff --git a/plugins/Bonsai/Bonsai.rc b/plugins/Bonsai/Bonsai.rc new file mode 100644 index 0000000000..fbb66130c3 --- /dev/null +++ b/plugins/Bonsai/Bonsai.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT_FIXOPTIONS DIALOGEX 0, 0, 314, 240 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Plugins",IDC_STATIC,4,4,306,182 + CONTROL "",IDC_LIST_PLUGINS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,8,11,298,171 + GROUPBOX "Options group and title",IDC_STATIC,4,189,306,47 + LTEXT "Group:",IDC_STATIC,8,202,47,8 + EDITTEXT IDC_GROUP,57,199,127,14,ES_AUTOHSCROLL + LTEXT "Title:",IDC_STATIC,8,219,47,8 + EDITTEXT IDC_TITLE,57,215,127,14,ES_AUTOHSCROLL + PUSHBUTTON "&Save",IDC_SAVE,256,200,50,14 + PUSHBUTTON "&Reset",IDC_CANCEL,256,215,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT_FIXOPTIONS, DIALOG + BEGIN + LEFTMARGIN, 4 + RIGHTMARGIN, 310 + VERTGUIDE, 8 + VERTGUIDE, 306 + TOPMARGIN, 4 + BOTTOMMARGIN, 236 + HORZGUIDE, 11 + HORZGUIDE, 182 + HORZGUIDE, 189 + HORZGUIDE, 229 + HORZGUIDE, 231 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_MODIFIED BITMAP "icons\\modified.bmp" +IDB_UNMODIFIED BITMAP "icons\\unmodified.bmp" +IDB_NEWLYMODIFIED BITMAP "icons\\newlymodified.bmp" +IDB_HIDDEN BITMAP "icons\\hidden.bmp" +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/Bonsai/Bonsai.sln b/plugins/Bonsai/Bonsai.sln index 78b93e62cd..8a446a5ac1 100644 --- a/plugins/Bonsai/Bonsai.sln +++ b/plugins/Bonsai/Bonsai.sln @@ -1,9 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Bonsai", "FixOptions\FixOptions.vcxproj", "{C2F9A2EE-128B-43BD-9F3A-DAD0D954CB67}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Bonsai", "Bonsai.vcxproj", "{C2F9A2EE-128B-43BD-9F3A-DAD0D954CB67}" EndProject Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 diff --git a/plugins/Bonsai/Bonsai.vcxproj b/plugins/Bonsai/Bonsai.vcxproj new file mode 100644 index 0000000000..b175ed70c2 --- /dev/null +++ b/plugins/Bonsai/Bonsai.vcxproj @@ -0,0 +1,220 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Bonsai + {C2F9A2EE-128B-43BD-9F3A-DAD0D954CB67} + Bonsai + Win32Proj + + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + true + true + true + true + + + + Disabled + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_WINDOWS;_USRDLL;FIXOPTIONS_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Level3 + EditAndContinue + + + comctl32.lib;%(AdditionalDependencies) + true + Windows + $(IntDir)$(TargetName).lib + 0x2F080000 + false + + + ../../include/msapi + + + + + X64 + + + Disabled + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_DEPRECATE;WIN64;_DEBUG;_WINDOWS;_USRDLL;FIXOPTIONS_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Level3 + + + comctl32.lib;%(AdditionalDependencies) + true + Windows + $(IntDir)$(TargetName).lib + 0x2F080000 + false + + + ../../include/msapi + + + + + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_WINDOWS;_USRDLL;FIXOPTIONS_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + Full + Size + OnlyExplicitInline + + + comctl32.lib;%(AdditionalDependencies) + true + Windows + true + true + 0x2F080000 + $(IntDir)$(TargetName).lib + false + + + ../../include/msapi + + + + + X64 + + + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_DEPRECATE;WIN64;NDEBUG;_WINDOWS;_USRDLL;FIXOPTIONS_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + Full + Size + OnlyExplicitInline + + + comctl32.lib;%(AdditionalDependencies) + true + Windows + true + true + 0x2F080000 + $(IntDir)$(TargetName).lib + false + + + ../../include/msapi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/Bonsai.cpp b/plugins/Bonsai/FixOptions/Bonsai.cpp deleted file mode 100644 index bea3156f89..0000000000 --- a/plugins/Bonsai/FixOptions/Bonsai.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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 ICON_SIZE 16 - -char ModuleName[] = "Bonsai"; -HINSTANCE hInstance; -int bUseANSIStrings = 0; - -HBITMAP hbModified = NULL; -HBITMAP hbUnmodified = NULL; -HBITMAP hbHidden = NULL; -HBITMAP hbNewlyModified = NULL; -HIMAGELIST imgList = NULL; - -PLUGINLINK *pluginLink; -int hLangpack; -struct MM_INTERFACE mmi; - -PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - __PLUGIN_DISPLAY_NAME, - VERSION, - __DESC, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - 1, //unicode aware - 0, - {0x2fe47261, 0x7f38, 0x45f4, {0x8f, 0xac, 0xb8, 0x7e, 0x97, 0x4a, 0x13, 0x50}} //{2fe47261-7f38-45f4-8fac-b87e974a1350} - }; //not used - -OLD_MIRANDAPLUGININFO_SUPPORT; - -extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion) -{ -// Log("%s", "Entering function " __FUNCTION__); -// Log("%s", "Leaving function " __FUNCTION__); - if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 6, 0, 0)) - { - return NULL; - } - return &pluginInfo; -} - -static const MUUID interfaces[] = {MIID_BONSAI, MIID_LAST}; - -extern "C" __declspec(dllexport) const MUUID *MirandaPluginInterfaces() -{ - return interfaces; -} - -extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) -{ - INITCOMMONCONTROLSEX icex; - icex.dwSize = sizeof(INITCOMMONCONTROLSEX); - icex.dwICC = ICC_LISTVIEW_CLASSES; - - InitCommonControls(); - - LogInit(); - - pluginLink = link; - mir_getMMI(&mmi); - mir_getLP(&pluginInfo); - - InitServices(); - - HookEvents(); - - hbModified = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MODIFIED)); - hbUnmodified = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_UNMODIFIED)); - hbHidden = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_HIDDEN)); - hbNewlyModified = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_NEWLYMODIFIED)); - imgList = ImageList_Create(ICON_SIZE, ICON_SIZE, ILC_COLORDDB | ILC_MASK, 2, 1); - ImageList_AddMasked(imgList, hbUnmodified, RGB(255, 0, 255)); - ImageList_AddMasked(imgList, hbModified, RGB(255, 0, 255)); - ImageList_AddMasked(imgList, hbHidden, RGB(255, 0, 255)); - ImageList_AddMasked(imgList, hbNewlyModified, RGB(255, 0, 255)); - - //are we running on Windows 98 ? - OSVERSIONINFO vi = {0}; - vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&vi); - bUseANSIStrings = (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) ? 0 : 1; - char mirVer[512]; - CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof(mirVer), (LPARAM) mirVer); - _strlwr(mirVer); - bUseANSIStrings = (strstr(mirVer, "unicode") == NULL) ? 1 : bUseANSIStrings; - Log("Windows 98 ? %d", bUseANSIStrings); - - return 0; -} - -extern "C" int __declspec(dllexport) Unload() -{ - DestroyServices(); - - UnhookEvents(); - - ImageList_Destroy(imgList); - - return 0; -} - -bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) -{ - hInstance = hinstDLL; - if (fdwReason == DLL_PROCESS_ATTACH) - { - DisableThreadLibraryCalls(hinstDLL); - } - - return TRUE; -} - diff --git a/plugins/Bonsai/FixOptions/Bonsai.rc b/plugins/Bonsai/FixOptions/Bonsai.rc deleted file mode 100644 index fbb66130c3..0000000000 --- a/plugins/Bonsai/FixOptions/Bonsai.rc +++ /dev/null @@ -1,121 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPT_FIXOPTIONS DIALOGEX 0, 0, 314, 240 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Dialog" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Plugins",IDC_STATIC,4,4,306,182 - CONTROL "",IDC_LIST_PLUGINS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,8,11,298,171 - GROUPBOX "Options group and title",IDC_STATIC,4,189,306,47 - LTEXT "Group:",IDC_STATIC,8,202,47,8 - EDITTEXT IDC_GROUP,57,199,127,14,ES_AUTOHSCROLL - LTEXT "Title:",IDC_STATIC,8,219,47,8 - EDITTEXT IDC_TITLE,57,215,127,14,ES_AUTOHSCROLL - PUSHBUTTON "&Save",IDC_SAVE,256,200,50,14 - PUSHBUTTON "&Reset",IDC_CANCEL,256,215,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPT_FIXOPTIONS, DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 310 - VERTGUIDE, 8 - VERTGUIDE, 306 - TOPMARGIN, 4 - BOTTOMMARGIN, 236 - HORZGUIDE, 11 - HORZGUIDE, 182 - HORZGUIDE, 189 - HORZGUIDE, 229 - HORZGUIDE, 231 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_MODIFIED BITMAP "icons\\modified.bmp" -IDB_UNMODIFIED BITMAP "icons\\unmodified.bmp" -IDB_NEWLYMODIFIED BITMAP "icons\\newlymodified.bmp" -IDB_HIDDEN BITMAP "icons\\hidden.bmp" -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/Bonsai/FixOptions/FixOptions.vcxproj b/plugins/Bonsai/FixOptions/FixOptions.vcxproj deleted file mode 100644 index 67a96c954e..0000000000 --- a/plugins/Bonsai/FixOptions/FixOptions.vcxproj +++ /dev/null @@ -1,217 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - Bonsai - {C2F9A2EE-128B-43BD-9F3A-DAD0D954CB67} - Bonsai - Win32Proj - - - - DynamicLibrary - NotSet - true - - - DynamicLibrary - NotSet - - - DynamicLibrary - NotSet - true - - - DynamicLibrary - NotSet - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)/Plugins\ - $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ - true - $(SolutionDir)$(Configuration)64/Plugins\ - $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ - true - $(SolutionDir)$(Configuration)/Plugins\ - $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ - false - $(SolutionDir)$(Configuration)64/Plugins\ - $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ - false - - - - Disabled - ../../../include;../../ExternalAPI;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_WINDOWS;_USRDLL;FIXOPTIONS_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - - - comctl32.lib;%(AdditionalDependencies) - true - Windows - MachineX86 - $(IntDir)$(TargetName).lib - - - - - X64 - - - Disabled - ../../../include;../../ExternalAPI;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_DEPRECATE;WIN64;_DEBUG;_WINDOWS;_USRDLL;FIXOPTIONS_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - - - comctl32.lib;%(AdditionalDependencies) - true - Windows - MachineX64 - $(IntDir)$(TargetName).lib - - - - - ../../../include;../../ExternalAPI;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_WINDOWS;_USRDLL;FIXOPTIONS_EXPORTS;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - Full - Size - OnlyExplicitInline - - - unicows.lib;comctl32.lib;%(AdditionalDependencies) - true - Windows - true - true - 0x2F080000 - MachineX86 - $(IntDir)$(TargetName).lib - - - - - X64 - - - ../../../include;../../ExternalAPI;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_DEPRECATE;WIN64;NDEBUG;_WINDOWS;_USRDLL;FIXOPTIONS_EXPORTS;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - Full - Size - OnlyExplicitInline - - - comctl32.lib;%(AdditionalDependencies) - true - Windows - true - true - 0x2F080000 - MachineX64 - $(IntDir)$(TargetName).lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/FixOptions.vcxproj.filters b/plugins/Bonsai/FixOptions/FixOptions.vcxproj.filters deleted file mode 100644 index 3bb27e93ca..0000000000 --- a/plugins/Bonsai/FixOptions/FixOptions.vcxproj.filters +++ /dev/null @@ -1,95 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - Resource Files - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/OptArrange.rc b/plugins/Bonsai/FixOptions/OptArrange.rc deleted file mode 100644 index ba9a6a0c50..0000000000 --- a/plugins/Bonsai/FixOptions/OptArrange.rc +++ /dev/null @@ -1,111 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPT_FIXOPTIONS DIALOGEX 0, 0, 314, 240 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Dialog" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Plugins",IDC_STATIC,4,4,306,182 - CONTROL "",IDC_LIST_PLUGINS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,8,11,298,171 - GROUPBOX "Options group and title",IDC_STATIC,4,189,306,47 - LTEXT "Group:",IDC_STATIC,8,202,47,8 - EDITTEXT IDC_GROUP,57,199,127,14,ES_AUTOHSCROLL - LTEXT "Title:",IDC_STATIC,8,219,47,8 - EDITTEXT IDC_TITLE,57,215,127,14,ES_AUTOHSCROLL - PUSHBUTTON "&Reset",IDC_CANCEL,256,215,50,14 - PUSHBUTTON "&Save",IDC_SAVE,256,200,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPT_FIXOPTIONS, DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 310 - VERTGUIDE, 8 - VERTGUIDE, 306 - TOPMARGIN, 4 - BOTTOMMARGIN, 236 - HORZGUIDE, 11 - HORZGUIDE, 182 - HORZGUIDE, 189 - HORZGUIDE, 229 - HORZGUIDE, 231 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/Bonsai/FixOptions/commonheaders.h b/plugins/Bonsai/FixOptions/commonheaders.h deleted file mode 100644 index 29ebda9d46..0000000000 --- a/plugins/Bonsai/FixOptions/commonheaders.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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_BONSAI_COMMONHEADERS_H -#define M_BONSAI_COMMONHEADERS_H - -#define MIRANDA_VER 0x0A00 - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef MODULES_H_ -typedef INT_PTR (*MIRANDASERVICE)(WPARAM,LPARAM); -#endif - -#include "newpluginapi.h" -#include "m_database.h" -#include "m_contacts.h" -#include "m_langpack.h" -#include "m_options.h" -//#include "m_hotkeys.h" -//#include "sdk/m_hotkeysplus.h" -#include "m_popup.h" -#include "m_utils.h" -#include "m_updater.h" -#include "m_system.h" - -#include "version.h" -#include "utils.h" -#include "services.h" -#include "list.h" -#include "dlg_handlers.h" -#include "hooked_events.h" - -#include "resource.h" - -extern char ModuleName[]; -extern HINSTANCE hInstance; -extern PLUGINLINK *pluginLink; -extern int bUseANSIStrings; - -extern HBITMAP hbModified; -extern HBITMAP hbUnmodified; -extern HBITMAP hbNewlyModified; -extern HIMAGELIST imgList; - -#define OLD_MIRANDAPLUGININFO_SUPPORT PLUGININFO oldPluginInfo = { \ - sizeof(PLUGININFO), \ - pluginInfo.shortName, \ - pluginInfo.version, \ - pluginInfo.description, \ - pluginInfo.author, \ - pluginInfo.authorEmail, \ - pluginInfo.copyright, \ - pluginInfo.homepage, \ - pluginInfo.flags, \ - pluginInfo.replacesDefaultModule \ -}; \ -\ -extern "C" __declspec(dllexport) PLUGININFO *MirandaPluginInfo(DWORD mirandaVersion) \ -{ \ - if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 6, 0, 0)) \ - { \ - return NULL; \ - } \ - return &oldPluginInfo; \ -} - -#endif //M_WWI_COMMONHEADERS_H \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/dlg_handlers.cpp b/plugins/Bonsai/FixOptions/dlg_handlers.cpp deleted file mode 100644 index 7bceb1026e..0000000000 --- a/plugins/Bonsai/FixOptions/dlg_handlers.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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 "dlg_handlers.h" -#include "commctrl.h" - -#define CMP(a, b) ( ((a == b) ? 0 : ((a < b) ? -1 : 1)) ) - -HWND hOptDlg = NULL; - -const char *szColumns[] = {"Plugin", "Current group", "Current title", "Initial group", "Initial title"}; -const int cxColumns[] = {100, 120, 120, 120, 120}; -const int cColumns = sizeof(szColumns) / sizeof(szColumns[0]); - -WNDPROC oldPluginsListProc = NULL; - -inline int SettingChanged(WCHAR *defaultSetting, WCHAR *currentSetting, int nullTrueValue, int trueValue, int falseValue) -{ - if (currentSetting == NULL) - { - return ((defaultSetting != NULL) && (wcslen(defaultSetting) != 0)) ? nullTrueValue : falseValue; - } - else{ - return (_wcsicmp(currentSetting, defaultSetting)) ? trueValue : falseValue; - } -} - -void UpdatePlugin(HWND hList, int index, PPluginOptions plugin, int newlyModified) -{ - const int MAX_SIZE = 256; - WCHAR buffer[MAX_SIZE]; - - GetPluginGroup(plugin, buffer, MAX_SIZE); - ListView_SetItemTextW(hList, index, 1, buffer); - - GetPluginTitle(plugin, buffer, MAX_SIZE); - ListView_SetItemTextW(hList, index, 2, buffer); - - if (newlyModified) - { - LVITEM item = {0}; - item.iItem = index; - item.mask = LVIF_IMAGE; - item.iImage = 3; - ListView_SetItem(hList, &item); - } - - ListView_SetItemTextW(hList, index, 3, plugin->szGroup); - - ListView_SetItemTextW(hList, index, 4, plugin->szTitle); -} - -int ItemOptionEntryChanged(int index, PPluginOptions plugin) -{ - const int MAX_SIZE = 256; - WCHAR buffer[MAX_SIZE]; - WCHAR *res; - - int changed = 0; - - res = GetPluginGroup(plugin, buffer, MAX_SIZE); - changed = SettingChanged(plugin->szGroup, res, 1, 1, 0); -// changed = (res == NULL) ? plugin->szGroup != NULL : (_wcsicmp(buffer, plugin->szGroup)) ? 1 : 0; - - res = GetPluginTitle(plugin, buffer, MAX_SIZE); - changed = SettingChanged(plugin->szTitle, res, 2, 1, changed); -// changed = (res == NULL) ? plugin->szTitle != NULL : (_wcsicmp(buffer, plugin->szTitle)) ? 1 : changed; - - return changed; -} - -void LoadPlugins(HWND hWnd, int bAll = 1) -{ - HWND hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); - - if (bAll) - { - ListView_DeleteAllItems(hList); - } - - int i; - int init = (bAll) ? 0 : ListView_GetItemCount(hList); - PPluginOptions plugin = NULL; - - LVITEMW item = {0}; - item.mask = LVIF_INDENT | LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM; - for (i = init; i < lstPluginOptions.Count(); i++) - { - plugin = lstPluginOptions[i]; - item.iItem = i; - item.lParam = (LPARAM) plugin; - item.pszText = plugin->szPlugin; - item.iImage = ItemOptionEntryChanged(i, plugin); - ListView_InsertItemW(hList, &item); - - UpdatePlugin(hList, i, plugin, 0); - } -} - -struct SortParams{ - HWND hList; - int column; -}; - -static int lastColumn = -1; - -int CALLBACK PluginsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam) -{ - SortParams params = *(SortParams *) myParam; - int res; - const int MAX_SIZE = 1024; - - wchar_t text1[MAX_SIZE]; - wchar_t text2[MAX_SIZE]; - - ListView_GetItemTextW(params.hList, (int) lParam1, params.column, text1, MAX_SIZE); - ListView_GetItemTextW(params.hList, (int) lParam2, params.column, text2, MAX_SIZE); - - res = _wcsicmp(text1, text2); - - res = (params.column == lastColumn) ? -res : res; - - return res; -} - -int LoadColumns(HWND hList) -{ - int i; - int start = 0; - LVCOLUMN col; - col.mask = LVCF_TEXT | LVCF_WIDTH; - - while (ListView_DeleteColumn(hList, 1)) //delete all columns - { - start = 1; - } - - for (i = start; i < cColumns; i++) - { - col.pszText = TranslateTS(szColumns[i]); - - col.cx = cxColumns[i]; - - ListView_InsertColumn(hList, i, &col); - } - - return 0; -} - -void LoadPluginInfo(HWND hWnd, PPluginOptions plugin) -{ - if (plugin) - { - const int MAX_SIZE = 256; - WCHAR buffer[MAX_SIZE]; - - GetPluginGroup(plugin, buffer, MAX_SIZE); - SetWindowTextW(GetDlgItem(hWnd, IDC_GROUP), buffer); - - GetPluginTitle(plugin, buffer, MAX_SIZE); - SetWindowTextW(GetDlgItem(hWnd, IDC_TITLE), buffer); - } -} - -PPluginOptions GetSelectedPlugin(HWND hWnd, int *index = NULL) -{ - int i; - HWND hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); - int count = ListView_GetItemCount(hList); - for (i = 0; i < count; i++) - { - if (ListView_GetItemState(hList, i, LVIS_SELECTED) == LVIS_SELECTED) - { - LVITEM item = {0}; - item.iItem = i; - item.mask = LVIF_PARAM; - - if (index) - { - *index = i; - } - - ListView_GetItem(hList, &item); - return (PPluginOptions) item.lParam; - } - } - - if (index) - { - *index = -1; - } - return NULL; -} - -INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static int bInitializing = 0; - switch (msg) - { - case WM_INITDIALOG: - { - bInitializing = 1; - hOptDlg = hWnd; - HWND hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); - - TranslateDialogDefault(hWnd); - - ListView_SetExtendedListViewStyleEx(hList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); - //ListView_SetImageList(hList, imgList, LVSIL_NORMAL); - ImageList_SetBkColor(imgList, RGB(255, 255, 255)); - ListView_SetImageList(hList, imgList, LVSIL_SMALL); - - //ListView_SetImageList(hList, imgList, LVSIL_STATE); - - LoadColumns(hList); - - LoadPlugins(hWnd); - - SortParams params = {0}; - params.hList = hList; - params.column = DBGetContactSettingByte(NULL, ModuleName, "LastSortColumn", -1); - ListView_SortItemsEx(hList, PluginsCompare, ¶ms); - - EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 0); - EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), 0); - EnableWindow(GetDlgItem(hWnd, IDC_GROUP), 0); - EnableWindow(GetDlgItem(hWnd, IDC_TITLE), 0); - - bInitializing = 0; - return TRUE; - break; - } - - case WM_DESTROY: - { - DBWriteContactSettingByte(NULL, ModuleName, "LastSortColumn", lastColumn); - hOptDlg = NULL; - - lastColumn = -1; - - break; - } - - case FOM_UPDATEPLUGINS: - { - LoadPlugins(hWnd, 0); - - break; - } - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_GROUP: - case IDC_TITLE: - { - if ((HIWORD(wParam) == EN_CHANGE)) - { - if (!bInitializing) - { - EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 1); - EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), 1); - } - } - - break; - } - - case IDC_SAVE: - { - int index; - PPluginOptions plugin = GetSelectedPlugin(hWnd, &index); - if (plugin) - { - WCHAR buffer[256]; - int changed = 0; - - GetWindowTextW(GetDlgItem(hWnd, IDC_GROUP), buffer, 256); - SavePluginGroup(plugin, buffer); - changed = (_wcsicmp(plugin->szGroup, buffer) != 0) ? 1 : 0; - - GetWindowTextW(GetDlgItem(hWnd, IDC_TITLE), buffer, 256); - SavePluginTitle(plugin, buffer); - changed = (_wcsicmp(plugin->szTitle, buffer) != 0) ? 1 : changed; - - UpdatePlugin(GetDlgItem(hWnd, IDC_LIST_PLUGINS), index, plugin, 1); - - } - EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 0); - - break; - } - - case IDC_CANCEL: - { - int state = GetKeyState(VK_CONTROL); - if (state & (1 << 8)) //ctrl pressed - { - if (MessageBox(hWnd, Translate("This will reset all plugins to their default group and title.\nDo you wish to reset all plugins to their default group and title ?"), Translate("Proceed ?"), MB_YESNO | MB_ICONWARNING) == IDYES) - { - int i; - HWND hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); - int count = ListView_GetItemCount(hList); - LVITEM item = {0}; - item.mask = LVIF_PARAM; - - PPluginOptions plugin; - - for (i = 0; i < count; i++) - { - item.iItem = i; - ListView_GetItem(hList, &item); - plugin = (PPluginOptions) item.lParam; - SavePluginGroup(plugin, plugin->szGroup); - SavePluginTitle(plugin, plugin->szTitle); - UpdatePlugin(hList, i, plugin, 1); - } - - LoadPluginInfo(hWnd, GetSelectedPlugin(hWnd)); - } - } - else{ - int index; - PPluginOptions plugin = GetSelectedPlugin(hWnd, &index); - if (plugin) - { - SavePluginGroup(plugin, plugin->szGroup); - SavePluginTitle(plugin, plugin->szTitle); - - UpdatePlugin(GetDlgItem(hWnd, IDC_LIST_PLUGINS), index, plugin, 1); - LoadPluginInfo(hWnd, GetSelectedPlugin(hWnd)); - } - - EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 0); - EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), 0); - } - - break; - } - } - - break; - } - - case WM_NOTIFY: - { - switch(((LPNMHDR)lParam)->idFrom) - { - case 0: - { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - // - - break; - } - } - - break; - } - - case IDC_LIST_PLUGINS: - { - switch (((LPNMHDR)lParam)->code) - { - case LVN_COLUMNCLICK: - { - LPNMLISTVIEW lv = (LPNMLISTVIEW) lParam; - int column = lv->iSubItem; - SortParams params = {0}; - params.hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); - params.column = column; - - ListView_SortItemsEx(params.hList, PluginsCompare, (LPARAM) ¶ms); - lastColumn = (params.column == lastColumn) ? -1 : params.column; - - break; - } - - case LVN_ITEMCHANGED: - { - NMLISTVIEW *data = (NMLISTVIEW *) lParam; - if (data->uNewState & LVIS_SELECTED) //new item - { - LoadPluginInfo(hWnd, GetSelectedPlugin(hWnd)); - - EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 0); - EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), 1); - EnableWindow(GetDlgItem(hWnd, IDC_GROUP), 1); - EnableWindow(GetDlgItem(hWnd, IDC_TITLE), 1); - } - else{ //selected item - if (data->uOldState & LVIS_SELECTED) - { - const int MAX_SIZE = 256; - PPluginOptions plugin = (PPluginOptions) data->lParam; - if (plugin) - { - WCHAR group[MAX_SIZE]; - WCHAR title[MAX_SIZE]; - WCHAR newGroup[MAX_SIZE]; - WCHAR newTitle[MAX_SIZE]; - - GetPluginGroup(plugin, group, MAX_SIZE); - GetPluginTitle(plugin, title, MAX_SIZE); - GetWindowTextW(GetDlgItem(hWnd, IDC_GROUP), newGroup, MAX_SIZE); - GetWindowTextW(GetDlgItem(hWnd, IDC_TITLE), newTitle, MAX_SIZE); - - if ((wcscmp(group, newGroup)) || (wcscmp(title, newTitle))) - { - if (MessageBox(hWnd, Translate("Do you want to save the changes now ?"), Translate("Changes not saved"), MB_YESNO | MB_ICONINFORMATION) == IDYES) - { - SavePluginGroup(plugin, newGroup); - SavePluginTitle(plugin, newTitle); - - UpdatePlugin(GetDlgItem(hWnd, IDC_LIST_PLUGINS), data->iItem, plugin, 1); - } - } - } - } - } - - break; - } - } - - break; - } - } - - break; - } - } - - return 0; -} \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/dlg_handlers.h b/plugins/Bonsai/FixOptions/dlg_handlers.h deleted file mode 100644 index f51e7bb0d2..0000000000 --- a/plugins/Bonsai/FixOptions/dlg_handlers.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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_BONSAI_DLGHANDLERS_H -#define M_BONSAI_DLGHANDLERS_H - -#include "commonheaders.h" - -#define ListView_GetItemTextW(hwndLV, i, iSubItem_, pszText_, cchTextMax_) \ -{ LVITEMW _ms_lvi;\ - _ms_lvi.iSubItem = iSubItem_;\ - _ms_lvi.cchTextMax = cchTextMax_;\ - _ms_lvi.pszText = pszText_;\ - SNDMSG((hwndLV), LVM_GETITEMTEXTW, (WPARAM)(i), (LPARAM)(LVITEMW *)&_ms_lvi);\ -} - -#define ListView_SetItemTextW(hwndLV, i, iSubItem_, pszText_) \ -{ LVITEMW _ms_lvi;\ - _ms_lvi.iSubItem = iSubItem_;\ - _ms_lvi.pszText = pszText_;\ - SNDMSG((hwndLV), LVM_SETITEMTEXTW, (WPARAM)(i), (LPARAM)(LVITEMW *)&_ms_lvi);\ -} - -#define ListView_InsertItemW(hwnd, pitem) \ - (int)SNDMSG((hwnd), LVM_INSERTITEMW, 0, (LPARAM)(const LVITEMW *)(pitem)) - -#define FOM_UPDATEPLUGINS (WM_USER + 10) - -extern HWND hOptDlg; - -INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -#endif \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/hooked_events.cpp b/plugins/Bonsai/FixOptions/hooked_events.cpp deleted file mode 100644 index ba1ee85d91..0000000000 --- a/plugins/Bonsai/FixOptions/hooked_events.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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 "hooked_events.h" - -HANDLE hModulesLoaded; -HANDLE hOptionsInitialize; - -UINT_PTR hRefreshTimer = NULL; - -#define HOST "http://eblis.tla.ro/projects" - -#if defined(WIN64) || defined(_WIN64) - #define FIXOPTIONS_VERSION_URL HOST "/miranda/Bonsai/updater/x64/Bonsai.html" - #define FIXOPTIONS_UPDATE_URL HOST "/miranda/Bonsai/updater/x64/Bonsai.zip" -#else - #define FIXOPTIONS_VERSION_URL HOST "/miranda/Bonsai/updater/Bonsai.html" - #define FIXOPTIONS_UPDATE_URL HOST "/miranda/Bonsai/updater/Bonsai.zip" -#endif -#define FIXOPTIONS_VERSION_PREFIX "Bonsai version " - - -int HookEvents() -{ - hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise); - - //UpdateTimer(); - - return 0; -} - -int UnhookEvents() -{ - UnhookEvent(hModulesLoaded); - UnhookEvent(hOptionsInitialize); - - return 0; -} - -int OnModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - char buffer[1024]; - Update update = {0}; - update.cbSize = sizeof(Update); - update.szComponentName = __PLUGIN_DISPLAY_NAME; - update.pbVersion = (BYTE *) CreateVersionString(VERSION, buffer); - update.cpbVersion = (int) strlen((char *) update.pbVersion); - update.szUpdateURL = UPDATER_AUTOREGISTER; - update.szBetaVersionURL = FIXOPTIONS_VERSION_URL; - update.szBetaUpdateURL = FIXOPTIONS_UPDATE_URL; - update.pbBetaVersionPrefix = (BYTE *) FIXOPTIONS_VERSION_PREFIX; - update.cpbBetaVersionPrefix = (int) strlen(FIXOPTIONS_VERSION_PREFIX); - CallService(MS_UPDATE_REGISTER, 0, (LPARAM) &update); - - return 0; -} - -int OnOptionsInitialise(WPARAM wParam, LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = {0}; - - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInstance; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FIXOPTIONS); - odp.ptszTitle = TranslateT("Arrange Options"); - odp.ptszGroup = TranslateT("Services"); - odp.groupPosition = 810000000; - odp.flags=ODPF_BOLDGROUPS; - odp.pfnDlgProc = DlgProcOptions; - CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp); - - return 0; -} \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/hooked_events.h b/plugins/Bonsai/FixOptions/hooked_events.h deleted file mode 100644 index 70c1a0d0c6..0000000000 --- a/plugins/Bonsai/FixOptions/hooked_events.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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_BONSAI_HOOKED_EVENTS_H -#define M_BONSAI_HOOKED_EVENTS_H - -#include "commonheaders.h" -#include "dlg_handlers.h" - -extern HANDLE hModulesLoaded; -extern HANDLE hOptionsInitialize; - -extern UINT_PTR hRefreshTimer; - -int HookEvents(); -int UnhookEvents(); - -int OnModulesLoaded(WPARAM wParam, LPARAM lParam); -int OnOptionsInitialise(WPARAM wParam, LPARAM lParam); - -#endif \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/icons/hidden.bmp b/plugins/Bonsai/FixOptions/icons/hidden.bmp deleted file mode 100644 index 6ec1e60428..0000000000 Binary files a/plugins/Bonsai/FixOptions/icons/hidden.bmp and /dev/null differ diff --git a/plugins/Bonsai/FixOptions/icons/modified.bmp b/plugins/Bonsai/FixOptions/icons/modified.bmp deleted file mode 100644 index 1d9e13262a..0000000000 Binary files a/plugins/Bonsai/FixOptions/icons/modified.bmp and /dev/null differ diff --git a/plugins/Bonsai/FixOptions/icons/newlymodified.bmp b/plugins/Bonsai/FixOptions/icons/newlymodified.bmp deleted file mode 100644 index 87f7cc48f4..0000000000 Binary files a/plugins/Bonsai/FixOptions/icons/newlymodified.bmp and /dev/null differ diff --git a/plugins/Bonsai/FixOptions/icons/unmodified.bmp b/plugins/Bonsai/FixOptions/icons/unmodified.bmp deleted file mode 100644 index c9d552c032..0000000000 Binary files a/plugins/Bonsai/FixOptions/icons/unmodified.bmp and /dev/null differ diff --git a/plugins/Bonsai/FixOptions/list.cpp b/plugins/Bonsai/FixOptions/list.cpp deleted file mode 100644 index a7ce5c1033..0000000000 --- a/plugins/Bonsai/FixOptions/list.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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 "list.h" - -COptionsList &lstPluginOptions = COptionsList(); - -COptionsList::COptionsList(int initialCapacity) -{ - _plugins = NULL; - _count = 0; - _capacity = 0; - - Enlarge(initialCapacity); -} - -COptionsList::~COptionsList() -{ - Clear(); - free(_plugins); -} - -void COptionsList::Clear() -{ - int i; - for (i = 0; i < Count(); i++) - { - delete _plugins[i]; - } - _count = 0; -} - -int COptionsList::Count() const -{ - return _count; -} - -int COptionsList::Capacity() const -{ - return _capacity; -} - -void COptionsList::EnsureCapacity() -{ - if (_count >= _capacity) - { - Enlarge(_capacity / 2); - } -} - -void COptionsList::Enlarge(int increaseAmount) -{ - int newSize = _capacity + increaseAmount; - _plugins = (PPluginOptions *) realloc(_plugins, newSize * sizeof(PPluginOptions)); - _capacity = newSize; -} - -int COptionsList::Contains(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) const -{ - int pos = Index(plugin, group, title); - return (pos >= 0); -} - -int COptionsList::Index(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) const -{ - int i; - DWORD hPlugin = LangPackHashW(plugin); - DWORD hGroup = LangPackHashW(group); - DWORD hTitle = LangPackHashW(title); - PPluginOptions p; - - for (i = 0; i < Count(); i++) - { - p = _plugins[i]; - if ((hPlugin == p->pluginHash) && (hGroup == p->groupHash) && (hTitle == p->titleHash)) - { - return i; - } - } - - return -1; -} - -int COptionsList::Add(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) -{ - int pos = Index(plugin, group, title); - if (pos < 0) - { - EnsureCapacity(); - - PPluginOptions s = new TPluginOptions(plugin, group, title, LangPackHashW(plugin), LangPackHashW(group), LangPackHashW(title)); - _plugins[_count++] = s; - if (hOptDlg) - { - SendMessage(hOptDlg, FOM_UPDATEPLUGINS, 0, 0); - } - pos = _count - 1; - } - - return pos; -} - -int COptionsList::Remove(int index) -{ - if ((index < 0) && (index >= Count())) - { - return 1; - } - - int i; - PPluginOptions tmp = _plugins[index]; - for (i = index; i < _count - 1; i++) - { - _plugins[i] = _plugins[i + 1]; - } - _count--; - delete tmp; - - return 0; -} - -const PPluginOptions COptionsList::operator [](int index) -{ - if ((index < 0) || (index >= Count())) - { - return NULL; - } - - return _plugins[index]; -} - -char *BuildPluginUniqueID(PPluginOptions plugin, char *out, int size, int type) -{ - mir_snprintf(out, size, "%lu-%lu-%lu-%s", plugin->pluginHash, plugin->groupHash, plugin->titleHash, (type == ID_GROUP) ? "G" : "T"); - - return out; -} - -WCHAR *GetPluginGroup(PPluginOptions plugin, WCHAR *group, int count) -{ - char name[256]; - WCHAR *res = plugin->szGroup; - - BuildPluginUniqueID(plugin, name, 256, ID_GROUP); - - GetStringFromDatabase(name, plugin->szGroup, group, count); - res = (wcslen(group) == 0) ? NULL : group; - - return res; -} - -WCHAR *GetPluginTitle(PPluginOptions plugin, WCHAR *title, int count) -{ - char name[256]; - WCHAR *res = plugin->szTitle; - - BuildPluginUniqueID(plugin, name, 256, ID_TITLE); - - GetStringFromDatabase(name, plugin->szTitle, title, count); - res = (wcslen(title) == 0) ? NULL : title; - - return res; -} - -void SavePluginGroup(PPluginOptions plugin, WCHAR *newGroup) -{ - char name[256]; - int del = 0; - - BuildPluginUniqueID(plugin, name, 256, ID_GROUP); - - if (plugin->szGroup) - { - del = (wcscmp(plugin->szGroup, newGroup) == 0) ? 1 : 0; - } - else{ - del = ((!newGroup) || (wcslen(newGroup) == 0)) ? 1 : 0; - } - - if (del) - { - DBDeleteContactSetting(NULL, ModuleName, name); - } - else{ - DBWriteContactSettingWString(NULL, ModuleName, name, newGroup); - } -} - -void SavePluginTitle(PPluginOptions plugin, WCHAR *newTitle) -{ - char name[256]; - int del = 0; - - BuildPluginUniqueID(plugin, name, sizeof(name), ID_TITLE); - - if (plugin->szTitle) - { - del = (wcscmp(plugin->szTitle, newTitle) == 0) ? 1 : 0; - } - else{ - del = ((!newTitle) || (wcslen(newTitle)) == 0) ? 1 : 0; - } - - if (del) - { - DBDeleteContactSetting(NULL, ModuleName, name); - } - else{ - DBWriteContactSettingWString(NULL, ModuleName, name, newTitle); - } -} \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/list.h b/plugins/Bonsai/FixOptions/list.h deleted file mode 100644 index 7143cb0f55..0000000000 --- a/plugins/Bonsai/FixOptions/list.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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_BONSAI_LIST_H -#define M_BONSAI_LIST_H - -#define INITIAL_SIZE 20 - -#include "commonheaders.h" - -#define ID_GROUP 1 -#define ID_TITLE 2 - -struct TPluginOptions{ - WCHAR *szPlugin; - WCHAR *szGroup; - WCHAR *szTitle; - - DWORD pluginHash; - DWORD groupHash; - DWORD titleHash; - - TPluginOptions(const WCHAR *plugin, const WCHAR *group, const WCHAR *title, DWORD pluginHash, DWORD groupHash, DWORD titleHash) - { - szPlugin = _wcsdup(plugin); - szGroup = _wcsdup(group); - szTitle = _wcsdup(title); - this->pluginHash = pluginHash; - this->groupHash = groupHash; - this->titleHash = titleHash; - } - - ~TPluginOptions() - { - free(this->szPlugin); - free(this->szGroup); - free(this->szTitle); - } -}; - -typedef TPluginOptions *PPluginOptions; - -class COptionsList{ - protected: - PPluginOptions *_plugins; - int _count; - int _capacity; - - void Enlarge(int increaseAmount); - void EnsureCapacity(); - - public: - COptionsList(int initialSize = INITIAL_SIZE); - ~COptionsList(); - - void Clear(); - - int Add(const WCHAR *plugin, const WCHAR *group, const WCHAR *title); - int Remove(int index); - int Contains(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) const; - int Index(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) const; - - const PPluginOptions operator [](int index); - - int Count() const; - int Capacity() const; -}; - -extern COptionsList &lstPluginOptions; //list of services - -WCHAR *BuildPluginUniqueID(PPluginOptions plugin, WCHAR *out, int size, int type); -WCHAR *GetPluginGroup(PPluginOptions plugin, WCHAR *group, int count); -WCHAR *GetPluginTitle(PPluginOptions plugin, WCHAR *title, int count); -void SavePluginGroup(PPluginOptions plugin, WCHAR *newGroup); -void SavePluginTitle(PPluginOptions plugin, WCHAR *newTitle); - -#endif //M_SERVICESLIST_LIST_H \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/resource.h b/plugins/Bonsai/FixOptions/resource.h deleted file mode 100644 index fa0aefbfec..0000000000 --- a/plugins/Bonsai/FixOptions/resource.h +++ /dev/null @@ -1,28 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Bonsai.rc -// -#define IDD_FIXOPTIONS 101 -#define IDD_OPT_FIXOPTIONS 101 -#define IDB_MODIFIED 104 -#define IDB_UNMODIFIED 105 -#define IDB_NEWLYMODIFIED 106 -#define IDB_BITMAP1 107 -#define IDB_HIDDEN 107 -#define IDC_LIST_PLUGINS 1003 -#define IDC_GROUP 1004 -#define IDC_TITLE 1006 -#define IDC_SAVE 1007 -#define IDC_CANCEL 1008 -#define IDC_BUTTON1 1009 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 108 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1010 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/Bonsai/FixOptions/services.cpp b/plugins/Bonsai/FixOptions/services.cpp deleted file mode 100644 index 64d7f92c72..0000000000 --- a/plugins/Bonsai/FixOptions/services.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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 "services.h" - -static CRITICAL_SECTION csServices; - -static DWORD OPTIONS_ADDPAGE_HASH = NameHashFunction(MS_OPT_ADDPAGE); - -CALLSERVICEFUNCTION realCallServiceFunction = NULL; - -int InitServices() -{ - InitializeCriticalSection(&csServices); - - HookRealServices(); - - return 0; -} - -int DestroyServices() -{ - UnhookRealServices(); - - DeleteCriticalSection(&csServices); - - return 0; -} - -void HookRealServices() -{ - Log("Hooking real CallService(). Replacing 0x%p with 0x%p", pluginLink->CallService, BonsaiCallServiceFunction); - realCallServiceFunction = pluginLink->CallService; - pluginLink->CallService = BonsaiCallServiceFunction; -} - -void UnhookRealServices() -{ - Log("Unhooking real CallService(). Replacing 0x%p with 0x%p", pluginLink->CallService, realCallServiceFunction); - EnterCriticalSection(&csServices); - - pluginLink->CallService = realCallServiceFunction; - - LeaveCriticalSection(&csServices); -} - -INT_PTR BonsaiCallServiceFunction(const char *name, WPARAM wParam, LPARAM lParam) -{ - int res; - int run = 1; - int fix = 0; - const int MAX_SIZE = 256; - WCHAR group[MAX_SIZE]; - WCHAR title[MAX_SIZE]; - WCHAR tabTitle[MAX_SIZE]; - - BYTE temp[200] = {0}; - OPTIONSDIALOGPAGE *options = (OPTIONSDIALOGPAGE *) lParam; - - if (NameHashFunction(name) == OPTIONS_ADDPAGE_HASH) - { - memmove(temp, options, options->cbSize); - options = (OPTIONSDIALOGPAGE *) temp; - //EnterCriticalSection(&csServices); - if ((options->cbSize > 60) && !(options->flags & ODPF_UNICODE) && (options->pszTab) && (!bUseANSIStrings)) - { - MultiByteToWideChar(CP_ACP, 0, options->pszTab, -1, tabTitle, MAX_SIZE); - options->pszTab = (char *) tabTitle; - } - - FixPluginOptions(name, options, group, MAX_SIZE, title, MAX_SIZE); - if (!options->pszTitle) - { - run = 0; - } - } - res = (run) ? realCallServiceFunction(name, wParam, (LPARAM) options) : CALLSERVICE_NOTFOUND; - - return res; -} - -int FixPluginOptions(const char *serviceName, void *options, WCHAR *group, int cGroup, WCHAR *title, int cTitle) -{ - MEMORY_BASIC_INFORMATION mbi; - HINSTANCE hInstance; - const int MODULE_MAX_SIZE = 256; - char mod[MODULE_MAX_SIZE]; - WCHAR plugin[MODULE_MAX_SIZE]; - mod[0] = '\0'; - if(VirtualQuery(serviceName, &mbi, sizeof(mbi) )) - { - hInstance = (HINSTANCE)(mbi.AllocationBase); - char mod_path[MAX_PATH]; - GetModuleFileName(hInstance, mod_path, MAX_PATH); - // chop path - char *p = strrchr(mod_path, '.'); - if (p) - { - p[0] = '\0'; - } - - p = strrchr(mod_path, '\\'); - if(p) - { - p++; - strncpy(mod, p, sizeof(mod)); - } - } - - if (strlen(mod) > 0) - { - if (bUseANSIStrings) - { - _strlwr(mod); - } - MultiByteToWideChar(CP_ACP, 0, mod, -1, plugin, MODULE_MAX_SIZE); - const int MAX_SIZE = 256; - WCHAR temp1[MAX_SIZE]; - WCHAR temp2[MAX_SIZE]; - WCHAR *optGroup = temp1; - WCHAR *optTitle = temp2; - OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE *) options; - temp1[0] = temp2[0] = L'\0'; - - if ((odp->flags & ODPF_UNICODE) && (odp->cbSize > 40)) - { - - optGroup = (WCHAR *) odp->pszGroup; - optTitle = (WCHAR *) odp->pszTitle; - - Log("[UNICODE] %-15S - Initial options location %S->%S (unicode)", plugin, optGroup, optTitle); - } - else{ - Log(" %-15S - Initial options location %s->%s", plugin, odp->pszGroup, odp->pszTitle); - MultiByteToWideChar(CP_ACP, 0, odp->pszGroup, -1, temp1, MAX_SIZE); - MultiByteToWideChar(CP_ACP, 0, odp->pszTitle, -1, temp2, MAX_SIZE); - - if (odp->cbSize > 40) //some old plugins don't have flags variable in structure - { - odp->flags |= ODPF_UNICODE; - } - } - - int index = lstPluginOptions.Add(plugin, optGroup, optTitle); - odp->pszGroup = (char *) GetPluginGroup(lstPluginOptions[index], group, cGroup); - odp->pszTitle = (char *) GetPluginTitle(lstPluginOptions[index], title, cTitle); - Log("[UNICODE] %-15S - New options location %S->%S", plugin, odp->pszGroup, odp->pszTitle); - - if ((bUseANSIStrings) || (odp->cbSize <= 40)) //if plugins doesn't have flags variable in structure then they only support ansi strings - { - Log(" Plugin is either very old or we're running on Windows 98, converting back to ansi strings ..."); - WCHAR temp[MAX_SIZE]; - - if (odp->pszGroup) - { - wcsncpy(temp, (WCHAR *) odp->pszGroup, MAX_SIZE); - WideCharToMultiByte(CP_ACP, 0, temp, -1, odp->pszGroup, cGroup, NULL, NULL); - } - - if (odp->pszTitle) - { - wcsncpy(temp, (WCHAR *) odp->pszTitle, MAX_SIZE); - WideCharToMultiByte(CP_ACP, 0, temp, -1, odp->pszTitle, cTitle, NULL, NULL); - } - - if (odp->cbSize > 40) - { - Log(" Windows98 - Resetting ODPF_UNICODE flag"); - odp->flags &= ~ODPF_UNICODE; - } - } - } - - return 0; -} \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/services.h b/plugins/Bonsai/FixOptions/services.h deleted file mode 100644 index a78ba2b75c..0000000000 --- a/plugins/Bonsai/FixOptions/services.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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_BONSAI_SERVICES_H -#define M_BONSAI_SERVICES_H - -#include "commonheaders.h" - -typedef INT_PTR (*CALLSERVICEFUNCTION) (const char *, WPARAM wParam, LPARAM lParam); - -extern CALLSERVICEFUNCTION realCallServiceFunction; - -int InitServices(); -int DestroyServices(); - -void HookRealServices(); -void UnhookRealServices(); - -INT_PTR BonsaiCallServiceFunction(const char *name, WPARAM wParam, LPARAM lParam); - -int FixPluginOptions(const char *serviceName, void *options, WCHAR *group, int cGroup, WCHAR *title, int cTitle); - -#endif //M_SERVICESLIST_SERVICES_H diff --git a/plugins/Bonsai/FixOptions/utils.cpp b/plugins/Bonsai/FixOptions/utils.cpp deleted file mode 100644 index 3f30dc44ad..0000000000 --- a/plugins/Bonsai/FixOptions/utils.cpp +++ /dev/null @@ -1,527 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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 "utils.h" - -int LogInit() -{ -#ifdef USE_LOG - //FILE *fout = fopen(LOG_FILE, "wt"); - //fclose(fout); - Log("********************** Miranda started **********************"); -#endif - return 0; -} - -int Log(char *format, ...) -{ -#ifdef USE_LOG - char str[4096]; - va_list vararg; - int tBytes; - FILE *fout = fopen(LOG_FILE, "at"); - if (!fout) - { -// MessageBox(0, "can't open file", NULL, MB_OK); - return -1; - } - time_t tNow = time(NULL); - struct tm *now = localtime(&tNow); - strftime(str, sizeof(str), "%d %b %Y @ %H:%M:%S: ", now); - fputs(str, fout); - va_start(vararg, format); - - tBytes = _vsnprintf(str, sizeof(str), format, vararg); - if (tBytes > 0) - { - str[tBytes] = 0; - } - - va_end(vararg); - if (str[strlen(str) - 1] != '\n') - { - strcat(str, "\n"); - } - fputs(str, fout); - fclose(fout); -#endif - return 0; -} - -int Info(char *title, char *format, ...) -{ - char str[4096]; - va_list vararg; - int tBytes; - va_start(vararg, format); - tBytes = _vsnprintf(str, sizeof(str), format, vararg); - if (tBytes > 0) - { - str[tBytes] = 0; - } - va_end(vararg); - return MessageBoxA(0, str, title, MB_OK | MB_ICONINFORMATION); -} - -int MyPUShowMessage(char *lpzText, BYTE kind) -{ - if (ServiceExists(MS_POPUP_SHOWMESSAGE)) - { - return PUShowMessage(lpzText, kind); - } - else{ - char *title = (kind == SM_NOTIFY) ? Translate("Notify") : Translate("Warning"); - - return MessageBox(NULL, lpzText, title, MB_OK | (kind == SM_NOTIFY) ? MB_ICONINFORMATION : MB_ICONEXCLAMATION); - } -} - -#define HEX_SIZE 8 - -char *BinToHex(int size, PBYTE data) -{ - char *szresult = NULL; - char buffer[32] = {0}; //should be more than enough - int maxSize = size * 2 + HEX_SIZE + 1; - szresult = (char *) new char[ maxSize ]; - memset(szresult, 0, maxSize); - sprintf(buffer, "%0*X", HEX_SIZE, size); - strcpy(szresult, buffer); - int i; - for (i = 0; i < size; i++) - { - sprintf(buffer, "%02X", data[i]); - strcpy(szresult + (HEX_SIZE + i * 2), buffer); - } - return szresult; -} - -void HexToBin(char *inData, ULONG &size, LPBYTE &outData) -{ - char buffer[32] = {0}; - strcpy(buffer, "0x"); - strncpy(buffer + 2, inData, HEX_SIZE); - sscanf(buffer, "%x", &size); - outData = (unsigned char*)new char[size*2]; - UINT i; - //size = i; - char *tmp = inData + HEX_SIZE; - buffer[4] = '\0'; //mark the end of the string - for (i = 0; i < size; i++) - { - strncpy(buffer + 2, &tmp[i * 2], 2); - sscanf(buffer, "%x", &outData[i]); - } - i = size; -} - -int GetStringFromDatabase(HANDLE hContact, char *szModule, char *szSettingName, char *szError, char *szResult, size_t size) -{ - DBVARIANT dbv = {0}; - int res = 1; - size_t len; - dbv.type = DBVT_ASCIIZ; - if (DBGetContactSetting(hContact, szModule, szSettingName, &dbv) == 0) - { - res = 0; - size_t tmp = strlen(dbv.pszVal); - len = (tmp < size - 1) ? tmp : size - 1; - strncpy(szResult, dbv.pszVal, len); - szResult[len] = '\0'; - mir_free(dbv.pszVal); - } - else{ - res = 1; - if (szError) - { - size_t tmp = strlen(szError); - len = (tmp < size - 1) ? tmp : size - 1; - strncpy(szResult, szError, len); - szResult[len] = '\0'; - } - else{ - szResult[0] = '\0'; - } - } - return res; -} - -int GetStringFromDatabase(HANDLE hContact, char *szModule, char *szSettingName, WCHAR *szError, WCHAR *szResult, size_t count) -{ - DBVARIANT dbv = {0}; - int res = 1; - size_t len; - dbv.type = DBVT_WCHAR; - if (DBGetContactSettingWString(hContact, szModule, szSettingName, &dbv) == 0) - { - res = 0; - if (dbv.type != DBVT_WCHAR) - { - MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, szResult, (int) count); - } - else{ - size_t tmp = wcslen(dbv.pwszVal); - len = (tmp < count - 1) ? tmp : count - 1; - wcsncpy(szResult, dbv.pwszVal, len); - szResult[len] = L'\0'; - } - mir_free(dbv.pwszVal); - } - else{ - res = 1; - if (szError) - { - size_t tmp = wcslen(szError); - len = (tmp < count - 1) ? tmp : count - 1; - wcsncpy(szResult, szError, len); - szResult[len] = L'\0'; - } - else{ - szResult[0] = L'\0'; - } - } - return res; -} - -int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, size_t size) -{ - return GetStringFromDatabase(NULL, ModuleName, szSettingName, szError, szResult, size); -} - -int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult, size_t count) -{ - return GetStringFromDatabase(NULL, ModuleName, szSettingName, szError, szResult, count); -} - -#pragma warning (disable: 4312) -TCHAR *GetContactName(HANDLE hContact, char *szProto) -{ - CONTACTINFO ctInfo; - int ret; - char proto[200]; - - ZeroMemory((void *) &ctInfo, sizeof(ctInfo)); - ctInfo.cbSize = sizeof(ctInfo); - if (szProto) - { - ctInfo.szProto = szProto; - } - else{ - GetContactProtocol(hContact, proto, sizeof(proto)); - ctInfo.szProto = proto; - } - ctInfo.dwFlag = CNF_DISPLAY; -#ifdef _UNICODE - ctInfo.dwFlag += CNF_UNICODE; -#endif - ctInfo.hContact = hContact; - //_debug_message("retrieving contact name for %d", hContact); - ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo); - //_debug_message(" contact name %s", ctInfo.pszVal); - TCHAR *buffer; - if (!ret) - { - buffer = _tcsdup(ctInfo.pszVal); - } - mir_free(ctInfo.pszVal); - if (!ret) - { - return buffer; - } - else{ - return NULL; - } - return buffer; -} -#pragma warning (default: 4312) - -#pragma warning (disable: 4312) -void GetContactProtocol(HANDLE hContact, char *szProto, size_t size) -{ - GetStringFromDatabase(hContact, "Protocol", "p", NULL, szProto, size); -} -#pragma warning (default: 4312) - -#pragma warning (disable: 4312) -TCHAR *GetContactID(HANDLE hContact) -{ - char protocol[256]; - GetContactProtocol(hContact, protocol, sizeof(protocol)); - - return GetContactID(hContact, protocol); -} - -TCHAR *GetContactID(HANDLE hContact, char *szProto) -{ - CONTACTINFO ctInfo; - int ret; - - ZeroMemory((void *) &ctInfo, sizeof(ctInfo)); - ctInfo.cbSize = sizeof(ctInfo); - ctInfo.szProto = szProto; - ctInfo.dwFlag = CNF_UNIQUEID; -#ifdef _UNICODE - ctInfo.dwFlag |= CNF_UNICODE; -#endif - ctInfo.hContact = hContact; - ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo); - TCHAR *buffer; - if (!ret) - { - TCHAR tmp[16]; - switch (ctInfo.type) - { - case CNFT_BYTE: - { - _stprintf(tmp, _T("%d"), ctInfo.bVal); - buffer = _tcsdup(tmp); - - break; - } - - case CNFT_WORD: - { - _stprintf(tmp, _T("%d"), ctInfo.wVal); - buffer = _tcsdup(tmp); - - break; - } - - case CNFT_DWORD: - { - _stprintf(tmp, _T("%ld"), ctInfo.dVal); - buffer = _tcsdup(tmp); - - break; - } - - case CNFT_ASCIIZ: - default: - { - buffer = _tcsdup(ctInfo.pszVal); - - break; - } - } - - - } - mir_free(ctInfo.pszVal); - if (!ret) - { - return buffer; - } - else{ - return NULL; - } -} -#pragma warning (default: 4312) - -#pragma warning (disable: 4312) -HANDLE GetContactFromID(TCHAR *szID, char *szProto) -{ - HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - TCHAR *szHandle; - char cProtocol[256]; - - int found = 0; - while (hContact) - { - GetContactProtocol(hContact, cProtocol, sizeof(cProtocol)); - szHandle = GetContactID(hContact, cProtocol); - if ((szHandle) && (_tcsicmp(szHandle, szID) == 0) && (_stricmp(szProto, cProtocol) == 0)) - { - found = 1; - } - if (szHandle) free(szHandle); - - if (found) - { - break; - } - hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); - } - return hContact; -} -#pragma warning (default: 4312) - -#pragma warning (disable: 4312) -HANDLE GetContactFromID(TCHAR *szID, wchar_t *szProto) -{ - char protocol[1024]; - WideCharToMultiByte(CP_ACP, 0, szProto, -1, protocol, sizeof(protocol), NULL, NULL); - return GetContactFromID(szID, protocol); -} -#pragma warning (default: 4312) - -void ScreenToClient(HWND hWnd, LPRECT rect) -{ - POINT pt; - int cx = rect->right - rect->left; - int cy = rect->bottom - rect->top; - pt.x = rect->left; - pt.y = rect->top; - ScreenToClient(hWnd, &pt); - rect->left = pt.x; - rect->top = pt.y; - rect->right = pt.x + cx; - rect->bottom = pt.y + cy; -} - -void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors) -{ - RECT rParent; - RECT rChild; - - if (parentPos->flags & SWP_NOSIZE) - { - return; - } - GetWindowRect(parentPos->hwnd, &rParent); - rChild = AnchorCalcPos(window, &rParent, parentPos, anchors); - MoveWindow(window, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, FALSE); -} - -RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors) -{ - RECT rChild; - RECT rTmp; - - GetWindowRect(window, &rChild); - ScreenToClient(parentPos->hwnd, &rChild); - - int cx = rParent->right - rParent->left; - int cy = rParent->bottom - rParent->top; - if ((cx == parentPos->cx) && (cy == parentPos->cy)) - { - return rChild; - } - if (parentPos->flags & SWP_NOSIZE) - { - return rChild; - } - - rTmp.left = parentPos->x - rParent->left; - rTmp.right = (parentPos->x + parentPos->cx) - rParent->right; - rTmp.bottom = (parentPos->y + parentPos->cy) - rParent->bottom; - rTmp.top = parentPos->y - rParent->top; - - cx = (rTmp.left) ? -rTmp.left : rTmp.right; - cy = (rTmp.top) ? -rTmp.top : rTmp.bottom; - - rChild.right += cx; - rChild.bottom += cy; - //expanded the window accordingly, now we need to enforce the anchors - if ((anchors & ANCHOR_LEFT) && (!(anchors & ANCHOR_RIGHT))) - { - rChild.right -= cx; - } - if ((anchors & ANCHOR_TOP) && (!(anchors & ANCHOR_BOTTOM))) - { - rChild.bottom -= cy; - } - if ((anchors & ANCHOR_RIGHT) && (!(anchors & ANCHOR_LEFT))) - { - rChild.left += cx; - } - if ((anchors & ANCHOR_BOTTOM) && (!(anchors & ANCHOR_TOP))) - { - rChild.top += cy; - } - return rChild; -} - -DWORD NameHashFunction(const char *szStr) -{ -#if defined _M_IX86 && !defined _NUMEGA_BC_FINALCHECK && !defined NOINLINEASM - __asm { //this breaks if szStr is empty - xor edx,edx - xor eax,eax - mov esi,szStr - cmp esi, 0x0 - je end - mov al,[esi] - xor cl,cl - lph_top: //only 4 of 9 instructions in here don't use AL, so optimal pipe use is impossible - xor edx,eax - inc esi - xor eax,eax - and cl,31 - mov al,[esi] - add cl,5 - test al,al - rol eax,cl //rol is u-pipe only, but pairable - //rol doesn't touch z-flag - jnz lph_top //5 clock tick loop. not bad. - - xor eax,edx - end: - } -#else - DWORD hash=0; - int i; - int shift=0; - for(i=0;szStr[i];i++) { - hash^=szStr[i]<24) hash^=(szStr[i]>>(32-shift))&0x7F; - shift=(shift+5)&0x1F; - } - return hash; -#endif -} - -DWORD LangPackHashW(const WCHAR *szStr) -{ -#if defined _M_IX86 && !defined _NUMEGA_BC_FINALCHECK && !defined __GNUC__ - __asm { //this is mediocrely optimised, but I'm sure it's good enough - xor edx,edx - xor eax, eax - mov esi,szStr - cmp esi, 0x0 - je end - xor cl,cl -lph_top: - xor eax,eax - and cl,31 - mov al,[esi] - inc esi - inc esi - test al,al - jz lph_end - rol eax,cl - add cl,5 - xor edx,eax - jmp lph_top -lph_end: - mov eax,edx -end: - } -#else - DWORD hash=0; - int i; - int shift=0; - for(i=0;szStr[i];i+=2) { - hash^=szStr[i]<24) hash^=(szStr[i]>>(32-shift))&0x7F; - shift=(shift+5)&0x1F; - } - return hash; -#endif -} \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/utils.h b/plugins/Bonsai/FixOptions/utils.h deleted file mode 100644 index db5533c21c..0000000000 --- a/plugins/Bonsai/FixOptions/utils.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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_BONSAI_UTILS_H -#define M_BONSAI_UTILS_H - -#include -#include "commonheaders.h" -#include "list.h" - -//#define USE_LOG -#define LOG_FILE "bonsai.log" - -#define ANCHOR_LEFT 0x000001 -#define ANCHOR_RIGHT 0x000002 -#define ANCHOR_TOP 0x000004 -#define ANCHOR_BOTTOM 0x000008 -#define ANCHOR_ALL ANCHOR_LEFT | ANCHOR_RIGHT | ANCHOR_TOP | ANCHOR_BOTTOM - -int LogInit(); -int Log(char *format, ...); -int Info(char *title, char *format, ...); - -char *BinToHex(int size, PBYTE data); -void HexToBin(char *inData, ULONG &size, PBYTE &outData); - -void ScreenToClient(HWND hWnd, LPRECT rect); -void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors); -RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors); - -int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, size_t size); -int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult, size_t count); - -TCHAR *GetContactName(HANDLE hContact, char *szProto); -TCHAR *GetContactID(HANDLE hContact); -TCHAR *GetContactID(HANDLE hContact, char *szProto); -HANDLE GetContactFromID(TCHAR *szID, char *szProto); -HANDLE GetContactFromID(TCHAR *szID, wchar_t *szProto); -void GetContactProtocol(HANDLE hContact, char *szProto, size_t size); - -DWORD NameHashFunction(const char *szStr); -DWORD LangPackHashW(const WCHAR *szStr); - -int MyPUShowMessage(char *lpzText, BYTE kind); - - -#endif \ No newline at end of file diff --git a/plugins/Bonsai/FixOptions/version.h b/plugins/Bonsai/FixOptions/version.h deleted file mode 100644 index 5ae566b4eb..0000000000 --- a/plugins/Bonsai/FixOptions/version.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -Bonsai plugin for Miranda IM - -Copyright © 2006 Cristian Libotean - -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_BONSAI_VERSION_H -#define M_BONSAI_VERSION_H - -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 0 -#define __RELEASE_NUM 2 -#define __BUILD_NUM 5 - -#define VERSION PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM) - -#define __PLUGINVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __PLUGINVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM -#define __STRINGIFY_(x) #x -#define __STRINGIFY(x) __STRINGIFY_(x) -#define __VERSION_STRING __STRINGIFY(__PLUGINVERSION_STRING_DOTS) - -#define __DESC "This plugin lets you rearrange the options tree by changing the options groups and titles that plugin options are displayed under." -#define __AUTHOR "Cristian Libotean" -#define __AUTHOREMAIL "eblis102@yahoo.com" -#define __COPYRIGHT "© 2006-2007 Cristian Libotean" -#define __AUTHORWEB "http://www.miranda-im.org/" - -#if defined(WIN64) || defined(_WIN64) -#define __PLUGIN_DISPLAY_NAME "Bonsai (x64)" -#else -#define __PLUGIN_DISPLAY_NAME "Bonsai" -#endif - -#endif //M_BONSAI_VERSION_H diff --git a/plugins/Bonsai/FixOptions/version.rc b/plugins/Bonsai/FixOptions/version.rc deleted file mode 100644 index 0f8fea03fc..0000000000 --- a/plugins/Bonsai/FixOptions/version.rc +++ /dev/null @@ -1,100 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" -#include "version.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource1.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __PLUGINVERSION_STRING - PRODUCTVERSION __PLUGINVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Author", __AUTHOR - VALUE "FileDescription", __DESC - VALUE "FileVersion", __VERSION_STRING - VALUE "InternalName", __PLUGIN_DISPLAY_NAME - VALUE "LegalCopyright", __COPYRIGHT - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/Bonsai/OptArrange.rc b/plugins/Bonsai/OptArrange.rc new file mode 100644 index 0000000000..ba9a6a0c50 --- /dev/null +++ b/plugins/Bonsai/OptArrange.rc @@ -0,0 +1,111 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT_FIXOPTIONS DIALOGEX 0, 0, 314, 240 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Plugins",IDC_STATIC,4,4,306,182 + CONTROL "",IDC_LIST_PLUGINS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,8,11,298,171 + GROUPBOX "Options group and title",IDC_STATIC,4,189,306,47 + LTEXT "Group:",IDC_STATIC,8,202,47,8 + EDITTEXT IDC_GROUP,57,199,127,14,ES_AUTOHSCROLL + LTEXT "Title:",IDC_STATIC,8,219,47,8 + EDITTEXT IDC_TITLE,57,215,127,14,ES_AUTOHSCROLL + PUSHBUTTON "&Reset",IDC_CANCEL,256,215,50,14 + PUSHBUTTON "&Save",IDC_SAVE,256,200,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT_FIXOPTIONS, DIALOG + BEGIN + LEFTMARGIN, 4 + RIGHTMARGIN, 310 + VERTGUIDE, 8 + VERTGUIDE, 306 + TOPMARGIN, 4 + BOTTOMMARGIN, 236 + HORZGUIDE, 11 + HORZGUIDE, 182 + HORZGUIDE, 189 + HORZGUIDE, 229 + HORZGUIDE, 231 + END +END +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/Bonsai/commonheaders.h b/plugins/Bonsai/commonheaders.h new file mode 100644 index 0000000000..29ebda9d46 --- /dev/null +++ b/plugins/Bonsai/commonheaders.h @@ -0,0 +1,92 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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_BONSAI_COMMONHEADERS_H +#define M_BONSAI_COMMONHEADERS_H + +#define MIRANDA_VER 0x0A00 + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef MODULES_H_ +typedef INT_PTR (*MIRANDASERVICE)(WPARAM,LPARAM); +#endif + +#include "newpluginapi.h" +#include "m_database.h" +#include "m_contacts.h" +#include "m_langpack.h" +#include "m_options.h" +//#include "m_hotkeys.h" +//#include "sdk/m_hotkeysplus.h" +#include "m_popup.h" +#include "m_utils.h" +#include "m_updater.h" +#include "m_system.h" + +#include "version.h" +#include "utils.h" +#include "services.h" +#include "list.h" +#include "dlg_handlers.h" +#include "hooked_events.h" + +#include "resource.h" + +extern char ModuleName[]; +extern HINSTANCE hInstance; +extern PLUGINLINK *pluginLink; +extern int bUseANSIStrings; + +extern HBITMAP hbModified; +extern HBITMAP hbUnmodified; +extern HBITMAP hbNewlyModified; +extern HIMAGELIST imgList; + +#define OLD_MIRANDAPLUGININFO_SUPPORT PLUGININFO oldPluginInfo = { \ + sizeof(PLUGININFO), \ + pluginInfo.shortName, \ + pluginInfo.version, \ + pluginInfo.description, \ + pluginInfo.author, \ + pluginInfo.authorEmail, \ + pluginInfo.copyright, \ + pluginInfo.homepage, \ + pluginInfo.flags, \ + pluginInfo.replacesDefaultModule \ +}; \ +\ +extern "C" __declspec(dllexport) PLUGININFO *MirandaPluginInfo(DWORD mirandaVersion) \ +{ \ + if (mirandaVersion < PLUGIN_MAKE_VERSION(0, 6, 0, 0)) \ + { \ + return NULL; \ + } \ + return &oldPluginInfo; \ +} + +#endif //M_WWI_COMMONHEADERS_H \ No newline at end of file diff --git a/plugins/Bonsai/dlg_handlers.cpp b/plugins/Bonsai/dlg_handlers.cpp new file mode 100644 index 0000000000..7bceb1026e --- /dev/null +++ b/plugins/Bonsai/dlg_handlers.cpp @@ -0,0 +1,456 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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 "dlg_handlers.h" +#include "commctrl.h" + +#define CMP(a, b) ( ((a == b) ? 0 : ((a < b) ? -1 : 1)) ) + +HWND hOptDlg = NULL; + +const char *szColumns[] = {"Plugin", "Current group", "Current title", "Initial group", "Initial title"}; +const int cxColumns[] = {100, 120, 120, 120, 120}; +const int cColumns = sizeof(szColumns) / sizeof(szColumns[0]); + +WNDPROC oldPluginsListProc = NULL; + +inline int SettingChanged(WCHAR *defaultSetting, WCHAR *currentSetting, int nullTrueValue, int trueValue, int falseValue) +{ + if (currentSetting == NULL) + { + return ((defaultSetting != NULL) && (wcslen(defaultSetting) != 0)) ? nullTrueValue : falseValue; + } + else{ + return (_wcsicmp(currentSetting, defaultSetting)) ? trueValue : falseValue; + } +} + +void UpdatePlugin(HWND hList, int index, PPluginOptions plugin, int newlyModified) +{ + const int MAX_SIZE = 256; + WCHAR buffer[MAX_SIZE]; + + GetPluginGroup(plugin, buffer, MAX_SIZE); + ListView_SetItemTextW(hList, index, 1, buffer); + + GetPluginTitle(plugin, buffer, MAX_SIZE); + ListView_SetItemTextW(hList, index, 2, buffer); + + if (newlyModified) + { + LVITEM item = {0}; + item.iItem = index; + item.mask = LVIF_IMAGE; + item.iImage = 3; + ListView_SetItem(hList, &item); + } + + ListView_SetItemTextW(hList, index, 3, plugin->szGroup); + + ListView_SetItemTextW(hList, index, 4, plugin->szTitle); +} + +int ItemOptionEntryChanged(int index, PPluginOptions plugin) +{ + const int MAX_SIZE = 256; + WCHAR buffer[MAX_SIZE]; + WCHAR *res; + + int changed = 0; + + res = GetPluginGroup(plugin, buffer, MAX_SIZE); + changed = SettingChanged(plugin->szGroup, res, 1, 1, 0); +// changed = (res == NULL) ? plugin->szGroup != NULL : (_wcsicmp(buffer, plugin->szGroup)) ? 1 : 0; + + res = GetPluginTitle(plugin, buffer, MAX_SIZE); + changed = SettingChanged(plugin->szTitle, res, 2, 1, changed); +// changed = (res == NULL) ? plugin->szTitle != NULL : (_wcsicmp(buffer, plugin->szTitle)) ? 1 : changed; + + return changed; +} + +void LoadPlugins(HWND hWnd, int bAll = 1) +{ + HWND hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); + + if (bAll) + { + ListView_DeleteAllItems(hList); + } + + int i; + int init = (bAll) ? 0 : ListView_GetItemCount(hList); + PPluginOptions plugin = NULL; + + LVITEMW item = {0}; + item.mask = LVIF_INDENT | LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM; + for (i = init; i < lstPluginOptions.Count(); i++) + { + plugin = lstPluginOptions[i]; + item.iItem = i; + item.lParam = (LPARAM) plugin; + item.pszText = plugin->szPlugin; + item.iImage = ItemOptionEntryChanged(i, plugin); + ListView_InsertItemW(hList, &item); + + UpdatePlugin(hList, i, plugin, 0); + } +} + +struct SortParams{ + HWND hList; + int column; +}; + +static int lastColumn = -1; + +int CALLBACK PluginsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam) +{ + SortParams params = *(SortParams *) myParam; + int res; + const int MAX_SIZE = 1024; + + wchar_t text1[MAX_SIZE]; + wchar_t text2[MAX_SIZE]; + + ListView_GetItemTextW(params.hList, (int) lParam1, params.column, text1, MAX_SIZE); + ListView_GetItemTextW(params.hList, (int) lParam2, params.column, text2, MAX_SIZE); + + res = _wcsicmp(text1, text2); + + res = (params.column == lastColumn) ? -res : res; + + return res; +} + +int LoadColumns(HWND hList) +{ + int i; + int start = 0; + LVCOLUMN col; + col.mask = LVCF_TEXT | LVCF_WIDTH; + + while (ListView_DeleteColumn(hList, 1)) //delete all columns + { + start = 1; + } + + for (i = start; i < cColumns; i++) + { + col.pszText = TranslateTS(szColumns[i]); + + col.cx = cxColumns[i]; + + ListView_InsertColumn(hList, i, &col); + } + + return 0; +} + +void LoadPluginInfo(HWND hWnd, PPluginOptions plugin) +{ + if (plugin) + { + const int MAX_SIZE = 256; + WCHAR buffer[MAX_SIZE]; + + GetPluginGroup(plugin, buffer, MAX_SIZE); + SetWindowTextW(GetDlgItem(hWnd, IDC_GROUP), buffer); + + GetPluginTitle(plugin, buffer, MAX_SIZE); + SetWindowTextW(GetDlgItem(hWnd, IDC_TITLE), buffer); + } +} + +PPluginOptions GetSelectedPlugin(HWND hWnd, int *index = NULL) +{ + int i; + HWND hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); + int count = ListView_GetItemCount(hList); + for (i = 0; i < count; i++) + { + if (ListView_GetItemState(hList, i, LVIS_SELECTED) == LVIS_SELECTED) + { + LVITEM item = {0}; + item.iItem = i; + item.mask = LVIF_PARAM; + + if (index) + { + *index = i; + } + + ListView_GetItem(hList, &item); + return (PPluginOptions) item.lParam; + } + } + + if (index) + { + *index = -1; + } + return NULL; +} + +INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int bInitializing = 0; + switch (msg) + { + case WM_INITDIALOG: + { + bInitializing = 1; + hOptDlg = hWnd; + HWND hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); + + TranslateDialogDefault(hWnd); + + ListView_SetExtendedListViewStyleEx(hList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); + //ListView_SetImageList(hList, imgList, LVSIL_NORMAL); + ImageList_SetBkColor(imgList, RGB(255, 255, 255)); + ListView_SetImageList(hList, imgList, LVSIL_SMALL); + + //ListView_SetImageList(hList, imgList, LVSIL_STATE); + + LoadColumns(hList); + + LoadPlugins(hWnd); + + SortParams params = {0}; + params.hList = hList; + params.column = DBGetContactSettingByte(NULL, ModuleName, "LastSortColumn", -1); + ListView_SortItemsEx(hList, PluginsCompare, ¶ms); + + EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 0); + EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), 0); + EnableWindow(GetDlgItem(hWnd, IDC_GROUP), 0); + EnableWindow(GetDlgItem(hWnd, IDC_TITLE), 0); + + bInitializing = 0; + return TRUE; + break; + } + + case WM_DESTROY: + { + DBWriteContactSettingByte(NULL, ModuleName, "LastSortColumn", lastColumn); + hOptDlg = NULL; + + lastColumn = -1; + + break; + } + + case FOM_UPDATEPLUGINS: + { + LoadPlugins(hWnd, 0); + + break; + } + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDC_GROUP: + case IDC_TITLE: + { + if ((HIWORD(wParam) == EN_CHANGE)) + { + if (!bInitializing) + { + EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 1); + EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), 1); + } + } + + break; + } + + case IDC_SAVE: + { + int index; + PPluginOptions plugin = GetSelectedPlugin(hWnd, &index); + if (plugin) + { + WCHAR buffer[256]; + int changed = 0; + + GetWindowTextW(GetDlgItem(hWnd, IDC_GROUP), buffer, 256); + SavePluginGroup(plugin, buffer); + changed = (_wcsicmp(plugin->szGroup, buffer) != 0) ? 1 : 0; + + GetWindowTextW(GetDlgItem(hWnd, IDC_TITLE), buffer, 256); + SavePluginTitle(plugin, buffer); + changed = (_wcsicmp(plugin->szTitle, buffer) != 0) ? 1 : changed; + + UpdatePlugin(GetDlgItem(hWnd, IDC_LIST_PLUGINS), index, plugin, 1); + + } + EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 0); + + break; + } + + case IDC_CANCEL: + { + int state = GetKeyState(VK_CONTROL); + if (state & (1 << 8)) //ctrl pressed + { + if (MessageBox(hWnd, Translate("This will reset all plugins to their default group and title.\nDo you wish to reset all plugins to their default group and title ?"), Translate("Proceed ?"), MB_YESNO | MB_ICONWARNING) == IDYES) + { + int i; + HWND hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); + int count = ListView_GetItemCount(hList); + LVITEM item = {0}; + item.mask = LVIF_PARAM; + + PPluginOptions plugin; + + for (i = 0; i < count; i++) + { + item.iItem = i; + ListView_GetItem(hList, &item); + plugin = (PPluginOptions) item.lParam; + SavePluginGroup(plugin, plugin->szGroup); + SavePluginTitle(plugin, plugin->szTitle); + UpdatePlugin(hList, i, plugin, 1); + } + + LoadPluginInfo(hWnd, GetSelectedPlugin(hWnd)); + } + } + else{ + int index; + PPluginOptions plugin = GetSelectedPlugin(hWnd, &index); + if (plugin) + { + SavePluginGroup(plugin, plugin->szGroup); + SavePluginTitle(plugin, plugin->szTitle); + + UpdatePlugin(GetDlgItem(hWnd, IDC_LIST_PLUGINS), index, plugin, 1); + LoadPluginInfo(hWnd, GetSelectedPlugin(hWnd)); + } + + EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 0); + EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), 0); + } + + break; + } + } + + break; + } + + case WM_NOTIFY: + { + switch(((LPNMHDR)lParam)->idFrom) + { + case 0: + { + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + { + // + + break; + } + } + + break; + } + + case IDC_LIST_PLUGINS: + { + switch (((LPNMHDR)lParam)->code) + { + case LVN_COLUMNCLICK: + { + LPNMLISTVIEW lv = (LPNMLISTVIEW) lParam; + int column = lv->iSubItem; + SortParams params = {0}; + params.hList = GetDlgItem(hWnd, IDC_LIST_PLUGINS); + params.column = column; + + ListView_SortItemsEx(params.hList, PluginsCompare, (LPARAM) ¶ms); + lastColumn = (params.column == lastColumn) ? -1 : params.column; + + break; + } + + case LVN_ITEMCHANGED: + { + NMLISTVIEW *data = (NMLISTVIEW *) lParam; + if (data->uNewState & LVIS_SELECTED) //new item + { + LoadPluginInfo(hWnd, GetSelectedPlugin(hWnd)); + + EnableWindow(GetDlgItem(hWnd, IDC_SAVE), 0); + EnableWindow(GetDlgItem(hWnd, IDC_CANCEL), 1); + EnableWindow(GetDlgItem(hWnd, IDC_GROUP), 1); + EnableWindow(GetDlgItem(hWnd, IDC_TITLE), 1); + } + else{ //selected item + if (data->uOldState & LVIS_SELECTED) + { + const int MAX_SIZE = 256; + PPluginOptions plugin = (PPluginOptions) data->lParam; + if (plugin) + { + WCHAR group[MAX_SIZE]; + WCHAR title[MAX_SIZE]; + WCHAR newGroup[MAX_SIZE]; + WCHAR newTitle[MAX_SIZE]; + + GetPluginGroup(plugin, group, MAX_SIZE); + GetPluginTitle(plugin, title, MAX_SIZE); + GetWindowTextW(GetDlgItem(hWnd, IDC_GROUP), newGroup, MAX_SIZE); + GetWindowTextW(GetDlgItem(hWnd, IDC_TITLE), newTitle, MAX_SIZE); + + if ((wcscmp(group, newGroup)) || (wcscmp(title, newTitle))) + { + if (MessageBox(hWnd, Translate("Do you want to save the changes now ?"), Translate("Changes not saved"), MB_YESNO | MB_ICONINFORMATION) == IDYES) + { + SavePluginGroup(plugin, newGroup); + SavePluginTitle(plugin, newTitle); + + UpdatePlugin(GetDlgItem(hWnd, IDC_LIST_PLUGINS), data->iItem, plugin, 1); + } + } + } + } + } + + break; + } + } + + break; + } + } + + break; + } + } + + return 0; +} \ No newline at end of file diff --git a/plugins/Bonsai/dlg_handlers.h b/plugins/Bonsai/dlg_handlers.h new file mode 100644 index 0000000000..f51e7bb0d2 --- /dev/null +++ b/plugins/Bonsai/dlg_handlers.h @@ -0,0 +1,50 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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_BONSAI_DLGHANDLERS_H +#define M_BONSAI_DLGHANDLERS_H + +#include "commonheaders.h" + +#define ListView_GetItemTextW(hwndLV, i, iSubItem_, pszText_, cchTextMax_) \ +{ LVITEMW _ms_lvi;\ + _ms_lvi.iSubItem = iSubItem_;\ + _ms_lvi.cchTextMax = cchTextMax_;\ + _ms_lvi.pszText = pszText_;\ + SNDMSG((hwndLV), LVM_GETITEMTEXTW, (WPARAM)(i), (LPARAM)(LVITEMW *)&_ms_lvi);\ +} + +#define ListView_SetItemTextW(hwndLV, i, iSubItem_, pszText_) \ +{ LVITEMW _ms_lvi;\ + _ms_lvi.iSubItem = iSubItem_;\ + _ms_lvi.pszText = pszText_;\ + SNDMSG((hwndLV), LVM_SETITEMTEXTW, (WPARAM)(i), (LPARAM)(LVITEMW *)&_ms_lvi);\ +} + +#define ListView_InsertItemW(hwnd, pitem) \ + (int)SNDMSG((hwnd), LVM_INSERTITEMW, 0, (LPARAM)(const LVITEMW *)(pitem)) + +#define FOM_UPDATEPLUGINS (WM_USER + 10) + +extern HWND hOptDlg; + +INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + +#endif \ No newline at end of file diff --git a/plugins/Bonsai/files_release.txt b/plugins/Bonsai/files_release.txt deleted file mode 100644 index 61e3b21c9d..0000000000 --- a/plugins/Bonsai/files_release.txt +++ /dev/null @@ -1 +0,0 @@ -FixOptions\win32\Release\*.dll diff --git a/plugins/Bonsai/files_releasex64.txt b/plugins/Bonsai/files_releasex64.txt deleted file mode 100644 index bb3349e661..0000000000 --- a/plugins/Bonsai/files_releasex64.txt +++ /dev/null @@ -1 +0,0 @@ -FixOptions\x64\Release\*.dll diff --git a/plugins/Bonsai/files_source.txt b/plugins/Bonsai/files_source.txt deleted file mode 100644 index 6135031985..0000000000 --- a/plugins/Bonsai/files_source.txt +++ /dev/null @@ -1,3 +0,0 @@ -FixOptions\*.* -docs\*.* -*.* diff --git a/plugins/Bonsai/hooked_events.cpp b/plugins/Bonsai/hooked_events.cpp new file mode 100644 index 0000000000..ba1ee85d91 --- /dev/null +++ b/plugins/Bonsai/hooked_events.cpp @@ -0,0 +1,92 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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 "hooked_events.h" + +HANDLE hModulesLoaded; +HANDLE hOptionsInitialize; + +UINT_PTR hRefreshTimer = NULL; + +#define HOST "http://eblis.tla.ro/projects" + +#if defined(WIN64) || defined(_WIN64) + #define FIXOPTIONS_VERSION_URL HOST "/miranda/Bonsai/updater/x64/Bonsai.html" + #define FIXOPTIONS_UPDATE_URL HOST "/miranda/Bonsai/updater/x64/Bonsai.zip" +#else + #define FIXOPTIONS_VERSION_URL HOST "/miranda/Bonsai/updater/Bonsai.html" + #define FIXOPTIONS_UPDATE_URL HOST "/miranda/Bonsai/updater/Bonsai.zip" +#endif +#define FIXOPTIONS_VERSION_PREFIX "Bonsai version " + + +int HookEvents() +{ + hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise); + + //UpdateTimer(); + + return 0; +} + +int UnhookEvents() +{ + UnhookEvent(hModulesLoaded); + UnhookEvent(hOptionsInitialize); + + return 0; +} + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + char buffer[1024]; + Update update = {0}; + update.cbSize = sizeof(Update); + update.szComponentName = __PLUGIN_DISPLAY_NAME; + update.pbVersion = (BYTE *) CreateVersionString(VERSION, buffer); + update.cpbVersion = (int) strlen((char *) update.pbVersion); + update.szUpdateURL = UPDATER_AUTOREGISTER; + update.szBetaVersionURL = FIXOPTIONS_VERSION_URL; + update.szBetaUpdateURL = FIXOPTIONS_UPDATE_URL; + update.pbBetaVersionPrefix = (BYTE *) FIXOPTIONS_VERSION_PREFIX; + update.cpbBetaVersionPrefix = (int) strlen(FIXOPTIONS_VERSION_PREFIX); + CallService(MS_UPDATE_REGISTER, 0, (LPARAM) &update); + + return 0; +} + +int OnOptionsInitialise(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = {0}; + + odp.cbSize = sizeof(odp); + odp.position = 100000000; + odp.hInstance = hInstance; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FIXOPTIONS); + odp.ptszTitle = TranslateT("Arrange Options"); + odp.ptszGroup = TranslateT("Services"); + odp.groupPosition = 810000000; + odp.flags=ODPF_BOLDGROUPS; + odp.pfnDlgProc = DlgProcOptions; + CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp); + + return 0; +} \ No newline at end of file diff --git a/plugins/Bonsai/hooked_events.h b/plugins/Bonsai/hooked_events.h new file mode 100644 index 0000000000..70c1a0d0c6 --- /dev/null +++ b/plugins/Bonsai/hooked_events.h @@ -0,0 +1,39 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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_BONSAI_HOOKED_EVENTS_H +#define M_BONSAI_HOOKED_EVENTS_H + +#include "commonheaders.h" +#include "dlg_handlers.h" + +extern HANDLE hModulesLoaded; +extern HANDLE hOptionsInitialize; + +extern UINT_PTR hRefreshTimer; + +int HookEvents(); +int UnhookEvents(); + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam); +int OnOptionsInitialise(WPARAM wParam, LPARAM lParam); + +#endif \ No newline at end of file diff --git a/plugins/Bonsai/icons/hidden.bmp b/plugins/Bonsai/icons/hidden.bmp new file mode 100644 index 0000000000..6ec1e60428 Binary files /dev/null and b/plugins/Bonsai/icons/hidden.bmp differ diff --git a/plugins/Bonsai/icons/modified.bmp b/plugins/Bonsai/icons/modified.bmp new file mode 100644 index 0000000000..1d9e13262a Binary files /dev/null and b/plugins/Bonsai/icons/modified.bmp differ diff --git a/plugins/Bonsai/icons/newlymodified.bmp b/plugins/Bonsai/icons/newlymodified.bmp new file mode 100644 index 0000000000..87f7cc48f4 Binary files /dev/null and b/plugins/Bonsai/icons/newlymodified.bmp differ diff --git a/plugins/Bonsai/icons/unmodified.bmp b/plugins/Bonsai/icons/unmodified.bmp new file mode 100644 index 0000000000..c9d552c032 Binary files /dev/null and b/plugins/Bonsai/icons/unmodified.bmp differ diff --git a/plugins/Bonsai/list.cpp b/plugins/Bonsai/list.cpp new file mode 100644 index 0000000000..a7ce5c1033 --- /dev/null +++ b/plugins/Bonsai/list.cpp @@ -0,0 +1,228 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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 "list.h" + +COptionsList &lstPluginOptions = COptionsList(); + +COptionsList::COptionsList(int initialCapacity) +{ + _plugins = NULL; + _count = 0; + _capacity = 0; + + Enlarge(initialCapacity); +} + +COptionsList::~COptionsList() +{ + Clear(); + free(_plugins); +} + +void COptionsList::Clear() +{ + int i; + for (i = 0; i < Count(); i++) + { + delete _plugins[i]; + } + _count = 0; +} + +int COptionsList::Count() const +{ + return _count; +} + +int COptionsList::Capacity() const +{ + return _capacity; +} + +void COptionsList::EnsureCapacity() +{ + if (_count >= _capacity) + { + Enlarge(_capacity / 2); + } +} + +void COptionsList::Enlarge(int increaseAmount) +{ + int newSize = _capacity + increaseAmount; + _plugins = (PPluginOptions *) realloc(_plugins, newSize * sizeof(PPluginOptions)); + _capacity = newSize; +} + +int COptionsList::Contains(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) const +{ + int pos = Index(plugin, group, title); + return (pos >= 0); +} + +int COptionsList::Index(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) const +{ + int i; + DWORD hPlugin = LangPackHashW(plugin); + DWORD hGroup = LangPackHashW(group); + DWORD hTitle = LangPackHashW(title); + PPluginOptions p; + + for (i = 0; i < Count(); i++) + { + p = _plugins[i]; + if ((hPlugin == p->pluginHash) && (hGroup == p->groupHash) && (hTitle == p->titleHash)) + { + return i; + } + } + + return -1; +} + +int COptionsList::Add(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) +{ + int pos = Index(plugin, group, title); + if (pos < 0) + { + EnsureCapacity(); + + PPluginOptions s = new TPluginOptions(plugin, group, title, LangPackHashW(plugin), LangPackHashW(group), LangPackHashW(title)); + _plugins[_count++] = s; + if (hOptDlg) + { + SendMessage(hOptDlg, FOM_UPDATEPLUGINS, 0, 0); + } + pos = _count - 1; + } + + return pos; +} + +int COptionsList::Remove(int index) +{ + if ((index < 0) && (index >= Count())) + { + return 1; + } + + int i; + PPluginOptions tmp = _plugins[index]; + for (i = index; i < _count - 1; i++) + { + _plugins[i] = _plugins[i + 1]; + } + _count--; + delete tmp; + + return 0; +} + +const PPluginOptions COptionsList::operator [](int index) +{ + if ((index < 0) || (index >= Count())) + { + return NULL; + } + + return _plugins[index]; +} + +char *BuildPluginUniqueID(PPluginOptions plugin, char *out, int size, int type) +{ + mir_snprintf(out, size, "%lu-%lu-%lu-%s", plugin->pluginHash, plugin->groupHash, plugin->titleHash, (type == ID_GROUP) ? "G" : "T"); + + return out; +} + +WCHAR *GetPluginGroup(PPluginOptions plugin, WCHAR *group, int count) +{ + char name[256]; + WCHAR *res = plugin->szGroup; + + BuildPluginUniqueID(plugin, name, 256, ID_GROUP); + + GetStringFromDatabase(name, plugin->szGroup, group, count); + res = (wcslen(group) == 0) ? NULL : group; + + return res; +} + +WCHAR *GetPluginTitle(PPluginOptions plugin, WCHAR *title, int count) +{ + char name[256]; + WCHAR *res = plugin->szTitle; + + BuildPluginUniqueID(plugin, name, 256, ID_TITLE); + + GetStringFromDatabase(name, plugin->szTitle, title, count); + res = (wcslen(title) == 0) ? NULL : title; + + return res; +} + +void SavePluginGroup(PPluginOptions plugin, WCHAR *newGroup) +{ + char name[256]; + int del = 0; + + BuildPluginUniqueID(plugin, name, 256, ID_GROUP); + + if (plugin->szGroup) + { + del = (wcscmp(plugin->szGroup, newGroup) == 0) ? 1 : 0; + } + else{ + del = ((!newGroup) || (wcslen(newGroup) == 0)) ? 1 : 0; + } + + if (del) + { + DBDeleteContactSetting(NULL, ModuleName, name); + } + else{ + DBWriteContactSettingWString(NULL, ModuleName, name, newGroup); + } +} + +void SavePluginTitle(PPluginOptions plugin, WCHAR *newTitle) +{ + char name[256]; + int del = 0; + + BuildPluginUniqueID(plugin, name, sizeof(name), ID_TITLE); + + if (plugin->szTitle) + { + del = (wcscmp(plugin->szTitle, newTitle) == 0) ? 1 : 0; + } + else{ + del = ((!newTitle) || (wcslen(newTitle)) == 0) ? 1 : 0; + } + + if (del) + { + DBDeleteContactSetting(NULL, ModuleName, name); + } + else{ + DBWriteContactSettingWString(NULL, ModuleName, name, newTitle); + } +} \ No newline at end of file diff --git a/plugins/Bonsai/list.h b/plugins/Bonsai/list.h new file mode 100644 index 0000000000..7143cb0f55 --- /dev/null +++ b/plugins/Bonsai/list.h @@ -0,0 +1,94 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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_BONSAI_LIST_H +#define M_BONSAI_LIST_H + +#define INITIAL_SIZE 20 + +#include "commonheaders.h" + +#define ID_GROUP 1 +#define ID_TITLE 2 + +struct TPluginOptions{ + WCHAR *szPlugin; + WCHAR *szGroup; + WCHAR *szTitle; + + DWORD pluginHash; + DWORD groupHash; + DWORD titleHash; + + TPluginOptions(const WCHAR *plugin, const WCHAR *group, const WCHAR *title, DWORD pluginHash, DWORD groupHash, DWORD titleHash) + { + szPlugin = _wcsdup(plugin); + szGroup = _wcsdup(group); + szTitle = _wcsdup(title); + this->pluginHash = pluginHash; + this->groupHash = groupHash; + this->titleHash = titleHash; + } + + ~TPluginOptions() + { + free(this->szPlugin); + free(this->szGroup); + free(this->szTitle); + } +}; + +typedef TPluginOptions *PPluginOptions; + +class COptionsList{ + protected: + PPluginOptions *_plugins; + int _count; + int _capacity; + + void Enlarge(int increaseAmount); + void EnsureCapacity(); + + public: + COptionsList(int initialSize = INITIAL_SIZE); + ~COptionsList(); + + void Clear(); + + int Add(const WCHAR *plugin, const WCHAR *group, const WCHAR *title); + int Remove(int index); + int Contains(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) const; + int Index(const WCHAR *plugin, const WCHAR *group, const WCHAR *title) const; + + const PPluginOptions operator [](int index); + + int Count() const; + int Capacity() const; +}; + +extern COptionsList &lstPluginOptions; //list of services + +WCHAR *BuildPluginUniqueID(PPluginOptions plugin, WCHAR *out, int size, int type); +WCHAR *GetPluginGroup(PPluginOptions plugin, WCHAR *group, int count); +WCHAR *GetPluginTitle(PPluginOptions plugin, WCHAR *title, int count); +void SavePluginGroup(PPluginOptions plugin, WCHAR *newGroup); +void SavePluginTitle(PPluginOptions plugin, WCHAR *newTitle); + +#endif //M_SERVICESLIST_LIST_H \ No newline at end of file diff --git a/plugins/Bonsai/pack source.bat b/plugins/Bonsai/pack source.bat deleted file mode 100644 index 847ba36a5e..0000000000 --- a/plugins/Bonsai/pack source.bat +++ /dev/null @@ -1,8 +0,0 @@ -for /F "tokens=4-8* delims=. " %%i in (docs\Bonsai_readme.txt) do (call :Pack %%i %%j %%k %%l; exit) - -:Pack -d:\usr\PowerArchiver\pacl\pacomp.exe -p -a -c2 "Bonsai src %1.%2.%3.%4.zip" @files_source.txt -x*.zip -x*.ncb -x*.user -exit - -error: -echo "Error packing Bonsai" diff --git a/plugins/Bonsai/pack symbols.bat b/plugins/Bonsai/pack symbols.bat deleted file mode 100644 index 3fd0bdb610..0000000000 --- a/plugins/Bonsai/pack symbols.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -if NOT EXIST "symbols\%1 - %3" ( - mkdir "symbols\%1 - %3" -) -xcopy "%2\win32\Release\*.pdb" "symbols\%1 - %3\win32\*" /EXCLUDE:symbols_exclude.txt /Y -xcopy "%2\x64\Release\*.pdb" "symbols\%1 - %3\x64\*" /EXCLUDE:symbols_exclude.txt /Y - -d:\usr\PowerArchiver\pacl\pacomp.exe -p -a -r -c2 "symbols - %1.zip" "symbols\*.*" -rmdir "symbols\" /Q /S \ No newline at end of file diff --git a/plugins/Bonsai/pack x64.bat b/plugins/Bonsai/pack x64.bat deleted file mode 100644 index caabd8aae7..0000000000 --- a/plugins/Bonsai/pack x64.bat +++ /dev/null @@ -1,10 +0,0 @@ -for /F "tokens=4-8* delims=. " %%i in (docs\Bonsai_readme.txt) do (call :Pack %%i %%j %%k %%l; exit) - -:Pack -d:\usr\PowerArchiver\pacl\pacomp.exe -a -c2 "Bonsai %1.%2.%3.%4 x64.zip" @files_releasex64.txt -d:\usr\PowerArchiver\pacl\pacomp.exe -p -a -c2 "Bonsai %1.%2.%3.%4 x64.zip" docs\*.* *.caca -call "pack symbols.bat" Bonsai FixOptions %1.%2.%3.%4 -exit - -error: -echo "Error packing Bonsai" diff --git a/plugins/Bonsai/pack.bat b/plugins/Bonsai/pack.bat deleted file mode 100644 index 011d680281..0000000000 --- a/plugins/Bonsai/pack.bat +++ /dev/null @@ -1,10 +0,0 @@ -for /F "tokens=4-8* delims=. " %%i in (docs\Bonsai_readme.txt) do (call :Pack %%i %%j %%k %%l; exit) - -:Pack -d:\usr\PowerArchiver\pacl\pacomp.exe -a -c2 "Bonsai %1.%2.%3.%4 x32.zip" @files_release.txt -d:\usr\PowerArchiver\pacl\pacomp.exe -p -a -c2 "Bonsai %1.%2.%3.%4 x32.zip" docs\*.* *.caca -call "pack symbols.bat" Bonsai FixOptions %1.%2.%3.%4 -exit - -error: -echo "Error packing Bonsai" diff --git a/plugins/Bonsai/resource.h b/plugins/Bonsai/resource.h new file mode 100644 index 0000000000..fa0aefbfec --- /dev/null +++ b/plugins/Bonsai/resource.h @@ -0,0 +1,28 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Bonsai.rc +// +#define IDD_FIXOPTIONS 101 +#define IDD_OPT_FIXOPTIONS 101 +#define IDB_MODIFIED 104 +#define IDB_UNMODIFIED 105 +#define IDB_NEWLYMODIFIED 106 +#define IDB_BITMAP1 107 +#define IDB_HIDDEN 107 +#define IDC_LIST_PLUGINS 1003 +#define IDC_GROUP 1004 +#define IDC_TITLE 1006 +#define IDC_SAVE 1007 +#define IDC_CANCEL 1008 +#define IDC_BUTTON1 1009 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 108 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1010 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/Bonsai/screenshot.png b/plugins/Bonsai/screenshot.png deleted file mode 100644 index 8436480191..0000000000 Binary files a/plugins/Bonsai/screenshot.png and /dev/null differ diff --git a/plugins/Bonsai/services.cpp b/plugins/Bonsai/services.cpp new file mode 100644 index 0000000000..64d7f92c72 --- /dev/null +++ b/plugins/Bonsai/services.cpp @@ -0,0 +1,192 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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 "services.h" + +static CRITICAL_SECTION csServices; + +static DWORD OPTIONS_ADDPAGE_HASH = NameHashFunction(MS_OPT_ADDPAGE); + +CALLSERVICEFUNCTION realCallServiceFunction = NULL; + +int InitServices() +{ + InitializeCriticalSection(&csServices); + + HookRealServices(); + + return 0; +} + +int DestroyServices() +{ + UnhookRealServices(); + + DeleteCriticalSection(&csServices); + + return 0; +} + +void HookRealServices() +{ + Log("Hooking real CallService(). Replacing 0x%p with 0x%p", pluginLink->CallService, BonsaiCallServiceFunction); + realCallServiceFunction = pluginLink->CallService; + pluginLink->CallService = BonsaiCallServiceFunction; +} + +void UnhookRealServices() +{ + Log("Unhooking real CallService(). Replacing 0x%p with 0x%p", pluginLink->CallService, realCallServiceFunction); + EnterCriticalSection(&csServices); + + pluginLink->CallService = realCallServiceFunction; + + LeaveCriticalSection(&csServices); +} + +INT_PTR BonsaiCallServiceFunction(const char *name, WPARAM wParam, LPARAM lParam) +{ + int res; + int run = 1; + int fix = 0; + const int MAX_SIZE = 256; + WCHAR group[MAX_SIZE]; + WCHAR title[MAX_SIZE]; + WCHAR tabTitle[MAX_SIZE]; + + BYTE temp[200] = {0}; + OPTIONSDIALOGPAGE *options = (OPTIONSDIALOGPAGE *) lParam; + + if (NameHashFunction(name) == OPTIONS_ADDPAGE_HASH) + { + memmove(temp, options, options->cbSize); + options = (OPTIONSDIALOGPAGE *) temp; + //EnterCriticalSection(&csServices); + if ((options->cbSize > 60) && !(options->flags & ODPF_UNICODE) && (options->pszTab) && (!bUseANSIStrings)) + { + MultiByteToWideChar(CP_ACP, 0, options->pszTab, -1, tabTitle, MAX_SIZE); + options->pszTab = (char *) tabTitle; + } + + FixPluginOptions(name, options, group, MAX_SIZE, title, MAX_SIZE); + if (!options->pszTitle) + { + run = 0; + } + } + res = (run) ? realCallServiceFunction(name, wParam, (LPARAM) options) : CALLSERVICE_NOTFOUND; + + return res; +} + +int FixPluginOptions(const char *serviceName, void *options, WCHAR *group, int cGroup, WCHAR *title, int cTitle) +{ + MEMORY_BASIC_INFORMATION mbi; + HINSTANCE hInstance; + const int MODULE_MAX_SIZE = 256; + char mod[MODULE_MAX_SIZE]; + WCHAR plugin[MODULE_MAX_SIZE]; + mod[0] = '\0'; + if(VirtualQuery(serviceName, &mbi, sizeof(mbi) )) + { + hInstance = (HINSTANCE)(mbi.AllocationBase); + char mod_path[MAX_PATH]; + GetModuleFileName(hInstance, mod_path, MAX_PATH); + // chop path + char *p = strrchr(mod_path, '.'); + if (p) + { + p[0] = '\0'; + } + + p = strrchr(mod_path, '\\'); + if(p) + { + p++; + strncpy(mod, p, sizeof(mod)); + } + } + + if (strlen(mod) > 0) + { + if (bUseANSIStrings) + { + _strlwr(mod); + } + MultiByteToWideChar(CP_ACP, 0, mod, -1, plugin, MODULE_MAX_SIZE); + const int MAX_SIZE = 256; + WCHAR temp1[MAX_SIZE]; + WCHAR temp2[MAX_SIZE]; + WCHAR *optGroup = temp1; + WCHAR *optTitle = temp2; + OPTIONSDIALOGPAGE *odp = (OPTIONSDIALOGPAGE *) options; + temp1[0] = temp2[0] = L'\0'; + + if ((odp->flags & ODPF_UNICODE) && (odp->cbSize > 40)) + { + + optGroup = (WCHAR *) odp->pszGroup; + optTitle = (WCHAR *) odp->pszTitle; + + Log("[UNICODE] %-15S - Initial options location %S->%S (unicode)", plugin, optGroup, optTitle); + } + else{ + Log(" %-15S - Initial options location %s->%s", plugin, odp->pszGroup, odp->pszTitle); + MultiByteToWideChar(CP_ACP, 0, odp->pszGroup, -1, temp1, MAX_SIZE); + MultiByteToWideChar(CP_ACP, 0, odp->pszTitle, -1, temp2, MAX_SIZE); + + if (odp->cbSize > 40) //some old plugins don't have flags variable in structure + { + odp->flags |= ODPF_UNICODE; + } + } + + int index = lstPluginOptions.Add(plugin, optGroup, optTitle); + odp->pszGroup = (char *) GetPluginGroup(lstPluginOptions[index], group, cGroup); + odp->pszTitle = (char *) GetPluginTitle(lstPluginOptions[index], title, cTitle); + Log("[UNICODE] %-15S - New options location %S->%S", plugin, odp->pszGroup, odp->pszTitle); + + if ((bUseANSIStrings) || (odp->cbSize <= 40)) //if plugins doesn't have flags variable in structure then they only support ansi strings + { + Log(" Plugin is either very old or we're running on Windows 98, converting back to ansi strings ..."); + WCHAR temp[MAX_SIZE]; + + if (odp->pszGroup) + { + wcsncpy(temp, (WCHAR *) odp->pszGroup, MAX_SIZE); + WideCharToMultiByte(CP_ACP, 0, temp, -1, odp->pszGroup, cGroup, NULL, NULL); + } + + if (odp->pszTitle) + { + wcsncpy(temp, (WCHAR *) odp->pszTitle, MAX_SIZE); + WideCharToMultiByte(CP_ACP, 0, temp, -1, odp->pszTitle, cTitle, NULL, NULL); + } + + if (odp->cbSize > 40) + { + Log(" Windows98 - Resetting ODPF_UNICODE flag"); + odp->flags &= ~ODPF_UNICODE; + } + } + } + + return 0; +} \ No newline at end of file diff --git a/plugins/Bonsai/services.h b/plugins/Bonsai/services.h new file mode 100644 index 0000000000..a78ba2b75c --- /dev/null +++ b/plugins/Bonsai/services.h @@ -0,0 +1,40 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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_BONSAI_SERVICES_H +#define M_BONSAI_SERVICES_H + +#include "commonheaders.h" + +typedef INT_PTR (*CALLSERVICEFUNCTION) (const char *, WPARAM wParam, LPARAM lParam); + +extern CALLSERVICEFUNCTION realCallServiceFunction; + +int InitServices(); +int DestroyServices(); + +void HookRealServices(); +void UnhookRealServices(); + +INT_PTR BonsaiCallServiceFunction(const char *name, WPARAM wParam, LPARAM lParam); + +int FixPluginOptions(const char *serviceName, void *options, WCHAR *group, int cGroup, WCHAR *title, int cTitle); + +#endif //M_SERVICESLIST_SERVICES_H diff --git a/plugins/Bonsai/symbols_exclude.txt b/plugins/Bonsai/symbols_exclude.txt deleted file mode 100644 index 361cf2448b..0000000000 --- a/plugins/Bonsai/symbols_exclude.txt +++ /dev/null @@ -1 +0,0 @@ -vc80.pdb \ No newline at end of file diff --git a/plugins/Bonsai/utils.cpp b/plugins/Bonsai/utils.cpp new file mode 100644 index 0000000000..3f30dc44ad --- /dev/null +++ b/plugins/Bonsai/utils.cpp @@ -0,0 +1,527 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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 "utils.h" + +int LogInit() +{ +#ifdef USE_LOG + //FILE *fout = fopen(LOG_FILE, "wt"); + //fclose(fout); + Log("********************** Miranda started **********************"); +#endif + return 0; +} + +int Log(char *format, ...) +{ +#ifdef USE_LOG + char str[4096]; + va_list vararg; + int tBytes; + FILE *fout = fopen(LOG_FILE, "at"); + if (!fout) + { +// MessageBox(0, "can't open file", NULL, MB_OK); + return -1; + } + time_t tNow = time(NULL); + struct tm *now = localtime(&tNow); + strftime(str, sizeof(str), "%d %b %Y @ %H:%M:%S: ", now); + fputs(str, fout); + va_start(vararg, format); + + tBytes = _vsnprintf(str, sizeof(str), format, vararg); + if (tBytes > 0) + { + str[tBytes] = 0; + } + + va_end(vararg); + if (str[strlen(str) - 1] != '\n') + { + strcat(str, "\n"); + } + fputs(str, fout); + fclose(fout); +#endif + return 0; +} + +int Info(char *title, char *format, ...) +{ + char str[4096]; + va_list vararg; + int tBytes; + va_start(vararg, format); + tBytes = _vsnprintf(str, sizeof(str), format, vararg); + if (tBytes > 0) + { + str[tBytes] = 0; + } + va_end(vararg); + return MessageBoxA(0, str, title, MB_OK | MB_ICONINFORMATION); +} + +int MyPUShowMessage(char *lpzText, BYTE kind) +{ + if (ServiceExists(MS_POPUP_SHOWMESSAGE)) + { + return PUShowMessage(lpzText, kind); + } + else{ + char *title = (kind == SM_NOTIFY) ? Translate("Notify") : Translate("Warning"); + + return MessageBox(NULL, lpzText, title, MB_OK | (kind == SM_NOTIFY) ? MB_ICONINFORMATION : MB_ICONEXCLAMATION); + } +} + +#define HEX_SIZE 8 + +char *BinToHex(int size, PBYTE data) +{ + char *szresult = NULL; + char buffer[32] = {0}; //should be more than enough + int maxSize = size * 2 + HEX_SIZE + 1; + szresult = (char *) new char[ maxSize ]; + memset(szresult, 0, maxSize); + sprintf(buffer, "%0*X", HEX_SIZE, size); + strcpy(szresult, buffer); + int i; + for (i = 0; i < size; i++) + { + sprintf(buffer, "%02X", data[i]); + strcpy(szresult + (HEX_SIZE + i * 2), buffer); + } + return szresult; +} + +void HexToBin(char *inData, ULONG &size, LPBYTE &outData) +{ + char buffer[32] = {0}; + strcpy(buffer, "0x"); + strncpy(buffer + 2, inData, HEX_SIZE); + sscanf(buffer, "%x", &size); + outData = (unsigned char*)new char[size*2]; + UINT i; + //size = i; + char *tmp = inData + HEX_SIZE; + buffer[4] = '\0'; //mark the end of the string + for (i = 0; i < size; i++) + { + strncpy(buffer + 2, &tmp[i * 2], 2); + sscanf(buffer, "%x", &outData[i]); + } + i = size; +} + +int GetStringFromDatabase(HANDLE hContact, char *szModule, char *szSettingName, char *szError, char *szResult, size_t size) +{ + DBVARIANT dbv = {0}; + int res = 1; + size_t len; + dbv.type = DBVT_ASCIIZ; + if (DBGetContactSetting(hContact, szModule, szSettingName, &dbv) == 0) + { + res = 0; + size_t tmp = strlen(dbv.pszVal); + len = (tmp < size - 1) ? tmp : size - 1; + strncpy(szResult, dbv.pszVal, len); + szResult[len] = '\0'; + mir_free(dbv.pszVal); + } + else{ + res = 1; + if (szError) + { + size_t tmp = strlen(szError); + len = (tmp < size - 1) ? tmp : size - 1; + strncpy(szResult, szError, len); + szResult[len] = '\0'; + } + else{ + szResult[0] = '\0'; + } + } + return res; +} + +int GetStringFromDatabase(HANDLE hContact, char *szModule, char *szSettingName, WCHAR *szError, WCHAR *szResult, size_t count) +{ + DBVARIANT dbv = {0}; + int res = 1; + size_t len; + dbv.type = DBVT_WCHAR; + if (DBGetContactSettingWString(hContact, szModule, szSettingName, &dbv) == 0) + { + res = 0; + if (dbv.type != DBVT_WCHAR) + { + MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, szResult, (int) count); + } + else{ + size_t tmp = wcslen(dbv.pwszVal); + len = (tmp < count - 1) ? tmp : count - 1; + wcsncpy(szResult, dbv.pwszVal, len); + szResult[len] = L'\0'; + } + mir_free(dbv.pwszVal); + } + else{ + res = 1; + if (szError) + { + size_t tmp = wcslen(szError); + len = (tmp < count - 1) ? tmp : count - 1; + wcsncpy(szResult, szError, len); + szResult[len] = L'\0'; + } + else{ + szResult[0] = L'\0'; + } + } + return res; +} + +int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, size_t size) +{ + return GetStringFromDatabase(NULL, ModuleName, szSettingName, szError, szResult, size); +} + +int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult, size_t count) +{ + return GetStringFromDatabase(NULL, ModuleName, szSettingName, szError, szResult, count); +} + +#pragma warning (disable: 4312) +TCHAR *GetContactName(HANDLE hContact, char *szProto) +{ + CONTACTINFO ctInfo; + int ret; + char proto[200]; + + ZeroMemory((void *) &ctInfo, sizeof(ctInfo)); + ctInfo.cbSize = sizeof(ctInfo); + if (szProto) + { + ctInfo.szProto = szProto; + } + else{ + GetContactProtocol(hContact, proto, sizeof(proto)); + ctInfo.szProto = proto; + } + ctInfo.dwFlag = CNF_DISPLAY; +#ifdef _UNICODE + ctInfo.dwFlag += CNF_UNICODE; +#endif + ctInfo.hContact = hContact; + //_debug_message("retrieving contact name for %d", hContact); + ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo); + //_debug_message(" contact name %s", ctInfo.pszVal); + TCHAR *buffer; + if (!ret) + { + buffer = _tcsdup(ctInfo.pszVal); + } + mir_free(ctInfo.pszVal); + if (!ret) + { + return buffer; + } + else{ + return NULL; + } + return buffer; +} +#pragma warning (default: 4312) + +#pragma warning (disable: 4312) +void GetContactProtocol(HANDLE hContact, char *szProto, size_t size) +{ + GetStringFromDatabase(hContact, "Protocol", "p", NULL, szProto, size); +} +#pragma warning (default: 4312) + +#pragma warning (disable: 4312) +TCHAR *GetContactID(HANDLE hContact) +{ + char protocol[256]; + GetContactProtocol(hContact, protocol, sizeof(protocol)); + + return GetContactID(hContact, protocol); +} + +TCHAR *GetContactID(HANDLE hContact, char *szProto) +{ + CONTACTINFO ctInfo; + int ret; + + ZeroMemory((void *) &ctInfo, sizeof(ctInfo)); + ctInfo.cbSize = sizeof(ctInfo); + ctInfo.szProto = szProto; + ctInfo.dwFlag = CNF_UNIQUEID; +#ifdef _UNICODE + ctInfo.dwFlag |= CNF_UNICODE; +#endif + ctInfo.hContact = hContact; + ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo); + TCHAR *buffer; + if (!ret) + { + TCHAR tmp[16]; + switch (ctInfo.type) + { + case CNFT_BYTE: + { + _stprintf(tmp, _T("%d"), ctInfo.bVal); + buffer = _tcsdup(tmp); + + break; + } + + case CNFT_WORD: + { + _stprintf(tmp, _T("%d"), ctInfo.wVal); + buffer = _tcsdup(tmp); + + break; + } + + case CNFT_DWORD: + { + _stprintf(tmp, _T("%ld"), ctInfo.dVal); + buffer = _tcsdup(tmp); + + break; + } + + case CNFT_ASCIIZ: + default: + { + buffer = _tcsdup(ctInfo.pszVal); + + break; + } + } + + + } + mir_free(ctInfo.pszVal); + if (!ret) + { + return buffer; + } + else{ + return NULL; + } +} +#pragma warning (default: 4312) + +#pragma warning (disable: 4312) +HANDLE GetContactFromID(TCHAR *szID, char *szProto) +{ + HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + TCHAR *szHandle; + char cProtocol[256]; + + int found = 0; + while (hContact) + { + GetContactProtocol(hContact, cProtocol, sizeof(cProtocol)); + szHandle = GetContactID(hContact, cProtocol); + if ((szHandle) && (_tcsicmp(szHandle, szID) == 0) && (_stricmp(szProto, cProtocol) == 0)) + { + found = 1; + } + if (szHandle) free(szHandle); + + if (found) + { + break; + } + hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); + } + return hContact; +} +#pragma warning (default: 4312) + +#pragma warning (disable: 4312) +HANDLE GetContactFromID(TCHAR *szID, wchar_t *szProto) +{ + char protocol[1024]; + WideCharToMultiByte(CP_ACP, 0, szProto, -1, protocol, sizeof(protocol), NULL, NULL); + return GetContactFromID(szID, protocol); +} +#pragma warning (default: 4312) + +void ScreenToClient(HWND hWnd, LPRECT rect) +{ + POINT pt; + int cx = rect->right - rect->left; + int cy = rect->bottom - rect->top; + pt.x = rect->left; + pt.y = rect->top; + ScreenToClient(hWnd, &pt); + rect->left = pt.x; + rect->top = pt.y; + rect->right = pt.x + cx; + rect->bottom = pt.y + cy; +} + +void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors) +{ + RECT rParent; + RECT rChild; + + if (parentPos->flags & SWP_NOSIZE) + { + return; + } + GetWindowRect(parentPos->hwnd, &rParent); + rChild = AnchorCalcPos(window, &rParent, parentPos, anchors); + MoveWindow(window, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, FALSE); +} + +RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors) +{ + RECT rChild; + RECT rTmp; + + GetWindowRect(window, &rChild); + ScreenToClient(parentPos->hwnd, &rChild); + + int cx = rParent->right - rParent->left; + int cy = rParent->bottom - rParent->top; + if ((cx == parentPos->cx) && (cy == parentPos->cy)) + { + return rChild; + } + if (parentPos->flags & SWP_NOSIZE) + { + return rChild; + } + + rTmp.left = parentPos->x - rParent->left; + rTmp.right = (parentPos->x + parentPos->cx) - rParent->right; + rTmp.bottom = (parentPos->y + parentPos->cy) - rParent->bottom; + rTmp.top = parentPos->y - rParent->top; + + cx = (rTmp.left) ? -rTmp.left : rTmp.right; + cy = (rTmp.top) ? -rTmp.top : rTmp.bottom; + + rChild.right += cx; + rChild.bottom += cy; + //expanded the window accordingly, now we need to enforce the anchors + if ((anchors & ANCHOR_LEFT) && (!(anchors & ANCHOR_RIGHT))) + { + rChild.right -= cx; + } + if ((anchors & ANCHOR_TOP) && (!(anchors & ANCHOR_BOTTOM))) + { + rChild.bottom -= cy; + } + if ((anchors & ANCHOR_RIGHT) && (!(anchors & ANCHOR_LEFT))) + { + rChild.left += cx; + } + if ((anchors & ANCHOR_BOTTOM) && (!(anchors & ANCHOR_TOP))) + { + rChild.top += cy; + } + return rChild; +} + +DWORD NameHashFunction(const char *szStr) +{ +#if defined _M_IX86 && !defined _NUMEGA_BC_FINALCHECK && !defined NOINLINEASM + __asm { //this breaks if szStr is empty + xor edx,edx + xor eax,eax + mov esi,szStr + cmp esi, 0x0 + je end + mov al,[esi] + xor cl,cl + lph_top: //only 4 of 9 instructions in here don't use AL, so optimal pipe use is impossible + xor edx,eax + inc esi + xor eax,eax + and cl,31 + mov al,[esi] + add cl,5 + test al,al + rol eax,cl //rol is u-pipe only, but pairable + //rol doesn't touch z-flag + jnz lph_top //5 clock tick loop. not bad. + + xor eax,edx + end: + } +#else + DWORD hash=0; + int i; + int shift=0; + for(i=0;szStr[i];i++) { + hash^=szStr[i]<24) hash^=(szStr[i]>>(32-shift))&0x7F; + shift=(shift+5)&0x1F; + } + return hash; +#endif +} + +DWORD LangPackHashW(const WCHAR *szStr) +{ +#if defined _M_IX86 && !defined _NUMEGA_BC_FINALCHECK && !defined __GNUC__ + __asm { //this is mediocrely optimised, but I'm sure it's good enough + xor edx,edx + xor eax, eax + mov esi,szStr + cmp esi, 0x0 + je end + xor cl,cl +lph_top: + xor eax,eax + and cl,31 + mov al,[esi] + inc esi + inc esi + test al,al + jz lph_end + rol eax,cl + add cl,5 + xor edx,eax + jmp lph_top +lph_end: + mov eax,edx +end: + } +#else + DWORD hash=0; + int i; + int shift=0; + for(i=0;szStr[i];i+=2) { + hash^=szStr[i]<24) hash^=(szStr[i]>>(32-shift))&0x7F; + shift=(shift+5)&0x1F; + } + return hash; +#endif +} \ No newline at end of file diff --git a/plugins/Bonsai/utils.h b/plugins/Bonsai/utils.h new file mode 100644 index 0000000000..db5533c21c --- /dev/null +++ b/plugins/Bonsai/utils.h @@ -0,0 +1,64 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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_BONSAI_UTILS_H +#define M_BONSAI_UTILS_H + +#include +#include "commonheaders.h" +#include "list.h" + +//#define USE_LOG +#define LOG_FILE "bonsai.log" + +#define ANCHOR_LEFT 0x000001 +#define ANCHOR_RIGHT 0x000002 +#define ANCHOR_TOP 0x000004 +#define ANCHOR_BOTTOM 0x000008 +#define ANCHOR_ALL ANCHOR_LEFT | ANCHOR_RIGHT | ANCHOR_TOP | ANCHOR_BOTTOM + +int LogInit(); +int Log(char *format, ...); +int Info(char *title, char *format, ...); + +char *BinToHex(int size, PBYTE data); +void HexToBin(char *inData, ULONG &size, PBYTE &outData); + +void ScreenToClient(HWND hWnd, LPRECT rect); +void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors); +RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors); + +int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, size_t size); +int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult, size_t count); + +TCHAR *GetContactName(HANDLE hContact, char *szProto); +TCHAR *GetContactID(HANDLE hContact); +TCHAR *GetContactID(HANDLE hContact, char *szProto); +HANDLE GetContactFromID(TCHAR *szID, char *szProto); +HANDLE GetContactFromID(TCHAR *szID, wchar_t *szProto); +void GetContactProtocol(HANDLE hContact, char *szProto, size_t size); + +DWORD NameHashFunction(const char *szStr); +DWORD LangPackHashW(const WCHAR *szStr); + +int MyPUShowMessage(char *lpzText, BYTE kind); + + +#endif \ No newline at end of file diff --git a/plugins/Bonsai/version.h b/plugins/Bonsai/version.h new file mode 100644 index 0000000000..5ae566b4eb --- /dev/null +++ b/plugins/Bonsai/version.h @@ -0,0 +1,49 @@ +/* +Bonsai plugin for Miranda IM + +Copyright © 2006 Cristian Libotean + +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_BONSAI_VERSION_H +#define M_BONSAI_VERSION_H + +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 2 +#define __BUILD_NUM 5 + +#define VERSION PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM) + +#define __PLUGINVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __PLUGINVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM +#define __STRINGIFY_(x) #x +#define __STRINGIFY(x) __STRINGIFY_(x) +#define __VERSION_STRING __STRINGIFY(__PLUGINVERSION_STRING_DOTS) + +#define __DESC "This plugin lets you rearrange the options tree by changing the options groups and titles that plugin options are displayed under." +#define __AUTHOR "Cristian Libotean" +#define __AUTHOREMAIL "eblis102@yahoo.com" +#define __COPYRIGHT "© 2006-2007 Cristian Libotean" +#define __AUTHORWEB "http://www.miranda-im.org/" + +#if defined(WIN64) || defined(_WIN64) +#define __PLUGIN_DISPLAY_NAME "Bonsai (x64)" +#else +#define __PLUGIN_DISPLAY_NAME "Bonsai" +#endif + +#endif //M_BONSAI_VERSION_H diff --git a/plugins/Bonsai/version.rc b/plugins/Bonsai/version.rc new file mode 100644 index 0000000000..0f8fea03fc --- /dev/null +++ b/plugins/Bonsai/version.rc @@ -0,0 +1,100 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" +#include "version.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource1.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __PLUGINVERSION_STRING + PRODUCTVERSION __PLUGINVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Author", __AUTHOR + VALUE "FileDescription", __DESC + VALUE "FileVersion", __VERSION_STRING + VALUE "InternalName", __PLUGIN_DISPLAY_NAME + VALUE "LegalCopyright", __COPYRIGHT + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + -- cgit v1.2.3