diff options
author | George Hazan <george.hazan@gmail.com> | 2014-02-20 18:43:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-02-20 18:43:33 +0000 |
commit | b26198b243f682cfd66aa5d06acbb62d6d35206c (patch) | |
tree | 0bb4c9efbcb9b3418a82f804ca5825e055f6169e | |
parent | b9567416b251f589ba5ac4ed1dadc644e79d6912 (diff) |
attempt to revive NAS
git-svn-id: http://svn.miranda-ng.org/main/trunk@8194 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/!Deprecated/NewAwaySysMod/AggressiveOptimize.h | 169 | ||||
-rw-r--r-- | plugins/!Deprecated/NewAwaySysMod/NewAwaySys.vcxproj.filters | 187 | ||||
-rw-r--r-- | plugins/BasicHistory/src/EventList.cpp | 4 | ||||
-rw-r--r-- | plugins/ExternalAPI/m_NewAwaySys.h | 119 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/NewAwaySys_10.vcxproj (renamed from plugins/!Deprecated/NewAwaySysMod/NewAwaySys.vcxproj) | 78 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/NewAwaySys_10.vcxproj.filters | 118 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/docs/copying.txt (renamed from plugins/!Deprecated/NewAwaySysMod/copying.txt) | 0 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/docs/nas_readme.txt (renamed from plugins/!Deprecated/NewAwaySysMod/nas_readme.txt) | 0 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/res/Delete.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/Delete.ico) | bin | 2038 -> 2038 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/DisableNotify.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/DisableNotify.ico) | bin | 2038 -> 2038 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/Dot.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/Dot.ico) | bin | 2550 -> 2550 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/EnableNotify.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/EnableNotify.ico) | bin | 2038 -> 2038 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/Ignore.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/Ignore.ico) | bin | 2550 -> 2550 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/Indefinite.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/Indefinite.ico) | bin | 2550 -> 2550 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/MsgIcon.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/MsgIcon.ico) | bin | 1150 -> 1150 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/NewAwaySys.rc (renamed from plugins/!Deprecated/NewAwaySysMod/NewAwaySys.rc) | 34 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/res/NewCat.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/NewCat.ico) | bin | 2550 -> 2550 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/NewMessage.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/NewMessage.ico) | bin | 2550 -> 2550 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/SaveAsNew.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/SaveAsNew.ico) | bin | 2038 -> 2038 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/SaveMsg.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/SaveMsg.ico) | bin | 1150 -> 1150 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/Settings.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/Settings.ico) | bin | 2550 -> 2550 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/Status_Other.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/Status_Other.ico) | bin | 1406 -> 1406 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/Variables.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/Variables.ico) | bin | 2550 -> 2550 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/off.bmp (renamed from plugins/!Deprecated/NewAwaySysMod/Images/off.bmp) | bin | 1336 -> 1336 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/off.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/off.ico) | bin | 1150 -> 1150 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/on.bmp (renamed from plugins/!Deprecated/NewAwaySysMod/Images/on.bmp) | bin | 1016 -> 1016 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/on.ico (renamed from plugins/!Deprecated/NewAwaySysMod/Images/on.ico) | bin | 1150 -> 1150 bytes | |||
-rw-r--r-- | plugins/NewAwaySysMod/res/version.rc (renamed from plugins/!Deprecated/NewAwaySysMod/version.rc) | 0 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/AwayOpt.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/AwayOpt.cpp) | 153 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/AwaySys.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/AwaySys.cpp) | 175 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/CString.cpp | 308 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/CString.h | 237 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Client.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/Client.cpp) | 22 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Common.h (renamed from plugins/!Deprecated/NewAwaySysMod/Common.h) | 64 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/ContactList.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/ContactList.cpp) | 41 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/ContactList.h (renamed from plugins/!Deprecated/NewAwaySysMod/ContactList.h) | 10 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/MsgEventAdded.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/MsgEventAdded.cpp) | 81 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/MsgTree.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/MsgTree.cpp) | 2 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/MsgTree.h (renamed from plugins/!Deprecated/NewAwaySysMod/MsgTree.h) | 0 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Notification.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/Notification.cpp) | 16 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Options.cpp | 963 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Options.h | 483 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Path.h (renamed from plugins/!Deprecated/NewAwaySysMod/Path.h) | 14 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Properties.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/Properties.cpp) | 32 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Properties.h (renamed from plugins/!Deprecated/NewAwaySysMod/Properties.h) | 72 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/ReadAwayMsg.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/ReadAwayMsg.cpp) | 15 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Services.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/Services.cpp) | 20 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Services.h (renamed from plugins/!Deprecated/NewAwaySysMod/Services.h) | 0 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/SetAwayMsg.cpp (renamed from plugins/!Deprecated/NewAwaySysMod/SetAwayMsg.cpp) | 76 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/TMyArray.h | 353 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/resource.h (renamed from plugins/!Deprecated/NewAwaySysMod/resource.h) | 0 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/version.h (renamed from plugins/!Deprecated/NewAwaySysMod/VersionNo.h) | 0 |
52 files changed, 2968 insertions, 878 deletions
diff --git a/plugins/!Deprecated/NewAwaySysMod/AggressiveOptimize.h b/plugins/!Deprecated/NewAwaySysMod/AggressiveOptimize.h deleted file mode 100644 index 65cfa5b010..0000000000 --- a/plugins/!Deprecated/NewAwaySysMod/AggressiveOptimize.h +++ /dev/null @@ -1,169 +0,0 @@ -
-//////////////////////////////
-// Version 1.40
-// October 22nd, 2002 - .NET (VC7, _MSC_VER=1300) support!
-// Version 1.30
-// Nov 24th, 2000
-// Version 1.20
-// Jun 9th, 2000
-// 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 noticeable 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! For larger
-// programs, this is less overall, but can save at least 4k.
-// 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 alignment 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. This is very noticeable 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. Note that this is the same as using /OPT:NOWIN98, which *is*
-// a previously documented switch, but was left out of the docs for some reason in VC6 and
-// all of the current MSDN's - see KB:Q235956 for more information.
-// Microsoft does say that using the 4k alignment will "speed up process loading",
-// but I've been unable to notice a difference, even on my P180, with a very large (4meg) exe.
-// Please note, however, that this will probably not change the size of the COMPRESSED
-// file (either in a .zip file or in an install archive), since this 4k is all zeroes and
-// gets compressed away.
-// Also, the /ALIGN:4096 switch will "magically" do the same thing, even though this is the
-// default setting for this switch. Apparently this sets the same values as the above two
-// switches do. We do not use this in this header, since it smacks of a bug and not a feature.
-// Thanks to Michael Geary <Mike@Geary.com> for some additional tips!
-//
-// Notes about using this header in .NET
-// First off, VC7 does not allow a lot of the linker command options in pragma's. There is no
-// honest or good reason why Microsoft decided to make this change, it just doesn't.
-// So that is why there are a lot of <1300 #if's in the header.
-// If you want to take full advantage of the VC7 linker options, you will need to do it on a
-// PER PROJECT BASIS; you can no longer use a global header file like this to make it better.
-// Items I strongly suggest putting in all your VC7 project linker options command line settings:
-// /ignore:4078 /RELEASE
-// Compiler options:
-// /GL (Whole Program Optimization)
-// If you're making an .EXE and not a .DLL, consider adding in:
-// /GA (Optimize for Windows Application)
-// Some items to consider using in your VC7 projects (not VC6):
-// Link-time Code Generation - whole code optimization. Put this in your exe/dll project link settings.
-// /LTCG:NOSTATUS
-// The classic no-padding and no-bloat compiler C/C++ switch:
-// /opt:nowin98
-//
-// (C++ command line options: /GL /opt:nowin98 and /GA for .exe files)
-// (Link command line options: /ignore:4078 /RELEASE /LTCG:NOSTATUS)
-//
-// Now, notes on using these options in VC7 vs VC6.
-// VC6 consistently, for me, produces smaller code from C++ the exact same sources,
-// with or without this header. On average, VC6 produces 5% smaller binaries compared
-// to VC7 compiling the exact same project, *without* this header. With this header, VC6
-// will make a 13k file, while VC7 will make a 64k one. VC7 is just bloaty, pure and
-// simple - all that managed/unmanaged C++ runtimes, and the CLR stuff must be getting
-// in the way of code generation. However, template support is better, so there.
-// Both VC6 and VC7 show the same end kind of end result savings - larger binary output
-// will shave about 2% off, where as smaller projects (support DLL's, cpl's,
-// activex controls, ATL libs, etc) get the best result, since the padding is usually
-// more than the actual usable code. But again, VC7 does not compile down as small as VC6.
-//
-// The argument can be made that doing this is a waste of time, since the "zero bytes"
-// will be compressed out in a zip file or install archive. Not really - it doesn't matter
-// if the data is a string of zeroes or ones or 85858585 - it will still take room (20 bytes
-// in a zip file, 29 bytes if only *4* of them 4k bytes are not the same) and time to
-// compress that data and decompress it. Also, 20k of zeros is NOT 20k on disk - it's the
-// size of the cluster slop- for Fat32 systems, 20k can be 32k, NTFS could make it 24k if you're
-// just 1 byte over (round up). Most end users do not have the dual P4 Xeon systems with
-// two gigs of RDram and a Raid 0+1 of Western Digital 120meg Special Editions that all
-// worthy developers have (all six of us), so they will need any space and LOADING TIME
-// savings they will need; taking an extra 32k or more out of your end user's 64megs of
-// ram on Windows 98 is Not a Good Thing.
-//
-// Now, as a ADDED BONUS at NO EXTRA COST TO YOU! Under VC6, using the /merge:.text=.data
-// pragma will cause the output file to be un-disassembleable! (is that a word?) At least,
-// with the normal tools - WinDisam, DumpBin, and the like will not work. Try it - use the
-// header, compile release, and then use DUMPBIN /DISASM filename.exe - no code!
-// Thanks to Gëzim Pani <gpani@siu.edu> for discovering this gem - for a full writeup on
-// this issue and the ramifactions of it, visit www.nopcode.com for the Aggressive Optimize
-// article.
-
-#ifndef _AGGRESSIVEOPTIMIZE_H_
-#define _AGGRESSIVEOPTIMIZE_H_
-
-#pragma warning(disable:4711)
-
-#ifdef NDEBUG
-// /Og (global optimizations), /Os (favor small code), /Oy (no frame pointers)
-#pragma optimize("gsy",on)
-
-#if (_MSC_VER<1300)
- #pragma comment(linker,"/RELEASE")
-#endif
-
-// 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.
-/* DEP prevents the plugin from running when section merging is used. Had to disable it. */
-/*
-#ifdef _MERGE_RDATA_
-#pragma comment(linker,"/merge:.rdata=.data")
-#endif // _MERGE_RDATA_
-
-#pragma comment(linker,"/merge:.text=.data")
-#if (_MSC_VER<1300)
- // In VC7, this causes problems with the relocation and data tables, so best to not merge them
- #pragma comment(linker,"/merge:.reloc=.data")
-#endif
-*/
-
-// Merging sections with different attributes causes a linker warning, so
-// turn off the warning. From Michael Geary. Undocumented, as usual!
-#if (_MSC_VER<1300)
- // In VC7, you will need to put this in your project settings
- #pragma comment(linker,"/ignore:4078")
-#endif
-
-// With Visual C++ 5, you already get the 512-byte alignment, so you will only need
-// it for VC6, and maybe later.
-#if _MSC_VER >= 1000
-
-// Option #1: use /filealign
-// 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")
-
-// Option #2: use /opt:nowin98
-// See KB:Q235956 or the READMEVC.htm in your VC directory for info on this one.
-// This is our currently preferred option, since it is fully documented and unlikely
-// to break in service packs and updates.
-#if (_MSC_VER<1300)
- // In VC7, you will need to put this in your project settings
- #pragma comment(linker,"/opt:nowin98")
-#else
-
-// Option #3: use /align:4096
-// A side effect of using the default align value is that it turns on the above switch.
-// Does nothing under Vc7 that /opt:nowin98 doesn't already give you
-// #pragma comment(linker,"/ALIGN:512")
-#endif
-
-#endif // _MSC_VER >= 1000
-
-#endif // NDEBUG
-
-#endif // _AGGRESSIVEOPTIMIZE_H_
diff --git a/plugins/!Deprecated/NewAwaySysMod/NewAwaySys.vcxproj.filters b/plugins/!Deprecated/NewAwaySysMod/NewAwaySys.vcxproj.filters deleted file mode 100644 index bb85b875dd..0000000000 --- a/plugins/!Deprecated/NewAwaySysMod/NewAwaySys.vcxproj.filters +++ /dev/null @@ -1,187 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{116110a1-b9f8-4995-aab2-1de50eab806f}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{7c639270-1dc0-403f-a6ba-7da092e1f885}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{bbdb7c3b-6f74-434a-b577-46de841df2af}</UniqueIdentifier>
- <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- <Filter Include="Documentation">
- <UniqueIdentifier>{b1737ff9-4769-4f5b-b414-ee0f5256de7f}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="AwayOpt.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="AwaySys.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Client.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="ContactList.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MsgEventAdded.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MsgTree.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Notification.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Properties.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="ReadAwayMsg.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="Services.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="SetAwayMsg.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonLibs\CString.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonLibs\GroupCheckbox.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonLibs\Options.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonLibs\ThemedImageCheckbox.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\CommonLibs\Themes.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="AggressiveOptimize.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="Common.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="ContactList.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MsgTree.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="Path.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="Properties.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="Services.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="VersionNo.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonLibs\CString.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonLibs\GroupCheckbox.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonLibs\Options.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonLibs\ThemedImageCheckbox.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonLibs\Themes.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\CommonLibs\TMyArray.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <None Include="Images\Delete.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\DisableNotify.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\Dot.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\EnableNotify.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\Ignore.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\Indefinite.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\MsgIcon.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\NewCat.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\NewMessage.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\off.bmp">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\off.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\on.bmp">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\on.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\SaveAsNew.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\SaveMsg.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\Settings.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\Status_Other.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="Images\Variables.ico">
- <Filter>Resource Files</Filter>
- </None>
- <None Include="copying.txt">
- <Filter>Documentation</Filter>
- </None>
- <None Include="nas_readme.txt">
- <Filter>Documentation</Filter>
- </None>
- <None Include="nas_translation.txt">
- <Filter>Documentation</Filter>
- </None>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="NewAwaySys.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project>
\ No newline at end of file diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index 420d25072a..bb6efe76f7 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -84,8 +84,8 @@ bool EventList::CanShowHistory(DBEVENTINFO* dbei) return true;
default:
- DBEVENTTYPEDESCR* et = ( DBEVENTTYPEDESCR* )CallService(MS_DB_EVENT_GETTYPE, ( WPARAM )dbei->szModule, ( LPARAM )dbei->eventType );
- if ( et && ( et->flags & DETF_HISTORY ))
+ DBEVENTTYPEDESCR *et = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, ( WPARAM )dbei->szModule, ( LPARAM )dbei->eventType);
+ if (et && ( et->flags & DETF_HISTORY))
return true;
}
diff --git a/plugins/ExternalAPI/m_NewAwaySys.h b/plugins/ExternalAPI/m_NewAwaySys.h new file mode 100644 index 0000000000..1a81ec66ff --- /dev/null +++ b/plugins/ExternalAPI/m_NewAwaySys.h @@ -0,0 +1,119 @@ +/*
+ New Away System plugin for Miranda IM
+ Copyright (c) 2005-2007 Chervov Dmitry
+
+ 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_NEWAWAYSYS_H
+#define __M_NEWAWAYSYS_H
+
+// NAS_PROTOINFO::Flags constants
+#define PIF_NO_CLIST_SETSTATUSMODE 1 // NAS won't call MS_CLIST_SETSTATUSMODE service on a global status change, if this flag is set. it's useful if you want to change the global message and status in NAS without changing current "real" protocol statuses. NAS ignores this flag if szProto != NULL
+#define PIF_NOTTEMPORARY 2
+// usually you should NOT set this flag
+// for MS_NAS_SETSTATE: NAS will overwrite current user-defined message for szProto if this flag is specified; otherwise (if the flag isn't specified), your szMsg will be stored only until the next szProto status change, and won't overwrite any messages specified by user
+// for MS_NAS_GETSTATE: NAS ignores any temporary messages and returns only non-temporary ones. this flag affects something only when status == 0
+
+typedef struct {
+ int cbSize;
+ char *szProto; // pointer to protocol modulename (NULL means global)
+ union
+ {
+ char *szMsg;
+ WCHAR *wszMsg;
+ TCHAR *tszMsg;
+ }; // pointer to the status message _format_ (i.e. it's an unparsed message containing variables, in any case. NAS takes care of parsing) (may be NULL - means that there's no specific message for this protocol - then the global status message will be used)
+/*
+ Be aware that MS_NAS_GETSTATE allocates memory for szMsg through Miranda's
+ memory management interface (MS_SYSTEM_GET_MMI). And MS_NAS_SETSTATE
+ expects szMsg to be allocated through the same service. MS_NAS_SETSTATE deallocates szMsg.
+*/
+ WORD status; // status mode. 0 means current (NAS will overwrite 0 with the current status mode)
+// for MS_NAS_GETSTATE if the specified status is not 0, MS_NAS_GETSTATE will return the default/last status message (depends on settings) - i.e. the same message that will be shown by default when user changes status to the specified one. please note that, for example, if current status mode is ID_STATUS_AWAY, then status messages returned by MS_NAS_GETSTATE for status=0 and status=ID_STATUS_AWAY may be different! for status=ID_STATUS_AWAY it always returns the default/last status message, and for status=0 it returns _current_ status message.
+ int Flags;
+} NAS_PROTOINFO;
+
+// MS_NAS_GETSTATE
+// Fills specified array of NAS_PROTOINFO items with protocol data.
+// You must construct the array and specify cbSize and szProto fields of
+// all items in the array before calling this service.
+// Remember to free szMsg fields through Miranda's MMI if you don't pass them back to NAS through MS_NAS_SETSTATE later.
+// wParam = (WPARAM)(NAS_PROTOINFO*)pi - pointer to an array of NAS_PROTOINFO items to be filled.
+// lParam = (LPARAM)(int)protoCount - number of items in pi.
+// returns 0 on success
+#define MS_NAS_GETSTATEA "NewAwaySystem/GetStateA"
+#define MS_NAS_GETSTATEW "NewAwaySystem/GetStateW"
+#ifdef _UNICODE
+ #define MS_NAS_GETSTATE MS_NAS_GETSTATEW
+#else
+ #define MS_NAS_GETSTATE MS_NAS_GETSTATEA
+#endif
+
+// MS_NAS_SETSTATE
+// Changes status mode and message of specified protocols.
+// (Note that this service deallocates szMsg field of the specified items through
+// Miranda's MMI, so the array is not valid anymore after MS_NAS_SETSTATE returns!)
+// wParam = (WPARAM)(NAS_PROTOINFO*)pi - pointer to an array of NAS_PROTOINFO items.
+// lParam = (LPARAM)(int)protoCount - number of items in pi.
+// returns 0 on success
+#define MS_NAS_SETSTATEA "NewAwaySystem/SetStateA"
+#define MS_NAS_SETSTATEW "NewAwaySystem/SetStateW"
+#ifdef _UNICODE
+ #define MS_NAS_SETSTATE MS_NAS_SETSTATEW
+#else
+ #define MS_NAS_SETSTATE MS_NAS_SETSTATEA
+#endif
+
+// NAS_ISWINFO::Flags constants
+#define ISWF_NOCOUNTDOWN 1 // don't start the countdown to close the window
+#define ISWF_UNICODE 2 // specifies that NAS_ISWINFO::szMsg is a WCHAR*
+#ifdef _UNICODE
+ #define ISWF_TCHAR ISWF_UNICODE // will use WCHAR* instead of char*
+#else
+ #define ISWF_TCHAR 0 // will use char*, as usual
+#endif
+
+typedef struct {
+ int cbSize;
+ char *szProto; // pointer to initial protocol modulename (NULL means global); ignored when hContact is not NULL.
+ MCONTACT hContact; // NAS will select this contact in the window initially, if it's not NULL.
+ union
+ {
+ char *szMsg;
+ WCHAR *wszMsg;
+ TCHAR *tszMsg;
+ }; // pointer to an initial status message (may be NULL, NAS will use the default message then)
+ WORD status; // status mode. 0 means current.
+ int Flags; // a combination of ISWF_ constants
+} NAS_ISWINFO;
+
+// MS_NAS_INVOKESTATUSWINDOW
+// Invokes the status message change window.
+// Though if the window is open already, this service just activates an existing window and changes protocol status (i.e. it ignores szMsg and hContact). This behavior may change in future.
+// wParam = (WPARAM)(NAS_ISWINFO*)iswi - pointer to a NAS_ISWINFO structure.
+// lParam = 0
+// returns HWND of the window on success, or NULL on failure.
+#define MS_NAS_INVOKESTATUSWINDOW "NewAwaySystem/InvokeStatusWindow"
+
+/* An example:
+ NAS_ISWINFO iswi = {0}; // for C you may use ZeroMemory() instead
+ iswi.cbSize = sizeof(iswi);
+ iswi.tszMsg = _T("New global status message.");
+ iswi.Flags = ISWF_TCHAR;
+ CallService(MS_NAS_INVOKESTATUSWINDOW, (WPARAM)&iswi, 0);
+*/
+
+#endif // __M_NEWAWAYSYS_H
\ No newline at end of file diff --git a/plugins/!Deprecated/NewAwaySysMod/NewAwaySys.vcxproj b/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj index b6c4b8018f..91290fef63 100644 --- a/plugins/!Deprecated/NewAwaySysMod/NewAwaySys.vcxproj +++ b/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj @@ -20,6 +20,7 @@ </ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6A516E27-AC50-5374-756B-A1558DB2EFA9}</ProjectGuid>
+ <ProjectName>NewAwaySys</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@@ -174,67 +175,44 @@ </ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="AwayOpt.cpp" />
- <ClCompile Include="AwaySys.cpp">
+ <ClCompile Include="src\AwayOpt.cpp" />
+ <ClCompile Include="src\AwaySys.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
- <ClCompile Include="Client.cpp" />
- <ClCompile Include="ContactList.cpp" />
- <ClCompile Include="..\CommonLibs\CString.cpp" />
- <ClCompile Include="..\CommonLibs\GroupCheckbox.cpp" />
- <ClCompile Include="MsgEventAdded.cpp" />
- <ClCompile Include="MsgTree.cpp" />
- <ClCompile Include="Notification.cpp" />
- <ClCompile Include="..\CommonLibs\Options.cpp" />
- <ClCompile Include="Properties.cpp" />
- <ClCompile Include="ReadAwayMsg.cpp" />
- <ClCompile Include="Services.cpp" />
- <ClCompile Include="SetAwayMsg.cpp" />
- <ClCompile Include="..\CommonLibs\ThemedImageCheckbox.cpp" />
- <ClCompile Include="..\CommonLibs\Themes.cpp" />
+ <ClCompile Include="src\Client.cpp" />
+ <ClCompile Include="src\ContactList.cpp" />
+ <ClCompile Include="src\CString.cpp" />
+ <ClCompile Include="src\GroupCheckbox.cpp" />
+ <ClCompile Include="src\MsgEventAdded.cpp" />
+ <ClCompile Include="src\MsgTree.cpp" />
+ <ClCompile Include="src\Notification.cpp" />
+ <ClCompile Include="src\Options.cpp" />
+ <ClCompile Include="src\Properties.cpp" />
+ <ClCompile Include="src\ReadAwayMsg.cpp" />
+ <ClCompile Include="src\Services.cpp" />
+ <ClCompile Include="src\SetAwayMsg.cpp" />
+ <ClCompile Include="src\ThemedImageCheckbox.cpp" />
+ <ClCompile Include="src\Themes.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="AggressiveOptimize.h" />
- <ClInclude Include="Common.h" />
- <ClInclude Include="ContactList.h" />
- <ClInclude Include="..\CommonLibs\CString.h" />
- <ClInclude Include="..\CommonLibs\GroupCheckbox.h" />
- <ClInclude Include="MsgTree.h" />
+ <ClInclude Include="src\Common.h" />
+ <ClInclude Include="src\ContactList.h" />
+ <ClInclude Include="src\CString.h" />
+ <ClInclude Include="src\MsgTree.h" />
<ClInclude Include="..\CommonLibs\Options.h" />
- <ClInclude Include="Path.h" />
- <ClInclude Include="Properties.h" />
- <ClInclude Include="resource.h" />
- <ClInclude Include="Services.h" />
- <ClInclude Include="..\CommonLibs\ThemedImageCheckbox.h" />
- <ClInclude Include="..\CommonLibs\Themes.h" />
- <ClInclude Include="..\CommonLibs\TMyArray.h" />
- <ClInclude Include="VersionNo.h" />
+ <ClInclude Include="src\Options.h" />
+ <ClInclude Include="src\Path.h" />
+ <ClInclude Include="src\Properties.h" />
+ <ClInclude Include="src\resource.h" />
+ <ClInclude Include="src\Services.h" />
+ <ClInclude Include="src\version.h" />
</ItemGroup>
<ItemGroup>
- <None Include="Images\Delete.ico" />
- <None Include="Images\DisableNotify.ico" />
- <None Include="Images\Dot.ico" />
- <None Include="Images\EnableNotify.ico" />
- <None Include="Images\Ignore.ico" />
- <None Include="Images\Indefinite.ico" />
- <None Include="Images\MsgIcon.ico" />
- <None Include="Images\NewCat.ico" />
- <None Include="Images\NewMessage.ico" />
- <None Include="Images\off.bmp" />
- <None Include="Images\off.ico" />
- <None Include="Images\on.bmp" />
- <None Include="Images\on.ico" />
- <None Include="Images\SaveAsNew.ico" />
- <None Include="Images\SaveMsg.ico" />
- <None Include="Images\Settings.ico" />
- <None Include="Images\Status_Other.ico" />
- <None Include="Images\Variables.ico" />
<None Include="copying.txt" />
<None Include="nas_readme.txt" />
- <None Include="nas_translation.txt" />
</ItemGroup>
<ItemGroup>
- <ResourceCompile Include="NewAwaySys.rc" />
+ <ResourceCompile Include="res\NewAwaySys.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj.filters b/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj.filters new file mode 100644 index 0000000000..7fb56a8f67 --- /dev/null +++ b/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj.filters @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{116110a1-b9f8-4995-aab2-1de50eab806f}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{7c639270-1dc0-403f-a6ba-7da092e1f885}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{bbdb7c3b-6f74-434a-b577-46de841df2af}</UniqueIdentifier>
+ <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
+ </Filter>
+ <Filter Include="Documentation">
+ <UniqueIdentifier>{b1737ff9-4769-4f5b-b414-ee0f5256de7f}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\AwayOpt.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\AwaySys.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Client.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\ContactList.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\MsgEventAdded.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\MsgTree.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Notification.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Properties.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\ReadAwayMsg.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Services.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\SetAwayMsg.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\CString.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Options.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\ThemedImageCheckbox.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Themes.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\GroupCheckbox.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\CommonLibs\Options.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\ContactList.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\MsgTree.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Path.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Properties.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Services.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\CString.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Options.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="copying.txt">
+ <Filter>Documentation</Filter>
+ </None>
+ <None Include="nas_readme.txt">
+ <Filter>Documentation</Filter>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\NewAwaySys.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/!Deprecated/NewAwaySysMod/copying.txt b/plugins/NewAwaySysMod/docs/copying.txt index 45645b4b53..45645b4b53 100644 --- a/plugins/!Deprecated/NewAwaySysMod/copying.txt +++ b/plugins/NewAwaySysMod/docs/copying.txt diff --git a/plugins/!Deprecated/NewAwaySysMod/nas_readme.txt b/plugins/NewAwaySysMod/docs/nas_readme.txt index 83395abf60..83395abf60 100644 --- a/plugins/!Deprecated/NewAwaySysMod/nas_readme.txt +++ b/plugins/NewAwaySysMod/docs/nas_readme.txt diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/Delete.ico b/plugins/NewAwaySysMod/res/Delete.ico Binary files differindex b44da83dbc..b44da83dbc 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/Delete.ico +++ b/plugins/NewAwaySysMod/res/Delete.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/DisableNotify.ico b/plugins/NewAwaySysMod/res/DisableNotify.ico Binary files differindex 5df846b34e..5df846b34e 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/DisableNotify.ico +++ b/plugins/NewAwaySysMod/res/DisableNotify.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/Dot.ico b/plugins/NewAwaySysMod/res/Dot.ico Binary files differindex 12ffcb1997..12ffcb1997 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/Dot.ico +++ b/plugins/NewAwaySysMod/res/Dot.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/EnableNotify.ico b/plugins/NewAwaySysMod/res/EnableNotify.ico Binary files differindex da4e6af1c0..da4e6af1c0 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/EnableNotify.ico +++ b/plugins/NewAwaySysMod/res/EnableNotify.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/Ignore.ico b/plugins/NewAwaySysMod/res/Ignore.ico Binary files differindex 1ba34d7244..1ba34d7244 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/Ignore.ico +++ b/plugins/NewAwaySysMod/res/Ignore.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/Indefinite.ico b/plugins/NewAwaySysMod/res/Indefinite.ico Binary files differindex fb895622ff..fb895622ff 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/Indefinite.ico +++ b/plugins/NewAwaySysMod/res/Indefinite.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/MsgIcon.ico b/plugins/NewAwaySysMod/res/MsgIcon.ico Binary files differindex 7880f71a70..7880f71a70 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/MsgIcon.ico +++ b/plugins/NewAwaySysMod/res/MsgIcon.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/NewAwaySys.rc b/plugins/NewAwaySysMod/res/NewAwaySys.rc index 7a0bfba8ee..7e5bb36546 100644 --- a/plugins/!Deprecated/NewAwaySysMod/NewAwaySys.rc +++ b/plugins/NewAwaySysMod/res/NewAwaySys.rc @@ -1,6 +1,6 @@ //Microsoft Developer Studio generated resource script.
//
-#include "resource.h"
+#include "..\src\resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
@@ -600,20 +600,20 @@ END // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
-IDI_MSGICON ICON DISCARDABLE "Images\\MsgIcon.ico"
-IDI_SOE_ENABLED ICON DISCARDABLE "Images\\on.ico"
-IDI_SOE_DISABLED ICON DISCARDABLE "Images\\off.ico"
-IDI_DOT ICON DISCARDABLE "Images\\Dot.ico"
-IDI_IGNORE ICON DISCARDABLE "Images\\Ignore.ico"
-IDI_SAVE ICON DISCARDABLE "Images\\SaveMsg.ico"
-IDI_SAVEASNEW ICON DISCARDABLE "Images\\SaveAsNew.ico"
-IDI_DELETE ICON DISCARDABLE "Images\\Delete.ico"
-IDI_NEWCATEGORY ICON DISCARDABLE "Images\\NewCat.ico"
-IDI_VARIABLES ICON DISCARDABLE "Images\\Variables.ico"
-IDI_NEWMESSAGE ICON DISCARDABLE "Images\\NewMessage.ico"
-IDI_SETTINGS ICON DISCARDABLE "Images\\Settings.ico"
-IDI_STATUS_OTHER ICON DISCARDABLE "Images\\Status_Other.ico"
-IDI_INDEFINITE ICON DISCARDABLE "Images\\Indefinite.ico"
+IDI_MSGICON ICON DISCARDABLE "res\\MsgIcon.ico"
+IDI_SOE_ENABLED ICON DISCARDABLE "res\\on.ico"
+IDI_SOE_DISABLED ICON DISCARDABLE "res\\off.ico"
+IDI_DOT ICON DISCARDABLE "res\\Dot.ico"
+IDI_IGNORE ICON DISCARDABLE "res\\Ignore.ico"
+IDI_SAVE ICON DISCARDABLE "res\\SaveMsg.ico"
+IDI_SAVEASNEW ICON DISCARDABLE "res\\SaveAsNew.ico"
+IDI_DELETE ICON DISCARDABLE "res\\Delete.ico"
+IDI_NEWCATEGORY ICON DISCARDABLE "res\\NewCat.ico"
+IDI_VARIABLES ICON DISCARDABLE "res\\Variables.ico"
+IDI_NEWMESSAGE ICON DISCARDABLE "res\\NewMessage.ico"
+IDI_SETTINGS ICON DISCARDABLE "res\\Settings.ico"
+IDI_STATUS_OTHER ICON DISCARDABLE "res\\Status_Other.ico"
+IDI_INDEFINITE ICON DISCARDABLE "res\\Indefinite.ico"
/////////////////////////////////////////////////////////////////////////////
//
@@ -682,8 +682,8 @@ END // Bitmap
//
-IDB_SOE_ENABLED BITMAP MOVEABLE PURE "Images\\on.bmp"
-IDB_SOE_DISABLED BITMAP MOVEABLE PURE "Images\\off.bmp"
+IDB_SOE_ENABLED BITMAP MOVEABLE PURE "res\\on.bmp"
+IDB_SOE_DISABLED BITMAP MOVEABLE PURE "res\\off.bmp"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/NewCat.ico b/plugins/NewAwaySysMod/res/NewCat.ico Binary files differindex c6d213b289..c6d213b289 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/NewCat.ico +++ b/plugins/NewAwaySysMod/res/NewCat.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/NewMessage.ico b/plugins/NewAwaySysMod/res/NewMessage.ico Binary files differindex 1ba04c8d6a..1ba04c8d6a 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/NewMessage.ico +++ b/plugins/NewAwaySysMod/res/NewMessage.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/SaveAsNew.ico b/plugins/NewAwaySysMod/res/SaveAsNew.ico Binary files differindex 6954faa978..6954faa978 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/SaveAsNew.ico +++ b/plugins/NewAwaySysMod/res/SaveAsNew.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/SaveMsg.ico b/plugins/NewAwaySysMod/res/SaveMsg.ico Binary files differindex e972db2923..e972db2923 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/SaveMsg.ico +++ b/plugins/NewAwaySysMod/res/SaveMsg.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/Settings.ico b/plugins/NewAwaySysMod/res/Settings.ico Binary files differindex ddb72fb8ca..ddb72fb8ca 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/Settings.ico +++ b/plugins/NewAwaySysMod/res/Settings.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/Status_Other.ico b/plugins/NewAwaySysMod/res/Status_Other.ico Binary files differindex 922d911bbb..922d911bbb 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/Status_Other.ico +++ b/plugins/NewAwaySysMod/res/Status_Other.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/Variables.ico b/plugins/NewAwaySysMod/res/Variables.ico Binary files differindex 7fd7196664..7fd7196664 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/Variables.ico +++ b/plugins/NewAwaySysMod/res/Variables.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/off.bmp b/plugins/NewAwaySysMod/res/off.bmp Binary files differindex fcc9507634..fcc9507634 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/off.bmp +++ b/plugins/NewAwaySysMod/res/off.bmp diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/off.ico b/plugins/NewAwaySysMod/res/off.ico Binary files differindex 0facbfa29f..0facbfa29f 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/off.ico +++ b/plugins/NewAwaySysMod/res/off.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/on.bmp b/plugins/NewAwaySysMod/res/on.bmp Binary files differindex cf7343ef31..cf7343ef31 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/on.bmp +++ b/plugins/NewAwaySysMod/res/on.bmp diff --git a/plugins/!Deprecated/NewAwaySysMod/Images/on.ico b/plugins/NewAwaySysMod/res/on.ico Binary files differindex f236715870..f236715870 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Images/on.ico +++ b/plugins/NewAwaySysMod/res/on.ico diff --git a/plugins/!Deprecated/NewAwaySysMod/version.rc b/plugins/NewAwaySysMod/res/version.rc index 408fa5fa8b..408fa5fa8b 100644 --- a/plugins/!Deprecated/NewAwaySysMod/version.rc +++ b/plugins/NewAwaySysMod/res/version.rc diff --git a/plugins/!Deprecated/NewAwaySysMod/AwayOpt.cpp b/plugins/NewAwaySysMod/src/AwayOpt.cpp index d40fb85b18..7ba87f43ab 100644 --- a/plugins/!Deprecated/NewAwaySysMod/AwayOpt.cpp +++ b/plugins/NewAwaySysMod/src/AwayOpt.cpp @@ -23,9 +23,8 @@ #include "Path.h"
#include "m_button.h"
#include "m_clc.h"
-#include "..\CommonLibs\Themes.h"
-#include "..\CommonLibs\GroupCheckbox.h"
-#include "..\CommonLibs\ThemedImageCheckbox.h"
+#include "GroupCheckbox.h"
+#include "ThemedImageCheckbox.h"
//NightFox
#include <m_modernopt.h>
@@ -1020,8 +1019,7 @@ INT_PTR CALLBACK MessagesModernOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ood.cbSize = sizeof(ood);
ood.pszPage = "Status";
ood.pszTab = "Autoreply";
- //CallService( MS_OPT_OPENOPTIONS, 0, (LPARAM)&ood );
- CallService( MS_OPT_OPENOPTIONSPAGE, 0, (LPARAM)&ood );
+ Options_OpenPage(&ood);
break;
}
@@ -1279,7 +1277,7 @@ static void SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE hItemAll, int }
}
-static void SaveItemState(HWND hwndList, HANDLE hContact, HANDLE hItem)
+static void SaveItemState(HWND hwndList, MCONTACT hContact, HANDLE hItem)
{ // hContact == INVALID_HANDLE_VALUE means that hItem is hItemUnknown
int Ignore = IgnoreIconToDBValue(SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNORECOLUMN, 0)));
int Reply = ReplyIconToDBValue(SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(AUTOREPLYCOLUMN, 0)));
@@ -1296,7 +1294,7 @@ static void SaveItemState(HWND hwndList, HANDLE hContact, HANDLE hItem) {
CContactSettings(ID_STATUS_ONLINE, hContact).PopupNotify = Notify;
}*/
- if (hContact != INVALID_HANDLE_VALUE && g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS))
+ if (hContact != INVALID_CONTACT_ID && g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS))
{
int iMode;
for (iMode = ID_STATUS_AWAY; iMode < ID_STATUS_OUTTOLUNCH; iMode++)
@@ -1315,43 +1313,32 @@ static void SaveItemState(HWND hwndList, HANDLE hContact, HANDLE hItem) static void SetAllContactIcons(HWND hwndList, HANDLE hItemUnknown)
{
- HANDLE hContact, hItem;
- char *szProto;
-// set values for hItemUnknown first
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItemUnknown, MAKELPARAM(IGNORECOLUMN, DBValueToIgnoreIcon(CContactSettings(ID_STATUS_ONLINE, INVALID_HANDLE_VALUE).Ignore)));
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItemUnknown, MAKELPARAM(AUTOREPLYCOLUMN, DBValueToOptReplyIcon(CContactSettings(ID_STATUS_ONLINE, INVALID_HANDLE_VALUE).Autoreply)));
-// SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItemUnknown, MAKELPARAM(NOTIFYCOLUMN, DBValueToNotifyIcon(CContactSettings(ID_STATUS_ONLINE, INVALID_HANDLE_VALUE).PopupNotify)));
-
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- do
- {
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem)// && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNOREEVENT_MAX, 0)) == 0xFF)
- {
- szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItemUnknown, MAKELPARAM(IGNORECOLUMN, DBValueToIgnoreIcon(CContactSettings(ID_STATUS_ONLINE, INVALID_CONTACT_ID).Ignore)));
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItemUnknown, MAKELPARAM(AUTOREPLYCOLUMN, DBValueToOptReplyIcon(CContactSettings(ID_STATUS_ONLINE, INVALID_CONTACT_ID).Autoreply)));
+
+ MCONTACT hContact = db_find_first();
+ do {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem) {
+ char *szProto = GetContactProto(hContact);
int Ignore = CContactSettings(ID_STATUS_ONLINE, hContact).Ignore;
int Reply = CContactSettings(ID_STATUS_ONLINE, hContact).Autoreply;
// int Notify = CContactSettings(ID_STATUS_ONLINE, hContact).PopupNotify;
- if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS))
- {
+ if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS)) {
int iMode;
- for (iMode = ID_STATUS_AWAY; iMode < ID_STATUS_OUTTOLUNCH; iMode++)
- {
+ for (iMode = ID_STATUS_AWAY; iMode < ID_STATUS_OUTTOLUNCH; iMode++) {
if (CContactSettings(iMode, hContact).Ignore != Ignore)
- {
Ignore = VAL_INDEFINITE;
- }
+
if (CContactSettings(iMode, hContact).Autoreply != Reply)
- {
Reply = VAL_INDEFINITE;
- } // Notify is not per-status, so we're not checking it here
}
}
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNORECOLUMN, DBValueToIgnoreIcon(Ignore)));
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(AUTOREPLYCOLUMN, DBValueToOptReplyIcon(Reply)));
-// SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(NOTIFYCOLUMN, (szProto && IsAnICQProto(szProto)) ? DBValueToNotifyIcon(Notify) : 0xFF));
}
- } while (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0));
+ }
+ while (hContact = db_find_next(hContact));
}
static LRESULT CALLBACK ContactsSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
@@ -1376,19 +1363,16 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP static HANDLE hItemAll, hItemUnknown;
switch (msg)
{
- case WM_INITDIALOG:
+ case WM_INITDIALOG:
{
TranslateDialogDefault(hwndDlg);
MySetPos(hwndDlg);
HWND hwndList = GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST);
- HIMAGELIST hIml;
- hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR8) | ILC_MASK, 5, 2);
+ HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 5, 2);
ImageList_AddIcon(hIml, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DOT)));
ImageList_AddIcon(hIml, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_IGNORE)));
ImageList_AddIcon(hIml, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SOE_ENABLED)));
ImageList_AddIcon(hIml, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SOE_DISABLED)));
- //ImageList_AddIcon(hIml, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ENABLENOTIFY)));
- //ImageList_AddIcon(hIml, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DISABLENOTIFY)));
ImageList_AddIcon(hIml, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_INDEFINITE)));
SendMessage(hwndList, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
SendMessage(hwndDlg, UM_CONTACTSDLG_RESETLISTOPTIONS, 0, 0);
@@ -1400,10 +1384,10 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP hItemAll = (HANDLE)SendMessage(hwndList, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
cii.pszText = TranslateT("** Not-on-list contacts **"); // == Unknown contacts
hItemUnknown = (HANDLE)SendMessage(hwndList, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ MCONTACT hContact = db_find_first();
do
{
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ char *szProto = GetContactProto(hContact);
if (szProto)
{
int Flag1 = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
@@ -1412,12 +1396,13 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendMessage(hwndList, CLM_DELETEITEM, SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
}
}
- } while (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0));
+ }
+ while (hContact = db_find_next(hContact));
SetAllContactIcons(hwndList, hItemUnknown);
SetListGroupIcons(hwndList, (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll);
g_OrigContactsProc = (WNDPROC)SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)ContactsSubclassProc);
} break;
- case UM_CONTACTSDLG_RESETLISTOPTIONS:
+ case UM_CONTACTSDLG_RESETLISTOPTIONS:
{
HWND hwndList = GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST);
SendMessage(hwndList, CLM_SETBKBITMAP, 0, NULL);
@@ -1432,33 +1417,33 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendMessage(hwndList, CLM_SETTEXTCOLOR, I, GetSysColor(COLOR_WINDOWTEXT));
}
} break;
- case WM_SETFOCUS:
+ case WM_SETFOCUS:
{
SetFocus(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST));
} break;
- case WM_NOTIFY:
+ case WM_NOTIFY:
{
switch (((LPNMHDR)lParam)->idFrom)
{
- case IDC_CONTACTSDLG_LIST:
+ case IDC_CONTACTSDLG_LIST:
{
switch (((LPNMHDR)lParam)->code)
{
- case CLN_NEWCONTACT:
- case CLN_LISTREBUILT:
+ case CLN_NEWCONTACT:
+ case CLN_LISTREBUILT:
{
SetAllContactIcons(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), hItemUnknown);
} // fall through
- case CLN_CONTACTMOVED:
+ case CLN_CONTACTMOVED:
{
SetListGroupIcons(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll);
} break;
- case CLN_OPTIONSCHANGED:
+ case CLN_OPTIONSCHANGED:
{
SendMessage(hwndDlg, UM_CONTACTSDLG_RESETLISTOPTIONS, 0, 0);
} break;
- case NM_CLICK:
- case NM_DBLCLK:
+ case NM_CLICK:
+ case NM_DBLCLK:
{
NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
HWND hwndList = GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST);
@@ -1476,27 +1461,27 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP int iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0));
switch (nm->iColumn)
{
- case AUTOREPLYCOLUMN:
+ case AUTOREPLYCOLUMN:
{
switch (iImage)
{
- case EXTRAICON_DOT: iImage = EXTRAICON_AUTOREPLYOFF; break;
- case EXTRAICON_AUTOREPLYOFF: iImage = EXTRAICON_AUTOREPLYON; break;
- default: iImage = EXTRAICON_DOT; // EXTRAICON_AUTOREPLYON and EXTRAICON_INDEFINITE
+ case EXTRAICON_DOT: iImage = EXTRAICON_AUTOREPLYOFF; break;
+ case EXTRAICON_AUTOREPLYOFF: iImage = EXTRAICON_AUTOREPLYON; break;
+ default: iImage = EXTRAICON_DOT; // EXTRAICON_AUTOREPLYON and EXTRAICON_INDEFINITE
}
} break;
- case IGNORECOLUMN:
+ case IGNORECOLUMN:
{
iImage = (iImage == EXTRAICON_DOT) ? EXTRAICON_IGNORE : EXTRAICON_DOT;
} break;
/*case NOTIFYCOLUMN:
{
- switch (iImage)
- {
- case EXTRAICON_DOT: iImage = EXTRAICON_DISABLENOTIFY; break;
- case EXTRAICON_DISABLENOTIFY: iImage = EXTRAICON_ENABLENOTIFY; break;
- default: iImage = EXTRAICON_DOT; // EXTRAICON_ENABLENOTIFY and EXTRAICON_INDEFINITE
- }
+ switch (iImage)
+ {
+ case EXTRAICON_DOT: iImage = EXTRAICON_DISABLENOTIFY; break;
+ case EXTRAICON_DISABLENOTIFY: iImage = EXTRAICON_ENABLENOTIFY; break;
+ default: iImage = EXTRAICON_DOT; // EXTRAICON_ENABLENOTIFY and EXTRAICON_INDEFINITE
+ }
}*/ break;
}
SetIconsForColumn(hwndList, hItem, hItemAll, nm->iColumn, iImage);
@@ -1504,37 +1489,28 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
} break;
}
- } break;
- case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- HANDLE hContact, hItem;
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- do
- {
- hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem)
- {
- SaveItemState(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), hContact, hItem);
- }
- } while (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0));
-// SaveItemMask(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), NULL, hItemAll, "Default1"); // TODO: store All Contacts setting here too, - change global Notify and Autoreply settings? (& set the All Contacts icons to "?" initially if the global setting doesn't coincide with the setting calculated in the _current_ way); and also make sure that these settings will be refreshed in the other windows too
- SaveItemState(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), INVALID_HANDLE_VALUE, hItemUnknown);
- return true;
- } break;
+ }
+ break;
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem)
+ SaveItemState(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), hContact, hItem);
}
- } break;
+
+ SaveItemState(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), INVALID_CONTACT_ID, hItemUnknown);
+ return true;
+ }
+ break;
}
} break;
- case WM_DESTROY:
- {
- HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
- _ASSERT(hIml);
- ImageList_Destroy(hIml);
- } break;
+ case WM_DESTROY:
+ HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
+ _ASSERT(hIml);
+ ImageList_Destroy(hIml);
+ break;
}
return 0;
}
@@ -1577,7 +1553,6 @@ COptPage g_MsgTreePage(MOD_NAME, NULL); void InitOptions()
{
- InitThemes();
g_MessagesOptPage.Items.AddElem(new COptItem_Generic(IDC_MESSAGEDLG_VARS, IDC_MESSAGEDLG_MSGTREE));
g_MessagesOptPage.Items.AddElem(new COptItem_Generic(IDC_MESSAGEDLG_DEL));
g_MessagesOptPage.Items.AddElem(new COptItem_Generic(IDC_MESSAGEDLG_MSGTITLE));
diff --git a/plugins/!Deprecated/NewAwaySysMod/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index 9e8b0dd5b1..1032780f79 100644 --- a/plugins/!Deprecated/NewAwaySysMod/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -40,7 +40,7 @@ #include "Properties.h"
#include "Path.h"
#include "Services.h"
-#include "VersionNo.h"
+#include "version.h"
//NightFox
#include <m_modernopt.h>
@@ -109,18 +109,16 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD miranda //NightFox
int ModernOptInitialise(WPARAM wParam,LPARAM lParam);
-TCString GetDynamicStatMsg(HANDLE hContact, char *szProto, DWORD UIN, int iStatus)
+TCString GetDynamicStatMsg(MCONTACT hContact, char *szProto, DWORD UIN, int iStatus)
{
// hContact is the contact that requests the status message
- if (hContact != INVALID_HANDLE_VALUE)
- {
+ if (hContact != INVALID_CONTACT_ID)
VarParseData.Message = CContactSettings(iStatus, hContact).GetMsgFormat(GMF_ANYCURRENT, NULL, szProto);
- } else
- { // contact is unknown
+ else // contact is unknown
VarParseData.Message = CProtoSettings(szProto, iStatus).GetMsgFormat(iStatus ? GMF_LASTORDEFAULT : GMF_ANYCURRENT);
- }
+
TCString sTime;
- VarParseData.szProto = szProto ? szProto : ((hContact && hContact != INVALID_HANDLE_VALUE) ? (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0) : NULL);
+ VarParseData.szProto = szProto ? szProto : ((hContact && hContact != INVALID_CONTACT_ID) ? (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0) : NULL);
VarParseData.UIN = UIN;
VarParseData.Flags = 0;
if (ServiceExists(MS_VARS_FORMATSTRING) && !g_SetAwayMsgPage.GetDBValueCopy(IDS_SAWAYMSG_DISABLEVARIABLES))
@@ -147,37 +145,29 @@ int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto) LogMessage("ME_ICQ_STATUSMSGREQ called. szProto=%s, Status=%d, UIN=%d", (char*)szProto, wParam, lParam);
// find the contact
char *szFoundProto;
- HANDLE hFoundContact = NULL; // if we'll find the contact only on some other protocol, but not on szProto, then we'll use that hContact.
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- while (hContact)
- {
+ MCONTACT hFoundContact = NULL; // if we'll find the contact only on some other protocol, but not on szProto, then we'll use that hContact.
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szCurProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- if (DBGetContactSettingDword(hContact, szCurProto, "UIN", 0) == lParam)
- {
+ if (db_get_dw(hContact, szCurProto, "UIN", 0) == lParam) {
szFoundProto = szCurProto;
hFoundContact = hContact;
if (!strcmp(szCurProto, szProto))
- {
break;
- }
}
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
}
+
int iMode = ICQStatusToGeneralStatus(wParam);
if (!hFoundContact)
- {
- hFoundContact = INVALID_HANDLE_VALUE;
- } else if (iMode >= ID_STATUS_ONLINE && iMode <= ID_STATUS_OUTTOLUNCH)
- { // don't count xstatus requests
- DBWriteContactSettingWord(hFoundContact, MOD_NAME, DB_REQUESTCOUNT, DBGetContactSettingWord(hFoundContact, MOD_NAME, DB_REQUESTCOUNT, 0) + 1);
- }
- HANDLE hContactForSettings = hFoundContact; // used to take into account not-on-list contacts when getting contact settings, but at the same time allows to get correct contact info for contacts that are in the DB
- if (hContactForSettings != INVALID_HANDLE_VALUE && DBGetContactSettingByte(hContactForSettings, "CList", "NotOnList", 0))
- {
- hContactForSettings = INVALID_HANDLE_VALUE; // INVALID_HANDLE_VALUE means the contact is not-on-list
- }
- if (g_SetAwayMsgPage.GetWnd())
- {
+ hFoundContact = INVALID_CONTACT_ID;
+ else if (iMode >= ID_STATUS_ONLINE && iMode <= ID_STATUS_OUTTOLUNCH)
+ // don't count xstatus requests
+ db_set_w(hFoundContact, MOD_NAME, DB_REQUESTCOUNT, db_get_w(hFoundContact, MOD_NAME, DB_REQUESTCOUNT, 0) + 1);
+
+ MCONTACT hContactForSettings = hFoundContact; // used to take into account not-on-list contacts when getting contact settings, but at the same time allows to get correct contact info for contacts that are in the DB
+ if (hContactForSettings != INVALID_CONTACT_ID && db_get_b(hContactForSettings, "CList", "NotOnList", 0))
+ hContactForSettings = INVALID_CONTACT_ID; // INVALID_HANDLE_VALUE means the contact is not-on-list
+
+ if (g_SetAwayMsgPage.GetWnd()) {
CallAllowedPS_SETAWAYMSG(szProto, iMode, NULL); // we can set status messages to NULL here, as they'll be changed again when the SAM dialog closes.
return 0;
}
@@ -189,7 +179,7 @@ int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto) if (iMode)
{ // if it's not an xstatus message request
- CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)TCHAR2ANSI(GetDynamicStatMsg(hFoundContact, szProto, lParam)));
+ CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)_T2A(GetDynamicStatMsg(hFoundContact, szProto, lParam)));
}
// COptPage PopupNotifyData(g_PopupOptPage);
// PopupNotifyData.DBToMem();
@@ -222,8 +212,8 @@ int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto) TCString LogMsg;
if (!iMode)
{ // if it's an xstatus message request
- LogMsg = DBGetContactSettingString(NULL, szProto, "XStatusName", _T(""));
- TCString XMsg(DBGetContactSettingString(NULL, szProto, "XStatusMsg", _T("")));
+ LogMsg = db_get_s(NULL, szProto, "XStatusName", _T(""));
+ TCString XMsg(db_get_s(NULL, szProto, "XStatusMsg", _T("")));
if (XMsg.GetLen())
{
if (LogMsg.GetLen())
@@ -285,30 +275,24 @@ int StatusChanged(WPARAM wParam, LPARAM lParam) LogMessage("MS_CLIST_SETSTATUSMODE called. szProto=%s, Status=%d", lParam ? (char*)lParam : "NULL", wParam);
g_ProtoStates[(char*)lParam].Status = wParam;
// let's check if we handle this thingy
- if (g_fNoProcessing) // we're told not to do anything
- {
+ if (g_fNoProcessing) { // we're told not to do anything
g_fNoProcessing = false; // take it off
return 0;
}
DWORD Flag1 = 0;
DWORD Flag3 = 0;
- if (lParam)
- {
+ if (lParam) {
Flag1 = CallProtoService((char*)lParam, PS_GETCAPS, PFLAGNUM_1, 0);
Flag3 = CallProtoService((char*)lParam, PS_GETCAPS, PFLAGNUM_3, 0);
- } else
- {
- PROTOCOLDESCRIPTOR **proto;
+ }
+ else {
+ PROTOACCOUNT **proto;
int iProtoCount = 0;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&iProtoCount, (LPARAM)&proto);
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&iProtoCount, (LPARAM)&proto);
int i;
- for (i = 0; i < iProtoCount; i++)
- {
- if (proto[i]->type == PROTOTYPE_PROTOCOL)
- {
- Flag1 |= CallProtoService(proto[i]->szName, PS_GETCAPS, PFLAGNUM_1, 0);
- Flag3 |= CallProtoService(proto[i]->szName, PS_GETCAPS, PFLAGNUM_3, 0);
- }
+ for (i = 0; i < iProtoCount; i++) {
+ Flag1 |= CallProtoService(proto[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ Flag3 |= CallProtoService(proto[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
}
}
if (!(Flag1 & PF1_MODEMSGSEND || Flag3 & Proto_Status2Flag(wParam) || (Flag1 & PF1_IM) == PF1_IM))
@@ -365,14 +349,14 @@ int CSStatusChange(WPARAM wParam, LPARAM lParam) // CommonStatus plugins (Startu int i;
for (i = 0; i < g_CSProtoCount; i++)
{
- LogMessage("%d: cbSize=%d, szProto=%s, status=%d, lastStatus=%d, szMsg:", i + 1, ps[i]->cbSize, ps[i]->szName ? (char*)ps[i]->szName : "NULL", ps[i]->status, ps[i]->lastStatus, ps[i]->szMsg ? ps[i]->szMsg : "NULL");
+ LogMessage("%d: cbSize=%d, szProto=%s, status=%d, lastStatus=%d, szMsg:", i + 1, ps[i]->cbSize, ps[i]->szName ? (char*)ps[i]->szName : "NULL", ps[i]->status, ps[i]->lastStatus, ps[i]->szMsg ? ps[i]->szMsg : _T("NULL"));
if (ps[i]->status != ID_STATUS_DISABLED)
{
if (ps[i]->status != ID_STATUS_CURRENT)
{
g_ProtoStates[ps[i]->szName].Status = (ps[i]->status == ID_STATUS_LAST) ? ps[i]->lastStatus : ps[i]->status;
}
- CProtoSettings(ps[i]->szName).SetMsgFormat(SMF_TEMPORARY, ps[i]->szMsg ? ANSI2TCHAR(ps[i]->szMsg) : CProtoSettings(ps[i]->szName).GetMsgFormat(GMF_LASTORDEFAULT));
+ CProtoSettings(ps[i]->szName).SetMsgFormat(SMF_TEMPORARY, ps[i]->szMsg ? ps[i]->szMsg : CProtoSettings(ps[i]->szName).GetMsgFormat(GMF_LASTORDEFAULT));
}
}
return 0;
@@ -395,10 +379,9 @@ int CSModuleLoaded(WPARAM wParam, LPARAM lParam) // StartupStatus and AdvancedAu }
-int PreBuildContactMenu(WPARAM wParam, LPARAM lParam)
+int PreBuildContactMenu(WPARAM hContact, LPARAM lParam)
{
- HANDLE hContact = (HANDLE)wParam;
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ char *szProto = GetContactProto(hContact);
CLISTMENUITEM miSetMsg = {0};
miSetMsg.cbSize = sizeof(miSetMsg);
miSetMsg.flags = CMIM_FLAGS | CMIF_TCHAR | CMIF_HIDDEN;
@@ -407,7 +390,7 @@ int PreBuildContactMenu(WPARAM wParam, LPARAM lParam) miReadMsg.flags = CMIM_FLAGS | CMIF_TCHAR | CMIF_HIDDEN;
int iMode = szProto ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : 0;
int Flag1 = szProto ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) : 0;
- int iContactMode = DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE);
+ int iContactMode = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
TCHAR szSetStr[256], szReadStr[256];
if (szProto)
{
@@ -469,7 +452,7 @@ int PreBuildContactMenu(WPARAM wParam, LPARAM lParam) }
-static INT_PTR SetContactStatMsg(WPARAM wParam, LPARAM lParam)
+static INT_PTR SetContactStatMsg(WPARAM hContact, LPARAM lParam)
{
if (g_SetAwayMsgPage.GetWnd()) // already setting something
{
@@ -478,15 +461,15 @@ static INT_PTR SetContactStatMsg(WPARAM wParam, LPARAM lParam) }
SetAwayMsgData *dat = new SetAwayMsgData;
ZeroMemory(dat, sizeof(SetAwayMsgData));
- dat->hInitContact = (HANDLE)wParam;
- dat->szProtocol = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
+ dat->hInitContact = hContact;
+ dat->szProtocol = GetContactProto(hContact);
dat->IsModeless = false;
DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_SETAWAYMSG), NULL, SetAwayMsgDlgProc, (LPARAM)dat);
return 0;
}
/* //NightFox: deleted used-to-be support
-void UpdateSOEButtons(HANDLE hContact)
+void UpdateSOEButtons(MCONTACT hContact)
{
if (!hContact)
{
@@ -507,37 +490,33 @@ void UpdateSOEButtons(HANDLE hContact) }
*/
-INT_PTR ToggleSendOnEvent(WPARAM wParam, LPARAM lParam)
+INT_PTR ToggleSendOnEvent(WPARAM hContact, LPARAM lParam)
{ // used only for the global setting
- HANDLE hContact = (HANDLE)wParam;
- CContactSettings(g_ProtoStates[hContact ? (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0) : (char*)NULL].Status, hContact).Autoreply.Toggle();
+ CContactSettings(g_ProtoStates[hContact ? GetContactProto(hContact) : NULL].Status, hContact).Autoreply.Toggle();
//UpdateSOEButtons();
return 0;
}
-INT_PTR srvAutoreplyOn(WPARAM wParam, LPARAM lParam)
-{ // wParam = hContact
- HANDLE hContact = (HANDLE)wParam;
- CContactSettings(g_ProtoStates[(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)].Status, hContact).Autoreply = 1;
+INT_PTR srvAutoreplyOn(WPARAM hContact, LPARAM lParam)
+{
+ CContactSettings(g_ProtoStates[GetContactProto(hContact)].Status, hContact).Autoreply = 1;
//UpdateSOEButtons(hContact);
return 0;
}
-INT_PTR srvAutoreplyOff(WPARAM wParam, LPARAM lParam)
-{ // wParam = hContact
- HANDLE hContact = (HANDLE)wParam;
- CContactSettings(g_ProtoStates[(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)].Status, hContact).Autoreply = 0;
+INT_PTR srvAutoreplyOff(WPARAM hContact, LPARAM lParam)
+{
+ CContactSettings(g_ProtoStates[GetContactProto(hContact)].Status, hContact).Autoreply = 0;
//UpdateSOEButtons(hContact);
return 0;
}
-INT_PTR srvAutoreplyUseDefault(WPARAM wParam, LPARAM lParam)
-{ // wParam = hContact
- HANDLE hContact = (HANDLE)wParam;
- CContactSettings(g_ProtoStates[(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)].Status, hContact).Autoreply = VAL_USEDEFAULT;
+INT_PTR srvAutoreplyUseDefault(WPARAM hContact, LPARAM lParam)
+{
+ CContactSettings(g_ProtoStates[GetContactProto(hContact)].Status, hContact).Autoreply = VAL_USEDEFAULT;
//UpdateSOEButtons(hContact);
return 0;
}
@@ -589,7 +568,7 @@ static int IconsChanged(WPARAM wParam, LPARAM lParam) static int ContactSettingsInit(WPARAM wParam, LPARAM lParam)
{
CONTACTSETTINGSINIT *csi = (CONTACTSETTINGSINIT*)wParam;
- char *szProto = (csi->Type == CSIT_CONTACT) ? (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)csi->hContact, 0) : NULL;
+ char *szProto = (csi->Type == CSIT_CONTACT) ? GetContactProto(csi->hContact) : NULL;
if ((csi->Type == CSIT_GROUP) || szProto)
{
int Flag1 = (csi->Type == CSIT_CONTACT) ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) : PF1_IM; // we assume that there can be some contacts in the group with PF1_IM capability
@@ -685,7 +664,7 @@ INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam) {
if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_MYNICKPERPROTO) && VarParseData.szProto)
{
- Result = DBGetContactSettingString(NULL, VarParseData.szProto, "Nick", (TCHAR*)NULL);
+ Result = db_get_s(NULL, VarParseData.szProto, "Nick", (TCHAR*)NULL);
}
if (Result == NULL)
{
@@ -697,11 +676,11 @@ INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam) }
} else if (!lstrcmp(ai->targv[0], _T(VAR_REQUESTCOUNT)))
{
- mir_sntprintf(Result.GetBuffer(16), 16, _T("%d"), DBGetContactSettingWord(ai->fi->hContact, MOD_NAME, DB_REQUESTCOUNT, 0));
+ mir_sntprintf(Result.GetBuffer(16), 16, _T("%d"), db_get_w(ai->fi->hContact, MOD_NAME, DB_REQUESTCOUNT, 0));
Result.ReleaseBuffer();
} else if (!lstrcmp(ai->targv[0], _T(VAR_MESSAGENUM)))
{
- mir_sntprintf(Result.GetBuffer(16), 16, _T("%d"), DBGetContactSettingWord(ai->fi->hContact, MOD_NAME, DB_MESSAGECOUNT, 0));
+ mir_sntprintf(Result.GetBuffer(16), 16, _T("%d"), db_get_w(ai->fi->hContact, MOD_NAME, DB_MESSAGECOUNT, 0));
Result.ReleaseBuffer();
} else if (!lstrcmp(ai->targv[0], _T(VAR_TIMEPASSED)))
{
@@ -754,7 +733,7 @@ INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam) CString AnsiResult;
CallProtoService(VarParseData.szProto, PS_GETNAME, 256, (LPARAM)AnsiResult.GetBuffer(256));
AnsiResult.ReleaseBuffer();
- Result = ANSI2TCHAR(AnsiResult);
+ Result = _A2T(AnsiResult);
}
if (Result == NULL)
{ // if we didn't find a message with specified title
@@ -799,17 +778,18 @@ static INT_PTR MyCallService(const char *name, WPARAM wParam, LPARAM lParam) {
g_ProtoStates[Proto].Status = wParam;
TCString Msg(CProtoSettings(Proto).GetMsgFormat(GMF_LASTORDEFAULT));
- LogMessage("Detected a PS_SETSTATUS call with Status different from the one known to NAS. szProto=%s, NewStatus=%d, NewMsg:\n%s", (char*)Proto, wParam, (Msg != NULL) ? TCHAR2ANSI(Msg) : "NULL");
+ LogMessage("Detected a PS_SETSTATUS call with Status different from the one known to NAS. szProto=%s, NewStatus=%d, NewMsg:\n%s", (char*)Proto, wParam, (Msg != NULL) ? _T2A(Msg) : "NULL");
CProtoSettings(Proto).SetMsgFormat(SMF_TEMPORARY, Msg);
}
- } else if (!lstrcmpA(pProtoNameEnd, PS_SETAWAYMSG))
- {
- // PS_SETAWAYMSG service; wParam = status; lParam = (const char*)szMessage
- // returns 0 on success, nonzero on failure
- CString Proto("");
+ }
+ else if (!lstrcmpA(pProtoNameEnd, PS_SETAWAYMSG)) {
+ // PS_SETAWAYMSG service; wParam = status; lParam = (const char*)szMessage
+ // returns 0 on success, nonzero on failure
+ CString Proto("");
Proto.DiffCat(name, pProtoNameEnd);
- LogMessage("Someone else than NAS called PS_SETAWAYMSG. szProto=%s, Status=%d, Msg:\n%s", (char*)Proto, wParam, lParam ? (char*)lParam : "NULL");
- CProtoSettings(Proto).SetMsgFormat(SMF_TEMPORARY, lParam ? ((ServiceExists(MS_VARS_FORMATSTRING) && !g_SetAwayMsgPage.GetDBValueCopy(IDS_SAWAYMSG_DISABLEVARIABLES)) ? VariablesEscape(ANSI2TCHAR((char*)lParam)) : ANSI2TCHAR((char*)lParam)) : TCString(_T("")));
+ char *param = (char*)lParam;
+ LogMessage("Someone else than NAS called PS_SETAWAYMSG. szProto=%s, Status=%d, Msg:\n%s", (char*)Proto, wParam, param ? param : "NULL");
+ CProtoSettings(Proto).SetMsgFormat(SMF_TEMPORARY, lParam ? ((ServiceExists(MS_VARS_FORMATSTRING) && !g_SetAwayMsgPage.GetDBValueCopy(IDS_SAWAYMSG_DISABLEVARIABLES)) ? VariablesEscape((TCHAR*)_A2T(param)) : (TCHAR*)_A2T(param)) : TCString(_T("")));
ChangeProtoMessages(Proto, wParam, TCString());
return 0;
}
@@ -829,7 +809,7 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) PROTOCOLDESCRIPTOR **proto;
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, false, 0);
int iProtoCount = 0;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&iProtoCount, (LPARAM)&proto);
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&iProtoCount, (LPARAM)&proto);
int i;
int CurProtoIndex;
for (i = 0, CurProtoIndex = 0; i < iProtoCount && CurProtoIndex < MAXICQACCOUNTS; i++)
@@ -976,36 +956,35 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) extern "C" int __declspec(dllexport) Load(void)
{
-
mir_getLP( &pluginInfo );
hHooks.insert(HookEvent(ME_SYSTEM_MODULESLOADED, MirandaLoaded));
- if (DBGetContactSettingString(NULL, "KnownModules", "New Away System", (char*)NULL) == NULL)
- DBWriteContactSettingString(NULL, "KnownModules", "New Away System", MOD_NAME);
+ if (db_get_s(NULL, "KnownModules", "New Away System", (char*)NULL) == NULL)
+ db_set_s(NULL, "KnownModules", "New Away System", MOD_NAME);
InitCommonControls();
InitOptions(); // must be called before we hook CallService
logservice_register(LOG_ID, LPGENT("New Away System"), _T("NewAwaySys?puts(p,?dbsetting(%subject%,Protocol,p))?if2(_?dbsetting(,?get(p),?pinfo(?get(p),uidsetting)),).log"), TranslateTS(_T("`[`!cdate()-!ctime()`]` ?cinfo(%subject%,display) (?cinfo(%subject%,id)) read your %") _T(VAR_STATDESC) _T("% message:\r\n%extratext%\r\n\r\n")));
- if (DBGetContactSettingByte(NULL, MOD_NAME, DB_SETTINGSVER, 0) < 1)
+ if (db_get_b(NULL, MOD_NAME, DB_SETTINGSVER, 0) < 1)
{ // change all %nas_message% variables to %extratext% if it wasn't done before
TCString Str;
- Str = DBGetContactSettingString(NULL, MOD_NAME, "PopupsFormat", _T(""));
+ Str = db_get_s(NULL, MOD_NAME, "PopupsFormat", _T(""));
if (Str.GetLen())
{
- DBWriteContactSettingTString(NULL, MOD_NAME, "PopupsFormat", Str.Replace(_T("nas_message"), _T("extratext")));
+ db_set_ts(NULL, MOD_NAME, "PopupsFormat", Str.Replace(_T("nas_message"), _T("extratext")));
}
- Str = DBGetContactSettingString(NULL, MOD_NAME, "ReplyPrefix", _T(""));
+ Str = db_get_s(NULL, MOD_NAME, "ReplyPrefix", _T(""));
if (Str.GetLen())
{
- DBWriteContactSettingTString(NULL, MOD_NAME, "ReplyPrefix", Str.Replace(_T("nas_message"), _T("extratext")));
+ db_set_ts(NULL, MOD_NAME, "ReplyPrefix", Str.Replace(_T("nas_message"), _T("extratext")));
}
}
- if (DBGetContactSettingByte(NULL, MOD_NAME, DB_SETTINGSVER, 0) < 2)
+ if (db_get_b(NULL, MOD_NAME, DB_SETTINGSVER, 0) < 2)
{ // disable autoreply for not-on-list contacts, as such contact may be a spam bot
- DBWriteContactSettingByte(NULL, MOD_NAME, ContactStatusToDBSetting(0, DB_ENABLEREPLY, 0, INVALID_HANDLE_VALUE), 0);
- DBWriteContactSettingByte(NULL, MOD_NAME, DB_SETTINGSVER, 2);
+ db_set_b(NULL, MOD_NAME, ContactStatusToDBSetting(0, DB_ENABLEREPLY, 0, INVALID_CONTACT_ID), 0);
+ db_set_b(NULL, MOD_NAME, DB_SETTINGSVER, 2);
}
return 0;
}
diff --git a/plugins/NewAwaySysMod/src/CString.cpp b/plugins/NewAwaySysMod/src/CString.cpp new file mode 100644 index 0000000000..da36abd4d6 --- /dev/null +++ b/plugins/NewAwaySysMod/src/CString.cpp @@ -0,0 +1,308 @@ +/*
+ TCString.cpp - TCString class
+ Copyright (c) 2005-2008 Chervov Dmitry
+
+ 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"
+
+#define STR_GROWBY 64
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+
+
+template <class T>
+void TString<T>::Empty()
+{
+ nBufSize = 1;
+ SetAllocSize(STR_GROWBY);
+ pBuf[0] = 0;
+}
+
+
+template <class T>
+void TString<T>::Free()
+{
+// HeapFree(GetProcessHeap(), 0, pBuf);
+ free(pBuf);
+ pBuf = NULL;
+ nBufSize = 0;
+ nAllocSize = 0;
+}
+
+
+template <class T>
+T *TString<T>::GetBuffer(int nNewLen)
+{
+ if (nNewLen != -1)
+ {
+ SetBufSize(nNewLen + 1);
+ }
+ _ASSERT(pBuf);
+ return pBuf;
+}
+
+
+template <class T>
+void TString<T>::ReleaseBuffer(int nNewLen)
+{
+ if (nNewLen == -1)
+ {
+ nBufSize = My_lstrlen(pBuf) + 1;
+ } else
+ {
+ nBufSize = nNewLen + 1;
+ pBuf[nNewLen] = 0;
+ _ASSERT(My_lstrlen(pBuf) == nNewLen);
+ }
+ _ASSERT(nBufSize <= nAllocSize); // prevent buffer overruns
+}
+
+
+template <class T>
+void TString<T>::SetAllocSize(int nNewAllocSize)
+{
+ _ASSERT(nNewAllocSize > 0);
+ T *pNewBuf = /*(char *)HeapAlloc(GetProcessHeap(), 0, sizeof(char) * nNewAllocSize);*/
+(T *)malloc(sizeof(T) * nNewAllocSize);
+ if (pBuf)
+ {
+ memcpy(pNewBuf, pBuf, sizeof(T) * min(nBufSize, nNewAllocSize));
+ //HeapFree(GetProcessHeap(), 0, pBuf);
+ free(pBuf);
+ }
+ pBuf = pNewBuf;
+ nAllocSize = nNewAllocSize;
+}
+
+
+template <class T>
+void TString<T>::SetBufSize(int nNewBufSize)
+{
+ _ASSERT(nNewBufSize >= 0);
+ if (nNewBufSize < nBufSize)
+ {
+ _ASSERT(pBuf);
+ pBuf[nNewBufSize - 1] = 0;
+ }
+ if ((unsigned)(nAllocSize - nNewBufSize) / STR_GROWBY)
+ {
+ SetAllocSize((nNewBufSize + STR_GROWBY - 1) - (nNewBufSize + STR_GROWBY - 1) % STR_GROWBY);
+ }
+ nBufSize = nNewBufSize;
+}
+
+
+template <class T>
+TString<T>& TString<T>::Cat(const T *pStr)
+{
+ _ASSERT(pBuf && pStr);
+ int StrLen = My_lstrlen(pStr);
+ SetAllocSize(nBufSize + StrLen);
+ My_lstrcpy(GetBuffer() + GetLen(), pStr);
+ ReleaseBuffer(nBufSize + StrLen - 1);
+ return *this;
+}
+
+
+template <class T>
+TString<T>& TString<T>::Cat(const T c)
+{
+ _ASSERT(pBuf);
+ SetAllocSize(nBufSize + 1);
+ int CurLen = GetLen();
+ T *p = GetBuffer();
+ p[CurLen] = c;
+ p[CurLen + 1] = '\0';
+ ReleaseBuffer(nBufSize);
+ return *this;
+}
+
+
+template <class T>
+TString<T>& TString<T>::DiffCat(const T *pStart, const T *pEnd)
+{
+ _ASSERT(pBuf && pStart && pEnd);
+ int StrLen = pEnd - pStart;
+ SetAllocSize(nBufSize + StrLen);
+ My_strncpy(GetBuffer() + GetLen(), pStart, StrLen);
+ ReleaseBuffer(nBufSize + StrLen - 1);
+ return *this;
+}
+
+
+template <class T>
+TString<T>& TString<T>::Replace(const T *szFind, const T *szReplaceBy)
+{
+ if (!pBuf)
+ {
+ return *this;
+ }
+ T *pCurPos = pBuf;
+ int FindLen = My_lstrlen(szFind);
+ T *p;
+ TString<T> Result;
+ Result.GetBuffer(1)[0] = '\0';
+ Result.ReleaseBuffer(0); // set the string to ""; we can't do it in a usual way (using a constructor or an assignment) because we don't know whether "" needs to be unicode or ansi
+ while (p = ( T* )My_strstr(pCurPos, szFind))
+ {
+ Result.DiffCat(pCurPos, p);
+ Result += szReplaceBy;
+ pCurPos = p + FindLen;
+ }
+ Result += pCurPos;
+ *this = Result;
+ return *this;
+}
+
+
+template <class T>
+TString<T>& TString<T>::Replace(int nIndex, int nCount, const T *szReplaceBy)
+{
+ if (!pBuf || !szReplaceBy || nIndex < 0 || nCount < 0)
+ {
+ return *this;
+ }
+
+ TString<T> Result;
+ Result.GetBuffer(1)[0] = '\0';
+ Result.ReleaseBuffer(0); // set the string to ""; we can't do it in a usual way (using a constructor or an assignment) because we don't know whether "" needs to be unicode or ansi
+ if (nIndex > GetLen())
+ {
+ nIndex = GetLen();
+ }
+ if (nIndex + nCount > GetLen())
+ {
+ nCount = GetLen() - nIndex;
+ }
+ Result.DiffCat(pBuf, pBuf + nIndex);
+ Result += szReplaceBy;
+ Result += pBuf + nIndex + nCount;
+ *this = Result;
+ return *this;
+}
+
+
+template <class T>
+TString<T> TString<T>::Left(int nCount) const
+{
+ _ASSERT(nCount >= 0);
+ TString<T> Result(*this);
+ Result.SetBufSize(nCount + 1);
+ return Result;
+}
+
+
+template <class T>
+TString<T> TString<T>::Right(int nCount) const
+{
+ _ASSERT(nCount >= 0);
+ if (nCount < GetLen())
+ {
+ return &pBuf[GetLen() - nCount];
+ } else
+ {
+ return *this;
+ }
+}
+
+
+template <class T>
+TString<T> TString<T>::SubStr(int nIndex, int nCount) const
+{
+ _ASSERT(nIndex >= 0 && nCount >= 0);
+ TString<T> Result;
+ if (nIndex < GetLen())
+ {
+ My_strncpy(Result.GetBuffer(nCount), &pBuf[nIndex], nCount);
+ Result.ReleaseBuffer();
+ } else
+ {
+ Result.GetBuffer(1)[0] = '\0';
+ Result.ReleaseBuffer(0);
+ }
+ return Result;
+}
+
+
+template <class T>
+TString<T> TString<T>::ToLower() const
+{
+ TString<T> Result(*this);
+ if (!pBuf)
+ {
+ return Result; // return NULL string
+ }
+ My_strlwr((T*)Result);
+ return Result;
+}
+
+
+template <class T>
+TString<T>& TString<T>::operator = (const T *pStr)
+{
+ if (pStr)
+ {
+ int StrLen = My_lstrlen(pStr);
+ SetBufSize(StrLen + 1);
+ My_lstrcpy(GetBuffer(), pStr);
+ ReleaseBuffer(StrLen);
+ } else
+ {
+ Free();
+ }
+ return *this;
+}
+
+template class TString<TCHAR>;
+template class TString<char>;
+template class TString<WCHAR>;
+
+CString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szDefaultValue)
+{
+ ptrA p( db_get_sa(hContact, szModule, szSetting));
+ return CString(p == NULL ? szDefaultValue : p);
+}
+
+TCString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR *szDefaultValue)
+{
+ ptrT p( db_get_tsa(hContact, szModule, szSetting));
+ return TCString(p == NULL ? szDefaultValue : p);
+}
+
+TCString DBGetContactSettingAsString(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR *szDefaultValue)
+{ // also converts numeric values to a string
+ DBVARIANT dbv = {0};
+ int iRes = db_get_ws(hContact, szModule, szSetting, &dbv);
+
+ TCString Result;
+ if (!iRes && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR))
+ {
+ Result = dbv.ptszVal;
+ }
+ else if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD)
+ {
+ long value = (dbv.type == DBVT_DWORD) ? dbv.dVal : (dbv.type == DBVT_WORD ? dbv.wVal : dbv.bVal);
+ _ultot(value, Result.GetBuffer(64), 10);
+ Result.ReleaseBuffer();
+ }
+ else Result = szDefaultValue;
+
+ if (!iRes)
+ db_free(&dbv);
+
+ return Result;
+}
diff --git a/plugins/NewAwaySysMod/src/CString.h b/plugins/NewAwaySysMod/src/CString.h new file mode 100644 index 0000000000..0d81a4f7c3 --- /dev/null +++ b/plugins/NewAwaySysMod/src/CString.h @@ -0,0 +1,237 @@ +/*
+ TCString.h - TCString class
+ Copyright (c) 2005-2008 Chervov Dmitry
+
+ 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
+*/
+
+#pragma once
+
+#include <windows.h>
+#include <tchar.h>
+#include <crtdbg.h>
+#ifdef CHARARRAY_CONVERT
+#include "TMyArray.h"
+#endif
+#include "newpluginapi.h"
+#include "m_system.h"
+#include "m_database.h"
+
+__inline int My_lstrlen(LPCSTR lpString) {return lstrlenA(lpString);}
+__inline int My_lstrlen(LPCWSTR lpString) {return lstrlenW(lpString);}
+__inline int My_lstrcmp(LPCSTR lpString1, LPCSTR lpString2) {return lstrcmpA(lpString1, lpString2);}
+__inline int My_lstrcmp(LPCWSTR lpString1, LPCWSTR lpString2) {return lstrcmpW(lpString1, lpString2);}
+__inline LPCSTR My_strstr(LPCSTR lpString1, LPCSTR lpString2) {return strstr(lpString1, lpString2);}
+__inline LPWSTR My_strstr(LPCWSTR lpString1, LPCWSTR lpString2) {return (LPWSTR)wcsstr(lpString1, lpString2);}
+__inline LPSTR My_lstrcpy(LPSTR lpString1, LPCSTR lpString2) {return lstrcpyA(lpString1, lpString2);}
+__inline LPWSTR My_lstrcpy(LPWSTR lpString1, LPCWSTR lpString2) {return lstrcpyW(lpString1, lpString2);}
+__inline LPSTR My_strncpy(LPSTR lpString1, LPCSTR lpString2, int Len) {return strncpy(lpString1, lpString2, Len);}
+__inline LPWSTR My_strncpy(LPWSTR lpString1, LPCWSTR lpString2, int Len) {return wcsncpy(lpString1, lpString2, Len);}
+__inline LPSTR My_strlwr(LPSTR lpString) {return _strlwr(lpString);}
+__inline LPWSTR My_strlwr(LPWSTR lpString) {return _wcslwr(lpString);}
+
+template <class T>
+class TString
+{
+public:
+ TString(): pBuf(NULL), nBufSize(0), nAllocSize(0) {}
+ TString(const T *pStr): pBuf(NULL), nBufSize(0), nAllocSize(0) {*this = pStr;}
+ TString(const TString<T> &Str): pBuf(NULL), nBufSize(0), nAllocSize(0) {*this = Str.pBuf;}
+ ~TString() {Free();}
+
+ int GetLen() const {return (nBufSize) ? (nBufSize - 1) : 0;};
+ int IsEmpty() const {return (!GetLen());};
+ T *GetBuffer(int nNewLen = -1);
+ void ReleaseBuffer(int nNewLen = -1);
+ TString<T>& Cat(const T *pStr);
+ TString<T>& Cat(const T c);
+ TString<T>& DiffCat(const T *pStart, const T *pEnd);
+ TString<T>& Replace(const T *szFind, const T *szReplaceBy);
+ TString<T>& Replace(int nIndex, int nCount, const T *szReplaceBy);
+ TString<T> Left(int nCount) const;
+ TString<T> Right(int nCount) const;
+ TString<T> SubStr(int nIndex, int nCount) const;
+ TString<T> ToLower() const;
+ void Empty();
+ void Free();
+ T& operator [] (int nIndex) {_ASSERT(nIndex >= 0 && nIndex <= GetLen()); return pBuf[nIndex];}
+ operator const T*() const {return pBuf;}
+ operator T*() {return pBuf;}
+ TString<T>& operator = (const T *pStr);
+ TString<T>& operator = (const TString<T> &Str) {return *this = Str.pBuf;}
+// TCString& operator + (const char *pStr)
+// {_ASSERT(pBuf && pStr); TCString Result(*this); return Result.Cat(pStr);}
+ friend TString<T> operator + (const TString<T> &Str1, const T *Str2)
+ {_ASSERT(Str1.pBuf && Str2); TString<T> Result(Str1); return Result.Cat(Str2);}
+/* friend TCString operator + (const char *Str1, const TCString &Str2)
+ {_ASSERT(Str1 && Str2.pBuf); TCString Result(Str1); return Result.Cat(Str2);}*/
+ TString<T>& operator += (const T *pStr) {_ASSERT(pBuf && pStr); return this->Cat(pStr);}
+ TString<T>& operator += (const T c) {_ASSERT(pBuf); return this->Cat(c);}
+ int operator == (const T *pStr) const {return (!pBuf || !pStr) ? (pBuf == pStr) : !My_lstrcmp(pBuf, pStr);}
+ int operator != (const T *pStr) const {return (!pBuf || !pStr) ? (pBuf != pStr) : My_lstrcmp(pBuf, pStr);}
+ int operator < (const T *pStr) const {_ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) > 0;}
+ int operator > (const T *pStr) const {_ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) < 0;}
+ int operator <= (const T *pStr) const {_ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) >= 0;}
+ int operator >= (const T *pStr) const {_ASSERT(pBuf && pStr); return My_lstrcmp(pBuf, pStr) <= 0;}
+// TCString& Format(char *pszFormat, ...);
+
+private:
+ void SetBufSize(int nNewBufSize);
+ void SetAllocSize(int nNewAllocSize);
+
+ T *pBuf;
+ int nBufSize; // current string length + 1 (including 0 at the end)
+ int nAllocSize; // allocated memory size
+};
+
+
+typedef TString<TCHAR> TCString;
+typedef TString<char> CString;
+typedef TString<WCHAR> WCString;
+
+#ifdef CHARARRAY_CONVERT
+
+__inline CHARARRAY WCHAR2ANSI_ARRAY(CHARARRAY &c)
+{
+ CHARARRAY Result;
+ int Len = WideCharToMultiByte(CP_ACP, 0, (WCHAR*)c.GetData(), c.GetSize() / sizeof(WCHAR), NULL, 0, NULL, NULL);
+ if (Len)
+ {
+ Result.SetAtGrow(Len - 1);
+ if (!WideCharToMultiByte(CP_ACP, 0, (WCHAR*)c.GetData(), c.GetSize() / sizeof(WCHAR), Result.GetData(), Len, NULL, NULL))
+ {
+ Result.RemoveAll();
+ }
+ if (Result.GetSize())
+ {
+ Result.RemoveElem(Result.GetSize() - 1); // remove the null terminator
+ }
+ }
+ return Result;
+}
+
+__inline CHARARRAY ANSI2WCHAR_ARRAY(CHARARRAY &c)
+{
+ CHARARRAY Result;
+ int Len = MultiByteToWideChar(CP_ACP, 0, c.GetData(), c.GetSize(), NULL, 0);
+ if (Len)
+ {
+ Result.SetAtGrow(Len * sizeof(WCHAR) - 1);
+ if (!MultiByteToWideChar(CP_ACP, 0, c.GetData(), c.GetSize(), (WCHAR*)Result.GetData(), Len))
+ {
+ Result.RemoveAll();
+ }
+ if (Result.GetSize())
+ {
+ Result.RemoveElem(Result.GetSize() - 1);
+ Result.RemoveElem(Result.GetSize() - 1); // remove the null terminator
+ }
+ }
+ return Result;
+}
+
+
+__inline CHARARRAY WCHAR2UTF8(WCString Str)
+{
+ CHARARRAY Result;
+ int Len = WideCharToMultiByte(CP_UTF8, 0, Str, -1, NULL, 0, NULL, NULL);
+ if (Len)
+ {
+ Result.SetAtGrow(Len - 1);
+ if (!WideCharToMultiByte(CP_UTF8, 0, Str, -1, Result.GetData(), Len, NULL, NULL))
+ {
+ Result.RemoveAll();
+ }
+ }
+ return Result;
+}
+
+
+#endif // CHARARRAY_CONVERT
+
+
+#undef db_get_s
+CString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szDefaultValue);
+TCString db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR *szDefaultValue);
+int db_get_s(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
+TCString DBGetContactSettingAsString(MCONTACT hContact, const char *szModule, const char *szSetting, const TCHAR *szDefaultValue); // also converts numeric values to a string
+
+// various string helpers. their return values are valid only while the class is visible
+class UTF8Encode
+{
+public:
+ UTF8Encode(const char *str) { p = mir_utf8encode(str); }
+ UTF8Encode(const wchar_t *str) { p = mir_utf8encodeW(str); }
+ ~UTF8Encode() { mir_free(p); }
+ operator char*() { return p; }
+
+private:
+ char *p;
+};
+
+class UTF8DecodeA
+{
+public:
+ UTF8DecodeA(const char *str) { p = mir_strdup(str); mir_utf8decode(p, NULL); }
+ ~UTF8DecodeA() { mir_free(p); }
+ operator char*() { return p; }
+
+private:
+ char *p;
+};
+
+class UTF8DecodeW
+{
+public:
+ UTF8DecodeW(const char *str) { p = mir_utf8decodeW(str); }
+ ~UTF8DecodeW() { mir_free(p); }
+ operator wchar_t*() { return p; }
+
+private:
+ wchar_t *p;
+};
+
+
+#define UTF8Decode UTF8DecodeW
+
+
+/*class mallocStrA
+{
+public:
+ mallocStrA(int n) { p = (char*)malloc((n + 1) * sizeof(char)); }
+ mallocStrA(const char *str) { p = str ? strdup(str) : NULL; }
+ ~mallocStrA() { if (p) free(p); }
+ operator char*() { return p; }
+
+private:
+ char *p;
+};
+
+class mallocStrW
+{
+public:
+ mallocStrW(int n) { p = (wchar_t*)malloc((n + 1) * sizeof(wchar_t)); }
+ mallocStrW(const wchar_t *str) { p = str ? _wcsdup(str) : NULL; }
+ ~mallocStrW() { if (p) free(p); }
+ operator wchar_t*() { return p; }
+
+private:
+ wchar_t *p;
+};
+
+
+#define mallocStr mallocStrW
+
+*/
\ No newline at end of file diff --git a/plugins/!Deprecated/NewAwaySysMod/Client.cpp b/plugins/NewAwaySysMod/src/Client.cpp index 7767bdb285..9d8c520f7c 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Client.cpp +++ b/plugins/NewAwaySysMod/src/Client.cpp @@ -32,7 +32,7 @@ void __cdecl UpdateMsgsThreadProc(void *) {
int ProtoCount;
PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&ProtoCount, (LPARAM)&proto);
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
int I;
while (WaitForSingleObject(g_hTerminateUpdateMsgsThread, 0) == WAIT_TIMEOUT && !Miranda_Terminated())
{
@@ -48,11 +48,11 @@ void __cdecl UpdateMsgsThreadProc(void *) }
if (CallProtoService(proto[I]->szName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(Status) && g_ProtoStates[proto[I]->szName].CurStatusMsg.GetUpdateTimeDifference() >= MinUpdateTimeDifference)
{
- TCString CurMsg(GetDynamicStatMsg(INVALID_HANDLE_VALUE, proto[I]->szName));
+ TCString CurMsg(GetDynamicStatMsg(INVALID_CONTACT_ID, proto[I]->szName));
if ((TCString)g_ProtoStates[proto[I]->szName].CurStatusMsg != (const TCHAR*)CurMsg) // if the message has changed
{
g_ProtoStates[proto[I]->szName].CurStatusMsg = CurMsg;
- CallAllowedPS_SETAWAYMSG(proto[I]->szName, Status, (char*)TCHAR2ANSI(CurMsg));
+ CallAllowedPS_SETAWAYMSG(proto[I]->szName, Status, (char*)_T2A(CurMsg));
}
}
}
@@ -94,25 +94,25 @@ void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg) {
if (Msg == NULL)
{
- CurMsg = GetDynamicStatMsg(INVALID_HANDLE_VALUE, szProto);
+ CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, szProto);
}
- CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)TCHAR2ANSI(CurMsg));
+ CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)_T2A(CurMsg));
g_ProtoStates[szProto].CurStatusMsg = CurMsg;
} else // change message of all protocols
{
int ProtoCount;
PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&ProtoCount, (LPARAM)&proto);
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
int I;
for (I = 0; I < ProtoCount; I++)
{
- if (proto[I]->type == PROTOTYPE_PROTOCOL && !DBGetContactSettingByte(NULL, proto[I]->szName, "LockMainStatus", 0))
+ if (proto[I]->type == PROTOTYPE_PROTOCOL && !db_get_b(NULL, proto[I]->szName, "LockMainStatus", 0))
{
if (Msg == NULL)
{
- CurMsg = GetDynamicStatMsg(INVALID_HANDLE_VALUE, proto[I]->szName);
+ CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, proto[I]->szName);
}
- CallAllowedPS_SETAWAYMSG(proto[I]->szName, iMode, (char*)TCHAR2ANSI(CurMsg));
+ CallAllowedPS_SETAWAYMSG(proto[I]->szName, iMode, (char*)_T2A(CurMsg));
g_ProtoStates[proto[I]->szName].CurStatusMsg = CurMsg;
}
}
@@ -139,8 +139,8 @@ void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg) {
if (iMode == StatusSettings[I].Status)
{
- DBWriteContactSettingTString(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Msg", CurMsg);
- DBWriteContactSettingTString(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Default", CurMsg); // TODO: make it more accurate, and change not only here, but when changing status messages through UpdateMsgsTimerFunc too; and when changing messages through AutoAway() ?
+ db_set_ts(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Msg", CurMsg);
+ db_set_ts(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Default", CurMsg); // TODO: make it more accurate, and change not only here, but when changing status messages through UpdateMsgsTimerFunc too; and when changing messages through AutoAway() ?
break;
}
}
diff --git a/plugins/!Deprecated/NewAwaySysMod/Common.h b/plugins/NewAwaySysMod/src/Common.h index 4fe6d2d50f..8449efea0a 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Common.h +++ b/plugins/NewAwaySysMod/src/Common.h @@ -22,16 +22,18 @@ #pragma once
#define _CRT_SECURE_NO_WARNINGS
-#define WIN32_LEAN_AND_MEAN
#define _WIN32_WINNT 0x0500
-#define MIRANDA_VER 0x0600
+#define MIRANDA_VER 0x0A00
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <CommCtrl.h>
#include <commdlg.h>
+#include <Uxtheme.h>
+#include <vsstyle.h>
+
#include <time.h>
#include <shellapi.h>
#include <crtdbg.h>
@@ -46,7 +48,7 @@ #include "m_langpack.h"
#include "m_protosvc.h"
#include "m_options.h"
-#include "..\..\protocols\IcqOscarJ\icq_constants.h"
+#include "..\..\protocols\IcqOscarJ\src\icq_constants.h"
#include "m_skin.h"
#include "m_awaymsg.h"
#include "m_utils.h"
@@ -55,9 +57,7 @@ #include "m_message.h"
#include "m_userinfo.h"
#include "m_icq.h"
-#define THEMEAPI // we don't need no uxtheme defines :-/ they break everything when trying to include tmschema.h later
#include "win2k.h"
-#undef THEMEAPI
#include "resource.h"
@@ -67,12 +67,20 @@ //#include "m_popupw.h"
#include "m_metacontacts.h"
#include "m_LogService.h"
-#include "..\CommonLibs\CString.h"
-#include "..\CommonLibs\Options.h"
-
#pragma comment(lib,"comctl32.lib")
+#include "CString.h"
+#include "Options.h"
+
+#define CBSCHECK_UNCHECKED 1
+#define CBSCHECK_CHECKED 5
+#define CBSCHECK_MIXED 9
+#define CBSSTATE_NORMAL 0
+#define CBSSTATE_HOT 1
+#define CBSSTATE_PRESSED 2
+#define CBSSTATE_DISABLED 3
+
#define VAR_AWAYSINCE_TIME "nas_awaysince_time"
#define VAR_AWAYSINCE_DATE "nas_awaysince_date"
#define VAR_STATDESC "nas_statdesc"
@@ -244,7 +252,7 @@ int ICQStatusToGeneralStatus(int bICQStat); // TODO: get rid of these protocol-s typedef struct SetAwayMsgData_type
{
CString szProtocol;
- HANDLE hInitContact; // initial contact (filled by caller)
+ MCONTACT hInitContact; // initial contact (filled by caller)
TCString Message; // initial message, NULL means default
bool IsModeless; // means the dialog was created with the CreateDialogParam function, not DialogBoxParam
int ISW_Flags; // InvokeStatusWindow service flags
@@ -252,7 +260,7 @@ typedef struct SetAwayMsgData_type typedef struct READAWAYMSGDATA_TYPE
{
- HANDLE hContact; // contact
+ MCONTACT hContact; // contact
HANDLE hSeq; // sequence for stat msg request
HANDLE hAwayMsgEvent; // hooked
} READAWAYMSGDATA;
@@ -267,7 +275,7 @@ typedef struct typedef struct
{
- HANDLE hContact;
+ MCONTACT hContact;
int iStatusMode;
TCString Proto;
} DYNAMIC_NOTIFY_DATA;
@@ -275,7 +283,7 @@ typedef struct typedef struct
{
BYTE PopupLClickAction, PopupRClickAction;
- HANDLE hContact;
+ MCONTACT hContact;
HICON hStatusIcon; // needed here to destroy its handle on UM_FREEPLUGINDATA
} PLUGIN_DATA;
@@ -283,32 +291,13 @@ typedef struct {
int cbSize;
char *szProto;
- HANDLE hContact;
+ MCONTACT hContact;
char *szMsg;
WORD status;
} NAS_ISWINFOv1;
#define MTYPE_AUTOONLINE 0xE7 // required to support ICQ Plus online status messages
-/*
-// additional m_popup.h declarations
- typedef struct
- {
- HANDLE lchContact;
- HICON lchIcon;
- WCHAR lpzContactName[MAX_CONTACTNAME];
- WCHAR lpzText[MAX_SECONDLINE];
- COLORREF colorBack;
- COLORREF colorText;
- WNDPROC PluginWindowProc;
- void * PluginData;
- int iSeconds;
- char cZero[16];
- } POPUPDATAT;
-
- #define MS_POPUP_ADDPOPUPT MS_POPUP_ADDPOPUPW
-
-*/
// Beware of conflicts between two different windows trying to use the same page at a time!
// Other windows than the owner of the Page must copy the page to their own memory,
// or use GetDBValueCopy to retrieve values
@@ -326,7 +315,7 @@ extern bool g_fNoProcessing; extern int g_bIsIdle;
// AwaySys.cpp
-TCString GetDynamicStatMsg(HANDLE hContact, char *szProto = NULL, DWORD UIN = 0, int iStatus = 0);
+TCString GetDynamicStatMsg(MCONTACT hContact, char *szProto = NULL, DWORD UIN = 0, int iStatus = 0);
int IsAnICQProto(char *szProto);
// Client.cpp
@@ -346,7 +335,7 @@ INT_PTR GetContactStatMsg(WPARAM wParam, LPARAM lParam); int OptsDlgInit(WPARAM wParam, LPARAM lParam); // called on opening of the options dialog
void InitOptions(); // called once when plugin is loaded
-//int ShowPopupNotification(COptPage &PopupNotifyData, HANDLE hContact, int iStatusMode);
+//int ShowPopupNotification(COptPage &PopupNotifyData, MCONTACT hContact, int iStatusMode);
void ShowLog(TCString &LogFilePath);
void ShowMsg(TCHAR *szFirstLine, TCHAR *szSecondLine = _T(""), bool IsErrorMsg = false, int Timeout = 0);
@@ -358,7 +347,7 @@ int _Workaround_CallService(const char *name, WPARAM wParam, LPARAM lParam); int MsgEventAdded(WPARAM wParam, LPARAM lParam);
// buttons
-//void UpdateSOEButtons(HANDLE hContact = NULL);
+//void UpdateSOEButtons(MCONTACT hContact = NULL);
INT_PTR ToggleSendOnEvent(WPARAM wParam, LPARAM lParam);
//int Create_TopToolbar(WPARAM wParam, LPARAM lParam);
@@ -387,9 +376,7 @@ static __inline void my_variables_skin_helpbutton(HWND hwndDlg, UINT uIDButton) {
HICON hIcon = ServiceExists(MS_VARS_GETSKINITEM) ? (HICON)CallService(MS_VARS_GETSKINITEM, 0, (LPARAM)VSI_HELPICON) : NULL;
if (hIcon)
- {
SendDlgItemMessage(hwndDlg, uIDButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
- }
}
static __inline int my_variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags = 0, char *szSubjectDesc = NULL, char *szExtraDesc = NULL)
@@ -403,7 +390,8 @@ static __inline int my_variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags vhi.szSubjectDesc = szSubjectDesc;
vhi.szExtraTextDesc = szExtraDesc;
return CallService(MS_VARS_SHOWHELPEX, (WPARAM)hwndDlg, (LPARAM)&vhi);
- } else
+ }
+ else
{
ShowMsg(TranslateT("New Away System"), TranslateT("Variables plugin is not installed"), true);
return -1;
diff --git a/plugins/!Deprecated/NewAwaySysMod/ContactList.cpp b/plugins/NewAwaySysMod/src/ContactList.cpp index 70b26d1d57..f9a710532f 100644 --- a/plugins/!Deprecated/NewAwaySysMod/ContactList.cpp +++ b/plugins/NewAwaySysMod/src/ContactList.cpp @@ -142,7 +142,7 @@ static LRESULT CALLBACK ParentSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, L nm.OldSelection = &OldSelection;
nm.NewSelection = &dat->SelectedItems;
SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm);
- dat->Items[pnmtv->itemOld.lParam].hContact = INVALID_HANDLE_VALUE;
+ dat->Items[pnmtv->itemOld.lParam].hContact = INVALID_CONTACT_ID;
}
} break;
case NM_CUSTOMDRAW:
@@ -191,16 +191,14 @@ static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wPar {
case INTM_CONTACTDELETED: // wParam = (HANDLE)hContact
{
- HTREEITEM hItem = dat->FindContact((HANDLE)wParam);
+ HTREEITEM hItem = dat->FindContact(wParam);
if (hItem)
- {
TreeView_DeleteItem(hWnd, hItem);
- }
} break;
case INTM_ICONCHANGED: // wParam = (HANDLE)hContact, lParam = IconID
{
TVITEM tvi;
- tvi.hItem = dat->FindContact((HANDLE)wParam);
+ tvi.hItem = dat->FindContact(wParam);
if (tvi.hItem)
{
tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
@@ -371,7 +369,7 @@ static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wPar }
if (hItem)
{
- HANDLE hContact = dat->GetItemData(hItem).hContact;
+ MCONTACT hContact = dat->GetItemData(hItem).hContact;
if (IsHContactContact(hContact))
{
HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)hContact, 0);
@@ -420,7 +418,7 @@ CCList::~CCList() }
-HTREEITEM CCList::AddContact(HANDLE hContact)
+HTREEITEM CCList::AddContact(MCONTACT hContact)
// adds a new contact if it doesn't exist yet; returns its hItem
{
_ASSERT(IsHContactContact(hContact));
@@ -431,7 +429,7 @@ HTREEITEM CCList::AddContact(HANDLE hContact) }
TVINSERTSTRUCT tvIns;
ZeroMemory(&tvIns, sizeof(tvIns));
- tvIns.hParent = AddGroup(DBGetContactSettingString(hContact, "CList", "Group", _T("")));
+ tvIns.hParent = AddGroup(db_get_s(hContact, "CList", "Group", _T("")));
/* if (!tvIns.hParent)
{
return NULL;
@@ -454,7 +452,7 @@ typedef struct int GroupEnum(const char *szSetting, LPARAM lParam)
{
sGroupEnumData *GroupEnumData = (sGroupEnumData*)lParam;
- TCString GroupName = DBGetContactSettingString(NULL, "CListGroups", szSetting, _T(" "));
+ TCString GroupName = db_get_s(NULL, "CListGroups", szSetting, _T(" "));
if (!lstrcmp(GroupEnumData->GroupName, &GroupName[1]))
{
GroupEnumData->hGroup = (HANDLE)(atol(szSetting) | HCONTACT_ISGROUP);
@@ -482,7 +480,7 @@ HTREEITEM CCList::AddGroup(TCString GroupName) {
return NULL;
}
- HTREEITEM hGroupItem = FindContact(GroupEnumData.hGroup);
+ HTREEITEM hGroupItem = FindContact((MCONTACT)GroupEnumData.hGroup);
if (hGroupItem)
{
return hGroupItem; // exists already, just return its handle
@@ -503,7 +501,7 @@ HTREEITEM CCList::AddGroup(TCString GroupName) tvIns.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
tvIns.item.state = tvIns.item.stateMask = TVIS_BOLD | TVIS_EXPANDED;
tvIns.item.iImage = tvIns.item.iSelectedImage = IMAGE_GROUPOPEN;
- tvIns.item.lParam = Items.AddElem(CCLItemData(GroupEnumData.hGroup));
+ tvIns.item.lParam = Items.AddElem(CCLItemData((MCONTACT)GroupEnumData.hGroup));
return TreeView_InsertItem(hTreeView, &tvIns);
}
@@ -611,14 +609,14 @@ void CCList::SetExtraImageList(HIMAGELIST hImgList) int CCList::GetItemType(HTREEITEM hItem) // returns a MCLCIT_ (see below)
{
- HANDLE hContact = GetItemData(hItem).hContact;
+ MCONTACT hContact = GetItemData(hItem).hContact;
return (IsHContactInfo(hContact)) ? MCLCIT_INFO : ((IsHContactGroup(hContact)) ? MCLCIT_GROUP : MCLCIT_CONTACT);
}
DWORD CCList::GetItemTypeAsCLGNFlag(HTREEITEM hItem)
{
- HANDLE hContact = GetItemData(hItem).hContact;
+ MCONTACT hContact = GetItemData(hItem).hContact;
return (IsHContactInfo(hContact)) ? MCLGN_INFO : ((IsHContactGroup(hContact)) ? MCLGN_GROUP : MCLGN_CONTACT);
}
@@ -727,19 +725,14 @@ HTREEITEM CCList::GetNextItem(DWORD Flags, HTREEITEM hItem) }
-HANDLE CCList::GethContact(HTREEITEM hItem) // returns hContact, hGroup or hInfo
+MCONTACT CCList::GethContact(HTREEITEM hItem) // returns hContact, hGroup or hInfo
{
- HANDLE hContact = GetItemData(hItem).hContact;
+ MCONTACT hContact = GetItemData(hItem).hContact;
if (IsHContactContact(hContact))
- {
return hContact;
- } else if (IsHContactGroup(hContact))
- {
- return (HANDLE)((int)hContact & ~HCONTACT_ISGROUP);
- } else
- {
- return (HANDLE)((int)hContact & ~HCONTACT_ISINFO);
- }
+ if (IsHContactGroup(hContact))
+ return hContact & ~HCONTACT_ISGROUP;
+ return hContact & ~HCONTACT_ISINFO;
}
@@ -843,7 +836,7 @@ HTREEITEM CCList::TreeView_GetLastChild(HWND hTreeView, HTREEITEM hItem) }
-HTREEITEM CCList::FindContact(HANDLE hContact)
+HTREEITEM CCList::FindContact(MCONTACT hContact)
{
TVITEM tvi;
tvi.mask = TVIF_HANDLE | TVIF_PARAM;
diff --git a/plugins/!Deprecated/NewAwaySysMod/ContactList.h b/plugins/NewAwaySysMod/src/ContactList.h index 1730887954..8b9ce2f845 100644 --- a/plugins/!Deprecated/NewAwaySysMod/ContactList.h +++ b/plugins/NewAwaySysMod/src/ContactList.h @@ -33,10 +33,10 @@ typedef TREEITEMARRAY* PTREEITEMARRAY; class CCLItemData // internal CCList's class
{
public:
- CCLItemData(HANDLE hContact = INVALID_HANDLE_VALUE): hContact(hContact) {FillMemory(ExtraIcons, sizeof(ExtraIcons), CLC_EXTRAICON_EMPTY);};
+ CCLItemData(MCONTACT hContact = INVALID_CONTACT_ID): hContact(hContact) {FillMemory(ExtraIcons, sizeof(ExtraIcons), CLC_EXTRAICON_EMPTY);};
BYTE ExtraIcons[MAXEXTRAICONS];
- HANDLE hContact;
+ MCONTACT hContact;
LPARAM lParam;
};
@@ -49,7 +49,7 @@ public: CCList(HWND hTreeView);
~CCList();
- HTREEITEM AddContact(HANDLE hContact);
+ HTREEITEM AddContact(MCONTACT hContact);
HTREEITEM AddGroup(TCString GroupName);
HTREEITEM AddInfo(TCString Title, HTREEITEM hParent, HTREEITEM hInsertAfter, LPARAM lParam = NULL, HICON hIcon = NULL);
void SetInfoIcon(HTREEITEM hItem, HICON hIcon);
@@ -59,7 +59,7 @@ public: int GetItemType(HTREEITEM hItem); // returns a MCLCIT_ (see below)
HTREEITEM GetNextItem(DWORD Flags, HTREEITEM hItem);
void SortContacts();
- HANDLE GethContact(HTREEITEM hItem); // returns hContact, hGroup or hInfo
+ MCONTACT GethContact(HTREEITEM hItem); // returns hContact, hGroup or hInfo
HTREEITEM HitTest(LPPOINT pt, PDWORD hitFlags); // pt is relative to control; returns hItem or NULL
void EnsureVisible(HTREEITEM hItem) {TreeView_EnsureVisible(hTreeView, hItem); InvalidateRect(hTreeView, NULL, false);} // sometimes horizontal scrollbar position changes too, so we must redraw extra icons - that's why here is InvalidateRect. TODO: try to find a way to invalidate it on _every_ horizontal scrollbar position change, instead of just here - unfortunately the scrollbar doesn't notify the tree control of its position change through WM_HSCROLL in some cases
int SelectItem(HTREEITEM hItem) {return TreeView_SelectItem(hTreeView, hItem);}
@@ -76,7 +76,7 @@ private: int Array_SetItemState(HTREEITEM hItem, bool bSelected);
CCLItemData& GetItemData(HTREEITEM hItem);
HTREEITEM TreeView_GetLastChild(HWND hTreeView, HTREEITEM hItem);
- HTREEITEM FindContact(HANDLE hContact); // returns NULL if not found
+ HTREEITEM FindContact(MCONTACT hContact); // returns NULL if not found
void SelectGroups(HTREEITEM hCurItem, bool bSelected);
DWORD GetItemTypeAsCLGNFlag(HTREEITEM hItem); // returns MCLGN_CONTACT, MCLGN_GROUP or MCLGN_INFO
diff --git a/plugins/!Deprecated/NewAwaySysMod/MsgEventAdded.cpp b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp index 8f280898c9..6995a6c683 100644 --- a/plugins/!Deprecated/NewAwaySysMod/MsgEventAdded.cpp +++ b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp @@ -43,9 +43,9 @@ static struct class CAutoreplyData
{
public:
- CAutoreplyData(HANDLE hContact, TCString Reply): hContact(hContact), Reply(Reply) {}
+ CAutoreplyData(MCONTACT hContact, TCString Reply): hContact(hContact), Reply(Reply) {}
- HANDLE hContact;
+ MCONTACT hContact;
TCString Reply;
};
@@ -54,7 +54,7 @@ void __cdecl AutoreplyDelayThread(void *_ad) { // _ad must be allocated using "new CAutoreplyData()"
CAutoreplyData *ad = (CAutoreplyData*)_ad;
_ASSERT(ad && ad->hContact && ad->Reply.GetLen());
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ad->hContact, 0);
+ char *szProto = GetContactProto(ad->hContact);
if (!szProto)
{
_ASSERT(0);
@@ -63,7 +63,7 @@ void __cdecl AutoreplyDelayThread(void *_ad) int ReplyLen = (ad->Reply.GetLen() + 1) * (sizeof(char) + sizeof(WCHAR));
PBYTE pBuf = (PBYTE)malloc(ReplyLen);
- memcpy(pBuf, TCHAR2ANSI(ad->Reply), ad->Reply.GetLen() + 1);
+ memcpy(pBuf, _T2A(ad->Reply), ad->Reply.GetLen() + 1);
memcpy(pBuf + ad->Reply.GetLen() + 1, ad->Reply, (ad->Reply.GetLen() + 1) * sizeof(WCHAR));
CallContactService(ad->hContact, ServiceExists(CString(szProto) + PSS_MESSAGE "W") ? (PSS_MESSAGE "W") : PSS_MESSAGE, PREF_UNICODE, (LPARAM)pBuf);
@@ -80,33 +80,15 @@ void __cdecl AutoreplyDelayThread(void *_ad) dbeo.pBlob = pBuf;
SleepEx(1000, true); // delay before sending the reply, as we need it to be later than the message we're replying to (without this delay, srmm puts the messages in a wrong order)
- CallService(MS_DB_EVENT_ADD, (WPARAM)ad->hContact, (LPARAM)&dbeo);
+ db_event_add(ad->hContact, &dbeo);
}
free(pBuf);
-
-/*
- char *utf8Reply = mir_utf8encodeT(ad->Reply); // todo: use this instead of the code above, when 0.7 will be released
- if (g_AutoreplyOptPage.GetDBValueCopy(IDC_REPLYDLG_LOGREPLY))
- { // store in the history
- DBEVENTINFO dbeo = {0};
- dbeo.cbSize = sizeof(dbeo);
- dbeo.eventType = EVENTTYPE_MESSAGE;
- dbeo.flags = DBEF_SENT | DBEF_UTF;
- dbeo.szModule = szProto;
- dbeo.timestamp = time(NULL);
- dbeo.cbBlob = strlen(utf8Reply);
- dbeo.pBlob = utf8Reply;
- CallService(MS_DB_EVENT_ADD, (WPARAM)ad->hContact, (LPARAM)&dbeo);
- }
- CallContactService(ad->hContact, ServiceExists(CString(szProto) + PSS_MESSAGE "W") ? (PSS_MESSAGE "W") : PSS_MESSAGE, PREF_UTF, (LPARAM)utf8Reply);
- mir_free(utf8Reply);
-*/
delete ad;
}
-int IsSRMsgWindowOpen(HANDLE hContact, int DefaultRetVal)
+int IsSRMsgWindowOpen(MCONTACT hContact, int DefaultRetVal)
{
if (ServiceExists(MS_MSG_GETWINDOWDATA))
{
@@ -130,9 +112,9 @@ int IsSRMsgWindowOpen(HANDLE hContact, int DefaultRetVal) class CMetacontactEvent
{
public:
- CMetacontactEvent(HANDLE hMetaContact, DWORD timestamp, int bMsgWindowIsOpen): hMetaContact(hMetaContact), timestamp(timestamp), bMsgWindowIsOpen(bMsgWindowIsOpen) {};
+ CMetacontactEvent(MCONTACT hMetaContact, DWORD timestamp, int bMsgWindowIsOpen): hMetaContact(hMetaContact), timestamp(timestamp), bMsgWindowIsOpen(bMsgWindowIsOpen) {};
- HANDLE hMetaContact;
+ MCONTACT hMetaContact;
DWORD timestamp;
int bMsgWindowIsOpen;
};
@@ -140,37 +122,30 @@ public: TMyArray<CMetacontactEvent> MetacontactEvents;
-int MsgEventAdded(WPARAM wParam, LPARAM lParam)
+int MsgEventAdded(WPARAM hContact, LPARAM lParam)
{
- HANDLE hContact = (HANDLE)wParam;
DBEVENTINFO *dbei = (DBEVENTINFO*)lParam;
if (!hContact)
- {
return 0;
- }
+
if (dbei->flags & DBEF_SENT || (dbei->eventType != EVENTTYPE_MESSAGE && dbei->eventType != EVENTTYPE_URL && dbei->eventType != EVENTTYPE_FILE))
- {
return 0;
- }
- if (time(NULL) - dbei->timestamp > MAX_REPLY_TIMEDIFF)
- { // don't reply to offline messages
+
+ if (time(NULL) - dbei->timestamp > MAX_REPLY_TIMEDIFF) // don't reply to offline messages
return 0;
- }
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
+ char *szProto = GetContactProto(hContact);
if (!szProto)
- {
return 0;
- }
+
DWORD Flags1 = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
- if (!(Flags1 & PF1_IMSEND))
- { // don't reply to protocols that don't support outgoing messages
+ if (!(Flags1 & PF1_IMSEND)) // don't reply to protocols that don't support outgoing messages
return 0;
- }
+
int bMsgWindowIsOpen = MSGWNDOPEN_UNDEFINED;
- if (dbei->flags & DBEF_READ)
- {
- HANDLE hMetaContact;
- if (ServiceExists(MS_MC_GETMETACONTACT) && (hMetaContact = (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0))) // if it's a subcontact of a metacontact
+ if (dbei->flags & DBEF_READ) {
+ MCONTACT hMetaContact;
+ if (ServiceExists(MS_MC_GETMETACONTACT) && (hMetaContact = CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0))) // if it's a subcontact of a metacontact
{ // ugly workaround for metacontacts, part II
// remove outdated events first
DWORD CurTime = time(NULL);
@@ -234,16 +209,16 @@ int MsgEventAdded(WPARAM wParam, LPARAM lParam) AutoreplyOptData.DBToMem();
if (dbei->eventType == EVENTTYPE_MESSAGE)
{
- DBWriteContactSettingWord(hContact, MOD_NAME, DB_MESSAGECOUNT, DBGetContactSettingWord(hContact, MOD_NAME, DB_MESSAGECOUNT, 0) + 1); // increment message counter
+ db_set_w(hContact, MOD_NAME, DB_MESSAGECOUNT, db_get_w(hContact, MOD_NAME, DB_MESSAGECOUNT, 0) + 1); // increment message counter
}
if (AutoreplyOptData.GetValue(StatusModeList[I].DisableReplyCtlID))
{
return 0;
}
- HANDLE hContactForSettings = hContact; // used to take into account not-on-list contacts when getting contact settings, but at the same time allows to get correct contact info for contacts that are in the DB
- if (hContactForSettings != INVALID_HANDLE_VALUE && DBGetContactSettingByte(hContactForSettings, "CList", "NotOnList", 0))
+ MCONTACT hContactForSettings = hContact; // used to take into account not-on-list contacts when getting contact settings, but at the same time allows to get correct contact info for contacts that are in the DB
+ if (hContactForSettings != INVALID_CONTACT_ID && db_get_b(hContactForSettings, "CList", "NotOnList", 0))
{
- hContactForSettings = INVALID_HANDLE_VALUE; // INVALID_HANDLE_VALUE means the contact is not-on-list
+ hContactForSettings = INVALID_CONTACT_ID; // INVALID_HANDLE_VALUE means the contact is not-on-list
}
if (!CContactSettings(iMode, hContactForSettings).Autoreply.IncludingParents(szProto) || CContactSettings(iMode, hContactForSettings).Ignore)
{
@@ -251,7 +226,7 @@ int MsgEventAdded(WPARAM wParam, LPARAM lParam) }
if (AutoreplyOptData.GetValue(IDC_REPLYDLG_DONTREPLYINVISIBLE))
{
- WORD ApparentMode = DBGetContactSettingWord(hContact, szProto, "ApparentMode", 0);
+ WORD ApparentMode = db_get_w(hContact, szProto, "ApparentMode", 0);
if ((iMode == ID_STATUS_INVISIBLE && (!(Flags1 & PF1_INVISLIST) || ApparentMode != ID_STATUS_ONLINE)) ||
(Flags1 & PF1_VISLIST && ApparentMode == ID_STATUS_OFFLINE))
{
@@ -277,11 +252,11 @@ int MsgEventAdded(WPARAM wParam, LPARAM lParam) int UIN = 0;
if (IsAnICQProto(szProto))
{
- UIN = DBGetContactSettingDword(hContact, szProto, "UIN", 0);
+ UIN = db_get_dw(hContact, szProto, "UIN", 0);
}
int SendCount = AutoreplyOptData.GetValue(IDC_REPLYDLG_SENDCOUNT);
if ((AutoreplyOptData.GetValue(IDC_REPLYDLG_DONTSENDTOICQ) && UIN) || // an icq contact
- (SendCount != -1 && DBGetContactSettingByte(hContact, MOD_NAME, DB_SENDCOUNT, 0) >= SendCount))
+ (SendCount != -1 && db_get_b(hContact, MOD_NAME, DB_SENDCOUNT, 0) >= SendCount))
{
return 0;
}
@@ -289,7 +264,7 @@ int MsgEventAdded(WPARAM wParam, LPARAM lParam) {
return 0;
}
- DBWriteContactSettingByte(hContact, MOD_NAME, DB_SENDCOUNT, DBGetContactSettingByte(hContact, MOD_NAME, DB_SENDCOUNT, 0) + 1);
+ db_set_b(hContact, MOD_NAME, DB_SENDCOUNT, db_get_b(hContact, MOD_NAME, DB_SENDCOUNT, 0) + 1);
GetDynamicStatMsg(hContact); // it updates VarParseData.Message needed for %extratext% in the format
TCString Reply(*(TCString*)AutoreplyOptData.GetValue(IDC_REPLYDLG_PREFIX));
if (Reply != NULL && ServiceExists(MS_VARS_FORMATSTRING) && !g_SetAwayMsgPage.GetDBValueCopy(IDS_SAWAYMSG_DISABLEVARIABLES))
diff --git a/plugins/!Deprecated/NewAwaySysMod/MsgTree.cpp b/plugins/NewAwaySysMod/src/MsgTree.cpp index c04665d33f..e53ea75cfc 100644 --- a/plugins/!Deprecated/NewAwaySysMod/MsgTree.cpp +++ b/plugins/NewAwaySysMod/src/MsgTree.cpp @@ -554,7 +554,7 @@ CMsgTree::CMsgTree(HWND hTreeView): MsgTreePage(g_MsgTreePage), hTreeView(hTreeV MsgTreePage.SetWnd(GetParent(hTreeView));
COptItem_TreeCtrl* TreeCtrl = (COptItem_TreeCtrl*)MsgTreePage.Find(IDV_MSGTREE);
TreeCtrl->SetDlgItemID(GetDlgCtrlID(hTreeView));
- hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 5, 2);
+ hImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 5, 2);
ImageList_AddIcon(hImageList, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_NEWMESSAGE)));
ImageList_AddIcon(hImageList, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_NEWCATEGORY)));
ImageList_AddIcon(hImageList, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DELETE)));
diff --git a/plugins/!Deprecated/NewAwaySysMod/MsgTree.h b/plugins/NewAwaySysMod/src/MsgTree.h index 98b2f9d6cc..98b2f9d6cc 100644 --- a/plugins/!Deprecated/NewAwaySysMod/MsgTree.h +++ b/plugins/NewAwaySysMod/src/MsgTree.h diff --git a/plugins/!Deprecated/NewAwaySysMod/Notification.cpp b/plugins/NewAwaySysMod/src/Notification.cpp index 389b17eae3..03ca926f94 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Notification.cpp +++ b/plugins/NewAwaySysMod/src/Notification.cpp @@ -24,22 +24,18 @@ void ShowMsg(TCHAR *FirstLine, TCHAR *SecondLine, bool IsErrorMsg, int Timeout)
{
- if (ServiceExists(MS_POPUP_ADDPOPUPEX))
+ if (ServiceExists(MS_POPUP_ADDPOPUPT))
{
POPUPDATAT ppd = {0};
ppd.lchIcon = LoadIcon(NULL, IsErrorMsg ? IDI_EXCLAMATION : IDI_INFORMATION);
-// lstrcpy(ppd.lpzContactName, FirstLine);
-// lstrcpy(ppd.lpzText, SecondLine);
lstrcpy(ppd.lptzContactName, FirstLine);
lstrcpy(ppd.lptzText, SecondLine);
ppd.colorBack = IsErrorMsg ? 0x0202E3 : 0xE8F1FD;
ppd.colorText = IsErrorMsg ? 0xE8F1FD : 0x000000;
ppd.iSeconds = Timeout;
CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&ppd, 0);
- } else
- {
- MessageBox(NULL, SecondLine, FirstLine, MB_OK | (IsErrorMsg ? MB_ICONEXCLAMATION : MB_ICONINFORMATION));
}
+ else MessageBox(NULL, SecondLine, FirstLine, MB_OK | (IsErrorMsg ? MB_ICONEXCLAMATION : MB_ICONINFORMATION));
}
@@ -78,7 +74,7 @@ static VOID CALLBACK ShowContactMenu(DWORD wParam) /*
void Popup_DoAction(HWND hWnd, BYTE Action, PLUGIN_DATA *pdata)
{
- HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0);
+ MCONTACT hContact = (HANDLE)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0);
switch (Action)
{
case PCA_OPENMESSAGEWND: // open message window
@@ -181,7 +177,7 @@ static int CALLBACK ReqNotifyPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam }
-int ShowPopupNotification(COptPage &PopupNotifyData, HANDLE hContact, int iStatusMode)
+int ShowPopupNotification(COptPage &PopupNotifyData, MCONTACT hContact, int iStatusMode)
{ // returns TRUE if popup was shown
// we take szProto, UIN and Message from VarParseData
POPUPDATAT ppd = {0};
@@ -189,8 +185,8 @@ int ShowPopupNotification(COptPage &PopupNotifyData, HANDLE hContact, int iStatu TCString ExtraText;
if (!iStatusMode)
{ // if it's an xstatus message request
- ExtraText = DBGetContactSettingString(NULL, VarParseData.szProto, "XStatusName", _T(""));
- TCString XMsg(DBGetContactSettingString(NULL, VarParseData.szProto, "XStatusMsg", _T("")));
+ ExtraText = db_get_s(NULL, VarParseData.szProto, "XStatusName", _T(""));
+ TCString XMsg(db_get_s(NULL, VarParseData.szProto, "XStatusMsg", _T("")));
if (XMsg.GetLen())
{
if (ExtraText.GetLen())
diff --git a/plugins/NewAwaySysMod/src/Options.cpp b/plugins/NewAwaySysMod/src/Options.cpp new file mode 100644 index 0000000000..e0d585d991 --- /dev/null +++ b/plugins/NewAwaySysMod/src/Options.cpp @@ -0,0 +1,963 @@ +/*
+ Options.cpp
+ Copyright (c) 2005-2008 Chervov Dmitry
+
+ 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 "Options.h"
+
+static CString sEmptyString("");
+
+
+COptPage::COptPage(const COptPage &Item)
+{
+ *this = Item;
+}
+
+COptPage::~COptPage()
+{
+ int I;
+ for (I = 0; I < Items.GetSize(); I++)
+ {
+ delete Items[I];
+ }
+ Items.RemoveAll();
+}
+
+void COptPage::MemToPage(int OnlyEnable)
+{
+ int I;
+ _ASSERT(hWnd);
+ for (I = 0; I < Items.GetSize(); I++)
+ {
+ if (OnlyEnable)
+ {
+ Items[I]->COptItem::MemToWnd(hWnd);
+ } else
+ {
+ Items[I]->MemToWnd(hWnd);
+ }
+ }
+}
+
+void COptPage::PageToMem()
+{
+ int I;
+ _ASSERT(hWnd);
+ for (I = 0; I < Items.GetSize(); I++)
+ {
+ Items[I]->WndToMem(hWnd);
+ }
+}
+
+void COptPage::DBToMem()
+{
+ int I;
+ _ASSERT(sModule != "");
+ for (I = 0; I < Items.GetSize(); I++)
+ {
+ Items[I]->DBToMem(sModule, &sDBSettingPrefix);
+ }
+}
+
+void COptPage::MemToDB()
+{
+ int I;
+ _ASSERT(sModule != "");
+ for (I = 0; I < Items.GetSize(); I++)
+ {
+ Items[I]->MemToDB(sModule, &sDBSettingPrefix);
+ }
+}
+
+void COptPage::CleanDBSettings()
+{
+ int I;
+ _ASSERT(sModule != "");
+ for (I = 0; I < Items.GetSize(); I++)
+ {
+ Items[I]->CleanDBSettings(sModule, &sDBSettingPrefix);
+ }
+}
+
+bool COptPage::GetModified()
+{
+ int I;
+ _ASSERT(sModule != "");
+ for (I = 0; I < Items.GetSize(); I++)
+ {
+ if (Items[I]->GetModified())
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+void COptPage::SetModified(bool Modified)
+{
+ int I;
+ _ASSERT(sModule != "");
+ for (I = 0; I < Items.GetSize(); I++)
+ {
+ Items[I]->SetModified(Modified);
+ }
+}
+
+COptItem *COptPage::Find(int DlgItemID)
+{
+ int I;
+ for (I = 0; I < Items.GetSize(); I++)
+ {
+ if (Items[I]->GetID() == DlgItemID)
+ {
+ return Items[I];
+ }
+ }
+ _ASSERT(0);
+ return 0;
+}
+
+COptPage& COptPage::operator = (const COptPage& Page)
+{
+ int I;
+ hWnd = Page.hWnd;
+ sModule = Page.sModule;
+ sDBSettingPrefix = Page.sDBSettingPrefix;
+ Items.RemoveAll();
+ for (I = 0; I < Page.Items.GetSize(); I++)
+ {
+ Items.AddElem(Page.Items[I]->Copy());
+ }
+ return *this;
+}
+
+
+int COptItem::GetIntDBVal(CString &sModule, int bSigned, CString *sDBSettingPrefix)
+{ // default procedure for reading value from DB; used only for integral types
+ if (sDBSetting != NULL)
+ {
+ _ASSERT(nValueSize == DBVT_BYTE || nValueSize == DBVT_WORD || nValueSize == DBVT_DWORD);
+ DBVARIANT dbv;
+ if (db_get(NULL, sModule, sDBSetting, &dbv))
+ return GetDefValue();
+
+ return (nValueSize == DBVT_BYTE) ? (bSigned ? (signed char)dbv.bVal : (unsigned char)dbv.bVal) : ((nValueSize == DBVT_WORD) ? (bSigned ? (signed short)dbv.wVal : (unsigned short)dbv.wVal) : dbv.dVal);
+ }
+ return GetDefValue();
+}
+
+void COptItem::SetIntDBVal(CString &sModule, int Value, CString *sDBSettingPrefix)
+{ // default procedure for writing value to the DB; used only for integral types
+ if (sDBSetting != NULL && !ReadOnly)
+ {
+ _ASSERT(nValueSize == DBVT_BYTE || nValueSize == DBVT_WORD || nValueSize == DBVT_DWORD);
+
+ DBVARIANT dbv;
+ dbv.type = nValueSize;
+ dbv.dVal = Value;
+ db_set(NULL, sModule, sDBSetting, &dbv);
+ }
+}
+
+TCString COptItem::GetStrDBVal(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (sDBSetting != NULL)
+ {
+ _ASSERT(GetDefValue());
+ return db_get_s(NULL, sModule, sDBSettingPrefix ? (*sDBSettingPrefix + sDBSetting) : sDBSetting, *(TCString*)GetDefValue());
+ }
+ return *(TCString*)GetDefValue();
+}
+
+void COptItem::SetStrDBVal(CString &sModule, TCString &Str, CString *sDBSettingPrefix)
+{
+ if (sDBSetting != NULL && !ReadOnly)
+ {
+ db_set_ts(NULL, sModule, sDBSettingPrefix ? (*sDBSettingPrefix + sDBSetting) : sDBSetting, Str);
+ }
+}
+
+
+
+void COptItem_Checkbox::DBToMem(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (ValueMask)
+ {
+ Value = (GetIntDBVal(sModule, false, sDBSettingPrefix) & ValueMask) ? BST_CHECKED : BST_UNCHECKED;
+ } else
+ {
+ Value = GetIntDBVal(sModule, false, sDBSettingPrefix);
+ }
+ COptItem::DBToMem(sModule, sDBSettingPrefix);
+}
+
+void COptItem_Checkbox::MemToDB(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (ValueMask)
+ {
+ if (Value == BST_CHECKED)
+ {
+ SetIntDBVal(sModule, GetIntDBVal(sModule, false, sDBSettingPrefix) | ValueMask, sDBSettingPrefix);
+ } else
+ {
+ SetIntDBVal(sModule, GetIntDBVal(sModule, false, sDBSettingPrefix) & ~ValueMask, sDBSettingPrefix);
+ }
+ } else
+ {
+ SetIntDBVal(sModule, Value, sDBSettingPrefix);
+ }
+ COptItem::MemToDB(sModule, sDBSettingPrefix);
+}
+
+void COptItem_Checkbox::WndToMem(HWND hWnd)
+{
+ Value = IsDlgButtonChecked(hWnd, DlgItemID);
+// tri-state checkboxes in combination with ValueMask != 0 are not supported ;)
+ _ASSERT(!ValueMask || Value != BST_INDETERMINATE);
+ COptItem::WndToMem(hWnd);
+}
+
+void COptItem_Checkbox::MemToWnd(HWND hWnd)
+{
+ CheckDlgButton(hWnd, DlgItemID, Value);
+ COptItem::MemToWnd(hWnd);
+}
+
+
+
+void COptItem_BitDBSetting::DBToMem(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (ValueMask)
+ {
+ Value = (GetIntDBVal(sModule, false, sDBSettingPrefix) & ValueMask) != 0;
+ } else
+ {
+ Value = GetIntDBVal(sModule, false, sDBSettingPrefix);
+ }
+ COptItem::DBToMem(sModule, sDBSettingPrefix);
+}
+
+void COptItem_BitDBSetting::MemToDB(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (ValueMask)
+ {
+ if (Value)
+ {
+ SetIntDBVal(sModule, GetIntDBVal(sModule, false, sDBSettingPrefix) | ValueMask, sDBSettingPrefix);
+ } else
+ {
+ SetIntDBVal(sModule, GetIntDBVal(sModule, false, sDBSettingPrefix) & ~ValueMask, sDBSettingPrefix);
+ }
+ } else
+ {
+ SetIntDBVal(sModule, Value, sDBSettingPrefix);
+ }
+ COptItem::MemToDB(sModule, sDBSettingPrefix);
+}
+
+
+// ================================================ COptItem_TreeCtrl ================================================
+
+int COptItem_TreeCtrl::IDToOrder(int ID)
+{
+ int I;
+ for (I = 0; I < RootItems.GetSize(); I++)
+ {
+ if (RootItems[I].ID == ID)
+ {
+ return ROOT_INDEX_TO_ORDER(I);
+ }
+ }
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ if (Value[I].ID == ID)
+ {
+ return I;
+ }
+ }
+ return -1;
+}
+
+int COptItem_TreeCtrl::hItemToOrder(HTREEITEM hItem)
+{
+ int I;
+ for (I = 0; I < RootItems.GetSize(); I++)
+ {
+ if (RootItems[I].hItem == hItem)
+ {
+ return ROOT_INDEX_TO_ORDER(I);
+ }
+ }
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ if (Value[I].hItem == hItem)
+ {
+ return I;
+ }
+ }
+ return -1;
+}
+
+int COptItem_TreeCtrl::GenerateID()
+{
+ int ID = 0;
+ while (IDToOrder(ID) != -1)
+ {
+ ID++;
+ }
+ return ID;
+}
+
+typedef struct
+{
+ COptItem_TreeCtrl *TreeCtrl;
+ CString *sModule;
+ CString *sDBSettingPrefix;
+} sTreeReadEnumData;
+
+int TreeReadEnum(const char *szSetting, LPARAM lParam)
+{
+ sTreeReadEnumData *TreeReadEnumData = (sTreeReadEnumData*)lParam;
+ int Len = TreeReadEnumData->TreeCtrl->sDBSetting.GetLen() + lengthof(TREEITEM_DBSTR_TITLE) - 1;
+ if (!strncmp(szSetting, TreeReadEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_TITLE, Len) && isdigit(szSetting[Len]))
+ {
+ int ID = atol(szSetting + Len);
+ short ParentID = (TreeReadEnumData->TreeCtrl->TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL) ? 0 : db_get_w(NULL, *TreeReadEnumData->sModule,
+ *TreeReadEnumData->sDBSettingPrefix + TreeReadEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_PARENT + (szSetting + Len), -1);
+ short Order = db_get_w(NULL, *TreeReadEnumData->sModule,
+ *TreeReadEnumData->sDBSettingPrefix + TreeReadEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_ORDER + (szSetting + Len), -1);
+ char Flags = (TreeReadEnumData->TreeCtrl->TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL && !(TreeReadEnumData->TreeCtrl->TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES)) ? 0 : db_get_b(NULL, *TreeReadEnumData->sModule,
+ *TreeReadEnumData->sDBSettingPrefix + TreeReadEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_FLAGS + (szSetting + Len), 0);
+ if (ParentID >= 0 && Order >= 0)
+ {
+ TreeReadEnumData->TreeCtrl->Value.SetAtGrow(Order).ID = ID;
+ TreeReadEnumData->TreeCtrl->Value.SetAtGrow(Order).ParentID = ParentID;
+ TreeReadEnumData->TreeCtrl->Value.SetAtGrow(Order).Flags = Flags;
+ TreeReadEnumData->TreeCtrl->Value.SetAtGrow(Order).hItem = NULL;
+ TreeReadEnumData->TreeCtrl->Value.SetAtGrow(Order).Title = db_get_s(NULL, *TreeReadEnumData->sModule, *TreeReadEnumData->sDBSettingPrefix + szSetting, _T(""));
+ TreeReadEnumData->TreeCtrl->Value.SetAtGrow(Order).User_Str1 = (TreeReadEnumData->TreeCtrl->User_Str1_DBName == NULL) ? NULL :
+ db_get_s(NULL, *TreeReadEnumData->sModule,
+ *TreeReadEnumData->sDBSettingPrefix + TreeReadEnumData->TreeCtrl->sDBSetting + TreeReadEnumData->TreeCtrl->User_Str1_DBName + (szSetting + Len), (TCHAR*)NULL);
+ }
+ }
+ return 0;
+}
+
+void COptItem_TreeCtrl::DBToMem(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (!sDBSettingPrefix)
+ {
+ sDBSettingPrefix = &sEmptyString;
+ }
+ Value.RemoveAll();
+ sTreeReadEnumData TreeReadEnumData;
+ TreeReadEnumData.TreeCtrl = this;
+ TreeReadEnumData.sModule = &sModule;
+ TreeReadEnumData.sDBSettingPrefix = sDBSettingPrefix;
+ DBCONTACTENUMSETTINGS dbEnum;
+ dbEnum.lParam = (LPARAM)&TreeReadEnumData;
+ dbEnum.ofsSettings = 0;
+ dbEnum.pfnEnumProc = TreeReadEnum;
+ dbEnum.szModule = sModule;
+ CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ if (!Value.GetSize())
+ {
+ Value = DefValue;
+ } else
+ {
+ int I;
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ if (Value[I].Title == NULL)
+ {
+ Value.RemoveElem(I);
+ I--;
+ }
+ }
+ }
+ COptItem::DBToMem(sModule, sDBSettingPrefix);
+}
+
+void COptItem_TreeCtrl::MemToDB(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (!ReadOnly && Modified)
+ {
+ if (!sDBSettingPrefix)
+ {
+ sDBSettingPrefix = &sEmptyString;
+ }
+ CleanDBSettings(sModule, sDBSettingPrefix);
+ int I;
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ CString StrID;
+ _itoa(Value[I].ID, StrID.GetBuffer(64), 10);
+ StrID.ReleaseBuffer();
+ db_set_ts(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_TITLE + StrID, Value[I].Title);
+ if (!(TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL))
+ db_set_w(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_PARENT + StrID, Value[I].ParentID);
+
+ db_set_w(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_ORDER + StrID, I);
+ if (!(TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL) || TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES)
+ db_set_b(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_FLAGS + StrID, Value[I].Flags);
+
+ if (User_Str1_DBName != NULL && Value[I].User_Str1 != NULL)
+ db_set_ts(NULL, sModule, *sDBSettingPrefix + sDBSetting + User_Str1_DBName + StrID, Value[I].User_Str1);
+ }
+ COptItem::MemToDB(sModule, sDBSettingPrefix);
+ }
+}
+
+void COptItem_TreeCtrl::WndToMem(HWND hWnd)
+{ // only need to gather info of items state (expanded/collapsed, checked/unchecked)
+ HWND hTreeView = GetDlgItem(hWnd, DlgItemID);
+ int I;
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ DWORD State = TreeView_GetItemState(hTreeView, Value[I].hItem, TVIS_EXPANDED | TVIS_STATEIMAGEMASK);
+ int OldFlags = Value[I].Flags;
+ if (State & TVIS_EXPANDED)
+ {
+ Value[I].Flags |= TIF_EXPANDED;
+ } else
+ {
+ Value[I].Flags &= ~TIF_EXPANDED;
+ }
+ if (TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES && (State >> 12) - 1)
+ {
+ Value[I].Flags |= TIF_ENABLED;
+ } else
+ {
+ Value[I].Flags &= ~TIF_ENABLED;
+ }
+ if (Value[I].Flags != OldFlags)
+ {
+ Modified = true;
+ }
+ }
+ COptItem::WndToMem(hWnd);
+}
+
+void COptItem_TreeCtrl::MemToWnd(HWND hWnd)
+{
+ HWND hTreeView = GetDlgItem(hWnd, DlgItemID);
+ if (TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES)
+ { // have to set this in run-time as it's specified in MSDN
+ LONG Style = GetWindowLongPtr(hTreeView, GWL_STYLE);
+ SetWindowLongPtr(hTreeView, GWL_STYLE, Style & ~TVS_CHECKBOXES);
+ SetWindowLongPtr(hTreeView, GWL_STYLE, Style | TVS_CHECKBOXES);
+ }
+ TVINSERTSTRUCT tvIn = {0};
+ int ScrollPos = GetScrollPos(hTreeView, SB_VERT);
+ int SelectOrder = IDToOrder(GetSelectedItemID(hWnd));
+ SendMessage(hTreeView, WM_SETREDRAW, false, 0);
+ TreeView_DeleteAllItems(hTreeView);
+ _ASSERT(RootItems.GetSize());
+ int I;
+ if (!(TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL))
+ {
+ for (I = 0; I < RootItems.GetSize(); I++)
+ {
+ tvIn.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
+ RootItems[I].Flags |= TIF_GROUP;
+ tvIn.item.state = tvIn.item.stateMask = TVIS_BOLD | ((RootItems[I].Flags & TIF_EXPANDED) ? TVIS_EXPANDED : 0);
+ tvIn.item.pszText = RootItems[I].Title;
+ tvIn.hParent = TVI_ROOT;
+ tvIn.hInsertAfter = TVI_LAST;
+ tvIn.item.lParam = RootItems[I].ID;
+ RootItems[I].hItem = TreeView_InsertItem(hTreeView, &tvIn);
+ }
+ }
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ Value[I].hItem = RootItems[0].hItem; // put an item to first group in case of some strange error
+ }
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ tvIn.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
+ tvIn.item.state = tvIn.item.stateMask = (Value[I].Flags & TIF_GROUP) ? (TVIS_BOLD | ((Value[I].Flags & TIF_EXPANDED) ? TVIS_EXPANDED : 0)) : 0;
+ if (TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES)
+ {
+ tvIn.item.stateMask |= TVIS_STATEIMAGEMASK;
+ tvIn.item.state |= INDEXTOSTATEIMAGEMASK((Value[I].Flags & TIF_ENABLED) ? 2 : 1);
+ }
+ tvIn.item.pszText = Value[I].Title;
+ int Order = IDToOrder(Value[I].ParentID);
+ if (Order != -1)
+ {
+ tvIn.hParent = (Order <= TREECTRL_ROOTORDEROFFS) ? RootItems[ROOT_ORDER_TO_INDEX(Order)].hItem : Value[Order].hItem;
+ tvIn.hInsertAfter = TVI_LAST;
+ tvIn.item.lParam = Value[I].ID;
+ Value[I].hItem = TreeView_InsertItem(hTreeView, &tvIn);
+ } else
+ { // found an orphan item; probably it's better just to delete it
+ Value.RemoveElem(I);
+ I--;
+ }
+ }
+ TreeView_SelectItem(hTreeView, (SelectOrder >= 0) ? Value[SelectOrder].hItem : ((SelectOrder <= TREECTRL_ROOTORDEROFFS) ? RootItems[ROOT_ORDER_TO_INDEX(SelectOrder)].hItem : NULL));
+ SendMessage(hTreeView, WM_SETREDRAW, true, 0);
+ SCROLLBARINFO sbi;
+ sbi.cbSize = sizeof(sbi);
+ GetScrollBarInfo(hTreeView, OBJID_VSCROLL, &sbi);
+ if (!(sbi.rgstate[0] & STATE_SYSTEM_INVISIBLE))
+ {
+ int MinPos, MaxPos;
+ GetScrollRange(hTreeView, SB_VERT, &MinPos, &MaxPos);
+ if (ScrollPos < MinPos)
+ {
+ ScrollPos = MinPos;
+ } else if (ScrollPos > MaxPos)
+ {
+ ScrollPos = MaxPos;
+ }
+ SetScrollPos(hTreeView, SB_VERT, ScrollPos, true);
+ }
+ COptItem::MemToWnd(hWnd);
+}
+
+
+typedef struct
+{
+ TMyArray<CString> TreeSettings;
+ COptItem_TreeCtrl *TreeCtrl;
+ CString *sDBSettingPrefix;
+} sTreeDeleteEnumData;
+
+int TreeDeleteEnum(const char *szSetting, LPARAM lParam)
+{
+ sTreeDeleteEnumData *TreeDeleteEnumData = (sTreeDeleteEnumData*)lParam;
+ CString CurSetting;
+ CurSetting = *TreeDeleteEnumData->sDBSettingPrefix + TreeDeleteEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_TITLE;
+ if (!strncmp(szSetting, CurSetting, CurSetting.GetLen()))
+ {
+ TreeDeleteEnumData->TreeSettings.AddElem(szSetting);
+ }
+ CurSetting = *TreeDeleteEnumData->sDBSettingPrefix + TreeDeleteEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_PARENT;
+ if (!strncmp(szSetting, CurSetting, CurSetting.GetLen()))
+ {
+ TreeDeleteEnumData->TreeSettings.AddElem(szSetting);
+ }
+ CurSetting = *TreeDeleteEnumData->sDBSettingPrefix + TreeDeleteEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_ORDER;
+ if (!strncmp(szSetting, CurSetting, CurSetting.GetLen()))
+ {
+ TreeDeleteEnumData->TreeSettings.AddElem(szSetting);
+ }
+ CurSetting = *TreeDeleteEnumData->sDBSettingPrefix + TreeDeleteEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_FLAGS;
+ if (!strncmp(szSetting, CurSetting, CurSetting.GetLen()))
+ {
+ TreeDeleteEnumData->TreeSettings.AddElem(szSetting);
+ }
+ if (TreeDeleteEnumData->TreeCtrl->User_Str1_DBName != NULL)
+ {
+ CurSetting = *TreeDeleteEnumData->sDBSettingPrefix + TreeDeleteEnumData->TreeCtrl->sDBSetting + TreeDeleteEnumData->TreeCtrl->User_Str1_DBName;
+ if (!strncmp(szSetting, CurSetting, CurSetting.GetLen()))
+ {
+ TreeDeleteEnumData->TreeSettings.AddElem(szSetting);
+ }
+ }
+ return 0;
+}
+
+void COptItem_TreeCtrl::CleanDBSettings(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (!sDBSettingPrefix)
+ {
+ sDBSettingPrefix = &sEmptyString;
+ }
+ sTreeDeleteEnumData TreeDeleteEnumData;
+ TreeDeleteEnumData.TreeCtrl = this;
+ TreeDeleteEnumData.sDBSettingPrefix = sDBSettingPrefix;
+ DBCONTACTENUMSETTINGS dbEnum;
+ dbEnum.lParam = (LPARAM)&TreeDeleteEnumData;
+ dbEnum.ofsSettings = 0;
+ dbEnum.pfnEnumProc = TreeDeleteEnum;
+ dbEnum.szModule = sModule;
+ CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ int I;
+ for (I = 0; I < TreeDeleteEnumData.TreeSettings.GetSize(); I++)
+ {
+ db_unset(NULL, sModule, TreeDeleteEnumData.TreeSettings[I]);
+ }
+}
+
+
+int COptItem_TreeCtrl::GetSelectedItemID(HWND hWnd)
+{
+ HWND hTreeView = GetDlgItem(hWnd, DlgItemID);
+ TVITEM tvi = {0};
+ tvi.hItem = TreeView_GetSelection(hTreeView);
+ if (!tvi.hItem)
+ {
+ return -1;
+ }
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ TreeView_GetItem(hTreeView, &tvi);
+ return tvi.lParam;
+}
+
+void COptItem_TreeCtrl::Delete(HWND hWnd, int ID)
+{
+ int SelectedOrder = IDToOrder(ID);
+ _ASSERT(SelectedOrder >= 0);
+ RecursiveDelete(hWnd, SelectedOrder);
+ Modified = true;
+}
+
+void COptItem_TreeCtrl::RecursiveDelete(HWND hWnd, int I)
+{
+ if (Value[I].Flags & TIF_GROUP)
+ {
+ int J;
+ for (J = I + 1; J < Value.GetSize(); J++)
+ {
+ if (Value[J].ParentID == Value[I].ID)
+ {
+ RecursiveDelete(hWnd, J--);
+ }
+ }
+ }
+ HWND hTreeView = GetDlgItem(hWnd, DlgItemID);
+ TreeView_DeleteItem(hTreeView, Value[I].hItem);
+ Value.RemoveElem(I);
+}
+
+CTreeItem* COptItem_TreeCtrl::InsertItem(HWND hWnd, CTreeItem &Item)
+// Item's ID and ParentID are not used (the new item position is determined by current selection in the tree)
+// returns a pointer to the newly inserted item info
+{
+ _ASSERT(!(TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL) || !(Item.Flags & TIF_GROUP));
+ HWND hTreeView = GetDlgItem(hWnd, DlgItemID);
+ TVITEM tvi;
+ int SelOrder = -1;
+ Item.ParentID = RootItems[0].ID;
+ TVINSERTSTRUCT tvIn = {0};
+ tvIn.hParent = RootItems[0].hItem;
+ tvIn.hInsertAfter = TVI_FIRST;
+ if (tvi.hItem = TreeView_GetSelection(hTreeView))
+ {
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ TreeView_GetItem(hTreeView, &tvi);
+ SelOrder = IDToOrder(tvi.lParam);
+ if (SelOrder <= TREECTRL_ROOTORDEROFFS)
+ {
+ Item.ParentID = RootItems[ROOT_ORDER_TO_INDEX(SelOrder)].ID;
+ tvIn.hParent = RootItems[ROOT_ORDER_TO_INDEX(SelOrder)].hItem;
+ SelOrder = -1;
+ } else
+ {
+ if (Value[SelOrder].Flags & TIF_GROUP)
+ {
+ Item.ParentID = Value[SelOrder].ID;
+ tvIn.hParent = Value[SelOrder].hItem;
+ } else
+ {
+ Item.ParentID = Value[SelOrder].ParentID;
+ int Order = IDToOrder(Value[SelOrder].ParentID);
+ tvIn.hParent = (Order <= TREECTRL_ROOTORDEROFFS) ? RootItems[ROOT_ORDER_TO_INDEX(Order)].hItem : Value[Order].hItem;
+ tvIn.hInsertAfter = Value[SelOrder].hItem;
+ }
+ }
+ }
+ tvIn.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
+ tvIn.item.state = tvIn.item.stateMask = (Item.Flags & TIF_GROUP) ? (TVIS_BOLD |
+ ((Item.Flags & TIF_EXPANDED) ? TVIS_EXPANDED : 0)) : 0;
+ if (TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES)
+ {
+ tvIn.item.stateMask |= TVIS_STATEIMAGEMASK;
+ tvIn.item.state |= INDEXTOSTATEIMAGEMASK((Item.Flags & TIF_ENABLED) ? 2 : 1);
+ }
+ tvIn.item.pszText = Item.Title;
+ tvIn.item.lParam = Item.ID = GenerateID();
+ Value.InsertElem(Item, SelOrder + 1);
+ Value[SelOrder + 1].hItem = TreeView_InsertItem(hTreeView, &tvIn);
+ TreeView_SelectItem(hTreeView, Value[SelOrder + 1].hItem);
+ Modified = true;
+ return &Value[SelOrder + 1];
+}
+
+int COptItem_TreeCtrl::RecursiveMove(int ItemOrder, int ParentID, int InsertAtOrder)
+// ItemOrder must be a movable item (i.e. ItemOrder >= 0)
+// InsertAtOrder must be >= 0 too.
+{
+ int ItemsMoved = 1;
+ Value.MoveElem(ItemOrder, InsertAtOrder);
+ Value[InsertAtOrder].ParentID = ParentID;
+ if (Value[InsertAtOrder].Flags & TIF_GROUP) // need to ensure that no items were left before their group by an order.
+ {
+ int GroupID = Value[InsertAtOrder].ID;
+ int I;
+ for (I = ItemOrder; I < InsertAtOrder; I++) // if ItemOrder > InsertAtOrder then there is simply nothing to do
+ {
+ if (Value[I].ParentID == GroupID)
+ {
+ int CurrentItemsMoved = RecursiveMove(I, GroupID, InsertAtOrder);
+ ItemsMoved += CurrentItemsMoved;
+ InsertAtOrder -= CurrentItemsMoved;
+ I--;
+ }
+ }
+ }
+ return ItemsMoved;
+}
+
+void COptItem_TreeCtrl::MoveItem(HWND hWnd, HTREEITEM hItem, HTREEITEM hMoveTo)
+{ // hMoveTo can be NULL and it means that we must move hItem to the beginning of the list
+ _ASSERT(hItem && (hMoveTo || TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL));
+ if (hItem == hMoveTo)
+ {
+ return;
+ }
+ HWND hTreeView = GetDlgItem(hWnd, DlgItemID);
+ TVITEM tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
+ tvi.hItem = hItem;
+ TreeView_GetItem(hTreeView, &tvi);
+ int ItemOrder = IDToOrder(tvi.lParam);
+ _ASSERT(ItemOrder != -1);
+ int MoveToOrder;
+ if (hMoveTo)
+ {
+ tvi.hItem = hMoveTo;
+ TreeView_GetItem(hTreeView, &tvi);
+ MoveToOrder = IDToOrder(tvi.lParam);
+ _ASSERT(MoveToOrder != -1);
+ } else
+ {
+ MoveToOrder = -1;
+ }
+ if (ItemOrder <= TREECTRL_ROOTORDEROFFS)
+ {
+ return; // can't move root items
+ }
+ if (Value[ItemOrder].Flags & TIF_GROUP)
+ { // need to check for a case when trying to move a group to its own subgroup.
+ int Order = MoveToOrder;
+ while (Order >= 0)
+ {
+ Order = IDToOrder(Value[Order].ParentID);
+ if (Order == ItemOrder)
+ {
+ return;
+ }
+ }
+ }
+// well, everything is ok, we really can move that item.
+ WndToMem(hWnd); // save groups state (expanded/collapsed)
+ if (MoveToOrder != -1 && ((MoveToOrder <= TREECTRL_ROOTORDEROFFS) ? RootItems[ROOT_ORDER_TO_INDEX(MoveToOrder)].Flags : Value[MoveToOrder].Flags) & TIF_GROUP)
+ { // if the destination is a group, then move the item to that group
+ RecursiveMove(ItemOrder, (MoveToOrder <= TREECTRL_ROOTORDEROFFS) ? RootItems[ROOT_ORDER_TO_INDEX(MoveToOrder)].ID : Value[MoveToOrder].ID, (MoveToOrder >= 0) ? ((ItemOrder < MoveToOrder) ? MoveToOrder : (MoveToOrder + 1)) : 0);
+ } else
+ { // else place the item after the destination item
+ RecursiveMove(ItemOrder, (MoveToOrder == -1) ? 0 : Value[MoveToOrder].ParentID, (ItemOrder < MoveToOrder) ? MoveToOrder : (MoveToOrder + 1)); // when TREECTRL_FLAG_IS_SINGLE_LEVEL, we always have a root item with ID = 0.
+ }
+ MemToWnd(hWnd); // update the tree
+ Modified = true;
+}
+
+
+// ================================================ COptItem_ListCtrl ================================================
+
+typedef struct
+{
+ COptItem_ListCtrl *ListCtrl;
+ CString *sModule;
+ CString *sDBSettingPrefix;
+} sListReadEnumData;
+
+int ListReadEnum(const char *szSetting, LPARAM lParam)
+{
+ sListReadEnumData *ListReadEnumData = (sListReadEnumData*)lParam;
+ int Len = ListReadEnumData->sDBSettingPrefix->GetLen() + ListReadEnumData->ListCtrl->sDBSetting.GetLen() + lengthof(LISTITEM_DBSTR_TEXT) - 1;
+ if (!strncmp(szSetting, *ListReadEnumData->sDBSettingPrefix + ListReadEnumData->ListCtrl->sDBSetting + LISTITEM_DBSTR_TEXT, Len) && isdigit(szSetting[Len]))
+ {
+ int ID = atol(szSetting + Len);
+ ListReadEnumData->ListCtrl->Value.SetAtGrow(ID).Text = db_get_s(NULL, *ListReadEnumData->sModule, *ListReadEnumData->sDBSettingPrefix + szSetting, _T(""));
+ }
+ return 0;
+}
+
+void COptItem_ListCtrl::DBToMem(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (!sDBSettingPrefix)
+ {
+ sDBSettingPrefix = &sEmptyString;
+ }
+ Value.RemoveAll();
+ sListReadEnumData ListReadEnumData;
+ ListReadEnumData.ListCtrl = this;
+ ListReadEnumData.sModule = &sModule;
+ ListReadEnumData.sDBSettingPrefix = sDBSettingPrefix;
+ DBCONTACTENUMSETTINGS dbEnum;
+ dbEnum.lParam = (LPARAM)&ListReadEnumData;
+ dbEnum.ofsSettings = 0;
+ dbEnum.pfnEnumProc = ListReadEnum;
+ dbEnum.szModule = sModule;
+ CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ if (!Value.GetSize())
+ {
+ Value = DefValue;
+ } else
+ {
+ int I;
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ if (Value[I].Text == NULL) // NULL is not ""!
+ {
+ Value.RemoveElem(I);
+ I--;
+ }
+ }
+ }
+ COptItem::DBToMem(sModule, sDBSettingPrefix);
+}
+
+void COptItem_ListCtrl::MemToDB(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (!ReadOnly && Modified)
+ {
+ if (!sDBSettingPrefix)
+ {
+ sDBSettingPrefix = &sEmptyString;
+ }
+ CleanDBSettings(sModule, sDBSettingPrefix);
+ int I;
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ CString StrID;
+ _itoa(I, StrID.GetBuffer(64), 10);
+ StrID.ReleaseBuffer();
+ db_set_ts(NULL, sModule, *sDBSettingPrefix + sDBSetting + LISTITEM_DBSTR_TEXT + StrID, Value[I].Text);
+ }
+ COptItem::MemToDB(sModule, sDBSettingPrefix);
+ }
+}
+
+void COptItem_ListCtrl::WndToMem(HWND hWnd)
+{
+// nothing to do
+ COptItem::WndToMem(hWnd);
+}
+
+void COptItem_ListCtrl::MemToWnd(HWND hWnd)
+{
+ HWND hListView = GetDlgItem(hWnd, DlgItemID);
+ SendMessage(hListView, WM_SETREDRAW, false, 0);
+ SendMessage(hListView, LB_RESETCONTENT, 0, 0);
+ int I;
+ for (I = 0; I < Value.GetSize(); I++)
+ {
+ SendMessage(hListView, LB_INSERTSTRING, -1, (LPARAM)(TCHAR*)Value[I].Text);
+ }
+ SendMessage(hListView, WM_SETREDRAW, true, 0);
+ COptItem::MemToWnd(hWnd);
+}
+
+
+typedef struct
+{
+ TMyArray<CString> ListSettings;
+ COptItem_ListCtrl *ListCtrl;
+ CString *sDBSettingPrefix;
+} sListDeleteEnumData;
+
+int ListDeleteEnum(const char *szSetting, LPARAM lParam)
+{
+ sListDeleteEnumData *ListDeleteEnumData = (sListDeleteEnumData*)lParam;
+ CString CurSetting = *ListDeleteEnumData->sDBSettingPrefix + ListDeleteEnumData->ListCtrl->sDBSetting + LISTITEM_DBSTR_TEXT;
+ if (!strncmp(szSetting, CurSetting, CurSetting.GetLen()))
+ {
+ ListDeleteEnumData->ListSettings.AddElem(szSetting);
+ }
+ return 0;
+}
+
+void COptItem_ListCtrl::CleanDBSettings(CString &sModule, CString *sDBSettingPrefix)
+{
+ if (!sDBSettingPrefix)
+ {
+ sDBSettingPrefix = &sEmptyString;
+ }
+ sListDeleteEnumData ListDeleteEnumData;
+ ListDeleteEnumData.ListCtrl = this;
+ ListDeleteEnumData.sDBSettingPrefix = sDBSettingPrefix;
+ DBCONTACTENUMSETTINGS dbEnum;
+ dbEnum.lParam = (LPARAM)&ListDeleteEnumData;
+ dbEnum.ofsSettings = 0;
+ dbEnum.pfnEnumProc = ListDeleteEnum;
+ dbEnum.szModule = sModule;
+ CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
+ int I;
+ for (I = 0; I < ListDeleteEnumData.ListSettings.GetSize(); I++)
+ {
+ db_unset(NULL, sModule, ListDeleteEnumData.ListSettings[I]);
+ }
+}
+
+
+int COptItem_ListCtrl::GetSelectedItemID(HWND hWnd)
+{
+ int Res = SendDlgItemMessage(hWnd, DlgItemID, LB_GETCURSEL, 0, 0);
+ return (Res == LB_ERR) ? -1 : Res; // I know that LB_ERR = -1 ;)
+}
+
+int COptItem_ListCtrl::SetSelectedItemID(HWND hWnd, int ID)
+{
+ int Res = SendDlgItemMessage(hWnd, DlgItemID, LB_SETCURSEL, ID, 0);
+ return (Res == LB_ERR) ? -1 : Res;
+}
+
+void COptItem_ListCtrl::Delete(HWND hWnd, int ID)
+{
+ _ASSERT(ID >= 0);
+ HWND hListView = GetDlgItem(hWnd, DlgItemID);
+ int Res = SendMessage(hListView, LB_DELETESTRING, ID, 0);
+ _ASSERT(Res != LB_ERR);
+ Value.RemoveElem(ID);
+ Modified = true;
+}
+
+void COptItem_ListCtrl::ModifyItem(HWND hWnd, int ID, CListItem &Item)
+{ // changes the text of item with the specified ID
+ _ASSERT(ID >= 0);
+ HWND hListView = GetDlgItem(hWnd, DlgItemID);
+ SendMessage(hListView, WM_SETREDRAW, false, 0);
+ int CurSel = SendMessage(hListView, LB_GETCURSEL, 0, 0);
+ int TopIndex = SendMessage(hListView, LB_GETTOPINDEX, 0, 0);
+ int Res = SendMessage(hListView, LB_DELETESTRING, ID, 0);
+ _ASSERT(Res != LB_ERR);
+ Res = SendMessage(hListView, LB_INSERTSTRING, ID, (LPARAM)(TCHAR*)(Item.Text));
+ _ASSERT(Res != LB_ERR && Res != LB_ERRSPACE);
+ SendMessage(hListView, LB_SETCURSEL, CurSel, 0);
+ SendMessage(hListView, LB_SETTOPINDEX, TopIndex, 0);
+ SendMessage(hListView, WM_SETREDRAW, true, 0);
+ Value[ID].Text = Item.Text;
+ Modified = true;
+}
+
+CListItem* COptItem_ListCtrl::InsertItem(HWND hWnd, int ID, CListItem &Item)
+// returns a pointer to the newly inserted item info
+// ID is position at which to insert the item; -1 = add to the end of the list
+{
+ HWND hListView = GetDlgItem(hWnd, DlgItemID);
+ int Res = SendMessage(hListView, LB_INSERTSTRING, ID, (LPARAM)(TCHAR*)(Item.Text)); // LB_INSERTSTRING doesn't sort the lists even with LBS_SORT style
+ _ASSERT(Res != LB_ERR && Res != LB_ERRSPACE);
+ int I = Value.AddElem(Item);
+ Modified = true;
+ return &Value[I];
+}
diff --git a/plugins/NewAwaySysMod/src/Options.h b/plugins/NewAwaySysMod/src/Options.h new file mode 100644 index 0000000000..666162c50a --- /dev/null +++ b/plugins/NewAwaySysMod/src/Options.h @@ -0,0 +1,483 @@ +/*
+ Options.h
+ Copyright (c) 2005-2008 Chervov Dmitry
+
+ 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
+*/
+
+#pragma once
+
+#include "CString.h"
+#include "TMyArray.h"
+
+#ifndef lengthof
+#define lengthof(s) (sizeof(s) / sizeof(*s))
+#endif
+
+
+class COptItem
+{
+public:
+ COptItem() {}
+ COptItem(int DlgItemID, char *szDBSetting, int nValueSize, int lParam = 0, bool ReadOnly = false):
+ DlgItemID(DlgItemID), nValueSize(nValueSize), sDBSetting(szDBSetting), lParam(lParam), Enabled(true), ReadOnly(ReadOnly), Modified(false) {}
+/* COptItem(const COptItem &Item): DlgItemID(Item.DlgItemID), nValueSize(Item.nValueSize),
+ sDBSetting(Item.szDBSetting), lParam(Item.lParam), Enabled(Item.Enabled) {};*/
+ virtual ~COptItem() {}
+
+ virtual void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL) {Modified = false;}
+ virtual void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL) {Modified = false;}
+ virtual void WndToMem(HWND hWnd) {}
+ virtual void MemToWnd(HWND hWnd) {EnableWindow(GetDlgItem(hWnd, DlgItemID), Enabled);}
+ void DBToMemToWnd(CString &sModule, HWND hWnd, CString *sDBSettingPrefix = NULL) {DBToMem(sModule, sDBSettingPrefix); MemToWnd(hWnd);}
+ void WndToMemToDB(HWND hWnd, CString &sModule, CString *sDBSettingPrefix = NULL) {WndToMem(hWnd); MemToDB(sModule, sDBSettingPrefix);}
+ virtual void CleanDBSettings(CString &sModule, CString *sDBSettingPrefix = NULL) {db_unset(NULL, sModule, sDBSettingPrefix ? (*sDBSettingPrefix + sDBSetting) : sDBSetting);}; // TODO: also set Value to DefValue?
+
+ virtual void SetValue(int Value) {Modified = true;}
+ virtual void SetDefValue(int DefValue) {}
+ virtual int GetValue() {return 0;}
+ virtual int GetDefValue() {return 0;}
+ int GetDBValue(CString &sModule, CString *sDBSettingPrefix = NULL) {DBToMem(sModule, sDBSettingPrefix); return GetValue();}
+ void SetDBValue(CString &sModule, int Value, CString *sDBSettingPrefix = NULL) {SetValue(Value); MemToDB(sModule, sDBSettingPrefix);}
+ int GetDBValueCopy(CString &sModule, CString *sDBSettingPrefix = NULL) {COptItem* Item = Copy(); Item->DBToMem(sModule, sDBSettingPrefix); int Value = Item->GetValue(); delete Item; return Value;} // retrieves DB value, but doesn't affect current page/item state; beware! it doesn't work with string values / other dynamic pointers
+ void SetDBValueCopy(CString &sModule, int Value, CString *sDBSettingPrefix = NULL) {COptItem* Item = Copy(); Item->SetValue(Value); Item->MemToDB(sModule, sDBSettingPrefix); delete Item;}
+ int GetWndValue(HWND hWnd) {WndToMem(hWnd); return GetValue();}
+ void SetWndValue(HWND hWnd, int Value) {SetValue(Value); MemToWnd(hWnd);}
+ void SetDlgItemID(int DlgItemID) {this->DlgItemID = DlgItemID;}
+ bool GetModified() {return Modified;}
+ void SetModified(bool Modified) {this->Modified = Modified;}
+
+ void Enable(int Enabled) {this->Enabled = Enabled;}
+ int GetParam() {return lParam;}
+ int GetID() {return DlgItemID;}
+
+// virtual COptItem& operator = (const COptItem& Item) {return *this;};
+ virtual COptItem* Copy() {_ASSERT(0); return NULL;} // Attention! Free Copy() result when it's not needed anymore!
+
+ CString sDBSetting;
+
+protected:
+ int GetIntDBVal(CString &sModule, int bSigned = false, CString *sDBSettingPrefix = NULL);
+ void SetIntDBVal(CString &sModule, int Value, CString *sDBSettingPrefix = NULL);
+ TCString GetStrDBVal(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void SetStrDBVal(CString &sModule, TCString &Str, CString *sDBSettingPrefix = NULL);
+
+ int DlgItemID;
+ int Enabled;
+ bool ReadOnly;
+ bool Modified;
+ int nValueSize; // maximum pValue size in bytes
+ int lParam;
+};
+
+
+class COptItem_Generic : public COptItem
+{
+public:
+ COptItem_Generic() {}
+ COptItem_Generic(int DlgItemID, int lParam = 0): COptItem(DlgItemID, NULL, 0, lParam) {}
+ virtual COptItem* Copy() {return new COptItem_Generic(*this);}
+};
+
+
+class COptItem_Edit : public COptItem
+{
+public:
+ COptItem_Edit() {}
+ COptItem_Edit(int DlgItemID, char *szDBSetting, int nMaxLen, TCHAR *szDefValue, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, nMaxLen, lParam, ReadOnly), sDefValue(szDefValue) {}
+// COptItem_Edit(const COptItem_Edit &Item): sDefValue(Item.sDefValue), sValue(Item.sValue) {}
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL) {sValue = GetStrDBVal(sModule, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix);}
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL) {SetStrDBVal(sModule, sValue, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix);}
+ void WndToMem(HWND hWnd) {GetDlgItemText(hWnd, DlgItemID, sValue.GetBuffer(nValueSize), nValueSize); sValue.ReleaseBuffer(); COptItem::MemToWnd(hWnd);}
+ void MemToWnd(HWND hWnd) {SetDlgItemText(hWnd, DlgItemID, sValue); COptItem::MemToWnd(hWnd);}
+ void SetValue(int Value) {sValue = *(TCString*)Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {sDefValue = *(TCString*)DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return (int)&sValue;}
+ int GetDefValue() {return (int)&sDefValue;}
+
+// COptItem_Edit& operator = (const COptItem_Edit& Item) {return *this;};
+ virtual COptItem* Copy() {return new COptItem_Edit(*this);}
+
+ TCString sDefValue;
+ TCString sValue;
+};
+
+
+class COptItem_IntEdit : public COptItem
+{
+public:
+ COptItem_IntEdit() {}
+ COptItem_IntEdit(int DlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int bSigned = true, int DefValue = 0, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, nValueSize, lParam, ReadOnly), DefValue(DefValue), Value(0), bSigned(bSigned) {}
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL) {Value = GetIntDBVal(sModule, bSigned, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix);}
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL) {SetIntDBVal(sModule, Value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix);}
+ void WndToMem(HWND hWnd) {Value = GetDlgItemInt(hWnd, DlgItemID, NULL, bSigned); COptItem::WndToMem(hWnd);}
+ void MemToWnd(HWND hWnd) {SetDlgItemInt(hWnd, DlgItemID, Value, bSigned); COptItem::MemToWnd(hWnd);}
+ void SetValue(int Value) {this->Value = Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return Value;}
+ int GetDefValue() {return DefValue;}
+ virtual COptItem* Copy() {return new COptItem_IntEdit(*this);}
+
+ int DefValue;
+ int Value;
+ int bSigned;
+};
+
+
+class COptItem_Checkbox : public COptItem
+{
+public:
+ COptItem_Checkbox() {}
+ COptItem_Checkbox(int DlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int DefValue = 0, int ValueMask = 0, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, nValueSize, lParam, ReadOnly), DefValue(DefValue), Value(0), ValueMask(ValueMask) {}
+
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void WndToMem(HWND hWnd);
+ void MemToWnd(HWND hWnd);
+
+ void SetValue(int Value) {this->Value = Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return Value;}
+ int GetDefValue() {return DefValue;}
+ virtual COptItem* Copy() {return new COptItem_Checkbox(*this);}
+
+ int Value;
+ int DefValue;
+ int ValueMask;
+};
+
+
+class COptItem_Radiobutton : public COptItem
+{
+public:
+ COptItem_Radiobutton() {}
+ COptItem_Radiobutton(int DlgItemID, char *szDBSetting, int nValueSize, int DefValue, int ValueMask, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, nValueSize, lParam, ReadOnly), DefValue(DefValue), Value(0), ValueMask(ValueMask) {}
+
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL) {Value = (GetIntDBVal(sModule, false, sDBSettingPrefix) == ValueMask) ? BST_CHECKED : BST_UNCHECKED; COptItem::DBToMem(sModule, sDBSettingPrefix);}
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL) {if ((Value == BST_CHECKED)) SetIntDBVal(sModule, ValueMask, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix);}
+ void WndToMem(HWND hWnd) {Value = IsDlgButtonChecked(hWnd, DlgItemID); COptItem::WndToMem(hWnd);}
+ void MemToWnd(HWND hWnd) {CheckDlgButton(hWnd, DlgItemID, Value); COptItem::MemToWnd(hWnd);}
+
+ void SetValue(int Value) {this->Value = Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return Value;}
+ int GetDefValue() {return DefValue;}
+ virtual COptItem* Copy() {return new COptItem_Radiobutton(*this);}
+
+ int Value;
+ int DefValue;
+ int ValueMask;
+};
+
+
+class COptItem_Combobox : public COptItem
+{
+public:
+ COptItem_Combobox() {}
+ COptItem_Combobox(int DlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int DefValue = 0, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, nValueSize, lParam, ReadOnly), DefValue(DefValue), Value(0) {}
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL) {Value = GetIntDBVal(sModule, false, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix);}
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL) {SetIntDBVal(sModule, Value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix);}
+ void WndToMem(HWND hWnd) {Value = SendDlgItemMessage(hWnd, DlgItemID, CB_GETITEMDATA, (WPARAM)SendDlgItemMessage(hWnd, DlgItemID, CB_GETCURSEL, 0, 0), 0); COptItem::WndToMem(hWnd);}
+ void MemToWnd(HWND hWnd) {SendDlgItemMessage(hWnd, DlgItemID, CB_SETCURSEL, Value, 0); COptItem::MemToWnd(hWnd);}
+ void SetValue(int Value) {this->Value = Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return Value;}
+ int GetDefValue() {return DefValue;}
+ virtual COptItem* Copy() {return new COptItem_Combobox(*this);}
+
+ int DefValue;
+ int Value;
+};
+
+
+class COptItem_Colourpicker : public COptItem
+{
+public:
+ COptItem_Colourpicker() {}
+ COptItem_Colourpicker(int DlgItemID, char *szDBSetting, int DefValue = 0, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, DBVT_DWORD, lParam, ReadOnly), DefValue(DefValue), Value(0) {}
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL) {Value = GetIntDBVal(sModule, false, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix);}
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL) {SetIntDBVal(sModule, Value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix);}
+ void WndToMem(HWND hWnd) {Value = SendDlgItemMessage(hWnd, DlgItemID, CPM_GETCOLOUR, 0, 0); COptItem::WndToMem(hWnd);}
+ void MemToWnd(HWND hWnd) {SendDlgItemMessage(hWnd, DlgItemID, CPM_SETCOLOUR, 0, Value); COptItem::MemToWnd(hWnd);}
+ void SetValue(int Value) {this->Value = Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return Value;}
+ int GetDefValue() {return DefValue;}
+ virtual COptItem* Copy() {return new COptItem_Colourpicker(*this);}
+
+ DWORD DefValue;
+ DWORD Value;
+};
+
+
+class COptItem_Slider : public COptItem
+{
+public:
+ COptItem_Slider() {}
+ COptItem_Slider(int DlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int DefValue = 0, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, nValueSize, lParam, ReadOnly), DefValue(DefValue), Value(0) {}
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL) {Value = GetIntDBVal(sModule, false, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix);}
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL) {SetIntDBVal(sModule, Value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix);}
+ void WndToMem(HWND hWnd) {Value = SendDlgItemMessage(hWnd, DlgItemID, TBM_GETPOS, 0, 0); COptItem::WndToMem(hWnd);}
+ void MemToWnd(HWND hWnd) {SendDlgItemMessage(hWnd, DlgItemID, TBM_SETPOS, true, Value); COptItem::MemToWnd(hWnd);}
+ void SetValue(int Value) {this->Value = Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return Value;}
+ int GetDefValue() {return DefValue;}
+ virtual COptItem* Copy() {return new COptItem_Slider(*this);}
+
+ int DefValue;
+ int Value;
+};
+
+
+class COptItem_IntDBSetting : public COptItem
+{
+public:
+ COptItem_IntDBSetting() {}
+ COptItem_IntDBSetting(int DlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int bSigned = true, int DefValue = 0, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, nValueSize, lParam, ReadOnly), DefValue(DefValue), Value(0), bSigned(bSigned) {}
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL) {Value = GetIntDBVal(sModule, bSigned, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix);}
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL) {SetIntDBVal(sModule, Value, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix);}
+ void WndToMem(HWND hWnd) {COptItem::WndToMem(hWnd);}
+ void MemToWnd(HWND hWnd) {COptItem::MemToWnd(hWnd);}
+ void SetValue(int Value) {this->Value = Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return Value;}
+ int GetDefValue() {return DefValue;}
+ virtual COptItem* Copy() {return new COptItem_IntDBSetting(*this);}
+
+ int Value;
+ int DefValue;
+ int bSigned;
+};
+
+
+class COptItem_BitDBSetting : public COptItem
+{
+public:
+ COptItem_BitDBSetting() {}
+ COptItem_BitDBSetting(int DlgItemID, char *szDBSetting, int nValueSize = DBVT_BYTE, int DefValue = 0, int ValueMask = 0, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, nValueSize, lParam, ReadOnly), DefValue(DefValue), Value(0), ValueMask(ValueMask) {}
+
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void WndToMem(HWND hWnd) {COptItem::WndToMem(hWnd);}
+ void MemToWnd(HWND hWnd) {COptItem::MemToWnd(hWnd);}
+
+ void SetValue(int Value) {this->Value = Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return Value;}
+ int GetDefValue() {return DefValue;}
+ virtual COptItem* Copy() {return new COptItem_BitDBSetting(*this);}
+
+ int Value;
+ int DefValue;
+ int ValueMask;
+};
+
+
+class COptItem_StrDBSetting : public COptItem
+{
+public:
+ COptItem_StrDBSetting() {}
+ COptItem_StrDBSetting(int DlgItemID, char *szDBSetting, int nMaxLen, TCHAR *szDefValue, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, nMaxLen, lParam, ReadOnly), sDefValue(szDefValue) {}
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL) {sValue = GetStrDBVal(sModule, sDBSettingPrefix); COptItem::DBToMem(sModule, sDBSettingPrefix);}
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL) {SetStrDBVal(sModule, sValue, sDBSettingPrefix); COptItem::MemToDB(sModule, sDBSettingPrefix);}
+ void WndToMem(HWND hWnd) {COptItem::WndToMem(hWnd);}
+ void MemToWnd(HWND hWnd) {COptItem::MemToWnd(hWnd);}
+ void SetValue(int Value) {sValue = *(TCString*)Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {sDefValue = *(TCString*)DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return (int)&sValue;}
+ int GetDefValue() {return (int)&sDefValue;}
+ virtual COptItem* Copy() {return new COptItem_StrDBSetting(*this);}
+
+ TCString sDefValue;
+ TCString sValue;
+};
+
+
+// Tree item flags
+#define TIF_GROUP 1 // is a group
+#define TIF_EXPANDED 2 // item is expanded
+#define TIF_ENABLED 4 // item is checked (has sense when the tree has checkboxes)
+#define TIF_ROOTITEM 0x80 // item is a root item
+
+class CBaseTreeItem
+{
+public:
+ CBaseTreeItem();
+ CBaseTreeItem(TCString Title, int ID, int Flags): Title(Title), ID(ID), Flags(Flags), hItem(NULL) {}
+
+ TCString Title;
+ int ID;
+ int Flags;
+ HTREEITEM hItem;
+};
+
+class CTreeItem : public CBaseTreeItem
+{
+public:
+ CTreeItem();
+ CTreeItem(TCString Title, int ParentID, int ID, int Flags = 0, TCString User_Str1 = NULL):
+ CBaseTreeItem(Title, ID, Flags & ~TIF_ROOTITEM), ParentID(ParentID), User_Str1(User_Str1) {}
+
+ int ParentID;
+ TCString User_Str1;
+};
+
+class CTreeRootItem : public CBaseTreeItem
+{
+public:
+ CTreeRootItem();
+ CTreeRootItem(TCString Title, int ID, int Flags): CBaseTreeItem(Title, ID, Flags | TIF_ROOTITEM) {}
+};
+
+typedef TMyArray<CTreeItem> TreeItemArray;
+typedef TMyArray<CTreeRootItem> TreeRootItemArray;
+
+#define TREECTRL_ROOTORDEROFFS -2
+#define ROOT_INDEX_TO_ORDER(i) (TREECTRL_ROOTORDEROFFS - (i))
+#define ROOT_ORDER_TO_INDEX(i) (TREECTRL_ROOTORDEROFFS - (i))
+
+#define TREEITEMTITLE_MAXLEN 128
+#define TREEITEM_DBSTR_TITLE "Title"
+#define TREEITEM_DBSTR_PARENT "Parent"
+#define TREEITEM_DBSTR_ORDER "Order"
+#define TREEITEM_DBSTR_FLAGS "Flags"
+
+// Tree control flags
+#define TREECTRL_FLAG_IS_SINGLE_LEVEL 1 // means that the tree items can't have children, i.e. the tree is a plain list of items
+#define TREECTRL_FLAG_HAS_CHECKBOXES 2
+//#define TREECTRL_FLAG_UNORDERED 4 TODO?
+
+class COptItem_TreeCtrl : public COptItem
+{
+public:
+ COptItem_TreeCtrl() {}
+ COptItem_TreeCtrl(int DlgItemID, char *szDBSetting, TreeItemArray &DefValue, TreeRootItemArray RootItems, int lParam = 0, CString User_Str1_DBName = NULL, bool ReadOnly = false, int TreeFlags = 0): COptItem(DlgItemID, szDBSetting, DBVT_DWORD, lParam, ReadOnly), DefValue(DefValue), RootItems(RootItems), User_Str1_DBName(User_Str1_DBName), TreeFlags(TreeFlags)
+ {
+ if (TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL)
+ {
+ _ASSERT(!RootItems.GetSize()); // there can't be any root items when the tree is a plain list
+ this->RootItems.AddElem(CTreeRootItem(_T(""), 0, TIF_EXPANDED)); // TODO??
+ this->RootItems[0].hItem = TVI_ROOT;
+ }
+ }
+ ~COptItem_TreeCtrl() {}
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void WndToMem(HWND hWnd);
+ void MemToWnd(HWND hWnd);
+ void CleanDBSettings(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void SetValue(int Value) {this->Value = *(TreeItemArray*)Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = *(TreeItemArray*)DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return (int)&Value;}
+ int GetDefValue() {return (int)&DefValue;}
+ virtual COptItem* Copy() {return new COptItem_TreeCtrl(*this);}
+
+ int IDToOrder(int ID);
+ int hItemToOrder(HTREEITEM hItem);
+ int GenerateID();
+ int GetSelectedItemID(HWND hWnd);
+ void Delete(HWND hWnd, int ID);
+ CTreeItem* InsertItem(HWND hWnd, CTreeItem &Item);
+ void MoveItem(HWND hWnd, HTREEITEM hItem, HTREEITEM hMoveTo);
+
+ TreeItemArray DefValue, Value;
+ TreeRootItemArray RootItems;
+ CString User_Str1_DBName;
+ int TreeFlags;
+
+protected:
+ void RecursiveDelete(HWND hWnd, int I);
+ int RecursiveMove(int ItemOrder, int ParentID, int InsertAtOrder);
+};
+
+
+class CListItem
+{
+public:
+ CListItem();
+ CListItem(TCString Text): Text(Text) {}
+
+ TCString Text;
+};
+
+typedef TMyArray<CListItem> ListItemArray;
+
+#define LISTITEM_DBSTR_TEXT "Text"
+
+class COptItem_ListCtrl : public COptItem
+{
+public:
+ COptItem_ListCtrl() {}
+ COptItem_ListCtrl(int DlgItemID, char *szDBSetting, ListItemArray &DefValue, int lParam = 0, bool ReadOnly = false): COptItem(DlgItemID, szDBSetting, DBVT_DWORD, lParam, ReadOnly), DefValue(DefValue) {}
+ ~COptItem_ListCtrl() {}
+ void DBToMem(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void MemToDB(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void WndToMem(HWND hWnd);
+ void MemToWnd(HWND hWnd);
+ void CleanDBSettings(CString &sModule, CString *sDBSettingPrefix = NULL);
+ void SetValue(int Value) {this->Value = *(ListItemArray*)Value; COptItem::SetValue(Value);}
+ void SetDefValue(int DefValue) {this->DefValue = *(ListItemArray*)DefValue; COptItem::SetDefValue(DefValue);}
+ int GetValue() {return (int)&Value;}
+ int GetDefValue() {return (int)&DefValue;}
+ virtual COptItem* Copy() {return new COptItem_ListCtrl(*this);}
+
+ int GetSelectedItemID(HWND hWnd); // returns -1 if there's no selection
+ int SetSelectedItemID(HWND hWnd, int ID);
+ void Delete(HWND hWnd, int ID);
+ CListItem* InsertItem(HWND hWnd, int ID, CListItem &Item);
+ void ModifyItem(HWND hWnd, int ID, CListItem &Item);
+
+ ListItemArray DefValue, Value;
+};
+
+
+class COptPage
+{
+public:
+ COptPage(): hWnd(NULL), sDBSettingPrefix("") {}
+ COptPage(char *szModule, HWND hWnd, CString sDBSettingPrefix = ""): sModule(szModule), hWnd(hWnd), sDBSettingPrefix(sDBSettingPrefix) {}
+ COptPage(const COptPage &Item);
+ ~COptPage();
+
+ void DBToMem();
+ void MemToDB();
+ void MemToPage(int OnlyEnable = 0);
+ void PageToMem();
+ void DBToMemToPage() {DBToMem(); MemToPage();}
+ void PageToMemToDB() {PageToMem(); MemToDB();}
+ void CleanDBSettings();
+
+ COptItem *Find(int DlgItemID);
+ int GetValue(int DlgItemID) {return Find(DlgItemID)->GetValue();}
+ void SetValue(int DlgItemID, int Value) {Find(DlgItemID)->SetValue(Value);}
+ int GetDBValue(int DlgItemID) {return Find(DlgItemID)->GetDBValue(sModule, &sDBSettingPrefix);}
+ void SetDBValue(int DlgItemID, int Value) {Find(DlgItemID)->SetDBValue(sModule, Value, &sDBSettingPrefix);}
+ int GetDBValueCopy(int DlgItemID) {return Find(DlgItemID)->GetDBValueCopy(sModule, &sDBSettingPrefix);}
+ void SetDBValueCopy(int DlgItemID, int Value) {Find(DlgItemID)->SetDBValueCopy(sModule, Value, &sDBSettingPrefix);}
+ int GetWndValue(int DlgItemID) {return Find(DlgItemID)->GetWndValue(hWnd);}
+ void SetWndValue(int DlgItemID, int Value) {Find(DlgItemID)->SetWndValue(hWnd, Value);}
+ HWND GetWnd() {return hWnd;}
+ void SetWnd(HWND hWnd) {_ASSERT(!this->hWnd || !hWnd); this->hWnd = hWnd;}
+ void Enable(int DlgItemID, int Enabled) {Find(DlgItemID)->Enable(Enabled);}
+ bool GetModified();
+ void SetModified(bool Modified);
+
+ COptPage& operator = (const COptPage& Page);
+
+ HWND hWnd;
+ CString sModule, sDBSettingPrefix;
+ TMyArray<COptItem*, COptItem*> Items;
+};
diff --git a/plugins/!Deprecated/NewAwaySysMod/Path.h b/plugins/NewAwaySysMod/src/Path.h index e64b7ceb3c..e108a919e5 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Path.h +++ b/plugins/NewAwaySysMod/src/Path.h @@ -20,24 +20,24 @@ #pragma once
#include "m_utils.h"
-#include "..\CommonLibs\CString.h"
+#include "CString.h"
__inline TCString Path_ToRelative(TCString &Path)
{
- CString Str;
+ TCString Str;
Str.GetBuffer(MAX_PATH);
- CallService(MS_UTILS_PATHTORELATIVE, (WPARAM)(const char*)TCHAR2ANSI(Path), (LPARAM)(char*)Str);
+ CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)(TCHAR*)Path, (LPARAM)(TCHAR*)Str);
Str.ReleaseBuffer();
- return ANSI2TCHAR(Str);
+ return Str;
}
__inline TCString Path_ToAbsolute(TCString &Path)
{
- CString Str;
+ TCString Str;
Str.GetBuffer(MAX_PATH);
- CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)(const char*)TCHAR2ANSI(Path), (LPARAM)(char*)Str);
+ CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)(TCHAR*)Path, (LPARAM)(TCHAR*)Str);
Str.ReleaseBuffer();
- return ANSI2TCHAR(Str);
+ return Str;
}
diff --git a/plugins/!Deprecated/NewAwaySysMod/Properties.cpp b/plugins/NewAwaySysMod/src/Properties.cpp index c9dc3c1c9c..d1e87d0b8c 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Properties.cpp +++ b/plugins/NewAwaySysMod/src/Properties.cpp @@ -22,11 +22,11 @@ CProtoStates g_ProtoStates;
-void ResetContactSettingsOnStatusChange(HANDLE hContact)
+void ResetContactSettingsOnStatusChange(MCONTACT hContact)
{
- DBDeleteContactSetting(hContact, MOD_NAME, DB_REQUESTCOUNT);
- DBDeleteContactSetting(hContact, MOD_NAME, DB_SENDCOUNT);
- DBDeleteContactSetting(hContact, MOD_NAME, DB_MESSAGECOUNT);
+ db_unset(hContact, MOD_NAME, DB_REQUESTCOUNT);
+ db_unset(hContact, MOD_NAME, DB_SENDCOUNT);
+ db_unset(hContact, MOD_NAME, DB_MESSAGECOUNT);
}
@@ -36,7 +36,7 @@ void ResetSettingsOnStatusChange(const char *szProto = NULL, int bResetPersonalM { // bResetPersonalMsgs &&= g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_SAVEPERSONALMSGS);
bResetPersonalMsgs = !g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_SAVEPERSONALMSGS);
}
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ MCONTACT hContact = db_find_first();
while (hContact)
{
const char *szCurProto;
@@ -48,7 +48,7 @@ void ResetSettingsOnStatusChange(const char *szProto = NULL, int bResetPersonalM CContactSettings(Status, hContact).SetMsgFormat(SMF_PERSONAL, NULL); // TODO: delete only when SAM dialog opens?
}
}
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
+ hContact = db_find_next(hContact);
}
}
@@ -82,7 +82,7 @@ CProtoState::CStatus& CProtoState::CStatus::operator = (int Status) for (I = 0; I < GrandParent->GetSize(); I++)
{
CProtoState &State = (*GrandParent)[I];
- if (!DBGetContactSettingByte(NULL, State.GetProto(), "LockMainStatus", 0)) // if the protocol isn't locked
+ if (!db_get_b(NULL, State.GetProto(), "LockMainStatus", 0)) // if the protocol isn't locked
{
if (State.Status != Status)
{
@@ -141,10 +141,10 @@ void CContactSettings::SetMsgFormat(int Flags, TCString Message) }
if (Message != NULL)
{
- DBWriteContactSettingTString(hContact, MOD_NAME, DBSetting, Message);
+ db_set_ts(hContact, MOD_NAME, DBSetting, Message);
} else
{
- DBDeleteContactSetting(hContact, MOD_NAME, DBSetting);
+ db_unset(hContact, MOD_NAME, DBSetting);
}
}
if (Flags & (SMF_LAST | SMF_TEMPORARY))
@@ -166,11 +166,11 @@ TCString CContactSettings::GetMsgFormat(int Flags, int *pOrder, char *szProtoOve }
if (Flags & GMF_PERSONAL)
{ // try getting personal message (it overrides global)
- Message = DBGetContactSettingString(hContact, MOD_NAME, StatusToDBSetting(Status, DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPERSONAL), (TCHAR*)NULL);
+ Message = db_get_s(hContact, MOD_NAME, StatusToDBSetting(Status, DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPERSONAL), (TCHAR*)NULL);
}
if (Flags & (GMF_LASTORDEFAULT | GMF_PROTOORGLOBAL | GMF_TEMPORARY) && Message.IsEmpty())
{
- char *szProto = szProtoOverride ? szProtoOverride : (hContact ? (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0) : NULL);
+ char *szProto = szProtoOverride ? szProtoOverride : (hContact ? GetContactProto(hContact) : NULL);
if (Flags & (GMF_LASTORDEFAULT | GMF_PROTOORGLOBAL))
{ // we mustn't pass here by GMF_TEMPORARY flag, as otherwise we'll handle GMF_TEMPORARY | GMF_PERSONAL combination incorrectly, which is supposed to get only per-contact messages, and at the same time also may be used with NULL contact to get the global status message
Message = CProtoSettings(szProto).GetMsgFormat(Flags, pOrder);
@@ -204,15 +204,15 @@ void CProtoSettings::SetMsgFormat(int Flags, TCString Message) CString DBSetting(ProtoStatusToDBSetting(DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPROTOMSGS));
if (Message != NULL)
{
- DBWriteContactSettingTString(NULL, MOD_NAME, DBSetting, Message);
+ db_set_ts(NULL, MOD_NAME, DBSetting, Message);
} else
{
if (!szProto)
{
- DBWriteContactSettingTString(NULL, MOD_NAME, DBSetting, CProtoSettings(NULL, Status).GetMsgFormat(GMF_LASTORDEFAULT)); // global message can't be NULL; we can use an empty string instead if it's really necessary
+ db_set_ts(NULL, MOD_NAME, DBSetting, CProtoSettings(NULL, Status).GetMsgFormat(GMF_LASTORDEFAULT)); // global message can't be NULL; we can use an empty string instead if it's really necessary
} else
{
- DBDeleteContactSetting(NULL, MOD_NAME, DBSetting);
+ db_unset(NULL, MOD_NAME, DBSetting);
}
}
}
@@ -325,7 +325,7 @@ TCString CProtoSettings::GetMsgFormat(int Flags, int *pOrder) }
if (Flags & GMF_PERSONAL && Message == NULL)
{ // try getting personal message (it overrides global)
- Message = DBGetContactSettingString(NULL, MOD_NAME, ProtoStatusToDBSetting(DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPROTOMSGS), (TCHAR*)NULL);
+ Message = db_get_s(NULL, MOD_NAME, ProtoStatusToDBSetting(DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPROTOMSGS), (TCHAR*)NULL);
}
if (Flags & GMF_PROTOORGLOBAL && Message == NULL)
{
@@ -340,7 +340,7 @@ TCString CProtoSettings::GetMsgFormat(int Flags, int *pOrder) Message = NULL;
if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_USELASTMSG)) // if using last message by default...
{
- Message = DBGetContactSettingString(NULL, MOD_NAME, ProtoStatusToDBSetting(DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPROTOMSGS), (TCHAR*)NULL); // try per-protocol message first
+ Message = db_get_s(NULL, MOD_NAME, ProtoStatusToDBSetting(DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPROTOMSGS), (TCHAR*)NULL); // try per-protocol message first
if (Message.IsEmpty())
{
Message = NULL; // to be sure it's NULL, not "" - as we're checking 'Message == NULL' later
diff --git a/plugins/!Deprecated/NewAwaySysMod/Properties.h b/plugins/NewAwaySysMod/src/Properties.h index 6b981bd77e..b484f4c2d1 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Properties.h +++ b/plugins/NewAwaySysMod/src/Properties.h @@ -282,7 +282,7 @@ public: {
int ProtoCount;
PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&ProtoCount, (LPARAM)&proto);
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
int I;
for (I = 0; I < ProtoCount; I++)
{
@@ -358,16 +358,16 @@ public: CAutoreply& operator = (const int Value)
{
CString Setting(Parent->szProto ? Parent->ProtoStatusToDBSetting(DB_ENABLEREPLY, IDC_MOREOPTDLG_PERSTATUSPROTOSETTINGS) : DB_ENABLEREPLY);
- if (DBGetContactSettingByte(NULL, MOD_NAME, Setting, VAL_USEDEFAULT) == Value)
+ if (db_get_b(NULL, MOD_NAME, Setting, VAL_USEDEFAULT) == Value)
{
return *this; // prevent deadlocks when calling UpdateSOEButtons
}
if (Value != VAL_USEDEFAULT)
{
- DBWriteContactSettingByte(NULL, MOD_NAME, Setting, Value != 0);
+ db_set_b(NULL, MOD_NAME, Setting, Value != 0);
} else
{
- DBDeleteContactSetting(NULL, MOD_NAME, Setting);
+ db_unset(NULL, MOD_NAME, Setting);
}
/*if (!Parent->szProto)
{
@@ -375,7 +375,7 @@ public: }*/
return *this;
}
- operator int() {return DBGetContactSettingByte(NULL, MOD_NAME, Parent->szProto ? Parent->ProtoStatusToDBSetting(DB_ENABLEREPLY, IDC_MOREOPTDLG_PERSTATUSPROTOSETTINGS) : DB_ENABLEREPLY, Parent->szProto ? VAL_USEDEFAULT : AUTOREPLY_DEF_REPLY);}
+ operator int() {return db_get_b(NULL, MOD_NAME, Parent->szProto ? Parent->ProtoStatusToDBSetting(DB_ENABLEREPLY, IDC_MOREOPTDLG_PERSTATUSPROTOSETTINGS) : DB_ENABLEREPLY, Parent->szProto ? VAL_USEDEFAULT : AUTOREPLY_DEF_REPLY);}
int IncludingParents() // takes into account global data also, if per-protocol setting is not defined
{
_ASSERT(Parent->szProto);
@@ -432,9 +432,9 @@ __inline CString StatusToDBSetting(int Status, const char *Prefix, int MoreOpt_P }
-__inline CString ContactStatusToDBSetting(int Status, const char *Prefix, int MoreOpt_PerStatusID, HANDLE hContact)
+__inline CString ContactStatusToDBSetting(int Status, const char *Prefix, int MoreOpt_PerStatusID, MCONTACT hContact)
{
- if (hContact == INVALID_HANDLE_VALUE)
+ if (hContact == INVALID_CONTACT_ID)
{ // it's a not-on-list contact
return CString(DB_UNK_CONTACT_PREFIX) + Prefix;
}
@@ -449,7 +449,7 @@ __inline CString ContactStatusToDBSetting(int Status, const char *Prefix, int Mo class CContactSettings
{
public:
- CContactSettings(int iStatus = 0, HANDLE hContact = NULL): Status(iStatus, hContact), hContact(hContact)
+ CContactSettings(int iStatus = 0, MCONTACT _hContact = NULL): Status(iStatus, hContact), hContact(_hContact)
{
Ignore.Parent = this;
Autoreply.Parent = this;
@@ -458,7 +458,7 @@ public: CString ContactStatusToDBSetting(const char *Prefix, int MoreOpt_PerStatusID = 0)
{
- return ::ContactStatusToDBSetting((hContact != INVALID_HANDLE_VALUE) ? Status : NULL, Prefix, MoreOpt_PerStatusID, hContact);
+ return ::ContactStatusToDBSetting((hContact != INVALID_CONTACT_ID) ? Status : NULL, Prefix, MoreOpt_PerStatusID, hContact);
}
class CIgnore
@@ -467,17 +467,17 @@ public: CIgnore& operator = (const int Value)
{
CString Setting(Parent->ContactStatusToDBSetting(DB_IGNOREREQUESTS, IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS));
- HANDLE hContact = (Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL;
+ MCONTACT hContact = (Parent->hContact != INVALID_CONTACT_ID) ? Parent->hContact : NULL;
if (Value)
{
- DBWriteContactSettingByte(hContact, MOD_NAME, Setting, 1);
+ db_set_b(hContact, MOD_NAME, Setting, 1);
} else
{
- DBDeleteContactSetting(hContact, MOD_NAME, Setting);
+ db_unset(hContact, MOD_NAME, Setting);
}
return *this;
}
- operator int() {return DBGetContactSettingByte((Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL, MOD_NAME, Parent->ContactStatusToDBSetting(DB_IGNOREREQUESTS, IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS), 0);}
+ operator int() {return db_get_b((Parent->hContact != INVALID_CONTACT_ID) ? Parent->hContact : NULL, MOD_NAME, Parent->ContactStatusToDBSetting(DB_IGNOREREQUESTS, IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS), 0);}
friend class CContactSettings;
private:
CContactSettings *Parent;
@@ -489,32 +489,24 @@ public: CAutoreply& operator = (const int Value)
{
CString Setting(Parent->ContactStatusToDBSetting(DB_ENABLEREPLY, IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS));
- HANDLE hContact = (Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL;
- if (DBGetContactSettingByte(hContact, MOD_NAME, Setting, VAL_USEDEFAULT) == Value)
- {
+ MCONTACT hContact = (Parent->hContact != INVALID_CONTACT_ID) ? Parent->hContact : NULL;
+ if (db_get_b(hContact, MOD_NAME, Setting, VAL_USEDEFAULT) == Value)
return *this; // prevent deadlocks when calling UpdateSOEButtons
- }
+
if (Value != VAL_USEDEFAULT)
- {
- DBWriteContactSettingByte(hContact, MOD_NAME, Setting, Value != 0);
- } else
- {
- DBDeleteContactSetting(hContact, MOD_NAME, Setting);
- }
- /*if (Parent->hContact != INVALID_HANDLE_VALUE)
- {
- UpdateSOEButtons(Parent->hContact);
- }*/
+ db_set_b(hContact, MOD_NAME, Setting, Value != 0);
+ else
+ db_unset(hContact, MOD_NAME, Setting);
return *this;
}
- operator int() {return DBGetContactSettingByte((Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL, MOD_NAME, Parent->ContactStatusToDBSetting(DB_ENABLEREPLY, IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS), Parent->hContact ? VAL_USEDEFAULT : AUTOREPLY_DEF_REPLY);}
+ operator int() {return db_get_b((Parent->hContact != INVALID_CONTACT_ID) ? Parent->hContact : NULL, MOD_NAME, Parent->ContactStatusToDBSetting(DB_ENABLEREPLY, IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS), Parent->hContact ? VAL_USEDEFAULT : AUTOREPLY_DEF_REPLY);}
int IncludingParents(const char *szProtoOverride = NULL) // takes into account protocol and global data also, if per-contact setting is not defined
{
- _ASSERT((Parent->hContact && Parent->hContact != INVALID_HANDLE_VALUE) || szProtoOverride); // we need either correct protocol or a correct hContact to determine its protocol
+ _ASSERT((Parent->hContact && Parent->hContact != INVALID_CONTACT_ID) || szProtoOverride); // we need either correct protocol or a correct hContact to determine its protocol
int Value = *this;
if (Value == VAL_USEDEFAULT)
{
- const char *szProto = (Parent->hContact && Parent->hContact != INVALID_HANDLE_VALUE) ? (const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)Parent->hContact, 0) : szProtoOverride;
+ const char *szProto = (Parent->hContact && Parent->hContact != INVALID_CONTACT_ID) ? (const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)Parent->hContact, 0) : szProtoOverride;
return CProtoSettings(szProto).Autoreply.IncludingParents();
}
return Value;
@@ -540,17 +532,17 @@ public: CPopupNotify& operator = (const int Value)
{
//CString Setting(Parent->ContactStatusToDBSetting(DB_POPUPNOTIFY, 0)); //IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS
- HANDLE hContact = (Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL;
- if (DBGetContactSettingByte(hContact, MOD_NAME, Setting, VAL_USEDEFAULT) == Value)
+ MCONTACT hContact = (Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL;
+ if (db_get_b(hContact, MOD_NAME, Setting, VAL_USEDEFAULT) == Value)
{
return *this; // prevent deadlocks when calling UpdateSOEButtons
}
if (Value != VAL_USEDEFAULT)
{
- DBWriteContactSettingByte(hContact, MOD_NAME, Setting, Value != 0);
+ db_set_b(hContact, MOD_NAME, Setting, Value != 0);
} else
{
- DBDeleteContactSetting(hContact, MOD_NAME, Setting);
+ db_unset(hContact, MOD_NAME, Setting);
}
if (!Parent->hContact)
{
@@ -558,7 +550,7 @@ public: }
return *this;
}
- operator int() {return DBGetContactSettingByte((Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL, MOD_NAME, Parent->ContactStatusToDBSetting(DB_POPUPNOTIFY, 0), Parent->hContact ? VAL_USEDEFAULT : POPUP_DEF_USEPOPUPS);} //IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS
+ operator int() {return db_get_b((Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL, MOD_NAME, Parent->ContactStatusToDBSetting(DB_POPUPNOTIFY, 0), Parent->hContact ? VAL_USEDEFAULT : POPUP_DEF_USEPOPUPS);} //IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS
int IncludingParents() // takes into account protocol and global data also, if per-contact setting is not defined
{
int Value = *this;
@@ -576,14 +568,14 @@ public: class CStatus
{
public:
- CStatus(int iStatus = 0, HANDLE hContact = NULL): Status(iStatus), hContact(hContact) {}
+ CStatus(int iStatus = 0, MCONTACT _hContact = NULL): Status(iStatus), hContact(_hContact) {}
CStatus& operator = (int Status) {this->Status = Status; return *this;}
operator int()
{
if (!Status)
{
- _ASSERT(hContact != INVALID_HANDLE_VALUE);
- char *szProto = hContact ? (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0) : NULL;
+ _ASSERT(hContact != INVALID_CONTACT_ID);
+ char *szProto = hContact ? GetContactProto(hContact) : NULL;
Status = (szProto || !hContact) ? g_ProtoStates[szProto].Status : ID_STATUS_AWAY;
}
return Status;
@@ -592,7 +584,7 @@ public: friend class CAutoreply;
private:
int Status;
- HANDLE hContact;
+ MCONTACT hContact;
} Status;
void SetMsgFormat(int Flags, TCString Message);
@@ -601,5 +593,5 @@ public: //NightFox: fix?
//private:
public:
- HANDLE hContact;
+ MCONTACT hContact;
};
diff --git a/plugins/!Deprecated/NewAwaySysMod/ReadAwayMsg.cpp b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp index 6d197b7614..2464c38f4c 100644 --- a/plugins/!Deprecated/NewAwaySysMod/ReadAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp @@ -60,7 +60,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam Utils_RestoreWindowPosition(hwndDlg, NULL, MOD_NAME, RAMDLGSIZESETTING);
READAWAYMSGDATA *awayData = new READAWAYMSGDATA;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)awayData);
- awayData->hContact = (HANDLE)lParam;
+ awayData->hContact = lParam;
awayData->hAwayMsgEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, UM_RAM_AWAYMSGACK);
awayData->hSeq = (HANDLE)CallContactService(awayData->hContact, PSS_GETAWAYMSG, 0, 0);
WindowList_Add(g_hReadWndList, hwndDlg, awayData->hContact);
@@ -68,8 +68,8 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam TCHAR str[256], format[128];
TCHAR *status, *contactName;
contactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)awayData->hContact, GCDNF_TCHAR);
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)awayData->hContact, 0);
- status = (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, DBGetContactSettingWord(awayData->hContact, szProto, "Status", ID_STATUS_OFFLINE), GSMDF_TCHAR);
+ char *szProto = GetContactProto(awayData->hContact);
+ status = (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, db_get_w(awayData->hContact, szProto, "Status", ID_STATUS_OFFLINE), GSMDF_TCHAR);
GetWindowText(hwndDlg, format, lengthof(format));
_sntprintf(str, lengthof(str), format, status, contactName);
SetWindowText(hwndDlg, str);
@@ -97,7 +97,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam ShowWindow(GetDlgItem(hwndDlg, IDC_READAWAYMSG_RETRIEVE), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_READAWAYMSG_MSG), SW_SHOW);
SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close"));
- DBWriteContactSettingString(awayData->hContact, "CList", "StatusMsg", (const char*)ack->lParam);
+ db_set_s(awayData->hContact, "CList", "StatusMsg", (const char*)ack->lParam);
} break;
case WM_COMMAND:
{
@@ -150,12 +150,9 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam INT_PTR GetContactStatMsg(WPARAM wParam, LPARAM lParam)
{
- if (HWND hWnd = WindowList_Find(g_hReadWndList, (HANDLE)wParam)) // already have it
- {
+ if (HWND hWnd = WindowList_Find(g_hReadWndList, wParam)) // already have it
SetForegroundWindow(hWnd);
- } else
- {
+ else
CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_READAWAYMSG), NULL, ReadAwayMsgDlgProc, wParam);
- }
return 0;
}
diff --git a/plugins/!Deprecated/NewAwaySysMod/Services.cpp b/plugins/NewAwaySysMod/src/Services.cpp index c8108eb1a9..392d318222 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Services.cpp +++ b/plugins/NewAwaySysMod/src/Services.cpp @@ -46,7 +46,7 @@ __inline void PSSetStatus(char *szProto, WORD Status, int bNoClistSetStatusMode {
/* int ProtoCount;
PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&ProtoCount, (LPARAM)&proto);
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
int i;
for (i = 0; i < ProtoCount; i++)
{
@@ -68,7 +68,7 @@ INT_PTR GetStatusMsg(WPARAM wParam, LPARAM lParam) // called by GamerStatus and // MS_AWAYMSG_GETSTATUSMSG "SRAway/GetStatusMessage"
{
LogMessage("MS_AWAYMSG_GETSTATUSMSG called. status=%d", wParam);
- CString Msg(TCHAR2ANSI(GetDynamicStatMsg(INVALID_HANDLE_VALUE, NULL, 0, wParam)));
+ CString Msg(_T2A(GetDynamicStatMsg(INVALID_CONTACT_ID, NULL, 0, wParam)));
char *szMsg;
if (Msg == NULL)
{ // it's ok to return NULL, so we'll do it
@@ -95,7 +95,7 @@ INT_PTR SetStatusMode(WPARAM wParam, LPARAM lParam) // called by GamerStatus and // }
_ASSERT(!g_fNoProcessing && g_ProtoStates[(char*)NULL].Status == wParam);
g_fNoProcessing = false;
- CProtoSettings(NULL, wParam).SetMsgFormat(SMF_TEMPORARY, lParam ? ANSI2TCHAR((char*)lParam) : CProtoSettings(NULL, wParam).GetMsgFormat(GMF_LASTORDEFAULT));
+ CProtoSettings(NULL, wParam).SetMsgFormat(SMF_TEMPORARY, lParam ? (TCHAR*)_A2T((char*)lParam) : CProtoSettings(NULL, wParam).GetMsgFormat(GMF_LASTORDEFAULT));
ChangeProtoMessages(NULL, wParam, TCString());
return 0;
}
@@ -123,9 +123,9 @@ int GetState(WPARAM wParam, LPARAM lParam, int Widechar) pi->szMsg = (char*)mir_alloc(Msg.GetLen() + 1);
_ASSERT(pi->szMsg);
if (Widechar)
- lstrcpyW(pi->wszMsg, TCHAR2WCHAR(Msg));
+ lstrcpyW(pi->wszMsg, Msg);
else
- lstrcpyA(pi->szMsg, TCHAR2ANSI(Msg));
+ lstrcpyA(pi->szMsg, _T2A(Msg));
}
else pi->szMsg = NULL;
@@ -134,7 +134,7 @@ int GetState(WPARAM wParam, LPARAM lParam, int Widechar) }
else pi->szMsg = NULL;
- LogMessage("%d (returned): status=%d, Flags=0x%x, szMsg:\n%s", i + 1, pi->status, (pi->cbSize > sizeof(NAS_PROTOINFOv1)) ? pi->Flags : 0, pi->szMsg ? (Widechar ? WCHAR2ANSI(pi->wszMsg) : pi->szMsg) : "NULL");
+ LogMessage("%d (returned): status=%d, Flags=0x%x, szMsg:\n%s", i + 1, pi->status, (pi->cbSize > sizeof(NAS_PROTOINFOv1)) ? pi->Flags : 0, pi->szMsg ? (Widechar ? _T2A(pi->wszMsg) : pi->szMsg) : "NULL");
*(char**)&pi += pi->cbSize;
}
return 0;
@@ -167,13 +167,13 @@ int SetState(WPARAM wParam, LPARAM lParam, int Widechar) return 1;
int Flags = (pi->cbSize > sizeof(NAS_PROTOINFOv1)) ? pi->Flags : 0;
- LogMessage("%d: cbSize=%d, status=%d, szProto=%s, Flags=0x%x, szMsg:\n%s", i + 1, pi->cbSize, pi->status, pi->szProto ? pi->szProto : "NULL", Flags, pi->szMsg ? (Widechar ? WCHAR2ANSI(pi->wszMsg) : pi->szMsg) : "NULL");
+ LogMessage("%d: cbSize=%d, status=%d, szProto=%s, Flags=0x%x, szMsg:\n%s", i + 1, pi->cbSize, pi->status, pi->szProto ? pi->szProto : "NULL", Flags, pi->szMsg ? (Widechar ? _T2A(pi->wszMsg) : pi->szMsg) : "NULL");
if (pi->status)
PSSetStatus(pi->szProto, pi->status, Flags & PIF_NO_CLIST_SETSTATUSMODE);
else
pi->status = g_ProtoStates[pi->szProto].Status;
- CProtoSettings(pi->szProto).SetMsgFormat((Flags & PIF_NOTTEMPORARY) ? SMF_PERSONAL : SMF_TEMPORARY, Widechar ? WCHAR2TCHAR(pi->wszMsg) : ANSI2TCHAR(pi->szMsg));
+ CProtoSettings(pi->szProto).SetMsgFormat((Flags & PIF_NOTTEMPORARY) ? SMF_PERSONAL : SMF_TEMPORARY, Widechar ? pi->wszMsg : _A2T(pi->szMsg));
if (pi->szMsg || !(Flags & PIF_NO_CLIST_SETSTATUSMODE))
ChangeProtoMessages(pi->szProto, pi->status, TCString());
@@ -207,7 +207,7 @@ INT_PTR InvokeStatusWindow(WPARAM wParam, LPARAM lParam) {
return NULL;
}
- LogMessage("MS_NAS_INVOKESTATUSWINDOW called. cbSize=%d, status=%d, szProto=%s, hContact=0x%08x, Flags=0x%x, szMsg:\n%s", iswi->cbSize, iswi->status, iswi->szProto ? iswi->szProto : "NULL", iswi->hContact, (iswi->cbSize < sizeof(NAS_ISWINFO)) ? 0 : iswi->Flags, iswi->szMsg ? ((iswi->Flags & ISWF_UNICODE) ? WCHAR2ANSI(iswi->wszMsg) : iswi->szMsg) : "NULL");
+ LogMessage("MS_NAS_INVOKESTATUSWINDOW called. cbSize=%d, status=%d, szProto=%s, hContact=0x%08x, Flags=0x%x, szMsg:\n%s", iswi->cbSize, iswi->status, iswi->szProto ? iswi->szProto : "NULL", iswi->hContact, (iswi->cbSize < sizeof(NAS_ISWINFO)) ? 0 : iswi->Flags, iswi->szMsg ? ((iswi->Flags & ISWF_UNICODE) ? _T2A(iswi->wszMsg) : iswi->szMsg) : "NULL");
if (iswi->status)
{
PSSetStatus(iswi->szProto, iswi->status);
@@ -221,7 +221,7 @@ INT_PTR InvokeStatusWindow(WPARAM wParam, LPARAM lParam) ZeroMemory(dat, sizeof(SetAwayMsgData));
dat->hInitContact = iswi->hContact;
dat->szProtocol = iswi->szProto;
- dat->Message = (iswi->Flags & ISWF_UNICODE) ? WCHAR2TCHAR(iswi->wszMsg) : ANSI2TCHAR(iswi->szMsg);
+ dat->Message = (iswi->Flags & ISWF_UNICODE) ? iswi->wszMsg : _A2T(iswi->szMsg);
dat->IsModeless = true;
if (iswi->cbSize > sizeof(NAS_ISWINFOv1))
{
diff --git a/plugins/!Deprecated/NewAwaySysMod/Services.h b/plugins/NewAwaySysMod/src/Services.h index 903bbd3784..903bbd3784 100644 --- a/plugins/!Deprecated/NewAwaySysMod/Services.h +++ b/plugins/NewAwaySysMod/src/Services.h diff --git a/plugins/!Deprecated/NewAwaySysMod/SetAwayMsg.cpp b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp index e367519554..9b918be898 100644 --- a/plugins/!Deprecated/NewAwaySysMod/SetAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp @@ -269,7 +269,7 @@ __inline int DBValueToReplyIcon(int Value) int GetRealReplyIcon(CCList *CList, HTREEITEM hItem)
{
_ASSERT(CList);
- HANDLE hContact = CList->GethContact(hItem);
+ MCONTACT hContact = CList->GethContact(hItem);
int ItemType = CList->GetItemType(hItem);
char *szProto = (char*)CList->GetItemParam(hItem);
return (ItemType == MCLCIT_GROUP) ? CList->GetItemParam(hItem) : DBValueToReplyIcon((ItemType == MCLCIT_CONTACT) ? (int)CContactSettings(0, hContact).Autoreply : CProtoSettings(szProto).Autoreply);
@@ -280,7 +280,7 @@ void SetExtraIcon(CCList *CList, int nColumn, HTREEITEM hItem, int nIcon) {
_ASSERT(CList);
int ItemType = CList->GetItemType(hItem);
- HANDLE hContact = CList->GethContact(hItem);
+ MCONTACT hContact = CList->GethContact(hItem);
if (ItemType == MCLCIT_CONTACT)
{
if (nIcon == -1) // means we need to retrieve it from the db by ourselves
@@ -465,7 +465,7 @@ void ApplySelContactsMessage(SetAwayMsgData* dat, CCList *CList, PTREEITEMARRAY int ItemType = CList->GetItemType(hItem);
if (ItemType == MCLCIT_CONTACT)
{
- HANDLE hContact = CList->GethContact(hItem);
+ MCONTACT hContact = CList->GethContact(hItem);
CContactSettings(0, hContact).SetMsgFormat(SMF_PERSONAL, Message);
} else if (ItemType == MCLCIT_INFO)
{
@@ -480,12 +480,9 @@ void ApplySelContactsMessage(SetAwayMsgData* dat, CCList *CList, PTREEITEMARRAY } else if (Selection != CLSEL_DAT_NOTHING)
{
if (dat->hInitContact)
- {
CContactSettings(0, dat->hInitContact).SetMsgFormat(SMF_PERSONAL, Message);
- } else
- {
+ else
CProtoSettings(dat->szProtocol).SetMsgFormat(SMF_PERSONAL, (dat->szProtocol || Message != NULL) ? Message : _T(""));
- }
}
SendDlgItemMessage(hwndDlg, IDC_SAWAYMSG_MSGDATA, EM_SETMODIFY, false, 0);
SetDlgItemText(hwndDlg, IDC_OK, TranslateT("OK"));
@@ -565,15 +562,10 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA TranslateDialogDefault(hwndDlg);
g_SetAwayMsgPage.SetWnd(hwndDlg);
g_SetAwayMsgPage.DBToMemToPage();
-/*
- HICON hTitleIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
- HICON hTitleIconBig = LoadSkinnedIconBig(SKINICON_OTHER_MIRANDA);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hTitleIconBig);
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hTitleIcon);
-*/
+
HICON hTitleIconBigElse = LoadSkinnedIconBig(SKINICON_OTHER_MIRANDA);
- char *szProto = dat->hInitContact ? (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hInitContact, 0) : dat->szProtocol;
+ char *szProto = dat->hInitContact ? GetContactProto(dat->hInitContact) : dat->szProtocol;
int Status = 0;
Status = g_ProtoStates[dat->szProtocol].Status;
HICON hTitleIcon = LoadSkinnedProtoIcon(szProto, Status);
@@ -669,12 +661,12 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA // [try] getting dialog position
- int DlgPosX = DBGetContactSettingDword(NULL, MOD_NAME, SAM_DB_DLGPOSX, -1);
- int DlgPosY = DBGetContactSettingDword(NULL, MOD_NAME, SAM_DB_DLGPOSY, -1);
- int DlgSizeX = DBGetContactSettingDword(NULL, MOD_NAME, SAM_DB_DLGSIZEX, -1);
- int DlgSizeY = DBGetContactSettingDword(NULL, MOD_NAME, SAM_DB_DLGSIZEY, -1);
- int MsgSplitterX = DBGetContactSettingDword(NULL, MOD_NAME, SAM_DB_MSGSPLITTERPOS, -1);
- int ContactSplitterX = DBGetContactSettingDword(NULL, MOD_NAME, SAM_DB_CONTACTSPLITTERPOS, -1);
+ int DlgPosX = db_get_dw(NULL, MOD_NAME, SAM_DB_DLGPOSX, -1);
+ int DlgPosY = db_get_dw(NULL, MOD_NAME, SAM_DB_DLGPOSY, -1);
+ int DlgSizeX = db_get_dw(NULL, MOD_NAME, SAM_DB_DLGSIZEX, -1);
+ int DlgSizeY = db_get_dw(NULL, MOD_NAME, SAM_DB_DLGSIZEY, -1);
+ int MsgSplitterX = db_get_dw(NULL, MOD_NAME, SAM_DB_MSGSPLITTERPOS, -1);
+ int ContactSplitterX = db_get_dw(NULL, MOD_NAME, SAM_DB_CONTACTSPLITTERPOS, -1);
if (DlgPosX >= 0 && DlgPosY >= 0 && DlgSizeX > 0 && DlgSizeY > 0 && MsgSplitterX > 0 && ContactSplitterX > 0)
{
RECT rcWorkArea, rcIntersect;
@@ -713,7 +705,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA // init message tree
if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_RECENTMSGSCOUNT) && g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSMRM))
{
- char *szProto = dat->hInitContact ? (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hInitContact, 0) : dat->szProtocol;
+ char *szProto = dat->hInitContact ? GetContactProto(dat->hInitContact) : dat->szProtocol;
int ID = GetRecentGroupID((szProto || !dat->hInitContact) ? g_ProtoStates[szProto].Status : ID_STATUS_AWAY);
CBaseTreeItem* pTreeItem = MsgTree->GetNextItem(MTGN_CHILD | MTGN_BYID, (CBaseTreeItem*)g_Messages_RecentRootID);
while (pTreeItem)
@@ -908,14 +900,14 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA for (I = 0; I < nm->NewSelection->GetSize(); I++)
{
HTREEITEM hItem = (*nm->NewSelection)[I];
- HANDLE hContact;
+ MCONTACT hContact;
char *szProto;
int ItemType = CList->GetItemType(hItem);
if (ItemType == MCLCIT_CONTACT)
{
hContact = CList->GethContact(hItem);
_ASSERT(hContact);
- szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ szProto = GetContactProto(hContact);
_ASSERT(szProto);
} else if (ItemType == MCLCIT_INFO)
{
@@ -973,7 +965,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (nNewContacts == 1)
{
WindowTitle += TCString(TranslateT("\" ("));
- HANDLE hContact = NULL;
+ MCONTACT hContact = NULL;
char *szProto = NULL;
if (CList)
{
@@ -1000,7 +992,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (hContact)
{
- if (IsAnICQProto((char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0))) {
+ if (IsAnICQProto(GetContactProto(hContact))) {
WindowTitle += TranslateT("message for");
WindowTitle += _T(" ");
} else {
@@ -1010,7 +1002,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA WindowTitle += (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
- if (!IsAnICQProto((char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)))
+ if (!IsAnICQProto(GetContactProto(hContact)))
{
//WindowTitle += TranslateT(" (autoreply only)");
WindowTitle += _T(" ");
@@ -1035,7 +1027,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA //ProtoTitle[0] = '\0';
}*/
//ProtoTitle.ReleaseBuffer();
- //WindowTitle += ANSI2TCHAR(ProtoTitle) + TranslateT(" protocol");
+ //WindowTitle += _A2T(ProtoTitle) + TranslateT(" protocol");
PROTOACCOUNT * acc = ProtoGetAccount(szProto);
@@ -1101,7 +1093,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA // init contact tree
HIMAGELIST hil;
- hil = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 5, 2);
+ hil = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 5, 2);
ImageList_AddIcon(hil, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DOT)));
ImageList_AddIcon(hil, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_IGNORE)));
ImageList_AddIcon(hil, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_MSGICON)));
@@ -1113,7 +1105,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA HTREEITEM hItem = hSelItem = CList->AddInfo(TranslateT("** All contacts **"), CLC_ROOT, CLC_ROOT, NULL, LoadSkinnedProtoIcon(NULL, g_ProtoStates[(char*)NULL].Status));
int ProtoCount;
PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&ProtoCount, (LPARAM)&proto);
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
int I;
for (I = 0; I < ProtoCount; I++)
{
@@ -1125,7 +1117,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA PROTOACCOUNT * acc = ProtoGetAccount(proto[I]->szName);
//NightFox: protocols -> accounts
- //hItem = CList->AddInfo(TCString(_T("* ")) + ANSI2TCHAR(ProtoTitle) + TranslateT(" contacts *"), CLC_ROOT, hItem, (LPARAM)proto[I]->szName, LoadSkinnedProtoIcon(proto[I]->szName, g_ProtoStates[proto[I]->szName].Status));
+ //hItem = CList->AddInfo(TCString(_T("* ")) + _A2T(ProtoTitle) + TranslateT(" contacts *"), CLC_ROOT, hItem, (LPARAM)proto[I]->szName, LoadSkinnedProtoIcon(proto[I]->szName, g_ProtoStates[proto[I]->szName].Status));
hItem = CList->AddInfo(TCString(_T("* ")) + acc->tszAccountName/* + TranslateT(" contacts *")*/ + _T(" *"), CLC_ROOT, hItem, (LPARAM)proto[I]->szName, LoadSkinnedProtoIcon(proto[I]->szName, g_ProtoStates[proto[I]->szName].Status));
if (dat->szProtocol && !strcmp(proto[I]->szName, dat->szProtocol))
{
@@ -1134,11 +1126,11 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
}
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ MCONTACT hContact = db_find_first();
CList->SetRedraw(false);
do
{
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ char *szProto = GetContactProto(hContact);
if (szProto)
{
int Flag1 = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
@@ -1151,7 +1143,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
}
}
- } while (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0));
+ } while (hContact = db_find_next(hContact));
CList->SortContacts();
hItem = CLC_ROOT;
while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_CONTACT | MCLGN_INFO | MCLGN_MULTILEVEL, hItem))
@@ -1183,7 +1175,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA // save Recent Messages
int ProtoCount;
PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&ProtoCount, (LPARAM)&proto);
+ CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
int I;
for (I = 0; I < ProtoCount; I++)
{
@@ -1219,12 +1211,12 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA {
RECT rcRect;
GetWindowRect(hwndDlg, &rcRect);
- DBWriteContactSettingDword(NULL, MOD_NAME, SAM_DB_DLGPOSX, rcRect.left);
- DBWriteContactSettingDword(NULL, MOD_NAME, SAM_DB_DLGPOSY, rcRect.top);
- DBWriteContactSettingDword(NULL, MOD_NAME, SAM_DB_DLGSIZEX, rcRect.right - rcRect.left);
- DBWriteContactSettingDword(NULL, MOD_NAME, SAM_DB_DLGSIZEY, rcRect.bottom - rcRect.top);
- DBWriteContactSettingDword(NULL, MOD_NAME, SAM_DB_MSGSPLITTERPOS, g_MsgSplitterX);
- DBWriteContactSettingDword(NULL, MOD_NAME, SAM_DB_CONTACTSPLITTERPOS, g_ContactSplitterX);
+ db_set_dw(NULL, MOD_NAME, SAM_DB_DLGPOSX, rcRect.left);
+ db_set_dw(NULL, MOD_NAME, SAM_DB_DLGPOSY, rcRect.top);
+ db_set_dw(NULL, MOD_NAME, SAM_DB_DLGSIZEX, rcRect.right - rcRect.left);
+ db_set_dw(NULL, MOD_NAME, SAM_DB_DLGSIZEY, rcRect.bottom - rcRect.top);
+ db_set_dw(NULL, MOD_NAME, SAM_DB_MSGSPLITTERPOS, g_MsgSplitterX);
+ db_set_dw(NULL, MOD_NAME, SAM_DB_CONTACTSPLITTERPOS, g_ContactSplitterX);
g_SetAwayMsgPage.PageToMemToDB();
} break;
case UM_SAM_REPLYSETTINGCHANGED:
@@ -1246,8 +1238,8 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA { // it's a contact's autoreply setting
while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_CONTACT | MCLGN_MULTILEVEL, hItem))
{
- HANDLE hContact = CList->GethContact(hItem);
- if (CList->GethContact(hItem) == (HANDLE)wParam)
+ MCONTACT hContact = CList->GethContact(hItem);
+ if (CList->GethContact(hItem) == wParam)
{ // we found the item
SetExtraIcon(CList, EXTRACOLUMN_REPLY, hItem, -1); // update it
break;
diff --git a/plugins/NewAwaySysMod/src/TMyArray.h b/plugins/NewAwaySysMod/src/TMyArray.h new file mode 100644 index 0000000000..68ca908fe1 --- /dev/null +++ b/plugins/NewAwaySysMod/src/TMyArray.h @@ -0,0 +1,353 @@ +/*
+ TMyArray.h - TMyArray template
+ Copyright (c) 2005-2008 Chervov Dmitry
+
+ 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
+*/
+
+#pragma once
+
+#include <stdlib.h>
+
+#define ARRAY_GROWBY 4
+// if there is more than ARRAY_FREETHRESHOLD free array elements, then we're reallocating the array
+#define ARRAY_FREETHRESHOLD 16
+
+template <class T, class ARG_T = const T&, int GrowBy = ARRAY_GROWBY, int FreeThreshold = ARRAY_FREETHRESHOLD>
+class TMyArray
+{
+public:
+ TMyArray();
+ TMyArray(const TMyArray<T, ARG_T, GrowBy, FreeThreshold> &A);
+ ~TMyArray();
+
+ int GetSize() const;
+ T* GetData() const;
+ int AddElem(ARG_T pElem);
+ int Add(const T *pItems, int nItems);
+ void InsertElem(ARG_T pElem, int nInsertAt);
+ void MoveElem(int nIndex, int nMoveTo);
+ T& SetAtGrow(int nIndex);
+ int Find(ARG_T pElem); // returns an index of the specified item, or -1 if the array doesn't contain the item
+ int BinarySearch(int (*CmpFunc)(ARG_T pItem, LPARAM lParam), LPARAM lParam, int *pIndex = NULL); // returns an index of the specified item, or -1 if the array doesn't contain the item;
+ // also it's possible to specify pIndex so that even if the array doesn't contain the item, the function will set *pIndex to a position where the item can be inserted;
+ // CmpFunc must return -1, 0 and 1 depending whether pItem is lesser, equal or greater than needed;
+ // BinarySearch() requires the array to be sorted in an ascending order
+ void RemoveElem(int nIndex, int nItems = 1);
+ void RemoveAll();
+ const T& operator[](int nIndex) const;
+ T& operator[](int nIndex);
+ TMyArray<T, ARG_T, GrowBy, FreeThreshold>& operator = (const TMyArray<T, ARG_T, GrowBy, FreeThreshold> &A);
+ TMyArray<T, ARG_T, GrowBy, FreeThreshold>& operator += (const TMyArray<T, ARG_T, GrowBy, FreeThreshold> &A);
+
+private:
+ int SetAllocNum(int nNewAllocNum);
+
+ T* pData;
+ int nElemNum;
+ int nAllocNum;
+};
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+TMyArray<T, ARG_T, GrowBy, FreeThreshold>::TMyArray()
+{
+ nElemNum = 0;
+ nAllocNum = 0;
+ pData = NULL;
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+TMyArray<T, ARG_T, GrowBy, FreeThreshold>::TMyArray(const TMyArray<T, ARG_T, GrowBy, FreeThreshold> &A)//: TMyArray<T, ARG_T>()
+{
+ nElemNum = 0;
+ nAllocNum = 0;
+ pData = NULL;
+ *this = A;
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+TMyArray<T, ARG_T, GrowBy, FreeThreshold>::~TMyArray()
+{
+ RemoveAll();
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline int TMyArray<T, ARG_T, GrowBy, FreeThreshold>::GetSize() const
+{
+ return nElemNum;
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline T* TMyArray<T, ARG_T, GrowBy, FreeThreshold>::GetData() const
+{
+ return pData;
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline int TMyArray<T, ARG_T, GrowBy, FreeThreshold>::SetAllocNum(int nNewAllocNum)
+{
+ _ASSERT(nNewAllocNum >= nElemNum);
+ T*pNewData = (nNewAllocNum) ? (T*)malloc(sizeof(T) * nNewAllocNum) : NULL;
+ if (pData)
+ {
+ if (pNewData)
+ {
+ memcpy(pNewData, pData, sizeof(T) * nElemNum);
+ }
+ free(pData);
+ }
+ pData = pNewData;
+ if (!pNewData)
+ {
+ nAllocNum = 0;
+ return -1; // not enough memory?
+ } else
+ {
+ nAllocNum = nNewAllocNum;
+ return 0; // everything's ok
+ }
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline int TMyArray<T, ARG_T, GrowBy, FreeThreshold>::AddElem(ARG_T pElem)
+{
+ if (nElemNum >= nAllocNum)
+ { // reallocate memory to fit new element
+ SetAllocNum(nAllocNum + GrowBy);
+ }
+ memset(pData + nElemNum, 0, sizeof(T));
+ pData[nElemNum] = pElem;
+ return nElemNum++;
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline int TMyArray<T, ARG_T, GrowBy, FreeThreshold>::Add(const T *pItems, int nItems)
+{
+ if (nElemNum + nItems > nAllocNum)
+ { // reallocate memory to fit new items
+ SetAllocNum(nAllocNum + nElemNum + nItems - 1 - ((nElemNum + nItems - 1) % GrowBy) + GrowBy);
+ }
+ memset(pData + nElemNum, 0, sizeof(T) * nItems);
+ int I;
+ for (I = 0; I < nItems; I++)
+ {
+ pData[nElemNum++] = pItems[I];
+ }
+ return nElemNum - nItems; // returns an index of the first item added
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline void TMyArray<T, ARG_T, GrowBy, FreeThreshold>::InsertElem(ARG_T pElem, int nInsertAt)
+{
+ _ASSERT(nInsertAt >= 0 && nInsertAt <= nElemNum);
+ if (nElemNum >= nAllocNum)
+ { // reallocate memory to fit new items
+ SetAllocNum(nAllocNum + GrowBy);
+ }
+ memmove(pData + nInsertAt + 1, pData + nInsertAt, sizeof(T) * (nElemNum - nInsertAt));
+ memset(pData + nInsertAt, 0, sizeof(T));
+ pData[nInsertAt] = pElem;
+ nElemNum++;
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline void TMyArray<T, ARG_T, GrowBy, FreeThreshold>::MoveElem(int nIndex, int nMoveTo)
+{
+ _ASSERT(nIndex >= 0 && nIndex < nElemNum && nMoveTo >= 0 && nMoveTo < nElemNum);
+ if (nIndex == nMoveTo)
+ {
+ return; // nothing to do
+ }
+ char Elem[sizeof(T)];
+ memmove(Elem, pData + nIndex, sizeof(T));
+ if (nIndex < nMoveTo)
+ {
+ memmove(pData + nIndex, pData + nIndex + 1, sizeof(T) * (nMoveTo - nIndex));
+ } else
+ {
+ memmove(pData + nMoveTo + 1, pData + nMoveTo, sizeof(T) * (nIndex - nMoveTo));
+ }
+ memmove(pData + nMoveTo, Elem, sizeof(T));
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline T& TMyArray<T, ARG_T, GrowBy, FreeThreshold>::SetAtGrow(int nIndex)
+{
+ _ASSERT(nIndex >= 0);
+ if (nIndex < nElemNum)
+ {
+ return pData[nIndex];
+ }
+ if (nIndex >= nAllocNum)
+ {
+ if (SetAllocNum(nIndex - (nIndex % GrowBy) + GrowBy))
+ { // if there was an error
+ nElemNum = 0;
+ return *pData;
+ }
+ }
+ memset(pData + nElemNum, 0, sizeof(T) * (nIndex - nElemNum + 1));
+ nElemNum = nIndex + 1;
+ return pData[nIndex];
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline int TMyArray<T, ARG_T, GrowBy, FreeThreshold>::Find(ARG_T pElem)
+{
+ int I;
+ for (I = 0; I < nElemNum; I++)
+ {
+ if (pData[I] == pElem)
+ {
+ return I;
+ }
+ }
+ return -1;
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline int TMyArray<T, ARG_T, GrowBy, FreeThreshold>::BinarySearch(int (*CmpFunc)(ARG_T pItem, LPARAM lParam), LPARAM lParam, int *pIndex)
+{
+ int L, R;
+ int CmpResult;
+ if (!nElemNum)
+ {
+ if (pIndex)
+ {
+ *pIndex = -1;
+ }
+ return -1;
+ }
+ for (L = 0, R = nElemNum; R - L > 1;)
+ {
+ int C = (L + R) >> 1; // rounds always to a lesser index if L + R is odd
+ CmpResult = CmpFunc(pData[C], lParam); // usually, CmpFunc = pData[C] - lParam; i.e. CmpFunc > 0 when pData[C] is greater than necessary, < 0 when pData[C] is less, and = 0 when pData[C] is the item we search for
+ if (CmpResult < 0)
+ {
+ L = C;
+ } else if (CmpResult > 0)
+ {
+ R = C;
+ } else
+ { // CmpResult == 0
+ if (pIndex)
+ {
+ *pIndex = C;
+ }
+ return C;
+ }
+ }
+ if (pIndex)
+ {
+ *pIndex = L;
+ }
+ CmpResult = CmpFunc(pData[L], lParam);
+ if (!CmpResult)
+ {
+ return L;
+ }
+ if (CmpResult > 0)
+ { // we don't need to check pData[R], as pData[R] > pData[L] > lParam, i.e. there are no suitable item in the array
+ return -1;
+ }
+// CmpResult < 0, we have to check pData[R] too
+ if (pIndex)
+ {
+ *pIndex = R;
+ }
+ if (R >= nElemNum)
+ {
+ return -1;
+ }
+ return CmpFunc(pData[R], lParam) ? -1 : R;
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline void TMyArray<T, ARG_T, GrowBy, FreeThreshold>::RemoveElem(int nIndex, int nItems)
+{
+ _ASSERT(nIndex >= 0 && nIndex + nItems <= nElemNum);
+ if (!nItems)
+ {
+ return;
+ }
+// delete pData[nIndex];
+// ~pData[nIndex];
+ int I;
+ for (I = nIndex; I < nIndex + nItems; I++)
+ {
+ (pData + I)->~T();
+ }
+ memmove(pData + nIndex, pData + nIndex + nItems, sizeof(T) * (nElemNum - nIndex - nItems));
+ nElemNum -= nItems;
+ if (nAllocNum - nElemNum >= FreeThreshold)
+ {
+ SetAllocNum(nAllocNum - FreeThreshold);
+ }/* else
+ {
+ memset(pData + nElemNum, 0, sizeof(T));
+ }*/
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline void TMyArray<T, ARG_T, GrowBy, FreeThreshold>::RemoveAll()
+{
+ int I;
+ for (I = 0; I < nElemNum; I++)
+ {
+ //delete pData[I];
+ (pData + I)->~T();
+ }
+ nElemNum = 0;
+ SetAllocNum(0);
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline const T& TMyArray<T, ARG_T, GrowBy, FreeThreshold>::operator[](int nIndex) const
+{
+ _ASSERT(nIndex >= 0 && nIndex < nElemNum);
+ return pData[nIndex];
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline T& TMyArray<T, ARG_T, GrowBy, FreeThreshold>::operator[](int nIndex)
+{
+ _ASSERT(nIndex >= 0 && nIndex < nElemNum);
+ return pData[nIndex];
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline TMyArray<T, ARG_T, GrowBy, FreeThreshold>& TMyArray<T, ARG_T, GrowBy, FreeThreshold>::operator = (const TMyArray<T, ARG_T, GrowBy, FreeThreshold> &A)
+{
+ RemoveAll();
+ int I;
+ for (I = 0; I < A.GetSize(); I++)
+ {
+ AddElem(A[I]);
+ }
+ return *this;
+}
+
+template <class T, class ARG_T, int GrowBy, int FreeThreshold>
+__forceinline TMyArray<T, ARG_T, GrowBy, FreeThreshold>& TMyArray<T, ARG_T, GrowBy, FreeThreshold>::operator += (const TMyArray<T, ARG_T, GrowBy, FreeThreshold> &A)
+{
+ int I;
+ for (I = 0; I < A.GetSize(); I++)
+ {
+ AddElem(A[I]);
+ }
+ return *this;
+}
+
+typedef TMyArray<char, const char&, 1024, 4096> CHARARRAY;
diff --git a/plugins/!Deprecated/NewAwaySysMod/resource.h b/plugins/NewAwaySysMod/src/resource.h index 1c6190554b..1c6190554b 100644 --- a/plugins/!Deprecated/NewAwaySysMod/resource.h +++ b/plugins/NewAwaySysMod/src/resource.h diff --git a/plugins/!Deprecated/NewAwaySysMod/VersionNo.h b/plugins/NewAwaySysMod/src/version.h index 3634e99662..3634e99662 100644 --- a/plugins/!Deprecated/NewAwaySysMod/VersionNo.h +++ b/plugins/NewAwaySysMod/src/version.h |