From 0cda0baab21d4d4bf40c9459f6f5a7e49aa92492 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 24 Jul 2012 12:45:18 +0000 Subject: VersionInfo, W7UI, WhoUsesMyFiles, YAPP, ZeroNotification: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1161 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/VersionInfo/AggressiveOptimize.h | 58 - plugins/VersionInfo/CPlugin.cpp | 147 --- plugins/VersionInfo/CPlugin.h | 73 -- plugins/VersionInfo/CVersionInfo.cpp | 1198 -------------------- plugins/VersionInfo/CVersionInfo.h | 115 -- plugins/VersionInfo/VersionInfo.html | 11 - plugins/VersionInfo/VersionInfo.ico | Bin 2550 -> 0 bytes plugins/VersionInfo/VersionInfo_10.vcxproj | 39 +- plugins/VersionInfo/VersionInfo_10.vcxproj.filters | 31 +- plugins/VersionInfo/common.h | 96 -- plugins/VersionInfo/dlgHandlers.cpp | 589 ---------- plugins/VersionInfo/dlgHandlers.h | 43 - plugins/VersionInfo/docs/VersionInfo.html | 11 + plugins/VersionInfo/docs/svc_vi-translation.txt | 56 + plugins/VersionInfo/hooked_events.cpp | 80 -- plugins/VersionInfo/hooked_events.h | 33 - plugins/VersionInfo/main.cpp | 119 -- plugins/VersionInfo/res/VersionInfo.ico | Bin 0 -> 2550 bytes plugins/VersionInfo/res/resource.rc | 225 ++++ plugins/VersionInfo/res/version.rc | 46 + plugins/VersionInfo/resource.h | 71 -- plugins/VersionInfo/resource.rc | 225 ---- plugins/VersionInfo/services.cpp | 76 -- plugins/VersionInfo/services.h | 31 - plugins/VersionInfo/src/CPlugin.cpp | 147 +++ plugins/VersionInfo/src/CPlugin.h | 73 ++ plugins/VersionInfo/src/CVersionInfo.cpp | 1198 ++++++++++++++++++++ plugins/VersionInfo/src/CVersionInfo.h | 115 ++ plugins/VersionInfo/src/common.h | 96 ++ plugins/VersionInfo/src/dlgHandlers.cpp | 589 ++++++++++ plugins/VersionInfo/src/dlgHandlers.h | 43 + plugins/VersionInfo/src/hooked_events.cpp | 80 ++ plugins/VersionInfo/src/hooked_events.h | 33 + plugins/VersionInfo/src/main.cpp | 119 ++ plugins/VersionInfo/src/resource.h | 71 ++ plugins/VersionInfo/src/services.cpp | 76 ++ plugins/VersionInfo/src/services.h | 31 + plugins/VersionInfo/src/utils.cpp | 526 +++++++++ plugins/VersionInfo/src/utils.h | 49 + plugins/VersionInfo/src/version.h | 44 + plugins/VersionInfo/svc_vi-translation.txt | 56 - plugins/VersionInfo/utils.cpp | 526 --------- plugins/VersionInfo/utils.h | 49 - plugins/VersionInfo/version.h | 44 - plugins/VersionInfo/version.rc | 104 -- plugins/W7UI/clistproxywindow.cpp | 292 ----- plugins/W7UI/clistproxywindow.h | 64 -- plugins/W7UI/docs/w7ui-translation.txt | 16 + plugins/W7UI/dwmwindow.cpp | 209 ---- plugins/W7UI/dwmwindow.h | 59 - plugins/W7UI/headers.h | 78 -- plugins/W7UI/jumplist.cpp | 123 -- plugins/W7UI/jumplist.h | 7 - plugins/W7UI/jumplistarray.cpp | 214 ---- plugins/W7UI/jumplistarray.h | 29 - plugins/W7UI/jumplistbuilder.cpp | 127 --- plugins/W7UI/jumplistbuilder.h | 47 - plugins/W7UI/main.cpp | 79 -- plugins/W7UI/src/clistproxywindow.cpp | 292 +++++ plugins/W7UI/src/clistproxywindow.h | 64 ++ plugins/W7UI/src/dwmwindow.cpp | 209 ++++ plugins/W7UI/src/dwmwindow.h | 59 + plugins/W7UI/src/headers.h | 78 ++ plugins/W7UI/src/jumplist.cpp | 123 ++ plugins/W7UI/src/jumplist.h | 7 + plugins/W7UI/src/jumplistarray.cpp | 214 ++++ plugins/W7UI/src/jumplistarray.h | 29 + plugins/W7UI/src/jumplistbuilder.cpp | 127 +++ plugins/W7UI/src/jumplistbuilder.h | 47 + plugins/W7UI/src/main.cpp | 79 ++ plugins/W7UI/src/srmmproxywindow.cpp | 374 ++++++ plugins/W7UI/src/srmmproxywindow.h | 42 + plugins/W7UI/src/subclassmgr.cpp | 0 plugins/W7UI/src/subclassmgr.h | 71 ++ plugins/W7UI/src/w7ui.cpp | 180 +++ plugins/W7UI/src/win7api.cpp | 25 + plugins/W7UI/src/win7api.h | 38 + plugins/W7UI/src/win7api_ICustomDestinationList.h | 34 + plugins/W7UI/src/win7api_IObjectArray.h | 15 + plugins/W7UI/src/win7api_IObjectCollection.h | 16 + plugins/W7UI/src/win7api_ITaskbarList3.h | 65 ++ plugins/W7UI/srmmproxywindow.cpp | 374 ------ plugins/W7UI/srmmproxywindow.h | 42 - plugins/W7UI/subclassmgr.cpp | 0 plugins/W7UI/subclassmgr.h | 71 -- plugins/W7UI/w7ui-translation.txt | 16 - plugins/W7UI/w7ui.cpp | 180 --- plugins/W7UI/w7ui_10.vcxproj | 54 +- plugins/W7UI/win7api.cpp | 25 - plugins/W7UI/win7api.h | 38 - plugins/W7UI/win7api_ICustomDestinationList.h | 34 - plugins/W7UI/win7api_IObjectArray.h | 15 - plugins/W7UI/win7api_IObjectCollection.h | 16 - plugins/W7UI/win7api_ITaskbarList3.h | 65 -- plugins/WhoUsesMyFiles/docs/wumf.readme.txt | 39 + plugins/WhoUsesMyFiles/list.c | 172 --- plugins/WhoUsesMyFiles/res/drive.bmp | Bin 222 -> 0 bytes plugins/WhoUsesMyFiles/res/resource.rc | 203 ++++ plugins/WhoUsesMyFiles/res/wumf.readme.txt | 39 - plugins/WhoUsesMyFiles/resizer.c | 131 --- plugins/WhoUsesMyFiles/resource.h | 47 - plugins/WhoUsesMyFiles/resource.rc | 209 ---- plugins/WhoUsesMyFiles/src/list.c | 172 +++ plugins/WhoUsesMyFiles/src/resizer.c | 131 +++ plugins/WhoUsesMyFiles/src/resource.h | 46 + plugins/WhoUsesMyFiles/src/wumf.c | 330 ++++++ plugins/WhoUsesMyFiles/src/wumf.h | 167 +++ plugins/WhoUsesMyFiles/src/wumfplug.c | 634 +++++++++++ plugins/WhoUsesMyFiles/wumf.c | 330 ------ plugins/WhoUsesMyFiles/wumf.h | 167 --- plugins/WhoUsesMyFiles/wumf.vcxproj | 16 +- plugins/WhoUsesMyFiles/wumf.vcxproj.filters | 14 +- plugins/WhoUsesMyFiles/wumfplug.c | 634 ----------- plugins/YAPP/PPh2.ico | Bin 2038 -> 0 bytes plugins/YAPP/common.h | 114 -- plugins/YAPP/docs/m_popup2.h | 29 - plugins/YAPP/docs/yapp-translation.txt | 74 ++ plugins/YAPP/message_pump.cpp | 186 --- plugins/YAPP/message_pump.h | 23 - plugins/YAPP/notify.h | 7 - plugins/YAPP/notify_imp.cpp | 146 --- plugins/YAPP/options.cpp | 505 --------- plugins/YAPP/options.h | 36 - plugins/YAPP/popup_history.cpp | 87 -- plugins/YAPP/popup_history.h | 96 -- plugins/YAPP/popup_history_dlg.cpp | 743 ------------ plugins/YAPP/popups2.cpp | 241 ---- plugins/YAPP/popups2.h | 12 - plugins/YAPP/popups2.rc | 207 ---- plugins/YAPP/popups2_10.vcxproj | 207 ---- plugins/YAPP/popups2_10.vcxproj.filters | 83 -- plugins/YAPP/popwin.cpp | 772 ------------- plugins/YAPP/popwin.h | 28 - plugins/YAPP/res/PPh2.ico | Bin 0 -> 2038 bytes plugins/YAPP/res/version.rc | 36 + plugins/YAPP/res/yapp.rc | 207 ++++ plugins/YAPP/resource.h | 79 -- plugins/YAPP/services.cpp | 524 --------- plugins/YAPP/services.h | 10 - plugins/YAPP/src/common.h | 114 ++ plugins/YAPP/src/m_yapp.h | 29 + plugins/YAPP/src/message_pump.cpp | 186 +++ plugins/YAPP/src/message_pump.h | 23 + plugins/YAPP/src/notify.h | 7 + plugins/YAPP/src/notify_imp.cpp | 146 +++ plugins/YAPP/src/options.cpp | 505 +++++++++ plugins/YAPP/src/options.h | 36 + plugins/YAPP/src/popwin.cpp | 772 +++++++++++++ plugins/YAPP/src/popwin.h | 28 + plugins/YAPP/src/resource.h | 79 ++ plugins/YAPP/src/services.cpp | 524 +++++++++ plugins/YAPP/src/services.h | 10 + plugins/YAPP/src/version.h | 24 + plugins/YAPP/src/yapp.cpp | 241 ++++ plugins/YAPP/src/yapp.h | 12 + plugins/YAPP/src/yapp_history.cpp | 87 ++ plugins/YAPP/src/yapp_history.h | 96 ++ plugins/YAPP/src/yapp_history_dlg.cpp | 743 ++++++++++++ plugins/YAPP/version.h | 24 - plugins/YAPP/version.rc | 36 - plugins/YAPP/yapp-translation.txt | 74 -- plugins/YAPP/yapp_10.vcxproj | 207 ++++ plugins/YAPP/yapp_10.vcxproj.filters | 83 ++ .../ZeroNotification/Zero Notification_10.vcxproj | 12 +- .../Zero Notification_10.vcxproj.filters | 8 +- plugins/ZeroNotification/common.h | 19 - .../docs/zeronotification-translation.txt | 12 + plugins/ZeroNotification/main.cpp | 281 ----- plugins/ZeroNotification/res/ZeroNotifyW.rc | 4 +- plugins/ZeroNotification/res/resource.h | 20 - plugins/ZeroNotification/src/common.h | 19 + plugins/ZeroNotification/src/main.cpp | 281 +++++ plugins/ZeroNotification/src/resource.h | 20 + plugins/ZeroNotification/src/version.h | 13 + plugins/ZeroNotification/version.h | 13 - .../zeronotification-translation.txt | 12 - 176 files changed, 12249 insertions(+), 12388 deletions(-) delete mode 100644 plugins/VersionInfo/AggressiveOptimize.h delete mode 100644 plugins/VersionInfo/CPlugin.cpp delete mode 100644 plugins/VersionInfo/CPlugin.h delete mode 100644 plugins/VersionInfo/CVersionInfo.cpp delete mode 100644 plugins/VersionInfo/CVersionInfo.h delete mode 100644 plugins/VersionInfo/VersionInfo.html delete mode 100644 plugins/VersionInfo/VersionInfo.ico delete mode 100644 plugins/VersionInfo/common.h delete mode 100644 plugins/VersionInfo/dlgHandlers.cpp delete mode 100644 plugins/VersionInfo/dlgHandlers.h create mode 100644 plugins/VersionInfo/docs/VersionInfo.html create mode 100644 plugins/VersionInfo/docs/svc_vi-translation.txt delete mode 100644 plugins/VersionInfo/hooked_events.cpp delete mode 100644 plugins/VersionInfo/hooked_events.h delete mode 100644 plugins/VersionInfo/main.cpp create mode 100644 plugins/VersionInfo/res/VersionInfo.ico create mode 100644 plugins/VersionInfo/res/resource.rc create mode 100644 plugins/VersionInfo/res/version.rc delete mode 100644 plugins/VersionInfo/resource.h delete mode 100644 plugins/VersionInfo/resource.rc delete mode 100644 plugins/VersionInfo/services.cpp delete mode 100644 plugins/VersionInfo/services.h create mode 100644 plugins/VersionInfo/src/CPlugin.cpp create mode 100644 plugins/VersionInfo/src/CPlugin.h create mode 100644 plugins/VersionInfo/src/CVersionInfo.cpp create mode 100644 plugins/VersionInfo/src/CVersionInfo.h create mode 100644 plugins/VersionInfo/src/common.h create mode 100644 plugins/VersionInfo/src/dlgHandlers.cpp create mode 100644 plugins/VersionInfo/src/dlgHandlers.h create mode 100644 plugins/VersionInfo/src/hooked_events.cpp create mode 100644 plugins/VersionInfo/src/hooked_events.h create mode 100644 plugins/VersionInfo/src/main.cpp create mode 100644 plugins/VersionInfo/src/resource.h create mode 100644 plugins/VersionInfo/src/services.cpp create mode 100644 plugins/VersionInfo/src/services.h create mode 100644 plugins/VersionInfo/src/utils.cpp create mode 100644 plugins/VersionInfo/src/utils.h create mode 100644 plugins/VersionInfo/src/version.h delete mode 100644 plugins/VersionInfo/svc_vi-translation.txt delete mode 100644 plugins/VersionInfo/utils.cpp delete mode 100644 plugins/VersionInfo/utils.h delete mode 100644 plugins/VersionInfo/version.h delete mode 100644 plugins/VersionInfo/version.rc delete mode 100644 plugins/W7UI/clistproxywindow.cpp delete mode 100644 plugins/W7UI/clistproxywindow.h create mode 100644 plugins/W7UI/docs/w7ui-translation.txt delete mode 100644 plugins/W7UI/dwmwindow.cpp delete mode 100644 plugins/W7UI/dwmwindow.h delete mode 100644 plugins/W7UI/headers.h delete mode 100644 plugins/W7UI/jumplist.cpp delete mode 100644 plugins/W7UI/jumplist.h delete mode 100644 plugins/W7UI/jumplistarray.cpp delete mode 100644 plugins/W7UI/jumplistarray.h delete mode 100644 plugins/W7UI/jumplistbuilder.cpp delete mode 100644 plugins/W7UI/jumplistbuilder.h delete mode 100644 plugins/W7UI/main.cpp create mode 100644 plugins/W7UI/src/clistproxywindow.cpp create mode 100644 plugins/W7UI/src/clistproxywindow.h create mode 100644 plugins/W7UI/src/dwmwindow.cpp create mode 100644 plugins/W7UI/src/dwmwindow.h create mode 100644 plugins/W7UI/src/headers.h create mode 100644 plugins/W7UI/src/jumplist.cpp create mode 100644 plugins/W7UI/src/jumplist.h create mode 100644 plugins/W7UI/src/jumplistarray.cpp create mode 100644 plugins/W7UI/src/jumplistarray.h create mode 100644 plugins/W7UI/src/jumplistbuilder.cpp create mode 100644 plugins/W7UI/src/jumplistbuilder.h create mode 100644 plugins/W7UI/src/main.cpp create mode 100644 plugins/W7UI/src/srmmproxywindow.cpp create mode 100644 plugins/W7UI/src/srmmproxywindow.h create mode 100644 plugins/W7UI/src/subclassmgr.cpp create mode 100644 plugins/W7UI/src/subclassmgr.h create mode 100644 plugins/W7UI/src/w7ui.cpp create mode 100644 plugins/W7UI/src/win7api.cpp create mode 100644 plugins/W7UI/src/win7api.h create mode 100644 plugins/W7UI/src/win7api_ICustomDestinationList.h create mode 100644 plugins/W7UI/src/win7api_IObjectArray.h create mode 100644 plugins/W7UI/src/win7api_IObjectCollection.h create mode 100644 plugins/W7UI/src/win7api_ITaskbarList3.h delete mode 100644 plugins/W7UI/srmmproxywindow.cpp delete mode 100644 plugins/W7UI/srmmproxywindow.h delete mode 100644 plugins/W7UI/subclassmgr.cpp delete mode 100644 plugins/W7UI/subclassmgr.h delete mode 100644 plugins/W7UI/w7ui-translation.txt delete mode 100644 plugins/W7UI/w7ui.cpp delete mode 100644 plugins/W7UI/win7api.cpp delete mode 100644 plugins/W7UI/win7api.h delete mode 100644 plugins/W7UI/win7api_ICustomDestinationList.h delete mode 100644 plugins/W7UI/win7api_IObjectArray.h delete mode 100644 plugins/W7UI/win7api_IObjectCollection.h delete mode 100644 plugins/W7UI/win7api_ITaskbarList3.h create mode 100644 plugins/WhoUsesMyFiles/docs/wumf.readme.txt delete mode 100644 plugins/WhoUsesMyFiles/list.c delete mode 100644 plugins/WhoUsesMyFiles/res/drive.bmp create mode 100644 plugins/WhoUsesMyFiles/res/resource.rc delete mode 100644 plugins/WhoUsesMyFiles/res/wumf.readme.txt delete mode 100644 plugins/WhoUsesMyFiles/resizer.c delete mode 100644 plugins/WhoUsesMyFiles/resource.h delete mode 100644 plugins/WhoUsesMyFiles/resource.rc create mode 100644 plugins/WhoUsesMyFiles/src/list.c create mode 100644 plugins/WhoUsesMyFiles/src/resizer.c create mode 100644 plugins/WhoUsesMyFiles/src/resource.h create mode 100644 plugins/WhoUsesMyFiles/src/wumf.c create mode 100644 plugins/WhoUsesMyFiles/src/wumf.h create mode 100644 plugins/WhoUsesMyFiles/src/wumfplug.c delete mode 100644 plugins/WhoUsesMyFiles/wumf.c delete mode 100644 plugins/WhoUsesMyFiles/wumf.h delete mode 100644 plugins/WhoUsesMyFiles/wumfplug.c delete mode 100644 plugins/YAPP/PPh2.ico delete mode 100644 plugins/YAPP/common.h delete mode 100644 plugins/YAPP/docs/m_popup2.h create mode 100644 plugins/YAPP/docs/yapp-translation.txt delete mode 100644 plugins/YAPP/message_pump.cpp delete mode 100644 plugins/YAPP/message_pump.h delete mode 100644 plugins/YAPP/notify.h delete mode 100644 plugins/YAPP/notify_imp.cpp delete mode 100644 plugins/YAPP/options.cpp delete mode 100644 plugins/YAPP/options.h delete mode 100644 plugins/YAPP/popup_history.cpp delete mode 100644 plugins/YAPP/popup_history.h delete mode 100644 plugins/YAPP/popup_history_dlg.cpp delete mode 100644 plugins/YAPP/popups2.cpp delete mode 100644 plugins/YAPP/popups2.h delete mode 100644 plugins/YAPP/popups2.rc delete mode 100644 plugins/YAPP/popups2_10.vcxproj delete mode 100644 plugins/YAPP/popups2_10.vcxproj.filters delete mode 100644 plugins/YAPP/popwin.cpp delete mode 100644 plugins/YAPP/popwin.h create mode 100644 plugins/YAPP/res/PPh2.ico create mode 100644 plugins/YAPP/res/version.rc create mode 100644 plugins/YAPP/res/yapp.rc delete mode 100644 plugins/YAPP/resource.h delete mode 100644 plugins/YAPP/services.cpp delete mode 100644 plugins/YAPP/services.h create mode 100644 plugins/YAPP/src/common.h create mode 100644 plugins/YAPP/src/m_yapp.h create mode 100644 plugins/YAPP/src/message_pump.cpp create mode 100644 plugins/YAPP/src/message_pump.h create mode 100644 plugins/YAPP/src/notify.h create mode 100644 plugins/YAPP/src/notify_imp.cpp create mode 100644 plugins/YAPP/src/options.cpp create mode 100644 plugins/YAPP/src/options.h create mode 100644 plugins/YAPP/src/popwin.cpp create mode 100644 plugins/YAPP/src/popwin.h create mode 100644 plugins/YAPP/src/resource.h create mode 100644 plugins/YAPP/src/services.cpp create mode 100644 plugins/YAPP/src/services.h create mode 100644 plugins/YAPP/src/version.h create mode 100644 plugins/YAPP/src/yapp.cpp create mode 100644 plugins/YAPP/src/yapp.h create mode 100644 plugins/YAPP/src/yapp_history.cpp create mode 100644 plugins/YAPP/src/yapp_history.h create mode 100644 plugins/YAPP/src/yapp_history_dlg.cpp delete mode 100644 plugins/YAPP/version.h delete mode 100644 plugins/YAPP/version.rc delete mode 100644 plugins/YAPP/yapp-translation.txt create mode 100644 plugins/YAPP/yapp_10.vcxproj create mode 100644 plugins/YAPP/yapp_10.vcxproj.filters delete mode 100644 plugins/ZeroNotification/common.h create mode 100644 plugins/ZeroNotification/docs/zeronotification-translation.txt delete mode 100644 plugins/ZeroNotification/main.cpp delete mode 100644 plugins/ZeroNotification/res/resource.h create mode 100644 plugins/ZeroNotification/src/common.h create mode 100644 plugins/ZeroNotification/src/main.cpp create mode 100644 plugins/ZeroNotification/src/resource.h create mode 100644 plugins/ZeroNotification/src/version.h delete mode 100644 plugins/ZeroNotification/version.h delete mode 100644 plugins/ZeroNotification/zeronotification-translation.txt diff --git a/plugins/VersionInfo/AggressiveOptimize.h b/plugins/VersionInfo/AggressiveOptimize.h deleted file mode 100644 index 1b646c301c..0000000000 --- a/plugins/VersionInfo/AggressiveOptimize.h +++ /dev/null @@ -1,58 +0,0 @@ - -////////////////////////////// -// Version 1.10 -// Jan 23rd, 2000 -// Version 1.00 -// May 20th, 1999 -// Todd C. Wilson, Fresh Ground Software -// (todd@nopcode.com) -// This header file will kick in settings for Visual C++ 5 and 6 that will (usually) -// result in smaller exe's. -// The "trick" is to tell the compiler to not pad out the function calls; this is done -// by not using the /O1 or /O2 option - if you do, you implicitly use /Gy, which pads -// out each and every function call. In one single 500k dll, I managed to cut out 120k -// by this alone! -// The other two "tricks" are telling the Linker to merge all data-type segments together -// in the exe file. The relocation, read-only (constants) data, and code section (.text) -// sections can almost always be merged. Each section merged can save 4k in exe space, -// since each section is padded out to 4k chunks. This is very noticable with smaller -// exes, since you could have only 700 bytes of data, 300 bytes of code, 94 bytes of -// strings - padded out, this could be 12k of runtime, for 1094 bytes of stuff! -// Note that if you're using MFC static or some other 3rd party libs, you may get poor -// results with merging the readonly (.rdata) section - the exe may grow larger. -// To use this feature, define _MERGE_DATA_ in your project or before this header is used. -// With Visual C++ 5, the program uses a file alignement of 512 bytes, which results -// in a small exe. Under VC6, the program instead uses 4k, which is the same as the -// section size. The reason (from what I understand) is that 4k is the chunk size of -// the virtual memory manager, and that WinAlign (an end-user tuning tool for Win98) -// will re-align the programs on this boundary. The problem with this is that all of -// Microsoft's system exes and dlls are not tuned like this, and using 4k causes serious -// exe bloat. Very noticable for smaller programs. -// The "trick" for this is to use the undocumented FILEALIGN linker parm to change the -// padding from 4k to 1/2k, which results in a much smaller exe - anywhere from 20%-75% -// depending on the size. - - -#ifdef NDEBUG -// /Og (global optimizations), /Os (favor small code), /Oy (no frame pointers) -#pragma optimize("gsy",on) - -#pragma comment(linker,"/RELEASE") - -// Note that merging the .rdata section will result in LARGER exe's if you using -// MFC (esp. static link). If this is desirable, define _MERGE_RDATA_ in your project. -#ifdef _MERGE_RDATA_ -#pragma comment(linker,"/merge:.rdata=.data") -#endif // _MERGE_RDATA_ - -#pragma comment(linker,"/merge:.text=.data") -#pragma comment(linker,"/merge:.reloc=.data") - -#if _MSC_VER >= 1000 -// Only supported/needed with VC6; VC5 already does 0x200 for release builds. -// Totally undocumented! And if you set it lower than 512 bytes, the program crashes. -// Either leave at 0x200 or 0x1000 -#pragma comment(linker,"/FILEALIGN:0x200") -#endif // _MSC_VER >= 1000 - -#endif // NDEBUG diff --git a/plugins/VersionInfo/CPlugin.cpp b/plugins/VersionInfo/CPlugin.cpp deleted file mode 100644 index 54d762064a..0000000000 --- a/plugins/VersionInfo/CPlugin.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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 "CPlugin.h" - -#include "common.h" - -#pragma comment(lib, "version.lib") - -const int cPLUGIN_UUID_MARK = 4; -TCHAR PLUGIN_UUID_MARK[cPLUGIN_UUID_MARK]; - -#define PLUGIN_UNCERTAIN_MARK "?" - -#define RJUST 70 - -CPlugin::CPlugin() { - pluginID = UUID_NULL; -} - -CPlugin::CPlugin(LPCTSTR eFileName, LPCTSTR eShortName, MUUID pluginID, LPCTSTR eUnicodeInfo, DWORD eVersion, LPCTSTR eTimestamp, LPCTSTR eLinkedModules) { - lpzFileName = eFileName; - lpzShortName = eShortName; - lpzUnicodeInfo = eUnicodeInfo; - lpzTimestamp = eTimestamp; - lpzLinkedModules = eLinkedModules; - - int v1, v2, v3, v4; - - DWORD unused, verInfoSize = GetFileVersionInfoSize(eFileName, &unused); - if (verInfoSize != 0) { - UINT blockSize; - VS_FIXEDFILEINFO* fi; - void* pVerInfo = mir_alloc(verInfoSize); - GetFileVersionInfo(eFileName, 0, verInfoSize, pVerInfo); - VerQueryValue(pVerInfo, _T("\\"), (LPVOID*)&fi, &blockSize); - v1 = HIWORD(fi->dwProductVersionMS), v2 = LOWORD(fi->dwProductVersionMS), - v3 = HIWORD(fi->dwProductVersionLS), v4 = LOWORD(fi->dwProductVersionLS); - mir_free(pVerInfo); - } - else { - DWORD ver = eVersion; - v1 = HIBYTE(HIWORD(ver)), v2 = LOBYTE(HIWORD(ver)), v3 = HIBYTE(LOWORD(ver)), v4 = LOBYTE(LOWORD(ver)); - } - - TCHAR aux[128]; - mir_sntprintf(aux, SIZEOF(aux), _T("%d.%d.%d.%d"), v1, v2, v3, v4); - lpzVersion = aux; - - this->pluginID = pluginID; -}; - -CPlugin::CPlugin(const CPlugin& other) { - lpzFileName = other.lpzFileName; - lpzShortName = other.lpzShortName; - lpzUnicodeInfo = other.lpzUnicodeInfo; - lpzVersion = other.lpzVersion; - lpzTimestamp = other.lpzTimestamp; - lpzLinkedModules = other.lpzLinkedModules; - pluginID = other.pluginID; -} - -CPlugin::~CPlugin() -{ -} - -void CPlugin::SetErrorMessage(LPCTSTR error) -{ - lpzLinkedModules = error; -} - -bool CPlugin::operator<(CPlugin &anotherPlugin) -{ - std::tstring anotherFileName = anotherPlugin.getFileName(); - - TCHAR szThis[MAX_PATH]; lstrcpy(szThis, lpzFileName.c_str()); - TCHAR szThat[MAX_PATH]; lstrcpy(szThat, anotherFileName.c_str()); - - if (lstrcmpi(szThis, szThat) < 0) - return TRUE; - else - return FALSE; -} - -bool CPlugin::operator>(CPlugin &anotherPlugin) -{ - return !((*this) < anotherPlugin); -} -bool CPlugin::operator==(CPlugin &anotherPlugin) -{ - return !((*this) < anotherPlugin || (*this) > anotherPlugin); -} - -std::tstring CPlugin::getFileName() -{ - return this->lpzFileName; -} - -std::tstring CPlugin::getInformations(DWORD flags, TCHAR *szHighlightHeader, TCHAR *szHighlightFooter) -{ - std::tstring lpzInformations; - if (flags & VISF_SHOWUUID) - { - TCHAR aux[128]; - UUIDToString(pluginID, aux, SIZEOF(aux)); - lpzInformations = aux; - } - else lpzInformations = (IsUUIDNull(pluginID)) ? _T(" ") : PLUGIN_UUID_MARK; - - lpzInformations += std::tstring(_T(" ") + lpzFileName + _T(" v.") + szHighlightHeader + lpzVersion + szHighlightFooter + _T(" [") + lpzTimestamp + _T("] - ") + lpzShortName); - if (lpzUnicodeInfo.size() > 0) - { - TCHAR *lwr = _tcslwr(_tcsdup(lpzShortName.c_str())); - if ( !_tcsstr(lwr, _T("unicode")) && !_tcsstr(lwr, _T("2in1"))) - lpzInformations.append( _T(" |") + lpzUnicodeInfo + _T("|")); - - free(lwr); - } - //lpzInformations.append("\t"); - //lpzInformations.append(lpzPluginID); - lpzInformations.append( _T("\r\n")); - - if (lpzLinkedModules.size() > 0) - { - lpzInformations.append(lpzLinkedModules); - lpzInformations.append( _T("\r\n")); - } -// std::string lpzInformations = std::string(lpzFileName + " - " + lpzShortName + " [" + lpzTimestamp + " · " + lpzVersion +"]\r\n"); - return lpzInformations; -}; \ No newline at end of file diff --git a/plugins/VersionInfo/CPlugin.h b/plugins/VersionInfo/CPlugin.h deleted file mode 100644 index 5da1b1dc6b..0000000000 --- a/plugins/VersionInfo/CPlugin.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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 CPLUGIN_H -#define CPLUGIN_H - -//#define STRICT -#define WIN32_LEAN_AND_MEAN - -#define _CRT_SECURE_NO_DEPRECATE - -#include -#include - -#ifndef M_NEWPLUGINAPI_H__ - #include "newpluginapi.h" -#endif - -#define DEF_UUID_CHARMARK "¤" - -extern const int cPLUGIN_UUID_MARK; -extern TCHAR PLUGIN_UUID_MARK[]; - -//using namespace std; - - - #define tstring wstring - - -class CPlugin { - private: - std::tstring lpzFileName; - std::tstring lpzShortName; - std::tstring lpzVersion; - std::tstring lpzUnicodeInfo; //aditional info, Unicode aware ... - std::tstring lpzTimestamp; //to show the last modified timestamp - std::tstring lpzLinkedModules; //to show linked modules that aren't found - MUUID pluginID; - - public: - CPlugin(); - CPlugin(LPCTSTR fileName, LPCTSTR shortName, MUUID pluginID, LPCTSTR unicodeInfo, DWORD version, LPCTSTR timestamp, LPCTSTR linkedModules); - CPlugin(const CPlugin&); - ~CPlugin(); - std::tstring getFileName(); - std::tstring getInformations(DWORD, TCHAR *, TCHAR *); - - void SetErrorMessage(LPCTSTR error); - - //Operators - bool operator<(CPlugin&); - bool operator>(CPlugin&); - bool operator==(CPlugin&); -}; -#endif \ No newline at end of file diff --git a/plugins/VersionInfo/CVersionInfo.cpp b/plugins/VersionInfo/CVersionInfo.cpp deleted file mode 100644 index da10f4b9a9..0000000000 --- a/plugins/VersionInfo/CVersionInfo.cpp +++ /dev/null @@ -1,1198 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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 "CVersionInfo.h" -//#include "AggressiveOptimize.h" - -#include "common.h" -#include "resource.h" - -//using namespace std; - -BOOL (WINAPI *MyGetDiskFreeSpaceEx)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); -BOOL (WINAPI *MyIsWow64Process)(HANDLE, PBOOL); -void (WINAPI *MyGetSystemInfo)(LPSYSTEM_INFO); -BOOL (WINAPI *MyGlobalMemoryStatusEx)(LPMEMORYSTATUSEX lpBuffer) = NULL; - -LANGID (WINAPI *MyGetUserDefaultUILanguage)() = NULL; -LANGID (WINAPI *MyGetSystemDefaultUILanguage)() = NULL; - -static int ValidExtension(TCHAR *fileName, TCHAR *extension) -{ - TCHAR *dot = _tcschr(fileName, '.'); - if ( dot != NULL && !lstrcmpi(dot + 1, extension)) - if (dot[lstrlen(extension) + 1] == 0) - return 1; - - return 0; -} - -void FillLocalTime(std::tstring &output, FILETIME *fileTime) -{ - TIME_ZONE_INFORMATION tzInfo = {0}; - FILETIME local = {0}; - SYSTEMTIME sysTime; - TCHAR date[1024]; - TCHAR time[256]; - - FileTimeToLocalFileTime(fileTime, &local); - FileTimeToSystemTime(&local, &sysTime); - - GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date)); - GetTimeFormat(NULL, TIME_FORCE24HOURFORMAT, &sysTime, _T("HH':'mm':'ss"), time, SIZEOF(time)); //americans love 24hour format ;) - output = std::tstring(date) + _T(" at ") + std::tstring(time); - - int res = GetTimeZoneInformation(&tzInfo); - char tzName[32] = {0}; - TCHAR tzOffset[64] = {0}; - int offset = 0; - switch (res) { - case TIME_ZONE_ID_DAYLIGHT: - offset = -(tzInfo.Bias + tzInfo.DaylightBias); - WideCharToMultiByte(CP_ACP, 0, tzInfo.DaylightName, -1, tzName, SIZEOF(tzName), NULL, NULL); - break; - - case TIME_ZONE_ID_STANDARD: - WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL); - offset = -(tzInfo.Bias + tzInfo.StandardBias); - break; - - case TIME_ZONE_ID_UNKNOWN: - WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL); - offset = -tzInfo.Bias; - break; - } - - mir_sntprintf(tzOffset, SIZEOF(tzOffset), _T("UTC %+02d:%02d"), offset / 60, offset % 60); - output += _T(" (") + std::tstring(tzOffset) + _T(")"); -} - -CVersionInfo::CVersionInfo() -{ - luiFreeDiskSpace = 0; - bDEPEnabled = 0; -} - -CVersionInfo::~CVersionInfo() -{ - listInactivePlugins.clear(); - listActivePlugins.clear(); - listUnloadablePlugins.clear(); - - lpzMirandaVersion.~basic_string(); - lpzNightly.~basic_string(); - lpzUnicodeBuild.~basic_string(); - lpzBuildTime.~basic_string(); - lpzOSVersion.~basic_string(); - lpzMirandaPath.~basic_string(); - lpzCPUName.~basic_string(); - lpzCPUIdentifier.~basic_string(); -}; - -void CVersionInfo::Initialize() -{ -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetMirandaVersion().", SM_NOTIFY); -#endif - GetMirandaVersion(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetProfileSettings().", SM_NOTIFY); -#endif - GetProfileSettings(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetLangpackInfo().", SM_NOTIFY); -#endif - GetOSLanguages(); - GetLangpackInfo(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetPluginLists().", SM_NOTIFY); -#endif - GetPluginLists(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetOSVersion().", SM_NOTIFY); -#endif - GetOSVersion(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetHWSettings().", SM_NOTIFY); -#endif - GetHWSettings(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Done with GetHWSettings().", SM_NOTIFY); -#endif -} - -bool CVersionInfo::GetMirandaVersion() -{ - //Miranda version - const BYTE str_size = 64; - char str[str_size]; - CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)str_size, (LPARAM)str); - this->lpzMirandaVersion = _A2T(str); - //Is it a nightly? - if (lpzMirandaVersion.find( _T("alpha"),0) != std::string::npos) - lpzNightly = _T("Yes"); - else - lpzNightly = _T("No"); - - if (lpzMirandaVersion.find( _T("Unicode"), 0) != std::string::npos) - lpzUnicodeBuild = _T("Yes"); - else - lpzUnicodeBuild = _T("No"); - - TCHAR time[128], date[128]; - GetModuleTimeStamp(date, time); - lpzBuildTime = std::tstring(time) + _T(" (UTC) on ") + std::tstring(date); - return TRUE; -} - -bool CVersionInfo::GetOSVersion() -{ - //Operating system informations - OSVERSIONINFO osvi = { 0 }; - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionEx(&osvi); - - //Now fill the private members. - TCHAR aux[256]; - wsprintf(aux, _T("%d.%d.%d %s"), osvi.dwMajorVersion, osvi.dwMinorVersion, LOWORD(osvi.dwBuildNumber), osvi.szCSDVersion); - lpzOSVersion = aux; - - //OSName - //Let's read the registry. - HKEY hKey; - TCHAR szKey[MAX_PATH], szValue[MAX_PATH]; - lstrcpyn(szKey, _T("Hardware\\Description\\System\\CentralProcessor\\0"), MAX_PATH); - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { - DWORD type, size, result; - - lstrcpyn(szValue, _T("Identifier"), MAX_PATH); - result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); - if (result == ERROR_SUCCESS) { - TCHAR *aux = new TCHAR[size+1]; - result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); - lpzCPUIdentifier = aux; - delete[] aux; - } - else { - NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); - lpzCPUIdentifier = _T(""); - } - - lstrcpyn(szValue, _T("ProcessorNameString"), MAX_PATH); - result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); //get the size - if (result == ERROR_SUCCESS) { - TCHAR *aux = new TCHAR[size+1]; - result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); - lpzCPUName = aux; - delete[] aux; - } - else { //else try to use cpuid instruction to get the proc name - char szName[50]; - #if (!defined(WIN64) && !defined(_WIN64)) - __asm - { - push eax //save the registers - push ebx - push ecx - push edx - - xor eax, eax //get simple name - cpuid - mov DWORD PTR szName[0], ebx - mov DWORD PTR szName[4], edx - mov DWORD PTR szName[8], ecx - mov DWORD PTR szName[12], 0 - - mov eax, 0x80000000 //try to get pretty name - cpuid - - cmp eax, 0x80000004 - jb end //if we don't have the extension end the check - - mov DWORD PTR szName[0], 0 //make the string null - - mov eax, 0x80000002 //first part of the string - cpuid - mov DWORD PTR szName[0], eax - mov DWORD PTR szName[4], ebx - mov DWORD PTR szName[8], ecx - mov DWORD PTR szName[12], edx - - mov eax, 0x80000003 //second part of the string - cpuid - mov DWORD PTR szName[16], eax - mov DWORD PTR szName[20], ebx - mov DWORD PTR szName[24], ecx - mov DWORD PTR szName[28], edx - - mov eax, 0x80000004 //third part of the string - cpuid - mov DWORD PTR szName[32], eax - mov DWORD PTR szName[36], ebx - mov DWORD PTR szName[40], ecx - mov DWORD PTR szName[44], edx - -end: - pop edx //load them back - pop ecx - pop ebx - pop eax - } - szName[SIZEOF(szName) - 1] = '\0'; - #else - szName[0] = 0; - #endif - - if ( !szName[0] ) - lpzCPUName = _T(""); - else - lpzCPUName = _A2T(szName); - } - } - - bDEPEnabled = IsProcessorFeaturePresent(PF_NX_ENABLED); - - switch (osvi.dwPlatformId) { - case VER_PLATFORM_WIN32_WINDOWS: - lstrcpyn(szKey, _T("Software\\Microsoft\\Windows\\CurrentVersion"), MAX_PATH); - lstrcpyn(szValue, _T("Version"), MAX_PATH); - break; - case VER_PLATFORM_WIN32_NT: - - lstrcpyn(szKey, _T("Software\\Microsoft\\Windows NT\\CurrentVersion"), MAX_PATH); - lstrcpyn(szValue, _T("ProductName"), MAX_PATH); - break; - } - - RegCloseKey(hKey); - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,szKey,0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) { - DWORD type, size, result; - //Get the size of the value we'll read. - result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)NULL, - (LPDWORD)&size); - if (result == ERROR_SUCCESS) { - //Read it. - TCHAR *aux = new TCHAR[size+1]; - result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)aux,(LPDWORD)&size); - lpzOSName = aux; - delete[] aux; - } - else { - NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); - lpzOSName = _T(""); - } - } - else { - NotifyError(GetLastError(), _T("RegOpenKeyEx()"), __LINE__); - lpzOSName = _T(""); - } - - //Now we can improve it if we can. - switch (LOWORD(osvi.dwBuildNumber)) { - case 950: lpzOSName = _T("Microsoft Windows 95"); break; - case 1111: lpzOSName = _T("Microsoft Windows 95 OSR2"); break; - case 1998: lpzOSName = _T("Microsoft Windows 98"); break; - case 2222: lpzOSName = _T("Microsoft Windows 98 SE"); break; - case 3000: lpzOSName = _T("Microsoft Windows ME"); break; //Even if this is wrong, we have already read it in the registry. - case 1381: lpzOSName = _T("Microsoft Windows NT"); break; //What about service packs? - case 2195: lpzOSName = _T("Microsoft Windows 2000"); break; //What about service packs? - case 2600: lpzOSName = _T("Microsoft Windows XP"); break; - case 3790: - if ( GetSystemMetrics( 89 )) //R2 ? - lpzOSName = _T("Microsoft Windows 2003 R2"); - else - lpzOSName = _T("Microsoft Windows 2003"); - - break; //added windows 2003 info - } - - return TRUE; -} - -bool CVersionInfo::GetHWSettings() { - //Free space on Miranda Partition. - TCHAR szMirandaPath[MAX_PATH] = { 0 }; - { - GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); - TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); - if ( str2 != NULL) *str2=0; - } - HMODULE hKernel32; - hKernel32 = LoadLibraryA("kernel32.dll"); - if (hKernel32) { - - MyGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCTSTR,PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER))GetProcAddress(hKernel32, "GetDiskFreeSpaceExW"); - - - MyIsWow64Process = (BOOL (WINAPI *) (HANDLE, PBOOL)) GetProcAddress(hKernel32, "IsWow64Process"); - MyGetSystemInfo = (void (WINAPI *) (LPSYSTEM_INFO)) GetProcAddress(hKernel32, "GetNativeSystemInfo"); - MyGlobalMemoryStatusEx = (BOOL (WINAPI *) (LPMEMORYSTATUSEX)) GetProcAddress(hKernel32, "GlobalMemoryStatusEx"); - if ( !MyGetSystemInfo ) - MyGetSystemInfo = GetSystemInfo; - - FreeLibrary(hKernel32); - } - if ( MyGetDiskFreeSpaceEx ) { - ULARGE_INTEGER FreeBytes, a, b; - MyGetDiskFreeSpaceEx(szMirandaPath, &FreeBytes, &a, &b); - //Now we need to convert it. - __int64 aux = FreeBytes.QuadPart; - aux /= (1024*1024); - luiFreeDiskSpace = (unsigned long int)aux; - } - else luiFreeDiskSpace = 0; - - TCHAR szInfo[1024]; - GetWindowsShell(szInfo, SIZEOF(szInfo)); - lpzShell = szInfo; - GetInternetExplorerVersion(szInfo, SIZEOF(szInfo)); - lpzIEVersion = szInfo; - - - lpzAdministratorPrivileges = (IsCurrentUserLocalAdministrator()) ? _T("Yes") : _T("No"); - - bIsWOW64 = 0; - if (MyIsWow64Process) - if (!MyIsWow64Process(GetCurrentProcess(), &bIsWOW64)) - bIsWOW64 = 0; - - SYSTEM_INFO sysInfo = {0}; - GetSystemInfo(&sysInfo); - luiProcessors = sysInfo.dwNumberOfProcessors; - - //Installed RAM - if (MyGlobalMemoryStatusEx) { //windows 2000+ - MEMORYSTATUSEX ms = {0}; - ms.dwLength = sizeof(ms); - MyGlobalMemoryStatusEx(&ms); - luiRAM = (unsigned int) ((ms.ullTotalPhys / (1024 * 1024)) + 1); - } - else { - MEMORYSTATUS ms = {0}; - ms.dwLength = sizeof(ms); - GlobalMemoryStatus(&ms); - luiRAM = (ms.dwTotalPhys/(1024*1024))+1; //Ugly hack!!!! - } - - return TRUE; -} - -bool CVersionInfo::GetProfileSettings() -{ - TCHAR* tszProfileName = Utils_ReplaceVarsT(_T("%miranda_userdata%\\%miranda_profilename%.dat")); - lpzProfilePath = tszProfileName; - - WIN32_FIND_DATA fd; - if ( FindFirstFile(tszProfileName, &fd) != INVALID_HANDLE_VALUE ) { - TCHAR number[40]; - mir_sntprintf( number, SIZEOF(number), _T("%.2f KBytes"), double(fd.nFileSizeLow) / 1024 ); - lpzProfileSize = number; - - FillLocalTime(lpzProfileCreationDate, &fd.ftCreationTime); - } - else { - DWORD error = GetLastError(); - TCHAR tmp[1024]; - wsprintf(tmp, _T("%d"), error); - lpzProfileCreationDate = _T("") + std::tstring(tszProfileName); - lpzProfileSize = _T("") + std::tstring(tszProfileName); - } - - mir_free( tszProfileName ); - return true; -} - -static TCHAR szSystemLocales[4096] = {0}; -static WORD systemLangID; -#define US_LANG_ID 0x00000409 - -BOOL CALLBACK EnumSystemLocalesProc(TCHAR *szLocale) -{ - DWORD locale = _ttoi(szLocale); - TCHAR *name = GetLanguageName(locale); - if ( !_tcsstr(szSystemLocales, name)) { - _tcscat(szSystemLocales, name); - _tcscat(szSystemLocales, _T(", ")); - } - - return TRUE; -} - -BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam) -{ - if (!lpszName) - return FALSE; - - if (wIDLanguage != US_LANG_ID) - systemLangID = wIDLanguage; - - return TRUE; -} - -bool CVersionInfo::GetOSLanguages() -{ - lpzOSLanguages = _T("(UI | Locale (User/System)) : "); - - LANGID UILang; - - OSVERSIONINFO os = {0}; - os.dwOSVersionInfoSize = sizeof(os); - GetVersionEx(&os); - if (os.dwMajorVersion == 4) { - if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) { //Win NT - HMODULE hLib = LoadLibraryA("ntdll.dll"); - - if (hLib) { - EnumResourceLanguages(hLib, RT_VERSION, MAKEINTRESOURCE(1), EnumResLangProc, NULL); - - FreeLibrary(hLib); - - if (systemLangID == US_LANG_ID) { - UINT uiACP; - - uiACP = GetACP(); - switch (uiACP) - { - case 874: // Thai code page activated, it's a Thai enabled system - systemLangID = MAKELANGID(LANG_THAI, SUBLANG_DEFAULT); - break; - - case 1255: // Hebrew code page activated, it's a Hebrew enabled system - systemLangID = MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT); - break; - - case 1256: // Arabic code page activated, it's a Arabic enabled system - systemLangID = MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_SAUDI_ARABIA); - break; - - default: - break; - } - } - } - } - else { //Win 95-Me - HKEY hKey = NULL; - TCHAR szLangID[128] = _T("0x"); - DWORD size = SIZEOF(szLangID) - 2; - TCHAR err[512]; - - if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop\\ResourceLocale"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { - if (RegQueryValueEx(hKey, _T(""), 0, NULL, (LPBYTE) &szLangID + 2, &size) == ERROR_SUCCESS) - _tscanf(szLangID, _T("%lx"), &systemLangID); - else { - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL); - MessageBox(0, err, _T("Error at RegQueryValueEx()"), MB_OK); - } - RegCloseKey(hKey); - } - else { - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL); - MessageBox(0, err, _T("Error at RegOpenKeyEx()"), MB_OK); - } - } - - lpzOSLanguages += GetLanguageName(systemLangID); - } - else { - HMODULE hKernel32 = LoadLibraryA("kernel32.dll"); - if (hKernel32) { - MyGetUserDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetUserDefaultUILanguage"); - MyGetSystemDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetSystemDefaultUILanguage"); - - FreeLibrary(hKernel32); - } - - if ((MyGetUserDefaultUILanguage) && (MyGetSystemDefaultUILanguage)) { - UILang = MyGetUserDefaultUILanguage(); - lpzOSLanguages += GetLanguageName(UILang); - lpzOSLanguages += _T("/"); - UILang = MyGetSystemDefaultUILanguage(); - lpzOSLanguages += GetLanguageName(UILang); - } - else lpzOSLanguages += _T("Missing functions in kernel32.dll (GetUserDefaultUILanguage, GetSystemDefaultUILanguage)"); - } - - lpzOSLanguages += _T(" | "); - lpzOSLanguages += GetLanguageName(LOCALE_USER_DEFAULT); - lpzOSLanguages += _T("/"); - lpzOSLanguages += GetLanguageName(LOCALE_SYSTEM_DEFAULT); - - if (DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", 0)) { - szSystemLocales[0] = '\0'; - lpzOSLanguages += _T(" ["); - EnumSystemLocales(EnumSystemLocalesProc, LCID_INSTALLED); - if (_tcslen(szSystemLocales) > 2) - szSystemLocales[ _tcslen(szSystemLocales) - 2] = '\0'; - - lpzOSLanguages += szSystemLocales; - lpzOSLanguages += _T("]"); - } - - return true; -} - -int SaveInfo(const char *data, const char *lwrData, const char *search, TCHAR *dest, int size) -{ - const char *pos = strstr(lwrData, search); - int res = 1; - if (pos == lwrData) { - _tcsncpy(dest, _A2T(&data[strlen(search)]), size); - res = 0; - } - - return res; -} - -bool CVersionInfo::GetLangpackInfo() -{ - TCHAR langpackPath[MAX_PATH] = {0}; - TCHAR search[MAX_PATH] = {0}; - - lpzLangpackModifiedDate = _T(""); - GetModuleFileName(GetModuleHandle(NULL), langpackPath, SIZEOF(langpackPath)); - TCHAR* p = _tcsrchr(langpackPath, '\\'); - if (p) { - WIN32_FIND_DATA data = {0}; - HANDLE hLangpack; - - p[1] = '\0'; - _tcscpy(search, langpackPath); - _tcscat(search, _T("langpack_*.txt")); - hLangpack = FindFirstFile(search, &data); - if (hLangpack != INVALID_HANDLE_VALUE) { - char buffer[1024]; - char temp[1024]; - FillLocalTime(lpzLangpackModifiedDate, &data.ftLastWriteTime); - - TCHAR locale[128] = {0}; - TCHAR language[128] = {0}; - TCHAR version[128] = {0}; - _tcscpy(version, _T("N/A")); - - _tcsncpy(language, data.cFileName, SIZEOF(language)); - p = _tcsrchr(language, '.'); - p[0] = '\0'; - - _tcscat(langpackPath, data.cFileName); - FILE *fin = _tfopen(langpackPath, _T("rt")); - if (fin) { - size_t len; - while (!feof(fin)) { - fgets(buffer, SIZEOF(buffer), fin); - len = strlen(buffer); - if (buffer[len - 1] == '\n') buffer[len - 1] = '\0'; - strncpy(temp, buffer, SIZEOF(temp)); - _strlwr(temp); - if (SaveInfo(buffer, temp, "language: ", language, SIZEOF(language))) { - if (SaveInfo(buffer, temp, "locale: ", locale, SIZEOF(locale))) { - char* p = strstr(buffer, "; FLID: "); - if (p) { - int ok = 1; - int i; - for (i = 0; ((i < 3) && (ok)); i++) { - p = strrchr(temp, '.'); - if (p) - p[0] = '\0'; - else - ok = 0; - } - p = strrchr(temp, ' '); - if ((ok) && (p)) - _tcsncpy(version, _A2T(&buffer[p - temp + 1]), SIZEOF(version)); - else - _tcsncpy(version, _T(""), SIZEOF(version)); - } } } } - - lpzLangpackInfo = std::tstring(language) + _T(" [") + std::tstring(locale) + _T("]"); - if ( version[0] ) - lpzLangpackInfo += _T(" v. ") + std::tstring(version); - - fclose(fin); - } - else { - int err = GetLastError(); - lpzLangpackInfo = _T(" Could not open file " + std::tstring(data.cFileName)); - } - FindClose(hLangpack); - } - else lpzLangpackInfo = _T("No language pack installed"); - } - - return true; -} - -std::tstring GetPluginTimestamp(FILETIME *fileTime) -{ - SYSTEMTIME sysTime; - FileTimeToSystemTime(fileTime, &sysTime); //convert the file tyme to system time - - //char time[256]; - TCHAR date[256]; //lovely - GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date)); - return date; -} - -bool CVersionInfo::GetPluginLists() -{ - HANDLE hFind; - TCHAR szMirandaPath[MAX_PATH] = { 0 }, szSearchPath[MAX_PATH] = { 0 }; //For search purpose - WIN32_FIND_DATA fd; - TCHAR szMirandaPluginsPath[MAX_PATH] = { 0 }, szPluginPath[MAX_PATH] = { 0 }; //For info reading purpose - BYTE PluginIsEnabled = 0; - HINSTANCE hInstPlugin = NULL; - PLUGININFOEX *(*MirandaPluginInfo)(DWORD); //These two are used to get informations from the plugin. - PLUGININFOEX *pluginInfo = NULL; //Read above. - DWORD mirandaVersion = 0; - BOOL asmCheckOK = FALSE; - DWORD loadError; - // SYSTEMTIME sysTime; //for timestamp - - mirandaVersion=(DWORD)CallService(MS_SYSTEM_GETVERSION,0,0); - { - GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); - TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); - if(str2!=NULL) *str2=0; - } - lpzMirandaPath = szMirandaPath; - - //We got Miranda path, now we'll use it for two different purposes. - //1) finding plugins. - //2) Reading plugin infos - lstrcpyn(szSearchPath,szMirandaPath, MAX_PATH); //We got the path, now we copy it into szSearchPath. We'll use szSearchPath as am auxiliary variable, while szMirandaPath will keep a "fixed" value. - lstrcat(szSearchPath, _T("\\Plugins\\*.dll")); - - lstrcpyn(szMirandaPluginsPath, szMirandaPath, MAX_PATH); - lstrcat(szMirandaPluginsPath, _T("\\Plugins\\")); - - hFind=FindFirstFile(szSearchPath,&fd); - if ( hFind != INVALID_HANDLE_VALUE) { - do { - if (verbose) PUShowMessageT(fd.cFileName, SM_NOTIFY); - if (!ValidExtension(fd.cFileName, _T("dll"))) - continue; //do not report plugins that do not have extension .dll - - hInstPlugin = GetModuleHandle(fd.cFileName); //try to get the handle of the module - - if (hInstPlugin) //if we got it then the dll is loaded (enabled) - PluginIsEnabled = 1; - else { - PluginIsEnabled = 0; - lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\" - lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll" - hInstPlugin = LoadLibrary(szPluginPath); - } - if (!hInstPlugin) { //It wasn't loaded. - loadError = GetLastError(); - int bUnknownError = 1; //assume plugin didn't load because of unknown error - //Some error messages. - //get the dlls the plugin statically links to - if (DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE)) - { - std::tstring linkedModules; - - lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\" - lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll" - if (GetLinkedModulesInfo(szPluginPath, linkedModules)) { - std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); - CPlugin thePlugin(fd.cFileName, _T(""), UUID_NULL, _T(""), 0, time.c_str(), linkedModules.c_str()); - AddPlugin(thePlugin, listUnloadablePlugins); - bUnknownError = 0; //we know why the plugin didn't load - } - } - if (bUnknownError) { //if cause is unknown then report it - std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); - TCHAR buffer[4096]; - TCHAR error[2048]; - //DWORD_PTR arguments[2] = {loadError, 0}; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, loadError, 0, error, SIZEOF(error), NULL); - wsprintf(buffer, _T(" Error %ld - %s"), loadError, error); - CPlugin thePlugin( fd.cFileName, _T(""), UUID_NULL, _T(""), 0, time.c_str(), buffer); - AddPlugin(thePlugin, listUnloadablePlugins); - } - } - else { //It was successfully loaded. - MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfoEx"); - if (!MirandaPluginInfo) - MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfo"); - - if (!MirandaPluginInfo) //There is no function: it's not a valid plugin. Let's move on to the next file. - continue; - - //It's a valid plugin, since we could find MirandaPluginInfo - #if (!defined(WIN64) && !defined(_WIN64)) - asmCheckOK = FALSE; - __asm { - push mirandaVersion - push mirandaVersion - call MirandaPluginInfo - pop eax - pop eax - cmp eax, mirandaVersion - jne a1 - mov asmCheckOK, 0xffffffff - a1: - } - #else - asmCheckOK = TRUE; - #endif - if (asmCheckOK) - pluginInfo = CopyPluginInfo(MirandaPluginInfo(mirandaVersion)); - else { - ZeroMemory(&pluginInfo, sizeof(pluginInfo)); - MessageBox(NULL, fd.cFileName, _T("Invalid plugin"), MB_OK); - } } - - //Let's get the info. - if (MirandaPluginInfo != NULL) {//a valid miranda plugin - if (pluginInfo != NULL) { - //We have loaded the informations into pluginInfo. - std::tstring timedate = GetPluginTimestamp(&fd.ftLastWriteTime); - CPlugin thePlugin(fd.cFileName, _A2T(pluginInfo->shortName), pluginInfo->uuid, (pluginInfo->flags & 1) ? _T("Unicode aware") : _T(""), (DWORD) pluginInfo->version, timedate.c_str(), _T("")); - - if (PluginIsEnabled) - AddPlugin(thePlugin, listActivePlugins); - else { - if ((IsUUIDNull(pluginInfo->uuid)) && (mirandaVersion >= PLUGIN_MAKE_VERSION(0,8,0,9))) { - thePlugin.SetErrorMessage( _T(" Plugin does not have an UUID and will not work with Miranda 0.8.\r\n")); - AddPlugin(thePlugin, listUnloadablePlugins); - } - else AddPlugin(thePlugin, listInactivePlugins); - - FreeLibrary(hInstPlugin); //We don't need it anymore. - } - FreePluginInfo(pluginInfo); - MirandaPluginInfo = NULL; - #ifdef _DEBUG - if (verbose) { - TCHAR szMsg[4096] = { 0 }; - wsprintf(szMsg, _T("Done with: %s"), fd.cFileName); - PUShowMessageT(szMsg, SM_NOTIFY); - } - #endif - } - else { //pluginINFO == NULL - pluginInfo = CopyPluginInfo(MirandaPluginInfo(PLUGIN_MAKE_VERSION(9, 9, 9, 9))); //let's see if the plugin likes this miranda version - char *szShortName = ""; - std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); //get the plugin timestamp; - DWORD version = 0; - if (pluginInfo) { - szShortName = pluginInfo->shortName; - version = pluginInfo->version; - } - - CPlugin thePlugin(fd.cFileName, _A2T(szShortName), (pluginInfo) ? pluginInfo->uuid : UUID_NULL, (((pluginInfo) && (pluginInfo->flags & 1)) ? _T("Unicode aware") : _T("")), version, time.c_str(), _T(" Plugin refuses to load. Miranda version too old.")); - - AddPlugin(thePlugin, listUnloadablePlugins); - if (pluginInfo) - FreePluginInfo(pluginInfo); - } } - } - while (FindNextFile(hFind,&fd)); - FindClose(hFind); - } - return TRUE; -} - -bool CVersionInfo::AddPlugin(CPlugin &aPlugin, std::list &aList) { - std::list::iterator pos = aList.begin(); - bool inserted = FALSE; - - if (aList.begin() == aList.end()) { //It's empty - aList.push_back(aPlugin); - return TRUE; - } - else { //It's not empty - while (pos != aList.end()) { - //It can be either < or >, not equal. - if (aPlugin < (*pos)) { - aList.insert(pos, aPlugin); - return TRUE; - } - - //It's greater: we need to insert it. - pos++; - } } - - if (inserted == FALSE) { - aList.push_back(aPlugin); - return TRUE; - } - return TRUE; -}; - -static char *GetStringFromRVA(DWORD RVA, const LOADED_IMAGE *image) -{ - char *moduleName; - moduleName = (char *) ImageRvaToVa(image->FileHeader, image->MappedAddress, RVA, NULL); - return moduleName; -} - -bool CVersionInfo::GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules) -{ - LOADED_IMAGE image; - ULONG importTableSize; - IMAGE_IMPORT_DESCRIPTOR *importData; - //HMODULE dllModule; - linkedModules = _T(""); - bool result = false; - TCHAR szError[20]; - char* szModuleName = mir_t2a(moduleName); - if (MapAndLoad(szModuleName, NULL, &image, TRUE, TRUE) == FALSE) { - wsprintf(szError, _T("%d"), GetLastError()); - mir_free( szModuleName ); - linkedModules = _T("\r\n"); - return result; - } - mir_free( szModuleName ); - importData = (IMAGE_IMPORT_DESCRIPTOR *) ImageDirectoryEntryToData(image.MappedAddress, FALSE, IMAGE_DIRECTORY_ENTRY_IMPORT, &importTableSize); - if (!importData) { - wsprintf(szError, _T("%d"), GetLastError()); - linkedModules = _T("\r\n"); - } - else { - while (importData->Name) { - char *moduleName; - moduleName = GetStringFromRVA(importData->Name, &image); - if (!DoesDllExist(moduleName)) { - linkedModules.append( _T(" Plugin statically links to missing dll file: ") + std::tstring(_A2T(moduleName)) + _T("\r\n")); - result = true; - } - - importData++; //go to next record - } } - - // FreeLibrary(dllModule); - UnMapAndLoad(&image); //unload the image - return result; -} - -std::tstring CVersionInfo::GetListAsString(std::list &aList, DWORD flags, int beautify) { - std::list::iterator pos = aList.begin(); - std::tstring out = _T(""); -#ifdef _DEBUG - if (verbose) PUShowMessage("CVersionInfo::GetListAsString, begin.", SM_NOTIFY); -#endif - - TCHAR szHeader[32] = {0}; - TCHAR szFooter[32] = {0}; - if ((((flags & VISF_FORUMSTYLE) == VISF_FORUMSTYLE) || beautify) && (DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE))) { - GetStringFromDatabase("BoldBegin", _T("[b]"), szHeader, SIZEOF(szHeader)); - GetStringFromDatabase("BoldEnd", _T("[/b]"), szFooter, SIZEOF(szFooter)); - } - - while (pos != aList.end()) { - out.append(std::tstring((*pos).getInformations(flags, szHeader, szFooter))); - pos++; - } - #ifdef _DEBUG - if (verbose) PUShowMessage("CVersionInfo::GetListAsString, end.", SM_NOTIFY); - #endif - return out; -}; - -void CVersionInfo::BeautifyReport(int beautify, LPCTSTR szBeautifyText, LPCTSTR szNonBeautifyText, std::tstring &out) -{ - if (beautify) - out.append(szBeautifyText); - else - out.append(szNonBeautifyText); -} - -void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautify, std::tstring &out) -{ - if (forumStyle) { //forum style - TCHAR szSize[256], szQuote[256]; - - GetStringFromDatabase("SizeBegin", _T("[size=1]"), szSize, SIZEOF(szSize)); - GetStringFromDatabase("QuoteBegin", _T("[quote]"), szQuote, SIZEOF(szQuote)); - out.append(szQuote); - out.append(szSize); - } - else out = _T(""); - - if (!suppressHeader) { - out.append( _T("Miranda IM - VersionInformation plugin by Hrk, modified by Eblis\r\n")); - if (!forumStyle) { - out.append( _T("Miranda's homepage: http://nightly.miranda.im/\r\n")); //changed homepage - out.append( _T("Miranda tools: http://nightly.miranda.im/\r\n\r\n")); //was missing a / before download - } } - - TCHAR buffer[1024]; //for beautification - GetStringFromDatabase("BeautifyHorizLine", _T("
"), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, _T(""), out); - GetStringFromDatabase("BeautifyBlockStart", _T("
"), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, _T(""), out); - if (!suppressHeader) { - //Time of report: - TCHAR lpzTime[12]; GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("HH':'mm':'ss"), lpzTime, SIZEOF(lpzTime)); - TCHAR lpzDate[32]; GetDateFormat(EnglishLocale, 0, NULL, _T("dd' 'MMMM' 'yyyy"), lpzDate, SIZEOF(lpzDate)); - out.append( _T("Report generated at: ") + std::tstring(lpzTime) + _T(" on ") + std::tstring(lpzDate) + _T("\r\n\r\n")); - } - - //Operating system - out.append(_T("CPU: ") + lpzCPUName + _T(" [") + lpzCPUIdentifier + _T("]")); - if (bDEPEnabled) - out.append(_T(" [DEP enabled]")); - - if (luiProcessors > 1) { - TCHAR noProcs[128]; - wsprintf(noProcs, _T(" [%d CPUs]"), luiProcessors); - out.append(noProcs); - } - out.append( _T("\r\n")); - - //RAM - TCHAR szRAM[64]; wsprintf(szRAM, _T("%d"), luiRAM); - out.append( _T("Installed RAM: ") + std::tstring(szRAM) + _T(" MBytes\r\n")); - - //operating system - out.append( _T("Operating System: ") + lpzOSName + _T(" [version: ") + lpzOSVersion + _T("]\r\n")); - - //shell, IE, administrator - out.append( _T("Shell: ") + lpzShell + _T(", Internet Explorer ") + lpzIEVersion + _T("\r\n")); - out.append( _T("Administrator privileges: ") + lpzAdministratorPrivileges + _T("\r\n")); - - //languages - out.append( _T("OS Languages: ") + lpzOSLanguages + _T("\r\n")); - - //FreeDiskSpace - if (luiFreeDiskSpace) { - TCHAR szDiskSpace[64]; wsprintf(szDiskSpace, _T("%d"), luiFreeDiskSpace); - out.append( _T("Free disk space on Miranda partition: ") + std::tstring(szDiskSpace) + _T(" MBytes\r\n")); - } - - //Miranda - out.append( _T("Miranda path: ") + lpzMirandaPath + _T("\r\n")); - out.append( _T("Miranda IM version: ") + lpzMirandaVersion); - if (bIsWOW64) - out.append( _T(" [running inside WOW64]")); - if (bServiceMode) - out.append( _T(" [service mode]")); - - out.append( _T("\r\nBuild time: ") + lpzBuildTime + _T("\r\n")); - out.append( _T("Profile path: ") + lpzProfilePath + _T("\r\n")); - out.append( _T("Profile size: ") + lpzProfileSize + _T("\r\n")); - out.append( _T("Profile creation date: ") + lpzProfileCreationDate + _T("\r\n")); - out.append( _T("Language pack: ") + lpzLangpackInfo); - out.append((lpzLangpackModifiedDate.size() > 0) ? _T(", modified: ") + lpzLangpackModifiedDate : _T("")); - out.append( _T("\r\n")); - - out.append( _T("Nightly: ") + lpzNightly + _T("\r\n")); - out.append( _T("Unicode core: ") + lpzUnicodeBuild); - - GetStringFromDatabase("BeautifyBlockEnd", _T("
"), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, _T("\r\n"), out); -} - -void CVersionInfo::AddInfoFooter(int suppressFooter, int forumStyle, int beautify, std::tstring &out) -{ - //End of report - TCHAR buffer[1024]; //for beautification purposes - GetStringFromDatabase("BeautifyHorizLine", _T("
"), buffer, SIZEOF(buffer)); - if (!suppressFooter) { - BeautifyReport(beautify, buffer, _T("\r\n"), out); - out.append( _T("\r\nEnd of report.\r\n")); - } - - if (!forumStyle) { - if (!suppressFooter) - out.append( TranslateT("If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!")); - } - else { - TCHAR szSize[256], szQuote[256]; - GetStringFromDatabase("SizeEnd", _T("[/size]"), szSize, SIZEOF(szSize)); - GetStringFromDatabase("QuoteEnd", _T("[/quote]"), szQuote, SIZEOF(szQuote)); - out.append(szSize); - out.append(szQuote); - } -} - -static void AddSectionAndCount(std::list list, LPCTSTR listText, std::tstring &out) -{ - TCHAR tmp[64]; - wsprintf(tmp, _T(" (%u)"), list.size()); - out.append(listText); - out.append( tmp ); - out.append( _T(":")); -} - -std::tstring CVersionInfo::GetInformationsAsString(int bDisableForumStyle) { - //Begin of report - std::tstring out; - int forumStyle = (bDisableForumStyle) ? 0 : DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE); - int showUUID = DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE); - int beautify = DBGetContactSettingByte(NULL, ModuleName, "Beautify", 0) & (!forumStyle); - int suppressHeader = DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE); - - DWORD flags = (forumStyle) | (showUUID << 1); - - AddInfoHeader(suppressHeader, forumStyle, beautify, out); - TCHAR normalPluginsStart[1024]; //for beautification purposes, for normal plugins text (start) - TCHAR normalPluginsEnd[1024]; //for beautification purposes, for normal plugins text (end) - TCHAR horizLine[1024]; //for beautification purposes - TCHAR buffer[1024]; //for beautification purposes - - TCHAR headerHighlightStart[10] = _T(""); - TCHAR headerHighlightEnd[10] = _T(""); - if (forumStyle) { - TCHAR start[128], end[128]; - GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start)); - GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end)); - _tcsncpy(headerHighlightStart, start, SIZEOF(headerHighlightStart)); - _tcsncpy(headerHighlightEnd, end, SIZEOF(headerHighlightEnd)); - } - - //Plugins: list of active (enabled) plugins. - GetStringFromDatabase("BeautifyHorizLine", _T("
"), horizLine, SIZEOF(horizLine)); - BeautifyReport(beautify, horizLine, _T("\r\n"), out); - GetStringFromDatabase("BeautifyActiveHeaderBegin", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightStart, out); - AddSectionAndCount(listActivePlugins, _T("Active Plugins"), out); - GetStringFromDatabase("BeautifyActiveHeaderEnd", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightEnd, out); - out.append( _T("\r\n")); - - GetStringFromDatabase("BeautifyPluginsBegin", _T(""), normalPluginsStart, SIZEOF(normalPluginsStart)); - BeautifyReport(beautify, normalPluginsStart, _T(""), out); - out.append(GetListAsString(listActivePlugins, flags, beautify)); - GetStringFromDatabase("BeautifyPluginsEnd", _T(""), normalPluginsEnd, SIZEOF(normalPluginsEnd)); - BeautifyReport(beautify, normalPluginsEnd, _T(""), out); - //Plugins: list of inactive (disabled) plugins. - if ((!forumStyle) && ((DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE)) || (bServiceMode))) { - BeautifyReport(beautify, horizLine, _T("\r\n"), out); - GetStringFromDatabase("BeautifyInactiveHeaderBegin", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightStart, out); - AddSectionAndCount(listInactivePlugins, _T("Inactive Plugins"), out); - GetStringFromDatabase("BeautifyInactiveHeaderEnd", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightEnd, out); - out.append( _T("\r\n")); - BeautifyReport(beautify, normalPluginsStart, _T(""), out); - out.append(GetListAsString(listInactivePlugins, flags, beautify)); - BeautifyReport(beautify, normalPluginsEnd, _T(""), out); - } - if (listUnloadablePlugins.size() > 0) { - BeautifyReport(beautify, horizLine, _T("\r\n"), out); - GetStringFromDatabase("BeautifyUnloadableHeaderBegin", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightStart, out); - AddSectionAndCount(listUnloadablePlugins, _T("Unloadable Plugins"), out); - GetStringFromDatabase("BeautifyUnloadableHeaderEnd", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightEnd, out); - out.append( _T("\r\n")); - BeautifyReport(beautify, normalPluginsStart, _T(""), out); - out.append(GetListAsString(listUnloadablePlugins, flags, beautify)); - BeautifyReport(beautify, normalPluginsEnd, _T(""), out); - } - AddInfoFooter(suppressHeader, forumStyle, beautify, out); - return out; -} - -//========== Print functions ===== - -void CVersionInfo::PrintInformationsToFile(const TCHAR *info) -{ - TCHAR buffer[MAX_PATH], outputFileName[MAX_PATH]; - if (bFoldersAvailable) { - FoldersGetCustomPathT(hOutputLocation, buffer, SIZEOF(buffer), _T("%miranda_path%")); - _tcscat(buffer, _T("\\VersionInfo.txt")); - } - else GetStringFromDatabase("OutputFile", _T("VersionInfo.txt"), buffer, SIZEOF(buffer)); - - RelativePathToAbsolute(buffer, outputFileName, SIZEOF(buffer)); - - FILE *fp = _tfopen(outputFileName, _T("wb")); - if ( fp != NULL ) { - char* utf = mir_utf8encodeT( info ); - fputs( "\xEF\xBB\xBF", fp); - fputs( utf, fp ); - fclose(fp); - - TCHAR mex[512]; - mir_sntprintf(mex, SIZEOF(mex), TranslateT("Information successfully written to file: \"%s\"."), outputFileName); - Log(mex); - } - else { - TCHAR mex[512]; - mir_sntprintf(mex, SIZEOF(mex), TranslateT("Error during the creation of file \"%s\". Disk may be full or write protected."), outputFileName); - Log(mex); - } -} - -void CVersionInfo::PrintInformationsToFile() -{ - PrintInformationsToFile( GetInformationsAsString().c_str()); -} - -void CVersionInfo::PrintInformationsToMessageBox() -{ - MessageBox(NULL, GetInformationsAsString().c_str(), _T("VersionInfo"), MB_OK); -} - -void CVersionInfo::PrintInformationsToOutputDebugString() -{ - OutputDebugString( GetInformationsAsString().c_str()); -} - - -void CVersionInfo::PrintInformationsToDialogBox() -{ - HWND DialogBox = CreateDialogParam(hInst, - MAKEINTRESOURCE(IDD_DIALOGINFO), - NULL, DialogBoxProc, (LPARAM) this); - - SetDlgItemText(DialogBox, IDC_TEXT, GetInformationsAsString().c_str()); -} - -void CVersionInfo::PrintInformationsToClipboard(bool showLog) -{ - if (GetOpenClipboardWindow()) { - Log( TranslateT("The clipboard is not available, retry.")); - return; - } - - OpenClipboard(NULL); - //Ok, let's begin, then. - EmptyClipboard(); - //Storage data we'll use. - LPTSTR lptstrCopy; - std::tstring aux = GetInformationsAsString(); - size_t length = aux.length() + 1; - HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, length*sizeof(TCHAR) + 5); - //Lock memory, copy it, release it. - lptstrCopy = (LPTSTR)GlobalLock(hData); - lstrcpy(lptstrCopy, aux.c_str()); - lptstrCopy[length] = '\0'; - GlobalUnlock(hData); - //Now set the clipboard data. - - SetClipboardData(CF_UNICODETEXT, hData); - - //Remove the lock on the clipboard. - CloseClipboard(); - if (showLog) - Log( TranslateT("Information successfully copied into clipboard.")); -} diff --git a/plugins/VersionInfo/CVersionInfo.h b/plugins/VersionInfo/CVersionInfo.h deleted file mode 100644 index eb55b808fc..0000000000 --- a/plugins/VersionInfo/CVersionInfo.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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 CVERSIONINFO_H -#define CVERSIONINFO_H - -//#define STRICT -#define WIN32_LEAN_AND_MEAN -//#include "AggressiveOptimize.h" - -#define _CRT_SECURE_NO_DEPRECATE - -#ifndef PF_NX_ENABLED - #define PF_NX_ENABLED 12 -#endif - -#include -#include -//using namespace std; - -#include "CPlugin.h" - -class CVersionInfo -{ - private: - //Informations related to Miranda: main informations. - std::tstring lpzMirandaVersion; - std::tstring lpzMirandaPath; - std::tstring lpzProfilePath; - std::tstring lpzProfileSize; - std::tstring lpzProfileCreationDate; - std::tstring lpzNightly; - std::tstring lpzUnicodeBuild; - std::tstring lpzCPUName; - std::tstring lpzCPUIdentifier; - std::tstring lpzBuildTime; - std::tstring lpzShell; - std::tstring lpzIEVersion; - std::tstring lpzAdministratorPrivileges; - std::tstring lpzOSLanguages; - std::tstring lpzLangpackInfo; - std::tstring lpzLangpackModifiedDate; - //Informations related to plugins - std::list listActivePlugins; - std::list listInactivePlugins; - std::list listUnloadablePlugins; - //OS and hardware informations. - std::tstring lpzOSVersion; - std::tstring lpzOSName; - unsigned int luiProcessors; - unsigned int luiRAM; - unsigned int luiFreeDiskSpace; - int bDEPEnabled; - BOOL bIsWOW64; - //Additional Miranda informations. - unsigned int luiContacts; - unsigned int luiEvents; - unsigned int luiUnreadEvents; - unsigned int luiDBSize; - bool bExpertSettingsOn; - //Configuration - - bool GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules); - - public: - //Constructor/Destructor - CVersionInfo(); - ~CVersionInfo(); - void Initialize(); - //Miranda informations - bool GetMirandaVersion(); - bool GetProfileSettings(); - bool GetOSLanguages(); - bool GetLangpackInfo(); - bool GetPluginLists(); - bool GetEventCount(); //TODO - //OSInformations - bool GetOSVersion(); - bool GetHWSettings(); - //Plugins - bool AddPlugin(CPlugin&, std::list&); - //Prints - - void PrintInformationsToFile(); - void PrintInformationsToFile(const TCHAR *info); - void PrintInformationsToDialogBox(); - void PrintInformationsToMessageBox(); - void PrintInformationsToOutputDebugString(); - void PrintInformationsToClipboard(bool); - - std::tstring GetListAsString(std::list&, DWORD flags, int beautify); - std::tstring GetInformationsAsString(int bDisableForumStyle = 0); - void BeautifyReport(int, LPCTSTR, LPCTSTR, std::tstring &); - void AddInfoHeader(int, int, int, std::tstring &); - void AddInfoFooter(int, int, int, std::tstring &); -}; - -#endif \ No newline at end of file diff --git a/plugins/VersionInfo/VersionInfo.html b/plugins/VersionInfo/VersionInfo.html deleted file mode 100644 index a955874979..0000000000 --- a/plugins/VersionInfo/VersionInfo.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -
-

Version Information Test Page

- -

Version Information version 1.4.3.2

-

VersionInfo.zip

-
- - diff --git a/plugins/VersionInfo/VersionInfo.ico b/plugins/VersionInfo/VersionInfo.ico deleted file mode 100644 index b026d584c2..0000000000 Binary files a/plugins/VersionInfo/VersionInfo.ico and /dev/null differ diff --git a/plugins/VersionInfo/VersionInfo_10.vcxproj b/plugins/VersionInfo/VersionInfo_10.vcxproj index 9481a8a3dd..2f758a10f8 100644 --- a/plugins/VersionInfo/VersionInfo_10.vcxproj +++ b/plugins/VersionInfo/VersionInfo_10.vcxproj @@ -73,12 +73,11 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 EditAndContinue - 4996;%(DisableSpecificWarnings) Use common.h @@ -102,12 +101,11 @@ OnlyExplicitInline Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true true Use Level3 - 4996;%(DisableSpecificWarnings) common.h @@ -134,7 +132,7 @@ Disabled Use common.h - WIN64;_DEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) Level3 @@ -159,7 +157,7 @@ Size Use common.h - WIN64;NDEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) Level3 true true @@ -181,28 +179,25 @@ - - - - - + + + + + Create - - + + - - - - - + + + + + - - - - + diff --git a/plugins/VersionInfo/VersionInfo_10.vcxproj.filters b/plugins/VersionInfo/VersionInfo_10.vcxproj.filters index e0c4f5db2e..b5f5a05d9b 100644 --- a/plugins/VersionInfo/VersionInfo_10.vcxproj.filters +++ b/plugins/VersionInfo/VersionInfo_10.vcxproj.filters @@ -15,53 +15,48 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Header Files - + Header Files - + Header Files - + Header Files - + Header Files - + Resource Files - - - Resource Files - - \ No newline at end of file diff --git a/plugins/VersionInfo/common.h b/plugins/VersionInfo/common.h deleted file mode 100644 index 3182abc660..0000000000 --- a/plugins/VersionInfo/common.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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_VERSIONINFO_COMMON_H -#define M_VERSIONINFO_COMMON_H - -#pragma warning(disable:4005) -#define _CRT_SECURE_NO_DEPRECATE -#pragma warning(default:4005) - -#define VIPF_NONE 0x0000 -#define VIPF_UNCERTAIN 0x0010 - -#define VISF_FORUMSTYLE 0x0001 -#define VISF_SHOWUUID 0x0002 -#define VISF_SHOWFLAGS 0x0004 - -#include -#include - -#include -#include -#include -#include - -#include -//using namespace std; - -#include "version.h" - -#include "m_versioninfo.h" -#include "hooked_events.h" -#include "services.h" -#include "dlgHandlers.h" - -#include "newpluginapi.h" -#include "m_system.h" -#include "m_langpack.h" -#include "m_database.h" -#include "m_skin.h" -#include "m_clist.h" -#include "m_options.h" -#include "m_popup.h" - -#include "m_utils.h" -#include "m_folders.h" -#include "win2k.h" - -#include "utils.h" - -#ifndef MS_DB_GETPROFILEPATH_BASIC //db3xSA -#define MS_DB_GETPROFILEPATH_BASIC "DB/GetProfilePathBasic" -#endif - -//main.cpp -extern HINSTANCE hInst; - -//main.cpp -extern HICON hiVIIcon; - -//main.cpp -extern DWORD EnglishLocale; - -//for folders support -extern BOOL bFoldersAvailable; -extern HANDLE hOutputLocation; - -//services.cpp -extern int bServiceMode; - -//main.cpp -extern char ModuleName[]; -extern BOOL verbose; - -#define DEFAULT_UPLOAD_PORT 51234 - -const MUUID UUID_NULL = {0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}; - -#endif \ No newline at end of file diff --git a/plugins/VersionInfo/dlgHandlers.cpp b/plugins/VersionInfo/dlgHandlers.cpp deleted file mode 100644 index a1a81e6a51..0000000000 --- a/plugins/VersionInfo/dlgHandlers.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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 "common.h" -#include "dlgHandlers.h" - -const char *szQuoteStrings[] = {"[quote] | [/quote]", "[code] | [/code]", ""}; -const char *szSizeStrings[] = {"[size=1] | [/size]", "[size=1px] | [/size]", "[size=12] | [/size]", "[size=80] | [/size]", ""}; -const char *szBoldStrings[] = {"[b] | [/b]", "[u] | [/u]", "[b][u] | [/u][/b]", " | ", " | ", " | "}; -const int nQuoteCount = SIZEOF(szQuoteStrings); //get the number of quote strings -const int nSizeCount = SIZEOF(szSizeStrings); //get the number of size strings -const int nBoldCount = SIZEOF(szBoldStrings); //get the number of bold strings - -#define MAX_TEXT 4096*4 - -int AddInfoToComboboxes(HWND hWnd, int nQuotesComboBox, int nSizesComboBox, int nBoldComboBox) -{ - int i; - for (i = 0; i < nQuoteCount; i++) - SendDlgItemMessageA(hWnd, nQuotesComboBox, CB_ADDSTRING, 0, (LPARAM) szQuoteStrings[i]); - - for (i = 0; i < nSizeCount; i++) - SendDlgItemMessageA(hWnd, nSizesComboBox, CB_ADDSTRING, 0, (LPARAM) szSizeStrings[i]); - - for (i = 0; i < nBoldCount; i++) - SendDlgItemMessageA(hWnd, nBoldComboBox, CB_ADDSTRING, 0, (LPARAM) szBoldStrings[i]); - - return 0; -} - -void EnableAskComboboxes(HWND hWnd, int bEnable) -{ - EnableWindow(GetDlgItem(hWnd, IDC_ASK_BOLDCOMBOBOX), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_ASK_QUOTECOMBOBOX), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_ASK_SIZECOMBOBOX), bEnable); -} - -INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - const int MAX_SIZE = 128; - static int oldFSFValue; - static TCHAR oldQuoteBegin[MAX_SIZE], oldQuoteEnd[MAX_SIZE]; - static TCHAR oldSizeBegin[MAX_SIZE], oldSizeEnd[MAX_SIZE]; - static TCHAR oldBoldBegin[MAX_SIZE], oldBoldEnd[MAX_SIZE]; - - switch (msg) { - case WM_INITDIALOG: - SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon); - - TranslateDialogDefault(hWnd); - - oldFSFValue = DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", 1); - - AddInfoToComboboxes(hWnd, IDC_ASK_QUOTECOMBOBOX, IDC_ASK_SIZECOMBOBOX, IDC_ASK_BOLDCOMBOBOX); - - CheckDlgButton(hWnd, IDC_ASK_TODIALOGBOX, BST_CHECKED); - - CheckDlgButton(hWnd, IDC_ASK_FORUMSTYLE, (oldFSFValue) ? BST_CHECKED : BST_UNCHECKED); - EnableAskComboboxes(hWnd, oldFSFValue); - { - TCHAR buffer[1024]; - GetStringFromDatabase("QuoteBegin", _T("[quote]"), oldQuoteBegin, MAX_SIZE); - GetStringFromDatabase("QuoteEnd", _T("[/quote]"), oldQuoteEnd, MAX_SIZE); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldQuoteBegin, oldQuoteEnd); - SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - - GetStringFromDatabase("SizeBegin", _T("[size=1]"), oldSizeBegin, MAX_SIZE); - GetStringFromDatabase("SizeEnd", _T("[/size]"), oldSizeEnd, MAX_SIZE); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldSizeBegin, oldSizeEnd); - SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - - GetStringFromDatabase("BoldBegin", _T("[b]"), oldBoldBegin, MAX_SIZE); - GetStringFromDatabase("BoldEnd", _T("[/b]"), oldBoldEnd, MAX_SIZE); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldBoldBegin, oldBoldEnd); - SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - } - - return TRUE; - - case WM_CLOSE: - DestroyWindow(hWnd); - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_ASK_FORUMSTYLE: - EnableAskComboboxes(hWnd, IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE)); - break; - - case IDC_ASK_CANCEL: - DestroyWindow(hWnd); - break; - - case IDC_ASK_OK: - TCHAR quoteBegin[MAX_SIZE], quoteEnd[MAX_SIZE]; - TCHAR sizeBegin[MAX_SIZE], sizeEnd[MAX_SIZE]; - TCHAR boldBegin[MAX_SIZE], boldEnd[MAX_SIZE]; - TCHAR buffer[1024]; - - SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, quoteBegin, quoteEnd); - SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, sizeBegin, sizeEnd); - SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, boldBegin, boldEnd); - - int newFSFValue = IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE); - if (newFSFValue != oldFSFValue) - DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", newFSFValue); //temporary store the new value - - if (newFSFValue) { - DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", quoteBegin); - DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", quoteEnd); - - DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", sizeBegin); - DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", sizeEnd); - - DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", boldBegin); - DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", boldEnd); - } - - int debugTo = TO_DIALOGBOX; //just to be safe - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOFILE)) - debugTo = TO_FILE; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOMESSAGEBOX)) - debugTo = TO_MESSAGEBOX; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TODIALOGBOX)) - debugTo = TO_DIALOGBOX; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOOUTPUTDEBUGSTRING)) - debugTo = TO_DEBUGSTRING; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOCLIPBOARD)) - debugTo = TO_CLIPBOARD; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOUPLOAD)) - debugTo = TO_UPLOAD; - - DoDebugTo(debugTo); - - if (newFSFValue != oldFSFValue) - DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", oldFSFValue); - - if (newFSFValue) { - DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", oldQuoteBegin); - DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", oldQuoteEnd); - - DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", oldSizeBegin); - DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", oldSizeEnd); - - DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", oldBoldBegin); - DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", oldBoldEnd); - } - - DestroyWindow(hWnd); - break; - } - break; - } - return 0; -} - -int DoDebugTo(int debugTo) -{ - HWND parent = NULL; - HWND askDialog; - CVersionInfo myInfo;// = CVersionInfo(); - if (verbose) PUShowMessage("I am going to read the information.", SM_NOTIFY); - if (debugTo != TO_ASK) - myInfo.Initialize(); - - if (verbose) PUShowMessage("I have read the information, I will now print them.", SM_NOTIFY); - - switch(debugTo) { - case TO_ASK: - askDialog = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ASKDIALOG), parent, AskDlgProc); - ShowWindow(askDialog, SW_SHOW); - break; - - case TO_FILE: - myInfo.PrintInformationsToFile(); - break; - - case TO_MESSAGEBOX: - myInfo.PrintInformationsToMessageBox(); - break; - - case TO_DIALOGBOX: - myInfo.PrintInformationsToDialogBox(); - break; - - case TO_DEBUGSTRING: - myInfo.PrintInformationsToOutputDebugString(); - break; - - case TO_CLIPBOARD: - myInfo.PrintInformationsToClipboard(true); - break; - - default: - myInfo.PrintInformationsToFile(); - break; - } - - if ((debugTo != TO_CLIPBOARD) && (DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE))) - myInfo.PrintInformationsToClipboard(false); - - if ((bServiceMode) && (debugTo != TO_DIALOGBOX) && (debugTo != TO_ASK)) //close miranda if in service mode and no dialog was shown - PostQuitMessage(0); - - return 0; -} - -void EnableUploadSettings(HWND hWnd, int bEnable) -{ - EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PORT), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), bEnable); -} - -INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static int bOptionsInitializing = 0; - switch(msg) { - case WM_INITDIALOG: - bOptionsInitializing = 1; - TranslateDialogDefault(hWnd); - AddInfoToComboboxes(hWnd, IDC_QUOTECOMBOBOX, IDC_SIZECOMBOBOX, IDC_BOLDCOMBOBOX); - - CheckDlgButton(hWnd, IDC_FORUMSTYLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_DISABLEDTOO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_SHOWUUIDS, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_SHOWINSTALLEDLANGUAGES, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_SUPPRESSHEADER, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE) ? BST_CHECKED : BST_UNCHECKED); - - CheckDlgButton(hWnd, IDC_SHOWINTASKBAR, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_CLIPBOARDALSO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_BOLDVERSION, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_CHECKUNLOADABLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE) ? BST_CHECKED : BST_UNCHECKED); - SetFocus(GetDlgItem(hWnd, IDC_FORUMSTYLE)); - { - DBVARIANT dbv = { 0 }; - bOptionsInitializing = 1; - TCHAR buffer[1024]; - TCHAR notFound[1024]; - - if (DBGetContactSettingTString(NULL, ModuleName, "OutputFile", &dbv) == 0) - RelativePathToAbsolute(dbv.ptszVal, notFound, SIZEOF(notFound)); - else - RelativePathToAbsolute( _T("VersionInfo.txt"), notFound, SIZEOF(notFound)); - - if (bFoldersAvailable) - _tcscpy(buffer, TranslateT("Customize using folders plugin")); - else - _tcsncpy(buffer, notFound, SIZEOF(notFound)); - - SetDlgItemText(hWnd, IDC_FILENAME, buffer); - - TCHAR start[256], end[256]; - GetStringFromDatabase("QuoteBegin", _T("[quote]"), start, SIZEOF(start)); - GetStringFromDatabase("QuoteEnd", _T("[/quote]"), end, SIZEOF(end)); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); - SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - - GetStringFromDatabase("SizeBegin", _T("[size=1]"), start, SIZEOF(start)); - GetStringFromDatabase("SizeEnd", _T("[/size]"), end, SIZEOF(end)); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); - SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - - GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start)); - GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end)); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); - SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - //to add stuff - - //upload server settings - GetStringFromDatabase("UploadServer", _T("vi.cass.cz"), buffer, SIZEOF(buffer)); - SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), buffer); - - int port = DBGetContactSettingWord(NULL, ModuleName, "UploadPort", DEFAULT_UPLOAD_PORT); - _itot(port, buffer, 10); - SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PORT), buffer); - - GetStringFromDatabase("UploadUser", _T(""), buffer, SIZEOF(buffer)); - SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), buffer); - - GetStringFromDatabase("UploadPassword", _T(""), buffer, SIZEOF(buffer)); - CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(buffer), (LPARAM) buffer); - SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), buffer); - } - - switch(DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX)) { - case TO_FILE: - CheckDlgButton(hWnd, IDC_TOFILE, BST_CHECKED); - break; - - case TO_MESSAGEBOX: - CheckDlgButton(hWnd, IDC_TOMESSAGEBOX, BST_CHECKED); - break; - - case TO_DIALOGBOX: - CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED); - break; - - case TO_DEBUGSTRING: - CheckDlgButton(hWnd, IDC_TODEBUGSTRING, BST_CHECKED); - break; - - case TO_CLIPBOARD: - CheckDlgButton(hWnd, IDC_TOCLIPBOARD, BST_CHECKED); - break; - - case TO_UPLOAD: - CheckDlgButton(hWnd, IDC_TOUPLOAD, BST_CHECKED); - break; - - case TO_ASK: - CheckDlgButton(hWnd, IDC_ASKEVERYTIME, BST_CHECKED); - break; - - default: - CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED); - break; - } - - EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE);//both forum style and bold version checked - EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box - EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins - EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard - EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); - EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE); - { - OSVERSIONINFO osvi = { 0 }; - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionEx(&osvi); - - if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) - EnableWindow(GetDlgItem(hWnd, IDC_CHECKUNLOADABLE), FALSE); - } - - CheckDlgButton(hWnd, IDC_DEBUG, (BOOL) verbose == TRUE ? BST_CHECKED : BST_UNCHECKED); - - SetFocus(GetDlgItem(hWnd, IDC_GETINFONOW)); - - bOptionsInitializing = 0; - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDC_ASKEVERYTIME: - case IDC_TOFILE: - case IDC_TOMESSAGEBOX: - case IDC_TODIALOGBOX: - case IDC_TODEBUGSTRING: - case IDC_TOCLIPBOARD: - case IDC_TOUPLOAD: - case IDC_FORUMSTYLE: - case IDC_BOLDVERSION: - EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE); //both forum style and bold version checked - EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); - EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box - EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins - EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard - EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE); - - case IDC_SHOWUUIDS: - if (IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) && MessageBox(hWnd, - TranslateT("Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it."), - TranslateT("Show plugin UUIDs ?"), MB_YESNO | MB_ICONWARNING) == IDNO) - { - CheckDlgButton(hWnd, IDC_SHOWUUIDS, FALSE); - - break; - }//else fallthrough - case IDC_DISABLEDTOO: - case IDC_SHOWINTASKBAR: - case IDC_CLIPBOARDALSO: - case IDC_CHECKUNLOADABLE: - case IDC_SUPPRESSHEADER: - case IDC_SHOWINSTALLEDLANGUAGES: - EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE); - - case IDC_QUOTECOMBOBOX: - case IDC_SIZECOMBOBOX: - case IDC_BOLDCOMBOBOX: - if (!bOptionsInitializing) - SendMessage(GetParent(hWnd), PSM_CHANGED,0,0); - break; - - case IDC_FILENAME: - case IDC_UPLOAD_USERNAME: - case IDC_UPLOAD_PASSWORD: - case IDC_UPLOAD_PORT: - case IDC_UPLOAD_SERVER: - if ( HIWORD(wParam) == EN_CHANGE && !bOptionsInitializing) { - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE); - } - break; - - case IDC_GETINFONOW: - //Call the plugin menu command routine. - PluginMenuCommand(0,0); - break; - - case IDC_DEBUG: - verbose = !verbose; - break; - } - - break; - - case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: - { - TCHAR buffer[1024]; - TCHAR start[256], end[256]; - SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, start, end); - DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", start); - DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", end); - SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, start, end); - DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", start); - DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", end); - SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, start, end); - DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", start); - DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", end); - } - - DBWriteContactSettingByte(NULL, ModuleName, "CheckForDependencies", IsDlgButtonChecked(hWnd, IDC_CHECKUNLOADABLE) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "BoldVersionNumber", IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "ClipboardAlways", IsDlgButtonChecked(hWnd, IDC_CLIPBOARDALSO) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "SuppressHeader", IsDlgButtonChecked(hWnd, IDC_SUPPRESSHEADER) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "ShowUUIDs", IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", IsDlgButtonChecked(hWnd, IDC_SHOWINSTALLEDLANGUAGES) ? TRUE : FALSE); - - if (!bFoldersAvailable) { - TCHAR filePath[MAX_PATH], fileName[MAX_PATH]; - GetDlgItemText(hWnd, IDC_FILENAME, fileName, MAX_PATH); - AbsolutePathToRelative(fileName, filePath, SIZEOF(filePath)); - - DBWriteContactSettingTString(NULL, ModuleName, "OutputFile", filePath); //store relative path - } - DBWriteContactSettingByte(NULL, ModuleName, "ShowInTaskbar", IsDlgButtonChecked(hWnd, IDC_SHOWINTASKBAR) ? TRUE : FALSE); - //Debug to: - if (IsDlgButtonChecked(hWnd, IDC_TOFILE)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_FILE); - else if (IsDlgButtonChecked(hWnd, IDC_TOMESSAGEBOX)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_MESSAGEBOX); - else if (IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX); - else if (IsDlgButtonChecked(hWnd, IDC_TODEBUGSTRING)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DEBUGSTRING); - else if (IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_CLIPBOARD); - else if (IsDlgButtonChecked(hWnd, IDC_TOUPLOAD)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_UPLOAD); - else if (IsDlgButtonChecked(hWnd, IDC_ASKEVERYTIME)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_ASK); - - EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), TRUE); - //Disabled plugins too? - DBWriteContactSettingByte(NULL, ModuleName, "ShowInactive", IsDlgButtonChecked(hWnd, IDC_DISABLEDTOO)?TRUE:FALSE); - - GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); - } } - - break; - } - return 0; -} - -INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static CVersionInfo *myInfo = NULL; - switch(msg) { - case WM_INITDIALOG: - SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon); - - myInfo = (CVersionInfo *) lParam; - if (DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE)) { - DWORD ws; - ws = GetWindowLongPtr(hWnd, GWL_EXSTYLE); - SetWindowLongPtr(hWnd, GWL_EXSTYLE, ws | WS_EX_APPWINDOW); - //SetWindowLongPtr(hWnd, GWL_STYLE, ws | WS_DLGFRAME | WS_POPUPWINDOW); - } - - TranslateDialogDefault(hWnd); - { - DBVARIANT dbv = { 0 }; - LOGFONT lf = { 0 }; - - dbv.type = DBVT_BLOB; - if (DBGetContactSetting(NULL, "OptionFont", "Font", &dbv) == 0) - lf=*(LOGFONT*)dbv.pbVal; - else { - HFONT hFont = (HFONT)SendDlgItemMessage(hWnd,IDC_CLOSE,WM_GETFONT,0,0); - GetObject(hFont,sizeof(lf),&lf); - } - SendDlgItemMessage(hWnd,IDC_TEXT,WM_SETFONT,(WPARAM)CreateFontIndirect(&lf),0); - } - - return TRUE; - - case WM_CLOSE: - DestroyWindow(hWnd); - break; - - case WM_COMMAND: { - switch(LOWORD(wParam)) { - case IDC_CLOSE: - DestroyWindow(hWnd); - break; - - case IDC_COPYTEXT: - SetLastError(0); - if (GetOpenClipboardWindow()) - Log( TranslateT("The clipboard is not available, retry.")); - else { - OpenClipboard(hWnd); - //Ok, let's begin, then. - EmptyClipboard(); - //Storage data we'll use. - TCHAR text[MAX_TEXT]; - LPTSTR lptstrCopy; - GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT); - int length = lstrlen(text) + 1; - HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, (length + 5)*sizeof( TCHAR )); - //Lock memory, copy it, release it. - lptstrCopy = (LPTSTR)GlobalLock(hData); - lstrcpyn(lptstrCopy, text, length); - lptstrCopy[length] = '\0'; - GlobalUnlock(hData); - //Now set the clipboard data. - - SetClipboardData(CF_UNICODETEXT, hData); - - //Remove the lock on the clipboard. - CloseClipboard(); - } - - break; - - case IDC_SAVETOFILE: - TCHAR text[MAX_TEXT]; - GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT); - myInfo->PrintInformationsToFile(text); - break; - } - - break; - } - case WM_DESTROY: - DeleteObject((HFONT)SendDlgItemMessage(hWnd,IDC_TEXT,WM_GETFONT,0,0)); - myInfo = NULL; - if (bServiceMode) //close miranda if in service mode - PostQuitMessage(0); - - break; - } - return 0; -} diff --git a/plugins/VersionInfo/dlgHandlers.h b/plugins/VersionInfo/dlgHandlers.h deleted file mode 100644 index bab1876ea2..0000000000 --- a/plugins/VersionInfo/dlgHandlers.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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_VERSIONINFO_DLGHEADERS_H -#define M_VERSIONINFO_DLGHEADERS_H - -#include "resource.h" -#include "CVersionInfo.h" - -#define TO_ASK 0 -#define TO_FILE 1 -#define TO_MESSAGEBOX 2 -#define TO_DIALOGBOX 3 -#define TO_DEBUGSTRING 4 -#define TO_CLIPBOARD 5 -#define TO_UPLOAD 6 - -extern INT_PTR PluginMenuCommand(WPARAM, LPARAM); -extern INT_PTR OptionsInitialise(WPARAM, LPARAM); - - -int DoDebugTo(int debugTo); -INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -#endif \ No newline at end of file diff --git a/plugins/VersionInfo/docs/VersionInfo.html b/plugins/VersionInfo/docs/VersionInfo.html new file mode 100644 index 0000000000..a955874979 --- /dev/null +++ b/plugins/VersionInfo/docs/VersionInfo.html @@ -0,0 +1,11 @@ + + + +
+

Version Information Test Page

+ +

Version Information version 1.4.3.2

+

VersionInfo.zip

+
+ + diff --git a/plugins/VersionInfo/docs/svc_vi-translation.txt b/plugins/VersionInfo/docs/svc_vi-translation.txt new file mode 100644 index 0000000000..719f0beb2c --- /dev/null +++ b/plugins/VersionInfo/docs/svc_vi-translation.txt @@ -0,0 +1,56 @@ +; Common strings that belong to many files +;[The clipboard is not available, retry.] +;[Version Information] + +; ../../plugins/Svc_vi/CVersionInfo.cpp +;[Error during the creation of file \"%s\". Disk may be full or write protected.] +;[If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!] +;[Information successfully copied into clipboard.] +;[Information successfully written to file: \"%s\".] + +; ../../plugins/Svc_vi/dlgHandlers.cpp +;[Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it.] +;[Customize using folders plugin] +;[Show plugin UUIDs ?] + +; ../../plugins/Svc_vi/hooked_events.cpp +;[Services] + +; ../../plugins/Svc_vi/main.cpp +;[Please rename the plugin '%s' to 'svc_vi.dll' to enable service mode functionality.] + +; ../../plugins/Svc_vi/resource.rc +;[&Copy text] +;[&Save to file] +;[Aditional options:] +;[Also copy info to clipboard] +;[Ask every time] +;[Attempt to find unloadable plugins (doesn't work on Windows 98)] +;[Cancel] +;[Clipboard] +;[Close] +;[DialogBox] +;[Do it now] +;[Enable debug messages] +;[Forum style formatting] +;[Highlight version number using] +;[MessageBox()] +;[Miranda Version Information] +;[OK] +;[Output to:] +;[OutputDebugString()] +;[Password] +;[Select output:] +;[Show disabled plugins too] +;[Show installed languages] +;[Show plugin UUIDs] +;[Show window in taskbar] +;[Suppress header information] +;[Text file] +;[Upload] +;[Upload site settings] +;[Upload to site] +;[Username] + +; ../../plugins/Svc_vi/utils.cpp +;[Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d] diff --git a/plugins/VersionInfo/hooked_events.cpp b/plugins/VersionInfo/hooked_events.cpp deleted file mode 100644 index 77d72e6a97..0000000000 --- a/plugins/VersionInfo/hooked_events.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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 "common.h" -#include "hooked_events.h" - -HANDLE hModulesLoaded; -HANDLE hOptionsInitialize; - -#define HOST "http://eblis.tla.ro/projects" - -#define VERSIONINFO_VERSION_URL HOST "/miranda/VersionInfo/updater/VersionInfo.html" -#define VERSIONINFO_UPDATE_URL HOST "/miranda/VersionInfo/updater/VersionInfo.zip" -#define VERSIONINFO_VERSION_PREFIX "Version Information version " - -int HookEvents() -{ - hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise); - //hPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); - - return 0; -} - -int UnhookEvents() -{ - UnhookEvent(hModulesLoaded); - UnhookEvent(hOptionsInitialize); - - return 0; -} - -int OnModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - - bFoldersAvailable = ServiceExists(MS_FOLDERS_REGISTER_PATH); - hOutputLocation = FoldersRegisterCustomPathT("VersionInfo", "Output folder", _T("%miranda_path%")); - - GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); - return 0; -} - -static UINT uiExpertOnlyControls[] = { IDC_SHOWUUIDS, IDC_SHOWINSTALLEDLANGUAGES }; - -int OnOptionsInitialise(WPARAM wParam, LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_VERSIONINFO); - odp.pszTitle = LPGEN("Version Information"); - odp.pszGroup = LPGEN("Services"); - odp.groupPosition = 910000000; - odp.flags = ODPF_BOLDGROUPS; - odp.pfnDlgProc = DlgProcOpts; - odp.expertOnlyControls = uiExpertOnlyControls; - odp.nExpertOnlyControls = SIZEOF(uiExpertOnlyControls); - - Options_AddPage(wParam, &odp); - - return 0; -} \ No newline at end of file diff --git a/plugins/VersionInfo/hooked_events.h b/plugins/VersionInfo/hooked_events.h deleted file mode 100644 index b75b5e59a8..0000000000 --- a/plugins/VersionInfo/hooked_events.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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_VERSIONINFO_HOOKED_EVENTS_H -#define M_VERSIONINFO_HOOKED_EVENTS_H - -extern HANDLE hModulesLoaded; -extern HANDLE hOptionsInitialise; - -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/VersionInfo/main.cpp b/plugins/VersionInfo/main.cpp deleted file mode 100644 index 53c75be86f..0000000000 --- a/plugins/VersionInfo/main.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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. -*/ - -#define STRICT -#define WIN32_LEAN_AND_MEAN - -#define _CRT_SECURE_NO_DEPRECATE - -#include "common.h" - -#include "CVersionInfo.h" - -HINSTANCE hInst; - -int hLangpack; - -HICON hiVIIcon; - -DWORD EnglishLocale; - -BOOL bFoldersAvailable = FALSE; -HANDLE hOutputLocation = NULL; //for folders plugin - -void * (* MirandaMalloc)(size_t); -void * (* MirandaRealloc)(void *, size_t); -void (* MirandaFree)(void *); - -char ModuleName[] = "VersionInfo"; - -#ifdef _DEBUG - BOOL verbose = FALSE;//TRUE; -#else - BOOL verbose = FALSE; -#endif - -PLUGININFOEX pluginInfo={ - sizeof(PLUGININFOEX), - __PLUGIN_DISPLAY_NAME, - VERSION, - __DESC, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // {2f174488-489c-4fe1-940d-596cf0f35e65} - {0x2f174488, 0x489c, 0x4fe1, {0x94, 0x0d, 0x59, 0x6c, 0xf0, 0xf3, 0x5e, 0x65}} -}; - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_VERSIONINFO, MIID_SERVICEMODE, MIID_LAST}; - -bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) -{ - hInst=hinstDLL; - if (fdwReason == DLL_PROCESS_ATTACH) DisableThreadLibraryCalls(hinstDLL); - EnglishLocale = MAKELCID(MAKELANGID(0x09, 0x01), SORT_DEFAULT); //create our english locale and use it everywhere it's needed - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" int __declspec(dllexport) Load(void) -{ - mir_getLP(&pluginInfo); - - InitServices(); - HookEvents(); - - hiVIIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAIN)); - - //get the name of the dll itself - TCHAR filePath[512] = {0}; - GetModuleFileName(hInst, filePath, SIZEOF(filePath)); - TCHAR *fileName = NULL; - size_t i = _tcslen(filePath) - 1; - _tcslwr(filePath); - - //Menu item - CLISTMENUITEM mi = { 0 }; - mi.cbSize = sizeof(mi); - mi.position = mi.popupPosition = 2000089999; - mi.flags = 0; - mi.hIcon = hiVIIcon; - mi.pszName = Translate("Version Information"); - mi.pszService = MS_VERSIONINFO_MENU_COMMAND; - Menu_AddMainMenuItem(&mi); - - if (LoadLibraryA("RichEd32.dll") == NULL) - MessageBoxA(NULL, "d'oh", "d'oh", MB_OK); - - return 0; -} - -extern "C" int __declspec(dllexport) Unload(void) -{ - UnhookEvents(); - DestroyServices(); - return 0; -} \ No newline at end of file diff --git a/plugins/VersionInfo/res/VersionInfo.ico b/plugins/VersionInfo/res/VersionInfo.ico new file mode 100644 index 0000000000..b026d584c2 Binary files /dev/null and b/plugins/VersionInfo/res/VersionInfo.ico differ diff --git a/plugins/VersionInfo/res/resource.rc b/plugins/VersionInfo/res/resource.rc new file mode 100644 index 0000000000..420b122b90 --- /dev/null +++ b/plugins/VersionInfo/res/resource.rc @@ -0,0 +1,225 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\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 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ASKDIALOG DIALOGEX 0, 0, 231, 146 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Output to:" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDC_ASK_OK,63,125,50,14 + PUSHBUTTON "Cancel",IDC_ASK_CANCEL,117,125,50,14 + CONTROL "Text file",IDC_ASK_TOFILE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,17,206,10 + CONTROL "MessageBox()",IDC_ASK_TOMESSAGEBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,27,206,10 + CONTROL "DialogBox",IDC_ASK_TODIALOGBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,37,206,10 + CONTROL "OutputDebugString()",IDC_ASK_TOOUTPUTDEBUGSTRING,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,47,206,10 + CONTROL "Clipboard",IDC_ASK_TOCLIPBOARD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,57,206,10 + GROUPBOX "Select output:",IDC_STATIC,7,7,217,72 + CONTROL "Upload to site",IDC_ASK_TOUPLOAD,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,15,67,206,10 + CONTROL "Forum style formatting",IDC_ASK_FORUMSTYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,92,206,9 + GROUPBOX "Aditional options:",IDC_STATIC,7,81,217,39 + COMBOBOX IDC_ASK_QUOTECOMBOBOX,15,104,75,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_ASK_SIZECOMBOBOX,93,104,71,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_ASK_BOLDCOMBOBOX,167,104,54,47,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ASKDIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 224 + VERTGUIDE, 15 + VERTGUIDE, 221 + TOPMARGIN, 7 + BOTTOMMARGIN, 139 + HORZGUIDE, 116 + END +END +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Italian (Italy) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA) +#ifdef _WIN32 +LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT_VERSIONINFO DIALOGEX 0, 0, 315, 222 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + PUSHBUTTON "Do it now",IDC_GETINFONOW,265,4,48,13 + GROUPBOX "Output to:",IDC_STATIC,5,4,197,130 + CONTROL "Text file",IDC_TOFILE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,16,186,10 + EDITTEXT IDC_FILENAME,24,26,150,14,ES_AUTOHSCROLL + CONTROL "MessageBox()",IDC_TOMESSAGEBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,40,186,10 + CONTROL "DialogBox",IDC_TODIALOGBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,51,186,10 + CONTROL "Show window in taskbar",IDC_SHOWINTASKBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,62,177,10 + CONTROL "OutputDebugString()",IDC_TODEBUGSTRING,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,73,186,10 + CONTROL "Clipboard",IDC_TOCLIPBOARD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,84,186,10 + CONTROL "Upload to site",IDC_TOUPLOAD,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,12,95,186,10 + CONTROL "Ask every time",IDC_ASKEVERYTIME,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,106,186,10 + CONTROL "Also copy info to clipboard",IDC_CLIPBOARDALSO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,121,186,10 + GROUPBOX "Upload site settings",IDC_STATIC,205,74,108,60 + EDITTEXT IDC_UPLOAD_SERVER,209,83,71,14,ES_AUTOHSCROLL | WS_DISABLED + EDITTEXT IDC_UPLOAD_PORT,281,83,27,14,ES_AUTOHSCROLL | WS_DISABLED + LTEXT "Username",IDC_STATIC,209,103,42,8 + EDITTEXT IDC_UPLOAD_USERNAME,253,99,55,14,ES_AUTOHSCROLL | WS_DISABLED + LTEXT "Password",IDC_STATIC,209,118,43,8 + EDITTEXT IDC_UPLOAD_PASSWORD,253,115,55,14,ES_PASSWORD | ES_AUTOHSCROLL | WS_DISABLED + CONTROL "Forum style formatting",IDC_FORUMSTYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,139,149,10 + COMBOBOX IDC_QUOTECOMBOBOX,159,137,75,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SIZECOMBOBOX,238,137,75,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Highlight version number using",IDC_BOLDVERSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,153,216,10 + COMBOBOX IDC_BOLDCOMBOBOX,252,153,61,37,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Show disabled plugins too",IDC_DISABLEDTOO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,164,232,10 + CONTROL "Attempt to find unloadable plugins (doesn't work on Windows 98)",IDC_CHECKUNLOADABLE, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,174,272,10 + CONTROL "Suppress header information",IDC_SUPPRESSHEADER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,184,274,10 + CONTROL "Enable debug messages",IDC_DEBUG,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,220,207,93,10 + CONTROL "Show plugin UUIDs",IDC_SHOWUUIDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,195,272,10 + CONTROL "Show installed languages",IDC_SHOWINSTALLEDLANGUAGES, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,206,273,10 +END + +IDD_DIALOGINFO DIALOGEX 0, 0, 373, 217 +STYLE DS_LOCALEDIT | DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT +CAPTION "Miranda Version Information" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + CONTROL "",IDC_TEXT,"RICHEDIT",TCS_HOTTRACK | TCS_FOCUSONBUTTONDOWN | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_TABSTOP,7,7,298,203 + PUSHBUTTON "Close",IDC_CLOSE,316,7,50,14 + PUSHBUTTON "&Copy text",IDC_COPYTEXT,316,26,50,14 + PUSHBUTTON "Upload",IDC_UPLOAD,316,196,50,14,WS_DISABLED + PUSHBUTTON "&Save to file",IDC_SAVETOFILE,316,45,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT_VERSIONINFO, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 313 + VERTGUIDE, 12 + VERTGUIDE, 198 + VERTGUIDE, 202 + VERTGUIDE, 205 + VERTGUIDE, 304 + VERTGUIDE, 308 + TOPMARGIN, 4 + BOTTOMMARGIN, 217 + HORZGUIDE, 149 + END + + IDD_DIALOGINFO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 366 + TOPMARGIN, 7 + BOTTOMMARGIN, 210 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_MAIN ICON "VersionInfo.ico" +#endif // Italian (Italy) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/VersionInfo/res/version.rc b/plugins/VersionInfo/res/version.rc new file mode 100644 index 0000000000..f691628164 --- /dev/null +++ b/plugins/VersionInfo/res/version.rc @@ -0,0 +1,46 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "..\src\version.h" +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +// +// 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 +///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/VersionInfo/resource.h b/plugins/VersionInfo/resource.h deleted file mode 100644 index b282e8bca6..0000000000 --- a/plugins/VersionInfo/resource.h +++ /dev/null @@ -1,71 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDD_DIALOG1 101 -#define IDD_OPT_VERSIONINFO 102 -#define IDD_DIALOGBOX 103 -#define IDD_DIALOGINFO 103 -#define IDI_ICON1 104 -#define IDI_MAIN 104 -#define IDD_ASKDIALOG 106 -#define IDC_MENUITEM 1000 -#define IDC_TOFILE 1001 -#define IDC_TOMESSAGEBOX 1002 -#define IDC_TODIALOGBOX 1003 -#define IDC_DISABLEDTOO 1004 -#define IDC_FILENAME 1005 -#define IDC_TEXT 1006 -#define IDC_TODEBUGSTRING 1006 -#define IDC_CLOSE 1007 -#define IDC_TOCLIPBOARD 1007 -#define IDC_GETINFONOW 1009 -#define IDC_TOUPLOAD 1010 -#define IDC_GETINFONOW2 1011 -#define IDC_COPYTEXT 1012 -#define IDC_DEBUG 1013 -#define IDC_FORUMSTYLE 1014 -#define IDC_CLIPBOARDALSO 1015 -#define IDC_SHOWINTASKBAR 1016 -#define IDC_QUOTECOMBOBOX 1017 -#define IDC_SIZECOMBOBOX 1018 -#define IDC_BOLDVERSION 1020 -#define IDC_CHECKUNLOADABLE 1021 -#define IDC_ASKEVERYTIME 1022 -#define IDC_ASK_TOFILE 1023 -#define IDC_ASK_TOMESSAGEBOX 1024 -#define IDC_ASK_TODIALOGBOX 1025 -#define IDC_ASK_TOOUTPUTDEBUGSTRING 1026 -#define IDC_ASK_TOCLIPBOARD 1027 -#define IDC_ASK_CANCEL 1028 -#define IDC_ASK_OK 1029 -#define IDC_BOLDCOMBOBOX 1030 -#define IDC_SUPPRESSHEADER 1031 -#define IDC_SHOWHARDWAREINFO 1033 -#define IDC_UPLOAD 1034 -#define IDC_ASK_UPLOAD 1036 -#define IDC_ASK_TOUPLOAD 1036 -#define IDC_UPLOAD_SERVER 1038 -#define IDC_UPLOAD_PORT 1039 -#define IDC_UPLOAD_USERNAME 1040 -#define IDC_UPLOAD_PASSWORD 1041 -#define IDC_TEMPORARY_FORUMSTYLE 1042 -#define IDC_ASK_FORUMSTYLE 1042 -#define IDC_ASK_QUOTECOMBOBOX 1043 -#define IDC_ASK_SIZECOMBOBOX 1044 -#define IDC_ASK_BOLDCOMBOBOX 1045 -#define IDC_SAVETOFILE 1046 -#define IDC_SHOWUUIDS 1048 -#define IDC_CHECK1 1049 -#define IDC_SHOWINSTALLEDLANGUAGES 1049 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 107 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1050 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/VersionInfo/resource.rc b/plugins/VersionInfo/resource.rc deleted file mode 100644 index b4a8eb819a..0000000000 --- a/plugins/VersionInfo/resource.rc +++ /dev/null @@ -1,225 +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 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ASKDIALOG DIALOGEX 0, 0, 231, 146 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Output to:" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDC_ASK_OK,63,125,50,14 - PUSHBUTTON "Cancel",IDC_ASK_CANCEL,117,125,50,14 - CONTROL "Text file",IDC_ASK_TOFILE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,17,206,10 - CONTROL "MessageBox()",IDC_ASK_TOMESSAGEBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,27,206,10 - CONTROL "DialogBox",IDC_ASK_TODIALOGBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,37,206,10 - CONTROL "OutputDebugString()",IDC_ASK_TOOUTPUTDEBUGSTRING,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,47,206,10 - CONTROL "Clipboard",IDC_ASK_TOCLIPBOARD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,57,206,10 - GROUPBOX "Select output:",IDC_STATIC,7,7,217,72 - CONTROL "Upload to site",IDC_ASK_TOUPLOAD,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,15,67,206,10 - CONTROL "Forum style formatting",IDC_ASK_FORUMSTYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,92,206,9 - GROUPBOX "Aditional options:",IDC_STATIC,7,81,217,39 - COMBOBOX IDC_ASK_QUOTECOMBOBOX,15,104,75,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_ASK_SIZECOMBOBOX,93,104,71,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_ASK_BOLDCOMBOBOX,167,104,54,47,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ASKDIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 224 - VERTGUIDE, 15 - VERTGUIDE, 221 - TOPMARGIN, 7 - BOTTOMMARGIN, 139 - HORZGUIDE, 116 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Italian (Italy) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA) -#ifdef _WIN32 -LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPT_VERSIONINFO DIALOGEX 0, 0, 315, 222 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - PUSHBUTTON "Do it now",IDC_GETINFONOW,265,4,48,13 - GROUPBOX "Output to:",IDC_STATIC,5,4,197,130 - CONTROL "Text file",IDC_TOFILE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,16,186,10 - EDITTEXT IDC_FILENAME,24,26,150,14,ES_AUTOHSCROLL - CONTROL "MessageBox()",IDC_TOMESSAGEBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,40,186,10 - CONTROL "DialogBox",IDC_TODIALOGBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,51,186,10 - CONTROL "Show window in taskbar",IDC_SHOWINTASKBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,62,177,10 - CONTROL "OutputDebugString()",IDC_TODEBUGSTRING,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,73,186,10 - CONTROL "Clipboard",IDC_TOCLIPBOARD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,84,186,10 - CONTROL "Upload to site",IDC_TOUPLOAD,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,12,95,186,10 - CONTROL "Ask every time",IDC_ASKEVERYTIME,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,106,186,10 - CONTROL "Also copy info to clipboard",IDC_CLIPBOARDALSO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,121,186,10 - GROUPBOX "Upload site settings",IDC_STATIC,205,74,108,60 - EDITTEXT IDC_UPLOAD_SERVER,209,83,71,14,ES_AUTOHSCROLL | WS_DISABLED - EDITTEXT IDC_UPLOAD_PORT,281,83,27,14,ES_AUTOHSCROLL | WS_DISABLED - LTEXT "Username",IDC_STATIC,209,103,42,8 - EDITTEXT IDC_UPLOAD_USERNAME,253,99,55,14,ES_AUTOHSCROLL | WS_DISABLED - LTEXT "Password",IDC_STATIC,209,118,43,8 - EDITTEXT IDC_UPLOAD_PASSWORD,253,115,55,14,ES_PASSWORD | ES_AUTOHSCROLL | WS_DISABLED - CONTROL "Forum style formatting",IDC_FORUMSTYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,139,149,10 - COMBOBOX IDC_QUOTECOMBOBOX,159,137,75,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_SIZECOMBOBOX,238,137,75,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Highlight version number using",IDC_BOLDVERSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,153,216,10 - COMBOBOX IDC_BOLDCOMBOBOX,252,153,61,37,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Show disabled plugins too",IDC_DISABLEDTOO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,164,232,10 - CONTROL "Attempt to find unloadable plugins (doesn't work on Windows 98)",IDC_CHECKUNLOADABLE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,174,272,10 - CONTROL "Suppress header information",IDC_SUPPRESSHEADER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,184,274,10 - CONTROL "Enable debug messages",IDC_DEBUG,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,220,207,93,10 - CONTROL "Show plugin UUIDs",IDC_SHOWUUIDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,195,272,10 - CONTROL "Show installed languages",IDC_SHOWINSTALLEDLANGUAGES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,206,273,10 -END - -IDD_DIALOGINFO DIALOGEX 0, 0, 373, 217 -STYLE DS_LOCALEDIT | DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT -CAPTION "Miranda Version Information" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CONTROL "",IDC_TEXT,"RICHEDIT",TCS_HOTTRACK | TCS_FOCUSONBUTTONDOWN | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_TABSTOP,7,7,298,203 - PUSHBUTTON "Close",IDC_CLOSE,316,7,50,14 - PUSHBUTTON "&Copy text",IDC_COPYTEXT,316,26,50,14 - PUSHBUTTON "Upload",IDC_UPLOAD,316,196,50,14,WS_DISABLED - PUSHBUTTON "&Save to file",IDC_SAVETOFILE,316,45,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPT_VERSIONINFO, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 313 - VERTGUIDE, 12 - VERTGUIDE, 198 - VERTGUIDE, 202 - VERTGUIDE, 205 - VERTGUIDE, 304 - VERTGUIDE, 308 - TOPMARGIN, 4 - BOTTOMMARGIN, 217 - HORZGUIDE, 149 - END - - IDD_DIALOGINFO, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 366 - TOPMARGIN, 7 - BOTTOMMARGIN, 210 - END -END -#endif // APSTUDIO_INVOKED - - -#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 - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MAIN ICON "VersionInfo.ico" -#endif // Italian (Italy) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/VersionInfo/services.cpp b/plugins/VersionInfo/services.cpp deleted file mode 100644 index 4efa482404..0000000000 --- a/plugins/VersionInfo/services.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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 "common.h" -#include "services.h" - -HANDLE hsMenuCommand; -HANDLE hsGetInfo; -HANDLE hsServiceMode; - -int bServiceMode = 0; //true only if plugin is running in service mode - -int InitServices() -{ - hsMenuCommand = CreateServiceFunction(MS_VERSIONINFO_MENU_COMMAND, PluginMenuCommand); - hsGetInfo = CreateServiceFunction(MS_VERSIONINFO_GETINFO, GetInfoService); - hsServiceMode = CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeService); - return 0; -} - -int DestroyServices() -{ - DestroyServiceFunction(hsMenuCommand); - DestroyServiceFunction(hsGetInfo); - DestroyServiceFunction(hsServiceMode); - return 0; -} - -INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam) -{ - int debugTo = DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX); - DoDebugTo(debugTo); - if (verbose) PUShowMessage("I have printed the information.", SM_NOTIFY); -/* char *data; - CallService(MS_VERSIONINFO_GETINFO, 1, (LPARAM) &data); */ - return 0; -} - -INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam) -{ - int result = 1; //failure - if (lParam != NULL) { - CVersionInfo myInfo; - myInfo.Initialize(); - std::tstring VI = myInfo.GetInformationsAsString(wParam); - char **retData = (char **) lParam; - *retData = mir_utf8encodeT( VI.c_str()); - if (*retData) - result = 0; //success - } - return result; -} - -INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam) -{ - bServiceMode = 1; - DoDebugTo(TO_ASK); - return 0; -} diff --git a/plugins/VersionInfo/services.h b/plugins/VersionInfo/services.h deleted file mode 100644 index 38acbc7731..0000000000 --- a/plugins/VersionInfo/services.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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_VERSIONINFO_SERVICES_H -#define M_VERSIONINFO_SERVICES_H - -int InitServices(); -int DestroyServices(); - -INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam); -INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam); -INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam); - -#endif //M_VERSIONINFO_SERVICES_H \ No newline at end of file diff --git a/plugins/VersionInfo/src/CPlugin.cpp b/plugins/VersionInfo/src/CPlugin.cpp new file mode 100644 index 0000000000..54d762064a --- /dev/null +++ b/plugins/VersionInfo/src/CPlugin.cpp @@ -0,0 +1,147 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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 "CPlugin.h" + +#include "common.h" + +#pragma comment(lib, "version.lib") + +const int cPLUGIN_UUID_MARK = 4; +TCHAR PLUGIN_UUID_MARK[cPLUGIN_UUID_MARK]; + +#define PLUGIN_UNCERTAIN_MARK "?" + +#define RJUST 70 + +CPlugin::CPlugin() { + pluginID = UUID_NULL; +} + +CPlugin::CPlugin(LPCTSTR eFileName, LPCTSTR eShortName, MUUID pluginID, LPCTSTR eUnicodeInfo, DWORD eVersion, LPCTSTR eTimestamp, LPCTSTR eLinkedModules) { + lpzFileName = eFileName; + lpzShortName = eShortName; + lpzUnicodeInfo = eUnicodeInfo; + lpzTimestamp = eTimestamp; + lpzLinkedModules = eLinkedModules; + + int v1, v2, v3, v4; + + DWORD unused, verInfoSize = GetFileVersionInfoSize(eFileName, &unused); + if (verInfoSize != 0) { + UINT blockSize; + VS_FIXEDFILEINFO* fi; + void* pVerInfo = mir_alloc(verInfoSize); + GetFileVersionInfo(eFileName, 0, verInfoSize, pVerInfo); + VerQueryValue(pVerInfo, _T("\\"), (LPVOID*)&fi, &blockSize); + v1 = HIWORD(fi->dwProductVersionMS), v2 = LOWORD(fi->dwProductVersionMS), + v3 = HIWORD(fi->dwProductVersionLS), v4 = LOWORD(fi->dwProductVersionLS); + mir_free(pVerInfo); + } + else { + DWORD ver = eVersion; + v1 = HIBYTE(HIWORD(ver)), v2 = LOBYTE(HIWORD(ver)), v3 = HIBYTE(LOWORD(ver)), v4 = LOBYTE(LOWORD(ver)); + } + + TCHAR aux[128]; + mir_sntprintf(aux, SIZEOF(aux), _T("%d.%d.%d.%d"), v1, v2, v3, v4); + lpzVersion = aux; + + this->pluginID = pluginID; +}; + +CPlugin::CPlugin(const CPlugin& other) { + lpzFileName = other.lpzFileName; + lpzShortName = other.lpzShortName; + lpzUnicodeInfo = other.lpzUnicodeInfo; + lpzVersion = other.lpzVersion; + lpzTimestamp = other.lpzTimestamp; + lpzLinkedModules = other.lpzLinkedModules; + pluginID = other.pluginID; +} + +CPlugin::~CPlugin() +{ +} + +void CPlugin::SetErrorMessage(LPCTSTR error) +{ + lpzLinkedModules = error; +} + +bool CPlugin::operator<(CPlugin &anotherPlugin) +{ + std::tstring anotherFileName = anotherPlugin.getFileName(); + + TCHAR szThis[MAX_PATH]; lstrcpy(szThis, lpzFileName.c_str()); + TCHAR szThat[MAX_PATH]; lstrcpy(szThat, anotherFileName.c_str()); + + if (lstrcmpi(szThis, szThat) < 0) + return TRUE; + else + return FALSE; +} + +bool CPlugin::operator>(CPlugin &anotherPlugin) +{ + return !((*this) < anotherPlugin); +} +bool CPlugin::operator==(CPlugin &anotherPlugin) +{ + return !((*this) < anotherPlugin || (*this) > anotherPlugin); +} + +std::tstring CPlugin::getFileName() +{ + return this->lpzFileName; +} + +std::tstring CPlugin::getInformations(DWORD flags, TCHAR *szHighlightHeader, TCHAR *szHighlightFooter) +{ + std::tstring lpzInformations; + if (flags & VISF_SHOWUUID) + { + TCHAR aux[128]; + UUIDToString(pluginID, aux, SIZEOF(aux)); + lpzInformations = aux; + } + else lpzInformations = (IsUUIDNull(pluginID)) ? _T(" ") : PLUGIN_UUID_MARK; + + lpzInformations += std::tstring(_T(" ") + lpzFileName + _T(" v.") + szHighlightHeader + lpzVersion + szHighlightFooter + _T(" [") + lpzTimestamp + _T("] - ") + lpzShortName); + if (lpzUnicodeInfo.size() > 0) + { + TCHAR *lwr = _tcslwr(_tcsdup(lpzShortName.c_str())); + if ( !_tcsstr(lwr, _T("unicode")) && !_tcsstr(lwr, _T("2in1"))) + lpzInformations.append( _T(" |") + lpzUnicodeInfo + _T("|")); + + free(lwr); + } + //lpzInformations.append("\t"); + //lpzInformations.append(lpzPluginID); + lpzInformations.append( _T("\r\n")); + + if (lpzLinkedModules.size() > 0) + { + lpzInformations.append(lpzLinkedModules); + lpzInformations.append( _T("\r\n")); + } +// std::string lpzInformations = std::string(lpzFileName + " - " + lpzShortName + " [" + lpzTimestamp + " · " + lpzVersion +"]\r\n"); + return lpzInformations; +}; \ No newline at end of file diff --git a/plugins/VersionInfo/src/CPlugin.h b/plugins/VersionInfo/src/CPlugin.h new file mode 100644 index 0000000000..5da1b1dc6b --- /dev/null +++ b/plugins/VersionInfo/src/CPlugin.h @@ -0,0 +1,73 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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 CPLUGIN_H +#define CPLUGIN_H + +//#define STRICT +#define WIN32_LEAN_AND_MEAN + +#define _CRT_SECURE_NO_DEPRECATE + +#include +#include + +#ifndef M_NEWPLUGINAPI_H__ + #include "newpluginapi.h" +#endif + +#define DEF_UUID_CHARMARK "¤" + +extern const int cPLUGIN_UUID_MARK; +extern TCHAR PLUGIN_UUID_MARK[]; + +//using namespace std; + + + #define tstring wstring + + +class CPlugin { + private: + std::tstring lpzFileName; + std::tstring lpzShortName; + std::tstring lpzVersion; + std::tstring lpzUnicodeInfo; //aditional info, Unicode aware ... + std::tstring lpzTimestamp; //to show the last modified timestamp + std::tstring lpzLinkedModules; //to show linked modules that aren't found + MUUID pluginID; + + public: + CPlugin(); + CPlugin(LPCTSTR fileName, LPCTSTR shortName, MUUID pluginID, LPCTSTR unicodeInfo, DWORD version, LPCTSTR timestamp, LPCTSTR linkedModules); + CPlugin(const CPlugin&); + ~CPlugin(); + std::tstring getFileName(); + std::tstring getInformations(DWORD, TCHAR *, TCHAR *); + + void SetErrorMessage(LPCTSTR error); + + //Operators + bool operator<(CPlugin&); + bool operator>(CPlugin&); + bool operator==(CPlugin&); +}; +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/src/CVersionInfo.cpp b/plugins/VersionInfo/src/CVersionInfo.cpp new file mode 100644 index 0000000000..da10f4b9a9 --- /dev/null +++ b/plugins/VersionInfo/src/CVersionInfo.cpp @@ -0,0 +1,1198 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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 "CVersionInfo.h" +//#include "AggressiveOptimize.h" + +#include "common.h" +#include "resource.h" + +//using namespace std; + +BOOL (WINAPI *MyGetDiskFreeSpaceEx)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); +BOOL (WINAPI *MyIsWow64Process)(HANDLE, PBOOL); +void (WINAPI *MyGetSystemInfo)(LPSYSTEM_INFO); +BOOL (WINAPI *MyGlobalMemoryStatusEx)(LPMEMORYSTATUSEX lpBuffer) = NULL; + +LANGID (WINAPI *MyGetUserDefaultUILanguage)() = NULL; +LANGID (WINAPI *MyGetSystemDefaultUILanguage)() = NULL; + +static int ValidExtension(TCHAR *fileName, TCHAR *extension) +{ + TCHAR *dot = _tcschr(fileName, '.'); + if ( dot != NULL && !lstrcmpi(dot + 1, extension)) + if (dot[lstrlen(extension) + 1] == 0) + return 1; + + return 0; +} + +void FillLocalTime(std::tstring &output, FILETIME *fileTime) +{ + TIME_ZONE_INFORMATION tzInfo = {0}; + FILETIME local = {0}; + SYSTEMTIME sysTime; + TCHAR date[1024]; + TCHAR time[256]; + + FileTimeToLocalFileTime(fileTime, &local); + FileTimeToSystemTime(&local, &sysTime); + + GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date)); + GetTimeFormat(NULL, TIME_FORCE24HOURFORMAT, &sysTime, _T("HH':'mm':'ss"), time, SIZEOF(time)); //americans love 24hour format ;) + output = std::tstring(date) + _T(" at ") + std::tstring(time); + + int res = GetTimeZoneInformation(&tzInfo); + char tzName[32] = {0}; + TCHAR tzOffset[64] = {0}; + int offset = 0; + switch (res) { + case TIME_ZONE_ID_DAYLIGHT: + offset = -(tzInfo.Bias + tzInfo.DaylightBias); + WideCharToMultiByte(CP_ACP, 0, tzInfo.DaylightName, -1, tzName, SIZEOF(tzName), NULL, NULL); + break; + + case TIME_ZONE_ID_STANDARD: + WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL); + offset = -(tzInfo.Bias + tzInfo.StandardBias); + break; + + case TIME_ZONE_ID_UNKNOWN: + WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL); + offset = -tzInfo.Bias; + break; + } + + mir_sntprintf(tzOffset, SIZEOF(tzOffset), _T("UTC %+02d:%02d"), offset / 60, offset % 60); + output += _T(" (") + std::tstring(tzOffset) + _T(")"); +} + +CVersionInfo::CVersionInfo() +{ + luiFreeDiskSpace = 0; + bDEPEnabled = 0; +} + +CVersionInfo::~CVersionInfo() +{ + listInactivePlugins.clear(); + listActivePlugins.clear(); + listUnloadablePlugins.clear(); + + lpzMirandaVersion.~basic_string(); + lpzNightly.~basic_string(); + lpzUnicodeBuild.~basic_string(); + lpzBuildTime.~basic_string(); + lpzOSVersion.~basic_string(); + lpzMirandaPath.~basic_string(); + lpzCPUName.~basic_string(); + lpzCPUIdentifier.~basic_string(); +}; + +void CVersionInfo::Initialize() +{ +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetMirandaVersion().", SM_NOTIFY); +#endif + GetMirandaVersion(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetProfileSettings().", SM_NOTIFY); +#endif + GetProfileSettings(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetLangpackInfo().", SM_NOTIFY); +#endif + GetOSLanguages(); + GetLangpackInfo(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetPluginLists().", SM_NOTIFY); +#endif + GetPluginLists(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetOSVersion().", SM_NOTIFY); +#endif + GetOSVersion(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetHWSettings().", SM_NOTIFY); +#endif + GetHWSettings(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Done with GetHWSettings().", SM_NOTIFY); +#endif +} + +bool CVersionInfo::GetMirandaVersion() +{ + //Miranda version + const BYTE str_size = 64; + char str[str_size]; + CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)str_size, (LPARAM)str); + this->lpzMirandaVersion = _A2T(str); + //Is it a nightly? + if (lpzMirandaVersion.find( _T("alpha"),0) != std::string::npos) + lpzNightly = _T("Yes"); + else + lpzNightly = _T("No"); + + if (lpzMirandaVersion.find( _T("Unicode"), 0) != std::string::npos) + lpzUnicodeBuild = _T("Yes"); + else + lpzUnicodeBuild = _T("No"); + + TCHAR time[128], date[128]; + GetModuleTimeStamp(date, time); + lpzBuildTime = std::tstring(time) + _T(" (UTC) on ") + std::tstring(date); + return TRUE; +} + +bool CVersionInfo::GetOSVersion() +{ + //Operating system informations + OSVERSIONINFO osvi = { 0 }; + osvi.dwOSVersionInfoSize = sizeof(osvi); + GetVersionEx(&osvi); + + //Now fill the private members. + TCHAR aux[256]; + wsprintf(aux, _T("%d.%d.%d %s"), osvi.dwMajorVersion, osvi.dwMinorVersion, LOWORD(osvi.dwBuildNumber), osvi.szCSDVersion); + lpzOSVersion = aux; + + //OSName + //Let's read the registry. + HKEY hKey; + TCHAR szKey[MAX_PATH], szValue[MAX_PATH]; + lstrcpyn(szKey, _T("Hardware\\Description\\System\\CentralProcessor\\0"), MAX_PATH); + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { + DWORD type, size, result; + + lstrcpyn(szValue, _T("Identifier"), MAX_PATH); + result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); + if (result == ERROR_SUCCESS) { + TCHAR *aux = new TCHAR[size+1]; + result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); + lpzCPUIdentifier = aux; + delete[] aux; + } + else { + NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); + lpzCPUIdentifier = _T(""); + } + + lstrcpyn(szValue, _T("ProcessorNameString"), MAX_PATH); + result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); //get the size + if (result == ERROR_SUCCESS) { + TCHAR *aux = new TCHAR[size+1]; + result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); + lpzCPUName = aux; + delete[] aux; + } + else { //else try to use cpuid instruction to get the proc name + char szName[50]; + #if (!defined(WIN64) && !defined(_WIN64)) + __asm + { + push eax //save the registers + push ebx + push ecx + push edx + + xor eax, eax //get simple name + cpuid + mov DWORD PTR szName[0], ebx + mov DWORD PTR szName[4], edx + mov DWORD PTR szName[8], ecx + mov DWORD PTR szName[12], 0 + + mov eax, 0x80000000 //try to get pretty name + cpuid + + cmp eax, 0x80000004 + jb end //if we don't have the extension end the check + + mov DWORD PTR szName[0], 0 //make the string null + + mov eax, 0x80000002 //first part of the string + cpuid + mov DWORD PTR szName[0], eax + mov DWORD PTR szName[4], ebx + mov DWORD PTR szName[8], ecx + mov DWORD PTR szName[12], edx + + mov eax, 0x80000003 //second part of the string + cpuid + mov DWORD PTR szName[16], eax + mov DWORD PTR szName[20], ebx + mov DWORD PTR szName[24], ecx + mov DWORD PTR szName[28], edx + + mov eax, 0x80000004 //third part of the string + cpuid + mov DWORD PTR szName[32], eax + mov DWORD PTR szName[36], ebx + mov DWORD PTR szName[40], ecx + mov DWORD PTR szName[44], edx + +end: + pop edx //load them back + pop ecx + pop ebx + pop eax + } + szName[SIZEOF(szName) - 1] = '\0'; + #else + szName[0] = 0; + #endif + + if ( !szName[0] ) + lpzCPUName = _T(""); + else + lpzCPUName = _A2T(szName); + } + } + + bDEPEnabled = IsProcessorFeaturePresent(PF_NX_ENABLED); + + switch (osvi.dwPlatformId) { + case VER_PLATFORM_WIN32_WINDOWS: + lstrcpyn(szKey, _T("Software\\Microsoft\\Windows\\CurrentVersion"), MAX_PATH); + lstrcpyn(szValue, _T("Version"), MAX_PATH); + break; + case VER_PLATFORM_WIN32_NT: + + lstrcpyn(szKey, _T("Software\\Microsoft\\Windows NT\\CurrentVersion"), MAX_PATH); + lstrcpyn(szValue, _T("ProductName"), MAX_PATH); + break; + } + + RegCloseKey(hKey); + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,szKey,0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) { + DWORD type, size, result; + //Get the size of the value we'll read. + result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)NULL, + (LPDWORD)&size); + if (result == ERROR_SUCCESS) { + //Read it. + TCHAR *aux = new TCHAR[size+1]; + result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)aux,(LPDWORD)&size); + lpzOSName = aux; + delete[] aux; + } + else { + NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); + lpzOSName = _T(""); + } + } + else { + NotifyError(GetLastError(), _T("RegOpenKeyEx()"), __LINE__); + lpzOSName = _T(""); + } + + //Now we can improve it if we can. + switch (LOWORD(osvi.dwBuildNumber)) { + case 950: lpzOSName = _T("Microsoft Windows 95"); break; + case 1111: lpzOSName = _T("Microsoft Windows 95 OSR2"); break; + case 1998: lpzOSName = _T("Microsoft Windows 98"); break; + case 2222: lpzOSName = _T("Microsoft Windows 98 SE"); break; + case 3000: lpzOSName = _T("Microsoft Windows ME"); break; //Even if this is wrong, we have already read it in the registry. + case 1381: lpzOSName = _T("Microsoft Windows NT"); break; //What about service packs? + case 2195: lpzOSName = _T("Microsoft Windows 2000"); break; //What about service packs? + case 2600: lpzOSName = _T("Microsoft Windows XP"); break; + case 3790: + if ( GetSystemMetrics( 89 )) //R2 ? + lpzOSName = _T("Microsoft Windows 2003 R2"); + else + lpzOSName = _T("Microsoft Windows 2003"); + + break; //added windows 2003 info + } + + return TRUE; +} + +bool CVersionInfo::GetHWSettings() { + //Free space on Miranda Partition. + TCHAR szMirandaPath[MAX_PATH] = { 0 }; + { + GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); + TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); + if ( str2 != NULL) *str2=0; + } + HMODULE hKernel32; + hKernel32 = LoadLibraryA("kernel32.dll"); + if (hKernel32) { + + MyGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCTSTR,PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER))GetProcAddress(hKernel32, "GetDiskFreeSpaceExW"); + + + MyIsWow64Process = (BOOL (WINAPI *) (HANDLE, PBOOL)) GetProcAddress(hKernel32, "IsWow64Process"); + MyGetSystemInfo = (void (WINAPI *) (LPSYSTEM_INFO)) GetProcAddress(hKernel32, "GetNativeSystemInfo"); + MyGlobalMemoryStatusEx = (BOOL (WINAPI *) (LPMEMORYSTATUSEX)) GetProcAddress(hKernel32, "GlobalMemoryStatusEx"); + if ( !MyGetSystemInfo ) + MyGetSystemInfo = GetSystemInfo; + + FreeLibrary(hKernel32); + } + if ( MyGetDiskFreeSpaceEx ) { + ULARGE_INTEGER FreeBytes, a, b; + MyGetDiskFreeSpaceEx(szMirandaPath, &FreeBytes, &a, &b); + //Now we need to convert it. + __int64 aux = FreeBytes.QuadPart; + aux /= (1024*1024); + luiFreeDiskSpace = (unsigned long int)aux; + } + else luiFreeDiskSpace = 0; + + TCHAR szInfo[1024]; + GetWindowsShell(szInfo, SIZEOF(szInfo)); + lpzShell = szInfo; + GetInternetExplorerVersion(szInfo, SIZEOF(szInfo)); + lpzIEVersion = szInfo; + + + lpzAdministratorPrivileges = (IsCurrentUserLocalAdministrator()) ? _T("Yes") : _T("No"); + + bIsWOW64 = 0; + if (MyIsWow64Process) + if (!MyIsWow64Process(GetCurrentProcess(), &bIsWOW64)) + bIsWOW64 = 0; + + SYSTEM_INFO sysInfo = {0}; + GetSystemInfo(&sysInfo); + luiProcessors = sysInfo.dwNumberOfProcessors; + + //Installed RAM + if (MyGlobalMemoryStatusEx) { //windows 2000+ + MEMORYSTATUSEX ms = {0}; + ms.dwLength = sizeof(ms); + MyGlobalMemoryStatusEx(&ms); + luiRAM = (unsigned int) ((ms.ullTotalPhys / (1024 * 1024)) + 1); + } + else { + MEMORYSTATUS ms = {0}; + ms.dwLength = sizeof(ms); + GlobalMemoryStatus(&ms); + luiRAM = (ms.dwTotalPhys/(1024*1024))+1; //Ugly hack!!!! + } + + return TRUE; +} + +bool CVersionInfo::GetProfileSettings() +{ + TCHAR* tszProfileName = Utils_ReplaceVarsT(_T("%miranda_userdata%\\%miranda_profilename%.dat")); + lpzProfilePath = tszProfileName; + + WIN32_FIND_DATA fd; + if ( FindFirstFile(tszProfileName, &fd) != INVALID_HANDLE_VALUE ) { + TCHAR number[40]; + mir_sntprintf( number, SIZEOF(number), _T("%.2f KBytes"), double(fd.nFileSizeLow) / 1024 ); + lpzProfileSize = number; + + FillLocalTime(lpzProfileCreationDate, &fd.ftCreationTime); + } + else { + DWORD error = GetLastError(); + TCHAR tmp[1024]; + wsprintf(tmp, _T("%d"), error); + lpzProfileCreationDate = _T("") + std::tstring(tszProfileName); + lpzProfileSize = _T("") + std::tstring(tszProfileName); + } + + mir_free( tszProfileName ); + return true; +} + +static TCHAR szSystemLocales[4096] = {0}; +static WORD systemLangID; +#define US_LANG_ID 0x00000409 + +BOOL CALLBACK EnumSystemLocalesProc(TCHAR *szLocale) +{ + DWORD locale = _ttoi(szLocale); + TCHAR *name = GetLanguageName(locale); + if ( !_tcsstr(szSystemLocales, name)) { + _tcscat(szSystemLocales, name); + _tcscat(szSystemLocales, _T(", ")); + } + + return TRUE; +} + +BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam) +{ + if (!lpszName) + return FALSE; + + if (wIDLanguage != US_LANG_ID) + systemLangID = wIDLanguage; + + return TRUE; +} + +bool CVersionInfo::GetOSLanguages() +{ + lpzOSLanguages = _T("(UI | Locale (User/System)) : "); + + LANGID UILang; + + OSVERSIONINFO os = {0}; + os.dwOSVersionInfoSize = sizeof(os); + GetVersionEx(&os); + if (os.dwMajorVersion == 4) { + if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) { //Win NT + HMODULE hLib = LoadLibraryA("ntdll.dll"); + + if (hLib) { + EnumResourceLanguages(hLib, RT_VERSION, MAKEINTRESOURCE(1), EnumResLangProc, NULL); + + FreeLibrary(hLib); + + if (systemLangID == US_LANG_ID) { + UINT uiACP; + + uiACP = GetACP(); + switch (uiACP) + { + case 874: // Thai code page activated, it's a Thai enabled system + systemLangID = MAKELANGID(LANG_THAI, SUBLANG_DEFAULT); + break; + + case 1255: // Hebrew code page activated, it's a Hebrew enabled system + systemLangID = MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT); + break; + + case 1256: // Arabic code page activated, it's a Arabic enabled system + systemLangID = MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_SAUDI_ARABIA); + break; + + default: + break; + } + } + } + } + else { //Win 95-Me + HKEY hKey = NULL; + TCHAR szLangID[128] = _T("0x"); + DWORD size = SIZEOF(szLangID) - 2; + TCHAR err[512]; + + if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop\\ResourceLocale"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { + if (RegQueryValueEx(hKey, _T(""), 0, NULL, (LPBYTE) &szLangID + 2, &size) == ERROR_SUCCESS) + _tscanf(szLangID, _T("%lx"), &systemLangID); + else { + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL); + MessageBox(0, err, _T("Error at RegQueryValueEx()"), MB_OK); + } + RegCloseKey(hKey); + } + else { + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL); + MessageBox(0, err, _T("Error at RegOpenKeyEx()"), MB_OK); + } + } + + lpzOSLanguages += GetLanguageName(systemLangID); + } + else { + HMODULE hKernel32 = LoadLibraryA("kernel32.dll"); + if (hKernel32) { + MyGetUserDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetUserDefaultUILanguage"); + MyGetSystemDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetSystemDefaultUILanguage"); + + FreeLibrary(hKernel32); + } + + if ((MyGetUserDefaultUILanguage) && (MyGetSystemDefaultUILanguage)) { + UILang = MyGetUserDefaultUILanguage(); + lpzOSLanguages += GetLanguageName(UILang); + lpzOSLanguages += _T("/"); + UILang = MyGetSystemDefaultUILanguage(); + lpzOSLanguages += GetLanguageName(UILang); + } + else lpzOSLanguages += _T("Missing functions in kernel32.dll (GetUserDefaultUILanguage, GetSystemDefaultUILanguage)"); + } + + lpzOSLanguages += _T(" | "); + lpzOSLanguages += GetLanguageName(LOCALE_USER_DEFAULT); + lpzOSLanguages += _T("/"); + lpzOSLanguages += GetLanguageName(LOCALE_SYSTEM_DEFAULT); + + if (DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", 0)) { + szSystemLocales[0] = '\0'; + lpzOSLanguages += _T(" ["); + EnumSystemLocales(EnumSystemLocalesProc, LCID_INSTALLED); + if (_tcslen(szSystemLocales) > 2) + szSystemLocales[ _tcslen(szSystemLocales) - 2] = '\0'; + + lpzOSLanguages += szSystemLocales; + lpzOSLanguages += _T("]"); + } + + return true; +} + +int SaveInfo(const char *data, const char *lwrData, const char *search, TCHAR *dest, int size) +{ + const char *pos = strstr(lwrData, search); + int res = 1; + if (pos == lwrData) { + _tcsncpy(dest, _A2T(&data[strlen(search)]), size); + res = 0; + } + + return res; +} + +bool CVersionInfo::GetLangpackInfo() +{ + TCHAR langpackPath[MAX_PATH] = {0}; + TCHAR search[MAX_PATH] = {0}; + + lpzLangpackModifiedDate = _T(""); + GetModuleFileName(GetModuleHandle(NULL), langpackPath, SIZEOF(langpackPath)); + TCHAR* p = _tcsrchr(langpackPath, '\\'); + if (p) { + WIN32_FIND_DATA data = {0}; + HANDLE hLangpack; + + p[1] = '\0'; + _tcscpy(search, langpackPath); + _tcscat(search, _T("langpack_*.txt")); + hLangpack = FindFirstFile(search, &data); + if (hLangpack != INVALID_HANDLE_VALUE) { + char buffer[1024]; + char temp[1024]; + FillLocalTime(lpzLangpackModifiedDate, &data.ftLastWriteTime); + + TCHAR locale[128] = {0}; + TCHAR language[128] = {0}; + TCHAR version[128] = {0}; + _tcscpy(version, _T("N/A")); + + _tcsncpy(language, data.cFileName, SIZEOF(language)); + p = _tcsrchr(language, '.'); + p[0] = '\0'; + + _tcscat(langpackPath, data.cFileName); + FILE *fin = _tfopen(langpackPath, _T("rt")); + if (fin) { + size_t len; + while (!feof(fin)) { + fgets(buffer, SIZEOF(buffer), fin); + len = strlen(buffer); + if (buffer[len - 1] == '\n') buffer[len - 1] = '\0'; + strncpy(temp, buffer, SIZEOF(temp)); + _strlwr(temp); + if (SaveInfo(buffer, temp, "language: ", language, SIZEOF(language))) { + if (SaveInfo(buffer, temp, "locale: ", locale, SIZEOF(locale))) { + char* p = strstr(buffer, "; FLID: "); + if (p) { + int ok = 1; + int i; + for (i = 0; ((i < 3) && (ok)); i++) { + p = strrchr(temp, '.'); + if (p) + p[0] = '\0'; + else + ok = 0; + } + p = strrchr(temp, ' '); + if ((ok) && (p)) + _tcsncpy(version, _A2T(&buffer[p - temp + 1]), SIZEOF(version)); + else + _tcsncpy(version, _T(""), SIZEOF(version)); + } } } } + + lpzLangpackInfo = std::tstring(language) + _T(" [") + std::tstring(locale) + _T("]"); + if ( version[0] ) + lpzLangpackInfo += _T(" v. ") + std::tstring(version); + + fclose(fin); + } + else { + int err = GetLastError(); + lpzLangpackInfo = _T(" Could not open file " + std::tstring(data.cFileName)); + } + FindClose(hLangpack); + } + else lpzLangpackInfo = _T("No language pack installed"); + } + + return true; +} + +std::tstring GetPluginTimestamp(FILETIME *fileTime) +{ + SYSTEMTIME sysTime; + FileTimeToSystemTime(fileTime, &sysTime); //convert the file tyme to system time + + //char time[256]; + TCHAR date[256]; //lovely + GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date)); + return date; +} + +bool CVersionInfo::GetPluginLists() +{ + HANDLE hFind; + TCHAR szMirandaPath[MAX_PATH] = { 0 }, szSearchPath[MAX_PATH] = { 0 }; //For search purpose + WIN32_FIND_DATA fd; + TCHAR szMirandaPluginsPath[MAX_PATH] = { 0 }, szPluginPath[MAX_PATH] = { 0 }; //For info reading purpose + BYTE PluginIsEnabled = 0; + HINSTANCE hInstPlugin = NULL; + PLUGININFOEX *(*MirandaPluginInfo)(DWORD); //These two are used to get informations from the plugin. + PLUGININFOEX *pluginInfo = NULL; //Read above. + DWORD mirandaVersion = 0; + BOOL asmCheckOK = FALSE; + DWORD loadError; + // SYSTEMTIME sysTime; //for timestamp + + mirandaVersion=(DWORD)CallService(MS_SYSTEM_GETVERSION,0,0); + { + GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); + TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); + if(str2!=NULL) *str2=0; + } + lpzMirandaPath = szMirandaPath; + + //We got Miranda path, now we'll use it for two different purposes. + //1) finding plugins. + //2) Reading plugin infos + lstrcpyn(szSearchPath,szMirandaPath, MAX_PATH); //We got the path, now we copy it into szSearchPath. We'll use szSearchPath as am auxiliary variable, while szMirandaPath will keep a "fixed" value. + lstrcat(szSearchPath, _T("\\Plugins\\*.dll")); + + lstrcpyn(szMirandaPluginsPath, szMirandaPath, MAX_PATH); + lstrcat(szMirandaPluginsPath, _T("\\Plugins\\")); + + hFind=FindFirstFile(szSearchPath,&fd); + if ( hFind != INVALID_HANDLE_VALUE) { + do { + if (verbose) PUShowMessageT(fd.cFileName, SM_NOTIFY); + if (!ValidExtension(fd.cFileName, _T("dll"))) + continue; //do not report plugins that do not have extension .dll + + hInstPlugin = GetModuleHandle(fd.cFileName); //try to get the handle of the module + + if (hInstPlugin) //if we got it then the dll is loaded (enabled) + PluginIsEnabled = 1; + else { + PluginIsEnabled = 0; + lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\" + lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll" + hInstPlugin = LoadLibrary(szPluginPath); + } + if (!hInstPlugin) { //It wasn't loaded. + loadError = GetLastError(); + int bUnknownError = 1; //assume plugin didn't load because of unknown error + //Some error messages. + //get the dlls the plugin statically links to + if (DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE)) + { + std::tstring linkedModules; + + lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\" + lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll" + if (GetLinkedModulesInfo(szPluginPath, linkedModules)) { + std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); + CPlugin thePlugin(fd.cFileName, _T(""), UUID_NULL, _T(""), 0, time.c_str(), linkedModules.c_str()); + AddPlugin(thePlugin, listUnloadablePlugins); + bUnknownError = 0; //we know why the plugin didn't load + } + } + if (bUnknownError) { //if cause is unknown then report it + std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); + TCHAR buffer[4096]; + TCHAR error[2048]; + //DWORD_PTR arguments[2] = {loadError, 0}; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, loadError, 0, error, SIZEOF(error), NULL); + wsprintf(buffer, _T(" Error %ld - %s"), loadError, error); + CPlugin thePlugin( fd.cFileName, _T(""), UUID_NULL, _T(""), 0, time.c_str(), buffer); + AddPlugin(thePlugin, listUnloadablePlugins); + } + } + else { //It was successfully loaded. + MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfoEx"); + if (!MirandaPluginInfo) + MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfo"); + + if (!MirandaPluginInfo) //There is no function: it's not a valid plugin. Let's move on to the next file. + continue; + + //It's a valid plugin, since we could find MirandaPluginInfo + #if (!defined(WIN64) && !defined(_WIN64)) + asmCheckOK = FALSE; + __asm { + push mirandaVersion + push mirandaVersion + call MirandaPluginInfo + pop eax + pop eax + cmp eax, mirandaVersion + jne a1 + mov asmCheckOK, 0xffffffff + a1: + } + #else + asmCheckOK = TRUE; + #endif + if (asmCheckOK) + pluginInfo = CopyPluginInfo(MirandaPluginInfo(mirandaVersion)); + else { + ZeroMemory(&pluginInfo, sizeof(pluginInfo)); + MessageBox(NULL, fd.cFileName, _T("Invalid plugin"), MB_OK); + } } + + //Let's get the info. + if (MirandaPluginInfo != NULL) {//a valid miranda plugin + if (pluginInfo != NULL) { + //We have loaded the informations into pluginInfo. + std::tstring timedate = GetPluginTimestamp(&fd.ftLastWriteTime); + CPlugin thePlugin(fd.cFileName, _A2T(pluginInfo->shortName), pluginInfo->uuid, (pluginInfo->flags & 1) ? _T("Unicode aware") : _T(""), (DWORD) pluginInfo->version, timedate.c_str(), _T("")); + + if (PluginIsEnabled) + AddPlugin(thePlugin, listActivePlugins); + else { + if ((IsUUIDNull(pluginInfo->uuid)) && (mirandaVersion >= PLUGIN_MAKE_VERSION(0,8,0,9))) { + thePlugin.SetErrorMessage( _T(" Plugin does not have an UUID and will not work with Miranda 0.8.\r\n")); + AddPlugin(thePlugin, listUnloadablePlugins); + } + else AddPlugin(thePlugin, listInactivePlugins); + + FreeLibrary(hInstPlugin); //We don't need it anymore. + } + FreePluginInfo(pluginInfo); + MirandaPluginInfo = NULL; + #ifdef _DEBUG + if (verbose) { + TCHAR szMsg[4096] = { 0 }; + wsprintf(szMsg, _T("Done with: %s"), fd.cFileName); + PUShowMessageT(szMsg, SM_NOTIFY); + } + #endif + } + else { //pluginINFO == NULL + pluginInfo = CopyPluginInfo(MirandaPluginInfo(PLUGIN_MAKE_VERSION(9, 9, 9, 9))); //let's see if the plugin likes this miranda version + char *szShortName = ""; + std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); //get the plugin timestamp; + DWORD version = 0; + if (pluginInfo) { + szShortName = pluginInfo->shortName; + version = pluginInfo->version; + } + + CPlugin thePlugin(fd.cFileName, _A2T(szShortName), (pluginInfo) ? pluginInfo->uuid : UUID_NULL, (((pluginInfo) && (pluginInfo->flags & 1)) ? _T("Unicode aware") : _T("")), version, time.c_str(), _T(" Plugin refuses to load. Miranda version too old.")); + + AddPlugin(thePlugin, listUnloadablePlugins); + if (pluginInfo) + FreePluginInfo(pluginInfo); + } } + } + while (FindNextFile(hFind,&fd)); + FindClose(hFind); + } + return TRUE; +} + +bool CVersionInfo::AddPlugin(CPlugin &aPlugin, std::list &aList) { + std::list::iterator pos = aList.begin(); + bool inserted = FALSE; + + if (aList.begin() == aList.end()) { //It's empty + aList.push_back(aPlugin); + return TRUE; + } + else { //It's not empty + while (pos != aList.end()) { + //It can be either < or >, not equal. + if (aPlugin < (*pos)) { + aList.insert(pos, aPlugin); + return TRUE; + } + + //It's greater: we need to insert it. + pos++; + } } + + if (inserted == FALSE) { + aList.push_back(aPlugin); + return TRUE; + } + return TRUE; +}; + +static char *GetStringFromRVA(DWORD RVA, const LOADED_IMAGE *image) +{ + char *moduleName; + moduleName = (char *) ImageRvaToVa(image->FileHeader, image->MappedAddress, RVA, NULL); + return moduleName; +} + +bool CVersionInfo::GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules) +{ + LOADED_IMAGE image; + ULONG importTableSize; + IMAGE_IMPORT_DESCRIPTOR *importData; + //HMODULE dllModule; + linkedModules = _T(""); + bool result = false; + TCHAR szError[20]; + char* szModuleName = mir_t2a(moduleName); + if (MapAndLoad(szModuleName, NULL, &image, TRUE, TRUE) == FALSE) { + wsprintf(szError, _T("%d"), GetLastError()); + mir_free( szModuleName ); + linkedModules = _T("\r\n"); + return result; + } + mir_free( szModuleName ); + importData = (IMAGE_IMPORT_DESCRIPTOR *) ImageDirectoryEntryToData(image.MappedAddress, FALSE, IMAGE_DIRECTORY_ENTRY_IMPORT, &importTableSize); + if (!importData) { + wsprintf(szError, _T("%d"), GetLastError()); + linkedModules = _T("\r\n"); + } + else { + while (importData->Name) { + char *moduleName; + moduleName = GetStringFromRVA(importData->Name, &image); + if (!DoesDllExist(moduleName)) { + linkedModules.append( _T(" Plugin statically links to missing dll file: ") + std::tstring(_A2T(moduleName)) + _T("\r\n")); + result = true; + } + + importData++; //go to next record + } } + + // FreeLibrary(dllModule); + UnMapAndLoad(&image); //unload the image + return result; +} + +std::tstring CVersionInfo::GetListAsString(std::list &aList, DWORD flags, int beautify) { + std::list::iterator pos = aList.begin(); + std::tstring out = _T(""); +#ifdef _DEBUG + if (verbose) PUShowMessage("CVersionInfo::GetListAsString, begin.", SM_NOTIFY); +#endif + + TCHAR szHeader[32] = {0}; + TCHAR szFooter[32] = {0}; + if ((((flags & VISF_FORUMSTYLE) == VISF_FORUMSTYLE) || beautify) && (DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE))) { + GetStringFromDatabase("BoldBegin", _T("[b]"), szHeader, SIZEOF(szHeader)); + GetStringFromDatabase("BoldEnd", _T("[/b]"), szFooter, SIZEOF(szFooter)); + } + + while (pos != aList.end()) { + out.append(std::tstring((*pos).getInformations(flags, szHeader, szFooter))); + pos++; + } + #ifdef _DEBUG + if (verbose) PUShowMessage("CVersionInfo::GetListAsString, end.", SM_NOTIFY); + #endif + return out; +}; + +void CVersionInfo::BeautifyReport(int beautify, LPCTSTR szBeautifyText, LPCTSTR szNonBeautifyText, std::tstring &out) +{ + if (beautify) + out.append(szBeautifyText); + else + out.append(szNonBeautifyText); +} + +void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautify, std::tstring &out) +{ + if (forumStyle) { //forum style + TCHAR szSize[256], szQuote[256]; + + GetStringFromDatabase("SizeBegin", _T("[size=1]"), szSize, SIZEOF(szSize)); + GetStringFromDatabase("QuoteBegin", _T("[quote]"), szQuote, SIZEOF(szQuote)); + out.append(szQuote); + out.append(szSize); + } + else out = _T(""); + + if (!suppressHeader) { + out.append( _T("Miranda IM - VersionInformation plugin by Hrk, modified by Eblis\r\n")); + if (!forumStyle) { + out.append( _T("Miranda's homepage: http://nightly.miranda.im/\r\n")); //changed homepage + out.append( _T("Miranda tools: http://nightly.miranda.im/\r\n\r\n")); //was missing a / before download + } } + + TCHAR buffer[1024]; //for beautification + GetStringFromDatabase("BeautifyHorizLine", _T("
"), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, _T(""), out); + GetStringFromDatabase("BeautifyBlockStart", _T("
"), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, _T(""), out); + if (!suppressHeader) { + //Time of report: + TCHAR lpzTime[12]; GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("HH':'mm':'ss"), lpzTime, SIZEOF(lpzTime)); + TCHAR lpzDate[32]; GetDateFormat(EnglishLocale, 0, NULL, _T("dd' 'MMMM' 'yyyy"), lpzDate, SIZEOF(lpzDate)); + out.append( _T("Report generated at: ") + std::tstring(lpzTime) + _T(" on ") + std::tstring(lpzDate) + _T("\r\n\r\n")); + } + + //Operating system + out.append(_T("CPU: ") + lpzCPUName + _T(" [") + lpzCPUIdentifier + _T("]")); + if (bDEPEnabled) + out.append(_T(" [DEP enabled]")); + + if (luiProcessors > 1) { + TCHAR noProcs[128]; + wsprintf(noProcs, _T(" [%d CPUs]"), luiProcessors); + out.append(noProcs); + } + out.append( _T("\r\n")); + + //RAM + TCHAR szRAM[64]; wsprintf(szRAM, _T("%d"), luiRAM); + out.append( _T("Installed RAM: ") + std::tstring(szRAM) + _T(" MBytes\r\n")); + + //operating system + out.append( _T("Operating System: ") + lpzOSName + _T(" [version: ") + lpzOSVersion + _T("]\r\n")); + + //shell, IE, administrator + out.append( _T("Shell: ") + lpzShell + _T(", Internet Explorer ") + lpzIEVersion + _T("\r\n")); + out.append( _T("Administrator privileges: ") + lpzAdministratorPrivileges + _T("\r\n")); + + //languages + out.append( _T("OS Languages: ") + lpzOSLanguages + _T("\r\n")); + + //FreeDiskSpace + if (luiFreeDiskSpace) { + TCHAR szDiskSpace[64]; wsprintf(szDiskSpace, _T("%d"), luiFreeDiskSpace); + out.append( _T("Free disk space on Miranda partition: ") + std::tstring(szDiskSpace) + _T(" MBytes\r\n")); + } + + //Miranda + out.append( _T("Miranda path: ") + lpzMirandaPath + _T("\r\n")); + out.append( _T("Miranda IM version: ") + lpzMirandaVersion); + if (bIsWOW64) + out.append( _T(" [running inside WOW64]")); + if (bServiceMode) + out.append( _T(" [service mode]")); + + out.append( _T("\r\nBuild time: ") + lpzBuildTime + _T("\r\n")); + out.append( _T("Profile path: ") + lpzProfilePath + _T("\r\n")); + out.append( _T("Profile size: ") + lpzProfileSize + _T("\r\n")); + out.append( _T("Profile creation date: ") + lpzProfileCreationDate + _T("\r\n")); + out.append( _T("Language pack: ") + lpzLangpackInfo); + out.append((lpzLangpackModifiedDate.size() > 0) ? _T(", modified: ") + lpzLangpackModifiedDate : _T("")); + out.append( _T("\r\n")); + + out.append( _T("Nightly: ") + lpzNightly + _T("\r\n")); + out.append( _T("Unicode core: ") + lpzUnicodeBuild); + + GetStringFromDatabase("BeautifyBlockEnd", _T("
"), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, _T("\r\n"), out); +} + +void CVersionInfo::AddInfoFooter(int suppressFooter, int forumStyle, int beautify, std::tstring &out) +{ + //End of report + TCHAR buffer[1024]; //for beautification purposes + GetStringFromDatabase("BeautifyHorizLine", _T("
"), buffer, SIZEOF(buffer)); + if (!suppressFooter) { + BeautifyReport(beautify, buffer, _T("\r\n"), out); + out.append( _T("\r\nEnd of report.\r\n")); + } + + if (!forumStyle) { + if (!suppressFooter) + out.append( TranslateT("If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!")); + } + else { + TCHAR szSize[256], szQuote[256]; + GetStringFromDatabase("SizeEnd", _T("[/size]"), szSize, SIZEOF(szSize)); + GetStringFromDatabase("QuoteEnd", _T("[/quote]"), szQuote, SIZEOF(szQuote)); + out.append(szSize); + out.append(szQuote); + } +} + +static void AddSectionAndCount(std::list list, LPCTSTR listText, std::tstring &out) +{ + TCHAR tmp[64]; + wsprintf(tmp, _T(" (%u)"), list.size()); + out.append(listText); + out.append( tmp ); + out.append( _T(":")); +} + +std::tstring CVersionInfo::GetInformationsAsString(int bDisableForumStyle) { + //Begin of report + std::tstring out; + int forumStyle = (bDisableForumStyle) ? 0 : DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE); + int showUUID = DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE); + int beautify = DBGetContactSettingByte(NULL, ModuleName, "Beautify", 0) & (!forumStyle); + int suppressHeader = DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE); + + DWORD flags = (forumStyle) | (showUUID << 1); + + AddInfoHeader(suppressHeader, forumStyle, beautify, out); + TCHAR normalPluginsStart[1024]; //for beautification purposes, for normal plugins text (start) + TCHAR normalPluginsEnd[1024]; //for beautification purposes, for normal plugins text (end) + TCHAR horizLine[1024]; //for beautification purposes + TCHAR buffer[1024]; //for beautification purposes + + TCHAR headerHighlightStart[10] = _T(""); + TCHAR headerHighlightEnd[10] = _T(""); + if (forumStyle) { + TCHAR start[128], end[128]; + GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start)); + GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end)); + _tcsncpy(headerHighlightStart, start, SIZEOF(headerHighlightStart)); + _tcsncpy(headerHighlightEnd, end, SIZEOF(headerHighlightEnd)); + } + + //Plugins: list of active (enabled) plugins. + GetStringFromDatabase("BeautifyHorizLine", _T("
"), horizLine, SIZEOF(horizLine)); + BeautifyReport(beautify, horizLine, _T("\r\n"), out); + GetStringFromDatabase("BeautifyActiveHeaderBegin", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightStart, out); + AddSectionAndCount(listActivePlugins, _T("Active Plugins"), out); + GetStringFromDatabase("BeautifyActiveHeaderEnd", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightEnd, out); + out.append( _T("\r\n")); + + GetStringFromDatabase("BeautifyPluginsBegin", _T(""), normalPluginsStart, SIZEOF(normalPluginsStart)); + BeautifyReport(beautify, normalPluginsStart, _T(""), out); + out.append(GetListAsString(listActivePlugins, flags, beautify)); + GetStringFromDatabase("BeautifyPluginsEnd", _T(""), normalPluginsEnd, SIZEOF(normalPluginsEnd)); + BeautifyReport(beautify, normalPluginsEnd, _T(""), out); + //Plugins: list of inactive (disabled) plugins. + if ((!forumStyle) && ((DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE)) || (bServiceMode))) { + BeautifyReport(beautify, horizLine, _T("\r\n"), out); + GetStringFromDatabase("BeautifyInactiveHeaderBegin", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightStart, out); + AddSectionAndCount(listInactivePlugins, _T("Inactive Plugins"), out); + GetStringFromDatabase("BeautifyInactiveHeaderEnd", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightEnd, out); + out.append( _T("\r\n")); + BeautifyReport(beautify, normalPluginsStart, _T(""), out); + out.append(GetListAsString(listInactivePlugins, flags, beautify)); + BeautifyReport(beautify, normalPluginsEnd, _T(""), out); + } + if (listUnloadablePlugins.size() > 0) { + BeautifyReport(beautify, horizLine, _T("\r\n"), out); + GetStringFromDatabase("BeautifyUnloadableHeaderBegin", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightStart, out); + AddSectionAndCount(listUnloadablePlugins, _T("Unloadable Plugins"), out); + GetStringFromDatabase("BeautifyUnloadableHeaderEnd", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightEnd, out); + out.append( _T("\r\n")); + BeautifyReport(beautify, normalPluginsStart, _T(""), out); + out.append(GetListAsString(listUnloadablePlugins, flags, beautify)); + BeautifyReport(beautify, normalPluginsEnd, _T(""), out); + } + AddInfoFooter(suppressHeader, forumStyle, beautify, out); + return out; +} + +//========== Print functions ===== + +void CVersionInfo::PrintInformationsToFile(const TCHAR *info) +{ + TCHAR buffer[MAX_PATH], outputFileName[MAX_PATH]; + if (bFoldersAvailable) { + FoldersGetCustomPathT(hOutputLocation, buffer, SIZEOF(buffer), _T("%miranda_path%")); + _tcscat(buffer, _T("\\VersionInfo.txt")); + } + else GetStringFromDatabase("OutputFile", _T("VersionInfo.txt"), buffer, SIZEOF(buffer)); + + RelativePathToAbsolute(buffer, outputFileName, SIZEOF(buffer)); + + FILE *fp = _tfopen(outputFileName, _T("wb")); + if ( fp != NULL ) { + char* utf = mir_utf8encodeT( info ); + fputs( "\xEF\xBB\xBF", fp); + fputs( utf, fp ); + fclose(fp); + + TCHAR mex[512]; + mir_sntprintf(mex, SIZEOF(mex), TranslateT("Information successfully written to file: \"%s\"."), outputFileName); + Log(mex); + } + else { + TCHAR mex[512]; + mir_sntprintf(mex, SIZEOF(mex), TranslateT("Error during the creation of file \"%s\". Disk may be full or write protected."), outputFileName); + Log(mex); + } +} + +void CVersionInfo::PrintInformationsToFile() +{ + PrintInformationsToFile( GetInformationsAsString().c_str()); +} + +void CVersionInfo::PrintInformationsToMessageBox() +{ + MessageBox(NULL, GetInformationsAsString().c_str(), _T("VersionInfo"), MB_OK); +} + +void CVersionInfo::PrintInformationsToOutputDebugString() +{ + OutputDebugString( GetInformationsAsString().c_str()); +} + + +void CVersionInfo::PrintInformationsToDialogBox() +{ + HWND DialogBox = CreateDialogParam(hInst, + MAKEINTRESOURCE(IDD_DIALOGINFO), + NULL, DialogBoxProc, (LPARAM) this); + + SetDlgItemText(DialogBox, IDC_TEXT, GetInformationsAsString().c_str()); +} + +void CVersionInfo::PrintInformationsToClipboard(bool showLog) +{ + if (GetOpenClipboardWindow()) { + Log( TranslateT("The clipboard is not available, retry.")); + return; + } + + OpenClipboard(NULL); + //Ok, let's begin, then. + EmptyClipboard(); + //Storage data we'll use. + LPTSTR lptstrCopy; + std::tstring aux = GetInformationsAsString(); + size_t length = aux.length() + 1; + HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, length*sizeof(TCHAR) + 5); + //Lock memory, copy it, release it. + lptstrCopy = (LPTSTR)GlobalLock(hData); + lstrcpy(lptstrCopy, aux.c_str()); + lptstrCopy[length] = '\0'; + GlobalUnlock(hData); + //Now set the clipboard data. + + SetClipboardData(CF_UNICODETEXT, hData); + + //Remove the lock on the clipboard. + CloseClipboard(); + if (showLog) + Log( TranslateT("Information successfully copied into clipboard.")); +} diff --git a/plugins/VersionInfo/src/CVersionInfo.h b/plugins/VersionInfo/src/CVersionInfo.h new file mode 100644 index 0000000000..eb55b808fc --- /dev/null +++ b/plugins/VersionInfo/src/CVersionInfo.h @@ -0,0 +1,115 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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 CVERSIONINFO_H +#define CVERSIONINFO_H + +//#define STRICT +#define WIN32_LEAN_AND_MEAN +//#include "AggressiveOptimize.h" + +#define _CRT_SECURE_NO_DEPRECATE + +#ifndef PF_NX_ENABLED + #define PF_NX_ENABLED 12 +#endif + +#include +#include +//using namespace std; + +#include "CPlugin.h" + +class CVersionInfo +{ + private: + //Informations related to Miranda: main informations. + std::tstring lpzMirandaVersion; + std::tstring lpzMirandaPath; + std::tstring lpzProfilePath; + std::tstring lpzProfileSize; + std::tstring lpzProfileCreationDate; + std::tstring lpzNightly; + std::tstring lpzUnicodeBuild; + std::tstring lpzCPUName; + std::tstring lpzCPUIdentifier; + std::tstring lpzBuildTime; + std::tstring lpzShell; + std::tstring lpzIEVersion; + std::tstring lpzAdministratorPrivileges; + std::tstring lpzOSLanguages; + std::tstring lpzLangpackInfo; + std::tstring lpzLangpackModifiedDate; + //Informations related to plugins + std::list listActivePlugins; + std::list listInactivePlugins; + std::list listUnloadablePlugins; + //OS and hardware informations. + std::tstring lpzOSVersion; + std::tstring lpzOSName; + unsigned int luiProcessors; + unsigned int luiRAM; + unsigned int luiFreeDiskSpace; + int bDEPEnabled; + BOOL bIsWOW64; + //Additional Miranda informations. + unsigned int luiContacts; + unsigned int luiEvents; + unsigned int luiUnreadEvents; + unsigned int luiDBSize; + bool bExpertSettingsOn; + //Configuration + + bool GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules); + + public: + //Constructor/Destructor + CVersionInfo(); + ~CVersionInfo(); + void Initialize(); + //Miranda informations + bool GetMirandaVersion(); + bool GetProfileSettings(); + bool GetOSLanguages(); + bool GetLangpackInfo(); + bool GetPluginLists(); + bool GetEventCount(); //TODO + //OSInformations + bool GetOSVersion(); + bool GetHWSettings(); + //Plugins + bool AddPlugin(CPlugin&, std::list&); + //Prints + + void PrintInformationsToFile(); + void PrintInformationsToFile(const TCHAR *info); + void PrintInformationsToDialogBox(); + void PrintInformationsToMessageBox(); + void PrintInformationsToOutputDebugString(); + void PrintInformationsToClipboard(bool); + + std::tstring GetListAsString(std::list&, DWORD flags, int beautify); + std::tstring GetInformationsAsString(int bDisableForumStyle = 0); + void BeautifyReport(int, LPCTSTR, LPCTSTR, std::tstring &); + void AddInfoHeader(int, int, int, std::tstring &); + void AddInfoFooter(int, int, int, std::tstring &); +}; + +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/src/common.h b/plugins/VersionInfo/src/common.h new file mode 100644 index 0000000000..3182abc660 --- /dev/null +++ b/plugins/VersionInfo/src/common.h @@ -0,0 +1,96 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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_VERSIONINFO_COMMON_H +#define M_VERSIONINFO_COMMON_H + +#pragma warning(disable:4005) +#define _CRT_SECURE_NO_DEPRECATE +#pragma warning(default:4005) + +#define VIPF_NONE 0x0000 +#define VIPF_UNCERTAIN 0x0010 + +#define VISF_FORUMSTYLE 0x0001 +#define VISF_SHOWUUID 0x0002 +#define VISF_SHOWFLAGS 0x0004 + +#include +#include + +#include +#include +#include +#include + +#include +//using namespace std; + +#include "version.h" + +#include "m_versioninfo.h" +#include "hooked_events.h" +#include "services.h" +#include "dlgHandlers.h" + +#include "newpluginapi.h" +#include "m_system.h" +#include "m_langpack.h" +#include "m_database.h" +#include "m_skin.h" +#include "m_clist.h" +#include "m_options.h" +#include "m_popup.h" + +#include "m_utils.h" +#include "m_folders.h" +#include "win2k.h" + +#include "utils.h" + +#ifndef MS_DB_GETPROFILEPATH_BASIC //db3xSA +#define MS_DB_GETPROFILEPATH_BASIC "DB/GetProfilePathBasic" +#endif + +//main.cpp +extern HINSTANCE hInst; + +//main.cpp +extern HICON hiVIIcon; + +//main.cpp +extern DWORD EnglishLocale; + +//for folders support +extern BOOL bFoldersAvailable; +extern HANDLE hOutputLocation; + +//services.cpp +extern int bServiceMode; + +//main.cpp +extern char ModuleName[]; +extern BOOL verbose; + +#define DEFAULT_UPLOAD_PORT 51234 + +const MUUID UUID_NULL = {0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}; + +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/src/dlgHandlers.cpp b/plugins/VersionInfo/src/dlgHandlers.cpp new file mode 100644 index 0000000000..a1a81e6a51 --- /dev/null +++ b/plugins/VersionInfo/src/dlgHandlers.cpp @@ -0,0 +1,589 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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 "common.h" +#include "dlgHandlers.h" + +const char *szQuoteStrings[] = {"[quote] | [/quote]", "[code] | [/code]", ""}; +const char *szSizeStrings[] = {"[size=1] | [/size]", "[size=1px] | [/size]", "[size=12] | [/size]", "[size=80] | [/size]", ""}; +const char *szBoldStrings[] = {"[b] | [/b]", "[u] | [/u]", "[b][u] | [/u][/b]", " | ", " | ", " | "}; +const int nQuoteCount = SIZEOF(szQuoteStrings); //get the number of quote strings +const int nSizeCount = SIZEOF(szSizeStrings); //get the number of size strings +const int nBoldCount = SIZEOF(szBoldStrings); //get the number of bold strings + +#define MAX_TEXT 4096*4 + +int AddInfoToComboboxes(HWND hWnd, int nQuotesComboBox, int nSizesComboBox, int nBoldComboBox) +{ + int i; + for (i = 0; i < nQuoteCount; i++) + SendDlgItemMessageA(hWnd, nQuotesComboBox, CB_ADDSTRING, 0, (LPARAM) szQuoteStrings[i]); + + for (i = 0; i < nSizeCount; i++) + SendDlgItemMessageA(hWnd, nSizesComboBox, CB_ADDSTRING, 0, (LPARAM) szSizeStrings[i]); + + for (i = 0; i < nBoldCount; i++) + SendDlgItemMessageA(hWnd, nBoldComboBox, CB_ADDSTRING, 0, (LPARAM) szBoldStrings[i]); + + return 0; +} + +void EnableAskComboboxes(HWND hWnd, int bEnable) +{ + EnableWindow(GetDlgItem(hWnd, IDC_ASK_BOLDCOMBOBOX), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_ASK_QUOTECOMBOBOX), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_ASK_SIZECOMBOBOX), bEnable); +} + +INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + const int MAX_SIZE = 128; + static int oldFSFValue; + static TCHAR oldQuoteBegin[MAX_SIZE], oldQuoteEnd[MAX_SIZE]; + static TCHAR oldSizeBegin[MAX_SIZE], oldSizeEnd[MAX_SIZE]; + static TCHAR oldBoldBegin[MAX_SIZE], oldBoldEnd[MAX_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon); + + TranslateDialogDefault(hWnd); + + oldFSFValue = DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", 1); + + AddInfoToComboboxes(hWnd, IDC_ASK_QUOTECOMBOBOX, IDC_ASK_SIZECOMBOBOX, IDC_ASK_BOLDCOMBOBOX); + + CheckDlgButton(hWnd, IDC_ASK_TODIALOGBOX, BST_CHECKED); + + CheckDlgButton(hWnd, IDC_ASK_FORUMSTYLE, (oldFSFValue) ? BST_CHECKED : BST_UNCHECKED); + EnableAskComboboxes(hWnd, oldFSFValue); + { + TCHAR buffer[1024]; + GetStringFromDatabase("QuoteBegin", _T("[quote]"), oldQuoteBegin, MAX_SIZE); + GetStringFromDatabase("QuoteEnd", _T("[/quote]"), oldQuoteEnd, MAX_SIZE); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldQuoteBegin, oldQuoteEnd); + SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + + GetStringFromDatabase("SizeBegin", _T("[size=1]"), oldSizeBegin, MAX_SIZE); + GetStringFromDatabase("SizeEnd", _T("[/size]"), oldSizeEnd, MAX_SIZE); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldSizeBegin, oldSizeEnd); + SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + + GetStringFromDatabase("BoldBegin", _T("[b]"), oldBoldBegin, MAX_SIZE); + GetStringFromDatabase("BoldEnd", _T("[/b]"), oldBoldEnd, MAX_SIZE); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldBoldBegin, oldBoldEnd); + SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + } + + return TRUE; + + case WM_CLOSE: + DestroyWindow(hWnd); + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_ASK_FORUMSTYLE: + EnableAskComboboxes(hWnd, IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE)); + break; + + case IDC_ASK_CANCEL: + DestroyWindow(hWnd); + break; + + case IDC_ASK_OK: + TCHAR quoteBegin[MAX_SIZE], quoteEnd[MAX_SIZE]; + TCHAR sizeBegin[MAX_SIZE], sizeEnd[MAX_SIZE]; + TCHAR boldBegin[MAX_SIZE], boldEnd[MAX_SIZE]; + TCHAR buffer[1024]; + + SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, quoteBegin, quoteEnd); + SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, sizeBegin, sizeEnd); + SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, boldBegin, boldEnd); + + int newFSFValue = IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE); + if (newFSFValue != oldFSFValue) + DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", newFSFValue); //temporary store the new value + + if (newFSFValue) { + DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", quoteBegin); + DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", quoteEnd); + + DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", sizeBegin); + DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", sizeEnd); + + DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", boldBegin); + DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", boldEnd); + } + + int debugTo = TO_DIALOGBOX; //just to be safe + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOFILE)) + debugTo = TO_FILE; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOMESSAGEBOX)) + debugTo = TO_MESSAGEBOX; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TODIALOGBOX)) + debugTo = TO_DIALOGBOX; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOOUTPUTDEBUGSTRING)) + debugTo = TO_DEBUGSTRING; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOCLIPBOARD)) + debugTo = TO_CLIPBOARD; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOUPLOAD)) + debugTo = TO_UPLOAD; + + DoDebugTo(debugTo); + + if (newFSFValue != oldFSFValue) + DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", oldFSFValue); + + if (newFSFValue) { + DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", oldQuoteBegin); + DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", oldQuoteEnd); + + DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", oldSizeBegin); + DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", oldSizeEnd); + + DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", oldBoldBegin); + DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", oldBoldEnd); + } + + DestroyWindow(hWnd); + break; + } + break; + } + return 0; +} + +int DoDebugTo(int debugTo) +{ + HWND parent = NULL; + HWND askDialog; + CVersionInfo myInfo;// = CVersionInfo(); + if (verbose) PUShowMessage("I am going to read the information.", SM_NOTIFY); + if (debugTo != TO_ASK) + myInfo.Initialize(); + + if (verbose) PUShowMessage("I have read the information, I will now print them.", SM_NOTIFY); + + switch(debugTo) { + case TO_ASK: + askDialog = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ASKDIALOG), parent, AskDlgProc); + ShowWindow(askDialog, SW_SHOW); + break; + + case TO_FILE: + myInfo.PrintInformationsToFile(); + break; + + case TO_MESSAGEBOX: + myInfo.PrintInformationsToMessageBox(); + break; + + case TO_DIALOGBOX: + myInfo.PrintInformationsToDialogBox(); + break; + + case TO_DEBUGSTRING: + myInfo.PrintInformationsToOutputDebugString(); + break; + + case TO_CLIPBOARD: + myInfo.PrintInformationsToClipboard(true); + break; + + default: + myInfo.PrintInformationsToFile(); + break; + } + + if ((debugTo != TO_CLIPBOARD) && (DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE))) + myInfo.PrintInformationsToClipboard(false); + + if ((bServiceMode) && (debugTo != TO_DIALOGBOX) && (debugTo != TO_ASK)) //close miranda if in service mode and no dialog was shown + PostQuitMessage(0); + + return 0; +} + +void EnableUploadSettings(HWND hWnd, int bEnable) +{ + EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PORT), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), bEnable); +} + +INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int bOptionsInitializing = 0; + switch(msg) { + case WM_INITDIALOG: + bOptionsInitializing = 1; + TranslateDialogDefault(hWnd); + AddInfoToComboboxes(hWnd, IDC_QUOTECOMBOBOX, IDC_SIZECOMBOBOX, IDC_BOLDCOMBOBOX); + + CheckDlgButton(hWnd, IDC_FORUMSTYLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_DISABLEDTOO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_SHOWUUIDS, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_SHOWINSTALLEDLANGUAGES, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_SUPPRESSHEADER, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE) ? BST_CHECKED : BST_UNCHECKED); + + CheckDlgButton(hWnd, IDC_SHOWINTASKBAR, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_CLIPBOARDALSO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_BOLDVERSION, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_CHECKUNLOADABLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE) ? BST_CHECKED : BST_UNCHECKED); + SetFocus(GetDlgItem(hWnd, IDC_FORUMSTYLE)); + { + DBVARIANT dbv = { 0 }; + bOptionsInitializing = 1; + TCHAR buffer[1024]; + TCHAR notFound[1024]; + + if (DBGetContactSettingTString(NULL, ModuleName, "OutputFile", &dbv) == 0) + RelativePathToAbsolute(dbv.ptszVal, notFound, SIZEOF(notFound)); + else + RelativePathToAbsolute( _T("VersionInfo.txt"), notFound, SIZEOF(notFound)); + + if (bFoldersAvailable) + _tcscpy(buffer, TranslateT("Customize using folders plugin")); + else + _tcsncpy(buffer, notFound, SIZEOF(notFound)); + + SetDlgItemText(hWnd, IDC_FILENAME, buffer); + + TCHAR start[256], end[256]; + GetStringFromDatabase("QuoteBegin", _T("[quote]"), start, SIZEOF(start)); + GetStringFromDatabase("QuoteEnd", _T("[/quote]"), end, SIZEOF(end)); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); + SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + + GetStringFromDatabase("SizeBegin", _T("[size=1]"), start, SIZEOF(start)); + GetStringFromDatabase("SizeEnd", _T("[/size]"), end, SIZEOF(end)); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); + SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + + GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start)); + GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end)); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); + SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + //to add stuff + + //upload server settings + GetStringFromDatabase("UploadServer", _T("vi.cass.cz"), buffer, SIZEOF(buffer)); + SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), buffer); + + int port = DBGetContactSettingWord(NULL, ModuleName, "UploadPort", DEFAULT_UPLOAD_PORT); + _itot(port, buffer, 10); + SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PORT), buffer); + + GetStringFromDatabase("UploadUser", _T(""), buffer, SIZEOF(buffer)); + SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), buffer); + + GetStringFromDatabase("UploadPassword", _T(""), buffer, SIZEOF(buffer)); + CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(buffer), (LPARAM) buffer); + SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), buffer); + } + + switch(DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX)) { + case TO_FILE: + CheckDlgButton(hWnd, IDC_TOFILE, BST_CHECKED); + break; + + case TO_MESSAGEBOX: + CheckDlgButton(hWnd, IDC_TOMESSAGEBOX, BST_CHECKED); + break; + + case TO_DIALOGBOX: + CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED); + break; + + case TO_DEBUGSTRING: + CheckDlgButton(hWnd, IDC_TODEBUGSTRING, BST_CHECKED); + break; + + case TO_CLIPBOARD: + CheckDlgButton(hWnd, IDC_TOCLIPBOARD, BST_CHECKED); + break; + + case TO_UPLOAD: + CheckDlgButton(hWnd, IDC_TOUPLOAD, BST_CHECKED); + break; + + case TO_ASK: + CheckDlgButton(hWnd, IDC_ASKEVERYTIME, BST_CHECKED); + break; + + default: + CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED); + break; + } + + EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE);//both forum style and bold version checked + EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box + EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins + EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard + EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); + EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE); + { + OSVERSIONINFO osvi = { 0 }; + osvi.dwOSVersionInfoSize = sizeof(osvi); + GetVersionEx(&osvi); + + if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + EnableWindow(GetDlgItem(hWnd, IDC_CHECKUNLOADABLE), FALSE); + } + + CheckDlgButton(hWnd, IDC_DEBUG, (BOOL) verbose == TRUE ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hWnd, IDC_GETINFONOW)); + + bOptionsInitializing = 0; + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDC_ASKEVERYTIME: + case IDC_TOFILE: + case IDC_TOMESSAGEBOX: + case IDC_TODIALOGBOX: + case IDC_TODEBUGSTRING: + case IDC_TOCLIPBOARD: + case IDC_TOUPLOAD: + case IDC_FORUMSTYLE: + case IDC_BOLDVERSION: + EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE); //both forum style and bold version checked + EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); + EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box + EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins + EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard + EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE); + + case IDC_SHOWUUIDS: + if (IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) && MessageBox(hWnd, + TranslateT("Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it."), + TranslateT("Show plugin UUIDs ?"), MB_YESNO | MB_ICONWARNING) == IDNO) + { + CheckDlgButton(hWnd, IDC_SHOWUUIDS, FALSE); + + break; + }//else fallthrough + case IDC_DISABLEDTOO: + case IDC_SHOWINTASKBAR: + case IDC_CLIPBOARDALSO: + case IDC_CHECKUNLOADABLE: + case IDC_SUPPRESSHEADER: + case IDC_SHOWINSTALLEDLANGUAGES: + EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE); + + case IDC_QUOTECOMBOBOX: + case IDC_SIZECOMBOBOX: + case IDC_BOLDCOMBOBOX: + if (!bOptionsInitializing) + SendMessage(GetParent(hWnd), PSM_CHANGED,0,0); + break; + + case IDC_FILENAME: + case IDC_UPLOAD_USERNAME: + case IDC_UPLOAD_PASSWORD: + case IDC_UPLOAD_PORT: + case IDC_UPLOAD_SERVER: + if ( HIWORD(wParam) == EN_CHANGE && !bOptionsInitializing) { + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE); + } + break; + + case IDC_GETINFONOW: + //Call the plugin menu command routine. + PluginMenuCommand(0,0); + break; + + case IDC_DEBUG: + verbose = !verbose; + break; + } + + break; + + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + { + TCHAR buffer[1024]; + TCHAR start[256], end[256]; + SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, start, end); + DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", start); + DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", end); + SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, start, end); + DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", start); + DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", end); + SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, start, end); + DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", start); + DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", end); + } + + DBWriteContactSettingByte(NULL, ModuleName, "CheckForDependencies", IsDlgButtonChecked(hWnd, IDC_CHECKUNLOADABLE) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "BoldVersionNumber", IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "ClipboardAlways", IsDlgButtonChecked(hWnd, IDC_CLIPBOARDALSO) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "SuppressHeader", IsDlgButtonChecked(hWnd, IDC_SUPPRESSHEADER) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "ShowUUIDs", IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", IsDlgButtonChecked(hWnd, IDC_SHOWINSTALLEDLANGUAGES) ? TRUE : FALSE); + + if (!bFoldersAvailable) { + TCHAR filePath[MAX_PATH], fileName[MAX_PATH]; + GetDlgItemText(hWnd, IDC_FILENAME, fileName, MAX_PATH); + AbsolutePathToRelative(fileName, filePath, SIZEOF(filePath)); + + DBWriteContactSettingTString(NULL, ModuleName, "OutputFile", filePath); //store relative path + } + DBWriteContactSettingByte(NULL, ModuleName, "ShowInTaskbar", IsDlgButtonChecked(hWnd, IDC_SHOWINTASKBAR) ? TRUE : FALSE); + //Debug to: + if (IsDlgButtonChecked(hWnd, IDC_TOFILE)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_FILE); + else if (IsDlgButtonChecked(hWnd, IDC_TOMESSAGEBOX)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_MESSAGEBOX); + else if (IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX); + else if (IsDlgButtonChecked(hWnd, IDC_TODEBUGSTRING)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DEBUGSTRING); + else if (IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_CLIPBOARD); + else if (IsDlgButtonChecked(hWnd, IDC_TOUPLOAD)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_UPLOAD); + else if (IsDlgButtonChecked(hWnd, IDC_ASKEVERYTIME)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_ASK); + + EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), TRUE); + //Disabled plugins too? + DBWriteContactSettingByte(NULL, ModuleName, "ShowInactive", IsDlgButtonChecked(hWnd, IDC_DISABLEDTOO)?TRUE:FALSE); + + GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); + } } + + break; + } + return 0; +} + +INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static CVersionInfo *myInfo = NULL; + switch(msg) { + case WM_INITDIALOG: + SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon); + + myInfo = (CVersionInfo *) lParam; + if (DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE)) { + DWORD ws; + ws = GetWindowLongPtr(hWnd, GWL_EXSTYLE); + SetWindowLongPtr(hWnd, GWL_EXSTYLE, ws | WS_EX_APPWINDOW); + //SetWindowLongPtr(hWnd, GWL_STYLE, ws | WS_DLGFRAME | WS_POPUPWINDOW); + } + + TranslateDialogDefault(hWnd); + { + DBVARIANT dbv = { 0 }; + LOGFONT lf = { 0 }; + + dbv.type = DBVT_BLOB; + if (DBGetContactSetting(NULL, "OptionFont", "Font", &dbv) == 0) + lf=*(LOGFONT*)dbv.pbVal; + else { + HFONT hFont = (HFONT)SendDlgItemMessage(hWnd,IDC_CLOSE,WM_GETFONT,0,0); + GetObject(hFont,sizeof(lf),&lf); + } + SendDlgItemMessage(hWnd,IDC_TEXT,WM_SETFONT,(WPARAM)CreateFontIndirect(&lf),0); + } + + return TRUE; + + case WM_CLOSE: + DestroyWindow(hWnd); + break; + + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case IDC_CLOSE: + DestroyWindow(hWnd); + break; + + case IDC_COPYTEXT: + SetLastError(0); + if (GetOpenClipboardWindow()) + Log( TranslateT("The clipboard is not available, retry.")); + else { + OpenClipboard(hWnd); + //Ok, let's begin, then. + EmptyClipboard(); + //Storage data we'll use. + TCHAR text[MAX_TEXT]; + LPTSTR lptstrCopy; + GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT); + int length = lstrlen(text) + 1; + HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, (length + 5)*sizeof( TCHAR )); + //Lock memory, copy it, release it. + lptstrCopy = (LPTSTR)GlobalLock(hData); + lstrcpyn(lptstrCopy, text, length); + lptstrCopy[length] = '\0'; + GlobalUnlock(hData); + //Now set the clipboard data. + + SetClipboardData(CF_UNICODETEXT, hData); + + //Remove the lock on the clipboard. + CloseClipboard(); + } + + break; + + case IDC_SAVETOFILE: + TCHAR text[MAX_TEXT]; + GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT); + myInfo->PrintInformationsToFile(text); + break; + } + + break; + } + case WM_DESTROY: + DeleteObject((HFONT)SendDlgItemMessage(hWnd,IDC_TEXT,WM_GETFONT,0,0)); + myInfo = NULL; + if (bServiceMode) //close miranda if in service mode + PostQuitMessage(0); + + break; + } + return 0; +} diff --git a/plugins/VersionInfo/src/dlgHandlers.h b/plugins/VersionInfo/src/dlgHandlers.h new file mode 100644 index 0000000000..bab1876ea2 --- /dev/null +++ b/plugins/VersionInfo/src/dlgHandlers.h @@ -0,0 +1,43 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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_VERSIONINFO_DLGHEADERS_H +#define M_VERSIONINFO_DLGHEADERS_H + +#include "resource.h" +#include "CVersionInfo.h" + +#define TO_ASK 0 +#define TO_FILE 1 +#define TO_MESSAGEBOX 2 +#define TO_DIALOGBOX 3 +#define TO_DEBUGSTRING 4 +#define TO_CLIPBOARD 5 +#define TO_UPLOAD 6 + +extern INT_PTR PluginMenuCommand(WPARAM, LPARAM); +extern INT_PTR OptionsInitialise(WPARAM, LPARAM); + + +int DoDebugTo(int debugTo); +INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/src/hooked_events.cpp b/plugins/VersionInfo/src/hooked_events.cpp new file mode 100644 index 0000000000..77d72e6a97 --- /dev/null +++ b/plugins/VersionInfo/src/hooked_events.cpp @@ -0,0 +1,80 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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 "common.h" +#include "hooked_events.h" + +HANDLE hModulesLoaded; +HANDLE hOptionsInitialize; + +#define HOST "http://eblis.tla.ro/projects" + +#define VERSIONINFO_VERSION_URL HOST "/miranda/VersionInfo/updater/VersionInfo.html" +#define VERSIONINFO_UPDATE_URL HOST "/miranda/VersionInfo/updater/VersionInfo.zip" +#define VERSIONINFO_VERSION_PREFIX "Version Information version " + +int HookEvents() +{ + hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise); + //hPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); + + return 0; +} + +int UnhookEvents() +{ + UnhookEvent(hModulesLoaded); + UnhookEvent(hOptionsInitialize); + + return 0; +} + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + + bFoldersAvailable = ServiceExists(MS_FOLDERS_REGISTER_PATH); + hOutputLocation = FoldersRegisterCustomPathT("VersionInfo", "Output folder", _T("%miranda_path%")); + + GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); + return 0; +} + +static UINT uiExpertOnlyControls[] = { IDC_SHOWUUIDS, IDC_SHOWINSTALLEDLANGUAGES }; + +int OnOptionsInitialise(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.position = 100000000; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_VERSIONINFO); + odp.pszTitle = LPGEN("Version Information"); + odp.pszGroup = LPGEN("Services"); + odp.groupPosition = 910000000; + odp.flags = ODPF_BOLDGROUPS; + odp.pfnDlgProc = DlgProcOpts; + odp.expertOnlyControls = uiExpertOnlyControls; + odp.nExpertOnlyControls = SIZEOF(uiExpertOnlyControls); + + Options_AddPage(wParam, &odp); + + return 0; +} \ No newline at end of file diff --git a/plugins/VersionInfo/src/hooked_events.h b/plugins/VersionInfo/src/hooked_events.h new file mode 100644 index 0000000000..b75b5e59a8 --- /dev/null +++ b/plugins/VersionInfo/src/hooked_events.h @@ -0,0 +1,33 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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_VERSIONINFO_HOOKED_EVENTS_H +#define M_VERSIONINFO_HOOKED_EVENTS_H + +extern HANDLE hModulesLoaded; +extern HANDLE hOptionsInitialise; + +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/VersionInfo/src/main.cpp b/plugins/VersionInfo/src/main.cpp new file mode 100644 index 0000000000..53c75be86f --- /dev/null +++ b/plugins/VersionInfo/src/main.cpp @@ -0,0 +1,119 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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. +*/ + +#define STRICT +#define WIN32_LEAN_AND_MEAN + +#define _CRT_SECURE_NO_DEPRECATE + +#include "common.h" + +#include "CVersionInfo.h" + +HINSTANCE hInst; + +int hLangpack; + +HICON hiVIIcon; + +DWORD EnglishLocale; + +BOOL bFoldersAvailable = FALSE; +HANDLE hOutputLocation = NULL; //for folders plugin + +void * (* MirandaMalloc)(size_t); +void * (* MirandaRealloc)(void *, size_t); +void (* MirandaFree)(void *); + +char ModuleName[] = "VersionInfo"; + +#ifdef _DEBUG + BOOL verbose = FALSE;//TRUE; +#else + BOOL verbose = FALSE; +#endif + +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + __PLUGIN_DISPLAY_NAME, + VERSION, + __DESC, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {2f174488-489c-4fe1-940d-596cf0f35e65} + {0x2f174488, 0x489c, 0x4fe1, {0x94, 0x0d, 0x59, 0x6c, 0xf0, 0xf3, 0x5e, 0x65}} +}; + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_VERSIONINFO, MIID_SERVICEMODE, MIID_LAST}; + +bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + if (fdwReason == DLL_PROCESS_ATTACH) DisableThreadLibraryCalls(hinstDLL); + EnglishLocale = MAKELCID(MAKELANGID(0x09, 0x01), SORT_DEFAULT); //create our english locale and use it everywhere it's needed + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + + InitServices(); + HookEvents(); + + hiVIIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAIN)); + + //get the name of the dll itself + TCHAR filePath[512] = {0}; + GetModuleFileName(hInst, filePath, SIZEOF(filePath)); + TCHAR *fileName = NULL; + size_t i = _tcslen(filePath) - 1; + _tcslwr(filePath); + + //Menu item + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(mi); + mi.position = mi.popupPosition = 2000089999; + mi.flags = 0; + mi.hIcon = hiVIIcon; + mi.pszName = Translate("Version Information"); + mi.pszService = MS_VERSIONINFO_MENU_COMMAND; + Menu_AddMainMenuItem(&mi); + + if (LoadLibraryA("RichEd32.dll") == NULL) + MessageBoxA(NULL, "d'oh", "d'oh", MB_OK); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + UnhookEvents(); + DestroyServices(); + return 0; +} \ No newline at end of file diff --git a/plugins/VersionInfo/src/resource.h b/plugins/VersionInfo/src/resource.h new file mode 100644 index 0000000000..b282e8bca6 --- /dev/null +++ b/plugins/VersionInfo/src/resource.h @@ -0,0 +1,71 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resource.rc +// +#define IDD_DIALOG1 101 +#define IDD_OPT_VERSIONINFO 102 +#define IDD_DIALOGBOX 103 +#define IDD_DIALOGINFO 103 +#define IDI_ICON1 104 +#define IDI_MAIN 104 +#define IDD_ASKDIALOG 106 +#define IDC_MENUITEM 1000 +#define IDC_TOFILE 1001 +#define IDC_TOMESSAGEBOX 1002 +#define IDC_TODIALOGBOX 1003 +#define IDC_DISABLEDTOO 1004 +#define IDC_FILENAME 1005 +#define IDC_TEXT 1006 +#define IDC_TODEBUGSTRING 1006 +#define IDC_CLOSE 1007 +#define IDC_TOCLIPBOARD 1007 +#define IDC_GETINFONOW 1009 +#define IDC_TOUPLOAD 1010 +#define IDC_GETINFONOW2 1011 +#define IDC_COPYTEXT 1012 +#define IDC_DEBUG 1013 +#define IDC_FORUMSTYLE 1014 +#define IDC_CLIPBOARDALSO 1015 +#define IDC_SHOWINTASKBAR 1016 +#define IDC_QUOTECOMBOBOX 1017 +#define IDC_SIZECOMBOBOX 1018 +#define IDC_BOLDVERSION 1020 +#define IDC_CHECKUNLOADABLE 1021 +#define IDC_ASKEVERYTIME 1022 +#define IDC_ASK_TOFILE 1023 +#define IDC_ASK_TOMESSAGEBOX 1024 +#define IDC_ASK_TODIALOGBOX 1025 +#define IDC_ASK_TOOUTPUTDEBUGSTRING 1026 +#define IDC_ASK_TOCLIPBOARD 1027 +#define IDC_ASK_CANCEL 1028 +#define IDC_ASK_OK 1029 +#define IDC_BOLDCOMBOBOX 1030 +#define IDC_SUPPRESSHEADER 1031 +#define IDC_SHOWHARDWAREINFO 1033 +#define IDC_UPLOAD 1034 +#define IDC_ASK_UPLOAD 1036 +#define IDC_ASK_TOUPLOAD 1036 +#define IDC_UPLOAD_SERVER 1038 +#define IDC_UPLOAD_PORT 1039 +#define IDC_UPLOAD_USERNAME 1040 +#define IDC_UPLOAD_PASSWORD 1041 +#define IDC_TEMPORARY_FORUMSTYLE 1042 +#define IDC_ASK_FORUMSTYLE 1042 +#define IDC_ASK_QUOTECOMBOBOX 1043 +#define IDC_ASK_SIZECOMBOBOX 1044 +#define IDC_ASK_BOLDCOMBOBOX 1045 +#define IDC_SAVETOFILE 1046 +#define IDC_SHOWUUIDS 1048 +#define IDC_CHECK1 1049 +#define IDC_SHOWINSTALLEDLANGUAGES 1049 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 107 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1050 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/VersionInfo/src/services.cpp b/plugins/VersionInfo/src/services.cpp new file mode 100644 index 0000000000..4efa482404 --- /dev/null +++ b/plugins/VersionInfo/src/services.cpp @@ -0,0 +1,76 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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 "common.h" +#include "services.h" + +HANDLE hsMenuCommand; +HANDLE hsGetInfo; +HANDLE hsServiceMode; + +int bServiceMode = 0; //true only if plugin is running in service mode + +int InitServices() +{ + hsMenuCommand = CreateServiceFunction(MS_VERSIONINFO_MENU_COMMAND, PluginMenuCommand); + hsGetInfo = CreateServiceFunction(MS_VERSIONINFO_GETINFO, GetInfoService); + hsServiceMode = CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeService); + return 0; +} + +int DestroyServices() +{ + DestroyServiceFunction(hsMenuCommand); + DestroyServiceFunction(hsGetInfo); + DestroyServiceFunction(hsServiceMode); + return 0; +} + +INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam) +{ + int debugTo = DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX); + DoDebugTo(debugTo); + if (verbose) PUShowMessage("I have printed the information.", SM_NOTIFY); +/* char *data; + CallService(MS_VERSIONINFO_GETINFO, 1, (LPARAM) &data); */ + return 0; +} + +INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam) +{ + int result = 1; //failure + if (lParam != NULL) { + CVersionInfo myInfo; + myInfo.Initialize(); + std::tstring VI = myInfo.GetInformationsAsString(wParam); + char **retData = (char **) lParam; + *retData = mir_utf8encodeT( VI.c_str()); + if (*retData) + result = 0; //success + } + return result; +} + +INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam) +{ + bServiceMode = 1; + DoDebugTo(TO_ASK); + return 0; +} diff --git a/plugins/VersionInfo/src/services.h b/plugins/VersionInfo/src/services.h new file mode 100644 index 0000000000..38acbc7731 --- /dev/null +++ b/plugins/VersionInfo/src/services.h @@ -0,0 +1,31 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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_VERSIONINFO_SERVICES_H +#define M_VERSIONINFO_SERVICES_H + +int InitServices(); +int DestroyServices(); + +INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam); +INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam); +INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam); + +#endif //M_VERSIONINFO_SERVICES_H \ No newline at end of file diff --git a/plugins/VersionInfo/src/utils.cpp b/plugins/VersionInfo/src/utils.cpp new file mode 100644 index 0000000000..9be552c8cc --- /dev/null +++ b/plugins/VersionInfo/src/utils.cpp @@ -0,0 +1,526 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, 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. +*/ + +//#define USE_LOG_FUNCTIONS + +#define STRICT +#define WIN32_LEAN_AND_MEAN + +#include "common.h" +#include "utils.h" + +/* +My usual MessageBoxes :-) +*/ +void MB(const TCHAR* message) +{ + if (verbose) MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONEXCLAMATION); +} + +void Log(const TCHAR* message) +{ + if (ServiceExists(MS_POPUP_ADDPOPUPT)) { + POPUPDATAT pu = {0}; + pu.lchIcon = hiVIIcon; + _tcsncpy(pu.lptzContactName, TranslateT("Version Information"), MAX_CONTACTNAME); + _tcsncpy(pu.lptzText, message, MAX_SECONDLINE); + PUAddPopUpT(&pu); + } + else MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONINFORMATION); +} + +int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText) +{ + const TCHAR *pos = _tcschr(szWholeText, '|'); + if (pos) { + size_t index = pos - szWholeText; + lstrcpyn(szStartText, szWholeText, (int)index); + szStartText[index] = '\0'; + StrTrim(szStartText, _T(" ")); + lstrcpyn(szEndText, pos + 1, (int)_tcslen(pos)); //copies the \0 as well ... :) + StrTrim(szEndText, _T(" ")); + } + else szStartText[0] = szEndText[0] = '\0'; + + return 0; +} + +int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size) +{ + DBVARIANT dbv = {0}; + int res = 1; + size_t len; + if ( DBGetContactSettingTString(NULL, ModuleName, szSettingName, &dbv) == 0) { + res = 0; + size_t tmp = _tcslen(dbv.ptszVal); + len = (tmp < size - 1) ? tmp : size - 1; + _tcsncpy(szResult, dbv.ptszVal, len); + szResult[len] = '\0'; + mir_free(dbv.ptszVal); + } + else { + res = 1; + size_t tmp = _tcslen(szError); + len = (tmp < size - 1) ? tmp : size - 1; + _tcsncpy(szResult, szError, len); + szResult[len] = '\0'; + } + return res; +} + +TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size) +{ + if (size < MAX_PATH) { + TCHAR buffer[MAX_PATH]; //new path should be at least MAX_PATH chars + CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) buffer); + _tcsncpy(szAbsolute, buffer, size); + } + else CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) szAbsolute); + + return szAbsolute; +} + +TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size) +{ + if (size < MAX_PATH) { + TCHAR buffer[MAX_PATH]; + CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative); + _tcsncpy(szRelative, buffer, size); + } + else CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative); + + return szRelative; +} + +#define GetFacility(dwError) (HIWORD(dwError) && 0x0000111111111111) +#define GetErrorCode(dwError) (LOWORD(dwError)) + +void NotifyError(DWORD dwError, const TCHAR* szSetting, int iLine) +{ + TCHAR str[1024]; + mir_sntprintf(str, SIZEOF(str), TranslateT("Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d"), szSetting, GetFacility(dwError), GetErrorCode(dwError), iLine); + Log(str); +} + +TCHAR *StrTrim(TCHAR *szText, const TCHAR *szTrimChars) +{ + size_t i = _tcslen(szText) - 1; + while (i >= 0 && _tcschr(szTrimChars, szText[i])) + szText[i--] = '\0'; + + i = 0; + while (((unsigned int )i < _tcslen(szText)) && _tcschr(szTrimChars, szText[i])) + i++; + + if (i) { + size_t size = _tcslen(szText); + size_t j; + for (j = i; j <= size; j++) //shift the \0 as well + szText[j - i] = szText[j]; + } + return szText; +} + +bool DoesDllExist(char *dllName) +{ + HMODULE dllHandle; + dllHandle = LoadLibraryExA(dllName, NULL, DONT_RESOLVE_DLL_REFERENCES); + if (dllHandle) + { + FreeLibrary(dllHandle); + return true; + } + return false; +} + +//========== From Cyreve ========== +PLUGININFOEX *GetPluginInfo(const TCHAR *filename,HINSTANCE *hPlugin) +{ + TCHAR szMirandaPath[MAX_PATH], szPluginPath[MAX_PATH]; + PLUGININFOEX *(*MirandaPluginInfo)(DWORD); + PLUGININFOEX *pPlugInfo; + HMODULE hLoadedModule; + DWORD mirandaVersion = CallService(MS_SYSTEM_GETVERSION,0,0); + + GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); + TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); + if(str2!=NULL) *str2=0; + + hLoadedModule = GetModuleHandle(filename); + if(hLoadedModule!=NULL) { + *hPlugin=NULL; + MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(hLoadedModule,"MirandaPluginInfo"); + return MirandaPluginInfo(mirandaVersion); + } + wsprintf(szPluginPath, _T("%s\\Plugins\\%s"), szMirandaPath, filename); + *hPlugin=LoadLibrary(szPluginPath); + if (*hPlugin==NULL) return NULL; + MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(*hPlugin,"MirandaPluginInfo"); + if(MirandaPluginInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} + pPlugInfo=MirandaPluginInfo(mirandaVersion); + if(pPlugInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} + if(pPlugInfo->cbSize != sizeof(PLUGININFOEX)) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} + return pPlugInfo; +} + +//========== from Frank Cheng (wintime98) ========== +// I've changed something to suit VersionInfo :-) +#include + +void TimeStampToSysTime(DWORD Unix,SYSTEMTIME* SysTime) +{ + SYSTEMTIME S; + DWORDLONG FileReal,UnixReal; + S.wYear=1970; + S.wMonth=1; + S.wDay=1; + S.wHour=0; + S.wMinute=0; + S.wSecond=0; + S.wMilliseconds=0; + SystemTimeToFileTime(&S,(FILETIME*)&FileReal); + UnixReal = Unix; + UnixReal*=10000000; + FileReal+=UnixReal; + FileTimeToSystemTime((FILETIME*)&FileReal,SysTime); +} + +void GetModuleTimeStamp(TCHAR* ptszDate, TCHAR* ptszTime) +{ + TCHAR tszModule[MAX_PATH]; + HANDLE mapfile,file; + DWORD timestamp,filesize; + LPVOID mapmem; + SYSTEMTIME systime; + GetModuleFileName(NULL,tszModule,SIZEOF(tszModule)); + file = CreateFile(tszModule,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); + filesize = GetFileSize(file,NULL); + mapfile = CreateFileMapping(file, NULL, PAGE_READONLY, 0, filesize, NULL); + mapmem = MapViewOfFile(mapfile, FILE_MAP_READ, 0, 0, 0); + timestamp = GetTimestampForLoadedLibrary((HINSTANCE)mapmem); + TimeStampToSysTime(timestamp,&systime); + GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, _T("HH':'mm':'ss"), ptszTime, 40 ); + GetDateFormat(EnglishLocale, 0, &systime, _T("dd' 'MMMM' 'yyyy"), ptszDate, 40); + UnmapViewOfFile(mapmem); + CloseHandle(mapfile); + CloseHandle(file); +} + +//From Egodust or Cyreve... I don't really know. +PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *piSrc) +{ + if(piSrc==NULL) + return NULL; + + PLUGININFOEX *pi = (PLUGININFOEX *)malloc(sizeof(PLUGININFOEX)); + *pi = *piSrc; + + if (piSrc->cbSize >= sizeof(PLUGININFOEX)) + pi->uuid = piSrc->uuid; + else + pi->uuid = UUID_NULL; + + if (pi->author) pi->author = _strdup(pi->author); + if (pi->authorEmail) pi->authorEmail = _strdup(pi->authorEmail); + if (pi->copyright) pi->copyright = _strdup(pi->copyright); + if (pi->description) pi->description = _strdup(pi->description); + if (pi->homepage) pi->homepage = _strdup(pi->homepage); + if (pi->shortName) pi->shortName = _strdup(pi->shortName); + return pi; +} + +void FreePluginInfo(PLUGININFOEX *pi) +{ + if (pi->author) free(pi->author); + if (pi->authorEmail) free(pi->authorEmail); + if (pi->copyright) free(pi->copyright); + if (pi->description) free(pi->description); + if (pi->homepage) free(pi->homepage); + if (pi->shortName) free(pi->shortName); + free(pi); +} + +BOOL IsCurrentUserLocalAdministrator(void) +{ + BOOL fReturn = FALSE; + DWORD dwStatus; + DWORD dwAccessMask; + DWORD dwAccessDesired; + DWORD dwACLSize; + DWORD dwStructureSize = sizeof(PRIVILEGE_SET); + PACL pACL = NULL; + PSID psidAdmin = NULL; + + HANDLE hToken = NULL; + HANDLE hImpersonationToken = NULL; + + PRIVILEGE_SET ps; + GENERIC_MAPPING GenericMapping; + + PSECURITY_DESCRIPTOR psdAdmin = NULL; + SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY; + + /* + Determine if the current thread is running as a user that is a member of + the local admins group. To do this, create a security descriptor that + has a DACL which has an ACE that allows only local aministrators access. + Then, call AccessCheck with the current thread's token and the security + descriptor. It will say whether the user could access an object if it + had that security descriptor. Note: you do not need to actually create + the object. Just checking access against the security descriptor alone + will be sufficient. + */ + const DWORD ACCESS_READ = 1; + const DWORD ACCESS_WRITE = 2; + + + __try + { + + /* + AccessCheck() requires an impersonation token. We first get a primary + token and then create a duplicate impersonation token. The + impersonation token is not actually assigned to the thread, but is + used in the call to AccessCheck. Thus, this function itself never + impersonates, but does use the identity of the thread. If the thread + was impersonating already, this function uses that impersonation context. + */ + if (!OpenThreadToken(GetCurrentThread(), TOKEN_DUPLICATE|TOKEN_QUERY, TRUE, &hToken)) + { + if (GetLastError() != ERROR_NO_TOKEN) + __leave; + + if (!OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &hToken)) + __leave; + } + + if (!DuplicateToken (hToken, SecurityImpersonation, &hImpersonationToken)) + __leave; + + + /* + Create the binary representation of the well-known SID that + represents the local administrators group. Then create the security + descriptor and DACL with an ACE that allows only local admins access. + After that, perform the access check. This will determine whether + the current user is a local admin. + */ + if (!AllocateAndInitializeSid(&SystemSidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &psidAdmin)) + __leave; + + psdAdmin = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); + if (psdAdmin == NULL) + __leave; + + if (!InitializeSecurityDescriptor(psdAdmin, SECURITY_DESCRIPTOR_REVISION)) + __leave; + + // Compute size needed for the ACL. + dwACLSize = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(psidAdmin) - sizeof(DWORD); + + pACL = (PACL)LocalAlloc(LPTR, dwACLSize); + if (pACL == NULL) + __leave; + + if (!InitializeAcl(pACL, dwACLSize, ACL_REVISION2)) + __leave; + + dwAccessMask= ACCESS_READ | ACCESS_WRITE; + + if (!AddAccessAllowedAce(pACL, ACL_REVISION2, dwAccessMask, psidAdmin)) + __leave; + + if (!SetSecurityDescriptorDacl(psdAdmin, TRUE, pACL, FALSE)) + __leave; + + /* + AccessCheck validates a security descriptor somewhat; set the group + and owner so that enough of the security descriptor is filled out to + make AccessCheck happy. + */ + SetSecurityDescriptorGroup(psdAdmin, psidAdmin, FALSE); + SetSecurityDescriptorOwner(psdAdmin, psidAdmin, FALSE); + + if (!IsValidSecurityDescriptor(psdAdmin)) + __leave; + + dwAccessDesired = ACCESS_READ; + + /* + Initialize GenericMapping structure even though you + do not use generic rights. + */ + GenericMapping.GenericRead = ACCESS_READ; + GenericMapping.GenericWrite = ACCESS_WRITE; + GenericMapping.GenericExecute = 0; + GenericMapping.GenericAll = ACCESS_READ | ACCESS_WRITE; + + if (!AccessCheck(psdAdmin, hImpersonationToken, dwAccessDesired, &GenericMapping, &ps, &dwStructureSize, &dwStatus, &fReturn)) + { + fReturn = FALSE; + __leave; + } + } + __finally + { + // Clean up. + if (pACL) LocalFree(pACL); + if (psdAdmin) LocalFree(psdAdmin); + if (psidAdmin) FreeSid(psidAdmin); + if (hImpersonationToken) CloseHandle (hImpersonationToken); + if (hToken) CloseHandle (hToken); + } + + return fReturn; +} + +BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize) +{ + OSVERSIONINFO vi = {0}; + vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&vi); + + TCHAR szShell[1024] = {0}; + DWORD size = SIZEOF(szShell); + + if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + HKEY hKey; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\system.ini\\boot"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size); + _tcslwr(szShell); + HKEY hRootKey = ( _tcsstr(szShell, _T("sys:")) == szShell) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + RegCloseKey(hKey); + + _tcscpy(szShell, _T("")); + if (RegOpenKeyEx(hRootKey, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + size = SIZEOF(szShell); + RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size); + RegCloseKey(hKey); + } + } + } + else{ + TCHAR szSystemIniPath[2048]; + GetWindowsDirectory(szSystemIniPath, SIZEOF(szSystemIniPath)); + size_t len = lstrlen(szSystemIniPath); + if (len > 0) + { + if (szSystemIniPath[len - 1] == '\\') { szSystemIniPath[--len] = '\0'; } + _tcscat(szSystemIniPath, _T("\\system.ini")); + GetPrivateProfileString( _T("boot"), _T("shell"), _T(""), szShell, size, szSystemIniPath); + } + } + + TCHAR *pos = _tcsrchr(szShell, '\\'); + TCHAR *res = (pos) ? pos + 1 : szShell; + _tcsncpy(shellPath, res, shSize); + + return TRUE; +} + +BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize) +{ + HKEY hKey; + TCHAR ieVer[1024]; + DWORD size = SIZEOF(ieVer); + TCHAR ieBuild[64] = {0}; + + _tcsncpy(ieVer, _T(""), size); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + if (RegQueryValueEx(hKey, _T("Version"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) + { + TCHAR *pos = _tcschr(ieVer, '.'); + if (pos) + { + pos = _tcschr(pos + 1, '.'); + if (pos) { *pos = 0; } + _tcsncpy(ieBuild, pos + 1, SIZEOF(ieBuild)); + pos = _tcschr(ieBuild, '.'); + if (pos) { *pos = 0; } + } + } + else{ + size = SIZEOF(ieVer); + if (RegQueryValueEx(hKey, _T("Build"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) + { + TCHAR *pos = ieVer + 1; + _tcsncpy(ieBuild, pos, SIZEOF(ieBuild)); + *pos = 0; + pos = _tcschr(ieBuild, '.'); + if (pos) { *pos = 0; } + } + else{ + _tcsncpy(ieVer, _T(""), size); + } + } + RegCloseKey(hKey); + } + + _tcsncpy(ieVersion, ieVer, ieSize); + if ( ieBuild[0] ) + { + _tcsncat(ieVersion, _T("."), ieSize); + _tcsncat(ieVersion, ieBuild, ieSize); + } + + return TRUE; +} + + +TCHAR *GetLanguageName(LANGID language) +{ + LCID lc = MAKELCID(language, SORT_DEFAULT); + return GetLanguageName(lc); +} + +extern TCHAR *GetLanguageName(LCID locale) +{ + static TCHAR name[1024]; + GetLocaleInfo(locale, LOCALE_SENGLANGUAGE, name, SIZEOF(name)); + return name; +} + +BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len) +{ + if ( len < sizeof(MUUID) || !str ) + return 0; + + mir_sntprintf(str, len, _T("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), uuid.a, uuid.b, uuid.c, uuid.d[0], uuid.d[1], uuid.d[2], uuid.d[3], uuid.d[4], uuid.d[5], uuid.d[6], uuid.d[7]); + return 1; +} + +BOOL IsUUIDNull(MUUID uuid) +{ + int i; + for (i = 0; i < sizeof(uuid.d); i++) + { + if (uuid.d[i]) + { + return 0; + } + } + + return ((uuid.a == 0) && (uuid.b == 0) && (uuid.c == 0)); +} \ No newline at end of file diff --git a/plugins/VersionInfo/src/utils.h b/plugins/VersionInfo/src/utils.h new file mode 100644 index 0000000000..5db4b1a811 --- /dev/null +++ b/plugins/VersionInfo/src/utils.h @@ -0,0 +1,49 @@ +#ifndef _M_VERSIONINFO_UTILS_H +#define _M_VERSIONINFO_UTILS_H + +#include "common.h" + +//utils.cpp +void MB(const TCHAR*); +void Log(const TCHAR*); +TCHAR *StrTrim(TCHAR *, const TCHAR *); + +//utils.cpp +TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size); +TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size); + +//returns a string from the database and uses MirandaFree to deallocate the string, leaving only the local copy +//utils.cpp +int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size); + +//a string of the form %s(start) | %s(end) is split into the two strings (start and end) +//utils.cpp +int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText); + +//utils.cpp +bool DoesDllExist(char *dllName); + +//utils.cpp +void GetModuleTimeStamp(TCHAR*, TCHAR*); +void NotifyError(DWORD, const TCHAR*, int); + +//utils.cpp +PLUGININFOEX *GetPluginInfo(const char *,HINSTANCE *); +PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *); +void FreePluginInfo(PLUGININFOEX *); + +//utils.cpp + +BOOL IsCurrentUserLocalAdministrator(); + +TCHAR *GetLanguageName(LANGID language); +TCHAR *GetLanguageName(LCID locale); + +BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize); +BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize); + +BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len); + +BOOL IsUUIDNull(MUUID uuid); + +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/src/version.h b/plugins/VersionInfo/src/version.h new file mode 100644 index 0000000000..7c0596e2c9 --- /dev/null +++ b/plugins/VersionInfo/src/version.h @@ -0,0 +1,44 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2005 Luca Santarelli, © 2005-2008 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_VERSIONINFO_VERSION_H +#define M_VERSIONINFO_VERSION_H + +#define __MAJOR_VERSION 1 +#define __MINOR_VERSION 5 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 3 + +#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 "Collects and prints information related to Miranda, the plugins and the OS." +#define __AUTHOR "Luca Santarelli, Cristian Libotean, George Hazan" +#define __AUTHOREMAIL "hrk@users.sourceforge.net, eblis102@yahoo.com, ghazan@miranda.im" +#define __COPYRIGHT "© 2002-2005 Luca Santarelli, © 2005-2009 Cristian Libotean" +#define __AUTHORWEB "http://nightly.miranda.im/" +#define __PLUGIN_DISPLAY_NAME "Version Information" + +#endif //M_VERSIONINFO_VERSION_H diff --git a/plugins/VersionInfo/svc_vi-translation.txt b/plugins/VersionInfo/svc_vi-translation.txt deleted file mode 100644 index 719f0beb2c..0000000000 --- a/plugins/VersionInfo/svc_vi-translation.txt +++ /dev/null @@ -1,56 +0,0 @@ -; Common strings that belong to many files -;[The clipboard is not available, retry.] -;[Version Information] - -; ../../plugins/Svc_vi/CVersionInfo.cpp -;[Error during the creation of file \"%s\". Disk may be full or write protected.] -;[If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!] -;[Information successfully copied into clipboard.] -;[Information successfully written to file: \"%s\".] - -; ../../plugins/Svc_vi/dlgHandlers.cpp -;[Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it.] -;[Customize using folders plugin] -;[Show plugin UUIDs ?] - -; ../../plugins/Svc_vi/hooked_events.cpp -;[Services] - -; ../../plugins/Svc_vi/main.cpp -;[Please rename the plugin '%s' to 'svc_vi.dll' to enable service mode functionality.] - -; ../../plugins/Svc_vi/resource.rc -;[&Copy text] -;[&Save to file] -;[Aditional options:] -;[Also copy info to clipboard] -;[Ask every time] -;[Attempt to find unloadable plugins (doesn't work on Windows 98)] -;[Cancel] -;[Clipboard] -;[Close] -;[DialogBox] -;[Do it now] -;[Enable debug messages] -;[Forum style formatting] -;[Highlight version number using] -;[MessageBox()] -;[Miranda Version Information] -;[OK] -;[Output to:] -;[OutputDebugString()] -;[Password] -;[Select output:] -;[Show disabled plugins too] -;[Show installed languages] -;[Show plugin UUIDs] -;[Show window in taskbar] -;[Suppress header information] -;[Text file] -;[Upload] -;[Upload site settings] -;[Upload to site] -;[Username] - -; ../../plugins/Svc_vi/utils.cpp -;[Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d] diff --git a/plugins/VersionInfo/utils.cpp b/plugins/VersionInfo/utils.cpp deleted file mode 100644 index 9be552c8cc..0000000000 --- a/plugins/VersionInfo/utils.cpp +++ /dev/null @@ -1,526 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, 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. -*/ - -//#define USE_LOG_FUNCTIONS - -#define STRICT -#define WIN32_LEAN_AND_MEAN - -#include "common.h" -#include "utils.h" - -/* -My usual MessageBoxes :-) -*/ -void MB(const TCHAR* message) -{ - if (verbose) MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONEXCLAMATION); -} - -void Log(const TCHAR* message) -{ - if (ServiceExists(MS_POPUP_ADDPOPUPT)) { - POPUPDATAT pu = {0}; - pu.lchIcon = hiVIIcon; - _tcsncpy(pu.lptzContactName, TranslateT("Version Information"), MAX_CONTACTNAME); - _tcsncpy(pu.lptzText, message, MAX_SECONDLINE); - PUAddPopUpT(&pu); - } - else MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONINFORMATION); -} - -int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText) -{ - const TCHAR *pos = _tcschr(szWholeText, '|'); - if (pos) { - size_t index = pos - szWholeText; - lstrcpyn(szStartText, szWholeText, (int)index); - szStartText[index] = '\0'; - StrTrim(szStartText, _T(" ")); - lstrcpyn(szEndText, pos + 1, (int)_tcslen(pos)); //copies the \0 as well ... :) - StrTrim(szEndText, _T(" ")); - } - else szStartText[0] = szEndText[0] = '\0'; - - return 0; -} - -int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size) -{ - DBVARIANT dbv = {0}; - int res = 1; - size_t len; - if ( DBGetContactSettingTString(NULL, ModuleName, szSettingName, &dbv) == 0) { - res = 0; - size_t tmp = _tcslen(dbv.ptszVal); - len = (tmp < size - 1) ? tmp : size - 1; - _tcsncpy(szResult, dbv.ptszVal, len); - szResult[len] = '\0'; - mir_free(dbv.ptszVal); - } - else { - res = 1; - size_t tmp = _tcslen(szError); - len = (tmp < size - 1) ? tmp : size - 1; - _tcsncpy(szResult, szError, len); - szResult[len] = '\0'; - } - return res; -} - -TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size) -{ - if (size < MAX_PATH) { - TCHAR buffer[MAX_PATH]; //new path should be at least MAX_PATH chars - CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) buffer); - _tcsncpy(szAbsolute, buffer, size); - } - else CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) szAbsolute); - - return szAbsolute; -} - -TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size) -{ - if (size < MAX_PATH) { - TCHAR buffer[MAX_PATH]; - CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative); - _tcsncpy(szRelative, buffer, size); - } - else CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative); - - return szRelative; -} - -#define GetFacility(dwError) (HIWORD(dwError) && 0x0000111111111111) -#define GetErrorCode(dwError) (LOWORD(dwError)) - -void NotifyError(DWORD dwError, const TCHAR* szSetting, int iLine) -{ - TCHAR str[1024]; - mir_sntprintf(str, SIZEOF(str), TranslateT("Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d"), szSetting, GetFacility(dwError), GetErrorCode(dwError), iLine); - Log(str); -} - -TCHAR *StrTrim(TCHAR *szText, const TCHAR *szTrimChars) -{ - size_t i = _tcslen(szText) - 1; - while (i >= 0 && _tcschr(szTrimChars, szText[i])) - szText[i--] = '\0'; - - i = 0; - while (((unsigned int )i < _tcslen(szText)) && _tcschr(szTrimChars, szText[i])) - i++; - - if (i) { - size_t size = _tcslen(szText); - size_t j; - for (j = i; j <= size; j++) //shift the \0 as well - szText[j - i] = szText[j]; - } - return szText; -} - -bool DoesDllExist(char *dllName) -{ - HMODULE dllHandle; - dllHandle = LoadLibraryExA(dllName, NULL, DONT_RESOLVE_DLL_REFERENCES); - if (dllHandle) - { - FreeLibrary(dllHandle); - return true; - } - return false; -} - -//========== From Cyreve ========== -PLUGININFOEX *GetPluginInfo(const TCHAR *filename,HINSTANCE *hPlugin) -{ - TCHAR szMirandaPath[MAX_PATH], szPluginPath[MAX_PATH]; - PLUGININFOEX *(*MirandaPluginInfo)(DWORD); - PLUGININFOEX *pPlugInfo; - HMODULE hLoadedModule; - DWORD mirandaVersion = CallService(MS_SYSTEM_GETVERSION,0,0); - - GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); - TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); - if(str2!=NULL) *str2=0; - - hLoadedModule = GetModuleHandle(filename); - if(hLoadedModule!=NULL) { - *hPlugin=NULL; - MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(hLoadedModule,"MirandaPluginInfo"); - return MirandaPluginInfo(mirandaVersion); - } - wsprintf(szPluginPath, _T("%s\\Plugins\\%s"), szMirandaPath, filename); - *hPlugin=LoadLibrary(szPluginPath); - if (*hPlugin==NULL) return NULL; - MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(*hPlugin,"MirandaPluginInfo"); - if(MirandaPluginInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} - pPlugInfo=MirandaPluginInfo(mirandaVersion); - if(pPlugInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} - if(pPlugInfo->cbSize != sizeof(PLUGININFOEX)) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} - return pPlugInfo; -} - -//========== from Frank Cheng (wintime98) ========== -// I've changed something to suit VersionInfo :-) -#include - -void TimeStampToSysTime(DWORD Unix,SYSTEMTIME* SysTime) -{ - SYSTEMTIME S; - DWORDLONG FileReal,UnixReal; - S.wYear=1970; - S.wMonth=1; - S.wDay=1; - S.wHour=0; - S.wMinute=0; - S.wSecond=0; - S.wMilliseconds=0; - SystemTimeToFileTime(&S,(FILETIME*)&FileReal); - UnixReal = Unix; - UnixReal*=10000000; - FileReal+=UnixReal; - FileTimeToSystemTime((FILETIME*)&FileReal,SysTime); -} - -void GetModuleTimeStamp(TCHAR* ptszDate, TCHAR* ptszTime) -{ - TCHAR tszModule[MAX_PATH]; - HANDLE mapfile,file; - DWORD timestamp,filesize; - LPVOID mapmem; - SYSTEMTIME systime; - GetModuleFileName(NULL,tszModule,SIZEOF(tszModule)); - file = CreateFile(tszModule,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); - filesize = GetFileSize(file,NULL); - mapfile = CreateFileMapping(file, NULL, PAGE_READONLY, 0, filesize, NULL); - mapmem = MapViewOfFile(mapfile, FILE_MAP_READ, 0, 0, 0); - timestamp = GetTimestampForLoadedLibrary((HINSTANCE)mapmem); - TimeStampToSysTime(timestamp,&systime); - GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, _T("HH':'mm':'ss"), ptszTime, 40 ); - GetDateFormat(EnglishLocale, 0, &systime, _T("dd' 'MMMM' 'yyyy"), ptszDate, 40); - UnmapViewOfFile(mapmem); - CloseHandle(mapfile); - CloseHandle(file); -} - -//From Egodust or Cyreve... I don't really know. -PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *piSrc) -{ - if(piSrc==NULL) - return NULL; - - PLUGININFOEX *pi = (PLUGININFOEX *)malloc(sizeof(PLUGININFOEX)); - *pi = *piSrc; - - if (piSrc->cbSize >= sizeof(PLUGININFOEX)) - pi->uuid = piSrc->uuid; - else - pi->uuid = UUID_NULL; - - if (pi->author) pi->author = _strdup(pi->author); - if (pi->authorEmail) pi->authorEmail = _strdup(pi->authorEmail); - if (pi->copyright) pi->copyright = _strdup(pi->copyright); - if (pi->description) pi->description = _strdup(pi->description); - if (pi->homepage) pi->homepage = _strdup(pi->homepage); - if (pi->shortName) pi->shortName = _strdup(pi->shortName); - return pi; -} - -void FreePluginInfo(PLUGININFOEX *pi) -{ - if (pi->author) free(pi->author); - if (pi->authorEmail) free(pi->authorEmail); - if (pi->copyright) free(pi->copyright); - if (pi->description) free(pi->description); - if (pi->homepage) free(pi->homepage); - if (pi->shortName) free(pi->shortName); - free(pi); -} - -BOOL IsCurrentUserLocalAdministrator(void) -{ - BOOL fReturn = FALSE; - DWORD dwStatus; - DWORD dwAccessMask; - DWORD dwAccessDesired; - DWORD dwACLSize; - DWORD dwStructureSize = sizeof(PRIVILEGE_SET); - PACL pACL = NULL; - PSID psidAdmin = NULL; - - HANDLE hToken = NULL; - HANDLE hImpersonationToken = NULL; - - PRIVILEGE_SET ps; - GENERIC_MAPPING GenericMapping; - - PSECURITY_DESCRIPTOR psdAdmin = NULL; - SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY; - - /* - Determine if the current thread is running as a user that is a member of - the local admins group. To do this, create a security descriptor that - has a DACL which has an ACE that allows only local aministrators access. - Then, call AccessCheck with the current thread's token and the security - descriptor. It will say whether the user could access an object if it - had that security descriptor. Note: you do not need to actually create - the object. Just checking access against the security descriptor alone - will be sufficient. - */ - const DWORD ACCESS_READ = 1; - const DWORD ACCESS_WRITE = 2; - - - __try - { - - /* - AccessCheck() requires an impersonation token. We first get a primary - token and then create a duplicate impersonation token. The - impersonation token is not actually assigned to the thread, but is - used in the call to AccessCheck. Thus, this function itself never - impersonates, but does use the identity of the thread. If the thread - was impersonating already, this function uses that impersonation context. - */ - if (!OpenThreadToken(GetCurrentThread(), TOKEN_DUPLICATE|TOKEN_QUERY, TRUE, &hToken)) - { - if (GetLastError() != ERROR_NO_TOKEN) - __leave; - - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &hToken)) - __leave; - } - - if (!DuplicateToken (hToken, SecurityImpersonation, &hImpersonationToken)) - __leave; - - - /* - Create the binary representation of the well-known SID that - represents the local administrators group. Then create the security - descriptor and DACL with an ACE that allows only local admins access. - After that, perform the access check. This will determine whether - the current user is a local admin. - */ - if (!AllocateAndInitializeSid(&SystemSidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &psidAdmin)) - __leave; - - psdAdmin = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); - if (psdAdmin == NULL) - __leave; - - if (!InitializeSecurityDescriptor(psdAdmin, SECURITY_DESCRIPTOR_REVISION)) - __leave; - - // Compute size needed for the ACL. - dwACLSize = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(psidAdmin) - sizeof(DWORD); - - pACL = (PACL)LocalAlloc(LPTR, dwACLSize); - if (pACL == NULL) - __leave; - - if (!InitializeAcl(pACL, dwACLSize, ACL_REVISION2)) - __leave; - - dwAccessMask= ACCESS_READ | ACCESS_WRITE; - - if (!AddAccessAllowedAce(pACL, ACL_REVISION2, dwAccessMask, psidAdmin)) - __leave; - - if (!SetSecurityDescriptorDacl(psdAdmin, TRUE, pACL, FALSE)) - __leave; - - /* - AccessCheck validates a security descriptor somewhat; set the group - and owner so that enough of the security descriptor is filled out to - make AccessCheck happy. - */ - SetSecurityDescriptorGroup(psdAdmin, psidAdmin, FALSE); - SetSecurityDescriptorOwner(psdAdmin, psidAdmin, FALSE); - - if (!IsValidSecurityDescriptor(psdAdmin)) - __leave; - - dwAccessDesired = ACCESS_READ; - - /* - Initialize GenericMapping structure even though you - do not use generic rights. - */ - GenericMapping.GenericRead = ACCESS_READ; - GenericMapping.GenericWrite = ACCESS_WRITE; - GenericMapping.GenericExecute = 0; - GenericMapping.GenericAll = ACCESS_READ | ACCESS_WRITE; - - if (!AccessCheck(psdAdmin, hImpersonationToken, dwAccessDesired, &GenericMapping, &ps, &dwStructureSize, &dwStatus, &fReturn)) - { - fReturn = FALSE; - __leave; - } - } - __finally - { - // Clean up. - if (pACL) LocalFree(pACL); - if (psdAdmin) LocalFree(psdAdmin); - if (psidAdmin) FreeSid(psidAdmin); - if (hImpersonationToken) CloseHandle (hImpersonationToken); - if (hToken) CloseHandle (hToken); - } - - return fReturn; -} - -BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize) -{ - OSVERSIONINFO vi = {0}; - vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&vi); - - TCHAR szShell[1024] = {0}; - DWORD size = SIZEOF(szShell); - - if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) - { - HKEY hKey; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\system.ini\\boot"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size); - _tcslwr(szShell); - HKEY hRootKey = ( _tcsstr(szShell, _T("sys:")) == szShell) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - RegCloseKey(hKey); - - _tcscpy(szShell, _T("")); - if (RegOpenKeyEx(hRootKey, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - size = SIZEOF(szShell); - RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size); - RegCloseKey(hKey); - } - } - } - else{ - TCHAR szSystemIniPath[2048]; - GetWindowsDirectory(szSystemIniPath, SIZEOF(szSystemIniPath)); - size_t len = lstrlen(szSystemIniPath); - if (len > 0) - { - if (szSystemIniPath[len - 1] == '\\') { szSystemIniPath[--len] = '\0'; } - _tcscat(szSystemIniPath, _T("\\system.ini")); - GetPrivateProfileString( _T("boot"), _T("shell"), _T(""), szShell, size, szSystemIniPath); - } - } - - TCHAR *pos = _tcsrchr(szShell, '\\'); - TCHAR *res = (pos) ? pos + 1 : szShell; - _tcsncpy(shellPath, res, shSize); - - return TRUE; -} - -BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize) -{ - HKEY hKey; - TCHAR ieVer[1024]; - DWORD size = SIZEOF(ieVer); - TCHAR ieBuild[64] = {0}; - - _tcsncpy(ieVer, _T(""), size); - - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - if (RegQueryValueEx(hKey, _T("Version"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) - { - TCHAR *pos = _tcschr(ieVer, '.'); - if (pos) - { - pos = _tcschr(pos + 1, '.'); - if (pos) { *pos = 0; } - _tcsncpy(ieBuild, pos + 1, SIZEOF(ieBuild)); - pos = _tcschr(ieBuild, '.'); - if (pos) { *pos = 0; } - } - } - else{ - size = SIZEOF(ieVer); - if (RegQueryValueEx(hKey, _T("Build"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) - { - TCHAR *pos = ieVer + 1; - _tcsncpy(ieBuild, pos, SIZEOF(ieBuild)); - *pos = 0; - pos = _tcschr(ieBuild, '.'); - if (pos) { *pos = 0; } - } - else{ - _tcsncpy(ieVer, _T(""), size); - } - } - RegCloseKey(hKey); - } - - _tcsncpy(ieVersion, ieVer, ieSize); - if ( ieBuild[0] ) - { - _tcsncat(ieVersion, _T("."), ieSize); - _tcsncat(ieVersion, ieBuild, ieSize); - } - - return TRUE; -} - - -TCHAR *GetLanguageName(LANGID language) -{ - LCID lc = MAKELCID(language, SORT_DEFAULT); - return GetLanguageName(lc); -} - -extern TCHAR *GetLanguageName(LCID locale) -{ - static TCHAR name[1024]; - GetLocaleInfo(locale, LOCALE_SENGLANGUAGE, name, SIZEOF(name)); - return name; -} - -BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len) -{ - if ( len < sizeof(MUUID) || !str ) - return 0; - - mir_sntprintf(str, len, _T("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), uuid.a, uuid.b, uuid.c, uuid.d[0], uuid.d[1], uuid.d[2], uuid.d[3], uuid.d[4], uuid.d[5], uuid.d[6], uuid.d[7]); - return 1; -} - -BOOL IsUUIDNull(MUUID uuid) -{ - int i; - for (i = 0; i < sizeof(uuid.d); i++) - { - if (uuid.d[i]) - { - return 0; - } - } - - return ((uuid.a == 0) && (uuid.b == 0) && (uuid.c == 0)); -} \ No newline at end of file diff --git a/plugins/VersionInfo/utils.h b/plugins/VersionInfo/utils.h deleted file mode 100644 index 5db4b1a811..0000000000 --- a/plugins/VersionInfo/utils.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _M_VERSIONINFO_UTILS_H -#define _M_VERSIONINFO_UTILS_H - -#include "common.h" - -//utils.cpp -void MB(const TCHAR*); -void Log(const TCHAR*); -TCHAR *StrTrim(TCHAR *, const TCHAR *); - -//utils.cpp -TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size); -TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size); - -//returns a string from the database and uses MirandaFree to deallocate the string, leaving only the local copy -//utils.cpp -int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size); - -//a string of the form %s(start) | %s(end) is split into the two strings (start and end) -//utils.cpp -int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText); - -//utils.cpp -bool DoesDllExist(char *dllName); - -//utils.cpp -void GetModuleTimeStamp(TCHAR*, TCHAR*); -void NotifyError(DWORD, const TCHAR*, int); - -//utils.cpp -PLUGININFOEX *GetPluginInfo(const char *,HINSTANCE *); -PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *); -void FreePluginInfo(PLUGININFOEX *); - -//utils.cpp - -BOOL IsCurrentUserLocalAdministrator(); - -TCHAR *GetLanguageName(LANGID language); -TCHAR *GetLanguageName(LCID locale); - -BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize); -BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize); - -BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len); - -BOOL IsUUIDNull(MUUID uuid); - -#endif \ No newline at end of file diff --git a/plugins/VersionInfo/version.h b/plugins/VersionInfo/version.h deleted file mode 100644 index 7c0596e2c9..0000000000 --- a/plugins/VersionInfo/version.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2005 Luca Santarelli, © 2005-2008 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_VERSIONINFO_VERSION_H -#define M_VERSIONINFO_VERSION_H - -#define __MAJOR_VERSION 1 -#define __MINOR_VERSION 5 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 3 - -#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 "Collects and prints information related to Miranda, the plugins and the OS." -#define __AUTHOR "Luca Santarelli, Cristian Libotean, George Hazan" -#define __AUTHOREMAIL "hrk@users.sourceforge.net, eblis102@yahoo.com, ghazan@miranda.im" -#define __COPYRIGHT "© 2002-2005 Luca Santarelli, © 2005-2009 Cristian Libotean" -#define __AUTHORWEB "http://nightly.miranda.im/" -#define __PLUGIN_DISPLAY_NAME "Version Information" - -#endif //M_VERSIONINFO_VERSION_H diff --git a/plugins/VersionInfo/version.rc b/plugins/VersionInfo/version.rc deleted file mode 100644 index cd65db2ee3..0000000000 --- a/plugins/VersionInfo/version.rc +++ /dev/null @@ -1,104 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#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/W7UI/clistproxywindow.cpp b/plugins/W7UI/clistproxywindow.cpp deleted file mode 100644 index 12e5b476ed..0000000000 --- a/plugins/W7UI/clistproxywindow.cpp +++ /dev/null @@ -1,292 +0,0 @@ -#include "headers.h" - -CClistProxyWindow *g_clistProxyWnd = 0; -extern ITaskbarList3 *g_pTaskbarList; - -CClistProxyWindow::CClistProxyWindow() : m_overlayEvents(5) -{ - g_clistProxyWnd = this; - - m_activeOverlay = 0; - m_overlayIcon = 0; - m_overlayText = 0; - - SetWindowText(hwnd(), _T("Miranda IM")); - SendMessage(hwnd(), WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); - SendMessage(hwnd(), WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); - - SetEventHook(ME_CLIST_STATUSMODECHANGE, &CClistProxyWindow::OnStatusModeChanged); - SetEventHook(ME_AV_MYAVATARCHANGED, &CClistProxyWindow::OnAvatarChanged); - SetEventHook(ME_SYSTEM_MODULESLOADED, &CClistProxyWindow::OnModulesLoaded); - SetEventHook(ME_PROTO_ACCLISTCHANGED, &CClistProxyWindow::OnAccListChanged); - - SetTimer(1, 500); -} - -CClistProxyWindow::~CClistProxyWindow() -{ - KillObjectEventHooks(this); -} - -int __cdecl CClistProxyWindow::OnStatusModeChanged(WPARAM wParam, LPARAM lParam) -{ - Update(); - return 0; -} -int __cdecl CClistProxyWindow::OnAvatarChanged(WPARAM wParam, LPARAM lParam) -{ - Update(); - return 0; -} -int __cdecl CClistProxyWindow::OnModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - Update(); - return 0; -} -int __cdecl CClistProxyWindow::OnAccListChanged(WPARAM wParam, LPARAM lParam) -{ - Update(); - return 0; -} - -HANDLE CClistProxyWindow::SetEventHook(char *evt, int (__cdecl CClistProxyWindow::*fn)(WPARAM, LPARAM)) -{ - return HookEventObj(evt, *(MIRANDAHOOKOBJ *)&fn, this); -} - -void CClistProxyWindow::Flash() -{ - FlashWindow(hwnd(), TRUE); -} - -void CClistProxyWindow::SetOverlayIcon(HICON hIcon) -{ - m_overlayIcon = hIcon; - m_overlayIconHandle = 0; -} - -void CClistProxyWindow::SetOverlayIconHandle(HANDLE hIcolibIcon) -{ - m_overlayIcon = 0; - m_overlayIconHandle = hIcolibIcon; -} - -void CClistProxyWindow::AddOverlayEvent(int idx) -{ - m_overlayEvents[idx].Push(); -} - -void CClistProxyWindow::RemoveOverlayEvent(int idx) -{ - m_overlayEvents[idx].Pop(); -} - -int CClistProxyWindow::AllocateOverlayEvent(HANDLE hIcolibIcon) -{ - m_overlayEvents.insert(new COverlayEventSlot(hIcolibIcon, _T("")), m_overlayEvents.getCount()); - return m_overlayEvents.getCount() - 1; -} - -void CClistProxyWindow::Update() -{ - AddButton(LoadSkinnedIcon(SKINICON_OTHER_MIRANDA), TranslateT("Menu"), -1); - - int nAccounts = 0; - PROTOACCOUNT **accounts; - ProtoEnumAccounts(&nAccounts, &accounts); - for (int i = 0; i < nAccounts; ++i) - { - if (!accounts[i]->bIsEnabled || !accounts[i]->bIsVisible || !accounts[i]->ppro || !(accounts[i]->ppro->GetCaps(PFLAGNUM_1) & PF1_IM)) - continue; - - HICON hIcon = LoadSkinnedProtoIcon(accounts[i]->szModuleName, CallProtoService(accounts[i]->szModuleName, PS_GETSTATUS, 0, 0)); - AddButton(hIcon, accounts[i]->tszAccountName, (INT_PTR)accounts[i]->tszAccountName); - } - UpdateButtons(g_pTaskbarList); - - InvalidateThumbnail(); -} - -void CClistProxyWindow::OnActivate(HWND hwndFrom) -{ - CallService(MS_CLIST_SHOWHIDE, 0, 0); - - HWND hwndClui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); - if (hwndFrom != hwndClui && !IsIconic(hwndClui) && IsWindowVisible(hwndClui)) - SetForegroundWindow(hwndClui); - else - SetForegroundWindow(NULL); -} - -void CClistProxyWindow::OnToolbar(int id, INT_PTR data) -{ - POINT pt; GetCursorPos(&pt); - HMENU hMenu = NULL; - HWND hwndClui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); - - switch (data) - { - case -1: - { - hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDMAIN, 0, 0); - break; - } - - default: - { - hMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0); - int nItems = GetMenuItemCount(hMenu); - for (int i = 0; i < nItems; ++i) - { - TCHAR buf[128]; - MENUITEMINFO mii = {0}; - mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STRING|MIIM_SUBMENU; - mii.dwTypeData = buf; - mii.cch = SIZEOF(buf); - GetMenuItemInfo(hMenu, i, TRUE, &mii); - - if (mii.hSubMenu && !lstrcmp(mii.dwTypeData, (TCHAR*)data)) - { - hMenu = mii.hSubMenu; - break; - } - } - } - } - - SetForegroundWindow(hwndClui); - TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hwndClui, NULL); -} - -void CClistProxyWindow::OnRenderThumbnail(int width, int height) -{ - HBITMAP hbmp = CreateDwmBitmap(width, height); - HDC hdc = CreateCompatibleDC(0); - SelectObject(hdc, hbmp); - - RGBQUAD rgb0, rgb1; - rgb0.rgbRed = 0; rgb0.rgbGreen = 0; rgb0.rgbBlue = 0; - rgb1.rgbRed = 19; rgb1.rgbGreen = 58; rgb1.rgbBlue = 89; - DrawGradient(hdc, 0, 0, width, height, &rgb0, &rgb1); - - HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); - SetTextColor(hdc, RGB(255, 255, 255)); - SetBkMode(hdc, TRANSPARENT); - - RECT rc; - SIZE sz; - SetRect(&rc, 5, 5, width-10, height-10); - - int avatarWidth = 0; - int avatarHeight = 0; - if (true) - { - AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)""); - if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND)) - { - if (ace->bmWidth < width / 4) - { - avatarWidth = ace->bmWidth; - avatarHeight = ace->bmHeight; - } else - { - avatarWidth = width / 4; - avatarHeight = avatarWidth * ace->bmHeight / ace->bmWidth; - } - - AVATARDRAWREQUEST avdr = {0}; - avdr.cbSize = sizeof(avdr); - avdr.hContact = NULL; - avdr.hTargetDC = hdc; - avdr.rcDraw = rc; - avdr.rcDraw.bottom = avdr.rcDraw.top + avatarHeight; - avdr.rcDraw.right = avdr.rcDraw.left + avatarWidth; - avdr.dwFlags = AVDRQ_FALLBACKPROTO | AVDRQ_FORCEALPHA | AVDRQ_OWNPIC; - avdr.szProto = ""; - - avdr.alpha = 255; - CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&avdr); - - rc.left += avatarWidth + 5; - } - } - - int nAccounts = 0; - PROTOACCOUNT **accounts; - ProtoEnumAccounts(&nAccounts, &accounts); - for (int i = 0; i < nAccounts; ++i) - { - if (!accounts[i]->bIsEnabled /*|| !accounts[i]->ppro || !(accounts[i]->ppro->GetCaps(PFLAGNUM_1) & PF1_IM)*/) - continue; - - char *proto = accounts[i]->szModuleName; - - if (true) - { - TCHAR name[128]; name[0] = 0; - - CONTACTINFO ci = {0}; - ci.cbSize = sizeof(ci); - ci.hContact = NULL; - ci.szProto = proto; - ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) - { - switch (ci.type) - { - case CNFT_ASCIIZ: - mir_sntprintf(name, SIZEOF(name), _T("%s - %s"), accounts[i]->tszAccountName, ci.pszVal); - mir_free((void *)ci.pszVal); - break; - case CNFT_DWORD: - mir_sntprintf(name, SIZEOF(name), _T("%s - %u"), accounts[i]->tszAccountName, ci.dVal); - break; - } - - } else - { - lstrcpyn(name, accounts[i]->tszAccountName, SIZEOF(name)); - } - - RECT rcText = rc; - rcText.left += 20; - DrawText(hdc, name, -1, &rcText, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP|DT_SINGLELINE); - GetTextExtentPoint32(hdc, name, lstrlen(name), &sz); - } - - if (true) - { - HICON hIcon = LoadSkinnedProtoIcon(proto, CallProtoService(proto, PS_GETSTATUS, 0, 0)); - DrawIconEx(hdc, rc.left, rc.top + (sz.cy - 16) / 2, hIcon, 16, 16, 0, NULL, DI_NORMAL); - } - - rc.top += sz.cy + 5; - } - - SelectObject(hdc, hfntSave); - - DeleteDC(hdc); - MakeBitmapOpaque(hbmp); - SetThumbnail(hbmp); - DeleteObject(hbmp); -} - -void CClistProxyWindow::OnClose() -{ - CallService("CloseAction", NULL, NULL); -} - -void CClistProxyWindow::OnTimer(int id) -{ - HANDLE hIcolibItem = m_overlayIconHandle; - for (m_activeOverlay = (m_activeOverlay + 1) % (m_overlayEvents.getCount() + 1); m_activeOverlay < m_overlayEvents.getCount(); ++m_activeOverlay) - if (m_overlayEvents[m_activeOverlay]) - { - hIcolibItem = m_overlayEvents[m_activeOverlay].GetIcon(); - break; - } - - HICON hIcon = hIcolibItem ? (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)hIcolibItem) : m_overlayIcon; - if (hIcon) g_pTaskbarList->SetOverlayIcon(hwnd(), hIcon, L""); -} diff --git a/plugins/W7UI/clistproxywindow.h b/plugins/W7UI/clistproxywindow.h deleted file mode 100644 index 153c59089b..0000000000 --- a/plugins/W7UI/clistproxywindow.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef clistproxywindow_h__ -#define clistproxywindow_h__ - -class CClistProxyWindow: public CDwmWindow -{ -public: - CClistProxyWindow(); - ~CClistProxyWindow(); - - void Flash(); - void SetOverlayIcon(HICON hIcon); - void SetOverlayIconHandle(HANDLE hIcolibIcon); - void AddOverlayEvent(int idx); - void RemoveOverlayEvent(int idx); - int AllocateOverlayEvent(HANDLE hIcolibIcon); - -private: - class COverlayEventSlot - { - private: - HANDLE m_hIcolibItem; - TCHAR *m_overlayText; - int m_level; - - public: - COverlayEventSlot(HANDLE hIcolibItem, TCHAR *overlayText) - { - m_hIcolibItem = hIcolibItem; - m_overlayText = mir_tstrdup(overlayText); - m_level = 0; - } - ~COverlayEventSlot() { mir_free(m_overlayText); } - void Push() { m_level++; } - void Pop() { if (m_level > 0) m_level--; } - operator bool() { return m_level > 0; } - HANDLE GetIcon() { return m_hIcolibItem; } - }; - - int m_activeOverlay; - HICON m_overlayIcon; - HANDLE m_overlayIconHandle; - TCHAR *m_overlayText; - OBJLIST m_overlayEvents; - - int __cdecl OnStatusModeChanged(WPARAM wParam, LPARAM lParam); - int __cdecl OnAvatarChanged(WPARAM wParam, LPARAM lParam); - int __cdecl OnModulesLoaded(WPARAM wParam, LPARAM lParam); - int __cdecl OnAccListChanged(WPARAM wParam, LPARAM lParam); - - HANDLE SetEventHook(char *evt, int (__cdecl CClistProxyWindow::*fn)(WPARAM, LPARAM)); - - void Update(); - -protected: - void OnActivate(HWND hwndFrom); - void OnToolbar(int id, INT_PTR data); - void OnRenderThumbnail(int width, int height); - void OnClose(); - void OnTimer(int id); -}; - -extern CClistProxyWindow *g_clistProxyWnd; - -#endif // clistproxywindow_h__ diff --git a/plugins/W7UI/docs/w7ui-translation.txt b/plugins/W7UI/docs/w7ui-translation.txt new file mode 100644 index 0000000000..30bce1459e --- /dev/null +++ b/plugins/W7UI/docs/w7ui-translation.txt @@ -0,0 +1,16 @@ +; Common strings that belong to many files +;[Do not disturb] +;[Invisible] +;[Offline] +;[Online] + +; ../../plugins/W7UI/clistproxywindow.cpp +;[Menu] + +; ../../plugins/W7UI/jumplistbuilder.cpp +;[Nickname] + +; ../../plugins/W7UI/srmmproxywindow.cpp +;[File] +;[History] +;[User Details] diff --git a/plugins/W7UI/dwmwindow.cpp b/plugins/W7UI/dwmwindow.cpp deleted file mode 100644 index 2d8dd6e9e4..0000000000 --- a/plugins/W7UI/dwmwindow.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include "headers.h" - -#define WNDCLASSNAME _T("W7DwmWndClass") - -CDwmWindow::CDwmWindow() -{ - GlobalInitWndClass(); - - m_btnInitialized = false; - m_btnCount = 0; - for (int i = 0; i < SIZEOF(m_btnInfo); ++i) - { - m_btnInfo[i].iId = i; - m_btnInfo[i].dwMask = THUMBBUTTONMASK(THB_FLAGS); - m_btnInfo[i].dwFlags = THUMBBUTTONFLAGS(THBF_HIDDEN); - m_btnData[i] = 0; - } - - m_hwnd = CreateWindowEx(WS_EX_APPWINDOW|WS_EX_NOACTIVATE, WNDCLASSNAME, NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, g_hInst, NULL); - SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); - SetWindowPos(m_hwnd, 0, -100000, -100000, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_DEFERERASE|SWP_NOSENDCHANGING|SWP_SHOWWINDOW); - - BOOL val = 1; - DwmSetWindowAttribute(m_hwnd, DWMWA_HAS_ICONIC_BITMAP, &val, 4); - DwmSetWindowAttribute(m_hwnd, DWMWA_FORCE_ICONIC_REPRESENTATION, &val, 4); - dwmInvalidateIconicBitmaps(m_hwnd); -} - -HBITMAP CDwmWindow::CreateDwmBitmap(int width, int height) -{ - BITMAPINFO bi; - bi.bmiHeader.biSize = sizeof(bi.bmiHeader); - bi.bmiHeader.biWidth = width; - bi.bmiHeader.biHeight = -height; - bi.bmiHeader.biPlanes = 1; - bi.bmiHeader.biBitCount = 32; - bi.bmiHeader.biCompression = BI_RGB; - return CreateDIBSection(0, &bi, DIB_RGB_COLORS, NULL, 0, 0); -} - -void CDwmWindow::MakeBitmapOpaque(HBITMAP hBmp) -{ - BITMAP bmp; - GetObject(hBmp, sizeof(bmp), &bmp); - if (bmp.bmBitsPixel != 32) return; - if (bmp.bmHeight < 0) bmp.bmHeight *= -1; - - int size = bmp.bmWidth * bmp.bmHeight * 4; - BYTE *data = new BYTE[size]; - GetBitmapBits(hBmp, size, data); - for (int i = 3; i < size; i += 4) - data[i] = 255; - SetBitmapBits(hBmp, size, data); - delete [] data; - -} - -void CDwmWindow::DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1) -{ - int oldMode = SetBkMode(hdc, OPAQUE); - COLORREF oldColor = SetBkColor(hdc, 0); - - RECT rc; SetRect(&rc, x, 0, x+width, 0); - for (int i=y+height; --i >= y; ) { - COLORREF color = RGB( - ((height-i-1)*rgb0->rgbRed + i*rgb1->rgbRed) / height, - ((height-i-1)*rgb0->rgbGreen + i*rgb1->rgbGreen) / height, - ((height-i-1)*rgb0->rgbBlue + i*rgb1->rgbBlue) / height); - rc.top = rc.bottom = i; - ++rc.bottom; - SetBkColor(hdc, color); - ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, "", 0, 0); - } - - SetBkMode(hdc, oldMode); - SetBkColor(hdc, oldColor); -} - -bool CDwmWindow::AddButton(HICON hIcon, TCHAR *text, INT_PTR data, DWORD flags) -{ - if (m_btnCount == SIZEOF(m_btnInfo)) return false; - m_btnInfo[m_btnCount].dwMask = THUMBBUTTONMASK(THB_ICON|THB_TOOLTIP|THB_FLAGS); - m_btnInfo[m_btnCount].hIcon = hIcon; - lstrcpyn(m_btnInfo[m_btnCount].szTip, text, SIZEOF(m_btnInfo[m_btnCount].szTip)); - m_btnInfo[m_btnCount].dwFlags = THUMBBUTTONFLAGS(flags); - m_btnData[m_btnCount] = data; - m_btnCount++; - return true; -} - -void CDwmWindow::UpdateButtons(ITaskbarList3 *p) -{ - if (m_btnInitialized) - p->ThumbBarUpdateButtons(hwnd(), SIZEOF(m_btnInfo), m_btnInfo); - else - p->ThumbBarAddButtons(hwnd(), SIZEOF(m_btnInfo), m_btnInfo); - - m_btnCount = 0; // reset this for next iteration - m_btnInitialized = true; -} - -void CDwmWindow::SetTimer(int id, int timeout) -{ - ::SetTimer(m_hwnd, id, timeout, NULL); -} - -void CDwmWindow::KillTimer(int id) -{ - ::KillTimer(m_hwnd, id); -} - -void CDwmWindow::InvalidateThumbnail() -{ - dwmInvalidateIconicBitmaps(m_hwnd); -} - -void CDwmWindow::SetPreview(HBITMAP hbmp, int x, int y) -{ - POINT pt = { x, y }; - dwmSetIconicLivePreviewBitmap(m_hwnd, hbmp, &pt, 0); -} - -void CDwmWindow::SetThumbnail(HBITMAP hbmp) -{ - dwmSetIconicThumbnail(m_hwnd, hbmp, 0); -} - -LRESULT CDwmWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_ACTIVATE: - { - if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) - { - OnActivate((HWND)wParam); - } - break; - } - - case WM_CLOSE: - { - OnClose(); - return FALSE; - } - - case WM_DWMSENDICONICLIVEPREVIEWBITMAP: - { - OnRenderPreview(); - break; - } - - case WM_DWMSENDICONICTHUMBNAIL: - { - int width = HIWORD(lParam); - int height = LOWORD(lParam); - OnRenderThumbnail(width, height); - break; - } - - case WM_TIMER: - { - OnTimer(wParam); - break; - } - - case WM_COMMAND: - { - if (HIWORD(wParam) == THBN_CLICKED) - OnToolbar(LOWORD(wParam), m_btnData[LOWORD(wParam)]); - break; - } - } - - return DefWindowProc(m_hwnd, msg, wParam, lParam); -} - -void CDwmWindow::GlobalInitWndClass() -{ - static bool bInitialized = false; - if (bInitialized) return; - - WNDCLASSEX wcl = {0}; - wcl.cbSize = sizeof(wcl); - wcl.lpfnWndProc = GlobalWndProc; - wcl.style = 0; - wcl.cbClsExtra = 0; - wcl.cbWndExtra = 0; - wcl.hInstance = g_hInst; - wcl.hIcon = NULL; - wcl.hCursor = LoadCursor(NULL, IDC_ARROW); - wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); - wcl.lpszMenuName = NULL; - wcl.lpszClassName = WNDCLASSNAME; - wcl.hIconSm = NULL; - RegisterClassEx(&wcl); -} - -LRESULT CALLBACK CDwmWindow::GlobalWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - CDwmWindow *wnd = (CDwmWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (!wnd) return DefWindowProc(hwnd, msg, wParam, lParam); - if (msg == WM_DESTROY) - { - delete wnd; - return DefWindowProc(hwnd, msg, wParam, lParam); - } - return wnd->WndProc(msg, wParam, lParam); -} \ No newline at end of file diff --git a/plugins/W7UI/dwmwindow.h b/plugins/W7UI/dwmwindow.h deleted file mode 100644 index e795823247..0000000000 --- a/plugins/W7UI/dwmwindow.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef dwmwindow_h__ -#define dwmwindow_h__ - -class CDwmWindow -{ -public: - CDwmWindow(); - virtual ~CDwmWindow() {} - - HWND hwnd() { return m_hwnd; } - - template - static TWindow *GetWindow(HWND hwnd) - { - return (TWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - } - -protected: - // events - virtual void OnActivate(HWND hwndFrom) {} - virtual void OnClose() {} - virtual void OnRenderThumbnail(int mzxWidth, int maxHeight) {} - virtual void OnRenderPreview() {} - virtual void OnTimer(int id) {} - virtual void OnToolbar(int id, INT_PTR data) {} - - // timer stuff - void SetTimer(int id, int timeout); - void KillTimer(int id); - - // manage thumbnail and aero peek - void InvalidateThumbnail(); - void SetPreview(HBITMAP hbmp, int x, int y); - void SetThumbnail(HBITMAP hbmp); - - // manage toolbar - bool AddButton(HICON hIcon, TCHAR *text, INT_PTR data, DWORD flags = THBF_ENABLED); - void UpdateButtons(ITaskbarList3 *p); - - //utilities - static HBITMAP CreateDwmBitmap(int width, int height); - static void MakeBitmapOpaque(HBITMAP hBmp); - static void DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1); - -private: - HWND m_hwnd; - - bool m_btnInitialized; - int m_btnCount; - THUMBBUTTON m_btnInfo[7]; - INT_PTR m_btnData[7]; - - LRESULT CALLBACK WndProc(UINT msg, WPARAM wParam, LPARAM lParam); - - static void GlobalInitWndClass(); - static LRESULT CALLBACK GlobalWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -}; - -#endif // dwmwindow_h__ \ No newline at end of file diff --git a/plugins/W7UI/headers.h b/plugins/W7UI/headers.h deleted file mode 100644 index 7d28902466..0000000000 --- a/plugins/W7UI/headers.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - -Miranda IM: the free IM client for Microsoft* Windows* - -Copyright 2000-2003 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#define _CRT_SECURE_NO_DEPRECATE - - -#include -#define _WIN32_WINNT 0x0501 -#include -#include -#include -#include - -#include -#include -#include - -#define MIRANDA_VER 0x0A00 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "m_w7ui.h" - -#include "win7api.h" - -#include "jumplistarray.h" -#include "jumplistbuilder.h" -#include "jumplist.h" - -#include "subclassmgr.h" -#include "dwmwindow.h" -#include "clistproxywindow.h" -#include "srmmproxywindow.h" - -extern HINSTANCE g_hInst; diff --git a/plugins/W7UI/jumplist.cpp b/plugins/W7UI/jumplist.cpp deleted file mode 100644 index 4fd1a68e9d..0000000000 --- a/plugins/W7UI/jumplist.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "headers.h" - -static HANDLE hProcessJumpList = 0; - -static void ProcessJumpListImpl(char *arg) -{ - char *prefix = mir_strdup(arg); - char *argument = strchr(prefix, ':'); - if (argument) *argument++ = 0; - NotifyEventHooks(hProcessJumpList, (WPARAM)prefix, (LPARAM)argument); - mir_free(prefix); -} - -static LRESULT CALLBACK MirandaJumpListProcessorWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_COPYDATA: - { - COPYDATASTRUCT *data = (COPYDATASTRUCT *)lParam; - ProcessJumpListImpl((char *)data->lpData); - break; - } - } - - return DefWindowProc(hwnd, message, wParam, lParam); -} - -extern "C" __declspec(dllexport) void ProcessJumpList(HWND, HINSTANCE, LPSTR arg, UINT) -{ - char miranda_path[MAX_PATH]; - GetModuleFileNameA(g_hInst, miranda_path, SIZEOF(miranda_path)); - lstrcpyA(strstr(_strlwr(miranda_path), "plugins\\w7ui.dll"), "miranda32.exe"); - - if (HWND hwnd = FindWindowA("MirandaJumpListProcessor", miranda_path)) - { - COPYDATASTRUCT data = {0}; - data.dwData = 0; - data.cbData = lstrlenA(arg) + 1; - data.lpData = arg; - SendMessage(hwnd, WM_COPYDATA, 0, (LPARAM)&data); - } else - { - char command[MAX_PATH * 2]; - wsprintfA(command, "\"%s\" -jump %s", miranda_path, arg); - WinExec(command, SW_SHOWNORMAL); - } -} - -static int OnJumpListItems(WPARAM, LPARAM lParam) -{ - WCHAR *category = (WCHAR *)lParam; - - if (!category) - { - MJumpList_AddItem(SKINICON_STATUS_ONLINE, TranslateT("Online"), L"status", L"online"); - MJumpList_AddItem(SKINICON_STATUS_DND, TranslateT("Do not disturb"), L"status", L"dnd"); - MJumpList_AddItem(SKINICON_STATUS_INVISIBLE, TranslateT("Invisible"), L"status", L"invisible"); - MJumpList_AddItem(SKINICON_STATUS_OFFLINE, TranslateT("Offline"), L"status", L"offline"); - return 0; - } - - return 0; -} - -static int OnJumpListProcess(WPARAM wParam, LPARAM lParam) -{ - char *prefix = (char *)wParam; - char *argument = (char *)lParam; - - if (!lstrcmpA(prefix, "status")) - { - if (!lstrcmpA(argument, "online")) - { - CallService(MS_CLIST_SETSTATUSMODE, ID_STATUS_ONLINE, 0); - } else - if (!lstrcmpA(argument, "dnd")) - { - CallService(MS_CLIST_SETSTATUSMODE, ID_STATUS_DND, 0); - } else - if (!lstrcmpA(argument, "invisible")) - { - CallService(MS_CLIST_SETSTATUSMODE, ID_STATUS_INVISIBLE, 0); - } else - if (!lstrcmpA(argument, "offline")) - { - CallService(MS_CLIST_SETSTATUSMODE, ID_STATUS_OFFLINE, 0); - } - return 1; - } - - return 0; -} - -void LoadJumpList() -{ - hProcessJumpList = CreateHookableEvent(ME_JUMPLIST_PROCESS); -} - -void InitJumpList() -{ - HookEvent(ME_JUMPLIST_BUILDITEMS, OnJumpListItems); - HookEvent(ME_JUMPLIST_PROCESS, OnJumpListProcess); - - if (char *cmd = strstr(GetCommandLineA(), " -jump ")) - ProcessJumpListImpl(cmd + 7); - - WNDCLASSEX wcx = {0}; - wcx.cbSize = sizeof(wcx); - wcx.lpfnWndProc = MirandaJumpListProcessorWndProc; - wcx.hInstance = g_hInst; - wcx.lpszClassName = _T("MirandaJumpListProcessor"); - RegisterClassEx(&wcx); - - char miranda_path[MAX_PATH]; - GetModuleFileNameA(g_hInst, miranda_path, SIZEOF(miranda_path)); - lstrcpyA(strstr(_strlwr(miranda_path), "plugins\\w7ui.dll"), "miranda32.exe"); - - HWND hwnd = CreateWindowA("MirandaJumpListProcessor", miranda_path, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, g_hInst, NULL); - ShowWindow(hwnd, SW_HIDE); - - CJumpListBuilder::Rebuild(); -} diff --git a/plugins/W7UI/jumplist.h b/plugins/W7UI/jumplist.h deleted file mode 100644 index de5a6f0548..0000000000 --- a/plugins/W7UI/jumplist.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef jumplist_h__ -#define jumplist_h__ - -void LoadJumpList(); -void InitJumpList(); - -#endif // jumplist_h__ diff --git a/plugins/W7UI/jumplistarray.cpp b/plugins/W7UI/jumplistarray.cpp deleted file mode 100644 index 669a7784ef..0000000000 --- a/plugins/W7UI/jumplistarray.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include "headers.h" - -#pragma pack(push, 1) -typedef struct -{ - BYTE bWidth; // Width, in pixels, of the image - BYTE bHeight; // Height, in pixels, of the image - BYTE bColorCount; // Number of colors in image (0 if >=8bpp) - BYTE bReserved; // Reserved ( must be 0) - WORD wPlanes; // Color Planes - WORD wBitCount; // Bits per pixel - DWORD dwBytesInRes; // How many bytes in this resource? - DWORD dwImageOffset; // Where in the file is this image? -} ICONDIRENTRY, *LPICONDIRENTRY; - -typedef struct -{ - WORD idReserved; // Reserved (must be 0) - WORD idType; // Resource Type (1 for icons) - WORD idCount; // How many images? - ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em) -} ICONDIR, *LPICONDIR; -#pragma pack(pop) - -static void SaveIconToFile(HICON hIcon, TCHAR *szFile) -{ - ICONINFO iconInfo = {0}; - BITMAP bmpColor, bmpMask; - HANDLE hFile = 0; - HANDLE hMap = 0; - BYTE *pFile = 0; - - GetIconInfo(hIcon, &iconInfo); - GetObject(iconInfo.hbmColor, sizeof(bmpColor), &bmpColor); - GetObject(iconInfo.hbmMask, sizeof(bmpMask), &bmpMask); - - do - { - if (bmpColor.bmBitsPixel <= 8) break; - - DWORD dwColorSize = bmpColor.bmWidthBytes * bmpColor.bmHeight; - DWORD dwMaskSize = bmpMask.bmWidthBytes * bmpMask.bmHeight; - DWORD dwFileSize = sizeof(ICONDIR) + sizeof(BITMAPINFOHEADER) + dwColorSize + dwMaskSize; - - hFile = CreateFile(szFile, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL); - if (hFile == INVALID_HANDLE_VALUE) break; - hMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwFileSize, NULL); - if (!hMap) break; - pFile = (BYTE *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0 ,0); - if (!pFile) break; - - ICONDIR iconDir = {0}; - iconDir.idCount = 1; - iconDir.idType = 1; - iconDir.idEntries[0].bWidth = bmpColor.bmWidth; - iconDir.idEntries[0].bHeight = bmpColor.bmHeight; - iconDir.idEntries[0].bColorCount = 0; - iconDir.idEntries[0].wPlanes = bmpColor.bmPlanes; - iconDir.idEntries[0].wBitCount = bmpColor.bmBitsPixel; - iconDir.idEntries[0].dwBytesInRes = sizeof(BITMAPINFOHEADER) + dwColorSize + dwMaskSize; - iconDir.idEntries[0].dwImageOffset = sizeof(ICONDIR); - MoveMemory(pFile, &iconDir, sizeof(ICONDIR)); - - BITMAPINFOHEADER iconBmp = {0}; - iconBmp.biSize = sizeof(iconBmp); - iconBmp.biWidth = bmpColor.bmWidth; - iconBmp.biHeight = bmpColor.bmHeight + bmpMask.bmHeight; - iconBmp.biPlanes = bmpColor.bmPlanes; - iconBmp.biBitCount = bmpColor.bmBitsPixel; - iconBmp.biSizeImage = dwColorSize + dwMaskSize; - MoveMemory(pFile + sizeof(ICONDIR), &iconBmp, sizeof(BITMAPINFOHEADER)); - - BYTE *buf = (BYTE *)mir_alloc(dwColorSize); - GetBitmapBits(iconInfo.hbmColor, dwColorSize, buf); - for (int row = 0; row < bmpColor.bmHeight; ++row) - { - MoveMemory( - pFile + sizeof(ICONDIR) + sizeof(BITMAPINFOHEADER) + row * bmpColor.bmWidthBytes, - buf + (bmpColor.bmHeight - row - 1) * bmpColor.bmWidthBytes, - bmpColor.bmWidthBytes); - } - mir_free(buf); - - GetBitmapBits(iconInfo.hbmMask, dwMaskSize, pFile + sizeof(ICONDIR) + sizeof(BITMAPINFOHEADER) + dwColorSize); - } while(0); - - DeleteObject(iconInfo.hbmColor); - DeleteObject(iconInfo.hbmMask); - - if (pFile) UnmapViewOfFile(pFile); - if (hMap) CloseHandle(hMap); - if (hFile && hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); -} - -CJumpListArray::CJumpListArray() -{ - CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER, IID_IObjectCollection, (void **)&m_pObjects); -} - -CJumpListArray::~CJumpListArray() -{ - if (m_pObjects) m_pObjects->Release(); -} - -void CJumpListArray::AddItemImpl(TCHAR *icon, int iIcon, TCHAR *title, TCHAR *path, TCHAR *args) -{ - IShellLink *link = NewShellLink(icon, iIcon, title, path, args); - m_pObjects->AddObject(link); - link->Release(); -} - -void CJumpListArray::AddItem(char *mir_icon, TCHAR *title, TCHAR *path, TCHAR *args) -{ - TCHAR icon[MAX_PATH]; int iIcon; - LoadMirandaIcon(mir_icon, icon, &iIcon); - AddItemImpl(icon, iIcon, title, path, args); -} - -void CJumpListArray::AddItem(int skinicon, TCHAR *title, TCHAR *path, TCHAR *args) -{ - TCHAR icon[MAX_PATH]; int iIcon; - LoadMirandaIcon(skinicon, icon, &iIcon); - AddItemImpl(icon, iIcon, title, path, args); -} - -void CJumpListArray::AddItem(char *proto, int status, TCHAR *title, TCHAR *path, TCHAR *args) -{ - TCHAR icon[MAX_PATH]; int iIcon; - LoadMirandaIcon(proto, status, icon, &iIcon); - AddItemImpl(icon, iIcon, title, path, args); -} - -IObjectArray *CJumpListArray::GetArray() -{ - IObjectArray *result = NULL; - m_pObjects->QueryInterface(IID_IObjectArray, (void **)&result); - return result; -} - -bool CJumpListArray::LoadMirandaIcon(char *mir_icon, TCHAR *icon, int *id) -{ - *id = 0; - - TCHAR *path = Utils_ReplaceVarsT(_T("%miranda_userdata%\\w7ui.IconCache")); - CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path); - - TCHAR *name = mir_a2t(mir_icon); - for (TCHAR *ch = name; *ch; ++ch) if (_tcschr(_T("\\/:*?<>|"), *ch)) *ch = _T('_'); - mir_sntprintf(icon, MAX_PATH, _T("%s\\%s.ico"), path, name); - - mir_free(name); - mir_free(path); - - HICON hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)mir_icon); - SaveIconToFile(hIcon, icon); - - return true; -} - -bool CJumpListArray::LoadMirandaIcon(int skinicon, TCHAR *icon, int *id) -{ - *id = 0; - - TCHAR *path = Utils_ReplaceVarsT(_T("%miranda_userdata%\\w7ui.IconCache")); - CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path); - mir_sntprintf(icon, MAX_PATH, _T("%s\\skinicon$%d.ico"), path, skinicon); - mir_free(path); - - HICON hIcon = LoadSkinnedIcon(skinicon); - SaveIconToFile(hIcon, icon); - - return true; -} - -bool CJumpListArray::LoadMirandaIcon(char *proto, int status, TCHAR *icon, int *id) -{ - *id = 0; - - TCHAR *path = Utils_ReplaceVarsT(_T("%miranda_userdata%\\w7ui.IconCache")); - CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path); - mir_sntprintf(icon, MAX_PATH, _T("%s\\skinprotoicon$") _T(TCHAR_STR_PARAM) _T("$%d.ico"), path, proto, status); - mir_free(path); - - HICON hIcon = LoadSkinnedProtoIcon(proto, status); - SaveIconToFile(hIcon, icon); - - return true; -} - -IShellLink *CJumpListArray::NewShellLink(TCHAR *icon, int iIcon, TCHAR *title, TCHAR *path, TCHAR *args) -{ - IShellLink *pShellLink = NULL; - CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&pShellLink); - - pShellLink->SetPath(path); - pShellLink->SetIconLocation(icon, iIcon); - pShellLink->SetArguments(args); - pShellLink->SetShowCmd(SW_SHOWDEFAULT); - - IPropertyStore *pPropStore = NULL; - if (SUCCEEDED(pShellLink->QueryInterface(IID_IPropertyStore, (void **)&pPropStore))) - { - PROPVARIANT pv; - - InitPropVariantFromString(title, &pv); - pPropStore->SetValue(PKEY_Title, pv); - PropVariantClear(&pv); - - pPropStore->Commit(); - pPropStore->Release(); - } - - return pShellLink; -} \ No newline at end of file diff --git a/plugins/W7UI/jumplistarray.h b/plugins/W7UI/jumplistarray.h deleted file mode 100644 index c9f2a8b979..0000000000 --- a/plugins/W7UI/jumplistarray.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef jumplistarray_h__ -#define jumplistarray_h__ - -class CJumpListArray -{ -private: - IObjectCollection *m_pObjects; - -public: - CJumpListArray(); - ~CJumpListArray(); - - void AddItem(char *mir_icon, TCHAR *title, TCHAR *path, TCHAR *args); - void AddItem(int skinicon, TCHAR *title, TCHAR *path, TCHAR *args); - void AddItem(char *proto, int skinicon, TCHAR *title, TCHAR *path, TCHAR *args); - - IObjectArray *GetArray(); - -private: - void AddItemImpl(TCHAR *icon, int iIcon, TCHAR *title, TCHAR *path, TCHAR *args); - - bool LoadMirandaIcon(char *mir_icon, TCHAR *icon, int *id); - bool LoadMirandaIcon(int skinicon, TCHAR *icon, int *id); - bool LoadMirandaIcon(char *proto, int status, TCHAR *icon, int *id); - - static IShellLink *NewShellLink(TCHAR *icon, int iIcon, TCHAR *title, TCHAR *path, TCHAR *args); -}; - -#endif // jumplistarray_h__ diff --git a/plugins/W7UI/jumplistbuilder.cpp b/plugins/W7UI/jumplistbuilder.cpp deleted file mode 100644 index 5e5f1d9f65..0000000000 --- a/plugins/W7UI/jumplistbuilder.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "headers.h" - -CJumpListBuilder *CJumpListBuilder::m_instance = 0; - -CJumpListBuilder::CJumpListBuilder() -{ - m_hBuildCategories = CreateHookableEvent(ME_JUMPLIST_BUILDCATEGORIES); - m_hBuildItems = CreateHookableEvent(ME_JUMPLIST_BUILDITEMS); - CreateSvc(MS_JUMPLIST_REBUILD, &CJumpListBuilder::Rebuild); - CreateSvc(MS_JUMPLIST_ADDCATEGORY, &CJumpListBuilder::AddCategory); - CreateSvc(MS_JUMPLIST_ADDITEM, &CJumpListBuilder::AddItem); -} - -CJumpListBuilder::~CJumpListBuilder() -{ - KillObjectServices(this); - DestroyHookableEvent(m_hBuildCategories); - DestroyHookableEvent(m_hBuildItems); -} - -void CJumpListBuilder::BuildJumpList() -{ - m_lists = new LIST(5, _tcscmp); - NotifyEventHooks(m_hBuildCategories, 0, 0); - - UINT maxSlots; - IObjectArray *pRemoved; - CoCreateInstance(CLSID_CustomDestinationList, NULL, CLSCTX_INPROC_SERVER, IID_ICustomDestinationList, (void **)&m_pList); - m_pList->BeginList(&maxSlots, IID_IObjectArray, (void **)&pRemoved); - BuildCategory(NULL); - for (int i = 0; i < m_lists->getCount(); ++i) - BuildCategory((*m_lists)[i]); - m_pList->CommitList(); - m_pList->Release(); - pRemoved->Release(); - - m_lists->destroy(); - delete m_lists; -} - -int __cdecl CJumpListBuilder::Rebuild(WPARAM wParam, LPARAM lParam) -{ - BuildJumpList(); - return 0; -} - -int __cdecl CJumpListBuilder::AddCategory(WPARAM wParam, LPARAM lParam) -{ - TCHAR *category = (TCHAR *)lParam; - if (!m_lists->find(category)) m_lists->insert(mir_wstrdup(category)); - return 0; -} - -int __cdecl CJumpListBuilder::AddItem(WPARAM wParam, LPARAM lParam) -{ - MIRANDAJUMPLISTITEM *item = (MIRANDAJUMPLISTITEM *)lParam; - switch (item->iconSource) - { - case MIS_ICOLIB: - m_pCurrentList->AddItem(item->iconName, item->szTitle, _T("rundll32.exe"), BuildJumpListCommand(item->szPrefix, item->szArgument)); - break; - case MIS_GENERAL: - m_pCurrentList->AddItem(item->iconIdx, item->szTitle, _T("rundll32.exe"), BuildJumpListCommand(item->szPrefix, item->szArgument)); - break; - case MIS_PROTOCOL: - m_pCurrentList->AddItem(item->iconName, item->iconIdx, item->szTitle, _T("rundll32.exe"), BuildJumpListCommand(item->szPrefix, item->szArgument)); - break; - } - return 0; -} - -void CJumpListBuilder::BuildCategory(TCHAR *category) -{ - m_pCurrentList = new CJumpListArray; - NotifyEventHooks(m_hBuildItems, 0, (LPARAM)category); - - if (category) - m_pList->AppendCategory(category, m_pCurrentList->GetArray()); - else - m_pList->AddUserTasks(m_pCurrentList->GetArray()); - delete m_pCurrentList; - -} - -TCHAR *CJumpListBuilder::BuildJumpListCommand(TCHAR *prefix, TCHAR *argument) -{ - TCHAR path[MAX_PATH]; - GetModuleFileName(g_hInst, path, SIZEOF(path)); - mir_sntprintf(m_cmdBuf, SIZEOF(m_cmdBuf), _T("\"%s\",ProcessJumpList %s:%s"), path, prefix, argument); - return m_cmdBuf; -} - -HANDLE CJumpListBuilder::CreateSvc(char *svc, int (__cdecl CJumpListBuilder::*fn)(WPARAM, LPARAM)) -{ - return CreateServiceFunctionObj(svc, *(MIRANDASERVICEOBJ *)&fn, this); -} - -/* -static TCHAR *BuildJumpListCommand(TCHAR *buf, int size, TCHAR *arg); - -static void SetupTasks() -{ - TCHAR buf[MAX_PATH * 2]; - - CJumpListArray tasks; - tasks.AddItem(SKINICON_STATUS_ONLINE, TranslateT("Online"), _T("rundll32.exe"), BuildJumpListCommand(buf, SIZEOF(buf), _T("status:online"))); - tasks.AddItem(SKINICON_STATUS_DND, TranslateT("Do not disturb"), _T("rundll32.exe"), BuildJumpListCommand(buf, SIZEOF(buf), _T("status:dnd"))); - tasks.AddItem(SKINICON_STATUS_INVISIBLE, TranslateT("Invisible"), _T("rundll32.exe"), BuildJumpListCommand(buf, SIZEOF(buf), _T("status:invisible"))); - tasks.AddItem(SKINICON_STATUS_OFFLINE, TranslateT("Offline"), _T("rundll32.exe"), BuildJumpListCommand(buf, SIZEOF(buf), _T("status:offline"))); - -// CJumpListArray contacts; -// contacts.AddItem("core_status_*0", TranslateT("Nickname"), L"taskhost.exe", L"profile.dat -contact:hcontact"); - - UINT maxSlots; - IObjectArray *pRemoved; - - ICustomDestinationList *pList; - CoCreateInstance(CLSID_CustomDestinationList, NULL, CLSCTX_INPROC_SERVER, IID_ICustomDestinationList, (void **)&pList); - pList->BeginList(&maxSlots, IID_IObjectArray, (void **)&pRemoved); - pList->AddUserTasks(tasks.GetArray()); -// pList->AppendCategory(L"Contacts", contacts.GetArray()); - pList->CommitList(); - pList->Release(); - - pRemoved->Release(); -} -*/ \ No newline at end of file diff --git a/plugins/W7UI/jumplistbuilder.h b/plugins/W7UI/jumplistbuilder.h deleted file mode 100644 index 6a0bde2fd4..0000000000 --- a/plugins/W7UI/jumplistbuilder.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef jumplistbuilder_h__ -#define jumplistbuilder_h__ - -class CJumpListBuilder -{ -public: - static void Load(void) - { - m_instance = new CJumpListBuilder; - } - - static void Unload() - { - delete m_instance; - } - - static void Rebuild() - { - m_instance->BuildJumpList(); - } - -private: - static CJumpListBuilder *m_instance; - - LIST *m_lists; - ICustomDestinationList *m_pList; - CJumpListArray *m_pCurrentList; - TCHAR m_cmdBuf[MAX_PATH * 2]; - - HANDLE m_hBuildCategories; - HANDLE m_hBuildItems; - - CJumpListBuilder(); - ~CJumpListBuilder(); - void BuildJumpList(); - - int __cdecl Rebuild(WPARAM wParam, LPARAM lParam); - int __cdecl AddCategory(WPARAM wParam, LPARAM lParam); - int __cdecl AddItem(WPARAM wParam, LPARAM lParam); - - void BuildCategory(TCHAR *category); - - TCHAR *BuildJumpListCommand(TCHAR *prefix, TCHAR *argument); - HANDLE CreateSvc(char *svc, int (__cdecl CJumpListBuilder::*fn)(WPARAM, LPARAM)); -}; - -#endif // jumplistbuilder_h__ diff --git a/plugins/W7UI/main.cpp b/plugins/W7UI/main.cpp deleted file mode 100644 index d9c6898338..0000000000 --- a/plugins/W7UI/main.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* -Miranda core extensions - -Copyright 2000-2007 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "headers.h" -#include - -int LoadW7UI(); -int UnloadW7UI(); - -HINSTANCE g_hInst; -int hLangpack; - -// {3625ACB8-794C-4727-88EA-76DBBAC6D200} -#define MIID_W7UI { 0x3625acb8, 0x794c, 0x4727, { 0x88, 0xea, 0x76, 0xdb, 0xba, 0xc6, 0xd2, 0x0 } } - - -PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - "Windows 7 UI", - PLUGIN_MAKE_VERSION(0, 0, 0, 1), - "Provides support for Windows 7 Taskbar feautures such as Aero Peek, Overlay icons, Jump Lists, Progress Bar", - "nullbie, persei", - "nullbie@miranda.im", - "2009 Victor Pavlychko, Vitaliy Igonin", - "http://nullbie.miranda.im", - UNICODE_AWARE, // replace internal version (if any) - // {D38EEB0B-B8EE-4177-B9E5-91EBE101E054} - { 0xd38eeb0b, 0xb8ee, 0x4177, { 0xb9, 0xe5, 0x91, 0xeb, 0xe1, 0x1, 0xe0, 0x54 } } -}; - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - g_hInst = hinstDLL; - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_W7UI, MIID_LAST }; - -extern "C" __declspec(dllexport) int Load(void) -{ - if (!IsWinVer7Plus()) return 1; - - - mir_getLP(&pluginInfo); - - LoadW7UI(); - - return 0; -} - -extern "C" __declspec(dllexport) int Unload(void) -{ - UnloadW7UI(); - return 0; -} diff --git a/plugins/W7UI/src/clistproxywindow.cpp b/plugins/W7UI/src/clistproxywindow.cpp new file mode 100644 index 0000000000..12e5b476ed --- /dev/null +++ b/plugins/W7UI/src/clistproxywindow.cpp @@ -0,0 +1,292 @@ +#include "headers.h" + +CClistProxyWindow *g_clistProxyWnd = 0; +extern ITaskbarList3 *g_pTaskbarList; + +CClistProxyWindow::CClistProxyWindow() : m_overlayEvents(5) +{ + g_clistProxyWnd = this; + + m_activeOverlay = 0; + m_overlayIcon = 0; + m_overlayText = 0; + + SetWindowText(hwnd(), _T("Miranda IM")); + SendMessage(hwnd(), WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); + SendMessage(hwnd(), WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); + + SetEventHook(ME_CLIST_STATUSMODECHANGE, &CClistProxyWindow::OnStatusModeChanged); + SetEventHook(ME_AV_MYAVATARCHANGED, &CClistProxyWindow::OnAvatarChanged); + SetEventHook(ME_SYSTEM_MODULESLOADED, &CClistProxyWindow::OnModulesLoaded); + SetEventHook(ME_PROTO_ACCLISTCHANGED, &CClistProxyWindow::OnAccListChanged); + + SetTimer(1, 500); +} + +CClistProxyWindow::~CClistProxyWindow() +{ + KillObjectEventHooks(this); +} + +int __cdecl CClistProxyWindow::OnStatusModeChanged(WPARAM wParam, LPARAM lParam) +{ + Update(); + return 0; +} +int __cdecl CClistProxyWindow::OnAvatarChanged(WPARAM wParam, LPARAM lParam) +{ + Update(); + return 0; +} +int __cdecl CClistProxyWindow::OnModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + Update(); + return 0; +} +int __cdecl CClistProxyWindow::OnAccListChanged(WPARAM wParam, LPARAM lParam) +{ + Update(); + return 0; +} + +HANDLE CClistProxyWindow::SetEventHook(char *evt, int (__cdecl CClistProxyWindow::*fn)(WPARAM, LPARAM)) +{ + return HookEventObj(evt, *(MIRANDAHOOKOBJ *)&fn, this); +} + +void CClistProxyWindow::Flash() +{ + FlashWindow(hwnd(), TRUE); +} + +void CClistProxyWindow::SetOverlayIcon(HICON hIcon) +{ + m_overlayIcon = hIcon; + m_overlayIconHandle = 0; +} + +void CClistProxyWindow::SetOverlayIconHandle(HANDLE hIcolibIcon) +{ + m_overlayIcon = 0; + m_overlayIconHandle = hIcolibIcon; +} + +void CClistProxyWindow::AddOverlayEvent(int idx) +{ + m_overlayEvents[idx].Push(); +} + +void CClistProxyWindow::RemoveOverlayEvent(int idx) +{ + m_overlayEvents[idx].Pop(); +} + +int CClistProxyWindow::AllocateOverlayEvent(HANDLE hIcolibIcon) +{ + m_overlayEvents.insert(new COverlayEventSlot(hIcolibIcon, _T("")), m_overlayEvents.getCount()); + return m_overlayEvents.getCount() - 1; +} + +void CClistProxyWindow::Update() +{ + AddButton(LoadSkinnedIcon(SKINICON_OTHER_MIRANDA), TranslateT("Menu"), -1); + + int nAccounts = 0; + PROTOACCOUNT **accounts; + ProtoEnumAccounts(&nAccounts, &accounts); + for (int i = 0; i < nAccounts; ++i) + { + if (!accounts[i]->bIsEnabled || !accounts[i]->bIsVisible || !accounts[i]->ppro || !(accounts[i]->ppro->GetCaps(PFLAGNUM_1) & PF1_IM)) + continue; + + HICON hIcon = LoadSkinnedProtoIcon(accounts[i]->szModuleName, CallProtoService(accounts[i]->szModuleName, PS_GETSTATUS, 0, 0)); + AddButton(hIcon, accounts[i]->tszAccountName, (INT_PTR)accounts[i]->tszAccountName); + } + UpdateButtons(g_pTaskbarList); + + InvalidateThumbnail(); +} + +void CClistProxyWindow::OnActivate(HWND hwndFrom) +{ + CallService(MS_CLIST_SHOWHIDE, 0, 0); + + HWND hwndClui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + if (hwndFrom != hwndClui && !IsIconic(hwndClui) && IsWindowVisible(hwndClui)) + SetForegroundWindow(hwndClui); + else + SetForegroundWindow(NULL); +} + +void CClistProxyWindow::OnToolbar(int id, INT_PTR data) +{ + POINT pt; GetCursorPos(&pt); + HMENU hMenu = NULL; + HWND hwndClui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + + switch (data) + { + case -1: + { + hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDMAIN, 0, 0); + break; + } + + default: + { + hMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0); + int nItems = GetMenuItemCount(hMenu); + for (int i = 0; i < nItems; ++i) + { + TCHAR buf[128]; + MENUITEMINFO mii = {0}; + mii.cbSize = sizeof(mii); + mii.fMask = MIIM_STRING|MIIM_SUBMENU; + mii.dwTypeData = buf; + mii.cch = SIZEOF(buf); + GetMenuItemInfo(hMenu, i, TRUE, &mii); + + if (mii.hSubMenu && !lstrcmp(mii.dwTypeData, (TCHAR*)data)) + { + hMenu = mii.hSubMenu; + break; + } + } + } + } + + SetForegroundWindow(hwndClui); + TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hwndClui, NULL); +} + +void CClistProxyWindow::OnRenderThumbnail(int width, int height) +{ + HBITMAP hbmp = CreateDwmBitmap(width, height); + HDC hdc = CreateCompatibleDC(0); + SelectObject(hdc, hbmp); + + RGBQUAD rgb0, rgb1; + rgb0.rgbRed = 0; rgb0.rgbGreen = 0; rgb0.rgbBlue = 0; + rgb1.rgbRed = 19; rgb1.rgbGreen = 58; rgb1.rgbBlue = 89; + DrawGradient(hdc, 0, 0, width, height, &rgb0, &rgb1); + + HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); + SetTextColor(hdc, RGB(255, 255, 255)); + SetBkMode(hdc, TRANSPARENT); + + RECT rc; + SIZE sz; + SetRect(&rc, 5, 5, width-10, height-10); + + int avatarWidth = 0; + int avatarHeight = 0; + if (true) + { + AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)""); + if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND)) + { + if (ace->bmWidth < width / 4) + { + avatarWidth = ace->bmWidth; + avatarHeight = ace->bmHeight; + } else + { + avatarWidth = width / 4; + avatarHeight = avatarWidth * ace->bmHeight / ace->bmWidth; + } + + AVATARDRAWREQUEST avdr = {0}; + avdr.cbSize = sizeof(avdr); + avdr.hContact = NULL; + avdr.hTargetDC = hdc; + avdr.rcDraw = rc; + avdr.rcDraw.bottom = avdr.rcDraw.top + avatarHeight; + avdr.rcDraw.right = avdr.rcDraw.left + avatarWidth; + avdr.dwFlags = AVDRQ_FALLBACKPROTO | AVDRQ_FORCEALPHA | AVDRQ_OWNPIC; + avdr.szProto = ""; + + avdr.alpha = 255; + CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&avdr); + + rc.left += avatarWidth + 5; + } + } + + int nAccounts = 0; + PROTOACCOUNT **accounts; + ProtoEnumAccounts(&nAccounts, &accounts); + for (int i = 0; i < nAccounts; ++i) + { + if (!accounts[i]->bIsEnabled /*|| !accounts[i]->ppro || !(accounts[i]->ppro->GetCaps(PFLAGNUM_1) & PF1_IM)*/) + continue; + + char *proto = accounts[i]->szModuleName; + + if (true) + { + TCHAR name[128]; name[0] = 0; + + CONTACTINFO ci = {0}; + ci.cbSize = sizeof(ci); + ci.hContact = NULL; + ci.szProto = proto; + ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR; + if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) + { + switch (ci.type) + { + case CNFT_ASCIIZ: + mir_sntprintf(name, SIZEOF(name), _T("%s - %s"), accounts[i]->tszAccountName, ci.pszVal); + mir_free((void *)ci.pszVal); + break; + case CNFT_DWORD: + mir_sntprintf(name, SIZEOF(name), _T("%s - %u"), accounts[i]->tszAccountName, ci.dVal); + break; + } + + } else + { + lstrcpyn(name, accounts[i]->tszAccountName, SIZEOF(name)); + } + + RECT rcText = rc; + rcText.left += 20; + DrawText(hdc, name, -1, &rcText, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP|DT_SINGLELINE); + GetTextExtentPoint32(hdc, name, lstrlen(name), &sz); + } + + if (true) + { + HICON hIcon = LoadSkinnedProtoIcon(proto, CallProtoService(proto, PS_GETSTATUS, 0, 0)); + DrawIconEx(hdc, rc.left, rc.top + (sz.cy - 16) / 2, hIcon, 16, 16, 0, NULL, DI_NORMAL); + } + + rc.top += sz.cy + 5; + } + + SelectObject(hdc, hfntSave); + + DeleteDC(hdc); + MakeBitmapOpaque(hbmp); + SetThumbnail(hbmp); + DeleteObject(hbmp); +} + +void CClistProxyWindow::OnClose() +{ + CallService("CloseAction", NULL, NULL); +} + +void CClistProxyWindow::OnTimer(int id) +{ + HANDLE hIcolibItem = m_overlayIconHandle; + for (m_activeOverlay = (m_activeOverlay + 1) % (m_overlayEvents.getCount() + 1); m_activeOverlay < m_overlayEvents.getCount(); ++m_activeOverlay) + if (m_overlayEvents[m_activeOverlay]) + { + hIcolibItem = m_overlayEvents[m_activeOverlay].GetIcon(); + break; + } + + HICON hIcon = hIcolibItem ? (HICON)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)hIcolibItem) : m_overlayIcon; + if (hIcon) g_pTaskbarList->SetOverlayIcon(hwnd(), hIcon, L""); +} diff --git a/plugins/W7UI/src/clistproxywindow.h b/plugins/W7UI/src/clistproxywindow.h new file mode 100644 index 0000000000..153c59089b --- /dev/null +++ b/plugins/W7UI/src/clistproxywindow.h @@ -0,0 +1,64 @@ +#ifndef clistproxywindow_h__ +#define clistproxywindow_h__ + +class CClistProxyWindow: public CDwmWindow +{ +public: + CClistProxyWindow(); + ~CClistProxyWindow(); + + void Flash(); + void SetOverlayIcon(HICON hIcon); + void SetOverlayIconHandle(HANDLE hIcolibIcon); + void AddOverlayEvent(int idx); + void RemoveOverlayEvent(int idx); + int AllocateOverlayEvent(HANDLE hIcolibIcon); + +private: + class COverlayEventSlot + { + private: + HANDLE m_hIcolibItem; + TCHAR *m_overlayText; + int m_level; + + public: + COverlayEventSlot(HANDLE hIcolibItem, TCHAR *overlayText) + { + m_hIcolibItem = hIcolibItem; + m_overlayText = mir_tstrdup(overlayText); + m_level = 0; + } + ~COverlayEventSlot() { mir_free(m_overlayText); } + void Push() { m_level++; } + void Pop() { if (m_level > 0) m_level--; } + operator bool() { return m_level > 0; } + HANDLE GetIcon() { return m_hIcolibItem; } + }; + + int m_activeOverlay; + HICON m_overlayIcon; + HANDLE m_overlayIconHandle; + TCHAR *m_overlayText; + OBJLIST m_overlayEvents; + + int __cdecl OnStatusModeChanged(WPARAM wParam, LPARAM lParam); + int __cdecl OnAvatarChanged(WPARAM wParam, LPARAM lParam); + int __cdecl OnModulesLoaded(WPARAM wParam, LPARAM lParam); + int __cdecl OnAccListChanged(WPARAM wParam, LPARAM lParam); + + HANDLE SetEventHook(char *evt, int (__cdecl CClistProxyWindow::*fn)(WPARAM, LPARAM)); + + void Update(); + +protected: + void OnActivate(HWND hwndFrom); + void OnToolbar(int id, INT_PTR data); + void OnRenderThumbnail(int width, int height); + void OnClose(); + void OnTimer(int id); +}; + +extern CClistProxyWindow *g_clistProxyWnd; + +#endif // clistproxywindow_h__ diff --git a/plugins/W7UI/src/dwmwindow.cpp b/plugins/W7UI/src/dwmwindow.cpp new file mode 100644 index 0000000000..2d8dd6e9e4 --- /dev/null +++ b/plugins/W7UI/src/dwmwindow.cpp @@ -0,0 +1,209 @@ +#include "headers.h" + +#define WNDCLASSNAME _T("W7DwmWndClass") + +CDwmWindow::CDwmWindow() +{ + GlobalInitWndClass(); + + m_btnInitialized = false; + m_btnCount = 0; + for (int i = 0; i < SIZEOF(m_btnInfo); ++i) + { + m_btnInfo[i].iId = i; + m_btnInfo[i].dwMask = THUMBBUTTONMASK(THB_FLAGS); + m_btnInfo[i].dwFlags = THUMBBUTTONFLAGS(THBF_HIDDEN); + m_btnData[i] = 0; + } + + m_hwnd = CreateWindowEx(WS_EX_APPWINDOW|WS_EX_NOACTIVATE, WNDCLASSNAME, NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, g_hInst, NULL); + SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this); + SetWindowPos(m_hwnd, 0, -100000, -100000, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_DEFERERASE|SWP_NOSENDCHANGING|SWP_SHOWWINDOW); + + BOOL val = 1; + DwmSetWindowAttribute(m_hwnd, DWMWA_HAS_ICONIC_BITMAP, &val, 4); + DwmSetWindowAttribute(m_hwnd, DWMWA_FORCE_ICONIC_REPRESENTATION, &val, 4); + dwmInvalidateIconicBitmaps(m_hwnd); +} + +HBITMAP CDwmWindow::CreateDwmBitmap(int width, int height) +{ + BITMAPINFO bi; + bi.bmiHeader.biSize = sizeof(bi.bmiHeader); + bi.bmiHeader.biWidth = width; + bi.bmiHeader.biHeight = -height; + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biBitCount = 32; + bi.bmiHeader.biCompression = BI_RGB; + return CreateDIBSection(0, &bi, DIB_RGB_COLORS, NULL, 0, 0); +} + +void CDwmWindow::MakeBitmapOpaque(HBITMAP hBmp) +{ + BITMAP bmp; + GetObject(hBmp, sizeof(bmp), &bmp); + if (bmp.bmBitsPixel != 32) return; + if (bmp.bmHeight < 0) bmp.bmHeight *= -1; + + int size = bmp.bmWidth * bmp.bmHeight * 4; + BYTE *data = new BYTE[size]; + GetBitmapBits(hBmp, size, data); + for (int i = 3; i < size; i += 4) + data[i] = 255; + SetBitmapBits(hBmp, size, data); + delete [] data; + +} + +void CDwmWindow::DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1) +{ + int oldMode = SetBkMode(hdc, OPAQUE); + COLORREF oldColor = SetBkColor(hdc, 0); + + RECT rc; SetRect(&rc, x, 0, x+width, 0); + for (int i=y+height; --i >= y; ) { + COLORREF color = RGB( + ((height-i-1)*rgb0->rgbRed + i*rgb1->rgbRed) / height, + ((height-i-1)*rgb0->rgbGreen + i*rgb1->rgbGreen) / height, + ((height-i-1)*rgb0->rgbBlue + i*rgb1->rgbBlue) / height); + rc.top = rc.bottom = i; + ++rc.bottom; + SetBkColor(hdc, color); + ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, "", 0, 0); + } + + SetBkMode(hdc, oldMode); + SetBkColor(hdc, oldColor); +} + +bool CDwmWindow::AddButton(HICON hIcon, TCHAR *text, INT_PTR data, DWORD flags) +{ + if (m_btnCount == SIZEOF(m_btnInfo)) return false; + m_btnInfo[m_btnCount].dwMask = THUMBBUTTONMASK(THB_ICON|THB_TOOLTIP|THB_FLAGS); + m_btnInfo[m_btnCount].hIcon = hIcon; + lstrcpyn(m_btnInfo[m_btnCount].szTip, text, SIZEOF(m_btnInfo[m_btnCount].szTip)); + m_btnInfo[m_btnCount].dwFlags = THUMBBUTTONFLAGS(flags); + m_btnData[m_btnCount] = data; + m_btnCount++; + return true; +} + +void CDwmWindow::UpdateButtons(ITaskbarList3 *p) +{ + if (m_btnInitialized) + p->ThumbBarUpdateButtons(hwnd(), SIZEOF(m_btnInfo), m_btnInfo); + else + p->ThumbBarAddButtons(hwnd(), SIZEOF(m_btnInfo), m_btnInfo); + + m_btnCount = 0; // reset this for next iteration + m_btnInitialized = true; +} + +void CDwmWindow::SetTimer(int id, int timeout) +{ + ::SetTimer(m_hwnd, id, timeout, NULL); +} + +void CDwmWindow::KillTimer(int id) +{ + ::KillTimer(m_hwnd, id); +} + +void CDwmWindow::InvalidateThumbnail() +{ + dwmInvalidateIconicBitmaps(m_hwnd); +} + +void CDwmWindow::SetPreview(HBITMAP hbmp, int x, int y) +{ + POINT pt = { x, y }; + dwmSetIconicLivePreviewBitmap(m_hwnd, hbmp, &pt, 0); +} + +void CDwmWindow::SetThumbnail(HBITMAP hbmp) +{ + dwmSetIconicThumbnail(m_hwnd, hbmp, 0); +} + +LRESULT CDwmWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_ACTIVATE: + { + if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) + { + OnActivate((HWND)wParam); + } + break; + } + + case WM_CLOSE: + { + OnClose(); + return FALSE; + } + + case WM_DWMSENDICONICLIVEPREVIEWBITMAP: + { + OnRenderPreview(); + break; + } + + case WM_DWMSENDICONICTHUMBNAIL: + { + int width = HIWORD(lParam); + int height = LOWORD(lParam); + OnRenderThumbnail(width, height); + break; + } + + case WM_TIMER: + { + OnTimer(wParam); + break; + } + + case WM_COMMAND: + { + if (HIWORD(wParam) == THBN_CLICKED) + OnToolbar(LOWORD(wParam), m_btnData[LOWORD(wParam)]); + break; + } + } + + return DefWindowProc(m_hwnd, msg, wParam, lParam); +} + +void CDwmWindow::GlobalInitWndClass() +{ + static bool bInitialized = false; + if (bInitialized) return; + + WNDCLASSEX wcl = {0}; + wcl.cbSize = sizeof(wcl); + wcl.lpfnWndProc = GlobalWndProc; + wcl.style = 0; + wcl.cbClsExtra = 0; + wcl.cbWndExtra = 0; + wcl.hInstance = g_hInst; + wcl.hIcon = NULL; + wcl.hCursor = LoadCursor(NULL, IDC_ARROW); + wcl.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); + wcl.lpszMenuName = NULL; + wcl.lpszClassName = WNDCLASSNAME; + wcl.hIconSm = NULL; + RegisterClassEx(&wcl); +} + +LRESULT CALLBACK CDwmWindow::GlobalWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + CDwmWindow *wnd = (CDwmWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if (!wnd) return DefWindowProc(hwnd, msg, wParam, lParam); + if (msg == WM_DESTROY) + { + delete wnd; + return DefWindowProc(hwnd, msg, wParam, lParam); + } + return wnd->WndProc(msg, wParam, lParam); +} \ No newline at end of file diff --git a/plugins/W7UI/src/dwmwindow.h b/plugins/W7UI/src/dwmwindow.h new file mode 100644 index 0000000000..e795823247 --- /dev/null +++ b/plugins/W7UI/src/dwmwindow.h @@ -0,0 +1,59 @@ +#ifndef dwmwindow_h__ +#define dwmwindow_h__ + +class CDwmWindow +{ +public: + CDwmWindow(); + virtual ~CDwmWindow() {} + + HWND hwnd() { return m_hwnd; } + + template + static TWindow *GetWindow(HWND hwnd) + { + return (TWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + } + +protected: + // events + virtual void OnActivate(HWND hwndFrom) {} + virtual void OnClose() {} + virtual void OnRenderThumbnail(int mzxWidth, int maxHeight) {} + virtual void OnRenderPreview() {} + virtual void OnTimer(int id) {} + virtual void OnToolbar(int id, INT_PTR data) {} + + // timer stuff + void SetTimer(int id, int timeout); + void KillTimer(int id); + + // manage thumbnail and aero peek + void InvalidateThumbnail(); + void SetPreview(HBITMAP hbmp, int x, int y); + void SetThumbnail(HBITMAP hbmp); + + // manage toolbar + bool AddButton(HICON hIcon, TCHAR *text, INT_PTR data, DWORD flags = THBF_ENABLED); + void UpdateButtons(ITaskbarList3 *p); + + //utilities + static HBITMAP CreateDwmBitmap(int width, int height); + static void MakeBitmapOpaque(HBITMAP hBmp); + static void DrawGradient(HDC hdc, int x, int y, int width, int height, RGBQUAD *rgb0, RGBQUAD *rgb1); + +private: + HWND m_hwnd; + + bool m_btnInitialized; + int m_btnCount; + THUMBBUTTON m_btnInfo[7]; + INT_PTR m_btnData[7]; + + LRESULT CALLBACK WndProc(UINT msg, WPARAM wParam, LPARAM lParam); + + static void GlobalInitWndClass(); + static LRESULT CALLBACK GlobalWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +}; + +#endif // dwmwindow_h__ \ No newline at end of file diff --git a/plugins/W7UI/src/headers.h b/plugins/W7UI/src/headers.h new file mode 100644 index 0000000000..7d28902466 --- /dev/null +++ b/plugins/W7UI/src/headers.h @@ -0,0 +1,78 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#define _CRT_SECURE_NO_DEPRECATE + + +#include +#define _WIN32_WINNT 0x0501 +#include +#include +#include +#include + +#include +#include +#include + +#define MIRANDA_VER 0x0A00 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "m_w7ui.h" + +#include "win7api.h" + +#include "jumplistarray.h" +#include "jumplistbuilder.h" +#include "jumplist.h" + +#include "subclassmgr.h" +#include "dwmwindow.h" +#include "clistproxywindow.h" +#include "srmmproxywindow.h" + +extern HINSTANCE g_hInst; diff --git a/plugins/W7UI/src/jumplist.cpp b/plugins/W7UI/src/jumplist.cpp new file mode 100644 index 0000000000..4fd1a68e9d --- /dev/null +++ b/plugins/W7UI/src/jumplist.cpp @@ -0,0 +1,123 @@ +#include "headers.h" + +static HANDLE hProcessJumpList = 0; + +static void ProcessJumpListImpl(char *arg) +{ + char *prefix = mir_strdup(arg); + char *argument = strchr(prefix, ':'); + if (argument) *argument++ = 0; + NotifyEventHooks(hProcessJumpList, (WPARAM)prefix, (LPARAM)argument); + mir_free(prefix); +} + +static LRESULT CALLBACK MirandaJumpListProcessorWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COPYDATA: + { + COPYDATASTRUCT *data = (COPYDATASTRUCT *)lParam; + ProcessJumpListImpl((char *)data->lpData); + break; + } + } + + return DefWindowProc(hwnd, message, wParam, lParam); +} + +extern "C" __declspec(dllexport) void ProcessJumpList(HWND, HINSTANCE, LPSTR arg, UINT) +{ + char miranda_path[MAX_PATH]; + GetModuleFileNameA(g_hInst, miranda_path, SIZEOF(miranda_path)); + lstrcpyA(strstr(_strlwr(miranda_path), "plugins\\w7ui.dll"), "miranda32.exe"); + + if (HWND hwnd = FindWindowA("MirandaJumpListProcessor", miranda_path)) + { + COPYDATASTRUCT data = {0}; + data.dwData = 0; + data.cbData = lstrlenA(arg) + 1; + data.lpData = arg; + SendMessage(hwnd, WM_COPYDATA, 0, (LPARAM)&data); + } else + { + char command[MAX_PATH * 2]; + wsprintfA(command, "\"%s\" -jump %s", miranda_path, arg); + WinExec(command, SW_SHOWNORMAL); + } +} + +static int OnJumpListItems(WPARAM, LPARAM lParam) +{ + WCHAR *category = (WCHAR *)lParam; + + if (!category) + { + MJumpList_AddItem(SKINICON_STATUS_ONLINE, TranslateT("Online"), L"status", L"online"); + MJumpList_AddItem(SKINICON_STATUS_DND, TranslateT("Do not disturb"), L"status", L"dnd"); + MJumpList_AddItem(SKINICON_STATUS_INVISIBLE, TranslateT("Invisible"), L"status", L"invisible"); + MJumpList_AddItem(SKINICON_STATUS_OFFLINE, TranslateT("Offline"), L"status", L"offline"); + return 0; + } + + return 0; +} + +static int OnJumpListProcess(WPARAM wParam, LPARAM lParam) +{ + char *prefix = (char *)wParam; + char *argument = (char *)lParam; + + if (!lstrcmpA(prefix, "status")) + { + if (!lstrcmpA(argument, "online")) + { + CallService(MS_CLIST_SETSTATUSMODE, ID_STATUS_ONLINE, 0); + } else + if (!lstrcmpA(argument, "dnd")) + { + CallService(MS_CLIST_SETSTATUSMODE, ID_STATUS_DND, 0); + } else + if (!lstrcmpA(argument, "invisible")) + { + CallService(MS_CLIST_SETSTATUSMODE, ID_STATUS_INVISIBLE, 0); + } else + if (!lstrcmpA(argument, "offline")) + { + CallService(MS_CLIST_SETSTATUSMODE, ID_STATUS_OFFLINE, 0); + } + return 1; + } + + return 0; +} + +void LoadJumpList() +{ + hProcessJumpList = CreateHookableEvent(ME_JUMPLIST_PROCESS); +} + +void InitJumpList() +{ + HookEvent(ME_JUMPLIST_BUILDITEMS, OnJumpListItems); + HookEvent(ME_JUMPLIST_PROCESS, OnJumpListProcess); + + if (char *cmd = strstr(GetCommandLineA(), " -jump ")) + ProcessJumpListImpl(cmd + 7); + + WNDCLASSEX wcx = {0}; + wcx.cbSize = sizeof(wcx); + wcx.lpfnWndProc = MirandaJumpListProcessorWndProc; + wcx.hInstance = g_hInst; + wcx.lpszClassName = _T("MirandaJumpListProcessor"); + RegisterClassEx(&wcx); + + char miranda_path[MAX_PATH]; + GetModuleFileNameA(g_hInst, miranda_path, SIZEOF(miranda_path)); + lstrcpyA(strstr(_strlwr(miranda_path), "plugins\\w7ui.dll"), "miranda32.exe"); + + HWND hwnd = CreateWindowA("MirandaJumpListProcessor", miranda_path, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, g_hInst, NULL); + ShowWindow(hwnd, SW_HIDE); + + CJumpListBuilder::Rebuild(); +} diff --git a/plugins/W7UI/src/jumplist.h b/plugins/W7UI/src/jumplist.h new file mode 100644 index 0000000000..de5a6f0548 --- /dev/null +++ b/plugins/W7UI/src/jumplist.h @@ -0,0 +1,7 @@ +#ifndef jumplist_h__ +#define jumplist_h__ + +void LoadJumpList(); +void InitJumpList(); + +#endif // jumplist_h__ diff --git a/plugins/W7UI/src/jumplistarray.cpp b/plugins/W7UI/src/jumplistarray.cpp new file mode 100644 index 0000000000..669a7784ef --- /dev/null +++ b/plugins/W7UI/src/jumplistarray.cpp @@ -0,0 +1,214 @@ +#include "headers.h" + +#pragma pack(push, 1) +typedef struct +{ + BYTE bWidth; // Width, in pixels, of the image + BYTE bHeight; // Height, in pixels, of the image + BYTE bColorCount; // Number of colors in image (0 if >=8bpp) + BYTE bReserved; // Reserved ( must be 0) + WORD wPlanes; // Color Planes + WORD wBitCount; // Bits per pixel + DWORD dwBytesInRes; // How many bytes in this resource? + DWORD dwImageOffset; // Where in the file is this image? +} ICONDIRENTRY, *LPICONDIRENTRY; + +typedef struct +{ + WORD idReserved; // Reserved (must be 0) + WORD idType; // Resource Type (1 for icons) + WORD idCount; // How many images? + ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em) +} ICONDIR, *LPICONDIR; +#pragma pack(pop) + +static void SaveIconToFile(HICON hIcon, TCHAR *szFile) +{ + ICONINFO iconInfo = {0}; + BITMAP bmpColor, bmpMask; + HANDLE hFile = 0; + HANDLE hMap = 0; + BYTE *pFile = 0; + + GetIconInfo(hIcon, &iconInfo); + GetObject(iconInfo.hbmColor, sizeof(bmpColor), &bmpColor); + GetObject(iconInfo.hbmMask, sizeof(bmpMask), &bmpMask); + + do + { + if (bmpColor.bmBitsPixel <= 8) break; + + DWORD dwColorSize = bmpColor.bmWidthBytes * bmpColor.bmHeight; + DWORD dwMaskSize = bmpMask.bmWidthBytes * bmpMask.bmHeight; + DWORD dwFileSize = sizeof(ICONDIR) + sizeof(BITMAPINFOHEADER) + dwColorSize + dwMaskSize; + + hFile = CreateFile(szFile, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL); + if (hFile == INVALID_HANDLE_VALUE) break; + hMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwFileSize, NULL); + if (!hMap) break; + pFile = (BYTE *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0 ,0); + if (!pFile) break; + + ICONDIR iconDir = {0}; + iconDir.idCount = 1; + iconDir.idType = 1; + iconDir.idEntries[0].bWidth = bmpColor.bmWidth; + iconDir.idEntries[0].bHeight = bmpColor.bmHeight; + iconDir.idEntries[0].bColorCount = 0; + iconDir.idEntries[0].wPlanes = bmpColor.bmPlanes; + iconDir.idEntries[0].wBitCount = bmpColor.bmBitsPixel; + iconDir.idEntries[0].dwBytesInRes = sizeof(BITMAPINFOHEADER) + dwColorSize + dwMaskSize; + iconDir.idEntries[0].dwImageOffset = sizeof(ICONDIR); + MoveMemory(pFile, &iconDir, sizeof(ICONDIR)); + + BITMAPINFOHEADER iconBmp = {0}; + iconBmp.biSize = sizeof(iconBmp); + iconBmp.biWidth = bmpColor.bmWidth; + iconBmp.biHeight = bmpColor.bmHeight + bmpMask.bmHeight; + iconBmp.biPlanes = bmpColor.bmPlanes; + iconBmp.biBitCount = bmpColor.bmBitsPixel; + iconBmp.biSizeImage = dwColorSize + dwMaskSize; + MoveMemory(pFile + sizeof(ICONDIR), &iconBmp, sizeof(BITMAPINFOHEADER)); + + BYTE *buf = (BYTE *)mir_alloc(dwColorSize); + GetBitmapBits(iconInfo.hbmColor, dwColorSize, buf); + for (int row = 0; row < bmpColor.bmHeight; ++row) + { + MoveMemory( + pFile + sizeof(ICONDIR) + sizeof(BITMAPINFOHEADER) + row * bmpColor.bmWidthBytes, + buf + (bmpColor.bmHeight - row - 1) * bmpColor.bmWidthBytes, + bmpColor.bmWidthBytes); + } + mir_free(buf); + + GetBitmapBits(iconInfo.hbmMask, dwMaskSize, pFile + sizeof(ICONDIR) + sizeof(BITMAPINFOHEADER) + dwColorSize); + } while(0); + + DeleteObject(iconInfo.hbmColor); + DeleteObject(iconInfo.hbmMask); + + if (pFile) UnmapViewOfFile(pFile); + if (hMap) CloseHandle(hMap); + if (hFile && hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); +} + +CJumpListArray::CJumpListArray() +{ + CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER, IID_IObjectCollection, (void **)&m_pObjects); +} + +CJumpListArray::~CJumpListArray() +{ + if (m_pObjects) m_pObjects->Release(); +} + +void CJumpListArray::AddItemImpl(TCHAR *icon, int iIcon, TCHAR *title, TCHAR *path, TCHAR *args) +{ + IShellLink *link = NewShellLink(icon, iIcon, title, path, args); + m_pObjects->AddObject(link); + link->Release(); +} + +void CJumpListArray::AddItem(char *mir_icon, TCHAR *title, TCHAR *path, TCHAR *args) +{ + TCHAR icon[MAX_PATH]; int iIcon; + LoadMirandaIcon(mir_icon, icon, &iIcon); + AddItemImpl(icon, iIcon, title, path, args); +} + +void CJumpListArray::AddItem(int skinicon, TCHAR *title, TCHAR *path, TCHAR *args) +{ + TCHAR icon[MAX_PATH]; int iIcon; + LoadMirandaIcon(skinicon, icon, &iIcon); + AddItemImpl(icon, iIcon, title, path, args); +} + +void CJumpListArray::AddItem(char *proto, int status, TCHAR *title, TCHAR *path, TCHAR *args) +{ + TCHAR icon[MAX_PATH]; int iIcon; + LoadMirandaIcon(proto, status, icon, &iIcon); + AddItemImpl(icon, iIcon, title, path, args); +} + +IObjectArray *CJumpListArray::GetArray() +{ + IObjectArray *result = NULL; + m_pObjects->QueryInterface(IID_IObjectArray, (void **)&result); + return result; +} + +bool CJumpListArray::LoadMirandaIcon(char *mir_icon, TCHAR *icon, int *id) +{ + *id = 0; + + TCHAR *path = Utils_ReplaceVarsT(_T("%miranda_userdata%\\w7ui.IconCache")); + CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path); + + TCHAR *name = mir_a2t(mir_icon); + for (TCHAR *ch = name; *ch; ++ch) if (_tcschr(_T("\\/:*?<>|"), *ch)) *ch = _T('_'); + mir_sntprintf(icon, MAX_PATH, _T("%s\\%s.ico"), path, name); + + mir_free(name); + mir_free(path); + + HICON hIcon = (HICON)CallService(MS_SKIN2_GETICON, 0, (LPARAM)mir_icon); + SaveIconToFile(hIcon, icon); + + return true; +} + +bool CJumpListArray::LoadMirandaIcon(int skinicon, TCHAR *icon, int *id) +{ + *id = 0; + + TCHAR *path = Utils_ReplaceVarsT(_T("%miranda_userdata%\\w7ui.IconCache")); + CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path); + mir_sntprintf(icon, MAX_PATH, _T("%s\\skinicon$%d.ico"), path, skinicon); + mir_free(path); + + HICON hIcon = LoadSkinnedIcon(skinicon); + SaveIconToFile(hIcon, icon); + + return true; +} + +bool CJumpListArray::LoadMirandaIcon(char *proto, int status, TCHAR *icon, int *id) +{ + *id = 0; + + TCHAR *path = Utils_ReplaceVarsT(_T("%miranda_userdata%\\w7ui.IconCache")); + CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path); + mir_sntprintf(icon, MAX_PATH, _T("%s\\skinprotoicon$") _T(TCHAR_STR_PARAM) _T("$%d.ico"), path, proto, status); + mir_free(path); + + HICON hIcon = LoadSkinnedProtoIcon(proto, status); + SaveIconToFile(hIcon, icon); + + return true; +} + +IShellLink *CJumpListArray::NewShellLink(TCHAR *icon, int iIcon, TCHAR *title, TCHAR *path, TCHAR *args) +{ + IShellLink *pShellLink = NULL; + CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&pShellLink); + + pShellLink->SetPath(path); + pShellLink->SetIconLocation(icon, iIcon); + pShellLink->SetArguments(args); + pShellLink->SetShowCmd(SW_SHOWDEFAULT); + + IPropertyStore *pPropStore = NULL; + if (SUCCEEDED(pShellLink->QueryInterface(IID_IPropertyStore, (void **)&pPropStore))) + { + PROPVARIANT pv; + + InitPropVariantFromString(title, &pv); + pPropStore->SetValue(PKEY_Title, pv); + PropVariantClear(&pv); + + pPropStore->Commit(); + pPropStore->Release(); + } + + return pShellLink; +} \ No newline at end of file diff --git a/plugins/W7UI/src/jumplistarray.h b/plugins/W7UI/src/jumplistarray.h new file mode 100644 index 0000000000..c9f2a8b979 --- /dev/null +++ b/plugins/W7UI/src/jumplistarray.h @@ -0,0 +1,29 @@ +#ifndef jumplistarray_h__ +#define jumplistarray_h__ + +class CJumpListArray +{ +private: + IObjectCollection *m_pObjects; + +public: + CJumpListArray(); + ~CJumpListArray(); + + void AddItem(char *mir_icon, TCHAR *title, TCHAR *path, TCHAR *args); + void AddItem(int skinicon, TCHAR *title, TCHAR *path, TCHAR *args); + void AddItem(char *proto, int skinicon, TCHAR *title, TCHAR *path, TCHAR *args); + + IObjectArray *GetArray(); + +private: + void AddItemImpl(TCHAR *icon, int iIcon, TCHAR *title, TCHAR *path, TCHAR *args); + + bool LoadMirandaIcon(char *mir_icon, TCHAR *icon, int *id); + bool LoadMirandaIcon(int skinicon, TCHAR *icon, int *id); + bool LoadMirandaIcon(char *proto, int status, TCHAR *icon, int *id); + + static IShellLink *NewShellLink(TCHAR *icon, int iIcon, TCHAR *title, TCHAR *path, TCHAR *args); +}; + +#endif // jumplistarray_h__ diff --git a/plugins/W7UI/src/jumplistbuilder.cpp b/plugins/W7UI/src/jumplistbuilder.cpp new file mode 100644 index 0000000000..5e5f1d9f65 --- /dev/null +++ b/plugins/W7UI/src/jumplistbuilder.cpp @@ -0,0 +1,127 @@ +#include "headers.h" + +CJumpListBuilder *CJumpListBuilder::m_instance = 0; + +CJumpListBuilder::CJumpListBuilder() +{ + m_hBuildCategories = CreateHookableEvent(ME_JUMPLIST_BUILDCATEGORIES); + m_hBuildItems = CreateHookableEvent(ME_JUMPLIST_BUILDITEMS); + CreateSvc(MS_JUMPLIST_REBUILD, &CJumpListBuilder::Rebuild); + CreateSvc(MS_JUMPLIST_ADDCATEGORY, &CJumpListBuilder::AddCategory); + CreateSvc(MS_JUMPLIST_ADDITEM, &CJumpListBuilder::AddItem); +} + +CJumpListBuilder::~CJumpListBuilder() +{ + KillObjectServices(this); + DestroyHookableEvent(m_hBuildCategories); + DestroyHookableEvent(m_hBuildItems); +} + +void CJumpListBuilder::BuildJumpList() +{ + m_lists = new LIST(5, _tcscmp); + NotifyEventHooks(m_hBuildCategories, 0, 0); + + UINT maxSlots; + IObjectArray *pRemoved; + CoCreateInstance(CLSID_CustomDestinationList, NULL, CLSCTX_INPROC_SERVER, IID_ICustomDestinationList, (void **)&m_pList); + m_pList->BeginList(&maxSlots, IID_IObjectArray, (void **)&pRemoved); + BuildCategory(NULL); + for (int i = 0; i < m_lists->getCount(); ++i) + BuildCategory((*m_lists)[i]); + m_pList->CommitList(); + m_pList->Release(); + pRemoved->Release(); + + m_lists->destroy(); + delete m_lists; +} + +int __cdecl CJumpListBuilder::Rebuild(WPARAM wParam, LPARAM lParam) +{ + BuildJumpList(); + return 0; +} + +int __cdecl CJumpListBuilder::AddCategory(WPARAM wParam, LPARAM lParam) +{ + TCHAR *category = (TCHAR *)lParam; + if (!m_lists->find(category)) m_lists->insert(mir_wstrdup(category)); + return 0; +} + +int __cdecl CJumpListBuilder::AddItem(WPARAM wParam, LPARAM lParam) +{ + MIRANDAJUMPLISTITEM *item = (MIRANDAJUMPLISTITEM *)lParam; + switch (item->iconSource) + { + case MIS_ICOLIB: + m_pCurrentList->AddItem(item->iconName, item->szTitle, _T("rundll32.exe"), BuildJumpListCommand(item->szPrefix, item->szArgument)); + break; + case MIS_GENERAL: + m_pCurrentList->AddItem(item->iconIdx, item->szTitle, _T("rundll32.exe"), BuildJumpListCommand(item->szPrefix, item->szArgument)); + break; + case MIS_PROTOCOL: + m_pCurrentList->AddItem(item->iconName, item->iconIdx, item->szTitle, _T("rundll32.exe"), BuildJumpListCommand(item->szPrefix, item->szArgument)); + break; + } + return 0; +} + +void CJumpListBuilder::BuildCategory(TCHAR *category) +{ + m_pCurrentList = new CJumpListArray; + NotifyEventHooks(m_hBuildItems, 0, (LPARAM)category); + + if (category) + m_pList->AppendCategory(category, m_pCurrentList->GetArray()); + else + m_pList->AddUserTasks(m_pCurrentList->GetArray()); + delete m_pCurrentList; + +} + +TCHAR *CJumpListBuilder::BuildJumpListCommand(TCHAR *prefix, TCHAR *argument) +{ + TCHAR path[MAX_PATH]; + GetModuleFileName(g_hInst, path, SIZEOF(path)); + mir_sntprintf(m_cmdBuf, SIZEOF(m_cmdBuf), _T("\"%s\",ProcessJumpList %s:%s"), path, prefix, argument); + return m_cmdBuf; +} + +HANDLE CJumpListBuilder::CreateSvc(char *svc, int (__cdecl CJumpListBuilder::*fn)(WPARAM, LPARAM)) +{ + return CreateServiceFunctionObj(svc, *(MIRANDASERVICEOBJ *)&fn, this); +} + +/* +static TCHAR *BuildJumpListCommand(TCHAR *buf, int size, TCHAR *arg); + +static void SetupTasks() +{ + TCHAR buf[MAX_PATH * 2]; + + CJumpListArray tasks; + tasks.AddItem(SKINICON_STATUS_ONLINE, TranslateT("Online"), _T("rundll32.exe"), BuildJumpListCommand(buf, SIZEOF(buf), _T("status:online"))); + tasks.AddItem(SKINICON_STATUS_DND, TranslateT("Do not disturb"), _T("rundll32.exe"), BuildJumpListCommand(buf, SIZEOF(buf), _T("status:dnd"))); + tasks.AddItem(SKINICON_STATUS_INVISIBLE, TranslateT("Invisible"), _T("rundll32.exe"), BuildJumpListCommand(buf, SIZEOF(buf), _T("status:invisible"))); + tasks.AddItem(SKINICON_STATUS_OFFLINE, TranslateT("Offline"), _T("rundll32.exe"), BuildJumpListCommand(buf, SIZEOF(buf), _T("status:offline"))); + +// CJumpListArray contacts; +// contacts.AddItem("core_status_*0", TranslateT("Nickname"), L"taskhost.exe", L"profile.dat -contact:hcontact"); + + UINT maxSlots; + IObjectArray *pRemoved; + + ICustomDestinationList *pList; + CoCreateInstance(CLSID_CustomDestinationList, NULL, CLSCTX_INPROC_SERVER, IID_ICustomDestinationList, (void **)&pList); + pList->BeginList(&maxSlots, IID_IObjectArray, (void **)&pRemoved); + pList->AddUserTasks(tasks.GetArray()); +// pList->AppendCategory(L"Contacts", contacts.GetArray()); + pList->CommitList(); + pList->Release(); + + pRemoved->Release(); +} +*/ \ No newline at end of file diff --git a/plugins/W7UI/src/jumplistbuilder.h b/plugins/W7UI/src/jumplistbuilder.h new file mode 100644 index 0000000000..6a0bde2fd4 --- /dev/null +++ b/plugins/W7UI/src/jumplistbuilder.h @@ -0,0 +1,47 @@ +#ifndef jumplistbuilder_h__ +#define jumplistbuilder_h__ + +class CJumpListBuilder +{ +public: + static void Load(void) + { + m_instance = new CJumpListBuilder; + } + + static void Unload() + { + delete m_instance; + } + + static void Rebuild() + { + m_instance->BuildJumpList(); + } + +private: + static CJumpListBuilder *m_instance; + + LIST *m_lists; + ICustomDestinationList *m_pList; + CJumpListArray *m_pCurrentList; + TCHAR m_cmdBuf[MAX_PATH * 2]; + + HANDLE m_hBuildCategories; + HANDLE m_hBuildItems; + + CJumpListBuilder(); + ~CJumpListBuilder(); + void BuildJumpList(); + + int __cdecl Rebuild(WPARAM wParam, LPARAM lParam); + int __cdecl AddCategory(WPARAM wParam, LPARAM lParam); + int __cdecl AddItem(WPARAM wParam, LPARAM lParam); + + void BuildCategory(TCHAR *category); + + TCHAR *BuildJumpListCommand(TCHAR *prefix, TCHAR *argument); + HANDLE CreateSvc(char *svc, int (__cdecl CJumpListBuilder::*fn)(WPARAM, LPARAM)); +}; + +#endif // jumplistbuilder_h__ diff --git a/plugins/W7UI/src/main.cpp b/plugins/W7UI/src/main.cpp new file mode 100644 index 0000000000..d9c6898338 --- /dev/null +++ b/plugins/W7UI/src/main.cpp @@ -0,0 +1,79 @@ +/* +Miranda core extensions + +Copyright 2000-2007 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "headers.h" +#include + +int LoadW7UI(); +int UnloadW7UI(); + +HINSTANCE g_hInst; +int hLangpack; + +// {3625ACB8-794C-4727-88EA-76DBBAC6D200} +#define MIID_W7UI { 0x3625acb8, 0x794c, 0x4727, { 0x88, 0xea, 0x76, 0xdb, 0xba, 0xc6, 0xd2, 0x0 } } + + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + "Windows 7 UI", + PLUGIN_MAKE_VERSION(0, 0, 0, 1), + "Provides support for Windows 7 Taskbar feautures such as Aero Peek, Overlay icons, Jump Lists, Progress Bar", + "nullbie, persei", + "nullbie@miranda.im", + "2009 Victor Pavlychko, Vitaliy Igonin", + "http://nullbie.miranda.im", + UNICODE_AWARE, // replace internal version (if any) + // {D38EEB0B-B8EE-4177-B9E5-91EBE101E054} + { 0xd38eeb0b, 0xb8ee, 0x4177, { 0xb9, 0xe5, 0x91, 0xeb, 0xe1, 0x1, 0xe0, 0x54 } } +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + g_hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_W7UI, MIID_LAST }; + +extern "C" __declspec(dllexport) int Load(void) +{ + if (!IsWinVer7Plus()) return 1; + + + mir_getLP(&pluginInfo); + + LoadW7UI(); + + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + UnloadW7UI(); + return 0; +} diff --git a/plugins/W7UI/src/srmmproxywindow.cpp b/plugins/W7UI/src/srmmproxywindow.cpp new file mode 100644 index 0000000000..a70ca1b672 --- /dev/null +++ b/plugins/W7UI/src/srmmproxywindow.cpp @@ -0,0 +1,374 @@ +#include "headers.h" + +extern int g_eventSlotMessage; +extern ITaskbarList3 *g_pTaskbarList; + +/////////////////////////////////////////////////////////////////////////////// +// srmm processing + +CSrmmProxyWindow::CSrmmProxyWindow(HANDLE hContact, HWND hwndWindow, HWND hwndParent) +{ + m_hContact = hContact; + m_hwndWindow = hwndWindow; + m_hwndParent = hwndParent; + + m_hbmpPreview = NULL; + m_refreshPreview = true; + + m_bActive = false; + m_bUnread = false; + m_bTyping = false; + + UpdateIcon(); + SetWindowText(hwnd(), (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)m_hContact, GCDNF_TCHAR)); + SetTimer(1, 1000); + + SetEventHook(ME_DB_EVENT_ADDED, &CSrmmProxyWindow::OnDbEventAdded); + SetEventHook(ME_DB_CONTACT_SETTINGCHANGED, &CSrmmProxyWindow::OnDbSettingChanged); + SetEventHook(ME_AV_AVATARCHANGED, &CSrmmProxyWindow::OnAvatarChanged); + SetEventHook(ME_PROTO_CONTACTISTYPING, &CSrmmProxyWindow::OnContactTyping); + + AddButton(LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS), TranslateT("User Details"), 1, THBF_DISMISSONCLICK); + AddButton(LoadSkinnedIcon(SKINICON_OTHER_HISTORY), TranslateT("History"), 2, THBF_DISMISSONCLICK); + AddButton(LoadSkinnedIcon(SKINICON_EVENT_FILE), TranslateT("File"), 3, THBF_DISMISSONCLICK); + UpdateButtons(g_pTaskbarList); +} + +CSrmmProxyWindow::~CSrmmProxyWindow() +{ + DeleteObject(m_hbmpPreview); + KillObjectEventHooks(this); +} + + +void CSrmmProxyWindow::Refresh() +{ + InvalidateThumbnail(); + m_refreshPreview = true; +} + +int __cdecl CSrmmProxyWindow::OnDbEventAdded(WPARAM wParam, LPARAM lParam) +{ + if ((HANDLE)wParam == m_hContact) + { + Refresh(); + + if (!m_bUnread && !IsActive()) + { + DBEVENTINFO dbei = {0}; + dbei.cbSize = sizeof(dbei); + if (!CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM)&dbei)) + if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & (DBEF_READ|DBEF_SENT))) + { + g_clistProxyWnd->Flash(); + g_clistProxyWnd->AddOverlayEvent(g_eventSlotMessage); + m_bUnread = true; + UpdateIcon(); + } + } + } + return 0; +} + +int __cdecl CSrmmProxyWindow::OnDbSettingChanged(WPARAM wParam, LPARAM lParam) +{ + if ((HANDLE)wParam == m_hContact) + { + UpdateIcon(); + Refresh(); + } + return 0; +} + +int __cdecl CSrmmProxyWindow::OnAvatarChanged(WPARAM wParam, LPARAM lParam) +{ + if ((HANDLE)wParam == m_hContact) + Refresh(); + return 0; +} + +int __cdecl CSrmmProxyWindow::OnContactTyping(WPARAM wParam, LPARAM lParam) +{ + if ((HANDLE)wParam == m_hContact) + { + m_bTyping = lParam ? true : false; + UpdateIcon(); + } + return 0; +} + +HANDLE CSrmmProxyWindow::SetEventHook(char *evt, int (__cdecl CSrmmProxyWindow::*fn)(WPARAM, LPARAM)) +{ + return HookEventObj(evt, *(MIRANDAHOOKOBJ *)&fn, this); +} + +void CSrmmProxyWindow::OnTabActive() +{ + m_bActive = true; + if (m_bUnread) + { + g_clistProxyWnd->RemoveOverlayEvent(g_eventSlotMessage); + m_bUnread = false; + UpdateIcon(); + } +} + +void CSrmmProxyWindow::OnTabInactive() +{ + m_bActive = false; +} + +bool CSrmmProxyWindow::IsActive() +{ + for (HWND hwnd = GetFocus(); hwnd; hwnd = GetParent(hwnd)) + if (hwnd == m_hwndWindow) + return m_bActive = true; + return m_bActive = false; +} + +void CSrmmProxyWindow::UpdateIcon() +{ + HICON hIcon; + if (m_bTyping) + { + hIcon = LoadSkinnedIcon(SKINICON_OTHER_TYPING); + } else + if (m_bUnread) + { + hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); + } else + { + char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0); + if (!szProto) return; + int iStatus = DBGetContactSettingWord(m_hContact, szProto, "Status", ID_STATUS_OFFLINE); + hIcon = (HICON)LoadSkinnedProtoIcon(szProto, iStatus); + } + + SendMessage(hwnd(), WM_SETICON, ICON_BIG, (LPARAM)hIcon); + SendMessage(hwnd(), WM_SETICON, ICON_SMALL, (LPARAM)hIcon); +} + +void CSrmmProxyWindow::OnActivate(HWND hwndFrom) +{ + CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)m_hContact, 0); +} + +void CSrmmProxyWindow::OnToolbar(int id, INT_PTR data) +{ + POINT pt; GetCursorPos(&pt); + HMENU hMenu = NULL; + HWND hwndClui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); + + switch (data) + { + case 1: + CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)m_hContact, 0); + break; + + case 2: + CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)m_hContact, 0); + break; + + case 3: + CallService(MS_FILE_SENDFILE, (WPARAM)m_hContact, 0); + break; + } +} + +void CSrmmProxyWindow::OnRenderThumbnail(int width, int height) +{ + HBITMAP hbmp = CreateDwmBitmap(width, height); + HDC hdc = CreateCompatibleDC(0); + SelectObject(hdc, hbmp); + + RGBQUAD rgb0, rgb1; + rgb0.rgbRed = 0; rgb0.rgbGreen = 0; rgb0.rgbBlue = 0; + rgb1.rgbRed = 19; rgb1.rgbGreen = 58; rgb1.rgbBlue = 89; + DrawGradient(hdc, 0, 0, width, height, &rgb0, &rgb1); + + HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); + SetTextColor(hdc, RGB(255, 255, 255)); + SetBkMode(hdc, TRANSPARENT); + + RECT rc; + SIZE sz; + SetRect(&rc, 5, 5, width-10, height-10); + + int avatarWidth = 0; + int avatarHeight = 0; + if (true) + { + AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)m_hContact, 0); + if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND)) + { + if (ace->bmWidth < width / 4) + { + avatarWidth = ace->bmWidth; + avatarHeight = ace->bmHeight; + } else + { + avatarWidth = width / 4; + avatarHeight = avatarWidth * ace->bmHeight / ace->bmWidth; + } + + AVATARDRAWREQUEST avdr = {0}; + avdr.cbSize = sizeof(avdr); + avdr.hContact = m_hContact; + avdr.hTargetDC = hdc; + avdr.rcDraw = rc; + avdr.rcDraw.bottom = avdr.rcDraw.top + avatarHeight; + avdr.rcDraw.right = avdr.rcDraw.left + avatarWidth; + avdr.dwFlags = AVDRQ_FALLBACKPROTO | AVDRQ_FORCEALPHA; + + avdr.alpha = 255; + CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&avdr); + + rc.left += avatarWidth + 5; + } + } + + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0); + + if (true) + { + CONTACTINFO ci = {0}; + ci.cbSize = sizeof(ci); + ci.hContact = m_hContact; + ci.szProto = proto; + ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR; + if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) + { + TCHAR name[128]; name[0] = 0; + switch (ci.type) + { + case CNFT_ASCIIZ: + mir_sntprintf(name, SIZEOF(name), _T("%s"), ci.pszVal); + mir_free((void *)ci.pszVal); + break; + case CNFT_DWORD: + mir_sntprintf(name, SIZEOF(name), _T("%u"), ci.dVal); + break; + } + + TextOut(hdc, rc.left + 20, rc.top, name, lstrlen(name)); + GetTextExtentPoint32(hdc, name, lstrlen(name), &sz); + } + } + + if (true) + { + HIMAGELIST hIml = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0); + int iIcon = CallService(MS_CLIST_GETCONTACTICON, (WPARAM)m_hContact, 0); + ImageList_Draw(hIml, iIcon, hdc, rc.left, rc.top + (sz.cy - 16) / 2, ILD_TRANSPARENT); + } + + rc.top += sz.cy + 5; + + rc.left += 10; + + struct + { + TCHAR *text; + bool out; + } msgs[10] = {0}; + + if (true) + { + int hMsgs = 0; + int n = 0; + HANDLE hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)m_hContact, 0); + while (hEvent) + { + BYTE buf[1024]; + DBEVENTINFO dbei = {0}; + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = sizeof(buf); + dbei.pBlob = buf; + if (!CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei)) + { + if (dbei.eventType == EVENTTYPE_MESSAGE) + { + msgs[n].text = DbGetEventTextT(&dbei, CP_ACP); + msgs[n].out = dbei.flags & DBEF_SENT ? true : false; + + RECT rcCopy = rc; + hMsgs += DrawText(hdc, msgs[n].text, -1, &rcCopy, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP|DT_CALCRECT); + if (n && hMsgs > rc.bottom - rc.top) + { + mir_free(msgs[n].text); + msgs[n].text = 0; + break; + } + + hMsgs += 3; + + if (++n >= SIZEOF(msgs)) break; + } + } + hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hEvent, 0); + } + } + + if (true) + { + for (int i = SIZEOF(msgs); i--; ) + { + if (!msgs[i].text) continue; + + TCHAR szDir[] = { (msgs[i].out ? (WCHAR)0xbb : (WCHAR)0xab), 0 }; + rc.left -= 10; + DrawText(hdc, szDir, -1, &rc, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP); + rc.left += 10; + + rc.top += 3 + DrawText(hdc, msgs[i].text, -1, &rc, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP); + mir_free(msgs[i].text); + } + } + + SelectObject(hdc, hfntSave); + + DeleteDC(hdc); + MakeBitmapOpaque(hbmp); + SetThumbnail(hbmp); + DeleteObject(hbmp); +} + +void CSrmmProxyWindow::OnRenderPreview() +{ + if (!m_hbmpPreview) return; + + RECT rc; + GetWindowRect(m_hwndWindow, &rc); + MapWindowPoints(NULL, m_hwndParent, (POINT *)&rc, 2); + SetPreview(m_hbmpPreview, rc.left, rc.top); +} + +void CSrmmProxyWindow::OnTimer(int) +{ + g_pTaskbarList->UnregisterTab(m_hwndParent); + + if (!m_refreshPreview) return; + if (!IsWindowVisible(m_hwndWindow) || !IsWindowVisible(m_hwndParent) || IsIconic(m_hwndParent)) return; + if (m_hbmpPreview) DeleteObject(m_hbmpPreview); + + m_refreshPreview = false; + + RECT rc; + GetWindowRect(m_hwndWindow, &rc); + + m_hbmpPreview = CreateDwmBitmap(rc.right - rc.left, rc.bottom - rc.top); + HDC hdc = CreateCompatibleDC(0); + HBITMAP hbmpSave = (HBITMAP)SelectObject(hdc, m_hbmpPreview); + PrintWindow(m_hwndWindow, hdc, PW_CLIENTONLY); + SelectObject(hdc, hbmpSave); + DeleteDC(hdc); + + MakeBitmapOpaque(m_hbmpPreview); + + InvalidateThumbnail(); +} + +void CSrmmProxyWindow::OnClose() +{ + SendMessage(m_hwndWindow, WM_CLOSE, 1, 0); +} \ No newline at end of file diff --git a/plugins/W7UI/src/srmmproxywindow.h b/plugins/W7UI/src/srmmproxywindow.h new file mode 100644 index 0000000000..f1c447d4e8 --- /dev/null +++ b/plugins/W7UI/src/srmmproxywindow.h @@ -0,0 +1,42 @@ +#ifndef srmmproxywindow_h__ +#define srmmproxywindow_h__ + +class CSrmmProxyWindow: public CDwmWindow +{ +public: + CSrmmProxyWindow(HANDLE hContact, HWND hwndWindow, HWND hwndParent); + ~CSrmmProxyWindow(); + + void OnTabActive(); + void OnTabInactive(); + +private: + HANDLE m_hContact; + HWND m_hwndWindow, m_hwndParent; + HBITMAP m_hbmpPreview; + bool m_refreshPreview; + bool m_bActive, m_bUnread, m_bTyping; + + void Refresh(); + + int __cdecl OnDbEventAdded(WPARAM wParam, LPARAM lParam); + int __cdecl OnDbSettingChanged(WPARAM wParam, LPARAM lParam); + int __cdecl OnAvatarChanged(WPARAM wParam, LPARAM lParam); + int __cdecl OnContactTyping(WPARAM wParam, LPARAM lParam); + + HANDLE SetEventHook(char *evt, int (__cdecl CSrmmProxyWindow::*fn)(WPARAM, LPARAM)); + + void UpdateIcon(); + + bool IsActive(); + +protected: + void OnActivate(HWND hwndFrom); + void OnToolbar(int id, INT_PTR data); + void OnRenderThumbnail(int width, int height); + void OnRenderPreview(); + void OnTimer(int); + void OnClose(); +}; + +#endif // srmmproxywindow_h__ diff --git a/plugins/W7UI/src/subclassmgr.cpp b/plugins/W7UI/src/subclassmgr.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/plugins/W7UI/src/subclassmgr.h b/plugins/W7UI/src/subclassmgr.h new file mode 100644 index 0000000000..1cf2433254 --- /dev/null +++ b/plugins/W7UI/src/subclassmgr.h @@ -0,0 +1,71 @@ +#ifndef subclassmgr_h__ +#define subclassmgr_h__ + +struct TSubclassData +{ + WNDPROC oldWndProc; + LPARAM lParam; +}; + +typedef LRESULT (*TSubclassProc)(MSG *msg, TSubclassData *data); + +class CSubclassMgr +{ +public: + static void Subclass(HWND hwnd, TSubclassProc newWndProc, LPARAM lParam) + { + TWindowInfo *wi = new TWindowInfo; + wi->hwnd = hwnd; + wi->newWndProc = newWndProc; + wi->lParam = lParam; + Instance().m_windows.insert(wi); + wi->oldWndProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)GlobalSubclassProc); + } + +private: + CSubclassMgr(): m_windows(5, TWindowInfo::Compare) {} + CSubclassMgr(const CSubclassMgr &); + CSubclassMgr &operator=(const CSubclassMgr &); + + static CSubclassMgr &Instance() + { + static CSubclassMgr theInstance; + return theInstance; + } + + struct TWindowInfo + { + HWND hwnd; + WNDPROC oldWndProc; + TSubclassProc newWndProc; + LPARAM lParam; + + static int Compare(const TWindowInfo *p1, const TWindowInfo *p2) + { + return (int)p1->hwnd - (int)p2->hwnd; + } + }; + + OBJLIST m_windows; + + static LRESULT CALLBACK GlobalSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) + { + TWindowInfo search = { hwnd }; + TWindowInfo *wnd = Instance().m_windows.find(&search); + if (!wnd) return DefWindowProc(hwnd, message, wParam, lParam); + + MSG msg = { hwnd, message, wParam, lParam }; + TSubclassData data = { wnd->oldWndProc, wnd->lParam }; + LRESULT result = wnd->newWndProc(&msg, &data); + + if (message == WM_DESTROY) + { + SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)wnd->oldWndProc); + Instance().m_windows.remove(wnd); + } + + return result; + } +}; + +#endif // subclassmgr_h__ diff --git a/plugins/W7UI/src/w7ui.cpp b/plugins/W7UI/src/w7ui.cpp new file mode 100644 index 0000000000..c94f7b31ca --- /dev/null +++ b/plugins/W7UI/src/w7ui.cpp @@ -0,0 +1,180 @@ +#include "headers.h" + +ITaskbarList3 *g_pTaskbarList = NULL; +UINT g_wm_TaskbarButtonCreated = 0; +HANDLE hSrmmWindows = NULL; + +int g_eventSlotTyping = 0; +int g_eventSlotMessage = 0; + +void InitJumpList(); + +static LRESULT CALLBACK W7UIHostWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +static LRESULT CALLBACK W7SrmmProxyWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +static int OnModulesLoaded(WPARAM, LPARAM); +static int OnProcessSrmmEvent(WPARAM, LPARAM lParam); +static int OnStatusModeChanged(WPARAM wParam, LPARAM); + +int LoadW7UI() +{ + CoInitialize(NULL); + + CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void **)&g_pTaskbarList); + g_pTaskbarList->HrInit(); + + g_wm_TaskbarButtonCreated = RegisterWindowMessage(_T("TaskbarButtonCreated")); + + CJumpListBuilder::Load(); + LoadJumpList(); + + HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + HookEvent(ME_CLIST_STATUSMODECHANGE, OnStatusModeChanged); + + hSrmmWindows = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); + new CClistProxyWindow(); + + return 0; +} + +int UnloadW7UI() +{ + CJumpListBuilder::Unload(); + return 0; +} + +static int OnContactIsTyping(WPARAM wParam, LPARAM lParam) +{ + if (!wParam) return 0; + + if (lParam) g_clistProxyWnd->AddOverlayEvent(g_eventSlotTyping); + else g_clistProxyWnd->RemoveOverlayEvent(g_eventSlotTyping); + + return 0; +} + +static int OnModulesLoaded(WPARAM, LPARAM) +{ + InitJumpList(); + g_eventSlotMessage = g_clistProxyWnd->AllocateOverlayEvent(LoadSkinnedIconHandle(SKINICON_EVENT_MESSAGE)); + g_eventSlotTyping = g_clistProxyWnd->AllocateOverlayEvent(LoadSkinnedIconHandle(SKINICON_OTHER_TYPING)); + OnStatusModeChanged(CallService(MS_CLIST_GETSTATUSMODE, 0, 0), 0); + HookEvent(ME_MSG_WINDOWEVENT, OnProcessSrmmEvent); + HookEvent(ME_PROTO_CONTACTISTYPING, OnContactIsTyping); + return 0; +} + +static LRESULT SrmmSubclassProc(MSG *msg, TSubclassData *data) +{ + HWND hwndProxy = WindowList_Find(hSrmmWindows, (HANDLE)data->lParam); + CSrmmProxyWindow *wnd = CDwmWindow::GetWindow(hwndProxy); + + if (wnd) + { + switch (msg->message) + { + case WM_SETFOCUS: + wnd->OnTabActive(); + break; + case WM_ACTIVATE: + switch (msg->wParam) + { + case WA_ACTIVE: + case WA_CLICKACTIVE: + wnd->OnTabActive(); + break; + case WA_INACTIVE: + wnd->OnTabInactive(); + } + break; + case WM_NCACTIVATE: + if (msg->wParam) + wnd->OnTabActive(); + else + wnd->OnTabInactive(); + break; + } + } + + return CallWindowProc(data->oldWndProc, msg->hwnd, msg->message, msg->wParam, msg->lParam); +} + +static HWND FindParent(HWND hwnd) +{ + while (1) + { + HWND hwndParent = GetParent(hwnd); + if (hwndParent == NULL) + return hwnd; + hwnd = hwndParent; + } +} + +int OnProcessSrmmEvent(WPARAM, LPARAM lParam) +{ + MessageWindowEventData *evt = (MessageWindowEventData *)lParam; + + switch (evt->uType) + { + case MSG_WINDOW_EVT_OPENING: + { + CSubclassMgr::Subclass(evt->hwndWindow, SrmmSubclassProc, (LPARAM)evt->hContact); + break; + } + + case MSG_WINDOW_EVT_OPEN: + { + HWND hwndParent = FindParent(evt->hwndWindow); + if (hwndParent != evt->hwndWindow) + { + SetWindowLongPtr(hwndParent, GWL_EXSTYLE, GetWindowLongPtr(hwndParent, GWL_EXSTYLE) & ~WS_EX_APPWINDOW); + CSrmmProxyWindow *wnd = new CSrmmProxyWindow(evt->hContact, evt->hwndWindow, hwndParent); + HWND hwndProxy = wnd->hwnd(); + g_pTaskbarList->UnregisterTab(hwndParent); + g_pTaskbarList->RegisterTab(hwndProxy, hwndParent); + g_pTaskbarList->SetTabOrder(hwndProxy, 0); + g_pTaskbarList->SetTabActive(hwndProxy, hwndParent, TBATF_USEMDITHUMBNAIL); + WindowList_Add(hSrmmWindows, hwndProxy, evt->hContact); + } + break; + } + + case MSG_WINDOW_EVT_CLOSING: + { + HWND hwndProxy = WindowList_Find(hSrmmWindows, evt->hContact); + if (hwndProxy) + { + WindowList_Remove(hSrmmWindows, hwndProxy); + g_pTaskbarList->UnregisterTab(hwndProxy); + DestroyWindow(hwndProxy); + } + break; + } + } + + return 0; +} + +/////////////////////////////////////////////////////////////////////////////// +// status processing + +int OnStatusModeChanged(WPARAM wParam, LPARAM) +{ + static int icons[] = + { + SKINICON_STATUS_OFFLINE, + SKINICON_STATUS_ONLINE, + SKINICON_STATUS_AWAY, + SKINICON_STATUS_DND, + SKINICON_STATUS_NA, + SKINICON_STATUS_OCCUPIED, + SKINICON_STATUS_FREE4CHAT, + SKINICON_STATUS_INVISIBLE, + SKINICON_STATUS_ONTHEPHONE, + SKINICON_STATUS_OUTTOLUNCH, + }; + + g_clistProxyWnd->SetOverlayIcon(LoadSkinnedIcon(icons[wParam - ID_STATUS_OFFLINE])); + + return 0; +} diff --git a/plugins/W7UI/src/win7api.cpp b/plugins/W7UI/src/win7api.cpp new file mode 100644 index 0000000000..dcfb6058ec --- /dev/null +++ b/plugins/W7UI/src/win7api.cpp @@ -0,0 +1,25 @@ +#include + +//extern "C" const CLSID CLSID_TaskbarList = {0x56fdf344,0xfd6d,0x11d0,{0x95,0x8a,0x00,0x60,0x97,0xc9,0xa0,0x90}}; // 56fdf344-fd6d-11d0-958a-006097c9a090; +//extern "C" const IID IID_ITaskbarList = {0x56FDF342,0xFD6D,0x11d0,{0x95,0x8A,0x00,0x60,0x97,0xC9,0xA0,0x90}}; // 56FDF342-FD6D-11d0-958A-006097C9A090; +//extern "C" const IID IID_ITaskbarList2 = {0x602D4995,0xB13A,0x429b,{0xA6,0x6E,0x19,0x35,0xE4,0x4F,0x43,0x17}}; // 602D4995-B13A-429b-A66E-1935E44F4317; +//extern "C" const IID IID_ICustomDestinationList = {0x6332debf,0x87b5,0x4670,{0x90,0xc0,0x5e,0x57,0xb4,0x08,0xa4,0x9e}}; // 6332debf-87b5-4670-90c0-5e57b408a49e +//extern "C" const IID IID_IObjectArray = {0x92CA9DCD,0x5622,0x4bba,{0xA8,0x05,0x5E,0x9F,0x54,0x1B,0xD8,0xC9}}; // 92CA9DCD-5622-4bba-A805-5E9F541BD8C9 +//extern "C" const IID IID_IObjectCollection = {0x5632b1a4,0xe38a,0x400a,{0x92,0x8a,0xd4,0xcd,0x63,0x23,0x02,0x95}}; // 5632b1a4-e38a-400a-928a-d4cd63230295 +//extern "C" const IID IID_ITaskbarList3 = {0xea1afb91,0x9e28,0x4b86,{0x90,0xe9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf}}; // ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf +extern "C" const CLSID CLSID_CustomDestinationList = {0x77f10cf0,0x3db5,0x4966,{0xb5,0x20,0xb7,0xc5,0x4f,0xd3,0x5e,0xd6}}; +//extern "C" const CLSID CLSID_EnumerableObjectCollection = {0x2d3468c1,0x36a7,0x43b6,{0xac,0x24,0xd3,0xf0,0x2f,0xd9,0x60,0x7a}}; + +HRESULT (WINAPI *dwmInvalidateIconicBitmaps)(HWND) = + (HRESULT (WINAPI *)(HWND))GetProcAddress(LoadLibraryA("dwmapi.dll"), "DwmInvalidateIconicBitmaps"); +HRESULT (WINAPI *dwmSetIconicThumbnail)(HWND, HBITMAP, DWORD) = + (HRESULT (WINAPI *)(HWND, HBITMAP, DWORD))GetProcAddress(LoadLibraryA("dwmapi.dll"), "DwmSetIconicThumbnail"); +HRESULT (WINAPI *dwmSetIconicLivePreviewBitmap)(HWND, HBITMAP, LPPOINT, DWORD) = + (HRESULT (WINAPI *)(HWND, HBITMAP, LPPOINT, DWORD))GetProcAddress(LoadLibraryA("dwmapi.dll"), "DwmSetIconicLivePreviewBitmap"); + +HANDLE (STDAPICALLTYPE *openThemeData)(HWND, LPCWSTR) = + (HANDLE (STDAPICALLTYPE *)(HWND, LPCWSTR))GetProcAddress(LoadLibraryA("uxtheme.dll"), "OpenThemeData"); +HRESULT (STDAPICALLTYPE *drawThemeTextEx)(HANDLE, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const struct _DTTOPTS *) = + (HRESULT (STDAPICALLTYPE *)(HANDLE, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const struct _DTTOPTS *))GetProcAddress(LoadLibraryA("uxtheme.dll"), "DrawThemeTextEx"); +HRESULT (STDAPICALLTYPE *closeThemeData)(HANDLE) = + (HRESULT (STDAPICALLTYPE *)(HANDLE))GetProcAddress(LoadLibraryA("uxtheme.dll"), "CloseThemeData"); diff --git a/plugins/W7UI/src/win7api.h b/plugins/W7UI/src/win7api.h new file mode 100644 index 0000000000..f9fa806335 --- /dev/null +++ b/plugins/W7UI/src/win7api.h @@ -0,0 +1,38 @@ +#ifndef win7api_h__ +#define win7api_h__ + +#define WM_DWMSENDICONICTHUMBNAIL 0x0323 +#define WM_DWMSENDICONICLIVEPREVIEWBITMAP 0x0326 + +#define DWMWA_HAS_ICONIC_BITMAP 10 + +#define DWM_SIT_DISPLAYFRAME 0x00000001 + +enum TBATFLAG +{ TBATF_USEMDITHUMBNAIL = 0x1, + TBATF_USEMDILIVEPREVIEW = 0x2 +}; + +#define THBN_CLICKED 0x1800 + +extern HRESULT (WINAPI *dwmInvalidateIconicBitmaps)(HWND); +extern HRESULT (WINAPI *dwmSetIconicThumbnail)(HWND, HBITMAP, DWORD); +extern HRESULT (WINAPI *dwmSetIconicLivePreviewBitmap)(HWND, HBITMAP, LPPOINT, DWORD); + +extern HANDLE (STDAPICALLTYPE *openThemeData)(HWND, LPCWSTR); +extern HRESULT (STDAPICALLTYPE *drawThemeTextEx)(HANDLE, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const struct _DTTOPTS *); +extern HRESULT (STDAPICALLTYPE *closeThemeData)(HANDLE); + +extern "C" const IID IID_ICustomDestinationList; +extern "C" const IID IID_IObjectArray; +extern "C" const IID IID_IObjectCollection; +extern "C" const IID IID_ITaskbarList3; +extern "C" const CLSID CLSID_CustomDestinationList; +extern "C" const CLSID CLSID_EnumerableObjectCollection; + +#include "win7api_IObjectArray.h" +#include "win7api_IObjectCollection.h" +#include "win7api_ICustomDestinationList.h" +//#include "win7api_ITaskbarList3.h" + +#endif // win7api_h__ diff --git a/plugins/W7UI/src/win7api_ICustomDestinationList.h b/plugins/W7UI/src/win7api_ICustomDestinationList.h new file mode 100644 index 0000000000..6d3f770d29 --- /dev/null +++ b/plugins/W7UI/src/win7api_ICustomDestinationList.h @@ -0,0 +1,34 @@ +#ifndef __ICustomDestinationList_INTERFACE_DEFINED__ +#define __ICustomDestinationList_INTERFACE_DEFINED__ + +typedef /* [v1_enum] */ enum tagKNOWNDESTCATEGORY { + KDC_FREQUENT = 1, + KDC_RECENT = (KDC_FREQUENT + 1) +} KNOWNDESTCATEGORY; + +MIDL_INTERFACE("6332debf-87b5-4670-90c0-5e57b408a49e") +ICustomDestinationList : public IUnknown { + public: + virtual HRESULT STDMETHODCALLTYPE SetAppID( + /* [string][in] */__RPC__in_string LPCWSTR pszAppID) = 0; + virtual HRESULT STDMETHODCALLTYPE BeginList( + /* [out] */ __RPC__out UINT *pcMaxSlots, + /* [in] */ __RPC__in REFIID riid, + /* [iid_is][out] */ __RPC__deref_out_opt void **ppv) = 0; + virtual HRESULT STDMETHODCALLTYPE AppendCategory( + /* [string][in] */ __RPC__in_string LPCWSTR pszCategory, + /* [in] */ __RPC__in_opt IObjectArray *poa) = 0; + virtual HRESULT STDMETHODCALLTYPE AppendKnownCategory( + /* [in] */ KNOWNDESTCATEGORY category) = 0; + virtual HRESULT STDMETHODCALLTYPE AddUserTasks( + /* [in] */ __RPC__in_opt IObjectArray *poa) = 0; + virtual HRESULT STDMETHODCALLTYPE CommitList(void) = 0; + virtual HRESULT STDMETHODCALLTYPE GetRemovedDestinations( + /* [in] */ __RPC__in REFIID riid, + /* [iid_is][out] */ __RPC__deref_out_opt void **ppv) = 0; + virtual HRESULT STDMETHODCALLTYPE DeleteList( + /* [string][in] */ __RPC__in_string LPCWSTR pszAppID) = 0; + virtual HRESULT STDMETHODCALLTYPE AbortList(void) = 0; +}; + +#endif // __ICustomDestinationList_INTERFACE_DEFINED__ diff --git a/plugins/W7UI/src/win7api_IObjectArray.h b/plugins/W7UI/src/win7api_IObjectArray.h new file mode 100644 index 0000000000..2102276989 --- /dev/null +++ b/plugins/W7UI/src/win7api_IObjectArray.h @@ -0,0 +1,15 @@ +#ifndef __IObjectArray_INTERFACE_DEFINED__ +#define __IObjectArray_INTERFACE_DEFINED__ + +MIDL_INTERFACE("92CA9DCD-5622-4bba-A805-5E9F541BD8C9") +IObjectArray : public IUnknown { + public: + virtual HRESULT STDMETHODCALLTYPE GetCount( + /* [out] */ __RPC__out UINT *pcObjects) = 0; + virtual HRESULT STDMETHODCALLTYPE GetAt( + /* [in] */ UINT uiIndex, + /* [in] */ __RPC__in REFIID riid, + /* [iid_is][out] */ __RPC__deref_out_opt void **ppv) = 0; +}; + +#endif // __IObjectArray_INTERFACE_DEFINED__ diff --git a/plugins/W7UI/src/win7api_IObjectCollection.h b/plugins/W7UI/src/win7api_IObjectCollection.h new file mode 100644 index 0000000000..71b37d0e99 --- /dev/null +++ b/plugins/W7UI/src/win7api_IObjectCollection.h @@ -0,0 +1,16 @@ +#ifndef __IObjectCollection_INTERFACE_DEFINED__ +#define __IObjectCollection_INTERFACE_DEFINED__ + +MIDL_INTERFACE("5632b1a4-e38a-400a-928a-d4cd63230295") +IObjectCollection : public IObjectArray { + public: + virtual HRESULT STDMETHODCALLTYPE AddObject( + /* [in] */ __RPC__in_opt IUnknown *punk) = 0; + virtual HRESULT STDMETHODCALLTYPE AddFromArray( + /* [in] */ __RPC__in_opt IObjectArray *poaSource) = 0; + virtual HRESULT STDMETHODCALLTYPE RemoveObjectAt( + /* [in] */ UINT uiIndex) = 0; + virtual HRESULT STDMETHODCALLTYPE Clear(void) = 0; +}; + +#endif // __IObjectCollection_INTERFACE_DEFINED__ diff --git a/plugins/W7UI/src/win7api_ITaskbarList3.h b/plugins/W7UI/src/win7api_ITaskbarList3.h new file mode 100644 index 0000000000..8c39fb5c41 --- /dev/null +++ b/plugins/W7UI/src/win7api_ITaskbarList3.h @@ -0,0 +1,65 @@ +#ifndef __ITaskbarList3_FWD_DEFINED__ +#define __ITaskbarList3_FWD_DEFINED__ +typedef interface ITaskbarList3 ITaskbarList3; +#endif /* __ITaskbarList3_FWD_DEFINED__ */ + +/* interface ITaskbarList3 */ +/* [object][uuid] */ + +MIDL_INTERFACE("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf") +ITaskbarList3 : public ITaskbarList2 +{ +public: + virtual HRESULT STDMETHODCALLTYPE SetProgressValue( + /* [in] */ __RPC__in HWND hwnd, + /* [in] */ ULONGLONG ullCompleted, + /* [in] */ ULONGLONG ullTotal) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetProgressState( + /* [in] */ __RPC__in HWND hwnd, + /* [in] */ TBPFLAG tbpFlags) = 0; + + virtual HRESULT STDMETHODCALLTYPE RegisterTab( + /* [in] */ __RPC__in HWND hwndTab, + /* [in] */ __RPC__in HWND hwndMDI) = 0; + + virtual HRESULT STDMETHODCALLTYPE UnregisterTab( + /* [in] */ __RPC__in HWND hwndTab) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetTabOrder( + /* [in] */ __RPC__in HWND hwndTab, + /* [in] */ __RPC__in HWND hwndInsertBefore) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetTabActive( + /* [in] */ __RPC__in HWND hwndTab, + /* [in] */ __RPC__in HWND hwndMDI, + /* [in] */ TBATFLAG tbatFlags) = 0; + + virtual HRESULT STDMETHODCALLTYPE ThumbBarAddButtons( + /* [in] */ __RPC__in HWND hwnd, + /* [in] */ UINT cButtons, + /* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0; + + virtual HRESULT STDMETHODCALLTYPE ThumbBarUpdateButtons( + /* [in] */ __RPC__in HWND hwnd, + /* [in] */ UINT cButtons, + /* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0; + + virtual HRESULT STDMETHODCALLTYPE ThumbBarSetImageList( + /* [in] */ __RPC__in HWND hwnd, + /* [in] */ __RPC__in_opt HIMAGELIST himl) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetOverlayIcon( + /* [in] */ __RPC__in HWND hwnd, + /* [in] */ __RPC__in HICON hIcon, + /* [string][in] */ __RPC__in_string LPCWSTR pszDescription) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetThumbnailTooltip( + /* [in] */ __RPC__in HWND hwnd, + /* [string][in] */ __RPC__in_string LPCWSTR pszTip) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetThumbnailClip( + /* [in] */ __RPC__in HWND hwnd, + /* [in] */ __RPC__in RECT *prcClip) = 0; + +}; diff --git a/plugins/W7UI/srmmproxywindow.cpp b/plugins/W7UI/srmmproxywindow.cpp deleted file mode 100644 index a70ca1b672..0000000000 --- a/plugins/W7UI/srmmproxywindow.cpp +++ /dev/null @@ -1,374 +0,0 @@ -#include "headers.h" - -extern int g_eventSlotMessage; -extern ITaskbarList3 *g_pTaskbarList; - -/////////////////////////////////////////////////////////////////////////////// -// srmm processing - -CSrmmProxyWindow::CSrmmProxyWindow(HANDLE hContact, HWND hwndWindow, HWND hwndParent) -{ - m_hContact = hContact; - m_hwndWindow = hwndWindow; - m_hwndParent = hwndParent; - - m_hbmpPreview = NULL; - m_refreshPreview = true; - - m_bActive = false; - m_bUnread = false; - m_bTyping = false; - - UpdateIcon(); - SetWindowText(hwnd(), (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)m_hContact, GCDNF_TCHAR)); - SetTimer(1, 1000); - - SetEventHook(ME_DB_EVENT_ADDED, &CSrmmProxyWindow::OnDbEventAdded); - SetEventHook(ME_DB_CONTACT_SETTINGCHANGED, &CSrmmProxyWindow::OnDbSettingChanged); - SetEventHook(ME_AV_AVATARCHANGED, &CSrmmProxyWindow::OnAvatarChanged); - SetEventHook(ME_PROTO_CONTACTISTYPING, &CSrmmProxyWindow::OnContactTyping); - - AddButton(LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS), TranslateT("User Details"), 1, THBF_DISMISSONCLICK); - AddButton(LoadSkinnedIcon(SKINICON_OTHER_HISTORY), TranslateT("History"), 2, THBF_DISMISSONCLICK); - AddButton(LoadSkinnedIcon(SKINICON_EVENT_FILE), TranslateT("File"), 3, THBF_DISMISSONCLICK); - UpdateButtons(g_pTaskbarList); -} - -CSrmmProxyWindow::~CSrmmProxyWindow() -{ - DeleteObject(m_hbmpPreview); - KillObjectEventHooks(this); -} - - -void CSrmmProxyWindow::Refresh() -{ - InvalidateThumbnail(); - m_refreshPreview = true; -} - -int __cdecl CSrmmProxyWindow::OnDbEventAdded(WPARAM wParam, LPARAM lParam) -{ - if ((HANDLE)wParam == m_hContact) - { - Refresh(); - - if (!m_bUnread && !IsActive()) - { - DBEVENTINFO dbei = {0}; - dbei.cbSize = sizeof(dbei); - if (!CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM)&dbei)) - if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & (DBEF_READ|DBEF_SENT))) - { - g_clistProxyWnd->Flash(); - g_clistProxyWnd->AddOverlayEvent(g_eventSlotMessage); - m_bUnread = true; - UpdateIcon(); - } - } - } - return 0; -} - -int __cdecl CSrmmProxyWindow::OnDbSettingChanged(WPARAM wParam, LPARAM lParam) -{ - if ((HANDLE)wParam == m_hContact) - { - UpdateIcon(); - Refresh(); - } - return 0; -} - -int __cdecl CSrmmProxyWindow::OnAvatarChanged(WPARAM wParam, LPARAM lParam) -{ - if ((HANDLE)wParam == m_hContact) - Refresh(); - return 0; -} - -int __cdecl CSrmmProxyWindow::OnContactTyping(WPARAM wParam, LPARAM lParam) -{ - if ((HANDLE)wParam == m_hContact) - { - m_bTyping = lParam ? true : false; - UpdateIcon(); - } - return 0; -} - -HANDLE CSrmmProxyWindow::SetEventHook(char *evt, int (__cdecl CSrmmProxyWindow::*fn)(WPARAM, LPARAM)) -{ - return HookEventObj(evt, *(MIRANDAHOOKOBJ *)&fn, this); -} - -void CSrmmProxyWindow::OnTabActive() -{ - m_bActive = true; - if (m_bUnread) - { - g_clistProxyWnd->RemoveOverlayEvent(g_eventSlotMessage); - m_bUnread = false; - UpdateIcon(); - } -} - -void CSrmmProxyWindow::OnTabInactive() -{ - m_bActive = false; -} - -bool CSrmmProxyWindow::IsActive() -{ - for (HWND hwnd = GetFocus(); hwnd; hwnd = GetParent(hwnd)) - if (hwnd == m_hwndWindow) - return m_bActive = true; - return m_bActive = false; -} - -void CSrmmProxyWindow::UpdateIcon() -{ - HICON hIcon; - if (m_bTyping) - { - hIcon = LoadSkinnedIcon(SKINICON_OTHER_TYPING); - } else - if (m_bUnread) - { - hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); - } else - { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0); - if (!szProto) return; - int iStatus = DBGetContactSettingWord(m_hContact, szProto, "Status", ID_STATUS_OFFLINE); - hIcon = (HICON)LoadSkinnedProtoIcon(szProto, iStatus); - } - - SendMessage(hwnd(), WM_SETICON, ICON_BIG, (LPARAM)hIcon); - SendMessage(hwnd(), WM_SETICON, ICON_SMALL, (LPARAM)hIcon); -} - -void CSrmmProxyWindow::OnActivate(HWND hwndFrom) -{ - CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)m_hContact, 0); -} - -void CSrmmProxyWindow::OnToolbar(int id, INT_PTR data) -{ - POINT pt; GetCursorPos(&pt); - HMENU hMenu = NULL; - HWND hwndClui = (HWND)CallService(MS_CLUI_GETHWND, 0, 0); - - switch (data) - { - case 1: - CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)m_hContact, 0); - break; - - case 2: - CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)m_hContact, 0); - break; - - case 3: - CallService(MS_FILE_SENDFILE, (WPARAM)m_hContact, 0); - break; - } -} - -void CSrmmProxyWindow::OnRenderThumbnail(int width, int height) -{ - HBITMAP hbmp = CreateDwmBitmap(width, height); - HDC hdc = CreateCompatibleDC(0); - SelectObject(hdc, hbmp); - - RGBQUAD rgb0, rgb1; - rgb0.rgbRed = 0; rgb0.rgbGreen = 0; rgb0.rgbBlue = 0; - rgb1.rgbRed = 19; rgb1.rgbGreen = 58; rgb1.rgbBlue = 89; - DrawGradient(hdc, 0, 0, width, height, &rgb0, &rgb1); - - HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); - SetTextColor(hdc, RGB(255, 255, 255)); - SetBkMode(hdc, TRANSPARENT); - - RECT rc; - SIZE sz; - SetRect(&rc, 5, 5, width-10, height-10); - - int avatarWidth = 0; - int avatarHeight = 0; - if (true) - { - AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)m_hContact, 0); - if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND)) - { - if (ace->bmWidth < width / 4) - { - avatarWidth = ace->bmWidth; - avatarHeight = ace->bmHeight; - } else - { - avatarWidth = width / 4; - avatarHeight = avatarWidth * ace->bmHeight / ace->bmWidth; - } - - AVATARDRAWREQUEST avdr = {0}; - avdr.cbSize = sizeof(avdr); - avdr.hContact = m_hContact; - avdr.hTargetDC = hdc; - avdr.rcDraw = rc; - avdr.rcDraw.bottom = avdr.rcDraw.top + avatarHeight; - avdr.rcDraw.right = avdr.rcDraw.left + avatarWidth; - avdr.dwFlags = AVDRQ_FALLBACKPROTO | AVDRQ_FORCEALPHA; - - avdr.alpha = 255; - CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&avdr); - - rc.left += avatarWidth + 5; - } - } - - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0); - - if (true) - { - CONTACTINFO ci = {0}; - ci.cbSize = sizeof(ci); - ci.hContact = m_hContact; - ci.szProto = proto; - ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) - { - TCHAR name[128]; name[0] = 0; - switch (ci.type) - { - case CNFT_ASCIIZ: - mir_sntprintf(name, SIZEOF(name), _T("%s"), ci.pszVal); - mir_free((void *)ci.pszVal); - break; - case CNFT_DWORD: - mir_sntprintf(name, SIZEOF(name), _T("%u"), ci.dVal); - break; - } - - TextOut(hdc, rc.left + 20, rc.top, name, lstrlen(name)); - GetTextExtentPoint32(hdc, name, lstrlen(name), &sz); - } - } - - if (true) - { - HIMAGELIST hIml = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0); - int iIcon = CallService(MS_CLIST_GETCONTACTICON, (WPARAM)m_hContact, 0); - ImageList_Draw(hIml, iIcon, hdc, rc.left, rc.top + (sz.cy - 16) / 2, ILD_TRANSPARENT); - } - - rc.top += sz.cy + 5; - - rc.left += 10; - - struct - { - TCHAR *text; - bool out; - } msgs[10] = {0}; - - if (true) - { - int hMsgs = 0; - int n = 0; - HANDLE hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)m_hContact, 0); - while (hEvent) - { - BYTE buf[1024]; - DBEVENTINFO dbei = {0}; - dbei.cbSize = sizeof(dbei); - dbei.cbBlob = sizeof(buf); - dbei.pBlob = buf; - if (!CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei)) - { - if (dbei.eventType == EVENTTYPE_MESSAGE) - { - msgs[n].text = DbGetEventTextT(&dbei, CP_ACP); - msgs[n].out = dbei.flags & DBEF_SENT ? true : false; - - RECT rcCopy = rc; - hMsgs += DrawText(hdc, msgs[n].text, -1, &rcCopy, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP|DT_CALCRECT); - if (n && hMsgs > rc.bottom - rc.top) - { - mir_free(msgs[n].text); - msgs[n].text = 0; - break; - } - - hMsgs += 3; - - if (++n >= SIZEOF(msgs)) break; - } - } - hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hEvent, 0); - } - } - - if (true) - { - for (int i = SIZEOF(msgs); i--; ) - { - if (!msgs[i].text) continue; - - TCHAR szDir[] = { (msgs[i].out ? (WCHAR)0xbb : (WCHAR)0xab), 0 }; - rc.left -= 10; - DrawText(hdc, szDir, -1, &rc, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP); - rc.left += 10; - - rc.top += 3 + DrawText(hdc, msgs[i].text, -1, &rc, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP); - mir_free(msgs[i].text); - } - } - - SelectObject(hdc, hfntSave); - - DeleteDC(hdc); - MakeBitmapOpaque(hbmp); - SetThumbnail(hbmp); - DeleteObject(hbmp); -} - -void CSrmmProxyWindow::OnRenderPreview() -{ - if (!m_hbmpPreview) return; - - RECT rc; - GetWindowRect(m_hwndWindow, &rc); - MapWindowPoints(NULL, m_hwndParent, (POINT *)&rc, 2); - SetPreview(m_hbmpPreview, rc.left, rc.top); -} - -void CSrmmProxyWindow::OnTimer(int) -{ - g_pTaskbarList->UnregisterTab(m_hwndParent); - - if (!m_refreshPreview) return; - if (!IsWindowVisible(m_hwndWindow) || !IsWindowVisible(m_hwndParent) || IsIconic(m_hwndParent)) return; - if (m_hbmpPreview) DeleteObject(m_hbmpPreview); - - m_refreshPreview = false; - - RECT rc; - GetWindowRect(m_hwndWindow, &rc); - - m_hbmpPreview = CreateDwmBitmap(rc.right - rc.left, rc.bottom - rc.top); - HDC hdc = CreateCompatibleDC(0); - HBITMAP hbmpSave = (HBITMAP)SelectObject(hdc, m_hbmpPreview); - PrintWindow(m_hwndWindow, hdc, PW_CLIENTONLY); - SelectObject(hdc, hbmpSave); - DeleteDC(hdc); - - MakeBitmapOpaque(m_hbmpPreview); - - InvalidateThumbnail(); -} - -void CSrmmProxyWindow::OnClose() -{ - SendMessage(m_hwndWindow, WM_CLOSE, 1, 0); -} \ No newline at end of file diff --git a/plugins/W7UI/srmmproxywindow.h b/plugins/W7UI/srmmproxywindow.h deleted file mode 100644 index f1c447d4e8..0000000000 --- a/plugins/W7UI/srmmproxywindow.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef srmmproxywindow_h__ -#define srmmproxywindow_h__ - -class CSrmmProxyWindow: public CDwmWindow -{ -public: - CSrmmProxyWindow(HANDLE hContact, HWND hwndWindow, HWND hwndParent); - ~CSrmmProxyWindow(); - - void OnTabActive(); - void OnTabInactive(); - -private: - HANDLE m_hContact; - HWND m_hwndWindow, m_hwndParent; - HBITMAP m_hbmpPreview; - bool m_refreshPreview; - bool m_bActive, m_bUnread, m_bTyping; - - void Refresh(); - - int __cdecl OnDbEventAdded(WPARAM wParam, LPARAM lParam); - int __cdecl OnDbSettingChanged(WPARAM wParam, LPARAM lParam); - int __cdecl OnAvatarChanged(WPARAM wParam, LPARAM lParam); - int __cdecl OnContactTyping(WPARAM wParam, LPARAM lParam); - - HANDLE SetEventHook(char *evt, int (__cdecl CSrmmProxyWindow::*fn)(WPARAM, LPARAM)); - - void UpdateIcon(); - - bool IsActive(); - -protected: - void OnActivate(HWND hwndFrom); - void OnToolbar(int id, INT_PTR data); - void OnRenderThumbnail(int width, int height); - void OnRenderPreview(); - void OnTimer(int); - void OnClose(); -}; - -#endif // srmmproxywindow_h__ diff --git a/plugins/W7UI/subclassmgr.cpp b/plugins/W7UI/subclassmgr.cpp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/plugins/W7UI/subclassmgr.h b/plugins/W7UI/subclassmgr.h deleted file mode 100644 index 1cf2433254..0000000000 --- a/plugins/W7UI/subclassmgr.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef subclassmgr_h__ -#define subclassmgr_h__ - -struct TSubclassData -{ - WNDPROC oldWndProc; - LPARAM lParam; -}; - -typedef LRESULT (*TSubclassProc)(MSG *msg, TSubclassData *data); - -class CSubclassMgr -{ -public: - static void Subclass(HWND hwnd, TSubclassProc newWndProc, LPARAM lParam) - { - TWindowInfo *wi = new TWindowInfo; - wi->hwnd = hwnd; - wi->newWndProc = newWndProc; - wi->lParam = lParam; - Instance().m_windows.insert(wi); - wi->oldWndProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)GlobalSubclassProc); - } - -private: - CSubclassMgr(): m_windows(5, TWindowInfo::Compare) {} - CSubclassMgr(const CSubclassMgr &); - CSubclassMgr &operator=(const CSubclassMgr &); - - static CSubclassMgr &Instance() - { - static CSubclassMgr theInstance; - return theInstance; - } - - struct TWindowInfo - { - HWND hwnd; - WNDPROC oldWndProc; - TSubclassProc newWndProc; - LPARAM lParam; - - static int Compare(const TWindowInfo *p1, const TWindowInfo *p2) - { - return (int)p1->hwnd - (int)p2->hwnd; - } - }; - - OBJLIST m_windows; - - static LRESULT CALLBACK GlobalSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) - { - TWindowInfo search = { hwnd }; - TWindowInfo *wnd = Instance().m_windows.find(&search); - if (!wnd) return DefWindowProc(hwnd, message, wParam, lParam); - - MSG msg = { hwnd, message, wParam, lParam }; - TSubclassData data = { wnd->oldWndProc, wnd->lParam }; - LRESULT result = wnd->newWndProc(&msg, &data); - - if (message == WM_DESTROY) - { - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)wnd->oldWndProc); - Instance().m_windows.remove(wnd); - } - - return result; - } -}; - -#endif // subclassmgr_h__ diff --git a/plugins/W7UI/w7ui-translation.txt b/plugins/W7UI/w7ui-translation.txt deleted file mode 100644 index 30bce1459e..0000000000 --- a/plugins/W7UI/w7ui-translation.txt +++ /dev/null @@ -1,16 +0,0 @@ -; Common strings that belong to many files -;[Do not disturb] -;[Invisible] -;[Offline] -;[Online] - -; ../../plugins/W7UI/clistproxywindow.cpp -;[Menu] - -; ../../plugins/W7UI/jumplistbuilder.cpp -;[Nickname] - -; ../../plugins/W7UI/srmmproxywindow.cpp -;[File] -;[History] -;[User Details] diff --git a/plugins/W7UI/w7ui.cpp b/plugins/W7UI/w7ui.cpp deleted file mode 100644 index c94f7b31ca..0000000000 --- a/plugins/W7UI/w7ui.cpp +++ /dev/null @@ -1,180 +0,0 @@ -#include "headers.h" - -ITaskbarList3 *g_pTaskbarList = NULL; -UINT g_wm_TaskbarButtonCreated = 0; -HANDLE hSrmmWindows = NULL; - -int g_eventSlotTyping = 0; -int g_eventSlotMessage = 0; - -void InitJumpList(); - -static LRESULT CALLBACK W7UIHostWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -static LRESULT CALLBACK W7SrmmProxyWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -static int OnModulesLoaded(WPARAM, LPARAM); -static int OnProcessSrmmEvent(WPARAM, LPARAM lParam); -static int OnStatusModeChanged(WPARAM wParam, LPARAM); - -int LoadW7UI() -{ - CoInitialize(NULL); - - CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void **)&g_pTaskbarList); - g_pTaskbarList->HrInit(); - - g_wm_TaskbarButtonCreated = RegisterWindowMessage(_T("TaskbarButtonCreated")); - - CJumpListBuilder::Load(); - LoadJumpList(); - - HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - HookEvent(ME_CLIST_STATUSMODECHANGE, OnStatusModeChanged); - - hSrmmWindows = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); - new CClistProxyWindow(); - - return 0; -} - -int UnloadW7UI() -{ - CJumpListBuilder::Unload(); - return 0; -} - -static int OnContactIsTyping(WPARAM wParam, LPARAM lParam) -{ - if (!wParam) return 0; - - if (lParam) g_clistProxyWnd->AddOverlayEvent(g_eventSlotTyping); - else g_clistProxyWnd->RemoveOverlayEvent(g_eventSlotTyping); - - return 0; -} - -static int OnModulesLoaded(WPARAM, LPARAM) -{ - InitJumpList(); - g_eventSlotMessage = g_clistProxyWnd->AllocateOverlayEvent(LoadSkinnedIconHandle(SKINICON_EVENT_MESSAGE)); - g_eventSlotTyping = g_clistProxyWnd->AllocateOverlayEvent(LoadSkinnedIconHandle(SKINICON_OTHER_TYPING)); - OnStatusModeChanged(CallService(MS_CLIST_GETSTATUSMODE, 0, 0), 0); - HookEvent(ME_MSG_WINDOWEVENT, OnProcessSrmmEvent); - HookEvent(ME_PROTO_CONTACTISTYPING, OnContactIsTyping); - return 0; -} - -static LRESULT SrmmSubclassProc(MSG *msg, TSubclassData *data) -{ - HWND hwndProxy = WindowList_Find(hSrmmWindows, (HANDLE)data->lParam); - CSrmmProxyWindow *wnd = CDwmWindow::GetWindow(hwndProxy); - - if (wnd) - { - switch (msg->message) - { - case WM_SETFOCUS: - wnd->OnTabActive(); - break; - case WM_ACTIVATE: - switch (msg->wParam) - { - case WA_ACTIVE: - case WA_CLICKACTIVE: - wnd->OnTabActive(); - break; - case WA_INACTIVE: - wnd->OnTabInactive(); - } - break; - case WM_NCACTIVATE: - if (msg->wParam) - wnd->OnTabActive(); - else - wnd->OnTabInactive(); - break; - } - } - - return CallWindowProc(data->oldWndProc, msg->hwnd, msg->message, msg->wParam, msg->lParam); -} - -static HWND FindParent(HWND hwnd) -{ - while (1) - { - HWND hwndParent = GetParent(hwnd); - if (hwndParent == NULL) - return hwnd; - hwnd = hwndParent; - } -} - -int OnProcessSrmmEvent(WPARAM, LPARAM lParam) -{ - MessageWindowEventData *evt = (MessageWindowEventData *)lParam; - - switch (evt->uType) - { - case MSG_WINDOW_EVT_OPENING: - { - CSubclassMgr::Subclass(evt->hwndWindow, SrmmSubclassProc, (LPARAM)evt->hContact); - break; - } - - case MSG_WINDOW_EVT_OPEN: - { - HWND hwndParent = FindParent(evt->hwndWindow); - if (hwndParent != evt->hwndWindow) - { - SetWindowLongPtr(hwndParent, GWL_EXSTYLE, GetWindowLongPtr(hwndParent, GWL_EXSTYLE) & ~WS_EX_APPWINDOW); - CSrmmProxyWindow *wnd = new CSrmmProxyWindow(evt->hContact, evt->hwndWindow, hwndParent); - HWND hwndProxy = wnd->hwnd(); - g_pTaskbarList->UnregisterTab(hwndParent); - g_pTaskbarList->RegisterTab(hwndProxy, hwndParent); - g_pTaskbarList->SetTabOrder(hwndProxy, 0); - g_pTaskbarList->SetTabActive(hwndProxy, hwndParent, TBATF_USEMDITHUMBNAIL); - WindowList_Add(hSrmmWindows, hwndProxy, evt->hContact); - } - break; - } - - case MSG_WINDOW_EVT_CLOSING: - { - HWND hwndProxy = WindowList_Find(hSrmmWindows, evt->hContact); - if (hwndProxy) - { - WindowList_Remove(hSrmmWindows, hwndProxy); - g_pTaskbarList->UnregisterTab(hwndProxy); - DestroyWindow(hwndProxy); - } - break; - } - } - - return 0; -} - -/////////////////////////////////////////////////////////////////////////////// -// status processing - -int OnStatusModeChanged(WPARAM wParam, LPARAM) -{ - static int icons[] = - { - SKINICON_STATUS_OFFLINE, - SKINICON_STATUS_ONLINE, - SKINICON_STATUS_AWAY, - SKINICON_STATUS_DND, - SKINICON_STATUS_NA, - SKINICON_STATUS_OCCUPIED, - SKINICON_STATUS_FREE4CHAT, - SKINICON_STATUS_INVISIBLE, - SKINICON_STATUS_ONTHEPHONE, - SKINICON_STATUS_OUTTOLUNCH, - }; - - g_clistProxyWnd->SetOverlayIcon(LoadSkinnedIcon(icons[wParam - ID_STATUS_OFFLINE])); - - return 0; -} diff --git a/plugins/W7UI/w7ui_10.vcxproj b/plugins/W7UI/w7ui_10.vcxproj index 84c93d20ec..c7331edc9c 100644 --- a/plugins/W7UI/w7ui_10.vcxproj +++ b/plugins/W7UI/w7ui_10.vcxproj @@ -73,7 +73,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;W7UI_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -93,7 +93,7 @@ Disabled ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;W7UI_EXPORTS;%(PreprocessorDefinitions) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 @@ -112,7 +112,7 @@ Full Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;W7UI_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Level3 OnlyExplicitInline @@ -133,7 +133,7 @@ Full Size ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;W7UI_EXPORTS;%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Level3 OnlyExplicitInline @@ -150,31 +150,31 @@ - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/plugins/W7UI/win7api.cpp b/plugins/W7UI/win7api.cpp deleted file mode 100644 index dcfb6058ec..0000000000 --- a/plugins/W7UI/win7api.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include - -//extern "C" const CLSID CLSID_TaskbarList = {0x56fdf344,0xfd6d,0x11d0,{0x95,0x8a,0x00,0x60,0x97,0xc9,0xa0,0x90}}; // 56fdf344-fd6d-11d0-958a-006097c9a090; -//extern "C" const IID IID_ITaskbarList = {0x56FDF342,0xFD6D,0x11d0,{0x95,0x8A,0x00,0x60,0x97,0xC9,0xA0,0x90}}; // 56FDF342-FD6D-11d0-958A-006097C9A090; -//extern "C" const IID IID_ITaskbarList2 = {0x602D4995,0xB13A,0x429b,{0xA6,0x6E,0x19,0x35,0xE4,0x4F,0x43,0x17}}; // 602D4995-B13A-429b-A66E-1935E44F4317; -//extern "C" const IID IID_ICustomDestinationList = {0x6332debf,0x87b5,0x4670,{0x90,0xc0,0x5e,0x57,0xb4,0x08,0xa4,0x9e}}; // 6332debf-87b5-4670-90c0-5e57b408a49e -//extern "C" const IID IID_IObjectArray = {0x92CA9DCD,0x5622,0x4bba,{0xA8,0x05,0x5E,0x9F,0x54,0x1B,0xD8,0xC9}}; // 92CA9DCD-5622-4bba-A805-5E9F541BD8C9 -//extern "C" const IID IID_IObjectCollection = {0x5632b1a4,0xe38a,0x400a,{0x92,0x8a,0xd4,0xcd,0x63,0x23,0x02,0x95}}; // 5632b1a4-e38a-400a-928a-d4cd63230295 -//extern "C" const IID IID_ITaskbarList3 = {0xea1afb91,0x9e28,0x4b86,{0x90,0xe9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf}}; // ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf -extern "C" const CLSID CLSID_CustomDestinationList = {0x77f10cf0,0x3db5,0x4966,{0xb5,0x20,0xb7,0xc5,0x4f,0xd3,0x5e,0xd6}}; -//extern "C" const CLSID CLSID_EnumerableObjectCollection = {0x2d3468c1,0x36a7,0x43b6,{0xac,0x24,0xd3,0xf0,0x2f,0xd9,0x60,0x7a}}; - -HRESULT (WINAPI *dwmInvalidateIconicBitmaps)(HWND) = - (HRESULT (WINAPI *)(HWND))GetProcAddress(LoadLibraryA("dwmapi.dll"), "DwmInvalidateIconicBitmaps"); -HRESULT (WINAPI *dwmSetIconicThumbnail)(HWND, HBITMAP, DWORD) = - (HRESULT (WINAPI *)(HWND, HBITMAP, DWORD))GetProcAddress(LoadLibraryA("dwmapi.dll"), "DwmSetIconicThumbnail"); -HRESULT (WINAPI *dwmSetIconicLivePreviewBitmap)(HWND, HBITMAP, LPPOINT, DWORD) = - (HRESULT (WINAPI *)(HWND, HBITMAP, LPPOINT, DWORD))GetProcAddress(LoadLibraryA("dwmapi.dll"), "DwmSetIconicLivePreviewBitmap"); - -HANDLE (STDAPICALLTYPE *openThemeData)(HWND, LPCWSTR) = - (HANDLE (STDAPICALLTYPE *)(HWND, LPCWSTR))GetProcAddress(LoadLibraryA("uxtheme.dll"), "OpenThemeData"); -HRESULT (STDAPICALLTYPE *drawThemeTextEx)(HANDLE, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const struct _DTTOPTS *) = - (HRESULT (STDAPICALLTYPE *)(HANDLE, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const struct _DTTOPTS *))GetProcAddress(LoadLibraryA("uxtheme.dll"), "DrawThemeTextEx"); -HRESULT (STDAPICALLTYPE *closeThemeData)(HANDLE) = - (HRESULT (STDAPICALLTYPE *)(HANDLE))GetProcAddress(LoadLibraryA("uxtheme.dll"), "CloseThemeData"); diff --git a/plugins/W7UI/win7api.h b/plugins/W7UI/win7api.h deleted file mode 100644 index f9fa806335..0000000000 --- a/plugins/W7UI/win7api.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef win7api_h__ -#define win7api_h__ - -#define WM_DWMSENDICONICTHUMBNAIL 0x0323 -#define WM_DWMSENDICONICLIVEPREVIEWBITMAP 0x0326 - -#define DWMWA_HAS_ICONIC_BITMAP 10 - -#define DWM_SIT_DISPLAYFRAME 0x00000001 - -enum TBATFLAG -{ TBATF_USEMDITHUMBNAIL = 0x1, - TBATF_USEMDILIVEPREVIEW = 0x2 -}; - -#define THBN_CLICKED 0x1800 - -extern HRESULT (WINAPI *dwmInvalidateIconicBitmaps)(HWND); -extern HRESULT (WINAPI *dwmSetIconicThumbnail)(HWND, HBITMAP, DWORD); -extern HRESULT (WINAPI *dwmSetIconicLivePreviewBitmap)(HWND, HBITMAP, LPPOINT, DWORD); - -extern HANDLE (STDAPICALLTYPE *openThemeData)(HWND, LPCWSTR); -extern HRESULT (STDAPICALLTYPE *drawThemeTextEx)(HANDLE, HDC, int, int, LPCWSTR, int, DWORD, LPRECT, const struct _DTTOPTS *); -extern HRESULT (STDAPICALLTYPE *closeThemeData)(HANDLE); - -extern "C" const IID IID_ICustomDestinationList; -extern "C" const IID IID_IObjectArray; -extern "C" const IID IID_IObjectCollection; -extern "C" const IID IID_ITaskbarList3; -extern "C" const CLSID CLSID_CustomDestinationList; -extern "C" const CLSID CLSID_EnumerableObjectCollection; - -#include "win7api_IObjectArray.h" -#include "win7api_IObjectCollection.h" -#include "win7api_ICustomDestinationList.h" -//#include "win7api_ITaskbarList3.h" - -#endif // win7api_h__ diff --git a/plugins/W7UI/win7api_ICustomDestinationList.h b/plugins/W7UI/win7api_ICustomDestinationList.h deleted file mode 100644 index 6d3f770d29..0000000000 --- a/plugins/W7UI/win7api_ICustomDestinationList.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef __ICustomDestinationList_INTERFACE_DEFINED__ -#define __ICustomDestinationList_INTERFACE_DEFINED__ - -typedef /* [v1_enum] */ enum tagKNOWNDESTCATEGORY { - KDC_FREQUENT = 1, - KDC_RECENT = (KDC_FREQUENT + 1) -} KNOWNDESTCATEGORY; - -MIDL_INTERFACE("6332debf-87b5-4670-90c0-5e57b408a49e") -ICustomDestinationList : public IUnknown { - public: - virtual HRESULT STDMETHODCALLTYPE SetAppID( - /* [string][in] */__RPC__in_string LPCWSTR pszAppID) = 0; - virtual HRESULT STDMETHODCALLTYPE BeginList( - /* [out] */ __RPC__out UINT *pcMaxSlots, - /* [in] */ __RPC__in REFIID riid, - /* [iid_is][out] */ __RPC__deref_out_opt void **ppv) = 0; - virtual HRESULT STDMETHODCALLTYPE AppendCategory( - /* [string][in] */ __RPC__in_string LPCWSTR pszCategory, - /* [in] */ __RPC__in_opt IObjectArray *poa) = 0; - virtual HRESULT STDMETHODCALLTYPE AppendKnownCategory( - /* [in] */ KNOWNDESTCATEGORY category) = 0; - virtual HRESULT STDMETHODCALLTYPE AddUserTasks( - /* [in] */ __RPC__in_opt IObjectArray *poa) = 0; - virtual HRESULT STDMETHODCALLTYPE CommitList(void) = 0; - virtual HRESULT STDMETHODCALLTYPE GetRemovedDestinations( - /* [in] */ __RPC__in REFIID riid, - /* [iid_is][out] */ __RPC__deref_out_opt void **ppv) = 0; - virtual HRESULT STDMETHODCALLTYPE DeleteList( - /* [string][in] */ __RPC__in_string LPCWSTR pszAppID) = 0; - virtual HRESULT STDMETHODCALLTYPE AbortList(void) = 0; -}; - -#endif // __ICustomDestinationList_INTERFACE_DEFINED__ diff --git a/plugins/W7UI/win7api_IObjectArray.h b/plugins/W7UI/win7api_IObjectArray.h deleted file mode 100644 index 2102276989..0000000000 --- a/plugins/W7UI/win7api_IObjectArray.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __IObjectArray_INTERFACE_DEFINED__ -#define __IObjectArray_INTERFACE_DEFINED__ - -MIDL_INTERFACE("92CA9DCD-5622-4bba-A805-5E9F541BD8C9") -IObjectArray : public IUnknown { - public: - virtual HRESULT STDMETHODCALLTYPE GetCount( - /* [out] */ __RPC__out UINT *pcObjects) = 0; - virtual HRESULT STDMETHODCALLTYPE GetAt( - /* [in] */ UINT uiIndex, - /* [in] */ __RPC__in REFIID riid, - /* [iid_is][out] */ __RPC__deref_out_opt void **ppv) = 0; -}; - -#endif // __IObjectArray_INTERFACE_DEFINED__ diff --git a/plugins/W7UI/win7api_IObjectCollection.h b/plugins/W7UI/win7api_IObjectCollection.h deleted file mode 100644 index 71b37d0e99..0000000000 --- a/plugins/W7UI/win7api_IObjectCollection.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __IObjectCollection_INTERFACE_DEFINED__ -#define __IObjectCollection_INTERFACE_DEFINED__ - -MIDL_INTERFACE("5632b1a4-e38a-400a-928a-d4cd63230295") -IObjectCollection : public IObjectArray { - public: - virtual HRESULT STDMETHODCALLTYPE AddObject( - /* [in] */ __RPC__in_opt IUnknown *punk) = 0; - virtual HRESULT STDMETHODCALLTYPE AddFromArray( - /* [in] */ __RPC__in_opt IObjectArray *poaSource) = 0; - virtual HRESULT STDMETHODCALLTYPE RemoveObjectAt( - /* [in] */ UINT uiIndex) = 0; - virtual HRESULT STDMETHODCALLTYPE Clear(void) = 0; -}; - -#endif // __IObjectCollection_INTERFACE_DEFINED__ diff --git a/plugins/W7UI/win7api_ITaskbarList3.h b/plugins/W7UI/win7api_ITaskbarList3.h deleted file mode 100644 index 8c39fb5c41..0000000000 --- a/plugins/W7UI/win7api_ITaskbarList3.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __ITaskbarList3_FWD_DEFINED__ -#define __ITaskbarList3_FWD_DEFINED__ -typedef interface ITaskbarList3 ITaskbarList3; -#endif /* __ITaskbarList3_FWD_DEFINED__ */ - -/* interface ITaskbarList3 */ -/* [object][uuid] */ - -MIDL_INTERFACE("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf") -ITaskbarList3 : public ITaskbarList2 -{ -public: - virtual HRESULT STDMETHODCALLTYPE SetProgressValue( - /* [in] */ __RPC__in HWND hwnd, - /* [in] */ ULONGLONG ullCompleted, - /* [in] */ ULONGLONG ullTotal) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetProgressState( - /* [in] */ __RPC__in HWND hwnd, - /* [in] */ TBPFLAG tbpFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE RegisterTab( - /* [in] */ __RPC__in HWND hwndTab, - /* [in] */ __RPC__in HWND hwndMDI) = 0; - - virtual HRESULT STDMETHODCALLTYPE UnregisterTab( - /* [in] */ __RPC__in HWND hwndTab) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetTabOrder( - /* [in] */ __RPC__in HWND hwndTab, - /* [in] */ __RPC__in HWND hwndInsertBefore) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetTabActive( - /* [in] */ __RPC__in HWND hwndTab, - /* [in] */ __RPC__in HWND hwndMDI, - /* [in] */ TBATFLAG tbatFlags) = 0; - - virtual HRESULT STDMETHODCALLTYPE ThumbBarAddButtons( - /* [in] */ __RPC__in HWND hwnd, - /* [in] */ UINT cButtons, - /* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0; - - virtual HRESULT STDMETHODCALLTYPE ThumbBarUpdateButtons( - /* [in] */ __RPC__in HWND hwnd, - /* [in] */ UINT cButtons, - /* [size_is][in] */ __RPC__in_ecount_full(cButtons) LPTHUMBBUTTON pButton) = 0; - - virtual HRESULT STDMETHODCALLTYPE ThumbBarSetImageList( - /* [in] */ __RPC__in HWND hwnd, - /* [in] */ __RPC__in_opt HIMAGELIST himl) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetOverlayIcon( - /* [in] */ __RPC__in HWND hwnd, - /* [in] */ __RPC__in HICON hIcon, - /* [string][in] */ __RPC__in_string LPCWSTR pszDescription) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetThumbnailTooltip( - /* [in] */ __RPC__in HWND hwnd, - /* [string][in] */ __RPC__in_string LPCWSTR pszTip) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetThumbnailClip( - /* [in] */ __RPC__in HWND hwnd, - /* [in] */ __RPC__in RECT *prcClip) = 0; - -}; diff --git a/plugins/WhoUsesMyFiles/docs/wumf.readme.txt b/plugins/WhoUsesMyFiles/docs/wumf.readme.txt new file mode 100644 index 0000000000..f07d9c2275 --- /dev/null +++ b/plugins/WhoUsesMyFiles/docs/wumf.readme.txt @@ -0,0 +1,39 @@ +WUMF: Who Use My Files? +----------------------- + +ver 0.1.0.1 + +This plugins scans for network users of +your shared files and notify you with popups. +Uses PopUps Interoperability by Luca Santarelli. +PopUps plugin must be activated! + +If you like such functionality, +and have any questions/comments, +just write me: nike000@users.sf.net + +ChangeLog: + + improvement + - bugfix + * other changes +----------------------- +0.1.0.1 2003-09-30 + - Fixed bug with menu item + +0.1.0.0 2003-09-18 + + TopToolbar button added, connection list added + - international (locale) filenames are shown correctly + - log is not overwritten every start of Miranda + +0.0.8.0 2003-09-09 + + logging feature, option of log/alert folder access + +0.0.7.0 2003-09-08 + + pop-up options dialog added + +0.0.6.0 2003-09-03 + + size reduced to 4k, thanx to Paul Smakov. nothing more changed. + +0.0.5.0 2003-09-01 + * first public beta. + diff --git a/plugins/WhoUsesMyFiles/list.c b/plugins/WhoUsesMyFiles/list.c deleted file mode 100644 index 1e52e12e4d..0000000000 --- a/plugins/WhoUsesMyFiles/list.c +++ /dev/null @@ -1,172 +0,0 @@ -#include "wumf.h" - -PWumf new_wumf( DWORD dwID, - LPTSTR szUser, - LPTSTR szPath, - LPTSTR szComp, - LPTSTR szUNC, - DWORD dwSess, - DWORD dwPerm, - DWORD dwAttr) -{ - PWumf w; - CHAR szID[10]; - - w = (PWumf)malloc(sizeof(Wumf)); - if(!w)return NULL; - - #define SCPY(X) if(X){w->X = (LPSTR)malloc(1+strlen(X));if(!w->X)return NULL;strcpy(w->X, X);} else { w->X = NULL;} - #define SCPYW(X) if(X){w->X = (LPSTR)malloc(1+lstrlenW(X));if(!w->X)return NULL;wsprintfA(w->X, "%S", X);} else { w->X = NULL;} - - #define SCCPY(X, Y) w->X = (LPSTR)malloc(1+strlen(Y));if(!w->X)return NULL;strcpy(w->X, Y) - - SCPYW(szUser); - SCPYW(szPath); - SCPYW(szComp); - SCPYW(szUNC); - switch(dwPerm) - { - case PERM_FILE_READ: SCCPY(szPerm, "Read");break; - case PERM_FILE_WRITE: SCCPY(szPerm, "Write");break; - case PERM_FILE_CREATE: SCCPY(szPerm, "Create");break; - default: SCCPY(szPerm, "Execute");//w->szPerm = NULL; - }; - wsprintf(szID, "%i", dwID); - SCPY(szID); - - #undef SCPY - w->dwID = dwID; - w->dwSess = dwSess; - w->dwAttr = dwAttr; - w->dwPerm = dwPerm; - w->mark = FALSE; - w->next = NULL; - return w; -} - -BOOL del_wumf(PWumf w) -{ - if(!w) return FALSE; - free(w->szUser); - free(w->szPath); - free(w->szComp); - free(w->szUNC); - free(w->szID); - free(w->szPerm); - free(w); - return TRUE; -} - -BOOL add_cell(PWumf* l, PWumf w) -{ - PWumf p; - if(!w || !l)return FALSE; - if(!(*l)) - { - *l = w; - } - else - { - p = *l; - while(p->next) p = p->next; - p->next = w; - } - w->next = NULL; - return TRUE; -} - -BOOL del_cell(PWumf *l, PWumf w) -{ - PWumf p; - if(!l || !*l || !w)return FALSE; - p = *l; - if(w == *l) - *l = p->next; - else - { - while(p && p->next != w) p = p->next; - if(!p) return FALSE; - p->next = w->next; - } - return del_wumf(w); - -}; - -BOOL cpy_cell(PWumf *l, PWumf w) -{ - PWumf w1; - w1 = new_wumf(w->dwID, w->szUser, w->szPath, w->szComp,w->szUNC, w->dwSess, w->dwPerm, w->dwAttr); - if(!w1) return FALSE; - w1->mark = w->mark; - return add_cell(l, w1); -}; - -PWumf cpy_list(PWumf *l) -{ - PWumf w, p = NULL; - - if(!l || !*l) return NULL; - w = *l; - while(w) - { - if(!cpy_cell(&p, w))return NULL; - w = w->next; - } - return p; -} - -PWumf fnd_cell(PWumf *l, DWORD dwID) -{ - PWumf w; - if(!l || !*l)return NULL; - w = *l; - while(w && w->dwID != dwID) w = w->next; - return w; -} - -BOOL del_all(PWumf *l) -{ - PWumf w, p; - if(!l || !*l) return FALSE; - w = *l; - while(w) - { - p = w->next; - if(!del_cell(l, w)) - { - return FALSE; - } - w = p; - } - *l = NULL; - - return TRUE; -} - -BOOL del_marked(PWumf *l) -{ - PWumf w, p; - if(!l)return FALSE; - w = *l; - while(w) - { - p = w->next; - if(w->mark) - { - if(!del_cell(l, w)) return FALSE; - }; - w = p; - } - return TRUE; -} - -void mark_all(PWumf *l, BOOL mark) -{ - PWumf w; - w = *l; - while(w) - { - w->mark = mark; - w = w->next; - } -} diff --git a/plugins/WhoUsesMyFiles/res/drive.bmp b/plugins/WhoUsesMyFiles/res/drive.bmp deleted file mode 100644 index 767aef2997..0000000000 Binary files a/plugins/WhoUsesMyFiles/res/drive.bmp and /dev/null differ diff --git a/plugins/WhoUsesMyFiles/res/resource.rc b/plugins/WhoUsesMyFiles/res/resource.rc new file mode 100644 index 0000000000..a0333d96ef --- /dev/null +++ b/plugins/WhoUsesMyFiles/res/resource.rc @@ -0,0 +1,203 @@ +//Microsoft Developer Studio generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_CONNLIST DIALOGEX 0, 0, 330, 230 +STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +EXSTYLE WS_EX_NOPARENTNOTIFY +CAPTION "WUMF: Current connections" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,276,212,50,14 + CONTROL "List1",IDC_CONNLIST,"SysListView32",LVS_REPORT | + LVS_SINGLESEL | LVS_SORTASCENDING | WS_TABSTOP,4,4,322, + 200,WS_EX_CLIENTEDGE +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_CONNLIST, DIALOG + BEGIN + LEFTMARGIN, 4 + RIGHTMARGIN, 326 + TOPMARGIN, 4 + BOTTOMMARGIN, 226 + END +END +#endif // APSTUDIO_INVOKED + + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// 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 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPTIONS DIALOGEX 0, 0, 330, 246 +STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTEXTHELP | WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Popup delay settings",IDC_STATIC,9,9,153,93,WS_GROUP + EDITTEXT IDC_DELAY_SEC,17,23,20,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "PopUp Delay (seconds)",IDC_TX_DELAY_SEC,39,25,94,8 + CONTROL "",IDC_COLOR_BACK,"ColourPicker",WS_TABSTOP,187,24,39,12 + LTEXT "Background color",IDC_STATIC,231,26,76,8,SS_CENTERIMAGE | + NOT WS_GROUP + CONTROL "",IDC_COLOR_TEXT,"ColourPicker",WS_TABSTOP,187,39,39,12 + LTEXT "Text color",IDC_STATIC,231,42,76,8,SS_CENTERIMAGE | NOT + WS_GROUP + PUSHBUTTON "Previe&w",IDC_PREVIEW,270,231,50,15 + CONTROL "Show infinitely",IDC_DELAY_INF,"Button", + BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,17,50,61,10 + CONTROL "Default PopUp delay",IDC_DELAY_DEF,"Button", + BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,17,61,81,10 + CONTROL "Choose delay time",IDC_DELAY_SET,"Button", + BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,17,39,73,10 + GROUPBOX "Popup color settings",IDC_STATIC,167,9,153,93,WS_GROUP + CONTROL "Use windows colors",IDC_COLOR_WIN,"Button", + BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,187,63,79,10 + CONTROL "Use default PopUp colors",IDC_COLOR_DEF,"Button", + BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,187,74,97,10 + CONTROL "Choose colors",IDC_COLOR_SET,"Button", + BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,187,52,61,10 + GROUPBOX "File access filter && logging settings",IDC_STATIC,9, + 106,311,101 + CTEXT "Please note that this settings has effect only with PopUps Interoperability plugin version 1.0.1.9 or higher", + IDC_DELAY_NOTE,14,73,143,26,SS_SUNKEN | WS_DISABLED | + NOT WS_GROUP + EDITTEXT IDC_FILE,83,123,210,12,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES + PUSHBUTTON "...",IDC_SEL_FILE,299,123,14,12 + CONTROL "Log into text file",IDC_LOG_INTO_FILE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,14,123,64,12 + CONTROL "Log folders access",IDC_LOG_FOLDER,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,14,143,75,12 + CONTROL "Alerts on folders access",IDC_ALERT_FOLDER,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,165,143,91,12 + CONTROL "Log files and folders in UNC format",IDC_LOG_UNC,"Button", + BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,14,163,125,12 + CONTROL "Alert files && folders in UNC format",IDC_ALERT_UNC, + "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,165, + 163,119,12 + CONTROL "Log computer name with username",IDC_LOG_COMP,"Button", + BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,14,183,126,10 + CONTROL "Alert computer name with username",IDC_ALERT_COMP, + "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,165, + 183,128,10 + LTEXT "Disabled options will be available in the next version", + IDC_STATIC,83,194,199,9 + PUSHBUTTON "Show current connections",IDC_CONN,162,231,104,15 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPTIONS, DIALOG + BEGIN + RIGHTMARGIN, 320 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_POPUP ICON "popup.ico" +IDI_NOPOPUP ICON "popup_no.ico" +IDI_DRIVE ICON "drive.ico" +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/WhoUsesMyFiles/res/wumf.readme.txt b/plugins/WhoUsesMyFiles/res/wumf.readme.txt deleted file mode 100644 index f07d9c2275..0000000000 --- a/plugins/WhoUsesMyFiles/res/wumf.readme.txt +++ /dev/null @@ -1,39 +0,0 @@ -WUMF: Who Use My Files? ------------------------ - -ver 0.1.0.1 - -This plugins scans for network users of -your shared files and notify you with popups. -Uses PopUps Interoperability by Luca Santarelli. -PopUps plugin must be activated! - -If you like such functionality, -and have any questions/comments, -just write me: nike000@users.sf.net - -ChangeLog: - + improvement - - bugfix - * other changes ------------------------ -0.1.0.1 2003-09-30 - - Fixed bug with menu item - -0.1.0.0 2003-09-18 - + TopToolbar button added, connection list added - - international (locale) filenames are shown correctly - - log is not overwritten every start of Miranda - -0.0.8.0 2003-09-09 - + logging feature, option of log/alert folder access - -0.0.7.0 2003-09-08 - + pop-up options dialog added - -0.0.6.0 2003-09-03 - + size reduced to 4k, thanx to Paul Smakov. nothing more changed. - -0.0.5.0 2003-09-01 - * first public beta. - diff --git a/plugins/WhoUsesMyFiles/resizer.c b/plugins/WhoUsesMyFiles/resizer.c deleted file mode 100644 index e45d10a453..0000000000 --- a/plugins/WhoUsesMyFiles/resizer.c +++ /dev/null @@ -1,131 +0,0 @@ -#include "wumf.h" -#pragma hdrstop - -typedef struct { - DWORD helpID; - DWORD exStyle; - DWORD style; - short x; - short y; - short cx; - short cy; - WORD id; -} START_OF_DLGITEMTEMPLATEEX; - -typedef struct { - WORD dlgVer; - WORD signature; - DWORD helpID; - DWORD exStyle; - DWORD style; - WORD cDlgItems; - short x; - short y; - short cx; - short cy; -} START_OF_DLGTEMPLATEEX; - -int ResizeDialog(WPARAM wParam,LPARAM lParam) -{ - UTILRESIZEDIALOG *urd=(UTILRESIZEDIALOG*)lParam; - HDWP hDwp; - int i; - DLGITEMTEMPLATE *pItem; - START_OF_DLGITEMTEMPLATEEX *pItemEx; - RECT rc; - PWORD pWord; - DLGTEMPLATE *pTemplate; - START_OF_DLGTEMPLATEEX *pTemplateEx; - UTILRESIZECONTROL urc; - int procResult; - int extendedDlg,itemCount; - - if(urd->cbSize!=sizeof(UTILRESIZEDIALOG)) return 1; - pTemplate=(DLGTEMPLATE*)LockResource(LoadResource(urd->hInstance,FindResource(urd->hInstance,urd->lpTemplate,RT_DIALOG))); - pTemplateEx=(START_OF_DLGTEMPLATEEX*)pTemplate; - extendedDlg=pTemplateEx->signature==0xFFFF; - if(extendedDlg && pTemplateEx->dlgVer!=1) - return 1; - - if(extendedDlg) pWord=(PWORD)(pTemplateEx+1); - else pWord=(PWORD)(pTemplate+1); - if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //menu - if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //class - while(*pWord++); //title - if(extendedDlg) { - if(pTemplateEx->style&DS_SETFONT) { - pWord+=3; //font size,weight,italic - while(*pWord++); //font name - } - } - else { - if(pTemplate->style&DS_SETFONT) { - pWord++; //font size - while(*pWord++); //font name - } - } - - urc.cbSize=sizeof(UTILRESIZECONTROL); - rc.left=0; rc.top=0; - if(extendedDlg) {rc.right=pTemplateEx->cx; rc.bottom=pTemplateEx->cy;} - else {rc.right=pTemplate->cx; rc.bottom=pTemplate->cy;} - MapDialogRect(urd->hwndDlg,&rc); - urc.dlgOriginalSize.cx=rc.right; urc.dlgOriginalSize.cy=rc.bottom; - GetClientRect(urd->hwndDlg,&rc); - urc.dlgNewSize.cx=rc.right; urc.dlgNewSize.cy=rc.bottom; - - if(extendedDlg) itemCount=pTemplateEx->cDlgItems; - else itemCount=pTemplate->cdit; - hDwp=BeginDeferWindowPos(itemCount); - for(i=0;iid; - urc.rcItem.left=pItemEx->x; urc.rcItem.top=pItemEx->y; - urc.rcItem.right=urc.rcItem.left+pItemEx->cx; urc.rcItem.bottom=urc.rcItem.top+pItemEx->cy; - } - else { - pItem=(DLGITEMTEMPLATE*)pWord; - pWord=(PWORD)(pItem+1); - - urc.wId=pItem->id; - urc.rcItem.left=pItem->x; urc.rcItem.top=pItem->y; - urc.rcItem.right=urc.rcItem.left+pItem->cx; urc.rcItem.bottom=urc.rcItem.top+pItem->cy; - } - if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //menu - if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //class - pWord+=1+(1+*pWord)/2; //creation data - - if(urc.wId==65535) continue; //using this breaks the dwp, so just ignore it - - MapDialogRect(urd->hwndDlg,&urc.rcItem); - procResult=(urd->pfnResizer)(urd->hwndDlg,urd->lParam,&urc); - if(procResult&RD_ANCHORX_RIGHT) { - urc.rcItem.left+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; - urc.rcItem.right+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; - } - else if(procResult&RD_ANCHORX_WIDTH) - urc.rcItem.right+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; - else if(procResult&RD_ANCHORX_CENTRE) { - urc.rcItem.left+=(urc.dlgNewSize.cx-urc.dlgOriginalSize.cx)/2; - urc.rcItem.right+=(urc.dlgNewSize.cx-urc.dlgOriginalSize.cx)/2; - } - if(procResult&RD_ANCHORY_BOTTOM) { - urc.rcItem.top+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; - urc.rcItem.bottom+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; - } - else if(procResult&RD_ANCHORY_HEIGHT) - urc.rcItem.bottom+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; - else if(procResult&RD_ANCHORY_CENTRE) { - urc.rcItem.top+=(urc.dlgNewSize.cy-urc.dlgOriginalSize.cy)/2; - urc.rcItem.bottom+=(urc.dlgNewSize.cy-urc.dlgOriginalSize.cy)/2; - } - hDwp=DeferWindowPos(hDwp,GetDlgItem(urd->hwndDlg,extendedDlg?pItemEx->id:pItem->id),0,urc.rcItem.left,urc.rcItem.top,urc.rcItem.right-urc.rcItem.left,urc.rcItem.bottom-urc.rcItem.top,SWP_NOZORDER); - } - EndDeferWindowPos(hDwp); - return 0; -} \ No newline at end of file diff --git a/plugins/WhoUsesMyFiles/resource.h b/plugins/WhoUsesMyFiles/resource.h deleted file mode 100644 index 3fb3c7e09e..0000000000 --- a/plugins/WhoUsesMyFiles/resource.h +++ /dev/null @@ -1,47 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by resource.rc -// -#define IDD_OPTIONS 101 -#define IDI_POPUP 102 -#define IDI_NOPOPUP 103 -#define IDI_DRIVE 106 -#define IDD_CONNLIST 107 -#define IDB_DRIVE 108 -#define IDC_COLOR_SET 1000 -#define IDC_COLOR_WIN 1001 -#define IDC_COLOR_DEF 1002 -#define IDC_COLOR_BACK 1003 -#define IDC_COLOR_TEXT 1004 -#define IDC_FILE 1006 -#define IDC_SEL_FILE 1007 -#define IDC_DELAY_SEC 1026 -#define IDC_PREVIEW 1033 -#define IDC_DEBUG 1034 -#define IDC_DELAY_SET 1049 -#define IDC_DELAY_INF 1050 -#define IDC_DELAY_DEF 1051 -#define IDC_DELAY_NOTE 1052 -#define IDC_TX_DELAY_SEC 1053 -#define IDC_LOG_INTO_FILE 1054 -#define IDC_LOG_FOLDER 1055 -#define IDC_ALERT_FOLDER 1056 -#define IDC_LOG_UNC 1057 -#define IDC_ALERT_UNC 1058 -#define IDC_LOG_COMP 1059 -#define IDC_ALERT_COMP 1060 -#define IDC_CONNLIST 1061 -#define IDC_CONN 1062 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NO_MFC 1 -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 109 -#define _APS_NEXT_COMMAND_VALUE 40081 -#define _APS_NEXT_CONTROL_VALUE 1063 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/WhoUsesMyFiles/resource.rc b/plugins/WhoUsesMyFiles/resource.rc deleted file mode 100644 index 1bf8f41511..0000000000 --- a/plugins/WhoUsesMyFiles/resource.rc +++ /dev/null @@ -1,209 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Russian resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -#ifdef _WIN32 -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_CONNLIST DIALOGEX 0, 0, 330, 230 -STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | - WS_THICKFRAME -EXSTYLE WS_EX_NOPARENTNOTIFY -CAPTION "WUMF: Current connections" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "OK",IDOK,276,212,50,14 - CONTROL "List1",IDC_CONNLIST,"SysListView32",LVS_REPORT | - LVS_SINGLESEL | LVS_SORTASCENDING | WS_TABSTOP,4,4,322, - 200,WS_EX_CLIENTEDGE -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_CONNLIST, DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 326 - TOPMARGIN, 4 - BOTTOMMARGIN, 226 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDB_DRIVE BITMAP DISCARDABLE "res\\drive.bmp" -#endif // Russian resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// 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 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPTIONS DIALOGEX 0, 0, 330, 246 -STYLE DS_MODALFRAME | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTEXTHELP | WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "Popup delay settings",IDC_STATIC,9,9,153,93,WS_GROUP - EDITTEXT IDC_DELAY_SEC,17,23,20,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "PopUp Delay (seconds)",IDC_TX_DELAY_SEC,39,25,94,8 - CONTROL "",IDC_COLOR_BACK,"ColourPicker",WS_TABSTOP,187,24,39,12 - LTEXT "Background color",IDC_STATIC,231,26,76,8,SS_CENTERIMAGE | - NOT WS_GROUP - CONTROL "",IDC_COLOR_TEXT,"ColourPicker",WS_TABSTOP,187,39,39,12 - LTEXT "Text color",IDC_STATIC,231,42,76,8,SS_CENTERIMAGE | NOT - WS_GROUP - PUSHBUTTON "Previe&w",IDC_PREVIEW,270,231,50,15 - CONTROL "Show infinitely",IDC_DELAY_INF,"Button", - BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,17,50,61,10 - CONTROL "Default PopUp delay",IDC_DELAY_DEF,"Button", - BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,17,61,81,10 - CONTROL "Choose delay time",IDC_DELAY_SET,"Button", - BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,17,39,73,10 - GROUPBOX "Popup color settings",IDC_STATIC,167,9,153,93,WS_GROUP - CONTROL "Use windows colors",IDC_COLOR_WIN,"Button", - BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,187,63,79,10 - CONTROL "Use default PopUp colors",IDC_COLOR_DEF,"Button", - BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,187,74,97,10 - CONTROL "Choose colors",IDC_COLOR_SET,"Button", - BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,187,52,61,10 - GROUPBOX "File access filter && logging settings",IDC_STATIC,9, - 106,311,101 - CTEXT "Please note that this settings has effect only with PopUps Interoperability plugin version 1.0.1.9 or higher", - IDC_DELAY_NOTE,14,73,143,26,SS_SUNKEN | WS_DISABLED | - NOT WS_GROUP - EDITTEXT IDC_FILE,83,123,210,12,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES - PUSHBUTTON "...",IDC_SEL_FILE,299,123,14,12 - CONTROL "Log into text file",IDC_LOG_INTO_FILE,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,14,123,64,12 - CONTROL "Log folders access",IDC_LOG_FOLDER,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,14,143,75,12 - CONTROL "Alerts on folders access",IDC_ALERT_FOLDER,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,165,143,91,12 - CONTROL "Log files and folders in UNC format",IDC_LOG_UNC,"Button", - BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,14,163,125,12 - CONTROL "Alert files && folders in UNC format",IDC_ALERT_UNC, - "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,165, - 163,119,12 - CONTROL "Log computer name with username",IDC_LOG_COMP,"Button", - BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,14,183,126,10 - CONTROL "Alert computer name with username",IDC_ALERT_COMP, - "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,165, - 183,128,10 - LTEXT "Disabled options will be available in the next version", - IDC_STATIC,83,194,199,9 - PUSHBUTTON "Show current connections",IDC_CONN,162,231,104,15 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_OPTIONS, DIALOG - BEGIN - RIGHTMARGIN, 320 - END -END -#endif // APSTUDIO_INVOKED - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_POPUP ICON DISCARDABLE "res\\popup.ico" -IDI_NOPOPUP ICON DISCARDABLE "res\\popup_no.ico" -IDI_DRIVE ICON DISCARDABLE "res\\drive.ico" -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/WhoUsesMyFiles/src/list.c b/plugins/WhoUsesMyFiles/src/list.c new file mode 100644 index 0000000000..1e52e12e4d --- /dev/null +++ b/plugins/WhoUsesMyFiles/src/list.c @@ -0,0 +1,172 @@ +#include "wumf.h" + +PWumf new_wumf( DWORD dwID, + LPTSTR szUser, + LPTSTR szPath, + LPTSTR szComp, + LPTSTR szUNC, + DWORD dwSess, + DWORD dwPerm, + DWORD dwAttr) +{ + PWumf w; + CHAR szID[10]; + + w = (PWumf)malloc(sizeof(Wumf)); + if(!w)return NULL; + + #define SCPY(X) if(X){w->X = (LPSTR)malloc(1+strlen(X));if(!w->X)return NULL;strcpy(w->X, X);} else { w->X = NULL;} + #define SCPYW(X) if(X){w->X = (LPSTR)malloc(1+lstrlenW(X));if(!w->X)return NULL;wsprintfA(w->X, "%S", X);} else { w->X = NULL;} + + #define SCCPY(X, Y) w->X = (LPSTR)malloc(1+strlen(Y));if(!w->X)return NULL;strcpy(w->X, Y) + + SCPYW(szUser); + SCPYW(szPath); + SCPYW(szComp); + SCPYW(szUNC); + switch(dwPerm) + { + case PERM_FILE_READ: SCCPY(szPerm, "Read");break; + case PERM_FILE_WRITE: SCCPY(szPerm, "Write");break; + case PERM_FILE_CREATE: SCCPY(szPerm, "Create");break; + default: SCCPY(szPerm, "Execute");//w->szPerm = NULL; + }; + wsprintf(szID, "%i", dwID); + SCPY(szID); + + #undef SCPY + w->dwID = dwID; + w->dwSess = dwSess; + w->dwAttr = dwAttr; + w->dwPerm = dwPerm; + w->mark = FALSE; + w->next = NULL; + return w; +} + +BOOL del_wumf(PWumf w) +{ + if(!w) return FALSE; + free(w->szUser); + free(w->szPath); + free(w->szComp); + free(w->szUNC); + free(w->szID); + free(w->szPerm); + free(w); + return TRUE; +} + +BOOL add_cell(PWumf* l, PWumf w) +{ + PWumf p; + if(!w || !l)return FALSE; + if(!(*l)) + { + *l = w; + } + else + { + p = *l; + while(p->next) p = p->next; + p->next = w; + } + w->next = NULL; + return TRUE; +} + +BOOL del_cell(PWumf *l, PWumf w) +{ + PWumf p; + if(!l || !*l || !w)return FALSE; + p = *l; + if(w == *l) + *l = p->next; + else + { + while(p && p->next != w) p = p->next; + if(!p) return FALSE; + p->next = w->next; + } + return del_wumf(w); + +}; + +BOOL cpy_cell(PWumf *l, PWumf w) +{ + PWumf w1; + w1 = new_wumf(w->dwID, w->szUser, w->szPath, w->szComp,w->szUNC, w->dwSess, w->dwPerm, w->dwAttr); + if(!w1) return FALSE; + w1->mark = w->mark; + return add_cell(l, w1); +}; + +PWumf cpy_list(PWumf *l) +{ + PWumf w, p = NULL; + + if(!l || !*l) return NULL; + w = *l; + while(w) + { + if(!cpy_cell(&p, w))return NULL; + w = w->next; + } + return p; +} + +PWumf fnd_cell(PWumf *l, DWORD dwID) +{ + PWumf w; + if(!l || !*l)return NULL; + w = *l; + while(w && w->dwID != dwID) w = w->next; + return w; +} + +BOOL del_all(PWumf *l) +{ + PWumf w, p; + if(!l || !*l) return FALSE; + w = *l; + while(w) + { + p = w->next; + if(!del_cell(l, w)) + { + return FALSE; + } + w = p; + } + *l = NULL; + + return TRUE; +} + +BOOL del_marked(PWumf *l) +{ + PWumf w, p; + if(!l)return FALSE; + w = *l; + while(w) + { + p = w->next; + if(w->mark) + { + if(!del_cell(l, w)) return FALSE; + }; + w = p; + } + return TRUE; +} + +void mark_all(PWumf *l, BOOL mark) +{ + PWumf w; + w = *l; + while(w) + { + w->mark = mark; + w = w->next; + } +} diff --git a/plugins/WhoUsesMyFiles/src/resizer.c b/plugins/WhoUsesMyFiles/src/resizer.c new file mode 100644 index 0000000000..e45d10a453 --- /dev/null +++ b/plugins/WhoUsesMyFiles/src/resizer.c @@ -0,0 +1,131 @@ +#include "wumf.h" +#pragma hdrstop + +typedef struct { + DWORD helpID; + DWORD exStyle; + DWORD style; + short x; + short y; + short cx; + short cy; + WORD id; +} START_OF_DLGITEMTEMPLATEEX; + +typedef struct { + WORD dlgVer; + WORD signature; + DWORD helpID; + DWORD exStyle; + DWORD style; + WORD cDlgItems; + short x; + short y; + short cx; + short cy; +} START_OF_DLGTEMPLATEEX; + +int ResizeDialog(WPARAM wParam,LPARAM lParam) +{ + UTILRESIZEDIALOG *urd=(UTILRESIZEDIALOG*)lParam; + HDWP hDwp; + int i; + DLGITEMTEMPLATE *pItem; + START_OF_DLGITEMTEMPLATEEX *pItemEx; + RECT rc; + PWORD pWord; + DLGTEMPLATE *pTemplate; + START_OF_DLGTEMPLATEEX *pTemplateEx; + UTILRESIZECONTROL urc; + int procResult; + int extendedDlg,itemCount; + + if(urd->cbSize!=sizeof(UTILRESIZEDIALOG)) return 1; + pTemplate=(DLGTEMPLATE*)LockResource(LoadResource(urd->hInstance,FindResource(urd->hInstance,urd->lpTemplate,RT_DIALOG))); + pTemplateEx=(START_OF_DLGTEMPLATEEX*)pTemplate; + extendedDlg=pTemplateEx->signature==0xFFFF; + if(extendedDlg && pTemplateEx->dlgVer!=1) + return 1; + + if(extendedDlg) pWord=(PWORD)(pTemplateEx+1); + else pWord=(PWORD)(pTemplate+1); + if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //menu + if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //class + while(*pWord++); //title + if(extendedDlg) { + if(pTemplateEx->style&DS_SETFONT) { + pWord+=3; //font size,weight,italic + while(*pWord++); //font name + } + } + else { + if(pTemplate->style&DS_SETFONT) { + pWord++; //font size + while(*pWord++); //font name + } + } + + urc.cbSize=sizeof(UTILRESIZECONTROL); + rc.left=0; rc.top=0; + if(extendedDlg) {rc.right=pTemplateEx->cx; rc.bottom=pTemplateEx->cy;} + else {rc.right=pTemplate->cx; rc.bottom=pTemplate->cy;} + MapDialogRect(urd->hwndDlg,&rc); + urc.dlgOriginalSize.cx=rc.right; urc.dlgOriginalSize.cy=rc.bottom; + GetClientRect(urd->hwndDlg,&rc); + urc.dlgNewSize.cx=rc.right; urc.dlgNewSize.cy=rc.bottom; + + if(extendedDlg) itemCount=pTemplateEx->cDlgItems; + else itemCount=pTemplate->cdit; + hDwp=BeginDeferWindowPos(itemCount); + for(i=0;iid; + urc.rcItem.left=pItemEx->x; urc.rcItem.top=pItemEx->y; + urc.rcItem.right=urc.rcItem.left+pItemEx->cx; urc.rcItem.bottom=urc.rcItem.top+pItemEx->cy; + } + else { + pItem=(DLGITEMTEMPLATE*)pWord; + pWord=(PWORD)(pItem+1); + + urc.wId=pItem->id; + urc.rcItem.left=pItem->x; urc.rcItem.top=pItem->y; + urc.rcItem.right=urc.rcItem.left+pItem->cx; urc.rcItem.bottom=urc.rcItem.top+pItem->cy; + } + if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //menu + if(*pWord==0xFFFF) pWord+=2; else while(*pWord++); //class + pWord+=1+(1+*pWord)/2; //creation data + + if(urc.wId==65535) continue; //using this breaks the dwp, so just ignore it + + MapDialogRect(urd->hwndDlg,&urc.rcItem); + procResult=(urd->pfnResizer)(urd->hwndDlg,urd->lParam,&urc); + if(procResult&RD_ANCHORX_RIGHT) { + urc.rcItem.left+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; + urc.rcItem.right+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; + } + else if(procResult&RD_ANCHORX_WIDTH) + urc.rcItem.right+=urc.dlgNewSize.cx-urc.dlgOriginalSize.cx; + else if(procResult&RD_ANCHORX_CENTRE) { + urc.rcItem.left+=(urc.dlgNewSize.cx-urc.dlgOriginalSize.cx)/2; + urc.rcItem.right+=(urc.dlgNewSize.cx-urc.dlgOriginalSize.cx)/2; + } + if(procResult&RD_ANCHORY_BOTTOM) { + urc.rcItem.top+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; + urc.rcItem.bottom+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; + } + else if(procResult&RD_ANCHORY_HEIGHT) + urc.rcItem.bottom+=urc.dlgNewSize.cy-urc.dlgOriginalSize.cy; + else if(procResult&RD_ANCHORY_CENTRE) { + urc.rcItem.top+=(urc.dlgNewSize.cy-urc.dlgOriginalSize.cy)/2; + urc.rcItem.bottom+=(urc.dlgNewSize.cy-urc.dlgOriginalSize.cy)/2; + } + hDwp=DeferWindowPos(hDwp,GetDlgItem(urd->hwndDlg,extendedDlg?pItemEx->id:pItem->id),0,urc.rcItem.left,urc.rcItem.top,urc.rcItem.right-urc.rcItem.left,urc.rcItem.bottom-urc.rcItem.top,SWP_NOZORDER); + } + EndDeferWindowPos(hDwp); + return 0; +} \ No newline at end of file diff --git a/plugins/WhoUsesMyFiles/src/resource.h b/plugins/WhoUsesMyFiles/src/resource.h new file mode 100644 index 0000000000..6e4cd69615 --- /dev/null +++ b/plugins/WhoUsesMyFiles/src/resource.h @@ -0,0 +1,46 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by resource.rc +// +#define IDD_OPTIONS 101 +#define IDI_POPUP 102 +#define IDI_NOPOPUP 103 +#define IDI_DRIVE 106 +#define IDD_CONNLIST 107 +#define IDC_COLOR_SET 1000 +#define IDC_COLOR_WIN 1001 +#define IDC_COLOR_DEF 1002 +#define IDC_COLOR_BACK 1003 +#define IDC_COLOR_TEXT 1004 +#define IDC_FILE 1006 +#define IDC_SEL_FILE 1007 +#define IDC_DELAY_SEC 1026 +#define IDC_PREVIEW 1033 +#define IDC_DEBUG 1034 +#define IDC_DELAY_SET 1049 +#define IDC_DELAY_INF 1050 +#define IDC_DELAY_DEF 1051 +#define IDC_DELAY_NOTE 1052 +#define IDC_TX_DELAY_SEC 1053 +#define IDC_LOG_INTO_FILE 1054 +#define IDC_LOG_FOLDER 1055 +#define IDC_ALERT_FOLDER 1056 +#define IDC_LOG_UNC 1057 +#define IDC_ALERT_UNC 1058 +#define IDC_LOG_COMP 1059 +#define IDC_ALERT_COMP 1060 +#define IDC_CONNLIST 1061 +#define IDC_CONN 1062 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_3D_CONTROLS 1 +#define _APS_NEXT_RESOURCE_VALUE 109 +#define _APS_NEXT_COMMAND_VALUE 40081 +#define _APS_NEXT_CONTROL_VALUE 1063 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/WhoUsesMyFiles/src/wumf.c b/plugins/WhoUsesMyFiles/src/wumf.c new file mode 100644 index 0000000000..03aa576d38 --- /dev/null +++ b/plugins/WhoUsesMyFiles/src/wumf.c @@ -0,0 +1,330 @@ +#define MAX_CHARS 4096 +#define WS_WINDOW_STYLE WS_OVERLAPPED +#define NAME "WUMF" +#define WM_MYCMD 0x0401 + +#include "wumf.h" +static PWumf list = NULL; +static PWumf lst = NULL; + +extern WUMF_OPTIONS WumfOptions; +extern HANDLE hInst; +extern HWND hDlg; +extern char ModuleName[]; + +HANDLE hLog = INVALID_HANDLE_VALUE; +BOOL wumf(); + +static int DlgResizer(HWND hwndDlg,LPARAM lParam,UTILRESIZECONTROL *urc) { + switch(urc->wId) { + case IDC_CONNLIST: + return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; + case IDOK: + return RD_ANCHORX_RIGHT|RD_ANCHORY_BOTTOM; + } + return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; +} + + + +void AddToList(HWND hList, PWumf w) +{ + LVITEM lvi = { 0 }; + lvi.iItem=ListView_GetItemCount(hList)+1; + lvi.mask= LVIF_PARAM|LVIF_TEXT; + lvi.pszText = w->szID; + lvi.cchTextMax = (int)_tcslen(w->szID); + lvi.lParam = (LPARAM)w; + ListView_InsertItem(hList,&lvi); +} + +void ShowList(PWumf l, HWND hList) +{ + PWumf w; + w = l; + while(w) + { + AddToList(hList,w); + w = w->next; + } +} + +VOID OnGetDispInfo(NMLVDISPINFO *plvdi) +{ + PWumf w; + w = (PWumf)(plvdi->item.lParam); + switch (plvdi->item.iSubItem) + { + case 0: + plvdi->item.pszText = w->szID; + break; + case 1: + plvdi->item.pszText = w->szUser; + break; + case 2: + plvdi->item.pszText = w->szPath; + break; + case 3: + plvdi->item.pszText = w->szPerm; + break; + default: + break; + } +} + + +int CALLBACK ConnDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +{ + UTILRESIZEDIALOG urd={0}; + LV_COLUMN lvc = { 0 }; + char col0[] = "ID"; + char col1[] = "User"; + char col2[] = "File"; + char col3[] = "Access"; +// char buff[256]; + HWND hList; + switch( Msg ) + { + case WM_INITDIALOG: + hList = GetDlgItem(hWnd, IDC_CONNLIST); +// ListView_DeleteAllItems(hList); + ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT); + lvc.mask = LVCF_TEXT|LVCF_FMT|LVCF_WIDTH; + lvc.fmt = LVCFMT_LEFT; + lvc.cx = 40; + lvc.pszText = col0; + lvc.cchTextMax = sizeof(col0); + ListView_InsertColumn(hList, 0, &lvc); + lvc.cx = 50; + lvc.pszText = col1; + lvc.cchTextMax = sizeof(col1); + ListView_InsertColumn(hList, 1, &lvc); + lvc.cx = 250; + lvc.pszText = col2; + lvc.cchTextMax = sizeof(col2); + ListView_InsertColumn(hList, 2, &lvc); + lvc.cx = 50; + lvc.pszText = col3; + lvc.cchTextMax = sizeof(col3); + ListView_InsertColumn(hList, 3, &lvc); + KillTimer(NULL, 777); + lst = cpy_list(&list); + if (IsUserAnAdmin()) { + SetTimer(NULL, 777, TIME,(TIMERPROC) TimerProc); + } else { + MessageBox(NULL, "Plugin WhoUsesMyFiles requires admin privileges in order to work.", "Miranda IM", MB_OK); + } + ShowList(lst, hList); + Utils_RestoreWindowPosition(hWnd, NULL, ModuleName,"conn"); + break; + case WM_CLOSE: + PostMessage( hWnd, WM_COMMAND, IDCANCEL, 0l ); + break; + case WM_COMMAND: + switch( LOWORD(wParam) ) + { + case IDOK: + case IDCANCEL: + PostMessage( hWnd, WM_DESTROY, 0, 0l ); + break; + } + break; + case WM_SIZE: + urd.cbSize=sizeof(urd); + urd.hwndDlg=hWnd; + urd.hInstance=hInst; + urd.lpTemplate=MAKEINTRESOURCE(IDD_CONNLIST); + urd.lParam=(LPARAM)NULL; + urd.pfnResizer=DlgResizer; + ResizeDialog(0,(LPARAM)&urd); + Utils_SaveWindowPosition(hWnd, NULL, ModuleName,"conn"); + return TRUE; + case WM_MOVE: + Utils_SaveWindowPosition(hWnd, NULL, ModuleName,"conn"); + break; + case WM_NOTIFY: + switch (((LPNMHDR) lParam)->code) + { + case LVN_GETDISPINFO: + OnGetDispInfo((NMLVDISPINFO *) lParam); + break; + } + break; + case WM_DESTROY: + del_all(&lst); + PostQuitMessage(0); + break; + default: + return FALSE; + } + return TRUE; +} + +void LogWumf(PWumf w) +{ + char str[256]; + LPTSTR lpstr; + char lpDateStr[20]; + char lpTimeStr[20]; + SYSTEMTIME time; + DWORD bytes; + + if(!WumfOptions.LogFolders && (w->dwAttr & FILE_ATTRIBUTE_DIRECTORY)) return; + + if(hLog == INVALID_HANDLE_VALUE || hLog == NULL) + { + hLog = CreateFile(WumfOptions.LogFile, + GENERIC_WRITE, + FILE_SHARE_READ, + (LPSECURITY_ATTRIBUTES) NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + (HANDLE) NULL); + if(hLog == INVALID_HANDLE_VALUE) + { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpstr, + 0, + NULL); + wsprintf(str, "Can't open log file %s\nError:%s", WumfOptions.LogFile, lpstr); + LocalFree(lpstr); + MessageBox( NULL, str, "Error opening file", MB_OK | MB_ICONSTOP); + WumfOptions.LogToFile = FALSE; + } + } + GetLocalTime(&time); + GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &time,NULL, lpDateStr, 20); + GetTimeFormat(LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER, &time,NULL, lpTimeStr, 20); + wsprintf(str ,"%s %s %20s\t%s\r\n\0",lpDateStr, lpTimeStr, w->szUser, w->szPath); + SetFilePointer (hLog, 0, NULL, FILE_END); + WriteFile(hLog, str, (DWORD)_tcslen(str), &bytes, NULL); +} + +/* +BOOL wumf() +{ + FILE_INFO_3 *buf, *cur; + SESSION_INFO_0 *sinfo; + DWORD read, total, resumeh, rc, i, sess = 0L; + wchar_t server[20]; + char user[512], path[512], comp[512]; + char* UNC = NULL; + PWumf w = NULL; + + mbstowcs( server, "\\\\.", 8); + resumeh = 0; + + mark_all(&list, TRUE); + do + { + buf = NULL; + rc = NetFileEnum( (LPWSTR)server, + NULL, + NULL, 3, + (BYTE **) &buf, 2048, &read, &total, &resumeh ); + if ( rc != ERROR_MORE_DATA && rc != ERROR_SUCCESS ) + break; + for ( i = 0, cur = buf; i < read; ++ i, ++ cur) + { + w = fnd_cell(&list, cur->fi3_id); + if(!w) + { + wcstombs(user, (wchar_t *) cur->fi3_username, 512); + wcstombs(path, (wchar_t *) cur->fi3_pathname, 512); + + w = new_wumf(cur->fi3_id, user, path, comp, UNC, sess, cur->fi3_permissions,GetFileAttributes(path)); + w->mark = FALSE; + if(!add_cell(&list, w)){ + msg("Error memory allocation"); + return FALSE; + }; + + if(WumfOptions.PopupsEnabled) ShowWumfPopUp(w); + if(WumfOptions.LogToFile) LogWumf(w); + } + else + w->mark = FALSE; + } + if(buf != NULL) NetApiBufferFree( buf ); + } while(rc == ERROR_MORE_DATA); + return del_marked(&list); +};*/ + +BOOL wumf() +{ + LPSESSION_INFO_1 s_info = NULL; + DWORD ent_read = 0, ent_total = 0, res_handle = 0, i = 0; + NET_API_STATUS res = NERR_Success; + if( (res = NetSessionEnum(NULL, NULL, NULL, 1, (LPBYTE *)&s_info, MAX_PREFERRED_LENGTH, &ent_read, &ent_total, &res_handle)) == NERR_Success || + res == ERROR_MORE_DATA) + { + mark_all(&list, TRUE); + for(i = 0; i < ent_read; i++) + { + process_session(s_info[ i ]); + } + NetApiBufferFree(s_info); + } else { + printError(res); + } + return del_marked(&list); +}; + +void process_session(SESSION_INFO_1 s_info) +{ + LPFILE_INFO_3 f_info = NULL; + DWORD ent_read = 0, ent_total = 0, res_handle = 0, i = 0; + NET_API_STATUS res = NERR_Success; + if( (res = NetFileEnum(NULL, NULL, s_info.sesi1_username, 3, (LPBYTE *)&f_info, MAX_PREFERRED_LENGTH, &ent_read, &ent_total, &res_handle)) == NERR_Success || + res == ERROR_MORE_DATA) + { + for(i = 0; i < ent_read; i++) + { + process_file(s_info, f_info[ i ]); + } + NetApiBufferFree(f_info); + } else { + printError(res); + } +} + +void process_file(SESSION_INFO_1 s_info, FILE_INFO_3 f_info) +{ + PWumf w = fnd_cell(&list, f_info.fi3_id); + if(!w) + { + w = new_wumf(f_info.fi3_id, f_info.fi3_username, f_info.fi3_pathname, s_info.sesi1_cname, NULL, 0, f_info.fi3_permissions, GetFileAttributes(f_info.fi3_pathname)); + w->mark = FALSE; + if(!add_cell(&list, w)){ + msg("Error memory allocation"); + }; + if(WumfOptions.PopupsEnabled) ShowWumfPopUp(w); + if(WumfOptions.LogToFile) LogWumf(w); + } else { + w->mark = FALSE; + } +} + +void printError(DWORD res) +{ + LPVOID lpMsgBuf; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, res, 0, (LPTSTR) &lpMsgBuf, 0, NULL ); + OutputDebugString(lpMsgBuf); + msg(lpMsgBuf); + LocalFree( lpMsgBuf ); +} + +VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + if(!wumf()) + KillTimer(NULL, 777); +}; + +void FreeAll() +{ + del_all(&list); +}; diff --git a/plugins/WhoUsesMyFiles/src/wumf.h b/plugins/WhoUsesMyFiles/src/wumf.h new file mode 100644 index 0000000000..5535ae0c5f --- /dev/null +++ b/plugins/WhoUsesMyFiles/src/wumf.h @@ -0,0 +1,167 @@ +#define _CRT_SECURE_NO_WARNINGS + +#include +#include +#include +#include +#include + +#include "newpluginapi.h" +#include "m_system.h" +#include "m_options.h" +#include "m_langpack.h" +#include "m_clui.h" +#include "m_clist.h" +#include "m_database.h" +#include "m_utils.h" +#include "m_skin.h" +#include "m_popup.h" + +#include "m_toptoolbar.h" + +#include "resource.h" + +#define LIFETIME_MAX 60 +#define LIFETIME_MIN 1 +#define MAX_PATHNAME 512 +#define MAX_USERNAME 512 +#define TIME 500 + +#define POPUPS_ENABLED "1033" +#define DELAY_SEC "1026" +#define DELAY_SET "1049" +#define DELAY_INF "1050" +#define DELAY_DEF "1051" +#define COLOR_SET "1000" +#define COLOR_WIN "1001" +#define COLOR_DEF "1002" +#define COLOR_BACK "1003" +#define COLOR_TEXT "1004" +#define OPT_FILE "1006" +#define LOG_INTO_FILE "1054" +#define LOG_FOLDER "1055" +#define ALERT_FOLDER "1056" +#define LOG_UNC "1057" +#define ALERT_UNC "1058" +#define LOG_COMP "1059" +#define ALERT_COMP "1060" + +#define IDM_SETUP 0x0402 +#define IDM_ABOUT 0x0403 +#define IDM_SHOW 0x0405 +#define IDM_EXIT 0x0404 + +typedef struct +{ + BOOL PopupsEnabled; + + BOOL UseWinColor; + BOOL UseDefColor; + BOOL SelectColor; + COLORREF ColorText; + COLORREF ColorBack; + BOOL DelayInf; + BOOL DelayDef; + BOOL DelaySet; + int DelaySec; + + BOOL LogToFile; + BOOL LogFolders; + BOOL AlertFolders; + BOOL LogUNC; + BOOL AlertUNC; + BOOL LogComp; + BOOL AlertComp; + + char LogFile[255]; +} WUMF_OPTIONS; + +typedef struct _WUMF{ + DWORD dwID; + LPSTR szID; + LPSTR szUser; + LPSTR szPath; + LPSTR szComp; + LPSTR szUNC; + LPSTR szPerm; + DWORD dwSess; + DWORD dwLocks; + DWORD dwAttr; + DWORD dwPerm; + BOOL mark; + struct _WUMF* next; +} Wumf, *PWumf; + +PWumf new_wumf( + DWORD dwID, + LPSTR szUser, + LPSTR szPath, + LPSTR szComp, + LPSTR szUNC, + DWORD szSess, + DWORD dwPerm, + DWORD dwAttr); + +BOOL add_cell (PWumf* l, PWumf w); +BOOL del_cell (PWumf* l, PWumf w); +BOOL cpy_cell (PWumf* l, PWumf w); +PWumf fnd_cell (PWumf* l, DWORD dwID); +PWumf cpy_list (PWumf* l); +BOOL del_all (PWumf* l); +void mark_all (PWumf* l, BOOL mark); +BOOL del_marked(PWumf* l); + + + +void FreeAll(); +VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD); +int CALLBACK ConnDlgProc(HWND, UINT, WPARAM, LPARAM); +int ResizeDialog(WPARAM wParam,LPARAM lParam); + +void ShowThePopUp(PWumf w, LPSTR, LPSTR); +void ShowWumfPopUp(PWumf w); + +void process_session(SESSION_INFO_1 s_info); +void process_file(SESSION_INFO_1 s_info, FILE_INFO_3 f_info); +void printError(DWORD res); + +#define msg(X) MessageBox(NULL, X, "WUMF", MB_OK|MB_ICONSTOP) +#define MS_WUMF_SWITCHPOPUP "WUMF/SwitchPopup" +#define MS_WUMF_CONNECTIONSSHOW "WUMF/ShowConnections" + +#define malloc(size) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size) +#define free(something) HeapFree(GetProcessHeap(), 0, something) + +#ifndef RD_ANCHORX_CUSTOM +#define RD_ANCHORX_CUSTOM 0 //function did everything required to the x axis, do no more processing +#define RD_ANCHORX_LEFT 0 //move the control to keep it constant distance from the left edge of the dialog +#define RD_ANCHORX_RIGHT 1 //move the control to keep it constant distance from the right edge of the dialog +#define RD_ANCHORX_WIDTH 2 //size the control to keep it constant distance from both edges of the dialog +#define RD_ANCHORX_CENTRE 4 //move the control to keep it constant distance from the centre of the dialog +#define RD_ANCHORY_CUSTOM 0 +#define RD_ANCHORY_TOP 0 +#define RD_ANCHORY_BOTTOM 8 +#define RD_ANCHORY_HEIGHT 16 +#define RD_ANCHORY_CENTRE 32 + +typedef struct { + int cbSize; + UINT wId; //control ID + RECT rcItem; //original control rectangle, relative to dialog + //modify in-place to specify the new position + SIZE dlgOriginalSize; //size of dialog client area in template + SIZE dlgNewSize; //current size of dialog client area +} UTILRESIZECONTROL; + +typedef int (*DIALOGRESIZERPROC)(HWND hwndDlg,LPARAM lParam,UTILRESIZECONTROL *urc); + +typedef struct { + int cbSize; + HWND hwndDlg; + HINSTANCE hInstance; //module containing the dialog template + LPCTSTR lpTemplate; //dialog template + LPARAM lParam; //caller-defined + DIALOGRESIZERPROC pfnResizer; +} UTILRESIZEDIALOG; + +#endif diff --git a/plugins/WhoUsesMyFiles/src/wumfplug.c b/plugins/WhoUsesMyFiles/src/wumfplug.c new file mode 100644 index 0000000000..2493de584b --- /dev/null +++ b/plugins/WhoUsesMyFiles/src/wumfplug.c @@ -0,0 +1,634 @@ +#include "wumf.h" + +HINSTANCE hInst; +WUMF_OPTIONS WumfOptions = { 0 }; +const char ModuleName[] = "WUMF Plugin"; +HANDLE hMenuItem = 0; +extern HANDLE hLog; +static HWND hDlg; +static HANDLE hWumfBut; +extern PWumf list; +int hLangpack; + +static PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + "WUMF: Who Use My Files?", + PLUGIN_MAKE_VERSION(0,1,0,1), + "Scans for network users of your shared files and notify you with popups. Uses PopUps Interoperability by Luca Santarelli. PopUps plugin must be activated!", + "Nikolay Redko", + "nike000@users.sf.net", + "© 2003 Nike. Freeware. Please mail me all bugs & your suggestions.", + "http://nightly.miranda.im/", + UNICODE_AWARE, + // {80DCA515-973A-4A7E-8B85-5D8EC88FC5A7} + { 0x80dca515, 0x973a, 0x4a7e, { 0x8b, 0x85, 0x5d, 0x8e, 0xc8, 0x8f, 0xc5, 0xa7 } } +}; + +void LoadOptions() +{ + DBVARIANT dbv = { 0 }; + dbv.type = DBVT_ASCIIZ; + ZeroMemory(&WumfOptions, sizeof(WumfOptions)); + if (DBGetContactSetting(NULL, ModuleName, OPT_FILE, &dbv) == 0) + { + strncpy(WumfOptions.LogFile, dbv.pszVal, 255); + } + else + { + WumfOptions.LogFile[0] = '\0'; + }; + WumfOptions.PopupsEnabled = DBGetContactSettingByte(NULL,ModuleName, POPUPS_ENABLED, TRUE); + + WumfOptions.UseDefColor = DBGetContactSettingByte(NULL,ModuleName, COLOR_DEF, TRUE); + WumfOptions.UseWinColor = DBGetContactSettingByte(NULL,ModuleName, COLOR_WIN, FALSE); + WumfOptions.SelectColor = DBGetContactSettingByte(NULL,ModuleName, COLOR_SET, FALSE); + + WumfOptions.ColorText = DBGetContactSettingDword(NULL,ModuleName, COLOR_TEXT, RGB(0,0,0)); + WumfOptions.ColorBack = DBGetContactSettingDword(NULL,ModuleName, COLOR_BACK, RGB(255,255,255)); + + WumfOptions.DelayDef = DBGetContactSettingByte(NULL,ModuleName, DELAY_DEF, TRUE); + WumfOptions.DelayInf = DBGetContactSettingByte(NULL,ModuleName, DELAY_INF, FALSE); + WumfOptions.DelaySet = DBGetContactSettingByte(NULL,ModuleName, DELAY_SET, FALSE); + WumfOptions.DelaySec = DBGetContactSettingByte(NULL,ModuleName, DELAY_SEC, 0); + if(!ServiceExists(MS_POPUP_ADDPOPUPEX)) + { + WumfOptions.DelayDef = TRUE; + WumfOptions.DelaySet = FALSE; + WumfOptions.DelayInf = FALSE; + } + WumfOptions.LogToFile = DBGetContactSettingByte(NULL,ModuleName, LOG_INTO_FILE, FALSE); + WumfOptions.LogFolders = DBGetContactSettingByte(NULL,ModuleName, LOG_FOLDER, TRUE); + WumfOptions.AlertFolders = DBGetContactSettingByte(NULL,ModuleName, ALERT_FOLDER, TRUE); + WumfOptions.LogUNC = DBGetContactSettingByte(NULL,ModuleName, LOG_UNC, FALSE); + WumfOptions.AlertUNC = DBGetContactSettingByte(NULL,ModuleName, ALERT_UNC, FALSE); + WumfOptions.LogComp = DBGetContactSettingByte(NULL,ModuleName, LOG_COMP, FALSE); + WumfOptions.AlertComp = DBGetContactSettingByte(NULL,ModuleName, ALERT_COMP, FALSE); + return; +} + + +void ExecuteMenu(HWND hWnd) +{ + HMENU hMenu; + POINT point; + + hMenu=CreatePopupMenu(); + if(!hMenu) + { + MessageBox(NULL, "Error crerating menu", "WUMF",MB_OK); + return; + }; + AppendMenu(hMenu,MF_STRING,IDM_ABOUT, "About\0"); + AppendMenu(hMenu,MF_SEPARATOR,0,NULL);//------------------ + AppendMenu(hMenu,MF_STRING,IDM_SHOW, "Show connections\0"); + AppendMenu(hMenu,MF_SEPARATOR,0,NULL);//------------------ + AppendMenu(hMenu,MF_STRING,IDM_EXIT, "Dismiss popup\0"); + + GetCursorPos (&point); + SetForegroundWindow (hWnd); + + TrackPopupMenu (hMenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RIGHTALIGN | TPM_TOPALIGN, + point.x, point.y, 0, hWnd, NULL); + + PostMessage (hWnd, WM_USER, 0, 0); + DestroyMenu(hMenu); +} + +static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ +// PWumf w = NULL; + switch(message) { + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDM_ABOUT: + break; + case IDM_EXIT: + PUDeletePopUp(hWnd); + break; + case IDM_SHOW: + CallService(MS_WUMF_CONNECTIONSSHOW, (WPARAM)0, (LPARAM)0); + return TRUE; + } + switch (HIWORD(wParam)) + { + case STN_CLICKED: + PUDeletePopUp(hWnd); + return TRUE; + } + break; + case WM_CONTEXTMENU: +// ExecuteMenu(hWnd); + CallService(MS_WUMF_CONNECTIONSSHOW, (WPARAM)0, (LPARAM)0); + break; + case UM_FREEPLUGINDATA: { +/* w = (PWumf)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)w); + if(w) free(w);*/ + return TRUE; //TRUE or FALSE is the same, it gets ignored. + } + default: + break; + } + return DefWindowProc(hWnd, message, wParam, lParam); +}; + +void ShowWumfPopUp(PWumf w) +{ + char text[512], title[512]; + + if(!WumfOptions.AlertFolders && (w->dwAttr & FILE_ATTRIBUTE_DIRECTORY)) return; + mir_snprintf(title, sizeof(title)/sizeof(title[0]), "%s (%s)", w->szComp, w->szUser); + mir_snprintf(text, sizeof(text)/sizeof(text[0]), "%s (%s)", w->szPath, w->szPerm); + ShowThePopUp(w, title, text); +} +void ShowThePopUp(PWumf w, LPSTR title, LPSTR text) +{ + POPUPDATAEX ppd = { 0 }; + COLORREF colorBack; + COLORREF colorText; + + colorBack = GetSysColor(COLOR_BTNFACE); + colorText = RGB(0,0,0); + + ppd.lchContact = NULL; + ppd.lchIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_DRIVE)); + ppd.iSeconds = -1; + + if(WumfOptions.DelayInf) + { + ppd.iSeconds = -1; + } + else if(WumfOptions.DelayDef) + { + ppd.iSeconds = 0; + } + else if(WumfOptions.DelaySet) + { + ppd.iSeconds = WumfOptions.DelaySec; + } + + lstrcpyn(ppd.lpzContactName, title, 128); + lstrcpyn(ppd.lpzText, text, 128); + if(WumfOptions.UseWinColor) + { + ppd.colorBack = GetSysColor(COLOR_WINDOW); + ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); + } + else if(WumfOptions.UseDefColor) + { + ppd.colorBack = 0L; + ppd.colorText = 0L; + } + else if(WumfOptions.SelectColor) + { + ppd.colorBack = WumfOptions.ColorBack; + ppd.colorText = WumfOptions.ColorText; + } + + ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; + ppd.PluginData = w; + if(CALLSERVICE_NOTFOUND == CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0)) + CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0); +} + +void ShowThePreview() +{ + if(!ServiceExists(MS_POPUP_ADDPOPUP)) + { + MessageBox(NULL,"PopUp plugin not found!", "WUMF plugin", MB_OK|MB_ICONSTOP); + return; + }; + if(WumfOptions.AlertFolders) + { + ShowThePopUp(NULL, "Guest", "C:\\My Share"); + Sleep(300); + ShowThePopUp(NULL, "Guest", "C:\\My Share\\Photos"); + Sleep(300); + } + ShowThePopUp(NULL, "Guest", "C:\\Share\\My Photos\\photo.jpg"); + Sleep(300); + if(WumfOptions.AlertFolders) + { + ShowThePopUp(NULL, "User", "C:\\My Share"); + Sleep(300); + ShowThePopUp(NULL, "User", "C:\\My Share\\Movies"); + Sleep(300); + } + ShowThePopUp(NULL, "User", "C:\\My Share\\Movies\\The Two Towers.avi"); + Sleep(300); + if(WumfOptions.AlertFolders) + { + ShowThePopUp(NULL, "Administrator", "C:\\Distributives"); + Sleep(300); + ShowThePopUp(NULL, "Administrator", "C:\\Distributives\\Win2k"); + Sleep(300); + } + ShowThePopUp(NULL, "Administrator", "C:\\Distributives\\Win2k\\setup.exe"); +}; + + + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + return TRUE; +} + +DWORD WINAPI ThreadProc(LPVOID lpParameter) +{ + MSG msg; //Message pump. + if(hDlg) + { + ShowWindow(hDlg, SW_SHOWNORMAL); + SetForegroundWindow(hDlg); + return (int)(1); + } + hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_CONNLIST), NULL, (DLGPROC)ConnDlgProc); + SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(IDI_DRIVE))); + ShowWindow(hDlg, SW_SHOW); + while(GetMessage(&msg, NULL, 0, 0) == TRUE) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + hDlg = NULL; + ExitThread(0); + + return (int)(1); +} + + +static INT_PTR WumfShowConnections(WPARAM wParam,LPARAM lParam) +{ + DWORD threadID = 0; + CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, (LPVOID)NULL,0,&threadID)); + Sleep(100); + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hWumfBut, TTBST_RELEASED); + return 0; +} + +static INT_PTR WumfMenuCommand(WPARAM wParam,LPARAM lParam) +{ + BOOL MajorTo0121 = FALSE; + int iResult = 0; + CLISTMENUITEM mi = { 0 }; + + mi.cbSize = sizeof(mi); + if (WumfOptions.PopupsEnabled == TRUE) + { + WumfOptions.PopupsEnabled = FALSE; + mi.pszName = Translate("Enable WUMF popups"); + mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NOPOPUP)); + } + else + { + WumfOptions.PopupsEnabled = TRUE; + mi.pszName = Translate("Disable WUMF popups"); + mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_POPUP)); + } + DBWriteContactSettingByte(NULL, ModuleName, POPUPS_ENABLED, (BYTE)WumfOptions.PopupsEnabled); + mi.flags = CMIM_NAME | CMIM_ICON; + iResult = CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hMenuItem,(LPARAM)&mi); + return iResult; +} + +__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +void DisableDelayOptions(HWND hwndDlg) +{ + CheckDlgButton(hwndDlg, IDC_DELAY_INF,BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DELAY_SET,BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DELAY_DEF,BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_INF), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SET), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_DEF), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_TX_DELAY_SEC), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_NOTE), TRUE); +} +void ChooseFile(HWND hDlg) +{ + OPENFILENAME ofn; // common dialog box structure + char szFile[260]; // buffer for filename + HANDLE hf; // file handle + // Initialize OPENFILENAME + ZeroMemory(&ofn, sizeof(OPENFILENAME)); + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner =hDlg; + szFile[0]=0; + ofn.lpstrFile = szFile; + ofn.nMaxFile = 260; + ofn.lpstrFilter = "All files (*.*)\0*.*\0Text files (*.txt)\0*.txt\0Log files (*.log)\0*.log\0\0"; + ofn.nFilterIndex = 2; + ofn.lpstrFileTitle = NULL; + ofn.nMaxFileTitle = 0; + ofn.lpstrInitialDir = NULL; + ofn.Flags = OFN_CREATEPROMPT; + // Display the Open dialog box. + if (GetSaveFileName(&ofn)==TRUE) + { + hf = CreateFile(ofn.lpstrFile, + GENERIC_WRITE, + 0, + (LPSECURITY_ATTRIBUTES) NULL, + OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + (HANDLE) NULL); + if(hf!=INVALID_HANDLE_VALUE) + { + SetDlgItemText(hDlg,IDC_FILE,ofn.lpstrFile); + lstrcpyn(WumfOptions.LogFile, ofn.lpstrFile, 255); + CloseHandle(hf); + } + } + else if(CommDlgExtendedError()!=0L) + { + char str[256]; + wsprintf(str,"Common Dialog Error 0x%lx",CommDlgExtendedError()); + MessageBox(hDlg,str,"Wumf plugin",MB_OK|MB_ICONSTOP); + }; + +}; + +INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wparam,LPARAM lparam) +{ + WORD wControlId = LOWORD(wparam); + WORD wNotifyCode = HIWORD(wparam); + int seconds; + + switch(msg) + { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + CheckDlgButton(hwndDlg, IDC_COLOR_WIN, WumfOptions.UseWinColor?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_COLOR_DEF, WumfOptions.UseDefColor?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_COLOR_SET, WumfOptions.SelectColor?BST_CHECKED:BST_UNCHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BACK), WumfOptions.SelectColor); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_TEXT), WumfOptions.SelectColor); + if(WumfOptions.SelectColor) + { + SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_SETCOLOUR,0,WumfOptions.ColorBack); + SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_SETCOLOUR,0,WumfOptions.ColorText); + } + if(!ServiceExists(MS_POPUP_ADDPOPUPEX)) + { + DisableDelayOptions(hwndDlg); + break; + } + CheckDlgButton(hwndDlg, IDC_DELAY_INF, WumfOptions.DelayInf?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DELAY_DEF, WumfOptions.DelayDef?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DELAY_SET, WumfOptions.DelaySet?BST_CHECKED:BST_UNCHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), WumfOptions.DelaySet); + SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, FALSE); + //Logging & alerts + CheckDlgButton(hwndDlg, IDC_LOG_FOLDER, WumfOptions.LogFolders?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ALERT_FOLDER, WumfOptions.AlertFolders?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_LOG_UNC, WumfOptions.LogUNC?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ALERT_UNC, WumfOptions.AlertUNC?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_LOG_COMP, WumfOptions.LogComp?BST_CHECKED:BST_UNCHECKED); + + if(WumfOptions.LogToFile) + { + CheckDlgButton(hwndDlg,IDC_LOG_INTO_FILE,BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), TRUE); + SetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile); + } + else + { + CheckDlgButton(hwndDlg,IDC_LOG_INTO_FILE,BST_UNCHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), FALSE); + SetDlgItemText(hwndDlg,IDC_FILE,""); + }; + + break; + case WM_COMMAND: + switch(wNotifyCode) + { + case BN_CLICKED : + switch(wControlId) + { + case IDC_DELAY_SET: + case IDC_DELAY_DEF: + case IDC_DELAY_INF: + WumfOptions.DelaySet = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_SET) == BST_CHECKED); + WumfOptions.DelayDef = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_DEF) == BST_CHECKED); + WumfOptions.DelayInf = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_INF) == BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), WumfOptions.DelaySet); + SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, TRUE); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_COLOR_SET: + case IDC_COLOR_DEF: + case IDC_COLOR_WIN: + WumfOptions.SelectColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_SET) == BST_CHECKED); + WumfOptions.UseDefColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_DEF) == BST_CHECKED); + WumfOptions.UseWinColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_WIN) == BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BACK),WumfOptions.SelectColor); + EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_TEXT), WumfOptions.SelectColor); + SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_SETCOLOUR,0,WumfOptions.ColorBack); + SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_SETCOLOUR,0,WumfOptions.ColorText); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + /* not implemented */ + case IDC_LOG_COMP: + case IDC_ALERT_COMP: + case IDC_LOG_UNC: + case IDC_ALERT_UNC: + MessageBox(NULL, "Not implemented yet...", "WUMF", MB_OK|MB_ICONINFORMATION); + break; + /* end */ + case IDC_LOG_INTO_FILE: + WumfOptions.LogToFile = (IsDlgButtonChecked(hwndDlg, IDC_LOG_INTO_FILE) == BST_CHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), WumfOptions.LogToFile); + EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), WumfOptions.LogToFile); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_SEL_FILE: + ChooseFile(hwndDlg); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_LOG_FOLDER: + WumfOptions.LogFolders = (IsDlgButtonChecked(hwndDlg, IDC_LOG_FOLDER) == BST_CHECKED); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_ALERT_FOLDER: + WumfOptions.AlertFolders = (IsDlgButtonChecked(hwndDlg, IDC_ALERT_FOLDER) == BST_CHECKED); + break; +/* case IDC_LOG_COMP: + WumfOptions.LogComp = (IsDlgButtonChecked(hwndDlg, IDC_LOG_COMP) == BST_CHECKED); + break; + case IDC_ALERT_COMP: + WumfOptions.AlertComp = (IsDlgButtonChecked(hwndDlg, IDC_ALERT_COMP) == BST_CHECKED); + break; + case IDC_LOG_UNC: + WumfOptions.LogUNC = (IsDlgButtonChecked(hwndDlg, IDC_LOG_UNC) == BST_CHECKED); + break; + case IDC_ALERT_UNC: + WumfOptions.AlertUNC = (IsDlgButtonChecked(hwndDlg, IDC_ALERT_UNC) == BST_CHECKED); + break; +*/ case IDC_PREVIEW: + ShowThePreview(); + break; + case IDC_CONN: + CallService(MS_WUMF_CONNECTIONSSHOW, (WPARAM)0, (LPARAM)0); + break; + } + break; + case CPN_COLOURCHANGED: + WumfOptions.ColorText = SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_GETCOLOUR,0,0); + WumfOptions.ColorBack = SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_GETCOLOUR,0,0); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case EN_CHANGE: + switch(wControlId) + { + case IDC_DELAY_SEC: + seconds = GetDlgItemInt(hwndDlg, IDC_DELAY_SEC, NULL, FALSE); + if (seconds > LIFETIME_MAX) + WumfOptions.DelaySec = LIFETIME_MAX; + else if (seconds < LIFETIME_MIN) + WumfOptions.DelaySec = LIFETIME_MIN; + else if (seconds <= LIFETIME_MAX || seconds >= LIFETIME_MIN) + WumfOptions.DelaySec = seconds; + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_FILE: + GetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile, sizeof(WumfOptions.LogFile)); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + break; + case EN_KILLFOCUS: + switch(wControlId) + { + case IDC_DELAY_SEC: + SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, FALSE); + break; + }; + break; + } + break; + case WM_NOTIFY: + switch(((LPNMHDR)lparam)->idFrom) { + case 0: + switch (((LPNMHDR)lparam)->code) { + case PSN_RESET: + LoadOptions(); + return TRUE; + case PSN_APPLY: + DBWriteContactSettingByte(NULL,ModuleName, COLOR_DEF, (BYTE)WumfOptions.UseDefColor); + DBWriteContactSettingByte(NULL,ModuleName, COLOR_WIN, (BYTE)WumfOptions.UseWinColor); + DBWriteContactSettingByte(NULL,ModuleName, COLOR_SET, (BYTE)WumfOptions.SelectColor ); + DBWriteContactSettingDword(NULL,ModuleName, COLOR_TEXT, (DWORD)WumfOptions.ColorText); + DBWriteContactSettingDword(NULL,ModuleName, COLOR_BACK, (DWORD)WumfOptions.ColorBack); + DBWriteContactSettingByte(NULL,ModuleName, DELAY_DEF, (BYTE)WumfOptions.DelayDef); + DBWriteContactSettingByte(NULL,ModuleName, DELAY_INF, (BYTE)WumfOptions.DelayInf); + DBWriteContactSettingByte(NULL,ModuleName, DELAY_SET, (BYTE)WumfOptions.DelaySet); + DBWriteContactSettingByte(NULL,ModuleName, DELAY_SEC, (BYTE)WumfOptions.DelaySec); + DBWriteContactSettingByte(NULL,ModuleName, LOG_INTO_FILE, (BYTE)WumfOptions.LogToFile); + DBWriteContactSettingByte(NULL,ModuleName, LOG_FOLDER, (BYTE)WumfOptions.LogFolders); + DBWriteContactSettingByte(NULL,ModuleName, ALERT_FOLDER, (BYTE)WumfOptions.AlertFolders); + DBWriteContactSettingByte(NULL,ModuleName, LOG_UNC, (BYTE)WumfOptions.LogUNC); + DBWriteContactSettingByte(NULL,ModuleName, ALERT_UNC, (BYTE)WumfOptions.AlertUNC); + DBWriteContactSettingByte(NULL,ModuleName, LOG_COMP, (BYTE)WumfOptions.LogComp); + DBWriteContactSettingByte(NULL,ModuleName, ALERT_COMP, (BYTE)WumfOptions.AlertComp); + GetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile, 255); + DBWriteContactSettingString(NULL,ModuleName, OPT_FILE, WumfOptions.LogFile); + break; + } + break; + } + break; + } + return 0; +} + +int InitTopToolbar(WPARAM wparam,LPARAM lparam) +{ + TTBButton ttb = { 0 }; + ttb.cbSize = sizeof(ttb); + ttb.hIconUp = LoadIcon(hInst, MAKEINTRESOURCE(IDI_DRIVE)); + ttb.pszService = MS_WUMF_CONNECTIONSSHOW; + ttb.dwFlags = TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP; + ttb.name = ttb.pszTooltipUp = LPGEN("Show connections list"); + hWumfBut = TopToolbar_AddButton(&ttb); + return 0; +} + +int OptionsInit(WPARAM wparam,LPARAM lparam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + + + odp.cbSize=sizeof(odp); + odp.position=945000000; + odp.hInstance=hInst; + odp.pszTemplate=MAKEINTRESOURCE(IDD_OPTIONS); + odp.pszTitle="Wumf"; + odp.pfnDlgProc=OptionsDlgProc; + odp.pszGroup=Translate("Plugins"); + odp.flags=ODPF_BOLDGROUPS; + Options_AddPage(wparam, &odp); + return 0; +} + +__declspec(dllexport) int Load(void) +{ + CLISTMENUITEM mi = { 0 }; + + mir_getLP(&pluginInfo); + + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + LoadOptions(); + + CreateServiceFunction(MS_WUMF_SWITCHPOPUP, WumfMenuCommand); + CreateServiceFunction(MS_WUMF_CONNECTIONSSHOW, WumfShowConnections); + if (WumfOptions.PopupsEnabled == FALSE) + { + mi.pszName = Translate("Enable WUMF popups"); + mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NOPOPUP)); + } + else + { + mi.pszName = Translate("Disable WUMF popups"); + mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_POPUP)); + } + mi.pszService = MS_WUMF_SWITCHPOPUP; + mi.popupPosition = 1999990000; + mi.pszPopupName = Translate("PopUps"); + hMenuItem = (HANDLE)Menu_AddMainMenuItem(&mi); + + mi.pszName = Translate("WUMF: Show connections"); + mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_DRIVE)); + mi.pszService = MS_WUMF_CONNECTIONSSHOW; + mi.popupPosition = 1999990000; + mi.pszPopupName = NULL; + Menu_AddMainMenuItem(&mi); + + HookEvent(ME_OPT_INITIALISE,OptionsInit); + HookEvent(ME_TTB_MODULELOADED, InitTopToolbar); + setlocale( LC_ALL, ".ACP"); +// _setmbcp(_MB_CP_ANSI); + + if (IsUserAnAdmin()) { + SetTimer(NULL, 777, TIME,(TIMERPROC) TimerProc); + } else { + MessageBox(NULL, "Plugin WhoUsesMyFiles requires admin privileges in order to work.", "Miranda IM", MB_OK); + } + + return 0; +} + +__declspec(dllexport) int Unload(void) +{ + KillTimer(NULL, 777); + CloseHandle(hLog); + FreeAll(); + return 0; +} \ No newline at end of file diff --git a/plugins/WhoUsesMyFiles/wumf.c b/plugins/WhoUsesMyFiles/wumf.c deleted file mode 100644 index 03aa576d38..0000000000 --- a/plugins/WhoUsesMyFiles/wumf.c +++ /dev/null @@ -1,330 +0,0 @@ -#define MAX_CHARS 4096 -#define WS_WINDOW_STYLE WS_OVERLAPPED -#define NAME "WUMF" -#define WM_MYCMD 0x0401 - -#include "wumf.h" -static PWumf list = NULL; -static PWumf lst = NULL; - -extern WUMF_OPTIONS WumfOptions; -extern HANDLE hInst; -extern HWND hDlg; -extern char ModuleName[]; - -HANDLE hLog = INVALID_HANDLE_VALUE; -BOOL wumf(); - -static int DlgResizer(HWND hwndDlg,LPARAM lParam,UTILRESIZECONTROL *urc) { - switch(urc->wId) { - case IDC_CONNLIST: - return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; - case IDOK: - return RD_ANCHORX_RIGHT|RD_ANCHORY_BOTTOM; - } - return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; -} - - - -void AddToList(HWND hList, PWumf w) -{ - LVITEM lvi = { 0 }; - lvi.iItem=ListView_GetItemCount(hList)+1; - lvi.mask= LVIF_PARAM|LVIF_TEXT; - lvi.pszText = w->szID; - lvi.cchTextMax = (int)_tcslen(w->szID); - lvi.lParam = (LPARAM)w; - ListView_InsertItem(hList,&lvi); -} - -void ShowList(PWumf l, HWND hList) -{ - PWumf w; - w = l; - while(w) - { - AddToList(hList,w); - w = w->next; - } -} - -VOID OnGetDispInfo(NMLVDISPINFO *plvdi) -{ - PWumf w; - w = (PWumf)(plvdi->item.lParam); - switch (plvdi->item.iSubItem) - { - case 0: - plvdi->item.pszText = w->szID; - break; - case 1: - plvdi->item.pszText = w->szUser; - break; - case 2: - plvdi->item.pszText = w->szPath; - break; - case 3: - plvdi->item.pszText = w->szPerm; - break; - default: - break; - } -} - - -int CALLBACK ConnDlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) -{ - UTILRESIZEDIALOG urd={0}; - LV_COLUMN lvc = { 0 }; - char col0[] = "ID"; - char col1[] = "User"; - char col2[] = "File"; - char col3[] = "Access"; -// char buff[256]; - HWND hList; - switch( Msg ) - { - case WM_INITDIALOG: - hList = GetDlgItem(hWnd, IDC_CONNLIST); -// ListView_DeleteAllItems(hList); - ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT); - lvc.mask = LVCF_TEXT|LVCF_FMT|LVCF_WIDTH; - lvc.fmt = LVCFMT_LEFT; - lvc.cx = 40; - lvc.pszText = col0; - lvc.cchTextMax = sizeof(col0); - ListView_InsertColumn(hList, 0, &lvc); - lvc.cx = 50; - lvc.pszText = col1; - lvc.cchTextMax = sizeof(col1); - ListView_InsertColumn(hList, 1, &lvc); - lvc.cx = 250; - lvc.pszText = col2; - lvc.cchTextMax = sizeof(col2); - ListView_InsertColumn(hList, 2, &lvc); - lvc.cx = 50; - lvc.pszText = col3; - lvc.cchTextMax = sizeof(col3); - ListView_InsertColumn(hList, 3, &lvc); - KillTimer(NULL, 777); - lst = cpy_list(&list); - if (IsUserAnAdmin()) { - SetTimer(NULL, 777, TIME,(TIMERPROC) TimerProc); - } else { - MessageBox(NULL, "Plugin WhoUsesMyFiles requires admin privileges in order to work.", "Miranda IM", MB_OK); - } - ShowList(lst, hList); - Utils_RestoreWindowPosition(hWnd, NULL, ModuleName,"conn"); - break; - case WM_CLOSE: - PostMessage( hWnd, WM_COMMAND, IDCANCEL, 0l ); - break; - case WM_COMMAND: - switch( LOWORD(wParam) ) - { - case IDOK: - case IDCANCEL: - PostMessage( hWnd, WM_DESTROY, 0, 0l ); - break; - } - break; - case WM_SIZE: - urd.cbSize=sizeof(urd); - urd.hwndDlg=hWnd; - urd.hInstance=hInst; - urd.lpTemplate=MAKEINTRESOURCE(IDD_CONNLIST); - urd.lParam=(LPARAM)NULL; - urd.pfnResizer=DlgResizer; - ResizeDialog(0,(LPARAM)&urd); - Utils_SaveWindowPosition(hWnd, NULL, ModuleName,"conn"); - return TRUE; - case WM_MOVE: - Utils_SaveWindowPosition(hWnd, NULL, ModuleName,"conn"); - break; - case WM_NOTIFY: - switch (((LPNMHDR) lParam)->code) - { - case LVN_GETDISPINFO: - OnGetDispInfo((NMLVDISPINFO *) lParam); - break; - } - break; - case WM_DESTROY: - del_all(&lst); - PostQuitMessage(0); - break; - default: - return FALSE; - } - return TRUE; -} - -void LogWumf(PWumf w) -{ - char str[256]; - LPTSTR lpstr; - char lpDateStr[20]; - char lpTimeStr[20]; - SYSTEMTIME time; - DWORD bytes; - - if(!WumfOptions.LogFolders && (w->dwAttr & FILE_ATTRIBUTE_DIRECTORY)) return; - - if(hLog == INVALID_HANDLE_VALUE || hLog == NULL) - { - hLog = CreateFile(WumfOptions.LogFile, - GENERIC_WRITE, - FILE_SHARE_READ, - (LPSECURITY_ATTRIBUTES) NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - (HANDLE) NULL); - if(hLog == INVALID_HANDLE_VALUE) - { - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpstr, - 0, - NULL); - wsprintf(str, "Can't open log file %s\nError:%s", WumfOptions.LogFile, lpstr); - LocalFree(lpstr); - MessageBox( NULL, str, "Error opening file", MB_OK | MB_ICONSTOP); - WumfOptions.LogToFile = FALSE; - } - } - GetLocalTime(&time); - GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE, &time,NULL, lpDateStr, 20); - GetTimeFormat(LOCALE_USER_DEFAULT,TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER, &time,NULL, lpTimeStr, 20); - wsprintf(str ,"%s %s %20s\t%s\r\n\0",lpDateStr, lpTimeStr, w->szUser, w->szPath); - SetFilePointer (hLog, 0, NULL, FILE_END); - WriteFile(hLog, str, (DWORD)_tcslen(str), &bytes, NULL); -} - -/* -BOOL wumf() -{ - FILE_INFO_3 *buf, *cur; - SESSION_INFO_0 *sinfo; - DWORD read, total, resumeh, rc, i, sess = 0L; - wchar_t server[20]; - char user[512], path[512], comp[512]; - char* UNC = NULL; - PWumf w = NULL; - - mbstowcs( server, "\\\\.", 8); - resumeh = 0; - - mark_all(&list, TRUE); - do - { - buf = NULL; - rc = NetFileEnum( (LPWSTR)server, - NULL, - NULL, 3, - (BYTE **) &buf, 2048, &read, &total, &resumeh ); - if ( rc != ERROR_MORE_DATA && rc != ERROR_SUCCESS ) - break; - for ( i = 0, cur = buf; i < read; ++ i, ++ cur) - { - w = fnd_cell(&list, cur->fi3_id); - if(!w) - { - wcstombs(user, (wchar_t *) cur->fi3_username, 512); - wcstombs(path, (wchar_t *) cur->fi3_pathname, 512); - - w = new_wumf(cur->fi3_id, user, path, comp, UNC, sess, cur->fi3_permissions,GetFileAttributes(path)); - w->mark = FALSE; - if(!add_cell(&list, w)){ - msg("Error memory allocation"); - return FALSE; - }; - - if(WumfOptions.PopupsEnabled) ShowWumfPopUp(w); - if(WumfOptions.LogToFile) LogWumf(w); - } - else - w->mark = FALSE; - } - if(buf != NULL) NetApiBufferFree( buf ); - } while(rc == ERROR_MORE_DATA); - return del_marked(&list); -};*/ - -BOOL wumf() -{ - LPSESSION_INFO_1 s_info = NULL; - DWORD ent_read = 0, ent_total = 0, res_handle = 0, i = 0; - NET_API_STATUS res = NERR_Success; - if( (res = NetSessionEnum(NULL, NULL, NULL, 1, (LPBYTE *)&s_info, MAX_PREFERRED_LENGTH, &ent_read, &ent_total, &res_handle)) == NERR_Success || - res == ERROR_MORE_DATA) - { - mark_all(&list, TRUE); - for(i = 0; i < ent_read; i++) - { - process_session(s_info[ i ]); - } - NetApiBufferFree(s_info); - } else { - printError(res); - } - return del_marked(&list); -}; - -void process_session(SESSION_INFO_1 s_info) -{ - LPFILE_INFO_3 f_info = NULL; - DWORD ent_read = 0, ent_total = 0, res_handle = 0, i = 0; - NET_API_STATUS res = NERR_Success; - if( (res = NetFileEnum(NULL, NULL, s_info.sesi1_username, 3, (LPBYTE *)&f_info, MAX_PREFERRED_LENGTH, &ent_read, &ent_total, &res_handle)) == NERR_Success || - res == ERROR_MORE_DATA) - { - for(i = 0; i < ent_read; i++) - { - process_file(s_info, f_info[ i ]); - } - NetApiBufferFree(f_info); - } else { - printError(res); - } -} - -void process_file(SESSION_INFO_1 s_info, FILE_INFO_3 f_info) -{ - PWumf w = fnd_cell(&list, f_info.fi3_id); - if(!w) - { - w = new_wumf(f_info.fi3_id, f_info.fi3_username, f_info.fi3_pathname, s_info.sesi1_cname, NULL, 0, f_info.fi3_permissions, GetFileAttributes(f_info.fi3_pathname)); - w->mark = FALSE; - if(!add_cell(&list, w)){ - msg("Error memory allocation"); - }; - if(WumfOptions.PopupsEnabled) ShowWumfPopUp(w); - if(WumfOptions.LogToFile) LogWumf(w); - } else { - w->mark = FALSE; - } -} - -void printError(DWORD res) -{ - LPVOID lpMsgBuf; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, res, 0, (LPTSTR) &lpMsgBuf, 0, NULL ); - OutputDebugString(lpMsgBuf); - msg(lpMsgBuf); - LocalFree( lpMsgBuf ); -} - -VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) -{ - if(!wumf()) - KillTimer(NULL, 777); -}; - -void FreeAll() -{ - del_all(&list); -}; diff --git a/plugins/WhoUsesMyFiles/wumf.h b/plugins/WhoUsesMyFiles/wumf.h deleted file mode 100644 index 5535ae0c5f..0000000000 --- a/plugins/WhoUsesMyFiles/wumf.h +++ /dev/null @@ -1,167 +0,0 @@ -#define _CRT_SECURE_NO_WARNINGS - -#include -#include -#include -#include -#include - -#include "newpluginapi.h" -#include "m_system.h" -#include "m_options.h" -#include "m_langpack.h" -#include "m_clui.h" -#include "m_clist.h" -#include "m_database.h" -#include "m_utils.h" -#include "m_skin.h" -#include "m_popup.h" - -#include "m_toptoolbar.h" - -#include "resource.h" - -#define LIFETIME_MAX 60 -#define LIFETIME_MIN 1 -#define MAX_PATHNAME 512 -#define MAX_USERNAME 512 -#define TIME 500 - -#define POPUPS_ENABLED "1033" -#define DELAY_SEC "1026" -#define DELAY_SET "1049" -#define DELAY_INF "1050" -#define DELAY_DEF "1051" -#define COLOR_SET "1000" -#define COLOR_WIN "1001" -#define COLOR_DEF "1002" -#define COLOR_BACK "1003" -#define COLOR_TEXT "1004" -#define OPT_FILE "1006" -#define LOG_INTO_FILE "1054" -#define LOG_FOLDER "1055" -#define ALERT_FOLDER "1056" -#define LOG_UNC "1057" -#define ALERT_UNC "1058" -#define LOG_COMP "1059" -#define ALERT_COMP "1060" - -#define IDM_SETUP 0x0402 -#define IDM_ABOUT 0x0403 -#define IDM_SHOW 0x0405 -#define IDM_EXIT 0x0404 - -typedef struct -{ - BOOL PopupsEnabled; - - BOOL UseWinColor; - BOOL UseDefColor; - BOOL SelectColor; - COLORREF ColorText; - COLORREF ColorBack; - BOOL DelayInf; - BOOL DelayDef; - BOOL DelaySet; - int DelaySec; - - BOOL LogToFile; - BOOL LogFolders; - BOOL AlertFolders; - BOOL LogUNC; - BOOL AlertUNC; - BOOL LogComp; - BOOL AlertComp; - - char LogFile[255]; -} WUMF_OPTIONS; - -typedef struct _WUMF{ - DWORD dwID; - LPSTR szID; - LPSTR szUser; - LPSTR szPath; - LPSTR szComp; - LPSTR szUNC; - LPSTR szPerm; - DWORD dwSess; - DWORD dwLocks; - DWORD dwAttr; - DWORD dwPerm; - BOOL mark; - struct _WUMF* next; -} Wumf, *PWumf; - -PWumf new_wumf( - DWORD dwID, - LPSTR szUser, - LPSTR szPath, - LPSTR szComp, - LPSTR szUNC, - DWORD szSess, - DWORD dwPerm, - DWORD dwAttr); - -BOOL add_cell (PWumf* l, PWumf w); -BOOL del_cell (PWumf* l, PWumf w); -BOOL cpy_cell (PWumf* l, PWumf w); -PWumf fnd_cell (PWumf* l, DWORD dwID); -PWumf cpy_list (PWumf* l); -BOOL del_all (PWumf* l); -void mark_all (PWumf* l, BOOL mark); -BOOL del_marked(PWumf* l); - - - -void FreeAll(); -VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD); -int CALLBACK ConnDlgProc(HWND, UINT, WPARAM, LPARAM); -int ResizeDialog(WPARAM wParam,LPARAM lParam); - -void ShowThePopUp(PWumf w, LPSTR, LPSTR); -void ShowWumfPopUp(PWumf w); - -void process_session(SESSION_INFO_1 s_info); -void process_file(SESSION_INFO_1 s_info, FILE_INFO_3 f_info); -void printError(DWORD res); - -#define msg(X) MessageBox(NULL, X, "WUMF", MB_OK|MB_ICONSTOP) -#define MS_WUMF_SWITCHPOPUP "WUMF/SwitchPopup" -#define MS_WUMF_CONNECTIONSSHOW "WUMF/ShowConnections" - -#define malloc(size) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size) -#define free(something) HeapFree(GetProcessHeap(), 0, something) - -#ifndef RD_ANCHORX_CUSTOM -#define RD_ANCHORX_CUSTOM 0 //function did everything required to the x axis, do no more processing -#define RD_ANCHORX_LEFT 0 //move the control to keep it constant distance from the left edge of the dialog -#define RD_ANCHORX_RIGHT 1 //move the control to keep it constant distance from the right edge of the dialog -#define RD_ANCHORX_WIDTH 2 //size the control to keep it constant distance from both edges of the dialog -#define RD_ANCHORX_CENTRE 4 //move the control to keep it constant distance from the centre of the dialog -#define RD_ANCHORY_CUSTOM 0 -#define RD_ANCHORY_TOP 0 -#define RD_ANCHORY_BOTTOM 8 -#define RD_ANCHORY_HEIGHT 16 -#define RD_ANCHORY_CENTRE 32 - -typedef struct { - int cbSize; - UINT wId; //control ID - RECT rcItem; //original control rectangle, relative to dialog - //modify in-place to specify the new position - SIZE dlgOriginalSize; //size of dialog client area in template - SIZE dlgNewSize; //current size of dialog client area -} UTILRESIZECONTROL; - -typedef int (*DIALOGRESIZERPROC)(HWND hwndDlg,LPARAM lParam,UTILRESIZECONTROL *urc); - -typedef struct { - int cbSize; - HWND hwndDlg; - HINSTANCE hInstance; //module containing the dialog template - LPCTSTR lpTemplate; //dialog template - LPARAM lParam; //caller-defined - DIALOGRESIZERPROC pfnResizer; -} UTILRESIZEDIALOG; - -#endif diff --git a/plugins/WhoUsesMyFiles/wumf.vcxproj b/plugins/WhoUsesMyFiles/wumf.vcxproj index c6044637fa..d798b606b5 100644 --- a/plugins/WhoUsesMyFiles/wumf.vcxproj +++ b/plugins/WhoUsesMyFiles/wumf.vcxproj @@ -155,8 +155,6 @@ Windows true true - - $(IntDir)$(TargetName).lib false $(SolutionDir)\lib @@ -167,17 +165,17 @@ - - + + - + - - - - + + + + diff --git a/plugins/WhoUsesMyFiles/wumf.vcxproj.filters b/plugins/WhoUsesMyFiles/wumf.vcxproj.filters index 923fdf838f..0715f41ff1 100644 --- a/plugins/WhoUsesMyFiles/wumf.vcxproj.filters +++ b/plugins/WhoUsesMyFiles/wumf.vcxproj.filters @@ -15,29 +15,29 @@ - + Header Files - + Header Files - + Resource Files - + Source Files - + Source Files - + Source Files - + Source Files diff --git a/plugins/WhoUsesMyFiles/wumfplug.c b/plugins/WhoUsesMyFiles/wumfplug.c deleted file mode 100644 index 0af8d6e817..0000000000 --- a/plugins/WhoUsesMyFiles/wumfplug.c +++ /dev/null @@ -1,634 +0,0 @@ -#include "wumf.h" - -HINSTANCE hInst; -WUMF_OPTIONS WumfOptions = { 0 }; -const char ModuleName[] = "WUMF Plugin"; -HANDLE hMenuItem = 0; -extern HANDLE hLog; -static HWND hDlg; -static HANDLE hWumfBut; -extern PWumf list; -int hLangpack; - -static PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - "WUMF: Who Use My Files?", - PLUGIN_MAKE_VERSION(0,1,0,1), - "Scans for network users of your shared files and notify you with popups. Uses PopUps Interoperability by Luca Santarelli. PopUps plugin must be activated!", - "Nikolay Redko", - "nike000@users.sf.net", - "© 2003 Nike. Freeware. Please mail me all bugs & your suggestions.", - "http://nightly.miranda.im/", - UNICODE_AWARE, - // {80DCA515-973A-4A7E-8B85-5D8EC88FC5A7} - { 0x80dca515, 0x973a, 0x4a7e, { 0x8b, 0x85, 0x5d, 0x8e, 0xc8, 0x8f, 0xc5, 0xa7 } } -}; - -void LoadOptions() -{ - DBVARIANT dbv = { 0 }; - dbv.type = DBVT_ASCIIZ; - ZeroMemory(&WumfOptions, sizeof(WumfOptions)); - if (DBGetContactSetting(NULL, ModuleName, OPT_FILE, &dbv) == 0) - { - strncpy(WumfOptions.LogFile, dbv.pszVal, 255); - } - else - { - WumfOptions.LogFile[0] = '\0'; - }; - WumfOptions.PopupsEnabled = DBGetContactSettingByte(NULL,ModuleName, POPUPS_ENABLED, TRUE); - - WumfOptions.UseDefColor = DBGetContactSettingByte(NULL,ModuleName, COLOR_DEF, TRUE); - WumfOptions.UseWinColor = DBGetContactSettingByte(NULL,ModuleName, COLOR_WIN, FALSE); - WumfOptions.SelectColor = DBGetContactSettingByte(NULL,ModuleName, COLOR_SET, FALSE); - - WumfOptions.ColorText = DBGetContactSettingDword(NULL,ModuleName, COLOR_TEXT, RGB(0,0,0)); - WumfOptions.ColorBack = DBGetContactSettingDword(NULL,ModuleName, COLOR_BACK, RGB(255,255,255)); - - WumfOptions.DelayDef = DBGetContactSettingByte(NULL,ModuleName, DELAY_DEF, TRUE); - WumfOptions.DelayInf = DBGetContactSettingByte(NULL,ModuleName, DELAY_INF, FALSE); - WumfOptions.DelaySet = DBGetContactSettingByte(NULL,ModuleName, DELAY_SET, FALSE); - WumfOptions.DelaySec = DBGetContactSettingByte(NULL,ModuleName, DELAY_SEC, 0); - if(!ServiceExists(MS_POPUP_ADDPOPUPEX)) - { - WumfOptions.DelayDef = TRUE; - WumfOptions.DelaySet = FALSE; - WumfOptions.DelayInf = FALSE; - } - WumfOptions.LogToFile = DBGetContactSettingByte(NULL,ModuleName, LOG_INTO_FILE, FALSE); - WumfOptions.LogFolders = DBGetContactSettingByte(NULL,ModuleName, LOG_FOLDER, TRUE); - WumfOptions.AlertFolders = DBGetContactSettingByte(NULL,ModuleName, ALERT_FOLDER, TRUE); - WumfOptions.LogUNC = DBGetContactSettingByte(NULL,ModuleName, LOG_UNC, FALSE); - WumfOptions.AlertUNC = DBGetContactSettingByte(NULL,ModuleName, ALERT_UNC, FALSE); - WumfOptions.LogComp = DBGetContactSettingByte(NULL,ModuleName, LOG_COMP, FALSE); - WumfOptions.AlertComp = DBGetContactSettingByte(NULL,ModuleName, ALERT_COMP, FALSE); - return; -} - - -void ExecuteMenu(HWND hWnd) -{ - HMENU hMenu; - POINT point; - - hMenu=CreatePopupMenu(); - if(!hMenu) - { - MessageBox(NULL, "Error crerating menu", "WUMF",MB_OK); - return; - }; - AppendMenu(hMenu,MF_STRING,IDM_ABOUT, "About\0"); - AppendMenu(hMenu,MF_SEPARATOR,0,NULL);//------------------ - AppendMenu(hMenu,MF_STRING,IDM_SHOW, "Show connections\0"); - AppendMenu(hMenu,MF_SEPARATOR,0,NULL);//------------------ - AppendMenu(hMenu,MF_STRING,IDM_EXIT, "Dismiss popup\0"); - - GetCursorPos (&point); - SetForegroundWindow (hWnd); - - TrackPopupMenu (hMenu, TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RIGHTALIGN | TPM_TOPALIGN, - point.x, point.y, 0, hWnd, NULL); - - PostMessage (hWnd, WM_USER, 0, 0); - DestroyMenu(hMenu); -} - -static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ -// PWumf w = NULL; - switch(message) { - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDM_ABOUT: - break; - case IDM_EXIT: - PUDeletePopUp(hWnd); - break; - case IDM_SHOW: - CallService(MS_WUMF_CONNECTIONSSHOW, (WPARAM)0, (LPARAM)0); - return TRUE; - } - switch (HIWORD(wParam)) - { - case STN_CLICKED: - PUDeletePopUp(hWnd); - return TRUE; - } - break; - case WM_CONTEXTMENU: -// ExecuteMenu(hWnd); - CallService(MS_WUMF_CONNECTIONSSHOW, (WPARAM)0, (LPARAM)0); - break; - case UM_FREEPLUGINDATA: { -/* w = (PWumf)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)w); - if(w) free(w);*/ - return TRUE; //TRUE or FALSE is the same, it gets ignored. - } - default: - break; - } - return DefWindowProc(hWnd, message, wParam, lParam); -}; - -void ShowWumfPopUp(PWumf w) -{ - char text[512], title[512]; - - if(!WumfOptions.AlertFolders && (w->dwAttr & FILE_ATTRIBUTE_DIRECTORY)) return; - mir_snprintf(title, sizeof(title)/sizeof(title[0]), "%s (%s)", w->szComp, w->szUser); - mir_snprintf(text, sizeof(text)/sizeof(text[0]), "%s (%s)", w->szPath, w->szPerm); - ShowThePopUp(w, title, text); -} -void ShowThePopUp(PWumf w, LPSTR title, LPSTR text) -{ - POPUPDATAEX ppd = { 0 }; - COLORREF colorBack; - COLORREF colorText; - - colorBack = GetSysColor(COLOR_BTNFACE); - colorText = RGB(0,0,0); - - ppd.lchContact = NULL; - ppd.lchIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_DRIVE)); - ppd.iSeconds = -1; - - if(WumfOptions.DelayInf) - { - ppd.iSeconds = -1; - } - else if(WumfOptions.DelayDef) - { - ppd.iSeconds = 0; - } - else if(WumfOptions.DelaySet) - { - ppd.iSeconds = WumfOptions.DelaySec; - } - - lstrcpyn(ppd.lpzContactName, title, 128); - lstrcpyn(ppd.lpzText, text, 128); - if(WumfOptions.UseWinColor) - { - ppd.colorBack = GetSysColor(COLOR_WINDOW); - ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); - } - else if(WumfOptions.UseDefColor) - { - ppd.colorBack = 0L; - ppd.colorText = 0L; - } - else if(WumfOptions.SelectColor) - { - ppd.colorBack = WumfOptions.ColorBack; - ppd.colorText = WumfOptions.ColorText; - } - - ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; - ppd.PluginData = w; - if(CALLSERVICE_NOTFOUND == CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0)) - CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0); -} - -void ShowThePreview() -{ - if(!ServiceExists(MS_POPUP_ADDPOPUP)) - { - MessageBox(NULL,"PopUp plugin not found!", "WUMF plugin", MB_OK|MB_ICONSTOP); - return; - }; - if(WumfOptions.AlertFolders) - { - ShowThePopUp(NULL, "Guest", "C:\\My Share"); - Sleep(300); - ShowThePopUp(NULL, "Guest", "C:\\My Share\\Photos"); - Sleep(300); - } - ShowThePopUp(NULL, "Guest", "C:\\Share\\My Photos\\photo.jpg"); - Sleep(300); - if(WumfOptions.AlertFolders) - { - ShowThePopUp(NULL, "User", "C:\\My Share"); - Sleep(300); - ShowThePopUp(NULL, "User", "C:\\My Share\\Movies"); - Sleep(300); - } - ShowThePopUp(NULL, "User", "C:\\My Share\\Movies\\The Two Towers.avi"); - Sleep(300); - if(WumfOptions.AlertFolders) - { - ShowThePopUp(NULL, "Administrator", "C:\\Distributives"); - Sleep(300); - ShowThePopUp(NULL, "Administrator", "C:\\Distributives\\Win2k"); - Sleep(300); - } - ShowThePopUp(NULL, "Administrator", "C:\\Distributives\\Win2k\\setup.exe"); -}; - - - -BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) -{ - hInst=hinstDLL; - return TRUE; -} - -DWORD WINAPI ThreadProc(LPVOID lpParameter) -{ - MSG msg; //Message pump. - if(hDlg) - { - ShowWindow(hDlg, SW_SHOWNORMAL); - SetForegroundWindow(hDlg); - return (int)(1); - } - hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_CONNLIST), NULL, (DLGPROC)ConnDlgProc); - SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(IDI_DRIVE))); - ShowWindow(hDlg, SW_SHOW); - while(GetMessage(&msg, NULL, 0, 0) == TRUE) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - hDlg = NULL; - ExitThread(0); - - return (int)(1); -} - - -static INT_PTR WumfShowConnections(WPARAM wParam,LPARAM lParam) -{ - DWORD threadID = 0; - CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, (LPVOID)NULL,0,&threadID)); - Sleep(100); - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hWumfBut, TTBST_RELEASED); - return 0; -} - -static INT_PTR WumfMenuCommand(WPARAM wParam,LPARAM lParam) -{ - BOOL MajorTo0121 = FALSE; - int iResult = 0; - CLISTMENUITEM mi = { 0 }; - - mi.cbSize = sizeof(mi); - if (WumfOptions.PopupsEnabled == TRUE) - { - WumfOptions.PopupsEnabled = FALSE; - mi.pszName = Translate("Enable WUMF popups"); - mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NOPOPUP)); - } - else - { - WumfOptions.PopupsEnabled = TRUE; - mi.pszName = Translate("Disable WUMF popups"); - mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_POPUP)); - } - DBWriteContactSettingByte(NULL, ModuleName, POPUPS_ENABLED, (BYTE)WumfOptions.PopupsEnabled); - mi.flags = CMIM_NAME | CMIM_ICON; - iResult = CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hMenuItem,(LPARAM)&mi); - return iResult; -} - -__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -void DisableDelayOptions(HWND hwndDlg) -{ - CheckDlgButton(hwndDlg, IDC_DELAY_INF,BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DELAY_SET,BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DELAY_DEF,BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_INF), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SET), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_DEF), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_TX_DELAY_SEC), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_NOTE), TRUE); -} -void ChooseFile(HWND hDlg) -{ - OPENFILENAME ofn; // common dialog box structure - char szFile[260]; // buffer for filename - HANDLE hf; // file handle - // Initialize OPENFILENAME - ZeroMemory(&ofn, sizeof(OPENFILENAME)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner =hDlg; - szFile[0]=0; - ofn.lpstrFile = szFile; - ofn.nMaxFile = 260; - ofn.lpstrFilter = "All files (*.*)\0*.*\0Text files (*.txt)\0*.txt\0Log files (*.log)\0*.log\0\0"; - ofn.nFilterIndex = 2; - ofn.lpstrFileTitle = NULL; - ofn.nMaxFileTitle = 0; - ofn.lpstrInitialDir = NULL; - ofn.Flags = OFN_CREATEPROMPT; - // Display the Open dialog box. - if (GetSaveFileName(&ofn)==TRUE) - { - hf = CreateFile(ofn.lpstrFile, - GENERIC_WRITE, - 0, - (LPSECURITY_ATTRIBUTES) NULL, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - (HANDLE) NULL); - if(hf!=INVALID_HANDLE_VALUE) - { - SetDlgItemText(hDlg,IDC_FILE,ofn.lpstrFile); - lstrcpyn(WumfOptions.LogFile, ofn.lpstrFile, 255); - CloseHandle(hf); - } - } - else if(CommDlgExtendedError()!=0L) - { - char str[256]; - wsprintf(str,"Common Dialog Error 0x%lx",CommDlgExtendedError()); - MessageBox(hDlg,str,"Wumf plugin",MB_OK|MB_ICONSTOP); - }; - -}; - -INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg,UINT msg,WPARAM wparam,LPARAM lparam) -{ - WORD wControlId = LOWORD(wparam); - WORD wNotifyCode = HIWORD(wparam); - int seconds; - - switch(msg) - { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - CheckDlgButton(hwndDlg, IDC_COLOR_WIN, WumfOptions.UseWinColor?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_COLOR_DEF, WumfOptions.UseDefColor?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_COLOR_SET, WumfOptions.SelectColor?BST_CHECKED:BST_UNCHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BACK), WumfOptions.SelectColor); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_TEXT), WumfOptions.SelectColor); - if(WumfOptions.SelectColor) - { - SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_SETCOLOUR,0,WumfOptions.ColorBack); - SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_SETCOLOUR,0,WumfOptions.ColorText); - } - if(!ServiceExists(MS_POPUP_ADDPOPUPEX)) - { - DisableDelayOptions(hwndDlg); - break; - } - CheckDlgButton(hwndDlg, IDC_DELAY_INF, WumfOptions.DelayInf?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DELAY_DEF, WumfOptions.DelayDef?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_DELAY_SET, WumfOptions.DelaySet?BST_CHECKED:BST_UNCHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), WumfOptions.DelaySet); - SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, FALSE); - //Logging & alerts - CheckDlgButton(hwndDlg, IDC_LOG_FOLDER, WumfOptions.LogFolders?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ALERT_FOLDER, WumfOptions.AlertFolders?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_LOG_UNC, WumfOptions.LogUNC?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ALERT_UNC, WumfOptions.AlertUNC?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_LOG_COMP, WumfOptions.LogComp?BST_CHECKED:BST_UNCHECKED); - - if(WumfOptions.LogToFile) - { - CheckDlgButton(hwndDlg,IDC_LOG_INTO_FILE,BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), TRUE); - EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), TRUE); - SetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile); - } - else - { - CheckDlgButton(hwndDlg,IDC_LOG_INTO_FILE,BST_UNCHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), FALSE); - EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), FALSE); - SetDlgItemText(hwndDlg,IDC_FILE,""); - }; - - break; - case WM_COMMAND: - switch(wNotifyCode) - { - case BN_CLICKED : - switch(wControlId) - { - case IDC_DELAY_SET: - case IDC_DELAY_DEF: - case IDC_DELAY_INF: - WumfOptions.DelaySet = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_SET) == BST_CHECKED); - WumfOptions.DelayDef = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_DEF) == BST_CHECKED); - WumfOptions.DelayInf = (IsDlgButtonChecked(hwndDlg, IDC_DELAY_INF) == BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_DELAY_SEC), WumfOptions.DelaySet); - SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, TRUE); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_COLOR_SET: - case IDC_COLOR_DEF: - case IDC_COLOR_WIN: - WumfOptions.SelectColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_SET) == BST_CHECKED); - WumfOptions.UseDefColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_DEF) == BST_CHECKED); - WumfOptions.UseWinColor = (IsDlgButtonChecked(hwndDlg, IDC_COLOR_WIN) == BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_BACK),WumfOptions.SelectColor); - EnableWindow(GetDlgItem(hwndDlg, IDC_COLOR_TEXT), WumfOptions.SelectColor); - SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_SETCOLOUR,0,WumfOptions.ColorBack); - SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_SETCOLOUR,0,WumfOptions.ColorText); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - /* not implemented */ - case IDC_LOG_COMP: - case IDC_ALERT_COMP: - case IDC_LOG_UNC: - case IDC_ALERT_UNC: - MessageBox(NULL, "Not implemented yet...", "WUMF", MB_OK|MB_ICONINFORMATION); - break; - /* end */ - case IDC_LOG_INTO_FILE: - WumfOptions.LogToFile = (IsDlgButtonChecked(hwndDlg, IDC_LOG_INTO_FILE) == BST_CHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILE), WumfOptions.LogToFile); - EnableWindow(GetDlgItem(hwndDlg, IDC_SEL_FILE), WumfOptions.LogToFile); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_SEL_FILE: - ChooseFile(hwndDlg); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_LOG_FOLDER: - WumfOptions.LogFolders = (IsDlgButtonChecked(hwndDlg, IDC_LOG_FOLDER) == BST_CHECKED); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_ALERT_FOLDER: - WumfOptions.AlertFolders = (IsDlgButtonChecked(hwndDlg, IDC_ALERT_FOLDER) == BST_CHECKED); - break; -/* case IDC_LOG_COMP: - WumfOptions.LogComp = (IsDlgButtonChecked(hwndDlg, IDC_LOG_COMP) == BST_CHECKED); - break; - case IDC_ALERT_COMP: - WumfOptions.AlertComp = (IsDlgButtonChecked(hwndDlg, IDC_ALERT_COMP) == BST_CHECKED); - break; - case IDC_LOG_UNC: - WumfOptions.LogUNC = (IsDlgButtonChecked(hwndDlg, IDC_LOG_UNC) == BST_CHECKED); - break; - case IDC_ALERT_UNC: - WumfOptions.AlertUNC = (IsDlgButtonChecked(hwndDlg, IDC_ALERT_UNC) == BST_CHECKED); - break; -*/ case IDC_PREVIEW: - ShowThePreview(); - break; - case IDC_CONN: - CallService(MS_WUMF_CONNECTIONSSHOW, (WPARAM)0, (LPARAM)0); - break; - } - break; - case CPN_COLOURCHANGED: - WumfOptions.ColorText = SendDlgItemMessage(hwndDlg,IDC_COLOR_TEXT,CPM_GETCOLOUR,0,0); - WumfOptions.ColorBack = SendDlgItemMessage(hwndDlg,IDC_COLOR_BACK,CPM_GETCOLOUR,0,0); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case EN_CHANGE: - switch(wControlId) - { - case IDC_DELAY_SEC: - seconds = GetDlgItemInt(hwndDlg, IDC_DELAY_SEC, NULL, FALSE); - if (seconds > LIFETIME_MAX) - WumfOptions.DelaySec = LIFETIME_MAX; - else if (seconds < LIFETIME_MIN) - WumfOptions.DelaySec = LIFETIME_MIN; - else if (seconds <= LIFETIME_MAX || seconds >= LIFETIME_MIN) - WumfOptions.DelaySec = seconds; - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_FILE: - GetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile, sizeof(WumfOptions.LogFile)); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - break; - case EN_KILLFOCUS: - switch(wControlId) - { - case IDC_DELAY_SEC: - SetDlgItemInt(hwndDlg, IDC_DELAY_SEC, WumfOptions.DelaySec, FALSE); - break; - }; - break; - } - break; - case WM_NOTIFY: - switch(((LPNMHDR)lparam)->idFrom) { - case 0: - switch (((LPNMHDR)lparam)->code) { - case PSN_RESET: - LoadOptions(); - return TRUE; - case PSN_APPLY: - DBWriteContactSettingByte(NULL,ModuleName, COLOR_DEF, (BYTE)WumfOptions.UseDefColor); - DBWriteContactSettingByte(NULL,ModuleName, COLOR_WIN, (BYTE)WumfOptions.UseWinColor); - DBWriteContactSettingByte(NULL,ModuleName, COLOR_SET, (BYTE)WumfOptions.SelectColor ); - DBWriteContactSettingDword(NULL,ModuleName, COLOR_TEXT, (DWORD)WumfOptions.ColorText); - DBWriteContactSettingDword(NULL,ModuleName, COLOR_BACK, (DWORD)WumfOptions.ColorBack); - DBWriteContactSettingByte(NULL,ModuleName, DELAY_DEF, (BYTE)WumfOptions.DelayDef); - DBWriteContactSettingByte(NULL,ModuleName, DELAY_INF, (BYTE)WumfOptions.DelayInf); - DBWriteContactSettingByte(NULL,ModuleName, DELAY_SET, (BYTE)WumfOptions.DelaySet); - DBWriteContactSettingByte(NULL,ModuleName, DELAY_SEC, (BYTE)WumfOptions.DelaySec); - DBWriteContactSettingByte(NULL,ModuleName, LOG_INTO_FILE, (BYTE)WumfOptions.LogToFile); - DBWriteContactSettingByte(NULL,ModuleName, LOG_FOLDER, (BYTE)WumfOptions.LogFolders); - DBWriteContactSettingByte(NULL,ModuleName, ALERT_FOLDER, (BYTE)WumfOptions.AlertFolders); - DBWriteContactSettingByte(NULL,ModuleName, LOG_UNC, (BYTE)WumfOptions.LogUNC); - DBWriteContactSettingByte(NULL,ModuleName, ALERT_UNC, (BYTE)WumfOptions.AlertUNC); - DBWriteContactSettingByte(NULL,ModuleName, LOG_COMP, (BYTE)WumfOptions.LogComp); - DBWriteContactSettingByte(NULL,ModuleName, ALERT_COMP, (BYTE)WumfOptions.AlertComp); - GetDlgItemText(hwndDlg,IDC_FILE,WumfOptions.LogFile, 255); - DBWriteContactSettingString(NULL,ModuleName, OPT_FILE, WumfOptions.LogFile); - break; - } - break; - } - break; - } - return 0; -} - -int InitTopToolbar(WPARAM wparam,LPARAM lparam) -{ - TTBButton ttb = { 0 }; - ttb.cbSize = sizeof(ttb); - ttb.hIconUp = LoadIcon(hInst, MAKEINTRESOURCE(IDB_DRIVE)); - ttb.pszService = MS_WUMF_CONNECTIONSSHOW; - ttb.dwFlags = TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP; - ttb.name = ttb.pszTooltipUp = LPGEN("Show connections list"); - hWumfBut = TopToolbar_AddButton(&ttb); - return 0; -} - -int OptionsInit(WPARAM wparam,LPARAM lparam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - - - odp.cbSize=sizeof(odp); - odp.position=945000000; - odp.hInstance=hInst; - odp.pszTemplate=MAKEINTRESOURCE(IDD_OPTIONS); - odp.pszTitle="Wumf"; - odp.pfnDlgProc=OptionsDlgProc; - odp.pszGroup=Translate("Plugins"); - odp.flags=ODPF_BOLDGROUPS; - Options_AddPage(wparam, &odp); - return 0; -} - -__declspec(dllexport) int Load(void) -{ - CLISTMENUITEM mi = { 0 }; - - mir_getLP(&pluginInfo); - - ZeroMemory(&mi, sizeof(mi)); - mi.cbSize = sizeof(mi); - LoadOptions(); - - CreateServiceFunction(MS_WUMF_SWITCHPOPUP, WumfMenuCommand); - CreateServiceFunction(MS_WUMF_CONNECTIONSSHOW, WumfShowConnections); - if (WumfOptions.PopupsEnabled == FALSE) - { - mi.pszName = Translate("Enable WUMF popups"); - mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_NOPOPUP)); - } - else - { - mi.pszName = Translate("Disable WUMF popups"); - mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_POPUP)); - } - mi.pszService = MS_WUMF_SWITCHPOPUP; - mi.popupPosition = 1999990000; - mi.pszPopupName = Translate("PopUps"); - hMenuItem = (HANDLE)Menu_AddMainMenuItem(&mi); - - mi.pszName = Translate("WUMF: Show connections"); - mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_DRIVE)); - mi.pszService = MS_WUMF_CONNECTIONSSHOW; - mi.popupPosition = 1999990000; - mi.pszPopupName = NULL; - Menu_AddMainMenuItem(&mi); - - HookEvent(ME_OPT_INITIALISE,OptionsInit); - HookEvent(ME_TTB_MODULELOADED, InitTopToolbar); - setlocale( LC_ALL, ".ACP"); -// _setmbcp(_MB_CP_ANSI); - - if (IsUserAnAdmin()) { - SetTimer(NULL, 777, TIME,(TIMERPROC) TimerProc); - } else { - MessageBox(NULL, "Plugin WhoUsesMyFiles requires admin privileges in order to work.", "Miranda IM", MB_OK); - } - - return 0; -} - -__declspec(dllexport) int Unload(void) -{ - KillTimer(NULL, 777); - CloseHandle(hLog); - FreeAll(); - return 0; -} \ No newline at end of file diff --git a/plugins/YAPP/PPh2.ico b/plugins/YAPP/PPh2.ico deleted file mode 100644 index f8aa63abf2..0000000000 Binary files a/plugins/YAPP/PPh2.ico and /dev/null differ diff --git a/plugins/YAPP/common.h b/plugins/YAPP/common.h deleted file mode 100644 index 1b2a52b74b..0000000000 --- a/plugins/YAPP/common.h +++ /dev/null @@ -1,114 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#define _CRT_SECURE_NO_WARNINGS - -// Modify the following defines if you have to target a platform prior to the ones specified below. -// Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Allow use of features specific to Windows XP or later. -#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. -#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. -#endif - -#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. -#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. -#endif - - -#include - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include -#include -#include - -#define MIRANDA_VER 0x0A00 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define MODULE "YAPP" - -extern HMODULE hInst; - -extern HFONT hFontFirstLine, hFontSecondLine, hFontTime; -extern COLORREF colFirstLine, colSecondLine, colBg, colTime, colBorder, colSidebar, colTitleUnderline; - -extern MNOTIFYLINK *notifyLink; - -// work around a bug in neweventnotify, possibly httpserver -// ignore the address passed to the 'get plugin data' service -extern bool ignore_gpd_passed_addy; - -// win32 defines for mingw version of windows headers :( -#ifndef LVM_SORTITEMSEX -#define LVM_SORTITEMSEX (LVM_FIRST + 81) - -typedef int (CALLBACK *PFNLVCOMPARE)(LPARAM, LPARAM, LPARAM); - -#define ListView_SortItemsEx(hwndLV, _pfnCompare, _lPrm) \ - (BOOL)SendMessage((hwndLV), LVM_SORTITEMSEX, (WPARAM)(LPARAM)(_lPrm), (LPARAM)(PFNLVCOMPARE)(_pfnCompare)) -#endif - - -typedef struct { - int cbSize; - int flags; // OR of PDF_* flags below - HANDLE hContact; - HICON hIcon; - union { - char *pszTitle; - TCHAR *ptzTitle; - wchar_t *pwzTitle; - }; - union { - char *pszText; - TCHAR *ptzText; - wchar_t *pwzText; - }; - COLORREF colorBack; // if colorBack and colorText are equal, defaults will be used - COLORREF colorText; - WNDPROC windowProc; // optional custom window procedure - int timeout; // -1 == infinite, 0 == default, otherwise timeout in seconds - void *opaque; -} PopupData; - -#define PDF_UNICODE 0x0001 - -#define PDF_TCHAR PDF_UNICODE - -// windowProc messages -#define PM_INIT (WM_USER + 0x0202) // message sent to your windowProc after the window has been initialized -#define PM_DIENOTIFY (WM_USER + 0x0200) // message sent to your windowProc just before the window is destroyed (can be used e.g. to free your opaque data) - -#define PM_DESTROY (WM_USER + 0x0201) // send to the popup hWnd (use PostMessage generally, or SendMessage inside your windowProc) to kill it - -void ShowPopup(PopupData &pd_in); \ No newline at end of file diff --git a/plugins/YAPP/docs/m_popup2.h b/plugins/YAPP/docs/m_popup2.h deleted file mode 100644 index b23aecf7fb..0000000000 --- a/plugins/YAPP/docs/m_popup2.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __m_popup2_h__ -#define __m_popup2_h__ - -#define NFOPT_POPUP2_BACKCOLOR "Popup2/BackColor" -#define NFOPT_POPUP2_TEXTCOLOR "Popup2/TextColor" -#define NFOPT_POPUP2_TIMEOUT "Popup2/Timeout" -#define NFOPT_POPUP2_LCLICKSVC "Popup2/LClickSvc" -#define NFOPT_POPUP2_LCLICKCOOKIE "Popup2/LClickCookie" -#define NFOPT_POPUP2_RCLICKSVC "Popup2/RClickSvc" -#define NFOPT_POPUP2_RCLICKCOOKIE "Popup2/RClickCookie" -#define NFOPT_POPUP2_STATUSMODE "Popup2/StatusMode" -#define NFOPT_POPUP2_PLUGINDATA "Popup2/PluginData" -#define NFOPT_POPUP2_WNDPROC "Popup2/WndProc" - -#define NFOPT_POPUP2_BACKCOLOR_S "Popup2/BackColor/Save" -#define NFOPT_POPUP2_TEXTCOLOR_S "Popup2/TextColor/Save" -#define NFOPT_POPUP2_TIMEOUT_S "Popup2/Timeout/Save" - -#define MS_POPUP2_SHOW "Popup2/Show" -#define MS_POPUP2_UPDATE "Popup2/Update" -#define MS_POPUP2_REMOVE "Popup2/Remove" - -#ifndef POPUP2_NOHELPERS - #define MPopup2Show(a) (CallService(MS_POPUP2_SHOW, 0, (LPARAM)(a))) - #define MPopup2Update(a) (CallService(MS_POPUP2_UPDATE, 0, (LPARAM)(a))) - #define MPopup2Remove(a) (CallService(MS_POPUP2_REMOVE, 0, (LPARAM)(a))) -#endif - -#endif // __m_popup2_h__ diff --git a/plugins/YAPP/docs/yapp-translation.txt b/plugins/YAPP/docs/yapp-translation.txt new file mode 100644 index 0000000000..82c150e612 --- /dev/null +++ b/plugins/YAPP/docs/yapp-translation.txt @@ -0,0 +1,74 @@ +; Common strings that belong to many files +;[PopUps] + +; ../../plugins/YAPP/notify_imp.cpp +;[YAPP Popups] + +; ../../plugins/YAPP/options.cpp +;[An avatar.] +;[Bottom left] +;[Bottom right] +;[Classes] +;[Error] +;[Example] +;[Example With a Long Title] +;[Full-screen app running] +;[Icon on left] +;[Icon on right] +;[Left avatar] +;[No avatar] +;[No time] +;[Right avatar] +;[Settings] +;[Status] +;[The quick brown fox jumped over the lazy dog.] +;[Thequickbrownfoxjumpedoverthelazydog.] +;[Time above avatar] +;[Time on left] +;[Time on right] +;[Top left] +;[Top right] +;[You cannot set a default timeout of 0.\nValue has been reset.] + +; ../../plugins/YAPP/popup_history_dlg.cpp +;[Copy message to clipboard] +;[Copy timestamp to clipboard] +;[Copy title to clipboard] + +; ../../plugins/YAPP/popups2.cpp +;[Test popup class] + +; ../../plugins/YAPP/popups2.rc +;[Animate] +;[Avatar size:] +;[Background colour:] +;[Border] +;[Case sensitive] +;[Close] +;[Custom1] +;[Default Timeout] +;[Disable when] +;[Global hover] +;[Layout] +;[Maximum height:] +;[Never timeout] +;[Opacity(%):] +;[Options] +;[Padding:] +;[Popup history] +;[Preview] +;[Round corners (avatar)] +;[Round corners (window)] +;[Set timeout] +;[Set timeout:] +;[Sidebar width:] +;[Text colour:] +;[Text indent:] +;[Timeout value (0 = default):] +;[Transparent background] +;[Width:] + +; ../../plugins/YAPP/services.cpp +;[Disable Popups] +;[Enable Popups] +;[Popup History] diff --git a/plugins/YAPP/message_pump.cpp b/plugins/YAPP/message_pump.cpp deleted file mode 100644 index 7e2cea5f0c..0000000000 --- a/plugins/YAPP/message_pump.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include "common.h" -#include "message_pump.h" -#include "popwin.h" -#include "services.h" -#include "options.h" - -unsigned message_pump_thread_id = 0; -int num_popups = 0; - -HANDLE hMPEvent; - -#define MUM_FINDWINDOW (WM_USER + 0x050) - -#define MAX_POPUPS 100 - -// from popups, popup2 implementation, slightly modified -// return true if there is a full-screen application (e.g. game) running -bool is_full_screen() { - int w = GetSystemMetrics(SM_CXSCREEN); - int h = GetSystemMetrics(SM_CYSCREEN); - // use ClientRect instead of WindowRect so that it works normally for maximized applications - thx Nikto - RECT ClientRect; - HWND hWnd; - - HWND hWndDesktop = GetDesktopWindow(); - HWND hWndShell = GetShellWindow(); - - // check foregroundwindow - hWnd = GetForegroundWindow(); - if(hWnd && hWnd != hWndDesktop && hWnd != hWndShell) { - GetClientRect(hWnd, &ClientRect); - if ((ClientRect.right - ClientRect.left) >= w && (ClientRect.bottom - ClientRect.top) >= h) - return true; - } - - // check other top level windows - while ((hWnd = FindWindowEx(NULL, hWnd, NULL, NULL))) { - if(IsWindowVisible(hWnd) == 0 || IsIconic(hWnd) || hWnd == hWndDesktop || hWnd == hWndShell) - continue; - -// if(DBGetContactSettingByte(0, MODULE, "ShowForNonTopmostFullscreenWindows", 0) == 1) { - if (!(GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST)) - continue; -// } - - // not sure if this could be done more simply using 'IsZoomed'? - GetClientRect(hWnd, &ClientRect); - if ((ClientRect.right - ClientRect.left) < w || (ClientRect.bottom - ClientRect.top) < h) - continue; - - return true; - } - - return false; -} - -bool is_workstation_locked() -{ - bool rc = false; - HDESK hDesk = OpenDesktop((TCHAR*)_T("default"), 0, FALSE, DESKTOP_SWITCHDESKTOP); - if(hDesk != 0) { - HDESK hDeskInput = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); - if(hDeskInput == 0) { - rc = true; - } else - CloseDesktop(hDeskInput); - - CloseDesktop(hDesk); - } - - return rc; -} - - -unsigned __stdcall MessagePumpThread(void* param) -{ - InitWindowStack(); - - if(param) SetEvent((HANDLE)param); - - MSG hwndMsg = {0}; - while(GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated()) { - if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) { - switch(hwndMsg.message) { - case MUM_CREATEPOPUP: - { - bool enabled = true; - int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); - if(status >= ID_STATUS_OFFLINE && status <= ID_STATUS_OUTTOLUNCH && options.disable_status[status - ID_STATUS_OFFLINE]) - enabled = false; - if ((options.disable_full_screen && is_full_screen()) || is_workstation_locked()) - enabled = false; - - PopupData *pd = (PopupData *)hwndMsg.lParam; - if(enabled && num_popups < MAX_POPUPS) { - //HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, GetDesktopWindow(), 0, hInst, (LPVOID)hwndMsg.lParam); - HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)hwndMsg.lParam); - num_popups++; - if(hwndMsg.wParam) // set notifyer handle - SendMessage(hwnd, PUM_SETNOTIFYH, hwndMsg.wParam, 0); - } else { - if (pd) { - mir_free(pd->pwzTitle); - mir_free(pd->pwzText); - mir_free(pd); - } - } - } - break; - - case MUM_DELETEPOPUP: - { - HWND hwnd = (HWND)hwndMsg.lParam; - if(IsWindow(hwnd)) { - DestroyWindow(hwnd); - num_popups--; - } - } - break; - - case MUM_NMUPDATE: - { - HANDLE hNotify = (HANDLE)hwndMsg.wParam; - BroadcastMessage(PUM_UPDATENOTIFY, (WPARAM)hNotify, 0); - } - break; - - case MUM_NMREMOVE: - { - HANDLE hNotify = (HANDLE)hwndMsg.wParam; - BroadcastMessage(PUM_KILLNOTIFY, (WPARAM)hNotify, 0); - } - break; - - case MUM_NMAVATAR: - RepositionWindows(); - break; - - default: - TranslateMessage(&hwndMsg); - DispatchMessage(&hwndMsg); - break; - } - } - } - - DeinitWindowStack(); - num_popups = 0; - - //if(param) SetEvent((HANDLE)param); - - DeinitOptions(); - DeinitServices(); - - return 0; -} - -void PostMPMessage(UINT msg, WPARAM wParam, LPARAM lParam) { - PostThreadMessage(message_pump_thread_id, msg, wParam, lParam); -} - -// given a popup data pointer, and a handle to an event, this function -// will post a message to the message queue which will set the hwnd value -// and then set the event...so create an event, call this function and then wait on the event -// when the event is signalled, the hwnd will be valid -void FindWindow(PopupData *pd, HANDLE hEvent, HWND *hwnd); - -void InitMessagePump() { - WNDCLASS popup_win_class = {0}; - popup_win_class.lpfnWndProc = PopupWindowProc; - popup_win_class.hInstance = hInst; - popup_win_class.lpszClassName = POP_WIN_CLASS; - popup_win_class.hCursor = LoadCursor(NULL, IDC_ARROW); - RegisterClass(&popup_win_class); - - InitServices(); - - hMPEvent = CreateEvent(0, TRUE, 0, 0); - CloseHandle(mir_forkthreadex(MessagePumpThread, hMPEvent, &message_pump_thread_id)); - WaitForSingleObject(hMPEvent, INFINITE); - CloseHandle(hMPEvent); -} - -void DeinitMessagePump() { - PostMPMessage(WM_QUIT, 0, 0); -} diff --git a/plugins/YAPP/message_pump.h b/plugins/YAPP/message_pump.h deleted file mode 100644 index 70671b157a..0000000000 --- a/plugins/YAPP/message_pump.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _MESSAGE_PUMP_INC -#define _MESSAGE_PUMP_INC - -extern unsigned message_pump_thread_id; -void PostMPMessage(UINT msg, WPARAM, LPARAM); - -#define MUM_CREATEPOPUP (WM_USER + 0x011) -#define MUM_DELETEPOPUP (WM_USER + 0x012) - -#define MUM_NMUPDATE (WM_USER + 0x013) -#define MUM_NMREMOVE (WM_USER + 0x014) -#define MUM_NMAVATAR (WM_USER + 0x015) - -// given a popup data pointer, and a handle to an event, this function -// will post a message to the message queue which will set the hwnd value -// and then set the event...so create an event, call this function and then wait on the event -// when the event is signalled, the hwnd will be valid -void FindWindow(PopupData *pd, HANDLE hEvent, HWND *hwnd); - -void InitMessagePump(); -void DeinitMessagePump(); - -#endif diff --git a/plugins/YAPP/notify.h b/plugins/YAPP/notify.h deleted file mode 100644 index 7f39eb6d65..0000000000 --- a/plugins/YAPP/notify.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _NOTIFY_IMP_INC -#define _NOTIFY_IMP_INC - -void InitNotify(); -void DeinitNotify(); - -#endif diff --git a/plugins/YAPP/notify_imp.cpp b/plugins/YAPP/notify_imp.cpp deleted file mode 100644 index 2f2ca9967b..0000000000 --- a/plugins/YAPP/notify_imp.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "common.h" -#include "resource.h" -#include "notify.h" -#include "message_pump.h" -#include "docs/m_popup2.h" - -HANDLE hhkShow=0, hhkUpdate=0, hhkRemove=0; - -//struct - -int Popup2Show(WPARAM wParam, LPARAM lParam) { - - HANDLE hNotify = (HANDLE)lParam; - - PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData)); - memset(pd_out, 0, sizeof(PopupData)); - - PostMPMessage(MUM_CREATEPOPUP, (WPARAM)hNotify, (LPARAM)pd_out); - PostMPMessage(MUM_NMUPDATE, (WPARAM)hNotify, (LPARAM)0); - return 0; -} - -INT_PTR svcPopup2Show(WPARAM wParam, LPARAM lParam) { - return Popup2Show(wParam, lParam); -} - -int Popup2Update(WPARAM wParam, LPARAM lParam) { - HANDLE hNotify = (HANDLE)lParam; - PostMPMessage(MUM_NMUPDATE, (WPARAM)hNotify, (LPARAM)0); - return 0; -} - -int AvatarChanged(WPARAM wParam, LPARAM lParam) { - PostMPMessage(MUM_NMAVATAR, (WPARAM)0, (LPARAM)0); - return 0; -} - - -INT_PTR svcPopup2Update(WPARAM wParam, LPARAM lParam) { - return Popup2Update(wParam, lParam); -} - -int Popup2Remove(WPARAM wParam, LPARAM lParam) { - HANDLE hNotify = (HANDLE)lParam; - PostMPMessage(MUM_NMREMOVE, (WPARAM)hNotify, (LPARAM)0); - return 0; -} - -INT_PTR svcPopup2Remove(WPARAM wParam, LPARAM lParam) { - return Popup2Remove(wParam, lParam); -} - -INT_PTR svcPopup2DefaultActions(WPARAM wParam, LPARAM lParam) -{ - //PopupWindow *wnd = (PopupWindow *)MNotifyGetDWord((HANDLE)lParam, "Popup2/data", (DWORD)NULL); - //if (!wnd) return 0; - switch (wParam) - { - case 0: - { // send message - //if (wnd->lchContact) CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)wnd->lchContact, 0); - //SendMessage(wnd->lchMain, UM_DESTROYPOPUP, 0, 0); - break; - } - case 1: - { // dismiss popup - //SendMessage(wnd->lchMain, UM_DESTROYPOPUP, 0, 0); - break; - } - } - return 0; -} - -INT_PTR CALLBACK DlgProcPopUps(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ -/* To change options use MNotifySet*(hNotify, ....) Apply/Cancel is implemented in notify.dll */ - HANDLE hNotify = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA); - switch (msg) - { - case WM_USER+100: - { - // This will be extendet to handle array of handles for multiselect lParam - // will be HANDLE * and wParam wil; store amount of handles passed - hNotify = (HANDLE)lParam; - SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); - return TRUE; - } - - case WM_COMMAND: - // This in different from Miranda options! - SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); - break; - } - return FALSE; -} - -int NotifyOptionsInitialize(WPARAM wParam,LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = {0}; - odp.cbSize = sizeof(odp); - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NOTIFY); - odp.pszTitle = LPGEN("YAPP Popups"); - odp.flags=ODPF_BOLDGROUPS; - odp.pfnDlgProc = DlgProcPopUps; - CallService(MS_NOTIFY_OPT_ADDPAGE, wParam, (LPARAM)&odp); - return 0; -} - -HANDLE hEventNotifyOptInit, hEventNotifyModulesLoaded; -HANDLE hAvChangeEvent; - -int NotifyModulesLoaded(WPARAM wParam,LPARAM lParam) -{ - hEventNotifyOptInit = HookEvent(ME_NOTIFY_OPT_INITIALISE, NotifyOptionsInitialize); - hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); - return 0; -} - -HANDLE hServicesNotify[4]; -void InitNotify() { - hhkShow = HookEvent(ME_NOTIFY_SHOW, Popup2Show); - hhkUpdate = HookEvent(ME_NOTIFY_UPDATE, Popup2Update); - hhkRemove = HookEvent(ME_NOTIFY_REMOVE, Popup2Remove); - - hServicesNotify[0] = CreateServiceFunction("Popup2/DefaultActions", svcPopup2DefaultActions); - - hServicesNotify[1] = CreateServiceFunction(MS_POPUP2_SHOW, svcPopup2Show); - hServicesNotify[2] = CreateServiceFunction(MS_POPUP2_UPDATE, svcPopup2Update); - hServicesNotify[3] = CreateServiceFunction(MS_POPUP2_REMOVE, svcPopup2Remove); - - hEventNotifyModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, NotifyModulesLoaded); -} - -void DeinitNotify() { - UnhookEvent(hhkShow); - UnhookEvent(hhkUpdate); - UnhookEvent(hhkRemove); - - UnhookEvent(hAvChangeEvent); - UnhookEvent(hEventNotifyOptInit); - UnhookEvent(hEventNotifyModulesLoaded); - - for(int i = 0; i < 4; i++) - DestroyServiceFunction(hServicesNotify[i]); -} diff --git a/plugins/YAPP/options.cpp b/plugins/YAPP/options.cpp deleted file mode 100644 index 7ba798e5fa..0000000000 --- a/plugins/YAPP/options.cpp +++ /dev/null @@ -1,505 +0,0 @@ -#include "common.h" -#include "options.h" -#include "resource.h" -#include "popwin.h" -#include "services.h" - -Options options; - -HICON hPopupIcon = 0; - -void LoadModuleDependentOptions() { - if(ServiceExists(MS_AV_DRAWAVATAR)) - options.av_layout = (PopupAvLayout)DBGetContactSettingByte(0, MODULE, "AVLayout", PAV_RIGHT); - else - options.av_layout = PAV_NONE; - - options.time_layout = (PopupTimeLayout)DBGetContactSettingByte(0, MODULE, "TimeLayout", (ServiceExists(MS_AV_DRAWAVATAR) ? PT_WITHAV : PT_RIGHT)); - if(options.time_layout == PT_WITHAV && !ServiceExists(MS_AV_DRAWAVATAR)) - options.time_layout = PT_RIGHT; -} - -void LoadOptions() { - options.default_timeout = DBGetContactSettingDword(0, MODULE, "DefaultTimeout", 7); - options.win_width = DBGetContactSettingDword(0, MODULE, "WinWidth", 220); - options.win_max_height = DBGetContactSettingDword(0, MODULE, "WinMaxHeight", 400); - options.location = (PopupLocation)DBGetContactSettingByte(0, MODULE, "Location", (BYTE)PL_BOTTOMRIGHT); - options.opacity = DBGetContactSettingByte(0, MODULE, "Opacity", 75); - options.border = (DBGetContactSettingByte(0, MODULE, "Border", 1) == 1); - options.round = (DBGetContactSettingByte(0, MODULE, "RoundCorners", 1) == 1); - options.av_round = (DBGetContactSettingByte(0, MODULE, "AvatarRoundCorners", 1) == 1); - options.animate = (DBGetContactSettingByte(0, MODULE, "Animate", 1) == 1); - options.trans_bg = (DBGetContactSettingByte(0, MODULE, "TransparentBg", 0) == 1); - options.use_mim_monitor = (DBGetContactSettingByte(0, MODULE, "UseMimMonitor", 1) == 1); - options.right_icon = (DBGetContactSettingByte(0, MODULE, "RightIcon", 0) == 1); - options.av_layout = PAV_NONE; // corrected in LoadModuleDependentOptions function above - options.av_size = DBGetContactSettingDword(0, MODULE, "AVSize", 40); //tweety - options.text_indent = DBGetContactSettingDword(0, MODULE, "TextIndent", 22); - options.global_hover = (DBGetContactSettingByte(0, MODULE, "GlobalHover", 1) == 1); - options.time_layout = PT_RIGHT; // corrected in LoadModuleDependentOptions function above - - char buff[128]; - for(int i = 0; i < 10; i++) { - sprintf(buff, "DisableStatus%d", i - 1); // -1 because i forgot offline status earlier! - options.disable_status[i] = (DBGetContactSettingByte(0, MODULE, buff, 0) == 1); - } - - options.disable_full_screen = (DBGetContactSettingByte(0, MODULE, "DisableFullScreen", 1) == 1); - options.drop_shadow = (DBGetContactSettingByte(0, MODULE, "DropShadow", 0) == 1); - options.sb_width = DBGetContactSettingDword(0, MODULE, "SidebarWidth", 22); - options.padding = DBGetContactSettingDword(0, MODULE, "Padding", 4); - options.av_padding = DBGetContactSettingDword(0, MODULE, "AvatarPadding", 4); -} - -void SaveOptions() { - DBWriteContactSettingDword(0, MODULE, "DefaultTimeout", options.default_timeout); - DBWriteContactSettingDword(0, MODULE, "WinWidth", options.win_width); - DBWriteContactSettingDword(0, MODULE, "WinMaxHeight", options.win_max_height); - DBWriteContactSettingByte(0, MODULE, "Location", (BYTE)options.location); - DBWriteContactSettingByte(0, MODULE, "Opacity", (BYTE)options.opacity); - DBWriteContactSettingByte(0, MODULE, "Border", (options.border ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "RoundCorners", (options.round ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "AvatarRoundCorners", (options.av_round ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "Animate", (options.animate ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "TransparentBg", (options.trans_bg ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "UseMimMonitor", (options.use_mim_monitor ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "RightIcon", (options.right_icon ? 1 : 0)); - if(ServiceExists(MS_AV_DRAWAVATAR)) - DBWriteContactSettingByte(0, MODULE, "AVLayout", (BYTE)options.av_layout); - DBWriteContactSettingDword(0, MODULE, "AVSize", options.av_size); - DBWriteContactSettingDword(0, MODULE, "TextIndent", options.text_indent); - DBWriteContactSettingByte(0, MODULE, "GlobalHover", (options.global_hover ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "TimeLayout", (BYTE)options.time_layout); - - char buff[128]; - for(int i = 0; i < 9; i++) { - sprintf(buff, "DisableStatus%d", i - 1); - DBWriteContactSettingByte(0, MODULE, buff, options.disable_status[i] ? 1 : 0); - } - DBWriteContactSettingByte(0, MODULE, "DisableFullScreen", (options.disable_full_screen ? 1 : 0)); - DBWriteContactSettingByte(0, MODULE, "DropShadow", (options.drop_shadow ? 1 : 0)); - DBWriteContactSettingDword(0, MODULE, "SidebarWidth", options.sb_width); - DBWriteContactSettingDword(0, MODULE, "Padding", options.padding); - DBWriteContactSettingDword(0, MODULE, "AvatarPadding", options.av_padding); -} - -void ShowExamplePopups() { - PopupData pd = {sizeof(PopupData)}; - pd.hIcon = hPopupIcon; - pd.flags = PDF_TCHAR; - - pd.ptzTitle = TranslateT("Example"); - pd.ptzText = TranslateT("The quick brown fox jumped over the lazy dog."); - ShowPopup(pd); - - pd.ptzTitle = TranslateT("Example With a Long Title"); - pd.ptzText = TranslateT("The quick brown fox jumped over the lazy dog."); - ShowPopup(pd); - - pd.ptzTitle = TranslateT("Example"); - pd.ptzText = TranslateT("Thequickbrownfoxjumpedoverthelazydog."); - ShowPopup(pd); - - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while(hContact) { - if(options.av_layout != PAV_NONE && ServiceExists(MS_AV_DRAWAVATAR)) { - AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0); - if(ace && (ace->dwFlags & AVS_BITMAP_VALID)) { - pd.hContact = hContact; - pd.ptzText = TranslateT("An avatar."); - ShowPopup(pd); - break; - } - } - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } -} - -static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - - switch ( msg ) { - case WM_INITDIALOG: - TranslateDialogDefault( hwndDlg ); - - SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right")); - SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left")); - SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top right")); - SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top left")); - SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_SETCURSEL, (int)options.location, 0); - - SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left")); - SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right")); - SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_SETCURSEL, (options.right_icon ? 1 : 0), 0); - - SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("No time")); - SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time on left")); - SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time on right")); - if(ServiceExists(MS_AV_DRAWAVATAR)) - SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time above avatar")); - SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_SETCURSEL, (int)options.time_layout, 0); - - SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("No avatar")); - if(ServiceExists(MS_AV_DRAWAVATAR)) { - SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar")); - SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar")); - } else { - HWND hw = GetDlgItem(hwndDlg, IDC_CMB_AV); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE); - EnableWindow(hw, FALSE); - } - SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_SETCURSEL, (int)options.av_layout, 0); - - CheckDlgButton(hwndDlg, IDC_CHK_GLOBALHOVER, options.global_hover ? TRUE : FALSE); - - { - // initialise and fill listbox - HWND hwndList = GetDlgItem(hwndDlg, IDC_LST_STATUS); - ListView_DeleteAllItems(hwndList); - - SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); - - LVCOLUMN lvc = {0}; - // Initialize the LVCOLUMN structure. - // The mask specifies that the format, width, text, and - // subitem members of the structure are valid. - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - lvc.fmt = LVCFMT_LEFT; - - lvc.iSubItem = 0; - lvc.pszText = TranslateT("Status"); - lvc.cx = 200; // width of column in pixels - ListView_InsertColumn(hwndList, 0, &lvc); - - - LVITEM lvI = {0}; - - // Some code to create the list-view control. - // Initialize LVITEM members that are common to all - // items. - lvI.mask = LVIF_TEXT; - - char *strptr; - int i = 0; - for (; i < 10; i++) { - strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(ID_STATUS_OFFLINE + i), (LPARAM)0); - lvI.pszText = mir_a2t(strptr); - lvI.iItem = i; - ListView_InsertItem(hwndList, &lvI); - ListView_SetCheckState(hwndList, i, options.disable_status[i]); - mir_free(lvI.pszText); - } - lvI.pszText = TranslateT("Full-screen app running"); - lvI.iItem = i; - ListView_InsertItem(hwndList, &lvI); - ListView_SetCheckState(hwndList, i, options.disable_full_screen); - } - - SendDlgItemMessage(hwndDlg, IDC_SPIN_TIMEOUT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(360, 1)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 1)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0)); - SendDlgItemMessage(hwndDlg, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); - - if(options.default_timeout == -1) { - CheckDlgButton(hwndDlg, IDC_RAD_NOTIMEOUT, TRUE); - HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT); - EnableWindow(hw, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, 7, FALSE); - } else { - CheckDlgButton(hwndDlg, IDC_RAD_TIMEOUT, TRUE); - SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.default_timeout, FALSE); - } - if(options.right_icon) CheckDlgButton(hwndDlg, IDC_RAD_RIGHTICON, TRUE); - else CheckDlgButton(hwndDlg, IDC_RAD_LEFTICON, TRUE); - - if(ServiceExists(MS_AV_DRAWAVATAR)) { - switch(options.av_layout) { - case PAV_NONE: CheckDlgButton(hwndDlg, IDC_RAD_NOAV, TRUE); break; - case PAV_RIGHT: CheckDlgButton(hwndDlg, IDC_RAD_RIGHTAV, TRUE); break; - case PAV_LEFT: CheckDlgButton(hwndDlg, IDC_RAD_LEFTAV, TRUE); break; - } - } else { - CheckDlgButton(hwndDlg, IDC_RAD_NOAV, TRUE); - HWND hw = GetDlgItem(hwndDlg, IDC_RAD_RIGHTAV); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_RAD_LEFTAV); - EnableWindow(hw, FALSE); - } - - SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, options.win_width, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, options.win_max_height, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, options.av_size, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_INDENT, options.text_indent, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, options.sb_width, FALSE); - SetDlgItemInt(hwndDlg, IDC_ED_PADDING, options.padding, FALSE); - - switch(options.location) { - case PL_BOTTOMRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMRIGHT, TRUE); break; - case PL_BOTTOMLEFT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMLEFT, TRUE); break; - case PL_TOPRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_TOPRIGHT, TRUE); break; - case PL_TOPLEFT: CheckDlgButton(hwndDlg, IDC_RAD_TOPLEFT, TRUE); break; - } - - SetDlgItemInt(hwndDlg, IDC_ED_TRANS, options.opacity, FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_BORDER, options.border); - CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, options.round); - CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, options.av_round); - - CheckDlgButton(hwndDlg, IDC_CHK_ANIMATE, options.animate); - CheckDlgButton(hwndDlg, IDC_CHK_TRANSBG, options.trans_bg); - - return FALSE; - case WM_COMMAND: - if ( HIWORD( wParam ) == CBN_SELCHANGE) { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } else if ( HIWORD( wParam ) == BN_CLICKED ) { - if(LOWORD(wParam) == IDC_BTN_PREVIEW) { - ShowExamplePopups(); - } else { - switch( LOWORD( wParam )) { - case IDC_RAD_NOTIMEOUT: - { - HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT); - EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_RAD_TIMEOUT)); - } - break; - case IDC_RAD_TIMEOUT: - { - HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT); - EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_RAD_TIMEOUT)); - } - break; - } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - break; - case WM_NOTIFY: - if(IsWindowVisible(hwndDlg) && ((LPNMHDR) lParam)->hwndFrom == GetDlgItem(hwndDlg, IDC_LST_STATUS)) { - switch (((LPNMHDR) lParam)->code) { - - case LVN_ITEMCHANGED: - { - NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; - if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) { - SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); - } - } - break; - } - } else - if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) { - BOOL trans; - int new_val; - if(IsDlgButtonChecked(hwndDlg, IDC_RAD_NOTIMEOUT)) - options.default_timeout = -1; - else { - new_val = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &trans, FALSE); - if(trans) options.default_timeout = new_val; - } - if(options.default_timeout == 0) { - SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.default_timeout, FALSE); - MessageBox(hwndDlg, TranslateT("You cannot set a default timeout of 0.\nValue has been reset."), TranslateT("Error"), MB_OK | MB_ICONWARNING); - options.default_timeout = 7; // prevent instant timeout - } - - new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE); - if(trans) options.win_width = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE); - if(trans) options.win_max_height = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, &trans, FALSE); - if(trans) options.av_size = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &trans, FALSE); - if(trans) options.text_indent = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, &trans, FALSE); - if(trans) options.sb_width = new_val; - new_val = GetDlgItemInt(hwndDlg, IDC_ED_PADDING, &trans, FALSE); - if(trans) options.padding = new_val; - - options.location = (PopupLocation)SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_GETCURSEL, 0, 0); - options.right_icon = (SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_GETCURSEL, 0, 0) == 1); - options.av_layout = (PopupAvLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_GETCURSEL, 0, 0); - options.time_layout = (PopupTimeLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_GETCURSEL, 0, 0); - - new_val = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, &trans, FALSE); - if(trans) options.opacity = new_val; - options.border = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_BORDER)) ? true : false; - options.round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS)) ? true : false; - options.av_round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false; - options.animate = IsDlgButtonChecked(hwndDlg, IDC_CHK_ANIMATE) ? true : false; - options.trans_bg = IsDlgButtonChecked(hwndDlg, IDC_CHK_TRANSBG) ? true : false; - options.global_hover = IsDlgButtonChecked(hwndDlg, IDC_CHK_GLOBALHOVER) ? true : false; - - int i = 0; - for (; i < 10; i++) - options.disable_status[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_STATUS), i) == 1); - options.disable_full_screen = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_STATUS), i) == 1); - - SaveOptions(); - return TRUE; - } - break; - } - - return 0; -} - -POPUPCLASS *newclasses = 0; -static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - switch ( msg ) { - case WM_INITDIALOG: - TranslateDialogDefault( hwndDlg ); - { - if(num_classes) { - newclasses = (POPUPCLASS *)mir_alloc(num_classes * sizeof(POPUPCLASS)); - memcpy(newclasses, classes, num_classes * sizeof(POPUPCLASS)); - - POPUPCLASS *pc; - int index; - for(int i = 0; i < num_classes; i++) { - pc = &newclasses[i]; - if(pc->flags & PCF_UNICODE) { - index = SendDlgItemMessageW(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pwszDescription); - } else { - index = SendDlgItemMessageA(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pszDescription); - } - SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_SETITEMDATA, index, i); - } - } - } - return FALSE; - case WM_COMMAND: - if ( LOWORD(wParam) == IDC_LST_CLASSES && HIWORD( wParam ) == LBN_SELCHANGE) { - int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_PREVIEW), index != -1); - EnableWindow(GetDlgItem(hwndDlg, IDC_COL_TEXT), index != -1); - EnableWindow(GetDlgItem(hwndDlg, IDC_COL_BG), index != -1); - EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_TIMEOUT), index != -1); - if(index != -1) { - int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0); - SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorText); - SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorBack); - CheckDlgButton(hwndDlg, IDC_CHK_TIMEOUT, newclasses[i].iSeconds != -1); - SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE); - } - EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), index != -1 && IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT)); - return TRUE; - } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { - int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0); - if(index != -1) { - int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0); - BOOL tr; - int t = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &tr, FALSE); - newclasses[i].iSeconds = t; - - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } else { - int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0); - if(index != -1) { - int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0); - switch(LOWORD(wParam)) { - case IDC_CHK_TIMEOUT: - { - BOOL isChecked = IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT); - EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), isChecked); - if(isChecked) newclasses[i].iSeconds = 0; - else newclasses[i].iSeconds = -1; - SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE); - } - SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); - break; - case IDC_COL_TEXT: - newclasses[i].colorText = SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_GETCOLOUR, 0, 0); - SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); - break; - case IDC_COL_BG: - newclasses[i].colorBack = SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_GETCOLOUR, 0, 0); - SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); - break; - case IDC_BTN_PREVIEW: - if(newclasses[i].flags & PCF_UNICODE) { - POPUPCLASS pc = newclasses[i]; - pc.PluginWindowProc = 0; - POPUPDATACLASS d = {sizeof(d), pc.pszName}; - d.pwszTitle = L"Preview"; - d.pwszText = L"The quick brown fox jumps over the lazy dog."; - CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d); - } else { - POPUPCLASS pc = newclasses[i]; - pc.PluginWindowProc = 0; - POPUPDATACLASS d = {sizeof(d), pc.pszName}; - d.pszTitle = "Preview"; - d.pszText = "The quick brown fox jumps over the lazy dog."; - CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d); - } - break; - } - } - } - break; - case WM_NOTIFY: - if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) { - memcpy(classes, newclasses, num_classes * sizeof(POPUPCLASS)); - char setting[256]; - for(int i = 0; i < num_classes; i++) { - mir_snprintf(setting, 256, "%s/Timeout", classes[i].pszName); - DBWriteContactSettingWord(0, MODULE, setting, classes[i].iSeconds); - mir_snprintf(setting, 256, "%s/TextCol", classes[i].pszName); - DBWriteContactSettingDword(0, MODULE, setting, (DWORD)classes[i].colorText); - mir_snprintf(setting, 256, "%s/BgCol", classes[i].pszName); - DBWriteContactSettingDword(0, MODULE, setting, (DWORD)classes[i].colorBack); - } - return TRUE; - } - break; - case WM_DESTROY: - mir_free(newclasses); - break; - } - return 0; -} - -int OptInit(WPARAM wParam, LPARAM lParam) { - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.flags = ODPF_BOLDGROUPS; - odp.position = -790000000; - odp.hInstance = hInst; - odp.pszTitle = LPGEN("PopUps"); - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT1); - odp.pszTab = LPGEN("Settings"); - odp.pfnDlgProc = DlgProcOpts1; - Options_AddPage(wParam, &odp); - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_CLASSES); - odp.pszTab = LPGEN("Classes"); - odp.pfnDlgProc = DlgProcOptsClasses; - Options_AddPage(wParam, &odp); - - return 0; -} - -HANDLE hEventOptInit; -void InitOptions() { - hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit); - - // an icon for preview popups - hPopupIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); - - LoadOptions(); -} - -void DeinitOptions() { - UnhookEvent(hEventOptInit); -} diff --git a/plugins/YAPP/options.h b/plugins/YAPP/options.h deleted file mode 100644 index 55b94d17db..0000000000 --- a/plugins/YAPP/options.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _OPTIONS_INC -#define _OPTIONS_INC - -typedef enum {PL_BOTTOMRIGHT=0, PL_BOTTOMLEFT=1, PL_TOPRIGHT=2, PL_TOPLEFT=3} PopupLocation; -typedef enum {PAV_NONE=0, PAV_LEFT=1, PAV_RIGHT=2} PopupAvLayout; -typedef enum {PT_NONE=0, PT_LEFT=1, PT_RIGHT=2, PT_WITHAV=3} PopupTimeLayout; -typedef struct { - int win_width, win_max_height, av_size; //tweety - int default_timeout; - PopupLocation location; - int opacity; - bool border; - bool round, av_round; - bool animate; - bool trans_bg; - bool use_mim_monitor; - bool right_icon; - PopupAvLayout av_layout; - bool disable_status[10]; - int text_indent; - bool global_hover; - PopupTimeLayout time_layout; - bool disable_full_screen; - bool drop_shadow; - int sb_width; - int padding, av_padding; -} Options; - -extern Options options; - -void InitOptions(); -void LoadOptions(); -void LoadModuleDependentOptions(); -void DeinitOptions(); - -#endif diff --git a/plugins/YAPP/popup_history.cpp b/plugins/YAPP/popup_history.cpp deleted file mode 100644 index db0c53fa3a..0000000000 --- a/plugins/YAPP/popup_history.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "common.h" -#include "popup_history.h" - -PopupHistoryList::PopupHistoryList(int renderer) -{ - this->renderer = renderer; - size = HISTORY_SIZE; //fixed size (at least for now) - historyData = (PopupHistoryData *) malloc(size * sizeof(PopupHistoryData)); //alloc space for data - count = 0; -} - -PopupHistoryList::~PopupHistoryList() -{ - Clear(); //clear the data strings - free(historyData); //deallocate the data list -} - -void PopupHistoryList::Clear() -{ - int i; - for (i = 0; i < count; i++) - { - DeleteData(i); - } - count = 0; -} - -void PopupHistoryList::RemoveItem(int index) -{ - int i; - DeleteData(index); //free the mem for that particular item - for (i = index + 1; i < count; i++) - { - historyData[i - 1] = historyData[i]; //shift all items to the left - } -} - -void PopupHistoryList::DeleteData(int index) -{ - PopupHistoryData *item = &historyData[index]; - mir_free(item->titleT); - mir_free(item->messageT); - item->timestamp = 0; //invalidate item - item->title = NULL; - item->message = NULL; - item->flags = 0; -} - -void PopupHistoryList::AddItem(PopupHistoryData item) -{ - if (count >= size) - { - RemoveItem(0); //remove first element - the oldest - count--; //it will be inc'ed later - } - historyData[count++] = item; //item has it's relevant strings dupped() - RefreshPopupHistory(hHistoryWindow, GetRenderer()); -} - -void PopupHistoryList::Add(char *title, char *message, time_t timestamp) -{ - PopupHistoryData item = {0}; //create a history item - item.timestamp = timestamp; - item.title = mir_strdup(title); - item.message = mir_strdup(message); - AddItem(item); //add it (flags = 0) -} - -void PopupHistoryList::Add(wchar_t *title, wchar_t *message, time_t timestamp) -{ - PopupHistoryData item = {0}; //create an unicode history item - item.flags = PHDF_UNICODE; //mark it as unicode - item.timestamp = timestamp; - item.titleT = mir_u2t(title); - item.messageT = mir_u2t(message); - AddItem(item); //add it -} - -PopupHistoryData *PopupHistoryList::Get(int index) -{ - if ((index < 0) || (index >= count)) //a bit of sanity check - { - return NULL; - } - - return &historyData[index]; -} diff --git a/plugins/YAPP/popup_history.h b/plugins/YAPP/popup_history.h deleted file mode 100644 index f79b6ee7af..0000000000 --- a/plugins/YAPP/popup_history.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef __popup_history_h__ -#define __popup_history_h__ - -#include "m_ieview.h" //need this for special renderers - -/****HISTORY ++ STUFF ***/ -//there's no include file for h++ yet -#ifndef MS_HPP_EG_WINDOW -#define MS_HPP_EG_WINDOW "History++/ExtGrid/NewWindow" -#endif - -#ifndef MS_HPP_EG_EVENT -#define MS_HPP_EG_EVENT "History++/ExtGrid/Event" -#endif - -#ifndef MS_HPP_EG_NAVIGATE -#define MS_HPP_EG_NAVIGATE "History++/ExtGrid/Navigate" -#endif - -#ifndef MS_HPP_EG_OPTIONSCHANGED -#define MS_HPP_EG_OPTIONSCHANGED "History++/ExtGrid/OptionsChanged" -#endif -/************************/ - - - -#define HISTORY_SIZE 200 //number of popup history items - -#define PHDF_UNICODE 1 - -#define POPUPMENU_TITLE 100 -#define POPUPMENU_MESSAGE 101 -#define POPUPMENU_TIMESTAMP 102 - -#define RENDER_DEFAULT 0x00000 -#define RENDER_HISTORYPP 0x00001 -#define RENDER_IEVIEW 0x00002 - -struct PopupHistoryData{ - DWORD flags; //PHDF_* flags - union{ - char *message; - wchar_t *messageW; - TCHAR *messageT; - }; - union{ - char *title; - wchar_t *titleW; - TCHAR *titleT; - }; - time_t timestamp; -}; - -class PopupHistoryList{ - private: - PopupHistoryData *historyData; //historyData[0] - oldest, historyData[size - 1] - newest - int count; - int size; - int renderer; - - void DeleteData(int index); - void AddItem(PopupHistoryData item); //adds a PopupHistoryData item - void RemoveItem(int index); - - public: - PopupHistoryList(int renderer = RENDER_DEFAULT); - ~PopupHistoryList(); - - int GetRenderer() { return renderer; } - void SetRenderer(int newRenderer) { renderer = newRenderer; } - - void Add(char *title, char *message, time_t timestamp); - void Add(wchar_t *title, wchar_t *message, time_t timestamp); - - PopupHistoryData *Get(int index); - - void Clear(); - int Count() { return count; } - int Size() { return size; } -}; - -/*Shows a history with the last popups. -Useful if you've missed a popup when it appeared. -wParam - 0 -lParam - 0 -*/ -#define MS_POPUP_SHOWHISTORY "PopUp/ShowHistory" - -extern PopupHistoryList lstPopupHistory; //defined in main.cpp -extern HWND hHistoryWindow; //the history window -extern HICON hiPopupHistory; -void RefreshPopupHistory(HWND hWnd, int renderer); - -INT_PTR CALLBACK DlgProcHistLst(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -#endif //__popup_history_h__ diff --git a/plugins/YAPP/popup_history_dlg.cpp b/plugins/YAPP/popup_history_dlg.cpp deleted file mode 100644 index e192139c8a..0000000000 --- a/plugins/YAPP/popup_history_dlg.cpp +++ /dev/null @@ -1,743 +0,0 @@ -#include "common.h" -#include "resource.h" -#include "popup_history.h" - -//************ Some helper resize stuff ****************** - -#define MIN_HISTORY_WIDTH 540 -#define MIN_HISTORY_HEIGHT 300 - -#define GAP_SIZE 2 - -#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 - -WNDPROC oldPopupsListProc = NULL; - -HWND hHistoryWindow = 0; //the history window -HICON hiPopupHistory; //popup history icon -PopupHistoryList lstPopupHistory; //defined in main.cpp - -const TCHAR *szHistoryColumns[] = {_T("Title"), _T("Message"), _T("Timestamp")}; //need to make sure that the string and size vectors have the same number of elements -const int cxHistoryColumns[] = {100, 450, 115}; -const int cHistoryColumns = sizeof(szHistoryColumns) / sizeof(szHistoryColumns[0]); - -struct PopupHistoryWindowData{ - HWND hIEView; -}; - -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; -} - -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; -} - -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); -} - -void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOWPOS *wndPos, int anchors) -{ - RECT rChild = AnchorCalcPos(window, rParent, wndPos, anchors); - hdWnds = DeferWindowPos(hdWnds, window, HWND_NOTOPMOST, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, SWP_NOZORDER); -} -//************************************************************ - -//Stucture passed to list sort function -struct SortParams{ - HWND hList; - int column; -}; - -static int lastColumn = -1; //last sort column - -int MatchesFilterCS(const TCHAR *filter, const PopupHistoryData *popupItem) //case sensitive -{ - if (_tcslen(filter) <= 0) { return 1; } //if no filter is set then the popup item matches the filter - int match = 0; - - match = (_tcsstr(popupItem->messageT, filter)) ? 1 : match; //check message part - - if (!match) //check title part of no match has been found - { - match = (_tcsstr(popupItem->titleT, filter)) ? 1 : match; - } - - if (!match) //if no match has been found yet try to match the timestamp - { - TCHAR buffer[1024]; - struct tm *myTime = localtime(&popupItem->timestamp); - _tcsftime(buffer, 1024, _T("%c"), myTime); - match = (_tcsstr(buffer, filter)) ? 1 : match; - } - - return match; -} - -__inline void ConvertCase(TCHAR *dest, const TCHAR *source, size_t size) -{ - _tcsncpy(dest, source, size); - _tcslwr(dest); -} - -int MatchesFilterCI(const TCHAR *filterS, const PopupHistoryData *popupItem) -{ - if (_tcslen(filterS) <= 0) { return 1; } //if no filter is set then the popup item matches the filter - int match = 0; - const int BUFFER_SIZE = 1024; - TCHAR buffer[BUFFER_SIZE]; - TCHAR filterI[BUFFER_SIZE]; - - ConvertCase(filterI, filterS, BUFFER_SIZE); - - ConvertCase(buffer, popupItem->messageT, BUFFER_SIZE); //check message part - match = (_tcsstr(buffer, filterI)) ? 1 : match; - - if (!match) // check title part of no match has been found - { - ConvertCase(buffer, popupItem->titleT, BUFFER_SIZE); - match = (_tcsstr(buffer, filterI)) ? 1 : match; - } - - if (!match) //if no match has been found yet try to match the timestamp - { - struct tm *myTime = localtime(&popupItem->timestamp); - _tcsftime(buffer, 1024, _T("%c"), myTime); - match = (_tcsstr(buffer, filterI)) ? 1 : match; - } - - return match; -} - -int CALLBACK PopupsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam) -{ - SortParams params = *(SortParams *) myParam; - const int MAX_SIZE = 512; - TCHAR text1[MAX_SIZE]; - TCHAR text2[MAX_SIZE]; - int res; - - ListView_GetItemText(params.hList, (int) lParam1, params.column, text1, MAX_SIZE); - ListView_GetItemText(params.hList, (int) lParam2, params.column, text2, MAX_SIZE); - - res = _tcsicmp(text1, text2); - - res = (params.column == lastColumn) ? -res : res; //do reverse search on second click on same column - - return res; -} - - - -int CalcCustomControlPos(IEVIEWWINDOW *ieWnd, HWND hMainWindow) -{ - RECT rect; - GetWindowRect(GetDlgItem(hMainWindow, IDC_LST_HISTORY), &rect); - ScreenToClient(hMainWindow, &rect); - //GetClientRect(hMainWindow, &rect); - - ieWnd->x = rect.left + GAP_SIZE; - ieWnd->y = rect.top + GAP_SIZE; - ieWnd->cx = rect.right - rect.left - (2 * GAP_SIZE); - ieWnd->cy = rect.bottom - rect.top - (2 * GAP_SIZE); - return 0; -} - -void MoveCustomControl(HWND hWnd, int renderer) -{ - switch (renderer) - { - case RENDER_HISTORYPP: - case RENDER_IEVIEW: - { - PopupHistoryWindowData *data = (PopupHistoryWindowData *) GetWindowLongPtr(hWnd, GWLP_USERDATA); - if (data) - { - IEVIEWWINDOW ieWnd = {0}; - ieWnd.cbSize = sizeof(ieWnd); - ieWnd.parent = hWnd; - ieWnd.hwnd = data->hIEView; - ieWnd.iType = IEW_SETPOS; - CalcCustomControlPos(&ieWnd, hWnd); - - CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_WINDOW : MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd); - } - - break; - } - } -} - -void LoadRenderer(HWND hWnd, int renderer) -{ - switch (renderer) - { - case RENDER_HISTORYPP: - case RENDER_IEVIEW: - { - IEVIEWWINDOW ieWnd = {0}; - - ieWnd.cbSize = sizeof(ieWnd); - ieWnd.iType = IEW_CREATE; - ieWnd.dwMode = IEWM_HISTORY; - ieWnd.dwFlags = 0; - ieWnd.parent = hWnd; - CalcCustomControlPos(&ieWnd, hWnd); - - CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_WINDOW : MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd); //create the IeView or H++ control. - - PopupHistoryWindowData *data = (PopupHistoryWindowData *) mir_alloc(sizeof(PopupHistoryWindowData)); //create custom control data - data->hIEView = ieWnd.hwnd; - ShowWindow(data->hIEView, SW_SHOW); - SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) data); //set it as the window's user data - ShowWindow(GetDlgItem(hWnd, IDC_LST_HISTORY), SW_HIDE); - //SetWindowPos(GetDlgItem(hWnd, IDC_LST_HISTORY), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - - break; - } - } -} - -void UnloadRenderer(HWND hWnd, int renderer) -{ - switch (renderer) - { - case RENDER_HISTORYPP: - case RENDER_IEVIEW: - { - PopupHistoryWindowData *data = (PopupHistoryWindowData *) GetWindowLongPtr(hWnd, GWLP_USERDATA); - - if (data) - { - IEVIEWWINDOW ieWnd = {0}; - ieWnd.cbSize = sizeof(ieWnd); - ieWnd.parent = hWnd; - ieWnd.hwnd = data->hIEView; - ieWnd.iType = IEW_DESTROY; - CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_WINDOW : MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd); - - mir_free(data); - } - - break; - } - } -} - -void DeleteOldEvents(HWND hWnd, int renderer) -{ - switch (renderer) - { - case RENDER_HISTORYPP: - case RENDER_IEVIEW: - { - PopupHistoryWindowData *data = (PopupHistoryWindowData *) GetWindowLongPtr(hWnd, GWLP_USERDATA); - if (data) - { - IEVIEWEVENT ieEvent = {0}; - ieEvent.cbSize = sizeof(IEVIEWEVENT); - ieEvent.hwnd = data->hIEView; - ieEvent.iType = IEE_CLEAR_LOG; - - CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_EVENT : MS_IEVIEW_EVENT, 0, (LPARAM) &ieEvent); - } - - break; - } - - case RENDER_DEFAULT: - default: - { - ListView_DeleteAllItems(GetDlgItem(hWnd, IDC_LST_HISTORY)); - - break; - } - - } -} - -typedef int (*SIG_MATCHESFILTER)(const TCHAR *filter, const PopupHistoryData *popupItem); -typedef void (*SIG_ADDEVENTS)(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHESFILTER MatchesFilter); - -IEVIEWEVENTDATA *CreateAndFillEventData(PopupHistoryData *popupItem) -{ - IEVIEWEVENTDATA *eventData = (IEVIEWEVENTDATA *) mir_calloc(sizeof(IEVIEWEVENTDATA)); - if (eventData) - { - eventData->cbSize = sizeof(IEVIEWEVENTDATA); - eventData->iType = IEED_EVENT_MESSAGE; - - eventData->dwFlags = IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT | IEEDF_UNICODE_TEXT2; - eventData->pszNickW = popupItem->titleT; - eventData->pszTextW = popupItem->messageT; - - eventData->time = (DWORD) popupItem->timestamp; - eventData->next = NULL; - } - - return eventData; -} - -void AddEventsCustomControl(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHESFILTER MatchesFilter) -{ - PopupHistoryWindowData *pwData = (PopupHistoryWindowData *) GetWindowLongPtr(hWnd, GWLP_USERDATA); - if (pwData) - { - IEVIEWEVENT ieEvent = {0}; - ieEvent.cbSize = sizeof(IEVIEWEVENT); - ieEvent.hwnd = pwData->hIEView; - ieEvent.codepage = CP_ACP; - ieEvent.iType = IEE_LOG_MEM_EVENTS; - ieEvent.hContact = NULL;//(HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); IEVIEW needs a contact handle !! - - IEVIEWEVENTDATA *eventData = NULL; - IEVIEWEVENTDATA *cED = NULL; - IEVIEWEVENTDATA *prevED = NULL; - - int i; - int count = 0; - int size = lstPopupHistory.Count(); - PopupHistoryData *popupItem; - - for (i = 0; i < size; i++) - { - popupItem = lstPopupHistory.Get(i); - if (MatchesFilter(filter, popupItem)) - { - cED = CreateAndFillEventData(popupItem); - if (cED) - { - count++; - if (!eventData) - { - eventData = cED; - } - else{ - prevED->next = cED; - } - - prevED = cED; - } - } - } - ieEvent.count = count; - ieEvent.eventData = eventData; - - CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_EVENT : MS_IEVIEW_EVENT, 0, (LPARAM) &ieEvent); - - while (eventData) - { - cED = eventData; - eventData = eventData->next; - mir_free(cED); - } - } -} - -void AddEventsDefault(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHESFILTER MatchesFilter) -{ - HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY); - TCHAR buffer[1024]; - struct tm *myTime; - - LVITEM item = {0}; - item.mask = LVIF_TEXT; - - int i, lIndex; - lIndex = 0; - PopupHistoryData *popupItem; - for (i = 0; i < lstPopupHistory.Count(); i++) - { - item.iItem = lIndex; - popupItem = lstPopupHistory.Get(i); - if (MatchesFilter(filter, popupItem)) - { - item.pszText = popupItem->titleT; - ListView_InsertItem(hHistoryList, &item); - ListView_SetItemText(hHistoryList, lIndex, 1, popupItem->messageT); - myTime = localtime(&popupItem->timestamp); - _tcsftime(buffer, 1024, _T("%c"), myTime); - ListView_SetItemText(hHistoryList, lIndex++, 2, buffer); - } - } -} - -void RefreshPopupHistory(HWND hWnd, int renderer) -{ - if (!hWnd) { return; } - const int MAX_FILTER_SIZE = 1024; - SIG_MATCHESFILTER MatchesFilter = (IsDlgButtonChecked(hWnd, IDC_HISTORY_FILTER_CASESENSITIVE)) ? MatchesFilterCS : MatchesFilterCI; //case sensitive compare or not ? - - SIG_ADDEVENTS AddEvents = (renderer == RENDER_DEFAULT) ? AddEventsDefault : AddEventsCustomControl; - - TCHAR filter[MAX_FILTER_SIZE]; - DeleteOldEvents(hWnd, renderer); //delete events - - GetWindowText(GetDlgItem(hWnd, IDC_HISTORY_FILTER), filter, MAX_FILTER_SIZE); //get filter text - - AddEvents(hWnd, renderer, filter, MatchesFilter); - - if (renderer == RENDER_DEFAULT) - { - HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY); - SortParams params = {0}; - params.hList = hHistoryList; - params.column = lastColumn; - - ListView_SortItemsEx(hHistoryList, PopupsCompare, ¶ms); - } -} - -void CopyPopupDataToClipboard(HWND hList, int selection) -{ - if (!selection) - { - return; - } - - if (!GetOpenClipboardWindow()) - { - if (OpenClipboard(hList)) - { - TCHAR buffer[2048]; - buffer[0] = _T('\0'); - TCHAR *clipboard; - int i; - int found = 0; - int count = ListView_GetItemCount(hList); - int textType; - - textType = CF_UNICODETEXT; - - - for (i = 0; i < count; i++) - { - if (ListView_GetItemState(hList, i, LVIS_SELECTED)) - { - ListView_GetItemText(hList, i, selection - 100, buffer, 2048); - found = 1; - break; - } - } - if (found) - { - EmptyClipboard(); - int len = (int)_tcslen(buffer); - - HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, (len + 2) * sizeof(TCHAR)); - clipboard = (TCHAR *) GlobalLock(hData); - _tcsncpy(clipboard, buffer, len); - clipboard[len] = _T('\0'); - GlobalUnlock(hData); - if (!SetClipboardData(textType, hData)) - { - PUShowMessage("Could not set clipboard data", SM_WARNING); - } - } - CloseClipboard(); - } - else{ - PUShowMessage("Could not open clipboard", SM_WARNING); - } - } - else{ - PUShowMessage("The clipboard is not available", SM_WARNING); - } -} - -//subclass proc for the list view -BOOL CALLBACK PopupsListSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_CONTEXTMENU: - { - int x = LOWORD(lParam); - int y = HIWORD(lParam); - int selection; - - HMENU hMenu = CreatePopupMenu(); - AppendMenu(hMenu, MF_STRING, POPUPMENU_TITLE, TranslateT("Copy title to clipboard")); - AppendMenu(hMenu, MF_STRING, POPUPMENU_MESSAGE, TranslateT("Copy message to clipboard")); - AppendMenu(hMenu, MF_STRING, POPUPMENU_TIMESTAMP, TranslateT("Copy timestamp to clipboard")); - selection = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, x, y, 0, hWnd, NULL); - DestroyMenu(hMenu); - if (selection) - { - CopyPopupDataToClipboard(hWnd, selection); - } - - break; - } - - case WM_KEYUP: - { - switch (wParam) - { - case 'C': - { - if (GetKeyState(VK_CONTROL)) - { - CopyPopupDataToClipboard(hWnd, POPUPMENU_MESSAGE); - } - - break; - } - - case VK_ESCAPE: - { - SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); - - break; - } - - } - - break; - } - - case WM_SYSKEYDOWN: - { - if (wParam == 'X') - { - SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); - } - - break; - } - } - - return CallWindowProc(oldPopupsListProc, hWnd, msg, wParam, lParam); -} - -//load the columns -void LoadHistoryColumns(HWND hHistoryList) -{ - LVCOLUMN col; - col.mask = LVCF_TEXT | LVCF_WIDTH; - int i; - - for (i = 0; i < cHistoryColumns; i++) - { - col.pszText = TranslateTS(szHistoryColumns[i]); - col.cx = cxHistoryColumns[i]; - ListView_InsertColumn(hHistoryList, i, &col); - } -} - -//this is the history list window handler -INT_PTR CALLBACK DlgProcHistLst(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static int bInitializing; - - switch (msg) - { - case WM_INITDIALOG: - { - bInitializing = 1; - int renderer = lstPopupHistory.GetRenderer(); - - SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiPopupHistory); - - LoadRenderer(hWnd, renderer); - - TranslateDialogDefault(hWnd); - HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY); - - ListView_SetExtendedListViewStyleEx(hHistoryList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); - - oldPopupsListProc = (WNDPROC) SetWindowLongPtr(hHistoryList, GWLP_WNDPROC, (LONG_PTR) PopupsListSubclassProc); - - LoadHistoryColumns(hHistoryList); - - RefreshPopupHistory(hWnd, renderer); - - bInitializing = 0; - - return TRUE; - } - - case WM_DESTROY: - { - UnloadRenderer(hWnd, lstPopupHistory.GetRenderer()); - hHistoryWindow = NULL; - - break; - } - - case WM_CLOSE: - { - //Utils_SaveWindowPosition(hWnd, 0, MODULE, "history_dlg"); - DestroyWindow(hWnd); - - break; - } - - case WM_WINDOWPOSCHANGING: - { - WINDOWPOS *wndPos = (WINDOWPOS *) lParam; - - if (wndPos->cx < MIN_HISTORY_WIDTH) - { - wndPos->cx = MIN_HISTORY_WIDTH; - } - if (wndPos->cy < MIN_HISTORY_HEIGHT) - { - wndPos->cy = MIN_HISTORY_HEIGHT; - } - - RECT rParent; - GetWindowRect(hWnd, &rParent); - HDWP hdWnds = BeginDeferWindowPos(4); - - AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_RIGHT | ANCHOR_BOTTOM); - AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_HISTORY_FILTER), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_BOTTOM); - AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_HISTORY_FILTER_CASESENSITIVE), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_RIGHT | ANCHOR_BOTTOM); - AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_LST_HISTORY), &rParent, wndPos, ANCHOR_ALL); - - EndDeferWindowPos(hdWnds); - MoveCustomControl(hWnd, lstPopupHistory.GetRenderer()); //move the custom control too, if any - break; - } - - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_CLOSE: - { - SendMessage(hWnd, WM_CLOSE, 0, 0); - - break; - } - - case IDC_HISTORY_FILTER_CASESENSITIVE: - { - if (HIWORD(wParam) == BN_CLICKED) - { - RefreshPopupHistory(hWnd, lstPopupHistory.GetRenderer()); - } - } - - case IDC_HISTORY_FILTER: - { - if (HIWORD(wParam) == EN_CHANGE) - { - if (!bInitializing) - { - RefreshPopupHistory(hWnd, lstPopupHistory.GetRenderer()); - } - } - - break; - } - - } - - break; - } - - case WM_NOTIFY: - { - switch(((LPNMHDR)lParam)->idFrom) - { - case IDC_LST_HISTORY: - { - switch (((LPNMHDR)lParam)->code) - { - case LVN_COLUMNCLICK: - { - LPNMLISTVIEW lv = (LPNMLISTVIEW) lParam; - int column = lv->iSubItem; - SortParams params = {0}; - params.hList = GetDlgItem(hWnd, IDC_LST_HISTORY); - params.column = column; - - ListView_SortItemsEx(params.hList, PopupsCompare, (LPARAM) ¶ms); - lastColumn = (params.column == lastColumn) ? -1 : params.column; - - break; - } - } - - break; - } - } - - break; - } - } - - return 0; -} diff --git a/plugins/YAPP/popups2.cpp b/plugins/YAPP/popups2.cpp deleted file mode 100644 index 5c6fd9261f..0000000000 --- a/plugins/YAPP/popups2.cpp +++ /dev/null @@ -1,241 +0,0 @@ -// popups2.cpp : Defines the entry point for the DLL application. -// - -#include "common.h" -#include "popups2.h" -#include "version.h" -#include "message_pump.h" -#include "options.h" -#include "popwin.h" -#include "notify.h" - -#include "popup_history.h" //to be able to update the renderer - -HMODULE hInst = 0; - -MNOTIFYLINK *notifyLink = 0; - -// used to work around a bug in neweventnotify and others with the address passed in the GetPluginData function -bool ignore_gpd_passed_addy = false; - -FontID font_id_firstline = {0}, font_id_secondline = {0}, font_id_time = {0}; -ColourID colour_id_bg = {0}, colour_id_border = {0}, colour_id_sidebar = {0}, colour_id_titleunderline = {0}; -FontIDW font_id_firstlinew = {0}, font_id_secondlinew = {0}, font_id_timew = {0}; -ColourIDW colour_id_bgw = {0}, colour_id_borderw = {0}, colour_id_sidebarw = {0}, colour_id_titleunderlinew = {0}; - -COLORREF colBg = GetSysColor(COLOR_3DSHADOW); -HFONT hFontFirstLine = 0, hFontSecondLine = 0, hFontTime = 0; -COLORREF colFirstLine = RGB(255, 0, 0), colSecondLine = 0, colTime = RGB(0, 0, 255), colBorder = RGB(0, 0, 0), - colSidebar = RGB(128, 128, 128), colTitleUnderline = GetSysColor(COLOR_3DSHADOW); -int hLangpack; - -PLUGININFOEX pluginInfo={ - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __DESC, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - { 0xefd15f16, 0x7ae4, 0x40d7, { 0xa8, 0xe3, 0xa4, 0x11, 0xed, 0x74, 0x7b, 0xd5 } } // {EFD15F16-7AE4-40d7-A8E3-A411ED747BD5} -}; - - - - -extern "C" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) -{ - hInst = hModule; - DisableThreadLibraryCalls(hInst); - return TRUE; -} - -extern "C" POPUPS2_API PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_POPUPS, MIID_LAST}; - -int ReloadFont(WPARAM wParam, LPARAM lParam) -{ - - if(ServiceExists(MS_FONT_GETW)) { - LOGFONTW log_font; - if(hFontFirstLine) DeleteObject(hFontFirstLine); - colFirstLine = CallService(MS_FONT_GETW, (WPARAM)&font_id_firstlinew, (LPARAM)&log_font); - hFontFirstLine = CreateFontIndirectW(&log_font); - if(hFontSecondLine) DeleteObject(hFontSecondLine); - colSecondLine = CallService(MS_FONT_GETW, (WPARAM)&font_id_secondlinew, (LPARAM)&log_font); - hFontSecondLine = CreateFontIndirectW(&log_font); - if(hFontTime) DeleteObject(hFontTime); - colTime = CallService(MS_FONT_GETW, (WPARAM)&font_id_timew, (LPARAM)&log_font); - hFontTime = CreateFontIndirectW(&log_font); - - colBg = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_bgw, 0); - colBorder = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_borderw, 0); - colSidebar = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_sidebarw, 0); - colTitleUnderline = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_titleunderlinew, 0); - } else - - { - LOGFONTA log_font; - if(hFontFirstLine) DeleteObject(hFontFirstLine); - colFirstLine = CallService(MS_FONT_GET, (WPARAM)&font_id_firstline, (LPARAM)&log_font); - hFontFirstLine = CreateFontIndirectA(&log_font); - if(hFontSecondLine) DeleteObject(hFontSecondLine); - colSecondLine = CallService(MS_FONT_GET, (WPARAM)&font_id_secondline, (LPARAM)&log_font); - hFontSecondLine = CreateFontIndirectA(&log_font); - if(hFontTime) DeleteObject(hFontTime); - colTime = CallService(MS_FONT_GET, (WPARAM)&font_id_time, (LPARAM)&log_font); - hFontTime = CreateFontIndirectA(&log_font); - - colBg = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_bg, 0); - colBorder = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_border, 0); - colSidebar = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_sidebar, 0); - colTitleUnderline = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_titleunderline, 0); - } - - return 0; -} - -HANDLE hEventReloadFont = 0; - -int ModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - MNotifyGetLink(); - - if (ServiceExists(MS_HPP_EG_WINDOW)) - lstPopupHistory.SetRenderer(RENDER_HISTORYPP); - - font_id_firstlinew.cbSize = sizeof(FontIDW); - font_id_firstlinew.flags = FIDF_ALLOWEFFECTS; - _tcscpy(font_id_firstlinew.group, _T("Popups")); - _tcscpy(font_id_firstlinew.name, _T("First line")); - strcpy(font_id_firstlinew.dbSettingsGroup, MODULE); - strcpy(font_id_firstlinew.prefix, "FontFirst"); - _tcscpy(font_id_firstlinew.backgroundGroup, _T("Popups")); - _tcscpy(font_id_firstlinew.backgroundName, _T("Background")); - font_id_firstlinew.order = 0; - FontRegisterT(&font_id_firstlinew); - - font_id_secondlinew.cbSize = sizeof(FontIDW); - font_id_secondlinew.flags = FIDF_ALLOWEFFECTS; - _tcscpy(font_id_secondlinew.group, _T("Popups")); - _tcscpy(font_id_secondlinew.name, _T("Second line")); - strcpy(font_id_secondlinew.dbSettingsGroup, MODULE); - strcpy(font_id_secondlinew.prefix, "FontSecond"); - _tcscpy(font_id_secondlinew.backgroundGroup, _T("Popups")); - _tcscpy(font_id_secondlinew.backgroundName, _T("Background")); - font_id_secondlinew.order = 1; - FontRegisterT(&font_id_secondlinew); - - font_id_timew.cbSize = sizeof(FontIDW); - font_id_timew.flags = FIDF_ALLOWEFFECTS; - _tcscpy(font_id_timew.group, _T("Popups")); - _tcscpy(font_id_timew.name, _T("Time")); - strcpy(font_id_timew.dbSettingsGroup, MODULE); - strcpy(font_id_timew.prefix, "FontTime"); - _tcscpy(font_id_timew.backgroundGroup, _T("Popups")); - _tcscpy(font_id_timew.backgroundName, _T("Background")); - font_id_timew.order = 2; - FontRegisterT(&font_id_timew); - - colour_id_bgw.cbSize = sizeof(ColourIDW); - _tcscpy(colour_id_bgw.group, _T("Popups")); - _tcscpy(colour_id_bgw.name, _T("Background")); - strcpy(colour_id_bgw.dbSettingsGroup, MODULE); - strcpy(colour_id_bgw.setting, "ColourBg"); - colour_id_bgw.defcolour = GetSysColor(COLOR_3DSHADOW); - colour_id_bgw.order = 0; - ColourRegisterT(&colour_id_bgw); - - colour_id_borderw.cbSize = sizeof(ColourIDW); - _tcscpy(colour_id_borderw.group, _T("Popups")); - _tcscpy(colour_id_borderw.name, _T("Border")); - strcpy(colour_id_borderw.dbSettingsGroup, MODULE); - strcpy(colour_id_borderw.setting, "ColourBorder"); - colour_id_borderw.defcolour = RGB(0, 0, 0); - colour_id_borderw.order = 1; - ColourRegisterT(&colour_id_borderw); - - colour_id_sidebarw.cbSize = sizeof(ColourIDW); - _tcscpy(colour_id_sidebarw.group, _T("Popups")); - _tcscpy(colour_id_sidebarw.name, _T("Sidebar")); - strcpy(colour_id_sidebarw.dbSettingsGroup, MODULE); - strcpy(colour_id_sidebarw.setting, "ColourSidebar"); - colour_id_sidebarw.defcolour = RGB(128, 128, 128); - colour_id_sidebarw.order = 2; - ColourRegisterT(&colour_id_sidebarw); - - colour_id_titleunderlinew.cbSize = sizeof(ColourIDW); - _tcscpy(colour_id_titleunderlinew.group, _T("Popups")); - _tcscpy(colour_id_titleunderlinew.name, _T("Title underline")); - strcpy(colour_id_titleunderlinew.dbSettingsGroup, MODULE); - strcpy(colour_id_titleunderlinew.setting, "ColourTitleUnderline"); - colour_id_titleunderlinew.defcolour = GetSysColor(COLOR_3DSHADOW); - colour_id_titleunderlinew.order = 3; - ColourRegisterT(&colour_id_titleunderlinew); - - ReloadFont(0, 0); - - hEventReloadFont = HookEvent(ME_FONT_RELOAD, ReloadFont); - - LoadModuleDependentOptions(); - - if(GetModuleHandle(_T("neweventnotify"))) - ignore_gpd_passed_addy = true; - - return 0; -} - -int PreShutdown(WPARAM wParam, LPARAM lParam) { - DeinitMessagePump(); - DeinitNotify(); - return 0; -} - -HANDLE hEventPreShutdown, hEventModulesLoaded; - -extern "C" int POPUPS2_API Load(void) { - - mir_getLP(&pluginInfo); - - InitMessagePump(); - InitOptions(); - InitNotify(); - - hEventPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); - hEventModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); - - /* - // test popup classes - PopupClass test = {0}; - test.cbSize = sizeof(test); - test.flags = PCF_TCHAR; - test.hIcon = LoadIcon(0, IDI_WARNING); - test.colorBack = RGB(0, 0, 0); - test.colorText = RGB(255, 255, 255); - test.iSeconds = 10; - test.ptszDescription = TranslateT("Test popup class"); - test.pszName = "popup/testclass"; - CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&test); - */ - - return 0; -} - -extern "C" int POPUPS2_API Unload() -{ - if(hEventReloadFont) - UnhookEvent(hEventReloadFont); - UnhookEvent(hEventPreShutdown); - UnhookEvent(hEventModulesLoaded); - DeinitNotify(); - DeleteObject(hFontFirstLine); - DeleteObject(hFontSecondLine); - DeleteObject(hFontTime); - return 0; -} diff --git a/plugins/YAPP/popups2.h b/plugins/YAPP/popups2.h deleted file mode 100644 index 59e4f89baf..0000000000 --- a/plugins/YAPP/popups2.h +++ /dev/null @@ -1,12 +0,0 @@ -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the POPUPS2_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// POPUPS2_API functions as being imported from a DLL, whereas this DLL sees symbols -// defined with this macro as being exported. -#ifdef POPUPS2_EXPORTS -#define POPUPS2_API __declspec(dllexport) -#else -#define POPUPS2_API __declspec(dllimport) -#endif - diff --git a/plugins/YAPP/popups2.rc b/plugins/YAPP/popups2.rc deleted file mode 100644 index c59e253ff2..0000000000 --- a/plugins/YAPP/popups2.rc +++ /dev/null @@ -1,207 +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 - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (Australia) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_LST_HISTORY DIALOGEX 0, 0, 467, 303 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "Popup history" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - PUSHBUTTON "Close",IDC_CLOSE,413,285,50,14 - CONTROL "",IDC_LST_HISTORY,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,4,3,459,278 - EDITTEXT IDC_HISTORY_FILTER,4,285,176,14,ES_AUTOHSCROLL - CONTROL "Case sensitive",IDC_HISTORY_FILTER_CASESENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,185,287,222,10 -END - -IDD_OPT1 DIALOGEX 0, 0, 297, 218 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Default Timeout",IDC_STATIC,4,7,153,36 - CONTROL "Never timeout",IDC_RAD_NOTIMEOUT,"Button",BS_AUTORADIOBUTTON | BS_LEFTTEXT | WS_GROUP,10,16,77,10,WS_EX_RIGHT - CONTROL "Set timeout:",IDC_RAD_TIMEOUT,"Button",BS_AUTORADIOBUTTON | BS_LEFTTEXT,10,28,77,10,WS_EX_RIGHT - EDITTEXT IDC_ED_TIMEOUT,93,26,40,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_TIMEOUT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,131,26,12,14 - EDITTEXT IDC_ED_WIDTH,238,84,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_WIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,84,12,14 - EDITTEXT IDC_ED_MAXHEIGHT,238,102,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_MAXHEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,102,12,14 - RTEXT "Width:",IDC_STATIC,174,87,60,8,0,WS_EX_RIGHT - RTEXT "Maximum height:",IDC_STATIC,174,104,60,8,0,WS_EX_RIGHT - GROUPBOX "Options",IDC_STATIC,4,116,153,94 - EDITTEXT IDC_ED_TRANS,97,183,33,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_TRANS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,126,183,13,12 - RTEXT "Opacity(%):",IDC_STATIC,11,186,84,8,0,WS_EX_RIGHT - CONTROL "Border",IDC_CHK_BORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,127,121,10 - CONTROL "Round corners (window)",IDC_CHK_ROUNDCORNERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,138,121,10 - PUSHBUTTON "Preview",IDC_BTN_PREVIEW,161,194,130,17 - CONTROL "Animate",IDC_CHK_ANIMATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,160,121,10 - CONTROL "Transparent background",IDC_CHK_TRANSBG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,199,121,10 - GROUPBOX "Layout",IDC_STATIC,161,7,129,184 - RTEXT "Avatar size:",IDC_STATIC,174,122,60,8,0,WS_EX_RIGHT - EDITTEXT IDC_ED_AVSIZE,238,120,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_AVSIZE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,120,12,14 - GROUPBOX "Disable when",IDC_STATIC,4,44,153,70 - CONTROL "",IDC_LST_STATUS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,54,148,56 - COMBOBOX IDC_CMB_PLACEMENT,165,19,120,68,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_CMB_ICON,165,36,120,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_CMB_AV,165,53,120,76,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Global hover",IDC_CHK_GLOBALHOVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,171,121,10 - COMBOBOX IDC_CMB_TIME,165,69,120,76,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - EDITTEXT IDC_ED_SBWIDTH,238,138,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_SBWIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,138,11,14 - RTEXT "Sidebar width:",IDC_STATIC,174,141,60,8 - EDITTEXT IDC_ED_INDENT,238,156,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_INDENT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,269,156,12,14 - RTEXT "Text indent:",IDC_STATIC,174,160,60,8 - EDITTEXT IDC_ED_PADDING,238,173,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT - CONTROL "",IDC_SPIN_PADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,173,12,14 - RTEXT "Padding:",IDC_STATIC,174,176,60,8 - CONTROL "Round corners (avatar)",IDC_CHK_ROUNDCORNERSAV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,149,121,10 -END - -IDD_OPT_NOTIFY DIALOGEX 0, 0, 187, 91 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN -END - -IDD_CLASSES DIALOGEX 0, 0, 294, 223 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LISTBOX IDC_LST_CLASSES,7,18,102,184,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - RTEXT "Text colour:",IDC_STATIC,136,66,80,8 - RTEXT "Background colour:",IDC_STATIC,136,88,80,8 - CONTROL "Set timeout",IDC_CHK_TIMEOUT,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,144,122,99,10 - RTEXT "Timeout value (0 = default):",IDC_STATIC,114,143,121,8 - EDITTEXT IDC_ED_TIMEOUT,243,140,43,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED - CONTROL "Custom1",IDC_COL_TEXT,"ColourPicker",WS_DISABLED | WS_TABSTOP,243,61,44,17 - CONTROL "Custom1",IDC_COL_BG,"ColourPicker",WS_DISABLED | WS_TABSTOP,243,82,44,17 - PUSHBUTTON "Preview",IDC_BTN_PREVIEW,141,178,130,17,WS_DISABLED -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPT1, DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 290 - TOPMARGIN, 7 - BOTTOMMARGIN, 211 - END - - IDD_OPT_NOTIFY, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 180 - TOPMARGIN, 7 - BOTTOMMARGIN, 84 - END - - IDD_CLASSES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 287 - TOPMARGIN, 7 - BOTTOMMARGIN, 216 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_POPUP_HISTORY ICON "PPh2.ico" -#endif // English (Australia) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/YAPP/popups2_10.vcxproj b/plugins/YAPP/popups2_10.vcxproj deleted file mode 100644 index 0d65a05078..0000000000 --- a/plugins/YAPP/popups2_10.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - YAPP - {B6FC188B-8E54-4197-9444-8BADE9AA75E2} - - - - DynamicLibrary - Unicode - true - - - DynamicLibrary - Unicode - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - Unicode - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - true - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;POPUPS2_EXPORTS;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - common.h - Level3 - EditAndContinue - 4996;%(DisableSpecificWarnings) - Use - - - true - Windows - false - $(IntDir)$(TargetName).lib - $(SolutionDir)\lib - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - - - Full - OnlyExplicitInline - Size - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;POPUPS2_EXPORTS;%(PreprocessorDefinitions) - true - false - Fast - common.h - Level3 - 4996;%(DisableSpecificWarnings) - Use - - - true - Windows - true - true - false - $(IntDir)$(TargetName).lib - $(SolutionDir)\lib - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - - - Full - OnlyExplicitInline - Size - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;POPUPS2_EXPORTS;%(PreprocessorDefinitions) - true - Level3 - Use - common.h - - - true - true - $(IntDir)$(TargetName).lib - true - Windows - false - $(SolutionDir)\lib - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - - - EnableFastChecks - MultiThreadedDebugDLL - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;POPUPS2_EXPORTS;%(PreprocessorDefinitions) - Disabled - Level3 - Use - common.h - - - $(IntDir)$(TargetName).lib - false - true - Windows - $(SolutionDir)\lib - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/YAPP/popups2_10.vcxproj.filters b/plugins/YAPP/popups2_10.vcxproj.filters deleted file mode 100644 index a3fc3c5946..0000000000 --- a/plugins/YAPP/popups2_10.vcxproj.filters +++ /dev/null @@ -1,83 +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 - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/plugins/YAPP/popwin.cpp b/plugins/YAPP/popwin.cpp deleted file mode 100644 index 682a3f7b05..0000000000 --- a/plugins/YAPP/popwin.cpp +++ /dev/null @@ -1,772 +0,0 @@ -#include "common.h" -#include "popwin.h" -#include "message_pump.h" -#include "options.h" - -HMODULE hUserDll; -BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD) = 0; -BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags) = 0; -HMONITOR (WINAPI *MyMonitorFromRect)(LPCRECT rect, DWORD flags) = 0; -BOOL (WINAPI *MyGetMonitorInfo)(HMONITOR hMonitor, LPMONITORINFO mi) = 0; - -#define ID_CLOSETIMER 0x0101 -#define ID_MOVETIMER 0x0102 - -DWORD pop_start_x, pop_start_y; -int global_mouse_in = 0; - -void trimW(wchar_t *str) { - int len = (int)wcslen(str), pos; - // trim whitespace (e.g. from OTR detection) - for(pos = len - 1; pos >= 0; pos--) { - if(str[pos] == L' ' || str[pos] == L'\t' || str[pos] == L'\r' || str[pos] == L'\n') str[pos] = 0; - else break; - } - - // remove tabs - for(pos = len - 1; pos >= 0; pos--) - if(str[pos] == L'\t') str[pos] = L' '; -} - -void SetStartValues(void) -{ - RECT wa_rect; - SystemParametersInfo(SPI_GETWORKAREA, 0, &wa_rect, 0); - if (options.use_mim_monitor && MyMonitorFromRect && MyGetMonitorInfo) - { - RECT clr; - GetWindowRect((HWND)CallService(MS_CLUI_GETHWND, 0, 0), &clr); - HMONITOR hMonitor = MyMonitorFromRect(&clr, MONITOR_DEFAULTTONEAREST); - if (hMonitor) - { - MONITORINFO mi; - mi.cbSize = sizeof(mi); - if (MyGetMonitorInfo(hMonitor, &mi)) - wa_rect = mi.rcWork; - } - } - - if(options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT) - pop_start_x = wa_rect.right - options.win_width - 1; - else - pop_start_x = wa_rect.left + 1; - - if(options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT) - pop_start_y = wa_rect.bottom - 1; - else - pop_start_y = wa_rect.top + 1; -} - -struct HWNDStackNode { - HWND hwnd; - struct HWNDStackNode *next; -}; - -HWNDStackNode *hwnd_stack_top = 0; -int stack_size = 0; - -void RepositionWindows() { - HWNDStackNode *current; - int x = pop_start_x, y = pop_start_y; - int height;//, total_height = 0; - - /* - current = hwnd_stack_top; - while(current) { - SendMessage(current->hwnd, PUM_GETHEIGHT, (WPARAM)&height, 0); - total_height += height; - current = current->next; - } - */ - - current = hwnd_stack_top; - while(current) { - SendMessage(current->hwnd, PUM_GETHEIGHT, (WPARAM)&height, 0); - if(options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT) y -= height + 1; - SendMessage(current->hwnd, PUM_MOVE, (WPARAM)x, (LPARAM)y); - if(options.location == PL_TOPRIGHT || options.location == PL_TOPLEFT) y += height + 1; - - current = current->next; - } -} - -void AddWindowToStack(HWND hwnd) { - SetStartValues(); - - HWNDStackNode *new_node = (HWNDStackNode *)mir_alloc(sizeof(HWNDStackNode)); - new_node->hwnd = hwnd; - new_node->next = hwnd_stack_top; - hwnd_stack_top = new_node; - - int height; - SendMessage(hwnd, PUM_GETHEIGHT, (WPARAM)&height, 0); - - int x = pop_start_x, y = pop_start_y; - if(options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT) - x += options.win_width; - else - x -= options.win_width; - - if(options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT) y -= height; - SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); - if(options.location == PL_TOPRIGHT || options.location == PL_TOPLEFT) y += height; - - stack_size++; - - RepositionWindows(); -} - -void RemoveWindowFromStack(HWND hwnd) { - HWNDStackNode *current = hwnd_stack_top, *prev = 0; - while(current) { - if(current->hwnd == hwnd) { - if(prev) { - prev->next = current->next; - } else { - hwnd_stack_top = current->next; - } - mir_free(current); - stack_size--; - break; - } - - prev = current; - current = current->next; - } - - if(hwnd_stack_top) RepositionWindows(); -} - -void ClearStack() { - while(hwnd_stack_top) { - DestroyWindow(hwnd_stack_top->hwnd); - } -} - -void BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam) { - HWNDStackNode *current = hwnd_stack_top; - while(current) { - SendMessage(current->hwnd, msg, wParam, lParam); - current = current->next; - } -} - -struct PopupWindowData { - PopupData *pd; - int new_x, new_y; - bool is_round, av_is_round, mouse_in, close_on_leave; - bool custom_col; - HBRUSH bkBrush, barBrush, underlineBrush; - HPEN bPen; - TCHAR tbuff[128]; - int tb_height, av_height, text_height, time_height, time_width; - int real_av_width, real_av_height; - bool have_av; - HANDLE hNotify; -}; - -LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - PopupWindowData *pwd = (PopupWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - PopupData *pd = 0; - if(pwd) pd = pwd->pd; - - switch(uMsg) { - case WM_CREATE: - { - CREATESTRUCT *cs = (CREATESTRUCT *)lParam; - pwd = (PopupWindowData *)mir_alloc(sizeof(PopupWindowData)); - pd = (PopupData *)cs->lpCreateParams; - pwd->pd = pd; - pwd->hNotify = 0; - - trimW(pwd->pd->pwzTitle); - trimW(pwd->pd->pwzText); - - pwd->is_round = options.round; - pwd->av_is_round = options.av_round; - pwd->mouse_in = pwd->close_on_leave = false; - pwd->custom_col = (pd->colorBack != pd->colorText); - - pwd->tb_height = pwd->av_height = pwd->text_height = pwd->time_height = pwd->time_width = 0; - pwd->have_av = false; - - if(pwd->custom_col) { - pwd->bkBrush = CreateSolidBrush(pd->colorBack); - - //pwd->barBrush = CreateSolidBrush(pd->colorBack / 2); // make sidebar a dark version of the bg - //DWORD darkBg = (((pd->colorBack & 0xff0000) >> 1) & 0xff0000) + (((pd->colorBack & 0xff00) >> 1) & 0xff00) + (((pd->colorBack & 0xff) >> 1) & 0xff); - //DWORD darkBg = (pdColorBack >> 1) & 0x7f7f7f; // equivalent to above :) - - DWORD darkBg = pd->colorBack - ((pd->colorBack >> 2) & 0x3f3f3f); // 3/4 of current individual RGB components - pwd->barBrush = CreateSolidBrush(darkBg); // make sidebar a dark version of the bg - pwd->underlineBrush = CreateSolidBrush(pd->colorBack); // make sidebar a dark version of the bg - } else { - pwd->bkBrush = CreateSolidBrush(colBg); - pwd->barBrush = CreateSolidBrush(colSidebar); - pwd->underlineBrush = CreateSolidBrush(colTitleUnderline); - } - - if(options.border) pwd->bPen = (HPEN)CreatePen(PS_SOLID, 1, colBorder); - else pwd->bPen = CreatePen(PS_SOLID, 1, pwd->custom_col ? pd->colorBack : colBg); - - SYSTEMTIME st; - GetLocalTime(&st); - GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, 0, pwd->tbuff, 128); - - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pwd); - - if(pd->timeout == -1 || (pd->timeout == 0 && options.default_timeout == -1)) { - // make a really long timeout - say 7 days? ;) - SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0); - } else { - if(pd->timeout == 0) { - SetTimer(hwnd, ID_CLOSETIMER, options.default_timeout * 1000, 0); - } else { - SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0); - } - } - - AddWindowToStack(hwnd); // this updates our size - } - - // transparency -#ifdef WS_EX_LAYERED - SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); -#endif - -#ifdef CS_DROPSHADOW - if (options.drop_shadow) { - SetClassLong(hwnd, GCL_STYLE, CS_DROPSHADOW); - } -#endif - -#ifdef LWA_ALPHA - if(MySetLayeredWindowAttributes) { - MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (int)(options.opacity / 100.0 * 255), LWA_ALPHA); - if(options.trans_bg) { - COLORREF bg; - if(pd->colorBack == pd->colorText) - bg = colBg; - else - bg = pd->colorBack; - MySetLayeredWindowAttributes(hwnd, bg, 0, LWA_COLORKEY); - } - } -#endif - PostMessage(hwnd, PM_INIT, (WPARAM)hwnd, 0); - return 0; - case WM_MOUSEMOVE: - if(pwd && !pwd->mouse_in) { - pwd->mouse_in = true; - global_mouse_in++; - TRACKMOUSEEVENT tme = { sizeof(tme) }; - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = hwnd; - TrackMouseEvent(&tme); - } - break; - case WM_MOUSELEAVE: - if(pwd && pwd->mouse_in) { - pwd->mouse_in = false; - global_mouse_in--; - } - return 0; - case WM_LBUTTONUP: - // fake STN_CLICKED notification - SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, STN_CLICKED), 0); - break; - case WM_TIMER: - if(wParam == ID_CLOSETIMER) { - KillTimer(hwnd, ID_CLOSETIMER); - if(pwd->mouse_in || (options.global_hover && global_mouse_in)) - SetTimer(hwnd, ID_CLOSETIMER, 800, 0); // reset timer if mouse in window - allow another 800 ms - else { - PostMessage(hwnd, PM_DESTROY, 0, 0); - } - return TRUE; - } else if(wParam == ID_MOVETIMER) { - RECT r; - GetWindowRect(hwnd, &r); - - if(r.left == pwd->new_x && r.top == pwd->new_y) { - KillTimer(hwnd, ID_MOVETIMER); - return TRUE; - } - int adj_x = (pwd->new_x - r.left) / 4, adj_y = (pwd->new_y - r.top) / 4; - if(adj_x == 0) adj_x = (pwd->new_x - r.left); - if(adj_y == 0) adj_y = (pwd->new_y - r.top); - - int x = r.left + adj_x, y = r.top + adj_y; - //SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS); - SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); - - - /* - // clip to monitor bounds (paints badly!) - //HDC hdc = GetDC(hwnd); - HMONITOR hMonitor = MonitorFromRect(&r, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi; - mi.cbSize = sizeof(mi); - GetMonitorInfo(hMonitor, &mi); - - POINT p[2]; - p[0].x = mi.rcWork.left; p[0].y = mi.rcWork.top; p[1].x = mi.rcWork.right; p[1].y = mi.rcWork.bottom; - //LPtoDP(hdc, p, 2); - ScreenToClient(hwnd, &p[0]); ScreenToClient(hwnd, &p[1]); - - HRGN hMonRgn = CreateRectRgn(p[0].x, p[0].y, p[1].x, p[1].y); - //ReleaseDC(hwnd, hdc); - - RECT cr; GetClientRect(hwnd, &cr); - HRGN hWndRgn = CreateRectRgn(cr.left, cr.top, cr.right + 3, cr.bottom + 3); - CombineRgn(hMonRgn, hMonRgn, hWndRgn, RGN_AND); - - // round corners - if(options.round) { - HRGN hRgn1; - int v,h, w=10; - h=(r.right-r.left)>(w*2)?w:(r.right-r.left); - v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top); - h=(hbkBrush); - // sidebar - r_bar = r; - r_bar.right = r.left + options.sb_width; - FillRect(hdc, &r_bar, pwd->barBrush); - // border - if(options.border) { - - HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH)); - HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->bPen); - - int h = 0; - if(options.round) { - int v; - int w=14; - h=(r.right-r.left)>(w*2)?w:(r.right-r.left); - v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top); - h=(hcustom_col) SetBkColor(ps.hdc, pd->colorBack); - //else SetBkColor(ps.hdc, colBg); - SetBkMode(hdc, TRANSPARENT); - - // avatar & time if with avatar - if(options.av_layout != PAV_NONE && (pwd->have_av || options.time_layout == PT_WITHAV)) { - RECT avr; - avr.top = options.av_padding; - - if(options.av_layout == PAV_LEFT) { - avr.left = r.left + options.av_padding; - if(pwd->have_av && options.time_layout == PT_WITHAV) avr.right = avr.left + max(pwd->real_av_width, pwd->time_width); - else if(pwd->have_av) avr.right = avr.left + pwd->real_av_width; - else avr.right = avr.left + pwd->time_width; - r.left = avr.right; - } else if(options.av_layout == PAV_RIGHT) { - avr.right = r.right - options.av_padding; - if(pwd->have_av && options.time_layout == PT_WITHAV) avr.left = avr.right - max(pwd->real_av_width, pwd->time_width); - else if(pwd->have_av) avr.left = avr.right - pwd->real_av_width; - else avr.left = avr.right - pwd->time_width; - r.right = avr.left; - } - - if(options.time_layout == PT_WITHAV) { - avr.top = options.padding; - avr.bottom = avr.top + pwd->time_height; - if(pwd->custom_col) SetTextColor(ps.hdc, pd->colorText); - else SetTextColor(ps.hdc, colTime); - if(hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime); - DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &avr, DT_VCENTER | DT_CENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX); - avr.top = avr.bottom + options.av_padding; - } - - if(pwd->have_av) { - // correct for wider time - if(options.time_layout == PT_WITHAV && pwd->time_width > options.av_size) { - avr.left = avr.left + (pwd->time_width - pwd->real_av_width) / 2; - avr.right = avr.left + pwd->real_av_width; - } - avr.bottom = avr.top + pwd->real_av_height; - - AVATARDRAWREQUEST adr = {0}; - adr.cbSize = sizeof(adr); - adr.hContact = pd->hContact; - adr.hTargetDC = ps.hdc; - adr.rcDraw = avr; - adr.dwFlags = (pwd->av_is_round ? AVDRQ_ROUNDEDCORNER : 0); - adr.radius = 5; //(pwd->av_is_round ? 5 : 0); - - CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&adr); - } - } - - // title icon - int iconx, textxmin = r.left + options.padding, textxmax = r.right - options.padding; - if(pd->hIcon) { - if(options.right_icon) { - iconx = r.right - (16 + options.padding); - textxmax -= 16 + options.padding; - } else { - iconx = r.left + options.padding; - textxmin += 16 + options.padding; - } - DrawIconEx(ps.hdc, iconx, options.padding + (pwd->tb_height - 16) / 2, pd->hIcon, 16, 16, 0, NULL, DI_NORMAL); - } - - // title time - if(options.time_layout == PT_LEFT || options.time_layout == PT_RIGHT) { - RECT ttr; - ttr.top = r.top + options.padding; ttr.bottom = ttr.top + pwd->tb_height; - if(pwd->custom_col) SetTextColor(ps.hdc, pd->colorText); - else SetTextColor(ps.hdc, colTime); - if(hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime); - switch(options.time_layout) { - case PT_LEFT: - ttr.left = textxmin; ttr.right = ttr.left + pwd->time_width; - textxmin += pwd->time_width + options.padding; - DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX); - break; - case PT_RIGHT: - ttr.right = textxmax; ttr.left = ttr.right - pwd->time_width; - textxmax -= pwd->time_width + options.padding; - DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX); - break; - default: - break; - } - } - - if(textxmin < options.sb_width) textxmin = options.sb_width + options.padding / 2; - - // title text - if(hFontFirstLine) SelectObject(ps.hdc, (HGDIOBJ)hFontFirstLine); - RECT tr; - tr.left = r.left + options.padding + options.text_indent; tr.right = textxmax; tr.top = r.top + options.padding; tr.bottom = tr.top + pwd->tb_height; - - if(pwd->custom_col) SetTextColor(ps.hdc, pd->colorText); - else SetTextColor(ps.hdc, colFirstLine); - TCHAR *title = mir_u2t(pd->pwzTitle); - DrawText(ps.hdc, title, (int)_tcslen(title), &tr, DT_VCENTER | DT_LEFT | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX); - mir_free(title); - - // title underline - RECT tur; - tur.left = r.left + options.sb_width + options.padding; - tur.right = r.right - options.padding; - tur.top = tr.bottom + options.padding/2; - tur.bottom = tur.top + 1; - FillRect(ps.hdc, &tur, pwd->underlineBrush); - - // second line(s) - if(pd->pwzText[0]) { - if(hFontSecondLine) SelectObject(ps.hdc, (HGDIOBJ)hFontSecondLine); - if (!pwd->custom_col) - SetTextColor(ps.hdc, colSecondLine); - - // expand text if no avatar and the time isn't too large - if(options.av_layout != PAV_NONE && options.time_layout == PT_WITHAV && pwd->time_height <= pwd->tb_height && !pwd->have_av) - GetClientRect(hwnd, &r); - - TCHAR *text = mir_u2t(pd->pwzText); - tr.left = r.left + options.padding + options.text_indent; tr.right = r.right - options.padding; tr.top = tr.bottom + options.padding; tr.bottom = r.bottom - options.padding; - DrawText(ps.hdc, text, (int)_tcslen(text), &tr, DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS); - mir_free(text); - } - - EndPaint(hwnd, &ps); - //} - } - return 0; - - case WM_DESTROY: - if(pwd->mouse_in) global_mouse_in--; - - ShowWindow(hwnd, SW_HIDE); - - DeleteObject(pwd->bkBrush); - DeleteObject(pwd->bPen); - DeleteObject(pwd->barBrush); - DeleteObject(pwd->underlineBrush); - KillTimer(hwnd, ID_MOVETIMER); - KillTimer(hwnd, ID_CLOSETIMER); - - RemoveWindowFromStack(hwnd); - - SendMessage(hwnd, PM_DIENOTIFY, 0, 0); - - if (pd) { - mir_free(pd->pwzTitle); - mir_free(pd->pwzText); - mir_free(pd); - } - mir_free(pwd); pwd = 0; pd = 0; - SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); - break; - - case PUM_UPDATERGN: - // round corners - if(pwd->is_round) { - HRGN hRgn1; - RECT r; - - int v,h; - int w=11; - GetWindowRect(hwnd,&r); - h=(r.right-r.left)>(w*2)?w:(r.right-r.left); - v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top); - h=(hnew_x = (int)wParam; - pwd->new_y = (int)lParam; - SetTimer(hwnd, ID_MOVETIMER, 10, 0); - } else { - SetWindowPos(hwnd, 0, (int)wParam, (int)lParam, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); - if (!IsWindowVisible(hwnd)) { - ShowWindow(hwnd, SW_SHOWNOACTIVATE); - UpdateWindow(hwnd); - } - } - return TRUE; - - case PUM_SETTEXT: - replaceStrT(pd->ptzText, (TCHAR*)lParam); - InvalidateRect(hwnd, 0, TRUE); - RepositionWindows(); - return TRUE; - - case PUM_GETCONTACT: - { - HANDLE *phContact = (HANDLE *)wParam; - *phContact = pd->hContact; - if(lParam) SetEvent((HANDLE)lParam); - } - return TRUE; - case PUM_GETHEIGHT: - { - int *pHeight = (int *)wParam; - HDC hdc = GetDC(hwnd); - SIZE size; - - // time_height + width - if(options.time_layout != PT_NONE) { - SIZE size_t; - if(hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime); - GetTextExtentPoint32(hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &size_t); - pwd->time_height = size_t.cy; - pwd->time_width = size_t.cx; - } - - // titlebar height - if(hFontFirstLine) SelectObject(hdc, (HGDIOBJ)hFontFirstLine); - TCHAR *title = mir_u2t(pd->pwzTitle); - GetTextExtentPoint32(hdc, title, (int)_tcslen(title), &size); - mir_free(title); - pwd->tb_height = size.cy; - if(options.time_layout == PT_LEFT || options.time_layout == PT_RIGHT) { - if(pwd->tb_height < pwd->time_height) pwd->tb_height = pwd->time_height; - } - if(pwd->tb_height < 16) pwd->tb_height = 16; - - // avatar height - if(options.av_layout != PAV_NONE && ServiceExists(MS_AV_DRAWAVATAR)) { - AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pd->hContact, 0); - if(ace && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) { - if(ace->bmHeight >= ace->bmWidth) { - pwd->real_av_height = options.av_size; - pwd->real_av_width = options.av_size * ace->bmWidth / ace->bmHeight; - } else { - pwd->real_av_height = options.av_size * ace->bmHeight / ace->bmWidth; - pwd->real_av_width = options.av_size; - } - pwd->have_av = true; - pwd->av_height = pwd->real_av_height; - } - } - - // text height - if (pd->pwzText[0]) { - RECT r; - r.left = r.top = 0; - r.right = options.win_width - 2 * options.padding - options.text_indent; - if(pwd->have_av && options.time_layout == PT_WITHAV) - r.right -= (max(options.av_size, pwd->time_width) + options.padding); - else if(pwd->have_av) - r.right -= (options.av_size + options.padding); - else if(options.av_layout != PAV_NONE && options.time_layout == PT_WITHAV && pwd->time_height >= pwd->tb_height) - r.right -= pwd->time_width + options.padding; - - if(hFontSecondLine) SelectObject(hdc, (HGDIOBJ)hFontSecondLine); - TCHAR *text = mir_u2t(pd->pwzText); - DrawText(hdc, text, (int)_tcslen(text), &r, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS); - pwd->text_height = r.bottom; - mir_free(text); - } - - ReleaseDC(hwnd, hdc); - - if(options.time_layout == PT_WITHAV && options.av_layout != PAV_NONE) - *pHeight = max(pwd->tb_height + pwd->text_height + 3 * options.padding, pwd->av_height + pwd->time_height + options.padding + 2 * options.av_padding); - else - *pHeight = max(pwd->tb_height + pwd->text_height + 3 * options.padding, pwd->av_height + 2 * options.av_padding); - - if (*pHeight > options.win_max_height) *pHeight = options.win_max_height; - - RECT r; - GetWindowRect(hwnd, &r); - if(r.right - r.left != options.win_width || r.bottom - r.top != *pHeight) { - SetWindowPos(hwnd, 0, 0, 0, options.win_width, *pHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); - SendMessage(hwnd, PUM_UPDATERGN, 0, 0); - InvalidateRect(hwnd, 0, TRUE); - } - } - return TRUE; - case PUM_GETOPAQUE: - { - void **pData = (void **)wParam; - if(pd) *pData = pd->opaque; - if(lParam) SetEvent((HANDLE)lParam); - } - return TRUE; - case PUM_CHANGE: - { - KillTimer(hwnd, ID_CLOSETIMER); - if (pd) { - mir_free(pd->pwzTitle); - mir_free(pd->pwzText); - mir_free(pd); - } - pwd->pd = pd = (PopupData *)lParam; - - if(pd->timeout != -1) { - if(pd->timeout == 0) { - SetTimer(hwnd, ID_CLOSETIMER, 7 * 1000, 0); - } else { - SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0); - } - } else { - // make a really long timeout - say 7 days? ;) - SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0); - } - - InvalidateRect(hwnd, 0, TRUE); - RepositionWindows(); - } - return TRUE; - - case PUM_SETNOTIFYH: - pwd->hNotify = (HANDLE)wParam; - return TRUE; - - case PUM_UPDATENOTIFY: - if(pwd->hNotify == (HANDLE)wParam) { - pd->colorBack = MNotifyGetDWord(pwd->hNotify, NFOPT_BACKCOLOR, colBg); - pd->colorText = MNotifyGetDWord(pwd->hNotify, NFOPT_TEXTCOLOR, colSecondLine); - pd->timeout = MNotifyGetDWord(pwd->hNotify, NFOPT_TIMEOUT, options.default_timeout); - pd->hContact = (HANDLE)MNotifyGetDWord(pwd->hNotify, NFOPT_CONTACT, 0); - pd->hIcon = (HICON)MNotifyGetDWord(pwd->hNotify, NFOPT_ICON, 0); - - const wchar_t *swzName = MNotifyGetWString(pwd->hNotify, NFOPT_TITLEW, 0); - mir_free(pd->pwzTitle); - pd->pwzTitle = mir_wstrdup(swzName); - - const wchar_t *swzText = MNotifyGetWString(pwd->hNotify, NFOPT_TEXTW, 0); - mir_free(pd->pwzText); - pd->pwzText = mir_wstrdup(swzText); - - InvalidateRect(hwnd, 0, TRUE); - RepositionWindows(); - } - - return TRUE; - case PUM_KILLNOTIFY: - if(pwd->hNotify != (HANDLE)wParam) - return TRUE; - // drop through - - case PM_DESTROY: - PostMPMessage(MUM_DELETEPOPUP, 0, (LPARAM)hwnd); - return TRUE; - } - - - if(pd && pd->windowProc) - return CallWindowProc(pd->windowProc, hwnd, uMsg, wParam, lParam); - else { - // provide a way to close popups, if no PluginWindowProc is provided - if(uMsg == WM_CONTEXTMENU) { - SendMessage(hwnd, PM_DESTROY, 0, 0); - return TRUE; - } else - return DefWindowProc(hwnd, uMsg, wParam, lParam); - } -} - -void InitWindowStack() { - hUserDll = GetModuleHandle(_T("user32.dll")); - if (hUserDll) { - MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes"); - MyAnimateWindow=(BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll,"AnimateWindow"); - MyMonitorFromRect=(HMONITOR (WINAPI*)(LPCRECT,DWORD))GetProcAddress(hUserDll, "MonitorFromRect"); - - MyGetMonitorInfo=(BOOL (WINAPI*)(HMONITOR,LPMONITORINFO))GetProcAddress(hUserDll, "GetMonitorInfoW"); - - } -} - -void DeinitWindowStack() { - ClearStack(); -} - diff --git a/plugins/YAPP/popwin.h b/plugins/YAPP/popwin.h deleted file mode 100644 index 4d826ceade..0000000000 --- a/plugins/YAPP/popwin.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _POPWIN_INC -#define _POPWIN_INC - -#define POP_WIN_CLASS _T(MODULE) _T("YAPPWindowClass") - -#define PUM_SETTEXT (WM_USER + 0x020) -#define PUM_GETCONTACT (WM_USER + 0x021) -#define PUM_GETOPAQUE (WM_USER + 0x022) -#define PUM_CHANGE (WM_USER + 0x023) -#define PUM_MOVE (WM_USER + 0x024) -#define PUM_GETHEIGHT (WM_USER + 0x025) -#define PUM_UPDATERGN (WM_USER + 0x026) - -#define PUM_SETNOTIFYH (WM_USER + 0x030) -#define PUM_KILLNOTIFY (WM_USER + 0x031) -#define PUM_UPDATENOTIFY (WM_USER + 0x032) - -void InitWindowStack(); -void DeinitWindowStack(); - -void BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam); - -void RepositionWindows(); - -LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - -#endif diff --git a/plugins/YAPP/res/PPh2.ico b/plugins/YAPP/res/PPh2.ico new file mode 100644 index 0000000000..f8aa63abf2 Binary files /dev/null and b/plugins/YAPP/res/PPh2.ico differ diff --git a/plugins/YAPP/res/version.rc b/plugins/YAPP/res/version.rc new file mode 100644 index 0000000000..3ad9c3a4b3 --- /dev/null +++ b/plugins/YAPP/res/version.rc @@ -0,0 +1,36 @@ +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include +#include "..\src\version.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "Author", __AUTHOR + VALUE "FileDescription", __DESC + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/plugins/YAPP/res/yapp.rc b/plugins/YAPP/res/yapp.rc new file mode 100644 index 0000000000..d4a7243199 --- /dev/null +++ b/plugins/YAPP/res/yapp.rc @@ -0,0 +1,207 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\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 + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (Australia) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_LST_HISTORY DIALOGEX 0, 0, 467, 303 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +CAPTION "Popup history" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + PUSHBUTTON "Close",IDC_CLOSE,413,285,50,14 + CONTROL "",IDC_LST_HISTORY,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,4,3,459,278 + EDITTEXT IDC_HISTORY_FILTER,4,285,176,14,ES_AUTOHSCROLL + CONTROL "Case sensitive",IDC_HISTORY_FILTER_CASESENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,185,287,222,10 +END + +IDD_OPT1 DIALOGEX 0, 0, 297, 218 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Default Timeout",IDC_STATIC,4,7,153,36 + CONTROL "Never timeout",IDC_RAD_NOTIMEOUT,"Button",BS_AUTORADIOBUTTON | BS_LEFTTEXT | WS_GROUP,10,16,77,10,WS_EX_RIGHT + CONTROL "Set timeout:",IDC_RAD_TIMEOUT,"Button",BS_AUTORADIOBUTTON | BS_LEFTTEXT,10,28,77,10,WS_EX_RIGHT + EDITTEXT IDC_ED_TIMEOUT,93,26,40,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_TIMEOUT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,131,26,12,14 + EDITTEXT IDC_ED_WIDTH,238,84,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_WIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,84,12,14 + EDITTEXT IDC_ED_MAXHEIGHT,238,102,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_MAXHEIGHT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,102,12,14 + RTEXT "Width:",IDC_STATIC,174,87,60,8,0,WS_EX_RIGHT + RTEXT "Maximum height:",IDC_STATIC,174,104,60,8,0,WS_EX_RIGHT + GROUPBOX "Options",IDC_STATIC,4,116,153,94 + EDITTEXT IDC_ED_TRANS,97,183,33,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_TRANS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,126,183,13,12 + RTEXT "Opacity(%):",IDC_STATIC,11,186,84,8,0,WS_EX_RIGHT + CONTROL "Border",IDC_CHK_BORDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,127,121,10 + CONTROL "Round corners (window)",IDC_CHK_ROUNDCORNERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,138,121,10 + PUSHBUTTON "Preview",IDC_BTN_PREVIEW,161,194,130,17 + CONTROL "Animate",IDC_CHK_ANIMATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,160,121,10 + CONTROL "Transparent background",IDC_CHK_TRANSBG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,199,121,10 + GROUPBOX "Layout",IDC_STATIC,161,7,129,184 + RTEXT "Avatar size:",IDC_STATIC,174,122,60,8,0,WS_EX_RIGHT + EDITTEXT IDC_ED_AVSIZE,238,120,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_AVSIZE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,120,12,14 + GROUPBOX "Disable when",IDC_STATIC,4,44,153,70 + CONTROL "",IDC_LST_STATUS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_NOLABELWRAP | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,54,148,56 + COMBOBOX IDC_CMB_PLACEMENT,165,19,120,68,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CMB_ICON,165,36,120,69,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_CMB_AV,165,53,120,76,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Global hover",IDC_CHK_GLOBALHOVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,171,121,10 + COMBOBOX IDC_CMB_TIME,165,69,120,76,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_ED_SBWIDTH,238,138,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_SBWIDTH,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,138,11,14 + RTEXT "Sidebar width:",IDC_STATIC,174,141,60,8 + EDITTEXT IDC_ED_INDENT,238,156,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_INDENT,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,269,156,12,14 + RTEXT "Text indent:",IDC_STATIC,174,160,60,8 + EDITTEXT IDC_ED_PADDING,238,173,39,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT + CONTROL "",IDC_SPIN_PADDING,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,270,173,12,14 + RTEXT "Padding:",IDC_STATIC,174,176,60,8 + CONTROL "Round corners (avatar)",IDC_CHK_ROUNDCORNERSAV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,25,149,121,10 +END + +IDD_OPT_NOTIFY DIALOGEX 0, 0, 187, 91 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN +END + +IDD_CLASSES DIALOGEX 0, 0, 294, 223 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LISTBOX IDC_LST_CLASSES,7,18,102,184,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + RTEXT "Text colour:",IDC_STATIC,136,66,80,8 + RTEXT "Background colour:",IDC_STATIC,136,88,80,8 + CONTROL "Set timeout",IDC_CHK_TIMEOUT,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,144,122,99,10 + RTEXT "Timeout value (0 = default):",IDC_STATIC,114,143,121,8 + EDITTEXT IDC_ED_TIMEOUT,243,140,43,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED + CONTROL "Custom1",IDC_COL_TEXT,"ColourPicker",WS_DISABLED | WS_TABSTOP,243,61,44,17 + CONTROL "Custom1",IDC_COL_BG,"ColourPicker",WS_DISABLED | WS_TABSTOP,243,82,44,17 + PUSHBUTTON "Preview",IDC_BTN_PREVIEW,141,178,130,17,WS_DISABLED +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT1, DIALOG + BEGIN + LEFTMARGIN, 4 + RIGHTMARGIN, 290 + TOPMARGIN, 7 + BOTTOMMARGIN, 211 + END + + IDD_OPT_NOTIFY, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 180 + TOPMARGIN, 7 + BOTTOMMARGIN, 84 + END + + IDD_CLASSES, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 287 + TOPMARGIN, 7 + BOTTOMMARGIN, 216 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_POPUP_HISTORY ICON "PPh2.ico" +#endif // English (Australia) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/YAPP/resource.h b/plugins/YAPP/resource.h deleted file mode 100644 index d7db4cda2e..0000000000 --- a/plugins/YAPP/resource.h +++ /dev/null @@ -1,79 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by popups2.rc -// -#define IDD_OPT1 101 -#define IDD_DIALOG1 102 -#define IDD_OPT_NOTIFY 103 -#define IDD_LST_HISTORY 104 -#define IDI_ICON1 105 -#define IDI_POPUP_HISTORY 105 -#define IDI_ICON2 106 -#define IDD_CLASSES 107 -#define IDC_RAD_NOTIMEOUT 1001 -#define IDC_RAD_TIMEOUT 1002 -#define IDC_ED_TIMEOUT 1003 -#define IDC_SPIN_TIMEOUT 1004 -#define IDC_ED_WIDTH 1005 -#define IDC_ED_MAXHEIGHT 1006 -#define IDC_SPIN_WIDTH 1007 -#define IDC_SPIN3 1008 -#define IDC_SPIN_MAXHEIGHT 1009 -#define IDC_RAD_BOTTOMRIGHT 1010 -#define IDC_ED_INDENT 1011 -#define IDC_RAD_BOTTOMLEFT 1012 -#define IDC_ED_SBWIDTH 1012 -#define IDC_SPIN_INDENT 1013 -#define IDC_RAD_TOPRIGHT 1014 -#define IDC_SPIN_SBWIDTH 1014 -#define IDC_RAD_TOPLEFT 1015 -#define IDC_ED_PADDING 1015 -#define IDC_ED_TRANS 1016 -#define IDC_SPIN_TRANS 1017 -#define IDC_CHK_BORDER 1018 -#define IDC_CHK_ROUNDCORNERS 1019 -#define IDC_BTN_PREVIEW 1020 -#define IDC_CHK_ANIMATE 1021 -#define IDC_CHK_TRANSBG 1022 -#define IDC_RAD_RIGHTICON 1023 -#define IDC_SPIN_INDENT2 1023 -#define IDC_SPIN_PADDING 1023 -#define IDC_CHK_GLOBALHOVER 1024 -#define IDC_RAD_LEFTICON 1025 -#define IDC_CHK_ROUNDCORNERSAV 1025 -#define IDC_RAD_NOAV 1026 -#define IDC_RAD_RIGHTAV 1027 -#define IDC_RAD_NOAV3 1028 -#define IDC_RAD_LEFTAV 1029 -#define IDC_ED_MAXHEIGHT2 1030 -#define IDC_ED_AVSIZE 1031 -#define IDC_SPIN_AVSIZE 1032 -#define IDC_LST_STATUS 1033 -#define IDC_CMB_PLACEMENT 1034 -#define IDC_CMB_ICON 1035 -#define IDC_CMB_AV 1036 -#define IDC_CMB_AV2 1037 -#define IDC_CMB_TIME 1038 -#define IDC_CUSTOM1 1039 -#define IDC_COL_TEXT 1039 -#define IDC_BORDERCOLOUR 1040 -#define IDC_COL_BG 1040 -#define IDC_CLOSE 1041 -#define IDC_LIST3 1042 -#define IDC_LST_HISTORY 1043 -#define IDC_HISTORY_FILTER 1044 -#define IDC_HISTORY_FILTER_CASESENSITIVE 1046 -#define IDC_LST_CLASSES 1047 -#define IDC_CHK_TIMEOUT 1048 -#define IDC_BUTTON1 1050 - -// 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 1051 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/YAPP/services.cpp b/plugins/YAPP/services.cpp deleted file mode 100644 index 84e4330151..0000000000 --- a/plugins/YAPP/services.cpp +++ /dev/null @@ -1,524 +0,0 @@ -#include "common.h" -#include "services.h" -#include "popwin.h" -#include "message_pump.h" -#include "resource.h" -#include "popup_history.h" - -#define NUM_SERVICES 20 -HANDLE hService[NUM_SERVICES]; -HANDLE hMenuShowHistory, hMenuToggleOnOff; - -void StripBBCodesInPlace(wchar_t *text) { - if(text == 0 || DBGetContactSettingByte(0, MODULE, "StripBBCodes", 1) == 0) - return; - - int read = 0, write = 0; - int len = (int)wcslen(text); - - while(read <= len) { // copy terminating null too - while(read <= len && text[read] != L'[') { - if(text[read] != text[write]) text[write] = text[read]; - read++; write++; - } - if(read > len) break; - - if(len - read >= 3 && (_wcsnicmp(text + read, L"[b]", 3) == 0 || _wcsnicmp(text + read, L"[i]", 3) == 0)) - read += 3; - else if(len - read >= 4 && (_wcsnicmp(text + read, L"[/b]", 4) == 0 || _wcsnicmp(text + read, L"[/i]", 4) == 0)) - read += 4; - else if(len - read >= 6 && (_wcsnicmp(text + read, L"[color", 6) == 0)) { - while(read < len && text[read] != L']') read++; - read++;// skip the ']' - } else if(len - read >= 8 && (_wcsnicmp(text + read, L"[/color]", 8) == 0)) - read += 8; - else if(len - read >= 5 && (_wcsnicmp(text + read, L"[size", 5) == 0)) { - while(read < len && text[read] != L']') read++; - read++;// skip the ']' - } else if(len - read >= 7 && (_wcsnicmp(text + read, L"[/size]", 7) == 0)) - read += 7; - else { - if(text[read] != text[write]) text[write] = text[read]; - read++; write++; - } - } -} - -INT_PTR OldCreatePopupA(WPARAM wParam, LPARAM lParam) { - POPUPDATA *pd_in = (POPUPDATA *)wParam; - PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData)); - - pd_out->cbSize = sizeof(PopupData); - pd_out->flags = PDF_UNICODE; - pd_out->pwzTitle = mir_a2u(pd_in->lpzContactName); - pd_out->pwzText = mir_a2u(pd_in->lpzText); - StripBBCodesInPlace(pd_out->pwzTitle); - StripBBCodesInPlace(pd_out->pwzText); - - pd_out->hContact = pd_in->lchContact; - pd_out->hIcon = pd_in->lchIcon; - if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' - pd_out->colorBack = pd_out->colorText = 0; - else { - pd_out->colorBack = pd_in->colorBack & 0xFFFFFF; - pd_out->colorText = pd_in->colorText & 0xFFFFFF; - } - pd_out->windowProc = pd_in->PluginWindowProc; - pd_out->opaque = pd_in->PluginData; - pd_out->timeout = 0; - - lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); - - if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) { - mir_free(pd_out->pwzTitle); - mir_free(pd_out->pwzText); - mir_free(pd_out); - return -1; - } - - //MessageBox(0, pd_out->lpwzContactName, _T("CreatePopupA"), MB_OK); - PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out); - return 0; -} - -INT_PTR OldCreatePopupExA(WPARAM wParam, LPARAM lParam) { - - POPUPDATAEX *pd_in = (POPUPDATAEX *)wParam; - PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData)); - - pd_out->cbSize = sizeof(PopupData); - pd_out->flags = PDF_UNICODE; - pd_out->pwzTitle = mir_a2u(pd_in->lpzContactName); - pd_out->pwzText = mir_a2u(pd_in->lpzText); - StripBBCodesInPlace(pd_out->pwzTitle); - StripBBCodesInPlace(pd_out->pwzText); - - pd_out->hContact = pd_in->lchContact; - pd_out->hIcon = pd_in->lchIcon; - if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' - pd_out->colorBack = pd_out->colorText = 0; - else { - pd_out->colorBack = pd_in->colorBack & 0xFFFFFF; - pd_out->colorText = pd_in->colorText & 0xFFFFFF; - } - pd_out->windowProc = pd_in->PluginWindowProc; - pd_out->opaque = pd_in->PluginData; - pd_out->timeout = pd_in->iSeconds; - - lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); - if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) { - mir_free(pd_out->pwzTitle); - mir_free(pd_out->pwzText); - mir_free(pd_out); - return -1; - } - - //MessageBox(0, pd_out->lpwzContactName, _T("CreatePopupExA"), MB_OK); - PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out); - return 0; -} - -INT_PTR OldCreatePopupW(WPARAM wParam, LPARAM lParam) { - - POPUPDATAW *pd_in = (POPUPDATAW *)wParam; - PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData)); - - pd_out->cbSize = sizeof(PopupData); - pd_out->flags = PDF_UNICODE; - pd_out->pwzTitle = mir_wstrdup(pd_in->lpwzContactName); - pd_out->pwzText = mir_wstrdup(pd_in->lpwzText); - StripBBCodesInPlace(pd_out->pwzTitle); - StripBBCodesInPlace(pd_out->pwzText); - - pd_out->hContact = pd_in->lchContact; - pd_out->hIcon = pd_in->lchIcon; - if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' - pd_out->colorBack = pd_out->colorText = 0; - else { - pd_out->colorBack = pd_in->colorBack & 0xFFFFFF; - pd_out->colorText = pd_in->colorText & 0xFFFFFF; - } - pd_out->windowProc = pd_in->PluginWindowProc; - pd_out->opaque = pd_in->PluginData; - pd_out->timeout = pd_in->iSeconds; - - lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); - if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) { - mir_free(pd_out->pwzTitle); - mir_free(pd_out->pwzText); - mir_free(pd_out); - return -1; - } - - //MessageBox(0, pd_out->lpwzContactName, _T("CreatePopupW"), MB_OK); - PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out); - return 0; -} - -INT_PTR ChangeTextW(WPARAM wParam, LPARAM lParam) -{ - HWND hwndPop = (HWND)wParam; - wchar_t *newText = NEWWSTR_ALLOCA((wchar_t *)lParam); - StripBBCodesInPlace(newText); - - if(IsWindow(hwndPop)) - SendMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)newText); - else - mir_free(newText); - return 0; -} - -INT_PTR ChangeTextA(WPARAM wParam, LPARAM lParam) { - HWND hwndPop = (HWND)wParam; - char *newText = (char *)lParam; - wchar_t* buff = mir_a2u(newText); - StripBBCodesInPlace(buff); - - if(IsWindow(hwndPop)) - SendMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)buff); - - mir_free(buff); - return 0; -} - -void ShowPopup(PopupData &pd_in) -{ - PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData)); - *pd_out = pd_in; - if (pd_in.flags & PDF_UNICODE) { - pd_out->pwzTitle = mir_wstrdup(pd_in.pwzTitle); - pd_out->pwzText = mir_wstrdup(pd_in.pwzText); - } else { - pd_out->flags |= PDF_UNICODE; - pd_out->pwzTitle = mir_a2u(pd_in.pszTitle); - pd_out->pwzText = mir_a2u(pd_in.pszText); - } - StripBBCodesInPlace(pd_out->pwzTitle); - StripBBCodesInPlace(pd_out->pwzText); - - lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); - - if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) - { - mir_free(pd_out->pwzTitle); - mir_free(pd_out->pwzText); - mir_free(pd_out); - } - else - PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out); -} - -INT_PTR GetContact(WPARAM wParam, LPARAM lParam) { - HWND hwndPop = (HWND)wParam; - HANDLE hContact; - if(GetCurrentThreadId() == message_pump_thread_id) { - SendMessage(hwndPop, PUM_GETCONTACT, (WPARAM)&hContact, 0); - } else { - HANDLE hEvent = CreateEvent(0, 0, 0, 0); - PostMessage(hwndPop, PUM_GETCONTACT, (WPARAM)&hContact, (LPARAM)hEvent); - MsgWaitForMultipleObjectsEx(1, &hEvent, INFINITE, 0, 0); - CloseHandle(hEvent); - } - - return (INT_PTR)hContact; -} - -INT_PTR GetOpaque(WPARAM wParam, LPARAM lParam) { - HWND hwndPop = (HWND)wParam; - void *data = 0; - if(GetCurrentThreadId() == message_pump_thread_id) { - SendMessage(hwndPop, PUM_GETOPAQUE, (WPARAM)&data, 0); - } else { - HANDLE hEvent = CreateEvent(0, 0, 0, 0); - PostMessage(hwndPop, PUM_GETOPAQUE, (WPARAM)&data, (LPARAM)hEvent); - MsgWaitForMultipleObjectsEx(1, &hEvent, INFINITE, 0, 0); - CloseHandle(hEvent); - } - - return (INT_PTR)data; -} - -INT_PTR IsSecondLineShown(WPARAM wParam, LPARAM lParam) { - return TRUE; -} - -void UpdateMenu() { - CLISTMENUITEM mi = {0}; - mi.cbSize = sizeof(CLISTMENUITEM); - mi.pszName = (char*)(DBGetContactSettingByte(0, MODULE, "Enabled", 1) == 1 ? LPGEN("Disable Popups") : LPGEN("Enable Popups")); - mi.flags = CMIM_NAME;// | CMIM_ICON; - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuToggleOnOff, (LPARAM)&mi); -} - -INT_PTR PopupQuery(WPARAM wParam, LPARAM lParam) { - switch(wParam) { - case PUQS_ENABLEPOPUPS: - { - bool enabled = DBGetContactSettingByte(0, MODULE, "Enabled", 1) != 0; - if (!enabled) DBWriteContactSettingByte(0, MODULE, "Enabled", 1); - return !enabled; - } - break; - case PUQS_DISABLEPOPUPS: - { - bool enabled = DBGetContactSettingByte(0, MODULE, "Enabled", 1) != 0; - if (enabled) DBWriteContactSettingByte(0, MODULE, "Enabled", 0); - return enabled; - } - break; - case PUQS_GETSTATUS: - return DBGetContactSettingByte(0, MODULE, "Enabled", 1); - default: - return 1; - } - UpdateMenu(); - return 0; -} - -INT_PTR TogglePopups(WPARAM wParam, LPARAM lParam) { - BYTE val = DBGetContactSettingByte(0, MODULE, "Enabled", 1); - DBWriteContactSettingByte(0, MODULE, "Enabled", !val); - UpdateMenu(); - return 0; -} - -INT_PTR PopupChangeA(WPARAM wParam, LPARAM lParam) { - HWND hwndPop = (HWND)wParam; - POPUPDATAEX *pd_in = (POPUPDATAEX *)lParam; - - if(IsWindow(hwndPop)) { - PopupData pd_out; - pd_out.cbSize = sizeof(PopupData); - pd_out.flags = PDF_UNICODE; - - pd_out.pwzTitle = mir_a2u(pd_in->lpzContactName); - pd_out.pwzText = mir_a2u(pd_in->lpzText); - StripBBCodesInPlace(pd_out.pwzTitle); - StripBBCodesInPlace(pd_out.pwzText); - - pd_out.hContact = pd_in->lchContact; - pd_out.hIcon = pd_in->lchIcon; - if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' - pd_out.colorBack = pd_out.colorText = 0; - else { - pd_out.colorBack = pd_in->colorBack & 0xFFFFFF; - pd_out.colorText = pd_in->colorText & 0xFFFFFF; - } - pd_out.colorBack = pd_in->colorBack; - pd_out.colorText = pd_in->colorText; - pd_out.windowProc = pd_in->PluginWindowProc; - pd_out.opaque = pd_in->PluginData; - pd_out.timeout = pd_in->iSeconds; - - lstPopupHistory.Add(pd_out.pwzTitle, pd_out.pwzText, time(0)); - - SendMessage(hwndPop, PUM_CHANGE, 0, (LPARAM)&pd_out); - } - return 0; -} - -INT_PTR PopupChangeW(WPARAM wParam, LPARAM lParam) { - HWND hwndPop = (HWND)wParam; - POPUPDATAW *pd_in = (POPUPDATAW *)lParam; - - if(IsWindow(hwndPop)) { - PopupData pd_out; - pd_out.cbSize = sizeof(PopupData); - pd_out.flags = PDF_UNICODE; - - pd_out.pwzTitle = mir_wstrdup(pd_in->lpwzContactName); - pd_out.pwzText = mir_wstrdup(pd_in->lpwzText); - StripBBCodesInPlace(pd_out.pwzTitle); - StripBBCodesInPlace(pd_out.pwzText); - - pd_out.hContact = pd_in->lchContact; - pd_out.hIcon = pd_in->lchIcon; - if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' - pd_out.colorBack = pd_out.colorText = 0; - else { - pd_out.colorBack = pd_in->colorBack & 0xFFFFFF; - pd_out.colorText = pd_in->colorText & 0xFFFFFF; - } - pd_out.colorBack = pd_in->colorBack; - pd_out.colorText = pd_in->colorText; - pd_out.windowProc = pd_in->PluginWindowProc; - pd_out.opaque = pd_in->PluginData; - pd_out.timeout = pd_in->iSeconds; - - lstPopupHistory.Add(pd_out.pwzTitle, pd_out.pwzText, time(0)); - - SendMessage(hwndPop, PUM_CHANGE, 0, (LPARAM)&pd_out); - } - return 0; -} - -INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam) { - if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) return 0; - - POPUPDATAT pd = {0}; - _tcscpy(pd.lptzContactName, lParam == SM_WARNING ? _T("Warning") : _T("Notification")); - pd.lchIcon = LoadIcon(0, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION); - TCHAR *buff = mir_a2t((char *)wParam); - _tcscpy(pd.lptzText, buff); pd.lptzText[MAX_SECONDLINE-1] = 0; - mir_free(buff); - - CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, 0); - - return 0; -} - -INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam) { - if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) return 0; - - POPUPDATAW pd = {0}; - wcscpy(pd.lpwzContactName, lParam == SM_WARNING ? L"Warning" : L"Notification"); - pd.lchIcon = LoadIcon(0, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION); - wcsncpy(pd.lpwzText, (wchar_t *)wParam, MAX_SECONDLINE); - - CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pd, 0); - - return 0; -} - -//=====PopUp/ShowHistory -//extern BOOL CALLBACK DlgProcHistLstOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR PopUp_ShowHistory(WPARAM wParam, LPARAM lParam) -{ - if (!hHistoryWindow) { - hHistoryWindow = CreateDialog(hInst, MAKEINTRESOURCE(IDD_LST_HISTORY), NULL, DlgProcHistLst); - } - ShowWindow(hHistoryWindow, SW_SHOW); - return 0; -} - -int num_classes = 0; -POPUPCLASS *classes = 0; - -INT_PTR RegisterPopupClass(WPARAM wParam, LPARAM lParam) -{ - classes = (POPUPCLASS *)mir_realloc(classes, sizeof(POPUPCLASS) * (num_classes + 1)); - memcpy(classes + num_classes, (PVOID)lParam, sizeof(POPUPCLASS)); - POPUPCLASS *pc = classes + num_classes; - num_classes++; - - pc->pszName = mir_strdup(pc->pszName); - if(pc->flags & PCF_UNICODE) - pc->pwszDescription = mir_wstrdup(pc->pwszDescription); - else - pc->pszDescription = mir_strdup(pc->pszDescription); - - char setting[256]; - mir_snprintf(setting, 256, "%s/Timeout", pc->pszName); - pc->iSeconds = DBGetContactSettingWord(0, MODULE, setting, pc->iSeconds); - if(pc->iSeconds == (WORD)-1) pc->iSeconds = -1; - mir_snprintf(setting, 256, "%s/TextCol", pc->pszName); - pc->colorText = (COLORREF)DBGetContactSettingDword(0, MODULE, setting, (DWORD)pc->colorText); - mir_snprintf(setting, 256, "%s/BgCol", pc->pszName); - pc->colorBack = (COLORREF)DBGetContactSettingDword(0, MODULE, setting, (DWORD)pc->colorBack); - - return 0; -} - -INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam) -{ - POPUPDATACLASS *pdc = (POPUPDATACLASS *)lParam; - if(pdc->cbSize < sizeof(POPUPDATACLASS)) return 1; - - POPUPCLASS *pc = 0; - if(wParam) - pc = (POPUPCLASS *)wParam; - else { - for(int i = 0; i < num_classes; i++) { - if(strcmp(classes[i].pszName, pdc->pszClassName) == 0) { - pc = &classes[i]; - break; - } - } - } - if(pc) { - PopupData pd = {sizeof(PopupData)}; - if(pc->flags & PCF_UNICODE) pd.flags |= PDF_UNICODE; - pd.colorBack = pc->colorBack; - pd.colorText = pc->colorText; - pd.hIcon = pc->hIcon; - pd.timeout = pc->iSeconds; - pd.windowProc = pc->PluginWindowProc; - - pd.hContact = pdc->hContact; - pd.opaque = pdc->PluginData; - pd.pszTitle = (char *)pdc->pszTitle; - pd.pszText = (char *)pdc->pszText; - - ShowPopup(pd); - } - return 0; -} - -int PrebuildMenu(WPARAM wParam, LPARAM lParam) { - return 0; -} - -HANDLE hEventBuildMenu; - -void InitServices() -{ - int i = 0; - hService[i++] = CreateServiceFunction(MS_POPUP_REGISTERCLASS, RegisterPopupClass); - hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup); - hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUP, OldCreatePopupA); - hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPEX, OldCreatePopupExA); - hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPW, OldCreatePopupW); - hService[i++] = CreateServiceFunction(MS_POPUP_CHANGETEXTW, ChangeTextW); - hService[i++] = CreateServiceFunction(MS_POPUP_CHANGETEXT, ChangeTextA); - hService[i++] = CreateServiceFunction(MS_POPUP_CHANGE, PopupChangeA); - hService[i++] = CreateServiceFunction(MS_POPUP_CHANGEW, PopupChangeW); - hService[i++] = CreateServiceFunction(MS_POPUP_GETCONTACT, GetContact); - hService[i++] = CreateServiceFunction(MS_POPUP_GETPLUGINDATA, GetOpaque); - hService[i++] = CreateServiceFunction(MS_POPUP_ISSECONDLINESHOWN, IsSecondLineShown); - hService[i++] = CreateServiceFunction(MS_POPUP_QUERY, PopupQuery); - - hService[i++] = CreateServiceFunction(MS_POPUP_SHOWMESSAGE, ShowMessage); - hService[i++] = CreateServiceFunction(MS_POPUP_SHOWMESSAGE"W", ShowMessageW); - - hService[i++] = CreateServiceFunction(MS_POPUP_SHOWHISTORY, PopUp_ShowHistory); - hService[i++] = CreateServiceFunction("PopUp/ToggleEnabled", TogglePopups); - - hService[i++] = CreateServiceFunction("YAPP/RegisterClass", RegisterPopupClass); - hService[i++] = CreateServiceFunction("YAPP/ClassInstance", CreateClassPopup); - - CLISTMENUITEM mi = {0}; - - mi.cbSize = sizeof(mi); - mi.flags = CMIM_ALL; - - mi.position = 500010000; - mi.pszPopupName = LPGEN("PopUps"); - - hiPopupHistory = LoadIcon(hInst, MAKEINTRESOURCE(IDI_POPUP_HISTORY)); - mi.hIcon = hiPopupHistory; - mi.pszService= MS_POPUP_SHOWHISTORY; - mi.pszName = LPGEN("Popup History"); - hMenuShowHistory = Menu_AddMainMenuItem(&mi); - - mi.hIcon = NULL; - mi.pszService = "PopUp/ToggleEnabled"; - mi.pszName = (char*)(DBGetContactSettingByte(0, MODULE, "Enabled", 1) ? - LPGEN("Disable Popups") : LPGEN("Enable Popups")); - hMenuToggleOnOff = Menu_AddMainMenuItem(&mi); - - hEventBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildMenu); -} - -void DeinitServices() { - int i; - for(i = 0; i < num_classes; i++) { - mir_free(classes[i].pszName); - mir_free(classes[i].pszDescription); - } - mir_free(classes); num_classes = 0; - - UnhookEvent(hEventBuildMenu); - - for(i = 0; i < NUM_SERVICES; i++) - if(hService[i]) DestroyServiceFunction(hService[i]); -} diff --git a/plugins/YAPP/services.h b/plugins/YAPP/services.h deleted file mode 100644 index 8243b0ba8b..0000000000 --- a/plugins/YAPP/services.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _SERVICES_INC -#define _SERVICES_INC - -void InitServices(); -void DeinitServices(); - -extern int num_classes; -extern POPUPCLASS *classes; - -#endif diff --git a/plugins/YAPP/src/common.h b/plugins/YAPP/src/common.h new file mode 100644 index 0000000000..1b2a52b74b --- /dev/null +++ b/plugins/YAPP/src/common.h @@ -0,0 +1,114 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#define _CRT_SECURE_NO_WARNINGS + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Allow use of features specific to Windows XP or later. +#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. +#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. +#endif + + +#include + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include +#include +#include + +#define MIRANDA_VER 0x0A00 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define MODULE "YAPP" + +extern HMODULE hInst; + +extern HFONT hFontFirstLine, hFontSecondLine, hFontTime; +extern COLORREF colFirstLine, colSecondLine, colBg, colTime, colBorder, colSidebar, colTitleUnderline; + +extern MNOTIFYLINK *notifyLink; + +// work around a bug in neweventnotify, possibly httpserver +// ignore the address passed to the 'get plugin data' service +extern bool ignore_gpd_passed_addy; + +// win32 defines for mingw version of windows headers :( +#ifndef LVM_SORTITEMSEX +#define LVM_SORTITEMSEX (LVM_FIRST + 81) + +typedef int (CALLBACK *PFNLVCOMPARE)(LPARAM, LPARAM, LPARAM); + +#define ListView_SortItemsEx(hwndLV, _pfnCompare, _lPrm) \ + (BOOL)SendMessage((hwndLV), LVM_SORTITEMSEX, (WPARAM)(LPARAM)(_lPrm), (LPARAM)(PFNLVCOMPARE)(_pfnCompare)) +#endif + + +typedef struct { + int cbSize; + int flags; // OR of PDF_* flags below + HANDLE hContact; + HICON hIcon; + union { + char *pszTitle; + TCHAR *ptzTitle; + wchar_t *pwzTitle; + }; + union { + char *pszText; + TCHAR *ptzText; + wchar_t *pwzText; + }; + COLORREF colorBack; // if colorBack and colorText are equal, defaults will be used + COLORREF colorText; + WNDPROC windowProc; // optional custom window procedure + int timeout; // -1 == infinite, 0 == default, otherwise timeout in seconds + void *opaque; +} PopupData; + +#define PDF_UNICODE 0x0001 + +#define PDF_TCHAR PDF_UNICODE + +// windowProc messages +#define PM_INIT (WM_USER + 0x0202) // message sent to your windowProc after the window has been initialized +#define PM_DIENOTIFY (WM_USER + 0x0200) // message sent to your windowProc just before the window is destroyed (can be used e.g. to free your opaque data) + +#define PM_DESTROY (WM_USER + 0x0201) // send to the popup hWnd (use PostMessage generally, or SendMessage inside your windowProc) to kill it + +void ShowPopup(PopupData &pd_in); \ No newline at end of file diff --git a/plugins/YAPP/src/m_yapp.h b/plugins/YAPP/src/m_yapp.h new file mode 100644 index 0000000000..26d9be0e2e --- /dev/null +++ b/plugins/YAPP/src/m_yapp.h @@ -0,0 +1,29 @@ +#ifndef __m_yapp_h__ +#define __m_yapp_h__ + +#define NFOPT_POPUP2_BACKCOLOR "Popup2/BackColor" +#define NFOPT_POPUP2_TEXTCOLOR "Popup2/TextColor" +#define NFOPT_POPUP2_TIMEOUT "Popup2/Timeout" +#define NFOPT_POPUP2_LCLICKSVC "Popup2/LClickSvc" +#define NFOPT_POPUP2_LCLICKCOOKIE "Popup2/LClickCookie" +#define NFOPT_POPUP2_RCLICKSVC "Popup2/RClickSvc" +#define NFOPT_POPUP2_RCLICKCOOKIE "Popup2/RClickCookie" +#define NFOPT_POPUP2_STATUSMODE "Popup2/StatusMode" +#define NFOPT_POPUP2_PLUGINDATA "Popup2/PluginData" +#define NFOPT_POPUP2_WNDPROC "Popup2/WndProc" + +#define NFOPT_POPUP2_BACKCOLOR_S "Popup2/BackColor/Save" +#define NFOPT_POPUP2_TEXTCOLOR_S "Popup2/TextColor/Save" +#define NFOPT_POPUP2_TIMEOUT_S "Popup2/Timeout/Save" + +#define MS_POPUP2_SHOW "Popup2/Show" +#define MS_POPUP2_UPDATE "Popup2/Update" +#define MS_POPUP2_REMOVE "Popup2/Remove" + +#ifndef POPUP2_NOHELPERS + #define MPopup2Show(a) (CallService(MS_POPUP2_SHOW, 0, (LPARAM)(a))) + #define MPopup2Update(a) (CallService(MS_POPUP2_UPDATE, 0, (LPARAM)(a))) + #define MPopup2Remove(a) (CallService(MS_POPUP2_REMOVE, 0, (LPARAM)(a))) +#endif + +#endif // __m_yapp_h__ diff --git a/plugins/YAPP/src/message_pump.cpp b/plugins/YAPP/src/message_pump.cpp new file mode 100644 index 0000000000..7e2cea5f0c --- /dev/null +++ b/plugins/YAPP/src/message_pump.cpp @@ -0,0 +1,186 @@ +#include "common.h" +#include "message_pump.h" +#include "popwin.h" +#include "services.h" +#include "options.h" + +unsigned message_pump_thread_id = 0; +int num_popups = 0; + +HANDLE hMPEvent; + +#define MUM_FINDWINDOW (WM_USER + 0x050) + +#define MAX_POPUPS 100 + +// from popups, popup2 implementation, slightly modified +// return true if there is a full-screen application (e.g. game) running +bool is_full_screen() { + int w = GetSystemMetrics(SM_CXSCREEN); + int h = GetSystemMetrics(SM_CYSCREEN); + // use ClientRect instead of WindowRect so that it works normally for maximized applications - thx Nikto + RECT ClientRect; + HWND hWnd; + + HWND hWndDesktop = GetDesktopWindow(); + HWND hWndShell = GetShellWindow(); + + // check foregroundwindow + hWnd = GetForegroundWindow(); + if(hWnd && hWnd != hWndDesktop && hWnd != hWndShell) { + GetClientRect(hWnd, &ClientRect); + if ((ClientRect.right - ClientRect.left) >= w && (ClientRect.bottom - ClientRect.top) >= h) + return true; + } + + // check other top level windows + while ((hWnd = FindWindowEx(NULL, hWnd, NULL, NULL))) { + if(IsWindowVisible(hWnd) == 0 || IsIconic(hWnd) || hWnd == hWndDesktop || hWnd == hWndShell) + continue; + +// if(DBGetContactSettingByte(0, MODULE, "ShowForNonTopmostFullscreenWindows", 0) == 1) { + if (!(GetWindowLongPtr(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST)) + continue; +// } + + // not sure if this could be done more simply using 'IsZoomed'? + GetClientRect(hWnd, &ClientRect); + if ((ClientRect.right - ClientRect.left) < w || (ClientRect.bottom - ClientRect.top) < h) + continue; + + return true; + } + + return false; +} + +bool is_workstation_locked() +{ + bool rc = false; + HDESK hDesk = OpenDesktop((TCHAR*)_T("default"), 0, FALSE, DESKTOP_SWITCHDESKTOP); + if(hDesk != 0) { + HDESK hDeskInput = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP); + if(hDeskInput == 0) { + rc = true; + } else + CloseDesktop(hDeskInput); + + CloseDesktop(hDesk); + } + + return rc; +} + + +unsigned __stdcall MessagePumpThread(void* param) +{ + InitWindowStack(); + + if(param) SetEvent((HANDLE)param); + + MSG hwndMsg = {0}; + while(GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated()) { + if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) { + switch(hwndMsg.message) { + case MUM_CREATEPOPUP: + { + bool enabled = true; + int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0); + if(status >= ID_STATUS_OFFLINE && status <= ID_STATUS_OUTTOLUNCH && options.disable_status[status - ID_STATUS_OFFLINE]) + enabled = false; + if ((options.disable_full_screen && is_full_screen()) || is_workstation_locked()) + enabled = false; + + PopupData *pd = (PopupData *)hwndMsg.lParam; + if(enabled && num_popups < MAX_POPUPS) { + //HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, GetDesktopWindow(), 0, hInst, (LPVOID)hwndMsg.lParam); + HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)hwndMsg.lParam); + num_popups++; + if(hwndMsg.wParam) // set notifyer handle + SendMessage(hwnd, PUM_SETNOTIFYH, hwndMsg.wParam, 0); + } else { + if (pd) { + mir_free(pd->pwzTitle); + mir_free(pd->pwzText); + mir_free(pd); + } + } + } + break; + + case MUM_DELETEPOPUP: + { + HWND hwnd = (HWND)hwndMsg.lParam; + if(IsWindow(hwnd)) { + DestroyWindow(hwnd); + num_popups--; + } + } + break; + + case MUM_NMUPDATE: + { + HANDLE hNotify = (HANDLE)hwndMsg.wParam; + BroadcastMessage(PUM_UPDATENOTIFY, (WPARAM)hNotify, 0); + } + break; + + case MUM_NMREMOVE: + { + HANDLE hNotify = (HANDLE)hwndMsg.wParam; + BroadcastMessage(PUM_KILLNOTIFY, (WPARAM)hNotify, 0); + } + break; + + case MUM_NMAVATAR: + RepositionWindows(); + break; + + default: + TranslateMessage(&hwndMsg); + DispatchMessage(&hwndMsg); + break; + } + } + } + + DeinitWindowStack(); + num_popups = 0; + + //if(param) SetEvent((HANDLE)param); + + DeinitOptions(); + DeinitServices(); + + return 0; +} + +void PostMPMessage(UINT msg, WPARAM wParam, LPARAM lParam) { + PostThreadMessage(message_pump_thread_id, msg, wParam, lParam); +} + +// given a popup data pointer, and a handle to an event, this function +// will post a message to the message queue which will set the hwnd value +// and then set the event...so create an event, call this function and then wait on the event +// when the event is signalled, the hwnd will be valid +void FindWindow(PopupData *pd, HANDLE hEvent, HWND *hwnd); + +void InitMessagePump() { + WNDCLASS popup_win_class = {0}; + popup_win_class.lpfnWndProc = PopupWindowProc; + popup_win_class.hInstance = hInst; + popup_win_class.lpszClassName = POP_WIN_CLASS; + popup_win_class.hCursor = LoadCursor(NULL, IDC_ARROW); + RegisterClass(&popup_win_class); + + InitServices(); + + hMPEvent = CreateEvent(0, TRUE, 0, 0); + CloseHandle(mir_forkthreadex(MessagePumpThread, hMPEvent, &message_pump_thread_id)); + WaitForSingleObject(hMPEvent, INFINITE); + CloseHandle(hMPEvent); +} + +void DeinitMessagePump() { + PostMPMessage(WM_QUIT, 0, 0); +} diff --git a/plugins/YAPP/src/message_pump.h b/plugins/YAPP/src/message_pump.h new file mode 100644 index 0000000000..70671b157a --- /dev/null +++ b/plugins/YAPP/src/message_pump.h @@ -0,0 +1,23 @@ +#ifndef _MESSAGE_PUMP_INC +#define _MESSAGE_PUMP_INC + +extern unsigned message_pump_thread_id; +void PostMPMessage(UINT msg, WPARAM, LPARAM); + +#define MUM_CREATEPOPUP (WM_USER + 0x011) +#define MUM_DELETEPOPUP (WM_USER + 0x012) + +#define MUM_NMUPDATE (WM_USER + 0x013) +#define MUM_NMREMOVE (WM_USER + 0x014) +#define MUM_NMAVATAR (WM_USER + 0x015) + +// given a popup data pointer, and a handle to an event, this function +// will post a message to the message queue which will set the hwnd value +// and then set the event...so create an event, call this function and then wait on the event +// when the event is signalled, the hwnd will be valid +void FindWindow(PopupData *pd, HANDLE hEvent, HWND *hwnd); + +void InitMessagePump(); +void DeinitMessagePump(); + +#endif diff --git a/plugins/YAPP/src/notify.h b/plugins/YAPP/src/notify.h new file mode 100644 index 0000000000..7f39eb6d65 --- /dev/null +++ b/plugins/YAPP/src/notify.h @@ -0,0 +1,7 @@ +#ifndef _NOTIFY_IMP_INC +#define _NOTIFY_IMP_INC + +void InitNotify(); +void DeinitNotify(); + +#endif diff --git a/plugins/YAPP/src/notify_imp.cpp b/plugins/YAPP/src/notify_imp.cpp new file mode 100644 index 0000000000..061c30f1a2 --- /dev/null +++ b/plugins/YAPP/src/notify_imp.cpp @@ -0,0 +1,146 @@ +#include "common.h" +#include "resource.h" +#include "notify.h" +#include "message_pump.h" +#include "m_yapp.h" + +HANDLE hhkShow=0, hhkUpdate=0, hhkRemove=0; + +//struct + +int Popup2Show(WPARAM wParam, LPARAM lParam) { + + HANDLE hNotify = (HANDLE)lParam; + + PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData)); + memset(pd_out, 0, sizeof(PopupData)); + + PostMPMessage(MUM_CREATEPOPUP, (WPARAM)hNotify, (LPARAM)pd_out); + PostMPMessage(MUM_NMUPDATE, (WPARAM)hNotify, (LPARAM)0); + return 0; +} + +INT_PTR svcPopup2Show(WPARAM wParam, LPARAM lParam) { + return Popup2Show(wParam, lParam); +} + +int Popup2Update(WPARAM wParam, LPARAM lParam) { + HANDLE hNotify = (HANDLE)lParam; + PostMPMessage(MUM_NMUPDATE, (WPARAM)hNotify, (LPARAM)0); + return 0; +} + +int AvatarChanged(WPARAM wParam, LPARAM lParam) { + PostMPMessage(MUM_NMAVATAR, (WPARAM)0, (LPARAM)0); + return 0; +} + + +INT_PTR svcPopup2Update(WPARAM wParam, LPARAM lParam) { + return Popup2Update(wParam, lParam); +} + +int Popup2Remove(WPARAM wParam, LPARAM lParam) { + HANDLE hNotify = (HANDLE)lParam; + PostMPMessage(MUM_NMREMOVE, (WPARAM)hNotify, (LPARAM)0); + return 0; +} + +INT_PTR svcPopup2Remove(WPARAM wParam, LPARAM lParam) { + return Popup2Remove(wParam, lParam); +} + +INT_PTR svcPopup2DefaultActions(WPARAM wParam, LPARAM lParam) +{ + //PopupWindow *wnd = (PopupWindow *)MNotifyGetDWord((HANDLE)lParam, "Popup2/data", (DWORD)NULL); + //if (!wnd) return 0; + switch (wParam) + { + case 0: + { // send message + //if (wnd->lchContact) CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)wnd->lchContact, 0); + //SendMessage(wnd->lchMain, UM_DESTROYPOPUP, 0, 0); + break; + } + case 1: + { // dismiss popup + //SendMessage(wnd->lchMain, UM_DESTROYPOPUP, 0, 0); + break; + } + } + return 0; +} + +INT_PTR CALLBACK DlgProcPopUps(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ +/* To change options use MNotifySet*(hNotify, ....) Apply/Cancel is implemented in notify.dll */ + HANDLE hNotify = (HANDLE)GetWindowLongPtr(hwnd, GWLP_USERDATA); + switch (msg) + { + case WM_USER+100: + { + // This will be extendet to handle array of handles for multiselect lParam + // will be HANDLE * and wParam wil; store amount of handles passed + hNotify = (HANDLE)lParam; + SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); + return TRUE; + } + + case WM_COMMAND: + // This in different from Miranda options! + SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); + break; + } + return FALSE; +} + +int NotifyOptionsInitialize(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = {0}; + odp.cbSize = sizeof(odp); + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NOTIFY); + odp.pszTitle = LPGEN("YAPP Popups"); + odp.flags=ODPF_BOLDGROUPS; + odp.pfnDlgProc = DlgProcPopUps; + CallService(MS_NOTIFY_OPT_ADDPAGE, wParam, (LPARAM)&odp); + return 0; +} + +HANDLE hEventNotifyOptInit, hEventNotifyModulesLoaded; +HANDLE hAvChangeEvent; + +int NotifyModulesLoaded(WPARAM wParam,LPARAM lParam) +{ + hEventNotifyOptInit = HookEvent(ME_NOTIFY_OPT_INITIALISE, NotifyOptionsInitialize); + hAvChangeEvent = HookEvent(ME_AV_AVATARCHANGED, AvatarChanged); + return 0; +} + +HANDLE hServicesNotify[4]; +void InitNotify() { + hhkShow = HookEvent(ME_NOTIFY_SHOW, Popup2Show); + hhkUpdate = HookEvent(ME_NOTIFY_UPDATE, Popup2Update); + hhkRemove = HookEvent(ME_NOTIFY_REMOVE, Popup2Remove); + + hServicesNotify[0] = CreateServiceFunction("Popup2/DefaultActions", svcPopup2DefaultActions); + + hServicesNotify[1] = CreateServiceFunction(MS_POPUP2_SHOW, svcPopup2Show); + hServicesNotify[2] = CreateServiceFunction(MS_POPUP2_UPDATE, svcPopup2Update); + hServicesNotify[3] = CreateServiceFunction(MS_POPUP2_REMOVE, svcPopup2Remove); + + hEventNotifyModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, NotifyModulesLoaded); +} + +void DeinitNotify() { + UnhookEvent(hhkShow); + UnhookEvent(hhkUpdate); + UnhookEvent(hhkRemove); + + UnhookEvent(hAvChangeEvent); + UnhookEvent(hEventNotifyOptInit); + UnhookEvent(hEventNotifyModulesLoaded); + + for(int i = 0; i < 4; i++) + DestroyServiceFunction(hServicesNotify[i]); +} diff --git a/plugins/YAPP/src/options.cpp b/plugins/YAPP/src/options.cpp new file mode 100644 index 0000000000..7ba798e5fa --- /dev/null +++ b/plugins/YAPP/src/options.cpp @@ -0,0 +1,505 @@ +#include "common.h" +#include "options.h" +#include "resource.h" +#include "popwin.h" +#include "services.h" + +Options options; + +HICON hPopupIcon = 0; + +void LoadModuleDependentOptions() { + if(ServiceExists(MS_AV_DRAWAVATAR)) + options.av_layout = (PopupAvLayout)DBGetContactSettingByte(0, MODULE, "AVLayout", PAV_RIGHT); + else + options.av_layout = PAV_NONE; + + options.time_layout = (PopupTimeLayout)DBGetContactSettingByte(0, MODULE, "TimeLayout", (ServiceExists(MS_AV_DRAWAVATAR) ? PT_WITHAV : PT_RIGHT)); + if(options.time_layout == PT_WITHAV && !ServiceExists(MS_AV_DRAWAVATAR)) + options.time_layout = PT_RIGHT; +} + +void LoadOptions() { + options.default_timeout = DBGetContactSettingDword(0, MODULE, "DefaultTimeout", 7); + options.win_width = DBGetContactSettingDword(0, MODULE, "WinWidth", 220); + options.win_max_height = DBGetContactSettingDword(0, MODULE, "WinMaxHeight", 400); + options.location = (PopupLocation)DBGetContactSettingByte(0, MODULE, "Location", (BYTE)PL_BOTTOMRIGHT); + options.opacity = DBGetContactSettingByte(0, MODULE, "Opacity", 75); + options.border = (DBGetContactSettingByte(0, MODULE, "Border", 1) == 1); + options.round = (DBGetContactSettingByte(0, MODULE, "RoundCorners", 1) == 1); + options.av_round = (DBGetContactSettingByte(0, MODULE, "AvatarRoundCorners", 1) == 1); + options.animate = (DBGetContactSettingByte(0, MODULE, "Animate", 1) == 1); + options.trans_bg = (DBGetContactSettingByte(0, MODULE, "TransparentBg", 0) == 1); + options.use_mim_monitor = (DBGetContactSettingByte(0, MODULE, "UseMimMonitor", 1) == 1); + options.right_icon = (DBGetContactSettingByte(0, MODULE, "RightIcon", 0) == 1); + options.av_layout = PAV_NONE; // corrected in LoadModuleDependentOptions function above + options.av_size = DBGetContactSettingDword(0, MODULE, "AVSize", 40); //tweety + options.text_indent = DBGetContactSettingDword(0, MODULE, "TextIndent", 22); + options.global_hover = (DBGetContactSettingByte(0, MODULE, "GlobalHover", 1) == 1); + options.time_layout = PT_RIGHT; // corrected in LoadModuleDependentOptions function above + + char buff[128]; + for(int i = 0; i < 10; i++) { + sprintf(buff, "DisableStatus%d", i - 1); // -1 because i forgot offline status earlier! + options.disable_status[i] = (DBGetContactSettingByte(0, MODULE, buff, 0) == 1); + } + + options.disable_full_screen = (DBGetContactSettingByte(0, MODULE, "DisableFullScreen", 1) == 1); + options.drop_shadow = (DBGetContactSettingByte(0, MODULE, "DropShadow", 0) == 1); + options.sb_width = DBGetContactSettingDword(0, MODULE, "SidebarWidth", 22); + options.padding = DBGetContactSettingDword(0, MODULE, "Padding", 4); + options.av_padding = DBGetContactSettingDword(0, MODULE, "AvatarPadding", 4); +} + +void SaveOptions() { + DBWriteContactSettingDword(0, MODULE, "DefaultTimeout", options.default_timeout); + DBWriteContactSettingDword(0, MODULE, "WinWidth", options.win_width); + DBWriteContactSettingDword(0, MODULE, "WinMaxHeight", options.win_max_height); + DBWriteContactSettingByte(0, MODULE, "Location", (BYTE)options.location); + DBWriteContactSettingByte(0, MODULE, "Opacity", (BYTE)options.opacity); + DBWriteContactSettingByte(0, MODULE, "Border", (options.border ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "RoundCorners", (options.round ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "AvatarRoundCorners", (options.av_round ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "Animate", (options.animate ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "TransparentBg", (options.trans_bg ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "UseMimMonitor", (options.use_mim_monitor ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "RightIcon", (options.right_icon ? 1 : 0)); + if(ServiceExists(MS_AV_DRAWAVATAR)) + DBWriteContactSettingByte(0, MODULE, "AVLayout", (BYTE)options.av_layout); + DBWriteContactSettingDword(0, MODULE, "AVSize", options.av_size); + DBWriteContactSettingDword(0, MODULE, "TextIndent", options.text_indent); + DBWriteContactSettingByte(0, MODULE, "GlobalHover", (options.global_hover ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "TimeLayout", (BYTE)options.time_layout); + + char buff[128]; + for(int i = 0; i < 9; i++) { + sprintf(buff, "DisableStatus%d", i - 1); + DBWriteContactSettingByte(0, MODULE, buff, options.disable_status[i] ? 1 : 0); + } + DBWriteContactSettingByte(0, MODULE, "DisableFullScreen", (options.disable_full_screen ? 1 : 0)); + DBWriteContactSettingByte(0, MODULE, "DropShadow", (options.drop_shadow ? 1 : 0)); + DBWriteContactSettingDword(0, MODULE, "SidebarWidth", options.sb_width); + DBWriteContactSettingDword(0, MODULE, "Padding", options.padding); + DBWriteContactSettingDword(0, MODULE, "AvatarPadding", options.av_padding); +} + +void ShowExamplePopups() { + PopupData pd = {sizeof(PopupData)}; + pd.hIcon = hPopupIcon; + pd.flags = PDF_TCHAR; + + pd.ptzTitle = TranslateT("Example"); + pd.ptzText = TranslateT("The quick brown fox jumped over the lazy dog."); + ShowPopup(pd); + + pd.ptzTitle = TranslateT("Example With a Long Title"); + pd.ptzText = TranslateT("The quick brown fox jumped over the lazy dog."); + ShowPopup(pd); + + pd.ptzTitle = TranslateT("Example"); + pd.ptzText = TranslateT("Thequickbrownfoxjumpedoverthelazydog."); + ShowPopup(pd); + + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while(hContact) { + if(options.av_layout != PAV_NONE && ServiceExists(MS_AV_DRAWAVATAR)) { + AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0); + if(ace && (ace->dwFlags & AVS_BITMAP_VALID)) { + pd.hContact = hContact; + pd.ptzText = TranslateT("An avatar."); + ShowPopup(pd); + break; + } + } + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } +} + +static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + + switch ( msg ) { + case WM_INITDIALOG: + TranslateDialogDefault( hwndDlg ); + + SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right")); + SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left")); + SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top right")); + SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top left")); + SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_SETCURSEL, (int)options.location, 0); + + SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left")); + SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right")); + SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_SETCURSEL, (options.right_icon ? 1 : 0), 0); + + SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("No time")); + SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time on left")); + SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time on right")); + if(ServiceExists(MS_AV_DRAWAVATAR)) + SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_ADDSTRING, 0, (LPARAM)TranslateT("Time above avatar")); + SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_SETCURSEL, (int)options.time_layout, 0); + + SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("No avatar")); + if(ServiceExists(MS_AV_DRAWAVATAR)) { + SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar")); + SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar")); + } else { + HWND hw = GetDlgItem(hwndDlg, IDC_CMB_AV); + EnableWindow(hw, FALSE); + hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE); + EnableWindow(hw, FALSE); + hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE); + EnableWindow(hw, FALSE); + } + SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_SETCURSEL, (int)options.av_layout, 0); + + CheckDlgButton(hwndDlg, IDC_CHK_GLOBALHOVER, options.global_hover ? TRUE : FALSE); + + { + // initialise and fill listbox + HWND hwndList = GetDlgItem(hwndDlg, IDC_LST_STATUS); + ListView_DeleteAllItems(hwndList); + + SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); + + LVCOLUMN lvc = {0}; + // Initialize the LVCOLUMN structure. + // The mask specifies that the format, width, text, and + // subitem members of the structure are valid. + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + + lvc.iSubItem = 0; + lvc.pszText = TranslateT("Status"); + lvc.cx = 200; // width of column in pixels + ListView_InsertColumn(hwndList, 0, &lvc); + + + LVITEM lvI = {0}; + + // Some code to create the list-view control. + // Initialize LVITEM members that are common to all + // items. + lvI.mask = LVIF_TEXT; + + char *strptr; + int i = 0; + for (; i < 10; i++) { + strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(ID_STATUS_OFFLINE + i), (LPARAM)0); + lvI.pszText = mir_a2t(strptr); + lvI.iItem = i; + ListView_InsertItem(hwndList, &lvI); + ListView_SetCheckState(hwndList, i, options.disable_status[i]); + mir_free(lvI.pszText); + } + lvI.pszText = TranslateT("Full-screen app running"); + lvI.iItem = i; + ListView_InsertItem(hwndList, &lvI); + ListView_SetCheckState(hwndList, i, options.disable_full_screen); + } + + SendDlgItemMessage(hwndDlg, IDC_SPIN_TIMEOUT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(360, 1)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 1)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0)); + SendDlgItemMessage(hwndDlg, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0)); + + if(options.default_timeout == -1) { + CheckDlgButton(hwndDlg, IDC_RAD_NOTIMEOUT, TRUE); + HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT); + EnableWindow(hw, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, 7, FALSE); + } else { + CheckDlgButton(hwndDlg, IDC_RAD_TIMEOUT, TRUE); + SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.default_timeout, FALSE); + } + if(options.right_icon) CheckDlgButton(hwndDlg, IDC_RAD_RIGHTICON, TRUE); + else CheckDlgButton(hwndDlg, IDC_RAD_LEFTICON, TRUE); + + if(ServiceExists(MS_AV_DRAWAVATAR)) { + switch(options.av_layout) { + case PAV_NONE: CheckDlgButton(hwndDlg, IDC_RAD_NOAV, TRUE); break; + case PAV_RIGHT: CheckDlgButton(hwndDlg, IDC_RAD_RIGHTAV, TRUE); break; + case PAV_LEFT: CheckDlgButton(hwndDlg, IDC_RAD_LEFTAV, TRUE); break; + } + } else { + CheckDlgButton(hwndDlg, IDC_RAD_NOAV, TRUE); + HWND hw = GetDlgItem(hwndDlg, IDC_RAD_RIGHTAV); + EnableWindow(hw, FALSE); + hw = GetDlgItem(hwndDlg, IDC_RAD_LEFTAV); + EnableWindow(hw, FALSE); + } + + SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, options.win_width, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, options.win_max_height, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, options.av_size, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_INDENT, options.text_indent, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, options.sb_width, FALSE); + SetDlgItemInt(hwndDlg, IDC_ED_PADDING, options.padding, FALSE); + + switch(options.location) { + case PL_BOTTOMRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMRIGHT, TRUE); break; + case PL_BOTTOMLEFT: CheckDlgButton(hwndDlg, IDC_RAD_BOTTOMLEFT, TRUE); break; + case PL_TOPRIGHT: CheckDlgButton(hwndDlg, IDC_RAD_TOPRIGHT, TRUE); break; + case PL_TOPLEFT: CheckDlgButton(hwndDlg, IDC_RAD_TOPLEFT, TRUE); break; + } + + SetDlgItemInt(hwndDlg, IDC_ED_TRANS, options.opacity, FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_BORDER, options.border); + CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, options.round); + CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, options.av_round); + + CheckDlgButton(hwndDlg, IDC_CHK_ANIMATE, options.animate); + CheckDlgButton(hwndDlg, IDC_CHK_TRANSBG, options.trans_bg); + + return FALSE; + case WM_COMMAND: + if ( HIWORD( wParam ) == CBN_SELCHANGE) { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } else if ( HIWORD( wParam ) == BN_CLICKED ) { + if(LOWORD(wParam) == IDC_BTN_PREVIEW) { + ShowExamplePopups(); + } else { + switch( LOWORD( wParam )) { + case IDC_RAD_NOTIMEOUT: + { + HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT); + EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_RAD_TIMEOUT)); + } + break; + case IDC_RAD_TIMEOUT: + { + HWND hw = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT); + EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_RAD_TIMEOUT)); + } + break; + } + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } + break; + case WM_NOTIFY: + if(IsWindowVisible(hwndDlg) && ((LPNMHDR) lParam)->hwndFrom == GetDlgItem(hwndDlg, IDC_LST_STATUS)) { + switch (((LPNMHDR) lParam)->code) { + + case LVN_ITEMCHANGED: + { + NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; + if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) { + SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); + } + } + break; + } + } else + if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) { + BOOL trans; + int new_val; + if(IsDlgButtonChecked(hwndDlg, IDC_RAD_NOTIMEOUT)) + options.default_timeout = -1; + else { + new_val = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &trans, FALSE); + if(trans) options.default_timeout = new_val; + } + if(options.default_timeout == 0) { + SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.default_timeout, FALSE); + MessageBox(hwndDlg, TranslateT("You cannot set a default timeout of 0.\nValue has been reset."), TranslateT("Error"), MB_OK | MB_ICONWARNING); + options.default_timeout = 7; // prevent instant timeout + } + + new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE); + if(trans) options.win_width = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE); + if(trans) options.win_max_height = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, &trans, FALSE); + if(trans) options.av_size = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &trans, FALSE); + if(trans) options.text_indent = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, &trans, FALSE); + if(trans) options.sb_width = new_val; + new_val = GetDlgItemInt(hwndDlg, IDC_ED_PADDING, &trans, FALSE); + if(trans) options.padding = new_val; + + options.location = (PopupLocation)SendDlgItemMessage(hwndDlg, IDC_CMB_PLACEMENT, CB_GETCURSEL, 0, 0); + options.right_icon = (SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_GETCURSEL, 0, 0) == 1); + options.av_layout = (PopupAvLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_GETCURSEL, 0, 0); + options.time_layout = (PopupTimeLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_TIME, CB_GETCURSEL, 0, 0); + + new_val = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, &trans, FALSE); + if(trans) options.opacity = new_val; + options.border = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_BORDER)) ? true : false; + options.round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS)) ? true : false; + options.av_round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false; + options.animate = IsDlgButtonChecked(hwndDlg, IDC_CHK_ANIMATE) ? true : false; + options.trans_bg = IsDlgButtonChecked(hwndDlg, IDC_CHK_TRANSBG) ? true : false; + options.global_hover = IsDlgButtonChecked(hwndDlg, IDC_CHK_GLOBALHOVER) ? true : false; + + int i = 0; + for (; i < 10; i++) + options.disable_status[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_STATUS), i) == 1); + options.disable_full_screen = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_STATUS), i) == 1); + + SaveOptions(); + return TRUE; + } + break; + } + + return 0; +} + +POPUPCLASS *newclasses = 0; +static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + switch ( msg ) { + case WM_INITDIALOG: + TranslateDialogDefault( hwndDlg ); + { + if(num_classes) { + newclasses = (POPUPCLASS *)mir_alloc(num_classes * sizeof(POPUPCLASS)); + memcpy(newclasses, classes, num_classes * sizeof(POPUPCLASS)); + + POPUPCLASS *pc; + int index; + for(int i = 0; i < num_classes; i++) { + pc = &newclasses[i]; + if(pc->flags & PCF_UNICODE) { + index = SendDlgItemMessageW(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pwszDescription); + } else { + index = SendDlgItemMessageA(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pszDescription); + } + SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_SETITEMDATA, index, i); + } + } + } + return FALSE; + case WM_COMMAND: + if ( LOWORD(wParam) == IDC_LST_CLASSES && HIWORD( wParam ) == LBN_SELCHANGE) { + int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_PREVIEW), index != -1); + EnableWindow(GetDlgItem(hwndDlg, IDC_COL_TEXT), index != -1); + EnableWindow(GetDlgItem(hwndDlg, IDC_COL_BG), index != -1); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_TIMEOUT), index != -1); + if(index != -1) { + int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0); + SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorText); + SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorBack); + CheckDlgButton(hwndDlg, IDC_CHK_TIMEOUT, newclasses[i].iSeconds != -1); + SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE); + } + EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), index != -1 && IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT)); + return TRUE; + } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { + int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0); + if(index != -1) { + int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0); + BOOL tr; + int t = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &tr, FALSE); + newclasses[i].iSeconds = t; + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } else { + int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0); + if(index != -1) { + int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0); + switch(LOWORD(wParam)) { + case IDC_CHK_TIMEOUT: + { + BOOL isChecked = IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT); + EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), isChecked); + if(isChecked) newclasses[i].iSeconds = 0; + else newclasses[i].iSeconds = -1; + SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE); + } + SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); + break; + case IDC_COL_TEXT: + newclasses[i].colorText = SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_GETCOLOUR, 0, 0); + SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); + break; + case IDC_COL_BG: + newclasses[i].colorBack = SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_GETCOLOUR, 0, 0); + SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); + break; + case IDC_BTN_PREVIEW: + if(newclasses[i].flags & PCF_UNICODE) { + POPUPCLASS pc = newclasses[i]; + pc.PluginWindowProc = 0; + POPUPDATACLASS d = {sizeof(d), pc.pszName}; + d.pwszTitle = L"Preview"; + d.pwszText = L"The quick brown fox jumps over the lazy dog."; + CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d); + } else { + POPUPCLASS pc = newclasses[i]; + pc.PluginWindowProc = 0; + POPUPDATACLASS d = {sizeof(d), pc.pszName}; + d.pszTitle = "Preview"; + d.pszText = "The quick brown fox jumps over the lazy dog."; + CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d); + } + break; + } + } + } + break; + case WM_NOTIFY: + if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) { + memcpy(classes, newclasses, num_classes * sizeof(POPUPCLASS)); + char setting[256]; + for(int i = 0; i < num_classes; i++) { + mir_snprintf(setting, 256, "%s/Timeout", classes[i].pszName); + DBWriteContactSettingWord(0, MODULE, setting, classes[i].iSeconds); + mir_snprintf(setting, 256, "%s/TextCol", classes[i].pszName); + DBWriteContactSettingDword(0, MODULE, setting, (DWORD)classes[i].colorText); + mir_snprintf(setting, 256, "%s/BgCol", classes[i].pszName); + DBWriteContactSettingDword(0, MODULE, setting, (DWORD)classes[i].colorBack); + } + return TRUE; + } + break; + case WM_DESTROY: + mir_free(newclasses); + break; + } + return 0; +} + +int OptInit(WPARAM wParam, LPARAM lParam) { + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.flags = ODPF_BOLDGROUPS; + odp.position = -790000000; + odp.hInstance = hInst; + odp.pszTitle = LPGEN("PopUps"); + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT1); + odp.pszTab = LPGEN("Settings"); + odp.pfnDlgProc = DlgProcOpts1; + Options_AddPage(wParam, &odp); + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_CLASSES); + odp.pszTab = LPGEN("Classes"); + odp.pfnDlgProc = DlgProcOptsClasses; + Options_AddPage(wParam, &odp); + + return 0; +} + +HANDLE hEventOptInit; +void InitOptions() { + hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit); + + // an icon for preview popups + hPopupIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); + + LoadOptions(); +} + +void DeinitOptions() { + UnhookEvent(hEventOptInit); +} diff --git a/plugins/YAPP/src/options.h b/plugins/YAPP/src/options.h new file mode 100644 index 0000000000..55b94d17db --- /dev/null +++ b/plugins/YAPP/src/options.h @@ -0,0 +1,36 @@ +#ifndef _OPTIONS_INC +#define _OPTIONS_INC + +typedef enum {PL_BOTTOMRIGHT=0, PL_BOTTOMLEFT=1, PL_TOPRIGHT=2, PL_TOPLEFT=3} PopupLocation; +typedef enum {PAV_NONE=0, PAV_LEFT=1, PAV_RIGHT=2} PopupAvLayout; +typedef enum {PT_NONE=0, PT_LEFT=1, PT_RIGHT=2, PT_WITHAV=3} PopupTimeLayout; +typedef struct { + int win_width, win_max_height, av_size; //tweety + int default_timeout; + PopupLocation location; + int opacity; + bool border; + bool round, av_round; + bool animate; + bool trans_bg; + bool use_mim_monitor; + bool right_icon; + PopupAvLayout av_layout; + bool disable_status[10]; + int text_indent; + bool global_hover; + PopupTimeLayout time_layout; + bool disable_full_screen; + bool drop_shadow; + int sb_width; + int padding, av_padding; +} Options; + +extern Options options; + +void InitOptions(); +void LoadOptions(); +void LoadModuleDependentOptions(); +void DeinitOptions(); + +#endif diff --git a/plugins/YAPP/src/popwin.cpp b/plugins/YAPP/src/popwin.cpp new file mode 100644 index 0000000000..682a3f7b05 --- /dev/null +++ b/plugins/YAPP/src/popwin.cpp @@ -0,0 +1,772 @@ +#include "common.h" +#include "popwin.h" +#include "message_pump.h" +#include "options.h" + +HMODULE hUserDll; +BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD) = 0; +BOOL (WINAPI *MyAnimateWindow)(HWND hWnd,DWORD dwTime,DWORD dwFlags) = 0; +HMONITOR (WINAPI *MyMonitorFromRect)(LPCRECT rect, DWORD flags) = 0; +BOOL (WINAPI *MyGetMonitorInfo)(HMONITOR hMonitor, LPMONITORINFO mi) = 0; + +#define ID_CLOSETIMER 0x0101 +#define ID_MOVETIMER 0x0102 + +DWORD pop_start_x, pop_start_y; +int global_mouse_in = 0; + +void trimW(wchar_t *str) { + int len = (int)wcslen(str), pos; + // trim whitespace (e.g. from OTR detection) + for(pos = len - 1; pos >= 0; pos--) { + if(str[pos] == L' ' || str[pos] == L'\t' || str[pos] == L'\r' || str[pos] == L'\n') str[pos] = 0; + else break; + } + + // remove tabs + for(pos = len - 1; pos >= 0; pos--) + if(str[pos] == L'\t') str[pos] = L' '; +} + +void SetStartValues(void) +{ + RECT wa_rect; + SystemParametersInfo(SPI_GETWORKAREA, 0, &wa_rect, 0); + if (options.use_mim_monitor && MyMonitorFromRect && MyGetMonitorInfo) + { + RECT clr; + GetWindowRect((HWND)CallService(MS_CLUI_GETHWND, 0, 0), &clr); + HMONITOR hMonitor = MyMonitorFromRect(&clr, MONITOR_DEFAULTTONEAREST); + if (hMonitor) + { + MONITORINFO mi; + mi.cbSize = sizeof(mi); + if (MyGetMonitorInfo(hMonitor, &mi)) + wa_rect = mi.rcWork; + } + } + + if(options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT) + pop_start_x = wa_rect.right - options.win_width - 1; + else + pop_start_x = wa_rect.left + 1; + + if(options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT) + pop_start_y = wa_rect.bottom - 1; + else + pop_start_y = wa_rect.top + 1; +} + +struct HWNDStackNode { + HWND hwnd; + struct HWNDStackNode *next; +}; + +HWNDStackNode *hwnd_stack_top = 0; +int stack_size = 0; + +void RepositionWindows() { + HWNDStackNode *current; + int x = pop_start_x, y = pop_start_y; + int height;//, total_height = 0; + + /* + current = hwnd_stack_top; + while(current) { + SendMessage(current->hwnd, PUM_GETHEIGHT, (WPARAM)&height, 0); + total_height += height; + current = current->next; + } + */ + + current = hwnd_stack_top; + while(current) { + SendMessage(current->hwnd, PUM_GETHEIGHT, (WPARAM)&height, 0); + if(options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT) y -= height + 1; + SendMessage(current->hwnd, PUM_MOVE, (WPARAM)x, (LPARAM)y); + if(options.location == PL_TOPRIGHT || options.location == PL_TOPLEFT) y += height + 1; + + current = current->next; + } +} + +void AddWindowToStack(HWND hwnd) { + SetStartValues(); + + HWNDStackNode *new_node = (HWNDStackNode *)mir_alloc(sizeof(HWNDStackNode)); + new_node->hwnd = hwnd; + new_node->next = hwnd_stack_top; + hwnd_stack_top = new_node; + + int height; + SendMessage(hwnd, PUM_GETHEIGHT, (WPARAM)&height, 0); + + int x = pop_start_x, y = pop_start_y; + if(options.location == PL_BOTTOMRIGHT || options.location == PL_TOPRIGHT) + x += options.win_width; + else + x -= options.win_width; + + if(options.location == PL_BOTTOMRIGHT || options.location == PL_BOTTOMLEFT) y -= height; + SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); + if(options.location == PL_TOPRIGHT || options.location == PL_TOPLEFT) y += height; + + stack_size++; + + RepositionWindows(); +} + +void RemoveWindowFromStack(HWND hwnd) { + HWNDStackNode *current = hwnd_stack_top, *prev = 0; + while(current) { + if(current->hwnd == hwnd) { + if(prev) { + prev->next = current->next; + } else { + hwnd_stack_top = current->next; + } + mir_free(current); + stack_size--; + break; + } + + prev = current; + current = current->next; + } + + if(hwnd_stack_top) RepositionWindows(); +} + +void ClearStack() { + while(hwnd_stack_top) { + DestroyWindow(hwnd_stack_top->hwnd); + } +} + +void BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam) { + HWNDStackNode *current = hwnd_stack_top; + while(current) { + SendMessage(current->hwnd, msg, wParam, lParam); + current = current->next; + } +} + +struct PopupWindowData { + PopupData *pd; + int new_x, new_y; + bool is_round, av_is_round, mouse_in, close_on_leave; + bool custom_col; + HBRUSH bkBrush, barBrush, underlineBrush; + HPEN bPen; + TCHAR tbuff[128]; + int tb_height, av_height, text_height, time_height, time_width; + int real_av_width, real_av_height; + bool have_av; + HANDLE hNotify; +}; + +LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + PopupWindowData *pwd = (PopupWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + PopupData *pd = 0; + if(pwd) pd = pwd->pd; + + switch(uMsg) { + case WM_CREATE: + { + CREATESTRUCT *cs = (CREATESTRUCT *)lParam; + pwd = (PopupWindowData *)mir_alloc(sizeof(PopupWindowData)); + pd = (PopupData *)cs->lpCreateParams; + pwd->pd = pd; + pwd->hNotify = 0; + + trimW(pwd->pd->pwzTitle); + trimW(pwd->pd->pwzText); + + pwd->is_round = options.round; + pwd->av_is_round = options.av_round; + pwd->mouse_in = pwd->close_on_leave = false; + pwd->custom_col = (pd->colorBack != pd->colorText); + + pwd->tb_height = pwd->av_height = pwd->text_height = pwd->time_height = pwd->time_width = 0; + pwd->have_av = false; + + if(pwd->custom_col) { + pwd->bkBrush = CreateSolidBrush(pd->colorBack); + + //pwd->barBrush = CreateSolidBrush(pd->colorBack / 2); // make sidebar a dark version of the bg + //DWORD darkBg = (((pd->colorBack & 0xff0000) >> 1) & 0xff0000) + (((pd->colorBack & 0xff00) >> 1) & 0xff00) + (((pd->colorBack & 0xff) >> 1) & 0xff); + //DWORD darkBg = (pdColorBack >> 1) & 0x7f7f7f; // equivalent to above :) + + DWORD darkBg = pd->colorBack - ((pd->colorBack >> 2) & 0x3f3f3f); // 3/4 of current individual RGB components + pwd->barBrush = CreateSolidBrush(darkBg); // make sidebar a dark version of the bg + pwd->underlineBrush = CreateSolidBrush(pd->colorBack); // make sidebar a dark version of the bg + } else { + pwd->bkBrush = CreateSolidBrush(colBg); + pwd->barBrush = CreateSolidBrush(colSidebar); + pwd->underlineBrush = CreateSolidBrush(colTitleUnderline); + } + + if(options.border) pwd->bPen = (HPEN)CreatePen(PS_SOLID, 1, colBorder); + else pwd->bPen = CreatePen(PS_SOLID, 1, pwd->custom_col ? pd->colorBack : colBg); + + SYSTEMTIME st; + GetLocalTime(&st); + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, 0, pwd->tbuff, 128); + + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pwd); + + if(pd->timeout == -1 || (pd->timeout == 0 && options.default_timeout == -1)) { + // make a really long timeout - say 7 days? ;) + SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0); + } else { + if(pd->timeout == 0) { + SetTimer(hwnd, ID_CLOSETIMER, options.default_timeout * 1000, 0); + } else { + SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0); + } + } + + AddWindowToStack(hwnd); // this updates our size + } + + // transparency +#ifdef WS_EX_LAYERED + SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); +#endif + +#ifdef CS_DROPSHADOW + if (options.drop_shadow) { + SetClassLong(hwnd, GCL_STYLE, CS_DROPSHADOW); + } +#endif + +#ifdef LWA_ALPHA + if(MySetLayeredWindowAttributes) { + MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (int)(options.opacity / 100.0 * 255), LWA_ALPHA); + if(options.trans_bg) { + COLORREF bg; + if(pd->colorBack == pd->colorText) + bg = colBg; + else + bg = pd->colorBack; + MySetLayeredWindowAttributes(hwnd, bg, 0, LWA_COLORKEY); + } + } +#endif + PostMessage(hwnd, PM_INIT, (WPARAM)hwnd, 0); + return 0; + case WM_MOUSEMOVE: + if(pwd && !pwd->mouse_in) { + pwd->mouse_in = true; + global_mouse_in++; + TRACKMOUSEEVENT tme = { sizeof(tme) }; + tme.dwFlags = TME_LEAVE; + tme.hwndTrack = hwnd; + TrackMouseEvent(&tme); + } + break; + case WM_MOUSELEAVE: + if(pwd && pwd->mouse_in) { + pwd->mouse_in = false; + global_mouse_in--; + } + return 0; + case WM_LBUTTONUP: + // fake STN_CLICKED notification + SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(0, STN_CLICKED), 0); + break; + case WM_TIMER: + if(wParam == ID_CLOSETIMER) { + KillTimer(hwnd, ID_CLOSETIMER); + if(pwd->mouse_in || (options.global_hover && global_mouse_in)) + SetTimer(hwnd, ID_CLOSETIMER, 800, 0); // reset timer if mouse in window - allow another 800 ms + else { + PostMessage(hwnd, PM_DESTROY, 0, 0); + } + return TRUE; + } else if(wParam == ID_MOVETIMER) { + RECT r; + GetWindowRect(hwnd, &r); + + if(r.left == pwd->new_x && r.top == pwd->new_y) { + KillTimer(hwnd, ID_MOVETIMER); + return TRUE; + } + int adj_x = (pwd->new_x - r.left) / 4, adj_y = (pwd->new_y - r.top) / 4; + if(adj_x == 0) adj_x = (pwd->new_x - r.left); + if(adj_y == 0) adj_y = (pwd->new_y - r.top); + + int x = r.left + adj_x, y = r.top + adj_y; + //SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOCOPYBITS); + SetWindowPos(hwnd, 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); + + + /* + // clip to monitor bounds (paints badly!) + //HDC hdc = GetDC(hwnd); + HMONITOR hMonitor = MonitorFromRect(&r, MONITOR_DEFAULTTONEAREST); + MONITORINFO mi; + mi.cbSize = sizeof(mi); + GetMonitorInfo(hMonitor, &mi); + + POINT p[2]; + p[0].x = mi.rcWork.left; p[0].y = mi.rcWork.top; p[1].x = mi.rcWork.right; p[1].y = mi.rcWork.bottom; + //LPtoDP(hdc, p, 2); + ScreenToClient(hwnd, &p[0]); ScreenToClient(hwnd, &p[1]); + + HRGN hMonRgn = CreateRectRgn(p[0].x, p[0].y, p[1].x, p[1].y); + //ReleaseDC(hwnd, hdc); + + RECT cr; GetClientRect(hwnd, &cr); + HRGN hWndRgn = CreateRectRgn(cr.left, cr.top, cr.right + 3, cr.bottom + 3); + CombineRgn(hMonRgn, hMonRgn, hWndRgn, RGN_AND); + + // round corners + if(options.round) { + HRGN hRgn1; + int v,h, w=10; + h=(r.right-r.left)>(w*2)?w:(r.right-r.left); + v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top); + h=(hbkBrush); + // sidebar + r_bar = r; + r_bar.right = r.left + options.sb_width; + FillRect(hdc, &r_bar, pwd->barBrush); + // border + if(options.border) { + + HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, GetStockObject(NULL_BRUSH)); + HPEN hOldPen = (HPEN)SelectObject(hdc, pwd->bPen); + + int h = 0; + if(options.round) { + int v; + int w=14; + h=(r.right-r.left)>(w*2)?w:(r.right-r.left); + v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top); + h=(hcustom_col) SetBkColor(ps.hdc, pd->colorBack); + //else SetBkColor(ps.hdc, colBg); + SetBkMode(hdc, TRANSPARENT); + + // avatar & time if with avatar + if(options.av_layout != PAV_NONE && (pwd->have_av || options.time_layout == PT_WITHAV)) { + RECT avr; + avr.top = options.av_padding; + + if(options.av_layout == PAV_LEFT) { + avr.left = r.left + options.av_padding; + if(pwd->have_av && options.time_layout == PT_WITHAV) avr.right = avr.left + max(pwd->real_av_width, pwd->time_width); + else if(pwd->have_av) avr.right = avr.left + pwd->real_av_width; + else avr.right = avr.left + pwd->time_width; + r.left = avr.right; + } else if(options.av_layout == PAV_RIGHT) { + avr.right = r.right - options.av_padding; + if(pwd->have_av && options.time_layout == PT_WITHAV) avr.left = avr.right - max(pwd->real_av_width, pwd->time_width); + else if(pwd->have_av) avr.left = avr.right - pwd->real_av_width; + else avr.left = avr.right - pwd->time_width; + r.right = avr.left; + } + + if(options.time_layout == PT_WITHAV) { + avr.top = options.padding; + avr.bottom = avr.top + pwd->time_height; + if(pwd->custom_col) SetTextColor(ps.hdc, pd->colorText); + else SetTextColor(ps.hdc, colTime); + if(hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime); + DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &avr, DT_VCENTER | DT_CENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX); + avr.top = avr.bottom + options.av_padding; + } + + if(pwd->have_av) { + // correct for wider time + if(options.time_layout == PT_WITHAV && pwd->time_width > options.av_size) { + avr.left = avr.left + (pwd->time_width - pwd->real_av_width) / 2; + avr.right = avr.left + pwd->real_av_width; + } + avr.bottom = avr.top + pwd->real_av_height; + + AVATARDRAWREQUEST adr = {0}; + adr.cbSize = sizeof(adr); + adr.hContact = pd->hContact; + adr.hTargetDC = ps.hdc; + adr.rcDraw = avr; + adr.dwFlags = (pwd->av_is_round ? AVDRQ_ROUNDEDCORNER : 0); + adr.radius = 5; //(pwd->av_is_round ? 5 : 0); + + CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&adr); + } + } + + // title icon + int iconx, textxmin = r.left + options.padding, textxmax = r.right - options.padding; + if(pd->hIcon) { + if(options.right_icon) { + iconx = r.right - (16 + options.padding); + textxmax -= 16 + options.padding; + } else { + iconx = r.left + options.padding; + textxmin += 16 + options.padding; + } + DrawIconEx(ps.hdc, iconx, options.padding + (pwd->tb_height - 16) / 2, pd->hIcon, 16, 16, 0, NULL, DI_NORMAL); + } + + // title time + if(options.time_layout == PT_LEFT || options.time_layout == PT_RIGHT) { + RECT ttr; + ttr.top = r.top + options.padding; ttr.bottom = ttr.top + pwd->tb_height; + if(pwd->custom_col) SetTextColor(ps.hdc, pd->colorText); + else SetTextColor(ps.hdc, colTime); + if(hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime); + switch(options.time_layout) { + case PT_LEFT: + ttr.left = textxmin; ttr.right = ttr.left + pwd->time_width; + textxmin += pwd->time_width + options.padding; + DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX); + break; + case PT_RIGHT: + ttr.right = textxmax; ttr.left = ttr.right - pwd->time_width; + textxmax -= pwd->time_width + options.padding; + DrawText(ps.hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX); + break; + default: + break; + } + } + + if(textxmin < options.sb_width) textxmin = options.sb_width + options.padding / 2; + + // title text + if(hFontFirstLine) SelectObject(ps.hdc, (HGDIOBJ)hFontFirstLine); + RECT tr; + tr.left = r.left + options.padding + options.text_indent; tr.right = textxmax; tr.top = r.top + options.padding; tr.bottom = tr.top + pwd->tb_height; + + if(pwd->custom_col) SetTextColor(ps.hdc, pd->colorText); + else SetTextColor(ps.hdc, colFirstLine); + TCHAR *title = mir_u2t(pd->pwzTitle); + DrawText(ps.hdc, title, (int)_tcslen(title), &tr, DT_VCENTER | DT_LEFT | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX); + mir_free(title); + + // title underline + RECT tur; + tur.left = r.left + options.sb_width + options.padding; + tur.right = r.right - options.padding; + tur.top = tr.bottom + options.padding/2; + tur.bottom = tur.top + 1; + FillRect(ps.hdc, &tur, pwd->underlineBrush); + + // second line(s) + if(pd->pwzText[0]) { + if(hFontSecondLine) SelectObject(ps.hdc, (HGDIOBJ)hFontSecondLine); + if (!pwd->custom_col) + SetTextColor(ps.hdc, colSecondLine); + + // expand text if no avatar and the time isn't too large + if(options.av_layout != PAV_NONE && options.time_layout == PT_WITHAV && pwd->time_height <= pwd->tb_height && !pwd->have_av) + GetClientRect(hwnd, &r); + + TCHAR *text = mir_u2t(pd->pwzText); + tr.left = r.left + options.padding + options.text_indent; tr.right = r.right - options.padding; tr.top = tr.bottom + options.padding; tr.bottom = r.bottom - options.padding; + DrawText(ps.hdc, text, (int)_tcslen(text), &tr, DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS); + mir_free(text); + } + + EndPaint(hwnd, &ps); + //} + } + return 0; + + case WM_DESTROY: + if(pwd->mouse_in) global_mouse_in--; + + ShowWindow(hwnd, SW_HIDE); + + DeleteObject(pwd->bkBrush); + DeleteObject(pwd->bPen); + DeleteObject(pwd->barBrush); + DeleteObject(pwd->underlineBrush); + KillTimer(hwnd, ID_MOVETIMER); + KillTimer(hwnd, ID_CLOSETIMER); + + RemoveWindowFromStack(hwnd); + + SendMessage(hwnd, PM_DIENOTIFY, 0, 0); + + if (pd) { + mir_free(pd->pwzTitle); + mir_free(pd->pwzText); + mir_free(pd); + } + mir_free(pwd); pwd = 0; pd = 0; + SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); + break; + + case PUM_UPDATERGN: + // round corners + if(pwd->is_round) { + HRGN hRgn1; + RECT r; + + int v,h; + int w=11; + GetWindowRect(hwnd,&r); + h=(r.right-r.left)>(w*2)?w:(r.right-r.left); + v=(r.bottom-r.top)>(w*2)?w:(r.bottom-r.top); + h=(hnew_x = (int)wParam; + pwd->new_y = (int)lParam; + SetTimer(hwnd, ID_MOVETIMER, 10, 0); + } else { + SetWindowPos(hwnd, 0, (int)wParam, (int)lParam, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); + if (!IsWindowVisible(hwnd)) { + ShowWindow(hwnd, SW_SHOWNOACTIVATE); + UpdateWindow(hwnd); + } + } + return TRUE; + + case PUM_SETTEXT: + replaceStrT(pd->ptzText, (TCHAR*)lParam); + InvalidateRect(hwnd, 0, TRUE); + RepositionWindows(); + return TRUE; + + case PUM_GETCONTACT: + { + HANDLE *phContact = (HANDLE *)wParam; + *phContact = pd->hContact; + if(lParam) SetEvent((HANDLE)lParam); + } + return TRUE; + case PUM_GETHEIGHT: + { + int *pHeight = (int *)wParam; + HDC hdc = GetDC(hwnd); + SIZE size; + + // time_height + width + if(options.time_layout != PT_NONE) { + SIZE size_t; + if(hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime); + GetTextExtentPoint32(hdc, pwd->tbuff, (int)_tcslen(pwd->tbuff), &size_t); + pwd->time_height = size_t.cy; + pwd->time_width = size_t.cx; + } + + // titlebar height + if(hFontFirstLine) SelectObject(hdc, (HGDIOBJ)hFontFirstLine); + TCHAR *title = mir_u2t(pd->pwzTitle); + GetTextExtentPoint32(hdc, title, (int)_tcslen(title), &size); + mir_free(title); + pwd->tb_height = size.cy; + if(options.time_layout == PT_LEFT || options.time_layout == PT_RIGHT) { + if(pwd->tb_height < pwd->time_height) pwd->tb_height = pwd->time_height; + } + if(pwd->tb_height < 16) pwd->tb_height = 16; + + // avatar height + if(options.av_layout != PAV_NONE && ServiceExists(MS_AV_DRAWAVATAR)) { + AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)pd->hContact, 0); + if(ace && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) { + if(ace->bmHeight >= ace->bmWidth) { + pwd->real_av_height = options.av_size; + pwd->real_av_width = options.av_size * ace->bmWidth / ace->bmHeight; + } else { + pwd->real_av_height = options.av_size * ace->bmHeight / ace->bmWidth; + pwd->real_av_width = options.av_size; + } + pwd->have_av = true; + pwd->av_height = pwd->real_av_height; + } + } + + // text height + if (pd->pwzText[0]) { + RECT r; + r.left = r.top = 0; + r.right = options.win_width - 2 * options.padding - options.text_indent; + if(pwd->have_av && options.time_layout == PT_WITHAV) + r.right -= (max(options.av_size, pwd->time_width) + options.padding); + else if(pwd->have_av) + r.right -= (options.av_size + options.padding); + else if(options.av_layout != PAV_NONE && options.time_layout == PT_WITHAV && pwd->time_height >= pwd->tb_height) + r.right -= pwd->time_width + options.padding; + + if(hFontSecondLine) SelectObject(hdc, (HGDIOBJ)hFontSecondLine); + TCHAR *text = mir_u2t(pd->pwzText); + DrawText(hdc, text, (int)_tcslen(text), &r, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS); + pwd->text_height = r.bottom; + mir_free(text); + } + + ReleaseDC(hwnd, hdc); + + if(options.time_layout == PT_WITHAV && options.av_layout != PAV_NONE) + *pHeight = max(pwd->tb_height + pwd->text_height + 3 * options.padding, pwd->av_height + pwd->time_height + options.padding + 2 * options.av_padding); + else + *pHeight = max(pwd->tb_height + pwd->text_height + 3 * options.padding, pwd->av_height + 2 * options.av_padding); + + if (*pHeight > options.win_max_height) *pHeight = options.win_max_height; + + RECT r; + GetWindowRect(hwnd, &r); + if(r.right - r.left != options.win_width || r.bottom - r.top != *pHeight) { + SetWindowPos(hwnd, 0, 0, 0, options.win_width, *pHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); + SendMessage(hwnd, PUM_UPDATERGN, 0, 0); + InvalidateRect(hwnd, 0, TRUE); + } + } + return TRUE; + case PUM_GETOPAQUE: + { + void **pData = (void **)wParam; + if(pd) *pData = pd->opaque; + if(lParam) SetEvent((HANDLE)lParam); + } + return TRUE; + case PUM_CHANGE: + { + KillTimer(hwnd, ID_CLOSETIMER); + if (pd) { + mir_free(pd->pwzTitle); + mir_free(pd->pwzText); + mir_free(pd); + } + pwd->pd = pd = (PopupData *)lParam; + + if(pd->timeout != -1) { + if(pd->timeout == 0) { + SetTimer(hwnd, ID_CLOSETIMER, 7 * 1000, 0); + } else { + SetTimer(hwnd, ID_CLOSETIMER, pd->timeout * 1000, 0); + } + } else { + // make a really long timeout - say 7 days? ;) + SetTimer(hwnd, ID_CLOSETIMER, 7 * 24 * 60 * 60 * 1000, 0); + } + + InvalidateRect(hwnd, 0, TRUE); + RepositionWindows(); + } + return TRUE; + + case PUM_SETNOTIFYH: + pwd->hNotify = (HANDLE)wParam; + return TRUE; + + case PUM_UPDATENOTIFY: + if(pwd->hNotify == (HANDLE)wParam) { + pd->colorBack = MNotifyGetDWord(pwd->hNotify, NFOPT_BACKCOLOR, colBg); + pd->colorText = MNotifyGetDWord(pwd->hNotify, NFOPT_TEXTCOLOR, colSecondLine); + pd->timeout = MNotifyGetDWord(pwd->hNotify, NFOPT_TIMEOUT, options.default_timeout); + pd->hContact = (HANDLE)MNotifyGetDWord(pwd->hNotify, NFOPT_CONTACT, 0); + pd->hIcon = (HICON)MNotifyGetDWord(pwd->hNotify, NFOPT_ICON, 0); + + const wchar_t *swzName = MNotifyGetWString(pwd->hNotify, NFOPT_TITLEW, 0); + mir_free(pd->pwzTitle); + pd->pwzTitle = mir_wstrdup(swzName); + + const wchar_t *swzText = MNotifyGetWString(pwd->hNotify, NFOPT_TEXTW, 0); + mir_free(pd->pwzText); + pd->pwzText = mir_wstrdup(swzText); + + InvalidateRect(hwnd, 0, TRUE); + RepositionWindows(); + } + + return TRUE; + case PUM_KILLNOTIFY: + if(pwd->hNotify != (HANDLE)wParam) + return TRUE; + // drop through + + case PM_DESTROY: + PostMPMessage(MUM_DELETEPOPUP, 0, (LPARAM)hwnd); + return TRUE; + } + + + if(pd && pd->windowProc) + return CallWindowProc(pd->windowProc, hwnd, uMsg, wParam, lParam); + else { + // provide a way to close popups, if no PluginWindowProc is provided + if(uMsg == WM_CONTEXTMENU) { + SendMessage(hwnd, PM_DESTROY, 0, 0); + return TRUE; + } else + return DefWindowProc(hwnd, uMsg, wParam, lParam); + } +} + +void InitWindowStack() { + hUserDll = GetModuleHandle(_T("user32.dll")); + if (hUserDll) { + MySetLayeredWindowAttributes = (BOOL (WINAPI *)(HWND,COLORREF,BYTE,DWORD))GetProcAddress(hUserDll, "SetLayeredWindowAttributes"); + MyAnimateWindow=(BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(hUserDll,"AnimateWindow"); + MyMonitorFromRect=(HMONITOR (WINAPI*)(LPCRECT,DWORD))GetProcAddress(hUserDll, "MonitorFromRect"); + + MyGetMonitorInfo=(BOOL (WINAPI*)(HMONITOR,LPMONITORINFO))GetProcAddress(hUserDll, "GetMonitorInfoW"); + + } +} + +void DeinitWindowStack() { + ClearStack(); +} + diff --git a/plugins/YAPP/src/popwin.h b/plugins/YAPP/src/popwin.h new file mode 100644 index 0000000000..4d826ceade --- /dev/null +++ b/plugins/YAPP/src/popwin.h @@ -0,0 +1,28 @@ +#ifndef _POPWIN_INC +#define _POPWIN_INC + +#define POP_WIN_CLASS _T(MODULE) _T("YAPPWindowClass") + +#define PUM_SETTEXT (WM_USER + 0x020) +#define PUM_GETCONTACT (WM_USER + 0x021) +#define PUM_GETOPAQUE (WM_USER + 0x022) +#define PUM_CHANGE (WM_USER + 0x023) +#define PUM_MOVE (WM_USER + 0x024) +#define PUM_GETHEIGHT (WM_USER + 0x025) +#define PUM_UPDATERGN (WM_USER + 0x026) + +#define PUM_SETNOTIFYH (WM_USER + 0x030) +#define PUM_KILLNOTIFY (WM_USER + 0x031) +#define PUM_UPDATENOTIFY (WM_USER + 0x032) + +void InitWindowStack(); +void DeinitWindowStack(); + +void BroadcastMessage(UINT msg, WPARAM wParam, LPARAM lParam); + +void RepositionWindows(); + +LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + + +#endif diff --git a/plugins/YAPP/src/resource.h b/plugins/YAPP/src/resource.h new file mode 100644 index 0000000000..d7db4cda2e --- /dev/null +++ b/plugins/YAPP/src/resource.h @@ -0,0 +1,79 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by popups2.rc +// +#define IDD_OPT1 101 +#define IDD_DIALOG1 102 +#define IDD_OPT_NOTIFY 103 +#define IDD_LST_HISTORY 104 +#define IDI_ICON1 105 +#define IDI_POPUP_HISTORY 105 +#define IDI_ICON2 106 +#define IDD_CLASSES 107 +#define IDC_RAD_NOTIMEOUT 1001 +#define IDC_RAD_TIMEOUT 1002 +#define IDC_ED_TIMEOUT 1003 +#define IDC_SPIN_TIMEOUT 1004 +#define IDC_ED_WIDTH 1005 +#define IDC_ED_MAXHEIGHT 1006 +#define IDC_SPIN_WIDTH 1007 +#define IDC_SPIN3 1008 +#define IDC_SPIN_MAXHEIGHT 1009 +#define IDC_RAD_BOTTOMRIGHT 1010 +#define IDC_ED_INDENT 1011 +#define IDC_RAD_BOTTOMLEFT 1012 +#define IDC_ED_SBWIDTH 1012 +#define IDC_SPIN_INDENT 1013 +#define IDC_RAD_TOPRIGHT 1014 +#define IDC_SPIN_SBWIDTH 1014 +#define IDC_RAD_TOPLEFT 1015 +#define IDC_ED_PADDING 1015 +#define IDC_ED_TRANS 1016 +#define IDC_SPIN_TRANS 1017 +#define IDC_CHK_BORDER 1018 +#define IDC_CHK_ROUNDCORNERS 1019 +#define IDC_BTN_PREVIEW 1020 +#define IDC_CHK_ANIMATE 1021 +#define IDC_CHK_TRANSBG 1022 +#define IDC_RAD_RIGHTICON 1023 +#define IDC_SPIN_INDENT2 1023 +#define IDC_SPIN_PADDING 1023 +#define IDC_CHK_GLOBALHOVER 1024 +#define IDC_RAD_LEFTICON 1025 +#define IDC_CHK_ROUNDCORNERSAV 1025 +#define IDC_RAD_NOAV 1026 +#define IDC_RAD_RIGHTAV 1027 +#define IDC_RAD_NOAV3 1028 +#define IDC_RAD_LEFTAV 1029 +#define IDC_ED_MAXHEIGHT2 1030 +#define IDC_ED_AVSIZE 1031 +#define IDC_SPIN_AVSIZE 1032 +#define IDC_LST_STATUS 1033 +#define IDC_CMB_PLACEMENT 1034 +#define IDC_CMB_ICON 1035 +#define IDC_CMB_AV 1036 +#define IDC_CMB_AV2 1037 +#define IDC_CMB_TIME 1038 +#define IDC_CUSTOM1 1039 +#define IDC_COL_TEXT 1039 +#define IDC_BORDERCOLOUR 1040 +#define IDC_COL_BG 1040 +#define IDC_CLOSE 1041 +#define IDC_LIST3 1042 +#define IDC_LST_HISTORY 1043 +#define IDC_HISTORY_FILTER 1044 +#define IDC_HISTORY_FILTER_CASESENSITIVE 1046 +#define IDC_LST_CLASSES 1047 +#define IDC_CHK_TIMEOUT 1048 +#define IDC_BUTTON1 1050 + +// 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 1051 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/YAPP/src/services.cpp b/plugins/YAPP/src/services.cpp new file mode 100644 index 0000000000..4dd00fcd38 --- /dev/null +++ b/plugins/YAPP/src/services.cpp @@ -0,0 +1,524 @@ +#include "common.h" +#include "services.h" +#include "popwin.h" +#include "message_pump.h" +#include "resource.h" +#include "yapp_history.h" + +#define NUM_SERVICES 20 +HANDLE hService[NUM_SERVICES]; +HANDLE hMenuShowHistory, hMenuToggleOnOff; + +void StripBBCodesInPlace(wchar_t *text) { + if(text == 0 || DBGetContactSettingByte(0, MODULE, "StripBBCodes", 1) == 0) + return; + + int read = 0, write = 0; + int len = (int)wcslen(text); + + while(read <= len) { // copy terminating null too + while(read <= len && text[read] != L'[') { + if(text[read] != text[write]) text[write] = text[read]; + read++; write++; + } + if(read > len) break; + + if(len - read >= 3 && (_wcsnicmp(text + read, L"[b]", 3) == 0 || _wcsnicmp(text + read, L"[i]", 3) == 0)) + read += 3; + else if(len - read >= 4 && (_wcsnicmp(text + read, L"[/b]", 4) == 0 || _wcsnicmp(text + read, L"[/i]", 4) == 0)) + read += 4; + else if(len - read >= 6 && (_wcsnicmp(text + read, L"[color", 6) == 0)) { + while(read < len && text[read] != L']') read++; + read++;// skip the ']' + } else if(len - read >= 8 && (_wcsnicmp(text + read, L"[/color]", 8) == 0)) + read += 8; + else if(len - read >= 5 && (_wcsnicmp(text + read, L"[size", 5) == 0)) { + while(read < len && text[read] != L']') read++; + read++;// skip the ']' + } else if(len - read >= 7 && (_wcsnicmp(text + read, L"[/size]", 7) == 0)) + read += 7; + else { + if(text[read] != text[write]) text[write] = text[read]; + read++; write++; + } + } +} + +INT_PTR OldCreatePopupA(WPARAM wParam, LPARAM lParam) { + POPUPDATA *pd_in = (POPUPDATA *)wParam; + PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData)); + + pd_out->cbSize = sizeof(PopupData); + pd_out->flags = PDF_UNICODE; + pd_out->pwzTitle = mir_a2u(pd_in->lpzContactName); + pd_out->pwzText = mir_a2u(pd_in->lpzText); + StripBBCodesInPlace(pd_out->pwzTitle); + StripBBCodesInPlace(pd_out->pwzText); + + pd_out->hContact = pd_in->lchContact; + pd_out->hIcon = pd_in->lchIcon; + if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' + pd_out->colorBack = pd_out->colorText = 0; + else { + pd_out->colorBack = pd_in->colorBack & 0xFFFFFF; + pd_out->colorText = pd_in->colorText & 0xFFFFFF; + } + pd_out->windowProc = pd_in->PluginWindowProc; + pd_out->opaque = pd_in->PluginData; + pd_out->timeout = 0; + + lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); + + if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) { + mir_free(pd_out->pwzTitle); + mir_free(pd_out->pwzText); + mir_free(pd_out); + return -1; + } + + //MessageBox(0, pd_out->lpwzContactName, _T("CreatePopupA"), MB_OK); + PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out); + return 0; +} + +INT_PTR OldCreatePopupExA(WPARAM wParam, LPARAM lParam) { + + POPUPDATAEX *pd_in = (POPUPDATAEX *)wParam; + PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData)); + + pd_out->cbSize = sizeof(PopupData); + pd_out->flags = PDF_UNICODE; + pd_out->pwzTitle = mir_a2u(pd_in->lpzContactName); + pd_out->pwzText = mir_a2u(pd_in->lpzText); + StripBBCodesInPlace(pd_out->pwzTitle); + StripBBCodesInPlace(pd_out->pwzText); + + pd_out->hContact = pd_in->lchContact; + pd_out->hIcon = pd_in->lchIcon; + if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' + pd_out->colorBack = pd_out->colorText = 0; + else { + pd_out->colorBack = pd_in->colorBack & 0xFFFFFF; + pd_out->colorText = pd_in->colorText & 0xFFFFFF; + } + pd_out->windowProc = pd_in->PluginWindowProc; + pd_out->opaque = pd_in->PluginData; + pd_out->timeout = pd_in->iSeconds; + + lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); + if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) { + mir_free(pd_out->pwzTitle); + mir_free(pd_out->pwzText); + mir_free(pd_out); + return -1; + } + + //MessageBox(0, pd_out->lpwzContactName, _T("CreatePopupExA"), MB_OK); + PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out); + return 0; +} + +INT_PTR OldCreatePopupW(WPARAM wParam, LPARAM lParam) { + + POPUPDATAW *pd_in = (POPUPDATAW *)wParam; + PopupData *pd_out = (PopupData *)mir_calloc(sizeof(PopupData)); + + pd_out->cbSize = sizeof(PopupData); + pd_out->flags = PDF_UNICODE; + pd_out->pwzTitle = mir_wstrdup(pd_in->lpwzContactName); + pd_out->pwzText = mir_wstrdup(pd_in->lpwzText); + StripBBCodesInPlace(pd_out->pwzTitle); + StripBBCodesInPlace(pd_out->pwzText); + + pd_out->hContact = pd_in->lchContact; + pd_out->hIcon = pd_in->lchIcon; + if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' + pd_out->colorBack = pd_out->colorText = 0; + else { + pd_out->colorBack = pd_in->colorBack & 0xFFFFFF; + pd_out->colorText = pd_in->colorText & 0xFFFFFF; + } + pd_out->windowProc = pd_in->PluginWindowProc; + pd_out->opaque = pd_in->PluginData; + pd_out->timeout = pd_in->iSeconds; + + lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); + if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) { + mir_free(pd_out->pwzTitle); + mir_free(pd_out->pwzText); + mir_free(pd_out); + return -1; + } + + //MessageBox(0, pd_out->lpwzContactName, _T("CreatePopupW"), MB_OK); + PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out); + return 0; +} + +INT_PTR ChangeTextW(WPARAM wParam, LPARAM lParam) +{ + HWND hwndPop = (HWND)wParam; + wchar_t *newText = NEWWSTR_ALLOCA((wchar_t *)lParam); + StripBBCodesInPlace(newText); + + if(IsWindow(hwndPop)) + SendMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)newText); + else + mir_free(newText); + return 0; +} + +INT_PTR ChangeTextA(WPARAM wParam, LPARAM lParam) { + HWND hwndPop = (HWND)wParam; + char *newText = (char *)lParam; + wchar_t* buff = mir_a2u(newText); + StripBBCodesInPlace(buff); + + if(IsWindow(hwndPop)) + SendMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)buff); + + mir_free(buff); + return 0; +} + +void ShowPopup(PopupData &pd_in) +{ + PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData)); + *pd_out = pd_in; + if (pd_in.flags & PDF_UNICODE) { + pd_out->pwzTitle = mir_wstrdup(pd_in.pwzTitle); + pd_out->pwzText = mir_wstrdup(pd_in.pwzText); + } else { + pd_out->flags |= PDF_UNICODE; + pd_out->pwzTitle = mir_a2u(pd_in.pszTitle); + pd_out->pwzText = mir_a2u(pd_in.pszText); + } + StripBBCodesInPlace(pd_out->pwzTitle); + StripBBCodesInPlace(pd_out->pwzText); + + lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0)); + + if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) + { + mir_free(pd_out->pwzTitle); + mir_free(pd_out->pwzText); + mir_free(pd_out); + } + else + PostMPMessage(MUM_CREATEPOPUP, 0, (LPARAM)pd_out); +} + +INT_PTR GetContact(WPARAM wParam, LPARAM lParam) { + HWND hwndPop = (HWND)wParam; + HANDLE hContact; + if(GetCurrentThreadId() == message_pump_thread_id) { + SendMessage(hwndPop, PUM_GETCONTACT, (WPARAM)&hContact, 0); + } else { + HANDLE hEvent = CreateEvent(0, 0, 0, 0); + PostMessage(hwndPop, PUM_GETCONTACT, (WPARAM)&hContact, (LPARAM)hEvent); + MsgWaitForMultipleObjectsEx(1, &hEvent, INFINITE, 0, 0); + CloseHandle(hEvent); + } + + return (INT_PTR)hContact; +} + +INT_PTR GetOpaque(WPARAM wParam, LPARAM lParam) { + HWND hwndPop = (HWND)wParam; + void *data = 0; + if(GetCurrentThreadId() == message_pump_thread_id) { + SendMessage(hwndPop, PUM_GETOPAQUE, (WPARAM)&data, 0); + } else { + HANDLE hEvent = CreateEvent(0, 0, 0, 0); + PostMessage(hwndPop, PUM_GETOPAQUE, (WPARAM)&data, (LPARAM)hEvent); + MsgWaitForMultipleObjectsEx(1, &hEvent, INFINITE, 0, 0); + CloseHandle(hEvent); + } + + return (INT_PTR)data; +} + +INT_PTR IsSecondLineShown(WPARAM wParam, LPARAM lParam) { + return TRUE; +} + +void UpdateMenu() { + CLISTMENUITEM mi = {0}; + mi.cbSize = sizeof(CLISTMENUITEM); + mi.pszName = (char*)(DBGetContactSettingByte(0, MODULE, "Enabled", 1) == 1 ? LPGEN("Disable Popups") : LPGEN("Enable Popups")); + mi.flags = CMIM_NAME;// | CMIM_ICON; + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuToggleOnOff, (LPARAM)&mi); +} + +INT_PTR PopupQuery(WPARAM wParam, LPARAM lParam) { + switch(wParam) { + case PUQS_ENABLEPOPUPS: + { + bool enabled = DBGetContactSettingByte(0, MODULE, "Enabled", 1) != 0; + if (!enabled) DBWriteContactSettingByte(0, MODULE, "Enabled", 1); + return !enabled; + } + break; + case PUQS_DISABLEPOPUPS: + { + bool enabled = DBGetContactSettingByte(0, MODULE, "Enabled", 1) != 0; + if (enabled) DBWriteContactSettingByte(0, MODULE, "Enabled", 0); + return enabled; + } + break; + case PUQS_GETSTATUS: + return DBGetContactSettingByte(0, MODULE, "Enabled", 1); + default: + return 1; + } + UpdateMenu(); + return 0; +} + +INT_PTR TogglePopups(WPARAM wParam, LPARAM lParam) { + BYTE val = DBGetContactSettingByte(0, MODULE, "Enabled", 1); + DBWriteContactSettingByte(0, MODULE, "Enabled", !val); + UpdateMenu(); + return 0; +} + +INT_PTR PopupChangeA(WPARAM wParam, LPARAM lParam) { + HWND hwndPop = (HWND)wParam; + POPUPDATAEX *pd_in = (POPUPDATAEX *)lParam; + + if(IsWindow(hwndPop)) { + PopupData pd_out; + pd_out.cbSize = sizeof(PopupData); + pd_out.flags = PDF_UNICODE; + + pd_out.pwzTitle = mir_a2u(pd_in->lpzContactName); + pd_out.pwzText = mir_a2u(pd_in->lpzText); + StripBBCodesInPlace(pd_out.pwzTitle); + StripBBCodesInPlace(pd_out.pwzText); + + pd_out.hContact = pd_in->lchContact; + pd_out.hIcon = pd_in->lchIcon; + if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' + pd_out.colorBack = pd_out.colorText = 0; + else { + pd_out.colorBack = pd_in->colorBack & 0xFFFFFF; + pd_out.colorText = pd_in->colorText & 0xFFFFFF; + } + pd_out.colorBack = pd_in->colorBack; + pd_out.colorText = pd_in->colorText; + pd_out.windowProc = pd_in->PluginWindowProc; + pd_out.opaque = pd_in->PluginData; + pd_out.timeout = pd_in->iSeconds; + + lstPopupHistory.Add(pd_out.pwzTitle, pd_out.pwzText, time(0)); + + SendMessage(hwndPop, PUM_CHANGE, 0, (LPARAM)&pd_out); + } + return 0; +} + +INT_PTR PopupChangeW(WPARAM wParam, LPARAM lParam) { + HWND hwndPop = (HWND)wParam; + POPUPDATAW *pd_in = (POPUPDATAW *)lParam; + + if(IsWindow(hwndPop)) { + PopupData pd_out; + pd_out.cbSize = sizeof(PopupData); + pd_out.flags = PDF_UNICODE; + + pd_out.pwzTitle = mir_wstrdup(pd_in->lpwzContactName); + pd_out.pwzText = mir_wstrdup(pd_in->lpwzText); + StripBBCodesInPlace(pd_out.pwzTitle); + StripBBCodesInPlace(pd_out.pwzText); + + pd_out.hContact = pd_in->lchContact; + pd_out.hIcon = pd_in->lchIcon; + if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg' + pd_out.colorBack = pd_out.colorText = 0; + else { + pd_out.colorBack = pd_in->colorBack & 0xFFFFFF; + pd_out.colorText = pd_in->colorText & 0xFFFFFF; + } + pd_out.colorBack = pd_in->colorBack; + pd_out.colorText = pd_in->colorText; + pd_out.windowProc = pd_in->PluginWindowProc; + pd_out.opaque = pd_in->PluginData; + pd_out.timeout = pd_in->iSeconds; + + lstPopupHistory.Add(pd_out.pwzTitle, pd_out.pwzText, time(0)); + + SendMessage(hwndPop, PUM_CHANGE, 0, (LPARAM)&pd_out); + } + return 0; +} + +INT_PTR ShowMessage(WPARAM wParam, LPARAM lParam) { + if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) return 0; + + POPUPDATAT pd = {0}; + _tcscpy(pd.lptzContactName, lParam == SM_WARNING ? _T("Warning") : _T("Notification")); + pd.lchIcon = LoadIcon(0, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION); + TCHAR *buff = mir_a2t((char *)wParam); + _tcscpy(pd.lptzText, buff); pd.lptzText[MAX_SECONDLINE-1] = 0; + mir_free(buff); + + CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, 0); + + return 0; +} + +INT_PTR ShowMessageW(WPARAM wParam, LPARAM lParam) { + if (!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) return 0; + + POPUPDATAW pd = {0}; + wcscpy(pd.lpwzContactName, lParam == SM_WARNING ? L"Warning" : L"Notification"); + pd.lchIcon = LoadIcon(0, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION); + wcsncpy(pd.lpwzText, (wchar_t *)wParam, MAX_SECONDLINE); + + CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pd, 0); + + return 0; +} + +//=====PopUp/ShowHistory +//extern BOOL CALLBACK DlgProcHistLstOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR PopUp_ShowHistory(WPARAM wParam, LPARAM lParam) +{ + if (!hHistoryWindow) { + hHistoryWindow = CreateDialog(hInst, MAKEINTRESOURCE(IDD_LST_HISTORY), NULL, DlgProcHistLst); + } + ShowWindow(hHistoryWindow, SW_SHOW); + return 0; +} + +int num_classes = 0; +POPUPCLASS *classes = 0; + +INT_PTR RegisterPopupClass(WPARAM wParam, LPARAM lParam) +{ + classes = (POPUPCLASS *)mir_realloc(classes, sizeof(POPUPCLASS) * (num_classes + 1)); + memcpy(classes + num_classes, (PVOID)lParam, sizeof(POPUPCLASS)); + POPUPCLASS *pc = classes + num_classes; + num_classes++; + + pc->pszName = mir_strdup(pc->pszName); + if(pc->flags & PCF_UNICODE) + pc->pwszDescription = mir_wstrdup(pc->pwszDescription); + else + pc->pszDescription = mir_strdup(pc->pszDescription); + + char setting[256]; + mir_snprintf(setting, 256, "%s/Timeout", pc->pszName); + pc->iSeconds = DBGetContactSettingWord(0, MODULE, setting, pc->iSeconds); + if(pc->iSeconds == (WORD)-1) pc->iSeconds = -1; + mir_snprintf(setting, 256, "%s/TextCol", pc->pszName); + pc->colorText = (COLORREF)DBGetContactSettingDword(0, MODULE, setting, (DWORD)pc->colorText); + mir_snprintf(setting, 256, "%s/BgCol", pc->pszName); + pc->colorBack = (COLORREF)DBGetContactSettingDword(0, MODULE, setting, (DWORD)pc->colorBack); + + return 0; +} + +INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam) +{ + POPUPDATACLASS *pdc = (POPUPDATACLASS *)lParam; + if(pdc->cbSize < sizeof(POPUPDATACLASS)) return 1; + + POPUPCLASS *pc = 0; + if(wParam) + pc = (POPUPCLASS *)wParam; + else { + for(int i = 0; i < num_classes; i++) { + if(strcmp(classes[i].pszName, pdc->pszClassName) == 0) { + pc = &classes[i]; + break; + } + } + } + if(pc) { + PopupData pd = {sizeof(PopupData)}; + if(pc->flags & PCF_UNICODE) pd.flags |= PDF_UNICODE; + pd.colorBack = pc->colorBack; + pd.colorText = pc->colorText; + pd.hIcon = pc->hIcon; + pd.timeout = pc->iSeconds; + pd.windowProc = pc->PluginWindowProc; + + pd.hContact = pdc->hContact; + pd.opaque = pdc->PluginData; + pd.pszTitle = (char *)pdc->pszTitle; + pd.pszText = (char *)pdc->pszText; + + ShowPopup(pd); + } + return 0; +} + +int PrebuildMenu(WPARAM wParam, LPARAM lParam) { + return 0; +} + +HANDLE hEventBuildMenu; + +void InitServices() +{ + int i = 0; + hService[i++] = CreateServiceFunction(MS_POPUP_REGISTERCLASS, RegisterPopupClass); + hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup); + hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUP, OldCreatePopupA); + hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPEX, OldCreatePopupExA); + hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPW, OldCreatePopupW); + hService[i++] = CreateServiceFunction(MS_POPUP_CHANGETEXTW, ChangeTextW); + hService[i++] = CreateServiceFunction(MS_POPUP_CHANGETEXT, ChangeTextA); + hService[i++] = CreateServiceFunction(MS_POPUP_CHANGE, PopupChangeA); + hService[i++] = CreateServiceFunction(MS_POPUP_CHANGEW, PopupChangeW); + hService[i++] = CreateServiceFunction(MS_POPUP_GETCONTACT, GetContact); + hService[i++] = CreateServiceFunction(MS_POPUP_GETPLUGINDATA, GetOpaque); + hService[i++] = CreateServiceFunction(MS_POPUP_ISSECONDLINESHOWN, IsSecondLineShown); + hService[i++] = CreateServiceFunction(MS_POPUP_QUERY, PopupQuery); + + hService[i++] = CreateServiceFunction(MS_POPUP_SHOWMESSAGE, ShowMessage); + hService[i++] = CreateServiceFunction(MS_POPUP_SHOWMESSAGE"W", ShowMessageW); + + hService[i++] = CreateServiceFunction(MS_POPUP_SHOWHISTORY, PopUp_ShowHistory); + hService[i++] = CreateServiceFunction("PopUp/ToggleEnabled", TogglePopups); + + hService[i++] = CreateServiceFunction("YAPP/RegisterClass", RegisterPopupClass); + hService[i++] = CreateServiceFunction("YAPP/ClassInstance", CreateClassPopup); + + CLISTMENUITEM mi = {0}; + + mi.cbSize = sizeof(mi); + mi.flags = CMIM_ALL; + + mi.position = 500010000; + mi.pszPopupName = LPGEN("PopUps"); + + hiPopupHistory = LoadIcon(hInst, MAKEINTRESOURCE(IDI_POPUP_HISTORY)); + mi.hIcon = hiPopupHistory; + mi.pszService= MS_POPUP_SHOWHISTORY; + mi.pszName = LPGEN("Popup History"); + hMenuShowHistory = Menu_AddMainMenuItem(&mi); + + mi.hIcon = NULL; + mi.pszService = "PopUp/ToggleEnabled"; + mi.pszName = (char*)(DBGetContactSettingByte(0, MODULE, "Enabled", 1) ? + LPGEN("Disable Popups") : LPGEN("Enable Popups")); + hMenuToggleOnOff = Menu_AddMainMenuItem(&mi); + + hEventBuildMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildMenu); +} + +void DeinitServices() { + int i; + for(i = 0; i < num_classes; i++) { + mir_free(classes[i].pszName); + mir_free(classes[i].pszDescription); + } + mir_free(classes); num_classes = 0; + + UnhookEvent(hEventBuildMenu); + + for(i = 0; i < NUM_SERVICES; i++) + if(hService[i]) DestroyServiceFunction(hService[i]); +} diff --git a/plugins/YAPP/src/services.h b/plugins/YAPP/src/services.h new file mode 100644 index 0000000000..8243b0ba8b --- /dev/null +++ b/plugins/YAPP/src/services.h @@ -0,0 +1,10 @@ +#ifndef _SERVICES_INC +#define _SERVICES_INC + +void InitServices(); +void DeinitServices(); + +extern int num_classes; +extern POPUPCLASS *classes; + +#endif diff --git a/plugins/YAPP/src/version.h b/plugins/YAPP/src/version.h new file mode 100644 index 0000000000..4118cc9091 --- /dev/null +++ b/plugins/YAPP/src/version.h @@ -0,0 +1,24 @@ +#ifndef __VERSION_H_INCLUDED +#define __VERSION_H_INCLUDED + +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 5 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 10 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM +#define __STRINGIFY(x) #x +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS) + +#define __DESC "Yet Another Popup Plugin - Provides popup notification window services (unicode and ansi) to other plugins" +#define __AUTHOR "Scott Ellis" +#define __AUTHOREMAIL "mail@scottellis.com.au" +#define __COPYRIGHT "© 2005,2006 Scott Ellis" +#define __AUTHORWEB "http://www.scottellis.com.au" + +#define __PLUGIN_NAME "YAPP" + +#define __FILENAME "yapp.dll" + +#endif //__VERSION_H_INCLUDED diff --git a/plugins/YAPP/src/yapp.cpp b/plugins/YAPP/src/yapp.cpp new file mode 100644 index 0000000000..11067040b2 --- /dev/null +++ b/plugins/YAPP/src/yapp.cpp @@ -0,0 +1,241 @@ +// popups2.cpp : Defines the entry point for the DLL application. +// + +#include "common.h" +#include "yapp.h" +#include "version.h" +#include "message_pump.h" +#include "options.h" +#include "popwin.h" +#include "notify.h" + +#include "yapp_history.h" //to be able to update the renderer + +HMODULE hInst = 0; + +MNOTIFYLINK *notifyLink = 0; + +// used to work around a bug in neweventnotify and others with the address passed in the GetPluginData function +bool ignore_gpd_passed_addy = false; + +FontID font_id_firstline = {0}, font_id_secondline = {0}, font_id_time = {0}; +ColourID colour_id_bg = {0}, colour_id_border = {0}, colour_id_sidebar = {0}, colour_id_titleunderline = {0}; +FontIDW font_id_firstlinew = {0}, font_id_secondlinew = {0}, font_id_timew = {0}; +ColourIDW colour_id_bgw = {0}, colour_id_borderw = {0}, colour_id_sidebarw = {0}, colour_id_titleunderlinew = {0}; + +COLORREF colBg = GetSysColor(COLOR_3DSHADOW); +HFONT hFontFirstLine = 0, hFontSecondLine = 0, hFontTime = 0; +COLORREF colFirstLine = RGB(255, 0, 0), colSecondLine = 0, colTime = RGB(0, 0, 255), colBorder = RGB(0, 0, 0), + colSidebar = RGB(128, 128, 128), colTitleUnderline = GetSysColor(COLOR_3DSHADOW); +int hLangpack; + +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESC, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + { 0xefd15f16, 0x7ae4, 0x40d7, { 0xa8, 0xe3, 0xa4, 0x11, 0xed, 0x74, 0x7b, 0xd5 } } // {EFD15F16-7AE4-40d7-A8E3-A411ED747BD5} +}; + + + + +extern "C" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + hInst = hModule; + DisableThreadLibraryCalls(hInst); + return TRUE; +} + +extern "C" YAPP_API PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_POPUPS, MIID_LAST}; + +int ReloadFont(WPARAM wParam, LPARAM lParam) +{ + + if(ServiceExists(MS_FONT_GETW)) { + LOGFONTW log_font; + if(hFontFirstLine) DeleteObject(hFontFirstLine); + colFirstLine = CallService(MS_FONT_GETW, (WPARAM)&font_id_firstlinew, (LPARAM)&log_font); + hFontFirstLine = CreateFontIndirectW(&log_font); + if(hFontSecondLine) DeleteObject(hFontSecondLine); + colSecondLine = CallService(MS_FONT_GETW, (WPARAM)&font_id_secondlinew, (LPARAM)&log_font); + hFontSecondLine = CreateFontIndirectW(&log_font); + if(hFontTime) DeleteObject(hFontTime); + colTime = CallService(MS_FONT_GETW, (WPARAM)&font_id_timew, (LPARAM)&log_font); + hFontTime = CreateFontIndirectW(&log_font); + + colBg = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_bgw, 0); + colBorder = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_borderw, 0); + colSidebar = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_sidebarw, 0); + colTitleUnderline = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_titleunderlinew, 0); + } else + + { + LOGFONTA log_font; + if(hFontFirstLine) DeleteObject(hFontFirstLine); + colFirstLine = CallService(MS_FONT_GET, (WPARAM)&font_id_firstline, (LPARAM)&log_font); + hFontFirstLine = CreateFontIndirectA(&log_font); + if(hFontSecondLine) DeleteObject(hFontSecondLine); + colSecondLine = CallService(MS_FONT_GET, (WPARAM)&font_id_secondline, (LPARAM)&log_font); + hFontSecondLine = CreateFontIndirectA(&log_font); + if(hFontTime) DeleteObject(hFontTime); + colTime = CallService(MS_FONT_GET, (WPARAM)&font_id_time, (LPARAM)&log_font); + hFontTime = CreateFontIndirectA(&log_font); + + colBg = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_bg, 0); + colBorder = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_border, 0); + colSidebar = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_sidebar, 0); + colTitleUnderline = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_titleunderline, 0); + } + + return 0; +} + +HANDLE hEventReloadFont = 0; + +int ModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + MNotifyGetLink(); + + if (ServiceExists(MS_HPP_EG_WINDOW)) + lstPopupHistory.SetRenderer(RENDER_HISTORYPP); + + font_id_firstlinew.cbSize = sizeof(FontIDW); + font_id_firstlinew.flags = FIDF_ALLOWEFFECTS; + _tcscpy(font_id_firstlinew.group, _T("Popups")); + _tcscpy(font_id_firstlinew.name, _T("First line")); + strcpy(font_id_firstlinew.dbSettingsGroup, MODULE); + strcpy(font_id_firstlinew.prefix, "FontFirst"); + _tcscpy(font_id_firstlinew.backgroundGroup, _T("Popups")); + _tcscpy(font_id_firstlinew.backgroundName, _T("Background")); + font_id_firstlinew.order = 0; + FontRegisterT(&font_id_firstlinew); + + font_id_secondlinew.cbSize = sizeof(FontIDW); + font_id_secondlinew.flags = FIDF_ALLOWEFFECTS; + _tcscpy(font_id_secondlinew.group, _T("Popups")); + _tcscpy(font_id_secondlinew.name, _T("Second line")); + strcpy(font_id_secondlinew.dbSettingsGroup, MODULE); + strcpy(font_id_secondlinew.prefix, "FontSecond"); + _tcscpy(font_id_secondlinew.backgroundGroup, _T("Popups")); + _tcscpy(font_id_secondlinew.backgroundName, _T("Background")); + font_id_secondlinew.order = 1; + FontRegisterT(&font_id_secondlinew); + + font_id_timew.cbSize = sizeof(FontIDW); + font_id_timew.flags = FIDF_ALLOWEFFECTS; + _tcscpy(font_id_timew.group, _T("Popups")); + _tcscpy(font_id_timew.name, _T("Time")); + strcpy(font_id_timew.dbSettingsGroup, MODULE); + strcpy(font_id_timew.prefix, "FontTime"); + _tcscpy(font_id_timew.backgroundGroup, _T("Popups")); + _tcscpy(font_id_timew.backgroundName, _T("Background")); + font_id_timew.order = 2; + FontRegisterT(&font_id_timew); + + colour_id_bgw.cbSize = sizeof(ColourIDW); + _tcscpy(colour_id_bgw.group, _T("Popups")); + _tcscpy(colour_id_bgw.name, _T("Background")); + strcpy(colour_id_bgw.dbSettingsGroup, MODULE); + strcpy(colour_id_bgw.setting, "ColourBg"); + colour_id_bgw.defcolour = GetSysColor(COLOR_3DSHADOW); + colour_id_bgw.order = 0; + ColourRegisterT(&colour_id_bgw); + + colour_id_borderw.cbSize = sizeof(ColourIDW); + _tcscpy(colour_id_borderw.group, _T("Popups")); + _tcscpy(colour_id_borderw.name, _T("Border")); + strcpy(colour_id_borderw.dbSettingsGroup, MODULE); + strcpy(colour_id_borderw.setting, "ColourBorder"); + colour_id_borderw.defcolour = RGB(0, 0, 0); + colour_id_borderw.order = 1; + ColourRegisterT(&colour_id_borderw); + + colour_id_sidebarw.cbSize = sizeof(ColourIDW); + _tcscpy(colour_id_sidebarw.group, _T("Popups")); + _tcscpy(colour_id_sidebarw.name, _T("Sidebar")); + strcpy(colour_id_sidebarw.dbSettingsGroup, MODULE); + strcpy(colour_id_sidebarw.setting, "ColourSidebar"); + colour_id_sidebarw.defcolour = RGB(128, 128, 128); + colour_id_sidebarw.order = 2; + ColourRegisterT(&colour_id_sidebarw); + + colour_id_titleunderlinew.cbSize = sizeof(ColourIDW); + _tcscpy(colour_id_titleunderlinew.group, _T("Popups")); + _tcscpy(colour_id_titleunderlinew.name, _T("Title underline")); + strcpy(colour_id_titleunderlinew.dbSettingsGroup, MODULE); + strcpy(colour_id_titleunderlinew.setting, "ColourTitleUnderline"); + colour_id_titleunderlinew.defcolour = GetSysColor(COLOR_3DSHADOW); + colour_id_titleunderlinew.order = 3; + ColourRegisterT(&colour_id_titleunderlinew); + + ReloadFont(0, 0); + + hEventReloadFont = HookEvent(ME_FONT_RELOAD, ReloadFont); + + LoadModuleDependentOptions(); + + if(GetModuleHandle(_T("neweventnotify"))) + ignore_gpd_passed_addy = true; + + return 0; +} + +int PreShutdown(WPARAM wParam, LPARAM lParam) { + DeinitMessagePump(); + DeinitNotify(); + return 0; +} + +HANDLE hEventPreShutdown, hEventModulesLoaded; + +extern "C" int YAPP_API Load(void) { + + mir_getLP(&pluginInfo); + + InitMessagePump(); + InitOptions(); + InitNotify(); + + hEventPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown); + hEventModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + + /* + // test popup classes + PopupClass test = {0}; + test.cbSize = sizeof(test); + test.flags = PCF_TCHAR; + test.hIcon = LoadIcon(0, IDI_WARNING); + test.colorBack = RGB(0, 0, 0); + test.colorText = RGB(255, 255, 255); + test.iSeconds = 10; + test.ptszDescription = TranslateT("Test popup class"); + test.pszName = "popup/testclass"; + CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&test); + */ + + return 0; +} + +extern "C" int YAPP_API Unload() +{ + if(hEventReloadFont) + UnhookEvent(hEventReloadFont); + UnhookEvent(hEventPreShutdown); + UnhookEvent(hEventModulesLoaded); + DeinitNotify(); + DeleteObject(hFontFirstLine); + DeleteObject(hFontSecondLine); + DeleteObject(hFontTime); + return 0; +} diff --git a/plugins/YAPP/src/yapp.h b/plugins/YAPP/src/yapp.h new file mode 100644 index 0000000000..de86e26295 --- /dev/null +++ b/plugins/YAPP/src/yapp.h @@ -0,0 +1,12 @@ +// The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the POPUPS2_EXPORTS +// symbol defined on the command line. this symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// POPUPS2_API functions as being imported from a DLL, whereas this DLL sees symbols +// defined with this macro as being exported. +#ifdef YAPP_EXPORTS +#define YAPP_API __declspec(dllexport) +#else +#define YAPP_API __declspec(dllimport) +#endif + diff --git a/plugins/YAPP/src/yapp_history.cpp b/plugins/YAPP/src/yapp_history.cpp new file mode 100644 index 0000000000..d6b0c4b114 --- /dev/null +++ b/plugins/YAPP/src/yapp_history.cpp @@ -0,0 +1,87 @@ +#include "common.h" +#include "yapp_history.h" + +PopupHistoryList::PopupHistoryList(int renderer) +{ + this->renderer = renderer; + size = HISTORY_SIZE; //fixed size (at least for now) + historyData = (PopupHistoryData *) malloc(size * sizeof(PopupHistoryData)); //alloc space for data + count = 0; +} + +PopupHistoryList::~PopupHistoryList() +{ + Clear(); //clear the data strings + free(historyData); //deallocate the data list +} + +void PopupHistoryList::Clear() +{ + int i; + for (i = 0; i < count; i++) + { + DeleteData(i); + } + count = 0; +} + +void PopupHistoryList::RemoveItem(int index) +{ + int i; + DeleteData(index); //free the mem for that particular item + for (i = index + 1; i < count; i++) + { + historyData[i - 1] = historyData[i]; //shift all items to the left + } +} + +void PopupHistoryList::DeleteData(int index) +{ + PopupHistoryData *item = &historyData[index]; + mir_free(item->titleT); + mir_free(item->messageT); + item->timestamp = 0; //invalidate item + item->title = NULL; + item->message = NULL; + item->flags = 0; +} + +void PopupHistoryList::AddItem(PopupHistoryData item) +{ + if (count >= size) + { + RemoveItem(0); //remove first element - the oldest + count--; //it will be inc'ed later + } + historyData[count++] = item; //item has it's relevant strings dupped() + RefreshPopupHistory(hHistoryWindow, GetRenderer()); +} + +void PopupHistoryList::Add(char *title, char *message, time_t timestamp) +{ + PopupHistoryData item = {0}; //create a history item + item.timestamp = timestamp; + item.title = mir_strdup(title); + item.message = mir_strdup(message); + AddItem(item); //add it (flags = 0) +} + +void PopupHistoryList::Add(wchar_t *title, wchar_t *message, time_t timestamp) +{ + PopupHistoryData item = {0}; //create an unicode history item + item.flags = PHDF_UNICODE; //mark it as unicode + item.timestamp = timestamp; + item.titleT = mir_u2t(title); + item.messageT = mir_u2t(message); + AddItem(item); //add it +} + +PopupHistoryData *PopupHistoryList::Get(int index) +{ + if ((index < 0) || (index >= count)) //a bit of sanity check + { + return NULL; + } + + return &historyData[index]; +} diff --git a/plugins/YAPP/src/yapp_history.h b/plugins/YAPP/src/yapp_history.h new file mode 100644 index 0000000000..d527bc47f4 --- /dev/null +++ b/plugins/YAPP/src/yapp_history.h @@ -0,0 +1,96 @@ +#ifndef __yapp_history_h__ +#define __yapp_history_h__ + +#include "m_ieview.h" //need this for special renderers + +/****HISTORY ++ STUFF ***/ +//there's no include file for h++ yet +#ifndef MS_HPP_EG_WINDOW +#define MS_HPP_EG_WINDOW "History++/ExtGrid/NewWindow" +#endif + +#ifndef MS_HPP_EG_EVENT +#define MS_HPP_EG_EVENT "History++/ExtGrid/Event" +#endif + +#ifndef MS_HPP_EG_NAVIGATE +#define MS_HPP_EG_NAVIGATE "History++/ExtGrid/Navigate" +#endif + +#ifndef MS_HPP_EG_OPTIONSCHANGED +#define MS_HPP_EG_OPTIONSCHANGED "History++/ExtGrid/OptionsChanged" +#endif +/************************/ + + + +#define HISTORY_SIZE 200 //number of popup history items + +#define PHDF_UNICODE 1 + +#define POPUPMENU_TITLE 100 +#define POPUPMENU_MESSAGE 101 +#define POPUPMENU_TIMESTAMP 102 + +#define RENDER_DEFAULT 0x00000 +#define RENDER_HISTORYPP 0x00001 +#define RENDER_IEVIEW 0x00002 + +struct PopupHistoryData{ + DWORD flags; //PHDF_* flags + union{ + char *message; + wchar_t *messageW; + TCHAR *messageT; + }; + union{ + char *title; + wchar_t *titleW; + TCHAR *titleT; + }; + time_t timestamp; +}; + +class PopupHistoryList{ + private: + PopupHistoryData *historyData; //historyData[0] - oldest, historyData[size - 1] - newest + int count; + int size; + int renderer; + + void DeleteData(int index); + void AddItem(PopupHistoryData item); //adds a PopupHistoryData item + void RemoveItem(int index); + + public: + PopupHistoryList(int renderer = RENDER_DEFAULT); + ~PopupHistoryList(); + + int GetRenderer() { return renderer; } + void SetRenderer(int newRenderer) { renderer = newRenderer; } + + void Add(char *title, char *message, time_t timestamp); + void Add(wchar_t *title, wchar_t *message, time_t timestamp); + + PopupHistoryData *Get(int index); + + void Clear(); + int Count() { return count; } + int Size() { return size; } +}; + +/*Shows a history with the last popups. +Useful if you've missed a popup when it appeared. +wParam - 0 +lParam - 0 +*/ +#define MS_POPUP_SHOWHISTORY "PopUp/ShowHistory" + +extern PopupHistoryList lstPopupHistory; //defined in main.cpp +extern HWND hHistoryWindow; //the history window +extern HICON hiPopupHistory; +void RefreshPopupHistory(HWND hWnd, int renderer); + +INT_PTR CALLBACK DlgProcHistLst(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + +#endif //__popup_history_h__ diff --git a/plugins/YAPP/src/yapp_history_dlg.cpp b/plugins/YAPP/src/yapp_history_dlg.cpp new file mode 100644 index 0000000000..534af1fe0c --- /dev/null +++ b/plugins/YAPP/src/yapp_history_dlg.cpp @@ -0,0 +1,743 @@ +#include "common.h" +#include "resource.h" +#include "yapp_history.h" + +//************ Some helper resize stuff ****************** + +#define MIN_HISTORY_WIDTH 540 +#define MIN_HISTORY_HEIGHT 300 + +#define GAP_SIZE 2 + +#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 + +WNDPROC oldPopupsListProc = NULL; + +HWND hHistoryWindow = 0; //the history window +HICON hiPopupHistory; //popup history icon +PopupHistoryList lstPopupHistory; //defined in main.cpp + +const TCHAR *szHistoryColumns[] = {_T("Title"), _T("Message"), _T("Timestamp")}; //need to make sure that the string and size vectors have the same number of elements +const int cxHistoryColumns[] = {100, 450, 115}; +const int cHistoryColumns = sizeof(szHistoryColumns) / sizeof(szHistoryColumns[0]); + +struct PopupHistoryWindowData{ + HWND hIEView; +}; + +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; +} + +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; +} + +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); +} + +void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOWPOS *wndPos, int anchors) +{ + RECT rChild = AnchorCalcPos(window, rParent, wndPos, anchors); + hdWnds = DeferWindowPos(hdWnds, window, HWND_NOTOPMOST, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, SWP_NOZORDER); +} +//************************************************************ + +//Stucture passed to list sort function +struct SortParams{ + HWND hList; + int column; +}; + +static int lastColumn = -1; //last sort column + +int MatchesFilterCS(const TCHAR *filter, const PopupHistoryData *popupItem) //case sensitive +{ + if (_tcslen(filter) <= 0) { return 1; } //if no filter is set then the popup item matches the filter + int match = 0; + + match = (_tcsstr(popupItem->messageT, filter)) ? 1 : match; //check message part + + if (!match) //check title part of no match has been found + { + match = (_tcsstr(popupItem->titleT, filter)) ? 1 : match; + } + + if (!match) //if no match has been found yet try to match the timestamp + { + TCHAR buffer[1024]; + struct tm *myTime = localtime(&popupItem->timestamp); + _tcsftime(buffer, 1024, _T("%c"), myTime); + match = (_tcsstr(buffer, filter)) ? 1 : match; + } + + return match; +} + +__inline void ConvertCase(TCHAR *dest, const TCHAR *source, size_t size) +{ + _tcsncpy(dest, source, size); + _tcslwr(dest); +} + +int MatchesFilterCI(const TCHAR *filterS, const PopupHistoryData *popupItem) +{ + if (_tcslen(filterS) <= 0) { return 1; } //if no filter is set then the popup item matches the filter + int match = 0; + const int BUFFER_SIZE = 1024; + TCHAR buffer[BUFFER_SIZE]; + TCHAR filterI[BUFFER_SIZE]; + + ConvertCase(filterI, filterS, BUFFER_SIZE); + + ConvertCase(buffer, popupItem->messageT, BUFFER_SIZE); //check message part + match = (_tcsstr(buffer, filterI)) ? 1 : match; + + if (!match) // check title part of no match has been found + { + ConvertCase(buffer, popupItem->titleT, BUFFER_SIZE); + match = (_tcsstr(buffer, filterI)) ? 1 : match; + } + + if (!match) //if no match has been found yet try to match the timestamp + { + struct tm *myTime = localtime(&popupItem->timestamp); + _tcsftime(buffer, 1024, _T("%c"), myTime); + match = (_tcsstr(buffer, filterI)) ? 1 : match; + } + + return match; +} + +int CALLBACK PopupsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam) +{ + SortParams params = *(SortParams *) myParam; + const int MAX_SIZE = 512; + TCHAR text1[MAX_SIZE]; + TCHAR text2[MAX_SIZE]; + int res; + + ListView_GetItemText(params.hList, (int) lParam1, params.column, text1, MAX_SIZE); + ListView_GetItemText(params.hList, (int) lParam2, params.column, text2, MAX_SIZE); + + res = _tcsicmp(text1, text2); + + res = (params.column == lastColumn) ? -res : res; //do reverse search on second click on same column + + return res; +} + + + +int CalcCustomControlPos(IEVIEWWINDOW *ieWnd, HWND hMainWindow) +{ + RECT rect; + GetWindowRect(GetDlgItem(hMainWindow, IDC_LST_HISTORY), &rect); + ScreenToClient(hMainWindow, &rect); + //GetClientRect(hMainWindow, &rect); + + ieWnd->x = rect.left + GAP_SIZE; + ieWnd->y = rect.top + GAP_SIZE; + ieWnd->cx = rect.right - rect.left - (2 * GAP_SIZE); + ieWnd->cy = rect.bottom - rect.top - (2 * GAP_SIZE); + return 0; +} + +void MoveCustomControl(HWND hWnd, int renderer) +{ + switch (renderer) + { + case RENDER_HISTORYPP: + case RENDER_IEVIEW: + { + PopupHistoryWindowData *data = (PopupHistoryWindowData *) GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (data) + { + IEVIEWWINDOW ieWnd = {0}; + ieWnd.cbSize = sizeof(ieWnd); + ieWnd.parent = hWnd; + ieWnd.hwnd = data->hIEView; + ieWnd.iType = IEW_SETPOS; + CalcCustomControlPos(&ieWnd, hWnd); + + CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_WINDOW : MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd); + } + + break; + } + } +} + +void LoadRenderer(HWND hWnd, int renderer) +{ + switch (renderer) + { + case RENDER_HISTORYPP: + case RENDER_IEVIEW: + { + IEVIEWWINDOW ieWnd = {0}; + + ieWnd.cbSize = sizeof(ieWnd); + ieWnd.iType = IEW_CREATE; + ieWnd.dwMode = IEWM_HISTORY; + ieWnd.dwFlags = 0; + ieWnd.parent = hWnd; + CalcCustomControlPos(&ieWnd, hWnd); + + CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_WINDOW : MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd); //create the IeView or H++ control. + + PopupHistoryWindowData *data = (PopupHistoryWindowData *) mir_alloc(sizeof(PopupHistoryWindowData)); //create custom control data + data->hIEView = ieWnd.hwnd; + ShowWindow(data->hIEView, SW_SHOW); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) data); //set it as the window's user data + ShowWindow(GetDlgItem(hWnd, IDC_LST_HISTORY), SW_HIDE); + //SetWindowPos(GetDlgItem(hWnd, IDC_LST_HISTORY), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + + break; + } + } +} + +void UnloadRenderer(HWND hWnd, int renderer) +{ + switch (renderer) + { + case RENDER_HISTORYPP: + case RENDER_IEVIEW: + { + PopupHistoryWindowData *data = (PopupHistoryWindowData *) GetWindowLongPtr(hWnd, GWLP_USERDATA); + + if (data) + { + IEVIEWWINDOW ieWnd = {0}; + ieWnd.cbSize = sizeof(ieWnd); + ieWnd.parent = hWnd; + ieWnd.hwnd = data->hIEView; + ieWnd.iType = IEW_DESTROY; + CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_WINDOW : MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd); + + mir_free(data); + } + + break; + } + } +} + +void DeleteOldEvents(HWND hWnd, int renderer) +{ + switch (renderer) + { + case RENDER_HISTORYPP: + case RENDER_IEVIEW: + { + PopupHistoryWindowData *data = (PopupHistoryWindowData *) GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (data) + { + IEVIEWEVENT ieEvent = {0}; + ieEvent.cbSize = sizeof(IEVIEWEVENT); + ieEvent.hwnd = data->hIEView; + ieEvent.iType = IEE_CLEAR_LOG; + + CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_EVENT : MS_IEVIEW_EVENT, 0, (LPARAM) &ieEvent); + } + + break; + } + + case RENDER_DEFAULT: + default: + { + ListView_DeleteAllItems(GetDlgItem(hWnd, IDC_LST_HISTORY)); + + break; + } + + } +} + +typedef int (*SIG_MATCHESFILTER)(const TCHAR *filter, const PopupHistoryData *popupItem); +typedef void (*SIG_ADDEVENTS)(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHESFILTER MatchesFilter); + +IEVIEWEVENTDATA *CreateAndFillEventData(PopupHistoryData *popupItem) +{ + IEVIEWEVENTDATA *eventData = (IEVIEWEVENTDATA *) mir_calloc(sizeof(IEVIEWEVENTDATA)); + if (eventData) + { + eventData->cbSize = sizeof(IEVIEWEVENTDATA); + eventData->iType = IEED_EVENT_MESSAGE; + + eventData->dwFlags = IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT | IEEDF_UNICODE_TEXT2; + eventData->pszNickW = popupItem->titleT; + eventData->pszTextW = popupItem->messageT; + + eventData->time = (DWORD) popupItem->timestamp; + eventData->next = NULL; + } + + return eventData; +} + +void AddEventsCustomControl(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHESFILTER MatchesFilter) +{ + PopupHistoryWindowData *pwData = (PopupHistoryWindowData *) GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (pwData) + { + IEVIEWEVENT ieEvent = {0}; + ieEvent.cbSize = sizeof(IEVIEWEVENT); + ieEvent.hwnd = pwData->hIEView; + ieEvent.codepage = CP_ACP; + ieEvent.iType = IEE_LOG_MEM_EVENTS; + ieEvent.hContact = NULL;//(HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); IEVIEW needs a contact handle !! + + IEVIEWEVENTDATA *eventData = NULL; + IEVIEWEVENTDATA *cED = NULL; + IEVIEWEVENTDATA *prevED = NULL; + + int i; + int count = 0; + int size = lstPopupHistory.Count(); + PopupHistoryData *popupItem; + + for (i = 0; i < size; i++) + { + popupItem = lstPopupHistory.Get(i); + if (MatchesFilter(filter, popupItem)) + { + cED = CreateAndFillEventData(popupItem); + if (cED) + { + count++; + if (!eventData) + { + eventData = cED; + } + else{ + prevED->next = cED; + } + + prevED = cED; + } + } + } + ieEvent.count = count; + ieEvent.eventData = eventData; + + CallService((renderer == RENDER_HISTORYPP) ? MS_HPP_EG_EVENT : MS_IEVIEW_EVENT, 0, (LPARAM) &ieEvent); + + while (eventData) + { + cED = eventData; + eventData = eventData->next; + mir_free(cED); + } + } +} + +void AddEventsDefault(HWND hWnd, int renderer, TCHAR *filter, SIG_MATCHESFILTER MatchesFilter) +{ + HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY); + TCHAR buffer[1024]; + struct tm *myTime; + + LVITEM item = {0}; + item.mask = LVIF_TEXT; + + int i, lIndex; + lIndex = 0; + PopupHistoryData *popupItem; + for (i = 0; i < lstPopupHistory.Count(); i++) + { + item.iItem = lIndex; + popupItem = lstPopupHistory.Get(i); + if (MatchesFilter(filter, popupItem)) + { + item.pszText = popupItem->titleT; + ListView_InsertItem(hHistoryList, &item); + ListView_SetItemText(hHistoryList, lIndex, 1, popupItem->messageT); + myTime = localtime(&popupItem->timestamp); + _tcsftime(buffer, 1024, _T("%c"), myTime); + ListView_SetItemText(hHistoryList, lIndex++, 2, buffer); + } + } +} + +void RefreshPopupHistory(HWND hWnd, int renderer) +{ + if (!hWnd) { return; } + const int MAX_FILTER_SIZE = 1024; + SIG_MATCHESFILTER MatchesFilter = (IsDlgButtonChecked(hWnd, IDC_HISTORY_FILTER_CASESENSITIVE)) ? MatchesFilterCS : MatchesFilterCI; //case sensitive compare or not ? + + SIG_ADDEVENTS AddEvents = (renderer == RENDER_DEFAULT) ? AddEventsDefault : AddEventsCustomControl; + + TCHAR filter[MAX_FILTER_SIZE]; + DeleteOldEvents(hWnd, renderer); //delete events + + GetWindowText(GetDlgItem(hWnd, IDC_HISTORY_FILTER), filter, MAX_FILTER_SIZE); //get filter text + + AddEvents(hWnd, renderer, filter, MatchesFilter); + + if (renderer == RENDER_DEFAULT) + { + HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY); + SortParams params = {0}; + params.hList = hHistoryList; + params.column = lastColumn; + + ListView_SortItemsEx(hHistoryList, PopupsCompare, ¶ms); + } +} + +void CopyPopupDataToClipboard(HWND hList, int selection) +{ + if (!selection) + { + return; + } + + if (!GetOpenClipboardWindow()) + { + if (OpenClipboard(hList)) + { + TCHAR buffer[2048]; + buffer[0] = _T('\0'); + TCHAR *clipboard; + int i; + int found = 0; + int count = ListView_GetItemCount(hList); + int textType; + + textType = CF_UNICODETEXT; + + + for (i = 0; i < count; i++) + { + if (ListView_GetItemState(hList, i, LVIS_SELECTED)) + { + ListView_GetItemText(hList, i, selection - 100, buffer, 2048); + found = 1; + break; + } + } + if (found) + { + EmptyClipboard(); + int len = (int)_tcslen(buffer); + + HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, (len + 2) * sizeof(TCHAR)); + clipboard = (TCHAR *) GlobalLock(hData); + _tcsncpy(clipboard, buffer, len); + clipboard[len] = _T('\0'); + GlobalUnlock(hData); + if (!SetClipboardData(textType, hData)) + { + PUShowMessage("Could not set clipboard data", SM_WARNING); + } + } + CloseClipboard(); + } + else{ + PUShowMessage("Could not open clipboard", SM_WARNING); + } + } + else{ + PUShowMessage("The clipboard is not available", SM_WARNING); + } +} + +//subclass proc for the list view +BOOL CALLBACK PopupsListSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_CONTEXTMENU: + { + int x = LOWORD(lParam); + int y = HIWORD(lParam); + int selection; + + HMENU hMenu = CreatePopupMenu(); + AppendMenu(hMenu, MF_STRING, POPUPMENU_TITLE, TranslateT("Copy title to clipboard")); + AppendMenu(hMenu, MF_STRING, POPUPMENU_MESSAGE, TranslateT("Copy message to clipboard")); + AppendMenu(hMenu, MF_STRING, POPUPMENU_TIMESTAMP, TranslateT("Copy timestamp to clipboard")); + selection = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, x, y, 0, hWnd, NULL); + DestroyMenu(hMenu); + if (selection) + { + CopyPopupDataToClipboard(hWnd, selection); + } + + break; + } + + case WM_KEYUP: + { + switch (wParam) + { + case 'C': + { + if (GetKeyState(VK_CONTROL)) + { + CopyPopupDataToClipboard(hWnd, POPUPMENU_MESSAGE); + } + + break; + } + + case VK_ESCAPE: + { + SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); + + break; + } + + } + + break; + } + + case WM_SYSKEYDOWN: + { + if (wParam == 'X') + { + SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); + } + + break; + } + } + + return CallWindowProc(oldPopupsListProc, hWnd, msg, wParam, lParam); +} + +//load the columns +void LoadHistoryColumns(HWND hHistoryList) +{ + LVCOLUMN col; + col.mask = LVCF_TEXT | LVCF_WIDTH; + int i; + + for (i = 0; i < cHistoryColumns; i++) + { + col.pszText = TranslateTS(szHistoryColumns[i]); + col.cx = cxHistoryColumns[i]; + ListView_InsertColumn(hHistoryList, i, &col); + } +} + +//this is the history list window handler +INT_PTR CALLBACK DlgProcHistLst(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int bInitializing; + + switch (msg) + { + case WM_INITDIALOG: + { + bInitializing = 1; + int renderer = lstPopupHistory.GetRenderer(); + + SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiPopupHistory); + + LoadRenderer(hWnd, renderer); + + TranslateDialogDefault(hWnd); + HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY); + + ListView_SetExtendedListViewStyleEx(hHistoryList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); + + oldPopupsListProc = (WNDPROC) SetWindowLongPtr(hHistoryList, GWLP_WNDPROC, (LONG_PTR) PopupsListSubclassProc); + + LoadHistoryColumns(hHistoryList); + + RefreshPopupHistory(hWnd, renderer); + + bInitializing = 0; + + return TRUE; + } + + case WM_DESTROY: + { + UnloadRenderer(hWnd, lstPopupHistory.GetRenderer()); + hHistoryWindow = NULL; + + break; + } + + case WM_CLOSE: + { + //Utils_SaveWindowPosition(hWnd, 0, MODULE, "history_dlg"); + DestroyWindow(hWnd); + + break; + } + + case WM_WINDOWPOSCHANGING: + { + WINDOWPOS *wndPos = (WINDOWPOS *) lParam; + + if (wndPos->cx < MIN_HISTORY_WIDTH) + { + wndPos->cx = MIN_HISTORY_WIDTH; + } + if (wndPos->cy < MIN_HISTORY_HEIGHT) + { + wndPos->cy = MIN_HISTORY_HEIGHT; + } + + RECT rParent; + GetWindowRect(hWnd, &rParent); + HDWP hdWnds = BeginDeferWindowPos(4); + + AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_RIGHT | ANCHOR_BOTTOM); + AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_HISTORY_FILTER), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_BOTTOM); + AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_HISTORY_FILTER_CASESENSITIVE), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_RIGHT | ANCHOR_BOTTOM); + AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_LST_HISTORY), &rParent, wndPos, ANCHOR_ALL); + + EndDeferWindowPos(hdWnds); + MoveCustomControl(hWnd, lstPopupHistory.GetRenderer()); //move the custom control too, if any + break; + } + + + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDC_CLOSE: + { + SendMessage(hWnd, WM_CLOSE, 0, 0); + + break; + } + + case IDC_HISTORY_FILTER_CASESENSITIVE: + { + if (HIWORD(wParam) == BN_CLICKED) + { + RefreshPopupHistory(hWnd, lstPopupHistory.GetRenderer()); + } + } + + case IDC_HISTORY_FILTER: + { + if (HIWORD(wParam) == EN_CHANGE) + { + if (!bInitializing) + { + RefreshPopupHistory(hWnd, lstPopupHistory.GetRenderer()); + } + } + + break; + } + + } + + break; + } + + case WM_NOTIFY: + { + switch(((LPNMHDR)lParam)->idFrom) + { + case IDC_LST_HISTORY: + { + switch (((LPNMHDR)lParam)->code) + { + case LVN_COLUMNCLICK: + { + LPNMLISTVIEW lv = (LPNMLISTVIEW) lParam; + int column = lv->iSubItem; + SortParams params = {0}; + params.hList = GetDlgItem(hWnd, IDC_LST_HISTORY); + params.column = column; + + ListView_SortItemsEx(params.hList, PopupsCompare, (LPARAM) ¶ms); + lastColumn = (params.column == lastColumn) ? -1 : params.column; + + break; + } + } + + break; + } + } + + break; + } + } + + return 0; +} diff --git a/plugins/YAPP/version.h b/plugins/YAPP/version.h deleted file mode 100644 index 4118cc9091..0000000000 --- a/plugins/YAPP/version.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __VERSION_H_INCLUDED -#define __VERSION_H_INCLUDED - -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 5 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 10 - -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM -#define __STRINGIFY(x) #x -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS) - -#define __DESC "Yet Another Popup Plugin - Provides popup notification window services (unicode and ansi) to other plugins" -#define __AUTHOR "Scott Ellis" -#define __AUTHOREMAIL "mail@scottellis.com.au" -#define __COPYRIGHT "© 2005,2006 Scott Ellis" -#define __AUTHORWEB "http://www.scottellis.com.au" - -#define __PLUGIN_NAME "YAPP" - -#define __FILENAME "yapp.dll" - -#endif //__VERSION_H_INCLUDED diff --git a/plugins/YAPP/version.rc b/plugins/YAPP/version.rc deleted file mode 100644 index c962918f07..0000000000 --- a/plugins/YAPP/version.rc +++ /dev/null @@ -1,36 +0,0 @@ -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include -#include "version.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "Author", __AUTHOR - VALUE "FileDescription", __DESC - VALUE "InternalName", __PLUGIN_NAME - VALUE "LegalCopyright", __COPYRIGHT - VALUE "OriginalFilename", __FILENAME - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/plugins/YAPP/yapp-translation.txt b/plugins/YAPP/yapp-translation.txt deleted file mode 100644 index 82c150e612..0000000000 --- a/plugins/YAPP/yapp-translation.txt +++ /dev/null @@ -1,74 +0,0 @@ -; Common strings that belong to many files -;[PopUps] - -; ../../plugins/YAPP/notify_imp.cpp -;[YAPP Popups] - -; ../../plugins/YAPP/options.cpp -;[An avatar.] -;[Bottom left] -;[Bottom right] -;[Classes] -;[Error] -;[Example] -;[Example With a Long Title] -;[Full-screen app running] -;[Icon on left] -;[Icon on right] -;[Left avatar] -;[No avatar] -;[No time] -;[Right avatar] -;[Settings] -;[Status] -;[The quick brown fox jumped over the lazy dog.] -;[Thequickbrownfoxjumpedoverthelazydog.] -;[Time above avatar] -;[Time on left] -;[Time on right] -;[Top left] -;[Top right] -;[You cannot set a default timeout of 0.\nValue has been reset.] - -; ../../plugins/YAPP/popup_history_dlg.cpp -;[Copy message to clipboard] -;[Copy timestamp to clipboard] -;[Copy title to clipboard] - -; ../../plugins/YAPP/popups2.cpp -;[Test popup class] - -; ../../plugins/YAPP/popups2.rc -;[Animate] -;[Avatar size:] -;[Background colour:] -;[Border] -;[Case sensitive] -;[Close] -;[Custom1] -;[Default Timeout] -;[Disable when] -;[Global hover] -;[Layout] -;[Maximum height:] -;[Never timeout] -;[Opacity(%):] -;[Options] -;[Padding:] -;[Popup history] -;[Preview] -;[Round corners (avatar)] -;[Round corners (window)] -;[Set timeout] -;[Set timeout:] -;[Sidebar width:] -;[Text colour:] -;[Text indent:] -;[Timeout value (0 = default):] -;[Transparent background] -;[Width:] - -; ../../plugins/YAPP/services.cpp -;[Disable Popups] -;[Enable Popups] -;[Popup History] diff --git a/plugins/YAPP/yapp_10.vcxproj b/plugins/YAPP/yapp_10.vcxproj new file mode 100644 index 0000000000..3761ad68d5 --- /dev/null +++ b/plugins/YAPP/yapp_10.vcxproj @@ -0,0 +1,207 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + YAPP + {B6FC188B-8E54-4197-9444-8BADE9AA75E2} + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;YAPP_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + common.h + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + + + true + Windows + false + $(IntDir)$(TargetName).lib + $(SolutionDir)\lib + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Full + OnlyExplicitInline + Size + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;YAPP_EXPORTS;%(PreprocessorDefinitions) + true + false + Fast + common.h + Level3 + 4996;%(DisableSpecificWarnings) + Use + + + true + Windows + true + true + false + $(IntDir)$(TargetName).lib + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Full + OnlyExplicitInline + Size + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;YAPP_EXPORTS;%(PreprocessorDefinitions) + true + Level3 + Use + common.h + + + true + true + $(IntDir)$(TargetName).lib + true + Windows + false + $(SolutionDir)\lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + EnableFastChecks + MultiThreadedDebugDLL + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;YAPP_EXPORTS;%(PreprocessorDefinitions) + Disabled + Level3 + Use + common.h + + + $(IntDir)$(TargetName).lib + false + true + Windows + $(SolutionDir)\lib + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/YAPP/yapp_10.vcxproj.filters b/plugins/YAPP/yapp_10.vcxproj.filters new file mode 100644 index 0000000000..cb0d887b30 --- /dev/null +++ b/plugins/YAPP/yapp_10.vcxproj.filters @@ -0,0 +1,83 @@ + + + + + {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 + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/ZeroNotification/Zero Notification_10.vcxproj b/plugins/ZeroNotification/Zero Notification_10.vcxproj index 852858b5dd..f43ffb0799 100644 --- a/plugins/ZeroNotification/Zero Notification_10.vcxproj +++ b/plugins/ZeroNotification/Zero Notification_10.vcxproj @@ -82,7 +82,6 @@ Fast Level3 EditAndContinue - 4996;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -108,7 +107,6 @@ false Fast Level3 - 4996;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -136,7 +134,6 @@ false Fast Level3 - 4996;%(DisableSpecificWarnings) true @@ -167,7 +164,6 @@ false Fast Level3 - 4996;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) @@ -185,12 +181,12 @@ - + - - - + + + diff --git a/plugins/ZeroNotification/Zero Notification_10.vcxproj.filters b/plugins/ZeroNotification/Zero Notification_10.vcxproj.filters index 693662db9f..95f544a875 100644 --- a/plugins/ZeroNotification/Zero Notification_10.vcxproj.filters +++ b/plugins/ZeroNotification/Zero Notification_10.vcxproj.filters @@ -15,18 +15,18 @@ - + Source Files - + Header Files - + Header Files - + Header Files diff --git a/plugins/ZeroNotification/common.h b/plugins/ZeroNotification/common.h deleted file mode 100644 index d0efafec1b..0000000000 --- a/plugins/ZeroNotification/common.h +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define DEFAULT_NOSOUND 0x00000000 -#define DEFAULT_NOBLINK 0x00000000 -#define DEFAULT_NOCLCBLINK 0x00000000 - -#define DISABLE_SOUND "Disable &Sounds" -#define ENABLE_SOUND "Enable &Sounds" - diff --git a/plugins/ZeroNotification/docs/zeronotification-translation.txt b/plugins/ZeroNotification/docs/zeronotification-translation.txt new file mode 100644 index 0000000000..e62104e8f8 --- /dev/null +++ b/plugins/ZeroNotification/docs/zeronotification-translation.txt @@ -0,0 +1,12 @@ +; Common strings that belong to many files +;[] + +; ../../plugins/ZeroNotification/main.cpp +;[Plugins] +;[Zero Notifications] + +; ../../plugins/ZeroNotification/res/ZeroNotifyW.rc +;[Hide the \"toggle sound\" menu item (requires restart of Miranda)] +;[No CLIST blink when:] +;[No SysTray blink when:] +;[No sounds when:] diff --git a/plugins/ZeroNotification/main.cpp b/plugins/ZeroNotification/main.cpp deleted file mode 100644 index ff4aa20e93..0000000000 --- a/plugins/ZeroNotification/main.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/* -A small Miranda plugin, by bidyut, updated by Maat. - -Original plugin idea Anders Nilsson. -His plugin NoSound can be found at: -http://anders.nilsson.net/programs/miranda - -Miranda can be found here: -http://nightly.miranda.im/ -*/ - -#include "version.h" -#include "common.h" -#include "res\resource.h" - -HINSTANCE hInst; - -static HANDLE hEventSoundSettingChange, hEventStatusModeChange, hEventOptionsInitialize, hAckEvent, hSoundMenu; -CLISTMENUITEM mi; -HGENMENU noSoundMenu; -int hLangpack; - -struct CheckBoxValues_t { - DWORD style; - TCHAR *szDescr; -}; - -static const struct CheckBoxValues_t statusValues[]={ - {PF2_ONLINE, TEXT("Online")}, - {PF2_SHORTAWAY, TEXT("Away")}, - {PF2_LONGAWAY, TEXT("NA")}, - {PF2_LIGHTDND, TEXT("Occupied")}, - {PF2_HEAVYDND, TEXT("DND")}, - {PF2_FREECHAT, TEXT("Free for chat")}, - {PF2_INVISIBLE, TEXT("Invisible")}, - {PF2_OUTTOLUNCH, TEXT("Out to lunch")}, - {PF2_ONTHEPHONE, TEXT("On the phone")} -}; - -PLUGININFOEX pluginInfoEx = { - sizeof(PLUGININFOEX), - PLUGINNAME, - PLUGIN_MAKE_VERSION(VER_MAJOR, VER_MINOR, VER_RELEASE, VER_BUILD), - DESCRIPTION, - AUTHOR, - "", - COPYRIGHT, - "", - UNICODE_AWARE, - UID -}; - -extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfoEx; -} - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} - -static void FillCheckBoxTree(HWND hwndTree,const struct CheckBoxValues_t *values,int nValues,DWORD style) -{ - TVINSERTSTRUCT tvis; - int i; - - tvis.hParent=NULL; - tvis.hInsertAfter=TVI_LAST; - tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - for(i=0;i>12==2)) flags|=tvi.lParam; - tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem); - } - return flags; -} - -//Update the name on the menu -static void UpdateMenuItem() { - if (DBGetContactSettingByte(NULL, "Skin", "UseSound", 1)) - mi.ptszName = TranslateT(DISABLE_SOUND); - else - mi.ptszName = TranslateT(ENABLE_SOUND); -} - -//Called when the sound setting in the database is changed -static int SoundSettingChanged(WPARAM wParam,LPARAM lParam) -{ - DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; - if(lstrcmpA(cws->szModule, "Skin") || lstrcmpA(cws->szSetting, "UseSound")) return 0; - - UpdateMenuItem(); - - mi.flags |= CMIM_NAME; - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)noSoundMenu,(LPARAM)&mi); - - return 0; -} - -static int SetNotify(const long status){ - DBWriteContactSettingByte(NULL,"Skin","UseSound", (BYTE) !(DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoSound",DEFAULT_NOSOUND) & status)); - DBWriteContactSettingByte(NULL,"CList","DisableTrayFlash", (BYTE) (DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoBlink",DEFAULT_NOBLINK) & status)); - DBWriteContactSettingByte(NULL,"CList","NoIconBlink", (BYTE) (DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoCLCBlink",DEFAULT_NOCLCBLINK) & status)); - - UpdateMenuItem(); - - mi.flags |= CMIM_NAME; - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)noSoundMenu,(LPARAM)&mi); - - return 0; -} - -//Called whenever a change in status is detected -static int ProtoAck(WPARAM wParam, LPARAM lParam) -{ - ACKDATA *ack=(ACKDATA*)lParam; - PROTOCOLDESCRIPTOR **protos; - - //quit if not status event - if ( ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS ) { - long status = 0; - int i, count; - CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM) & count, (LPARAM) & protos); - - for (i = 0; i < count; i++) { - status = status | Proto_Status2Flag(CallProtoService(protos[i]->szName, PS_GETSTATUS, 0, 0)); - } - - SetNotify(status); - - return 0; - } - - return 0; -} - -static INT_PTR CALLBACK DlgProcNoSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - DWORD test; - switch (msg) - { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOSOUND),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOSOUND),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); - SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOBLINK),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOBLINK),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); - SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOCLCBLINK),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOCLCBLINK),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); - CheckDlgButton(hwndDlg, IDC_HIDEMENU, DBGetContactSettingByte(NULL,PLUGINNAME_SHORT,"HideMenu",1) ? BST_CHECKED : BST_UNCHECKED); - - FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_NOSOUND),statusValues,sizeof(statusValues)/sizeof(statusValues[0]),DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoSound",DEFAULT_NOSOUND)); - FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_NOBLINK),statusValues,sizeof(statusValues)/sizeof(statusValues[0]),DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoBlink",DEFAULT_NOBLINK)); - FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_NOCLCBLINK),statusValues,sizeof(statusValues)/sizeof(statusValues[0]),DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoCLCBlink",DEFAULT_NOCLCBLINK)); - return TRUE; - case WM_COMMAND: - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { - case IDC_NOSOUND: - case IDC_NOBLINK: - case IDC_NOCLCBLINK: - if (((LPNMHDR)lParam)->code==NM_CLICK) { - TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); - if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) { - if(hti.flags&TVHT_ONITEMSTATEICON) { - TVITEM tvi; - tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE; - tvi.hItem=hti.hItem; - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); - tvi.iImage=tvi.iSelectedImage=tvi.iImage==1?2:1; - TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - } - } - break; - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: - DBWriteContactSettingByte(NULL,PLUGINNAME_SHORT,"HideMenu",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_HIDEMENU)); - - DBWriteContactSettingDword(NULL,PLUGINNAME_SHORT,"NoSound",MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_NOSOUND))); - DBWriteContactSettingDword(NULL,PLUGINNAME_SHORT,"NoBlink",MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_NOBLINK))); - DBWriteContactSettingDword(NULL,PLUGINNAME_SHORT,"NoCLCBlink",MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_NOCLCBLINK))); - - test = DBGetContactSettingWord(NULL,"CList","Status",0); - SetNotify(Proto_Status2Flag(DBGetContactSettingWord(NULL,"CList","Status",0))); - return TRUE; - } - break; - } - } - return FALSE; -} -//Called when the user opened the options dialog -static int OptionsInitialize(WPARAM wParam,LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInst; - odp.flags = ODPF_TCHAR; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NOSOUND); - odp.ptszTitle = LPGENT("Zero Notifications"); - odp.ptszGroup = LPGENT("Plugins"); - odp.groupPosition = 100000000; - odp.pfnDlgProc = DlgProcNoSoundOpts; - Options_AddPage(wParam, &odp); - - return 0; -} - -static INT_PTR NoSoundMenuCommand(WPARAM wParam,LPARAM lParam) -{ - if (DBGetContactSettingByte(NULL,"Skin","UseSound",1)) - DBWriteContactSettingByte(NULL,"Skin","UseSound",0); -// else -// DBWriteContactSettingByte(NULL,"Skin","UseSound",1); - - return 0; -} - -extern "C" __declspec(dllexport) int Load(void) -{ - - mir_getLP(&pluginInfoEx); - - //The menu item - begin - if (!DBGetContactSettingByte(NULL, PLUGINNAME_SHORT, "HideMenu", 1)) - { - hSoundMenu = CreateServiceFunction(PLUGINNAME_SHORT "/MenuCommand", NoSoundMenuCommand); - ZeroMemory(&mi, sizeof(mi)); - mi.cbSize = sizeof(mi); - mi.position = -0x7FFFFFFF; - mi.flags = CMIF_TCHAR; - UpdateMenuItem(); - - mi.pszService = PLUGINNAME_SHORT "/MenuCommand"; - noSoundMenu = Menu_AddMainMenuItem(&mi); - } - //The menu item - end - - //The hooks - hAckEvent = HookEvent(ME_PROTO_ACK, ProtoAck); - hEventSoundSettingChange = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SoundSettingChanged); - hEventOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OptionsInitialize); - - //Uninstall info - DBWriteContactSettingString(NULL, "Uninstall", PLUGINNAME_SHORT, PLUGINNAME_SHORT); - - return 0; -} - -extern "C" __declspec(dllexport) int Unload(void) -{ - UnhookEvent(hEventSoundSettingChange); - UnhookEvent(hEventOptionsInitialize); - UnhookEvent(hAckEvent); - DestroyServiceFunction(hSoundMenu); - return 0; -} \ No newline at end of file diff --git a/plugins/ZeroNotification/res/ZeroNotifyW.rc b/plugins/ZeroNotification/res/ZeroNotifyW.rc index 5d0ab0dcc7..5488ba0257 100644 --- a/plugins/ZeroNotification/res/ZeroNotifyW.rc +++ b/plugins/ZeroNotification/res/ZeroNotifyW.rc @@ -1,6 +1,6 @@ // Microsoft Visual C++ generated resource script. // -#include "resource.h" +#include "..\src\resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -79,7 +79,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 1 TEXTINCLUDE BEGIN - "resource.\0" + "..\\src\\resource.\0" END 2 TEXTINCLUDE diff --git a/plugins/ZeroNotification/res/resource.h b/plugins/ZeroNotification/res/resource.h deleted file mode 100644 index ac11d8b30b..0000000000 --- a/plugins/ZeroNotification/res/resource.h +++ /dev/null @@ -1,20 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by ZeroNotifyW.rc -// -#define IDD_OPT_NOSOUND 101 -#define IDC_NOSOUND 1000 -#define IDC_NOBLINK 1002 -#define IDC_NOCLCBLINK 1003 -#define IDC_HIDEMENU 1008 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 103 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/ZeroNotification/src/common.h b/plugins/ZeroNotification/src/common.h new file mode 100644 index 0000000000..d0efafec1b --- /dev/null +++ b/plugins/ZeroNotification/src/common.h @@ -0,0 +1,19 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define DEFAULT_NOSOUND 0x00000000 +#define DEFAULT_NOBLINK 0x00000000 +#define DEFAULT_NOCLCBLINK 0x00000000 + +#define DISABLE_SOUND "Disable &Sounds" +#define ENABLE_SOUND "Enable &Sounds" + diff --git a/plugins/ZeroNotification/src/main.cpp b/plugins/ZeroNotification/src/main.cpp new file mode 100644 index 0000000000..2f2221fbf4 --- /dev/null +++ b/plugins/ZeroNotification/src/main.cpp @@ -0,0 +1,281 @@ +/* +A small Miranda plugin, by bidyut, updated by Maat. + +Original plugin idea Anders Nilsson. +His plugin NoSound can be found at: +http://anders.nilsson.net/programs/miranda + +Miranda can be found here: +http://nightly.miranda.im/ +*/ + +#include "version.h" +#include "common.h" +#include "resource.h" + +HINSTANCE hInst; + +static HANDLE hEventSoundSettingChange, hEventStatusModeChange, hEventOptionsInitialize, hAckEvent, hSoundMenu; +CLISTMENUITEM mi; +HGENMENU noSoundMenu; +int hLangpack; + +struct CheckBoxValues_t { + DWORD style; + TCHAR *szDescr; +}; + +static const struct CheckBoxValues_t statusValues[]={ + {PF2_ONLINE, TEXT("Online")}, + {PF2_SHORTAWAY, TEXT("Away")}, + {PF2_LONGAWAY, TEXT("NA")}, + {PF2_LIGHTDND, TEXT("Occupied")}, + {PF2_HEAVYDND, TEXT("DND")}, + {PF2_FREECHAT, TEXT("Free for chat")}, + {PF2_INVISIBLE, TEXT("Invisible")}, + {PF2_OUTTOLUNCH, TEXT("Out to lunch")}, + {PF2_ONTHEPHONE, TEXT("On the phone")} +}; + +PLUGININFOEX pluginInfoEx = { + sizeof(PLUGININFOEX), + PLUGINNAME, + PLUGIN_MAKE_VERSION(VER_MAJOR, VER_MINOR, VER_RELEASE, VER_BUILD), + DESCRIPTION, + AUTHOR, + "", + COPYRIGHT, + "", + UNICODE_AWARE, + UID +}; + +extern "C" __declspec(dllexport) PLUGININFOEX * MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +static void FillCheckBoxTree(HWND hwndTree,const struct CheckBoxValues_t *values,int nValues,DWORD style) +{ + TVINSERTSTRUCT tvis; + int i; + + tvis.hParent=NULL; + tvis.hInsertAfter=TVI_LAST; + tvis.item.mask=TVIF_PARAM|TVIF_TEXT|TVIF_STATE; + for(i=0;i>12==2)) flags|=tvi.lParam; + tvi.hItem=TreeView_GetNextSibling(hwndTree,tvi.hItem); + } + return flags; +} + +//Update the name on the menu +static void UpdateMenuItem() { + if (DBGetContactSettingByte(NULL, "Skin", "UseSound", 1)) + mi.ptszName = TranslateT(DISABLE_SOUND); + else + mi.ptszName = TranslateT(ENABLE_SOUND); +} + +//Called when the sound setting in the database is changed +static int SoundSettingChanged(WPARAM wParam,LPARAM lParam) +{ + DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; + if(lstrcmpA(cws->szModule, "Skin") || lstrcmpA(cws->szSetting, "UseSound")) return 0; + + UpdateMenuItem(); + + mi.flags |= CMIM_NAME; + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)noSoundMenu,(LPARAM)&mi); + + return 0; +} + +static int SetNotify(const long status){ + DBWriteContactSettingByte(NULL,"Skin","UseSound", (BYTE) !(DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoSound",DEFAULT_NOSOUND) & status)); + DBWriteContactSettingByte(NULL,"CList","DisableTrayFlash", (BYTE) (DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoBlink",DEFAULT_NOBLINK) & status)); + DBWriteContactSettingByte(NULL,"CList","NoIconBlink", (BYTE) (DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoCLCBlink",DEFAULT_NOCLCBLINK) & status)); + + UpdateMenuItem(); + + mi.flags |= CMIM_NAME; + CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)noSoundMenu,(LPARAM)&mi); + + return 0; +} + +//Called whenever a change in status is detected +static int ProtoAck(WPARAM wParam, LPARAM lParam) +{ + ACKDATA *ack=(ACKDATA*)lParam; + PROTOCOLDESCRIPTOR **protos; + + //quit if not status event + if ( ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS ) { + long status = 0; + int i, count; + CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM) & count, (LPARAM) & protos); + + for (i = 0; i < count; i++) { + status = status | Proto_Status2Flag(CallProtoService(protos[i]->szName, PS_GETSTATUS, 0, 0)); + } + + SetNotify(status); + + return 0; + } + + return 0; +} + +static INT_PTR CALLBACK DlgProcNoSoundOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + DWORD test; + switch (msg) + { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOSOUND),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOSOUND),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); + SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOBLINK),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOBLINK),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); + SetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOCLCBLINK),GWL_STYLE,GetWindowLongPtr(GetDlgItem(hwndDlg,IDC_NOCLCBLINK),GWL_STYLE)|TVS_NOHSCROLL|TVS_CHECKBOXES); + CheckDlgButton(hwndDlg, IDC_HIDEMENU, DBGetContactSettingByte(NULL,PLUGINNAME_SHORT,"HideMenu",1) ? BST_CHECKED : BST_UNCHECKED); + + FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_NOSOUND),statusValues,sizeof(statusValues)/sizeof(statusValues[0]),DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoSound",DEFAULT_NOSOUND)); + FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_NOBLINK),statusValues,sizeof(statusValues)/sizeof(statusValues[0]),DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoBlink",DEFAULT_NOBLINK)); + FillCheckBoxTree(GetDlgItem(hwndDlg,IDC_NOCLCBLINK),statusValues,sizeof(statusValues)/sizeof(statusValues[0]),DBGetContactSettingDword(NULL,PLUGINNAME_SHORT,"NoCLCBlink",DEFAULT_NOCLCBLINK)); + return TRUE; + case WM_COMMAND: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case IDC_NOSOUND: + case IDC_NOBLINK: + case IDC_NOCLCBLINK: + if (((LPNMHDR)lParam)->code==NM_CLICK) { + TVHITTESTINFO hti; + hti.pt.x=(short)LOWORD(GetMessagePos()); + hti.pt.y=(short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); + if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) { + if(hti.flags&TVHT_ONITEMSTATEICON) { + TVITEM tvi; + tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvi.hItem=hti.hItem; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + tvi.iImage=tvi.iSelectedImage=tvi.iImage==1?2:1; + TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + } + } + break; + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + DBWriteContactSettingByte(NULL,PLUGINNAME_SHORT,"HideMenu",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_HIDEMENU)); + + DBWriteContactSettingDword(NULL,PLUGINNAME_SHORT,"NoSound",MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_NOSOUND))); + DBWriteContactSettingDword(NULL,PLUGINNAME_SHORT,"NoBlink",MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_NOBLINK))); + DBWriteContactSettingDword(NULL,PLUGINNAME_SHORT,"NoCLCBlink",MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg,IDC_NOCLCBLINK))); + + test = DBGetContactSettingWord(NULL,"CList","Status",0); + SetNotify(Proto_Status2Flag(DBGetContactSettingWord(NULL,"CList","Status",0))); + return TRUE; + } + break; + } + } + return FALSE; +} +//Called when the user opened the options dialog +static int OptionsInitialize(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.position = 100000000; + odp.hInstance = hInst; + odp.flags = ODPF_TCHAR; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NOSOUND); + odp.ptszTitle = LPGENT("Zero Notifications"); + odp.ptszGroup = LPGENT("Plugins"); + odp.groupPosition = 100000000; + odp.pfnDlgProc = DlgProcNoSoundOpts; + Options_AddPage(wParam, &odp); + + return 0; +} + +static INT_PTR NoSoundMenuCommand(WPARAM wParam,LPARAM lParam) +{ + if (DBGetContactSettingByte(NULL,"Skin","UseSound",1)) + DBWriteContactSettingByte(NULL,"Skin","UseSound",0); +// else +// DBWriteContactSettingByte(NULL,"Skin","UseSound",1); + + return 0; +} + +extern "C" __declspec(dllexport) int Load(void) +{ + + mir_getLP(&pluginInfoEx); + + //The menu item - begin + if (!DBGetContactSettingByte(NULL, PLUGINNAME_SHORT, "HideMenu", 1)) + { + hSoundMenu = CreateServiceFunction(PLUGINNAME_SHORT "/MenuCommand", NoSoundMenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = -0x7FFFFFFF; + mi.flags = CMIF_TCHAR; + UpdateMenuItem(); + + mi.pszService = PLUGINNAME_SHORT "/MenuCommand"; + noSoundMenu = Menu_AddMainMenuItem(&mi); + } + //The menu item - end + + //The hooks + hAckEvent = HookEvent(ME_PROTO_ACK, ProtoAck); + hEventSoundSettingChange = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SoundSettingChanged); + hEventOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OptionsInitialize); + + //Uninstall info + DBWriteContactSettingString(NULL, "Uninstall", PLUGINNAME_SHORT, PLUGINNAME_SHORT); + + return 0; +} + +extern "C" __declspec(dllexport) int Unload(void) +{ + UnhookEvent(hEventSoundSettingChange); + UnhookEvent(hEventOptionsInitialize); + UnhookEvent(hAckEvent); + DestroyServiceFunction(hSoundMenu); + return 0; +} \ No newline at end of file diff --git a/plugins/ZeroNotification/src/resource.h b/plugins/ZeroNotification/src/resource.h new file mode 100644 index 0000000000..ac11d8b30b --- /dev/null +++ b/plugins/ZeroNotification/src/resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by ZeroNotifyW.rc +// +#define IDD_OPT_NOSOUND 101 +#define IDC_NOSOUND 1000 +#define IDC_NOBLINK 1002 +#define IDC_NOCLCBLINK 1003 +#define IDC_HIDEMENU 1008 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/ZeroNotification/src/version.h b/plugins/ZeroNotification/src/version.h new file mode 100644 index 0000000000..a334eec318 --- /dev/null +++ b/plugins/ZeroNotification/src/version.h @@ -0,0 +1,13 @@ +#define VER_MAJOR 0 +#define VER_MINOR 0 +#define VER_RELEASE 0 +#define VER_BUILD 5 + +#define PLUGINNAME_SHORT "ZeroNotify" +#define PLUGINNAME "Zero Notifications" +#define DESCRIPTION "Adds options to automatically disable notifications when a protocol is in a certain status." +#define AUTHOR "bidyut (<0.0.0.5), Maat" +#define COPYRIGHT "© 2005 bidyut, © 2009 Maat" + +// {47D489D3-310D-4ef6-BD05-699FFFD5A4AA} +#define UID { 0x47d489d3, 0x310d, 0x4ef6, { 0xbd, 0x5, 0x69, 0x9f, 0xff, 0xd5, 0xa4, 0xaa } } diff --git a/plugins/ZeroNotification/version.h b/plugins/ZeroNotification/version.h deleted file mode 100644 index a334eec318..0000000000 --- a/plugins/ZeroNotification/version.h +++ /dev/null @@ -1,13 +0,0 @@ -#define VER_MAJOR 0 -#define VER_MINOR 0 -#define VER_RELEASE 0 -#define VER_BUILD 5 - -#define PLUGINNAME_SHORT "ZeroNotify" -#define PLUGINNAME "Zero Notifications" -#define DESCRIPTION "Adds options to automatically disable notifications when a protocol is in a certain status." -#define AUTHOR "bidyut (<0.0.0.5), Maat" -#define COPYRIGHT "© 2005 bidyut, © 2009 Maat" - -// {47D489D3-310D-4ef6-BD05-699FFFD5A4AA} -#define UID { 0x47d489d3, 0x310d, 0x4ef6, { 0xbd, 0x5, 0x69, 0x9f, 0xff, 0xd5, 0xa4, 0xaa } } diff --git a/plugins/ZeroNotification/zeronotification-translation.txt b/plugins/ZeroNotification/zeronotification-translation.txt deleted file mode 100644 index e62104e8f8..0000000000 --- a/plugins/ZeroNotification/zeronotification-translation.txt +++ /dev/null @@ -1,12 +0,0 @@ -; Common strings that belong to many files -;[] - -; ../../plugins/ZeroNotification/main.cpp -;[Plugins] -;[Zero Notifications] - -; ../../plugins/ZeroNotification/res/ZeroNotifyW.rc -;[Hide the \"toggle sound\" menu item (requires restart of Miranda)] -;[No CLIST blink when:] -;[No SysTray blink when:] -;[No sounds when:] -- cgit v1.2.3