diff options
Diffstat (limited to 'plugins')
284 files changed, 65702 insertions, 28 deletions
diff --git a/plugins/MetaContacts/src/meta_main.cpp b/plugins/MetaContacts/src/meta_main.cpp index 5e4cea2186..5ff2d14878 100644 --- a/plugins/MetaContacts/src/meta_main.cpp +++ b/plugins/MetaContacts/src/meta_main.cpp @@ -211,7 +211,7 @@ extern "C" __declspec(dllexport) int Load(void) CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
pd.szName = META_PROTO;
- pd.type = PROTOTYPE_PROTOCOL;
+ pd.type = PROTOTYPE_VIRTUAL;
CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
// further db setup done in modules loaded (nick [protocol string required] & clist display name)
diff --git a/plugins/NewsAggregator/NewsAggregator_10.vcxproj b/plugins/NewsAggregator/NewsAggregator_10.vcxproj new file mode 100644 index 0000000000..78450a3189 --- /dev/null +++ b/plugins/NewsAggregator/NewsAggregator_10.vcxproj @@ -0,0 +1,199 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>NewsAggregator</ProjectName>
+ <ProjectGuid>{6DE11A47-2268-4B08-8DE5-15A1705FCE28}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NEWSAGGREGATOR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <DisableSpecificWarnings>4996</DisableSpecificWarnings>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>Common.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <AdditionalDependencies>comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;NEWSAGGREGATOR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DisableSpecificWarnings>4996</DisableSpecificWarnings>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>Common.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NEWSAGGREGATOR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ <DisableSpecificWarnings>4996</DisableSpecificWarnings>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>Common.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;NEWSAGGREGATOR_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <WarningLevel>Level3</WarningLevel>
+ <DisableSpecificWarnings>4996</DisableSpecificWarnings>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>Common.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>comdlg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\Resource.rc" />
+ <ResourceCompile Include="res\Version.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h" />
+ <ClInclude Include="Src\Common.h" />
+ <ClInclude Include="src\Version.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="Src\Icons.cpp" />
+ <ClCompile Include="Src\Menus.cpp" />
+ <ClCompile Include="Src\Options.cpp" />
+ <ClCompile Include="Src\Stdafx.cpp">
+ <PrecompiledHeader>Create</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="Src\Services.cpp" />
+ <ClCompile Include="Src\NewsAggregator.cpp" />
+ <ClCompile Include="Src\Update.cpp" />
+ <ClCompile Include="Src\Utils.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/NewsAggregator/NewsAggregator_10.vcxproj.filters b/plugins/NewsAggregator/NewsAggregator_10.vcxproj.filters new file mode 100644 index 0000000000..e02b0ce97e --- /dev/null +++ b/plugins/NewsAggregator/NewsAggregator_10.vcxproj.filters @@ -0,0 +1,62 @@ +<?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>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\Version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ <ResourceCompile Include="res\Resource.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\Version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Src\Common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="Src\Options.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Src\Menus.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Src\Services.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Src\Icons.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Src\Update.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Src\Utils.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Src\NewsAggregator.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Src\Stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/NewsAggregator/Res/AddFeed.ico b/plugins/NewsAggregator/Res/AddFeed.ico Binary files differnew file mode 100644 index 0000000000..2503d8ec60 --- /dev/null +++ b/plugins/NewsAggregator/Res/AddFeed.ico diff --git a/plugins/NewsAggregator/Res/CheckALL.ico b/plugins/NewsAggregator/Res/CheckALL.ico Binary files differnew file mode 100644 index 0000000000..98d434b2ba --- /dev/null +++ b/plugins/NewsAggregator/Res/CheckALL.ico diff --git a/plugins/NewsAggregator/Res/Export.ico b/plugins/NewsAggregator/Res/Export.ico Binary files differnew file mode 100644 index 0000000000..ef475bb5cd --- /dev/null +++ b/plugins/NewsAggregator/Res/Export.ico diff --git a/plugins/NewsAggregator/Res/Import.ico b/plugins/NewsAggregator/Res/Import.ico Binary files differnew file mode 100644 index 0000000000..4becddf394 --- /dev/null +++ b/plugins/NewsAggregator/Res/Import.ico diff --git a/plugins/NewsAggregator/Res/Main.ico b/plugins/NewsAggregator/Res/Main.ico Binary files differnew file mode 100644 index 0000000000..4e9d1abc51 --- /dev/null +++ b/plugins/NewsAggregator/Res/Main.ico diff --git a/plugins/NewsAggregator/Res/Resource.rc b/plugins/NewsAggregator/Res/Resource.rc new file mode 100644 index 0000000000..ccfef31466 --- /dev/null +++ b/plugins/NewsAggregator/Res/Resource.rc @@ -0,0 +1,148 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "..\src\resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Ðóññêèé (Ðîññèÿ) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON ICON "Main.ico"
+IDI_CHECKALL ICON "CheckAll.ico"
+IDI_ADDFEED ICON "AddFeed.ico"
+IDI_IMPORTFEEDS ICON "Import.ico"
+IDI_EXPORTFEEDS ICON "Export.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPTIONS DIALOGEX 0, 0, 314, 234
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "",IDC_FEEDLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_TABSTOP,9,8,294,174
+ PUSHBUTTON "Add",IDC_ADD,79,187,50,14
+ PUSHBUTTON "Change",IDC_CHANGE,133,187,50,14
+ PUSHBUTTON "Remove",IDC_REMOVE,187,187,50,14
+ PUSHBUTTON "Import",IDC_IMORT,252,204,50,14
+ PUSHBUTTON "Export",IDC_EXORT,252,219,50,14
+END
+
+IDD_ADDFEED DIALOGEX 0, 0, 250, 228
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_NOFAILCREATE | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,140,209,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,194,209,50,14
+ GROUPBOX "General Settings",IDC_STATIC,6,3,238,61
+ RTEXT "Title",IDC_STATIC,17,16,44,8
+ EDITTEXT IDC_FEEDTITLE,63,14,173,13,ES_AUTOHSCROLL
+ RTEXT "URL",IDC_STATIC,17,31,44,8
+ EDITTEXT IDC_FEEDURL,63,29,173,13,ES_AUTOHSCROLL
+ RTEXT "Check every",IDC_STATIC,7,46,54,8
+ LTEXT "minutes",IDC_STATIC,100,46,75,8
+ PUSHBUTTON "Check Feed",IDC_DISCOVERY,177,44,59,12
+ GROUPBOX "Authentication",IDC_STATIC,6,67,238,48
+ CONTROL "Use &authentication",IDC_USEAUTH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,80,157,10
+ RTEXT "Login",IDC_STATIC,16,96,42,8
+ EDITTEXT IDC_LOGIN,61,94,63,14,ES_AUTOHSCROLL | WS_DISABLED
+ RTEXT "Password",IDC_STATIC,129,96,41,8
+ EDITTEXT IDC_PASSWORD,173,94,63,14,ES_PASSWORD | ES_AUTOHSCROLL | WS_DISABLED
+ GROUPBOX "Visualization",IDC_STATIC,6,119,238,85
+ LTEXT "Display news using the following format:",IDC_STATIC,13,132,168,8
+ EDITTEXT IDC_TAGSEDIT,13,143,224,36,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
+ LTEXT "All item's tags are valid. Put them between #. Example: #<author>#",IDC_STATIC,14,182,167,16
+ PUSHBUTTON "Reset",IDC_RESET,192,184,45,14
+ PUSHBUTTON "?",IDC_TAGHELP,175,184,15,14
+ LTEXT "0 - check manually",IDC_STATIC,100,55,79,8
+ EDITTEXT IDC_CHECKTIME,64,45,32,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_TIMEOUT_VALUE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,85,45,11,12
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "..\\src\\resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPTIONS, DIALOG
+ BEGIN
+ BOTTOMMARGIN, 189
+ END
+
+ IDD_ADDFEED, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 241
+ TOPMARGIN, 7
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // Ðóññêèé (Ðîññèÿ) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/NewsAggregator/Res/Version.rc b/plugins/NewsAggregator/Res/Version.rc new file mode 100644 index 0000000000..d741488c4f --- /dev/null +++ b/plugins/NewsAggregator/Res/Version.rc @@ -0,0 +1,42 @@ +// Microsoft Visual C++ generated resource script.
+//
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+#include "afxres.h"
+#include "..\src\version.h"
+
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#endif //_WIN32
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "FileDescription", __DESCRIPTION
+ VALUE "InternalName", __PLUGIN_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ VALUE "ProductName", __PLUGIN_NAME
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
diff --git a/plugins/NewsAggregator/Src/Common.h b/plugins/NewsAggregator/Src/Common.h new file mode 100644 index 0000000000..953229080d --- /dev/null +++ b/plugins/NewsAggregator/Src/Common.h @@ -0,0 +1,162 @@ +/*
+Copyright (C) 2012 Mataes
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+#define MIRANDA_VER 0x0A00
+
+// Windows Header Files:
+#include <windows.h>
+#include <commctrl.h>
+#include <time.h>
+#include <fcntl.h>
+#include <io.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys\stat.h>
+#include <mshtml.h>
+
+// Miranda header files
+#include <newpluginapi.h>
+#include <m_clist.h>
+#include <m_skin.h>
+#include <m_langpack.h>
+#include <m_options.h>
+#include <m_database.h>
+#include <m_utils.h>
+#include <m_system.h>
+#include <m_popup.h>
+#include <m_hotkeys.h>
+#include <m_netlib.h>
+#include <m_icolib.h>
+#include <m_message.h>
+#include <win2k.h>
+#include <m_protocols.h>
+#include <m_protomod.h>
+#include <m_protosvc.h>
+#include <m_xml.h>
+#include <m_avatars.h>
+
+#include <m_folders.h>
+#include <m_popup.h>
+
+#include "version.h"
+#include "resource.h"
+
+#define MODULE "NewsAggr"
+#define TAGSHELP "#<title># - The title of the item.\r\n#<description># - The item synopsis.\r\n#<link># - The URL of the item.\r\n#<author># - Email address of the author of the item.\r\n#<comments># - URL of a page for comments relating to the item.\r\n#<guid># - A string that uniquely identifies the item.\r\n#<category># - Specify one or more categories that the item belongs to."
+#define TAGSDEFAULT "#<title>#\r\n#<link>#\r\n#<description>#"
+#define DEFAULT_AVATARS_FOLDER "NewsAggregator"
+extern HINSTANCE hInst;
+extern HWND hAddFeedDlg;
+extern HANDLE hChangeFeedDlgList;
+extern UINT_PTR timerId;
+// check if Feeds is currently updating
+extern BOOL ThreadRunning;
+extern BOOL UpdateListFlag;
+extern TCHAR tszRoot[MAX_PATH];
+struct ItemInfo
+{
+ HWND hwndList;
+ HANDLE hContact;
+ int SelNumber;
+ TCHAR nick[MAX_PATH];
+ TCHAR url[MAX_PATH];
+};
+
+//============ STRUCT USED TO MAKE AN UPDATE LIST ============
+
+struct NEWSCONTACTLIST {
+ HANDLE hContact;
+ struct NEWSCONTACTLIST *next;
+};
+
+typedef struct NEWSCONTACTLIST UPDATELIST;
+
+extern UPDATELIST *UpdateListHead;
+extern UPDATELIST *UpdateListTail;
+
+void UpdateListAdd(HANDLE hContact);
+void UpdateThreadProc(LPVOID hWnd);
+void DestroyUpdateList(void);
+
+extern HANDLE hUpdateMutex;
+
+int NewsAggrInit(WPARAM wParam,LPARAM lParam);
+INT OptInit(WPARAM wParam, LPARAM lParam);
+int NewsAggrPreShutdown(WPARAM wParam,LPARAM lParam);
+VOID NetlibInit();
+VOID NetlibUnInit();
+VOID InitMenu();
+VOID InitIcons();
+HICON LoadIconEx(const char* name, BOOL big);
+HANDLE GetIconHandle(const char* name);
+INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam);
+INT_PTR NewsAggrGetCaps(WPARAM wp, LPARAM lp);
+INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM /*lp*/);
+INT_PTR NewsAggrGetStatus(WPARAM/* wp*/, LPARAM/* lp*/);
+INT_PTR NewsAggrLoadIcon(WPARAM wParam, LPARAM lParam);
+INT_PTR NewsAggrGetInfo(WPARAM wParam, LPARAM lParam);
+INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam);
+INT_PTR NewsAggrRecvMessage(WPARAM wParam,LPARAM lParam);
+
+INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam);
+INT_PTR AddFeed(WPARAM wParam,LPARAM lParam);
+INT_PTR ChangeFeed(WPARAM wParam,LPARAM lParam);
+INT_PTR ImportFeeds(WPARAM wParam,LPARAM lParam);
+INT_PTR ExportFeeds(WPARAM wParam,LPARAM lParam);
+INT_PTR CheckFeed(WPARAM wParam,LPARAM lParam);
+INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
+VOID CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
+
+BOOL IsMyContact(HANDLE hContact);
+VOID GetNewsData(TCHAR *szUrl, char** szData, HANDLE hContact, HWND hwndDlg);
+VOID CreateList (HWND hwndList);
+VOID UpdateList (HWND hwndList);
+VOID DeleteAllItems(HWND hwndList);
+time_t __stdcall DateToUnixTime(TCHAR *stamp, BOOL FeedType);
+VOID CheckCurrentFeed (HANDLE hContact);
+TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg);
+
+// =============== NewsAggr SERVICES ================
+// Check all Feeds info
+// WPARAM = LPARAM = NULL
+#define MS_NEWSAGGR_CHECKALLFEEDS "NEWSAGGR/CheckAllFeeds"
+
+// Add new Feed channel
+// WPARAM = LPARAM = NULL
+#define MS_NEWSAGGR_ADDFEED "NEWSAGGR/AddNewsFeed"
+
+// Add new Feed channel
+// WPARAM = LPARAM = NULL
+#define MS_NEWSAGGR_CHANGEFEED "NEWSAGGR/ChangeNewsFeed"
+
+// Import Feed chanels from file
+// WPARAM = LPARAM = NULL
+#define MS_NEWSAGGR_IMPORTFEEDS "NEWSAGGR/ImportFeeds"
+
+// Export Feed chanels to file
+// WPARAM = LPARAM = NULL
+#define MS_NEWSAGGR_EXPORTFEEDS "NEWSAGGR/ExportFeeds"
+
+// Check Feed info
+// WPARAM = LPARAM = NULL
+#define MS_NEWSAGGR_CHECKFEED "NEWSAGGR/CheckFeed"
\ No newline at end of file diff --git a/plugins/NewsAggregator/Src/Icons.cpp b/plugins/NewsAggregator/Src/Icons.cpp new file mode 100644 index 0000000000..5cd94ff76d --- /dev/null +++ b/plugins/NewsAggregator/Src/Icons.cpp @@ -0,0 +1,79 @@ +/*
+Copyright (C) 2012 Mataes
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+struct _tag_iconList
+{
+ TCHAR* szDescr;
+ char* szName;
+ int defIconID;
+ HANDLE hIconLibItem;
+}
+
+static iconList[] =
+{
+ { LPGENT("Protocol icon"), "main", IDI_ICON },
+ { LPGENT("Check All Feeds"), "checkall", IDI_CHECKALL },
+ { LPGENT("Add Feed"), "addfeed", IDI_ADDFEED },
+ { LPGENT("Import Feeds"), "importfeeds", IDI_IMPORTFEEDS },
+ { LPGENT("Export Feeds"), "exportfeeds", IDI_EXPORTFEEDS },
+ { LPGENT("Check Feed"), "checkfeed", IDI_CHECKALL },
+};
+
+VOID InitIcons()
+{
+ TCHAR szFile[MAX_PATH];
+ char szSettingName[100];
+ SKINICONDESC sid = {0};
+ unsigned i;
+
+ GetModuleFileName(hInst, szFile, MAX_PATH);
+
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.flags = SIDF_ALL_TCHAR;
+ sid.ptszDefaultFile = szFile;
+ sid.pszName = szSettingName;
+ sid.ptszSection = _T("News Aggregator");
+
+ for (i = 0; i < SIZEOF(iconList); i++)
+ {
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, iconList[i].szName);
+
+ sid.ptszDescription = iconList[i].szDescr;
+ sid.iDefaultIndex = -iconList[i].defIconID;
+ iconList[i].hIconLibItem = Skin_AddIcon(&sid);
+ }
+}
+
+HICON LoadIconEx(const char* name, BOOL big)
+{
+ char szSettingName[100];
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, name);
+ return Skin_GetIcon(szSettingName, big);
+}
+
+HANDLE GetIconHandle(const char* name)
+{
+ unsigned i;
+ for (i=0; i < SIZEOF(iconList); i++)
+ if (strcmp(iconList[i].szName, name) == 0)
+ return iconList[i].hIconLibItem;
+ return NULL;
+}
\ No newline at end of file diff --git a/plugins/NewsAggregator/Src/Menus.cpp b/plugins/NewsAggregator/Src/Menus.cpp new file mode 100644 index 0000000000..62a5da045d --- /dev/null +++ b/plugins/NewsAggregator/Src/Menus.cpp @@ -0,0 +1,78 @@ +/*
+Copyright (C) 2012 Mataes
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+HANDLE hService2[6];
+
+VOID InitMenu()
+{
+ CLISTMENUITEM mi = {0};
+ mi.cbSize = sizeof(mi);
+ mi.pszContactOwner = MODULE;
+ mi.flags = CMIF_TCHAR|CMIF_ICONFROMICOLIB|CMIF_NOTOFFLINE;
+
+ // adding main menu items
+ mi.ptszPopupName = LPGENT("News Aggregator");
+ mi.popupPosition = 500099000;
+
+ mi.position=10100001;
+ mi.icolibItem = GetIconHandle("main");
+ mi.ptszName = LPGENT("Check All Feeds");
+ mi.pszService = MS_NEWSAGGR_CHECKALLFEEDS;
+ hService2[0] = Menu_AddMainMenuItem(&mi);
+
+ mi.position=10100002;
+ mi.icolibItem = GetIconHandle("addfeed");
+ mi.ptszName = LPGENT("Add Feed");
+ mi.pszService = MS_NEWSAGGR_ADDFEED;
+ hService2[1] = Menu_AddMainMenuItem(&mi);
+
+ mi.position=10100003;
+ mi.icolibItem = GetIconHandle("importfeeds");
+ mi.ptszName = LPGENT("Import Feeds");
+ mi.pszService = MS_NEWSAGGR_IMPORTFEEDS;
+ hService2[2] = Menu_AddMainMenuItem(&mi);
+
+ mi.position=10100004;
+ mi.icolibItem = GetIconHandle("exportfeeds");
+ mi.ptszName = LPGENT("Export Feeds");
+ mi.pszService = MS_NEWSAGGR_EXPORTFEEDS;
+ hService2[3] = Menu_AddMainMenuItem(&mi);
+
+ // adding contact menu items
+ mi.position=-0x7FFFFFFA;
+ mi.icolibItem = GetIconHandle("checkfeed");
+ mi.ptszName = LPGENT("Check feed");
+ mi.pszService = MS_NEWSAGGR_CHECKFEED;
+ hService2[4] = Menu_AddContactMenuItem(&mi);
+
+ // adding contact menu items
+ mi.position=-0x7FFFFFFA;
+ //mi.icolibItem = GetIconHandle("checkfeed");
+ mi.ptszName = LPGENT("Change feed");
+ mi.pszService = MS_NEWSAGGR_CHANGEFEED;
+ hService2[5] = Menu_AddContactMenuItem(&mi);
+
+ ZeroMemory(&mi, sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_ICON;
+ mi.icolibItem = GetIconHandle("checkall");
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hService2[0], (LPARAM)&mi);
+}
\ No newline at end of file diff --git a/plugins/NewsAggregator/Src/NewsAggregator.cpp b/plugins/NewsAggregator/Src/NewsAggregator.cpp new file mode 100644 index 0000000000..57795ac15d --- /dev/null +++ b/plugins/NewsAggregator/Src/NewsAggregator.cpp @@ -0,0 +1,126 @@ +/*
+Copyright (C) 2012 Mataes
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+#include "Common.h"
+
+HINSTANCE hInst = NULL;
+
+int hLangpack;
+HANDLE hOptHook = NULL, hLoadHook = NULL, hOnPreShutdown = NULL, hPrebuildMenuHook = NULL, hPackUpdaterFolder = NULL;
+HANDLE hProtoService[8];
+HWND hAddFeedDlg;
+HANDLE hChangeFeedDlgList = NULL;
+XML_API xi = {0};
+TCHAR tszRoot[MAX_PATH] = {0};
+HANDLE hUpdateMutex;
+#define NUM_SERVICES 6
+HANDLE hService[NUM_SERVICES];
+
+PLUGININFOEX pluginInfoEx = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {56CC3F29-CCBF-4546-A8BA-9856248A412A}
+ {0x56cc3f29, 0xccbf, 0x4546, {0xa8, 0xba, 0x98, 0x56, 0x24, 0x8a, 0x41, 0x2a}}
+};
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ hInst = hinstDLL;
+ return TRUE;
+}
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfoEx;
+}
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {{0x29517be5, 0x779a, 0x48e5, {0x89, 0x50, 0xcb, 0x4d, 0xe1, 0xd4, 0x31, 0x72}}, MIID_LAST};
+
+extern "C" __declspec(dllexport) int Load(void)
+{
+
+ mir_getLP(&pluginInfoEx);
+ mir_getXI(&xi);
+
+ if (ServiceExists(MS_FOLDERS_REGISTER_PATH))
+ {
+ hPackUpdaterFolder = FoldersRegisterCustomPathT("News Aggregator", "Avatars", MIRANDA_USERDATAT _T("\\Avatars\\")_T(DEFAULT_AVATARS_FOLDER));
+ FoldersGetCustomPathT(hPackUpdaterFolder, tszRoot, MAX_PATH, _T(""));
+ }
+ else
+ {
+ TCHAR* tszFolder = Utils_ReplaceVarsT(_T("%miranda_userdata%\\"_T(DEFAULT_AVATARS_FOLDER)));
+ lstrcpyn(tszRoot, tszFolder, SIZEOF(tszRoot));
+ mir_free(tszFolder);
+ }
+
+ // Add options hook
+ hOptHook = HookEvent(ME_OPT_INITIALISE, OptInit);
+ hLoadHook = HookEvent(ME_SYSTEM_MODULESLOADED, NewsAggrInit);
+ hOnPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, NewsAggrPreShutdown);
+
+ hUpdateMutex = CreateMutex(NULL, FALSE, NULL);
+ hChangeFeedDlgList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
+
+ // register weather protocol
+ PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
+ pd.szName = MODULE;
+ pd.type = PROTOTYPE_VIRTUAL;
+ CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
+
+ hProtoService[0] = CreateProtoServiceFunction(MODULE, PS_GETNAME, NewsAggrGetName);
+ hProtoService[1] = CreateProtoServiceFunction(MODULE, PS_GETCAPS, NewsAggrGetCaps);
+ hProtoService[2] = CreateProtoServiceFunction(MODULE, PS_SETSTATUS, NewsAggrSetStatus);
+ hProtoService[3] = CreateProtoServiceFunction(MODULE, PS_GETSTATUS, NewsAggrGetStatus);
+ hProtoService[4] = CreateProtoServiceFunction(MODULE, PS_LOADICON, NewsAggrLoadIcon);
+ hProtoService[5] = CreateProtoServiceFunction(MODULE, PSS_GETINFO, NewsAggrGetInfo);
+ hProtoService[6] = CreateProtoServiceFunction(MODULE, PS_GETAVATARINFOT, NewsAggrGetAvatarInfo);
+ hProtoService[7] = CreateProtoServiceFunction(MODULE, PSR_MESSAGE, NewsAggrRecvMessage);
+
+ hService[0] = CreateServiceFunction(MS_NEWSAGGR_CHECKALLFEEDS, CheckAllFeeds);
+ hService[1] = CreateServiceFunction(MS_NEWSAGGR_ADDFEED, AddFeed);
+ hService[2] = CreateServiceFunction(MS_NEWSAGGR_IMPORTFEEDS, ImportFeeds);
+ hService[3] = CreateServiceFunction(MS_NEWSAGGR_EXPORTFEEDS, ExportFeeds);
+ hService[4] = CreateServiceFunction(MS_NEWSAGGR_CHECKFEED, CheckFeed);
+ hService[5] = CreateServiceFunction(MS_NEWSAGGR_CHANGEFEED, ChangeFeed);
+
+ return 0;
+}
+
+extern "C" __declspec(dllexport) int Unload(void)
+{
+ for (int i = 0;i<NUM_SERVICES;i++)
+ DestroyServiceFunction(hService[i]);
+
+ UnhookEvent(hOptHook);
+ UnhookEvent(hLoadHook);
+ UnhookEvent(hOnPreShutdown);
+
+ DestroyUpdateList();
+ CloseHandle(hUpdateMutex);
+
+ return 0;
+}
\ No newline at end of file diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp new file mode 100644 index 0000000000..4869867d9a --- /dev/null +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -0,0 +1,651 @@ +/*
+Copyright (C) 2012 Mataes
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ SetWindowText(hwndDlg, TranslateT("Add Feed"));
+ SetDlgItemText(hwndDlg, IDC_FEEDURL, _T("http://"));
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
+ SendDlgItemMessage(hwndDlg, IDC_CHECKTIME, EM_LIMITTEXT, 3, 0);
+ SetDlgItemInt(hwndDlg, IDC_CHECKTIME, 60, TRUE);
+ SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999);
+ Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,MODULE,"AddDlg");
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ {
+ TCHAR str[MAX_PATH];
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str)))
+ {
+ MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else if (!GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)) || lstrcmp(str, _T("http://")) == 0)
+ {
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else if (GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false) < 0)
+ {
+ MessageBox(hwndDlg, TranslateT("Enter checking interval"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else if (!GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str)))
+ {
+ MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else
+ {
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)MODULE);
+ GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "Nick", str);
+ HWND hwndList = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "URL", str);
+ DBWriteContactSettingByte(hContact, MODULE, "CheckState", 1);
+ DBWriteContactSettingDword(hContact, MODULE, "UpdateTime", GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false));
+ GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "MsgFormat", str);
+ DBWriteContactSettingWord(hContact, MODULE, "Status", CallProtoService(MODULE, PS_GETSTATUS, 0, 0));
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
+ {
+ DBWriteContactSettingByte(hContact, MODULE, "UseAuth", 1);
+ GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "Login", str);
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "Password", str);
+ }
+ DeleteAllItems(hwndList);
+ UpdateList(hwndList);
+ }
+ }
+
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case IDC_USEAUTH:
+ {
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ }
+ else
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
+ }
+ }
+ break;
+
+ case IDC_TAGHELP:
+ MessageBox(hwndDlg, TranslateT(TAGSHELP), TranslateT("Feed Tag Help"), MB_OK);
+ break;
+
+ case IDC_RESET:
+ if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Tags Mask Reset"), MB_YESNO | MB_ICONWARNING) == IDYES)
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
+ break;
+
+ case IDC_DISCOVERY:
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait..."));
+ TCHAR tszURL[MAX_PATH] = {0}, *tszTitle = NULL;
+ if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0)
+ tszTitle = CheckFeed(tszURL, hwndDlg);
+ else
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed"));
+ }
+ break;
+ }
+ break;
+ }
+ case WM_CLOSE:
+ {
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ case WM_DESTROY:
+ {
+ Utils_SaveWindowPosition(hwndDlg,NULL,MODULE,"AddDlg");
+ }
+ }
+
+ return FALSE;
+}
+
+INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ ItemInfo &SelItem = *(ItemInfo*)lParam;
+ ItemInfo *nSelItem = new ItemInfo(SelItem);
+ SetWindowText(hwndDlg, TranslateT("Change Feed"));
+ SendDlgItemMessage(hwndDlg, IDC_CHECKTIME, EM_LIMITTEXT, 3, 0);
+ SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999);
+
+ HANDLE hContact = db_find_first();
+ while (hContact != NULL)
+ {
+ if (IsMyContact(hContact))
+ {
+ DBVARIANT dbNick = {0};
+ if (DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
+ continue;
+ else if (lstrcmp(dbNick.ptszVal, SelItem.nick) == 0)
+ {
+ DBFreeVariant(&dbNick);
+ DBVARIANT dbURL = {0};
+ if (DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
+ continue;
+ else if (lstrcmp(dbURL.ptszVal, SelItem.url) == 0)
+ {
+ DBFreeVariant(&dbURL);
+ nSelItem->hContact = hContact;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem);
+ SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url);
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick);
+ SetDlgItemInt(hwndDlg, IDC_CHECKTIME, DBGetContactSettingDword(hContact, MODULE, "UpdateTime", 60), TRUE);
+ DBVARIANT dbMsg = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "MsgFormat", &dbMsg))
+ {
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
+ DBFreeVariant(&dbMsg);
+ }
+ if (DBGetContactSettingByte(hContact, MODULE, "UseAuth", 0))
+ {
+ CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ DBVARIANT dbLogin = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "Login", &dbLogin))
+ {
+ SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
+ DBFreeVariant(&dbLogin);
+ }
+ DBVARIANT dbPass = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "Password", &dbPass))
+ {
+ SetDlgItemText(hwndDlg, IDC_PASSWORD, dbPass.ptszVal);
+ DBFreeVariant(&dbPass);
+ }
+ }
+ break;
+ }
+ DBFreeVariant(&dbURL);
+ }
+ DBFreeVariant(&dbNick);
+ }
+ hContact = db_find_next(hContact);
+ }
+ WindowList_Add(hChangeFeedDlgList,hwndDlg,hContact);
+ Utils_RestoreWindowPositionNoSize(hwndDlg,hContact,MODULE,"ChangeDlg");
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ {
+ ItemInfo *SelItem = (ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ TCHAR str[MAX_PATH];
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str)))
+ {
+ MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else if (!GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)) || lstrcmp(str, _T("http://")) == 0)
+ {
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else if (GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false) < 0)
+ {
+ MessageBox(hwndDlg, TranslateT("Enter checking interval"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else if (!GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str)))
+ {
+ MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else
+ {
+ GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str));
+ DBWriteContactSettingTString(SelItem->hContact, MODULE, "URL", str);
+ GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str));
+ DBWriteContactSettingTString(SelItem->hContact, MODULE, "Nick", str);
+ DBWriteContactSettingDword(SelItem->hContact, MODULE, "UpdateTime", GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false));
+ GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str));
+ DBWriteContactSettingTString(SelItem->hContact, MODULE, "MsgFormat", str);
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
+ {
+ DBWriteContactSettingByte(SelItem->hContact, MODULE, "UseAuth", 1);
+ GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
+ DBWriteContactSettingTString(SelItem->hContact, MODULE, "Login", str);
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
+ DBWriteContactSettingTString(SelItem->hContact, MODULE, "Password", str);
+ }
+ DeleteAllItems(SelItem->hwndList);
+ UpdateList(SelItem->hwndList);
+ }
+ }
+
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case IDC_USEAUTH:
+ {
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ }
+ else
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
+ }
+ break;
+ }
+
+ case IDC_TAGHELP:
+ MessageBox(hwndDlg, TranslateT(TAGSHELP), TranslateT("Feed Tag Help"), MB_OK);
+ break;
+
+ case IDC_RESET:
+ if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Tags Mask Reset"), MB_YESNO | MB_ICONWARNING) == IDYES)
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
+ break;
+
+ case IDC_DISCOVERY:
+ {
+ TCHAR tszURL[MAX_PATH] = {0};
+ if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0)
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait..."));
+ TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg);
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed"));
+ }
+ else
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
+ }
+ break;
+ }
+ break;
+ }
+
+ case WM_CLOSE:
+ {
+ DestroyWindow(hwndDlg);
+ break;
+ }
+
+ case WM_DESTROY:
+ {
+ HANDLE hContact = (HANDLE) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Utils_SaveWindowPosition(hwndDlg,hContact,MODULE,"ChangeDlg");
+ WindowList_Remove(hChangeFeedDlgList,hwndDlg);
+ ItemInfo *SelItem = (ItemInfo*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ delete SelItem;
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
+INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ SetWindowText(hwndDlg, TranslateT("Change Feed"));
+ SendDlgItemMessage(hwndDlg, IDC_CHECKTIME, UDM_SETRANGE32, 0, 999);
+
+ HANDLE hContact = (HANDLE)lParam;
+ WindowList_Add(hChangeFeedDlgList,hwndDlg,hContact);
+ Utils_RestoreWindowPositionNoSize(hwndDlg,hContact,MODULE,"ChangeDlg");
+ DBVARIANT dbNick = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
+ {
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, dbNick.ptszVal);
+ DBFreeVariant(&dbNick);
+ DBVARIANT dbURL = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
+ {
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)lParam);
+ SetDlgItemText(hwndDlg, IDC_FEEDURL, dbURL.ptszVal);
+ DBFreeVariant(&dbURL);
+ SetDlgItemInt(hwndDlg, IDC_CHECKTIME, DBGetContactSettingDword(hContact, MODULE, "UpdateTime", 60), TRUE);
+ DBVARIANT dbMsg = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "MsgFormat", &dbMsg))
+ {
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
+ DBFreeVariant(&dbMsg);
+ }
+ if (DBGetContactSettingByte(hContact, MODULE, "UseAuth", 0))
+ {
+ CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ DBVARIANT dbLogin = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "Login", &dbLogin))
+ {
+ SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
+ DBFreeVariant(&dbLogin);
+ }
+ DBVARIANT dbPass = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "Password", &dbPass))
+ {
+ SetDlgItemText(hwndDlg, IDC_PASSWORD, dbPass.ptszVal);
+ DBFreeVariant(&dbPass);
+ }
+ }
+ break;
+ }
+ }
+ return TRUE;
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ {
+ HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ TCHAR str[MAX_PATH];
+ if (!GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str)))
+ {
+ MessageBox(hwndDlg, TranslateT("Enter Feed name"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else if (!GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str)) || lstrcmp(str, _T("http://")) == 0)
+ {
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else if (GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false) < 0)
+ {
+ MessageBox(hwndDlg, TranslateT("Enter checking interval"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else if (!GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str)))
+ {
+ MessageBox(hwndDlg, TranslateT("Enter message format"), TranslateT("Error"), MB_OK);
+ break;
+ }
+ else
+ {
+ GetDlgItemText(hwndDlg, IDC_FEEDURL, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "URL", str);
+ GetDlgItemText(hwndDlg, IDC_FEEDTITLE, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "Nick", str);
+ DBWriteContactSettingDword(hContact, MODULE, "UpdateTime", GetDlgItemInt(hwndDlg, IDC_CHECKTIME, false, false));
+ GetDlgItemText(hwndDlg, IDC_TAGSEDIT, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "MsgFormat", str);
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
+ {
+ DBWriteContactSettingByte(hContact, MODULE, "UseAuth", 1);
+ GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "Login", str);
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, MODULE, "Password", str);
+ }
+ }
+ }
+
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case IDC_USEAUTH:
+ {
+ if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ }
+ else
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), FALSE);
+ }
+ break;
+ }
+
+ case IDC_TAGHELP:
+ MessageBox(hwndDlg, TranslateT(TAGSHELP), TranslateT("Feed Tag Help"), MB_OK);
+ break;
+
+ case IDC_RESET:
+ if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Tags Mask Reset"), MB_YESNO | MB_ICONWARNING) == IDYES)
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, _T(TAGSDEFAULT));
+ break;
+
+ case IDC_DISCOVERY:
+ {
+ TCHAR tszURL[MAX_PATH] = {0};
+ if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, SIZEOF(tszURL)) || lstrcmp(tszURL, _T("http://")) != 0)
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait..."));
+ TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg);
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE);
+ SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed"));
+ }
+ else
+ MessageBox(hwndDlg, TranslateT("Enter Feed URL"), TranslateT("Error"), MB_OK);
+ }
+ break;
+ }
+ break;
+ }
+
+ case WM_CLOSE:
+ {
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ case WM_DESTROY:
+ {
+ HANDLE hContact = (HANDLE) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Utils_SaveWindowPosition(hwndDlg,hContact,MODULE,"ChangeDlg");
+ WindowList_Remove(hChangeFeedDlgList,hwndDlg);
+ }
+ }
+
+ return FALSE;
+}
+
+INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_FEEDLIST);
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
+ CreateList(hwndList);
+ UpdateList(hwndList);
+ return TRUE;
+ }
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDC_ADD:
+ {
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcAddFeedOpts, (LPARAM)hwndList);
+ }
+ return FALSE;
+ case IDC_CHANGE:
+ {
+ ItemInfo SelItem = {0};
+ int sel = ListView_GetSelectionMark(hwndList);
+ ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH);
+ ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH);
+ SelItem.hwndList = hwndList;
+ SelItem.SelNumber = sel;
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcChangeFeedOpts, (LPARAM)&SelItem);
+ }
+ return FALSE;
+ case IDC_REMOVE:
+ {
+ if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Contact deleting"), MB_YESNO | MB_ICONWARNING) == IDYES)
+ {
+ TCHAR nick[MAX_PATH], url[MAX_PATH];
+ int sel = ListView_GetSelectionMark(hwndList);
+ ListView_GetItemText(hwndList, sel, 0, nick, MAX_PATH);
+ ListView_GetItemText(hwndList, sel, 1, url, MAX_PATH);
+
+ HANDLE hContact = db_find_first();
+ while (hContact != NULL)
+ {
+ if(IsMyContact(hContact))
+ {
+ DBVARIANT dbNick = {0};
+ if (DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
+ break;
+ else if (lstrcmp(dbNick.ptszVal, nick) == 0)
+ {
+ DBFreeVariant(&dbNick);
+ DBVARIANT dbURL = {0};
+ if (DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
+ break;
+ else if (lstrcmp(dbURL.ptszVal, url) == 0)
+ {
+ DBFreeVariant(&dbURL);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ ListView_DeleteItem(hwndList, sel);
+ break;
+ }
+ DBFreeVariant(&dbURL);
+ }
+ DBFreeVariant(&dbNick);
+ }
+ hContact = db_find_next(hContact);
+ }
+ }
+ return FALSE;
+ }
+ }
+ break;
+ }
+ case WM_NOTIFY:
+ {
+ NMHDR *hdr = (NMHDR *)lParam;
+ switch (hdr->code)
+ {
+ case PSN_APPLY:
+ {
+ HANDLE hContact = db_find_first();
+ int i = 0;
+ while (hContact != NULL)
+ {
+ if(IsMyContact(hContact))
+ {
+ DBWriteContactSettingByte(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i));
+ if (!ListView_GetCheckState(hwndList, i))
+ DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
+ else
+ DBDeleteContactSetting(hContact,"CList","Hidden");
+ i += 1;
+ }
+ hContact = db_find_next(hContact);
+ }
+ break;
+ }
+
+ case NM_DBLCLK:
+ {
+ ItemInfo SelItem = {0};
+ int sel = ListView_GetHotItem(hwndList);
+ if (sel != -1)
+ {
+ ListView_GetItemText(hwndList, sel, 0, SelItem.nick, MAX_PATH);
+ ListView_GetItemText(hwndList, sel, 1, SelItem.url, MAX_PATH);
+ SelItem.hwndList = hwndList;
+ SelItem.SelNumber = sel;
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), hwndDlg, DlgProcChangeFeedOpts, (LPARAM)&SelItem);
+ }
+ break;
+ }
+
+ case LVN_ITEMCHANGED:
+ {
+ NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
+ if (((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) && !UpdateListFlag)
+ {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ break;
+ }
+ }
+ }
+ }//end* switch (msg)
+ return FALSE;
+}
+
+INT OptInit(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = {0};
+ odp.cbSize = sizeof(odp);
+ odp.position = 100000000;
+ odp.hInstance = hInst;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
+ odp.pszGroup = LPGEN("Network");
+ odp.pszTitle = LPGEN("News Aggregator");
+ odp.pfnDlgProc = UpdateNotifyOptsProc;
+ Options_AddPage(wParam, &odp);
+ return 0;
+}
\ No newline at end of file diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp new file mode 100644 index 0000000000..72f666fa98 --- /dev/null +++ b/plugins/NewsAggregator/Src/Services.cpp @@ -0,0 +1,245 @@ +/*
+Copyright (C) 2012 Mataes
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+int g_nStatus = ID_STATUS_OFFLINE;
+UINT_PTR timerId = 0;
+
+void SetContactStatus(HANDLE hContact,int nNewStatus)
+{
+ if(DBGetContactSettingWord(hContact,MODULE,"Status",ID_STATUS_OFFLINE) != nNewStatus)
+ DBWriteContactSettingWord(hContact,MODULE,"Status",nNewStatus);
+}
+
+static void __cdecl WorkingThread(void* param)
+{
+ int nStatus = (int)param;
+// UpdateAll(FALSE, FALSE);
+ HANDLE hContact= db_find_first();
+ while (hContact != NULL)
+ {
+ if(IsMyContact(hContact))
+ {
+ SetContactStatus(hContact, nStatus);
+ }
+ hContact = db_find_next(hContact);
+ }
+}
+
+int NewsAggrInit(WPARAM wParam,LPARAM lParam)
+{
+ HANDLE hContact= db_find_first();
+ while (hContact != NULL)
+ {
+ if(IsMyContact(hContact))
+ {
+ SetContactStatus(hContact, ID_STATUS_OFFLINE);
+ }
+ hContact = db_find_next(hContact);
+ }
+ NetlibInit();
+ InitIcons();
+ InitMenu();
+
+ // timer for the first update
+ timerId = SetTimer(NULL, 0, 5000, timerProc2); // first update is 5 sec after load
+
+ return 0;
+}
+
+int NewsAggrPreShutdown(WPARAM wParam,LPARAM lParam)
+{
+ if (hAddFeedDlg)
+ {
+ SendMessage(hAddFeedDlg, WM_CLOSE, 0, 0);
+ }
+ WindowList_Broadcast(hChangeFeedDlgList, WM_CLOSE, 0, 0);
+
+ mir_forkthread(WorkingThread, (void*)ID_STATUS_OFFLINE);
+ KillTimer(NULL, timerId);
+ NetlibUnInit();
+
+ return 0;
+}
+
+INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam)
+{
+ if(lParam)
+ {
+ lstrcpynA((char*)lParam, MODULE, wParam);
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+INT_PTR NewsAggrGetCaps(WPARAM wp,LPARAM lp)
+{
+ switch(wp)
+ {
+ case PFLAGNUM_1:
+ return PF1_IM | PF1_PEER2PEER;
+ case PFLAGNUM_3:
+ case PFLAGNUM_2:
+ return PF2_ONLINE;
+ case PFLAGNUM_4:
+ return PF4_AVATARS;
+ case PFLAG_UNIQUEIDTEXT:
+ return (INT_PTR) "News Feed";
+ case PFLAG_UNIQUEIDSETTING:
+ return (INT_PTR) "URL";
+ default:
+ return 0;
+ }
+}
+
+INT_PTR NewsAggrSetStatus(WPARAM wp,LPARAM /*lp*/)
+{
+ int nStatus = wp;
+ if ((ID_STATUS_ONLINE == nStatus) || (ID_STATUS_OFFLINE == nStatus))
+ {
+ int nOldStatus = g_nStatus;
+ if(nStatus != g_nStatus)
+ {
+ g_nStatus = nStatus;
+ mir_forkthread(WorkingThread, (void*)g_nStatus);
+ ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)nOldStatus, g_nStatus);
+ }
+
+ }
+
+ return 0;
+}
+
+INT_PTR NewsAggrGetStatus(WPARAM/* wp*/,LPARAM/* lp*/)
+{
+ return g_nStatus;
+}
+
+INT_PTR NewsAggrLoadIcon(WPARAM wParam,LPARAM lParam)
+{
+ return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(LoadIconEx("main", FALSE)) : 0;
+}
+
+static void __cdecl AckThreadProc(HANDLE param)
+{
+ Sleep(100);
+ ProtoBroadcastAck(MODULE, param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+}
+
+INT_PTR NewsAggrGetInfo(WPARAM wParam,LPARAM lParam)
+{
+ CCSDATA *ccs = (CCSDATA *) lParam;
+ mir_forkthread(AckThreadProc, ccs->hContact);
+ return 0;
+}
+
+INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam)
+{
+ HANDLE hContact = db_find_first();
+ while (hContact != NULL)
+ {
+ if (IsMyContact(hContact) && lParam && DBGetContactSettingDword(hContact, MODULE, "UpdateTime", 60))
+ UpdateListAdd(hContact);
+ else if (IsMyContact(hContact) && !lParam)
+ UpdateListAdd(hContact);
+ hContact = db_find_next(hContact);
+ }
+ if (!ThreadRunning)
+ mir_forkthread(UpdateThreadProc, NULL);
+
+
+ return 0;
+}
+
+INT_PTR AddFeed(WPARAM wParam,LPARAM lParam)
+{
+ hAddFeedDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ADDFEED), NULL, DlgProcAddFeedOpts);
+ ShowWindow(hAddFeedDlg, SW_SHOW);
+ return 0;
+}
+
+INT_PTR ChangeFeed(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE) wParam;
+ HWND hChangeFeedDlg = WindowList_Find(hChangeFeedDlgList,hContact);
+ if (!hChangeFeedDlg)
+ {
+ hChangeFeedDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADDFEED), NULL, DlgProcChangeFeedMenu, (LPARAM)hContact);
+ ShowWindow(hChangeFeedDlg, SW_SHOW);
+ }
+ else
+ {
+ SetForegroundWindow(hChangeFeedDlg);
+ SetFocus(hChangeFeedDlg);
+ }
+ return 0;
+}
+
+INT_PTR ImportFeeds(WPARAM wParam, LPARAM lParam)
+{
+ return 0;
+}
+
+INT_PTR ExportFeeds(WPARAM wParam, LPARAM lParam)
+{
+ return 0;
+}
+
+INT_PTR CheckFeed(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE)wParam;
+ if(IsMyContact(hContact))
+ UpdateListAdd(hContact);
+ if (!ThreadRunning)
+ mir_forkthread(UpdateThreadProc, NULL);
+ return 0;
+}
+
+INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam)
+{
+ PROTO_AVATAR_INFORMATIONT* pai = (PROTO_AVATAR_INFORMATIONT*) lParam;
+
+ if (!IsMyContact(pai->hContact))
+ return GAIR_NOAVATAR;
+
+ // if GAIF_FORCE is set, we are updating the feed
+ // otherwise, cached avatar is used
+ if (wParam & GAIF_FORCE && DBGetContactSettingDword(pai->hContact, MODULE, "UpdateTime", 60))
+ UpdateListAdd(pai->hContact);
+ if (!ThreadRunning)
+ mir_forkthread(UpdateThreadProc, NULL);
+
+ DBVARIANT dbv = {0};
+ if(DBGetContactSettingTString(pai->hContact,MODULE,"ImageURL",&dbv))
+ {
+ return GAIR_NOAVATAR;
+ }
+ DBFreeVariant(&dbv);
+ return GAIR_WAITFOR;
+}
+
+INT_PTR NewsAggrRecvMessage(WPARAM wParam, LPARAM lParam)
+{
+ CallService(MS_PROTO_RECVMSG, 0, lParam);
+ return 0;
+}
\ No newline at end of file diff --git a/plugins/NewsAggregator/Src/Stdafx.cpp b/plugins/NewsAggregator/Src/Stdafx.cpp new file mode 100644 index 0000000000..7a516adf58 --- /dev/null +++ b/plugins/NewsAggregator/Src/Stdafx.cpp @@ -0,0 +1,18 @@ +/*
+Copyright (C) 2012 Miranda NG team (http://miranda-ng.org)
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "common.h"
\ No newline at end of file diff --git a/plugins/NewsAggregator/Src/Update.cpp b/plugins/NewsAggregator/Src/Update.cpp new file mode 100644 index 0000000000..c0b42eb759 --- /dev/null +++ b/plugins/NewsAggregator/Src/Update.cpp @@ -0,0 +1,147 @@ +/*
+Copyright (C) 2012 Mataes
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+// check if Feed is currently updating
+BOOL ThreadRunning;
+UPDATELIST *UpdateListHead = NULL;
+UPDATELIST *UpdateListTail = NULL;
+
+// main auto-update timer
+VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+{
+ // only run if it is not current updating and the auto update option is enabled
+ if (!ThreadRunning && !Miranda_Terminated())
+ {
+ BOOL HaveUpdates = FALSE;
+ HANDLE hContact = db_find_first();
+ while (hContact != NULL)
+ {
+ if(IsMyContact(hContact))
+ {
+ if (DBGetContactSettingDword(hContact, MODULE, "UpdateTime", 60))
+ {
+ double diff = difftime(time(NULL), DBGetContactSettingDword(hContact, MODULE, "LastCheck", 0));
+ if (diff >= DBGetContactSettingDword(hContact, MODULE, "UpdateTime", 60) * 60)
+ {
+ UpdateListAdd(hContact);
+ HaveUpdates = TRUE;
+ }
+ }
+ }
+ hContact = db_find_next(hContact);
+ }
+ if (!ThreadRunning && HaveUpdates)
+ mir_forkthread(UpdateThreadProc, NULL);
+ }
+}
+
+// temporary timer for first run
+// when this is run, it kill the old startup timer and create the permenant one above
+VOID CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+{
+ KillTimer(NULL, timerId);
+ ThreadRunning = FALSE;
+
+ if (!Miranda_Terminated())
+ {
+ CheckAllFeeds(0, 1);
+ timerId = SetTimer(NULL, 0, 30000, (TIMERPROC)timerProc);
+ }
+}
+
+void UpdateListAdd(HANDLE hContact)
+{
+ UPDATELIST *newItem;
+
+ newItem = (UPDATELIST*)mir_alloc(sizeof(UPDATELIST));
+ newItem->hContact = hContact;
+ newItem->next = NULL;
+
+ WaitForSingleObject(hUpdateMutex, INFINITE);
+
+ if (UpdateListTail == NULL) UpdateListHead = newItem;
+ else UpdateListTail->next = newItem;
+ UpdateListTail = newItem;
+
+ ReleaseMutex(hUpdateMutex);
+}
+
+HANDLE UpdateGetFirst()
+{
+ HANDLE hContact = NULL;
+
+ WaitForSingleObject(hUpdateMutex, INFINITE);
+
+ if (UpdateListHead != NULL)
+ {
+ UPDATELIST* Item = UpdateListHead;
+
+ hContact = Item->hContact;
+ UpdateListHead = Item->next;
+ mir_free(Item);
+
+ if (UpdateListHead == NULL) UpdateListTail = NULL;
+ }
+
+ ReleaseMutex(hUpdateMutex);
+
+ return hContact;
+}
+
+void DestroyUpdateList(void)
+{
+ UPDATELIST *temp;
+
+ WaitForSingleObject(hUpdateMutex, INFINITE);
+
+ temp = UpdateListHead;
+
+ // free the list one by one
+ while (temp != NULL)
+ {
+ UpdateListHead = temp->next;
+ mir_free(temp);
+ temp = UpdateListHead;
+ }
+ // make sure the entire list is clear
+ UpdateListTail = NULL;
+
+ ReleaseMutex(hUpdateMutex);
+}
+
+void UpdateThreadProc(LPVOID hWnd)
+{
+ WaitForSingleObject(hUpdateMutex, INFINITE);
+ if (ThreadRunning)
+ {
+ ReleaseMutex(hUpdateMutex);
+ return;
+ }
+ ThreadRunning = TRUE; // prevent 2 instance of this thread running
+ ReleaseMutex(hUpdateMutex);
+
+ // update weather by getting the first station from the queue until the queue is empty
+ while (UpdateListHead != NULL && !Miranda_Terminated())
+ CheckCurrentFeed(UpdateGetFirst());
+
+ // exit the update thread
+ ThreadRunning = FALSE;
+}
\ No newline at end of file diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp new file mode 100644 index 0000000000..f28825d7e5 --- /dev/null +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -0,0 +1,1400 @@ +/*
+Copyright (C) 2012 Mataes
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This 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
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+HANDLE hNetlibUser = NULL, hNetlibHttp;
+BOOL UpdateListFlag = FALSE;
+
+BOOL IsMyContact(HANDLE hContact)
+{
+ const char* szProto = GetContactProto(hContact);
+ return szProto != NULL && strcmp(MODULE, szProto) == 0;
+}
+
+VOID NetlibInit()
+{
+ NETLIBUSER nlu = {0};
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_TCHAR; // | NUF_HTTPGATEWAY;
+ nlu.ptszDescriptiveName = TranslateT("NewsAggr HTTP connection");
+ nlu.szSettingsModule = MODULE;
+ hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+}
+
+VOID NetlibUnInit()
+{
+ Netlib_CloseHandle(hNetlibUser);
+ hNetlibUser = NULL;
+}
+
+static void arrayToHex(BYTE* data, size_t datasz, char* res)
+{
+ char* resptr = res;
+ for (unsigned i=0; i<datasz ; i++)
+ {
+ const BYTE ch = data[i];
+
+ const char ch0 = (char)(ch >> 4);
+ *resptr++ = (char)((ch0 <= 9) ? ('0' + ch0) : (('a' - 10) + ch0));
+
+ const char ch1 = (char)(ch & 0xF);
+ *resptr++ = (char)((ch1 <= 9) ? ('0' + ch1) : (('a' - 10) + ch1));
+ }
+ *resptr = '\0';
+}
+
+int GetImageFormat(const TCHAR* ext)
+{
+ if (!lstrcmp(ext,_T(".jpg")) || !lstrcmp(ext,_T(".jpeg")))
+ {
+ return PA_FORMAT_JPEG;
+ }
+ else if (!lstrcmp(ext,_T(".png")))
+ {
+ return PA_FORMAT_PNG;
+ }
+ else if (!lstrcmp(ext,_T(".gif")))
+ {
+ return PA_FORMAT_GIF;
+ }
+ else if (!lstrcmp(ext,_T(".ico")))
+ {
+ return PA_FORMAT_ICON;
+ }
+ else if (!lstrcmp(ext,_T(".bmp")))
+ {
+ return PA_FORMAT_BMP;
+ }
+ else if (!lstrcmp(ext,_T(".swf")))
+ {
+ return PA_FORMAT_SWF;
+ }
+ else if (!lstrcmp(ext,_T(".xml")))
+ {
+ return PA_FORMAT_XML;
+ }
+ else
+ {
+ return PA_FORMAT_UNKNOWN;
+ }
+}
+void CreateAuthString(char* auth, HANDLE hContact, HWND hwndDlg)
+{
+ char *user = NULL, *pass = NULL;
+ TCHAR *tlogin = NULL, *tpass = NULL, buf[MAX_PATH] = {0};
+ if (hContact && DBGetContactSettingByte(hContact, MODULE, "UseAuth", 0))
+ {
+ DBVARIANT dbLogin = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "Login", &dbLogin))
+ {
+ tlogin = mir_tstrdup(dbLogin.ptszVal);
+ DBFreeVariant(&dbLogin);
+ }
+ DBVARIANT dbPass = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "Password", &dbPass))
+ {
+ tpass = mir_tstrdup(dbPass.ptszVal);
+ DBFreeVariant(&dbPass);
+ }
+ }
+ else if (hwndDlg && IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
+ {
+ GetDlgItemText(hwndDlg, IDC_LOGIN, buf, SIZEOF(buf));
+ tlogin = buf;
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, buf, SIZEOF(buf));
+ tpass = buf;
+ }
+ user = mir_t2a(tlogin);
+ pass = mir_t2a(tpass);
+
+ char str[MAX_PATH];
+ int len = mir_snprintf(str, SIZEOF(str), "%s:%s", user, pass);
+ mir_free(user);
+ mir_free(pass);
+ mir_free(tlogin);
+ mir_free(tpass);
+
+ strcpy(auth, "Basic ");
+ NETLIBBASE64 nlb = { auth+6, 250, (PBYTE)str, len };
+ CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
+}
+
+VOID GetNewsData(TCHAR *tszUrl, char** szData, HANDLE hContact, HWND hwndDlg)
+{
+ char* szRedirUrl = NULL;
+ NETLIBHTTPREQUEST nlhr = {0};
+ NETLIBHTTPHEADER headers[5];
+
+ // initialize the netlib request
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_HTTP11;
+ char *szUrl = mir_t2a(tszUrl);
+ nlhr.szUrl = szUrl;
+ nlhr.nlc = hNetlibHttp;
+
+ // change the header so the plugin is pretended to be IE 6 + WinXP
+ nlhr.headers = headers;
+ nlhr.headers[0].szName = "User-Agent";
+ nlhr.headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
+ nlhr.headers[1].szName = "Cache-Control";
+ nlhr.headers[1].szValue = "no-cache";
+ nlhr.headers[2].szName = "Pragma";
+ nlhr.headers[2].szValue = "no-cache";
+ nlhr.headers[3].szName = "Connection";
+ nlhr.headers[3].szValue = "close";
+ nlhr.headers[4].szName = "Accept";
+ nlhr.headers[4].szValue = "*/*";
+ if (DBGetContactSettingByte(hContact, MODULE, "UseAuth", 0) || IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
+ {
+ nlhr.headersCount = 6;
+ nlhr.headers[5].szName = "Authorization";
+
+ char auth[256];
+ CreateAuthString(auth, hContact, hwndDlg);
+ nlhr.headers[5].szValue = auth;
+ }
+ else
+ nlhr.headersCount = 5;
+
+ // download the page
+ NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+ if (nlhrReply)
+ {
+ // if the recieved code is 200 OK
+ switch (nlhrReply->resultCode)
+ {
+ case 200:
+ {
+ if (nlhrReply->dataLength)
+ {
+ // allocate memory and save the retrieved data
+ *szData = (char *)mir_alloc(nlhrReply->dataLength + 2);
+ memcpy(*szData, nlhrReply->pData, nlhrReply->dataLength);
+ (*szData)[nlhrReply->dataLength] = 0;
+ }
+ break;
+ }
+
+ case 401:
+ {
+ //ShowMessage(0, TranslateT("Cannot upload VersionInfo. Incorrect username or password"));
+ break;
+ }
+
+ case 301:
+ case 302:
+ case 307:
+ // get the url for the new location and save it to szInfo
+ // look for the reply header "Location"
+ for (int i=0; i<nlhrReply->headersCount; i++)
+ {
+ if (!strcmp(nlhrReply->headers[i].szName, "Location"))
+ {
+ size_t rlen = 0;
+ if (nlhrReply->headers[i].szValue[0] == '/')
+ {
+ const char* szPath;
+ const char* szPref = strstr(szUrl, "://");
+ szPref = szPref ? szPref + 3 : szUrl;
+ szPath = strchr(szPref, '/');
+ rlen = szPath != NULL ? szPath - szUrl : strlen(szUrl);
+ }
+
+ szRedirUrl = (char*)mir_realloc(szRedirUrl, rlen + strlen(nlhrReply->headers[i].szValue)*3 + 1);
+
+ strncpy(szRedirUrl, szUrl, rlen);
+ strcpy(szRedirUrl+rlen, nlhrReply->headers[i].szValue);
+
+ nlhr.szUrl = szRedirUrl;
+ break;
+ }
+ }
+ break;
+
+ default:
+ //ShowMessage(0, TranslateT("Cannot upload VersionInfo. Unknown error"));
+ break;
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
+ }
+ mir_free(szUrl);
+}
+
+VOID CreateList(HWND hwndList)
+{
+ SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
+
+ LVCOLUMN lvc = {0};
+ // Initialize the LVCOLUMN structure.
+ // The mask specifies that the format, width, text, and
+ // subitem members of the structure are valid.
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvc.fmt = LVCFMT_LEFT;
+
+ lvc.iSubItem = 0;
+ lvc.pszText = TranslateT("Feed");
+ lvc.cx = 160; // width of column in pixels
+ ListView_InsertColumn(hwndList, 0, &lvc);
+
+ lvc.iSubItem = 1;
+ lvc.pszText = TranslateT("URL");
+ lvc.cx = 280; // width of column in pixels
+ ListView_InsertColumn(hwndList, 1, &lvc);
+}
+
+VOID UpdateList(HWND hwndList)
+{
+ LVITEM lvI = {0};
+
+ // Some code to create the list-view control.
+ // Initialize LVITEM members that are common to all
+ // items.
+ HANDLE hContact = db_find_first();
+ int i = 0;
+ while (hContact != NULL)
+ {
+ if (IsMyContact(hContact))
+ {
+ UpdateListFlag = TRUE;
+ lvI.mask = LVIF_TEXT;
+ lvI.iSubItem = 0;
+ DBVARIANT dbNick = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "Nick", &dbNick))
+ {
+ lvI.pszText = dbNick.ptszVal;
+ lvI.iItem = i;
+ ListView_InsertItem(hwndList, &lvI);
+ lvI.iSubItem = 1;
+ DBVARIANT dbURL = {0};
+ if (!DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
+ {
+ lvI.pszText = dbURL.ptszVal;
+ ListView_SetItem(hwndList, &lvI);
+ i += 1;
+ ListView_SetCheckState(hwndList, lvI.iItem, DBGetContactSettingByte(hContact, MODULE, "CheckState", 1));
+ DBFreeVariant(&dbURL);
+ }
+ DBFreeVariant(&dbNick);
+ }
+ }
+ hContact = db_find_next(hContact);
+ }
+ UpdateListFlag = FALSE;
+}
+
+VOID DeleteAllItems(HWND hwndList)
+{
+ ListView_DeleteAllItems(hwndList);
+}
+
+time_t __stdcall DateToUnixTime(TCHAR* stamp, BOOL FeedType)
+{
+ struct tm timestamp;
+ TCHAR date[9];
+ int i, y;
+ time_t t;
+
+ if ( stamp == NULL ) return ( time_t ) 0;
+
+ TCHAR *p = stamp;
+
+ if (FeedType)
+ {
+ // skip '-' chars
+ int si = 0, sj = 0;
+ while (1) {
+ if ( p[si] == _T('-'))
+ si++;
+ else
+ if ( !( p[sj++] = p[si++] ))
+ break;
+ };
+ }
+ else
+ {
+ TCHAR weekday[4], monthstr[4], timezonesign[2];
+ INT day, month, year, hour, min, sec, timezoneh, timezonem;
+ if (_tcsstr(p, _T(",")))
+ {
+ _stscanf( p, _T("%3s, %d %3s %d %d:%d:%d %1s%02d%02d"), &weekday, &day, &monthstr, &year, &hour, &min, &sec, &timezonesign, &timezoneh, &timezonem);
+ if (!lstrcmpi(monthstr, _T("Jan")))
+ month = 1;
+ if (!lstrcmpi(monthstr, _T("Feb")))
+ month = 2;
+ if (!lstrcmpi(monthstr, _T("Mar")))
+ month = 3;
+ if (!lstrcmpi(monthstr, _T("Apr")))
+ month = 4;
+ if (!lstrcmpi(monthstr, _T("May")))
+ month = 5;
+ if (!lstrcmpi(monthstr, _T("Jun")))
+ month = 6;
+ if (!lstrcmpi(monthstr, _T("Jul")))
+ month = 7;
+ if (!lstrcmpi(monthstr, _T("Aug")))
+ month = 8;
+ if (!lstrcmpi(monthstr, _T("Sep")))
+ month = 9;
+ if (!lstrcmpi(monthstr, _T("Oct")))
+ month = 10;
+ if (!lstrcmpi(monthstr, _T("Nov")))
+ month = 11;
+ if (!lstrcmpi(monthstr, _T("Dec")))
+ month = 12;
+ if (!lstrcmp(timezonesign, _T("+")))
+ mir_sntprintf(p, 4+2+2+1+2+1+2+1+2+1, _T("%04d%02d%02dT%02d:%02d:%02d"), year, month, day, hour-timezoneh, min-timezonem, sec);
+ else if (!lstrcmp(timezonesign, _T("-")))
+ mir_sntprintf(p, 4+2+2+1+2+1+2+1+2+1, _T("%04d%02d%02dT%02d:%02d:%02d"), year, month, day, hour+timezoneh, min+timezonem, sec);
+ else
+ mir_sntprintf(p, 4+2+2+1+2+1+2+1+2+1, _T("%04d%02d%02dT%02d:%02d:%02d"), year, month, day, hour, min, sec);
+ }
+ else
+ {
+ _stscanf( p, _T("%d-%d-%d %d:%d:%d %1s%02d%02d"), &year, &month, &day, &hour, &min, &sec, &timezonesign, &timezoneh, &timezonem);
+ if (!lstrcmp(timezonesign, _T("+")))
+ mir_sntprintf(p, 4+2+2+1+2+1+2+1+2+1, _T("%04d%02d%02dT%02d:%02d:%02d"), year, month, day, hour-timezoneh, min-timezonem, sec);
+ else if (!lstrcmp(timezonesign, _T("-")))
+ mir_sntprintf(p, 4+2+2+1+2+1+2+1+2+1, _T("%04d%02d%02dT%02d:%02d:%02d"), year, month, day, hour+timezoneh, min+timezonem, sec);
+ else
+ mir_sntprintf(p, 4+2+2+1+2+1+2+1+2+1, _T("%04d%02d%02dT%02d:%02d:%02d"), year, month, day, hour, min, sec);
+ }
+ }
+ // Get the date part
+ for ( i=0; *p!='\0' && i<8 && isdigit( *p ); p++,i++ )
+ date[i] = *p;
+
+ // Parse year
+ if ( i == 6 ) {
+ // 2-digit year ( 1970-2069 )
+ y = ( date[0]-'0' )*10 + ( date[1]-'0' );
+ if ( y < 70 ) y += 100;
+ }
+ else if ( i == 8 ) {
+ // 4-digit year
+ y = ( date[0]-'0' )*1000 + ( date[1]-'0' )*100 + ( date[2]-'0' )*10 + date[3]-'0';
+ y -= 1900;
+ }
+ else
+ return ( time_t ) 0;
+ timestamp.tm_year = y;
+ // Parse month
+ timestamp.tm_mon = ( date[i-4]-'0' )*10 + date[i-3]-'0' - 1;
+ // Parse date
+ timestamp.tm_mday = ( date[i-2]-'0' )*10 + date[i-1]-'0';
+
+ // Skip any date/time delimiter
+ for ( ; *p!='\0' && !isdigit( *p ); p++ );
+
+ // Parse time
+ if ( _stscanf( p, _T("%d:%d:%d"), ×tamp.tm_hour, ×tamp.tm_min, ×tamp.tm_sec ) != 3 )
+ return ( time_t ) 0;
+
+ timestamp.tm_isdst = 0; // DST is already present in _timezone below
+ t = mktime( ×tamp );
+
+ _tzset();
+ t -= _timezone;
+
+ if ( t >= 0 )
+ return t;
+ else
+ return ( time_t ) 0;
+}
+
+TCHAR * _tcsistr(const TCHAR * str, const TCHAR * substr)
+{
+ if (!str || !substr || (substr[0] == _T('\0')))
+ return (TCHAR *) str;
+
+ size_t nLen = _tcslen(substr);
+ while (*str)
+ {
+ if (_tcsnicmp(str, substr, nLen) == 0)
+ break;
+ str++;
+ }
+
+ if (*str == _T('\0'))
+ str = NULL;
+
+ return (TCHAR *) str;
+}
+
+int StrReplace(TCHAR* lpszOld, TCHAR* lpszNew, TCHAR*& lpszStr)
+{
+ if (!lpszStr || !lpszOld || !lpszNew)
+ return 0;
+
+ size_t nStrLen = _tcslen(lpszStr);
+ if (nStrLen == 0)
+ return 0;
+
+ size_t nOldLen = _tcslen(lpszOld);
+ if (nOldLen == 0)
+ return 0;
+
+ size_t nNewLen = _tcslen(lpszNew);
+
+ // loop once to figure out the size of the result string
+ int nCount = 0;
+ TCHAR *pszStart = (TCHAR *) lpszStr;
+ TCHAR *pszEnd = (TCHAR *) lpszStr + nStrLen;
+ TCHAR *pszTarget = NULL;
+ TCHAR * pszResultStr = NULL;
+
+ while (pszStart < pszEnd)
+ {
+ while ((pszTarget = _tcsistr(pszStart, lpszOld)) != NULL)
+ {
+ nCount++;
+ pszStart = pszTarget + nOldLen;
+ }
+ pszStart += _tcslen(pszStart);
+ }
+
+ // if any changes, make them now
+ if (nCount > 0)
+ {
+ // allocate buffer for result string
+ size_t nResultStrSize = nStrLen + (nNewLen - nOldLen) * nCount + 2;
+ pszResultStr = new TCHAR [nResultStrSize];
+ ZeroMemory(pszResultStr, nResultStrSize*sizeof(TCHAR));
+
+ pszStart = (TCHAR *) lpszStr;
+ pszEnd = (TCHAR *) lpszStr + nStrLen;
+ TCHAR *cp = pszResultStr;
+
+ // loop again to actually do the work
+ while (pszStart < pszEnd)
+ {
+ while ((pszTarget = _tcsistr(pszStart, lpszOld)) != NULL)
+ {
+ int nCopyLen = (int)(pszTarget - pszStart);
+ _tcsncpy(cp, &lpszStr[pszStart-lpszStr], nCopyLen);
+
+ cp += nCopyLen;
+
+ pszStart = pszTarget + nOldLen;
+
+ _tcscpy(cp, lpszNew);
+
+ cp += nNewLen;
+ }
+ _tcscpy(cp, pszStart);
+ pszStart += _tcslen(pszStart);
+ }
+
+ if (pszResultStr)
+ lpszStr = mir_tstrdup(pszResultStr);
+ }
+
+ int nSize = 0;
+ if (pszResultStr)
+ {
+ nSize = (int)_tcslen(pszResultStr);
+ delete [] pszResultStr;
+ }
+
+ return nSize;
+}
+
+BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
+{
+ HANDLE hFile = NULL;
+ DWORD dwBytes;
+
+ NETLIBHTTPREQUEST nlhr = {0};
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
+ char* szUrl = mir_t2a(tszURL);
+ nlhr.szUrl = szUrl;
+ nlhr.headersCount = 4;
+ nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
+ nlhr.headers[0].szName = "User-Agent";
+ nlhr.headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
+ nlhr.headers[1].szName = "Connection";
+ nlhr.headers[1].szValue = "close";
+ nlhr.headers[2].szName = "Cache-Control";
+ nlhr.headers[2].szValue = "no-cache";
+ nlhr.headers[3].szName = "Pragma";
+ nlhr.headers[3].szValue = "no-cache";
+
+ bool ret = false;
+ NETLIBHTTPREQUEST *pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr);
+
+ if (pReply)
+ {
+ if ((200 == pReply->resultCode) && (pReply->dataLength > 0))
+ {
+ char *date = NULL, *size = NULL;
+ for (int i = 0; i < pReply->headersCount; i++)
+ {
+ if (!lstrcmpiA(pReply->headers[i].szName, "Last-Modified"))
+ {
+ date = pReply->headers[i].szValue;
+ continue;
+ }
+ if (!lstrcmpiA(pReply->headers[i].szName, "Content-Length"))
+ {
+ size = pReply->headers[i].szValue;
+ continue;
+ }
+ }
+ if (date != NULL && size != NULL)
+ {
+ TCHAR *tdate = mir_a2t(date);
+ TCHAR *tsize = mir_a2t(size);
+ int fh;
+ struct _stat buf;
+
+ fh = _topen(tszLocal, _O_RDONLY);
+ if (fh != -1)
+ {
+ _fstat(fh, &buf);
+ time_t modtime = DateToUnixTime(tdate, 0);
+ time_t filemodtime = mktime(localtime(&buf.st_atime));
+ if (modtime > filemodtime && buf.st_size != _ttoi(tsize))
+ {
+ hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
+ ret = true;
+ }
+ _close(fh);
+ }
+ else
+ {
+ hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
+ ret = true;
+ }
+ mir_free(tdate);
+ mir_free(tsize);
+ }
+ else
+ {
+ hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ WriteFile(hFile, pReply->pData, (DWORD)pReply->dataLength, &dwBytes, NULL);
+ ret = true;
+ }
+ }
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)pReply);
+ }
+
+ mir_free(szUrl);
+ mir_free(nlhr.headers);
+
+ if (hFile)
+ CloseHandle(hFile);
+
+ return ret;
+}
+
+size_t PathToRelative(const TCHAR *pSrc, TCHAR *pOut)
+{
+ return CallService( MS_UTILS_PATHTORELATIVET, (WPARAM)pSrc, (LPARAM)pOut );
+}
+
+typedef HRESULT (MarkupCallback)(IHTMLDocument3*, BSTR& message);
+
+HRESULT TestMarkupServices(BSTR bstrHtml, MarkupCallback* pCallback, BSTR& message)
+{
+ IHTMLDocument3* pHtmlDocRoot = NULL;
+
+ // Create the root document -- a "workspace" for parsing.
+ HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pHtmlDocRoot));
+ if (SUCCEEDED(hr) && pHtmlDocRoot)
+ {
+ IPersistStreamInit *pPersistStreamInit = NULL;
+
+ HRESULT hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pPersistStreamInit));
+ if (SUCCEEDED(hr))
+ {
+ // Initialize the root document to a default state -- ready for parsing.
+ hr = pPersistStreamInit->InitNew();
+
+ IMarkupServices *pMarkupServices = NULL;
+ hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pMarkupServices));
+ if (SUCCEEDED(hr))
+ {
+ IMarkupPointer *pMarkupBegin = NULL;
+ IMarkupPointer *pMarkupEnd = NULL;
+
+ // These markup pointers indicate the insertion point.
+ hr = pMarkupServices->CreateMarkupPointer(&pMarkupBegin);
+ if (SUCCEEDED(hr))
+ hr = pMarkupServices->CreateMarkupPointer(&pMarkupEnd);
+
+ if (SUCCEEDED(hr) && pMarkupBegin && pMarkupEnd)
+ {
+ IMarkupContainer *pMarkupContainer = NULL;
+
+ // Parse the string -- the markup container contains the parsed HTML.
+ // Markup pointers are updated to point to begining and end of new container.
+ hr = pMarkupServices->ParseString(bstrHtml, 0, &pMarkupContainer, pMarkupBegin, pMarkupEnd);
+ if (SUCCEEDED(hr) && pMarkupContainer)
+ {
+ IHTMLDocument3 *pHtmlDoc = NULL;
+
+ // Retrieve the document interface to the markup container.
+ hr = pMarkupContainer->QueryInterface(IID_PPV_ARGS(&pHtmlDoc));
+ if (SUCCEEDED(hr) && pHtmlDoc)
+ {
+ // Invoke the user-defined action for this new fragment.
+ hr = pCallback(pHtmlDoc, message);
+
+ // Clean up.
+ pHtmlDoc->Release();
+ }
+ pMarkupContainer->Release();
+ }
+ pMarkupEnd->Release();
+ }
+ if (pMarkupBegin)
+ pMarkupBegin->Release();
+ pMarkupServices->Release();
+ }
+ pPersistStreamInit->Release();
+ }
+ pHtmlDocRoot->Release();
+ }
+ return hr;
+}
+
+HRESULT TestDocumentText(IHTMLDocument3* pHtmlDoc, BSTR& message)
+{
+ IHTMLDocument2 *pDoc = NULL;
+ IHTMLElement *pElem = NULL;
+ BSTR bstrId = SysAllocString(L"test");
+
+ HRESULT hr = pHtmlDoc->QueryInterface(IID_PPV_ARGS(&pDoc));
+ if (SUCCEEDED(hr) && pDoc)
+ {
+ hr = pDoc->get_body(&pElem);
+ if (SUCCEEDED(hr) && pElem)
+ {
+ BSTR bstrText = NULL;
+ pElem->get_innerText(&bstrText);
+ message = SysAllocString(bstrText);
+ SysFreeString(bstrText);
+ pElem->Release();
+ }
+
+ pDoc->Release();
+ }
+
+ SysFreeString(bstrId);
+ return hr;
+}
+
+VOID ClearText(TCHAR*& message)
+{
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ BSTR bstrHtml = SysAllocString(message), bstrRes = SysAllocString(L"");
+ HRESULT hr = TestMarkupServices(bstrHtml, &TestDocumentText, bstrRes);
+ if ( SUCCEEDED(hr)) {
+ replaceStrT(message, bstrRes);
+ SysFreeString(bstrRes);
+ }
+ SysFreeString(bstrHtml);
+ CoUninitialize();
+}
+
+TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg)
+{
+ char *szData = NULL;
+ DBVARIANT dbVar = {0};
+ if (CallProtoService(MODULE, PS_GETSTATUS, 0, 0) != ID_STATUS_OFFLINE)
+ {
+ GetNewsData(tszURL, &szData, NULL, hwndDlg);
+ if (szData)
+ {
+ TCHAR *tszData = mir_utf8decodeT(szData);
+ if (!tszData)
+ tszData = mir_a2t(szData);
+ int bytesParsed = 0;
+ HXML hXml = xi.parseString(tszData, &bytesParsed, NULL);
+ mir_free(tszData);
+ mir_free(szData);
+ if (hXml != NULL)
+ {
+ int childcount = 0;
+ HXML node = xi.getChild(hXml, childcount);
+ while (node)
+ {
+ if (!lstrcmpi(xi.getName(node), _T("rss")) || !lstrcmpi(xi.getName(node), _T("rdf")))
+ {
+ HXML chan = xi.getChild(node, 0);
+ for (int j = 0; j < xi.getChildCount(chan); j++)
+ {
+ HXML child = xi.getChild(chan, j);
+ if (!lstrcmpi(xi.getName(child), _T("title")))
+ {
+ TCHAR mes[MAX_PATH];
+ mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis a valid feed's address."), tszURL);
+ MessageBox(NULL, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONINFORMATION);
+ TCHAR *tszTitle = (TCHAR*)xi.getText(child);
+ return tszTitle;
+ }
+ }
+ }
+ else if (!lstrcmpi(xi.getName(node), _T("feed")))
+ {
+ for (int j = 0; j < xi.getChildCount(node); j++)
+ {
+ HXML child = xi.getChild(node, j);
+ if (!lstrcmpi(xi.getName(child), _T("title")))
+ {
+ TCHAR mes[MAX_PATH];
+ mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis a valid feed's address."), tszURL);
+ MessageBox(NULL, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONINFORMATION);
+ TCHAR *tszTitle = (TCHAR*)xi.getText(child);
+ return tszTitle;
+ }
+ }
+ }
+ childcount +=1;
+ node = xi.getChild(hXml, childcount);
+ }
+ }
+ xi.destroyNode(hXml);
+ }
+ else
+ {
+ TCHAR mes[MAX_PATH];
+ mir_sntprintf(mes, SIZEOF(mes), TranslateT("%s\nis a not valid feed's address."), tszURL);
+ MessageBox(NULL, mes, TranslateT("New Aggregator"), MB_OK|MB_ICONERROR);
+ }
+ }
+ return NULL;
+}
+
+VOID CheckCurrentFeed(HANDLE hContact)
+{
+ char *szData = NULL;
+ DBVARIANT dbURL = {0};
+ if (DBGetContactSettingTString(hContact, MODULE, "URL", &dbURL))
+ return;
+ else if ((DBGetContactSettingWord(hContact, MODULE, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) && DBGetContactSettingByte(hContact, MODULE, "CheckState", 1) != 0)
+ {
+ GetNewsData(dbURL.ptszVal, &szData, hContact, NULL);
+ DBFreeVariant(&dbURL);
+ if (szData)
+ {
+ TCHAR *tszData = mir_utf8decodeT(szData);
+ if (!tszData)
+ tszData = mir_a2t(szData);
+ int bytesParsed = 0;
+ HXML hXml = xi.parseString(tszData, &bytesParsed, NULL);
+ mir_free(tszData);
+ mir_free(szData);
+ if(hXml != NULL)
+ {
+ int childcount = 0;
+ HXML node = xi.getChild(hXml, childcount);
+ while (node)
+ {
+ if (!lstrcmpi(xi.getName(node), _T("rss")) || !lstrcmpi(xi.getName(node), _T("rdf")))
+ {
+ if (!lstrcmpi(xi.getName(node), _T("rss")))
+ {
+ for (int i = 0; i < xi.getAttrCount(node); i++)
+ {
+ if (!lstrcmpi(xi.getAttrName(node, i), _T("version")))
+ {
+ TCHAR ver[MAX_PATH];
+ mir_sntprintf(ver, SIZEOF(ver), _T("RSS %s"), xi.getAttrValue(node, xi.getAttrName(node, i)));
+ DBWriteContactSettingTString(hContact, MODULE, "MirVer", ver);
+ break;
+ }
+ }
+ }
+ else if (!lstrcmpi(xi.getName(node), _T("rdf")))
+ {
+ DBWriteContactSettingTString(hContact, MODULE, "MirVer", _T("RSS 1.0"));
+ }
+
+ HXML chan = xi.getChild(node, 0);
+ for (int j = 0; j < xi.getChildCount(chan); j++)
+ {
+ HXML child = xi.getChild(chan, j);
+ if (!lstrcmpi(xi.getName(child), _T("title")) && xi.getText(child))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(child));
+ ClearText(string);
+ DBWriteContactSettingTString(hContact, MODULE, "FirstName", string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("link")))
+ {
+ DBWriteContactSettingTString(hContact, MODULE, "Homepage", xi.getText(child));
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("description")) && xi.getText(child))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(child));
+ ClearText(string);
+ DBWriteContactSettingTString(hContact, MODULE, "About", string);
+ DBWriteContactSettingTString(hContact, "CList", "StatusMsg", string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("language")) && xi.getText(child))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(child));
+ ClearText(string);
+ DBWriteContactSettingTString(hContact, MODULE, "Language1", string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("managingEditor")) && xi.getText(child))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(child));
+ ClearText(string);
+ DBWriteContactSettingTString(hContact, MODULE, "e-mail", string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("category")) && xi.getText(child))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(child));
+ ClearText(string);
+ DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("image")))
+ {
+ for (int x = 0; x < xi.getChildCount(child); x++)
+ {
+ HXML imageval = xi.getChild(child, x);
+ if (!lstrcmpi(xi.getName(imageval), _T("url")))
+ {
+ LPCTSTR url = xi.getText(imageval);
+ DBWriteContactSettingTString(hContact, MODULE, "ImageURL", url);
+
+ PROTO_AVATAR_INFORMATIONT pai = {NULL};
+ pai.cbSize = sizeof(pai);
+ pai.hContact = hContact;
+ DBVARIANT dbVar = {0};
+
+ if (!DBGetContactSettingTString(hContact, MODULE, "Nick", &dbVar))
+ {
+ TCHAR *ext = _tcsrchr((TCHAR*)url, _T('.')) + 1;
+ pai.format = GetImageFormat(ext);
+
+ TCHAR *filename = dbVar.ptszVal;
+ mir_sntprintf(pai.filename, SIZEOF(pai.filename), _T("%s\\%s.%s"), tszRoot, filename, ext);
+ if (DownloadFile(url, pai.filename))
+ {
+ DBWriteContactSettingTString(hContact, MODULE, "ImagePath", pai.filename);
+ ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE) &pai, NULL);
+ }
+ else
+ ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE) &pai, NULL);
+ DBFreeVariant(&dbVar);
+ break;
+ }
+ }
+ }
+ }
+ if (!lstrcmpi(xi.getName(child), _T("lastBuildDate")) && xi.getText(child))
+ {
+ TCHAR *lastupdtime = (TCHAR*)xi.getText(child);
+ time_t stamp = DateToUnixTime(lastupdtime, 0);
+ double deltaupd = difftime(time(NULL), stamp);
+ double deltacheck = difftime(time(NULL), DBGetContactSettingDword(hContact, MODULE, "LastCheck", 0));
+ if (deltaupd - deltacheck >= 0)
+ {
+ DBWriteContactSettingDword(hContact, MODULE, "LastCheck", time(NULL));
+ xi.destroyNode(hXml);
+ return;
+ }
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("item")))
+ {
+ TCHAR *title = NULL, *link = NULL, *datetime = NULL, *descr = NULL, *author = NULL, *comments = NULL, *guid = NULL, *category = NULL;
+ for (int z = 0; z < xi.getChildCount(child); z++)
+ {
+ HXML itemval = xi.getChild(child, z);
+ if (!lstrcmpi(xi.getName(itemval), _T("title")))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ title = mir_tstrdup(string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("link")))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ link = mir_tstrdup(string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("pubDate")))
+ {
+ datetime = (TCHAR*)xi.getText(itemval);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("dc:date")))
+ {
+ datetime = (TCHAR*)xi.getText(itemval);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("description")))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ descr = mir_tstrdup(string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("author")))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ author = mir_tstrdup(string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("comments")))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ comments = mir_tstrdup(string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("guid")))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ guid = mir_tstrdup(string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("category")))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ category = mir_tstrdup(string);
+ mir_free(string);
+ continue;
+ }
+ }
+ TCHAR* message;
+ DBVARIANT dbMsg = {0};
+ if (DBGetContactSettingTString(hContact, MODULE, "MsgFormat", &dbMsg))
+ message = _T(TAGSDEFAULT);
+ else
+ message = mir_tstrdup(dbMsg.ptszVal);
+ DBFreeVariant(&dbMsg);
+ if (!title)
+ StrReplace(_T("#<title>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<title>#"), title, message);
+ mir_free(title);
+ }
+ if (!link)
+ StrReplace(_T("#<link>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<link>#"), link, message);
+ mir_free(link);
+ }
+ if (!descr)
+ StrReplace(_T("#<description>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<description>#"), descr, message);
+ mir_free(descr);
+ }
+ if (!author)
+ StrReplace(_T("#<author>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<author>#"), author, message);
+ mir_free(author);
+ }
+ if (!comments)
+ StrReplace(_T("#<comments>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<comments>#"), comments, message);
+ mir_free(comments);
+ }
+ if (!guid)
+ StrReplace(_T("#<guid>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<guid>#"), guid, message);
+ mir_free(guid);
+ }
+ if (!category)
+ StrReplace(_T("#<category>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<category>#"), category, message);
+ mir_free(category);
+ }
+
+ time_t stamp;
+ if (!datetime)
+ stamp = time(NULL);
+ else
+ stamp = DateToUnixTime(datetime, 0);
+
+ HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ BOOL MesExist = FALSE;
+ while (hDbEvent)
+ {
+ DBEVENTINFO olddbei = {0};
+ olddbei.cbSize = sizeof(olddbei);
+ olddbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ olddbei.pBlob = (PBYTE)mir_alloc(olddbei.cbBlob);
+ CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&olddbei);
+ char *pszTemp = mir_utf8encodeT(message);
+ if (olddbei.cbBlob == lstrlenA(pszTemp) + 1 && !lstrcmpA((char*)olddbei.pBlob, pszTemp))
+ MesExist = TRUE;
+ hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ mir_free(olddbei.pBlob);
+ mir_free(pszTemp);
+ }
+
+ if (!MesExist)
+ {
+ PROTORECVEVENT recv;
+ recv.flags = PREF_TCHAR;
+ recv.timestamp = stamp;
+ recv.tszMessage = message;
+ ProtoChainRecvMsg(hContact, &recv);
+ }
+ mir_free(message);
+ }
+ }
+ }
+ else if (!lstrcmpi(xi.getName(node), _T("feed")))
+ {
+ DBWriteContactSettingTString(hContact, MODULE, "MirVer", _T("Atom 3"));
+ for (int j = 0; j < xi.getChildCount(node); j++)
+ {
+ HXML child = xi.getChild(node, j);
+ if (!lstrcmpi(xi.getName(child), _T("title")) && xi.getText(child))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(child));
+ ClearText(string);
+ DBWriteContactSettingTString(hContact, MODULE, "FirstName", string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("link")))
+ {
+ for (int x = 0; x < xi.getAttrCount(child); x++)
+ {
+ if (!lstrcmpi(xi.getAttrName(child, x), _T("rel")))
+ {
+ if (!lstrcmpi(xi.getAttrValue(child, xi.getAttrName(child, x)), _T("self")))
+ break;
+ }
+ if (!lstrcmpi(xi.getAttrName(child, x), _T("href")))
+ {
+ DBWriteContactSettingTString(hContact, MODULE, "Homepage", xi.getAttrValue(child, xi.getAttrName(child, x)));
+ }
+ }
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("subtitle")) && xi.getText(child))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(child));
+ ClearText(string);
+ DBWriteContactSettingTString(hContact, MODULE, "About", string);
+ DBWriteContactSettingTString(hContact, "CList", "StatusMsg", string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("language")) && xi.getText(child))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(child));
+ ClearText(string);
+ DBWriteContactSettingTString(hContact, MODULE, "Language1", string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("author")))
+ {
+ for (int x = 0; x < xi.getChildCount(child); x++)
+ {
+ HXML authorval = xi.getChild(child, x);
+ if (!lstrcmpi(xi.getName(authorval), _T("name")))
+ {
+ DBWriteContactSettingTString(hContact, MODULE, "e-mail", xi.getText(authorval));
+ break;
+ }
+ }
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("category")) && xi.getText(child))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(child));
+ ClearText(string);
+ DBWriteContactSettingTString(hContact, MODULE, "Interest0Text", string);
+ mir_free(string);
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("icon")))
+ {
+ for (int x = 0; x < xi.getChildCount(child); x++)
+ {
+ HXML imageval = xi.getChild(child, x);
+ if (!lstrcmpi(xi.getName(imageval), _T("url")))
+ {
+ LPCTSTR url = xi.getText(imageval);
+ DBWriteContactSettingTString(hContact, MODULE, "ImageURL", url);
+
+ PROTO_AVATAR_INFORMATIONT pai = {NULL};
+ pai.cbSize = sizeof(pai);
+ pai.hContact = hContact;
+ DBVARIANT dbVar = {0};
+
+ if (!DBGetContactSettingTString(hContact, MODULE, "Nick", &dbVar))
+ {
+ TCHAR *ext = _tcsrchr((TCHAR*)url, _T('.')) + 1;
+ pai.format = GetImageFormat(ext);
+
+ TCHAR *filename = dbVar.ptszVal;
+ mir_sntprintf(pai.filename, SIZEOF(pai.filename), _T("%s\\%s.%s"), tszRoot, filename, ext);
+ if (DownloadFile(url, pai.filename))
+ {
+ DBWriteContactSettingTString(hContact, MODULE, "ImagePath", pai.filename);
+ ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE) &pai, NULL);
+ }
+ else
+ ProtoBroadcastAck(MODULE, hContact, ACKTYPE_AVATAR, ACKRESULT_FAILED, (HANDLE) &pai, NULL);
+ DBFreeVariant(&dbVar);
+ break;
+ }
+ }
+ }
+ }
+ if (!lstrcmpi(xi.getName(child), _T("updated")) && xi.getText(child))
+ {
+ TCHAR *lastupdtime = (TCHAR*)xi.getText(child);
+ time_t stamp = DateToUnixTime(lastupdtime, 1);
+ double deltaupd = difftime(time(NULL), stamp);
+ double deltacheck = difftime(time(NULL), DBGetContactSettingDword(hContact, MODULE, "LastCheck", 0));
+ if (deltaupd - deltacheck >= 0)
+ {
+ DBWriteContactSettingDword(hContact, MODULE, "LastCheck", time(NULL));
+ xi.destroyNode(hXml);
+ return;
+ }
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(child), _T("entry")))
+ {
+ TCHAR *title = NULL, *link = NULL, *datetime = NULL, *descr = NULL, *author = NULL, *comments = NULL, *guid = NULL, *category = NULL;
+ for (int z = 0; z < xi.getChildCount(child); z++)
+ {
+ HXML itemval = xi.getChild(child, z);
+ if (!lstrcmpi(xi.getName(itemval), _T("title")) && xi.getText(itemval))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ title = string;
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("link")))
+ {
+ for (int x = 0; x < xi.getAttrCount(itemval); x++)
+ {
+ if (!lstrcmpi(xi.getAttrName(itemval, x), _T("href")))
+ {
+ TCHAR *string = mir_tstrdup(xi.getAttrValue(itemval, xi.getAttrName(itemval, x)));
+ ClearText(string);
+ link = string;
+ break;
+ }
+ }
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("updated")))
+ {
+ datetime = (TCHAR*)xi.getText(itemval);
+ continue;
+ }
+ if ((!lstrcmpi(xi.getName(itemval), _T("summary")) || !lstrcmpi(xi.getName(itemval), _T("content"))) && xi.getText(itemval))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ descr = string;
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("author")))
+ {
+ for (int x = 0; x < xi.getChildCount(itemval); x++)
+ {
+ HXML authorval = xi.getChild(itemval, x);
+ if (!lstrcmpi(xi.getName(authorval), _T("name")) && xi.getText(authorval))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(authorval));
+ ClearText(string);
+ author = string;
+ break;
+ }
+ }
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("comments")) && xi.getText(itemval))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ comments = string;
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("id")))
+ {
+ TCHAR *string = mir_tstrdup(xi.getText(itemval));
+ ClearText(string);
+ guid = string;
+ continue;
+ }
+ if (!lstrcmpi(xi.getName(itemval), _T("category")))
+ {
+ for (int x = 0; x < xi.getAttrCount(itemval); x++)
+ {
+ if (!lstrcmpi(xi.getAttrName(itemval, x), _T("term")) && xi.getText(itemval))
+ {
+ TCHAR *string = mir_tstrdup(xi.getAttrValue(itemval, xi.getAttrName(itemval, x)));
+ ClearText(string);
+ category = string;
+ break;
+ }
+ }
+ continue;
+ }
+ }
+ TCHAR* message;
+ DBVARIANT dbMsg = {0};
+ if (DBGetContactSettingTString(hContact, MODULE, "MsgFormat", &dbMsg))
+ message = _T(TAGSDEFAULT);
+ else
+ message = mir_tstrdup(dbMsg.ptszVal);
+ DBFreeVariant(&dbMsg);
+
+ if (!title)
+ StrReplace(_T("#<title>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<title>#"), title, message);
+ mir_free(title);
+ }
+ if (!link)
+ StrReplace(_T("#<link>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<link>#"), link, message);
+ mir_free(link);
+ }
+ if (!descr)
+ StrReplace(_T("#<description>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<description>#"), descr, message);
+ mir_free(descr);
+ }
+ if (!author)
+ StrReplace(_T("#<author>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<author>#"), author, message);
+ mir_free(author);
+ }
+ if (!comments)
+ StrReplace(_T("#<comments>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<comments>#"), comments, message);
+ mir_free(comments);
+ }
+ if (!guid)
+ StrReplace(_T("#<guid>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<guid>#"), guid, message);
+ mir_free(guid);
+ }
+ if (!category)
+ StrReplace(_T("#<category>#"), TranslateT("empty"), message);
+ else
+ {
+ StrReplace(_T("#<category>#"), category, message);
+ mir_free(category);
+ }
+
+ time_t stamp;
+ if (!datetime)
+ stamp = time(NULL);
+ else
+ stamp = DateToUnixTime(datetime, 1);
+
+ HANDLE hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0);
+ BOOL MesExist = FALSE;
+ while (hDbEvent)
+ {
+ DBEVENTINFO olddbei = {0};
+ olddbei.cbSize = sizeof(olddbei);
+ olddbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
+ olddbei.pBlob = (PBYTE)mir_alloc(olddbei.cbBlob);
+ CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&olddbei);
+ char *pszTemp = mir_utf8encodeT(message);
+ if (olddbei.cbBlob == lstrlenA(pszTemp) + 1 && !lstrcmpA((char*)olddbei.pBlob, pszTemp))
+ MesExist = TRUE;
+ hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0);
+ mir_free(olddbei.pBlob);
+ mir_free(pszTemp);
+ }
+
+ if (!MesExist)
+ {
+ PROTORECVEVENT recv;
+ recv.flags = PREF_TCHAR;
+ recv.timestamp = stamp;
+ recv.tszMessage = message;
+ ProtoChainRecvMsg(hContact, &recv);
+ }
+ mir_free(message);
+ }
+ }
+ }
+ childcount +=1;
+ node = xi.getChild(hXml, childcount);
+ }
+ xi.destroyNode(hXml);
+ }
+ }
+ DBWriteContactSettingDword(hContact, MODULE, "LastCheck", time(NULL));
+ }
+}
\ No newline at end of file diff --git a/plugins/NewsAggregator/Src/Version.h b/plugins/NewsAggregator/Src/Version.h new file mode 100644 index 0000000000..7d4efa3d9d --- /dev/null +++ b/plugins/NewsAggregator/Src/Version.h @@ -0,0 +1,20 @@ +#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 1
+
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
+
+#define __STRINGIFY_IMPL(x) #x
+#define __STRINGIFY(x) __STRINGIFY_IMPL(x)
+#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS)
+
+#define __PLUGIN_NAME "NewsAggregator"
+#define __INTERNAL_NAME "NewsAggregator"
+#define __FILENAME "NewsAggregator.dll"
+#define __DESCRIPTION "RSS/Atom news aggregator."
+#define __AUTHOR "Mataes, FREAK_THEMIGHTY"
+#define __AUTHOREMAIL "mataes2007@gmail.com"
+#define __AUTHORWEB "http://miranda-ng.org/"
+#define __COPYRIGHT "© 2012 Mataes, FREAK_THEMIGHTY"
diff --git a/plugins/NewsAggregator/Src/resource.h b/plugins/NewsAggregator/Src/resource.h new file mode 100644 index 0000000000..f243b95585 --- /dev/null +++ b/plugins/NewsAggregator/Src/resource.h @@ -0,0 +1,39 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Resource.rc
+//
+#define IDD_OPTIONS 101
+#define IDI_ICON 109
+#define IDD_ADDFEED 110
+#define IDI_CHECKALL 111
+#define IDI_ADDFEED 112
+#define IDI_IMPORTFEEDS 113
+#define IDI_EXPORTFEEDS 114
+#define IDC_TIMEOUT_VALUE_SPIN 1035
+#define IDC_FEEDLIST 1036
+#define IDC_ADD 1037
+#define IDC_CHANGE 1038
+#define IDC_REMOVE 1039
+#define IDC_IMORT 1040
+#define IDC_EXORT 1041
+#define IDC_FEEDTITLE 1042
+#define IDC_FEEDURL 1043
+#define IDC_CHECKTIME 1044
+#define IDC_DISCOVERY 1045
+#define IDC_USEAUTH 1046
+#define IDC_LOGIN 1047
+#define IDC_PASSWORD 1048
+#define IDC_TAGSEDIT 1049
+#define IDC_RESET 1050
+#define IDC_TAGHELP 1051
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 111
+#define _APS_NEXT_COMMAND_VALUE 40075
+#define _APS_NEXT_CONTROL_VALUE 1052
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/NewsAggregator/docs/AtomText.txt b/plugins/NewsAggregator/docs/AtomText.txt new file mode 100644 index 0000000000..052516a6bb --- /dev/null +++ b/plugins/NewsAggregator/docs/AtomText.txt @@ -0,0 +1,482 @@ +<?xml version="1.0"?>
+
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <updated>2012-01-04T06:45:38Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic</id>
+
+ <title>watcher-miranda project updates - Google Code</title>
+
+ <link rel="self" type="application/atom+xml;type=feed" href="http://code.google.com/feeds/p/watcher-miranda/updates/basic"/>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/updates/list"/>
+
+ <entry>
+ <updated>2012-01-04T06:45:38Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z12pftbjzm31hlgp204cepjgmoicsl1oq1w</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=miranda-0.10.latest-vc2010_x64-static.7z" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=miranda-0.10.latest-vc2010_x64-static.7z">miranda-0.10.latest-vc2010_x64-static.7z</a> (Miranda IM 0.10.0 Alpha #2 VC2010 x64) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2012-01-03T21:06:03Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z12qdzfqdumlchjgm04cepjgmoicsl1oq1w</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=miranda-v0100a2w11.7z" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=miranda-v0100a2w11.7z">miranda-v0100a2w11.7z</a> (T - ) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2012-01-03T20:47:25Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z135ypx45kehgtcq304cepjgmoicsl1oq1w</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=miranda-v0100a2w11.7z" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=miranda-v0100a2w11.7z">miranda-v0100a2w11.7z</a> (Miranda IM 0.10.0 Alpha #2 VC6111) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2012-01-03T09:21:55Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z12szb1zzybuejnnv22pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=mirotr1.7z" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=mirotr1.7z">mirotr1.7z</a> (Miranda IM 0.10.0 Alpha #2 VC6) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2012-01-02T20:12:28Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z12ltxpzuvr4xvahk04cepjgmoicsl1oq1w</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=miranda32.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=miranda32.exe">miranda32.exe</a> (Miranda32 v.0.9.40.0) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2012-01-01T18:00:06Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13idtjadwu5y3q2322pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.1.0.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.1.0.exe">Miranda IM Watcher Pack v3.1.0.exe</a> (Miranda IM Watcher Pack v3.1.0) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+
+ <span class="ot-field-label">Type-Installer</span>
+
+
+
+ <span class="ot-field-label">OpSys-Windows</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-30T11:06:47Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z12vzfygpwqng3m3b22pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda_Empoli_Pack_Mod.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda_Empoli_Pack_Mod.exe">Miranda_Empoli_Pack_Mod.exe</a> (Miranda IM Empoli Pack Mod v.2.2 (core 0.9.39)) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-29T14:08:24Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z135in4x1yi1fd2ou04cepjgmoicsl1oq1w</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=mirotr.7z" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=mirotr.7z">mirotr.7z</a> (MirOTR 0.11.0.3) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-25T10:59:24Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13dgrs5elfkfp0n122pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=LangpackSuite.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=LangpackSuite.exe">LangpackSuite.exe</a> (Test upload) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-25T10:58:18Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13cu14hyzzawjmev22pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=LangpackSuite.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=LangpackSuite.exe">LangpackSuite.exe</a> (Test) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-21T21:55:28Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z12sh1jqflzkj3ofd22pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.9.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.9.exe">Miranda IM Watcher Pack v3.0.9.exe</a> (Miranda IM Watcher Pack v3.0.9) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+
+ <span class="ot-field-label">Type-Installer</span>
+
+
+
+ <span class="ot-field-label">OpSys-Windows</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-13T19:46:02Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13nxvbpft3ezr5ps04cepjgmoicsl1oq1w</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.8.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.8.exe">Miranda IM Watcher Pack v3.0.8.exe</a> (Miranda IM Watcher Pack v3.0.8) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+
+ <span class="ot-field-label">Type-Installer</span>
+
+
+
+ <span class="ot-field-label">OpSys-Windows</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-04T10:52:49Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13vubiqswqqe1cf222pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Fingerprint.dll" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Fingerprint.dll">Fingerprint.dll</a> (Fingerprint.dll WP update) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-04T10:52:32Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z125fjy5qruixxloh04cepjgmoicsl1oq1w</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=PackUpdater.dll" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=PackUpdater.dll">PackUpdater.dll</a> (PackUpdater.dll WP update) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-03T15:01:42Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13etferquvuyzd0z22pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=packupdater.7z" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=packupdater.7z">packupdater.7z</a> (Pack Updater 0.0.1.0) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-12-02T22:21:54Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z12ysnhy4zi2wvudo22pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=fingerprintmodplus.7z" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=fingerprintmodplus.7z">fingerprintmodplus.7z</a> (Fingerprint Mod Plus 0.2.2.4 (latest svn revision)) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-11-28T06:15:02Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13hy1xpcr2hgbrfv22pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.7.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.7.exe">Miranda IM Watcher Pack v3.0.7.exe</a> (Miranda IM Watcher Pack v3.0.7) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+
+ <span class="ot-field-label">Type-Installer</span>
+
+
+
+ <span class="ot-field-label">OpSys-Windows</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-11-24T16:35:48Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13mcvxqurmeybypn04cepjgmoicsl1oq1w</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.6.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.6.exe">Miranda IM Watcher Pack v3.0.6.exe</a> (Miranda IM Watcher Pack v3.0.6) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+
+ <span class="ot-field-label">Type-Installer</span>
+
+
+
+ <span class="ot-field-label">OpSys-Windows</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-11-23T04:58:16Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13rxxbauu3wxtfmz22pfv4p3ma4ch5kj</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=simplestatusmsg.7z" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=simplestatusmsg.7z">simplestatusmsg.7z</a> (Simple Status Message 1.9.0.4) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+ <entry>
+ <updated>2011-11-19T06:13:19Z</updated>
+ <id>http://code.google.com/feeds/p/watcher-miranda/updates/basic/z13di1rprvjfhpta004cepjgmoicsl1oq1w</id>
+ <link rel="alternate" type="text/html" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.5.exe" />
+ <title type="html"><a class="ot-download-link" href="http://code.google.com/p/watcher-miranda/downloads/detail?name=Miranda%20IM%20Watcher%20Pack%20v3.0.5.exe">Miranda IM Watcher Pack v3.0.5.exe</a> (Miranda IM Watcher Pack v3.0.5) file uploaded by <a class="ot-profile-link-2" href="http://code.google.com/u/watcherhd/">watcherhd</a></title>
+ <author>
+ <name>watcherhd</name>
+ </author>
+ <category term="ProjectNewDownload" scheme="http://code.google.com/updates/type"/>
+ <content type="html"><div class="ot-labels-field-wrapper">
+ <span class="ot-labels-field-name">Labels: </span>
+ <span class="ot-labels-field-value">
+
+
+ <span class="ot-field-label">Featured</span>
+
+
+
+ <span class="ot-field-label">Type-Installer</span>
+
+
+
+ <span class="ot-field-label">OpSys-Windows</span>
+
+
+ </span>
+ </div></content>
+</entry>
+
+
+</feed>
diff --git a/plugins/NewsAggregator/docs/RssText.txt b/plugins/NewsAggregator/docs/RssText.txt new file mode 100644 index 0000000000..b229fc9e78 --- /dev/null +++ b/plugins/NewsAggregator/docs/RssText.txt @@ -0,0 +1,713 @@ +<?xml version="1.0" encoding="windows-1251"?>
+<rss version="2.0"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/">
+ <channel>
+ <title>Bash.Org.Ru</title>
+ <link>http://bash.org.ru/</link>
+ <atom:link href="http://bash.org.ru/rss/" rel="self" type="application/rss+xml" />
+ <description>Öèòàòíèê Ðóíåòà</description>
+ <language>ru</language>
+ <item>
+ <guid isPermaLink="false">b3cf2d64d57bdfea405b43426ec354e4b89a98912c71f243c93568020e2f0a70</guid>
+ <link>http://bash.org.ru/quote/414990</link>
+ <title>Öèòàòà #414990</title>
+ <pubDate>Fri, 30 Dec 2011 12:12:01 +0400</pubDate>
+ <description><![CDATA[xxx: Ýòî âñå ðàâíî ÷òî áðûçãàòü íà ïîðíîáàííåð ñâÿòîé âîäîé, à ïîòîì, êîãäà ìîíèòîð çàêîðîòèò, êðè÷àòü, ìîë, äüÿâîëüñêîå óñòðîéñòâî íå âûíåñëî ïðèñóòñòâèÿ ñâÿòîãî äóõà<br>]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">9f3028db6c6020de238a5d27b14d85c21e5f4c8a5f96506b757925df8500c940</guid>
+ <link>http://bash.org.ru/quote/414989</link>
+ <title>Öèòàòà #414989</title>
+ <pubDate>Fri, 30 Dec 2011 11:45:18 +0400</pubDate>
+ <description><![CDATA[ ïîëíîé ìåðå îñîçíàë, ÷òî ïåðåøåë íà íî÷íîé îáðàç æèçíè, êîãäà îòåö ðàçáóäèë â ÷àñ íî÷è ñ âîïðîñàìè: "Òû ÷åãî ñïèøü? Íå çàáîëåë ñëó÷àåì?"]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">c917324b76e57d2d6103af4b154f41fb335e9a4cc3f973b0b077a8c857c1353a</guid>
+ <link>http://bash.org.ru/quote/414988</link>
+ <title>Öèòàòà #414988</title>
+ <pubDate>Fri, 30 Dec 2011 11:44:38 +0400</pubDate>
+ <description><![CDATA[õõõ: íó êàê òåáå ôèëüì?<br>óóó: êîíåö òðó<br>õõõ: òû ôèëüì íå ïåðåïóòàë?<br>óóó: ÷åðò, â ñìûñëå, ôèíàë ìåíÿ ïðèÿòíî óäèâèë)]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">96b70712a7185b7d1167f6f9aee454841a4246b0f270185ea3f29d034b9bd39f</guid>
+ <link>http://bash.org.ru/quote/414987</link>
+ <title>Öèòàòà #414987</title>
+ <pubDate>Fri, 30 Dec 2011 11:44:01 +0400</pubDate>
+ <description><![CDATA[Îòçûâ î òåëåôîíå ñ ñåíñîðíûì ýêðàíîì:<br>Ñâåòà:<br>Êóïèëà åãî â ***. Êëàññíûé òåëåôîí!!! Åù¸ íå ðàçîáðàëàñü, êàê ñíÿòü áëîêèðîâêó ñ ýêðàíà. Îí êðàñèâûé.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">793886d798688d3e6bec7d2ffb51d6397f356e5c0e00ef06d07f22b87643c93a</guid>
+ <link>http://bash.org.ru/quote/414986</link>
+ <title>Öèòàòà #414986</title>
+ <pubDate>Fri, 30 Dec 2011 11:13:16 +0400</pubDate>
+ <description><![CDATA[xxx: ñåãîäíÿ ïðèøëà ïîñûëêà ïîñûëêà ñ ebay â êîòîðîé 50øò íàêëååê îò ipad. Òåïåðü ó ìåíÿ iÄîì, à â íåì iÓíèòàç, iØêàô, iÕîëîäèëüíèê è äàæå iÊîò êóäà òî óáåæàë....]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">6eac3f54c4f58d8a41c7e7f72f72ca6e0c6bf5869f0eefc99044ef4427db28d0</guid>
+ <link>http://bash.org.ru/quote/414985</link>
+ <title>Öèòàòà #414985</title>
+ <pubDate>Fri, 30 Dec 2011 11:12:02 +0400</pubDate>
+ <description><![CDATA[xxx: îòäàì 4-õ êîòÿò â ëþáûå ðóêè, èì óæå 3 ìåñÿöà è îíè âñåõ çàäîëáàëè.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">744d1d505dce7f1877c45baee1fdf97009a403d6dedb3ae1cd185480ec3dbbd0</guid>
+ <link>http://bash.org.ru/quote/414984</link>
+ <title>Öèòàòà #414984</title>
+ <pubDate>Fri, 30 Dec 2011 11:11:01 +0400</pubDate>
+ <description><![CDATA[xxx:<br>Ãäå êóïèòü êîðìîâûõ ìûøåé (ëûñûõ)?<br>Íà çîîðûíêå íåòó.<br><br>yyy:<br>Äîâåëè ñòðàíó... Íàðîä óæå ìûøåé æðàòü íà÷àë.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">aadc7f6194e8062c44250a9a878f010c0fe7d9d95af9a8389fbf8a8f748d6c6f</guid>
+ <link>http://bash.org.ru/quote/414983</link>
+ <title>Öèòàòà #414983</title>
+ <pubDate>Fri, 30 Dec 2011 10:45:08 +0400</pubDate>
+ <description><![CDATA[xxx: ó íàñ ¸ëêà íå ïðîñòàÿ, ïîíòîâàÿ<br>xxx: ñ îïòîâîëîêíîì è ñâåòèòñÿ<br>yyy: wifi áåñïëàòíî íå ðàçäàåò?]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">01511c230d7cdf4ed42f09106b3075a5021797ae5a11d3063dc9332bb7baf858</guid>
+ <link>http://bash.org.ru/quote/414982</link>
+ <title>Öèòàòà #414982</title>
+ <pubDate>Fri, 30 Dec 2011 10:44:36 +0400</pubDate>
+ <description><![CDATA[Darkforce: À òû ê ýêçàìåíó ñ ìóçûêîé ãîòîâèøüñÿ?<br>Ergo: Äà. È ñ âêëþ÷åííîé àñåé. Íå áåðè ñ ìåíÿ ïðèìåð.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">cc05613e48d3f285e2a2a95a12f542586c5c0fe4499addf3c2a633cf4940e572</guid>
+ <link>http://bash.org.ru/quote/414981</link>
+ <title>Öèòàòà #414981</title>
+ <pubDate>Fri, 30 Dec 2011 10:44:01 +0400</pubDate>
+ <description><![CDATA[<Jakiro> ñåãîäíÿ âåøàë ãèðëÿíäó, çàïóòàëñÿ â íåé, ñåë, ïðèøëà ñåñòðà, âêëþ÷èëà ãèðëÿíäó è ïîøëà ðæàòü :(]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">589fe99078c1447d672503cd8ffb9ba7524d9bd9e03cb5444e7c6fcd2be55269</guid>
+ <link>http://bash.org.ru/quote/414980</link>
+ <title>Öèòàòà #414980</title>
+ <pubDate>Fri, 30 Dec 2011 10:12:44 +0400</pubDate>
+ <description><![CDATA[SeeR: Åñëè ñ÷èòàòü êîýôôèöèåíò ëåíè ðàâíûì îòíîøåíèþ òîãî, ÷òî íóæíî áûëî ñäåëàòü, ê òîìó, ÷òî ñäåëàíî, òî ïî âîñêðåñåíüÿì ÿ òðàäèöèîííî äåëþ íà íîëü.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">58b960aeadb0e2700dd3ec5c18a0f9ca1f446d49f66edabf2ad3ea0f4a9f4933</guid>
+ <link>http://bash.org.ru/quote/414979</link>
+ <title>Öèòàòà #414979</title>
+ <pubDate>Fri, 30 Dec 2011 10:12:01 +0400</pubDate>
+ <description><![CDATA[Ñòèíà: Ãëóïî áûëî ïðèíèìàòü âàííó ñ áîìáî÷êîé ñ áëåñòêàìè. Ìû â áëåñòêàõ, ïîëîòåíöà â áëåñòêàõ, ïîñòåëüíîå áåëüå â áëåñòêàõ, äàæå êîøêà óæå â áëåñòêàõ.<br>Íî åùå ãëóïåå áûëî íàóòðî èäòè ê ãèíåêîëîãó! >.<]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">dda44cf9be0c8bf4691ce24629fd67dca371952e1dc45aa5dc1cce16ca095d29</guid>
+ <link>http://bash.org.ru/quote/414978</link>
+ <title>Öèòàòà #414978</title>
+ <pubDate>Fri, 30 Dec 2011 09:46:04 +0400</pubDate>
+ <description><![CDATA[BaDMaN: íåíàâèæó óòðî ñóááîòû. Ïðàâäà, îíî íå âñåãäà óòðîì è íå âñåãäà â ñóááîòó.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">33f18d83baf27fbd1e28e525c942b2c7e379b42a7d91f7436e2e199400ceda30</guid>
+ <link>http://bash.org.ru/quote/414977</link>
+ <title>Öèòàòà #414977</title>
+ <pubDate>Fri, 30 Dec 2011 09:45:01 +0400</pubDate>
+ <description><![CDATA[ÕÕÕ: Ñêàéðèìñêèå íîðäû òàêèå áðóòàëüíûå, ÷òî ñóðîâûå ÷åëÿáèíñêèå ìóæèêè ïî ñðàâíåíèþ ñ íèìè äåâî÷êè èç ïåñî÷íèöû. Íî ïðè ýòîì â êàæäîé ïåùåðå ñàìîãî æåñòîêîãî ðàçáîéíèêà, â êàæäîì äîìå ñàìîãî ÿðîñòíîãî íîðäà íà ñòîëå èëè ïîëêå ñòîèò ñëàäêèé ðóëåò.<br>ÓÓÓ: Ðóëåòèêè ôèãíÿ. Âñå òàìðèýëüñêèå ðàçáîéíèêè è ìàðîä¸ðû ïîääåðæèâàþò ñðåäè ñåáÿ âûñîêóþ ãðàìîòíîñòü è äàæå â ñàìîì ðàñïðîïàùåì, çàðîñøåì ìõîì è ïàóòèíîé ëîãîâå âñåãäà åñòü äâå-òðè êíèæå÷êè. Âîò òàê ïðèõîäèò áðóòàëüíûé ñêàéðèìñêèé äîðîæíûé ðàçáîéíèê ïîñëå òÿæ¸ëîãî òðóäîâîãî áóäíÿ, ñàäèòñÿ íà õëèïêèé òàáóðåòèê, áåð¸ò ñëàäêèé ðóëåòèê è ÷èòàåò "êðàòêóþ èñòîðèþ èìïåðèè". áðóòàëüíåíüêî.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">5599090163fe32efddbf295e457fd9cc4f3426b524eebaaaa4fa8277f34e9be2</guid>
+ <link>http://bash.org.ru/quote/414976</link>
+ <title>Öèòàòà #414976</title>
+ <pubDate>Fri, 30 Dec 2011 09:13:01 +0400</pubDate>
+ <description><![CDATA[xxx: ìîé äðóã êàæäóþ ñóááîòó õîäèò â êèíîòåàòð!<br>yyy: òîððåíòû çàìàëèâàåò?]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">1bb26a5bc553b0570cbdf64be1a9ba3af74c3fd64dc60fe0bf9335ecb74600d0</guid>
+ <link>http://bash.org.ru/quote/414975</link>
+ <title>Öèòàòà #414975</title>
+ <pubDate>Fri, 30 Dec 2011 08:45:35 +0400</pubDate>
+ <description><![CDATA[xxx: Ìàëåíüêèé Ïåòÿ î÷åíü ëþáèò ïîäàðêè. Åãî ìàìà ïîäàðèëà åìó íà äåíü ðîæäåíèÿ äâå ñòðîêè ðàâíîé äëèíû, ñîñòîÿùèå èç áîëüøèõ è ìàëåíüêèõ áóêâ ëàòèíñêîãî àëôàâèòà. Òåïåðü Ïåòÿ õî÷åò ñðàâíèòü ýòè ñòðîêè ëåêñèêîãðàôè÷åñêè. Ïîìîãèòå Ïåòå âûïîëíèòü ñðàâíåíèå. (facepalm)<br>yyy: Ïîìîãèòå Ïåòå íå çàêîí÷èòü æèçíü ñóèöèäîì :D]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">cf4da48b55d3fdb9e9825e39a664bd4d41dc5c7a64227796ad1afb0900bdec19</guid>
+ <link>http://bash.org.ru/quote/414974</link>
+ <title>Öèòàòà #414974</title>
+ <pubDate>Fri, 30 Dec 2011 08:45:01 +0400</pubDate>
+ <description><![CDATA[Äàâíûì-äàâíî, êîãäà åù¸ íå áûëî áàòàðååê è àêêóìóëÿòîðîâ, ñàäèëîñü ñîëíöå. Åãî òîæå õâàòàëî îò ñèëû íà äåíü, íå áîëüøå.<br>]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">1a7a8ba066100acdf40b79f4fbc967932320641e3565b230678920432e80e1e3</guid>
+ <link>http://bash.org.ru/quote/414973</link>
+ <title>Öèòàòà #414973</title>
+ <pubDate>Fri, 30 Dec 2011 08:12:44 +0400</pubDate>
+ <description><![CDATA[xxx: òîëüêî â àðìèè ïîíèìàåøü, ÷òî çóáíàÿ ùåòêà ðåàëüíî äëÿ òðóäíîäîñòóïíûõ ìåñò...]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">339e00558b293e087749ba42e0f06916531e712b1edfb25e470e2c0d10494aea</guid>
+ <link>http://bash.org.ru/quote/414972</link>
+ <title>Öèòàòà #414972</title>
+ <pubDate>Fri, 30 Dec 2011 08:11:44 +0400</pubDate>
+ <description><![CDATA[Ñ ôîðóìà<br><br>XXX: Çäðàâñòâóéòå, ñêàæèòå ïîæàëóéñòà, êàêîâ ñðîê ãîäíîñòè ó ñèãàðåò?<br>Êóïèë ïà÷êó ñèãàðåò è ÷óâñòâóþ, ÷òî êàêèå òî îíè õðåíîâûå, ñíà÷àëà ïîäóìàë, ÷òî ýòî ñâÿçàíî ñ òåì, ÷òî ÿ ñåé÷àñ ïûòàþñü áðîñèòü êóðèòü (ðàíüøå êóðèë ïà÷êó â äåíü, à ùàñ ïà÷êó íà íåäåëþ òÿíó) è íà÷àë îòâûêàòü, ïîòîì ãëÿíóë íà ñðîê èçãîòîâëåíèÿ, à òàì íàïèñàíî èþëü 2008ã...<br><br>YYY: Áîèòåñü íàâðåäèòü çäîðîâüþ? )))]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">cfa6ff32cedafbf49ef812730e850a6abc9ec61c7682f3518d95fa00db4e1a14</guid>
+ <link>http://bash.org.ru/quote/414971</link>
+ <title>Öèòàòà #414971</title>
+ <pubDate>Fri, 30 Dec 2011 08:11:01 +0400</pubDate>
+ <description><![CDATA[R*: íè÷î òàê ïðîãà. ðàáî÷èå ìåñòà ïîëüçîâàòåëåé íà ñõåìå ìîæíî èçîáðàçèòü î÷åíü ðàçíîîáðàçíî - åñòü êàðòèíêè îëåíÿ, êåíãóðó, îâöû, æèðàôà]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">128696d56057a228c43deb8cad49205905868817d0b4e834e37e3fdaccecafb4</guid>
+ <link>http://bash.org.ru/quote/414970</link>
+ <title>Öèòàòà #414970</title>
+ <pubDate>Thu, 29 Dec 2011 12:12:42 +0400</pubDate>
+ <description><![CDATA[xxx: ß òàêàÿ, êàêàÿ ÿ åñòü!!<br>yyy: Äà, è ãëàçà ó òåáÿ öâåòà òâîèõ ãëàç.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">2d15491a51b88af3e66c02b4d326f1e2802656b6361f8f07dd667fbbe9dce728</guid>
+ <link>http://bash.org.ru/quote/414969</link>
+ <title>Öèòàòà #414969</title>
+ <pubDate>Thu, 29 Dec 2011 12:11:34 +0400</pubDate>
+ <description><![CDATA[õõõ: Äà ó ìåíÿ âîîáùå òàêîå îùóùåíèå, ÷òî âñå ïîêóïàåìûå ìíîþ ñðåäñòâà äëÿ óêðåïëåíèÿ è ðîñòà âîëîñ íå çàäåðæèâàÿñü íà ãîëîâå íà÷èíàþò äåéñòâîâàòü â îáëàñòè íèæíèõ êîíå÷íîñòåé è ïðîìåæíîñòè...]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">ed64e480321c46a51035c44a445cfd98927e2e303d972ac8874e8e36c11a8371</guid>
+ <link>http://bash.org.ru/quote/414968</link>
+ <title>Öèòàòà #414968</title>
+ <pubDate>Thu, 29 Dec 2011 12:11:01 +0400</pubDate>
+ <description><![CDATA["Ïî÷åìó ïðîãðàììèñòû ðàáîòàþò ïî íî÷àì" @habr<br><br>troydm: Àáñîëþòíî ñîãëàñåí ñ àâòîðîì, èìåííî ïîýòîìó ÿ ëîæóñü ñïàòü â 5 óòðà è ïðîñûïàþñü â ÷àñ äíÿ! Âñåì ñïîêîéíîé íî÷è!<br>muzhig: Ýòî ìîæíî ñåáå ïîçâîëèòü, åñëè íåò æåíû. À âîò ìîåé î÷åíü íå íðàâèòñÿ êîãäà ÿ ðàáîòàþ ïî íî÷àì. Âñå îáúÿñíåíèÿ ïðî òî ÷òî «íî÷üþ íàìíîãî ëó÷øå ðàáîòàåòñÿ» îíà íå õî÷åò âîñïðèíèìàòü âñåðü¸ç.<br>ozgg: Íó æåíó ìîæíî òîæå íàó÷èòü ïðîãðàììèðîâàòü, è ãðàôèê ñèíõðîíèçèðóåòñÿ ;)<br>Vexilurz: Êîíå÷íî. Äåëîâ-òî íà 5 ìèíóò]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">aaa2f3a8dd486d209a697ecd4e3d728d99a2aa37dd482a3a859af5c473143b69</guid>
+ <link>http://bash.org.ru/quote/414967</link>
+ <title>Öèòàòà #414967</title>
+ <pubDate>Thu, 29 Dec 2011 11:46:07 +0400</pubDate>
+ <description><![CDATA[Íàøåë íà ñàéòå îäíîé íàó÷íîé ëàáîðàòîðèè â ñîòðóäíèêàõ ÷åëîâåêà, êîòîðûé ëåò ýäàê 16 íàçàä óãíàë ó ìåíÿ âåëèê. Âîò äóìàþ, ìîæåò ñõîäèòü, ïîïðîñèòü ó íåãî âåëîñèïåä îáðàòíî, îí æå ãîâîðèë "äà ÿ ïðîêà÷óñü âîí äî òóäà è âåðíó!" :)))]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">dc470e391715c450eef79e82aaadfb0342ecc256504946f0a32d2f8c1160557e</guid>
+ <link>http://bash.org.ru/quote/414966</link>
+ <title>Öèòàòà #414966</title>
+ <pubDate>Thu, 29 Dec 2011 11:45:06 +0400</pubDate>
+ <description><![CDATA[vova_belkin:<br><br>Âîò ìîé ïðàäåäóøêà, íàïðèìåð, óõèòðèëñÿ ïðîêóòèòü è ïðîèãðàòü â êàðòû äî êîïåéêè âñå èìåíèå, íàñëåäñòâî è æåíèíî ïðèäàíîå àêêóðàò ê 1917 ãîäó.<br><br>È ñ òåõ ïîð ñ÷èòàëñÿ â íàøåì ñåìåéñòâå íåïðåðåêàåìûì àâòîðèòåòîì â âîïðîñàõ ðàñïîðÿæåíèÿ êàïèòàëîì.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">a7147227d4c9f64edae338c2cec9f4456a1214ea3f9d899c2486038abe99a8f5</guid>
+ <link>http://bash.org.ru/quote/414965</link>
+ <title>Öèòàòà #414965</title>
+ <pubDate>Thu, 29 Dec 2011 11:44:01 +0400</pubDate>
+ <description><![CDATA[íó-íó: åñëè àòåèçì - ýòî ðåëèãèÿ, òî íå ñîáèðàòü ìàðêè - ýòî õîááè]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">d35adf64ed961a7e7ff88e11a9b57760b1cd3f0a835f008b6e9782a27ee1a31a</guid>
+ <link>http://bash.org.ru/quote/414964</link>
+ <title>Öèòàòà #414964</title>
+ <pubDate>Thu, 29 Dec 2011 11:13:11 +0400</pubDate>
+ <description><![CDATA[xxx: äà íó íàõåð ýòó ñåññèþ. Ïîêà ó÷èë äèñêðåòíóþ ìàòåìàòèêó, çàáûë ïàðîëè îò äâóõ ïî÷òîâûõ ÿùèêîâ.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">8ce06ad45b760d6b51e2432476e5c13dc9158f589c9b662147b760b0a1b967ac</guid>
+ <link>http://bash.org.ru/quote/414963</link>
+ <title>Öèòàòà #414963</title>
+ <pubDate>Thu, 29 Dec 2011 11:12:01 +0400</pubDate>
+ <description><![CDATA[Îáñóæäåíèå íîâîé àíòðåñîëè â êëàäîâêå:<br><br>Íó òàì âñå êàê íàäî ñäåëàëè. Íî áàðàõëà òðàäèöèîííî áîëüøå, ÷åì ìåñòà ïîä íåãî. Ïðè÷åì âîò â ÷åì çàãàäêà áûòèÿ: âûíèìàåøü áàðàõëî èç êëàäîâêè, ïîëîâèíó âûêèäûâàåøü, îñòàâøååñÿ óáèðàåøü â êëàäîâêó, à îíî òóäà íå âëåçàåò!]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">c64eb292881cc760ac0d2f7ac0b1010a8047b1271d39a0bc759076633640bbb4</guid>
+ <link>http://bash.org.ru/quote/414962</link>
+ <title>Öèòàòà #414962</title>
+ <pubDate>Thu, 29 Dec 2011 10:45:24 +0400</pubDate>
+ <description><![CDATA[Lilith: ÿ áîþñü ãîòîâèòü êàëüìàðà<br>Lightning: ïî÷åìó???<br>Lilith: ó íåãî êëþâ, è åùå íàäî ÷òî-òî ñäèðàòü êàê ÷óëîê<br>Lightning: ÷å òû áîèøüñÿ, òàì âñå ñõîäèò êëàññíî<br>Lilith: âäðóã ÿ ñäåðó êàëüìàðà, à ñúåì ÷óëîê<br>Lilith: à åùå ó íèõ òàì ÷åðíèëüíèöà âðîäå, è èêðà<br>Lightning: íó áëèí, òû ïîòðîøèëà êîãî-íèáóäü âîîáùå êîãäà-íèáóäü?<br>Lilith: ÿ ÷òî, ïîõîæà íà ñàìöà êàëüìàðà?<br>Lilith: òîëüêî êîï÷åíóþ ìîéâó<br>Lightning: à êóðèöó? íå? åå òàê ñìåøíî åùå ìîæíî íàäåâàòü íà ðóêó è èãðàòü â òåàòð<br>Lightning: øåâåëèòü êðûëûøêàìè, åñëè ÷åðåç æîïó âñòàâèòü<br>Lightning: òàê âîò, êàëüìàðà ëåã÷å ïîòðîøèòü, îí ìÿãîíüêèé òàêîé<br>Lightning: è æîïû íåò]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">19ee3858da403abdebc2f2694ade27e224d83cb2d0325964d802f3313c1333de</guid>
+ <link>http://bash.org.ru/quote/414961</link>
+ <title>Öèòàòà #414961</title>
+ <pubDate>Thu, 29 Dec 2011 10:44:36 +0400</pubDate>
+ <description><![CDATA[ìóæ: äà êàê, êàê, õåðîâî :( íå ïåðåæèâó ÿ, íàâåðíîå, èñïûòàòåëüíûé ñðîê<br>ÿ: ïî÷åìó??<br>ìóæ: äà âîò áëèí. ðåøèë ïîêàçàòü ñåáÿ â õîðîøåì ñâåòå ïåðåä øåôîì. ïîæåëàë åìó ïðèÿòíîãî àïïåòèòà. à îí øåë íå â ñòîëîâóþ à â òóàëåò.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">e0270fd309b6e90cb9f26d9012a1db8ed681fd071f5848b395535442033ffe3a</guid>
+ <link>http://bash.org.ru/quote/414960</link>
+ <title>Öèòàòà #414960</title>
+ <pubDate>Thu, 29 Dec 2011 10:44:01 +0400</pubDate>
+ <description><![CDATA[Luba: ×åì çàíèìàåøüñÿ â îòïóñêå?<br>BreakDancer: Ðàçíûìè âàæíûìè äåëàìè<br>Luba: Íàïðèìåð?<br>BreakDancer: Äà âîò âñïîìíèë, ÷òî â äåòñòâå ó ìåíÿ áûë ïèñòîëåò, ñòðåëÿþùèé ïðèñîñêàìè<br>BreakDancer: è ðåøèë, ÷òî ðàç óæ ÿ âûðîñ äî 29 ëåò è ñòàë áîëüøèì<br>BreakDancer: òî è ïðèñîñêè òîæå äîëæíû áûòü áîëüøèìè!<br>BreakDancer: Ñäåëàë àðáàëåò, êîòîðûé ñòðåëÿåò âàíòóñîì]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">8187c704ade265c329ccc02384e4206607407657bc6c9b9425a9542f0cb5a6a1</guid>
+ <link>http://bash.org.ru/quote/414959</link>
+ <title>Öèòàòà #414959</title>
+ <pubDate>Thu, 29 Dec 2011 10:13:01 +0400</pubDate>
+ <description><![CDATA[Îáåùàþò, ÷òî äåòè, ðîæäåííûå â ãîä ×åðíîãî Äðàêîíà, áóäóò òâîð÷åñêèìè è àêòèâíûìè. Íî ìû-òî çíàåì, ÷òî ãëàâíîå äëÿ íèõ - èììóíèòåò ê ìàãèè!]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">1e5eadf8678f61893bcf84e0dfb41290f63266eab736941b7ca07653b70f17d4</guid>
+ <link>http://bash.org.ru/quote/414958</link>
+ <title>Öèòàòà #414958</title>
+ <pubDate>Thu, 29 Dec 2011 09:45:26 +0400</pubDate>
+ <description><![CDATA[Çâîíèò êóðüåð èç îäíîé êîíòîðû è ñïðàøèâàåò êàê äîáðàòüñÿ.<br>ß: äàëåå ìîñò ÷åðåç ðåêó, èäåòå ïî ìîñòó...<br>Ê: À ðåêà ãäå â ýòî âðåìÿ? Ñëåâà? Ñïðàâà?<br>ß: ÂÍÈÇÓ!<br>Ê: àãà, ïîíÿòíî...<br>ß: Äàëüøå ïåðåõîäèòå íà äðóãîé áåðåã, ñïóñêàåòåñü íà íàáåðåæíóþ...<br>Ê: À ÷¸, ïðÿìî äî êîíöà ìîñòà èäòè? èëè ðàíüøå ïîâåðíóòü?]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">b7c708279640f1efe4ec3401970cb89f075864203ed0fbeeb612e9592655a4c3</guid>
+ <link>http://bash.org.ru/quote/414957</link>
+ <title>Öèòàòà #414957</title>
+ <pubDate>Thu, 29 Dec 2011 09:44:52 +0400</pubDate>
+ <description><![CDATA[gutta_honey@lj<br>Ëèçà ôàíàò "Çâåçäíûõ âîéí". Ó íåå åñòü ôèãóðêà Äàðòà Âåéäåðà. Íî äåâ÷îíêà åñòü äåâ÷îíêà. Îíà, êàê ñ ïóïñèêîì, ñ íèì èãðàåò. Âîò ñåãîäíÿ:<br>- Äàðòó Âåéäåðó íóæíà êâàðòèðà! ß åãî ïîñåëþ â êîðîáêå èç-ïîä àïåëüñèíîâ.<br>Âîò òàê â æåíñêèõ ðóêàõ äàæå çëîäååâ ãàëàêòè÷åñêîãî ìàñøòàáà ïîñòèãàåò ñóäüáà ÷åáóðàøêè.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">e91f03e5e391060d916a7e7e827cb6eaeec132c17a1ac5d78af70d5368461ec5</guid>
+ <link>http://bash.org.ru/quote/414956</link>
+ <title>Öèòàòà #414956</title>
+ <pubDate>Thu, 29 Dec 2011 09:44:01 +0400</pubDate>
+ <description><![CDATA[ÕÕÕ: êòî ðàíî âñòà¸ò, òîãî êîò ðàçáóäèë :(]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">c805cfaf28bf072384933e50ea8e1c48f815063c3bfbfe05a0986d6b944bd14e</guid>
+ <link>http://bash.org.ru/quote/414955</link>
+ <title>Öèòàòà #414955</title>
+ <pubDate>Thu, 29 Dec 2011 09:13:01 +0400</pubDate>
+ <description><![CDATA[XXX: Áåæàòü, áåæàòü îòñþäà!<br>YYY: ×òî ó òåáÿ òàì?<br>XXX: Òîëüêî ÷òî êîììåð÷åñêèé ñ èñïîëíèòåëüíûì â êàáèíåòå îðàëè äðóã íà äðóãà: "Äà ÿ òàêèõ êàê òû â Àôãàíå ê ñòåíêå ñòàâèë" vs "À ÿ òàêèõ êàê òû íà çîíå ïåòóøèë". Ìíå ñòðàøíî.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">0636538a5462fc292f9b4fc6439cd6f7f8ab0fe79ba081c47e36d3d8338806fe</guid>
+ <link>http://bash.org.ru/quote/414954</link>
+ <title>Öèòàòà #414954</title>
+ <pubDate>Thu, 29 Dec 2011 08:46:01 +0400</pubDate>
+ <description><![CDATA[xxx: Äà òû ÷òî, ýòî æå áàÿíú.<br>xxx: Êðóãîâîðîò èíòåðíåòà.  òâèòòåð ïîñòÿò çàïèñè ïÿòèëåòíåé äàâíîñòè èç ÆÆ.<br>yyy: âîò íå âèäåëà, ææ îáîøåë ìåíÿ ñòîðîíîé<br>õõõ: Òàê ÿ è ãîâîðþ, â ÆÆ ïîñòèëè øóòêè ñ ôîðóìîâ, â ôîðóìû - ñ ôèäî...<br>õõõ: è òîëüêî â ôèäî îñíîâîïîëîæíèêè ñåòåâîãî þìîðà ïåðåïå÷àòûâàëè àíåêäîòû èç ãàçåò]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">c8591055f839c5dbc882d36e7a4d2db9ce399460048e8e0e6d466dd43a88cae1</guid>
+ <link>http://bash.org.ru/quote/414953</link>
+ <title>Öèòàòà #414953</title>
+ <pubDate>Thu, 29 Dec 2011 08:13:04 +0400</pubDate>
+ <description><![CDATA[Î ñåêñå:<br>xxx: îòëè÷íî! â ëàáîðàòîðíûõ òàêîãî íå áûëî,íî ÿ ÇÀ! )))<br>yyy:  ëàáîðàòîðèÿõ îïàñíî. çàöåïèë íå òó êîëáó - è âñå, ÷åì ãîðäèëñÿ âñþ æèçíü è ñ ÷åì æèë - ñ òèõèì øèïåíèåì êàïàåò íà ïîë... =(<br>xxx: Èëè âûñîêîâîëüòíàÿ óñòàíîâêà ïî êðåñòöîâîìó ñïëåòåíèþ... Ñòðóÿ ýÿêóëÿòà ïðîáèâàåò êèðïè÷íóþ ñòåíó è ðàíèò ëåêòîðà â ñîñåäíåé àóäèòîðèè!<br>xxx: Êàæåòñÿ, ÿ òîëüêî ÷òî ïðèäóìàë êëàññíîå àíèìå, äà?]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">714be978a8678d201b16981150150166752145feaefa2f159980d76051602d87</guid>
+ <link>http://bash.org.ru/quote/414952</link>
+ <title>Öèòàòà #414952</title>
+ <pubDate>Thu, 29 Dec 2011 08:11:54 +0400</pubDate>
+ <description><![CDATA[Ðåêëàìà íà ßíäåêñå èçâåñòíîé êîìïàíèè è ñëîãàí "Ïîïðîáóé ñ íàøèì âûáèðàòîðîì ïîäàðêîâ!"<br>Àãà, ÿ òîæå ïåðâûé ðàç íåïðàâèëüíî ïðî÷èòàë =)]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">dd7d36ba1543a7ac360b28c72f669816d3551bb09f34156635f80efbc9a4f390</guid>
+ <link>http://bash.org.ru/quote/414951</link>
+ <title>Öèòàòà #414951</title>
+ <pubDate>Thu, 29 Dec 2011 08:11:01 +0400</pubDate>
+ <description><![CDATA[Ñåãîäíÿ âûíîñèë ìóñîð â îôèñå, à ìîÿ êîëëåãà èãðàëà â âèíäó, çàäàâàÿ âîïðîñû:<br>- Âû óâåðåíû, ÷òî õîòèòå î÷èñòèòü êîðçèíó? Ôàéëû áóäóò óäàëåíû áåçâîçâðàòíî.<br>À ïîòîì ó ìåíÿ ïîðâàëñÿ ïàêåò è âåñü ìóñîð ðàçëåòåëñÿ ïî îôèñó, íà ÷òî êîëëåãà ïå÷àëüíî çàìåòèëà:<br>- Ïðîèçîøåë ñáîé ïðè î÷èñòêå êîðçèíû, ïåðåçàãðóçèòåñü è ïîïðîáóéòå ñíîâà...]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">174e14053635b5325be15ae0a37b47953115b33e0d082053064572907d2829a0</guid>
+ <link>http://bash.org.ru/quote/414950</link>
+ <title>Öèòàòà #414950</title>
+ <pubDate>Wed, 28 Dec 2011 12:46:01 +0400</pubDate>
+ <description><![CDATA[[QuizMaster7] Ïîâòîðÿþ âîïðîñ: Èìåííî îíè âåøàëè ïîä øåþ êîíÿ âîë÷üþ ãîëîâó, à íà ñåäëî ïðèêðåïðÿëè ìåòëó, ÷òîáû âûíþõèâàòü èçìåíó è âûìåòàòü åå èç ãîñóäàðñòâà<br>[QuizMaster7] Ïåðâàÿ ïîäñêàçêà: Êîëè÷åñòâî áóêâ: 9<br>[EwokDoUrden] ôèãàñå!<br>[EwokDoUrden] ÍÀÐÊÎÌÀÍÛ]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">691660b05378e2d242a7a60429e2cd94a44e8d2041b2facb2597cb21ec213fbf</guid>
+ <link>http://bash.org.ru/quote/414949</link>
+ <title>Öèòàòà #414949</title>
+ <pubDate>Wed, 28 Dec 2011 12:13:18 +0400</pubDate>
+ <description><![CDATA[Äîê: Áëÿ, õîäèë ïîêóðèòü íà áàëêîí, âèæó â óãëó ÷òî-òî ìîõíàòîå ñ óãðîæàþùåé òåíüþ.  ñòîðîíó øàðàõíóëñÿ. È óæå äóìàþ, ãëþêè îò áåññîííèöû ïðóò. Íå áëèí, ÿ ïðîñòî çàáûë, ÷òî â÷åðà åëêó êóïèë.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">634c63c05a37bbb5933ccae9bd50bbc4e04d2a27dfd2895ab8f4be5cc77a5707</guid>
+ <link>http://bash.org.ru/quote/414948</link>
+ <title>Öèòàòà #414948</title>
+ <pubDate>Wed, 28 Dec 2011 12:12:02 +0400</pubDate>
+ <description><![CDATA[XXX: âñå, ôèíèø! ÿ êîíå÷íî ðàçíûõ äåáèëîâ âèäåëà. è ê ñêðåïêàì â ïðèíòåðå óæå äàæå ïî÷òè ïðèâûêëà. è ñêîò÷ íà áàðàáàíå, áëèí, ïðèêëååííûé ñ ÷åñòíûìè ãëàçàìè "íó ÿ æå åãî äàæå íå îòêðûâàëà, ÿ íå çíàþ, êàê îí òóäà ïîïàë!". íî ÷òîáû òàê! ó ìåíÿ ñåé÷àñ ïðèíòåð ÊÀËÜÊÓËßÒÎÐ çàæåâàë!!! êàëüêóëÿòîð, áëèí!]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">2309307a0dd79a2f77f63dbbbf3239d5de3cd41409ce23750c0e8ebecd20466f</guid>
+ <link>http://bash.org.ru/quote/414946</link>
+ <title>Öèòàòà #414946</title>
+ <pubDate>Wed, 28 Dec 2011 11:44:57 +0400</pubDate>
+ <description><![CDATA[xxx:<br>îòäàì â äàð ïëååð<br>Explay T-7, ñëåãêà ïîäåðæàíûé (âõëàìèíó)]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">c58a33a67db26dab4b121d14ebad5cd80d78040eea517835a90bbdc81887b4dc</guid>
+ <link>http://bash.org.ru/quote/414945</link>
+ <title>Öèòàòà #414945</title>
+ <pubDate>Wed, 28 Dec 2011 11:44:01 +0400</pubDate>
+ <description><![CDATA[Êóïèëè ñ ñîòðóäíèöåé â îôèñ ëèêåðà. Ïîëîâèíó âûïèëè, îñòàòêè îíà çàìàòûâàåò â ïàêåòèê è ñòàâèò â õîëîäèëüíèê.<br>ß: Ìû ÷òî, òóò åãî è îñòàâèì?<br>Ñîòðóäíèöà: Íó äà, à ÷òî íàì òåðÿòü? )<br>ß: Íó, íàïðèìåð ðàáîòó....]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">3a8ab041c452b16f9f415d3f6d209f1d58f11ed2ab0ee5f928a5f6b8e22a78b9</guid>
+ <link>http://bash.org.ru/quote/414944</link>
+ <title>Öèòàòà #414944</title>
+ <pubDate>Wed, 28 Dec 2011 11:12:55 +0400</pubDate>
+ <description><![CDATA[<Belka> Âåñüìà ñìóòèëàñü, íàéäÿ â çàïèñíîé òåëåôîííîé êíèæêå ñâîåãî áåçãðàìîòíîãî áðàòà çàïèñü "Ìàêñ -ñîñåò".]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">d72696e62bb007bb3004d7403e5915734f7ca02ef54757e08cb0a689a1b4df4d</guid>
+ <link>http://bash.org.ru/quote/414943</link>
+ <title>Öèòàòà #414943</title>
+ <pubDate>Wed, 28 Dec 2011 11:12:01 +0400</pubDate>
+ <description><![CDATA[korsa: âîêðóã ìåíÿ òðè êîìïà, äâà òåëåôîíà è íàâèãàòîð<br>fintar: íóæíî ïåðåâåçòè èõ ÷åðåç ðåêó?]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">9ffbfa3d0268a0dc955b9969e4c2b77cc50443a7d6bd9b60f9cf4102daeb7fb1</guid>
+ <link>http://bash.org.ru/quote/414942</link>
+ <title>Öèòàòà #414942</title>
+ <pubDate>Wed, 28 Dec 2011 10:45:41 +0400</pubDate>
+ <description><![CDATA[Èç îáñóæäåíèÿ:<br>Êàê–òî ðàç ÿ â ñïîðå ñî ñâîåé æåíîé îáíàðóæèë êàêóþ–òî îòêðîâåííóþ äóðü â åå ñëîâàõ è ñêàçàë:<br>— Íî ýòî æå íå ëîãè÷íî!<br>— Íó è ÷òî?<br>Áëÿäü, ÍÓ È ×ÒÎ? â ýòîò ìîìåíò ó ìåíÿ âîîáùå âåñü ìèð ðóõíóë, è ÿ ïîíÿë ÷òî äëÿ íåå âîîáùå íåò ðàçíèöû, ëîãè÷íî èëè íåò òî, ÷òî îíà ãîâîðèò. ÂÎÎÁÙÅ!<br><br>Êîãäà ÿ ïåðåñêàçûâàþ ýòî ñâîèì äðóçüÿì, âñå õîõî÷óò èëè óëûáàþòñÿ. À êîãäà äåâóøêàì — îíè ïðîñòî æäóò, ÷òî ÿ äàëüøå ñêàæó, ñî âíèìàòåëüíûì ëèöîì, ïîòîìó ÷òî èñêðåííå íå çàìå÷àþò ïðîáëåìû â ýòîé ôðàçå]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">6017310e922bd529b5ad3be09f4f0c5e8b6b2fb76d0bd05b617a8eac0ae27193</guid>
+ <link>http://bash.org.ru/quote/414941</link>
+ <title>Öèòàòà #414941</title>
+ <pubDate>Wed, 28 Dec 2011 10:44:47 +0400</pubDate>
+ <description><![CDATA[xxx: ó íàñ â ñòîëîâîé äàâíî âìåñòî ñàëôåòîê áóìàãà ïðîìûøëåííàÿ íàðåçàíà, íî ñåé÷àñ îíà åùå è ãëÿíöåâàÿ]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">b101af3976aa2e9b7841576433b0c68af93c3ce85ac75383a6f7b20a0106a9c6</guid>
+ <link>http://bash.org.ru/quote/414940</link>
+ <title>Öèòàòà #414940</title>
+ <pubDate>Wed, 28 Dec 2011 10:44:01 +0400</pubDate>
+ <description><![CDATA[Ñåé÷àñ ñ æåíîé ïî òåëåôîíó ðàçãîâàðèâàë.<br>Îíà ãîâîðèò:<br>- Äàâàé òåáå íà Íà ðóáàøêó ïîøüåì êëåâóþ è ýòî áóäåò ìîèì ïîäàðêîì.<br>- Êàê õî÷åøü.<br>Ïðåäëàãàåò ìåðêè ïîåõàòü ñíÿòü, ÿ íà÷èíàþ äèêòîâàòü.<br>- Äëèíà 174 ñì, øèðèíà 80 ñì. Âíóòðè òêàíü áàðõàò, ñíàðóæè äåðåâî, ëó÷øå äóá, êðûøêà òîæå äóáîâàÿ ðåçíàÿ.<br>Îíà ãîâîðèò:<br>- Âñå çàïèñàëà, ñåé÷àñ èì ïîçâîíþ.<br>È òóò îíà ïðî÷èòàëà òî, ÷òî çàïèñàëà...]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">1d3da2d78ecf5bac86c480e26d65184e8b69cab96bc8d6c038de7de9ca468ebd</guid>
+ <link>http://bash.org.ru/quote/414939</link>
+ <title>Öèòàòà #414939</title>
+ <pubDate>Wed, 28 Dec 2011 10:13:07 +0400</pubDate>
+ <description><![CDATA[õõõ: Ó íàñ ñåãîäíÿ ýêçàìåí ïî àíàòîìèè âîîáùå çà÷åòíûé âûøåë. Îäèí ïàðåíü ñðåç ãîðòàíè íàçâàë ñðåçîì øåéêè ìàòêè, äðóãîé â ðîìáîâèäíîé ÿìêå ìîçãà ïðèìåòèë, çâèíÿþñü, âóëüâó.<br>õõõ: Îáîèõ îòïðàâèëè íà ïåðåñäà÷ó ñ ôîðìóëèðîâêîé "âûëå÷èòå íåäîòðàõ è ïðèõîäèòå ñíîâà".]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">0365ddac152e7a1f45d4fe35cc5d673ff9e9cbce8d9d125e40b5dca139cd293e</guid>
+ <link>http://bash.org.ru/quote/414938</link>
+ <title>Öèòàòà #414938</title>
+ <pubDate>Wed, 28 Dec 2011 10:12:01 +0400</pubDate>
+ <description><![CDATA[xxx: Æåíà ïîñëå ñóòîê íà ðàáîòå ïîïðîñèëà ðàçáóäèòü åå â 20:00. Çâîíþ, îíà ïîäíèìàåò òðóáêó, íè÷åãî íå ãîâîðèò, ñëûøíî òîëüêî ìèðíîå ñîïåíèå... Âûêëþ÷èëà áóäèëüíèê, áëèí :D]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">8774184a10feb87ab76c3eac63fcf6873b572cd376d06b87ec2cafa48464b57b</guid>
+ <link>http://bash.org.ru/quote/414937</link>
+ <title>Öèòàòà #414937</title>
+ <pubDate>Wed, 28 Dec 2011 09:45:31 +0400</pubDate>
+ <description><![CDATA[Ascha: êàê óäîáíî: åñëè ðåâåòü äâà ÷àñà ïîäðÿä - òî òóøü ñìûâàòü óæå íå íóæíî!]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">5f9e58d114c8a86764bd26780e94bb3f00f0a4db026821f84d06b4540db7b5ed</guid>
+ <link>http://bash.org.ru/quote/414936</link>
+ <title>Öèòàòà #414936</title>
+ <pubDate>Wed, 28 Dec 2011 09:45:01 +0400</pubDate>
+ <description><![CDATA[xxx: ÿ çàéäó ùàñ?<br>yyy: ß - ãîðÿ÷àÿ øòó÷êà. È ÿ óæå âñÿ òåêó. Íî áóäü ñî ìíîé îñòîðîæåí.<br>xxx: Àíÿ?<br>yyy: Ó ìåíÿ òåìïåðàòóðà. Ñîïëè ðó÷üåì. Ðèñêóåøü çàðàçèòüñÿ.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">8b1acd9ec8457ac318c78b1dc88005edf4fc9f0ace4d47c1080c1b670de19e2e</guid>
+ <link>http://bash.org.ru/quote/414935</link>
+ <title>Öèòàòà #414935</title>
+ <pubDate>Wed, 28 Dec 2011 09:13:01 +0400</pubDate>
+ <description><![CDATA[Duck: Ðåøèë ïîïðàâèòü çäîðîâüå, çàïèñàëñÿ â áàññåéí.<br>Dimes: óðèíîòåðàïèÿ íå ðàáîòàåò]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">187c05af1edfcce0de5da82d30a58fb83ae474e6fa897ad684bd3ad7c50e9dd7</guid>
+ <link>http://bash.org.ru/quote/414934</link>
+ <title>Öèòàòà #414934</title>
+ <pubDate>Wed, 28 Dec 2011 08:46:02 +0400</pubDate>
+ <description><![CDATA[xxx: Ìåíÿ ïîïðîñèëè â ìåòðî ïðîéòè ÷åðåç ðàìêó<br>yyy: êàêîãî õ?<br>xxx: Õðåí åãî çíàåò<br>yyy: òû ïîêàçàëñÿ èì ïîäîçðèòåëüíûì? )<br>xxx: Áûë êàê âñåãäà â äæèíñàõ ÷èñòûõ áîòèíêàõ êîæàíîé ñóìêå è íàãëîé ðîæåé<br>xxx: Ìåíÿ êàê ïðàâèëî îíè âîîáùå íå çàìå÷àþò<br>yyy: õû<br>yyy: òû áûë â êîæàíîé ñóìêå, ýòî íàñòîðàæèâàåò]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">00822e572762f43d2fb56ef00c2f7be12f703a27a39949f99036f7734a26f566</guid>
+ <link>http://bash.org.ru/quote/414933</link>
+ <title>Öèòàòà #414933</title>
+ <pubDate>Wed, 28 Dec 2011 08:45:02 +0400</pubDate>
+ <description><![CDATA[misterIT: Ñàíü, ïðèâåò. ñðî÷íî íóæíà ïîìîùü, ÷åðåç ñêîëüêî ìîæåøü â îôèñ ïîäãðåñòè?<br>misterIT: Äîìåí ðóõíóë, ðåéä çàãëþ÷èëî. È âèíò ïðèõâàòè.<br>misterIT: Ñàíü!!! òû òóò?<br>xxx@qip: Òóò, ñîáèðàþñü, à ÷òî ñëó÷èëîñü òî? Íàïðÿæåíèå? Êîðîòíóëî?<br>misterIT: Äà õç<br>misterIT: Áîðîäó â÷åðà ñáðèë, ñâèäàíèå áëÿäü âèäèòå ëè!<br>xxx@qip: À ÿ ñâèòåð ïîñòèðàë. Âèäèìî íå âðàëè.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">a6231be02247fcfffbaa07e020f43a4c7a1c7ed628ed86af16443ffe45ed7127</guid>
+ <link>http://bash.org.ru/quote/414932</link>
+ <title>Öèòàòà #414932</title>
+ <pubDate>Wed, 28 Dec 2011 08:12:38 +0400</pubDate>
+ <description><![CDATA[xxx: Æåíùèíû - êàê êîìïüþòåðíûå èãðû ñ ðàçíûìè óðîâíÿìè ñëîæíîñòè. Åñëè èãðàòü íà Very Easy - òî áûñòðî ïðîïàäàåò èíòåðåñ ê èãðå. À åñëè èãðàòü íà Very Hard - òî ìîæíî íàòåðåòü ìîçîëè äæîéñòèêîì.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">039ba4efda1619b3b4374b223e344b3423a8d9788a18bf73ac07bce7bac04bea</guid>
+ <link>http://bash.org.ru/quote/414931</link>
+ <title>Öèòàòà #414931</title>
+ <pubDate>Wed, 28 Dec 2011 08:12:01 +0400</pubDate>
+ <description><![CDATA[ß:<br>Æåíà ìíå òàêàÿ ãîâîðèò:<br>- ìíå íóæíà øóáà íîðêîâàÿ,<br>- ó òåáÿ æå åñòü,<br>- ó ìåíÿ èç êóñî÷êîâ, à ìíå íàäî öåëüíóþ, ó íàñ ó âñåé ãðóïïû óæå öåëüíûå, à z îäíà êàê ëîøàðà!<br>- ó âñåé - ýòî ó îäíîé Ëþäêè?<br>- íó íåò, ó äâîèõ òî÷íî åñòü!<br>- ... à ìíå íóæåí ôîòîàïïàðàò êýíîí 5ä ìàðê 2<br>- ó òåáÿ æå åñòü óæå.<br>- íó òàê ó ìåíÿ 5ä, à ÿ õî÷ó ÷òîáû áûë ìàðê 2, à òî ó âñåõ óæå â ãîðîäå ìàðêè, à ÿ îäèí êàê ëîøàðà<br>- íó òåáå-òî ïðîñòî õî÷åòñÿ, à ìíå... (âîò òóò âíèìàíèå!!!!) ÍÅÎÁÕÎÄÈÌÎ.<br><br>Êåìï:<br>õîðîøî, ÷òî òû íå ñêàçàë, ÷òî òû èì åùå è äåíüãè çàðàáàòûâàåøü, à òî îíà áû òåáå êàêóþ-íèáóäü àëüòåðíàòèâó ñ øóáîé ïðèäóìàëà]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">66fab6cb65e11c7de896d7c6840095b9a90bd70ed8d49f8fb7adc0adb9b6a43c</guid>
+ <link>http://bash.org.ru/quote/414930</link>
+ <title>Öèòàòà #414930</title>
+ <pubDate>Tue, 27 Dec 2011 13:46:01 +0400</pubDate>
+ <description><![CDATA[õõõ: Äðóã ìíå â÷åðà ðàññêàçàë. Îí áàðìåíîì ðàáîòàåò â çàâåäåíèè. Ïî÷òè â íî÷è ê íè íà÷àëè çàëàìûâàòüñÿ äâà ïüÿíûõ â çþçþ ÷óâàêà è îõðàíà èõ íå ïóñòèëà, òàê êàê çàâåäåíèå ïðèëè÷íîå. Ýòè äâà òèïà íå íàøëè íè÷åãî óìíåå è âûçâàëè ïîëèöèþ, òå ïðèåõàëè, èõ ñàìèõ æå çàáðàëè è óâåçëè!]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">39b40cb066f0a9b64c53dbc67c1a521a1b3948a5b021efd4b1982753059aaee1</guid>
+ <link>http://bash.org.ru/quote/414929</link>
+ <title>Öèòàòà #414929</title>
+ <pubDate>Tue, 27 Dec 2011 13:13:01 +0400</pubDate>
+ <description><![CDATA[xxx: ÿ èì çâîíèë<br>xxx: íåò ó íèõ âðåìåíè íà ïîíåäåëüíèê<br>yyy: ïå÷àëüêà<br>xxx: ýòî óæå íå ïå÷àëüêà<br>xxx: ýòî óæå çëîñòüêà, ÿðîñòüêà è ãíåâèê]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">4f3b79bfba6994d73b3eb21530d98188f4830c26c4f8108a6d8120a4c0b5e8fc</guid>
+ <link>http://bash.org.ru/quote/414928</link>
+ <title>Öèòàòà #414928</title>
+ <pubDate>Tue, 27 Dec 2011 12:46:01 +0400</pubDate>
+ <description><![CDATA[Êîììåíòû ê ñòàòüå "Êàê îñâîáîäèòüñÿ èç íàðó÷íèêîâ-ñòÿæåê":<br>xxx: À âîò èíòåðåñíî, åñëè òû åäåøü â áàãàæíèêå ìàøèíû, ÷òî äåëàòü?<br>yyy: åñëè íî÷üþ è â ëåñ – òî ýòî ïðîñòî ïëîõàÿ ïðèìåòà.<br>zzz: Âî âñ¸ì íàäî èñêàòü ïîçèòèâ! ß óâåðåí, ýòî áóäåò ïîñëåäíÿÿ ïëîõàÿ ïðèìåòà â âàøåé æèçíè! :)]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">d3162ccb1c30aa3f654c0c6b368fa9e583c020dc3d04bcc07b6c5f02eeadaaeb</guid>
+ <link>http://bash.org.ru/quote/414927</link>
+ <title>Öèòàòà #414927</title>
+ <pubDate>Tue, 27 Dec 2011 12:13:01 +0400</pubDate>
+ <description><![CDATA[zzz: Íó âîò êàê îáúÿñíèòü èíîñòðàíöó, ïî÷åìó âèëêà — ëåæèò, òàðåëêà — ñòîèò, à ïòèöà — ñèäèò?<br>xxx: Âîò, êñòàòè, íîóòáóê: êîãäà çàêðûòà êðûøêà — ëåæèò, à êîãäà îòêðûòà — ñòîèò…<br>yyy: ß êàæåòñÿ íà÷èíàþ ïîíèìàòü, ëåæèò — áåç òîëêó, à ñòîèò — âî èìÿ Âåëèêîé Ñïðàâåäëèâîñòè!<br>]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">69e05b82fc5a5028a65e0435a584a83ffaa44e9784c024fb30eda9b7d87f38ba</guid>
+ <link>http://bash.org.ru/quote/414926</link>
+ <title>Öèòàòà #414926</title>
+ <pubDate>Tue, 27 Dec 2011 11:46:03 +0400</pubDate>
+ <description><![CDATA[Sovershenstvo: ðàñïå÷àòàëà äîêóìåíò íà 115 ñòðàíèö. çàáèðàëà èç ïðèíòåðà. îáîæãëàñü î áóìàãó :(<br>iNote: ïðèíòåð ææîò :D]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">caa3a31eca89b56e3669c9910f23564e1ee2bd2c67f0be5472e206496b688609</guid>
+ <link>http://bash.org.ru/quote/414925</link>
+ <title>Öèòàòà #414925</title>
+ <pubDate>Tue, 27 Dec 2011 11:45:01 +0400</pubDate>
+ <description><![CDATA[Èç îáñóæäåíèÿ èñïîëüçîâàíèÿ àêóñòè÷åñêîãî äàò÷èêà äëÿ âêëþ÷åíèÿ êîìïüþòåðà õëîïêîì â ëàäîøè:<br>xxx: Áûë òàêîé ñëó÷àé.<br>xxx: Ïðèÿòåëü ñäåëàë àêóñòè÷åñêèé âûêëþ÷àòåëü íà îñâåùåíèå.<br>xxx: Äîñòàâàë êíèãè ñ ïîëêè, ñòîÿ íà òàáóðåòå.<br>xxx: Óïàëà êíèãà, ñâåò ïîòóõ, îí îñòóïèëñÿ, ñëîìàë ðóêó.<br>xxx: Ñâåò çàãîðåëñÿ.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">d3db54801b673716d6b41137bbf9ca64c62a04a1211bf43ea44876c411f88728</guid>
+ <link>http://bash.org.ru/quote/414924</link>
+ <title>Öèòàòà #414924</title>
+ <pubDate>Tue, 27 Dec 2011 11:13:12 +0400</pubDate>
+ <description><![CDATA[Îáñóæäàåì ñ ìóæåì Ñêàéðèì:<br>- Ìíå îäíîé êàæåòñÿ, ÷òî äðàóãè êóäàõòàþò? "Êóä-êó-äà", "Êóä-êó-äààààà"<br>- Ýòî åùå ÷òî. Â÷åðà ñêåëåò ïîäõîäèò êî ìíå è ÷åòêî òàê: "ïàñ-ïîðò".<br>- Ñóðîâûå ñêåëåòû äðåâíåñêàéðèìñêèõ ïîãðàíè÷íèêîâ. Èç âñåãî, ÷òî ëåïå÷óò, ìîæíî ðàçîáðàòü òîëüêî "ïàñïîðò" è "óõîäè" )]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">6206e668575ef7364ca52bacdfc3d6b45da5ab80d4c69c0f1467269cec9ee6c4</guid>
+ <link>http://bash.org.ru/quote/414923</link>
+ <title>Öèòàòà #414923</title>
+ <pubDate>Tue, 27 Dec 2011 11:12:01 +0400</pubDate>
+ <description><![CDATA[xxx: Óñòðîèë äèâåðñèþ íà ðàáîòå - ïðèí¸ñ èðèñ "Êèñ-Êèñ" (ñîâåòñêèé, æåëåçîáåòîííûé). <br>xxx: Òåïåðü íèêòî ñî ìíîé íå ðàçãîâàðèâàåò. <br>xxx: ÂÎÎÁÙÅ ÍÈÊÒÎ ÍÈ Ñ ÊÅÌ ÍÅ ÐÀÇÃÎÂÀÐÈÂÀÅÒ! )))]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">47c8ec43ac12036ac0528b4b4077f8d9f80a0fe8d4aa029f8a39b7b9d4327b6f</guid>
+ <link>http://bash.org.ru/quote/414922</link>
+ <title>Öèòàòà #414922</title>
+ <pubDate>Tue, 27 Dec 2011 10:45:34 +0400</pubDate>
+ <description><![CDATA[õõõ: ß ãîòîâëþñü ê çà÷åòó, òîëüêî î÷åíü îáäóìàííî. Ñî ñòîðîíû ýòî âûãëÿäèò, áóäòî ÿ ïðèìåðÿþ êèðçà÷è]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">7871bd6a1b62f062468316e82234015b27a0c448d21c39120579d4c66c1b3367</guid>
+ <link>http://bash.org.ru/quote/414921</link>
+ <title>Öèòàòà #414921</title>
+ <pubDate>Tue, 27 Dec 2011 10:45:01 +0400</pubDate>
+ <description><![CDATA[xxx: Ïåðååõàëè â íîâûé îôèñ. Ñïóñòÿ òðè ìåñÿöà îáíàðóæèëè ëþê ïîä íîãàìè, à èç ùåëè ñâåò ãîðèò. Äóìàåì òåïåðü - âñêðûâàòü, èëè íå ñòîèò.<br>yyy: Âû àêêóðàòíåé òàì. À òî ïîñóòî÷íî äåæóðèòü çàñòàâÿò è öèôåðêè ââîäèòü.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">c5fcb5c4cf429099d6540943fd5f376998aee7e5ac90409e8afc3e6a61ef177f</guid>
+ <link>http://bash.org.ru/quote/414920</link>
+ <title>Öèòàòà #414920</title>
+ <pubDate>Tue, 27 Dec 2011 10:13:01 +0400</pubDate>
+ <description><![CDATA[MG: Ìàìà ìîåé ìàìû ñêàçàëà ìîåé ìàìå: òâîþ æ ìàòü çà íîãó! È óïàëà.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">72838435dc732ed7410037dd17b0e38588ac91999f5f195421621a8355ded16e</guid>
+ <link>http://bash.org.ru/quote/414919</link>
+ <title>Öèòàòà #414919</title>
+ <pubDate>Tue, 27 Dec 2011 09:45:45 +0400</pubDate>
+ <description><![CDATA[Seryozha:<br>ðîçîâûé óæå íå ìîäíî â ýòîì ñåçîíå<br>ñòîÿë íà îñòàíîâêå<br>ïðîåõàë ìèìî ðîçîâûé ëèìóçèí<br>îäíà ôèôà äðóãîé ñêàçàëà, ÷òî ýòî áåçâêóñèöà<br>è ýòî âîîáùå óåáèùå<br>íó è ïîòîì ùåìèëèñü ñî ìíîé â àâòîáóñ]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">7b098f0d541bdc4ac0f90634a82e781d38e174ef380aa56ff6c94e69734fcde8</guid>
+ <link>http://bash.org.ru/quote/414918</link>
+ <title>Öèòàòà #414918</title>
+ <pubDate>Tue, 27 Dec 2011 09:44:43 +0400</pubDate>
+ <description><![CDATA[Worontzoff: Èçáèðàòåëüíûå ó÷àñòêè áóäóò îñíàùåíû êàìåðàìè, êóäà áóäóò ïîìåùàòü íàáëþäàòåëåé âî âðåìÿ ïîäñ÷åòà áþëëåòåíåé.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">5af15998f29f5f063b9ce01b54dc8d3f0b73bb7d3f877edcc5eaa7ff8f71013b</guid>
+ <link>http://bash.org.ru/quote/414917</link>
+ <title>Öèòàòà #414917</title>
+ <pubDate>Tue, 27 Dec 2011 09:44:01 +0400</pubDate>
+ <description><![CDATA[õõõ: Ó íàñ â äâà ÷àñà íî÷è ïðèøåñòâèå Âèííè Ïóõà<br>óóó:  ñìûñëå? Ìàìà ïðèøëà?<br>õõõ: Íå, Êîëÿ ìåä â õîëîäèëüíèêå íàøåë. Õîäèò ïî êâàðòèðå, íåæíî ïðèæèìàÿ ê ñåáå áàíêó. ß ñåãîäíÿ Ïÿòà÷îê]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">b5a66cb535552b46159d467911174f1e4aac941c8c1d891a62619a8cdb00a3ea</guid>
+ <link>http://bash.org.ru/quote/414916</link>
+ <title>Öèòàòà #414916</title>
+ <pubDate>Tue, 27 Dec 2011 09:13:02 +0400</pubDate>
+ <description><![CDATA[(ðàçãîâîð î "Ëåáåäèíîì Îçåðå")<br>xxx: ìîæåò áûòü, òû è ñþæåò ïîìíèøü?<br>yyy: î÷åíü ñìóòíî. ß ñîâñåì ìàëåíüêàÿ áûëà, êîãäà åãî â ïîñëåäíèé ðàç ïîêàçûâàëè...]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">9e007ee3d9984de85c727f6885f913891b11676f10b053ba8a51bec6fba0e23c</guid>
+ <link>http://bash.org.ru/quote/414915</link>
+ <title>Öèòàòà #414915</title>
+ <pubDate>Tue, 27 Dec 2011 08:46:11 +0400</pubDate>
+ <description><![CDATA[xxx: ïðèâåò<br>xxx: êàê ñëóæáà?<br>yyy: êàê ó ñëóæåáíîé ñîáàêè<br>yyy: öåëûé äåíü ñïàñàþ ìèð, à âå÷åðîì îáåùàëè ïîêîðìèòü]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">3dc9ddc2fad185181993315c5c3a404405ab704423d3c24bd9213dcb23bad2eb</guid>
+ <link>http://bash.org.ru/quote/414914</link>
+ <title>Öèòàòà #414914</title>
+ <pubDate>Tue, 27 Dec 2011 08:45:01 +0400</pubDate>
+ <description><![CDATA[õõõ: íåò, ÿ ñêîðåå ïîéäó óáèâàòü, ÷åì êðàñòü<br>óóó: ñòðàííàÿ ìîðàëü, ÷òî òàê?<br>õõõ: ÿ ÷åëîâåê ÷åñòíûé, à ïîòîìó çëîé]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">61e793991c5dea07ea5a5afa2bbc899e49c23d8a0d8a1f48918915129a13a35c</guid>
+ <link>http://bash.org.ru/quote/414913</link>
+ <title>Öèòàòà #414913</title>
+ <pubDate>Tue, 27 Dec 2011 08:12:04 +0400</pubDate>
+ <description><![CDATA[Ðå÷ü îá àóäèîíàðêîòèêàõ:<br><br>õõõ: Äà ôèãíÿ ýòî âñ¸!<br>yyy: Íó ïî÷åìó ôèãíÿ, åñòü æå çâóêè, êîòîðûå êàê-òî âîçäåéñòâóþò íà ïñèõèêó ÷åëîâåêà...<br>õõõ: Äà, íà ìåíÿ çâóê äðåëè òàê âîçäåéñòâóåò! Ñðàçó õî÷åòñÿ ïîéòè è óáèòü êîãî-íèáóäü!]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">ed2932ac0768ceb5ec1a155d4b039fb2cba050296935d7852baccb238ada1819</guid>
+ <link>http://bash.org.ru/quote/414912</link>
+ <title>Öèòàòà #414912</title>
+ <pubDate>Tue, 27 Dec 2011 08:11:31 +0400</pubDate>
+ <description><![CDATA[<xxx> ãîòîâèëè îáåä, ïîëåç â õîëîäèëüíèê<br><xxx> îêàçûâàåòñÿ, â÷åðà ÿ íåâîëüíî êóïèë ïðîäóêòîâûé íàáîð "Çëûå ïòèöû": íîãè êóðèíûå, ãðóäêà èíäåéêè, ñâèíûå ýñêàëîïû]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">1989a43d3a03de416d16788589caaa318ece611245b328df9b1567c13205cf70</guid>
+ <link>http://bash.org.ru/quote/414911</link>
+ <title>Öèòàòà #414911</title>
+ <pubDate>Tue, 27 Dec 2011 08:11:01 +0400</pubDate>
+ <description><![CDATA[xxx: ñêîëüçêî íà óëèöå, äàæå ñîáàêà ãóëÿòü íå õî÷åò<br>yyy: åé-òî ÷òî, ó íå¸ æ ïîëíûé ïðèâîä]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">c207fd198261176146047e54ccfff9058582e311ab402e32dfe67837c3e61e64</guid>
+ <link>http://bash.org.ru/quote/414910</link>
+ <title>Öèòàòà #414910</title>
+ <pubDate>Mon, 26 Dec 2011 13:12:49 +0400</pubDate>
+ <description><![CDATA[Ìàìà, êóïèâøàÿ ñâîåìó ðåáåíêó ÷åõîë ê ìîáèëüíîìó òåëåôîíó, ïðèíåñëà åãî â ìàãàçèí, ÷òîáû âåðíóòü ïðîäàâöó.<br><br>Ï: Íà ÷òî æàëóåòåñü?<br>Ì: Ðåáåíîê îòêàçûâàåòñÿ ïîëüçîâàòüñÿ ÷åõëîì.<br>Ï: Ïî÷åìó? ×òî íå óñòðàèâàåò?<br>Ì: Ìû çàêàçûâàëè ÷åõîë ñ ÷åëîâåêîì-ïàóêîì. Íà ÷åõëå íàäïèñü SPIDER-MAN. Òàê âîò, êîãäà çàñòåãèâàåì ìîëíèþ, ñòàíîâèòñÿ íå âèäíî áóêâó S.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">245f34c6c6da77a68ba258f717177e3ecb27865bd7cd72c5966a9bae3d68cdab</guid>
+ <link>http://bash.org.ru/quote/414909</link>
+ <title>Öèòàòà #414909</title>
+ <pubDate>Mon, 26 Dec 2011 13:11:56 +0400</pubDate>
+ <description><![CDATA[xxx: Äàé ôëîìàñòåð, ïàëåö ïîêðàñèòü!<br>yyy: Çà÷åì?<br>xxx: Èäó â ãîñòè, à ó ìåíÿ íîñîê äûðÿâûé!]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">b9674cdf642593a5c193c3262031513822c50bcb950170cc07aadfb7fddc2649</guid>
+ <link>http://bash.org.ru/quote/414908</link>
+ <title>Öèòàòà #414908</title>
+ <pubDate>Mon, 26 Dec 2011 13:11:02 +0400</pubDate>
+ <description><![CDATA[*  ÷àò âõîäèò Âàçåëèí.<br>Âàçåëèí: ñòóäåíòû, ÿ ïðèøåë<br>Âàçåëèí: êîìó ñêîëüêî?<br>Âàçåëèí: ïîðà áû óæå çàêàçûâàòü]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">f5e384c1050a5d6df2cbe999fbae0e082deda5e89839ad0a913b490b3fada8c0</guid>
+ <link>http://bash.org.ru/quote/414907</link>
+ <title>Öèòàòà #414907</title>
+ <pubDate>Mon, 26 Dec 2011 12:46:14 +0400</pubDate>
+ <description><![CDATA[õõõ: ãóëÿëè ñ ðåáåíêîì â ïàðêå, êîðìèëè óòî÷åê<br>õõõ: ñíà÷àëà èõ áûëî íåñêîëüêî øòóê, ïîòîì ïîäïëûëè åùå, íåêîòîðûå ïèêèðîâàëè ñ âîçäóõà)))<br>õõõ: ïðèëè÷íîå êîëè÷åñòâî ñîáðàëîñü, â îáùåì, íåêîòîðûå âûëåçëè íà áåðåã è ïîäîøëè ê íàì ïî÷òè âïëîòíóþ<br>õõõ: â êàêîé-òî ìîìåíò ìíå ñòàëî ñòðåìíî, ÷òî áóëêà êîí÷àåòñÿ]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">71aba0126bc495b6efcd494e8b95c11b4e27fadb96f8fa31475db7aa85c7f1a4</guid>
+ <link>http://bash.org.ru/quote/414906</link>
+ <title>Öèòàòà #414906</title>
+ <pubDate>Mon, 26 Dec 2011 12:45:14 +0400</pubDate>
+ <description><![CDATA[xxx: "Åñëè âû ÷èòàëè ðîìàí Æþëÿ Âåðíà èëè õîòÿ áû ñìîòðåëè ôèëüì ñ îäíîèì¸ííûì íàçâàíèåì, òî áóäåòå íå òî ÷òîáû ðàçî÷àðîâàííû, âû, ìÿãêî ãîâîðÿ, áóäåòå øîêèðîâàíû óâèäåííûì, íà÷èíàÿ ñ ïåðâûõ ñåêóíä ôèëüìà"<br><br>xxx: êòî áû áëÿòü ìîã ïîäóìàòü, ÷òî èìåííî òàê íà÷èíàåòñÿ ðåöåíçèÿ ê ôèëüìó Ìóøêåò¸ðû...]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">3d3b28ac59593143fe32ecbb4c5df048f39482f38d336d6dc4ad119ffbeea78b</guid>
+ <link>http://bash.org.ru/quote/414905</link>
+ <title>Öèòàòà #414905</title>
+ <pubDate>Mon, 26 Dec 2011 12:44:01 +0400</pubDate>
+ <description><![CDATA[xxx: à âåäóùèé ïðîãðàììèñò - ýòî òàêîé ïðîãðàììèñò, êîòîðûé ìîæåò ðåøèòü ëþáóþ ïîñòàâëåííóþ çàäà÷ó åãî ïðîôèëÿ ñàìîñòîÿòåëüíî<br>yyy: íî íå õî÷åò )]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">2931790e946054e81789e63e91d5dc9237bf492d3f26c6d7bc530b59ef2672fe</guid>
+ <link>http://bash.org.ru/quote/414904</link>
+ <title>Öèòàòà #414904</title>
+ <pubDate>Mon, 26 Dec 2011 12:13:01 +0400</pubDate>
+ <description><![CDATA[xxx: Ïîãîäèòå, íà àíäðîèäå ïðîõîäèò àâòîðèçàöèÿ ïî ðàñïîçíàâàíèþ ëèöà? Òî åñòü, åñëè ìíå íàáüþò ìîðäó, ÿ íå ñìîãó â ñêîðóþ ïîçâîíèòü?<br>yyy: Áîþñü, ÷òî íàáèòèå ìîðäû è îòú¸ì ñìàðòôîíà - ñîáûòèÿ ñèëüíî ñêîððåëèðîâàííûå, òàê ÷òî Âàøà ïðîáëåìà íåñêîëüêî íàäóìàííà. :)]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">5ee6027cf4758aa3989a3552db60d21acfc4bce66518265e9137abc3ce1fc3c7</guid>
+ <link>http://bash.org.ru/quote/414903</link>
+ <title>Öèòàòà #414903</title>
+ <pubDate>Mon, 26 Dec 2011 11:46:01 +0400</pubDate>
+ <description><![CDATA[leon:<br>Ñåãîäíÿ îòâîæó ðåáåíêà â øêîëó, à òàì ñòåíä íîâûé ïîâåñèëè ñ ôîòîãðàôèÿìè ó÷èòåëåé. Îçàãëàâëåíî ãîðäî "Ñåðäöå íàøåé øêîëû!". Ðÿäîì ñ ôîòîãðàôèåé òðóäîâèêà â áåðåòå, ìàðêåðîì ñòðåëî÷êà è íàäïèñü "ýòî ïå÷åíü".]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">a47fdbea7602bfa4df71054ed3d391d00a1c0dd13f8adaa983bb5f93e5ac3d90</guid>
+ <link>http://bash.org.ru/quote/414902</link>
+ <title>Öèòàòà #414902</title>
+ <pubDate>Mon, 26 Dec 2011 11:13:01 +0400</pubDate>
+ <description><![CDATA[xxx: áåçðàáîòíûé ñòóäåíò âñåì ñâîèì âèäîì äîêàçûâàåò íàì, ÷òî ìèíèìàëüíîãî ðàçìåðà îïëàòû òðóäà íå ñóùåñòâóåò.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">bc8b51fdf44d63edc888ad063db2fa66d1ad92c48d999408fff00a8cbec8e4ae</guid>
+ <link>http://bash.org.ru/quote/414901</link>
+ <title>Öèòàòà #414901</title>
+ <pubDate>Mon, 26 Dec 2011 10:46:12 +0400</pubDate>
+ <description><![CDATA[Psihodel: ñåãîäíÿ ñ óòðà ïðèøëà ñìñ "Ìàì êèíü óòðîì íà ìòñ õõõ-õõ-õõ-õõ 950ð. Ìíå íå çâîíè. Ïîçæå îáúÿñíþ." ×åðåç ÷àñ ìíå æåíà ñîîáùàåò, ÷òî îíà áåðåìåííà. Òåïåðü ÿ ïîíÿë, ïî÷åìó íå íàäî çâîíèòü. Âîò ëåò ÷åðåç 5 óçíàþ, çà÷åì åìó íàäî áûëî 950ð.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">e5174f709f5372c11eaf170b06efe25bf23fd3a65dbc9669e7b55b83ad598340</guid>
+ <link>http://bash.org.ru/quote/414900</link>
+ <title>Öèòàòà #414900</title>
+ <pubDate>Mon, 26 Dec 2011 10:45:01 +0400</pubDate>
+ <description><![CDATA[xxx: Çàâòðà âñòðå÷à îäíîãðóïïíèêîâ. â 16:00 â Ïàáå íà Òàãàíêå. Íó ÷åãî, òû áóäåøü ?<br>yyy: Âîäêó<br>yyy: Äóìàþ ÿ îòâåòèë ñðàçó íà äâà âîïðîñà]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">0f5c7eaee411484a37e8071fb60030eb902f42a26969363233116d425faec446</guid>
+ <link>http://bash.org.ru/quote/414899</link>
+ <title>Öèòàòà #414899</title>
+ <pubDate>Mon, 26 Dec 2011 10:12:34 +0400</pubDate>
+ <description><![CDATA[Íàñòîÿùèé ðàäèîëþáèòåëü, îòêðûâ ñïè÷å÷íûé êîðîáîê è îáíàðóæèâ òàì ñïè÷êè, ñìîòðèò íà íèõ Ñ ÓÄÈÂËÅÍÈÅÌ]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">1941999057f97da275dbaee167f5314de54a3de0f1ccc0f25c983cfe08845e71</guid>
+ <link>http://bash.org.ru/quote/414898</link>
+ <title>Öèòàòà #414898</title>
+ <pubDate>Mon, 26 Dec 2011 10:12:01 +0400</pubDate>
+ <description><![CDATA[xxx: Åñëè â âàøåé æèçíè ïîñòîÿííî ïðîèñõîäèò êàêàÿ-òî õåðíÿ, òî ñòîèò çàäóìàòüñÿ, à íå âû ëè òà ñàìàÿ õåðíÿ.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">1493df9ec128867419e1c9e0f8adf1e7c73eaecba9ba81e51395778f2c599faf</guid>
+ <link>http://bash.org.ru/quote/414897</link>
+ <title>Öèòàòà #414897</title>
+ <pubDate>Mon, 26 Dec 2011 09:46:15 +0400</pubDate>
+ <description><![CDATA[õõõ: ïëîõàÿ ýòî èäåÿ, ñ äåòñêèìè äîìàøíèìè ïðàçäíèêàìè.<br>óóó: äà ïî÷åìó? ó ìåíÿ çíàêîìûå ýòèì êàæäûå ïðàçäíèêè çàíèìàþòñÿ. âïîëíå íåïëîõî äëÿ ïîäðàáîòêè, âåñåëî + ñðàçó äåíüãè â êàðìàíå.<br>õõõ: ïàðó ëåò íàçàä ìû ñ ïîäðóãîé òîæå ðàçäîáûëè íîâîãîäíèõ êîñòþìîâ, íàïèñàëè âåñåëûé ñöåíàðèé è ðàçâåñëèëè îáúÿâëåíèÿ: "Âîëøåáíîå íîâîãîäíåå ïðèêëþ÷åíèå îò ñåñòðè÷åê-Ñíåãóðî÷åê â âàøåì äîìå".<br>õõõ: àõ âû ìîè íåèñïîð÷åííûå!<br>óóó: àãà, âñå ïðàâèëüíî ïîíÿë.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">507045f7af9d1dbc586b1ea528ecc9edb09ea5a1f35dab1141afc0dee491c7f2</guid>
+ <link>http://bash.org.ru/quote/414896</link>
+ <title>Öèòàòà #414896</title>
+ <pubDate>Mon, 26 Dec 2011 09:45:01 +0400</pubDate>
+ <description><![CDATA[CKuB: ÇÀß, áëÿ! Ïåðåëîæèòü âñå ãîâíî íà ìîþ ïîëêó - ýòî íå òî, ÷òî ÿ èìåë â âèäó, ïðîñÿ íàâåñòè ïîðÿäîê ó ñåáÿ íà ïîëêå!]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">e4f30a21e7ffa737cc164ea71ddf1fe24a2c87b269a1b47db1dbf591ebe3e843</guid>
+ <link>http://bash.org.ru/quote/414895</link>
+ <title>Öèòàòà #414895</title>
+ <pubDate>Mon, 26 Dec 2011 09:12:45 +0400</pubDate>
+ <description><![CDATA[xxx: Àäìèíñêàÿ ïðèìåòà.<br>xxx: Åñëè 12-ëåòíèé ñûí íà÷àëüíèêà èäåò â ñåðâåðíóþ - ê áîëüøîé áåäå.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">0ac1bcd3e77c115764edf2fef78568d7e88f0dcfa2830ebff7a4a67ca246192b</guid>
+ <link>http://bash.org.ru/quote/414894</link>
+ <title>Öèòàòà #414894</title>
+ <pubDate>Mon, 26 Dec 2011 09:11:52 +0400</pubDate>
+ <description><![CDATA[Vegyja: ðîìàíòèêà - ÷åì åå ìåíüøå, òåì ëó÷øå. åñëè ïàðåíü òîëüêî è äåëàåò, ÷òî ñòðàäàåò òàêîé ôèãíåé... âîïðîñ âîçíèêàåò: à ìóæ÷èíà ëè îí?<br>Telecantrelem: À åñëè ïðåäëîæèòü äåâóøêå áóòåðáðîä ñ êîëáàñîé - ýòî ðîìàíòèêà?<br>1143r: Telecantrelem, â îïðåäåëåííûõ îáñòîÿòåëüñòâàõ ýòî î÷åíü äàæå ðîìàíòè÷íî. Íàïðèìåð, Îíà âûïèëà ñòàêàí ñàìîãîíó, à çàêóñèòü íå÷åì. À òóò òû ñ áóòåðîì. Îïà! Íà, åøü!]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">0b0d1ae0708037d49d4edd71c8e1d7a488907c379787b7827be44ba7adab6cef</guid>
+ <link>http://bash.org.ru/quote/414893</link>
+ <title>Öèòàòà #414893</title>
+ <pubDate>Mon, 26 Dec 2011 09:11:01 +0400</pubDate>
+ <description><![CDATA[Èç îáúÿñíèòåëüíîé çàïèñêè:<br><br>12.12 íà ñêëàäå ¹4 áûë ðàçãðóæåí ëàìèíàò "..." ñ áîëüøèì êîëè÷åñòâîì áðàêà. Ïà÷êè áûëè îòñîðòèðîâàíû ìíîé è ïîäïèñàíû, õîðîøèå ïà÷êè "Õ", à ïëîõèå ïà÷êè "Ï". Ïðè âîçâðàòå òîâàðà ïîñòàâùèêó, íà÷àëüíèê ñêëàäà îøèáî÷íî ïîñ÷èòàë, ÷òî "Õ" îçíà÷àåò "õó¸âûå", à "Ï" îçíà÷àåò "ïèçäàòûå", ÷òî â êîðíå ìåíÿëî ñèòóàöèþ. Ãðóç÷èêè åãî ïîääåðæàëè è íà âîçâðàò áûë îòãðóæåí êà÷åñòâåííûé òîâàð. Âèíîâíûì â äàííîì èíöèäåíòå ñåáÿ íå ïðèçíàþ, óñëóãè òðàíñïîðòíîé êîìïàíèè îïëà÷èâàòü îòêàçûâàþñü.]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">4caeec3b83a23c4ef7e6822f1b9151c62dd719538f9719fd9dc49079edf12869</guid>
+ <link>http://bash.org.ru/quote/414892</link>
+ <title>Öèòàòà #414892</title>
+ <pubDate>Mon, 26 Dec 2011 08:46:01 +0400</pubDate>
+ <description><![CDATA[Ëåíà: ÷òî äåëàòü, åñëè êîò ñïèò, ÿ îäíà äîìà, à íà êóõíå ãðîõîò?<br>Îëåã: êèíü òóäà êîòà)]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">533d63288a28594dd6858f5eb212c9fd62c95da02ef6c532902585a525f78b2e</guid>
+ <link>http://bash.org.ru/quote/414891</link>
+ <title>Öèòàòà #414891</title>
+ <pubDate>Mon, 26 Dec 2011 08:13:01 +0400</pubDate>
+ <description><![CDATA[îí: Ðàññêàæè ìíå ñêàçêó<br>îíà: Æèëà-áûëà íåêàÿ ôóíêöèÿ ýô îò èêñ, è áûëà îíà äèôôåðåíöèðóåìà íà âñåé ýïñèëîí-îêðåñòíîñòè íåêîé òî÷êè èêñ íóëåâîå<br>îíà: Ó ìåíÿ ÷èñëåííûå ìåòîäû )<br>îíà: Èçâèíè )]]></description>
+ </item>
+ <item>
+ <guid isPermaLink="false">92cf655d26cbe5d10b1af532ab4abb491a0d74ae9759cb81cd6dd4bb84a1d2bc</guid>
+ <link>http://bash.org.ru/quote/414890</link>
+ <title>Öèòàòà #414890</title>
+ <pubDate>Sun, 25 Dec 2011 09:13:01 +0400</pubDate>
+ <description><![CDATA[ñìñ èç î÷åðåäè ê âðà÷ó<br><br>õõõ: Ìàìà, çà ÷àñ ïðèíÿëè òîëüêî äâóõ áîëüíûõ è îíè äî ñèõ ïîð òàì. ïåðåäî ìíîé 12 çëûõ è îïàñíûõ áàáóøåê, êîòîðûå óæå óñïåëè çàêàòèòü äâà ñêàíäàëà ñ ïðèìåíåíèåì äâåðè è ãðóáîé ôèçè÷åñêîé ñèëû òåì, êòî ïûòàëñÿ ïðîéòè áåç î÷åðåäè. Ïîä÷¸ðêèâàþ: ÏÛÒÀËÑß! Ìíå åñòü ñìûñë ñèäåòü äàëüøå?]]></description>
+ </item>
+ </channel>
+</rss>
\ No newline at end of file diff --git a/plugins/NewsAggregator/docs/ToDo.txt b/plugins/NewsAggregator/docs/ToDo.txt new file mode 100644 index 0000000000..fa08c1a5f3 --- /dev/null +++ b/plugins/NewsAggregator/docs/ToDo.txt @@ -0,0 +1,11 @@ +Ïàðñèòü xml
+ýêñïîðò\èìïîðò
+àâòîèìïîðò èç ôàéëà
+àâòîðèçàöèÿ
+çàìåíà âñåãî html'íîãî
+
+xml parse
+contacts export\import
+autoimport from file service
+authorization
+replace all html to text
\ No newline at end of file diff --git a/plugins/NewsAggregator/proto_newsaggr/Proto_NewsAggr.vcxproj b/plugins/NewsAggregator/proto_newsaggr/Proto_NewsAggr.vcxproj new file mode 100644 index 0000000000..0b4c2702ce --- /dev/null +++ b/plugins/NewsAggregator/proto_newsaggr/Proto_NewsAggr.vcxproj @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{B97882DC-7462-41DB-A390-BDFCE5295265}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\Proto_NewsAggr.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/NewsAggregator/proto_newsaggr/Proto_NewsAggr.vcxproj.filters b/plugins/NewsAggregator/proto_newsaggr/Proto_NewsAggr.vcxproj.filters new file mode 100644 index 0000000000..e32e34e0dc --- /dev/null +++ b/plugins/NewsAggregator/proto_newsaggr/Proto_NewsAggr.vcxproj.filters @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\Proto_NewsAggr.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/NewsAggregator/proto_newsaggr/res/Offline.ico b/plugins/NewsAggregator/proto_newsaggr/res/Offline.ico Binary files differnew file mode 100644 index 0000000000..91788e73e7 --- /dev/null +++ b/plugins/NewsAggregator/proto_newsaggr/res/Offline.ico diff --git a/plugins/NewsAggregator/proto_newsaggr/res/Online.ico b/plugins/NewsAggregator/proto_newsaggr/res/Online.ico Binary files differnew file mode 100644 index 0000000000..3629737fda --- /dev/null +++ b/plugins/NewsAggregator/proto_newsaggr/res/Online.ico diff --git a/plugins/NewsAggregator/proto_newsaggr/res/Proto_NewsAggr.rc b/plugins/NewsAggregator/proto_newsaggr/res/Proto_NewsAggr.rc Binary files differnew file mode 100644 index 0000000000..3eaac4e99b --- /dev/null +++ b/plugins/NewsAggregator/proto_newsaggr/res/Proto_NewsAggr.rc diff --git a/plugins/NewsAggregator/proto_newsaggr/src/resource.h b/plugins/NewsAggregator/proto_newsaggr/src/resource.h Binary files differnew file mode 100644 index 0000000000..c6b804fd4e --- /dev/null +++ b/plugins/NewsAggregator/proto_newsaggr/src/resource.h diff --git a/plugins/Quotes/Forex.vcxproj b/plugins/Quotes/Forex.vcxproj new file mode 100644 index 0000000000..3def2265f1 --- /dev/null +++ b/plugins/Quotes/Forex.vcxproj @@ -0,0 +1,264 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{C619A811-8023-4441-B3D7-785388A09DF0}</ProjectGuid>
+ <ProjectName>Quotes</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\..\boost_1_49_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;FOREX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>comsuppw.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;..\..\..\boost_1_49_0\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\..\boost_1_49_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;FOREX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>comsuppw.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;..\..\..\boost_1_49_0\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\..\boost_1_49_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;FOREX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>comsuppw.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;..\..\..\boost_1_49_0\lib</AdditionalLibraryDirectories>
+ <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;..\..\..\boost_1_49_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;FOREX_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>comsuppw.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib;..\..\..\boost_1_49_0\lib</AdditionalLibraryDirectories>
+ <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
+ </Link>
+ <ResourceCompile>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="src\Base64.cpp" />
+ <ClCompile Include="src\ComHelper.cpp" />
+ <ClCompile Include="src\CommonOptionDlg.cpp" />
+ <ClCompile Include="src\CreateFilePath.cpp" />
+ <ClCompile Include="src\CurrencyConverter.cpp" />
+ <ClCompile Include="src\DBUtils.cpp" />
+ <ClCompile Include="src\ExtraImages.cpp" />
+ <ClCompile Include="src\Forex.cpp" />
+ <ClCompile Include="src\HTMLParserMS.cpp" />
+ <ClCompile Include="src\HTTPSession.cpp" />
+ <ClCompile Include="src\IconLib.cpp" />
+ <ClCompile Include="src\ImportExport.cpp" />
+ <ClCompile Include="src\LightMutex.cpp" />
+ <ClCompile Include="src\Locale.cpp" />
+ <ClCompile Include="src\Log.cpp" />
+ <ClCompile Include="src\ModuleInfo.cpp" />
+ <ClCompile Include="src\OptionDukasCopy.cpp" />
+ <ClCompile Include="src\QuoteChart.cpp" />
+ <ClCompile Include="src\QuoteInfoDlg.cpp" />
+ <ClCompile Include="src\QuotesProviderBase.cpp" />
+ <ClCompile Include="src\QuotesProviderDukasCopy.cpp" />
+ <ClCompile Include="src\QuotesProviderFinance.cpp" />
+ <ClCompile Include="src\QuotesProviderGoogle.cpp" />
+ <ClCompile Include="src\QuotesProviderGoogleFinance.cpp" />
+ <ClCompile Include="src\QuotesProviders.cpp" />
+ <ClCompile Include="src\QuotesProviderVisitorDbSettings.cpp" />
+ <ClCompile Include="src\QuotesProviderVisitorFormater.cpp" />
+ <ClCompile Include="src\QuotesProviderVisitorFormatSpecificator.cpp" />
+ <ClCompile Include="src\QuotesProviderVisitorTendency.cpp" />
+ <ClCompile Include="src\QuotesProviderYahoo.cpp" />
+ <ClCompile Include="src\SettingsDlg.cpp" />
+ <ClCompile Include="src\stdafx.cpp">
+ <PrecompiledHeader>Create</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="src\WinCtrlHelper.cpp" />
+ <ClCompile Include="src\WorkingThread.cpp" />
+ <ClCompile Include="src\XMLEngineMI.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\Base64.h" />
+ <ClInclude Include="src\Chart.h" />
+ <ClInclude Include="src\ComHelper.h" />
+ <ClInclude Include="src\CommonOptionDlg.h" />
+ <ClInclude Include="src\CreateFilePath.h" />
+ <ClInclude Include="src\CurrencyConverter.h" />
+ <ClInclude Include="src\DBUtils.h" />
+ <ClInclude Include="src\EconomicRateInfo.h" />
+ <ClInclude Include="src\ExtraImages.h" />
+ <ClInclude Include="src\HTMLParserMS.h" />
+ <ClInclude Include="src\HTTPSession.h" />
+ <ClInclude Include="src\IconLib.h" />
+ <ClInclude Include="src\IHTMLEngine.h" />
+ <ClInclude Include="src\IHTMLParser.h" />
+ <ClInclude Include="src\ImportExport.h" />
+ <ClInclude Include="src\IQuotesProvider.h" />
+ <ClInclude Include="src\IsWithinAccuracy.h" />
+ <ClInclude Include="src\IXMLEngine.h" />
+ <ClInclude Include="src\LightMutex.h" />
+ <ClInclude Include="src\Locale.h" />
+ <ClInclude Include="src\Log.h" />
+ <ClInclude Include="src\ModuleInfo.h" />
+ <ClInclude Include="src\OptionDukasCopy.h" />
+ <ClInclude Include="src\QuoteChart.h" />
+ <ClInclude Include="src\QuoteInfoDlg.h" />
+ <ClInclude Include="src\QuotesProviderBase.h" />
+ <ClInclude Include="src\QuotesProviderDukasCopy.h" />
+ <ClInclude Include="src\QuotesProviderFinance.h" />
+ <ClInclude Include="src\QuotesProviderGoogle.h" />
+ <ClInclude Include="src\QuotesProviderGoogleFinance.h" />
+ <ClInclude Include="src\QuotesProviders.h" />
+ <ClInclude Include="src\QuotesProviderVisitor.h" />
+ <ClInclude Include="src\QuotesProviderVisitorDbSettings.h" />
+ <ClInclude Include="src\QuotesProviderVisitorFormater.h" />
+ <ClInclude Include="src\QuotesProviderVisitorFormatSpecificator.h" />
+ <ClInclude Include="src\QuotesProviderVisitorTendency.h" />
+ <ClInclude Include="src\QuotesProviderYahoo.h" />
+ <ClInclude Include="src\resource.h" />
+ <ClInclude Include="src\SettingsDlg.h" />
+ <ClInclude Include="src\stdafx.h" />
+ <ClInclude Include="src\targetver.h" />
+ <ClInclude Include="src\version.h" />
+ <ClInclude Include="src\WinCtrlHelper.h" />
+ <ClInclude Include="src\WorkingThread.h" />
+ <ClInclude Include="src\XMLEngineMI.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\Forex.rc" />
+ <ResourceCompile Include="res\Version.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/Quotes/Forex.vcxproj.filters b/plugins/Quotes/Forex.vcxproj.filters new file mode 100644 index 0000000000..632658ed44 --- /dev/null +++ b/plugins/Quotes/Forex.vcxproj.filters @@ -0,0 +1,269 @@ +<?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>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\Base64.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\ComHelper.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\CommonOptionDlg.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\CreateFilePath.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\CurrencyConverter.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\DBUtils.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\ExtraImages.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Forex.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\HTMLParserMS.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\HTTPSession.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\IconLib.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\ImportExport.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\LightMutex.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Locale.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\Log.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\ModuleInfo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\OptionDukasCopy.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuoteChart.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuoteInfoDlg.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderBase.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderDukasCopy.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderGoogle.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderGoogleFinance.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviders.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderVisitorDbSettings.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderVisitorFormater.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderVisitorFormatSpecificator.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\WinCtrlHelper.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\WorkingThread.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\XMLEngineMI.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\SettingsDlg.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderVisitorTendency.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderFinance.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\QuotesProviderYahoo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\Base64.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\ComHelper.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\CommonOptionDlg.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\CreateFilePath.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\CurrencyConverter.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\DBUtils.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\EconomicRateInfo.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\ExtraImages.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\HTMLParserMS.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\HTTPSession.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\IconLib.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\IHTMLEngine.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\IHTMLParser.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\ImportExport.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\IQuotesProvider.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\IsWithinAccuracy.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\IXMLEngine.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\LightMutex.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Locale.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Log.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\ModuleInfo.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\OptionDukasCopy.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuoteChart.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuoteInfoDlg.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderBase.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderDukasCopy.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderGoogle.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderGoogleFinance.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviders.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderVisitor.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderVisitorDbSettings.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderVisitorFormater.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderVisitorFormatSpecificator.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\targetver.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\WinCtrlHelper.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\WorkingThread.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\XMLEngineMI.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\SettingsDlg.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\Chart.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderVisitorTendency.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderFinance.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\QuotesProviderYahoo.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\Forex.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ <ResourceCompile Include="res\Version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/Quotes/docs/Utility/DukasCopy.py b/plugins/Quotes/docs/Utility/DukasCopy.py new file mode 100644 index 0000000000..2d12d1c4ec --- /dev/null +++ b/plugins/Quotes/docs/Utility/DukasCopy.py @@ -0,0 +1,48 @@ +from html.parser import HTMLParser
+import sys
+
+class MyHTMLParser(HTMLParser):
+ def __init__(self, in_fn,out_fn):
+ HTMLParser.__init__(self)
+ f_in = open(in_fn,'r')
+ self.quote = 0
+ self.descr = ''
+ self.f_out = open(out_fn,'w')
+ self.feed(f_in.read())
+ f_in.close()
+ self.f_out.close()
+
+ def handle_starttag(self, tag, attrs):
+ #print ("start of a %s" % tag)
+ #print (attrs)
+ self.start = 1
+ if tag == 'input':
+ self.f_out.write('\n<quote>')
+ for k in attrs:
+ if k[0] == 'stname':
+ self.f_out.write('\n\t<symbol>%s</symbol>'%k[1])
+ if k[0] == 'stid':
+ self.f_out.write('\n\t<id>%s</id>'%k[1])
+ self.quote = 1
+
+
+ def handle_endtag(self, tag):
+ self.start = 0
+ if tag == 'tr' and self.quote == 1:
+ if self.descr:
+ self.f_out.write('\n\t<description>%s</description>'%self.descr)
+ self.f_out.write('\n</quote>')
+ self.quote = 0
+ self.descr = 1
+ #print ("end of a %s" % tag)
+
+ def handle_data(self, data):
+ if self.start == 1:
+ self.descr = data
+ #print ("Data %s" % self.descr)
+
+
+
+parser = MyHTMLParser(sys.argv[1],sys.argv[2])
+parser.close()
+
\ No newline at end of file diff --git a/plugins/Quotes/docs/Utility/Dukascopy.xml b/plugins/Quotes/docs/Utility/Dukascopy.xml new file mode 100644 index 0000000000..92890888b9 --- /dev/null +++ b/plugins/Quotes/docs/Utility/Dukascopy.xml @@ -0,0 +1,1635 @@ +<?xml version="1.0" encoding="utf-8"?>
+
+<Provider>
+ <name>Dukascopy Swiss Forex Group</name>
+ <ref>http://www.dukascopy.com</ref>
+ <url>http://freeserv.dukascopy.com/qt/?&STOCKS=</url>
+
+ <!--European Stocks-->
+
+ <section>
+ <name>European Stocks</name>
+
+<quote>
+ <id>127</id>
+ <symbol>BA</symbol>
+ <description>BAE Systems</description>
+</quote>
+<quote>
+ <id>130</id>
+ <symbol>BKIR</symbol>
+ <description>Bank of Ireland</description>
+</quote>
+<quote>
+ <id>131</id>
+ <symbol>BP</symbol>
+ <description>British Petroleum</description>
+</quote>
+<quote>
+ <id>138</id>
+ <symbol>SBRY</symbol>
+ <description>Sainsbury</description>
+</quote>
+<quote>
+ <id>142</id>
+ <symbol>AZN</symbol>
+ <description>Astrazeneca</description>
+</quote>
+<quote>
+ <id>145</id>
+ <symbol>CNA</symbol>
+ <description>Centrica</description>
+</quote>
+<quote>
+ <id>153</id>
+ <symbol>MKS</symbol>
+ <description> Spencer</description>
+</quote>
+<quote>
+ <id>155</id>
+ <symbol>RTR</symbol>
+ <description>Reuters Group</description>
+</quote>
+<quote>
+ <id>156</id>
+ <symbol>RR</symbol>
+ <description>Rolls Royce</description>
+</quote>
+<quote>
+ <id>158</id>
+ <symbol>TSCO</symbol>
+ <description>Tesco</description>
+</quote>
+<quote>
+ <id>165</id>
+ <symbol>ALV</symbol>
+ <description>Alliaz AG</description>
+</quote>
+<quote>
+ <id>167</id>
+ <symbol>BAY</symbol>
+ <description>Bayer AG</description>
+</quote>
+<quote>
+ <id>169</id>
+ <symbol>CBK</symbol>
+ <description>Commerzbank AG</description>
+</quote>
+<quote>
+ <id>171</id>
+ <symbol>DBK</symbol>
+ <description>Deutsche Bank AG</description>
+</quote>
+<quote>
+ <id>177</id>
+ <symbol>SIE</symbol>
+ <description>Siemens AG</description>
+</quote>
+<quote>
+ <id>178</id>
+ <symbol>TKA</symbol>
+ <description>Thyssenkrupp AG</description>
+</quote>
+<quote>
+ <id>179</id>
+ <symbol>VOW</symbol>
+ <description>Volkswagen AG</description>
+</quote>
+<quote>
+ <id>183</id>
+ <symbol>FTE</symbol>
+ <description>France Telecom</description>
+</quote>
+<quote>
+ <id>191</id>
+ <symbol>OR</symbol>
+ <description>LOreal</description>
+</quote>
+<quote>
+ <id>192</id>
+ <symbol>ML</symbol>
+ <description>Michelin</description>
+</quote>
+<quote>
+ <id>193</id>
+ <symbol>RNO</symbol>
+ <description>Renault</description>
+</quote>
+<quote>
+ <id>195</id>
+ <symbol>UG</symbol>
+ <description>Peugeot SA</description>
+</quote>
+<quote>
+ <id>198</id>
+ <symbol>LG</symbol>
+ <description>Lafarge</description>
+</quote>
+<quote>
+ <id>206</id>
+ <symbol>PIN</symbol>
+ <description>Pinguin</description>
+</quote>
+<quote>
+ <id>213</id>
+ <symbol>RBACW</symbol>
+ <description>Rabo Agaath Bank</description>
+</quote>
+<quote>
+ <id>221</id>
+ <symbol>ABBN</symbol>
+ <description>ABB Finance</description>
+</quote>
+<quote>
+ <id>222</id>
+ <symbol>ADEN</symbol>
+ <description>Adecco SA</description>
+</quote>
+<quote>
+ <id>224</id>
+ <symbol>RUKN</symbol>
+ <description>Swiss Reinsurance</description>
+</quote>
+<quote>
+ <id>232</id>
+ <symbol>GFC</symbol>
+ <description>Gecina</description>
+</quote>
+<quote>
+ <id>234</id>
+ <symbol>VK</symbol>
+ <description>Vallourec</description>
+</quote>
+<quote>
+ <id>235</id>
+ <symbol>FLE</symbol>
+ <description>Fleury Michon</description>
+</quote>
+<quote>
+ <id>242</id>
+ <symbol>NEX</symbol>
+ <description>National Express Group</description>
+</quote>
+<quote>
+ <id>245</id>
+ <symbol>IMT</symbol>
+ <description>Imperial Tobacco</description>
+</quote>
+<quote>
+ <id>338</id>
+ <symbol>Pseudo</symbol>
+ <description>Pseudo</description>
+</quote>
+<quote>
+ <id>340</id>
+ <symbol>Pseudo1</symbol>
+ <description>Pseudo1</description>
+</quote>
+<quote>
+ <id>321</id>
+ <symbol>ROS</symbol>
+ <description>OAO Rostelecom</description>
+</quote>
+<quote>
+ <id>325</id>
+ <symbol>FIA</symbol>
+ <description>Fiat S.p.A.</description>
+</quote>
+<quote>
+ <id>326</id>
+ <symbol>E</symbol>
+ <description>Eni S.p.A.</description>
+</quote>
+<quote>
+ <id>327</id>
+ <symbol>EN</symbol>
+ <description>Enel S.p.A.</description>
+</quote>
+<quote>
+ <id>152</id>
+ <symbol>LLOY</symbol>
+ <description>Lloyds TSB Bank</description>
+</quote>
+<quote>
+ <id>226</id>
+ <symbol>AKZA</symbol>
+ <description>Akzo Nobel NV</description>
+</quote>
+<quote>
+ <id>135</id>
+ <symbol>BSY</symbol>
+ <description>British Sky Broadcast</description>
+</quote>
+<quote>
+ <id>144</id>
+ <symbol>CW</symbol>
+ <description> Wireless</description>
+</quote>
+<quote>
+ <id>146</id>
+ <symbol>GSK</symbol>
+ <description>Glaxosmithkline</description>
+</quote>
+<quote>
+ <id>149</id>
+ <symbol>HSBA</symbol>
+ <description>HSBC Bank</description>
+</quote>
+<quote>
+ <id>151</id>
+ <symbol>KGF</symbol>
+ <description>Kingfisher</description>
+</quote>
+<quote>
+ <id>166</id>
+ <symbol>BAS</symbol>
+ <description>BASF AG</description>
+</quote>
+<quote>
+ <id>172</id>
+ <symbol>DPW</symbol>
+ <description>Deutsche Post AG</description>
+</quote>
+<quote>
+ <id>173</id>
+ <symbol>DTE</symbol>
+ <description>Deutsche Telecom</description>
+</quote>
+<quote>
+ <id>249</id>
+ <symbol>CA</symbol>
+ <description>Carrefour</description>
+</quote>
+<quote>
+ <id>218</id>
+ <symbol>NESN</symbol>
+ <description>Nestle SA</description>
+</quote>
+<quote>
+ <id>219</id>
+ <symbol>UBSN</symbol>
+ <description>UBS AG</description>
+</quote>
+<quote>
+ <id>229</id>
+ <symbol>DIE</symbol>
+ <description>DIeteren Trading</description>
+</quote>
+<quote>
+ <id>237</id>
+ <symbol>GAM</symbol>
+ <description>Gaumont</description>
+</quote>
+<quote>
+ <id>238</id>
+ <symbol>AGE</symbol>
+ <description>AGFA Gevaert NV</description>
+</quote>
+<quote>
+ <id>243</id>
+ <symbol>CBRY</symbol>
+ <description>Cadbury Schweppes</description>
+</quote>
+<quote>
+ <id>246</id>
+ <symbol>MLW</symbol>
+ <description>Merrill Lynch World</description>
+</quote>
+<quote>
+ <id>248</id>
+ <symbol>MASN</symbol>
+ <description>Micronas Semiconductors</description>
+</quote>
+<quote>
+ <id>255</id>
+ <symbol>ARE</symbol>
+ <description>Groupe Ares</description>
+</quote>
+<quote>
+ <id>200</id>
+ <symbol>DELB</symbol>
+ <description>Delhaize Group</description>
+</quote>
+<quote>
+ <id>215</id>
+ <symbol>PHIA</symbol>
+ <description>Philips Electronics</description>
+</quote>
+<quote>
+ <id>216</id>
+ <symbol>CSGN</symbol>
+ <description>Credit Suisse Groupe CAP</description>
+</quote>
+<quote>
+ <id>772</id>
+ <symbol>VOD</symbol>
+ <description>VODAFONE </description>
+</quote>
+<quote>
+ <id>773</id>
+ <symbol>BA</symbol>
+ <description>British Airways</description>
+</quote>
+
+ </section>
+
+ <!--US Stocks-->
+
+ <section>
+ <name>US Stocks</name>
+
+
+<quote>
+ <id>99</id>
+ <symbol>INTC</symbol>
+ <description>Intel Corp.</description>
+</quote>
+<quote>
+ <id>98</id>
+ <symbol>QCOM</symbol>
+ <description>QUALCOMM Incorporated</description>
+</quote>
+<quote>
+ <id>97</id>
+ <symbol>CSCO</symbol>
+ <description>Cisco Systems, Inc.</description>
+</quote>
+<quote>
+ <id>96</id>
+ <symbol>AMGN</symbol>
+ <description>Amgen Inc.</description>
+</quote>
+<quote>
+ <id>94</id>
+ <symbol>ORCL</symbol>
+ <description>Oracle Corp.</description>
+</quote>
+<quote>
+ <id>92</id>
+ <symbol>MXIM</symbol>
+ <description>Maxim Integrated Products, Inc.</description>
+</quote>
+<quote>
+ <id>85</id>
+ <symbol>SBUX</symbol>
+ <description>Starbucks Corp.</description>
+</quote>
+<quote>
+ <id>82</id>
+ <symbol>CTAS</symbol>
+ <description>Cintas Corp.</description>
+</quote>
+<quote>
+ <id>81</id>
+ <symbol>BMET</symbol>
+ <description>Biomet, Inc.</description>
+</quote>
+<quote>
+ <id>80</id>
+ <symbol>PAYX</symbol>
+ <description>Paychex, Inc</description>
+</quote>
+<quote>
+ <id>79</id>
+ <symbol>XLNX</symbol>
+ <description>Xilinx, Inc.</description>
+</quote>
+<quote>
+ <id>75</id>
+ <symbol>FISV</symbol>
+ <description>Fiserv, Inc.</description>
+</quote>
+<quote>
+ <id>69</id>
+ <symbol>COST</symbol>
+ <description>Costco Wholesale Corp.</description>
+</quote>
+<quote>
+ <id>64</id>
+ <symbol>PCAR</symbol>
+ <description>PACCAR Inc.</description>
+</quote>
+<quote>
+ <id>62</id>
+ <symbol>ADBE</symbol>
+ <description>Adobe Systems Incorporated</description>
+</quote>
+<quote>
+ <id>61</id>
+ <symbol>SPLS</symbol>
+ <description>Staples, Inc.</description>
+</quote>
+<quote>
+ <id>33</id>
+ <symbol>T</symbol>
+ <description>T Corp.</description>
+</quote>
+<quote>
+ <id>31</id>
+ <symbol>AA</symbol>
+ <description>Alcoa</description>
+</quote>
+<quote>
+ <id>32</id>
+ <symbol>AXP</symbol>
+ <description>American Express Co.</description>
+</quote>
+<quote>
+ <id>34</id>
+ <symbol>BA</symbol>
+ <description>The Boeing Co.</description>
+</quote>
+<quote>
+ <id>35</id>
+ <symbol>CAT</symbol>
+ <description>Caterpillar Inc.</description>
+</quote>
+<quote>
+ <id>36</id>
+ <symbol>C</symbol>
+ <description>Citigroup, Inc.</description>
+</quote>
+<quote>
+ <id>37</id>
+ <symbol>KO</symbol>
+ <description>The Coca-Cola Co.</description>
+</quote>
+<quote>
+ <id>40</id>
+ <symbol>EK</symbol>
+ <description>Eastman Kodak Co.</description>
+</quote>
+<quote>
+ <id>43</id>
+ <symbol>GM</symbol>
+ <description>General Motors Corp.</description>
+</quote>
+<quote>
+ <id>49</id>
+ <symbol>JNJ</symbol>
+ <description> Johnson</description>
+</quote>
+<quote>
+ <id>50</id>
+ <symbol>MCD</symbol>
+ <description>McDonald's Corp.</description>
+</quote>
+<quote>
+ <id>51</id>
+ <symbol>MRK</symbol>
+ <description>Merck Company, Inc.</description>
+</quote>
+<quote>
+ <id>52</id>
+ <symbol>MMM</symbol>
+ <description>Manufacturing Co.</description>
+</quote>
+<quote>
+ <id>53</id>
+ <symbol>JPM</symbol>
+ <description>J.P. Morgan Company Inc.</description>
+</quote>
+<quote>
+ <id>57</id>
+ <symbol>UTX</symbol>
+ <description>United Technologies Corp.</description>
+</quote>
+<quote>
+ <id>58</id>
+ <symbol>WMT</symbol>
+ <description>Wal-Mart Stores, Inc.</description>
+</quote>
+<quote>
+ <id>104</id>
+ <symbol>CDWC</symbol>
+ <description>CDW Computer Centers, Inc.</description>
+</quote>
+<quote>
+ <id>116</id>
+ <symbol>SGA</symbol>
+ <description>Saga Communications, Inc.</description>
+</quote>
+<quote>
+ <id>118</id>
+ <symbol>MPP</symbol>
+ <description>Medical Technology System</description>
+</quote>
+<quote>
+ <id>119</id>
+ <symbol>ACU</symbol>
+ <description>Acme United Corp.</description>
+</quote>
+<quote>
+ <id>128</id>
+ <symbol>BAL</symbol>
+ <description>Barclays</description>
+</quote>
+<quote>
+ <id>141</id>
+ <symbol>RBS</symbol>
+ <description>Royal Bank of Scotland</description>
+</quote>
+<quote>
+ <id>250</id>
+ <symbol>BMO</symbol>
+ <description>Bank of Montreal</description>
+</quote>
+<quote>
+ <id>254</id>
+ <symbol>TRP</symbol>
+ <description>TransCanada PipeLines Ltd</description>
+</quote>
+<quote>
+ <id>329</id>
+ <symbol>QQQQ</symbol>
+ <description>TransCanada PipeLines Ltd</description>
+</quote>
+<quote>
+ <id>330</id>
+ <symbol>DIA</symbol>
+ <description>TransCanada PipeLines Ltd</description>
+</quote>
+<quote>
+ <id>332</id>
+ <symbol>SMH</symbol>
+ <description>TransCanada PipeLines Ltd</description>
+</quote>
+<quote>
+ <id>122</id>
+ <symbol>DW</symbol>
+ <description>Drew Industries, Inc.</description>
+</quote>
+<quote>
+ <id>123</id>
+ <symbol>FPU</symbol>
+ <description>Florida Public Utilities</description>
+</quote>
+<quote>
+ <id>280</id>
+ <symbol>NOK</symbol>
+ <description>Nokia</description>
+</quote>
+<quote>
+ <id>281</id>
+ <symbol>UPM</symbol>
+ <description>UPM-Kymmene OYJ</description>
+</quote>
+<quote>
+ <id>282</id>
+ <symbol>SEO</symbol>
+ <description>Stora Enso OYJ</description>
+</quote>
+<quote>
+ <id>287</id>
+ <symbol>BEAS</symbol>
+ <description>BEA System INC.</description>
+</quote>
+<quote>
+ <id>288</id>
+ <symbol>BRCD</symbol>
+ <description>Brocade Communication System Inc.</description>
+</quote>
+<quote>
+ <id>291</id>
+ <symbol>CEPH</symbol>
+ <description>Cephalon Inc.</description>
+</quote>
+<quote>
+ <id>292</id>
+ <symbol>CIEN</symbol>
+ <description>Ciena Corp.</description>
+</quote>
+<quote>
+ <id>293</id>
+ <symbol>CHKP</symbol>
+ <description>Checkpoint Software</description>
+</quote>
+<quote>
+ <id>295</id>
+ <symbol>DISH</symbol>
+ <description>Echostar Communications</description>
+</quote>
+<quote>
+ <id>100</id>
+ <symbol>MSFT</symbol>
+ <description>Microsoft Corp.</description>
+</quote>
+<quote>
+ <id>95</id>
+ <symbol>DELL</symbol>
+ <description>Dell Computer Corp.</description>
+</quote>
+<quote>
+ <id>91</id>
+ <symbol>EBAY</symbol>
+ <description>eBay Inc.</description>
+</quote>
+<quote>
+ <id>88</id>
+ <symbol>BBBY</symbol>
+ <description>Beyond Inc.</description>
+</quote>
+<quote>
+ <id>87</id>
+ <symbol>LLTC</symbol>
+ <description>Linear Technology Corp.</description>
+</quote>
+<quote>
+ <id>84</id>
+ <symbol>IACI</symbol>
+ <description>USA Interactive</description>
+</quote>
+<quote>
+ <id>76</id>
+ <symbol>KLAC</symbol>
+ <description>KLA-Tencor Corp.</description>
+</quote>
+<quote>
+ <id>70</id>
+ <symbol>APOL</symbol>
+ <description>Apollo Group, Inc.</description>
+</quote>
+<quote>
+ <id>68</id>
+ <symbol>TEVA</symbol>
+ <description>Teva Pharmaceutical Industries Limited</description>
+</quote>
+<quote>
+ <id>65</id>
+ <symbol>ALTR</symbol>
+ <description>Altera Corp.</description>
+</quote>
+<quote>
+ <id>63</id>
+ <symbol>SYMC</symbol>
+ <description>Symantec Corp.</description>
+</quote>
+<quote>
+ <id>42</id>
+ <symbol>GE</symbol>
+ <description>General Electric Co.</description>
+</quote>
+<quote>
+ <id>44</id>
+ <symbol>HPQ</symbol>
+ <description>Hewlett-Packard Co.</description>
+</quote>
+<quote>
+ <id>46</id>
+ <symbol>HON</symbol>
+ <description>Honeywell International Inc.</description>
+</quote>
+<quote>
+ <id>47</id>
+ <symbol>IBM</symbol>
+ <description>International Business Machines Corp.</description>
+</quote>
+<quote>
+ <id>54</id>
+ <symbol>MO</symbol>
+ <description>Morris Companies, Inc.</description>
+</quote>
+<quote>
+ <id>55</id>
+ <symbol>PG</symbol>
+ <description>Gamble Co.</description>
+</quote>
+<quote>
+ <id>103</id>
+ <symbol>FLEX</symbol>
+ <description>Flextronics International Ltd.</description>
+</quote>
+<quote>
+ <id>115</id>
+ <symbol>OHB</symbol>
+ <description>Orleans Homebuilders</description>
+</quote>
+<quote>
+ <id>251</id>
+ <symbol>BNS</symbol>
+ <description>Bank of Nova Scotia</description>
+</quote>
+<quote>
+ <id>252</id>
+ <symbol>BCE</symbol>
+ <description>BCE, Inc.</description>
+</quote>
+<quote>
+ <id>331</id>
+ <symbol>SPY</symbol>
+ <description>BCE, Inc.</description>
+</quote>
+<quote>
+ <id>286</id>
+ <symbol>AMCC</symbol>
+ <description>Applied Micro Circuit Corp.</description>
+</quote>
+<quote>
+ <id>294</id>
+ <symbol>CTXS</symbol>
+ <description>Citrix Systems</description>
+</quote>
+<quote>
+ <id>738</id>
+ <symbol>MCHP</symbol>
+ <description>Microchip Technology</description>
+</quote>
+<quote>
+ <id>747</id>
+ <symbol>NTE</symbol>
+ <description>NAM TAI Electronics</description>
+</quote>
+<quote>
+ <id>759</id>
+ <symbol>TTWO</symbol>
+ <description>Take-Two Interactive Software</description>
+</quote>
+<quote>
+ <id>700</id>
+ <symbol>ADI </symbol>
+ <description>Analog Devices </description>
+</quote>
+<quote>
+ <id>701</id>
+ <symbol>ADTN</symbol>
+ <description>Adtran </description>
+</quote>
+<quote>
+ <id>702</id>
+ <symbol>AIG</symbol>
+ <description>American International Group</description>
+</quote>
+<quote>
+ <id>703</id>
+ <symbol>APA</symbol>
+ <description>Apache Corp</description>
+</quote>
+<quote>
+ <id>704</id>
+ <symbol>BAC</symbol>
+ <description>Bank of America Corp</description>
+</quote>
+<quote>
+ <id>705</id>
+ <symbol>BBY</symbol>
+ <description>Best Buy Co </description>
+</quote>
+<quote>
+ <id>706</id>
+ <symbol>BIIB</symbol>
+ <description>Biogen Idec </description>
+</quote>
+<quote>
+ <id>707</id>
+ <symbol>BOBJ</symbol>
+ <description>Business Objects SA</description>
+</quote>
+<quote>
+ <id>708</id>
+ <symbol>BRCM</symbol>
+ <description>Broadcom Corp</description>
+</quote>
+<quote>
+ <id>709</id>
+ <symbol>CALM</symbol>
+ <description>Cal-Maine Foods </description>
+</quote>
+<quote>
+ <id>710</id>
+ <symbol>CCU</symbol>
+ <description>Clear Channel Communications </description>
+</quote>
+<quote>
+ <id>711</id>
+ <symbol>COF</symbol>
+ <description>Capital One Financial Corp</description>
+</quote>
+<quote>
+ <id>714</id>
+ <symbol>DLTR</symbol>
+ <description>Dollar Tree Stores </description>
+</quote>
+<quote>
+ <id>716</id>
+ <symbol>FITB</symbol>
+ <description>Fifth Third Bancorp</description>
+</quote>
+<quote>
+ <id>717</id>
+ <symbol>FNM</symbol>
+ <description>Fannie Mae</description>
+</quote>
+<quote>
+ <id>718</id>
+ <symbol>FRE</symbol>
+ <description>Freddie Mac</description>
+</quote>
+<quote>
+ <id>719</id>
+ <symbol>FRX</symbol>
+ <description>Forest Laboratories </description>
+</quote>
+<quote>
+ <id>720</id>
+ <symbol>GCI</symbol>
+ <description>Gannett Co </description>
+</quote>
+<quote>
+ <id>721</id>
+ <symbol>GD</symbol>
+ <description>General Dynamics Corp</description>
+</quote>
+<quote>
+ <id>724</id>
+ <symbol>GS</symbol>
+ <description>Goldman Sachs Group </description>
+</quote>
+<quote>
+ <id>726</id>
+ <symbol>HOV</symbol>
+ <description>Hovnanian Enterprises </description>
+</quote>
+<quote>
+ <id>727</id>
+ <symbol>ICOS</symbol>
+ <description>ICOS Corp</description>
+</quote>
+<quote>
+ <id>728</id>
+ <symbol>IMCL</symbol>
+ <description>ImClone Systems</description>
+</quote>
+<quote>
+ <id>731</id>
+ <symbol>KSS</symbol>
+ <description>Kohl's Corp</description>
+</quote>
+<quote>
+ <id>732</id>
+ <symbol>LEH</symbol>
+ <description>Lehman Brothers Holdings Inc</description>
+</quote>
+<quote>
+ <id>734</id>
+ <symbol>LLY</symbol>
+ <description> Co</description>
+</quote>
+<quote>
+ <id>737</id>
+ <symbol>LXK</symbol>
+ <description>Lexmark International</description>
+</quote>
+<quote>
+ <id>743</id>
+ <symbol>NEM</symbol>
+ <description>Newmont Mining Corp</description>
+</quote>
+<quote>
+ <id>744</id>
+ <symbol>NFLX</symbol>
+ <description>NetFlix</description>
+</quote>
+<quote>
+ <id>745</id>
+ <symbol>NOC</symbol>
+ <description>Northrop Grumman Corp</description>
+</quote>
+<quote>
+ <id>748</id>
+ <symbol>NTES</symbol>
+ <description>Netease.com</description>
+</quote>
+<quote>
+ <id>749</id>
+ <symbol>NVLS</symbol>
+ <description>Novellus Systems</description>
+</quote>
+<quote>
+ <id>750</id>
+ <symbol>OVTI</symbol>
+ <description>Omnivision Technologies</description>
+</quote>
+<quote>
+ <id>753</id>
+ <symbol>RMBS</symbol>
+ <description>Rambus</description>
+</quote>
+<quote>
+ <id>755</id>
+ <symbol>SINA</symbol>
+ <description>Sina Corp</description>
+</quote>
+<quote>
+ <id>756</id>
+ <symbol>SNDK</symbol>
+ <description>Sandisk Corp</description>
+</quote>
+<quote>
+ <id>757</id>
+ <symbol>SNPS</symbol>
+ <description>Synopsys</description>
+</quote>
+<quote>
+ <id>758</id>
+ <symbol>SOHU</symbol>
+ <description>Sohu.com</description>
+</quote>
+<quote>
+ <id>760</id>
+ <symbol>UTSI</symbol>
+ <description>Utstarcom</description>
+</quote>
+<quote>
+ <id>762</id>
+ <symbol>WLP</symbol>
+ <description>WellPoint Health Networks</description>
+</quote>
+<quote>
+ <id>763</id>
+ <symbol>WY</symbol>
+ <description>Weyerhaeuser Co</description>
+</quote>
+<quote>
+ <id>764</id>
+ <symbol>XMSR</symbol>
+ <description>XM Satellite Radio Holdings</description>
+</quote>
+<quote>
+ <id>765</id>
+ <symbol>YHOO</symbol>
+ <description>Yahoo! </description>
+</quote>
+<quote>
+ <id>38</id>
+ <symbol>DIS</symbol>
+ <description>The Walt Disney Co.</description>
+</quote>
+<quote>
+ <id>39</id>
+ <symbol>DD</symbol>
+ <description>E.I. duPont de Nemours Co.</description>
+</quote>
+<quote>
+ <id>78</id>
+ <symbol>ERTS</symbol>
+ <description>Electronic Arts Inc.</description>
+</quote>
+<quote>
+ <id>77</id>
+ <symbol>GENZ</symbol>
+ <description>Genzyme General</description>
+</quote>
+<quote>
+ <id>766</id>
+ <symbol>GOOGL</symbol>
+ <description>Google!</description>
+</quote>
+<quote>
+ <id>45</id>
+ <symbol>HD</symbol>
+ <description>Home Depot Inc.</description>
+</quote>
+<quote>
+ <id>48</id>
+ <symbol>IP</symbol>
+ <description>International Paper Co.</description>
+</quote>
+<quote>
+ <id>121</id>
+ <symbol>DLA</symbol>
+ <description>Delta Apparel Inc.</description>
+</quote>
+<quote>
+ <id>86</id>
+ <symbol>AMAT</symbol>
+ <description>Applied Materials, Inc.</description>
+</quote>
+<quote>
+ <id>41</id>
+ <symbol>XOM</symbol>
+ <description>Exxon Mobil Corp.</description>
+</quote>
+<quote>
+ <id>102</id>
+ <symbol>AMZN</symbol>
+ <description>Amazon.com, Inc.</description>
+</quote>
+<quote>
+ <id>729</id>
+ <symbol>IVGN</symbol>
+ <description>Invitrogen Corp</description>
+</quote>
+<quote>
+ <id>736</id>
+ <symbol>LRCX</symbol>
+ <description>Lam Research Corp</description>
+</quote>
+<quote>
+ <id>712</id>
+ <symbol>CTSH</symbol>
+ <description>Cognizant Technology Solutions Corp</description>
+</quote>
+<quote>
+ <id>713</id>
+ <symbol>DHI</symbol>
+ <description>DR Horton </description>
+</quote>
+<quote>
+ <id>740</id>
+ <symbol>MNST</symbol>
+ <description>Monster Worldwide</description>
+</quote>
+
+ </section>
+
+
+ <!--Indices-->
+
+ <section>
+ <name>Indices</name>
+ <!--on the basis of US Indices-->
+ <section>
+ <name>on the basis of US Indices</name>
+
+<quote>
+ <id>22</id>
+ <symbol>SandP-500</symbol>
+ <description>P 500</description>
+</quote>
+<quote>
+ <id>23</id>
+ <symbol>NQ-100</symbol>
+ <description>CFD statistics for Nasdaq 100</description>
+</quote>
+<quote>
+ <id>28</id>
+ <symbol>Nyssee-comp</symbol>
+ <description>CFD statistics for NYSE Composite</description>
+</quote>
+<quote>
+ <id>21</id>
+ <symbol>D&J-Ind</symbol>
+ <description>CFD statistics for Dow Jones Industrial Average</description>
+</quote>
+<quote>
+ <id>26</id>
+ <symbol>NQ-comp</symbol>
+ <description>CFD statistics for Nasdaq Composite</description>
+</quote>
+<quote>
+ <id>27</id>
+ <symbol>AMMEKS</symbol>
+ <description>CFD statistics for AMEX</description>
+</quote>
+<quote>
+ <id>768</id>
+ <symbol>VIXX</symbol>
+ <description>Volatility Index</description>
+</quote>
+<quote>
+ <id>769</id>
+ <symbol>10Y note</symbol>
+ <description>10Y note yield</description>
+</quote>
+<quote>
+ <id>770</id>
+ <symbol>5Y note</symbol>
+ <description>5Y note yield</description>
+</quote>
+<quote>
+ <id>771</id>
+ <symbol>ST note</symbol>
+ <description>Short term note yield</description>
+</quote>
+
+ </section>
+ <!--on the basis of European Indices-->
+ <section>
+ <name>on the basis of European Indices</name>
+
+<quote>
+ <id>24</id>
+ <symbol>CAAC-40</symbol>
+ <description>CFD statistics for CAC 40</description>
+</quote>
+<quote>
+ <id>25</id>
+ <symbol>DAAX</symbol>
+ <description>CFD statistics for XETRA DAX</description>
+</quote>
+<quote>
+ <id>225</id>
+ <symbol>SWMI</symbol>
+ <description>CFD statistics for SMI</description>
+</quote>
+<quote>
+ <id>345</id>
+ <symbol>Futsee-100</symbol>
+ <description>CFD statistics for FTSE</description>
+</quote>
+<quote>
+ <id>503</id>
+ <symbol>DJE50XX</symbol>
+ <description>CFD statistics for DJ Euro Stoxx50</description>
+</quote>
+
+ </section>
+ <!--on the basis of Asian Indices-->
+ <section>
+ <name>on the basis of Asian Indices</name>
+
+ <quote>
+ <id>500</id>
+ <symbol>N225Jap</symbol>
+ <description>CFD statistics for Nikkei 225</description>
+</quote>
+<quote>
+ <id>501</id>
+ <symbol>SC-Korea</symbol>
+ <description>CFD statistics for KOSPI</description>
+</quote>
+<quote>
+ <id>502</id>
+ <symbol>H-Kong</symbol>
+ <description>CFD statistics for Hang Seng</description>
+</quote>
+
+ </section>
+ </section>
+
+ <!--FOREX-->
+ <section>
+ <name>FOREX</name>
+ <!--Major-->
+ <section>
+ <name>Major</name>
+
+ <quote>
+ <id>3</id>
+ <symbol>USD/CHF</symbol>
+ <description>USD/CHF</description>
+</quote>
+<quote>
+ <id>9</id>
+ <symbol>USD/CAD</symbol>
+ <description>USD/CAD</description>
+</quote>
+<quote>
+ <id>10</id>
+ <symbol>AUD/USD</symbol>
+ <description>AUD/USD</description>
+</quote>
+<quote>
+ <id>11</id>
+ <symbol>NZD/USD</symbol>
+ <description>NZD/USD</description>
+</quote>
+<quote>
+ <id>1</id>
+ <symbol>EUR/USD</symbol>
+ <description>EUR/USD</description>
+</quote>
+<quote>
+ <id>2</id>
+ <symbol>GBP/USD</symbol>
+ <description>GBP/USD</description>
+</quote>
+
+ </section>
+ <!--Other Currencies-->
+ <section>
+ <name>Other Currencies</name>
+
+
+<quote>
+ <id>12</id>
+ <symbol>USD/NOK</symbol>
+ <description>USD/NOK</description>
+</quote>
+<quote>
+ <id>13</id>
+ <symbol>USD/DKK</symbol>
+ <description>USD/DKK</description>
+</quote>
+<quote>
+ <id>14</id>
+ <symbol>USD/SEK</symbol>
+ <description>USD/SEK</description>
+</quote>
+<quote>
+ <id>15</id>
+ <symbol>USD/SAR</symbol>
+ <description>USD/SAR</description>
+</quote>
+<quote>
+ <id>507</id>
+ <symbol>USD/EUR</symbol>
+ <description>USD/EUR</description>
+</quote>
+<quote>
+ <id>508</id>
+ <symbol>USD/GBP</symbol>
+ <description>USD/GBP</description>
+</quote>
+<quote>
+ <id>512</id>
+ <symbol>JPY/USD</symbol>
+ <description>JPY/USD</description>
+</quote>
+<quote>
+ <id>513</id>
+ <symbol>JPY/EUR</symbol>
+ <description>JPY/EUR</description>
+</quote>
+<quote>
+ <id>516</id>
+ <symbol>GBP/EUR</symbol>
+ <description>GBP/EUR</description>
+</quote>
+<quote>
+ <id>519</id>
+ <symbol>CHF/USD</symbol>
+ <description>CHF/USD</description>
+</quote>
+<quote>
+ <id>521</id>
+ <symbol>CHF/JPY</symbol>
+ <description>CHF/JPY</description>
+</quote>
+<quote>
+ <id>514</id>
+ <symbol>JPY/GBP</symbol>
+ <description>JPY/GBP</description>
+</quote>
+<quote>
+ <id>515</id>
+ <symbol>JPY/CHF</symbol>
+ <description>JPY/CHF</description>
+</quote>
+<quote>
+ <id>520</id>
+ <symbol>CHF/EUR</symbol>
+ <description>CHF/EUR</description>
+</quote>
+<quote>
+ <id>522</id>
+ <symbol>CHF/GBP</symbol>
+ <description>CHF/GBP</description>
+</quote>
+<quote>
+ <id>74</id>
+ <symbol>USD/ZAR</symbol>
+ <description>USD/ZAR</description>
+</quote>
+<quote>
+ <id>30</id>
+ <symbol>USD/SGD</symbol>
+ <description>USD/SGD</description>
+</quote>
+<quote>
+ <id>29</id>
+ <symbol>EUR/SEK</symbol>
+ <description>EUR/SEK</description>
+</quote>
+ </section>
+ <!--Crosses-->
+ <section>
+ <name>Crosses</name>
+
+
+<quote>
+ <id>509</id>
+ <symbol>EUR/JPY</symbol>
+ <description>EUR/JPY</description>
+</quote>
+<quote>
+ <id>510</id>
+ <symbol>EUR/GBP</symbol>
+ <description>EUR/GBP</description>
+</quote>
+<quote>
+ <id>511</id>
+ <symbol>EUR/CHF</symbol>
+ <description>EUR/CHF</description>
+</quote>
+<quote>
+ <id>517</id>
+ <symbol>GBP/JPY</symbol>
+ <description>GBP/JPY</description>
+</quote>
+<quote>
+ <id>518</id>
+ <symbol>GBP/CHF</symbol>
+ <description>GBP/CHF</description>
+</quote>
+<quote>
+ <id>60</id>
+ <symbol>AUD/JPY</symbol>
+ <description>AUD/JPY</description>
+</quote>
+<quote>
+ <id>767</id>
+ <symbol>CAD/JPY</symbol>
+ <description>CAD/JPY</description>
+</quote>
+ </section>
+ <!--Other Arab Currencies-->
+ <section>
+ <name>Other Arab Currencies</name>
+
+
+<quote>
+ <id>4</id>
+ <symbol>USD/JPY</symbol>
+ <description>USD/JPY</description>
+</quote>
+<quote>
+ <id>5</id>
+ <symbol>USD/EGP</symbol>
+ <description>USD/EGP</description>
+</quote>
+<quote>
+ <id>6</id>
+ <symbol>USD/JOD</symbol>
+ <description>USD/JOD</description>
+</quote>
+<quote>
+ <id>7</id>
+ <symbol>USD/QAR</symbol>
+ <description>USD/QAR</description>
+</quote>
+<quote>
+ <id>16</id>
+ <symbol>USD/TND</symbol>
+ <description>USD/TND</description>
+</quote>
+<quote>
+ <id>17</id>
+ <symbol>EUR/EGP</symbol>
+ <description>EUR/EGP</description>
+</quote>
+<quote>
+ <id>18</id>
+ <symbol>EUR/JOD</symbol>
+ <description>EUR/JOD</description>
+</quote>
+<quote>
+ <id>19</id>
+ <symbol>EUR/QAR</symbol>
+ <description>EUR/QAR</description>
+</quote>
+<quote>
+ <id>59</id>
+ <symbol>EUR/TND</symbol>
+ <description>EUR/TND</description>
+</quote>
+<quote>
+ <id>523</id>
+ <symbol>EGP/USD</symbol>
+ <description>EGP/USD</description>
+</quote>
+<quote>
+ <id>524</id>
+ <symbol>EGP/EUR</symbol>
+ <description>EGP/EUR</description>
+</quote>
+<quote>
+ <id>527</id>
+ <symbol>EGP/CHF</symbol>
+ <description>EGP/CHF</description>
+</quote>
+<quote>
+ <id>528</id>
+ <symbol>JOD/USD</symbol>
+ <description>JOD/USD</description>
+</quote>
+<quote>
+ <id>529</id>
+ <symbol>JOD/EUR</symbol>
+ <description>JOD/EUR</description>
+</quote>
+<quote>
+ <id>530</id>
+ <symbol>JOD/JPY</symbol>
+ <description>JOD/JPY</description>
+</quote>
+<quote>
+ <id>531</id>
+ <symbol>JOD/GBP</symbol>
+ <description>JOD/GBP</description>
+</quote>
+<quote>
+ <id>533</id>
+ <symbol>JOD/CHF</symbol>
+ <description>JOD/CHF</description>
+</quote>
+<quote>
+ <id>534</id>
+ <symbol>QAR/EUR</symbol>
+ <description>QAR/EUR</description>
+</quote>
+<quote>
+ <id>535</id>
+ <symbol>QAR/USD</symbol>
+ <description>QAR/USD</description>
+</quote>
+<quote>
+ <id>536</id>
+ <symbol>QAR/JPY</symbol>
+ <description>QAR/JPY</description>
+</quote>
+<quote>
+ <id>537</id>
+ <symbol>QAR/GBP</symbol>
+ <description>QAR/GBP</description>
+</quote>
+<quote>
+ <id>538</id>
+ <symbol>QAR/CHF</symbol>
+ <description>QAR/CHF</description>
+</quote>
+<quote>
+ <id>539</id>
+ <symbol>SAR/USD</symbol>
+ <description>SAR/USD</description>
+</quote>
+<quote>
+ <id>540</id>
+ <symbol>SAR/EUR</symbol>
+ <description>SAR/EUR</description>
+</quote>
+<quote>
+ <id>541</id>
+ <symbol>SAR/JPY</symbol>
+ <description>SAR/JPY</description>
+</quote>
+<quote>
+ <id>542</id>
+ <symbol>SAR/GBP</symbol>
+ <description>SAR/GBP</description>
+</quote>
+<quote>
+ <id>543</id>
+ <symbol>GBP/SAR</symbol>
+ <description>GBP/SAR</description>
+</quote>
+<quote>
+ <id>544</id>
+ <symbol>SAR/CHF</symbol>
+ <description>SAR/CHF</description>
+</quote>
+<quote>
+ <id>545</id>
+ <symbol>TND/USD</symbol>
+ <description>TND/USD</description>
+</quote>
+<quote>
+ <id>546</id>
+ <symbol>TND/EUR</symbol>
+ <description>TND/EUR</description>
+</quote>
+<quote>
+ <id>547</id>
+ <symbol>TND/JPY</symbol>
+ <description>TND/JPY</description>
+</quote>
+<quote>
+ <id>548</id>
+ <symbol>TND/GBP</symbol>
+ <description>TND/GBP</description>
+</quote>
+<quote>
+ <id>549</id>
+ <symbol>TND/CHF</symbol>
+ <description>TND/CHF</description>
+</quote>
+<quote>
+ <id>20</id>
+ <symbol>EUR/SAR</symbol>
+ <description>EUR/SAR</description>
+</quote>
+<quote>
+ <id>525</id>
+ <symbol>EGP/JPY</symbol>
+ <description>EGP/JPY</description>
+</quote>
+<quote>
+ <id>526</id>
+ <symbol>EGP/GBP</symbol>
+ <description>EGP/GBP</description>
+</quote>
+<quote>
+ <id>532</id>
+ <symbol>GBP/JOD</symbol>
+ <description>GBP/JOD</description>
+</quote>
+
+ </section>
+ </section>
+
+ <!--Asian Stocks-->
+ <section>
+ <name>Asian Stocks</name>
+
+
+<quote>
+ <id>307</id>
+ <symbol>TSM</symbol>
+ <description>Taiwan Semiconductor Mfg</description>
+</quote>
+<quote>
+ <id>308</id>
+ <symbol>SNE</symbol>
+ <description>Sony Corp.</description>
+</quote>
+<quote>
+ <id>310</id>
+ <symbol>MITSY</symbol>
+ <description>Mitsui Co., Ltd.</description>
+</quote>
+<quote>
+ <id>314</id>
+ <symbol>NSANY</symbol>
+ <description>Nissan Motor Co., Ltd.</description>
+</quote>
+<quote>
+ <id>317</id>
+ <symbol>CAJ</symbol>
+ <description>Canon, Inc.</description>
+</quote>
+<quote>
+ <id>323</id>
+ <symbol>CHL</symbol>
+ <description>China Mobile Limited</description>
+</quote>
+<quote>
+ <id>324</id>
+ <symbol>SNP</symbol>
+ <description>Chemical Corp.</description>
+</quote>
+<quote>
+ <id>313</id>
+ <symbol>HMC</symbol>
+ <description>Honda Motor Co., Ltd.</description>
+</quote>
+<quote>
+ <id>315</id>
+ <symbol>MC</symbol>
+ <description>Matsushita Electric Ind.</description>
+</quote>
+<quote>
+ <id>311</id>
+ <symbol>NTT</symbol>
+ <description> Telephone</description>
+</quote>
+<quote>
+ <id>312</id>
+ <symbol>HIT</symbol>
+ <description>Hitachi, Ltd.</description>
+</quote>
+
+ </section>
+
+ <!--Commodities-->
+ <section>
+ <name>Commodities</name>
+
+
+<quote>
+ <id>333</id>
+ <symbol>XAU/USD</symbol>
+ <description>XAU/USD</description>
+</quote>
+<quote>
+ <id>334</id>
+ <symbol>XAG/USD</symbol>
+ <description>XAG/USD</description>
+</quote>
+<quote>
+ <id>335</id>
+ <symbol>Platinum</symbol>
+ <description>Platinum</description>
+</quote>
+<quote>
+ <id>336</id>
+ <symbol>Palladium</symbol>
+ <description>Palladium</description>
+</quote>
+<quote>
+ <id>504</id>
+ <symbol>Light</symbol>
+ <description>Light</description>
+</quote>
+<quote>
+ <id>505</id>
+ <symbol>Brent</symbol>
+ <description>Brent</description>
+</quote>
+<quote>
+ <id>506</id>
+ <symbol>Copper</symbol>
+ <description>Copper</description>
+</quote>
+
+ </section>
+</Provider>
diff --git a/plugins/Quotes/docs/Utility/Google.py b/plugins/Quotes/docs/Utility/Google.py new file mode 100644 index 0000000000..35653a77f6 --- /dev/null +++ b/plugins/Quotes/docs/Utility/Google.py @@ -0,0 +1,52 @@ +from html.parser import HTMLParser
+import sys
+from xml.etree.ElementTree import Element, ElementTree, SubElement
+
+class MyHTMLParser(HTMLParser):
+ def __init__(self,in_fn,out_fn):
+ HTMLParser.__init__(self)
+ f_in = open(in_fn,'r')
+ self.quote = 0
+ self.start = 0
+ self.parse_option = 0
+ self.elQuote = Element("fake")
+ elProvider = Element("Provider")
+ SubElement(elProvider,'name').text = 'Google'
+ SubElement(elProvider,'ref').text = 'http://www.google.com'
+ SubElement(elProvider,'url').text = 'http://www.google.com/finance/converter?a=1&'
+ self.root = SubElement(elProvider,'section')
+ SubElement(self.root,'name').text = 'Currencies'
+ self.feed(f_in.read())
+ f_in.close()
+ ElementTree(elProvider).write(out_fn)
+
+ def handle_starttag(self, tag, attrs):
+ self.start = 1
+ if tag == 'select':
+ if self.parse_option == 0:
+ for k in attrs:
+ if k[0] == 'name' and k[1] == 'from':
+ self.parse_option = 1
+ break
+ else:
+ self.parse_option == 0
+ elif self.parse_option == 1 and tag == 'option':
+ for k in attrs:
+ if k[0] == 'value':
+ self.elQuote = SubElement(self.root,'quote')
+ SubElement(self.elQuote,'id').text = k[1]
+ SubElement(self.elQuote,'symbol').text = k[1]
+ break
+
+ def handle_endtag(self, tag):
+ self.start = 0
+ if tag == 'select':
+ self.parse_option == 0
+
+ def handle_data(self, data):
+ if self.start == 1 and self.parse_option == 1:
+ SubElement(self.elQuote,'description').text = data
+
+parser = MyHTMLParser(sys.argv[1],sys.argv[2])
+parser.close()
+
diff --git a/plugins/Quotes/docs/Utility/GoogleFinance.xml b/plugins/Quotes/docs/Utility/GoogleFinance.xml new file mode 100644 index 0000000000..031afbcdd5 --- /dev/null +++ b/plugins/Quotes/docs/Utility/GoogleFinance.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?>
+
+<Provider>
+ <name>Google Finance</name>
+ <ref>http://www.google.com</ref>
+ <url>http://www.google.com/finance</url>
+</Provider>
\ No newline at end of file diff --git a/plugins/Quotes/docs/Utility/Quotes_Readme.txt b/plugins/Quotes/docs/Utility/Quotes_Readme.txt new file mode 100644 index 0000000000..7c0bf2ca10 --- /dev/null +++ b/plugins/Quotes/docs/Utility/Quotes_Readme.txt @@ -0,0 +1,112 @@ +Quotes version 0.0.24.0 plugin for Miranda
+
+This plugin displays periodically updated economic quotes, currency exchanges and different economic and financial indexes in Miranda contact list.
+
+Author: Dioksin.
+You can always contact me via email dioksin@ua.fm
+
+How to install:
+unpack zip archive;
+copy quotes.dll and Quotes subdirectory from Plugins folder to miranda plugins floder.
+copy proto_Quotes.dll from Icons folder to miranda icons folder
+
+[2011-10-24] Changelog Release 0.0.24.0
+1. Tendency calculation for Yahoo was fixed
+
+[2011-10-18] Changelog Release 0.0.23.0
+1. Previous Close and Change values were added to YAHOO
+2. If there is no xml file corresponding options page is not show in properties window
+
+[2011-10-14] Changelog Release 0.0.22.0
+1. Supports YAHOO
+2. Options location was moved from "Plugins\Quotes" to "Network\Quotes"
+
+[2011-08-19] Changelog Release 0.0.21.0
+1. Tendency format specification
+2. Main icon was changed
+3. Currency converter icon was changed
+4. Popup plugin support
+5. Per-contact options
+6. Menu redesign
+7. Import/export from/to xml file
+
+[2011-08-14] Changelog Release 0.0.20.0
+1. Updation of code to use new format of Google finance HTML page
+
+[2010-09-26] Changelog Release 0.0.19.0
+1. Currency converter shown values in the sientific format
+2. Currency converter didn't convert big values
+3. Currency converter output is formatted with user-defined locale preferences
+4. Swap button in the currency converter has an icon
+5. Big icon is set for the currency converter to correct show in ALT+TAB dialog
+
+[2010-09-19] Changelog Release 0.0.18.0
+1. Thousand separator error for non USA locale in Google Finance
+
+Changelog Release 0.0.17.0
+1. The percent change with respecto to yesterday close variable was added to the Google Finance
+2. The Vietnamese Dong was added to the Currency Converter
+
+Changelog Release 0.0.16.0
+1. It was impossible to get quotes from google finance on non-USA locale
+
+Changelog Release 0.0.15.0
+1. Crash if invalid display name format was used
+
+Changelog Release 0.0.14.0
+1. References to Microsoft's XML parser were removed.
+
+Changelog Release 0.0.12.0
+1. The Swap button had been added to the Currency Converter
+
+Changelog Release 0.0.11.0
+1. Google finance is supported
+2. Occupied status was made optionally (To use it's necessary to set the 'ExtendedStatus' option in the Miranda's database).
+
+Changelog Release 0.0.9.981
+1. Currency converter
+2. Refresh all Quotes\Rates
+3. Refresh particular Quote\Rate
+2. Minor fixings to better support national language pack
+
+Changelog Release 0.0.0.8
+1. Minor changing in logic of status
+2. Minor resource modification to better support national language pack
+
+Changelog Release 0.0.0.7
+1. Status message may be set on per contact basis (second line in contact list)
+2. Two new modes were added. Occupied - it's set if error occurred during rate/quote updation. DND - it's set if updation is in progress.
+3. Open Log File menu item was added and Quotes related menu items are grouped in Quotes popup menu.
+4. Several new variables were added: previous rate, fetch date, fetch time.
+5. New empty icon was added. This icon is used when rate/quote was not changed.
+6. Quotes\rate info page was changed to show both current and previous rates.
+7. Database ForceToAddArrowToNick setting was added. This value governs an up\down arrow appearance in contact name. If it's equal 0 (default value) - arrows will be added only if extraicons were set . It it' equal 1 - arrows will be shown always and if it's equal 2 - arrows will be never shown.
+
+Changelog Release 0.0.0.6
+1. Change to log and to history only if rate (quote) value changed option has been added
+2. Several minor bugs were fixed
+
+Changelog Release 0.0.0.5
+1. Extraicons supporting
+2. Ability to change name in contact list with variables
+3. Log to file
+4. Log to Miranda's history
+5. Proxy server supporting
+6. Protocol icons were changes and removed to separate dll
+
+Changelog Release 0.0.0.4
+1. It is possible to get currency exchange rates from Google site
+2. Unicode supporting was improved
+3. User info page was modified
+4. Option pages were moved under Plugin section
+
+Changelog Release 0.0.0.3
+1. Fix bug when decimal separator was not dot
+2. User info page was added
+
+Changelog Release 0.0.0.2
+1. The size of plugin was reduced
+2. The plugin was statically link with CRT library to resolve some dependencies to system modules
+3. The updater plugin is supported now.
+
+
diff --git a/plugins/Quotes/docs/Utility/Yahoo.xml b/plugins/Quotes/docs/Utility/Yahoo.xml new file mode 100644 index 0000000000..1c2a156d89 --- /dev/null +++ b/plugins/Quotes/docs/Utility/Yahoo.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?>
+
+<Provider>
+ <name>Yahoo</name>
+ <ref>http://finance.yahoo.com/</ref>
+ <url>http://finance.yahoo.com/d/</url>
+</Provider>
\ No newline at end of file diff --git a/plugins/Quotes/docs/Utility/google.xml b/plugins/Quotes/docs/Utility/google.xml new file mode 100644 index 0000000000..9363addced --- /dev/null +++ b/plugins/Quotes/docs/Utility/google.xml @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="utf-8"?>
+
+<Provider>
+ <name>Google</name>
+ <ref>http://www.google.com</ref>
+ <url>http://www.google.com/finance/converter</url>
+
+<section>
+ <name>Currencies</name>
+ <quote>
+ <id>AED</id>
+ <symbol>AED</symbol>
+ <description>United Arab Emirates Dirham (AED)</description>
+ </quote>
+ <quote>
+ <id>ANG</id><symbol>ANG</symbol><description>Netherlands Antillean Gulden (ANG)</description>
+ </quote>
+ <quote>
+ <id>ARS</id><symbol>ARS</symbol><description>Argentine Peso (ARS)</description>
+ </quote>
+ <quote>
+ <id>AUD</id><symbol>AUD</symbol><description>Australian Dollar (AUD)</description>
+ </quote>
+ <quote>
+ <id>BGN</id><symbol>BGN</symbol><description>Bulgarian Lev (BGN)</description>
+ </quote>
+ <quote>
+ <id>BHD</id><symbol>BHD</symbol><description>Bahraini Dinar (BHD)</description>
+ </quote>
+ <quote>
+ <id>BND</id><symbol>BND</symbol><description>Brunei Dollar (BND)</description>
+ </quote>
+ <quote>
+ <id>BOB</id><symbol>BOB</symbol><description>Bolivian Boliviano (BOB)</description>
+ </quote>
+ <quote>
+ <id>BRL</id><symbol>BRL</symbol><description>Brazilian Real (BRL)</description>
+ </quote>
+ <quote>
+ <id>BWP</id><symbol>BWP</symbol><description>Botswana Pula (BWP)</description>
+ </quote>
+ <quote>
+ <id>CAD</id><symbol>CAD</symbol><description>Canadian Dollar (CAD)</description>
+ </quote>
+ <quote>
+ <id>CHF</id><symbol>CHF</symbol><description>Swiss Franc (CHF)</description>
+ </quote>
+ <quote>
+ <id>CLP</id><symbol>CLP</symbol><description>Chilean Peso (CLP)</description>
+ </quote>
+ <quote>
+ <id>CNY</id><symbol>CNY</symbol><description>Chinese Yuan (renminbi) (CNY)</description>
+ </quote>
+ <quote>
+ <id>COP</id><symbol>COP</symbol><description>Colombian Peso (COP)</description>
+ </quote>
+ <quote>
+ <id>CSD</id><symbol>CSD</symbol><description>Serbian Dinar (CSD)</description>
+ </quote>
+ <quote>
+ <id>CZK</id><symbol>CZK</symbol><description>Czech Koruna (CZK)</description>
+ </quote>
+ <quote>
+ <id>DKK</id><symbol>DKK</symbol><description>Danish Krone (DKK)</description>
+ </quote>
+ <quote>
+ <id>EEK</id><symbol>EEK</symbol><description>Estonian Kroon (EEK)</description>
+ </quote>
+ <quote>
+ <id>EGP</id><symbol>EGP</symbol><description>Egyptian Pound (EGP)</description>
+ </quote>
+ <quote>
+ <id>EUR</id><symbol>EUR</symbol><description>Euro (EUR)</description>
+ </quote>
+ <quote>
+ <id>FJD</id><symbol>FJD</symbol><description>Fijian Dollar (FJD)</description>
+ </quote>
+ <quote><id>GBP</id><symbol>GBP</symbol><description>British Pound (GBP)</description></quote><quote><id>HKD</id><symbol>HKD</symbol><description>Hong Kong Dollar (HKD)</description></quote><quote><id>HNL</id><symbol>HNL</symbol><description>Honduran Lempira (HNL)</description></quote><quote><id>HRK</id><symbol>HRK</symbol><description>Croatian Kuna (HRK)</description></quote><quote><id>HUF</id><symbol>HUF</symbol><description>Hungarian Forint (HUF)</description></quote><quote><id>IDR</id><symbol>IDR</symbol><description>Indonesian Rupiah (IDR)</description></quote><quote><id>ILS</id><symbol>ILS</symbol><description>New Israeli Sheqel (ILS)</description></quote><quote><id>INR</id><symbol>INR</symbol><description>Indian Rupee (INR)</description></quote><quote><id>ISK</id><symbol>ISK</symbol><description>Icelandic Króna (ISK)</description></quote><quote><id>JPY</id><symbol>JPY</symbol><description>Japanese Yen (JPY)</description></quote><quote><id>KRW</id><symbol>KRW</symbol><description>South Korean Won (KRW)</description></quote><quote><id>KWD</id><symbol>KWD</symbol><description>Kuwaiti Dinar (KWD)</description></quote><quote><id>KZT</id><symbol>KZT</symbol><description>Kazakhstani Tenge (KZT)</description></quote><quote><id>LKR</id><symbol>LKR</symbol><description>Sri Lankan Rupee (LKR)</description></quote><quote><id>LTL</id><symbol>LTL</symbol><description>Lithuanian Litas (LTL)</description></quote><quote><id>MAD</id><symbol>MAD</symbol><description>Moroccan Dirham (MAD)</description></quote><quote><id>MUR</id><symbol>MUR</symbol><description>Mauritian Rupee (MUR)</description></quote><quote><id>MXN</id><symbol>MXN</symbol><description>Mexican Peso (MXN)</description></quote><quote><id>MYR</id><symbol>MYR</symbol><description>Malaysian Ringgit (MYR)</description></quote><quote><id>NOK</id><symbol>NOK</symbol><description>Norwegian Krone (NOK)</description></quote><quote><id>NPR</id><symbol>NPR</symbol><description>Nepalese Rupee (NPR)</description></quote><quote><id>NZD</id><symbol>NZD</symbol><description>New Zealand Dollar (NZD)</description></quote><quote><id>OMR</id><symbol>OMR</symbol><description>Omani Rial (OMR)</description></quote><quote><id>PEN</id><symbol>PEN</symbol><description>Peruvian Nuevo Sol (PEN)</description></quote><quote><id>PHP</id><symbol>PHP</symbol><description>Philippine Peso (PHP)</description></quote><quote><id>PKR</id><symbol>PKR</symbol><description>Pakistani Rupee (PKR)</description></quote><quote><id>PLN</id><symbol>PLN</symbol><description>Polish Złoty (PLN)</description></quote><quote><id>QAR</id><symbol>QAR</symbol><description>Qatari Riyal (QAR)</description></quote><quote><id>RON</id><symbol>RON</symbol><description>New Romanian Leu (RON)</description></quote>
+
+ <quote>
+ <id>RUB</id><symbol>RUB</symbol><description>Russian Ruble (RUB)</description>
+ </quote>
+ <quote>
+ <id>SAR</id><symbol>SAR</symbol><description>Saudi Riyal (SAR)</description>
+ </quote>
+ <quote><id>SEK</id><symbol>SEK</symbol><description>Swedish Krona (SEK)</description></quote><quote><id>SGD</id><symbol>SGD</symbol><description>Singapore Dollar (SGD)</description></quote><quote><id>SIT</id><symbol>SIT</symbol><description>Slovenian Tolar (SIT)</description></quote><quote><id>SKK</id><symbol>SKK</symbol><description>Slovak Koruna (SKK)</description></quote><quote><id>THB</id><symbol>THB</symbol><description>Thai Baht (THB)</description></quote><quote><id>TRY</id><symbol>TRY</symbol><description>New Turkish Lira (TRY)</description></quote><quote><id>TTD</id><symbol>TTD</symbol><description>Trinidad and Tobago Dollar (TTD)</description></quote><quote><id>TWD</id><symbol>TWD</symbol><description>New Taiwan Dollar (TWD)</description></quote><quote><id>UAH</id><symbol>UAH</symbol><description>Ukrainian Hryvnia (UAH)</description></quote><quote><id>USD</id><symbol>USD</symbol><description>United States Dollar (USD)</description></quote><quote><id>VEB</id><symbol>VEB</symbol><description>Venezuelan BolÃvar (VEB)</description></quote><quote><id>ZAR</id><symbol>ZAR</symbol><description>South African Rand (ZAR)</description></quote>
+ <quote>
+ <id>VND</id><symbol>VND</symbol><description>Vietnamese Dong (VND)</description>
+ </quote>
+</section>
+</Provider>
\ No newline at end of file diff --git a/plugins/Quotes/proto_Quotes/proto_Quotes_10.vcxproj b/plugins/Quotes/proto_Quotes/proto_Quotes_10.vcxproj new file mode 100644 index 0000000000..0f4a4592b0 --- /dev/null +++ b/plugins/Quotes/proto_Quotes/proto_Quotes_10.vcxproj @@ -0,0 +1,124 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>Proto_Quotes</ProjectName>
+ <ProjectGuid>{5A0A9761-78E1-4E0F-AD8C-8931A667A5F2}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Link>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Link>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Link>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Link>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\proto_Quotes.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/Quotes/proto_Quotes/proto_Quotes_10.vcxproj.filters b/plugins/Quotes/proto_Quotes/proto_Quotes_10.vcxproj.filters new file mode 100644 index 0000000000..835e3f8bf1 --- /dev/null +++ b/plugins/Quotes/proto_Quotes/proto_Quotes_10.vcxproj.filters @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\proto_Quotes.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/Quotes/proto_Quotes/res/proto_Quotes.rc b/plugins/Quotes/proto_Quotes/res/proto_Quotes.rc new file mode 100644 index 0000000000..4f696d5870 --- /dev/null +++ b/plugins/Quotes/proto_Quotes/res/proto_Quotes.rc @@ -0,0 +1,122 @@ +//Microsoft Developer Studio generated resource script.
+//
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+104 ICON "proto_online.ico"
+105 ICON "proto_offline.ico"
+131 ICON "proto_na.ico"
+159 ICON "proto_occupied.ico"
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+#ifdef _WIN32
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "\r\n"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 0,0,0,1
+ PRODUCTVERSION 0,0,0,15
+ FILEFLAGSMASK 0x37L
+#ifdef _DEBUG
+ FILEFLAGS 0x21L
+#else
+ FILEFLAGS 0x20L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "CompanyName", "Dioksin"
+ VALUE "FileDescription", "Quotes protocol icons"
+ VALUE "FileVersion", "0, 0, 0, 1"
+ VALUE "InternalName", "proto_Quotes"
+ VALUE "LegalCopyright", "Do not worry!"
+ VALUE "OriginalFilename", "proto_Quotes.dll"
+ VALUE "ProductName", "Miranda NG"
+ VALUE "ProductVersion", "0, 0, 0, 15"
+ VALUE "SpecialBuild", "3"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
+
+#endif // Russian resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/Quotes/proto_Quotes/res/proto_na.ico b/plugins/Quotes/proto_Quotes/res/proto_na.ico Binary files differnew file mode 100644 index 0000000000..c8888adb80 --- /dev/null +++ b/plugins/Quotes/proto_Quotes/res/proto_na.ico diff --git a/plugins/Quotes/proto_Quotes/res/proto_occupied.ico b/plugins/Quotes/proto_Quotes/res/proto_occupied.ico Binary files differnew file mode 100644 index 0000000000..3f54c740d1 --- /dev/null +++ b/plugins/Quotes/proto_Quotes/res/proto_occupied.ico diff --git a/plugins/Quotes/proto_Quotes/res/proto_offline.ico b/plugins/Quotes/proto_Quotes/res/proto_offline.ico Binary files differnew file mode 100644 index 0000000000..cd99c072bf --- /dev/null +++ b/plugins/Quotes/proto_Quotes/res/proto_offline.ico diff --git a/plugins/Quotes/proto_Quotes/res/proto_online.ico b/plugins/Quotes/proto_Quotes/res/proto_online.ico Binary files differnew file mode 100644 index 0000000000..29e500e2bb --- /dev/null +++ b/plugins/Quotes/proto_Quotes/res/proto_online.ico diff --git a/plugins/Quotes/res/CurrencyConverter.ico b/plugins/Quotes/res/CurrencyConverter.ico Binary files differnew file mode 100644 index 0000000000..67ac2095f5 --- /dev/null +++ b/plugins/Quotes/res/CurrencyConverter.ico diff --git a/plugins/Quotes/res/Export quotes.ico b/plugins/Quotes/res/Export quotes.ico Binary files differnew file mode 100644 index 0000000000..31c7aa2ba1 --- /dev/null +++ b/plugins/Quotes/res/Export quotes.ico diff --git a/plugins/Quotes/res/Forex.rc b/plugins/Quotes/res/Forex.rc new file mode 100644 index 0000000000..8d62c83725 --- /dev/null +++ b/plugins/Quotes/res/Forex.rc @@ -0,0 +1,565 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "..\src\resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1251)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON_MAIN ICON "main.ico"
+IDI_ICON_SECTION ICON "Section.ico"
+IDI_ICON_QUOTE ICON "quote.ico"
+IDI_ICON_UP ICON "up.ico"
+IDI_ICON_DOWN ICON "down.ico"
+IDI_ICON_CURRENCY_CONVERTER ICON "CurrencyConverter.ico"
+IDI_ICON_REFRESH ICON "Refresh.ico"
+IDI_ICON_EXPORT ICON "Export quotes.ico"
+IDI_ICON_SWAP ICON "swap.ico"
+IDI_ICON_IMPORT ICON "Import quotes.ico"
+IDI_ICON_NOTCHANGED ICON "notchanged.ico"
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian (Russia) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "..\\src\\resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DIALOG_VARIABLE_LIST DIALOGEX 0, 0, 216, 182
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Variable List"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,83,161,50,14
+ EDITTEXT IDC_EDIT_VARIABLE,7,7,202,147,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_DIALOG_VARIABLE_LIST, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 209
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 175
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // Russian (Russia) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_CONTACT_SETTINGS DIALOGEX 0, 0, 323, 269
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Edit Settings"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Use contact specific settings",IDC_CHECK_CONTACT_SPECIFIC,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,22,151,10
+ GROUPBOX "Log",IDC_STATIC,26,35,290,137
+ CONTROL "Use &Internal History",IDC_CHECK_INTERNAL_HISTORY,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,49,140,10
+ LTEXT "&Format:",IDC_STATIC_HISTORY_FORMAT,50,63,47,8
+ EDITTEXT IDC_EDIT_HISTORY_FORMAT,101,61,137,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Variables...",IDC_BUTTON_HISTORY_DESCRIPTION,241,61,65,12
+ CONTROL "&Add to History only if Value Changed",IDC_CHECK_HISTORY_CONDITION,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,77,252,10
+ CONTROL "Use &External File",IDC_CHECK_EXTERNAL_FILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,97,127,10
+ LTEXT "&Select File:",IDC_STATIC_SELECT_FILE,50,113,49,8
+ EDITTEXT IDC_EDIT_FILE_NAME,101,111,137,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Browse...",IDC_BUTTON_BROWSE,241,111,65,12
+ LTEXT "Variables Allowed: %miranda_userdata%,%quotename%",IDC_STATIC,50,126,257,8,WS_DISABLED
+ LTEXT "F&ormat:",IDC_STATIC_LOG_FILE_FORMAT,50,142,47,8
+ EDITTEXT IDC_EDIT_LOG_FILE_FORMAT,101,140,137,12,ES_AUTOHSCROLL
+ PUSHBUTTON "V&ariables...",IDC_BUTTON_LOG_FILE_DESCRIPTION,241,140,65,12
+ CONTROL "Add to &Log only if Value Changed",IDC_CHECK_LOG_FILE_CONDITION,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,50,156,224,10
+ CONTROL "Show &Popup Window",IDC_CHECK_SHOW_POPUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,180,120,10
+ LTEXT "F&ormat:",IDC_STATIC_POPUP_FORMAT,30,197,47,8
+ EDITTEXT IDC_EDIT_POPUP_FORMAT,81,195,137,12,ES_AUTOHSCROLL
+ PUSHBUTTON "V&ariables...",IDC_BUTTON_POPUP_FORMAT_DESCRIPTION,221,195,65,12
+ CONTROL "Show Popup Window Only if Value &Changed",IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,210,245,10
+ DEFPUSHBUTTON "OK",IDOK,107,248,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,163,248,50,14
+ EDITTEXT IDC_EDIT_NAME,7,7,309,12,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ PUSHBUTTON "Popup settings...",IDC_BUTTON_POPUP_SETTINGS,98,222,111,14
+END
+
+IDD_CURRENCY_CONVERTER DIALOGEX 0, 0, 347, 101
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Currency Converter"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ EDITTEXT IDC_EDIT_VALUE,6,7,56,13,ES_AUTOHSCROLL
+ COMBOBOX IDC_COMBO_CONVERT_FROM,68,7,105,44,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&to:",IDC_STATIC,214,9,14,8
+ COMBOBOX IDC_COMBO_CONVERT_INTO,230,7,105,44,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "&Swap",IDC_BUTTON_SWAP,180,7,24,12,BS_ICON
+ PUSHBUTTON "Convert",IDC_BUTTON_CONVERT,134,24,79,14
+ EDITTEXT IDC_EDIT_RESULT,7,44,328,12,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY
+ CONTROL "Info provided by <a href=""http://www.google.com"">Google</a>",IDC_SYSLINK_PROVIDER,
+ "SysLink",WS_TABSTOP,7,61,159,11
+ PUSHBUTTON "Close",IDCANCEL,148,80,50,14
+END
+
+IDD_CHART DIALOGEX 0, 0, 394, 279
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+EXSTYLE WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT
+CAPTION "Chart"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "Info provided by <a href=""http://www.dukascopy.com"">Dukascopy Swiss Forex Group</a>",IDC_SYSLINK_PROVIDER,
+ "SysLink",WS_TABSTOP,7,261,176,11
+ PUSHBUTTON "Close",IDCANCEL,337,258,50,14
+ CONTROL "",IDC_STATIC_IMAGE,"Static",SS_ETCHEDFRAME | NOT WS_VISIBLE,7,24,380,230,WS_EX_TRANSPARENT
+ LTEXT "Get data from:",IDC_STATIC,7,9,69,8
+ COMBOBOX IDC_COMBO_DATA_SOURCE,79,7,85,54,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Filter:",IDC_STATIC,170,9,29,8
+ COMBOBOX IDC_COMBO_FILTER,204,7,69,47,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ EDITTEXT IDC_EDIT_FROM,277,7,53,12,ES_AUTOHSCROLL | NOT WS_VISIBLE
+ EDITTEXT IDC_EDIT_TO,334,7,53,12,ES_AUTOHSCROLL | NOT WS_VISIBLE
+END
+
+IDD_PROVIDER_ADV_SETTINGS DIALOGEX 0, 0, 303, 260
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Edit Settings"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ GROUPBOX "Log",IDC_STATIC,7,23,289,139
+ CONTROL "Use &Internal History",IDC_CHECK_INTERNAL_HISTORY,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,37,140,10
+ LTEXT "&Format:",IDC_STATIC_HISTORY_FORMAT,30,51,47,8
+ EDITTEXT IDC_EDIT_HISTORY_FORMAT,81,49,137,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Variables...",IDC_BUTTON_HISTORY_DESCRIPTION,221,49,65,12
+ CONTROL "&Add to History only if Value Changed",IDC_CHECK_HISTORY_CONDITION,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,65,252,10
+ CONTROL "Use &External File",IDC_CHECK_EXTERNAL_FILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,85,127,10
+ LTEXT "&Select File:",IDC_STATIC_SELECT_FILE,30,101,49,8
+ EDITTEXT IDC_EDIT_FILE_NAME,81,99,137,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Browse...",IDC_BUTTON_BROWSE,221,99,65,12
+ LTEXT "Variables Allowed: %miranda_userdata%,%quotename%",IDC_STATIC,30,115,257,8,WS_DISABLED
+ LTEXT "F&ormat:",IDC_STATIC_LOG_FILE_FORMAT,30,131,47,8
+ EDITTEXT IDC_EDIT_LOG_FILE_FORMAT,81,129,137,12,ES_AUTOHSCROLL
+ PUSHBUTTON "V&ariables...",IDC_BUTTON_LOG_FILE_DESCRIPTION,221,129,65,12
+ CONTROL "Add to &Log only if Value Changed",IDC_CHECK_LOG_FILE_CONDITION,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,145,224,10
+ CONTROL "Show &Popup Window",IDC_CHECK_SHOW_POPUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,167,120,10
+ LTEXT "F&ormat:",IDC_STATIC_POPUP_FORMAT,30,184,47,8
+ EDITTEXT IDC_EDIT_POPUP_FORMAT,81,182,137,12,ES_AUTOHSCROLL
+ PUSHBUTTON "V&ariables...",IDC_BUTTON_POPUP_FORMAT_DESCRIPTION,221,182,65,12
+ CONTROL "Show Popup Window Only if Value &Changed",IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,197,245,10
+ DEFPUSHBUTTON "OK",IDOK,98,239,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,154,239,50,14
+ EDITTEXT IDC_EDIT_NAME,7,7,289,12,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ PUSHBUTTON "Popup settings...",IDC_BUTTON_POPUP_SETTINGS,86,210,111,14
+END
+
+IDD_DIALOG_POPUP DIALOGEX 0, 0, 319, 160
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Popup Window Settings"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ GROUPBOX "Colours",IDC_STATIC,7,7,149,82,WS_GROUP
+ CONTROL "Use default colours",IDC_RADIO_DEFAULT_COLOURS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,20,82,10
+ CONTROL "Use user-defined colours",IDC_RADIO_USER_DEFINED_COLOURS,
+ "Button",BS_AUTORADIOBUTTON,15,34,97,10
+ LTEXT "Background colour",IDC_STATIC,70,53,66,8
+ CONTROL "",IDC_BGCOLOR,"ColourPicker",WS_TABSTOP,26,49,35,14
+ LTEXT "Text colour",IDC_STATIC,70,71,66,8
+ CONTROL "",IDC_TEXTCOLOR,"ColourPicker",WS_TABSTOP,26,67,35,14
+ GROUPBOX "Delay",IDC_STATIC,162,6,149,82,WS_GROUP
+ CONTROL "From PopUp plugin",IDC_DELAYFROMPU,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,174,20,76,10
+ CONTROL "Custom",IDC_DELAYCUSTOM,"Button",BS_AUTORADIOBUTTON,174,35,47,10
+ CONTROL "Permanent",IDC_DELAYPERMANENT,"Button",BS_AUTORADIOBUTTON,174,50,50,10
+ EDITTEXT IDC_DELAY,252,33,35,14,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP
+ CONTROL "Do not add to popup's history",IDC_CHECK_DONT_USE_POPUPHISTORY,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,96,200,10
+ PUSHBUTTON "Preview",IDC_PREV,134,114,50,14
+ DEFPUSHBUTTON "OK",IDOK,101,139,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,167,139,50,14
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_CONTACT_SETTINGS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 316
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 262
+ END
+
+ IDD_CURRENCY_CONVERTER, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 335
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 94
+ END
+
+ IDD_CHART, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 387
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 272
+ END
+
+ IDD_PROVIDER_ADV_SETTINGS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 296
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 253
+ END
+
+ IDD_DIALOG_POPUP, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 312
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 153
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_CHART DLGINIT
+BEGIN
+ IDC_COMBO_DATA_SOURCE, 0x403, 9, 0
+0x6f4c, 0x2067, 0x6946, 0x656c, "\000"
+ IDC_COMBO_DATA_SOURCE, 0x403, 18, 0
+0x694d, 0x6172, 0x646e, 0x2761, 0x2073, 0x6948, 0x7473, 0x726f, 0x0079,
+
+ IDC_COMBO_FILTER, 0x403, 4, 0
+0x6c41, 0x006c,
+ IDC_COMBO_FILTER, 0x403, 9, 0
+0x614c, 0x7473, 0x4420, 0x7961, "\000"
+ IDC_COMBO_FILTER, 0x403, 10, 0
+0x614c, 0x7473, 0x5720, 0x6565, 0x006b,
+ IDC_COMBO_FILTER, 0x403, 11, 0
+0x614c, 0x7473, 0x4d20, 0x6e6f, 0x6874, "\000"
+ IDC_COMBO_FILTER, 0x403, 10, 0
+0x614c, 0x7473, 0x5920, 0x6165, 0x0072,
+ IDC_COMBO_FILTER, 0x403, 13, 0
+0x7355, 0x7265, 0x442d, 0x6665, 0x6e69, 0x6465, "\000"
+ 0
+END
+
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (United Kingdom) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DIALOG_ECONOMIC_RATES DIALOGEX 0, 0, 310, 230
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "&Choose Quotes to watch in contact list:",IDC_STATIC,7,7,298,8
+ CONTROL "",IDC_TREE_ECONOMIC_RATES,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_CHECKBOXES | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,21,18,284,126
+ LTEXT "&Refresh Quotes Every:",IDC_STATIC,7,150,108,8
+ EDITTEXT IDC_EDIT_REFRESH_RATE,118,148,40,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_SPIN_REFRESH_RATE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_HOTTRACK,230,147,11,14
+ COMBOBOX IDC_COMBO_REFRESH_RATE,161,148,69,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Display in Contact List as:",IDC_STATIC,7,165,109,8
+ EDITTEXT IDC_EDIT_CONTACT_LIST_FORMAT,118,162,120,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Variables...",IDC_BUTTON_DESCRIPTION,240,162,65,12
+ LTEXT "&Status Message:",IDC_STATIC,7,178,107,8
+ EDITTEXT IDC_EDIT_STATUS_MESSAGE_FORMAT,118,176,120,12,ES_AUTOHSCROLL
+ LTEXT "&Tendency:",IDC_STATIC,7,192,102,8
+ EDITTEXT IDC_EDIT_TENDENCY_FORMAT,118,190,120,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Advanced Settings...",IDC_BUTTON_ADVANCED_SETTINGS,103,208,110,14
+END
+
+IDD_DIALOG_QUOTE_INFO DIALOGEX 0, 0, 222, 132
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CTEXT "Static",IDC_STATIC_QUOTE_NAME,7,7,208,8
+ CONTROL "<a>SysLink1</a>",IDC_SYSLINK_PROVIDER,"SysLink",WS_TABSTOP,7,110,208,14
+ LTEXT "Current Rate:",IDC_STATIC,21,62,72,8
+ EDITTEXT IDC_EDIT_RATE,97,60,61,12,ES_AUTOHSCROLL | ES_READONLY
+ LTEXT "Rate Fetch Time:",IDC_STATIC,21,47,73,8
+ EDITTEXT IDC_EDIT_RATE_FETCH_TIME,97,45,98,12,ES_AUTOHSCROLL | ES_READONLY
+ LTEXT "Previous Rate:",IDC_STATIC,21,77,71,8
+ EDITTEXT IDC_EDIT_PREVIOUS_RATE,97,75,61,12,ES_AUTOHSCROLL | ES_READONLY
+END
+
+IDD_DIALOG_OPT_GOOGLE DIALOGEX 0, 0, 310, 233
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "&Convert:",IDC_STATIC,7,9,56,8
+ COMBOBOX IDC_COMBO_CONVERT_FROM,64,7,105,44,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&to:",IDC_STATIC,175,9,21,8
+ COMBOBOX IDC_COMBO_CONVERT_INTO,200,7,105,44,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "&Add",IDC_BUTTON_ADD,255,35,50,14
+ LTEXT "&Watched currency rates:",IDC_STATIC,7,23,110,8
+ LISTBOX IDC_LIST_RATES,19,35,231,111,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "&Remove",IDC_BUTTON_REMOVE,255,52,50,14
+ LTEXT "&Refresh Rates Every:",IDC_STATIC,7,153,107,8
+ EDITTEXT IDC_EDIT_REFRESH_RATE,117,151,40,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_SPIN_REFRESH_RATE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_HOTTRACK,234,150,11,14
+ COMBOBOX IDC_COMBO_REFRESH_RATE,160,151,69,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Display in Contact List as:",IDC_STATIC,7,168,107,8
+ EDITTEXT IDC_EDIT_CONTACT_LIST_FORMAT,117,165,120,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Variables...",IDC_BUTTON_DESCRIPTION,240,165,65,12
+ LTEXT "&Status Message:",IDC_STATIC,7,181,108,8
+ EDITTEXT IDC_EDIT_STATUS_MESSAGE_FORMAT,117,179,120,12,ES_AUTOHSCROLL
+ LTEXT "&Tendency:",IDC_STATIC,7,195,102,8
+ EDITTEXT IDC_EDIT_TENDENCY_FORMAT,117,193,120,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Advanced Settings...",IDC_BUTTON_ADVANCED_SETTINGS,102,211,110,14
+END
+
+IDD_DIALOG_QUOTE_INFO_1 DIALOGEX 0, 0, 222, 143
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Quote\\Rate Info"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CTEXT "Static",IDC_STATIC_QUOTE_NAME,7,7,208,8
+ CONTROL "<a>SysLink1</a>",IDC_SYSLINK_PROVIDER,"SysLink",WS_TABSTOP,7,98,208,14
+ LTEXT "Current Rate:",IDC_STATIC,15,57,81,8
+ EDITTEXT IDC_EDIT_RATE,108,55,61,12,ES_AUTOHSCROLL | ES_READONLY
+ LTEXT "Rate Fetch Time:",IDC_STATIC,15,42,81,8
+ EDITTEXT IDC_EDIT_RATE_FETCH_TIME,108,40,98,12,ES_AUTOHSCROLL | ES_READONLY
+ LTEXT "Previous Rate:",IDC_STATIC,15,72,92,8
+ EDITTEXT IDC_EDIT_PREVIOUS_RATE,108,70,61,12,ES_AUTOHSCROLL | ES_READONLY
+ PUSHBUTTON "Close",IDOK,85,122,50,14
+END
+
+IDD_DIALOG_OPT_FINANCE DIALOGEX 0, 0, 310, 232
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "Type &Stock Name or Symbol:",IDC_STATIC,7,10,96,8
+ EDITTEXT IDC_EDIT_QUOTE,106,7,143,14,ES_AUTOHSCROLL
+ PUSHBUTTON "&Add",IDC_BUTTON_ADD,255,7,50,14
+ LTEXT "&Watched Quotes:",IDC_STATIC,7,23,110,8
+ LISTBOX IDC_LIST_RATES,19,35,231,112,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "&Remove",IDC_BUTTON_REMOVE,255,35,50,14
+ LTEXT "&Refresh Rates Every:",IDC_STATIC,7,153,107,8
+ EDITTEXT IDC_EDIT_REFRESH_RATE,117,151,40,12,ES_AUTOHSCROLL
+ CONTROL "",IDC_SPIN_REFRESH_RATE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_HOTTRACK,234,150,11,14
+ COMBOBOX IDC_COMBO_REFRESH_RATE,160,151,69,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Display in Contact List as:",IDC_STATIC,7,168,107,8
+ EDITTEXT IDC_EDIT_CONTACT_LIST_FORMAT,117,165,120,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Variables...",IDC_BUTTON_DESCRIPTION,240,165,65,12
+ LTEXT "Status &Message:",IDC_STATIC,7,181,108,8
+ EDITTEXT IDC_EDIT_STATUS_MESSAGE_FORMAT,117,179,120,12,ES_AUTOHSCROLL
+ LTEXT "&Tendency:",IDC_STATIC,7,195,102,8
+ EDITTEXT IDC_EDIT_TENDENCY_FORMAT,117,193,120,12,ES_AUTOHSCROLL
+ PUSHBUTTON "&Advanced Settings...",IDC_BUTTON_ADVANCED_SETTINGS,99,210,110,14
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_DIALOG_ECONOMIC_RATES, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 305
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 222
+ END
+
+ IDD_DIALOG_QUOTE_INFO, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 215
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 124
+ END
+
+ IDD_DIALOG_OPT_GOOGLE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 305
+ VERTGUIDE, 249
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 225
+ END
+
+ IDD_DIALOG_QUOTE_INFO_1, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 215
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 135
+ END
+
+ IDD_DIALOG_OPT_FINANCE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 305
+ VERTGUIDE, 249
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 224
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_DIALOG_ECONOMIC_RATES DLGINIT
+BEGIN
+ IDC_COMBO_REFRESH_RATE, 0x403, 8, 0
+0x6553, 0x6f63, 0x646e, 0x0073,
+ IDC_COMBO_REFRESH_RATE, 0x403, 8, 0
+0x694d, 0x756e, 0x6574, 0x0073,
+ IDC_COMBO_REFRESH_RATE, 0x403, 6, 0
+0x6f48, 0x7275, 0x0073,
+ 0
+END
+
+IDD_DIALOG_OPT_GOOGLE DLGINIT
+BEGIN
+ IDC_COMBO_REFRESH_RATE, 0x403, 8, 0
+0x6553, 0x6f63, 0x646e, 0x0073,
+ IDC_COMBO_REFRESH_RATE, 0x403, 8, 0
+0x694d, 0x756e, 0x6574, 0x0073,
+ IDC_COMBO_REFRESH_RATE, 0x403, 6, 0
+0x6f48, 0x7275, 0x0073,
+ 0
+END
+
+IDD_DIALOG_OPT_FINANCE DLGINIT
+BEGIN
+ IDC_COMBO_REFRESH_RATE, 0x403, 8, 0
+0x6553, 0x6f63, 0x646e, 0x0073,
+ IDC_COMBO_REFRESH_RATE, 0x403, 8, 0
+0x694d, 0x756e, 0x6574, 0x0073,
+ IDC_COMBO_REFRESH_RATE, 0x403, 6, 0
+0x6f48, 0x7275, 0x0073,
+ 0
+END
+
+#endif // English (United Kingdom) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/Quotes/res/Import quotes.ico b/plugins/Quotes/res/Import quotes.ico Binary files differnew file mode 100644 index 0000000000..506aa62af3 --- /dev/null +++ b/plugins/Quotes/res/Import quotes.ico diff --git a/plugins/Quotes/res/Refresh.ico b/plugins/Quotes/res/Refresh.ico Binary files differnew file mode 100644 index 0000000000..2dbcfd3878 --- /dev/null +++ b/plugins/Quotes/res/Refresh.ico diff --git a/plugins/Quotes/res/Section.ico b/plugins/Quotes/res/Section.ico Binary files differnew file mode 100644 index 0000000000..f59105b665 --- /dev/null +++ b/plugins/Quotes/res/Section.ico diff --git a/plugins/Quotes/res/Version.rc b/plugins/Quotes/res/Version.rc new file mode 100644 index 0000000000..d5721e1578 --- /dev/null +++ b/plugins/Quotes/res/Version.rc @@ -0,0 +1,45 @@ +// Microsoft Visual C++ generated resource script.
+//
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+#include "afxres.h"
+#include "..\src\version.h"
+
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#endif //_WIN32
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "FileDescription", __DESCRIPTION
+ VALUE "FileVersion", __FILEVERSION_DOTS
+ VALUE "InternalName", __PLUGIN_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ VALUE "ProductName", __PLUGIN_NAME
+ VALUE "ProductVersion", __FILEVERSION_DOTS
+ VALUE "SpecialBuild", SPECIAL_BUILD_STRING
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
diff --git a/plugins/Quotes/res/down.ico b/plugins/Quotes/res/down.ico Binary files differnew file mode 100644 index 0000000000..9dfe185cbe --- /dev/null +++ b/plugins/Quotes/res/down.ico diff --git a/plugins/Quotes/res/main.ico b/plugins/Quotes/res/main.ico Binary files differnew file mode 100644 index 0000000000..4d32e57495 --- /dev/null +++ b/plugins/Quotes/res/main.ico diff --git a/plugins/Quotes/res/notchanged.ico b/plugins/Quotes/res/notchanged.ico Binary files differnew file mode 100644 index 0000000000..e1d9ee3a09 --- /dev/null +++ b/plugins/Quotes/res/notchanged.ico diff --git a/plugins/Quotes/res/quote.ico b/plugins/Quotes/res/quote.ico Binary files differnew file mode 100644 index 0000000000..832ed12f52 --- /dev/null +++ b/plugins/Quotes/res/quote.ico diff --git a/plugins/Quotes/res/swap.ico b/plugins/Quotes/res/swap.ico Binary files differnew file mode 100644 index 0000000000..1bff71b764 --- /dev/null +++ b/plugins/Quotes/res/swap.ico diff --git a/plugins/Quotes/res/up.ico b/plugins/Quotes/res/up.ico Binary files differnew file mode 100644 index 0000000000..a75899cd3d --- /dev/null +++ b/plugins/Quotes/res/up.ico diff --git a/plugins/Quotes/src/Base64.cpp b/plugins/Quotes/src/Base64.cpp new file mode 100644 index 0000000000..1854fb42fd --- /dev/null +++ b/plugins/Quotes/src/Base64.cpp @@ -0,0 +1,43 @@ +#include "StdAfx.h"
+#include "Base64.h"
+
+bool base64::encode(const BYTE* in, size_t inlen,std::vector<char>& out)
+{
+ int nOutLength = Base64EncodeGetRequiredLength((int)inlen);
+ out.resize(nOutLength);
+ char* p = &*out.begin();
+ bool bResult = (TRUE == Base64Encode(in,(int)inlen,p,&nOutLength));
+ if(false == bResult)
+ {
+ out.resize(nOutLength);
+ p = &*out.begin();
+ bResult = (TRUE == Base64Encode(in,(int)inlen,p,&nOutLength));
+ }
+ if(bResult)
+ {
+ out.resize(nOutLength);
+ }
+
+ return bResult;
+}
+
+
+bool base64::decode(const char* in, size_t inlen,std::vector<BYTE>& out)
+{
+ int nOutLength = (int)inlen;
+ out.resize(nOutLength);
+ BYTE* p = &*out.begin();
+ bool bResult = TRUE == Base64Decode(in,(int)inlen,p,&nOutLength);
+ if(false == bResult)
+ {
+ out.resize(nOutLength);
+ p = &*out.begin();
+ bResult = TRUE == Base64Decode(in,(int)inlen,p,&nOutLength);
+ }
+ if(bResult)
+ {
+ out.resize(nOutLength);
+ }
+
+ return true;
+}
diff --git a/plugins/Quotes/src/Base64.h b/plugins/Quotes/src/Base64.h new file mode 100644 index 0000000000..3f911bfeb8 --- /dev/null +++ b/plugins/Quotes/src/Base64.h @@ -0,0 +1,12 @@ +#ifndef __FBB8ABCA_315E_4ace_B2EB_51E03AD6F8D1_Base64_h__
+#define __FBB8ABCA_315E_4ace_B2EB_51E03AD6F8D1_Base64_h__
+
+#pragma once
+
+namespace base64
+{
+ bool encode(const BYTE* in, size_t inlen,std::vector<char>& out);
+ bool decode(const char* in, size_t inlen,std::vector<BYTE>& out);
+}
+
+#endif //__FBB8ABCA_315E_4ace_B2EB_51E03AD6F8D1_Base64_h__
diff --git a/plugins/Quotes/src/Chart.h b/plugins/Quotes/src/Chart.h new file mode 100644 index 0000000000..62a658d818 --- /dev/null +++ b/plugins/Quotes/src/Chart.h @@ -0,0 +1,280 @@ +#ifndef __FAE7F26E_61ED_4951_BE87_5E022CDF21DF_Chart_h__
+#define __FAE7F26E_61ED_4951_BE87_5E022CDF21DF_Chart_h__
+
+#pragma once
+
+namespace detail
+{
+ template<class T> struct CConverter
+ {
+ static double Convert(const T& v)
+ {
+ return boost::numeric_cast<double>(v);
+ }
+
+ static tstring ToString(const T& v)
+ {
+ return boost::lexical_cast<tstring>(v);
+ }
+ };
+
+ template<> struct CConverter<double>
+ {
+ static double Convert(double v)
+ {
+ return v;
+ }
+
+ static tstring ToString(double v)
+ {
+ tostringstream s;
+ s.imbue(std::locale(""));
+ s << std::fixed << v;
+ return s.str();
+ }
+ };
+}
+
+template<class TXValue,class TYValue,class TXConverter = detail::CConverter<TXValue>,class TYConverter = detail::CConverter<TYValue> >
+class CChart
+{
+private:
+ typedef std::pair<TXValue,TYValue> TValue;
+ typedef std::vector<TValue> TValues;
+
+public:
+ CChart() : m_MaxY(),m_MinY()
+ {
+ ZeroMemory(&m_rect,sizeof(m_rect));
+ }
+
+ ~CChart()
+ {
+ }
+
+ void AddValue(const TXValue& x,const TYValue& y)
+ {
+ if(m_aValues.empty())
+ {
+ m_MaxY = m_MinY = y;
+ }
+ else
+ {
+ m_MaxY = __max(y,m_MaxY);
+ m_MinY = __min(y,m_MinY);
+ }
+ m_aValues.push_back(std::make_pair(x,y));
+ }
+
+ void SetRect(int x,int y,int cx,int cy)
+ {
+ m_rect.left = x;
+ m_rect.right = x + cx;
+ m_rect.top = y;
+ m_rect.bottom = y + cy;
+ }
+
+ void Draw(HDC hdc)const
+ {
+ RECT rc = m_rect;
+ DrawBackground(hdc,rc);
+ if(false == m_aValues.empty())
+ {
+ ::InflateRect(&rc,-10,-10);
+ DrawGrid(hdc,rc);
+ DrawAxis(hdc,rc);
+ DrawPoints(hdc,rc);
+ }
+ else
+ {
+ HFONT hFont = static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
+ HFONT hOldFont = static_cast<HFONT>(::SelectObject(hdc,hFont));
+
+ LPCTSTR pszText = TranslateT("There is no to show");
+ int nDrawTextResult = ::DrawText(hdc,pszText,::lstrlen(pszText),&rc,DT_SINGLELINE|DT_VCENTER|DT_CENTER);
+ assert(0 != nDrawTextResult);
+
+ ::SelectObject(hdc,hOldFont);
+ BOOL bResult = ::DeleteObject(hFont);
+ assert(TRUE == bResult);
+ }
+ }
+
+private:
+ void DrawBackground(HDC hdc,RECT& rc)const
+ {
+// HBRUSH hBrush = ::CreateSolidBrush(RGB(255,0,0));//user preferable background color here!
+// ::FillRect(hdc,&m_rect,hBrush);
+// ::DeleteBrush(hBrush);
+ }
+
+ void DrawGrid(HDC hdc,RECT& rc)const
+ {
+ enum{number_of_lines = 5};
+ HPEN hPen = ::CreatePen(PS_SOLID,1,RGB(125,125,125));
+ HPEN hPenOld = static_cast<HPEN>(::SelectObject(hdc,hPen));
+ HFONT hFont = static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
+ HFONT hOldFont = static_cast<HFONT>(::SelectObject(hdc,hFont));
+
+ //vertical grid
+ int step = (rc.bottom-rc.top)/number_of_lines;
+ TYValue y_val = m_MinY + ((m_MaxY-m_MinY)/number_of_lines);
+ int nXIndent = 0;
+ for(int y = rc.bottom-step;y > rc.top;y-=step,y_val+=((m_MaxY-m_MinY)/number_of_lines))
+ {
+ tstring sY = TYConverter::ToString(y_val);
+ SIZE sizeText = {0,0};
+ BOOL bResult = ::GetTextExtentPoint32(hdc,sY.c_str(), (int)sY.size(), &sizeText);
+ assert(TRUE == bResult);
+ nXIndent = __max(nXIndent,sizeText.cx);
+ }
+
+ y_val = m_MinY + ((m_MaxY-m_MinY)/number_of_lines);
+ nXIndent += 2;
+ rc.left += nXIndent;
+ for(int y = rc.bottom-step;y > rc.top;y-=step,y_val+=((m_MaxY-m_MinY)/number_of_lines))
+ {
+ tstring sY = TYConverter::ToString(y_val);
+ SIZE sizeText = {0,0};
+ BOOL bResult = ::GetTextExtentPoint32(hdc, sY.c_str(), (int)sY.size(), &sizeText);
+ assert(TRUE == bResult);
+
+ RECT rcText = {rc.left-nXIndent,y-(sizeText.cy/2),rc.left-1,y+(sizeText.cy/2)};
+ int nDrawTextResult = ::DrawText(hdc, sY.c_str(), (int)sY.size(), &rcText, DT_SINGLELINE|DT_VCENTER|DT_RIGHT);
+ assert(0 != nDrawTextResult);
+
+ bResult = ::MoveToEx(hdc,rc.left,y,NULL);
+ assert(TRUE == bResult);
+
+ bResult = ::LineTo(hdc,rc.right,y);
+ assert(TRUE == bResult);
+ }
+
+ // horizontal grid
+ HRGN rgnAllLables = ::CreateRectRgn(0,0,0,0);
+ HRGN rgnTemporary = ::CreateRectRgn(0,0,0,0);
+ bool bFixedRect = false;
+ step = (rc.right-rc.left)/number_of_lines;
+ TXValue x_val = m_aValues[0].first + ((m_aValues[m_aValues.size()-1].first-m_aValues[0].first)/number_of_lines);
+ for(int x = rc.left+step;x < rc.right;x+=step,x_val+=((m_aValues[m_aValues.size()-1].first-m_aValues[0].first)/number_of_lines))
+ {
+ tstring sX = TXConverter::ToString(x_val);
+ SIZE sizeText = {0,0};
+ BOOL bResult = ::GetTextExtentPoint32(hdc, sX.c_str(), (int)sX.size(), &sizeText);
+ assert(TRUE == bResult);
+
+ if(false == bFixedRect)
+ {
+ rc.bottom -= sizeText.cy+2;
+ bFixedRect = true;
+ }
+
+ RECT rcText = {x-(sizeText.cx/2),rc.bottom,x+(sizeText.cx/2),rc.bottom+sizeText.cy-1};
+ // Draw a label if it doesn't overlap with previous ones
+ HRGN rgnCurrentLable = ::CreateRectRgnIndirect(&rcText);
+ if(NULLREGION == ::CombineRgn(rgnTemporary,rgnCurrentLable,rgnAllLables,RGN_AND))
+ {
+ int nDrawTextResult = ::DrawText(hdc, sX.c_str(), (int)sX.size(), &rcText, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
+ assert(0 != nDrawTextResult);
+ int nCombineRgnResult = ::CombineRgn(rgnTemporary,rgnCurrentLable,rgnAllLables,RGN_OR);
+ assert(ERROR != nCombineRgnResult);
+ nCombineRgnResult = ::CombineRgn(rgnAllLables,rgnTemporary,NULL,RGN_COPY);
+ assert(ERROR != nCombineRgnResult);
+ }
+ bResult = ::DeleteObject(rgnCurrentLable);
+ assert(TRUE == bResult);
+
+ bResult = ::MoveToEx(hdc,x,rc.bottom,NULL);
+ assert(TRUE == bResult);
+
+ bResult = ::LineTo(hdc,x,rc.top);
+ assert(TRUE == bResult);
+ }
+
+ BOOL bResult = ::DeleteObject(rgnAllLables);
+ assert(TRUE == bResult);
+ bResult = ::DeleteObject(rgnTemporary);
+ assert(TRUE == bResult);
+
+ ::SelectObject(hdc,hOldFont);
+ ::SelectObject(hdc,hPenOld);
+ bResult = ::DeleteObject(hFont);
+ assert(TRUE == bResult);
+ bResult = ::DeleteObject(hPen);
+ assert(TRUE == bResult);
+ }
+
+ void DrawAxis(HDC hdc,RECT& rc)const
+ {
+ HPEN hPen = ::CreatePen(PS_SOLID,2,RGB(0,0,0));
+ HPEN hPenOld = static_cast<HPEN>(::SelectObject(hdc,hPen));
+
+ // draw Y-axes
+ BOOL bResult = ::MoveToEx(hdc,rc.left+1,rc.bottom-1,NULL);
+ assert(TRUE == bResult);
+ bResult = ::LineTo(hdc,rc.left+1,rc.top+1);
+ assert(TRUE == bResult);
+
+ // draw X-axes
+ bResult = ::MoveToEx(hdc,rc.left+1,rc.bottom-1,NULL);
+ assert(TRUE == bResult);
+ bResult = ::LineTo(hdc,rc.right-1,rc.bottom-1);
+ assert(TRUE == bResult);
+
+ ::SelectObject(hdc,hPenOld);
+ bResult = ::DeleteObject(hPen);
+ assert(TRUE == bResult);
+ }
+
+ void DrawPoints(HDC hdc,RECT& rc)const
+ {
+ TXValue xMin(m_aValues[0].first);
+ double dx = TXConverter::Convert(m_aValues[m_aValues.size()-1].first-xMin);
+ double dY = TYConverter::Convert(m_MaxY-m_MinY);
+
+ HPEN hPen = ::CreatePen(PS_SOLID,1,RGB(255,0,0));
+ HGDIOBJ hPenOld = ::SelectObject(hdc,hPen);
+
+ HBRUSH hBrush = ::CreateSolidBrush(RGB(255,0,0));
+ HGDIOBJ hBrushOld = ::SelectObject(hdc,hBrush);
+
+ bool bPrevValid = false;
+ int xPrex,yPrev;
+
+ BOOST_FOREACH(const TValue& v,m_aValues)
+ {
+ double k = TXConverter::Convert(v.first-xMin);
+
+ int x = rc.left+boost::numeric_cast<int>((rc.right-rc.left)*(k/dx));
+ k = TYConverter::Convert(v.second-m_MinY);
+ int y = rc.bottom-boost::numeric_cast<int>((rc.bottom-rc.top)*(k/dY));
+ ::Ellipse(hdc,x-5,y-5,x+5,y+5);
+ if(bPrevValid)
+ {
+ BOOL bResult = ::MoveToEx(hdc,xPrex,yPrev,NULL);
+ assert(TRUE == bResult);
+ bResult = ::LineTo(hdc,x,y);
+ assert(TRUE == bResult);
+ }
+
+ xPrex = x,yPrev = y;
+ bPrevValid = true;
+ }
+
+ ::SelectObject(hdc,hPenOld);
+ BOOL bResult = ::DeleteObject(hPen);
+ assert(TRUE == bResult);
+
+ ::SelectObject(hdc,hBrushOld);
+ bResult = ::DeleteObject(hBrush);
+ assert(TRUE == bResult);
+ }
+
+private:
+ TValues m_aValues;
+ RECT m_rect;
+ TYValue m_MaxY;
+ TYValue m_MinY;
+};
+
+#endif // __FAE7F26E_61ED_4951_BE87_5E022CDF21DF_Chart_h__
diff --git a/plugins/Quotes/src/ComHelper.cpp b/plugins/Quotes/src/ComHelper.cpp new file mode 100644 index 0000000000..e15d05d739 --- /dev/null +++ b/plugins/Quotes/src/ComHelper.cpp @@ -0,0 +1,39 @@ +#include "StdAfx.h"
+#include "ComHelper.h"
+#include "Log.h"
+#include "WinCtrlHelper.h"
+
+tstring ComException2Msg(_com_error& e,const tstring& rsAdditionalInfo)
+{
+ HRESULT hError = e.Error();
+ tostringstream o;
+ if(false == rsAdditionalInfo.empty())
+ {
+ o << rsAdditionalInfo << "\n";
+ }
+
+ o << e.ErrorMessage() << _T(" (") << std::hex << hError << _T(")");
+
+ IErrorInfo* p = e.ErrorInfo();
+ CComPtr<IErrorInfo> pErrorInfo(p);
+ if(NULL != p)
+ {
+ p->Release();
+ }
+
+ if(pErrorInfo)
+ {
+ o << _T("\n") << e.Description();
+ }
+
+ return o.str();
+}
+
+void ShowComError(_com_error& e,const tstring& rsAdditionalInfo)
+{
+ tstring sErrorMsg = ComException2Msg(e,rsAdditionalInfo);
+ LogIt(Error,sErrorMsg);
+ Quotes_MessageBox(NULL,sErrorMsg.c_str(),MB_OK|MB_ICONERROR);
+}
+
+
diff --git a/plugins/Quotes/src/ComHelper.h b/plugins/Quotes/src/ComHelper.h new file mode 100644 index 0000000000..0b4140d80d --- /dev/null +++ b/plugins/Quotes/src/ComHelper.h @@ -0,0 +1,9 @@ +#ifndef __37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__
+#define __37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__
+
+#include <string>
+
+void ShowComError(_com_error& e,const tstring& rsAdditionalInfo);
+tstring ComException2Msg(_com_error& e,const tstring& rsAdditionalInfo);
+
+#endif//__37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__
diff --git a/plugins/Quotes/src/CommonOptionDlg.cpp b/plugins/Quotes/src/CommonOptionDlg.cpp new file mode 100644 index 0000000000..0b460665c5 --- /dev/null +++ b/plugins/Quotes/src/CommonOptionDlg.cpp @@ -0,0 +1,272 @@ +#include "StdAfx.h"
+#include "CommonOptionDlg.h"
+#include "QuotesProviderBase.h"
+#include "resource.h"
+#include "EconomicRateInfo.h"
+#include "DBUtils.h"
+#include "QuotesProviderVisitorDbSettings.h"
+#include "WinCtrlHelper.h"
+#include "SettingsDlg.h"
+
+namespace
+{
+ typedef boost::shared_ptr<CAdvProviderSettings> TAdvSettingsPtr;
+ typedef std::map<const IQuotesProvider*,TAdvSettingsPtr> TAdvSettings;
+
+ TAdvSettings g_aAdvSettings;
+
+ CAdvProviderSettings* get_adv_settings(const IQuotesProvider* pProvider,bool bCreateIfNonExist)
+ {
+ TAdvSettings::iterator i = g_aAdvSettings.find(pProvider);
+ if(i != g_aAdvSettings.end())
+ {
+ return i->second.get();
+ }
+ else if(true == bCreateIfNonExist)
+ {
+ TAdvSettingsPtr pAdvSet(new CAdvProviderSettings(pProvider));
+ g_aAdvSettings.insert(std::make_pair(pProvider,pAdvSet));
+ return pAdvSet.get();
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+
+ void remove_adv_settings(const IQuotesProvider* pProvider)
+ {
+ TAdvSettings::iterator i = g_aAdvSettings.find(pProvider);
+ if(i != g_aAdvSettings.end())
+ {
+ g_aAdvSettings.erase(i);
+ }
+ }
+}
+
+void CommonOptionDlgProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp,CCommonDlgProcData& rData)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ assert(rData.m_pQuotesProvider);
+
+ CQuotesProviderVisitorDbSettings visitor;
+ rData.m_pQuotesProvider->Accept(visitor);
+ assert(visitor.m_pszDbRefreshRateType);
+ assert(visitor.m_pszDbRefreshRateValue);
+ assert(visitor.m_pszDbDisplayNameFormat);
+ assert(visitor.m_pszDbStatusMsgFormat);
+ assert(visitor.m_pszDbTendencyFormat);
+
+ // set contact list display format
+ tstring sDspNameFrmt = Quotes_DBGetStringT(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbDisplayNameFormat,visitor.m_pszDefDisplayFormat);
+ ::SetDlgItemText(hWnd,IDC_EDIT_CONTACT_LIST_FORMAT,sDspNameFrmt.c_str());
+
+ // set status message display format
+ tstring sStatusMsgFrmt = Quotes_DBGetStringT(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbStatusMsgFormat,visitor.m_pszDefStatusMsgFormat);
+ ::SetDlgItemText(hWnd,IDC_EDIT_STATUS_MESSAGE_FORMAT,sStatusMsgFrmt.c_str());
+
+ // set tendency format
+ tstring sTendencyFrmt = Quotes_DBGetStringT(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbTendencyFormat,visitor.m_pszDefTendencyFormat);
+ ::SetDlgItemText(hWnd,IDC_EDIT_TENDENCY_FORMAT,sTendencyFrmt.c_str());
+
+ // refresh rate
+ HWND hwndCombo = ::GetDlgItem(hWnd,IDC_COMBO_REFRESH_RATE);
+ LPCTSTR pszRefreshRateTypes[] = {TranslateT("Seconds"),TranslateT("Minutes"),TranslateT("Hours")};
+ for(int i = 0;i < SIZEOF(pszRefreshRateTypes);++i)
+ {
+ ::SendMessage(hwndCombo,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(pszRefreshRateTypes[i]));
+ }
+
+ int nRefreshRateType = DBGetContactSettingWord(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbRefreshRateType,RRT_MINUTES);
+ if(nRefreshRateType < RRT_SECONDS || nRefreshRateType > RRT_HOURS)
+ {
+ nRefreshRateType = RRT_MINUTES;
+ }
+
+ UINT nRate = DBGetContactSettingWord(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbRefreshRateValue,1);
+ switch(nRefreshRateType)
+ {
+ default:
+ case RRT_SECONDS:
+ case RRT_MINUTES:
+ if(nRate < 1 || nRate > 60)
+ {
+ nRate = 1;
+ }
+ spin_set_range(::GetDlgItem(hWnd,IDC_SPIN_REFRESH_RATE),1,60);
+ break;
+ case RRT_HOURS:
+ if(nRate < 1 || nRate > 24)
+ {
+ nRate = 1;
+ }
+ spin_set_range(::GetDlgItem(hWnd,IDC_SPIN_REFRESH_RATE),1,24);
+ break;
+ }
+
+ ::SendMessage(hwndCombo,CB_SETCURSEL,nRefreshRateType,0);
+ ::SetDlgItemInt(hWnd,IDC_EDIT_REFRESH_RATE,nRate,FALSE);
+
+ PropSheet_UnChanged(::GetParent(hWnd),hWnd);
+ }
+ break;
+ case WM_COMMAND:
+ switch(HIWORD(wp))
+ {
+ case CBN_SELCHANGE:
+ if(IDC_COMBO_REFRESH_RATE == LOWORD(wp))
+ {
+ ERefreshRateType nType = static_cast<ERefreshRateType>(::SendMessage(reinterpret_cast<HWND>(lp),CB_GETCURSEL,0,0));
+ switch(nType)
+ {
+ default:
+ case RRT_SECONDS:
+ case RRT_MINUTES:
+ spin_set_range(::GetDlgItem(hWnd,IDC_SPIN_REFRESH_RATE),1,60);
+ break;
+ case RRT_HOURS:
+ {
+ spin_set_range(::GetDlgItem(hWnd,IDC_SPIN_REFRESH_RATE),1,24);
+ BOOL bOk = FALSE;
+ UINT nRefreshRate = ::GetDlgItemInt(hWnd,IDC_EDIT_REFRESH_RATE,&bOk,FALSE);
+ if(TRUE == bOk && nRefreshRate > 24)
+ {
+ ::SetDlgItemInt(hWnd,IDC_EDIT_REFRESH_RATE,24,FALSE);
+ }
+ }
+ break;
+ }
+
+ PropSheet_Changed(::GetParent(hWnd),hWnd);
+ }
+ break;
+ case EN_CHANGE:
+ switch(LOWORD(wp))
+ {
+ case IDC_EDIT_REFRESH_RATE:
+ case IDC_EDIT_CONTACT_LIST_FORMAT:
+ case IDC_EDIT_STATUS_MESSAGE_FORMAT:
+ case IDC_EDIT_TENDENCY_FORMAT:
+ if(reinterpret_cast<HWND>(lp) == ::GetFocus())
+ {
+ PropSheet_Changed(::GetParent(hWnd),hWnd);
+ }
+ break;
+ }
+ break;
+ case BN_CLICKED:
+ switch( LOWORD(wp))
+ {
+ case IDC_BUTTON_DESCRIPTION:
+ show_variable_list(hWnd,rData.m_pQuotesProvider);
+ break;
+ case IDC_BUTTON_ADVANCED_SETTINGS:
+ {
+ CAdvProviderSettings* pAdvSet = get_adv_settings(rData.m_pQuotesProvider,true);
+ assert(pAdvSet);
+ if(true == ShowSettingsDlg(hWnd,pAdvSet))
+ {
+ PropSheet_Changed(::GetParent(hWnd),hWnd);
+ }
+ }
+ break;
+ }
+ break;
+ }
+ break;
+ case WM_NOTIFY:
+ {
+ LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lp);
+ switch(pNMHDR->code)
+ {
+ case PSN_KILLACTIVE:
+ {
+ BOOL bOk = FALSE;
+ UINT nRefreshRate = ::GetDlgItemInt(hWnd,IDC_EDIT_REFRESH_RATE,&bOk,FALSE);
+ ERefreshRateType nType = static_cast<ERefreshRateType>(::SendMessage(::GetDlgItem(hWnd,IDC_COMBO_REFRESH_RATE),CB_GETCURSEL,0,0));
+ switch(nType)
+ {
+ default:
+ case RRT_MINUTES:
+ case RRT_SECONDS:
+ if(FALSE == bOk || nRefreshRate < 1 || nRefreshRate > 60)
+ {
+ prepare_edit_ctrl_for_error(::GetDlgItem(hWnd,IDC_EDIT_REFRESH_RATE));
+ Quotes_MessageBox(hWnd,TranslateT("Enter integer value between 1 and 60."),MB_OK|MB_ICONERROR);
+ bOk = FALSE;
+ }
+ break;
+ case RRT_HOURS:
+ if(FALSE == bOk || nRefreshRate < 1 || nRefreshRate > 24)
+ {
+ prepare_edit_ctrl_for_error(::GetDlgItem(hWnd,IDC_EDIT_REFRESH_RATE));
+ Quotes_MessageBox(hWnd,TranslateT("Enter integer value between 1 and 24."),MB_OK|MB_ICONERROR);
+ bOk = FALSE;
+ }
+ break;
+ }
+
+ if(TRUE == bOk)
+ {
+ HWND hEdit = ::GetDlgItem(hWnd,IDC_EDIT_CONTACT_LIST_FORMAT);
+ assert(IsWindow(hEdit));
+
+ tstring s = get_window_text(hEdit);
+ if(true == s.empty())
+ {
+ prepare_edit_ctrl_for_error(hEdit);
+ Quotes_MessageBox(hWnd,TranslateT("Enter text to display in contact list."),MB_OK|MB_ICONERROR);
+ bOk = FALSE;
+ }
+ }
+
+ ::SetWindowLongPtr(hWnd,DWLP_MSGRESULT,(TRUE == bOk) ? FALSE : TRUE);
+ }
+ break;
+ case PSN_APPLY:
+ {
+ BOOL bOk = FALSE;
+ UINT nRefreshRate = ::GetDlgItemInt(hWnd,IDC_EDIT_REFRESH_RATE,&bOk,FALSE);
+ assert(TRUE == bOk);
+ ERefreshRateType nType = static_cast<ERefreshRateType>(::SendMessage(::GetDlgItem(hWnd,IDC_COMBO_REFRESH_RATE),CB_GETCURSEL,0,0));
+
+ assert(rData.m_pQuotesProvider);
+
+ CQuotesProviderVisitorDbSettings visitor;
+ rData.m_pQuotesProvider->Accept(visitor);
+ assert(visitor.m_pszDbRefreshRateType);
+ assert(visitor.m_pszDbRefreshRateValue);
+ assert(visitor.m_pszDbDisplayNameFormat);
+ assert(visitor.m_pszDbStatusMsgFormat);
+
+ rData.m_bFireSetingsChangedEvent = true;
+ DBWriteContactSettingWord(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbRefreshRateType,nType);
+ DBWriteContactSettingWord(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbRefreshRateValue,nRefreshRate);
+
+ tstring s = get_window_text(::GetDlgItem(hWnd,IDC_EDIT_CONTACT_LIST_FORMAT));
+ DBWriteContactSettingTString(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbDisplayNameFormat,s.c_str());
+
+ s = get_window_text(::GetDlgItem(hWnd,IDC_EDIT_STATUS_MESSAGE_FORMAT));
+ DBWriteContactSettingTString(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbStatusMsgFormat,s.c_str());
+
+ s = get_window_text(::GetDlgItem(hWnd,IDC_EDIT_TENDENCY_FORMAT));
+ DBWriteContactSettingTString(NULL,QUOTES_MODULE_NAME,visitor.m_pszDbTendencyFormat,s.c_str());
+
+ CAdvProviderSettings* pAdvSet = get_adv_settings(rData.m_pQuotesProvider,false);
+ if(pAdvSet)
+ {
+ pAdvSet->SaveToDb();
+ }
+ }
+ break;
+ }
+ }
+ break;
+ case WM_DESTROY:
+ remove_adv_settings(rData.m_pQuotesProvider);
+ break;
+ }
+}
\ No newline at end of file diff --git a/plugins/Quotes/src/CommonOptionDlg.h b/plugins/Quotes/src/CommonOptionDlg.h new file mode 100644 index 0000000000..b9f696362a --- /dev/null +++ b/plugins/Quotes/src/CommonOptionDlg.h @@ -0,0 +1,17 @@ +#ifndef __c85fe710_f71b_4a58_9d44_3e39f6209c5f_CommonOptionDlg_h__
+#define __c85fe710_f71b_4a58_9d44_3e39f6209c5f_CommonOptionDlg_h__
+
+class CQuotesProviderBase;
+
+struct CCommonDlgProcData
+{
+ CCommonDlgProcData(const CQuotesProviderBase* pQuotesProvider)
+ : m_pQuotesProvider(pQuotesProvider),m_bFireSetingsChangedEvent(false){}
+
+ const CQuotesProviderBase* m_pQuotesProvider;
+ bool m_bFireSetingsChangedEvent;
+};
+
+void CommonOptionDlgProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp,CCommonDlgProcData& rData);
+
+#endif//__c85fe710_f71b_4a58_9d44_3e39f6209c5f_CommonOptionDlg_h__
diff --git a/plugins/Quotes/src/CreateFilePath.cpp b/plugins/Quotes/src/CreateFilePath.cpp new file mode 100644 index 0000000000..23c0c345b0 --- /dev/null +++ b/plugins/Quotes/src/CreateFilePath.cpp @@ -0,0 +1,45 @@ +#include "StdAfx.h"
+#include "CreateFilePath.h"
+
+#include <sstream>
+#include "ModuleInfo.h"
+
+namespace
+{
+ TCHAR replace_invalid_symbol(TCHAR chr)
+ {
+ TCHAR InvaliSymbols[] = {_T('\\'),_T('/'),_T(':'),_T('*'),_T('?'),_T('"'),_T('<'),_T('>'),_T('|')};
+ for(int i = 0; i < sizeof(InvaliSymbols)/sizeof(InvaliSymbols[0]);++i)
+ {
+ if(chr == InvaliSymbols[i])
+ {
+ return _T('_');
+ }
+ }
+
+ return chr;
+ }
+
+ void prepare_name(tstring& rsName)
+ {
+ std::transform(rsName.begin(),rsName.end(),rsName.begin(),boost::bind(replace_invalid_symbol,_1));
+ }
+}
+
+tstring CreateFilePath(const tstring& rsName)
+{
+ TCHAR szPath[_MAX_PATH];
+ ::GetModuleFileName(g_hInstance,szPath,_MAX_PATH);
+
+ TCHAR* p = _tcsrchr(szPath,_T('\\'));
+ if(p)
+ {
+ *p = 0;
+ }
+
+ tstring s(rsName);
+ prepare_name(s);
+ tostringstream o;
+ o << szPath << _T("\\Quotes\\") << s;
+ return o.str();
+}
\ No newline at end of file diff --git a/plugins/Quotes/src/CreateFilePath.h b/plugins/Quotes/src/CreateFilePath.h new file mode 100644 index 0000000000..f097e59a52 --- /dev/null +++ b/plugins/Quotes/src/CreateFilePath.h @@ -0,0 +1,8 @@ +#ifndef _aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__
+#define _aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__
+
+#include <string>
+
+tstring CreateFilePath(const tstring& rsName);
+
+#endif //_aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__
diff --git a/plugins/Quotes/src/CurrencyConverter.cpp b/plugins/Quotes/src/CurrencyConverter.cpp new file mode 100644 index 0000000000..7124677567 --- /dev/null +++ b/plugins/Quotes/src/CurrencyConverter.cpp @@ -0,0 +1,309 @@ +#include "StdAfx.h"
+#include "CurrencyConverter.h"
+#include "ModuleInfo.h"
+#include "resource.h"
+
+#include "QuotesProviderGoogle.h"
+#include "QuotesProviders.h"
+#include "WinCtrlHelper.h"
+#include "EconomicRateInfo.h"
+#include "Locale.h"
+#include "DBUtils.h"
+#include "IconLib.h"
+
+#define WINDOW_PREFIX "CurrenyConverter_"
+
+#define DB_STR_CC_QUOTE_FROM_ID "CurrencyConverter_FromID"
+#define DB_STR_CC_QUOTE_TO_ID "CurrencyConverter_ToID"
+#define DB_STR_CC_AMOUNT "CurrencyConverter_Amount"
+
+namespace
+{
+ CQuotesProviderGoogle* get_google_provider()
+ {
+ CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr();
+ const CQuotesProviders::TQuotesProviders& rapQuotesProviders = pProviders->GetProviders();
+ for(CQuotesProviders::TQuotesProviders::const_iterator i = rapQuotesProviders.begin();i != rapQuotesProviders.end();++i)
+ {
+ const CQuotesProviders::TQuotesProviderPtr& pProvider = *i;
+ CQuotesProviderGoogle* pGoogle = dynamic_cast<CQuotesProviderGoogle*>(pProvider.get());
+ if(pGoogle)
+ {
+ return pGoogle;
+ }
+ }
+
+ assert(!"We should never get here!");
+ return NULL;
+ }
+
+
+ CQuotesProviderGoogle::CQuoteSection get_quotes(const CQuotesProviderGoogle* pProvider = NULL)
+ {
+ if(NULL == pProvider)
+ {
+ pProvider = get_google_provider();
+ }
+
+ if(pProvider)
+ {
+ const CQuotesProviderGoogle::CQuoteSection& rQuotes = pProvider->GetQuotes();
+ if(rQuotes.GetSectionCount() > 0)
+ {
+ return rQuotes.GetSection(0);
+ }
+ }
+
+ return CQuotesProviderGoogle::CQuoteSection();
+ }
+
+ inline tstring make_quote_name(const CQuotesProviderGoogle::CQuote& rQuote)
+ {
+ const tstring& rsDesc = rQuote.GetName();
+ return((false == rsDesc.empty()) ? rsDesc : rQuote.GetSymbol());
+ }
+
+ inline void update_convert_button(HWND hDlg)
+ {
+ int nFrom = static_cast<int>(::SendMessage(::GetDlgItem(hDlg,IDC_COMBO_CONVERT_FROM),CB_GETCURSEL,0,0));
+ int nTo = static_cast<int>(::SendMessage(::GetDlgItem(hDlg,IDC_COMBO_CONVERT_INTO),CB_GETCURSEL,0,0));
+ bool bEnableButton = ((CB_ERR != nFrom)
+ && (CB_ERR != nTo)
+ && (nFrom != nTo)
+ && (GetWindowTextLength(GetDlgItem(hDlg,IDC_EDIT_VALUE)) > 0));
+ EnableWindow(GetDlgItem(hDlg,IDC_BUTTON_CONVERT),bEnableButton);
+ }
+
+ inline void update_swap_button(HWND hDlg)
+ {
+ int nFrom = static_cast<int>(::SendMessage(::GetDlgItem(hDlg,IDC_COMBO_CONVERT_FROM),CB_GETCURSEL,0,0));
+ int nTo = static_cast<int>(::SendMessage(::GetDlgItem(hDlg,IDC_COMBO_CONVERT_INTO),CB_GETCURSEL,0,0));
+ bool bEnableButton = ((CB_ERR != nFrom)
+ && (CB_ERR != nTo)
+ && (nFrom != nTo));
+ EnableWindow(GetDlgItem(hDlg,IDC_BUTTON_SWAP),bEnableButton);
+ }
+
+ inline tstring double2str(double dValue)
+ {
+ tostringstream output;
+ output.imbue(GetSystemLocale());
+ output << std::fixed << std::setprecision(2) << dValue;
+ return output.str();
+ }
+
+ inline bool str2double(const tstring& s,double& d)
+ {
+ tistringstream input(s);
+ input.imbue(GetSystemLocale());
+ input >> d;
+ return ((false == input.bad()) && (false == input.fail()));
+ }
+
+
+ INT_PTR CALLBACK CurrencyConverterDlgProc(HWND hDlg,UINT msg,WPARAM wp,LPARAM lp)
+ {
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX,false);
+ assert(hWL);
+ WindowList_Add(hWL,hDlg,NULL);
+
+ TranslateDialogDefault(hDlg);
+
+ ::SendMessage(hDlg,WM_SETICON,FALSE,reinterpret_cast<LPARAM>(Quotes_LoadIconEx(ICON_STR_CURRENCY_CONVERTER)));
+ ::SendMessage(hDlg,WM_SETICON,TRUE,reinterpret_cast<LPARAM>(Quotes_LoadIconEx(ICON_STR_CURRENCY_CONVERTER,true)));
+
+ HWND hcbxFrom = ::GetDlgItem(hDlg,IDC_COMBO_CONVERT_FROM);
+ HWND hcbxTo = ::GetDlgItem(hDlg,IDC_COMBO_CONVERT_INTO);
+
+ tstring sFromQuoteID = Quotes_DBGetStringT(NULL,QUOTES_MODULE_NAME,DB_STR_CC_QUOTE_FROM_ID);
+ tstring sToQuoteID = Quotes_DBGetStringT(NULL,QUOTES_MODULE_NAME,DB_STR_CC_QUOTE_TO_ID);
+
+ const CQuotesProviderGoogle* pProvider = get_google_provider();
+ const CQuotesProviderGoogle::CQuoteSection& rSection = get_quotes(pProvider);
+ size_t cQuotes = rSection.GetQuoteCount();
+ for(size_t i = 0;i < cQuotes;++i)
+ {
+ const CQuotesProviderGoogle::CQuote& rQuote = rSection.GetQuote(i);
+ tstring sName = make_quote_name(rQuote);
+ LPCTSTR pszName = sName.c_str();
+ LRESULT nFrom = ::SendMessage(hcbxFrom,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(pszName));
+ LRESULT nTo = ::SendMessage(hcbxTo,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(pszName));
+
+ if(0 == quotes_stricmp(rQuote.GetID().c_str(),sFromQuoteID.c_str()))
+ {
+ ::SendMessage(hcbxFrom,CB_SETCURSEL,nFrom,0);
+ }
+
+ if(0 == quotes_stricmp(rQuote.GetID().c_str(),sToQuoteID.c_str()))
+ {
+ ::SendMessage(hcbxTo,CB_SETCURSEL,nTo,0);
+ }
+ }
+
+ double dAmount = 1.0;
+ Quotes_DBReadDouble(NULL,QUOTES_MODULE_NAME,DB_STR_CC_AMOUNT,dAmount);
+ ::SetDlgItemText(hDlg,IDC_EDIT_VALUE,double2str(dAmount).c_str());
+
+ const IQuotesProvider::CProviderInfo& pi = pProvider->GetInfo();
+ tostringstream o;
+ o << TranslateT("Info provided by") << _T(" <a href=\"") << pi.m_sURL << _T("\">") << pi.m_sName << _T("</a>");
+
+ ::SetDlgItemText(hDlg,IDC_SYSLINK_PROVIDER,o.str().c_str());
+
+ ::SendMessage(::GetDlgItem(hDlg,IDC_BUTTON_SWAP),BM_SETIMAGE,IMAGE_ICON,
+ reinterpret_cast<LPARAM>(Quotes_LoadIconEx(ICON_STR_SWAP)));
+
+ update_convert_button(hDlg);
+ update_swap_button(hDlg);
+
+ Utils_RestoreWindowPositionNoSize(hDlg,NULL,QUOTES_PROTOCOL_NAME,WINDOW_PREFIX);
+ ::ShowWindow(hDlg,SW_SHOW);
+ }
+ return (TRUE);
+ case WM_CLOSE:
+ {
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX,false);
+ assert(hWL);
+ WindowList_Remove(hWL,hDlg);
+ Utils_SaveWindowPosition(hDlg,NULL,QUOTES_PROTOCOL_NAME,WINDOW_PREFIX);
+ EndDialog(hDlg,0);
+ }
+ return (TRUE);
+ case WM_COMMAND:
+ switch(LOWORD(wp))
+ {
+ case IDC_COMBO_CONVERT_FROM:
+ case IDC_COMBO_CONVERT_INTO:
+ if(CBN_SELCHANGE == HIWORD(wp))
+ {
+ update_convert_button(hDlg);
+ update_swap_button(hDlg);
+ }
+ return TRUE;
+ case IDC_EDIT_VALUE:
+ if(EN_CHANGE == HIWORD(wp))
+ {
+ update_convert_button(hDlg);
+ }
+ return TRUE;
+ case IDCANCEL:
+ {
+ SendMessage(hDlg, WM_CLOSE, 0, 0);
+ }
+ return (TRUE);
+ case IDC_BUTTON_SWAP:
+ {
+ HWND wndFrom = ::GetDlgItem(hDlg,IDC_COMBO_CONVERT_FROM);
+ HWND wndTo = ::GetDlgItem(hDlg,IDC_COMBO_CONVERT_INTO);
+ WPARAM nFrom = ::SendMessage(wndFrom,CB_GETCURSEL,0,0);
+ WPARAM nTo = ::SendMessage(wndTo,CB_GETCURSEL,0,0);
+
+ ::SendMessage(wndFrom,CB_SETCURSEL,nTo,0);
+ ::SendMessage(wndTo,CB_SETCURSEL,nFrom,0);
+ }
+ return (TRUE);
+ case IDC_BUTTON_CONVERT:
+ {
+ HWND hwndAmount = GetDlgItem(hDlg,IDC_EDIT_VALUE);
+ tstring sText = get_window_text(hwndAmount);
+
+ double dAmount = 1.0;
+ if ((true == str2double(sText,dAmount)) && (dAmount > 0.0))
+ {
+ Quotes_DBWriteDouble(NULL,QUOTES_MODULE_NAME,DB_STR_CC_AMOUNT,dAmount);
+
+ size_t nFrom = static_cast<size_t>(::SendMessage(::GetDlgItem(hDlg,IDC_COMBO_CONVERT_FROM),CB_GETCURSEL,0,0));
+ size_t nTo = static_cast<size_t>(::SendMessage(::GetDlgItem(hDlg,IDC_COMBO_CONVERT_INTO),CB_GETCURSEL,0,0));
+ if ((CB_ERR != nFrom) && (CB_ERR != nTo) && (nFrom != nTo))
+ {
+ const CQuotesProviderGoogle::CQuoteSection& rSection = get_quotes();
+ size_t cQuotes = rSection.GetQuoteCount();
+ if ((nFrom < cQuotes) && (nTo < cQuotes))
+ {
+ CQuotesProviderGoogle::CRateInfo ri;
+ CQuotesProviderGoogle::CQuote from = rSection.GetQuote(nFrom);
+ CQuotesProviderGoogle::CQuote to = rSection.GetQuote(nTo);
+
+ DBWriteContactSettingTString(NULL,QUOTES_MODULE_NAME,DB_STR_CC_QUOTE_FROM_ID,from.GetID().c_str());
+ DBWriteContactSettingTString(NULL,QUOTES_MODULE_NAME,DB_STR_CC_QUOTE_TO_ID,to.GetID().c_str());
+
+ const CQuotesProviderGoogle* pProvider = get_google_provider();
+ assert(pProvider);
+ if(pProvider)
+ {
+ tstring sResult;
+ std::string sError;
+ try
+ {
+ double dResult = pProvider->Convert(dAmount,from,to);
+ tostringstream ss;
+ ss.imbue(GetSystemLocale());
+ ss << std::fixed << std::setprecision(2) << dAmount << " " << from.GetName() << " = " << dResult << " " << to.GetName();
+ sResult = ss.str();
+ }
+ catch(std::exception& e)
+ {
+ sError = e.what();
+ //Quotes_MessageBox(hDlg,sResult.c_str());
+ }
+
+ if(false == sError.empty())
+ {
+ //USES_CONVERSION;
+ sResult = quotes_a2t(sError.c_str());//A2T(sError.c_str());
+ }
+
+ SetDlgItemText(hDlg,IDC_EDIT_RESULT,sResult.c_str());
+ }
+ }
+ }
+ }
+ else
+ {
+ Quotes_MessageBox(hDlg,TranslateT("Enter positive number."),MB_OK|MB_ICONERROR);
+ prepare_edit_ctrl_for_error(GetDlgItem(hDlg,IDC_EDIT_VALUE));
+ }
+ }
+ return (TRUE);
+ }
+ return (FALSE);
+ case WM_NOTIFY:
+ {
+ LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lp);
+ switch(pNMHDR->code)
+ {
+ case NM_CLICK:
+ if(IDC_SYSLINK_PROVIDER == wp)
+ {
+ PNMLINK pNMLink = reinterpret_cast<PNMLINK>(pNMHDR);
+ ::ShellExecute(hDlg,_T("open"),pNMLink->item.szUrl,NULL,NULL,SW_SHOWNORMAL);
+ }
+ break;
+ }
+ }
+ break;
+ }
+ return (FALSE);
+ }
+}
+
+INT_PTR QuotesMenu_CurrencyConverter(WPARAM wp,LPARAM lp)
+{
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX,true);
+ HWND hWnd = WindowList_Find(hWL,NULL);
+ if(NULL != hWnd)
+ {
+ SetForegroundWindow(hWnd);
+ SetFocus(hWnd);
+ }
+ else
+ {
+ CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_CURRENCY_CONVERTER), NULL, CurrencyConverterDlgProc, 0);
+ }
+
+ return 0;
+}
diff --git a/plugins/Quotes/src/CurrencyConverter.h b/plugins/Quotes/src/CurrencyConverter.h new file mode 100644 index 0000000000..9af7c6bca1 --- /dev/null +++ b/plugins/Quotes/src/CurrencyConverter.h @@ -0,0 +1,6 @@ +#ifndef __4FB6320B_2D02_408b_BAF5_426C185AAA11_CurrencyConverter_h__
+#define __4FB6320B_2D02_408b_BAF5_426C185AAA11_CurrencyConverter_h__
+
+INT_PTR QuotesMenu_CurrencyConverter(WPARAM wp,LPARAM lp);
+
+#endif //__4FB6320B_2D02_408b_BAF5_426C185AAA11_CurrencyConverter_h__
diff --git a/plugins/Quotes/src/DBUtils.cpp b/plugins/Quotes/src/DBUtils.cpp new file mode 100644 index 0000000000..11c0fb3d0d --- /dev/null +++ b/plugins/Quotes/src/DBUtils.cpp @@ -0,0 +1,70 @@ +#include "StdAfx.h"
+#include "DBUtils.h"
+
+std::string Quotes_DBGetStringA(HANDLE hContact,const char* szModule,const char* szSetting,const char* pszDefValue /*= NULL*/)
+{
+ std::string sResult;
+ char* pszSymbol = DBGetString(hContact,szModule,szSetting);
+ if(NULL != pszSymbol)
+ {
+ sResult = pszSymbol;
+ mir_free(pszSymbol);
+ }
+ else if(NULL != pszDefValue)
+ {
+ sResult = pszDefValue;
+ }
+
+ return sResult;
+}
+
+std::wstring Quotes_DBGetStringW(HANDLE hContact,const char* szModule,const char* szSetting,const wchar_t* pszDefValue/* = NULL*/)
+{
+ std::wstring sResult;
+ wchar_t* pszSymbol = DBGetStringW(hContact,szModule,szSetting);
+ if(NULL != pszSymbol)
+ {
+ sResult = pszSymbol;
+ mir_free(pszSymbol);
+ }
+ else if(NULL != pszDefValue)
+ {
+ sResult = pszDefValue;
+ }
+
+ return sResult;
+}
+
+bool Quotes_DBWriteDouble(HANDLE hContact,const char* szModule,const char* szSetting,double dValue)
+{
+ DBCONTACTWRITESETTING cws = {0};
+
+ cws.szModule = szModule;
+ cws.szSetting = szSetting;
+ cws.value.type = DBVT_BLOB;
+ cws.value.cpbVal = sizeof(dValue);
+ cws.value.pbVal = reinterpret_cast<BYTE*>(&dValue);
+ return 0 == CallService(MS_DB_CONTACT_WRITESETTING,reinterpret_cast<WPARAM>(hContact),reinterpret_cast<LPARAM>(&cws));
+}
+
+bool Quotes_DBReadDouble(HANDLE hContact,const char* szModule,const char* szSetting,double& rdValue)
+{
+ DBVARIANT dbv = {0};
+ DBCONTACTGETSETTING cgs;
+ cgs.szModule=szModule;
+ cgs.szSetting=szSetting;
+ cgs.pValue = &dbv;
+ dbv.type = DBVT_BLOB;
+
+ bool bResult = ((0 == CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs))
+ && (DBVT_BLOB == dbv.type));
+
+ if(bResult)
+ {
+ rdValue = *reinterpret_cast<double*>(dbv.pbVal);
+ }
+
+ DBFreeVariant(&dbv);
+ return bResult;
+}
+
diff --git a/plugins/Quotes/src/DBUtils.h b/plugins/Quotes/src/DBUtils.h new file mode 100644 index 0000000000..27e3de5038 --- /dev/null +++ b/plugins/Quotes/src/DBUtils.h @@ -0,0 +1,13 @@ +#ifndef __54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__
+#define __54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__
+
+std::string Quotes_DBGetStringA(HANDLE hContact,const char* szModule,const char* szSetting,const char* pszDefValue = NULL);
+std::wstring Quotes_DBGetStringW(HANDLE hContact,const char* szModule,const char* szSetting,const wchar_t* pszDefValue = NULL);
+
+
+#define Quotes_DBGetStringT Quotes_DBGetStringW
+
+bool Quotes_DBWriteDouble(HANDLE hContact,const char* szModule,const char* szSetting,double dValue);
+bool Quotes_DBReadDouble(HANDLE hContact,const char* szModule,const char* szSetting,double& rdValue);
+
+#endif //__54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__
diff --git a/plugins/Quotes/src/EconomicRateInfo.h b/plugins/Quotes/src/EconomicRateInfo.h new file mode 100644 index 0000000000..73e269619c --- /dev/null +++ b/plugins/Quotes/src/EconomicRateInfo.h @@ -0,0 +1,59 @@ +#ifndef __87d726e0_26c6_485d_8016_1fba819b037d_EconomicRateInfo__
+#define __87d726e0_26c6_485d_8016_1fba819b037d_EconomicRateInfo__
+
+#define QUOTES_PROTOCOL_NAME "Quotes"// protocol name
+
+#define QUOTES_MODULE_NAME QUOTES_PROTOCOL_NAME // db settings module path
+
+enum ERefreshRateType
+{
+ RRT_SECONDS = 0,
+ RRT_MINUTES = 1,
+ RRT_HOURS = 2
+};
+
+#define DB_STR_ENABLE_LOG "EnableLog"
+#define DB_STR_QUOTE_PROVIDER "QuoteProvider"
+#define DB_STR_QUOTE_ID "QuoteID"
+#define DB_STR_QUOTE_SYMBOL "QuoteSymbol"
+#define DB_STR_QUOTE_DESCRIPTION "QuoteDescription"
+#define DB_STR_QUOTE_PREV_VALUE "PreviousQuoteValue"
+#define DB_STR_QUOTE_CURR_VALUE "CurrentQuoteValue"
+#define DB_STR_QUOTE_FETCH_TIME "FetchTime"
+
+
+enum ELogMode
+{
+ lmDisabled = 0x0000,
+ lmInternalHistory = 0x0001,
+ lmExternalFile = 0x0002,
+ lmPopup = 0x0004,
+};
+
+#define DB_STR_CONTACT_SPEC_SETTINGS "ContactSpecSettings"
+#define DB_STR_QUOTE_LOG "Log"
+#define DB_STR_QUOTE_LOG_FILE "LogFile"
+#define DB_STR_QUOTE_FORMAT_LOG_FILE "LogFileFormat"
+#define DB_STR_QUOTE_FORMAT_HISTORY "HistoryFormat"
+#define DB_STR_QUOTE_LOG_FILE_CONDITION "AddToLogOnlyIfValueIsChanged"
+#define DB_STR_QUOTE_HISTORY_CONDITION "AddToHistoryOnlyIfValueIsChanged"
+#define DB_STR_QUOTE_EXTRA_IMAGE_SLOT "ExtraImageSlot"
+#define DB_STR_QUOTE_FORMAT_POPUP "PopupFormat"
+#define DB_STR_QUOTE_POPUP_CONDITION "ShowPopupOnlyIfValueIsChanged"
+
+#define DB_STR_QUOTE_POPUP_COLOUR_MODE "PopupColourMode"
+#define DB_STR_QUOTE_POPUP_COLOUR_BK "PopupColourBk"
+#define DB_STR_QUOTE_POPUP_COLOUR_TEXT "PopupColourText"
+#define DB_STR_QUOTE_POPUP_DELAY_MODE "PopupDelayMode"
+#define DB_STR_QUOTE_POPUP_DELAY_TIMEOUT "PopupDelayTimeout"
+#define DB_STR_QUOTE_POPUP_HISTORY_FLAG "PopupHistoryFlag"
+
+
+// #define DB_STR_NICK "Nick"
+#define DB_STR_STATUS "Status"
+
+#define LIST_MODULE_NAME "CList"
+#define CONTACT_LIST_NAME "MyHandle"
+#define STATUS_MSG_NAME "StatusMsg"
+
+#endif //__87d726e0_26c6_485d_8016_1fba819b037d_EconomicRateInfo__
diff --git a/plugins/Quotes/src/ExtraImages.cpp b/plugins/Quotes/src/ExtraImages.cpp new file mode 100644 index 0000000000..a89032e53c --- /dev/null +++ b/plugins/Quotes/src/ExtraImages.cpp @@ -0,0 +1,67 @@ +#include "StdAfx.h"
+#include "ExtraImages.h"
+#include "IconLib.h"
+#include "EconomicRateInfo.h"
+#include "ModuleInfo.h"
+#include "QuotesProviders.h"
+#include "IQuotesProvider.h"
+#include "Log.h"
+#include "DBUtils.h"
+#include "resource.h"
+
+CExtraImages::CExtraImages() :
+ m_hExtraIcons(ExtraIcon_Register(ICON_STR_QUOTE,QUOTES_PROTOCOL_NAME,Quotes_MakeIconName(ICON_STR_MAIN).c_str())),
+ m_bExtraImagesInit(false)
+{
+ m_ahExtraImages[eiUp] = INVALID_HANDLE_VALUE;
+ m_ahExtraImages[eiDown] = INVALID_HANDLE_VALUE;
+ m_ahExtraImages[eiNotChanged] = INVALID_HANDLE_VALUE;
+}
+
+CExtraImages::~CExtraImages()
+{
+}
+
+CExtraImages& CExtraImages::GetInstance()
+{
+ static CExtraImages s_ei;
+ return s_ei;
+}
+
+void CExtraImages::RebuildExtraImages()
+{
+}
+
+bool CExtraImages::SetContactExtraImage(HANDLE hContact,EImageIndex nIndex)const
+{
+ if (!m_hExtraIcons)
+ return false;
+
+ HANDLE hIcolib;
+ switch(nIndex) {
+ case eiUp:
+ hIcolib = Quotes_GetIconHandle(IDI_ICON_UP);
+ break;
+ case eiDown:
+ hIcolib = Quotes_GetIconHandle(IDI_ICON_DOWN);
+ break;
+ case eiNotChanged:
+ hIcolib = Quotes_GetIconHandle(IDI_ICON_NOTCHANGED);
+ break;
+ default:
+ hIcolib = NULL;
+ }
+ return ExtraIcon_SetIcon(m_hExtraIcons, hContact, hIcolib) == 0;
+}
+
+int QuotesEventFunc_onExtraImageApply(WPARAM wp,LPARAM lp)
+{
+ HANDLE hContact = reinterpret_cast<HANDLE>(wp);
+
+ const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr();
+ CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact);
+ if(pProvider)
+ pProvider->SetContactExtraIcon(hContact);
+
+ return 0;
+}
diff --git a/plugins/Quotes/src/ExtraImages.h b/plugins/Quotes/src/ExtraImages.h new file mode 100644 index 0000000000..cd09600217 --- /dev/null +++ b/plugins/Quotes/src/ExtraImages.h @@ -0,0 +1,37 @@ +#ifndef __9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__
+#define __9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__
+
+#include "LightMutex.h"
+
+class CExtraImages : private boost::noncopyable
+{
+public:
+ enum EImageIndex
+ {
+ eiUp = 0,
+ eiDown = 1,
+ eiNotChanged = 2,
+ eiEmpty = 3,
+ ImageCount = 3
+ };
+
+private:
+ CExtraImages();
+ ~CExtraImages();
+
+public:
+ static CExtraImages& GetInstance();
+
+ void RebuildExtraImages();
+ bool SetContactExtraImage(HANDLE hContact,EImageIndex nIndex)const;
+
+private:
+ mutable CLightMutex m_lmExtraImages;
+ HANDLE m_ahExtraImages[ImageCount];
+ HANDLE m_hExtraIcons;
+ bool m_bExtraImagesInit;
+};
+
+int QuotesEventFunc_onExtraImageApply(WPARAM wp,LPARAM lp);
+
+#endif //__9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__
diff --git a/plugins/Quotes/src/Forex.cpp b/plugins/Quotes/src/Forex.cpp new file mode 100644 index 0000000000..6aa7d90dcf --- /dev/null +++ b/plugins/Quotes/src/Forex.cpp @@ -0,0 +1,469 @@ +// Forex.cpp : Defines the exported functions for the DLL application.
+//
+
+#include "stdafx.h"
+
+#pragma warning(disable:4996)
+#include <m_protocols.h>
+#include <m_protomod.h>
+#pragma warning(default:4996)
+#include "WorkingThread.h"
+#include <m_protosvc.h>
+#include "resource.h"
+#include "IconLib.h"
+#include <m_options.h>
+#include <m_userinfo.h>
+#include "QuoteInfoDlg.h"
+#include "ModuleInfo.h"
+#include "QuotesProviders.h"
+#include "IQuotesProvider.h"
+#include "EconomicRateInfo.h"
+#include "DBUtils.h"
+#include "ExtraImages.h"
+#include "HTTPSession.h"
+#include "CurrencyConverter.h"
+#ifdef CHART_IMPLEMENT
+#include "QuoteChart.h"
+#endif
+#include "WinCtrlHelper.h"
+#include "ImportExport.h"
+#include "m_Quotes.h"
+#include "version.h"
+
+int hLangpack;
+HINSTANCE g_hInstance = NULL;
+HANDLE g_hEventWorkThreadStop;
+int g_nStatus = ID_STATUS_OFFLINE;
+HGENMENU g_hMenuEditSettings = NULL;
+HGENMENU g_hMenuOpenLogFile = NULL;
+#ifdef CHART_IMPLEMENT
+HGENMENU g_hMenuChart = NULL;
+#endif
+HGENMENU g_hMenuRefresh = NULL;
+
+namespace
+{
+ typedef std::vector<HANDLE> THandles;
+ THandles g_ahEvents;
+ THandles g_ahServices;
+ THandles g_ahThreads;
+ std::vector<HGENMENU> g_ahMenus;
+
+ PLUGININFOEX Global_pluginInfo =
+ {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {E882056D-0D1D-4131-9A98-404CBAEA6A9C}
+ {0xe882056d, 0xd1d, 0x4131, { 0x9a, 0x98, 0x40, 0x4c, 0xba, 0xea, 0x6a, 0x9c } }
+ };
+
+ INT_PTR QuotesMenu_RefreshAll(WPARAM wp,LPARAM lp)
+ {
+ const CQuotesProviders::TQuotesProviders& apProviders = CModuleInfo::GetQuoteProvidersPtr()->GetProviders();
+ std::for_each(apProviders.begin(),apProviders.end(),boost::bind(&IQuotesProvider::RefreshAll,_1));
+ return 0;
+ }
+
+ void InitMenu()
+ {
+// USES_CONVERSION;
+
+ CLISTMENUITEM mi = {0};
+ mi.cbSize = sizeof(CLISTMENUITEM);
+ //mi.ptszPopupName = _T("Quotes");
+ mi.ptszName = _T("Quotes");
+ mi.flags = CMIF_TCHAR|CMIF_ICONFROMICOLIB|CMIF_ROOTPOPUP;
+ mi.icolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN);
+ HGENMENU hMenuRoot = Menu_AddMainMenuItem(&mi);
+ g_ahMenus.push_back(hMenuRoot);
+
+ mi.ptszName = _T("Refresh All Quotes\\Rates");
+ mi.flags = CMIF_TCHAR|CMIF_ICONFROMICOLIB|CMIF_ROOTHANDLE;
+ //mi.position = 0x0FFFFFFF;
+ mi.icolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN);
+ mi.pszService = "Quotes/RefreshAll";
+ mi.hParentMenu = hMenuRoot;
+ HGENMENU hMenu = Menu_AddMainMenuItem(&mi);
+ g_ahMenus.push_back(hMenu);
+ HANDLE h = CreateServiceFunction(mi.pszService, QuotesMenu_RefreshAll);
+ g_ahServices.push_back(h);
+
+ mi.ptszName = _T("Currency Converter...");
+ //mi.flags = CMIF_TCHAR|CMIF_ICONFROMICOLIB|CMIF_ROOTHANDLE;
+ //mi.position = 0x0FFFFFFF;
+ mi.icolibItem = Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER);
+ mi.pszService = "Quotes/CurrencyConverter";
+ hMenu = Menu_AddMainMenuItem(&mi);
+ g_ahMenus.push_back(hMenu);
+ h = CreateServiceFunction(mi.pszService, QuotesMenu_CurrencyConverter);
+ g_ahServices.push_back(h);
+
+#ifdef TEST_IMPORT_EXPORT
+ mi.ptszName = _T("Export All Quotes");
+ //mi.flags = CMIF_TCHAR|CMIF_ICONFROMICOLIB|CMIF_ROOTHANDLE;
+ mi.icolibItem = Quotes_GetIconHandle(IDI_ICON_EXPORT);
+ mi.pszService = "Quotes/ExportAll";
+ hMenu = Menu_AddMainMenuItem(&mi);
+ g_ahMenus.push_back(hMenu);
+ h = CreateServiceFunction(mi.pszService, QuotesMenu_ExportAll);
+ g_ahServices.push_back(h);
+
+ mi.ptszName =_T("Import All Quotes");
+ //mi.flags = CMIF_TCHAR|CMIF_ICONFROMICOLIB|CMIF_ROOTHANDLE;
+ mi.icolibItem = Quotes_GetIconHandle(IDI_ICON_IMPORT);
+ mi.pszService = "Quotes/ImportAll";
+ hMenu = Menu_AddMainMenuItem(&mi);
+ g_ahMenus.push_back(hMenu);
+ h = CreateServiceFunction(mi.pszService, QuotesMenu_ImportAll);
+ g_ahServices.push_back(h);
+#endif
+
+ bool bSubGroups = 1 == ServiceExists(MS_CLIST_MENUBUILDSUBGROUP);
+
+ h = HookEvent(ME_CLIST_PREBUILDCONTACTMENU,Quotes_PrebuildContactMenu);
+ g_ahEvents.push_back(h);
+
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.pszContactOwner = QUOTES_PROTOCOL_NAME;
+ hMenuRoot = NULL;
+ if(bSubGroups)
+ {
+ mi.pszPopupName=(char *)-1;
+ mi.icolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN);
+ mi.flags = CMIF_ICONFROMICOLIB|CMIF_TCHAR|CMIF_ROOTPOPUP;
+ tstring sProtocolName = quotes_a2t(QUOTES_PROTOCOL_NAME);
+ mi.ptszName = const_cast<TCHAR*>(sProtocolName.c_str());//A2T(QUOTES_PROTOCOL_NAME);
+ mi.position = 0;
+
+ hMenuRoot = Menu_AddContactMenuItem(&mi);
+ }
+
+ mi.flags = CMIF_TCHAR;
+ if(bSubGroups)
+ {
+ mi.flags |= CMIF_CHILDPOPUP;
+ mi.pszPopupName = (char*)hMenuRoot;
+ }
+
+ mi.ptszName = _T("Refresh");
+ mi.popupPosition = 0;
+ mi.flags |= CMIF_ICONFROMICOLIB;
+ mi.icolibItem = Quotes_GetIconHandle(IDI_ICON_REFRESH);
+ mi.pszService = "Quotes/RefreshContact";
+ hMenu = Menu_AddContactMenuItem(&mi);
+ g_hMenuRefresh = hMenu;
+ g_ahMenus.push_back(hMenu);
+ h = CreateServiceFunction(mi.pszService, QuotesMenu_RefreshContact);
+ g_ahServices.push_back(h);
+
+ mi.ptszName = _T("Open Log File...");
+ mi.popupPosition = 1;
+ mi.icolibItem = NULL;
+ mi.pszService = "Quotes/OpenLogFile";
+ hMenu = Menu_AddContactMenuItem(&mi);
+ g_hMenuOpenLogFile = hMenu;
+ g_ahMenus.push_back(hMenu);
+ h = CreateServiceFunction(mi.pszService, QuotesMenu_OpenLogFile);
+ g_ahServices.push_back(h);
+
+#ifdef CHART_IMPLEMENT
+ mi.ptszName = _T("Chart...");
+ mi.popupPosition = 2;
+ mi.icolibItem = NULL;
+ mi.pszService = "Quotes/Chart";
+ hMenu = Menu_AddContactMenuItem(&mi);
+ g_hMenuChart = hMenu;
+ g_ahMenus.push_back(hMenu);
+ h = CreateServiceFunction(mi.pszService, QuotesMenu_Chart);
+ g_ahServices.push_back(h);
+#endif
+
+ mi.ptszName = _T("Edit Settings...");
+#ifdef CHART_IMPLEMENT
+ mi.popupPosition = 3;
+#else
+ mi.popupPosition = 2;
+#endif
+ mi.icolibItem = NULL;
+ mi.pszService = "Quotes/EditSettings";
+ hMenu = Menu_AddContactMenuItem(&mi);
+ g_hMenuEditSettings = hMenu;
+ g_ahMenus.push_back(hMenu);
+ h = CreateServiceFunction(mi.pszService, QuotesMenu_EditSettings);
+ g_ahServices.push_back(h);
+ }
+
+
+ int QuotesEventFunc_OnModulesLoaded(WPARAM, LPARAM)
+ {
+ CHTTPSession::Init();
+
+ HANDLE h = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY,QuotesEventFunc_onExtraImageApply);
+ g_ahEvents.push_back(h);
+
+ g_hEventWorkThreadStop = ::CreateEvent(NULL,TRUE,FALSE,NULL);
+ h = (ME_USERINFO_INITIALISE,QuotesEventFunc_OnUserInfoInit);
+ g_ahEvents.push_back(h);
+
+ h = HookEvent(ME_CLIST_DOUBLECLICKED,Quotes_OnContactDoubleClick);
+ g_ahEvents.push_back(h);
+
+ InitMenu();
+
+ return 0;
+ }
+
+ int QuotesEventFunc_OnContactDeleted(WPARAM wParam, LPARAM)
+ {
+ HANDLE hContact = reinterpret_cast<HANDLE>(wParam);
+
+ const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr();
+ CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact);
+ if(pProvider)
+ {
+ pProvider->DeleteContact(hContact);
+ }
+
+ return 0;
+ }
+
+ INT_PTR QuoteProtoFunc_GetStatus(WPARAM/* wp*/,LPARAM/* lp*/)
+ {
+ return g_nStatus;
+ }
+
+ void WaitForWorkingThreads()
+ {
+ size_t cThreads = g_ahThreads.size();
+ if(cThreads > 0)
+ {
+ HANDLE* paHandles = &*(g_ahThreads.begin());
+ ::WaitForMultipleObjects((DWORD)cThreads,paHandles,TRUE,INFINITE);
+ }
+ }
+
+ INT_PTR QuoteProtoFunc_SetStatus(WPARAM wp,LPARAM /*lp*/)
+ {
+ int nStatus = wp;
+ if ((ID_STATUS_ONLINE == nStatus) || (ID_STATUS_OFFLINE == nStatus))
+ {
+ int nOldStatus = g_nStatus;
+ if(nStatus != g_nStatus)
+ {
+ g_nStatus = nStatus;
+ if ((ID_STATUS_ONLINE == nOldStatus) && (ID_STATUS_OFFLINE == g_nStatus))
+ {
+ BOOL b = ::SetEvent(g_hEventWorkThreadStop);
+ assert(b);
+ }
+ else if ((ID_STATUS_ONLINE == g_nStatus) && (ID_STATUS_OFFLINE == nOldStatus))
+ {
+ BOOL b = ::ResetEvent(g_hEventWorkThreadStop);
+ assert(b && "Failed to reset event");
+
+ const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr();
+ const CQuotesProviders::TQuotesProviders& rapProviders = pProviders->GetProviders();
+ for(CQuotesProviders::TQuotesProviders::const_iterator i = rapProviders.begin();i != rapProviders.end();++i)
+ {
+ const CQuotesProviders::TQuotesProviderPtr& pProvider = *i;
+ HANDLE hThread = reinterpret_cast<HANDLE>(mir_forkthread(WorkingThread,pProvider.get()));
+ g_ahThreads.push_back(hThread);
+ }
+ }
+
+ ProtoBroadcastAck(QUOTES_PROTOCOL_NAME,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,reinterpret_cast<HANDLE>(nOldStatus),g_nStatus);
+ }
+
+ }
+
+ return 0;
+ }
+
+ int QuotesEventFunc_PreShutdown(WPARAM wParam, LPARAM lParam)
+ {
+ QuoteProtoFunc_SetStatus(ID_STATUS_OFFLINE,0);
+ //WindowList_Broadcast(g_hWindowListEditSettings,WM_CLOSE,0,0);
+ CModuleInfo::GetInstance().OnMirandaShutdown();
+ return 0;
+ }
+
+ INT_PTR QuoteProtoFunc_GetName(WPARAM wParam, LPARAM lParam)
+ {
+ if(lParam)
+ {
+ lstrcpynA(reinterpret_cast<char*>(lParam),QUOTES_PROTOCOL_NAME,wParam);
+ return 0;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+
+ INT_PTR QuoteProtoFunc_GetCaps(WPARAM wp,LPARAM lp)
+ {
+ int ret = 0;
+ switch(wp)
+ {
+ case PFLAGNUM_1:
+ ret = PF1_PEER2PEER;
+ break;
+ case PFLAGNUM_3:
+ case PFLAGNUM_2:
+ ret = PF2_ONLINE|PF2_LONGAWAY;
+ if(CModuleInfo::GetInstance().GetExtendedStatusFlag())
+ {
+ ret |= PF2_LIGHTDND;
+ }
+ break;
+ }
+
+ return ret;
+ }
+
+ INT_PTR QuoteProtoFunc_LoadIcon(WPARAM wp,LPARAM /*lp*/)
+ {
+ if ((wp & 0xffff) == PLI_PROTOCOL)
+ {
+ return reinterpret_cast<int>(::CopyIcon(Quotes_LoadIconEx(ICON_STR_MAIN)));
+ }
+
+ return 0;
+ }
+
+ int QuotesEventFunc_OptInitialise(WPARAM wp,LPARAM/* lp*/)
+ {
+ const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr();
+ const CQuotesProviders::TQuotesProviders& rapProviders = pProviders->GetProviders();
+
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.cbSize = sizeof(odp);
+ odp.position = 910000000;
+ odp.hInstance = g_hInstance;
+ odp.ptszTitle = _T(QUOTES_PROTOCOL_NAME);
+ odp.ptszGroup = LPGENT("Network");
+ odp.hIcon = Quotes_LoadIconEx(ICON_STR_MAIN);
+ odp.flags = ODPF_USERINFOTAB | ODPF_TCHAR;
+
+ std::for_each(rapProviders.begin(),rapProviders.end(),boost::bind(&IQuotesProvider::ShowPropertyPage,_1,wp,boost::ref(odp)));
+ return 0;
+ }
+
+ inline int Quotes_DestroyServiceFunction(HANDLE h)
+ {
+ return DestroyServiceFunction(h);
+ }
+
+ inline int Quotes_UnhookEvent(HANDLE h)
+ {
+ return UnhookEvent(h);
+ }
+
+ inline int Quotes_RemoveMenuItem(HGENMENU h)
+ {
+ return CallService(MS_CLIST_REMOVECONTACTMENUITEM,reinterpret_cast<WPARAM>(h),0);
+ }
+
+// PROTO_INTERFACE* protoInit(const char* pszProtoName, const TCHAR* tszUserName)
+// {
+// CAimProto *ppro = new CAimProto(pszProtoName, tszUserName);
+// g_Instances.insert(ppro);
+// return ppro;
+// }
+//
+// int protoUninit(PROTO_INTERFACE* ppro)
+// {
+// g_Instances.remove((CAimProto*)ppro);
+// return 0;
+// }
+
+}
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+{
+ g_hInstance = hinstDLL;
+ return TRUE;
+}
+
+extern "C"
+{
+ __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+ {
+ return &Global_pluginInfo;
+ }
+
+
+ #define MIID_QUOTES {0x723243c2, 0x8d4b, 0x4c29, { 0x8a, 0x37, 0xc0, 0x11, 0x48, 0x65, 0xb0, 0x80}}
+
+ __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL,MIID_QUOTES,MIID_LAST};
+
+ int __declspec(dllexport) Load(void)
+ {
+
+ mir_getLP(&Global_pluginInfo);
+// if ((mirandaVersion >= 0x0800) && (1 == mir_getXI(&xi)))
+// {
+// CModuleInfo::SetXMLEnginePtr(CModuleInfo::TXMLEnginePtr(new CXMLEngineMI));
+// }
+
+ if(false == CModuleInfo::Verify())
+ {
+ return 1;
+ }
+
+ Quotes_IconsInit();
+
+ PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
+ pd.szName = QUOTES_PROTOCOL_NAME;
+ pd.type = PROTOTYPE_VIRTUAL;
+ CallService( MS_PROTO_REGISTERMODULE, 0, ( LPARAM )&pd );
+
+ HANDLE h = CreateProtoServiceFunction(QUOTES_PROTOCOL_NAME, PS_GETNAME, QuoteProtoFunc_GetName);
+ g_ahServices.push_back(h);
+ h = CreateProtoServiceFunction(QUOTES_PROTOCOL_NAME, PS_GETCAPS, QuoteProtoFunc_GetCaps);
+ g_ahServices.push_back(h);
+ h = CreateProtoServiceFunction(QUOTES_PROTOCOL_NAME, PS_SETSTATUS, QuoteProtoFunc_SetStatus);
+ g_ahServices.push_back(h);
+ h = CreateProtoServiceFunction(QUOTES_PROTOCOL_NAME, PS_GETSTATUS, QuoteProtoFunc_GetStatus);
+ g_ahServices.push_back(h);
+ h = CreateProtoServiceFunction(QUOTES_PROTOCOL_NAME, PS_LOADICON, QuoteProtoFunc_LoadIcon);
+ g_ahServices.push_back(h);
+
+ h = HookEvent(ME_SYSTEM_MODULESLOADED,QuotesEventFunc_OnModulesLoaded);
+ g_ahEvents.push_back(h);
+ h = HookEvent(ME_DB_CONTACT_DELETED,QuotesEventFunc_OnContactDeleted);
+ g_ahEvents.push_back(h);
+ h = HookEvent(ME_SYSTEM_PRESHUTDOWN,QuotesEventFunc_PreShutdown);
+ g_ahEvents.push_back(h);
+ h = HookEvent(ME_OPT_INITIALISE,QuotesEventFunc_OptInitialise);
+ g_ahEvents.push_back(h);
+
+ h = CreateServiceFunction(MS_QUOTES_EXPORT, Quotes_Export);
+ g_ahServices.push_back(h);
+ h = CreateServiceFunction(MS_QUOTES_IMPORT, Quotes_Import);
+ g_ahServices.push_back(h);
+
+ return 0;
+ }
+
+ __declspec(dllexport) int Unload(void)
+ {
+ std::for_each(g_ahServices.begin(),g_ahServices.end(),boost::bind(Quotes_DestroyServiceFunction,_1));
+ std::for_each(g_ahEvents.begin(),g_ahEvents.end(),boost::bind(Quotes_UnhookEvent,_1));
+ std::for_each(g_ahMenus.begin(),g_ahMenus.end(),boost::bind(Quotes_RemoveMenuItem,_1));
+
+ WaitForWorkingThreads();
+
+ ::CloseHandle(g_hEventWorkThreadStop);
+
+ return 0;
+ }
+}
diff --git a/plugins/Quotes/src/HTMLParserMS.cpp b/plugins/Quotes/src/HTMLParserMS.cpp new file mode 100644 index 0000000000..bfe58b43b1 --- /dev/null +++ b/plugins/Quotes/src/HTMLParserMS.cpp @@ -0,0 +1,313 @@ +#include "StdAfx.h"
+#include "HTMLParserMS.h"
+
+using _com_util::CheckError;
+
+namespace
+{
+ class CHTMLNode : public IHTMLNode
+ {
+ public:
+ typedef CComPtr<IDispatch> TComPtr;
+ typedef CComPtr<IHTMLDocument3> TDocumentPtr;
+
+ protected:
+ typedef CComPtr<IHTMLElementCollection> TElementCollectionPtr;
+
+ public:
+ CHTMLNode(const TComPtr& pElement,const TDocumentPtr& pDocument)
+ : m_pElement(pElement),m_pDocument(pDocument){}
+
+ virtual THTMLNodePtr GetElementByID(const tstring& rsID)const
+ {
+ if(m_pDocument)
+ {
+ CComPtr<IHTMLElement> pElement;
+ if(SUCCEEDED(m_pDocument->getElementById(bstr_t(rsID.c_str()),&pElement))
+ && pElement)
+ {
+ TComPtr p(pElement);
+ return THTMLNodePtr(new CHTMLNode(p,m_pDocument));
+ }
+ }
+
+ return THTMLNodePtr();
+ }
+
+ virtual size_t GetChildCount()const
+ {
+ TElementCollectionPtr pColl = GetElementCollectionPtr();
+ if(pColl)
+ {
+ LONG celem = 0;
+ HRESULT hr = pColl->get_length(&celem);
+ if(S_OK == hr)
+ {
+ return celem;
+ }
+ }
+
+ return 0;
+ }
+
+ virtual THTMLNodePtr GetChildPtr(size_t nIndex)
+ {
+ TElementCollectionPtr pColl = GetElementCollectionPtr();
+ if(pColl)
+ {
+ VARIANT varIndex;
+ varIndex.vt = VT_UINT;
+ varIndex.lVal = (LONG)nIndex;
+ VARIANT var2;
+ VariantInit(&var2);
+ TComPtr pDisp;
+ HRESULT hr = pColl->item(varIndex,var2,&pDisp);
+ if(S_OK == hr && pDisp)
+ {
+ return THTMLNodePtr(new CHTMLNode(pDisp,m_pDocument));
+ }
+ }
+
+ return THTMLNodePtr();
+ }
+
+ virtual bool Is(EType nType)const
+ {
+ switch(nType)
+ {
+ case Table:
+ {
+ CComPtr<IHTMLTable> pTable;
+ return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTable,reinterpret_cast<void**>(&pTable))) && (pTable));
+ }
+ case TableRow:
+ {
+ CComPtr<IHTMLTableRow> pRow;
+ return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTableRow,reinterpret_cast<void**>(&pRow))) && (pRow));
+ }
+ case TableColumn:
+ {
+ CComPtr<IHTMLTableCol> pCol;
+ return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTableCol,reinterpret_cast<void**>(&pCol))) && (pCol));
+ }
+ }
+
+ return false;
+ }
+
+ virtual tstring GetAttribute(const tstring& rsAttrName)const
+ {
+ USES_CONVERSION;
+
+ tstring sAttr;
+ CComPtr<IHTMLElement> pElement;
+ if(SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement,reinterpret_cast<void**>(&pElement))) && pElement)
+ {
+ _variant_t vAttribute;
+ BSTR pbstrAttrName = T2BSTR(rsAttrName.c_str());
+ if(SUCCEEDED(pElement->getAttribute(pbstrAttrName,1,&vAttribute))
+ && VT_NULL != vAttribute.vt && VT_EMPTY != vAttribute.vt)
+ {
+ try
+ {
+ _bstr_t b(vAttribute);
+ LPCTSTR psz = b;
+ if(psz)
+ {
+ sAttr = psz;
+ }
+ }
+ catch(_com_error&)
+ {
+ }
+ }
+ }
+
+ return sAttr;
+ }
+
+ virtual tstring GetText()const
+ {
+// USES_CONVERSION;
+
+ tstring sText;
+ CComPtr<IHTMLElement> pElement;
+ if(SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement,reinterpret_cast<void**>(&pElement))) && pElement)
+ {
+ BSTR bstrText;
+ if(SUCCEEDED(pElement->get_innerText(&bstrText)) && bstrText)
+ {
+ try
+ {
+ sText = _bstr_t(bstrText);
+ }
+ catch(_com_error&)
+ {
+ }
+
+ ::SysFreeString(bstrText);
+ }
+ }
+
+ return sText;
+ }
+
+ protected:
+ virtual TElementCollectionPtr GetElementCollectionPtr()const
+ {
+ TElementCollectionPtr pColl;
+ HRESULT hr = m_pElement->QueryInterface(IID_IHTMLElementCollection,reinterpret_cast<void**>(&pColl));
+ if(FAILED(hr))
+ {
+ CComPtr<IHTMLElement> pElement;
+ if(SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement,reinterpret_cast<void**>(&pElement))) && pElement)
+ {
+ CComPtr<IDispatch> pDisp;
+ if(SUCCEEDED(pElement->get_children(&pDisp)) && pDisp)
+ {
+ hr = pDisp->QueryInterface(IID_IHTMLElementCollection,reinterpret_cast<void**>(&pColl));
+ }
+ }
+ }
+
+ return pColl;
+ }
+
+ private:
+ TComPtr m_pElement;
+ TDocumentPtr m_pDocument;
+ };
+}
+
+CHTMLParserMS::CHTMLParserMS() : m_bCallUninit(false)
+{
+ try
+ {
+ CheckError(::CoInitialize(NULL));
+
+ m_bCallUninit = true;
+
+ _com_util::CheckError(
+ ::CoCreateInstance(CLSID_HTMLDocument,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_IHTMLDocument2,
+ (LPVOID*)&m_pDoc)
+ );
+
+ CComPtr<IPersistStreamInit> pPersist;
+ _com_util::CheckError(m_pDoc->QueryInterface(IID_IPersistStreamInit,
+ (LPVOID*)&pPersist));
+
+ _com_util::CheckError(pPersist->InitNew());
+
+ _com_util::CheckError(m_pDoc->QueryInterface(IID_IMarkupServices,
+ (LPVOID*)&m_pMS));
+
+ if(m_pMS)
+ {
+ _com_util::CheckError(m_pMS->CreateMarkupPointer(&m_pMkStart));
+ _com_util::CheckError(m_pMS->CreateMarkupPointer(&m_pMkFinish));
+ }
+ }
+ catch(_com_error&/* e*/)
+ {
+// show_com_error_msg(e);
+ }
+
+}
+
+CHTMLParserMS::~CHTMLParserMS()
+{
+ if(true == m_bCallUninit)
+ {
+ ::CoUninitialize();
+ }
+}
+
+CHTMLParserMS::THTMLNodePtr CHTMLParserMS::ParseString(const tstring& rsHTML)
+{
+ USES_CONVERSION;
+
+ try
+ {
+ CGuard<CLightMutex> cs(m_cs);
+
+ OLECHAR* p = T2OLE(const_cast<LPTSTR>(rsHTML.c_str()));
+ CComPtr<IMarkupContainer> pMC;
+ _com_util::CheckError(m_pMS->ParseString(p,0,&pMC,m_pMkStart,m_pMkFinish));
+
+ if(pMC)
+ {
+ CComPtr<IHTMLDocument2> pNewDoc;
+
+ _com_util::CheckError(pMC->QueryInterface(IID_IHTMLDocument,
+ (LPVOID*)&pNewDoc));
+
+ if(pNewDoc)
+ {
+ CComPtr<IHTMLElementCollection> pColl;
+ _com_util::CheckError(pNewDoc->get_all(&pColl));
+
+ CHTMLNode::TDocumentPtr pDoc;
+ pMC->QueryInterface(IID_IHTMLDocument3,(LPVOID*)&pDoc);
+
+
+ return THTMLNodePtr(new CHTMLNode(CHTMLNode::TComPtr(pColl),pDoc));
+ }
+ }
+ }
+ catch(_com_error&/* e*/)
+ {
+// show_com_error_msg(e);
+ }
+
+ return THTMLNodePtr();
+}
+
+bool CHTMLParserMS::IsInstalled()
+{
+ bool bResult = true;
+ bool bCallUninit = false;
+ try
+ {
+ CheckError(::CoInitialize(NULL));
+
+ bCallUninit = true;
+
+ CComPtr<IHTMLDocument2> pDoc;
+ _com_util::CheckError(
+ ::CoCreateInstance(CLSID_HTMLDocument,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ IID_IHTMLDocument2,
+ reinterpret_cast<LPVOID*>(&pDoc))
+ );
+ }
+ catch(_com_error&/* e*/)
+ {
+ bResult = false;
+ }
+
+ if(bCallUninit)
+ {
+ ::CoUninitialize();
+ }
+
+ return bResult;
+}
+
+CHTMLEngineMS::CHTMLEngineMS()
+{
+
+}
+
+CHTMLEngineMS::~CHTMLEngineMS()
+{
+
+}
+
+CHTMLEngineMS::THTMLParserPtr CHTMLEngineMS::GetParserPtr()const
+{
+ return THTMLParserPtr(new CHTMLParserMS);
+}
diff --git a/plugins/Quotes/src/HTMLParserMS.h b/plugins/Quotes/src/HTMLParserMS.h new file mode 100644 index 0000000000..0773efa42a --- /dev/null +++ b/plugins/Quotes/src/HTMLParserMS.h @@ -0,0 +1,36 @@ +#ifndef __3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__
+#define __3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__
+
+#include "ihtmlparser.h"
+#include "LightMutex.h"
+#include "IHTMLEngine.h"
+
+class CHTMLParserMS : public IHTMLParser
+{
+public:
+ CHTMLParserMS();
+ ~CHTMLParserMS();
+
+ virtual THTMLNodePtr ParseString(const tstring& rsHTML);
+
+ static bool IsInstalled();
+
+private:
+ bool m_bCallUninit;
+ CComPtr<IHTMLDocument2> m_pDoc;
+ CComPtr<IMarkupServices> m_pMS;
+ CComPtr<IMarkupPointer> m_pMkStart;
+ CComPtr<IMarkupPointer> m_pMkFinish;
+ mutable CLightMutex m_cs;
+};
+
+class CHTMLEngineMS : public IHTMLEngine
+{
+public:
+ CHTMLEngineMS();
+ ~CHTMLEngineMS();
+
+ virtual THTMLParserPtr GetParserPtr()const;
+};
+
+#endif //__3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__
diff --git a/plugins/Quotes/src/HTTPSession.cpp b/plugins/Quotes/src/HTTPSession.cpp new file mode 100644 index 0000000000..aa66948ae9 --- /dev/null +++ b/plugins/Quotes/src/HTTPSession.cpp @@ -0,0 +1,262 @@ +#include "StdAfx.h"
+#include "HTTPSession.h"
+#include "EconomicRateInfo.h"
+#include "LightMutex.h"
+
+class CHTTPSession::CImpl
+{
+public:
+ CImpl() {}
+ virtual ~CImpl() {}
+
+ virtual bool OpenURL(const tstring& rsURL) = 0;
+ virtual bool ReadResponce(tstring& rsResponce)const = 0;
+};
+
+namespace
+{
+// class CImplMS : public CHTTPSession::CImpl
+// {
+// public:
+// CImplMS()
+// : m_hSession(::InternetOpen(_T("Dioksin"),PRE_CONFIG_INTERNET_ACCESS,NULL,INTERNET_INVALID_PORT_NUMBER,0)),
+// m_hRequest(NULL)
+// {
+//
+// }
+//
+// ~CImplMS()
+// {
+// if(m_hRequest)
+// {
+// ::InternetCloseHandle(m_hRequest);
+// }
+//
+// if(m_hSession)
+// {
+// ::InternetCloseHandle(m_hSession);
+// }
+// }
+//
+// virtual bool OpenURL(const tstring& rsURL)
+// {
+// if(NULL == m_hSession)
+// {
+// return false;
+// }
+//
+// if(NULL != m_hRequest)
+// {
+// ::InternetCloseHandle(m_hRequest);
+// m_hRequest = NULL;
+// }
+//
+// m_hRequest = ::InternetOpenUrl(m_hSession,rsURL.c_str(),NULL,0,INTERNET_FLAG_RELOAD,0);
+// return NULL != m_hRequest;
+// }
+//
+// virtual bool ReadResponce(tstring& rsResponce)const
+// {
+// if(NULL == m_hRequest)
+// {
+// return false;
+// }
+//
+// std::string sBuffer;
+// bool bResult = true;
+// DWORD cbRead = 0;
+// char szBuffer[1024];
+// do{
+// if(FALSE == ::InternetReadFile(m_hRequest,szBuffer,1024,&cbRead))
+// {
+// bResult = false;
+// break;
+// }
+// if (0 == cbRead)
+// {
+// break; // Stop.
+// }
+// else
+// {
+// sBuffer.insert(sBuffer.size(),szBuffer,cbRead);
+// }
+// }while(true);
+//
+// if(true == bResult)
+// {
+// USES_CONVERSION;
+// rsResponce = A2CT(sBuffer.c_str());
+// }
+//
+// return bResult;
+// }
+// private:
+// HINTERNET m_hSession;
+// HINTERNET m_hRequest;
+// };
+//
+ int find_header(const NETLIBHTTPREQUEST* pRequest,const char* hdr)
+ {
+ for(int i = 0;i < pRequest->headersCount; ++i)
+ {
+ if (0 == _stricmp(pRequest->headers[i].szName,hdr))
+ {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+
+ class CImplMI : public CHTTPSession::CImpl
+ {
+ public:
+ CImplMI() {}
+
+ static bool Init()
+ {
+ assert(NULL == g_hNetLib);
+
+ NETLIBUSER nlu = {0};
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS|NUF_NOHTTPSOPTION|NUF_TCHAR;
+ nlu.szSettingsModule = QUOTES_PROTOCOL_NAME;
+ nlu.ptszDescriptiveName = TranslateT("Quotes HTTP connections");
+ g_hNetLib = reinterpret_cast<HANDLE>(CallService(MS_NETLIB_REGISTERUSER,0,(LPARAM)&nlu));
+ return (NULL != g_hNetLib);
+ }
+
+ static bool IsValid(){return NULL != g_hNetLib;}
+
+ virtual bool OpenURL(const tstring& rsURL)
+ {
+// USES_CONVERSION;
+
+ m_aURL.swap(TBuffer());
+
+ std::string s = quotes_t2a(rsURL.c_str());
+ const char* psz = s.c_str();//T2CA(rsURL.c_str());
+ m_aURL.insert(m_aURL.begin(),psz,psz+strlen(psz)+1);
+ return true;
+
+ }
+ virtual bool ReadResponce(tstring& rsResponce)const
+ {
+ if(true == m_aURL.empty())
+ {
+ return false;
+ }
+
+
+ NETLIBHTTPREQUEST nlhr = {0};
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_DUMPASTEXT|NLHRF_HTTP11|NLHRF_REDIRECT;
+ char* pURL = &*(m_aURL.begin());
+ nlhr.szUrl = pURL;
+
+ nlhr.headersCount = 4;
+ nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
+ nlhr.headers[0].szName = "User-Agent";
+ nlhr.headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
+ nlhr.headers[1].szName = "Connection";
+ nlhr.headers[1].szValue = "close";
+ nlhr.headers[2].szName = "Cache-Control";
+ nlhr.headers[2].szValue = "no-cache";
+ nlhr.headers[3].szName = "Pragma";
+ nlhr.headers[3].szValue = "no-cache";
+ // nlhr.headers[4].szName = "Accept-Encoding";
+ // nlhr.headers[4].szValue = "deflate, gzip";
+ // nlhr.headers[5].szName = "Cookie";
+ // nlhr.headers[5].szValue = cookie;
+
+ bool bResult = false;
+ NETLIBHTTPREQUEST* pReply = NULL;
+
+ {
+ CGuard<CLightMutex> guard(m_mx);
+ pReply = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
+ reinterpret_cast<WPARAM>(g_hNetLib),reinterpret_cast<LPARAM>(&nlhr)));
+ }
+
+ if(pReply)
+ {
+ if ((200 == pReply->resultCode) && (pReply->dataLength > 0))
+ {
+ TBuffer apBuffer;
+ apBuffer.insert(apBuffer.begin(),pReply->pData,pReply->pData+pReply->dataLength);
+ apBuffer.push_back('\0');
+
+ char* pResult = &*(apBuffer.begin());
+ int nIndex = find_header(pReply,"Content-Type");
+ if ((-1 != nIndex) && (NULL != strstr(_strlwr(pReply->headers[nIndex].szValue),"utf-8")))
+ {
+ TCHAR* p = mir_utf8decodeT(pResult);
+ rsResponce = p;
+ mir_free(p);
+ }
+ else
+ {
+// USES_CONVERSION;
+// LPCTSTR p = A2CT(pResult);
+ rsResponce = quotes_a2t(pResult);//p;
+ }
+
+ bResult = true;
+ }
+
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,reinterpret_cast<LPARAM>(pReply));
+ }
+
+ mir_free(nlhr.headers);
+
+ return bResult;
+ }
+
+ private:
+ static HANDLE g_hNetLib;
+ typedef std::vector<char> TBuffer;
+ mutable TBuffer m_aURL;
+ mutable CLightMutex m_mx;
+ };
+
+ HANDLE CImplMI::g_hNetLib = NULL;
+
+// CHTTPSession::CImpl* create_impl()
+// {
+// if(true == CImplMI::IsValid())
+// {
+// return new CImplMI;
+// }
+// else
+// {
+// return new CImplMS;
+// }
+// }
+}
+
+
+CHTTPSession::CHTTPSession()
+ : m_pImpl(new CImplMI)
+{
+}
+
+CHTTPSession::~CHTTPSession()
+{
+}
+
+bool CHTTPSession::OpenURL(const tstring& rsURL)
+{
+ return m_pImpl->OpenURL(rsURL);
+}
+
+bool CHTTPSession::ReadResponce(tstring& rsResponce)const
+{
+ return m_pImpl->ReadResponce(rsResponce);
+}
+
+bool CHTTPSession::Init()
+{
+ return CImplMI::Init();
+}
\ No newline at end of file diff --git a/plugins/Quotes/src/HTTPSession.h b/plugins/Quotes/src/HTTPSession.h new file mode 100644 index 0000000000..fe93a2dce5 --- /dev/null +++ b/plugins/Quotes/src/HTTPSession.h @@ -0,0 +1,27 @@ +#ifndef __8C9706FF_6B05_4d0d_85B8_5724E5DC0BA4_HTTPSession_h__
+#define __8C9706FF_6B05_4d0d_85B8_5724E5DC0BA4_HTTPSession_h__
+
+#include <string>
+
+class CHTTPSession
+{
+public:
+ CHTTPSession();
+ ~CHTTPSession();
+
+ static bool Init();
+
+ bool OpenURL(const tstring& rsURL);
+ bool ReadResponce(tstring& rsResponce)const;
+
+
+public:
+ class CImpl;
+private:
+ typedef boost::scoped_ptr<CImpl> TImpl;
+
+private:
+ TImpl m_pImpl;
+};
+
+#endif //__8C9706FF_6B05_4d0d_85B8_5724E5DC0BA4_HTTPSession_h__
diff --git a/plugins/Quotes/src/IHTMLEngine.h b/plugins/Quotes/src/IHTMLEngine.h new file mode 100644 index 0000000000..7df3074d3e --- /dev/null +++ b/plugins/Quotes/src/IHTMLEngine.h @@ -0,0 +1,18 @@ +#ifndef __85dbfa97_919b_4776_919c_7410a1c3d787_HTMLEngine_h__
+#define __85dbfa97_919b_4776_919c_7410a1c3d787_HTMLEngine_h__
+
+class IHTMLParser;
+
+class IHTMLEngine
+{
+public:
+ typedef boost::shared_ptr<IHTMLParser> THTMLParserPtr;
+
+public:
+ IHTMLEngine(void){}
+ virtual ~IHTMLEngine() {}
+
+ virtual THTMLParserPtr GetParserPtr()const = 0;
+};
+
+#endif //__85dbfa97_919b_4776_919c_7410a1c3d787_HTMLEngine_h__
diff --git a/plugins/Quotes/src/IHTMLParser.h b/plugins/Quotes/src/IHTMLParser.h new file mode 100644 index 0000000000..defc6f61cb --- /dev/null +++ b/plugins/Quotes/src/IHTMLParser.h @@ -0,0 +1,41 @@ +#ifndef __98ad6d6d_2a27_43fd_bf3e_c18416a45e54_IHTMLParser_h__
+#define __98ad6d6d_2a27_43fd_bf3e_c18416a45e54_IHTMLParser_h__
+
+class IHTMLNode
+{
+public:
+ typedef boost::shared_ptr<IHTMLNode> THTMLNodePtr;
+
+ enum EType
+ {
+ Table = 1,
+ TableRow,
+ TableColumn
+ };
+
+public:
+ IHTMLNode() {}
+ virtual ~IHTMLNode() {}
+
+ virtual size_t GetChildCount()const = 0;
+ virtual THTMLNodePtr GetChildPtr(size_t nIndex) = 0;
+ virtual bool Is(EType nType)const = 0;
+
+ virtual THTMLNodePtr GetElementByID(const tstring& rsID)const = 0;
+
+ virtual tstring GetAttribute(const tstring& rsAttrName)const = 0;
+ virtual tstring GetText()const = 0;
+};
+
+class IHTMLParser
+{
+public:
+ typedef IHTMLNode::THTMLNodePtr THTMLNodePtr;
+public:
+ IHTMLParser() {}
+ virtual ~IHTMLParser() {}
+
+ virtual THTMLNodePtr ParseString(const tstring& rsHTML) = 0;
+};
+
+#endif //__98ad6d6d_2a27_43fd_bf3e_c18416a45e54_IHTMLParser_h__
diff --git a/plugins/Quotes/src/IQuotesProvider.h b/plugins/Quotes/src/IQuotesProvider.h new file mode 100644 index 0000000000..a03a2a9bcd --- /dev/null +++ b/plugins/Quotes/src/IQuotesProvider.h @@ -0,0 +1,41 @@ +#pragma once
+
+#ifndef __ac71e133_786c_41a7_ab07_625b76ff2a8c_QuotesProvider_h__
+#define __ac71e133_786c_41a7_ab07_625b76ff2a8c_QuotesProvider_h__
+
+#include <boost\noncopyable.hpp>
+#include <string>
+
+class CQuotesProviderVisitor;
+
+class IQuotesProvider : private boost::noncopyable
+{
+public:
+ struct CProviderInfo
+ {
+ tstring m_sName;
+ tstring m_sURL;
+
+ };
+
+public:
+ IQuotesProvider() {}
+ virtual ~IQuotesProvider() {}
+
+ virtual bool Init() = 0;
+ virtual const CProviderInfo& GetInfo()const = 0;
+
+ virtual void AddContact(HANDLE hContact) = 0;
+ virtual void DeleteContact(HANDLE hContact) = 0;
+
+ virtual void ShowPropertyPage(WPARAM wp,OPTIONSDIALOGPAGE& odp) = 0;
+ virtual void RefreshAll() = 0;
+ virtual void RefreshContact(HANDLE hContact) = 0;
+ virtual void SetContactExtraIcon(HANDLE hContact)const = 0;
+
+ virtual void Run() = 0;
+
+ virtual void Accept(CQuotesProviderVisitor& visitor)const = 0;
+};
+
+#endif //__ac71e133_786c_41a7_ab07_625b76ff2a8c_QuotesProvider_h__
diff --git a/plugins/Quotes/src/IXMLEngine.h b/plugins/Quotes/src/IXMLEngine.h new file mode 100644 index 0000000000..910c3efea0 --- /dev/null +++ b/plugins/Quotes/src/IXMLEngine.h @@ -0,0 +1,43 @@ +#ifndef __f88e20d7_5e65_40fb_a7b5_7c7af1ee1c78_IXMLEngine_h__
+#define __f88e20d7_5e65_40fb_a7b5_7c7af1ee1c78_IXMLEngine_h__
+
+class IXMLNode
+{
+public:
+ typedef boost::shared_ptr<IXMLNode> TXMLNodePtr;
+
+public:
+ IXMLNode() {}
+ virtual ~IXMLNode() {}
+
+ virtual size_t GetChildCount()const = 0;
+ virtual TXMLNodePtr GetChildNode(size_t nIndex)const = 0;
+
+ virtual tstring GetText()const = 0;
+ virtual tstring GetName()const = 0;
+
+ virtual bool AddChild(const TXMLNodePtr& pNode) = 0;
+ virtual bool AddAttribute(const tstring& rsName,const tstring& rsValue) = 0;
+ virtual tstring GetAttributeValue(const tstring& rsAttrName) = 0;
+ virtual void Write(tostream& o)const = 0;
+};
+
+inline tostream& operator<<(tostream& o,const IXMLNode& node)
+{
+ node.Write(o);
+ return o;
+}
+
+class IXMLEngine
+{
+public:
+ IXMLEngine() {}
+
+ virtual ~IXMLEngine() {}
+
+ virtual IXMLNode::TXMLNodePtr LoadFile(const tstring& rsFileName)const = 0;
+ virtual bool SaveFile(const tstring& rsFileName,const IXMLNode::TXMLNodePtr& pNode)const = 0;
+ virtual IXMLNode::TXMLNodePtr CreateNode(const tstring& rsName,const tstring& rsText)const = 0;
+};
+
+#endif //__f88e20d7_5e65_40fb_a7b5_7c7af1ee1c78_IXMLEngine_h__
diff --git a/plugins/Quotes/src/IconLib.cpp b/plugins/Quotes/src/IconLib.cpp new file mode 100644 index 0000000000..9ac96599a5 --- /dev/null +++ b/plugins/Quotes/src/IconLib.cpp @@ -0,0 +1,94 @@ +#include "StdAfx.h"
+#include "IconLib.h"
+#include <m_icolib.h>
+#include "resource.h"
+#include "EconomicRateInfo.h"
+// #include <newpluginapi.h>
+#include <m_langpack.h>
+#include <sstream>
+#pragma warning (disable:4996)
+#include <m_utils.h>
+#pragma warning (default:4996)
+#include "ModuleInfo.h"
+
+// extern HMODULE g_hInstance;
+
+namespace
+{
+ struct CIconList
+ {
+ TCHAR* szDescr;
+ char* szName;
+ int defIconID;
+ HANDLE hIconLibItem;
+ };
+
+ CIconList iconList[] =
+ {
+ { _T("Protocol icon"), ICON_STR_MAIN, IDI_ICON_MAIN },
+ { _T("Quote/Rate up"), ICON_STR_QUOTE_UP, IDI_ICON_UP },
+ { _T("Quote/Rate down"), ICON_STR_QUOTE_DOWN, IDI_ICON_DOWN },
+ { _T("Quote/Rate not changed"), ICON_STR_QUOTE_NOT_CHANGED, IDI_ICON_NOTCHANGED },
+ { _T("Quote Section"), ICON_STR_SECTION, IDI_ICON_SECTION },
+ { _T("Quote"), ICON_STR_QUOTE, IDI_ICON_QUOTE },
+ { _T("Currency Converter"), ICON_STR_CURRENCY_CONVERTER, IDI_ICON_CURRENCY_CONVERTER },
+ { _T("Refresh"), ICON_STR_REFRESH, IDI_ICON_REFRESH },
+ { _T("Export"), ICON_STR_EXPORT, IDI_ICON_EXPORT },
+ { _T("Swap button"), ICON_STR_SWAP, IDI_ICON_SWAP },
+ { _T("Import"), ICON_STR_IMPORT, IDI_ICON_IMPORT }
+ };
+}
+
+void Quotes_IconsInit()
+{
+ USES_CONVERSION;
+
+ SKINICONDESC sid = {0};
+ TCHAR szFile[MAX_PATH];
+ ::GetModuleFileName(g_hInstance, szFile, MAX_PATH);
+
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.ptszDefaultFile = szFile;
+ sid.cx = sid.cy = 16;
+ sid.flags = SIDF_ALL_TCHAR;
+ sid.ptszSection = A2T(QUOTES_PROTOCOL_NAME);
+
+ for (int i = 0; i < SIZEOF(iconList); i++) {
+ std::string sName = Quotes_MakeIconName( iconList[i].szName);
+ sid.pszName = const_cast<char*>(sName.c_str());
+ sid.ptszDescription = iconList[i].szDescr;
+ sid.iDefaultIndex = -iconList[i].defIconID;
+ iconList[i].hIconLibItem = Skin_AddIcon(&sid);
+ }
+}
+
+std::string Quotes_MakeIconName(const char* name)
+{
+ assert(name);
+ //char szSettingName[100];
+ //mir_snprintf(szSettingName,SIZEOF(szSettingName),"%s_%s",QUOTES_PROTOCOL_NAME,name);
+ std::string sName(QUOTES_PROTOCOL_NAME);
+ sName += "_";
+ sName += name;
+ return sName;
+}
+
+HICON Quotes_LoadIconEx(const char* name,bool bBig /*= false*/)
+{
+ std::string sIconName = Quotes_MakeIconName(name);
+ return Skin_GetIcon(sIconName.c_str(), bBig);
+}
+
+HANDLE Quotes_GetIconHandle(int iconId)
+{
+ for(int i=0;i < SIZEOF(iconList);i++)
+ {
+ if(iconList[i].defIconID == iconId)
+ {
+ return iconList[i].hIconLibItem;
+ }
+ }
+
+ return NULL;
+}
+
diff --git a/plugins/Quotes/src/IconLib.h b/plugins/Quotes/src/IconLib.h new file mode 100644 index 0000000000..29b0326622 --- /dev/null +++ b/plugins/Quotes/src/IconLib.h @@ -0,0 +1,21 @@ +#ifndef __8821d334_afac_439e_9a81_76318e1ac4ef_IconLib_h__
+#define __8821d334_afac_439e_9a81_76318e1ac4ef_IconLib_h__
+
+#define ICON_STR_MAIN "main"
+#define ICON_STR_QUOTE_UP "quote_up"
+#define ICON_STR_QUOTE_DOWN "quote_down"
+#define ICON_STR_QUOTE_NOT_CHANGED "quote_not_changed"
+#define ICON_STR_SECTION "quote_section"
+#define ICON_STR_QUOTE "quote"
+#define ICON_STR_CURRENCY_CONVERTER "currency_converter"
+#define ICON_STR_REFRESH "refresh"
+#define ICON_STR_IMPORT "import"
+#define ICON_STR_EXPORT "export"
+#define ICON_STR_SWAP "swap"
+
+void Quotes_IconsInit();
+HICON Quotes_LoadIconEx(const char* name,bool bBig = false);
+HANDLE Quotes_GetIconHandle(int iconId);
+std::string Quotes_MakeIconName(const char* name);
+
+#endif //__8821d334_afac_439e_9a81_76318e1ac4ef_IconLib_h__
diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp new file mode 100644 index 0000000000..80ab41d309 --- /dev/null +++ b/plugins/Quotes/src/ImportExport.cpp @@ -0,0 +1,850 @@ +#include "StdAfx.h"
+#include "ImportExport.h"
+#include "ModuleInfo.h"
+#include "QuotesProviders.h"
+#ifdef TEST_IMPORT_EXPORT
+#include "m_Quotes.h"
+#endif
+#include "IXMLEngine.h"
+#include "Base64.h"
+#include "EconomicRateInfo.h"
+#include "IQuotesProvider.h"
+#include "QuotesProviderVisitor.h"
+#include "QuotesProviderDukasCopy.h"
+#include "QuotesProviderGoogle.h"
+#include "QuotesProviderGoogleFinance.h"
+#include "Locale.h"
+
+namespace
+{
+ LPCTSTR g_pszXmlValue = _T("Value");
+ LPCTSTR g_pszXmlName = _T("Name");
+ LPCTSTR g_pszXmlSetting = _T("Setting");
+ LPCTSTR g_pszXmlModule = _T("Module");
+ LPCTSTR g_pszXmlContact = _T("Contact");
+ LPCTSTR g_pszXmlContacts = _T("Contacts");
+ LPCTSTR g_pszXmlType = _T("type");
+ LPCTSTR g_pszXmlTypeByte = _T("byte");
+ LPCTSTR g_pszXmlTypeWord = _T("word");
+ LPCTSTR g_pszXmlTypeDword = _T("dword");
+ LPCTSTR g_pszXmlTypeAsciiz = _T("asciiz");
+ LPCTSTR g_pszXmlTypeWchar = _T("wchar");
+ LPCTSTR g_pszXmlTypeUtf8 = _T("utf8");
+ LPCTSTR g_pszXmlTypeBlob = _T("blob");
+
+ struct CEnumContext
+ {
+ CModuleInfo::TXMLEnginePtr m_pXmlEngine;
+ IXMLNode::TXMLNodePtr m_pNode;
+ HANDLE m_hContact;
+ LPCSTR m_pszModule;
+ };
+
+ struct mir_safety_dbvar
+ {
+ mir_safety_dbvar(DBVARIANT* p) : m_p(p){}
+ ~mir_safety_dbvar(){DBFreeVariant(m_p);}
+ DBVARIANT* m_p;
+ };
+
+ static int enum_contact_settings(const char* szSetting,LPARAM lp)
+ {
+// USES_CONVERSION;
+ CEnumContext* ctx = reinterpret_cast<CEnumContext*>(lp);
+
+ DBVARIANT dbv;
+ DBCONTACTGETSETTING cgs;
+
+ cgs.szModule = ctx->m_pszModule;
+ cgs.szSetting = szSetting;
+ cgs.pValue = &dbv;
+ if(0 == CallService(MS_DB_CONTACT_GETSETTING,
+ reinterpret_cast<WPARAM>(ctx->m_hContact),
+ reinterpret_cast<LPARAM>(&cgs)))
+ {
+ mir_safety_dbvar sdbvar(&dbv);
+
+ tstring sType;
+ tostringstream sValue;
+ sValue.imbue(GetSystemLocale());
+
+ switch(dbv.type)
+ {
+ case DBVT_BYTE:
+ sValue << dbv.bVal;
+ sType = g_pszXmlTypeByte;
+ break;
+ case DBVT_WORD:
+ sValue << dbv.wVal;
+ sType = g_pszXmlTypeWord;
+ break;
+ case DBVT_DWORD:
+ sValue << dbv.dVal;
+ sType = g_pszXmlTypeDword;
+ break;
+ case DBVT_ASCIIZ:
+ sType = g_pszXmlTypeAsciiz;
+ if(dbv.pszVal)
+ {
+ sValue << dbv.pszVal;
+// mir_safe_string<char> mss(mir_utf8encode(dbv.pszVal));
+// if(mss.m_p)
+// {
+// sValue << mss.m_p;
+// }
+ }
+ break;
+ case DBVT_WCHAR:
+ sType = g_pszXmlTypeWchar;
+ if(dbv.pwszVal)
+ {
+ sValue << dbv.pwszVal;
+// mir_safe_string<char> mss(mir_utf8encodeW(dbv.pwszVal));
+// if(mss.m_p)
+// {
+// sValue << mss.m_p;
+// }
+ }
+ break;
+ case DBVT_UTF8:
+ sType = g_pszXmlTypeUtf8;
+ if(dbv.pszVal)
+ {
+ sValue << dbv.pszVal;
+ }
+ break;
+ case DBVT_BLOB:
+ sType = g_pszXmlTypeBlob;
+ if(dbv.pbVal)
+ {
+ std::vector<char> buf;
+ if(true == base64::encode(dbv.pbVal,dbv.cpbVal,buf))
+ {
+ buf.push_back('\0');
+ sValue << &*buf.begin();
+ }
+ }
+ break;
+ }
+
+// mir_safe_string<char> mssSetting(mir_utf8encode(szSetting));
+// if(mssSetting.m_p)
+ {
+ IXMLNode::TXMLNodePtr pXmlSet = ctx->m_pXmlEngine->CreateNode(g_pszXmlSetting,tstring());
+ if(pXmlSet)
+ {
+ IXMLNode::TXMLNodePtr pXmlName = ctx->m_pXmlEngine->CreateNode(g_pszXmlName,quotes_a2t(szSetting));
+
+ IXMLNode::TXMLNodePtr pXmlValue = ctx->m_pXmlEngine->CreateNode(g_pszXmlValue,sValue.str());
+ if(pXmlName && pXmlValue)
+ {
+ pXmlValue->AddAttribute(g_pszXmlType,sType);
+
+ pXmlSet->AddChild(pXmlName);
+ pXmlSet->AddChild(pXmlValue);
+ ctx->m_pNode->AddChild(pXmlSet);
+ }
+ }
+ }
+ }
+
+ return 0;
+ }
+
+ int EnumDbModules(const char* szModuleName, DWORD ofsModuleName, LPARAM lp)
+ {
+// USES_CONVERSION;
+ CEnumContext* ctx = reinterpret_cast<CEnumContext*>(lp);
+ IXMLNode::TXMLNodePtr pXml = ctx->m_pNode;
+ IXMLNode::TXMLNodePtr pModule = ctx->m_pXmlEngine->CreateNode(g_pszXmlModule,quotes_a2t(szModuleName)/*A2CT(szModuleName)*/);
+ if(pModule)
+ {
+ ctx->m_pszModule = szModuleName;
+ ctx->m_pNode = pModule;
+
+ DBCONTACTENUMSETTINGS dbces;
+ dbces.pfnEnumProc = &enum_contact_settings;
+ dbces.szModule = szModuleName;
+ dbces.lParam = reinterpret_cast<LPARAM>(ctx);
+
+ CallService(MS_DB_CONTACT_ENUMSETTINGS,reinterpret_cast<WPARAM>(ctx->m_hContact),reinterpret_cast<LPARAM>(&dbces));
+ if(pModule->GetChildCount() > 0)
+ {
+ pXml->AddChild(pModule);
+ }
+ ctx->m_pNode = pXml;
+ }
+
+ return 0;
+ }
+
+ IXMLNode::TXMLNodePtr export_contact(HANDLE hContact,const CModuleInfo::TXMLEnginePtr& pXmlEngine)
+ {
+ IXMLNode::TXMLNodePtr pNode = pXmlEngine->CreateNode(g_pszXmlContact,tstring());
+ if(pNode)
+ {
+ CEnumContext ctx;
+ ctx.m_pXmlEngine = pXmlEngine;
+ ctx.m_pNode = pNode;
+ ctx.m_hContact = hContact;
+
+ CallService(MS_DB_MODULES_ENUM,reinterpret_cast<WPARAM>(&ctx),reinterpret_cast<LPARAM>(EnumDbModules));
+ }
+ return pNode;
+ }
+
+ LPCTSTR prepare_filter(LPTSTR pszBuffer,size_t cBuffer)
+ {
+ LPTSTR p = pszBuffer;
+ LPCTSTR pszXml = TranslateT("Xml File (*.xml)");
+ lstrcpyn(p,pszXml, (int)cBuffer);
+ size_t nLen = (int)lstrlen(pszXml)+1;
+ p+= nLen;
+ if(nLen < cBuffer)
+ {
+ lstrcpyn(p,_T("*.xml"),(int)(cBuffer-nLen));
+ p+= 6;
+ nLen += 6;
+ }
+
+ if(nLen < cBuffer)
+ {
+ LPCTSTR pszAll = TranslateT("All files (*.*)");
+ lstrcpyn(p,pszAll,(int)(cBuffer-nLen));
+ size_t n = lstrlen(pszAll)+1;
+ nLen += n;
+ p+= n;
+ }
+
+ if(nLen < cBuffer)
+ {
+ lstrcpyn(p,_T("*.*"),(int)(cBuffer-nLen));
+ p+= 4;
+ nLen += 4;
+ }
+
+ if(nLen < cBuffer)
+ {
+ *p = _T('\0');
+ }
+
+ return pszBuffer;
+ }
+
+ bool show_open_file_dialog(bool bOpen,tstring& rsFile)
+ {
+ TCHAR szBuffer[MAX_PATH];
+ TCHAR szFilter[MAX_PATH];
+ OPENFILENAME ofn;
+ memset(&ofn,0,sizeof(ofn));
+
+ ofn.lStructSize = sizeof(OPENFILENAME);
+
+ ofn.hwndOwner = NULL;
+ ofn.lpstrFilter = prepare_filter(szFilter,MAX_PATH);
+ ofn.Flags = OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_EXPLORER;
+ ofn.lpstrDefExt = _T("xml");
+ if(true == bOpen)
+ {
+ ofn.Flags |= OFN_FILEMUSTEXIST;
+ }
+ else
+ {
+ ofn.Flags |= OFN_OVERWRITEPROMPT;
+ }
+ ofn.nMaxFile = MAX_PATH;
+ ofn.lpstrFile = szBuffer;
+ ofn.lpstrFile[0] = _T('\0');
+
+ if(bOpen)
+ {
+ if(FALSE == GetOpenFileName(&ofn))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if(FALSE == GetSaveFileName(&ofn))
+ {
+ return false;
+ }
+ }
+
+ rsFile = szBuffer;
+
+ return true;
+ }
+}
+
+INT_PTR Quotes_Export(WPARAM wp,LPARAM lp)
+{
+// USES_CONVERSION;
+
+ tstring sFileName;
+ const char* pszFile = reinterpret_cast<const char*>(lp);
+ if(NULL == pszFile)
+ {
+ if(false == show_open_file_dialog(false,sFileName))
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ sFileName = quotes_a2t(pszFile);//A2CT(pszFile);
+ }
+
+ CModuleInfo::TXMLEnginePtr pXmlEngine = CModuleInfo::GetInstance().GetXMLEnginePtr();
+ CModuleInfo::TQuotesProvidersPtr pProviders = CModuleInfo::GetInstance().GetQuoteProvidersPtr();
+ IXMLNode::TXMLNodePtr pRoot = pXmlEngine->CreateNode(g_pszXmlContacts,tstring());
+ HANDLE hContact = reinterpret_cast<HANDLE>(wp);
+ if(hContact)
+ {
+ CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact);
+ if(pProvider)
+ {
+ IXMLNode::TXMLNodePtr pNode = export_contact(hContact,pXmlEngine);
+ if(pNode)
+ {
+ pRoot->AddChild(pNode);
+ }
+ }
+ }
+ else
+ {
+ for(hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ {
+ CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact);
+ if(pProvider)
+ {
+ IXMLNode::TXMLNodePtr pNode = export_contact(hContact,pXmlEngine);
+ if(pNode)
+ {
+ pRoot->AddChild(pNode);
+ }
+ }
+ }
+ }
+
+ return ((true == pXmlEngine->SaveFile(sFileName,pRoot)) ? 0 : 1);
+}
+
+namespace
+{
+ bool set_contact_settings(HANDLE hContact,DBCONTACTWRITESETTING& dbs)
+ {
+ assert(DBVT_DELETED != dbs.value.type);
+ return (0 == CallService(MS_DB_CONTACT_WRITESETTING,reinterpret_cast<WPARAM>(hContact),
+ reinterpret_cast<LPARAM>(&dbs)));
+ }
+
+ bool handle_module(HANDLE hContact,const IXMLNode::TXMLNodePtr& pXmlModule,UINT nFlags)
+ {
+// USES_CONVERSION;
+
+ size_t cCreatedRecords = 0;
+ tstring sModuleName = pXmlModule->GetText();
+ if(false == sModuleName.empty())
+ {
+ DBCONTACTWRITESETTING dbs;
+ std::string s = quotes_t2a(sModuleName.c_str());
+ dbs.szModule = s.c_str();//T2CA(sModuleName.c_str());
+
+ bool bCListModule = 0 == quotes_stricmp(sModuleName.c_str(),_T("CList"));
+
+ size_t cChild = pXmlModule->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ IXMLNode::TXMLNodePtr pSetting = pXmlModule->GetChildNode(i);
+ tstring sSetting = pSetting->GetName();
+ if(0 == quotes_stricmp(g_pszXmlSetting,sSetting.c_str()))
+ {
+ size_t cSetChild = pSetting->GetChildCount();
+ if(cSetChild >= 2)
+ {
+ tstring sName;
+ tstring sValue;
+ tstring sType;
+ for(size_t i = 0;i < cSetChild;++i)
+ {
+ IXMLNode::TXMLNodePtr pNode = pSetting->GetChildNode(i);
+ tstring sNode = pNode->GetName();
+ if(0 == quotes_stricmp(g_pszXmlName,sNode.c_str()))
+ {
+ sName = pNode->GetText();
+ }
+ else if(0 == quotes_stricmp(g_pszXmlValue,sNode.c_str()))
+ {
+ sValue = pNode->GetText();
+ sType = pNode->GetAttributeValue(g_pszXmlType);
+ }
+ }
+
+ if ((false == sName.empty()) && (false == sType.empty()))
+ {
+ std::string s = quotes_t2a(sName.c_str());
+ dbs.szSetting = s.c_str();//T2CA(sName.c_str());
+ if(0 == quotes_stricmp(g_pszXmlTypeByte,sType.c_str()))
+ {
+ tistringstream in(sValue.c_str());
+ in.imbue(GetSystemLocale());
+ dbs.value.cVal = in.get();
+ if(in.good() && in.eof())
+ {
+ dbs.value.type = DBVT_BYTE;
+ if(set_contact_settings(hContact,dbs))
+ {
+ ++cCreatedRecords;
+ }
+ }
+ }
+ else if(0 == quotes_stricmp(g_pszXmlTypeWord,sType.c_str()))
+ {
+ tistringstream in(sValue.c_str());
+ in.imbue(GetSystemLocale());
+ in >> dbs.value.wVal;
+ if(in.good() || in.eof())
+ {
+ dbs.value.type = DBVT_WORD;
+ if(set_contact_settings(hContact,dbs))
+ {
+ ++cCreatedRecords;
+ }
+ }
+ }
+ else if(0 == quotes_stricmp(g_pszXmlTypeDword,sType.c_str()))
+ {
+ tistringstream in(sValue.c_str());
+ in.imbue(GetSystemLocale());
+ in >> dbs.value.dVal;
+ if(in.good() || in.eof())
+ {
+ dbs.value.type = DBVT_DWORD;
+ if(set_contact_settings(hContact,dbs))
+ {
+ ++cCreatedRecords;
+ }
+ }
+ }
+ else if(0 == quotes_stricmp(g_pszXmlTypeAsciiz,sType.c_str()))
+ {
+ CT2A v(sValue.c_str());
+ dbs.value.pszVal = v;
+ dbs.value.type = DBVT_ASCIIZ;
+ if(set_contact_settings(hContact,dbs))
+ {
+ ++cCreatedRecords;
+ }
+ }
+ else if(0 == quotes_stricmp(g_pszXmlTypeUtf8,sType.c_str()))
+ {
+ dbs.value.pszVal = mir_utf8encodeT(sValue.c_str());
+ dbs.value.type = DBVT_UTF8;
+ if(set_contact_settings(hContact,dbs))
+ {
+ ++cCreatedRecords;
+ }
+ mir_free(dbs.value.pszVal);
+ }
+ else if(0 == quotes_stricmp(g_pszXmlTypeWchar,sType.c_str()))
+ {
+ CT2W val(sValue.c_str());
+ dbs.value.pwszVal = val;
+ dbs.value.type = DBVT_WCHAR;
+ if(set_contact_settings(hContact,dbs))
+ {
+ ++cCreatedRecords;
+ }
+ mir_free(dbs.value.pwszVal);
+ }
+ else if(0 == quotes_stricmp(g_pszXmlTypeBlob,sType.c_str()))
+ {
+ std::vector<BYTE> blob_buf;
+ std::string p = quotes_t2a(sValue.c_str());//T2A(sValue.c_str());
+ if(true == base64::decode(p.c_str(),lstrlenA(p.c_str()),blob_buf))
+ {
+ dbs.value.pbVal = &*blob_buf.begin();
+ dbs.value.cpbVal = (WORD)blob_buf.size();
+ dbs.value.type = DBVT_BLOB;
+
+ if(set_contact_settings(hContact,dbs))
+ {
+ ++cCreatedRecords;
+ }
+ }
+ }
+
+ if ((true == bCListModule) && (0 == quotes_stricmp(sName.c_str(),_T("Group"))))
+ {
+ CallService(MS_CLIST_GROUPCREATE,NULL,reinterpret_cast<LPARAM>(sValue.c_str()));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ size_t count_contacts(const IXMLNode::TXMLNodePtr& pXmlRoot,bool bInContactsGroup)
+ {
+ size_t cContacts = 0;
+ size_t cChild = pXmlRoot->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ IXMLNode::TXMLNodePtr pNode = pXmlRoot->GetChildNode(i);
+ tstring sName = pNode->GetName();
+ if(false == bInContactsGroup)
+ {
+ if(0 == quotes_stricmp(g_pszXmlContacts,sName.c_str()))
+ {
+ cContacts += count_contacts(pNode,true);
+ }
+ else
+ {
+ cContacts += count_contacts(pNode,false);
+ }
+ }
+ else
+ {
+ if(0 == quotes_stricmp(g_pszXmlContact,sName.c_str()))
+ {
+ ++ cContacts;
+ }
+ }
+ }
+
+ return cContacts;
+ }
+
+ struct CImportContext
+ {
+ CImportContext(size_t cTotalContacts) : m_cTotalContacts(cTotalContacts),m_cHandledContacts(0),m_nFlags(0){}
+
+ size_t m_cTotalContacts;
+ size_t m_cHandledContacts;
+ UINT m_nFlags;
+ };
+
+ struct CContactState
+ {
+ CContactState() : m_hContact(NULL),m_bNewContact(false){}
+ HANDLE m_hContact;
+ CQuotesProviders::TQuotesProviderPtr m_pProvider;
+ bool m_bNewContact;
+ };
+
+ IXMLNode::TXMLNodePtr find_quotes_module(const IXMLNode::TXMLNodePtr& pXmlContact)
+ {
+// USES_CONVERSION;
+// LPCTSTR pszQuotes = A2T(QUOTES_MODULE_NAME);
+ static const tstring g_sQuotes = quotes_a2t(QUOTES_MODULE_NAME);
+ size_t cChild = pXmlContact->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ IXMLNode::TXMLNodePtr pNode = pXmlContact->GetChildNode(i);
+ tstring sName = pNode->GetName();
+ if ((0 == quotes_stricmp(g_pszXmlModule,sName.c_str()))
+ && (0 == quotes_stricmp(g_sQuotes.c_str(),pNode->GetText().c_str())))
+ {
+ return pNode;
+ }
+ }
+
+ return IXMLNode::TXMLNodePtr();
+ }
+
+ typedef std::pair<tstring,tstring> TNameValue;//first is name,second is value
+ TNameValue parse_setting_node(const IXMLNode::TXMLNodePtr& pXmlSetting)
+ {
+ assert(pXmlSetting);
+
+ tstring sName,sValue;
+ size_t cSettingChildItems = pXmlSetting->GetChildCount();
+ for(size_t j = 0;j < cSettingChildItems;++j)
+ {
+ IXMLNode::TXMLNodePtr pXMLSetChild = pXmlSetting->GetChildNode(j);
+ if(pXMLSetChild)
+ {
+ if(0 == quotes_stricmp(g_pszXmlName,pXMLSetChild->GetName().c_str()))
+ {
+ sName = pXMLSetChild->GetText();
+ }
+ else if(0 == quotes_stricmp(g_pszXmlValue,pXMLSetChild->GetName().c_str()))
+ {
+ sValue = pXMLSetChild->GetText();
+ }
+ }
+ }
+
+ return std::make_pair(sName,sValue);
+ }
+
+ CQuotesProviders::TQuotesProviderPtr find_provider(const IXMLNode::TXMLNodePtr& pXmlQuotesModule)
+ {
+// USES_CONVERSION;
+ static const tstring g_sQuotesProvider = quotes_a2t(DB_STR_QUOTE_PROVIDER);//A2CT(DB_STR_QUOTE_PROVIDER);
+ size_t cChild = pXmlQuotesModule->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ IXMLNode::TXMLNodePtr pXMLSetting = pXmlQuotesModule->GetChildNode(i);
+ if(pXMLSetting && (0 == quotes_stricmp(g_pszXmlSetting,pXMLSetting->GetName().c_str())))
+ {
+ TNameValue Item = parse_setting_node(pXMLSetting);
+ if ((0 == quotes_stricmp(g_sQuotesProvider.c_str(),Item.first.c_str())) && (false == Item.second.empty()))
+ {
+ return CModuleInfo::GetInstance().GetQuoteProvidersPtr()->FindProvider(Item.second);
+ }
+ }
+ }
+
+ return CQuotesProviders::TQuotesProviderPtr();
+ }
+
+ bool get_contact_state(const IXMLNode::TXMLNodePtr& pXmlContact,CContactState& cst)
+ {
+ class visitor : public CQuotesProviderVisitor
+ {
+ public:
+ visitor(const IXMLNode::TXMLNodePtr& pXmlQuotes)
+ : m_hContact(NULL),m_pXmlQuotes(pXmlQuotes){}
+
+ HANDLE GetContact()const{return m_hContact;}
+
+ private:
+ virtual void Visit(const CQuotesProviderDukasCopy& rProvider)
+ {
+ tstring sQuoteID = GetXMLNodeValue(DB_STR_QUOTE_ID);
+ if(false == sQuoteID.empty())
+ {
+ m_hContact = rProvider.GetContactByQuoteID(sQuoteID);
+ }
+ }
+
+ virtual void Visit(const CQuotesProviderGoogle& rProvider)
+ {
+// USES_CONVERSION;
+ static const tstring g_sFromID = quotes_a2t(DB_STR_FROM_ID);//A2CT(DB_STR_FROM_ID);
+ static const tstring g_sToID = quotes_a2t(DB_STR_TO_ID);//A2CT(DB_STR_TO_ID);
+
+ tstring sFromID;
+ tstring sToID;
+ size_t cChild = m_pXmlQuotes->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ IXMLNode::TXMLNodePtr pNode = m_pXmlQuotes->GetChildNode(i);
+ if(pNode && (0 == quotes_stricmp(g_pszXmlSetting, pNode->GetName().c_str())))
+ {
+ TNameValue Item = parse_setting_node(pNode);
+ if(0 == quotes_stricmp(g_sFromID.c_str(),Item.first.c_str()))
+ {
+ sFromID = Item.second;
+ }
+ else if(0 == quotes_stricmp(g_sToID.c_str(),Item.first.c_str()))
+ {
+ sToID = Item.second;
+ }
+ }
+ }
+
+ if ((false == sFromID.empty()) && (false == sToID.empty()))
+ {
+ m_hContact = rProvider.GetContactByID(sFromID,sToID);
+ }
+ }
+
+ virtual void Visit(const CQuotesProviderFinance& rProvider)
+ {
+ tstring sQuoteID = GetXMLNodeValue(DB_STR_QUOTE_ID);
+ if(false == sQuoteID.empty())
+ {
+ m_hContact = rProvider.GetContactByQuoteID(sQuoteID);
+ }
+ }
+
+ tstring GetXMLNodeValue(const char* pszXMLNodeName)const
+ {
+// USES_CONVERSION;
+ tstring sXMLNodeName = quotes_a2t(pszXMLNodeName);//A2CT(pszXMLNodeName);
+
+ tstring sValue;
+ size_t cChild = m_pXmlQuotes->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ IXMLNode::TXMLNodePtr pNode = m_pXmlQuotes->GetChildNode(i);
+ if(pNode && (0 == quotes_stricmp(g_pszXmlSetting, pNode->GetName().c_str())))
+ {
+ TNameValue Item = parse_setting_node(pNode);
+ if(0 == quotes_stricmp(Item.first.c_str(),sXMLNodeName.c_str()))
+ {
+ sValue = Item.second;
+ break;
+ }
+ }
+ }
+
+ return sValue;
+ }
+
+ private:
+ HANDLE m_hContact;
+ IXMLNode::TXMLNodePtr m_pXmlQuotes;
+ };
+
+ IXMLNode::TXMLNodePtr pXmlQuotes = find_quotes_module(pXmlContact);
+ if(pXmlQuotes)
+ {
+ cst.m_pProvider = find_provider(pXmlQuotes);
+ if(cst.m_pProvider)
+ {
+ visitor vs(pXmlQuotes);
+ cst.m_pProvider->Accept(vs);
+ cst.m_hContact = vs.GetContact();
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ bool import_contact(const IXMLNode::TXMLNodePtr& pXmlContact,CImportContext& impctx)
+ {
+ ++ impctx.m_cHandledContacts;
+
+ CContactState cst;
+ bool bResult = get_contact_state(pXmlContact,cst);
+ if(bResult)
+ {
+ if(NULL == cst.m_hContact)
+ {
+ cst.m_hContact = reinterpret_cast<HANDLE>(CallService(MS_DB_CONTACT_ADD,0,0));
+ cst.m_bNewContact = true;
+ }
+ else if(impctx.m_nFlags"ES_IMPORT_SKIP_EXISTING_CONTACTS)
+ {
+ return true;
+ }
+
+ if(cst.m_hContact)
+ {
+ size_t cChild = pXmlContact->GetChildCount();
+ for(size_t i = 0;i < cChild && bResult;++i)
+ {
+ IXMLNode::TXMLNodePtr pNode = pXmlContact->GetChildNode(i);
+ tstring sName = pNode->GetName();
+ if(0 == quotes_stricmp(g_pszXmlModule,sName.c_str()))
+ {
+ bResult &= handle_module(cst.m_hContact,pNode,impctx.m_nFlags);
+ }
+ }
+
+ if(cst.m_bNewContact && bResult)
+ {
+ cst.m_pProvider->AddContact(cst.m_hContact);
+ cst.m_pProvider->RefreshContact(cst.m_hContact);
+ }
+ }
+ else
+ {
+ bResult = false;
+ }
+ }
+
+ return bResult;
+
+ }
+
+ size_t import_contacts(const IXMLNode::TXMLNodePtr& pXmlContacts,CImportContext& impctx)
+ {
+ size_t cContacts = 0;
+ size_t cChild = pXmlContacts->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ IXMLNode::TXMLNodePtr pNode = pXmlContacts->GetChildNode(i);
+ tstring sName = pNode->GetName();
+ if(0 == quotes_stricmp(g_pszXmlContact,sName.c_str()))
+ {
+ if(true == import_contact(pNode,impctx))
+ {
+ ++ cContacts;
+ }
+ }
+ }
+
+ return cContacts;
+
+ }
+
+ size_t handle_contacts_node(const IXMLNode::TXMLNodePtr& pXmlRoot,CImportContext& impctx)
+ {
+ size_t cContacts = 0;
+ size_t cChild = pXmlRoot->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ IXMLNode::TXMLNodePtr pNode = pXmlRoot->GetChildNode(i);
+ tstring sName = pNode->GetName();
+ if(0 == quotes_stricmp(g_pszXmlContacts,sName.c_str()))
+ {
+ cContacts += import_contacts(pNode,impctx);
+ }
+ else
+ {
+ cContacts += handle_contacts_node(pNode,impctx);
+ }
+ }
+
+ return cContacts;
+
+ }
+
+ bool do_import(const IXMLNode::TXMLNodePtr& pXmlRoot,UINT nFlags)
+ {
+ CImportContext imctx(count_contacts(pXmlRoot,false));
+ imctx.m_cHandledContacts = 0;
+ imctx.m_nFlags = nFlags;
+
+ return (handle_contacts_node(pXmlRoot,imctx) > 0);
+ }
+}
+
+INT_PTR Quotes_Import(WPARAM wp,LPARAM lp)
+{
+// USES_CONVERSION;
+
+ tstring sFileName;
+ const char* pszFile = reinterpret_cast<const char*>(lp);
+ if(NULL == pszFile)
+ {
+ if(false == show_open_file_dialog(true,sFileName))
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ sFileName = quotes_a2t(pszFile);//A2CT(pszFile);
+ }
+ CModuleInfo::TXMLEnginePtr pXmlEngine = CModuleInfo::GetInstance().GetXMLEnginePtr();
+ IXMLNode::TXMLNodePtr pXmlRoot = pXmlEngine->LoadFile(sFileName);
+ if(pXmlRoot)
+ {
+ return ((true == do_import(pXmlRoot,wp)) ? 0 : 1);
+ }
+
+ return 1;
+}
+
+#ifdef TEST_IMPORT_EXPORT
+INT_PTR QuotesMenu_ImportAll(WPARAM wp,LPARAM lp)
+{
+ return CallService(MS_QUOTES_IMPORT,0,0);
+}
+
+INT_PTR QuotesMenu_ExportAll(WPARAM wp,LPARAM lp)
+{
+ return CallService(MS_QUOTES_EXPORT,0,0);
+}
+#endif
+
diff --git a/plugins/Quotes/src/ImportExport.h b/plugins/Quotes/src/ImportExport.h new file mode 100644 index 0000000000..da2053e9a3 --- /dev/null +++ b/plugins/Quotes/src/ImportExport.h @@ -0,0 +1,11 @@ +#ifndef __F86374E6_713C_4600_85FB_903A5CDF7251_IMPORT_EXPORT_H__
+#define __F86374E6_713C_4600_85FB_903A5CDF7251_IMPORT_EXPORT_H__
+
+INT_PTR Quotes_Export(WPARAM wp,LPARAM lp);
+INT_PTR Quotes_Import(WPARAM wp,LPARAM lp);
+
+#ifdef TEST_IMPORT_EXPORT
+INT_PTR QuotesMenu_ImportAll(WPARAM wp,LPARAM lp);
+INT_PTR QuotesMenu_ExportAll(WPARAM wp,LPARAM lp);
+#endif
+#endif //__F86374E6_713C_4600_85FB_903A5CDF7251_IMPORT_EXPORT_H__
diff --git a/plugins/Quotes/src/IsWithinAccuracy.h b/plugins/Quotes/src/IsWithinAccuracy.h new file mode 100644 index 0000000000..5e39281719 --- /dev/null +++ b/plugins/Quotes/src/IsWithinAccuracy.h @@ -0,0 +1,15 @@ +#ifndef __C8C6FB80_D66B_4382_8FAB_E92C83F77BB8_IsWithinAcuracy_h__
+#define __C8C6FB80_D66B_4382_8FAB_E92C83F77BB8_IsWithinAcuracy_h__
+
+inline bool IsWithinAccuracy(double dValue1, double dValue2, double dAccuracy = 1e-4)
+{
+ double dDifference = dValue1 - dValue2 ;
+
+ if ((-dAccuracy <= dDifference) && (dDifference <= dAccuracy))
+ return true ;
+ else
+ return false ;
+}
+
+
+#endif //__C8C6FB80_D66B_4382_8FAB_E92C83F77BB8_IsWithinAcuracy_h__
diff --git a/plugins/Quotes/src/LightMutex.cpp b/plugins/Quotes/src/LightMutex.cpp new file mode 100644 index 0000000000..8d14e8e7bb --- /dev/null +++ b/plugins/Quotes/src/LightMutex.cpp @@ -0,0 +1,22 @@ +#include "StdAfx.h"
+#include "LightMutex.h"
+
+CLightMutex::CLightMutex()
+{
+ InitializeCriticalSection(&m_cs);
+}
+
+CLightMutex::~CLightMutex()
+{
+ ::DeleteCriticalSection(&m_cs);
+}
+
+void CLightMutex::Lock()
+{
+ ::EnterCriticalSection(&m_cs);
+}
+
+void CLightMutex::Unlock()
+{
+ ::LeaveCriticalSection(&m_cs);
+}
diff --git a/plugins/Quotes/src/LightMutex.h b/plugins/Quotes/src/LightMutex.h new file mode 100644 index 0000000000..e8c7363ba1 --- /dev/null +++ b/plugins/Quotes/src/LightMutex.h @@ -0,0 +1,34 @@ +#ifndef __a33da2bb_d4fe4aa7_aaf5_f9f8c3156ce6_LightMutex_h__
+#define __a33da2bb_d4fe4aa7_aaf5_f9f8c3156ce6_LightMutex_h__
+
+class CLightMutex
+{
+public:
+ CLightMutex();
+ ~CLightMutex();
+
+ void Lock();
+ void Unlock();
+
+private:
+ CRITICAL_SECTION m_cs;
+};
+
+template<class TObject> class CGuard
+{
+public:
+ CGuard(TObject& obj) : m_obj(obj)
+ {
+ m_obj.Lock();
+ }
+
+ ~CGuard()
+ {
+ m_obj.Unlock();
+ }
+
+private:
+ TObject& m_obj;
+};
+
+#endif //__a33da2bb_d4fe4aa7_aaf5_f9f8c3156ce6_LightMutex_h__
diff --git a/plugins/Quotes/src/Locale.cpp b/plugins/Quotes/src/Locale.cpp new file mode 100644 index 0000000000..c01f67148a --- /dev/null +++ b/plugins/Quotes/src/Locale.cpp @@ -0,0 +1,75 @@ +#include "StdAfx.h"
+#include "Locale.h"
+
+const std::locale GetSystemLocale()
+{
+ return std::locale("");
+}
+
+namespace
+{
+ tstring get_int_registry_value(LPCTSTR pszValueName)
+ {
+ tstring sResult;
+ HKEY hKey = NULL;
+ LONG lResult = ::RegOpenKeyEx(HKEY_CURRENT_USER,
+ _T("Control Panel\\International"),0,KEY_QUERY_VALUE,&hKey);
+ if ((ERROR_SUCCESS == lResult) && (NULL != hKey))
+ {
+ DWORD dwType = 0;
+ DWORD dwSize = 0;
+ lResult = ::RegQueryValueEx(hKey,pszValueName,nullptr,&dwType,nullptr,&dwSize);
+ if ((ERROR_SUCCESS == lResult) && ((REG_SZ == dwType) || (REG_EXPAND_SZ == dwType)))
+ {
+ std::vector<TCHAR> aBuffer(dwSize);
+ lResult = ::RegQueryValueEx(hKey,pszValueName,nullptr,nullptr,reinterpret_cast<LPBYTE>(&*aBuffer.begin()),&dwSize);
+ if(ERROR_SUCCESS == lResult)
+ {
+ std::copy(aBuffer.begin(),aBuffer.end(),std::back_inserter(sResult));
+ }
+ }
+ }
+
+ if(NULL != hKey)
+ {
+ lResult = ::RegCloseKey(hKey);
+ assert(ERROR_SUCCESS == lResult);
+ }
+
+ return sResult;
+ }
+
+ tstring date_win_2_boost(const tstring& sFrmt)
+ {
+ tstring sResult(_T("%d.%m.%y"));
+ if(sFrmt == _T("dd/MM/yy"))
+ {
+ sResult = _T("%d/%m/%y");
+ }
+ else if(sFrmt == _T("yyyy-MM-dd"))
+ {
+ sResult = _T("%y-%m-%d");
+ }
+ return sResult;
+ }
+
+ tstring time_win_2_boost(const tstring& sFrmt)
+ {
+ tstring sResult = _T("%H:%M:%S");
+ if(sFrmt == _T("H:mm") || sFrmt == _T("HH:mm"))
+ {
+ sResult = _T("%H:%M");
+ }
+ return sResult;
+ }
+}
+
+tstring Quotes_GetDateFormat(bool bShort)
+{
+ return date_win_2_boost(get_int_registry_value(bShort ? _T("sShortDate") : _T("sLongDate")));
+}
+
+tstring Quotes_GetTimeFormat(bool bShort)
+{
+ return time_win_2_boost(get_int_registry_value(bShort ? _T("sShortTime") : _T("sTimeFormat")));
+}
\ No newline at end of file diff --git a/plugins/Quotes/src/Locale.h b/plugins/Quotes/src/Locale.h new file mode 100644 index 0000000000..92d3a56ed4 --- /dev/null +++ b/plugins/Quotes/src/Locale.h @@ -0,0 +1,9 @@ +#ifndef __11f7afd0_5a66_4029_8bf3_e3c66346b349_Locale_h_
+#define __11f7afd0_5a66_4029_8bf3_e3c66346b349_Locale_h_
+
+// std::string GetLocaleInfoString(LCTYPE LCType,LCID Locale = LOCALE_USER_DEFAULT);
+const std::locale GetSystemLocale();
+tstring Quotes_GetDateFormat(bool bShort);
+tstring Quotes_GetTimeFormat(bool bShort);
+
+#endif //__11f7afd0_5a66_4029_8bf3_e3c66346b349_Locale_h_
diff --git a/plugins/Quotes/src/Log.cpp b/plugins/Quotes/src/Log.cpp new file mode 100644 index 0000000000..d692763bad --- /dev/null +++ b/plugins/Quotes/src/Log.cpp @@ -0,0 +1,56 @@ +#include "StdAfx.h"
+#include "Log.h"
+#include "LightMutex.h"
+#include "EconomicRateInfo.h"
+#include "CreateFilePath.h"
+
+namespace
+{
+ CLightMutex g_Mutex;
+
+ tstring get_log_file_name()
+ {
+ return CreateFilePath(_T("Quotes.log"));
+ }
+
+ bool is_log_enabled()
+ {
+#ifdef _DEBUG
+ return true;
+#else
+ return (1 == DBGetContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,DB_STR_ENABLE_LOG,false));
+#endif
+ }
+
+ void do_log(const tstring& rsFileName,ESeverity nSeverity,const tstring& rsMsg)
+ {
+ CGuard<CLightMutex> guard(g_Mutex);
+ tofstream file(rsFileName.c_str(),std::ios::ate|std::ios::app);
+ if(file.good())
+ {
+ TCHAR szTime[20];
+// TCHAR sz[10000+1];
+ _tstrtime_s(szTime);
+ file << szTime << _T(" ================================>\n") << rsMsg << _T("\n\n");
+
+// size_t cBytes = rsMsg.size();
+// const TCHAR* p = rsMsg.c_str();
+// for(size_t c = 0;c < cBytes;c += 10000,p+=10000)
+// {
+// _tcsncpy_s(sz,p,10000);
+// file << sz;
+// }
+//
+// file << "\n\n";
+ }
+ }
+}
+
+void LogIt(ESeverity nSeverity,const tstring& rsMsg)
+{
+ if(is_log_enabled())
+ {
+ tstring sFileName = get_log_file_name();
+ do_log(sFileName,nSeverity,rsMsg);
+ }
+}
diff --git a/plugins/Quotes/src/Log.h b/plugins/Quotes/src/Log.h new file mode 100644 index 0000000000..274fcfec06 --- /dev/null +++ b/plugins/Quotes/src/Log.h @@ -0,0 +1,13 @@ +#ifndef __653719be_16d6_4058_8555_8aa7d5404214_OutputDlg_h__
+#define __653719be_16d6_4058_8555_8aa7d5404214_OutputDlg_h__
+
+enum ESeverity
+{
+ Info,
+ Warning,
+ Error
+};
+
+void LogIt(ESeverity nSeverity,const tstring& rsMsg);
+
+#endif //__653719be_16d6_4058_8555_8aa7d5404214_OutputDlg_h__
diff --git a/plugins/Quotes/src/ModuleInfo.cpp b/plugins/Quotes/src/ModuleInfo.cpp new file mode 100644 index 0000000000..4caec96368 --- /dev/null +++ b/plugins/Quotes/src/ModuleInfo.cpp @@ -0,0 +1,135 @@ +#include "StdAfx.h"
+#include "ModuleInfo.h"
+#include "QuotesProviders.h"
+#include "HTMLParserMS.h"
+#include "LightMutex.h"
+#include "WinCtrlHelper.h"
+#include "EconomicRateInfo.h"
+#include "XMLEngineMI.h"
+
+namespace
+{
+ CModuleInfo::TXMLEnginePtr g_pXMLEngine;
+ CModuleInfo::THTMLEnginePtr g_pHTMLEngine;
+ CLightMutex g_lmParsers;
+}
+
+CModuleInfo::CModuleInfo()
+ : m_bExtendedStatusInfo(1 == DBGetContactSettingByte(NULL,QUOTES_MODULE_NAME,"ExtendedStatus",false))
+{
+}
+
+CModuleInfo::~CModuleInfo()
+{
+}
+
+CModuleInfo& CModuleInfo::GetInstance()
+{
+ static CModuleInfo mi;
+ return mi;
+}
+
+HANDLE CModuleInfo::GetWindowList(const std::string& rsKey,bool bAllocateIfNonExist /*= true*/)
+{
+ HANDLE hResult = NULL;
+ THandles::const_iterator i = m_ahWindowLists.find(rsKey);
+ if(i != m_ahWindowLists.end())
+ {
+ hResult = i->second;
+ }
+ else if(bAllocateIfNonExist)
+ {
+ hResult = reinterpret_cast<HANDLE>(CallService(MS_UTILS_ALLOCWINDOWLIST,0,0));
+ if(hResult)
+ {
+ m_ahWindowLists.insert(std::make_pair(rsKey,hResult));
+ }
+ }
+
+ return hResult;
+}
+
+void CModuleInfo::OnMirandaShutdown()
+{
+ BOOST_FOREACH(THandles::value_type p,m_ahWindowLists)
+ {
+ WindowList_Broadcast(p.second,WM_CLOSE,0,0);
+ }
+}
+
+CModuleInfo::TQuotesProvidersPtr CModuleInfo::GetQuoteProvidersPtr()
+{
+ static TQuotesProvidersPtr pProviders(new CQuotesProviders);
+ return pProviders;
+}
+
+CModuleInfo::TXMLEnginePtr CModuleInfo::GetXMLEnginePtr()
+{
+ if (!g_pXMLEngine)
+ {
+ CGuard<CLightMutex> cs(g_lmParsers);
+ if (!g_pXMLEngine)
+ {
+ mir_getXI(&xi);
+ g_pXMLEngine = TXMLEnginePtr(new CXMLEngineMI);
+ }
+ }
+
+ return g_pXMLEngine;
+}
+
+// void CModuleInfo::SetXMLEnginePtr(TXMLEnginePtr pEngine)
+// {
+// g_pXMLEngine = pEngine;
+// }
+
+CModuleInfo::THTMLEnginePtr CModuleInfo::GetHTMLEngine()
+{
+ if (!g_pHTMLEngine)
+ {
+ CGuard<CLightMutex> cs(g_lmParsers);
+ if (!g_pHTMLEngine)
+ {
+ g_pHTMLEngine = THTMLEnginePtr(new CHTMLEngineMS);
+ }
+ }
+
+ return g_pHTMLEngine;
+}
+
+void CModuleInfo::SetHTMLEngine(THTMLEnginePtr pEngine)
+{
+ g_pHTMLEngine = pEngine;
+}
+
+bool CModuleInfo::Verify()
+{
+ INITCOMMONCONTROLSEX icc = {0};
+ icc.dwSize = sizeof(icc);
+ icc.dwICC = ICC_WIN95_CLASSES|ICC_LINK_CLASS;
+ if(FALSE == ::InitCommonControlsEx(&icc))
+ {
+ return false;
+ }
+
+ if (!GetXMLEnginePtr())
+ {
+ Quotes_MessageBox(NULL,TranslateT("Miranda could not load Quotes plugin. XML parser is missing."),MB_OK|MB_ICONERROR);
+ return false;
+ }
+
+ if (!g_pHTMLEngine && (false == CHTMLParserMS::IsInstalled()))
+ {
+ Quotes_MessageBox(NULL,
+ TranslateT("Miranda could not load Quotes plugin. Microsoft HTML parser is missing."),
+ MB_YESNO|MB_ICONQUESTION);
+ return false;
+ }
+
+ return true;
+}
+
+bool CModuleInfo::GetExtendedStatusFlag()const
+{
+ return m_bExtendedStatusInfo;
+}
diff --git a/plugins/Quotes/src/ModuleInfo.h b/plugins/Quotes/src/ModuleInfo.h new file mode 100644 index 0000000000..2882dfae6d --- /dev/null +++ b/plugins/Quotes/src/ModuleInfo.h @@ -0,0 +1,43 @@ +#ifndef __d0f22b66_3135_4bbe_bee5_a31ea631ce58_ModuleInfo__
+#define __d0f22b66_3135_4bbe_bee5_a31ea631ce58_ModuleInfo__
+
+class CQuotesProviders;
+class IXMLEngine;
+class IHTMLEngine;
+// class IHTMLParser;
+
+class CModuleInfo
+{
+public:
+ typedef boost::shared_ptr<CQuotesProviders> TQuotesProvidersPtr;
+ typedef boost::shared_ptr<IXMLEngine> TXMLEnginePtr;
+ typedef boost::shared_ptr<IHTMLEngine> THTMLEnginePtr;
+
+private:
+ CModuleInfo();
+ ~CModuleInfo(void);
+
+public:
+ static CModuleInfo& GetInstance();
+
+ void OnMirandaShutdown();
+ HANDLE GetWindowList(const std::string& rsKey,bool bAllocateIfNonExist = true);
+ bool GetExtendedStatusFlag()const;
+
+ static bool Verify();
+
+ static TQuotesProvidersPtr GetQuoteProvidersPtr();
+
+ static TXMLEnginePtr GetXMLEnginePtr();
+// static void SetXMLEnginePtr(TXMLEnginePtr pEngine);
+
+ static THTMLEnginePtr GetHTMLEngine();
+ static void SetHTMLEngine(THTMLEnginePtr pEngine);
+
+private:
+ typedef std::map<std::string,HANDLE> THandles;
+ THandles m_ahWindowLists;
+ bool m_bExtendedStatusInfo;
+};
+
+#endif //__d0f22b66_3135_4bbe_bee5_a31ea631ce58_ModuleInfo__
diff --git a/plugins/Quotes/src/OptionDukasCopy.cpp b/plugins/Quotes/src/OptionDukasCopy.cpp new file mode 100644 index 0000000000..6fcc542b09 --- /dev/null +++ b/plugins/Quotes/src/OptionDukasCopy.cpp @@ -0,0 +1,414 @@ +#include "StdAfx.h"
+#include "OptionDukasCopy.h"
+#include "IconLib.h"
+#include "ModuleInfo.h"
+#include "QuotesProviders.h"
+#include "QuotesProviderDukasCopy.h"
+#include "resource.h"
+#include "EconomicRateInfo.h"
+#include "CommonOptionDlg.h"
+
+// extern HANDLE g_hEventSettingsCnanged;
+
+namespace
+{
+ enum ETreeCheckBoxState
+ {
+ // tree check box state
+ TCBS_NOSTATEBOX = 0,
+ TCBS_UNCHECKED = 1,
+ TCBS_CHECKED = 2,
+ };
+
+ enum
+ {
+ TREE_VIEW_CHECK_STATE_CHANGE = WM_USER + 100,
+ IMAGE_INDEX_SECTION = 0,
+ IMAGE_INDEX_QUOTE = 1
+ };
+
+ // typedef CQuotesProviders::TQuotesProviders TQuotesProviders;
+ // typedef CQuotesProviders::TQuotesProviderPtr TQuotesProviderPtr;
+
+ HTREEITEM tree_insert_item(HWND hwndTree,
+ const tstring& rsName,
+ HTREEITEM htiParent,
+ int nImage,
+ LPARAM lp = 0)
+ {
+// USES_CONVERSION;
+ TVINSERTSTRUCT tvi;
+ ZeroMemory(&tvi,sizeof(tvi));
+
+ tvi.hParent = htiParent;
+ tvi.hInsertAfter = TVI_LAST;
+ tvi.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+
+// CA2T name(rsName.c_str());
+
+ tvi.item.pszText = const_cast<LPTSTR>(rsName.c_str());//name;
+ tvi.item.lParam = lp;
+ tvi.item.iImage = nImage;
+ tvi.item.iSelectedImage = nImage;
+ return TreeView_InsertItem(hwndTree,&tvi);
+ }
+
+ bool add_quote_to_tree(const CQuotesProviderDukasCopy::CQuote& q,HWND hwndTree,HTREEITEM htiParent,const CQuotesProviderDukasCopy* pQuotesProvier)
+ {
+ bool bChecked = pQuotesProvier->IsQuoteWatched(q);
+ HTREEITEM hti = tree_insert_item(hwndTree,((false == q.GetName().empty()) ? q.GetName() : q.GetSymbol()),htiParent,IMAGE_INDEX_QUOTE);
+ if(hti && bChecked)
+ {
+ HWND hDlg = ::GetParent(hwndTree);
+ assert(::IsWindow(hDlg));
+ ::PostMessage(hDlg,TREE_VIEW_CHECK_STATE_CHANGE,MAKEWPARAM(0,TCBS_CHECKED),reinterpret_cast<LPARAM>(hti));
+ }
+
+ return (NULL != hti && bChecked);
+ }
+
+ void add_section_to_tree(const CQuotesProviderDukasCopy::CQuoteSection& qs,
+ HWND hwndTree,
+ HTREEITEM htiParent,
+ const CQuotesProviderDukasCopy* pQuotesProvier,
+ bool& rbIsChecked,
+ bool& rbIsExpended,
+ bool bExpand = false)
+ {
+ rbIsChecked = false;
+ rbIsExpended = false;
+ HTREEITEM hti = tree_insert_item(hwndTree,qs.GetName(),htiParent,IMAGE_INDEX_SECTION);
+
+ size_t cCheckedItems = 0;
+ size_t cSection = qs.GetSectionCount();
+ for(size_t i = 0;i < cSection;++i)
+ {
+ bool bIsChecked = false;
+ bool bIsExpanded = false;
+ CQuotesProviderDukasCopy::CQuoteSection other = qs.GetSection(i);
+ add_section_to_tree(other,hwndTree,hti,pQuotesProvier,bIsChecked,bIsExpanded);
+
+ if(bIsChecked)
+ {
+ ++cCheckedItems;
+ }
+
+ if(bIsExpanded)
+ {
+ bExpand = true;
+ }
+ }
+
+ size_t cQuotes = qs.GetQuoteCount();
+ for(size_t i = 0;i < cQuotes;++i)
+ {
+ CQuotesProviderDukasCopy::CQuote q = qs.GetQuote(i);
+ if(true == add_quote_to_tree(q,hwndTree,hti,pQuotesProvier))
+ {
+ ++ cCheckedItems;
+ }
+ }
+
+ if(bExpand || cCheckedItems > 0)
+ {
+ rbIsExpended = true;
+ TreeView_Expand(hwndTree,hti,TVE_EXPAND);
+ }
+
+ if(cCheckedItems == (cSection+cQuotes))
+ {
+ rbIsChecked = true;
+ HWND hDlg = ::GetParent(hwndTree);
+ assert(::IsWindow(hDlg));
+ ::PostMessage(hDlg,TREE_VIEW_CHECK_STATE_CHANGE,MAKEWPARAM(0,TCBS_CHECKED),reinterpret_cast<LPARAM>(hti));
+ }
+ }
+
+ void add_provider_to_tree(const CQuotesProviderDukasCopy* pQuotesProvier,HWND hwndTree)
+ {
+ CQuotesProviderDukasCopy::CQuoteSection qs = pQuotesProvier->GetQuotes();
+ bool bIsChecked = false;
+ bool bIsExpanded = false;
+ add_section_to_tree(qs,hwndTree,TVI_ROOT,pQuotesProvier,bIsChecked,bIsExpanded,true);
+ }
+
+ inline HTREEITEM tree_get_child_item(HWND hwndTree,HTREEITEM hti)
+ {
+ return reinterpret_cast<HTREEITEM>(::SendMessage(hwndTree, TVM_GETNEXTITEM, TVGN_CHILD,reinterpret_cast<LPARAM>(hti)));
+ }
+
+ inline HTREEITEM tree_get_next_sibling_item(HWND hwndTree,HTREEITEM hti)
+ {
+ return reinterpret_cast<HTREEITEM>(::SendMessage(hwndTree, TVM_GETNEXTITEM, TVGN_NEXT,reinterpret_cast<LPARAM>(hti)));
+ }
+
+ inline ETreeCheckBoxState tree_get_state_image(HWND hwndTree,HTREEITEM hti)
+ {
+ TVITEM tvi;
+ tvi.hItem = hti;
+ tvi.mask = TVIF_STATE|TVIF_HANDLE;
+ tvi.stateMask = TVIS_STATEIMAGEMASK;
+ if(TRUE == ::SendMessage(hwndTree,TVM_GETITEM,0,reinterpret_cast<LPARAM>(&tvi)))
+ {
+ UINT nState = (tvi.state >> 12);
+ return static_cast<ETreeCheckBoxState>(nState);
+ }
+ else
+ {
+ return TCBS_UNCHECKED;
+ }
+ }
+
+ void tree_do_set_item_state(HWND hwndTree,HTREEITEM hti,ETreeCheckBoxState nState)
+ {
+ TVITEM tvi;
+ ZeroMemory(&tvi,sizeof(tvi));
+
+ tvi.mask = TVIF_STATE|TVIF_HANDLE;
+ tvi.hItem = hti;
+
+ tvi.stateMask = TVIS_STATEIMAGEMASK;
+ tvi.state = INDEXTOSTATEIMAGEMASK(nState);
+
+ ::SendMessage(hwndTree,TVM_SETITEM,0,reinterpret_cast<LPARAM>(&tvi));
+ }
+
+ void tree_set_item_state(HWND hwndTree,HTREEITEM hti,ETreeCheckBoxState nState,bool bRecursively)
+ {
+ if(true == bRecursively)
+ {
+ for(hti = tree_get_child_item(hwndTree,hti);hti;hti = tree_get_next_sibling_item(hwndTree,hti))
+ {
+ tree_do_set_item_state(hwndTree,hti,nState);
+ tree_set_item_state(hwndTree,hti,nState,bRecursively);
+ }
+ }
+ else
+ {
+ tree_do_set_item_state(hwndTree,hti,nState);
+ }
+ }
+
+ void save_quote_selection(HWND hwndTree,HTREEITEM h,const CQuotesProviderDukasCopy::CQuote& q,CQuotesProviderDukasCopy* pQuotesProvier)
+ {
+ ETreeCheckBoxState nState = tree_get_state_image(hwndTree,h);
+ pQuotesProvier->WatchForQuote(q,(TCBS_CHECKED == nState));
+ }
+
+ void recursive_save_quote_section_selection(HWND hwndTree,HTREEITEM h,const CQuotesProviderDukasCopy::CQuoteSection& qs,CQuotesProviderDukasCopy* pQuotesProvier)
+ {
+ size_t cSection = qs.GetSectionCount();
+ h = tree_get_child_item(hwndTree,h);
+ for(size_t i = 0;h && (i < cSection);++i,h = tree_get_next_sibling_item(hwndTree,h))
+ {
+ CQuotesProviderDukasCopy::CQuoteSection other = qs.GetSection(i);
+ recursive_save_quote_section_selection(hwndTree,h,other,pQuotesProvier);
+ }
+
+ size_t cQuotes = qs.GetQuoteCount();
+ for(size_t i = 0;h && (i < cQuotes);++i,h = tree_get_next_sibling_item(hwndTree,h))
+ {
+ CQuotesProviderDukasCopy::CQuote q = qs.GetQuote(i);
+ save_quote_selection(hwndTree,h,q,pQuotesProvier);
+ }
+ }
+
+ void recursive_save_selection(HWND hwndTree,CQuotesProviderDukasCopy* pQuotesProvider)
+ {
+ // CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr();
+ // const TQuotesProviders& rapQuotesProviders = pProviders->GetProviders();
+ //
+ // TQuotesProviders::const_iterator i = rapQuotesProviders.begin();
+ // TQuotesProviders::const_iterator iE = rapQuotesProviders.end();
+ // for(HTREEITEM h = tree_get_child_item(hwndTree,TVI_ROOT);h && (i!=iE);++i,h = tree_get_next_sibling_item(hwndTree,h))
+ // {
+ // const TQuotesProviderPtr& pQuotesProvier = *i;
+ CQuotesProviderDukasCopy::CQuoteSection qs = pQuotesProvider->GetQuotes();
+ recursive_save_quote_section_selection(hwndTree,tree_get_child_item(hwndTree,TVI_ROOT),qs,pQuotesProvider);
+ // }
+ }
+
+ class CImageListWrapper
+ {
+ public:
+ CImageListWrapper()
+ : m_hImageList(ImageList_Create(::GetSystemMetrics(SM_CXSMICON),
+ ::GetSystemMetrics(SM_CYSMICON),
+ ILC_COLOR24|ILC_MASK,2,0))
+ {
+ if(m_hImageList)
+ {
+ ImageList_AddIcon(m_hImageList,Quotes_LoadIconEx(ICON_STR_SECTION));
+ ImageList_AddIcon(m_hImageList,Quotes_LoadIconEx(ICON_STR_QUOTE));
+ }
+ }
+
+ ~CImageListWrapper()
+ {
+ if(m_hImageList)
+ {
+ ImageList_Destroy(m_hImageList);
+ }
+ }
+
+ operator HIMAGELIST()const
+ {
+ return m_hImageList;
+ }
+
+ private:
+ HIMAGELIST m_hImageList;
+ };
+
+ HIMAGELIST get_image_list()
+ {
+ static CImageListWrapper wrapper;
+ return wrapper;
+ }
+
+ CQuotesProviderDukasCopy* get_dukas_copy_provider()
+ {
+ CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr();
+ const CQuotesProviders::TQuotesProviders& rapQuotesProviders = pProviders->GetProviders();
+ for(CQuotesProviders::TQuotesProviders::const_iterator i = rapQuotesProviders.begin();i != rapQuotesProviders.end();++i)
+ {
+ const CQuotesProviders::TQuotesProviderPtr& pProvider = *i;
+ CQuotesProviderDukasCopy* pDukas = dynamic_cast<CQuotesProviderDukasCopy*>(pProvider.get());
+ if(pDukas)
+ {
+ return pDukas;
+ }
+ }
+
+ assert(!"We should never get here!");
+ return NULL;
+ }
+
+ INT_PTR CALLBACK EconomicRatesDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam)
+ {
+ CCommonDlgProcData d(get_dukas_copy_provider());
+ CommonOptionDlgProc(hdlg,message,wParam,lParam,d);
+
+ switch(message)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hdlg);
+
+ HWND hwndTree = ::GetDlgItem(hdlg,IDC_TREE_ECONOMIC_RATES);
+ HIMAGELIST hImage = get_image_list();
+ if(hImage)
+ {
+ TreeView_SetImageList(hwndTree,hImage,TVSIL_NORMAL);
+ }
+
+ const CQuotesProviderDukasCopy* pDukasProvider = get_dukas_copy_provider();
+ if(pDukasProvider)
+ {
+ add_provider_to_tree(pDukasProvider,hwndTree);
+ }
+ // Window_SetIcon_IcoLib(hdlg, SKINICON_OTHER_MIRANDA);
+ }
+ return TRUE;
+
+ case WM_NOTIFY:
+ {
+ LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lParam);
+ switch(pNMHDR->code)
+ {
+ case TVN_KEYDOWN:
+ if(IDC_TREE_ECONOMIC_RATES == wParam)
+ {
+ LPNMTVKEYDOWN pKeyDown = reinterpret_cast<LPNMTVKEYDOWN>(lParam);
+ if(VK_SPACE == pKeyDown->wVKey)
+ {
+ HTREEITEM hti = TreeView_GetSelection(::GetDlgItem(hdlg,IDC_TREE_ECONOMIC_RATES));
+ ::PostMessage(hdlg,TREE_VIEW_CHECK_STATE_CHANGE,MAKEWPARAM(1,0),reinterpret_cast<LPARAM>(hti));
+ PropSheet_Changed(::GetParent(hdlg),hdlg);
+ }
+ }
+ break;
+ case NM_CLICK:
+ if(IDC_TREE_ECONOMIC_RATES == wParam)
+ {
+ DWORD pos = ::GetMessagePos();
+
+ HWND hwndTree = ::GetDlgItem(hdlg,IDC_TREE_ECONOMIC_RATES);
+
+ TVHITTESTINFO tvhti;
+ tvhti.pt.x = LOWORD(pos);
+ tvhti.pt.y = HIWORD(pos);
+ ::ScreenToClient(hwndTree,&(tvhti.pt));
+
+ HTREEITEM hti = reinterpret_cast<HTREEITEM>(::SendMessage(hwndTree,TVM_HITTEST,0,reinterpret_cast<LPARAM>(&tvhti)));
+ if(hti && (tvhti.flags&TVHT_ONITEMSTATEICON))
+ {
+ ::PostMessage(hdlg,TREE_VIEW_CHECK_STATE_CHANGE,MAKEWPARAM(1,0),reinterpret_cast<LPARAM>(hti));
+ PropSheet_Changed(::GetParent(hdlg),hdlg);
+ }
+ }
+ break;
+ case PSN_APPLY:
+ {
+ CQuotesProviderDukasCopy* pDukasProvider = get_dukas_copy_provider();
+ if(pDukasProvider)
+ {
+ recursive_save_selection(::GetDlgItem(hdlg,IDC_TREE_ECONOMIC_RATES),pDukasProvider);
+ pDukasProvider->RefreshAll();
+ }
+ }
+ break;
+ }
+ }
+ return TRUE;
+
+ case TREE_VIEW_CHECK_STATE_CHANGE:
+ {
+ HWND hwndTree = ::GetDlgItem(hdlg,IDC_TREE_ECONOMIC_RATES);
+ HTREEITEM hti = reinterpret_cast<HTREEITEM>(lParam);
+
+ ETreeCheckBoxState nState;
+
+ bool bRecursively = 1 == LOWORD(wParam);
+ if(bRecursively)
+ {
+ nState = tree_get_state_image(hwndTree,hti);
+ }
+ else
+ {
+ nState = static_cast<ETreeCheckBoxState>(HIWORD(wParam));
+ }
+
+ tree_set_item_state(hwndTree,hti,nState,bRecursively);
+ }
+ break;
+ // case WM_CLOSE:
+ // DestroyWindow(hdlg);
+ // break;
+ // case WM_DESTROY:
+ // g_hwndEconomicRates = NULL;
+ // break;
+ }
+
+ return FALSE;
+ }
+}
+
+void ShowDukasCopyPropPage(CQuotesProviderDukasCopy* pProvider,WPARAM wp,OPTIONSDIALOGPAGE& odp)
+{
+ const IQuotesProvider::CProviderInfo& pi = pProvider->GetInfo();
+
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_ECONOMIC_RATES);
+ odp.pfnDlgProc = EconomicRatesDlgProc;
+// #if MIRANDA_VER >= 0x0600
+ //odp.ptszTab = TranslateTS(const_cast<LPTSTR>(pi.m_sName.c_str()));
+ odp.ptszTab = const_cast<LPTSTR>(pi.m_sName.c_str());
+// #else
+// tostringstream o;
+// o << TranslateTS(QUOTES_PROTOCOL_NAME) << _T(" - ") << TranslateTS(pi.m_sName.c_str());
+// tstring sTitle = o.str();
+// odp.ptszTitle = TranslateTS(const_cast<LPTSTR>(sTitle.c_str()));
+// #endif
+
+ Options_AddPage(wp, &odp);
+}
diff --git a/plugins/Quotes/src/OptionDukasCopy.h b/plugins/Quotes/src/OptionDukasCopy.h new file mode 100644 index 0000000000..0674119e83 --- /dev/null +++ b/plugins/Quotes/src/OptionDukasCopy.h @@ -0,0 +1,8 @@ +#ifndef __60a5d152_872c_4bc4_b9ae_cd561d110b2dOptionDukasCopy_h__
+#define __60a5d152_872c_4bc4_b9ae_cd561d110b2dOptionDukasCopy_h__
+
+class CQuotesProviderDukasCopy;
+
+void ShowDukasCopyPropPage(CQuotesProviderDukasCopy* pProvider,WPARAM wp,OPTIONSDIALOGPAGE& odp);
+
+#endif //__60a5d152_872c_4bc4_b9ae_cd561d110b2dOptionDukasCopy_h__
diff --git a/plugins/Quotes/src/QuoteChart.cpp b/plugins/Quotes/src/QuoteChart.cpp new file mode 100644 index 0000000000..3746540d23 --- /dev/null +++ b/plugins/Quotes/src/QuoteChart.cpp @@ -0,0 +1,408 @@ +#include "StdAfx.h"
+#include "QuoteChart.h"
+
+#ifdef CHART_IMPLEMENT
+
+// #include "QuotesProviderDukasCopy.h"
+// #include "QuotesProviders.h"
+#include "ModuleInfo.h"
+#include "EconomicRateInfo.h"
+// #include "WinCtrlHelper.h"
+#include "resource.h"
+#include "DBUtils.h"
+#include "Locale.h"
+#include "SettingsDlg.h"
+#include "Chart.h"
+#include "WinCtrlHelper.h"
+
+#define WINDOW_PREFIX "Quotes Chart_"
+#define CHART_CTRL_CLASS _T("DioksinChart")
+
+namespace
+{
+ struct CTimeConvert
+ {
+ static double Convert(const boost::posix_time::time_duration& v)
+ {
+ return boost::numeric_cast<double>(v.ticks());
+ }
+
+ static tstring ToString(const boost::posix_time::ptime& v)
+ {
+ tostringstream k;
+ k.imbue(std::locale(GetSystemLocale(),new ttime_facet(_T("%d/%m/%y %H:%M:%S"))));
+ k << v;
+ return k.str();
+ }
+ };
+
+ typedef CChart<boost::posix_time::ptime,double,CTimeConvert> TChart;
+
+ inline TChart* get_chart_ptr(HWND hWnd)
+ {
+ TChart* pChart = reinterpret_cast<TChart*>(GetWindowLongPtr(hWnd,GWLP_USERDATA));
+ return pChart;
+ }
+
+ bool read_log_file(HANDLE hContact,TChart& rChart)
+ {
+ tstring sLogFileName = GetContactLogFileName(hContact);
+ if(false == sLogFileName.empty())
+ {
+ std::locale loc(GetSystemLocale(),new ttime_input_facet(_T("%d.%m.%y %H:%M:%S")));
+ boost::posix_time::ptime oDateTime;
+ double dRate;
+
+ tifstream file(sLogFileName.c_str());
+ file.imbue(loc);
+ while((false == file.fail()) && (false == file.eof()))
+ {
+ tstring sLine;
+ std::getline(file,sLine);
+
+ tistringstream line(sLine);
+ line.imbue(loc);
+
+ tstring sName;
+ std::getline(line,sName,_T('\t'));
+ line >> oDateTime >> dRate;
+ if ((false == line.fail()) && (true == line.eof()))
+ {
+ rChart.AddValue(oDateTime,dRate);
+ }
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+
+ enum
+ {
+ ID_CHART = 0x1969,
+
+ srcLogFile = 0,
+ srcHistory = 1,
+
+ filterAll = 0,
+ filterLastDay = 1,
+ filterLastWeek = 2,
+ filterLastMonth = 3,
+ filterLastYear = 4,
+ filterUserDefined = 5,
+
+ CHART_SET_SOURCE = WM_USER + 1,
+ CHART_SET_FILTER = WM_USER + 2,
+ };
+
+ LRESULT CALLBACK ChartWndProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp)
+ {
+ switch(msg)
+ {
+ case WM_CREATE:
+ {
+ CREATESTRUCT* pCS = reinterpret_cast<CREATESTRUCT*>(lp);
+ HANDLE hContact = reinterpret_cast<HANDLE>(pCS->lpCreateParams);
+
+ TChart* pChart = new TChart;
+ read_log_file(hContact,*pChart);
+
+ ::SetWindowLongPtr(hWnd,GWLP_USERDATA,reinterpret_cast<LONG_PTR>(pChart));
+ }
+ return 0;
+
+ case CHART_SET_SOURCE:
+ break;
+
+ case CHART_SET_FILTER:
+ break;
+
+ case WM_SIZE:
+ {
+ TChart* pChart = get_chart_ptr(hWnd);
+ pChart->SetRect(0,0,LOWORD(lp),HIWORD(lp));
+ }
+ return 0;
+
+ case WM_PAINT:
+ if(TRUE == ::GetUpdateRect(hWnd,NULL,FALSE))
+ {
+ PAINTSTRUCT ps;
+ HDC hdc = ::BeginPaint(hWnd,&ps);
+ if(NULL != hdc)
+ {
+ TChart* pChart = get_chart_ptr(hWnd);
+ pChart->Draw(hdc);
+ ::EndPaint(hWnd,&ps);
+ }
+ }
+
+ return 0;
+ case WM_DESTROY:
+ {
+ TChart* pChart = get_chart_ptr(hWnd);
+ ::SetWindowLongPtr(hWnd,GWLP_USERDATA,NULL);
+ delete pChart;
+ }
+ break;
+ }
+
+ return ::DefWindowProc(hWnd,msg,wp,lp);
+ }
+
+ void register_chart_control()
+ {
+ static bool g_bRegister = false;
+ if(g_bRegister)
+ {
+ return;
+ }
+
+ WNDCLASS wc;
+
+ wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.lpfnWndProc = ChartWndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = CModuleInfo::GetInstance().GetModuleHandle();
+ wc.hIcon = NULL;
+ wc.hCursor = LoadCursor(NULL,IDC_ARROW);
+ wc.hbrBackground = static_cast<HBRUSH>(::GetStockObject(WHITE_BRUSH));
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = CHART_CTRL_CLASS;
+
+ if(RegisterClass(&wc))
+ {
+ g_bRegister = true;
+ }
+ }
+
+
+ bool screen_2_client(HWND hWnd,LPRECT pRect)
+ {
+ POINT pt;
+ pt.x = pRect->left;
+ pt.y = pRect->top;
+ bool bResult = TRUE == ::ScreenToClient(hWnd,&pt);
+ pRect->left = pt.x;
+ pRect->top = pt.y;
+ pt.x = pRect->right;
+ pt.y = pRect->bottom;
+ bResult |= TRUE == ::ScreenToClient(hWnd,&pt);
+ pRect->right = pt.x;
+ pRect->bottom = pt.y;
+ return bResult;
+ }
+
+ inline HANDLE get_contact(HWND hWnd)
+ {
+ HANDLE hContact = reinterpret_cast<HANDLE>(GetWindowLongPtr(hWnd,GWLP_USERDATA));
+ return hContact;
+ }
+
+ void update_filter_controls(HWND hDlg)
+ {
+ int nSel = ::SendDlgItemMessage(hDlg,IDC_COMBO_FILTER,CB_GETCURSEL,0,0);
+
+ ::ShowWindow(::GetDlgItem(hDlg,IDC_EDIT_FROM),(filterUserDefined == nSel) ? SW_SHOW : SW_HIDE);
+ ::ShowWindow(::GetDlgItem(hDlg,IDC_EDIT_TO),(filterUserDefined == nSel) ? SW_SHOW : SW_HIDE);
+ }
+
+ INT_PTR CALLBACK ChartDlgProc(HWND hDlg,UINT msg,WPARAM wp,LPARAM lp)
+ {
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ HANDLE hContact = reinterpret_cast<HANDLE>(lp);
+
+ TranslateDialogDefault(hDlg);
+
+ tstring sName = get_window_text(hDlg);
+ sName += _T(" - ");
+ sName += GetContactName(hContact);
+ ::SetWindowText(hDlg,sName.c_str());
+
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX,false);
+ assert(hWL);
+ WindowList_Add(hWL,hDlg,hContact);
+
+ ::SetWindowLongPtr(hDlg,GWLP_USERDATA,reinterpret_cast<LONG_PTR>(hContact));
+
+ static LPCTSTR szSources[] = {_T("Log File"),_T("Miranda's History")};
+ static LPCTSTR szFilters[] = {_T("All"),_T("Last Day"),_T("Last Week"),_T("Last Month"),_T("Last Year"),_T("User-Defined")};
+
+ for(int i = 0;i < sizeof(szSources)/sizeof(szSources[0]);++i)
+ {
+ LPCTSTR p = TranslateTS(szSources[i]);
+ ::SendDlgItemMessage(hDlg,IDC_COMBO_DATA_SOURCE,CB_INSERTSTRING,-1,reinterpret_cast<LPARAM>(p));
+ }
+
+ int nSel = DBGetContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,"Chart_Source",srcLogFile);
+ ::SendDlgItemMessage(hDlg,IDC_COMBO_DATA_SOURCE,CB_SETCURSEL,nSel,0);
+
+ for(int i = 0;i < sizeof(szFilters)/sizeof(szFilters[0]);++i)
+ {
+ LPCTSTR p = TranslateTS(szSources[i]);
+ ::SendDlgItemMessage(hDlg,IDC_COMBO_FILTER,CB_INSERTSTRING,-1,reinterpret_cast<LPARAM>(szFilters[i]));
+ }
+
+ nSel = DBGetContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,"Chart_Filter",filterAll);
+ ::SendDlgItemMessage(hDlg,IDC_COMBO_FILTER,CB_SETCURSEL,nSel,0);
+
+ update_filter_controls(hDlg);
+
+ register_chart_control();
+ HWND hwndImage = ::GetDlgItem(hDlg,IDC_STATIC_IMAGE);
+ RECT rcImage;
+ ::GetWindowRect(hwndImage,&rcImage);
+ screen_2_client(hDlg,&rcImage);
+ //BOOL bResult = ShowWindow(hwndImage,SW_HIDE);
+ //assert(bResult);
+
+ HWND hChart = ::CreateWindowEx(0L,CHART_CTRL_CLASS,NULL,WS_CHILDWINDOW|WS_VISIBLE,
+ rcImage.left,rcImage.top,rcImage.right-rcImage.left,rcImage.bottom-rcImage.top,
+ hDlg,reinterpret_cast<HMENU>(ID_CHART),CModuleInfo::GetInstance().GetModuleHandle(),hContact);
+ assert(NULL != hChart);
+
+ Utils_RestoreWindowPosition(hDlg,hContact,QUOTES_MODULE_NAME,WINDOW_PREFIX);
+ BOOL bResult = ::ShowWindow(hDlg,SW_SHOW);
+ assert(bResult);
+ }
+ return (TRUE);
+ case WM_CLOSE:
+ {
+ HANDLE hContact = get_contact(hDlg);
+ SetWindowLongPtr(hDlg,GWLP_USERDATA,0);
+
+// save_options(hDlg,hContact);
+
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX,false);
+ assert(hWL);
+ WindowList_Remove(hWL,hDlg);
+ Utils_SaveWindowPosition(hDlg,hContact,QUOTES_MODULE_NAME,WINDOW_PREFIX);
+
+ HWND hwndChart = ::GetDlgItem(hDlg,ID_CHART);
+ BOOL bResult = ::DestroyWindow(hwndChart);
+ assert(bResult);
+
+ ::EndDialog(hDlg,0);
+ }
+ return (TRUE);
+ case WM_COMMAND:
+ switch(LOWORD(wp))
+ {
+ case IDCANCEL:
+ {
+ SendMessage(hDlg, WM_CLOSE, 0, 0);
+ }
+ return (TRUE);
+ case IDC_COMBO_FILTER:
+ if(CBN_SELCHANGE == HIWORD(wp))
+ {
+ ::SendDlgItemMessage(hDlg,ID_CHART,CHART_SET_FILTER,::SendDlgItemMessage(hDlg,IDC_COMBO_FILTER,CB_GETCURSEL,0,0),0);
+ update_filter_controls(hDlg);
+ }
+ break;
+ case IDC_COMBO_DATA_SOURCE:
+ if(CBN_SELCHANGE == HIWORD(wp))
+ {
+ ::SendDlgItemMessage(hDlg,ID_CHART,CHART_SET_SOURCE,::SendDlgItemMessage(hDlg,IDC_COMBO_DATA_SOURCE,CB_GETCURSEL,0,0),0);
+ }
+ break;
+ }
+ return (FALSE);
+ case WM_NOTIFY:
+ {
+ LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lp);
+ switch(pNMHDR->code)
+ {
+ case NM_CLICK:
+ if(IDC_SYSLINK_PROVIDER == wp)
+ {
+ PNMLINK pNMLink = reinterpret_cast<PNMLINK>(pNMHDR);
+ ::ShellExecute(hDlg,_T("open"),pNMLink->item.szUrl,NULL,NULL,SW_SHOWNORMAL);
+ }
+ break;
+ }
+ }
+ break;
+// case WM_ERASEBKGND:
+// {
+// HDC hdc = reinterpret_cast<HDC>(wp);
+// TChart* pChart = get_chart_ptr(hDlg);
+// pChart->DrawBackground(hdc);
+// return TRUE;
+// }
+// break;
+ case WM_SIZE:
+ {
+ enum{ INDENT = 7};
+
+ int nWidth = LOWORD(lp);
+ int nHeight = HIWORD(lp);
+
+ HWND hwndChart = GetDlgItem(hDlg,ID_CHART);
+ HWND hwndLink = GetDlgItem(hDlg,IDC_SYSLINK_PROVIDER);
+ HWND hwndClose = GetDlgItem(hDlg,IDCANCEL);
+
+ RECT rcDlg;
+ GetClientRect(hDlg,&rcDlg);
+
+ RECT rcChart;
+ GetWindowRect(hwndChart,&rcChart);
+ screen_2_client(hDlg,&rcChart);
+
+ RECT rcLink;
+ GetWindowRect(hwndLink,&rcLink);
+ screen_2_client(hDlg,&rcLink);
+ SetWindowPos(hwndLink,NULL,rcDlg.left + INDENT,
+ rcDlg.bottom-INDENT-(rcLink.bottom-rcLink.top),
+ 0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
+
+ RECT rcClose;
+ GetWindowRect(hwndClose,&rcClose);
+ screen_2_client(hDlg,&rcClose);
+ SetWindowPos(hwndClose,NULL,rcDlg.right - INDENT - (rcClose.right-rcClose.left),
+ rcDlg.bottom-INDENT-(rcClose.bottom-rcClose.top),
+ 0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
+
+ SetWindowPos(hwndChart,NULL,rcDlg.left + INDENT,
+ rcChart.top,
+ (nWidth-INDENT*2),
+ nHeight-(rcClose.bottom-rcClose.top)-INDENT*2-rcChart.top,
+ SWP_NOZORDER|SWP_NOACTIVATE);
+
+ }
+ break;
+ }
+ return (FALSE);
+ }
+}
+
+INT_PTR QuotesMenu_Chart(WPARAM wp,LPARAM lp)
+{
+ HANDLE hContact = reinterpret_cast<HANDLE>(wp);
+ if(NULL == hContact)
+ {
+ return 0;
+ }
+
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX,true);
+ assert(hWL);
+ HWND hWnd = WindowList_Find(hWL,hContact);
+ if(NULL != hWnd)
+ {
+ SetForegroundWindow(hWnd);
+ SetFocus(hWnd);
+ }
+ else
+ {
+ CreateDialogParam(CModuleInfo::GetModuleHandle(), MAKEINTRESOURCE(IDD_DUKASCOPY_CHART), NULL, ChartDlgProc, reinterpret_cast<LPARAM>(hContact));
+ }
+
+ return 0;
+}
+
+#endif //CHART_IMPLEMENT
diff --git a/plugins/Quotes/src/QuoteChart.h b/plugins/Quotes/src/QuoteChart.h new file mode 100644 index 0000000000..1b40f428b5 --- /dev/null +++ b/plugins/Quotes/src/QuoteChart.h @@ -0,0 +1,12 @@ +#ifndef __39BE8775_A837_494f_925C_0ABF7910F238_QuoteChart_h__
+#define __39BE8775_A837_494f_925C_0ABF7910F238_QuoteChart_h__
+
+#ifdef CHART_IMPLEMENT
+
+#pragma once
+
+INT_PTR QuotesMenu_Chart(WPARAM wp,LPARAM lp);
+
+#endif
+
+#endif //__39BE8775_A837_494f_925C_0ABF7910F238_QuoteChart_h__
diff --git a/plugins/Quotes/src/QuoteInfoDlg.cpp b/plugins/Quotes/src/QuoteInfoDlg.cpp new file mode 100644 index 0000000000..61b6fb5f11 --- /dev/null +++ b/plugins/Quotes/src/QuoteInfoDlg.cpp @@ -0,0 +1,350 @@ +#include "StdAfx.h"
+#include "QuoteInfoDlg.h"
+#include "EconomicRateInfo.h"
+#include "resource.h"
+#include "ModuleInfo.h"
+#include "QuotesProviders.h"
+#include "IconLib.h"
+#include "DBUtils.h"
+#include "IQuotesProvider.h"
+#include "Locale.h"
+#include "SettingsDlg.h"
+
+// extern HANDLE g_hWindowListEditSettings;
+extern HGENMENU g_hMenuEditSettings;
+extern HGENMENU g_hMenuOpenLogFile;
+#ifdef CHART_IMPLEMENT
+extern HGENMENU g_hMenuChart;
+#endif
+extern HGENMENU g_hMenuRefresh;
+
+
+#define WINDOW_PREFIX_INFO "Quote Info"
+
+
+namespace
+{
+ HANDLE g_hContact;
+
+ inline bool IsMyContact(HANDLE hContact)
+ {
+ CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact);
+ return (NULL != pProvider);
+ }
+
+ inline HANDLE get_contact(HWND hWnd)
+ {
+ return reinterpret_cast<HANDLE>(GetWindowLongPtr(hWnd,GWLP_USERDATA));
+ }
+
+
+ bool get_fetch_time(time_t& rTime,HANDLE hContact)
+ {
+ DBVARIANT dbv;
+ DBCONTACTGETSETTING cgs;
+
+ cgs.szModule=QUOTES_PROTOCOL_NAME;
+ cgs.szSetting=DB_STR_QUOTE_FETCH_TIME;
+ cgs.pValue=&dbv;
+ if(CallService(MS_DB_CONTACT_GETSETTING,reinterpret_cast<WPARAM>(hContact),reinterpret_cast<LPARAM>(&cgs))
+ || (DBVT_DWORD != dbv.type))
+ {
+ return false;
+ }
+
+ rTime = dbv.dVal;
+ return true;
+ }
+
+ INT_PTR CALLBACK QuoteInfoDlgProcImpl(HANDLE hContact,HWND hdlg,UINT msg,WPARAM wParam,LPARAM lParam)
+ {
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ assert(hContact);
+
+ TranslateDialogDefault(hdlg);
+
+ tstring sDescription = GetContactName(hContact);
+ ::SetDlgItemText(hdlg,IDC_STATIC_QUOTE_NAME,sDescription.c_str());
+
+ double dRate = 0.0;
+ if(true == Quotes_DBReadDouble(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_PREV_VALUE,dRate))
+ {
+ tostringstream o;
+ o.imbue(GetSystemLocale());
+ o << dRate;
+
+ ::SetDlgItemText(hdlg,IDC_EDIT_PREVIOUS_RATE,o.str().c_str());
+ }
+
+ dRate = 0.0;
+ if(true == Quotes_DBReadDouble(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_CURR_VALUE,dRate))
+ {
+ tostringstream o;
+ o.imbue(GetSystemLocale());
+ o << dRate;
+
+ ::SetDlgItemText(hdlg,IDC_EDIT_RATE,o.str().c_str());
+ }
+
+ time_t nFetchTime;
+ if(true == get_fetch_time(nFetchTime,hContact))
+ {
+ TCHAR szTime[50];
+ if(0 == _tctime_s(szTime,50,&nFetchTime))
+ {
+ szTime[::_tcslen(szTime)-1] = _T('\0');
+ ::SetDlgItemText(hdlg,IDC_EDIT_RATE_FETCH_TIME,szTime);
+ }
+ }
+
+ CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact);
+
+ const IQuotesProvider::CProviderInfo& pi = pProvider->GetInfo();
+ tostringstream o;
+ o << TranslateT("Info provided by") << _T(" <a href=\"") << pi.m_sURL << _T("\">") << pi.m_sName << _T("</a>");
+
+ ::SetDlgItemText(hdlg,IDC_SYSLINK_PROVIDER,o.str().c_str());
+ }
+ return TRUE;
+ case WM_NOTIFY:
+ {
+ LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lParam);
+ switch(pNMHDR->code)
+ {
+ case NM_CLICK:
+ if(IDC_SYSLINK_PROVIDER == wParam)
+ {
+ PNMLINK pNMLink = reinterpret_cast<PNMLINK>(pNMHDR);
+ ::ShellExecute(hdlg,_T("open"),pNMLink->item.szUrl,NULL,NULL,SW_SHOWNORMAL);
+ }
+ break;
+ }
+ }
+ break;
+ }
+ return FALSE;
+ }
+
+ INT_PTR CALLBACK QuoteInfoDlgProc(HWND hdlg,UINT msg,WPARAM wParam,LPARAM lParam)
+ {
+ return QuoteInfoDlgProcImpl(g_hContact,hdlg,msg,wParam,lParam);
+ }
+}
+
+int QuotesEventFunc_OnUserInfoInit(WPARAM wp,LPARAM lp)
+{
+ HANDLE hContact = reinterpret_cast<HANDLE>(lp);
+ if(NULL == hContact)
+ {
+ return 0;
+ }
+
+
+ if(false == IsMyContact(hContact))
+ {
+ return 0;
+ }
+
+ g_hContact = hContact;
+
+ OPTIONSDIALOGPAGE odp = {0};
+ odp.cbSize = sizeof( odp );
+ odp.hInstance = g_hInstance;
+
+ odp.hIcon = Quotes_LoadIconEx(ICON_STR_MAIN);
+ odp.pfnDlgProc = QuoteInfoDlgProc;
+ odp.position = -2000000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_QUOTE_INFO);
+ odp.pszTitle = LPGEN("Quote");
+ UserInfo_AddPage(wp, &odp);
+ return 0;
+}
+
+
+INT_PTR QuotesMenu_EditSettings(WPARAM wp,LPARAM lp)
+{
+ HANDLE hContact = reinterpret_cast<HANDLE>(wp);
+ if(NULL == hContact)
+ {
+ return 0;
+ }
+
+ ShowSettingsDlg(hContact);
+
+ return 0;
+}
+
+namespace
+{
+ bool get_log_file(HANDLE hContact,tstring& rsLogfile)
+ {
+ rsLogfile = GetContactLogFileName(hContact);
+ return ((rsLogfile.empty()) ? false : true);
+ }
+}
+
+INT_PTR QuotesMenu_OpenLogFile(WPARAM wp,LPARAM lp)
+{
+ HANDLE hContact = reinterpret_cast<HANDLE>(wp);
+ if(NULL == hContact)
+ {
+ return 0;
+ }
+
+ tstring sLogFileName;
+ if ((true == get_log_file(hContact,sLogFileName)) && (false == sLogFileName.empty()))
+ {
+ ::ShellExecute(NULL,_T("open"),sLogFileName.c_str(),NULL,NULL,SW_SHOWNORMAL);
+ }
+
+ return 0;
+}
+
+INT_PTR QuotesMenu_RefreshContact(WPARAM wp,LPARAM lp)
+{
+ HANDLE hContact = reinterpret_cast<HANDLE>(wp);
+ if(NULL == hContact)
+ {
+ return 0;
+ }
+
+ CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact);
+ if (!pProvider)
+ {
+ return 0;
+ }
+
+ pProvider->RefreshContact(hContact);
+
+ return 0;
+}
+
+namespace
+{
+ INT_PTR CALLBACK QuoteInfoDlgProc1(HWND hdlg,UINT msg,WPARAM wParam,LPARAM lParam)
+ {
+ HANDLE hContact = NULL;
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ hContact = reinterpret_cast<HANDLE>(lParam);
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO,false);
+ assert(hWL);
+ WindowList_Add(hWL,hdlg,hContact);
+
+ ::SetWindowLongPtr(hdlg,GWLP_USERDATA,reinterpret_cast<LONG>(hContact));
+ Utils_RestoreWindowPositionNoSize(hdlg,hContact,QUOTES_MODULE_NAME,WINDOW_PREFIX_INFO);
+ ::ShowWindow(hdlg,SW_SHOW);
+ }
+ break;
+ case WM_CLOSE:
+ DestroyWindow(hdlg);
+ return FALSE;
+ case WM_DESTROY:
+ {
+ HANDLE hContact = get_contact(hdlg);
+ if(hContact)
+ {
+ SetWindowLongPtr(hdlg,GWLP_USERDATA,0);
+
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO,false);
+ assert(hWL);
+ WindowList_Remove(hWL,hdlg);
+ Utils_SaveWindowPosition(hdlg,hContact,QUOTES_MODULE_NAME,WINDOW_PREFIX_INFO);
+ }
+ }
+ return FALSE;
+ case WM_COMMAND:
+ if(LOWORD(wParam) == IDOK)
+ {
+ ::DestroyWindow(hdlg);
+ return FALSE;
+ }
+
+ default:
+ hContact = get_contact(hdlg);
+ break;
+ }
+
+ return QuoteInfoDlgProcImpl(hContact,hdlg,msg,wParam,lParam);
+ }
+}
+
+int Quotes_OnContactDoubleClick(WPARAM wp,LPARAM/* lp*/)
+{
+ HANDLE hContact = reinterpret_cast<HANDLE>(wp);
+ if(CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact))
+ {
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO,true);
+ assert(hWL);
+ HWND hWnd = WindowList_Find(hWL,hContact);
+ if(NULL != hWnd)
+ {
+ SetForegroundWindow(hWnd);
+ SetFocus(hWnd);
+ }
+ else if(true == IsMyContact(hContact))
+ {
+ CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_DIALOG_QUOTE_INFO_1),NULL,QuoteInfoDlgProc1,reinterpret_cast<LPARAM>(hContact));
+ }
+
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+namespace
+{
+ void enable_menu(HANDLE hMenu,bool bEnable)
+ {
+ CLISTMENUITEM clmi = {0};
+ clmi.cbSize = sizeof( CLISTMENUITEM );
+ clmi.flags = CMIM_FLAGS;
+ if(false == bEnable)
+ {
+ clmi.flags |= /*CMIF_HIDDEN*/CMIF_GRAYED;
+ }
+
+ CallService(MS_CLIST_MODIFYMENUITEM,reinterpret_cast<WPARAM>(hMenu),reinterpret_cast<LPARAM>(&clmi));
+ }
+}
+
+int Quotes_PrebuildContactMenu(WPARAM wp,LPARAM lp)
+{
+ enable_menu(g_hMenuEditSettings,false);
+ enable_menu(g_hMenuOpenLogFile,false);
+#ifdef CHART_IMPLEMENT
+ enable_menu(g_hMenuChart,false);
+#endif
+ enable_menu(g_hMenuRefresh,false);
+
+ HANDLE hContact = reinterpret_cast<HANDLE>(wp);
+ if(NULL == hContact)
+ {
+ return 0;
+ }
+
+ enable_menu(g_hMenuEditSettings,true);
+
+ enable_menu(g_hMenuRefresh,true);
+
+ tstring sLogFileName;
+ bool bThereIsLogFile = (true == get_log_file(hContact,sLogFileName))
+ && (false == sLogFileName.empty()) && (0 == _taccess(sLogFileName.c_str(),04));
+ if(true == bThereIsLogFile)
+ {
+#ifdef CHART_IMPLEMENT
+ enable_menu(g_hMenuChart,true);
+#endif
+ enable_menu(g_hMenuOpenLogFile,true);
+ }
+
+ return 0;
+}
diff --git a/plugins/Quotes/src/QuoteInfoDlg.h b/plugins/Quotes/src/QuoteInfoDlg.h new file mode 100644 index 0000000000..c4a1999a4c --- /dev/null +++ b/plugins/Quotes/src/QuoteInfoDlg.h @@ -0,0 +1,11 @@ +#ifndef __aa849fa0_ff3f_49e9_b47a_e7dd34783dc2_QuoteInfoDlg_h__
+#define __aa849fa0_ff3f_49e9_b47a_e7dd34783dc2_QuoteInfoDlg_h__
+
+int QuotesEventFunc_OnUserInfoInit(WPARAM wp,LPARAM lp);
+INT_PTR QuotesMenu_EditSettings(WPARAM wp,LPARAM lp);
+INT_PTR QuotesMenu_OpenLogFile(WPARAM wp,LPARAM lp);
+INT_PTR QuotesMenu_RefreshContact(WPARAM wp,LPARAM lp);
+int Quotes_PrebuildContactMenu(WPARAM wp,LPARAM lp);
+int Quotes_OnContactDoubleClick(WPARAM wp,LPARAM lp);
+
+#endif //__aa849fa0_ff3f_49e9_b47a_e7dd34783dc2_QuoteInfoDlg_h__
diff --git a/plugins/Quotes/src/QuotesProviderBase.cpp b/plugins/Quotes/src/QuotesProviderBase.cpp Binary files differnew file mode 100644 index 0000000000..681afb0d38 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderBase.cpp diff --git a/plugins/Quotes/src/QuotesProviderBase.h b/plugins/Quotes/src/QuotesProviderBase.h new file mode 100644 index 0000000000..76db155f4c --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderBase.h @@ -0,0 +1,112 @@ +#ifndef __3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__
+#define __3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__
+
+#include "iquotesprovider.h"
+#include <vector>
+#include "LightMutex.h"
+
+class CQuotesProviderBase : public IQuotesProvider
+{
+public:
+ class CQuote
+ {
+ public:
+ CQuote(const tstring& rsID = _T(""),const tstring& rsSymbol = _T(""),const tstring& rsName = _T(""))
+ : m_sSymbol(rsSymbol),m_sName(rsName),m_sID(rsID){}
+
+ const tstring& GetSymbol()const{return m_sSymbol;}
+ const tstring& GetName()const{return m_sName;}
+ const tstring& GetID()const{return m_sID;}
+
+ private:
+ tstring m_sSymbol;
+ tstring m_sName;
+ tstring m_sID;
+ };
+
+ class CQuoteSection
+ {
+ public:
+ typedef std::vector<CQuoteSection> TSections;
+ typedef std::vector<CQuote> TQuotes;
+
+ public:
+ CQuoteSection(const tstring& rsName = _T(""),const TSections& raSections = TSections(),const TQuotes& raQuotes = TQuotes())
+ : m_sName(rsName),m_aSections(raSections),m_aQuotes(raQuotes){}
+
+ const tstring& GetName()const
+ {return m_sName;}
+
+ size_t GetSectionCount()const
+ {return m_aSections.size();}
+ CQuoteSection GetSection(size_t nIndex)const
+ {return ((nIndex < m_aSections.size()) ? m_aSections[nIndex] : CQuoteSection());}
+
+ size_t GetQuoteCount()const
+ {return m_aQuotes.size();}
+ CQuote GetQuote(size_t nIndex)const
+ {return ((nIndex < m_aQuotes.size()) ? m_aQuotes[nIndex] : CQuote());}
+
+ private:
+ tstring m_sName;
+ TSections m_aSections;
+ TQuotes m_aQuotes;
+ };
+
+protected:
+ typedef std::vector<HANDLE> TContracts;
+
+public:
+ struct CXMLFileInfo;
+
+public:
+ CQuotesProviderBase();
+ ~CQuotesProviderBase();
+
+
+ const CQuoteSection& GetQuotes()const;
+// void SetSettingsEvent();
+
+ virtual bool Init();
+ virtual const CProviderInfo& GetInfo()const;
+ virtual void AddContact(HANDLE hContact);
+ virtual void DeleteContact(HANDLE hContact);
+ virtual void Run();
+ virtual void Accept(CQuotesProviderVisitor& visitor)const;
+ virtual void RefreshAll();
+ virtual void RefreshContact(HANDLE hContact);
+ virtual void SetContactExtraIcon(HANDLE hContact)const;
+
+protected:
+ const tstring& GetURL()const;
+ HANDLE CreateNewContact(const tstring& rsName);
+ static bool IsOnline();
+ static void SetContactStatus(HANDLE hContact,int nNewStatus);
+ void WriteContactRate(HANDLE hContact,double dRate,const tstring& rsSymbol = _T(""));
+
+private:
+ virtual void RefreshQuotes(TContracts& anContacts) = 0;
+
+private:
+ virtual void OnEndRun();
+
+private:
+ CXMLFileInfo* GetXMLFileInfo()const;
+
+protected:
+ TContracts m_aContacts;
+ mutable CLightMutex m_cs;
+
+private:
+ typedef boost::scoped_ptr<CXMLFileInfo> TXMLFileInfoPtr;
+ mutable TXMLFileInfoPtr m_pXMLInfo;
+ HANDLE m_hEventSettingsChanged;
+ HANDLE m_hEventRefreshContact;
+ tstring m_sContactListFormat;
+ tstring m_sStatusMsgFormat;
+ tstring m_sTendencyFormat;
+ TContracts m_aRefreshingContacts;
+ bool m_bRefreshInProgress;
+};
+
+#endif //__3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__
diff --git a/plugins/Quotes/src/QuotesProviderDukasCopy.cpp b/plugins/Quotes/src/QuotesProviderDukasCopy.cpp Binary files differnew file mode 100644 index 0000000000..a7ffc5331a --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderDukasCopy.cpp diff --git a/plugins/Quotes/src/QuotesProviderDukasCopy.h b/plugins/Quotes/src/QuotesProviderDukasCopy.h new file mode 100644 index 0000000000..d6ec498bcf --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderDukasCopy.h @@ -0,0 +1,38 @@ +#ifndef __93121758_68c7_4836_b571_da84dfe82b84_QuotesProviderDukasCopy_h__
+#define __93121758_68c7_4836_b571_da84dfe82b84_QuotesProviderDukasCopy_h__
+
+#include "quotesproviderbase.h"
+#include <vector>
+
+#define DB_STR_REFRESH_RATE_TYPE "RefreshRateType"
+#define DB_STR_REFRESH_RATE_VALUE "RefreshRateValue"
+#define DB_STR_DC_DISPLAY_NAME_FORMAT "DC_DisplayNameFormat"
+// #define DB_STR_DC_LOG_FILE_FORMAT "DC_LogFileFormat"
+// #define DB_STR_DC_HISTORY_FORMAT "DC_HistoryFormat"
+
+class CQuotesProviderDukasCopy : public CQuotesProviderBase
+{
+public:
+ CQuotesProviderDukasCopy();
+ ~CQuotesProviderDukasCopy();
+
+ bool WatchForQuote(const CQuote& rQuote,bool bWatch);
+ bool IsQuoteWatched(const CQuote& rQuote)const;
+
+ HANDLE GetContactByQuoteID(const tstring& rsQuoteID)const;
+// #ifdef CHART_IMPLEMENT
+// bool Chart(HANDLE hContact,const tstring& url)const;
+// #endif
+
+private:
+ //IQuotesProvider implementation
+ virtual void RefreshQuotes(TContracts& anContacts);
+ virtual void ShowPropertyPage(WPARAM wp,OPTIONSDIALOGPAGE& odp);
+ virtual void Accept(CQuotesProviderVisitor& visitor)const;
+
+private:
+ tstring BuildHTTPURL()const;
+
+};
+
+#endif //__93121758_68c7_4836_b571_da84dfe82b84_QuotesProviderDukasCopy_h__
diff --git a/plugins/Quotes/src/QuotesProviderFinance.cpp b/plugins/Quotes/src/QuotesProviderFinance.cpp new file mode 100644 index 0000000000..e8b335035d --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderFinance.cpp @@ -0,0 +1,318 @@ +#include "stdafx.h"
+#include "QuotesProviderFinance.h"
+#include "EconomicRateInfo.h"
+#include "DBUtils.h"
+#include "QuotesProviderVisitor.h"
+#include "ModuleInfo.h"
+#include "QuotesProviders.h"
+#include "CommonOptionDlg.h"
+#include "resource.h"
+#include "WinCtrlHelper.h"
+
+void CQuotesProviderFinance::GetWatchedQuotes(TQuotes& raQuotes)const
+{
+ raQuotes.clear();
+ BOOST_FOREACH(HANDLE hContact,m_aContacts)
+ {
+ tstring sID = Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_ID);
+ tstring sSymbol = Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_SYMBOL,sID.c_str());
+ tstring sDescr = Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_DESCRIPTION);
+ CQuotesProviderBase::CQuote quote(sID,sSymbol,sDescr);
+
+ raQuotes.push_back(quote);
+ }
+}
+
+namespace
+{
+ inline tstring get_quote_id(HANDLE hContact)
+ {
+ return Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_ID);
+ }
+
+ inline bool is_quote_id_equal(HANDLE hContact,const tstring& sID)
+ {
+ return sID == get_quote_id(hContact);
+ }
+}
+
+bool CQuotesProviderFinance::WatchForQuote(const CQuote& rQuote,bool bWatch)
+{
+ const tstring& sQuoteID = rQuote.GetID();
+ TContracts::iterator i = std::find_if(m_aContacts.begin(),m_aContacts.end(),
+ boost::bind(is_quote_id_equal,_1,sQuoteID));
+
+ if ((false == bWatch) && (i != m_aContacts.end()))
+ {
+ HANDLE hContact = *i;
+ {// for CCritSection
+ CGuard<CLightMutex> cs(m_cs);
+ m_aContacts.erase(i);
+ }
+
+ CallService(MS_DB_CONTACT_DELETE,reinterpret_cast<WPARAM>(hContact),0);
+ return true;
+ }
+ else if ((true == bWatch) && (i == m_aContacts.end()))
+ {
+ HANDLE hContact = CreateNewContact(rQuote.GetSymbol());
+ if(hContact)
+ {
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_ID,sQuoteID.c_str());
+ if(false == rQuote.GetName().empty())
+ {
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_DESCRIPTION,rQuote.GetName().c_str());
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+HANDLE CQuotesProviderFinance::GetContactByQuoteID(const tstring& rsQuoteID)const
+{
+ CGuard<CLightMutex> cs(m_cs);
+
+ TContracts::const_iterator i = std::find_if(m_aContacts.begin(),m_aContacts.end(),
+ boost::bind(std::equal_to<tstring>(),rsQuoteID,boost::bind(get_quote_id,_1)));
+ if(i != m_aContacts.end())
+ {
+ return *i;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+void CQuotesProviderFinance::Accept(CQuotesProviderVisitor& visitor)const
+{
+ CQuotesProviderBase::Accept(visitor);
+ visitor.Visit(*this);
+}
+
+namespace
+{
+ inline tstring make_quote_name(const CQuotesProviderBase::CQuote& rQuote)
+ {
+ const tstring& rsDesc = rQuote.GetName();
+ return((false == rsDesc.empty()) ? rsDesc : rQuote.GetSymbol());
+ }
+
+ int add_quote_to_wnd(const CQuotesProviderBase::CQuote& rQuote,HWND hwnd)
+ {
+ tstring sName = make_quote_name(rQuote);
+ int nIndex = ::SendMessage(hwnd,LB_ADDSTRING,0,reinterpret_cast<LPARAM>(sName.c_str()));
+ if(nIndex >= 0)
+ {
+ CQuotesProviderBase::CQuote* pQuote = new CQuotesProviderBase::CQuote(rQuote);
+ if(LB_ERR == ::SendMessage(hwnd,LB_SETITEMDATA,nIndex,reinterpret_cast<LPARAM>(pQuote)))
+ {
+ delete pQuote;
+ }
+ }
+ return nIndex;
+ }
+
+// typedef CQuotesProviderFinance::TQuotes TQuotes;
+// TQuotes g_aWatchedQuotes;
+
+// inline bool cmp_quotes(const tstring& rsQuoteId,const CQuotesProviderBase::CQuote& quote)
+// {
+// return (0 == quotes_stricmp(rsQuoteId.c_str(),quote.GetID().c_str()));
+// }
+
+ CQuotesProviderBase::CQuote* get_quote_ptr_from_lb_index(HWND hwndListBox,int nIndex)
+ {
+ LRESULT lResult = ::SendMessage(hwndListBox,LB_GETITEMDATA,nIndex,0);
+ return (((LB_ERR != lResult) && (0 != lResult)) ? (reinterpret_cast<CQuotesProviderBase::CQuote*>(lResult)) : nullptr);
+ }
+
+ int is_quote_added(HWND hwndList,const tstring& rsQuoteID)
+ {
+ int cItems = ::SendMessage(hwndList,LB_GETCOUNT,0,0);
+ for(int i = 0;i < cItems;++i)
+ {
+ const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndList,i);
+ if ((nullptr != pQuote)
+ && ((0 == quotes_stricmp(rsQuoteID.c_str(),pQuote->GetID().c_str()))
+ || (0 == quotes_stricmp(rsQuoteID.c_str(),pQuote->GetName().c_str()))
+ || (0 == quotes_stricmp(rsQuoteID.c_str(),pQuote->GetSymbol().c_str()))))
+ {
+ return i;
+ }
+ }
+ return LB_ERR;
+ }
+
+ INT_PTR CALLBACK GoogleFinanceOptDlgProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
+ {
+ CQuotesProviderFinance* pProvider = nullptr;
+ if(WM_INITDIALOG == message)
+ {
+ pProvider = reinterpret_cast<CQuotesProviderFinance*>(lParam);
+ SetWindowLongPtr(hDlg,GWLP_USERDATA,lParam);
+ }
+ else
+ {
+ pProvider = reinterpret_cast<CQuotesProviderFinance*>(GetWindowLongPtr(hDlg,GWLP_USERDATA));
+ }
+
+ CCommonDlgProcData d(pProvider);
+ CommonOptionDlgProc(hDlg,message,wParam,lParam,d);
+
+ switch(message)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hDlg);
+
+ CQuotesProviderFinance::TQuotes aQuotes;
+ pProvider->GetWatchedQuotes(aQuotes);
+
+ HWND hwndList = GetDlgItem(hDlg,IDC_LIST_RATES);
+ std::for_each(aQuotes.begin(),aQuotes.end(),
+ boost::bind(add_quote_to_wnd,_1,hwndList));
+
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_ADD),FALSE);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_REMOVE),FALSE);
+ }
+ return (TRUE);
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDC_EDIT_QUOTE:
+ if(EN_CHANGE == HIWORD(wParam))
+ {
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_ADD),GetWindowTextLength(GetDlgItem(hDlg,IDC_EDIT_QUOTE)) > 0);
+ }
+ return (TRUE);
+ case IDC_BUTTON_ADD:
+ if(BN_CLICKED == HIWORD(wParam))
+ {
+ HWND hEdit = GetDlgItem(hDlg,IDC_EDIT_QUOTE);
+ tstring sQuoteSymbol = get_window_text(hEdit);
+ assert(false == sQuoteSymbol.empty());
+ HWND hwndList = GetDlgItem(hDlg,IDC_LIST_RATES);
+ if(LB_ERR == is_quote_added(hwndList,sQuoteSymbol))
+ {
+ CQuotesProviderBase::CQuote quote(sQuoteSymbol,sQuoteSymbol);
+ if(add_quote_to_wnd(quote,hwndList) >= 0)
+ {
+ SetDlgItemText(hDlg,IDC_EDIT_QUOTE,_T(""));
+ SetFocus(hEdit);
+ PropSheet_Changed(::GetParent(hDlg),hDlg);
+ }
+ else
+ {
+ ::MessageBeep(MB_ICONERROR);
+ }
+ }
+ }
+ return (TRUE);
+ case IDC_BUTTON_REMOVE:
+ if(BN_CLICKED == HIWORD(wParam))
+ {
+ HWND hWnd = ::GetDlgItem(hDlg,IDC_LIST_RATES);
+ int nSel = ::SendMessage(hWnd,LB_GETCURSEL,0,0);
+ if(LB_ERR != nSel)
+ {
+ CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hWnd,nSel);
+ delete pQuote;
+ if(LB_ERR != ::SendMessage(hWnd,LB_DELETESTRING,nSel,0))
+ {
+ PropSheet_Changed(::GetParent(hDlg),hDlg);
+ }
+ }
+
+ nSel = ::SendMessage(hWnd,LB_GETCURSEL,0,0);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_REMOVE),(LB_ERR != nSel));
+ }
+ return (TRUE);
+ case IDC_LIST_RATES:
+ if(CBN_SELCHANGE == HIWORD(wParam))
+ {
+ int nSel = ::SendMessage(::GetDlgItem(hDlg,IDC_LIST_RATES),LB_GETCURSEL,0,0);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_REMOVE),(LB_ERR != nSel));
+ }
+ return (TRUE);
+ }
+ return (FALSE);
+
+ case WM_NOTIFY:
+ {
+ LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lParam);
+ switch(pNMHDR->code)
+ {
+ case PSN_APPLY:
+ if(pProvider)
+ {
+ CQuotesProviderFinance::TQuotes aTemp;
+ pProvider->GetWatchedQuotes(aTemp);
+
+ typedef std::vector<const CQuotesProviderBase::CQuote*> TQuotesPtr;
+ TQuotesPtr apCurrent;
+ HWND hwndListBox = GetDlgItem(hDlg,IDC_LIST_RATES);
+ int cItems = ::SendMessage(hwndListBox,LB_GETCOUNT,0,0);
+ for(int i = 0;i < cItems;++i)
+ {
+ const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndListBox,i);
+ if(pQuote)
+ {
+ apCurrent.push_back(pQuote);
+ }
+ }
+
+ std::for_each(aTemp.begin(),aTemp.end(),
+ [&apCurrent,pProvider](const CQuotesProviderBase::CQuote& quote)
+ {
+ if(apCurrent.end() == std::find_if(apCurrent.begin(),apCurrent.end(),
+ ["e](const CQuotesProviderBase::CQuote* pQuote){return 0 == quotes_stricmp(pQuote->GetID().c_str(),quote.GetID().c_str());}))
+ {
+ pProvider->WatchForQuote(quote,false);
+ }
+ });
+
+ std::for_each(apCurrent.begin(),apCurrent.end(),
+ [&aTemp,pProvider](const CQuotesProviderBase::CQuote* pQuote)
+ {
+ if(aTemp.end() ==
+ std::find_if(aTemp.begin(),aTemp.end(),
+ [pQuote](const CQuotesProviderBase::CQuote& quote){return 0 == quotes_stricmp(pQuote->GetID().c_str(),quote.GetID().c_str());}))
+ {
+ pProvider->WatchForQuote(*pQuote,true);
+ }
+
+ });
+
+ pProvider->RefreshAll();
+ }
+
+ return (TRUE);
+ }
+ }
+ return (FALSE);
+ case WM_DESTROY:
+ HWND hwndListBox = GetDlgItem(hDlg,IDC_LIST_RATES);
+ int cItems = ::SendMessage(hwndListBox,LB_GETCOUNT,0,0);
+ for(int i = 0;i < cItems;++i)
+ {
+ const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndListBox,i);
+ delete pQuote;
+ }
+ return (FALSE);
+ }
+ return (FALSE);
+ }
+}
+
+void CQuotesProviderFinance::ShowPropertyPage(WPARAM wp,OPTIONSDIALOGPAGE& odp)
+{
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_OPT_FINANCE);
+ odp.pfnDlgProc = GoogleFinanceOptDlgProc;
+ odp.dwInitParam = reinterpret_cast<DWORD>(static_cast<CQuotesProviderFinance*>(this));
+ odp.ptszTab = const_cast<LPTSTR>(GetInfo().m_sName.c_str());
+ Options_AddPage(wp, &odp);
+}
diff --git a/plugins/Quotes/src/QuotesProviderFinance.h b/plugins/Quotes/src/QuotesProviderFinance.h new file mode 100644 index 0000000000..f63077071d --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderFinance.h @@ -0,0 +1,21 @@ +#ifndef __95A13A68_0DF0_43FA_B6C1_81D83AED59AA_QuotesProviderFinance_h__
+#define __95A13A68_0DF0_43FA_B6C1_81D83AED59AA_QuotesProviderFinance_h__
+
+#include "QuotesProviderBase.h"
+
+class CQuotesProviderFinance : public CQuotesProviderBase
+{
+public:
+ typedef std::vector<CQuotesProviderBase::CQuote> TQuotes;
+
+public:
+ void GetWatchedQuotes(TQuotes& raQuotes)const;
+ bool WatchForQuote(const CQuote& rQuote,bool bWatch);
+ HANDLE GetContactByQuoteID(const tstring& rsQuoteID)const;
+
+protected:
+ virtual void ShowPropertyPage(WPARAM wp,OPTIONSDIALOGPAGE& odp);
+ virtual void Accept(CQuotesProviderVisitor& visitor)const;
+};
+
+#endif //__95A13A68_0DF0_43FA_B6C1_81D83AED59AA_QuotesProviderFinance_h__
\ No newline at end of file diff --git a/plugins/Quotes/src/QuotesProviderGoogle.cpp b/plugins/Quotes/src/QuotesProviderGoogle.cpp new file mode 100644 index 0000000000..c2b30a9a6a --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderGoogle.cpp @@ -0,0 +1,543 @@ +#include "StdAfx.h"
+#include "QuotesProviderGoogle.h"
+#include "resource.h"
+#include "HTTPSession.h"
+#include "Log.h"
+#include "DBUtils.h"
+#include "EconomicRateInfo.h"
+#include "ModuleInfo.h"
+#include "QuotesProviders.h"
+#include "IHTMLParser.h"
+#include "IHTMLEngine.h"
+#include "CommonOptionDlg.h"
+#include "QuotesProviderVisitor.h"
+
+CQuotesProviderGoogle::CQuotesProviderGoogle()
+{
+}
+
+CQuotesProviderGoogle::~CQuotesProviderGoogle()
+{
+}
+
+namespace
+{
+ inline tstring make_contact_name(const tstring& rsSymbolFrom,const tstring& rsSymbolTo)
+ {
+ tostringstream o;
+ o << rsSymbolFrom << _T("/") << rsSymbolTo;
+ return o.str();
+ }
+
+ inline bool is_rate_watched(HANDLE hContact,
+ const CQuotesProviderBase::CQuote& from,
+ const CQuotesProviderBase::CQuote& to)
+ {
+ tstring sFrom = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_FROM_ID);
+ tstring sTo = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_TO_ID);
+ return ((0 == quotes_stricmp(from.GetID().c_str(),sFrom.c_str()))
+ && (0 == quotes_stricmp(to.GetID().c_str(),sTo.c_str())));
+ }
+}
+
+bool CQuotesProviderGoogle::WatchForRate(const CRateInfo& ri,
+ bool bWatch)
+{
+ TContracts::const_iterator i = std::find_if(m_aContacts.begin(),m_aContacts.end(),
+ boost::bind(is_rate_watched,_1,ri.m_from,ri.m_to));
+ if ((true == bWatch) && (i == m_aContacts.end()))
+ {
+ tstring sName = make_contact_name(ri.m_from.GetSymbol(),ri.m_to.GetSymbol());
+ HANDLE hContact = CreateNewContact(sName);
+ if(hContact)
+ {
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_FROM_ID,ri.m_from.GetID().c_str());
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_TO_ID,ri.m_to.GetID().c_str());
+ if(false == ri.m_from.GetName().empty())
+ {
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_FROM_DESCRIPTION,ri.m_from.GetName().c_str());
+ }
+ if(false == ri.m_to.GetName().empty())
+ {
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_TO_DESCRIPTION,ri.m_to.GetName().c_str());
+ }
+
+ return true;
+ }
+ }
+ else if ((false == bWatch) && (i != m_aContacts.end()))
+ {
+ HANDLE hContact = *i;
+ {// for CCritSection
+ CGuard<CLightMutex> cs(m_cs);
+ m_aContacts.erase(i);
+ }
+
+ CallService(MS_DB_CONTACT_DELETE,reinterpret_cast<WPARAM>(hContact),0);
+ return true;
+ }
+
+ return false;
+}
+
+size_t CQuotesProviderGoogle::GetWatchedRateCount()const
+{
+ return m_aContacts.size();
+}
+
+bool CQuotesProviderGoogle::GetWatchedRateInfo(size_t nIndex,CRateInfo& rRateInfo)
+{
+ if(nIndex < m_aContacts.size())
+ {
+ HANDLE hContact = m_aContacts[nIndex];
+ tstring sSymbolFrom = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_FROM_ID);
+ tstring sSymbolTo = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_TO_ID);
+ tstring sDescFrom = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_FROM_DESCRIPTION);
+ tstring sDescTo = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_TO_DESCRIPTION);
+
+ rRateInfo.m_from = CQuote(sSymbolFrom,sSymbolFrom,sDescFrom);
+ rRateInfo.m_to = CQuote(sSymbolTo,sSymbolTo,sDescTo);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+namespace
+{
+ tstring build_url(const tstring& rsURL,const tstring& from,const tstring& to,double dAmount)
+ {
+ tostringstream o;
+ o << rsURL << _T("?a=") << std::fixed << dAmount << _T("&from=") << from << _T("&to=") << to;
+ return o.str();
+ }
+ tstring build_url(HANDLE hContact,const tstring& rsURL,double dAmount = 1.0)
+ {
+ tstring sFrom = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_FROM_ID);
+ tstring sTo = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_TO_ID);
+ return build_url(rsURL,sFrom,sTo,dAmount);
+ }
+
+ typedef IHTMLNode::THTMLNodePtr THTMLNodePtr;
+
+ bool parse_html_node(const THTMLNodePtr& pNode,double& rdRate)
+ {
+ tstring sID = pNode->GetAttribute(_T("id"));
+ if ((false == sID.empty()) && (0 == quotes_stricmp(sID.c_str(),_T("currency_converter_result"))))
+ {
+ size_t cChild = pNode->GetChildCount();
+// assert(1 == cChild);
+ if(cChild > 0)
+ {
+ THTMLNodePtr pChild = pNode->GetChildPtr(0);
+ tstring sRate = pChild->GetText();
+
+ tistringstream input(sRate);
+ input >> rdRate;
+
+ return ((false == input.bad()) && (false == input.fail()));
+ }
+ }
+ else
+ {
+ size_t cChild = pNode->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ THTMLNodePtr pChild = pNode->GetChildPtr(i);
+ if(pChild && (true == parse_html_node(pChild,rdRate)))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ bool parse_responce(const tstring& rsHTML,double& rdRate)
+ {
+ IHTMLEngine::THTMLParserPtr pHTMLParser = CModuleInfo::GetHTMLEngine()->GetParserPtr();
+ THTMLNodePtr pRoot = pHTMLParser->ParseString(rsHTML);
+ if(pRoot)
+ {
+ return parse_html_node(pRoot,rdRate);
+ }
+ else
+ {
+ return false;
+ }
+ }
+}
+
+void CQuotesProviderGoogle::RefreshQuotes(TContracts& anContacts)
+{
+ CHTTPSession http;
+ tstring sURL = GetURL();
+
+ bool bUseExtendedStatus = CModuleInfo::GetInstance().GetExtendedStatusFlag();
+
+ for(TContracts::const_iterator i = anContacts.begin();i != anContacts.end() && IsOnline();++i)
+ {
+ HANDLE hContact = *i;
+
+ if(bUseExtendedStatus)
+ {
+ SetContactStatus(hContact,ID_STATUS_OCCUPIED);
+ }
+
+ tstring sFullURL = build_url(hContact,sURL);
+// LogIt(Info,sFullURL);
+ if ((true == http.OpenURL(sFullURL)) && (true == IsOnline()))
+ {
+ tstring sHTML;
+ if ((true == http.ReadResponce(sHTML)) && (true == IsOnline()))
+ {
+// LogIt(Info,sHTML);
+
+ double dRate = 0.0;
+ if ((true == parse_responce(sHTML,dRate)) && (true == IsOnline()))
+ {
+ WriteContactRate(hContact,dRate);
+ continue;
+ }
+ }
+ }
+
+ SetContactStatus(hContact,ID_STATUS_NA);
+ }
+}
+
+namespace
+{
+ inline tstring make_quote_name(const CQuotesProviderGoogle::CQuote& rQuote)
+ {
+ const tstring& rsDesc = rQuote.GetName();
+ return((false == rsDesc.empty()) ? rsDesc : rQuote.GetSymbol());
+ }
+
+ CQuotesProviderGoogle* get_google_provider()
+ {
+ CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr();
+ const CQuotesProviders::TQuotesProviders& rapQuotesProviders = pProviders->GetProviders();
+ for(CQuotesProviders::TQuotesProviders::const_iterator i = rapQuotesProviders.begin();i != rapQuotesProviders.end();++i)
+ {
+ const CQuotesProviders::TQuotesProviderPtr& pProvider = *i;
+ CQuotesProviderGoogle* pGoogle = dynamic_cast<CQuotesProviderGoogle*>(pProvider.get());
+ if(pGoogle)
+ {
+ return pGoogle;
+ }
+ }
+
+ assert(!"We should never get here!");
+ return NULL;
+ }
+
+ CQuotesProviderGoogle::CQuoteSection get_quotes()
+ {
+ const CQuotesProviderGoogle* pProvider = get_google_provider();
+ if(pProvider)
+ {
+ const CQuotesProviderGoogle::CQuoteSection& rQuotes = pProvider->GetQuotes();
+ if(rQuotes.GetSectionCount() > 0)
+ {
+ return rQuotes.GetSection(0);
+ }
+ }
+
+ return CQuotesProviderGoogle::CQuoteSection();
+ }
+
+ tstring make_rate_name(const CQuotesProviderGoogle::CQuote& rFrom,
+ const CQuotesProviderGoogle::CQuote& rTo)
+ {
+ if ((false == rFrom.GetName().empty()) && (false == rTo.GetName().empty()))
+ {
+ return make_contact_name(rFrom.GetName(),rTo.GetName());
+ }
+ else
+ {
+ return make_contact_name(rFrom.GetSymbol(),rTo.GetSymbol());
+ }
+ }
+
+ typedef std::vector<CQuotesProviderGoogle::CRateInfo> TWatchedRates;
+ TWatchedRates g_aWatchedRates;
+
+ bool is_equal_rate(const CQuotesProviderGoogle::CRateInfo& riL,const CQuotesProviderGoogle::CRateInfo& riR)
+ {
+ return ((0 == quotes_stricmp(riL.m_from.GetID().c_str(),riR.m_from.GetID().c_str()))
+ && ((0 == quotes_stricmp(riL.m_to.GetID().c_str(),riR.m_to.GetID().c_str()))));
+ }
+
+ INT_PTR CALLBACK GoogleOptDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam)
+ {
+ CQuotesProviderGoogle* pProvider = get_google_provider();
+
+ CCommonDlgProcData d(pProvider);
+ CommonOptionDlgProc(hdlg,message,wParam,lParam,d);
+
+ switch(message)
+ {
+ case WM_NOTIFY:
+ {
+ LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lParam);
+ switch(pNMHDR->code)
+ {
+ case PSN_APPLY:
+ {
+ if(pProvider)
+ {
+ TWatchedRates aTemp(g_aWatchedRates);
+ TWatchedRates aRemove;
+ size_t cWatchedRates = pProvider->GetWatchedRateCount();
+ for(size_t i = 0;i < cWatchedRates;++i)
+ {
+ CQuotesProviderGoogle::CRateInfo ri;
+ if(true == pProvider->GetWatchedRateInfo(i,ri))
+ {
+ TWatchedRates::iterator it =
+ std::find_if(aTemp.begin(),aTemp.end(),
+ boost::bind(is_equal_rate,_1,boost::cref(ri)));
+ if(it == aTemp.end())
+ {
+ aRemove.push_back(ri);
+ }
+ else
+ {
+ aTemp.erase(it);
+ }
+ }
+ }
+
+ std::for_each(aRemove.begin(),aRemove.end(),boost::bind(&CQuotesProviderGoogle::WatchForRate,pProvider,_1,false));
+ std::for_each(aTemp.begin(),aTemp.end(),boost::bind(&CQuotesProviderGoogle::WatchForRate,pProvider,_1,true));
+
+ pProvider->RefreshAll();
+ }
+ }
+ break;
+ }
+ }
+ break;
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hdlg);
+
+ g_aWatchedRates.clear();
+
+ HWND hcbxFrom = ::GetDlgItem(hdlg,IDC_COMBO_CONVERT_FROM);
+ HWND hcbxTo = ::GetDlgItem(hdlg,IDC_COMBO_CONVERT_INTO);
+
+ const CQuotesProviderGoogle::CQuoteSection& rSection = get_quotes();
+ size_t cQuotes = rSection.GetQuoteCount();
+ for(size_t i = 0;i < cQuotes;++i)
+ {
+ const CQuotesProviderGoogle::CQuote& rQuote = rSection.GetQuote(i);
+ tstring sName = make_quote_name(rQuote);
+ LPCTSTR pszName = sName.c_str();
+ ::SendMessage(hcbxFrom,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(pszName));
+ ::SendMessage(hcbxTo,CB_ADDSTRING,0,reinterpret_cast<LPARAM>(pszName));
+ }
+
+ CQuotesProviderGoogle* pProvider = get_google_provider();
+ if(pProvider)
+ {
+ size_t cWatchedRates = pProvider->GetWatchedRateCount();
+ for(size_t i = 0;i < cWatchedRates;++i)
+ {
+ CQuotesProviderGoogle::CRateInfo ri;
+ if(true == pProvider->GetWatchedRateInfo(i,ri))
+ {
+ g_aWatchedRates.push_back(ri);
+ tstring sRate = make_rate_name(ri.m_from,ri.m_to);
+ LPCTSTR pszRateName = sRate.c_str();
+ ::SendMessage(::GetDlgItem(hdlg,IDC_LIST_RATES),LB_ADDSTRING,0,reinterpret_cast<LPARAM>(pszRateName));
+ }
+ }
+ }
+
+ ::EnableWindow(::GetDlgItem(hdlg,IDC_BUTTON_ADD),FALSE);
+ ::EnableWindow(::GetDlgItem(hdlg,IDC_BUTTON_REMOVE),FALSE);
+ }
+ return TRUE;
+ case WM_COMMAND:
+ switch(HIWORD(wParam))
+ {
+ case CBN_SELCHANGE:
+ switch(LOWORD(wParam))
+ {
+ case IDC_COMBO_REFRESH_RATE:
+ break;
+ case IDC_COMBO_CONVERT_FROM:
+ case IDC_COMBO_CONVERT_INTO:
+ {
+ int nFrom = static_cast<int>(::SendMessage(::GetDlgItem(hdlg,IDC_COMBO_CONVERT_FROM),CB_GETCURSEL,0,0));
+ int nTo = static_cast<int>(::SendMessage(::GetDlgItem(hdlg,IDC_COMBO_CONVERT_INTO),CB_GETCURSEL,0,0));
+ bool bEnableAddButton = ((CB_ERR != nFrom) && (CB_ERR != nTo) && (nFrom != nTo));
+ EnableWindow(GetDlgItem(hdlg,IDC_BUTTON_ADD),bEnableAddButton);
+ }
+ break;
+ case IDC_LIST_RATES:
+ {
+ int nSel = ::SendMessage(::GetDlgItem(hdlg,IDC_LIST_RATES),LB_GETCURSEL,0,0);
+ ::EnableWindow(::GetDlgItem(hdlg,IDC_BUTTON_REMOVE),(LB_ERR != nSel));
+ }
+ break;
+ }
+ break;
+ case BN_CLICKED:
+ switch(LOWORD(wParam))
+ {
+ case IDC_BUTTON_ADD:
+ {
+ size_t nFrom = static_cast<size_t>(::SendMessage(::GetDlgItem(hdlg,IDC_COMBO_CONVERT_FROM),CB_GETCURSEL,0,0));
+ size_t nTo = static_cast<size_t>(::SendMessage(::GetDlgItem(hdlg,IDC_COMBO_CONVERT_INTO),CB_GETCURSEL,0,0));
+ if ((CB_ERR != nFrom) && (CB_ERR != nTo) && (nFrom != nTo))
+ {
+ const CQuotesProviderGoogle::CQuoteSection& rSection = get_quotes();
+ size_t cQuotes = rSection.GetQuoteCount();
+ if ((nFrom < cQuotes) && (nTo < cQuotes))
+ {
+ CQuotesProviderGoogle::CRateInfo ri;
+ ri.m_from = rSection.GetQuote(nFrom);
+ ri.m_to = rSection.GetQuote(nTo);
+
+ g_aWatchedRates.push_back(ri);
+
+ tstring sRate = make_rate_name(ri.m_from,ri.m_to);
+ LPCTSTR pszRateName = sRate.c_str();
+ ::SendMessage(::GetDlgItem(hdlg,IDC_LIST_RATES),LB_ADDSTRING,0,reinterpret_cast<LPARAM>(pszRateName));
+ PropSheet_Changed(::GetParent(hdlg),hdlg);
+ }
+ }
+ }
+ break;
+ case IDC_BUTTON_REMOVE:
+ {
+ HWND hWnd = ::GetDlgItem(hdlg,IDC_LIST_RATES);
+ int nSel = ::SendMessage(hWnd,LB_GETCURSEL,0,0);
+ if(LB_ERR != nSel)
+ {
+ if ((LB_ERR != ::SendMessage(hWnd, LB_DELETESTRING,nSel,0))
+ && (nSel < static_cast<int>(g_aWatchedRates.size())))
+ {
+
+ TWatchedRates::iterator i = g_aWatchedRates.begin();
+ std::advance(i,nSel);
+ g_aWatchedRates.erase(i);
+ PropSheet_Changed(::GetParent(hdlg),hdlg);
+ }
+ }
+
+ nSel = ::SendMessage(hWnd,LB_GETCURSEL,0,0);
+ ::EnableWindow(::GetDlgItem(hdlg,IDC_BUTTON_REMOVE),(LB_ERR != nSel));
+ }
+ break;
+ }
+ break;
+// case LBN_SELCHANGE:
+// switch(LOWORD(lParam))
+// {
+// case IDC_LIST_RATES:
+// {
+// int nSel = ::SendMessage(::GetDlgItem(hdlg,IDC_LIST_RATES),LB_GETCURSEL,0,0);
+// ::EnableWindow(::GetDlgItem(hdlg,IDC_BUTTON_REMOVE),(-1 != nSel));
+// }
+// }
+// break;
+ }
+ break;
+
+ }
+
+ return FALSE;
+ }
+}
+
+void CQuotesProviderGoogle::ShowPropertyPage(WPARAM wp,OPTIONSDIALOGPAGE& odp)
+{
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_OPT_GOOGLE);
+ odp.pfnDlgProc = GoogleOptDlgProc;
+// #if MIRANDA_VER >= 0x0600
+ //odp.ptszTab = TranslateTS(const_cast<LPTSTR>(GetInfo().m_sName.c_str()));
+ odp.ptszTab = const_cast<LPTSTR>(GetInfo().m_sName.c_str());
+// #else
+// tostringstream o;
+// o << TranslateTS(QUOTES_PROTOCOL_NAME) << _T(" - ") << TranslateTS(GetInfo().m_sName.c_str());
+// tstring sTitle = o.str();
+// odp.ptszTitle = TranslateTS(const_cast<LPTSTR>(sTitle.c_str()));
+// #endif
+ Options_AddPage(wp, &odp);
+}
+
+void CQuotesProviderGoogle::Accept(CQuotesProviderVisitor& visitor)const
+{
+ CQuotesProviderBase::Accept(visitor);
+ visitor.Visit(*this);
+}
+
+double CQuotesProviderGoogle::Convert(double dAmount,const CQuote& from,const CQuote& to)const
+{
+ tstring sFullURL = build_url(GetURL(),from.GetID(),to.GetID(),dAmount);
+// LogIt(Info,sFullURL);
+
+ CHTTPSession http;
+ if ((true == http.OpenURL(sFullURL)))
+ {
+ tstring sHTML;
+ if ((true == http.ReadResponce(sHTML)))
+ {
+// LogIt(Info,sHTML);
+
+ double dResult = 0.0;
+ if ((true == parse_responce(sHTML,dResult)))
+ {
+ return dResult;
+ }
+ else
+ {
+ throw std::runtime_error(Translate("Error occurred during html parsing."));
+ }
+ }
+ else
+ {
+ throw std::runtime_error(Translate("Error occurred during site access."));
+ }
+ }
+ else
+ {
+ throw std::runtime_error(Translate("Error occurred during site access."));
+ }
+
+ return 0.0;
+}
+
+namespace
+{
+ bool is_equal_ids(HANDLE hContact,const tstring& rsFromID,const tstring& rsToID)
+ {
+ tstring sFrom = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_FROM_ID);
+ tstring sTo = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_TO_ID);
+ return ((0 == quotes_stricmp(rsFromID.c_str(),sFrom.c_str()))
+ && (0 == quotes_stricmp(rsToID.c_str(),sTo.c_str())));
+ }
+}
+
+HANDLE CQuotesProviderGoogle::GetContactByID(const tstring& rsFromID,const tstring& rsToID)const
+{
+ CGuard<CLightMutex> cs(m_cs);
+
+ TContracts::const_iterator i = std::find_if(m_aContacts.begin(),m_aContacts.end(),
+ boost::bind(is_equal_ids,_1,boost::cref(rsFromID),boost::cref(rsToID)));
+ if(i != m_aContacts.end())
+ {
+ return *i;
+ }
+ else
+ {
+ return NULL;
+ }
+}
diff --git a/plugins/Quotes/src/QuotesProviderGoogle.h b/plugins/Quotes/src/QuotesProviderGoogle.h new file mode 100644 index 0000000000..4289861178 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderGoogle.h @@ -0,0 +1,42 @@ +#ifndef __c0e48a95_b3f0_4227_8adc_455e265f3c14_QuotesProviderGoogle_h__
+#define __c0e48a95_b3f0_4227_8adc_455e265f3c14_QuotesProviderGoogle_h__
+
+#include "quotesproviderBase.h"
+
+#define DB_STR_FROM_ID "FromID"
+#define DB_STR_TO_ID "ToID"
+#define DB_STR_FROM_DESCRIPTION "FromDesc"
+#define DB_STR_TO_DESCRIPTION "ToDesc"
+#define DB_STR_GOOGLE_REFRESH_RATE_TYPE "Google_RefreshRateType"
+#define DB_STR_GOOGLE_REFRESH_RATE_VALUE "Google_RefreshRateValue"
+#define DB_STR_GOOGLE_DISPLAY_NAME_FORMAT "Google_DspNameFrmt"
+// #define DB_STR_GOOGLE_LOG_FILE_FORMAT "Google_LogFileFormat"
+// #define DB_STR_GOOGLE_HISTORY_FORMAT "Google_HistoryFormat"
+
+class CQuotesProviderGoogle : public CQuotesProviderBase
+{
+public:
+ struct CRateInfo
+ {
+ CQuotesProviderBase::CQuote m_from;
+ CQuotesProviderBase::CQuote m_to;
+ };
+public:
+ CQuotesProviderGoogle();
+ ~CQuotesProviderGoogle();
+
+ bool WatchForRate(const CRateInfo& ri,bool bWatch);
+ size_t GetWatchedRateCount()const;
+ bool GetWatchedRateInfo(size_t nIndex,CRateInfo& rRateInfo);
+
+ HANDLE GetContactByID(const tstring& rsFromID,const tstring& rsToID)const;
+
+ double Convert(double dAmount,const CQuote& from,const CQuote& to)const;
+
+private:
+ virtual void RefreshQuotes(TContracts& anContacts);
+ virtual void ShowPropertyPage(WPARAM wp,OPTIONSDIALOGPAGE& odp);
+ virtual void Accept(CQuotesProviderVisitor& visitor)const;
+};
+
+#endif //__c0e48a95_b3f0_4227_8adc_455e265f3c14_QuotesProviderGoogle_h__
diff --git a/plugins/Quotes/src/QuotesProviderGoogleFinance.cpp b/plugins/Quotes/src/QuotesProviderGoogleFinance.cpp new file mode 100644 index 0000000000..8a129b6b8b --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderGoogleFinance.cpp @@ -0,0 +1,366 @@ +#include "StdAfx.h"
+#include "QuotesProviderGoogleFinance.h"
+#include "QuotesProviderVisitor.h"
+#include "EconomicRateInfo.h"
+#include "DBUtils.h"
+#include "resource.h"
+#include "ModuleInfo.h"
+// #include "QuotesProviders.h"
+// #include "CommonOptionDlg.h"
+// #include "WinCtrlHelper.h"
+#include "IHTMLParser.h"
+#include "IHTMLEngine.h"
+#include "HTTPSession.h"
+#include "Log.h"
+#include "Locale.h"
+
+CQuotesProviderGoogleFinance::CQuotesProviderGoogleFinance()
+{
+}
+
+CQuotesProviderGoogleFinance::~CQuotesProviderGoogleFinance()
+{
+}
+
+namespace
+{
+ tstring build_url(HANDLE hContact,const tstring& rsURL)
+ {
+ tostringstream o;
+ o << rsURL << _T("?q=") << Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_ID);
+ return o.str();
+ }
+
+ struct CGoogleInfo
+ {
+ enum
+ {
+ giRate = 0x0001,
+ giOpen = 0x0002,
+ giPercentChangeAfterHours = 0x0004,
+ giPercentChangeToYesterdayClose = 0x0008
+ };
+ CGoogleInfo()
+ : m_dRate(0.0),m_dOpenValue(0.0),m_dPercentChangeAfterHours(0.0),m_dPercentChangeToYersterdayClose(0.0),m_nFlags(0){}
+// tstring m_sCmpID;
+ tstring m_sCmpName;
+ double m_dRate;
+ double m_dOpenValue;
+ double m_dPercentChangeAfterHours;
+ double m_dPercentChangeToYersterdayClose;
+
+// tstring m_sRateID;
+// tstring m_sDiffID;
+ byte m_nFlags;
+ };
+
+ tstring make_rate_id_value(const tstring& rsCmpID,int nFlags)
+ {
+ tostringstream o;
+ o << _T("ref_") << rsCmpID;
+ switch(nFlags)
+ {
+ default:
+ assert(!"Unknown type of value");
+ case CGoogleInfo::giRate:
+ o << _T("_l");
+ break;
+ case CGoogleInfo::giPercentChangeAfterHours:
+ o << _T("_ecp");
+ break;
+ case CGoogleInfo::giPercentChangeToYesterdayClose:
+ o << _T("_cp");
+ break;
+ }
+
+ return o.str();
+ }
+
+ tstring get_var_value(const tstring& rsHTML,LPCTSTR pszVarName,size_t cVarNameLength)
+ {
+ tstring sResult;
+ tstring::size_type n = rsHTML.find(pszVarName);
+ if(tstring::npos != n)
+ {
+ size_t cLengthHTML = rsHTML.size();
+ for(size_t i = n + cVarNameLength;i < cLengthHTML;++i)
+ {
+ TCHAR c = rsHTML[i];
+ if(_T(';') == c)
+ {
+ break;
+ }
+ else
+ {
+ sResult.push_back(c);
+ }
+ }
+ }
+
+ return sResult;
+ }
+
+ tstring get_company_id(const tstring& rsHTML)
+ {
+ static LPCTSTR pszVarName = _T("setCompanyId(");
+ static size_t cVarNameLength = _tcslen(pszVarName);
+
+ tstring sResult;
+ tstring::size_type n = rsHTML.find(pszVarName);
+ if(tstring::npos != n)
+ {
+ size_t cLengthHTML = rsHTML.size();
+ for(size_t i = n + cVarNameLength;i < cLengthHTML;++i)
+ {
+ TCHAR c = rsHTML[i];
+ if(_T(')') == c)
+ {
+ break;
+ }
+ else
+ {
+ sResult.push_back(c);
+ }
+ }
+ }
+ return sResult;
+// return get_var_value(rsHTML,pszVarName,cVarNameLength);
+ }
+
+ tstring get_company_name(const tstring& rsHTML)
+ {
+ static LPCTSTR pszVarName = _T("var _companyName = ");
+ static size_t cVarNameLength = _tcslen(pszVarName);
+
+ tstring s = get_var_value(rsHTML,pszVarName,cVarNameLength);
+ if(s.size() > 0 && _T('\'') == s[0])
+ {
+ s.erase(s.begin());
+ }
+
+ if(s.size() > 0 && _T('\'') == s[s.size()-1])
+ {
+ s.erase(s.rbegin().base()-1);
+ }
+
+ return s;
+ }
+
+ bool get_double_value(const tstring& rsText,double& rdValue)
+ {
+ tistringstream input(rsText);
+ input.imbue(std::locale("English_United States.1252"));
+ input >> rdValue;
+
+ if ((true == input.bad()) || (true == input.fail()))
+ {
+ tistringstream inputSys(rsText);
+ input.imbue(GetSystemLocale());
+ input >> rdValue;
+ return (false == inputSys.bad()) && (false == inputSys.fail());
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ bool get_rate(const IHTMLNode::THTMLNodePtr& pRate,CGoogleInfo& rInfo)
+ {
+ tstring sRate = pRate->GetText();
+
+ if(true == get_double_value(sRate,rInfo.m_dRate))
+ {
+ rInfo.m_nFlags |= CGoogleInfo::giRate;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ bool get_inline_data(const IHTMLNode::THTMLNodePtr& pNode,CGoogleInfo& rInfo)
+ {
+ size_t cChild = pNode->GetChildCount();
+ for(size_t i = 0;i < cChild;++i)
+ {
+ IHTMLNode::THTMLNodePtr pChild = pNode->GetChildPtr(i);
+ size_t c = pChild->GetChildCount();
+ assert(2 == c);
+ if(c >= 2)
+ {
+ IHTMLNode::THTMLNodePtr pName = pChild->GetChildPtr(0);
+
+ tstring sName = pName->GetText();
+ if(0 == quotes_stricmp(sName.c_str(),_T("Open")))
+ {
+ IHTMLNode::THTMLNodePtr pValue = pChild->GetChildPtr(1);
+ tstring sValue = pValue->GetText();
+ if(true == get_double_value(sValue,rInfo.m_dOpenValue))
+ {
+ rInfo.m_nFlags |= CGoogleInfo::giOpen;
+ }
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ bool get_dif_value(const IHTMLNode::THTMLNodePtr& pNode,CGoogleInfo& rInfo,int nItem)
+ {
+ tstring sDiff = pNode->GetText();
+ // this value is in brackets and it has percentage sign.
+ // Remove these symbols.
+ for(tstring::iterator i = sDiff.begin();i != sDiff.end();)
+ {
+ TCHAR s = *i;
+ if(_T('(') == s || _T(')') == s || _T('%') == s)
+ {
+ i = sDiff.erase(i);
+ }
+ else
+ {
+ ++i;
+ }
+ }
+
+ double* pValue = NULL;
+ switch(nItem)
+ {
+ case CGoogleInfo::giPercentChangeAfterHours:
+ pValue = &rInfo.m_dPercentChangeAfterHours;
+ break;
+ case CGoogleInfo::giPercentChangeToYesterdayClose:
+ pValue = &rInfo.m_dPercentChangeToYersterdayClose;
+ break;
+ }
+
+ assert(pValue);
+
+ if ((pValue) && (true == get_double_value(sDiff,*pValue)))
+ {
+ rInfo.m_nFlags |= nItem;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ bool parse_responce(const tstring& rsHTML,CGoogleInfo& rInfo)
+ {
+ IHTMLEngine::THTMLParserPtr pHTMLParser = CModuleInfo::GetHTMLEngine()->GetParserPtr();
+ IHTMLNode::THTMLNodePtr pRoot = pHTMLParser->ParseString(rsHTML);
+ if(pRoot)
+ {
+ tstring sCmpID = get_company_id(rsHTML);
+ if(false == sCmpID.empty())
+ {
+ tstring sRateID = make_rate_id_value(sCmpID,CGoogleInfo::giRate);
+ IHTMLNode::THTMLNodePtr pRate = pRoot->GetElementByID(sRateID);
+ if(pRate && get_rate(pRate,rInfo))
+ {
+ rInfo.m_sCmpName = get_company_name(rsHTML);
+
+ IHTMLNode::THTMLNodePtr pInline = pRoot->GetElementByID(_T("snap-data"));
+ if(pInline)
+ {
+ get_inline_data(pInline,rInfo);
+ }
+
+ tstring sDiffID = make_rate_id_value(sCmpID,CGoogleInfo::giPercentChangeAfterHours);
+ IHTMLNode::THTMLNodePtr pDiff = pRoot->GetElementByID(sDiffID);
+ if(pDiff)
+ {
+ get_dif_value(pDiff,rInfo,CGoogleInfo::giPercentChangeAfterHours);
+ }
+
+ sDiffID = make_rate_id_value(sCmpID,CGoogleInfo::giPercentChangeToYesterdayClose);
+ pDiff = pRoot->GetElementByID(sDiffID);
+ if(pDiff)
+ {
+ get_dif_value(pDiff,rInfo,CGoogleInfo::giPercentChangeToYesterdayClose);
+ }
+
+ return true;
+ }
+
+ //return (true == parse_html_node(pRoot,rInfo));
+ }
+ }
+
+ return false;
+ }
+}
+
+void CQuotesProviderGoogleFinance::RefreshQuotes(TContracts& anContacts)
+{
+ CHTTPSession http;
+ tstring sURL = GetURL();
+ bool bUseExtendedStatus = CModuleInfo::GetInstance().GetExtendedStatusFlag();
+
+ for(TContracts::const_iterator i = anContacts.begin();i != anContacts.end() && IsOnline();++i)
+ {
+ HANDLE hContact = *i;
+
+ if(bUseExtendedStatus)
+ {
+ SetContactStatus(hContact,ID_STATUS_OCCUPIED);
+ }
+
+ tstring sFullURL = build_url(hContact,sURL);
+// LogIt(Info,sFullURL);
+ if ((true == http.OpenURL(sFullURL)) && (true == IsOnline()))
+ {
+ tstring sHTML;
+ if ((true == http.ReadResponce(sHTML)) && (true == IsOnline()))
+ {
+// LogIt(Info,sHTML);
+
+ CGoogleInfo Info;
+ parse_responce(sHTML,Info);
+ if(true == IsOnline())
+ {
+ if(Info.m_nFlags&CGoogleInfo::giRate)
+ {
+ if(Info.m_nFlags&CGoogleInfo::giOpen)
+ {
+ Quotes_DBWriteDouble(hContact,QUOTES_MODULE_NAME,DB_STR_GOOGLE_FINANCE_OPEN_VALUE,Info.m_dOpenValue);
+ }
+ if(Info.m_nFlags&CGoogleInfo::giPercentChangeAfterHours)
+ {
+ Quotes_DBWriteDouble(hContact,QUOTES_MODULE_NAME,DB_STR_GOOGLE_FINANCE_DIFF,Info.m_dPercentChangeAfterHours);
+ }
+ if(Info.m_nFlags&CGoogleInfo::giPercentChangeToYesterdayClose)
+ {
+ Quotes_DBWriteDouble(hContact,QUOTES_MODULE_NAME,DB_STR_GOOGLE_FINANCE_PERCENT_CHANGE_TO_YERSTERDAY_CLOSE,Info.m_dPercentChangeToYersterdayClose);
+ }
+ if(false == Info.m_sCmpName.empty())
+ {
+ DBWriteContactSettingTString(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_DESCRIPTION,Info.m_sCmpName.c_str());
+ }
+
+ WriteContactRate(hContact,Info.m_dRate);
+ continue;
+ }
+ }
+ }
+ }
+
+ SetContactStatus(hContact,ID_STATUS_NA);
+ }
+
+}
+
+
+void CQuotesProviderGoogleFinance::Accept(CQuotesProviderVisitor& visitor)const
+{
+ CQuotesProviderFinance::Accept(visitor);
+ visitor.Visit(*this);
+}
+
diff --git a/plugins/Quotes/src/QuotesProviderGoogleFinance.h b/plugins/Quotes/src/QuotesProviderGoogleFinance.h new file mode 100644 index 0000000000..075498a4dd --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderGoogleFinance.h @@ -0,0 +1,25 @@ +#ifndef __89D3CC58_7DED_484f_AA25_62BDBB57E18B_QuotesProvider_Google_Finance_h__
+#define __89D3CC58_7DED_484f_AA25_62BDBB57E18B_QuotesProvider_Google_Finance_h__
+
+#include "QuotesProviderFinance.h"
+
+#define DB_STR_GOOGLE_FINANCE_OPEN_VALUE "OpenQuotePrice"
+#define DB_STR_GOOGLE_FINANCE_DIFF "DifferentFromStartOfDay"
+#define DB_STR_GOOGLE_FINANCE_PERCENT_CHANGE_TO_YERSTERDAY_CLOSE "PercentChangeToYersterdayClose"
+
+// #define DB_STR_GOOGLE_FINANCE_COMP_NAME "CompanyName"
+
+
+class CQuotesProviderGoogleFinance : public CQuotesProviderFinance
+{
+
+public:
+ CQuotesProviderGoogleFinance();
+ ~CQuotesProviderGoogleFinance();
+
+private:
+ virtual void RefreshQuotes(TContracts& anContacts);
+ virtual void Accept(CQuotesProviderVisitor& visitor)const;
+};
+
+#endif //__89D3CC58_7DED_484f_AA25_62BDBB57E18B_QuotesProvider_Google_Finance_h__
diff --git a/plugins/Quotes/src/QuotesProviderVisitor.h b/plugins/Quotes/src/QuotesProviderVisitor.h new file mode 100644 index 0000000000..9ae601f2a1 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderVisitor.h @@ -0,0 +1,25 @@ +#ifndef __7fca59e7_17b2_4849_bd7a_02c7675f2d76_QuotesProviderVisitor_h__
+#define __7fca59e7_17b2_4849_bd7a_02c7675f2d76_QuotesProviderVisitor_h__
+
+class CQuotesProviderBase;
+class CQuotesProviderFinance;
+class CQuotesProviderDukasCopy;
+class CQuotesProviderGoogle;
+class CQuotesProviderGoogleFinance;
+class CQuotesProviderYahoo;
+
+class CQuotesProviderVisitor
+{
+public:
+ CQuotesProviderVisitor() {}
+ virtual ~CQuotesProviderVisitor() {}
+
+ virtual void Visit(const CQuotesProviderBase& rProvider){}
+ virtual void Visit(const CQuotesProviderFinance& rProvider){}
+ virtual void Visit(const CQuotesProviderDukasCopy& rProvider){}
+ virtual void Visit(const CQuotesProviderGoogle& rProvider){}
+ virtual void Visit(const CQuotesProviderGoogleFinance& rProvider){}
+ virtual void Visit(const CQuotesProviderYahoo& rProvider){}
+};
+
+#endif //__7fca59e7_17b2_4849_bd7a_02c7675f2d76_QuotesProviderVisitor_h__
diff --git a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp new file mode 100644 index 0000000000..5caea48685 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp @@ -0,0 +1,157 @@ +#include "StdAfx.h"
+#include "QuotesProviderVisitorDbSettings.h"
+
+#include "QuotesProviderGoogle.h"
+#include "QuotesProviderDukasCopy.h"
+
+CQuotesProviderVisitorDbSettings::CQuotesProviderVisitorDbSettings()
+ : m_pszDbRefreshRateType(NULL),
+ m_pszDbRefreshRateValue(NULL),
+ m_pszDbDisplayNameFormat(NULL),
+ m_pszDefDisplayFormat(NULL),
+ m_pszDefLogFileFormat(NULL),
+ m_pszDefHistoryFormat(NULL),
+ m_pszXMLIniFileName(NULL),
+ m_pszDbStatusMsgFormat(NULL),
+ m_pszDefStatusMsgFormat(NULL),
+ m_pszDbLogMode(NULL),
+ m_pszDbHistoryFormat(NULL),
+ m_pszDbHistoryCondition(NULL),
+ m_pszDbLogFile(NULL),
+ m_pszDbLogFormat(NULL),
+ m_pszDbLogCondition(NULL),
+ m_pszDbPopupFormat(NULL),
+ m_pszDefPopupFormat(NULL),
+ m_pszDbPopupCondition(NULL),
+ m_pszDbPopupColourMode(NULL),
+ m_pszDbPopupBkColour(NULL),
+ m_pszDbPopupTextColour(NULL),
+ m_pszDbPopupDelayMode(NULL),
+ m_pszDbPopupDelayTimeout(NULL),
+ m_pszDbPopupHistoryFlag(NULL),
+ m_pszDbTendencyFormat(nullptr),
+ m_pszDefTendencyFormat(_T("%r>%p"))
+{
+}
+
+CQuotesProviderVisitorDbSettings::~CQuotesProviderVisitorDbSettings()
+{
+}
+
+void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderBase&/* rProvider*/)
+{
+ m_pszDefLogFileFormat = _T("%s\\t%t\\t%r\\n");
+ m_pszDefHistoryFormat = _T("%s %r");
+ m_pszDefPopupFormat = _T("\\nCurrent = %r\\nPrevious = %p");
+}
+
+void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderDukasCopy&/* rProvider*/)
+{
+ m_pszDbRefreshRateType = DB_STR_REFRESH_RATE_TYPE;
+ m_pszDbRefreshRateValue = DB_STR_REFRESH_RATE_VALUE;
+ m_pszDbDisplayNameFormat = DB_STR_DC_DISPLAY_NAME_FORMAT;
+ m_pszDefDisplayFormat = _T("%s %r");
+ m_pszXMLIniFileName = _T("Dukascopy.xml");
+ m_pszDbStatusMsgFormat = "DC_StatusMessageFormat";
+
+ m_pszDbLogMode = "DC_LogMode";
+ m_pszDbHistoryFormat = "DC_HistoryFormat";
+ m_pszDbHistoryCondition = "DC_AddToHistoryOnlyIfValueIsChanged";
+ m_pszDbLogFile = "DC_LogFile";
+ m_pszDbLogFormat = "DC_LogFileFormat";
+ m_pszDbLogCondition = "DC_AddToLogOnlyIfValueIsChanged";
+ m_pszDbPopupFormat ="DC_PopupFormat";
+ m_pszDbPopupCondition = "DC_ShowPopupOnlyIfValueChanged";
+
+ m_pszDbPopupColourMode = "DC_PopupColourMode";
+ m_pszDbPopupBkColour = "DC_PopupColourBk";
+ m_pszDbPopupTextColour = "DC_PopupColourText";
+ m_pszDbPopupDelayMode = "DC_PopupDelayMode";
+ m_pszDbPopupDelayTimeout = "DC_PopupDelayTimeout";
+ m_pszDbPopupHistoryFlag = "DC_PopupHistoryFlag";
+ m_pszDbTendencyFormat = "DC_TendencyFormat";
+}
+
+void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderGoogle&/* rProvider*/)
+{
+ m_pszDbRefreshRateType = DB_STR_GOOGLE_REFRESH_RATE_TYPE;
+ m_pszDbRefreshRateValue = DB_STR_GOOGLE_REFRESH_RATE_VALUE;
+ m_pszDbDisplayNameFormat = DB_STR_GOOGLE_DISPLAY_NAME_FORMAT;
+ m_pszDefDisplayFormat = _T("1 %f = %r %i");
+ m_pszXMLIniFileName = _T("Google.xml");
+ m_pszDbStatusMsgFormat = "Google_StatusMessageFormat";
+
+ m_pszDbLogMode = "Google_LogMode";
+ m_pszDbHistoryFormat = "Google_HistoryFormat";
+ m_pszDbHistoryCondition = "Google_AddToHistoryOnlyIfValueIsChanged";
+ m_pszDbLogFile = "Google_LogFile";
+ m_pszDbLogFormat = "Google_LogFileFormat";
+ m_pszDbLogCondition = "Google_AddToLogOnlyIfValueIsChanged";
+ m_pszDbPopupFormat ="Google_PopupFormat";
+ m_pszDbPopupCondition = "Google_ShowPopupOnlyIfValueChanged";
+
+ m_pszDbPopupColourMode = "Google_PopupColourMode";
+ m_pszDbPopupBkColour = "Google_PopupColourBk";
+ m_pszDbPopupTextColour = "Google_PopupColourText";
+ m_pszDbPopupDelayMode = "Google_PopupDelayMode";
+ m_pszDbPopupDelayTimeout = "Google_PopupDelayTimeout";
+ m_pszDbPopupHistoryFlag = "Google_PopupHistoryFlag";
+
+ m_pszDbTendencyFormat = "Google_TendencyFormat";
+}
+
+void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderGoogleFinance&/* rProvider*/)
+{
+ m_pszDbRefreshRateType = "GoogleFinance_RefreshRateType";
+ m_pszDbRefreshRateValue = "GoogleFinance_RefreshRateValue";
+ m_pszDbDisplayNameFormat = "GoogleFinance_DspNameFrmt";
+ m_pszDefDisplayFormat = _T("%s %r");
+ m_pszXMLIniFileName = _T("GoogleFinance.xml");
+ m_pszDbStatusMsgFormat = "GoogleFinance_StatusMessageFormat";
+
+ m_pszDbLogMode = "GoogleFinance_LogMode";
+ m_pszDbHistoryFormat = "GoogleFinance_HistoryFormat";
+ m_pszDbHistoryCondition = "GoogleFinance_AddToHistoryOnlyIfValueIsChanged";
+ m_pszDbLogFile = "GoogleFinance_LogFile";
+ m_pszDbLogFormat = "GoogleFinance_LogFileFormat";
+ m_pszDbLogCondition = "GoogleFinance_AddToLogOnlyIfValueIsChanged";
+ m_pszDbPopupFormat ="GoogleFinance_PopupFormat";
+ m_pszDbPopupCondition = "GoogleFinance_ShowPopupOnlyIfValueChanged";
+
+ m_pszDbPopupColourMode = "GoogleFinance_PopupColourMode";
+ m_pszDbPopupBkColour = "GoogleFinance_PopupColourBk";
+ m_pszDbPopupTextColour = "GoogleFinance_PopupColourText";
+ m_pszDbPopupDelayMode = "GoogleFinance_PopupDelayMode";
+ m_pszDbPopupDelayTimeout = "GoogleFinance_PopupDelayTimeout";
+ m_pszDbPopupHistoryFlag = "GoogleFinance_PopupHistoryFlag";
+
+ m_pszDbTendencyFormat = "GoogleFinance_TendencyFormat";
+}
+
+void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderYahoo& rProvider)
+{
+ m_pszDbRefreshRateType = "Yahoo_RefreshRateType";
+ m_pszDbRefreshRateValue = "Yahoo_RefreshRateValue";
+ m_pszDbDisplayNameFormat = "Yahoo_DspNameFrmt";
+ m_pszDefDisplayFormat = _T("%s %r");
+ m_pszXMLIniFileName = _T("Yahoo.xml");
+ m_pszDbStatusMsgFormat = "Yahoo_StatusMessageFormat";
+
+ m_pszDbLogMode = "Yahoo_LogMode";
+ m_pszDbHistoryFormat = "Yahoo_HistoryFormat";
+ m_pszDbHistoryCondition = "Yahoo_AddToHistoryOnlyIfValueIsChanged";
+ m_pszDbLogFile = "Yahoo_LogFile";
+ m_pszDbLogFormat = "Yahoo_LogFileFormat";
+ m_pszDbLogCondition = "Yahoo_AddToLogOnlyIfValueIsChanged";
+ m_pszDbPopupFormat ="Yahoo_PopupFormat";
+ m_pszDbPopupCondition = "Yahoo_ShowPopupOnlyIfValueChanged";
+
+ m_pszDbPopupColourMode = "Yahoo_PopupColourMode";
+ m_pszDbPopupBkColour = "Yahoo_PopupColourBk";
+ m_pszDbPopupTextColour = "Yahoo_PopupColourText";
+ m_pszDbPopupDelayMode = "Yahoo_PopupDelayMode";
+ m_pszDbPopupDelayTimeout = "Yahoo_PopupDelayTimeout";
+ m_pszDbPopupHistoryFlag = "Yahoo_PopupHistoryFlag";
+
+ m_pszDbTendencyFormat = "Yahoo_TendencyFormat";
+}
diff --git a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h new file mode 100644 index 0000000000..728a436dfa --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h @@ -0,0 +1,49 @@ +#ifndef __97cd432a_1119_4803_a96f_0abc1cc2653f_QuotesProviderVisitorDbSettings_h__
+#define __97cd432a_1119_4803_a96f_0abc1cc2653f_QuotesProviderVisitorDbSettings_h__
+
+#include "quotesprovidervisitor.h"
+
+class CQuotesProviderVisitorDbSettings : public CQuotesProviderVisitor
+{
+public:
+ CQuotesProviderVisitorDbSettings();
+ ~CQuotesProviderVisitorDbSettings();
+
+private:
+ virtual void Visit(const CQuotesProviderBase& rProvider);
+ virtual void Visit(const CQuotesProviderDukasCopy& rProvider);
+ virtual void Visit(const CQuotesProviderGoogle& rProvider);
+ virtual void Visit(const CQuotesProviderGoogleFinance& rProvider);
+ virtual void Visit(const CQuotesProviderYahoo& rProvider);
+public:
+ LPCSTR m_pszDbRefreshRateType;
+ LPCSTR m_pszDbRefreshRateValue;
+ LPCSTR m_pszDbDisplayNameFormat;
+ LPCTSTR m_pszDefDisplayFormat;
+ LPCTSTR m_pszDefLogFileFormat;
+ LPCTSTR m_pszDefHistoryFormat;
+ LPCTSTR m_pszXMLIniFileName;
+ LPCSTR m_pszDbStatusMsgFormat;
+ LPCTSTR m_pszDefStatusMsgFormat;
+ LPCTSTR m_pszDefPopupFormat;
+ LPCSTR m_pszDbTendencyFormat;
+ LPCTSTR m_pszDefTendencyFormat;
+
+ //global settings
+ LPCSTR m_pszDbLogMode;
+ LPCSTR m_pszDbHistoryFormat;
+ LPCSTR m_pszDbHistoryCondition;
+ LPCSTR m_pszDbLogFile;
+ LPCSTR m_pszDbLogFormat;
+ LPCSTR m_pszDbLogCondition;
+ LPCSTR m_pszDbPopupFormat;
+ LPCSTR m_pszDbPopupCondition;
+ LPCSTR m_pszDbPopupColourMode;
+ LPCSTR m_pszDbPopupBkColour;
+ LPCSTR m_pszDbPopupTextColour;
+ LPCSTR m_pszDbPopupDelayMode;
+ LPCSTR m_pszDbPopupDelayTimeout;
+ LPCSTR m_pszDbPopupHistoryFlag;
+};
+
+#endif //__97cd432a_1119_4803_a96f_0abc1cc2653f_QuotesProviderVisitorDbSettings_h__
diff --git a/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.cpp b/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.cpp new file mode 100644 index 0000000000..9e643fe1b6 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.cpp @@ -0,0 +1,63 @@ +#include "StdAfx.h"
+#include "QuotesProviderVisitorFormatSpecificator.h"
+
+CQuotesProviderVisitorFormatSpecificator::CQuotesProviderVisitorFormatSpecificator()
+{
+}
+
+CQuotesProviderVisitorFormatSpecificator::~CQuotesProviderVisitorFormatSpecificator()
+{
+}
+
+void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderDukasCopy&/* rProvider*/)
+{
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%s"),TranslateT("Quote Symbol")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%d"),TranslateT("Quote Name")));
+}
+
+void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderGoogle&/* rProvider*/)
+{
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%F"),TranslateT("From Currency Full Name")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%f"),TranslateT("From Currency Short Name")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%I"),TranslateT("Into Currency Full Name")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%i"),TranslateT("Into Currency Short Name")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%s"),TranslateT("Short notation for \"%f/%i\"")));
+}
+
+void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderBase&/* rProvider*/)
+{
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%S"),TranslateT("Source of Information")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%r"),TranslateT("Rate Value")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%p"),TranslateT("Previous Rate Value")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%X"),TranslateT("Fetch Time")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%x"),TranslateT("Fetch Date")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%t"),TranslateT("Fetch Time and Date")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("\\%"),TranslateT("Percentage Character (%)")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("\\t"),TranslateT("Tabulation")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("\\\\"),TranslateT("Left slash (\\)")));
+}
+
+void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderGoogleFinance&/* rProvider*/)
+{
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%s"),TranslateT("Quote Symbol")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%n"),TranslateT("Quote Name")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%o"),TranslateT("Open Price")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%d"),TranslateT("Percent Change to After Hours")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%y"),TranslateT("Percent Change to Yesterday Close")));
+}
+
+const CQuotesProviderVisitorFormatSpecificator::TFormatSpecificators& CQuotesProviderVisitorFormatSpecificator::GetSpecificators()const
+{
+ return m_aSpecificators;
+}
+
+void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderYahoo& rProvider)
+{
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%s"),TranslateT("Quote Symbol")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%n"),TranslateT("Quote Name")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%o"),TranslateT("Open Price")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%h"),TranslateT("Day's High")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%g"),TranslateT("Day's Low")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%P"),TranslateT("Previous Close")));
+ m_aSpecificators.push_back(CFormatSpecificator(_T("%c"),TranslateT("Change")));
+}
diff --git a/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.h b/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.h new file mode 100644 index 0000000000..870ab00634 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.h @@ -0,0 +1,36 @@ +#ifndef __00c159f3_525a_41e9_8fc5_00464b6fafa3_QuotesProviderVisitorFormatSpecificator_h__
+#define __00c159f3_525a_41e9_8fc5_00464b6fafa3_QuotesProviderVisitorFormatSpecificator_h__
+
+#include "quotesprovidervisitor.h"
+
+class CQuotesProviderVisitorFormatSpecificator : public CQuotesProviderVisitor
+{
+public:
+ struct CFormatSpecificator
+ {
+ CFormatSpecificator(const tstring& rsSymbol = _T(""),const tstring& rsDec = _T(""))
+ : m_sSymbol(rsSymbol),m_sDesc(rsDec){}
+
+ tstring m_sSymbol;
+ tstring m_sDesc;
+ };
+ typedef std::vector<CFormatSpecificator> TFormatSpecificators;
+
+public:
+ CQuotesProviderVisitorFormatSpecificator();
+ ~CQuotesProviderVisitorFormatSpecificator();
+
+ const TFormatSpecificators& GetSpecificators()const;
+
+private:
+ virtual void Visit(const CQuotesProviderDukasCopy& rProvider);
+ virtual void Visit(const CQuotesProviderGoogle& rProvider);
+ virtual void Visit(const CQuotesProviderBase& rProvider);
+ virtual void Visit(const CQuotesProviderGoogleFinance& rProvider);
+ virtual void Visit(const CQuotesProviderYahoo& rProvider);
+
+private:
+ TFormatSpecificators m_aSpecificators;
+};
+
+#endif//__00c159f3_525a_41e9_8fc5_00464b6fafa3_QuotesProviderVisitorFormatSpecificator_h__
diff --git a/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp b/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp new file mode 100644 index 0000000000..4b1d73bb05 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp @@ -0,0 +1,216 @@ +#include "StdAfx.h"
+#include "QuotesProviderVisitorFormater.h"
+#include "DBUtils.h"
+#include "EconomicRateInfo.h"
+#include "QuotesProviderGoogle.h"
+#include "Locale.h"
+#include "IsWithinAccuracy.h"
+#include "QuotesProviderGoogleFinance.h"
+#include "QuotesProviderYahoo.h"
+
+CQuotesProviderVisitorFormater::CQuotesProviderVisitorFormater(HANDLE hContact,TCHAR chr,int nWidth)
+ : m_hContact(hContact),
+ m_chr(chr),
+ m_nWidth(nWidth)
+{
+}
+
+CQuotesProviderVisitorFormater::~CQuotesProviderVisitorFormater()
+{
+}
+
+const tstring& CQuotesProviderVisitorFormater::GetResult()const
+{
+ return m_sResult;
+}
+
+void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderDukasCopy& rProvider)
+{
+ if(_T('d') == m_chr || _T('D') == m_chr)
+ {
+ m_sResult = Quotes_DBGetStringT(m_hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_DESCRIPTION);
+ }
+}
+
+void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderGoogle& rProvider)
+{
+ switch(m_chr)
+ {
+ case _T('F'):
+ m_sResult = Quotes_DBGetStringT(m_hContact,QUOTES_MODULE_NAME,DB_STR_FROM_DESCRIPTION);
+ break;
+ case _T('f'):
+ m_sResult = Quotes_DBGetStringT(m_hContact,QUOTES_MODULE_NAME,DB_STR_FROM_ID);
+ break;
+ case _T('I'):
+ m_sResult = Quotes_DBGetStringT(m_hContact,QUOTES_MODULE_NAME,DB_STR_TO_DESCRIPTION);
+ break;
+ case _T('i'):
+ m_sResult = Quotes_DBGetStringT(m_hContact,QUOTES_MODULE_NAME,DB_STR_TO_ID);
+ break;
+ }
+}
+
+namespace
+{
+ bool get_fetch_time(HANDLE hContact,time_t& rTime)
+ {
+ DBVARIANT dbv;
+ DBCONTACTGETSETTING cgs;
+
+ cgs.szModule=QUOTES_MODULE_NAME;
+ cgs.szSetting=DB_STR_QUOTE_FETCH_TIME;
+ cgs.pValue=&dbv;
+ if(CallService(MS_DB_CONTACT_GETSETTING,reinterpret_cast<WPARAM>(hContact),reinterpret_cast<LPARAM>(&cgs))
+ || (DBVT_DWORD != dbv.type))
+ {
+ return false;
+ }
+
+ rTime = dbv.dVal;
+ return true;
+ }
+
+ tstring format_fetch_time(const CQuotesProviderBase& rProvider,HANDLE hContact,const tstring& rsFormat)
+ {
+ time_t nTime;
+ if(true == get_fetch_time(hContact,nTime))
+ {
+ boost::posix_time::ptime time = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(boost::posix_time::from_time_t(nTime));
+ tostringstream k;
+ k.imbue(std::locale(GetSystemLocale(),new ttime_facet(rsFormat.c_str())));
+ k << time;
+ return k.str();
+ }
+
+ return tstring();
+ }
+}
+
+void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderBase& rProvider)
+{
+ switch(m_chr)
+ {
+// default:
+// m_sResult = m_chr;
+// break;
+ case _T('%'):
+ case _T('\t'):
+ case _T('\\'):
+ m_sResult = m_chr;
+ break;
+ case _T('S'):
+ m_sResult = Quotes_DBGetStringT(m_hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_PROVIDER);
+ break;
+ case _T('s'):
+ m_sResult = Quotes_DBGetStringT(m_hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_SYMBOL);
+ break;
+ case _T('X'):
+ //m_sResult = format_fetch_time(rProvider,m_hContact,_T("%H:%M:%S"));
+ m_sResult = format_fetch_time(rProvider,m_hContact,Quotes_GetTimeFormat(true));
+ break;
+ case _T('x'):
+ //m_sResult = format_fetch_time(rProvider,m_hContact,_T("%d.%m.%y"));
+ m_sResult = format_fetch_time(rProvider,m_hContact,Quotes_GetDateFormat(true));
+ break;
+ case _T('t'):
+ {
+ tstring sFrmt = Quotes_GetDateFormat(true);
+ sFrmt += _T(" ");
+ sFrmt += Quotes_GetTimeFormat(true);
+ m_sResult = format_fetch_time(rProvider,m_hContact,sFrmt);
+
+ //m_sResult = format_fetch_time(rProvider,m_hContact,_T("%d.%m.%y %H:%M:%S"));
+ }
+ break;
+ case _T('r'):
+ case _T('R'):
+ FormatDoubleHelper(DB_STR_QUOTE_CURR_VALUE);
+ break;
+ case _T('p'):
+ FormatDoubleHelper(DB_STR_QUOTE_PREV_VALUE);
+ break;
+// case _T('c'):
+// FormatChangeValueHelper(false);
+// break;
+// case _T('C'):
+// FormatChangeValueHelper(true);
+// break;
+ }
+}
+
+void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderGoogleFinance&/* rProvider*/)
+{
+ switch(m_chr)
+ {
+ case _T('o'):
+ FormatDoubleHelper(DB_STR_GOOGLE_FINANCE_OPEN_VALUE);
+ break;
+ case _T('d'):
+ FormatDoubleHelper(DB_STR_GOOGLE_FINANCE_DIFF,_T("0"));
+ break;
+ case _T('y'):
+ FormatDoubleHelper(DB_STR_GOOGLE_FINANCE_PERCENT_CHANGE_TO_YERSTERDAY_CLOSE,_T("0"));
+ break;
+ case _T('n'):
+ m_sResult = Quotes_DBGetStringT(m_hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_DESCRIPTION);
+ break;
+ }
+}
+
+namespace
+{
+ tstring format_double(double dValue,int nWidth)
+ {
+ tostringstream o;
+ o.imbue(GetSystemLocale());
+
+ if(nWidth > 0 && nWidth <= 9)
+ {
+ o << std::setprecision(nWidth) << std::showpoint << std::fixed;
+ }
+ o << dValue;
+
+ return o.str();
+ }
+}
+
+void CQuotesProviderVisitorFormater::FormatDoubleHelper(LPCSTR pszDbSet,
+ const tstring sInvalid/* = _T("-")*/)
+{
+ double d = 0.0;
+ if(true == Quotes_DBReadDouble(m_hContact,QUOTES_MODULE_NAME,pszDbSet,d))
+ {
+ m_sResult = format_double(d,m_nWidth);
+ }
+ else
+ {
+ m_sResult = sInvalid;
+ }
+}
+
+void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderYahoo& rProvider)
+{
+ switch(m_chr)
+ {
+ case _T('o'):
+ FormatDoubleHelper(DB_STR_YAHOO_OPEN_VALUE);
+ break;
+ case _T('h'):
+ FormatDoubleHelper(DB_STR_YAHOO_DAY_HIGH);
+ break;
+ case _T('P'):
+ FormatDoubleHelper(DB_STR_YAHOO_PREVIOUS_CLOSE);
+ break;
+ case _T('c'):
+ FormatDoubleHelper(DB_STR_YAHOO_CHANGE);
+ break;
+ case _T('g'):
+ FormatDoubleHelper(DB_STR_YAHOO_DAY_LOW);
+ break;
+ case _T('n'):
+ m_sResult = Quotes_DBGetStringT(m_hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_DESCRIPTION);
+ break;
+ }
+
+}
diff --git a/plugins/Quotes/src/QuotesProviderVisitorFormater.h b/plugins/Quotes/src/QuotesProviderVisitorFormater.h new file mode 100644 index 0000000000..7c9c222269 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderVisitorFormater.h @@ -0,0 +1,32 @@ +#ifndef __2b5ddd05_9255_4be0_9408_e59768b70568_QuotesProviderVisitorFormater_h__
+#define __2b5ddd05_9255_4be0_9408_e59768b70568_QuotesProviderVisitorFormater_h__
+
+#include "quotesprovidervisitor.h"
+
+class CQuotesProviderVisitorFormater : public CQuotesProviderVisitor
+{
+public:
+ CQuotesProviderVisitorFormater(HANDLE hContact,TCHAR chr,int nWidth);
+ ~CQuotesProviderVisitorFormater();
+
+ const tstring& GetResult()const;
+
+private:
+ virtual void Visit(const CQuotesProviderDukasCopy& rProvider);
+ virtual void Visit(const CQuotesProviderGoogle& rProvider);
+ virtual void Visit(const CQuotesProviderBase& rProvider);
+ virtual void Visit(const CQuotesProviderGoogleFinance& rProvider);
+ virtual void Visit(const CQuotesProviderYahoo& rProvider);
+
+private:
+ void FormatDoubleHelper(LPCSTR pszDbSet,const tstring sInvalid = _T("-"));
+// void FormatChangeValueHelper(bool bPercentage);
+
+private:
+ HANDLE m_hContact;
+ TCHAR m_chr;
+ tstring m_sResult;
+ int m_nWidth;
+};
+
+#endif //__2b5ddd05_9255_4be0_9408_e59768b70568_QuotesProviderVisitorFormater_h__
diff --git a/plugins/Quotes/src/QuotesProviderVisitorTendency.cpp b/plugins/Quotes/src/QuotesProviderVisitorTendency.cpp new file mode 100644 index 0000000000..00703521b3 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderVisitorTendency.cpp @@ -0,0 +1,70 @@ +#include "stdafx.h"
+#include "QuotesProviderVisitorTendency.h"
+#include "DBUtils.h"
+#include "QuotesProviderGoogleFinance.h"
+#include "EconomicRateInfo.h"
+#include "QuotesProviderYahoo.h"
+
+CQuotesProviderVisitorTendency::CQuotesProviderVisitorTendency(HANDLE hContact,TCHAR chr)
+ : m_hContact(hContact),m_chr(chr),m_bValid(false),m_dResult(0.0)
+{
+}
+
+void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderBase& rProvider)
+{
+ switch(m_chr)
+ {
+ case _T('r'):
+ case _T('R'):
+ GetValue(DB_STR_QUOTE_CURR_VALUE);
+ break;
+ case _T('p'):
+ GetValue(DB_STR_QUOTE_PREV_VALUE);
+ break;
+ }
+}
+
+void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderGoogleFinance& rProvider)
+{
+ switch(m_chr)
+ {
+ case _T('o'):
+ GetValue(DB_STR_GOOGLE_FINANCE_OPEN_VALUE);
+ break;
+ case _T('d'):
+ GetValue(DB_STR_GOOGLE_FINANCE_DIFF);
+ break;
+ case _T('y'):
+ GetValue(DB_STR_GOOGLE_FINANCE_PERCENT_CHANGE_TO_YERSTERDAY_CLOSE);
+ break;
+ }
+}
+
+void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderYahoo& rProvider)
+{
+ switch(m_chr)
+ {
+ case _T('o'):
+ GetValue(DB_STR_YAHOO_OPEN_VALUE);
+ break;
+ case _T('h'):
+ GetValue(DB_STR_YAHOO_DAY_HIGH);
+ break;
+ case _T('P'):
+ GetValue(DB_STR_YAHOO_PREVIOUS_CLOSE);
+ break;
+ case _T('c'):
+ GetValue(DB_STR_YAHOO_CHANGE);
+ break;
+ case _T('g'):
+ GetValue(DB_STR_YAHOO_DAY_LOW);
+ break;
+ }
+
+}
+
+
+void CQuotesProviderVisitorTendency::GetValue(LPCSTR pszDbKeyName)
+{
+ m_bValid = Quotes_DBReadDouble(m_hContact,QUOTES_MODULE_NAME,pszDbKeyName,m_dResult);
+}
diff --git a/plugins/Quotes/src/QuotesProviderVisitorTendency.h b/plugins/Quotes/src/QuotesProviderVisitorTendency.h new file mode 100644 index 0000000000..fa0f04c5f0 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderVisitorTendency.h @@ -0,0 +1,29 @@ +#ifndef __AD721194_E9944366_9CF1_0307460EF32F_QuotesProviderVisitorTendency_h__
+#define __AD721194_E9944366_9CF1_0307460EF32F_QuotesProviderVisitorTendency_h__
+
+#include "quotesprovidervisitor.h"
+
+class CQuotesProviderVisitorTendency : public CQuotesProviderVisitor
+{
+public:
+ CQuotesProviderVisitorTendency(HANDLE hContact,TCHAR chr);
+
+ bool IsValid()const{return m_bValid;}
+ double GetResult()const{return m_dResult;}
+
+private:
+ virtual void Visit(const CQuotesProviderBase& rProvider);
+ virtual void Visit(const CQuotesProviderGoogleFinance& rProvider);
+ virtual void Visit(const CQuotesProviderYahoo& rProvider);
+
+private:
+ void GetValue(LPCSTR pszDbKeyName);
+
+private:
+ HANDLE m_hContact;
+ TCHAR m_chr;
+ bool m_bValid;
+ double m_dResult;
+};
+
+#endif //__AD721194_E9944366_9CF1_0307460EF32F_QuotesProviderVisitorTendency_h__
diff --git a/plugins/Quotes/src/QuotesProviderYahoo.cpp b/plugins/Quotes/src/QuotesProviderYahoo.cpp new file mode 100644 index 0000000000..35edb3207c --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderYahoo.cpp @@ -0,0 +1,193 @@ +#include "stdafx.h"
+#include "QuotesProviderYahoo.h"
+#include "QuotesProviderVisitor.h"
+#include "ModuleInfo.h"
+#include "DBUtils.h"
+#include "EconomicRateInfo.h"
+#include "HTTPSession.h"
+
+namespace
+{
+ void remove_quotes(tstring& s)
+ {
+ if (*s.begin() == _T('"'))
+ {
+ s.erase(s.begin());
+ }
+ if (*s.rbegin() == _T('"'))
+ {
+ tstring::iterator i(s.begin());
+ std::advance(i,s.size()-1);
+ s.erase(i);
+ }
+ }
+
+ void remove_end_of_line(tstring& s)
+ {
+ if (*s.rbegin() == _T('\n'))
+ {
+ tstring::iterator i(s.begin());
+ std::advance(i,s.size()-1);
+ s.erase(i);
+ }
+ if (*s.rbegin() == _T('\r'))
+ {
+ tstring::iterator i(s.begin());
+ std::advance(i,s.size()-1);
+ s.erase(i);
+ }
+ }
+
+ bool t2d(const tstring& s,double& d)
+ {
+ tistringstream stream(s);
+ stream >> d;
+ return ((false == stream.fail()) && (false == stream.bad()));
+// try
+// {
+// d = boost::lexical_cast<double>(s);
+// return true;
+// }
+// catch(boost::bad_lexical_cast& e)
+// {
+// }
+// return false;
+ }
+
+ typedef std::vector<tstring> TStrings;
+
+ bool get_double_from_parsed_line(HANDLE hContact,const TStrings& rasParsedLine,size_t nIndex,const char* pszDbName)
+ {
+ if(rasParsedLine.size() > nIndex)
+ {
+ double d = 0.0;
+ if(true == t2d(rasParsedLine[nIndex],d))
+ {
+ return Quotes_DBWriteDouble(hContact,QUOTES_MODULE_NAME,pszDbName,d);
+ }
+ }
+
+ DBWriteContactSettingTString(hContact,QUOTES_MODULE_NAME,pszDbName,_T(""));
+ return false;
+ }
+}
+
+void CQuotesProviderYahoo::RefreshQuotes(TContracts& anContacts)
+{
+ tstring sURL = GetURL();
+ bool bUseExtendedStatus = CModuleInfo::GetInstance().GetExtendedStatusFlag();
+
+ typedef std::map<tstring,HANDLE> TQuoteID2ContractHandles;
+ TQuoteID2ContractHandles aQuoteID2Handles;
+ tostringstream oURL;
+ oURL << sURL << _T("dioksin.txt?s=");
+ for(TContracts::const_iterator i = anContacts.begin();i != anContacts.end() && IsOnline();++i)
+ {
+ HANDLE hContact = *i;
+ if(bUseExtendedStatus)
+ {
+ SetContactStatus(hContact,ID_STATUS_OCCUPIED);
+ }
+
+ tstring sQuoteID = Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_ID);
+ aQuoteID2Handles[sQuoteID] = hContact;
+ if(i != anContacts.begin())
+ {
+ oURL << _T("+");
+ }
+ oURL << sQuoteID;
+ }
+
+ if(true == IsOnline())
+ {
+ oURL << _T("&f=snl1ohgpc1");
+ CHTTPSession http;
+ if ((true == http.OpenURL(oURL.str())) && (true == IsOnline()))
+ {
+ tstring sFile;
+ if ((true == http.ReadResponce(sFile)) && (true == IsOnline()))
+ {
+ tistringstream out_str(sFile.c_str());
+ while(false == out_str.eof())
+ {
+ tstring sLine;
+ std::getline(out_str,sLine);
+ if(false == sLine.empty())
+ {
+ remove_end_of_line(sLine);
+
+ TStrings asStrings;
+ for(tstring::size_type nPos = sLine.find(_T(','));nPos != tstring::npos; nPos = sLine.find(_T(',')))
+ {
+ tstring::iterator i(sLine.begin());
+ std::advance(i,nPos);
+ tstring s(sLine.begin(),i);
+ remove_quotes(s);
+ asStrings.push_back(s);
+
+ if(i != sLine.end())
+ {
+ std::advance(i,1);
+ }
+ sLine.erase(sLine.begin(),i);
+ }
+
+ if(false == sLine.empty())
+ {
+ remove_quotes(sLine);
+
+ if(false == sLine.empty())
+ asStrings.push_back(sLine);
+ }
+
+ size_t cItems = asStrings.size();
+ if(cItems >= 3)
+ {
+ enum
+ {
+ indexSymbol = 0,
+ indexName,
+ indexLastTrade,
+ indexOpen,
+ indexDayHigh,
+ indexDayLow,
+ indexPreviousClose,
+ indexChange
+ };
+ auto it3 = aQuoteID2Handles.find(asStrings[indexSymbol]);
+ if(it3 != aQuoteID2Handles.end())
+ {
+ HANDLE hContact = it3->second;
+ double dRate = 0.0;
+ if(true == t2d(asStrings[indexLastTrade],dRate))
+ {
+ DBWriteContactSettingTString(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_DESCRIPTION,asStrings[indexName].c_str());
+
+ get_double_from_parsed_line(hContact,asStrings,indexOpen,DB_STR_YAHOO_OPEN_VALUE);
+ get_double_from_parsed_line(hContact,asStrings,indexDayHigh,DB_STR_YAHOO_DAY_HIGH);
+ get_double_from_parsed_line(hContact,asStrings,indexDayLow,DB_STR_YAHOO_DAY_LOW);
+ get_double_from_parsed_line(hContact,asStrings,indexPreviousClose,DB_STR_YAHOO_PREVIOUS_CLOSE);
+ get_double_from_parsed_line(hContact,asStrings,indexChange,DB_STR_YAHOO_CHANGE);
+ WriteContactRate(hContact,dRate);
+ aQuoteID2Handles.erase(it3);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(true == IsOnline())
+ {
+ std::for_each(aQuoteID2Handles.begin(),aQuoteID2Handles.end(),
+ [](const TQuoteID2ContractHandles::value_type& pair){SetContactStatus(pair.second,ID_STATUS_NA);});
+ }
+ }
+}
+
+void CQuotesProviderYahoo::Accept(CQuotesProviderVisitor& visitor)const
+{
+ CQuotesProviderFinance::Accept(visitor);
+ visitor.Visit(*this);
+}
diff --git a/plugins/Quotes/src/QuotesProviderYahoo.h b/plugins/Quotes/src/QuotesProviderYahoo.h new file mode 100644 index 0000000000..feadefbca4 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviderYahoo.h @@ -0,0 +1,20 @@ +#ifndef __E927F394_5452_458E_AF48_71E44F9EE793_QuotesProviderYahoo_h__
+#define __E927F394_5452_458E_AF48_71E44F9EE793_QuotesProviderYahoo_h__
+
+#include "QuotesProviderFinance.h"
+
+
+#define DB_STR_YAHOO_OPEN_VALUE "OpenQuotePrice"
+#define DB_STR_YAHOO_DAY_HIGH "DayHigh"
+#define DB_STR_YAHOO_DAY_LOW "DayLow"
+#define DB_STR_YAHOO_PREVIOUS_CLOSE "PreviousClose"
+#define DB_STR_YAHOO_CHANGE "Change"
+
+class CQuotesProviderYahoo : public CQuotesProviderFinance
+{
+private:
+ virtual void RefreshQuotes(TContracts& anContacts);
+ virtual void Accept(CQuotesProviderVisitor& visitor)const;
+};
+
+#endif //__E927F394_5452_458E_AF48_71E44F9EE793_QuotesProviderYahoo_h__
diff --git a/plugins/Quotes/src/QuotesProviders.cpp b/plugins/Quotes/src/QuotesProviders.cpp new file mode 100644 index 0000000000..26cbb067ea --- /dev/null +++ b/plugins/Quotes/src/QuotesProviders.cpp @@ -0,0 +1,119 @@ +#include "StdAfx.h"
+#include "QuotesProviders.h"
+
+#include "QuotesProviderDukasCopy.h"
+#include "EconomicRateInfo.h"
+#include "QuotesProviderGoogle.h"
+#include "DBUtils.h"
+#include "QuotesProviderGoogleFinance.h"
+#include "QuotesProviderYahoo.h"
+
+#define LAST_RUN_VERSION "LastRunVersion"
+
+CQuotesProviders::CQuotesProviders()
+{
+ InitProviders();
+}
+
+CQuotesProviders::~CQuotesProviders()
+{
+ ClearProviders();
+}
+
+const CQuotesProviders::TQuotesProviders& CQuotesProviders::GetProviders()const
+{
+ return m_apProviders;
+}
+
+namespace
+{
+ template<class T>void create_provider(CQuotesProviders::TQuotesProviders& apProviders)
+ {
+ CQuotesProviders::TQuotesProviderPtr pProvider(new T);
+ if(pProvider->Init())
+ {
+ apProviders.push_back(pProvider);
+ }
+ }
+}
+
+void CQuotesProviders::CreateProviders()
+{
+ create_provider<CQuotesProviderDukasCopy>(m_apProviders);
+ create_provider<CQuotesProviderGoogle>(m_apProviders);
+ create_provider<CQuotesProviderGoogleFinance>(m_apProviders);
+ create_provider<CQuotesProviderYahoo>(m_apProviders);
+}
+
+void CQuotesProviders::ClearProviders()
+{
+ m_apProviders.clear();
+}
+
+namespace
+{
+ void convert_contact_settings(HANDLE hContact)
+ {
+ WORD dwLogMode = DBGetContactSettingWord(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG,static_cast<WORD>(lmDisabled));
+ if ((dwLogMode&lmInternalHistory) || (dwLogMode&lmExternalFile))
+ {
+ DBWriteContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_CONTACT_SPEC_SETTINGS,1);
+ }
+ }
+}
+void CQuotesProviders::InitProviders()
+{
+ CreateProviders();
+
+ const WORD nCurrentVersion = 17;
+ WORD nVersion = DBGetContactSettingWord(NULL,QUOTES_MODULE_NAME,LAST_RUN_VERSION,1);
+
+ for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ {
+ TQuotesProviderPtr pProvider = GetContactProviderPtr(hContact);
+ if(pProvider)
+ {
+ pProvider->AddContact(hContact);
+ if(nVersion < nCurrentVersion)
+ {
+ convert_contact_settings(hContact);
+ }
+ }
+ }
+
+ DBWriteContactSettingWord(NULL,QUOTES_MODULE_NAME,LAST_RUN_VERSION,nCurrentVersion);
+}
+
+CQuotesProviders::TQuotesProviderPtr CQuotesProviders::GetContactProviderPtr(HANDLE hContact)const
+{
+ char* szProto = GetContactProto(hContact);
+ if(NULL == szProto || 0 != ::_stricmp(szProto, QUOTES_PROTOCOL_NAME))
+ {
+ return TQuotesProviderPtr();
+ }
+
+ tstring sProvider = Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_PROVIDER);
+ if(true == sProvider.empty())
+ {
+ return TQuotesProviderPtr();
+ }
+
+ return FindProvider(sProvider);
+}
+
+CQuotesProviders::TQuotesProviderPtr CQuotesProviders::FindProvider(const tstring& rsName)const
+{
+ TQuotesProviderPtr pResult;
+ for(TQuotesProviders::const_iterator i = m_apProviders.begin();i != m_apProviders.end();++i)
+ {
+ const TQuotesProviderPtr& pProvider = *i;
+ const IQuotesProvider::CProviderInfo& rInfo = pProvider->GetInfo();
+ if(0 == ::quotes_stricmp(rsName.c_str(),rInfo.m_sName.c_str()))
+ {
+ pResult = pProvider;
+ break;
+ }
+ }
+
+ return pResult;
+}
diff --git a/plugins/Quotes/src/QuotesProviders.h b/plugins/Quotes/src/QuotesProviders.h new file mode 100644 index 0000000000..02aa5184c9 --- /dev/null +++ b/plugins/Quotes/src/QuotesProviders.h @@ -0,0 +1,32 @@ +#ifndef __148306d1_da2a_43df_b1ad_0cdc8ef8a79e_QuotesProviders_h__
+#define __148306d1_da2a_43df_b1ad_0cdc8ef8a79e_QuotesProviders_h__
+
+#include <boost\shared_ptr.hpp>
+#include <vector>
+
+class IQuotesProvider;
+
+class CQuotesProviders
+{
+public:
+ typedef boost::shared_ptr<IQuotesProvider> TQuotesProviderPtr;
+ typedef std::vector<TQuotesProviderPtr> TQuotesProviders;
+
+public:
+ CQuotesProviders();
+ ~CQuotesProviders();
+
+ TQuotesProviderPtr FindProvider(const tstring& rsName)const;
+ TQuotesProviderPtr GetContactProviderPtr(HANDLE hContact)const;
+ const TQuotesProviders& GetProviders()const;
+
+private:
+ void InitProviders();
+ void CreateProviders();
+ void ClearProviders();
+
+private:
+ TQuotesProviders m_apProviders;
+};
+
+#endif //__148306d1_da2a_43df_b1ad_0cdc8ef8a79e_QuotesProviders_h__
diff --git a/plugins/Quotes/src/SettingsDlg.cpp b/plugins/Quotes/src/SettingsDlg.cpp new file mode 100644 index 0000000000..0011d2e917 --- /dev/null +++ b/plugins/Quotes/src/SettingsDlg.cpp @@ -0,0 +1,1148 @@ +#include "StdAfx.h"
+#include "SettingsDlg.h"
+#include "EconomicRateInfo.h"
+#include "ModuleInfo.h"
+#include "WinCtrlHelper.h"
+#include "CreateFilePath.h"
+#include "QuotesProviderVisitorDbSettings.h"
+#include "DBUtils.h"
+#include "resource.h"
+#include "QuotesProviders.h"
+#include "IQuotesProvider.h"
+
+#define WINDOW_PREFIX_SETTINGS "Edit Settings_"
+
+namespace
+{
+ LPCTSTR g_pszVariableQuoteName = _T("%quotename%");
+ LPCTSTR g_pszVariableUserProfile = _T("%miranda_userdata%");
+
+ void update_file_controls(HWND hDlg)
+ {
+ bool bEnable = (1 == ::IsDlgButtonChecked(hDlg,IDC_CHECK_EXTERNAL_FILE));
+
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_EDIT_FILE_NAME),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_STATIC_SELECT_FILE),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_BROWSE),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_STATIC_LOG_FILE_FORMAT),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_EDIT_LOG_FILE_FORMAT),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_LOG_FILE_DESCRIPTION),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_LOG_FILE_CONDITION),bEnable);
+ }
+
+ void update_history_controls(HWND hDlg)
+ {
+ bool bEnable = (1 == ::IsDlgButtonChecked(hDlg,IDC_CHECK_INTERNAL_HISTORY));
+
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_STATIC_HISTORY_FORMAT),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_EDIT_HISTORY_FORMAT),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_HISTORY_DESCRIPTION),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_HISTORY_CONDITION),bEnable);
+ }
+
+ void update_popup_controls(HWND hDlg)
+ {
+ bool bEnable = (1 == ::IsDlgButtonChecked(hDlg,IDC_CHECK_SHOW_POPUP));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_EDIT_POPUP_FORMAT),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_STATIC_POPUP_FORMAT),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_POPUP_FORMAT_DESCRIPTION),bEnable);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_POPUP_SETTINGS),bEnable);
+ }
+
+ bool enable_popup_controls(HWND hDlg)
+ {
+ bool bIsPopupServiceEnabled = 1 == ServiceExists(MS_POPUP_ADDPOPUPT);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_SHOW_POPUP),bIsPopupServiceEnabled);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_EDIT_POPUP_FORMAT),bIsPopupServiceEnabled);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED),bIsPopupServiceEnabled);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_STATIC_POPUP_FORMAT),bIsPopupServiceEnabled);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_POPUP_FORMAT_DESCRIPTION),bIsPopupServiceEnabled);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_POPUP_SETTINGS),bIsPopupServiceEnabled);
+
+ return bIsPopupServiceEnabled;
+ }
+
+ void update_all_controls(HWND hDlg)
+ {
+ bool bIsCheckedContactSpec = (1 == ::IsDlgButtonChecked(hDlg,IDC_CHECK_CONTACT_SPECIFIC));
+ bool bIsCheckedExternal = (1 == ::IsDlgButtonChecked(hDlg,IDC_CHECK_EXTERNAL_FILE));
+
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_EXTERNAL_FILE),bIsCheckedContactSpec);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_EDIT_FILE_NAME),(bIsCheckedContactSpec&&bIsCheckedExternal));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_STATIC_SELECT_FILE),(bIsCheckedContactSpec&&bIsCheckedExternal));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_BROWSE),(bIsCheckedContactSpec&&bIsCheckedExternal));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_STATIC_LOG_FILE_FORMAT),(bIsCheckedContactSpec&&bIsCheckedExternal));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_EDIT_LOG_FILE_FORMAT),(bIsCheckedContactSpec&&bIsCheckedExternal));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_LOG_FILE_DESCRIPTION),(bIsCheckedContactSpec&&bIsCheckedExternal));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_LOG_FILE_CONDITION),(bIsCheckedContactSpec&&bIsCheckedExternal));
+
+ bool bIsCheckedHistory = (1 == ::IsDlgButtonChecked(hDlg,IDC_CHECK_INTERNAL_HISTORY));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_INTERNAL_HISTORY),bIsCheckedContactSpec);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_STATIC_HISTORY_FORMAT),(bIsCheckedContactSpec&&bIsCheckedHistory));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_EDIT_HISTORY_FORMAT),(bIsCheckedContactSpec&&bIsCheckedHistory));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_HISTORY_DESCRIPTION),(bIsCheckedContactSpec&&bIsCheckedHistory));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_HISTORY_CONDITION),(bIsCheckedContactSpec&&bIsCheckedHistory));
+
+ bool bIsPopupServiceEnabled = 1 == ServiceExists(MS_POPUP_ADDPOPUPT);
+ bool bIsCheckedShowPopup = (1 == ::IsDlgButtonChecked(hDlg,IDC_CHECK_SHOW_POPUP));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_SHOW_POPUP),(bIsCheckedContactSpec&&bIsPopupServiceEnabled));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_EDIT_POPUP_FORMAT),(bIsCheckedContactSpec&&bIsPopupServiceEnabled&&bIsCheckedShowPopup));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED),(bIsCheckedContactSpec&&bIsPopupServiceEnabled&&bIsCheckedShowPopup));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_STATIC_POPUP_FORMAT),(bIsCheckedContactSpec&&bIsPopupServiceEnabled&&bIsCheckedShowPopup));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_POPUP_FORMAT_DESCRIPTION),(bIsCheckedContactSpec&&bIsPopupServiceEnabled&&bIsCheckedShowPopup));
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_POPUP_SETTINGS),(bIsCheckedContactSpec&&bIsPopupServiceEnabled));
+ }
+
+ std::vector<TCHAR> get_filter()
+ {
+ std::vector<TCHAR> aFilter;
+ LPCTSTR pszFilterParts[] = {_T("Log Files (*.txt,*.log)"),_T("*.txt;*.log"),_T("All files (*.*)"),_T("*.*")};
+ for(int i = 0;i < sizeof(pszFilterParts)/sizeof(pszFilterParts[0]);++i)
+ {
+ tstring sPart = TranslateTS(pszFilterParts[i]);
+ std::copy(sPart.begin(),sPart.end(),std::back_inserter(aFilter));
+ aFilter.push_back(_T('\0'));
+
+ }
+ aFilter.push_back(_T('\0'));
+ return aFilter;
+ }
+ void select_log_file(HWND hDlg)
+ {
+// tstring sFileName = GenerateLogFileName(
+// get_window_text(::GetDlgItem(hDlg,IDC_EDIT_FILE_NAME)),tstring(),glfnResolveUserProfile);
+ std::vector<TCHAR> aFileBuffer(_MAX_PATH*2,_T('\0'));
+// std::copy(sFileName.begin(),sFileName.end(),aFileBuffer.begin());
+ LPTSTR pszFile = &*aFileBuffer.begin();
+
+ std::vector<TCHAR> aFilterBuffer = get_filter();
+ LPCTSTR pszFilter = &*aFilterBuffer.begin();
+
+ OPENFILENAME ofn = {0};
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hDlg;
+ ofn.lpstrFile = pszFile;
+ ofn.nMaxFile = (DWORD)aFileBuffer.size();
+ ofn.lpstrFilter = pszFilter;
+ ofn.nFilterIndex = 1;
+ ofn.hInstance = g_hInstance;
+ ofn.lpstrDefExt = _T("log");
+// ofn.lpstrFileTitle = NULL;
+// ofn.nMaxFileTitle = 0;
+// ofn.lpstrInitialDir = NULL;
+ ofn.Flags = OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_EXPLORER;
+
+ BOOL b = GetOpenFileName(&ofn);
+ if(TRUE == b)
+ {
+ SetDlgItemText(hDlg,IDC_EDIT_FILE_NAME,ofn.lpstrFile);
+ }
+ }
+
+ struct CSettingWindowParam
+ {
+ CSettingWindowParam(HANDLE hContact) : m_hContact(hContact),m_pPopupSettings(NULL){}
+ ~CSettingWindowParam(){delete m_pPopupSettings;}
+
+ HANDLE m_hContact;
+ CPopupSettings* m_pPopupSettings;
+ };
+
+ inline CSettingWindowParam* get_param(HWND hWnd)
+ {
+ return reinterpret_cast<CSettingWindowParam*>(GetWindowLongPtr(hWnd,GWLP_USERDATA));
+ }
+
+
+// inline HANDLE get_contact(HWND hWnd)
+// {
+// return reinterpret_cast<HANDLE>(GetWindowLongPtr(hWnd,GWLP_USERDATA));
+// }
+
+ void update_popup_controls_settings(HWND hDlg)
+ {
+ bool bIsColoursEnabled = 1 == IsDlgButtonChecked(hDlg,IDC_RADIO_USER_DEFINED_COLOURS);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_BGCOLOR),bIsColoursEnabled);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_TEXTCOLOR),bIsColoursEnabled);
+
+ bool bIsDelayEnabled = 1 == IsDlgButtonChecked(hDlg,IDC_DELAYCUSTOM);
+ ::EnableWindow(::GetDlgItem(hDlg,IDC_DELAY),bIsDelayEnabled);
+
+ }
+
+ INT_PTR CALLBACK EditPopupSettingsDlgProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp)
+ {
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ CPopupSettings* pSettings = reinterpret_cast<CPopupSettings*>(lp);
+ TranslateDialogDefault( hWnd );
+// ::SendDlgItemMessage(hWnd,IDC_BGCOLOR,CPM_SETDEFAULTCOLOUR,0,::GetSysColor(COLOR_BTNFACE));
+// ::SendDlgItemMessage(hWnd,IDC_TEXTCOLOR,CPM_SETDEFAULTCOLOUR,0,::GetSysColor(COLOR_BTNTEXT));
+ ::SendDlgItemMessage(hWnd,IDC_BGCOLOR,CPM_SETCOLOUR,0,pSettings->GetColourBk());
+ ::SendDlgItemMessage(hWnd,IDC_TEXTCOLOR,CPM_SETCOLOUR,0,pSettings->GetColourText());
+
+ ::CheckDlgButton(hWnd,IDC_CHECK_DONT_USE_POPUPHISTORY,pSettings->GetHistoryFlag());
+
+ ::CheckRadioButton(hWnd,IDC_RADIO_DEFAULT_COLOURS,IDC_RADIO_USER_DEFINED_COLOURS,(CPopupSettings::colourDefault == pSettings->GetColourMode()) ? IDC_RADIO_DEFAULT_COLOURS : IDC_RADIO_USER_DEFINED_COLOURS);
+ UINT n;
+ switch(pSettings->GetDelayMode())
+ {
+ default:
+ assert(!"Unknown delay mode. Please, fix it");
+ case CPopupSettings::delayFromPopup:
+ n = IDC_DELAYFROMPU;
+ break;
+ case CPopupSettings::delayCustom:
+ n = IDC_DELAYCUSTOM;
+ break;
+ case CPopupSettings::delayPermanent:
+ n = IDC_DELAYPERMANENT;
+ break;
+ }
+ ::CheckRadioButton(hWnd,IDC_DELAYFROMPU,IDC_DELAYPERMANENT,n);
+
+ ::SetDlgItemInt(hWnd,IDC_DELAY,pSettings->GetDelayTimeout(),FALSE);
+
+ update_popup_controls_settings(hWnd);
+
+ ::SetWindowLongPtr(hWnd,GWLP_USERDATA,reinterpret_cast<LONG_PTR>(pSettings));
+ }
+ return TRUE;
+ case WM_COMMAND:
+ switch(LOWORD(wp))
+ {
+ case IDC_RADIO_DEFAULT_COLOURS:
+ case IDC_RADIO_USER_DEFINED_COLOURS:
+ case IDC_DELAYFROMPU:
+ case IDC_DELAYCUSTOM:
+ case IDC_DELAYPERMANENT:
+ update_popup_controls_settings(hWnd);
+ break;
+
+ case IDCANCEL:
+ ::EndDialog(hWnd,IDCANCEL);
+ break;
+ case IDOK:
+ {
+ CPopupSettings* pSettings = reinterpret_cast<CPopupSettings*>(GetWindowLongPtr(hWnd,GWLP_USERDATA));
+
+ bool bError = false;
+ BOOL bOk = FALSE;
+ UINT nDelay = ::GetDlgItemInt(hWnd,IDC_DELAY,&bOk,FALSE);
+ CPopupSettings::EDelayMode nModeDelay = pSettings->GetDelayMode();
+ if(1 == ::IsDlgButtonChecked(hWnd,IDC_DELAYFROMPU))
+ {
+ nModeDelay = CPopupSettings::delayFromPopup;
+ }
+ else if(1 == ::IsDlgButtonChecked(hWnd,IDC_DELAYCUSTOM))
+ {
+ if(TRUE == bOk)
+ {
+ nModeDelay = CPopupSettings::delayCustom;
+ }
+ else
+ {
+ prepare_edit_ctrl_for_error(::GetDlgItem(hWnd,IDC_DELAY));
+ Quotes_MessageBox(hWnd,TranslateT("Enter integer value"),MB_OK|MB_ICONERROR);
+ bError = true;
+ }
+ }
+ else if(1 == ::IsDlgButtonChecked(hWnd,IDC_DELAYPERMANENT))
+ {
+ nModeDelay = CPopupSettings::delayPermanent;
+ }
+ if(false == bError)
+ {
+ pSettings->SetDelayMode(nModeDelay);
+ if(TRUE == bOk)
+ {
+ pSettings->SetDelayTimeout(nDelay);
+ }
+ pSettings->SetHistoryFlag((1 == IsDlgButtonChecked(hWnd,IDC_CHECK_DONT_USE_POPUPHISTORY)));
+
+ if(1 == ::IsDlgButtonChecked(hWnd,IDC_RADIO_DEFAULT_COLOURS))
+ {
+ pSettings->SetColourMode(CPopupSettings::colourDefault);
+ }
+ else if(1 == ::IsDlgButtonChecked(hWnd,IDC_RADIO_USER_DEFINED_COLOURS))
+ {
+ pSettings->SetColourMode(CPopupSettings::colourUserDefined);
+ }
+
+ pSettings->SetColourBk(static_cast<COLORREF>(::SendDlgItemMessage(hWnd,IDC_BGCOLOR,CPM_GETCOLOUR,0,0)));
+ pSettings->SetColourText(static_cast<COLORREF>(::SendDlgItemMessage(hWnd,IDC_TEXTCOLOR,CPM_GETCOLOUR,0,0)));
+
+ ::EndDialog(hWnd,IDOK);
+ }
+ }
+ break;
+ }
+ break;
+ }
+
+ return FALSE;
+ }
+
+ INT_PTR CALLBACK EditSettingsPerContactDlgProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp)
+ {
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ HANDLE hContact = reinterpret_cast<HANDLE>(lp);
+ TranslateDialogDefault(hWnd);
+
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_SETTINGS,false);
+ assert(hWL);
+ WindowList_Add(hWL,hWnd,hContact);
+
+ tstring sName = GetContactName(hContact);
+ ::SetDlgItemText(hWnd,IDC_EDIT_NAME,sName.c_str());
+
+ CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact);
+
+ BYTE bUseContactSpecific = DBGetContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_CONTACT_SPEC_SETTINGS,0);
+ ::CheckDlgButton(hWnd,IDC_CHECK_CONTACT_SPECIFIC,bUseContactSpecific);
+
+ CAdvProviderSettings setGlobal(pProvider.get());
+ // log to history
+ WORD dwLogMode = DBGetContactSettingWord(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG,setGlobal.GetLogMode());
+ UINT nCheck = (dwLogMode&lmInternalHistory) ? 1 : 0;
+ ::CheckDlgButton(hWnd,IDC_CHECK_INTERNAL_HISTORY,nCheck);
+
+ tstring sHistoryFrmt = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_FORMAT_HISTORY,setGlobal.GetHistoryFormat().c_str());
+ ::SetDlgItemText(hWnd,IDC_EDIT_HISTORY_FORMAT,sHistoryFrmt.c_str());
+
+ WORD wOnlyIfChanged = DBGetContactSettingWord(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_HISTORY_CONDITION,setGlobal.GetHistoryOnlyChangedFlag());
+ ::CheckDlgButton(hWnd,IDC_CHECK_HISTORY_CONDITION,(1 == wOnlyIfChanged) ? 1 : 0);
+
+ // log to file
+ nCheck = (dwLogMode&lmExternalFile) ? 1 : 0;
+ ::CheckDlgButton(hWnd,IDC_CHECK_EXTERNAL_FILE,nCheck);
+
+ tstring sLogFileName = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG_FILE);
+ if(true == sLogFileName.empty())
+ {
+ sLogFileName = GenerateLogFileName(setGlobal.GetLogFileName(),Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_SYMBOL),glfnResolveQuoteName);
+ }
+ ::SetDlgItemText(hWnd,IDC_EDIT_FILE_NAME,sLogFileName.c_str());
+
+ tstring sLogFileFrmt = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_FORMAT_LOG_FILE,setGlobal.GetLogFormat().c_str());
+ ::SetDlgItemText(hWnd,IDC_EDIT_LOG_FILE_FORMAT,sLogFileFrmt.c_str());
+
+ wOnlyIfChanged = DBGetContactSettingWord(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG_FILE_CONDITION,setGlobal.GetLogOnlyChangedFlag());
+ ::CheckDlgButton(hWnd,IDC_CHECK_LOG_FILE_CONDITION,(1 == wOnlyIfChanged) ? 1 : 0);
+
+ // popup
+ nCheck = (dwLogMode&lmPopup) ? 1 : 0;
+ ::CheckDlgButton(hWnd,IDC_CHECK_SHOW_POPUP,nCheck);
+ tstring sPopupFrmt = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_FORMAT_POPUP,setGlobal.GetPopupFormat().c_str());
+ ::SetDlgItemText(hWnd,IDC_EDIT_POPUP_FORMAT,sPopupFrmt.c_str());
+ bool bOnlyIfChanged = 1 == DBGetContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_CONDITION,setGlobal.GetShowPopupIfValueChangedFlag());
+ ::CheckDlgButton(hWnd,IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED,(true == bOnlyIfChanged) ? 1 : 0);
+
+ update_all_controls(hWnd);
+
+ CSettingWindowParam* pParam = new CSettingWindowParam(hContact);
+ ::SetWindowLongPtr(hWnd,GWLP_USERDATA,reinterpret_cast<LONG_PTR>(pParam));
+ Utils_RestoreWindowPositionNoSize(hWnd,hContact,QUOTES_MODULE_NAME,WINDOW_PREFIX_SETTINGS);
+ ::ShowWindow(hWnd,SW_SHOW);
+ }
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wp))
+ {
+ case IDC_BUTTON_HISTORY_DESCRIPTION:
+ case IDC_BUTTON_LOG_FILE_DESCRIPTION:
+ case IDC_BUTTON_POPUP_FORMAT_DESCRIPTION:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(get_param(hWnd)->m_hContact);
+ show_variable_list(hWnd,pProvider.get());
+ }
+ break;
+
+ case IDC_CHECK_CONTACT_SPECIFIC:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ update_all_controls(hWnd);
+ }
+ break;
+ case IDC_CHECK_EXTERNAL_FILE:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ update_file_controls(hWnd);
+ }
+ break;
+ case IDC_CHECK_INTERNAL_HISTORY:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ update_history_controls(hWnd);
+ }
+ break;
+ case IDC_CHECK_SHOW_POPUP:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ update_popup_controls(hWnd);
+ }
+ break;
+ case IDC_BUTTON_BROWSE:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ select_log_file(hWnd);
+ }
+ break;
+ case IDC_BUTTON_POPUP_SETTINGS:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ CSettingWindowParam* pParam = get_param(hWnd);
+ if (!pParam->m_pPopupSettings)
+ {
+ CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(pParam->m_hContact);
+
+ pParam->m_pPopupSettings = new CPopupSettings(pProvider.get());
+ pParam->m_pPopupSettings->InitForContact(pParam->m_hContact);
+ }
+
+ DialogBoxParam(g_hInstance,
+ MAKEINTRESOURCE(IDD_DIALOG_POPUP),
+ hWnd,
+ EditPopupSettingsDlgProc,reinterpret_cast<LPARAM>(pParam->m_pPopupSettings));
+ }
+ break;
+
+ case IDOK:
+ {
+ CSettingWindowParam* pParam = get_param(hWnd);
+ HANDLE hContact = pParam->m_hContact;
+
+ bool bUseContactSpec = 1 == ::IsDlgButtonChecked(hWnd,IDC_CHECK_CONTACT_SPECIFIC);
+
+ WORD nLogMode = lmDisabled;
+ UINT nCheck = ::IsDlgButtonChecked(hWnd,IDC_CHECK_EXTERNAL_FILE);
+ if(1 == nCheck)
+ {
+ nLogMode |= lmExternalFile;
+ }
+
+ nCheck = ::IsDlgButtonChecked(hWnd,IDC_CHECK_INTERNAL_HISTORY);
+ if(1 == nCheck)
+ {
+ nLogMode |= lmInternalHistory;
+ }
+
+ nCheck = ::IsDlgButtonChecked(hWnd,IDC_CHECK_SHOW_POPUP);
+ if(1 == nCheck)
+ {
+ nLogMode |= lmPopup;
+ }
+
+ bool bOk = true;
+ HWND hwndLogFile = ::GetDlgItem(hWnd,IDC_EDIT_FILE_NAME);
+ HWND hwndLogFileFrmt = ::GetDlgItem(hWnd,IDC_EDIT_LOG_FILE_FORMAT);
+ HWND hwndHistoryFrmt = ::GetDlgItem(hWnd,IDC_EDIT_HISTORY_FORMAT);
+ tstring sLogFile = get_window_text(hwndLogFile);
+ tstring sLogFileFormat = get_window_text(hwndLogFileFrmt);
+ tstring sHistoryFormat = get_window_text(hwndHistoryFrmt);
+ if ((nLogMode&lmExternalFile))
+ {
+ if(true == sLogFile.empty())
+ {
+ prepare_edit_ctrl_for_error(hwndLogFile);
+ Quotes_MessageBox(hWnd,TranslateT("Enter log file name."),MB_OK|MB_ICONERROR);
+ bOk = false;
+ }
+ else if(true == sLogFileFormat.empty())
+ {
+ prepare_edit_ctrl_for_error(hwndLogFileFrmt);
+ Quotes_MessageBox(hWnd,TranslateT("Enter log file format."),MB_OK|MB_ICONERROR);
+ bOk = false;
+ }
+ }
+
+ if ((true == bOk) && (nLogMode&lmInternalHistory) && (true == sHistoryFormat.empty()))
+ {
+ prepare_edit_ctrl_for_error(hwndHistoryFrmt);
+ Quotes_MessageBox(hWnd,TranslateT("Enter history format."),MB_OK|MB_ICONERROR);
+ bOk = false;
+ }
+
+ HWND hwndPopupFrmt = ::GetDlgItem(hWnd,IDC_EDIT_POPUP_FORMAT);
+ tstring sPopupFormat = get_window_text(hwndPopupFrmt);
+ if ((true == bOk) && (nLogMode&lmPopup) && (true == sPopupFormat.empty()))
+ {
+ prepare_edit_ctrl_for_error(hwndPopupFrmt);
+ Quotes_MessageBox(hWnd,TranslateT("Enter popup window format."),MB_OK|MB_ICONERROR);
+ bOk = false;
+ }
+
+ if(true == bOk)
+ {
+ UINT nIfChangedHistory = IsDlgButtonChecked(hWnd,IDC_CHECK_HISTORY_CONDITION);
+ UINT nIfChangedFile = IsDlgButtonChecked(hWnd,IDC_CHECK_LOG_FILE_CONDITION);
+ bool bIfChangedPopup = (1 == IsDlgButtonChecked(hWnd,IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED));
+
+ DBWriteContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_CONTACT_SPEC_SETTINGS,bUseContactSpec);
+ DBWriteContactSettingWord(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG,nLogMode);
+ DBWriteContactSettingWord(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG_FILE_CONDITION,nIfChangedFile);
+ DBWriteContactSettingWord(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_HISTORY_CONDITION,nIfChangedHistory);
+ DBWriteContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_CONDITION,bIfChangedPopup);
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG_FILE,sLogFile.c_str());
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_FORMAT_LOG_FILE,sLogFileFormat.c_str());
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_FORMAT_HISTORY,sHistoryFormat.c_str());
+ DBWriteContactSettingTString(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_FORMAT_POPUP,sPopupFormat.c_str());
+
+ if(pParam->m_pPopupSettings)
+ {
+ pParam->m_pPopupSettings->SaveForContact(hContact);
+ }
+
+ ::DestroyWindow(hWnd);
+ }
+ }
+ break;
+ case IDCANCEL:
+ DestroyWindow(hWnd);
+ break;
+ }
+ break;
+ case WM_CLOSE:
+ DestroyWindow(hWnd);
+ break;
+ case WM_DESTROY:
+ {
+ CSettingWindowParam* pParam = get_param(hWnd);
+ SetWindowLongPtr(hWnd,GWLP_USERDATA,0);
+
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_SETTINGS,false);
+ assert(hWL);
+ WindowList_Remove(hWL,hWnd);
+ Utils_SaveWindowPosition(hWnd,pParam->m_hContact,QUOTES_MODULE_NAME,WINDOW_PREFIX_SETTINGS);
+ delete pParam;
+ }
+ break;
+ }
+
+ return FALSE;
+ }
+}
+
+
+void ShowSettingsDlg(HANDLE hContact)
+{
+ HANDLE hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_SETTINGS,true);
+ assert(hWL);
+ HWND hWnd = WindowList_Find(hWL,hContact);
+ if(NULL != hWnd)
+ {
+ SetForegroundWindow(hWnd);
+ SetFocus(hWnd);
+ }
+ else
+ {
+ CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_CONTACT_SETTINGS),NULL,EditSettingsPerContactDlgProc,reinterpret_cast<LPARAM>(hContact));
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////
+
+namespace
+{
+ INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp)
+ {
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hWnd);
+ CAdvProviderSettings* pAdvSettings = reinterpret_cast<CAdvProviderSettings*>(lp);
+
+ ::SetDlgItemText(hWnd,IDC_EDIT_NAME,pAdvSettings->GetProviderPtr()->GetInfo().m_sName.c_str());
+
+ // log to history
+ WORD dwLogMode = pAdvSettings->GetLogMode();
+ UINT nCheck = (dwLogMode&lmInternalHistory) ? 1 : 0;
+ ::CheckDlgButton(hWnd,IDC_CHECK_INTERNAL_HISTORY,nCheck);
+ ::SetDlgItemText(hWnd,IDC_EDIT_HISTORY_FORMAT,pAdvSettings->GetHistoryFormat().c_str());
+ ::CheckDlgButton(hWnd,IDC_CHECK_HISTORY_CONDITION,(true == pAdvSettings->GetHistoryOnlyChangedFlag()) ? 1 : 0);
+
+ // log to file
+ nCheck = (dwLogMode&lmExternalFile) ? 1 : 0;
+ ::CheckDlgButton(hWnd,IDC_CHECK_EXTERNAL_FILE,nCheck);
+ ::SetDlgItemText(hWnd,IDC_EDIT_FILE_NAME,pAdvSettings->GetLogFileName().c_str());
+ ::SetDlgItemText(hWnd,IDC_EDIT_LOG_FILE_FORMAT,pAdvSettings->GetLogFormat().c_str());
+ ::CheckDlgButton(hWnd,IDC_CHECK_LOG_FILE_CONDITION,(true == pAdvSettings->GetLogOnlyChangedFlag()) ? 1 : 0);
+
+ update_file_controls(hWnd);
+ update_history_controls(hWnd);
+
+ // popup
+ nCheck = (dwLogMode&lmPopup) ? 1 : 0;
+ ::CheckDlgButton(hWnd,IDC_CHECK_SHOW_POPUP,nCheck);
+ ::SetDlgItemText(hWnd,IDC_EDIT_POPUP_FORMAT,pAdvSettings->GetPopupFormat().c_str());
+ ::CheckDlgButton(hWnd,IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED,(true == pAdvSettings->GetShowPopupIfValueChangedFlag()) ? 1 : 0);
+
+ if(true == enable_popup_controls(hWnd))
+ {
+ update_popup_controls(hWnd);
+ }
+
+ ::SetWindowLongPtr(hWnd,GWLP_USERDATA,reinterpret_cast<LONG>(pAdvSettings));
+ }
+ return TRUE;
+ case WM_COMMAND:
+ switch(LOWORD(wp))
+ {
+ case IDOK:
+ {
+ WORD nLogMode = lmDisabled;
+ UINT nCheck = ::IsDlgButtonChecked(hWnd,IDC_CHECK_EXTERNAL_FILE);
+ if(1 == nCheck)
+ {
+ nLogMode |= lmExternalFile;
+ }
+
+ nCheck = ::IsDlgButtonChecked(hWnd,IDC_CHECK_INTERNAL_HISTORY);
+ if(1 == nCheck)
+ {
+ nLogMode |= lmInternalHistory;
+ }
+
+ nCheck = ::IsDlgButtonChecked(hWnd,IDC_CHECK_SHOW_POPUP);
+ if(1 == nCheck)
+ {
+ nLogMode |= lmPopup;
+ }
+
+ bool bOk = true;
+ HWND hwndLogFile = ::GetDlgItem(hWnd,IDC_EDIT_FILE_NAME);
+ HWND hwndLogFileFrmt = ::GetDlgItem(hWnd,IDC_EDIT_LOG_FILE_FORMAT);
+
+ tstring sLogFile = get_window_text(hwndLogFile);
+ tstring sLogFileFormat = get_window_text(hwndLogFileFrmt);
+
+ if ((nLogMode&lmExternalFile))
+ {
+ if(true == sLogFile.empty())
+ {
+ prepare_edit_ctrl_for_error(hwndLogFile);
+ Quotes_MessageBox(hWnd,TranslateT("Enter log file name."),MB_OK|MB_ICONERROR);
+ bOk = false;
+ }
+ else if(true == sLogFileFormat.empty())
+ {
+ prepare_edit_ctrl_for_error(hwndLogFileFrmt);
+ Quotes_MessageBox(hWnd,TranslateT("Enter log file format."),MB_OK|MB_ICONERROR);
+ bOk = false;
+ }
+ }
+
+ HWND hwndHistoryFrmt = ::GetDlgItem(hWnd,IDC_EDIT_HISTORY_FORMAT);
+ tstring sHistoryFormat = get_window_text(hwndHistoryFrmt);
+ if ((true == bOk) && (nLogMode&lmInternalHistory) && (true == sHistoryFormat.empty()))
+ {
+ prepare_edit_ctrl_for_error(hwndHistoryFrmt);
+ Quotes_MessageBox(hWnd,TranslateT("Enter history format."),MB_OK|MB_ICONERROR);
+ bOk = false;
+ }
+
+ HWND hwndPopupFrmt = ::GetDlgItem(hWnd,IDC_EDIT_POPUP_FORMAT);
+ tstring sPopupFormat = get_window_text(hwndPopupFrmt);
+ if ((true == bOk) && (nLogMode&lmPopup) && (true == sPopupFormat.empty()))
+ {
+ prepare_edit_ctrl_for_error(hwndPopupFrmt);
+ Quotes_MessageBox(hWnd,TranslateT("Enter popup window format."),MB_OK|MB_ICONERROR);
+ bOk = false;
+ }
+
+ if(true == bOk)
+ {
+ CAdvProviderSettings* pAdvSettings = reinterpret_cast<CAdvProviderSettings*>(GetWindowLongPtr(hWnd,GWLP_USERDATA));
+
+ pAdvSettings->SetLogMode(nLogMode);
+ pAdvSettings->SetHistoryOnlyChangedFlag(1 == IsDlgButtonChecked(hWnd,IDC_CHECK_HISTORY_CONDITION));
+ pAdvSettings->SetLogOnlyChangedFlag(1 == IsDlgButtonChecked(hWnd,IDC_CHECK_LOG_FILE_CONDITION));
+ pAdvSettings->SetShowPopupIfValueChangedFlag(1 == IsDlgButtonChecked(hWnd,IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED));
+ pAdvSettings->SetLogFileName(sLogFile);
+ pAdvSettings->SetLogFormat(sLogFileFormat);
+ pAdvSettings->SetHistoryFormat(sHistoryFormat);
+ pAdvSettings->SetPopupFormat(sPopupFormat);
+
+ ::EndDialog(hWnd,IDOK);
+ }
+ }
+ break;
+ case IDCANCEL:
+ ::EndDialog(hWnd,IDCANCEL);
+ break;
+ case IDC_BUTTON_HISTORY_DESCRIPTION:
+ case IDC_BUTTON_LOG_FILE_DESCRIPTION:
+ case IDC_BUTTON_POPUP_FORMAT_DESCRIPTION:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ const CAdvProviderSettings* pAdvSettings = reinterpret_cast<CAdvProviderSettings*>(GetWindowLongPtr(hWnd,GWLP_USERDATA));
+ show_variable_list(hWnd,pAdvSettings->GetProviderPtr());
+ }
+ break;
+ case IDC_CHECK_EXTERNAL_FILE:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ update_file_controls(hWnd);
+ }
+ break;
+ case IDC_CHECK_INTERNAL_HISTORY:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ update_history_controls(hWnd);
+ }
+ break;
+ case IDC_CHECK_SHOW_POPUP:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ update_popup_controls(hWnd);
+ }
+ break;
+ case IDC_BUTTON_BROWSE:
+ if(BN_CLICKED == HIWORD(wp))
+ {
+ select_log_file(hWnd);
+ }
+ break;
+ case IDC_BUTTON_POPUP_SETTINGS:
+ {
+ const CAdvProviderSettings* pAdvSettings = reinterpret_cast<CAdvProviderSettings*>(GetWindowLongPtr(hWnd,GWLP_USERDATA));
+ DialogBoxParam(g_hInstance,
+ MAKEINTRESOURCE(IDD_DIALOG_POPUP),
+ hWnd,
+ EditPopupSettingsDlgProc,reinterpret_cast<LPARAM>(pAdvSettings->GetPopupSettingsPtr()));
+
+ }
+ break;
+ }
+ break;
+ }
+ return FALSE;
+ }
+}
+
+CAdvProviderSettings::CAdvProviderSettings(const IQuotesProvider* pQuotesProvider)
+ : m_pQuotesProvider(pQuotesProvider),
+ m_wLogMode(lmDisabled),
+ m_bIsOnlyChangedHistory(false),
+ m_bIsOnlyChangedLogFile(false),
+ m_bShowPopupIfValueChanged(false),
+ m_pPopupSettings(nullptr)
+{
+ assert(m_pQuotesProvider);
+
+ CQuotesProviderVisitorDbSettings visitor;
+ m_pQuotesProvider->Accept(visitor);
+
+ assert(visitor.m_pszDefLogFileFormat);
+ assert(visitor.m_pszDefHistoryFormat);
+ assert(visitor.m_pszDbLogMode);
+ assert(visitor.m_pszDbHistoryFormat);
+ assert(visitor.m_pszDbHistoryCondition);
+ assert(visitor.m_pszDbLogFile);
+ assert(visitor.m_pszDbLogFormat);
+ assert(visitor.m_pszDbLogCondition);
+
+ m_wLogMode = DBGetContactSettingWord(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbLogMode,static_cast<WORD>(lmDisabled));
+ m_sFormatHistory = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbHistoryFormat,visitor.m_pszDefHistoryFormat);
+ m_bIsOnlyChangedHistory = 1 == DBGetContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbHistoryCondition,0);
+
+ m_sLogFileName = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbLogFile);
+ if(true == m_sLogFileName.empty())
+ {
+ m_sLogFileName = g_pszVariableUserProfile;
+ m_sLogFileName += _T("\\Quotes\\");
+ m_sLogFileName += g_pszVariableQuoteName;
+ m_sLogFileName += _T(".log");
+ }
+
+ m_sFormatLogFile = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbLogFormat,visitor.m_pszDefLogFileFormat);
+ m_bIsOnlyChangedLogFile = (1 == DBGetContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbLogCondition,0));
+
+ m_sPopupFormat = Quotes_DBGetStringT(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupFormat,visitor.m_pszDefPopupFormat);
+ m_bShowPopupIfValueChanged = (1 == DBGetContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupCondition,0));
+}
+
+CAdvProviderSettings::~CAdvProviderSettings()
+{
+ delete m_pPopupSettings;
+}
+
+const IQuotesProvider* CAdvProviderSettings::GetProviderPtr()const
+{
+ return m_pQuotesProvider;
+}
+
+void CAdvProviderSettings::SaveToDb()const
+{
+ CQuotesProviderVisitorDbSettings visitor;
+ m_pQuotesProvider->Accept(visitor);
+
+ assert(visitor.m_pszDbLogMode);
+ assert(visitor.m_pszDbHistoryFormat);
+ assert(visitor.m_pszDbHistoryCondition);
+ assert(visitor.m_pszDbLogFile);
+ assert(visitor.m_pszDbLogFormat);
+ assert(visitor.m_pszDbLogCondition);
+ assert(visitor.m_pszDbPopupColourMode);
+ assert(visitor.m_pszDbPopupBkColour);
+ assert(visitor.m_pszDbPopupTextColour);
+ assert(visitor.m_pszDbPopupDelayMode);
+ assert(visitor.m_pszDbPopupDelayTimeout);
+ assert(visitor.m_pszDbPopupHistoryFlag);
+
+ DBWriteContactSettingWord(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbLogMode,m_wLogMode);
+ DBWriteContactSettingTString(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbHistoryFormat,m_sFormatHistory.c_str());
+ DBWriteContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbHistoryCondition,m_bIsOnlyChangedHistory);
+ DBWriteContactSettingTString(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbLogFile,m_sLogFileName.c_str());
+ DBWriteContactSettingTString(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbLogFormat,m_sFormatLogFile.c_str());
+ DBWriteContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbLogCondition,m_bIsOnlyChangedLogFile);
+ DBWriteContactSettingTString(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupFormat,m_sPopupFormat.c_str());
+ DBWriteContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupCondition,m_bShowPopupIfValueChanged);
+
+ if(nullptr != m_pPopupSettings)
+ {
+ DBWriteContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupColourMode,static_cast<BYTE>(m_pPopupSettings->GetColourMode()));
+ DBWriteContactSettingDword(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupBkColour,m_pPopupSettings->GetColourBk());
+ DBWriteContactSettingDword(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupTextColour,m_pPopupSettings->GetColourText());
+ DBWriteContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupDelayMode,static_cast<BYTE>(m_pPopupSettings->GetDelayMode()));
+ DBWriteContactSettingWord(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupDelayTimeout,m_pPopupSettings->GetDelayTimeout());
+ DBWriteContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupHistoryFlag,m_pPopupSettings->GetHistoryFlag());
+ }
+}
+
+WORD CAdvProviderSettings::GetLogMode()const
+{
+ return m_wLogMode;
+}
+
+void CAdvProviderSettings::SetLogMode(WORD wMode)
+{
+ m_wLogMode = wMode;
+}
+
+tstring CAdvProviderSettings::GetHistoryFormat()const
+{
+ return m_sFormatHistory;
+}
+
+void CAdvProviderSettings::SetHistoryFormat(const tstring& rsFormat)
+{
+ m_sFormatHistory = rsFormat;
+}
+
+bool CAdvProviderSettings::GetHistoryOnlyChangedFlag()const
+{
+ return m_bIsOnlyChangedHistory;
+}
+
+void CAdvProviderSettings::SetHistoryOnlyChangedFlag(bool bMode)
+{
+ m_bIsOnlyChangedHistory = bMode;
+}
+
+tstring CAdvProviderSettings::GetLogFileName()const
+{
+ return m_sLogFileName;
+}
+
+void CAdvProviderSettings::SetLogFileName(const tstring& rsFile)
+{
+ m_sLogFileName = rsFile;
+}
+
+tstring CAdvProviderSettings::GetLogFormat()const
+{
+ return m_sFormatLogFile;
+}
+
+void CAdvProviderSettings::SetLogFormat(const tstring& rsFormat)
+{
+ m_sFormatLogFile = rsFormat;
+}
+
+bool CAdvProviderSettings::GetLogOnlyChangedFlag()const
+{
+ return m_bIsOnlyChangedLogFile;
+}
+
+void CAdvProviderSettings::SetLogOnlyChangedFlag(bool bMode)
+{
+ m_bIsOnlyChangedLogFile = bMode;
+}
+
+const tstring& CAdvProviderSettings::GetPopupFormat() const
+{
+ return m_sPopupFormat;
+}
+
+void CAdvProviderSettings::SetPopupFormat(const tstring& val)
+{
+ m_sPopupFormat = val;
+}
+
+bool CAdvProviderSettings::GetShowPopupIfValueChangedFlag() const
+{
+ return m_bShowPopupIfValueChanged;
+}
+
+void CAdvProviderSettings::SetShowPopupIfValueChangedFlag(bool val)
+{
+ m_bShowPopupIfValueChanged = val;
+}
+
+CPopupSettings* CAdvProviderSettings::GetPopupSettingsPtr()const
+{
+ if(nullptr == m_pPopupSettings)
+ {
+ m_pPopupSettings = new CPopupSettings(m_pQuotesProvider);
+ }
+
+ return m_pPopupSettings;
+}
+
+CPopupSettings::CPopupSettings(const IQuotesProvider* pQuotesProvider)
+ : m_modeColour(colourDefault),
+ m_modeDelay(delayFromPopup),
+ m_rgbBkg(GetDefColourBk()),
+ m_rgbText(GetDefColourText()),
+ m_wDelay(3),
+ m_bUseHistory(false)
+
+{
+ CQuotesProviderVisitorDbSettings visitor;
+ pQuotesProvider->Accept(visitor);
+
+ assert(visitor.m_pszDbPopupColourMode);
+ assert(visitor.m_pszDbPopupBkColour);
+ assert(visitor.m_pszDbPopupTextColour);
+ assert(visitor.m_pszDbPopupDelayMode);
+ assert(visitor.m_pszDbPopupDelayTimeout);
+ assert(visitor.m_pszDbPopupHistoryFlag);
+
+ BYTE m = DBGetContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupColourMode,static_cast<BYTE>(m_modeColour));
+ if(m >= colourDefault && m <= colourUserDefined)
+ {
+ m_modeColour = static_cast<EColourMode>(m);
+ }
+
+ m_rgbBkg = DBGetContactSettingDword(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupBkColour,m_rgbBkg);
+ m_rgbText = DBGetContactSettingDword(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupTextColour,m_rgbText);
+
+ m = DBGetContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupDelayMode,static_cast<BYTE>(m_modeDelay));
+ if(m >= delayFromPopup && m <= delayPermanent)
+ {
+ m_modeDelay = static_cast<EDelayMode>(m);
+ }
+ m_wDelay = DBGetContactSettingWord(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupDelayTimeout,m_wDelay);
+ m_bUseHistory = (1 == DBGetContactSettingByte(NULL,QUOTES_PROTOCOL_NAME,visitor.m_pszDbPopupHistoryFlag,m_bUseHistory));
+}
+
+/*static */
+COLORREF CPopupSettings::GetDefColourBk()
+{
+ return ::GetSysColor(COLOR_BTNFACE);
+}
+
+/*static */
+COLORREF CPopupSettings::GetDefColourText()
+{
+ return ::GetSysColor(COLOR_BTNTEXT);
+}
+
+void CPopupSettings::InitForContact(HANDLE hContact)
+{
+ BYTE m = DBGetContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_COLOUR_MODE,static_cast<BYTE>(m_modeColour));
+ if(m >= CPopupSettings::colourDefault && m <= CPopupSettings::colourUserDefined)
+ {
+ m_modeColour = static_cast<CPopupSettings::EColourMode>(m);
+ }
+
+ m_rgbBkg = DBGetContactSettingDword(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_COLOUR_BK,m_rgbBkg);
+ m_rgbText = DBGetContactSettingDword(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_COLOUR_TEXT,m_rgbText);
+
+ m = DBGetContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_DELAY_MODE,static_cast<BYTE>(m_modeDelay));
+ if(m >= CPopupSettings::delayFromPopup && m <= CPopupSettings::delayPermanent)
+ {
+ m_modeDelay = static_cast<CPopupSettings::EDelayMode>(m);
+ }
+ m_wDelay = DBGetContactSettingWord(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_DELAY_TIMEOUT,m_wDelay);
+ m_bUseHistory = 1 == DBGetContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_HISTORY_FLAG,m_bUseHistory);
+}
+
+void CPopupSettings::SaveForContact(HANDLE hContact)const
+{
+ DBWriteContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_COLOUR_MODE,static_cast<BYTE>(m_modeColour));
+ DBWriteContactSettingDword(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_COLOUR_BK,m_rgbBkg);
+ DBWriteContactSettingDword(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_COLOUR_TEXT,m_rgbText);
+ DBWriteContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_DELAY_MODE,static_cast<BYTE>(m_modeDelay));
+ DBWriteContactSettingWord(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_DELAY_TIMEOUT,m_wDelay);
+ DBWriteContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_POPUP_HISTORY_FLAG,m_bUseHistory);
+}
+
+CPopupSettings::EColourMode CPopupSettings::GetColourMode()const
+{
+ return m_modeColour;
+}
+
+void CPopupSettings::SetColourMode(EColourMode nMode)
+{
+ m_modeColour = nMode;
+}
+
+COLORREF CPopupSettings::GetColourBk()const
+{
+ return m_rgbBkg;
+}
+
+void CPopupSettings::SetColourBk(COLORREF rgb)
+{
+ m_rgbBkg = rgb;
+}
+
+COLORREF CPopupSettings::GetColourText()const
+{
+ return m_rgbText;
+}
+
+void CPopupSettings::SetColourText(COLORREF rgb)
+{
+ m_rgbText = rgb;
+}
+
+CPopupSettings::EDelayMode CPopupSettings::GetDelayMode()const
+{
+ return m_modeDelay;
+}
+
+void CPopupSettings::SetDelayMode(EDelayMode nMode)
+{
+ m_modeDelay = nMode;
+}
+
+WORD CPopupSettings::GetDelayTimeout()const
+{
+ return m_wDelay;
+}
+
+void CPopupSettings::SetDelayTimeout(WORD delay)
+{
+ m_wDelay = delay;
+}
+
+bool CPopupSettings::GetHistoryFlag()const
+{
+ return m_bUseHistory;
+}
+
+void CPopupSettings::SetHistoryFlag(bool flag)
+{
+ m_bUseHistory = flag;
+}
+
+bool ShowSettingsDlg(HWND hWndParent,CAdvProviderSettings* pAdvSettings)
+{
+ assert(pAdvSettings);
+
+ return (IDOK == DialogBoxParam(g_hInstance,
+ MAKEINTRESOURCE(IDD_PROVIDER_ADV_SETTINGS),
+ hWndParent,
+ EditSettingsPerProviderDlgProc,
+ reinterpret_cast<LPARAM>(pAdvSettings)));
+}
+
+namespace
+{
+ void replace_invalid_char(tstring::value_type& rChar,tstring::value_type repl)
+ {
+ static const TCHAR charInvalidSigns[] = {_T('\\'), _T('/'), _T(':'), _T('*'), _T('?'), _T('\"'), _T('<'), _T('>'), _T('|')};
+
+ for(int i = 0; i < sizeof(charInvalidSigns)/sizeof(charInvalidSigns[0]);++i)
+ {
+ if(rChar == charInvalidSigns[i])
+ {
+ rChar = repl;
+ break;
+ }
+ }
+ }
+
+}
+
+tstring GenerateLogFileName(const tstring& rsLogFilePattern,
+ const tstring& rsQuoteSymbol,
+ int nFlags/* = glfnResolveAll*/)
+{
+ tstring sPath = rsLogFilePattern;
+ if(nFlags&glfnResolveQuoteName)
+ {
+ assert(false == rsQuoteSymbol.empty());
+
+ tstring::size_type n = sPath.find(g_pszVariableQuoteName);
+ if(tstring::npos != n)
+ {
+ tstring s = rsQuoteSymbol;
+ std::for_each(s.begin(),s.end(),boost::bind(replace_invalid_char,_1,_T('_')));
+ sPath.replace(n,lstrlen(g_pszVariableQuoteName),s.c_str());
+ }
+ }
+
+ if(nFlags&glfnResolveUserProfile)
+ {
+ REPLACEVARSDATA dat = {0};
+ dat.cbSize = sizeof(dat);
+ dat.dwFlags = RVF_TCHAR;
+
+ TCHAR* ptszParsedName = reinterpret_cast<TCHAR*>(CallService(MS_UTILS_REPLACEVARS,
+ reinterpret_cast<WPARAM>(sPath.c_str()),reinterpret_cast<LPARAM>(&dat)));
+ if(ptszParsedName)
+ {
+ sPath = ptszParsedName;
+ mir_free(ptszParsedName);
+ }
+ }
+
+ return sPath;
+}
+
+tstring GetContactLogFileName(HANDLE hContact)
+{
+ tstring result;
+
+ const CQuotesProviders::TQuotesProviderPtr& pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact);
+ if(pProvider)
+ {
+ tstring sPattern;
+ bool bUseContactSpecific = (DBGetContactSettingByte(hContact,QUOTES_PROTOCOL_NAME,DB_STR_CONTACT_SPEC_SETTINGS,0) > 0);
+ if(bUseContactSpecific)
+ {
+ sPattern = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_LOG_FILE);
+ }
+ else
+ {
+ CAdvProviderSettings global_settings(pProvider.get());
+ sPattern = global_settings.GetLogFileName();
+ }
+
+ result = GenerateLogFileName(sPattern,Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_SYMBOL));
+ }
+
+ return result;
+}
+
+tstring GetContactName(HANDLE hContact)
+{
+ tstring sDescription = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_DESCRIPTION);
+ if(sDescription.empty())
+ {
+ sDescription = Quotes_DBGetStringT(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_SYMBOL);
+ }
+ return sDescription;
+}
diff --git a/plugins/Quotes/src/SettingsDlg.h b/plugins/Quotes/src/SettingsDlg.h new file mode 100644 index 0000000000..569d0b7d2c --- /dev/null +++ b/plugins/Quotes/src/SettingsDlg.h @@ -0,0 +1,118 @@ +#ifndef __E211E4D9_383C_43BE_A787_7EF1D585B90D_SettingsDlg_h__
+#define __E211E4D9_383C_43BE_A787_7EF1D585B90D_SettingsDlg_h__
+
+class IQuotesProvider;
+
+class CPopupSettings
+{
+public:
+ enum EColourMode
+ {
+ colourDefault,
+ colourUserDefined,
+ };
+
+ enum EDelayMode
+ {
+ delayFromPopup,
+ delayCustom,
+ delayPermanent
+ };
+
+public:
+ CPopupSettings(const IQuotesProvider* pQuotesProvider);
+
+ static COLORREF GetDefColourBk();
+ static COLORREF GetDefColourText();
+
+ void InitForContact(HANDLE hContact);
+ void SaveForContact(HANDLE hContact)const;
+
+ EColourMode GetColourMode()const;
+ void SetColourMode(EColourMode nMode);
+
+ COLORREF GetColourBk()const;
+ void SetColourBk(COLORREF rgb);
+
+ COLORREF GetColourText()const;
+ void SetColourText(COLORREF rgb);
+
+ EDelayMode GetDelayMode()const;
+ void SetDelayMode(EDelayMode nMode);
+
+ WORD GetDelayTimeout()const;
+ void SetDelayTimeout(WORD delay);
+
+ bool GetHistoryFlag()const;
+ void SetHistoryFlag(bool flag);
+
+private:
+ EColourMode m_modeColour;
+ EDelayMode m_modeDelay;
+ COLORREF m_rgbBkg;
+ COLORREF m_rgbText;
+ WORD m_wDelay;
+ bool m_bUseHistory;
+};
+
+
+class CAdvProviderSettings
+{
+public:
+ CAdvProviderSettings(const IQuotesProvider* pQuotesProvider);
+ ~CAdvProviderSettings();
+
+ void SaveToDb()const;
+
+ const IQuotesProvider* GetProviderPtr()const;
+
+ WORD GetLogMode()const;
+ void SetLogMode(WORD wMode);
+ tstring GetHistoryFormat()const;
+ void SetHistoryFormat(const tstring& rsFormat);
+ bool GetHistoryOnlyChangedFlag()const;
+ void SetHistoryOnlyChangedFlag(bool bMode);
+
+ tstring GetLogFileName()const;
+ void SetLogFileName(const tstring& rsFile);
+ tstring GetLogFormat()const;
+ void SetLogFormat(const tstring& rsFormat);
+ bool GetLogOnlyChangedFlag()const;
+ void SetLogOnlyChangedFlag(bool bMode);
+
+ const tstring& GetPopupFormat() const;
+ void SetPopupFormat(const tstring& val);
+
+ bool GetShowPopupIfValueChangedFlag() const;
+ void SetShowPopupIfValueChangedFlag(bool val);
+
+ CPopupSettings* GetPopupSettingsPtr()const;
+
+private:
+ const IQuotesProvider* m_pQuotesProvider;
+ WORD m_wLogMode;
+ tstring m_sFormatHistory;
+ bool m_bIsOnlyChangedHistory;
+ tstring m_sLogFileName;
+ tstring m_sFormatLogFile;
+ bool m_bIsOnlyChangedLogFile;
+ tstring m_sPopupFormat;
+ bool m_bShowPopupIfValueChanged;
+ mutable CPopupSettings* m_pPopupSettings;
+};
+
+void ShowSettingsDlg(HANDLE hContact);
+bool ShowSettingsDlg(HWND hWndParent,CAdvProviderSettings* pAdvSettings);
+
+enum
+{
+ glfnResolveQuoteName = 0x0001,
+ glfnResolveUserProfile = 0x0002,
+ glfnResolveAll = glfnResolveQuoteName|glfnResolveUserProfile,
+};
+tstring GenerateLogFileName(const tstring& rsLogFilePattern,const tstring& rsQuoteSymbol,int nFlags = glfnResolveAll);
+tstring GetContactLogFileName(HANDLE hContact);
+tstring GetContactName(HANDLE hContact);
+
+#endif //__E211E4D9_383C_43BE_A787_7EF1D585B90D_SettingsDlg_h__
+
diff --git a/plugins/Quotes/src/WinCtrlHelper.cpp b/plugins/Quotes/src/WinCtrlHelper.cpp new file mode 100644 index 0000000000..619fe3d41b --- /dev/null +++ b/plugins/Quotes/src/WinCtrlHelper.cpp @@ -0,0 +1,49 @@ +#include "stdafx.h"
+#include "QuotesProviderVisitorFormatSpecificator.h"
+#include "IQuotesProvider.h"
+#include "resource.h"
+#include "ModuleInfo.h"
+
+namespace
+{
+ INT_PTR CALLBACK VariableListDlgProc(HWND hWnd,UINT msg,WPARAM wp,LPARAM lp)
+ {
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hWnd);
+ const IQuotesProvider* pProvider = reinterpret_cast<const IQuotesProvider*>(lp);
+ CQuotesProviderVisitorFormatSpecificator visitor;
+ pProvider->Accept(visitor);
+
+ tostringstream o;
+ const CQuotesProviderVisitorFormatSpecificator::TFormatSpecificators& raSpec = visitor.GetSpecificators();
+ std::for_each(raSpec.begin(),raSpec.end(),
+ [&o](const CQuotesProviderVisitorFormatSpecificator::CFormatSpecificator& spec)
+ {
+ o << spec.m_sSymbol << _T('\t') << spec.m_sDesc << _T("\r\n");
+ });
+ ::SetDlgItemText(hWnd,IDC_EDIT_VARIABLE,o.str().c_str());
+ }
+ break;
+ case WM_COMMAND:
+ if(BN_CLICKED == HIWORD(wp) && (IDOK == LOWORD(wp) || IDCANCEL == LOWORD(wp)))
+ {
+ ::EndDialog(hWnd,IDOK);
+ }
+ break;
+ }
+
+ return FALSE;
+ }
+}
+
+void show_variable_list(HWND hwndParent,const IQuotesProvider* pProvider)
+{
+ ::DialogBoxParam(g_hInstance,
+ MAKEINTRESOURCE(IDD_DIALOG_VARIABLE_LIST),
+ hwndParent,
+ VariableListDlgProc,
+ reinterpret_cast<LPARAM>(pProvider));
+}
diff --git a/plugins/Quotes/src/WinCtrlHelper.h b/plugins/Quotes/src/WinCtrlHelper.h new file mode 100644 index 0000000000..d7f8957a86 --- /dev/null +++ b/plugins/Quotes/src/WinCtrlHelper.h @@ -0,0 +1,37 @@ +#ifndef __a05d6852_4497_4f28_85e1_48a15a170738_WinCtrlHelper_h__
+#define __a05d6852_4497_4f28_85e1_48a15a170738_WinCtrlHelper_h__
+
+class IQuotesProvider;
+
+inline tstring get_window_text(HWND hWnd)
+{
+ int cBytes = ::GetWindowTextLength(hWnd);
+
+ std::vector<TCHAR> aBuf(cBytes+1);
+ LPTSTR pBuffer = &*(aBuf.begin());
+ ::GetWindowText(hWnd,pBuffer,cBytes+1);
+
+ return tstring(pBuffer);
+}
+
+inline void prepare_edit_ctrl_for_error(HWND hwndEdit)
+{
+ ::SetFocus(hwndEdit);
+ ::SendMessage(hwndEdit, EM_SETSEL, 0, -1);
+ ::SendMessage(hwndEdit, EM_SCROLLCARET, 0, 0);
+}
+
+void show_variable_list(HWND hwndParent,const IQuotesProvider* pProvider);
+
+inline int Quotes_MessageBox(HWND hWnd,LPCTSTR pszText,UINT nType = MB_OK)
+{
+ return ::MessageBox(hWnd,pszText,quotes_a2t(MIRANDANAME).c_str(),nType);
+}
+
+inline void spin_set_range(HWND hwndSpin,short nLower,short nUpper)
+{
+ ::SendMessage(hwndSpin,UDM_SETRANGE,0,MAKELPARAM(nUpper,nLower));
+}
+
+
+#endif //__a05d6852_4497_4f28_85e1_48a15a170738_WinCtrlHelper_h__
diff --git a/plugins/Quotes/src/WorkingThread.cpp b/plugins/Quotes/src/WorkingThread.cpp new file mode 100644 index 0000000000..bc4d80b734 --- /dev/null +++ b/plugins/Quotes/src/WorkingThread.cpp @@ -0,0 +1,15 @@ +#include "StdAfx.h"
+#include "WorkingThread.h"
+
+#include "IQuotesProvider.h"
+
+void WorkingThread(void* pParam)
+{
+ IQuotesProvider* pProvider = reinterpret_cast<IQuotesProvider*>(pParam);
+ assert(pProvider);
+
+ if(pProvider)
+ {
+ pProvider->Run();
+ }
+}
diff --git a/plugins/Quotes/src/WorkingThread.h b/plugins/Quotes/src/WorkingThread.h new file mode 100644 index 0000000000..a77734bb85 --- /dev/null +++ b/plugins/Quotes/src/WorkingThread.h @@ -0,0 +1,6 @@ +#ifndef __cd52f1a3_63b2_44f0_a0a9_48c203958fa4_WorkingThread_h__
+#define __cd52f1a3_63b2_44f0_a0a9_48c203958fa4_WorkingThread_h__
+
+void WorkingThread(void* pParam);
+
+#endif //__cd52f1a3_63b2_44f0_a0a9_48c203958fa4_WorkingThread_h__
diff --git a/plugins/Quotes/src/XMLEngineMI.cpp b/plugins/Quotes/src/XMLEngineMI.cpp new file mode 100644 index 0000000000..7e2adfb7d9 --- /dev/null +++ b/plugins/Quotes/src/XMLEngineMI.cpp @@ -0,0 +1,230 @@ +#include "StdAfx.h"
+#include "XMLEngineMI.h"
+
+XML_API xi;
+
+namespace
+{
+ class CXMLNodeMI : public IXMLNode,
+ private boost::noncopyable
+ {
+ public:
+ typedef boost::shared_ptr<IXMLNode> TXMLNodePtr;
+
+ public:
+ explicit CXMLNodeMI(HXML hXMl,bool bDestroy = false) : m_hXML(hXMl),m_bDestroy(bDestroy)
+ {
+ assert(m_hXML);
+ }
+
+ virtual ~CXMLNodeMI()
+ {
+ if(m_bDestroy)
+ {
+ xi.destroyNode(m_hXML);
+ }
+ }
+
+ virtual size_t GetChildCount()const
+ {
+ return xi.getChildCount(m_hXML);
+ }
+
+ virtual TXMLNodePtr GetChildNode(size_t nIndex)const
+ {
+ HXML h = xi.getChild(m_hXML, (int)nIndex);
+ if(h)
+ {
+ return TXMLNodePtr(new CXMLNodeMI(h));
+ }
+ else
+ {
+ return TXMLNodePtr();
+ }
+ }
+
+ virtual tstring GetText()const
+ {
+ tstring sResult;
+ LPCTSTR psz = xi.getText(m_hXML);
+ if(psz)
+ {
+ sResult = psz;
+ }
+
+ return sResult;
+ }
+
+ virtual tstring GetName()const
+ {
+ tstring sResult;
+ LPCTSTR psz = xi.getName(m_hXML);
+ if(psz)
+ {
+ sResult = psz;
+ }
+
+ return sResult;
+ }
+
+ virtual bool AddChild(const TXMLNodePtr& pNode)
+ {
+ CXMLNodeMI* pXML = dynamic_cast<CXMLNodeMI*>(pNode.get());
+ if(pXML)
+ {
+ xi.addChild2(pXML->m_hXML,m_hXML);
+ pXML->m_bDestroy = false;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ virtual bool AddAttribute(const tstring& rsName,const tstring& rsValue)
+ {
+ xi.addAttr(m_hXML,rsName.c_str(),rsValue.c_str());
+ return true;
+ }
+
+ virtual tstring GetAttributeValue(const tstring& rsAttrName)
+ {
+ LPCTSTR pszValue = xi.getAttrValue(m_hXML,rsAttrName.c_str());
+ return ((NULL != pszValue) ? tstring(pszValue) : tstring());
+ }
+
+ virtual void Write(tostream& o)const
+ {
+// struct safe_string
+// {
+// safe_string(LPTSTR p):m_p(p){}
+// ~safe_string(){xi.freeMem(m_p);}
+//
+// LPTSTR m_p;
+// };
+//
+// struct mir_safe_string
+// {
+// mir_safe_string(LPSTR p) : m_p(p){}
+// ~mir_safe_string(){mir_free(m_p);}
+//
+// LPSTR m_p;
+// };
+
+
+ safe_string<TCHAR> ss(xi.toString(m_hXML,NULL));
+ if(ss.m_p)
+ {
+ mir_safe_string<char> mss(mir_utf8encodeT(ss.m_p));
+ if(mss.m_p)
+ {
+ o << mss.m_p;
+ }
+ }
+ }
+
+ private:
+ HXML m_hXML;
+ bool m_bDestroy;
+ };
+}
+
+CXMLEngineMI::CXMLEngineMI()
+{
+}
+
+CXMLEngineMI::~CXMLEngineMI()
+{
+}
+
+IXMLNode::TXMLNodePtr CXMLEngineMI::LoadFile(const tstring& rsFileName)const
+{
+// struct mir_safe_string
+// {
+// mir_safe_string(LPTSTR p) : m_p(p){}
+// ~mir_safe_string(){mir_free(m_p);}
+//
+// LPTSTR m_p;
+// };
+
+
+ IXMLNode::TXMLNodePtr pResult;
+ FILE* stream;
+ if(0 == ::_tfopen_s(&stream,rsFileName.c_str(),_T("r")))
+ {
+ struct _stat st;
+ if (-1 != ::_fstat(::_fileno(stream),&st))
+ {
+ std::vector<char> aBuffer(st.st_size+1);
+ char* pBuffer = &*(aBuffer.begin());
+ size_t cBytes = ::fread(pBuffer,sizeof(char),st.st_size,stream);
+ if(cBytes > 0 && cBytes <= static_cast<size_t>(st.st_size))
+ {
+ pBuffer[cBytes] = '\0';
+
+ int nLen = (int)cBytes;
+ mir_safe_string<TCHAR> ss(mir_utf8decodeT(pBuffer));
+ if(ss.m_p)
+ {
+ HXML h = xi.parseString(ss.m_p,&nLen,NULL);
+ if(h)
+ {
+ pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h,true));
+ }
+ }
+ }
+ }
+ ::fclose(stream);
+ }
+
+ return pResult;
+}
+
+namespace
+{
+ IXMLNode::TXMLNodePtr create_node(const tstring& rsName,const tstring& rsText,bool bIsDecl)
+ {
+ IXMLNode::TXMLNodePtr pResult;
+ HXML h = xi.createNode(rsName.c_str(),rsText.c_str(),bIsDecl);
+ if(h)
+ {
+ pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h,true));
+ }
+
+ return pResult;
+ }
+}
+
+bool CXMLEngineMI::SaveFile(const tstring& rsFileName,const IXMLNode::TXMLNodePtr& pNode)const
+{
+ CXMLNodeMI* pXML = dynamic_cast<CXMLNodeMI*>(pNode.get());
+ if(pXML)
+ {
+ tofstream file(rsFileName.c_str());
+ if(file.good())
+ {
+ IXMLNode::TXMLNodePtr pRoot(create_node(_T("xml"),tstring(),true));
+ if(pRoot)
+ {
+ pRoot->AddAttribute(_T("version"),_T("1.0"));
+ pRoot->AddAttribute(_T("encoding"),_T("UTF-8"));
+ file << *pRoot;
+ }
+
+ if(file.good())
+ {
+ file << *pNode;
+ }
+ }
+
+ return file.good();
+ }
+
+ return false;
+}
+
+IXMLNode::TXMLNodePtr CXMLEngineMI::CreateNode(const tstring& rsName,const tstring& rsText)const
+{
+ return create_node(rsName,rsText,false);
+}
\ No newline at end of file diff --git a/plugins/Quotes/src/XMLEngineMI.h b/plugins/Quotes/src/XMLEngineMI.h new file mode 100644 index 0000000000..5e5a51232f --- /dev/null +++ b/plugins/Quotes/src/XMLEngineMI.h @@ -0,0 +1,17 @@ +#ifndef __0c3d1da4_92b7_431c_83e5_f998cd513f0d_XMLEngineMI_h__
+#define __0c3d1da4_92b7_431c_83e5_f998cd513f0d_XMLEngineMI_h__
+
+#include "ixmlengine.h"
+
+class CXMLEngineMI : public IXMLEngine
+{
+public:
+ CXMLEngineMI();
+ ~CXMLEngineMI();
+
+ virtual IXMLNode::TXMLNodePtr LoadFile(const tstring& rsFileName)const;
+ virtual bool SaveFile(const tstring& rsFileName,const IXMLNode::TXMLNodePtr& pNode)const;
+ virtual IXMLNode::TXMLNodePtr CreateNode(const tstring& rsName,const tstring& rsText)const;
+};
+
+#endif //__0c3d1da4_92b7_431c_83e5_f998cd513f0d_XMLEngineMI_h__
diff --git a/plugins/Quotes/src/resource.h b/plugins/Quotes/src/resource.h new file mode 100644 index 0000000000..50ee0a637b --- /dev/null +++ b/plugins/Quotes/src/resource.h @@ -0,0 +1,109 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Forex.rc
+//
+#define IDD_DIALOG_ECONOMIC_RATES 101
+#define IDI_ICON_MAIN 102
+#define IDD_DIALOG_QUOTE_INFO 102
+#define IDD_DIALOG_OPT_GOOGLE 103
+#define IDI_ICON_SECTION 110
+#define IDI_ICON_QUOTE 111
+#define IDI_ICON_UP 113
+#define IDI_ICON_DOWN 114
+#define IDD_CONTACT_SETTINGS 115
+#define IDI_ICON_NOTCHANGED 116
+#define IDD_CURRENCY_CONVERTER 116
+#define IDI_ICON_CURRENCY_CONVERTER 117
+#define IDD_DUKASCOPY_CHART 117
+#define IDD_CHART 117
+#define IDD_DIALOG_QUOTE_INFO_1 118
+#define IDI_ICON_REFRESH 118
+#define IDD_DIALOG_OPT_FINANCE 119
+#define IDI_ICON_IMPORT 119
+#define IDI_ICON_EXPORT 120
+#define IDD_PROVIDER_ADV_SETTINGS 120
+#define IDI_ICON_SWAP 121
+#define IDD_DIALOG_POPUP 121
+#define IDD_DIALOG_VARIABLE_LIST 123
+#define IDC_TREE_ECONOMIC_RATES 1001
+#define IDC_EDIT_REFRESH_RATE 1002
+#define IDC_SPIN_REFRESH_RATE 1003
+#define IDC_COMBO_REFRESH_RATE 1004
+#define IDC_STATIC_QUOTE_NAME 1008
+#define IDC_SYSLINK_PROVIDER 1009
+#define IDC_STATIC_CHART 1010
+#define IDC_STATIC_QUOTE_CHART 1010
+#define IDC_COMBO_CONVERT_FROM 1011
+#define IDC_COMBO_CONVERT_INTO 1012
+#define IDC_BUTTON_ADD 1013
+#define IDC_LIST_RATES 1014
+#define IDC_BUTTON_REMOVE 1015
+#define IDC_EDIT_RATE 1016
+#define IDC_EDIT_RATE_FETCH_TIME 1017
+#define IDC_EDIT_CONTACT_LIST_FORMAT 1018
+#define IDC_EDIT_PREVIOUS_RATE 1018
+#define IDC_BUTTON_DESCRIPTION 1019
+#define IDC_CHECK_INTERNAL_HISTORY 1020
+#define IDC_EDIT_STATUS_MESSAGE_FORMAT 1020
+#define IDC_CHECK_EXTERNAL_FILE 1021
+#define IDC_EDIT_FILE_NAME 1022
+#define IDC_EDIT_TENDENCY_FORMAT 1022
+#define IDC_BUTTON_BROWSE 1023
+#define IDC_STATIC_SELECT_FILE 1024
+#define IDC_EDIT_NAME 1025
+#define IDC_EDIT_HISTORY_FORMAT 1026
+#define IDC_EDIT_LOG_FILE_FORMAT 1027
+#define IDC_BUTTON_DESCRIPTION2 1028
+#define IDC_BUTTON_LOG_FILE_DESCRIPTION 1028
+#define IDC_STATIC_HISTORY_FORMAT 1029
+#define IDC_BUTTON_HISTORY_DESCRIPTION 1030
+#define IDC_STATIC_LOG_FILE_FORMAT 1031
+#define IDC_CHECK_HISTORY_CONDITION 1032
+#define IDC_CHECK_LOG_CONDITION2 1033
+#define IDC_CHECK_LOG_FILE_CONDITION 1033
+#define IDC_EDIT_VALUE 1033
+#define IDC_BUTTON_CONVERT 1034
+#define IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED 1034
+#define IDC_STATIC_POPUP_FORMAT 1035
+#define IDC_EDIT_POPUP_FORMAT 1036
+#define IDC_BUTTON_LOG_FILE_DESCRIPTION2 1037
+#define IDC_BUTTON_POPUP_FORMAT_DESCRIPTION 1037
+#define IDC_EDIT_RESULT 1039
+#define IDC_STATIC_IMAGE 1056
+#define IDC_EDIT_QUOTE 1059
+#define IDC_BUTTON_SWAP 1060
+#define IDC_BUTTON_ADVANCED_SETTINGS 1061
+#define IDC_BUTTON_POPUP_SETTINGS 1061
+#define IDC_CHECK_CONTACT_SPECIFIC 1062
+#define IDC_RADIO_DEFAULT_COLOURS 1063
+#define IDC_CHECK_SHOW_POPUP 1064
+#define IDC_RADIO_USER_DEFINED_COLOURS 1064
+#define IDC_MFCCOLORBUTTON1 1066
+#define IDC_CHECK1 1067
+#define IDC_CHECK_DONT_USE_POPUPHISTORY 1067
+#define IDC_COMBO_DATA_SOURCE 1068
+#define IDC_COMBO_FILTER 1069
+#define IDC_EDIT_FROM 1070
+#define IDC_EDIT_FROM2 1071
+#define IDC_EDIT_TO 1071
+#define IDC_STATIC_PROVIDER_NAME 1071
+#define IDC_DELAY 1072
+#define IDC_EDIT1 1072
+#define IDC_EDIT_VARIABLE 1072
+#define IDC_BGCOLOR 1074
+#define IDC_TEXTCOLOR 1075
+#define IDC_PREV 1076
+#define IDC_DELAYFROMPU 1093
+#define IDC_DELAYCUSTOM 1094
+#define IDC_DELAYPERMANENT 1095
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 124
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1073
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/Quotes/src/stdafx.cpp b/plugins/Quotes/src/stdafx.cpp new file mode 100644 index 0000000000..e4738d8f60 --- /dev/null +++ b/plugins/Quotes/src/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes
+// Forex.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/plugins/Quotes/src/stdafx.h b/plugins/Quotes/src/stdafx.h new file mode 100644 index 0000000000..5e72bc0e0b --- /dev/null +++ b/plugins/Quotes/src/stdafx.h @@ -0,0 +1,154 @@ +// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+#define MIRANDA_VER 0x0A00
+// #define CHART_IMPLEMENT
+#define TEST_IMPORT_EXPORT
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+#include <tchar.h>
+#include <stdio.h>
+#include <string>
+#include <wininet.h>
+#include <atlbase.h>
+#include <atlconv.h>
+#include <mshtml.h>
+#include <atlcomcli.h>
+#include <comutil.h>
+#include <comdef.h>
+#include <commctrl.h>
+#include <ShellAPI.h>
+#include <msxml2.h>
+#include <sys\stat.h>
+#include <CommDlg.h>
+#include <windowsx.h>
+#include <atlenc.h>
+
+
+// Miranda headers
+#pragma warning(disable: 4996)
+#include <newpluginapi.h>
+#include <m_database.h>
+#include <m_protocols.h>
+#include <m_protomod.h>
+#pragma warning(default: 4996)
+#include <win2k.h>
+#include <m_xml.h>
+#include <m_langpack.h>
+#include <m_options.h>
+#include <m_cluiframes.h>
+#include <m_extraicons.h>
+#include <m_icolib.h>
+#include <m_clist.h>
+#include <m_genmenu.h>
+#include <m_netlib.h>
+#include <m_popup.h>
+#include <m_userinfo.h>
+#include <m_variables.h>
+
+// boost headers
+#include <boost\shared_ptr.hpp>
+#include <boost/bind.hpp>
+#include <boost\lexical_cast.hpp>
+#include <boost\noncopyable.hpp>
+#include <boost\scoped_ptr.hpp>
+#include <boost\foreach.hpp>
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost\cast.hpp>
+#include "boost/date_time/c_local_time_adjustor.hpp"
+
+// stl headers
+#include <string>
+#include <vector>
+#include <sstream>
+#include <iomanip>
+#include <fstream>
+#include <map>
+
+
+typedef std::wstring tstring;
+typedef std::wostringstream tostringstream;
+typedef std::wistringstream tistringstream;
+typedef std::wofstream tofstream;
+typedef std::wifstream tifstream;
+typedef std::wostream tostream;
+typedef std::wistream tistream;
+typedef boost::posix_time::wtime_input_facet ttime_input_facet;
+typedef boost::posix_time::wtime_facet ttime_facet;
+
+inline int quotes_stricmp(LPCTSTR p1,LPCTSTR p2)
+{
+ return _tcsicmp(p1,p2);
+}
+
+inline std::string quotes_t2a(const TCHAR* t)
+{
+ std::string s;
+ char* p = mir_t2a(t);
+ if(p)
+ {
+ s = p;
+ mir_free(p);
+ }
+ return s;
+}
+
+inline tstring quotes_a2t(const char* s)
+{
+ tstring t;
+ TCHAR* p = mir_a2t(s);
+ if(p)
+ {
+ t = p;
+ mir_free(p);
+ }
+ return t;
+}
+namespace detail
+{
+ template<typename T,typename TD> struct safe_string_impl
+ {
+ typedef T* PTR;
+
+ safe_string_impl(PTR p) : m_p(p){}
+ ~safe_string_impl(){TD::dealloc(m_p);}
+
+ PTR m_p;
+ };
+
+ template<typename T> struct MirandaFree
+ {
+ static void dealloc(T* p){mir_free(p);}
+ };
+
+ template<typename T> struct OwnerFree
+ {
+ static void dealloc(T* p){::free(p);}
+ };
+}
+
+template<typename T> struct mir_safe_string : public detail::safe_string_impl<T,detail::MirandaFree<T>>
+{
+ mir_safe_string(PTR p) : detail::safe_string_impl<T,detail::MirandaFree<T>>(p){}
+};
+
+template<typename T> struct safe_string : public detail::safe_string_impl<T,detail::OwnerFree<T>>
+{
+ safe_string(PTR p) : detail::safe_string_impl<T,detail::OwnerFree<T>>(p){}
+};
+
+extern HINSTANCE g_hInstance;
+
+// #ifdef MIRANDA_VER
+// #undef MIRANDA_VER
+// #endif
+
+// TODO: reference additional headers your program requires here
diff --git a/plugins/Quotes/src/targetver.h b/plugins/Quotes/src/targetver.h new file mode 100644 index 0000000000..f583181dfd --- /dev/null +++ b/plugins/Quotes/src/targetver.h @@ -0,0 +1,24 @@ +#pragma once
+
+// The following macros define the minimum required platform. The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
+#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
+#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#endif
+
+#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
+#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
+#endif
diff --git a/plugins/Quotes/src/version.h b/plugins/Quotes/src/version.h new file mode 100644 index 0000000000..a80f032948 --- /dev/null +++ b/plugins/Quotes/src/version.h @@ -0,0 +1,21 @@ +#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 24
+#define __BUILD_NUM 0
+
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
+
+#define __STRINGIFY_IMPL(x) #x
+#define __STRINGIFY(x) __STRINGIFY_IMPL(x)
+#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS)
+
+#define __PLUGIN_NAME "Quotes"
+#define __INTERNAL_NAME "Quotes"
+#define __FILENAME "Quotes.dll"
+#define __DESCRIPTION "Shows currency rates and economic quotes."
+#define __AUTHOR "Dioksin"
+#define __AUTHOREMAIL "dioksin@ua.fm"
+#define __AUTHORWEB "http://miranda-ng.org/"
+#define __COPYRIGHT "Don't worry!"
+#define SPECIAL_BUILD_STRING "5388"
diff --git a/plugins/StatusPlugins/StartupStatus/options.cpp b/plugins/StatusPlugins/StartupStatus/options.cpp index d6b30052f7..c6cecb3d17 100644 --- a/plugins/StatusPlugins/StartupStatus/options.cpp +++ b/plugins/StatusPlugins/StartupStatus/options.cpp @@ -39,16 +39,16 @@ static int ClearDatabase(char* filter); static TSettingsList* GetCurrentProtoSettings()
{
int count;
- PROTOACCOUNT** protos;
- ProtoEnumAccounts( &count, &protos );
+ PROTOACCOUNT **protos;
+ ProtoEnumAccounts(&count, &protos);
- TSettingsList* result = new TSettingsList( count, CompareSettings );
- if ( result == NULL )
+ TSettingsList *result = new TSettingsList(count, CompareSettings);
+ if (result == NULL)
return NULL;
- for ( int i=0; i < count; i++ )
- if ( IsSuitableProto( protos[i] ))
- result->insert( new TSSSetting( protos[i] ));
+ for (int i=0; i < count; i++)
+ if ( IsSuitableProto(protos[i]))
+ result->insert( new TSSSetting(protos[i]));
return result;
}
diff --git a/plugins/StatusPlugins/commonstatus.cpp b/plugins/StatusPlugins/commonstatus.cpp index d02986a275..9ca9e15e35 100644 --- a/plugins/StatusPlugins/commonstatus.cpp +++ b/plugins/StatusPlugins/commonstatus.cpp @@ -164,11 +164,11 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) { return 0;
int count;
- PROTOACCOUNT** protos;
- ProtoEnumAccounts( &count, &protos );
+ PROTOACCOUNT **protos;
+ ProtoEnumAccounts(&count, &protos);
- for ( i=0; i < count; i++ ) {
- if ( !IsSuitableProto( protos[i] ))
+ for (i=0; i < count; i++) {
+ if ( !IsSuitableProto(protos[i]))
continue;
pstatus = 0;
@@ -317,18 +317,9 @@ static INT_PTR GetProtocolCountService(WPARAM wParam, LPARAM lParam) return GetProtoCount();
}
-bool IsSuitableProto( PROTOACCOUNT* pa )
+bool IsSuitableProto(PROTOACCOUNT *pa)
{
- if ( pa == NULL )
- return false;
-
- if ( pa->bDynDisabled || !pa->bIsEnabled )
- return false;
-
- if ( CallProtoService( pa->szProtoName, PS_GETCAPS, PFLAGNUM_2, 0 ) == 0 )
- return false;
-
- return true;
+ return (pa == NULL) ? false : (pcli->pfnGetProtocolVisibility(pa->szModuleName) != 0);
}
int GetProtoCount()
@@ -336,12 +327,12 @@ int GetProtoCount() int pCount = 0;
int count;
- PROTOACCOUNT** protos;
+ PROTOACCOUNT **protos;
ProtoEnumAccounts( &count, &protos );
- for ( int i=0; i < count; i++ )
- if ( IsSuitableProto( protos[i] ))
- pCount ++;
+ for (int i=0; i < count; i++)
+ if ( IsSuitableProto(protos[i]))
+ pCount++;
return pCount;
}
diff --git a/plugins/StatusPlugins/commonstatus.h b/plugins/StatusPlugins/commonstatus.h index 8eccbc3a8f..64619f11bd 100644 --- a/plugins/StatusPlugins/commonstatus.h +++ b/plugins/StatusPlugins/commonstatus.h @@ -75,7 +75,7 @@ static int statusModePf2List[]={PF2_OFFLINE,PF2_ONLINE,PF2_SHORTAWAY,PF2_LONGAWA TCHAR *GetDefaultStatusMessage(PROTOCOLSETTINGEX *ps, int status);
int GetActualStatus(PROTOCOLSETTINGEX *protoSetting);
int InitCommonStatus();
-bool IsSuitableProto( PROTOACCOUNT* pa );
+bool IsSuitableProto(PROTOACCOUNT *pa);
/* SimpleAway */
diff --git a/plugins/Weather/docs/license.txt b/plugins/Weather/docs/license.txt new file mode 100644 index 0000000000..45645b4b53 --- /dev/null +++ b/plugins/Weather/docs/license.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/plugins/Weather/docs/sample_ini.ini b/plugins/Weather/docs/sample_ini.ini new file mode 100644 index 0000000000..dc36eda754 --- /dev/null +++ b/plugins/Weather/docs/sample_ini.ini @@ -0,0 +1,421 @@ +[Weather 0.3.x Update Data 1.4]
+
+; This file contains the information required for the weather protocol to obtain update.
+; For the plugin to function properly, at least one of these file must be present.
+; The proper location of these files is: plugins\weather
+
+; Note that for the entire file, DO NOT put spaces before or after the "=". The groups
+; and setting names (for example, [Header] and Name) are not case sensitive; however,
+; the values set for each settings ARE case sensitive.
+
+; Also note that the first line of this file must be either one of the following:
+; [Weather 0.3.x Update Data] (min. req. v0.3.0.0)
+; [Weather 0.3.x Update Data 1.1] (min. req. v0.3.1.8)
+; [Weather 0.3.x Update Data 1.1a] (min. req. v0.3.2.8)
+; [Weather 0.3.x Update Data 1.2] (min. req. v0.3.5.0)
+; [Weather 0.3.x Update Data 1.3] (min. req. v0.3.8.0)
+; [Weather 0.3.x Update Data 1.4] (min. req. v0.3.8.12)
+
+; Minimun version for not crashing Miranda (Set to this version to prevent the ini from
+; loading in an old version of weather plugin and crash Miranda)
+; 1.1a String longer than 256 characters.
+; 1.1 More than 16 data items in the ini
+; Not using [/...] footer at the end of the list
+; 1.0 All other features
+
+; Minimun version for using the new features (Set to this version to prevent invalid data
+; for user with old version of weather plugin. However, the other features still works)
+; 1.4 Using "Cookie="
+; 1.3 Using "Update Url2=" & "Update Url3="
+; 1.2 Using the operation "Break Data="
+; Using the setting "Hidden=" for each data item
+; Assign weather icons from ini
+; 1.1a Support for the units: Day, Month, %, Deg, Cond
+; 1.1 Using the operation "Set Data="
+; 1.0 All other features
+
+; Revision history:
+; 1.4 (Updated in v0.3.8.12)
+; New "Cookie="
+; 1.3 (Updated in v0.3.8.0)
+; New "Update Url2=" & "Update Url3="
+; 1.2 (Updated in v0.3.5.0; minimun req. v0.3.5.0)
+; New operation "Break Data="
+; New setting "Hidden=" that hide the data item from the mor data list
+; Weather icon assignment from the ini
+; 1.1a (Updated in v0.3.4.0; minimun req. v0.3.2.8)
+; Support for Day, Month units
+; 1.1a (Updated in v0.3.3.0; minimun req. v0.3.2.8)
+; Support the %, Deg, Cond units
+; 1.1a (For v0.3.2.8; minimun req. v0.3.2.8)
+; Now the string can be unlimited long (at least when it's within 4096 characters)
+; 1.1 (For v0.3.2.0; minimun req. v0.3.1.8)
+; No more need to use [/...] headers (now it just like a normal INI file)
+; Support more weather data, and the number of data is no longer limited to 16
+; New operation "Set Data=" that assign data items without download the info
+; 1.0 (For v0.3.0.0; minimun req. v0.3.0.0)
+; Initial version.
+
+; ======================================================================================
+
+; INI Headers
+
+[Header]
+; The name field contains the string that will appear to the user. Please be unique.
+; (for example, "Yahoo Weather")
+Name=
+
+; The internal name is the string that will be used to set the weather ID, and are used
+; internally to obtain the weather update information. This string should be short and
+; unique.
+; (for example, "yw" for "Yahoo Weather")
+Internal Name=
+
+; The following 3 fields are used in the plugin for INI information only, but it also
+; gives user some information about the file.
+Description=
+Author=
+Version=
+
+; For the following three default fields, %s is used for station ID (the one with the
+; internal name taken away, for example, CAXX0001)
+[Default]
+; The default URL for getting more weather information from contact menu or brief info
+; dialog. This setting is the default one assigned to the weather contact when it is
+; added, but can be changed by user in the Edit Settings dialog.
+Default URL=
+
+; The default URL for getting weather map from contact menu. Same as above.
+Default Map=
+
+; The URL for retrieving weather updates.
+Update URL=
+Update URL2=
+Update URL3=
+Update URL4=
+
+; Set cookie(s) when retrieving weather updates.
+Cookie=
+
+; ======================================================================================
+
+; Weather Data Fields
+
+; The following section list the data fields that are used to assign the data to be stored
+; in the database. These fields should be placed in the order of appearance in the
+; download information. For each item searched, the string before the item are discarded
+; so if the order is wrong, no information can be obtained from the latter item.
+
+; Format (not all settings are necessary):
+; [Field Name]
+; Start=
+; End=
+; Set Data=
+; Break Data=
+; Source=
+; Unit=
+; Hidden=
+
+; Default Fields:
+; [Condition] Current condition, to assign condition icon
+; [Update] For display of the update time of the weather data
+; [Temperature] Current temperature
+; [Feel] Feel-like temperature
+; [High] Today's high
+; [Low] Today's low
+; [Sunrise] Sun rise time
+; [Sunset] Sun set time
+; [Wind Direction] Wind direction (not including speed)
+; Be careful to consider the no wind situation (ie. calm)
+; [Wind Speed] The speed of the wind
+; [Pressure] Barometer pressure
+; [Visibility] Visibility, if the value is 0 or non-numerical value, then unit conversion
+; for this will not run and original string is retained
+; [Humidity] Humidity, without a % sign.
+
+; Special Fields:
+; [Alert]
+; Special item for weather alert.
+; If the data retrieved for this field is non-empty, then a special alert popup will
+; display and the city on the contact list will be in a special state (using the
+; setting for "Contact to whom you have a different visibility".
+; This will be reset to normal once the alert field becomes empty.
+; [Ignore]
+; Special item for the plugin to ignore what the value it gets and all errors when
+; getting it. The value obtained for this field will not be written into the
+; database, and no popup and notification will be raised. This is useful to skip
+; some specific text or end the download script. Multiple placement of this field
+; is allowed.
+; Note: For prevent the popup of error message, v0.3.2.11 is required
+
+; Custom Fields:
+; [%name%]
+; Where %name% can be any string you want.
+
+
+; Settings:
+; Settings for obtaining data: "Start=", "End=", "Set Data=", "Break Data=", "Source="
+
+; There are 3 ways for the plugin to obtain the information string:
+; 1. Parse directly from the webpage by specifying start and end strings. Note that these
+; strings are case sensitive.
+
+; When parsing the information, the following items are removed:
+; HTML tags example: <b> </b>
+; symbols example:
+; linefeed and tabs
+; multiple spaces, spaces at the beginning and at the end of the string
+; Also, if the start field is blank, that means the information starts immediately
+; after the string from the last "End=" field. If the end field is blank, that means
+; the information ends at the first space the plugin encounters (even if it is inside
+; a HTML tag).
+
+; An example, for parsing
+; "<sth before>Partly <!-- something in middle --> Cloudy<sth after>
+; The code to give "Partly Cloudy" (without quotation):
+; [Condition]
+; Start=<sth before>
+; End=<sth after>
+
+; 2. Concatenate strings, using "Set Data=", can merge various string together by placing
+; them around the operator " & " (without the quotation mark but with the 2 spaces).
+; For the variable strings (ie. the data item retrieved previously), use []
+; For constant strings, use ""
+
+; For example, merging two condition strings "Condition 1" and "Condition 2":
+; [Condition]
+; Set Data=[Condition 1] & " and " & [Condition 2]
+
+; Another example, copy the content of "Condition
+; [Copy of Condition]
+; Set Data=[Condition]
+
+; 3. Break a string into 2, using "Break Data=", by specifying the string in between the
+; two substrings. The first half will store into the name specify by the header, and
+; the second half will be specified by "End="
+
+; An example, to reverse what we did in Example 2 (the two condition strings):
+; [Condition 1]
+; Break Data= and
+; Source=Condition
+; End=Condition 2
+
+; Other Settings:
+; Unit=
+; Specify the unit for the data, for use in unit conversion. The conversion to use
+; depends on the value assigned.
+; For temperature conversion: C, F, K
+; For speed conversion: km/h, m/s, mph, knots
+; For pressure conversion: hPa, kPa, mb, torr, mm, in
+; For distance conversion: km, miles
+; For adding a percent sign at the end: %
+; For adding a degree sign at the end: Deg
+; Convert condition str to proper case: Cond
+; For weekday string length: Day
+; For month string length: Month
+
+; Hidden=
+; Acceptable values: true, false
+; Using this on any field will prevent it from being displayed in the "More Info"
+; list, but its value will still be stored in the database.
+
+; Url=
+; Acceptable values: 1, 2, 3
+; Specifies the url on where to look for data item
+; If parameter is not specified item is searched on all urls, the last found will be used
+
+; Here's an example:
+[Condition]
+Start=
+End=
+Unit=Cond
+
+[Temperature]
+Start=
+End=
+Unit=C
+
+[Humidity TEMP]
+Start=
+End=
+Hidden=true
+
+[Humidity]
+Set Data=[Humidity TEMP] & "%"
+
+; - or -
+
+[Humidity]
+Start=
+End=
+Unit=%
+
+
+; ======================================================================================
+
+; The setting for find and add contacts.
+
+; ID search is used when the user type in the ID in the "Station ID" field and pressed
+; "Search"
+[ID Search]
+
+; This can be "true" or "false" (without quotation, not case sensitive)
+; If this is set to "false", all the following strings are ignored and the ID are NOT
+; going to search for this weather service.
+; If this field is set to FALSE, no matter what the user type for station ID, the
+; plugin will always return a result with station name empty and ID the same as what
+; the user has typed.
+Available=
+
+; The URL for ID search. Note that %s is used for placing the ID.
+Search URL=
+
+; The string appeared in the downloaded information when there is no match
+; (ie. "Document not found")
+; If this string is found while searching, the search process quit and return no result.
+Not Found Str=
+
+; Similar to weather information retrival above. This is the string preceeding the
+; station name obtained from searching. Note that the parsing is the same as above, and
+; spaces can be used.
+Name Start=
+
+; This is what's after the station name.
+Name End=
+
+; END ID SEARCH
+
+; Name search is used when the user type in any of the name field (Nick, First, Last) and
+; click on the "search" button.
+[Name Search]
+
+; This can be "true" or "false" (without quotation, not case sensitive)
+; If this is set to "false", then the plugin igmore the information stated in the Single
+; fields (ie. from "Single Name Start" to "Single ID End")
+Single Result=
+
+; This can be "true" or "false" (without quotation, not case sensitive)
+; If this is set to "false", then the plugin igmore the information stated in the Multiple
+; fields (ie. from Multiple Name Start" to Multiple ID End")
+; Note that if both single and multiple are disabled, the Name search are disabled for
+; this weather service.
+Multiple Result=
+
+; The URL for doing the name search. %s will be replaced by the station name input from
+; the user.
+Search URL=
+
+; The string appeared in the downloaded information when there is no match
+; (ie. "Document not found")
+; If this string is found while searching, the search process quit and return no result.
+Not Found Str=
+
+; This field determines whether the search will return a single result or multiple result
+; If the string stated in this field is found and Single Result is enabled from above, the
+; settings for single result will be used. Otherwise, the settings in multiple result
+; will be used.
+Single Result Str=
+
+; These fields are for the single result
+
+; Determine which item is the first to appear in the download search result file
+; This field can be ID or Name (not case sensitive).
+; For example, if ID is used here, it means that station ID appears before the station
+; name in the downloaded document.
+Single First=
+
+; The start and end string for station name. Parsing using the same way as discribed
+; above for weather information.
+; Note that if both fields are empty, then whatever the user type into the search field
+; will be used for the station name.
+Single Name Start=
+Single Name End=
+
+; The start and end string for station name. Parsing using the same way as discribed
+; above for weather information.
+Single ID Start=
+Single ID End=
+
+; The multiple result is similar to the single result as described above.
+; For this search, the plugin will loop until no more Name's and ID's can be founded
+; in the downloaded file.
+Mult First=
+Mult Name Start=
+Mult Name End=
+Mult ID Start=
+Mult ID End=
+
+; END NAME SEARCH
+
+; For a workaround of URL forwarding issue:
+; If the page retrieved contains URL forward (ie. the 302 code), the download content
+; will appears as:
+; Moved/Location: <forwarded URL>
+; This might be useful for writing the start/end string settings for the single result
+; Name Search.
+; A typical use of this is:
+; Single Result Str=Moved/Location:
+; Single First=ID (this isn't really matter)
+; Single Name Start=
+; Single Name End= (this will use whatever user type in as stn name)
+; Single ID Start=/newpages/ (what's before the station ID in the URL)
+; Single ID End=.html (what's after the station ID)
+
+; ======================================================================================
+
+; INI Defined Icon Assignments (new in v1.2)
+
+; These assignment will take the highest priority (before the internal and the langpack
+; defined assignment) when matching the condition (icon) to the current condition.
+; These settings are INI specific, which means that the setting in one INI will not affect
+; the stations that are associated to another INI.
+
+; Format:
+; {icon name}={string to search}
+
+; The "icon name" is the icon to assigned with the condition string containing the string
+; specified in "string to search" is found.
+
+; Available icon names are (in order of assigning priority):
+; Lightning, Fog, Snow Shower, Snow, Rain Shower, Rain, Partly Cloudy, Cloudy, Sunny, N/A
+
+; For examples, mimicking what internal icon selection and langpack_defweather do (of
+; course, putting these in an actual INI is not needed and is waste of space and memory).
+
+[Icons]
+Sunny=Sunny
+Sunny=Clear
+Sunny=Fair
+
+Partly Cloudy=Mainly Sunny
+Partly Cloudy=Mainly Clear
+Partly Cloudy=Partly
+Partly Cloudy=Mostly
+Partly Cloudy=Clouds
+
+Cloudy=Cloudy
+Cloudy=Overcast
+
+Rain=Drizzle
+Rain=Rain
+
+Rain Shower=Rain Shower
+Rain Shower=Shower
+
+Snow=Snow
+Snow=Ice
+Snow=Freezing
+Snow=Wintery
+
+Snow Shower=Snow Shower
+Snow Shower=Flurries
+
+Ligntning=Thunder
+Ligntning=T-storm
+
+Fog=Fog
+Fog=Mist
+Fog=Smoke
+Fog=Haze
+Fog=Sand
+Fog=Dust
diff --git a/plugins/Weather/docs/weather-history.txt b/plugins/Weather/docs/weather-history.txt new file mode 100644 index 0000000000..ff936f56f2 --- /dev/null +++ b/plugins/Weather/docs/weather-history.txt @@ -0,0 +1,930 @@ +Weather Protocol - Version History
+==================================
+Version 0.3.8.19 2011/09/03
+ - Fixed Brief window update on weather station update
+ - Fixed No ini window no show
+
+Version 0.3.8.18 2010/08/20
+ - Specialized translations for all weather conditions
+ - Fixed possible crashes
+
+Version 0.3.8.17 2010/05/29
+ - Added possibility to add specialized translations for weather conditions
+ format: #condition Weather
+ - Added 32x32 icon support
+ - 32x32 icon is used in a frame in a frame if no avatar present
+ - Added support for Miranda 0.9 persistent http trasactions
+ - Changed Breif dialog appearence
+ - Fixed translation issues
+ - Fixed keyborad navigation in UserInfo dialog
+ - Requires Miranda 0.8 or higher
+
+Version 0.3.8.16 2009/08/09
+ - Increased allowed size of station id
+ - Removed built-in support for HTTP compression (compression not supported with pre 0.8 Miranda any longer)
+ - Fixed crash with no ini files
+ - x64 port
+
+Version 0.3.8.15 2009/03/22
+ - Added support for gif avatars
+ - Added support for 4 urls per ini
+ - Added supoort for html metadata (utf8)
+ - Fixed rounding with fractional reading display
+ - Added more http redirection support
+ - Allow to draw forced avatar in frame
+
+Version 0.3.8.14 2009/01/10
+ - Fixed Set Data failures
+ - Fixed crashes with http
+ - Fixed http errors processing
+ - Added support for temperature in format -<space><number>
+
+Version 0.3.8.13 2008/12/25
+ - Changed search UI to have more descriptive labels
+ - Documentation updates
+
+Version 0.3.8.12 2008/12/22
+ - Added support for cookies (cakes and ice cream)
+
+Version 0.3.8.10 2008/12/07
+ - Fixed temperature display
+
+Version 0.3.8.9 2008/12/06
+ - Added support for deflate compressed http streams
+ - Fixes for weather crashes
+ - Added option to round all values to nearest integer
+
+Version 0.3.8.8 2008/11/22
+ - Improved formatting for numerical values
+ - Fixed crashes due to compressed http stream
+ - Added support for gzip encoded http stream
+
+Version 0.3.8.7 2008/08/02
+ - Fixed crash for people measuring speed in km/h
+
+Version 0.3.8.6 2008/08/01
+ - Added display fraction of temperature and wind speed when available
+ - Added handling of UTF8 pages (needed for GisMeteo)
+
+Version 0.3.8.5 2008/07/27
+ - Fixed option dialog layout
+ - Fixed ini version display
+ - Fixed memory leak with multiurl ini
+ - Fixed plugin version number
+
+Version 0.3.8.3 2008/07/24
+ - Fixed url tag
+ - Added headers to variable view
+ - Fixed options dialog layout
+
+Version 0.3.8.2 2008/06/08
+ - Fixed ini version display in User Info
+ - Fixes for wind in Weather Underground ini to work correctly
+
+Version 0.3.8.1 2008/05/25
+ - Added ability to parse upto 3 URL per ini file for weather data
+ - Fixed break data and parameters with units
+ - Added ability to skin weather frame with clist_modern ("Main,ID=WeatherFrame")
+ - Added display "nickname" in the first line of the frame
+ - Added avatar display in the weather frame
+
+Version 0.3.7.2 2008/01/19
+ - Fixed updates in normal mode
+ - Fixed option dialog layout
+
+Version 0.3.7.1 2007/12/22
+ - Partial workaround for core HTTP problem
+ - Tabbed option dialog
+
+Version 0.3.7.0 2007/12/21
+ - Added icolib support
+ - Added frames support
+ - New icons by Angeli-Ka
+ - Compatible with Miranda 0.7 and later
+
+Version 0.3.6.5 2007/08/17
+ - Workaround for tray icon
+
+Version 0.3.6.4 2007/07/27
+ - Fixed caching problems
+
+Version 0.3.6.3 2007/07/08
+ - Fixed error message at stratup (with updater)
+ - Increased possible weather variable size
+ - More generic couldy definition
+
+Version 0.3.6.2 2007/06/02
+ - More sensible autoupdate Enable/Disable operation
+
+Version 0.3.6.1 2007/06/01
+ - Fixed popup click action
+ - Fixed translation
+
+Version 0.3.6.0 2007/05/18
+ - New icons by Angeli-Ka
+ - Protocol icons split into separate dll
+ - Option dialog and menus redesign
+ - Instant avatar update
+ - Ini file display name now used as client ID (MirVer)
+ - Moved ini file list into View/Change My Details
+ - Support for new plugin interface
+ - Fixed few parsing issues
+
+Version 0.3.5.19 2007/01/27
+ - Fixed translation
+
+Version 0.3.5.18 2007/01/26
+ - Fixed translation
+ - Fixed resource leaks
+ - Fixed crash
+ - Partial unicode support
+
+Version 0.3.5.17 2007/01/20
+ - Reduced GDI resource utilization
+ - Fixed memory leak with old ini files
+ - Fixed search function for stations with special characters
+
+Version 0.3.5.16 2006/11/27
+ - Fixed units conversion
+ - Fixed memory corruption
+ - Added ability to show clickable links in Brief window
+
+Version 0.3.5.15 2006/11/16
+ - Fixed web page parsing (Wind Speed in Yahoo)
+ - Fixed "No wind" condition handling
+ - Performance improvments for HTTP transfers
+ - Fixed memory corruption
+
+Version 0.3.5.14 2006/10/31
+ - Fixed status message operation
+
+Version 0.3.5.13 2006/10/29
+ - Fixed non english alphabets operation
+ - Fixed Weather condition update issues
+ - Added option to keep station status from reflecting weather condition
+ (should resolve avatar overlay problems with clist modern)
+ - Moved Weather main menu entry into the protocol group
+ - Improvements for forecast window sizing
+
+Version 0.3.5.12 2006/07/23
+ - Fixed non english alphabets operation
+
+Version 0.3.5.11 2006/07/22
+ - Fixed text corruption
+ - Added ability to display avatars for each weather condition
+ - Fixed Win95 operation
+
+Version 0.3.5.10 2006/07/16
+ - Changed Current Date/Time display (%d) according to locale
+ - Changed handling of HTTP redirect requests
+
+Version 0.3.5.9 2006/04/08
+ - Fixed misplaced buttons on forecast view window
+ - Fixed weather history incorrect source
+ - Fixed incorrect PopUp notification text in the menu
+
+Version 0.3.5.8 2005/09/20
+ - Fixed automatic set of deafult station logic failure and as a result crash at power-up
+ - Fixed INI info dialog layout and ini version information
+ - Fixed rare crash on exit
+ - Fixed resource leak
+ - Fixed few memory leaks
+ - Fixed crash at power-up with corrupted ini file
+ - A lot of code robustness updates
+
+Version 0.3.5.7 2005/09/18
+ - Fixed few resource leaks
+ - Fixed gloabal status
+ - Fixed weather alert format
+ - Fixed very rare crash on exit
+
+Version 0.3.5.6 2005/09/14
+ - Fixed few crashes on exit and
+ - A lot of code robustness updates
+ - Updater compatibility
+ - Fixed resource leaks
+
+Version 0.3.5.5 2005/09/11
+ - Fixed crash on exit
+ - Support for custom "Status Messages"
+
+Version 0.3.5.4 2005/09/08
+ - Fixed crash in my User details
+ - Fixed endless "updating user info ..."
+ - Fixed search function regression
+
+Version 0.3.5.3 2005/09/07
+ - Fixed crash at Powerup
+ - Fixed crash on Miranda exit
+ - Fixed numerous other crashes
+ - Fixed numerous memory leaks
+ - Fixed memory corruption
+ - Fixed resource leak
+
+Version 0.3.5.2 2005/09/07
+ - Fixed crash on Miranda exit
+ - Fixed numerous other crashes
+ - Fixed numerous memory leaks
+ - Fixed memory corruption
+ - Fixed resource leak
+
+Version 0.3.5.0 2005/03/21
+ - New Option: Disable update on startup
+ - New Option: Enable/Disable popups by type: update, alert, error
+ - INI Option: Support breaking string
+ - INI Option: Support hidden fields
+ - INI Option: Support icon assignment from ini
+ - Updated sample_ini.ini and translation
+ - Some other minor changes that I can't remember
+
+Version 0.3.4.4 2004/12/28
+ - Load window list correctly, fix problem with brief info and edit dlg not showing
+ - Some internal changes with new service functions
+
+Version 0.3.4.3 2004/12/26
+ - Minor change in INI loading
+
+Version 0.3.4.2 Beta 2004/12/16
+ - Bug fix: Miranda cannot quit after forkthread is used
+ - Bug fix: The unit % does not work anymore
+ - Bug fix: No longer crash when the link settings is not set
+ - Update the weather ini download link to the new location
+
+Version 0.3.4.1 Beta 2004/12/09
+ - ESC now works in weather dialogs
+ - More changes to forkthread
+ - Document updated: weather-translation, sample_ini
+
+Version 0.3.4.0 Beta 2004/11/21
+ - Change the threading to forkthread
+ - New option: Custom status when condition is unavailable
+ - New option: Convert day/month string into 2 char or 3 char format
+ - Some internal changes
+ - Minor change in ini format
+
+Version 0.3.3.17 2004/11/19
+ - Condition translated correctly when writing into database
+ - Correctly restore the windows position for edit setting dialog
+
+Version 0.3.3.16 2004/11/10
+
+Version 0.3.3.15 2004/10/21
+ - Remember the window position for edit settings dialog
+ - Minor change in dialog (I still can't get the close on ESC to work...)
+
+Version 0.3.3.14 Beta 2004/10/20
+ - Fix the crash in option page bug (hopefully)
+ - Fix the support for \n in text input
+ - Minor change in dialog
+
+Version 0.3.3.13 2004/10/16
+ - Another fix for default station
+ - Some changes to reduce database read/write for default station changes
+ - Now the plugin is correctly registered in known module list for DBEditor++
+ - Save the setting for popup and update enable/disable directly after menu click
+ - Some update in readme, more changes in translation (thanks smyle again)
+
+Version 0.3.3.12 2004/10/16
+ - Fix 2 possible crashes regarding default station
+
+Version 0.3.3.11 2004/10/15
+ - Fix a bug with global status
+ - Updated translation list (thanks smyle)
+
+Version 0.3.3.10 2004/10/14
+ - Changes in default station handling, hopefully will fix a crash in option page
+ - Add new sound event: Weather alert
+ - Add new menu item: Add new weather station (call up the find/add dialog)
+ - Document updated: weather_translation.txt
+
+Version 0.3.3.9 2004/09/26
+ - Some changes in code.
+
+Version 0.3.3.8 2004/09/24
+ - Now uses default system text for brief info and setup dialog.
+
+Version 0.3.3.7 (Beta)
+ - Test releases for crash in option page
+
+Version 0.3.3.6 2004/09/24
+ - Add a sound event when weather condition is updated
+ - Use the default system color for brief info and setup dialog
+ - Minor change in unit conversion
+ - Fix in brief info when there is no data for current conditions
+ - Add entry to Database Editor++ known module
+
+Version 0.3.3.5 2004/08/14
+ - Fix apply button in option pages
+ - Fix "Humidity" in default settings
+ - Ignore the sample ini file if it is placed in plugin\weather dir
+ - Minor changes in update timer and option dialog
+
+Version 0.3.3.4 (Beta) 2004/07/23
+ - Fix some bug in text option
+ - Take proto_weather.dll icon into account when auto-assigning icon
+ - Option to disable automatic icon assignment
+ - Few minor changes
+ - Document updated: weather_translation.txt
+
+Version 0.3.3.3 2004/07/21
+ - Automatically set to default weather icon if no custom one is set
+ - Add a ini setup information dialog to help setup weather protocol
+ - Update in brief info now retrieve new data from the internet
+ - Few minor changes
+ - Document updated: weather_translation.txt
+
+Version 0.3.3.2 (Beta) 2004/07/14
+ - Show error detail on update errors
+ - Includes simple set of 16-colors weather icons in the dll file
+ - Option to disable italic display for station with alert issued
+ - Option to disable warning dialog if ini is not found at startup
+ - Attempt to fix the black bar bug in brief info
+ - Fix the bug that shows connecting as weather status
+ - Document updated: weather_translation.txt
+
+Version 0.3.3.1 2004/06/19
+ - Minor change in the brief info dialog
+ - More info items are now translatable
+ - Case conversion in condition to make them translatable (use unit: Cond)
+ - Save window size for the brief info dialog
+ - Fix crash when invalid ID or ini file for the station is not found
+ - Few minor changes
+ - Document updated: sample_ini
+
+Version 0.3.3.0 (Beta) 2004/06/12
+ - A new feature that erase old data while updating for new data
+ - A change in the brief information dialog (thanks micron-x for last seen plugin)
+ - Double click a contact shows brief info dialog (thanks Matrix and JdGordon)
+ - Add brief info title setting
+ - Change in the weather, text, and popup options dialogs
+ - Add reset to default and preview for all display text field
+ - Change the way the plugin handles protocol status
+ - Enable/disable auto-update from the main menu
+ - Reconizes dust conditions and assign a fog icon (thanks Klenje)
+ - Support the units "%" and "Deg"
+ - Fix a crash if miranda32.exe is renamed
+ - Fix crashes in between updating of 2 stations (thanks Targaff)
+ - Update links in the readme and DLL to the new weather category (thanks lynlimz)
+ - Other bug fixes and minor changes
+ - Document updated: weather-translation, langpack_defweather, sample_ini
+
+Version 0.3.2.16 2004/05/27
+ - Reconizes condition in lower case
+ - Few changes.
+
+Version 0.3.2.15 2004/05/24
+ - Now reconizes the condition string "T-storm"
+ - No longer skip hidden weather contact while updating
+ - Bug fix when previewing weather popups
+ - Bug fix in parsing the HTML content (in cases where "&" exists)
+ - Few other minor fixes and changes.
+
+Version 0.3.2.14 2004/05/12
+ - Popup preview include a preview of popup text settings (use default station)
+ - Fix memory leaks in various places.
+
+Version 0.3.2.13 2004/05/08
+ - Changed some linker options to prevent plugin not loading
+
+Version 0.3.2.12 2004/05/08
+ - Assign fog icon to the sand conditions
+
+Version 0.3.2.11 2004/05/07
+ - Really ignore the "Ignore" item in the ini file
+ - Fix crash when unloading ini's (at reload or shutdown)
+ - Change in weather alert popup
+ - Few minor changes
+
+Version 0.3.2.10 2004/05/02
+ - Rebuild using Visual C++
+
+Version 0.3.2.9 2004/04/29
+ - Attempt to fix crash when searching for cities by name
+ - Display a list of custom variables
+ - Fix memory leak when reloading strings from ini files
+ - Changes in the code for parsing weather info and loading ini files
+ - Other minor changes
+
+Version 0.3.2.8 2004/04/28
+ - Fix on loading ini strings, support for v1.1a again
+ - Fix in weather station search
+ - Fix crash when not connected to the internet
+ - Add a new debug function (need DB Editor)
+ - A few other minor fixes and changes
+
+Version 0.3.2.7 2004/04/19
+ - Fixing the crash on startup bug one more time :(
+
+Version 0.3.2.6 2004/04/19
+ - Attempt to fix an crash on startup bug again.
+ - Temporary remove support for v1.1a of the INI file. :(
+
+Version 0.3.2.5 2004/04/19
+ - Attempt to fix an crash on startup bug.
+
+Version 0.3.2.4 2004/04/19
+ - Fix some error while loading weather ini file.
+ - Obtain station name from the net in edit dialog.
+ - Display N/A when temperature is unavail. and the string retrieved is not "N/A"
+ - Some minor changes.
+
+Version 0.3.2.3 2004/04/18
+ - Automatically suppress online notification for all weather contact when upgrade.
+ - Fixed crash when adding new contact.
+ - Fixed crash when importing contact using mContacts.
+ - Some minor changes.
+
+Version 0.3.2.2 2004/04/18
+ - Change the way weather handles status, now properly display NA for def stn.
+ - Protocol status can be changed freely if "Do not display weather conditions
+ as protocol status" is enabled.
+ - More memory leak fixes and crash fixes.
+
+Version 0.3.2.1 2004/04/17
+ - Reduce memory use by more than 60% and fixed some memory leaks
+ - Support a revision of v1.1 ini file (the length string now can be unlimited)
+ - Incrase the maximun text length to 4k (but try keep it as short as possible)
+ - A few minor fixes and changes
+ - Updated readme file.
+
+Version 0.3.2.0 2004/04/12
+ - Support new variable %% (same as \%) and %[..] (see readme)
+ - Now with the complete support of weather INI v1.1
+ - Very basic support of weather alert notifications (if the INI supports it)
+ - Add browse, view webpage, and reset to default buttons edit settings dialog
+ - Interface changes and fixed tab order for all dialogs
+ - Display information for the weather INI files
+ - Some other monor changes and fixes
+ - Updates Read Me, and now it is in HTML format.
+
+Version 0.3.1.8 2004/04/09
+ - "My Notes" text are copied to "Current\WeatherInfo" (might be useful for some plugins)
+ - Increase the length of display texts from 512b to 4k
+ - Bug Fix: when temperature is N/A, display N/A
+ - Bug Fix: rounding in unit conversion, err...
+ - Bug Fix: crash with new ini setting "Set Data="
+
+Version 0.3.1.7 2004/04/08
+ - Now correctly support the new ini files.
+
+Version 0.3.1.6 2004/04/04
+ - Support escape characters "\%" for displaying %
+ - Changes in warning popups
+
+Version 0.3.1.5 2004/04/02
+ - New option: Consider weather info updated only when cond and temp are changed
+ - Support v1.1 of weather ini files - only support loading, but not the new features ;)
+ - Rounding is used when converting units
+ - Attempt to fix the crash on exit and reload weather data bug
+ - The default update time is changed to 20 min
+ - Other minor fixes and changes that I don't remember
+
+Version 0.3.1.1 2004/03/27
+ - Fix the crash when opening brief info dialog
+ - The default for "Support online notification" is on when adding new station
+
+Version 0.3.1.0 2004/03/25
+ - Change the way popup is handled, no longer need to enable the threading option
+ - Manually add station without searching by entering "#" in the ID field
+ - Always provide a search result if the weather service has no ID search available.
+ - Some error handling and popups to prevent crashes.
+ - New hookable event: ME_WEATHER_UPDATED
+ - Bug fix: Translation of retrieved data
+ - Bug fix: Search don't work for city that has more than 1 word
+ - Bug fix: Speed conversion is wrong
+ - Bug fix: weatherch.ini: Crash if adding/updating a station in US Eastern timezone
+ - Updated: weatherch.ini, Read Me, Translation, Sample INI, m_weather.h
+
+Version 0.3.0.1 (Beta) 2004/03/23
+ - Do not update contacts that are hidden from list (see it as "disabled" contacts)
+ - Give error message box when selecting more info and weather map before setting the URL
+ - Bug fix: Find and search contacts (no result found + crashes)
+ - Bug fix: Issue with StartupStatus, now weather will update at least once on startup
+ regardless of what's the setting there.
+ - Bug fix: Visibility unit conversion
+ - Bug fix: Weather contacts appear offline if langpack is installed
+ - Bug fix: Some spelling error
+ - Bug fix: Feel-like temperature can't be displayed by mToolTip
+ - Bug fix: WU: Find and search for station that doesn't have current condition
+ - Updated: All 4 INI files, Read Me, Translation
+
+Version 0.3.0.0 (Beta) 2004/03/22
+ - Combine the weather dll's into one
+ - Using external file for getting update (in plugins\weather directory)
+ - Added user detail page for weather contacts
+ - New and improved option pages
+ - Proxy support (now uses netlib)
+ - Unit conversion for pressure, visibility, and wind
+ - Optimization in the edit setting dialog - Allow multiple window
+ - Changes in brief info dialog - able to open multiple brief info
+ - Reduce the number of DB access for getting settings
+ - Add more variables such as feel-like temperature, pressure
+ - Add menu item for enable/disable popup
+ - Support weather icon determination for site in other languages using langpack
+ - Support for plugin uninstaller
+ - Optimization in weather update - now update using a queue and minimize DB access
+ - Optimizaiton in add/search - now don't do unnecessary searches
+ - Other code optimization and reduce file size
+ - Reload weather update data file from the main menu
+ - Some other major and minor UI change
+ - Remove some useless features
+ - Bug fix: temperature conversion (thanks to sirius)
+ - Bug fix: crash on adding new station
+ - Some minor changes and fixes in webpage downloading.
+ - Includes documentation for INI update data file and icon selection translation.
+ - Major changes in translation strings.
+ - Some update in the readme documentation.
+ - Included in this version:
+ Weather Channel, Weather Underground (both US and International), Yahoo Weather.
+
+Version 0.2.5.2
+
+Version 0.2.5.1 2003/07/19
+ - Minor bug fixes
+
+Version 0.2.5.0 2003/06/09
+ - New feature: short weather information as status message and/or note.
+ - New option: display weather options inside plugin options.
+ - Create a seperate page for text and display options.
+ - Other minor changes and bug fixes
+
+Version 0.2.4.5 2003/06/12
+ - Bug fix: Backup/restore protocol icon (including rebuild icon) if status is hidden.
+ - Bug fix: Popup only condition changes.
+
+Version 0.2.4.4 2003/06/08
+ - Fixed typo in option
+ - Weather underground: Retrieve data for high/low temperature even if
+ current info is unavailable
+ - Minor code change.
+
+Version 0.2.4.3 2003/06/07
+ - Fix weather underground searching station
+
+Version 0.2.4.2 2003/06/06
+ - Fixed weather underground station name display problem.
+ - Changes to make compatible with earlier version in case of downgrading
+ - Reorganize language pack strings.
+
+Version 0.2.4.1 (Beta) 2003/05/28
+ - New preview using the selected timeout value.
+ - Modified timeout warning message box.
+
+Version 0.2.4.0 (Beta) 2003/05/28
+ - Added advanced option page
+ - New option: Popup timeout
+ - Restore the hide icons in status / task bar option
+ - Use old weather information if new data is unavailable
+ - Add the debug setting in advanced option page
+ - Major internal / weather update / DB settings change
+
+Version 0.2.3.13 2003/05/30
+ - Fixed searching weather underground station
+ - Few minor changes
+
+Version 0.2.3.12 2003/05/28
+
+Version 0.2.3.11 (Beta) 2003/05/27
+ - Fixed Weather Channel for the FOURTH time
+
+Version 0.2.3.10 2003/05/27
+ - Third fix for Weather Channel.
+ - Note: If v0.2.3.9 works, there is no need to upgrade
+
+Version 0.2.3.9 2003/05/26
+ - Fixed download from Weather Channel
+ - Few minor changes and updates
+
+Version 0.2.3.8 2003/05/25
+ - Removed some unnecessary popup that causes crash and/or confusion
+ - Minor code change in weather update.
+
+Version 0.2.3.7 (Beta) 2003/05/08
+ - Now compile using latest Miranda source code
+
+Version 0.2.3.6 (Beta) 2003/04/15
+
+Version 0.2.3.5 2003/03/16
+ - Fix in "Do not display weather condition as protocol status" option
+ - Fix in maximun temperature for weather channel plugin.
+
+Version 0.2.3.4 2003/03/16
+
+Version 0.2.3.3 (Beta) 2003/03/10
+ - Remove features that are incompatiable with latest version of Miranda
+ - Bug fix on retrieving weather (again!)
+
+Version 0.2.3.2 (Beta) 2003/02/28
+ - Few minor bug fixes
+
+Version 0.2.3.1 (Beta) 2003/02/17
+ - Bug fix in retrieving high and low temperature.
+ - Other minor fixes.
+
+Version 0.2.3.0 2003/02/05
+ - New option: Do not display default condition as protocol status
+ - Support Miranda Installer
+ - Other minor code changes.
+
+Version 0.2.2.11 2003/01/31
+ - Fixed some weather info parsing problems
+
+Version 0.2.2.10 2003/01/26
+ - Fix some minor errors in weather update
+
+Version 0.2.2.9 2003/01/25
+ - Add some warning messages.
+
+Version 0.2.2.8 (Beta) 2003/01/25
+ - Fixed on popup display.
+ - More infinite loop prevention.
+
+Version 0.2.2.7 2003/01/24
+ - Forget to update version number in last release
+
+Version 0.2.2.6 2003/01/24
+ - Popup only when condition changes now work properly.
+ - Minor bug fix in logging
+ - Smaller file size.
+ - Other minor changes.
+
+Version 0.2.2.5 (Beta) 2003/01/23
+ - Fixed weatherch.dll for new website format.
+
+Version 0.2.2.4 (Beta) 2003/01/18
+ - Minor code change
+
+Version 0.2.2.3 2003/01/16
+
+Version 0.2.2.2 2003/01/15
+ - Show popup action selection when menu is opened.
+ - Bug fix: Modified weather station now can update normally.
+
+Version 0.2.2.1 (Beta) 2003/01/12
+ - Bug fix: Opening menu when click on PopUp.
+ - Added link in main menu to the homepage of weathe source.
+ - New protocol icon.
+
+Version 0.2.2.0 (Beta) 2003/01/11
+ - Move pop-up related options to popup option page.
+ - New option: Set popup title
+ - New option: Specify command for popups when mouse is clicked.
+ - Added variable information popup.
+ - Some UI changes.
+ - Added version info.
+ - Some translation string added / changed.
+
+Version 0.2.1.6 (Beta) 2003/01/09
+ - Shorten code in some functions.
+
+Version 0.2.1.5 2003/01/08
+ - Updated weatherch.dll for data retrieval.
+ - Bug fix: Searching new weather station.
+ - Bug fix: Loading default settings.
+ - Few other minor changes.
+
+Version 0.2.1.3 (Beta) 2003/01/07
+ - Minor bug fix.
+
+Version 0.2.1.2 2003/01/04
+ - New option: Overwrite File upon Update.
+ - Update in translation doc.
+
+Version 0.2.1.1 2003/01/03
+ - Better support for multiline popups.
+ - Minor change in codes and readme document.
+
+Version 0.2.1.0 2002/12/31
+ - New option: Override default URL settings for each contact
+ - Display text are no longer case sensitive.
+ - Prevent opening two dialogs at the same time.
+
+Version 0.2.0.5 2002/12/18
+ - Few minor changes and bug fixes
+
+Version 0.2.0.4 (Beta) 2002/12/15
+ - Bug fix: changing status and popups.
+ - Minor change in weather update.
+
+Version 0.2.0.3 (Beta) 2002/12/14
+ - Bug fix: disable popup st startup.
+ - Other minor changes.
+
+Version 0.2.0.2 (Beta) 2002/12/12
+ - Try to make string compatible between each weather source (not tested)
+ - Bug fix: crash when not connected (not tested)
+ - New weather condition in translation string.
+ - Various other minor bug fixes and changes.
+
+Version 0.2.0.1 (Beta) 2002/12/11
+ - Fix in updating weather information in wunderground.dll
+ - Various other minor bug fixes and changes.
+
+Version 0.2.0.0 (Beta) 2002/12/10
+ - Completed wunderground.dll
+ - Bug fix: Update all weather.
+ - Bug fix: Weather update in weatherch.dll
+ - Various other bug fixes and improvements.
+
+Version 0.1.9.5 (Preview) 2002/12/10
+ - Completed weatherch.dll
+ - Weather Underground (wunderground.dll) included - not complete yet.
+ - Bug fix: Default weather station and weather status.
+ - Bug fix: Crash when edit weather station.
+ - Bug fix: Crash when adding new weather station.
+ - Bug fix: Searching for weather station when no contact found.
+ - Various other changes and bug fixes.
+
+Version 0.1.9.0 (Preview) 2002/12/09
+ - Split code into different files for easier modification.
+ - Support for multiple weather protocols (required minimal change + new build)
+ - Minor changes and bug fixes
+
+Version 0.1.5.2 2002/12/09
+ - Bug fix: crash when "Show multiple icons only when statuses differ" enabled
+ - Bug fix: some options not saved properly.
+ - Bug fix: bug fix when adding the first station.
+
+Version 0.1.5.1 2002/12/07
+ - Bug fix in showing notifying messages.
+
+Version 0.1.5.0 2002/12/06
+ - Error detections.
+ - New option: Show errors on popups.
+ - Display default station weather condition as status icon.
+ - Enable / Disable weather update through status.
+ - New weather conditions.
+ - Slight change in adding new weather station.
+ - Fixed tab orders.
+
+Version 0.1.4.9 2002/12/06
+
+Version 0.1.2.0 2002/11/29
+ - Add links to weather maps.
+ - Add option to change Popup text, Log text, and URL links.
+ - New variables: %d, %s, %S
+ - New option: open webpage in new window.
+ - Internal code changes and bug fixes.
+
+Version 0.1.1.1 2002/11/25
+ - Bug fix: Translations
+ - Minor code change and translation updates.
+
+Version 0.1.1.0 2002/11/24
+ - Brief Information template now translable.
+ - Add set to default button for Brief Information display.
+ - UI change in Brief Information dialog.
+ - Add some control over looping.
+ - Set default weather station (currently has no use, but it maybe useful later or by
+ other plugins)
+ - Bug fix: Searching for station using city names.
+ - Bug fix: Assigning icon to weather conditions.
+ - Fixed tab order.
+ - Other minor UI and code changes (hope this will fix some bugs).
+
+Version 0.1.0.0 2002/11/23
+ - Now add weather station via Find/Add Contact dialog.
+ - Able to search for station using city name.
+ - Customize string for showing brief information.
+ - New option: Log weather station in history.
+ - New option: Disable popup for specific weather station.
+ - Bug fix: Update after editing weather station.
+ - Bug fix: Now correctly update using the new webpage format.
+ - Updated translation string (both dll and weather condition).
+ - Updated debug output method.
+ - Smaller file size.
+ - Re-organized readme and language files.
+ - Various other minor bug fixes and improvement.
+
+Version 0.0.8.5 2002/11/22
+ - Bug fix: Hiding icon in task bar.
+ - New weather condition added (both dll and langpack).
+
+Version 0.0.8.4 2002/11/22
+ - Bug fix: Update issues.
+ - Updated translation string.
+
+Version 0.0.8.3 2002/11/21
+ - Interface change in option screen.
+ - Prevent displaying invalid data.
+ - Minor code change for update weather condition.
+ - Added missing translation string.
+
+Version 0.0.8.2 2002/11/20
+ - Bug fix: Translation of weather condition on contact list
+ - Bug fix: Temperature conversion.
+ - Minor change in option screens and edit setting screen.
+
+Version 0.0.8.1 2002/11/19
+ - Bug fix: Fixed temperature display.
+ - Fixed tab orders.
+
+Version 0.0.8.0 (Beta) 2002/11/19
+ - Retrieve high and low temperature forecast for the current day.
+ - Search and display temperature from alternative source when it is unknown.
+ (For the people who have N/A display beside their city, this ver should work now)
+ - More customizable contact list name display.
+ - Bug fix: C and F conversion when temperature < 0 degree C.
+ - Bug fix: Some update problems.
+ - Language pack updated: more weather conditions.
+
+Version 0.0.7.5 (Beta) 2002/11/18
+ - Right click -> Update Weather will no longer freeze Miranda.
+ - New option: Disable popup if condition doesn't change.
+ - Bug fix: prevent manual update when auto-update is in progress.
+ - Added missing translation string.
+
+Version 0.0.7.0 (Beta) 2002/11/17
+ - Updating weather will no longer freeze up miranda.
+ - Add option to disable popup.
+ - Bug fix: Now saves the degree sign in option.
+ - Bug fix: Logging weather condition and view log command.
+ - Bug fix: Update weather condition after modifying weather station.
+ - Added missing translation string.
+ - Various other improvements.
+
+Version 0.0.6.1 (Beta) 2002/11/16
+ - Bug fix: Update after modifying weather station.
+ - Bug fix: No cache (slower but more accurate info).
+
+Version 0.0.6.0 (Beta) 2002/11/16
+ - The plugin has it's own popup (not using NewStatusNotify's anymore)
+ - Add option to hide icon in status bar and status menu (expreimental release).
+ - Various minor changes.
+
+Version 0.0.5.1 (Alpha) 2002/11/16
+
+Version 0.0.5.0 (Alpha) 2002/11/15
+
+Version 0.0.4.3 (Beta) 2002/11/15
+ - Added option to disable main menu item.
+ - Various minor improvements.
+
+Version 0.0.4.2 (Beta) 2002/11/15
+ - Bug fix: translation strings.
+ - Bug fix: no longer open miranda directory when no log is found.
+
+Version 0.0.4.1 (Beta) 2002/11/15
+ - Bug fix on retrieving weather information.
+ - Removed debug string that was accidentally built in the last release. (see above)
+
+Version 0.0.4.0 (Beta) 2002/11/14
+ - Retrieve weather information no longer require temp files.
+ - Able to modify weather station settings.
+ - Add link to log file in contact menu.
+ - Add an option for degree sign (I can't think of a better way to do this).
+ - Relocate main menu item.
+ - Bug fix: DB: Attempt to get wrong type of value, word.
+ - Various other minor bug fixes.
+
+Version 0.0.3.7 (Beta) 2002/11/14
+ - Bug fix: degree signs (sorry for the copy-and-paste error).
+ - Move the temporary file to miranda directory.
+
+Version 0.0.3.6 (Beta) 2002/11/14
+ - Bug fix: degree signs (changable using language pack)
+ - Bug fix: DB: Attempt to get wrong type of value, word.
+ - More weather condition are now able to display with correct icon.
+
+Version 0.0.3.5 (Beta) 2002/11/13
+ - Initial public beta release.
+
+Version 0.0.3.1 (Beta) 2002/11/13
+
+Version 0.0.3.0 (Beta) 2002/11/12
+ - Disable auto update option.
+ - Logging weather condition.
+ - New option for displaying weather conditions on contact list.
+ - Bug fix: some tarnslation strings.
+ - Bug fix: switching between English and metric units.
+ - Bug fix: time of update.
+
+Version 0.0.2.1 (Preview) 2002/11/12
+ - Bug fix: F to C conversion.
+ - Bug fix: Display complete forcast page in correct unit system.
+
+Version 0.0.2.0 (Preview) 2002/11/12
+ - Display temperature on contact list.
+ - Translable strings.
+ - Display brief weather information as message box.
+ - Faster information download.
+ - Various other fixes.
+
+Version 0.0.1.2 (Pre-Alpha) 2002/11/12
+
+Version 0.0.1.1 (Pre-Alpha) 2002/11/11
+ - Faster and more reliable download.
+ - Various bug fixes.
+
+Version 0.0.1.0 (Pre-Alpha) 2002/11/11
+ - Retrieve temperature and update time.
+
+Version 0.0.0.3 (Pre-Alpha) 2002/11/11
+ - Bug fix in weather condition and icons.
+ - Various other bug fixes.
+
+Version 0.0.0.2 (Pre-Alpha) 2002/11/11
+ - Set the name for city, retrieve weather condition.
+
+Version 0.0.0.1 (Pre-Alpha) 2002/11/10
+ - Initial build
diff --git a/plugins/Weather/docs/weather-readme.html b/plugins/Weather/docs/weather-readme.html new file mode 100644 index 0000000000..ff81561171 --- /dev/null +++ b/plugins/Weather/docs/weather-readme.html @@ -0,0 +1,230 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>Read Me for Weather Protocol</title>
+ <script language="javascript" type="text/javascript">
+function link(num){document.location="http://addons.miranda-im.org/details.php?action=viewfile&id="+num;}
+ </script>
+ </head>
+ <body>
+ <h2>Read Me for Weather Protocol</h2>
+ <hr/>
+ <pre>
+<a name="top"><font color="red">
+<b>*** IMPORTANT NOTICE ***</b>
+Be cautious when choosing the "special status" selection for selecting the status
+assign to contact whose current condition is unavailable. This feature is not
+officially support by Miranda and may cause a lot of plugins to crash. Be sure to
+backup your profile before you try this feature.</font>
+
+</a>
+</pre>
+<hr/>
+<pre>
+
+<b><u>File Content</u></b>
+
+<a href="#fea">Features</a>
+<a href="#fi">Files Included</a>
+<a href="#sr">System Requirement</a>
+<a href="#ins">Installation</a>
+<a href="#faq">Frequently Asked Questions</a>
+<a href="#lic">License</a>
+
+</pre>
+<hr/>
+<pre>
+
+<a name="fea"><b><u>Features</u></b>
+
+ - Retrieve weather information and display them on your Miranda contact list.
+ - Provide a contact information page for viewing the current weather conditions.
+ - Display PopUp when information is retrieved.
+ - Log weather conditions to a file or in history.
+ - Quick links for viewing complete forecast and weather maps.
+
+
+</a><a name="fi"><b><u>Files Included</u></b>
+
+ - plugins\weather.dll
+ The core to the weather plugin. Required component
+ - </a><a href="langpack_defweather.txt">langpack_defweather.txt</a> (stored in the documentation folder by default)
+ Langpack for weather icon assignment, containing documentation for how to use
+ - <a href="weather-readme.html">plugins\weather-doc\weather-readme.html</a>
+ Documentation and FAQ for Weather Protocol (this file).
+ - <a href="sample_ini.ini">plugins\weather-doc\sample_ini.ini</a>
+ Documentation of the format of the weather INI file.
+ - <a href="weather-translation.txt">plugins\weather-doc\weather-translation.txt</a>
+ A file that contains a translation of hopefully all string used in Weather Protocol.
+
+
+<a name="sr"><b><u>System Requirement</u></b>
+
+ - </a><a href=
+"http://www.miranda-im.org">Miranda IM</a> (v0.7.3.0 or later)
+ - <a href="http://addons.miranda-im.org/index.php?action=display&id=78">Weather INI file</a>
+ - Weather icons (Optional)
+ Numerous choices available in <a href=
+"http://addons.miranda-im.org/index.php?action=display&id=35">icon downloads</a>.
+ - <a href=
+"javascript:link(2759)">YAPP plugin</a> by sje or <a href=
+"javascript:link(3400)">PopUp Plus plugin</a> by nullbie (Optional)
+
+
+<a name="ins"><b><u>Installation</u></b>
+ For installation of weather protocol, it is recommended for installing it using Miranda
+ Installer. For manual installation, please following these steps:
+
+ 1. Copy weather.dll into plugins directory.
+ 2. Get the ini's from file listing and place them into plugin\weather directory.
+ 3. If you want external file for status icon selection, copy the content of
+ langpack_defweather.txt into your language pack and (optionally) enable
+ "Disable internal icon selection" from the option page.
+ 4. In icon option, customize the weather icon or use the default one in the dll
+
+ IMPORTANT UPGRADE NOTICE
+ Due to the changes made in this version, Weather 0.3.x is not compatible with older
+ releases (v0.2.x). Therefore, you should delete your weather contacts before
+ upgrading to this new version.
+
+
+</a><a name="faq"><b><u>Frequently Asked Question</u></b>
+
+<i><u>Setting Up Weather Protocol</u></i>
+For installation, follow the steps describe in the </a><a href=
+"#ins">installation</a> section of the readme.
+
+<b>Q1-1. Weather Protocol does not do anything after I installed it, and it
+ cannot go online.</b>
+A. You need to add a new station before you can go online.
+
+<b>Q1-2. How do I add new stations?</b>
+A. Use the find/add dialog box. You can either search for station ID (see the readme
+ for the ini file to see how it can be obtained) or search by city name by entering
+ the name in either one of the Nickname, Firstname, or Lastname field.
+
+<b>Q1-3. I can't find my station! Any help?</b>
+A. Make sure you have installed the plugin and ini file correctly. At least one INI
+ file must exist in the plugins\weather directory in order for the plugin to funciton
+ properly. For more information, click <a href=
+"#ins">here</a>.
+
+<b>Q1-4. I have installed the plugin properly, and it still doesn't work. I have
+ noticed that there is no traffic generated by the plugin.</b>
+A. Check you proxy setting, some proxy does not work properly under Miranda IM 0.3.3.0.
+ If your proxy is having problem connecting, you need to upgrade to Miranda IM 0.3.3.1
+ or try the <a href="http://www.miranda-im.org/development/">nightly builds</a>
+ (Note: They are experimental builds!)
+ Also, if you are using <a href="javascript:link(844)">traffic counter</a> plugin,
+ please make sure that you are using the latest version. The old version stops Weather
+ and some other plugin from working.
+
+<i><u>INI and Development Related Questions</u></i>
+
+<b>Q2-1. What are those INI files for?</b>
+A. The INI files contain information for downloading and parsing weather information
+ from a particular weather site. At least one INI file must exist in order for the
+ plugin to work. For a list of available INI's, click <a href="#top">here</a>.
+
+<b>Q2-2. Can I install or modify the INI files without restarting Miranda?</b>
+A. Yes, choose: M (main menu) -> Weather -> Reload Weather Data
+
+<b>Q2-3. I want to retrieve weather information from a different source than those
+ that are currently available. How can this be done?</b>
+A. You can write your own INI file. For more information, click <a href="sample_ini.ini">here</a>.
+
+<b>Q2-4. I wrote/downloaded an ini file that retrieve weather condition in a
+ language that weather protocol doesn't seems to reconize and always
+ display N/A. What should I do?</b>
+A. You can use translation string for assigning icons. For more information, click <a href="langpack_defweather.txt">here</a>.
+
+<b>Q2-5. How does weather assign status icons for each status?</b>
+A. Online = Sunny
+ Away = Partly Cloudy
+ NA = Cloudy
+ Occupied = Rain
+ DND = Rain Shower
+ Free for Chat = Snow / Wintery Conditions
+ Invisible = Lightning / Thunderstorm
+ On the Phone = Snow Shower
+ Out to Lunch = Fog / Haze
+ Offline = No Data Available
+
+<u><i>Obtaining Weather Data</i></u>
+
+<b>Q3-1. Does weather protocol retreve weather forecasts?</b>
+A. Support of this feature depend on the ini file you use. If it is supported, the most
+ likely variable you use for it is %[Forecast Day #] or %[FD#] where # is the day you
+ want the forecast for. See the readme supplied in the INI file package for more
+ information.
+
+<b>Q3-2. How long should the time between update be?</b>
+A. This depend on the update interval on the website. Generally, this field should set
+ to a value between 10 to 30 minutes. If the value is too small, a lot of traffics
+ will be generated by the protocol.
+
+<b>Q3-3. How can I temporary disable weather procotol?</b>
+A. Switch the weather status to OFFLINE, but this will not work if you have "Do not
+ display weather condition as protocol status" option enabled. To enable the
+ protocol again, switch it to a status other than OFFLINE. Automatic update of
+ weather condition can be disabled through menu and option page.
+
+<b>Q3-4. Why are the name of some weather contacts italic on my contact?</b>
+A. There are weather alerts issued for those cities. To see the alert title, use the
+ %[Alert] variable. You can disable this function in option page.
+
+<b>Q3-5. There are some status that the weather plugin doesn't seems to
+ reconize and always shows as N/A on the contact list. What can I do?</b>
+A. If the source of weather info is in a language other than English, please check the
+ INI package for instruction of how to install language pack. If the source is in
+ English, notify me.
+
+<u><i>Customizing the Weather Protocol</i></u>
+
+<b>Q4-1. Can I hide Weather from status bar and protocol menu?</b>
+A. Go to Options->Plugins->Weather, enable "Hide Weather in status bar and status menu".
+
+<b>Q4-2. I can't find Weather in the icon option drop-down list. How can I change
+ weather icons?</b>
+A. Weather icon cannot be changed if "Hide Weather in status bar and status menu" is
+ enabled. To change icons, disable the option (see Q4-1), make your change, then re-
+ enable it.
+
+<b>Q4-3. I can't find the options for changing display text.</b>
+A. Go to Options->Plugins->Weather, then click on the icon beside "Change display texts"
+
+<b>Q4-4. How can I change the display name of my city?</b>
+A. Right-click on the city and select "Edit Settings". Change the field "City name"
+ to the new display name.
+
+<b>Q4-5. How can I change the default station?</b>
+A. Use the Edit Settings dialog (See A4-4). Note that only 1 station can be default.
+
+<b>Q4-6. What is the %[..] variable for?</b>
+A. They are the custom variables. Replace the ".." with a setting name that can be
+ found in \Weather in the database. For more information about the availability of
+ the settings, use <a href=
+"javascript:link(2957)">Database Editor</a> or refer to the readme of the ini file.
+
+<b>Q4-7. What are the "Extra Text" for?</b>
+A. The field has no use internally. However, it can be useful for some other plugin
+ to obtain a weather information string that is already parsed.
+
+<b>Q4-8. I want weather protocol to have the same status as the other protocols.
+ Is such option available?</b>
+A.
+Disable the option "Use weather condition as protocol status", then you will be
+ able to change the status freely.
+
+<b>Q4-9. How do I create avatars for each weather condition?</b>
+A. Put the following files into the Miranda\Plugins\Weather folder:
+ Light.png, Fog.png, SShower.png, Snow.png, RShower.png, Rain.png
+ PCloudy.png, Cloudy.png, Sunny.png, NA.png
+
+
+<a name="lic">License
+
+This plugin is released under </a><a href="http://www.gnu.org/licenses/gpl.txt">GPL</a>.
+</pre>
+ </body>
+</html>
diff --git a/plugins/Weather/proto_weather/proto_weather_10.vcxproj b/plugins/Weather/proto_weather/proto_weather_10.vcxproj new file mode 100644 index 0000000000..8187912e95 --- /dev/null +++ b/plugins/Weather/proto_weather/proto_weather_10.vcxproj @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>Proto_Weather</ProjectName>
+ <ProjectGuid>{B2F4BA6C-1BD6-4A50-A706-DCBC6A5D439B}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Link>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/Weather/proto_weather/proto_weather_10.vcxproj.filters b/plugins/Weather/proto_weather/proto_weather_10.vcxproj.filters new file mode 100644 index 0000000000..27e90fab59 --- /dev/null +++ b/plugins/Weather/proto_weather/proto_weather_10.vcxproj.filters @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/Weather/proto_weather/res/Cloud.ico b/plugins/Weather/proto_weather/res/Cloud.ico Binary files differnew file mode 100644 index 0000000000..2edb539dcb --- /dev/null +++ b/plugins/Weather/proto_weather/res/Cloud.ico diff --git a/plugins/Weather/proto_weather/res/FOG.ico b/plugins/Weather/proto_weather/res/FOG.ico Binary files differnew file mode 100644 index 0000000000..fbd81b9a03 --- /dev/null +++ b/plugins/Weather/proto_weather/res/FOG.ico diff --git a/plugins/Weather/proto_weather/res/LIGHT.ico b/plugins/Weather/proto_weather/res/LIGHT.ico Binary files differnew file mode 100644 index 0000000000..d266094fbe --- /dev/null +++ b/plugins/Weather/proto_weather/res/LIGHT.ico diff --git a/plugins/Weather/proto_weather/res/NA.ico b/plugins/Weather/proto_weather/res/NA.ico Binary files differnew file mode 100644 index 0000000000..3e4a3aa324 --- /dev/null +++ b/plugins/Weather/proto_weather/res/NA.ico diff --git a/plugins/Weather/proto_weather/res/PCLOUDY.ico b/plugins/Weather/proto_weather/res/PCLOUDY.ico Binary files differnew file mode 100644 index 0000000000..be3d0c88bd --- /dev/null +++ b/plugins/Weather/proto_weather/res/PCLOUDY.ico diff --git a/plugins/Weather/proto_weather/res/RAIN.ico b/plugins/Weather/proto_weather/res/RAIN.ico Binary files differnew file mode 100644 index 0000000000..4b65fb6714 --- /dev/null +++ b/plugins/Weather/proto_weather/res/RAIN.ico diff --git a/plugins/Weather/proto_weather/res/RSHOWER.ico b/plugins/Weather/proto_weather/res/RSHOWER.ico Binary files differnew file mode 100644 index 0000000000..442552e155 --- /dev/null +++ b/plugins/Weather/proto_weather/res/RSHOWER.ico diff --git a/plugins/Weather/proto_weather/res/SNOW.ico b/plugins/Weather/proto_weather/res/SNOW.ico Binary files differnew file mode 100644 index 0000000000..1a482c3bc8 --- /dev/null +++ b/plugins/Weather/proto_weather/res/SNOW.ico diff --git a/plugins/Weather/proto_weather/res/SSHOWER.ico b/plugins/Weather/proto_weather/res/SSHOWER.ico Binary files differnew file mode 100644 index 0000000000..0bd2264413 --- /dev/null +++ b/plugins/Weather/proto_weather/res/SSHOWER.ico diff --git a/plugins/Weather/proto_weather/res/SUN.ico b/plugins/Weather/proto_weather/res/SUN.ico Binary files differnew file mode 100644 index 0000000000..b37fc6ad2a --- /dev/null +++ b/plugins/Weather/proto_weather/res/SUN.ico diff --git a/plugins/Weather/proto_weather/res/resource.rc b/plugins/Weather/proto_weather/res/resource.rc new file mode 100644 index 0000000000..b059c0696d --- /dev/null +++ b/plugins/Weather/proto_weather/res/resource.rc @@ -0,0 +1,41 @@ +//Microsoft Developer Studio generated resource script.
+//
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+104 ICON "SUN.ico"
+105 ICON "NA.ico"
+128 ICON "PCLOUDY.ico"
+129 ICON "RSHOWER.ico"
+130 ICON "LIGHT.ico"
+131 ICON "RAIN.ico"
+158 ICON "SNOW.ico"
+159 ICON "CLOUD.ico"
+1002 ICON "SSHOWER.ico"
+1003 ICON "FOG.ico"
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
\ No newline at end of file diff --git a/plugins/Weather/res/brief.ico b/plugins/Weather/res/brief.ico Binary files differnew file mode 100644 index 0000000000..717ef66669 --- /dev/null +++ b/plugins/Weather/res/brief.ico diff --git a/plugins/Weather/res/disabled.ico b/plugins/Weather/res/disabled.ico Binary files differnew file mode 100644 index 0000000000..ed6e27b691 --- /dev/null +++ b/plugins/Weather/res/disabled.ico diff --git a/plugins/Weather/res/edit.ico b/plugins/Weather/res/edit.ico Binary files differnew file mode 100644 index 0000000000..f59dc79b9c --- /dev/null +++ b/plugins/Weather/res/edit.ico diff --git a/plugins/Weather/res/icon.ico b/plugins/Weather/res/icon.ico Binary files differnew file mode 100644 index 0000000000..be3d0c88bd --- /dev/null +++ b/plugins/Weather/res/icon.ico diff --git a/plugins/Weather/res/info.ico b/plugins/Weather/res/info.ico Binary files differnew file mode 100644 index 0000000000..97d34dc4a5 --- /dev/null +++ b/plugins/Weather/res/info.ico diff --git a/plugins/Weather/res/infologo.ico b/plugins/Weather/res/infologo.ico Binary files differnew file mode 100644 index 0000000000..cf22ece1b1 --- /dev/null +++ b/plugins/Weather/res/infologo.ico diff --git a/plugins/Weather/res/log.ico b/plugins/Weather/res/log.ico Binary files differnew file mode 100644 index 0000000000..86139d5e23 --- /dev/null +++ b/plugins/Weather/res/log.ico diff --git a/plugins/Weather/res/map.ico b/plugins/Weather/res/map.ico Binary files differnew file mode 100644 index 0000000000..8c4c70742d --- /dev/null +++ b/plugins/Weather/res/map.ico diff --git a/plugins/Weather/res/more.ico b/plugins/Weather/res/more.ico Binary files differnew file mode 100644 index 0000000000..47e13df383 --- /dev/null +++ b/plugins/Weather/res/more.ico diff --git a/plugins/Weather/res/popup.ico b/plugins/Weather/res/popup.ico Binary files differnew file mode 100644 index 0000000000..7e0301b42f --- /dev/null +++ b/plugins/Weather/res/popup.ico diff --git a/plugins/Weather/res/popup_no.ico b/plugins/Weather/res/popup_no.ico Binary files differnew file mode 100644 index 0000000000..08de082ec2 --- /dev/null +++ b/plugins/Weather/res/popup_no.ico diff --git a/plugins/Weather/res/reload.ico b/plugins/Weather/res/reload.ico Binary files differnew file mode 100644 index 0000000000..3c81203c03 --- /dev/null +++ b/plugins/Weather/res/reload.ico diff --git a/plugins/Weather/res/resource.rc b/plugins/Weather/res/resource.rc new file mode 100644 index 0000000000..f8dd82df30 --- /dev/null +++ b/plugins/Weather/res/resource.rc @@ -0,0 +1,467 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "..\src\resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include <windows.h>
+#include "..\src\version.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_BRIEF DIALOGEX 0, 0, 245, 231
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+EXSTYLE WS_EX_WINDOWEDGE | WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "",IDC_HEADERBAR,"MHeaderbarCtrl",0x0,0,0,245,25
+ CONTROL "",IDC_MTEXT,"RichEdit20W",ES_MULTILINE | ES_READONLY | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,0,25,244,180,WS_EX_STATICEDGE
+ CONTROL "List1",IDC_DATALIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SORTASCENDING | WS_TABSTOP,0,25,244,180,WS_EX_STATICEDGE
+ PUSHBUTTON "Update",IDC_MUPDATE,10,213,48,13
+ PUSHBUTTON "Brief Info",IDC_MTOGGLE,79,213,48,13
+ PUSHBUTTON "Webpage",IDC_MWEBPAGE,132,213,48,13
+ DEFPUSHBUTTON "Close",IDCANCEL,184,213,48,13
+END
+
+IDD_OPTIONS DIALOGEX 0, 0, 306, 222
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ GROUPBOX "Options",IDC_STATIC,3,0,299,70,WS_GROUP
+ CONTROL "Update weather information on startup",IDC_STARTUPUPD,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,10,219,8
+ CONTROL "Update weather information every",IDC_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,19,206,8
+ EDITTEXT IDC_UPDATETIME,231,15,21,12,ES_AUTOHSCROLL | ES_NUMBER | NOT WS_BORDER,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
+ LTEXT "minutes",IDC_STATIC,257,16,43,9
+ CONTROL "Consider weather info updated only when condition and temperature are changed",IDC_UPDCONDCHG,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,28,282,8
+ CONTROL "Remove old data when updating",IDC_REMOVEOLD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,38,282,8
+ CONTROL "Make the contact italic when weather alert is issued",IDC_MAKEI,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,48,282,8
+ CONTROL "Open URLs in new browser window",IDC_NEWWIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,57,287,8
+ GROUPBOX "Modes",IDC_STATIC,3,70,300,37
+ CONTROL "Use weather condition as protocol status",IDC_PROTOCOND,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,81,278,8
+ CONTROL "Avatar only mode",IDC_DISCONDICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,91,278,8
+ GROUPBOX "Units",IDC_STATIC,3,107,299,80,WS_GROUP
+ LTEXT "Temperature",IDC_STATIC,8,116,53,8
+ CONTROL "Celsius",IDC_T1,"Button",BS_AUTORADIOBUTTON,65,116,40,8
+ CONTROL "Fahrenheit",IDC_T2,"Button",BS_AUTORADIOBUTTON,120,116,47,8
+ LTEXT "Degree sign:",IDC_STATIC,227,116,55,8
+ EDITTEXT IDC_DEGREE,283,116,13,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
+ LTEXT "Wind",IDC_STATIC,8,125,53,8
+ CONTROL "km/h",IDC_W1,"Button",BS_AUTORADIOBUTTON,65,125,34,8
+ CONTROL "m/s",IDC_W2,"Button",BS_AUTORADIOBUTTON,120,125,34,8
+ CONTROL "mph",IDC_W3,"Button",BS_AUTORADIOBUTTON,176,125,34,8
+ CONTROL "knots",IDC_W4,"Button",BS_AUTORADIOBUTTON,232,125,49,8
+ LTEXT "Visibility",IDC_STATIC,8,134,53,8
+ CONTROL "km",IDC_V1,"Button",BS_AUTORADIOBUTTON,65,134,34,8
+ CONTROL "miles",IDC_V2,"Button",BS_AUTORADIOBUTTON,120,134,34,8
+ LTEXT "Pressure",IDC_STATIC,8,143,53,8
+ CONTROL "kPa",IDC_P1,"Button",BS_AUTORADIOBUTTON,65,143,38,8
+ CONTROL "mb (hPa)",IDC_P2,"Button",BS_AUTORADIOBUTTON,120,143,56,8
+ CONTROL "inches",IDC_P3,"Button",BS_AUTORADIOBUTTON,176,143,38,8
+ CONTROL "mm Hg (torr)",IDC_P4,"Button",BS_AUTORADIOBUTTON,232,143,62,8
+ LTEXT "Day/Month",IDC_STATIC,8,153,53,8
+ CONTROL "No change",IDC_D1,"Button",BS_AUTORADIOBUTTON,65,153,52,8
+ CONTROL "2 chars",IDC_D2,"Button",BS_AUTORADIOBUTTON,120,153,56,8
+ CONTROL "3 chars",IDC_D3,"Button",BS_AUTORADIOBUTTON,176,153,56,8
+ LTEXT "Elevation",IDC_STATIC,8,163,53,8
+ CONTROL "ft",IDC_E1,"Button",BS_AUTORADIOBUTTON,65,163,34,8
+ CONTROL "m",IDC_E2,"Button",BS_AUTORADIOBUTTON,120,163,34,8
+ CONTROL "Do not append units to values",IDC_DONOTAPPUNITS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,174,144,8
+ CONTROL "Do not display fractional values",IDC_NOFRAC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,155,174,146,8
+ GROUPBOX "Frame",IDC_STATIC,3,187,300,29
+ EDITTEXT IDC_AVATARSIZE,11,197,29,14,ES_AUTOHSCROLL | ES_NUMBER | NOT WS_BORDER,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
+ CONTROL "",IDC_AVATARSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,28,197,11,14
+ LTEXT "Avatar size",IDC_STATIC,42,200,85,9
+END
+
+IDD_EDIT DIALOGEX 0, 0, 241, 226
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Edit Weather Station"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ GROUPBOX "Weather Station",IDC_STATIC,5,7,231,46
+ LTEXT "City name",IDC_STATIC,12,21,57,8,SS_CENTERIMAGE
+ EDITTEXT IDC_NAME,69,19,146,12,ES_AUTOHSCROLL
+ LTEXT "ID",IDC_STATIC,12,37,57,8,SS_CENTERIMAGE
+ EDITTEXT IDC_ID,69,35,146,12,ES_AUTOHSCROLL
+ GROUPBOX "Log Information",IDC_STATIC,5,55,231,53
+ CONTROL "Use internal history",IDC_Internal,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,68,218,8
+ CONTROL "Use external file",IDC_External,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,80,98,8
+ CONTROL "Overwrite file upon update",IDC_Overwrite,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,119,80,111,8
+ LTEXT "Path:",IDC_STATIC,25,93,37,8,SS_CENTERIMAGE
+ EDITTEXT IDC_LOG,69,91,146,12,ES_AUTOHSCROLL | ES_READONLY
+ CONTROL "6",IDC_BROWSE,"MButtonClass",WS_TABSTOP,217,91,13,12,WS_EX_NOACTIVATE | 0x10000000L
+ GROUPBOX "Link Settings",IDC_STATIC,5,110,231,44
+ LTEXT "More Info URL",IDC_STATIC,12,123,57,8
+ EDITTEXT IDC_IURL,69,121,131,12,ES_AUTOHSCROLL
+ CONTROL "6",IDC_VIEW1,"MButtonClass",WS_TABSTOP,202,121,13,12,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "6",IDC_RESET1,"MButtonClass",WS_TABSTOP,217,121,13,12,WS_EX_NOACTIVATE | 0x10000000L
+ LTEXT "Weather Map",IDC_STATIC,12,138,57,8
+ EDITTEXT IDC_MURL,69,137,131,12,ES_AUTOHSCROLL
+ CONTROL "6",IDC_VIEW2,"MButtonClass",WS_TABSTOP,202,137,13,12,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "6",IDC_RESET2,"MButtonClass",WS_TABSTOP,217,137,13,12,WS_EX_NOACTIVATE | 0x10000000L
+ GROUPBOX "Other Options",IDC_STATIC,5,157,231,46
+ CONTROL "Set as default station",IDC_DEFA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,168,218,8
+ CONTROL "Disable automatic update for this station",IDC_DAutoUpdate,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,179,218,8
+ CONTROL "Disable PopUp for this station",IDC_DPop,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,190,218,8
+ PUSHBUTTON "Change",IDC_CHANGE,57,207,46,14
+ DEFPUSHBUTTON "Cancel",IDCANCEL,136,207,46,14
+ CONTROL "",IDC_SVCINFO,"MButtonClass",WS_TABSTOP,217,35,13,12,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "",IDC_GETNAME,"MButtonClass",WS_TABSTOP,217,19,13,12,WS_EX_NOACTIVATE | 0x10000000L
+END
+
+IDD_POPUP DIALOGEX 0, 0, 312, 182
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ GROUPBOX "PopUp Options",IDC_STATIC,6,5,156,54
+ CONTROL "Enable popups",IDC_E,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,15,15,143,9
+ CONTROL "Popup only when condition changes",IDC_CH,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,15,44,140,10
+ GROUPBOX "Colours",IDC_STATIC,168,5,139,54
+ CONTROL "",IDC_BGCOLOUR,"ColourPicker",WS_TABSTOP,177,16,39,11
+ LTEXT "Background colour",IDC_STATIC,223,18,78,8,SS_CENTERIMAGE
+ CONTROL "",IDC_TEXTCOLOUR,"ColourPicker",WS_TABSTOP,177,30,39,11
+ LTEXT "Text colour",IDC_STATIC,223,31,80,8,SS_CENTERIMAGE
+ CONTROL "Use Windows colours",IDC_USEWINCOLORS,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,177,43,125,13
+ GROUPBOX "Popup Actions",IDC_STATIC,6,63,155,46
+ LTEXT "Left Click",IDC_STATIC,15,77,40,8
+ CONTROL "",IDC_LeftClick,"MButtonClass",WS_TABSTOP,59,76,95,9,WS_EX_NOACTIVATE | 0x10000000L
+ LTEXT "Right Click",IDC_STATIC,15,93,42,8
+ CONTROL "",IDC_RightClick,"MButtonClass",WS_TABSTOP,59,92,95,9,WS_EX_NOACTIVATE | 0x10000000L
+ GROUPBOX "Popup Delay",IDC_STATIC,167,63,141,46
+ CONTROL "Delay",IDC_PD3,"Button",BS_AUTORADIOBUTTON,177,74,53,8
+ EDITTEXT IDC_DELAY,233,73,36,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_BORDER,WS_EX_STATICEDGE
+ LTEXT "seconds",IDC_STATIC,272,73,34,10
+ CONTROL "From PopUp plugin",IDC_PD1,"Button",BS_AUTORADIOBUTTON,177,85,110,8
+ CONTROL "Permanent",IDC_PD2,"Button",BS_AUTORADIOBUTTON,177,96,110,8
+ GROUPBOX "Popup Text",IDC_STATIC,6,112,302,66
+ LTEXT "Popup Title",IDC_STATIC,15,127,56,9
+ EDITTEXT IDC_PTitle,74,124,163,12,ES_AUTOHSCROLL
+ LTEXT "Popup Text",IDC_STATIC,15,142,55,9
+ EDITTEXT IDC_PText,73,140,164,31,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
+ CONTROL "Variables",IDC_VAR3,"MButtonClass",WS_TABSTOP,244,124,47,12,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "Default",IDC_PDEF,"MButtonClass",WS_TABSTOP,244,141,47,12,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "Preview",IDC_PREVIEW,"MButtonClass",WS_TABSTOP,244,158,47,12,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "Updates",IDC_POP1,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,29,24,64,9
+ CONTROL "Alerts",IDC_POP2,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,29,34,64,9
+ CONTROL "Errors",IDC_W,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,97,24,54,9
+END
+
+IDD_TEXTOPT DIALOGEX 0, 0, 309, 228
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "Contact List",IDC_TM1,"MButtonClass",WS_TABSTOP | 0x100,2,9,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+ EDITTEXT IDC_CTEXT,80,8,124,12,ES_AUTOHSCROLL
+ CONTROL "Brief Info Title",IDC_TM2,"MButtonClass",WS_TABSTOP,2,41,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+ EDITTEXT IDC_BTITLE,80,40,124,12,ES_AUTOHSCROLL
+ CONTROL "Brief Info",IDC_TM3,"MButtonClass",WS_TABSTOP,2,55,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+ EDITTEXT IDC_BTEXT,80,54,124,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
+ CONTROL "Note Text",IDC_TM4,"MButtonClass",WS_TABSTOP,2,101,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+ EDITTEXT IDC_NTEXT,80,100,124,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
+ CONTROL "Extra Text",IDC_TM5,"MButtonClass",WS_TABSTOP,2,147,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+ EDITTEXT IDC_XTEXT,80,146,124,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
+ CONTROL "External Log",IDC_TM6,"MButtonClass",WS_TABSTOP,2,193,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+ EDITTEXT IDC_ETEXT,80,192,124,12,ES_AUTOHSCROLL
+ CONTROL "History Log",IDC_TM7,"MButtonClass",WS_TABSTOP,2,208,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+ EDITTEXT IDC_HTEXT,80,207,124,12,ES_AUTOHSCROLL
+ GROUPBOX "Variable List",IDC_STATIC,206,4,99,198
+ LTEXT "",IDC_VARLIST,213,15,86,158
+ CONTROL "More Variables",IDC_MORE,"MButtonClass",WS_TABSTOP,214,188,76,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "Reset",IDC_RESET,"MButtonClass",WS_TABSTOP,222,208,61,12,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+ EDITTEXT IDC_BTITLE2,80,24,124,12,ES_AUTOHSCROLL
+ CONTROL "Status Message",IDC_TM8,"MButtonClass",WS_TABSTOP | 0x100,2,25,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+END
+
+IDD_USERINFO DIALOGEX 0, 0, 222, 132
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ ICON "",IDC_INFOICON,16,15,20,20,SS_CENTERIMAGE
+ LTEXT "",IDC_INFO1,12,8,193,10
+ LTEXT "Sunset",IDC_STATIC,112,58,54,8
+ LTEXT "Feel-like",IDC_STATIC,12,46,39,8
+ LTEXT "Today's Low",IDC_STATIC,112,82,54,8
+ LTEXT "Wind",IDC_STATIC,12,70,39,8
+ LTEXT "Today's High",IDC_STATIC,112,70,54,8
+ LTEXT "Sunrise",IDC_STATIC,112,46,54,8
+ LTEXT "",IDC_INFO11,12,121,195,9
+ LTEXT "Dewpoint",IDC_STATIC,12,94,39,8
+ LTEXT "Pressure",IDC_STATIC,12,58,39,8
+ GROUPBOX "",IDC_STATIC,4,36,211,84
+ GROUPBOX "",IDC_STATIC,4,1,211,35
+ EDITTEXT IDC_INFO2,42,20,165,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_INFO3,51,46,57,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_INFO4,51,58,57,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_INFO5,51,70,56,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_INFO6,51,94,56,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_INFO7,166,46,41,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_INFO8,166,58,41,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_INFO9,166,70,41,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ EDITTEXT IDC_INFO10,166,82,41,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ LTEXT "Humidity",IDC_STATIC,12,82,39,8
+ EDITTEXT IDC_INFO12,51,82,56,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ LTEXT "Visibility",IDC_STATIC,12,106,39,8
+ EDITTEXT IDC_INFO13,51,106,56,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ CONTROL "More...",IDC_MOREDETAIL,"MButtonClass",WS_TABSTOP,129,104,61,12,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L
+END
+
+IDD_SETUP DIALOGEX 0, 0, 244, 146
+STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+CAPTION "Weather Protocol INI Setup"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "Weather Protocol INI Setup\nInstall and load your weather ini file here",IDC_HEADERBAR,
+ "MHeaderbarCtrl",0x0,0,0,243,28
+ CTEXT "Weather Protocol cannot find any weather INI file stored in your computer. To setup weather INI and add weather stations, please follow the steps:",IDC_STATIC,11,32,222,26
+ CONTROL "Click here to download a weather ini file from Miranda file listing",IDC_STEP1,
+ "MButtonClass",WS_TABSTOP,5,62,234,12,WS_EX_WINDOWEDGE | 0x800000L
+ CONTROL "Extract the weather ini file from archive to this directory",IDC_STEP2,
+ "MButtonClass",WS_TABSTOP,5,74,234,12,WS_EX_WINDOWEDGE | 0x800000L
+ CONTROL "Click here to load the data from the new ini file into memory",IDC_STEP3,
+ "MButtonClass",WS_TABSTOP,5,86,234,13,WS_EX_WINDOWEDGE | 0x800000L
+ CONTROL "Add new weather station and close this dialog",IDC_STEP4,
+ "MButtonClass",WS_TABSTOP,5,99,234,12,WS_EX_WINDOWEDGE | 0x800000L
+ PUSHBUTTON "Close",IDCANCEL,95,122,48,13
+ CONTROL "",IDC_MFRAME,"Static",SS_ETCHEDHORZ,0,117,244,1
+END
+
+IDD_INFO DIALOGEX 0, 0, 225, 155
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_INFOLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,210,115
+ LTEXT "Total INI files",IDC_STATIC,7,125,95,8
+ LTEXT "Total memory used",IDC_STATIC,7,138,92,8
+ LTEXT "",IDC_INICOUNT,104,125,30,10,SS_SUNKEN
+ LTEXT "",IDC_MEMUSED,104,138,29,10,SS_SUNKEN
+ PUSHBUTTON "Reload INI",IDC_RELOADINI,145,128,64,18
+END
+
+IDD_SEARCHCITY DIALOGEX 0, 0, 114, 55
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU
+EXSTYLE WS_EX_TRANSPARENT | WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ EDITTEXT IDC_SEARCHCITY,3,18,103,12,0,WS_EX_CLIENTEDGE
+ LTEXT "City:",IDC_STATIC,6,7,99,8
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_BRIEF, DIALOG
+ BEGIN
+ RIGHTMARGIN, 241
+ BOTTOMMARGIN, 226
+ END
+
+ IDD_OPTIONS, DIALOG
+ BEGIN
+ VERTGUIDE, 12
+ BOTTOMMARGIN, 209
+ END
+
+ IDD_POPUP, DIALOG
+ BEGIN
+ RIGHTMARGIN, 306
+ END
+
+ IDD_TEXTOPT, DIALOG
+ BEGIN
+ RIGHTMARGIN, 308
+ END
+
+ IDD_SETUP, DIALOG
+ BEGIN
+ BOTTOMMARGIN, 140
+ END
+
+ IDD_INFO, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 217
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 148
+ END
+
+ IDD_SEARCHCITY, DIALOG
+ BEGIN
+ RIGHTMARGIN, 113
+ BOTTOMMARGIN, 54
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_PMENU MENU
+BEGIN
+ POPUP "Menu"
+ BEGIN
+ MENUITEM "Dismiss PopUp", IDM_M1
+ MENUITEM "Open brief information", IDM_M2
+ MENUITEM "Open complete forecast", IDM_M3
+ MENUITEM "Open weather map", IDM_M4
+ MENUITEM "View history", IDM_M5
+ MENUITEM "Open log file", IDM_M6
+ MENUITEM "Show user menu", IDM_M7
+ MENUITEM "Show user detail", IDM_M8
+ END
+END
+
+IDR_TMENU MENU
+BEGIN
+ POPUP "Menu"
+ BEGIN
+ MENUITEM "To old setting", ID_T1
+ MENUITEM "To default", ID_T2
+ END
+END
+
+IDR_TMMENU MENU
+BEGIN
+ POPUP "Menu"
+ BEGIN
+ MENUITEM "Preview", ID_MPREVIEW
+ MENUITEM "Reset", ID_MRESET
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON ICON "icon.ico"
+IDI_UPDATE ICON "update.ico"
+IDI_READ ICON "more.ico"
+IDI_S ICON "brief.ico"
+IDI_LOG ICON "log.ico"
+IDI_EDIT ICON "edit.ico"
+IDI_MAP ICON "map.ico"
+IDI_POPUP ICON "popup.ico"
+IDI_NOPOPUP ICON "popup_no.ico"
+IDI_UPDATE2 ICON "update2.ico"
+IDI_DISABLED ICON "disabled.ico"
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "..\\src\\resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include <windows.h>\r\n"
+ "#include ""..\\src\\version.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "borkra, noname"
+ VALUE "FileDescription", "Miranda Weather Protocol"
+ VALUE "FileVersion", __VERSION_STRING
+ VALUE "InternalName", "Weather Protocol"
+ VALUE "LegalCopyright", "Copyright © 2005 - 2010 Boris Krasnovskiy All Rights Reserved"
+ VALUE "OriginalFilename", "weather.dll"
+ VALUE "ProductName", "Weather Protocol"
+ VALUE "ProductVersion", __VERSION_STRING
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/Weather/res/update.ico b/plugins/Weather/res/update.ico Binary files differnew file mode 100644 index 0000000000..ccc4d4611d --- /dev/null +++ b/plugins/Weather/res/update.ico diff --git a/plugins/Weather/res/update2.ico b/plugins/Weather/res/update2.ico Binary files differnew file mode 100644 index 0000000000..f71be51ee2 --- /dev/null +++ b/plugins/Weather/res/update2.ico diff --git a/plugins/Weather/src/resource.h b/plugins/Weather/src/resource.h new file mode 100644 index 0000000000..e88e4c19de --- /dev/null +++ b/plugins/Weather/src/resource.h @@ -0,0 +1,176 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by resource.rc
+//
+#define IDI_ICON 101
+#define IDD_USERINFO 201
+#define IDD_EDIT 202
+#define IDI_DISABLED 203
+#define IDD_POPUP 204
+#define IDD_OPTIONS 205
+#define IDI_LOG 206
+#define IDI_UPDATE2 208
+#define IDI_READ 209
+#define IDI_UPDATE 210
+#define IDI_S 211
+#define IDI_MAP 212
+#define IDR_PMENU 213
+#define IDI_POPUP 214
+#define IDI_NOPOPUP 215
+#define IDD_TEXTOPT 216
+#define IDD_BRIEF 217
+#define IDD_SETUP 218
+#define IDR_TMENU 219
+#define IDR_TMMENU 220
+#define IDI_EDIT 222
+#define IDD_INFO 224
+#define IDD_SEARCHCITY 225
+#define IDC_NAME 2000
+#define IDC_ID 2001
+#define IDC_LOG 2003
+#define IDC_UPDATETIME 2005
+#define IDC_CTEXT 2006
+#define IDC_AVATARSIZE 2006
+#define IDC_UPDATE 2007
+#define IDC_BTITLE 2008
+#define IDC_STARTUPUPD 2008
+#define IDC_CHANGE 2009
+#define IDC_BTITLE2 2009
+#define IDC_USEWINCOLORS 2010
+#define IDC_BTEXT 2011
+#define IDC_CH 2013
+#define IDC_NTEXT 2015
+#define IDC_DEGREE 2016
+#define IDC_E 2017
+#define IDC_W 2018
+#define IDC_POP1 2019
+#define IDC_XTEXT 2020
+#define IDC_POP2 2020
+#define IDC_PText 2021
+#define IDC_PTitle 2023
+#define IDC_Internal 2024
+#define IDC_ETEXT 2025
+#define IDC_DISCONDICON 2025
+#define IDC_External 2026
+#define IDC_DONOTAPPUNITS 2026
+#define IDC_DEFA 2027
+#define IDC_NOFRAC 2027
+#define IDC_HTEXT 2028
+#define IDC_DPop 2029
+#define IDC_DAutoUpdate 2030
+#define IDC_NEWWIN 2031
+#define IDC_IURL 2032
+#define IDC_MURL 2033
+#define IDC_PROTOCOND 2034
+#define IDC_Overwrite 2035
+#define IDC_UPDCONDCHG 2036
+#define IDC_REMOVEOLD 2037
+#define IDC_MAKEI 2039
+#define IDC_BGCOLOUR 2040
+#define IDC_TEXTCOLOUR 2041
+#define IDC_LeftClick 2042
+#define IDC_PREVIEW 2043
+#define IDC_VAR3 2044
+#define IDC_RightClick 2045
+#define IDC_DELAY 2046
+#define IDC_PDEF 2047
+#define IDC_T1 2048
+#define IDC_T2 2049
+#define IDC_W1 2050
+#define IDC_W2 2051
+#define IDC_W3 2052
+#define IDC_W4 2053
+#define IDC_BROWSE 2054
+#define IDC_VIEW1 2055
+#define IDC_RESET1 2056
+#define IDC_VIEW2 2057
+#define IDC_V1 2058
+#define IDC_V2 2059
+#define IDC_RESET2 2060
+#define IDC_SVCINFO 2061
+#define IDC_GETNAME 2062
+#define IDC_P1 2063
+#define IDC_P2 2064
+#define IDC_P3 2065
+#define IDC_P4 2066
+#define IDC_RESET 2067
+#define IDC_D1 2067
+#define IDC_D2 2068
+#define IDC_D3 2069
+#define IDC_INFO1 2069
+#define IDC_INFOICON 2070
+#define IDC_INFO11 2071
+#define IDC_INFO2 2072
+#define IDC_INFO3 2073
+#define IDC_VARLIST 2074
+#define IDC_INFO4 2075
+#define IDC_INFO5 2076
+#define IDC_PD1 2077
+#define IDC_PD2 2078
+#define IDC_PD3 2079
+#define IDC_INFO6 2079
+#define IDC_TM1 2080
+#define IDC_TM2 2081
+#define IDC_TM3 2082
+#define IDC_TM4 2083
+#define IDC_TM5 2084
+#define IDC_TM6 2085
+#define IDC_TM7 2086
+#define IDC_TM8 2087
+#define IDC_INFO7 2087
+#define IDC_TM9 2088
+#define IDC_INFO8 2089
+#define IDC_INFO9 2090
+#define IDC_INFO10 2091
+#define IDC_INFO12 2092
+#define IDC_INFO13 2093
+#define IDC_MORE 2094
+#define IDC_MOREDETAIL 2095
+#define IDC_DATALIST 2096
+#define IDC_MUPDATE 2097
+#define IDC_MFRAME 2099
+#define IDC_MTOGGLE 2101
+#define IDC_MWEBPAGE 2102
+#define IDC_MTEXT 2103
+#define IDC_STEP1 2107
+#define IDC_STEP2 2108
+#define IDC_STEP3 2109
+#define IDC_STEP4 2110
+#define IDC_INFOLIST 2117
+#define IDC_RELOADINI 2118
+#define IDC_MEMUSED 2119
+#define IDC_INICOUNT 2120
+#define IDC_AVATARSPIN 2124
+#define IDC_SEARCHCITY 2125
+#define IDC_HEADERBAR 2126
+#define IDC_E1 2128
+#define IDC_E2 2129
+#define OIC_HAND 32513
+#define OIC_QUES 32514
+#define OIC_BANG 32515
+#define OIC_NOTE 32516
+#define IDM_M1 40002
+#define IDM_M2 40003
+#define IDM_M3 40004
+#define IDM_M4 40005
+#define IDM_M5 40006
+#define IDM_M6 40007
+#define IDM_M7 40008
+#define IDM_M8 40009
+#define ID_T1 40010
+#define ID_T2 40011
+#define ID_MPREVIEW 40020
+#define ID_MRESET 40021
+#define IDC_STATIC -1
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 226
+#define _APS_NEXT_COMMAND_VALUE 40030
+#define _APS_NEXT_CONTROL_VALUE 2128
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/Weather/src/stdafx.cpp b/plugins/Weather/src/stdafx.cpp new file mode 100644 index 0000000000..2d786344e5 --- /dev/null +++ b/plugins/Weather/src/stdafx.cpp @@ -0,0 +1,18 @@ +/*
+Copyright (c) 2012 Miranda NG team (http://miranda-ng.org)
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "weather.h"
\ No newline at end of file diff --git a/plugins/Weather/src/version.h b/plugins/Weather/src/version.h new file mode 100644 index 0000000000..58a8f34a3c --- /dev/null +++ b/plugins/Weather/src/version.h @@ -0,0 +1,6 @@ +#define __FILEVERSION_STRING 0,3,9,1
+#define __VERSION_STRING "0.3.9.1"
+#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0, 3, 9, 1)
+
+#define BETA FALSE
+#define AUTH "NoName, borkra"
diff --git a/plugins/Weather/src/weather.cpp b/plugins/Weather/src/weather.cpp new file mode 100644 index 0000000000..9eb22252b5 --- /dev/null +++ b/plugins/Weather/src/weather.cpp @@ -0,0 +1,266 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+Main file for the Weather Protocol, includes loading, unloading,
+upgrading, support for plugin uninsaller, and anything that doesn't
+belong to any other file.
+*/
+
+#include "weather.h"
+
+//============ GLOBAL VARIABLES ============
+
+WIDATALIST *WIHead;
+WIDATALIST *WITail;
+
+HINSTANCE hInst;
+HWND hPopupWindow;
+
+HANDLE hHookWeatherUpdated;
+HANDLE hHookWeatherError;
+
+HANDLE hDataWindowList;
+HANDLE hWindowList;
+
+HANDLE hUpdateMutex;
+
+unsigned status;
+unsigned old_status;
+
+UINT_PTR timerId;
+int hLangpack;
+
+MYOPTIONS opt;
+
+// check if weather is currently updating
+BOOL ThreadRunning;
+
+// variable to determine if module loaded
+BOOL ModuleLoaded;
+
+
+
+
+// plugin info
+// VER = version, AUTH = author, defined in weather.h
+static const PLUGININFOEX pluginInfoEx =
+{
+ sizeof(PLUGININFOEX),
+ "Weather Protocol",
+ __VERSION_DWORD,
+ "Retrieves weather information and displays it in your contact list.",
+ AUTH,
+ "borkra@miranda-im.org",
+ "(c) 2002-2005 NoName, 2005-2010 Boris Krasnovskiy",
+ "http://miranda-ng.org/",
+ UNICODE_AWARE,
+ MIID_WEATHER
+};
+
+extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfoEx;
+}
+
+// MirandaInterfaces - returns the protocol interface to the core
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ hInst = hinstDLL;
+ return TRUE;
+}
+
+
+int WeatherShutdown(WPARAM wParam,LPARAM lParam)
+{
+ KillTimer(NULL, timerId); // kill update timer
+
+ SaveOptions(); // save options once more
+ status = ID_STATUS_OFFLINE; // set status to offline
+
+ CallService(MS_NETLIB_SHUTDOWN, (WPARAM)hNetlibHttp, 0);
+
+ WindowList_Broadcast(hWindowList, WM_CLOSE, 0, 0);
+ WindowList_Broadcast(hDataWindowList, WM_CLOSE, 0, 0);
+ SendMessage(hWndSetup, WM_CLOSE, 0, 0);
+
+ return 0;
+}
+
+// update some settings/db values for new version
+// lastver = dword value for the last version made by PLUGIN_MAKE_VERSION
+void Upgrade(DWORD lastver)
+{
+ // for version below v0.3.2.3, remove the "TriggerText" setting
+ if (lastver < PLUGIN_MAKE_VERSION(0,3,2,3))
+ db_unset(NULL, WEATHERPROTONAME, "TriggerText");
+ if (lastver < PLUGIN_MAKE_VERSION(0,3,3,13))
+ db_unset(NULL, "KnownModules", "Weather");
+
+ db_set_dw(NULL, WEATHERPROTONAME, "Version", __VERSION_DWORD);
+}
+
+// weather protocol initialization function
+// run after the event ME_SYSTEM_MODULESLOADED occurs
+int WeatherInit(WPARAM wParam,LPARAM lParam)
+{
+ // initialize netlib
+ NetlibInit();
+
+ InitIcons();
+ InitMwin();
+
+ // load weather menu items
+ AddMenuItems();
+
+ // timer for the first update
+ timerId = SetTimer(NULL, 0, 5000, timerProc2); // first update is 5 sec after load
+
+ // weather user detail
+ HookEvent(ME_USERINFO_INITIALISE, UserInfoInit);
+
+ hDataWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
+ hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
+
+ return 0;
+}
+
+// update some settings/db values for new version, this one is for contact
+// lastver = dword value for the last version made by PLUGIN_MAKE_VERSION
+// hContact = current contact
+void UpgradeContact(DWORD lastver, HANDLE hContact)
+{
+ // for version below v0.3.2.3, suppress online notifications for all weather contacts
+ if (lastver < PLUGIN_MAKE_VERSION(0,3,2,3))
+ {
+ db_set_dw(hContact, "Ignore", "Mask", 8);
+ db_set_dw(hContact, "Ignore", "Mask1", 8);
+ }
+}
+
+//============ MISC FUNCTIONS ============
+
+// initialize the global variables at startup
+void InitVar()
+{
+ // setup the linklist for weather update list
+ UpdateListTail = NULL;
+ UpdateListHead = NULL;
+
+ // other settings
+ timerId = 0;
+ opt.DefStn = NULL;
+ ModuleLoaded = FALSE;
+}
+
+// unload function
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ DestroyMwin();
+ DestroyWindow(hPopupWindow);
+
+ DestroyHookableEvent(hHookWeatherUpdated);
+ DestroyHookableEvent(hHookWeatherError);
+
+ NetlibHttpDisconnect();
+ Netlib_CloseHandle(hNetlibUser);
+
+ DestroyUpdateList();
+ DestroyOptions();
+ DestroyWIList(); // unload all ini data from memory
+
+ CloseHandle(hUpdateMutex);
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Load(void)
+{
+ DWORD lastver;
+
+ mir_getLP(&pluginInfoEx);
+
+ // initialize global variables
+ InitVar();
+
+ // load options and set defaults
+ LoadOptions();
+
+ // upgrade check
+ // I only support version check and upgrade for my own version, so check if the author is my name
+ if (strstr(AUTH, "NoName") != NULL)
+ {
+ lastver = db_get_dw(NULL, WEATHERPROTONAME, "Version", PLUGIN_MAKE_VERSION(0,3,1,8));
+ if (lastver < __VERSION_DWORD) Upgrade(lastver);
+ }
+ else // if it is not my build, ignore upgrade procedure
+ lastver = PLUGIN_MAKE_VERSION(255,255,255,255);
+
+ // reset the weather data at startup for individual contacts
+ EraseAllInfo(lastver);
+
+ // load weather update data
+ LoadWIData(TRUE);
+
+ // set status to online if "Do not display weather condition as protocol status" is enabled
+ old_status = status = ID_STATUS_OFFLINE;
+
+ // add an event on weather update and error
+ hHookWeatherUpdated = CreateHookableEvent(ME_WEATHER_UPDATED);
+ hHookWeatherError = CreateHookableEvent(ME_WEATHER_ERROR);
+
+ // initialize options and network
+ HookEvent(ME_OPT_INITIALISE, OptInit);
+ HookEvent(ME_SYSTEM_MODULESLOADED, WeatherInit);
+ HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
+ HookEvent(ME_CLIST_DOUBLECLICKED, BriefInfo);
+ HookEvent(ME_WEATHER_UPDATED, WeatherPopup);
+ HookEvent(ME_WEATHER_ERROR, WeatherError);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, WeatherShutdown);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, BuildContactMenu);
+
+ hUpdateMutex = CreateMutex(NULL, FALSE, NULL);
+
+ // register weather protocol
+ PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
+ pd.szName = WEATHERPROTONAME;
+ pd.type = (opt.NoProtoCondition) ? PROTOTYPE_VIRTUAL : PROTOTYPE_PROTOCOL;
+ CallService(MS_PROTO_REGISTERMODULE,0, (LPARAM)&pd);
+
+ // initialize weather protocol services
+ InitServices();
+
+ // add our modules to the KnownModules list
+ db_set_s(NULL, "KnownModules", "Weather Protocol", "Weather,WeatherCondition,Current");
+
+ // add sound event
+ SkinAddNewSoundExT("weatherupdated", _T(WEATHERPROTONAME), LPGENT("Weather Condition Changed"));
+ SkinAddNewSoundExT("weatheralert", _T(WEATHERPROTONAME), LPGENT("Weather Alert Issued"));
+
+ // window needed for popup commands
+ TCHAR SvcFunc[100];
+ mir_sntprintf( SvcFunc, SIZEOF(SvcFunc), _T("%s__PopupWindow"), _T(WEATHERPROTONAME));
+ hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW,_T("static"),SvcFunc,0,CW_USEDEFAULT,CW_USEDEFAULT,
+ CW_USEDEFAULT,CW_USEDEFAULT,HWND_DESKTOP,NULL, hInst,NULL);
+ SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LONG_PTR)PopupWndProc);
+
+ return 0;
+}
diff --git a/plugins/Weather/src/weather.h b/plugins/Weather/src/weather.h new file mode 100644 index 0000000000..072860c914 --- /dev/null +++ b/plugins/Weather/src/weather.h @@ -0,0 +1,545 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This file contains the includes, weather constants/declarations,
+ the structs, and the primitives for some of the functions.
+*/
+
+//============ THE INCLUDES ===========
+
+#define _CRT_SECURE_NO_WARNINGS
+#include <m_stdhdr.h>
+
+#include <stdio.h>
+#include <io.h>
+#include <share.h>
+#include <direct.h>
+#include <process.h>
+#include <time.h>
+
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+
+#include <win2k.h>
+
+#define MIRANDA_VER 0x0A00
+
+#include <newpluginapi.h>
+#include <m_system.h>
+#include <m_system_cpp.h>
+#include <m_protomod.h>
+#include <m_protosvc.h>
+#include <m_clist.h>
+#include <m_icolib.h>
+#include <m_options.h>
+#include <m_langpack.h>
+#include <m_skin.h>
+#include <m_database.h>
+#include <m_history.h>
+#include <m_utils.h>
+#include <m_userinfo.h>
+#include <m_netlib.h>
+#include <m_ignore.h>
+#include <m_findadd.h>
+#include <m_button.h>
+#include <m_avatars.h>
+#include <m_clui.h>
+#include <m_clc.h>
+#include <m_fontservice.h>
+#include <m_skin_eng.h>
+#include <m_cluiframes.h>
+
+#include <m_popup.h>
+
+#include "m_weather.h"
+#include "resource.h"
+#include "version.h"
+
+//============ CONSTANTS ============
+
+// status
+#define NOSTATUSDATA 1
+
+// limits
+#define MAX_TEXT_SIZE 4096
+#define MAX_DATA_LEN 1024
+
+// db info mangement mode
+#define WDBM_REMOVE 1
+#define WDBM_DETAILDISPLAY 2
+
+// more info list column width
+#define LIST_COLUMN 150
+
+// others
+#define NODATA TranslateT("N/A")
+#define UM_SETCONTACT 40000
+
+// weather update error codes
+#define INVALID_ID_FORMAT 10
+#define INVALID_SVC 11
+#define INVALID_ID 12
+#define SVC_NOT_FOUND 20
+#define NETLIB_ERROR 30
+#define DATA_EMPTY 40
+#define DOC_NOT_FOUND 42
+#define DOC_TOO_SHORT 43
+#define UNKNOWN_ERROR 99
+
+// weather update error text
+#define E10 TranslateT("Invalid ID format, missing \"/\" (10)")
+#define E11 TranslateT("Invalid service (11)")
+#define E12 TranslateT("Invalid station (12)")
+#define E20 TranslateT("Weather service ini for this station is not found (20)")
+#define E30 TranslateT("Netlib error - check your internet connection (30)")
+#define E40 TranslateT("Empty data is retrieved (40)")
+#define E42 TranslateT("Document not found (42)")
+#define E43 TranslateT("Document too short to contain any weather data (43)")
+#define E99 TranslateT("Unknown error (99)")
+
+// HTTP error... not all translated
+// 100 Continue
+// 101 Switching Protocols
+// 200 OK
+// 201 Created
+// 202 Accepted
+// 203 Non-Authoritative Information
+#define E204 TranslateT("HTTP Error: No content (204)")
+// 205 Reset Content
+// 206 Partial Content
+// 300 Multiple Choices
+#define E301 TranslateT("HTTP Error: Data moved (301)")
+// 302 Found
+// 303 See Other
+// 304 Not Modified
+#define E305 TranslateT("HTTP Error: Use proxy (305)")
+// 306 (Unused)
+#define E307 TranslateT("HTTP Error: Temporary redirect (307)")
+#define E400 TranslateT("HTTP Error: Bad request (400)")
+#define E401 TranslateT("HTTP Error: Unauthorized (401)")
+#define E402 TranslateT("HTTP Error: Payment required (402)")
+#define E403 TranslateT("HTTP Error: Forbidden (403)")
+#define E404 TranslateT("HTTP Error: Not found (404)")
+#define E405 TranslateT("HTTP Error: Method not allowed (405)")
+// 406 Not Acceptable
+#define E407 TranslateT("HTTP Error: Proxy authentication required (407)")
+// 408 Request Timeout
+// 409 Conflict
+#define E410 TranslateT("HTTP Error: Gone (410)")
+// 411 Length Required
+// 412 Precondition Failed
+// 413 Request Entity Too Large
+// 414 Request-URI Too Long
+// 415 Unsupported Media Type
+// 416 Requested Range Not Satisfiable
+// 417 Expectation Failed
+#define E500 TranslateT("HTTP Error: Internal server error (500)")
+// 501 Not Implemented
+#define E502 TranslateT("HTTP Error: Bad gateway (502)")
+#define E503 TranslateT("HTTP Error: Service unavailable (503)")
+#define E504 TranslateT("HTTP Error: Gateway timeout (504)")
+// 505 HTTP Version Not Supported
+
+// defaults constants
+#define C_DEFAULT TranslateT("%n [%t, %c]")
+#define N_DEFAULT TranslateT("%c\nTemperature: %t\nFeel-Like: %f\nPressure: %p\nWind: %i %w\nHumidity: %m\nDew Point: %e\nVisibility: %v\n\nSun Rise: %r\nSun Set: %y\n\n5 Days Forecast:\n%[Forecast Day 1]\n%[Forecast Day 2]\n%[Forecast Day 3]\n%[Forecast Day 4]\n%[Forecast Day 5]")
+#define B_DEFAULT TranslateT("Feel-Like: %f\nPressure: %p\nWind: %i %w\nHumidity: %m\nDew Point: %e\nVisibility: %v\n\nSun Rise: %r\nSun Set: %y\n\n5 Days Forecast:\n%[Forecast Day 1]\n%[Forecast Day 2]\n%[Forecast Day 3]\n%[Forecast Day 4]\n%[Forecast Day 5]")
+#define b_DEFAULT TranslateT("Weather Condition for %n as of %u")
+#define X_DEFAULT N_DEFAULT
+#define H_DEFAULT TranslateT("%c, %t (feel-like %f) Wind: %i %w Humidity: %m")
+#define E_DEFAULT TranslateT("%n at %u: %c, %t (feel-like %f) Wind: %i %w Humidity: %m")
+#define P_DEFAULT TranslateT("%n (%u)")
+#define p_DEFAULT TranslateT("%c, %t\nToday: High %h, Low %l")
+#define s_DEFAULT TranslateT("Temperature: %[Temperature]")
+
+
+//============ OPTION STRUCT ============
+
+// option struct
+typedef struct {
+// main options
+ BOOL AutoUpdate;
+ BOOL CAutoUpdate;
+ BOOL StartupUpdate;
+ WORD UpdateTime;
+ WORD AvatarSize;
+ BOOL NewBrowserWin;
+ BOOL NoProtoCondition;
+ BOOL UpdateOnlyConditionChanged;
+ BOOL RemoveOldData;
+ BOOL MakeItalic;
+// units
+ WORD tUnit;
+ WORD wUnit;
+ WORD vUnit;
+ WORD pUnit;
+ WORD dUnit;
+ WORD eUnit;
+ TCHAR DegreeSign[4];
+ BOOL DoNotAppendUnit;
+ BOOL NoFrac;
+// texts
+ TCHAR *cText;
+ TCHAR *bTitle;
+ TCHAR *bText;
+ TCHAR *nText;
+ TCHAR *eText;
+ TCHAR *hText;
+ TCHAR *xText;
+ TCHAR *sText;
+// advanced
+ BOOL DisCondIcon;
+// popup options
+ BOOL UsePopup;
+ BOOL UpdatePopup;
+ BOOL AlertPopup;
+ BOOL PopupOnChange;
+ BOOL ShowWarnings;
+// popup colors
+ BOOL UseWinColors;
+ COLORREF BGColour;
+ COLORREF TextColour;
+// popup actions
+ DWORD LeftClickAction;
+ DWORD RightClickAction;
+// popup delay
+ DWORD pDelay;
+// popup texts
+ TCHAR *pTitle;
+ TCHAR *pText;
+// other misc stuff
+ TCHAR Default[64];
+ HANDLE DefStn;
+} MYOPTIONS;
+
+void DestroyOptions(void);
+
+//============ STRUCT USED TO MAKE AN UPDATE LIST ============
+
+struct WCONTACTLIST {
+ HANDLE hContact;
+ struct WCONTACTLIST *next;
+};
+
+typedef struct WCONTACTLIST UPDATELIST;
+
+extern UPDATELIST *UpdateListHead;
+extern UPDATELIST *UpdateListTail;
+
+void DestroyUpdateList(void);
+
+//============ DATA FORMAT STRUCT ============
+
+#define WID_NORMAL 0
+#define WID_SET 1
+#define WID_BREAK 2
+
+typedef struct {
+ TCHAR *Name;
+ TCHAR *Start;
+ TCHAR *End;
+ TCHAR *Unit;
+ char *Url;
+ TCHAR *Break;
+ int Type;
+} WIDATAITEM;
+
+struct WITEMLIST {
+ WIDATAITEM Item;
+ struct WITEMLIST *Next;
+};
+
+typedef struct WITEMLIST WIDATAITEMLIST;
+
+typedef struct {
+ BOOL Available;
+ char *SearchURL;
+ TCHAR *NotFoundStr;
+ WIDATAITEM Name;
+} WIIDSEARCH;
+
+typedef struct {
+ BOOL Available;
+ TCHAR *First;
+ WIDATAITEM Name;
+ WIDATAITEM ID;
+} WINAMESEARCHTYPE;
+
+typedef struct {
+ char *SearchURL;
+ TCHAR *NotFoundStr;
+ TCHAR *SingleStr;
+ WINAMESEARCHTYPE Single;
+ WINAMESEARCHTYPE Multiple;
+} WINAMESEARCH;
+
+struct STRLIST {
+ TCHAR *Item;
+ struct STRLIST *Next;
+};
+
+typedef struct STRLIST WICONDITEM;
+
+typedef struct {
+ WICONDITEM *Head;
+ WICONDITEM *Tail;
+} WICONDLIST;
+
+typedef struct {
+ TCHAR *FileName;
+ TCHAR *ShortFileName;
+ BOOL Enabled;
+
+ // header
+ TCHAR *DisplayName;
+ TCHAR *InternalName;
+ TCHAR *Description;
+ TCHAR *Author;
+ TCHAR *Version;
+ int InternalVer;
+ size_t MemUsed;
+
+ // default
+ char *DefaultURL;
+ TCHAR *DefaultMap;
+ char *UpdateURL;
+ char *UpdateURL2;
+ char *UpdateURL3;
+ char *UpdateURL4;
+ char *Cookie;
+// items
+ int UpdateDataCount;
+ WIDATAITEMLIST *UpdateData;
+ WIDATAITEMLIST *UpdateDataTail;
+ WIIDSEARCH IDSearch;
+ WINAMESEARCH NameSearch;
+ WICONDLIST CondList[10];
+} WIDATA;
+
+//============ DATA LIST (LINKED LIST) ============
+
+struct DATALIST {
+ WIDATA Data;
+ struct DATALIST *next;
+};
+
+typedef struct DATALIST WIDATALIST;
+
+//============ GLOBAL VARIABLES ============
+
+extern WIDATALIST *WIHead;
+extern WIDATALIST *WITail;
+
+extern HINSTANCE hInst;
+extern HWND hPopupWindow;
+extern HWND hWndSetup;
+
+extern MYOPTIONS opt;
+
+extern unsigned status;
+extern unsigned old_status;
+
+extern HANDLE hDataWindowList;
+extern HANDLE hNetlibUser, hNetlibHttp;
+extern HANDLE hHookWeatherUpdated;
+extern HANDLE hHookWeatherError;
+extern HANDLE hWindowList;
+extern HANDLE hMwinMenu;
+
+extern UINT_PTR timerId;
+
+// check if weather is currently updating
+extern BOOL ThreadRunning;
+
+//============ FUNCTION PRIMITIVES ============
+
+// functions in weather.c
+void UpgradeContact(DWORD lastver, HANDLE hContact);
+
+// functions in weather_addstn.c
+INT_PTR WeatherAddToList(WPARAM wParam,LPARAM lParam);
+BOOL CheckSearch();
+
+int IDSearch(TCHAR *id, const int searchId);
+int NameSearch(TCHAR *name, const int searchId);
+
+INT_PTR WeatherBasicSearch(WPARAM wParam,LPARAM lParam);
+INT_PTR WeatherCreateAdvancedSearchUI(WPARAM wParam, LPARAM lParam);
+INT_PTR WeatherAdvancedSearch(WPARAM wParam, LPARAM lParam);
+
+int WeatherAdd(WPARAM wParam, LPARAM lParam);
+
+// functions used in weather_contacts.c
+INT_PTR ViewLog(WPARAM wParam,LPARAM lParam);
+INT_PTR LoadForecast(WPARAM wParam,LPARAM lParam);
+INT_PTR WeatherMap(WPARAM wParam,LPARAM lParam);
+
+INT_PTR EditSettings(WPARAM wParam,LPARAM lParam);
+INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+int ContactDeleted(WPARAM wParam,LPARAM lParam);
+
+BOOL IsMyContact(HANDLE hContact);
+
+// functions in weather_conv.c
+BOOL is_number(char *s);
+
+void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+
+WORD GetIcon(const TCHAR* cond, WIDATA *Data);
+void CaseConv(TCHAR *str);
+void TrimString(char *str);
+void TrimString(WCHAR *str);
+void ConvertBackslashes(char *str);
+char *GetSearchStr(char *dis);
+
+TCHAR *GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str);
+INT_PTR GetDisplaySvcFunc(WPARAM wParam, LPARAM lParam);
+
+void GetSvc(TCHAR *pszID);
+void GetID(TCHAR *pszID);
+
+TCHAR *GetError(int code);
+
+// functions in weather_data.c
+void GetStationID(HANDLE hContact, TCHAR* id, size_t idlen);
+WEATHERINFO LoadWeatherInfo(HANDLE Change);
+int DBGetData(HANDLE hContact, char *setting, DBVARIANT *dbv);
+int DBGetStaticString(HANDLE hContact, const char *szModule, const char *valueName, TCHAR *dest, size_t dest_len);
+
+void EraseAllInfo(DWORD lastver);
+
+void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data);
+void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szInfo);
+void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data);
+void wSetData(char **Data, const char *Value);
+void wSetData(WCHAR **Data, const char *Value);
+void wSetData(WCHAR **Data, const WCHAR *Value);
+void wfree(char **Data);
+void wfree(WCHAR **Data);
+
+void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam);
+
+// functions in weather_http.c
+int InternetDownloadFile (char *szUrl, char *cookie, TCHAR** szData);
+void NetlibInit();
+void NetlibHttpDisconnect(void);
+
+// functions in weather_ini.c
+void WIListAdd(WIDATA Data);
+WIDATA* GetWIData(TCHAR *pszServ);
+
+BOOL IsContainedInCondList(const TCHAR *pszStr, WICONDLIST *List);
+
+void DestroyWIList();
+BOOL LoadWIData(BOOL dial);
+void FreeWIData(WIDATA *Data);
+
+INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// functions in weather_info.c
+void GetINIInfo(TCHAR *pszSvc);
+
+void MoreVarList();
+
+// functions in weather_opt.c
+void SetTextDefault(const char* in);
+void LoadOptions();
+void SaveOptions();
+
+int OptInit(WPARAM wParam,LPARAM lParam);
+
+INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam);
+void SetIconDefault();
+void RemoveIconSettings();
+
+BOOL CALLBACK TextOptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam);
+BOOL CALLBACK AdvOptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam);
+INT_PTR CALLBACK DlgProcText(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgPopUpOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+// functions in weather_popup.c
+int WeatherPopup(WPARAM wParam, LPARAM lParam);
+int WeatherError(WPARAM wParam, LPARAM lParam);
+int WPShowMessage(TCHAR* lpzText, WORD kind);
+
+LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+// functions in weather_svcs.c
+void InitServices(void);
+
+INT_PTR WeatherSetStatus(WPARAM new_status, LPARAM lParam);
+INT_PTR WeatherGetCaps(WPARAM wParam, LPARAM lParam);
+INT_PTR WeatherGetName(WPARAM wParam, LPARAM lParam);
+INT_PTR WeatherGetStatus(WPARAM wParam, LPARAM lParam);
+INT_PTR WeatherLoadIcon(WPARAM wParam, LPARAM lParam);
+
+void UpdateMenu(BOOL State);
+void UpdatePopupMenu(BOOL State);
+void AddMenuItems();
+void AvatarDownloaded(HANDLE hContact);
+
+// functions in weather_update.c
+int UpdateWeather(HANDLE hContact);
+
+int RetrieveWeather(HANDLE hContact, WEATHERINFO *winfo);
+
+void UpdateAll(BOOL AutoUpdate, BOOL RemoveOld);
+void UpdateThreadProc(LPVOID hWnd);
+INT_PTR UpdateSingleStation(WPARAM wParam,LPARAM lParam);
+INT_PTR UpdateAllInfo(WPARAM wParam,LPARAM lParam);
+INT_PTR UpdateSingleRemove(WPARAM wParam,LPARAM lParam);
+INT_PTR UpdateAllRemove(WPARAM wParam,LPARAM lParam);
+
+int GetWeatherData(HANDLE hContact);
+
+void CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
+void CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
+
+// function from multiwin module
+void InitMwin(void);
+void DestroyMwin(void);
+INT_PTR Mwin_MenuClicked(WPARAM wParam, LPARAM lParam);
+int BuildContactMenu(WPARAM wparam, LPARAM lparam);
+void UpdateMwinData(HANDLE hContact);
+void removeWindow(HANDLE hContact);
+
+// functions in weather_userinfo.c
+int UserInfoInit(WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+#define WM_UPDATEDATA WM_USER + 2687
+
+int BriefInfo(WPARAM wParam, LPARAM lParam);
+INT_PTR BriefInfoSvc(WPARAM wParam, LPARAM lParam);
+void LoadBriefInfoText(HWND hwndDlg, HANDLE hContact);
+INT_PTR CALLBACK DlgProcBrief(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+void InitIcons(void);
+HICON LoadIconEx(const char* name, BOOL big);
+HANDLE GetIconHandle(const char* name);
+void ReleaseIconEx(HICON hIcon);
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp new file mode 100644 index 0000000000..9a3f1fd19f --- /dev/null +++ b/plugins/Weather/src/weather_addstn.cpp @@ -0,0 +1,428 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This file contain the source related to search and add a weather station
+to the contact list. Contain code for both name and ID search.
+*/
+
+#include "weather.h"
+
+// variables used for weather_addstn.c
+static int searchId = -1;
+static TCHAR name1[256];
+
+// ============ ADDING NEW STATION ============
+
+// protocol service function for adding a new contact onto contact list
+// lParam = PROTOSEARCHRESULT
+INT_PTR WeatherAddToList(WPARAM wParam, LPARAM lParam)
+{
+ PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)lParam;
+ WIDATA *sData;
+
+ // search for existing contact
+ HANDLE hContact = db_find_first();
+ while (hContact != NULL) {
+ // check if it is a weather contact
+ if ( IsMyContact(hContact)) {
+ DBVARIANT dbv;
+ // check ID to see if the contact already exist in the database
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ if ( !_tcsicmp(psr->email, dbv.ptszVal)) {
+ // remove the flag for not on list and hidden, thus make the contact visible
+ // and add them on the list
+ if (db_get_b(hContact, "CList", "NotOnList", 1)) {
+ db_unset(hContact, "CList", "NotOnList");
+ db_unset(hContact, "CList", "Hidden");
+ }
+ db_free(&dbv);
+ // contact is added, function quitting
+ return (INT_PTR)hContact;
+ }
+ db_free(&dbv);
+ }
+ }
+ hContact = db_find_next(hContact);
+ }
+
+ // if contact with the same ID was not found, add it
+ if (psr->cbSize < sizeof(PROTOSEARCHRESULT)) return 0;
+ hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)WEATHERPROTONAME);
+ // suppress online notification for the new contact
+ CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, IGNOREEVENT_USERONLINE);
+
+ // set contact info and settings
+ TCHAR svc[256];
+ _tcsncpy(svc, psr->email, SIZEOF(svc)); svc[SIZEOF(svc)-1] = 0;
+ GetSvc(svc);
+ // set settings by obtaining the default for the service
+ if (psr->lastName[0] != 0) {
+ sData = GetWIData(svc);
+ db_set_ts(hContact, WEATHERPROTONAME, "MapURL", sData->DefaultMap);
+ db_set_s(hContact, WEATHERPROTONAME, "InfoURL", sData->DefaultURL);
+ }
+ else { // if no valid service is found, create empty strings for MapURL and InfoURL
+ db_set_s(hContact, WEATHERPROTONAME, "MapURL", "");
+ db_set_s(hContact, WEATHERPROTONAME, "InfoURL", "");
+ }
+ // write the other info and settings to the database
+ db_set_ts(hContact, WEATHERPROTONAME, "ID", psr->email);
+ db_set_ts(hContact, WEATHERPROTONAME, "Nick", psr->nick);
+ db_set_w(hContact, WEATHERPROTONAME, "Status", ID_STATUS_OFFLINE);
+
+ AvatarDownloaded(hContact);
+
+ TCHAR str[256];
+ mir_sntprintf(str, SIZEOF(str), TranslateT("Current weather information for %s."), psr->nick);
+ db_set_ts(hContact, WEATHERPROTONAME, "About", str);
+
+ // make the last update tags to something invalid
+ db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never");
+ db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None");
+ db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None");
+
+ // ignore status change
+ db_set_dw(hContact, "Ignore", "Mask", 8);
+
+ // if no default station is found, set the new contact as default station
+ if (opt.Default[0] == 0) {
+ DBVARIANT dbv;
+ GetStationID(hContact, opt.Default, SIZEOF(opt.Default));
+
+ opt.DefStn = hContact;
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ // notification message box
+ wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ db_free(&dbv);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ }
+ db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ }
+ // display the Edit Settings dialog box
+ EditSettings((WPARAM)hContact, 0);
+ return (INT_PTR)hContact;
+}
+
+// ============ WARNING DIALOG ============
+
+// show a message box and cancel search if update is in process
+BOOL CheckSearch() {
+ if (UpdateListHead != NULL) {
+ MessageBox(NULL, TranslateT("Please try again after weather update is completed."), TranslateT("Weather Protocol"), MB_OK|MB_ICONERROR);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+// ============ BASIC ID SEARCH ============
+
+static TCHAR sID[32];
+
+// A timer process for the ID search (threaded)
+static void __cdecl BasicSearchTimerProc(LPVOID hWnd)
+{
+ int result;
+ // search only when it's not current updating weather.
+ if (CheckSearch())
+ result = IDSearch(sID, searchId);
+
+ // broadcast the search result
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)searchId, 0);
+
+ // exit the search
+ searchId = -1;
+}
+
+// the service function for ID search
+// lParam = ID search string
+INT_PTR WeatherBasicSearch(WPARAM wParam, LPARAM lParam)
+{
+ if (searchId != -1) return 0; //only one search at a time
+ _tcsncpy(sID, ( TCHAR* )lParam, SIZEOF(sID));
+ sID[SIZEOF(sID)-1] = 0;
+ searchId = 1;
+ // create a thread for the ID search
+ mir_forkthread(BasicSearchTimerProc, NULL);
+ return searchId;
+}
+
+// ============ NAME SEARCH ============
+
+// name search timer process (threaded)
+static void __cdecl NameSearchTimerProc(LPVOID hWnd)
+{
+ // search only when it's not current updating weather.
+ if (CheckSearch())
+ if (name1[0] != 0)
+ NameSearch(name1, searchId); // search nickname field
+
+ // broadcast the result
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)searchId, 0);
+
+ // exit the search
+ searchId = -1;
+}
+
+static INT_PTR CALLBACK WeatherSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SetFocus(GetDlgItem(hwndDlg, IDC_SEARCHCITY));
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == EN_SETFOCUS)
+ PostMessage(GetParent(hwndDlg), WM_COMMAND, MAKEWPARAM(0, EN_SETFOCUS), (LPARAM)hwndDlg);
+ }
+ return FALSE;
+}
+
+INT_PTR WeatherCreateAdvancedSearchUI(WPARAM wParam, LPARAM lParam)
+{
+ HWND parent = (HWND)lParam;
+ if (parent)
+ return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCHCITY), parent, WeatherSearchAdvancedDlgProc, 0);
+
+ return 0;
+}
+
+// service function for name search
+INT_PTR WeatherAdvancedSearch(WPARAM wParam, LPARAM lParam)
+{
+ if (searchId != -1) return 0; //only one search at a time
+
+ searchId = 1;
+ GetDlgItemText((HWND)lParam, IDC_SEARCHCITY, name1, 256);
+
+ // search for the weather station using a thread
+ mir_forkthread(NameSearchTimerProc, NULL);
+ return searchId;
+}
+
+// ============ SEARCH FOR A WEATHER STATION USING ID ============
+
+// Seaching station ID from a single weather service (Threaded)
+// sID = search string for the station ID
+// searchId = -1
+// sData = the ID search data for that particular weather service
+// svcname = the name of the weather service that is currently searching (ie. Yahoo Weather)
+int IDSearchProc(TCHAR *sID, const int searchId, WIIDSEARCH *sData, TCHAR *svc, TCHAR *svcname)
+{
+ TCHAR str[MAX_DATA_LEN], newID[MAX_DATA_LEN];
+
+ if (sData->Available) {
+ char loc[255];
+ TCHAR *szData = NULL;
+
+ // load the page
+ mir_snprintf(loc, SIZEOF(loc), sData->SearchURL, sID);
+ if (InternetDownloadFile(loc, NULL, &szData) == 0) {
+ TCHAR* szInfo = szData;
+
+ // not found
+ if ( _tcsstr(szInfo, sData->NotFoundStr) == NULL)
+ GetDataValue(&sData->Name, str, &szInfo);
+ }
+ mir_free(szData);
+ // Station not found exit
+ if (str[0] == 0) return 1;
+ }
+
+ // give no station name but only ID if the search is unavailable
+ else _tcscpy(str, TranslateT("<Enter station name here>"));
+ mir_sntprintf(newID, SIZEOF(newID), _T("%s/%s"), svc, sID);
+
+ // set the search result and broadcast it
+ PROTOSEARCHRESULT psr = { sizeof(psr) };
+ psr.flags = PSR_TCHAR;
+ psr.nick = str;
+ psr.firstName = _T(" ");
+ psr.lastName = svcname;
+ psr.email = newID;
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
+
+ return 0;
+}
+
+// ID search (Threaded)
+// sID: the ID to search for
+// searchId: don't change
+// return 0 if no error
+int IDSearch(TCHAR *sID, const int searchId)
+{
+ // for a normal ID search (ID != #)
+ if ( _tcscmp(sID, _T("#"))) {
+ WIDATALIST *Item = WIHead;
+
+ // search every weather service using the search station ID
+ while (Item != NULL) {
+ IDSearchProc(sID, searchId, &Item->Data.IDSearch, Item->Data.InternalName, Item->Data.DisplayName);
+ Item = Item->next;
+ }
+ NetlibHttpDisconnect();
+ }
+ // if the station ID is #, return a dummy result and quit the funciton
+ else {
+ // return an empty contact on "#"
+ PROTOSEARCHRESULT psr = { sizeof(psr) };
+ psr.flags = PSR_TCHAR;
+ psr.nick = TranslateT("<Enter station name here>"); // to be entered
+ psr.firstName = _T(" ");
+ psr.lastName = _T("");
+ psr.email = TranslateT("<Enter station ID here>"); // to be entered
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
+ }
+
+ return 0;
+}
+
+// ============ SEARCH FOR A WEATHER STATION BY NAME ============
+
+// Seaching station name from a single weather service (Threaded)
+// name = the name of the weather station to be searched
+// searchId = -1
+// sData = the name search data for that particular weather service
+// svcname = the name of the weather service that is currently searching (ie. Yahoo Weather)
+int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *svc, TCHAR *svcname)
+{
+ char loc[256];
+ TCHAR Name[MAX_DATA_LEN], str[MAX_DATA_LEN], sID[MAX_DATA_LEN], *szData = NULL, *search;
+
+ // replace spaces with %20
+ {
+ mir_ptr<char> szSearchName( mir_utf8encodeT(name));
+ char *pstr = (char*)CallService(MS_NETLIB_URLENCODE, 0, (LPARAM)(char*)szSearchName);
+ wsprintfA(loc, sData->SearchURL, pstr);
+ HeapFree(GetProcessHeap(), 0, pstr);
+ }
+
+ if (InternetDownloadFile(loc, NULL, &szData) == 0) {
+ TCHAR* szInfo = szData;
+ search = _tcsstr(szInfo, sData->NotFoundStr); // determine if data is available
+ if (search == NULL) { // if data is found
+ // test if it is single result
+ if (sData->Single.Available && sData->Multiple.Available)
+ search = _tcsstr(szInfo, sData->SingleStr);
+ // for single result
+ if (sData->Single.Available && (search != NULL || !sData->Multiple.Available)) { // single result
+ // if station ID appears first in the downloaded data
+ if ( !_tcsicmp(sData->Single.First, _T("ID"))) {
+ GetDataValue(&sData->Single.ID, str, &szInfo);
+ wsprintf(sID, _T("%s/%s"), svc, str);
+ GetDataValue(&sData->Single.Name, Name, &szInfo);
+ }
+ // if station name appears first in the downloaded data
+ else if ( !_tcsicmp(sData->Single.First, _T("NAME"))) {
+ GetDataValue(&sData->Single.Name, Name, &szInfo);
+ GetDataValue(&sData->Single.ID, str, &szInfo);
+ wsprintf(sID, _T("%s/%s"), svc, str);
+ }
+ // if no station ID is obtained, quit the search
+ if (str[0] == 0) {
+ mir_free(szData);
+ return 1;
+ }
+
+ // if can't get the name, use the search string as name
+ if (Name[0] == 0)
+ _tcscpy(Name, name);
+
+ // set the data and broadcast it
+ PROTOSEARCHRESULT psr = { sizeof(psr) };
+ psr.flags = PSR_TCHAR;
+ psr.nick = Name;
+ psr.firstName = _T(" ");
+ psr.lastName = svcname;
+ psr.email = sID;
+ psr.id = sID;
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
+ mir_free(szData);
+ return 0;
+ }
+ // for multiple result
+ else if (sData->Multiple.Available) { // multiple results
+ // search for the next occurrence of the string
+ for (;;) {
+ // if station ID appears first in the downloaded data
+ if ( !_tcsicmp(sData->Multiple.First, _T("ID"))) {
+ GetDataValue(&sData->Multiple.ID, str, &szInfo);
+ wsprintf(sID, _T("%s/%s"), svc, str);
+ GetDataValue(&sData->Multiple.Name, Name, &szInfo);
+ }
+ // if station name appears first in the downloaded data
+ else if ( !_tcsicmp(sData->Multiple.First, _T("NAME"))) {
+ GetDataValue(&sData->Multiple.Name, Name, &szInfo);
+ GetDataValue(&sData->Multiple.ID, str, &szInfo);
+ wsprintf(sID, _T("%s/%s"), svc, str);
+ }
+ // if no station ID is obtained, search completed and quit the search
+ if (str[0] == 0) break;
+ // if can't get the name, use the search string as name
+ if (Name[0] == 0)
+ _tcscpy(Name, name);
+
+ PROTOSEARCHRESULT psr = { sizeof(psr) };
+ psr.flags = PSR_TCHAR;
+ psr.nick = Name;
+ psr.firstName = _T("");
+ psr.lastName = svcname;
+ psr.email = sID;
+ psr.id = sID;
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
+ } } }
+
+ mir_free(szData);
+ return 0;
+ }
+
+ mir_free(szData);
+ return 1;
+}
+
+// name search (Threaded)
+// name: the station name to search for
+// searchId: don't change
+// return 0 if no error
+int NameSearch(TCHAR *name, const int searchId)
+{
+ WIDATALIST *Item = WIHead;
+
+ // search every weather service using the search station name
+ while (Item != NULL) {
+ if (Item->Data.NameSearch.Single.Available || Item->Data.NameSearch.Multiple.Available)
+ NameSearchProc(name, searchId, &Item->Data.NameSearch, Item->Data.InternalName, Item->Data.DisplayName);
+ Item = Item->next;
+ }
+
+ NetlibHttpDisconnect();
+ return 0;
+}
+
+// ======================MENU ITEM FUNCTION ============
+
+// add a new weather station via find/add dialog
+int WeatherAdd(WPARAM wParam, LPARAM lParam)
+{
+ db_set_s(NULL, "FindAdd", "LastSearched", "Weather");
+ CallService(MS_FINDADD_FINDADD, 0, 0);
+ return 0;
+}
diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp new file mode 100644 index 0000000000..4c049f5d26 --- /dev/null +++ b/plugins/Weather/src/weather_contacts.cpp @@ -0,0 +1,486 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This file contain the source that is related to weather contacts,
+include the links, edit settings, and loading weather information for
+the contact.
+*/
+
+#include "weather.h"
+
+static void OpenUrl( TCHAR* format, TCHAR* id )
+{
+ TCHAR loc[512];
+
+ GetID( id );
+ mir_sntprintf( loc, SIZEOF(loc), format, id );
+
+ CallService(MS_UTILS_OPENURL, opt.NewBrowserWin | OUF_TCHAR, (LPARAM)loc );
+}
+
+//============ BASIC CONTACTS FUNCTIONS AND LINKS ============
+
+// view weather log for the contact
+// wParam = current contact
+INT_PTR ViewLog(WPARAM wParam, LPARAM lParam)
+{
+ // see if the log path is set
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingTString((HANDLE)wParam, WEATHERPROTONAME, "Log", &dbv)) {
+ if (dbv.pszVal[0] != 0)
+ ShellExecute((HWND)lParam, _T("open"), dbv.ptszVal, _T(""), _T(""), SW_SHOW);
+ db_free(&dbv);
+ }
+ else // display warning dialog if no path is specified
+ MessageBox(NULL, TranslateT("Weather condition was not logged."),
+ TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
+ return 0;
+}
+
+// read complete forecast
+// wParam = current contact
+INT_PTR LoadForecast(WPARAM wParam, LPARAM lParam)
+{
+ TCHAR id[256], loc2[256];
+ GetStationID((HANDLE)wParam, id, SIZEOF(id));
+ if (id[0] != 0) {
+ // check if the complte forecast URL is set. If it is not, display warning and quit
+ if ( DBGetStaticString((HANDLE)wParam, WEATHERPROTONAME, "InfoURL", loc2, SIZEOF(loc2)) || loc2[0] == 0) {
+ MessageBox(NULL, TranslateT("The URL for complete forcast have not been set. You can set it from the Edit Settings dialog."),
+ TranslateT("Weather Protocol"), MB_ICONINFORMATION);
+ return 1;
+ }
+ // set the url and open the webpage
+ OpenUrl(loc2, id );
+ }
+ return 0;
+}
+
+// load weather map
+// wParam = current contact
+INT_PTR WeatherMap(WPARAM wParam, LPARAM lParam)
+{
+ TCHAR id[256], loc2[256];
+ GetStationID((HANDLE)wParam, id, SIZEOF(id));
+ if (id[0] != 0) {
+ // check if the weather map URL is set. If it is not, display warning and quit
+ if ( DBGetStaticString((HANDLE)wParam, WEATHERPROTONAME, "MapURL", loc2, SIZEOF(loc2)) || loc2[0] == 0) {
+ MessageBox(NULL, TranslateT("The URL for weather map have not been set. You can set it from the Edit Settings dialog."), TranslateT("Weather Protocol"), MB_ICONINFORMATION);
+ return 1;
+ }
+
+ // set the url and open the webpage
+ OpenUrl(loc2, id);
+ }
+
+ return 0;
+}
+
+//============ EDIT SETTINGS ============
+
+// show edit settings dialog
+// wParam = current contact
+INT_PTR EditSettings(WPARAM wParam, LPARAM lParam)
+{
+ HWND hEditDlg = WindowList_Find(hWindowList, (HANDLE)wParam);
+
+ // search the dialog list to prevent multiple instance of dialog for the same contact
+ if (hEditDlg != NULL) {
+ // if the dialog box already opened, bring it to the front
+ SetForegroundWindow(hEditDlg);
+ SetFocus(hEditDlg);
+ }
+ else {
+ // if the dialog box is not opened, open a new one
+ if (IsMyContact((HANDLE)wParam))
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT), NULL, DlgProcChange, (LPARAM)wParam);
+ }
+
+ return 0;
+}
+
+typedef struct
+{
+ HANDLE hContact;
+ HICON hRename;
+ HICON hUserDetail;
+ HICON hFile;
+ HICON hSrchAll;
+} CntSetWndDataType;
+
+// edit weather settings
+// lParam = current contact
+INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ DBVARIANT dbv;
+ TCHAR str[256], str2[256], city[256], filter[256], *pfilter, *chop;
+ char loc[512];
+ OPENFILENAME ofn; // common dialog box structure
+ HANDLE hContact;
+ WIDATA *sData;
+ CntSetWndDataType *wndData = NULL;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ wndData = ( CntSetWndDataType* )mir_alloc(sizeof(CntSetWndDataType));
+ wndData->hContact = hContact = (HANDLE)lParam;
+ wndData->hRename = LoadSkinnedIcon(SKINICON_OTHER_RENAME);
+ wndData->hUserDetail = LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS);
+ wndData->hFile = LoadSkinnedIcon(SKINICON_EVENT_FILE);
+ wndData->hSrchAll = LoadSkinnedIcon(SKINICON_OTHER_SEARCHALL);
+
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)wndData);
+
+ // set button images
+ SendDlgItemMessage(hwndDlg, IDC_GETNAME, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename);
+ SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hUserDetail);
+ SendDlgItemMessage(hwndDlg, IDC_BROWSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hFile);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW1, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hSrchAll);
+ SendDlgItemMessage(hwndDlg, IDC_RESET1, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW2, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hSrchAll);
+ SendDlgItemMessage(hwndDlg, IDC_RESET2, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename);
+
+ // make all buttons flat
+ SendDlgItemMessage(hwndDlg, IDC_GETNAME, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BROWSE, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW1, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_RESET1, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW2, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_RESET2, BUTTONSETASFLATBTN, TRUE, 0);
+
+ // set tooltip for the buttons
+ SendDlgItemMessage(hwndDlg, IDC_GETNAME, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Get city name from ID"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Weather INI information"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BROWSE, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Browse"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW1, BUTTONADDTOOLTIP, (WPARAM) LPGENT("View webpage"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_RESET1, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Reset to default"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW2, BUTTONADDTOOLTIP, (WPARAM) LPGENT("View webpage"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_RESET2, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Reset to default"), BATF_TCHAR);
+
+ // save the handle for the contact
+ WindowList_Add(hWindowList, hwndDlg, hContact);
+
+ // start to get the settings
+ // if the setting not exist, leave the dialog box blank
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_ID, dbv.ptszVal);
+ // check if the station is a default station
+ CheckDlgButton(hwndDlg, IDC_DEFA, _tcscmp(dbv.ptszVal, opt.Default) != 0);
+ db_free(&dbv);
+ }
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_NAME, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Log", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_LOG, dbv.ptszVal);
+ // if the log path is not empty, check the checkbox for external log
+ if (dbv.ptszVal[0]) CheckDlgButton(hwndDlg, IDC_External, TRUE);
+ db_free(&dbv);
+ }
+ // enable/disable the browse button depending on the value of external log checkbox
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External));
+
+ // other checkbox options
+ CheckDlgButton(hwndDlg, IDC_DPop, db_get_b(hContact, WEATHERPROTONAME, "DPopUp", FALSE));
+ CheckDlgButton(hwndDlg, IDC_DAutoUpdate, db_get_b(hContact, WEATHERPROTONAME, "DAutoUpdate", FALSE));
+ CheckDlgButton(hwndDlg, IDC_Internal, db_get_b(hContact, WEATHERPROTONAME, "History", 0));
+
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "InfoURL", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_IURL, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "MapURL", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_MURL, dbv.ptszVal);
+ db_free(&dbv);
+ }
+
+ // display the dialog box and free memory
+ Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, WEATHERPROTONAME, "EditSetting_");
+ ShowWindow(hwndDlg, SW_SHOW);
+ break;
+
+ case WM_COMMAND:
+ wndData = (CntSetWndDataType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ hContact = wndData ? wndData->hContact : NULL;
+
+ switch(LOWORD(wParam)) {
+ case IDC_ID:
+ // check if there are 2 parts in the ID (svc/id) seperated by "/"
+ // if not, don't let user change the setting
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
+ chop = _tcsstr(str, _T("/"));
+ if (chop == NULL)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), FALSE);
+ else
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), TRUE);
+ break;
+
+ case IDC_NAME:
+ // check if station name is entered
+ // if not, don't let user change the setting
+ GetDlgItemText(hwndDlg, IDC_NAME, str, SIZEOF(str));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), str[0] != 0);
+ break;
+
+ case IDC_GETNAME:
+ {
+ // the button for getting station name from the internet
+ // this function uses the ID search for add/find weather station
+
+ if ( !CheckSearch()) return TRUE; // don't download if update is in progress
+ // get the weather update data using the string in the ID field
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
+ GetSvc(str);
+ WIDATA *sData = GetWIData(str);
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
+ GetID(str);
+ // if ID search is available, do it
+ if (sData->IDSearch.Available) {
+ TCHAR *szData = NULL;
+
+ // load the page
+ wsprintfA(loc, sData->IDSearch.SearchURL, str);
+ str[0] = 0;
+ if (InternetDownloadFile(loc, NULL, &szData) == 0) {
+ TCHAR *szInfo = szData;
+ TCHAR* search = _tcsstr(szInfo, sData->IDSearch.NotFoundStr);
+
+ // if the page is found (ie. valid ID), get the name of the city
+ if (search == NULL)
+ GetDataValue(&sData->IDSearch.Name, str, &szInfo);
+
+ // free memory
+ mir_free(szData);
+ }
+ NetlibHttpDisconnect();
+ }
+ // give no station name but only ID if the search is unavailable
+ if (str[0] != 0) SetDlgItemText(hwndDlg, IDC_NAME, str);
+ break;
+ }
+ case IDC_External:
+ // enable/disable the borwse button depending if the external log is enabled
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External));
+ if ( !(BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) return TRUE;
+
+ case IDC_BROWSE: // fall through
+ // browse for the external log file
+ GetDlgItemText(hwndDlg, IDC_LOG, str, SIZEOF(str));
+ // Initialize OPENFILENAME
+ ZeroMemory(&ofn, sizeof(OPENFILENAME));
+ ofn.lStructSize = sizeof(OPENFILENAME);
+ ofn.hwndOwner = hwndDlg;
+ ofn.lpstrFile = str;
+ ofn.nMaxFile = SIZEOF(str);
+ // set filters
+ _tcscpy(filter, TranslateT("Text Files"));
+ _tcscat(filter, _T(" (*.txt)"));
+ pfilter = filter + _tcslen(filter)+1;
+ _tcscpy(pfilter, _T("*.txt"));
+ pfilter = pfilter + _tcslen(pfilter)+1;
+ _tcscpy(pfilter, TranslateT("All Files"));
+ _tcscat(pfilter, _T(" (*.*)"));
+ pfilter = pfilter + _tcslen(pfilter)+1;
+ _tcscpy(pfilter, _T("*.*"));
+ pfilter = pfilter + _tcslen(pfilter)+1;
+ *pfilter = '\0';
+ ofn.lpstrFilter = filter;
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFileTitle = NULL;
+ ofn.nMaxFileTitle = 0;
+ ofn.lpstrInitialDir = NULL;
+ ofn.Flags = OFN_PATHMUSTEXIST;
+
+ // Display a Open dialog box and put the file name on the dialog
+ if (GetOpenFileName(&ofn))
+ SetDlgItemText(hwndDlg, IDC_LOG, ofn.lpstrFile);
+ // if there is no log file specified, disable external logging
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), ofn.lpstrFile[0] != 0);
+ break;
+
+ case IDC_VIEW1:
+ // view the page for more info
+ GetDlgItemText(hwndDlg, IDC_IURL, str, SIZEOF(str));
+ if (str[0] == 0) return TRUE;
+ GetDlgItemText(hwndDlg, IDC_ID, str2, SIZEOF(str2));
+ OpenUrl(str, str2);
+ break;
+
+ case IDC_VIEW2:
+ // view the page for weather map
+ GetDlgItemText(hwndDlg, IDC_MURL, str, SIZEOF(str));
+ if (str[0] == 0) return TRUE;
+ GetDlgItemText(hwndDlg, IDC_ID, str2, SIZEOF(str2));
+ OpenUrl(str, str2);
+ break;
+
+ case IDC_RESET1:
+ // reset the more info url to service default
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
+ GetSvc(str);
+ sData = GetWIData(str);
+ SetDlgItemTextA(hwndDlg, IDC_IURL, sData->DefaultURL);
+ break;
+
+ case IDC_RESET2:
+ // reset the weathe map url to service default
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
+ GetSvc(str);
+ sData = GetWIData(str);
+ SetDlgItemText(hwndDlg, IDC_MURL, sData->DefaultMap);
+ break;
+
+ case IDC_SVCINFO:
+ // display the information of the ini file used by the weather station
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
+ GetSvc(str);
+ GetINIInfo(str);
+ break;
+
+ case IDC_CHANGE:
+ // temporary disable the protocol while applying the change
+ // start writing the new settings to database
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
+ db_set_ts(hContact, WEATHERPROTONAME, "ID", str);
+ if ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_DEFA)) { // if default station is set
+ _tcscpy(opt.Default, str);
+ opt.DefStn = hContact;
+ db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ }
+ GetDlgItemText(hwndDlg, IDC_NAME, city, SIZEOF(city));
+ db_set_ts(hContact, WEATHERPROTONAME, "Nick", city);
+ wsprintf(str2, TranslateT("Current weather information for %s."), city);
+ if ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) {
+ GetDlgItemText(hwndDlg, IDC_LOG, str, SIZEOF(str));
+ db_set_ts(hContact, WEATHERPROTONAME, "Log", str);
+ }
+ else db_unset(hContact, WEATHERPROTONAME, "Log");
+
+ GetDlgItemText(hwndDlg, IDC_IURL, str, SIZEOF(str));
+ db_set_ts(hContact, WEATHERPROTONAME, "InfoURL", str);
+
+ GetDlgItemText(hwndDlg, IDC_MURL, str, SIZEOF(str));
+ db_set_ts(hContact, WEATHERPROTONAME, "MapURL", str);
+ db_set_w(hContact, WEATHERPROTONAME, "Status", ID_STATUS_OFFLINE);
+ db_set_w(hContact, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE);
+ AvatarDownloaded(hContact);
+ db_set_ts(hContact, WEATHERPROTONAME, "About", str2);
+ db_set_b(hContact, WEATHERPROTONAME, "History", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_Internal));
+ db_set_b(hContact, WEATHERPROTONAME, "Overwrite", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_Overwrite));
+ db_set_b(hContact, WEATHERPROTONAME, "File", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External));
+ db_set_b(hContact, WEATHERPROTONAME, "DPopUp", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DPop));
+ db_set_b(hContact, WEATHERPROTONAME, "DAutoUpdate", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DAutoUpdate));
+
+ // re-enable the protocol and update the data for the station
+ db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None");
+ UpdateSingleStation((WPARAM)hContact, 0);
+
+ case IDCANCEL: // fall through
+ // remove the dialog from window list and close it
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ break;
+
+ case WM_CLOSE:
+ // remove the dialog from window list and close it
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ wndData = (CntSetWndDataType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Skin_ReleaseIcon(wndData->hFile);
+ Skin_ReleaseIcon(wndData->hRename);
+ Skin_ReleaseIcon(wndData->hSrchAll);
+ Skin_ReleaseIcon(wndData->hUserDetail);
+ mir_free(wndData);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
+
+ WindowList_Remove(hWindowList, hwndDlg);
+ Utils_SaveWindowPosition(hwndDlg, NULL, WEATHERPROTONAME, "EditSetting_");
+ break;
+ }
+ return FALSE;
+}
+
+//============ CONTACT DELETION ============
+
+// when a contact is deleted, make sure some other contact take over the default station
+// wParam = deleted contact
+int ContactDeleted(WPARAM wParam, LPARAM lParam)
+{
+ if ( !IsMyContact((HANDLE)wParam))
+ return 0;
+
+ removeWindow((HANDLE)wParam);
+
+ // exit this function if it is not default station
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingTString((HANDLE)wParam, WEATHERPROTONAME, "ID", &dbv)) {
+ if ( _tcscmp(dbv.ptszVal, opt.Default)) {
+ db_free(&dbv);
+ return 0;
+ }
+ db_free(&dbv);
+ }
+
+ // now the default station is deleted, try to get a new one
+
+ // start looking for other weather stations
+ HANDLE hContact = db_find_first();
+ while(hContact) {
+ if (IsMyContact(hContact)) {
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ // if the station is not a default station, set it as the new default station
+ // this is the first weather station encountered from the search
+ if ( _tcscmp(opt.Default, dbv.ptszVal)) {
+ _tcscpy(opt.Default, dbv.ptszVal);
+ opt.DefStn = hContact;
+ db_free(&dbv);
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ TCHAR str[255];
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ db_free(&dbv);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
+ }
+ db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ return 0; // exit this function quickly
+ }
+ db_free(&dbv);
+ }
+ }
+ hContact = db_find_next(hContact);
+ }
+ // got here if no more weather station left
+ opt.Default[0] = 0; // no default station
+ opt.DefStn = NULL;
+ db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ return 0;
+}
+
+BOOL IsMyContact(HANDLE hContact)
+{
+ const char* szProto = GetContactProto(hContact);
+ return szProto != NULL && strcmp(WEATHERPROTONAME, szProto) == 0;
+}
diff --git a/plugins/Weather/src/weather_conv.cpp b/plugins/Weather/src/weather_conv.cpp new file mode 100644 index 0000000000..780253b8ac --- /dev/null +++ b/plugins/Weather/src/weather_conv.cpp @@ -0,0 +1,644 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+This file contain the source related unit conversion, icon assignment,
+string conversions, display text parsing, etc
+*/
+
+#include "weather.h"
+
+//============ SOME HELPER FUNCTIONS ============
+
+// see if a string is a number
+// s = the string to be determined
+// return value = true if the string is a number, false if it isn't
+BOOL is_number(TCHAR *s)
+{
+ BOOL tag = FALSE;
+ // looking character by character
+ // for a number: numerous spaces in front, then optional +/-, then the number
+ // don't care anything that comes after it
+ while(*s != '\0')
+ {
+ if (*s >= '0' && *s <= '9') return TRUE;
+ else if (*s == ' ');
+ else if (*s != '+' && *s != '-') return FALSE;
+ else if ((*s == '+' || *s == '-') && !tag) tag = TRUE;
+ else return FALSE;
+ s++;
+ }
+ return FALSE;
+}
+
+static void numToStr(double num, TCHAR* str)
+{
+ int i = (int)(num * (opt.NoFrac ? 10 : 100));
+ int u = abs(i);
+
+ int r = u % 10;
+ int w = u / 10 + (r >= 5);
+
+ if (opt.NoFrac)
+ r = 0;
+ else {
+ r = w % 10;
+ w /= 10;
+ }
+
+ if (i < 0 && (w || r)) *(str++) = '-';
+ if (r)
+ wsprintf(str, _T("%i.%i"), w, r);
+ else
+ wsprintf(str, _T("%i"), w);
+}
+
+//============ UNIT CONVERSIONS ============
+
+// temperature conversion
+// tempchar = the string containing the temperature value
+// unit = the unit for temperature
+// return value = the converted temperature with degree sign and unit; if fails, return N/A
+void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
+{
+ // unit can be C, F
+ double temp;
+ TCHAR tstr[20];
+
+ TrimString(tempchar);
+ if (tempchar[0] == '-' && tempchar[1] == ' ')
+ memmove(&tempchar[1], &tempchar[2], sizeof(TCHAR)*(_tcslen(&tempchar[2])+1));
+
+ // quit if the value obtained is N/A or not a number
+ if ( !_tcscmp(tempchar, NODATA) || !_tcscmp(tempchar, _T("N/A"))) {
+ _tcscpy(str, tempchar);
+ return;
+ }
+ if ( !is_number(tempchar)) {
+ _tcscpy(str, NODATA);
+ return;
+ }
+
+ // convert the string to an integer
+ temp = _ttof(tempchar);
+
+ // convert all to F first
+ if ( !_tcsicmp(unit, _T("C"))) temp = (temp*9/5)+32;
+ else if ( !_tcsicmp(unit, _T("K"))) temp = ((temp-273.15)*9/5)+32;
+
+ // convert to apporiate unit
+ switch (opt.tUnit) {
+ case 1:
+ // rounding
+ numToStr((temp-32)/9*5, tstr);
+ if (opt.DoNotAppendUnit)
+ wsprintf(str, _T("%s"), tstr);
+ else
+ wsprintf(str, _T("%s%sC"), tstr, opt.DegreeSign);
+ break;
+
+ case 2:
+ numToStr(temp, tstr);
+ if (opt.DoNotAppendUnit)
+ wsprintf(str, _T("%s"), tstr);
+ else
+ wsprintf(str, _T("%s%sF"), tstr, opt.DegreeSign);
+ break;
+ }
+}
+
+// temperature conversion
+// tempchar = the string containing the pressure value
+// unit = the unit for pressure
+// return value = the converted pressure with unit; if fail, return the original string
+void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
+{
+ // unit can be kPa, hPa, mb, in, mm, torr
+ double tempunit = 0, output;
+ int intunit;
+
+ // convert the string to a floating point number (always positive)
+ // if it end up with 0, then it's not a number, return the original string and quit
+ output = _ttof(tempchar);
+ if (output == 0) {
+ _tcscpy(str, tempchar);
+ return;
+ }
+
+ // convert all to mb first
+ if ( !_tcsicmp(unit, _T("KPA")))
+ tempunit = (double)output * 10;
+ else if ( !_tcsicmp(unit, _T("HPA")))
+ tempunit = (double)output;
+ else if ( !_tcsicmp(unit, _T("MB")))
+ tempunit = (double)output;
+ else if ( !_tcsicmp(unit, _T("IN")))
+ tempunit = (double)output * 33.86388;
+ else if ( !_tcsicmp(unit, _T("MM")))
+ tempunit = (double)output * 1.33322;
+ else if ( !_tcsicmp(unit, _T("TORR")))
+ tempunit = (double)output * 1.33322;
+
+ // convert to apporiate unit
+ switch (opt.pUnit) {
+ case 1:
+ intunit = (int)(tempunit + 0.5);
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa"));
+ break;
+ case 2:
+ intunit = (int)(tempunit + 0.5);
+ wsprintf(str, _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb"));
+ break;
+ case 3:
+ intunit = (int)((tempunit*10 / 33.86388) + 0.5);
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in"));
+ break;
+ case 4:
+ intunit = (int)((tempunit*10 / 1.33322) + 0.5);
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm"));
+ break;
+ default:
+ _tcscpy(str, tempchar);
+ break;
+
+ }
+}
+
+// speed conversion
+// tempchar = the string containing the speed value
+// unit = the unit for speed
+// return value = the converted speed with unit; if fail, return _T(""
+void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
+{
+ // unit can be km/h, mph, m/s, knots
+ double tempunit;
+ TCHAR tstr[20];
+
+ str[0] = 0;
+
+ // convert the string into an integer (always positive)
+ // if the result is 0, then the string is not a number, return _T(""
+ tempunit = _ttof(tempchar);
+ if (tempunit == 0 && tempchar[0] != '0')
+ return;
+
+ // convert all to m/s first
+ if ( !_tcsicmp(unit, _T("KM/H")))
+ tempunit /= 3.6;
+// else if ( !_tcsicmp(unit, _T("M/S"))
+// tempunit = tempunit;
+ else if ( !_tcsicmp(unit, _T("MPH")))
+ tempunit *= 0.44704;
+ else if ( !_tcsicmp(unit, _T("KNOTS")))
+ tempunit *= 0.514444;
+
+ // convert to apporiate unit
+ switch (opt.wUnit) {
+ case 1:
+ numToStr(tempunit * 3.6, tstr);
+ wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h"));
+ break;
+ case 2:
+ numToStr(tempunit, tstr);
+ wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s"));
+ break;
+ case 3:
+ numToStr(tempunit / 0.44704, tstr);
+ wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph"));
+ break;
+ case 4:
+ numToStr(tempunit / 0.514444, tstr);
+ wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots"));
+ break;
+ }
+}
+
+// distance conversion
+// tempchar = the string containing the distance value
+// unit = the unit for distance
+// return value = the converted distance with unit; if fail, return original string
+void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
+{
+ // unit can be km, miles
+ double tempunit = 0, output;
+ int intunit;
+
+ // convert the string to a floating point number (always positive)
+ // if it end up with 0, then it's not a number, return the original string and quit
+ output = _ttof(tempchar);
+ if (output == 0) {
+ _tcscpy(str, tempchar);
+ return;
+ }
+
+ // convert all to km first
+ if ( !_tcsicmp(unit, _T("KM")))
+ tempunit = (double)output;
+ else if ( !_tcsicmp(unit, _T("MILES")))
+ tempunit = (double)output * 1.609;
+
+ // convert to apporiate unit
+ switch (opt.vUnit) {
+ case 1:
+ intunit = (int)((tempunit*10) + 0.5);
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("km"));
+ break;
+ case 2:
+ intunit = (int)((tempunit*10 / 1.609) + 0.5);
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles"));
+ break;
+ default:
+ _tcscpy(str, tempchar);
+ break;
+ }
+}
+
+// elevation conversion
+// tempchar = the string containing the elevation value
+// unit = the unit for elevation
+// return value = the converted elevation with unit; if fail, return original string
+void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
+{
+ // unit can be ft, m
+ double tempunit = 0, output;
+ int intunit;
+
+ // convert the string to a floating point number (always positive)
+ // if it end up with 0, then it's not a number, return the original string and quit
+ output = _ttof(tempchar);
+ if (output == 0) {
+ _tcscpy(str, tempchar);
+ return;
+ }
+
+ // convert all to m first
+ if ( !_tcsicmp(unit, _T("M")))
+ tempunit = (double)output;
+ else if ( !_tcsicmp(unit, _T("FT")))
+ tempunit = (double)output / 3.28;
+
+ // convert to apporiate unit
+ switch (opt.eUnit) {
+ case 1:
+ intunit = (int)((tempunit*10 * 3.28) + 0.5);
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft"));
+ break;
+ case 2:
+ intunit = (int)((tempunit*10) + 0.5);
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m"));
+ break;
+ default:
+ _tcscpy(str, tempchar);
+ break;
+ }
+}
+
+//============ CONDITION ICON ASSIGNMENT ============
+
+// assign the contact icon (status) from the condition string
+// the description may be different between different sources
+// cond = the string for weather condition
+// return value = status for the icon (ONLINE, OFFLINE, etc)
+
+static const TCHAR *statusStr[10] = { _T("Lightning"), _T("Fog"), _T("Snow Shower"), _T("Snow"), _T("Rain Shower"), _T("Rain"), _T("Partly Cloudy"), _T("Cloudy"), _T("Sunny"), _T("N/A") };
+static const WORD statusValue[10] = { LIGHT, FOG, SSHOWER, SNOW, RSHOWER, RAIN, PCLOUDY, CLOUDY, SUNNY, NA };
+
+WORD GetIcon(const TCHAR* cond, WIDATA *Data)
+{
+ int i;
+
+ // set the icon using ini
+ for (i=0; i<10; i++)
+ if ( IsContainedInCondList(cond, &Data->CondList[i]))
+ return statusValue[i];
+
+ // internal detection
+ if (
+ _tcsstr(cond, _T("mainy sunny")) != NULL ||
+ _tcsstr(cond, _T("mainy clear")) != NULL ||
+ _tcsstr(cond, _T("partly cloudy")) != NULL ||
+ _tcsstr(cond, _T("mostly")) != NULL ||
+ _tcsstr(cond, _T("clouds")) != NULL) {
+ return PCLOUDY;
+ }
+ else if (
+ _tcsstr(cond, _T("sunny")) != NULL ||
+ _tcsstr(cond, _T("clear")) != NULL ||
+ _tcsstr(cond, _T("fair")) != NULL) {
+ return SUNNY;
+ }
+ else if (
+ _tcsstr(cond, _T("thunder")) != NULL ||
+ _tcsstr(cond, _T("t-storm")) != NULL) {
+ return LIGHT;
+ }
+ else if (
+ _tcsstr(cond, _T("cloud")) != NULL ||
+ _tcsstr(cond, _T("overcast")) != NULL) {
+ return CLOUDY;
+ }
+ else if (
+ _tcsstr(cond, _T("fog")) != NULL ||
+ _tcsstr(cond, _T("mist")) != NULL ||
+ _tcsstr(cond, _T("smoke")) != NULL ||
+ _tcsstr(cond, _T("sand")) != NULL ||
+ _tcsstr(cond, _T("dust")) != NULL ||
+ _tcsstr(cond, _T("haze")) != NULL) {
+ return FOG;
+ }
+ else if (
+ (_tcsstr(cond, _T("shower")) != NULL && _tcsstr(cond, _T("snow")) != NULL) ||
+ _tcsstr(cond, _T("flurries")) != NULL) {
+ return SSHOWER;
+ }
+ else if (
+ _tcsstr(cond, _T("rain shower")) != NULL ||
+ _tcsstr(cond, _T("shower")) != NULL)
+ {
+ return RSHOWER;
+ }
+ else if (
+ _tcsstr(cond, _T("snow")) != NULL ||
+ _tcsstr(cond, _T("ice")) != NULL ||
+ _tcsstr(cond, _T("freezing")) != NULL ||
+ _tcsstr(cond, _T("wintry")) != NULL) {
+ return SNOW;
+ }
+ else if (
+ _tcsstr(cond, _T("drizzle")) != NULL ||
+ _tcsstr(cond, _T("rain")) != NULL)
+ {
+ return RAIN;
+ }
+
+ // set the icon using langpack
+ for (i=0; i < 9; i++) {
+ TCHAR LangPackStr[64], LangPackStr1[128];
+ int j = 0;
+ do {
+ j++;
+ // using the format _T("# Weather <condition name> <counter> #"
+ mir_sntprintf(LangPackStr, SIZEOF(LangPackStr), _T("# Weather %s %i #"), statusStr[i], j);
+ mir_sntprintf(LangPackStr1, SIZEOF(LangPackStr1), _T("%s"), TranslateTS(LangPackStr));
+ CharLowerBuff(LangPackStr1, (DWORD)_tcslen(LangPackStr1));
+ if (_tcsstr(cond, LangPackStr1) != NULL)
+ return statusValue[i];
+ // loop until the translation string exists (ie, the translated string is differ from original)
+ }
+ while ( _tcscmp(TranslateTS(LangPackStr), LangPackStr));
+ }
+
+ return NA;
+}
+
+//============ STRING CONVERSIONS ============
+
+// this function convert the string to the format with 1 upper case followed by lower case char
+void CaseConv(TCHAR *str)
+{
+ TCHAR *pstr;
+ BOOL nextUp = TRUE;
+
+ CharLowerBuff(str, (DWORD)_tcslen(str));
+ for(pstr = str; *pstr; pstr++) {
+ if (*pstr == ' ' || *pstr == '-')
+ nextUp = TRUE;
+ else {
+ TCHAR ch = *(TCHAR*)pstr;
+ if (nextUp)
+ *pstr = ( TCHAR )CharUpper((LPTSTR)ch);
+ nextUp = FALSE;
+} } }
+
+// the next 2 functions are copied from miranda source
+// str = the string to modify
+
+void TrimString(char *str)
+{
+ size_t len, start;
+
+ len = strlen(str);
+ while(len && (unsigned char)str[len-1] <= ' ') str[--len] = 0;
+ for(start=0; (unsigned char)str[start] <= ' ' && str[start]; start++);
+ memmove(str, str+start, len-start+1);
+}
+
+void TrimString(WCHAR *str)
+{
+ size_t len, start;
+
+ len = wcslen(str);
+ while(len && (unsigned char)str[len-1] <= ' ') str[--len] = 0;
+ for(start=0; (unsigned char)str[start] <= ' ' && str[start]; start++);
+ memmove(str, str+start, (len-start+1)*sizeof(WCHAR));
+}
+
+// convert \t to tab and \n to linefeed
+void ConvertBackslashes(char *str)
+{
+ for (char *pstr=str; *pstr; pstr = CharNextA(pstr)) {
+ if (*pstr == '\\') {
+ switch(pstr[1]) {
+ case 'n': *pstr = '\n'; break;
+ case 't': *pstr = '\t'; break;
+ default: *pstr = pstr[1]; break;
+ }
+ memmove(pstr+1, pstr+2, strlen(pstr+2)+1);
+} } }
+
+// replace spaces with _T("%20"
+// dis = original string
+// return value = the modified string with space -> _T("%20"
+char *GetSearchStr(char *dis)
+{
+ char *pstr = dis;
+ size_t len = strlen(dis);
+ while (*pstr != 0)
+ {
+ if (*pstr == ' ')
+ {
+ memmove(pstr+3, pstr+1, len);
+ memcpy(pstr, _T("%20"), 3);
+ pstr += 2;
+ }
+ pstr++;
+ len--;
+ }
+ return dis;
+}
+
+//============ ICON ASSIGNMENT ============
+
+// make display and history strings
+// w = WEATHERINFO data to be parsed
+// dis = the string to parse
+// return value = the parsed string
+TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str)
+{
+ TCHAR lpzDate[32], chr;
+ char name[256], temp[2];
+ DBVARIANT dbv;
+ size_t i;
+
+ // Clear the string
+ str[0] = 0;
+
+ // looking character by character
+ for (i=0; i < _tcslen(dis); i++) {
+ // for the escape characters
+ if (dis[i] == '\\') {
+ i++;
+ chr = dis[i];
+ switch (chr) {
+ case '%': _tcscat(str, _T("%")); break;
+ case 't': _tcscat(str, _T("\t")); break;
+ case 'n': _tcscat(str, _T("\r\n")); break;
+ case '\\': _tcscat(str, _T("\\")); break;
+ }
+ }
+
+ // for the % varaibles
+ else if (dis[i] == '%')
+ {
+ i++;
+ chr = dis[i];
+ // turn capitalized characters to small case
+ if (chr < 'a' && chr != '[' && chr != '%') chr = (char)((int)chr + 32);
+ switch (chr) {
+ case 'c': _tcscat(str, w->cond); break;
+ case 'd': // get the current date
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, lpzDate, SIZEOF(lpzDate));
+ _tcscat(str, lpzDate); break;
+ case 'e': _tcscat(str, w->dewpoint); break;
+ case 'f': _tcscat(str, w->feel); break;
+ case 'h': _tcscat(str, w->high); break;
+ case 'i': _tcscat(str, w->winddir); break;
+ case 'l': _tcscat(str, w->low); break;
+ case 'm': _tcscat(str, w->humid); break;
+ case 'n': _tcscat(str, w->city); break;
+ case 'p': _tcscat(str, w->pressure); break;
+ case 'r': _tcscat(str, w->sunrise); break;
+ case 's': _tcscat(str, w->id); break;
+ case 't': _tcscat(str, w->temp); break;
+ case 'u':
+ if (_tcscmp(w->update, NODATA)) _tcscat(str, w->update);
+ else _tcscat(str, TranslateT("<unknown time>"));
+ break;
+ case 'v': _tcscat(str, w->vis); break;
+ case 'w': _tcscat(str, w->wind); break;
+ case 'y': _tcscat(str, w->sunset); break;
+ case '%': _tcscat(str, _T("%")); break;
+ case '[': // custom variables
+ i++;
+ name[0] = 0;
+ // read the entire variable name
+ while (dis[i] != ']' && i < _tcslen(dis)) {
+ wsprintfA(temp, "%c", dis[i++]);
+ strcat(name, temp);
+ }
+ // access the database to get its value
+ if ( !DBGetContactSettingTString(w->hContact, WEATHERCONDITION, name, &dbv)) {
+ if (dbv.ptszVal != TranslateTS(NODATA) && dbv.ptszVal != TranslateT("<Error>"))
+ _tcscat(str, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ break;
+ }
+ }
+ // if the character is not a variable, write the original character to the new string
+ else {
+ wsprintf( lpzDate, _T("%c"), dis[i]);
+ _tcscat(str, lpzDate);
+ } }
+
+ return str;
+}
+
+TCHAR svcReturnText[MAX_TEXT_SIZE];
+INT_PTR GetDisplaySvcFunc(WPARAM wParam, LPARAM lParam)
+{
+ WEATHERINFO winfo = LoadWeatherInfo((HANDLE)wParam);
+ return (INT_PTR)GetDisplay(&winfo, (TCHAR*)lParam, svcReturnText);
+}
+
+//============ ID MANAGEMENT ============
+
+// get service data module internal name
+// mod/id <- the mod part
+// pszID = original 2-part id, return the service internal name
+void GetSvc(TCHAR *pszID)
+{
+ TCHAR *chop = _tcsstr(pszID, _T("/"));
+ if (chop != NULL) *chop = '\0';
+ else pszID[0] = 0;
+}
+
+// get the id use for update without the service internal name
+// mod/id <- the id part
+// pszID = original 2-part id, return the single part id
+void GetID(TCHAR *pszID)
+{
+ TCHAR *chop = _tcsstr(pszID, _T("/"));
+ if (chop != NULL) _tcscpy(pszID, chop+1);
+ else pszID[0] = 0;
+}
+
+//============ WEATHER ERROR CODE ============
+
+// Get the text when an error code is specified
+// code = the error code obtained when updating weather
+// str = the string for the error
+
+TCHAR *GetError(int code)
+{
+ TCHAR *str, str2[100];
+ switch (code) {
+ case 10: str = E10; break;
+ case 11: str = E11; break;
+ case 12: str = E12; break;
+ case 20: str = E20; break;
+ case 30: str = E30; break;
+ case 40: str = E40; break;
+ case 42: str = E42; break;
+ case 43: str = E43; break;
+ case 99: str = E99; break;
+ case 204: str = E204; break;
+ case 301: str = E301; break;
+ case 305: str = E305; break;
+ case 307: str = E307; break;
+ case 400: str = E400; break;
+ case 401: str = E401; break;
+ case 402: str = E402; break;
+ case 403: str = E403; break;
+ case 404: str = E404; break;
+ case 405: str = E405; break;
+ case 407: str = E407; break;
+ case 410: str = E410; break;
+ case 500: str = E500; break;
+ case 502: str = E502; break;
+ case 503: str = E503; break;
+ case 504: str = E504; break;
+ default:
+ mir_sntprintf(str2, SIZEOF(str2), TranslateT("HTTP Error %i"), code);
+ str = str2;
+ break;
+ }
+ return str;
+}
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp new file mode 100644 index 0000000000..5def028c3d --- /dev/null +++ b/plugins/Weather/src/weather_data.cpp @@ -0,0 +1,472 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+This file contain the source related loading, obtaining, and
+saving individual weather data for a weather contact.
+*/
+
+#include "weather.h"
+
+//============ LOAD WEATHER INFO FROM A CONTACT ============
+// get station ID from DB
+// hContact = the current contact handle
+// return value = the string for station ID
+
+void GetStationID(HANDLE hContact, TCHAR* id, size_t idlen)
+{
+ // accessing the database
+ if ( DBGetStaticString(hContact, WEATHERPROTONAME, "ID", id, idlen))
+ id[0] = 0;
+}
+
+// initialize weather info by loading values from database
+// hContact = current contact handle
+// return value = the current weather information in WEATHERINFO struct
+WEATHERINFO LoadWeatherInfo(HANDLE hContact)
+{
+ // obtaining values from the DB
+ // assuming station ID must exist at all time, but others does not have to
+ // if the string is not found in database, a value of "N/A" is stored in the field
+ WEATHERINFO winfo;
+ winfo.hContact = hContact;
+ GetStationID(hContact, winfo.id, SIZEOF(winfo.id));
+
+ if ( DBGetStaticString(hContact, WEATHERPROTONAME, "Nick", winfo.city, SIZEOF(winfo.city)))
+ _tcscpy(winfo.city, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Update", winfo.update, SIZEOF(winfo.update)))
+ _tcscpy(winfo.update, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Condition", winfo.cond, SIZEOF(winfo.cond)))
+ _tcscpy(winfo.cond, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Temperature", winfo.temp, SIZEOF(winfo.temp)))
+ _tcscpy(winfo.temp, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "High", winfo.high, SIZEOF(winfo.high)))
+ _tcscpy(winfo.high, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Low", winfo.low, SIZEOF(winfo.low)))
+ _tcscpy(winfo.low, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Sunset", winfo.sunset, SIZEOF(winfo.sunset)))
+ _tcscpy(winfo.sunset, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Sunrise", winfo.sunrise, SIZEOF(winfo.sunrise)))
+ _tcscpy(winfo.sunrise, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Wind Speed", winfo.wind, SIZEOF(winfo.wind)))
+ _tcscpy(winfo.wind, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Wind Direction", winfo.winddir, SIZEOF(winfo.winddir)))
+ _tcscpy(winfo.winddir, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, SIZEOF(winfo.dewpoint)))
+ _tcscpy(winfo.dewpoint, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Pressure", winfo.pressure, SIZEOF(winfo.pressure)))
+ _tcscpy(winfo.pressure, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Visibility", winfo.vis, SIZEOF(winfo.vis)))
+ _tcscpy(winfo.vis, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Humidity", winfo.humid, SIZEOF(winfo.humid)))
+ _tcscpy(winfo.humid, NODATA);
+ if ( DBGetStaticString(hContact, WEATHERCONDITION, "Feel", winfo.feel, SIZEOF(winfo.feel)))
+ _tcscpy(winfo.feel, NODATA);
+
+ winfo.status = (WORD)db_get_w(hContact, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE);
+ return winfo;
+}
+
+// getting weather setting from database
+// return 0 on success
+int DBGetData(HANDLE hContact, char *setting, DBVARIANT *dbv)
+{
+ if ( DBGetContactSettingTString(hContact, WEATHERCONDITION, setting, dbv)) {
+ size_t len = strlen(setting) + 1;
+ char *set = (char*)alloca(len + 1);
+ *set = '#';
+ memcpy(set + 1, setting, len);
+
+ if ( DBGetContactSettingTString(hContact, WEATHERCONDITION, set, dbv))
+ return 1;
+ }
+ return 0;
+}
+
+int DBGetStaticString(HANDLE hContact, const char *szModule, const char *valueName, TCHAR *dest, size_t dest_len)
+{
+ DBVARIANT dbv;
+ if ( DBGetContactSettingTString( hContact, szModule, valueName, &dbv ))
+ return 1;
+
+ _tcsncpy( dest, dbv.ptszVal, dest_len );
+ dest[ dest_len-1 ] = 0;
+ db_free( &dbv );
+ return 0;
+}
+
+
+//============ ERASE OLD SETTINGS ============
+
+// erase all current weather information from database
+// lastver = the last used version number in dword (using PLUGIN_MAKE_VERSION)
+void EraseAllInfo(DWORD lastver)
+{
+ TCHAR str[255];
+ int ContactCount = 0;
+ HANDLE LastContact = NULL;
+ DBVARIANT dbv;
+ // loop through all contacts
+ HANDLE hContact = db_find_first();
+ while(hContact) {
+ // see if the contact is a weather contact
+ if ( IsMyContact(hContact)) {
+ // check for upgrade
+ if (lastver < __VERSION_DWORD)
+ UpgradeContact(lastver, hContact);
+ db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE);
+ db_set_w(hContact,WEATHERPROTONAME, "StatusIcon",ID_STATUS_OFFLINE);
+ db_unset(hContact, "CList", "MyHandle");
+ // clear all data
+ if ( DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("<Enter city name here>"));
+ db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never");
+ db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None");
+ db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None");
+ }
+ else db_free(&dbv);
+
+ DBDataManage(hContact, WDBM_REMOVE, 0, 0);
+ db_set_s(hContact, "UserInfo", "MyNotes", "");
+ // reset update tag
+ db_set_b(hContact,WEATHERPROTONAME, "IsUpdated",FALSE);
+ // reset logging settings
+ if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME, "Log", &dbv)) {
+ db_set_b(hContact,WEATHERPROTONAME, "File",(BYTE)(dbv.ptszVal[0] != 0));
+ db_free(&dbv);
+ }
+ else db_set_b(hContact,WEATHERPROTONAME, "File",FALSE);
+
+ // if no default station find, assign a new one
+ if (opt.Default[0] == 0) {
+ GetStationID(hContact, opt.Default, SIZEOF(opt.Default));
+
+ opt.DefStn = hContact;
+ if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME, "Nick",&dbv)) {
+ wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ db_free(&dbv);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ }
+ }
+ // get the handle of the default station
+ if (opt.DefStn == NULL) {
+ if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME, "ID",&dbv)) {
+ if ( !_tcscmp(dbv.ptszVal, opt.Default))
+ opt.DefStn = hContact;
+ db_free(&dbv);
+ }
+ }
+ ContactCount++; // increment counter
+ LastContact = hContact;
+ }
+ hContact = db_find_next(hContact);
+ }
+
+ // if weather contact exists, set the status to online so it is ready for update
+ // if (ContactCount != 0) status = ONLINE;
+ // in case where the default station is missing
+ if (opt.DefStn == NULL && ContactCount != 0) {
+ if ( !DBGetContactSettingTString(LastContact, WEATHERPROTONAME, "ID", &dbv)) {
+ _tcscpy(opt.Default, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ opt.DefStn = LastContact;
+ if ( !DBGetContactSettingTString(LastContact,WEATHERPROTONAME, "Nick",&dbv)) {
+ wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ db_free(&dbv);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ }
+ }
+ // save option in case of default station changed
+ db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
+}
+
+void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data)
+{
+ TCHAR str[MAX_DATA_LEN];
+
+ // convert the unit
+ if ( _tcscmp(Data, TranslateT("<Error>")) && _tcscmp(Data, NODATA) && _tcscmp(Data, TranslateTS(NODATA))) {
+ // temperature
+ if ( !_tcscmp(UpdateData->Name, _T("Temperature")) || !_tcscmp(UpdateData->Name, _T("High")) ||
+ !_tcscmp(UpdateData->Name, _T("Low")) || !_tcscmp(UpdateData->Name, _T("Feel")) ||
+ !_tcscmp(UpdateData->Name, _T("Dewpoint")) ||
+ !_tcsicmp(UpdateData->Unit, _T("C")) || !_tcsicmp(UpdateData->Unit, _T("F")) ||
+ !_tcsicmp(UpdateData->Unit, _T("K")))
+ {
+ GetTemp(Data, UpdateData->Unit, str);
+ _tcscpy(Data, str);
+ }
+ // pressure
+ else if ( !_tcscmp(UpdateData->Name, _T("Pressure")) || !_tcsicmp(UpdateData->Unit, _T("HPA")) ||
+ !_tcsicmp(UpdateData->Unit, _T("KPA")) || !_tcsicmp(UpdateData->Unit, _T("MB")) ||
+ !_tcsicmp(UpdateData->Unit, _T("TORR")) || !_tcsicmp(UpdateData->Unit, _T("IN")) ||
+ !_tcsicmp(UpdateData->Unit, _T("MM")))
+ {
+ GetPressure(Data, UpdateData->Unit, str);
+ _tcscpy(Data, str);
+ }
+ // speed
+ else if ( !_tcscmp(UpdateData->Name, _T("Wind Speed")) || !_tcsicmp(UpdateData->Unit, _T("KM/H")) ||
+ !_tcsicmp(UpdateData->Unit, _T("M/S")) || !_tcsicmp(UpdateData->Unit, _T("MPH")) ||
+ !_tcsicmp(UpdateData->Unit, _T("KNOTS")))
+ {
+ GetSpeed(Data, UpdateData->Unit, str);
+ _tcscpy(Data, str);
+ }
+ // visibility
+ else if ( !_tcscmp(UpdateData->Name, _T("Visibility")) || !_tcsicmp(UpdateData->Unit, _T("KM")) ||
+ !_tcsicmp(UpdateData->Unit, _T("MILES")))
+ {
+ GetDist(Data, UpdateData->Unit, str);
+ _tcscpy(Data, str);
+ }
+ // elevation
+ else if ( !_tcscmp(UpdateData->Name, _T("Elevation")) || !_tcsicmp(UpdateData->Unit, _T("FT")) ||
+ !_tcsicmp(UpdateData->Unit, _T("M")))
+ {
+ GetElev(Data, UpdateData->Unit, str);
+ _tcscpy(Data, str);
+ }
+ // converting case for condition to the upper+lower format
+ else if ( !_tcsicmp(UpdateData->Unit, _T("COND")))
+ CaseConv(Data);
+ // degree sign
+ else if ( !_tcsicmp(UpdateData->Unit, _T("DEG")))
+ {
+ if ( !opt.DoNotAppendUnit) _tcscat(Data, opt.DegreeSign);
+ }
+ // percent sign
+ else if ( !_tcsicmp(UpdateData->Unit, _T("%")))
+ {
+ if ( !opt.DoNotAppendUnit) _tcscat(Data, _T("%"));
+ }
+ // truncating strings for day/month to 2 or 3 characters
+ else if ( !_tcsicmp(UpdateData->Unit, _T("DAY")) || !_tcsicmp(UpdateData->Unit, _T("MONTH")))
+ if (opt.dUnit > 1 && _tcslen(Data) > opt.dUnit)
+ Data[opt.dUnit] = '\0';
+ }
+}
+
+//============ GET THE VALUE OF A DATAITEM ============
+
+// get the value of the data using the start, end strings
+// UpdateData = the WIDATAITEM struct containing start, end, unit
+// Data = the string containing weather data obtained from UpdateData
+// global var. used: szInfo = the downloaded string
+
+void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
+{
+ TCHAR last = 0, current, *start, *end;
+ unsigned startloc = 0, endloc = 0, respos = 0;
+ BOOL tag = FALSE, symb = FALSE;
+ TCHAR *szInfo = *szData;
+
+ Data[0] = 0;
+ // parse the data if available
+ if (UpdateData->Start[0] == 0 && UpdateData->End[0] == 0) return;
+ start = szInfo;
+ // the start string must be found
+ if (UpdateData->Start[0] != 0) {
+ start = _tcsstr(szInfo, UpdateData->Start);
+ if (start != NULL) {
+ // set the starting location for getting data
+ start += _tcslen(UpdateData->Start);
+ szInfo = start;
+ }
+ }
+ // the end string must be found too
+ if (UpdateData->End[0] != 0)
+ end = _tcsstr(szInfo, UpdateData->End);
+ else
+ end = _tcsstr(szInfo, _T(" "));
+
+ if (end != NULL) {
+ // set the ending location
+ startloc = 0;
+ endloc = end - szInfo;
+ end += _tcslen(UpdateData->End);
+ last = '\n';
+ }
+ // ignore if not both of the string found - this prevent crashes
+ if (start != NULL && end != NULL)
+ {
+ // begin reading the data from start location to end location
+ // remove all HTML tag in between, as well as leading space, ending space,
+ // multiple spaces, tabs, and return key
+ while (startloc < endloc)
+ {
+ if (szInfo[startloc] == '<') tag = TRUE;
+ else if (szInfo[startloc] == '&' &&
+ (szInfo[startloc+1] == ';' || szInfo[startloc+2] == ';' || szInfo[startloc+3] == ';' ||
+ szInfo[startloc+4] == ';' || szInfo[startloc+5] == ';' || szInfo[startloc+6] == ';'))
+ symb = TRUE;
+ else if (szInfo[startloc] == '>') tag = FALSE;
+ else if (szInfo[startloc] == ';') symb = FALSE;
+ else {
+ if ( !tag && !symb) {
+ current = szInfo[startloc];
+ if (current == '\n' || current == '\t' || current == ' ' || current == '\r')
+ current = ' ';
+ if (current != ' ' || last != ' ') {
+ if (last != '\n' && (respos != 0 || (respos == 0 && last != ' ')))
+ Data[respos++] = last;
+ last = current;
+ }
+ }
+ }
+ ++startloc;
+ // prevent crashes if the string go over maximun length -> generate an error
+ if (respos >= MAX_DATA_LEN) {
+ if (opt.ShowWarnings && UpdateData->Name[0] != 0 && _tcscmp(UpdateData->Name, _T("Ignore"))) {
+ mir_sntprintf(Data, MAX_DATA_LEN, TranslateT("Error when obtaining data: %s"), UpdateData->Name);
+ WPShowMessage(Data, SM_WARNING);
+ }
+ _tcsncpy(Data, TranslateT("<Error>"), MAX_DATA_LEN);
+ last = ' ';
+ respos = MAX_DATA_LEN - 1;
+ break;
+ }
+ }
+
+ // get the last character
+ if (last != ' ')
+ Data[respos++] = last;
+
+ // null terminate the string
+ Data[respos] = 0;
+
+ // convert the unit
+ ConvertDataValue(UpdateData, Data);
+
+ // remove the string before the data from szInfo
+ szInfo = end;
+ }
+ *szData = szInfo;
+}
+
+//============ ALLOCATE SPACE AND COPY STRING ============
+
+// copy a string into a new memory location
+// Data = the field the data is copied to
+// Value = the original string, the string where data is copied from
+void wSetData(char **Data, const char *Value)
+{
+ if (Value[0] != 0)
+ {
+ char *newData = (char*)mir_alloc(strlen(Value)+3);
+ strcpy(newData, Value);
+ *Data = newData;
+ }
+ else
+ *Data = "";
+}
+
+void wSetData(WCHAR **Data, const char *Value)
+{
+ if (Value[0] != 0)
+ *Data = mir_a2u( Value );
+ else
+ *Data = L"";
+}
+
+void wSetData(WCHAR **Data, const WCHAR *Value)
+{
+ if (Value[0] != 0) {
+ WCHAR *newData = (WCHAR*)mir_alloc( sizeof(WCHAR)*(wcslen(Value)+3));
+ wcscpy(newData, Value);
+ *Data = newData;
+ }
+ else *Data = L"";
+}
+
+// A safer free function that free memory for a string
+// Data = the string occuping the data to be freed
+void wfree(char **Data)
+{
+ if (*Data && strlen(*Data) > 0) mir_free(*Data);
+ *Data = NULL;
+}
+
+void wfree(WCHAR **Data)
+{
+ if (*Data && wcslen(*Data) > 0)
+ mir_free(*Data);
+ *Data = NULL;
+}
+
+//============ MANAGE THE ITEMS STORED IN DB ============
+// get single setting that is found
+// szSetting = the setting name
+// lparam = the counter
+int GetWeatherDataFromDB(const char *szSetting, LPARAM lparam)
+{
+ LIST<char> *pList = (LIST<char>*)lparam;
+ pList->insert( mir_strdup(szSetting));
+ return 0;
+}
+
+// remove or display the weather information for a contact
+// hContact - the contact in which the info is going to be removed
+
+void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam)
+{
+ LIST<char> arSettings(10);
+
+ // get all the settings and stored them in a temporary list
+ DBCONTACTENUMSETTINGS dbces;
+ dbces.lParam = (LPARAM)&arSettings;
+ dbces.pfnEnumProc = GetWeatherDataFromDB;
+ dbces.szModule = WEATHERCONDITION;
+ CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)hContact, (LPARAM)&dbces);
+
+ // begin deleting settings
+ for (int i=arSettings.getCount()-1; i >= 0; i--) {
+ char *szSetting = arSettings[i];
+
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingTString(hContact, WEATHERCONDITION, szSetting, &dbv)) {
+ switch (Mode) {
+ case WDBM_REMOVE:
+ db_unset(hContact, WEATHERCONDITION, szSetting);
+ break;
+
+ case WDBM_DETAILDISPLAY:
+ // skip the "WeatherInfo" variable
+ if ( !strcmp(szSetting, "WeatherInfo") || !strcmp(szSetting, "Ignore") || szSetting[0] == '#')
+ continue;
+ else {
+ HWND hList = GetDlgItem((HWND)wParam, IDC_DATALIST);
+ LV_ITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.lParam = i;
+ lvi.pszText = TranslateTS( _A2T(szSetting ));
+ lvi.iItem = ListView_InsertItem(hList, &lvi);
+ lvi.pszText = dbv.ptszVal;
+ ListView_SetItemText(hList, lvi.iItem, 1, dbv.ptszVal );
+ break;
+ }
+ }
+ db_free(&dbv);
+ }
+ mir_free(szSetting);
+ }
+ arSettings.destroy();
+}
diff --git a/plugins/Weather/src/weather_http.cpp b/plugins/Weather/src/weather_http.cpp new file mode 100644 index 0000000000..d9038db9c8 --- /dev/null +++ b/plugins/Weather/src/weather_http.cpp @@ -0,0 +1,206 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+This file contain the source related to downloading weather info
+from the web using netlib
+*/
+
+#include "weather.h"
+
+HANDLE hNetlibUser, hNetlibHttp;
+
+int findHeader(NETLIBHTTPREQUEST *nlhrReply, char *hdr)
+{
+ int res = -1, i;
+ for (i=0; i<nlhrReply->headersCount; i++)
+ {
+ if (_stricmp(nlhrReply->headers[i].szName, hdr) == 0)
+ {
+ res = i;
+ break;
+ }
+ }
+ return res;
+}
+
+//============ DOWNLOAD NEW WEATHER ============
+
+// function to download webpage from the internet
+// szUrl = URL of the webpage to be retrieved
+// return value = 0 for success, 1 or HTTP error code for failure
+// global var used: szData, szInfo = containing the retrieved data
+int InternetDownloadFile (char *szUrl, char* cookie, TCHAR** szData)
+{
+ int result = 0xBADBAD;
+ char* szRedirUrl = NULL;
+ NETLIBHTTPREQUEST nlhr = {0};
+ NETLIBHTTPHEADER headers[6];
+
+ // initialize the netlib request
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_PERSISTENT | NLHRF_REDIRECT;
+ nlhr.szUrl = szUrl;
+ nlhr.nlc = hNetlibHttp;
+
+ // change the header so the plugin is pretended to be IE 6 + WinXP
+ nlhr.headersCount = 5;
+ nlhr.headers = headers;
+ nlhr.headers[0].szName = "User-Agent";
+ nlhr.headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
+ nlhr.headers[1].szName = "Cache-Control";
+ nlhr.headers[1].szValue = "no-cache";
+ nlhr.headers[2].szName = "Pragma";
+ nlhr.headers[2].szValue = "no-cache";
+ nlhr.headers[3].szName = "Connection";
+ nlhr.headers[3].szValue = "close";
+ nlhr.headers[4].szName = "Cookie";
+ nlhr.headers[4].szValue = cookie;
+// nlhr.headers[5].szName = "If-Modified-Since";
+// nlhr.headers[5].szValue = "Tue, 24 Feb 2009 03:44:23 GMT";
+
+ if (cookie == NULL || cookie[0] == 0) --nlhr.headersCount;
+
+ while (result == 0xBADBAD) {
+ // download the page
+ NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,
+ (WPARAM)hNetlibUser, (LPARAM)&nlhr);
+
+ if (nlhrReply) {
+ // if the recieved code is 200 OK
+ if (nlhrReply->resultCode == 200) {
+ if (nlhrReply->dataLength) {
+ result = 0;
+ bool bIsUtf = false;
+
+ // allocate memory and save the retrieved data
+ int i = findHeader(nlhrReply, "Content-Type");
+ if (i != -1 && strstr(_strlwr((char*)nlhrReply->headers[i].szValue), "utf-8"))
+ bIsUtf = true;
+ else {
+ char* end = nlhrReply->pData;
+ for (;;) {
+ char* beg = strstr(end, "<meta");
+ if (beg == NULL) break;
+ else {
+ char* method, tmp;
+ end = strchr(beg, '>');
+ tmp = *end; *end = 0;
+
+ method = strstr(beg, "http-equiv=\"");
+ if (method && _strnicmp(method+12, "Content-Type", 12) == 0 && strstr(method, "utf-8")) {
+ bIsUtf = true;
+ break;
+ }
+ else *end = tmp;
+ } } }
+
+ if ( bIsUtf )
+ *szData = mir_utf8decodeT( nlhrReply->pData );
+ else
+ *szData = mir_a2t( nlhrReply->pData );
+
+ }
+ else result = DATA_EMPTY;
+ }
+ // if the recieved code is 302 Moved, Found, etc
+ // workaround for url forwarding
+ else if (nlhrReply->resultCode == 302 || nlhrReply->resultCode == 301 || nlhrReply->resultCode == 303 ) // page moved
+ {
+ // get the url for the new location and save it to szInfo
+ // look for the reply header "Location"
+ int i = findHeader(nlhrReply, "Location");
+
+ if (i != -1)
+ {
+ size_t rlen = 0;
+ if (nlhrReply->headers[i].szValue[0] == '/')
+ {
+ char* szPath;
+ char* szPref = strstr(szUrl, "://");
+ szPref = szPref ? szPref + 3 : szUrl;
+ szPath = strchr(szPref, '/');
+ rlen = szPath != NULL ? szPath - szUrl : strlen(szUrl);
+ }
+
+ szRedirUrl = (char*)mir_realloc(szRedirUrl,
+ rlen + strlen(nlhrReply->headers[i].szValue)*3 + 1);
+
+ strncpy(szRedirUrl, szUrl, rlen);
+ strcpy(szRedirUrl+rlen, nlhrReply->headers[i].szValue);
+
+ GetSearchStr(szRedirUrl);
+
+ nlhr.szUrl = szRedirUrl;
+ }
+ }
+ // return error code if the recieved code is neither 200 OK nor 302 Moved
+ else {
+ *szData = ( TCHAR* )mir_alloc(512);
+ // store the error code in szData
+ wsprintf(*szData, _T("Error occured! HTTP Error: %i\n"), nlhrReply->resultCode);
+ result = (int)nlhrReply->resultCode;
+ }
+
+ hNetlibHttp = nlhrReply->nlc;
+ // make a copy of the retrieved data, then free the memory of the http reply
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0, (LPARAM)nlhrReply);
+ }
+ // if the data does not downloaded successfully (ie. disconnected), then return 1000 as error code
+ else
+ {
+ *szData = ( TCHAR* )mir_alloc(512);
+ // store the error code in szData
+ _tcscpy(*szData, _T("NetLib error occurred!!"));
+ result = NETLIB_ERROR;
+ hNetlibHttp = NULL;
+ }
+
+ }
+
+ mir_free(szRedirUrl);
+
+ return result;
+}
+
+//============ NETLIB INITIALIZATION ============
+
+// initialize netlib support for weather protocol
+void NetlibInit(void)
+{
+ NETLIBUSER nlu = {0};
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS|NUF_NOHTTPSOPTION|NUF_TCHAR;
+ nlu.szSettingsModule = WEATHERPROTONAME;
+ nlu.ptszDescriptiveName = TranslateT("Weather HTTP connections");
+ hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER,0, (LPARAM)&nlu);
+}
+
+void NetlibHttpDisconnect(void)
+{
+ if (hNetlibHttp)
+ {
+ HANDLE hConn = hNetlibHttp;
+ hNetlibHttp = NULL;
+ Netlib_CloseHandle(hConn);
+ }
+}
+
diff --git a/plugins/Weather/src/weather_icons.cpp b/plugins/Weather/src/weather_icons.cpp new file mode 100644 index 0000000000..321d758ca2 --- /dev/null +++ b/plugins/Weather/src/weather_icons.cpp @@ -0,0 +1,87 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+
+#include "weather.h"
+
+HANDLE hIcoLibIconsChanged = NULL;
+
+struct _tag_iconList
+{
+ TCHAR* szDescr;
+ char* szName;
+ int defIconID;
+ HANDLE hIconLibItem;
+}
+static iconList[] =
+{
+ { LPGENT("Protocol icon"), "main", IDI_ICON },
+ { LPGENT("Update Disabled"), "disabled", IDI_DISABLED },
+ { LPGENT("View Log"), "log", IDI_LOG },
+ { LPGENT("Update with Clear"), "update2", IDI_UPDATE2 },
+ { LPGENT("View Brief"), "brief", IDI_S },
+ { LPGENT("View Complete"), "read", IDI_READ },
+ { LPGENT("Weather Update"), "update", IDI_UPDATE },
+ { LPGENT("Weather Map"), "map", IDI_MAP },
+ { LPGENT("Popup"), "popup", IDI_POPUP },
+ { LPGENT("No Popup"), "nopopup", IDI_NOPOPUP },
+ { LPGENT("Edit Settings"), "edit", IDI_EDIT },
+};
+
+void InitIcons(void)
+{
+ char szSettingName[100];
+ TCHAR szFile[MAX_PATH];
+ GetModuleFileName(hInst, szFile, MAX_PATH);
+
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(sid);
+ sid.ptszDefaultFile = szFile;
+ sid.pszName = szSettingName;
+ sid.ptszSection = _T(WEATHERPROTONAME);
+ sid.flags = SIDF_ALL_TCHAR;
+
+ for (int i = 0; i < SIZEOF(iconList); i++) {
+ mir_snprintf(szSettingName, SIZEOF( szSettingName ), "%s_%s", WEATHERPROTONAME, iconList[i].szName);
+
+ sid.ptszDescription = iconList[i].szDescr;
+ sid.iDefaultIndex = -iconList[i].defIconID;
+ iconList[i].hIconLibItem = Skin_AddIcon(&sid);
+} }
+
+HICON LoadIconEx(const char* name, BOOL big)
+{
+ char szSettingName[100];
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", WEATHERPROTONAME, name);
+ return Skin_GetIcon(szSettingName, big);
+}
+
+HANDLE GetIconHandle(const char* name)
+{
+ unsigned i;
+ for (i=0; i < SIZEOF(iconList); i++)
+ if (strcmp(iconList[i].szName, name) == 0)
+ return iconList[i].hIconLibItem;
+ return NULL;
+}
+
+void ReleaseIconEx(HICON hIcon)
+{
+ Skin_ReleaseIcon(hIcon);
+}
diff --git a/plugins/Weather/src/weather_info.cpp b/plugins/Weather/src/weather_info.cpp new file mode 100644 index 0000000000..f02fc79a28 --- /dev/null +++ b/plugins/Weather/src/weather_info.cpp @@ -0,0 +1,252 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+
+/*
+This file contain the source for displaying information for the
+ini files, as well as function that are used for debug purpose
+regrading the loading of ini contents
+*/
+
+#include "weather.h"
+
+//============ INI INFORMATION ============
+
+// List INI Information for all loaded INI files
+void INIInfo(HWND hwndDlg)
+{
+ TCHAR str[16];
+ size_t memused = 0;
+ LVITEM lvi = {0};
+ WIDATALIST *Item = WIHead;
+
+ HWND hIniList = GetDlgItem(hwndDlg, IDC_INFOLIST);
+
+ ListView_DeleteAllItems(hIniList);
+
+ lvi.mask = LVIF_TEXT;
+ lvi.iItem = 0;
+ while (Item != NULL)
+ {
+ // get the data for the ini file
+ lvi.iSubItem = 0;
+ lvi.pszText = Item->Data.InternalName;
+ ListView_InsertItem(hIniList, &lvi);
+ lvi.iSubItem = 1;
+ lvi.pszText = Item->Data.Author;
+ ListView_SetItem(hIniList, &lvi);
+ lvi.iSubItem = 2;
+ lvi.pszText = Item->Data.Version;
+ ListView_SetItem(hIniList, &lvi);
+ lvi.iSubItem = 3;
+ switch (Item->Data.InternalVer)
+ {
+ case 1: lvi.pszText = _T("1.0"); break;
+ case 2: lvi.pszText = _T("1.1"); break;
+ case 3: lvi.pszText = _T("1.1a"); break;
+ case 4: lvi.pszText = _T("1.2"); break;
+ case 5: lvi.pszText = _T("1.3"); break;
+ case 6: lvi.pszText = _T("1.4"); break;
+ default: lvi.pszText = _T(""); break;
+ }
+ ListView_SetItem(hIniList, &lvi);
+ lvi.iSubItem = 4;
+ lvi.pszText = _ltot(Item->Data.UpdateDataCount, str, 10);
+ ListView_SetItem(hIniList, &lvi);
+ lvi.iSubItem = 5;
+ lvi.pszText = Item->Data.DisplayName;
+ ListView_SetItem(hIniList, &lvi);
+ lvi.iSubItem = 6;
+ lvi.pszText = Item->Data.ShortFileName;
+ ListView_SetItem(hIniList, &lvi);
+
+ memused += Item->Data.MemUsed;
+
+ Item = Item->next;
+ ++lvi.iItem;
+ }
+ SetDlgItemText(hwndDlg, IDC_INICOUNT, _itot(lvi.iItem, str, 10));
+ SetDlgItemText(hwndDlg, IDC_MEMUSED, _ltot((long)memused, str, 10));
+}
+
+static const struct tag_Columns
+{
+ const TCHAR *name;
+ unsigned size;
+}
+columns[] =
+{
+ { _T("Name"), 70 },
+ { _T("Author"), 100 },
+ { _T("File Version"), 70 },
+ { _T("INI Version"), 70 },
+ { _T("Items"), 40 },
+ { _T("Display Name"), 200 },
+ { _T("File Name"), 150 },
+};
+
+
+INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ HWND hIniList = GetDlgItem(hwndDlg, IDC_INFOLIST);
+ LVCOLUMN lvc = {0};
+
+ lvc.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
+ lvc.fmt = LVCFMT_LEFT;
+ for ( int i=0; i<7; ++i) {
+ lvc.iSubItem = i;
+ lvc.pszText = TranslateTS(columns[i].name);
+ lvc.cx = columns[i].size;
+ ListView_InsertColumn(hIniList, i, &lvc);
+ }
+ INIInfo(hwndDlg);
+ }
+
+ break;
+
+ case WM_DESTROY:
+ break;
+
+ case WM_COMMAND:
+ if ( HIWORD(wParam) == BN_CLICKED &&
+ LOWORD(wParam) == IDC_RELOADINI )
+ {
+ DestroyWIList();
+ LoadWIData(TRUE);
+ INIInfo(hwndDlg);
+ }
+ break;
+ }
+ return 0;
+}
+
+
+// get the info of individual ini file
+// pszSvc = the internal name of the service to get the data
+void GetINIInfo(TCHAR *pszSvc)
+{
+ TCHAR str2[2048];
+ WIDATA *sData = GetWIData(pszSvc);
+ // if the service does not exist among the loaded INI's
+ if (sData == NULL)
+ {
+ wsprintf(str2, TranslateT("The corresponding INI file for \"%s\" is not found."), pszSvc);
+ MessageBox(NULL, str2, TranslateT("Weather INI information"), MB_OK|MB_ICONINFORMATION);
+ }
+ // if exist, get the information
+ else
+ {
+ wsprintf(str2, TranslateT("Weather INI information for \"%s\":"), pszSvc);
+ _tcscat(str2,_T("\n\n"));
+ _tcscat(str2, TranslateT("Name:"));
+ _tcscat(str2,_T("\t\t"));
+ _tcscat(str2, sData->DisplayName);
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("Internal Name:"));
+ _tcscat(str2,_T("\t"));
+ _tcscat(str2, sData->InternalName);
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("Author:"));
+ _tcscat(str2,_T("\t\t"));
+ _tcscat(str2, sData->Author);
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("Version:"));
+ _tcscat(str2,_T("\t\t"));
+ _tcscat(str2, sData->Version);
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("INI Version:"));
+ _tcscat(str2,_T("\t"));
+ switch (sData->InternalVer) {
+ case 1: _tcscat(str2,_T("1.0")); break;
+ case 2: _tcscat(str2,_T("1.1")); break;
+ case 3: _tcscat(str2,_T("1.1a")); break;
+ case 4: _tcscat(str2,_T("1.2")); break;
+ case 5: _tcscat(str2,_T("1.3")); break;
+ case 6: _tcscat(str2,_T("1.4")); break;
+ }
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("File Name:"));
+ _tcscat(str2,_T("\t"));
+ _tcscat(str2, sData->ShortFileName);
+ _tcscat(str2, _T("\n"));
+ _tcscat(str2, TranslateT("Item Count:"));
+ wsprintf(str2, _T("%s\t%i\n"), str2, sData->UpdateDataCount);
+ _tcscat(str2, TranslateT("Memory Used:"));
+ wsprintf(str2, _T("%s\t%i "), str2, sData->MemUsed);
+ _tcscat(str2, TranslateT("bytes"));
+ _tcscat(str2,_T("\n\n"));
+ _tcscat(str2, TranslateT("Description:"));
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, sData->Description);
+
+ // display the message box and quit
+ MessageBox(NULL, str2, TranslateT("Weather INI information"), MB_OK|MB_ICONINFORMATION);
+ }
+}
+
+//============ DISPLAY A LIST FOR CUSTOM VARIABLES ============
+
+// a message box for displaying the list of custom variables
+// can be found when click on "More" in text option dialog
+void MoreVarList(void)
+{
+ TCHAR str[10240], tempstr[1024];
+
+ WIDATALIST *Item = WIHead;
+ // heading
+ _tcscpy(str, TranslateT("Here is a list of custom variables that are currently available"));
+ _tcscat(str, _T("\n\n"));
+ // loop through all weather services to find custom variables
+ while (Item != NULL)
+ {
+ WIDATAITEMLIST* WItem;
+ WItem = Item->Data.UpdateData;
+ // loop through all update items in a service
+ while (WItem != NULL)
+ {
+ // the custom variable is defined as "%[<variable name>]"
+ // ignore the "hi" item and hidden items
+ if ( _tcscmp(WItem->Item.Name, _T("Ignore")) && WItem->Item.Name[0] != '#') {
+ wsprintf(tempstr, _T("%c[%s]"), '%', WItem->Item.Name);
+ TCHAR* find = _tcsstr(str, tempstr);
+ // if the custom variable does not exist in the list, add it to the list
+ if (find == NULL) {
+ _tcscat(str, tempstr);
+ _tcscat(str, _T(", "));
+ }
+ }
+ WItem = WItem->Next;
+ }
+ Item = Item->next;
+ }
+ // remove the last comma in the list
+ TCHAR* find = _tcsrchr(str, ',');
+ if (find != NULL)
+ *find = '\0';
+
+ // display the list in a message box
+ MessageBox(NULL, str, TranslateT("More Variables"), MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
+}
+
diff --git a/plugins/Weather/src/weather_ini.cpp b/plugins/Weather/src/weather_ini.cpp new file mode 100644 index 0000000000..69f9ba40bb --- /dev/null +++ b/plugins/Weather/src/weather_ini.cpp @@ -0,0 +1,613 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+
+/*
+This file contain the source related to loading the reading the
+weather ini files and store them into memory. Also containing
+code for unloading and getting weather data from the ini settings.
+*/
+
+#include "weather.h"
+
+HWND hWndSetup;
+
+//============ DATA LIST (LINKED LIST) ============
+
+// add an item into weather service data list
+// Data = the service data to be added to the list
+void WIListAdd(WIDATA Data)
+{
+ WIDATALIST *newItem;
+
+ // create a new datalist item and point to the data
+ newItem = (WIDATALIST*)mir_alloc(sizeof(WIDATALIST));
+ newItem->Data = Data;
+ // add to the linked list
+ newItem->next = NULL;
+ if (WITail == NULL) WIHead = newItem;
+ else WITail->next = newItem;
+ WITail = newItem;
+}
+
+// get the service data (from loaded ini file) by internal name
+// pszServ = internal name for the service
+// return value = the matching WIDATA struct for pszServ, NULL if no match found
+WIDATA* GetWIData(TCHAR *pszServ)
+{
+ WIDATALIST *Item = WIHead;
+
+ // loop through the list to find matching internal name
+ while (Item != NULL) {
+ // if internal name found, return the data
+ if ( _tcscmp(Item->Data.InternalName, pszServ) == 0)
+ return &Item->Data;
+ Item = Item->next;
+ }
+ // return NULL when no match found
+ return NULL;
+}
+
+// remove all service data from memory
+void DestroyWIList(void)
+{
+ // free the list one by one
+ while (WIHead != NULL)
+ {
+ WIDATALIST *wi = WIHead;
+ WIHead = wi->next;
+ FreeWIData(&wi->Data); // free the data struct
+ mir_free(wi);
+ }
+
+ // make sure the entire list is clear
+ WITail = NULL;
+}
+
+//============ DATA ITEM LIST (LINKED LIST) ============
+
+// add a new update item into the current list
+void WIItemListAdd(WIDATAITEM *DataItem, WIDATA *Data)
+{
+ WIDATAITEMLIST *newItem;
+
+ newItem = (WIDATAITEMLIST*)mir_alloc(sizeof(WIDATAITEMLIST));
+ newItem->Item = *DataItem;
+ newItem->Next = NULL;
+ if (Data->UpdateData == NULL) Data->UpdateData = newItem;
+ else Data->UpdateDataTail->Next = newItem;
+ Data->UpdateDataTail = newItem;
+}
+
+// reset the data item by using empty string
+// Item = the item to set
+// name = the string to store in the "name" field
+void ResetDataItem(WIDATAITEM *Item, const TCHAR *name)
+{
+ TCHAR str[] = _T("ID Search - Station Name");
+ Item->Name = ( TCHAR* )mir_alloc( sizeof(str));
+ _tcscpy(Item->Name, str);
+ Item->Start = _T("");
+ Item->End = _T("");
+ Item->Unit = _T("");
+ Item->Url = "";
+ Item->Break = _T("");
+ Item->Type = 0;
+}
+
+// free the data item by using empty string
+// Item = the item to free
+void FreeDataItem(WIDATAITEM *Item)
+{
+ wfree(&Item->Name);
+ wfree(&Item->Start);
+ wfree(&Item->End);
+ wfree(&Item->Unit);
+ wfree(&Item->Url);
+ wfree(&Item->Break);
+}
+
+//============ Condition Icon List ============
+
+// initiate icon assignmet list
+void WICondListInit(WICONDLIST *List)
+{
+ List->Tail = NULL;
+ List->Head = NULL;
+}
+
+// add a new update item into the current list
+void WICondListAdd(char *str, WICONDLIST *List)
+{
+ WICONDITEM *newItem = (WICONDITEM*)mir_alloc(sizeof(WICONDITEM));
+ wSetData(&newItem->Item, str);
+ CharLowerBuff(newItem->Item, (DWORD)_tcslen( newItem->Item ));
+ newItem->Next = NULL;
+ if (List->Tail == NULL) List->Head = newItem;
+ else List->Tail->Next = newItem;
+ List->Tail = newItem;
+}
+
+// check if the condition string matched for the assignment
+BOOL IsContainedInCondList(const TCHAR *pszStr, WICONDLIST *List)
+{
+ WICONDITEM *Item = List->Head;
+
+ // loop through the list to find matching internal name
+ while (Item != NULL) {
+ // if internal name found, return true indicating that the data is found
+ if ( _tcsstr(pszStr, Item->Item))
+ return TRUE;
+ Item = Item->Next;
+ }
+ // return false when no match found
+ return FALSE;
+}
+
+// free the memory for icon assignment list
+void DestroyCondList(WICONDLIST *List)
+{
+ WICONDITEM *temp;
+
+ temp = List->Head;
+
+ // free the list one by one
+ while (temp != NULL)
+ {
+ List->Head = temp->Next;
+ wfree(&temp->Item); // free the data struct
+ mir_free(temp);
+ temp = List->Head;
+ }
+ // make sure the entire list is clear
+ List->Tail = NULL;
+}
+
+
+//============ LOADING INI FILES ============
+
+// load the weather update data form INI files
+BOOL LoadWIData(BOOL dial)
+{
+ HANDLE hFind;
+ TCHAR szSearchPath[MAX_PATH], FileName[MAX_PATH], *chop;
+ WIN32_FIND_DATA fd;
+ WIDATA Data;
+
+ // make sure that the current service data list is empty
+ WITail = NULL;
+ WIHead = WITail;
+
+ // find all *.ini file in the plugin\weather directory
+ GetModuleFileName(GetModuleHandle(NULL), szSearchPath, SIZEOF(szSearchPath));
+ chop = _tcsrchr(szSearchPath, '\\');
+ *chop = '\0';
+ _tcscat(szSearchPath, _T("\\Plugins\\Weather\\*.ini"));
+ _tcscpy(FileName, szSearchPath);
+
+ hFind = FindFirstFile(szSearchPath, &fd);
+
+ // load the content of the ini file into memory
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ chop = _tcsrchr(FileName, '\\');
+ chop[1] = '\0';
+ _tcscat(FileName, fd.cFileName);
+ if ( _tcsicmp(fd.cFileName, _T("SAMPLE_INI.INI"))) {
+ LoadStationData(FileName, fd.cFileName, &Data);
+ if (Data.Enabled) WIListAdd(Data);
+ }
+ // look through the entire "plugins\weather" directory
+ }
+ while(FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
+
+ if (WIHead == NULL) {
+ // no ini found, display an error message box.
+ if (dial)
+ hWndSetup = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SETUP), NULL, DlgProcSetup);
+ else
+ MessageBox(NULL,
+ TranslateT("No update data file is found. Please check your Plugins\\Weather directory."),
+ TranslateT("Weather Protocol"), MB_OK | MB_ICONERROR);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+// load the station data from a file
+// pszFile = the file name + path for the ini file to be loaded
+// pszShortFile = the file name of the ini file, but not including the path
+// Data = the struct to load the ini content to, and return to previous function
+void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
+{
+ WIDATAITEM DataItem;
+ FILE *pfile;
+ int i;
+ char *Group, *Temp;
+ char *ValName, *Value;
+
+ static const char *statusStr[10] =
+ {
+ "LIGHTNING",
+ "FOG",
+ "SNOW SHOWER",
+ "SNOW",
+ "RAIN SHOWER",
+ "RAIN",
+ "PARTLY CLOUDY",
+ "CLOUDY",
+ "SUNNY",
+ "N/A"
+ };
+
+ // clean up old stuff
+ ZeroMemory(Data, sizeof(Data));
+ Data->Enabled = FALSE;
+
+ // open the ini file
+ pfile = _tfsopen(pszFile, _T("rt"), _SH_DENYWR);
+ if (pfile != NULL) {
+ char Line[4096];
+ fgets(Line, SIZEOF(Line), pfile);
+ TrimString(Line);
+
+ // make sure it is a valid weather protocol ini file
+ if ( !strcmp(Line, "[Weather 0.3.x Update Data]"))
+ Data->InternalVer = 1;
+ else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.1]"))
+ Data->InternalVer = 2;
+ else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.1a]"))
+ Data->InternalVer = 3;
+ else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.2]"))
+ Data->InternalVer = 4;
+ else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.3]"))
+ Data->InternalVer = 5;
+ else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.4]"))
+ Data->InternalVer = 6;
+ else
+ {
+ wsprintfA(Line, Translate("Invalid ini format for: %s"), pszFile);
+ MessageBoxA(NULL, Line, Translate("Weather Protocol"), MB_OK|MB_ICONERROR);
+ fclose(pfile);
+ return;
+ }
+
+ // initialize all data fields
+ Group = "";
+
+ Data->DisplayName = _T("");
+ Data->InternalName = _T("");
+ Data->Description = _T("");
+ Data->Author = _T("");
+ Data->Version = _T("");
+ Data->DefaultURL = "";
+ Data->DefaultMap = _T("");
+ Data->UpdateURL = "";
+ Data->UpdateURL2 = "";
+ Data->UpdateURL3 = "";
+ Data->UpdateURL4 = "";
+ Data->Cookie = "";
+ Data->IDSearch.SearchURL = "";
+ Data->IDSearch.NotFoundStr = _T("");
+ Data->NameSearch.SearchURL = "";
+ Data->NameSearch.NotFoundStr = _T("");
+ Data->NameSearch.SingleStr = _T("");
+ Data->NameSearch.Single.First = _T("");
+ Data->NameSearch.Multiple.First = _T("");
+ Data->IDSearch.Available = FALSE;
+ Data->NameSearch.Single.Available = FALSE;
+ Data->NameSearch.Multiple.Available = FALSE;
+ wSetData(&Data->FileName, pszFile);
+ wSetData(&Data->ShortFileName, pszShortFile);
+
+ ResetDataItem(&Data->IDSearch.Name, _T("ID Search - Station Name"));
+ ResetDataItem(&Data->NameSearch.Single.Name, _T("Name Search Single Result - Station Name"));
+ ResetDataItem(&Data->NameSearch.Single.ID, _T("Name Search Single Result - Station ID"));
+ ResetDataItem(&Data->NameSearch.Multiple.Name, _T("Name Search Multiple Result - Station Name"));
+ ResetDataItem(&Data->NameSearch.Multiple.ID, _T("Name Search Multiple Result - Station ID"));
+
+ DataItem.Name = _T("");
+ DataItem.Start = _T("");
+ DataItem.End = _T("");
+ DataItem.Unit = _T("");
+ DataItem.Url = "";
+ DataItem.Break = _T("");
+ DataItem.Type = 0;
+
+ Temp = "";
+
+ // initialize the linked list for update items
+ Data->UpdateDataCount = 0;
+ Data->MemUsed = sizeof(WIDATA) + sizeof(WIDATALIST) + (_tcslen(pszShortFile) + _tcslen(pszFile) + 20)*sizeof( TCHAR );
+ Data->UpdateData = NULL;
+ Data->UpdateDataTail = NULL;
+
+ // initialize the icon assignment list
+ for (i=0; i<10; i++)
+ WICondListInit( &Data->CondList[i] );
+
+ while (!feof(pfile)) {
+ // determine current tag
+
+ if (fgets(Line, SIZEOF(Line), pfile) == NULL)
+ break;
+ TrimString(Line);
+
+ // if the line is a group header/footer
+ if (Line[0] == '[') {
+ char *chop = strchr(Line+1,']');
+ if (chop == NULL)
+ continue;
+
+ if (Line[1] != '/') { // if it is not a footer (for old ini)
+ // save the group name
+ Temp = (char *)mir_alloc(strlen(Line)+10);
+ strncpy(Temp, Line+1, chop-Line-1);
+ Temp[chop-Line-1] = 0;
+ wfree(&Group);
+ wSetData(&Group, Temp);
+ // see if it is a update item, if it is, add a new item to the linked list
+ // if (_stricmp(Group, "HEADER") && _stricmp(Group, "DEFAULT") && _stricmp(Group, "ID SEARCH") &&
+ // strcmpi(Group, "NAME SEARCH"))
+ // wSetData(&DataItem.Name, Group);
+ if (_stricmp(Group, "HEADER") && _stricmp(Group, "DEFAULT") && _stricmp(Group, "ID SEARCH") &&
+ _stricmp(Group, "NAME SEARCH") && _stricmp(Group, "ICONS"))
+ {
+ wSetData(&DataItem.Name, Temp);
+ DataItem.Type = WID_NORMAL;
+ WIItemListAdd(&DataItem, Data);
+ Data->UpdateDataCount++;
+ }
+ mir_free(Temp);
+ }
+ else
+ {
+ wfree(&Group);
+ wSetData(&Group, "");
+ }
+ }
+ // ignore comments and all lines without an '='
+ Value = strstr(Line, "=");
+ if (Value == NULL) continue;
+
+ // get the string before '=' (ValName) and after '=' (Value)
+ ValName = (char *)mir_alloc(strlen(Line)+1);
+ strncpy(ValName, Line, Value-Line);
+ ValName[Value-Line] = 0;
+ Value++;
+ ConvertBackslashes(Value);
+ // store the value for each string
+ if ( !_stricmp(Group, "HEADER")) {
+ if ( !_stricmp(ValName, "NAME")) wSetData(&Data->DisplayName, Value);
+ else if ( !_stricmp(ValName, "INTERNAL NAME")) wSetData(&Data->InternalName, Value);
+ else if ( !_stricmp(ValName, "DESCRIPTION")) wSetData(&Data->Description, Value);
+ else if ( !_stricmp(ValName, "AUTHOR")) wSetData(&Data->Author, Value);
+ else if ( !_stricmp(ValName, "VERSION")) wSetData(&Data->Version, Value);
+ }
+ else if ( !_stricmp(Group, "DEFAULT")) {
+ if ( !_stricmp(ValName, "DEFAULT URL")) wSetData(&Data->DefaultURL, Value);
+ else if ( !_stricmp(ValName, "DEFAULT MAP")) wSetData(&Data->DefaultMap, Value);
+ else if ( !_stricmp(ValName, "UPDATE URL")) wSetData(&Data->UpdateURL, Value);
+ else if ( !_stricmp(ValName, "UPDATE URL2")) wSetData(&Data->UpdateURL2, Value);
+ else if ( !_stricmp(ValName, "UPDATE URL3")) wSetData(&Data->UpdateURL3, Value);
+ else if ( !_stricmp(ValName, "UPDATE URL4")) wSetData(&Data->UpdateURL4, Value);
+ else if ( !_stricmp(ValName, "COOKIE")) wSetData(&Data->Cookie, Value);
+ }
+ else if ( !_stricmp(Group, "ID SEARCH")) {
+ if ( !_stricmp(ValName, "AVAILABLE")) {
+ if ( !_stricmp(Value, "TRUE")) Data->IDSearch.Available = TRUE;
+ else Data->IDSearch.Available = FALSE;
+ }
+ else if ( !_stricmp(ValName, "SEARCH URL")) wSetData(&Data->IDSearch.SearchURL, Value);
+ else if ( !_stricmp(ValName, "NOT FOUND STR")) wSetData(&Data->IDSearch.NotFoundStr, Value);
+ else if ( !_stricmp(ValName, "NAME START")) wSetData(&Data->IDSearch.Name.Start, Value);
+ else if ( !_stricmp(ValName, "NAME END")) wSetData(&Data->IDSearch.Name.End, Value);
+ }
+ else if ( !_stricmp(Group, "NAME SEARCH")) {
+ if ( !_stricmp(ValName, "SINGLE RESULT")) {
+ if ( !_stricmp(Value, "TRUE")) Data->NameSearch.Single.Available = TRUE;
+ else Data->NameSearch.Single.Available = FALSE;
+ }
+ else if ( !_stricmp(ValName, "MULTIPLE RESULT")) {
+ if ( !_stricmp(Value, "TRUE")) Data->NameSearch.Multiple.Available = TRUE;
+ else Data->NameSearch.Multiple.Available = FALSE;
+ }
+ else if ( !_stricmp(ValName, "SEARCH URL")) wSetData(&Data->NameSearch.SearchURL, Value);
+ else if ( !_stricmp(ValName, "NOT FOUND STR")) wSetData(&Data->NameSearch.NotFoundStr, Value);
+ else if ( !_stricmp(ValName, "SINGLE RESULT STR")) wSetData(&Data->NameSearch.SingleStr, Value);
+ else if ( !_stricmp(ValName, "SINGLE FIRST")) wSetData(&Data->NameSearch.Single.First, Value);
+ else if ( !_stricmp(ValName, "SINGLE NAME START"))wSetData(&Data->NameSearch.Single.Name.Start, Value);
+ else if ( !_stricmp(ValName, "SINGLE NAME END")) wSetData(&Data->NameSearch.Single.Name.End, Value);
+ else if ( !_stricmp(ValName, "SINGLE ID START")) wSetData(&Data->NameSearch.Single.ID.Start, Value);
+ else if ( !_stricmp(ValName, "SINGLE ID END")) wSetData(&Data->NameSearch.Single.ID.End, Value);
+ else if ( !_stricmp(ValName, "MULT FIRST")) wSetData(&Data->NameSearch.Multiple.First, Value);
+ else if ( !_stricmp(ValName, "MULT NAME START")) wSetData(&Data->NameSearch.Multiple.Name.Start, Value);
+ else if ( !_stricmp(ValName, "MULT NAME END")) wSetData(&Data->NameSearch.Multiple.Name.End, Value);
+ else if ( !_stricmp(ValName, "MULT ID START")) wSetData(&Data->NameSearch.Multiple.ID.Start, Value);
+ else if ( !_stricmp(ValName, "MULT ID END")) wSetData(&Data->NameSearch.Multiple.ID.End, Value);
+ }
+ else if ( !_stricmp(Group, "ICONS")) {
+ for (i=0; i<10; i++) {
+ if ( !_stricmp(ValName, statusStr[i])) {
+ WICondListAdd(Value, &Data->CondList[i]);
+ break;
+ }
+ }
+ }
+ else if (Data->UpdateDataCount != 0) {
+ if ( !_stricmp(ValName, "START")) wSetData(&Data->UpdateDataTail->Item.Start, Value);
+ else if ( !_stricmp(ValName, "SOURCE")) wSetData(&Data->UpdateDataTail->Item.Start, Value);
+ else if ( !_stricmp(ValName, "END")) wSetData(&Data->UpdateDataTail->Item.End, Value);
+ else if ( !_stricmp(ValName, "UNIT")) wSetData(&Data->UpdateDataTail->Item.Unit, Value);
+ else if ( !_stricmp(ValName, "URL")) wSetData(&Data->UpdateDataTail->Item.Url, Value);
+ else if ( !_stricmp(ValName, "HIDDEN")) {
+ if ( !_stricmp(Value, "TRUE")) {
+ TCHAR *nm = Data->UpdateDataTail->Item.Name;
+ size_t len = _tcslen(nm) + 1;
+
+ Data->UpdateDataTail->Item.Name = nm = ( TCHAR* )mir_realloc(nm, sizeof(TCHAR)*(len + 3));
+ memmove(nm + 1, nm, len*sizeof( TCHAR ));
+ *nm = '#';
+ }
+ }
+ else if ( !_stricmp(ValName, "SET DATA")) {
+ Data->UpdateDataTail->Item.Type = WID_SET;
+ wSetData(&Data->UpdateDataTail->Item.End, Value);
+ }
+ else if ( !_stricmp(ValName, "BREAK DATA")) {
+ Data->UpdateDataTail->Item.Type = WID_BREAK;
+ wSetData(&Data->UpdateDataTail->Item.Break, Value);
+ }
+ }
+ // recalculate memory used
+ Data->MemUsed += (strlen(Value) + 10);
+ wfree(&ValName);
+ }
+ // calcualate memory used for the ini and close the file
+ Data->MemUsed += sizeof(WIDATAITEMLIST)*Data->UpdateDataCount;
+ Data->Enabled = TRUE; // enable the service
+ fclose(pfile);
+ wfree(&Group);
+ }
+}
+
+//============ FREE WIDATA ITEM FROM MEMORY ============
+
+// free the WIDATA struct from memory
+// Data = the struct to be freed
+void FreeWIData(WIDATA *Data)
+{
+ WIDATAITEMLIST* WItem;
+ int i;
+
+ // free update items linked list first
+ WItem = Data->UpdateData;
+ while (WItem != NULL)
+ {
+ Data->UpdateData = WItem->Next;
+ FreeDataItem(&WItem->Item);
+ mir_free(WItem);
+ WItem = Data->UpdateData;
+ }
+
+ // free the strings in the rest of the struct
+ wfree(&Data->DisplayName);
+ wfree(&Data->InternalName);
+ wfree(&Data->Description);
+ wfree(&Data->Author);
+ wfree(&Data->Version);
+ wfree(&Data->DefaultURL);
+ wfree(&Data->DefaultMap);
+ wfree(&Data->UpdateURL);
+ wfree(&Data->UpdateURL2);
+ wfree(&Data->UpdateURL3);
+ wfree(&Data->UpdateURL4);
+ wfree(&Data->Cookie);
+ wfree(&Data->IDSearch.SearchURL);
+ wfree(&Data->IDSearch.NotFoundStr);
+ FreeDataItem(&Data->IDSearch.Name);
+ wfree(&Data->NameSearch.SearchURL);
+ wfree(&Data->NameSearch.NotFoundStr);
+ wfree(&Data->NameSearch.SingleStr);
+ wfree(&Data->NameSearch.Single.First);
+ FreeDataItem(&Data->NameSearch.Single.Name);
+ FreeDataItem(&Data->NameSearch.Single.ID);
+ wfree(&Data->NameSearch.Multiple.First);
+ FreeDataItem(&Data->NameSearch.Multiple.Name);
+ FreeDataItem(&Data->NameSearch.Multiple.ID);
+ wfree(&Data->ShortFileName);
+ wfree(&Data->FileName);
+ for (i=0; i<10; i++) DestroyCondList(&Data->CondList[i]);
+}
+
+//============ WEATHER INI SETUP DIALOG ============
+
+INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ // make the buttons flat
+ SendMessage(GetDlgItem(hwndDlg,IDC_STEP1), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hwndDlg,IDC_STEP2), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hwndDlg,IDC_STEP3), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hwndDlg,IDC_STEP4), BUTTONSETASFLATBTN, TRUE, 0);
+
+ // set icons
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx("main", TRUE));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx("main", FALSE));
+
+ WindowList_Add(hWindowList, hwndDlg, NULL);
+ ShowWindow(hwndDlg, SW_SHOW);
+ break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDC_STEP1:
+ // update current data
+ CallService(MS_UTILS_OPENURL, opt.NewBrowserWin | OUF_TCHAR, (WPARAM)_T("http://miranda-ng.org/"));
+ break;
+
+ case IDC_STEP2:
+ {
+ TCHAR szPath[1024], *chop;
+ GetModuleFileName(GetModuleHandle(NULL), szPath, sizeof(szPath));
+ chop = _tcsrchr(szPath, '\\');
+ *chop = '\0';
+ _tcscat(szPath, _T("\\Plugins\\weather\\"));
+ _tmkdir(szPath);
+ ShellExecute((HWND)lParam, _T("open"), szPath, _T(""), _T(""), SW_SHOW);
+ break;
+ }
+
+ case IDC_STEP3:
+ if (LoadWIData(FALSE))
+ MessageBox(NULL,
+ TranslateT("All update data has been reloaded."),
+ TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ break;
+
+ case IDC_STEP4:
+ WeatherAdd(0, 0);
+
+ case IDCANCEL:
+ // close the info window
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
+ ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0));
+ break;
+ }
+ return FALSE;
+}
+
diff --git a/plugins/Weather/src/weather_mwin.cpp b/plugins/Weather/src/weather_mwin.cpp new file mode 100644 index 0000000000..8a7798b3b1 --- /dev/null +++ b/plugins/Weather/src/weather_mwin.cpp @@ -0,0 +1,420 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2006-2009 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2006 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "weather.h"
+#include "m_acc.h"
+
+#define MS_TOOLTIP_SHOWTIP "mToolTip/ShowTip"
+#define MS_TOOLTIP_HIDETIP "mToolTip/HideTip"
+
+typedef BOOL (WINAPI *ft_TrackMouseEvent) (LPTRACKMOUSEEVENT lpEventTrack);
+
+static ft_TrackMouseEvent f_TrackMouseEvent = NULL;
+static HANDLE hMwinWindowList;
+static HANDLE hFontHook;
+
+HANDLE hMwinMenu;
+
+typedef struct
+{
+ HANDLE hContact;
+ HWND hAvt;
+ BOOL haveAvatar;
+} MWinDataType;
+
+#define WM_REDRAWWIN (WM_USER + 17369)
+
+static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ MWinDataType *data = (MWinDataType*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+
+ switch(msg)
+ {
+ case WM_CREATE:
+ data = (MWinDataType*)mir_calloc(sizeof(MWinDataType));
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data);
+
+ data->hContact = (HANDLE)((LPCREATESTRUCT)lParam)->lpCreateParams;
+ data->hAvt = CreateWindow(AVATAR_CONTROL_CLASS, TEXT(""), WS_CHILD,
+ 0, 0, opt.AvatarSize, opt.AvatarSize, hwnd, NULL, hInst, 0);
+ if (data->hAvt) SendMessage(data->hAvt, AVATAR_SETCONTACT, 0, (LPARAM)data->hContact);
+ break;
+
+ case WM_DESTROY:
+ mir_free(data);
+ break;
+
+ case WM_CONTEXTMENU:
+ {
+ POINT pt;
+
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)data->hContact, 0);
+ GetCursorPos(&pt);
+ TrackPopupMenu(hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hwnd, NULL);
+ DestroyMenu(hMenu);
+ }
+ break;
+
+ case WM_MOUSEMOVE:
+ if (f_TrackMouseEvent)
+ {
+ TRACKMOUSEEVENT tme = {0};
+ tme.cbSize = sizeof(TRACKMOUSEEVENT);
+ tme.hwndTrack = hwnd;
+ tme.dwFlags = TME_QUERY;
+ f_TrackMouseEvent(&tme);
+
+ if (tme.dwFlags == 0)
+ {
+ tme.dwFlags = TME_HOVER | TME_LEAVE;
+ tme.hwndTrack = hwnd;
+ tme.dwHoverTime = CallService(MS_CLC_GETINFOTIPHOVERTIME, 0, 0);
+ f_TrackMouseEvent(&tme);
+ }
+ }
+ break;
+
+ case WM_MOUSEHOVER:
+ {
+ POINT pt;
+ CLCINFOTIP ti = {0};
+
+ GetCursorPos(&pt);
+ GetWindowRect(hwnd, &ti.rcItem);
+
+ ti.cbSize = sizeof(ti);
+ ti.hItem = data->hContact;
+ ti.ptCursor = pt;
+ ti.isTreeFocused = 1;
+ CallService(MS_TOOLTIP_SHOWTIP, 0, (LPARAM)&ti);
+ }
+ break;
+
+ case WM_LBUTTONDBLCLK:
+ BriefInfo((WPARAM)data->hContact, 0);
+ break;
+
+ case WM_COMMAND: //Needed by the contact's context menu
+ if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)data->hContact))
+ break;
+ return FALSE;
+
+ case WM_MEASUREITEM: //Needed by the contact's context menu
+ return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
+
+ case WM_DRAWITEM: //Needed by the contact's context menu
+ return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == NM_AVATAR_CHANGED)
+ {
+ BOOL newava = CallService(MS_AV_GETAVATARBITMAP, (WPARAM)data->hContact, 0) != 0;
+ if (newava != data->haveAvatar)
+ {
+ LONG_PTR style = GetWindowLongPtr(data->hAvt, GWL_STYLE);
+ data->haveAvatar = newava;
+ SetWindowLongPtr(data->hAvt, GWL_STYLE, newava ? (style | WS_VISIBLE) : (style & ~WS_VISIBLE));
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE);
+ }
+ }
+ break;
+
+ case WM_REDRAWWIN:
+ if (data->hAvt != NULL) MoveWindow(data->hAvt, 0, 0, opt.AvatarSize, opt.AvatarSize, TRUE);
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
+ break;
+
+ case WM_PAINT:
+ {
+ RECT r, rc;
+
+ if (GetUpdateRect(hwnd, &r, FALSE))
+ {
+ DBVARIANT dbv = {0};
+ PAINTSTRUCT ps;
+ LOGFONT lfnt, lfnt1;
+ COLORREF fntc, fntc1;
+ COLORREF clr;
+ int picSize = opt.AvatarSize;
+ HICON hIcon = NULL;
+
+ if ( !data->haveAvatar)
+ {
+ int statusIcon = db_get_w(data->hContact, WEATHERPROTONAME, "Status", 0);
+
+ picSize = GetSystemMetrics(SM_CXICON);
+ hIcon = LoadSkinnedProtoIconBig(WEATHERPROTONAME, statusIcon);
+ if ((INT_PTR)hIcon == CALLSERVICE_NOTFOUND)
+ {
+ picSize = GetSystemMetrics(SM_CXSMICON);
+ hIcon = LoadSkinnedProtoIcon(WEATHERPROTONAME, statusIcon);
+ }
+ }
+
+ clr = db_get_dw(NULL, WEATHERPROTONAME, "ColorMwinFrame", GetSysColor(COLOR_3DFACE));
+
+ {
+ FontIDT fntid = {0};
+ _tcscpy(fntid.group, _T(WEATHERPROTONAME));
+ _tcscpy(fntid.name, LPGENT("Frame Font"));
+ fntc = CallService(MS_FONT_GETT, (WPARAM)&fntid, (LPARAM)&lfnt);
+
+ _tcscpy(fntid.name, LPGENT("Frame Title Font"));
+ fntc1 = CallService(MS_FONT_GETT, (WPARAM)&fntid, (LPARAM)&lfnt1);
+ }
+
+ DBGetContactSettingTString(data->hContact, WEATHERCONDITION, "WeatherInfo", &dbv);
+
+ GetClientRect(hwnd, &rc);
+
+ HDC hdc = BeginPaint(hwnd, &ps);
+
+ if ( ServiceExists(MS_SKIN_DRAWGLYPH)) {
+ SKINDRAWREQUEST rq;
+ memset(&rq, 0, sizeof(rq));
+ rq.hDC = hdc;
+ rq.rcDestRect = rc;
+ rq.rcClipRect = rc;
+
+ strcpy(rq.szObjectID, "Main,ID=WeatherFrame");
+ CallService(MS_SKIN_DRAWGLYPH, (WPARAM)&rq, 0);
+ }
+
+ if (clr != 0xFFFFFFFF) {
+ HBRUSH hBkgBrush = CreateSolidBrush(clr);
+ FillRect(hdc, &rc, hBkgBrush);
+ DeleteObject(hBkgBrush);
+ }
+
+ if ( !data->haveAvatar)
+ DrawIconEx(hdc, 1, 1, hIcon, 0, 0, 0, NULL, DI_NORMAL);
+
+ SetBkMode(hdc, TRANSPARENT);
+
+ HFONT hfnt = CreateFontIndirect(&lfnt1);
+ HFONT hfntold = ( HFONT )SelectObject(hdc, hfnt);
+ SIZE fontSize;
+
+ TCHAR *nick = ( TCHAR* )CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)data->hContact, GCDNF_TCHAR);
+
+ GetTextExtentPoint32(hdc, _T("|"), 1, &fontSize);
+
+ rc.top += 1;
+ rc.left += picSize + fontSize.cx;
+
+ SetTextColor(hdc, fntc1);
+ DrawText(hdc, nick, -1, &rc, DT_LEFT | DT_EXPANDTABS);
+
+ rc.top += fontSize.cy;
+
+ SelectObject(hdc, hfntold);
+ DeleteObject(hfnt);
+
+ if (dbv.pszVal)
+ {
+ HFONT hfnt = CreateFontIndirect(&lfnt);
+ HFONT hfntold = ( HFONT )SelectObject(hdc, hfnt);
+
+ SetTextColor(hdc, fntc);
+ DrawText(hdc, dbv.ptszVal, -1, &rc, DT_LEFT | DT_EXPANDTABS);
+
+ SelectObject(hdc, hfntold);
+ DeleteObject(hfnt);
+ }
+ EndPaint(hwnd, &ps);
+ Skin_ReleaseIcon(hIcon);
+ db_free(&dbv);
+ }
+ break;
+ }
+
+ default:
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+ return(TRUE);
+}
+
+static void addWindow(HANDLE hContact)
+{
+ DBVARIANT dbv;
+ DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv);
+
+ TCHAR winname[512];
+ mir_sntprintf(winname, SIZEOF(winname), _T("Weather: %s"), dbv.ptszVal);
+ db_free(&dbv);
+
+ HWND hWnd = CreateWindow( _T("WeatherFrame"), _T(""), WS_CHILD | WS_VISIBLE,
+ 0, 0, 10, 10, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL, hInst, hContact);
+ WindowList_Add(hMwinWindowList, hWnd, hContact);
+
+ CLISTFrame Frame = {0};
+ Frame.tname = winname;
+ Frame.hIcon = LoadIconEx("main",FALSE);
+ Frame.cbSize = sizeof(Frame);
+ Frame.hWnd = hWnd;
+ Frame.align = alBottom;
+ Frame.Flags = F_VISIBLE|F_NOBORDER|F_TCHAR;
+ Frame.height = 32;
+ DWORD frameID = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0);
+
+ db_set_dw(hContact, WEATHERPROTONAME, "mwin", frameID);
+ db_set_b(hContact, "CList", "Hidden", TRUE);
+}
+
+void removeWindow(HANDLE hContact)
+{
+ DWORD frameId = db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0);
+
+ WindowList_Remove(hMwinWindowList, WindowList_Find(hMwinWindowList, hContact));
+ CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0);
+
+ db_set_dw(hContact, WEATHERPROTONAME, "mwin", 0);
+ db_unset(hContact, "CList", "Hidden");
+}
+
+void UpdateMwinData(HANDLE hContact)
+{
+ HWND hwnd = WindowList_Find(hMwinWindowList, hContact);
+ if (hwnd != NULL)
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
+}
+
+
+INT_PTR Mwin_MenuClicked(WPARAM wParam,LPARAM lParam)
+{
+ BOOL addwnd = WindowList_Find(hMwinWindowList, (HANDLE)wParam) == NULL;
+ if (addwnd)
+ addWindow((HANDLE)wParam);
+ else
+ removeWindow((HANDLE)wParam);
+ return 0;
+}
+
+
+int BuildContactMenu(WPARAM wparam,LPARAM lparam)
+{
+ CLISTMENUITEM mi = {0};
+
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIM_FLAGS |
+ (db_get_dw((HANDLE)wparam, WEATHERPROTONAME, "mwin", 0) ? CMIF_CHECKED : 0);
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMwinMenu, (LPARAM)&mi);
+ return 0;
+}
+
+
+int RedrawFrame(WPARAM wParam, LPARAM lParam)
+{
+ WindowList_Broadcast(hMwinWindowList, WM_REDRAWWIN, 0, 0);
+ return 0;
+}
+
+
+void InitMwin(void)
+{
+ HMODULE hUser = GetModuleHandle(_T("user32.dll"));
+
+ if ( !ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) return;
+
+ f_TrackMouseEvent = (ft_TrackMouseEvent)GetProcAddress(hUser, "TrackMouseEvent");
+
+
+ hMwinWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
+
+ {
+ WNDCLASS wndclass;
+ wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
+ wndclass.lpfnWndProc = wndProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInst;
+ wndclass.hIcon = NULL;
+ wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.hbrBackground = 0; //(HBRUSH)(COLOR_3DFACE+1);
+ wndclass.lpszMenuName = NULL;
+ wndclass.lpszClassName = _T("WeatherFrame");
+ RegisterClass(&wndclass);
+ }
+
+ {
+ ColourIDT colourid = {0};
+ colourid.cbSize = sizeof(ColourIDT);
+ strcpy(colourid.dbSettingsGroup, WEATHERPROTONAME);
+ strcpy(colourid.setting, "ColorMwinFrame");
+ _tcscpy(colourid.name, LPGENT("Frame Background"));
+ _tcscpy(colourid.group, _T(WEATHERPROTONAME));
+ colourid.defcolour = GetSysColor(COLOR_3DFACE);
+ ColourRegisterT(&colourid);
+
+ FontIDT fontid = {0};
+ fontid.cbSize = sizeof(FontIDT);
+ fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID;
+ strcpy(fontid.dbSettingsGroup, WEATHERPROTONAME);
+ _tcscpy(fontid.group, _T(WEATHERPROTONAME));
+ _tcscpy(fontid.name, LPGENT("Frame Font"));
+ strcpy(fontid.prefix, "fnt0");
+
+ HDC hdc = GetDC(NULL);
+ fontid.deffontsettings.size = -13;
+ ReleaseDC(0, hdc);
+
+ fontid.deffontsettings.charset = DEFAULT_CHARSET;
+ _tcscpy(fontid.deffontsettings.szFace, _T("Verdana"));
+ _tcscpy(fontid.backgroundGroup, _T(WEATHERPROTONAME));
+ _tcscpy(fontid.backgroundName, LPGENT("Frame Background"));
+ FontRegisterT(&fontid);
+
+ fontid.deffontsettings.style = DBFONTF_BOLD;
+ _tcscpy(fontid.name, LPGENT("Frame Title Font"));
+ strcpy(fontid.prefix, "fnt1");
+ FontRegisterT(&fontid);
+ }
+
+ HANDLE hContact = db_find_first();
+ while(hContact)
+ {
+ // see if the contact is a weather contact
+ if (IsMyContact(hContact))
+ {
+ if (db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0))
+ addWindow(hContact);
+ }
+ hContact = db_find_next(hContact);
+ }
+ hFontHook = HookEvent(ME_FONT_RELOAD, RedrawFrame);
+}
+
+void DestroyMwin(void)
+{
+ HANDLE hContact = db_find_first();
+ while(hContact)
+ {
+ // see if the contact is a weather contact
+ if (IsMyContact(hContact))
+ {
+ DWORD frameId = db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0);
+ if (frameId)
+ CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0);
+ }
+ hContact = db_find_next(hContact);
+ }
+ UnregisterClass( _T("WeatherFrame"), hInst);
+ UnhookEvent(hFontHook);
+}
diff --git a/plugins/Weather/src/weather_opt.cpp b/plugins/Weather/src/weather_opt.cpp new file mode 100644 index 0000000000..f242adb0f1 --- /dev/null +++ b/plugins/Weather/src/weather_opt.cpp @@ -0,0 +1,642 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This file contain the source related to weather option pages. It also
+contain code for saving/loading options from the database.
+*/
+
+#include "weather.h"
+
+static BOOL opt_startup;
+int RedrawFrame(WPARAM wParam, LPARAM lParam);
+
+//============ LOADING AND SAVING OPTIONS ===========
+
+// set a string to default
+// in = string to determine which field to set default "CBNEHXPp"
+void SetTextDefault(const char* in)
+{
+ TCHAR str[MAX_TEXT_SIZE];
+
+ if (strchr(in, 'C') != NULL)
+ {
+ _tcscpy(str, C_DEFAULT);
+ wSetData(&opt.cText, str);
+ }
+ if (strchr(in, 'b') != NULL)
+ {
+ _tcscpy(str, b_DEFAULT);
+ wSetData(&opt.bTitle, str);
+ }
+ if (strchr(in, 'B') != NULL)
+ {
+ _tcscpy(str, B_DEFAULT);
+ wSetData(&opt.bText, str);
+ }
+ if (strchr(in, 'N') != NULL)
+ {
+ _tcscpy(str, N_DEFAULT);
+ wSetData(&opt.nText, str);
+ }
+ if (strchr(in, 'E') != NULL)
+ {
+ _tcscpy(str, E_DEFAULT);
+ wSetData(&opt.eText, str);
+ }
+ if (strchr(in, 'H') != NULL)
+ {
+ _tcscpy(str, H_DEFAULT);
+ wSetData(&opt.hText, str);
+ }
+ if (strchr(in, 'X') != NULL)
+ {
+ _tcscpy(str, X_DEFAULT);
+ wSetData(&opt.xText, str);
+ }
+ if (strchr(in, 'P') != NULL)
+ {
+ _tcscpy(str, P_DEFAULT);
+ wSetData(&opt.pTitle, str);
+ }
+ if (strchr(in, 'p') != NULL)
+ {
+ _tcscpy(str, p_DEFAULT);
+ wSetData(&opt.pText, str);
+ }
+ if (strchr(in, 'S') != NULL)
+ {
+ _tcscpy(str, s_DEFAULT);
+ wSetData(&opt.sText, str);
+ }
+}
+
+void DestroyOptions(void)
+{
+ wfree(&opt.cText);
+ wfree(&opt.bTitle);
+ wfree(&opt.bText);
+ wfree(&opt.nText);
+ wfree(&opt.eText);
+ wfree(&opt.hText);
+ wfree(&opt.xText);
+ wfree(&opt.pTitle);
+ wfree(&opt.pText);
+ wfree(&opt.sText);
+}
+
+// load options from database + set default if the setting does not exist
+void LoadOptions(void)
+{
+ DBVARIANT dbv;
+ ZeroMemory(&opt, sizeof(opt));
+
+ // main options
+ opt.StartupUpdate = db_get_b(NULL, WEATHERPROTONAME, "StartupUpdate",TRUE);
+ opt.AutoUpdate = db_get_b(NULL, WEATHERPROTONAME, "AutoUpdate",TRUE);
+ opt.UpdateTime = db_get_w(NULL, WEATHERPROTONAME, "UpdateTime",30);
+ opt.NewBrowserWin = db_get_b(NULL, WEATHERPROTONAME, "NewWindow",TRUE);
+ opt.NoProtoCondition = db_get_b(NULL, WEATHERPROTONAME, "NoStatus",0);
+ opt.UpdateOnlyConditionChanged = db_get_b(NULL, WEATHERPROTONAME, "CondChangeAsUpdate",TRUE);
+ opt.RemoveOldData = db_get_b(NULL, WEATHERPROTONAME, "RemoveOld",FALSE);
+ opt.MakeItalic = db_get_b(NULL, WEATHERPROTONAME, "MakeItalic",TRUE);
+ opt.AvatarSize = db_get_b(NULL, WEATHERPROTONAME, "AvatarSize", 128);
+ // units
+ opt.tUnit = db_get_w(NULL, WEATHERPROTONAME, "tUnit", 1);
+ opt.wUnit = db_get_w(NULL, WEATHERPROTONAME, "wUnit", 2);
+ opt.vUnit = db_get_w(NULL, WEATHERPROTONAME, "vUnit", 1);
+ opt.pUnit = db_get_w(NULL, WEATHERPROTONAME, "pUnit", 4);
+ opt.dUnit = db_get_w(NULL, WEATHERPROTONAME, "dUnit", 1);
+ opt.eUnit = db_get_w(NULL, WEATHERPROTONAME, "eUnit", 2);
+ if (DBGetContactSettingTString(NULL, WEATHERPROTONAME, "DegreeSign",&dbv))
+ _tcscpy(opt.DegreeSign, _T(""));
+ else {
+ _tcscpy(opt.DegreeSign, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ opt.DoNotAppendUnit = db_get_b(NULL, WEATHERPROTONAME, "DoNotAppendUnit", 0);
+ opt.NoFrac = db_get_b(NULL, WEATHERPROTONAME, "NoFractions", 0);
+ // texts
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "DisplayText",&dbv)) {
+ wSetData(&opt.cText, TranslateTS(dbv.ptszVal));
+ db_free(&dbv);
+ }
+ else SetTextDefault("C");
+
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "BriefTextTitle",&dbv)) {
+ wSetData(&opt.bTitle, TranslateTS(dbv.ptszVal));
+ db_free(&dbv);
+ }
+ else SetTextDefault("b");
+
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "BriefText",&dbv)) {
+ wSetData(&opt.bText, TranslateTS(dbv.ptszVal));
+ db_free(&dbv);
+ }
+ else SetTextDefault("B");
+
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "NoteText",&dbv)) {
+ wSetData(&opt.nText, TranslateTS(dbv.ptszVal));
+ db_free(&dbv);
+ }
+ else SetTextDefault("N");
+
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "ExtText",&dbv)) {
+ wSetData(&opt.eText, TranslateTS(dbv.ptszVal));
+ db_free(&dbv);
+ }
+ else SetTextDefault("E");
+
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "HistoryText",&dbv)) {
+ wSetData(&opt.hText, TranslateTS(dbv.ptszVal));
+ db_free(&dbv);
+ }
+ else SetTextDefault("H");
+
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "ExtraText",&dbv)) {
+ wSetData(&opt.xText, TranslateTS(dbv.ptszVal));
+ db_free(&dbv);
+ }
+ else SetTextDefault("X");
+
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "StatusText",&dbv)) {
+ wSetData(&opt.sText, TranslateTS(dbv.ptszVal));
+ db_free(&dbv);
+ }
+ else SetTextDefault("S");
+
+ // advanced
+ opt.DisCondIcon = db_get_b(NULL, WEATHERPROTONAME, "DisableConditionIcon",FALSE);
+ // popup options
+ opt.UsePopup = db_get_b(NULL, WEATHERPROTONAME, "UsePopUp",TRUE);
+ opt.UpdatePopup = db_get_b(NULL, WEATHERPROTONAME, "UpdatePopup",TRUE);
+ opt.AlertPopup = db_get_b(NULL, WEATHERPROTONAME, "AlertPopup",TRUE);
+ opt.PopupOnChange = db_get_b(NULL, WEATHERPROTONAME, "PopUpOnChange",TRUE);
+ opt.ShowWarnings = db_get_b(NULL, WEATHERPROTONAME, "ShowWarnings",TRUE);
+ // popup colors
+ opt.BGColour = db_get_dw(NULL, WEATHERPROTONAME, "BackgroundColour",GetSysColor(COLOR_BTNFACE));
+ opt.TextColour = db_get_dw(NULL, WEATHERPROTONAME, "TextColour",GetSysColor(COLOR_WINDOWTEXT));
+ opt.UseWinColors = (BOOL)db_get_b(NULL, WEATHERPROTONAME, "UseWinColors", FALSE);
+ // popup actions
+ opt.LeftClickAction = db_get_dw(NULL, WEATHERPROTONAME, "LeftClickAction",IDM_M2);
+ opt.RightClickAction = db_get_dw(NULL, WEATHERPROTONAME, "RightClickAction",IDM_M1);
+ // popup delay
+ opt.pDelay = db_get_dw(NULL, WEATHERPROTONAME, "PopupDelay",0);
+ // popup texts
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "PopupTitle",&dbv)) {
+ wSetData(&opt.pTitle, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else SetTextDefault("P");
+
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "PopupText",&dbv)) {
+ wSetData(&opt.pText, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else SetTextDefault("p");
+
+ // misc
+ if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "Default",&dbv)) {
+ _tcscpy(opt.Default, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else opt.Default[0] = 0;
+}
+
+// save the options to database
+void SaveOptions(void)
+{
+ // main options
+ db_set_b(NULL, WEATHERPROTONAME, "StartupUpdate", (BYTE)opt.StartupUpdate);
+ db_set_b(NULL, WEATHERPROTONAME, "AutoUpdate", (BYTE)opt.AutoUpdate);
+ db_set_w(NULL, WEATHERPROTONAME, "UpdateTime", opt.UpdateTime);
+ db_set_b(NULL, WEATHERPROTONAME, "NewWindow", (BYTE)opt.NewBrowserWin);
+ db_set_b(NULL, WEATHERPROTONAME, "NoStatus", (BYTE)opt.NoProtoCondition);
+ db_set_b(NULL, WEATHERPROTONAME, "CondChangeAsUpdate", (BYTE)opt.UpdateOnlyConditionChanged);
+ db_set_b(NULL, WEATHERPROTONAME, "RemoveOld", (BYTE)opt.RemoveOldData);
+ db_set_b(NULL, WEATHERPROTONAME, "MakeItalic", (BYTE)opt.MakeItalic);
+ db_set_b(NULL, WEATHERPROTONAME, "AvatarSize", (BYTE)opt.AvatarSize);
+ // units
+ db_set_w(NULL, WEATHERPROTONAME, "tUnit", opt.tUnit);
+ db_set_w(NULL, WEATHERPROTONAME, "wUnit", opt.wUnit);
+ db_set_w(NULL, WEATHERPROTONAME, "vUnit", opt.vUnit);
+ db_set_w(NULL, WEATHERPROTONAME, "pUnit", opt.pUnit);
+ db_set_w(NULL, WEATHERPROTONAME, "dUnit", opt.dUnit);
+ db_set_w(NULL, WEATHERPROTONAME, "eUnit", opt.eUnit);
+ db_set_ts(NULL, WEATHERPROTONAME, "DegreeSign", opt.DegreeSign);
+ db_set_b(NULL, WEATHERPROTONAME, "DoNotAppendUnit", (BYTE)opt.DoNotAppendUnit);
+ db_set_b(NULL, WEATHERPROTONAME, "NoFractions", (BYTE)opt.NoFrac);
+ // texts
+ db_set_ts(NULL, WEATHERPROTONAME, "DisplayText", opt.cText);
+ db_set_ts(NULL, WEATHERPROTONAME, "BriefTextTitle", opt.bTitle);
+ db_set_ts(NULL, WEATHERPROTONAME, "BriefText", opt.bText);
+ db_set_ts(NULL, WEATHERPROTONAME, "NoteText", opt.nText);
+ db_set_ts(NULL, WEATHERPROTONAME, "ExtText", opt.eText);
+ db_set_ts(NULL, WEATHERPROTONAME, "HistoryText", opt.hText);
+ db_set_ts(NULL, WEATHERPROTONAME, "ExtraText", opt.xText);
+ db_set_ts(NULL, WEATHERPROTONAME, "StatusText", opt.sText);
+ // advanced
+ db_set_b(NULL, WEATHERPROTONAME, "DisableConditionIcon", (BYTE)opt.DisCondIcon);
+ // popup options
+ db_set_b(NULL, WEATHERPROTONAME, "UsePopUp", (BYTE)opt.UsePopup);
+ db_set_b(NULL, WEATHERPROTONAME, "UpdatePopup", (BYTE)opt.UpdatePopup);
+ db_set_b(NULL, WEATHERPROTONAME, "AlertPopup", (BYTE)opt.AlertPopup);
+ db_set_b(NULL, WEATHERPROTONAME, "PopUpOnChange", (BYTE)opt.PopupOnChange);
+ db_set_b(NULL, WEATHERPROTONAME, "ShowWarnings", (BYTE)opt.ShowWarnings);
+ // popup colors
+ db_set_dw(NULL, WEATHERPROTONAME, "BackgroundColour", opt.BGColour);
+ db_set_dw(NULL, WEATHERPROTONAME, "TextColour", opt.TextColour);
+ db_set_b(NULL, WEATHERPROTONAME, "UseWinColors", (BYTE)opt.UseWinColors);
+ // popup actions
+ db_set_dw(NULL, WEATHERPROTONAME, "LeftClickAction", opt.LeftClickAction);
+ db_set_dw(NULL, WEATHERPROTONAME, "RightClickAction", opt.RightClickAction);
+ // popup delay
+ db_set_dw(NULL, WEATHERPROTONAME, "PopupDelay", opt.pDelay);
+ // popup texts
+ db_set_ts(NULL, WEATHERPROTONAME, "PopupTitle", opt.pTitle);
+ db_set_ts(NULL, WEATHERPROTONAME, "PopupText", opt.pText);
+ // misc stuff
+ db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
+}
+
+//============ OPTION INITIALIZATION ============
+
+// register the weather option pages
+int OptInit(WPARAM wParam,LPARAM lParam) {
+ OPTIONSDIALOGPAGE odp = {0};
+
+ odp.cbSize = sizeof(odp);
+ odp.hInstance = hInst;
+
+ // plugin options
+ odp.position = 95600;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
+ odp.pfnDlgProc = OptionsProc;
+ odp.ptszGroup = LPGENT("Network");
+ odp.ptszTitle = _T(WEATHERPROTOTEXT);
+ odp.ptszTab = LPGENT("General");
+ odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ Options_AddPage(wParam, &odp);
+
+ // text options
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_TEXTOPT);
+ odp.pfnDlgProc = DlgProcText;
+ odp.ptszTab = LPGENT("Display");
+ Options_AddPage(wParam, &odp);
+
+ // if popup service exists, load the weather popup options
+ if (( ServiceExists(MS_POPUP_ADDPOPUPT))) {
+ odp.position = 100000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP);
+ odp.ptszGroup = LPGENT("PopUps");
+ odp.groupPosition = 910000000;
+ odp.ptszTab = NULL;
+ odp.pfnDlgProc = DlgPopUpOpts;
+ Options_AddPage(wParam, &odp);
+ }
+
+ return 0;
+}
+
+//============ MAIN OPTIONS ============
+
+// weather options
+INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ TCHAR str[512];
+
+ switch(msg) {
+ case WM_INITDIALOG:
+ opt_startup = TRUE;
+ TranslateDialogDefault(hdlg);
+ // load settings
+ _ltot(opt.UpdateTime, str, 10);
+ SetDlgItemText(hdlg, IDC_UPDATETIME, str);
+ SetDlgItemText(hdlg, IDC_DEGREE, opt.DegreeSign);
+
+ SendDlgItemMessage(hdlg, IDC_AVATARSPIN, UDM_SETRANGE32, 0, 999);
+ SendDlgItemMessage(hdlg, IDC_AVATARSPIN, UDM_SETPOS, 0, opt.AvatarSize);
+ SendDlgItemMessage(hdlg, IDC_AVATARSIZE, EM_LIMITTEXT, 3, 0);
+
+ CheckDlgButton(hdlg, IDC_STARTUPUPD, opt.StartupUpdate);
+ CheckDlgButton(hdlg, IDC_UPDATE, opt.AutoUpdate);
+ CheckDlgButton(hdlg, IDC_PROTOCOND, !opt.NoProtoCondition);
+ CheckDlgButton(hdlg, IDC_UPDCONDCHG, opt.UpdateOnlyConditionChanged);
+ CheckDlgButton(hdlg, IDC_NEWWIN, opt.NewBrowserWin);
+ CheckDlgButton(hdlg, IDC_REMOVEOLD, opt.RemoveOldData);
+ CheckDlgButton(hdlg, IDC_MAKEI, opt.MakeItalic);
+ CheckDlgButton(hdlg, IDC_DISCONDICON, opt.DisCondIcon);
+ CheckDlgButton(hdlg, IDC_DONOTAPPUNITS, opt.DoNotAppendUnit);
+ CheckDlgButton(hdlg, IDC_NOFRAC, opt.NoFrac);
+
+ // load units
+ switch (opt.tUnit) { // temperature
+ case 1: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T1); break;
+ case 2: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T2); break;
+ }
+ switch (opt.wUnit) { // wind
+ case 1: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W1); break;
+ case 2: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W2); break;
+ case 3: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W3); break;
+ case 4: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W4); break;
+ }
+ switch (opt.vUnit) { // visibility
+ case 1: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V1); break;
+ case 2: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V2); break;
+ }
+ switch (opt.pUnit) { // pressure
+ case 1: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P1); break;
+ case 2: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P2); break;
+ case 3: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P3); break;
+ case 4: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P4); break;
+ }
+ switch (opt.dUnit) { // pressure
+ case 1: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D1); break;
+ case 2: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D2); break;
+ case 3: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D3); break;
+ }
+
+ switch (opt.eUnit) { // elev
+ case 1: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E1); break;
+ case 2: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E2); break;
+ }
+
+ opt_startup = FALSE;
+ return 0;
+
+ case WM_COMMAND:
+ if (HIWORD(wparam)==BN_CLICKED && GetFocus()==(HWND)lparam)
+ if ( !opt_startup) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ if ( !((LOWORD(wparam) == IDC_UPDATE || LOWORD(wparam) == IDC_DEGREE) &&
+ (HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus())))
+ if ( !opt_startup) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ return 0;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lparam)->code) {
+ case PSN_APPLY:
+ // change the status for weather protocol
+ if (IsDlgButtonChecked(hdlg, IDC_PROTOCOND) && opt.DefStn != NULL) {
+ old_status = status;
+ status = db_get_w(opt.DefStn, WEATHERPROTONAME, "StatusIcon", NOSTATUSDATA);
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, status);
+ }
+
+ // get update time and remove the old timer
+ GetDlgItemText(hdlg, IDC_UPDATETIME, str, sizeof(str));
+ opt.UpdateTime = (WORD)_ttoi(str);
+ if (opt.UpdateTime < 1) opt.UpdateTime = 1;
+ KillTimer(NULL, timerId);
+ timerId = SetTimer(NULL, 0, opt.UpdateTime*60000, (TIMERPROC)timerProc);
+
+ // other general options
+ GetDlgItemText(hdlg, IDC_DEGREE, opt.DegreeSign, sizeof(opt.DegreeSign));
+ opt.StartupUpdate = IsDlgButtonChecked(hdlg, IDC_STARTUPUPD);
+ opt.AutoUpdate = IsDlgButtonChecked(hdlg, IDC_UPDATE);
+ opt.NewBrowserWin = IsDlgButtonChecked(hdlg, IDC_NEWWIN);
+ opt.NoProtoCondition = !IsDlgButtonChecked(hdlg, IDC_PROTOCOND);
+ opt.DisCondIcon = IsDlgButtonChecked(hdlg, IDC_DISCONDICON);
+ opt.UpdateOnlyConditionChanged = (BYTE)IsDlgButtonChecked(hdlg, IDC_UPDCONDCHG);
+ opt.RemoveOldData = IsDlgButtonChecked(hdlg, IDC_REMOVEOLD);
+ opt.MakeItalic = IsDlgButtonChecked(hdlg, IDC_MAKEI);
+ opt.AvatarSize = GetDlgItemInt(hdlg, IDC_AVATARSIZE, NULL, FALSE);;
+ opt.DoNotAppendUnit = IsDlgButtonChecked(hdlg, IDC_DONOTAPPUNITS);
+ opt.NoFrac = IsDlgButtonChecked(hdlg, IDC_NOFRAC);
+ UpdateMenu(opt.AutoUpdate);
+
+ // save the units
+ if (IsDlgButtonChecked(hdlg, IDC_T1)) opt.tUnit = 1;
+ if (IsDlgButtonChecked(hdlg, IDC_T2)) opt.tUnit = 2;
+ if (IsDlgButtonChecked(hdlg, IDC_W1)) opt.wUnit = 1;
+ if (IsDlgButtonChecked(hdlg, IDC_W2)) opt.wUnit = 2;
+ if (IsDlgButtonChecked(hdlg, IDC_W3)) opt.wUnit = 3;
+ if (IsDlgButtonChecked(hdlg, IDC_W4)) opt.wUnit = 4;
+ if (IsDlgButtonChecked(hdlg, IDC_V1)) opt.vUnit = 1;
+ if (IsDlgButtonChecked(hdlg, IDC_V2)) opt.vUnit = 2;
+ if (IsDlgButtonChecked(hdlg, IDC_P1)) opt.pUnit = 1;
+ if (IsDlgButtonChecked(hdlg, IDC_P2)) opt.pUnit = 2;
+ if (IsDlgButtonChecked(hdlg, IDC_P3)) opt.pUnit = 3;
+ if (IsDlgButtonChecked(hdlg, IDC_P4)) opt.pUnit = 4;
+ if (IsDlgButtonChecked(hdlg, IDC_D1)) opt.dUnit = 1;
+ if (IsDlgButtonChecked(hdlg, IDC_D2)) opt.dUnit = 2;
+ if (IsDlgButtonChecked(hdlg, IDC_D3)) opt.dUnit = 3;
+ if (IsDlgButtonChecked(hdlg, IDC_E1)) opt.eUnit = 1;
+ if (IsDlgButtonChecked(hdlg, IDC_E2)) opt.eUnit = 2;
+
+ // save the new weather options
+ SaveOptions();
+
+ RedrawFrame(0, 0);
+
+ return 1;
+ }
+ break;
+ }
+ return 0;
+}
+
+//============ TEXT OPTION DIALOG ============
+
+void LoadTextSettings(HWND hdlg)
+{
+ // load text option settings from memory
+ SetDlgItemText(hdlg, IDC_CTEXT, opt.cText);
+ SetDlgItemText(hdlg, IDC_BTITLE, opt.bTitle);
+ SetDlgItemText(hdlg, IDC_BTEXT, opt.bText);
+ SetDlgItemText(hdlg, IDC_ETEXT, opt.eText);
+ SetDlgItemText(hdlg, IDC_NTEXT, opt.nText);
+ SetDlgItemText(hdlg, IDC_HTEXT, opt.hText);
+ SetDlgItemText(hdlg, IDC_XTEXT, opt.xText);
+ SetDlgItemText(hdlg, IDC_BTITLE2, opt.sText);
+}
+
+// free the display text settings from memory
+void FreeTextVar(void)
+{
+ wfree(&opt.cText);
+ wfree(&opt.bText);
+ wfree(&opt.bTitle);
+ wfree(&opt.eText);
+ wfree(&opt.nText);
+ wfree(&opt.hText);
+ wfree(&opt.xText);
+ wfree(&opt.sText);
+}
+
+// text option dialog
+
+static const char *varname[8] = {"C", "b", "B", "N", "X", "E", "H", "S"};
+static const int cname[8] = {IDC_CTEXT, IDC_BTITLE, IDC_BTEXT, IDC_NTEXT, IDC_XTEXT, IDC_ETEXT, IDC_HTEXT, IDC_BTITLE2 };
+static TCHAR* const *var[8] = {&opt.cText, &opt.bTitle, &opt.bText, &opt.nText, &opt.xText, &opt.eText, &opt.hText, &opt.sText };
+
+INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ RECT rc, pos;
+ HWND button;
+ HMENU hMenu, hMenu1;
+ TCHAR str[4096];
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ opt_startup = TRUE;
+ // set windows position, make it top-most
+ GetWindowRect(hdlg, &rc);
+ SetWindowPos(hdlg, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE);
+ TranslateDialogDefault(hdlg);
+ // generate the display text for variable list
+ _tcscpy(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temp\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
+ SetDlgItemText(hdlg, IDC_VARLIST, str);
+
+ // make the more variable and other buttons flat
+ SendMessage(GetDlgItem(hdlg,IDC_MORE), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_TM1), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_TM2), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_TM3), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_TM4), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_TM5), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_TM6), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_TM7), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_TM8), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_RESET), BUTTONSETASFLATBTN, TRUE, 0);
+ // load the settings
+ LoadTextSettings(hdlg);
+ opt_startup = FALSE;
+ return TRUE;
+
+ case WM_COMMAND:
+ if (opt_startup) return TRUE;
+ switch(LOWORD(wParam)) {
+ case IDC_CTEXT:
+ case IDC_BTITLE:
+ case IDC_BTEXT:
+ case IDC_NTEXT:
+ case IDC_XTEXT:
+ case IDC_ETEXT:
+ case IDC_HTEXT:
+ case IDC_BTITLE2:
+ if (HIWORD(wParam) == EN_CHANGE)
+ SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ break;
+
+ case IDC_MORE:
+ // display custom variables list
+ MoreVarList();
+ break;
+
+ case IDC_TM1:
+ case IDC_TM2:
+ case IDC_TM3:
+ case IDC_TM4:
+ case IDC_TM5:
+ case IDC_TM6:
+ case IDC_TM7:
+ case IDC_TM8:
+ {
+ WEATHERINFO winfo;
+
+ // display the menu
+ button = GetDlgItem(hdlg, LOWORD(wParam));
+ GetWindowRect(button, &pos);
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ TranslateMenu(hMenu1);
+ switch(TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL)) {
+ case ID_MPREVIEW:
+ // show the preview in a message box, using the weather data from the default station
+ winfo = LoadWeatherInfo(opt.DefStn);
+ GetDisplay(&winfo, *var[LOWORD(wParam)-IDC_TM1], str);
+ MessageBox(NULL, str, TranslateT("Weather Protocol Text Preview"), MB_OK|MB_TOPMOST);
+ break;
+
+ case ID_MRESET:
+ {
+ unsigned varo = LOWORD(wParam) - IDC_TM1;
+ // remove the old setting from db and free memory
+ TCHAR* vartmp = *var[varo];
+ wfree(&vartmp);
+ SetTextDefault(varname[varo]);
+ SetDlgItemText(hdlg, cname[varo], *var[varo]);
+ }
+ break;
+ }
+ DestroyMenu(hMenu);
+ break;
+ }
+
+ case IDC_RESET:
+ // left click action selection menu
+ button = GetDlgItem(hdlg, IDC_RESET);
+ GetWindowRect(button, &pos);
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ TranslateMenu(hMenu1);
+ switch(TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL))
+ {
+ case ID_T1:
+ // reset to the strings in memory, discard all changes
+ LoadTextSettings(hdlg);
+ break;
+
+ case ID_T2:
+ // reset to the default setting
+ FreeTextVar();
+ SetTextDefault("CbBENHX");
+ LoadTextSettings(hdlg);
+ break;
+ }
+ DestroyMenu(hMenu);
+ break;
+ }
+ return TRUE;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ // save the option
+ TCHAR textstr[MAX_TEXT_SIZE];
+ // free memory for old settings
+ FreeTextVar();
+ // save new settings to memory
+ GetDlgItemText(hdlg, IDC_CTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.cText, textstr);
+ GetDlgItemText(hdlg, IDC_BTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.bText, textstr);
+ GetDlgItemText(hdlg, IDC_BTITLE, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.bTitle, textstr);
+ GetDlgItemText(hdlg, IDC_ETEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.eText, textstr);
+ GetDlgItemText(hdlg, IDC_NTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.nText, textstr);
+ GetDlgItemText(hdlg, IDC_HTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.hText, textstr);
+ GetDlgItemText(hdlg, IDC_XTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.xText, textstr);
+ GetDlgItemText(hdlg, IDC_BTITLE2, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.sText, textstr);
+ SaveOptions();
+ UpdateAllInfo(0, 0);
+ break;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
diff --git a/plugins/Weather/src/weather_popup.cpp b/plugins/Weather/src/weather_popup.cpp new file mode 100644 index 0000000000..2a3e3580e5 --- /dev/null +++ b/plugins/Weather/src/weather_popup.cpp @@ -0,0 +1,438 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2009 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This file contain the source related to weather popups, including popup
+ options, popup display, and the code for popup process.
+*/
+
+#include "weather.h"
+
+// variables for weather_popup.c
+static HANDLE hPopupContact;
+
+//============ SHOW WEATHER POPUPS ============
+
+// display weather popups
+// wParam = the contact to display popup
+// lParam = whether the weather data is changed or not
+int WeatherPopup(WPARAM wParam, LPARAM lParam)
+{
+ // determine if the popup should display or not
+ if (opt.UsePopup && opt.UpdatePopup && (!opt.PopupOnChange || (BOOL)lParam) &&
+ !db_get_b((HANDLE)wParam, WEATHERPROTONAME, "DPopUp", 0))
+ {
+ POPUPDATAT ppd = {0};
+ WEATHERINFO winfo;
+
+ // setup the popup
+ ppd.lchContact = (HANDLE)wParam;
+// if ((HANDLE)wParam != NULL) { // for actual contact
+ winfo = LoadWeatherInfo((HANDLE)wParam);
+ ppd.PluginData = ppd.lchIcon = LoadSkinnedProtoIcon(WEATHERPROTONAME, winfo.status);
+ GetDisplay(&winfo, opt.pTitle, ppd.lptzContactName);
+ GetDisplay(&winfo, opt.pText, ppd.lptzText);
+ ppd.PluginWindowProc = PopupDlgProc;
+// }
+// else { // for preview
+// ppd.lchIcon = LoadSkinnedProtoIcon(WEATHERPROTONAME, ONLINE);
+// strcpy(ppd.lpzContactName, Translate("This is the name of the city"));
+// strcpy(ppd.lpzText, Translate("Here is a short weather description"));
+// ppd.PluginWindowProc = NULL;
+// }
+ ppd.colorBack = (opt.UseWinColors)?GetSysColor(COLOR_BTNFACE):opt.BGColour;
+ ppd.colorText = (opt.UseWinColors)?GetSysColor(COLOR_WINDOWTEXT):opt.TextColour;
+ ppd.iSeconds = opt.pDelay;
+ PUAddPopUpT( &ppd );
+ }
+ return 0;
+}
+
+//============ WEATHER ERROR POPUPS ============
+
+// display weather error or notices (not threaded)
+// wParam = error text
+// lParam = display type
+// Type can either be SM_WARNING, SM_NOTIFY, or SM_WEATHERALERT
+
+int WeatherError(WPARAM wParam, LPARAM lParam)
+{
+ if ( !opt.UsePopup)
+ return 0;
+
+ TCHAR* tszMsg = ( TCHAR* )wParam;
+
+ if ((DWORD)lParam == SM_WARNING)
+ PUShowMessageT( tszMsg, SM_WARNING );
+ else if ((DWORD)lParam == SM_NOTIFY)
+ PUShowMessageT( tszMsg, SM_NOTIFY);
+ else if ((DWORD)lParam == SM_WEATHERALERT)
+ {
+ POPUPDATAT ppd = {0};
+ TCHAR *chop, str1[512], str2[512];
+
+ // get the 2 strings
+ _tcscpy(str1, tszMsg);
+ _tcscpy(str2, tszMsg);
+ chop = _tcschr(str1, 255);
+ if (chop != NULL) *chop = '\0';
+ else str1[0] = 0;
+ chop = _tcschr(str2, 255);
+ if (chop != NULL) _tcscpy(str2, chop+1);
+ else str2[0] = 0;
+
+ // setup the popup
+ ppd.lchIcon = (HICON)LoadImage(NULL, MAKEINTRESOURCE(OIC_BANG), IMAGE_ICON,
+ GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
+ _tcscpy(ppd.lptzContactName, str1);
+ _tcscpy(ppd.lptzText, str2);
+ ppd.colorBack = (opt.UseWinColors)?GetSysColor(COLOR_BTNFACE):opt.BGColour;
+ ppd.colorText = (opt.UseWinColors)?GetSysColor(COLOR_WINDOWTEXT):opt.TextColour;
+ ppd.iSeconds = opt.pDelay;
+ PUAddPopUpT( &ppd );
+ }
+ return 0;
+}
+
+// wrapper function for displaying weather warning popup by triggering an event
+// (threaded)
+// lpzText = error text
+// kind = display type (see m_popup.h)
+
+int WPShowMessage(TCHAR* lpzText, WORD kind)
+{
+ NotifyEventHooks(hHookWeatherError, (WPARAM)lpzText, (LPARAM)kind);
+ return 0;
+}
+
+//============ WEATHER POPUP PROCESSES ============
+
+// popup dialog pocess
+// for selecting actions when click on the popup window
+// use for displaying contact menu
+LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ DWORD ID = 0;
+ HANDLE hContact;
+ hContact = PUGetContact(hWnd);
+
+ switch(message) {
+ case WM_COMMAND:
+ ID = opt.LeftClickAction;
+ if (ID != IDM_M7) PUDeletePopUp(hWnd);
+ SendMessage(hPopupWindow, ID, (WPARAM)hContact, 0);
+ return TRUE;
+
+ case WM_CONTEXTMENU:
+ ID = opt.RightClickAction;
+ if (ID != IDM_M7) PUDeletePopUp(hWnd);
+ SendMessage(hPopupWindow, ID, (WPARAM)hContact, 0);
+ return TRUE;
+
+ case UM_FREEPLUGINDATA:
+ Skin_ReleaseIcon((HICON)PUGetPluginData(hWnd));
+ return FALSE;
+ }
+
+ return DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+// process for the popup window
+// containing the code for popup actions
+LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ POINT pt;
+ HMENU hMenu;
+ switch (uMsg) {
+ case IDM_M2: // brief info
+ BriefInfo(wParam, 0);
+ break;
+
+ case IDM_M3: // read complete forecast
+ LoadForecast(wParam, 0);
+ break;
+
+ case IDM_M4: // display weather map
+ WeatherMap(wParam, 0);
+ break;
+
+ case IDM_M5: // open history window
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, wParam, 0);
+ break;
+
+ case IDM_M6: // open external log
+ ViewLog(wParam, 0);
+ break;
+
+ case IDM_M7: // display contact menu
+ hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT,wParam,0);
+ GetCursorPos(&pt);
+ hPopupContact = (HANDLE)wParam;
+ TrackPopupMenu(hMenu,TPM_LEFTALIGN,pt.x,pt.y,0,hWnd,NULL);
+ DestroyMenu(hMenu);
+ break;
+
+ case IDM_M8: // display contact detail
+ CallService(MS_USERINFO_SHOWDIALOG, wParam, 0);
+
+ case WM_COMMAND: //Needed by the contact's context menu
+ if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)hPopupContact))
+ break;
+ return FALSE;
+
+ case WM_MEASUREITEM: //Needed by the contact's context menu
+ return CallService(MS_CLIST_MENUMEASUREITEM,wParam,lParam);
+
+ case WM_DRAWITEM: //Needed by the contact's context menu
+ return CallService(MS_CLIST_MENUDRAWITEM,wParam,lParam);
+ }
+
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);//FALSE;
+}
+
+//============ POPUP OPTIONS ============
+
+// used to select the menu item for popup action menu
+static void SelectMenuItem(HMENU hMenu, int Check)
+{
+ for (int i=0; i <= GetMenuItemCount(hMenu)-1; i++)
+ CheckMenuItem(hMenu, i, MF_BYPOSITION|((int)GetMenuItemID(hMenu, i) == Check)*8);
+}
+
+// temporary read the current option to memory
+// but does not write to the database
+void ReadPopupOpt(HWND hdlg)
+{
+ TCHAR text[MAX_TEXT_SIZE];
+ int num;
+ TCHAR str[512];
+
+ // popup colour
+ opt.TextColour = SendDlgItemMessage(hdlg,IDC_TEXTCOLOUR,CPM_GETCOLOUR,0,0);
+ opt.BGColour = SendDlgItemMessage(hdlg,IDC_BGCOLOUR,CPM_GETCOLOUR,0,0);
+
+ // get delay time
+ GetDlgItemText(hdlg, IDC_DELAY, str, sizeof(str));
+ num = _ttoi(str);
+ opt.pDelay = num;
+
+ // other options
+ opt.UseWinColors = (BYTE)IsDlgButtonChecked(hdlg, IDC_USEWINCOLORS);
+ opt.UsePopup = (BYTE)IsDlgButtonChecked(hdlg, IDC_E);
+ opt.UpdatePopup = (BYTE)IsDlgButtonChecked(hdlg, IDC_POP1);
+ opt.AlertPopup = (BYTE)IsDlgButtonChecked(hdlg, IDC_POP2);
+ opt.PopupOnChange = (BYTE)IsDlgButtonChecked(hdlg, IDC_CH);
+ opt.ShowWarnings = (BYTE)IsDlgButtonChecked(hdlg, IDC_W);
+
+ // popup texts
+ wfree(&opt.pText);
+ wfree(&opt.pTitle);
+ GetDlgItemText(hdlg, IDC_PText, text, MAX_TEXT_SIZE);
+ wSetData(&opt.pText, text);
+ GetDlgItemText(hdlg, IDC_PTitle, text, MAX_TEXT_SIZE);
+ wSetData(&opt.pTitle, text);
+}
+
+// copied and modified from NewStatusNotify
+INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ int ID;
+ TCHAR str[512];
+ HMENU hMenu, hMenu1;
+ RECT pos;
+ HWND button;
+ HANDLE hContact;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hdlg);
+ SaveOptions();
+
+ // click actions
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
+ SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
+ GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
+ SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
+ DestroyMenu(hMenu);
+
+ // other options
+ CheckDlgButton(hdlg, IDC_E, opt.UsePopup);
+ CheckDlgButton(hdlg, IDC_POP2, opt.AlertPopup);
+ CheckDlgButton(hdlg, IDC_POP1, opt.UpdatePopup);
+ CheckDlgButton(hdlg, IDC_CH, opt.PopupOnChange);
+ CheckDlgButton(hdlg, IDC_W, opt.ShowWarnings);
+ SetDlgItemText(hdlg,IDC_PText, opt.pText);
+ SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
+ // setting popup delay option
+ _ltot(opt.pDelay, str, 10);
+ SetDlgItemText(hdlg,IDC_DELAY, str);
+ if (opt.pDelay == -1)
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
+ else if (opt.pDelay == 0)
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
+ else
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
+ //Colours. First step is configuring the colours.
+ SendDlgItemMessage(hdlg,IDC_BGCOLOUR,CPM_SETCOLOUR,0,opt.BGColour);
+ SendDlgItemMessage(hdlg,IDC_TEXTCOLOUR,CPM_SETCOLOUR,0,opt.TextColour);
+ //Second step is disabling them if we want to use default Windows ones.
+ CheckDlgButton(hdlg, IDC_USEWINCOLORS,opt.UseWinColors?BST_CHECKED:BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !opt.UseWinColors);
+ EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !opt.UseWinColors);
+
+ // buttons
+ SendMessage(GetDlgItem(hdlg,IDC_PREVIEW), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_PDEF), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_LeftClick), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_RightClick), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg,IDC_VAR3), BUTTONSETASFLATBTN, TRUE, 0);
+ return TRUE;
+
+ case WM_COMMAND:
+ // enable the "apply" button
+ if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam)
+ SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ if ( !((LOWORD(wParam) == IDC_UPDATE || LOWORD(wParam) == IDC_DEGREE) &&
+ (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())))
+ SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ //These are simple clicks: we don't save, but we tell the Options Page to enable the "Apply" button.
+ switch(LOWORD(wParam)) {
+ case IDC_BGCOLOUR: //Fall through
+ case IDC_TEXTCOLOUR:
+ // select new colors
+ if (HIWORD(wParam) == CPN_COLOURCHANGED)
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_USEWINCOLORS:
+ // use window color - enable/disable color selection controls
+ EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !(opt.UseWinColors));
+ EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !(opt.UseWinColors));
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_E:
+ case IDC_CH:
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_RightClick:
+ // right click action selection menu
+ button = GetDlgItem(hdlg, IDC_RightClick);
+ GetWindowRect(button, &pos);
+
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ TranslateMenu(hMenu1);
+ SelectMenuItem(hMenu1, opt.RightClickAction);
+ ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
+ if (ID) opt.RightClickAction = ID;
+ DestroyMenu(hMenu);
+
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
+ SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
+ DestroyMenu(hMenu);
+ break;
+
+ case IDC_LeftClick:
+ // left click action selection menu
+ button = GetDlgItem(hdlg, IDC_LeftClick);
+ GetWindowRect(button, &pos);
+
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ TranslateMenu(hMenu1);
+ SelectMenuItem(hMenu1, opt.LeftClickAction);
+ ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
+ if (ID) opt.LeftClickAction = ID;
+ DestroyMenu(hMenu);
+
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
+ SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
+ DestroyMenu(hMenu);
+ break;
+
+ case IDC_PD1:
+ // Popup delay setting from PopUp plugin
+ SetDlgItemText(hdlg, IDC_DELAY, _T("0"));
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
+ break;
+
+ case IDC_PD2:
+ // Popup delay = permanent
+ SetDlgItemText(hdlg, IDC_DELAY, _T("-1"));
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
+ break;
+
+ case IDC_DELAY:
+ // if text is edited
+ CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
+ break;
+
+ case IDC_PDEF:
+ // set the default value for popup texts
+ SetTextDefault("Pp");
+ SetDlgItemText(hdlg,IDC_PText, opt.pText);
+ SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
+ wfree(&opt.pText);
+ wfree(&opt.pTitle);
+ break;
+
+ case IDC_VAR3:
+ // display variable list
+ _tcscpy(str, _T(" \n")); // to make the message box wider
+ _tcscat(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temperature\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
+ _tcscat(str, _T("\n"));
+ _tcscat(str, TranslateT("%[..]\tcustom variables"));
+ MessageBox(NULL, str, TranslateT("Variable List"), MB_OK|MB_ICONASTERISK|MB_TOPMOST);
+ break;
+
+ case IDC_PREVIEW:
+ // popup preview
+ hContact = opt.DefStn;
+ ReadPopupOpt(hdlg); // read new options to memory
+ WeatherPopup((WPARAM)opt.DefStn, (BOOL)TRUE); // display popup using new opt
+ DestroyOptions();
+ LoadOptions(); // restore old option in memory
+ opt.DefStn = hContact;
+ break;
+ }
+ break;
+
+ case WM_NOTIFY: //Here we have pressed either the OK or the APPLY button.
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY: {
+ ReadPopupOpt(hdlg);
+
+ // save the options, and update main menu
+ SaveOptions();
+ UpdatePopupMenu(opt.UsePopup);
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/plugins/Weather/src/weather_svcs.cpp b/plugins/Weather/src/weather_svcs.cpp new file mode 100644 index 0000000000..3872760fc6 --- /dev/null +++ b/plugins/Weather/src/weather_svcs.cpp @@ -0,0 +1,386 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+This file contain the source related to weather protocol services
+as required for a Miranda protocol. Also, it contains functions for
+building/changing the weather menu items.
+*/
+
+#include "weather.h"
+
+static HGENMENU hEnableDisablePopupMenu;
+static HGENMENU hEnableDisableMenu;
+
+//============ MIRANDA PROTOCOL SERVICES ============
+
+// protocol service function for setting weather protocol status
+INT_PTR WeatherSetStatus(WPARAM new_status, LPARAM lParam)
+{
+ new_status = new_status != ID_STATUS_OFFLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE;
+
+ // if we don't want to show status for default station
+ if (opt.NoProtoCondition && status != new_status) {
+ old_status = status;
+ status = new_status != ID_STATUS_OFFLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE;
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, status);
+
+ UpdateMenu(new_status != ID_STATUS_OFFLINE);
+ if (new_status != ID_STATUS_OFFLINE)
+ UpdateAll(FALSE, FALSE);
+ }
+
+ return 0;
+}
+
+// get capabilities protocol service function
+INT_PTR WeatherGetCaps(WPARAM wParam, LPARAM lParam)
+{
+ INT_PTR ret = 0;
+
+ switch(wParam) {
+ case PFLAGNUM_1:
+ // support search and visible list
+ ret = PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_EXTSEARCH | PF1_VISLIST | PF1_MODEMSGRECV;
+ break;
+
+ case PFLAGNUM_2:
+ ret = PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND |
+ PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
+ break;
+
+ case PFLAGNUM_4:
+ ret = PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEADDED |
+ PF4_FORCEAUTH;
+ break;
+
+ case PFLAGNUM_5: /* this is PFLAGNUM_5 change when alpha SDK is released */
+ ret = PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND |
+ PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
+ break;
+
+ case PFLAG_UNIQUEIDTEXT:
+ ret = (INT_PTR)Translate("Station ID");
+ break;
+
+ case PFLAG_UNIQUEIDSETTING:
+ ret = (INT_PTR)"ID";
+ break;
+ }
+ return ret;
+}
+
+// protocol service function to get weather protocol name
+INT_PTR WeatherGetName(WPARAM wParam,LPARAM lParam)
+{
+ strncpy((char*)lParam,WEATHERPROTOTEXT,wParam-1);
+ *((char*)lParam + wParam-1) = 0;
+ return 0;
+}
+
+// protocol service function to get the current status of the protocol
+INT_PTR WeatherGetStatus(WPARAM wParam,LPARAM lParam)
+{
+ return status;
+}
+
+// protocol service function to get the icon of the protocol
+INT_PTR WeatherLoadIcon(WPARAM wParam,LPARAM lParam)
+{
+ return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(LoadIconEx("main", FALSE)) : 0;
+}
+
+static void __cdecl AckThreadProc(HANDLE param)
+{
+ Sleep(100);
+ ProtoBroadcastAck(WEATHERPROTONAME, param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
+}
+
+// nothing to do here because weather proto do not need to retrieve contact info form network
+// so just return a 0
+INT_PTR WeatherGetInfo(WPARAM wParam,LPARAM lParam)
+{
+ CCSDATA *ccs = (CCSDATA *) lParam;
+ mir_forkthread(AckThreadProc, ccs->hContact);
+ return 0;
+}
+
+// avatars
+static const TCHAR *statusStr[] = { _T("Light"), _T("Fog"), _T("SShower"), _T("Snow"), _T("RShower"), _T("Rain"), _T("PCloudy"), _T("Cloudy"), _T("Sunny"), _T("NA") };
+static const WORD statusValue[] = { LIGHT, FOG, SSHOWER, SNOW, RSHOWER, RAIN, PCLOUDY, CLOUDY, SUNNY, NA };
+
+INT_PTR WeatherGetAvatarInfo(WPARAM wParam, LPARAM lParam)
+{
+ TCHAR szSearchPath[MAX_PATH], *chop;
+ WORD status;
+ unsigned i;
+ PROTO_AVATAR_INFORMATIONT* ai = ( PROTO_AVATAR_INFORMATIONT* )lParam;
+
+ GetModuleFileName(GetModuleHandle(NULL), szSearchPath, sizeof(szSearchPath));
+ chop = _tcsrchr(szSearchPath, '\\');
+
+ if (chop) *chop = '\0';
+ else szSearchPath[0] = 0;
+
+ status = (WORD)db_get_w(ai->hContact, WEATHERPROTONAME, "StatusIcon",0);
+ for (i=0; i<10; i++)
+ if (statusValue[i] == status)
+ break;
+
+ if (i >= 10)
+ return GAIR_NOAVATAR;
+
+ ai->format = PA_FORMAT_PNG;
+ wsprintf(ai->filename, _T("%s\\Plugins\\Weather\\%s.png"), szSearchPath, statusStr[i]);
+ if ( _taccess(ai->filename, 4) == 0)
+ return GAIR_SUCCESS;
+
+ ai->format = PA_FORMAT_GIF;
+ wsprintf(ai->filename, _T("%s\\Plugins\\Weather\\%s.gif"), szSearchPath, statusStr[i]);
+ if ( _taccess(ai->filename, 4) == 0)
+ return GAIR_SUCCESS;
+
+ ai->format = PA_FORMAT_UNKNOWN;
+ ai->filename[0] = 0;
+ return GAIR_NOAVATAR;
+}
+
+
+void AvatarDownloaded(HANDLE hContact)
+{
+ PROTO_AVATAR_INFORMATIONT AI = {0};
+ AI.cbSize = sizeof(AI);
+ AI.hContact = hContact;
+
+ if (WeatherGetAvatarInfo(GAIF_FORCE, (LPARAM)&AI) == GAIR_SUCCESS)
+ ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, &AI, 0);
+ else
+ ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0);
+}
+
+
+static void __cdecl WeatherGetAwayMsgThread(HANDLE hContact)
+{
+ Sleep(100);
+
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingTString(hContact, "CList", "StatusMsg", &dbv)) {
+ ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
+ db_free( &dbv );
+ }
+ else ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+}
+
+static INT_PTR WeatherGetAwayMsg(WPARAM wParam, LPARAM lParam)
+{
+ CCSDATA* ccs = (CCSDATA*)lParam;
+ if (ccs == NULL)
+ return 0;
+
+ mir_forkthread(WeatherGetAwayMsgThread, ccs->hContact);
+ return 1;
+}
+
+//============ PROTOCOL INITIALIZATION ============
+// protocol services
+void InitServices(void)
+{
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETCAPS, WeatherGetCaps);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETNAME, WeatherGetName);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_LOADICON, WeatherLoadIcon);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_SETSTATUS, WeatherSetStatus);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETSTATUS, WeatherGetStatus);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_BASICSEARCHT, WeatherBasicSearch);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_SEARCHBYEMAILT, WeatherBasicSearch);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_ADDTOLIST, WeatherAddToList);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PSS_GETINFO, WeatherGetInfo);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETAVATARINFOT, WeatherGetAvatarInfo);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PSS_GETAWAYMSG, WeatherGetAwayMsg);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_CREATEADVSEARCHUI, WeatherCreateAdvancedSearchUI);
+ CreateProtoServiceFunction(WEATHERPROTONAME, PS_SEARCHBYADVANCED, WeatherAdvancedSearch);
+
+ CreateProtoServiceFunction(WEATHERPROTONAME, MS_WEATHER_GETDISPLAY, GetDisplaySvcFunc);
+}
+
+//============ MENU INITIALIZATION ============
+
+void UpdateMenu(BOOL State)
+{
+ // update option setting
+ opt.CAutoUpdate = State;
+ db_set_b(NULL, WEATHERPROTONAME, "AutoUpdate", (BYTE)opt.AutoUpdate);
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+
+ if (State) { // to enable auto-update
+ mi.pszName = LPGEN("Auto Update Enabled");
+ mi.icolibItem = GetIconHandle("main");
+ }
+ else { // to disable auto-update
+ mi.pszName = LPGEN("Auto Update Disabled");
+ mi.icolibItem = GetIconHandle("disabled");
+ }
+
+ mi.flags = CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hEnableDisableMenu, (LPARAM)&mi);
+}
+
+void UpdatePopupMenu(BOOL State)
+{
+ // update option setting
+ opt.UsePopup = State;
+ db_set_b(NULL, WEATHERPROTONAME, "UsePopUp", (BYTE)opt.UsePopup);
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+ if (State)
+ { // to enable popup
+ mi.pszName = LPGEN("Disable &weather notification");
+ mi.icolibItem = GetIconHandle("popup");
+ }
+ else
+ { // to disable popup
+ mi.pszName = LPGEN("Enable &weather notification");
+ mi.icolibItem = GetIconHandle("nopopup");
+ }
+
+ mi.flags = CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hEnableDisablePopupMenu, (LPARAM)&mi);
+}
+
+// update the weather auto-update menu item when click on it
+INT_PTR EnableDisableCmd(WPARAM wParam,LPARAM lParam)
+{
+ UpdateMenu(wParam == TRUE ? (BOOL)lParam : !opt.CAutoUpdate);
+ return 0;
+}
+
+// update the weather popup menu item when click on it
+INT_PTR MenuitemNotifyCmd(WPARAM wParam,LPARAM lParam)
+{
+ UpdatePopupMenu(!opt.UsePopup);
+ return 0;
+}
+
+// adding weather contact menus
+// copied and modified form "modified MSN Protocol"
+void AddMenuItems(void)
+{
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.pszContactOwner = WEATHERPROTONAME;
+ mi.flags = CMIF_ICONFROMICOLIB;
+
+ // contact menu
+ CreateServiceFunction(MS_WEATHER_UPDATE, UpdateSingleStation);
+ mi.position = -0x7FFFFFFA;
+ mi.icolibItem = GetIconHandle("update");
+ mi.pszName = LPGEN("Update Weather");
+ mi.pszService = MS_WEATHER_UPDATE;
+ Menu_AddContactMenuItem(&mi);
+
+ CreateServiceFunction(MS_WEATHER_REFRESH, UpdateSingleRemove);
+ mi.position = -0x7FFFFFF9;
+ mi.icolibItem = GetIconHandle("update2");
+ mi.pszName = LPGEN("Remove Old Data then Update");
+ mi.pszService = MS_WEATHER_REFRESH;
+ Menu_AddContactMenuItem(&mi);
+
+ CreateServiceFunction(MS_WEATHER_BRIEF, BriefInfoSvc);
+ mi.position = -0x7FFFFFF8;
+ mi.icolibItem = GetIconHandle("brief");
+ mi.pszName = LPGEN("Brief Information");
+ mi.pszService = MS_WEATHER_BRIEF;
+ Menu_AddContactMenuItem(&mi);
+
+ CreateServiceFunction(MS_WEATHER_COMPLETE, LoadForecast);
+ mi.position = -0x7FFFFFF7;
+ mi.icolibItem = GetIconHandle("read");
+ mi.pszName = LPGEN("Read Complete Forecast");
+ mi.pszService = MS_WEATHER_COMPLETE;
+ Menu_AddContactMenuItem(&mi);
+
+ CreateServiceFunction(MS_WEATHER_MAP, WeatherMap);
+ mi.position = -0x7FFFFFF6;
+ mi.icolibItem = GetIconHandle("map");
+ mi.pszName = LPGEN("Weather Map");
+ mi.pszService = MS_WEATHER_MAP;
+ Menu_AddContactMenuItem(&mi);
+
+ CreateServiceFunction(MS_WEATHER_LOG, ViewLog);
+ mi.position = -0x7FFFFFF5;
+ mi.icolibItem = GetIconHandle("log");
+ mi.pszName = LPGEN("View Log");
+ mi.pszService = MS_WEATHER_LOG;
+ Menu_AddContactMenuItem(&mi);
+
+ CreateServiceFunction(MS_WEATHER_EDIT, EditSettings);
+ mi.position = -0x7FFFFFF4;
+ mi.icolibItem = GetIconHandle("edit");
+ mi.pszName = LPGEN("Edit Settings");
+ mi.pszService = MS_WEATHER_EDIT;
+ Menu_AddContactMenuItem(&mi);
+
+ // adding main menu items
+ mi.pszPopupName = LPGEN("Weather");
+ mi.popupPosition = 500099000;
+
+ CreateServiceFunction(MS_WEATHER_ENABLED, EnableDisableCmd);
+ mi.pszName = LPGEN("Enable/Disable Weather Update");
+ mi.icolibItem = GetIconHandle("main");
+ mi.position = 10100001;
+ mi.pszService = MS_WEATHER_ENABLED;
+ hEnableDisableMenu = Menu_AddMainMenuItem(&mi);
+ UpdateMenu(opt.AutoUpdate);
+
+ CreateServiceFunction(MS_WEATHER_UPDATEALL, UpdateAllInfo);
+ mi.position = 20100001;
+ mi.icolibItem = GetIconHandle("update");
+ mi.pszName = LPGEN("Update All Weather");
+ mi.pszService = MS_WEATHER_UPDATEALL;
+ Menu_AddMainMenuItem(&mi);
+
+ CreateServiceFunction(MS_WEATHER_REFRESHALL, UpdateAllRemove);
+ mi.position = 20100002;
+ mi.icolibItem = GetIconHandle("update2");
+ mi.pszName = LPGEN("Remove Old Data then Update All");
+ mi.pszService = MS_WEATHER_REFRESHALL;
+ Menu_AddMainMenuItem(&mi);
+
+ // only run if popup service exists
+ if ( ServiceExists(MS_POPUP_ADDPOPUPT)) {
+ CreateServiceFunction(WEATHERPROTONAME "/PopupMenu", MenuitemNotifyCmd);
+ mi.pszName = LPGEN("Weather Notification");
+ mi.icolibItem = GetIconHandle("popup");
+ mi.position = 0;
+ mi.pszPopupName = LPGEN("PopUps");
+ mi.pszService = WEATHERPROTONAME "/PopupMenu";
+ hEnableDisablePopupMenu = Menu_AddMainMenuItem(&mi);
+ UpdatePopupMenu(opt.UsePopup);
+ }
+
+ if ( ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ CreateServiceFunction("Weather/mwin_menu", Mwin_MenuClicked);
+ mi.position = -0x7FFFFFF0;
+ mi.hIcon = NULL;
+ mi.flags = 0;
+ mi.pszName = LPGEN("Display in a frame");
+ mi.pszService = "Weather/mwin_menu";
+ hMwinMenu = Menu_AddContactMenuItem(&mi);
+ }
+}
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp new file mode 100644 index 0000000000..d07af7865b --- /dev/null +++ b/plugins/Weather/src/weather_update.cpp @@ -0,0 +1,615 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+This file contain the source related to updating new weather
+information, both automatic (by timer) and manually (by selecting
+menu items).
+*/
+
+#include "weather.h"
+
+UPDATELIST *UpdateListHead;
+UPDATELIST *UpdateListTail;
+
+extern HANDLE hUpdateMutex;
+
+//============ RETRIEVE NEW WEATHER ============
+
+// retrieve weather info and display / log them
+// hContact = current contact
+int UpdateWeather(HANDLE hContact)
+{
+ TCHAR str[256], str2[MAX_TEXT_SIZE];
+ DBVARIANT dbv;
+ BOOL Ch = FALSE;
+
+ if (hContact == NULL) return 1; // some error prevention
+
+ dbv.pszVal = "";
+
+ // log to netlib log for debug purpose
+ Netlib_LogfT(hNetlibUser, _T("************************************************************************"));
+ int dbres = DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv);
+
+ Netlib_LogfT(hNetlibUser, _T("<-- Start update for station -->"));
+
+ // download the info and parse it
+ // result are stored in database
+ int code = GetWeatherData(hContact);
+ if (code != 0)
+ {
+ // error occurs if the return value is not equals to 0
+ if (opt.ShowWarnings)
+ { // show warnings by popup
+ mir_sntprintf(str, SIZEOF(str)-105,
+ TranslateT("Unable to retrieve weather information for %s"), dbv.ptszVal);
+ _tcscat(str, _T("\n"));
+ _tcscat(str, GetError(code));
+ WPShowMessage(str, SM_WARNING);
+ }
+ // log to netlib
+ Netlib_LogfT(hNetlibUser, _T("Error! Update cannot continue... Start to free memory"));
+ Netlib_LogfT(hNetlibUser, _T("<-- Error occurs while updating station: %s -->"), dbv.ptszVal);
+ if ( !dbres) db_free(&dbv);
+ return 1;
+ }
+ if ( !dbres) db_free(&dbv);
+
+ // initialize, load new weather Data
+ WEATHERINFO winfo = LoadWeatherInfo(hContact);
+
+ // translate weather condition
+ _tcscpy(winfo.cond, TranslateTS(winfo.cond));
+
+ // compare the old condition and determine if the weather had changed
+ if (opt.UpdateOnlyConditionChanged) { // consider condition change
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastCondition", &dbv)) {
+ if (_tcsicmp(winfo.cond, dbv.ptszVal)) Ch = TRUE; // the weather condition is changed
+ db_free(&dbv);
+ }
+ else Ch = TRUE;
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastTemperature", &dbv)) {
+ if (_tcsicmp(winfo.temp, dbv.ptszVal)) Ch = TRUE; // the temperature is changed
+ db_free(&dbv);
+ }
+ else Ch = TRUE;
+ }
+ else { // consider update time change
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastUpdate", &dbv)) {
+ if (_tcsicmp(winfo.update, dbv.ptszVal)) Ch = TRUE; // the update time is changed
+ db_free(&dbv);
+ }
+ else Ch = TRUE;
+ }
+
+ // have weather alert issued?
+ dbres = DBGetContactSettingTString(hContact, WEATHERCONDITION, "Alert", &dbv);
+ if ( !dbres && dbv.ptszVal[0] != 0) {
+ if (opt.AlertPopup && !db_get_b(hContact, WEATHERPROTONAME, "DPopUp", 0) && Ch) {
+ // display alert popup
+ wsprintf(str, _T("Alert for %s%c%s"), winfo.city, 255, dbv.ptszVal);
+ WPShowMessage(str, SM_WEATHERALERT);
+ }
+ // alert issued, set display to italic
+ if (opt.MakeItalic)
+ db_set_w(hContact, WEATHERPROTONAME, "ApparentMode", ID_STATUS_OFFLINE);
+ SkinPlaySound("weatheralert");
+ }
+ // alert dropped, set the display back to normal
+ else db_unset(hContact, WEATHERPROTONAME, "ApparentMode");
+ if ( !dbres) db_free(&dbv);
+
+ // backup current condition for checking if the weather is changed or not
+ db_set_ts(hContact, WEATHERPROTONAME, "LastLog", winfo.update);
+ db_set_ts(hContact, WEATHERPROTONAME, "LastCondition", winfo.cond);
+ db_set_ts(hContact, WEATHERPROTONAME, "LastTemperature", winfo.temp);
+ db_set_ts(hContact, WEATHERPROTONAME, "LastUpdate", winfo.update);
+
+ // display condition on contact list
+ if (opt.DisCondIcon && winfo.status != ID_STATUS_OFFLINE)
+ db_set_w(hContact, WEATHERPROTONAME, "Status", ID_STATUS_ONLINE);
+ else
+ db_set_w(hContact, WEATHERPROTONAME, "Status", winfo.status);
+ AvatarDownloaded(hContact);
+
+ GetDisplay(&winfo, opt.cText, str2);
+ db_set_ts(hContact, "CList", "MyHandle", str2);
+
+ GetDisplay(&winfo, opt.sText, str2);
+ if (str2[0])
+ db_set_ts(hContact, "CList", "StatusMsg", str2);
+ else
+ db_unset(hContact, "CList", "StatusMsg");
+
+ ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)(str2[0] ? str2 : 0));
+
+ // save descriptions in MyNotes
+ GetDisplay(&winfo, opt.nText, str2);
+ db_set_ts(hContact, "UserInfo", "MyNotes", str2);
+ GetDisplay(&winfo, opt.xText, str2);
+ db_set_ts(hContact, WEATHERCONDITION, "WeatherInfo", str2);
+
+ // set the update tag
+ db_set_b(hContact, WEATHERPROTONAME, "IsUpdated", TRUE);
+
+ // save info for default weather condition
+ if ( !_tcscmp(winfo.id, opt.Default) && !opt.NoProtoCondition) {
+ // save current condition for default station to be displayed after the update
+ old_status = status;
+ status = winfo.status;
+ // a workaround for a default station that currently have an n/a icon assigned
+ if (status == ID_STATUS_OFFLINE) status = NOSTATUSDATA;
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, status);
+ }
+
+ // logging
+ if (Ch) {
+ // play the sound event
+ SkinPlaySound("weatherupdated");
+
+ if (db_get_b(hContact, WEATHERPROTONAME, "File", 0)) {
+ // external log
+ if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME, "Log",&dbv)) {
+ // for the option for overwriting the file, delete old file first
+ if (db_get_b(hContact,WEATHERPROTONAME, "Overwrite",0))
+ DeleteFile(dbv.ptszVal);
+ // open the file and set point to the end of file
+ FILE *file = _tfopen( dbv.ptszVal, _T("a"));
+ db_free(&dbv);
+ if (file != NULL) {
+ // write data to the file and close
+ GetDisplay(&winfo, opt.eText, str2);
+ _fputts(str2, file);
+ fclose(file);
+ } } }
+
+ if (db_get_b(hContact, WEATHERPROTONAME, "History", 0)) {
+ DBEVENTINFO dbei = {0};
+ // internal log using history
+ GetDisplay(&winfo, opt.hText, str2);
+ dbei.cbSize = sizeof(dbei);
+ dbei.szModule = WEATHERPROTONAME;
+ dbei.timestamp = (DWORD)time(NULL);
+ dbei.flags = DBEF_READ|DBEF_UTF;
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.pBlob = (PBYTE)mir_utf8encodeT(str2);
+ dbei.cbBlob = (DWORD)strlen((char*)dbei.pBlob)+1;
+
+ // add the history event
+ CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
+ }
+
+ // show the popup
+ NotifyEventHooks(hHookWeatherUpdated, (WPARAM)hContact, (LPARAM)Ch);
+ }
+
+ Netlib_LogfT(hNetlibUser, _T("Update Completed - Start to free memory"));
+ Netlib_LogfT(hNetlibUser, _T("<-- Update successful for station -->"));
+
+ // Update frame data
+ UpdateMwinData(hContact);
+
+ // update brief info if its opened
+ HWND hMoreDataDlg = WindowList_Find(hDataWindowList, hContact);
+ if (hMoreDataDlg != NULL) PostMessage(hMoreDataDlg, WM_UPDATEDATA, 0, 0);
+ return 0;
+}
+
+//============ UPDATE LIST ============
+
+// a linked list queue for updating weather station
+// this function add a weather contact to the end of queue for update
+// hContact = current contact
+void UpdateListAdd(HANDLE hContact)
+{
+ UPDATELIST *newItem = (UPDATELIST*)mir_alloc(sizeof(UPDATELIST));
+ newItem->hContact = hContact;
+ newItem->next = NULL;
+
+ WaitForSingleObject(hUpdateMutex, INFINITE);
+
+ if (UpdateListTail == NULL) UpdateListHead = newItem;
+ else UpdateListTail->next = newItem;
+ UpdateListTail = newItem;
+
+ ReleaseMutex(hUpdateMutex);
+}
+
+// get the first item from the update queue and remove it from the queue
+// return value = the contact for next update
+HANDLE UpdateGetFirst()
+{
+ HANDLE hContact = NULL;
+
+ WaitForSingleObject(hUpdateMutex, INFINITE);
+
+ if (UpdateListHead != NULL)
+ {
+ UPDATELIST* Item = UpdateListHead;
+
+ hContact = Item->hContact;
+ UpdateListHead = Item->next;
+ mir_free(Item);
+
+ if (UpdateListHead == NULL) UpdateListTail = NULL;
+ }
+
+ ReleaseMutex(hUpdateMutex);
+
+ return hContact;
+}
+
+void DestroyUpdateList(void)
+{
+ WaitForSingleObject(hUpdateMutex, INFINITE);
+
+ UPDATELIST *temp = UpdateListHead;
+
+ // free the list one by one
+ while (temp != NULL)
+ {
+ UpdateListHead = temp->next;
+ mir_free(temp);
+ temp = UpdateListHead;
+ }
+ // make sure the entire list is clear
+ UpdateListTail = NULL;
+
+ ReleaseMutex(hUpdateMutex);
+}
+
+
+//============ UPDATE WEATHER ============
+
+// update all weather station
+// AutoUpdate = true if it is from automatic update using timer
+// false if it is from update by clicking the main menu
+void UpdateAll(BOOL AutoUpdate, BOOL RemoveData)
+{
+ // add all weather contact to the update queue list
+ HANDLE hContact = db_find_first();
+ while (hContact != NULL)
+ {
+ if (IsMyContact(hContact))
+ {
+ if ( !db_get_b(hContact,WEATHERPROTONAME, "AutoUpdate",FALSE) || !AutoUpdate)
+ {
+ if (RemoveData) DBDataManage((HANDLE)hContact, WDBM_REMOVE, 0, 0);
+ UpdateListAdd(hContact);
+ }
+ }
+ hContact = db_find_next(hContact);
+ }
+
+ // if it is not updating, then start the update thread process
+ // if it is updating, the stations just added to the queue will get updated by the already-running process
+ if ( !ThreadRunning)
+ mir_forkthread(UpdateThreadProc, NULL);
+}
+
+// update a single station
+// wParam = handle for the weather station that is going to be updated
+INT_PTR UpdateSingleStation(WPARAM wParam, LPARAM lParam)
+{
+ if (IsMyContact((HANDLE)wParam))
+ {
+ // add the station to the end of the update queue
+ UpdateListAdd((HANDLE)wParam);
+
+ // if it is not updating, then start the update thread process
+ // if it is updating, the stations just added to the queue will get
+ // updated by the already-running process
+ if ( !ThreadRunning)
+ mir_forkthread(UpdateThreadProc, NULL);
+ }
+
+ return 0;
+}
+
+// update a single station with removing the old data
+// wParam = handle for the weather station that is going to be updated
+INT_PTR UpdateSingleRemove(WPARAM wParam, LPARAM lParam)
+{
+ if (IsMyContact((HANDLE)wParam))
+ {
+ // add the station to the end of the update queue, and also remove old data
+ DBDataManage((HANDLE)wParam, WDBM_REMOVE, 0, 0);
+ UpdateListAdd((HANDLE)wParam);
+
+ // if it is not updating, then start the update thread process
+ // if it is updating, the stations just added to the queue will get updated by the already-running process
+ if ( !ThreadRunning)
+ mir_forkthread(UpdateThreadProc, NULL);
+ }
+
+ return 0;
+}
+
+// update all weather thread
+// this thread update each weather station from the queue
+void UpdateThreadProc(LPVOID hWnd)
+{
+ WaitForSingleObject(hUpdateMutex, INFINITE);
+ if (ThreadRunning)
+ {
+ ReleaseMutex(hUpdateMutex);
+ return;
+ }
+ ThreadRunning = TRUE; // prevent 2 instance of this thread running
+ ReleaseMutex(hUpdateMutex);
+
+ // update weather by getting the first station from the queue until the queue is empty
+ while (UpdateListHead != NULL && !Miranda_Terminated())
+ UpdateWeather(UpdateGetFirst());
+
+ NetlibHttpDisconnect();
+
+ // exit the update thread
+ ThreadRunning = FALSE;
+}
+
+// the "Update All" menu item in main menu
+INT_PTR UpdateAllInfo(WPARAM wParam,LPARAM lParam)
+{
+ if ( !ThreadRunning) UpdateAll(FALSE, FALSE);
+ return 0;
+}
+
+// the "Update All" menu item in main menu and remove the old data
+INT_PTR UpdateAllRemove(WPARAM wParam,LPARAM lParam) {
+ if ( !ThreadRunning) UpdateAll(FALSE, TRUE);
+ return 0;
+}
+
+//============ GETTING WEATHER DATA ============
+
+// getting weather data and save them into the database
+// hContact = the contact to get the data
+int GetWeatherData(HANDLE hContact)
+{
+ // get eacnh part of the id's
+ TCHAR id[256];
+ GetStationID(hContact, id, SIZEOF(id));
+
+ // test ID format
+ TCHAR* szInfo = _tcschr(id, '/');
+ if (szInfo == NULL)
+ return INVALID_ID_FORMAT;
+
+ GetID(id);
+
+ TCHAR Svc[256];
+ GetStationID(hContact, Svc, SIZEOF(Svc));
+ GetSvc(Svc);
+
+ // check for invalid station
+ if (id[0] == 0) return INVALID_ID;
+ if (Svc[0] == 0) return INVALID_SVC;
+
+ // get the update strings (loaded to memory from ini files)
+ WIDATA *Data = GetWIData(Svc);
+ if (Data == NULL)
+ return SVC_NOT_FOUND; // the ini for the station cannot be found
+
+ WIDATAITEMLIST* Item;
+ WORD cond = NA;
+ char loc[256];
+ char* szId = mir_t2a( id );
+ for ( int i=0; i<4; ++i) {
+ // generate update URL
+ switch(i) {
+ case 0:
+ _snprintf(loc, SIZEOF(loc), Data->UpdateURL, szId);
+ break;
+
+ case 1:
+ _snprintf(loc, SIZEOF(loc), Data->UpdateURL2, szId);
+ break;
+
+ case 2:
+ _snprintf(loc, SIZEOF(loc), Data->UpdateURL3, szId);
+ break;
+
+ case 3:
+ _snprintf(loc, SIZEOF(loc), Data->UpdateURL4, szId);
+ break;
+ }
+
+ if ( loc[0] == 0 )
+ continue;
+
+ // download the html file from the internet
+ TCHAR* szData = NULL;
+ int retval = InternetDownloadFile(loc, Data->Cookie, &szData);
+ if (retval != 0) {
+ mir_free(szData);
+ return retval;
+ }
+ if ( _tcsstr(szData, _T("Document Not Found")) != NULL) {
+ mir_free(szData);
+ return DOC_NOT_FOUND;
+ }
+
+ szInfo = szData;
+ Item = Data->UpdateData;
+
+ // begin parsing item by item
+ while (Item != NULL) {
+ if (Item->Item.Url[0] != 0 && Item->Item.Url[0] != (i + '1')) {
+ Item = Item->Next;
+ continue;
+ }
+
+ TCHAR DataValue[MAX_DATA_LEN];
+ switch (Item->Item.Type) {
+ case WID_NORMAL:
+ // if it is a normal item with start= and end=, then parse through the downloaded string
+ // to get a data value.
+ GetDataValue(&Item->Item, DataValue, &szInfo);
+ if ( _tcscmp(Item->Item.Name, _T("Condition")) && _tcsicmp(Item->Item.Unit, _T("Cond")))
+ _tcscpy(DataValue, TranslateTS(DataValue));
+ break;
+
+ case WID_SET:
+ {
+ // for the "Set Data=" operation
+ DBVARIANT dbv;
+ TCHAR *chop, *str, str2[MAX_DATA_LEN];
+ BOOL hasvar = FALSE;
+ size_t stl;
+
+ // get the set data operation string
+ str = Item->Item.End;
+ DataValue[0] = 0;
+ // go through each part of the operation string seperated by the & operator
+ do {
+ // the end of the string, last item
+ chop = _tcsstr(str, _T(" & "));
+ if (chop == NULL)
+ chop = _tcschr(str, '\0');
+
+ stl = min(sizeof(str2)-1, (unsigned)(chop-str-2));
+ _tcsncpy(str2, str+1, stl);
+ str2[stl] = 0;
+
+ switch(str[0]) {
+ case '[': // variable, add the value to the result string
+ hasvar = TRUE;
+ if ( !DBGetData(hContact, _T2A(str2), &dbv)) {
+ _tcsncat(DataValue, dbv.ptszVal, SIZEOF(DataValue) - _tcslen(DataValue));
+ DataValue[SIZEOF(DataValue)-1] = 0;
+ db_free(&dbv);
+ }
+ break;
+
+ case'\"': // constant, add it to the result string
+ _tcsncat(DataValue, TranslateTS(str2), SIZEOF(DataValue) - _tcslen(DataValue));
+ DataValue[SIZEOF(DataValue)-1] = 0;
+ break;
+ }
+
+ // remove the front part of the string that is done and continue parsing
+ str = chop + 3;
+ } while (chop[0] && str[0]);
+
+ if ( !hasvar) ConvertDataValue(&Item->Item, DataValue);
+ break;
+ }
+ case WID_BREAK:
+ {
+ // for the "Break Data=" operation
+ DBVARIANT dbv;
+ if ( !DBGetData(hContact, _T2A(Item->Item.Start), &dbv)) {
+ _tcsncpy(DataValue, dbv.ptszVal, SIZEOF(DataValue));
+ DataValue[SIZEOF(DataValue)-1] = 0;
+ db_free(&dbv);
+ }
+ else {
+ DataValue[0] = 0;
+ break; // do not continue if the source is invalid
+ }
+
+ // generate the strings
+ TCHAR* end = _tcsstr(DataValue, Item->Item.Break);
+ if (end == NULL) {
+ DataValue[0] = 0;
+ break; // exit if break string is not found
+ }
+ *end = '\0';
+ end += _tcslen(Item->Item.Break);
+ while (end[0] == ' ')
+ end++; // remove extra space
+
+ ConvertDataValue(&Item->Item, DataValue);
+
+ // write the 2 strings created from the break operation
+ if (Item->Item.End[0])
+ db_set_ts(hContact, WEATHERCONDITION, _T2A(Item->Item.End), end);
+ break;
+ } }
+
+ // don't store data if it is not available
+ if ((DataValue[0] != 0 && _tcscmp(DataValue, NODATA) &&
+ _tcscmp(DataValue, TranslateTS(NODATA)) && _tcscmp(Item->Item.Name, _T("Ignore"))) ||
+ ( !_tcscmp(Item->Item.Name, _T("Alert")) && i == 0))
+ {
+ // temporary workaround for mToolTip to show feel-like temperature
+ if ( !_tcscmp(Item->Item.Name, _T("Feel")))
+ db_set_ts(hContact, WEATHERCONDITION, "Heat Index", DataValue);
+ GetStationID(hContact, Svc, SIZEOF(Svc));
+ if ( !_tcscmp(Svc, opt.Default))
+ db_set_ts(NULL, DEFCURRENTWEATHER, _T2A(Item->Item.Name), DataValue);
+ if ( !_tcscmp(Item->Item.Name, _T("Condition"))) {
+ TCHAR buf[128], *cbuf;
+ mir_sntprintf(buf, SIZEOF(buf), _T("#%s Weather"), DataValue);
+ cbuf = TranslateTS(buf);
+ if (cbuf[0] == '#')
+ cbuf = TranslateTS(DataValue);
+ db_set_ts(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), cbuf);
+ CharLowerBuff(DataValue, (DWORD)_tcslen(DataValue));
+ cond = GetIcon(DataValue, Data);
+ }
+ else if ( _tcsicmp(Item->Item.Unit, _T("Cond")) == 0) {
+ TCHAR buf[128], *cbuf;
+ mir_sntprintf(buf, SIZEOF(buf), _T("#%s Weather"), DataValue);
+ cbuf = TranslateTS(buf);
+ if (cbuf[0] == '#')
+ cbuf = TranslateTS(DataValue);
+ db_set_ts(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), cbuf);
+ }
+ else db_set_ts(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), DataValue);
+ }
+ Item = Item->Next;
+ }
+ mir_free(szData);
+ }
+
+ // assign condition icon
+ db_set_w(hContact, WEATHERPROTONAME, "StatusIcon", cond);
+ db_set_ts(hContact, WEATHERPROTONAME, "MirVer", Data->DisplayName);
+ return 0;
+}
+
+//============ UPDATE TIMERS ============
+
+// main auto-update timer
+void CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+{
+ // only run if it is not current updating and the auto update option is enabled
+ if ( !ThreadRunning && opt.CAutoUpdate && !Miranda_Terminated() &&
+ (!opt.NoProtoCondition || status == ID_STATUS_ONLINE))
+ UpdateAll(TRUE, FALSE);
+}
+
+// temporary timer for first run
+// when this is run, it kill the old startup timer and create the permenant one above
+void CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
+{
+ KillTimer(NULL, timerId);
+ ThreadRunning = FALSE;
+
+ if ( !Miranda_Terminated()) {
+ if (opt.StartupUpdate && !opt.NoProtoCondition)
+ UpdateAll(FALSE, FALSE);
+ timerId = SetTimer(NULL, 0, ((int)opt.UpdateTime)*60000, (TIMERPROC)timerProc);
+ }
+}
+
diff --git a/plugins/Weather/src/weather_userinfo.cpp b/plugins/Weather/src/weather_userinfo.cpp new file mode 100644 index 0000000000..1d716a58ef --- /dev/null +++ b/plugins/Weather/src/weather_userinfo.cpp @@ -0,0 +1,402 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (c) 2012 Miranda NG Team
+Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
+Copyright (c) 2002-2005 Calvin Che
+
+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; version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+
+/*
+This file contain the source that is related to display contact
+information, including the one shows in user detail and the brief
+information
+*/
+
+#include "weather.h"
+
+extern INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+//============ CONTACT INFORMATION ============
+
+// initialize user info
+// lParam = current contact
+int UserInfoInit(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = {0};
+ odp.cbSize = sizeof(odp);
+ odp.hInstance = hInst;
+ odp.position = 100000000;
+ odp.ptszTitle = _T(WEATHERPROTONAME);
+
+ if (lParam == 0)
+ {
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO);
+ odp.pfnDlgProc = DlgProcINIPage;
+ odp.flags = ODPF_TCHAR;
+ UserInfo_AddPage(wParam, &odp);
+ }
+ else
+ {
+ // check if it is a weather contact
+ if (IsMyContact((HANDLE)lParam))
+ {
+ // register the contact info page
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
+ odp.pfnDlgProc = DlgProcUIPage;
+ odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ UserInfo_AddPage(wParam, &odp);
+ }
+ }
+
+ return 0;
+}
+
+// dialog process for the weather tab under user info
+// lParam = current contact
+INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ WEATHERINFO w;
+ TCHAR str[MAX_TEXT_SIZE];
+
+ HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SendMessage(GetDlgItem(hwndDlg,IDC_MOREDETAIL), BUTTONSETASFLATBTN, TRUE, 0);
+ // save the contact handle for later use
+ hContact = (HANDLE)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact);
+ // load weather info for the contact
+ w = LoadWeatherInfo((HANDLE)lParam);
+ SetDlgItemText(hwndDlg, IDC_INFO1, GetDisplay(&w, TranslateT("Current condition for %n"), str));
+
+ SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON,
+ (WPARAM)LoadSkinnedProtoIcon(WEATHERPROTONAME,
+ db_get_w(hContact, WEATHERPROTONAME, "StatusIcon",0)), 0);
+
+ { // bold and enlarge the current condition
+ LOGFONT lf;
+ HFONT hNormalFont = (HFONT)SendDlgItemMessage(hwndDlg,IDC_INFO2,WM_GETFONT,0,0);
+ GetObject(hNormalFont,sizeof(lf),&lf);
+ lf.lfWeight = FW_BOLD;
+ lf.lfWidth = 7;
+ lf.lfHeight = 15;
+ SendDlgItemMessage(hwndDlg, IDC_INFO2, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
+ }
+ // set the text for displaying other current weather conditions data
+ GetDisplay(&w, _T("%c %t"), str);
+ SetDlgItemText(hwndDlg, IDC_INFO2, str);
+ SetDlgItemText(hwndDlg, IDC_INFO3, w.feel);
+ SetDlgItemText(hwndDlg, IDC_INFO4, w.pressure);
+ GetDisplay(&w, _T("%i %w"), str);
+ SetDlgItemText(hwndDlg, IDC_INFO5, str);
+ SetDlgItemText(hwndDlg, IDC_INFO6, w.dewpoint);
+ SetDlgItemText(hwndDlg, IDC_INFO7, w.sunrise);
+ SetDlgItemText(hwndDlg, IDC_INFO8, w.sunset);
+ SetDlgItemText(hwndDlg, IDC_INFO9, w.high);
+ SetDlgItemText(hwndDlg, IDC_INFO10, w.low);
+ GetDisplay(&w, TranslateT("Last update on: %u"), str);
+ SetDlgItemText(hwndDlg, IDC_INFO11, str);
+ SetDlgItemText(hwndDlg, IDC_INFO12, w.humid);
+ SetDlgItemText(hwndDlg, IDC_INFO13, w.vis);
+ break;
+
+ case WM_DESTROY:
+ Skin_ReleaseIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON, 0, 0));
+ DeleteObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_INFO2, WM_GETFONT, 0, 0));
+ break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_MOREDETAIL:
+ {
+ HWND hMoreDataDlg = WindowList_Find(hDataWindowList, hContact);
+ if (hMoreDataDlg == NULL)
+ hMoreDataDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_BRIEF), NULL,
+ DlgProcMoreData, (LPARAM)hContact);
+ else
+ {
+ SetForegroundWindow(hMoreDataDlg);
+ SetFocus(hMoreDataDlg);
+ }
+ ShowWindow(GetDlgItem(hMoreDataDlg, IDC_MTEXT), 0);
+ ShowWindow(GetDlgItem(hMoreDataDlg, IDC_DATALIST), 1);
+ break;
+ }
+ }
+ break;
+ }
+ return 0;
+}
+
+//============ BRIEF INFORMATION ============
+
+static int BriefDlgResizer(HWND hwnd, LPARAM lParam, UTILRESIZECONTROL *urc)
+{
+ switch(urc->wId)
+ {
+ case IDC_HEADERBAR:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORX_WIDTH;
+
+ case IDC_MTEXT:
+ case IDC_DATALIST:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+
+ case IDC_MUPDATE:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+
+ case IDC_MTOGGLE:
+ case IDC_MWEBPAGE:
+ case IDCANCEL:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ }
+ return RD_ANCHORX_LEFT|RD_ANCHORY_TOP;
+}
+
+
+
+// dialog process for more data in the user info window
+// lParam = contact handle
+INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static const unsigned tabstops = 48;
+ HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ // save the contact handle for later use
+ hContact = (HANDLE)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact);
+
+ SendDlgItemMessage(hwndDlg, IDC_MTEXT, EM_AUTOURLDETECT, (WPARAM) TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_MTEXT, EM_SETEVENTMASK, 0, ENM_LINK);
+ SendDlgItemMessage(hwndDlg, IDC_MTEXT, EM_SETMARGINS, EC_LEFTMARGIN, 5);
+ SendDlgItemMessage(hwndDlg, IDC_MTEXT, EM_SETTABSTOPS, 1, (LPARAM)&tabstops);
+
+ // get the list to display
+ {
+ LV_COLUMN lvc = { 0 };
+ HWND hList = GetDlgItem(hwndDlg, IDC_DATALIST);
+ RECT aRect = { 0 };
+ GetClientRect(hList, &aRect);
+
+ // managing styles
+ lvc.mask = LVCF_WIDTH | LVCF_TEXT;
+ ListView_SetExtendedListViewStyleEx(hList,
+ LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP,
+ LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
+
+ // inserting columns
+ lvc.cx = LIST_COLUMN;
+ lvc.pszText = TranslateT("Variable");
+ ListView_InsertColumn(hList, 0, &lvc);
+
+ lvc.cx = aRect.right - LIST_COLUMN - GetSystemMetrics(SM_CXVSCROLL) - 3;
+ lvc.pszText = TranslateT("Information");
+ ListView_InsertColumn(hList, 1, &lvc);
+
+ // inserting data
+ SendMessage(hwndDlg, WM_UPDATEDATA, 0, 0);
+ }
+ TranslateDialogDefault(hwndDlg);
+
+ // prevent dups of the window
+ WindowList_Add(hDataWindowList, hwndDlg, hContact);
+
+ // restore window position
+ Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, WEATHERPROTONAME, "BriefInfo_");
+ return TRUE;
+
+ case WM_UPDATEDATA:
+ ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_DATALIST));
+ LoadBriefInfoText(hwndDlg, hContact);
+ DBDataManage(hContact, WDBM_DETAILDISPLAY, (WPARAM)hwndDlg, 0);
+
+ // set icons
+ {
+ WORD statusIcon = db_get_w(hContact, WEATHERPROTONAME, "StatusIcon", 0);
+
+ ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedProtoIconBig(WEATHERPROTONAME, statusIcon)));
+ ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedProtoIcon(WEATHERPROTONAME, statusIcon)));
+ }
+ RedrawWindow(GetDlgItem(hwndDlg, IDC_HEADERBAR), NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
+ break;
+
+ case WM_SIZE:
+ {
+ RECT rc;
+ HWND hList = GetDlgItem(hwndDlg, IDC_DATALIST);
+ GetWindowRect(hList, &rc);
+ ListView_SetColumnWidth(hList, 1, ListView_GetColumnWidth(hList, 1) +
+ (int)LOWORD(lParam) - (rc.right - rc.left));
+ }
+ {
+ UTILRESIZEDIALOG urd = {0};
+ urd.cbSize = sizeof(urd);
+ urd.hwndDlg = hwndDlg;
+ urd.hInstance = hInst;
+ urd.lpTemplate = MAKEINTRESOURCEA(IDD_BRIEF);
+ urd.pfnResizer = BriefDlgResizer;
+ CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
+ }
+ break;
+
+ case WM_GETMINMAXINFO:
+ {
+ LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
+
+ // The minimum width in points
+ mmi->ptMinTrackSize.x = 350;
+ // The minimum height in points
+ mmi->ptMinTrackSize.y = 300;
+ }
+ break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ {
+ case IDCANCEL:
+ // close the info window
+ DestroyWindow(hwndDlg);
+ break;
+
+ case IDC_MUPDATE:
+ {
+ LV_ITEM lvi = {0};
+ HWND hList = GetDlgItem(hwndDlg, IDC_DATALIST);
+
+ // update current data
+ // set the text to "updating"
+ SetDlgItemText(hwndDlg, IDC_MTEXT, TranslateT("Retrieving new data, please wait..."));
+ ListView_DeleteAllItems(hList);
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.lParam = 1;
+ lvi.pszText = _T("");
+ lvi.iItem = ListView_InsertItem(hList, &lvi);
+ lvi.pszText = TranslateT("Retrieving new data, please wait...");
+ ListView_SetItemText(hList, lvi.iItem, 1, lvi.pszText);
+ UpdateSingleStation((WPARAM)hContact, 0);
+ break;
+ }
+
+ case IDC_MWEBPAGE:
+ LoadForecast((WPARAM)hContact, 0); // read complete forecast
+ break;
+
+ case IDC_MTOGGLE:
+ if (IsWindowVisible(GetDlgItem(hwndDlg,IDC_DATALIST)))
+ SetDlgItemText(hwndDlg, IDC_MTOGGLE, TranslateT("More Info"));
+ else
+ SetDlgItemText(hwndDlg, IDC_MTOGGLE, TranslateT("Brief Info"));
+ ShowWindow(GetDlgItem(hwndDlg,IDC_DATALIST), (int)!IsWindowVisible(
+ GetDlgItem(hwndDlg,IDC_DATALIST)));
+ ShowWindow(GetDlgItem(hwndDlg,IDC_MTEXT), (int)!IsWindowVisible(GetDlgItem(hwndDlg,IDC_MTEXT)));
+ break;
+ }
+ break;
+
+ case WM_NOTIFY:
+ {
+ LPNMHDR pNmhdr = (LPNMHDR)lParam;
+ if (pNmhdr->idFrom == IDC_MTEXT && pNmhdr->code == EN_LINK)
+ {
+ ENLINK *enlink = (ENLINK *) lParam;
+ TEXTRANGE tr;
+ switch (enlink->msg)
+ {
+ case WM_LBUTTONUP:
+ tr.chrg = enlink->chrg;
+ tr.lpstrText = ( LPTSTR )mir_alloc( sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 8));
+ SendMessage(pNmhdr->hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
+ CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM) tr.lpstrText);
+ mir_free(tr.lpstrText);
+ break;
+ }
+ }
+ break;
+ }
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
+ ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0));
+
+ Utils_SaveWindowPosition(hwndDlg, NULL, WEATHERPROTONAME, "BriefInfo_");
+ WindowList_Remove(hDataWindowList, hwndDlg);
+ break;
+ }
+
+ return FALSE;
+}
+
+// set the title of the dialog and on the which rectangle
+// also load brief info into message box
+void LoadBriefInfoText(HWND hwndDlg, HANDLE hContact)
+{
+ WEATHERINFO winfo;
+ TCHAR str[4096], str2[4096];
+
+ // load weather information from the contact into the WEATHERINFO struct
+ winfo = LoadWeatherInfo(hContact);
+ // check if data exist. If not, display error message box
+ if ( !(BOOL)db_get_b(hContact, WEATHERPROTONAME, "IsUpdated", FALSE))
+ _tcscpy(str, TranslateT("No information available.\r\nPlease update weather condition first."));
+ else
+ // set the display text and show the message box
+ GetDisplay(&winfo, opt.bText, str);
+ SetDlgItemText(hwndDlg, IDC_MTEXT, str);
+
+ GetDisplay(&winfo, opt.bTitle, str);
+ SetWindowText(hwndDlg, str);
+ GetDisplay(&winfo, _T("%c, %t"), str);
+ mir_sntprintf(str2, SIZEOF(str2), _T("%s\n%s"), winfo.city, str);
+ SetDlgItemText(hwndDlg, IDC_HEADERBAR, str2);
+}
+
+// show brief information dialog
+// wParam = current contact
+int BriefInfo(WPARAM wParam, LPARAM lParam)
+{
+ // make sure that the contact is actually a weather one
+ if (IsMyContact((HANDLE)wParam))
+ {
+ HWND hMoreDataDlg = WindowList_Find(hDataWindowList,(HANDLE)wParam);
+ if (hMoreDataDlg != NULL)
+ {
+ SetForegroundWindow(hMoreDataDlg);
+ SetFocus(hMoreDataDlg);
+ }
+ else
+ {
+ hMoreDataDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_BRIEF), NULL, DlgProcMoreData,
+ (LPARAM)wParam);
+ }
+ ShowWindow(GetDlgItem(hMoreDataDlg, IDC_DATALIST), 0);
+ ShowWindow(GetDlgItem(hMoreDataDlg, IDC_MTEXT), 1);
+ SetDlgItemText(hMoreDataDlg, IDC_MTOGGLE, TranslateT("More Info"));
+ return 1;
+ }
+ return 0;
+}
+
+INT_PTR BriefInfoSvc(WPARAM wParam, LPARAM lParam)
+{
+ return BriefInfo(wParam, lParam);
+}
diff --git a/plugins/Weather/weather_10.vcxproj b/plugins/Weather/weather_10.vcxproj new file mode 100644 index 0000000000..d09c5d1cb1 --- /dev/null +++ b/plugins/Weather/weather_10.vcxproj @@ -0,0 +1,218 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>Weather</ProjectName>
+ <ProjectGuid>{6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <OmitFramePointers>true</OmitFramePointers>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>false</ExceptionHandling>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeaderFile>weather.h</PrecompiledHeaderFile>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <BaseAddress>0x72030000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <ExceptionHandling>false</ExceptionHandling>
+ <BufferSecurityCheck>false</BufferSecurityCheck>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <FloatingPointModel>Fast</FloatingPointModel>
+ <PrecompiledHeaderFile>weather.h</PrecompiledHeaderFile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <BaseAddress>0x72030000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeaderFile>weather.h</PrecompiledHeaderFile>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <SmallerTypeCheck>true</SmallerTypeCheck>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <BaseAddress>0x72030000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeaderFile>weather.h</PrecompiledHeaderFile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <BaseAddress>0x72030000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="src\weather.cpp" />
+ <ClCompile Include="src\stdafx.cpp">
+ <PrecompiledHeader>Create</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="src\weather_addstn.cpp" />
+ <ClCompile Include="src\weather_contacts.cpp" />
+ <ClCompile Include="src\weather_conv.cpp" />
+ <ClCompile Include="src\weather_data.cpp" />
+ <ClCompile Include="src\weather_http.cpp" />
+ <ClCompile Include="src\weather_icons.cpp" />
+ <ClCompile Include="src\weather_info.cpp" />
+ <ClCompile Include="src\weather_ini.cpp" />
+ <ClCompile Include="src\weather_mwin.cpp" />
+ <ClCompile Include="src\weather_opt.cpp" />
+ <ClCompile Include="src\weather_popup.cpp" />
+ <ClCompile Include="src\weather_svcs.cpp" />
+ <ClCompile Include="src\weather_update.cpp" />
+ <ClCompile Include="src\weather_userinfo.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h" />
+ <ClInclude Include="src\version.h" />
+ <ClInclude Include="src\weather.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/Weather/weather_10.vcxproj.filters b/plugins/Weather/weather_10.vcxproj.filters new file mode 100644 index 0000000000..385b06f839 --- /dev/null +++ b/plugins/Weather/weather_10.vcxproj.filters @@ -0,0 +1,86 @@ +<?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>{ae98b833-66fd-4d03-8883-da86b699da8e}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{229b056a-ba07-4698-ad86-26548bd87e32}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl</Extensions>
+ </Filter>
+ <Filter Include="Documentations">
+ <UniqueIdentifier>{3433a4a3-b1af-4761-ab98-0d4ada361b3a}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{4be16e1a-70ca-4330-b259-db32ec58dcc0}</UniqueIdentifier>
+ <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\weather.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_addstn.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_contacts.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_conv.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_data.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_http.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_icons.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_info.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_ini.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_mwin.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_opt.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_popup.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_svcs.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_update.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\weather_userinfo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\weather.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/YAMN/YAMN_10.vcxproj b/plugins/YAMN/YAMN_10.vcxproj new file mode 100644 index 0000000000..a9479b4d2d --- /dev/null +++ b/plugins/YAMN/YAMN_10.vcxproj @@ -0,0 +1,217 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>YAMN</ProjectName>
+ <ProjectGuid>{C5A87409-F08C-4A07-A8F9-1F5D52BA6D72}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>comctl32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <BaseAddress>0x60010000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>comctl32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <BaseAddress>0x60010000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>Full</Optimization>
+ <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <WarningLevel>Level3</WarningLevel>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>comctl32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <BaseAddress>0x60010000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <AdditionalDependencies>comctl32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <BaseAddress>0x60010000</BaseAddress>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <SubSystem>Windows</SubSystem>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="src\account.cpp" />
+ <ClCompile Include="src\debug.cpp" />
+ <ClCompile Include="src\filterplugin.cpp" />
+ <ClCompile Include="src\main.cpp" />
+ <ClCompile Include="src\protoplugin.cpp" />
+ <ClCompile Include="src\services.cpp" />
+ <ClCompile Include="src\synchro.cpp" />
+ <ClCompile Include="src\yamn.cpp" />
+ <ClCompile Include="src\browser\badconnect.cpp" />
+ <ClCompile Include="src\browser\mailbrowser.cpp" />
+ <ClCompile Include="src\mails\decode.cpp" />
+ <ClCompile Include="src\mails\mails.cpp" />
+ <ClCompile Include="src\mails\mime.cpp" />
+ <ClCompile Include="src\proto\md5.c" />
+ <ClCompile Include="src\proto\netlib.cpp" />
+ <ClCompile Include="src\proto\pop3\pop3.cpp" />
+ <ClCompile Include="src\proto\pop3\pop3comm.cpp" />
+ <ClCompile Include="src\proto\pop3\pop3opt.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h" />
+ <ClInclude Include="src\debug.h" />
+ <ClInclude Include="src\main.h" />
+ <ClInclude Include="src\proto\pop3\pop3.h" />
+ <ClInclude Include="src\proto\pop3\pop3comm.h" />
+ <ClInclude Include="src\proto\pop3\pop3opt.h" />
+ <ClInclude Include="src\yamn.h" />
+ <ClInclude Include="src\version.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\YAMN.rc" />
+ <ResourceCompile Include="res\yamn_ver.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/YAMN/YAMN_10.vcxproj.filters b/plugins/YAMN/YAMN_10.vcxproj.filters new file mode 100644 index 0000000000..5a21b2d9db --- /dev/null +++ b/plugins/YAMN/YAMN_10.vcxproj.filters @@ -0,0 +1,115 @@ +<?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>{30eb0c8d-5383-47ff-8a05-4b9793d26d50}</UniqueIdentifier>
+ <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
+ </Filter>
+ <Filter Include="Source Files\Mail browser, dialogs">
+ <UniqueIdentifier>{6b01a00c-f1f9-4958-b89a-2721d5bdd229}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\Mails">
+ <UniqueIdentifier>{4743640f-ca6b-4518-8ead-525bea367ec0}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\POP3 plugin">
+ <UniqueIdentifier>{0189ff00-aae9-40fd-847b-a81dca9496bd}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{daef8d66-0947-4a6c-ad55-4e1b2bf26d86}</UniqueIdentifier>
+ <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{c58708cc-53b7-4db2-b19e-4d6291665e8b}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\account.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\debug.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\filterplugin.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\main.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\protoplugin.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\services.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\synchro.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\yamn.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\browser\badconnect.cpp">
+ <Filter>Source Files\Mail browser, dialogs</Filter>
+ </ClCompile>
+ <ClCompile Include="src\browser\mailbrowser.cpp">
+ <Filter>Source Files\Mail browser, dialogs</Filter>
+ </ClCompile>
+ <ClCompile Include="src\mails\decode.cpp">
+ <Filter>Source Files\Mails</Filter>
+ </ClCompile>
+ <ClCompile Include="src\mails\mails.cpp">
+ <Filter>Source Files\Mails</Filter>
+ </ClCompile>
+ <ClCompile Include="src\mails\mime.cpp">
+ <Filter>Source Files\Mails</Filter>
+ </ClCompile>
+ <ClCompile Include="src\proto\md5.c">
+ <Filter>Source Files\POP3 plugin</Filter>
+ </ClCompile>
+ <ClCompile Include="src\proto\netlib.cpp">
+ <Filter>Source Files\POP3 plugin</Filter>
+ </ClCompile>
+ <ClCompile Include="src\proto\pop3\pop3.cpp">
+ <Filter>Source Files\POP3 plugin</Filter>
+ </ClCompile>
+ <ClCompile Include="src\proto\pop3\pop3comm.cpp">
+ <Filter>Source Files\POP3 plugin</Filter>
+ </ClCompile>
+ <ClCompile Include="src\proto\pop3\pop3opt.cpp">
+ <Filter>Source Files\POP3 plugin</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\debug.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\main.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\proto\pop3\pop3.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\proto\pop3\pop3comm.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\proto\pop3\pop3opt.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\yamn.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\YAMN.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ <ResourceCompile Include="res\yamn_ver.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/YAMN/docs/ChangeLog.txt b/plugins/YAMN/docs/ChangeLog.txt new file mode 100644 index 0000000000..6a85810ab2 --- /dev/null +++ b/plugins/YAMN/docs/ChangeLog.txt @@ -0,0 +1,243 @@ +0.1.2.5
+=======
+! fix many memory leaks patch by Merlin
+* x64 support by Merlin
+* Resource patch by mataes (for translations)
+
+0.1.2.4
+=======
+* Only show popup tab if popup plugin is present
+! Wrong time displayed in mailbrower (fix by y_b)
+
+0.1.2.3
+=======
+* New design for the options pages (Thanks Eyecue)
+
+0.1.2.2
+=======
+* using, with updater, the correct file id in file listing (yamn 2in1)
++ added folders plugin support
++ Support for miranda 0.8
+
+0.1.2.1
+=======
+! Don't close MailBrowser when e-mails are updated if it is manually open
++ Discard the new Event when message is shown or is deleted from the server
++ Option to disable the CList events per account
++ Contact status change also happens when e-mail are being deleted
+
+0.1.2.0
+=======
+! patch by TioDuke for icolib and status and status icons handling. Thanks!
+! code cleaning (properly destroy services and hooks)
++ Contact status changes accordingly the action (Ready, Working, Error)
+
+0.1.1.0
+=======
++ Show message is open in new thread
++ Click on individual new e-mail popups shows the message window
+
+0.1.0.2
+============
++ Pressing "Space" key will show the selected message
+! Delete message is done by DELETE key, not by '.'
+! removed some repeated code
+! "Ok" and "Select All" buttons in mail browser are translatable
+
+0.1.0.1
+============
++ Message body shown in separate edit box.
++ Support for Content-transfer-encoding: Quoted-Printable and base64
++ Recursive Content-type: multipart/ support
++ Option to auto retrieve body
+
+0.0.1.11
+============
++ Option to use yamn as a protocol.
+* Patch by Tioduke (code cleaning)
+! Fixed the crash parsing invalid "Date" header (SPAMs or silly e-mail client) (y_b)
+! ShowMessage dialog follows Content-type header to chose the codepage (y_b)
++ Only supported codepages are shown in the options (y_b)
++ Enhance codepages support (y_b)
+
+0.0.1.10
+============
+! Icons are based on single bitmap image (y_b)
+* Show full feaders on double click in mailbrowser (y_b)
+* Dates are shown localized and sorted correctly (y_b)
+* To show long/short date and seconds (y_b)
+! Solved a rare/random crash on unstable connection (y_b)
+! Enabled tabstop on new tabcontrol and reordered tabstop in option pages (y_b)
+* Enable TAB selection in mailbrowser dialog (patch by -pv-)
++ introducing 2in1 build - can be used both in win9x and NT/XP
+* Options redesign.
+
+0.0.1.9
+============
+* Patch by Perf (visual patch)
+
+0.0.1.8
+============
++ add ctr-A to select all mails
++ del key delete selected mail
++ add a select all button
+
+0.0.1.7
+============
+* Change options dialog (use tabsrmm uxtheme)
+! Invert back and text color for no new mail popup in option page.
+* New default icon reworked by Faith Healer.
+
+0.0.1.6
+============
+* Try to update all icons when changing in icolib.
+! Allow scrolling in list of email account. (Patch by Jazzy)
+! Memory leak in stls fix (y_b)
+
+0.0.1.5
+============
+! Bug fix with help.dll problem. (Patch by Jazzy)
+ (http://developer.berlios.de/bugs/?func=detailbug&bug_id=6692&group_id=3292)
+! Remove merge in agressiveoptimize.h
+
+0.0.1.4
+============
+! Option page bug (patch by y_b)
+* Allow to edit the application text
+
+0.0.1.3
+============
+! Bug fix with new icolib
+
+0.0.1.2
+============
+! Bug fix with updater and stable version
++ Using new m_icolib.h
++ New context menu entry to launch application
++ Patch by y_b
+{
+ + Start TLS support
+ + Better icolib support
+ + SSL Logging
+}
+
+0.0.1.1
+============
+! Bug fix on left click popup.
+
+0.0.1.0
+============
+Time for release.
+
+0.0.0.18
+============
+! Visual bug in option page
+! Recompilation for win 9x users.
+
+0.0.0.17
+============
+* Redesign option page to have only one entry in plugins options
+! Bug fix when there is no date set in the header (spam mails) (Thx Egres)
+
+0.0.0.16
+============
+* Right click on error popup close the popup.
+! Missing break; in nonewmail popup in switch.
++ Add option to rename contact according to new mail.
+! Patch by pescuma on delete accounts
+
+0.0.0.15
+============
+! Fixed dismiss event by right click on new mail popup crash
+* Change string for the status choose button
+! use CallServiceSync() instead of CallService() for adding clistevent (now icon blinks)
+
+0.0.0.14
+============
+! Tooltip on the clist event will now show correct text
+! Remove the messagebox on double clik on mail
+* Change options dialog add dialog for status choose.
+
+0.0.0.13
+============
++ Use of event count for the keyboard flashing
+
+0.0.0.12
+============
+- Remove message body retrieving due to bug.
+
+0.0.0.11
+============
++ Add a function to retrieve the whole mail source.
++ Show the mail source when double clicking on it in mail browser.
++ Add a version resource.
+
+0.0.0.10
+============
++ Now able to pass hContact handle to popup so can show avatar if set.
+* Change folder structure in svn SDK\import replace by include
+
+0.0.0.9
+============
++ Sorting asc and desc of the mail browser listview
++ Use the format yyyy-mm-dd hh:mm:ss for date comparaison in sorting
++ Doubleclick on list view to show the mail body but it seems to be empty :(
+
+0.0.0.8
+============
++ Add date field in mail browser
+* Modify the tooltip text for the clist event (add account name)
+* Rename Contact member of CAccount by hContact since it is an HANDLE
++ Updater support for BETA
+* Using the right headers (no more the one in SDK)
+
+0.0.0.7
+============
++ Added changelog txt file.
++ Check presence of icolib to choose the right icon to show in clist
++ Status message will show all message pending in mail box (until they get retrieve by your email client)
+
+0.0.0.6
+============
+* Options page redesign.
++ Right click on popup close the clist event too.
++ Update status message if no new mail.
++ Right click on popup^with no new mail close the popup.
+* No more delete of contact (avoid group affectation bug).
+
+0.0.0.5
+============
++ Add contact context menu entry to check for new mail.
++ Catch double click event on contact to shown the mail browser.
+
+0.0.0.4
+============
++ Add per account option to be show as contact or not.
++ Gestion de la suppression d'un compte
++ Use of the status message for showing number of emails.
++ Refresh yamn contact on the click on apply in options dialog.
+* Better condition for the ^contact loop (ouuppsss)
+
+0.0.0.3
+============
++ Now account are shown as a contact.
++ Source code modification and use of yamn.h
++ Wait the event moduleloaded before loading the icons (support icolib).
+
+0.0.0.2
+============
++ Use of patch by Q (From file listing) (Memory cleaning, empty mail browser even if there are mails, yamn freeze sometime)
++ Use of thread access function.
++ Possibility to change toptoolbar icons via icolib.
++ Icon in main menu entry (Asked by a7)
++ New Icons set by Manudevil.
++ Change version number to be compatible with updater plugin
+
+0.01
+============
+
++ icolib support.
++ keyboard flash support (just 10 sec) (thx TioDuke) needs Keyboard Notify Ext. 1.5.4.4
++ list of email can be sorted.
+* left click on popup shows email list.
+* better toptoolbar support.
\ No newline at end of file diff --git a/plugins/YAMN/docs/InstallScript.xml b/plugins/YAMN/docs/InstallScript.xml new file mode 100644 index 0000000000..33d8ac9dfd --- /dev/null +++ b/plugins/YAMN/docs/InstallScript.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="ISO-8859-1"?>
+<installscript>
+ <info>
+ <name>Yet Another Mail Notifier</name>
+ <author>majvan</author>
+ <version>0.2.4.7</version>
+ <type>Plugin</type>
+ </info>
+
+ <packageinfo>
+ <title>Plugin</title>
+ <file>YAMN.dll</file>
+ </packageinfo>
+
+ <packageinfo>
+ <optional/>
+ <title>Documentation</title>
+ <file>YAMN-Readme.txt</file>
+ <file>YAMN-License.txt</file>
+ <document/>
+ </packageinfo>
+
+ <packageinfo>
+ <optional/>
+ <title>Developers Information</title>
+ <file>YAMN-Readme.developers.txt</file>
+ <document/>
+ </packageinfo>
+
+ <packageinfo>
+ <optional/>
+ <title>Simple filter plugin</title>
+ <file>YAMN\simple.dll</file>
+ <file>YAMN\simple-readme.txt</file>
+ </packageinfo>
+
+ <packageinfo>
+ <optional/>
+ <title>Base filter plugin</title>
+ <file>YAMN\base.dll</file>
+ <file>YAMN\base-readme.txt</file>
+ </packageinfo>
+
+ <autorun>
+ <file>YAMN-Readme.txt</file>
+ <document/>
+ </autorun>
+
+</installscript>
diff --git a/plugins/YAMN/docs/YAMN-License.txt b/plugins/YAMN/docs/YAMN-License.txt new file mode 100644 index 0000000000..7f1161073d --- /dev/null +++ b/plugins/YAMN/docs/YAMN-License.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ 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
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/plugins/YAMN/docs/YAMN-Readme.developers.txt b/plugins/YAMN/docs/YAMN-Readme.developers.txt new file mode 100644 index 0000000000..fdb338707c --- /dev/null +++ b/plugins/YAMN/docs/YAMN-Readme.developers.txt @@ -0,0 +1,205 @@ +==================================================================================
+= YAMN plugin for Miranda (short readme for developers) =
+==================================================================================
+Hello developer! :)
+I hope YAMN will give you what you find, but you can also improve YAMN.
+
+This readme gives you some info about YAMN. Please read it first before you are
+going to look at YAMN sources.
+
+YAMN provides two types of plugins now: protocol plugins and filter plugins.
+
+
+1. What do you need to make your protocol plugin cooperating with YAMN
+ -------------------------------------------------------------------
+
+ If you want to cooperate with YAMN, you have to do some things. YAMN offers you some services,
+ so your work is easier, but YAMN needs some things to be done for proper work. These limits go
+ according thread synchronization and memory mutual exclusion.
+
+ YAMN offers you two types of services. Exported functions and Miranda services. Miranda
+ services are described in header files, exported functions are described in cpp files. All
+ exported functions in YAMN have the suffix Fcn, so you can easy get if the function is
+ exported. Using exported functions is more difficult than using miranda services, but after
+ solving some definitions, the work with exported functions is more clear and easier. Miranda
+ services from YAMN are for miscellaneus functions. The fact Miranda service uses only two
+ parameters and therefore is sometimes very unsuitable leads us to make exported functions.
+ Exported functions are divided in several parts: synchronizing functions (used for thread
+ and account synchronization) and MIME functions (used to work with MIME
+ messages).
+
+ Miranda services are used through Miranda CallService function. YAMN exported functions are avialable
+ when registering plugin. Then YAMN gives you its table of exported functions.
+
+ How to write write your protocol plugin for YAMN? The best way for you is to look at
+ internal POP3 protocol, where all info about this is written. At start, you need to register
+ plugin (it is done in two steps- registering and inserting to YAMN), then get pointers to
+ YAMN's exported functions (using Miranda's service MS_YAMN_GETFCN) you will need in your
+ protocol plugin. These are the first steps you should do when implementing some plugin to
+ YAMN. Next, you should know how YAMN is stuctured. Structures of YAMN are described in
+ chapter 2. And, at the end, you should know something about account synchronizing and some
+ limitations you have to achieve, if you want your plugin works well.
+
+
+2. YAMN structures and memory organization
+ ---------------------------------------
+
+ YAMN uses its own structures, that can change in the future. The problem with change is,
+ that there can occur some incomapatibilities between YAMN and plugins written for old YAMN
+ versions. To avoid problems, YAMN defines versions for services or exported/imported
+ functions, where strucutre version information is passed to/from plugins.
+
+
+2.1. Structures of protcol plugin queue
+
+ (PYAMN_PROTOPLUGINQUEUE)FirstPlugin---> =(HYAMNPROTOPLUGIN)= ---> =(HYAMNPROTOPLUGIN)= ---> =(HYAMNPROTOPLUGIN)= ---> NULL
+ | | | | | | | | |
+ | . | | | . | | | . | |
+ | . | | | . | | | . | |
+ | . | | | . | | | . | |
+ -------------------- | |------------------| | |------------------| |
+ | Next |--| | Next |--| | Next |--|
+ ==================== ==================== ====================
+
+ This structure is not needed if you only create protocol plugin for YAMN. YAMN plugin does
+ not see and it is not important for it how YAMN works with plugins and how it stores plugins
+ data. For plugin is important only handle for its own plugin, returned from
+ MS_YAMN_REGISTERPLUGIN service.
+
+
+2.2. Structure of accounts
+
+ Every account in YAMN belongs to exact plugin and its members are allocated with
+ MS_YAMN_CREATEPLUGINACCOUNT service. This service cooperates with your function, which is
+ defined in your function import table. In your function (if you have defined it), you should
+ create the whole account. It is because YAMN cannot know which members in structure did you
+ add. So you create the whole derived structure. If your fcn is not implemented (NULL in
+ import table), YAMN creates standard account structure.
+
+ This structure contains information (members) related to YAMN, to plugin and members shared
+ between both (plugin and YAMN). Therefore it is needed to synchronize access to members (see
+ Ch. 3). Standard YAMN account is defined in m_account.h header file. There's also
+ description for every member how it is synchronised. YAMN creates two synchronizing objects
+ (SO) to synchronise access to members. In m_synchro.h file, there are definitions for easy
+ work with these SO.
+
+ Accounts are queued in plugin:
+
+ =(HYAMNPLUGIN)= ---> ===(HACCOUNT)=== ---> ===(HACCOUNT)=== ---> ===(HACCOUNT)=== ---> NULL
+ | | | | | | | | | | | |
+ | | | | | | | | | | | |
+ | . | | | | | | | | | | |
+ | . | | | | | | | | | | |
+ | . | | | | | | | | | | |
+ | | | |--------------| | |--------------| | |--------------| |
+ | (HACCOUNT) | | | Next |--| | Next |--| | Next |--|
+ | FirstAccount|--| ================ ================ ================
+ |-------------|
+ | |
+ ===============
+
+ Every account has its own back pointer to (HYAMNPLUGIN) in Plugin member, so you can easy
+ look at first account, when you have any other account (see m_account.h).
+
+
+2.3. Structure of mails
+
+ Account has a pointer to mails. Account's pointer to mails is pointer to first mail in fact
+ and mails are queued too:
+
+ ==(HACCOUNT)== ---> ==(HYAMNMAIL)== ---> ==(HYAMNMAIL)== ---> ==(HYAMNMAIL)== ---> NULL
+ | | | | | | | | | | | |
+ | . | | | | | | | | | | |
+ | . | | | | | | | | | | |
+ | . | | | | | | | | | | |
+ | | | |-------------| | |-------------| | |-------------| |
+ | (HYAMNMAIL)| | | Next |--| | Next |--| | Next |--|
+ | Mails|--| =============== =============== ===============
+ |------------|
+ | |
+ ==============
+
+ Standard MIME mail is defined in mails/m_mails.h file.
+
+ Plugin can work with accounts in its own way, but note it is needed to synchronize access.
+ For better work, YAMN offers you some services and exports functions. Description of
+ exported functions is in its declartation; for accounts functions see account.cpp, for mails
+ functions see mails/mails.cpp and so on.
+
+
+3. YAMN thread synchronization
+ ---------------------------
+
+ Because YAMN is multithreaded, more than one thread can access to any member of account
+ structure. Therefore access to these members should be synchronised. YAMN offers two types
+ of synchronization objects (SO): SCOUNTER (Synchronized Counter) and SWMRG (Single
+ Writer/Multiple Readers Guard). To use these objects, you can use exported functions:
+
+ SWMRG: WaitToWriteSO, WaitToWriteSOEx, WriteDoneSO, WaitToReadSO, WaitToReadSOEx, ReadDoneSO
+ SCOUNTER: SCGetNumber, SCInc, SCDec
+
+ To see description for these functions, see m_synchro.h header file and synchro.cpp. Note
+ that in HACCOUNT structure, there are 3 synchronizing members, which you have to use if you
+ want to access to any member of account structure. All access techniques (writing to members
+ and read from members) are used in POP3 protocol plugin. Now, it is important what we have
+ to do when we want to make our plugin be synchronized with YAMN (in POP3 protocol it is
+ described too).
+
+ 1. We have to use ThreadRunningEV event when YAMN calls our checking/deleting function. This
+ parameter is to stop YAMN called thread until we do not have copied datas from stack. After
+ that, we SetEvent(ThreadRunningEvent) to unblock YAMN to continue in its work.
+
+ 2. We have to use UsingThreads account's member. This is only for YAMN account deleting
+ prevention. We use this counter to set number of threads using account. If no thread is just
+ using account, account is signaled, that it can be deleted (and is deleted when needed).
+ This leads us to do some things: We use SCInc(UsingThreads) as the first thing we can do. We
+ cannot omit, that called thread finished before we call this function. UsingThreads should
+ have "continuous" value greater than zero when using account. E.g. if YAMN creates thread
+ for plugin that checks account for new mail, YAMN waits until we set ThreadRunningEV (see
+ point 1). After setting this event to signal, that YAMN can continue in its work, we
+ increase SCInc(UsingThreads), so we ensure that another thread uses account before YAMN
+ thread, that uses this account ends. And SCDec(UsingThreads) should be the last thing we do
+ in our thread. If we run another thread in our thread, we should wait until it does not
+ SCInc(UsingThreads) and after that we should continue (just like YAMN creates and calls our
+ thread).
+
+ 3. If we use account's SWMRG (AccountAccessSO, MessagesAccessSO), we should test what our
+ function returned. Use the same methods as POP3 protocol does while testing and accessing
+ critical section. Note that we cannot use WaitToWriteSO(MyAccount->AccountAccessSO), but in
+ easy way we can WaitToWrite(AccountAccess) and for mails
+ WaitToWriteSO(MyAccount->MessagesAccessSO) use MsgsWaitToWrite(AccountAccess) and so on. See
+ export.h file for these definitions.
+
+ 4. Deleting account is quite easy, but in YAMN, it is very problematic operation. If you use
+ MS_YAMN_DELETEACCOUNT service, it is the best way to avoid any problem. These problems raise
+ from the facts desribed in the point 2.
+
+ 5. You should use ctritical sections only for short time not to block other threads. You can
+ imagine that users can't browse through mails, because account is blocked by your thread...
+
+ All needed infos in POP3 internal protocol plugin (see proto/pop3/pop3comm.cpp), are
+ described.
+
+
+4. What do you need to make your filter plugin cooperating with YAMN
+ -----------------------------------------------------------------
+
+ Filter plugins are very easy to write in its own way, it much more easier than protocol
+ plugin. But some things are common: you have to register your plugin and insert to YAMN
+ (these are 2 steps, see sources of some filter plugin), You have to import to YAMN your
+ filter function. Filter function can do anything with mails, but the most important is, that
+ it can set Flags member of mail (see mails/m_mails.h file) to one of YAMN_MSG_SPAMLx.
+ Note Mail is in write-access, so your plugin can do anything with mail and avoid the
+ synchronization problem.
+
+ Now YAMN recognizes 4 spam levels:
+ 1. Notifies about this mail, but shows it in mailbrowser with other color than normally
+ 2. Does not notify about this mail, shows it in mailbrowser with other color than normally
+ 3. Deletes mail from server (depends on protocol), does not notify and shows "this spam was
+ deleted"
+ 4. Deletes mail from server (depends on protocol), does not notify, does not show in
+ mailbrowser
+
+ Your plugin can set data for mail in the TranslatedHeader structure, inserting it to the
+ queue. This information is stored, so it is reloaded after protocol read mails from book
+ file.
diff --git a/plugins/YAMN/docs/YAMN-Readme.txt b/plugins/YAMN/docs/YAMN-Readme.txt new file mode 100644 index 0000000000..901ad22f73 --- /dev/null +++ b/plugins/YAMN/docs/YAMN-Readme.txt @@ -0,0 +1,79 @@ +=========================================================
+= YAMN plugin for Miranda readme =
+=========================================================
+Yet Another Mail Notifier
+Checks pop3 accounts for new mail
+
+Advantages:
+- quite small
+- structured in two parts: notifier and protocols
+- unlimited number of accounts
+- international support in Unicode
+- open-source (GNU-GPL)
+POP3:
+- many switches for each account
+- support for MIME standard
+- support for Base64 and Quoted-Printable
+- 100% detection of new mail based on unique message ID
+- multithreaded checking (also with hotkey)
+- deleting mail from server
+- connecting through Miranda proxy
+- secure password authentification
+- SSL support through OpenSSL
+
+WIN9X SUPPORT
+-------------
+Win9x users, use unicows.dll library, download it at:
+http://libunicows.sf.net (whole package)
+or just visit http://www.majvan.host.sk/Projekty/YAMN
+and download zip-ed unicows.dll
+All you need is to copy unicows.dll to Windows system32
+directory (or to Miranda home directory). Use Win9x
+version of YAMN, not WinNT version.
+
+SSL SUPPORT
+-----------
+If you want to use SSL features, you have to download
+OpenSSL libraries on YAMN homepage
+http://www.majvan.host.sk/Projekty/YAMN
+or the latest (stable) version with installer on
+http://www.slproweb.com/products/Win32OpenSSL.html
+Copy *.dll files to Windows system32 directory (or to
+Miranda home directory).
+
+LATEST STABLE
+-------------
+Version of YAMN has following structure: w.x.y.z
+z- only some bug fixed or some changes
+y- some new feature added
+x- big feature added
+w- if this changes, YAMN becomes better than Outlook ;-)
+Latest stable plugin is always present to download from YAMN
+homepage.
+
+BETA
+----
+* YAMN-beta version is intended only for testing purposes.
+* Author waits for stability reports. Sometimes author waits not
+only for crash reports, but also for success reports (you are
+informed by message box on startup, if success reports are also
+needed). This is because he has no resources for testing.
+* Please do not send reports if newer beta version is available.
+* Please do not send reports without describing problem detailed.
+* Beta version produces debug files (yamn-debug.*.log) located
+in Miranda home directory (like every YAMN debug release). These
+files are usefull for author to locate the bug (although not
+100%). After Miranda restart, log files are rewritten. Log files
+can become very large (more than 10MB). Sometimes they can be
+cut at the end (contact author).
+IMPORTANT FOR BETA: yamn-debug.comm.log file contains your plain
+password. You should rewrite it.
+Thank you for comprehension.
+
+=========================================================
+ Do you want some FAQ? Visit HOMEPAGE:
+ http://www.majvan.host.sk/Projekty/YAMN
+ Still don't know answer? Write question to guestbook.
+
+ majvan
+=========================================================
diff --git a/plugins/YAMN/proto_yamn/proto_YAMN_10.vcxproj b/plugins/YAMN/proto_yamn/proto_YAMN_10.vcxproj new file mode 100644 index 0000000000..2338196c5f --- /dev/null +++ b/plugins/YAMN/proto_yamn/proto_YAMN_10.vcxproj @@ -0,0 +1,131 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>Proto_YAMN</ProjectName>
+ <ProjectGuid>{C1CDB82C-6BBF-496E-88F4-CC57E60B0CA9}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\proto_YAMN.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/YAMN/proto_yamn/proto_YAMN_10.vcxproj.filters b/plugins/YAMN/proto_yamn/proto_YAMN_10.vcxproj.filters new file mode 100644 index 0000000000..3fa00bebfb --- /dev/null +++ b/plugins/YAMN/proto_yamn/proto_YAMN_10.vcxproj.filters @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{4726e1d1-39cd-435a-bd59-51fdb6745f46}</UniqueIdentifier>
+ <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{81ae85e6-6c6b-42dc-be93-6b2bdc29210f}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\proto_YAMN.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/YAMN/proto_yamn/res/icoaway.ico b/plugins/YAMN/proto_yamn/res/icoaway.ico Binary files differnew file mode 100644 index 0000000000..a99cbe0a60 --- /dev/null +++ b/plugins/YAMN/proto_yamn/res/icoaway.ico diff --git a/plugins/YAMN/proto_yamn/res/icooccupied.ico b/plugins/YAMN/proto_yamn/res/icooccupied.ico Binary files differnew file mode 100644 index 0000000000..81dd9fe467 --- /dev/null +++ b/plugins/YAMN/proto_yamn/res/icooccupied.ico diff --git a/plugins/YAMN/proto_yamn/res/icooffline.ico b/plugins/YAMN/proto_yamn/res/icooffline.ico Binary files differnew file mode 100644 index 0000000000..78f925ede7 --- /dev/null +++ b/plugins/YAMN/proto_yamn/res/icooffline.ico diff --git a/plugins/YAMN/proto_yamn/res/icoonline.ico b/plugins/YAMN/proto_yamn/res/icoonline.ico Binary files differnew file mode 100644 index 0000000000..b2605bb9d4 --- /dev/null +++ b/plugins/YAMN/proto_yamn/res/icoonline.ico diff --git a/plugins/YAMN/proto_yamn/res/proto_YAMN.rc b/plugins/YAMN/proto_yamn/res/proto_YAMN.rc new file mode 100644 index 0000000000..087ee444c9 --- /dev/null +++ b/plugins/YAMN/proto_yamn/res/proto_YAMN.rc @@ -0,0 +1,16 @@ +#include "..\src\resource.h"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+
+IDI_ICON1 ICON "icooffline.ico"
+IDI_ICON2 ICON "icoonline.ico"
+IDI_ICON5 ICON "icooffline.ico"
+IDI_ICON7 ICON "icooccupied.ico"
+IDI_ICON3 ICON "icoaway.ico"
diff --git a/plugins/YAMN/proto_yamn/src/resource.h b/plugins/YAMN/proto_yamn/src/resource.h new file mode 100644 index 0000000000..0532df3fa6 --- /dev/null +++ b/plugins/YAMN/proto_yamn/src/resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Proto_YAMN.rc
+//
+#define IDI_ICON1 105
+#define IDI_ICON2 104
+#define IDI_ICON3 128
+#define IDI_ICON5 131
+#define IDI_ICON7 159
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 110
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/YAMN/res/YAMN.rc b/plugins/YAMN/res/YAMN.rc new file mode 100644 index 0000000000..70f5976d15 --- /dev/null +++ b/plugins/YAMN/res/YAMN.rc @@ -0,0 +1,338 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "..\src\resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1251)
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "..\\src\\resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_DLGVIEWMESSAGES, DIALOG
+ BEGIN
+ LEFTMARGIN, 5
+ RIGHTMARGIN, 455
+ TOPMARGIN, 5
+ BOTTOMMARGIN, 105
+ END
+
+ IDD_DLGSHOWMESSAGE, DIALOG
+ BEGIN
+ END
+
+ IDD_DLGBADCONNECT, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 43
+ END
+
+ IDD_PLUGINOPT, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ VERTGUIDE, 13
+ VERTGUIDE, 85
+ VERTGUIDE, 160
+ VERTGUIDE, 307
+ TOPMARGIN, 4
+ HORZGUIDE, 5
+ HORZGUIDE, 20
+ HORZGUIDE, 147
+ HORZGUIDE, 157
+ HORZGUIDE, 173
+ HORZGUIDE, 184
+ HORZGUIDE, 207
+ HORZGUIDE, 217
+ END
+
+ IDD_POP3ACCOUNTOPT, DIALOG
+ BEGIN
+ VERTGUIDE, 155
+ VERTGUIDE, 236
+ END
+
+ IDD_CHOOSESTATUSMODES, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 219
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 147
+ END
+
+ IDD_YAMNOPT, DIALOG
+ BEGIN
+ RIGHTMARGIN, 310
+ VERTGUIDE, 8
+ END
+
+ IDD_POP3ACCOUNTPOPUP, DIALOG
+ BEGIN
+ VERTGUIDE, 155
+ VERTGUIDE, 236
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DLGVIEWMESSAGES DIALOG 50, 200, 460, 110
+STYLE DS_SETFONT | DS_3DLOOK | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+FONT 8, "MS Shell Dlg"
+BEGIN
+ CONTROL "List4",IDC_LISTMAILS,"SysListView32",LVS_REPORT | LVS_EDITLABELS | WS_BORDER | WS_TABSTOP,5,5,450,70
+ DEFPUSHBUTTON "",IDC_BTNOK,395,90,60,15
+ PUSHBUTTON "",IDC_BTNAPP,263,90,114,15
+ PUSHBUTTON "",IDC_BTNDEL,5,90,114,15
+ LTEXT "",IDC_STSTATUS,5,75,450,10
+ PUSHBUTTON "",IDC_BTNCHECKALL,150,91,92,14
+END
+
+IDD_DLGSHOWMESSAGE DIALOGEX 50, 200, 460, 132
+STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "List5",IDC_LISTHEADERS,"SysListView32",LVS_REPORT | LVS_EDITLABELS | WS_BORDER | WS_TABSTOP,5,5,450,70
+ CONTROL "",IDC_SPLITTER,"Static",SS_ENHMETAFILE | WS_TABSTOP,0,80,187,2,WS_EX_STATICEDGE
+ EDITTEXT IDC_EDITBODY,3,84,454,45,ES_MULTILINE | ES_READONLY | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
+END
+
+IDD_DLGBADCONNECT DIALOG 0, 0, 186, 76
+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+FONT 8, "MS Shell Dlg"
+BEGIN
+ DEFPUSHBUTTON "OK",IDC_BTNOK,69,55,50,14
+ LTEXT "",IDC_STATICMSG,7,7,172,37
+END
+
+IDD_PLUGINOPT DIALOGEX 0, 0, 310, 231
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_BORDER
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ GROUPBOX "Installed plugins",IDC_STATIC,7,5,300,142
+ COMBOBOX IDC_COMBOPLUGINS,13,14,287,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Version:",IDC_STATIC,13,30,72,11
+ EDITTEXT IDC_STVER,85,30,215,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_GROUP
+ LTEXT "Description:",IDC_STATIC,13,41,72,23
+ EDITTEXT IDC_STDESC,85,41,215,23,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_GROUP
+ LTEXT "Copyright:",IDC_STATIC,13,64,72,10
+ EDITTEXT IDC_STCOPY,85,63,215,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_GROUP
+ LTEXT "Contact:",IDC_STATIC,13,77,72,11
+ EDITTEXT IDC_STMAIL,85,76,214,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_GROUP
+ LTEXT "WWW:",IDC_STATIC,13,101,72,11
+ CONTROL "",IDC_STWWW,"Hyperlink",WS_TABSTOP,85,101,215,11
+END
+
+IDD_POP3ACCOUNTOPT DIALOGEX 0, 0, 310, 230
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ COMBOBOX IDC_COMBOACCOUNT,4,6,106,65,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ CONTROL "Check this account",IDC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,167,32,118,10,WS_EX_TRANSPARENT
+ LTEXT "Check interval [min]:",IDC_STINTERVAL,168,56,94,8
+ EDITTEXT IDC_EDITINTERVAL,259,53,20,12,ES_AUTOHSCROLL | ES_NUMBER,WS_EX_TRANSPARENT
+ GROUPBOX "Notifications",IDC_GBNEWMAIL,4,143,304,87
+ CONTROL "Sound",IDC_CHECKSND,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,12,162,60,10
+ CONTROL "Message",IDC_CHECKMSG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,174,135,10
+ CONTROL "Tray Icon",IDC_CHECKICO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,163,65,10
+ CONTROL "Keyboard Flash",IDC_CHECKKBN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,186,132,9
+ CONTROL "Execute Application",IDC_CHECKAPP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,198,135,8
+ PUSHBUTTON "...",IDC_BTNAPP,19,209,16,12
+ EDITTEXT IDC_EDITAPP,41,209,65,12,ES_AUTOHSCROLL
+ EDITTEXT IDC_EDITAPPPARAM,111,209,40,12,ES_AUTOHSCROLL
+ CONTROL "Use contact notification for this account",IDC_CHECKCONTACT,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,107,138,10,WS_EX_TRANSPARENT
+ CONTROL "Replace nick name",IDC_CHECKCONTACTNICK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,117,117,10,WS_EX_TRANSPARENT
+ CONTROL "Disable Events",IDC_CHECKCONTACTNOEVENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,128,115,10,WS_EX_TRANSPARENT
+ LTEXT "",IDC_STSTATUS,218,9,88,8
+ LTEXT "Server:",IDC_STSERVER,10,50,44,8
+ EDITTEXT IDC_EDITSERVER,56,48,92,12,ES_AUTOHSCROLL | WS_GROUP
+ LTEXT "User Name:",IDC_STLOGIN,10,82,44,8
+ EDITTEXT IDC_EDITLOGIN,57,80,92,12,ES_AUTOHSCROLL | WS_GROUP
+ LTEXT "Password:",IDC_STPASS,10,96,44,8
+ EDITTEXT IDC_EDITPASS,57,94,92,12,ES_PASSWORD | ES_AUTOHSCROLL | WS_GROUP
+ LTEXT "Codepage:",IDC_STCP,10,111,44,8
+ COMBOBOX IDC_COMBOCP,57,108,92,130,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
+ LTEXT "Port:",IDC_STPORT,10,65,44,8,SS_CENTERIMAGE
+ EDITTEXT IDC_EDITPORT,57,64,27,12,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP
+ CONTROL "SSL",IDC_CHECKSSL,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,87,66,27,10
+ CONTROL "Disable STLS",IDC_CHECKNOTLS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,83,125,69,10
+ CONTROL "Startup check",IDC_CHECKSTART,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,167,43,78,10
+ CONTROL "Auto retrieve body",IDC_AUTOBODY,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,166,86,137,10
+ CONTROL "Check from menu",IDC_CHECKFORCE,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,166,97,137,8
+ PUSHBUTTON "Only check when ...",IDC_BTNSTATUS,195,69,81,13
+ CONTROL "Sound notification if failed",IDC_CHECKFSND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,163,135,10
+ CONTROL "Message notification if failed",IDC_CHECKFMSG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,174,135,10
+ CONTROL "Tray icon notification if failed",IDC_CHECKFICO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,166,186,135,10
+ PUSHBUTTON "Reset counter",IDC_BTNRESET,161,200,75,13
+ PUSHBUTTON "-",IDC_BTNDEL,140,6,15,13
+ PUSHBUTTON "Default",IDC_BTNDEFAULT,9,124,54,13
+ LTEXT "",IDC_STTIMELEFT,163,216,141,8
+ LTEXT "Status:",IDC_STATIC,175,9,34,9
+ PUSHBUTTON "+",IDC_BTNADD,118,6,15,13
+ GROUPBOX "Account",IDC_STATIC,4,22,151,120
+ CONTROL "APOP",IDC_CHECKAPOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,119,66,34,10
+ LTEXT "Name:",IDC_STATIC,10,34,44,10
+ EDITTEXT IDC_EDITNAME,56,32,92,12,ES_AUTOHSCROLL
+ GROUPBOX "Options",IDC_STATIC,161,22,147,120
+ GROUPBOX "New Mail",IDC_STATIC,7,153,149,73
+ GROUPBOX "Errors",IDC_STATIC,161,153,143,44
+END
+
+IDD_CHOOSESTATUSMODES DIALOG 0, 0, 226, 154
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Check while ..."
+FONT 8, "MS Shell Dlg"
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,112,133,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,169,133,50,14
+ GROUPBOX "Choose modes",IDC_STATUSGROUP,7,7,212,119
+ CONTROL "Offline",IDC_CHECKST0,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,15,19,70,9
+ CONTROL "Online",IDC_CHECKST1,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,15,39,70,9
+ CONTROL "Away",IDC_CHECKST2,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,15,62,70,9
+ CONTROL "N/A",IDC_CHECKST3,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,15,83,70,9
+ CONTROL "Occupied",IDC_CHECKST4,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,15,104,70,9
+ CONTROL "DND",IDC_CHECKST5,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,134,19,70,9
+ CONTROL "Free for chat",IDC_CHECKST6,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,134,39,70,9
+ CONTROL "Invisible",IDC_CHECKST7,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,134,62,70,9
+ CONTROL "On the phone",IDC_CHECKST8,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,134,83,70,9
+ CONTROL "Out to lunch",IDC_CHECKST9,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,134,104,70,9
+END
+
+IDD_YAMNOPT DIALOGEX 0, 0, 312, 121
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_BORDER
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ GROUPBOX "YAMN General Options",IDC_STATIC,3,2,303,65
+ CONTROL "TopToolBar button ""Check mail""",IDC_CHECKTTB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,15,294,11
+ CONTROL "Enable YAMN Main Menu",IDC_MAINMENU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,33,293,9
+ CONTROL "Show YAMN as a Protocol (Require Restart)",IDC_YAMNASPROTO,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,50,293,9
+
+ GROUPBOX "MailBrowser Options",IDC_STATIC,3,68,151,47
+ CONTROL "Enable Close on Delete Button",IDC_CLOSEONDELETE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,80,143,11
+ CONTROL "Show long localised date",IDC_LONGDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,77,130,10
+ CONTROL "Don't show today's date",IDC_SMARTDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,89,131,10
+
+ GROUPBOX "Date/Time Representation",IDC_STATIC,166,68,141,47
+ CONTROL "Don't show seconds",IDC_NOSECONDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,170,101,129,8
+END
+
+IDD_POP3ACCOUNTPOPUP DIALOGEX 0, 0, 315, 230
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ COMBOBOX IDC_COMBOACCOUNT,4,4,140,65,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "Mail Notifications",IDC_GBNEWMAIL,5,23,300,76
+ CONTROL "Popup",IDC_CHECKPOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,32,108,10
+ CONTROL "Single popup",IDC_RADIOPOP1,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,23,43,95,10
+ CONTROL "Multi popup",IDC_RADIOPOPN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,23,55,95,10
+ CONTROL "Use custom colour",IDC_CHECKCOL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,83,107,10
+ CONTROL "",IDC_CPB,"ColourPicker",WS_TABSTOP,145,66,29,12
+ CONTROL "",IDC_CPT,"ColourPicker",WS_TABSTOP,145,83,29,12
+ EDITTEXT IDC_EDITPOPS,23,65,20,12,ES_AUTOHSCROLL
+ GROUPBOX "No new mail notifications",IDC_GBNONEWMAIL,5,152,300,62
+ CONTROL "Popup if no mail",IDC_CHECKNPOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,161,94,10
+ CONTROL "Persistant message",IDC_CHECKNMSGP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,188,110,10
+ CONTROL "Use custom colour",IDC_CHECKNCOL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,201,107,10
+ CONTROL "",IDC_CPNB,"ColourPicker",WS_TABSTOP,145,181,29,12
+ CONTROL "",IDC_CPNT,"ColourPicker",WS_TABSTOP,145,198,29,12
+ EDITTEXT IDC_EDITNPOPS,23,173,20,12,ES_AUTOHSCROLL
+ GROUPBOX "Connection failure notifications",IDC_GBBADCONNECT,5,101,300,49
+ CONTROL "Popup notification if failed",IDC_CHECKFPOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,110,118,10
+ CONTROL "Use custom colour",IDC_CHECKFCOL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,136,95,10
+ CONTROL "",IDC_CPFB,"ColourPicker",WS_TABSTOP,145,118,29,12
+ CONTROL "",IDC_CPFT,"ColourPicker",WS_TABSTOP,145,134,29,12
+ EDITTEXT IDC_EDITFPOPS,23,121,20,12,ES_AUTOHSCROLL
+ LTEXT "..s Popup duration",IDC_STATIC,45,67,70,8
+ LTEXT "..s Popup duration",IDC_STATIC,45,176,70,8
+ LTEXT "..s Popup duration",IDC_STATIC,45,122,70,8
+ PUSHBUTTON "Preview",IDC_PREVIEW,255,215,49,13
+ LTEXT "Background colour",IDC_STATIC,177,184,108,10
+ LTEXT "Text colour",IDC_STATIC,177,200,107,10
+ LTEXT "Background colour",IDC_STATIC,177,120,108,10
+ LTEXT "Text colour",IDC_STATIC,177,136,107,10
+ LTEXT "Background colour",IDC_STATIC,177,69,108,10
+ LTEXT "Text colour",IDC_STATIC,177,85,107,10
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_CHECKMAIL ICON "checkmail.ico"
+IDI_LAUNCHAPP ICON "launchapp.ico"
+IDI_BADCONNECT ICON "badconnect.ico"
+IDI_NEWMAIL ICON "newmail.ico"
+
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
diff --git a/plugins/YAMN/res/badconnect.ico b/plugins/YAMN/res/badconnect.ico Binary files differnew file mode 100644 index 0000000000..78f925ede7 --- /dev/null +++ b/plugins/YAMN/res/badconnect.ico diff --git a/plugins/YAMN/res/checkmail.ico b/plugins/YAMN/res/checkmail.ico Binary files differnew file mode 100644 index 0000000000..b2605bb9d4 --- /dev/null +++ b/plugins/YAMN/res/checkmail.ico diff --git a/plugins/YAMN/res/launchapp.ico b/plugins/YAMN/res/launchapp.ico Binary files differnew file mode 100644 index 0000000000..81dd9fe467 --- /dev/null +++ b/plugins/YAMN/res/launchapp.ico diff --git a/plugins/YAMN/res/newmail.ico b/plugins/YAMN/res/newmail.ico Binary files differnew file mode 100644 index 0000000000..a99cbe0a60 --- /dev/null +++ b/plugins/YAMN/res/newmail.ico diff --git a/plugins/YAMN/res/yamn_ver.rc b/plugins/YAMN/res/yamn_ver.rc new file mode 100644 index 0000000000..84d27568b6 --- /dev/null +++ b/plugins/YAMN/res/yamn_ver.rc @@ -0,0 +1,76 @@ +// Microsoft Visual C++ generated resource script.
+//
+
+#include "..\src\version.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 0,1,2,5
+ PRODUCTVERSION 0,1,2,5
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "Comments", "Yet Another Mail Notifier"
+ VALUE "FileDescription", "Yet Another Mail Notifier"
+ VALUE "FileVersion", YAMN_VERSION_C
+ VALUE "InternalName", "YAMN"
+ VALUE "LegalCopyright", "Copyright © 2007"
+ VALUE "OriginalFilename", "YAMN.dll"
+ VALUE "ProductName", "YAMN tweety"
+ VALUE "ProductVersion", YAMN_VERSION_C
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
+
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
diff --git a/plugins/YAMN/src/YAMNopts.cpp b/plugins/YAMN/src/YAMNopts.cpp new file mode 100644 index 0000000000..99a8091366 --- /dev/null +++ b/plugins/YAMN/src/YAMNopts.cpp @@ -0,0 +1,2 @@ +
+
diff --git a/plugins/YAMN/src/account.cpp b/plugins/YAMN/src/account.cpp new file mode 100644 index 0000000000..f45dcfadcd --- /dev/null +++ b/plugins/YAMN/src/account.cpp @@ -0,0 +1,1309 @@ +/*
+ * This code implements manipulation with accounts
+ * such as reading accounts from file, writing them to file,
+ * finding account by name etc.
+ *
+ * (c) majvan 2002-2004
+ */
+
+#include "yamn.h"
+#include "m_mails.h"
+#if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES) || defined(DEBUG_SYNCHRO)
+ #include <stdio.h>
+#endif
+
+//Account status CS
+//When we check some account, thread should change status of account to idle, connecting etc.
+//So if we want to read status, we have to successfully write and then read.
+CRITICAL_SECTION AccountStatusCS;
+
+//File Writing CS
+//When 2 threads want to write to file...
+CRITICAL_SECTION FileWritingCS;
+
+struct CExportedFunctions AccountExportedFcn[]=
+{
+ {YAMN_GETSTATUSID,(void *)GetStatusFcn},
+ {YAMN_SETSTATUSID,(void *)SetStatusFcn},
+};
+
+struct CExportedServices AccountExportedSvc[]=
+{
+ {MS_YAMN_CREATEPLUGINACCOUNT,CreatePluginAccountSvc},
+ {MS_YAMN_DELETEPLUGINACCOUNT,DeletePluginAccountSvc},
+ {MS_YAMN_FINDACCOUNTBYNAME,FindAccountByNameSvc},
+ {MS_YAMN_GETNEXTFREEACCOUNT,GetNextFreeAccountSvc},
+ {MS_YAMN_DELETEACCOUNT,DeletePluginAccountSvc},
+ {MS_YAMN_READACCOUNTS,AddAccountsFromFileSvc},
+ {MS_YAMN_WRITEACCOUNTS,WriteAccountsToFileSvc},
+};
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+INT_PTR CreatePluginAccountSvc(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
+ DWORD AccountVersion=(DWORD)lParam;
+ HACCOUNT NewAccount;
+
+//test if we are going to initialize members of suitable structure (structures of plugin and YAMN must match)
+ if (AccountVersion!=YAMN_ACCOUNTVERSION)
+ return NULL;
+
+ if (Plugin!=NULL)
+ {
+ if (Plugin->Fcn->NewAccountFcnPtr!=NULL)
+ {
+//Let plugin create its own structure, which can be derived from CAccount structure
+ NewAccount=Plugin->Fcn->NewAccountFcnPtr(Plugin,YAMN_ACCOUNTVERSION);
+ NewAccount->Plugin=Plugin;
+ }
+ else
+ {
+//We suggest plugin uses standard CAccount structure, so we create it
+ NewAccount=new struct CAccount;
+ NewAccount->Plugin=Plugin;
+ }
+//If not created successfully
+ if (NewAccount==NULL)
+ return NULL;
+//Init every members of structure, used by YAMN
+ InitAccount(NewAccount);
+
+ return (INT_PTR)NewAccount;
+ }
+ return NULL;
+}
+
+INT_PTR DeletePluginAccountSvc(WPARAM wParam,LPARAM)
+{
+ HACCOUNT OldAccount=(HACCOUNT)wParam;
+
+ if (OldAccount->Plugin->Fcn!=NULL)
+ {
+//Deinit every members and allocated fields of structure used by YAMN
+ DeInitAccount(OldAccount);
+ if (OldAccount->Plugin->Fcn->DeleteAccountFcnPtr!=NULL)
+ {
+//Let plugin delete its own CAccount derived structure
+ OldAccount->Plugin->Fcn->DeleteAccountFcnPtr(OldAccount);
+ }
+ else
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeletePluginAccountSvc:delete OldAccount\n");
+#endif
+ delete OldAccount; //consider account as standard YAMN HACCOUNT and use its own destructor
+ }
+ return 1;
+ }
+ delete OldAccount; //consider account as standard YAMN HACCOUNT, not initialized before and use its own destructor
+ return 1;
+}
+
+int InitAccount(HACCOUNT Which)
+{
+//initialize synchronizing objects
+ Which->AccountAccessSO=new SWMRG;
+ SWMRGInitialize(Which->AccountAccessSO,NULL);
+ Which->MessagesAccessSO=new SWMRG;
+ SWMRGInitialize(Which->MessagesAccessSO,NULL);
+ Which->UsingThreads=new SCOUNTER;
+ SWMRGInitialize(Which->MessagesAccessSO,NULL);
+
+//zero memory, where timestamps are stored
+ ZeroMemory(&Which->LastChecked,sizeof(Which->LastChecked));
+ ZeroMemory(&Which->LastSChecked,sizeof(Which->LastSChecked));
+ ZeroMemory(&Which->LastSynchronised,sizeof(Which->LastSynchronised));
+ ZeroMemory(&Which->LastMail,sizeof(Which->LastMail));
+
+ Which->Name=NULL;
+ Which->Mails=NULL;
+ Which->Interval=0;
+ Which->Flags=0;
+ Which->StatusFlags=0;
+ Which->Next=NULL;
+
+ Which->Server=new struct CServer;
+ Which->AbleToWork=TRUE;
+
+ return 1;
+}
+
+void DeInitAccount(HACCOUNT Which)
+{
+//delete YAMN allocated fields
+ if (Which->Name!=NULL)
+ delete[] Which->Name;
+ if (Which->Server->Name!=NULL)
+ delete[] Which->Server->Name;
+ if (Which->Server->Login!=NULL)
+ delete[] Which->Server->Login;
+ if (Which->Server->Passwd!=NULL)
+ delete[] Which->Server->Passwd;
+ if (Which->Server!=NULL)
+ delete[] Which->Server;
+
+ SWMRGDelete(Which->AccountAccessSO);
+ delete Which->AccountAccessSO;
+ SWMRGDelete(Which->MessagesAccessSO);
+ delete Which->MessagesAccessSO;
+ delete Which->UsingThreads;
+ DeleteMessagesToEndFcn(Which,(HYAMNMAIL)Which->Mails);
+}
+
+void StopSignalFcn(HACCOUNT Which)
+//set event that we are going to delete account
+{
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tStopSignalFcn:stop account: %x\n",Which);
+#endif
+ Which->AbleToWork=FALSE;
+//do not use synchronizing objects anymore
+//any access to these objects then ends with WAIT_FAILED
+ SetEvent(Which->AccountAccessSO->hFinishEV);
+ SetEvent(Which->MessagesAccessSO->hFinishEV);
+}
+
+void CodeDecodeString(char *Dest,BOOL Encrypt)
+{
+ TCHAR Code=STARTCODEPSW;
+
+ if (Dest==NULL)
+ return;
+
+ for (;*Dest!=(TCHAR)0;Dest++)
+ {
+ if (Encrypt)
+ *Dest=*Dest+Code;
+ else
+ *Dest=*Dest-Code;
+ Code+=(TCHAR)ADDCODEPSW;
+ }
+}
+
+static DWORD PostFileToMemory(HANDLE File,char **MemFile,char **End)
+{
+ DWORD FileSize,ReadBytes;
+ if (!(FileSize=GetFileSize(File,NULL))) {
+ CloseHandle(File);
+ return EACC_FILESIZE;
+ }
+
+ //allocate space in memory, where we copy the whole file
+ if (NULL==(*MemFile = new char[FileSize]))
+ {
+ CloseHandle(File);
+ return EACC_ALLOC;
+ }
+
+ //copy file to memory
+ if (!ReadFile(File,(LPVOID)*MemFile,FileSize,&ReadBytes,NULL))
+ {
+ CloseHandle(File);
+ delete[] *MemFile;
+ return EACC_SYSTEM;
+ }
+ CloseHandle(File);
+ *End = *MemFile + FileSize;
+ return 0;
+}
+
+DWORD FileToMemory(TCHAR *FileName,char **MemFile,char **End)
+{
+ HANDLE hFile = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
+ return EACC_SYSTEM;
+
+ return PostFileToMemory(hFile, MemFile, End);
+}
+
+#if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES)
+DWORD ReadStringFromMemory(char **Parser,TCHAR *End,char **StoreTo,TCHAR *DebugString)
+{
+//This is the debug version of ReadStringFromMemory function. This version shows MessageBox where
+//read string is displayed
+ TCHAR *Dest,*Finder;
+ DWORD Size;
+ TCHAR Debug[65536];
+
+ Finder=*Parser;
+ while((*Finder!=(TCHAR)0) && (Finder<=End)) Finder++;
+ _stprintf(Debug,_T("%s: %s,length is %d, remaining %d chars"),DebugString,*Parser,Finder-*Parser,End-Finder);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+ if (Finder>=End)
+ return EACC_FILECOMPATIBILITY;
+ if (Size=Finder-*Parser)
+ {
+ if (NULL==(Dest=*StoreTo=new TCHAR[Size+1]))
+ return EACC_ALLOC;
+ for (;*Parser<=Finder;(*Parser)++,Dest++)
+ *Dest=**Parser;
+ }
+ else
+ {
+ *StoreTo=NULL;
+ (*Parser)++;
+ }
+ return 0;
+}
+#endif
+
+DWORD ReadStringFromMemory(char **Parser,char *End,char **StoreTo)
+{
+ char *Dest,*Finder;
+ DWORD Size;
+
+ Finder=*Parser;
+ while((*Finder!=(TCHAR)0) && (Finder<=End)) Finder++;
+ if (Finder>=End)
+ return EACC_FILECOMPATIBILITY;
+ if (Size=Finder-*Parser)
+ {
+ if (NULL==(Dest=*StoreTo=new char[Size+1]))
+ return EACC_ALLOC;
+ for (;*Parser<=Finder;(*Parser)++,Dest++)
+ *Dest=**Parser;
+ }
+ else
+ {
+ *StoreTo=NULL;
+ (*Parser)++;
+ }
+ return 0;
+}
+
+ #if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES)
+DWORD ReadStringFromMemoryW(WCHAR **Parser,TCHAR *End,WCHAR **StoreTo,WCHAR *DebugString)
+{
+//This is the debug version of ReadStringFromMemoryW function. This version shows MessageBox where
+//read string is displayed
+ WCHAR *Dest,*Finder;
+ DWORD Size;
+ WCHAR Debug[65536];
+
+ Finder=*Parser;
+ while((*Finder!=(WCHAR)0) && (Finder<=(WCHAR *)End)) Finder++;
+ swprintf(Debug,L"%s: %s,length is %d, remaining %d chars",DebugString,*Parser,Finder-*Parser,(WCHAR *)End-Finder);
+ MessageBoxW(NULL,Debug,L"debug",MB_OK);
+ if (Finder>=(WCHAR *)End)
+ return EACC_FILECOMPATIBILITY;
+ if (Size=Finder-*Parser)
+ {
+ if (NULL==(Dest=*StoreTo=new WCHAR[Size+1]))
+ return EACC_ALLOC;
+ for (;*Parser<=Finder;(*Parser)++,Dest++)
+ *Dest=**Parser;
+ }
+ else
+ {
+ *StoreTo=NULL;
+ (*Parser)++;
+ }
+ return 0;
+}
+ #endif //if defined(DEBUG...)
+
+DWORD ReadStringFromMemoryW(WCHAR **Parser,WCHAR *End,WCHAR **StoreTo)
+{
+ WCHAR *Dest,*Finder;
+ DWORD Size;
+
+ Finder=*Parser;
+ while((*Finder!=(WCHAR)0) && (Finder<=(WCHAR *)End)) Finder++;
+ if (Finder>=(WCHAR *)End)
+ return EACC_FILECOMPATIBILITY;
+ if (Size=Finder-*Parser)
+ {
+ if (NULL==(Dest=*StoreTo=new WCHAR[Size+1]))
+ return EACC_ALLOC;
+ for (;*Parser<=Finder;(*Parser)++,Dest++)
+ *Dest=**Parser;
+ }
+ else
+ {
+ *StoreTo=NULL;
+ (*Parser)++;
+ }
+ return 0;
+}
+
+static DWORD ReadNotificationFromMemory(char **Parser,char *End,YAMN_NOTIFICATION *Which)
+{
+ DWORD Stat;
+#ifdef DEBUG_FILEREAD
+ TCHAR Debug[65536];
+#endif
+
+ Which->Flags=*(DWORD *)(*Parser);
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("NFlags: %04x, remaining %d chars"),Which->Flags,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+
+ Which->PopUpB=*(COLORREF *)(*Parser);
+ (*Parser)+=sizeof(COLORREF);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("PopUpB: %04x, remaining %d chars"),Which->PopUpB,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+ Which->PopUpT=*(COLORREF *)(*Parser);
+ (*Parser)+=sizeof(COLORREF);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("PopUpT: %04x, remaining %d chars"),Which->PopUpT,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+ Which->PopUpTime=*(DWORD *)(*Parser);
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("PopUpTime: %04x, remaining %d chars"),Which->PopUpTime,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+
+#ifdef DEBUG_FILEREAD
+ if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->App,L"App"))
+#else
+ if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->App))
+#endif
+ return Stat;
+#ifdef DEBUG_FILEREAD
+ if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->AppParam,L"AppParam"))
+#else
+ if (Stat=ReadStringFromMemoryW((WCHAR **)Parser,(WCHAR*)End,&Which->AppParam))
+#endif
+ return Stat;
+ return 0;
+}
+
+DWORD ReadMessagesFromMemory(HACCOUNT Which,char **Parser,char *End)
+{
+ char *Finder;
+ DWORD Size,Stat;
+ HYAMNMAIL ActualMail=NULL;
+ struct CMimeItem *items;
+ char *ReadString;
+
+#ifdef DEBUG_FILEREAD
+ MessageBox(NULL,_T("going to read messages, if any..."),_T("debug"),MB_OK);
+#endif
+ do
+ {
+ Finder=*Parser;
+ while((*Finder!=(TCHAR)0) && (Finder<=End)) Finder++;
+ if (Finder>=End)
+ return EACC_FILECOMPATIBILITY;
+ if (Size=Finder-*Parser)
+ {
+ if (Which->Mails==NULL) //First message in queue
+ {
+ if (NULL==(Which->Mails=ActualMail=CreateAccountMail(Which)))
+ return EACC_ALLOC;
+ }
+ else
+ {
+ if (NULL==(ActualMail->Next=CreateAccountMail(Which))) {
+ return EACC_ALLOC;
+ }
+ ActualMail=ActualMail->Next;
+ }
+ items=NULL;
+#ifdef DEBUG_FILEREADMESSAGES
+ if (Stat=ReadStringFromMemory(Parser,End,&ActualMail->ID,_T("ID")))
+#else
+ if (Stat=ReadStringFromMemory(Parser,End,&ActualMail->ID))
+#endif
+ return Stat;
+// ActualMail->MailData=new MAILDATA; !!! mem leake !!! this is alloc by CreateAccountMail, no need for doubble alloc !!!!
+
+ ActualMail->MailData->Size=*(DWORD *)(*Parser);
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+ ActualMail->Flags=*(DWORD *)(*Parser);
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+ ActualMail->Number=*(DWORD *)(*Parser);
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+
+ if ((NULL!=Which->Plugin->MailFcn) && (NULL!=Which->Plugin->MailFcn->ReadMailOptsFcnPtr))
+ Which->Plugin->MailFcn->ReadMailOptsFcnPtr(ActualMail,Parser,End); //read plugin mail settings from file
+
+ do
+ {
+#if defined(DEBUG_FILEREADMESSAGES) || defined(DEBUG_FILEREAD)
+ if (Stat=ReadStringFromMemory(Parser,End,&ReadString,_T("Name")))
+#else
+ if (Stat=ReadStringFromMemory(Parser,End,&ReadString))
+#endif
+ return Stat;
+ if (ReadString==NULL)
+ break;
+
+#ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<read name>%s</read name>",ReadString);
+#endif
+
+ if (items==NULL)
+ items=ActualMail->MailData->TranslatedHeader=new struct CMimeItem;
+ else
+ {
+ items->Next=new struct CMimeItem;
+ items=items->Next;
+ }
+ if (items==NULL)
+ return EACC_ALLOC;
+ items->name=ReadString;
+
+#ifdef DEBUG_FILEREADMESSAGES
+ if (Stat=ReadStringFromMemory(Parser,End,&ReadString,_T("Value")))
+#else
+ if (Stat=ReadStringFromMemory(Parser,End,&ReadString))
+#endif
+ return Stat;
+ items->value=ReadString;
+#ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<read value>%s</read value>\n",ReadString);
+#endif
+ }while(1);
+ }
+ else
+ break; //no next messages, new account!
+
+ }while(1);
+ (*Parser)++;
+ return 0;
+}
+
+DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,char *End)
+{
+ DWORD Stat;
+#ifdef DEBUG_FILEREAD
+ TCHAR Debug[65536];
+#endif
+ //Read name of account
+
+#ifdef DEBUG_FILEREAD
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Name,_T("Name")))
+#else
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Name))
+#endif
+ return Stat;
+ if (Which->Name==NULL)
+ return EACC_FILECOMPATIBILITY;
+
+ //Read server parameters
+#ifdef DEBUG_FILEREAD
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Name,_T("Server")))
+#else
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Name))
+#endif
+ return Stat;
+ Which->Server->Port=*(WORD *)(*Parser);
+ (*Parser)+=sizeof(WORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("Port: %d, remaining %d chars"),Which->Server->Port,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+#ifdef DEBUG_FILEREAD
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Login,_T("Login")))
+#else
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Login))
+#endif
+ return Stat;
+#ifdef DEBUG_FILEREAD
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Passwd,_T("Password")))
+#else
+ if (Stat=ReadStringFromMemory(Parser,End,&Which->Server->Passwd))
+#endif
+ return Stat;
+ CodeDecodeString(Which->Server->Passwd,FALSE);
+
+ //Read account flags
+ Which->Flags=*(DWORD *)(*Parser);
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("Flags: %04x, remaining %d chars"),Which->Flags,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+ Which->StatusFlags=*(DWORD *)(*Parser);
+ (*Parser)+=sizeof(DWORD);
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("STFlags: %04x, remaining %d chars"),Which->StatusFlags,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+ Which->PluginFlags=*(DWORD *)(*Parser);
+ (*Parser)+=sizeof(DWORD);
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("PFlags: %04x, remaining %d chars"),Which->PluginFlags,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+
+ //Read account miscellaneous parameters
+ Which->Interval=*(WORD *)(*Parser);
+ Which->TimeLeft=Which->Interval; //check on loading
+ (*Parser)+=sizeof(WORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("Interval: %d, remaining %d chars"),Which->Interval,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+
+ //Read notification parameters
+ if (Stat=ReadNotificationFromMemory(Parser,End,&Which->NewMailN))
+ return Stat;
+ if (Stat=ReadNotificationFromMemory(Parser,End,&Which->NoNewMailN))
+ return Stat;
+ if (Stat=ReadNotificationFromMemory(Parser,End,&Which->BadConnectN))
+ return Stat;
+
+ //Let plugin read its own data stored in file
+ if (Which->Plugin->Fcn!=NULL && Which->Plugin->Fcn->ReadPluginOptsFcnPtr!=NULL)
+ if (Stat=Which->Plugin->Fcn->ReadPluginOptsFcnPtr(Which,Parser,End))
+ return Stat;
+ //Read mails
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write wait\n");
+#endif
+ WaitToWriteFcn(Which->MessagesAccessSO);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write enter\n");
+#endif
+ if (Stat=ReadMessagesFromMemory(Which,Parser,End))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write done\n");
+#endif
+ WriteDoneFcn(Which->MessagesAccessSO);
+ return Stat;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"ReadAccountFromMemory:ActualAccountMsgsSO-write done\n");
+#endif
+ WriteDoneFcn(Which->MessagesAccessSO);
+
+ //Read timestamps
+ Which->LastChecked=*(SYSTEMTIME *)(*Parser);
+ (*Parser)+=sizeof(SYSTEMTIME);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("LastChecked: %04x, remaining %d chars"),Which->LastChecked,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+ Which->LastSChecked=*(SYSTEMTIME *)(*Parser);
+ (*Parser)+=sizeof(SYSTEMTIME);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("LastSChecked: %04x, remaining %d chars"),Which->LastSChecked,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+ Which->LastSynchronised=*(SYSTEMTIME *)(*Parser);
+ (*Parser)+=sizeof(SYSTEMTIME);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("LastSynchronised: %04x, remaining %d chars"),Which->LastSynchronised,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+ Which->LastMail=*(SYSTEMTIME *)(*Parser);
+ (*Parser)+=sizeof(SYSTEMTIME);
+ if (*Parser>End) //WARNING! There's only > at the end of testing
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("LastMail: %04x, remaining %d chars"),Which->LastMail,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+ if (*Parser==End)
+ return EACC_ENDOFFILE;
+ return 0;
+
+}
+
+static INT_PTR PerformAccountReading(HYAMNPROTOPLUGIN Plugin,char *MemFile,char *End)
+{
+ //Retrieve info for account from memory
+ char *Parser;
+ DWORD Ver,Stat;
+
+ HACCOUNT ActualAccount,FirstAllocatedAccount;
+
+ Ver=*(DWORD *)MemFile;
+ if (Ver>YAMN_ACCOUNTFILEVERSION)
+ {
+ delete[] MemFile;
+ return EACC_FILEVERSION;
+ }
+ Parser=MemFile+sizeof(Ver);
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write wait\n");
+#endif
+ SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write enter\n");
+#endif
+ if (NULL==(ActualAccount=(HACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT,(WPARAM)Plugin,(LPARAM)YAMN_ACCOUNTVERSION)))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n");
+#endif
+ SWMRGDoneWriting(Plugin->AccountBrowserSO);
+ delete[] MemFile;
+ return EACC_ALLOC;
+ }
+ FirstAllocatedAccount=ActualAccount;
+
+ do
+ {
+ HACCOUNT Temp;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write wait\n");
+#endif
+ WaitToWriteFcn(ActualAccount->AccountAccessSO);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write enter\n");
+#endif
+ Stat=ReadAccountFromMemory(ActualAccount,&Parser,End);
+
+ if (ActualAccount->StatusFlags & (YAMN_ACC_STARTA | YAMN_ACC_STARTS))
+ ActualAccount->TimeLeft=1; //check on loading
+
+ if (Stat && (Stat!=EACC_ENDOFFILE))
+ {
+ for (ActualAccount=FirstAllocatedAccount;ActualAccount!=NULL;ActualAccount=Temp)
+ {
+ Temp=ActualAccount->Next;
+ delete ActualAccount;
+ }
+ delete[] MemFile;
+ if (Plugin->FirstAccount==FirstAllocatedAccount)
+ Plugin->FirstAccount=NULL;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write done\n");
+#endif
+ SWMRGDoneWriting(Plugin->AccountBrowserSO);
+ return (INT_PTR)Stat;
+ }
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"AddAccountsFromFile:ActualAccountSO-write done\n");
+#endif
+ WriteDoneFcn(ActualAccount->AccountAccessSO);
+
+ if ((Stat!=EACC_ENDOFFILE) && (NULL==(ActualAccount=(HACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT,(WPARAM)Plugin,(LPARAM)YAMN_ACCOUNTVERSION))))
+ {
+ for (ActualAccount=FirstAllocatedAccount;ActualAccount!=NULL;ActualAccount=Temp)
+ {
+ Temp=ActualAccount->Next;
+ delete ActualAccount;
+ }
+ delete[] MemFile;
+ if (Plugin->FirstAccount==FirstAllocatedAccount)
+ Plugin->FirstAccount=NULL;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n");
+#endif
+ SWMRGDoneWriting(Plugin->AccountBrowserSO);
+ return EACC_ALLOC;
+ }
+ }while(Stat!=EACC_ENDOFFILE);
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"AddAccountsFromFile:AccountBrowserSO-write done\n");
+#endif
+ SWMRGDoneWriting(Plugin->AccountBrowserSO);
+ delete[] MemFile;
+
+ return 0;
+}
+
+// Add accounts from file to memory
+INT_PTR AddAccountsFromFileSvc(WPARAM wParam,LPARAM lParam)
+{
+ char *MemFile,*End;
+ DWORD Stat = FileToMemory(( TCHAR* )lParam, &MemFile, &End);
+ if ( Stat != NO_ERROR )
+ return (INT_PTR)Stat;
+
+ return PerformAccountReading((HYAMNPROTOPLUGIN)wParam,MemFile,End);
+}
+
+DWORD WriteStringToFile(HANDLE File,char *Source)
+{
+ DWORD Length,WrittenBytes;
+ char null = 0;
+
+ if ((Source==NULL) || !(Length=(DWORD)strlen(Source))) {
+ if (!WriteFile(File,&null,1,&WrittenBytes,NULL)) {
+ CloseHandle(File);
+ return EACC_SYSTEM;
+ }
+ }
+ else if (!WriteFile(File,Source,(Length+1),&WrittenBytes,NULL)) {
+ CloseHandle(File);
+ return EACC_SYSTEM;
+ }
+ return 0;
+}
+
+DWORD WriteStringToFileW(HANDLE File,WCHAR *Source)
+{
+ DWORD Length,WrittenBytes;
+ WCHAR null=(WCHAR)0;
+
+ if ((Source==NULL) || !(Length=(DWORD)wcslen(Source)))
+ {
+ if (!WriteFile(File,&null,sizeof(WCHAR),&WrittenBytes,NULL))
+ {
+ CloseHandle(File);
+ return EACC_SYSTEM;
+ }
+ }
+ else if (!WriteFile(File,Source,(Length+1)*sizeof(WCHAR),&WrittenBytes,NULL))
+ return EACC_SYSTEM;
+ return 0;
+}
+
+DWORD WriteMessagesToFile(HANDLE File,HACCOUNT Which)
+{
+ DWORD WrittenBytes,Stat;
+ HYAMNMAIL ActualMail=(HYAMNMAIL)Which->Mails;
+ struct CMimeItem *items;
+
+ while(ActualMail!=NULL)
+ {
+ if (Stat=WriteStringToFile(File,ActualMail->ID))
+ return Stat;
+ if (!WriteFile(File,(char *)&ActualMail->MailData->Size,sizeof(ActualMail->MailData->Size),&WrittenBytes,NULL) ||
+ !WriteFile(File,(char *)&ActualMail->Flags,sizeof(ActualMail->Flags),&WrittenBytes,NULL) ||
+ !WriteFile(File,(char *)&ActualMail->Number,sizeof(ActualMail->Number),&WrittenBytes,NULL))
+ return EACC_SYSTEM;
+ if ((NULL!=Which->Plugin->MailFcn) && (NULL!=Which->Plugin->MailFcn->WriteMailOptsFcnPtr))
+ Which->Plugin->MailFcn->WriteMailOptsFcnPtr(File,ActualMail); //write plugin mail options to file
+ for (items=ActualMail->MailData->TranslatedHeader;items!=NULL;items=items->Next)
+ {
+ if (Stat=WriteStringToFile(File,items->name))
+ return Stat;
+ if (Stat=WriteStringToFile(File,items->value))
+ return Stat;
+ }
+ if (Stat=WriteStringToFile(File,""))
+ return Stat;
+ ActualMail=ActualMail->Next;
+ }
+ if (Stat=WriteStringToFile(File,""))
+ return Stat;
+ return 0;
+}
+
+static INT_PTR PerformAccountWriting(HYAMNPROTOPLUGIN Plugin,HANDLE File)
+{
+ DWORD WrittenBytes,Stat;
+ HACCOUNT ActualAccount;
+ DWORD Ver=YAMN_ACCOUNTFILEVERSION;
+ BOOL Writed=FALSE;
+ DWORD ReturnValue=0,EnterCode;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:AccountBrowserSO-read wait\n");
+#endif
+ SWMRGWaitToRead(Plugin->AccountBrowserSO,INFINITE);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:AccountBrowserSO-read enter\n");
+#endif
+ try
+ {
+ for (ActualAccount=Plugin->FirstAccount;ActualAccount!=NULL;ActualAccount=ActualAccount->Next)
+ {
+/* TCHAR DEBUG[100];
+ Beep(3000,100);Sleep(200);
+ _stprintf(DEBUG,_T("Browsing account %s"),ActualAccount->Name==NULL ? _T("(null)") : ActualAccount->Name);
+ MessageBox(NULL,DEBUG,_T("debug- WriteAccount..."),MB_OK);
+*/
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read wait\n");
+#endif
+ EnterCode=WaitToReadFcn(ActualAccount->AccountAccessSO);
+ if (EnterCode==WAIT_FINISH) //account is about to delete
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read wait failed\n");
+#endif
+ ActualAccount=ActualAccount->Next;
+ continue;
+ }
+ if (EnterCode==WAIT_FAILED) //account is deleted
+ break;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read enter\n");
+#endif
+ if ((ActualAccount->Name==NULL) || (*ActualAccount->Name==(TCHAR)0))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read done\n");
+#endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ continue;
+ }
+
+ if (!Writed && !WriteFile(File,&Ver,sizeof(Ver),&WrittenBytes,NULL))
+ throw (DWORD)EACC_SYSTEM;
+ Writed=TRUE;
+
+ if (Stat=WriteStringToFile(File,ActualAccount->Name))
+ throw (DWORD)Stat;
+
+ if (Stat=WriteStringToFile(File,ActualAccount->Server->Name))
+ throw (DWORD)Stat;
+
+ if (!WriteFile(File,(char *)&ActualAccount->Server->Port,2,&WrittenBytes,NULL))
+ throw (DWORD)EACC_SYSTEM;
+
+ if ((Stat=WriteStringToFile(File,ActualAccount->Server->Login)))
+ throw (DWORD)Stat;
+
+ CodeDecodeString(ActualAccount->Server->Passwd,TRUE);
+
+ if (Stat=WriteStringToFile(File,ActualAccount->Server->Passwd))
+ {
+ CodeDecodeString(ActualAccount->Server->Passwd,FALSE);
+ throw (DWORD)Stat;
+ }
+ CodeDecodeString(ActualAccount->Server->Passwd,FALSE);
+
+ if ((!WriteFile(File,(char *)&ActualAccount->Flags,sizeof(DWORD),&WrittenBytes,NULL) ||
+ (!WriteFile(File,(char *)&ActualAccount->StatusFlags,sizeof(DWORD),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->PluginFlags,sizeof(DWORD),&WrittenBytes,NULL))))
+ throw (DWORD)EACC_SYSTEM;
+
+ if (!WriteFile(File,(char *)&ActualAccount->Interval,sizeof(WORD),&WrittenBytes,NULL))
+ throw (DWORD)EACC_SYSTEM;
+
+ if ((!WriteFile(File,(char *)&ActualAccount->NewMailN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->NewMailN.PopUpB,sizeof(COLORREF),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->NewMailN.PopUpT,sizeof(COLORREF),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->NewMailN.PopUpTime,sizeof(DWORD),&WrittenBytes,NULL)))
+ throw (DWORD)EACC_SYSTEM;
+
+ if ((Stat=WriteStringToFileW(File,ActualAccount->NewMailN.App)) ||
+ (Stat=WriteStringToFileW(File,ActualAccount->NewMailN.AppParam)))
+ throw (DWORD)Stat;
+
+ if ((!WriteFile(File,(char *)&ActualAccount->NoNewMailN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->NoNewMailN.PopUpB,sizeof(COLORREF),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->NoNewMailN.PopUpT,sizeof(COLORREF),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->NoNewMailN.PopUpTime,sizeof(DWORD),&WrittenBytes,NULL)))
+ throw (DWORD)EACC_SYSTEM;
+
+ if ((Stat=WriteStringToFileW(File,ActualAccount->NoNewMailN.App)) ||
+ (Stat=WriteStringToFileW(File,ActualAccount->NoNewMailN.AppParam)))
+ throw (DWORD)Stat;
+
+ if ((!WriteFile(File,(char *)&ActualAccount->BadConnectN.Flags,sizeof(DWORD),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->BadConnectN.PopUpB,sizeof(COLORREF),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->BadConnectN.PopUpT,sizeof(COLORREF),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->BadConnectN.PopUpTime,sizeof(DWORD),&WrittenBytes,NULL)))
+ throw (DWORD)EACC_SYSTEM;
+
+ if ((Stat=WriteStringToFileW(File,ActualAccount->BadConnectN.App)) ||
+ (Stat=WriteStringToFileW(File,ActualAccount->BadConnectN.AppParam)))
+ throw (DWORD)Stat;
+
+//Let plugin write its own values into file
+ if (ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->WritePluginOptsFcnPtr!=NULL)
+ if (Stat=ActualAccount->Plugin->Fcn->WritePluginOptsFcnPtr(File,ActualAccount))
+ throw (DWORD)Stat;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read wait\n");
+#endif
+ WaitToReadFcn(ActualAccount->MessagesAccessSO);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read enter\n");
+#endif
+ if (Stat=WriteMessagesToFile(File,ActualAccount))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read done\n");
+#endif
+ ReadDoneFcn(ActualAccount->MessagesAccessSO);
+ throw (DWORD)Stat;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountMsgsSO-read done\n");
+#endif
+ ReadDoneFcn(ActualAccount->MessagesAccessSO);
+
+ if ((!WriteFile(File,(char *)&ActualAccount->LastChecked,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->LastSChecked,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->LastSynchronised,sizeof(SYSTEMTIME),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&ActualAccount->LastMail,sizeof(SYSTEMTIME),&WrittenBytes,NULL)))
+ throw (DWORD)Stat;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read done\n");
+#endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+ }
+ catch(DWORD ErrorCode)
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:ActualAccountSO-read done\n");
+#endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ ReturnValue=ErrorCode;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WriteAccountsToFile:AccountBrowserSO-read done\n");
+#endif
+ SWMRGDoneReading(Plugin->AccountBrowserSO);
+ CloseHandle(File);
+ return 0;
+}
+
+//Writes accounts to file
+INT_PTR WriteAccountsToFileSvc(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNPROTOPLUGIN Plugin = ( HYAMNPROTOPLUGIN )wParam;
+ TCHAR* tszFileName = ( TCHAR* )lParam;
+
+ EnterCriticalSection( &FileWritingCS );
+ HANDLE hFile = CreateFile(tszFileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
+ if ( hFile == INVALID_HANDLE_VALUE ) {
+ LeaveCriticalSection(&FileWritingCS);
+ return EACC_SYSTEM;
+ }
+
+ INT_PTR rv = PerformAccountWriting(Plugin, hFile);
+ LeaveCriticalSection(&FileWritingCS);
+
+ return rv;
+}
+
+INT_PTR FindAccountByNameSvc(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
+ char *SearchedAccount=(char *)lParam;
+ HACCOUNT Finder;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"FindAccountByName:AccountBrowserSO-read wait\n");
+#endif
+ SWMRGWaitToRead(Plugin->AccountBrowserSO,INFINITE);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"FindAccountByName:AccountBrowserSO-read enter\n");
+#endif
+ for (Finder=Plugin->FirstAccount;Finder!=NULL;Finder=Finder->Next)
+ if ((Finder->Name!=NULL) && (0 == strcmp(SearchedAccount,Finder->Name)))
+ break;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"FindAccountByName:AccountBrowserSO-read done\n");
+#endif
+ SWMRGDoneReading(Plugin->AccountBrowserSO);
+ return (INT_PTR)Finder;
+}
+
+INT_PTR GetNextFreeAccountSvc(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
+ HACCOUNT Finder;
+
+ if (Plugin->FirstAccount==NULL)
+ {
+ Plugin->FirstAccount=(HACCOUNT)CallService(MS_YAMN_CREATEPLUGINACCOUNT,wParam,lParam);
+ return (INT_PTR)Plugin->FirstAccount;
+ }
+ for (Finder=Plugin->FirstAccount;Finder->Next!=NULL;Finder=Finder->Next);
+ Finder->Next=(HACCOUNT)CallService(MS_YAMN_CREATEPLUGINACCOUNT,wParam,lParam);
+ return (INT_PTR)Finder->Next;
+}
+
+/*
+int FindPluginAccount(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
+ HACCOUNT Finder=(HACCOUNT)lParam;
+
+ if (Finder=NULL) Finder=Plugin->FirstAccount;
+
+// for (;Finder!=NULL && Finder->PluginID!=Plugin->PluginInfo->PluginID;Finder=(HACCOUNT)Finder->Next);
+ return (int)Finder;
+}
+*/
+INT_PTR DeleteAccountSvc(WPARAM wParam,LPARAM lParam)
+{
+//Deleting account works on these steps:
+//1. set signal that account should stop activity (set event)
+// setting this event we achieve, that any access to account is failed,
+// so threads do not start any work with accounts (better saying threads of plugins should not start)
+//2. wait to get write access to chained list of accounts
+//3. we can write to chained list, so we change chain not to show to actual account
+// now, any thread browsing list of accounts does not browse through actual account
+// actual account seems to be hidden (it exists, but it is not in accounts chained list (chained list=queue))
+//Now, we should delete account from memory, BUT!!!
+// Any thread can still be waked up and start asking account synchronizing object
+// If account is deleted, asking about access to read account can throw memory exception (reading for
+// a synchronizing object from memory, that was deleted)
+//So, we cannot now delete account. We have to wait until we are sure no thread will be using account anymore
+// (or to the end of Miranda, but problem is in allocated memory- it is allocated and Miranda is SMALLER, faster, easier, isn't it?)
+// This deleting is achieved in 2 ways:
+// We have event in UsingThreads synchronization objects. This event signals that no thread will use actual account
+// 1. Any thread using account first increment UsingThread, so we know that account is used
+// 2. If thread is about to close, it should decrement UsingThread
+// 3. If thread creates another thread, that will use account, caller has to wait until the new thread does not
+// increment UsingThreads (imagine that caller ends before the new thread set it: if no other thread is using
+// account, account is automaticaly (decreasing UsingThreads) signaled as "not used" and we delete it. But then
+// new thread is going to read account...).
+//4. wait until UsingThread Event is signaled
+//5. delete account from memory
+
+ HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
+ HACCOUNT Which=(HACCOUNT)lParam;
+ HACCOUNT Finder;
+ DWORD tid;
+
+//1. set stop signal
+ StopSignalFcn(Which);
+ WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_STOPACCOUNT,(WPARAM)Which,0);
+ if (Plugin->Fcn->StopAccountFcnPtr!=NULL)
+ Plugin->Fcn->StopAccountFcnPtr(Which);
+
+//2. wait to get write access
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteAccount:AccountBrowserSO-write wait\n");
+#endif
+ SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteAccount:AccountBrowserSO-write enter\n");
+#endif
+
+//3. remove from queue (chained list)
+ if (Plugin->FirstAccount==NULL)
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteAccount:AccountBrowserSO-write done\n");
+#endif
+ SWMRGDoneWriting(Plugin->AccountBrowserSO);
+ return 0;
+ }
+ if (Plugin->FirstAccount==Which)
+ {
+ Finder=Plugin->FirstAccount->Next;
+ Plugin->FirstAccount=Finder;
+ }
+ else
+ {
+ for (Finder=Plugin->FirstAccount;Which!=Finder->Next;Finder=Finder->Next);
+ Finder->Next=Finder->Next->Next;
+ }
+//leave write access
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteAccount:AccountBrowserSO-write done\n");
+#endif
+ SWMRGDoneWriting(Plugin->AccountBrowserSO);
+
+//4. wait while event "UsingThread" is not signaled
+// And what to do, if this event will be signaled in 1 hour? (Although it's paranoia, because we have sent "delete signal", so
+// other threads do not start any new work with actual account) We will wait in blocked state?
+// No, of course not. We will create new thread, that will wait and additionally remove our thread in background.
+//5. So, the last point (deleting from memory) is performed in new DeleteAccountInBackground thread
+
+ if ((Plugin->Fcn!=NULL) && (Plugin->Fcn->WriteAccountsFcnPtr!=NULL))
+ Plugin->Fcn->WriteAccountsFcnPtr();
+ CloseHandle(CreateThread(NULL,0,DeleteAccountInBackground,(LPVOID)Which,0,&tid));
+
+//Now, plugin can consider account as deleted, but plugin really can achieve deleting this account from memory when using
+//event UsingThreads.
+ return 1;
+}
+
+DWORD WINAPI DeleteAccountInBackground(LPVOID Value)
+{
+ HACCOUNT Which=(HACCOUNT)Value;
+ WaitForSingleObject(Which->UsingThreads->Event,INFINITE);
+ CallService(MS_YAMN_DELETEPLUGINACCOUNT,(WPARAM)Which,0);
+ return 0;
+}
+
+int StopAccounts(HYAMNPROTOPLUGIN Plugin)
+{
+ HACCOUNT Finder;
+
+//1. wait to get write access
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"StopAccounts:AccountBrowserSO-write wait\n");
+#endif
+ SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"StopAccounts:AccountBrowserSO-write enter\n");
+#endif
+ for (Finder=Plugin->FirstAccount;Finder!=NULL;Finder=Finder->Next)
+ {
+//2. set stop signal
+ StopSignalFcn(Finder);
+ WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_STOPACCOUNT,(WPARAM)Finder,0);
+ if (Plugin->Fcn->StopAccountFcnPtr!=NULL)
+ Plugin->Fcn->StopAccountFcnPtr(Finder);
+ }
+
+//leave write access
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"StopAccounts:AccountBrowserSO-write done\n");
+#endif
+ SWMRGDoneWriting(Plugin->AccountBrowserSO);
+
+//Now, account is stopped. It can be removed from memory...
+ return 1;
+}
+
+int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin,BOOL GetAccountBrowserAccess)
+{
+ HACCOUNT Finder;
+
+ if (GetAccountBrowserAccess)
+ {
+//1. wait to get write access
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WaitForAllAccounts:AccountBrowserSO-write wait\n");
+#endif
+ SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WaitForAllAccounts:AccountBrowserSO-write enter\n");
+#endif
+ }
+ for (Finder=Plugin->FirstAccount;Finder!=NULL;Finder=Finder->Next)
+ {
+//2. wait for signal that account is not in use
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WaitForAllAccounts:waiting for UsingThreadEV %x (account %x)\n",Finder->UsingThreads,Finder);
+#endif
+ WaitForSingleObject(Finder->UsingThreads->Event,INFINITE);
+ SetEvent(Finder->UsingThreads->Event);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WaitForAllAccounts:UsingThreadEV signaled\n");
+#endif
+ }
+ if (GetAccountBrowserAccess)
+ {
+//leave write access
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"WaitForAllAccounts:AccountBrowserSO-write done\n");
+#endif
+ SWMRGDoneWriting(Plugin->AccountBrowserSO);
+ }
+
+ return 1;
+}
+
+int DeleteAccounts(HYAMNPROTOPLUGIN Plugin)
+{
+ HACCOUNT Finder;
+
+ //1. wait to get write access
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteAccounts:AccountBrowserSO-write wait\n");
+ #endif
+ SWMRGWaitToWrite(Plugin->AccountBrowserSO,INFINITE);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteAccounts:AccountBrowserSO-write enter\n");
+ #endif
+
+ WaitForAllAccounts(Plugin,FALSE);
+
+ for (Finder=Plugin->FirstAccount;Finder!=NULL;)
+ {
+ HACCOUNT Next = Finder->Next;
+ DeletePluginAccountSvc((WPARAM)Finder,0);
+ Finder = Next;
+ }
+
+ //leave write access
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteAccounts:AccountBrowserSO-write done\n");
+ #endif
+ SWMRGDoneWriting(Plugin->AccountBrowserSO);
+
+ return 1;
+}
+
+void WINAPI GetStatusFcn(HACCOUNT Which,TCHAR *Value)
+{
+ if (Which==NULL)
+ return;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs wait\n");
+#endif
+ EnterCriticalSection(&AccountStatusCS);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs enter\n");
+#endif
+ lstrcpy(Value,Which->Status);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tGetStatus:AccountStatusCS-cs done\n");
+#endif
+ LeaveCriticalSection(&AccountStatusCS);
+ return;
+}
+
+void WINAPI SetStatusFcn(HACCOUNT Which,TCHAR *Value)
+{
+ if (Which==NULL)
+ return;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs wait\n");
+#endif
+ EnterCriticalSection(&AccountStatusCS);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs enter\n");
+#endif
+ lstrcpy(Which->Status,Value);
+ WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_CHANGESTATUS,(WPARAM)Which,0);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tSetStatus:AccountStatusCS-cs done\n");
+#endif
+ LeaveCriticalSection(&AccountStatusCS);
+}
+
+/*
+#ifdef DEBUG_ACCOUNTS
+int GetAccounts()
+{
+ HACCOUNT Finder;
+ int cnt=0;
+
+ for (Finder=Account;Finder!=NULL;Finder=Finder->Next)
+ cnt++;
+ return cnt;
+}
+
+void WriteAccounts()
+{
+ HACCOUNT Finder;
+
+ for (Finder=Account;Finder!=NULL;Finder=Finder->Next)
+ MessageBoxA(NULL,Finder->Name,"Browsing account",MB_OK);
+}
+#endif
+*/
diff --git a/plugins/YAMN/src/browser/badconnect.cpp b/plugins/YAMN/src/browser/badconnect.cpp new file mode 100644 index 0000000000..6f11151ee3 --- /dev/null +++ b/plugins/YAMN/src/browser/badconnect.cpp @@ -0,0 +1,345 @@ +/*
+ * This code implements window handling (connection error)
+ *
+ * (c) majvan 2002,2004
+ */
+
+#include "../yamn.h"
+#include "../main.h"
+
+#define BADCONNECTTITLE "%s - connection error"
+#define BADCONNECTMSG "An error occured. Error code: %d"
+
+//--------------------------------------------------------------------------------------------------
+
+LRESULT CALLBACK BadConnectPopUpProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ DWORD PluginParam;
+ switch(msg)
+ {
+ case WM_COMMAND:
+ if ((HIWORD(wParam)==STN_CLICKED) && (CallService(MS_POPUP_GETPLUGINDATA,(WPARAM)hWnd,(LPARAM)&PluginParam))) //if clicked and it's new mail popup window
+ {
+ PROCESS_INFORMATION pi;
+ STARTUPINFOW si;
+ HACCOUNT ActualAccount;
+
+ ZeroMemory(&si,sizeof(si));
+ si.cb=sizeof(si);
+ ActualAccount=(HACCOUNT)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read wait\n");
+#endif
+ if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read enter\n");
+#endif
+ if (ActualAccount->BadConnectN.App!=NULL)
+ {
+ WCHAR *Command;
+ if (ActualAccount->BadConnectN.AppParam!=NULL)
+ Command=new WCHAR[wcslen(ActualAccount->BadConnectN.App)+wcslen(ActualAccount->BadConnectN.AppParam)+6];
+ else
+ Command=new WCHAR[wcslen(ActualAccount->BadConnectN.App)+6];
+
+ if (Command!=NULL)
+ {
+ lstrcpyW(Command,L"\"");
+ lstrcatW(Command,ActualAccount->BadConnectN.App);
+ lstrcatW(Command,L"\" ");
+ if (ActualAccount->BadConnectN.AppParam!=NULL)
+ lstrcatW(Command,ActualAccount->BadConnectN.AppParam);
+ CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi);
+ delete[] Command;
+ }
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read done\n");
+#endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+#ifdef DEBUG_SYNCHRO
+ else
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read enter failed\n");
+#endif
+ SendMessage(hWnd,UM_DESTROYPOPUP,0,0);
+ }
+ break;
+ case UM_FREEPLUGINDATA:
+ //Here we'd free our own data, if we had it.
+ return FALSE;
+ case UM_INITPOPUP:
+ //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups.
+ break;
+ case WM_CONTEXTMENU:
+ SendMessage(hWnd,UM_DESTROYPOPUP,0,0);
+ break;
+ case WM_NOTIFY:
+/* switch(((LPNMHDR)lParam)->code)
+ {
+ case NM_CLICK:
+ {
+ }
+ }
+ break;
+*/ default:
+ break;
+ }
+ return DefWindowProc(hWnd,msg,wParam,lParam);
+}
+
+INT_PTR CALLBACK DlgProcYAMNBadConnection(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ BOOL ShowPopUp,ShowMsg,ShowIco;
+ HACCOUNT ActualAccount;
+ DWORD ErrorCode;
+ char* TitleStrA;
+ char *Message1A=NULL;
+ TCHAR *Message1W=NULL;
+ POPUPDATAT BadConnectPopUp;
+
+ ActualAccount=((struct BadConnectionParam *)lParam)->account;
+ ErrorCode=((struct BadConnectionParam *)lParam)->errcode;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait\n");
+#endif
+ if (WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait failed\n");
+#endif
+ return FALSE;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read enter\n");
+#endif
+ TitleStrA = new char[strlen(ActualAccount->Name)+strlen(Translate(BADCONNECTTITLE))];
+ wsprintfA(TitleStrA,Translate(BADCONNECTTITLE),ActualAccount->Name);
+
+ ShowPopUp=ActualAccount->BadConnectN.Flags & YAMN_ACC_POP;
+ ShowMsg=ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG;
+ ShowIco=ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO;
+
+ if (ShowPopUp)
+ {
+ BadConnectPopUp.lchContact=ActualAccount;
+ BadConnectPopUp.lchIcon=g_LoadIconEx(3);
+ BadConnectPopUp.colorBack=ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopUpB : GetSysColor(COLOR_BTNFACE);
+ BadConnectPopUp.colorText=ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? ActualAccount->BadConnectN.PopUpT : GetSysColor(COLOR_WINDOWTEXT);
+ BadConnectPopUp.iSeconds=ActualAccount->BadConnectN.PopUpTime;
+
+ BadConnectPopUp.PluginWindowProc=BadConnectPopUpProc;
+ BadConnectPopUp.PluginData=0; //it's bad connect popup
+ lstrcpyn(BadConnectPopUp.lptzContactName,_A2T(ActualAccount->Name),SIZEOF(BadConnectPopUp.lptzContactName));
+ }
+
+ if (ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr!=NULL)
+ {
+ Message1W=ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
+ SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
+ lstrcpyn(BadConnectPopUp.lptzText,Message1W,sizeof(BadConnectPopUp.lptzText));
+ if (ShowPopUp)
+ PUAddPopUpT(&BadConnectPopUp);
+ }
+ else if (ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->GetErrorStringAFcnPtr!=NULL)
+ {
+ Message1W=ActualAccount->Plugin->Fcn->GetErrorStringWFcnPtr(ErrorCode);
+ SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
+ lstrcpyn(BadConnectPopUp.lptzText,Message1W,sizeof(BadConnectPopUp.lptzText));
+ if (ShowPopUp)
+ PUAddPopUpT(&BadConnectPopUp);
+ }
+ else
+ {
+ Message1W=TranslateT("Unknown error");
+ SetDlgItemText(hDlg,IDC_STATICMSG,Message1W);
+ lstrcpyn(BadConnectPopUp.lptzText,Message1W,sizeof(BadConnectPopUp.lptzText));
+ if (ShowPopUp)
+ PUAddPopUpT(&BadConnectPopUp);
+ }
+
+ if (!ShowMsg && !ShowIco)
+ DestroyWindow(hDlg);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read done\n");
+#endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+
+ SetWindowTextA(hDlg, TitleStrA);
+ delete[] TitleStrA;
+ if (Message1A!=NULL)
+ delete[] Message1A;
+ if (ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr!=NULL && Message1A!=NULL)
+ ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1A);
+ if (ActualAccount->Plugin->Fcn!=NULL && ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr!=NULL && Message1W!=NULL)
+ ActualAccount->Plugin->Fcn->DeleteErrorStringFcnPtr(Message1W);
+ return 0;
+ }
+ case WM_DESTROY:
+ {
+ NOTIFYICONDATA nid;
+
+ ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
+ nid.cbSize=sizeof(NOTIFYICONDATA);
+ nid.hWnd=hDlg;
+ nid.uID=0;
+ Shell_NotifyIcon(NIM_DELETE,&nid);
+ PostQuitMessage(0);
+ break;
+ }
+ case WM_YAMN_NOTIFYICON:
+ switch (lParam)
+ {
+ case WM_LBUTTONDBLCLK:
+ ShowWindow(hDlg,SW_SHOWNORMAL);
+ SetForegroundWindow(hDlg);
+ break;
+ }
+ return 0;
+ case WM_CHAR:
+ switch((TCHAR)wParam)
+ {
+ case 27:
+ case 13:
+ DestroyWindow(hDlg);
+ break;
+ }
+ break;
+ case WM_SYSCOMMAND:
+ switch(wParam)
+ {
+ case SC_CLOSE:
+ DestroyWindow(hDlg);
+ break;
+ }
+ case WM_COMMAND:
+ {
+ WORD wNotifyCode = HIWORD(wParam);
+ switch(LOWORD(wParam))
+ {
+ case IDC_BTNOK:
+ DestroyWindow(hDlg);
+ break;
+ }
+ break;
+ }
+ }
+ return 0;
+}
+
+DWORD WINAPI BadConnection(LPVOID Param)
+{
+ MSG msg;
+ HWND hBadConnect;
+ HACCOUNT ActualAccount;
+ struct BadConnectionParam MyParam;
+ NOTIFYICONDATA nid;
+ char *NotIconText = Translate(" - connection error"), *src;
+ TCHAR *dest;
+ int i;
+
+ MyParam=*(struct BadConnectionParam *)Param;
+ ActualAccount=MyParam.account;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+#endif
+ SCIncFcn(ActualAccount->UsingThreads);
+
+// we will not use params in stack anymore
+ SetEvent(MyParam.ThreadRunningEV);
+
+ __try
+ {
+ hBadConnect=CreateDialogParam(YAMNVar.hInst,MAKEINTRESOURCE(IDD_DLGBADCONNECT),NULL,DlgProcYAMNBadConnection,(LPARAM)&MyParam);
+ SendMessage(hBadConnect,WM_SETICON,ICON_BIG,(LPARAM)g_LoadIconEx(3));
+ SendMessage(hBadConnect,WM_SETICON,ICON_SMALL,(LPARAM)g_LoadIconEx(3));
+
+ ZeroMemory(&nid,sizeof(nid));
+ nid.cbSize=sizeof(NOTIFYICONDATA);
+ nid.hWnd=hBadConnect;
+ nid.hIcon=g_LoadIconEx(3);
+ nid.uID=0;
+ nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
+ nid.uCallbackMessage=WM_YAMN_NOTIFYICON;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait\n");
+#endif
+ if (WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait failed\n");
+#endif
+ return 0;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read enter\n");
+#endif
+ for (src=ActualAccount->Name,dest=nid.szTip,i=0;(*src!=(TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
+ for (src=NotIconText;(*src!=(TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
+ *dest=(TCHAR)0;
+
+ if (ActualAccount->BadConnectN.Flags & YAMN_ACC_SND)
+ CallService(MS_SKIN_PLAYSOUND,0,(LPARAM)YAMN_CONNECTFAILSOUND);
+ if (ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG)
+ ShowWindow(hBadConnect,SW_SHOWNORMAL);
+ if (ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO)
+ Shell_NotifyIcon(NIM_ADD,&nid);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read done\n");
+#endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+
+ UpdateWindow(hBadConnect);
+ while(GetMessage(&msg,NULL,0,0))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+// now, write to file. Why? Because we want to write when was new mail last checked
+ if ((ActualAccount->Plugin->Fcn!=NULL) && (ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr!=NULL) && ActualAccount->AbleToWork)
+ ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr();
+ }
+ __finally
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"BadConnect:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+#endif
+ SCDecFcn(ActualAccount->UsingThreads);
+ }
+ return 0;
+}
+
+
+INT_PTR RunBadConnectionSvc(WPARAM wParam,LPARAM lParam)
+{
+ DWORD tid;
+//an event for successfull copy parameters to which point a pointer in stack for new thread
+ HANDLE ThreadRunningEV;
+ PYAMN_BADCONNECTIONPARAM Param=(PYAMN_BADCONNECTIONPARAM)wParam;
+
+ if ((DWORD)lParam!=YAMN_BADCONNECTIONVERSION)
+ return 0;
+
+ if (NULL!=(ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL)))
+ {
+ HANDLE NewThread;
+
+ Param->ThreadRunningEV=ThreadRunningEV;
+ if (NULL!=(NewThread=CreateThread(NULL,0,BadConnection,Param,0,&tid)))
+ {
+ WaitForSingleObject(ThreadRunningEV,INFINITE);
+ CloseHandle(NewThread);
+ }
+ CloseHandle(ThreadRunningEV);
+
+ return 1;
+ }
+ return 0;
+}
diff --git a/plugins/YAMN/src/browser/m_browser.h b/plugins/YAMN/src/browser/m_browser.h new file mode 100644 index 0000000000..8b05e3d84a --- /dev/null +++ b/plugins/YAMN/src/browser/m_browser.h @@ -0,0 +1,42 @@ +#ifndef __MAILBROWSER_H
+#define __MAILBROWSER_H
+
+#include "m_account.h"
+#include "../debug.h"
+
+typedef struct MailBrowserWinParam
+{
+#define YAMN_MAILBROWSERVERSION 1
+ HANDLE ThreadRunningEV;
+ HACCOUNT account;
+ DWORD nflags; //flags YAMN_ACC_??? when new mails
+ DWORD nnflags; //flags YAMN_ACC_??? when no new mails
+ void *Param;
+} YAMN_MAILBROWSERPARAM,*PYAMN_MAILBROWSERPARAM;
+
+typedef struct MailShowMsgWinParam
+{
+ HANDLE ThreadRunningEV;
+ HACCOUNT account;
+ HYAMNMAIL mail;
+} YAMN_MAILSHOWPARAM, *PYAMN_MAILSHOWPARAM;
+
+typedef struct NoNewMailParam
+{
+#define YAMN_NONEWMAILVERSION 1
+ HANDLE ThreadRunningEV;
+ HACCOUNT account;
+ DWORD flags;
+ void *Param;
+} YAMN_NONEWMAILPARAM,*PYAMN_NONEWMAILPARAM;
+
+typedef struct BadConnectionParam
+{
+#define YAMN_BADCONNECTIONVERSION 1
+ HANDLE ThreadRunningEV;
+ HACCOUNT account;
+ UINT_PTR errcode;
+ void *Param;
+} YAMN_BADCONNECTIONPARAM,*PYAMN_BADCONNECTIONPARAM;
+
+#endif
diff --git a/plugins/YAMN/src/browser/mailbrowser.cpp b/plugins/YAMN/src/browser/mailbrowser.cpp new file mode 100644 index 0000000000..4f1f5593d6 --- /dev/null +++ b/plugins/YAMN/src/browser/mailbrowser.cpp @@ -0,0 +1,2605 @@ +/*
+ * This code implements window handling (new mail)
+ *
+ * (c) majvan 2002-2004
+ */
+/* There can be problems when compiling this file, because in this file
+ * we are using both unicode and no-unicode functions and compiler does not
+ * like it in one file
+ * When you got errors, try to comment the #define <stdio.h> and compile, then
+ * put it back to uncommented and compile again :)
+ */
+#ifndef _WIN32_IE
+ #define _WIN32_IE 0x0400
+#endif
+#ifndef _WIN32_WINNT
+ #define _WIN32_WINNT 0x0501
+#endif
+
+#include "../yamn.h"
+#include "../main.h"
+
+#define TIMER_FLASHING 0x09061979
+#define MAILBROWSER_MINXSIZE 200 //min size of mail browser window
+#define MAILBROWSER_MINYSIZE 130
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+char* s_MonthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+bool bDate = false,bSub=false,bSize=false,bFrom=false;
+int PosX=0,PosY=0,SizeX=460,SizeY=100;
+int HeadSizeX = 0x2b2, HeadSizeY = 0x0b5, HeadPosX = 100, HeadPosY = 100;
+int HeadSplitPos=250; // per-mils of the size
+static int FromWidth=250,SubjectWidth=280,SizeWidth=50,SizeDate=205;
+unsigned char optDateTime = (SHOWDATELONG | SHOWDATENOTODAY);
+
+static WNDPROC OldListViewSubclassProc;
+
+struct CMailNumbersSub
+{
+ int Total; //any mail
+ int New; //uses YAMN_MSG_NEW flag
+ int UnSeen; //uses YAMN_MSG_UNSEEN flag
+// int Browser; //uses YAMN_MSG_BROWSER flag
+ int BrowserUC; //uses YAMN_MSG_BROWSER flag and YAMN_MSG_UNSEEN flag
+ int Display; //uses YAMN_MSG_DISPLAY flag
+ int DisplayTC; //uses YAMN_MSG_DISPLAY flag and YAMN_MSG_DISPLAYC flag
+ int DisplayUC; //uses YAMN_MSG_DISPLAY flag and YAMN_MSG_DISPLAYC flag and YAMN_MSG_UNSEEN flag
+ int PopUp; //uses YAMN_MSG_POPUP flag
+ int PopUpTC; //uses YAMN_MSG_POPUPC flag
+ int PopUpNC; //uses YAMN_MSG_POPUPC flag and YAMN_MSG_NEW flag
+ int PopUpRun; //uses YAMN_MSG_POPUP flag and YAMN_MSG_NEW flag
+ int PopUpSL2NC; //uses YAMN_MSG_SPAML2 flag and YAMN_MSG_NEW flag
+ int PopUpSL3NC; //uses YAMN_MSG_SPAML3 flag and YAMN_MSG_NEW flag
+// int SysTray; //uses YAMN_MSG_SYSTRAY flag
+ int SysTrayUC; //uses YAMN_MSG_SYSTRAY flag and YAMN_MSG_UNSEEN flag
+// int Sound; //uses YAMN_MSG_SOUND flag
+ int SoundNC; //uses YAMN_MSG_SOUND flag and YAMN_MSG_NEW flag
+// int App; //uses YAMN_MSG_APP flag
+ int AppNC; //uses YAMN_MSG_APP flag and YAMN_MSG_NEW flag
+ int EventNC; //uses YAMN_MSG_NEVENT flag and YAMN_MSG_NEW flag
+};
+
+struct CMailNumbers
+{
+ struct CMailNumbersSub Real;
+ struct CMailNumbersSub Virtual;
+};
+
+struct CMailWinUserInfo
+{
+ HACCOUNT Account;
+ int TrayIconState;
+ BOOL UpdateMailsMessagesAccess;
+ BOOL Seen;
+ BOOL RunFirstTime;
+};
+
+struct CChangeContent
+{
+ DWORD nflags;
+ DWORD nnflags;
+};
+
+struct CUpdateMails
+{
+ struct CChangeContent *Flags;
+ BOOL Waiting;
+ HANDLE Copied;
+};
+struct CSortList
+{
+ HWND hDlg;
+ int iSubItem;
+};
+
+//Retrieves HACCOUNT, whose mails are displayed in ListMails
+// hLM- handle of dialog window
+// returns handle of account
+inline HACCOUNT GetWindowAccount(HWND hDialog);
+
+//Looks to mail flags and increment mail counter (e.g. if mail is new, increments the new mail counter
+// msgq- mail, which increments the counters
+// MN- counnters structure
+void IncrementMailCounters(HYAMNMAIL msgq,struct CMailNumbers *MN);
+
+enum
+{
+ UPDATE_FAIL=0, //function failed
+ UPDATE_NONE, //none update has been performed
+ UPDATE_OK, //some changes occured, update performed
+};
+//Just looks for mail changes in account and update the mail browser window
+// hDlg- dialog handle
+// ActualAccount- account handle
+// nflags- flags what to do when new mail arrives
+// nnflags- flags what to do when no new mail arrives
+// returns one of UPDATE_XXX value(not implemented yet)
+int UpdateMails(HWND hDlg,HACCOUNT ActualAccount,DWORD nflags,DWORD nnflags);
+
+//When new mail occurs, shows window, plays sound, runs application...
+// hDlg- dialog handle. Dialog of mailbrowser is already created and actions are performed over this window
+// ActualAccount- handle of account, whose mails are to be notified
+// MN- statistics of mails in account
+// nflags- what to do or not to do (e.g. to show mailbrowser window or prohibit to show)
+// nflags- flags what to do when new mail arrives
+// nnflags- flags what to do when no new mail arrives
+void DoMailActions(HWND hDlg,HACCOUNT ActualAccount,struct CMailNumbers *MN,DWORD nflags,DWORD nnflags);
+
+//Looks for items in mailbrowser and if they were deleted, delete them from browser window
+// hListView- handle of listview window
+// ActualAccount- handle of account, whose mails are show
+// MailNumbers- pointer to structure, in which function stores numbers of mails with some property
+// returns one of UPDATE_XXX value (not implemented yet)
+int ChangeExistingMailStatus(HWND hListView,HACCOUNT ActualAccount,struct CMailNumbers *MN);
+
+//Adds new mails to ListView and if any new, shows multi popup (every new message is new popup window created by popup plugin)
+// hListView- handle of listview window
+// ActualAccount- handle of account, whose mails are show
+// NewMailPopUp- pointer to prepared structure for popup plugin, can be NULL if no popup show
+// MailNumbers- pointer to structure, in which function stores numbers of mails with some property
+// nflags- flags what to do when new mail arrives
+// returns one of UPDATE_XXX value (not implemented yet)
+int AddNewMailsToListView(HWND hListView,HACCOUNT ActualAccount,struct CMailNumbers *MailNumbers,DWORD nflags);
+
+//Window callback procedure for popup window (created by popup plugin)
+LRESULT CALLBACK NewMailPopUpProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
+
+//Window callback procedure for popup window (created by popup plugin)
+LRESULT CALLBACK NoNewMailPopUpProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam);
+
+//Dialog callback procedure for mail browser
+INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam);
+
+//MailBrowser thread function creates window if needed, tray icon and plays sound
+DWORD WINAPI MailBrowser(LPVOID Param);
+
+LRESULT CALLBACK ListViewSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+//Runs mail browser in new thread
+INT_PTR RunMailBrowserSvc(WPARAM,LPARAM);
+
+#define YAMN_BROWSER_SHOWPOPUP 0x01
+
+ // list view items' order criteria
+ #define LVORDER_NOORDER -1
+ #define LVORDER_STRING 0
+ #define LVORDER_NUMERIC 1
+ #define LVORDER_DATETIME 2
+
+ // list view order direction
+ #define LVORDER_ASCENDING 1
+ #define LVORDER_NONE 0
+ #define LVORDER_DESCENDING -1
+
+ // list view sort type
+ #define LVSORTPRIORITY_NONE -1
+
+ // List view column info.
+ typedef struct _SAMPLELISTVIEWCOLUMN
+ {
+ UINT uCXCol; // index
+ int nSortType; // sorting type (STRING = 0, NUMERIC, DATE, DATETIME)
+ int nSortOrder; // sorting order (ASCENDING = -1, NONE, DESCENDING)
+ int nPriority; // sort priority (-1 for none, 0, 1, ..., nColumns - 1 maximum)
+ TCHAR lpszName[128]; // column name
+ } SAMPLELISTVIEWCOLUMN;
+
+ // Compare priority
+ typedef struct _LVCOMPAREINFO
+ {
+ int iIdx; // Index
+ int iPriority; // Priority
+ } LVCOMPAREINFO, *LPLVCOMPAREINFO;
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+LPARAM readItemLParam(HWND hwnd,DWORD iItem)
+{
+ LVITEM item;
+
+ item.mask = LVIF_PARAM;
+ item.iItem = iItem;
+ item.iSubItem = 0;
+ SendMessage(hwnd,LVM_GETITEM,0,(LPARAM)&item);
+ return item.lParam;
+}
+
+inline HACCOUNT GetWindowAccount(HWND hDlg)
+{
+ struct CMailWinUserInfo *mwui;
+
+ if (NULL==(mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER)))
+ return NULL;
+ return mwui->Account;
+}
+
+void IncrementMailCounters(HYAMNMAIL msgq,struct CMailNumbers *MN)
+{
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.Total++;
+ else
+ MN->Real.Total++;
+
+ if (msgq->Flags & YAMN_MSG_NEW)
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.New++;
+ else
+ MN->Real.New++;
+ if (msgq->Flags & YAMN_MSG_UNSEEN)
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.UnSeen++;
+ else
+ MN->Real.UnSeen++;
+ if ((msgq->Flags & (YAMN_MSG_UNSEEN | YAMN_MSG_BROWSER)) == (YAMN_MSG_UNSEEN | YAMN_MSG_BROWSER))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.BrowserUC++;
+ else
+ MN->Real.BrowserUC++;
+ if (msgq->Flags & YAMN_MSG_DISPLAY)
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.Display++;
+ else
+ MN->Real.Display++;
+ if ((msgq->Flags & (YAMN_MSG_DISPLAYC | YAMN_MSG_DISPLAY)) == (YAMN_MSG_DISPLAYC | YAMN_MSG_DISPLAY))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.DisplayTC++;
+ else
+ MN->Real.DisplayTC++;
+ if ((msgq->Flags & (YAMN_MSG_UNSEEN | YAMN_MSG_DISPLAYC | YAMN_MSG_DISPLAY)) == (YAMN_MSG_UNSEEN | YAMN_MSG_DISPLAYC | YAMN_MSG_DISPLAY))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.DisplayUC++;
+ else
+ MN->Real.DisplayUC++;
+ if (msgq->Flags & YAMN_MSG_POPUP)
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.PopUp++;
+ else
+ MN->Real.PopUp++;
+ if ((msgq->Flags & YAMN_MSG_POPUPC) == YAMN_MSG_POPUPC)
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.PopUpTC++;
+ else
+ MN->Real.PopUpTC++;
+ if ((msgq->Flags & (YAMN_MSG_NEW | YAMN_MSG_POPUPC)) == (YAMN_MSG_NEW | YAMN_MSG_POPUPC))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.PopUpNC++;
+ else
+ MN->Real.PopUpNC++;
+ if ((msgq->Flags & (YAMN_MSG_NEW | YAMN_MSG_POPUP)) == (YAMN_MSG_NEW | YAMN_MSG_POPUP))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.PopUpRun++;
+ else
+ MN->Real.PopUpRun++;
+ if ((msgq->Flags & YAMN_MSG_NEW) && YAMN_MSG_SPAML(msgq->Flags,YAMN_MSG_SPAML2))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.PopUpSL2NC++;
+ else
+ MN->Real.PopUpSL2NC++;
+ if ((msgq->Flags & YAMN_MSG_NEW) && YAMN_MSG_SPAML(msgq->Flags,YAMN_MSG_SPAML3))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.PopUpSL3NC++;
+ else
+ MN->Real.PopUpSL3NC++;
+/* if (msgq->MailData->Flags & YAMN_MSG_SYSTRAY)
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.SysTray++;
+ else
+ MN->Real.SysTray++;
+*/ if ((msgq->Flags & (YAMN_MSG_UNSEEN | YAMN_MSG_SYSTRAY)) == (YAMN_MSG_UNSEEN|YAMN_MSG_SYSTRAY))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.SysTrayUC++;
+ else
+ MN->Real.SysTrayUC++;
+/* if (msgq->MailData->Flags & YAMN_MSG_SOUND)
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.Sound++;
+ else
+ MN->Real.Sound++;
+*/ if ((msgq->Flags & (YAMN_MSG_NEW|YAMN_MSG_SOUND)) == (YAMN_MSG_NEW|YAMN_MSG_SOUND))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.SoundNC++;
+ else
+ MN->Real.SoundNC++;
+/* if (msgq->MailData->Flags & YAMN_MSG_APP)
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.App++;
+ else
+ MN->Real.App++;
+*/ if ((msgq->Flags & (YAMN_MSG_NEW|YAMN_MSG_APP)) == (YAMN_MSG_NEW|YAMN_MSG_APP))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.AppNC++;
+ else
+ MN->Real.AppNC++;
+ if ((msgq->Flags & (YAMN_MSG_NEW|YAMN_MSG_NEVENT)) == (YAMN_MSG_NEW|YAMN_MSG_NEVENT))
+ if (msgq->Flags & YAMN_MSG_VIRTUAL)
+ MN->Virtual.EventNC++;
+ else
+ MN->Real.EventNC++;
+}
+
+int UpdateMails(HWND hDlg,HACCOUNT ActualAccount,DWORD nflags,DWORD nnflags)
+{
+#define MAILBROWSERTITLE "%s - %d new mail messages, %d total"
+
+ struct CMailWinUserInfo *mwui;
+ struct CMailNumbers MN;
+
+ HYAMNMAIL msgq;
+ BOOL Loaded;
+ BOOL RunMailBrowser,RunPopUps;
+
+ mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER);
+ //now we ensure read access for account and write access for its mails
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read wait failed\n");
+ #endif
+ PostMessage(hDlg,WM_DESTROY,0,0);
+
+ return UPDATE_FAIL;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read enter\n");
+ #endif
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=WaitToWriteFcn(ActualAccount->MessagesAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write wait failed\n");
+ DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+
+ PostMessage(hDlg,WM_DESTROY,0,0);
+ return UPDATE_FAIL;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write enter\n");
+ #endif
+
+ ZeroMemory(&MN,sizeof(MN));
+
+ for (msgq=(HYAMNMAIL)ActualAccount->Mails;msgq!=NULL;msgq=msgq->Next)
+ {
+ if (!LoadedMailData(msgq)) //check if mail is already in memory
+ {
+ Loaded=false;
+ if (NULL==LoadMailData(msgq)) //if we could not load mail to memory, consider this mail deleted and do not display it
+ continue;
+ }
+ else
+ Loaded=true;
+
+ IncrementMailCounters(msgq,&MN);
+
+ if (!Loaded)
+ UnloadMailData(msgq); //do not keep data for mail in memory
+ }
+
+ if (mwui!=NULL)
+ mwui->UpdateMailsMessagesAccess=TRUE;
+
+ //Now we are going to check if extracting data from mail headers are needed.
+ //If popups will be displayed or mailbrowser window
+ if ((((mwui!=NULL) && !(mwui->RunFirstTime)) &&
+ (
+ ((nnflags & YAMN_ACC_MSGP) && !(MN.Real.BrowserUC+MN.Virtual.BrowserUC)) ||
+ ((nflags & YAMN_ACC_MSGP) && (MN.Real.BrowserUC+MN.Virtual.BrowserUC))
+ )
+ ) || //if mail window was displayed before and flag YAMN_ACC_MSGP is set
+ ((nnflags & YAMN_ACC_MSG) && !(MN.Real.BrowserUC+MN.Virtual.BrowserUC)) || //if needed to run mailbrowser when no unseen and no unseen mail found
+ ((nflags & YAMN_ACC_MSG) && (MN.Real.BrowserUC+MN.Virtual.BrowserUC)) || //if unseen mails found, we sure run mailbrowser
+ ((nflags & YAMN_ACC_ICO) && (MN.Real.SysTrayUC+MN.Virtual.SysTrayUC))
+ ) //if needed to run systray
+ RunMailBrowser=TRUE;
+ else RunMailBrowser=FALSE;
+
+ if ( (nflags & YAMN_ACC_POP) &&
+ (ActualAccount->Flags & YAMN_ACC_POPN) &&
+ (MN.Real.PopUpNC+MN.Virtual.PopUpNC)) //if some popups with mails are needed to show
+ RunPopUps=TRUE;
+ else RunPopUps=FALSE;
+
+ if (RunMailBrowser)
+ ChangeExistingMailStatus(GetDlgItem(hDlg,IDC_LISTMAILS),ActualAccount,&MN);
+ if (RunMailBrowser || RunPopUps)
+ AddNewMailsToListView(hDlg==NULL ? NULL : GetDlgItem(hDlg,IDC_LISTMAILS),ActualAccount,&MN,nflags);
+
+ if (RunMailBrowser)
+ {
+ size_t len = strlen(ActualAccount->Name)+strlen(Translate(MAILBROWSERTITLE))+10; //+10 chars for numbers
+ char *TitleStrA=new char[len];
+ WCHAR *TitleStrW=new WCHAR[len];
+
+ sprintf(TitleStrA,Translate(MAILBROWSERTITLE),ActualAccount->Name,MN.Real.DisplayUC+MN.Virtual.DisplayUC,MN.Real.Display+MN.Virtual.Display);
+ MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,TitleStrA,-1,TitleStrW,(int)strlen(TitleStrA)+1);
+ SendMessageW(hDlg,WM_SETTEXT,0,(LPARAM)TitleStrW);
+ delete[] TitleStrA;
+ delete[] TitleStrW;
+ }
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UpdateMails:Do mail actions\n");
+ #endif
+
+ DoMailActions(hDlg,ActualAccount,&MN,nflags,nnflags);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UpdateMails:Do mail actions done\n");
+ #endif
+
+ SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_NEW,0,YAMN_MSG_NEW,YAMN_FLAG_REMOVE); //rempve the new flag
+ if (!RunMailBrowser)
+ SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_UNSEEN,YAMN_MSG_STAYUNSEEN,YAMN_MSG_UNSEEN,YAMN_FLAG_REMOVE); //remove the unseen flag when it was not displayed and it has not "stay unseen" flag set
+
+ if (mwui!=NULL)
+ {
+ mwui->UpdateMailsMessagesAccess=FALSE;
+ mwui->RunFirstTime=FALSE;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UpdateMails:ActualAccountMsgsSO-write done\n");
+ DebugLog(SynchroFile,"UpdateMails:ActualAccountSO-read done\n");
+ #endif
+ WriteDoneFcn(ActualAccount->MessagesAccessSO);
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+
+ if (RunMailBrowser)
+ UpdateWindow(GetDlgItem(hDlg,IDC_LISTMAILS));
+ else if (hDlg!=NULL)
+ DestroyWindow(hDlg);
+
+ return 1;
+}
+
+int ChangeExistingMailStatus(HWND hListView,HACCOUNT ActualAccount,struct CMailNumbers *MN)
+{
+ int i,in;
+ LVITEMW item;
+ HYAMNMAIL mail,msgq;
+
+ in=ListView_GetItemCount(hListView);
+ item.mask=LVIF_PARAM;
+
+ for (i=0;i<in;i++)
+ {
+ item.iItem=i;
+ item.iSubItem=0;
+ if (TRUE==ListView_GetItem(hListView,&item))
+ mail=(HYAMNMAIL)item.lParam;
+ else
+ continue;
+ for (msgq=(HYAMNMAIL)ActualAccount->Mails;(msgq!=NULL)&&(msgq!=mail);msgq=msgq->Next); //found the same mail in account queue
+ if (msgq==NULL) //if mail was not found
+ if (TRUE==ListView_DeleteItem(hListView,i))
+ {
+ in--;i--;
+ continue;
+ }
+ }
+
+ return TRUE;
+}
+
+void MimeDateToLocalizedDateTime(char *datein, WCHAR *dateout, int lendateout);
+int AddNewMailsToListView(HWND hListView,HACCOUNT ActualAccount,struct CMailNumbers *MN,DWORD nflags)
+{
+ HYAMNMAIL msgq;
+ POPUPDATAT NewMailPopUp = {0};
+
+ WCHAR *FromStr;
+ WCHAR SizeStr[20];
+ WCHAR LocalDateStr[128];
+
+ LVITEMW item;
+ LVFINDINFO fi;
+
+ int foundi,lfoundi;
+ struct CHeader UnicodeHeader;
+ BOOL Loaded,Extracted,FromStrNew=FALSE;
+
+ ZeroMemory(&item,sizeof(item));
+ ZeroMemory(&UnicodeHeader,sizeof(UnicodeHeader));
+
+ if (hListView!=NULL)
+ {
+ item.mask=LVIF_TEXT | LVIF_PARAM;
+ item.iItem=0;
+ ZeroMemory(&fi,sizeof(fi));
+ fi.flags=LVFI_PARAM; //let's go search item by lParam number
+ lfoundi=0;
+ }
+
+ NewMailPopUp.lchContact=(ActualAccount->hContact != NULL) ? ActualAccount->hContact : ActualAccount;
+ NewMailPopUp.lchIcon=g_LoadIconEx(2);
+ NewMailPopUp.colorBack=nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopUpB : GetSysColor(COLOR_BTNFACE);
+ NewMailPopUp.colorText=nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopUpT : GetSysColor(COLOR_WINDOWTEXT);
+ NewMailPopUp.iSeconds=ActualAccount->NewMailN.PopUpTime;
+
+ NewMailPopUp.PluginWindowProc=NewMailPopUpProc;
+ NewMailPopUp.PluginData=(void *)0; //it's new mail popup
+
+ for (msgq=(HYAMNMAIL)ActualAccount->Mails;msgq!=NULL;msgq=msgq->Next,lfoundi++)
+ {
+// now we hide mail pointer to item's lParam member. We can later use it to retrieve mail datas
+
+ Extracted=FALSE;FromStr=NULL;FromStrNew=FALSE;
+
+ if (hListView!=NULL)
+ {
+ fi.lParam=(LPARAM)msgq;
+ if (-1!=(foundi=ListView_FindItem(hListView,-1,&fi))) //if mail is already in window
+ {
+ lfoundi=foundi;
+ continue; //do not insert any item
+ }
+
+ item.iItem=lfoundi; //insert after last found item
+ item.lParam=(LPARAM)msgq;
+ }
+
+ if (!LoadedMailData(msgq)) //check if mail is already in memory
+ {
+ Loaded=false;
+ if (NULL==LoadMailData(msgq)) //if we could not load mail to memory, consider this mail deleted and do not display it
+ continue;
+ }
+ else
+ Loaded=true;
+
+ if (((hListView!=NULL) && (msgq->Flags & YAMN_MSG_DISPLAY)) ||
+ ((nflags & YAMN_ACC_POP) && (ActualAccount->Flags & YAMN_ACC_POPN) && (msgq->Flags & YAMN_MSG_POPUP) && (msgq->Flags & YAMN_MSG_NEW)))
+ {
+
+ if (!Extracted) ExtractHeader(msgq->MailData->TranslatedHeader,msgq->MailData->CP,&UnicodeHeader);
+ Extracted=TRUE;
+
+ if ((UnicodeHeader.From!=NULL) && (UnicodeHeader.FromNick!=NULL))
+ {
+ FromStr=new WCHAR[wcslen(UnicodeHeader.From)+wcslen(UnicodeHeader.FromNick)+4];
+ swprintf(FromStr,L"%s <%s>",UnicodeHeader.FromNick,UnicodeHeader.From);
+ FromStrNew=TRUE;
+ }
+ else if (UnicodeHeader.From!=NULL)
+ FromStr=UnicodeHeader.From;
+ else if (UnicodeHeader.FromNick!=NULL)
+ FromStr=UnicodeHeader.FromNick;
+ else if (UnicodeHeader.ReturnPath!=NULL)
+ FromStr=UnicodeHeader.ReturnPath;
+
+ if (NULL==FromStr)
+ {
+ FromStr=L"";
+ FromStrNew=FALSE;
+ }
+ }
+
+
+ if ((hListView!=NULL) && (msgq->Flags & YAMN_MSG_DISPLAY))
+ {
+ item.iSubItem=0;
+ item.pszText=FromStr;
+ item.iItem=SendMessageW(hListView,LVM_INSERTITEMW,0,(LPARAM)&item);
+
+ item.iSubItem=1;
+ item.pszText=(NULL!=UnicodeHeader.Subject ? UnicodeHeader.Subject : (WCHAR*)L"");
+ SendMessageW(hListView,LVM_SETITEMTEXTW,(WPARAM)item.iItem,(LPARAM)&item);
+
+ item.iSubItem=2;
+ swprintf(SizeStr,L"%d kB",msgq->MailData->Size/1024);
+ item.pszText=SizeStr;
+ SendMessageW(hListView,LVM_SETITEMTEXTW,(WPARAM)item.iItem,(LPARAM)&item);
+
+ item.iSubItem=3;
+ item.pszText=L"";
+ { CMimeItem *heads;
+ for (heads=msgq->MailData->TranslatedHeader;heads!=NULL;heads=heads->Next) {
+ if (!_stricmp(heads->name,"Date")) {
+ MimeDateToLocalizedDateTime(heads->value,LocalDateStr,128);
+ item.pszText=LocalDateStr;
+ break;
+ } } }
+ SendMessageW(hListView,LVM_SETITEMTEXTW,(WPARAM)item.iItem,(LPARAM)&item);
+ }
+
+ if ((nflags & YAMN_ACC_POP) && (ActualAccount->Flags & YAMN_ACC_POPN) && (msgq->Flags & YAMN_MSG_POPUP) && (msgq->Flags & YAMN_MSG_NEW))
+ {
+ WideCharToMultiByte(CP_ACP,0,FromStr,-1,(char *)NewMailPopUp.lptzContactName,sizeof(NewMailPopUp.lptzContactName),NULL,NULL);
+ if (!WideCharToMultiByte(CP_ACP,0,UnicodeHeader.Subject,-1,(char *)NewMailPopUp.lptzText,sizeof(NewMailPopUp.lptzText),NULL,NULL))
+ NewMailPopUp.lptzText[0]=0;
+ PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM)malloc(sizeof(YAMN_MAILSHOWPARAM));
+ if (MailParam) {
+ MailParam->account = ActualAccount;
+ MailParam->mail = msgq;
+ MailParam->ThreadRunningEV = 0;
+ NewMailPopUp.PluginData=MailParam;
+ PUAddPopUpT(&NewMailPopUp);
+ }
+ }
+
+ if ((msgq->Flags & YAMN_MSG_UNSEEN) && (ActualAccount->NewMailN.Flags & YAMN_ACC_KBN))
+ CallService(MS_KBDNOTIFY_EVENTSOPENED,(WPARAM)1,NULL);
+
+ if (FromStrNew)
+ delete[] FromStr;
+
+ if (Extracted)
+ {
+ DeleteHeaderContent(&UnicodeHeader);
+ ZeroMemory(&UnicodeHeader,sizeof(UnicodeHeader));
+ }
+
+ if (!Loaded)
+ {
+ SaveMailData(msgq);
+ UnloadMailData(msgq); //do not keep data for mail in memory
+ }
+ }
+
+ return TRUE;
+}
+
+void DoMailActions(HWND hDlg,HACCOUNT ActualAccount,struct CMailNumbers *MN,DWORD nflags,DWORD nnflags)
+{
+ char *NotIconText = Translate("- new mail message(s)");
+ NOTIFYICONDATA nid;
+
+ ZeroMemory(&nid,sizeof(nid));
+
+ if (MN->Real.EventNC+MN->Virtual.EventNC)
+ NotifyEventHooks(hNewMailHook,0,0);
+
+ if ((nflags & YAMN_ACC_KBN) && (MN->Real.PopUpRun+MN->Virtual.PopUpRun))
+ {
+ CallService(MS_KBDNOTIFY_STARTBLINK,(WPARAM)MN->Real.PopUpNC+MN->Virtual.PopUpNC,NULL);
+ }
+
+ if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopUpRun+MN->Virtual.PopUpRun))
+ {
+ char sMsg[250];
+ _snprintf(sMsg,249,Translate("%s : %d new mail message(s), %d total"),ActualAccount->Name,MN->Real.PopUpNC+MN->Virtual.PopUpNC,MN->Real.PopUpTC+MN->Virtual.PopUpTC);
+ if (!(nflags & YAMN_ACC_CONTNOEVENT)) {
+ CLISTEVENT cEvent;
+ cEvent.cbSize = sizeof(CLISTEVENT);
+ cEvent.hContact = ActualAccount->hContact;
+ cEvent.hIcon = g_LoadIconEx(2);
+ cEvent.hDbEvent = (HANDLE)ActualAccount->hContact;
+ cEvent.lParam = (LPARAM) ActualAccount->hContact;
+ cEvent.pszService = MS_YAMN_CLISTDBLCLICK;
+ cEvent.pszTooltip = sMsg;
+ cEvent.flags = 0;
+ CallServiceSync(MS_CLIST_ADDEVENT, 0,(LPARAM)&cEvent);
+ }
+ DBWriteContactSettingString(ActualAccount->hContact, "CList", "StatusMsg", sMsg);
+
+ if (nflags & YAMN_ACC_CONTNICK)
+ {
+ DBWriteContactSettingString(ActualAccount->hContact, YAMN_DBMODULE, "Nick",sMsg);
+ }
+ }
+
+ if ((nflags & YAMN_ACC_POP) &&
+ !(ActualAccount->Flags & YAMN_ACC_POPN) &&
+ (MN->Real.PopUpRun+MN->Virtual.PopUpRun))
+ {
+ POPUPDATAT NewMailPopUp ={0};
+
+ NewMailPopUp.lchContact=(ActualAccount->hContact != NULL) ? ActualAccount->hContact : ActualAccount;
+ NewMailPopUp.lchIcon=g_LoadIconEx(2);
+ NewMailPopUp.colorBack=nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopUpB : GetSysColor(COLOR_BTNFACE);
+ NewMailPopUp.colorText=nflags & YAMN_ACC_POPC ? ActualAccount->NewMailN.PopUpT : GetSysColor(COLOR_WINDOWTEXT);
+ NewMailPopUp.iSeconds=ActualAccount->NewMailN.PopUpTime;
+
+ NewMailPopUp.PluginWindowProc=NewMailPopUpProc;
+ NewMailPopUp.PluginData=(void *)0; //multiple popups
+
+ lstrcpyn(NewMailPopUp.lptzContactName, _A2T(ActualAccount->Name),SIZEOF(NewMailPopUp.lptzContactName));
+ wsprintf(NewMailPopUp.lptzText,TranslateT("%d new mail message(s), %d total"),MN->Real.PopUpNC+MN->Virtual.PopUpNC,MN->Real.PopUpTC+MN->Virtual.PopUpTC);
+ PUAddPopUpT(&NewMailPopUp);
+ }
+
+ //destroy tray icon if no new mail
+ if ((MN->Real.SysTrayUC+MN->Virtual.SysTrayUC==0) && (hDlg!=NULL))
+ {
+ nid.hWnd=hDlg;
+ nid.uID=0;
+ Shell_NotifyIcon(NIM_DELETE,&nid);
+ }
+
+ //and remove the event
+ if ((nflags & YAMN_ACC_CONT) && (!(nflags & YAMN_ACC_CONTNOEVENT)) && (MN->Real.UnSeen + MN->Virtual.UnSeen==0)) {
+ CallService(MS_CLIST_REMOVEEVENT,(WPARAM)ActualAccount->hContact,(LPARAM)ActualAccount->hContact);
+ }
+
+ if ((MN->Real.BrowserUC+MN->Virtual.BrowserUC==0) && (hDlg!=NULL))
+ {
+ if (!IsWindowVisible(hDlg) && !(nflags & YAMN_ACC_MSG))
+ PostMessage(hDlg,WM_DESTROY,0,0); //destroy window if no new mail and window is not visible
+ if (nnflags & YAMN_ACC_MSG) //if no new mail and msg should be executed
+ {
+ SetForegroundWindow(hDlg);
+ ShowWindow(hDlg,SW_SHOWNORMAL);
+ }
+ }
+ else
+ if (hDlg!=NULL) //else insert icon and set window if new mails
+ {
+ SendMessageW(GetDlgItem(hDlg,IDC_LISTMAILS),LVM_SCROLL,0,(LPARAM)0x7ffffff);
+
+ if ((nflags & YAMN_ACC_ICO) && (MN->Real.SysTrayUC+MN->Virtual.SysTrayUC))
+ {
+ char* src;
+ TCHAR *dest;
+ int i;
+
+ for (src=ActualAccount->Name,dest=nid.szTip,i=0;(*src!=(TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
+ for (src=NotIconText;(*src!=(TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
+ *dest=(TCHAR)0;
+ nid.cbSize=sizeof(NOTIFYICONDATA);
+ nid.hWnd=hDlg;
+ nid.hIcon=g_LoadIconEx(2);
+ nid.uID=0;
+ nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
+ nid.uCallbackMessage=WM_YAMN_NOTIFYICON;
+ Shell_NotifyIcon(NIM_ADD,&nid);
+ SetTimer(hDlg,TIMER_FLASHING,500,NULL);
+ }
+ if (nflags & YAMN_ACC_MSG) //if no new mail and msg should be executed
+ ShowWindow(hDlg,SW_SHOWNORMAL);
+ }
+
+ if (MN->Real.AppNC+MN->Virtual.AppNC!=0)
+ {
+ if (nflags & YAMN_ACC_APP)
+ {
+ PROCESS_INFORMATION pi;
+ STARTUPINFOW si;
+ ZeroMemory(&si,sizeof(si));
+ si.cb=sizeof(si);
+
+ if (ActualAccount->NewMailN.App!=NULL)
+ {
+ WCHAR *Command;
+ if (ActualAccount->NewMailN.AppParam!=NULL)
+ Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+wcslen(ActualAccount->NewMailN.AppParam)+6];
+ else
+ Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+6];
+
+ if (Command!=NULL)
+ {
+ lstrcpyW(Command,L"\"");
+ lstrcatW(Command,ActualAccount->NewMailN.App);
+ lstrcatW(Command,L"\" ");
+ if (ActualAccount->NewMailN.AppParam!=NULL)
+ lstrcatW(Command,ActualAccount->NewMailN.AppParam);
+ CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi);
+ delete[] Command;
+ }
+ }
+ }
+ }
+
+ if (MN->Real.SoundNC+MN->Virtual.SoundNC!=0)
+ if (nflags & YAMN_ACC_SND)
+ CallService(MS_SKIN_PLAYSOUND,0,(LPARAM)YAMN_NEWMAILSOUND);
+
+ if ((nnflags & YAMN_ACC_POP) && (MN->Real.PopUpRun+MN->Virtual.PopUpRun==0))
+ {
+ POPUPDATAT NoNewMailPopUp;
+
+ NoNewMailPopUp.lchContact=(ActualAccount->hContact != NULL) ? ActualAccount->hContact : ActualAccount;
+ NoNewMailPopUp.lchIcon=g_LoadIconEx(1);
+ NoNewMailPopUp.colorBack=ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC ? ActualAccount->NoNewMailN.PopUpB : GetSysColor(COLOR_BTNFACE);
+ NoNewMailPopUp.colorText=ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC ? ActualAccount->NoNewMailN.PopUpT : GetSysColor(COLOR_WINDOWTEXT);
+ NoNewMailPopUp.iSeconds=ActualAccount->NoNewMailN.PopUpTime;
+
+ NoNewMailPopUp.PluginWindowProc=NoNewMailPopUpProc;
+ NoNewMailPopUp.PluginData=(void *)0; //it's not new mail popup
+
+ lstrcpyn(NoNewMailPopUp.lptzContactName,_A2T(ActualAccount->Name),SIZEOF(NoNewMailPopUp.lptzContactName));
+ if (MN->Real.PopUpSL2NC+MN->Virtual.PopUpSL2NC)
+ wsprintf(NoNewMailPopUp.lptzText,TranslateT("No new mail message, %d spam(s)"),MN->Real.PopUpSL2NC+MN->Virtual.PopUpSL2NC);
+ else
+ lstrcpyn(NoNewMailPopUp.lptzText,TranslateT("No new mail message"),SIZEOF(NoNewMailPopUp.lptzText));
+ PUAddPopUpT(&NoNewMailPopUp);
+ }
+
+ if ((nflags & YAMN_ACC_CONT) && (MN->Real.PopUpRun+MN->Virtual.PopUpRun==0))
+ {
+ if (ActualAccount->hContact != NULL)
+ {
+ if (MN->Real.PopUpTC+MN->Virtual.PopUpTC)
+ {
+ char tmp[255];
+ sprintf(tmp,Translate("%d new mail message(s), %d total"),MN->Real.PopUpNC+MN->Virtual.PopUpNC,MN->Real.PopUpTC+MN->Virtual.PopUpTC);
+ DBWriteContactSettingString(ActualAccount->hContact, "CList", "StatusMsg", tmp);
+ }
+ else
+ DBWriteContactSettingString(ActualAccount->hContact, "CList", "StatusMsg", Translate("No new mail message"));
+
+ if (nflags & YAMN_ACC_CONTNICK)
+ {
+ DBWriteContactSettingString(ActualAccount->hContact, YAMN_DBMODULE, "Nick", ActualAccount->Name);
+ }
+ }
+ }
+ return;
+}
+
+DWORD WINAPI ShowEmailThread(LPVOID Param);
+LRESULT CALLBACK NewMailPopUpProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ INT_PTR PluginParam=0;
+ switch(msg)
+ {
+ case WM_COMMAND:
+ //if clicked and it's new mail popup window
+ if ((HIWORD(wParam)==STN_CLICKED) && (-1!=(PluginParam=CallService(MS_POPUP_GETPLUGINDATA,(WPARAM)hWnd,(LPARAM)&PluginParam))))
+ {
+ HANDLE hContact = 0;
+ HACCOUNT Account;
+ if (PluginParam){
+ PYAMN_MAILSHOWPARAM MailParam = new YAMN_MAILSHOWPARAM;
+ memcpy(MailParam,(PINT_PTR)PluginParam,sizeof(YAMN_MAILSHOWPARAM));
+ hContact = MailParam->account->hContact;
+ Account = MailParam->account;
+ if (NULL!=(MailParam->ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL))) {
+ HANDLE NewThread;
+ if (NULL!=(NewThread=CreateThread(NULL,0,ShowEmailThread,(LPVOID)MailParam,0,NULL)))
+ {
+ CloseHandle(NewThread);
+ }
+ CloseHandle(MailParam->ThreadRunningEV);
+ }
+ //delete MailParam;
+ } else {
+ DBVARIANT dbv;
+
+ hContact=(HANDLE)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0);
+
+ if (!DBGetContactSetting((HANDLE) hContact,YAMN_DBMODULE,"Id",&dbv))
+ {
+ Account=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ else
+ Account = (HACCOUNT) hContact; //????
+
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0==WaitToReadFcn(Account->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read enter\n");
+ #endif
+ switch(msg)
+ {
+ case WM_COMMAND:
+ {
+ YAMN_MAILBROWSERPARAM Param={(HANDLE)0,Account,
+ (Account->NewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG,
+ (Account->NoNewMailN.Flags & ~YAMN_ACC_POP) | YAMN_ACC_MSGP | YAMN_ACC_MSG};
+
+ RunMailBrowserSvc((WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION);
+ }
+ break;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(Account->AccountAccessSO);
+ }
+ #ifdef DEBUG_SYNCHRO
+ else
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read enter failed\n");
+ #endif
+ }
+ if ((Account->NewMailN.Flags & YAMN_ACC_CONT) && !(Account->NewMailN.Flags & YAMN_ACC_CONTNOEVENT)) {
+ CallService(MS_CLIST_REMOVEEVENT,(WPARAM)hContact,(LPARAM)hContact);
+ }
+ }
+ // fall through
+ case WM_CONTEXTMENU:
+ SendMessageW(hWnd,UM_DESTROYPOPUP,0,0);
+ break;
+ case UM_FREEPLUGINDATA:{
+ PYAMN_MAILSHOWPARAM mpd = (PYAMN_MAILSHOWPARAM)PUGetPluginData(hWnd);
+ HANDLE hContact = 0;
+ if ((mpd) && (INT_PTR)mpd!=-1)free(mpd);
+ return FALSE;
+ }
+ case UM_INITPOPUP:
+ //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups.
+ WindowList_Add(YAMNVar.MessageWnds,hWnd,NULL);
+ break;
+ case UM_DESTROYPOPUP:
+ WindowList_Remove(YAMNVar.MessageWnds,hWnd);
+ break;
+ case WM_YAMN_STOPACCOUNT:
+ {
+ HACCOUNT ActualAccount;
+ HANDLE hContact;
+ DBVARIANT dbv;
+
+ hContact=(HANDLE)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0);
+
+ if (!DBGetContactSetting((HANDLE) hContact,YAMN_DBMODULE,"Id",&dbv))
+ {
+ ActualAccount=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ else
+ ActualAccount = (HACCOUNT) hContact;
+
+ if ((HACCOUNT)wParam!=ActualAccount)
+ break;
+ DestroyWindow(hWnd);
+ return 0;
+ }
+ case WM_NOTIFY:
+ default:
+ break;
+ }
+ return DefWindowProc(hWnd,msg,wParam,lParam);
+}
+
+LRESULT CALLBACK NoNewMailPopUpProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_COMMAND:
+ if ((HIWORD(wParam)==STN_CLICKED) && (msg==WM_COMMAND))
+ {
+ HACCOUNT ActualAccount;
+ HANDLE hContact;
+ DBVARIANT dbv;
+
+ hContact=(HANDLE)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0);
+
+ if (!DBGetContactSetting((HANDLE) hContact,YAMN_DBMODULE,"Id",&dbv))
+ {
+ ActualAccount=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ else
+ ActualAccount = (HACCOUNT) hContact;
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read enter\n");
+ #endif
+ switch(msg)
+ {
+ case WM_COMMAND:
+ {
+ YAMN_MAILBROWSERPARAM Param={(HANDLE)0,ActualAccount,ActualAccount->NewMailN.Flags,ActualAccount->NoNewMailN.Flags,0};
+
+ Param.nnflags=Param.nnflags | YAMN_ACC_MSG; //show mails in account even no new mail in account
+ Param.nnflags=Param.nnflags & ~YAMN_ACC_POP;
+
+ Param.nflags=Param.nflags | YAMN_ACC_MSG; //show mails in account even no new mail in account
+ Param.nflags=Param.nflags & ~YAMN_ACC_POP;
+
+ RunMailBrowserSvc((WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION);
+ }
+ break;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+ #ifdef DEBUG_SYNCHRO
+ else
+ DebugLog(SynchroFile,"PopUpProc:LEFTCLICK:ActualAccountSO-read enter failed\n");
+ #endif
+ SendMessageW(hWnd,UM_DESTROYPOPUP,0,0);
+ }
+ break;
+
+ case WM_CONTEXTMENU:
+ SendMessageW(hWnd,UM_DESTROYPOPUP,0,0);
+ break;
+
+ case UM_FREEPLUGINDATA:
+ //Here we'd free our own data, if we had it.
+ return FALSE;
+ case UM_INITPOPUP:
+ //This is the equivalent to WM_INITDIALOG you'd get if you were the maker of dialog popups.
+ WindowList_Add(YAMNVar.MessageWnds,hWnd,NULL);
+ break;
+ case UM_DESTROYPOPUP:
+ WindowList_Remove(YAMNVar.MessageWnds,hWnd);
+ break;
+ case WM_YAMN_STOPACCOUNT:
+ {
+ HACCOUNT ActualAccount;
+ HANDLE hContact;
+ DBVARIANT dbv;
+
+ hContact=(HANDLE)CallService(MS_POPUP_GETCONTACT,(WPARAM)hWnd,0);
+
+ if (!DBGetContactSetting((HANDLE) hContact,YAMN_DBMODULE,"Id",&dbv))
+ {
+ ActualAccount=(HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)dbv.pszVal);
+ DBFreeVariant(&dbv);
+ }
+ else
+ ActualAccount = (HACCOUNT) hContact;
+
+ if ((HACCOUNT)wParam!=ActualAccount)
+ break;
+
+ DestroyWindow(hWnd);
+ return 0;
+ }
+ case WM_NOTIFY:
+/* switch(((LPNMHDR)lParam)->code)
+ {
+ case NM_CLICK:
+ {
+ }
+ }
+ break;
+*/ default:
+ break;
+ }
+ return DefWindowProc(hWnd,msg,wParam,lParam);
+}
+
+#ifdef __GNUC__
+//number of 100 ns periods between FILETIME 0 (1601/01/01 00:00:00.0000000) and TIMESTAMP 0 (1970/01/01 00:00:00)
+#define NUM100NANOSEC 116444736000000000ULL
+//The biggest time Get[Date|Time]Format can handle (Fri, 31 Dec 30827 23:59:59.9999999)
+#define MAXFILETIME 0x7FFF35F4F06C7FFFULL
+#else
+#define NUM100NANOSEC 116444736000000000
+#define MAXFILETIME 0x7FFF35F4F06C7FFF
+#endif
+
+ULONGLONG MimeDateToFileTime(char *datein)
+{
+ char *day=0, *month=0, *year=0, *time=0, *shift=0;
+ SYSTEMTIME st;
+ ULONGLONG res=0;
+ int wShiftSeconds = CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,0,0);
+ GetLocalTime(&st);
+ //datein = "Xxx, 1 Jan 2060 5:29:1 +0530 XXX";
+ //datein = "Xxx, 1 Jan 2060 05:29:10 ";
+ //datein = " ManySpaces 1.5 Jan 2060 05::";
+ //datein = "Xxx, 35 February 20 :29:10 ";
+ //datein = "01.12.2007 (22:38:17)"; //
+ if (datein){
+ char tmp [64];
+ while ( datein[0]==' ') datein++; // eat leading spaces
+ strncpy(tmp,datein,63); tmp [63]=0;
+ if (atoi(tmp)) { // Parseable integer on DayOfWeek field? Buggy mime date.
+ day = tmp;
+ } else {
+ int i = 0;
+ while (tmp[i]==' ')i++; if (day = strchr(&tmp[i],' ')){day[0]=0; day++;}
+ }
+ if (day) {while ( day[0]==' ') day++;if (month= strchr(day, ' ')){month[0]=0; month++;}}
+ if (month) {while (month[0]==' ')month++;if (year = strchr(month,' ')) { year[0]=0; year++;}}
+ if (year) {while ( year[0]==' ') year++;if (time = strchr(year, ' ')) { time[0]=0; time++;}}
+ if (time) {while ( time[0]==' ') time++;if (shift= strchr(time, ' ')){shift[0]=0; shift++;shift[5]=0;}}
+
+ if (year){
+ st.wYear = atoi(year);
+ if (strlen(year)<4) if (st.wYear<70)st.wYear += 2000; else st.wYear += 1900;
+ };
+ if (month) for (int i=0;i<12;i++) if (strncmp(month,s_MonthNames[i],3)==0) {st.wMonth = i + 1; break;}
+ if (day) st.wDay = atoi(day);
+ if (time) {
+ char *h, *m, *s;
+ h = time;
+ if (m = strchr(h,':')) {
+ m[0]=0; m++;
+ if (s = strchr(m,':')){s[0] = 0; s++;}
+ } else s=0;
+ st.wHour = atoi(h);
+ st.wMinute = m?atoi(m):0;
+ st.wSecond = s?atoi(s):0;
+ } else {st.wHour=st.wMinute=st.wSecond=0;}
+
+ if (shift){
+ if (strlen(shift)<4) {
+ //has only hour
+ wShiftSeconds = (atoi(shift))*3600;
+ } else {
+ char *smin = shift + strlen(shift)-2;
+ int ismin = atoi(smin);
+ smin[0] = 0;
+ int ishour = atoi(shift);
+ wShiftSeconds = (ishour*60+(ishour<0?-1:1)*ismin)*60;
+ }
+ }
+ } // if (datein)
+ FILETIME ft;
+ if (SystemTimeToFileTime(&st,&ft)) {
+ res = ((ULONGLONG)ft.dwHighDateTime<<32)|((ULONGLONG)ft.dwLowDateTime);
+ LONGLONG w100nano = Int32x32To64((DWORD)wShiftSeconds,10000000);
+ res -= w100nano;
+ }else{
+ res=0;
+ }
+ return res;
+}
+
+void FileTimeToLocalizedDateTime(LONGLONG filetime, WCHAR *dateout, int lendateout){
+ int localeID = CallService(MS_LANGPACK_GETLOCALE,0,0);
+ //int localeID = MAKELCID(LANG_URDU, SORT_DEFAULT);
+ if (localeID==CALLSERVICE_NOTFOUND) localeID=LOCALE_USER_DEFAULT;
+ if (filetime>MAXFILETIME) filetime = MAXFILETIME;
+ else if (filetime<=0) {
+ wcsncpy(dateout,TranslateW(L"Invalid"),lendateout);
+ return;
+ }
+ SYSTEMTIME st;
+ WORD wTodayYear, wTodayMonth, wTodayDay;
+ FILETIME ft;
+ BOOL willShowDate = !(optDateTime&SHOWDATENOTODAY);
+ if (!willShowDate){
+ GetLocalTime(&st);
+ wTodayYear = st.wYear;
+ wTodayMonth = st.wMonth;
+ wTodayDay = st.wDay;
+ }
+ ft.dwLowDateTime = (DWORD)filetime;
+ ft.dwHighDateTime = (DWORD)(filetime >> 32);
+ FILETIME localft;
+ if (!FileTimeToLocalFileTime(&ft,&localft)) {
+ // this should never happen
+ wcsncpy(dateout,L"Incorrect FileTime",lendateout);
+ } else {
+ if (!FileTimeToSystemTime(&localft,&st)) {
+ // this should never happen
+ wcsncpy(dateout,L"Incorrect LocalFileTime",lendateout);
+ } else {
+ dateout[lendateout-1]=0;
+ int templen = 0;
+ if (!willShowDate) willShowDate = (wTodayYear!=st.wYear)||(wTodayMonth!=st.wMonth)||(wTodayDay!=st.wDay);
+ if (willShowDate){
+ templen = GetDateFormatW(localeID,(optDateTime&SHOWDATELONG)?DATE_LONGDATE:DATE_SHORTDATE,&st,NULL,dateout,lendateout-2);
+ dateout[templen-1] = ' ';
+ }
+ if (templen<(lendateout-1)) {
+ GetTimeFormatW(localeID,(optDateTime&SHOWDATENOSECONDS)?TIME_NOSECONDS:0,&st,NULL,&dateout[templen],lendateout-templen-1);
+ }
+ }
+ }
+}
+
+void MimeDateToLocalizedDateTime(char *datein, WCHAR *dateout, int lendateout)
+{
+ ULONGLONG ft = MimeDateToFileTime(datein);
+ FileTimeToLocalizedDateTime(ft,dateout,lendateout);
+}
+
+int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2,LPARAM lParamSort ) {
+ if (lParam1 == NULL || lParam2 == NULL)
+ return 0;
+
+ int nResult = 0;
+ char *str1;
+ char *str2;
+ HYAMNMAIL email1 = (HYAMNMAIL)lParam1;
+ HYAMNMAIL email2 = (HYAMNMAIL)lParam2;
+ struct CShortHeader Header1;
+ struct CShortHeader Header2;
+ ZeroMemory(&Header1,sizeof(Header1));
+ ZeroMemory(&Header2,sizeof(Header2));
+
+ try {
+ ExtractShortHeader(email1->MailData->TranslatedHeader,&Header1);
+ ExtractShortHeader(email2->MailData->TranslatedHeader,&Header2);
+
+ switch((int)lParamSort)
+ {
+ case 0: //From
+ if (Header1.FromNick == NULL)
+ str1 = Header1.From;
+ else str1 = Header1.FromNick;
+
+ if (Header2.FromNick == NULL)
+ str2 = Header2.From;
+ else str2 = Header2.FromNick;
+
+ nResult = strcmp(str1, str2);
+
+ if (bFrom) nResult = -nResult;
+ break;
+ case 1: //Subject
+ if (Header1.Subject == NULL)
+ str1 = " ";
+ else str1 = Header1.Subject;
+
+ if (Header2.Subject == NULL)
+ str2 = " ";
+ else str2 = Header2.Subject;
+
+ nResult = strcmp(str1, str2);
+
+ if (bSub) nResult = -nResult;
+ break;
+ case 2: //Size
+ if (email1->MailData->Size == email2->MailData->Size) nResult = 0;
+ if (email1->MailData->Size > email2->MailData->Size) nResult = 1;
+ if (email1->MailData->Size < email2->MailData->Size) nResult = -1;
+
+ if (bSize) nResult = -nResult;
+ break;
+
+ case 3: //Date
+ {
+ ULONGLONG ts1 = 0, ts2 = 0;
+ ts1 = MimeDateToFileTime(Header1.Date);
+ ts2 = MimeDateToFileTime(Header2.Date);
+ if (ts1 > ts2) nResult = 1;
+ else if (ts1 < ts2) nResult = -1;
+ else nResult = 0;
+ }
+ if (bDate) nResult = -nResult;
+ break;
+
+ default:
+ if (Header1.Subject == NULL) str1 = " ";
+ else str1 = Header1.Subject;
+
+ if (Header2.Subject == NULL) str2 = " ";
+ else str2 = Header2.Subject;
+
+ nResult = strcmp(str1, str2);
+ break;
+ }
+ //MessageBox(NULL,str1,str2,0);
+ }
+ catch( ... )
+ {
+ }
+
+ //free mem
+ DeleteShortHeaderContent(&Header1);
+ DeleteShortHeaderContent(&Header2);
+ return nResult;
+
+}
+
+HCURSOR hCurSplitNS, hCurSplitWE;
+static WNDPROC OldSplitterProc;
+#define DM_SPLITTERMOVED (WM_USER+15)
+static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_NCHITTEST:
+ return HTCLIENT;
+ case WM_SETCURSOR:
+ {
+ SetCursor(hCurSplitNS);
+ return TRUE;
+ }
+ case WM_LBUTTONDOWN:
+ SetCapture(hwnd);
+ return 0;
+ case WM_MOUSEMOVE:
+ if (GetCapture() == hwnd) {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ SendMessage(GetParent(hwnd), DM_SPLITTERMOVED, (short) HIWORD(GetMessagePos()) + rc.bottom / 2, (LPARAM) hwnd);
+ }
+ return 0;
+ case WM_LBUTTONUP:
+ ReleaseCapture();
+ return 0;
+ }
+ return CallWindowProc(OldSplitterProc, hwnd, msg, wParam, lParam);
+}
+
+
+void ConvertCodedStringToUnicode(char *stream,WCHAR **storeto,DWORD cp,int mode);
+int ConvertStringToUnicode(char *stream,unsigned int cp,WCHAR **out);
+INT_PTR CALLBACK DlgProcYAMNShowMessage(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+// HIMAGELIST hIcons;
+ PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM)lParam;
+ WCHAR *iHeaderW=NULL;
+ WCHAR *iValueW=NULL;
+ int StrLen;
+ HWND hListView = GetDlgItem(hDlg,IDC_LISTHEADERS);
+ OldSplitterProc = (WNDPROC) SetWindowLongPtr(GetDlgItem(hDlg, IDC_SPLITTER), GWLP_WNDPROC, (LONG_PTR) SplitterSubclassProc);
+ SetWindowLongPtr(hDlg,DWLP_USER,(LONG_PTR)MailParam);
+ SendMessageW(hDlg,WM_SETICON,(WPARAM)ICON_BIG,(LPARAM)g_LoadIconEx(2, true));
+ SendMessageW(hDlg,WM_SETICON,(WPARAM)ICON_SMALL,(LPARAM)g_LoadIconEx(2));
+
+ ListView_SetUnicodeFormat(hListView,TRUE);
+ ListView_SetExtendedListViewStyle(hListView,LVS_EX_FULLROWSELECT);
+
+ StrLen=MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,Translate("Header"),-1,NULL,0);
+ iHeaderW=new WCHAR[StrLen+1];
+ MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,Translate("Header"),-1,iHeaderW,StrLen);
+
+ StrLen=MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,Translate("Value"),-1,NULL,0);
+ iValueW=new WCHAR[StrLen+1];
+ MultiByteToWideChar(CP_ACP,MB_USEGLYPHCHARS,Translate("Value"),-1,iValueW,StrLen);
+
+ LVCOLUMNW lvc0={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,130,iHeaderW,0,0};
+ LVCOLUMNW lvc1={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,400,iValueW,0,0};
+ SendMessageW(hListView,LVM_INSERTCOLUMNW,0,(LPARAM)&lvc0);
+ SendMessageW(hListView,LVM_INSERTCOLUMNW,(WPARAM)1,(LPARAM)&lvc1);
+ if (NULL!=iHeaderW)
+ delete[] iHeaderW;
+ if (NULL!=iValueW)
+ delete[] iValueW;
+
+ //WindowList_Add(YAMNVar.MessageWnds,hDlg,NULL);
+ //WindowList_Add(YAMNVar.NewMailAccountWnd,hDlg,ActualAccount);
+ SendMessage(hDlg,WM_YAMN_CHANGECONTENT,0,(LPARAM)MailParam);
+ MoveWindow(hDlg,HeadPosX,HeadPosY,HeadSizeX,HeadSizeY,0);
+ ShowWindow(hDlg,SW_SHOWNORMAL);
+ break;
+ }
+ case WM_YAMN_CHANGECONTENT:
+ {
+ PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM)
+ (lParam?lParam:GetWindowLongPtr(hDlg,DWLP_USER));
+ HWND hListView = GetDlgItem(hDlg,IDC_LISTHEADERS);
+ HWND hEdit = GetDlgItem(hDlg,IDC_EDITBODY);
+ //do not redraw
+ SendMessage(hListView, WM_SETREDRAW, 0, 0);
+ ListView_DeleteAllItems(hListView);
+ struct CMimeItem *Header;
+ LVITEMW item;
+ item.mask=LVIF_TEXT | LVIF_PARAM;
+ WCHAR *From=0,*Subj=0;
+ char *contentType=0, *transEncoding=0, *body=0; //should not be delete[]-ed
+ for (Header=MailParam->mail->MailData->TranslatedHeader;Header!=NULL;Header=Header->Next)
+ {
+ WCHAR *str1 = 0;
+ WCHAR *str2 = 0;
+ if (!body) if (!_stricmp(Header->name,"Body")) {body = Header->value; continue;}
+ if (!contentType) if (!_stricmp(Header->name,"Content-Type")) contentType = Header->value;
+ if (!transEncoding) if (!_stricmp(Header->name,"Content-Transfer-Encoding")) transEncoding = Header->value;
+ //ConvertCodedStringToUnicode(Header->name,&str1,MailParam->mail->MailData->CP,1);
+ {
+ int streamsize = MultiByteToWideChar(20127,0,Header->name,-1,NULL,0);
+ str1 = new WCHAR[streamsize+1];
+ MultiByteToWideChar(20127,0,Header->name,-1,str1,streamsize);//US-ASCII
+ }
+ ConvertCodedStringToUnicode(Header->value,&str2,MailParam->mail->MailData->CP,1);
+ if (!str2) { str2 = (WCHAR *)malloc(2); str2[0] = 0; }// the header value may be NULL
+ if (!From) if (!_stricmp(Header->name,"From")) {
+ From =new WCHAR[wcslen(str2)+1];
+ wcscpy(From,str2);
+ }
+ if (!Subj) if (!_stricmp(Header->name,"Subject")) {
+ Subj =new WCHAR[wcslen(str2)+1];
+ wcscpy(Subj,str2);
+ }
+ //if (!hasBody) if (!strcmp(Header->name,"Body")) hasBody = true;
+ int count = 0; WCHAR **split=0;
+ if (str2){
+ int ofs = 0;
+ while (str2[ofs]) {
+ if ((str2[ofs]==0x266A)||(str2[ofs]==0x25D9)||(str2[ofs]==0x25CB)||
+ (str2[ofs]==0x09)||(str2[ofs]==0x0A)||(str2[ofs]==0x0D))count++;
+ ofs++;
+ }
+ split=new WCHAR*[count+1];
+ count=0; ofs=0;
+ split[0]=str2;
+ while (str2[ofs]) {
+ if ((str2[ofs]==0x266A)||(str2[ofs]==0x25D9)||(str2[ofs]==0x25CB)||
+ (str2[ofs]==0x09)||(str2[ofs]==0x0A)||(str2[ofs]==0x0D)) {
+ if (str2[ofs-1]) {
+ count++;
+ }
+ split[count]=(WCHAR *)(str2+ofs+1);
+ str2[ofs]=0;
+ }
+ ofs++;
+ };
+ }
+ if (!_stricmp(Header->name,"From")||!_stricmp(Header->name,"To")||!_stricmp(Header->name,"Date")||!_stricmp(Header->name,"Subject"))
+ item.iItem = 0;
+ else
+ item.iItem = 999;
+ for (int i=0;i<=count;i++) {
+ item.iSubItem=0;
+ if (i==0)
+ item.pszText=str1;
+ else {
+ item.iItem++;
+ item.pszText=0;
+ }
+ item.iItem=SendMessageW(hListView,LVM_INSERTITEMW,0,(LPARAM)&item);
+ item.iSubItem=1;
+ item.pszText=str2?split[i]:0;
+ SendMessageW(hListView,LVM_SETITEMTEXTW,(WPARAM)item.iItem,(LPARAM)&item);
+ }
+ if (split)delete[] split;
+
+ if (str1) free(str1);
+ if (str2) free(str2);
+ }
+ if (body){
+ WCHAR *bodyDecoded = 0;
+ char *localBody=0;
+ if (contentType) {
+ if (!_strnicmp(contentType,"text",4)) {
+ if (transEncoding){
+ if (!_stricmp(transEncoding,"base64")) {
+ int size = (int)strlen(body)*3/4+5;
+ localBody = new char[size+1];
+ DecodeBase64(body,localBody,size);
+ } else if (!_stricmp(transEncoding,"quoted-printable")) {
+ int size = (int)strlen(body)+2;
+ localBody = new char[size+1];
+ DecodeQuotedPrintable(body,localBody,size,FALSE);
+ }
+ }
+ } else if (!_strnicmp(contentType,"multipart/",10)) {
+ char *bondary=NULL;
+ if (NULL!=(bondary=ExtractFromContentType(contentType,"boundary=")))
+ {
+ bodyDecoded = ParseMultipartBody(body,bondary);
+ delete[] bondary;
+ }
+ }
+ }
+ if (!bodyDecoded)ConvertStringToUnicode(localBody?localBody:body,MailParam->mail->MailData->CP,&bodyDecoded);
+ SendMessageW(hEdit,WM_SETTEXT,0,(LPARAM)bodyDecoded);
+ delete[] bodyDecoded;
+ if (localBody) delete[] localBody;
+ SetFocus(hEdit);
+ }
+ if (!(MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED)) {
+ MailParam->mail->Flags |= YAMN_MSG_BODYREQUESTED;
+ CallService(MS_YAMN_ACCOUNTCHECK,(WPARAM)MailParam->account,0);
+ } else {
+ if (MailParam->mail->Flags & YAMN_MSG_UNSEEN){
+ MailParam->mail->Flags&=~YAMN_MSG_UNSEEN; //mark the message as seen
+ HWND hMailBrowser;
+ if (hMailBrowser=WindowList_Find(YAMNVar.NewMailAccountWnd,MailParam->account)) {
+ struct CChangeContent Params={MailParam->account->NewMailN.Flags|YAMN_ACC_MSGP,MailParam->account->NoNewMailN.Flags|YAMN_ACC_MSGP};
+ SendMessageW(hMailBrowser,WM_YAMN_CHANGECONTENT,(WPARAM)MailParam->account,(LPARAM)&Params);
+ } else {
+ UpdateMails(NULL,MailParam->account,MailParam->account->NewMailN.Flags,MailParam->account->NoNewMailN.Flags);
+ }
+ }
+ }
+ ShowWindow(GetDlgItem(hDlg, IDC_SPLITTER),(MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED)?SW_SHOW:SW_HIDE);
+ ShowWindow(hEdit,(MailParam->mail->Flags & YAMN_MSG_BODYRECEIVED)?SW_SHOW:SW_HIDE);
+ WCHAR *title=0;
+ title = new WCHAR[(From?wcslen(From):0)+(Subj?wcslen(Subj):0)+4];
+ if (From&&Subj) wsprintfW(title,L"%s (%s)",Subj,From);
+ else if (From)wsprintfW(title,L"%s",From);
+ else if (Subj)wsprintfW(title,L"%s",Subj);
+ else wsprintfW(title,L"none");
+ if (Subj) delete[] Subj;
+ if (From) delete[] From;
+ SendMessageW(hDlg,WM_SETTEXT,0,(LPARAM)title);
+ delete[] title;
+ // turn on redrawing
+ SendMessage(hListView, WM_SETREDRAW, 1, 0);
+ SendMessage(hDlg, WM_SIZE, 0, HeadSizeY<<16|HeadSizeX);
+ } break;
+ case WM_YAMN_STOPACCOUNT:
+ {
+ PYAMN_MAILSHOWPARAM MailParam = (PYAMN_MAILSHOWPARAM)
+ (lParam?lParam:GetWindowLongPtr(hDlg,DWLP_USER));
+
+ if (NULL==MailParam)
+ break;
+ if ((HACCOUNT)wParam!=MailParam->account)
+ break;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"ShowMessage:STOPACCOUNT:sending destroy msg\n");
+ #endif
+ DestroyWindow(hDlg);
+ }
+ return 1;
+ case WM_CTLCOLORSTATIC:
+ //here should be check if this is our edittext control.
+ //but we have only one static control (for now);
+ SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
+ SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
+ return (INT_PTR)GetSysColorBrush(COLOR_WINDOW);;
+ case WM_DESTROY:
+ {
+ RECT coord;
+ if (GetWindowRect(hDlg,&coord))
+ {
+ HeadPosX=coord.left;
+ HeadSizeX=coord.right-coord.left;
+ HeadPosY=coord.top;
+ HeadSizeY=coord.bottom-coord.top;
+ }
+
+ PostQuitMessage(1);
+ }
+ break;
+ case WM_SYSCOMMAND:
+ {
+ switch(wParam)
+ {
+ case SC_CLOSE:
+ DestroyWindow(hDlg);
+ break;
+ }
+ }
+ break;
+ case WM_MOVE:
+ HeadPosX=LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left;
+ HeadPosY=HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top;
+ return 0;
+ case DM_SPLITTERMOVED:
+ {
+ if ((HWND) lParam == GetDlgItem(hDlg, IDC_SPLITTER)) {
+ POINT pt;
+ pt.x = 0;
+ pt.y = wParam;
+ ScreenToClient(hDlg, &pt);
+ HeadSplitPos = (pt.y*1000)/HeadSizeY;//+rc.bottom-rc.top;
+ if (HeadSplitPos>=1000) HeadSplitPos = 999;
+ else if (HeadSplitPos<=0) HeadSplitPos = 1;
+ else SendMessage(hDlg, WM_SIZE, 0, HeadSizeY<<16|HeadSizeX);
+ }
+ return 0;
+ }
+ case WM_SIZE:
+ if (wParam==SIZE_RESTORED)
+ {
+ HWND hList = GetDlgItem(hDlg,IDC_LISTHEADERS);
+ HWND hEdit = GetDlgItem(hDlg,IDC_EDITBODY);
+ BOOL changeX = LOWORD(lParam)!=HeadSizeX;
+ BOOL isBodyShown = ((PYAMN_MAILSHOWPARAM)(GetWindowLongPtr(hDlg,DWLP_USER)))->mail->Flags & YAMN_MSG_BODYRECEIVED;
+ HeadSizeX=LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left;
+ HeadSizeY=HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top;
+ int localSplitPos = (HeadSplitPos*HeadSizeY)/1000;
+ int localSizeX;
+ RECT coord;
+ MoveWindow(GetDlgItem(hDlg,IDC_SPLITTER),5,localSplitPos,HeadSizeX-10,2,TRUE);
+ MoveWindow(hEdit,5,localSplitPos+6,HeadSizeX-10,HeadSizeY-localSplitPos-11,TRUE); //where to put text window while resizing
+ MoveWindow(hList, 5 ,5 ,HeadSizeX-10 ,(isBodyShown?localSplitPos:HeadSizeY)-10,TRUE); //where to put headers list window while resizing
+ //if (changeX){
+ if (GetClientRect(hList,&coord)) {
+ localSizeX=coord.right-coord.left;
+ } else localSizeX=HeadSizeX;
+ LONG iNameWidth = ListView_GetColumnWidth(hList,0);
+ ListView_SetColumnWidth(hList,1,(localSizeX<=iNameWidth)?0:(localSizeX-iNameWidth));
+ //}
+ }
+// break;
+ return 0;
+ case WM_CONTEXTMENU:
+ {
+ if ( GetWindowLongPtr(( HWND )wParam, GWLP_ID ) == IDC_LISTHEADERS) {
+ //MessageBox(0,"LISTHEADERS","Debug",0);
+ HWND hList = GetDlgItem( hDlg, IDC_LISTHEADERS );
+ POINT pt = { (signed short)LOWORD( lParam ), (signed short)HIWORD( lParam ) };
+ HTREEITEM hItem = 0;
+ if (pt.x==-1) pt.x = 0;
+ if (pt.y==-1) pt.y = 0;
+ if (int numRows = ListView_GetItemCount(hList)) {
+ HMENU hMenu = CreatePopupMenu();
+ AppendMenu(hMenu, MF_STRING, (UINT_PTR)1, TranslateT("Copy Selected"));
+ AppendMenu(hMenu, MF_STRING, (UINT_PTR)2, TranslateT("Copy All"));
+ AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
+ AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel"));
+ int nReturnCmd = TrackPopupMenu( hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL );
+ DestroyMenu( hMenu );
+ if (nReturnCmd>0){
+ int courRow=0;
+ size_t sizeNeeded = 0;
+ TCHAR headname[64]={0}, headvalue[256]={0};
+ for (courRow=0; courRow < numRows; courRow++) {
+ if ((nReturnCmd==1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED)==0)) continue;
+ ListView_GetItemText(hList, courRow, 0, headname, SIZEOF(headname));
+ ListView_GetItemText(hList, courRow, 1, headvalue, SIZEOF(headvalue));
+ size_t headnamelen = _tcslen(headname);
+ if (headnamelen) sizeNeeded += 1 + headnamelen;
+ sizeNeeded += 3 + _tcslen(headvalue);
+ }
+ if (sizeNeeded && OpenClipboard(hDlg)) {
+ EmptyClipboard();
+ HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE,(sizeNeeded+1)*sizeof(TCHAR));
+ TCHAR *buff = ( TCHAR* )GlobalLock(hData);
+ int courPos = 0;
+ for (courRow=0;courRow<numRows;courRow++) {
+ if ((nReturnCmd==1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED)==0)) continue;
+ ListView_GetItemText(hList, courRow, 0, headname, SIZEOF(headname));
+ ListView_GetItemText(hList, courRow, 1, headvalue, SIZEOF(headvalue));
+ if ( _tcslen(headname)) courPos += _stprintf(&buff[courPos], _T("%s:\t%s\r\n"), headname, headvalue);
+ else courPos += _stprintf( &buff[courPos], _T("\t%s\r\n"), headvalue);
+ }
+ GlobalUnlock(hData);
+ #if defined( _UNICODE )
+ SetClipboardData(CF_UNICODETEXT,hData);
+ #else
+ SetClipboardData(CF_TEXT,hData);
+ #endif
+ CloseClipboard();
+ }
+ }
+ }
+ } }
+ break; // just in case
+ }
+ return 0;
+}
+
+DWORD WINAPI ShowEmailThread(LPVOID Param){
+ struct MailShowMsgWinParam MyParam;
+ MyParam=*(struct MailShowMsgWinParam *)Param;
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"ShowMessage:Incrementing \"using threads\" %x (account %x)\n",MyParam.account->UsingThreads,MyParam.account);
+ #endif
+ SCIncFcn(MyParam.account->UsingThreads);
+ SetEvent(MyParam.ThreadRunningEV);
+ if (MyParam.mail->MsgWindow){
+ //if (!BringWindowToTop(MyParam.mail->MsgWindow)) {
+ if (!SetForegroundWindow(MyParam.mail->MsgWindow)) {
+ SendMessage(MyParam.mail->MsgWindow,WM_DESTROY,0,0);
+ MyParam.mail->MsgWindow = 0;
+ goto CREADTEVIEWMESSAGEWINDOW;
+ }else{
+ if (IsIconic(MyParam.mail->MsgWindow)) {
+ OpenIcon(MyParam.mail->MsgWindow);
+ }
+ }
+ } else {
+CREADTEVIEWMESSAGEWINDOW:
+ MyParam.mail->MsgWindow = CreateDialogParamW(YAMNVar.hInst,MAKEINTRESOURCEW(IDD_DLGSHOWMESSAGE),NULL,DlgProcYAMNShowMessage,(LPARAM)&MyParam);
+ WindowList_Add(YAMNVar.MessageWnds,MyParam.mail->MsgWindow,NULL);
+ MSG msg;
+ while(GetMessage(&msg,NULL,0,0)) {
+ if (!IsDialogMessage(MyParam.mail->MsgWindow, &msg)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ } }
+ WindowList_Remove(YAMNVar.MessageWnds,MyParam.mail->MsgWindow);
+ MyParam.mail->MsgWindow = NULL;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"ShowMessage:Decrementing \"using threads\" %x (account %x)\n",MyParam.account->UsingThreads,MyParam.account);
+ #endif
+ SCDecFcn(MyParam.account->UsingThreads);
+ delete Param;
+ return 1;
+}
+
+INT_PTR CALLBACK DlgProcYAMNMailBrowser(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ HACCOUNT ActualAccount;
+ struct MailBrowserWinParam *MyParam=(struct MailBrowserWinParam *)lParam;
+ struct CMailWinUserInfo *mwui;
+
+ ListView_SetUnicodeFormat(GetDlgItem(hDlg,IDC_LISTMAILS),TRUE);
+ ListView_SetExtendedListViewStyle(GetDlgItem(hDlg,IDC_LISTMAILS),LVS_EX_FULLROWSELECT);
+
+ ActualAccount=MyParam->account;
+ mwui=new struct CMailWinUserInfo;
+ mwui->Account=ActualAccount;
+ mwui->TrayIconState=0;
+ mwui->UpdateMailsMessagesAccess=FALSE;
+ mwui->Seen=FALSE;
+ mwui->RunFirstTime=TRUE;
+
+ SetWindowLongPtr(hDlg,DWLP_USER,(LONG_PTR)mwui);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read enter failed\n");
+ #endif
+ DestroyWindow(hDlg);
+ return FALSE;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read enter\n");
+ #endif
+
+ SendMessageW(GetDlgItem(hDlg,IDC_BTNAPP),WM_SETTEXT,0,(LPARAM)TranslateW(L"Run application"));
+ SendMessageW(GetDlgItem(hDlg,IDC_BTNDEL),WM_SETTEXT,0,(LPARAM)TranslateW(L"Delete selected"));
+ SendMessageW(GetDlgItem(hDlg,IDC_BTNCHECKALL),WM_SETTEXT,0,(LPARAM)TranslateW(L"Select All"));
+ SendMessageW(GetDlgItem(hDlg,IDC_BTNOK),WM_SETTEXT,0,(LPARAM)TranslateW(L"OK"));
+
+ LVCOLUMNW lvc0={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,FromWidth,TranslateW(L"From"),0,0};
+ LVCOLUMNW lvc1={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,SubjectWidth,TranslateW(L"Subject"),0,0};
+ LVCOLUMNW lvc2={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,SizeWidth,TranslateW(L"Size"),0,0};
+ LVCOLUMNW lvc3={LVCF_FMT | LVCF_TEXT | LVCF_WIDTH,LVCFMT_LEFT,SizeDate,TranslateW(L"Date"),0,0};
+ SendMessageW(GetDlgItem(hDlg,IDC_LISTMAILS),LVM_INSERTCOLUMNW,0,(LPARAM)&lvc0);
+ SendMessageW(GetDlgItem(hDlg,IDC_LISTMAILS),LVM_INSERTCOLUMNW,(WPARAM)1,(LPARAM)&lvc1);
+ SendMessageW(GetDlgItem(hDlg,IDC_LISTMAILS),LVM_INSERTCOLUMNW,(WPARAM)2,(LPARAM)&lvc2);
+ SendMessageW(GetDlgItem(hDlg,IDC_LISTMAILS),LVM_INSERTCOLUMNW,(WPARAM)3,(LPARAM)&lvc3);
+
+ if ((ActualAccount->NewMailN.App!=NULL) && (wcslen(ActualAccount->NewMailN.App)))
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNAPP),(WPARAM)TRUE);
+ else
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNAPP),(WPARAM)FALSE);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:INIT:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+
+ WindowList_Add(YAMNVar.MessageWnds,hDlg,NULL);
+ WindowList_Add(YAMNVar.NewMailAccountWnd,hDlg,ActualAccount);
+
+ {
+ TCHAR accstatus[512];
+ GetStatusFcn(ActualAccount,accstatus);
+ SetDlgItemText(hDlg,IDC_STSTATUS,accstatus);
+ }
+ SetTimer(hDlg,TIMER_FLASHING,500,NULL);
+
+ if (ActualAccount->hContact != NULL)
+ {
+ CallService(MS_CLIST_REMOVEEVENT,(WPARAM)ActualAccount->hContact,(LPARAM)"yamn new mail message");
+ }
+
+ OldListViewSubclassProc = (WNDPROC) SetWindowLongPtr(GetDlgItem(hDlg, IDC_LISTMAILS), GWLP_WNDPROC, (LONG_PTR) ListViewSubclassProc);
+
+ break;
+ }
+ case WM_DESTROY:
+ {
+ HACCOUNT ActualAccount;
+ RECT coord;
+ LVCOLUMNW ColInfo;
+ NOTIFYICONDATA nid;
+ HYAMNMAIL Parser;
+ struct CMailWinUserInfo *mwui;
+
+ mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER);
+ if (NULL==(ActualAccount=GetWindowAccount(hDlg)))
+ break;
+ ColInfo.mask=LVCF_WIDTH;
+ if (ListView_GetColumn(GetDlgItem(hDlg,IDC_LISTMAILS),0,&ColInfo))
+ FromWidth=ColInfo.cx;
+ if (ListView_GetColumn(GetDlgItem(hDlg,IDC_LISTMAILS),1,&ColInfo))
+ SubjectWidth=ColInfo.cx;
+ if (ListView_GetColumn(GetDlgItem(hDlg,IDC_LISTMAILS),2,&ColInfo))
+ SizeWidth=ColInfo.cx;
+ if (ListView_GetColumn(GetDlgItem(hDlg,IDC_LISTMAILS),3,&ColInfo))
+ SizeDate=ColInfo.cx;
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DESTROY:save window position\n");
+ #endif
+ if (!YAMNVar.Shutdown && GetWindowRect(hDlg,&coord)) //the YAMNVar.Shutdown testing is because M<iranda strange functionality at shutdown phase, when call to DBWriteContactSetting freezes calling thread
+ {
+ PosX=coord.left;
+ SizeX=coord.right-coord.left;
+ PosY=coord.top;
+ SizeY=coord.bottom-coord.top;
+ DBWriteContactSettingDword(NULL,YAMN_DBMODULE,YAMN_DBPOSX,PosX);
+ DBWriteContactSettingDword(NULL,YAMN_DBMODULE,YAMN_DBPOSY,PosY);
+ DBWriteContactSettingDword(NULL,YAMN_DBMODULE,YAMN_DBSIZEX,SizeX);
+ DBWriteContactSettingDword(NULL,YAMN_DBMODULE,YAMN_DBSIZEY,SizeY);
+ }
+ KillTimer(hDlg,TIMER_FLASHING);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DESTROY:remove window from list\n");
+ #endif
+ WindowList_Remove(YAMNVar.NewMailAccountWnd,hDlg);
+ WindowList_Remove(YAMNVar.MessageWnds,hDlg);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=WaitToWriteFcn(ActualAccount->MessagesAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write wait failed\n");
+ #endif
+ break;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write enter\n");
+ #endif
+ //delete mails from queue, which are deleted from server (spam level 3 mails e.g.)
+ for (Parser=(HYAMNMAIL)ActualAccount->Mails;Parser!=NULL;Parser=Parser->Next)
+ {
+ if ((Parser->Flags & YAMN_MSG_DELETED) && YAMN_MSG_SPAML(Parser->Flags,YAMN_MSG_SPAML3) && mwui->Seen) //if spaml3 was already deleted and user knows about it
+ {
+ DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails,Parser,1);
+ CallService(MS_YAMN_DELETEACCOUNTMAIL,(WPARAM)ActualAccount->Plugin,(LPARAM)Parser);
+ }
+ }
+
+ //mark mails as read (remove "new" and "unseen" flags)
+ if (mwui->Seen)
+ SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_DISPLAY,0,YAMN_MSG_NEW | YAMN_MSG_UNSEEN,0);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DESTROY:ActualAccountMsgsSO-write done\n");
+ #endif
+ WriteDoneFcn(ActualAccount->MessagesAccessSO);
+
+ ZeroMemory(&nid,sizeof(NOTIFYICONDATA));
+
+ delete mwui;
+ SetWindowLongPtr(hDlg,DWLP_USER,(LONG_PTR)NULL);
+
+ nid.cbSize=sizeof(NOTIFYICONDATA);
+ nid.hWnd=hDlg;
+ nid.uID=0;
+ Shell_NotifyIcon(NIM_DELETE,&nid);
+ PostQuitMessage(0);
+ }
+ break;
+ case WM_SHOWWINDOW:
+ {
+ struct CMailWinUserInfo *mwui;
+
+ if (NULL==(mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER)))
+ return 0;
+ mwui->Seen=TRUE;
+ }
+ case WM_YAMN_CHANGESTATUS:
+ {
+ HACCOUNT ActualAccount;
+ if (NULL==(ActualAccount=GetWindowAccount(hDlg)))
+ break;
+
+ if ((HACCOUNT)wParam!=ActualAccount)
+ break;
+
+ TCHAR accstatus[512];
+ GetStatusFcn(ActualAccount,accstatus);
+ SetDlgItemText(hDlg,IDC_STSTATUS,accstatus);
+ }
+ return 1;
+ case WM_YAMN_CHANGECONTENT:
+ {
+ struct CUpdateMails UpdateParams;
+ BOOL ThisThreadWindow=(GetCurrentThreadId()==GetWindowThreadProcessId(hDlg,NULL));
+
+ if (NULL==(UpdateParams.Copied=CreateEvent(NULL,FALSE,FALSE,NULL)))
+ {
+ DestroyWindow(hDlg);
+ return 0;
+ }
+ UpdateParams.Flags=(struct CChangeContent *)lParam;
+ UpdateParams.Waiting=!ThisThreadWindow;
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:posting UPDATEMAILS\n");
+ #endif
+ if (ThisThreadWindow)
+ {
+ if (!UpdateMails(hDlg,(HACCOUNT)wParam,UpdateParams.Flags->nflags,UpdateParams.Flags->nnflags))
+ DestroyWindow(hDlg);
+ }
+ else if (PostMessage(hDlg,WM_YAMN_UPDATEMAILS,wParam,(LPARAM)&UpdateParams)) //this ensures UpdateMails will execute the thread who created the browser window
+ {
+ if (!ThisThreadWindow)
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:waiting for event\n");
+ #endif
+ WaitForSingleObject(UpdateParams.Copied,INFINITE);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:CHANGECONTENT:event signaled\n");
+ #endif
+ }
+ }
+
+ CloseHandle(UpdateParams.Copied);
+ }
+ return 1;
+ case WM_YAMN_UPDATEMAILS:
+ {
+ HACCOUNT ActualAccount;
+
+ struct CUpdateMails *um=(struct CUpdateMails *)lParam;
+ DWORD nflags,nnflags;
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:UPDATEMAILS\n");
+ #endif
+
+ if (NULL==(ActualAccount=GetWindowAccount(hDlg)))
+ return 0;
+ if ((HACCOUNT)wParam!=ActualAccount)
+ return 0;
+
+ nflags=um->Flags->nflags;
+ nnflags=um->Flags->nnflags;
+
+ if (um->Waiting)
+ SetEvent(um->Copied);
+
+ if (!UpdateMails(hDlg,ActualAccount,nflags,nnflags))
+ DestroyWindow(hDlg);
+ }
+ return 1;
+ case WM_YAMN_STOPACCOUNT:
+ {
+ HACCOUNT ActualAccount;
+
+ if (NULL==(ActualAccount=GetWindowAccount(hDlg)))
+ break;
+ if ((HACCOUNT)wParam!=ActualAccount)
+ break;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:STOPACCOUNT:sending destroy msg\n");
+ #endif
+ PostQuitMessage(0);
+ }
+ return 1;
+ case WM_YAMN_NOTIFYICON:
+ {
+ HACCOUNT ActualAccount;
+ if (NULL==(ActualAccount=GetWindowAccount(hDlg)))
+ break;
+
+ switch(lParam)
+ {
+ case WM_LBUTTONDBLCLK:
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read wait failed\n");
+ #endif
+ return 0;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read enter\n");
+ #endif
+ if (ActualAccount->AbilityFlags & YAMN_ACC_BROWSE)
+ {
+ ShowWindow(hDlg,SW_SHOWNORMAL);
+ SetForegroundWindow(hDlg);
+ }
+ else
+ DestroyWindow(hDlg);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DBLCLICKICON:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ break;
+ }
+ break;
+ }
+ case WM_YAMN_SHOWSELECTED:
+ {
+ int iSelect;
+ iSelect=SendMessage(GetDlgItem(hDlg,IDC_LISTMAILS),LVM_GETNEXTITEM,-1,MAKELPARAM((UINT)LVNI_FOCUSED,0)); // return item selected
+
+ if (iSelect!=-1)
+ {
+ LV_ITEMW item;
+ HYAMNMAIL ActualMail;
+
+ item.iItem=iSelect;
+ item.iSubItem=0;
+ item.mask=LVIF_PARAM | LVIF_STATE;
+ item.stateMask=0xFFFFFFFF;
+ ListView_GetItem(GetDlgItem(hDlg,IDC_LISTMAILS),&item);
+ ActualMail=(HYAMNMAIL)item.lParam;
+ if (NULL!=ActualMail)
+ {
+ //ShowEmailThread
+ PYAMN_MAILSHOWPARAM MailParam = new YAMN_MAILSHOWPARAM;
+ MailParam->account = GetWindowAccount(hDlg);
+ MailParam->mail = ActualMail;
+ if (NULL!=(MailParam->ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL))) {
+ HANDLE NewThread;
+ if (NULL!=(NewThread=CreateThread(NULL,0,ShowEmailThread,MailParam,0,NULL)))
+ {
+ //WaitForSingleObject(MailParam->ThreadRunningEV,INFINITE);
+ CloseHandle(NewThread);
+ }
+ CloseHandle(MailParam->ThreadRunningEV);
+ }
+ //delete MailParam;
+ }
+ }
+ } break;
+ case WM_SYSCOMMAND:
+ {
+ HACCOUNT ActualAccount;
+
+ if (NULL==(ActualAccount=GetWindowAccount(hDlg)))
+ break;
+ switch(wParam)
+ {
+ case SC_CLOSE:
+ DestroyWindow(hDlg);
+ break;
+ }
+ }
+ break;
+
+ case WM_COMMAND:
+ {
+ HACCOUNT ActualAccount;
+ int Items;
+
+ if (NULL==(ActualAccount=GetWindowAccount(hDlg)))
+ break;
+
+ switch(LOWORD(wParam))
+ {
+ case IDC_BTNCHECKALL:
+ ListView_SetItemState(GetDlgItem(hDlg,IDC_LISTMAILS), -1, 0, LVIS_SELECTED); // deselect all items
+ ListView_SetItemState(GetDlgItem(hDlg,IDC_LISTMAILS),-1, LVIS_SELECTED ,LVIS_SELECTED);
+ Items = ListView_GetItemCount(GetDlgItem(hDlg,IDC_LISTMAILS));
+ ListView_RedrawItems(GetDlgItem(hDlg,IDC_LISTMAILS), 0, Items);
+ UpdateWindow(GetDlgItem(hDlg,IDC_LISTMAILS));
+ SetFocus(GetDlgItem(hDlg,IDC_LISTMAILS));
+ break;
+
+ case IDC_BTNOK:
+ DestroyWindow(hDlg);
+ break;
+
+ case IDC_BTNAPP:
+ {
+ PROCESS_INFORMATION pi;
+ STARTUPINFOW si;
+
+ ZeroMemory(&si,sizeof(si));
+ si.cb=sizeof(si);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read enter\n");
+ #endif
+ if (ActualAccount->NewMailN.App!=NULL)
+ {
+ WCHAR *Command;
+ if (ActualAccount->NewMailN.AppParam!=NULL)
+ Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+wcslen(ActualAccount->NewMailN.AppParam)+6];
+ else
+ Command=new WCHAR[wcslen(ActualAccount->NewMailN.App)+6];
+
+ if (Command!=NULL)
+ {
+ lstrcpyW(Command,L"\"");
+ lstrcatW(Command,ActualAccount->NewMailN.App);
+ lstrcatW(Command,L"\" ");
+ if (ActualAccount->NewMailN.AppParam!=NULL)
+ lstrcatW(Command,ActualAccount->NewMailN.AppParam);
+ CreateProcessW(NULL,Command,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi);
+ delete[] Command;
+ }
+ }
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+ #ifdef DEBUG_SYNCHRO
+ else
+ DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read enter failed\n");
+ #endif
+ if (!(GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000))
+ DestroyWindow(hDlg);
+
+ }
+ break;
+ case IDC_BTNDEL:
+ {
+ LVITEMW item;
+ HYAMNMAIL FirstMail=NULL,ActualMail;
+ HANDLE ThreadRunningEV;
+ DWORD tid,Total=0;
+
+ // we use event to signal, that running thread has all needed stack parameters copied
+ if (NULL==(ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL)))
+ break;
+ int Items=ListView_GetItemCount(GetDlgItem(hDlg,IDC_LISTMAILS));
+
+ item.stateMask=0xFFFFFFFF;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n");
+ #endif
+ if (WAIT_OBJECT_0==WaitToWriteFcn(ActualAccount->MessagesAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n");
+ #endif
+ for (int i=0;i<Items;i++)
+ {
+ item.iItem=i;
+ item.iSubItem=0;
+ item.mask=LVIF_PARAM | LVIF_STATE;
+ item.stateMask=0xFFFFFFFF;
+ ListView_GetItem(GetDlgItem(hDlg,IDC_LISTMAILS),&item);
+ ActualMail=(HYAMNMAIL)item.lParam;
+ if (NULL==ActualMail)
+ break;
+ if (item.state & LVIS_SELECTED)
+ {
+ ActualMail->Flags|=YAMN_MSG_USERDELETE; //set to mail we are going to delete it
+ Total++;
+ }
+ }
+
+ // Enable write-access to mails
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n");
+ #endif
+ WriteDoneFcn(ActualAccount->MessagesAccessSO);
+
+ if (Total)
+ {
+ TCHAR DeleteMsg[1024];
+
+ wsprintf(DeleteMsg,TranslateT("Do you really want to delete %d selected mails?"),Total);
+ if (IDOK==MessageBox(hDlg,DeleteMsg,TranslateT("Delete confirmation"),MB_OKCANCEL | MB_ICONWARNING))
+ {
+ struct DeleteParam ParamToDeleteMails={YAMN_DELETEVERSION,ThreadRunningEV,ActualAccount,NULL};
+
+ // Find if there's mail marked to delete, which was deleted before
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write wait\n");
+ #endif
+ if (WAIT_OBJECT_0==WaitToWriteFcn(ActualAccount->MessagesAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write enter\n");
+ #endif
+ for (ActualMail=(HYAMNMAIL)ActualAccount->Mails;ActualMail!=NULL;ActualMail=ActualMail->Next)
+ {
+ if ((ActualMail->Flags & YAMN_MSG_DELETED) && ((ActualMail->Flags & YAMN_MSG_USERDELETE))) //if selected mail was already deleted
+ {
+ DeleteMessageFromQueueFcn((HYAMNMAIL *)&ActualAccount->Mails,ActualMail,1);
+ CallService(MS_YAMN_DELETEACCOUNTMAIL,(WPARAM)ActualAccount->Plugin,(LPARAM)ActualMail); //delete it from memory
+ continue;
+ }
+ }
+ // Set flag to marked mails that they can be deleted
+ SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE,0,YAMN_MSG_DELETEOK,1);
+ // Create new thread which deletes marked mails.
+ HANDLE NewThread;
+
+ if (NULL!=(NewThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ActualAccount->Plugin->Fcn->DeleteMailsFcnPtr,(LPVOID)&ParamToDeleteMails,0,&tid)))
+ {
+ WaitForSingleObject(ThreadRunningEV,INFINITE);
+ CloseHandle(NewThread);
+ }
+ // Enable write-access to mails
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNDEL:ActualAccountMsgsSO-write done\n");
+ #endif
+ WriteDoneFcn(ActualAccount->MessagesAccessSO);
+ }
+ }
+ else
+ //else mark messages that they are not to be deleted
+ SetRemoveFlagsInQueueFcn((HYAMNMAIL)ActualAccount->Mails,YAMN_MSG_DISPLAY | YAMN_MSG_USERDELETE,0,YAMN_MSG_USERDELETE,0);
+ }
+ }
+ CloseHandle(ThreadRunningEV);
+ if (DBGetContactSettingByte(NULL, YAMN_DBMODULE, YAMN_CLOSEDELETE, 0))
+ DestroyWindow(hDlg);
+
+ }
+ break;
+ }
+ }
+ break;
+ case WM_SIZE:
+ if (wParam==SIZE_RESTORED)
+ {
+ LONG x=LOWORD(lParam); //((LPRECT)lParam)->right-((LPRECT)lParam)->left;
+ LONG y=HIWORD(lParam); //((LPRECT)lParam)->bottom-((LPRECT)lParam)->top;
+ MoveWindow(GetDlgItem(hDlg,IDC_BTNDEL), 5 ,y-5-25,(x-20)/3,25,TRUE); //where to put DELETE button while resizing
+ MoveWindow(GetDlgItem(hDlg,IDC_BTNCHECKALL),10+ (x-20)/3,y-5-25,(x-20)/6,25,TRUE); //where to put CHECK ALL button while resizing
+ MoveWindow(GetDlgItem(hDlg,IDC_BTNAPP), 15+ (x-20)/3 + (x-20)/6,y-5-25,(x-20)/3,25,TRUE); //where to put RUN APP button while resizing
+ MoveWindow(GetDlgItem(hDlg,IDC_BTNOK), 20+2*(x-20)/3 + (x-20)/6 ,y-5-25,(x-20)/6,25,TRUE); //where to put OK button while resizing
+ MoveWindow(GetDlgItem(hDlg,IDC_LISTMAILS), 5 ,5 ,x-10 ,y-55,TRUE); //where to put list mail window while resizing
+ MoveWindow(GetDlgItem(hDlg,IDC_STSTATUS), 5 ,y-5-45 ,x-10 ,15,TRUE); //where to put account status text while resizing
+ }
+// break;
+ return 0;
+ case WM_GETMINMAXINFO:
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.x=MAILBROWSER_MINXSIZE;
+ ((LPMINMAXINFO)lParam)->ptMinTrackSize.y=MAILBROWSER_MINYSIZE;
+ return 0;
+ case WM_TIMER:
+ {
+ NOTIFYICONDATA nid;
+ struct CMailWinUserInfo *mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER);
+
+ ZeroMemory(&nid,sizeof(nid));
+ nid.cbSize=sizeof(NOTIFYICONDATA);
+ nid.hWnd=hDlg;
+ nid.uID=0;
+ nid.uFlags=NIF_ICON;
+ if (mwui->TrayIconState==0)
+ nid.hIcon=g_LoadIconEx(0);
+ else
+ nid.hIcon=g_LoadIconEx(2);
+ Shell_NotifyIcon(NIM_MODIFY,&nid);
+ mwui->TrayIconState=!mwui->TrayIconState;
+// UpdateWindow(hDlg);
+ }
+ break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom)
+ {
+
+ case IDC_LISTMAILS:
+ {
+
+ switch(((LPNMHDR)lParam)->code)
+ {
+ case NM_DBLCLK:
+ SendMessage(hDlg,WM_YAMN_SHOWSELECTED,0,0);
+ break;
+ case LVN_COLUMNCLICK:
+ HACCOUNT ActualAccount;
+ if (NULL!=(ActualAccount=GetWindowAccount(hDlg))) {
+ NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lParam;
+ if (WAIT_OBJECT_0==WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:COLUMNCLICK:ActualAccountSO-read enter\n");
+ #endif
+ switch((int)pNMListView->iSubItem)
+ {
+ case 0:
+ bFrom = !bFrom;
+ break;
+ case 1:
+ bSub = !bSub;
+ break;
+ case 2:
+ bSize = !bSize;
+ break;
+ case 3:
+ bDate = !bDate;
+ break;
+ default:
+ break;
+ }
+ ListView_SortItems(pNMListView->hdr.hwndFrom,ListViewCompareProc,pNMListView->iSubItem);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:BTNAPP:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ } }
+ break;
+
+ case NM_CUSTOMDRAW:
+ {
+ HACCOUNT ActualAccount;
+ LPNMLVCUSTOMDRAW cd=(LPNMLVCUSTOMDRAW)lParam;
+ LONG_PTR PaintCode;
+
+ if (NULL==(ActualAccount=GetWindowAccount(hDlg)))
+ break;
+
+ switch(cd->nmcd.dwDrawStage)
+ {
+ case CDDS_PREPAINT:
+ PaintCode=CDRF_NOTIFYITEMDRAW;
+ break;
+ case CDDS_ITEMPREPAINT:
+ PaintCode=CDRF_NOTIFYSUBITEMDRAW;
+ break;
+ case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
+ {
+// COLORREF crText, crBkgnd;
+// crText= RGB(128,128,255);
+ HYAMNMAIL ActualMail;
+ BOOL umma;
+
+ {
+ struct CMailWinUserInfo *mwui;
+ mwui=(struct CMailWinUserInfo *)GetWindowLongPtr(hDlg,DWLP_USER);
+ umma= mwui->UpdateMailsMessagesAccess;
+ }
+ ActualMail=(HYAMNMAIL)cd->nmcd.lItemlParam;
+ if (!ActualMail)
+ ActualMail=(HYAMNMAIL)readItemLParam(cd->nmcd.hdr.hwndFrom,cd->nmcd.dwItemSpec);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait\n");
+ #endif
+ if (!umma)
+ if (WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->MessagesAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read wait failed\n");
+ #endif
+ return 0;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read enter\n");
+ #endif
+ switch(ActualMail->Flags & YAMN_MSG_SPAMMASK)
+ {
+ case YAMN_MSG_SPAML1:
+ case YAMN_MSG_SPAML2:
+ cd->clrText=RGB(150,150,150);
+ break;
+ case YAMN_MSG_SPAML3:
+ cd->clrText=RGB(200,200,200);
+ cd->clrTextBk=RGB(160,160,160);
+ break;
+ case 0:
+ if (cd->nmcd.dwItemSpec & 1)
+ cd->clrTextBk=RGB(230,230,230);
+ break;
+ default:
+ break;
+ }
+ if (ActualMail->Flags & YAMN_MSG_UNSEEN)
+ cd->clrTextBk=RGB(220,235,250);
+ PaintCode=CDRF_DODEFAULT;
+
+ if (!umma)
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:DRAWITEM:ActualAccountMsgsSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->MessagesAccessSO);
+ }
+
+ break;
+ }
+ }
+ SetWindowLongPtr(hDlg,DWLP_MSGRESULT,PaintCode);
+ return 1;
+ }
+ }
+ }
+ }
+ break;
+ case WM_CONTEXTMENU:
+ {
+ if ( GetWindowLongPtr(( HWND )wParam, GWLP_ID ) == IDC_LISTMAILS) {
+ //MessageBox(0,"LISTHEADERS","Debug",0);
+ HWND hList = GetDlgItem( hDlg, IDC_LISTMAILS );
+ POINT pt = { (signed short)LOWORD( lParam ), (signed short)HIWORD( lParam ) };
+ HTREEITEM hItem = 0;
+ if (pt.x==-1) pt.x = 0;
+ if (pt.y==-1) pt.y = 0;
+ if (int numRows = ListView_GetItemCount(hList)) {
+ HMENU hMenu = CreatePopupMenu();
+ AppendMenu(hMenu, MF_STRING, (UINT_PTR)1, TranslateT("Copy Selected"));
+ AppendMenu(hMenu, MF_STRING, (UINT_PTR)2, TranslateT("Copy All"));
+ AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
+ AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel"));
+ int nReturnCmd = TrackPopupMenu( hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL );
+ DestroyMenu( hMenu );
+ if (nReturnCmd>0){
+ int courRow=0;
+ size_t sizeNeeded = 0;
+ TCHAR from[128]={0}, subject[256]={0}, size[16]={0}, date[64]={0};
+ for (courRow=0;courRow<numRows;courRow++) {
+ if ((nReturnCmd==1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED)==0)) continue;
+ ListView_GetItemText(hList, courRow, 0, from, SIZEOF(from));
+ ListView_GetItemText(hList, courRow, 1, subject, SIZEOF(subject));
+ ListView_GetItemText(hList, courRow, 2, size, SIZEOF(size));
+ ListView_GetItemText(hList, courRow, 3, date, SIZEOF(date));
+ sizeNeeded += 5+_tcslen(from)+_tcslen(subject)+_tcslen(size)+_tcslen(date);
+ }
+ if (sizeNeeded && OpenClipboard(hDlg)) {
+ EmptyClipboard();
+ HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE,(sizeNeeded+1)*sizeof(TCHAR));
+ TCHAR *buff = (TCHAR *)GlobalLock(hData);
+ int courPos = 0;
+ for (courRow=0; courRow < numRows; courRow++) {
+ if ((nReturnCmd==1) && (ListView_GetItemState(hList, courRow, LVIS_SELECTED)==0)) continue;
+ ListView_GetItemText(hList, courRow, 0, from, SIZEOF(from));
+ ListView_GetItemText(hList, courRow, 1, subject, SIZEOF(subject));
+ ListView_GetItemText(hList, courRow, 2, size, SIZEOF(size));
+ ListView_GetItemText(hList, courRow, 3, date, SIZEOF(date));
+ courPos += _stprintf(&buff[courPos], _T("%s\t%s\t%s\t%s\r\n"), from, subject, size, date);
+ }
+ GlobalUnlock(hData);
+ #if defined( _UNICODE )
+ SetClipboardData(CF_UNICODETEXT,hData);
+ #else
+ SetClipboardData(CF_TEXT,hData);
+ #endif
+ CloseClipboard();
+ }
+ }
+ }
+ } }
+ break; // just in case
+ default:
+ return 0;
+ }
+// return DefWindowProc(hDlg,msg,wParam,lParam);
+ return 0;
+}
+
+LRESULT CALLBACK ListViewSubclassProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ HWND hwndParent = GetParent(hDlg);
+
+ switch(msg) {
+ case WM_GETDLGCODE :
+ {
+ LPMSG lpmsg;
+ if ( ( lpmsg = (LPMSG)lParam ) != NULL ) {
+ if ( lpmsg->message == WM_KEYDOWN
+ && lpmsg->wParam == VK_RETURN)
+ return DLGC_WANTALLKEYS;
+ }
+ break;
+ }
+ case WM_KEYDOWN:
+ {
+
+ BOOL isCtrl = GetKeyState(VK_CONTROL) & 0x8000;
+ BOOL isShift = GetKeyState(VK_SHIFT) & 0x8000;
+ BOOL isAlt = GetKeyState(VK_MENU) & 0x8000;
+
+ switch (wParam)
+ {
+ case 'A': // ctrl-a
+ if (!isAlt && !isShift && isCtrl) SendMessage(hwndParent,WM_COMMAND,IDC_BTNCHECKALL,0);
+ break;
+ case VK_RETURN:
+ case VK_SPACE:
+ if (!isAlt && !isShift && !isCtrl) SendMessage(hwndParent,WM_YAMN_SHOWSELECTED,0,0);
+ break;
+ case VK_DELETE:
+ SendMessage(hwndParent,WM_COMMAND,IDC_BTNDEL,0);
+ break;
+ }
+
+ break;
+
+ }
+ }
+ return CallWindowProc(OldListViewSubclassProc, hDlg, msg, wParam, lParam);
+}
+
+DWORD WINAPI MailBrowser(LPVOID Param)
+{
+ MSG msg;
+
+ HWND hMailBrowser;
+ BOOL WndFound=FALSE;
+ HACCOUNT ActualAccount;
+ struct MailBrowserWinParam MyParam;
+
+ MyParam=*(struct MailBrowserWinParam *)Param;
+ ActualAccount=MyParam.account;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+ #endif
+ SCIncFcn(ActualAccount->UsingThreads);
+
+// we will not use params in stack anymore
+ SetEvent(MyParam.ThreadRunningEV);
+
+ __try
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read wait failed\n");
+ #endif
+ return 0;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read enter\n");
+ #endif
+ if (!(ActualAccount->AbilityFlags & YAMN_ACC_BROWSE))
+ {
+ MyParam.nflags=MyParam.nflags & ~YAMN_ACC_MSG;
+ MyParam.nnflags=MyParam.nnflags & ~YAMN_ACC_MSG;
+ }
+ if (!(ActualAccount->AbilityFlags & YAMN_ACC_POPUP))
+ MyParam.nflags=MyParam.nflags & ~YAMN_ACC_POP;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+
+ if (NULL!=(hMailBrowser=WindowList_Find(YAMNVar.NewMailAccountWnd,ActualAccount)))
+ WndFound=TRUE;
+ if ((hMailBrowser==NULL) && ((MyParam.nflags & YAMN_ACC_MSG) || (MyParam.nflags & YAMN_ACC_ICO) || (MyParam.nnflags & YAMN_ACC_MSG)))
+ {
+ hMailBrowser=CreateDialogParamW(YAMNVar.hInst,MAKEINTRESOURCEW(IDD_DLGVIEWMESSAGES),NULL,DlgProcYAMNMailBrowser,(LPARAM)&MyParam);
+ SendMessageW(hMailBrowser,WM_SETICON,(WPARAM)ICON_BIG,(LPARAM)g_LoadIconEx(2,true));
+ SendMessageW(hMailBrowser,WM_SETICON,(WPARAM)ICON_SMALL,(LPARAM)g_LoadIconEx(2));
+ MoveWindow(hMailBrowser,PosX,PosY,SizeX,SizeY,TRUE);
+ }
+
+ if (hMailBrowser!=NULL)
+ {
+ struct CChangeContent Params={MyParam.nflags,MyParam.nnflags}; //if this thread created window, just post message to update mails
+
+ SendMessageW(hMailBrowser,WM_YAMN_CHANGECONTENT,(WPARAM)ActualAccount,(LPARAM)&Params); //we ensure this will do the thread who created the browser window
+ }
+ else
+ UpdateMails(NULL,ActualAccount,MyParam.nflags,MyParam.nnflags); //update mails without displaying or refreshing any window
+
+ if ((hMailBrowser!=NULL) && !WndFound) //we process message loop only for thread that created window
+ {
+ while(GetMessage(&msg,NULL,0,0))
+ {
+ if (!IsDialogMessage(hMailBrowser, &msg))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ }
+
+ if ((!WndFound) && (ActualAccount->Plugin->Fcn!=NULL) && (ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr!=NULL) && ActualAccount->AbleToWork)
+ ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr();
+ }
+ __finally
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"MailBrowser:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+ #endif
+ SCDecFcn(ActualAccount->UsingThreads);
+ }
+ return 1;
+}
+
+INT_PTR RunMailBrowserSvc(WPARAM wParam,LPARAM lParam)
+{
+ DWORD tid;
+ //an event for successfull copy parameters to which point a pointer in stack for new thread
+ HANDLE ThreadRunningEV;
+ PYAMN_MAILBROWSERPARAM Param=(PYAMN_MAILBROWSERPARAM)wParam;
+
+ if ((DWORD)lParam!=YAMN_MAILBROWSERVERSION)
+ return 0;
+
+ if (NULL!=(ThreadRunningEV=CreateEvent(NULL,FALSE,FALSE,NULL)))
+ {
+ HANDLE NewThread;
+
+ Param->ThreadRunningEV=ThreadRunningEV;
+ if (NULL!=(NewThread=CreateThread(NULL,0,MailBrowser,Param,0,&tid)))
+ {
+ WaitForSingleObject(ThreadRunningEV,INFINITE);
+ CloseHandle(NewThread);
+ }
+ CloseHandle(ThreadRunningEV);
+ return 1;
+ }
+ return 0;
+}
diff --git a/plugins/YAMN/src/debug.cpp b/plugins/YAMN/src/debug.cpp new file mode 100644 index 0000000000..9b9793a965 --- /dev/null +++ b/plugins/YAMN/src/debug.cpp @@ -0,0 +1,139 @@ +/*
+ * YAMN plugin main file
+ * Miranda homepage: http://miranda-icq.sourceforge.net/
+ *
+ * Debug functions used in DEBUG release (you need to global #define DEBUG to get debug version)
+ *
+ * (c) majvan 2002-2004
+ */
+
+#include "yamn.h"
+#include "debug.h"
+#ifdef YAMN_DEBUG
+#include "version.h"
+
+#if defined (WIN9X)
+ #define YAMN_VER "YAMN " YAMN_VERSION_C " (Win9x)"
+#elif defined(WIN2IN1)
+ #define YAMN_VER "YAMN " YAMN_VERSION_C " (2in1)"
+#else
+ #define YAMN_VER "YAMN " YAMN_VERSION_C " (WinNT)"
+#endif
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+TCHAR DebugUserDirectory[MAX_PATH] = _T(".");
+LPCRITICAL_SECTION FileAccessCS;
+
+#ifdef DEBUG_SYNCHRO
+TCHAR DebugSynchroFileName2[]=_T("%s\\yamn-debug.synchro.log");
+HANDLE SynchroFile;
+#endif
+
+#ifdef DEBUG_COMM
+TCHAR DebugCommFileName2[]=_T("%s\\yamn-debug.comm.log");
+HANDLE CommFile;
+#endif
+
+#ifdef DEBUG_DECODE
+TCHAR DebugDecodeFileName2[]=_T("%s\\yamn-debug.decode.log");
+HANDLE DecodeFile;
+#endif
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+void InitDebug()
+{
+#if defined (DEBUG_SYNCHRO) || defined (DEBUG_COMM) || defined (DEBUG_DECODE)
+ TCHAR DebugFileName[MAX_PATH];
+#endif
+ if (FileAccessCS==NULL)
+ {
+ FileAccessCS=new CRITICAL_SECTION;
+ InitializeCriticalSection(FileAccessCS);
+ }
+
+#ifdef DEBUG_SYNCHRO
+ _stprintf(DebugFileName,DebugSynchroFileName2,DebugUserDirectory);
+
+ SynchroFile=CreateFile(DebugFileName,GENERIC_WRITE,FILE_SHARE_WRITE|FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL);
+ DebugLog(SynchroFile,"Synchro debug file created by %s\n",YAMN_VER);
+#endif
+
+#ifdef DEBUG_COMM
+ _stprintf(DebugFileName,DebugCommFileName2,DebugUserDirectory);
+
+ CommFile=CreateFile(DebugFileName,GENERIC_WRITE,FILE_SHARE_WRITE|FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL);
+ DebugLog(CommFile,"Communication debug file created by %s\n",YAMN_VER);
+#endif
+
+#ifdef DEBUG_DECODE
+ _stprintf(DebugFileName,DebugDecodeFileName2,DebugUserDirectory);
+
+ DecodeFile=CreateFile(DebugFileName,GENERIC_WRITE,FILE_SHARE_WRITE|FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL);
+ DebugLog(DecodeFile,"Decoding kernel debug file created by %s\n",YAMN_VER);
+#endif
+}
+
+void UnInitDebug()
+{
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"File is being closed normally.");
+ CloseHandle(SynchroFile);
+#endif
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"File is being closed normally.");
+ CloseHandle(CommFile);
+#endif
+#ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"File is being closed normally.");
+ CloseHandle(DecodeFile);
+#endif
+}
+
+
+void DebugLog(HANDLE File,const char *fmt,...)
+{
+ char *str;
+ char tids[32];
+ va_list vararg;
+ int strsize;
+ DWORD Written;
+
+ va_start(vararg,fmt);
+ str=(char *)malloc(strsize=65536);
+ mir_snprintf(tids, SIZEOF(tids), "[%x]",GetCurrentThreadId());
+ while(_vsnprintf(str,strsize,fmt,vararg)==-1)
+ str=(char *)realloc(str,strsize+=65536);
+ va_end(vararg);
+ EnterCriticalSection(FileAccessCS);
+ WriteFile(File,tids,(DWORD)strlen(tids),&Written,NULL);
+ WriteFile(File,str,(DWORD)strlen(str),&Written,NULL);
+ LeaveCriticalSection(FileAccessCS);
+ free(str);
+}
+
+void DebugLogW(HANDLE File,const WCHAR *fmt,...)
+{
+ WCHAR *str;
+ char tids[32];
+ va_list vararg;
+ int strsize;
+ DWORD Written;
+
+ va_start(vararg,fmt);
+ str=(WCHAR *)malloc((strsize=65536)*sizeof(WCHAR));
+ mir_snprintf(tids, SIZEOF(tids), "[%x]",GetCurrentThreadId());
+ while(_vsnwprintf(str,strsize,fmt,vararg)==-1)
+ str=(WCHAR *)realloc(str,(strsize+=65536)*sizeof(WCHAR));
+ va_end(vararg);
+ EnterCriticalSection(FileAccessCS);
+ WriteFile(File,tids,(DWORD)strlen(tids),&Written,NULL);
+ WriteFile(File,str,(DWORD)wcslen(str)*sizeof(WCHAR),&Written,NULL);
+ LeaveCriticalSection(FileAccessCS);
+ free(str);
+}
+
+#endif //ifdef DEBUG
\ No newline at end of file diff --git a/plugins/YAMN/src/debug.h b/plugins/YAMN/src/debug.h new file mode 100644 index 0000000000..3bde9ddc81 --- /dev/null +++ b/plugins/YAMN/src/debug.h @@ -0,0 +1,67 @@ +#ifndef __DEBUG_H
+#define __DEBUG_H
+
+// #define YAMN_DEBUG
+
+//#define YAMN_VER_BETA
+//#define YAMN_VER_BETA_CRASHONLY
+
+#ifdef YAMN_DEBUG
+
+//#pragma comment(lib, "th32.lib")
+
+#if !defined(_WIN32_WINNT)
+#define _WIN32_WINNT 0x0501 // WinXP only
+#endif
+#define VC_EXTRALEAN
+#include <windows.h>
+#include <tlhelp32.h>
+#include <stdio.h>
+#include <shlwapi.h>
+
+//#define DEBUG_SYNCHRO //debug synchro to a file
+//#define DEBUG_COMM //debug communiation to a file
+//#define DEBUG_DECODE //debug header decoding to a file
+//#define DEBUG_DECODECODEPAGE //add info about codepage used in conversion
+//#define DEBUG_DECODEBASE64 //add info about base64 result
+//#define DEBUG_DECODEQUOTED //add info about quoted printable result
+//#define DEBUG_FILEREAD //debug file reading to message boxes
+//#define DEBUG_FILEREADMESSAGES //debug file reading messages to message boxes
+
+void DebugLog(HANDLE,const char *fmt,...);
+void DebugLogW(HANDLE File,const WCHAR *fmt,...);
+
+#ifdef DEBUG_SYNCHRO
+// Used for synchronization debug
+extern HANDLE SynchroFile;
+#endif
+
+#ifdef DEBUG_COMM
+// Used for communication debug
+extern HANDLE CommFile;
+#endif
+
+#ifdef DEBUG_DECODE
+// Used for decoding debug
+extern HANDLE DecodeFile;
+#endif
+
+#if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES)
+DWORD ReadStringFromMemory(char **Parser,char *End,char **StoreTo,char *DebugString);
+
+DWORD ReadStringFromMemoryW(char **Parser,TCHAR *End,char **StoreTo,TCHAR *DebugString);
+
+#else
+DWORD ReadStringFromMemory(char **Parser,char *End,char **StoreTo);
+
+DWORD ReadStringFromMemoryW(WCHAR **Parser,WCHAR *End,WCHAR **StoreTo);
+
+#endif
+
+//#ifdef DEBUG_ACCOUNTS
+//int GetAccounts();
+//void WriteAccounts();
+//#endif
+
+#endif //YAMN_DEBUG
+#endif //_DEBUG_H
diff --git a/plugins/YAMN/src/filterplugin.cpp b/plugins/YAMN/src/filterplugin.cpp new file mode 100644 index 0000000000..8f61003293 --- /dev/null +++ b/plugins/YAMN/src/filterplugin.cpp @@ -0,0 +1,204 @@ +/*
+ * YAMN plugin export functions for filtering
+ *
+ * (c) majvan 2002-2004
+ */
+
+#include "yamn.h"
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+PYAMN_FILTERPLUGINQUEUE FirstFilterPlugin=NULL;
+
+INT_PTR RegisterFilterPluginSvc(WPARAM,LPARAM);
+
+//Removes plugin from queue and deletes its structures
+INT_PTR UnregisterFilterPlugin(HYAMNFILTERPLUGIN Plugin);
+
+INT_PTR UnregisterFilterPluginSvc(WPARAM wParam,LPARAM lParam);
+
+//Removes all filter plugins
+INT_PTR UnregisterFilterPlugins();
+
+INT_PTR FilterMailSvc(WPARAM,LPARAM);
+
+//Sets imported functions for an plugin and therefore it starts plugin to be registered and running
+// Plugin- plugin, which wants to set its functions
+// Importance- importance of plugin (see m_filterplugin.h)
+// YAMNFilterFcn- pointer to imported functions
+// YAMNfilterFcnVer- version of YAMN_FILTERIMPORTFCN, use YAMN_FILTERIMPORTFCNVERSION
+// returns nonzero if success
+int WINAPI SetFilterPluginFcnImportFcn(HYAMNFILTERPLUGIN Plugin,DWORD Importance,PYAMN_FILTERIMPORTFCN YAMNFilterFcn,DWORD YAMNFilterFcnVer);
+
+struct CExportedFunctions FilterPluginExportedFcn[]=
+{
+ {YAMN_SETFILTERPLUGINFCNIMPORTID,(void *)SetFilterPluginFcnImportFcn},
+};
+
+struct CExportedServices FilterPluginExportedSvc[]=
+{
+ {MS_YAMN_REGISTERFILTERPLUGIN,RegisterFilterPluginSvc},
+ {MS_YAMN_UNREGISTERFILTERPLUGIN,UnregisterFilterPluginSvc},
+};
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+INT_PTR RegisterFilterPluginSvc(WPARAM wParam,LPARAM lParam)
+{
+ PYAMN_FILTERREGISTRATION Registration=(PYAMN_FILTERREGISTRATION)wParam;
+ HYAMNFILTERPLUGIN Plugin;
+
+ if (lParam!=YAMN_FILTERREGISTRATIONVERSION)
+ return 0;
+ if ((Registration->Name==NULL) || (Registration->Ver==NULL))
+ return NULL;
+ if (NULL==(Plugin=new YAMN_FILTERPLUGIN))
+ return NULL;
+
+ Plugin->PluginInfo=Registration;
+
+ Plugin->FilterFcn=NULL;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"::: YAMN- new filter registered: %0x (%s) :::\n",Plugin,Registration->Name);
+#endif
+ return (INT_PTR)Plugin;
+}
+
+INT_PTR UnregisterFilterPlugin(HYAMNFILTERPLUGIN Plugin)
+{
+ PYAMN_FILTERPLUGINQUEUE Parser,Found;
+
+ if (FirstFilterPlugin->Plugin==Plugin)
+ {
+ Found=FirstFilterPlugin;
+ FirstFilterPlugin=FirstFilterPlugin->Next;
+ }
+ else
+ {
+ for (Parser=FirstFilterPlugin;(Parser->Next!=NULL) && (Plugin!=Parser->Next->Plugin);Parser=Parser->Next);
+ if (Parser->Next!=NULL)
+ {
+ Found=Parser->Next;
+ Parser->Next=Parser->Next->Next;
+ }
+ else
+ Found=NULL;
+ }
+ if (Found!=NULL)
+ {
+ if (Plugin->FilterFcn->UnLoadFcn!=NULL)
+ Plugin->FilterFcn->UnLoadFcn((void *)0);
+
+ delete Found->Plugin;
+ delete Found;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"::: YAMN- filter %0x unregistered :::\n",Plugin);
+#endif
+ }
+ else
+ return 0;
+ return 1;
+}
+
+INT_PTR UnregisterFilterPluginSvc(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNFILTERPLUGIN Plugin=(HYAMNFILTERPLUGIN)wParam;
+
+ EnterCriticalSection(&PluginRegCS);
+ UnregisterFilterPlugin(Plugin);
+ LeaveCriticalSection(&PluginRegCS);
+ return 1;
+}
+
+INT_PTR UnregisterFilterPlugins()
+{
+ EnterCriticalSection(&PluginRegCS);
+//We remove protocols from the protocol list
+ while(FirstFilterPlugin!=NULL)
+ UnregisterFilterPlugin(FirstFilterPlugin->Plugin);
+ LeaveCriticalSection(&PluginRegCS);
+ return 1;
+}
+
+int WINAPI SetFilterPluginFcnImportFcn(HYAMNFILTERPLUGIN Plugin,DWORD Importance,PYAMN_FILTERIMPORTFCN YAMNFilterFcn,DWORD YAMNFilterFcnVer)
+{
+ PYAMN_FILTERPLUGINQUEUE Parser,Previous;
+
+ if (YAMNFilterFcnVer!=YAMN_FILTERIMPORTFCNVERSION)
+ return 0;
+ if (YAMNFilterFcn==NULL)
+ return 0;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"::: YAMN- filter %0x import succeed :::\n",Plugin);
+#endif
+ Plugin->Importance=Importance;
+ Plugin->FilterFcn=YAMNFilterFcn;
+
+ EnterCriticalSection(&PluginRegCS);
+//We add protocol to the protocol list
+ for (Previous=NULL,Parser=FirstFilterPlugin;Parser!=NULL && Parser->Next!=NULL && Parser->Plugin->Importance<=Importance;Previous=Parser,Parser=Parser->Next);
+ if (Previous==NULL) //insert to the beginnig of queue
+ {
+ FirstFilterPlugin=new YAMN_FILTERPLUGINQUEUE;
+ FirstFilterPlugin->Plugin=Plugin;
+ FirstFilterPlugin->Next=Parser;
+ }
+ else
+ {
+ Previous->Next=new YAMN_FILTERPLUGINQUEUE;
+ Previous=Previous->Next; //leave previous, go to actual plugin
+ Previous->Plugin=Plugin;
+ Previous->Next=Parser; //and in actual plugin set, that next plugin is the one we insert in front of
+ }
+
+ LeaveCriticalSection(&PluginRegCS);
+ return 1;
+}
+
+INT_PTR FilterMailSvc(WPARAM wParam,LPARAM lParam)
+{
+ HACCOUNT Account=(HACCOUNT)wParam;
+ HYAMNMAIL Mail=(HYAMNMAIL)lParam;
+ PYAMN_FILTERPLUGINQUEUE ActualPlugin;
+
+ EnterCriticalSection(&PluginRegCS);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"FilterMail:ActualAccountMsgsSO-write wait\n");
+#endif
+ WaitToWriteFcn(Account->MessagesAccessSO);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"FilterMail:ActualAccountMsgsSO-write enter\n");
+#endif
+ for (ActualPlugin=FirstFilterPlugin;ActualPlugin!=NULL;ActualPlugin=ActualPlugin->Next)
+ {
+ if (ActualPlugin->Plugin->FilterFcn->FilterMailFcnPtr!=NULL)
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tFiltering Mail, running plugin %0x to filter mail\n",ActualPlugin->Plugin);
+#endif
+ ActualPlugin->Plugin->FilterFcn->FilterMailFcnPtr(Account,YAMN_ACCOUNTVERSION,Mail,YAMN_MAILVERSION);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tFiltering Mail done\n");
+#endif
+ }
+ }
+ Mail->Flags|=YAMN_MSG_FILTERED;
+
+//Set mail flags according to spamlevel settings
+ if ((Mail->Flags & YAMN_MSG_SPAMMASK) > YAMN_MSG_SPAML1)
+ Mail->Flags=Mail->Flags & ~(YAMN_MSG_BROWSER | YAMN_MSG_POPUP | YAMN_MSG_SYSTRAY | YAMN_MSG_SOUND | YAMN_MSG_APP | YAMN_MSG_NEVENT);
+ if (YAMN_MSG_SPAML(Mail->Flags,YAMN_MSG_SPAML3) || YAMN_MSG_SPAML(Mail->Flags,YAMN_MSG_SPAML4))
+ Mail->Flags=Mail->Flags | (YAMN_MSG_AUTODELETE | YAMN_MSG_DELETEOK); //set message to delete
+ if (YAMN_MSG_SPAML(Mail->Flags,YAMN_MSG_SPAML3))
+ Mail->Flags=Mail->Flags & ~(YAMN_MSG_MEMDELETE); //set message not to delete it immidiatelly from memory
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"FilterMail:ActualAccountMsgsSO-write done\n");
+#endif
+ WriteDoneFcn(Account->MessagesAccessSO);
+ LeaveCriticalSection(&PluginRegCS);
+ return 1;
+}
diff --git a/plugins/YAMN/src/mails/decode.cpp b/plugins/YAMN/src/mails/decode.cpp new file mode 100644 index 0000000000..867ed7ff25 --- /dev/null +++ b/plugins/YAMN/src/mails/decode.cpp @@ -0,0 +1,558 @@ +/*
+ * This code implements decoding encoded MIME header in style
+ * =?iso-8859-2?Q? "User using email in central Europe characters such as =E9" ?=
+ *
+ * (c) majvan 2002-2004
+ */
+#include "../yamn.h"
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+struct _tcptable CodePageNamesAll[]=
+{
+ { "ANSI", "",TRUE,CP_ACP},
+ { "WINDOWS-1", "250",0,1250},
+ { "WINDOWS-1", "251",0,1251},
+ { "WINDOWS-1", "252",0,1252},
+ { "WINDOWS-1", "253",0,1253},
+ { "WINDOWS-1", "254",0,1254},
+ { "WINDOWS-1", "255",0,1255},
+ { "WINDOWS-1", "256",0,1256},
+ { "WINDOWS-1", "257",0,1257},
+ { "WINDOWS-1", "258",0,1258},
+ { "CP1", "250",0,1250},
+ { "CP1", "251",0,1251},
+ { "CP1", "252",0,1252},
+ { "CP1", "253",0,1253},
+ { "CP1", "254",0,1254},
+ { "CP1", "255",0,1255},
+ { "CP1", "256",0,1256},
+ { "CP1", "257",0,1257},
+ { "CP1", "258",0,1258},
+ { "ANSI-1", "250",0,1250},
+ { "ANSI-1", "251",0,1251},
+ { "ANSI-1", "252",0,1252},
+ { "ANSI-1", "253",0,1253},
+ { "ANSI-1", "254",0,1254},
+ { "ANSI-1", "255",0,1255},
+ { "ANSI-1", "256",0,1256},
+ { "ANSI-1", "257",0,1257},
+ { "ANSI-1", "258",0,1258},
+ { "KOI8", "-R",0,20866},
+ { "KOI8", "",0,20866},
+ { "KOI8", "-U",0,21866},
+ { "KOI8", "-RU",0,21866},
+ { "US-", "ASCII",0,20127},
+ { "CP", "367",0,20127},
+ { "ASCII", "",0,20127},
+ { "ASCII", "7",0,20127},
+ { "ISO-8859", "-1",0,28591},
+ { "ISO-8859", "-2",0,28592},
+ { "ISO-8859", "-3",0,28593},
+ { "ISO-8859", "-4",0,28594},
+ { "ISO-8859", "-5",0,28595},
+ { "ISO-8859", "-6",0,28596},
+ { "ISO-8859", "-7",0,28597},
+ { "ISO-8859", "-8",0,28598},
+ { "ISO-8859", "-9",0,28599},
+ { "ISO-8859", "-15",0,28605},
+ { "ISO_8859", "-1",0,28591},
+ { "ISO_8859", "-2",0,28592},
+ { "ISO_8859", "-3",0,28593},
+ { "ISO_8859", "-4",0,28594},
+ { "ISO_8859", "-5",0,28595},
+ { "ISO_8859", "-6",0,28596},
+ { "ISO_8859", "-7",0,28597},
+ { "ISO_8859", "-8",0,28598},
+ { "ISO_8859", "-9",0,28599},
+ { "ISO_8859", "-15",0,28605},
+ { "ISO-", "10646-USC2",0,1200},
+ { "ISO-2022", "/2-JP",0,50220},
+ { "ISO-2022", "-JP",0,50221},
+ { "ISO-2022", "/JIS-JP",0,50222},
+ { "ISO-2022", "-KR",0,50225},
+ { "ISO-2022", "-CH(SP)",0,50227},
+ { "ISO-2022", "-CH(TR)",0,50229},
+ { "UTF-", "7",0,65000},
+ { "UTF-", "8",0,65001},
+ { "ARAB-", "TRANSPARENT",0,710},
+ { "ASMO-", "TRANSPARENT",0,720},
+ { "ASMO-", "449",0,709},
+ { "ASMO-", "708",0,708},
+ { "BIG5", "",0,950},
+ { "EUC-", "CH(SP)",0,51936},
+ { "EUC-", "CH(TR)",0,51950},
+ { "EUC-", "JP",0,51932},
+ { "EUC-", "KR",0,51949},
+ { "GB-", "2312",0,20936},
+ { "GB", "2312",0,20936},
+ { "HZGB-", "2312",0,52936},
+ { "IBM-", "037",0,37},
+ { "IBM-", "290",0,290},
+ { "IBM-", "437",0,437},
+ { "IBM-", "500",0,500},
+ { "IBM-", "775",0,775},
+ { "IBM-", "850",0,850},
+ { "IBM-", "852",0,852},
+ { "IBM-", "855",0,855},
+ { "IBM-", "857",0,857},
+ { "IBM-", "860",0,860},
+ { "IBM-", "861",0,861},
+ { "IBM-", "862",0,862},
+ { "IBM-", "863",0,863},
+ { "IBM-", "864",0,864},
+ { "IBM-", "865",0,865},
+ { "IBM-", "866",0,866},
+ { "IBM-", "869",0,869},
+ { "IBM-", "870",0,870},
+ { "IBM-", "875",0,875},
+ { "IBM-", "1026",0,1026},
+ { "IBM-", "273",0,20273},
+ { "IBM-", "277",0,20277},
+ { "IBM-", "278",0,20278},
+ { "IBM-", "280",0,20280},
+ { "IBM-", "284",0,20284},
+ { "IBM-", "285",0,20285},
+ { "IBM-", "290",0,20290},
+ { "IBM-", "297",0,20297},
+ { "IBM-", "420",0,20420},
+ { "IBM-", "423",0,20423},
+ { "IBM-", "871",0,20871},
+ { "IBM-", "880",0,20880},
+ { "IBM-", "905",0,20905},
+ { "IBM-", "THAI",0,20838},
+ { "ISCII-", "DEVANAGARI",0,57002},
+ { "ISCII-", "BENGALI",0,57003},
+ { "ISCII-", "TAMIL",0,57004},
+ { "ISCII-", "TELUGU",0,57005},
+ { "ISCII-", "ASSAMESE",0,57006},
+ { "ISCII-", "ORIYA",0,57007},
+ { "ISCII-", "KANNADA",0,57008},
+ { "ISCII-", "MALAYALAM",0,57009},
+ { "ISCII-", "GUJARATI",0,57010},
+ { "ISCII-", "PUNJABI",0,57011},
+ { "KOR-", "JOHAB",0,1361},
+ { "KSC-", "5601",0,1361},
+ { "MAC-", "ROMAN",0,10000},
+ { "MAC-", "JP",0,10001},
+ { "MAC-", "CH(SP)(BIG5)",0,10002},
+ { "MAC-", "KR",0,10003},
+ { "MAC-", "AR",0,10004},
+ { "MAC-", "HW",0,10005},
+ { "MAC-", "GR",0,10006},
+ { "MAC-", "CY",0,10007},
+ { "MAC-", "CH(SP)(GB2312)",0,10008},
+ { "MAC-", "ROMANIA",0,10010},
+ { "MAC-", "UA",0,10017},
+ { "MAC-", "TH",0,10021},
+ { "MAC-", "LAT2",0,10029},
+ { "MAC-", "ICE",0,10079},
+ { "MAC-", "TR",0,10081},
+ { "MAC-", "CR",0,10082}
+};
+
+int CPLENALL = (sizeof(CodePageNamesAll)/sizeof(CodePageNamesAll[0]));
+struct _tcptable *CodePageNamesSupp;
+int CPLENSUPP = 1;
+
+//Gets codepage ID from string representing charset such as "iso-8859-1"
+// input- the string
+// size- max length of input string
+int GetCharsetFromString(char *input,size_t size);
+
+//HexValue to DecValue ('a' to 10)
+// HexValue- hexa value ('a')
+// DecValue- poiner where to store dec value
+// returns 0 if not success
+int FromHexa(char HexValue,char *DecValue);
+
+//Decodes a char from Base64
+// Base64Value- input char in Base64
+// DecValue- pointer where to store the result
+// returns 0 if not success
+int FromBase64(char Base64Value,char *DecValue);
+
+//Decodes string in quoted printable
+// Src- input string
+// Dst- where to store output string
+// DstLen- how max long should be output string
+// isQ- if is "Q-encoding" modification. should be TRUE in headers
+// always returns 1
+int DecodeQuotedPrintable(char *Src,char *Dst,int DstLen, BOOL isQ);
+
+//Decodes string in base64
+// Src- input string
+// Dst- where to store output string
+// DstLen- how max long should be output string
+// returns 0 if string was not properly decoded
+int DecodeBase64(char *Src,char *Dst,int DstLen);
+
+//Converts string to unicode from string with specified codepage
+// stream- input string
+// cp- codepage of input string
+// out- pointer to new allocated memory that contains unicode string
+int ConvertStringToUnicode(char *stream,unsigned int cp,WCHAR **out);
+
+//Converts string from MIME header to unicode
+// stream- input string
+// cp- codepage of input string
+// storeto- pointer to memory that contains unicode string
+// mode- MIME_PLAIN or MIME_MAIL (MIME_MAIL deletes '"' from start and end of string)
+void ConvertCodedStringToUnicode(char *stream,WCHAR **storeto,DWORD cp,int mode);
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+int GetCharsetFromString(char *input,size_t size)
+//"ISO-8859-1" to ID from table
+{
+ char *pin=input;
+ char *pout,*parser;
+
+ if ((size<1) || (parser=pout=new char[size+1])==NULL)
+ return -1;
+ while((*pin!=0) && (pin-input< (INT_PTR)size))
+ {
+ if ((*pin>='a') && (*pin<='z'))
+ *parser++=*(pin++)-('a'-'A'); // make it capital
+ //else if (*pin=='\"') // this is already done in ExtractFromContentType
+ // *pin++; //skip the quotes if any
+ else
+ *parser++=*pin++;
+ }
+
+ *parser=(char)0;
+
+#ifdef DEBUG_DECODECODEPAGE
+ DebugLog(DecodeFile,"<CodePage>%s</CodePage>",pout);
+#endif
+ for (int i=0;i<CPLENALL;i++) {
+ size_t len = strlen(CodePageNamesAll[i].NameBase);
+ if (0==strncmp(pout,CodePageNamesAll[i].NameBase,len)) {
+ if (0==strcmp(pout+len,CodePageNamesAll[i].NameSub)) {
+ delete[] pout;
+ return CodePageNamesAll[i].CP;
+ }
+ }
+ }
+ delete[] pout;
+ return -1; //not found
+}
+
+int FromHexa(char HexValue,char *DecValue)
+{
+ if (HexValue>='0' && HexValue<='9')
+ {
+ *DecValue=HexValue-'0';
+ return 1;
+ }
+ if (HexValue>='A' && HexValue<='F')
+ {
+ *DecValue=HexValue-'A'+10;
+ return 1;
+ }
+ if (HexValue>='a' && HexValue<='f')
+ {
+ *DecValue=HexValue-'a'+10;
+ return 1;
+ }
+ return 0;
+}
+
+int FromBase64(char Base64Value,char *DecValue)
+{
+ if (Base64Value>='A' && Base64Value<='Z')
+ {
+ *DecValue=Base64Value-'A';
+ return 1;
+ }
+ if (Base64Value>='a' && Base64Value<='z')
+ {
+ *DecValue=Base64Value-'a'+26;
+ return 1;
+ }
+ if (Base64Value>='0' && Base64Value<='9')
+ {
+ *DecValue=Base64Value-'0'+52;
+ return 1;
+ }
+ if (Base64Value=='+')
+ {
+ *DecValue=Base64Value-'+'+62;
+ return 1;
+ }
+ if (Base64Value=='/')
+ {
+ *DecValue=Base64Value-'/'+63;
+ return 1;
+ }
+ if (Base64Value=='=')
+ {
+ *DecValue=0;
+ return 1;
+ }
+ return 0;
+}
+
+int DecodeQuotedPrintable(char *Src,char *Dst,int DstLen, BOOL isQ)
+{
+#ifdef DEBUG_DECODEQUOTED
+ char *DstTemp=Dst;
+ DebugLog(DecodeFile,"<Decode Quoted><Input>%s</Input>",Src);
+#endif
+ for (int Counter=0;((char)*Src!=0) && DstLen && (Counter++<DstLen);Src++,Dst++)
+ if (*Src=='=')
+ {
+ if (!isQ){
+ if (Src[1]==0x0D){
+ Src++; Src++;
+ if (Src[0]==0x0A) Src++;
+ goto CopyCharQuotedPrintable;
+ }
+ if (Src[1]==0x0A){
+ Src++; Src++;
+ goto CopyCharQuotedPrintable;
+ }
+ }
+ char First,Second;
+ if (!FromHexa(*(++Src),&First))
+ {
+ *Dst++='=';Src--;
+ continue;
+ }
+ if (!FromHexa(*(++Src),&Second))
+ {
+ *Dst++='=';Src--;Src--;
+ continue;
+ }
+ *Dst=(char)(First)<<4;
+ *Dst+=Second;
+ }
+ else if (isQ && *Src=='_')
+ *Dst=' ';
+ else
+CopyCharQuotedPrintable: // Yeah. Bad programming stile.
+ *Dst=*Src;
+ *Dst=(char)0;
+#ifdef DEBUG_DECODEQUOTED
+ DebugLog(DecodeFile,"<Output>%s</Output></Decode Quoted>",DstTemp);
+#endif
+ return 1;
+}
+
+int DecodeBase64(char *Src,char *Dst,int DstLen)
+{
+ int Result=0;
+ char Locator=0,MiniResult[4];
+ char *End=Dst+DstLen;
+
+ MiniResult[0]=MiniResult[1]=MiniResult[2]=MiniResult[3]=0;
+
+#ifdef DEBUG_DECODEBASE64
+ char *DstTemp=Dst;
+ DebugLog(DecodeFile,"<Decode Base64><Input>\n%s\n</Input>\n",Src);
+#endif
+ while(*Src!=0 && DstLen && Dst!=End)
+ {
+ if ((*Src==0x0D)||(*Src==0x0A)) {
+ Src++;
+ continue;
+ }
+ if ((!(Result=FromBase64(*Src,MiniResult+Locator)) && (*Src==0)) || Locator++==3) //end_of_str || end_of_4_bytes
+ {
+ Locator=0; //next write to the first byte
+ *Dst++=(char)((MiniResult[0]<<2) | (MiniResult[1]>>4));
+ if (Dst==End) goto end; //DstLen exceeded?
+ *Dst++=(char)((MiniResult[1]<<4) | (MiniResult[2]>>2));
+ if (Dst==End) goto end; //someones don't like goto, but not me
+ *Dst++=(char)((MiniResult[2]<<6) | MiniResult[3]);
+ if (!Result && (*Src==0)) goto end; //end of string?
+ MiniResult[0]=MiniResult[1]=MiniResult[2]=MiniResult[3]=0; //zero 4byte buffer for next loop
+ }
+ if (!Result) return 0; //unrecognised character occured
+ Src++;
+ }
+end:
+ *Dst=0;
+#ifdef DEBUG_DECODEBASE64
+ DebugLog(DecodeFile,"<Output>\n%s\n</Output></Decode Base64>",DstTemp);
+#endif
+ return 1;
+}
+
+
+
+int ConvertStringToUnicode(char *stream,unsigned int cp,WCHAR **out)
+{
+ CPINFO CPInfo;
+ WCHAR *temp,*src=*out,*dest;
+ size_t outlen;
+ int streamlen,Index;
+
+ //codepages, which require to have set 0 in dwFlags parameter when calling MultiByteToWideChar
+ DWORD CodePagesZeroFlags[]={50220,50221,50222,50225,50227,50229,52936,54936,57002,57003,57004,57005,57006,57007,57008,57009,57010,57011,65000,65001};
+
+ if ((cp!=CP_ACP) && (cp!=CP_OEMCP) && (cp!=CP_MACCP) && (cp!=CP_THREAD_ACP) && (cp!=CP_SYMBOL) && (cp!=CP_UTF7) && (cp!=CP_UTF8) && !GetCPInfo(cp,&CPInfo))
+ cp=CP_ACP;
+#ifdef DEBUG_DECODECODEPAGE
+ DebugLog(DecodeFile,"<CodePage #>%d</CodePage #>",cp);
+#endif
+
+ for (Index=0;Index<sizeof(CodePagesZeroFlags)/sizeof(CodePagesZeroFlags[0]);Index++)
+ if (CodePagesZeroFlags[Index]==cp)
+ {
+ Index=-1;
+ break;
+ }
+ if (Index==-1)
+ streamlen=MultiByteToWideChar(cp,0,stream,-1,NULL,0);
+ else
+ streamlen=MultiByteToWideChar(cp,MB_USEGLYPHCHARS,stream,-1,NULL,0);
+
+ if (*out!=NULL)
+ outlen=wcslen(*out);
+ else
+ outlen=0;
+ temp=new WCHAR[streamlen+outlen+1];
+
+ if (*out!=NULL)
+ {
+ for (dest=temp;*src!=(WCHAR)0;src++,dest++) //copy old string from *out to temp
+ *dest=*src;
+// *dest++=L' '; //add space?
+ delete[] *out;
+ }
+ else
+ dest=temp;
+ *out=temp;
+
+ if (Index==-1)
+ {
+ if (!MultiByteToWideChar(cp,0,stream,-1,dest,streamlen))
+ return 0;
+ }
+ else
+ {
+ if (!MultiByteToWideChar(cp,MB_USEGLYPHCHARS,stream,-1,dest,streamlen))
+ return 0;
+ }
+ return 1;
+}
+
+void ConvertCodedStringToUnicode(char *stream,WCHAR **storeto,DWORD cp,int mode)
+{
+ char *start=stream,*finder,*finderend;
+ char Encoding=0;
+ char *DecodedResult=NULL;
+
+ if (stream==NULL)
+ return;
+
+ while(WS(start)) start++;
+ WCHAR *tempstore=0;
+ if (!ConvertStringToUnicode(stream,cp,&tempstore))return;
+
+ size_t tempstoreLength = wcslen(tempstore);
+
+ size_t outind = 0;
+ while(*start!=0){
+ if (CODES(start)) {
+ finder=start+2;finderend=finder;
+ while(!CODED(finderend) && !EOS(finderend)) finderend++;
+ start = finderend;
+ if (CODED(finderend))
+ {
+ Encoding=*(finderend+1);
+ switch(Encoding)
+ {
+ case 'b':
+ case 'B':
+ case 'q':
+ case 'Q':
+ break;
+ default:
+ goto NotEncoded;
+ }
+ if (-1==(cp=(DWORD)GetCharsetFromString(finder,finderend-finder)))
+ cp=CP_ACP;
+ if (Encoding!=0)
+ {
+ int size,codeend;
+ char *pcodeend;
+
+ finder=finderend+2;
+ if (CODED(finder))
+ finder++;
+ while(WS(finder)) finder++;
+ finderend=finder;
+ while(!CODEE(finderend) && !EOS(finderend)) finderend++;
+ if (codeend=CODEE(finderend))
+ pcodeend=finderend;
+ while(WS(finderend-1)) finderend--;
+ if ((mode==MIME_MAIL) && (((*finder=='"') && (*(finderend-1)=='"'))))
+ {
+ finder++;
+ finderend--;
+ }
+ //*finderend=(char)0;
+ char * oneWordEncoded = new char[finderend-finder+1];
+ strncpy(oneWordEncoded,finder,finderend-finder);
+ oneWordEncoded[finderend-finder]=0;
+ switch(Encoding)
+ {
+ case 'b':
+ case 'B':
+ size=(finderend-finder)*3/4+3+1+1;
+ break;
+ case 'q':
+ case 'Q':
+ size=finderend-finder+1+1;
+ break;
+ }
+ if (DecodedResult!=NULL)
+ delete[] DecodedResult;
+ DecodedResult=new char[size+1];
+ switch(Encoding)
+ {
+ case 'q':
+ case 'Q':
+ DecodeQuotedPrintable(oneWordEncoded,DecodedResult,size, TRUE);
+ break;
+ case 'b':
+ case 'B':
+ DecodeBase64(oneWordEncoded,DecodedResult,size);
+ break;
+ }
+ delete[] oneWordEncoded;
+ if (codeend)
+ finderend=pcodeend+2;
+ if (WS(finderend)) //if string continues and there's some whitespace, add space to string that is to be converted
+ {
+ size_t len=strlen(DecodedResult);
+ DecodedResult[len]=' ';
+ DecodedResult[len+1]=0;
+ finderend++;
+ }
+ WCHAR *oneWord=0;
+ if (ConvertStringToUnicode(DecodedResult,cp,&oneWord)) {
+ size_t len = wcslen(oneWord);
+ memcpy(&tempstore[outind],oneWord,len*sizeof(WCHAR));
+ outind += len;
+ }
+ delete oneWord;
+ oneWord = 0;
+ delete[] DecodedResult; DecodedResult = 0;
+ start = finderend;
+ } else if (!EOS(start)) start++;
+ } else if (!EOS(start)) start++;
+ }else{
+NotEncoded:
+ tempstore[outind] = tempstore[start-stream];
+ outind++;
+ if (outind > tempstoreLength) break;
+ start++;
+ }
+ }
+ tempstore[outind] = 0;
+ *storeto = tempstore;
+}
diff --git a/plugins/YAMN/src/mails/m_decode.h b/plugins/YAMN/src/mails/m_decode.h new file mode 100644 index 0000000000..e6d2b52fae --- /dev/null +++ b/plugins/YAMN/src/mails/m_decode.h @@ -0,0 +1,25 @@ +#ifndef __DECODE_H
+#define __DECODE_H
+
+#include "../debug.h"
+
+#define DOTLINE(s) ((((s)[-2]=='\r') || ((s)[-2]=='\n')) && ((s)[-1]=='.') && (((s)[0]=='\r') || ((s)[0]=='\n') || ((s)[0]=='\0'))) // be careful, it's different to ESR's pop3.c ;-)
+#define ENDLINE(s) (((s)[0]=='\r') || ((s)[0]=='\n')) //endline
+#define WS(s) (((s)[0]==' ') || ((s)[0]=='\t')) //whitespace
+#define ENDLINEWS(s) ((((s)[0]=='\r') || ((s)[0]=='\n')) && (((((s)[1]=='\r') || ((s)[1]=='\n')) && (((s)[2]==' ') || ((s)[2]=='\t'))) || (((s)[1]==' ') || ((s)[1]=='\t')))) //endline+whitespace: enters(CR or LF and their combinations) followed by space or tab
+#define EOS(s) ((s)[0]==0) //end of string (stream)
+
+#define CODES(s) ((s[0]=='=') && (s[1]=='?')) //start of coded string
+#define CODEE(s) ((s[0]=='?') && (s[1]=='=')) //end of coded string
+#define CODED(s) (s[0]=='?') //code delimiter
+
+#define MIME_PLAIN 1
+#define MIME_MAIL 2
+
+struct cptable
+{
+ char *name;
+ unsigned int ID;
+};
+
+#endif
diff --git a/plugins/YAMN/src/mails/mails.cpp b/plugins/YAMN/src/mails/mails.cpp new file mode 100644 index 0000000000..af0f3d2329 --- /dev/null +++ b/plugins/YAMN/src/mails/mails.cpp @@ -0,0 +1,499 @@ +/*
+ * This code implements retrieving info from MIME header
+ *
+ * (c) majvan 2002-2004
+ */
+
+#pragma warning( disable : 4290 )
+#include "../yamn.h"
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+// SMALL INTRO
+// Mails are queued in a queue (chained list). Pointer to first mail is pointed from Account structure
+// member called Mails.
+// Mail queue is ended with NULL- pointered mail (NULL handle)
+
+//Creates new mail for plugin (calling plugin's constructor, when plugin imported to YAMN)
+INT_PTR CreateAccountMailSvc(WPARAM wParam,LPARAM lParam);
+
+//Deletes mail for plugin (calling plugin's destructor, when plugin imported to YAMN)
+INT_PTR DeleteAccountMailSvc(WPARAM wParam,LPARAM lParam);
+
+//Loads mail data from standard storage to memory
+INT_PTR LoadMailDataSvc(WPARAM wParam,LPARAM lParam);
+
+//Deletes mail data from memory
+INT_PTR UnloadMailDataSvc(WPARAM wParam,LPARAM);
+
+//Saves mail data from memory to standard storage
+INT_PTR SaveMailDataSvc(WPARAM wParam,LPARAM lParam);
+
+//Appends second MIME mail queue to the first one
+//Only finds the end of first queue and its Next memember repoints to second one
+void WINAPI AppendQueueFcn(HYAMNMAIL first,HYAMNMAIL second);
+
+//Synchronizes two accounts
+//Function finds, if there were some mails deleted from mailbox and deletes (depends on RemovedOld param) them from OldQueue
+//Next finds, if there are new mails. Mails that are still on mailbox are deleted (depends on RemovedNew param) from NewQueue
+//After this, OldQueue is pointer to mails that are on mailbox, but not new mails
+//and NewQueue contains new mails in account
+//New accounts can be then appended to account mails queue, but they have set the New flag
+//
+//Two mails equals if they have the same ID
+//
+// hPlugin- handle of plugin going to delete mails
+// OldQueue- queue of mails that we found on mailbox last time, after function finishes queue contains all mails except new ones
+// RemovedOld- queue of mails where to store removed mails from OldQueue, if NULL deletes mails from OldQueue
+// NewQueue- queue of mails that we found on mailbox (all mails), after function finishes queue contains only new mails
+// RemovedNew- queue of mails where to store removed mails from NewQueue, if NULL deletes mails from NewQueue
+//So function works like:
+//1. delete (or move to RemovedOld queue if RemovedOld is not NULL) all mails from OldQueue not found in NewQueue
+//2. delete (or move to RemovedNew queue if RemovedNew is not NULL) all mails from NewQueue found in OldQueue
+void WINAPI SynchroMessagesFcn(HACCOUNT Account,HYAMNMAIL *OldQueue,HYAMNMAIL *RemovedOld,HYAMNMAIL *NewQueue,HYAMNMAIL *RemovedNew);
+
+//Deletes messages from mail From to the end
+// Account- account who owns mails
+// From- first mail in queue, which is going to delete
+void WINAPI DeleteMessagesToEndFcn(HACCOUNT Account,HYAMNMAIL From);
+
+//Removes message from queue, does not delete from memory
+// From- queue pointer
+// Which- mail to delete
+// mode- nonzero if you want to decrement numbers in messages that are bigger than the one in Which mail, 0 if not
+void WINAPI DeleteMessageFromQueueFcn(HYAMNMAIL *From,HYAMNMAIL Which,int mode);
+
+//Finds message in queue that has the same ID number
+// From- message queue
+// ID- pointer to ID
+// returns pointer to found message, NULL if not found
+HYAMNMAIL WINAPI FindMessageByIDFcn(HYAMNMAIL From,char *ID);
+
+//Translate header from text to queue of CMimeItem structures
+//This means that new queue will contain all info about headers
+// stream- pointer to text containing header (can be ended with zero)
+// len- length of stream
+// head- function fills this pointer to first header item in queue
+void WINAPI TranslateHeaderFcn(char *stream,int len,struct CMimeItem **head);
+
+//Creates new mail queue, copying only these mails, that have set flag for deleting
+// From- message queue, whose mail with given flag are duplicated
+// returns new mail queue (or NULL when no mail with flag is in From queue)
+//Function does not copy the whole mails, it copies only ID string. And ID is copied as string, so
+//you can use this fcn only if you have your ID as pointer to char string ended with zero character
+HYAMNMAIL WINAPI CreateNewDeleteQueueFcn(HYAMNMAIL From);
+
+//Sets/removes flags from specific mails
+// From- pointer to first message
+// FlagsSet- mail must have set these flags...
+// FlagsNotSet- ...and must not have set these flags...
+// FlagsToSetRemove- ...to set/remove these flags (see mode)
+// mode- nonzero to set, else remove
+void WINAPI SetRemoveFlagsInQueueFcn(HYAMNMAIL From,DWORD FlagsSet,DWORD FlagsNotSet,DWORD FlagsToSetRemove,int mode);
+
+struct CExportedFunctions MailExportedFcn[]=
+{
+ {YAMN_SYNCHROMIMEMSGSID,(void *)SynchroMessagesFcn},
+ {YAMN_TRANSLATEHEADERID,(void *)TranslateHeaderFcn},
+ {YAMN_APPENDQUEUEID,(void *)AppendQueueFcn},
+ {YAMN_DELETEMIMEQUEUEID,(void *)DeleteMessagesToEndFcn},
+ {YAMN_DELETEMIMEMESSAGEID,(void *)DeleteMessageFromQueueFcn},
+ {YAMN_FINDMIMEMESSAGEID,(void *)FindMessageByIDFcn},
+ {YAMN_CREATENEWDELETEQUEUEID,(void *)CreateNewDeleteQueueFcn},
+ {YAMN_SETREMOVEQUEUEFLAGSID,(void *)SetRemoveFlagsInQueueFcn},
+};
+
+struct CExportedServices MailExportedSvc[]=
+{
+ {MS_YAMN_CREATEACCOUNTMAIL,CreateAccountMailSvc},
+ {MS_YAMN_DELETEACCOUNTMAIL,DeleteAccountMailSvc},
+ {MS_YAMN_LOADMAILDATA,LoadMailDataSvc},
+ {MS_YAMN_UNLOADMAILDATA,UnloadMailDataSvc},
+ {MS_YAMN_SAVEMAILDATA,SaveMailDataSvc},
+};
+
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+INT_PTR CreateAccountMailSvc(WPARAM wParam,LPARAM lParam)
+{
+ HACCOUNT Account=(HACCOUNT)wParam;
+ DWORD MailVersion=(DWORD)lParam;
+ HYAMNMAIL NewMail;
+
+//test if we are going to initialize members of suitable structure (structures of plugin and YAMN must match)
+ if (MailVersion!=YAMN_MAILVERSION)
+ return NULL;
+
+ if (Account->Plugin!=NULL)
+ {
+ if (Account->Plugin->MailFcn->NewMailFcnPtr!=NULL)
+ {
+//Let plugin create its own structure, which can be derived from CAccount structure
+ if (NULL==(NewMail=Account->Plugin->MailFcn->NewMailFcnPtr(Account,YAMN_MAILVERSION)))
+ return NULL;
+ }
+ else
+ {
+//We suggest plugin uses standard CAccount structure, so we create it
+ if (NULL==(NewMail=new YAMNMAIL))
+//If not created successfully
+ return NULL;
+ NewMail->MailData=NULL;
+ }
+//Init every members of structure, used by YAMN
+ return (INT_PTR)NewMail;
+ }
+ return NULL;
+}
+
+INT_PTR DeleteAccountMailSvc(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
+ HYAMNMAIL OldMail=(HYAMNMAIL)lParam;
+ struct CMimeItem *TH;
+
+ if (Plugin->MailFcn!=NULL){
+ if (Plugin->MailFcn->DeleteMailFcnPtr!=NULL) {
+ //Let plugin delete its own CMimeMsgQueue derived structure
+ Plugin->MailFcn->DeleteMailFcnPtr(OldMail);
+ return 1;
+ }
+ }
+ if (OldMail->MailData!=NULL) {
+ if (OldMail->MailData->Body!=NULL)
+ delete[] OldMail->MailData->Body;
+ if ((TH=OldMail->MailData->TranslatedHeader)!=NULL)
+ for (;OldMail->MailData->TranslatedHeader!=NULL;) {
+ TH=TH->Next;
+ if (OldMail->MailData->TranslatedHeader->name!=NULL)
+ delete[] OldMail->MailData->TranslatedHeader->name;
+ if (OldMail->MailData->TranslatedHeader->value!=NULL)
+ delete[] OldMail->MailData->TranslatedHeader->value;
+ delete OldMail->MailData->TranslatedHeader;
+ OldMail->MailData->TranslatedHeader=TH;
+ }
+ delete OldMail->MailData;
+ }
+ if (OldMail->ID!=NULL)
+ delete[] OldMail->ID;
+
+ delete OldMail; //consider mail as standard HYAMNMAIL, not initialized before and use its own destructor
+ return 1;
+}
+
+
+void WINAPI AppendQueueFcn(HYAMNMAIL first,HYAMNMAIL second)
+{
+ HYAMNMAIL Finder=first;
+ while(Finder->Next!=NULL) Finder=Finder->Next;
+ Finder->Next=second;
+}
+
+INT_PTR LoadMailDataSvc(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNMAIL Mail=(HYAMNMAIL)wParam;
+ DWORD MailVersion=(DWORD)lParam;
+
+ if (MailVersion!=YAMN_MAILDATAVERSION)
+ return NULL;
+
+//now we have all data to memory persisting, so no loading is needed
+ return (INT_PTR)Mail->MailData;
+}
+
+INT_PTR UnloadMailDataSvc(WPARAM wParam,LPARAM)
+{
+ HYAMNMAIL Mail=(HYAMNMAIL)wParam;
+
+//now we should delete structure from memory, but it will be made in future YAMN version
+ return 1;
+}
+
+INT_PTR SaveMailDataSvc(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNMAIL Mail=(HYAMNMAIL)wParam;
+ DWORD MailVersion=(DWORD)lParam;
+
+ if (MailVersion!=YAMN_MAILDATAVERSION)
+ return (INT_PTR)-1;
+
+//now we have all data to memory persisting, so no saving is needed
+ return (INT_PTR)0;
+}
+
+void WINAPI SynchroMessagesFcn(HACCOUNT Account,HYAMNMAIL *OldQueue,HYAMNMAIL *RemovedOld,HYAMNMAIL *NewQueue,HYAMNMAIL *RemovedNew)
+//deletes messages from new queue, if they are old
+//it also deletes messages from old queue, if they are not in mailbox anymore
+//"YAMN_MSG_DELETED" messages in old queue remain in old queue (are never removed, although they are not in new queue)
+//"YAMN_MSG_DELETED" messages in new queue remain in new queue (are never removed, although they can be in old queue)
+{
+ HYAMNMAIL Finder,FinderPrev;
+ HYAMNMAIL Parser,ParserPrev;
+ HYAMNMAIL RemovedOldParser =NULL;
+ HYAMNMAIL RemovedNewParser =NULL;
+ if (RemovedOld!=NULL) *RemovedOld=NULL;
+ if (RemovedNew!=NULL) *RemovedNew=NULL;
+
+ for (FinderPrev=NULL,Finder=*OldQueue;Finder!=NULL;)
+ {
+ if (Finder->Flags & YAMN_MSG_DELETED) //if old queue contains deleted mail
+ {
+ FinderPrev=Finder;
+ Finder=Finder->Next; //get next message in old queue for testing
+ continue;
+ }
+ for (ParserPrev=NULL,Parser=*NewQueue;Parser!=NULL;ParserPrev=Parser,Parser=Parser->Next)
+ {
+ if (Parser->Flags & YAMN_MSG_DELETED)
+ continue;
+
+ if (Parser->ID==NULL) //simply ignore the message, that has not filled its ID
+ continue;
+
+ if (0==strcmp(Parser->ID,Finder->ID)) //search for equal message in new queue
+ break;
+ }
+ if (Parser!=NULL) //found equal message in new queue
+ {
+ if (Parser==*NewQueue)
+ *NewQueue=(*NewQueue)->Next;
+ else
+ ParserPrev->Next=Parser->Next;
+ Finder->Number=Parser->Number; //rewrite the number of current message in old queue
+
+ if (RemovedNew==NULL) //delete from new queue
+ DeleteAccountMailSvc((WPARAM)Account->Plugin,(LPARAM)Parser);
+ else //or move to RemovedNew
+ {
+ if (RemovedNewParser==NULL) //if it is first mail removed from NewQueue
+ *RemovedNew=Parser; //set RemovedNew queue to point to first message in removed queue
+ else
+ RemovedNewParser->Next=Parser; //else don't forget to show to next message in RemovedNew queue
+ RemovedNewParser=Parser; //follow RemovedNew queue
+ RemovedNewParser->Next=NULL;
+ }
+ FinderPrev=Finder;
+ Finder=Finder->Next; //get next message in old queue for testing
+ }
+ else //a message was already deleted from mailbox
+ {
+ if (Finder==*OldQueue) //if we are at the first item in OldQueue
+ {
+ *OldQueue=(*OldQueue)->Next; //set OldQueue to next item
+ if (RemovedOld==NULL) //delete from old queue
+ DeleteAccountMailSvc((WPARAM)Account->Plugin,(LPARAM)Finder);
+ else //or move to RemovedOld
+ {
+ if (RemovedOldParser==NULL) //if it is first mail removed from OldQueue
+ *RemovedOld=Finder; //set RemovedOld queue to point to first message in removed queue
+ else
+ RemovedOldParser->Next=Finder; //else don't forget to show to next message in RemovedNew queue
+ RemovedOldParser=Finder; //follow RemovedOld queue
+ RemovedOldParser->Next=NULL;
+ }
+ Finder=*OldQueue;
+ }
+ else
+ {
+ FinderPrev->Next=Finder->Next;
+ if (RemovedOld==NULL) //delete from old queue
+ DeleteAccountMailSvc((WPARAM)Account->Plugin,(LPARAM)Finder);
+ else //or move to RemovedOld
+ {
+ if (RemovedOldParser==NULL) //if it is first mail removed from OldQueue
+ *RemovedOld=Finder; //set RemovedOld queue to point to first message in removed queue
+ else
+ RemovedOldParser->Next=Finder; //else don't forget to show to next message in RemovedNew queue
+ RemovedOldParser=Finder; //follow RemovedOld queue
+ RemovedOldParser->Next=NULL;
+ }
+ Finder=FinderPrev->Next;
+ }
+ }
+ }
+}
+
+void WINAPI DeleteMessagesToEndFcn(HACCOUNT Account,HYAMNMAIL From)
+{
+ HYAMNMAIL Temp;
+ while(From!=NULL)
+ {
+ Temp=From;
+ From=From->Next;
+ DeleteAccountMailSvc((WPARAM)Account->Plugin,(LPARAM)Temp);
+ }
+}
+
+void WINAPI DeleteMessageFromQueueFcn(HYAMNMAIL *From,HYAMNMAIL Which,int mode=0)
+{
+ DWORD Number=Which->Number;
+ HYAMNMAIL Parser;
+
+ if (*From==Which)
+ {
+ Parser=Which->Next;
+ *From=Parser;
+ }
+ else
+ {
+ for (Parser=*From;Which!=Parser->Next;Parser=Parser->Next)
+ if (mode && (Parser->Number>Number)) Parser->Number--;
+ if (mode && (Parser->Number>Number)) Parser->Number--;
+ Parser->Next=Parser->Next->Next;
+ Parser=Which->Next;
+ }
+ if (mode)
+ for (;Parser!=NULL;Parser=Parser->Next)
+ if (Parser->Number>Number) Parser->Number--;
+}
+
+void DeleteMessagesFromQueue(HYAMNMAIL *From,HYAMNMAIL Which,int mode=0)
+{
+ HYAMNMAIL Parser;
+
+ for (Parser=Which;Parser!=NULL;Parser=Parser->Next)
+ DeleteMessageFromQueueFcn(From,Parser,mode);
+}
+
+HYAMNMAIL WINAPI FindMessageByIDFcn(HYAMNMAIL From,char *ID)
+{
+ HYAMNMAIL Browser;
+
+ for (Browser=From;Browser!=NULL;Browser=Browser->Next)
+ if (0==lstrcmpA(Browser->ID,ID))
+ break;
+ return Browser;
+}
+
+void WINAPI TranslateHeaderFcn(char *stream,int len,struct CMimeItem **head)
+{
+ try
+ {
+ char *finder=stream;
+ char *prev1,*prev2,*prev3;
+ struct CMimeItem *Item=NULL;
+
+ while(finder<=(stream+len))
+ {
+ while(ENDLINEWS(finder)) finder++;
+
+ //at the start of line
+ if (DOTLINE(finder+1)) //at the end of stream
+ break;
+
+ prev1=finder;
+
+ while(*finder!=':' && !EOS(finder)) finder++;
+ if (!EOS(finder))
+ prev2=finder++;
+ else
+ break;
+
+ while(WS(finder) && !EOS(finder)) finder++;
+ if (!EOS(finder))
+ prev3=finder;
+ else
+ break;
+
+ do
+ {
+ if (ENDLINEWS(finder)) finder+=2; //after endline information continues
+ while(!ENDLINE(finder) && !EOS(finder)) finder++;
+ }while(ENDLINEWS(finder));
+
+ if (Item!=NULL)
+ {
+ if (NULL==(Item->Next=new struct CMimeItem))
+ break;
+ Item=Item->Next;
+ }
+ else
+ {
+ Item = new CMimeItem;
+ *head = Item;
+ }
+
+ Item->Next=NULL;
+ Item->name=new char [prev2-prev1+1];
+ lstrcpynA(Item->name,prev1,prev2-prev1+1);
+ Item->value=new char [finder-prev3+1];
+ lstrcpynA(Item->value,prev3,finder-prev3+1);
+
+ if (EOS(finder))
+ break;
+ finder++;
+ if (ENDLINE(finder)) {
+ finder++;
+ if (ENDLINE(finder)) {
+ // end of headers. message body begins
+ finder++;
+ if (ENDLINE(finder))finder++;
+ prev1 = finder;
+ while (!DOTLINE(finder+1))finder++;
+ if (ENDLINE(finder))finder--;
+ prev2 = finder;
+ if (prev2>prev1){ // yes, we have body
+ if (NULL==(Item->Next=new struct CMimeItem)) break; // Cant create new item?!
+ Item=Item->Next;
+ Item->Next=NULL;//just in case;
+ Item->name=new char[5]; strncpy(Item->name,"Body",5);
+ Item->value=new char [prev2-prev1];
+ lstrcpynA(Item->value,prev1,prev2-prev1-1);
+ }
+ break; // there is nothing else
+ }
+ }
+ }
+ }
+ catch(...)
+ {
+ MessageBoxA(NULL,"Translate header error","",0);
+ }
+}
+
+HYAMNMAIL WINAPI CreateNewDeleteQueueFcn(HYAMNMAIL From)
+{
+ HYAMNMAIL FirstMail,Browser;
+
+ for (FirstMail=NULL;From!=NULL;From=From->Next)
+ {
+ if ((From->Flags & (YAMN_MSG_USERDELETE | YAMN_MSG_AUTODELETE)) && !(From->Flags & YAMN_MSG_DELETED))
+ {
+ if (FirstMail==NULL)
+ {
+ FirstMail=Browser=new YAMNMAIL;
+ if (FirstMail==NULL)
+ break;
+ }
+ else
+ {
+ Browser->Next=new YAMNMAIL;
+ Browser=Browser->Next;
+ }
+ Browser->ID=new char[strlen(From->ID)+1];
+ strcpy(Browser->ID,From->ID);
+ Browser->Number=From->Number;
+ Browser->Flags=From->Flags;
+ }
+ }
+ return FirstMail;
+}
+
+void WINAPI SetRemoveFlagsInQueueFcn(HYAMNMAIL From,DWORD FlagsSet,DWORD FlagsNotSet,DWORD FlagsToSetRemove,int mode)
+{
+ HYAMNMAIL msgq;
+
+ for (msgq=(HYAMNMAIL)From;msgq!=NULL;msgq=msgq->Next)
+ {
+ if ((FlagsSet==(msgq->Flags & FlagsSet)) && (0==(msgq->Flags & FlagsNotSet)))
+ {
+ if (mode)
+ msgq->Flags=msgq->Flags | FlagsToSetRemove;
+ else
+ msgq->Flags=msgq->Flags & ~FlagsToSetRemove;
+ }
+ }
+}
diff --git a/plugins/YAMN/src/mails/mime.cpp b/plugins/YAMN/src/mails/mime.cpp new file mode 100644 index 0000000000..2a66b80e2b --- /dev/null +++ b/plugins/YAMN/src/mails/mime.cpp @@ -0,0 +1,732 @@ +/*
+ * This code implements retrieving info from MIME header
+ *
+ * (c) majvan 2002-2004
+ */
+
+#pragma warning( disable : 4290 )
+#include "../yamn.h"
+
+//- imported ---------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+extern SWMRG *AccountBrowserSO;
+extern struct WndHandles *MessageWnd;
+
+extern int GetCharsetFromString(char *input,size_t size);
+extern void SendMsgToRecepients(struct WndHandles *FirstWin,UINT msg,WPARAM wParam,LPARAM lParam);
+extern void ConvertCodedStringToUnicode(char *stream,WCHAR **storeto,DWORD cp,int mode);
+extern DWORD WINAPI MailBrowser(LPVOID Param);
+extern DWORD WINAPI NoNewMailProc(LPVOID Param);
+extern DWORD WINAPI BadConnection(LPVOID Param);
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+//Copies one string to another
+// srcstart- source string
+// srcend- address to the end of source string
+// dest- pointer that stores new allocated string that contains copy of source string
+// mode- MIME_PLAIN or MIME_MAIL (MIME_MAIL deletes '"' characters (or '<' and '>') if they are at start and end of source string
+void CopyToHeader(char *srcstart,char *srcend,char **dest,int mode);
+
+//Extracts email address (finds nick name and mail and then stores them to strings)
+// finder- source string
+// storeto- pointer that receives address of mail string
+// storetonick- pointer that receives address of nickname
+void ExtractAddressFromLine(char *finder,char **storeto,char **storetonick);
+
+//Extracts simple text from string
+// finder- source string
+// storeto- pointer that receives address of string
+void ExtractStringFromLine(char *finder,char **storeto);
+
+//Extracts some item from content-type string
+//Example: ContentType string: "TEXT/PLAIN; charset=US-ASCII", item:"charset=", returns: "US-ASCII"
+// ContetType- content-type string
+// value- string item
+// returns extracted string (or NULL when not found)
+char *ExtractFromContentType(char *ContentType,char *value);
+
+//Extracts info from header text into header members
+//Note that this function as well as struct CShortHeadwer can be always changed, because there are many items to extract
+//(e.g. the X-Priority and Importance and so on)
+// items- translated header (see TranslateHeaderFcn)
+// head- header to be filled with values extracted from items
+void ExtractShortHeader(struct CMimeItem *items,struct CShortHeader *head);
+
+//Extracts header to mail using ExtractShortHeader fcn.
+// items- translated header (see TranslateHeaderFcn)
+// CP- codepage used when no default found
+// head- header to be filled with values extracted from items, in unicode (wide char)
+void ExtractHeader(struct CMimeItem *items,int &CP,struct CHeader *head);
+
+//Deletes items in CShortHeader structure
+// head- structure whose items are deleted
+void DeleteShortHeaderContent(struct CShortHeader *head);
+
+//Deletes list of YAMN_MIMENAMES structures
+// Names- pointer to first item of list
+void DeleteNames(PYAMN_MIMENAMES Names);
+
+//Deletes list of YAMN_MIMESHORTNAMES structures
+// Names- pointer to first item of list
+void DeleteShortNames(PYAMN_MIMESHORTNAMES Names);
+
+//Makes a string lowercase
+// string- string to be lowercased
+void inline ToLower(char *string);
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+void CopyToHeader(char *srcstart,char *srcend,char **dest,int mode)
+{
+ char *dst;
+
+ if (dest==NULL)
+ return;
+ if (srcstart>=srcend)
+ return;
+
+ if ((mode==MIME_MAIL) && (((*srcstart=='"') && (*(srcend-1)=='"')) || ((*srcstart=='<') && (*(srcend-1)=='>'))))
+ {
+ srcstart++;
+ srcend--;
+ }
+
+ if (srcstart>=srcend)
+ return;
+
+ if (NULL!=*dest)
+ delete[] *dest;
+ if (NULL==(*dest=new char[srcend-srcstart+1]))
+ return;
+
+ dst=*dest;
+
+ for (;srcstart<srcend;dst++,srcstart++)
+ {
+ if (ENDLINE(srcstart))
+ {
+ while(ENDLINE(srcstart) || WS(srcstart)) srcstart++;
+ *dst=' ';
+ srcstart--; //because at the end of "for loop" we increment srcstart
+ }
+ else
+ *dst=*srcstart;
+ }
+ *dst=0;
+}
+
+void ExtractAddressFromLine(char *finder,char **storeto,char **storetonick)
+{
+ if (finder==NULL)
+ {
+ *storeto=*storetonick=NULL;
+ return;
+ }
+ while(WS(finder)) finder++;
+ if ((*finder)!='<')
+ {
+ char *finderend=finder+1;
+ do
+ {
+ if (ENDLINEWS(finderend)) //after endline information continues
+ finderend+=2;
+ while(!ENDLINE(finderend) && !EOS(finderend)) finderend++; //seek to the end of line or to the end of string
+ }while(ENDLINEWS(finderend));
+ finderend--;
+ while(WS(finderend) || ENDLINE(finderend)) finderend--; //find the end of text, no whitespace
+ if (*finderend!='>') //not '>' at the end of line
+ CopyToHeader(finder,finderend+1,storeto,MIME_MAIL);
+ else //at the end of line, there's '>'
+ {
+ char *finder2=finderend;
+ while((*finder2!='<') && (finder2>finder)) finder2--; //go to matching '<' or to the start
+ CopyToHeader(finder2,finderend+1,storeto,MIME_MAIL);
+ if (*finder2=='<') //if we found '<', the rest copy as from nick
+ {
+ finder2--;
+ while(WS(finder2) || ENDLINE(finder2)) finder2--; //parse whitespace
+ CopyToHeader(finder,finder2+1,storetonick,MIME_MAIL); //and store nickname
+ }
+ }
+ }
+ else
+ {
+ char *finderend=finder+1;
+ do
+ {
+ if (ENDLINEWS(finderend)) //after endline information continues
+ finderend+=2;
+ while(!ENDLINE(finderend) && (*finderend!='>') && !EOS(finderend)) finderend++; //seek to the matching < or to the end of line or to the end of string
+ }while(ENDLINEWS(finderend));
+ CopyToHeader(finder,finderend+1,storeto,MIME_MAIL); //go to first '>' or to the end and copy
+ finder=finderend+1;
+ while(WS(finder)) finder++; //parse whitespace
+ if (!ENDLINE(finder) && !EOS(finder)) //if there are chars yet, it's nick
+ {
+ finderend=finder+1;
+ while(!ENDLINE(finderend) && !EOS(finderend)) finderend++; //seek to the end of line or to the end of string
+ finderend--;
+ while(WS(finderend)) finderend--; //find the end of line, no whitespace
+ CopyToHeader(finder,finderend+1,storetonick,MIME_MAIL);
+ }
+ }
+}
+
+void ExtractStringFromLine(char *finder,char **storeto)
+{
+ if (finder==NULL)
+ {
+ *storeto=NULL;
+ return;
+ }
+ while(WS(finder)) finder++;
+ char *finderend=finder;
+
+ do
+ {
+ if (ENDLINEWS(finderend)) finderend++; //after endline information continues
+ while(!ENDLINE(finderend) && !EOS(finderend)) finderend++;
+ }while(ENDLINEWS(finderend));
+ finderend--;
+ while(WS(finderend)) finderend--; //find the end of line, no whitespace
+ CopyToHeader(finder,finderend+1,storeto,MIME_PLAIN);
+}
+
+char *ExtractFromContentType(char *ContentType,char *value)
+{
+ char *lowered = _strdup(ContentType);
+ ToLower(lowered);
+ char *finder=strstr(lowered,value);
+ if (finder==NULL){
+ free (lowered);
+ return NULL;
+ }
+ finder = finder-lowered+ContentType;
+ free (lowered);
+
+ char *temp,*copier;
+ char *CopiedString;
+
+ temp=finder-1;
+ while((temp>ContentType) && WS(temp)) temp--; //now we have to find, if the word "Charset=" is located after ';' like "; Charset="
+ if (*temp!=';' && !ENDLINE(temp) && temp!=ContentType)
+ return NULL;
+ finder=finder+strlen(value); //jump over value string
+
+ while(WS(finder)) finder++; //jump over whitespaces
+ temp=finder;
+ while(*temp!=0 && *temp!=';') temp++; //jump to the end of setting (to the next ;)
+ temp--;
+ while(WS(temp)) temp--; //remove whitespaces from the end
+ if (*finder=='\"') { //remove heading and tailing quotes
+ finder++;
+ if (*temp=='\"') temp--;
+ }
+ if (NULL==(CopiedString=new char[++temp-finder+1]))
+ return NULL;
+ for (copier=CopiedString;finder!=temp;*copier++=*finder++); //copy string
+ *copier=0; //and end it with zero character
+
+ return CopiedString;
+}
+
+void ExtractShortHeader(struct CMimeItem *items,struct CShortHeader *head)
+{
+ for (;items!=NULL;items=items->Next)
+ {
+ //at the start of line
+ //MessageBox(NULL,items->value,items->name,0);
+ if (0==_strnicmp(items->name,"From",4))
+ {
+ if (items->value==NULL)
+ continue;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting from>");
+ #endif
+ ExtractAddressFromLine(items->value,&head->From,&head->FromNick);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting>\n");
+ #endif
+ }
+ else if (0==_strnicmp(items->name,"Return-Path",11))
+ {
+ if (items->value==NULL)
+ continue;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting return-path>");
+ #endif
+ ExtractAddressFromLine(items->value,&head->ReturnPath,&head->ReturnPathNick);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting>\n");
+ #endif
+ }
+ else if (0==_strnicmp(items->name,"Subject",7))
+ {
+ if (items->value==NULL)
+ continue;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting subject>");
+ #endif
+ ExtractStringFromLine(items->value,&head->Subject);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting>\n");
+ #endif
+ }
+ else if (0==_strnicmp(items->name,"Body",4))
+ {
+ if (items->value==NULL)
+ continue;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting body>");
+ #endif
+ ExtractStringFromLine(items->value,&head->Body);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting>\n");
+ #endif
+ }
+ else if (0==_strnicmp(items->name,"Date",4))
+ {
+ if (items->value==NULL)
+ continue;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting date>");
+ #endif
+ ExtractStringFromLine(items->value,&head->Date);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting>\n");
+ #endif
+ }
+ else if (0==_strnicmp(items->name,"Content-Type",12))
+ {
+ if (items->value==NULL)
+ continue;
+
+ char *ContentType=NULL,*CharSetStr;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting Content-Type>");
+ #endif
+ ExtractStringFromLine(items->value,&ContentType);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting>\n");
+ #endif
+ ToLower(ContentType);
+ if (NULL!=(CharSetStr=ExtractFromContentType(ContentType,"charset=")))
+ {
+ head->CP=GetCharsetFromString(CharSetStr,strlen(CharSetStr));
+ delete[] CharSetStr;
+ }
+ delete[] ContentType;
+ }
+ else if (0==_strnicmp(items->name,"Importance",10))
+ {
+ if (items->value==NULL)
+ continue;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting importance>");
+ #endif
+ if (head->Priority!=-1)
+ {
+ if (0==strncmp(items->value,"low",3))
+ head->Priority=5;
+ else if (0==strncmp(items->value,"normal",6))
+ head->Priority=3;
+ else if (0==strncmp(items->value,"high",4))
+ head->Priority=1;
+ }
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting>\n");
+ #endif
+ }
+ else if (0==_strnicmp(items->name,"X-Priority",10))
+ {
+ if (items->value==NULL)
+ continue;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<X-Priority>");
+ #endif
+ if ((*items->value>='1') && (*items->value<='5'))
+ head->Priority=*items->value-'0';
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting>\n");
+ #endif
+ }
+
+ }
+}
+
+void ExtractHeader(struct CMimeItem *items,int &CP,struct CHeader *head)
+{
+ struct CShortHeader ShortHeader;
+
+ ZeroMemory(&ShortHeader,sizeof(struct CShortHeader));
+ ShortHeader.Priority=ShortHeader.CP=-1;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting header>\n");
+ #endif
+ ExtractShortHeader(items,&ShortHeader);
+
+ head->Priority=ShortHeader.Priority==-1 ? 3 : ShortHeader.Priority;
+ CP=ShortHeader.CP==-1 ? CP : ShortHeader.CP;
+ #ifdef DEBUG_DECODE
+ if (NULL!=ShortHeader.From)
+ DebugLog(DecodeFile,"<Decoded from>%s</Decoded)\n",ShortHeader.From);
+ if (NULL!=ShortHeader.FromNick)
+ DebugLog(DecodeFile,"<Decoded from-nick>%s</Decoded)\n",ShortHeader.FromNick);
+ if (NULL!=ShortHeader.ReturnPath)
+ DebugLog(DecodeFile,"<Decoded return-path>%s</Decoded)\n",ShortHeader.ReturnPath);
+ if (NULL!=ShortHeader.ReturnPathNick)
+ DebugLog(DecodeFile,"<Decoded return-path nick>%s</Decoded)\n",ShortHeader.ReturnPathNick);
+ if (NULL!=ShortHeader.Subject)
+ DebugLog(DecodeFile,"<Decoded subject>%s</Decoded)\n",ShortHeader.Subject);
+ if (NULL!=ShortHeader.Date)
+ DebugLog(DecodeFile,"<Decoded date>%s</Decoded)\n",ShortHeader.Date);
+ DebugLog(DecodeFile,"</Extracting header>\n");
+ DebugLog(DecodeFile,"<Convert>\n");
+ #endif
+
+ ConvertCodedStringToUnicode(ShortHeader.From,&head->From,CP,MIME_PLAIN);
+
+ #ifdef DEBUG_DECODE
+ if (NULL!=head->From)
+ DebugLogW(DecodeFile,L"<Converted from>%s</Converted>\n",head->From);
+ #endif
+ ConvertCodedStringToUnicode(ShortHeader.FromNick,&head->FromNick,CP,MIME_MAIL);
+ #ifdef DEBUG_DECODE
+ if (NULL!=head->FromNick)
+ DebugLogW(DecodeFile,L"<Converted from-nick>%s</Converted>\n",head->FromNick);
+ #endif
+ ConvertCodedStringToUnicode(ShortHeader.ReturnPath,&head->ReturnPath,CP,MIME_PLAIN);
+ #ifdef DEBUG_DECODE
+ if (NULL!=head->ReturnPath)
+ DebugLogW(DecodeFile,L"<Converted return-path>%s</Converted>\n",head->ReturnPath);
+ #endif
+ ConvertCodedStringToUnicode(ShortHeader.ReturnPathNick,&head->ReturnPathNick,CP,MIME_MAIL);
+ #ifdef DEBUG_DECODE
+ if (NULL!=head->ReturnPathNick)
+ DebugLogW(DecodeFile,L"<Converted return-path nick>%s</Converted>\n",head->ReturnPathNick);
+ #endif
+ ConvertCodedStringToUnicode(ShortHeader.Subject,&head->Subject,CP,MIME_PLAIN);
+ #ifdef DEBUG_DECODE
+ if (NULL!=head->Subject)
+ DebugLogW(DecodeFile,L"<Converted subject>%s</Converted>\n",head->Subject);
+ #endif
+ ConvertCodedStringToUnicode(ShortHeader.Date,&head->Date,CP,MIME_PLAIN);
+ #ifdef DEBUG_DECODE
+ if (NULL!=head->Date)
+ DebugLogW(DecodeFile,L"<Converted date>%s</Converted>\n",head->Date);
+ #endif
+
+ ConvertCodedStringToUnicode(ShortHeader.Body,&head->Body,CP,MIME_PLAIN);
+ #ifdef DEBUG_DECODE
+ if (NULL!=head->Body)
+ DebugLogW(DecodeFile,L"<Converted Body>%s</Converted>\n",head->Body);
+ #endif
+
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Convert>\n");
+ #endif
+
+ DeleteShortHeaderContent(&ShortHeader);
+
+// head->From=L"Frommmm";
+// head->Subject=L"Subject";
+ return;
+}
+
+void DeleteShortHeaderContent(struct CShortHeader *head)
+{
+ if (head->From!=NULL) delete[] head->From;
+ if (head->FromNick!=NULL) delete[] head->FromNick;
+ if (head->ReturnPath!=NULL) delete[] head->ReturnPath;
+ if (head->ReturnPathNick!=NULL) delete[] head->ReturnPathNick;
+ if (head->Subject!=NULL) delete[] head->Subject;
+ if (head->Date!=NULL) delete[] head->Date;
+ if (head->To!=NULL) DeleteShortNames(head->To);
+ if (head->Cc!=NULL) DeleteShortNames(head->Cc);
+ if (head->Bcc!=NULL) DeleteShortNames(head->Bcc);
+ if (head->Body!=NULL) delete[] head->Body;
+}
+
+void DeleteHeaderContent(struct CHeader *head)
+{
+ if (head->From!=NULL) delete[] head->From;
+ if (head->FromNick!=NULL) delete[] head->FromNick;
+ if (head->ReturnPath!=NULL) delete[] head->ReturnPath;
+ if (head->ReturnPathNick!=NULL) delete[] head->ReturnPathNick;
+ if (head->Subject!=NULL) delete[] head->Subject;
+ if (head->Date!=NULL) delete[] head->Date;
+ if (head->Body!=NULL) delete[] head->Body;
+ if (head->To!=NULL) DeleteNames(head->To);
+ if (head->Cc!=NULL) DeleteNames(head->Cc);
+ if (head->Bcc!=NULL) DeleteNames(head->Bcc);
+}
+
+void DeleteNames(PYAMN_MIMENAMES Names)
+{
+ PYAMN_MIMENAMES Parser=Names,Old;
+ for (;Parser!=NULL;Parser=Parser->Next)
+ {
+ if (Parser->Value!=NULL)
+ delete[] Parser->Value;
+ if (Parser->ValueNick!=NULL)
+ delete[] Parser->ValueNick;
+ Old=Parser;
+ Parser=Parser->Next;
+ delete Old;
+ }
+}
+
+void DeleteShortNames(PYAMN_MIMESHORTNAMES Names)
+{
+ PYAMN_MIMESHORTNAMES Parser=Names,Old;
+ for (;Parser!=NULL;Parser=Parser->Next)
+ {
+ if (Parser->Value!=NULL)
+ delete[] Parser->Value;
+ if (Parser->ValueNick!=NULL)
+ delete[] Parser->ValueNick;
+ Old=Parser;
+ Parser=Parser->Next;
+ delete Old;
+ }
+}
+
+
+void inline ToLower(char *string)
+{
+ for (;*string!=0;string++)
+ if (*string>='A' && *string<='Z') *string=*string-'A'+'a';
+}
+
+#define TE_UNKNOWN
+#define TE_QUOTEDPRINTABLE 1
+#define TE_BASE64 2
+struct APartDataType
+{
+ char *Src;//Input
+ char *ContType;
+ int CodePage;
+ char *TransEnc;
+ BYTE TransEncType; //TE_something
+ char *body;
+ int bodyLen;
+ WCHAR *wBody;
+};
+
+
+void ParseAPart(APartDataType *data)
+{
+ size_t len = strlen(data->Src);
+ try
+ {
+ char *finder=data->Src;
+ char *prev1,*prev2,*prev3;
+
+ while(finder<=(data->Src+len))
+ {
+ while(ENDLINEWS(finder)) finder++;
+
+ //at the start of line
+ if (finder>data->Src){
+ if (*(finder-2)=='\r' || *(finder-2)=='\n')
+ *(finder-2)=0;
+ if (*(finder-1)=='\r' || *(finder-1)=='\n')
+ *(finder-1)=0;
+ }
+ prev1=finder;
+
+ while(*finder!=':' && !EOS(finder) && !ENDLINE(finder)) finder++;
+ if (ENDLINE(finder)||EOS(finder)) {
+ // no ":" in the line? here the body begins;
+ data->body = prev1;
+ break;
+ }
+ prev2=finder++;
+
+ while(WS(finder) && !EOS(finder)) finder++;
+ if (!EOS(finder))
+ prev3=finder;
+ else
+ break;
+
+ do
+ {
+ if (ENDLINEWS(finder)) finder+=2; //after endline information continues
+ while(!ENDLINE(finder) && !EOS(finder)) finder++;
+ }while(ENDLINEWS(finder));
+
+ if (!_strnicmp(prev1,"Content-type",prev2-prev1)) {
+ data->ContType = prev3;
+ } else if (!_strnicmp(prev1,"Content-Transfer-Encoding",prev2-prev1)) {
+ data->TransEnc = prev3;
+ }
+
+ if (EOS(finder))
+ break;
+ finder++;
+ if (ENDLINE(finder)) {
+ finder++;
+ if (ENDLINE(finder)) {
+ // end of headers. message body begins
+ if (finder>data->Src){
+ if (*(finder-2)=='\r' || *(finder-2)=='\n')
+ *(finder-2)=0;
+ if (*(finder-1)=='\r' || *(finder-1)=='\n')
+ *(finder-1)=0;
+ }
+ finder++;
+ if (ENDLINE(finder))finder++;
+ prev1 = finder;
+ while (!EOS(finder+1))finder++;
+ if (ENDLINE(finder))finder--;
+ prev2 = finder;
+ if (prev2>prev1){ // yes, we have body
+ data->body = prev1;
+ }
+ break; // there is nothing else
+ }
+ }
+ }
+ }
+ catch(...)
+ {
+ MessageBox(NULL,_T("Translate header error"),_T(""),0);
+ }
+ if (data->body) data->bodyLen = (int)strlen(data->body);
+}
+
+//from decode.cpp
+int DecodeQuotedPrintable(char *Src,char *Dst,int DstLen, BOOL isQ);
+int DecodeBase64(char *Src,char *Dst,int DstLen);
+int ConvertStringToUnicode(char *stream,unsigned int cp,WCHAR **out);
+
+WCHAR *ParseMultipartBody(char *src, char *bond)
+{
+ char *srcback = _strdup(src);
+ size_t sizebond = strlen(bond);
+ int numparts = 1;
+ int i;
+ char *courbond = srcback;
+ WCHAR *dest;
+ for (;(courbond=strstr(courbond,bond));numparts++,courbond+=sizebond);
+ APartDataType *partData = new APartDataType[numparts];
+ memset(partData, 0, sizeof(APartDataType)*numparts);
+ partData[0].Src = courbond = srcback;
+ for (i=1;(courbond=strstr(courbond,bond));i++,courbond+=sizebond){
+ *(courbond-2) = 0;
+ partData[i].Src = courbond+sizebond;
+ while (ENDLINE(partData[i].Src)) partData[i].Src++;
+ }
+ size_t resultSize=0;
+ for (i=0;i<numparts;i++) {
+ ParseAPart(&partData[i]);
+ if (partData[i].body){
+ if (partData[i].TransEnc){
+ if (!_stricmp(partData[i].TransEnc,"base64")) partData[i].TransEncType=TE_BASE64;
+ else if (!_stricmp(partData[i].TransEnc,"quoted-printable"))partData[i].TransEncType=TE_QUOTEDPRINTABLE;
+ }
+ if (partData[i].ContType){
+ char *CharSetStr;
+ if (NULL!=(CharSetStr=ExtractFromContentType(partData[i].ContType,"charset=")))
+ {
+ partData[i].CodePage=GetCharsetFromString(CharSetStr,strlen(CharSetStr));
+ delete[] CharSetStr;
+ }
+ }
+ if (partData[i].ContType && !_strnicmp(partData[i].ContType,"text",4)) {
+ char *localBody=0;
+ switch (partData[i].TransEncType){
+ case TE_BASE64:
+ {
+ int size =partData[i].bodyLen*3/4+5;
+ localBody = new char[size+1];
+ DecodeBase64(partData[i].body,localBody,size);
+ }break;
+ case TE_QUOTEDPRINTABLE:
+ {
+ int size = partData[i].bodyLen+2;
+ localBody = new char[size+1];
+ DecodeQuotedPrintable(partData[i].body,localBody,size,FALSE);
+ }break;
+ }
+ ConvertStringToUnicode(localBody?localBody:partData[i].body,partData[i].CodePage,&partData[i].wBody);
+ if (localBody) delete[] localBody;
+ } else if (partData[i].ContType && !_strnicmp(partData[i].ContType,"multipart/",10)) {
+ //Multipart in mulitipart recursive? should be SPAM. Ah well
+ char *bondary=NULL;
+ if (NULL!=(bondary=ExtractFromContentType(partData[i].ContType,"boundary=")))
+ {
+ partData[i].wBody = ParseMultipartBody(partData[i].body,bondary);
+ delete[] bondary;
+ } else goto FailBackRaw; //multipart with no boundary? badly formatted messages.
+ } else {
+FailBackRaw:
+ ConvertStringToUnicode(partData[i].body,partData[i].CodePage,&partData[i].wBody);
+ }
+ resultSize += wcslen(partData[i].wBody);
+ }// if (partData[i].body)
+ resultSize += 100+4+3; //cr+nl+100+ 3*bullet
+ }
+ dest = new WCHAR[resultSize+1];
+ size_t destpos = 0;
+ for (i=0;i<numparts;i++) {
+ if (i){ // part before first boudary should not have headers
+ char infoline[104]; size_t linesize = 0;
+ _snprintf(infoline,100,"%s %d",Translate("Part"),i);
+ linesize = strlen(infoline);
+ if (partData[i].TransEnc){
+ _snprintf(infoline+linesize,100-linesize,"; %s",partData[i].TransEnc);
+ linesize = strlen(infoline);
+ }
+ if (partData[i].ContType){
+ char *CharSetStr=strchr(partData[i].ContType,';');
+ if (CharSetStr){
+ CharSetStr[0]=0;
+ _snprintf(infoline+linesize,100-linesize,"; %s",partData[i].ContType);
+ linesize = strlen(infoline);
+ partData[i].ContType=CharSetStr+1;
+ if (NULL!=(CharSetStr=ExtractFromContentType(partData[i].ContType,"charset=")))
+ {
+ _snprintf(infoline+linesize,100-linesize,"; %s",CharSetStr);
+ linesize = strlen(infoline);
+ delete[] CharSetStr;
+ }
+ if (NULL!=(CharSetStr=ExtractFromContentType(partData[i].ContType,"name=")))
+ {
+ _snprintf(infoline+linesize,100-linesize,"; \"%s\"",CharSetStr);
+ linesize = strlen(infoline);
+ delete[] CharSetStr;
+ }
+ } else {
+ _snprintf(infoline+linesize,100-linesize,"; %s",partData[i].ContType);
+ linesize = strlen(infoline);
+ }
+ }
+ sprintf(infoline+linesize,".\r\n");
+ {WCHAR *temp=0;
+ dest[destpos] = dest[destpos+1] = dest[destpos+2] = 0x2022; // bullet;
+ destpos+=3;
+ ConvertStringToUnicode(infoline,CP_ACP,&temp);
+ size_t wsize = wcslen(temp);
+ wcscpy(&dest[destpos],temp);
+ destpos += wsize;
+ delete[] temp;
+ }
+ } // if (i)
+ if (partData[i].wBody){
+ size_t wsize = wcslen(partData[i].wBody);
+ wcscpy(&dest[destpos],partData[i].wBody);
+ destpos += wsize;
+ delete[] partData[i].wBody;
+ }
+ }
+
+ free (srcback);
+ delete[] partData;
+ dest[resultSize] = 0;//just in case
+ return dest;
+}
diff --git a/plugins/YAMN/src/main.cpp b/plugins/YAMN/src/main.cpp new file mode 100644 index 0000000000..018d9f9565 --- /dev/null +++ b/plugins/YAMN/src/main.cpp @@ -0,0 +1,501 @@ +/*
+ * YAMN plugin main file
+ * Miranda homepage: http://miranda-icq.sourceforge.net/
+ * YAMN homepage: http://www.majvan.host.sk/Projekty/YAMN
+ *
+ * initializes all variables for further work
+ *
+ * (c) majvan 2002-2004
+ */
+
+
+#include "yamn.h"
+#include "main.h"
+#include <io.h>
+
+#include "m_hotkeys.h"
+
+//--------------------------------------------------------------------------------------------------
+
+TCHAR ProfileName[MAX_PATH];
+TCHAR UserDirectory[MAX_PATH];
+
+TCHAR szMirandaDir[MAX_PATH];
+TCHAR szProfileDir[MAX_PATH];
+
+int YAMN_STATUS;
+
+BOOL UninstallPlugins;
+
+HANDLE hAccountFolder;
+
+HINSTANCE *hDllPlugins;
+static int iDllPlugins = 0;
+
+
+YAMN_VARIABLES YAMNVar;
+
+int hLangpack;
+
+PLUGININFOEX pluginInfo = {
+ sizeof(PLUGININFOEX),
+ YAMN_SHORTNAME,
+ YAMN_VERSION,
+ "Mail notifier and browser for Miranda NG. Included POP3 protocol.",
+ "y_b tweety (majvan)",
+ "francois.mean@skynet.be",
+ "© (2002-2004 majvan) 2005-2007 tweety y_b Miranda community",
+ "http://miranda-ng.org/", //"http://www.majvan.host.sk/Projekty/YAMN?fm = soft",
+ UNICODE_AWARE,
+ { 0xb047a7e5, 0x27a, 0x4cfc, { 0x8b, 0x18, 0xed, 0xa8, 0x34, 0x5d, 0x27, 0x90 } } // {B047A7E5-027A-4cfc-8B18-EDA8345D2790}
+};
+
+HANDLE hNewMailHook;
+HANDLE NoWriterEV;
+HANDLE hTTButton;
+
+UINT SecTimer;
+
+HANDLE hMenuItemMain = 0;
+HANDLE hMenuItemCont = 0;
+HANDLE hMenuItemContApp = 0;
+
+HMODULE hUxTheme = 0;
+BOOL (WINAPI *MyEnableThemeDialogTexture)(HANDLE, DWORD) = 0;
+
+// function pointers, use typedefs for casting to shut up the compiler when using GetProcAddress()
+
+typedef BOOL (WINAPI *PITA)();
+typedef HANDLE (WINAPI *POTD)(HWND, LPCWSTR);
+typedef UINT (WINAPI *PDTB)(HANDLE, HDC, int, int, RECT *, RECT *);
+typedef UINT (WINAPI *PCTD)(HANDLE);
+typedef UINT (WINAPI *PDTT)(HANDLE, HDC, int, int, LPCWSTR, int, DWORD, DWORD, RECT *);
+
+PITA pfnIsThemeActive = 0;
+POTD pfnOpenThemeData = 0;
+PDTB pfnDrawThemeBackground = 0;
+PCTD pfnCloseThemeData = 0;
+PDTT pfnDrawThemeText = 0;
+
+#define FIXED_TAB_SIZE 100 // default value for fixed width tabs
+
+/*
+ * visual styles support (XP+)
+ * returns 0 on failure
+ */
+
+int InitVSApi()
+{
+ if ((hUxTheme = LoadLibraryA("uxtheme.dll")) == 0)
+ return 0;
+
+ pfnIsThemeActive = (PITA)GetProcAddress(hUxTheme, "IsThemeActive");
+ pfnOpenThemeData = (POTD)GetProcAddress(hUxTheme, "OpenThemeData");
+ pfnDrawThemeBackground = (PDTB)GetProcAddress(hUxTheme, "DrawThemeBackground");
+ pfnCloseThemeData = (PCTD)GetProcAddress(hUxTheme, "CloseThemeData");
+ pfnDrawThemeText = (PDTT)GetProcAddress(hUxTheme, "DrawThemeText");
+
+ MyEnableThemeDialogTexture = (BOOL (WINAPI *)(HANDLE, DWORD))GetProcAddress(hUxTheme, "EnableThemeDialogTexture");
+ if (pfnIsThemeActive != 0 && pfnOpenThemeData != 0 && pfnDrawThemeBackground != 0 && pfnCloseThemeData != 0 && pfnDrawThemeText != 0)
+ return 1;
+
+ return 0;
+}
+
+/*
+ * unload uxtheme.dll
+ */
+
+int FreeVSApi()
+{
+ if (hUxTheme != 0)
+ FreeLibrary(hUxTheme);
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+
+static void GetProfileDirectory(TCHAR *szPath, int cbPath)
+//This is copied from Miranda's sources. In 0.2.1.0 it is needed, in newer vesions of Miranda use MS_DB_GETPROFILEPATH service
+{
+ TCHAR tszOldPath[MAX_PATH];
+ CallService(MS_DB_GETPROFILEPATHT, SIZEOF(tszOldPath), (LPARAM)tszOldPath);
+ _tcscat(tszOldPath, _T("\\*.book"));
+
+ TCHAR* ptszNewPath = Utils_ReplaceVarsT( _T("%miranda_userdata%"));
+
+ SHFILEOPSTRUCT file_op = {
+ NULL,
+ FO_MOVE,
+ tszOldPath,
+ ptszNewPath,
+ FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT,
+ false,
+ 0,
+ _T("") };
+ SHFileOperation(&file_op);
+
+ _tcsncpy(szPath, ptszNewPath, cbPath);
+ mir_free(ptszNewPath);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ YAMNVar.hInst = hinstDLL;
+ return TRUE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MUUID_YAMN_FORCECHECK, MIID_LAST};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef YAMN_DEBUG
+static char unknownCP[1500] = {0};
+#endif
+// The callback function
+BOOL CALLBACK EnumSystemCodePagesProc(LPTSTR cpStr)
+{
+ //Convert code page string to number
+ UINT cp = _ttoi(cpStr);
+ if (!IsValidCodePage(cp))
+ return TRUE;
+
+ //Get Code Page name
+ CPINFOEX info;
+ if (GetCPInfoEx(cp, 0, &info)) {
+ #ifdef YAMN_DEBUG
+ BOOLEAN found = FALSE;
+ #endif
+ for (int i = 1;i<CPLENALL;i++) if (CodePageNamesAll[i].CP == cp) {
+ CodePageNamesAll[i].isValid = TRUE;
+ CPLENSUPP++;
+ #ifdef YAMN_DEBUG
+ found = TRUE;
+ #endif
+ break;
+ }
+ #ifdef YAMN_DEBUG
+ if (!found) {
+ strcat(unknownCP, info.CodePageName);
+ strcat(unknownCP, "\n");
+ }
+ #endif
+ }
+ return TRUE;
+}
+
+void CheckMenuItems()
+{
+ CLISTMENUITEM clmi = {0};
+ clmi.cbSize = sizeof( CLISTMENUITEM );
+ clmi.flags = CMIM_FLAGS;
+ if ( !DBGetContactSettingByte(NULL, YAMN_DBMODULE, YAMN_SHOWMAINMENU, 1))
+ clmi.flags |= CMIF_HIDDEN;
+
+ CallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )hMenuItemMain, ( LPARAM )&clmi );
+}
+
+int SystemModulesLoaded(WPARAM, LPARAM)
+{
+ //Insert "Check mail (YAMN)" item to Miranda's menu
+ CLISTMENUITEM mi = { 0 };
+ mi.cbSize = sizeof(mi);
+ mi.position = 0xb0000000;
+ mi.flags = CMIF_ICONFROMICOLIB;
+ mi.icolibItem = g_GetIconHandle(0);
+ mi.pszName = "Check &mail (All Account)";
+ mi.pszPopupName = NULL;//YAMN_DBMODULE;
+ mi.pszService = MS_YAMN_FORCECHECK;
+ hMenuItemMain = Menu_AddMainMenuItem(&mi);
+
+ mi.pszName = "Check &mail (This Account)";
+ mi.pszContactOwner = YAMN_DBMODULE;
+ mi.pszService = MS_YAMN_CLISTCONTEXT;
+ hMenuItemCont = Menu_AddContactMenuItem(&mi);
+
+ mi.icolibItem = g_GetIconHandle(1);
+ mi.pszName = "Launch application";
+ mi.pszContactOwner = YAMN_DBMODULE;
+ mi.pszService = MS_YAMN_CLISTCONTEXTAPP;
+ hMenuItemContApp = Menu_AddContactMenuItem(&mi);
+
+ CheckMenuItems();
+
+ if (ServiceExists(MS_FOLDERS_GET_PATH)) {
+ hAccountFolder = FoldersRegisterCustomPathT(YAMN_DBMODULE, YAMN_DBMODULE" Account Folder", UserDirectory);
+ FoldersGetCustomPathT(hAccountFolder, UserDirectory, MAX_PATH, UserDirectory);
+ }
+
+ RegisterPOP3Plugin(0, 0);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct TIconListItem
+{
+ TCHAR* szDescr;
+ char* szName;
+ int defIconID;
+ HANDLE hIcon;
+};
+
+static TIconListItem iconList[] =
+{
+
+ {LPGENT("Check mail"), "YAMN_Check", IDI_CHECKMAIL, 0},
+ {LPGENT("Launch application"), "YAMN_Launch", IDI_LAUNCHAPP, 0},
+ {LPGENT("New Mail"), "YAMN_NewMail", IDI_NEWMAIL, 0},
+ {LPGENT("Connect Fail"), "YAMN_ConnectFail", IDI_BADCONNECT, 0},
+};
+
+static void LoadIcons()
+{
+ TCHAR szFile[MAX_PATH];
+ GetModuleFileName(YAMNVar.hInst, szFile, MAX_PATH);
+
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(SKINICONDESC);
+ sid.flags = SIDF_ALL_TCHAR;
+ sid.ptszDefaultFile = szFile;
+ sid.ptszSection = _T("YAMN");
+
+ for (int i = 0, k = 0; i < SIZEOF(iconList); i++)
+ {
+ sid.pszName = iconList[i].szName;
+ sid.ptszDescription = iconList[i].szDescr;
+ sid.iDefaultIndex = -iconList[i].defIconID;
+ iconList[i].hIcon = Skin_AddIcon(&sid);
+ }
+}
+
+HANDLE WINAPI g_GetIconHandle( int idx )
+{
+ if ( idx >= SIZEOF(iconList))
+ return NULL;
+ return iconList[idx].hIcon;
+}
+
+HICON WINAPI g_LoadIconEx( int idx, bool big )
+{
+ if ( idx >= SIZEOF(iconList))
+ return NULL;
+ return Skin_GetIcon(iconList[idx].szName, big);
+}
+
+void WINAPI g_ReleaseIcon( HICON hIcon )
+{
+ if ( hIcon ) Skin_ReleaseIcon(hIcon);
+}
+
+static void LoadPlugins()
+{
+ HANDLE hFind;
+ WIN32_FIND_DATA fd;
+ TCHAR szSearchPath[MAX_PATH];
+ TCHAR szPluginPath[MAX_PATH];
+ lstrcpy(szSearchPath, szMirandaDir);
+ lstrcat(szSearchPath, _T("\\Plugins\\YAMN\\*.dll"));
+ typedef INT_PTR (*LOADFILTERFCN)(MIRANDASERVICE GetYAMNFcn);
+
+ hDllPlugins = NULL;
+
+ if (INVALID_HANDLE_VALUE!=(hFind = FindFirstFile(szSearchPath, &fd))) {
+ do {
+ //rewritten from Miranda sources... Needed because Win32 API has a bug in FindFirstFile, search is done for *.dlllllll... too
+ TCHAR *dot = _tcsrchr(fd.cFileName, '.');
+ if (dot == NULL )
+ continue;
+
+ // we have a dot
+ int len = (int)lstrlen(fd.cFileName); // find the length of the string
+ TCHAR* end = fd.cFileName+len; // get a pointer to the NULL
+ int safe = (end-dot)-1; // figure out how many chars after the dot are "safe", not including NULL
+
+ if ((safe!=3) || (lstrcmpi(dot+1, _T("dll"))!=0)) //not bound, however the "dll" string should mean only 3 chars are compared
+ continue;
+
+ HINSTANCE hDll;
+ LOADFILTERFCN LoadFilter;
+
+ lstrcpy(szPluginPath, szMirandaDir);
+ lstrcat(szPluginPath, _T("\\Plugins\\YAMN\\"));
+ lstrcat(szPluginPath, fd.cFileName);
+ if ((hDll = LoadLibrary(szPluginPath)) == NULL) continue;
+ LoadFilter = (LOADFILTERFCN)GetProcAddress(hDll, "LoadFilter");
+ if (NULL == LoadFilter) {
+ FreeLibrary(hDll);
+ hDll = NULL;
+ continue;
+ }
+
+ if (!(*LoadFilter)(GetFcnPtrSvc)) {
+ FreeLibrary(hDll);
+ hDll = NULL;
+ }
+
+ if (hDll != NULL) {
+ hDllPlugins = (HINSTANCE *)realloc((void *)hDllPlugins, (iDllPlugins+1)*sizeof(HINSTANCE));
+ hDllPlugins[iDllPlugins++] = hDll;
+ }
+ }
+ while(FindNextFile(hFind, &fd));
+
+ FindClose(hFind);
+ }
+}
+
+extern "C" int __declspec(dllexport) Load(void)
+{
+ int i, k;
+ mir_getLP(&pluginInfo);
+
+ YAMN_STATUS = ID_STATUS_OFFLINE;
+
+ // we get the Miranda Root Path
+ if (ServiceExists(MS_UTILS_PATHTOABSOLUTET))
+ CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)_T("."), (LPARAM)szMirandaDir);
+ else {
+ GetModuleFileName(GetModuleHandle(NULL), szMirandaDir, MAX_PATH);
+ TCHAR* str2 = _tcsrchr(szMirandaDir, '\\');
+ if (str2!=NULL) *str2 = 0;
+ }
+
+ // retrieve the current profile name
+ CallService(MS_DB_GETPROFILENAMET, (WPARAM)SIZEOF(ProfileName), (LPARAM)ProfileName); //not to pass entire array to fcn
+ TCHAR *fc = _tcsrchr(ProfileName, '.');
+ if ( fc != NULL ) *fc = 0;
+
+ // we get the user path where our yamn-account.book.ini is stored from mirandaboot.ini file
+ GetProfileDirectory(UserDirectory, SIZEOF(UserDirectory));
+
+ // Enumerate all the code pages available for the System Locale
+ EnumSystemCodePages(EnumSystemCodePagesProc, CP_INSTALLED);
+ CodePageNamesSupp = new _tcptable[CPLENSUPP];
+ for (i = 0, k = 0; i < CPLENALL; i++) {
+ if (CodePageNamesAll[i].isValid){
+ CodePageNamesSupp[k] = CodePageNamesAll[i];
+ k++;
+ } }
+
+ // Registering YAMN as protocol
+ PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
+ pd.szName = YAMN_DBMODULE;
+ pd.type = PROTOTYPE_VIRTUAL;
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
+
+ InitializeCriticalSection(&AccountStatusCS);
+ InitializeCriticalSection(&FileWritingCS);
+ InitializeCriticalSection(&PluginRegCS);
+
+ if (NULL == (NoWriterEV = CreateEvent(NULL, TRUE, TRUE, NULL)))
+ return 1;
+ if (NULL == (WriteToFileEV = CreateEvent(NULL, FALSE, FALSE, NULL)))
+ return 1;
+ if (NULL == (ExitEV = CreateEvent(NULL, TRUE, FALSE, NULL)))
+ return 1;
+
+ PosX = DBGetContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBPOSX, 0);
+ PosY = DBGetContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBPOSY, 0);
+ SizeX = DBGetContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBSIZEX, 800);
+ SizeY = DBGetContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBSIZEY, 200);
+
+ HeadPosX = DBGetContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBMSGPOSX, 0);
+ HeadPosY = DBGetContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBMSGPOSY, 0);
+ HeadSizeX = DBGetContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBMSGSIZEX, 690);
+ HeadSizeY = DBGetContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBMSGSIZEY, 300);
+ HeadSplitPos = DBGetContactSettingWord(NULL, YAMN_DBMODULE, YAMN_DBMSGPOSSPLIT, 250);
+
+ optDateTime = DBGetContactSettingByte(NULL, YAMN_DBMODULE, YAMN_DBTIMEOPTIONS, optDateTime);
+
+ // Create new window queues for broadcast messages
+ YAMNVar.MessageWnds = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ YAMNVar.NewMailAccountWnd = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+ YAMNVar.Shutdown = FALSE;
+
+ hCurSplitNS = LoadCursor(NULL, IDC_SIZENS);
+ hCurSplitWE = LoadCursor(NULL, IDC_SIZEWE);
+
+#ifdef YAMN_DEBUG
+ InitDebug();
+#endif
+
+ CreateServiceFunctions();
+
+ SkinAddNewSoundEx(YAMN_NEWMAILSOUND, YAMN_DBMODULE, YAMN_NEWMAILSNDDESC);
+ SkinAddNewSoundEx(YAMN_CONNECTFAILSOUND, YAMN_DBMODULE, YAMN_CONNECTFAILSNDDESC);
+
+ HookEvents();
+
+ LoadIcons();
+ LoadPlugins();
+ InitVSApi();
+
+ HOTKEYDESC hkd = {0};
+ hkd.cbSize = sizeof(hkd);
+ hkd.pszService = MS_YAMN_FORCECHECK;
+ hkd.pszSection = YAMN_DBMODULE;
+ hkd.pszDescription = LPGEN("Check mail");
+ hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, VK_F11);
+ Hotkey_Register(&hkd);
+
+ //Create thread that will be executed every second
+ if (!(SecTimer = SetTimer(NULL, 0, 1000, (TIMERPROC)TimerProc)))
+ return 1;
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static void UnloadPlugins()
+{
+ for (int i = iDllPlugins-1;i>=0;i--) {
+ if (FreeLibrary(hDllPlugins[i])) {
+ hDllPlugins[i] = NULL; //for safety
+ iDllPlugins --;
+ }
+ }
+ if (hDllPlugins){
+ free((void *)hDllPlugins);
+ hDllPlugins = NULL;
+ }
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+#ifdef YAMN_DEBUG
+ UnInitDebug();
+#endif
+ DestroyCursor(hCurSplitNS);
+ DestroyCursor(hCurSplitWE);
+
+ CloseHandle(NoWriterEV);
+ CloseHandle(WriteToFileEV);
+ CloseHandle(ExitEV);
+
+ FreeVSApi();
+
+ DeleteCriticalSection(&AccountStatusCS);
+ DeleteCriticalSection(&FileWritingCS);
+ DeleteCriticalSection(&PluginRegCS);
+
+ UnhookEvents();
+ DestroyServiceFunctions();
+
+ UnloadPlugins();
+
+ delete [] CodePageNamesSupp;
+ return 0;
+}
diff --git a/plugins/YAMN/src/main.h b/plugins/YAMN/src/main.h new file mode 100644 index 0000000000..08d9f91fed --- /dev/null +++ b/plugins/YAMN/src/main.h @@ -0,0 +1,51 @@ +#ifndef __MAIN_H
+#define __MAIN_H
+
+#ifdef __GNUC__
+ #define __try
+ #define __except(x) if (0) /* don't execute handler */
+ #define __finally
+ #define _try __try
+ #define _except __except
+ #define _finally __finally
+#endif
+
+#define YAMN_SHORTNAME "YAMN tweety"
+#define YAMN_FILENAME "yamn"
+
+
+#include "version.h"
+#define YAMN_NEWMAILSNDDESC "YAMN: new mail message"
+#define YAMN_CONNECTFAILSNDDESC "YAMN: connect failed"
+#define YAMN_CONNECTFAILSOUND "YAMN/Sound/ConnectFail"
+#define YAMN_NEWMAILSOUND "YAMN/Sound/NewMail"
+
+#define YAMN_DBMODULE "YAMN"
+#define YAMN_DBPOSX "MailBrowserWinX"
+#define YAMN_DBPOSY "MailBrowserWinY"
+#define YAMN_DBSIZEX "MailBrowserWinW"
+#define YAMN_DBSIZEY "MailBrowserWinH"
+#define YAMN_DBMSGPOSX "MailMessageWinX"
+#define YAMN_DBMSGPOSY "MailMessageWinY"
+#define YAMN_DBMSGSIZEX "MailMessageWinW"
+#define YAMN_DBMSGSIZEY "MailMessageWinH"
+#define YAMN_DBMSGPOSSPLIT "MailMessageSplitY"
+#define YAMN_TTBFCHECK "ForceCheckTTB"
+#define YAMN_SHOWMAINMENU "ShowMainMenu"
+#define YAMN_CLOSEDELETE "CloseOnDelete"
+#define YAMN_SHOWASPROTO "ShowAsProtcol"
+#define YAMN_DBTIMEOPTIONS "MailBrowserTimeOpts"
+
+#define YAMN_DEFAULTHK MAKEWORD(VK_F11,MOD_CONTROL)
+
+#define SHOWDATELONG 0x01
+#define SHOWDATENOTODAY 0x02
+#define SHOWDATENOSECONDS 0x04
+
+extern unsigned char optDateTime;
+
+// Loading Icon and checking for icolib
+void LoadIcons();
+
+#endif
+
diff --git a/plugins/YAMN/src/proto/md5.c b/plugins/YAMN/src/proto/md5.c new file mode 100644 index 0000000000..280fcdeaae --- /dev/null +++ b/plugins/YAMN/src/proto/md5.c @@ -0,0 +1,259 @@ +/* + * This code implements the MD5 message-digest algorithm. + * The algorithm is due to Ron Rivest. This code was + * written by Colin Plumb in 1993, no copyright is claimed. + * This code is in the public domain; do with it what you wish. + * + * Equivalent code is available from RSA Data Security, Inc. + * This code has been tested against that, and is equivalent, + * except that you don't need to include two pages of legalese + * with every copy. + * + * To compute the message digest of a chunk of bytes, declare an + * MD5Context structure, pass it to MD5Init, call MD5Update as + * needed on buffers full of bytes, and then call MD5Final, which + * will fill a supplied 16-byte array with the digest. + */
+//#include <string.h> /* for memcpy() */ +#if defined(_WIN64) + typedef unsigned __int64 size_t; +#else + typedef unsigned int size_t; +#endif +void * __cdecl memcpy(void *, const void *, size_t);
+void * __cdecl memset(void *, int, size_t);
+#include "md5.h" + +#ifndef HIGHFIRST +#define byteReverse(buf, len) /* Nothing */ +#else +void byteReverse(unsigned char *buf, unsigned longs); + +#ifndef ASM_MD5 +/* + * Note: this code is harmless on little-endian machines. + */ +void byteReverse(unsigned char *buf, unsigned longs) +{ + uint32 t; + do { + t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | + ((unsigned) buf[1] << 8 | buf[0]); + *(uint32 *) buf = t; + buf += 4; + } while (--longs); +} +#endif +#endif + +/* + * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious + * initialization constants. + */ +void MD5Init(struct MD5Context *ctx) +{ + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; + + ctx->bits[0] = 0; + ctx->bits[1] = 0; +} + +/* + * Update context to reflect the concatenation of another buffer full + * of bytes. + */ +void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) +{ + uint32 t; + + /* Update bitcount */ + + t = ctx->bits[0]; + if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) + ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1] += len >> 29; + + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + + /* Handle any leading odd-sized chunks */ + + if (t) { + unsigned char *p = (unsigned char *) ctx->in + t; + + t = 64 - t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); + buf += t; + len -= t; + } + /* Process data in 64-byte chunks */ + + while (len >= 64) { + memcpy(ctx->in, buf, 64); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); + buf += 64; + len -= 64; + } + + /* Handle any remaining bytes of data. */ + + memcpy(ctx->in, buf, len); +} + +/* + * Final wrapup - pad to 64-byte boundary with the bit pattern + * 1 0* (64-bit count of bits processed, MSB-first) + */ +void MD5Final(unsigned char digest[16], struct MD5Context *ctx) +{ + unsigned count; + unsigned char *p; + + /* Compute number of bytes mod 64 */ + count = (ctx->bits[0] >> 3) & 0x3F; + + /* Set the first char of padding to 0x80. This is safe since there is + always at least one byte free */ + p = ctx->in + count; + *p++ = 0x80; + + /* Bytes of padding needed to make 64 bytes */ + count = 64 - 1 - count; + + /* Pad out to 56 mod 64 */ + if (count < 8) { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (uint32 *) ctx->in); + + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); + } else { + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); + } + byteReverse(ctx->in, 14); + + /* Append length in bits and transform */ + ((uint32 *) ctx->in)[14] = ctx->bits[0]; + ((uint32 *) ctx->in)[15] = ctx->bits[1]; + + MD5Transform(ctx->buf, (uint32 *) ctx->in); + byteReverse((unsigned char *) ctx->buf, 4); + memcpy(digest, ctx->buf, 16); + memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ +} + +#ifndef ASM_MD5 + +/* The four core functions - F1 is optimized somewhat */ + +/* #define F1(x, y, z) (x & y | ~x & z) */ +#define F1(x, y, z) (z ^ (x & (y ^ z))) +#define F2(x, y, z) F1(z, x, y) +#define F3(x, y, z) (x ^ y ^ z) +#define F4(x, y, z) (y ^ (x | ~z)) + +/* This is the central step in the MD5 algorithm. */ +#define MD5STEP(f, w, x, y, z, data, s) \ + ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) + +/* + * The core of the MD5 algorithm, this alters an existing MD5 hash to + * reflect the addition of 16 longwords of new data. MD5Update blocks + * the data and converts bytes into longwords for this routine. + */ +void MD5Transform(uint32 buf[4], uint32 const in[16]) +{ + register uint32 a, b, c, d; + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} + +#endif diff --git a/plugins/YAMN/src/proto/md5.h b/plugins/YAMN/src/proto/md5.h new file mode 100644 index 0000000000..e264f686db --- /dev/null +++ b/plugins/YAMN/src/proto/md5.h @@ -0,0 +1,27 @@ +#ifndef MD5_H +#define MD5_H + +#ifdef __alpha +typedef unsigned int uint32; +#else +typedef unsigned long uint32; +#endif + +struct MD5Context { + uint32 buf[4]; + uint32 bits[2]; + unsigned char in[64]; +}; + +void MD5Init(struct MD5Context *context); +void MD5Update(struct MD5Context *context, unsigned char const *buf, + unsigned len); +void MD5Final(unsigned char digest[16], struct MD5Context *context); +void MD5Transform(uint32 buf[4], uint32 const in[16]); + +/* + * This is needed to make RSAREF happy on some MS-DOS compilers. + */ +typedef struct MD5Context MD5_CTX; + +#endif /* !MD5_H */ diff --git a/plugins/YAMN/src/proto/netclient.h b/plugins/YAMN/src/proto/netclient.h new file mode 100644 index 0000000000..2414dbdef1 --- /dev/null +++ b/plugins/YAMN/src/proto/netclient.h @@ -0,0 +1,22 @@ +#ifndef __CLIENT_H
+#define __CLIENT_H
+
+class CNetClient
+{
+public:
+ CNetClient(): Stopped(FALSE) {}
+ virtual void Connect(const char* servername,const int port)=0;
+ virtual void Send(const char *query)=0;
+ virtual char* Recv(char *buf=NULL,int buflen=65536)=0;
+ virtual void Disconnect()=0;
+ virtual BOOL Connected()=0;
+ virtual void SSLify()=0;
+
+ BOOL Stopped;
+ int Rcv;
+ DWORD NetworkError;
+ DWORD SystemError;
+ BOOL ifTLSed;
+};
+
+#endif
diff --git a/plugins/YAMN/src/proto/netlib.cpp b/plugins/YAMN/src/proto/netlib.cpp new file mode 100644 index 0000000000..b7c1864ffa --- /dev/null +++ b/plugins/YAMN/src/proto/netlib.cpp @@ -0,0 +1,271 @@ +/*
+ * This code implements communication based on Miranda netlib library
+ *
+ * (c) majvan 2002-2004
+ */
+
+#include "..\yamn.h"
+#include "m_netlib.h"
+#include "netlib.h"
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+BOOL SSLLoaded=FALSE;
+HANDLE hNetlibUser=NULL;
+
+extern PVOID TLSCtx;
+extern PVOID SSLCtx;
+
+void __stdcall SSL_DebugLog(const char *fmt, ...)
+{
+ char str[ 4096 ];
+ va_list vararg;
+
+ va_start( vararg, fmt );
+ int tBytes = _vsnprintf( str, sizeof(str)-1, fmt, vararg );
+ if ( tBytes == 0 )
+ return;
+
+ if ( tBytes > 0 )
+ str[ tBytes ] = 0;
+ else
+ str[ sizeof(str)-1 ] = 0;
+
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, (LPARAM)str);
+ va_end( vararg );
+}
+
+HANDLE RegisterNLClient(const char *name)
+{
+ static NETLIBUSER nlu={0};
+ char desc[128];
+
+ sprintf(desc, Translate("%s connection"),name);
+
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"<Register PROXY support>");
+#endif
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
+ nlu.szDescriptiveName=desc;
+ nlu.szSettingsModule=(char *)name;
+ hNetlibUser=(HANDLE)CallService(MS_NETLIB_REGISTERUSER,0,(LPARAM)&nlu);
+
+#ifdef DEBUG_COMM
+ if (NULL==hNetlibUser)
+ DebugLog(CommFile,"<error></Register PROXY support>\n");
+ else
+ DebugLog(CommFile,"</Register PROXY support>\n");
+#endif
+ return hNetlibUser;
+}
+
+//Move connection to SSL
+void CNLClient::SSLify() throw(DWORD){
+#ifdef DEBUG_COMM
+ SSL_DebugLog("Staring SSL...");
+#endif
+ int socket = CallService(MS_NETLIB_GETSOCKET, (WPARAM)hConnection, 0);
+ if (socket != INVALID_SOCKET)
+ {
+#ifdef DEBUG_COMM
+ SSL_DebugLog("Staring netlib core SSL");
+#endif
+ if (CallService(MS_NETLIB_STARTSSL, (WPARAM)hConnection, 0))
+ {
+#ifdef DEBUG_COMM
+ SSL_DebugLog("Netlib core SSL started");
+#endif
+ isTLSed = true;
+ SSLLoaded = TRUE;
+ return;
+ }
+ }
+
+ //ssl could not be created
+ throw NetworkError = (DWORD)ESSL_CREATESSL;
+}
+
+//Connects to the server through the sock
+//if not success, exception is throwed
+void CNLClient::Connect(const char* servername,const int port) throw(DWORD)
+{
+ NETLIBOPENCONNECTION nloc;
+
+ NetworkError=SystemError=0;
+ isTLSed = false;
+
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"<connect>\n");
+#endif
+ try
+ {
+ nloc.cbSize=sizeof(NETLIBOPENCONNECTION);
+ nloc.szHost=servername;
+ nloc.wPort=port;
+ nloc.flags=0;
+ if (NULL==(hConnection=(HANDLE)CallService(MS_NETLIB_OPENCONNECTION,(WPARAM)hNetlibUser,(LPARAM)&nloc)))
+ {
+ SystemError=WSAGetLastError();
+ throw NetworkError=(DWORD)ENL_CONNECT;
+ }
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"</connect>\n");
+#endif
+ return;
+ }
+ catch(...)
+ {
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"<error></connect>\n");
+#endif
+ throw;
+ }
+}
+
+//Performs a simple query
+// query- command to send
+int CNLClient::LocalNetlib_Send(HANDLE hConn,const char *buf,int len,int flags) {
+ if (isTLSed)
+ {
+#ifdef DEBUG_COMM
+ SSL_DebugLog("SSL send: %s", buf);
+#endif
+ }
+
+ NETLIBBUFFER nlb={(char*)buf,len,flags};
+ return CallService(MS_NETLIB_SEND,(WPARAM)hConn,(LPARAM)&nlb);
+}
+
+void CNLClient::Send(const char *query) throw(DWORD)
+{
+ unsigned int Sent;
+
+ if (NULL==query)
+ return;
+ if (hConnection==NULL)
+ return;
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"<send>%s",query);
+#endif
+ try
+ {
+ if ((SOCKET_ERROR==(Sent=LocalNetlib_Send(hConnection,query,(int)strlen(query),MSG_DUMPASTEXT))) || Sent!=(unsigned int)strlen(query))
+ {
+ SystemError=WSAGetLastError();
+ throw NetworkError=(DWORD)ENL_SEND;
+ }
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"</send>\n");
+#endif
+ }
+ catch(...)
+ {
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"<error></send>\n");
+#endif
+ throw;
+ }
+}
+
+//Reads data from socket
+// buf- buffer where to store max. buflen of received characters
+// if buf is NULL, creates buffer of buflen size
+// buf is NULL by default
+//You need free() returned buffer, which can be allocated in this function
+//if not success, exception is throwed
+
+int CNLClient::LocalNetlib_Recv(HANDLE hConn,char *buf,int len,int flags) {
+ NETLIBBUFFER nlb={buf,len,flags};
+ int iReturn = CallService(MS_NETLIB_RECV,(WPARAM)hConn,(LPARAM)&nlb);
+ if (isTLSed)
+ {
+#ifdef DEBUG_COMM
+ SSL_DebugLog("SSL recv: %s", buf);
+#endif
+ }
+
+ return iReturn;
+}
+
+char* CNLClient::Recv(char *buf,int buflen) throw(DWORD)
+{
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"<reading>");
+#endif
+ try
+ {
+ if (buf==NULL)
+ buf=(char *)malloc(sizeof(char)*(buflen+1));
+ if (buf==NULL)
+ throw NetworkError=(DWORD)ENL_RECVALLOC;
+
+ if (!isTLSed)
+ {
+ NETLIBSELECT nls;
+ memset(&nls, 0, sizeof(NETLIBSELECT));
+ nls.cbSize = sizeof(NETLIBSELECT);
+ nls.dwTimeout = 60000;
+ nls.hReadConns[0] = hConnection;
+ switch (CallService(MS_NETLIB_SELECT, 0, (LPARAM) &nls))
+ {
+ case SOCKET_ERROR:
+ free(buf);
+ SystemError=WSAGetLastError();
+ throw NetworkError = (DWORD) ENL_RECV;
+ case 0: // time out!
+ free(buf);
+ throw NetworkError = (DWORD) ENL_TIMEOUT;
+ }
+ }
+
+ ZeroMemory(buf,buflen);
+ if (SOCKET_ERROR==(Rcv=LocalNetlib_Recv(hConnection,buf,buflen,MSG_DUMPASTEXT)))
+ {
+ free(buf);
+ SystemError=WSAGetLastError();
+ throw NetworkError=(DWORD)ENL_RECV;
+ }
+ if (!Rcv)
+ {
+ free(buf);
+ SystemError=WSAGetLastError();
+ throw NetworkError=(DWORD)ENL_RECV;
+ }
+#ifdef DEBUG_COMM
+ *(buf+Rcv)=0; //end the buffer to write it to file
+ DebugLog(CommFile,"%s",buf);
+ DebugLog(CommFile,"</reading>\n");
+#endif
+ return(buf);
+ }
+ catch(...)
+ {
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"<error></reading>\n");
+#endif
+ throw;
+ }
+}
+
+//Closes netlib connection
+void CNLClient::Disconnect()
+{
+ Netlib_CloseHandle(hConnection);
+ hConnection=(HANDLE)NULL;
+}
+
+//Uninitializes netlib library
+void UnregisterNLClient()
+{
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"<Unregister PROXY support>");
+#endif
+
+ Netlib_CloseHandle(hNetlibUser);
+ hNetlibUser=(HANDLE)NULL;
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"</Unregister PROXY support>\n");
+#endif
+}
diff --git a/plugins/YAMN/src/proto/netlib.h b/plugins/YAMN/src/proto/netlib.h new file mode 100644 index 0000000000..90ad3613a5 --- /dev/null +++ b/plugins/YAMN/src/proto/netlib.h @@ -0,0 +1,55 @@ +#ifndef __NETLIB_H
+#define __NETLIB_H
+
+#include "netclient.h"
+
+#pragma warning( disable : 4290 )
+
+class CNLClient: public CNetClient
+{
+public:
+ CNLClient(): hConnection(NULL) {}
+ void Connect(const char* servername,const int port) throw(DWORD);
+ void Send(const char *query) throw(DWORD);
+ char* Recv(char *buf=NULL,int buflen=65536) throw(DWORD);
+ void Disconnect();
+ void SSLify()throw(DWORD);
+
+ inline BOOL Connected() {return hConnection!=NULL;}
+
+protected:
+ HANDLE hConnection;
+ BOOL isTLSed;
+ int LocalNetlib_Send(HANDLE hConn,const char *buf,int len,int flags);
+ int LocalNetlib_Recv(HANDLE hConn,char *buf,int len,int flags);
+};
+
+void SSL_DebugLog(const char *fmt, ...);
+
+enum
+{
+ ENL_WINSOCKINIT=1, //error initializing socket //only wsock
+ ENL_GETHOSTBYNAME, //DNS error //only wsock
+ ENL_CREATESOCKET, //error creating socket //only wsock
+ ENL_CONNECT, //cannot connect to server
+ ENL_SEND, //cannot send data
+ ENL_RECV, //cannot receive data
+ ENL_RECVALLOC, //cannot allocate memory for received data
+ ENL_TIMEOUT, //timed out during recv
+};
+
+enum
+{
+ ESSL_NOTLOADED=1, //OpenSSL is not loaded
+ ESSL_WINSOCKINIT, //WinSock 2.0 init failed
+ ESSL_GETHOSTBYNAME, //DNS error
+ ESSL_CREATESOCKET, //error creating socket
+ ESSL_SOCKETCONNECT, //error connecting with socket
+ ESSL_CREATESSL, //error creating SSL session structure
+ ESSL_SETSOCKET, //error connect socket with SSL session for bidirect I/O space
+ ESSL_CONNECT, //cannot connect to server
+ ESSL_SEND, //cannot send data
+ ESSL_RECV, //cannot receive data
+ ESSL_RECVALLOC, //cannot allocate memory for received data
+};
+#endif
diff --git a/plugins/YAMN/src/proto/pop3/pop3.cpp b/plugins/YAMN/src/proto/pop3/pop3.cpp new file mode 100644 index 0000000000..05e85d7156 --- /dev/null +++ b/plugins/YAMN/src/proto/pop3/pop3.cpp @@ -0,0 +1,370 @@ +/* + * This code implements basics of POP3 protocol + * + * (c) majvan 2002-2004 + */ +/* This was made from the libspopc project + * copyright c 2002 Benoit Rouits <brouits@free.fr> + * released under the terms of GNU LGPL + * (GNU Lesser General Public Licence). + * libspopc offers simple API for a pop3 client (MTA). + * See RFC 1725 for pop3 specifications. + * more information on http://brouits.free.fr/libspopc/ + */ +/* + * This file is not original and is changed by majvan <om3tn@psg.sk> + * for mail checker purpose. Please see original web page to + * obtain the original. I rewrote it in C++, but good ideas were, + * I think, unchanged. + * + * Note that this file was not designed to work under Unix. It's + * needed to add Unix-specific features. I was interested only in + * Windows for my project. majvan + * + */ + +#pragma warning( disable : 4290 ) + +#include "..\..\yamn.h" +#include "pop3.h" + +extern "C" { +#include "../md5.h" +} + +extern void __stdcall SSL_DebugLog( const char *fmt, ... ); + +//-------------------------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------------------------- + +//Connects to the server through the netlib +//if not success, exception is throwed +//returns welcome string returned by server +//sets AckFlag +char *CPop3Client::Connect(const char* servername,const int port,BOOL UseSSL, BOOL NoTLS) +{ + char *temp = 0; + if (Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + if (NetClient!=NULL) + delete NetClient; + SSL=UseSSL; + NetClient=new CNLClient; + +#ifdef DEBUG_DECODE + DebugLog(DecodeFile,"Connect:servername: %s port:%d\n",servername,port); +#endif + POP3Error=EPOP3_CONNECT; + NetClient->Connect(servername,port); + POP3Error=0; + + if (SSL) + { + try { NetClient->SSLify(); } + catch (...) + { + NetClient->Disconnect(); + return NULL; + } + } + + temp = RecvRest(NetClient->Recv(),POP3_SEARCHACK); + extern BOOL SSLLoaded; + if (!NoTLS & !(SSL)) { + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + NetClient->Send("STLS\r\n"); + free(temp); + temp=RecvRest(NetClient->Recv(),POP3_SEARCHACK); + if (AckFlag==POP3_FOK){ // Ok, we are going to tls + try { + NetClient->SSLify(); + } catch (...) { + NetClient->Disconnect(); + return NULL; + } +// temp = RecvRest(NetClient->Recv(),POP3_SEARCHACK); + } + } +// SSL_DebugLog("Received: %s",temp); + return temp; +} + +//Receives data to the end of packet +// prev- previous data read (appends to this string next received data) +// mode- mode of packet. +// Packet can end with ack state (+OK or -ERR): set mode to POP3_SEARCHACK +// If packet ends with '.' (end of string), set mode to POP3_SEARCHDOT +// size- received data are stored to memory, but if length of data is more than allocated memory, function allocates +// new memory. New allocated memory has allocated size more bytes +// This value can be selectable: if you think it is better to reallocate by 1kB size, select size to 1024, +// default is 128. You do not need to use this parameter +char* CPop3Client::RecvRest(char* prev,int mode,int size) +{ + int SizeRead=0; + int SizeLeft=size-NetClient->Rcv; + int RcvAll=NetClient->Rcv; + char *LastString,*PrevString=prev; + + AckFlag=0; + + while(((mode==POP3_SEARCHDOT) && !SearchFromEnd(PrevString+RcvAll-1,RcvAll-3,POP3_SEARCHDOT) && !SearchFromStart(PrevString,2,POP3_SEARCHERR)) || //we are looking for dot or -err phrase + ((mode==POP3_SEARCHACK) && (!SearchFromStart(PrevString,RcvAll-3,mode) || !((RcvAll>3) && SearchFromEnd(PrevString+RcvAll-1,1,POP3_SEARCHNL))))) //we are looking for +ok or -err phrase ended with newline + { //if not found + if (NetClient->Stopped) //check if we can work with this POP3 client session + { + if (PrevString!=NULL) + free(PrevString); + throw POP3Error=(DWORD)EPOP3_STOPPED; + } + if (SizeLeft==0) //if block is full + { + SizeRead+=size; + SizeLeft=size; + LastString=NetClient->Recv(NULL,SizeLeft); + PrevString=(char *)realloc(PrevString,sizeof(char)*(SizeRead+size)); + if (PrevString==NULL) + throw POP3Error=(DWORD)EPOP3_RESTALLOC; + memcpy(PrevString+SizeRead,LastString,size); + free(LastString); + } + else + NetClient->Recv(PrevString+RcvAll,SizeLeft); //to Rcv stores received bytes + SizeLeft=SizeLeft-NetClient->Rcv; + RcvAll+=NetClient->Rcv; +// printf("[Read: %s]\n",PrevString); + } + NetClient->Rcv=RcvAll; //at the end, store the number of all bytes, no the number of last received bytes + return PrevString; +} + +// CPop3Client::SearchFromEnd +// returns 1 if substring DOTLINE or ENDLINE found from end in bs bytes +// if you need to add condition for mode, insert it into switch statement +BOOL CPop3Client::SearchFromEnd(char *end,int bs,int mode) +{ + while(bs>=0) + { + switch(mode) + { + case POP3_SEARCHDOT: + if (DOTLINE(end)) + return 1; + break; + case POP3_SEARCHNL: + if (ENDLINE(end)) + return 1; + break; + } + end--; + bs--; + } + return 0; +} + +//Finds for a occurence of some pattern in string +// returns 1 if substring OKLINE, ERRLINE or any of them found from start in bs bytes +//call only this function to retrieve ack status (+OK or -ERR), because it sets flag AckFlag +//if you need to add condition for mode, insert it into switch statement +BOOL CPop3Client::SearchFromStart(char *start,int bs,int mode) +{ + while(bs>=0) + { + switch(mode) + { + case POP3_SEARCHOK: + if (OKLINE(start)) + { + AckFlag=POP3_FOK; + return 1; + } + break; + case POP3_SEARCHERR: + if (ERRLINE(start)) + { + AckFlag=POP3_FERR; + return 1; + } + break; + case POP3_SEARCHACK: + if (ACKLINE(start)) + { + OKLINE(start) ? AckFlag=POP3_FOK : AckFlag=POP3_FERR; + return 1; + } + break; + } + start++; + bs--; + } + return 0; +} + +//Performs "USER" pop query and returns server response +//sets AckFlag +char* CPop3Client::User(char* name) +{ + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + char query[128]; + char *Result; + + sprintf(query,"USER %s\r\n",name); + NetClient->Send(query); + Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); + if (AckFlag==POP3_FERR) + throw POP3Error=(DWORD)EPOP3_BADUSER; + POP3Error=0; + return Result; +} + +//Performs "PASS" pop query and returns server response +//sets AckFlag +char* CPop3Client::Pass(char* pw) +{ + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + char query[128]; + char *Result; + + sprintf(query,"PASS %s\r\n",pw); + NetClient->Send(query); + Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); + if (AckFlag==POP3_FERR) + throw POP3Error=(DWORD)EPOP3_BADPASS; + return Result; +} + +//Performs "APOP" pop query and returns server response +//sets AckFlag +char* CPop3Client::APOP(char* name, char* pw, char* timestamp) +{ + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + char query[512]; + char *Result; + unsigned char digest[16]; + char hexdigest[40]; + + if (timestamp==NULL) + throw POP3Error=(DWORD)EPOP3_APOP; + MD5Context ctx; + MD5Init(&ctx); + MD5Update(&ctx,(const unsigned char *)timestamp,(unsigned int)strlen(timestamp)); + MD5Update(&ctx,(const unsigned char *)pw,(unsigned int)strlen(pw)); + MD5Final(digest,&ctx); + hexdigest[0]='\0'; + for (int i=0; i<16; i++) { + char tmp[4]; + sprintf(tmp, "%02x", digest[i]); + strcat(hexdigest, tmp); + } + sprintf(query,"APOP %s %s\r\n",name, hexdigest); + NetClient->Send(query); + Result=RecvRest(NetClient->Recv(),POP3_SEARCHACK); + if (AckFlag==POP3_FERR) + throw POP3Error=(DWORD)EPOP3_BADUSER; + return Result; +} + +//Performs "QUIT" pop query and returns server response +//sets AckFlag +char* CPop3Client::Quit() +{ + char query[]="QUIT\r\n"; + + NetClient->Send(query); + return RecvRest(NetClient->Recv(),POP3_SEARCHACK); +} + +//Performs "STAT" pop query and returns server response +//sets AckFlag +char* CPop3Client::Stat() +{ + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + char query[]="STAT\r\n"; + + NetClient->Send(query); + return RecvRest(NetClient->Recv(),POP3_SEARCHACK); +} + +//Performs "LIST" pop query and returns server response +//sets AckFlag +char* CPop3Client::List() +{ + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + char query[]="LIST\r\n"; + + NetClient->Send(query); + return RecvRest(NetClient->Recv(),POP3_SEARCHDOT); +} + +//Performs "TOP" pop query and returns server response +//sets AckFlag +char* CPop3Client::Top(int nr, int lines) +{ + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + char query[128]; + + sprintf(query,"TOP %d %d\r\n",nr,lines); + NetClient->Send(query); + return RecvRest(NetClient->Recv(),POP3_SEARCHDOT); +} + +//Performs "UIDL" pop query and returns server response +//sets AckFlag +char* CPop3Client::Uidl(int nr) +{ + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + char query[128]; + + if (nr) + { + sprintf(query,"UIDL %d\r\n",nr); + NetClient->Send(query); + return RecvRest(NetClient->Recv(),POP3_SEARCHACK); + } + sprintf(query,"UIDL\r\n"); + NetClient->Send(query); + return RecvRest(NetClient->Recv(),POP3_SEARCHDOT); +} + +//Performs "DELE" pop query and returns server response +//sets AckFlag +char* CPop3Client::Dele(int nr) +{ + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + char query[128]; + + sprintf(query,"DELE %d\r\n",nr); + NetClient->Send(query); + return RecvRest(NetClient->Recv(),POP3_SEARCHACK); +} +//Performs "RETR" pop query and returns server response +//sets AckFlag +char* CPop3Client::Retr(int nr) +{ + if (NetClient->Stopped) //check if we can work with this POP3 client session + throw POP3Error=(DWORD)EPOP3_STOPPED; + + char query[128]; + + sprintf(query,"RETR %d\r\n",nr); + NetClient->Send(query); + RecvRest(NetClient->Recv(),POP3_SEARCHACK); + return NetClient->Recv(); +}
\ No newline at end of file diff --git a/plugins/YAMN/src/proto/pop3/pop3.h b/plugins/YAMN/src/proto/pop3/pop3.h new file mode 100644 index 0000000000..1f7f2ea737 --- /dev/null +++ b/plugins/YAMN/src/proto/pop3/pop3.h @@ -0,0 +1,66 @@ +#ifndef __POP3_H
+#define __POP3_H
+
+#include "../../debug.h"
+#include "../netlib.h" //NetLib client
+
+#define DOTLINE(s) ((((s)[-2]=='\r') || ((s)[-2]=='\n')) && ((s)[-1]=='.') && (((s)[0]=='\r') || ((s)[0]=='\n') || ((s)[0]=='\0'))) // be careful, it's different to ESR's pop3.c ;-)
+#define ENDLINE(s) (((s)[0]=='\r') || ((s)[0]=='\n')) //endline
+#define OKLINE(s) (((s)[0]=='+') && (((s)[1]=='o') || ((s)[1]=='O')) && (((s)[2]=='k') || ((s)[2]=='K'))) // +OK
+#define ERRLINE(s) (((s)[0]=='-') && (((s)[1]=='e') || ((s)[1]=='E')) && (((s)[2]=='r') || ((s)[2]=='R')) && (((s)[3]=='r') || ((s)[3]=='R'))) // -ERR
+#define ACKLINE(s) (OKLINE(s) || ERRLINE(s))
+
+#define POP3_SEARCHDOT 1
+#define POP3_SEARCHACK 2
+#define POP3_SEARCHOK 3
+#define POP3_SEARCHERR 4
+#define POP3_SEARCHNL 5
+
+#define POP3_FOK 1
+#define POP3_FERR 2
+
+class CPop3Client
+{
+public:
+ CPop3Client(): NetClient(NULL), Stopped(FALSE) {}
+ ~CPop3Client() {if (NetClient!=NULL) delete NetClient;}
+
+ char* Connect(const char* servername,const int port=110,BOOL UseSSL=FALSE, BOOL NoTLS=FALSE);
+ char* RecvRest(char* prev,int mode,int size=65536);
+ char* User(char* name);
+ char* Pass(char* pw);
+ char* APOP(char* name, char* pw, char* timestamp);
+ char* Quit();
+ char* Stat();
+ char* List();
+ char* Top(int nr, int lines=0);
+ char* Uidl(int nr=0);
+ char* Dele(int nr);
+ char* Retr(int nr);
+
+ unsigned char AckFlag;
+ BOOL SSL;
+ BOOL Stopped;
+
+ DWORD POP3Error;
+ class CNetClient *NetClient; //here the network layout is defined (TCP or SSL+TCP etc.)
+private:
+ BOOL SearchFromEnd(char *end,int bs,int mode);
+ BOOL SearchFromStart(char *end,int bs,int mode);
+};
+
+enum
+{
+ EPOP3_QUEUEALLOC=1, //memory allocation
+ EPOP3_STOPPED, //stop account
+ EPOP3_CONNECT, //cannot connect to server
+ EPOP3_RESTALLOC, //cannot allocate memory for received data
+ EPOP3_BADUSER, //cannot login because USER command failed
+ EPOP3_BADPASS, //cannot login because PASS command failed
+ EPOP3_APOP, //server does not send timestamp for APOP auth
+ EPOP3_STAT,
+ EPOP3_LIST,
+ EPOP3_UIDL,
+};
+
+#endif
diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.cpp b/plugins/YAMN/src/proto/pop3/pop3comm.cpp new file mode 100644 index 0000000000..98888a1733 --- /dev/null +++ b/plugins/YAMN/src/proto/pop3/pop3comm.cpp @@ -0,0 +1,1563 @@ +/*
+ * This code implements POP3 server checking for new mail and so on.
+ * There's function SynchroPOP3 in this file- for checking and synchronising POP3 account
+ * and DeleteMailsPOP3- for deleting mails from POP3 server
+ *
+ * Note this file acts as main file for internal plugin.
+ *
+ * (c) majvan 2002-2004
+ * 18/08
+*/
+
+
+#pragma warning( disable : 4290 )
+#include "../../yamn.h"
+#include "../../main.h"
+#include "pop3.h"
+#include "pop3comm.h" //all we need for POP3 account (POP3 account= YAMN account + some more POP3 specified members)
+#include <m_netlib.h> //socket thorugh proxy functions
+
+#define ERRORSTR_MAXLEN 1024 //in wide-chars
+
+//--------------------------------------------------------------------------------------------------
+
+HANDLE hNetLib = NULL;
+PSCOUNTER CPOP3Account::AccountWriterSO = NULL;
+
+//Creates new CPOP3Account structure
+HACCOUNT WINAPI CreatePOP3Account(HYAMNPROTOPLUGIN Plugin,DWORD CAccountVersion);
+
+//Deletes CPOP3Account structure
+void WINAPI DeletePOP3Account(HACCOUNT Which);
+
+//Sets stop flag to account
+void WINAPI StopPOP3Account(HACCOUNT Which);
+
+//Function registers standard functions for YAMN
+int RegisterPOP3Plugin(WPARAM,LPARAM);
+
+//Unloads all variables created on heap (delete[])
+DWORD WINAPI UnLoadPOP3(void *);
+
+//Function writes POP3 accounts using YAMN exported functions
+DWORD WINAPI WritePOP3Accounts();
+
+//Function stores plugin's data for account to file
+DWORD WINAPI WritePOP3Options(HANDLE,HACCOUNT);
+
+//Function reads plugin's data for account from file
+DWORD WINAPI ReadPOP3Options(HACCOUNT,char **,char *);
+
+//Creates new mail for an account
+HYAMNMAIL WINAPI CreatePOP3Mail(HACCOUNT Account,DWORD CMimeMailVersion);
+
+//Function does all needed work when connection failed or any error occured
+//Creates structure containing error code, closes internet session, runs "bad connect" function
+static void PostErrorProc(HPOP3ACCOUNT ActualAccount,void *ParamToBadConnect,DWORD POP3PluginParam,BOOL UseSSL);
+
+//Checks POP3 account and stores all info to account. It deletes old mails=> synchro
+// WhichTemp- pointer to strucure containing needed information
+DWORD WINAPI SynchroPOP3(struct CheckParam *WhichTemp);
+
+//Deletes mails from POP3 server
+// WhichTemp- structure containing needed information (queued messages to delete)
+//Function deletes from memory queue in WhichTemp structure
+DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp);
+
+//Function makes readable message about error. It sends it back to YAMN, so YAMN then
+//can show it to the message window
+TCHAR* WINAPI GetErrorString(DWORD Code);
+
+//Function deletes string allocated in GetErrorString
+void WINAPI DeleteErrorString(LPVOID String);
+
+//Extracts info from result of POP3's STAT command
+// stream- source string
+// len- length of source string
+// mboxsize- adreess to integer, that receives size of mailbox
+// mails- adreess to integer, that receives number of mails
+void ExtractStat(char *stream,int len,int *mboxsize,int *mails);
+
+//Extracts mail ID on mailbox
+// stream- source string
+// len- length of source string
+// queue- address of first message, where first ID will be stored
+void ExtractUIDL(char *stream,int len,HYAMNMAIL queue);
+
+//Extracts mail size on mailbox
+// stream- source string
+// len- length of source string
+// queue- address of first message, where size of message #1 will be stored
+void ExtractList(char *stream,int len,HYAMNMAIL queue);
+
+void ExtractMail(char *stream,int len,HYAMNMAIL queue);
+
+YAMNExportedFcns *pYAMNFcn = NULL;
+MailExportedFcns *pYAMNMailFcn = NULL;
+
+YAMN_PROTOIMPORTFCN POP3ProtocolFunctions =
+{
+ CreatePOP3Account,
+ DeletePOP3Account,
+ StopPOP3Account,
+ WritePOP3Options,
+ ReadPOP3Options,
+ SynchroPOP3,
+ SynchroPOP3,
+ SynchroPOP3,
+ DeleteMailsPOP3,
+ GetErrorString,
+ NULL,
+ DeleteErrorString,
+ WritePOP3Accounts,
+ NULL,
+ UnLoadPOP3,
+};
+
+YAMN_MAILIMPORTFCN POP3MailFunctions =
+{
+ CreatePOP3Mail,
+ NULL,
+ NULL,
+ NULL,
+};
+
+PYAMN_VARIABLES pYAMNVar = NULL;
+HYAMNPROTOPLUGIN POP3Plugin = NULL;
+
+YAMN_PROTOREGISTRATION POP3ProtocolRegistration =
+{
+ "POP3 protocol (internal)",
+ YAMN_VERSION_C,
+ "© 2002-2004 majvan | 2005-2007 tweety, yb",
+ "Mail notifier and browser for Miranda NG. Included POP3 protocol.",
+ "francois.mean@skynet.be",
+ "http://miranda-ng.org/",
+};
+
+static TCHAR *FileName = NULL;
+
+HANDLE RegisterNLClient(const char *name);
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+CPOP3Account::CPOP3Account()
+{
+//NOTE! This constructor constructs CAccount structure. If your plugin is not internal,
+//you will need these constructors. All you need is in Account.cpp. Just copy to your source code
+//constructor and destructor of CAccount.
+ UseInternetFree=CreateEvent(NULL,FALSE,TRUE,NULL);
+ InternetQueries=new SCOUNTER;
+ AbilityFlags=YAMN_ACC_BROWSE | YAMN_ACC_POPUP;
+
+ SetAccountStatus((HACCOUNT)this,TranslateT("Disconnected"));
+}
+
+CPOP3Account::~CPOP3Account()
+{
+ CloseHandle(UseInternetFree);
+ if (InternetQueries!=NULL)
+ delete InternetQueries;
+}
+
+HACCOUNT WINAPI CreatePOP3Account(HYAMNPROTOPLUGIN Plugin,DWORD CAccountVersion)
+{
+//First, we should check whether CAccountVersion matches.
+//But this is internal plugin, so YAMN's CAccount structure and our CAccount structure are
+//the same, so we do not need to test version. Otherwise, if CAccount version does not match
+//in your plugin, you should return NULL, like this:
+// if (CAccountVersion!=YAMN_ACCOUNTVERSION) return NULL;
+
+//Now it is needed to construct our POP3 account and return its handle
+ return (HACCOUNT)new struct CPOP3Account();
+}
+
+void WINAPI DeletePOP3Account(HACCOUNT Which)
+{
+ delete (HPOP3ACCOUNT)Which;
+}
+
+void WINAPI StopPOP3Account(HACCOUNT Which)
+{
+ ((HPOP3ACCOUNT)Which)->Client.Stopped=TRUE;
+ if (((HPOP3ACCOUNT)Which)->Client.NetClient!=NULL) //we should inform also network client. Usefull only when network client implements this feature
+ ((HPOP3ACCOUNT)Which)->Client.NetClient->Stopped=TRUE;
+}
+
+//This function is like main function for POP3 internal protocol
+int RegisterPOP3Plugin(WPARAM,LPARAM)
+{
+
+ //Get YAMN variables we can use
+ if (NULL==(pYAMNVar=(PYAMN_VARIABLES)CallService(MS_YAMN_GETVARIABLES,(WPARAM)YAMN_VARIABLESVERSION,0)))
+ return 0;
+
+ //We have to get pointers to YAMN exported functions: allocate structure and fill it
+ if (NULL==(pYAMNFcn=new struct YAMNExportedFcns))
+ {UnLoadPOP3(0); return 0;}
+
+ //Register new pop3 user in netlib
+ if (NULL==(hNetLib=RegisterNLClient("YAMN-POP3")))
+ {UnLoadPOP3(0); return 0;}
+
+ pYAMNFcn->SetProtocolPluginFcnImportFcn=(YAMN_SETPROTOCOLPLUGINFCNIMPORTFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SETPROTOCOLPLUGINFCNIMPORTID,0);
+ pYAMNFcn->WaitToWriteFcn=(YAMN_WAITTOWRITEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_WAITTOWRITEID,0);
+ pYAMNFcn->WriteDoneFcn=(YAMN_WRITEDONEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_WRITEDONEID,0);
+ pYAMNFcn->WaitToReadFcn=(YAMN_WAITTOREADFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_WAITTOREADID,0);
+ pYAMNFcn->ReadDoneFcn=(YAMN_READDONEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_READDONEID,0);
+ pYAMNFcn->SCGetNumberFcn=(YAMN_SCMANAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SCGETNUMBERID,0);
+ pYAMNFcn->SCIncFcn=(YAMN_SCMANAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SCINCID,0);
+ pYAMNFcn->SCDecFcn=(YAMN_SCMANAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SCDECID,0);
+ pYAMNFcn->SetStatusFcn=(YAMN_SETSTATUSFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SETSTATUSID,0);
+ pYAMNFcn->GetStatusFcn=(YAMN_GETSTATUSFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_GETSTATUSID,0);
+
+ if (NULL==(pYAMNMailFcn=new struct MailExportedFcns))
+ {UnLoadPOP3(0); return 0;}
+
+ pYAMNMailFcn->SynchroMessagesFcn=(YAMN_SYNCHROMIMEMSGSFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_SYNCHROMIMEMSGSID,0);
+ pYAMNMailFcn->TranslateHeaderFcn=(YAMN_TRANSLATEHEADERFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_TRANSLATEHEADERID,0);
+ pYAMNMailFcn->AppendQueueFcn=(YAMN_APPENDQUEUEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_APPENDQUEUEID,0);
+ pYAMNMailFcn->DeleteMessagesToEndFcn=(YAMN_DELETEMIMEQUEUEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_DELETEMIMEQUEUEID,0);
+ pYAMNMailFcn->DeleteMessageFromQueueFcn=(YAMN_DELETEMIMEMESSAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_DELETEMIMEMESSAGEID,0);
+ pYAMNMailFcn->FindMessageByIDFcn=(YAMN_FINDMIMEMESSAGEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_FINDMIMEMESSAGEID,0);
+ pYAMNMailFcn->CreateNewDeleteQueueFcn=(YAMN_CREATENEWDELETEQUEUEFCN)CallService(MS_YAMN_GETFCNPTR,(WPARAM)YAMN_CREATENEWDELETEQUEUEID,0);
+
+ //set static variable
+ if (CPOP3Account::AccountWriterSO==NULL) {
+ if (NULL==(CPOP3Account::AccountWriterSO=new SCOUNTER))
+ {UnLoadPOP3(0); return 0;}
+ }
+
+ //First, we register this plugin
+ //it is quite impossible this function returns zero (failure) as YAMN and internal plugin structre versions are the same
+ POP3ProtocolRegistration.Name = Translate("POP3 protocol (internal)");
+ POP3ProtocolRegistration.Description = Translate("Mail notifier and browser for Miranda NG. Included POP3 protocol.");
+ if (NULL==(POP3Plugin=(HYAMNPROTOPLUGIN)CallService(MS_YAMN_REGISTERPROTOPLUGIN,(WPARAM)&POP3ProtocolRegistration,(LPARAM)YAMN_PROTOREGISTRATIONVERSION)))
+ return 0;
+
+ //Next we set our imported functions for YAMN
+ if (!SetProtocolPluginFcnImport(POP3Plugin,&POP3ProtocolFunctions,YAMN_PROTOIMPORTFCNVERSION,&POP3MailFunctions,YAMN_MAILIMPORTFCNVERSION))
+ return 0;
+
+ //Then, we read all mails for accounts.
+ //You must first register account, before using this function as YAMN must use CreatePOP3Account function to add new accounts
+ //But if CreatePOP3Account is not implemented (equals to NULL), YAMN creates account as YAMN's standard HACCOUNT
+ if (FileName) CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName, 0); //shoud not happen (only for secure)
+ FileName = (TCHAR *)CallService(MS_YAMN_GETFILENAME,(WPARAM)_T("pop3"), 0);
+
+ switch(CallService(MS_YAMN_READACCOUNTS,(WPARAM)POP3Plugin,(LPARAM)FileName)) {
+ case EACC_FILEVERSION:
+ MessageBox(NULL,TranslateT("Found new version of account book, not compatible with this version of YAMN."),TranslateT("YAMN (internal POP3) read error"),MB_OK);
+ CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0);
+ FileName = NULL;
+ return 0;
+ case EACC_FILECOMPATIBILITY:
+ MessageBox(NULL,TranslateT("Error reading account file. Account file corrupted."),TranslateT("YAMN (internal POP3) read error"),MB_OK);
+ CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0);
+ FileName = NULL;
+ return 0;
+ case EACC_ALLOC:
+ MessageBox(NULL,TranslateT("Memory allocation error while data reading"),TranslateT("YAMN (internal POP3) read error"),MB_OK);
+ CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0);
+ FileName = NULL;
+ return 0;
+ case EACC_SYSTEM:
+ if (ERROR_FILE_NOT_FOUND!=GetLastError())
+ {
+ TCHAR temp[1024] = {0};
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s\n%s"),TranslateT("Reading file error. File already in use?"),FileName);
+ MessageBox(NULL,temp,TranslateT("YAMN (internal POP3) read error"),MB_OK);
+ CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0);
+ FileName = NULL;
+ return 0;
+ }
+ break;
+ }
+ //HookEvent(ME_OPT_INITIALISE,POP3OptInit);
+
+ HACCOUNT Finder;
+ HANDLE hContact;
+ DBVARIANT dbv;
+ char *szProto;
+
+ for (Finder=POP3Plugin->FirstAccount;Finder!=NULL;Finder=Finder->Next)
+ {
+ Finder->hContact = NULL;
+ hContact = db_find_first();
+ while(hContact)
+ {
+ szProto = GetContactProto(hContact);
+ if (szProto != NULL && strcmp(szProto, YAMN_DBMODULE)==0)
+ {
+ if (!DBGetContactSettingString(hContact,YAMN_DBMODULE,"Id",&dbv)) {
+ if ( strcmp( dbv.pszVal, Finder->Name) == 0) {
+ Finder->hContact = hContact;
+ DBWriteContactSettingWord(Finder->hContact, YAMN_DBMODULE, "Status", ID_STATUS_ONLINE);
+ DBWriteContactSettingString(Finder->hContact, "CList", "StatusMsg", Translate("No new mail message"));
+ if ((Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT))
+ DBDeleteContactSetting(Finder->hContact, "CList", "Hidden");
+
+ if (!(Finder->Flags & YAMN_ACC_ENA) || !(Finder->NewMailN.Flags & YAMN_ACC_CONT))
+ DBWriteContactSettingByte(Finder->hContact, "CList", "Hidden", 1);
+ }
+ DBFreeVariant(&dbv);
+ }
+ }
+ hContact = db_find_next(hContact);
+ }
+
+ if (Finder->hContact == NULL && (Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT)) {
+ //No account contact found, have to create one
+ Finder->hContact =(HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)Finder->hContact,(LPARAM)YAMN_DBMODULE);
+ DBWriteContactSettingString(Finder->hContact,YAMN_DBMODULE,"Id",Finder->Name);
+ DBWriteContactSettingString(Finder->hContact,YAMN_DBMODULE,"Nick",Finder->Name);
+ DBWriteContactSettingString(Finder->hContact,"Protocol","p",YAMN_DBMODULE);
+ DBWriteContactSettingWord(Finder->hContact, YAMN_DBMODULE, "Status", YAMN_STATUS);
+ }
+ }
+
+ return 0;
+}
+
+DWORD WINAPI UnLoadPOP3(void *)
+{
+ //pYAMNVar is only a pointr, no need delete or free
+ if (hNetLib) {
+ Netlib_CloseHandle(hNetLib); hNetLib = NULL;}
+ if (CPOP3Account::AccountWriterSO) {
+ delete CPOP3Account::AccountWriterSO; CPOP3Account::AccountWriterSO = NULL;}
+ if (pYAMNMailFcn) {
+ delete pYAMNMailFcn; pYAMNMailFcn = NULL;}
+ if (pYAMNFcn) {
+ delete pYAMNFcn; pYAMNFcn = NULL;}
+ if (FileName) {
+ CallService(MS_YAMN_DELETEFILENAME,(WPARAM)FileName,0); FileName = NULL;}
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"UnLoadPOP3:done\n");
+ #endif
+ return 1;
+}
+
+DWORD WINAPI WritePOP3Accounts()
+{
+ DWORD ReturnValue = CallService(MS_YAMN_WRITEACCOUNTS,(WPARAM)POP3Plugin,(LPARAM)FileName);
+ if (ReturnValue == EACC_SYSTEM) {
+ TCHAR temp[1024] = {0};
+ mir_sntprintf(temp, SIZEOF(temp), _T("%s\n%s"), TranslateT("Error while copying data to disk occured. File in use?"), FileName );
+ MessageBox(NULL, temp, TranslateT("POP3 plugin- write file error"), MB_OK );
+ }
+
+ return ReturnValue;
+}
+
+DWORD WINAPI WritePOP3Options(HANDLE File,HACCOUNT Which)
+{
+ DWORD WrittenBytes;
+ DWORD Ver=POP3_FILEVERSION;
+
+ if ((!WriteFile(File,(char *)&Ver,sizeof(DWORD),&WrittenBytes,NULL)) ||
+ (!WriteFile(File,(char *)&((HPOP3ACCOUNT)Which)->CP,sizeof(WORD),&WrittenBytes,NULL)))
+ return EACC_SYSTEM;
+ return 0;
+}
+
+DWORD WINAPI ReadPOP3Options(HACCOUNT Which,char **Parser,char *End)
+{
+ DWORD Ver;
+#ifdef DEBUG_FILEREAD
+ TCHAR Debug[256];
+#endif
+ Ver=*(DWORD *)(*Parser);
+ (*Parser)+=sizeof(DWORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+ if (Ver!=POP3_FILEVERSION)
+ return EACC_FILECOMPATIBILITY;
+
+ ((HPOP3ACCOUNT)Which)->CP=*(WORD *)(*Parser);
+ (*Parser)+=sizeof(WORD);
+ if (*Parser>=End)
+ return EACC_FILECOMPATIBILITY;
+#ifdef DEBUG_FILEREAD
+ _stprintf(Debug,_T("CodePage: %d, remaining %d chars"),((HPOP3ACCOUNT)Which)->CP,End-*Parser);
+ MessageBox(NULL,Debug,_T("debug"),MB_OK);
+#endif
+ return 0;
+}
+
+HYAMNMAIL WINAPI CreatePOP3Mail(HACCOUNT Account,DWORD MailDataVersion)
+{
+ HYAMNMAIL NewMail;
+//First, we should check whether MAILDATA matches.
+//But this is internal plugin, so YAMN's MAILDATA structure and our MAILDATA structure are
+//the same, so we do not need to test version. Otherwise, if MAILDATA version does not match
+//in your plugin, you should return NULL, like this:
+// if (MailDataVersion!=YAMN_MAILDATAVERSION) return NULL;
+
+//Now it is needed to construct our POP3 account and return its handle
+ if (NULL==(NewMail=new YAMNMAIL))
+ return NULL;
+
+ if (NULL==(NewMail->MailData=new MAILDATA))
+ {
+ delete NewMail;
+ return NULL;
+ }
+ NewMail->MailData->CP=((HPOP3ACCOUNT)Account)->CP;
+ return (HYAMNMAIL)NewMail;
+}
+
+static void SetContactStatus(HACCOUNT account, int status){
+ if ((account->hContact) && (account->NewMailN.Flags & YAMN_ACC_CONT)) {
+ DBWriteContactSettingWord(account->hContact, YAMN_DBMODULE, "Status", status);
+ }
+}
+
+static void PostErrorProc(HPOP3ACCOUNT ActualAccount,void *ParamToBadConnection,DWORD POP3PluginParam,BOOL UseSSL)
+{
+ char *DataRX;
+
+//We create new structure, that we pass to bad connection dialog procedure. This procedure next calls YAMN imported fuction
+//from POP3 protocol to determine the description of error. We can describe error from our error code structure, because later,
+//when YAMN calls our function, it passes us our error code. This is pointer to structure for POP3 protocol in fact.
+ PPOP3_ERRORCODE ErrorCode;
+
+//We store status before we do Quit(), because quit can destroy our errorcode status
+ if (NULL!=(ErrorCode=new POP3_ERRORCODE))
+ {
+ ErrorCode->SSL=UseSSL;
+ ErrorCode->AppError=ActualAccount->SystemError;
+ ErrorCode->POP3Error=ActualAccount->Client.POP3Error;
+ ErrorCode->NetError=ActualAccount->Client.NetClient->NetworkError;
+ ErrorCode->SystemError=ActualAccount->Client.NetClient->SystemError;
+ }
+
+ if (POP3PluginParam==(DWORD)NULL) //if it was normal YAMN call (force check or so on)
+ {
+ try
+ {
+ DataRX=ActualAccount->Client.Quit();
+ if (DataRX!=NULL)
+ free(DataRX);
+ }
+ catch(...)
+ {
+ }
+//We always close connection if error occured
+ try
+ {
+ ActualAccount->Client.NetClient->Disconnect();
+ }
+ catch(...)
+ {
+ }
+
+ SetAccountStatus(ActualAccount,TranslateT("Disconnected"));
+
+//If we cannot allocate memory, do nothing
+ if (ErrorCode==NULL)
+ {
+ SetEvent(ActualAccount->UseInternetFree);
+ return;
+ }
+ }
+ else //else it was called from POP3 plugin, probably error when deleting old mail (POP3 synchro calls POP3 delete)
+ if (ErrorCode==NULL)
+ return;
+
+ if ((ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG) || (ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO) || (ActualAccount->BadConnectN.Flags & YAMN_ACC_POP))
+ {
+ YAMN_BADCONNECTIONPARAM cp={(HANDLE)0,ActualAccount,(UINT_PTR)ErrorCode,ParamToBadConnection};
+
+ CallService(MS_YAMN_BADCONNECTION,(WPARAM)&cp,(LPARAM)YAMN_BADCONNECTIONVERSION);
+ }
+ if (POP3PluginParam==(DWORD)NULL) //if it was normal YAMN call
+ SetEvent(ActualAccount->UseInternetFree);
+}
+
+//Checks POP3 account and synchronizes it
+DWORD WINAPI SynchroPOP3(struct CheckParam * WhichTemp)
+{
+ HPOP3ACCOUNT ActualAccount;
+ CPop3Client *MyClient;
+ HYAMNMAIL NewMails=NULL,MsgQueuePtr=NULL;
+ char* DataRX=NULL,*Temp;
+ int mboxsize,msgs,i;
+ SYSTEMTIME now;
+ LPVOID YAMNParam;
+ DWORD CheckFlags;
+ BOOL UsingInternet=FALSE;
+ struct {
+ char *ServerName;
+ DWORD ServerPort;
+ char *ServerLogin;
+ char *ServerPasswd;
+ DWORD Flags;
+ DWORD NFlags;
+ DWORD NNFlags;
+ } ActualCopied;
+
+ //First, we should compare our version of CheckParam structure, but here it is not needed, because YAMN and internal plugin
+ //have the same version. But your plugin should do that in this way:
+ // if (((struct CheckParam *)WhichTemp)->Ver!=YAMN_CHECKVERSION)
+ // {
+ // SetEvent(((struct CheckParam *)WhichTemp)->ThreadRunningEV); //don't forget to unblock YAMN
+ // return (DWORD)-1; //ok, but we should return value.
+ // //When our plugin returns e.g. 0xFFFFFFFF (=-1, this is only our plugin value, YAMN does nothing with return value,
+ // //but only tests if it is nonzero. If yes, it calls GetErrorStringFcn. We know problem occured in YAMN incompatibility
+ // //and then we can in our GetErrorStringFcn e.g. return string "Uncompatible version of YAMN".
+ // }
+
+ ActualAccount=(HPOP3ACCOUNT)WhichTemp->AccountParam; //copy address of structure from calling thread to stack of this thread
+ YAMNParam=WhichTemp->BrowserParam;
+ CheckFlags=WhichTemp->Flags;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+ #endif
+ SCInc(ActualAccount->UsingThreads);
+ //Unblock YAMN, signal that we have copied all parameters from YAMN thread stack
+ if (INVALID_HANDLE_VALUE!=WhichTemp->ThreadRunningEV)
+ SetEvent(WhichTemp->ThreadRunningEV);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=WaitToRead(ActualAccount))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountSO-read wait failed\n");
+ #endif
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+ #endif
+ SCDec(ActualAccount->UsingThreads);
+ return 0;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountSO-read enter\n");
+ #endif
+ MyClient=&ActualAccount->Client;
+ //Now, copy all needed information about account to local variables, so ActualAccount is not blocked in read mode during all connection process, which can last for several minutes.
+ ActualCopied.ServerName = _strdup(ActualAccount->Server->Name);
+ ActualCopied.ServerPort=ActualAccount->Server->Port;
+ ActualCopied.Flags=ActualAccount->Flags;
+ ActualCopied.ServerLogin=_strdup(ActualAccount->Server->Login);
+ ActualCopied.ServerPasswd=_strdup(ActualAccount->Server->Passwd);
+ ActualCopied.NFlags=ActualAccount->NewMailN.Flags;
+ ActualCopied.NNFlags=ActualAccount->NoNewMailN.Flags;
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountSO-read done\n");
+ #endif
+ ReadDone(ActualAccount);
+
+ SCInc(ActualAccount->InternetQueries); //increment counter, that there is one more thread waiting for connection
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:InternetFreeEV-wait\n");
+ #endif
+ WaitForSingleObject(ActualAccount->UseInternetFree,INFINITE); //wait until we can use connection
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:InternetFreeEV-enter\n");
+ #endif
+ SCDec(ActualAccount->InternetQueries);
+
+ //OK, we enter the "use internet" section. But after we start communication, we can test if we did not enter the "use internet" section only for the reason,
+ //that previous thread release the internet section because this account has stop signal (we stop account and there are 2 threads: one communicating,
+ //the second one waiting for network access- the first one ends because we want to stop account, this one is released, but should be stopped as well).
+ if (!ActualAccount->AbleToWork)
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:stop signal-InternetFreeEV-done\n");
+ #endif
+ SetEvent(ActualAccount->UseInternetFree);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:stop signal-Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+ #endif
+ SCDec(ActualAccount->UsingThreads);
+ return 0;
+ }
+ UsingInternet=TRUE;
+
+ GetLocalTime(&now);
+ ActualAccount->SystemError=0; //now we can use internet for this socket. First, clear errorcode.
+ try
+ {
+ SetContactStatus(ActualAccount,ID_STATUS_OCCUPIED);
+ #ifdef DEBUG_COMM
+ DebugLog(CommFile,"<--------Communication-------->\n");
+ #endif
+ // if we are already connected, we have open session (another thread left us open session), so we don't need to login
+ // note that connected state without logging cannot occur, because if we close session, we always close socket too (we must close socket is the right word :))
+ if ((MyClient->NetClient==NULL) || !MyClient->NetClient->Connected())
+ {
+ SetAccountStatus(ActualAccount,TranslateT("Connecting to server"));
+
+ DataRX=MyClient->Connect(ActualCopied.ServerName,ActualCopied.ServerPort,ActualCopied.Flags & YAMN_ACC_SSL23,ActualCopied.Flags & YAMN_ACC_NOTLS);
+ char *timestamp=NULL;
+
+ if (DataRX!=NULL)
+ {
+ if (ActualCopied.Flags & YAMN_ACC_APOP)
+ {
+ char *lpos=strchr(DataRX,'<');
+ char *rpos=strchr(DataRX,'>');
+ if (lpos && rpos && rpos>lpos) {
+ int sz=(int)(rpos-lpos+2);
+ timestamp=new char[sz];
+ memcpy(timestamp, lpos, sz-1);
+ timestamp[sz-1]='\0';
+ }
+ }
+ free(DataRX);
+ DataRX=NULL;
+ }
+
+ SetAccountStatus(ActualAccount,TranslateT("Entering POP3 account"));
+
+ if (ActualCopied.Flags & YAMN_ACC_APOP)
+ {
+ DataRX=MyClient->APOP(ActualCopied.ServerLogin,ActualCopied.ServerPasswd,timestamp);
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ delete[] timestamp;
+ } else {
+ DataRX=MyClient->User(ActualCopied.ServerLogin);
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ DataRX=MyClient->Pass(ActualCopied.ServerPasswd);
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ }
+ }
+ SetAccountStatus(ActualAccount,TranslateT("Searching for new mail message"));
+
+ DataRX=MyClient->Stat();
+
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<--------Account checking-------->\n");
+ DebugLog(DecodeFile,"<Extracting stat>\n");
+ #endif
+ ExtractStat(DataRX,MyClient->NetClient->Rcv,&mboxsize,&msgs);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<MailBoxSize>%d</MailBoxSize>\n",mboxsize);
+ DebugLog(DecodeFile,"<Msgs>%d</Msgs>\n",msgs);
+ DebugLog(DecodeFile,"</Extracting stat>\n");
+ #endif
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ for (i=0;i<msgs;i++)
+ {
+ if (!i)
+ MsgQueuePtr=NewMails=(HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL,(WPARAM)ActualAccount,(LPARAM)YAMN_MAILVERSION);
+ else
+ {
+ MsgQueuePtr->Next=(HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL,(WPARAM)ActualAccount,(LPARAM)YAMN_MAILVERSION);
+ MsgQueuePtr=MsgQueuePtr->Next;
+ }
+ if (MsgQueuePtr==NULL)
+ {
+ ActualAccount->SystemError=EPOP3_QUEUEALLOC;
+ throw (DWORD)ActualAccount->SystemError;
+ }
+ }
+
+ if (msgs)
+ {
+ DataRX=MyClient->List();
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting list>\n");
+ #endif
+ ExtractList(DataRX,MyClient->NetClient->Rcv,NewMails);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting list>\n");
+ #endif
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting UIDL>\n");
+ #endif
+ DataRX=MyClient->Uidl();
+ ExtractUIDL(DataRX,MyClient->NetClient->Rcv,NewMails);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting UIDL>\n");
+ #endif
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=MsgsWaitToWrite(ActualAccount))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait failed\n");
+ #endif
+ throw (DWORD)(ActualAccount->SystemError=EACC_STOPPED);
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write enter\n");
+ #endif
+ ActualAccount->LastChecked=now;
+ for (MsgQueuePtr=(HYAMNMAIL)ActualAccount->Mails;MsgQueuePtr!=NULL;MsgQueuePtr=MsgQueuePtr->Next){
+ if (MsgQueuePtr->Flags&YAMN_MSG_BODYREQUESTED){
+ HYAMNMAIL NewMsgsPtr=NULL;
+ for (NewMsgsPtr=(HYAMNMAIL)NewMails;NewMsgsPtr!=NULL;NewMsgsPtr=NewMsgsPtr->Next){
+ if (!strcmp(MsgQueuePtr->ID,NewMsgsPtr->ID)) {
+ TCHAR accstatus[512];
+ wsprintf(accstatus,TranslateT("Reading body %s"),NewMsgsPtr->ID);
+ SetAccountStatus(ActualAccount,accstatus);
+ DataRX=MyClient->Top(MsgQueuePtr->Number,100);
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Reading body>\n");
+ DebugLog(DecodeFile,"<Header>%s</Header>\n",DataRX);
+ #endif
+ if (DataRX!=NULL)
+ {
+ Temp=DataRX;
+ while((Temp<DataRX+MyClient->NetClient->Rcv) && (WS(Temp) || ENDLINE(Temp))) Temp++;
+
+ if (OKLINE(DataRX))
+ for (Temp=DataRX;(Temp<DataRX+MyClient->NetClient->Rcv) && (!ENDLINE(Temp));Temp++);
+ while((Temp<DataRX+MyClient->NetClient->Rcv) && ENDLINE(Temp)) Temp++;
+ }
+ else
+ continue;
+ //delete all the headers of the old mail MsgQueuePtr->MailData->TranslatedHeader
+ struct CMimeItem *TH = MsgQueuePtr->MailData->TranslatedHeader;
+ if (TH) for (;MsgQueuePtr->MailData->TranslatedHeader!=NULL;)
+ {
+ TH=TH->Next;
+ if (MsgQueuePtr->MailData->TranslatedHeader->name!=NULL)
+ delete[] MsgQueuePtr->MailData->TranslatedHeader->name;
+ if (MsgQueuePtr->MailData->TranslatedHeader->value!=NULL)
+ delete[] MsgQueuePtr->MailData->TranslatedHeader->value;
+ delete MsgQueuePtr->MailData->TranslatedHeader;
+ MsgQueuePtr->MailData->TranslatedHeader=TH;
+ }
+
+ TranslateHeader(Temp,MyClient->NetClient->Rcv-(Temp-DataRX),&MsgQueuePtr->MailData->TranslatedHeader);
+
+
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Reading body>\n");
+ #endif
+ MsgQueuePtr->Flags|=YAMN_MSG_BODYRECEIVED;
+
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ break;
+ }
+ }
+ }
+ }
+
+ SynchroMessages(ActualAccount,(HYAMNMAIL *)&ActualAccount->Mails,NULL,(HYAMNMAIL *)&NewMails,NULL); //we get only new mails on server!
+// NewMails=NULL;
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write done\n");
+ #endif
+ MsgsWriteDone(ActualAccount);
+ for (MsgQueuePtr=(HYAMNMAIL)ActualAccount->Mails;MsgQueuePtr!=NULL;MsgQueuePtr=MsgQueuePtr->Next){
+ if ((MsgQueuePtr->Flags&YAMN_MSG_BODYREQUESTED) && (MsgQueuePtr->Flags&YAMN_MSG_BODYRECEIVED)) {
+ MsgQueuePtr->Flags&=~YAMN_MSG_BODYREQUESTED;
+ if (MsgQueuePtr->MsgWindow){
+ SendMessage(MsgQueuePtr->MsgWindow,WM_YAMN_CHANGECONTENT,0,0);
+ }
+ }
+ }
+
+ for (msgs=0,MsgQueuePtr=NewMails;MsgQueuePtr!=NULL;MsgQueuePtr=MsgQueuePtr->Next,msgs++); //get number of new mails
+
+ try
+ {
+ TCHAR accstatus[512];
+
+ for (i=0,MsgQueuePtr=NewMails;MsgQueuePtr!=NULL;i++)
+ {
+ BOOL autoretr = (ActualAccount->Flags & YAMN_ACC_BODY)!=0;
+ DataRX=MyClient->Top(MsgQueuePtr->Number,autoretr?100:0);
+ wsprintf(accstatus,TranslateT("Reading new mail messages (%d%% done)"),100*i/msgs);
+ SetAccountStatus(ActualAccount,accstatus);
+
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<New mail>\n");
+ DebugLog(DecodeFile,"<Header>%s</Header>\n",DataRX);
+ #endif
+ if (DataRX!=NULL)
+ {
+ Temp=DataRX;
+ while((Temp<DataRX+MyClient->NetClient->Rcv) && (WS(Temp) || ENDLINE(Temp))) Temp++;
+
+ if (OKLINE(DataRX))
+ for (Temp=DataRX;(Temp<DataRX+MyClient->NetClient->Rcv) && (!ENDLINE(Temp));Temp++);
+ while((Temp<DataRX+MyClient->NetClient->Rcv) && ENDLINE(Temp)) Temp++;
+ }
+ else
+ continue;
+
+ TranslateHeader(Temp,MyClient->NetClient->Rcv-(Temp-DataRX),&MsgQueuePtr->MailData->TranslatedHeader);
+
+
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</New mail>\n");
+ #endif
+ MsgQueuePtr->Flags|=YAMN_MSG_NORMALNEW;
+ if (autoretr) MsgQueuePtr->Flags|=YAMN_MSG_BODYRECEIVED;
+
+ //We are going to filter mail. Warning!- we must not be in read access neither write access to mails when calling this service
+ //This is done, because the "NewMails" queue is not synchronised. It is because it is new queue. Only this thread uses new queue yet, it is not
+ //connected to account mail queue.
+ // CallService(MS_YAMN_FILTERMAIL,(WPARAM)ActualAccount,(LPARAM)MsgQueuePtr);
+ FilterMailSvc((WPARAM)ActualAccount,(LPARAM)MsgQueuePtr);
+
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+
+ //MsgQueuePtr->MailData->Body=MyClient->Retr(MsgQueuePtr->Number);
+
+ MsgQueuePtr=MsgQueuePtr->Next;
+
+ }
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</--------Account checking-------->\n");
+ #endif
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=MsgsWaitToWrite(ActualAccount))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait failed\n");
+ #endif
+ throw (DWORD)ActualAccount->SystemError==EACC_STOPPED;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write enter\n");
+ #endif
+ if (ActualAccount->Mails==NULL)
+ ActualAccount->Mails=NewMails;
+ else
+ {
+ ActualAccount->LastMail=ActualAccount->LastChecked;
+ AppendQueue((HYAMNMAIL)ActualAccount->Mails,NewMails);
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write done\n");
+ #endif
+ MsgsWriteDone(ActualAccount);
+
+ // we are going to delete mails having SPAM flag level3 and 4 (see m_mails.h) set
+ {
+ struct DeleteParam ParamToDeleteMails={YAMN_DELETEVERSION,INVALID_HANDLE_VALUE,ActualAccount,YAMNParam,(void *)POP3_DELETEFROMCHECK};
+
+ // Delete mails from server. Here we should not be in write access for account's mails
+ DeleteMailsPOP3(&ParamToDeleteMails);
+ }
+
+ // if there is no waiting thread for internet connection close it
+ // else leave connection open
+ if (0==SCGetNumber(ActualAccount->InternetQueries))
+ {
+ DataRX=MyClient->Quit();
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ MyClient->NetClient->Disconnect();
+
+ SetAccountStatus(ActualAccount,TranslateT("Disconnected"));
+ }
+
+ UsingInternet=FALSE;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:InternetFreeEV-done\n");
+ #endif
+ SetEvent(ActualAccount->UseInternetFree);
+
+ ActualAccount->LastSChecked=ActualAccount->LastChecked;
+ ActualAccount->LastSynchronised=ActualAccount->LastChecked;
+ }
+ catch(...)
+ {
+ throw; //go to the main exception handling
+ }
+
+ {
+ YAMN_MAILBROWSERPARAM Param={(HANDLE)0,ActualAccount,ActualCopied.NFlags,ActualCopied.NNFlags,YAMNParam};
+
+ if (CheckFlags & YAMN_FORCECHECK)
+ Param.nnflags|=YAMN_ACC_POP; //if force check, show popup anyway and if mailbrowser was opened, do not close
+ Param.nnflags|= YAMN_ACC_MSGP; //do not close browser if already open
+ CallService(MS_YAMN_MAILBROWSER,(WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION);
+ }
+ SetContactStatus(ActualAccount,ActualAccount->isCounting?ID_STATUS_ONLINE:ID_STATUS_OFFLINE);
+ }
+ #ifdef DEBUG_COMM
+ catch(DWORD ErrorCode)
+ #else
+ catch(DWORD)
+ #endif
+ {
+ if (ActualAccount->Client.POP3Error==EPOP3_STOPPED)
+ ActualAccount->SystemError=EACC_STOPPED;
+ #ifdef DEBUG_COMM
+ DebugLog(CommFile,"ERROR: %x\n",ErrorCode);
+ #endif
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait\n");
+ #endif
+ if (WAIT_OBJECT_0==MsgsWaitToWrite(ActualAccount))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write enter\n");
+ #endif
+ ActualAccount->LastChecked=now;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write done\n");
+ #endif
+ MsgsWriteDone(ActualAccount);
+ }
+ #ifdef DEBUG_SYNCHRO
+ else
+ DebugLog(SynchroFile,"CheckPOP3:ActualAccountMsgsSO-write wait failed\n");
+ #endif
+
+ DeleteMIMEQueue(ActualAccount,NewMails);
+
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ switch(ActualAccount->SystemError)
+ {
+ case EACC_QUEUEALLOC:
+ case EACC_STOPPED:
+ ActualAccount->Client.NetClient->Disconnect();
+ break;
+ default:
+ PostErrorProc(ActualAccount,YAMNParam,(DWORD)NULL,MyClient->SSL); //it closes internet connection too
+ }
+
+ if (UsingInternet) //if our thread still uses internet
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:InternetFreeEV-done\n");
+ #endif
+ SetEvent(ActualAccount->UseInternetFree);
+ }
+ SetContactStatus(ActualAccount,ID_STATUS_NA);
+ }
+ free(ActualCopied.ServerName);
+ free(ActualCopied.ServerLogin);
+ free(ActualCopied.ServerPasswd);
+ #ifdef DEBUG_COMM
+ DebugLog(CommFile,"</--------Communication-------->\n");
+ #endif
+// WriteAccounts();
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+ #endif
+ SCDec(ActualAccount->UsingThreads);
+ return 0;
+}
+
+DWORD WINAPI DeleteMailsPOP3(struct DeleteParam *WhichTemp)
+{
+ HPOP3ACCOUNT ActualAccount;
+ LPVOID YAMNParam;
+ UINT_PTR POP3PluginParam;
+ CPop3Client *MyClient;
+ HYAMNMAIL DeleteMails,NewMails=NULL,MsgQueuePtr;
+ char* DataRX=NULL;
+ int mboxsize,msgs,i;
+ BOOL UsingInternet=FALSE;
+ struct {
+ char *ServerName;
+ DWORD ServerPort;
+ char *ServerLogin;
+ char *ServerPasswd;
+ DWORD Flags;
+ DWORD NFlags;
+ DWORD NNFlags;
+ } ActualCopied;
+
+ //First, we should compare our version of DeleteParam structure, but here it is not needed, because YAMN and internal plugin
+ //have the same version. But your plugin should do that in this way:
+ // if (((struct DeleteParam *)WhichTemp)->Ver!=YAMN_DELETEVERSION)
+ // {
+ // SetEvent(((struct DeleteParam *)WhichTemp)->ThreadRunningEV); //don't forget to unblock YAMN
+ // return (DWORD)-1; //ok, but we should return value.
+ // //When our plugin returns e.g. 0xFFFFFFFF (this is only our plugin value, YAMN does nothing with return value,
+ // //but only tests if it is nonzero. If yes, it calls GetErrorStringFcn), we know problem occured in YAMN incompatibility
+ // //and then we can in our GetErrorStringFcn e.g. return string "Uncompatible version of YAMN".
+ // }
+
+ ActualAccount=(HPOP3ACCOUNT)((struct DeleteParam *)WhichTemp)->AccountParam; //copy address of structure from calling thread to stack of this thread
+ YAMNParam=((struct DeleteParam *)WhichTemp)->BrowserParam;
+ POP3PluginParam=(UINT_PTR)((struct DeleteParam *)WhichTemp)->CustomParam;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+#endif
+ SCInc(ActualAccount->UsingThreads);
+ if (INVALID_HANDLE_VALUE!=WhichTemp->ThreadRunningEV)
+ SetEvent(WhichTemp->ThreadRunningEV);
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountSO-read wait\n");
+#endif
+ if (WAIT_OBJECT_0!=WaitToRead(ActualAccount))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountSO-read wait failed\n");
+#endif
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+#endif
+ SCDec(ActualAccount->UsingThreads);
+ return 0;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountSO-read enter\n");
+#endif
+ if (NULL==(DeleteMails=(HYAMNMAIL)CreateNewDeleteQueue((HYAMNMAIL)ActualAccount->Mails))) //if there's no mail for deleting, return
+ {
+ if (POP3_DELETEFROMCHECK!=POP3PluginParam) //We do not wait for free internet when calling from SynchroPOP3. It is because UseInternetFree is blocked
+ {
+ YAMN_MAILBROWSERPARAM Param={(HANDLE)0,ActualAccount,YAMN_ACC_MSGP,YAMN_ACC_MSGP,YAMNParam}; //Just update the window
+
+ CallService(MS_YAMN_MAILBROWSER,(WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION);
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountSO-read done\n");
+#endif
+ ReadDone(ActualAccount);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+#endif
+ SCDec(ActualAccount->UsingThreads);
+
+ return NO_MAIL_FOR_DELETE;
+ }
+ MyClient=&(ActualAccount->Client);
+
+//Now, copy all needed information about account to local variables, so ActualAccount is not blocked in read mode during all connection process, which can last for several minutes.
+ ActualCopied.ServerName=_strdup(ActualAccount->Server->Name);
+ ActualCopied.ServerPort=ActualAccount->Server->Port;
+ ActualCopied.Flags=ActualAccount->Flags;
+ ActualCopied.ServerLogin=_strdup(ActualAccount->Server->Login);
+ ActualCopied.ServerPasswd=_strdup(ActualAccount->Server->Passwd);
+ ActualCopied.NFlags=ActualAccount->NewMailN.Flags;
+ ActualCopied.NNFlags=ActualAccount->NoNewMailN.Flags;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountSO-read done\n");
+#endif
+ ReadDone(ActualAccount);
+
+ SCInc(ActualAccount->InternetQueries); //This is POP3-internal SCOUNTER, we set another thread wait for this account to be connected to inet
+ if (POP3_DELETEFROMCHECK!=POP3PluginParam) //We do not wait for free internet when calling from SynchroPOP3. It is because UseInternetFree is blocked
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:InternetFreeEV-wait\n");
+#endif
+ WaitForSingleObject(ActualAccount->UseInternetFree,INFINITE);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:InternetFreeEV-enter\n");
+#endif
+ }
+ SCDec(ActualAccount->InternetQueries);
+ UsingInternet=TRUE;
+
+ try
+ {
+ SetContactStatus(ActualAccount,ID_STATUS_OCCUPIED);
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"<--------Communication-------->\n");
+#endif
+ if ((MyClient->NetClient==NULL) || !MyClient->NetClient->Connected())
+ {
+ SetAccountStatus(ActualAccount,TranslateT("Connecting to server"));
+
+ DataRX=MyClient->Connect(ActualCopied.ServerName,ActualCopied.ServerPort,ActualCopied.Flags & YAMN_ACC_SSL23,ActualCopied.Flags & YAMN_ACC_NOTLS);
+
+ char *timestamp=NULL;
+ if (DataRX!=NULL) {
+ if (ActualAccount->Flags & YAMN_ACC_APOP) {
+ char *lpos=strchr(DataRX,'<');
+ char *rpos=strchr(DataRX,'>');
+ if (lpos && rpos && rpos>lpos) {
+ int sz=(int)(rpos-lpos+2);
+ timestamp=new char[sz];
+ memcpy(timestamp, lpos, sz-1);
+ timestamp[sz-1]='\0';
+ }
+ }
+ free(DataRX);
+ DataRX=NULL;
+ }
+ SetAccountStatus(ActualAccount,TranslateT("Entering POP3 account"));
+
+ if (ActualAccount->Flags & YAMN_ACC_APOP)
+ {
+ DataRX=MyClient->APOP(ActualCopied.ServerLogin,ActualCopied.ServerPasswd,timestamp);
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ delete[] timestamp;
+ } else {
+ DataRX=MyClient->User(ActualCopied.ServerLogin);
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ DataRX=MyClient->Pass(ActualCopied.ServerPasswd);
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ }
+ }
+
+#ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<--------Deleting requested mails-------->\n");
+#endif
+ if (POP3_DELETEFROMCHECK!=POP3PluginParam) //We do not need to get mails on server as we have already it from check function
+ {
+ SetAccountStatus(ActualAccount,TranslateT("Deleting requested mails"));
+
+ DataRX=MyClient->Stat();
+
+#ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting stat>\n");
+#endif
+ ExtractStat(DataRX,MyClient->NetClient->Rcv,&mboxsize,&msgs);
+#ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<MailBoxSize>%d</MailBoxSize>\n",mboxsize);
+ DebugLog(DecodeFile,"<Msgs>%d</Msgs>\n",msgs);
+ DebugLog(DecodeFile,"</Extracting stat>\n");
+#endif
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ for (i=0;i<msgs;i++)
+ {
+ if (!i)
+ MsgQueuePtr=NewMails=(HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL,(WPARAM)ActualAccount,(LPARAM)YAMN_MAILVERSION);
+ else
+ {
+ MsgQueuePtr->Next=(HYAMNMAIL)CallService(MS_YAMN_CREATEACCOUNTMAIL,(WPARAM)ActualAccount,(LPARAM)YAMN_MAILVERSION);
+ MsgQueuePtr=MsgQueuePtr->Next;
+ }
+ if (MsgQueuePtr==NULL)
+ {
+ ActualAccount->SystemError=EPOP3_QUEUEALLOC;
+ throw (DWORD)ActualAccount->SystemError;
+ }
+ }
+
+ if (msgs)
+ {
+#ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Extracting UIDL>\n");
+#endif
+ DataRX=MyClient->Uidl();
+ ExtractUIDL(DataRX,MyClient->NetClient->Rcv,NewMails);
+#ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</Extracting UIDL>\n");
+#endif
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+// we get "new mails" on server (NewMails will contain all mails on server not found in DeleteMails)
+// but also in DeleteMails we get only those, which are still on server with their responsable numbers
+ SynchroMessages(ActualAccount,(HYAMNMAIL *)&DeleteMails,NULL,(HYAMNMAIL *)&NewMails,NULL);
+ }
+ }
+ else
+ SetAccountStatus(ActualAccount,TranslateT("Deleting spam"));
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountMsgsSO-write wait\n");
+#endif
+ if (WAIT_OBJECT_0!=MsgsWaitToWrite(ActualAccount))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountMsgsSO-write wait failed\n");
+#endif
+ throw (DWORD)EACC_STOPPED;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountMsgsSO-write enter\n");
+#endif
+ if (msgs || POP3_DELETEFROMCHECK==POP3PluginParam)
+ {
+ try
+ {
+ HYAMNMAIL Temp;
+
+ for (i=0,MsgQueuePtr=DeleteMails;MsgQueuePtr!=NULL;i++)
+ {
+ if (!(MsgQueuePtr->Flags & YAMN_MSG_VIRTUAL)) //of course we can only delete real mails, not virtual
+ {
+ DataRX=MyClient->Dele(MsgQueuePtr->Number);
+ Temp=MsgQueuePtr->Next;
+ if (POP3_FOK==MyClient->AckFlag) //if server answers that mail was deleted
+ {
+ DeleteMIMEMessage((HYAMNMAIL *)&DeleteMails,MsgQueuePtr);
+ HYAMNMAIL DeletedMail=FindMIMEMessageByID((HYAMNMAIL)ActualAccount->Mails,MsgQueuePtr->ID);
+ if ((MsgQueuePtr->Flags & YAMN_MSG_MEMDELETE)) //if mail should be deleted from memory (or disk)
+ {
+ DeleteMIMEMessage((HYAMNMAIL *)&ActualAccount->Mails,DeletedMail); //remove from queue
+ CallService(MS_YAMN_DELETEACCOUNTMAIL,(WPARAM)POP3Plugin,(LPARAM)DeletedMail);
+ }
+ else //else mark it only as "deleted mail"
+ {
+ DeletedMail->Flags |= (YAMN_MSG_VIRTUAL | YAMN_MSG_DELETED);
+ DeletedMail->Flags &= ~(YAMN_MSG_NEW | YAMN_MSG_USERDELETE | YAMN_MSG_AUTODELETE); //clear "new mail"
+ }
+ delete MsgQueuePtr->MailData;
+ delete[] MsgQueuePtr->ID;
+ delete MsgQueuePtr;
+ }
+ MsgQueuePtr=Temp;
+
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ }
+ else
+ MsgQueuePtr=MsgQueuePtr->Next;
+ }
+ }
+ catch(...) //if any exception in the code where we have write-access to account occured, don't forget to leave write-access
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountMsgsSO-write done\n");
+#endif
+ MsgsWriteDone(ActualAccount);
+ throw; //and go to the main exception handling
+ }
+
+ if (NewMails!=NULL)
+// in ActualAccount->Mails we have all mails stored before calling this function
+// in NewMails we have all mails not found in DeleteMails (in other words: we performed new ID checking and we
+// stored all mails found on server, then we deleted the ones we wanted to delete in this function
+// and NewMails queue now contains actual state of mails on server). But we will not use NewMails as actual state, because NewMails does not contain header data (subject, from...)
+// We perform deleting from ActualAccount->Mails: we remove from original queue (ActualAccount->Mails) all deleted mails
+ SynchroMessages(ActualAccount,(HYAMNMAIL *)&ActualAccount->Mails,NULL,(HYAMNMAIL *)&NewMails,NULL);
+// Now ActualAccount->Mails contains all mails when calling this function except the ones, we wanted to delete (these are in DeleteMails)
+// And in NewMails we have new mails (if any)
+ else if (POP3_DELETEFROMCHECK!=POP3PluginParam)
+ {
+ DeleteMIMEQueue(ActualAccount,(HYAMNMAIL)ActualAccount->Mails);
+ ActualAccount->Mails=NULL;
+ }
+ }
+ else
+ {
+ DeleteMIMEQueue(ActualAccount,(HYAMNMAIL)ActualAccount->Mails);
+ ActualAccount->Mails=NULL;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:ActualAccountMsgsSO-write done\n");
+#endif
+ MsgsWriteDone(ActualAccount);
+#ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"</--------Deleting requested mails-------->\n");
+#endif
+
+// TODO: now, we have in NewMails new mails. If NewMails is not NULL, we found some new mails, so Checking for new mail should be performed
+// now, we do not call CheckPOP3
+
+// if there is no waiting thread for internet connection close it
+// else leave connection open
+// if this functin was called from SynchroPOP3, then do not try to disconnect
+ if (POP3_DELETEFROMCHECK!=POP3PluginParam)
+ {
+ YAMN_MAILBROWSERPARAM Param={(HANDLE)0,ActualAccount,ActualCopied.NFlags,YAMN_ACC_MSGP,YAMNParam};
+
+ CallService(MS_YAMN_MAILBROWSER,(WPARAM)&Param,(LPARAM)YAMN_MAILBROWSERVERSION);
+
+ if (0==SCGetNumber(ActualAccount->InternetQueries))
+ {
+ DataRX=MyClient->Quit();
+ if (DataRX!=NULL)
+ free(DataRX);
+ DataRX=NULL;
+ MyClient->NetClient->Disconnect();
+
+ SetAccountStatus(ActualAccount,TranslateT("Disconnected"));
+ }
+
+ UsingInternet=FALSE;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:InternetFreeEV-done\n");
+#endif
+ SetEvent(ActualAccount->UseInternetFree);
+ }
+ SetContactStatus(ActualAccount,ActualAccount->isCounting?ID_STATUS_ONLINE:ID_STATUS_OFFLINE);
+ }
+#ifdef DEBUG_COMM
+ catch(DWORD ErrorCode)
+#else
+ catch(DWORD)
+#endif
+ {
+ if (ActualAccount->Client.POP3Error==EPOP3_STOPPED)
+ ActualAccount->SystemError=EACC_STOPPED;
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"ERROR %x\n",ErrorCode);
+#endif
+ if (DataRX!=NULL)
+ free(DataRX);
+ switch(ActualAccount->SystemError)
+ {
+ case EACC_QUEUEALLOC:
+ case EACC_STOPPED:
+ ActualAccount->Client.NetClient->Disconnect();
+ break;
+ default:
+ PostErrorProc(ActualAccount,YAMNParam,POP3PluginParam,MyClient->SSL); //it closes internet connection too
+ }
+
+ if (UsingInternet && (POP3_DELETEFROMCHECK!=POP3PluginParam)) //if our thread still uses internet and it is needed to release internet
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"CheckPOP3:InternetFreeEV-done\n");
+#endif
+ SetEvent(ActualAccount->UseInternetFree);
+ }
+ }
+
+ free(ActualCopied.ServerName);
+ free(ActualCopied.ServerLogin);
+ free(ActualCopied.ServerPasswd);
+
+ DeleteMIMEQueue(ActualAccount,NewMails);
+ DeleteMIMEQueue(ActualAccount,DeleteMails);
+
+#ifdef DEBUG_COMM
+ DebugLog(CommFile,"</--------Communication-------->\n");
+#endif
+// WriteAccounts();
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"DeleteMailsPOP3:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
+#endif
+ SCDec(ActualAccount->UsingThreads);
+ return 0;
+}
+
+void ExtractStat(char *stream,int len,int *mboxsize,int *mails)
+{
+ char *finder=stream;
+ while(WS(finder) || ENDLINE(finder)) finder++;
+ if (ACKLINE(finder))
+ {
+ while(!WS(finder)) finder++;
+ while(WS(finder)) finder++;
+ }
+ if (1!=sscanf(finder,"%d",mails))
+ throw (DWORD)EPOP3_STAT;
+ while(!WS(finder)) finder++;
+ while(WS(finder)) finder++;
+ if (1!=sscanf(finder,"%d",mboxsize))
+ throw (DWORD)EPOP3_STAT;
+}
+void ExtractMail(char *stream,int len,HYAMNMAIL queue)
+{
+ char *finder=stream;
+ char *finderend;
+ int msgnr,i;
+ HYAMNMAIL queueptr=queue;
+
+ while(WS(finder) || ENDLINE(finder)) finder++;
+ while(!ACKLINE(finder)) finder++;
+ while(!ENDLINE(finder)) finder++; //now we at the end of first ack line
+ while(finder<=(stream+len))
+ {
+ while(ENDLINE(finder)) finder++; //go to the new line
+ if (DOTLINE(finder+1)) //at the end of stream
+ break;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Message>\n");
+ #endif
+ while(WS(finder)) finder++; //jump whitespace
+ if (1!=sscanf(finder,"%d",&msgnr))
+ throw (DWORD)EPOP3_UIDL;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Nr>%d</Nr>\n",msgnr);
+ #endif
+// for (i=1,queueptr=queue;(queueptr->Next!=NULL) && (i<msgnr);queueptr=queueptr->Next,i++);
+// if (i!=msgnr)
+// throw (DWORD)EPOP3_UIDL;
+ while(!WS(finder)) finder++; //jump characters
+ while(WS(finder)) finder++; //jump whitespace
+ finderend=finder+1;
+ while(!WS(finderend) && !ENDLINE(finderend)) finderend++;
+ queueptr->ID=new char[finderend-finder+1];
+ for (i=0;finder!=finderend;finder++,i++)
+ queueptr->MailData->Body[i]=*finder;
+ queueptr->MailData->Body[i]=0; //ends string
+ queueptr->Number=msgnr;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<ID>%s</ID>\n",queueptr->MailData->Body);
+ DebugLog(DecodeFile,"</Message>\n");
+ #endif
+ queueptr=queueptr->Next;
+ while(!ENDLINE(finder)) finder++;
+ }
+}
+
+void ExtractUIDL(char *stream,int len,HYAMNMAIL queue)
+{
+ char *finder=stream;
+ char *finderend;
+ int msgnr,i;
+ HYAMNMAIL queueptr=queue;
+
+ while(WS(finder) || ENDLINE(finder)) finder++;
+ while(!ACKLINE(finder)) finder++;
+ while(!ENDLINE(finder)) finder++; //now we at the end of first ack line
+ while(finder<=(stream+len))
+ {
+ while(ENDLINE(finder)) finder++; //go to the new line
+ if (DOTLINE(finder+1)) //at the end of stream
+ break;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Message>\n");
+ #endif
+ while(WS(finder)) finder++; //jump whitespace
+ if (1!=sscanf(finder,"%d",&msgnr))
+ throw (DWORD)EPOP3_UIDL;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Nr>%d</Nr>\n",msgnr);
+ #endif
+// for (i=1,queueptr=queue;(queueptr->Next!=NULL) && (i<msgnr);queueptr=queueptr->Next,i++);
+// if (i!=msgnr)
+// throw (DWORD)EPOP3_UIDL;
+ while(!WS(finder)) finder++; //jump characters
+ while(WS(finder)) finder++; //jump whitespace
+ finderend=finder+1;
+ while(!WS(finderend) && !ENDLINE(finderend)) finderend++;
+ queueptr->ID=new char[finderend-finder+1];
+ for (i=0;finder!=finderend;finder++,i++)
+ queueptr->ID[i]=*finder;
+ queueptr->ID[i]=0; //ends string
+ queueptr->Number=msgnr;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<ID>%s</ID>\n",queueptr->ID);
+ DebugLog(DecodeFile,"</Message>\n");
+ #endif
+ queueptr=queueptr->Next;
+ while(!ENDLINE(finder)) finder++;
+ }
+}
+
+void ExtractList(char *stream,int len,HYAMNMAIL queue)
+{
+ char *finder=stream;
+ char *finderend;
+ int msgnr,i;
+ HYAMNMAIL queueptr;
+
+ while(WS(finder) || ENDLINE(finder)) finder++;
+ while(!ACKLINE(finder)) finder++;
+ while(!ENDLINE(finder)) finder++; //now we at the end of first ack line
+ while(finder<=(stream+len))
+ {
+ while(ENDLINE(finder)) finder++; //go to the new line
+ if (DOTLINE(finder+1)) //at the end of stream
+ break;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Message>\n",NULL,0);
+ #endif
+ while(WS(finder)) finder++; //jump whitespace
+ if (1!=sscanf(finder,"%d",&msgnr)) //message nr.
+ throw (DWORD)EPOP3_LIST;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Nr>%d</Nr>\n",msgnr);
+ #endif
+
+ for (i=1,queueptr=queue;(queueptr->Next!=NULL) && (i<msgnr);queueptr=queueptr->Next,i++);
+ if (i!=msgnr)
+ throw (DWORD)EPOP3_LIST;
+ while(!WS(finder)) finder++; //jump characters
+ while(WS(finder)) finder++; //jump whitespace
+ finderend=finder+1;
+ if (1!=sscanf(finder,"%d",&queueptr->MailData->Size))
+ throw (DWORD)EPOP3_LIST;
+ #ifdef DEBUG_DECODE
+ DebugLog(DecodeFile,"<Nr>%d</Nr>\n",queueptr->MailData->Size);
+ #endif
+ while(!ENDLINE(finder)) finder++;
+ }
+}
+
+TCHAR* WINAPI GetErrorString(DWORD Code)
+{
+ static TCHAR *POP3Errors[]=
+ {
+ LPGENT("Memory allocation error."), //memory allocation
+ LPGENT("Account is about to be stopped."), //stop account
+ LPGENT("Cannot connect to POP3 server."),
+ LPGENT("Cannot allocate memory for received data."),
+ LPGENT("Cannot login to POP3 server."),
+ LPGENT("Bad user or password."),
+ LPGENT("Server does not support APOP authorization."),
+ LPGENT("Error while executing POP3 command."),
+ LPGENT("Error while executing POP3 command."),
+ LPGENT("Error while executing POP3 command."),
+ };
+
+ static TCHAR *NetlibErrors[]=
+ {
+ LPGENT("Cannot connect to server with NetLib."),
+ LPGENT("Cannot send data."),
+ LPGENT("Cannot receive data."),
+ LPGENT("Cannot allocate memory for received data."),
+ };
+
+ static TCHAR *SSLErrors[]=
+ {
+ LPGENT("OpenSSL not loaded."),
+ LPGENT("Windows socket 2.0 init failed."),
+ LPGENT("DNS lookup error."),
+ LPGENT("Error while creating base socket."),
+ LPGENT("Error connecting to server with socket."),
+ LPGENT("Error while creating SSL structure."),
+ LPGENT("Error connecting socket with SSL."),
+ LPGENT("Server rejected connection with SSL."),
+ LPGENT("Cannot write SSL data."),
+ LPGENT("Cannot read SSL data."),
+ LPGENT("Cannot allocate memory for received data."),
+ };
+
+ TCHAR *ErrorString = new TCHAR[ERRORSTR_MAXLEN];
+ POP3_ERRORCODE *ErrorCode=(POP3_ERRORCODE *)(UINT_PTR)Code;
+
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, TranslateT("Error %d-%d-%d-%d:"),ErrorCode->AppError,ErrorCode->POP3Error,ErrorCode->NetError,ErrorCode->SystemError);
+ if (ErrorCode->POP3Error)
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"),ErrorString,TranslateTS(POP3Errors[ErrorCode->POP3Error-1]));
+ if (ErrorCode->NetError) {
+ if (ErrorCode->SSL)
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"),ErrorString, TranslateTS(SSLErrors[ErrorCode->NetError-1]));
+ else
+ mir_sntprintf(ErrorString, ERRORSTR_MAXLEN, _T("%s\n%s"),ErrorString, TranslateTS(NetlibErrors[ErrorCode->NetError-4]));
+ }
+
+ return ErrorString;
+}
+
+void WINAPI DeleteErrorString(LPVOID String)
+{
+ delete (char *)String;
+}
diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.h b/plugins/YAMN/src/proto/pop3/pop3comm.h new file mode 100644 index 0000000000..c7eb01b5a1 --- /dev/null +++ b/plugins/YAMN/src/proto/pop3/pop3comm.h @@ -0,0 +1,97 @@ +#ifndef __POP3COMM_H
+#define __POP3COMM_H
+
+#include <windows.h>
+#include "pop3.h"
+
+#include "m_protoplugin.h"
+//We can use synchro.h because this is internal plugin. If you use external plugin,
+//and you want to use SO for your plugin, you can use YAMN's SO.
+//All you need is to include synchro.h and use YAMN's exported synchronization functions.
+#include "m_synchro.h"
+
+//For mail exported functions defintions
+#include "m_mails.h"
+
+#include "../../debug.h"
+
+#define POP3_FILEVERSION 1 //Version of aditional information stored in book file
+
+typedef struct CPOP3Account: public CAccount
+{
+// We can use SCOUNTER structure, because this is internal plugin.
+// This SO is used to determine if any POP3 account is in "write access" mode
+ static PSCOUNTER AccountWriterSO;
+
+// It is usefull to have client structure in account. With this structure we have access to account's socket.
+// This is related to InternetQueries and UseInternetFree
+// This member should be synchronized with UseInternetFree
+ class CPop3Client Client;
+
+// This member is usefull for MIME headers. It is default codepage, if no other codepage found
+ WORD CP; //access only through AccountAccessSO
+
+// In this memeber last error code is stored
+ DWORD SystemError; //access through UseInternetFree
+
+// We use only counter from this object and it is # of threads waiting to work on internet.
+// We use event UseInternet to access critical sections.
+// It is usefull in 2 ways: we have mutual exclusion that only one thread works with account on internet.
+// Thread, which has done its work with account on internet can close socket, but it is not needed, when any other
+// thread wants to work (e.g. we have deleted mails, but when deleting, another thread wants to check new mail, so
+// we delete all needed mails and check if there's thread that wants to work. If yes, we do not need to quit session,
+// we leave socket open, and leave internet. Another thread then start checking and does not connect, does not send
+// user and password... because socket is open- it continues)
+ PSCOUNTER InternetQueries;
+ HANDLE UseInternetFree;
+
+ CPOP3Account();
+ ~CPOP3Account();
+
+} POP3ACCOUNT,*HPOP3ACCOUNT;
+
+typedef struct POP3LayeredError
+{
+ BOOL SSL;
+ DWORD AppError;
+ DWORD POP3Error;
+ DWORD NetError;
+ DWORD SystemError;
+} POP3_ERRORCODE,*PPOP3_ERRORCODE;
+
+struct YAMNExportedFcns
+{
+ YAMN_SETPROTOCOLPLUGINFCNIMPORTFCN SetProtocolPluginFcnImportFcn;
+ YAMN_WAITTOWRITEFCN WaitToWriteFcn;
+ YAMN_WRITEDONEFCN WriteDoneFcn;
+ YAMN_WAITTOREADFCN WaitToReadFcn;
+ YAMN_READDONEFCN ReadDoneFcn;
+ YAMN_SCMANAGEFCN SCGetNumberFcn;
+ YAMN_SCMANAGEFCN SCIncFcn;
+ YAMN_SCMANAGEFCN SCDecFcn;
+ YAMN_SETSTATUSFCN SetStatusFcn;
+ YAMN_GETSTATUSFCN GetStatusFcn;
+};
+
+struct MailExportedFcns
+{
+ YAMN_SYNCHROMIMEMSGSFCN SynchroMessagesFcn;
+ YAMN_TRANSLATEHEADERFCN TranslateHeaderFcn;
+ YAMN_APPENDQUEUEFCN AppendQueueFcn;
+ YAMN_DELETEMIMEQUEUEFCN DeleteMessagesToEndFcn;
+ YAMN_DELETEMIMEMESSAGEFCN DeleteMessageFromQueueFcn;
+ YAMN_FINDMIMEMESSAGEFCN FindMessageByIDFcn;
+ YAMN_CREATENEWDELETEQUEUEFCN CreateNewDeleteQueueFcn;
+};
+
+enum
+{
+ EACC_QUEUEALLOC=1, //memory allocation
+ EACC_STOPPED, //stop account
+};
+
+#define NO_MAIL_FOR_DELETE 1
+
+#define POP3_DELETEFROMCHECK 1
+
+#endif
diff --git a/plugins/YAMN/src/proto/pop3/pop3opt.cpp b/plugins/YAMN/src/proto/pop3/pop3opt.cpp new file mode 100644 index 0000000000..c730b4b3fc --- /dev/null +++ b/plugins/YAMN/src/proto/pop3/pop3opt.cpp @@ -0,0 +1,1556 @@ +/*
+ * This code implements POP3 options window handling
+ *
+ * (c) majvan 2002-2003
+*/
+
+#include "../../yamn.h"
+#include "../../main.h"
+#include "pop3comm.h"
+#include "pop3opt.h"
+
+//--------------------------------------------------------------------------------------------------
+
+static BOOL Check0,Check1,Check2,Check3,Check4,Check5,Check6,Check7,Check8,Check9;
+static char DlgInput[MAX_PATH];
+
+void CheckMenuItems();
+
+//--------------------------------------------------------------------------------------------------
+
+INT_PTR CALLBACK DlgProcYAMNOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hDlg);
+ CheckDlgButton(hDlg,IDC_CHECKTTB,DBGetContactSettingByte(NULL,YAMN_DBMODULE,YAMN_TTBFCHECK,1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_LONGDATE,(optDateTime&SHOWDATELONG) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_SMARTDATE,(optDateTime&SHOWDATENOTODAY) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_NOSECONDS,(optDateTime&SHOWDATENOSECONDS) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_MAINMENU,DBGetContactSettingByte(NULL, YAMN_DBMODULE, YAMN_SHOWMAINMENU, 1));
+ CheckDlgButton(hDlg,IDC_YAMNASPROTO,DBGetContactSettingByte(NULL, YAMN_DBMODULE, YAMN_SHOWASPROTO, 1));
+ CheckDlgButton(hDlg,IDC_CLOSEONDELETE,DBGetContactSettingByte(NULL, YAMN_DBMODULE, YAMN_CLOSEDELETE, 0));
+ break;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_YAMNASPROTO:
+ case IDC_MAINMENU:
+ case IDC_CHECKTTB:
+ case IDC_CLOSEONDELETE:
+ case IDC_LONGDATE:
+ case IDC_SMARTDATE:
+ case IDC_NOSECONDS:
+ SendMessage(GetParent(hDlg),PSM_CHANGED,0,0);
+ break;
+ }
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch(((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ DBWriteContactSettingByte(NULL, YAMN_DBMODULE, YAMN_SHOWASPROTO, IsDlgButtonChecked(hDlg,IDC_YAMNASPROTO));
+ DBWriteContactSettingByte(NULL, YAMN_DBMODULE, YAMN_SHOWMAINMENU, IsDlgButtonChecked(hDlg,IDC_MAINMENU));
+ DBWriteContactSettingByte(NULL, YAMN_DBMODULE, YAMN_CLOSEDELETE, IsDlgButtonChecked(hDlg,IDC_CLOSEONDELETE));
+ DBWriteContactSettingByte(NULL, YAMN_DBMODULE, YAMN_TTBFCHECK, IsDlgButtonChecked(hDlg,IDC_CHECKTTB));
+
+ AddTopToolbarIcon(0, 0);
+ CheckMenuItems();
+
+ optDateTime = 0;
+ if (IsDlgButtonChecked(hDlg,IDC_LONGDATE))optDateTime |= SHOWDATELONG;
+ if (IsDlgButtonChecked(hDlg,IDC_SMARTDATE))optDateTime |= SHOWDATENOTODAY;
+ if (IsDlgButtonChecked(hDlg,IDC_NOSECONDS))optDateTime |= SHOWDATENOSECONDS;
+ DBWriteContactSettingByte(NULL,YAMN_DBMODULE,YAMN_DBTIMEOPTIONS,optDateTime);
+ }
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+INT_PTR CALLBACK DlgProcPluginOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hDlg);
+ break;
+
+ case WM_COMMAND:
+ {
+ WORD wNotifyCode = HIWORD(wParam);
+ switch(LOWORD(wParam))
+ {
+ case IDC_COMBOPLUGINS:
+ if (wNotifyCode==CBN_SELCHANGE)
+ {
+ HWND hCombo=GetDlgItem(hDlg,IDC_COMBOPLUGINS);
+ PYAMN_PROTOPLUGINQUEUE PParser;
+ PYAMN_FILTERPLUGINQUEUE FParser;
+ int index,id;
+
+ if (CB_ERR==(index=SendMessage(hCombo,CB_GETCURSEL,0,0)))
+ break;
+ id=SendMessage(hCombo,CB_GETITEMDATA,(WPARAM)index,0);
+ EnterCriticalSection(&PluginRegCS);
+ for (PParser=FirstProtoPlugin;PParser!=NULL;PParser=PParser->Next)
+ if (id==(INT_PTR)PParser->Plugin)
+ {
+ SetDlgItemTextA(hDlg,IDC_STVER,PParser->Plugin->PluginInfo->Ver);
+ SetDlgItemTextA(hDlg,IDC_STDESC,PParser->Plugin->PluginInfo->Description == NULL ? "" : PParser->Plugin->PluginInfo->Description);
+ SetDlgItemTextA(hDlg,IDC_STCOPY,PParser->Plugin->PluginInfo->Copyright == NULL ? "" : PParser->Plugin->PluginInfo->Copyright);
+ SetDlgItemTextA(hDlg,IDC_STMAIL,PParser->Plugin->PluginInfo->Email == NULL ? "" : PParser->Plugin->PluginInfo->Email);
+ SetDlgItemTextA(hDlg,IDC_STWWW,PParser->Plugin->PluginInfo->WWW == NULL ? "" : PParser->Plugin->PluginInfo->WWW);
+ break;
+ }
+ for (FParser=FirstFilterPlugin;FParser!=NULL;FParser=FParser->Next)
+ if (id==(INT_PTR)FParser->Plugin)
+ {
+ SetDlgItemTextA(hDlg,IDC_STVER,FParser->Plugin->PluginInfo->Ver);
+ SetDlgItemTextA(hDlg,IDC_STDESC,FParser->Plugin->PluginInfo->Description == NULL ? "" : FParser->Plugin->PluginInfo->Description);
+ SetDlgItemTextA(hDlg,IDC_STCOPY,FParser->Plugin->PluginInfo->Copyright == NULL ? "" : FParser->Plugin->PluginInfo->Copyright);
+ SetDlgItemTextA(hDlg,IDC_STMAIL,FParser->Plugin->PluginInfo->Email == NULL ? "" : FParser->Plugin->PluginInfo->Email);
+ SetDlgItemTextA(hDlg,IDC_STWWW,FParser->Plugin->PluginInfo->WWW == NULL ? "" : FParser->Plugin->PluginInfo->WWW);
+ break;
+ }
+ LeaveCriticalSection(&PluginRegCS);
+ }
+ break;
+ case IDC_STWWW:
+ {
+ char str[1024];
+ GetDlgItemTextA(hDlg,IDC_STWWW,str,SIZEOF(str));
+ CallService(MS_UTILS_OPENURL,1,(LPARAM)str);
+ break;
+ }
+
+ }
+ break;
+ }
+ case WM_SHOWWINDOW:
+ if (TRUE==(BOOL)wParam) {
+ PYAMN_PROTOPLUGINQUEUE PParser;
+ PYAMN_FILTERPLUGINQUEUE FParser;
+ int index;
+
+ EnterCriticalSection(&PluginRegCS);
+ for (PParser = FirstProtoPlugin; PParser != NULL; PParser = PParser->Next) {
+ index = SendDlgItemMessageA(hDlg,IDC_COMBOPLUGINS,CB_ADDSTRING,0,(LPARAM)PParser->Plugin->PluginInfo->Name);
+ index = SendDlgItemMessage(hDlg,IDC_COMBOPLUGINS,CB_SETITEMDATA,(WPARAM)index,(LPARAM)PParser->Plugin);
+ }
+ for (FParser = FirstFilterPlugin; FParser != NULL; FParser = FParser->Next) {
+ index = SendDlgItemMessageA(hDlg,IDC_COMBOPLUGINS,CB_ADDSTRING,0,(LPARAM)FParser->Plugin->PluginInfo->Name);
+ index = SendDlgItemMessage(hDlg,IDC_COMBOPLUGINS,CB_SETITEMDATA,(WPARAM)index,(LPARAM)FParser->Plugin);
+ }
+
+ LeaveCriticalSection(&PluginRegCS);
+ SendDlgItemMessage(hDlg,IDC_COMBOPLUGINS,CB_SETCURSEL,0,0);
+ SendMessage(hDlg,WM_COMMAND,MAKELONG(IDC_COMBOPLUGINS,CBN_SELCHANGE),0);
+ break;
+ }
+ else { //delete all items in combobox
+ int cbn=SendDlgItemMessage(hDlg,IDC_COMBOPLUGINS,CB_GETCOUNT,0,0);
+ for (int i=0;i<cbn;i++)
+ SendDlgItemMessage(hDlg,IDC_COMBOPLUGINS,CB_DELETESTRING,0,0);
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
+
+int YAMNOptInitSvc(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp={0};
+ odp.cbSize = sizeof(odp);
+ odp.hInstance = YAMNVar.hInst;
+ odp.pszGroup = LPGEN("Network");
+ odp.pszTitle = LPGEN("YAMN");
+ odp.flags = ODPF_BOLDGROUPS;
+
+ odp.pszTab = LPGEN("Accounts");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_POP3ACCOUNTOPT);
+ odp.pfnDlgProc = DlgProcPOP3AccOpt;
+ Options_AddPage(wParam, &odp);
+
+ odp.pszTab = LPGEN("General");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_YAMNOPT);
+ odp.pfnDlgProc = DlgProcYAMNOpt;
+ Options_AddPage(wParam, &odp);
+
+ odp.pszTab = LPGEN("Plugins");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_PLUGINOPT);
+ odp.pfnDlgProc = DlgProcPluginOpt;
+ Options_AddPage(wParam, &odp);
+
+ if ( ServiceExists(MS_POPUP_ADDPOPUPEX)) {
+ odp.pszGroup = LPGEN("PopUps");
+ odp.pszTab = LPGEN("YAMN");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_POP3ACCOUNTPOPUP);
+ odp.pfnDlgProc = DlgProcPOP3AccPopup;
+ Options_AddPage(wParam, &odp);
+ }
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+BOOL DlgEnableAccountStatus(HWND hDlg,WPARAM wParam,LPARAM lParam)
+{
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST0),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST1),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST2),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST3),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST4),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST5),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST6),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST7),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST8),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST9),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST9),(BOOL)wParam);
+ return TRUE;
+}
+BOOL DlgEnableAccountPopup(HWND hDlg,WPARAM wParam,LPARAM lParam)
+{
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKPOP),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITPOPS),(IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKCOL),(IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPB),(IsDlgButtonChecked(hDlg,IDC_CHECKCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPT),(IsDlgButtonChecked(hDlg,IDC_CHECKCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_RADIOPOPN),(IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_RADIOPOP1),(IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKNPOP),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITNPOPS),(IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKNCOL),(IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPNB),(IsDlgButtonChecked(hDlg,IDC_CHECKNCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPNT),(IsDlgButtonChecked(hDlg,IDC_CHECKNCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKFPOP),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITFPOPS),(IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKFCOL),(IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPFB),(IsDlgButtonChecked(hDlg,IDC_CHECKFCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPFT),(IsDlgButtonChecked(hDlg,IDC_CHECKFCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKAPOP),(BOOL)wParam);
+ return TRUE;
+}
+
+BOOL DlgEnableAccount(HWND hDlg,WPARAM wParam,LPARAM lParam)
+{
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECK),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITSERVER),wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITNAME),wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITPORT),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITLOGIN),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITPASS),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITINTERVAL),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKSND),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKMSG),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKICO),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKAPP),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKKBN),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNAPP),(IsDlgButtonChecked(hDlg,IDC_CHECKAPP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITAPP),(IsDlgButtonChecked(hDlg,IDC_CHECKAPP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITAPPPARAM),(IsDlgButtonChecked(hDlg,IDC_CHECKAPP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKNMSGP),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKFSND),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKFMSG),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKFICO),(BOOL)wParam);
+ /*EnableWindow(GetDlgItem(hDlg,IDC_CHECKST0),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST1),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST2),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST3),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST4),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST5),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST6),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST7),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST8),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST9),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKST9),(BOOL)wParam);*/
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKSTART),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKFORCE),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_COMBOCP),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_STTIMELEFT),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNRESET),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNDEFAULT),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNSTATUS),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKSSL),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKNOTLS),(IsDlgButtonChecked(hDlg,IDC_CHECKSSL)==BST_UNCHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_AUTOBODY),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKCONTACT),(BOOL)wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKCONTACTNICK),(IsDlgButtonChecked(hDlg,IDC_CHECKCONTACT)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKCONTACTNOEVENT),(IsDlgButtonChecked(hDlg,IDC_CHECKCONTACT)==BST_CHECKED) && wParam);
+ return TRUE;
+}
+BOOL DlgShowAccountStatus(HWND hDlg,WPARAM wParam,LPARAM lParam)
+{
+ HPOP3ACCOUNT ActualAccount=(HPOP3ACCOUNT)lParam;
+
+ if ((DWORD)wParam==M_SHOWACTUAL)
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNT:ActualAccountSO-read wait\n");
+ #endif
+ WaitToRead(ActualAccount); //we do not need to check if account is deleted. It is not deleted, because only thread that can delete account is this thread
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNT:ActualAccountSO-read enter\n");
+ #endif
+ CheckDlgButton(hDlg,IDC_CHECKST0,ActualAccount->StatusFlags & YAMN_ACC_ST0 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST1,ActualAccount->StatusFlags & YAMN_ACC_ST1 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST2,ActualAccount->StatusFlags & YAMN_ACC_ST2 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST3,ActualAccount->StatusFlags & YAMN_ACC_ST3 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST4,ActualAccount->StatusFlags & YAMN_ACC_ST4 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST5,ActualAccount->StatusFlags & YAMN_ACC_ST5 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST6,ActualAccount->StatusFlags & YAMN_ACC_ST6 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST7,ActualAccount->StatusFlags & YAMN_ACC_ST7 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST8,ActualAccount->StatusFlags & YAMN_ACC_ST8 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST9,ActualAccount->StatusFlags & YAMN_ACC_ST9 ? BST_CHECKED : BST_UNCHECKED);
+ ReadDone(ActualAccount);
+ }
+ else
+ {
+ CheckDlgButton(hDlg,IDC_CHECKST0,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST1,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST2,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST3,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST4,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST5,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST6,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST7,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST8,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST9,BST_CHECKED);
+ }
+ return TRUE;
+}
+BOOL DlgShowAccountPopup(HWND hDlg,WPARAM wParam,LPARAM lParam)
+{
+ HPOP3ACCOUNT ActualAccount=(HPOP3ACCOUNT)lParam;
+
+ if ((DWORD)wParam==M_SHOWACTUAL)
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNT:ActualAccountSO-read wait\n");
+ #endif
+ WaitToRead(ActualAccount); //we do not need to check if account is deleted. It is not deleted, because only thread that can delete account is this thread
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNT:ActualAccountSO-read enter\n");
+ #endif
+ SetDlgItemInt(hDlg,IDC_EDITPOPS,ActualAccount->NewMailN.PopUpTime,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITNPOPS,ActualAccount->NoNewMailN.PopUpTime,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITFPOPS,ActualAccount->BadConnectN.PopUpTime,FALSE);
+
+
+ CheckDlgButton(hDlg,IDC_CHECKPOP,ActualAccount->NewMailN.Flags & YAMN_ACC_POP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKCOL,ActualAccount->NewMailN.Flags & YAMN_ACC_POPC ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKNPOP,ActualAccount->NoNewMailN.Flags & YAMN_ACC_POP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKNCOL,ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFPOP,ActualAccount->BadConnectN.Flags & YAMN_ACC_POP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFCOL,ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_RADIOPOPN,ActualAccount->Flags & YAMN_ACC_POPN ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_RADIOPOP1,ActualAccount->Flags & YAMN_ACC_POPN ? BST_UNCHECKED : BST_CHECKED);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNT:ActualAccountSO-read done\n");
+ #endif
+ ReadDone(ActualAccount);
+ }
+ else //default
+ {
+
+ SetDlgItemInt(hDlg,IDC_EDITPOPS,0,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITNPOPS,0,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITFPOPS,0,FALSE);
+ CheckDlgButton(hDlg,IDC_CHECKPOP,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKCOL,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKNPOP,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKNCOL,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFPOP,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFCOL,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_RADIOPOPN,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_RADIOPOP1,BST_CHECKED);
+ }
+ return TRUE;
+}
+BOOL DlgShowAccount(HWND hDlg,WPARAM wParam,LPARAM lParam)
+{
+ HPOP3ACCOUNT ActualAccount=(HPOP3ACCOUNT)lParam;
+ int i;
+
+ if ((DWORD)wParam==M_SHOWACTUAL)
+ {
+ TCHAR accstatus[256];
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNT:ActualAccountSO-read wait\n");
+ #endif
+ WaitToRead(ActualAccount); //we do not need to check if account is deleted. It is not deleted, because only thread that can delete account is this thread
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNT:ActualAccountSO-read enter\n");
+ #endif
+ DlgSetItemText(hDlg, IDC_EDITSERVER, ActualAccount->Server->Name);
+ DlgSetItemText(hDlg, IDC_EDITNAME, ActualAccount->Name);
+ DlgSetItemText(hDlg, IDC_EDITLOGIN, ActualAccount->Server->Login);
+ DlgSetItemText(hDlg, IDC_EDITPASS, ActualAccount->Server->Passwd);
+ DlgSetItemTextW(hDlg, IDC_EDITAPP, ActualAccount->NewMailN.App);
+ DlgSetItemTextW(hDlg, IDC_EDITAPPPARAM, ActualAccount->NewMailN.AppParam);
+ SetDlgItemInt(hDlg,IDC_EDITPORT,ActualAccount->Server->Port,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITINTERVAL,ActualAccount->Interval/60,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITPOPS,ActualAccount->NewMailN.PopUpTime,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITNPOPS,ActualAccount->NoNewMailN.PopUpTime,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITFPOPS,ActualAccount->BadConnectN.PopUpTime,FALSE);
+ for (i=0;i<=CPLENSUPP;i++)
+ if ((i<CPLENSUPP) && (CodePageNamesSupp[i].CP==ActualAccount->CP))
+ {
+ SendMessage(GetDlgItem(hDlg,IDC_COMBOCP),CB_SETCURSEL,(WPARAM)i,0);
+ break;
+ }
+ if (i==CPLENSUPP)
+ SendMessage(GetDlgItem(hDlg,IDC_COMBOCP),CB_SETCURSEL,(WPARAM)CPDEFINDEX,0);
+
+ CheckDlgButton(hDlg,IDC_CHECK,ActualAccount->Flags & YAMN_ACC_ENA ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKSND,ActualAccount->NewMailN.Flags & YAMN_ACC_SND ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKMSG,ActualAccount->NewMailN.Flags & YAMN_ACC_MSG ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKICO,ActualAccount->NewMailN.Flags & YAMN_ACC_ICO ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKPOP,ActualAccount->NewMailN.Flags & YAMN_ACC_POP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKCOL,ActualAccount->NewMailN.Flags & YAMN_ACC_POPC ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKAPP,ActualAccount->NewMailN.Flags & YAMN_ACC_APP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKKBN,ActualAccount->NewMailN.Flags & YAMN_ACC_KBN ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKNPOP,ActualAccount->NoNewMailN.Flags & YAMN_ACC_POP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKNCOL,ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKNMSGP,ActualAccount->NoNewMailN.Flags & YAMN_ACC_MSGP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFSND,ActualAccount->BadConnectN.Flags & YAMN_ACC_SND ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFMSG,ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFICO,ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFPOP,ActualAccount->BadConnectN.Flags & YAMN_ACC_POP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFCOL,ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_RADIOPOPN,ActualAccount->Flags & YAMN_ACC_POPN ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_RADIOPOP1,ActualAccount->Flags & YAMN_ACC_POPN ? BST_UNCHECKED : BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKSSL,ActualAccount->Flags & YAMN_ACC_SSL23 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKNOTLS,ActualAccount->Flags & YAMN_ACC_NOTLS ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKAPOP,ActualAccount->Flags & YAMN_ACC_APOP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_AUTOBODY,ActualAccount->Flags & YAMN_ACC_BODY ? BST_CHECKED : BST_UNCHECKED);
+ /*CheckDlgButton(hDlg,IDC_CHECKST0,ActualAccount->StatusFlags & YAMN_ACC_ST0 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST1,ActualAccount->StatusFlags & YAMN_ACC_ST1 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST2,ActualAccount->StatusFlags & YAMN_ACC_ST2 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST3,ActualAccount->StatusFlags & YAMN_ACC_ST3 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST4,ActualAccount->StatusFlags & YAMN_ACC_ST4 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST5,ActualAccount->StatusFlags & YAMN_ACC_ST5 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST6,ActualAccount->StatusFlags & YAMN_ACC_ST6 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST7,ActualAccount->StatusFlags & YAMN_ACC_ST7 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST8,ActualAccount->StatusFlags & YAMN_ACC_ST8 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST9,ActualAccount->StatusFlags & YAMN_ACC_ST9 ? BST_CHECKED : BST_UNCHECKED);*/
+ Check0=ActualAccount->StatusFlags & YAMN_ACC_ST0;
+ Check1=ActualAccount->StatusFlags & YAMN_ACC_ST1;
+ Check2=ActualAccount->StatusFlags & YAMN_ACC_ST2;
+ Check3=ActualAccount->StatusFlags & YAMN_ACC_ST3;
+ Check4=ActualAccount->StatusFlags & YAMN_ACC_ST4;
+ Check5=ActualAccount->StatusFlags & YAMN_ACC_ST5;
+ Check6=ActualAccount->StatusFlags & YAMN_ACC_ST6;
+ Check7=ActualAccount->StatusFlags & YAMN_ACC_ST7;
+ Check8=ActualAccount->StatusFlags & YAMN_ACC_ST8;
+ Check9=ActualAccount->StatusFlags & YAMN_ACC_ST9;
+ CheckDlgButton(hDlg,IDC_CHECKSTART,ActualAccount->StatusFlags & YAMN_ACC_STARTS ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFORCE,ActualAccount->StatusFlags & YAMN_ACC_FORCE ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKCONTACT,ActualAccount->NewMailN.Flags & YAMN_ACC_CONT ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKCONTACTNICK,ActualAccount->NewMailN.Flags & YAMN_ACC_CONTNICK ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKCONTACTNOEVENT,ActualAccount->NewMailN.Flags & YAMN_ACC_CONTNOEVENT ? BST_CHECKED : BST_UNCHECKED);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNT:ActualAccountSO-read done\n");
+#endif
+ GetAccountStatus(ActualAccount,accstatus);
+ SetDlgItemText(hDlg,IDC_STSTATUS,accstatus);
+ ReadDone(ActualAccount);
+ }
+ else //default
+ {
+ DlgSetItemText(hDlg,(WPARAM)IDC_EDITSERVER,0);
+ DlgSetItemText(hDlg,(WPARAM)IDC_EDITNAME,0);
+ DlgSetItemText(hDlg,(WPARAM)IDC_EDITLOGIN,0);
+ DlgSetItemText(hDlg,(WPARAM)IDC_EDITPASS,0);
+ DlgSetItemText(hDlg,(WPARAM)IDC_EDITAPP,0);
+ DlgSetItemText(hDlg,(WPARAM)IDC_EDITAPPPARAM,0);
+ DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0);
+ SetDlgItemInt(hDlg,IDC_EDITPORT,110,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITINTERVAL,30,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITPOPS,0,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITNPOPS,0,FALSE);
+ SetDlgItemInt(hDlg,IDC_EDITFPOPS,0,FALSE);
+ SendMessage(GetDlgItem(hDlg,IDC_COMBOCP),CB_SETCURSEL,(WPARAM)CPDEFINDEX,0);
+ CheckDlgButton(hDlg,IDC_CHECK,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKSND,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKMSG,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKICO,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKPOP,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKCOL,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKAPP,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKPOP,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKCOL,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFSND,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFMSG,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFICO,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFPOP,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFCOL,BST_CHECKED);
+ /*CheckDlgButton(hDlg,IDC_CHECKST0,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST1,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST2,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST3,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST4,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST5,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST6,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST7,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST8,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST9,BST_CHECKED);*/
+ CheckDlgButton(hDlg,IDC_CHECKSTART,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKFORCE,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_RADIOPOPN,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_RADIOPOP1,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKSSL,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKNOTLS,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKAPOP,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_AUTOBODY,BST_UNCHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKCONTACT,BST_CHECKED);
+
+ SetDlgItemText(hDlg,IDC_STSTATUS,TranslateT("No account selected"));
+ }
+ return TRUE;
+}
+
+BOOL DlgShowAccountColors(HWND hDlg,WPARAM wParam,LPARAM lParam)
+{
+ HPOP3ACCOUNT ActualAccount=(HPOP3ACCOUNT)lParam;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNTCOLORS:ActualAccountSO-read wait\n");
+#endif
+ WaitToRead(ActualAccount); //we do not need to check if account is deleted. It is not deleted, because only thread that can delete account is this thread
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNTCOLORS:ActualAccountSO-read enter\n");
+#endif
+ if (ActualAccount->NewMailN.Flags & YAMN_ACC_POPC)
+ {
+ SendDlgItemMessage(hDlg,IDC_CPB,CPM_SETCOLOUR,0,(LPARAM)ActualAccount->NewMailN.PopUpB);
+ SendDlgItemMessage(hDlg,IDC_CPT,CPM_SETCOLOUR,0,(LPARAM)ActualAccount->NewMailN.PopUpT);
+ }
+ else
+ {
+ SendDlgItemMessage(hDlg,IDC_CPB,CPM_SETCOLOUR,0,(LPARAM)GetSysColor(COLOR_BTNFACE));
+ SendDlgItemMessage(hDlg,IDC_CPT,CPM_SETCOLOUR,0,(LPARAM)GetSysColor(COLOR_WINDOWTEXT));
+ }
+ if (ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC)
+ {
+ SendDlgItemMessage(hDlg,IDC_CPFB,CPM_SETCOLOUR,0,(LPARAM)ActualAccount->BadConnectN.PopUpB);
+ SendDlgItemMessage(hDlg,IDC_CPFT,CPM_SETCOLOUR,0,(LPARAM)ActualAccount->BadConnectN.PopUpT);
+ }
+ else
+ {
+ SendDlgItemMessage(hDlg,IDC_CPFB,CPM_SETCOLOUR,0,(LPARAM)GetSysColor(COLOR_BTNFACE));
+ SendDlgItemMessage(hDlg,IDC_CPFT,CPM_SETCOLOUR,0,(LPARAM)GetSysColor(COLOR_WINDOWTEXT));
+ }
+ if (ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC)
+ {
+ SendDlgItemMessage(hDlg,IDC_CPNB,CPM_SETCOLOUR,0,(LPARAM)ActualAccount->NoNewMailN.PopUpB);
+ SendDlgItemMessage(hDlg,IDC_CPNT,CPM_SETCOLOUR,0,(LPARAM)ActualAccount->NoNewMailN.PopUpT);
+ }
+ else
+ {
+ SendDlgItemMessage(hDlg,IDC_CPNB,CPM_SETCOLOUR,0,(LPARAM)GetSysColor(COLOR_BTNFACE));
+ SendDlgItemMessage(hDlg,IDC_CPNT,CPM_SETCOLOUR,0,(LPARAM)GetSysColor(COLOR_WINDOWTEXT));
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:SHOWACCOUNTCOLORS:ActualAccountSO-read done\n");
+#endif
+ ReadDone(ActualAccount); //we do not need to check if account is deleted. It is not deleted, because only thread that can delete account is this thread
+ return TRUE;
+}
+
+BOOL DlgSetItemText(HWND hDlg, WPARAM wParam,const char* str)
+{
+ if (str == NULL)
+ SetDlgItemTextA(hDlg, wParam, "");
+ else
+ SetDlgItemTextA(hDlg, wParam, str);
+ return TRUE;
+}
+
+BOOL DlgSetItemTextW(HWND hDlg,WPARAM wParam,const WCHAR* str)
+{
+ if (str == NULL)
+ SetDlgItemTextW(hDlg, wParam, L"");
+ else
+ SetDlgItemTextW(hDlg, wParam, str);
+ return TRUE;
+}
+
+INT_PTR CALLBACK DlgProcPOP3AccStatusOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ static HPOP3ACCOUNT ActualAccount;
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)DlgInput);
+ if (ActualAccount != NULL)
+ {
+ DlgShowAccountStatus(hDlg,(WPARAM)M_SHOWACTUAL,(LPARAM)ActualAccount);
+ DlgEnableAccountStatus(hDlg,(WPARAM)TRUE,(LPARAM)TRUE);
+ }
+ else
+ {
+ CheckDlgButton(hDlg,IDC_CHECKST0,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST1,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST2,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST3,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST4,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST5,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST6,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST7,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST8,BST_CHECKED);
+ CheckDlgButton(hDlg,IDC_CHECKST9,BST_CHECKED);
+ }
+ TranslateDialogDefault(hDlg);
+ SendMessage(GetParent(hDlg),PSM_UNCHANGED,(WPARAM)hDlg,0);
+ return TRUE;
+ break;
+ }
+ case WM_COMMAND:
+ {
+
+ WORD wNotifyCode = HIWORD(wParam);
+ switch(LOWORD(wParam))
+ {
+ case IDOK:
+ Check0 = (IsDlgButtonChecked(hDlg,IDC_CHECKST0)==BST_CHECKED);
+ Check1 = (IsDlgButtonChecked(hDlg,IDC_CHECKST1)==BST_CHECKED);
+ Check2 = (IsDlgButtonChecked(hDlg,IDC_CHECKST2)==BST_CHECKED);
+ Check3 = (IsDlgButtonChecked(hDlg,IDC_CHECKST3)==BST_CHECKED);
+ Check4 = (IsDlgButtonChecked(hDlg,IDC_CHECKST4)==BST_CHECKED);
+ Check5 = (IsDlgButtonChecked(hDlg,IDC_CHECKST5)==BST_CHECKED);
+ Check6 = (IsDlgButtonChecked(hDlg,IDC_CHECKST6)==BST_CHECKED);
+ Check7 = (IsDlgButtonChecked(hDlg,IDC_CHECKST7)==BST_CHECKED);
+ Check8 = (IsDlgButtonChecked(hDlg,IDC_CHECKST8)==BST_CHECKED);
+ Check9 = (IsDlgButtonChecked(hDlg,IDC_CHECKST9)==BST_CHECKED);
+ WindowList_BroadcastAsync(YAMNVar.MessageWnds,WM_YAMN_CHANGESTATUSOPTION,0,0);
+ EndDialog(hDlg,0);
+ DestroyWindow(hDlg);
+ break;
+
+ case IDCANCEL:
+ EndDialog(hDlg,0);
+ DestroyWindow(hDlg);
+ break;
+
+ default:
+ break;
+ }
+ }
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+
+INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ BOOL Changed=FALSE;
+ INT_PTR Result;
+ static BOOL InList=FALSE;
+ static HPOP3ACCOUNT ActualAccount;
+ static UCHAR ActualStatus;
+// static struct CPOP3Options POP3Options;
+
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ int i;
+
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),FALSE);
+
+ DlgEnableAccount(hDlg,(WPARAM)FALSE,(LPARAM)FALSE);
+ DlgShowAccount(hDlg,(WPARAM)M_SHOWDEFAULT,0);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:INITDIALOG:AccountBrowserSO-read wait\n");
+ #endif
+ WaitToReadSO(POP3Plugin->AccountBrowserSO);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:INITDIALOG:AccountBrowserSO-read enter\n");
+ #endif
+
+ for (ActualAccount=(HPOP3ACCOUNT)POP3Plugin->FirstAccount;ActualAccount!=NULL;ActualAccount=(HPOP3ACCOUNT)ActualAccount->Next)
+ if (ActualAccount->Name != NULL)
+ SendDlgItemMessageA(hDlg,IDC_COMBOACCOUNT,CB_ADDSTRING,0,(LPARAM)ActualAccount->Name);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:INITDIALOG:AccountBrowserSO-read done\n");
+ #endif
+ ReadDoneSO(POP3Plugin->AccountBrowserSO);
+ SendDlgItemMessage(hDlg, IDC_COMBOCP, CB_ADDSTRING, 0, (LPARAM)TranslateT("Default"));
+ for (i=1; i < CPLENSUPP; i++) {
+ CPINFOEX info; GetCPInfoEx(CodePageNamesSupp[i].CP,0,&info);
+ size_t len = lstrlen(info.CodePageName+7);
+ info.CodePageName[len+6]=0;
+ SendDlgItemMessage(hDlg,IDC_COMBOCP,CB_ADDSTRING,0,(LPARAM)(info.CodePageName+7));
+ }
+
+ SendMessage(GetDlgItem(hDlg,IDC_COMBOCP),CB_SETCURSEL,(WPARAM)CPDEFINDEX,0);
+ ActualAccount=NULL;
+ TranslateDialogDefault(hDlg);
+ SendMessage(GetParent(hDlg),PSM_UNCHANGED,(WPARAM)hDlg,0);
+ return TRUE;
+ }
+
+ case WM_SHOWWINDOW:
+ if ( wParam == FALSE) {
+ WindowList_Remove(pYAMNVar->MessageWnds,hDlg);
+ SendMessage(GetParent(hDlg),PSM_UNCHANGED,(WPARAM)hDlg,0);
+ }
+ else WindowList_Add(pYAMNVar->MessageWnds,hDlg,NULL);
+ return TRUE;
+
+ case WM_YAMN_CHANGESTATUS:
+ if ((HPOP3ACCOUNT)wParam == ActualAccount) {
+ TCHAR accstatus[256];
+ GetAccountStatus(ActualAccount,accstatus);
+ SetDlgItemText(hDlg,IDC_STSTATUS,accstatus);
+ return TRUE;
+ }
+ break;
+
+ case WM_YAMN_CHANGESTATUSOPTION:
+ Changed=TRUE;
+ SendMessage(GetParent(hDlg),PSM_CHANGED,0,0);
+ return TRUE;
+
+ case WM_YAMN_CHANGETIME:
+ if ((HPOP3ACCOUNT)wParam == ActualAccount) {
+ TCHAR Text[256];
+ mir_sntprintf(Text,SIZEOF(Text),TranslateT("Time left to next check [s]: %d"),(DWORD)lParam);
+ SetDlgItemText(hDlg,IDC_STTIMELEFT,Text);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_COMBOACCOUNT:
+ switch( HIWORD(wParam)) {
+ case CBN_EDITCHANGE :
+ ActualAccount=NULL;
+ DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0);
+
+ if (GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,sizeof(DlgInput)))
+ DlgEnableAccount(hDlg,(WPARAM)TRUE,(LPARAM)FALSE);
+ else
+ DlgEnableAccount(hDlg,(WPARAM)FALSE,(LPARAM)FALSE);
+ break;
+
+ case CBN_KILLFOCUS:
+ GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,sizeof(DlgInput));
+ if (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)DlgInput))) {
+ DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0);
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),FALSE);
+ if (lstrlenA(DlgInput))
+ DlgEnableAccount(hDlg,(WPARAM)TRUE,(LPARAM)TRUE);
+ else
+ DlgEnableAccount(hDlg,(WPARAM)FALSE,(LPARAM)FALSE);
+ }
+ else {
+ DlgShowAccount(hDlg,(WPARAM)M_SHOWACTUAL,(LPARAM)ActualAccount);
+ DlgEnableAccount(hDlg,(WPARAM)TRUE,(LPARAM)TRUE);
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),TRUE);
+ }
+ break;
+
+ case CBN_SELCHANGE:
+ if (CB_ERR!=(Result=SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_GETCURSEL,0,0)))
+ SendDlgItemMessageA(hDlg,IDC_COMBOACCOUNT,CB_GETLBTEXT,(WPARAM)Result,(LPARAM)DlgInput);
+
+ if ((Result==CB_ERR) || (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)DlgInput)))) {
+ DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0);
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),FALSE);
+ }
+ else {
+ DlgShowAccount(hDlg,(WPARAM)M_SHOWACTUAL,(LPARAM)ActualAccount);
+ DlgEnableAccount(hDlg,(WPARAM)TRUE,(LPARAM)FALSE);
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),TRUE);
+ }
+ break;
+ }
+ break;
+
+ case IDC_COMBOCP:
+ {
+ int sel = SendDlgItemMessage(hDlg,IDC_COMBOCP,CB_GETCURSEL,0,0);
+ CPINFOEX info; GetCPInfoEx(CodePageNamesSupp[sel].CP,0,&info);
+ DlgSetItemTextT(hDlg, IDC_STSTATUS, info.CodePageName);
+ }
+ case IDC_CHECK:
+ case IDC_CHECKSND:
+ case IDC_CHECKMSG:
+ case IDC_CHECKICO:
+ case IDC_CHECKFSND:
+ case IDC_CHECKFMSG:
+ case IDC_CHECKFICO:
+ case IDC_CHECKST0:
+ case IDC_CHECKST1:
+ case IDC_CHECKST2:
+ case IDC_CHECKST3:
+ case IDC_CHECKST4:
+ case IDC_CHECKST5:
+ case IDC_CHECKST6:
+ case IDC_CHECKST7:
+ case IDC_CHECKST8:
+ case IDC_CHECKST9:
+ case IDC_CHECKSTART:
+ case IDC_CHECKFORCE:
+ case IDC_EDITAPPPARAM:
+ case IDC_CHECKAPOP:
+ case IDC_AUTOBODY:
+ case IDC_CHECKCONTACTNICK:
+ case IDC_CHECKCONTACTNOEVENT:
+ case IDC_CHECKNOTLS:
+ Changed=TRUE;
+ break;
+
+ case IDC_CHECKCONTACT:
+ Changed=IsDlgButtonChecked(hDlg,IDC_CHECKCONTACT)==BST_CHECKED;
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKCONTACTNICK),Changed);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKCONTACTNOEVENT),Changed);
+ Changed=TRUE;
+ break;
+
+ case IDC_CHECKSSL:
+ {
+ BOOL SSLC = (IsDlgButtonChecked(hDlg,IDC_CHECKSSL)==BST_CHECKED);
+ SetDlgItemInt(hDlg,IDC_EDITPORT,SSLC ? 995 : 110,FALSE);
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKNOTLS),SSLC?0:1);
+ }
+ Changed=TRUE;
+ break;
+
+ case IDC_CPB:
+ case IDC_CPT:
+ case IDC_CPFB:
+ case IDC_CPFT:
+ case IDC_CPNB:
+ case IDC_CPNT:
+ if (HIWORD(wParam)!=CPN_COLOURCHANGED)
+ break;
+
+ case IDC_CHECKKBN:
+ Changed=TRUE;
+ break;
+
+ case IDC_CHECKAPP:
+ Changed=TRUE;
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNAPP),IsDlgButtonChecked(hDlg,IDC_CHECKAPP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITAPP),IsDlgButtonChecked(hDlg,IDC_CHECKAPP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITAPPPARAM),IsDlgButtonChecked(hDlg,IDC_CHECKAPP)==BST_CHECKED);
+ break;
+
+ case IDC_BTNSTATUS:
+ DialogBoxParamW(pYAMNVar->hInst,MAKEINTRESOURCEW(IDD_CHOOSESTATUSMODES),hDlg,DlgProcPOP3AccStatusOpt,NULL);
+ break;
+
+ case IDC_BTNADD:
+ DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0);
+ DlgShowAccount(hDlg,(WPARAM)M_SHOWDEFAULT,0);
+ DlgEnableAccount(hDlg,(WPARAM)TRUE,(LPARAM)TRUE);
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),FALSE);
+ DlgSetItemTextT(hDlg, IDC_EDITNAME, TranslateT("New Account"));
+ {
+ int index = SendDlgItemMessage(hDlg, IDC_COMBOACCOUNT, CB_ADDSTRING, 0, (LPARAM)TranslateT("New Account"));
+ if ( index != CB_ERR && index != CB_ERRSPACE )
+ SendDlgItemMessage(hDlg, IDC_COMBOACCOUNT, CB_SETCURSEL, index, (LPARAM)TranslateT("New Account"));
+ }
+ break;
+
+ case IDC_BTNAPP:
+ {
+ TCHAR filter[MAX_PATH];
+ mir_sntprintf(filter, SIZEOF(filter), _T("%s (*.exe;*.bat;*.cmd;*.com)%c*.exe;*.bat;*.cmd;*.com%c%s (*.*)%c*.*%c"),
+ TranslateT("Executables"), 0, 0, TranslateT("All Files"), 0, 0);
+
+ OPENFILENAME OFNStruct = { 0 };
+ OFNStruct.lStructSize = sizeof(OPENFILENAME);
+ OFNStruct.hwndOwner = hDlg;
+ OFNStruct.lpstrFilter= filter;
+ OFNStruct.nFilterIndex=1;
+ OFNStruct.nMaxFile=MAX_PATH;
+ OFNStruct.lpstrFile=new TCHAR[MAX_PATH];
+ OFNStruct.lpstrFile[0]=(TCHAR)0;
+ OFNStruct.lpstrTitle=TranslateT("Select executable used for notification");
+ OFNStruct.Flags=OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR;
+ if (!GetOpenFileName(&OFNStruct))
+ {
+ if (CommDlgExtendedError())
+ MessageBox(hDlg,_T("Dialog box error"),_T("Failed"),MB_OK);
+ }
+ else DlgSetItemTextT(hDlg, IDC_EDITAPP, OFNStruct.lpstrFile);
+ delete[] OFNStruct.lpstrFile;
+ }
+ break;
+
+ case IDC_BTNDEFAULT:
+ DlgShowAccount(hDlg,(WPARAM)M_SHOWDEFAULT,0);
+ break;
+
+ case IDC_BTNDEL:
+ GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,sizeof(DlgInput));
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),FALSE);
+ if ((CB_ERR==(Result=SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_GETCURSEL,0,0)))
+ || (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)DlgInput))))
+ return TRUE;
+
+ if (IDOK!=MessageBox(hDlg,TranslateT("Do you really want to delete this account?"),TranslateT("Delete account confirmation"),MB_OKCANCEL | MB_ICONWARNING))
+ return TRUE;
+
+ DlgSetItemTextT(hDlg, IDC_STTIMELEFT, TranslateT("Please wait while no account is in use."));
+
+ if (ActualAccount->hContact != NULL)
+ CallService(MS_DB_CONTACT_DELETE,(WPARAM)(HANDLE) ActualAccount->hContact, 0);
+
+ CallService(MS_YAMN_DELETEACCOUNT,(WPARAM)POP3Plugin,(LPARAM)ActualAccount);
+
+ //We can consider our account as deleted.
+
+ SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_DELETESTRING,(WPARAM)Result,0);
+ DlgSetItemText(hDlg,(WPARAM)IDC_COMBOACCOUNT,0);
+ DlgEnableAccount(hDlg,(WPARAM)FALSE,0);
+ DlgShowAccount(hDlg,(WPARAM)M_SHOWDEFAULT,0);
+ break;
+
+ case IDC_BTNRESET:
+ if (ActualAccount != NULL)
+ ActualAccount->TimeLeft=ActualAccount->Interval;
+ return 1;
+ }
+
+ if (HIWORD(wParam) == EN_CHANGE)
+ Changed = TRUE;
+ break;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY ) {
+ char Text[MAX_PATH];
+ WCHAR TextW[MAX_PATH];
+ BOOL Translated,NewAcc=FALSE,Check,CheckMsg,CheckSnd,CheckIco,CheckApp, CheckAPOP;
+ BOOL CheckNMsgP,CheckFMsg,CheckFSnd,CheckFIco;
+ BOOL CheckKBN, CheckContact,CheckContactNick,CheckContactNoEvent;
+ BOOL CheckSSL, CheckABody, CheckNoTLS;
+ //BOOL Check0,Check1,Check2,Check3,Check4,Check5,Check6,Check7,Check8,Check9,
+ BOOL CheckStart,CheckForce;
+ size_t Length,index;
+ UINT Port,Interval;
+
+ if ( GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT, Text, sizeof(Text))) {
+ Check = (IsDlgButtonChecked(hDlg,IDC_CHECK)==BST_CHECKED);
+ CheckSSL = (IsDlgButtonChecked(hDlg,IDC_CHECKSSL)==BST_CHECKED);
+ CheckNoTLS = (IsDlgButtonChecked(hDlg,IDC_CHECKNOTLS)==BST_CHECKED);
+ CheckAPOP = (IsDlgButtonChecked(hDlg,IDC_CHECKAPOP)==BST_CHECKED);
+
+ CheckABody = (IsDlgButtonChecked(hDlg,IDC_AUTOBODY)==BST_CHECKED);
+ CheckMsg = (IsDlgButtonChecked(hDlg,IDC_CHECKMSG)==BST_CHECKED);
+ CheckSnd = (IsDlgButtonChecked(hDlg,IDC_CHECKSND)==BST_CHECKED);
+ CheckIco = (IsDlgButtonChecked(hDlg,IDC_CHECKICO)==BST_CHECKED);
+
+ CheckApp = (IsDlgButtonChecked(hDlg,IDC_CHECKAPP)==BST_CHECKED);
+ CheckKBN = (IsDlgButtonChecked(hDlg,IDC_CHECKKBN)==BST_CHECKED);
+ CheckContact = (IsDlgButtonChecked(hDlg,IDC_CHECKCONTACT)==BST_CHECKED);
+ CheckContactNick = (IsDlgButtonChecked(hDlg,IDC_CHECKCONTACTNICK)==BST_CHECKED);
+ CheckContactNoEvent = (IsDlgButtonChecked(hDlg,IDC_CHECKCONTACTNOEVENT)==BST_CHECKED);
+
+ CheckFSnd = (IsDlgButtonChecked(hDlg,IDC_CHECKFSND)==BST_CHECKED);
+ CheckFMsg = (IsDlgButtonChecked(hDlg,IDC_CHECKFMSG)==BST_CHECKED);
+ CheckFIco = (IsDlgButtonChecked(hDlg,IDC_CHECKFICO)==BST_CHECKED);
+
+ CheckNMsgP = (IsDlgButtonChecked(hDlg,IDC_CHECKNMSGP)==BST_CHECKED);
+
+ Port = GetDlgItemInt(hDlg, IDC_EDITPORT, &Translated, FALSE);
+ if ( !Translated ) {
+ MessageBox(hDlg,TranslateT("This is not a valid number value"),TranslateT("Input error"),MB_OK);
+ SetFocus(GetDlgItem(hDlg,IDC_EDITPORT));
+ break;
+ }
+ Interval = GetDlgItemInt(hDlg,IDC_EDITINTERVAL,&Translated,FALSE);
+ if ( !Translated ) {
+ MessageBox(hDlg,TranslateT("This is not a valid number value"),TranslateT("Input error"),MB_OK);
+ SetFocus(GetDlgItem(hDlg,IDC_EDITINTERVAL));
+ break;
+ }
+
+ GetDlgItemTextA(hDlg, IDC_EDITAPP, Text, sizeof(Text));
+ if (CheckApp && !(Length = strlen(Text))) {
+ MessageBox(hDlg,TranslateT("Please select application to run"),TranslateT("Input error"),MB_OK);
+ break;
+ }
+
+ GetDlgItemTextA(hDlg, IDC_COMBOACCOUNT, Text, sizeof(Text));
+ if ( !( Length = strlen(Text))) {
+ GetDlgItemTextA(hDlg,IDC_EDITNAME, Text, sizeof(Text));
+ if ( !(Length = strlen( Text )))
+ break;
+ }
+
+ DlgSetItemTextT(hDlg, IDC_STTIMELEFT, TranslateT("Please wait while no account is in use."));
+
+ if (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)Text))) {
+ NewAcc=TRUE;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:AccountBrowserSO-write wait\n");
+ #endif
+ WaitToWriteSO(POP3Plugin->AccountBrowserSO);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:AccountBrowserSO-write enter\n");
+ #endif
+ if (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_GETNEXTFREEACCOUNT,(WPARAM)POP3Plugin,(LPARAM)YAMN_ACCOUNTVERSION))) {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:AccountBrowserSO-write done\n");
+ #endif
+ WriteDoneSO(POP3Plugin->AccountBrowserSO);
+ MessageBox(hDlg,TranslateT("Cannot allocate memory space for new account"),TranslateT("Memory error"),MB_OK);
+ break;
+ }
+ }
+ else {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:AccountBrowserSO-write wait\n");
+ #endif
+ //We have to get full access to AccountBrowser, so other iterating thrads cannot get new account until new account is right set
+ WaitToWriteSO(POP3Plugin->AccountBrowserSO);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:AccountBrowserSO-write enter\n");
+ #endif
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:ActualAccountSO-write wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=WaitToWrite(ActualAccount))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:ActualAccountSO-write wait failed\n");
+ #endif
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:ActualBrowserSO-write done\n");
+ #endif
+ WriteDoneSO(POP3Plugin->AccountBrowserSO);
+
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:ActualAccountSO-write enter\n");
+ #endif
+
+ GetDlgItemTextA(hDlg, IDC_EDITNAME, Text, sizeof(Text));
+ if ( !(Length = strlen( Text )))
+ break;
+ if (NULL != ActualAccount->Name)
+ delete[] ActualAccount->Name;
+ ActualAccount->Name = new char[ strlen(Text)+1];
+ strcpy(ActualAccount->Name,Text);
+
+ GetDlgItemTextA(hDlg,IDC_EDITSERVER,Text,sizeof(Text));
+ if (NULL!=ActualAccount->Server->Name)
+ delete[] ActualAccount->Server->Name;
+ ActualAccount->Server->Name=new char[ strlen(Text)+1];
+ strcpy(ActualAccount->Server->Name,Text);
+
+ GetDlgItemTextA(hDlg,IDC_EDITLOGIN,Text,sizeof(Text));
+ if (NULL!=ActualAccount->Server->Login)
+ delete[] ActualAccount->Server->Login;
+ ActualAccount->Server->Login=new char[ strlen(Text)+1];
+ strcpy(ActualAccount->Server->Login,Text);
+
+ GetDlgItemTextA(hDlg,IDC_EDITPASS,Text,sizeof(Text));
+ if (NULL!=ActualAccount->Server->Passwd)
+ delete[] ActualAccount->Server->Passwd;
+ ActualAccount->Server->Passwd=new char[ strlen(Text)+1];
+ strcpy(ActualAccount->Server->Passwd,Text);
+
+ GetDlgItemTextW(hDlg,IDC_EDITAPP,TextW,SIZEOF(TextW));
+ if (NULL!=ActualAccount->NewMailN.App)
+ delete[] ActualAccount->NewMailN.App;
+ ActualAccount->NewMailN.App=new WCHAR[wcslen(TextW)+1];
+ wcscpy(ActualAccount->NewMailN.App,TextW);
+
+ GetDlgItemTextW(hDlg,IDC_EDITAPPPARAM,TextW,SIZEOF(TextW));
+ if (NULL!=ActualAccount->NewMailN.AppParam)
+ delete[] ActualAccount->NewMailN.AppParam;
+ ActualAccount->NewMailN.AppParam=new WCHAR[wcslen(TextW)+1];
+ wcscpy(ActualAccount->NewMailN.AppParam,TextW);
+
+ ActualAccount->Server->Port=Port;
+ ActualAccount->Interval=Interval*60;
+
+ if (CB_ERR==(index=SendDlgItemMessage(hDlg,IDC_COMBOCP,CB_GETCURSEL,0,0)))
+ index = CPDEFINDEX;
+ ActualAccount->CP = CodePageNamesSupp[index].CP;
+
+ if (NewAcc)
+ ActualAccount->TimeLeft=Interval*60;
+
+ CheckStart = (IsDlgButtonChecked(hDlg,IDC_CHECKSTART)==BST_CHECKED);
+ CheckForce = (IsDlgButtonChecked(hDlg,IDC_CHECKFORCE)==BST_CHECKED);
+
+ ActualAccount->Flags=
+ (Check ? YAMN_ACC_ENA : 0) |
+ (CheckSSL ? YAMN_ACC_SSL23 : 0) |
+ (CheckNoTLS ? YAMN_ACC_NOTLS : 0) |
+ (CheckAPOP ? YAMN_ACC_APOP : 0) |
+ (CheckABody ? YAMN_ACC_BODY : 0) |
+ (ActualAccount->Flags & YAMN_ACC_POPN);
+
+ ActualAccount->StatusFlags=
+ (Check0 ? YAMN_ACC_ST0 : 0) |
+ (Check1 ? YAMN_ACC_ST1 : 0) |
+ (Check2 ? YAMN_ACC_ST2 : 0) |
+ (Check3 ? YAMN_ACC_ST3 : 0) |
+ (Check4 ? YAMN_ACC_ST4 : 0) |
+ (Check5 ? YAMN_ACC_ST5 : 0) |
+ (Check6 ? YAMN_ACC_ST6 : 0) |
+ (Check7 ? YAMN_ACC_ST7 : 0) |
+ (Check8 ? YAMN_ACC_ST8 : 0) |
+ (Check9 ? YAMN_ACC_ST9 : 0) |
+ (CheckStart ? YAMN_ACC_STARTS : 0) |
+ (CheckForce ? YAMN_ACC_FORCE : 0);
+
+ ActualAccount->NewMailN.Flags=
+ (CheckSnd ? YAMN_ACC_SND : 0) |
+ (CheckMsg ? YAMN_ACC_MSG : 0) |
+ (CheckIco ? YAMN_ACC_ICO : 0) |
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_POP) |
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_POPC) |
+ (CheckApp ? YAMN_ACC_APP : 0) |
+ (CheckKBN ? YAMN_ACC_KBN : 0) |
+ (CheckContact ? YAMN_ACC_CONT : 0) |
+ (CheckContactNick ? YAMN_ACC_CONTNICK : 0) |
+ (CheckContactNoEvent ? YAMN_ACC_CONTNOEVENT : 0) |
+ YAMN_ACC_MSGP; //this is default: when new mail arrives and window was displayed, leave it displayed.
+
+ ActualAccount->NoNewMailN.Flags=
+ (ActualAccount->NoNewMailN.Flags & YAMN_ACC_POP) |
+ (ActualAccount->NoNewMailN.Flags & YAMN_ACC_POPC) |
+ (CheckNMsgP ? YAMN_ACC_MSGP : 0);
+
+ ActualAccount->BadConnectN.Flags=
+ (CheckFSnd ? YAMN_ACC_SND : 0) |
+ (CheckFMsg ? YAMN_ACC_MSG : 0) |
+ (CheckFIco ? YAMN_ACC_ICO : 0) |
+ (ActualAccount->BadConnectN.Flags & YAMN_ACC_POP) |
+ (ActualAccount->BadConnectN.Flags & YAMN_ACC_POPC);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:ActualAccountSO-write done\n");
+ #endif
+ WriteDone(ActualAccount);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:AccountBrowserSO-write done\n");
+ #endif
+ WriteDoneSO(POP3Plugin->AccountBrowserSO);
+
+ EnableWindow(GetDlgItem(hDlg,IDC_BTNDEL),TRUE);
+
+ DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0);
+
+ index = SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_GETCURSEL,0,0);
+
+ HPOP3ACCOUNT temp = ActualAccount;
+
+ SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_RESETCONTENT,0,0);
+ if (POP3Plugin->FirstAccount!=NULL)
+ for (ActualAccount=(HPOP3ACCOUNT)POP3Plugin->FirstAccount;ActualAccount!=NULL;ActualAccount=(HPOP3ACCOUNT)ActualAccount->Next)
+ if (ActualAccount->Name!=NULL)
+ SendDlgItemMessageA(hDlg,IDC_COMBOACCOUNT,CB_ADDSTRING,0,(LPARAM)ActualAccount->Name);
+
+ ActualAccount = temp;
+ SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_SETCURSEL,(WPARAM)index,(LPARAM)ActualAccount->Name);
+
+ WritePOP3Accounts();
+ RefreshContact();
+ return TRUE;
+ }
+ }
+ break;
+ }
+ if (Changed)
+ SendMessage(GetParent(hDlg),PSM_CHANGED,0,0);
+ return FALSE;
+}
+
+INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ BOOL Changed=FALSE;
+ static BOOL InList=FALSE;
+ static HPOP3ACCOUNT ActualAccount;
+ static UCHAR ActualStatus;
+// static struct CPOP3Options POP3Options;
+
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ DlgEnableAccountPopup(hDlg,(WPARAM)FALSE,(LPARAM)FALSE);
+ DlgShowAccountPopup(hDlg,(WPARAM)M_SHOWDEFAULT,0);
+ //DlgShowAccountColors(hDlg,0,(LPARAM)ActualAccount);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:INITDIALOG:AccountBrowserSO-read wait\n");
+ #endif
+ WaitToReadSO(POP3Plugin->AccountBrowserSO);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:INITDIALOG:AccountBrowserSO-read enter\n");
+ #endif
+ if (POP3Plugin->FirstAccount!=NULL)
+ for (ActualAccount=(HPOP3ACCOUNT)POP3Plugin->FirstAccount;ActualAccount!=NULL;ActualAccount=(HPOP3ACCOUNT)ActualAccount->Next)
+ if (ActualAccount->Name!=NULL)
+ SendDlgItemMessageA(hDlg,IDC_COMBOACCOUNT,CB_ADDSTRING,0,(LPARAM)ActualAccount->Name);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:INITDIALOG:AccountBrowserSO-read done\n");
+ #endif
+ ReadDoneSO(POP3Plugin->AccountBrowserSO);
+ ActualAccount=NULL;
+
+
+ TranslateDialogDefault(hDlg);
+ SendMessage(GetParent(hDlg),PSM_UNCHANGED,(WPARAM)hDlg,0);
+ return TRUE;
+ }
+
+ case WM_SHOWWINDOW:
+ if ((BOOL)wParam==FALSE)
+ {
+ WindowList_Remove(pYAMNVar->MessageWnds,hDlg);
+ SendMessage(GetParent(hDlg),PSM_UNCHANGED,(WPARAM)hDlg,0);
+ }
+ else
+ {
+ WindowList_Add(pYAMNVar->MessageWnds,hDlg,NULL);
+
+ int index = SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_GETCURSEL,0,0);
+ HPOP3ACCOUNT temp = ActualAccount;
+ SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_RESETCONTENT,0,0);
+
+ if (POP3Plugin->FirstAccount!=NULL)
+ for (ActualAccount=(HPOP3ACCOUNT)POP3Plugin->FirstAccount;ActualAccount!=NULL;ActualAccount=(HPOP3ACCOUNT)ActualAccount->Next)
+ if (ActualAccount->Name!=NULL)
+ SendDlgItemMessageA(hDlg,IDC_COMBOACCOUNT,CB_ADDSTRING,0,(LPARAM)ActualAccount->Name);
+
+ ActualAccount = temp;
+
+ if (ActualAccount != NULL)
+ {
+ SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_SETCURSEL,(WPARAM)index,(LPARAM)ActualAccount->Name);
+ DlgShowAccount(hDlg,(WPARAM)M_SHOWACTUAL,(LPARAM)ActualAccount);
+ DlgShowAccountColors(hDlg,0,(LPARAM)ActualAccount);
+ DlgEnableAccountPopup(hDlg,(WPARAM)TRUE,(LPARAM)FALSE);
+ }
+ else
+ {
+ DlgShowAccountPopup(hDlg,(WPARAM)M_SHOWDEFAULT,0);
+ DlgEnableAccountPopup(hDlg,(WPARAM)FALSE,(LPARAM)FALSE);
+ }
+
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ {
+ WORD wNotifyCode = HIWORD(wParam);
+ switch(LOWORD(wParam))
+ {
+ LONG Result;
+ case IDC_COMBOACCOUNT:
+ switch(wNotifyCode)
+ {
+
+ case CBN_KILLFOCUS:
+ GetDlgItemTextA(hDlg,IDC_COMBOACCOUNT,DlgInput,sizeof(DlgInput));
+ if (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)DlgInput)))
+ {
+ DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0);
+ if (lstrlenA(DlgInput))
+ DlgEnableAccountPopup(hDlg,(WPARAM)TRUE,(LPARAM)TRUE);
+ else
+ DlgEnableAccountPopup(hDlg,(WPARAM)FALSE,(LPARAM)FALSE);
+ }
+ else
+ {
+ DlgShowAccount(hDlg,(WPARAM)M_SHOWACTUAL,(LPARAM)ActualAccount);
+ DlgShowAccountColors(hDlg,0,(LPARAM)ActualAccount);
+ DlgEnableAccountPopup(hDlg,(WPARAM)TRUE,(LPARAM)TRUE);
+ }
+ break;
+ case CBN_SELCHANGE:
+ if (CB_ERR!=(Result=SendDlgItemMessage(hDlg,IDC_COMBOACCOUNT,CB_GETCURSEL,0,0)))
+ SendDlgItemMessageA(hDlg,IDC_COMBOACCOUNT,CB_GETLBTEXT,(WPARAM)Result,(LPARAM)DlgInput);
+ if ((Result==CB_ERR) || (NULL==(ActualAccount=(HPOP3ACCOUNT)CallService(MS_YAMN_FINDACCOUNTBYNAME,(WPARAM)POP3Plugin,(LPARAM)DlgInput))))
+ {
+ DlgSetItemText(hDlg,(WPARAM)IDC_STTIMELEFT,0);
+ }
+ else
+ {
+ DlgShowAccount(hDlg,(WPARAM)M_SHOWACTUAL,(LPARAM)ActualAccount);
+ DlgShowAccountColors(hDlg,0,(LPARAM)ActualAccount);
+ DlgEnableAccountPopup(hDlg,(WPARAM)TRUE,(LPARAM)FALSE);
+ }
+ break;
+ }
+ break;
+ case IDC_COMBOCP:
+ {
+ int sel = SendDlgItemMessage(hDlg,IDC_COMBOCP,CB_GETCURSEL,0,0);
+ CPINFOEX info; GetCPInfoEx(CodePageNamesSupp[sel].CP,0,&info);
+ DlgSetItemTextT(hDlg, IDC_STSTATUS, info.CodePageName);
+ }
+ case IDC_RADIOPOPN:
+ case IDC_RADIOPOP1:
+ Changed=TRUE;
+ break;
+ case IDC_CPB:
+ case IDC_CPT:
+ case IDC_CPFB:
+ case IDC_CPFT:
+ case IDC_CPNB:
+ case IDC_CPNT:
+ if (HIWORD(wParam)!=CPN_COLOURCHANGED)
+ break;
+ case IDC_CHECKCOL:
+ case IDC_CHECKFCOL:
+ case IDC_CHECKNCOL:
+ EnableWindow(GetDlgItem(hDlg,IDC_CPB),(IsDlgButtonChecked(hDlg,IDC_CHECKCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPT),(IsDlgButtonChecked(hDlg,IDC_CHECKCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPNB),(IsDlgButtonChecked(hDlg,IDC_CHECKNCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPNT),(IsDlgButtonChecked(hDlg,IDC_CHECKNCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPFB),(IsDlgButtonChecked(hDlg,IDC_CHECKFCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED) && wParam);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPFT),(IsDlgButtonChecked(hDlg,IDC_CHECKFCOL)==BST_CHECKED) && (IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED) && wParam);
+ Changed=TRUE;
+ break;
+
+ case IDC_PREVIEW:
+ {
+ POPUPDATAT Tester;
+ POPUPDATAT TesterF;
+ POPUPDATAT TesterN;
+ BOOL TesterC = (IsDlgButtonChecked(hDlg,IDC_CHECKCOL)==BST_CHECKED);
+ BOOL TesterFC = (IsDlgButtonChecked(hDlg,IDC_CHECKFCOL)==BST_CHECKED);
+ BOOL TesterNC = (IsDlgButtonChecked(hDlg,IDC_CHECKNCOL)==BST_CHECKED);
+
+ ZeroMemory(&Tester,sizeof(Tester));
+ ZeroMemory(&TesterF,sizeof(TesterF));
+ ZeroMemory(&TesterF,sizeof(TesterN));
+ Tester.lchContact=NULL;
+ TesterF.lchContact=NULL;
+ TesterN.lchContact=NULL;
+ Tester.lchIcon=g_LoadIconEx(2);
+ TesterF.lchIcon=g_LoadIconEx(3);
+ TesterN.lchIcon=g_LoadIconEx(1);
+
+ lstrcpyn(Tester.lptzContactName,TranslateT("Account Test"),MAX_CONTACTNAME);
+ lstrcpyn(TesterF.lptzContactName,TranslateT("Account Test (failed)"),MAX_CONTACTNAME);
+ lstrcpyn(TesterN.lptzContactName,TranslateT("Account Test"),MAX_CONTACTNAME);
+ lstrcpyn(Tester.lptzText,TranslateT("You have N new mail messages"),MAX_SECONDLINE);
+ lstrcpyn(TesterF.lptzText,TranslateT("Connection failed message"),MAX_SECONDLINE);
+ lstrcpyn(TesterN.lptzText,TranslateT("No new mail message"),MAX_SECONDLINE);
+ if (TesterC)
+ {
+ Tester.colorBack=SendDlgItemMessage(hDlg,IDC_CPB,CPM_GETCOLOUR,0,0);
+ Tester.colorText=SendDlgItemMessage(hDlg,IDC_CPT,CPM_GETCOLOUR,0,0);
+ }
+ else
+ {
+ Tester.colorBack=GetSysColor(COLOR_BTNFACE);
+ Tester.colorText=GetSysColor(COLOR_WINDOWTEXT);
+ }
+ if (TesterFC)
+ {
+ TesterF.colorBack=SendDlgItemMessage(hDlg,IDC_CPFB,CPM_GETCOLOUR,0,0);
+ TesterF.colorText=SendDlgItemMessage(hDlg,IDC_CPFT,CPM_GETCOLOUR,0,0);
+ }
+ else
+ {
+ TesterF.colorBack=GetSysColor(COLOR_BTNFACE);
+ TesterF.colorText=GetSysColor(COLOR_WINDOWTEXT);
+ }
+ if (TesterNC)
+ {
+ TesterN.colorBack=SendDlgItemMessage(hDlg,IDC_CPNB,CPM_GETCOLOUR,0,0);
+ TesterN.colorText=SendDlgItemMessage(hDlg,IDC_CPNT,CPM_GETCOLOUR,0,0);
+ }
+ else
+ {
+ TesterN.colorBack=GetSysColor(COLOR_BTNFACE);
+ TesterN.colorText=GetSysColor(COLOR_WINDOWTEXT);
+ }
+ Tester.PluginWindowProc=NULL;
+ TesterF.PluginWindowProc=NULL;
+ TesterN.PluginWindowProc=NULL;
+ Tester.PluginData=NULL;
+ TesterF.PluginData=NULL;
+ TesterN.PluginData=NULL;
+
+ if (IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED)
+ PUAddPopUpT(&Tester);
+ if (IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED)
+ PUAddPopUpT(&TesterF);
+ if (IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED)
+ PUAddPopUpT(&TesterN);
+ Changed=TRUE;
+ }
+ break;
+ case IDC_CHECKKBN:
+ Changed=TRUE;
+ break;
+ case IDC_CHECKPOP:
+ Changed=TRUE;
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKCOL),IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPB),(IsDlgButtonChecked(hDlg,IDC_CHECKCOL)==BST_CHECKED) && IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPT),(IsDlgButtonChecked(hDlg,IDC_CHECKCOL)==BST_CHECKED) && IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_RADIOPOPN),(IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED));
+ EnableWindow(GetDlgItem(hDlg,IDC_RADIOPOP1),(IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED));
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITPOPS),(IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED));
+ break;
+ case IDC_CHECKFPOP:
+ Changed=TRUE;
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKFCOL),IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPFB),(IsDlgButtonChecked(hDlg,IDC_CHECKFCOL)==BST_CHECKED) && IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPFT),(IsDlgButtonChecked(hDlg,IDC_CHECKFCOL)==BST_CHECKED) && IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITFPOPS),(IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED));
+ break;
+ case IDC_CHECKNPOP:
+ Changed=TRUE;
+ EnableWindow(GetDlgItem(hDlg,IDC_CHECKNCOL),IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPNB),(IsDlgButtonChecked(hDlg,IDC_CHECKNCOL)==BST_CHECKED) && IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_CPNT),(IsDlgButtonChecked(hDlg,IDC_CHECKNCOL)==BST_CHECKED) && IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED);
+ EnableWindow(GetDlgItem(hDlg,IDC_EDITNPOPS),(IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED));
+ break;
+
+ }
+ if (HIWORD(wParam)==EN_CHANGE)
+ Changed=TRUE;
+ break;
+ }
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom)
+ {
+ case 0:
+ switch(((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ TCHAR Text[MAX_PATH];
+ BOOL Translated,NewAcc=FALSE,CheckPopup,CheckPopupW;
+ BOOL CheckNPopup,CheckNPopupW,CheckFPopup,CheckFPopupW;
+ BOOL CheckPopN;
+ UINT Time,TimeN,TimeF;
+
+ if (GetDlgItemText(hDlg,IDC_COMBOACCOUNT,Text,sizeof(Text)/sizeof(TCHAR)))
+ {
+ CheckPopup = (IsDlgButtonChecked(hDlg,IDC_CHECKPOP)==BST_CHECKED);
+ CheckPopupW = (IsDlgButtonChecked(hDlg,IDC_CHECKCOL)==BST_CHECKED);
+
+ CheckFPopup = (IsDlgButtonChecked(hDlg,IDC_CHECKFPOP)==BST_CHECKED);
+ CheckFPopupW = (IsDlgButtonChecked(hDlg,IDC_CHECKFCOL)==BST_CHECKED);
+
+ CheckNPopup = (IsDlgButtonChecked(hDlg,IDC_CHECKNPOP)==BST_CHECKED);
+ CheckNPopupW = (IsDlgButtonChecked(hDlg,IDC_CHECKNCOL)==BST_CHECKED);
+
+ CheckPopN = (IsDlgButtonChecked(hDlg,IDC_RADIOPOPN)==BST_CHECKED);
+
+
+ Time=GetDlgItemInt(hDlg,IDC_EDITPOPS,&Translated,FALSE);
+ if (!Translated)
+ {
+ MessageBox(hDlg,TranslateT("This is not a valid number value"),TranslateT("Input error"),MB_OK);
+ SetFocus(GetDlgItem(hDlg,IDC_EDITPOPS));
+ break;
+ }
+ TimeN=GetDlgItemInt(hDlg,IDC_EDITNPOPS,&Translated,FALSE);
+ if (!Translated)
+ {
+ MessageBox(hDlg,TranslateT("This is not a valid number value"),TranslateT("Input error"),MB_OK);
+ SetFocus(GetDlgItem(hDlg,IDC_EDITNPOPS));
+ break;
+ }
+ TimeF=GetDlgItemInt(hDlg,IDC_EDITFPOPS,&Translated,FALSE);
+ if (!Translated)
+ {
+ MessageBox(hDlg,TranslateT("This is not a valid number value"),TranslateT("Input error"),MB_OK);
+ SetFocus(GetDlgItem(hDlg,IDC_EDITFPOPS));
+ break;
+ }
+
+
+ DlgSetItemTextT(hDlg, IDC_STTIMELEFT, TranslateT("Please wait while no account is in use."));
+
+ ActualAccount->Flags=
+ (ActualAccount->Flags & YAMN_ACC_ENA) |
+ (ActualAccount->Flags & YAMN_ACC_SSL23) |
+ (ActualAccount->Flags & YAMN_ACC_NOTLS) |
+ (ActualAccount->Flags & YAMN_ACC_APOP) |
+ (ActualAccount->Flags & YAMN_ACC_BODY) |
+ (CheckPopN ? YAMN_ACC_POPN : 0);
+
+ ActualAccount->NewMailN.Flags=
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_SND) |
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_MSG) |
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_ICO) |
+ (CheckPopup ? YAMN_ACC_POP : 0) |
+ (CheckPopupW ? YAMN_ACC_POPC : 0) |
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_APP) |
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_KBN) |
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_CONT) |
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_CONTNICK) |
+ (ActualAccount->NewMailN.Flags & YAMN_ACC_CONTNOEVENT) |
+ YAMN_ACC_MSGP;
+
+ ActualAccount->NoNewMailN.Flags=
+ (CheckNPopup ? YAMN_ACC_POP : 0) |
+ (CheckNPopupW ? YAMN_ACC_POPC : 0) |
+ (ActualAccount->NoNewMailN.Flags & YAMN_ACC_MSGP);
+
+ ActualAccount->BadConnectN.Flags=
+ (ActualAccount->BadConnectN.Flags & YAMN_ACC_SND) |
+ (ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG) |
+ (ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO) |
+ (CheckFPopup ? YAMN_ACC_POP : 0) |
+ (CheckFPopupW ? YAMN_ACC_POPC : 0);
+
+ ActualAccount->NewMailN.PopUpB=SendDlgItemMessage(hDlg,IDC_CPB,CPM_GETCOLOUR,0,0);
+ ActualAccount->NewMailN.PopUpT=SendDlgItemMessage(hDlg,IDC_CPT,CPM_GETCOLOUR,0,0);
+ ActualAccount->NewMailN.PopUpTime=Time;
+
+ ActualAccount->NoNewMailN.PopUpB=SendDlgItemMessage(hDlg,IDC_CPNB,CPM_GETCOLOUR,0,0);
+ ActualAccount->NoNewMailN.PopUpT=SendDlgItemMessage(hDlg,IDC_CPNT,CPM_GETCOLOUR,0,0);
+ ActualAccount->NoNewMailN.PopUpTime=TimeN;
+
+ ActualAccount->BadConnectN.PopUpB=SendDlgItemMessage(hDlg,IDC_CPFB,CPM_GETCOLOUR,0,0);
+ ActualAccount->BadConnectN.PopUpT=SendDlgItemMessage(hDlg,IDC_CPFT,CPM_GETCOLOUR,0,0);
+ ActualAccount->BadConnectN.PopUpTime=TimeF;
+
+
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:ActualAccountSO-write done\n");
+ #endif
+ WriteDone(ActualAccount);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Options:APPLY:AccountBrowserSO-write done\n");
+ #endif
+ WriteDoneSO(POP3Plugin->AccountBrowserSO);
+
+// if (0==WritePOP3Accounts())
+// Beep(500,100);
+ WritePOP3Accounts();
+ RefreshContact();
+ return TRUE;
+ }
+ }
+ break;
+ }
+ break;
+ }
+ break;
+ }
+ if (Changed)
+ SendMessage(GetParent(hDlg),PSM_CHANGED,0,0);
+ return FALSE;
+}
+
diff --git a/plugins/YAMN/src/proto/pop3/pop3opt.h b/plugins/YAMN/src/proto/pop3/pop3opt.h new file mode 100644 index 0000000000..6a678284fa --- /dev/null +++ b/plugins/YAMN/src/proto/pop3/pop3opt.h @@ -0,0 +1,40 @@ +#ifndef __OPTIONS_H
+#define __OPTIONS_H
+
+#define M_SHOWACTUAL 0
+#define M_SHOWDEFAULT 1
+
+
+//Enables account in options
+BOOL DlgEnableAccount(HWND hDlg,WPARAM wParam,LPARAM lParam);
+
+//Sets dialog controls to match current account
+BOOL DlgShowAccount(HWND hDlg,WPARAM wParam,LPARAM lParam);
+
+//Sets colors to match colors of actual account
+BOOL DlgShowAccountColors(HWND hDlg,WPARAM wParam,LPARAM lParam);
+
+//Options dialog procedure
+INT_PTR CALLBACK DlgProcPOP3AccOpt(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+//Options dialog procedure
+INT_PTR CALLBACK DlgProcPOP3AccStatusOpt(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+//Options dialog procedure
+INT_PTR CALLBACK DlgProcYAMNOpt(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+//Options dialog procedure
+INT_PTR CALLBACK DlgProcPOP3AccPopup(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+//Initializes POP3 options for Miranda
+int POP3OptInit(WPARAM wParam,LPARAM lParam);
+
+//Sets dialog item text
+BOOL DlgSetItemText(HWND hDlg,WPARAM wParam,const char*);
+BOOL DlgSetItemTextW(HWND hDlg,WPARAM wParam,const WCHAR*);
+
+
+#define DlgSetItemTextT DlgSetItemTextW
+
+
+#endif
diff --git a/plugins/YAMN/src/protoplugin.cpp b/plugins/YAMN/src/protoplugin.cpp new file mode 100644 index 0000000000..479b54ce67 --- /dev/null +++ b/plugins/YAMN/src/protoplugin.cpp @@ -0,0 +1,197 @@ +/*
+ * YAMN plugin export functions for protocols
+ *
+ * (c) majvan 2002-2004
+ */
+
+#include "yamn.h"
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+PYAMN_PROTOPLUGINQUEUE FirstProtoPlugin=NULL;
+
+INT_PTR RegisterProtocolPluginSvc(WPARAM,LPARAM);
+
+//Removes plugin from queue and deletes registration structures
+INT_PTR UnregisterProtocolPlugin(HYAMNPROTOPLUGIN Plugin);
+
+INT_PTR UnregisterProtocolPluginSvc(WPARAM,LPARAM);
+
+//Removes plugins from queue and deletes registration structures
+INT_PTR UnregisterProtoPlugins();
+
+//Sets imported functions for an plugin and therefore it starts plugin to be registered and running
+// Plugin- plugin, which wants to set its functions
+// YAMNFcn- pointer to imported functions with accounts
+// YAMNFcnVer- version of YAMN_PROTOIMPORTFCN, use YAMN_PROTOIMPORTFCNVERSION
+// YAMNMailFcn- pointer to imported functions with mails
+// YAMNMailFcnVer- version of YAMN_MAILIMPORTFCN, use YAMN_MAILIMPORTFCNVERSION
+// returns nonzero if success
+int WINAPI SetProtocolPluginFcnImportFcn(HYAMNPROTOPLUGIN Plugin,PYAMN_PROTOIMPORTFCN YAMNFcn,DWORD YAMNFcnVer,PYAMN_MAILIMPORTFCN YAMNMailFcn,DWORD YAMNMailFcnVer);
+
+struct CExportedFunctions ProtoPluginExportedFcn[]=
+{
+ {YAMN_SETPROTOCOLPLUGINFCNIMPORTID,(void *)SetProtocolPluginFcnImportFcn},
+};
+
+struct CExportedServices ProtoPluginExportedSvc[]=
+{
+ {MS_YAMN_REGISTERPROTOPLUGIN,RegisterProtocolPluginSvc},
+ {MS_YAMN_UNREGISTERPROTOPLUGIN,UnregisterProtocolPluginSvc},
+ {MS_YAMN_GETFILENAME,GetFileNameSvc},
+ {MS_YAMN_DELETEFILENAME,DeleteFileNameSvc},
+};
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+INT_PTR RegisterProtocolPluginSvc(WPARAM wParam,LPARAM lParam)
+{
+ PYAMN_PROTOREGISTRATION Registration=(PYAMN_PROTOREGISTRATION)wParam;
+ HYAMNPROTOPLUGIN Plugin;
+
+ if (lParam!=YAMN_PROTOREGISTRATIONVERSION)
+ return 0;
+ if ((Registration->Name==NULL) || (Registration->Ver==NULL))
+ return (INT_PTR)NULL;
+ if (NULL==(Plugin=new YAMN_PROTOPLUGIN))
+ return (INT_PTR)NULL;
+
+ Plugin->PluginInfo=Registration;
+
+ Plugin->FirstAccount=NULL;
+
+ Plugin->AccountBrowserSO=new SWMRG;
+ SWMRGInitialize(Plugin->AccountBrowserSO,NULL);
+
+ Plugin->Fcn=NULL;
+ Plugin->MailFcn=NULL;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"::: YAMN- new protocol registered: %0x (%s) :::\n",Plugin,Registration->Name);
+#endif
+ return (INT_PTR)Plugin;
+}
+
+int WINAPI SetProtocolPluginFcnImportFcn(HYAMNPROTOPLUGIN Plugin,PYAMN_PROTOIMPORTFCN YAMNFcn,DWORD YAMNFcnVer,PYAMN_MAILIMPORTFCN YAMNMailFcn,DWORD YAMNMailFcnVer)
+{
+ PYAMN_PROTOPLUGINQUEUE Parser;
+
+ if (YAMNFcnVer!=YAMN_PROTOIMPORTFCNVERSION)
+ return 0;
+ if (YAMNMailFcnVer!=YAMN_MAILIMPORTFCNVERSION)
+ return 0;
+ if (YAMNFcn==NULL)
+ return 0;
+ if (YAMNMailFcn==NULL)
+ return 0;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"::: YAMN- protocol %0x import succeed :::\n",Plugin);
+#endif
+ Plugin->Fcn=YAMNFcn;
+ Plugin->MailFcn=YAMNMailFcn;
+
+ EnterCriticalSection(&PluginRegCS);
+//We add protocol to the protocol list
+ for (Parser=FirstProtoPlugin;Parser!=NULL && Parser->Next!=NULL;Parser=Parser->Next);
+ if (Parser==NULL)
+ {
+ FirstProtoPlugin=new YAMN_PROTOPLUGINQUEUE;
+ Parser=FirstProtoPlugin;
+ }
+ else
+ {
+ Parser->Next=new YAMN_PROTOPLUGINQUEUE;
+ Parser=Parser->Next;
+ }
+
+ Parser->Plugin=Plugin;
+ Parser->Next=NULL;
+
+ LeaveCriticalSection(&PluginRegCS);
+ return 1;
+}
+
+INT_PTR UnregisterProtocolPlugin(HYAMNPROTOPLUGIN Plugin)
+{
+ PYAMN_PROTOPLUGINQUEUE Parser,Found;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"Entering UnregisterProtocolPlugin\n");
+#endif
+ if (FirstProtoPlugin->Plugin==Plugin)
+ {
+ Found=FirstProtoPlugin;
+ FirstProtoPlugin=FirstProtoPlugin->Next;
+ }
+ else
+ {
+ for (Parser=FirstProtoPlugin;(Parser->Next!=NULL) && (Plugin!=Parser->Next->Plugin);Parser=Parser->Next);
+ if (Parser->Next!=NULL)
+ {
+ Found=Parser->Next;
+ Parser->Next=Parser->Next->Next;
+ }
+ else
+ Found=NULL;
+ }
+ if (Found!=NULL)
+ {
+ StopAccounts(Plugin);
+ DeleteAccounts(Plugin);
+ if (Plugin->Fcn->UnLoadFcn!=NULL)
+ Plugin->Fcn->UnLoadFcn((void *)0);
+
+ delete Found->Plugin->AccountBrowserSO;
+ delete Found->Plugin;
+ delete Found;
+
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"::: YAMN- protocol %0x unregistered :::\n",Plugin);
+#endif
+ }
+ else
+ return 0;
+ return 1;
+}
+
+INT_PTR UnregisterProtocolPluginSvc(WPARAM wParam,LPARAM lParam)
+{
+ HYAMNPROTOPLUGIN Plugin=(HYAMNPROTOPLUGIN)wParam;
+
+ EnterCriticalSection(&PluginRegCS);
+ UnregisterProtocolPlugin(Plugin);
+ LeaveCriticalSection(&PluginRegCS);
+ return 1;
+
+}
+
+INT_PTR UnregisterProtoPlugins()
+{
+ EnterCriticalSection(&PluginRegCS);
+//We remove protocols from the protocol list
+ while(FirstProtoPlugin!=NULL)
+ UnregisterProtocolPlugin(FirstProtoPlugin->Plugin);
+ LeaveCriticalSection(&PluginRegCS);
+ return 1;
+}
+
+INT_PTR GetFileNameSvc(WPARAM wParam,LPARAM)
+{
+ TCHAR *FileName = new TCHAR[MAX_PATH];
+ if (FileName == NULL)
+ return NULL;
+
+ mir_sntprintf(FileName, MAX_PATH, _T("%s\\yamn-accounts.%s.%s.book"), UserDirectory, wParam, ProfileName);
+ return (INT_PTR)FileName;
+}
+
+INT_PTR DeleteFileNameSvc(WPARAM wParam,LPARAM)
+{
+ if (( TCHAR* )wParam != NULL)
+ delete[] ( TCHAR* ) wParam;
+
+ return 0;
+}
diff --git a/plugins/YAMN/src/resource.h b/plugins/YAMN/src/resource.h new file mode 100644 index 0000000000..62720a471e --- /dev/null +++ b/plugins/YAMN/src/resource.h @@ -0,0 +1,128 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by YAMN.rc
+//
+#define IDI_CHECKMAIL 104
+#define IDI_LAUNCHAPP 105
+#define IDD_DLGVIEWMESSAGES 107
+#define IDD_DLGSHOWMESSAGE 108
+#define IDI_ICOYAMN2 112
+#define IDI_ICOYAMN1 113
+#define IDD_DLGBADCONNECT 115
+#define IDD_POP3ACCOUNTOPT 121
+#define IDD_YAMNOPT 126
+#define IDI_BADCONNECT 131
+#define IDI_ICOTTBUP 138
+#define IDD_PLUGINOPT 141
+#define IDI_NEWMAIL 159
+#define IDD_CHOOSESTATUSMODES 310
+#define IDD_OPTIONS 311
+#define IDD_POP3ACCOUNTPOPUP 312
+#define IDC_EDITSERVER 1000
+#define IDC_EDITPORT 1001
+#define IDC_EDITLOGIN 1002
+#define IDC_EDITPASS 1003
+#define IDC_COMBOACCOUNT 1005
+#define IDC_BTNDEFAULT 1006
+#define IDC_EDITINTERVAL 1007
+#define IDC_CHECKSND 1008
+#define IDC_CHECKMSG 1009
+#define IDC_CHECKAPP 1010
+#define IDC_BTNAPP 1011
+#define IDC_CHECKICO 1012
+#define IDC_CHECK 1013
+#define IDC_BTNDEL 1014
+#define IDC_STSERVER 1015
+#define IDC_CHECKFSND 1016
+#define IDC_CHECKFMSG 1017
+#define IDC_CHECKFICO 1018
+#define IDC_CHECKST0 1019
+#define IDC_CHECKST1 1020
+#define IDC_CHECKST2 1021
+#define IDC_CHECKST3 1022
+#define IDC_CHECKST4 1023
+#define IDC_CHECKST5 1024
+#define IDC_CHECKST6 1025
+#define IDC_CHECKST7 1026
+#define IDC_EDITAPP 1027
+#define IDC_CHECKST8 1028
+#define IDC_CHECKST9 1029
+#define IDC_CHECKCONTACT 1030
+#define IDC_CHECKCONTACTNICK 1031
+#define IDC_CHECKCONTACTNOEVENT 1032
+#define IDC_STTIMELEFT 1033
+#define IDC_LISTMAILS 1038
+#define IDC_LISTHEADERS 1039
+#define IDC_EDITAPPPARAM 1044
+#define IDC_BTNOK 1047
+#define IDC_COMBOCP 1050
+#define IDC_STCP 1055
+#define IDC_STATICMSG 1055
+#define IDC_STPORT 1056
+#define IDC_STLOGIN 1057
+#define IDC_STPASS 1058
+#define IDC_STINTERVAL 1059
+#define IDC_AUTOBODY 1062
+#define IDC_BTNRESET 1063
+#define IDC_CHECKSTART 1064
+#define IDC_STWCHECK 1065
+#define IDC_CHECKFORCE 1066
+#define IDC_RADIOPOP1 1068
+#define IDC_RADIOPOPN 1069
+#define IDC_CPB 1070
+#define IDC_CPNB 1071
+#define IDC_CHECKCOL 1073
+#define IDC_CPT 1074
+#define IDC_CPFB 1075
+#define IDC_CPFT 1076
+#define IDC_CHECKFCOL 1077
+#define IDC_CHECKNCOL 1078
+#define IDC_CPNT 1079
+#define IDC_CHECKPOP 1087
+#define IDC_CHECKNPOP 1088
+#define IDC_CHECKFPOP 1089
+#define IDC_EDITPOPS 1090
+#define IDC_EDITNPOPS 1091
+#define IDC_EDITFPOPS 1092
+#define IDC_GBNEWMAIL 1094
+#define IDC_GBNONEWMAIL 1095
+#define IDC_GBBADCONNECT 1096
+#define IDC_STSTATUS 1102
+#define IDC_COMBOPLUGINS 1104
+#define IDC_STWWW 1111
+#define IDC_STMAIL 1113
+#define IDC_STCOPY 1114
+#define IDC_STDESC 1115
+#define IDC_STVER 1116
+#define IDC_CHECKTTB 1117
+#define IDC_CHECKSSL 1117
+#define IDC_CHECKNMSGP 1118
+#define IDC_CHECKNOTLS 1120
+#define IDC_CHECKKBN 1121
+#define IDC_BTNSTATUS 1123
+#define IDC_OPTIONSTAB 1124
+#define IDC_BTNCHECKALL 1125
+#define IDC_MAINMENU 1126
+#define IDC_CLOSEONDELETE 1127
+#define IDC_LONGDATE 1128
+#define IDC_SMARTDATE 1129
+#define IDC_NOSECONDS 1130
+#define IDC_YAMNASPROTO 1131
+#define IDC_CHECKAPOP 1200
+#define IDC_STATUSGROUP 1338
+#define IDC_SPLITTER 1400
+#define IDC_EDITBODY 1401
+#define IDC_PREVIEW 1402
+#define IDC_BTNADD 1403
+#define IDC_EDITNAME 1404
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 143
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1407
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/YAMN/src/services.cpp b/plugins/YAMN/src/services.cpp new file mode 100644 index 0000000000..7254a02428 --- /dev/null +++ b/plugins/YAMN/src/services.cpp @@ -0,0 +1,495 @@ +
+#include "yamn.h"
+#include "main.h"
+
+extern HANDLE hMenuItemMain, hMenuItemCont, hMenuItemContApp;
+
+static INT_PTR Service_GetCaps(WPARAM wParam, LPARAM lParam)
+{
+ if (wParam == PFLAGNUM_4)
+ return PF4_NOCUSTOMAUTH;
+ if (wParam == PFLAG_UNIQUEIDTEXT)
+ return (INT_PTR) Translate("Nick");
+ if (wParam == PFLAG_MAXLENOFMESSAGE)
+ return 400;
+ if (wParam == PFLAG_UNIQUEIDSETTING)
+ return (INT_PTR) "Id";
+ if (wParam == PFLAGNUM_2)
+ return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND;
+ if (wParam == PFLAGNUM_5) {
+ if (DBGetContactSettingByte(NULL, YAMN_DBMODULE, YAMN_SHOWASPROTO, 1))
+ return PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND;
+ return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND;
+ }
+ return 0;
+}
+
+static INT_PTR Service_GetStatus(WPARAM wParam, LPARAM lParam)
+{
+ return YAMN_STATUS;
+}
+
+static INT_PTR Service_SetStatus(WPARAM wParam, LPARAM lParam)
+{
+ int newstatus = (wParam != ID_STATUS_OFFLINE)?ID_STATUS_ONLINE:ID_STATUS_OFFLINE;
+ if (newstatus != YAMN_STATUS){
+ int oldstatus = YAMN_STATUS;
+ YAMN_STATUS = newstatus;
+ ProtoBroadcastAck(YAMN_DBMODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldstatus, newstatus);
+ }
+ return 0;
+
+}
+
+static INT_PTR Service_GetName(WPARAM wParam, LPARAM lParam)
+{
+ lstrcpynA((char *) lParam, YAMN_DBMODULE, wParam);;
+ return 0;
+}
+
+static INT_PTR Service_LoadIcon(WPARAM wParam, LPARAM lParam)
+{
+ if ( LOWORD( wParam ) == PLI_PROTOCOL )
+ return (INT_PTR)CopyIcon(g_LoadIconEx(0)); // noone cares about other than PLI_PROTOCOL
+
+ return (INT_PTR)(HICON)NULL;
+}
+
+INT_PTR ClistContactDoubleclicked(WPARAM wParam, LPARAM lParam)
+{
+ ContactDoubleclicked(((CLISTEVENT*)lParam)->lParam, lParam);
+ return 0;
+}
+
+static int Service_ContactDoubleclicked(WPARAM wParam, LPARAM lParam)
+{
+ ContactDoubleclicked(wParam, lParam);
+ return 0;
+}
+
+static INT_PTR ContactApplication(WPARAM wParam, LPARAM lParam)
+{
+ char *szProto = GetContactProto((HANDLE)wParam);
+ if ( lstrcmpA(szProto, YAMN_DBMODULE))
+ return 0;
+
+ DBVARIANT dbv;
+ if ( DBGetContactSetting((HANDLE) wParam, YAMN_DBMODULE, "Id", &dbv))
+ return 0;
+
+ HACCOUNT ActualAccount = (HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal);
+ if (ActualAccount != NULL) {
+ STARTUPINFOW si = { 0 };
+ si.cb = sizeof(si);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ContactApplication:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ContactApplication:ualAccountSO-read enter\n");
+ #endif
+ if (ActualAccount->NewMailN.App != NULL) {
+ WCHAR *Command;
+ if (ActualAccount->NewMailN.AppParam != NULL)
+ Command = new WCHAR[wcslen(ActualAccount->NewMailN.App)+wcslen(ActualAccount->NewMailN.AppParam)+6];
+ else
+ Command = new WCHAR[wcslen(ActualAccount->NewMailN.App)+6];
+
+ if (Command != NULL) {
+ lstrcpyW(Command, L"\"");
+ lstrcatW(Command, ActualAccount->NewMailN.App);
+ lstrcatW(Command, L"\" ");
+ if (ActualAccount->NewMailN.AppParam != NULL)
+ lstrcatW(Command, ActualAccount->NewMailN.AppParam);
+
+ PROCESS_INFORMATION pi;
+ CreateProcessW(NULL, Command, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
+ delete[] Command;
+ }
+ }
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ContactApplication:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+ #ifdef DEBUG_SYNCHRO
+ else
+ DebugLog(SynchroFile, "ContactApplication:ActualAccountSO-read enter failed\n");
+ #endif
+ }
+ DBFreeVariant(&dbv);
+ return 0;
+}
+
+DWORD WINAPI SWMRGWaitToRead(PSWMRG pSWMRG, DWORD dwTimeout);
+static INT_PTR AccountMailCheck(WPARAM wParam, LPARAM lParam){
+ //This service will check/sincronize the account pointed by wParam
+ HACCOUNT ActualAccount = (HACCOUNT)wParam;
+ HANDLE ThreadRunningEV;
+ DWORD tid;
+ // copy/paste make mistakes
+ if (ActualAccount != NULL) {
+ //we use event to signal, that running thread has all needed stack parameters copied
+ if (NULL == (ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL)))
+ return 0;
+ //if we want to close miranda, we get event and do not run pop3 checking anymore
+ if (WAIT_OBJECT_0 == WaitForSingleObject(ExitEV, 0))
+ return 0;
+
+ EnterCriticalSection(&PluginRegCS);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "AccountCheck:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0 != SWMRGWaitToRead(ActualAccount->AccountAccessSO, 0)) {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read wait failed\n");
+ #endif
+ }
+ else {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read enter\n");
+ #endif
+ if ((ActualAccount->Flags & YAMN_ACC_ENA) && ActualAccount->Plugin->Fcn->SynchroFcnPtr) {
+ struct CheckParam ParamToPlugin = {YAMN_CHECKVERSION, ThreadRunningEV, ActualAccount, lParam?YAMN_FORCECHECK:YAMN_NORMALCHECK, (void *)0, NULL};
+ HANDLE NewThread;
+
+ ActualAccount->TimeLeft = ActualAccount->Interval;
+ if (NewThread = CreateThread(NULL, 0, (YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->SynchroFcnPtr, &ParamToPlugin, 0, &tid)) {
+ WaitForSingleObject(ThreadRunningEV, INFINITE);
+ CloseHandle(NewThread);
+ }
+ }
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+ LeaveCriticalSection(&PluginRegCS);
+ CloseHandle(ThreadRunningEV);
+ }
+ return 0;
+}
+
+static INT_PTR ContactMailCheck(WPARAM wParam, LPARAM lParam)
+{
+ char *szProto = GetContactProto((HANDLE)wParam);
+ if ( lstrcmpA(szProto, YAMN_DBMODULE))
+ return 0;
+
+ DBVARIANT dbv;
+ if ( DBGetContactSetting((HANDLE) wParam, YAMN_DBMODULE, "Id", &dbv))
+ return 0;
+
+ HACCOUNT ActualAccount = (HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal);
+ if (ActualAccount != NULL) {
+ //we use event to signal, that running thread has all needed stack parameters copied
+ HANDLE ThreadRunningEV;
+ if (NULL == (ThreadRunningEV = CreateEvent(NULL, FALSE, FALSE, NULL)))
+ return 0;
+ //if we want to close miranda, we get event and do not run pop3 checking anymore
+ if (WAIT_OBJECT_0 == WaitForSingleObject(ExitEV, 0))
+ return 0;
+ EnterCriticalSection(&PluginRegCS);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read wait failed\n");
+ #endif
+ }
+ else
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read enter\n");
+ #endif
+ if ((ActualAccount->Flags & YAMN_ACC_ENA) && (ActualAccount->StatusFlags & YAMN_ACC_FORCE)) //account cannot be forced to check
+ {
+ if (ActualAccount->Plugin->Fcn->ForceCheckFcnPtr == NULL)
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+
+ DWORD tid;
+ struct CheckParam ParamToPlugin = {YAMN_CHECKVERSION, ThreadRunningEV, ActualAccount, YAMN_FORCECHECK, (void *)0, NULL};
+ if (NULL == CreateThread(NULL, 0, (YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->ForceCheckFcnPtr, &ParamToPlugin, 0, &tid))
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ else
+ WaitForSingleObject(ThreadRunningEV, INFINITE);
+ }
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+ LeaveCriticalSection(&PluginRegCS);
+ CloseHandle(ThreadRunningEV);
+ }
+ DBFreeVariant(&dbv);
+ return 0;
+}
+
+void MainMenuAccountClicked(WPARAM wParam, LPARAM lParam)
+{
+}
+
+/*static*/ void ContactDoubleclicked(WPARAM wParam, LPARAM lParam)
+{
+ char *szProto = GetContactProto((HANDLE)wParam);
+ if ( lstrcmpA(szProto, YAMN_DBMODULE))
+ return;
+
+ DBVARIANT dbv;
+ if ( DBGetContactSetting(( HANDLE )wParam, YAMN_DBMODULE, "Id", &dbv))
+ return;
+
+ HACCOUNT ActualAccount = (HACCOUNT) CallService(MS_YAMN_FINDACCOUNTBYNAME, (WPARAM)POP3Plugin, (LPARAM)dbv.pszVal);
+ if (ActualAccount != NULL) {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "Service_ContactDoubleclicked:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0 == WaitToReadFcn(ActualAccount->AccountAccessSO)) {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "Service_ContactDoubleclicked:ActualAccountSO-read enter\n");
+ #endif
+ YAMN_MAILBROWSERPARAM Param = {(HANDLE)0, ActualAccount, ActualAccount->NewMailN.Flags, ActualAccount->NoNewMailN.Flags, 0};
+
+ Param.nnflags = Param.nnflags | YAMN_ACC_MSG; //show mails in account even no new mail in account
+ Param.nnflags = Param.nnflags & ~YAMN_ACC_POP;
+
+ Param.nflags = Param.nflags | YAMN_ACC_MSG; //show mails in account even no new mail in account
+ Param.nflags = Param.nflags & ~YAMN_ACC_POP;
+
+ RunMailBrowserSvc((WPARAM)&Param, (LPARAM)YAMN_MAILBROWSERVERSION);
+
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "Service_ContactDoubleclicked:ActualAccountSO-read done\n");
+ #endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+ #ifdef DEBUG_SYNCHRO
+ else
+ DebugLog(SynchroFile, "Service_ContactDoubleclicked:ActualAccountSO-read enter failed\n");
+ #endif
+
+ }
+ DBFreeVariant(&dbv);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+HBITMAP LoadBmpFromIcon(HICON hIcon)
+{
+ int IconSizeX = 16;
+ int IconSizeY = 16;
+
+ HBRUSH hBkgBrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
+
+ BITMAPINFOHEADER bih = {0};
+ bih.biSize = sizeof(bih);
+ bih.biBitCount = 24;
+ bih.biPlanes = 1;
+ bih.biCompression = BI_RGB;
+ bih.biHeight = IconSizeY;
+ bih.biWidth = IconSizeX;
+
+ int widthBytes = ((bih.biWidth*bih.biBitCount + 31) >> 5) * 4;
+
+ RECT rc;
+ rc.top = rc.left = 0;
+ rc.right = bih.biWidth;
+ rc.bottom = bih.biHeight;
+
+ HDC hdc = GetDC(NULL);
+ HBITMAP hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight);
+ HDC hdcMem = CreateCompatibleDC(hdc);
+ HBITMAP hoBmp = (HBITMAP)SelectObject(hdcMem, hBmp);
+ FillRect(hdcMem, &rc, hBkgBrush);
+ DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, NULL, DI_NORMAL);
+ SelectObject(hdcMem, hoBmp);
+ return hBmp;
+}
+
+int AddTopToolbarIcon(WPARAM,LPARAM)
+{
+ if ( DBGetContactSettingByte(NULL, YAMN_DBMODULE, YAMN_TTBFCHECK, 1)) {
+ if ( ServiceExists(MS_TTB_REMOVEBUTTON) && hTTButton == NULL) {
+ TTBButton btn = {0};
+ btn.cbSize = sizeof(btn);
+ btn.pszService = MS_YAMN_FORCECHECK;
+ btn.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
+ btn.hIconHandleUp = btn.hIconHandleDn = g_GetIconHandle(0);
+ btn.name = btn.pszTooltipUp = LPGEN("Check mail");
+ hTTButton = TopToolbar_AddButton(&btn);
+ }
+ }
+ else {
+ if (hTTButton != NULL) {
+ CallService(MS_TTB_REMOVEBUTTON, (WPARAM)hTTButton, 0);
+ hTTButton = NULL;
+ }
+ }
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int Shutdown(WPARAM, LPARAM)
+{
+ CallService(MS_TTB_REMOVEBUTTON, (WPARAM)hTTButton, 0);
+
+ DBWriteContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBMSGPOSX, HeadPosX);
+ DBWriteContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBMSGPOSY, HeadPosY);
+ DBWriteContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBMSGSIZEX, HeadSizeX);
+ DBWriteContactSettingDword(NULL, YAMN_DBMODULE, YAMN_DBMSGSIZEY, HeadSizeY);
+ DBWriteContactSettingWord(NULL, YAMN_DBMODULE, YAMN_DBMSGPOSSPLIT, HeadSplitPos);
+ YAMNVar.Shutdown = TRUE;
+ KillTimer(NULL, SecTimer);
+
+ UnregisterProtoPlugins();
+ UnregisterFilterPlugins();
+ return 0;
+}
+
+int SystemModulesLoaded(WPARAM, LPARAM); //in main.cpp
+typedef struct { HANDLE hookHandle; const char *hookName; MIRANDAHOOK mirandaFunction;} HookDataType;
+static HookDataType hookData[] = {
+ {0, ME_SYSTEM_MODULESLOADED, SystemModulesLoaded}, //pop3 plugin must be included after all miranda modules are loaded
+ {0, ME_TTB_MODULELOADED, AddTopToolbarIcon},
+ {0, ME_OPT_INITIALISE, YAMNOptInitSvc},
+ {0, ME_SYSTEM_PRESHUTDOWN, Shutdown},
+ {0, ME_CLIST_DOUBLECLICKED, Service_ContactDoubleclicked},
+ {0, 0, 0}//end marker
+};
+
+void HookEvents(void)
+{
+ //We set function which registers needed POP3 accounts. This is a part of internal POP3 plugin.
+ //Your plugin should do the same task in your Load fcn. Why we call it in MODULESLOADED? Because netlib
+ //user can be registered after all modules are loaded (see m_netlib.h in Miranda)
+ for (int i = 0;hookData[i].hookName;i++) {
+ hookData[i].hookHandle = HookEvent(hookData[i].hookName, hookData[i].mirandaFunction);
+ }
+}
+void UnhookEvents(void){
+ for (int i = 0;i<(sizeof(hookData)/sizeof(hookData[0]));i++) {
+ if (hookData[i].hookHandle) UnhookEvent(hookData[i].hookHandle);
+ }
+}
+
+typedef struct { HANDLE serviceHandle; const char *serviceName; MIRANDASERVICE serviceFunction;} ServiceDataType;
+static ServiceDataType serviceData[] = {
+ {0, YAMN_DBMODULE PS_GETCAPS, Service_GetCaps},
+ {0, YAMN_DBMODULE PS_GETSTATUS, Service_GetStatus},
+ {0, YAMN_DBMODULE PS_SETSTATUS, Service_SetStatus},
+ {0, YAMN_DBMODULE PS_GETNAME, Service_GetName},
+ {0, YAMN_DBMODULE PS_LOADICON, Service_LoadIcon},
+
+ //Function with which protocol plugin can register
+ {0, MS_YAMN_GETFCNPTR, GetFcnPtrSvc},
+
+ //Function returns pointer to YAMN variables
+ {0, MS_YAMN_GETVARIABLES, GetVariablesSvc},
+
+ //Function with which protocol plugin can register
+ {0, MS_YAMN_REGISTERPROTOPLUGIN, RegisterProtocolPluginSvc},
+
+ //Function with which protocol plugin can unregister
+ {0, MS_YAMN_UNREGISTERPROTOPLUGIN, UnregisterProtocolPluginSvc},
+
+ //Function creates an account for plugin
+ {0, MS_YAMN_CREATEPLUGINACCOUNT, CreatePluginAccountSvc},
+
+ //Function deletes plugin account
+ {0, MS_YAMN_DELETEPLUGINACCOUNT, DeletePluginAccountSvc},
+
+ //Finds account for plugin by name
+ {0, MS_YAMN_FINDACCOUNTBYNAME, FindAccountByNameSvc},
+
+ //Creates next account for plugin
+ {0, MS_YAMN_GETNEXTFREEACCOUNT, GetNextFreeAccountSvc},
+
+ //Function removes account from YAMN queue. Does not delete it from memory
+ {0, MS_YAMN_DELETEACCOUNT, DeleteAccountSvc},
+
+ //Function finds accounts for specified plugin
+ {0, MS_YAMN_READACCOUNTS, AddAccountsFromFileSvc},
+
+ //Function that stores all plugin mails to one file
+ {0, MS_YAMN_WRITEACCOUNTS, WriteAccountsToFileSvc},
+
+ //Function that returns user's filename
+ {0, MS_YAMN_GETFILENAME, GetFileNameSvc},
+
+ //Releases unicode string from memory
+ {0, MS_YAMN_DELETEFILENAME, DeleteFileNameSvc},
+
+ //Checks mail
+ {0, MS_YAMN_FORCECHECK, ForceCheckSvc},
+
+ //Runs YAMN's mail browser
+ {0, MS_YAMN_MAILBROWSER, RunMailBrowserSvc},
+
+ //Runs YAMN's bad conenction window
+ {0, MS_YAMN_BADCONNECTION, RunBadConnectionSvc},
+
+ //Function creates new mail for plugin
+ {0, MS_YAMN_CREATEACCOUNTMAIL, CreateAccountMailSvc},
+
+ //Function deletes plugin account
+ {0, MS_YAMN_DELETEACCOUNTMAIL, DeleteAccountMailSvc},
+
+ //Function with which filter plugin can register
+ {0, MS_YAMN_REGISTERFILTERPLUGIN, RegisterFilterPluginSvc},
+
+ //Function with which filter plugin can unregister
+ {0, MS_YAMN_UNREGISTERFILTERPLUGIN, UnregisterFilterPluginSvc},
+
+ //Function filters mail
+ {0, MS_YAMN_FILTERMAIL, FilterMailSvc},
+
+ //Function contact list double click
+ {0, MS_YAMN_CLISTDBLCLICK, ClistContactDoubleclicked},
+
+ //Function to check individual account
+ {0, MS_YAMN_ACCOUNTCHECK, AccountMailCheck},
+
+ //Function contact list context menu click
+ {0, MS_YAMN_CLISTCONTEXT, ContactMailCheck},
+
+ //Function contact list context menu click
+ {0, MS_YAMN_CLISTCONTEXTAPP, ContactApplication},
+
+ {0, 0, 0}//end marker
+};
+
+void CreateServiceFunctions(void)
+{
+ for (int i = 0;serviceData[i].serviceName;i++) {
+ serviceData[i].serviceHandle = CreateServiceFunction(serviceData[i].serviceName, serviceData[i].serviceFunction);
+ }
+};
+
+void DestroyServiceFunctions(void)
+{
+ for (int i = 0;serviceData[i].serviceName;i++) {
+ if (serviceData[i].serviceHandle) DestroyServiceFunction(serviceData[i].serviceHandle);
+ }
+};
+
+//Function to put all enabled contact to the Online status
+void RefreshContact(void)
+{
+ HACCOUNT Finder;
+ for (Finder = POP3Plugin->FirstAccount;Finder != NULL;Finder = Finder->Next) {
+ if (Finder->hContact != NULL) {
+ if ((Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT))
+ DBDeleteContactSetting(Finder->hContact, "CList", "Hidden");
+ else
+ DBWriteContactSettingByte(Finder->hContact, "CList", "Hidden", 1);
+ }
+ else if ((Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT)) {
+ Finder->hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)Finder->hContact, (LPARAM)YAMN_DBMODULE);
+ DBWriteContactSettingString(Finder->hContact, YAMN_DBMODULE, "Id", Finder->Name);
+ DBWriteContactSettingString(Finder->hContact, YAMN_DBMODULE, "Nick", Finder->Name);
+ DBWriteContactSettingString(Finder->hContact, "Protocol", "p", YAMN_DBMODULE);
+ DBWriteContactSettingWord(Finder->hContact, YAMN_DBMODULE, "Status", ID_STATUS_ONLINE);
+ DBWriteContactSettingString(Finder->hContact, "CList", "StatusMsg", Translate("No new mail message"));
+} } }
diff --git a/plugins/YAMN/src/synchro.cpp b/plugins/YAMN/src/synchro.cpp new file mode 100644 index 0000000000..e510d8bac9 --- /dev/null +++ b/plugins/YAMN/src/synchro.cpp @@ -0,0 +1,359 @@ +/*
+ * This code implements synchronization objects code between threads. If you want, you can include it to your
+ * code. This file is not dependent on any other external code (functions)
+ *
+ * (c) majvan 2002-2004
+ */
+
+#include "yamn.h"
+
+// Initializes a SWMRG structure. This structure must be
+// initialized before any writer or reader threads attempt
+// to wait on it.
+// The structure must be allocated by the application and
+// the structure's address is passed as the first parameter.
+// The lpszName parameter is the name of the object. Pass
+// NULL if you do not want to share the object.
+BOOL WINAPI SWMRGInitialize(PSWMRG pSWMRG,TCHAR *Name);
+
+// Deletes the system resources associated with a SWMRG
+// structure. The structure must be deleted only when
+// no writer or reader threads in the calling process
+// will wait on it.
+void WINAPI SWMRGDelete(PSWMRG pSWMRG);
+
+// A writer thread calls this function to know when
+// it can successfully write to the shared data.
+// returns WAIT_FINISH when we are in write-access or WAIT_FAILED
+// when event about quick finishing is set (or when system returns fail when waiting for synchro object)
+DWORD WINAPI SWMRGWaitToWrite(PSWMRG pSWMRG,DWORD dwTimeout);
+
+// A writer thread calls this function to let other threads
+// know that it no longer needs to write to the shared data.
+void WINAPI SWMRGDoneWriting(PSWMRG pSWMRG);
+
+// A reader thread calls this function to know when
+// it can successfully read the shared data.
+// returns WAIT_FINISH when we are in read-access or WAIT_FAILED
+// when event about quick finishing is set (or when system returns fail when waiting for synchro object)
+DWORD WINAPI SWMRGWaitToRead(PSWMRG pSWMRG, DWORD dwTimeout);
+
+// A reader thread calls this function to let other threads
+// know when it no longer needs to read the shared data.
+void WINAPI SWMRGDoneReading(PSWMRG pSWMRG);
+
+// WaitToReadFcn
+// is used to wait for read access with SWMRG SO, but it also increments counter if successfull
+// returns WAIT_FAILED or WAIT_FINISH
+// when WAIT_FAILED, we should not begin to access datas, we are not in read-access mode
+DWORD WINAPI WaitToReadFcn(PSWMRG SObject);
+
+// WriteDoneFcn
+// is used to release read access with SWMRG SO, but it also decrements counter if successfull
+void WINAPI ReadDoneFcn(PSWMRG SObject);
+
+// This functions is for export purposes
+// Plugin can call this function to manage SCOUNTER synchronization object
+
+// Gets number value stored in SCOUNTER SO
+// Note you must not read the number from memory directly, because
+// CPU can stop reading thread when it has read HI-Word, then another thread
+// can change the value and then OS starts the previous thread, that reads the
+// LO-WORD of DWORD. And the return value HI+LO-WORD is corrupted
+DWORD WINAPI SCGetNumberFcn(PSCOUNTER SCounter);
+
+// Increments SCOUNTER and unsets event
+// Returns Number after incrementing
+DWORD WINAPI SCIncFcn(PSCOUNTER SCounter);
+
+// Decrements SCOUNTER and sets event if zero
+// Returns Number after decrementing
+DWORD WINAPI SCDecFcn(PSCOUNTER SCounter);
+
+struct CExportedFunctions SynchroExportedFcn[]=
+{
+ {YAMN_WAITTOWRITEID,(void *)WaitToWriteFcn},
+ {YAMN_WRITEDONEID,(void *)WriteDoneFcn},
+ {YAMN_WAITTOREADID,(void *)WaitToReadFcn},
+ {YAMN_READDONEID,(void *)ReadDoneFcn},
+ {YAMN_SCGETNUMBERID,(void *)SCGetNumberFcn},
+ {YAMN_SCINCID,(void *)SCIncFcn},
+ {YAMN_SCDECID,(void *)SCDecFcn},
+};
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+void WINAPI SWMRGDelete(PSWMRG pSWMRG)
+{
+// Destroys any synchronization objects that were
+// successfully created.
+ if (NULL!=pSWMRG->hEventNoWriter)
+ CloseHandle(pSWMRG->hEventNoWriter);
+ if (NULL!=pSWMRG->hEventNoReaders)
+ CloseHandle(pSWMRG->hEventNoReaders);
+ if (NULL!=pSWMRG->hSemNumReaders)
+ CloseHandle(pSWMRG->hSemNumReaders);
+ if (NULL!=pSWMRG->hFinishEV)
+ CloseHandle(pSWMRG->hFinishEV);
+}
+
+BOOL WINAPI SWMRGInitialize(PSWMRG pSWMRG,TCHAR *Name)
+{
+ pSWMRG->hEventNoWriter=NULL;
+ pSWMRG->hEventNoReaders=NULL;
+ pSWMRG->hSemNumReaders=NULL;
+ pSWMRG->hFinishEV=NULL;
+
+// Creates the automatic-reset event that is signalled when
+// no writer threads are writing.
+// Initially no reader threads are reading.
+ if (Name!=NULL)
+ Name[0]=(TCHAR)'W';
+ pSWMRG->hEventNoWriter=CreateEvent(NULL,FALSE,TRUE,Name);
+
+// Creates the manual-reset event that is signalled when
+// no reader threads are reading.
+// Initially no reader threads are reading.
+ if (Name!=NULL)
+ Name[0]=(TCHAR)'R';
+ pSWMRG->hEventNoReaders=CreateEvent(NULL,TRUE,TRUE,Name);
+
+// Initializes the variable that indicates the number of
+// reader threads that are reading.
+// Initially no reader threads are reading.
+ if (Name!=NULL)
+ Name[0]=(TCHAR)'C';
+ pSWMRG->hSemNumReaders=CreateSemaphore(NULL,0,0x7FFFFFFF,Name);
+
+ if (Name!=NULL)
+ Name[0]=(TCHAR)'F';
+ pSWMRG->hFinishEV=CreateEvent(NULL,TRUE,FALSE,Name);
+
+// If a synchronization object could not be created,
+// destroys any created objects and return failure.
+ if ((NULL==pSWMRG->hEventNoWriter) || (NULL==pSWMRG->hEventNoReaders) || (NULL==pSWMRG->hSemNumReaders) || (NULL==pSWMRG->hFinishEV))
+ {
+ SWMRGDelete(pSWMRG);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+DWORD WINAPI SWMRGWaitToWrite(PSWMRG pSWMRG,DWORD dwTimeout)
+{
+ DWORD dw;
+ HANDLE aHandles[2];
+
+// We can write if the following are true:
+// 1. No other threads are writing.
+// 2. No threads are reading.
+// But first we have to know if SWMRG structure is not about to delete
+ aHandles[0]=pSWMRG->hEventNoWriter;
+ aHandles[1]=pSWMRG->hEventNoReaders;
+ if (WAIT_OBJECT_0==(dw=WaitForSingleObject(pSWMRG->hFinishEV,0)))
+ return WAIT_FINISH;
+ if (WAIT_FAILED==dw)
+ return dw;
+ dw=WaitForMultipleObjects(2,aHandles,TRUE,dwTimeout);
+// if a request to delete became later, we should not catch it. Try once more to ask if account is not about to delete
+ if ((dw!=WAIT_FAILED) && (WAIT_OBJECT_0==(WaitForSingleObject(pSWMRG->hFinishEV,0))))
+ {
+ SetEvent(pSWMRG->hEventNoWriter);
+ return WAIT_FINISH;
+ }
+
+// This thread can write to the shared data.
+// Automatic event for NoWriter sets hEventNoWriter to nonsignaled after WaitForMultipleObject
+
+// Because a writer thread is writing, the Event
+// should not be reset. This stops other
+// writers and readers.
+ return dw;
+}
+
+void WINAPI SWMRGDoneWriting(PSWMRG pSWMRG)
+// Presumably, a writer thread calling this function has
+// successfully called WaitToWrite. This means that we
+// do not have to wait on any synchronization objects
+// here because the writer already owns the Event.
+{
+// Allow other writer/reader threads to use
+// the SWMRG synchronization object.
+ SetEvent(pSWMRG->hEventNoWriter);
+}
+
+DWORD WINAPI SWMRGWaitToRead(PSWMRG pSWMRG, DWORD dwTimeout)
+{
+ DWORD dw;
+ LONG lPreviousCount;
+
+// We can read if no threads are writing.
+// And there's not request to delete structure
+ if (WAIT_OBJECT_0==(dw=WaitForSingleObject(pSWMRG->hFinishEV,0)))
+ return WAIT_FINISH;
+ if (WAIT_FAILED==dw)
+ return dw;
+ dw=WaitForSingleObject(pSWMRG->hEventNoWriter, dwTimeout);
+// if a request to delete became later, we should not catch it. Try once more to ask if account is not about to delete
+ if ((dw!=WAIT_FAILED) && (WAIT_OBJECT_0==(WaitForSingleObject(pSWMRG->hFinishEV,0))))
+ {
+ SetEvent(pSWMRG->hEventNoWriter);
+ return WAIT_FINISH;
+ }
+
+ if (dw==WAIT_OBJECT_0)
+ {
+ // This thread can read from the shared data.
+ // Increment the number of reader threads.
+ // But there can't be more than one thread incrementing readers,
+ // so this is why we use semaphore.
+ ReleaseSemaphore(pSWMRG->hSemNumReaders,1,&lPreviousCount);
+ if (lPreviousCount==0)
+ // If this is the first reader thread,
+ // set event to reflect this. Other reader threads can read, no writer thread can write.
+ ResetEvent(pSWMRG->hEventNoReaders);
+
+ // Allow other writer/reader threads to use
+ // the SWMRG synchronization object. hEventNoWrite is still non-signaled
+ // (it looks like writer is processing thread, but it is not true)
+ SetEvent(pSWMRG->hEventNoWriter);
+ }
+
+ return(dw);
+}
+
+void WINAPI SWMRGDoneReading(PSWMRG pSWMRG)
+{
+ HANDLE aHandles[2];
+ LONG lNumReaders;
+
+// We can stop reading if the events are available,
+// but when we stop reading we must also decrement the
+// number of reader threads.
+ aHandles[0]=pSWMRG->hEventNoWriter;
+ aHandles[1]=pSWMRG->hSemNumReaders;
+ WaitForMultipleObjects(2,aHandles,TRUE,INFINITE);
+
+// Get the remaining number of readers by releasing the
+// semaphore and then restoring the count by immediately
+// performing a wait.
+ ReleaseSemaphore(pSWMRG->hSemNumReaders,1,&lNumReaders);
+ WaitForSingleObject(pSWMRG->hSemNumReaders,INFINITE);
+
+// If there are no remaining readers,
+// set the event to relect this.
+ if (lNumReaders==0)
+ // If there are no reader threads,
+ // set our event to reflect this.
+ SetEvent(pSWMRG->hEventNoReaders);
+
+// Allow other writer/reader threads to use
+// the SWMRG synchronization object.
+// (it looks like writer is processing thread, but it is not true)
+ SetEvent(pSWMRG->hEventNoWriter);
+}
+
+DWORD WINAPI WaitToWriteFcn(PSWMRG SObject,PSCOUNTER SCounter)
+{
+ DWORD EnterCode;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tSO WaitToWrite: %x\n",SObject);
+#endif
+ if (WAIT_OBJECT_0==(EnterCode=SWMRGWaitToWrite(SObject,INFINITE)))
+ if (SCounter!=NULL)
+ SCIncFcn(SCounter);
+ return EnterCode;
+}
+
+void WINAPI WriteDoneFcn(PSWMRG SObject,PSCOUNTER SCounter)
+{
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tSO WriteDone: %x\n",SObject);
+#endif
+ SWMRGDoneWriting(SObject);
+ if (SCounter!=NULL)
+ SCDecFcn(SCounter);
+}
+
+DWORD WINAPI WaitToReadFcn(PSWMRG SObject)
+{
+ DWORD EnterCode;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tSO WaitToRead: %x\n",SObject);
+#endif
+ EnterCode=SWMRGWaitToRead(SObject,INFINITE);
+ return EnterCode;
+}
+
+void WINAPI ReadDoneFcn(PSWMRG SObject)
+{
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tSO ReadDone: %x\n",SObject);
+#endif
+ SWMRGDoneReading(SObject);
+}
+
+DWORD WINAPI SCGetNumberFcn(PSCOUNTER SCounter)
+{
+ DWORD Temp;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tGetNumber-cs wait\n");
+#endif
+ EnterCriticalSection(&SCounter->CounterCS);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tGetNumber-cs enter\n");
+#endif
+ Temp=SCounter->Number;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tValue: %d\n",Temp);
+ DebugLog(SynchroFile,"\tGetNumber-cs done\n");
+#endif
+ LeaveCriticalSection(&SCounter->CounterCS);
+ return Temp;
+}
+
+DWORD WINAPI SCIncFcn(PSCOUNTER SCounter)
+{
+ DWORD Temp;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tIncrementValue-cs wait\n");
+#endif
+ EnterCriticalSection(&SCounter->CounterCS);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tIncrementValue-cs enter\n");
+#endif
+ Temp=++SCounter->Number;
+ ResetEvent(SCounter->Event);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tValue: %d\n",Temp);
+ DebugLog(SynchroFile,"\tIncrementValue-cs done\n");
+#endif
+ LeaveCriticalSection(&SCounter->CounterCS);
+ return Temp;
+}
+
+DWORD WINAPI SCDecFcn(PSCOUNTER SCounter)
+{
+ DWORD Temp;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tDecrementValue-cs wait\n");
+#endif
+ EnterCriticalSection(&SCounter->CounterCS);
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tDecrementValue-cs enter\n");
+#endif
+ if (!(Temp=--SCounter->Number))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tDecrementValue-zero ev set\n");
+#endif
+ SetEvent(SCounter->Event);
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile,"\tValue: %d\n",Temp);
+ DebugLog(SynchroFile,"\tDecrementValue-cs done\n");
+#endif
+ LeaveCriticalSection(&SCounter->CounterCS);
+ return Temp;
+}
diff --git a/plugins/YAMN/src/version.h b/plugins/YAMN/src/version.h new file mode 100644 index 0000000000..e658cfee0c --- /dev/null +++ b/plugins/YAMN/src/version.h @@ -0,0 +1,3 @@ +#define YAMN_VERSION_H 0,1,2,5
+#define YAMN_VERSION PLUGIN_MAKE_VERSION( 0,1,2,5 )
+#define YAMN_VERSION_C "0.1.2.5"
diff --git a/plugins/YAMN/src/yamn.cpp b/plugins/YAMN/src/yamn.cpp new file mode 100644 index 0000000000..c93225e609 --- /dev/null +++ b/plugins/YAMN/src/yamn.cpp @@ -0,0 +1,333 @@ +/*
+ * This code implements miscellaneous usefull functions
+ *
+ * (c) majvan 2002-2004
+ */
+
+#include "yamn.h"
+
+#include "m_yamn.h"
+#include "m_protoplugin.h"
+#include "m_messages.h"
+#include "m_synchro.h"
+#include "main.h"
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+//Plugin registration CS
+//Used if we add (register) plugin to YAMN plugins and when we browse through registered plugins
+CRITICAL_SECTION PluginRegCS;
+
+//AccountWriterCS
+//We want to store number of writers of Accounts (number of Accounts used for writing)
+//If we want to read all accounts (for saving to file) immidiatelly, we have to wait until no account is changing (no thread writing to account)
+SCOUNTER *AccountWriterSO;
+
+//NoExitEV
+//Event that is signaled when there's a request to exit, so no new pop3 check should be performed
+HANDLE ExitEV;
+
+//WriteToFileEV
+//If this is signaled, write accounts to file is performed. Set this event if you want to actualize your accounts and messages
+HANDLE WriteToFileEV;
+
+//Returns pointer to YAMN exported function
+INT_PTR GetFcnPtrSvc(WPARAM wParam, LPARAM lParam);
+
+//Returns pointer to YAMN variables
+INT_PTR GetVariablesSvc(WPARAM wParam, LPARAM);
+
+// Function every seconds decrements account counter of seconds and checks if they are 0
+// If yes, creates a POP3 thread to check account
+void CALLBACK TimerProc(HWND, UINT, UINT, DWORD);
+
+// Function called to check all accounts immidialtelly
+// no params
+INT_PTR ForceCheckSvc(WPARAM, LPARAM);
+
+//thread is running all the time
+//waits for WriteToFileEV and then writes all accounts to file
+//DWORD WINAPI FileWritingThread(PVOID);
+
+// Function is called when Miranda notifies plugin that it is about to exit
+// Ensures succesfull end of POP3 checking, sets event that no next checking should be performed
+// If there's no writer to account (POP3 thread), saves the results to the file
+//not used now, perhaps in the future
+
+
+//int ExitProc(WPARAM wParam, LPARAM lParam);
+
+//--------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------
+
+INT_PTR GetFcnPtrSvc(WPARAM wParam, LPARAM lParam)
+{
+ register int i;
+
+ for (i=0;i<sizeof(ProtoPluginExportedFcn)/sizeof(ProtoPluginExportedFcn[0]);i++)
+ if (0==lstrcmpA((char *)wParam, ProtoPluginExportedFcn[i].ID))
+ return (INT_PTR)ProtoPluginExportedFcn[i].Ptr;
+ for (i=0;i<sizeof(ProtoPluginExportedSvc)/sizeof(ProtoPluginExportedSvc[0]);i++)
+ if (0==lstrcmpA((char *)wParam, ProtoPluginExportedSvc[i].ID))
+ return (INT_PTR)ProtoPluginExportedSvc[i].Ptr;
+ for (i=0;i<sizeof(SynchroExportedFcn)/sizeof(SynchroExportedFcn[0]);i++)
+ if (0==lstrcmpA((char *)wParam, SynchroExportedFcn[i].ID))
+ return (INT_PTR)SynchroExportedFcn[i].Ptr;
+ for (i=0;i<sizeof(AccountExportedFcn)/sizeof(AccountExportedFcn[0]);i++)
+ if (0==lstrcmpA((char *)wParam, AccountExportedFcn[i].ID))
+ return (INT_PTR)AccountExportedFcn[i].Ptr;
+ for (i=0;i<sizeof(AccountExportedSvc)/sizeof(AccountExportedSvc[0]);i++)
+ if (0==lstrcmpA((char *)wParam, AccountExportedSvc[i].ID))
+ return (INT_PTR)AccountExportedSvc[i].Ptr;
+ for (i=0;i<sizeof(MailExportedFcn)/sizeof(MailExportedFcn[0]);i++)
+ if (0==lstrcmpA((char *)wParam, MailExportedFcn[i].ID))
+ return (INT_PTR)MailExportedFcn[i].Ptr;
+ for (i=0;i<sizeof(MailExportedSvc)/sizeof(MailExportedSvc[0]);i++)
+ if (0==lstrcmpA((char *)wParam, MailExportedSvc[i].ID))
+ return (INT_PTR)MailExportedSvc[i].Ptr;
+ for (i=0;i<sizeof(FilterPluginExportedFcn)/sizeof(FilterPluginExportedFcn[0]);i++)
+ if (0==lstrcmpA((char *)wParam, FilterPluginExportedFcn[i].ID))
+ return (INT_PTR)FilterPluginExportedFcn[i].Ptr;
+ for (i=0;i<sizeof(FilterPluginExportedSvc)/sizeof(FilterPluginExportedSvc[0]);i++)
+ if (0==lstrcmpA((char *)wParam, FilterPluginExportedSvc[i].ID))
+ return (INT_PTR)FilterPluginExportedSvc[i].Ptr;
+ return (INT_PTR)NULL;
+}
+
+INT_PTR GetVariablesSvc(WPARAM wParam, LPARAM)
+{
+ return wParam==YAMN_VARIABLESVERSION ? (INT_PTR)&YAMNVar : (INT_PTR)NULL;
+}
+
+void CALLBACK TimerProc(HWND, UINT, UINT, DWORD)
+{
+ PYAMN_PROTOPLUGINQUEUE ActualPlugin;
+ HACCOUNT ActualAccount;
+ HANDLE ThreadRunningEV;
+ DWORD Status, tid;
+
+// we use event to signal, that running thread has all needed stack parameters copied
+ if (NULL==(ThreadRunningEV=CreateEvent(NULL, FALSE, FALSE, NULL)))
+ return;
+// if we want to close miranda, we get event and do not run checking anymore
+ if (WAIT_OBJECT_0==WaitForSingleObject(ExitEV, 0))
+ return;
+// Get actual status of current user in Miranda
+ Status=CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
+
+ EnterCriticalSection(&PluginRegCS);
+ for (ActualPlugin=FirstProtoPlugin;ActualPlugin!=NULL;ActualPlugin=ActualPlugin->Next)
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "TimerProc:AccountBrowserSO-read wait\n");
+#endif
+ if (WAIT_OBJECT_0!=SWMRGWaitToRead(ActualPlugin->Plugin->AccountBrowserSO, 0)) //we want to access accounts immiadtelly
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "TimerProc:AccountBrowserSO-read enter failed\n");
+#endif
+ LeaveCriticalSection(&PluginRegCS);
+ return;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "TimerProc:AccountBrowserSO-read enter\n");
+#endif
+ for (ActualAccount=ActualPlugin->Plugin->FirstAccount;ActualAccount!=NULL;ActualAccount=ActualAccount->Next)
+ {
+ if (ActualAccount->Plugin==NULL || ActualAccount->Plugin->Fcn==NULL) //account not inited
+ continue;
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read wait\n");
+#endif
+ if (WAIT_OBJECT_0!=SWMRGWaitToRead(ActualAccount->AccountAccessSO, 0))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read wait failed\n");
+#endif
+ continue;
+ }
+#ifdef DEBUG_SYNCHRO
+
+ switch(Status)
+ {
+ case ID_STATUS_OFFLINE:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status offline\n");
+ break;
+ case ID_STATUS_ONLINE:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status online\n");
+ break;
+ case ID_STATUS_AWAY:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status away\n");
+ break;
+ case ID_STATUS_DND:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status dnd\n");
+ break;
+ case ID_STATUS_NA:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status na\n");
+ break;
+ case ID_STATUS_OCCUPIED:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status occupied\n");
+ break;
+ case ID_STATUS_FREECHAT:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status freechat\n");
+ break;
+ case ID_STATUS_INVISIBLE:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status invisible\n");
+ break;
+ case ID_STATUS_ONTHEPHONE:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status onthephone\n");
+ break;
+ case ID_STATUS_OUTTOLUNCH:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status outtolunch\n");
+ break;
+ default:
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read enter status unknown\n");
+ break;
+ }
+#endif
+ BOOL isAccountCounting = 0;
+ if (
+ (ActualAccount->Flags & YAMN_ACC_ENA) &&
+ (((ActualAccount->StatusFlags & YAMN_ACC_ST0) && (Status<=ID_STATUS_OFFLINE)) ||
+ ((ActualAccount->StatusFlags & YAMN_ACC_ST1) && (Status==ID_STATUS_ONLINE)) ||
+ ((ActualAccount->StatusFlags & YAMN_ACC_ST2) && (Status==ID_STATUS_AWAY)) ||
+ ((ActualAccount->StatusFlags & YAMN_ACC_ST3) && (Status==ID_STATUS_DND)) ||
+ ((ActualAccount->StatusFlags & YAMN_ACC_ST4) && (Status==ID_STATUS_NA)) ||
+ ((ActualAccount->StatusFlags & YAMN_ACC_ST5) && (Status==ID_STATUS_OCCUPIED)) ||
+ ((ActualAccount->StatusFlags & YAMN_ACC_ST6) && (Status==ID_STATUS_FREECHAT)) ||
+ ((ActualAccount->StatusFlags & YAMN_ACC_ST7) && (Status==ID_STATUS_INVISIBLE)) ||
+ ((ActualAccount->StatusFlags & YAMN_ACC_ST8) && (Status==ID_STATUS_ONTHEPHONE)) ||
+ ((ActualAccount->StatusFlags & YAMN_ACC_ST9) && (Status==ID_STATUS_OUTTOLUNCH))))
+ {
+
+ if ((!ActualAccount->Interval && !ActualAccount->TimeLeft) || ActualAccount->Plugin->Fcn->TimeoutFcnPtr==NULL)
+ {
+ goto ChangeIsCountingStatusLabel;
+ }
+ if (ActualAccount->TimeLeft){
+ ActualAccount->TimeLeft--;
+ isAccountCounting = TRUE;
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "TimerProc:time left : %i\n", ActualAccount->TimeLeft);
+#endif
+ WindowList_BroadcastAsync(YAMNVar.MessageWnds, WM_YAMN_CHANGETIME, (WPARAM)ActualAccount, (LPARAM)ActualAccount->TimeLeft);
+ if (!ActualAccount->TimeLeft)
+ {
+ struct CheckParam ParamToPlugin={YAMN_CHECKVERSION, ThreadRunningEV, ActualAccount, YAMN_NORMALCHECK, (void *)0, NULL};
+ HANDLE NewThread;
+
+ ActualAccount->TimeLeft=ActualAccount->Interval;
+ if (NULL==(NewThread=CreateThread(NULL, 0, (YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->TimeoutFcnPtr, &ParamToPlugin, 0, &tid)))
+ {
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read done\n");
+#endif
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ continue;
+ }
+ else
+ {
+ WaitForSingleObject(ThreadRunningEV, INFINITE);
+ CloseHandle(NewThread);
+ }
+ }
+
+ }
+ChangeIsCountingStatusLabel:
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "TimerProc:ActualAccountSO-read done\n");
+#endif
+ if (((ActualAccount->isCounting)!=0)!=isAccountCounting){
+ ActualAccount->isCounting=isAccountCounting;
+ WORD cStatus = DBGetContactSettingWord(ActualAccount->hContact, YAMN_DBMODULE, "Status", 0);
+ switch (cStatus){
+ case ID_STATUS_ONLINE:
+ case ID_STATUS_OFFLINE:
+ DBWriteContactSettingWord(ActualAccount->hContact, YAMN_DBMODULE, "Status", isAccountCounting?ID_STATUS_ONLINE:ID_STATUS_OFFLINE);
+ default: break;
+ }
+ }
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "TimerProc:AccountBrowserSO-read done\n");
+#endif
+ SWMRGDoneReading(ActualPlugin->Plugin->AccountBrowserSO);
+ }
+ LeaveCriticalSection(&PluginRegCS);
+ CloseHandle(ThreadRunningEV);
+ return;
+}
+
+INT_PTR ForceCheckSvc(WPARAM, LPARAM)
+{
+ PYAMN_PROTOPLUGINQUEUE ActualPlugin;
+ HACCOUNT ActualAccount;
+ HANDLE ThreadRunningEV;
+ DWORD tid;
+
+ //we use event to signal, that running thread has all needed stack parameters copied
+ if (NULL==(ThreadRunningEV=CreateEvent(NULL, FALSE, FALSE, NULL)))
+ return 0;
+ //if we want to close miranda, we get event and do not run pop3 checking anymore
+ if (WAIT_OBJECT_0==WaitForSingleObject(ExitEV, 0))
+ return 0;
+ EnterCriticalSection(&PluginRegCS);
+ for (ActualPlugin=FirstProtoPlugin;ActualPlugin!=NULL;ActualPlugin=ActualPlugin->Next)
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:AccountBrowserSO-read wait\n");
+ #endif
+ SWMRGWaitToRead(ActualPlugin->Plugin->AccountBrowserSO, INFINITE);
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:AccountBrowserSO-read enter\n");
+ #endif
+ for (ActualAccount=ActualPlugin->Plugin->FirstAccount;ActualAccount!=NULL;ActualAccount=ActualAccount->Next)
+ {
+ if (ActualAccount->Plugin->Fcn==NULL) //account not inited
+ continue;
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read wait\n");
+ #endif
+ if (WAIT_OBJECT_0!=WaitToReadFcn(ActualAccount->AccountAccessSO))
+ {
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read wait failed\n");
+ #endif
+ continue;
+ }
+ #ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:ActualAccountSO-read enter\n");
+ #endif
+ if ((ActualAccount->Flags & YAMN_ACC_ENA) && (ActualAccount->StatusFlags & YAMN_ACC_FORCE)) //account cannot be forced to check
+ {
+ if (ActualAccount->Plugin->Fcn->ForceCheckFcnPtr==NULL)
+ {
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ continue;
+ }
+ struct CheckParam ParamToPlugin={YAMN_CHECKVERSION, ThreadRunningEV, ActualAccount, YAMN_FORCECHECK, (void *)0, NULL};
+
+ if (NULL==CreateThread(NULL, 0, (YAMN_STANDARDFCN)ActualAccount->Plugin->Fcn->ForceCheckFcnPtr, &ParamToPlugin, 0, &tid))
+ {
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ continue;
+ }
+ else
+ WaitForSingleObject(ThreadRunningEV, INFINITE);
+ }
+ ReadDoneFcn(ActualAccount->AccountAccessSO);
+ }
+#ifdef DEBUG_SYNCHRO
+ DebugLog(SynchroFile, "ForceCheck:AccountBrowserSO-read done\n");
+#endif
+ SWMRGDoneReading(ActualPlugin->Plugin->AccountBrowserSO);
+ }
+ LeaveCriticalSection(&PluginRegCS);
+ CloseHandle(ThreadRunningEV);
+
+ if (hTTButton) CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTButton, TTBST_RELEASED);
+ return 1;
+}
diff --git a/plugins/YAMN/src/yamn.h b/plugins/YAMN/src/yamn.h new file mode 100644 index 0000000000..c8cd8d596d --- /dev/null +++ b/plugins/YAMN/src/yamn.h @@ -0,0 +1,271 @@ +
+#ifndef __YAMN_H
+#define __YAMN_H
+#ifndef _WIN32_IE
+ #define _WIN32_IE 0x0400
+#endif
+#ifndef _WIN32_WINNT
+ #define _WIN32_WINNT 0x0501
+#endif
+
+#include <wchar.h>
+#include <tchar.h>
+#include <windows.h>
+#include <stdio.h>
+#include <direct.h> //For _chdir()
+
+#define MIRANDA_VER 0x0A00
+
+#include <commctrl.h> //For hotkeys
+#include "win2k.h"
+#include "newpluginapi.h" //CallService,UnHookEvent
+#include "m_utils.h" //window broadcasting
+#include "m_system.h"
+#include "m_skin.h"
+#include "m_langpack.h"
+#include "m_clist.h"
+#include "m_clui.h"
+#include "m_options.h"
+#include "m_database.h" //database
+#include "m_contacts.h" //contact
+#include "m_protocols.h" //protocols
+#include "m_protomod.h" //protocols module
+#include "m_protosvc.h"
+#include "m_toptoolbar.h"
+#include "m_icolib.h"
+#include "m_kbdnotify.h"
+#include "m_popup.h"
+#include "m_account.h" //Account structure and all needed structures to cooperate with YAMN
+#include "m_messages.h" //Messages sent to YAMN windows
+#include "m_mails.h" //use YAMN's mails
+#include "mails/m_decode.h" //use decoding macros (needed for header extracting)
+#include "browser/m_browser.h" //we want to run YAMN mailbrowser, no new mail notification and bad connect window
+#include "resource.h"
+#include "m_protoplugin.h"
+#include "m_filterplugin.h"
+#include "m_yamn.h" //Main YAMN's variables
+#include "m_protoplugin.h" //Protocol registration and so on
+#include "m_synchro.h" //Synchronization
+#include "debug.h"
+#include <m_folders.h>
+
+
+//From services.cpp
+void CreateServiceFunctions(void);
+void DestroyServiceFunctions(void);
+void HookEvents(void);
+void UnhookEvents(void);
+void RefreshContact(void);
+void ContactDoubleclicked(WPARAM wParam,LPARAM lParam);
+INT_PTR ClistContactDoubleclicked(WPARAM wParam, LPARAM lParam);
+
+extern CRITICAL_SECTION PluginRegCS;
+extern SCOUNTER *AccountWriterSO;
+extern HANDLE ExitEV;
+extern HANDLE WriteToFileEV;
+
+//From debug.cpp
+#undef YAMN_DEBUG
+#ifdef YAMN_DEBUG
+void InitDebug();
+void UnInitDebug();
+#endif
+
+//From synchro.cpp
+//struct CExportedFunctions SynchroExported[];
+
+//From yamn.cpp
+INT_PTR GetFcnPtrSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR GetVariablesSvc(WPARAM,LPARAM);
+void CALLBACK TimerProc(HWND,UINT,UINT,DWORD);
+INT_PTR ForceCheckSvc(WPARAM,LPARAM);
+
+extern struct YAMNExportedFcns *pYAMNFcn;
+
+//From account.cpp
+extern CRITICAL_SECTION AccountStatusCS;
+extern CRITICAL_SECTION FileWritingCS;
+
+INT_PTR CreatePluginAccountSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR DeletePluginAccountSvc(WPARAM wParam,LPARAM);
+int InitAccount(HACCOUNT Which);
+void DeInitAccount(HACCOUNT Which);
+void StopSignalFcn(HACCOUNT Which);
+void CodeDecodeString(char *Dest,BOOL Encrypt);
+DWORD FileToMemory(TCHAR *FileName,char **MemFile,char **End);
+
+#if defined(DEBUG_FILEREAD) || defined(DEBUG_FILEREADMESSAGES)
+DWORD ReadStringFromMemory(char **Parser,char *End,char **StoreTo,char *DebugString);
+#endif
+DWORD ReadStringFromMemory(char **Parser,char *End,char **StoreTo);
+DWORD ReadMessagesFromMemory(HACCOUNT Which,char **Parser,char *End);
+DWORD ReadAccountFromMemory(HACCOUNT Which,char **Parser,TCHAR *End);
+INT_PTR AddAccountsFromFileSvc(WPARAM wParam,LPARAM lParam);
+
+DWORD WriteStringToFile(HANDLE File,char *Source);
+DWORD WriteStringToFileW(HANDLE File,WCHAR *Source);
+
+
+DWORD WriteMessagesToFile(HANDLE File,HACCOUNT Which);
+DWORD WINAPI WritePOP3Accounts();
+INT_PTR WriteAccountsToFileSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR FindAccountByNameSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR GetNextFreeAccountSvc(WPARAM wParam,LPARAM lParam);
+
+INT_PTR DeleteAccountSvc(WPARAM wParam,LPARAM);
+DWORD WINAPI DeleteAccountInBackground(LPVOID Which);
+int StopAccounts(HYAMNPROTOPLUGIN Plugin);
+int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin,BOOL GetAccountBrowserAccess=FALSE);
+int DeleteAccounts(HYAMNPROTOPLUGIN Plugin);
+
+void WINAPI GetStatusFcn(HACCOUNT Which,TCHAR *Value);
+void WINAPI SetStatusFcn(HACCOUNT Which,TCHAR *Value);
+
+INT_PTR UnregisterProtoPlugins();
+INT_PTR RegisterProtocolPluginSvc(WPARAM,LPARAM);
+INT_PTR UnregisterProtocolPluginSvc(WPARAM,LPARAM);
+INT_PTR GetFileNameSvc(WPARAM,LPARAM);
+INT_PTR DeleteFileNameSvc(WPARAM,LPARAM);
+
+//From filterplugin.cpp
+//struct CExportedFunctions FilterPluginExported[];
+INT_PTR UnregisterFilterPlugins();
+INT_PTR RegisterFilterPluginSvc(WPARAM,LPARAM);
+INT_PTR UnregisterFilterPluginSvc(WPARAM,LPARAM);
+INT_PTR FilterMailSvc(WPARAM,LPARAM);
+
+//From mails.cpp (MIME)
+//struct CExportedFunctions MailExported[];
+INT_PTR CreateAccountMailSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR DeleteAccountMailSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR LoadMailDataSvc(WPARAM wParam,LPARAM lParam);
+INT_PTR UnloadMailDataSvc(WPARAM wParam,LPARAM);
+INT_PTR SaveMailDataSvc(WPARAM wParam,LPARAM lParam);
+
+//From mime.cpp
+//void WINAPI ExtractHeaderFcn(char *,int,WORD,HYAMNMAIL); //already in MailExported
+struct _tcptable
+{
+ char *NameBase,*NameSub;
+ BOOLEAN isValid;
+ unsigned short int CP;
+};
+extern struct _tcptable CodePageNamesAll[]; // in mime/decode.cpp
+extern int CPLENALL;
+extern struct _tcptable *CodePageNamesSupp; // in mime/decode.cpp
+extern int CPLENSUPP;
+
+extern int PosX,PosY,SizeX,SizeY;
+extern int HeadPosX,HeadPosY,HeadSizeX,HeadSizeY,HeadSplitPos;
+
+//#define CPDEFINDEX 63 //ISO-8859-1
+#define CPDEFINDEX 0 //ACP
+
+//From pop3comm.cpp
+int RegisterPOP3Plugin(WPARAM,LPARAM);
+
+//From mailbrowser.cpp
+INT_PTR RunMailBrowserSvc(WPARAM,LPARAM);
+
+//From badconnect.cpp
+INT_PTR RunBadConnectionSvc(WPARAM,LPARAM);
+
+//From YAMNopts.cpp
+int YAMNOptInitSvc(WPARAM,LPARAM);
+
+//From main.cpp
+int PostLoad(WPARAM,LPARAM); //Executed after all plugins loaded YAMN reads mails from file and notify every protocol it should set its functions
+int Shutdown(WPARAM,LPARAM); //Executed before Miranda is going to shutdown
+int AddTopToolbarIcon(WPARAM,LPARAM); //Executed when TopToolBar plugin loaded Adds bitmap to toolbar
+
+extern TCHAR UserDirectory[]; //e.g. "F:\WINNT\Profiles\UserXYZ"
+extern TCHAR ProfileName[]; //e.g. "majvan"
+extern SWMRG *AccountBrowserSO;
+extern CRITICAL_SECTION PluginRegCS;
+extern YAMN_VARIABLES YAMNVar;
+extern HANDLE hNewMailHook;
+extern HANDLE WriteToFileEV;
+extern HANDLE hTTButton;
+extern HCURSOR hCurSplitNS, hCurSplitWE;
+extern UINT SecTimer;
+
+HANDLE WINAPI g_GetIconHandle( int idx );
+HICON WINAPI g_LoadIconEx( int idx, bool big = false );
+void WINAPI g_ReleaseIcon( HICON hIcon );
+
+//From synchro.cpp
+void WINAPI DeleteMessagesToEndFcn(HACCOUNT Account,HYAMNMAIL From);
+DWORD WINAPI WaitToWriteFcn(PSWMRG SObject,PSCOUNTER SCounter=NULL);
+void WINAPI WriteDoneFcn(PSWMRG SObject,PSCOUNTER SCounter=NULL);
+DWORD WINAPI WaitToReadFcn(PSWMRG SObject);
+void WINAPI ReadDoneFcn(PSWMRG SObject);
+DWORD WINAPI SCIncFcn(PSCOUNTER SCounter);
+DWORD WINAPI SCDecFcn(PSCOUNTER SCounter);
+BOOL WINAPI SWMRGInitialize(PSWMRG,TCHAR *);
+void WINAPI SWMRGDelete(PSWMRG);
+DWORD WINAPI SWMRGWaitToWrite(PSWMRG pSWMRG,DWORD dwTimeout);
+void WINAPI SWMRGDoneWriting(PSWMRG pSWMRG);
+DWORD WINAPI SWMRGWaitToRead(PSWMRG pSWMRG, DWORD dwTimeout);
+void WINAPI SWMRGDoneReading(PSWMRG pSWMRG);
+
+//From mails.cpp
+void WINAPI DeleteMessageFromQueueFcn(HYAMNMAIL *From,HYAMNMAIL Which,int mode);
+void WINAPI SetRemoveFlagsInQueueFcn(HYAMNMAIL From,DWORD FlagsSet,DWORD FlagsNotSet,DWORD FlagsToSet,int mode);
+
+//From mime.cpp
+void ExtractHeader(struct CMimeItem *items,int &CP,struct CHeader *head);
+void ExtractShortHeader(struct CMimeItem *items,struct CShortHeader *head);
+void DeleteHeaderContent(struct CHeader *head);
+void DeleteShortHeaderContent(struct CShortHeader *head);
+char *ExtractFromContentType(char *ContentType,char *value);
+WCHAR *ParseMultipartBody(char *src, char *bond);
+
+//From account.cpp
+void WINAPI GetStatusFcn(HACCOUNT Which,TCHAR *Value);
+extern int StopAccounts(HYAMNPROTOPLUGIN Plugin);
+extern int DeleteAccounts(HYAMNPROTOPLUGIN Plugin);
+extern int WaitForAllAccounts(HYAMNPROTOPLUGIN Plugin,BOOL GetAccountBrowserAccess);
+
+extern HYAMNPROTOPLUGIN POP3Plugin;
+
+//from decode.cpp
+int DecodeQuotedPrintable(char *Src,char *Dst,int DstLen, BOOL isQ);
+int DecodeBase64(char *Src,char *Dst,int DstLen);
+
+//From maild.cpp
+extern INT_PTR LoadMailDataSvc(WPARAM wParam,LPARAM lParam);
+extern INT_PTR UnloadMailDataSvc(WPARAM wParam,LPARAM);
+extern INT_PTR SaveMailDataSvc(WPARAM wParam,LPARAM lParam);
+
+//From filterplugin.cpp
+extern PYAMN_FILTERPLUGINQUEUE FirstFilterPlugin;
+
+//From protoplugin.cpp
+extern PYAMN_PROTOPLUGINQUEUE FirstProtoPlugin;
+
+extern struct CExportedFunctions ProtoPluginExportedFcn[1];
+extern struct CExportedServices ProtoPluginExportedSvc[5];
+//From filterplugin.cpp
+extern struct CExportedFunctions FilterPluginExportedFcn[1];
+extern struct CExportedServices FilterPluginExportedSvc[2];
+//From synchro.cpp
+extern struct CExportedFunctions SynchroExportedFcn[7];
+//From account.cpp
+extern struct CExportedFunctions AccountExportedFcn[2];
+extern struct CExportedServices AccountExportedSvc[9];
+//From mails.cpp (MIME)
+extern struct CExportedFunctions MailExportedFcn[8];
+extern struct CExportedServices MailExportedSvc[5];
+
+extern char *iconDescs[];
+extern char *iconNames[];
+extern HIMAGELIST CSImages;
+
+extern void __stdcall SSL_DebugLog( const char *fmt, ... );
+
+extern int YAMN_STATUS;
+
+extern PYAMN_VARIABLES pYAMNVar;
+extern HYAMNPROTOPLUGIN POP3Plugin;
+
+#endif
diff --git a/plugins/mRadio/activex.pp b/plugins/mRadio/activex.pp new file mode 100644 index 0000000000..d36762ccf1 --- /dev/null +++ b/plugins/mRadio/activex.pp @@ -0,0 +1,4173 @@ +Unit ActiveX;
+
+//+-------------------------------------------------------------------------
+//
+// Microsoft Windows
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//
+// File: objidl.idl
+//
+// Header translation by Marco van de Voort for Free Pascal Platform
+// SDK dl'ed January 2002
+//
+//--------------------------------------------------------------------------
+
+{$Mode objfpc}
+
+{$ifndef NO_SMART_LINK}
+{$smartlink on}
+{$endif}
+
+Interface
+
+Uses variants,Windows,ctypes,types;
+
+
+type
+{ extra types }
+ TOleChar = Types.TOleChar;
+ POleStr = Types.POleStr;
+ PPOleStr = Types.PPOleStr;
+ TBStr = POleStr;
+ TBStrList = array[0..(high(integer) div sizeof(TBSTR))-1] of TBstr;
+ PBStrList = ^TBStrList;
+ POleStrList = ^TOleStrList;
+ TOleStrList = array[0..(high(integer) div sizeof(POleStr))-1] of POleStr;
+
+ PBStr = ^TBStr;
+ TOleEnum = type LongWord;
+ LargeInt = Types.LargeInt;
+ LargeUInt = Types.LargeUInt;
+ PLargeInt = Types.PLargeInt;
+ PLargeUInt = Types.PLargeUInt;
+ FMTID = TGUID;
+ pFMTID = pGUID;
+
+ { Glue types, should be linked to the proper windows unit types}
+ Size_t = DWord; {??, probably, like Unix, typecastable to pointer?!?}
+ OleChar = WChar;
+ LPOLESTR = ^OLECHAR;
+ POLECHAR = LPOLESTR;
+ PLPOLESTR = ^LPOLESTR;
+ PROPID = ULONG;
+ TPROPID= PROPID;
+ PPROPID= ^PROPID;
+ VARIANT_BOOL = wordbool;
+ _VARIANT_BOOL = VARIANT_BOOL;
+ PVARIANT_BOOL = ^VARIANT_BOOL;
+ CY = CURRENCY;
+ DATE = DOUBLE;
+ BSTR = POLESTR;
+ TOleDate = DATE;
+ POleDate = ^TOleDate;
+ OLE_HANDLE = UINT;
+ LPOLE_HANDLE = ^OLE_HANDLE;
+ OLE_COLOR = DWORD;
+ LPOLE_COLOR = ^OLE_COLOR;
+ TOleHandle = OLE_HANDLE;
+ POleHandle = LPOLE_HANDLE;
+ TOleColor = OLE_COLOR;
+ POleColor = LPOle_Color;
+
+CONST
+ GUID_NULL : TGUID = '{00000000-0000-0000-0000-000000000000}';
+
+ // bit flags for IExternalConnection
+CONST
+ EXTCONN_STRONG = $0001; // strong connection
+ EXTCONN_WEAK = $0002; // weak connection (table, container)
+ EXTCONN_CALLABLE = $0004; // table .vs. callable
+ {Bind Flags}
+ BIND_MAYBOTHERUSER = 1;
+ BIND_JUSTTESTEXISTENCE = 2;
+
+
+ MKSYS_NONE = 0;
+ MKSYS_GENERICCOMPOSITE = 1;
+ MKSYS_FILEMONIKER = 2;
+ MKSYS_ANTIMONIKER = 3;
+ MKSYS_ITEMMONIKER = 4;
+ MKSYS_POINTERMONIKER = 5;
+// MKSYS_URLMONIKER = 6;
+ MKSYS_CLASSMONIKER = 7;
+ MKSYS_OBJREFMONIKER = 8;
+ MKSYS_SESSIONMONIKER = 9;
+
+ // system moniker types; returned from IsSystemMoniker.
+
+ MKRREDUCE_ONE = 3 SHL 16;
+ MKRREDUCE_TOUSER = 2 SHL 16;
+ MKRREDUCE_THROUGHUSER = 1 SHL 16;
+ MKRREDUCE_ALL = 0;
+
+ // Storage element types
+ STGTY_STORAGE = 1;
+ STGTY_STREAM = 2;
+ STGTY_LOCKBYTES = 3;
+ STGTY_PROPERTY = 4;
+
+ STREAM_SEEK_SET = 0;
+ STREAM_SEEK_CUR = 1;
+ STREAM_SEEK_END = 2;
+
+ LOCK_WRITE = 1;
+ LOCK_EXCLUSIVE = 2;
+ LOCK_ONLYONCE = 4;
+
+ //Advise Flags
+ ADVF_NODATA = 1;
+ ADVF_PRIMEFIRST = 2;
+ ADVF_ONLYONCE = 4;
+ ADVF_DATAONSTOP = 64;
+ ADVFCACHE_NOHANDLER = 8;
+ ADVFCACHE_FORCEBUILTIN = 16;
+ ADVFCACHE_ONSAVE = 32;
+
+
+//****************************************************************************
+//* Notification Interfaces
+//****************************************************************************/
+
+ TYMED_HGLOBAL = 1;
+ TYMED_FILE = 2;
+ TYMED_ISTREAM = 4;
+ TYMED_ISTORAGE = 8;
+ TYMED_GDI = 16;
+ TYMED_MFPICT = 32;
+ TYMED_ENHMF = 64;
+ TYMED_NULL = 0;
+
+// Object Definitions for EnumObjects()
+ OBJ_PEN = 1;
+ OBJ_BRUSH = 2;
+ OBJ_DC = 3;
+ OBJ_METADC = 4;
+ OBJ_PAL = 5;
+ OBJ_FONT = 6;
+ OBJ_BITMAP = 7;
+ OBJ_REGION = 8;
+ OBJ_METAFILE = 9;
+ OBJ_MEMDC = 10;
+ OBJ_EXTPEN = 11;
+ OBJ_ENHMETADC = 12;
+ OBJ_ENHMETAFILE = 13;
+ DATADIR_GET = 1;
+ DATADIR_SET = 2;
+
+// call type used by IMessageFilter::HandleIncomingMessage
+
+ CALLTYPE_TOPLEVEL = 1; // toplevel call - no outgoing call
+ CALLTYPE_NESTED = 2; // callback on behalf of previous outgoing call - should always handle
+ CALLTYPE_ASYNC = 3; // aysnchronous call - can NOT be rejected
+ CALLTYPE_TOPLEVEL_CALLPENDING = 4; // new toplevel call with new LID
+ CALLTYPE_ASYNC_CALLPENDING = 5; // async call - can NOT be rejected
+
+// status of server call - returned by IMessageFilter::HandleIncomingCall
+// and passed to IMessageFilter::RetryRejectedCall
+
+ SERVERCALL_ISHANDLED = 0;
+ SERVERCALL_REJECTED = 1;
+ SERVERCALL_RETRYLATER = 2;
+
+// Pending type indicates the level of nesting
+
+ PENDINGTYPE_TOPLEVEL = 1; // toplevel call
+ PENDINGTYPE_NESTED = 2; // nested call
+
+// return values of MessagePending
+
+ PENDINGMSG_CANCELCALL = 0; // cancel the outgoing call
+ PENDINGMSG_WAITNOPROCESS = 1; // wait for the return and don't dispatch the message
+ PENDINGMSG_WAITDEFPROCESS = 2; // wait and dispatch the message
+
+ EOAC_NONE = $0;
+ EOAC_MUTUAL_AUTH = $1;
+ EOAC_STATIC_CLOAKING = $20;
+ EOAC_DYNAMIC_CLOAKING = $40;
+ EOAC_ANY_AUTHORITY = $80;
+ EOAC_MAKE_FULLSIC = $100;
+ EOAC_DEFAULT = $800;
+
+ // These are only valid for CoInitializeSecurity
+ EOAC_SECURE_REFS = $2;
+ EOAC_ACCESS_CONTROL = $4;
+ EOAC_APPID = $8;
+ EOAC_DYNAMIC = $10;
+ EOAC_REQUIRE_FULLSIC = $200;
+ EOAC_AUTO_IMPERSONATE = $400;
+ EOAC_NO_CUSTOM_MARSHAL = $2000;
+ EOAC_DISABLE_AAA = $1000;
+
+//****************************************************************************
+//* ICOMThreadingInfo and enums
+//****************************************************************************/
+
+ APTTYPE_CURRENT = -1;
+ APTTYPE_STA = 0;
+ APTTYPE_MTA = 1;
+ APTTYPE_NA = 2;
+ APTTYPE_MAINSTA = 3;
+
+ THDTYPE_BLOCKMESSAGES = 0;
+ THDTYPE_PROCESSMESSAGES = 1;
+
+ DCOM_NONE = $0;
+ DCOM_CALL_COMPLETE = $1;
+ DCOM_CALL_CANCELED = $2;
+
+ COMBND_RPCTIMEOUT = $1; // Rpc transport-specific timeout.
+
+//************************* Misc Enums wtypes.h ***********************************/
+
+// Common typdefs used in API paramaters, gleamed from compobj.h
+
+// memory context values; passed to CoGetMalloc
+
+Const
+ MEMCTX_TASK = 1; // task (private) memory
+ MEMCTX_SHARED = 2; // shared memory (between processes)
+ MEMCTX_MACSYSTEM = 3; // on the mac, the system heap
+ // these are mostly for internal use...
+ MEMCTX_UNKNOWN = -1; // unknown context (when asked about it)
+ MEMCTX_SAME = -2; // same context (as some other pointer)
+
+
+// For IRunningObjectTable::Register
+ ROTFLAGS_REGISTRATIONKEEPSALIVE = $1;
+ ROTFLAGS_ALLOWANYCLIENT = $2;
+
+// Maximum size of comparison buffer for IROTData::GetComparisonData
+ ROT_COMPARE_MAX = 2048;
+
+
+// class context: used to determine what scope and kind of class object to use
+// NOTE: this is a bitwise enum
+
+ CLSCTX_INPROC_SERVER = $0001; // server dll (runs in same process as caller)
+ CLSCTX_INPROC_HANDLER = $0002; // handler dll (runs in same process as caller)
+ CLSCTX_LOCAL_SERVER = $0004; // server exe (runs on same machine; diff proc)
+ CLSCTX_INPROC_SERVER16 = $0008; // 16-bit server dll (runs in same process as caller)
+ CLSCTX_REMOTE_SERVER = $0010; // remote server exe (runs on different machine)
+ CLSCTX_INPROC_HANDLER16 = $0020; // 16-bit handler dll (runs in same process as caller)
+ CLSCTX_INPROC_SERVERX86 = $0040; // Wx86 server dll (runs in same process as caller)
+ CLSCTX_INPROC_HANDLERX86 = $0080; // Wx86 handler dll (runs in same process as caller)
+ CLSCTX_ESERVER_HANDLER = $0100; // handler dll (runs in the server process)
+ CLSCTX_RESERVED =$0200; // reserved
+ CLSCTX_NO_CODE_DOWNLOAD = $0400; // disallow code download from the Directory Service (if any) or the internet -rahulth
+ CLSCTX_NO_WX86_TRANSLATION = $0800;
+ CLSCTX_NO_CUSTOM_MARSHAL = $1000;
+ CLSCTX_ENABLE_CODE_DOWNLOAD = $2000; // allow code download from the Directory Service (if any) or the internet
+ CLSCTX_NO_FAILURE_LOG = $04000; // do not log messages about activation failure (should one occur) to Event Log
+ CLSCTX_DISABLE_AAA = $08000; // Disable EOAC_DISABLE_AAA capability for this activation only
+ CLSCTX_ENABLE_AAA = $10000; // Enable EOAC_DISABLE_AAA capability for this activation only
+ CLSCTX_FROM_DEFAULT_CONTEXT = $20000; // Begin this activation from the default context of the current apartment
+ CLSCTX_INPROC = (CLSCTX_INPROC_SERVER OR CLSCTX_INPROC_HANDLER);
+// With DCOM, CLSCTX_REMOTE_SERVER should be included
+ CLSCTX_ALL = (CLSCTX_INPROC_SERVER OR CLSCTX_INPROC_HANDLER OR CLSCTX_LOCAL_SERVER {$ifdef Remote} OR CLSCTX_REMOTE_SERVER {$endif});
+ CLSCTX_SERVER = (CLSCTX_INPROC_SERVER OR CLSCTX_LOCAL_SERVER {$ifdef Remote} OR CLSCTX_REMOTE_SERVER {$endif});
+
+
+// marshaling flags; passed to CoMarshalInterface
+ MSHLFLAGS_NORMAL = 0; // normal marshaling via proxy/stub
+ MSHLFLAGS_TABLESTRONG = 1; // keep object alive; must explicitly release
+ MSHLFLAGS_TABLEWEAK = 2; // doesn't hold object alive; still must release
+ MSHLFLAGS_NOPING = 4; // remote clients dont 'ping' to keep objects alive
+ MSHLFLAGS_RESERVED1 = 8; // reserved
+ MSHLFLAGS_RESERVED2 = 16; // reserved
+ MSHLFLAGS_RESERVED3 = 32; // reserved
+ MSHLFLAGS_RESERVED4 = 64; // reserved
+
+// marshal context: determines the destination context of the marshal operation
+
+ MSHCTX_LOCAL = 0; // unmarshal context is local (eg.shared memory)
+ MSHCTX_NOSHAREDMEM = 1; // unmarshal context has no shared memory access
+ MSHCTX_DIFFERENTMACHINE = 2; // unmarshal context is on a different machine
+ MSHCTX_INPROC = 3; // unmarshal context is on different thread
+ MSHCTX_CROSSCTX = 4; // unmarshal context is on different context
+
+// #########################################################################
+//
+// VARTYPE
+//
+// #########################################################################
+
+
+{
+ VARENUM usage key,
+
+ * [V] - may appear in a VARIANT
+ * [T] - may appear in a TYPEDESC
+ * [P] - may appear in an OLE property set
+ * [S] - may appear in a Safe Array
+
+
+ VT_EMPTY [V] [P] nothing
+ VT_NULL [V] [P] SQL style Null
+ VT_I2 [V][T][P][S] 2 byte signed int
+ VT_I4 [V][T][P][S] 4 byte signed int
+ VT_R4 [V][T][P][S] 4 byte real
+ VT_R8 [V][T][P][S] 8 byte real
+ VT_CY [V][T][P][S] currency
+ VT_DATE [V][T][P][S] date
+ VT_BSTR [V][T][P][S] OLE Automation string
+ VT_DISPATCH [V][T] [S] IDispatch *
+ VT_ERROR [V][T][P][S] SCODE
+ VT_BOOL [V][T][P][S] True=-1, False=0
+ VT_VARIANT [V][T][P][S] VARIANT *
+ VT_UNKNOWN [V][T] [S] IUnknown *
+ VT_DECIMAL [V][T] [S] 16 byte fixed point
+ VT_RECORD [V] [P][S] user defined type
+ VT_I1 [V][T][P][s] signed char
+ VT_UI1 [V][T][P][S] unsigned char
+ VT_UI2 [V][T][P][S] unsigned short
+ VT_UI4 [V][T][P][S] unsigned long
+ VT_I8 [T][P] signed 64-bit int
+ VT_UI8 [T][P] unsigned 64-bit int
+ VT_INT [V][T][P][S] signed machine int
+ VT_UINT [V][T] [S] unsigned machine int
+ VT_INT_PTR [T] signed machine register size width
+ VT_UINT_PTR [T] unsigned machine register size width
+ VT_VOID [T] C style void
+ VT_HRESULT [T] Standard return type
+ VT_PTR [T] pointer type
+ VT_SAFEARRAY [T] (use VT_ARRAY in VARIANT)
+ VT_CARRAY [T] C style array
+ VT_USERDEFINED [T] user defined type
+ VT_LPSTR [T][P] null terminated string
+ VT_LPWSTR [T][P] wide null terminated string
+ VT_FILETIME [P] FILETIME
+ VT_BLOB [P] Length prefixed bytes
+ VT_STREAM [P] Name of the stream follows
+ VT_STORAGE [P] Name of the storage follows
+ VT_STREAMED_OBJECT [P] Stream contains an object
+ VT_STORED_OBJECT [P] Storage contains an object
+ VT_VERSIONED_STREAM [P] Stream with a GUID version
+ VT_BLOB_OBJECT [P] Blob contains an object
+ VT_CF [P] Clipboard format
+ VT_CLSID [P] A Class ID
+ VT_VECTOR [P] simple counted array
+ VT_ARRAY [V] SAFEARRAY*
+ VT_BYREF [V] void* for local use
+ VT_BSTR_BLOB Reserved for system use
+}
+
+// VARENUM's
+
+ VT_EMPTY = 0;
+ VT_NULL = 1;
+ VT_I2 = 2;
+ VT_I4 = 3;
+ VT_R4 = 4;
+ VT_R8 = 5;
+ VT_CY = 6;
+ VT_DATE = 7;
+ VT_BSTR = 8;
+ VT_DISPATCH = 9;
+ VT_ERROR = 10;
+ VT_BOOL = 11;
+ VT_VARIANT = 12;
+ VT_UNKNOWN = 13;
+ VT_DECIMAL = 14;
+// VBA reserves 15 for future use
+ VT_I1 = 16;
+ VT_UI1 = 17;
+ VT_UI2 = 18;
+ VT_UI4 = 19;
+ VT_I8 = 20;
+ VT_UI8 = 21;
+ VT_INT = 22;
+ VT_UINT = 23;
+ VT_VOID = 24;
+ VT_HRESULT = 25;
+ VT_PTR = 26;
+ VT_SAFEARRAY = 27;
+ VT_CARRAY = 28;
+ VT_USERDEFINED = 29;
+ VT_LPSTR = 30;
+ VT_LPWSTR = 31;
+// VBA reserves 32-35 for future use
+ VT_RECORD = 36;
+ VT_INT_PTR = 37;
+ VT_UINT_PTR = 38;
+
+ VT_FILETIME = 64;
+ VT_BLOB = 65;
+ VT_STREAM = 66;
+ VT_STORAGE = 67;
+ VT_STREAMED_OBJECT = 68;
+ VT_STORED_OBJECT = 69;
+ VT_BLOB_OBJECT = 70;
+ VT_CF = 71;
+ VT_CLSID = 72;
+ VT_VERSIONED_STREAM = 73;
+
+ VT_BSTR_BLOB = $0fff;
+
+ VT_VECTOR = $1000;
+ VT_ARRAY = $2000;
+ VT_BYREF = $4000;
+ VT_RESERVED = $8000;
+
+ VT_ILLEGAL = $ffff;
+ VT_ILLEGALMASKED = $0fff;
+ VT_TYPEMASK = $0fff;
+
+
+
+//
+// Common typedefs for paramaters used in data view API's, gleamed
+// from dvobj.h
+//
+
+// Data/View aspect; specifies the desired aspect of the object when
+// drawing or getting data.
+
+ DVASPECT_CONTENT = 1;
+ DVASPECT_THUMBNAIL = 2;
+ DVASPECT_ICON = 4;
+ DVASPECT_DOCPRINT = 8;
+
+//****** Storage types *************************************************
+
+
+// Storage commit types
+
+ STGC_DEFAULT = 0;
+ STGC_OVERWRITE = 1;
+ STGC_ONLYIFCURRENT = 2;
+ STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4;
+ STGC_CONSOLIDATE = 8;
+
+ STGMOVE_MOVE = 0;
+ STGMOVE_COPY = 1;
+ STGMOVE_SHALLOWCOPY = 2;
+
+ STATFLAG_DEFAULT = 0;
+ STATFLAG_NONAME = 1;
+ STATFLAG_NOOPEN = 2;
+
+// #########################################################################
+//
+// Constants for the call context
+//
+
+ WDT_INPROC_CALL = ULONG($48746457);
+ WDT_REMOTE_CALL = ULONG($52746457);
+ WDT_INPROC64_CALL = ULONG($50746457);
+
+ COLE_DEFAULT_PRINCIPAL {: pOleStr?} = pOleStr(-1);
+ COLE_DEFAULT_AUTHINFO {: pointer?} = pointer(-1);
+
+// DISPID reserved to indicate an \"unknown\" name
+// only reserved for data members (properties); reused as a method dispid below
+
+ DISPID_UNKNOWN = -1;
+
+// DISPID reserved for the \"value\" property
+
+ DISPID_VALUE = 0;
+
+// The following DISPID is reserved to indicate the param")
+// that is the right-hand-side (or \"put\" value) of a PropertyPut")
+
+ DISPID_PROPERTYPUT = -3;
+
+// DISPID reserved for the standard \"NewEnum\" method
+
+ DISPID_NEWENUM = -4;
+
+// DISPID reserved for the standard \"Evaluate\" method
+
+ DISPID_EVALUATE = -5;
+ DISPID_CONSTRUCTOR = -6;
+ DISPID_DESTRUCTOR = -7;
+ DISPID_COLLECT = -8;
+
+ DISPATCH_METHOD = $1;
+ DISPATCH_PROPERTYGET = $2;
+ DISPATCH_PROPERTYPUT = $4;
+ DISPATCH_PROPERTYPUTREF = $8;
+
+ USERCLASSTYPE_FULL = 1;
+ USERCLASSTYPE_SHORT = 2;
+ USERCLASSTYPE_APPNAME = 3;
+
+// The range -500 through -999 is reserved for Controls
+// The range 0x80010000 through 0x8001FFFF is reserved for Controls
+// The range -5000 through -5499 is reserved for ActiveX Accessability
+// The range -2000 through -2499 is reserved for VB5
+// The range -3900 through -3999 is reserved for Forms
+// The range -5500 through -5550 is reserved for Forms
+// The remainder of the negative DISPIDs are reserved for future use
+
+
+ DESCKIND_NONE = 0;
+ DESCKIND_FUNCDESC = 1;
+ DESCKIND_VARDESC = 2;
+ DESCKIND_TYPECOMP = 3;
+ DESCKIND_IMPLICITAPPOBJ = 4;
+ DESCKIND_MAX = 5;
+
+
+ SYS_WIN16 = 0;
+ SYS_WIN32 = 1;
+ SYS_MAC = 2;
+ SYS_WIN64 = 3;
+
+ REGKIND_DEFAULT = 0;
+ REGKIND_REGISTER = 1;
+ REGKIND_NONE = 2;
+
+ INTERFACESAFE_FOR_UNTRUSTED_CALLER = $00000001; // Caller of interface may be untrusted
+ INTERFACESAFE_FOR_UNTRUSTED_DATA = $00000002; // Data passed into interface may be untrusted
+ INTERFACE_USES_DISPEX = $00000004; // Object knows to use IDispatchEx
+ INTERFACE_USES_SECURITY_MANAGER = $00000008; // Object knows to use IInternetHostSecurityManager
+
+ LIBFLAG_FRESTRICTED = $01;
+ LIBFLAG_FCONTROL = $02;
+ LIBFLAG_FHIDDEN = $04;
+ LIBFLAG_FHASDISKIMAGE = $08;
+ TYPEFLAG_FAPPOBJECT = $01;
+ TYPEFLAG_FCANCREATE = $02;
+ TYPEFLAG_FLICENSED = $04;
+ TYPEFLAG_FPREDECLID = $08;
+ TYPEFLAG_FHIDDEN = $10;
+ TYPEFLAG_FCONTROL = $20;
+ TYPEFLAG_FDUAL = $40;
+ TYPEFLAG_FNONEXTENSIBLE = $80;
+ TYPEFLAG_FOLEAUTOMATION = $100;
+ TYPEFLAG_FRESTRICTED = $200;
+ TYPEFLAG_FAGGREGATABLE = $400;
+ TYPEFLAG_FREPLACEABLE = $800;
+ TYPEFLAG_FDISPATCHABLE = $1000;
+ TYPEFLAG_FREVERSEBIND = $2000;
+ TYPEFLAG_FPROXY = $4000;
+
+ FUNCFLAG_FRESTRICTED = $1;
+ FUNCFLAG_FSOURCE = $2;
+ FUNCFLAG_FBINDABLE = $4;
+ FUNCFLAG_FREQUESTEDIT = $8;
+ FUNCFLAG_FDISPLAYBIND = $10;
+ FUNCFLAG_FDEFAULTBIND = $20;
+ FUNCFLAG_FHIDDEN = $40;
+ FUNCFLAG_FUSESGETLASTERROR = $80;
+ FUNCFLAG_FDEFAULTCOLLELEM = $100;
+ FUNCFLAG_FUIDEFAULT = $200;
+ FUNCFLAG_FNONBROWSABLE = $400;
+ FUNCFLAG_FREPLACEABLE = $800;
+ FUNCFLAG_FIMMEDIATEBIND = $1000;
+
+ VARFLAG_FREADONLY = $1;
+ VARFLAG_FSOURCE = $2;
+ VARFLAG_FBINDABLE = $4;
+ VARFLAG_FREQUESTEDIT = $8;
+ VARFLAG_FDISPLAYBIND = $10;
+ VARFLAG_FDEFAULTBIND = $20;
+ VARFLAG_FHIDDEN = $40;
+ VARFLAG_FRESTRICTED = $80;
+ VARFLAG_FDEFAULTCOLLELEM = $100;
+ VARFLAG_FUIDEFAULT = $200;
+ VARFLAG_FNONBROWSABLE = $400;
+ VARFLAG_FREPLACEABLE = $800;
+ VARFLAG_FIMMEDIATEBIND = $1000;
+
+ FADF_AUTO = USHORT($0001); // array is allocated on the stack
+ FADF_STATIC = USHORT($0002); // array is staticly allocated
+ FADF_EMBEDDED = USHORT($0004); // array is embedded in a structure
+ FADF_FIXEDSIZE = USHORT($0010); // may not be resized or reallocated
+ FADF_RECORD = USHORT($0020); // an array of records
+ FADF_HAVEIID = USHORT($0040); // with FADF_DISPATCH, FADF_UNKNOWN
+ // array has an IID for interfaces
+ FADF_HAVEVARTYPE = USHORT($0080); // array has a VT type
+ FADF_BSTR = USHORT($0100); // an array of BSTRs
+ FADF_UNKNOWN = USHORT($0200); // an array of IUnknown*
+ FADF_DISPATCH = USHORT($0400); // an array of IDispatch*
+ FADF_VARIANT = USHORT($0800); // an array of VARIANTs
+ FADF_RESERVED = USHORT($F008); // reserved bits
+
+// IMPLTYPE Flags
+
+ IMPLTYPEFLAG_FDEFAULT = USHORT($1);
+ IMPLTYPEFLAG_FSOURCE = USHORT($2);
+ IMPLTYPEFLAG_FRESTRICTED = USHORT($4);
+ IMPLTYPEFLAG_FDEFAULTVTABLE = USHORT($8);
+
+ PARAMFLAG_NONE = USHORT($00);
+ PARAMFLAG_FIN = USHORT($01);
+ PARAMFLAG_FOUT = USHORT($02);
+ PARAMFLAG_FLCID = USHORT($04);
+ PARAMFLAG_FRETVAL = USHORT($08);
+ PARAMFLAG_FOPT = USHORT($10);
+ PARAMFLAG_FHASDEFAULT = USHORT($20);
+ PARAMFLAG_FHASCUSTDATA = USHORT($40);
+
+ VAR_PERINSTANCE = 0;
+ VAR_STATIC = 1;
+ VAR_CONST = 2;
+ VAR_DISPATCH = 3;
+
+ // notification messages used by the dynamic typeinfo protocol.
+
+ CHANGEKIND_ADDMEMBER = 0;
+ CHANGEKIND_DELETEMEMBER = 1;
+ CHANGEKIND_SETNAMES = 2;
+ CHANGEKIND_SETDOCUMENTATION = 3;
+ CHANGEKIND_GENERAL = 4;
+ CHANGEKIND_INVALIDATE = 5;
+ CHANGEKIND_CHANGEFAILED = 6;
+ CHANGEKIND_MAX = 7;
+
+ INVOKE_FUNC = 1;
+ INVOKE_PROPERTYGET = 2;
+ INVOKE_PROPERTYPUT = 4;
+ INVOKE_PROPERTYPUTREF = 8;
+
+ TKIND_ENUM = 0;
+ TKIND_RECORD = 1;
+ TKIND_MODULE = 2;
+ TKIND_INTERFACE = 3;
+ TKIND_DISPATCH = 4;
+ TKIND_COCLASS = 5;
+ TKIND_ALIAS = 6;
+ TKIND_UNION = 7;
+ TKIND_MAX = 8; // end of enum marker
+
+ SF_ERROR = VT_ERROR;
+ SF_I1 = VT_I1;
+ SF_I2 = VT_I2;
+ SF_I4 = VT_I4;
+ SF_I8 = VT_I8;
+ SF_BSTR = VT_BSTR;
+ SF_UNKNOWN = VT_UNKNOWN;
+ SF_DISPATCH = VT_DISPATCH;
+ SF_VARIANT = VT_VARIANT;
+ SF_RECORD = VT_RECORD;
+ SF_HAVEIID = VT_UNKNOWN OR VT_RESERVED;
+ IDLFLAG_NONE = PARAMFLAG_NONE;
+ IDLFLAG_FIN = PARAMFLAG_FIN;
+ IDLFLAG_FOUT = PARAMFLAG_FOUT;
+ IDLFLAG_FLCID = PARAMFLAG_FLCID;
+ IDLFLAG_FRETVAL = PARAMFLAG_FRETVAL;
+
+ CC_FASTCALL = 0;
+ CC_CDECL = 1;
+ CC_MSCPASCAL = 2;
+ CC_PASCAL = CC_MSCPASCAL;
+ CC_MACPASCAL = 3;
+ CC_STDCALL = 4;
+ CC_FPFASTCALL = 5;
+ CC_SYSCALL = 6;
+ CC_MPWCDECL = 7;
+ CC_MPWPASCAL = 8;
+ CC_MAX = 9; // end of enum marker
+
+ FUNC_VIRTUAL = 0;
+ FUNC_PUREVIRTUAL = 1;
+ FUNC_NONVIRTUAL = 2;
+ FUNC_STATIC = 3;
+ FUNC_DISPATCH = 4;
+
+// objbase.h
+
+ MARSHALINTERFACE_MIN = 500; // minimum number of bytes for interface marshl
+
+//
+// Common typedefs for paramaters used in Storage API's, gleamed from storage.h
+// Also contains Storage error codes, which should be moved into the storage
+// idl files.
+//
+
+
+ CWCSTORAGENAME = 32;
+
+// Storage instantiation modes
+ STGM_DIRECT = $00000000;
+ STGM_TRANSACTED = $00010000;
+ STGM_SIMPLE = $08000000;
+ STGM_READ = $00000000;
+ STGM_WRITE = $00000001;
+ STGM_READWRITE = $00000002;
+ STGM_SHARE_DENY_NONE = $00000040;
+ STGM_SHARE_DENY_READ = $00000030;
+ STGM_SHARE_DENY_WRITE = $00000020;
+ STGM_SHARE_EXCLUSIVE = $00000010;
+ STGM_PRIORITY = $00040000;
+ STGM_DELETEONRELEASE = $04000000;
+ STGM_NOSCRATCH = $00100000; {WINNT+}
+ STGM_CREATE = $00001000;
+ STGM_CONVERT = $00020000;
+ STGM_FAILIFTHERE = $00000000;
+ STGM_NOSNAPSHOT = $00200000;
+ STGM_DIRECT_SWMR = $00400000; { Win2000+}
+
+// flags for internet asyncronous and layout docfile
+ ASYNC_MODE_COMPATIBILITY = $00000001;
+ ASYNC_MODE_DEFAULT = $00000000;
+
+ STGTY_REPEAT = $00000100;
+ STG_TOEND = $FFFFFFFF;
+
+ STG_LAYOUT_SEQUENTIAL = $00000000;
+ STG_LAYOUT_INTERLEAVED = $00000001;
+
+ STGFMT_STORAGE = 0;
+ STGFMT_NATIVE = 1;
+ STGFMT_FILE = 3;
+ STGFMT_ANY = 4;
+ STGFMT_DOCFILE = 5;
+
+// This is a legacy define to allow old component to builds
+ STGFMT_DOCUMENT = 0;
+
+
+// COM initialization flags; passed to CoInitialize.
+ COINIT_APARTMENTTHREADED = $2; // Apartment model
+
+ // These constants are only valid on Windows NT 4.0
+
+ COINIT_MULTITHREADED = $0; // OLE calls objects on any thread.
+ COINIT_DISABLE_OLE1DDE = $4; // Don't use DDE for Ole1 support.
+ COINIT_SPEED_OVER_MEMORY = $8; // Trade memory for speed.
+
+ SMEXF_SERVER = $01; // server side aggregated std marshaler
+ SMEXF_HANDLER = $02; // client side (handler) agg std marshaler
+
+ COWAIT_WAITALL = 1;
+ COWAIT_ALERTABLE = 2;
+
+ DOCMISC_CANCREATEMULTIPLEVIEWS = 1;
+ DOCMISC_SUPPORTCOMPLEXRECTANGLES = 2;
+ DOCMISC_CANTOPENEDIT = 4; // fails the IOleDocumentView::Open method
+ DOCMISC_NOFILESUPPORT = 8; // does not support read/writing to a file
+
+ PID_DICTIONARY = PROPID($00000000);
+ PID_CODEPAGE = PROPID($00000001);
+ PID_FIRST_USABLE = PROPID($00000002);
+ PID_FIRST_NAME_DEFAULT = PROPID($00000fff);
+ PID_LOCALE = PROPID($80000000);
+ PID_MODIFY_TIME = PROPID($80000001);
+ PID_SECURITY = PROPID($80000002);
+ PID_BEHAVIOR = PROPID($80000003);
+ PID_ILLEGAL = PROPID($ffffffff);
+ PID_MIN_READONLY = PROPID($80000000);
+ PID_MAX_READONLY = PROPID($bfffffff);
+ PIDDI_THUMBNAIL = DWORD($00000002);// VT_BLOB
+ PIDSI_TITLE = DWORD($00000002); // VT_LPSTR
+ PIDSI_SUBJECT = DWORD($00000003); // VT_LPSTR
+ PIDSI_AUTHOR = DWORD($00000004); // VT_LPSTR
+ PIDSI_KEYWORDS = DWORD($00000005); // VT_LPSTR
+ PIDSI_COMMENTS = DWORD($00000006); // VT_LPSTR
+ PIDSI_TEMPLATE = DWORD($00000007); // VT_LPSTR
+ PIDSI_LASTAUTHOR = DWORD($00000008); // VT_LPSTR
+ PIDSI_REVNUMBER = DWORD($00000009); // VT_LPSTR
+ PIDSI_EDITTIME = DWORD($0000000a); // VT_FILETIME
+ PIDSI_LASTPRINTED = DWORD($0000000b); // VT_FILETIME
+ PIDSI_CREATE_DTM = DWORD($0000000c); // VT_FILETIME
+ PIDSI_LASTSAVE_DTM = DWORD($0000000d); // VT_FILETIME
+ PIDSI_PAGECOUNT = DWORD($0000000e); // VT_I4
+ PIDSI_WORDCOUNT = DWORD($0000000f); // VT_I4
+ PIDSI_CHARCOUNT = DWORD($00000010); // VT_I4
+ PIDSI_THUMBNAIL = DWORD($00000011); // VT_CF
+ PIDSI_APPNAME = DWORD($00000012); // VT_LPSTR
+ PIDSI_DOC_SECURITY = DWORD($00000013); // VT_I4
+ PIDDSI_CATEGORY = $00000002; // VT_LPSTR
+ PIDDSI_PRESFORMAT = $00000003; // VT_LPSTR
+ PIDDSI_BYTECOUNT = $00000004; // VT_I4
+ PIDDSI_LINECOUNT = $00000005; // VT_I4
+ PIDDSI_PARCOUNT = $00000006; // VT_I4
+ PIDDSI_SLIDECOUNT = $00000007; // VT_I4
+ PIDDSI_NOTECOUNT = $00000008; // VT_I4
+ PIDDSI_HIDDENCOUNT = $00000009; // VT_I4
+ PIDDSI_MMCLIPCOUNT = $0000000A; // VT_I4
+ PIDDSI_SCALE = $0000000B; // VT_BOOL
+ PIDDSI_HEADINGPAIR = $0000000C; // VT_VARIANT |VT_VECTOR
+ PIDDSI_DOCPARTS = $0000000D; // VT_LPSTR |VT_VECTOR
+ PIDDSI_MANAGER = $0000000E; // VT_LPSTR
+ PIDDSI_COMPANY = $0000000F; // VT_LPSTR
+ PIDDSI_LINKSDIRTY = $00000010; // VT_BOOL
+
+// FMTID_MediaFileSummaryInfo - Property IDs
+
+ PIDMSI_EDITOR = DWord($00000002); // VT_LPWSTR
+ PIDMSI_SUPPLIER = DWord($00000003); // VT_LPWSTR
+ PIDMSI_SOURCE = DWord($00000004); // VT_LPWSTR
+ PIDMSI_SEQUENCE_NO = DWord($00000005); // VT_LPWSTR
+ PIDMSI_PROJECT = DWord($00000006); // VT_LPWSTR
+ PIDMSI_STATUS = DWord($00000007); // VT_UI4
+ PIDMSI_OWNER = DWord($00000008); // VT_LPWSTR
+ PIDMSI_RATING = DWord($00000009); // VT_LPWSTR
+ PIDMSI_PRODUCTION = DWord($0000000A); // VT_FILETIME (UTC)
+ PIDMSI_COPYRIGHT = DWord($0000000B); // VT_LPWSTR
+ PRSPEC_INVALID = ULONG($ffffffff);
+ PRSPEC_LPWSTR = ULONG(0);
+ PRSPEC_PROPID = ULONG(1);
+ PROPSETFLAG_DEFAULT = DWORD(0);
+ PROPSETFLAG_NONSIMPLE = DWORD(1);
+ PROPSETFLAG_ANSI = DWORD(2);
+
+TYPE
+ VARTYPE = USHORT;
+
+//TypeInfo stuff.
+
+ DISPID = Long ;
+ SCODE = Long;
+ pSCODE = ^SCODE;
+ lpDISPID = ^DISPID;
+ MEMBERID = DispId;
+ HREFTYPE = DWord;
+ TResultList = array[0..high(integer) div 4-50] of HResult;
+ PResultList = ^TResultList;
+
+ PSYSINT = ^SYSINT;
+ SYSINT = LongInt;
+ PSYSUINT = ^SYSUINT;
+ SYSUINT = LongWord;
+
+// Enums
+ VARKIND = DWord;
+ DESCKIND = DWord;
+ SYSKIND = DWord;
+ TSYSKIND = SYSKIND;
+ REGKIND = DWord;
+ TREGKIND = REGKIND;
+ FUNCKIND = DWord;
+ CHANGEKIND = DWord;
+ CALLCONV = DWord;
+
+ PIDMSI_STATUS_VALUE = (
+ PIDMSI_STATUS_NORMAL = 0,
+ PIDMSI_STATUS_NEW,
+ PIDMSI_STATUS_PRELIM,
+ PIDMSI_STATUS_DRAFT,
+ PIDMSI_STATUS_INPROGRESS,
+ PIDMSI_STATUS_EDIT,
+ PIDMSI_STATUS_REVIEW,
+ PIDMSI_STATUS_PROOF,
+ PIDMSI_STATUS_FINAL,
+ PIDMSI_STATUS_OTHER = $7FFF
+ );
+ TPIDMSI_STATUS_VALUE= PIDMSI_STATUS_Value;
+
+
+
+ PCOAUTHIDENTITY = ^TCOAUTHIDENTITY;
+ _COAUTHIDENTITY = Record
+ User : PUSHORT;
+ UserLength : ULONG;
+ Domain : PUSHORT;
+ DomainLength : ULong;
+ Password : PUSHORT;
+ PassWordLength : ULong;
+ Flags : ULong;
+ End;
+
+ COAUTHIDENTITY = _COAUTHIDENTITY;
+ TCOAUTHIDENTITY = _COAUTHIDENTITY;
+
+ PCOAUTHINFO = ^TCOAUTHINFO;
+ COAuthInfo = Record
+ AuthnSvc : DWord;
+ AuthzSvc : DWord;
+ ServerPrincName : LPWSTR;
+ AuthnLevel : DWord;
+ ImpersonationLevel : DWord;
+ AuthIdentityData : PCOAUTHIDENTITY;
+ Capabilities : DWord;
+ END;
+ TCOAUTHINFO = COAUTHINFO;
+
+ PCOSERVERINFO = ^TCOSERVERINFO;
+ _COSERVERINFO = Record
+ dwReserved1 : DWord;
+ pwszName : LPWSTR;
+ pAuthInfo : PCoAuthInfo;
+ dwReserved2 : DWord;
+ end;
+ TCOSERVERINFO = _COSERVERINFO;
+ PMultiQI = ^Multi_QI;
+ tagMULTI_QI = Record
+ iid: piid; // pass this one in
+ itf: IUnknown; // get these out (you must set to NULL before calling)
+ hr : HResult;
+ END;
+ MULTI_QI = TagMULTI_QI;
+ PMulti_QI = PMultiQI;
+ TMultiQI = tagMULTI_QI;
+
+ PMultiQIArray = ^TMultiQIArray;
+ TMultiQIArray = array[0..65535] of TMultiQI;
+
+
+ HContext = Pointer;
+ ApartmentID = DWord;
+
+
+//****** Critical Section Wrappers ***********************************
+
+// LCID = WORD;
+// LANGID = USHORT;
+
+// #######################################################################
+//
+// User marshal support for Windows data types.
+
+//
+// Frequently used helpers: sized blobs
+//
+// Never put [user_marshal] or [wire_marshal] on the helpers directly.
+//
+
+// Flagged blobs.
+
+ _FLAGGED_BYTE_BLOB = Record
+ fFlags : ULong;
+ clSize : ULong;
+ abdata : array[0..0] of byte;
+ End;
+ FLAGGED_BYTE_BLOB = _FLAGGED_BYTE_BLOB;
+ UP_FLAGGED_BYTE_BLOB = ^FLAGGED_BYTE_BLOB;
+
+ _FLAGGED_WORD_BLOB = Record
+ fFlags : ULong;
+ clSize : ULong;
+ abdata : array[0..0] of USHORT;
+ End;
+ FLAGGED_WORD_BLOB = _FLAGGED_WORD_BLOB;
+ UP_FLAGGED_WORD_BLOB = ^FLAGGED_WORD_BLOB;
+
+ _FLAGGED_DWORD_BLOB = Record
+ fFlags : ULong;
+ clSize : ULong;
+ abdata : array[0..0] of ULONG;
+ End;
+ FLAGGED_DWORD_BLOB = _FLAGGED_DWORD_BLOB;
+ FLAGGED_UP_DWORD_BLOB = ^FLAGGED_DWORD_BLOB;
+
+// Simple blobs.
+
+ _BYTE_BLOB = Record
+ clSize : ULong;
+ abdata : array[0..0] of byte;
+ End;
+ BYTE_BLOB = _BYTE_BLOB;
+ UP_BYTE_BLOB = ^BYTE_BLOB;
+
+ _WORD_BLOB = Record
+ clSize : ULong;
+ abdata : array[0..0] of USHORT;
+ End;
+ WORD_BLOB = _WORD_BLOB;
+ UP_WORD_BLOB = ^WORD_BLOB;
+
+ _DWORD_BLOB = Record
+ clSize : ULong;
+ abdata : array[0..0] of ULONG;
+ End;
+ DWORD_BLOB = _DWORD_BLOB;
+ UP_DWORD_BLOB = ^DWORD_BLOB;
+
+// Frequently used helpers with sized pointers.
+
+ _BYTE_SIZEDARR = Record
+ clsize : ULong;
+ Data : PByte;
+ End;
+ BYTE_SIZEDARR = _BYTE_SIZEDARR;
+
+ _SHORT_SIZEDARR = Record
+ clsize : ULong;
+ Data : PSHORT;
+ End;
+ SHORT_SIZEDARR = _SHORT_SIZEDARR;
+
+ _LONG_SIZEDARR = Record
+ clsize : ULong;
+ Data : PLONG;
+ End;
+ LONG_SIZEDARR = _LONG_SIZEDARR;
+ HYPER = LONGLONG;
+ PHYPER = ^HYPER;
+ _HYPER_SIZEDARR = Record
+ clsize : ULong;
+ Data : PHYPER;
+ End;
+ HYPER_SIZEDARR = _HYPER_SIZEDARR;
+
+
+// #########################################################################
+//
+// CLIPFORMAT
+//
+
+ userCLIPFORMAT = Record
+ FContext : Long;
+ CASE INTEGER OF
+ 0 : (dwvalue : DWORD);
+ 1 : (szName : poleStr);
+ End;
+
+ wireCLIPFORMAT = ^userCLIPFORMAT;
+
+
+// #########################################################################
+//
+// Good for most of the gdi handles.
+
+ _GDI_NONREMOTE = Record
+ FContext : Long;
+ Case Integer Of
+ 0 : (HInProc : Long);
+ 1 : (HRemote : DWORD_BLOB);
+ END;
+ GDI_NONREMOTE = _GDI_NONREMOTE;
+
+// #########################################################################
+//
+// HGLOBAL
+//
+// A global may be Null or may be non-NULL with 0 length.
+
+ _userHGLOBAL = Record
+ FContext : Long;
+ CASE Integer OF
+ 0 : (hInproc : Long);
+ 1 : (hRemote : UP_FLAGGED_BYTE_BLOB);
+ 2 : (hInproc64: int64);
+ End;
+ userHGlobal = _userHGLOBAL;
+ wireHGLOBAL = ^userHGLOBAL;
+
+// #########################################################################
+//
+// HMETAFILE
+//
+ _userHMETAFILE = Record
+ fContext : Long;
+ Case Integer OF
+ 0 : (hInproc : Long);
+ 1 : (hRemote : up_byte_blob);
+ 2 : (hInProc64 : Int64);
+ End;
+ userHMETAFILE = _userHMETAFILE;
+ puserHMETAFILE = ^userHMETAFILE;
+
+// #########################################################################
+//
+// HMETAFILEPICT
+//
+
+ _remoteMETAFILEPICT = Record
+ mm : Long;
+ xExt : Long;
+ yExt : Long;
+ mgf : puserHMETAFILE;
+ End;
+
+ remoteMETAFILEPICT = _remoteMETAFILEPICT;
+ premoteMETAFILEPICT = ^remoteMETAFILEPICT;
+
+ _userHMETAFILEPICT = Record
+ fContext : Long;
+ Case Integer OF
+ 0 : (hInproc : Long);
+ 1 : (hRemote : premoteMETAFILEPICT);
+ 2 : (hInProc64 : Int64);
+ End;
+ userHMETAFILEPICT = _userHMETAFILEPICT;
+
+
+// #########################################################################
+//
+// HENHMETAFILE
+//
+
+ _userHENHMETAFILE = Record
+ fContext : Long;
+ Case Integer OF
+ 0 : (hInproc : Long);
+ 1 : (hRemote : up_byte_blob);
+ 2 : (hInProc64 : Int64);
+ End;
+ userHENHMETAFILE = _userHENHMETAFILE;
+ puserHENHMETAFILE = ^userHENHMETAFILE;
+
+// #########################################################################
+//
+// HBITMAP
+//
+
+// RemHBITMAP was just a byte blob, but the whole bitmap structure was copied
+// at the beginning of the buffer.
+
+// So, we take BITMAP fields from wingdi.x
+
+
+ _userBITMAP = Record
+ bmType,
+ bmWidth,
+ bmHeight,
+ bmWidthBytes : Long;
+ bmPlanes,
+ bmBitsPixel : Word;
+ cvsize : ULONG;
+ buffer : pbyte;
+ End;
+
+ userBITMAP = _userBITMAP;
+ puserBITMAP = ^userBITMAP;
+
+ _userHBITMAP = Record
+ fContext : Long;
+ Case Integer OF
+ 0 : (hInproc : Long);
+ 1 : (hRemote : puserBITMAP);
+ 2 : (hInProc64 : Int64);
+ End;
+ userHBITMAP = _userHBITMAP;
+ puserHBITMAP = ^userHBITMAP;
+
+
+// #########################################################################
+//
+// HPALETTE
+//
+
+// PALETTEENTRY is in wingdi.x, it is a struct with 4 bytes.
+// LOGPALETTE is in wingdi.x, it is a conf struct with paletteentries and
+// a version field
+
+ _userHpalette = Record
+ fContext : Long;
+ Case Integer OF
+ 0 : (hInproc : Long);
+ 1 : (hRemote : logpalette);
+ 2 : (hInProc64 : Int64);
+ End;
+ userHpalette = _userHpalette;
+ puserHpalette = ^userHpalette;
+
+// #########################################################################
+//
+// Handles passed locally as longs.
+//
+
+ _RemotableHandle = Record
+ fContext : Long;
+ Case Integer OF
+ 0 : (hInproc : Long);
+ 1 : (hRemote : Long);
+ End;
+ RemotableHandle = _RemotableHandle;
+
+
+ wireHWND = ^RemotableHandle;
+ wireHMENU = ^RemotableHandle;
+ wireHACCEL = ^RemotableHandle;
+ wireHBRUSH = ^RemotableHandle;
+ wireHFONT = ^RemotableHandle;
+ wireHDC = ^RemotableHandle;
+ wireHICON = ^RemotableHandle;
+ HCursor = HICON;
+
+
+ tagTEXTMETRICW = Record
+ tmHeight,
+ tmAscent,
+ tmDescent,
+ tmInternalLeading,
+ tmExternalLeading,
+ tmAveCharWidth,
+ tmMaxCharWidth,
+ tmWeight,
+ tmOverhang,
+ tmDigitizedAspectX,
+ tmDigitizedAspectY : Long;
+ tmFirstChar,
+ tmLastChar,
+ tmDefaultChar,
+ tmBreakChar : WCHAR;
+ tmItalic,
+ tmUnderlined,
+ tmStruckOut,
+ tmPitchAndFamily,
+ tmCharSet : BYTE;
+ End;
+
+ TEXTMETRICW = tagTEXTMETRICW;
+ PTEXTMETRICW = ^TEXTMETRICW;
+ LPTEXTMETRICW = PTEXTMETRICW;
+ wireHBITMAP = ^userHBITMAP;
+ wireHPALETTE = ^userHPALETTE;
+ wireHENHMETAFILE = ^userHENHMETAFILE;
+ wireHMETAFILE = ^userHMETAFILE;
+ wireHMETAFILEPICT = ^userHMETAFILEPICT;
+ HMetaFilePict = Pointer;
+ HLOCAL = HGLOBAL;
+// Date = Double;
+
+{****************************************************************************
+ * Binding Interfaces
+ ****************************************************************************}
+
+ tagBIND_OPTS = Record
+ cvStruct, // sizeof(BIND_OPTS)
+ grfFlags,
+ grfMode,
+ dwTickCountDeadline : DWord;
+ End;
+ TBind_Opts = tagBIND_OPTS;
+ PBind_Opts = ^TBind_Opts;
+ TBindOpts = tagBIND_OPTS;
+ PBindOpts = ^TBindOpts;
+ Bind_Opts = tagBind_opts;
+
+ tagBIND_OPTS2_CPP = Record
+ dwTrackFlags,
+ dwClassContext : Dword;
+ Locale : LCID;
+ ServerInfo : pCoServerInfo;
+ End;
+
+ TBind_Opts2_CPP = tagBIND_OPTS2_CPP;
+ PBind_Opts2_CPP = ^TBind_Opts2_CPP;
+
+
+ tagBind_OPTS2 = Record
+ cvStruct, // sizeof(BIND_OPTS)
+ grfFlags,
+ grfMode,
+ dwTickCountDeadline : DWord;
+ dwTrackFlags,
+ dwClassContext : DWord;
+ Locale : LCID;
+ ServerInfo : pCoServerInfo;
+ End;
+
+ TBind_Opts2 = tagBIND_OPTS2;
+ PBind_Opts2 = ^TBind_Opts2;
+
+// ****************************************************************************
+// * Structured Storage Interfaces
+// ****************************************************************************
+
+
+
+ tagSTATSTG = types.tagSTATSTG;
+
+ TStatStg = tagSTATSTG;
+ PStatStg = types.PStatStg;
+ STATSTG = TStatStg;
+
+{ TagRemSNB = Record
+ ulCntStr : ULong;
+ ulCntChar : ULong;
+ [size_is(ulCntChar)] OLECHAR rgString[];
+ End;
+ RemSNB=TagRemSNB
+ WireSNB=^RemSNB}
+ SNB = ^PoleStr;
+ tagDVTARGETDEVICE = Record
+ tdSize : DWord;
+ tdDriverNameOffset,
+ tdDeviceNameOffset,
+ tdPortNameOffset,
+ tdExtDevmodeOffset : Word;
+ Data : Record End;
+ End;
+
+ DVTARGETDEVICE = TagDVTARGETDEVICE;
+ PDVTARGETDEVICE = ^tagDVTARGETDEVICE;
+ LPCLIPFORMAT = ^TCLIPFORMAT;
+ TCLIPFORMAT = Word;
+ CLIPFORMAT = TCLIPFORMAT;
+ PClipFormat = LPCLIPFORMAT;
+
+ tagFORMATETC = Record
+ CfFormat : Word {TCLIPFORMAT};
+ Ptd : PDVTARGETDEVICE;
+ dwAspect : DWORD;
+ lindex : Long;
+ tymed : DWORD;
+ End;
+ FORMATETC = TagFORMATETC;
+ TFORMATETC = FORMATETC;
+ LPFORMATETC = ^FORMATETC;
+ PFormatEtc = LPFORMATETC;
+
+ // Stats for data; used by several enumerations and by at least one
+ // implementation of IDataAdviseHolder; if a field is not used, it
+ // will be NULL.
+
+
+ tagRemSTGMEDIUM = Record
+ tymed : DWord;
+ dwHandleType : DWord;
+ pData,
+ pUnkForRelease,
+ cbData : ULong;
+ Data : Record end;
+ End;
+
+ RemSTGMEDIUM = TagRemSTGMedium;
+
+ TagSTGMEDIUM = Record
+ Tymed : DWord;
+ Case Integer Of
+ 0 : (HBITMAP : hBitmap; PUnkForRelease : Pointer {IUnknown});
+ 1 : (HMETAFILEPICT : hMetaFilePict );
+ 2 : (HENHMETAFILE : hEnhMetaFile );
+ 3 : (HGLOBAL : hGlobal );
+ 4 : (lpszFileName : LPOLESTR );
+ 5 : (pstm : Pointer{IStream} );
+ 6 : (pstg : Pointer{IStorage} );
+ End;
+ USTGMEDIUM = TagSTGMEDIUM;
+ STGMEDIUM = USTGMEDIUM;
+ TStgMedium = TagSTGMEDIUM;
+ PStgMedium = ^TStgMedium;
+
+//
+// wireSTGMEDIUM
+//
+// These flags are #defined (not enumerated) in wingdi.
+// We need to repeat #defines to avoid conflict in the generated file.
+//
+
+ _GDI_OBJECT = Record
+ ObjectType : DWord;
+ Case Integer Of
+ 0 : (HBitmap : WireHBITMAP);
+ 1 : (hPalette: wireHPALETTE);
+ 2 : (hGeneric: wireHGLOBAL);
+ END;
+ GDI_OBJECT = _GDI_OBJECT;
+
+
+ _userSTGMEDIUM = Record
+ tymed : DWORD;
+ Case Integer OF
+ 0 : (hMetaFilePict : wireHMETAFILEPICT;punkforrelease:Pointer {IUnknown});
+ 1 : (hHEnhMetaFile : wireHENHMETAFILE);
+ 2 : (hGdiHandle : ^GDI_OBJECT);
+ 3 : (HGlobal : wireHGLOBAL);
+ 4 : (lpszFileName : LPOLESTR);
+ 5 : (pstm : ^BYTE_BLOB);
+ 6 : (pstg : ^BYTE_BLOB);
+ END;
+
+ userSTGMEDIUM = _userSTGMEDIUM;
+
+
+ LPSTGMEDIUM = ^STGMEDIUM;
+
+ _userFLAG_STGMEDIUM = Record
+ ContextFlags,
+ fPassOwnership : Long;
+ stgmed : userSTGMEDIUM;
+ End;
+
+ userFLAG_STGMEDIUM = _userFLAG_STGMEDIUM;
+
+ wireFLAG_STGMEDIUM = ^userFLAG_STGMEDIUM;
+
+
+ _FLAG_STGMEDIUM = Record
+ ContextFlags,
+ fPassOwnership : Long;
+ Stgmed : STGMEDIUM;
+ End;
+ FLAG_STGMEDIUM = _FLAG_STGMEDIUM;
+
+
+ VARIANTARG = VARIANT;
+ LPVARIANT = ^VARIANT;
+ LPVARIANTARG = ^VARIANT;
+
+// parameter description
+
+ tagPARAMDESCEX = Record
+ cBytes : ULong; // size of this structure
+ varDefaultValue: VariantARG; // default value of this parameter
+ End;
+
+ PARAMDESCEX = tagPARAMDESCEX;
+ LPPARAMDESCEX = ^PARAMDESCEX;
+
+ tagPARAMDESC = Record
+ pparamdescex: LPPARAMDESCEX ; // valid if PARAMFLAG_FHASDEFAULT bit is set
+ wParamFlags : UShort ; // IN, OUT, etc
+ End;
+
+ PARAMDESC = tagPARAMDESC;
+ LPPARAMDESC = ^PARAMDESC;
+
+
+ tagSAFEARRAYBOUND = Record
+ cElements : ULong;
+ lLbound : Long;
+ End;
+ SAFEARRAYBOUND = tagSAFEARRAYBOUND;
+ LPSAFEARRAYBOUND = ^SAFEARRAYBOUND;
+
+ tagSAFEARRAY = record
+ cDims: USHORT;
+ fFeatures: USHORT;
+ cbElements: ULONG;
+ cLocks: ULONG;
+ pvData: PVOID;
+ rgsabound: array[0..0] of SAFEARRAYBOUND;
+ end;
+ TSafeArray = tagSAFEARRAY;
+ SAFEARRAY = TSafeArray;
+ PSafeArray = ^TSafeArray;
+
+// additional interface information about the incoming call
+ tagINTERFACEINFO = Record
+ Unk : Pointer {IUnknown}; // the pointer to the object
+ IID : Tiid; // interface id
+ wMethod : WORD; // interface method
+ End;
+
+ INTERFACEINFO = tagINTERFACEINFO;
+ LPINTERFACEINFO = ^INTERFACEINFO;
+ RPCOLEDATAREP = ULong;
+ tagRPCOLEMESSAGE = Record
+ Reserved1 : Pointer;
+ DataRepresentation : RPCOLEDATAREP;
+ Buffer : Pointer;
+ cbBuffer,
+ IMethod : ULong;
+ Reserved2 : Array[0..4] Of Pointer;
+ rpcFlags : ULong;
+ End;
+
+ RPCOLEMESSAGE = tagRPCOLEMESSAGE;
+ PRPCOLEMESSAGE = ^RPCOLEMESSAGE;
+
+ tagStorageLayout = Record
+ LayoutType : Dword;
+ pwcsElementName : POleStr;
+ cOffset,
+ cBytes : Large_Integer;
+ End;
+
+ StorageLayout = tagStorageLayout;
+
+ tagSTATDATA = Record
+ // field used by:
+ FORMATETC : Tformatetc; // EnumAdvise, EnumData (cache), EnumFormats
+ advf : DWord; // EnumAdvise, EnumData (cache)
+ padvSink : Pointer {IAdviseSink}; // EnumAdvise
+ dwConnection: DWord; // EnumAdvise
+ End;
+ STATDATA = TagStatData;
+ LPStatData = ^StatData;
+
+ pARRAYDESC = ^ARRAYDESC;
+ pTYPEDESC = ^TYPEDESC;
+ tagTYPEKIND = Dword;
+ TYPEKIND = tagTYPEKIND;
+ TTYPEKIND = TYPEKIND;
+ INVOKEKIND = Dword;
+ tagTYPEDESC = Record
+ Case Integer OF
+ VT_PTR,
+ VT_SAFEARRAY : (lptdesc : PTYPEDESC;vt : VARTYPE);
+ VT_CARRAY : (lpadesc : PARRAYDESC);
+ VT_USERDEFINED : (hreftype : HREFTYPE);
+ End;
+ TYPEDESC = tagTYPEDESC;
+
+
+
+
+ tagARRAYDESC = Record
+ tdescElem : TYPEDESC; // element type
+ cDims : USHORT;
+ rgbounds : ARRAY [0..0] OF SAFEARRAYBOUND; // dimension count
+ End;
+
+ ARRAYDESC = tagARRAYDESC;
+
+ tagIDLDESC = Record
+ dwReserved : pULONG;
+ wIDLFlags : USHORT; // IN, OUT, etc
+ End;
+ IDLDESC = tagIDLDESC;
+ LPIDLDESC = ^IDLDESC;
+
+
+ tagELEMDESC = Record
+ tdesc : TYPEDESC;
+ case Integer Of
+ 0 : (idldesc : IDLDESC);
+ 1 : (paramdesc : PARAMDESC);
+ END;
+
+ ELEMDESC = tagELEMDESC;
+ LPELEMDESC = ^ELEMDESC;
+ tagVARDESC = Record
+ memId : MEMBERID;
+ lpstrSchema : pOleStr;
+ CASE Integer OF
+ VAR_PERINSTANCE,
+ VAR_DISPATCH,
+ VAR_STATIC : (oInst : ULong; // offset of variable within the instance
+ ElemdescVar : ELEMDESC;
+ wVarFlags : WORD;
+ varkind : VARKIND);
+ VAR_CONST : (lpvarValue : PVARIANT); // the value of the constant
+ End;
+ VARDESC = tagVARDESC;
+ LPVARDESC = ^VARDESC;
+ pVARDESC = LPVARDESC;
+ tagDISPPARAMS = Record
+ rgvarg : lpVARIANTARG;
+ rgdispidNamedArgs : lpDISPID;
+ cArgs,
+ cNamedArgs : UINT;
+ End;
+ DISPPARAMS = tagDISPPARAMS;
+ TDispParams = tagDISPPARAMS;
+ PDispParams = ^TDispParams;
+
+ PExcepInfo = ^TExcepInfo;
+ TFNDeferredFillIn = function(info : PExcepInfo): HRESULT;stdcall;
+ tagEXCEPINFO = Record
+ wCode, // An error code describing the error.
+ wReserved : Word;
+ Source, // A source of the exception
+ Description, // A description of the error
+ HelpFile : WideString; // Fully qualified drive, path, and file name
+ dwHelpContext : ULONG; // help context of topic within the help file
+ // We can use ULONG_PTR here, because EXCEPINFO is marshalled by RPC
+ // RPC will marshal pfnDeferredFillIn.
+ pvReserved : pointer;
+ pfnDeferredFillIn : TFNDeferredFillIn;
+ SCODE : scode;
+ End;
+
+ EXCEPINFO = tagEXCEPINFO;
+ TExcepInfo = tagEXCEPINFO;
+
+ tagTYPEATTR = Record
+ GUID : Tguid; // the GUID of the TypeInfo
+ LCID : lcid; // locale of member names and doc strings
+ dwReserved : DWord;
+ memidConstructor, // ID of constructor, MEMBERID_NIL if none
+ memidDestructor : MemberID; // ID of destructor, MEMBERID_NIL if none
+ lpstrSchema : pOleStr;
+
+ cbSizeInstance : ULong; // the size of an instance of this type
+ typekind : TYPEKIND; // the kind of type this typeinfo describes
+ cFuncs, // number of functions
+ cVars, // number of variables / data members
+ cImplTypes, // number of implemented interfaces
+ cbSizeVft, // the size of this types virtual func table
+ cbAlignment, { specifies the alignment requirements for
+ an instance of this type,
+ 0 = align on 64k boundary
+ 1 = byte align
+ 2 = word align
+ 4 = dword align... }
+ wTypeFlags,
+ wMajorVerNum, // major version number
+ wMinorVerNum : Word; // minor version number
+ tdescAlias : TYPEDESC; { if typekind == TKIND_ALIAS this field
+ specifies the type for which this type
+ is an alias }
+ idldescType : IDLDESC; // IDL attributes of the described type
+ END;
+ TYPEATTR = tagTYPEATTR;
+
+ LPTYPEATTR = ^TYPEATTR;
+ PTYPEAttr = LPTYPEATTR;
+
+ tagTLIBATTR = Record
+ GUID : guid;
+ LCID : lcid;
+ SYSKIND : syskind;
+ wMajorVerNum,
+ wMinorVerNum,
+ wLibFlags : Word
+ End;
+
+ TLIBATTR = tagTLIBATTR;
+ LPTLIBATTR = ^tagTLIBATTR;
+ PTLIBAttr = LPTLIBATTR;
+
+ LPFUNCDESC = ^FUNCDESC;
+ PFUNCDESC = LPFUNCDESC;
+
+ tagFUNCDESC = Record
+ memid : MEMBERID;
+ lprgscode : PResultList;
+ lprgelemdescParam : lpELEMDESC; // array of param types
+ FUNCKIND : funckind;
+ invkind : INVOKEKIND;
+ callconv : CALLCONV;
+ cParams,
+ cParamsOpt,
+ oVft,
+ cScodes : SHORT;
+ elemdescFunc : ELEMDESC;
+ wFuncFlags : WORD;
+ End;
+ FUNCDESC = tagFUNCDESC;
+
+
+ tagBINDPTR = Record
+ case integer Of
+ 0 : (lpfuncdesc : LPFUNCDESC);
+ 1 : (lpvardesc : LPVARDESC);
+ 2 : (lptcomp : Pointer {ITypeComp} );
+ End;
+ BINDPTR = tagBINDPTR;
+ LPBINDPTR = ^BINDPTR;
+
+ tagCUSTDATAITEM = Record
+ GUID : TGuid; // guid identifying this custom data item
+ varValue : VARIANTARG; // value of this custom data item
+ End;
+
+ CUSTDATAITEM = tagCUSTDATAITEM;
+
+ LPCUSTDATAITEM = ^CUSTDATAITEM;
+
+ tagCUSTDATA = Record
+ cCustData : DWord; // number of custom data items in rgCustData
+ prgCustData : LPCUSTDATAITEM; // array of custom data items
+ End;
+
+ CUSTDATA = tagCUSTDATA;
+ LPCUSTDATA = ^CUSTDATA;
+
+ PPROPVARIANT = ^TPROPVARIANT;
+
+
+
+ tagPROPSPEC = record
+ ulKind : ULONG ;
+ case boolean of
+ false : ( propid:propid);
+ true : (lpwstr: LPOLEStr);
+ end;
+
+ PROPSPEC= tagPROPSPEC;
+ TPROPSPEC = PROPSPEC;
+ PPROPSPEC = ^TPROPSPEC;
+
+ tagSTATPROPSTG = record
+ lpwstrName : LPOLESTR ;
+ propid:PROPID ;
+ vt : VARTYPE;
+ end;
+ STATPROPSTG = tagSTATPROPSTG;
+ TSTATPROPSTG = STATPROPSTG;
+ PSTATPROPSTG = ^TSTATPROPSTG;
+
+ tagSTATPROPSETSTG = record
+ fmtid : FMTID;
+ clsid : CLSID;
+ grfFlags : DWORD;
+ mtime : FILETIME;
+ ctime : FILETIME;
+ atime : FILETIME;
+ dwOSVersion : DWORD;
+ end;
+ STATPROPSETSTG = tagSTATPROPSETSTG;
+ TSTATPROPSETSTG = STATPROPSETSTG;
+ PSTATPROPSETSTG = ^STATPROPSETSTG;
+
+ tagVersionedStream = record
+ guidVersion : TGUID;
+ pStream : pointer; {IStream}
+ end;
+ VERSIONEDSTREAM = tagVersionedStream;
+ TVERSIONEDSTREAM = tagVersionedStream;
+ LPVERSIONEDSTREAM = tagVersionedStream;
+ PVERSIONEDSTREAM = ^TagVersionedStream;
+
+
+ LPSAFEARRAY = ^SAFEARRAY;
+ tagDEC = record // simpler remoting variant without nested unions. see wtypes.h
+ wReserved : ushort;
+ scale,
+ sign : byte;
+ hi32 : ULONG;
+ lo64 : ULONGLONG;
+ end;
+ TDECIMAL=tagDEC;
+ PDecimal=^TDECIMAL;
+
+ tagCAC = record
+ cElems : ULONG;
+ pElems : pCHAR;
+ end;
+ CAC = tagCAC;
+ TCAC = tagCAC;
+ tagCAUB = record
+ cElems : ULONG;
+ pElems : pUCHAR;
+ end;
+ CAUB = tagCAUB;
+ TCAUB = tagCAUB;
+ tagCAI = record
+ cElems : ULONG;
+ pElems : pSHORT;
+ end;
+ CAI = tagCAI;
+ TCAI = tagCAI;
+ tagCAUI = record
+ cElems : ULONG;
+ pElems : pUSHORT;
+ end;
+ CAUI = tagCAUI;
+ TCAUI = tagCAUI;
+ tagCAL = record
+ cElems : ULONG;
+ pElems : pLONG;
+ end;
+ CAL = tagCAL;
+ TCAL = tagCAL;
+ tagCAUL = record
+ cElems : ULONG;
+ pElems : pULONG;
+ end;
+ CAUL = tagCAUL;
+ TCAUL = tagCAUL;
+ tagCAFLT = record
+ cElems : ULONG;
+ pElems : pSingle;
+ end;
+ CAFLT = tagCAFLT;
+ TCAFLT = tagCAFLT;
+ tagCADBL = record
+ cElems : ULONG;
+ pElems : ^DOUBLE;
+ end;
+ CADBL = tagCADBL;
+ TCADBL = tagCADBL;
+ tagCACY = record
+ cElems : ULONG;
+ pElems : ^CY;
+ end;
+ CACY = tagCACY;
+ TCACY = tagCACY;
+ tagCADATE = record
+ cElems : ULONG;
+ pElems : ^DATE;
+ end;
+ CADATE = tagCADATE;
+ TCADATE = tagCADATE;
+ tagCABSTR = record
+ cElems : ULONG;
+ pElems : ^BSTR;
+ end;
+ CABSTR = tagCABSTR;
+ TCABSTR = tagCABSTR;
+ tagCABSTRBLOB = record
+ cElems : ULONG;
+ pElems : ^BSTRBLOB;
+ end;
+ CABSTRBLOB = tagCABSTRBLOB;
+ TCABSTRBLOB = tagCABSTRBLOB;
+ tagCABOOL = record
+ cElems : ULONG;
+ pElems : ^VARIANT_BOOL;
+ end;
+ CABOOL = tagCABOOL;
+ TCABOOL = tagCABOOL;
+ tagCASCODE = record
+ cElems : ULONG;
+ pElems : ^SCODE;
+ end;
+ CASCODE = tagCASCODE;
+ TCASCODE = tagCASCODE;
+ tagCAPROPVARIANT = record
+ cElems : ULONG;
+ pElems : ^PROPVARIANT;
+ end;
+ CAPROPVARIANT = tagCAPROPVARIANT;
+ TCAPROPVARIANT = tagCAPROPVARIANT;
+ tagCAH = record
+ cElems : ULONG;
+ pElems : ^LARGE_INTEGER;
+ end;
+ CAH = tagCAH;
+ TCAH = tagCAH;
+ tagCAUH = record
+ cElems : ULONG;
+ pElems : ^ULARGE_INTEGER;
+ end;
+ CAUH = tagCAUH;
+ TCAUH = tagCAUH;
+ tagCALPSTR = record
+ cElems : ULONG;
+ pElems : ^LPSTR;
+ end;
+ CALPSTR = tagCALPSTR;
+ TCALPSTR = tagCALPSTR;
+ tagCALPWSTR = record
+ cElems : ULONG;
+ pElems : ^LPWSTR;
+ end;
+ CALPWSTR = tagCALPWSTR;
+ TCALPWSTR = tagCALPWSTR;
+ tagCAFILETIME = record
+ cElems : ULONG;
+ pElems : ^FILETIME;
+ end;
+ CAFILETIME = tagCAFILETIME;
+ TCAFILETIME = tagCAFILETIME;
+ tagCACLIPDATA = record
+ cElems : ULONG;
+ pElems : ^CLIPDATA;
+ end;
+ CACLIPDATA = tagCACLIPDATA;
+ TCACLIPDATA = tagCACLIPDATA;
+ tagCACLSID = record
+ cElems : ULONG;
+ pElems : ^CLSID;
+ end;
+ CACLSID = tagCACLSID;
+ TCACLSID = tagCACLSID;
+
+ PROPVAR_PAD1 = WORD;
+ PROPVAR_PAD2 = WORD;
+ PROPVAR_PAD3 = WORD;
+
+// Forward interfaces.
+
+ IStream = Types.IStream;
+ IMoniker = Interface;
+ IEnumMoniker = Interface;
+ IEnumString = Interface;
+ IRunningObjectTable = Interface;
+ IStorage = Interface;
+ IEnumSTATSTG = Interface;
+ IAdviseSink = Interface;
+ IBindCtx = Interface;
+ IAsyncManager = Interface;
+ ICallFactory = Interface;
+ ISynchronize = Interface;
+ ITypeLib = Interface;
+ IPropertyStorage = Interface;
+ IEnumSTATPROPSETSTG = interface;
+
+ TPROPVARIANT = record
+ vt : VARTYPE;
+ wReserved1 : PROPVAR_PAD1;
+ wReserved2 : PROPVAR_PAD2;
+ wReserved3 : PROPVAR_PAD3;
+ case longint of
+ 0 : ( cVal : CHAR );
+ 1 : ( bVal : UCHAR );
+ 2 : ( iVal : SHORT );
+ 3 : ( uiVal : USHORT );
+ 4 : ( lVal : LONG );
+ 5 : ( ulVal : ULONG );
+ 6 : ( intVal : longINT );
+ 7 : ( uintVal : UINT );
+ 8 : ( hVal : LARGE_INTEGER );
+ 9 : ( uhVal : ULARGE_INTEGER );
+ 10 : ( fltVal : SINGLE );
+ 11 : ( dblVal : DOUBLE );
+ 12 : ( boolVal : VARIANT_BOOL );
+ 13 : ( bool : _VARIANT_BOOL );
+ 14 : ( scode : SCODE );
+ 15 : ( cyVal : CY );
+ 16 : ( date : DATE );
+ 17 : ( filetime : FILETIME );
+ 18 : ( puuid : ^CLSID );
+ 19 : ( pclipdata : ^CLIPDATA );
+ 20 : ( bstrVal : BSTR );
+ 21 : ( bstrblobVal : BSTRBLOB );
+ 22 : ( blob : BLOB );
+ 23 : ( pszVal : LPSTR );
+ 24 : ( pwszVal : LPWSTR );
+ 25 : ( punkVal : pointer; { IUnknown to avoid Data types which require initialization/finalization can't be used in variant records});
+ 26 : ( pdispVal : pointer; {IDispatch} );
+ 27 : ( pStream : pointer {IStream} );
+ 28 : ( pStorage : pointer{IStorage} );
+ 29 : ( pVersionedStream : LPVERSIONEDSTREAM );
+ 30 : ( parray : LPSAFEARRAY );
+ 31 : ( cac : CAC );
+ 32 : ( caub : CAUB );
+ 33 : ( cai : CAI );
+ 34 : ( caui : CAUI );
+ 35 : ( cal : CAL );
+ 36 : ( caul : CAUL );
+ 37 : ( cah : CAH );
+ 38 : ( cauh : CAUH );
+ 39 : ( caflt : CAFLT );
+ 40 : ( cadbl : CADBL );
+ 41 : ( cabool : CABOOL );
+ 42 : ( cascode : CASCODE );
+ 43 : ( cacy : CACY );
+ 44 : ( cadate : CADATE );
+ 45 : ( cafiletime : CAFILETIME );
+ 46 : ( cauuid : CACLSID );
+ 47 : ( caclipdata : CACLIPDATA );
+ 48 : ( cabstr : CABSTR );
+ 49 : ( cabstrblob : CABSTRBLOB );
+ 50 : ( calpstr : CALPSTR );
+ 51 : ( calpwstr : CALPWSTR );
+ 52 : ( capropvar : CAPROPVARIANT );
+ 53 : ( pcVal : pCHAR );
+ 54 : ( pbVal : pUCHAR );
+ 55 : ( piVal : pSHORT );
+ 56 : ( puiVal : pUSHORT );
+ 57 : ( plVal : pLONG );
+ 58 : ( pulVal : pULONG );
+ 59 : ( pintVal : plongint );
+ 60 : ( puintVal : pUINT );
+ 61 : ( pfltVal : psingle );
+ 62 : ( pdblVal : pDOUBLE );
+ 63 : ( pboolVal : ^VARIANT_BOOL );
+ 64 : ( pdecVal : pDECIMAL );
+ 65 : ( pscode : ^SCODE );
+ 66 : ( pcyVal : ^CY );
+ 67 : ( pdate : ^DATE );
+ 68 : ( pbstrVal : ^TBSTR );
+ 69 : ( ppunkVal : ^IUnknown );
+ 70 : ( ppdispVal : ^IDispatch );
+ 71 : ( pparray : ^LPSAFEARRAY );
+ 72 : ( pvarVal : ^PROPVARIANT );
+ end;
+ PROPVARIANT=TPROPVARIANT;
+ TagPROPVARIANT = TPROPVARIANT;
+// Unknwn.idl
+
+// IUnknown is in classesh.inc
+
+
+
+ AsyncIUnknown = Interface(IUnknown)
+ ['{000e0000-0000-0000-C000-000000000046}']
+ Function Begin_QueryInterface(Const riid : TIID): HResult; StdCall;
+ Function Finish_QueryInterface(Out ppvObject : Pointer):HResult;StdCall;
+ Function Begin_AddRef:HResult;StdCall;
+ Function Finish_AddRef:ULong;StdCall;
+ Function Begin_Release:HResult;StdCall;
+ Function Finish_Release:ULong;StdCall;
+ End;
+
+ IClassFactory = Interface(IUnknown)
+ ['{00000001-0000-0000-C000-000000000046}']
+ Function CreateInstance(Const unkOuter:IUnknown;Const riid : TIID;Out vObject):HResult; StdCall;
+ Function LockServer(fLock : Bool):HResult;StdCall;
+ End;
+
+ PLicInfo = ^TLicInfo;
+ tagLICINFO = record
+ cbLicInfo : ULONG;
+ fRuntimeKeyAvail : BOOL;
+ fLicVerified : BOOL;
+ end;
+ TLicInfo = tagLICINFO;
+ LICINFO = TLicInfo;
+
+ IClassFactory2 = interface(IClassFactory)
+ ['{B196B28F-BAB4-101A-B69C-00AA00341D07}']
+ function GetLicInfo(var licInfo: TLicInfo): HResult; stdcall;
+ function RequestLicKey(dwResrved: DWORD; out bstrKey: WideString): HResult; stdcall;
+ function CreateInstanceLic(const unkOuter: IUnknown; const unkReserved: IUnknown;
+ const iid: TIID; const bstrKey: WideString; out vObject): HResult; stdcall;
+ end;
+
+// objidl.idl
+
+{****************************************************************************
+ * Component Object Interfaces
+ ****************************************************************************}
+
+ IMarshal = Interface(IUnknown)
+ ['{00000003-0000-0000-C000-000000000046}']
+ Function GetUnmarshalClass ( Const riid: TIID; pv:Pointer; Const dwDestContext:DWord;
+ pvDestContext:Pointer; Const mshlflags:DWORD;out LCid : TCLSID ):HResult;Stdcall;
+ Function GetMarshalSizeMax ( Const Riid: TIID; {in, unique} pv:Pointer; Const dwDestContext : DWord;
+ {in, unique} pvDestContext:Pointer; Const mshlflags : DWord; out pSize : PDWord ): HResult;Stdcall;
+ Function MarshalInterface ( Const {in, unique} pStm: IStream; Const riid: TIID; {in, unique} pv:Pointer;
+ Const dwDestContext:DWord; {in, unique} pvDestContext:Pointer; Const mshlflags:DWord ): HRESULT;Stdcall;
+ Function UnmarshalInterface ( {[in, unique]} Const pStm:IStream; Const riid: TIID;
+ out ppv ): HResult;Stdcall;
+ Function ReleaseMarshalData ( {[in, unique]} Const Strm: IStream ):HResult;Stdcall;
+ Function DisconnectObject ( Const dwReserved:DWord ):HRESULT;Stdcall;
+ END;
+
+
+ IMarshal2 = Interface(IMarshal)
+ ['{000001cf-0000-0000-C000-000000000046}']
+ End;
+
+ IMalloc = Interface(IUnknown)
+ ['{00000002-0000-0000-C000-000000000046}']
+ Function Alloc(cb :size_t):Pointer; Stdcall;
+ Function Realloc (pv :pointer;cb:size_t):Pointer;stdcall;
+ Procedure Free({[in]} pv: pointer); Stdcall;
+ Function GetSize(pv:pointer):size_t;stdcall;
+ Function DidAlloc(pv:pointer):Longint;stdcall;
+ procedure HeapMinimize; stdcall;
+ End;
+
+ IMallocSpy = Interface(IUnknown)
+ ['{0000001d-0000-0000-C000-000000000046}']
+
+ Function PreAlloc(cbrequest:Size_t):Longint; StdCall;
+ function PostAlloc(Pactual:Pointer):Pointer;StdCall;
+ Function PreFree(pRequest:Pointer;fSpyed:bool):pointer;StdCall;
+ Procedure PostFree(fspyed:Bool);Stdcall;
+ Function PreRealloc(pRequest:Pointer;cbRequest:Size_t;Out ppNewRequest:Pointer;
+ fSpyed:Bool):Size_t;Stdcall;
+ Function PostRealloc(pactual:Pointer;fspyed:Bool):pointer;Stdcall;
+ Function PreGetSize(pRequest:pointer;fSpyed:Bool):Pointer;StdCall;
+ Function PostGetSize(cbactual:Size_t;fSpyed:Bool):Size_t;StdCall;
+ Function PreDidAlloc(pRequest:pointer;fSpyed:Bool):pointer;stdcall;
+ Function PostDidAlloc(pRequest:pointer;fSpyed:Bool;Factual:Longint):pointer;stdcall;
+ Procedure PreHeapMinimize;StdCall;
+ Procedure PostHeapMinimize;StdCall;
+ End;
+
+ IStdMarshalInfo = Interface(IUnknown)
+ ['{00000018-0000-0000-C000-000000000046}']
+ Function GetClassForHandler (dwDestContext : DWord;pvDestContext:pointer;out Clsid : Pclsid ):HResult;Stdcall;
+ End;
+
+
+ IExternalConnection = Interface(IUnknown)
+ ['{00000019-0000-0000-C000-000000000046}']
+ Function AddConnection (ExtConn: DWord; Reserved: DWord):DWord;Stdcall;
+ Function ReleaseConnection(extconn: DWord; Reserved: Dword;FLastReleaseCloses: Bool):DWord;StdCall;
+ End;
+
+
+ IMultiQI = Interface(IUnknown)
+ ['{00000020-0000-0000-C000-000000000046}']
+//if (__midl >= 500)
+// async_uuid(000e0020-0000-0000-C000-000000000046)
+//endif
+ Function QueryMultipleInterfaces(cMQIs:Ulong;pMQIs:pMultiQI):HResult;StdCall;
+ END;
+
+ IInternalUnknown=Interface(IUnknown)
+ ['{00000021-0000-0000-C000-000000000046}']
+ Function QueryInternalInterface(const riid:TIID;Out ppv:Pointer):HResult;StdCall;
+ END;
+
+
+ IEnumUnknown = Interface(IUnknown)
+ ['{00000100-0000-0000-C000-000000000046}']
+ // pointer_default(unique)
+ Function Next(Celt:Ulong;out rgelt;out pCeltFetched:pulong):HRESULT;StdCall;
+// HRESULT RemoteNext( [in] ULONG celt, [out, size_is(celt), length_is( *pceltFetched)] IUnknown **rgelt, [out] ULONG *pceltFetched);
+ Function Skip(Celt:Ulong):HResult;StdCall;
+ Function Reset():HResult;
+ Function Close(Out ppenum: IEnumUnknown):HResult;
+ END;
+
+
+ IBindCtx = Interface (IUnknown)
+ ['{0000000e-0000-0000-C000-000000000046}']
+ Function RegisterObjectBound(Const punk:IUnknown):HResult; stdCall;
+ Function RevokeObjectBound (Const Punk:IUnknown):HResult; stdCall;
+ Function ReleaseBoundObjects :HResult; StdCall;
+ Function SetBindOptions(Const bindOpts:TBind_Opts):HResult; stdCall;
+// Function RemoteSetBindOptions(Const bind_opts: TBind_Opts2):HResult;StdCall;
+ Function GetBindOptions(var BindOpts:TBind_Opts):HResult; stdCall;
+// Function RemoteGetBindOptions(Var bind_opts: TBind_Opts2):HResult;StdCall;
+ Function GetRunningObjectTable(Out rot : IRunningObjectTable):Hresult; StdCall;
+ Function RegisterObjectParam(Const pszkey:LPOleStr;const punk:IUnknown):HResult;
+ Function GetObjectParam(Const pszkey:LPOleStr; out punk: IUnknown):HResult; StdCall;
+ Function EnumObjectParam (out enum:IEnumString):Hresult;StdCall;
+ Function RevokeObjectParam(pszKey:LPOleStr):HResult;StdCall;
+ End;
+
+
+ IEnumMoniker = Interface (IUnknown)
+ ['{00000102-0000-0000-C000-000000000046}']
+ Function Next(celt:ULong; out Elt;out celftfetched: ULong):HResult; StdCall;
+// Function RemoteNext(Celt:ULong; Out rgelt;out celtfetched :ULong):Hresult; StdCall;
+ Function Skip(celt:Ulong):HResult; StdCall;
+ Function Reset:HResult; StdCall;
+ Function Close(out penum:IEnumMoniker):HResult;StdCall;
+ End;
+
+
+ IRunnableObject = Interface(IUnknown)
+ ['{00000126-0000-0000-C000-000000000046}']
+ Function GetRunningClass(Out clsid:Tclsid):Hresult; StdCall;
+ Function Run(Const pb: IBindCtx):HResult; StdCall;
+ Function IsRunning:Bool; StdCall;
+// Function RemoteIsRunning:Bool; StdCall;
+ Function LockRunning(FLock,FLastUnlockClose:BOOL):HResult; StdCall;
+ Function SetContainedObject(fContained:Bool):Hresult;Stdcall;
+ End;
+
+ IRunningObjectTable = Interface (IUnknown)
+ ['{00000010-0000-0000-C000-000000000046}']
+ Function Register (grfFlags :DWord;const unkobject:IUnknown;Const mkObjectName:IMoniker;Out dwregister:DWord):HResult;StdCall;
+ Function Revoke (dwRegister:DWord):HResult; StdCall;
+ Function IsRunning (Const mkObjectName: IMoniker):HResult;StdCall;
+ Function GetObject (Const mkObjectName: IMoniker; Out punkObject:IUnknown):HResult; StdCall;
+ Function NoteChangeTime(dwRegister :DWord;Const FileTime: TFileTime):HResult;StdCall;
+ Function GetTimeOfLastChange(Const mkObjectName:IMoniker;Out filetime:TFileTime):HResult; StdCall;
+ Function EnumRunning (Out enumMoniker: IEnumMoniker):HResult; StdCall;
+ End;
+
+ IPersist = Interface (IUnknown)
+ ['{0000010c-0000-0000-C000-000000000046}']
+ Function GetClassId(out clsid:TClsId):HResult; StdCall;
+ End;
+
+ IPersistStream = Interface(IPersist)
+ ['{00000109-0000-0000-C000-000000000046}']
+ Function IsDirty:HResult; StdCall;
+ Function Load(Const stm: IStream):HResult; StdCall;
+ Function Save(Const stm: IStream;fClearDirty:Bool):HResult;StdCall;
+ Function GetSizeMax(Out cbSize:ULarge_Integer):HResult; StdCall;
+ End;
+
+ PIMoniker = ^IMoniker;
+ IMoniker = Interface (IPersistStream)
+ ['{0000000f-0000-0000-C000-000000000046}']
+ Function BindToObject (const pbc:IBindCtx;const mktoleft:IMoniker; const RiidResult:TIID;Out vresult):HResult;StdCall;
+// Function RemoteBindToObject (const pbc:IBindCtx;const mktoleft:IMoniker;const RiidResult:TIID;Out vresult):HResult;StdCall;
+ Function BindToStorage(Const Pbc:IBindCtx;Const mktoLeft:IMoniker; const Riid:TIID;Out vobj):HResult; StdCall;
+// Function RemoteBindToStorage(Const Pbc:IBindCtx;Const mktoLeft:IMoniker;const Riid:TIID;Out vobj):HResult; StdCall;
+ Function Reduce (const pbc:IBindCtx; dwReduceHowFar:DWord; mktoLeft: PIMoniker; Out mkReduced:IMoniker):HResult; StdCall;
+ Function ComposeWith(Const MkRight:IMoniker;fOnlyIfNotGeneric:BOOL; OUT mkComposite:IMoniker):HResult; StdCall;
+ Function Enum(fForward:Bool;Out enumMoniker:IEnumMoniker):HResult;StdCall;
+ Function IsEqual(Const mkOtherMoniker:IMoniker):HResult;StdCall;
+ Function Hash (Out dwHash:Dword):HResult;StdCall;
+ Function IsRunning(Const bc:IBindCtx;Const MkToLeft:IMoniker;Const mknewlyRunning:IMoniker):HResult;StdCall;
+ Function GetTimeOfLastChange(Const bc:IBindCtx;Const mkToLeft:IMoniker; out ft : FileTime):HResult; StdCall;
+ Function Inverse(out mk : IMoniker):HResult; StdCall;
+ Function CommonPrefixWith (Const mkOther:IMoniker):HResult; StdCall;
+ Function RelativePathTo(Const mkother:IMoniker; Out mkRelPath : IMoniker):HResult;StdCall;
+ Function GetDisplayName(Const bc:IBindCtx;const mktoleft:IMoniker;Out szDisplayName: pOleStr):HResult; StdCall;
+ Function ParseDisplayName(Const bc:IBindCtx;Const mkToLeft:IMoniker;szDisplayName:POleStr;out cheaten:ULong;out mkOut:IMoniker):HResult; StdCall;
+ Function IsSystemMoniker(Out dwMkSys:DWord):HResult;StdCall;
+ End;
+
+ IROTData = Interface (IUnknown)
+ ['{f29f6bc0-5021-11ce-aa15-00006901293f}']
+ Function GetComparisonData(out data; cbMax:ULong;out cbData:ULong):HResult;StdCall;
+ End;
+
+
+ IEnumString = Interface (IUnknown)
+ ['{00000101-0000-0000-C000-000000000046}']
+ Function Next(Celt:ULong;Out xcelt;Out Celtfetched:ULong):HResult; StdCall;
+// Function RemoteNext(Celt:ULong; Out celt;Out Celtfetched:ULong):HResult; StdCall;
+ Function Skip (Celt:ULong):Hresult;StdCall;
+ Function Reset:HResult;StdCall;
+ Function Clone(Out penum:IEnumString):HResult;StdCall;
+ End;
+
+ ISequentialStream = Types.ISequentialStream;
+ (*interface(IUnknown)
+ ['{0c733a30-2a1c-11ce-ade5-00aa0044773d}']
+ function Read(pv : Pointer;cb : ULONG;pcbRead : PULONG) : HRESULT;stdcall;
+ function Write(pv : Pointer;cb : ULONG;pcbWritten : PULONG): HRESULT;stdcall;
+ end;
+ *)
+
+ (* defined above by pulling it in from types IStream = interface(ISequentialStream)
+ ['{0000000C-0000-0000-C000-000000000046}']
+ function Seek(dlibMove : LargeInt; dwOrigin: Longint;
+ out libNewPosition : LargeInt): HResult; stdcall;
+ function SetSize(libNewSize : LargeInt) : HRESULT;stdcall;
+ function CopyTo(stm: IStream;cb : LargeInt;out cbRead : LargeInt;
+ out cbWritten: LargeInt) : HRESULT;stdcall;
+ function Commit(grfCommitFlags : Longint) : HRESULT; stdcall;
+ function Revert : HRESULT; stdcall;
+ function LockRegion(libOffset : LargeInt;cb : LargeInt;
+ dwLockType: Longint) : HRESULT;stdcall;
+ function UnlockRegion(libOffset: LargeInt;cb: LargeInt;
+ dwLockType: Longint) : HRESULT;stdcall;
+ Function Stat(out statstg : TStatStg; grfStatFlag: Longint): HRESULT;stdcall;
+ function Clone(out stm : IStream) : HRESULT; stdcall;
+ end;
+ *)
+ IEnumSTATSTG = Interface (IUnknown)
+ ['{0000000d-0000-0000-C000-000000000046}']
+ Function Next (Celt:ULong;Out xcelt;pceltfetched : PUlong):HResult; StdCall;
+// Function RemoteNext(Celt:Ulong; Out Celt;pceltfetched : PUlong);
+ Function Skip(Celt:ULong):HResult; StdCall;
+ Function Reset:HResult; StdCall;
+ Function Clone(Out penum:IEnumStatSTG):HResult; StdCall;
+ End;
+
+ IStorage = Interface (IUnknown)
+ ['{0000000b-0000-0000-C000-000000000046}']
+ Function CreateStream(pwcsname:POleStr;GrfMode,Reserved1,Reserved2 : DWord; Out stm : IStream):HResult; StdCall;
+ Function OpenStream(pwcsname:POleStr;Reserved1:Pointer;GrfMode,Reserved2 : DWord; Out stm : IStream):HResult; StdCall;
+// Function RemouteOpenStream(pwcsname:POleStr;cbReserved1:ULong;reserved1:pbyte;GrfMode,Reserved2 : DWord; Out stm : IStream):HResult; StdCall;
+ Function CreateStorage(pwcsname:POleStr;GrfMode,Reserved1,Reserved2 : DWord; Out stm : IStorage):HResult; StdCall;
+ Function OpenStorage(pwcsname:POleStr;Const stgPriority:IStorage;grfmode : DWord;Const SNBExclude :SNB;reserved:DWord;Out stm : IStorage):HResult; StdCall;
+ Function CopyTo(ciidExclude:DWord; rgiidexclude:piid; const snbexclude:SNB;const pstg : IStorage):HResult;StdCall;
+ Function MoveElementTo(wcsName:POleStr;Const pstgDest : IStorage;
+ wcvsNewName:POleStr; GrfFlags:DWord):Hresult; StdCall;
+ Function Commit(grfCommitFlags:Dword):Hresult; StdCall;
+ Function Revert:HResult; StdCall;
+ Function EnumElements(Reserved1 :Dword;Reserved2:Pointer;Reserved3:DWord;Out penum:IEnumStatStg):HResult;StdCall;
+ Function RemoteEnumElements(Reserved1 :Dword;cbReserved2:ULong;Reserved2:pbyte;reserved3:DWord;Out penum:IEnumStatStg):HResult;StdCall;
+ Function DestroyElement(wcsName: POleStr):HResult;StdCall;
+ Function RenameElement(wcsoldName: POleStr;wcsnewName: POleStr):HResult;StdCall;
+ Function SetElementTimes(wcsName:POleStr; Const pctime,patime,pmtime : FileTime):HResult;StdCall;
+ Function SetClass(Const ClasId: TClsID):HResult;StdCall;
+ Function SetStateBits(grfStateBits:DWord;grfMask:DWord):HResult;StdCall;
+ Function Stat(Out pStatStg:StatStg;grfStatFlag:DWord):HResult;StdCall;
+ End;
+
+ IPersistFile = Interface (IPersist)
+ ['{0000010b-0000-0000-C000-000000000046}']
+ Function IsDirty:HResult;StdCall;
+ Function Load(FileName:POleStr;dwMode:DWord):HResult;StdCall;
+ Function Save(FileName:POleStr;fremember:Bool):HResult;StdCall;
+ Function SaveCompleted(FileName:POleStr):HResult;StdCall;
+ Function GetCurFIle(Out FileName:POleStr):HResult;StdCall;
+ End;
+
+
+ IPersistStorage = Interface (IPersist)
+ ['{0000010a-0000-0000-C000-000000000046}']
+ Function IsDirty:HResult;StdCall;
+ Function InitNew(const pstg:IStorage):HResult;StdCall;
+ Function Load(const pstg:IStorage):HResult;StdCall;
+ Function Save(const pstg:IStorage;FSameAsLoad:Boolean):HResult;StdCall;
+ Function SaveCompleted(const pstg:IStorage):HResult;StdCall;
+ Function HandsOffStorage:HResult;StdCall;
+ End;
+
+ ILockBytes = Interface (IUnknown)
+ ['{0000000a-0000-0000-C000-000000000046}']
+ Function ReadAt(ulOffset:ULarge_Integer;pv:Pointer;cb:Ulong; Out pcbRead:ULong):HResult; StdCall;
+// Function RemoteReadAt(ulOffset:ULarge_Integer;pv:Pointer;cb:Ulong; Out pcbRead:ULong):HResult; StdCall;
+ Function WriteAt(ulOffset:ULarge_Integer;pv:Pointer;cb:Ulong; Out pcbWritten:ULong):HResult; StdCall;
+// Function RemoteWriteAt(ulOffset:ULarge_Integer;pv:Pointer;cb:Ulong; Out pcbWritten:ULong):HResult; StdCall;
+ Function Flush:HResult;StdCall;
+ Function SetSize(cb:ULarge_Integer):HResult;StdCall;
+ Function LockRegion(LibOffSet:ULarge_Integer;cb:ULarge_Integer;dwLockType:DWord):HResult;StdCall;
+ Function UnlockRegion(LibOffSet:ULarge_Integer;cb:ULarge_Integer;dwLockType:DWord):HResult;StdCall;
+ Function Stat(Out pstatstg:STATSTG;grfstatFlag:DWord):HResult;StdCall;
+ End;
+
+
+ IEnumFORMATETC = Interface (IUnknown)
+ ['{00000103-0000-0000-C000-000000000046}']
+ Function Next(Celt:ULong;Out Rgelt:FormatEtc;pceltFetched:pULong=nil):HResult; StdCall;
+// Function RemoteNext(Celt:ULong;Out Rgelt:FormatEtc; pceltFetched:pULong=nil):HResult; StdCall;
+ Function Skip(Celt:ULong):HResult;StdCall;
+ Function Reset:HResult;StdCall;
+ Function Clone(out penum:IEnumFORMATETC):HResult;StdCall;
+ End;
+
+ IEnumSTATDATA = Interface (IUnknown)
+ ['{00000105-0000-0000-C000-000000000046}']
+ Function Next(Celt:ULong;Out Rgelt:statdata; pceltFetched:pULong=nil):HResult; StdCall;
+// Function RemoteNext(Celt:ULong;Out Rgelt:statdata;Out pceltFetched:ULong):HResult; StdCall;
+ Function Skip(Celt:ULong):HResult;StdCall;
+ Function Reset:HResult;StdCall;
+ Function Clone(out penum:IEnumstatdata):HResult;StdCall;
+ End;
+
+
+
+ IRootStorage = Interface (IUnknown)
+ ['{00000012-0000-0000-C000-000000000046}']
+ Function SwitchToFile(pszfile:PoleStr):HResult;StdCall;
+ End;
+
+
+
+ IAdviseSink = Interface (IUnknown)
+ ['{0000010f-0000-0000-C000-000000000046}']
+ {$ifdef midl500} ['{00000150-0000-0000-C000-000000000046}'] {$endif}
+ Procedure OnDataChange (Const pformatetc : Formatetc;const pstgmed : STGMEDIUM); StdCall;
+ Procedure OnViewChange (dwAspect : DWord; lindex : Long); StdCall;
+ Procedure OnRename (Const pmk : IMoniker); StdCall;
+ Procedure OnSave; StdCall;
+ Procedure OnClose; StdCall;
+ End;
+
+ IAdviseSink2 = Interface (IAdviseSink)
+ ['{00000125-0000-0000-C000-000000000046}']
+ Procedure OnLinkSrcChange(Const Pmk: IMoniker); StdCall;
+ End;
+
+
+ IDataObject = Interface (IUnknown)
+ ['{0000010e-0000-0000-C000-000000000046}']
+ Function GetData(Const formatetcIn : FORMATETC;Out medium : STGMEDIUM):HRESULT; STDCALL;
+ Function GetDataHere(CONST pformatetc : FormatETC; Out medium : STGMEDIUM):HRESULT; STDCALL;
+ Function QueryGetData(const pformatetc : FORMATETC):HRESULT; STDCALL;
+ Function GetCanonicalFormatEtc(const pformatetcIn : FORMATETC;Out pformatetcOut : FORMATETC):HResult; STDCALl;
+ Function SetData (Const pformatetc : FORMATETC;const medium:STGMEDIUM;FRelease : BOOL):HRESULT; StdCall;
+ Function EnumFormatEtc(dwDirection : DWord; OUT enumformatetcpara : IENUMFORMATETC):HRESULT; StdCall;
+ Function DAdvise(const formatetc : FORMATETC;advf :DWORD; CONST AdvSink : IAdviseSink;OUT dwConnection:DWORD):HRESULT;StdCall;
+ Function DUnadvise(dwconnection :DWord) :HRESULT;StdCall;
+ Function EnumDAdvise(Out enumAdvise : IEnumStatData):HResult;StdCall;
+ End;
+
+ IDataAdviseHolder = Interface (IUnknown)
+ ['{00000110-0000-0000-C000-000000000046}']
+ Function Advise (CONST pdataObject : IDataObject;CONST fetc:FORMATETC;advf : DWORD;Const pAdvise:IAdviseSink;Out DwConnection:DWord):HResult; StdCall;
+ Function Unadvise (dwConnection:Dword):HResult; StdCall;
+ Function EnumAdvise(out penumAdvise : IEnumStatData):HResult;StdCall;
+ Function SendOnDataChange(const pDataObject :IDataObject;DwReserved,advf : DWord):HResult; StdCall;
+ End;
+
+
+
+
+ IMessageFilter = Interface (IUnknown)
+ ['{00000016-0000-0000-C000-000000000046}']
+ Function HandleInComingCall(dwCallType :DWord;htaskCaller : HTASK; dwTickCount: DWORD;CONST sinterfaceinfo:InterfaceInfo):DWord; StdCall;
+ Function RetryRejectedCall (htaskCallee:HTASK; dwTickCount : DWord; dwRejectType : Dword):DWord; StdCall;
+ Function MessagePending (htaskCallee:HTASK; dwTickCount : DWord; dwPendingType : Dword):DWord; StdCall;
+ End;
+
+//****************************************************************************
+//* Object Remoting Interfaces
+//****************************************************************************
+
+
+
+ IRpcChannelBuffer = Interface (IUnknown)
+ ['{D5F56B60-593B-101A-B569-08002B2DBF7A}']
+ Function GetBuffer (Const pMesasge : RPCOLEMESSAGE;Const riid :TIId):HResult; StdCall;
+ Function SendReceive(Var pMessage : RPCOLEMESSAGE; Out PStatus : ULong):HResult; StdCall;
+ Function FreeBuffer(Const pMessage : RPCOLEMESSAGE):HResult; StdCall;
+ Function GetDestCTX(Out dwDestContext : DWord;Out pvDestContext : Pointer):HResult; StdCall;
+ Function IsConnected:HResult; StdCall;
+ End;
+
+ IRpcChannelBuffer2 = Interface (IRpcChannelBuffer)
+ ['{594f31d0-7f19-11d0-b194-00a0c90dc8bf}']
+ Function GetProtocolVersion(Var dwVersion : DWord):HResult; StdCall;
+ End;
+
+
+ IAsyncRpcChannelBuffer = Interface (IRpcChannelBuffer2)
+ ['{a5029fb6-3c34-11d1-9c99-00c04fb998aa}']
+ Function Send(Var Msg: RPCOLEMESSAGE;Const pSync : ISynchronize;Out PulStatus : ULong):HResult; StdCall;
+ Function Receive(Var Msg: RPCOLEMESSAGE;Out PulStatus : ULong):HResult; StdCall;
+ Function GetDestCTXEx(Out MSG : RPCOLEMESSAGE;Out vDestContext : DWord;Out pvDestContext : Pointer ):HResult;StdCall;
+ End;
+
+ IRpcChannelBuffer3 = Interface (IRpcChannelBuffer2)
+ ['{25B15600-0115-11d0-BF0D-00AA00B8DFD2}']
+ Function Send(Var msg : RPCOLEMESSAGE;Out ulStatus : ULONG):HResult; StdCall;
+ Function Receive(Var msg : RPCOLEMESSAGE;ulSize : ULong;Out ulStatus : ULONG):HResult; StdCall;
+ Function Cancel (Const msg : RPCOLEMESSAGE):HResult; StdCall;
+ Function GetCallContext(Const msg : RPCOLEMESSAGE; Const riid : TIID; Out pInterface : Pointer):HResult; StdCall;
+ Function GetDestCTXEx(Const Msg : RPCOLEMESSAGE;Out vDestContext : DWord;Out pvDestContext : Pointer ):HResult;StdCall;
+ Function GetState(Const Msg : RPCOLEMESSAGE;Out State: DWord):HResult;StdCall;
+ Function RegisterAsync(Const Msg : RPCOLEMESSAGE;Const asyncmgr : IAsyncManager):HResult;StdCall;
+ End;
+
+ IRpcSyntaxNegotiate = Interface (IUnknown)
+ ['{58a08519-24c8-4935-b482-3fd823333a4f}']
+ Function NegotiateSyntax ( Var msg : RPCOLEMESSAGE):HResult; StdCall;
+ End;
+
+
+
+
+ IRpcProxyBuffer = Interface (IUnknown)
+ ['{D5F56A34-593B-101A-B569-08002B2DBF7A}']
+ Function Connect(Const rpcchannelbuffer : IRpcChannelBuffer):HResult; StdCall;
+ Procedure Disconnect;
+ End;
+
+ IRpcStubBuffer = Interface (IUnknown)
+ ['{D5F56AFC-593B-101A-B569-08002B2DBF7A}']
+ Function COnnect ( Const UnkServer : IUnknown):HResult; StdCall;
+ Procedure Disconnect; StdCall;
+ Function Invoke(Const rpcmsg : RPCOLEMESSAGE;Const RpcChanBuf : IRpcChannelBuffer):HResult; StdCall;
+ Function IsIIDSupported (Const riid : TIID):Pointer {IRpcStubBuffer}; StdCall;
+ Function CountRefs :ULong; StdCall;
+ Function DebugServerQueryInterface(CONST pv : Pointer):HResult; StdCall;
+ Procedure DebugServerRelease (pv : Pointer); StdCall;
+ End;
+
+ IPSFactoryBuffer = Interface (IUnknown)
+ ['{D5F569D0-593B-101A-B569-08002B2DBF7A}']
+ Function CreateProxy(Const UnkOuter : IUnknown;const riid : TIID; Out proxy: IRpcProxyBuffer; Out Pv :Pointer):HResult; StdCall;
+ Function CreateStub (Const riid : TIID; Const UnkServer : IUnknown; Out pstub : IRpcStubBuffer):HResult; StdCall;
+ End;
+
+{$ifdef NT4_greater_Or_DCOM}
+// This interface is only valid on Windows NT 4.0
+
+// This structure contains additional data for hooks. As a backward
+// compatability hack, the entire structure is passed in place of the
+// RIID parameter on all hook methods. Thus the IID must be the first
+// parameter. As a forward compatability hack the second field is the
+// current size of the structure.
+
+ SChannelHookCallInfo= Record;
+ IID : iid;
+ cbSize : Dword;
+ uCausality : GUID;
+ dwServerPid,
+ iMethod : DWord;
+ pObject : Pointer;
+ End;
+
+
+
+ IChannelHook = Interface (IUnknown)
+ ['{1008c4a0-7613-11cf-9af1-0020af6e72f4}']
+ Procedure ClientGetSize(Const uExtent : TGuid; CONST riid : TIID; Out datasize :ULong); StdCall;
+ Procedure ClientFillBuffer(Const uExtent : TGuid; CONST riid : TIID; Var datasize :ULong;Buffer :Pointer); StdCall;
+ Procedure ClientNotify(Const uExtent : TGuid; CONST riid : TIID; datasize :ULong;Buffer :Pointer;hrfault:HResult); StdCall;
+ Procedure ServerNotify(Const uExtent : TGuid; CONST riid : TIID; datasize :ULong;Buffer :Pointer;DataRep:DWord); StdCall;
+ Procedure ServerGetSize(Const uExtent : TGuid; CONST riid : TIID;hrFault :HResult; Out datasize :ULong); StdCall;
+ Procedure ServerFillBuffer(Const uExtent : TGuid; CONST riid : TIID; Var datasize :ULong;Buffer :Pointer;HrFault:HResult); StdCall;
+ End;
+{$Endif}
+
+
+// Well-known Property Set Format IDs
+//FMTID_SummaryInformation = {CONST} FMTID;
+//FMTID_DocSummaryInformation = {CONST} FMTID;
+//FMTID_UserDefinedProperties = {CONST} FMTID;
+//FMTID_DiscardableInformation = {CONST} FMTID;
+//FMTID_ImageSummaryInformation = {CONST} FMTID;
+//FMTID_AudioSummaryInformation = {CONST} FMTID;
+//FMTID_VideoSummaryInformation = {CONST} FMTID;
+//FMTID_MediaFileSummaryInformation = {CONST} FMTID;
+
+
+//****************************************************************************
+// * Connection Point Interfaces
+// ****************************************************************************/
+
+//#ifdef __INCLUDE_CPIFS
+ IConnectionPointContainer = Interface;
+//interface IConnectionPoint;
+//interface IEnumConnections;
+ IEnumConnectionPoints = Interface;
+ IEnumConnections = Interface;
+
+
+ IConnectionPoint = Interface (IUnknown)
+ ['{B196B286-BAB4-101A-B69C-00AA00341D07}']
+ Function GetConnectionInterface(out piid : TIID):HResult;StdCall;
+ Function GetConnectionPointContainer(CPC : IConnectionPointContainer):HResult;StdCall;
+ Function Advise(unkSink : IUnknown;Out dwCookie : DWord):HResult;StdCall;
+ Function UnAdvise(dwCookie : DWord):HResult;StdCall;
+ Function EnumConnection(out pEnum : IEnumConnections):HResult;stdCall;
+ End;
+
+ IConnectionPointContainer = Interface (IUnknown)
+ ['{B196B284-BAB4-101A-B69C-00AA00341D07}']
+ Function EnumConnectionPoints(out pEnum : IEnumConnectionPoints):HResult;StdCall;
+ Function FindConnectionPoint(Const RIID : TIID;Out ppcp : IConnectionPoint):HResult;StdCall;
+ End;
+
+ tagCONNECTDATA = Record
+ unk : Pointer; {IUnknown}
+ dwCookie : DWord;
+ End;
+ ConnectData = tagCONNECTDATA;
+
+ IEnumConnections = Interface (IUnknown)
+ ['{B196B287-BAB4-101A-B69C-00AA00341D07}']
+ Function Next(cConnections : ULong; Out rgcd : ConnectData; lpcFetched : pULong=nil):HResult;StdCall;
+ Function Skip(cConnections : ULong):HResult;StdCall;
+ Function Reset:HResult;StdCall;
+ Function Clone(Out pEnum : IEnumConnections):HResult; StdCall;
+ End;
+
+
+ IEnumConnectionPoints = Interface (IUnknown)
+ ['{B196B285-BAB4-101A-B69C-00AA00341D07}']
+ Function Next(cConnections : ULong; Out rgpcm : IConnectionPoint; lpcFetched : pULong=nil):HResult;StdCall;
+ Function Skip(cConnections : ULong):HResult;StdCall;
+ Function Reset:HResult;StdCall;
+ Function Clone(Out pEnum : IEnumConnectionPoints):HResult;StdCall;
+ End;
+
+
+
+ tagSOLE_AUTHENTICATION_SERVICE = Record
+ dwAuthnSvc,
+ dwAuthzSvc : DWord;
+ pPrincipalName : POleStr;
+ hr : HResult;
+ End;
+ SOLE_AUTHENTICATION_SERVICE = tagSOLE_AUTHENTICATION_SERVICE;
+ PSOLE_AUTHENTICATION_SERVICE = ^SOLE_AUTHENTICATION_SERVICE;
+
+ tagSOLE_AUTHENTICATION_INFO = Record
+ dwAuthnSvc,
+ dwAuthzSvc : DWord;
+ AuthInfo : Pointer;
+ End;
+ SOLE_AUTHENTICATION_INFO = tagSOLE_AUTHENTICATION_INFO;
+ PSOLE_AUTHENTICATION_INFO = ^SOLE_AUTHENTICATION_INFO;
+
+ tagSOLE_AUTHENTICATION_LIST = Record
+ cAuthInfo : DWord;
+ AuthInfo : PSOLE_AUTHENTICATION_INFO;
+ End;
+ SOLE_AUTHENTICATION_LIST = tagSOLE_AUTHENTICATION_LIST;
+ PSOLE_AUTHENTICATION_LIST = ^SOLE_AUTHENTICATION_LIST;
+
+{$ifdef WINNT_DCOM}
+
+ IClientSecurity = Interface (IUnknown)
+ ['{0000013D-0000-0000-C000-000000000046}']
+ Function QueryBlanket (Proxy : IUnknown;Out AuthnSvc,AuthzSvc : Dword;Out ServerPrincName:pOleStr;Out AuthnLevel,ImpLevel:Dword; Out AuthInfo : Pointer; Out Capabilities : Dword):HResult;StdCall;
+ Function SetBlanket (Proxy : IUnknown;AuthnSvc,AuthzSvc : Dword;ServerPrincName:pOleStr;AuthnLevel,ImpLevel:Dword;AuthInfo : Pointer;Capabilities : Dword):HResult;StdCall;
+ Function CopyProxy (Proxy : IUnknown;Out pcopy:IUnknown):HResult;StdCall;
+ End;
+
+ IServerSecurity = Interface (IUnknown)
+ ['{0000013E-0000-0000-C000-000000000046}']
+ Function QueryBlanket ( out authnSvc,AuthzSvc : DWord; Out pServerPrincName : pOleStr; Out AuthnLevel, ImpLevel; :DWord; out Privs : Pointer; Var Capabilities :DWord):HResult;StdCall;
+ Function ImpersonateClient:HResult;StdCall;
+ Function RevertToSelf:HResult;StdCall;
+ Function IsImpersonating:Bool;StdCall;
+ End;
+
+ IClassActivator = Interface (IUnknown)
+ ['{00000140-0000-0000-C000-000000000046}']
+ Function GetClassObject(Const rclsif : TClsID; ClassContext : DWord; locale : LCID; Const ridd : TIID; Out pv : Pointer):HResult;StdCall;
+ End;
+
+
+ IRpcOptions = Interface (IUnknown)
+ ['{00000144-0000-0000-C000-000000000046}']
+ Function xSet (prx : IUnknown;dwProperty : DWord; dwValue:ULONG_PTR):HResult; StdCall;
+ Function Query (prx : IUnknown;dwProperty:Dword; dwValue:ULONG_PTR):HResult; StdCall;
+ End;
+
+{$endif} {DCOM}
+
+ IFillLockBytes = Interface (IUnknown)
+ ['{99caf010-415e-11cf-8814-00aa00b569f5}']
+ Function FillAppend(const pv : Pointer;cb:ULong; Out PcbWritten : ULong):HResult;StdCall;
+ Function FillAt(ulOffset : ULarge_INTEGER;Const pv : Pointer;cb :ULong; Out pcbWritten:ULong):HResult;StdCall;
+ Function SetFillSize ( ulSize :ULarge_Integer):HResult;StdCall;
+ Function Terminate (bCanceled :Bool):HResult;StdCall;
+ End;
+
+ IProgressNotify = Interface (IUnknown)
+ ['{a9d758a0-4617-11cf-95fc-00aa00680db4}']
+ Function OnProgress (ProgressCurrent,ProgressMaximum :Dword; FAccurate,Fowner : Bool):HResult;StdCall;
+ End;
+
+ ILayoutStorage = Interface (IUnknown)
+ ['{0e6d4d90-6738-11cf-9608-00aa00680db4}']
+ {The methods in this interface all had "__stdcall" as modifier, while the other classes don't. ?!?!?}
+ Function LayoutScript ( xStorageLayout : StorageLayout;nEntries,glfInterleaveFlag : Dword) :HResult; StdCall;
+ Function BeginMonitor:HResult;StdCall;
+ Function EndMonitor:HResult;StdCall;
+ Function ReLayourDocFile(pwcsNewDFName :pOleStr):HResult;StdCall;
+ Function ReLayoutDocfileOnILockBytes(LockBytes : ILockBytes):Hresult;StdCall;
+ End;
+
+ IBlockingLock = Interface (IUnknown)
+ ['{30f3d47a-6447-11d1-8e3c-00c04fb9386d}']
+ Function Lock (dwTimeOut : DWord) : HResult;Stdcall;
+ Function Unlock : HResult;Stdcall;
+ End;
+
+ ITimeAndNoticeControl = Interface (IUnknown)
+ ['{bc0bf6ae-8878-11d1-83e9-00c04fc2c6d4}']
+ Function SuppressChanges(res1,res2 : Dword):HResult;StdCall;
+ End;
+
+ IOplockStorage = Interface (IUnknown)
+ ['{8d19c834-8879-11d1-83e9-00c04fc2c6d4}']
+ Function CreateStorageEx(wcsName : LPCWSTR;grfMode,StgFmt,GrfAtrrs :Dword;Const riid :Tiid; Out ppstgOpen : Pointer):HResult;StdCall;
+ Function OpenStorageEx(wcsName : LPCWSTR;grfMode,StgFmt,GrfAtrrs :Dword;Const riid :Tiid; Out ppstgOpen : Pointer):HResult;StdCall;
+ End;
+
+ ISurrogate = Interface (IUnknown)
+ ['{00000022-0000-0000-C000-000000000046}']
+ Function LoadDllServer (Const ClsId : TClsId):HResult;StdCall;
+ Function FreeSurrogate:HResult;StdCall;
+ End;
+
+ IGlobalInterfaceTable = Interface (IUnknown)
+ ['{00000146-0000-0000-C000-000000000046}']
+ Function RegisterInterfaceInGlobal(unk :IUnknown;Const riid : TIID; Out dwcookie :DWord):HResult;StdCall;
+ Function RevokeInterfaceFromGlobal (dwCookie :DWord):HResult;StdCall;
+ Function GetInterfaceFromGlobal (dwCookie :DWord;Const riid : TIID;out pv : Pointer):HResult;StdCall;
+ End;
+
+ IDirectWriterLock = Interface (IUnknown)
+ ['{0e6d4d92-6738-11cf-9608-00aa00680db4}']
+ Function WaitForWriteAccess (dwTimeOut : DWORD):HResult;StdCall;
+ Function ReleaseWriteAccess:HResult;StdCall;
+ Function HaveWriteAccess:HResult;StdCall;
+ End;
+
+ ISynchronize = Interface (IUnknown)
+ ['{00000030-0000-0000-C000-000000000046}']
+ Function Wait (dwFlags : DWord; dwMilliSeconds : DWord):HResult;StdCall;
+ Function Signal : HResult;StdCall;
+ Function Reset : HResult;StdCall;
+ End;
+
+ ISynchronizeHandle = Interface (IUnknown)
+ ['{00000031-0000-0000-C000-000000000046}']
+ Function GetHandle(Out ph : Handle):HResult;StdCall;
+ End;
+
+ ISynchronizeEvent = Interface (ISynchronizeHandle)
+ ['{00000032-0000-0000-C000-000000000046}']
+ Function SetEventHandle (Const ph : Handle):HResult; StdCall;
+ End;
+
+ ISynchronizeContainer = Interface (IUnknown)
+ ['{00000033-0000-0000-C000-000000000046}']
+ Function AddSynchronize(pSync : ISynchronize):HResult; StdCall;
+ Function WaitMultiple(dwFlags : Dword; dwTimeOut : Dword; Out pSync : ISynchronize):HResult;StdCall;
+ End;
+
+ ISynchronizeMutex = Interface (ISynchronize)
+ ['{00000025-0000-0000-C000-000000000046}']
+ Function ReleaseMutex:HResult; StdCall;
+ End;
+
+ ICancelMethodCalls = Interface (IUnknown)
+ ['{00000029-0000-0000-C000-000000000046}']
+ Function Cancel(ulSeconds : ULong):HResult; StdCall;
+ Function TestCancel:HResult;StdCall;
+ End;
+
+ IAsyncManager = Interface (IUnknown)
+ ['{0000002A-0000-0000-C000-000000000046}']
+ Function CompleteCall (xResult : HResult):HResult;StdCall;
+ Function GetCallContext(Const iid :TIID; Out pInterface : Pointer):HResult;StdCall;
+ Function GetState(Out pulStateFlags : ULong):HResult;StdCall;
+ End;
+
+ ICallFactory = Interface (IUnknown)
+ ['{1c733a30-2a1c-11ce-ade5-00aa0044773d}']
+ Function CreateCall(Const riid:TIID;CtrUnk : IUnknown;Const Riid2:TIID;Out Unknown : IUnknown):HResult;StdCall;
+ End;
+
+ IRpcHelper = Interface (IUnknown)
+ ['{00000149-0000-0000-C000-000000000046}']
+ Function GetDCOMProtocolVersion(Out ComVersion :DWord):HResult;StdCall;
+ Function GettIIDFromOBJREF(ObjRef : Pointer;Out xIID : piid):HResult;StdCall;
+ End;
+
+ IReleaseMarshalBuffers = Interface (IUnknown)
+ ['{eb0cb9e8-7996-11d2-872e-0000f8080859}']
+ Function ReleaseMarshalBuffer(const pnsg : RPCOLEMESSAGE;dwFlags:DWord;Const pchn : IUnknown):HResult; StdCall;
+ End;
+
+ IWaitMultiple = Interface (IUnknown)
+ ['{0000002B-0000-0000-C000-000000000046}']
+ Function WaitMulitple(TImeout :DWord;out psync : ISynchronize):HResult; StdCall;
+ Function AddSynchronize (const psync : ISynchronize):HResult;StdCall;
+ End;
+
+ IUrlMon = Interface (IUnknown)
+ ['{00000026-0000-0000-C000-000000000046}']
+ Function AsyncGetClassBits(CONST rclsif : TClsID; psztype,pzext : lpcwstr; dwfileversionMS,dwFileVersionLS : DWord; pzcodebase : LPCWSTR; Const pbc : IBindCTX; dwclasscontext : DWord; const Riid:TIID; flags :DWORD):HResult; StdCall;
+ End;
+
+ IForegroundTransfer = Interface (IUnknown)
+ ['{00000145-0000-0000-C000-000000000046}']
+ Function AllowForegroundTransfer(lpvReserved:Pointer):HResult; StdCall;
+ End;
+
+ IAddrTrackingControl = Interface (IUnknown)
+ ['{00000147-0000-0000-C000-000000000046}']
+ Function EnableCOMDynamicAddrTracking:HResult; StdCall;
+ Function DisableCOMDynamicAddrTracking:HResult; StdCall;
+ End;
+
+ IAddrExclusionControl = Interface (IUnknown)
+ ['{00000148-0000-0000-C000-000000000046}']
+ Function GetCurrentAddrExclusionList(Const riid : TIID;out Enumerator : Pointer):HResult;StdCall;
+ Function UpdateAddrExclusionList(Enumerator : IUnknown):HResult;StdCall;
+ End;
+
+//****************************************************************************
+//* Pipe interfaces
+//****************************************************************************/
+
+// Doesn't look translatable. See objidl.idl
+
+//****************************************************************************
+//* Thumbnail generator interface
+//****************************************************************************/
+
+ IThumbnailExtractor = Interface (IUnknown)
+ ['{969dc708-5c76-11d1-8d86-0000f804b057}']
+ Function ExtractThumbnail (pStg : IStorage; uLength,UHeight : ULong; Out uloutputlength,Height :ULong; Out OutputBitmap : HBITMAP): HResult; StdCall;
+ Function OnFileUpdated (pStg : IStorage):HResult;
+ End;
+
+//****************************************************************************
+//* Dummy Interface to force inclusion of HICON and HDC in proxy/stub code....
+//****************************************************************************/
+
+ IDummyHICONIncluder = Interface (IUnknown)
+ ['{947990de-cc28-11d2-a0f7-00805f858fb1}']
+ Function Dummy (h1 : HICON; H2 :HDC):HResult;
+ End;
+
+ IComThreadingInfo = Interface (IUnknown)
+ ['{000001ce-0000-0000-C000-000000000046}']
+ Function GetCurrentApartmentType(out pAptType : DWord {APTTTYPE}):HResult;
+ Function GetCurrentThreadType(Out ThreadType : Dword {THDTTYPE}):HResult;StdCall;
+ Function GetCurrentLogicalThreadID(Out guidlogicalThreadId : TGUID):HResult;StdCall;
+ Function SetCurrentLogicalThreadID(Const guidlogicalThreadId : TGUID):HResult;StdCall;
+ End;
+
+ IProcessInitControl = Interface (IUnknown)
+ ['{72380d55-8d2b-43a3-8513-2b6ef31434e9}']
+ Function ResetInitializerTimeout(dwSecondsRemaining:DWord):HResult; StdCall;
+ End;
+
+
+// Interfaces from OAIDL.IDL
+
+ ITypeInfo = Interface;
+
+ ICreateTypeInfo = Interface (IUnknown)
+ ['{00020405-0000-0000-C000-000000000046}']
+ Function SetGuid(CONST guid: TGUID):HResult;StdCall;
+ Function SetTypeFlags(uTypeFlags: UINT):HResult;StdCall;
+ Function SetDocString(pStrDoc: pOleStr):HResult;StdCall;
+ Function SetHelpContext(dwHelpContext: DWORD):HResult;StdCall;
+ Function SetVersion(wMajorVerNum: WORD; wMinorVerNum: WORD):HResult;StdCall;
+ Function AddRefTypeInfo(CONST pTInfo: ITypeInfo; CONST phRefType: HREFTYPE):HResult;StdCall;
+ Function AddFuncDesc(index: UINT; CONST pFuncDesc: FUNCDESC):HResult;StdCall;
+ Function AddImplType(index: UINT; hRefType: HREFTYPE):HResult;StdCall;
+ Function SetImplTypeFlags(index: UINT; implTypeFlags: WINT):HResult;StdCall;
+ Function SetAlignment(cbAlignment: WORD):HResult;StdCall;
+ Function SetSchema(pStrSchema: pOleStr):HResult;StdCall;
+ Function AddVarDesc(index: UINT; CONST pVarDesc: VARDESC):HResult;StdCall;
+ Function SetFuncAndParamNames(index: UINT; CONST rgszNames: pOleStr; cNames: UINT):HResult;StdCall;
+ Function SetVarName(index: UINT; szName: pOleStr):HResult;StdCall;
+ Function SetTypeDescAlias(CONST pTDescAlias: TYPEDESC):HResult;StdCall;
+ Function DefineFuncAsDllEntry(index: UINT; szDllName: pOleStr; szProcName: pOleStr):HResult;StdCall;
+ Function SetFuncDocString(index: UINT; szDocString: pOleStr):HResult;StdCall;
+ Function SetVarDocString(index: UINT; szDocString: pOleStr):HResult;StdCall;
+ Function SetFuncHelpContext(index: UINT; dwHelpContext: DWORD):HResult;StdCall;
+ Function SetVarHelpContext(index: UINT; dwHelpContext: DWORD):HResult;StdCall;
+ Function SetMops(index: UINT; Const bstrMops: WideString):HResult;StdCall;
+ Function SetTypeIdldesc(CONST pIdlDesc: IDLDESC):HResult;StdCall;
+ Function LayOut():HResult;StdCall;
+ End;
+
+ ICreateTypeInfo2 = Interface (ICreateTypeInfo)
+ ['{0002040E-0000-0000-C000-000000000046}']
+ Function DeleteFuncDesc(index: UINT):HResult;StdCall;
+ Function DeleteFuncDescByMemId(memid: MEMBERID; invKind: INVOKEKIND):HResult;StdCall;
+ Function DeleteVarDesc(index: UINT):HResult;StdCall;
+ Function DeleteVarDescByMemId(memid: MEMBERID):HResult;StdCall;
+ Function DeleteImplType(index: UINT):HResult;StdCall;
+ Function SetCustData(CONST guid: TGUID; CONST pVarVal: VARIANT):HResult;StdCall;
+ Function SetFuncCustData(index: UINT; CONST guid: TGUID; CONST pVarVal: VARIANT):HResult;StdCall;
+ Function SetParamCustData(indexFunc: UINT; indexParam: UINT; CONST guid: TGUID; CONST pVarVal: VARIANT):HResult;StdCall;
+ Function SetVarCustData(index: UINT; CONST guid: TGUID; CONST pVarVal: VARIANT):HResult;StdCall;
+ Function SetImplTypeCustData(index: UINT; CONST guid: TGUID; CONST pVarVal: VARIANT):HResult;StdCall;
+ Function SetHelpStringContext(dwHelpStringContext: ULONG):HResult;StdCall;
+ Function SetFuncHelpStringContext(index: UINT; dwHelpStringContext: ULONG):HResult;StdCall;
+ Function SetVarHelpStringContext(index: UINT; dwHelpStringContext: ULONG):HResult;StdCall;
+ Function Invalidate():HResult;StdCall;
+ Function SetName(szName: pOleStr):HResult;StdCall;
+ End;
+
+ ICreateTypeLib = Interface (IUnknown)
+ ['{00020406-0000-0000-C000-000000000046}']
+ Function CreateTypeInfo(szName: pOleStr; tkind: TYPEKIND; OUT ppCTInfo: ICreateTypeInfo):HResult;StdCall;
+ Function SetName(szName: pOleStr):HResult;StdCall;
+ Function SetVersion(wMajorVerNum: WORD; wMinorVerNum: WORD):HResult;StdCall;
+ Function SetGuid(CONST guid: TGUID):HResult;StdCall;
+ Function SetDocString(szDoc: pOleStr):HResult;StdCall;
+ Function SetHelpFileName(szHelpFileName: pOleStr):HResult;StdCall;
+ Function SetHelpContext(dwHelpContext: DWORD):HResult;StdCall;
+ Function SetLcid(lcid: LCID):HResult;StdCall;
+ Function SetLibFlags(uLibFlags: UINT):HResult;StdCall;
+ Function SaveAllChanges():HResult;StdCall;
+ End;
+
+ ICreateTypeLib2 = Interface (ICreateTypeLib)
+ ['{0002040F-0000-0000-C000-000000000046}']
+ Function DeleteTypeInfo(szName: pOleStr):HResult;StdCall;
+ Function SetCustData(CONST guid: TGUID; CONST pVarVal: VARIANT):HResult;StdCall;
+ Function SetHelpStringContext(dwHelpStringContext: ULONG):HResult;StdCall;
+ Function SetHelpStringDll(szFileName: pOleStr):HResult;StdCall;
+ End;
+
+ IEnumVARIANT = Interface (IUnknown)
+ ['{00020404-0000-0000-C000-000000000046}']
+ {$ifndef Call_as}
+ Function Next(celt: ULONG; OUT rgVar: VARIANT; pCeltFetched: pULONG=nil):HResult;StdCall;
+ {$else}
+ Function Next(celt: ULONG; OUT rgVar: VARIANT; pCeltFetched: pULONG=nil):HResult;StdCall;
+ {$endif}
+ Function Skip(celt: ULONG):HResult;StdCall;
+ Function Reset():HResult;StdCall;
+ Function Clone(OUT ppEnum: IEnumVARIANT):HResult;StdCall;
+ End;
+
+ ITypeComp = Interface (IUnknown)
+ ['{00020403-0000-0000-C000-000000000046}']
+ {$ifndef Call_as}
+ Function Bind(szName: pOleStr; lHashVal: ULONG; wFlags: WORD; OUT ppTInfo: ITypeInfo; OUT pDescKind: DESCKIND; OUT pBindPtr: BINDPTR):HResult;StdCall;
+ Function BindType(szName: pOleStr; lHashVal: ULONG; OUT ppTInfo: ITypeInfo; OUT ppTComp: ITypeComp):HResult;StdCall;
+ {$else}
+ Function Bind(szName: pOleStr; lHashVal: ULONG; wFlags: WORD; OUT ppTInfo: ITypeInfo; OUT pDescKind: DESCKIND; OUT ppFuncDesc: LPFUNCDESC; OUT ppVarDesc: LPVARDESC; O
+ Function BindType(szName: pOleStr; lHashVal: ULONG; OUT ppTInfo: ITypeInfo):HResult;StdCall;
+ {$endif}
+ End;
+
+ ITypeInfo = Interface (IUnknown)
+ ['{00020401-0000-0000-C000-000000000046}']
+ {$ifndef Call_as}
+ Function GetTypeAttr(OUT ppTypeAttr: lpTYPEATTR):HResult;StdCall;
+ {$else}
+ Function GetTypeAttr(OUT ppTypeAttr: LPTYPEATTR; OUT pDummy: CLEANLOCALSTORAGE):HResult;StdCall;
+ {$endif}
+ Function GetTypeComp(OUT ppTComp: ITypeComp):HResult;StdCall;
+ {$ifndef Call_as}
+ Function GetFuncDesc(index: UINT; OUT ppFuncDesc: lpFUNCDESC):HResult;StdCall;
+ Function GetVarDesc(index: UINT; OUT ppVarDesc: lpVARDESC):HResult;StdCall;
+ Function GetNames(memid: MEMBERID; rgBstrNames: PBStrList; cMaxNames: UINT; OUT pcNames: UINT):HResult;StdCall;
+ {$else}
+ Function GetFuncDesc(index: UINT; OUT ppFuncDesc: LPFUNCDESC; OUT pDummy: CLEANLOCALSTORAGE):HResult;StdCall;
+ Function GetVarDesc(index: UINT; OUT ppVarDesc: LPVARDESC; OUT pDummy: CLEANLOCALSTORAGE):HResult;StdCall;
+ Function GetNames(memid: MEMBERID; rgBstrNames: PBStrList; cMaxNames: UINT; OUT pcNames: UINT):HResult;StdCall;
+ {$endif}
+ Function GetRefTypeOfImplType(index: UINT; OUT pRefType: HREFTYPE):HResult;StdCall;
+ Function GetImplTypeFlags(index: UINT; OUT pImplTypeFlags: WINT):HResult;StdCall;
+ {$ifndef Call_as}
+ Function GetIDsOfNames(CONST rgszNames: pOleStr; cNames: UINT; OUT pMemId: MEMBERID):HResult;StdCall;
+ {$else}
+ Function LocalGetIDsOfNames():HResult;StdCall;
+ {$endif}
+ {$ifndef Call_as}
+ Function Invoke(pvInstance: Pointer; memid: MEMBERID; wFlags: WORD; VAR pDispParams: DISPPARAMS; OUT pVarResult: VARIANT; OUT pExcepInfo: EXCEPINFO; OUT puArgErr: UINT):HResult;StdCall;
+ {$else}
+ Function LocalInvoke ():HResult;StdCall;
+ {$endif}
+ {$ifndef Call_as}
+ //Function GetDocumentation(memid: MEMBERID; OUT pBstrName: WideString; OUT pBstrDocString: WideString; OUT pdwHelpContext: DWORD; OUT pBstrHelpFile: WideString):HResult;StdCall;
+ Function GetDocumentation(memid: MEMBERID; pBstrName: PWideString; pBstrDocString: PWideString; pdwHelpContext: PDWORD; pBstrHelpFile: PWideString):HResult;StdCall;
+ {$else}
+ Function GetDocumentation(memid: MEMBERID; refPtrFlags: DWORD; OUT pBstrName: WideString; OUT pBstrDocString: WideString; OUT pdwHelpContext: DWORD; OUT pBstrHelpFile: WideString):HResult;StdCall;
+ {$endif}
+
+ {$ifndef Call_as}
+ Function GetDllEntry(memid: MEMBERID; invKind: INVOKEKIND; OUT pBstrDllName: WideString; OUT pBstrName: WideString; OUT pwOrdinal: WORD):HResult;StdCall;
+ {$else}
+ Function GetDllEntry(memid: MEMBERID; invKind: INVOKEKIND; refPtrFlags: DWORD; OUT pBstrDllName: WideString; OUT pBstrName: WideString; OUT pwOrdinal: WORD):HResult;StdCall;
+ {$endif}
+
+ Function GetRefTypeInfo(hRefType: HREFTYPE; OUT ppTInfo: ITypeInfo):HResult;StdCall;
+
+ {$ifndef Call_as}
+ Function AddressOfMember(memid: MEMBERID; invKind: INVOKEKIND; OUT ppv: Pointer):HResult;StdCall;
+ {$else}
+ Function LocalAddressOfMember():HResult;StdCall;
+ {$endif}
+
+ {$ifndef Call_as}
+ Function CreateInstance(CONST pUnkOuter: IUnknown; CONST riid: TIID; OUT ppvObj: Pointer):HResult;StdCall;
+ {$else}
+ Function CreateInstance(CONST riid: TIID; OUT ppvObj: pIUnknown):HResult;StdCall;
+ {$endif}
+ Function GetMops(memid: MEMBERID; OUT pBstrMops: WideString):HResult;StdCall;
+ {$ifndef Call_as}
+ Function GetContainingTypeLib(OUT ppTLib: ITypeLib; OUT pIndex: UINT):HResult;StdCall;
+ {$else}
+ Function GetContainingTypeLib(OUT ppTLib: ITypeLib; OUT pIndex: UINT):HResult;StdCall;
+ {$endif}
+ {$ifndef Call_as}
+ Procedure ReleaseTypeAttr( pTypeAttr: pTypeAttr); StdCall;
+ {$else}
+ Function ReleaseTypeAttr():HResult;StdCall;
+ {$endif}
+
+ {$ifndef Call_as}
+ Procedure ReleaseFuncDesc( pFuncDesc : lpFUNCDESC); StdCall;
+ {$else}
+ Function LocalReleaseFuncDesc():HResult;StdCall;
+ {$endif}
+ {$ifndef Call_as}
+ Procedure ReleaseVarDesc( pVarDesc : lpVarDesc); stdcall;
+ {$else}
+ Function LocalReleaseVarDesc():HResult;StdCall;
+ {$endif}
+ End;
+
+ ITypeInfo2 = Interface (ITypeInfo)
+ ['{00020412-0000-0000-C000-000000000046}']
+ Function GetTypeKind(OUT xpTypeKind: TYPEKIND):HResult;StdCall;
+ Function GetTypeFlags(OUT pTypeFlags: ULONG):HResult;StdCall;
+ Function GetFuncIndexOfMemId(memid: MEMBERID; invKind: INVOKEKIND; OUT pFuncIndex: UINT):HResult;StdCall;
+ Function GetVarIndexOfMemId(memid: MEMBERID; OUT pVarIndex: UINT):HResult;StdCall;
+ Function GetCustData(CONST guid: TGUID; OUT pVarVal: VARIANT):HResult;StdCall;
+ Function GetFuncCustData(index: UINT; CONST guid: TGUID; OUT pVarVal: VARIANT):HResult;StdCall;
+ Function GetParamCustData(indexFunc: UINT; indexParam: UINT; CONST guid: TGUID; OUT pVarVal: VARIANT):HResult;StdCall;
+ Function GetVarCustData(index: UINT; CONST guid: TGUID; OUT pVarVal: VARIANT):HResult;StdCall;
+ Function GetImplTypeCustData(index: UINT; CONST guid: TGUID; OUT pVarVal: VARIANT):HResult;StdCall;
+ {$ifndef Call_as}
+ Function GetDocumentation2(memid: MEMBERID; lcid: LCID; pbstrHelpString: PWideString; pdwHelpStringContext: PDWORD; pbstrHelpStringDll: PWideString):HResult;StdCall;
+ {$else}
+ Function GetDocumentation2(memid: MEMBERID; lcid: LCID; refPtrFlags: DWORD; pbstrHelpString: PWideString; pdwHelpStringContext: PDWORD; pbstrHelpStringDll: PWideString):HResult;StdCall;
+ {$endif}
+ Function GetAllCustData(OUT pCustData: CUSTDATA):HResult;StdCall;
+ Function GetAllFuncCustData(index: UINT; OUT pCustData: CUSTDATA):HResult;StdCall;
+ Function GetAllParamCustData(indexFunc: UINT; indexParam: UINT; OUT pCustData: CUSTDATA):HResult;StdCall;
+ Function GetAllVarCustData(index: UINT; OUT pCustData: CUSTDATA):HResult;StdCall;
+ Function GetAllImplTypeCustData(index: UINT; OUT pCustData: CUSTDATA):HResult;StdCall;
+ End;
+
+ ITypeLib = Interface (IUnknown)
+ ['{00020402-0000-0000-C000-000000000046}']
+ {$ifndef Call_as}
+ Function GetTypeInfoCount:UINT; StdCall;
+ {$else}
+ Function GetTypeInfoCount(OUT pcTInfo: UINT):HResult;StdCall;
+ {$endif}
+ Function GetTypeInfo(index: UINT; OUT ppTInfo: ITypeInfo):HResult;StdCall;
+ Function GetTypeInfoType(index: UINT; OUT pTKind: TYPEKIND):HResult;StdCall;
+ Function GetTypeInfoOfGuid(CONST guid: TGUID; OUT ppTinfo: ITypeInfo):HResult;StdCall;
+ {$ifndef Call_as}
+ Function GetLibAttr(OUT ppTLibAttr: lpTLIBATTR):HResult;StdCall;
+ {$else}
+ Function GetLibAttr(OUT ppTLibAttr: LPTLIBATTR; OUT pDummy: CLEANLOCALSTORAGE):HResult;StdCall;
+ {$endif}
+
+ Function GetTypeComp(OUT ppTComp: ITypeComp):HResult;StdCall;
+ {$ifndef Call_as}
+ Function GetDocumentation(index: WINT; pBstrName: PWideString; pBstrDocString: PWideString; pdwHelpContext: PDWORD; pBstrHelpFile: PWideString):HResult;StdCall;
+ {$else}
+ Function GetDocumentation(index: WINT; refPtrFlags: DWORD; pBstrName: PWideString; pBstrDocString: PWideString; pdwHelpContext: PDWORD; pBstrHelpFile: PWideString):HResult;StdCall;
+ {$endif}
+
+ {$ifndef Call_as}
+ Function IsName(szNameBuf: pOleStr; lHashVal: ULONG; OUT pfName: BOOL):HResult;StdCall;
+ {$else}
+ Function IsName(szNameBuf: pOleStr; lHashVal: ULONG; OUT pfName: BOOL; OUT pBstrLibName: WideString):HResult;StdCall;
+ {$endif}
+ {$ifndef Call_as}
+ Function FindName(szNameBuf: pOleStr; lHashVal: ULONG; OUT ppTInfo: ITypeInfo; OUT rgMemId: MEMBERID; VAR pcFound: USHORT):HResult;StdCall;
+ {$else}
+ Function FindName(szNameBuf: pOleStr; lHashVal: ULONG; OUT ppTInfo: ITypeInfo; OUT rgMemId: MEMBERID; VAR pcFound: USHORT; OUT pBstrLibName: WideString):HResult;StdCall;
+ {$endif}
+ {$ifndef Call_as}
+ Procedure ReleaseTLibAttr( pTLibAttr : LPTLIBATTR); StdCall;
+ {$else}
+ Function LocalReleaseTLibAttr:HResult;StdCall;
+ {$endif}
+ End;
+
+ ITypeLib2 = Interface (ITypeLib)
+ ['{00020411-0000-0000-C000-000000000046}']
+ Function GetCustData(CONST guid: TGUID; OUT pVarVal: VARIANT):HResult;StdCall;
+ {$ifndef Call_as}
+ Function GetLibStatistics(OUT pcUniqueNames: ULONG; OUT pcchUniqueNames: ULONG):HResult;StdCall;
+ {$else}
+ Function GetLibStatistics(OUT pcUniqueNames: ULONG; OUT pcchUniqueNames: ULONG):HResult;StdCall;
+ {$endif}
+ {$ifndef Call_as}
+ Function GetDocumentation2(index: WINT; lcid: LCID; pbstrHelpString: PWideString; pdwHelpStringContext: PDWORD; pbstrHelpStringDll: PWideString):HResult;StdCall;
+ {$else}
+ Function GetDocumentation2(index: WINT; lcid: LCID; refPtrFlags: DWORD; pbstrHelpString: PWideString; pdwHelpStringContext: PDWORD; pbstrHelpStringDll: PWideString):HResult;StdCall;
+ {$endif}
+ Function GetAllCustData(OUT pCustData: CUSTDATA):HResult;StdCall;
+ End;
+
+ ITypeChangeEvents= Interface (IUnknown)
+ ['{00020410-0000-0000-C000-000000000046}']
+ Function RequestTypeChange(changeKind: CHANGEKIND; CONST pTInfoBefore: ITypeInfo; pStrName: pOleStr; OUT pfCancel: WINT):HResult;StdCall;
+ Function AfterTypeChange(changeKind: CHANGEKIND; CONST pTInfoAfter: ITypeInfo; pStrName: pOleStr):HResult;StdCall;
+ End;
+
+ IErrorInfo= Interface (IUnknown)
+ ['{1CF2B120-547D-101B-8E65-08002B2BD119}']
+ Function GetGUID(OUT pGUID: TGUID):HResult;StdCall;
+ Function GetSource(OUT pBstrSource: WideString):HResult;StdCall;
+ Function GetDescription(OUT pBstrDescription: WideString):HResult;StdCall;
+ Function GetHelpFile(OUT pBstrHelpFile: WideString):HResult;StdCall;
+ Function GetHelpContext(OUT pdwHelpContext: DWORD):HResult;StdCall;
+ End;
+
+ ICreateErrorInfo= Interface (IUnknown)
+ ['{22F03340-547D-101B-8E65-08002B2BD119}']
+ Function SetGUID(CONST rguid: TGUID):HResult;StdCall;
+ Function SetSource(szSource: pOleStr):HResult;StdCall;
+ Function SetDescription(szDescription: pOleStr):HResult;StdCall;
+ Function SetHelpFile(szHelpFile: pOleStr):HResult;StdCall;
+ Function SetHelpContext(dwHelpContext: DWORD):HResult;StdCall;
+ End;
+
+ ISupportErrorInfo= Interface (IUnknown)
+ ['{DF0B3D60-548F-101B-8E65-08002B2BD119}']
+ Function InterfaceSupportsErrorInfo(CONST riid: TIID):HResult;StdCall;
+ End;
+
+ ITypeFactory = Interface (IUnknown)
+ ['{0000002E-0000-0000-C000-000000000046}']
+ Function CreateFromTypeInfo(CONST pTypeInfo: ITypeInfo; CONST riid: TIID; OUT ppv: IUnknown):HResult;StdCall;
+ End;
+
+ ITypeMarshal = Interface (IUnknown)
+ ['{0000002D-0000-0000-C000-000000000046}']
+ Function Size(pvType: Pointer; dwDestContext: DWORD; pvDestContext: Pointer; OUT pSize: ULONG):HResult;StdCall;
+ Function Marshal(pvType: Pointer; dwDestContext: DWORD; pvDestContext: Pointer; cbBufferLength: ULONG; OUT pBuffer: BYTE; OUT pcbWritten: ULONG):HResult;StdCall;
+ Function Unmarshal(pvType: Pointer; dwFlags: DWORD; cbBufferLength: ULONG; CONST pBuffer: BYTE; OUT pcbRead: ULONG):HResult;StdCall;
+ Function Free(pvType: Pointer):HResult;StdCall;
+ End;
+
+ IRecordInfo = Interface(IUnknown)
+ ['{0000002F-0000-0000-C000-000000000046}']
+ Function RecordInit(pvNew: Pointer):HResult;StdCall;
+ Function RecordClear(pvExisting: Pointer):HResult;StdCall;
+ Function RecordCopy(pvExisting: Pointer; pvNew: Pointer):HResult;StdCall;
+ Function GetGuid(OUT pguid: TGUID):HResult;StdCall;
+ Function GetName(OUT pbstrName: WideString):HResult;StdCall;
+ Function GetSize(OUT pcbSize: ULONG):HResult;StdCall;
+ Function GetTypeInfo(OUT ppTypeInfo: ITypeInfo):HResult;StdCall;
+ Function GetField(pvData: Pointer; szFieldName: pOleStr; OUT pvarField: VARIANT):HResult;StdCall;
+ Function GetFieldNoCopy(pvData: Pointer; szFieldName: pOleStr; OUT pvarField: VARIANT; OUT ppvDataCArray: Pointer):HResult;StdCall;
+ Function PutField(wFlags: ULONG; pvData: Pointer; szFieldName: pOleStr; CONST pvarField: VARIANT):HResult;StdCall;
+ Function PutFieldNoCopy(wFlags: ULONG; pvData: Pointer; szFieldName: pOleStr; CONST pvarField: VARIANT):HResult;StdCall;
+ Function GetFieldNames(VAR pcNames: ULONG; OUT rgBstrNames: WideString):HResult;StdCall;
+ Function IsMatchingType(CONST pRecordInfo : IRecordInfo):Bool;StdCall;
+ Function RecordCreate : Pointer; StdCall;
+ Function RecordCreateCopy(pvSource: Pointer; OUT ppvDest: Pointer):HResult;StdCall;
+ Function RecordDestroy(pvRecord: Pointer):HResult;StdCall;
+ End;
+
+ IErrorLog = Interface (IUnknown)
+ ['{3127CA40-446E-11CE-8135-00AA004BB851}']
+ Function AddError(pszPropName: pOleStr; CONST pExcepInfo: EXCEPINFO):HResult;StdCall;
+ End;
+
+
+ IPropertyBag = Interface (IUnknown)
+ ['{55272A00-42CB-11CE-8135-00AA004BB851}']
+ {$ifndef Call_as}
+ Function Read(pszPropName: pOleStr; VAR pVar: VARIANT; CONST pErrorLog: IErrorLog):HResult;StdCall;
+ {$else}
+ Function Read(pszPropName: pOleStr; OUT pVar: VARIANT; CONST pErrorLog: IErrorLog; varType: DWORD; CONST pUnkObj: IUnknown):HResult;StdCall;
+ {$endif}
+ Function Write(pszPropName: pOleStr; CONST pVar: VARIANT):HResult;StdCall;
+ End;
+
+ IEnumGUID = interface(IUnknown)
+ ['{0002E000-0000-0000-C000-000000000046}']
+ Function Next(celt: UINT; OUT rgelt: TGUID; pceltFetched: pUINT=nil):HResult;StdCall;
+ Function Skip(celt:UINT):HResult;StdCall;
+ Function Reset: HResult;StdCall;
+ Function Clone(out ppenum: IEnumGUID):HResult;StdCall;
+ End;
+
+ IBindHost = interface(IUnknown)
+ ['{FC4801A1-2BA9-11CF-A229-00AA003D7352}']
+ End;
+
+ IServiceProvider = interface(IUnknown)
+ ['{6D5140C1-7436-11CE-8034-00AA006009FA}']
+ Function QueryService(CONST rsid, iid: TGuid; OUT Obj):HResult;StdCall;
+ End;
+
+ PServiceProvider = ^IServiceProvider;
+
+ IParseDisplayName = interface(IUnknown)
+ ['{0000011A-0000-0000-C000-000000000046}']
+ Function ParseDisplayName(CONST bc: IBindCtx; pszDisplayName: POleStr;OUT chEaten: Longint; OUT mkOut: IMoniker): HResult;StdCall;
+ End;
+
+ IOleContainer = interface(IParseDisplayName)
+ ['{0000011B-0000-0000-C000-000000000046}']
+ Function EnumObjects(grfFlags: Longint; OUT Enum: IEnumUnknown):HResult;StdCall;
+ Function LockContainer(fLock: BOOL):HResult;StdCall;
+ End;
+
+ IOleClientSite = interface(IUnknown)
+ ['{00000118-0000-0000-C000-000000000046}']
+ Function SaveObject: HResult;StdCall;
+ Function GetMoniker(dwAssign: Longint; dwWhichMoniker: Longint;OUT mk: IMoniker):HResult;StdCall;
+ Function GetContainer(OUT container: IOleContainer):HResult;StdCall;
+ Function ShowObject:HResult;StdCall;
+ Function OnShowWindow(fShow: BOOL):HResult;StdCall;
+ Function RequestNewObjectLayout:HResult;StdCall;
+ End;
+
+ IOleWindow = interface(IUnknown)
+ ['{00000114-0000-0000-C000-000000000046}']
+ function GetWindow(out wnd: HWnd): HResult; stdcall;
+ function ContextSensitiveHelp(fEnterMode: BOOL): HResult; stdcall;
+ end;
+
+
+ tagOleMenuGroupWidths = record
+ width : array[0..5] Of LONG;
+ end;
+ OLEMENUGROUPWIDTHS = tagOleMenuGroupWidths;
+ TOleMenuGroupWidths = tagOleMenuGroupWidths;
+ LPOLEMENUGROUPWIDTHS = ^OLEMENUGROUPWIDTHS;
+ POleMenuGroupWidths = LPOLEMENUGROUPWIDTHS;
+
+
+ IProvideClassInfo = Interface (IUnknown)
+ ['{B196B283-BAB4-101A-B69C-00AA00341D07}']
+ function GetClassInfo(out pptti : ITypeInfo):HResult; StdCall;
+ end;
+
+
+ IProvideClassInfo2 = Interface (IProvideClassInfo)
+ ['{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}']
+ function GetGUID(dwguid:DWord;out pguid:TGUID):HResult; StdCall;
+ end;
+
+{ ******************************************************************************************************************
+ stuff from objbase.h
+ ****************************************************************************************************************** }
+
+ tagOIFI = record
+ cb: UINT;
+ fMDIApp: BOOL;
+ hwndFrame: HWND;
+ haccel: HAccel;
+ cAccelEntries: UINT;
+ end;
+ TOleInPlaceFrameInfo = tagOIFI;
+ POleInPlaceFrameInfo = ^TOleInPlaceFrameInfo;
+ LPOleInPlaceFrameInfo = POleInPlaceFrameInfo;
+ OLEINPLACEFRAMEINFO = tagOIFI;
+
+
+{ redefinitions }
+ function CoCreateGuid(out _para1:TGUID):HRESULT;stdcall;external 'ole32.dll' name 'CoCreateGuid';
+
+{ additional definitions }
+{$ifndef wince}
+ function IsEqualGUID(const guid1,guid2 : TGUID) : Boolean;stdcall;external 'ole32.dll' name 'IsEqualGUID';
+ function IsEqualIID(const iid1,iid2 : TIID) : Boolean;stdcall;external 'ole32.dll' name 'IsEqualGUID';
+ function IsEqualCLSID(const clsid1,clsid2 : TCLSID) : Boolean;stdcall;external 'ole32.dll' name 'IsEqualGUID';
+{$endif wince}
+
+{ OleIdl.h }
+type
+ IOleInPlaceActiveObject = interface;
+
+ IOleAdviseHolder = interface(IUnknown)
+ ['{00000111-0000-0000-C000-000000000046}']
+ function Advise(const advise: IAdviseSink; out dwConnection: DWORD): HResult;StdCall;
+ function Unadvise(dwConnection: DWORD): HResult;StdCall;
+ function EnumAdvise(out enumAdvise: IEnumStatData): HResult;StdCall;
+ function SendOnRename(const mk: IMoniker): HResult;StdCall;
+ function SendOnSave: HResult;StdCall;
+ function SendOnClose: HResult;StdCall;
+ end;
+
+ IEnumOLEVERB = interface(IUnknown)
+ ['{00000104-0000-0000-C000-000000000046}']
+ function Next(celt: ULONG; out elt; pceltFetched: PULONG=nil): HResult;StdCall;
+ function Skip(celt: ULONG): HResult;StdCall;
+ function Reset: HResult;StdCall;
+ function Clone(out ppenum: IEnumOLEVERB): HResult;StdCall;
+ end;
+
+ IDropSource = interface(IUnknown)
+ ['{00000121-0000-0000-C000-000000000046}']
+ function QueryContinueDrag(fEscapePressed: BOOL;
+ grfKeyState: Longint):HResult;StdCall;
+ function GiveFeedback(dwEffect: Longint): HResult;StdCall;
+ end;
+
+ IOleObject = interface(IUnknown)
+ ['{00000112-0000-0000-C000-000000000046}']
+ function SetClientSite(const clientSite: IOleClientSite): HResult;StdCall;
+ function GetClientSite(out clientSite: IOleClientSite): HResult;StdCall;
+ function SetHostNames(szContainerApp: POleStr; szContainerObj: POleStr): HResult;StdCall;
+ function Close(dwSaveOption: DWORD): HResult;StdCall;
+ function SetMoniker(dwWhichMoniker: DWORD; const mk: IMoniker): HResult;StdCall;
+ function GetMoniker(dwAssign: DWORD; dwWhichMoniker: DWORD; out mk: IMoniker): HResult;StdCall;
+ function InitFromData(const dataObject: IDataObject; fCreation: BOOL; dwReserved: DWORD): HResult;StdCall;
+ function GetClipboardData(dwReserved: DWORD; out dataObject: IDataObject): HResult;StdCall;
+ function DoVerb(iVerb: LONG; msg: PMsg; const activeSite: IOleClientSite; lindex: LONG; hwndParent: HWND; const posRect: TRect): HResult;StdCall;
+ function EnumVerbs(out enumOleVerb: IEnumOleVerb): HResult;StdCall;
+ function Update: HResult;StdCall;
+ function IsUpToDate: HResult;StdCall;
+ function GetUserClassID(out clsid: TCLSID): HResult;StdCall;
+ function GetUserType(dwFormOfType: DWORD; out pszUserType: POleStr): HResult;StdCall;
+ function SetExtent(dwDrawAspect: DWORD; const size: TPoint): HResult;StdCall;
+ function GetExtent(dwDrawAspect: DWORD; out size: TPoint): HResult;StdCall;
+ function Advise(const advSink: IAdviseSink; out dwConnection: Longint): HResult;StdCall;
+ function Unadvise(dwConnection: DWORD): HResult;StdCall;
+ function EnumAdvise(out enumAdvise: IEnumStatData): HResult;StdCall;
+ function GetMiscStatus(dwAspect: DWORD; out dwStatus: DWORD): HResult;StdCall;
+ function SetColorScheme(const logpal: TLogPalette): HResult;StdCall;
+ end;
+
+ IDropTarget = interface(IUnknown)
+ ['{00000122-0000-0000-C000-000000000046}']
+ function DragEnter(const dataObj: IDataObject; grfKeyState: DWORD; pt: TPoint; var dwEffect: DWORD): HResult;StdCall;
+ function DragOver(grfKeyState: DWORD; pt: TPoint; var dwEffect: DWORD): HResult;StdCall;
+ function DragLeave: HResult;StdCall;
+ function Drop(const dataObj: IDataObject; grfKeyState: DWORD; pt: TPoint; var dwEffect: DWORD):HResult;StdCall;
+ end;
+
+ IOleInPlaceUIWindow = interface(IOleWindow)
+ ['{00000115-0000-0000-C000-000000000046}']
+ function GetBorder(out rectBorder: TRect):HResult;StdCall;
+ function RequestBorderSpace(const borderwidths: TRect):HResult;StdCall;
+ function SetBorderSpace(const borderwidths: TRect):HResult;StdCall;
+ function SetActiveObject(const activeObject: IOleInPlaceActiveObject;pszObjName: POleStr):HResult;StdCall;
+ end;
+
+ IOleInPlaceActiveObject = interface(IOleWindow)
+ ['{00000117-0000-0000-C000-000000000046}']
+ function TranslateAccelerator(var msg: TMsg):HResult;StdCall;
+ function OnFrameWindowActivate(fActivate: BOOL):HResult;StdCall;
+ function OnDocWindowActivate(fActivate: BOOL):HResult;StdCall;
+ function ResizeBorder(const rcBorder: TRect; const uiWindow: IOleInPlaceUIWindow; fFrameWindow: BOOL):HResult;StdCall;
+ function EnableModeless(fEnable: BOOL):HResult;StdCall;
+ end;
+
+ IOleInPlaceFrame = interface(IOleInPlaceUIWindow)
+ ['{00000116-0000-0000-C000-000000000046}']
+ function InsertMenus(hmenuShared: HMenu; var menuWidths: TOleMenuGroupWidths): HResult;StdCall;
+ function SetMenu(hmenuShared: HMenu; holemenu: HMenu; hwndActiveObject: HWnd): HResult;StdCall;
+ function RemoveMenus(hmenuShared: HMenu): HResult;StdCall;
+ function SetStatusText(pszStatusText: POleStr): HResult;StdCall;
+ function EnableModeless(fEnable: BOOL): HResult;StdCall;
+ function TranslateAccelerator(var msg: TMsg; wID: Word): HResult;StdCall;
+ end;
+
+ IOleLink = interface(IUnknown)
+ ['{0000011d-0000-0000-C000-000000000046}']
+ function SetUpdateOptions(dwupdateopt:dword):HResult; stdcall;
+ function GetUpdateOptions(dwupdateopt:pdword):HResult; stdcall;
+ function SetSourceMoniker(pmk : IMoniker;const clsid: TCLSID):HRESULT; stdcall;
+ function GetSourceMoniker(out pmk : IMoniker):HRESULT; stdcall;
+ function SetSourceDisplayName(ppszDisplayName:lpolestr):HResult; stdcall;
+ function GetSourceDisplayName(out ppszDisplayName:lpolestr):HResult; stdcall;
+ function BindToSource(bindflags:DWord;pbc: IBindCTX):HResult; stdcall;
+ function BindIfRunning:HResult; stdcall;
+ function GetBoundSource(out ppunk: IUnKnown):HResult; stdcall;
+ function UnbindSource:HResult; stdcall;
+ function Update(pbc:IBindCtx):HResult; stdcall;
+ end;
+
+ IOleInPlaceSite = interface(IOleWindow)
+ ['{00000119-0000-0000-C000-000000000046}']
+ function CanInPlaceActivate : HResult;
+ function OnInPlaceActivate : HResult;
+ function OnUIActivate : HResult;
+ function GetWindowContext(out ppframe:IOleInPlaceFrame;out ppdoc:IOleInPlaceUIWindow;lprcposrect:LPRECT;lprccliprect:LPRECT;lpframeinfo:LPOLEINPLACEFRAMEINFO):hresult; stdcall;
+ function Scroll(scrollExtant:TSIZE):hresult; stdcall;
+ function OnUIDeactivate(fUndoable:BOOL):hresult; stdcall;
+ function OnInPlaceDeactivate :hresult; stdcall;
+ function DiscardUndoState :hresult; stdcall;
+ function DeactivateAndUndo :hresult; stdcall;
+ function OnPosRectChange(lprcPosRect:LPRect):hresult; stdcall;
+ end;
+
+ IOleInPlaceObject = interface(IOleWindow)
+ ['{00000113-0000-0000-C000-000000000046}']
+ function InPlaceDeactivate : HResult;
+ function UIDeactivate : HResult;
+ function SetObjectRects(lprcPosRect:LPRect;lprcClipRect:LPRect):hresult; stdcall;
+ function ReactivateAndUndo : HResult;
+ end;
+
+ IOleDocumentView = interface(IUnknown)
+ ['{b722bcc6-4e68-101b-a2bc-00aa00404770}']
+ function SetInPlaceSite(ppipsite:IOleInPlaceSite):hresult; stdcall;
+ function GetInPlaceSite(out ppipsite:IOleInPlaceSite):hresult; stdcall;
+ function GetDocument(out ppipsite:Iunknown):hresult; stdcall;
+ function SetRect(prcview:LPRect):hresult; stdcall;
+ function Getrect(prcView:LPRect):hresult; stdcall;
+ function SetRectComplex(prcview:LPRect;prcHScroll:LPRect;prcVScroll:LPRect;prcSizeBox:LPRect):hresult; stdcall;
+ function Show(fshow:Bool) :hresult; stdcall;
+ function UIActivate(fUIActive :BOOL): HResult;
+ function Open :hresult; stdcall;
+ function Closeview(dwreserved:DWORD):hresult; stdcall;
+ function SaveViewState(pstm:IStream):hresult; stdcall;
+ function ApplyViewState(pstm:IStream):hresult; stdcall;
+ function Clone(pipsitenew: IOleInPlaceSite;out ppviewNew:IOleDocumentView):HResult;
+ end;
+
+ IEnumOleDocumentViews = Interface(IUnknown)
+ ['{b722bcc8-4e68-101b-a2bc-00aa00404770}']
+ function Next (CViews:ULONG; out rgpview:IOleDocumentView;pcfetched:pulong):hresult; stdcall;
+ function Skip (CViews:ULong):hresult; stdcall;
+ function Reset:HResult; stdcall;
+ function Clone (out ppenum :IEnumOleDocumentViews) :HResult; stdcall;
+ end;
+
+ IOleDocument = interface(IUnknown)
+ ['{b722bcc5-4e68-101b-a2bc-00aa00404770}']
+ function CreateView(pipsite:IOleInPlaceSite;pstm:IStream;dwReserved:DWord;out ppview : IOleDocumentView):hresult; stdcall;
+ function GetDocMiscStatus(pdwstatus:PDWord):hresult; stdcall;
+ function EnumViews(out ppenum:IEnumOleDocumentViews;out ppview:IOleDocumentView):hresult; stdcall;
+ end;
+
+ IOleDocumentSite = interface(IUnknown)
+ ['{b722bcc7-4e68-101b-a2bc-00aa00404770}']
+ function ActivateMe(pviewtoactivate:IOleDocumentView):hresult; stdcall;
+ end;
+
+ IContinueCallback = interface(IUnknown)
+ ['{b722bcca-4e68-101b-a2bc-00aa00404770}']
+ function FContinue:HResult;Stdcall;
+ function FContinuePrinting( nCntPrinted:LONG;nCurPage:Long;pwzprintstatus:polestr):HResult;Stdcall;
+ end;
+
+
+{ ObjSafe.idl}
+ IObjectSafety = interface(IUnknown)
+ ['{CB5BDC81-93C1-11cf-8F20-00805F2CD064}']
+ function GetInterfaceSafetyOptions(const riid:Tiid; out pdwsupportedoptions: dword;out pdwenabledoptions: dword):HRESULT; stdcall;
+ function SetInterfaceSafetyOptions(const riid:Tiid; const dwoptionsetmask: dword;const dwenabledoptions : dword):HRESULT; stdcall;
+ end;
+
+ TContinueCallback = function (dwcontinue:ULONG_PTR):BOOL; stdcall;
+
+
+ IViewObject = interface(IUnknown)
+ ['{0000010d-0000-0000-C000-000000000046}']
+ function Draw(dwDrawAspect:DWord;LIndex:Long;pvaspect:pointer;ptd:PDVTARGETDEVICE;hdcTargetDev:HDC; hdcDraw:HDC;lprcBounds:PRECTL;lprcWBounds:PRECTL;pfncontinue:TContinueCallback;dwcontinue:ULONG_PTR):HResult; stdcall;
+ function GetColorSet(wDrawAspect:DWord;LIndex:Long;pvaspect:pointer;ptd:PDVTARGETDEVICE;hdcTargetDev:HDC;var ppcolorset:PLogPalette):HREsult; stdcall;
+ function Freeze(dwDrawAspect:DWord;LIndex:Long;pvaspect:pointer;pdwfreeze:pdword):HResult;stdcall;
+ function Unfreeze(dwfreeze:dword):HResult; stdcall;
+ function SetAdvise(aspects:DWORD;advf:DWORD;padvSink:IAdviseSink):HRESULT;stdcall;
+ function Getadvise(paspects:pdword;padvf:pdword;out ppadvsink: IADviseSink):HRESULT;stdcall;
+ end;
+
+ IViewObject2 = interface(IViewObject)
+ ['{00000127-0000-0000-C000-000000000046}']
+ function GetExtent(dwDrawAspect:dword;lindex:DWord;ptd:pDVTARGETDEVICE;lpsizel:LPSIZEL):HRESULT;stdcall;
+ end;
+
+
+
+{ COMCAT}
+
+Const CATDESC_MAX = 128;
+
+Type
+ CATID = TGUID;
+ TCATID = TGUID;
+ PCATID = PGUID;
+ tagCATEGORYINFO = packed record
+ catid : CATID;
+ LCID : lcid;
+ szDescription : array[0..CATDESC_MAX-1] of WideChar;
+ end;
+
+ CATEGORYINFO = tagCATEGORYINFO;
+ TCATEGORYINFO = tagCATEGORYINFO;
+ LPCATEGORYINFO = ^tagCATEGORYINFO;
+ PCATEGORYINFO = LPCATEGORYINFO;
+
+ IEnumCLSID = IEnumGUID;
+ IEnumCategoryInfo = interface(IUnknown)
+ ['{0002E011-0000-0000-C000-000000000046}']
+ function Next(celt: ULONG; out rgelt: TCategoryInfo; out pceltFetched: ULONG): HResult; stdcall;
+ function Skip(celt:ULONG):HResult; StdCall;
+ function Reset:HResult; StdCall;
+ function CLone(Out ppenum : IEnumCategoryInfo):HResult;StdCall;
+ end;
+
+ ICatRegister = interface (IUnknown)
+ ['{0002E012-0000-0000-C000-000000000046}']
+ function RegisterCategories (cCategories:ULONG;rgCategoryInfo : PCategoryInfo):HResult;Stdcall;
+ function UnRegisterCategories (cCategories:ULONG;PCatid :PCATID):HResult;Stdcall;
+ function RegisterClassImplCategories (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;
+ function UnRegisterClassImplCategories (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;
+ function RegisterClassReqCategories (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;
+ function UnRegisterClassReqCategories (const rclsid:TGUID;cCategories:ULONG; rgCatid :PCATID):HResult;Stdcall;
+ end;
+
+ ICatInformation = interface(IUnknown)
+ ['{0002E013-0000-0000-C000-000000000046}']
+ function EnumCategories(lcid:lcid;out ppenumCategoryInfo : IEnumCategoryInfo):HResult; StdCall;
+ function GetCategoryDesc(rcatid:PCATID;lcid:LCID;out pszdesc:lpwstr):HResult; StdCall;
+ function EnumClassesOfCategories(cImplemented : ULong; rgcatidImpl:PCATID;cRequired:ULong; rgcatidreq:PCATID; out ppenumclsid : IEnumClsID):HResult; StdCall;
+ function ISClassOfCategories(rclsid:pclsid;cImplemented:ULong;rgcatidimpl:PCATID;CRequired:ULONG;rgcatidreq : pcatid):HResult; StdCall;
+ function EnumImplCategoriesOfClass(rclsid:pclsid;out ppenumclsid : IEnumClsID):HResult; StdCall;
+ function EnumReqCategoriesOfClass(rclsid:pclsid;out ppenumclsid : IEnumClsID):HResult; StdCall;
+ end;
+
+ IPropertySetStorage = Interface(IUnknown)
+ ['{0000013A-0000-0000-C000-000000000046}']
+ function Create(const rfmtid:FMTID; const pclsid:CLSID; grfFlags:DWORD; grfMode:DWORD; out ppprstg:IPropertyStorage):HRESULT; StdCall;
+ function Open(const fmtid:FMTID; grfMode:DWORD; out ppprstg:IPropertyStorage):HRESULT; StdCall;
+ function Delete(const rfmtid:FMTID):HRESULT; StdCall;
+ function Enum(out ppenum:IEnumSTATPROPSETSTG):HRESULT; StdCall;
+ end;
+
+ IEnumSTATPROPSTG = interface( IUnknown)
+ ['{00000139-0000-0000-C000-000000000046}']
+ function Next(celt:ULONG; var rgelt:STATPROPSTG; pceltFetched:pULONG):HRESULT; StdCall;
+ function Skip(celt:ULONG):HRESULT; StdCall;
+ function Reset:HRESULT; StdCall;
+ function Clone(out ppenum:IEnumSTATPROPSTG):HRESULT; StdCall;
+ end;
+
+ IEnumSTATPROPSETSTG = interface( IUnknown)
+ ['{0000013B-0000-0000-C000-000000000046}']
+ function Next(celt:ULONG; var rgelt:STATPROPSETSTG; pceltFetched:pULONG):HRESULT; StdCall;
+ function Skip(celt:ULONG):HRESULT; StdCall;
+ function Reset:HRESULT; StdCall;
+ function Clone(out ppenum:IEnumSTATPROPSETSTG):HRESULT; StdCall;
+ end;
+
+ IPropertyStorage = interface(IUnknown)
+ ['{00000138-0000-0000-C000-000000000046}']
+ function ReadMultiple(cpspec:ULONG; rgpspec:pPROPSPEC; rgpropvar:pPROPVARIANT):HRESULT; StdCall;
+ function WriteMultiple(cpspec:ULONG; rgpspec:pPROPSPEC; rgpropvar:pPROPVARIANT; propidNameFirst:PROPID):HRESULT; StdCall;
+ function DeleteMultiple(cpspec:ULONG; rgpspec:pPROPSPEC):HRESULT; StdCall;
+ function ReadPropertyNames(cpspec:ULONG; rgpropid:pPROPID; rgpropvar:plpolestr):HRESULT; StdCall;
+ function WritePropertyNames(cpspec:ULONG; rgpspec:pPROPID; rgpropvar:plpolestr):HRESULT; StdCall;
+ function DeletePropertyNames(cpspec:ULONG; rgpspec:pPROPid):HRESULT; StdCall;
+ function Commit(grfCommitFlags:DWORD):HRESULT; StdCall;
+ function Revert:HRESULT; StdCall;
+ function Enum(out ppenum:IEnumSTATPROPSTG):HRESULT; StdCall;
+ function SetTimes(pctime:PFILETIME; patime:PFILETIME; pmtime:PFILETIME):HRESULT; StdCall;
+ function SetClass(clsid:pCLSID):HRESULT; StdCall;
+ function Stat(pstatpsstg:pSTATPROPSETSTG):HRESULT; StdCall;
+ end;
+
+{ ole2.h }
+
+ type
+ WINOLEAPI = HResult;
+ TLCID = DWORD; // is this needed (duplicate from windows?)
+
+ const
+ OLEIVERB_PRIMARY = 0;
+ OLEIVERB_SHOW = -(1);
+ OLEIVERB_OPEN = -(2);
+ OLEIVERB_HIDE = -(3);
+ OLEIVERB_UIACTIVATE = -(4);
+ OLEIVERB_INPLACEACTIVATE = -(5);
+ OLEIVERB_DISCARDUNDOSTATE = -(6);
+ { for OleCreateEmbeddingHelper flags; roles low word; options high word }
+ EMBDHLP_INPROC_HANDLER = $0000;
+ EMBDHLP_INPROC_SERVER = $0001;
+ EMBDHLP_CREATENOW = $00000000;
+ EMBDHLP_DELAYCREATE = $00010000;
+ { extended create function flags }
+ OLECREATE_LEAVERUNNING = $00000001;
+ { pull the MIDL generated header }
+{$ifndef wince}
+ function OleBuildVersion:DWORD;stdcall;external 'ole32.dll' name 'OleBuildVersion';
+{$endif wince}
+ { helper functions }
+ function ReadClassStg(pStg:IStorage; pclsid:PCLSID):WINOLEAPI;stdcall;external 'ole32.dll' name 'ReadClassStg';
+ function WriteClassStg(pStg:IStorage;const rclsid:TCLSID):WINOLEAPI;stdcall;external 'ole32.dll' name 'WriteClassStg';
+ function ReadClassStm(pStm:IStream; pclsid:PCLSID):WINOLEAPI;stdcall;external 'ole32.dll' name 'ReadClassStm';
+ function WriteClassStm(pStm:IStream;const rclsid:TCLSID):WINOLEAPI;stdcall;external 'ole32.dll' name 'WriteClassStm';
+{$ifndef wince}
+ function WriteFmtUserTypeStg(pstg:IStorage; cf:CLIPFORMAT; lpszUserType:LPOLESTR):WINOLEAPI;stdcall;external 'ole32.dll' name 'WriteFmtUserTypeStg';
+ function ReadFmtUserTypeStg(pstg:IStorage; pcf:PCLIPFORMAT;out lplpszUserType:POleStr):WINOLEAPI;stdcall;external 'ole32.dll' name 'ReadFmtUserTypeStg';
+
+ { init/term }
+ function OleInitialize(pvReserved:LPVOID):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleInitialize';
+ procedure OleUninitialize;stdcall;external 'ole32.dll' name 'OleUninitialize';
+
+ { APIs to query whether (Embedded/Linked) object can be created from
+ the data object }
+ function OleQueryLinkFromData(pSrcDataObject:IDataObject):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleQueryLinkFromData';
+ function OleQueryCreateFromData(pSrcDataObject:IDataObject):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleQueryCreateFromData';
+{$endif wince}
+ { Object creation APIs }
+ function OleCreate(const rclsid:TCLSID; const riid:TIID;
+ renderopt:DWORD; pFormatEtc:LPFORMATETC; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name
+ 'OleCreate';
+{$ifndef wince}
+ function OleCreateEx(const rclsid:TCLSID; const riid:TIID; dwFlags:DWORD; renderopt:DWORD; cFormats:ULONG;
+ rgAdvf:PDWORD; rgFormatEtc:LPFORMATETC; lpAdviseSink:IAdviseSink; rgdwConnection:PDWORD; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateEx';
+
+ function OleCreateFromData(pSrcDataObj:IDataObject; const riid:TIID; renderopt:DWORD; pFormatEtc:LPFORMATETC; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateFromData';
+
+ function OleCreateFromDataEx(pSrcDataObj:IDataObject; const riid:TIID; dwFlags:DWORD; renderopt:DWORD; cFormats:ULONG;
+ rgAdvf:PDWORD; rgFormatEtc:LPFORMATETC; lpAdviseSink:IAdviseSink; rgdwConnection:PDWORD; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateFromDataEx';
+
+ function OleCreateLinkFromData(pSrcDataObj:IDataObject; const riid:TIID; renderopt:DWORD; pFormatEtc:LPFORMATETC; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateLinkFromData';
+
+ function OleCreateLinkFromDataEx(pSrcDataObj:IDataObject; const riid:TIID; dwFlags:DWORD; renderopt:DWORD; cFormats:ULONG;
+ rgAdvf:PDWORD; rgFormatEtc:LPFORMATETC; lpAdviseSink:IAdviseSink; rgdwConnection:PDWORD; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateLinkFromDataEx';
+
+ function OleCreateStaticFromData(pSrcDataObj:IDataObject; const iid:TIID; renderopt:DWORD; pFormatEtc:LPFORMATETC; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateStaticFromData';
+
+ function OleCreateLink(pmkLinkSrc:IMoniker; const riid:TIID; renderopt:DWORD; lpFormatEtc:LPFORMATETC; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateLink';
+
+ function OleCreateLinkEx(pmkLinkSrc:IMoniker; const riid:TIID; dwFlags:DWORD; renderopt:DWORD; cFormats:ULONG;
+ rgAdvf:PDWORD; rgFormatEtc:LPFORMATETC; lpAdviseSink:IAdviseSink; rgdwConnection:PDWORD; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateLinkEx';
+
+ function OleCreateLinkToFile(lpszFileName:POleStr; const riid:TIID; renderopt:DWORD; lpFormatEtc:LPFORMATETC; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateLinkToFile';
+
+ function OleCreateLinkToFileEx(lpszFileName:POleStr; const riid:TIID; dwFlags:DWORD; renderopt:DWORD; cFormats:ULONG;
+ rgAdvf:PDWORD; rgFormatEtc:LPFORMATETC; lpAdviseSink:IAdviseSink; rgdwConnection:PDWORD; pClientSite:IOleClientSite;
+ pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateLinkToFileEx';
+
+ function OleCreateFromFile(const rclsid:TCLSID; lpszFileName:POleStr; const riid:TIID; renderopt:DWORD; lpFormatEtc:LPFORMATETC;
+ pClientSite:IOleClientSite; pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateFromFile';
+
+ function OleCreateFromFileEx(const rclsid:TCLSID; lpszFileName:POleStr; const riid:TIID; dwFlags:DWORD; renderopt:DWORD;
+ cFormats:ULONG; rgAdvf:PDWORD; rgFormatEtc:LPFORMATETC; lpAdviseSink:IAdviseSink; rgdwConnection:PDWORD;
+ pClientSite:IOleClientSite; pStg:IStorage; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateFromFileEx';
+
+ function OleLoad(pStg:IStorage; const riid:TIID; pClientSite:IOleClientSite; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleLoad';
+ function OleLoadFromStream(pStm:IStream; const iidInterface:TIID; out ppvObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleLoadFromStream';
+ function OleSaveToStream(pPStm:IPersistStream; pStm:IStream):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleSaveToStream';
+ function OleNoteObjectVisible(pUnknown:IUnknown; fVisible:BOOL):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleNoteObjectVisible';
+{$endif wince}
+ function OleSave(pPS:IPersistStorage; pStg:IStorage; fSameAsLoad:BOOL):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleSave';
+ function OleSetContainedObject(pUnknown:IUnknown; fContained:BOOL):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleSetContainedObject';
+
+ { Drag/Drop APIs }
+{$ifndef wince}
+ function RegisterDragDrop(hwnd:HWND; pDropTarget:IDropTarget):WINOLEAPI;stdcall;external 'ole32.dll' name 'RegisterDragDrop';
+ function RevokeDragDrop(hwnd:HWND):WINOLEAPI;stdcall;external 'ole32.dll' name 'RevokeDragDrop';
+ function DoDragDrop(pDataObj:IDataObject; pDropSource:IDropSource; dwOKEffects:DWORD; pdwEffect:LPDWORD):WINOLEAPI;stdcall;external 'ole32.dll' name 'DoDragDrop';
+
+ { Clipboard APIs }
+ function OleSetClipboard(pDataObj:IDataObject):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleSetClipboard';
+ function OleGetClipboard(out ppDataObj:IDataObject):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleGetClipboard';
+ function OleFlushClipboard:WINOLEAPI;stdcall;external 'ole32.dll' name 'OleFlushClipboard';
+ function OleIsCurrentClipboard(pDataObj:IDataObject):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleIsCurrentClipboard';
+{$endif wince}
+
+type
+ HOLEMENU = HMenu;
+
+ { InPlace Editing APIs }
+{$ifndef wince}
+ function OleCreateMenuDescriptor(hmenuCombined:HMENU; lpMenuWidths:LPOLEMENUGROUPWIDTHS):HOLEMENU;stdcall;external 'ole32.dll' name 'OleCreateMenuDescriptor';
+ function OleDestroyMenuDescriptor(holemenu:HOLEMENU):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleDestroyMenuDescriptor';
+ function OleTranslateAccelerator(lpFrame:IOleInPlaceFrame; lpFrameInfo:TOleInPlaceFrameInfo; lpmsg:LPMSG):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleTranslateAccelerator';
+{$endif wince}
+ function OleSetMenuDescriptor(holemenu:HOLEMENU; hwndFrame:HWND; hwndActiveObject:HWND; lpFrame:IOleInPlaceFrame; lpActiveObj:IOleInPlaceActiveObject):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleSetMenuDescriptor';
+
+ { Helper APIs }
+{$ifndef wince}
+ function OleDuplicateData(hSrc:HANDLE; cfFormat:CLIPFORMAT; uiFlags:UINT):HANDLE;stdcall;external 'ole32.dll' name 'OleDuplicateData';
+ function OleLockRunning(pUnknown:IUnknown; fLock:BOOL; fLastUnlockCloses:BOOL):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleLockRunning';
+ function OleCreateDefaultHandler(const clsid:TCLSID; pUnkOuter:IUnknown; const riid:TIID; out lplpObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateDefaultHandler';
+ function OleCreateEmbeddingHelper(const clsid:TCLSID; pUnkOuter:IUnknown; flags:DWORD; pCF:IClassFactory; const riid:TIID;
+ out lplpObj):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleCreateEmbeddingHelper';
+ function IsAccelerator(hAccel:HACCEL; cAccelEntries:longint; lpMsg:LPMSG; lpwCmd:PWORD):BOOL;stdcall;external 'ole32.dll' name 'IsAccelerator';
+{$endif wince}
+ function OleDraw(pUnknown:IUnknown; dwAspect:DWORD; hdcDraw:HDC;const lprcBounds:TRect):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleDraw';
+ function OleRun(pUnknown:IUnknown):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleRun';
+ function OleIsRunning(pObject:IOleObject):BOOL;stdcall;external 'ole32.dll' name 'OleIsRunning';
+
+ procedure ReleaseStgMedium(var _para1:STGMEDIUM);stdcall;external 'ole32.dll' name 'ReleaseStgMedium';
+ procedure ReleaseStgMedium(_para1:LPSTGMEDIUM);stdcall;external 'ole32.dll' name 'ReleaseStgMedium';
+ function CreateOleAdviseHolder(out ppOAHolder:IOleAdviseHolder):WINOLEAPI;stdcall;external 'ole32.dll' name 'CreateOleAdviseHolder';
+
+ { Icon extraction Helper APIs }
+{$ifndef wince}
+ function OleGetIconOfFile(lpszPath:LPOLESTR; fUseFileAsLabel:BOOL):HGLOBAL;stdcall;external 'ole32.dll' name 'OleGetIconOfFile';
+ function OleGetIconOfClass(const rclsid:TCLSID; lpszLabel:LPOLESTR; fUseTypeAsLabel:BOOL):HGLOBAL;stdcall;external 'ole32.dll' name 'OleGetIconOfClass';
+ function OleMetafilePictFromIconAndLabel(hIcon:HICON; lpszLabel:LPOLESTR; lpszSourceFile:LPOLESTR; iIconIndex:UINT):HGLOBAL;stdcall;external 'ole32.dll' name 'OleMetafilePictFromIconAndLabel';
+{$endif wince}
+
+ { Registration Database Helper APIs }
+{$ifndef wince}
+ function OleRegGetUserType(const clsid:TCLSID; dwFormOfType:DWORD;out pszUserType:POleStr):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleRegGetUserType';
+ function OleRegGetMiscStatus(const clsid:TCLSID; dwAspect:DWORD; pdwStatus:PDWORD):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleRegGetMiscStatus';
+ function OleRegEnumFormatEtc(const clsid:TCLSID; dwDirection:DWORD;out ppenum:IEnumFormatEtc):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleRegEnumFormatEtc';
+ function OleRegEnumVerbs(const clsid:TCLSID;out ppenum:IEnumOLEVERB):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleRegEnumVerbs';
+{$endif wince}
+
+{$ifdef _MAC}
+ { WlmOLE helper APIs }
+
+ function WlmOleCheckoutMacInterface(pUnk:IUnknown; out ppv):WINOLEAPI;stdcall;external 'ole32.dll' name 'WlmOleCheckoutMacInterface';
+
+ function WlmOleCheckinMacInterface(pUnk:IUnknown):WINOLEAPI;stdcall;external 'ole32.dll' name 'WlmOleCheckinMacInterface';
+
+ function WlmOleWrapMacInterface(pUnk:IUnknown; const riid:TIID; out ppv):WINOLEAPI;stdcall;external 'ole32.dll' name 'WlmOleWrapMacInterface';
+
+ function WlmOleUnwrapMacInterface(pv:LPVOID):WINOLEAPI;stdcall;external 'ole32.dll' name 'WlmOleUnwrapMacInterface';
+
+ function WlmOleCheckoutWinInterface(pUnk:LPVOID; ppv:PIUnknown):WINOLEAPI;stdcall;external 'ole32.dll' name 'WlmOleCheckoutWinInterface';
+
+ function WlmOleCheckinWinInterface(pUnk:LPVOID):WINOLEAPI;stdcall;external 'ole32.dll' name 'WlmOleCheckinWinInterface';
+
+ function WlmOleWrapWinInterface(pUnk:LPVOID; const riid:TIID; ppv:PIUnknown):WINOLEAPI;stdcall;external 'ole32.dll' name 'WlmOleWrapWinInterface';
+
+ function WlmOleUnwrapWinInterface(pv:LPVOID):WINOLEAPI;stdcall;external 'ole32.dll' name 'WlmOleUnwrapWinInterface';
+
+ procedure WlmOleVersion;stdcall;external 'ole32.dll' name 'WlmOleVersion';
+
+ procedure WlmOleSetInPlaceWindow(hwnd:HWND);stdcall;external 'ole32.dll' name 'WlmOleSetInPlaceWindow';
+
+ { typedef HRESULT (STDAPICALLTYPE* OLEWRAPPROC) (TIID riid, LPVOID* ppvWin, LPVOID* ppvMac); }
+ function WlmOleRegisterUserWrap(procNew:OLEWRAPPROC; pprocOld:POLEWRAPPROC):WINOLEAPI;stdcall;external 'ole32.dll' name 'WlmOleRegisterUserWrap';
+
+{$endif}
+ { OLE 1.0 conversion APIS }
+ {**** OLE 1.0 OLESTREAM declarations ************************************ }
+
+ type
+ LPOLESTREAM = ^_OLESTREAM;
+ _OLESTREAMVTBL = record
+ Get : function (p : POleStr;out o;dw : DWORD) : DWORD;
+ Put : function (p : POleStr;const o;dw : DWORD) : DWORD;
+ end;
+ OLESTREAMVTBL = _OLESTREAMVTBL;
+
+ LPOLESTREAMVTBL = OLESTREAMVTBL;
+
+ _OLESTREAM = record
+ lpstbl : LPOLESTREAMVTBL;
+ end;
+ OLESTREAM = _OLESTREAM;
+(* Const before type ignored *)
+
+{$ifndef wince}
+ function OleConvertOLESTREAMToIStorage(_lpolestream:LPOLESTREAM; pstg:IStorage; ptd:PDVTARGETDEVICE):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleConvertOLESTREAMToIStorage';
+ function OleConvertIStorageToOLESTREAM(pstg:IStorage; lpolestream:LPOLESTREAM):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleConvertIStorageToOLESTREAM';
+{$endif wince}
+
+ { Storage Utility APIs }
+ function GetHGlobalFromILockBytes(plkbyt:ILockBytes;out phglobal:HGLOBAL):WINOLEAPI;stdcall;external 'ole32.dll' name 'GetHGlobalFromILockBytes';
+ function CreateStreamOnHGlobal(hGlobal:HGLOBAL; fDeleteOnRelease:BOOL;out stm:IStream):WINOLEAPI;stdcall;external 'ole32.dll' name 'CreateStreamOnHGlobal';
+{$ifndef wince}
+ function CreateILockBytesOnHGlobal(hGlobal:HGLOBAL; fDeleteOnRelease:BOOL;out pplkbyt:ILockBytes):WINOLEAPI;stdcall;external 'ole32.dll' name 'CreateILockBytesOnHGlobal';
+ function GetHGlobalFromStream(pstm:IStream;out phglobal:HGLOBAL):WINOLEAPI;stdcall;external 'ole32.dll' name 'GetHGlobalFromStream';
+{$endif wince}
+
+ { ConvertTo APIS }
+{$ifndef wince}
+ function OleDoAutoConvert(pStg:IStorage; pClsidNew:LPCLSID):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleDoAutoConvert';
+ function OleGetAutoConvert(const clsidOld:TCLSID; pClsidNew:LPCLSID):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleGetAutoConvert';
+ function OleSetAutoConvert(const clsidOld:TCLSID; clsidNew:TCLSID):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleSetAutoConvert';
+ function GetConvertStg(pStg:IStorage):WINOLEAPI;stdcall;external 'ole32.dll' name 'GetConvertStg';
+ function SetConvertStg(pStg:IStorage; fConvert:BOOL):WINOLEAPI;stdcall;external 'ole32.dll' name 'SetConvertStg';
+
+ { Presentation data to OLESTREAM }
+ { format }
+ { width }
+ { height }
+ { size bytes }
+ { bits }
+ function OleConvertIStorageToOLESTREAMEx(pstg:IStorage; cfFormat:CLIPFORMAT; lWidth:LONG; lHeight:LONG; dwSize:DWORD;
+ pmedium:LPSTGMEDIUM; polestm:LPOLESTREAM):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleConvertIStorageToOLESTREAMEx';
+
+ { Presentation data from OLESTREAM }
+ { format }
+ { width }
+ { height }
+ { size bytes }
+ function OleConvertOLESTREAMToIStorageEx(polestm:LPOLESTREAM; pstg:IStorage; pcfFormat:PCLIPFORMAT; plwWidth:PLONG; plHeight:PLONG;
+ pdwSize:PDWORD; pmedium:LPSTGMEDIUM):WINOLEAPI;stdcall;external 'ole32.dll' name 'OleConvertOLESTREAMToIStorageEx';
+{$endif wince}
+
+const
+ DROPEFFECT_NONE = 0;
+ DROPEFFECT_COPY = 1;
+ DROPEFFECT_MOVE = 2;
+ DROPEFFECT_LINK = 4;
+ DROPEFFECT_SCROLL = dword($80000000);
+
+
+type
+ BORDERWIDTHS = TRect;
+ LPBORDERWIDTHS = PRect;
+ LPCBORDERWIDTHS = PRect;
+
+ TBorderWidths = TRect;
+ PBorderWidths = PRect;
+
+ function CoInitializeEx(_para1:LPVOID; _para2:DWORD):HRESULT;stdcall; external 'ole32.dll' name 'CoInitializeEx';
+ procedure CoUninitialize;stdcall; external 'ole32.dll' name 'CoUninitialize';
+ function CoGetClassObject(const _para1:TCLSID; _para2:DWORD; _para3:PVOID; const _para4:TIID; out _para5):HRESULT;stdcall; external 'ole32.dll' name 'CoGetClassObject';
+ function CoLoadLibrary(_para1:LPOLESTR; _para2:BOOL):THandle;stdcall; external 'ole32.dll' name 'CoLoadLibrary';
+ procedure CoFreeLibrary(_para1:THandle);stdcall; external 'ole32.dll' name 'CoFreeLibrary';
+ procedure CoFreeUnusedLibraries;stdcall; external 'ole32.dll' name 'CoFreeUnusedLibraries';
+ function CoCreateInstance(const _para1:TCLSID; _para2:IUnknown; _para3:DWORD;const _para4:TIID;out _para5):HRESULT;stdcall; external 'ole32.dll' name 'CoCreateInstance';
+ function StringFromCLSID(const _para1:TCLSID; out _para2:POLESTR):HRESULT;stdcall; external 'ole32.dll' name 'StringFromCLSID';
+ function CLSIDFromString(_para1:LPOLESTR; _para2:LPCLSID):HRESULT;stdcall; external 'ole32.dll' name 'CLSIDFromString';
+ function StringFromIID(const _para1:TIID; out _para2:POLESTR):HRESULT;stdcall; external 'ole32.dll' name 'StringFromIID';
+ function ProgIDFromCLSID(para:PCLSID; out _para2:POLESTR):HRESULT;stdcall; external 'ole32.dll' name 'ProgIDFromCLSID';
+ function ProgIDFromCLSID(const _para1:TCLSID; out _para2:POLESTR):HRESULT;stdcall; external 'ole32.dll' name 'ProgIDFromCLSID';
+ function CLSIDFromProgID(_para1:POLESTR; _para2:LPCLSID):HRESULT;stdcall; external 'ole32.dll' name 'CLSIDFromProgID';
+ function CLSIDFromProgID(_para1:POLESTR; out _para2:TCLSID):HRESULT;stdcall; external 'ole32.dll' name 'CLSIDFromProgID';
+ function StringFromGUID2(const _para1:TGUID; _para2:LPOLESTR; _para3:longint):longint;stdcall; external 'ole32.dll' name 'StringFromGUID2';
+ function CoCreateGuid(_para1:PGUID):HRESULT;stdcall; external 'ole32.dll' name 'CoCreateGuid';
+{$ifndef wince}
+ function CoBuildVersion:DWORD;stdcall; external 'ole32.dll' name 'CoBuildVersion';
+ function CoInitialize(_para1:PVOID):HRESULT;stdcall; external 'ole32.dll' name 'CoInitialize';
+ function CoGetMalloc(_para1:DWORD; out _para2:IMalloc):HRESULT;stdcall; external 'ole32.dll' name 'CoGetMalloc';
+ function CoGetCurrentProcess:DWORD;stdcall; external 'ole32.dll' name 'CoGetCurrentProcess';
+ function CoRegisterMallocSpy(_para1:IMallocSpy):HRESULT;stdcall; external 'ole32.dll' name 'CoRegisterMallocSpy';
+ function CoRevokeMallocSpy:HRESULT;stdcall; external 'ole32.dll' name 'CoRevokeMallocSpy';
+ function CoCreateStandardMalloc(_para1:DWORD; out _para2:IMalloc):HRESULT;stdcall; external 'ole32.dll' name 'CoGetMalloc';
+ function CoRegisterClassObject(const _para1:TCLSID; _para2:IUnknown; _para3:DWORD; _para4:DWORD; _para5:PDWORD):HRESULT;stdcall; external 'ole32.dll' name 'CoRegisterClassObject';
+ function CoRevokeClassObject(_para1:DWORD):HRESULT;stdcall; external 'ole32.dll' name 'CoRevokeClassObject';
+ function CoGetMarshalSizeMax(_para1:PULONG;const _para2:TIID; _para3:IUnknown; _para4:DWORD; _para5:PVOID;
+ _para6:DWORD):HRESULT;stdcall; external 'ole32.dll' name 'CoGetMarshalSizeMax';
+ function CoMarshalInterface(_para1:IStream;const _para2:TIID; _para3:IUnknown; _para4:DWORD; _para5:PVOID;
+ _para6:DWORD):HRESULT;stdcall; external 'ole32.dll' name 'CoMarshalInterface';
+ function CoUnmarshalInterface(_para1:IStream;const _para2:TIID; out _para3):HRESULT;stdcall; external 'ole32.dll' name 'CoUnmarshalInterface';
+ function CoMarshalHresult(_para1:IStream; _para2:HRESULT):HRESULT;stdcall; external 'ole32.dll' name 'CoMarshalHresult';
+ function CoUnmarshalHresult(_para1:IStream; _para2:HRESULT):HRESULT;stdcall; external 'ole32.dll' name 'CoUnmarshalHresult';
+ function CoReleaseMarshalData(_para1:IStream):HRESULT;stdcall; external 'ole32.dll' name 'CoReleaseMarshalData';
+ function CoDisconnectObject(_para1:IUnknown; _para2:DWORD):HRESULT;stdcall; external 'ole32.dll' name 'CoDisconnectObject';
+ function CoLockObjectExternal(_para1:IUnknown; _para2:BOOL; _para3:BOOL):HRESULT;stdcall; external 'ole32.dll' name 'CoLockObjectExternal';
+ function CoGetStandardMarshal(const _para1:TIID; _para2:IUnknown; _para3:DWORD; _para4:PVOID; _para5:DWORD;
+ out _para6:IMarshal):HRESULT;stdcall; external 'ole32.dll' name 'CoGetStandardMarshal';
+ function CoGetStdMarshalEx(_para1:IUnknown; _para2:DWORD; out _para3:IUnknown):HRESULT;stdcall; external 'ole32.dll' name 'CoGetStdMarshalEx';
+ function CoIsHandlerConnected(_para1:IUnknown):BOOL;stdcall; external 'ole32.dll' name 'CoIsHandlerConnected';
+ function CoHasStrongExternalConnections(_para1:IUnknown):BOOL;stdcall; external 'ole32.dll' name 'CoHasStrongExternalConnections';
+ function CoMarshalInterThreadInterfaceInStream(const _para1:TIID; _para2:IUnknown; out _para3:IStream):HRESULT;stdcall; external 'ole32.dll' name 'CoMarshalInterThreadInterfaceInStream';
+ function CoGetInterfaceAndReleaseStream(_para1:IStream;const _para2:TIID; out _para3):HRESULT;stdcall; external 'ole32.dll' name 'CoGetInterfaceAndReleaseStream';
+ function CoCreateFreeThreadedMarshaler(_para1:IUnknown; out _para2:IUnknown):HRESULT;stdcall; external 'ole32.dll' name 'CoCreateFreeThreadedMarshaler';
+ procedure CoFreeAllLibraries;stdcall; external 'ole32.dll' name 'CoFreeAllLibraries';
+ function CoCreateInstanceEx(const _para1:TCLSID; _para2:IUnknown; _para3:DWORD; _para4:PCOSERVERINFO; _para5:DWORD;
+ _para6:PMULTI_QI):HRESULT;stdcall; external 'ole32.dll' name 'CoCreateInstanceEx';
+ function IIDFromString(_para1:LPOLESTR; out _para2:TIID):HRESULT;stdcall; external 'ole32.dll' name 'IIDFromString';
+ function CoIsOle1Class(const _para1:TCLSID):BOOL;stdcall; external 'ole32.dll' name 'CoIsOle1Class';
+ function CoFileTimeToDosDateTime(_para1:PFILETIME; _para2:LPWORD; _para3:LPWORD):BOOL;stdcall; external 'ole32.dll' name 'CoFileTimeToDosDateTime';
+ function CoDosDateTimeToFileTime(_para1:WORD; _para2:WORD; _para3:PFILETIME):BOOL;stdcall; external 'ole32.dll' name 'CoDosDateTimeToFileTime';
+ function CoFileTimeNow(_para1:PFILETIME):HRESULT;stdcall; external 'ole32.dll' name 'CoFileTimeNow';
+ function CoRegisterMessageFilter(_para1:IMessageFilter;out _para2:IMessageFilter):HRESULT;stdcall; external 'ole32.dll' name 'CoRegisterMessageFilter';
+ function CoGetTreatAsClass(const _para1:TCLSID; _para2:LPCLSID):HRESULT;stdcall; external 'ole32.dll' name 'CoGetTreatAsClass';
+ function CoTreatAsClass(const _para1:TCLSID; const _para2:TCLSID):HRESULT;stdcall; external 'ole32.dll' name 'CoTreatAsClass';
+{$endif wince}
+
+ type
+ LPFNGETCLASSOBJECT = function (const _para1:TCLSID; const _para2:TIID;out _para3):HRESULT;stdcall;
+ LPFNCANUNLOADNOW = function:HRESULT;stdcall;
+
+{$ifndef wince}
+ function DllGetClassObject(const _para1:TCLSID; const _para2:TIID; out _para3):HRESULT;stdcall; external 'ole32.dll' name 'DllGetClassObject';
+ function DllCanUnloadNow:HRESULT;stdcall; external 'ole32.dll' name 'DllCanUnloadNow';
+{$endif wince}
+ function CoTaskMemAlloc(_para1:ULONG):PVOID;stdcall; external 'ole32.dll' name 'CoTaskMemAlloc';
+ function CoTaskMemRealloc(_para1:PVOID; _para2:ULONG):PVOID;stdcall; external 'ole32.dll' name 'CoTaskMemRealloc';
+ procedure CoTaskMemFree(_para1:PVOID);stdcall; external 'ole32.dll' name 'CoTaskMemFree';
+
+{$ifndef wince}
+ function CreateDataAdviseHolder(_para1:IDataAdviseHolder):HRESULT;stdcall; external 'ole32.dll' name 'CreateDataAdviseHolder';
+ function CreateDataCache(_para1:IUnknown; const _para2:TCLSID; const _para3:TIID; out _para4):HRESULT;stdcall; external 'ole32.dll' name 'CreateDataCache';
+{$endif wince}
+
+(* Const before type ignored *)
+ function StgCreateDocfile(_para1:POLESTR; _para2:DWORD; _para3:DWORD; out _para4:IStorage):HRESULT;stdcall; external 'ole32.dll' name 'StgCreateDocfile';
+ function StgCreateDocfileOnILockBytes(_para1:ILockBytes; _para2:DWORD; _para3:DWORD; out _para4:IStorage):HRESULT;stdcall; external 'ole32.dll' name 'StgCreateDocfileOnILockBytes';
+
+(* Const before type ignored *)
+ function StgOpenStorage(_para1:POLESTR; _para2:IStorage; _para3:DWORD; _para4:SNB; _para5:DWORD;
+ out _para6:IStorage):HRESULT;stdcall; external 'ole32.dll' name 'StgOpenStorage';
+ function StgOpenStorageOnILockBytes(_para1:ILockBytes; _para2:IStorage; _para3:DWORD; _para4:SNB; _para5:DWORD;
+ out _para6:IStorage):HRESULT;stdcall; external 'ole32.dll' name 'StgOpenStorageOnILockBytes';
+{$ifndef wince}
+ function StgIsStorageFile(_para1:POLESTR):HRESULT;stdcall; external 'ole32.dll' name 'StgIsStorageFile';
+ function StgIsStorageILockBytes(_para1:ILockBytes):HRESULT;stdcall; external 'ole32.dll' name 'StgIsStorageILockBytes';
+ function StgSetTimes(_para1:POLESTR; _para2:PFILETIME; _para3:PFILETIME; _para4:PFILETIME):HRESULT;stdcall; external 'ole32.dll' name 'StgSetTimes';
+ function CoGetObject(pszname:lpwstr; bndop:PBind_Opts; const riid:TIID; out ppv):HRESULT; stdcall; external 'ole32.dll' name 'CoGetObject';
+ function BindMoniker(_para1:IMoniker; _para2:DWORD; const _para3:TIID; out _para4):HRESULT;stdcall; external 'ole32.dll' name 'BindMoniker';
+ function MkParseDisplayName(_para1:IBindCtx; _para2:POLESTR; out _para3:PULONG; out _para4:IMoniker):HRESULT;stdcall; external 'ole32.dll' name 'MkParseDisplayName';
+ function MonikerRelativePathTo(_para1:IMoniker; _para2:IMoniker; out _para3:IMoniker; _para4:BOOL):HRESULT;stdcall; external 'ole32.dll' name 'MonikerRelativePathTo';
+ function MonikerCommonPrefixWith(_para1:IMoniker; _para2:IMoniker; _para3:PIMoniker):HRESULT;stdcall; external 'ole32.dll' name 'MonikerCommonPrefixWith';
+{$endif wince}
+ function CreateBindCtx(_para1:DWORD;out _para2:IBindCtx):HRESULT;stdcall; external 'ole32.dll' name 'CreateBindCtx';
+ function GetClassFile(_para1:POLESTR; out _para2:TCLSID):HRESULT;stdcall; external 'ole32.dll' name 'GetClassFile';
+{$ifndef wince}
+ function CreateGenericComposite(_para1:IMoniker; _para2:IMoniker; out _para3:IMoniker):HRESULT;stdcall; external 'ole32.dll' name 'CreateGenericComposite';
+ function CreateFileMoniker(_para1:POLESTR; out _para2:IMoniker):HRESULT;stdcall; external 'ole32.dll' name 'CreateFileMoniker';
+ function CreateItemMoniker(_para1:POLESTR; _para2:POLESTR;out _para3:IMoniker):HRESULT;stdcall; external 'ole32.dll' name 'CreateItemMoniker';
+ function CreateAntiMoniker(_para1:PIMoniker):HRESULT;stdcall; external 'ole32.dll' name 'CreateAntiMoniker';
+ function CreatePointerMoniker(_para1:IUnknown; out _para2:IMoniker):HRESULT;stdcall; external 'ole32.dll' name 'CreatePointerMoniker';
+ function GetRunningObjectTable(_para1:DWORD; _para2:IRunningObjectTable):HRESULT;stdcall; external 'ole32.dll' name 'GetRunningObjectTable';
+ function CoInitializeSecurity(_para1:PSECURITY_DESCRIPTOR; _para2:LONG; _para3:PSOLE_AUTHENTICATION_SERVICE; _para4:pointer; _para5:DWORD;
+ _para6:DWORD; _para7:pointer; _para8:DWORD; _para9:pointer):HRESULT;stdcall; external 'ole32.dll' name 'CoInitializeSecurity';
+ function CoGetCallContext(const _para1:TIID; _para2:Ppointer):HRESULT;stdcall; external 'ole32.dll' name 'CoGetCallContext';
+ function CoQueryProxyBlanket(_para1:IUnknown; _para2:PDWORD; _para3:PDWORD; _para4:POLESTR; _para5:PDWORD;
+ _para6:PDWORD; _para7:Pointer; _para8:PDWORD):HRESULT;stdcall; external 'ole32.dll' name 'CoQueryProxyBlanket';
+ function CoSetProxyBlanket(_para1:IUnknown; _para2:DWORD; _para3:DWORD; _para4:POLESTR; _para5:DWORD;
+ _para6:DWORD; _para7:pointer; _para8:DWORD):HRESULT;stdcall; external 'ole32.dll' name 'CoSetProxyBlanket';
+ function CoCopyProxy(_para1:IUnknown; var _para2:IUnknown):HRESULT;stdcall; external 'ole32.dll' name 'CoCopyProxy';
+ function CoQueryClientBlanket(_para1:PDWORD; _para2:PDWORD; _para3:POLESTR; _para4:PDWORD; _para5:PDWORD;
+ _para6:pointer; _para7:PDWORD):HRESULT;stdcall; external 'ole32.dll' name 'CoQueryClientBlanket';
+ function CoImpersonateClient:HRESULT;stdcall; external 'ole32.dll' name 'CoImpersonateClient';
+ function CoRevertToSelf:HRESULT;stdcall; external 'ole32.dll' name 'CoRevertToSelf';
+ function CoQueryAuthenticationServices(_para1:PDWORD; _para2:PSOLE_AUTHENTICATION_SERVICE):HRESULT;stdcall; external 'ole32.dll' name 'CoQueryAuthenticationServices';
+ function CoSwitchCallContext(_para1:IUnknown; var _para2:IUnknown):HRESULT;stdcall; external 'ole32.dll' name 'CoSwitchCallContext';
+ function CoGetInstanceFromFile(_para1:PCOSERVERINFO; _para2:PCLSID; _para3:IUnknown; _para4:DWORD; _para5:DWORD;
+ _para6:POLESTR; _para7:DWORD; _para8:PMULTI_QI):HRESULT;stdcall; external 'ole32.dll' name 'CoGetInstanceFromFile';
+ function CoGetInstanceFromIStorage(_para1:PCOSERVERINFO; _para2:PCLSID; _para3:IUnknown; _para4:DWORD; _para5:IStorage;
+ _para6:DWORD; _para7:PMULTI_QI):HRESULT;stdcall; external 'ole32.dll' name 'CoGetInstanceFromIStorage';
+{$endif wince}
+
+ type
+ TDispID = DISPID;
+
+ TDispIDList = array[0..65535] of TDispID;
+ PDispIDList = ^TDispIDList;
+
+ REFIID = TIID;
+ TREFIID = TIID;
+
+{$ifndef wince}
+ function SetErrorInfo(dwReserved:ULONG;errinfo:IErrorInfo):HResult;stdcall; external 'ole32.dll' name 'SetErrorInfo';
+ function GetErrorInfo(dwReserved:ULONG;out errinfo:IErrorInfo):HResult;stdcall; external 'ole32.dll' name 'GetErrorInfo';
+ function CreateErrorInfo(out errinfo:ICreateErrorInfo):HResult;stdcall; external 'ole32.dll' name 'CreateErrorInfo';
+{$endif wince}
+
+ const
+ oleaut32dll = 'oleaut32.dll';
+
+ function SysAllocString(psz: pointer): TBStr; stdcall; external oleaut32dll name 'SysAllocString';
+ function SysAllocStringLen(psz: pointer; len:dword): Integer; stdcall; external oleaut32dll name 'SysAllocStringLen';
+ procedure SysFreeString(bstr:pointer); stdcall; external oleaut32dll name 'SysFreeString';
+ function SysStringLen(bstr:pointer):UINT; stdcall; external oleaut32dll name 'SysStringLen';
+ function SysStringByteLen(bstr:pointer):UINT; stdcall; external oleaut32dll name 'SysStringByteLen';
+ function SysReAllocString(var bstr:pointer;psz: pointer): Integer; stdcall; external oleaut32dll name 'SysReAllocString';
+ function SysReAllocStringLen(var bstr:pointer;psz: pointer; len:dword): Integer; stdcall; external oleaut32dll name 'SysReAllocStringLen';
+
+ { Active object registration API }
+{$ifndef wince}
+ const
+ ACTIVEOBJECT_STRONG = 0;
+ ACTIVEOBJECT_WEAK = 1;
+
+ function RegisterActiveObject(unk: IUnknown; const clsid: TCLSID; dwFlags: DWORD; out dwRegister: culong): HResult; stdcall; external oleaut32dll name 'RegisterActiveObject';
+ function RevokeActiveObject(dwRegister: culong; pvReserved: Pointer) : HResult; stdcall; external oleaut32dll name 'RevokeActiveObject';
+ function GetActiveObject(const clsid: TCLSID; pvReserved: Pointer; out unk: IUnknown) : HResult; stdcall; external oleaut32dll name 'GetActiveObject';
+{$endif wince}
+
+function Succeeded(Res: HResult) : Boolean;inline;
+function Failed(Res: HResult) : Boolean;inline;
+function ResultCode(Res: HResult) : Longint;inline;
+function ResultFacility(Res: HResult): Longint;inline;
+function ResultSeverity(Res: HResult): Longint;inline;
+function MakeResult(Severity, Facility, Code: Longint): HResult;inline;
+
+function LoadTypeLib(szfile : lpolestr; var pptlib: ITypelib):HResult; stdcall; external oleaut32dll name 'LoadTypeLib';
+function LoadRegTypeLib(const rguid:TGUID;wVerMajor:ushort;wVerMinor:ushort;_lcid:lcid;out pptlib:ITypeLib):HResult; stdcall; external oleaut32dll name 'LoadRegTypeLib';
+function RegisterTypeLib(const ptrlib :ITypeLib;szfullpath:lpolestr;szhelpdir:lpolestr):HResult; stdcall; external oleaut32dll name 'RegisterTypeLib';
+function CreateTypeLib2(sysk:TSysKind;szfile:lpolestr;out ppctlib:ICreateTypeLib2):HResult; stdcall; external oleaut32dll name 'CreateTypeLib2';
+function DispInvoke(this:pointer;const ptinfo: ITypeInfo;dispidMember:TDISPID;wflags:ushort;pparams:pDISPParams;var pvarresult:OLEVARIANT;pexcepinfo:EXCEPINFO;puArgErr:puint):HRESULT; stdcall; external oleaut32dll name 'CreateTypeLib2';
+{$ifndef wince}
+function LoadTypeLibEx(szfile : lpolestr; regk:tregkind; var pptlib: ITypelib):HResult; stdcall; external oleaut32dll name 'LoadTypeLibEx';
+function QueryPathOfRegTypeLib(const guid:TGUID;wVerMajor:ushort;wVerMinor:ushort;_lcid:lcid;lpbstr:LPolestr):HResult; stdcall; external oleaut32dll name 'QueryPathOfRegTypeLib';
+function UnRegisterTypeLib(const libid:TGUID; wVerMajor:ushort;wVerMinor:ushort;_lcid:lcid;sysk:TSysKind):HResult; stdcall; external oleaut32dll name 'UnRegisterTypeLib';
+function CreateTypeLib(sysk:TSysKind;szfile:lpolestr;out ppctlib:ICreateTypeLib):HResult; stdcall; external oleaut32dll name 'CreateTypeLib';
+
+function DosDateTimeToVariantTime( wDosDate: ushort; wDosTime:ushort;pvtime:pdouble):longint; stdcall; external oleaut32dll name 'DosDateTimeToVariantTime';
+function VariantTimeToDosDateTime( vtime:DOUBLE;pwdosdate:PUSHORT;pwDosTime:PUSHORT):longint; stdcall; external oleaut32dll name 'VariantTimeToDosDateTime';
+{$endif wince}
+
+function SystemTimeToVariantTime(var lpsystemtime:TSystemTime;out pvtime: TOleDate):LONGINT; stdcall; external oleaut32dll name 'SystemTimeToVariantTime';
+function VariantTimeToSystemTime(vtime:TOleDate; out lpsystemtime: TSystemTime):LONGINT; stdcall; external oleaut32dll name 'VariantTimeToSystemTime';
+
+
+{--------------------------------------------------------------------- }
+{ VARTYPE Coercion API }
+{--------------------------------------------------------------------- }
+{ Note: The routines that convert *from* a string are defined
+ * to take a OLECHAR* rather than a BSTR because no allocation is
+ * required, and this makes the routines a bit more generic.
+ * They may of course still be passed a BSTR as the strIn param.
+ }
+
+function VarUI1FromI2(sIn:SHORT; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromI2';
+function VarUI1FromI4(lIn:LONG; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromI4';
+function VarUI1FromI8(i64In:LONG64; pbOut:PBYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromI8';
+function VarUI1FromR4(fltIn:Single; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromR4';
+function VarUI1FromR8(dblIn:DOUBLE; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromR8';
+function VarUI1FromCy(cyIn:CY; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromCy';
+function VarUI1FromDate(dateIn:DATE; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromDate';
+function VarUI1FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromStr';
+function VarUI1FromDisp(pdispIn:IDispatch; lcid:LCID; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromDisp';
+function VarUI1FromBool(boolIn:VARIANT_BOOL; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromBool';
+function VarUI1FromI1(cIn:CHAR; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromI1';
+function VarUI1FromUI2(uiIn:USHORT; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromUI2';
+function VarUI1FromUI4(ulIn:ULONG; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromUI4';
+function VarUI1FromUI8(ui64In:ULONG64; pbOut:PBYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromUI8';
+function VarUI1FromDec(var pdecIn:TDecimal; var pbOut:BYTE):HResult;stdcall;external oleaut32dll name 'VarUI1FromDec';
+function VarI2FromUI1(bIn:BYTE; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromUI1';
+function VarI2FromI4(lIn:LONG; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromI4';
+
+function VarI2FromI8(i64In:LONG64; psOut:PSHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromI8';
+function VarI2FromR4(fltIn:Single; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromR4';
+function VarI2FromR8(dblIn:DOUBLE; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromR8';
+function VarI2FromCy(cyIn:CY; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromCy';
+function VarI2FromDate(dateIn:DATE; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromDate';
+function VarI2FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromStr';
+function VarI2FromDisp(pdispIn:IDispatch; lcid:LCID; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromDisp';
+function VarI2FromBool(boolIn:VARIANT_BOOL; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromBool';
+function VarI2FromI1(cIn:CHAR; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromI1';
+function VarI2FromUI2(uiIn:USHORT; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromUI2';
+function VarI2FromUI4(ulIn:ULONG; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromUI4';
+
+function VarI2FromUI8(ui64In:ULONG64; psOut:PSHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromUI8';
+function VarI2FromDec(var pdecIn:TDecimal; var psOut:SHORT):HResult;stdcall;external oleaut32dll name 'VarI2FromDec';
+function VarI4FromUI1(bIn:BYTE; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromUI1';
+function VarI4FromI2(sIn:SHORT; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromI2';
+
+function VarI4FromI8(i64In:LONG64; plOut:PLONG):HResult;stdcall;external oleaut32dll name 'VarI4FromI8';
+function VarI4FromR4(fltIn:Single; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromR4';
+function VarI4FromR8(dblIn:DOUBLE; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromR8';
+function VarI4FromCy(cyIn:CY; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromCy';
+function VarI4FromDate(dateIn:DATE; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromDate';
+function VarI4FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromStr';
+function VarI4FromDisp(dispIn:IDispatch; lcid:LCID; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromDisp';
+function VarI4FromBool(boolIn:VARIANT_BOOL; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromBool';
+function VarI4FromI1(cIn:CHAR; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromI1';
+function VarI4FromUI2(uiIn:USHORT; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromUI2';
+function VarI4FromUI4(ulIn:ULONG; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromUI4';
+
+function VarI4FromUI8(ui64In:ULONG64; plOut:PLONG):HResult;stdcall;external oleaut32dll name 'VarI4FromUI8';
+function VarI4FromDec(var pdecIn:TDecimal; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromDec';
+function VarI4FromInt(intIn:cint; var plOut:LONG):HResult;stdcall;external oleaut32dll name 'VarI4FromInt';
+
+function VarI8FromUI1(bIn:BYTE; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromUI1';
+function VarI8FromI2(sIn:SHORT; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromI2';
+function VarI8FromI4(lIn:LONG; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromI4';
+function VarI8FromR4(fltIn:Single; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromR4';
+function VarI8FromR8(dblIn:DOUBLE; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromR8';
+function VarI8FromCy(cyIn:CY; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromCy';
+function VarI8FromDate(dateIn:DATE; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromDate';
+function VarI8FromStr(strIn:POLECHAR; lcid:LCID; dwFlags:dword; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromStr';
+function VarI8FromDisp(pdispIn:IDispatch; lcid:LCID; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromDisp';
+function VarI8FromBool(boolIn:VARIANT_BOOL; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromBool';
+function VarI8FromI1(cIn:CHAR; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromI1';
+
+function VarI8FromUI2(uiIn:USHORT; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromUI2';
+function VarI8FromUI4(ulIn:ULONG; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromUI4';
+function VarI8FromUI8(ui64In:ULONG64; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromUI8';
+function VarI8FromDec(var pdecIn:TDecimal; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromDec';
+function VarI8FromInt(intIn:cint; pi64Out:PLONG64):HResult;stdcall;external oleaut32dll name 'VarI8FromInt';
+
+{******************* }
+function VarR4FromUI1(bIn:BYTE; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromUI1';
+function VarR4FromI2(sIn:SHORT; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromI2';
+function VarR4FromI4(lIn:LONG; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromI4';
+
+function VarR4FromI8(i64In:LONG64; pfltOut:PSingle):HResult;stdcall;external oleaut32dll name 'VarR4FromI8';
+function VarR4FromR8(dblIn:DOUBLE; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromR8';
+function VarR4FromCy(cyIn:CY; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromCy';
+function VarR4FromDate(dateIn:DATE; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromDate';
+function VarR4FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromStr';
+function VarR4FromDisp(pdispIn:IDispatch; lcid:LCID; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromDisp';
+function VarR4FromBool(boolIn:VARIANT_BOOL; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromBool';
+function VarR4FromI1(cIn:CHAR; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromI1';
+function VarR4FromUI2(uiIn:USHORT; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromUI2';
+function VarR4FromUI4(ulIn:ULONG; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromUI4';
+
+function VarR4FromUI8(ui64In:ULONG64; pfltOut:PSingle):HResult;stdcall;external oleaut32dll name 'VarR4FromUI8';
+function VarR4FromDec(var pdecIn:TDecimal; var pfltOut:Single):HResult;stdcall;external oleaut32dll name 'VarR4FromDec';
+function VarR8FromUI1(bIn:BYTE; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromUI1';
+function VarR8FromI2(sIn:SHORT; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromI2';
+function VarR8FromI4(lIn:LONG; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromI4';
+
+function VarR8FromI8(i64In:LONG64; pdblOut:PDOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromI8';
+function VarR8FromR4(fltIn:Single; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromR4';
+function VarR8FromCy(cyIn:CY; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromCy';
+function VarR8FromDate(dateIn:DATE; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromDate';
+function VarR8FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromStr';
+function VarR8FromDisp(pdispIn:IDispatch; lcid:LCID; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromDisp';
+function VarR8FromBool(boolIn:VARIANT_BOOL; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromBool';
+function VarR8FromI1(cIn:CHAR; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromI1';
+function VarR8FromUI2(uiIn:USHORT; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromUI2';
+function VarR8FromUI4(ulIn:ULONG; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromUI4';
+
+function VarR8FromUI8(ui64In:ULONG64; pdblOut:PDOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromUI8';
+function VarR8FromDec(var pdecIn:TDecimal; var pdblOut:DOUBLE):HResult;stdcall;external oleaut32dll name 'VarR8FromDec';
+function VarDateFromUI1(bIn:BYTE; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromUI1';
+function VarDateFromI2(sIn:SHORT; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromI2';
+function VarDateFromI4(lIn:LONG; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromI4';
+
+function VarDateFromI8(i64In:LONG64; pdateOut:PDATE):HResult;stdcall;external oleaut32dll name 'VarDateFromI8';
+function VarDateFromR4(fltIn:Single; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromR4';
+function VarDateFromR8(dblIn:DOUBLE; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromR8';
+function VarDateFromCy(cyIn:CY; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromCy';
+function VarDateFromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromStr';
+
+function VarDateFromDisp(pdispIn:IDispatch; lcid:LCID; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromDisp';
+function VarDateFromBool(boolIn:VARIANT_BOOL; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromBool';
+function VarDateFromI1(cIn:CHAR; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromI1';
+function VarDateFromUI2(uiIn:USHORT; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromUI2';
+function VarDateFromUI4(ulIn:ULONG; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromUI4';
+
+function VarDateFromUI8(ui64In:ULONG64; pdateOut:PDATE):HResult;stdcall;external oleaut32dll name 'VarDateFromUI8';
+function VarDateFromDec(var pdecIn:TDecimal; var pdateOut:DATE):HResult;stdcall;external oleaut32dll name 'VarDateFromDec';
+function VarCyFromUI1(bIn:BYTE; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromUI1';
+function VarCyFromI2(sIn:SHORT; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromI2';
+function VarCyFromI4(lIn:LONG; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromI4';
+
+function VarCyFromI8(i64In:LONG64; pcyOut:PCurrency):HResult;stdcall;external oleaut32dll name 'VarCyFromI8';
+function VarCyFromR4(fltIn:Single; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromR4';
+function VarCyFromR8(dblIn:DOUBLE; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromR8';
+function VarCyFromDate(dateIn:DATE; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromDate';
+function VarCyFromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromStr';
+function VarCyFromDisp(pdispIn:IDispatch; lcid:LCID; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromDisp';
+function VarCyFromBool(boolIn:VARIANT_BOOL; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromBool';
+function VarCyFromI1(cIn:CHAR; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromI1';
+function VarCyFromUI2(uiIn:USHORT; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromUI2';
+function VarCyFromUI4(ulIn:ULONG; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromUI4';
+
+function VarCyFromUI8(ui64In:ULONG64; pcyOut:PCurrency):HResult;stdcall;external oleaut32dll name 'VarCyFromUI8';
+function VarCyFromDec(var pdecIn:TDecimal; var pcyOut:CY):HResult;stdcall;external oleaut32dll name 'VarCyFromDec';
+function VarBstrFromUI1(bVal:BYTE; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromUI1';
+function VarBstrFromI2(iVal:SHORT; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromI2';
+function VarBstrFromI4(lIn:LONG; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromI4';
+
+function VarBstrFromI8(i64In:LONG64; lcid:LCID; dwFlags:dword; pbstrOut:PBSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromI8';
+function VarBstrFromR4(fltIn:Single; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromR4';
+function VarBstrFromR8(dblIn:DOUBLE; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromR8';
+function VarBstrFromCy(cyIn:CY; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromCy';
+function VarBstrFromDate(dateIn:DATE; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromDate';
+function VarBstrFromDisp(pdispIn:IDispatch; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromDisp';
+function VarBstrFromBool(boolIn:VARIANT_BOOL; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromBool';
+function VarBstrFromI1(cIn:CHAR; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromI1';
+function VarBstrFromUI2(uiIn:USHORT; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromUI2';
+function VarBstrFromUI4(ulIn:ULONG; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromUI4';
+
+function VarBstrFromUI8(ui64In:ULONG64; lcid:LCID; dwFlags:dword; pbstrOut:PBSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromUI8';
+function VarBstrFromDec(var pdecIn:TDecimal; lcid:LCID; dwFlags:ULONG; var pbstrOut:BSTR):HResult;stdcall;external oleaut32dll name 'VarBstrFromDec';
+function VarBoolFromUI1(bIn:BYTE; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromUI1';
+function VarBoolFromI2(sIn:SHORT; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromI2';
+function VarBoolFromI4(lIn:LONG; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromI4';
+
+function VarBoolFromI8(i64In:LONG64; pboolOut:PVARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromI8';
+function VarBoolFromR4(fltIn:Single; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromR4';
+function VarBoolFromR8(dblIn:DOUBLE; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromR8';
+function VarBoolFromDate(dateIn:DATE; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromDate';
+function VarBoolFromCy(cyIn:CY; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromCy';
+function VarBoolFromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromStr';
+function VarBoolFromDisp(pdispIn:IDispatch; lcid:LCID; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromDisp';
+function VarBoolFromI1(cIn:CHAR; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromI1';
+function VarBoolFromUI2(uiIn:USHORT; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromUI2';
+function VarBoolFromUI4(ulIn:ULONG; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromUI4';
+
+function VarBoolFromUI8(i64In:ULONG64; pboolOut:PVARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromUI8';
+function VarBoolFromDec(var pdecIn:TDecimal; var pboolOut:VARIANT_BOOL):HResult;stdcall;external oleaut32dll name 'VarBoolFromDec';
+function VarI1FromUI1(bIn:BYTE; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromUI1';
+function VarI1FromI2(uiIn:SHORT; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromI2';
+function VarI1FromI4(lIn:LONG; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromI4';
+function VarI1FromI8(i64In:LONG64; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromI8';
+function VarI1FromR4(fltIn:Single; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromR4';
+function VarI1FromR8(dblIn:DOUBLE; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromR8';
+function VarI1FromDate(dateIn:DATE; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromDate';
+function VarI1FromCy(cyIn:CY; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromCy';
+function VarI1FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromStr';
+function VarI1FromDisp(pdispIn:IDispatch; lcid:LCID; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromDisp';
+function VarI1FromBool(boolIn:VARIANT_BOOL; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromBool';
+function VarI1FromUI2(uiIn:USHORT; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromUI2';
+function VarI1FromUI4(ulIn:ULONG; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromUI4';
+function VarI1FromUI8(i64In:ULONG64; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromUI8';
+function VarI1FromDec(var pdecIn:TDecimal; pcOut:pCHAR):HResult;stdcall;external oleaut32dll name 'VarI1FromDec';
+function VarUI2FromUI1(bIn:BYTE; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromUI1';
+function VarUI2FromI2(uiIn:SHORT; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromI2';
+function VarUI2FromI4(lIn:LONG; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromI4';
+
+function VarUI2FromI8(i64In:LONG64; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromI8';
+function VarUI2FromR4(fltIn:Single; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromR4';
+function VarUI2FromR8(dblIn:DOUBLE; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromR8';
+function VarUI2FromDate(dateIn:DATE; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromDate';
+function VarUI2FromCy(cyIn:CY; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromCy';
+function VarUI2FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromStr';
+function VarUI2FromDisp(pdispIn:IDispatch; lcid:LCID; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromDisp';
+function VarUI2FromBool(boolIn:VARIANT_BOOL; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromBool';
+function VarUI2FromI1(cIn:CHAR; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromI1';
+function VarUI2FromUI4(ulIn:ULONG; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromUI4';
+function VarUI2FromUI8(i64In:ULONG64; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromUI8';
+function VarUI2FromDec(var pdecIn:TDecimal; var puiOut:USHORT):HResult;stdcall;external oleaut32dll name 'VarUI2FromDec';
+function VarUI4FromUI1(bIn:BYTE; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromUI1';
+function VarUI4FromI2(uiIn:SHORT; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromI2';
+function VarUI4FromI4(lIn:LONG; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromI4';
+function VarUI4FromI8(i64In:LONG64; var plOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromI8';
+function VarUI4FromR4(fltIn:Single; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromR4';
+function VarUI4FromR8(dblIn:DOUBLE; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromR8';
+function VarUI4FromDate(dateIn:DATE; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromDate';
+function VarUI4FromCy(cyIn:CY; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromCy';
+function VarUI4FromStr(strIn:pOLECHAR; lcid:LCID; dwFlags:ULONG; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromStr';
+function VarUI4FromDisp(pdispIn:IDispatch; lcid:LCID; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromDisp';
+function VarUI4FromBool(boolIn:VARIANT_BOOL; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromBool';
+function VarUI4FromI1(cIn:CHAR; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromI1';
+function VarUI4FromUI2(uiIn:USHORT; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromUI2';
+function VarUI4FromUI8(ui64In:ULONG64; var plOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromUI8';
+function VarUI4FromDec(var pdecIn:TDecimal; var pulOut:ULONG):HResult;stdcall;external oleaut32dll name 'VarUI4FromDec';
+
+{**************************************** }
+function VarUI8FromUI1(bIn:BYTE; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromUI1';
+function VarUI8FromI2(sIn:SHORT; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromI2';
+function VarUI8FromI4(lIn:LONG; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromI4';
+function VarUI8FromI8(ui64In:LONG64; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromI8';
+function VarUI8FromR4(fltIn:Single; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromR4';
+function VarUI8FromR8(dblIn:DOUBLE; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromR8';
+function VarUI8FromCy(cyIn:CY; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromCy';
+function VarUI8FromDate(dateIn:DATE; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromDate';
+function VarUI8FromStr(strIn:POLECHAR; lcid:LCID; dwFlags:dword; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromStr';
+function VarUI8FromDisp(pdispIn:IDispatch; lcid:LCID; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromDisp';
+function VarUI8FromBool(boolIn:VARIANT_BOOL; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromBool';
+function VarUI8FromI1(cIn:CHAR; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromI1';
+function VarUI8FromUI2(uiIn:USHORT; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromUI2';
+function VarUI8FromUI4(ulIn:ULONG; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromUI4';
+function VarUI8FromDec(var pdecIn:TDecimal; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromDec';
+function VarUI8FromInt(intIn:cint; pi64Out:PULONG64):HResult;stdcall;external oleaut32dll name 'VarUI8FromInt';
+
+implementation
+
+function Succeeded(Res: HResult) : Boolean;inline;
+ begin
+ Result := Res and $80000000 = 0;
+ end;
+
+
+function Failed(Res: HResult) : Boolean;inline;
+ begin
+ Result := Res and $80000000 <> 0;
+ end;
+
+
+function ResultCode(Res: HResult) : Longint;inline;
+ begin
+ Result := Res and $0000FFFF;
+ end;
+
+
+function ResultFacility(Res: HResult): Longint;inline;
+ begin
+ Result := (Res shr 16) and $00001FFF;
+ end;
+
+
+function ResultSeverity(Res: HResult): Longint;inline;
+ begin
+ Result := Res shr 31;
+ end;
+
+
+function MakeResult(Severity, Facility, Code: Longint): HResult;inline;
+ begin
+ Result := (Severity shl 31) or (Facility shl 16) or Code;
+ end;
+
+
+end.
diff --git a/plugins/mRadio/commctrl.pp b/plugins/mRadio/commctrl.pp new file mode 100644 index 0000000000..56c995c210 --- /dev/null +++ b/plugins/mRadio/commctrl.pp @@ -0,0 +1,13751 @@ +{
+ This file is part of the Free Pascal run time library.
+ Copyright (c) 1999-2004 by Marco van de Voort
+ member of the Free Pascal development team.
+
+ See the file COPYING.FPC, included in this distribution,
+ for details about the copyright.
+
+ 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.
+
+ Original copyright statement follows.
+
+ **************************************************************************
+ * *
+ * commctrl.h - - Interface for the Windows Common Controls *
+ * *
+ * Version 1.2 *
+ * *
+ * Copyright (c) Microsoft Corporation. All rights reserved. *
+ * *
+ **************************************************************************
+
+ Note: This is an initial translation, and probably _full_ of bugs, this
+ is because my conversion tool was flawed, and a lot of postediting
+ was needed, which is bound to introduce bugs and inconsequencies
+
+ This is an huge unit, and its maintenance and compability is not
+ a top-priority.
+ I prefer patches as bugfix over bugreports, and
+ preferably patches with lots of fixes at once.
+
+ If you can't make a patch, at least research the bug thoroughly,
+ and provide as much info as possible (which windows version,
+ the C prototype from the sdk, etc)
+
+ Help the FPC team, and try to do as much as possible yourself.
+}
+
+
+Unit CommCtrl;
+Interface
+
+{$Mode ObjFPC}
+Uses Windows,CTypes;
+
+// --------------------
+
+// --------------------
+CONST CommCtrlDLL = 'comctl32.dll';
+
+// Some reasonal defaults.
+// for XP only set NT to $%0501 and IE to $0600
+//
+// The NT conditional is only used for XP/no XP.
+
+{$DEFINE WIN32_IE=$0500}
+{$DEFINE IE3PLUS}
+{$DEFINE IE4PLUS}
+{$define IE5plus}
+{$define WIN32XP}
+{$define win32vista} // till WC_STATICA
+{$define ie501plus}
+{$ifdef win32}
+ {$define _win32}
+{$endif win32}
+{$define ie6plus}
+{$define ntddi_vista}
+{$define NTDDI_WIN7}
+
+{$ifdef win64}
+ {$define _win32}
+{$endif win64}
+
+{$DEFINE WIN32_WINNT=0} // NO XP
+{.$DEFINE __IStream_INTERFACE_DEFINED__} // lpstream defined in activex afaik.
+
+// Sanity check in source. Not translated:
+//if (WIN32_IE < $0400) && defined(WIN32_WINNT) && (WIN32_WINNT >= $0500)}
+// #error _WIN32_IE setting conflicts with _WIN32_WINNT setting
+
+//
+// Users of this header may define any number of these constants to avoid
+// the definitions of each functional group.
+//
+// NOTOOLBAR Customizable bitmap-button toolbar control.
+// NOUPDOWN Up and Down arrow increment/decrement control.
+// NOSTATUSBAR Status bar control.
+// NOMENUHELP APIs to help manage menus, especially with a status bar.
+// NOTRACKBAR Customizable column-width tracking control.
+// NODRAGLIST APIs to make a listbox source and sink drag&drop actions.
+// NOPROGRESS Progress gas gauge.
+// NOHOTKEY HotKey control
+// NOHEADER Header bar control.
+// NOIMAGEAPIS ImageList apis.
+// NOLISTVIEW ListView control.
+// NOTREEVIEW TreeView control.
+// NOTABCONTROL Tab control.
+// NOANIMATE Animate control.
+// NOBUTTON Button control.
+// NOSTATIC Static control.
+// NOEDIT Edit control.
+// NOLISTBOX Listbox control.
+// NOCOMBOBOX Combobox control.
+// NOSCROLLBAR Scrollbar control.
+//
+//=============================================================================
+// Moved items due to forward defining limitations
+
+Const
+ MAX_LINKID_TEXT = 48;
+ L_MAX_URL_LENGTH = (2048 + 32 + length('://'));
+Type
+ tagLITEM = Record
+ mask : UINT;
+ iLink : cint;
+ state : UINT;
+ stateMask : UINT;
+ szID : Array [0..MAX_LINKID_TEXT-1] OF WCHAR;
+ szUrl : Array [0..L_MAX_URL_LENGTH-1] OF WCHAR;
+ END;
+ LITEM = tagLITEM;
+ PLITEM = ^tagLITEM;
+ TLITEM = tagLITEM;
+// PLITEM = ^tagLITEM;
+
+
+
+// include <prsht.h>
+
+Procedure InitCommonControls; stdcall; external commctrldll name 'InitCommonControls';
+
+{$ifdef ie3plus}
+TYPE
+
+ tagINITCOMMONCONTROLSEX = Record
+ dwSize : DWORD; // size of this structure
+ dwICC : DWORD; // flags indicating which classes to be initialized
+ END;
+ _INITCOMMONCONTROLSEX = tagINITCOMMONCONTROLSEX;
+ LPINITCOMMONCONTROLSEX = ^tagINITCOMMONCONTROLSEX;
+ TINITCOMMONCONTROLSEX = tagINITCOMMONCONTROLSEX;
+ PINITCOMMONCONTROLSEX = ^tagINITCOMMONCONTROLSEX;
+
+CONST
+ ICC_LISTVIEW_CLASSES = $00000001; // listview, header
+ ICC_TREEVIEW_CLASSES = $00000002; // treeview, tooltips
+ ICC_BAR_CLASSES = $00000004; // toolbar, statusbar, trackbar, tooltips
+ ICC_TAB_CLASSES = $00000008; // tab, tooltips
+ ICC_UPDOWN_CLASS = $00000010; // updown
+ ICC_PROGRESS_CLASS = $00000020; // progress
+ ICC_HOTKEY_CLASS = $00000040; // hotkey
+ ICC_ANIMATE_CLASS = $00000080; // animate
+ ICC_WIN95_CLASSES = $000000FF;
+ ICC_DATE_CLASSES = $00000100; // month picker, date picker, time picker, updown
+ ICC_USEREX_CLASSES = $00000200; // comboex
+ ICC_COOL_CLASSES = $00000400; // rebar (coolbar) control
+{$ifdef ie4plus}
+ ICC_INTERNET_CLASSES = $00000800;
+ ICC_PAGESCROLLER_CLASS = $00001000; // page scroller
+ ICC_NATIVEFNTCTL_CLASS = $00002000; // native font control
+{$ENDIF}
+{$ifdef WIN32XP}
+ ICC_STANDARD_CLASSES = $00004000;
+ ICC_LINK_CLASS = $00008000;
+{$ENDIF}
+
+function InitCommonControlsEx(var rec : TINITCOMMONCONTROLSEX):BOOL; stdcall; external commctrldll name 'InitCommonControlsEx';
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+CONST
+ ODT_HEADER = 100;
+ ODT_TAB = 101;
+ ODT_LISTVIEW = 102;
+
+//====== WM_NOTIFY codes (NMHDR.code values) ==================================
+
+
+CONST
+ NM_FIRST = (0- 0); // generic to all controls
+ NM_LAST = (0- 99);
+
+ LVN_FIRST = (0-100); // listview
+ LVN_LAST = (0-199);
+
+// Property sheet reserved (0U-200U) - (0U-299U) - see prsht.h
+
+ HDN_FIRST = (0-300); // header
+ HDN_LAST = (0-399);
+
+ TVN_FIRST = (0-400); // treeview
+ TVN_LAST = (0-499);
+
+ TTN_FIRST = (0-520); // tooltips
+ TTN_LAST = (0-549);
+
+ TCN_FIRST = (0-550); // tab control
+ TCN_LAST = (0-580);
+
+// Shell reserved (0U-580U) - (0U-589U)
+
+ CDN_FIRST = (0-601); // common dialog (new)
+ CDN_LAST = (0-699);
+
+ TBN_FIRST = (0-700); // toolbar
+ TBN_LAST = (0-720);
+
+ UDN_FIRST = (0-721); // updown
+ UDN_LAST = (0-740);
+{$ifdef ie3plus}
+ MCN_FIRST = (0-750); // monthcal
+ MCN_LAST = (0-759);
+
+ DTN_FIRST = (0-760); // datetimepick
+ DTN_LAST = (0-799);
+
+ CBEN_FIRST = (0-800); // combo box ex
+ CBEN_LAST = (0-830);
+
+ RBN_FIRST = (0-831); // rebar
+ RBN_LAST = (0-859);
+{$ENDIF}
+
+{$ifdef ie4plus}
+ IPN_FIRST = (0-860); // internet address
+ IPN_LAST = (0-879); // internet address
+
+ SBN_FIRST = (0-880); // status bar
+ SBN_LAST = (0-899);
+
+ PGN_FIRST = (0-900); // Pager Control
+ PGN_LAST = (0-950);
+
+{$ENDIF}
+
+{$ifdef ie5plus}
+{$IFNDEF WMN_FIRST}
+ WMN_FIRST = (0-1000);
+ WMN_LAST = (0-1200);
+{$ENDIF}
+{$ENDIF}
+
+{$ifdef Win32XP}
+ BCN_FIRST = (0-1250);
+ BCN_LAST = (0-1350);
+{$ENDIF}
+
+{$ifdef win32vista}
+ TRBN_FIRST = cardinal(0-1501); // trackbar
+ TRBN_LAST = cardinal(0-1519);
+{$endif}
+ MSGF_COMMCTRL_BEGINDRAG = $4200;
+ MSGF_COMMCTRL_SIZEHEADER = $4201;
+ MSGF_COMMCTRL_DRAGSELECT = $4202;
+ MSGF_COMMCTRL_TOOLBARCUST = $4203;
+
+//====== Ranges for control message IDs =======================================
+
+ LVM_FIRST = $1000; // ListView messages
+ TV_FIRST = $1100; // TreeView messages
+ HDM_FIRST = $1200; // Header messages
+ TCM_FIRST = $1300; // Tab control messages
+
+{$ifdef ie4plus}
+ PGM_FIRST = $1400; // Pager control messages
+{$ifdef win32xp}// actually 0x501=2003 or some sp?
+ ECM_FIRST = $1500; // Edit control messages
+ BCM_FIRST = $1600; // Button control messages
+ CBM_FIRST = $1700; // Combobox control messages
+{$ENDIF}
+ CCM_FIRST = $2000; // Common control shared messages
+ CCM_LAST = (CCM_FIRST + $200);
+
+
+ CCM_SETBKCOLOR = (CCM_FIRST + 1); // lParam is bkColor
+
+TYPE
+ tagCOLORSCHEME = Record
+ dwSize : DWORD;
+ clrBtnHighlight : COLORREF; // highlight color
+ clrBtnShadow : COLORREF; // shadow color
+ END;
+ COLORSCHEME = tagCOLORSCHEME;
+ LPCOLORSCHEME = ^tagCOLORSCHEME;
+ TCOLORSCHEME = tagCOLORSCHEME;
+ PCOLORSCHEME = ^tagCOLORSCHEME;
+
+CONST
+ CCM_SETCOLORSCHEME = (CCM_FIRST + 2); // lParam is color scheme
+ CCM_GETCOLORSCHEME = (CCM_FIRST + 3); // fills in COLORSCHEME pointed to by lParam
+ CCM_GETDROPTARGET = (CCM_FIRST + 4);
+ CCM_SETUNICODEFORMAT = (CCM_FIRST + 5);
+ CCM_GETUNICODEFORMAT = (CCM_FIRST + 6);
+
+{$ifdef ie5plus}
+{$ifdef win32xp}
+ COMCTL32_VERSION = 6;
+{$ELSE}
+ COMCTL32_VERSION = 5;
+{$ENDIF}
+
+ CCM_SETVERSION = (CCM_FIRST + $7);
+ CCM_GETVERSION = (CCM_FIRST + $8);
+ CCM_SETNOTIFYWINDOW = (CCM_FIRST + $9); // wParam == hwndParent.
+{$ifdef win32xp}
+ CCM_SETWINDOWTHEME = (CCM_FIRST + $b);
+ CCM_DPISCALE = (CCM_FIRST + $c); // wParam == Awareness
+{$ENDIF}
+{$ENDIF} // (_WIN32_IE >= 0x0500)
+
+{$ENDIF} // (_WIN32_IE >= 0x0400)
+
+{$ifdef ie4plus}
+// for tooltips
+ INFOTIPSIZE = 1024;
+{$ENDIF}
+
+//====== WM_NOTIFY Macros =====================================================
+
+// Macro 8
+Procedure HANDLE_WM_NOTIFY( hwnd : hwnd; wParam : cint;var _lParam : NMHDR ;fn :Pointer);
+
+// Macro 9
+Function FORWARD_WM_NOTIFY( hwnd : hwnd; idFrom : cint;var pnmhdr : NMHDR ; fn :pointer ):LRESULT;
+
+//====== Generic WM_NOTIFY notification codes =================================
+
+
+CONST
+ NM_OUTOFMEMORY = (NM_FIRST-1);
+ NM_CLICK = (NM_FIRST-2); // uses NMCLICK struct
+ NM_DBLCLK = (NM_FIRST-3);
+ NM_RETURN = (NM_FIRST-4);
+ NM_RCLICK = (NM_FIRST-5); // uses NMCLICK struct
+ NM_RDBLCLK = (NM_FIRST-6);
+ NM_SETFOCUS = (NM_FIRST-7);
+ NM_KILLFOCUS = (NM_FIRST-8);
+{$ifdef ie3plus}
+ NM_CUSTOMDRAW = (NM_FIRST-12);
+ NM_HOVER = (NM_FIRST-13);
+{$ENDIF}
+{$ifdef ie4plus}
+ NM_NCHITTEST = (NM_FIRST-14); // uses NMMOUSE struct
+ NM_KEYDOWN = (NM_FIRST-15); // uses NMKEY struct
+ NM_RELEASEDCAPTURE = (NM_FIRST-16);
+ NM_SETCURSOR = (NM_FIRST-17); // uses NMMOUSE struct
+ NM_CHAR = (NM_FIRST-18); // uses NMCHAR struct
+{$ENDIF}
+{$ifdef ie401plus}
+ NM_TOOLTIPSCREATED = (NM_FIRST-19); // notify of when the tooltips window is create
+{$ENDIF}
+{$ifdef ie5plus}
+ NM_LDOWN = (NM_FIRST-20);
+ NM_RDOWN = (NM_FIRST-21);
+ NM_THEMECHANGED = (NM_FIRST-22);
+{$ENDIF}
+{$ifdef win32vista}
+ NM_FONTCHANGED = (NM_FIRST-23);
+ NM_CUSTOMTEXT = (NM_FIRST-24); // uses NMCUSTOMTEXT struct
+ NM_TVSTATEIMAGECHANGING = (NM_FIRST-24); // uses NMTVSTATEIMAGECHANGING struct, defined after HTREEITEM
+{$endif}
+
+{$IFNDEF CCSIZEOF_STRUCT}
+
+// Macro 10
+// #define CCSIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member))
+{$ENDIF}
+
+//====== Generic WM_NOTIFY notification structures ============================
+{$ifdef ie401plus}
+
+TYPE
+
+ tagNMTOOLTIPSCREATED = Record
+ hdr : NMHDR;
+ hwndToolTips : HWND;
+ END;
+ NMTOOLTIPSCREATED = tagNMTOOLTIPSCREATED;
+ LPNMTOOLTIPSCREATED = ^tagNMTOOLTIPSCREATED;
+ TNMTOOLTIPSCREATED = tagNMTOOLTIPSCREATED;
+ PNMTOOLTIPSCREATED = ^tagNMTOOLTIPSCREATED;
+
+{$ENDIF}
+
+{$ifdef ie4plus}
+Type
+ tagNMMOUSE = Record
+ hdr : NMHDR;
+ dwItemSpec : DWORD_PTR;
+ dwItemData : DWORD_PTR;
+ pt : POINT;
+ dwHitInfo : LPARAM; // any specifics about where on the item or control the mouse is
+ END;
+ NMMOUSE = tagNMMOUSE;
+ LPNMMOUSE = ^tagNMMOUSE;
+ TNMMOUSE = tagNMMOUSE;
+ PNMMOUSE = ^tagNMMOUSE;
+
+
+ NMCLICK = NMMOUSE;
+ LPNMCLICK = LPNMMOUSE;
+
+// Generic structure to request an object of a specific type.
+
+ tagNMOBJECTNOTIFY = Record
+ hdr : NMHDR;
+ iItem : cint;
+{$IFDEF __IID_DEFINED__}
+ piid : PIID;
+{$ELSE}
+ piid : Pointer;
+{$ENDIF}
+ pObject : Pointer;
+ hResult : HRESULT;
+ dwFlags : DWORD; // control specific flags (hints as to where in iItem it hit)
+ END;
+ NMOBJECTNOTIFY = tagNMOBJECTNOTIFY;
+ LPNMOBJECTNOTIFY = ^tagNMOBJECTNOTIFY;
+ TNMOBJECTNOTIFY = tagNMOBJECTNOTIFY;
+ PNMOBJECTNOTIFY = ^tagNMOBJECTNOTIFY;
+
+
+// Generic structure for a key
+
+ tagNMKEY = Record
+ hdr : NMHDR;
+ nVKey : UINT;
+ uFlags : UINT;
+ END;
+ NMKEY = tagNMKEY;
+ LPNMKEY = ^tagNMKEY;
+ TNMKEY = tagNMKEY;
+ PNMKEY = ^tagNMKEY;
+
+
+// Generic structure for a character
+
+ tagNMCHAR = Record
+ hdr : NMHDR;
+ ch : UINT;
+ dwItemPrev : DWORD; // Item previously selected
+ dwItemNext : DWORD; // Item to be selected
+ END;
+ NMCHAR = tagNMCHAR;
+ LPNMCHAR = ^tagNMCHAR;
+ TNMCHAR = tagNMCHAR;
+ PNMCHAR = ^tagNMCHAR;
+
+{$ifdef win32vista}
+ tagNMCUSTOMTEXT = Record
+ hdr : NMHDR;
+ hDC : HDC;
+ lpString : LPCWSTR;
+ nCount : cint;
+ lpRect : LPRECT;
+ uFormat : UINT;
+ fLink : bool;
+ end;
+
+ NMCUSTOMTEXT = tagNMCUSTOMTEXT;
+ LPNMCUSTOMTEXT = ^tagNMCUSTOMTEXT;
+ TNMCUSTOMTEXT = tagNMCUSTOMTEXT;
+ PNMCUSTOMTEXT = LPNMCUSTOMTEXT;
+{$endif}
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+
+{$ifdef ie3plus}
+//==================== CUSTOM DRAW ==========================================
+
+// custom draw return flags
+// values under 0x00010000 are reserved for global custom draw values.
+// above that are for specific controls
+CONST
+ CDRF_DODEFAULT = $00000000;
+ CDRF_NEWFONT = $00000002;
+ CDRF_SKIPDEFAULT = $00000004;
+
+
+ CDRF_NOTIFYPOSTPAINT = $00000010;
+ CDRF_NOTIFYITEMDRAW = $00000020;
+{$ifdef ie4plus}
+ CDRF_NOTIFYSUBITEMDRAW = $00000020; // flags are the same, we can distinguish by context
+{$ENDIF}
+ CDRF_NOTIFYPOSTERASE = $00000040;
+ CDRF_NOTIFYITEMERASE = $00000080; // according to lazarus headers. Can't find in sdk 6.0 (Vista sdk)
+
+
+// drawstage flags
+// values under 0x00010000 are reserved for global custom draw values.
+// above that are for specific controls
+ CDDS_PREPAINT = $00000001;
+ CDDS_POSTPAINT = $00000002;
+ CDDS_PREERASE = $00000003;
+ CDDS_POSTERASE = $00000004;
+// the 0x000010000 bit means it's individual item specific
+ CDDS_ITEM = $00010000;
+ CDDS_ITEMPREPAINT = (CDDS_ITEM OR CDDS_PREPAINT);
+ CDDS_ITEMPOSTPAINT = (CDDS_ITEM OR CDDS_POSTPAINT);
+ CDDS_ITEMPREERASE = (CDDS_ITEM OR CDDS_PREERASE);
+ CDDS_ITEMPOSTERASE = (CDDS_ITEM OR CDDS_POSTERASE);
+{$ifdef ie4plus}
+ CDDS_SUBITEM = $00020000;
+{$ENDIF}
+
+// itemState flags
+ CDIS_SELECTED = $0001;
+ CDIS_GRAYED = $0002;
+ CDIS_DISABLED = $0004;
+ CDIS_CHECKED = $0008;
+ CDIS_FOCUS = $0010;
+ CDIS_DEFAULT = $0020;
+ CDIS_HOT = $0040;
+ CDIS_MARKED = $0080;
+ CDIS_INDETERMINATE = $0100;
+{$ifdef win32xp}
+ CDIS_SHOWKEYBOARDCUES = $0200;
+{$ENDIF}
+{$ifdef win32vista}
+ CDIS_NEARHOT = $0400;
+ CDIS_OTHERSIDEHOT = $0800;
+ CDIS_DROPHILITED = $1000;
+{$endif}
+
+TYPE
+
+ tagNMCUSTOMDRAWINFO = Record
+ hdr : NMHDR;
+ dwDrawStage : DWORD;
+ hdc : HDC;
+ rc : RECT;
+ dwItemSpec : DWORD_PTR; // this is control specific, but it's how to specify an item. valid only with CDDS_ITEM bit set
+ uItemState : UINT;
+ lItemlParam : LPARAM;
+ END;
+ NMCUSTOMDRAW = tagNMCUSTOMDRAWINFO;
+ LPNMCUSTOMDRAW = ^tagNMCUSTOMDRAWINFO;
+ TNMCUSTOMDRAWINFO = tagNMCUSTOMDRAWINFO;
+ PNMCUSTOMDRAWINFO = ^tagNMCUSTOMDRAWINFO;
+ PNMCustomDraw = PNMCUSTOMDRAWINFO;
+ TNMCustomDraw = tagNMCUSTOMDRAWINFO;
+
+ tagNMTTCUSTOMDRAW = Record
+ nmcd : NMCUSTOMDRAW;
+ uDrawFlags : UINT;
+ END;
+ NMTTCUSTOMDRAW = tagNMTTCUSTOMDRAW;
+ LPNMTTCUSTOMDRAW = ^tagNMTTCUSTOMDRAW;
+ TNMTTCUSTOMDRAW = tagNMTTCUSTOMDRAW;
+ PNMTTCUSTOMDRAW = ^tagNMTTCUSTOMDRAW;
+
+
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+
+//====== IMAGE APIS ===========================================================
+
+{$IFNDEF NOIMAGEAPIS}
+
+
+CONST
+ CLR_NONE = DWORD($FFFFFFFF);
+ CLR_DEFAULT = DWORD($FF000000);
+
+
+{$IFNDEF IMAGELISTDRAWPARAMS}
+{$ifdef ie3plus}
+TYPE
+ _IMAGELISTDRAWPARAMS = Record
+ cbSize : DWORD;
+ himl : HIMAGELIST;
+ i : cint;
+ hdcDst : HDC;
+ x : cint;
+ y : cint;
+ cx : cint;
+ cy : cint;
+ xBitmap : cint; // x offest from the upperleft of bitmap
+ yBitmap : cint; // y offset from the upperleft of bitmap
+ rgbBk : COLORREF;
+ rgbFg : COLORREF;
+ fStyle : UINT;
+ dwRop : DWORD;
+{$ifdef win32xp}
+ fState : DWORD;
+ Frame : DWORD;
+ crEffect : COLORREF;
+{$ENDIF}
+ END;
+ tagIMAGELISTDRAWPARAMS = _IMAGELISTDRAWPARAMS;
+ IMAGELISTDRAWPARAMS = _IMAGELISTDRAWPARAMS;
+ LPIMAGELISTDRAWPARAMS = ^_IMAGELISTDRAWPARAMS;
+ TIMAGELISTDRAWPARAMS = _IMAGELISTDRAWPARAMS;
+ PIMAGELISTDRAWPARAMS = ^_IMAGELISTDRAWPARAMS;
+
+// #define IMAGELISTDRAWPARAMS_V3_SIZE CCSIZEOF_STRUCT(IMAGELISTDRAWPARAMS, dwRop)
+
+{$ENDIF} // _WIN32_IE >= 0x0300
+{$ENDIF}
+
+
+CONST
+ ILC_MASK = $00000001;
+ ILC_COLOR = $00000000;
+ ILC_COLORDDB = $000000FE;
+ ILC_COLOR4 = $00000004;
+ ILC_COLOR8 = $00000008;
+ ILC_COLOR16 = $00000010;
+ ILC_COLOR24 = $00000018;
+ ILC_COLOR32 = $00000020;
+ ILC_PALETTE = $00000800; // (not implemented)
+{$ifdef win32xp}
+ ILC_MIRROR = $00002000; // Mirror the icons contained, if the process is mirrored
+ ILC_PERITEMMIRROR = $00008000; // Causes the mirroring code to mirror each item when inserting a set of images, verses the whole strip
+{$ENDIF}
+{$ifdef win32vista}
+ ILC_ORIGINALSIZE = $00010000; // Imagelist should accept smaller than set images and apply OriginalSize based on image added
+ ILC_HIGHQUALITYSCALE = $00020000; // Imagelist should enable use of the high quality scaler.
+{$endif}
+
+function ImageList_Create(cx:cint;cy:cint;flags:UINT;cInitial:cint;cGrow:cint):HIMAGELIST; stdcall; external commctrldll name 'ImageList_Create';
+function ImageList_Destroy(himl:HIMAGELIST):BOOL; stdcall; external commctrldll name 'ImageList_Destroy';
+
+function ImageList_GetImageCount(himl:HIMAGELIST):cint; stdcall; external commctrldll name 'ImageList_GetImageCount';
+{$ifdef ie3plus}
+function ImageList_SetImageCount(himl:HIMAGELIST;uNewCount:UINT):BOOL; stdcall; external commctrldll name 'ImageList_SetImageCount';
+{$ENDIF}
+
+function ImageList_Add(himl:HIMAGELIST;hbmImage:HBITMAP;hbmMask:HBITMAP):cint; stdcall; external commctrldll name 'ImageList_Add';
+
+function ImageList_ReplaceIcon(himl:HIMAGELIST;i:cint;hicon:HICON):cint; stdcall; external commctrldll name 'ImageList_ReplaceIcon';
+function ImageList_SetBkColor(himl:HIMAGELIST;clrBk:COLORREF):COLORREF; stdcall; external commctrldll name 'ImageList_SetBkColor';
+function ImageList_GetBkColor(himl:HIMAGELIST):COLORREF; stdcall; external commctrldll name 'ImageList_GetBkColor';
+function ImageList_SetOverlayImage(himl:HIMAGELIST;iImage:cint;iOverlay:cint):BOOL; stdcall; external commctrldll name 'ImageList_SetOverlayImage';
+
+// Macro 11
+Function ImageList_AddIcon(Himl:HIMAGELIST;hicon:HICON):cint;
+
+CONST
+ ILD_NORMAL = $00000000;
+ ILD_TRANSPARENT = $00000001;
+ ILD_MASK = $00000010;
+ ILD_IMAGE = $00000020;
+{$ifdef ie3plus}
+ ILD_ROP = $00000040;
+{$ENDIF}
+ ILD_BLEND25 = $00000002;
+ ILD_BLEND50 = $00000004;
+ ILD_OVERLAYMASK = $00000F00;
+
+// Macro 12
+// #define INDEXTOOVERLAYMASK(i) ((i) << 8)
+
+CONST
+ ILD_PRESERVEALPHA = $00001000; // This preserves the alpha channel in dest
+ ILD_SCALE = $00002000; // Causes the image to be scaled to cx, cy instead of clipped
+ ILD_DPISCALE = $00004000;
+{$ifdef win32vista}
+ ILD_ASYNC = $00008000;
+{$endif}
+
+ ILD_SELECTED = ILD_BLEND50;
+ ILD_FOCUS = ILD_BLEND25;
+ ILD_BLEND = ILD_BLEND50;
+ CLR_HILIGHT = CLR_DEFAULT;
+
+ ILS_NORMAL = $00000000;
+ ILS_GLOW = $00000001;
+ ILS_SHADOW = $00000002;
+ ILS_SATURATE = $00000004;
+ ILS_ALPHA = $00000008;
+
+{$ifdef win32vista}
+ ILGT_NORMAL = $00000000;
+ ILGT_ASYNC = $00000001;
+{$endif}
+
+function ImageList_Draw(himl:HIMAGELIST;i:cint;hdcDst:HDC;x:cint;y:cint;fStyle:UINT):BOOL; stdcall; external commctrldll name 'ImageList_Draw';
+
+
+{$IFDEF _WIN32}
+
+{$ifdef win32vista}
+const
+ HBITMAP_CALLBACK =HBITMAP(-1); // only for SparseImageList
+{$endif}
+function ImageList_Replace(himl:HIMAGELIST;i:cint;hbmImage:HBITMAP;hbmMask:HBITMAP):BOOL; stdcall; external commctrldll name 'ImageList_Replace';
+
+function ImageList_AddMasked(himl:HIMAGELIST;hbmImage:HBITMAP;crMask:COLORREF):cint; stdcall; external commctrldll name 'ImageList_AddMasked';
+function ImageList_DrawEx(himl:HIMAGELIST;i:cint;hdcDst:HDC;x:cint;y:cint;dx:cint;dy:cint;rgbBk:COLORREF;rgbFg:COLORREF;fStyle:UINT):BOOL; stdcall; external commctrldll name 'ImageList_DrawEx';
+{$ifdef ie3plus}
+function ImageList_DrawIndirect(pimldp:PIMAGELISTDRAWPARAMS):BOOL; stdcall; external commctrldll name 'ImageList_DrawIndirect';
+{$ENDIF}
+function ImageList_Remove(himl:HIMAGELIST;i:cint):BOOL; stdcall; external commctrldll name 'ImageList_Remove';
+function ImageList_GetIcon(himl:HIMAGELIST;i:cint;flags:UINT):HICON; stdcall; external commctrldll name 'ImageList_GetIcon';
+function ImageList_LoadImageA(hi:HINST;lpbmp:LPCSTR;cx:cint;cGrow:cint;crMask:COLORREF;uType:UINT;uFlags:UINT):HIMAGELIST; stdcall; external commctrldll name 'ImageList_LoadImageA';
+function ImageList_LoadImageW(hi:HINST;lpbmp:LPCWSTR;cx:cint;cGrow:cint;crMask:COLORREF;uType:UINT;uFlags:UINT):HIMAGELIST; stdcall; external commctrldll name 'ImageList_LoadImageW';
+function ImageList_LoadImage(hi:HINST;lpbmp:LPCSTR;cx:cint;cGrow:cint;crMask:COLORREF;uType:UINT;uFlags:UINT):HIMAGELIST; stdcall; external commctrldll name 'ImageList_LoadImageA';
+function ImageList_LoadImage(hi:HINST;lpbmp:LPCWSTR;cx:cint;cGrow:cint;crMask:COLORREF;uType:UINT;uFlags:UINT):HIMAGELIST; stdcall; external commctrldll name 'ImageList_LoadImageW';
+
+{$IFDEF UNICODE}
+// function ImageList_LoadImageW(hi:HINSTANCE;lpbmp:LPCWSTR;cx:cint;cGrow:cint;crMask:COLORREF;uType:UINT;uFlags:UINT):HIMAGELIST; external commctrldll name 'ImageList_LoadImageW';
+{$ELSE}
+// function ImageList_LoadImageA(hi:HINSTANCE;lpbmp:LPCSTR;cx:cint;cGrow:cint;crMask:COLORREF;uType:UINT;uFlags:UINT):HIMAGELIST; external commctrldll name 'ImageList_LoadImageA';
+{$ENDIF}
+
+{$ifdef ie3plus}
+
+CONST
+ ILCF_MOVE = ($00000000);
+ ILCF_SWAP = ($00000001);
+
+function ImageList_Copy(himlDst:HIMAGELIST;iDst:cint;himlSrc:HIMAGELIST;iSrc:cint;uFlags:UINT):BOOL; stdcall; external commctrldll name 'ImageList_Copy';
+{$ENDIF}
+
+function ImageList_BeginDrag(himlTrack:HIMAGELIST;iTrack:cint;dxHotspot:cint;dyHotspot:cint):BOOL; stdcall; external commctrldll name 'ImageList_BeginDrag';
+function ImageList_EndDrag:BOOL; stdcall; external commctrldll name 'ImageList_EndDrag';
+function ImageList_DragEnter(hwndLock:HWND;x:cint;y:cint):BOOL; stdcall; external commctrldll name 'ImageList_DragEnter';
+function ImageList_DragLeave(hwndLock:HWND):BOOL; stdcall; external commctrldll name 'ImageList_DragLeave';
+function ImageList_DragMove(x:cint;y:cint):BOOL; stdcall; external commctrldll name 'ImageList_DragMove';
+function ImageList_SetDragCursorImage(himlDrag:HIMAGELIST;iDrag:cint;dxHotspot:cint;dyHotspot:cint):BOOL; stdcall; external commctrldll name 'ImageList_SetDragCursorImage';
+
+function ImageList_DragShowNolock(fShow:BOOL):BOOL; stdcall; external commctrldll name 'ImageList_DragShowNolock';
+function ImageList_GetDragImage(ppt:PPOINT;pptHotspot:PPOINT):HIMAGELIST; stdcall; external commctrldll name 'ImageList_GetDragImage';
+
+// Macro 13
+Procedure ImageList_RemoveAll(himl:HIMAGELIST);
+
+// Macro 14
+function ImageList_ExtractIcon(hi:longint; himl:HIMAGELIST;i:longint):HICON;
+
+
+// Macro 15
+Procedure ImageList_LoadBitmap(hi:HInst;bmp:LPCTSTR;cx:cint;cGrow:cint;crMask:COLORREF);
+
+{$IFDEF __IStream_INTERFACE_DEFINED__}
+
+function ImageList_Read(pstm:ISTREAM):HIMAGELIST; stdcall; external commctrldll name 'ImageList_Read';
+function ImageList_Write(himl:HIMAGELIST;pstm:ISTREAM):BOOL; stdcall; external commctrldll name 'ImageList_Write';
+
+{$ifdef Win32XP}
+
+CONST
+ ILP_NORMAL = 0; // Writes or reads the stream using new sematics for this version of comctl32
+ ILP_DOWNLEVEL = 1; // Write or reads the stream using downlevel sematics.
+
+
+function ImageList_ReadEx(dwFlags:DWORD;pstm:ISTREAM;riid:TIID;ppv:PPointer):HRESULT; stdcall; external commctrldll name 'ImageList_ReadEx';
+function ImageList_WriteEx(himl:HIMAGELIST;dwFlags:DWORD;pstm:ISTREAM):HRESULT; stdcall; external commctrldll name 'ImageList_WriteEx';
+{$ENDIF}
+
+{$ENDIF}
+
+{$IFNDEF IMAGEINFO}
+TYPE
+
+ _IMAGEINFO = Record
+ hbmImage : HBITMAP;
+ hbmMask : HBITMAP;
+ Unused1 : cint;
+ Unused2 : cint;
+ rcImage : RECT;
+ END;
+ IMAGEINFO = _IMAGEINFO;
+ LPIMAGEINFO = ^_IMAGEINFO;
+ TIMAGEINFO = _IMAGEINFO;
+ PIMAGEINFO = ^_IMAGEINFO;
+
+{$ENDIF}
+
+function ImageList_GetIconSize(himl:HIMAGELIST;cx:Pint;cy:Pint):BOOL; stdcall; external commctrldll name 'ImageList_GetIconSize';
+function ImageList_GetIconSize(himl:HIMAGELIST;var cx:cint;var cy:cint):BOOL; stdcall; external commctrldll name 'ImageList_GetIconSize';
+function ImageList_SetIconSize(himl:HIMAGELIST;cx:cint;cy:cint):BOOL; stdcall; external commctrldll name 'ImageList_SetIconSize';
+function ImageList_GetImageInfo(himl:HIMAGELIST;i:cint;pImageInfo:PIMAGEINFO):BOOL; stdcall; external commctrldll name 'ImageList_GetImageInfo';
+function ImageList_GetImageInfo(himl:HIMAGELIST;i:cint;var pImageInfo:_IMAGEINFO):BOOL; stdcall; external commctrldll name 'ImageList_GetImageInfo';
+function ImageList_Merge(himl1:HIMAGELIST;i1:cint;himl2:HIMAGELIST;i2:cint;dx:cint;dy:cint):HIMAGELIST; stdcall; external commctrldll name 'ImageList_Merge';
+{$ifdef ie4plus}
+function ImageList_Duplicate(himl:HIMAGELIST):HIMAGELIST; stdcall; external commctrldll name 'ImageList_Duplicate';
+{$ENDIF}
+
+
+{$ENDIF}
+
+
+{$ENDIF}
+
+
+//====== HEADER CONTROL =======================================================
+
+{$IFNDEF NOHEADER}
+
+{$IFDEF _WIN32}
+
+CONST
+ WC_HEADERA = 'SysHeader32';
+ WC_HEADERW = {L}'SysHeader32';
+{$IFDEF UNICODE}
+ WC_HEADER = WC_HEADERW;
+{$ELSE}
+ WC_HEADER = WC_HEADERA;
+{$ENDIF}
+
+{$ELSE}
+
+CONST
+ WC_HEADER = 'SysHeader';
+{$ENDIF}
+
+CONST
+
+// begin_r_commctrl
+
+ HDS_HORZ = $0000;
+ HDS_BUTTONS = $0002;
+{$ifdef ie3plus}
+ HDS_HOTTRACK = $0004;
+{$ENDIF}
+ HDS_HIDDEN = $0008;
+
+{$ifdef ie3plus}
+ HDS_DRAGDROP = $0040;
+ HDS_FULLDRAG = $0080;
+{$ENDIF}
+{$ifdef ie5plus}
+ HDS_FILTERBAR = $0100;
+{$ENDIF}
+
+{$ifdef win32xp}
+ HDS_FLAT = $0200;
+{$ENDIF}
+{$ifdef win32vista}
+ HDS_CHECKBOXES = $0400;
+ HDS_NOSIZING = $0800;
+ HDS_OVERFLOW = $1000;
+{$endif}
+// end_r_commctrl
+
+{$ifdef ie5plus}
+
+ HDFT_ISSTRING = $0000; // HD_ITEM.pvFilter points to a HD_TEXTFILTER
+ HDFT_ISNUMBER = $0001; // HD_ITEM.pvFilter points to a INT
+
+ HDFT_HASNOVALUE = $8000; // clear the filter, by setting this bit
+
+TYPE
+
+
+ _HD_TEXTFILTERA = Record
+ pszText : LPSTR; // [in] pointer to the buffer containing the filter (ANSI)
+ cchTextMax : cint; // [in] max size of buffer/edit control buffer
+ END;
+ HD_TEXTFILTERA = _HD_TEXTFILTERA;
+ LPHD_TEXTFILTERA = ^_HD_TEXTFILTERA;
+ THD_TEXTFILTERA = _HD_TEXTFILTERA;
+ PHD_TEXTFILTERA = ^_HD_TEXTFILTERA;
+
+
+ _HD_TEXTFILTERW = Record
+ pszText : LPWSTR; // [in] pointer to the buffer contiaining the filter (UNICODE)
+ cchTextMax : cint; // [in] max size of buffer/edit control buffer
+ END;
+ HD_TEXTFILTERW = _HD_TEXTFILTERW;
+ LPHD_TEXTFILTERW = ^_HD_TEXTFILTERW;
+ THD_TEXTFILTERW = _HD_TEXTFILTERW;
+ PHD_TEXTFILTERW = ^_HD_TEXTFILTERW;
+
+{$IFDEF UNICODE}
+ HD_TEXTFILTER = HD_TEXTFILTERW;
+ HDTEXTFILTER = HD_TEXTFILTERW;
+ LPHD_TEXTFILTER = LPHD_TEXTFILTERW;
+ LPHDTEXTFILTER = LPHD_TEXTFILTERW;
+{$ELSE}
+ HD_TEXTFILTER = HD_TEXTFILTERA;
+ HDTEXTFILTER = HD_TEXTFILTERA;
+ LPHD_TEXTFILTER = LPHD_TEXTFILTERA;
+ LPHDTEXTFILTER = LPHD_TEXTFILTERA;
+{$ENDIF}
+
+
+{$ENDIF} // _WIN32_IE >= 0x0500
+
+TYPE
+
+
+ _HD_ITEMA = Record
+ mask : UINT;
+ cxy : cint;
+ pszText : LPSTR;
+ hbm : HBITMAP;
+ cchTextMax : cint;
+ fmt : cint;
+ lParam : LPARAM;
+{$ifdef ie3plus}
+ iImage : cint; // index of bitmap in ImageList
+ iOrder : cint; // where to draw this item
+{$ENDIF}
+{$ifdef ie5plus}
+ _type : UINT; // [in] filter type (defined what pvFilter is a pointer to)
+ pvFilter : Pointer; // [in] fillter data see above
+{$ENDIF}
+{$ifdef win32vista}
+ state : UINT;
+{$endif}
+ END;
+ HDITEMA = _HD_ITEMA;
+ pHDITEMA = ^_HD_ITEMA;
+
+ LPHDITEMA = ^_HD_ITEMA;
+ THD_ITEMA = _HD_ITEMA;
+ PHD_ITEMA = ^_HD_ITEMA;
+ THDItem = THD_ITEMA;
+ PHDItem = PHD_ITEMA;
+
+
+// #define HDITEMA_V1_SIZE CCSIZEOF_STRUCT(HDITEMA, lParam)
+// #define HDITEMW_V1_SIZE CCSIZEOF_STRUCT(HDITEMW, lParam)
+
+
+ _HD_ITEMW = Record
+ mask : UINT;
+ cxy : cint;
+ pszText : LPWSTR;
+ hbm : HBITMAP;
+ cchTextMax : cint;
+ fmt : cint;
+ lParam : LPARAM;
+{$ifdef ie3plus}
+ iImage : cint; // index of bitmap in ImageList
+ iOrder : cint;
+{$ENDIF}
+{$ifdef ie5plus}
+ _type : UINT; // [in] filter type (defined what pvFilter is a pointer to)
+ pvFilter : Pointer; // [in] fillter data see above
+{$ENDIF}
+{$ifdef win32vista}
+ state : UINT;
+{$endif}
+ END;
+ HDITEMW = _HD_ITEMW;
+ pHDITEMW = ^_HD_ITEMW;
+ LPHDITEMW = ^_HD_ITEMW;
+ THD_ITEMW = _HD_ITEMW;
+ PHD_ITEMW = ^_HD_ITEMW;
+
+
+TYPE
+{$IFDEF UNICODE}
+ HDITEM = HDITEMW;
+ LPHDITEM = LPHDITEMW;
+// HDITEM_V1_SIZE = HDITEMW_V1_SIZE;
+{$ELSE}
+
+ HDITEM = HDITEMA;
+ LPHDITEM = LPHDITEMA;
+// HDITEM_V1_SIZE = HDITEMA_V1_SIZE;
+{$ENDIF}
+
+ HD_ITEM = HDITEM;
+
+
+CONST
+
+ HDI_WIDTH = $0001;
+ HDI_HEIGHT = HDI_WIDTH;
+ HDI_TEXT = $0002;
+ HDI_FORMAT = $0004;
+ HDI_LPARAM = $0008;
+ HDI_BITMAP = $0010;
+{$ifdef ie3plus}
+ HDI_IMAGE = $0020;
+ HDI_DI_SETITEM = $0040;
+ HDI_ORDER = $0080;
+{$ENDIF}
+{$ifdef ie5plus}
+ HDI_FILTER = $0100;
+{$ENDIF}
+{$ifdef win32vista}
+ HDI_STATE = $0200;
+{$endif}
+
+ HDF_LEFT = $0000;
+ HDF_RIGHT = $0001;
+ HDF_CENTER = $0002;
+ HDF_JUSTIFYMASK = $0003;
+ HDF_RTLREADING = $0004;
+
+ HDF_OWNERDRAW = $8000;
+ HDF_STRING = $4000;
+ HDF_BITMAP = $2000;
+{$ifdef ie3plus}
+ HDF_BITMAP_ON_RIGHT = $1000;
+ HDF_IMAGE = $0800;
+{$ENDIF}
+
+{$ifdef win32xp}
+ HDF_SORTUP = $0400;
+ HDF_SORTDOWN = $0200;
+{$ENDIF}
+{$ifdef win32vista}
+ HDF_CHECKBOX = $0040;
+ HDF_CHECKED = $0080;
+ HDF_FIXEDWIDTH = $0100; // Can't resize the column; same as LVCFMT_FIXED_WIDTH
+ HDF_SPLITBUTTON = $1000000; // Column is a split button; same as LVCFMT_SPLITBUTTON
+{$endif}
+
+{$ifdef win32vista}
+ HDIS_FOCUSED = $00000001;
+{$endif}
+
+
+ HDM_GETITEMCOUNT = (HDM_FIRST + 0);
+
+// Macro 16
+Function Header_GetItemCount( hwndHD : hwnd):cint;
+
+CONST
+ HDM_INSERTITEMA = (HDM_FIRST + 1);
+ HDM_INSERTITEMW = (HDM_FIRST + 10);
+
+{$IFDEF UNICODE}
+ HDM_INSERTITEM = HDM_INSERTITEMW;
+{$ELSE}
+ HDM_INSERTITEM = HDM_INSERTITEMA;
+{$ENDIF}
+
+// Macro 17
+Function Header_InsertItem( hwndHD : hwnd; i : cint;const phdi : HD_ITEM ):cint;
+
+
+CONST
+ HDM_DELETEITEM = (HDM_FIRST + 2);
+
+// Macro 18
+Function Header_DeleteItem( hwndHD : hwnd; i : cint):BOOL;
+
+CONST
+ HDM_GETITEMA = (HDM_FIRST + 3);
+ HDM_GETITEMW = (HDM_FIRST + 11);
+
+{$IFDEF UNICODE}
+ HDM_GETITEM = HDM_GETITEMW;
+{$ELSE}
+ HDM_GETITEM = HDM_GETITEMA;
+{$ENDIF}
+
+// Macro 19
+Function Header_GetItem( hwndHD : hwnd; i : cint;var phdi : HD_ITEM ):BOOL;
+
+CONST
+ HDM_SETITEMA = (HDM_FIRST + 4);
+ HDM_SETITEMW = (HDM_FIRST + 12);
+
+{$IFDEF UNICODE}
+ HDM_SETITEM = HDM_SETITEMW;
+{$ELSE}
+ HDM_SETITEM = HDM_SETITEMA;
+{$ENDIF}
+
+// Macro 20
+Function Header_SetItem( hwndHD : hwnd; i : cint;const phdi : HD_ITEM ):BOOL;
+
+TYPE
+
+ _HD_LAYOUT = Record
+ prc : PRECT;
+ pwpos : PWINDOWPOS;
+ END;
+ HDLAYOUT = _HD_LAYOUT;
+ LPHDLAYOUT = ^_HD_LAYOUT;
+ THD_LAYOUT = _HD_LAYOUT;
+ PHD_LAYOUT = ^_HD_LAYOUT;
+
+CONST
+ HDM_LAYOUT = (HDM_FIRST + 5);
+
+{$ifdef ie3plus}
+TYPE
+ HD_LAYOUT = HDLAYOUT;
+{$ELSE}
+// HDLAYOUT = HD_LAYOUT;
+{$ENDIF}
+
+
+// Macro 21
+Function Header_Layout( hwndHD : hwnd;var playout : HD_LAYOUT ):BOOL;
+
+CONST
+ HHT_NOWHERE = $0001;
+ HHT_ONHEADER = $0002;
+ HHT_ONDIVIDER = $0004;
+ HHT_ONDIVOPEN = $0008;
+{$ifdef ie5plus}
+ HHT_ONFILTER = $0010;
+ HHT_ONFILTERBUTTON = $0020;
+{$ENDIF}
+ HHT_ABOVE = $0100;
+ HHT_BELOW = $0200;
+ HHT_TORIGHT = $0400;
+ HHT_TOLEFT = $0800;
+{$ifdef win32vista}
+ HHT_ONITEMSTATEICON = $1000;
+ HHT_ONDROPDOWN = $2000;
+ HHT_ONOVERFLOW = $4000;
+{$endif}
+
+TYPE
+ _HD_HITTESTINFO = Record
+ case integer of
+ 1: (pt : POINT;flags : UINT;iItem : cint);
+ { delphi }
+ 2: (point : POINT;dummyflags : UINT;Item : cint);
+ END;
+ HDHITTESTINFO = _HD_HITTESTINFO;
+ HD_HITTESTINFO = _HD_HITTESTINFO;
+ LPHDHITTESTINFO = ^_HD_HITTESTINFO;
+ THD_HITTESTINFO = _HD_HITTESTINFO;
+ PHD_HITTESTINFO = ^_HD_HITTESTINFO;
+ THDHitTestInfo = THD_HITTESTINFO;
+ PHDHitTestInfo = LPHDHITTESTINFO;
+
+
+CONST
+ HDM_HITTEST = (HDM_FIRST + 6);
+
+{$ifdef ie3plus}
+
+ HDM_GETITEMRECT = (HDM_FIRST + 7);
+
+// Macro 22
+Function Header_GetItemRect( hwnd : hwnd; iItem : WPARAM; lprc : LPARAM):BOOL;
+
+CONST
+ HDM_SETIMAGELIST = (HDM_FIRST + 8);
+
+// Macro 23
+Function Header_SetImageList( hwnd : hwnd; himl : LPARAM):HIMAGELIST;
+
+CONST
+ HDM_GETIMAGELIST = (HDM_FIRST + 9);
+
+// Macro 24
+Function Header_GetImageList( hwnd : hwnd):HIMAGELIST;
+
+CONST
+ HDM_ORDERTOINDEX = (HDM_FIRST + 15);
+
+// Macro 25
+Function Header_OrderToIndex( hwnd : hwnd; i : WPARAM):cint;
+
+CONST
+ HDM_CREATEDRAGIMAGE = (HDM_FIRST + 16); // wparam = which item (by index)
+
+// Macro 26
+Function Header_CreateDragImage( hwnd : hwnd; i : WPARAM):HIMAGELIST;
+
+CONST
+ HDM_GETORDERARRAY = (HDM_FIRST + 17);
+
+// Macro 27
+Function Header_GetOrderArray( hwnd : hwnd; iCount : WPARAM; lpi : LPARAM):BOOL;
+
+CONST
+ HDM_SETORDERARRAY = (HDM_FIRST + 18);
+
+// Macro 28
+Function Header_SetOrderArray( hwnd : hwnd; iCount : WPARAM; lpi : PInteger):BOOL;inline;
+
+// lparam = int array of size HDM_GETITEMCOUNT
+// the array specifies the order that all items should be displayed.
+// e.g. { 2, 0, 1}
+// says the index 2 item should be shown in the 0ths position
+// index 0 should be shown in the 1st position
+// index 1 should be shown in the 2nd position
+
+
+CONST
+ HDM_SETHOTDIVIDER = (HDM_FIRST + 19);
+
+// Macro 29
+Function Header_SetHotDivider( hwnd : hwnd; fPos : WPARAM; dw : LPARAM):cint;
+
+// convenience message for external dragdrop
+// wParam = BOOL specifying whether the lParam is a dwPos of the cursor
+// position or the index of which divider to hotlight
+// lParam = depends on wParam (-1 and wParm = FALSE turns off hotlight)
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+{$ifdef ie5plus}
+CONST
+ HDM_SETBITMAPMARGIN = (HDM_FIRST + 20);
+
+// Macro 30
+Function Header_SetBitmapMargin( hwnd : hwnd; iWidth : WPARAM):cint;
+
+CONST
+ HDM_GETBITMAPMARGIN = (HDM_FIRST + 21);
+
+// Macro 31
+Function Header_GetBitmapMargin( hwnd : hwnd):cint;
+
+{$ENDIF}
+
+
+{$ifdef ie4plus}
+
+CONST
+ HDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+
+// Macro 32
+Function Header_SetUnicodeFormat( hwnd : hwnd; fUnicode : WPARAM):BOOL;
+
+CONST
+ HDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+
+// Macro 33
+Function Header_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+{$ENDIF}
+
+{$ifdef ie5plus}
+CONST
+ HDM_SETFILTERCHANGETIMEOUT = (HDM_FIRST+22);
+
+// Macro 34
+Function Header_SetFilterChangeTimeout( hwnd : hwnd; i : LPARAM):cint;
+
+CONST
+ HDM_EDITFILTER = (HDM_FIRST+23);
+
+// Macro 35
+Function Header_EditFilter( hwnd : hwnd; i : WPARAM; fDiscardChanges :cint ):cint;
+
+
+// Clear filter takes -1 as a column value to indicate that all
+// the filter should be cleared. When this happens you will
+// only receive a single filter changed notification.
+
+CONST
+ HDM_CLEARFILTER = (HDM_FIRST+24);
+
+// Macro 36
+Function Header_ClearFilter( hwnd : hwnd; i : WPARAM):cint;
+
+// Macro 37
+Function Header_ClearAllFilters( hwnd : hwnd):cint;
+
+{$ENDIF}
+
+{$ifdef win32vista}
+// HDM_TRANSLATEACCELERATOR = CCM_TRANSLATEACCELERATOR; // CCM_* not defined anywhere yet in w7 sdk
+
+const
+ HDM_GETITEMDROPDOWNRECT = (HDM_FIRST+25);
+ HDM_GETOVERFLOWRECT = (HDM_FIRST+26);
+ HDM_GETFOCUSEDITEM = (HDM_FIRST+27);
+ HDM_SETFOCUSEDITEM = (HDM_FIRST+28);
+
+// macro 37a through 37d
+function Header_GetItemDropDownRect(hwnd : hwnd;iItem:cint; lprc:lprect):bool;
+function Header_GetOverflowRect( hwnd : hwnd; lprc:lprect):bool;
+function Header_GetFocusedItem (hwnd : hwnd):cint;
+function Header_SetFocusedItem (hwnd:hwnd; iItem:cint):BOOL;
+{$endif}
+
+CONST
+ HDN_ITEMCHANGINGA = (HDN_FIRST-0);
+ HDN_ITEMCHANGINGW = (HDN_FIRST-20);
+ HDN_ITEMCHANGEDA = (HDN_FIRST-1);
+ HDN_ITEMCHANGEDW = (HDN_FIRST-21);
+ HDN_ITEMCLICKA = (HDN_FIRST-2);
+ HDN_ITEMCLICKW = (HDN_FIRST-22);
+ HDN_ITEMDBLCLICKA = (HDN_FIRST-3);
+ HDN_ITEMDBLCLICKW = (HDN_FIRST-23);
+ HDN_DIVIDERDBLCLICKA = (HDN_FIRST-5);
+ HDN_DIVIDERDBLCLICKW = (HDN_FIRST-25);
+ HDN_BEGINTRACKA = (HDN_FIRST-6);
+ HDN_BEGINTRACKW = (HDN_FIRST-26);
+ HDN_ENDTRACKA = (HDN_FIRST-7);
+ HDN_ENDTRACKW = (HDN_FIRST-27);
+ HDN_TRACKA = (HDN_FIRST-8);
+ HDN_TRACKW = (HDN_FIRST-28);
+{$ifdef ie3plus}
+ HDN_GETDISPINFOA = (HDN_FIRST-9);
+ HDN_GETDISPINFOW = (HDN_FIRST-29);
+ HDN_BEGINDRAG = (HDN_FIRST-10);
+ HDN_ENDDRAG = (HDN_FIRST-11);
+{$ENDIF}
+{$ifdef ie5plus}
+ HDN_FILTERCHANGE = (HDN_FIRST-12);
+ HDN_FILTERBTNCLICK = (HDN_FIRST-13);
+{$ENDIF}
+{$ifdef win32vista}
+ HDN_BEGINFILTEREDIT = (HDN_FIRST-14);
+ HDN_ENDFILTEREDIT = (HDN_FIRST-15);
+
+ HDN_ITEMSTATEICONCLICK = (HDN_FIRST-16);
+ HDN_ITEMKEYDOWN = (HDN_FIRST-17);
+ HDN_DROPDOWN = (HDN_FIRST-18);
+ HDN_OVERFLOWCLICK = (HDN_FIRST-19);
+{$endif}
+
+{$IFDEF UNICODE}
+ HDN_ITEMCHANGING = HDN_ITEMCHANGINGW;
+ HDN_ITEMCHANGED = HDN_ITEMCHANGEDW;
+ HDN_ITEMCLICK = HDN_ITEMCLICKW;
+ HDN_ITEMDBLCLICK = HDN_ITEMDBLCLICKW;
+ HDN_DIVIDERDBLCLICK = HDN_DIVIDERDBLCLICKW;
+ HDN_BEGINTRACK = HDN_BEGINTRACKW;
+ HDN_ENDTRACK = HDN_ENDTRACKW;
+ HDN_TRACK = HDN_TRACKW;
+{$ifdef ie3plus}
+ HDN_GETDISPINFO = HDN_GETDISPINFOW;
+{$ENDIF}
+{$ELSE}
+ HDN_ITEMCHANGING = HDN_ITEMCHANGINGA;
+ HDN_ITEMCHANGED = HDN_ITEMCHANGEDA;
+ HDN_ITEMCLICK = HDN_ITEMCLICKA;
+ HDN_ITEMDBLCLICK = HDN_ITEMDBLCLICKA;
+ HDN_DIVIDERDBLCLICK = HDN_DIVIDERDBLCLICKA;
+ HDN_BEGINTRACK = HDN_BEGINTRACKA;
+ HDN_ENDTRACK = HDN_ENDTRACKA;
+ HDN_TRACK = HDN_TRACKA;
+{$ifdef ie3plus}
+ HDN_GETDISPINFO = HDN_GETDISPINFOA;
+{$ENDIF}
+{$ENDIF}
+
+TYPE
+ tagNMHEADERA = Record
+ hdr : NMHDR;
+ case integer of
+ 1: (iItem : cint;iButton : cint;pitem : PHDITEMA);
+ { delphi: }
+ 2: (Item : cint;Button : cint);
+ END;
+ NMHEADERA = tagNMHEADERA;
+ LPNMHEADERA = ^tagNMHEADERA;
+ TNMHEADERA = tagNMHEADERA;
+ PNMHEADERA = ^tagNMHEADERA;
+
+ tagNMHEADERW = Record
+ hdr : NMHDR;
+ iItem : cint;
+ iButton : cint;
+ pitem : PHDITEMW;
+ END;
+ NMHEADERW = tagNMHEADERW;
+ LPNMHEADERW = ^tagNMHEADERW;
+ TNMHEADERW = tagNMHEADERW;
+ PNMHEADERW = ^tagNMHEADERW;
+
+
+{$IFDEF UNICODE}
+ NMHEADER = NMHEADERW;
+ LPNMHEADER = LPNMHEADERW;
+{$ELSE}
+ NMHEADER = NMHEADERA;
+ LPNMHEADER = LPNMHEADERA;
+{$ENDIF}
+
+
+{$ifdef ie3plus}
+ HD_NOTIFYA = NMHEADERA;
+ HD_NOTIFYW = NMHEADERW;
+{$ELSE}
+// tagNMHEADERA = _HD_NOTIFY;
+// NMHEADERA = HD_NOTIFYA;
+// tagHMHEADERW = _HD_NOTIFYW;
+// NMHEADERW = HD_NOTIFYW;
+{$ENDIF}
+
+ HD_NOTIFY = NMHEADER;
+ THDNotify = HD_NOTIFY;
+ PHDNotify = ^HD_NOTIFY;
+
+ tagNMHDDISPINFOW = Record
+ hdr : NMHDR;
+ iItem : cint;
+ mask : UINT;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ lParam : LPARAM;
+ END;
+ NMHDDISPINFOW = tagNMHDDISPINFOW;
+ LPNMHDDISPINFOW = ^tagNMHDDISPINFOW;
+ TNMHDDISPINFOW = tagNMHDDISPINFOW;
+ PNMHDDISPINFOW = ^tagNMHDDISPINFOW;
+
+
+ tagNMHDDISPINFOA = Record
+ hdr : NMHDR;
+ iItem : cint;
+ mask : UINT;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ lParam : LPARAM;
+ END;
+ NMHDDISPINFOA = tagNMHDDISPINFOA;
+ LPNMHDDISPINFOA = ^tagNMHDDISPINFOA;
+ TNMHDDISPINFOA = tagNMHDDISPINFOA;
+ PNMHDDISPINFOA = ^tagNMHDDISPINFOA;
+
+
+
+{$IFDEF UNICODE}
+ NMHDDISPINFO = NMHDDISPINFOW;
+ LPNMHDDISPINFO = LPNMHDDISPINFOW;
+{$ELSE}
+ NMHDDISPINFO = NMHDDISPINFOA;
+ LPNMHDDISPINFO = LPNMHDDISPINFOA;
+{$ENDIF}
+
+{$ifdef ie5plus}
+ tagNMHDFILTERBTNCLICK = Record
+ hdr : NMHDR;
+ iItem : cint;
+ rc : RECT;
+ END;
+ NMHDFILTERBTNCLICK = tagNMHDFILTERBTNCLICK;
+ LPNMHDFILTERBTNCLICK = ^tagNMHDFILTERBTNCLICK;
+ TNMHDFILTERBTNCLICK = tagNMHDFILTERBTNCLICK;
+ PNMHDFILTERBTNCLICK = ^tagNMHDFILTERBTNCLICK;
+
+{$ENDIF}
+
+{$ENDIF} // NOHEADER
+
+
+//====== TOOLBAR CONTROL ======================================================
+
+{$IFNDEF NOTOOLBAR}
+
+{$IFDEF _WIN32}
+
+CONST
+ TOOLBARCLASSNAMEW = {L}'ToolbarWindow32';
+ TOOLBARCLASSNAMEA = 'ToolbarWindow32';
+
+{$IFDEF UNICODE}
+ TOOLBARCLASSNAME = TOOLBARCLASSNAMEW;
+{$ELSE}
+ TOOLBARCLASSNAME = TOOLBARCLASSNAMEA;
+{$ENDIF}
+
+{$ELSE}
+CONST
+ TOOLBARCLASSNAME = 'ToolbarWindow';
+{$ENDIF}
+
+TYPE
+
+ _TBBUTTON = Record
+ iBitmap : cint;
+ idCommand : cint;
+ fsState : BYTE;
+ fsStyle : BYTE;
+{$IFDEF _WIN64}
+ bReserved : ARRAY[0..5] OF BYTE; // padding for alignment
+{$ELSE}
+{$IFDEF _WIN32}
+ bReserved : ARRAY[0..1] OF BYTE; // padding for alignment
+{$ENDIF}
+{$ENDIF}
+ dwData : DWORD_PTR;
+ iString : INT_PTR;
+ END;
+ TBBUTTON = _TBBUTTON;
+ PTBBUTTON = {NEAR} ^_TBBUTTON; // ???
+ LPTBBUTTON = ^_TBBUTTON;
+ TTBBUTTON = _TBBUTTON;
+// PTBBUTTON = ^_TBBUTTON;
+
+ LPCTBBUTTON = {const} ^TBBUTTON;
+
+
+ _COLORMAP = Record
+ xfrom : COLORREF;
+ xto : COLORREF;
+ END;
+ COLORMAP = _COLORMAP;
+ LPCOLORMAP = ^_COLORMAP;
+ TCOLORMAP = _COLORMAP;
+ PCOLORMAP = ^_COLORMAP;
+
+function CreateToolbarEx(hwnd:HWND;ws:DWORD;wID:UINT;nBitmaps:cint;
+ hBMInst:HINST;
+ wBMID:UINT_PTR;lpButtons:LPCTBBUTTON;iNumButtons:cint;dxButton:cint;
+ dyButton:cint;dxBitmap:cint;dyBitmap:cint;uStructSize:UINT):HWND; stdcall; external commctrldll name 'CreateToolbarEx';
+
+function CreateMappedBitmap(hInstance:HINST;idBitmap:INT_PTR;wFlags:UINT;lpColorMap:LPCOLORMAP;iNumMaps:cint):HBITMAP; stdcall; external commctrldll name 'CreateMappedBitmap';
+
+CONST
+ CMB_MASKED = $02;
+ TBSTATE_CHECKED = $01;
+ TBSTATE_PRESSED = $02;
+ TBSTATE_ENABLED = $04;
+ TBSTATE_HIDDEN = $08;
+ TBSTATE_INDETERMINATE = $10;
+ TBSTATE_WRAP = $20;
+{$ifdef ie3plus}
+ TBSTATE_ELLIPSES = $40;
+{$ENDIF}
+{$ifdef ie4plus}
+ TBSTATE_MARKED = $80;
+{$ENDIF}
+
+ TBSTYLE_BUTTON = $0000; // obsolete; use BTNS_BUTTON instead
+ TBSTYLE_SEP = $0001; // obsolete; use BTNS_SEP instead
+ TBSTYLE_CHECK = $0002; // obsolete; use BTNS_CHECK instead
+ TBSTYLE_GROUP = $0004; // obsolete; use BTNS_GROUP instead
+ TBSTYLE_CHECKGROUP = (TBSTYLE_GROUP OR TBSTYLE_CHECK);// obsolete; use BTNS_CHECKGROUP instead
+{$ifdef ie3plus}
+ TBSTYLE_DROPDOWN = $0008; // obsolete; use BTNS_DROPDOWN instead
+{$ENDIF}
+{$ifdef ie4plus}
+ TBSTYLE_AUTOSIZE = $0010; // obsolete; use BTNS_AUTOSIZE instead
+ TBSTYLE_NOPREFIX = $0020; // obsolete; use BTNS_NOPREFIX instead
+{$ENDIF}
+
+ TBSTYLE_TOOLTIPS = $0100;
+ TBSTYLE_WRAPABLE = $0200;
+ TBSTYLE_ALTDRAG = $0400;
+{$ifdef ie3plus}
+ TBSTYLE_FLAT = $0800;
+ TBSTYLE_LIST = $1000;
+ TBSTYLE_CUSTOMERASE = $2000;
+{$ENDIF}
+{$ifdef ie4plus}
+ TBSTYLE_REGISTERDROP = $4000;
+ TBSTYLE_TRANSPARENT = $8000;
+ TBSTYLE_EX_DRAWDDARROWS = $00000001;
+{$ENDIF}
+
+{$ifdef ie5plus}
+ BTNS_BUTTON = TBSTYLE_BUTTON; // 0x0000
+ BTNS_SEP = TBSTYLE_SEP; // 0x0001
+ BTNS_CHECK = TBSTYLE_CHECK; // 0x0002
+ BTNS_GROUP = TBSTYLE_GROUP; // 0x0004
+ BTNS_CHECKGROUP = TBSTYLE_CHECKGROUP; // (TBSTYLE_GROUP | TBSTYLE_CHECK)
+ BTNS_DROPDOWN = TBSTYLE_DROPDOWN; // 0x0008
+ BTNS_AUTOSIZE = TBSTYLE_AUTOSIZE; // 0x0010; automatically calculate the cx of the button
+ BTNS_NOPREFIX = TBSTYLE_NOPREFIX; // 0x0020; this button should not have accel prefix
+{$ifdef ie501plus}
+ BTNS_SHOWTEXT = $0040; // ignored unless TBSTYLE_EX_MIXEDBUTTONS is set
+{$ENDIF} // 0x0501
+ BTNS_WHOLEDROPDOWN = $0080; // draw drop-down arrow, but without split arrow section
+{$ENDIF}
+
+{$ifdef ie501plus}
+ TBSTYLE_EX_MIXEDBUTTONS = $00000008;
+ TBSTYLE_EX_HIDECLIPPEDBUTTONS = $00000010; // don't show partially obscured buttons
+{$ENDIF} // 0x0501
+
+
+{$ifdef win32xp}
+ TBSTYLE_EX_DOUBLEBUFFER = $00000080; // Double Buffer the toolbar
+{$ENDIF}
+
+{$ifdef ie4plus}
+// Custom Draw Structure
+TYPE
+
+ _NMTBCUSTOMDRAW = Record
+ nmcd : NMCUSTOMDRAW;
+ hbrMonoDither : HBRUSH;
+ hbrLines : HBRUSH; // For drawing lines on buttons
+ hpenLines : HPEN; // For drawing lines on buttons
+ clrText : COLORREF; // Color of text
+ clrMark : COLORREF; // Color of text bk when marked. (only if TBSTATE_MARKED)
+ clrTextHighlight : COLORREF; // Color of text when highlighted
+ clrBtnFace : COLORREF; // Background of the button
+ clrBtnHighlight : COLORREF; // 3D highlight
+ clrHighlightHotTrack : COLORREF; // In conjunction with fHighlightHotTrack
+
+ rcText : RECT; // Rect for text
+ nStringBkMode : cint;
+ nHLStringBkMode : cint;
+{$ifdef win32xp}
+ iListGap : cint;
+{$ENDIF}
+ END;
+ NMTBCUSTOMDRAW = _NMTBCUSTOMDRAW;
+ LPNMTBCUSTOMDRAW = ^_NMTBCUSTOMDRAW;
+ TNMTBCUSTOMDRAW = _NMTBCUSTOMDRAW;
+ PNMTBCUSTOMDRAW = ^_NMTBCUSTOMDRAW;
+
+
+// Toolbar custom draw return flags
+
+CONST
+ TBCDRF_NOEDGES = $00010000; // Don't draw button edges
+ TBCDRF_HILITEHOTTRACK = $00020000; // Use color of the button bk when hottracked
+ TBCDRF_NOOFFSET = $00040000; // Don't offset button if pressed
+ TBCDRF_NOMARK = $00080000; // Don't draw default highlight of image/text for TBSTATE_MARKED
+ TBCDRF_NOETCHEDEFFECT = $00100000; // Don't draw etched effect for disabled items
+{$ENDIF}
+
+{$ifdef ie5plus}
+ TBCDRF_BLENDICON = $00200000; // Use ILD_BLEND50 on the icon image
+ TBCDRF_NOBACKGROUND = $00400000; // Use ILD_BLEND50 on the icon image
+{$ENDIF}
+{$ifdef win32vista}
+ TBCDRF_USECDCOLORS = $00800000; // Use CustomDrawColors to RenderText regardless of VisualStyle
+{$endif}
+
+CONST
+ TB_ENABLEBUTTON = (WM_USER + 1);
+ TB_CHECKBUTTON = (WM_USER + 2);
+ TB_PRESSBUTTON = (WM_USER + 3);
+ TB_HIDEBUTTON = (WM_USER + 4);
+ TB_INDETERMINATE = (WM_USER + 5);
+{$ifdef ie4plus}
+ TB_MARKBUTTON = (WM_USER + 6);
+{$ENDIF}
+ TB_ISBUTTONENABLED = (WM_USER + 9);
+ TB_ISBUTTONCHECKED = (WM_USER + 10);
+ TB_ISBUTTONPRESSED = (WM_USER + 11);
+ TB_ISBUTTONHIDDEN = (WM_USER + 12);
+ TB_ISBUTTONINDETERMINATE = (WM_USER + 13);
+{$ifdef ie4plus}
+ TB_ISBUTTONHIGHLIGHTED = (WM_USER + 14);
+{$ENDIF}
+ TB_SETSTATE = (WM_USER + 17);
+ TB_GETSTATE = (WM_USER + 18);
+ TB_ADDBITMAP = (WM_USER + 19);
+
+{$IFDEF _WIN32}
+
+TYPE
+
+ tagTBADDBITMAP = Record
+ hInst : HINST;
+ nID : UINT_PTR;
+ END;
+ TBADDBITMAP = tagTBADDBITMAP;
+ LPTBADDBITMAP = ^tagTBADDBITMAP;
+ TTBADDBITMAP = tagTBADDBITMAP;
+ PTBADDBITMAP = ^tagTBADDBITMAP;
+
+
+
+CONST
+ HINST_COMMCTRL = HINST(-1);
+ IDB_STD_SMALL_COLOR = 0;
+ IDB_STD_LARGE_COLOR = 1;
+ IDB_VIEW_SMALL_COLOR = 4;
+ IDB_VIEW_LARGE_COLOR = 5;
+{$ifdef ie3plus}
+ IDB_HIST_SMALL_COLOR = 8;
+ IDB_HIST_LARGE_COLOR = 9;
+{$ENDIF}
+{$ifdef win32vista}
+ IDB_HIST_NORMAL = 12;
+ IDB_HIST_HOT = 13;
+ IDB_HIST_DISABLED = 14;
+ IDB_HIST_PRESSED = 15;
+{$endif}
+
+// icon indexes for standard bitmap
+
+ STD_CUT = 0;
+ STD_COPY = 1;
+ STD_PASTE = 2;
+ STD_UNDO = 3;
+ STD_REDOW = 4;
+ STD_DELETE = 5;
+ STD_FILENEW = 6;
+ STD_FILEOPEN = 7;
+ STD_FILESAVE = 8;
+ STD_PRINTPRE = 9;
+ STD_PROPERTIES = 10;
+ STD_HELP = 11;
+ STD_FIND = 12;
+ STD_REPLACE = 13;
+ STD_PRINT = 14;
+
+// icon indexes for standard view bitmap
+
+ VIEW_LARGEICONS = 0;
+ VIEW_SMALLICONS = 1;
+ VIEW_LIST = 2;
+ VIEW_DETAILS = 3;
+ VIEW_SORTNAME = 4;
+ VIEW_SORTSIZE = 5;
+ VIEW_SORTDATE = 6;
+ VIEW_SORTTYPE = 7;
+ VIEW_PARENTFOLDER = 8;
+ VIEW_NETCONNECT = 9;
+ VIEW_NETDISCONNECT = 10;
+ VIEW_NEWFOLDER = 11;
+{$ifdef ie4plus}
+ VIEW_VIEWMENU = 12;
+{$ENDIF}
+
+{$ifdef ie3plus}
+ HIST_BACK = 0;
+ HIST_FORWARD = 1;
+ HIST_FAVORITES = 2;
+ HIST_ADDTOFAVORITES = 3;
+ HIST_VIEWTREE = 4;
+{$ENDIF}
+
+{$ENDIF}
+
+{$ifdef ie4plus}
+ TB_ADDBUTTONSA = (WM_USER + 20);
+ TB_INSERTBUTTONA = (WM_USER + 21);
+{$ELSE}
+ TB_ADDBUTTONS = (WM_USER + 20);
+ TB_INSERTBUTTON = (WM_USER + 21);
+{$ENDIF}
+
+ TB_DELETEBUTTON = (WM_USER + 22);
+ TB_GETBUTTON = (WM_USER + 23);
+ TB_BUTTONCOUNT = (WM_USER + 24);
+ TB_COMMANDTOINDEX = (WM_USER + 25);
+
+{$IFDEF _WIN32}
+TYPE
+
+ tagTBSAVEPARAMSA = Record
+ hkr : HKEY;
+ pszSubKey : LPCSTR;
+ pszValueName : LPCSTR;
+ END;
+ TBSAVEPARAMSA = tagTBSAVEPARAMSA;
+ LPTBSAVEPARAMSA = ^tagTBSAVEPARAMSA;
+ TTBSAVEPARAMSA = tagTBSAVEPARAMSA;
+ PTBSAVEPARAMSA = ^tagTBSAVEPARAMSA;
+
+
+ tagTBSAVEPARAMSW = Record
+ hkr : HKEY;
+ pszSubKey : LPCWSTR;
+ pszValueName : LPCWSTR;
+ END;
+ TBSAVEPARAMSW = tagTBSAVEPARAMSW;
+ LPTBSAVEPARAMW = ^tagTBSAVEPARAMSW;
+ TTBSAVEPARAMSW = tagTBSAVEPARAMSW;
+ PTBSAVEPARAMSW = ^tagTBSAVEPARAMSW;
+
+
+{$IFDEF UNICODE}
+ TBSAVEPARAMS = TBSAVEPARAMSW;
+ LPTBSAVEPARAMS = LPTBSAVEPARAMSW;
+{$ELSE}
+ TBSAVEPARAMS = TBSAVEPARAMSA;
+ LPTBSAVEPARAMS = LPTBSAVEPARAMSA;
+{$ENDIF}
+
+{$ENDIF} // _WIN32
+
+
+CONST
+ TB_SAVERESTOREA = (WM_USER + 26);
+ TB_SAVERESTOREW = (WM_USER + 76);
+ TB_CUSTOMIZE = (WM_USER + 27);
+ TB_ADDSTRINGA = (WM_USER + 28);
+ TB_ADDSTRINGW = (WM_USER + 77);
+ TB_GETITEMRECT = (WM_USER + 29);
+ TB_BUTTONSTRUCTSIZE = (WM_USER + 30);
+ TB_SETBUTTONSIZE = (WM_USER + 31);
+ TB_SETBITMAPSIZE = (WM_USER + 32);
+ TB_AUTOSIZE = (WM_USER + 33);
+ TB_GETTOOLTIPS = (WM_USER + 35);
+ TB_SETTOOLTIPS = (WM_USER + 36);
+ TB_SETPARENT = (WM_USER + 37);
+ TB_SETROWS = (WM_USER + 39);
+ TB_GETROWS = (WM_USER + 40);
+ TB_SETCMDID = (WM_USER + 42);
+ TB_CHANGEBITMAP = (WM_USER + 43);
+ TB_GETBITMAP = (WM_USER + 44);
+ TB_GETBUTTONTEXTA = (WM_USER + 45);
+ TB_GETBUTTONTEXTW = (WM_USER + 75);
+ TB_REPLACEBITMAP = (WM_USER + 46);
+{$ifdef ie3plus}
+ TB_SETINDENT = (WM_USER + 47);
+ TB_SETIMAGELIST = (WM_USER + 48);
+ TB_GETIMAGELIST = (WM_USER + 49);
+ TB_LOADIMAGES = (WM_USER + 50);
+ TB_GETRECT = (WM_USER + 51); // wParam is the Cmd instead of index
+ TB_SETHOTIMAGELIST = (WM_USER + 52);
+ TB_GETHOTIMAGELIST = (WM_USER + 53);
+ TB_SETDISABLEDIMAGELIST = (WM_USER + 54);
+ TB_GETDISABLEDIMAGELIST = (WM_USER + 55);
+ TB_SETSTYLE = (WM_USER + 56);
+ TB_GETSTYLE = (WM_USER + 57);
+ TB_GETBUTTONSIZE = (WM_USER + 58);
+ TB_SETBUTTONWIDTH = (WM_USER + 59);
+ TB_SETMAXTEXTROWS = (WM_USER + 60);
+ TB_GETTEXTROWS = (WM_USER + 61);
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+CONST
+{$IFDEF UNICODE}
+
+ TB_SAVERESTORE = TB_SAVERESTOREW;
+ TB_ADDSTRING = TB_ADDSTRINGW;
+{$ELSE}
+ TB_GETBUTTONTEXT = TB_GETBUTTONTEXTA;
+ TB_SAVERESTORE = TB_SAVERESTOREA;
+ TB_ADDSTRING = TB_ADDSTRINGA;
+{$ENDIF}
+{$ifdef ie4plus}
+
+CONST
+ TB_GETOBJECT = (WM_USER + 62); // wParam == IID, lParam void **ppv
+ TB_GETHOTITEM = (WM_USER + 71);
+ TB_SETHOTITEM = (WM_USER + 72); // wParam == iHotItem
+ TB_SETANCHORHIGHLIGHT = (WM_USER + 73); // wParam == TRUE/FALSE
+ TB_GETANCHORHIGHLIGHT = (WM_USER + 74);
+ TB_MAPACCELERATORA = (WM_USER + 78); // wParam == ch, lParam int * pidBtn
+
+TYPE
+ TBINSERTMARK = Record
+ iButton : cint;
+ dwFlags : DWORD;
+ END;
+ LPTBINSERTMARK = ^TBINSERTMARK;
+ TTBINSERTMARK = TBINSERTMARK;
+ PTBINSERTMARK = ^TBINSERTMARK;
+
+
+CONST
+ TBIMHT_AFTER = $00000001; // TRUE = insert After iButton, otherwise before
+ TBIMHT_BACKGROUND = $00000002; // TRUE iff missed buttons completely
+
+ TB_GETINSERTMARK = (WM_USER + 79); // lParam == LPTBINSERTMARK
+ TB_SETINSERTMARK = (WM_USER + 80); // lParam == LPTBINSERTMARK
+ TB_INSERTMARKHITTEST = (WM_USER + 81); // wParam == LPPOINT lParam == LPTBINSERTMARK
+ TB_MOVEBUTTON = (WM_USER + 82);
+ TB_GETMAXSIZE = (WM_USER + 83); // lParam == LPSIZE
+ TB_SETEXTENDEDSTYLE = (WM_USER + 84); // For TBSTYLE_EX_*
+ TB_GETEXTENDEDSTYLE = (WM_USER + 85); // For TBSTYLE_EX_*
+ TB_GETPADDING = (WM_USER + 86);
+ TB_SETPADDING = (WM_USER + 87);
+ TB_SETINSERTMARKCOLOR = (WM_USER + 88);
+ TB_GETINSERTMARKCOLOR = (WM_USER + 89);
+
+ TB_SETCOLORSCHEME = CCM_SETCOLORSCHEME; // lParam is color scheme
+ TB_GETCOLORSCHEME = CCM_GETCOLORSCHEME; // fills in COLORSCHEME pointed to by lParam
+
+ TB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+ TB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+
+ TB_MAPACCELERATORW = (WM_USER + 90); // wParam == ch, lParam int * pidBtn
+
+CONST
+{$IFDEF UNICODE}
+ TB_MAPACCELERATOR = TB_MAPACCELERATORW;
+{$ELSE}
+ TB_MAPACCELERATOR = TB_MAPACCELERATORA;
+{$ENDIF}
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+TYPE
+ TBREPLACEBITMAP = Record
+ hInstOld : HINST;
+ nIDOld : UINT_PTR;
+ hInstNew : HINST;
+ nIDNew : UINT_PTR;
+ nButtons : cint;
+ END;
+ LPTBREPLACEBITMAP = ^TBREPLACEBITMAP;
+ TTBREPLACEBITMAP = TBREPLACEBITMAP;
+ PTBREPLACEBITMAP = ^TBREPLACEBITMAP;
+
+
+{$IFDEF _WIN32}
+
+CONST
+ TBBF_LARGE = $0001;
+ TB_GETBITMAPFLAGS = (WM_USER + 41);
+
+{$ifdef ie4plus}
+ TBIF_IMAGE = $00000001;
+ TBIF_TEXT = $00000002;
+ TBIF_STATE = $00000004;
+ TBIF_STYLE = $00000008;
+ TBIF_LPARAM = $00000010;
+ TBIF_COMMAND = $00000020;
+ TBIF_SIZE = $00000040;
+
+{$ifdef ie5plus}
+ TBIF_BYINDEX = $80000000; // this specifies that the wparam in Get/SetButtonInfo is an index, not id
+{$ENDIF}
+
+TYPE
+
+ TBBUTTONINFOA = Record
+ cbSize : UINT;
+ dwMask : DWORD;
+ idCommand : cint;
+ iImage : cint;
+ fsState : BYTE;
+ fsStyle : BYTE;
+ cx : WORD;
+ lParam : DWORD_PTR;
+ pszText : LPSTR;
+ cchText : cint;
+ END;
+ LPTBBUTTONINFOA = ^TBBUTTONINFOA;
+ TTBBUTTONINFOA = TBBUTTONINFOA;
+ PTBBUTTONINFOA = ^TBBUTTONINFOA;
+
+
+ TBBUTTONINFOW = Record
+ cbSize : UINT;
+ dwMask : DWORD;
+ idCommand : cint;
+ iImage : cint;
+ fsState : BYTE;
+ fsStyle : BYTE;
+ cx : WORD;
+ lParam : DWORD_PTR;
+ pszText : LPWSTR;
+ cchText : cint;
+ END;
+ LPTBBUTTONINFOW = ^TBBUTTONINFOW;
+ TTBBUTTONINFOW= TBBUTTONINFOW;
+ PTBBUTTONINFOW= ^TBBUTTONINFOW;
+
+
+{$IFDEF UNICODE}
+ TBBUTTONINFO = TBBUTTONINFOW;
+ LPTBBUTTONINFO = LPTBBUTTONINFOW;
+{$ELSE}
+ TBBUTTONINFO = TBBUTTONINFOA;
+ LPTBBUTTONINFO = LPTBBUTTONINFOA;
+{$ENDIF}
+ TTBButtonInfo = TBBUTTONINFO;
+ PTBButtonInfo = LPTBBUTTONINFO;
+
+
+// BUTTONINFO APIs do NOT support the string pool.
+
+CONST
+ TB_GETBUTTONINFOW = (WM_USER + 63);
+ TB_SETBUTTONINFOW = (WM_USER + 64);
+ TB_GETBUTTONINFOA = (WM_USER + 65);
+ TB_SETBUTTONINFOA = (WM_USER + 66);
+
+{$IFDEF UNICODE}
+CONST
+ TB_GETBUTTONINFO = TB_GETBUTTONINFOW;
+ TB_SETBUTTONINFO = TB_SETBUTTONINFOW;
+{$ELSE}
+CONST
+ TB_GETBUTTONINFO = TB_GETBUTTONINFOA;
+ TB_SETBUTTONINFO = TB_SETBUTTONINFOA;
+{$ENDIF}
+
+CONST
+ TB_INSERTBUTTONW = (WM_USER + 67);
+ TB_ADDBUTTONSW = (WM_USER + 68);
+
+ TB_HITTEST = (WM_USER + 69);
+
+// New post Win95/NT4 for InsertButton and AddButton. if iString member
+// is a pointer to a string, it will be handled as a string like listview
+// (although LPSTR_TEXTCALLBACK is not supported).
+
+{$IFDEF UNICODE}
+CONST
+ TB_INSERTBUTTON = TB_INSERTBUTTONW;
+ TB_ADDBUTTONS = TB_ADDBUTTONSW;
+{$ELSE}
+CONST
+ TB_INSERTBUTTON = TB_INSERTBUTTONA;
+ TB_ADDBUTTONS = TB_ADDBUTTONSA;
+{$ENDIF}
+
+
+CONST
+ TB_SETDRAWTEXTFLAGS = (WM_USER + 70); // wParam == mask lParam == bit values
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+{$ifdef ie5plus}
+
+ TB_GETSTRINGW = (WM_USER + 91);
+ TB_GETSTRINGA = (WM_USER + 92);
+{$IFDEF UNICODE}
+
+ TB_GETSTRING = TB_GETSTRINGW;
+{$ELSE}
+ TB_GETSTRING = TB_GETSTRINGA;
+{$ENDIF}
+
+
+{$ENDIF} // _WIN32_IE >= 0x0500
+
+{$ifdef win32xp}
+
+CONST
+ TBMF_PAD = $00000001;
+ TBMF_BARPAD = $00000002;
+ TBMF_BUTTONSPACING = $00000004;
+
+TYPE
+
+ TBMETRICS = Record
+ cbSize : UINT;
+ dwMask : DWORD;
+ cxPad : cint; // PAD
+ cyPad : cint;
+ cxBarPad : cint; // BARPAD
+ cyBarPad : cint;
+ cxButtonSpacing : cint; // BUTTONSPACING
+ cyButtonSpacing : cint;
+ END;
+ LPTBMETRICS = ^TBMETRICS;
+ TTBMETRICS = TBMETRICS;
+ PTBMETRICS = ^TBMETRICS;
+
+CONST
+ TB_GETMETRICS = (WM_USER + 101);
+ TB_SETMETRICS = (WM_USER + 102);
+{$ENDIF}
+
+{$ifdef win32vista}
+ TB_SETPRESSEDIMAGELIST = (WM_USER + 104);
+ TB_GETPRESSEDIMAGELIST = (WM_USER + 105);
+{$endif}
+
+{$ifdef win32xp}
+ TB_SETWINDOWTHEME = CCM_SETWINDOWTHEME;
+{$ENDIF}
+
+ TBN_GETBUTTONINFOA = (TBN_FIRST-0);
+ TBN_BEGINDRAG = (TBN_FIRST-1);
+ TBN_ENDDRAG = (TBN_FIRST-2);
+ TBN_BEGINADJUST = (TBN_FIRST-3);
+ TBN_ENDADJUST = (TBN_FIRST-4);
+ TBN_RESET = (TBN_FIRST-5);
+ TBN_QUERYINSERT = (TBN_FIRST-6);
+ TBN_QUERYDELETE = (TBN_FIRST-7);
+ TBN_TOOLBARCHANGE = (TBN_FIRST-8);
+ TBN_CUSTHELP = (TBN_FIRST-9);
+{$ifdef ie3plus}
+ TBN_DROPDOWN = (TBN_FIRST - 10);
+{$ENDIF}
+{$ifdef ie4plus}
+ TBN_GETOBJECT = (TBN_FIRST - 12);
+
+// Structure for TBN_HOTITEMCHANGE notification
+//
+TYPE
+
+ tagNMTBHOTITEM = Record
+ hdr : NMHDR;
+ idOld : cint;
+ idNew : cint;
+ dwFlags : DWORD; // HICF_*
+ END;
+ NMTBHOTITEM = tagNMTBHOTITEM;
+ LPNMTBHOTITEM = ^tagNMTBHOTITEM;
+ TNMTBHOTITEM = tagNMTBHOTITEM;
+ PNMTBHOTITEM = ^tagNMTBHOTITEM;
+
+
+// Hot item change flags
+
+CONST
+ HICF_OTHER = $00000000;
+ HICF_MOUSE = $00000001; // Triggered by mouse
+ HICF_ARROWKEYS = $00000002; // Triggered by arrow keys
+ HICF_ACCELERATOR = $00000004; // Triggered by accelerator
+ HICF_DUPACCEL = $00000008; // This accelerator is not unique
+ HICF_ENTERING = $00000010; // idOld is invalid
+ HICF_LEAVING = $00000020; // idNew is invalid
+ HICF_RESELECT = $00000040; // hot item reselected
+ HICF_LMOUSE = $00000080; // left mouse button selected
+ HICF_TOGGLEDROPDOWN = $00000100; // Toggle button's dropdown state
+
+
+ TBN_HOTITEMCHANGE = (TBN_FIRST - 13);
+ TBN_DRAGOUT = (TBN_FIRST - 14); // this is sent when the user clicks down on a button then drags off the button
+ TBN_DELETINGBUTTON = (TBN_FIRST - 15); // uses TBNOTIFY
+ TBN_GETDISPINFOA = (TBN_FIRST - 16); // This is sent when the toolbar needs some display information
+ TBN_GETDISPINFOW = (TBN_FIRST - 17); // This is sent when the toolbar needs some display information
+ TBN_GETINFOTIPA = (TBN_FIRST - 18);
+ TBN_GETINFOTIPW = (TBN_FIRST - 19);
+ TBN_GETBUTTONINFOW = (TBN_FIRST - 20);
+{$ifdef ie5plus}
+ TBN_RESTORE = (TBN_FIRST - 21);
+ TBN_SAVE = (TBN_FIRST - 22);
+ TBN_INITCUSTOMIZE = (TBN_FIRST - 23);
+ TBNRF_HIDEHELP = $00000001;
+ TBNRF_ENDCUSTOMIZE = $00000002;
+{$ENDIF} // (_WIN32_IE >= 0x0500)
+
+
+
+{$ifdef ie5plus}
+
+TYPE
+
+ tagNMTBSAVE = Record
+ hdr : NMHDR;
+ pData : PDWORD;
+ pCurrent : PDWORD;
+ cbData : UINT;
+ iItem : cint;
+ cButtons : cint;
+ tbButton : TBBUTTON;
+ END;
+ NMTBSAVE = tagNMTBSAVE;
+ LPNMTBSAVE = ^tagNMTBSAVE;
+ TNMTBSAVE = tagNMTBSAVE;
+ PNMTBSAVE = ^tagNMTBSAVE;
+
+
+ tagNMTBRESTORE = Record
+ hdr : NMHDR;
+ pData : PDWORD;
+ pCurrent : PDWORD;
+ cbData : UINT;
+ iItem : cint;
+ cButtons : cint;
+ cbBytesPerRecord : cint;
+ tbButton : TBBUTTON;
+ END;
+ NMTBRESTORE = tagNMTBRESTORE;
+ LPNMTBRESTORE = ^tagNMTBRESTORE;
+ TNMTBRESTORE = tagNMTBRESTORE;
+ PNMTBRESTORE = ^tagNMTBRESTORE;
+
+{$ENDIF} // (_WIN32_IE >= 0x0500)
+
+ tagNMTBGETINFOTIPA = Record
+ hdr : NMHDR;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iItem : cint;
+ lParam : LPARAM;
+ END;
+ NMTBGETINFOTIPA = tagNMTBGETINFOTIPA;
+ LPNMTBGETINFOTIPA = ^tagNMTBGETINFOTIPA;
+ TNMTBGETINFOTIPA = tagNMTBGETINFOTIPA;
+ PNMTBGETINFOTIPA = ^tagNMTBGETINFOTIPA;
+
+
+ tagNMTBGETINFOTIPW = Record
+ hdr : NMHDR;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iItem : cint;
+ lParam : LPARAM;
+ END;
+ NMTBGETINFOTIPW = tagNMTBGETINFOTIPW;
+ LPNMTBGETINFOTIPW = ^tagNMTBGETINFOTIPW;
+ TNMTBGETINFOTIPW = tagNMTBGETINFOTIPW;
+ PNMTBGETINFOTIPW = ^tagNMTBGETINFOTIPW;
+
+
+{$IFDEF UNICODE}
+CONST
+ TBN_GETINFOTIP = TBN_GETINFOTIPW;
+TYPE
+ NMTBGETINFOTIP = NMTBGETINFOTIPW;
+ LPNMTBGETINFOTIP = LPNMTBGETINFOTIPW;
+{$ELSE}
+CONST
+ TBN_GETINFOTIP = TBN_GETINFOTIPA;
+TYPE
+ NMTBGETINFOTIP = NMTBGETINFOTIPA;
+ LPNMTBGETINFOTIP = LPNMTBGETINFOTIPA;
+{$ENDIF}
+
+
+CONST
+ TBNF_IMAGE = $00000001;
+ TBNF_TEXT = $00000002;
+ TBNF_DI_SETITEM = $10000000;
+
+TYPE
+
+ NMTBDISPINFOA = Record
+ hdr : NMHDR;
+ dwMask : DWORD; // [in] Specifies the values requested .[out] Client ask the data to be set for future use
+ idCommand : cint; // [in] id of button we're requesting info for
+ lParam : DWORD_PTR; // [in] lParam of button
+ iImage : cint; // [out] image index
+ pszText : LPSTR; // [out] new text for item
+ cchText : cint; // [in] size of buffer pointed to by pszText
+ END;
+ LPNMTBDISPINFOA = ^NMTBDISPINFOA;
+ TNMTBDISPINFOA = NMTBDISPINFOA;
+ PNMTBDISPINFOA = ^NMTBDISPINFOA;
+
+
+ NMTBDISPINFOW = Record
+ hdr : NMHDR;
+ dwMask : DWORD; //[in] Specifies the values requested .[out] Client ask the data to be set for future use
+ idCommand : cint; // [in] id of button we're requesting info for
+ lParam : DWORD_PTR; // [in] lParam of button
+ iImage : cint; // [out] image index
+ pszText : LPWSTR; // [out] new text for item
+ cchText : cint; // [in] size of buffer pointed to by pszText
+ END;
+ LPNMTBDISPINFOW = ^NMTBDISPINFOW;
+ TNMTBDISPINFOW = NMTBDISPINFOW;
+ PNMTBDISPINFOW = ^NMTBDISPINFOW;
+
+{$IFDEF UNICODE}
+CONST
+ TBN_GETDISPINFO = TBN_GETDISPINFOW;
+TYPE
+ NMTBDISPINFO = NMTBDISPINFOW;
+ LPNMTBDISPINFO = LPNMTBDISPINFOW;
+{$ELSE}
+CONST
+ TBN_GETDISPINFO = TBN_GETDISPINFOA;
+TYPE
+ NMTBDISPINFO = NMTBDISPINFOA;
+ LPNMTBDISPINFO = LPNMTBDISPINFOA;
+{$ENDIF}
+
+// Return codes for TBN_DROPDOWN
+
+CONST
+ TBDDRET_DEFAULT = 0;
+ TBDDRET_NODEFAULT = 1;
+ TBDDRET_TREATPRESSED = 2; // Treat as a standard press button
+
+{$ENDIF}
+{$IFDEF UNICODE}
+ TBN_GETBUTTONINFO = TBN_GETBUTTONINFOW;
+{$ELSE}
+ TBN_GETBUTTONINFO = TBN_GETBUTTONINFOA;
+{$ENDIF}
+TYPE
+
+{$ifdef ie3plus}
+ tagNMTOOLBARA = Record
+ hdr : NMHDR;
+ iItem : cint;
+ tbButton : TBBUTTON;
+ cchText : cint;
+ pszText : LPSTR;
+{$ifdef ie5plus}
+ rcButton : RECT;
+{$ENDIF}
+ END;
+ NMTOOLBARA = tagNMTOOLBARA;
+ LPNMTOOLBARA = ^tagNMTOOLBARA;
+ LPNMTOOLBAR = LPNMTOOLBARA;
+ TNMTOOLBARA = tagNMTOOLBARA;
+ PNMTOOLBARA = LPNMTOOLBARA;
+{$ENDIF}
+ LPTBNOTIFY = LPNMTOOLBARA;
+ TBNOTIFYA = NMTOOLBARA;
+
+
+{$ifdef ie3plus}
+ tagNMTOOLBARW = Record
+ hdr : NMHDR;
+ iItem : cint;
+ tbButton : TBBUTTON;
+ cchText : cint;
+ pszText : LPWSTR;
+{$ifdef ie5plus}
+ rcButton : RECT;
+{$ENDIF}
+ END;
+ NMTOOLBARW = tagNMTOOLBARW;
+ LPNMTOOLBARW = ^tagNMTOOLBARW;
+ TNMTOOLBARW = tagNMTOOLBARW;
+ PNMTOOLBARW = ^tagNMTOOLBARW;
+{$ENDIF}
+
+
+{$ifdef ie3plus}
+ TBNOTIFYW = NMTOOLBARW;
+ LPTBNOTIFYA = LPNMTOOLBARA;
+{$ELSE}
+ tagNMTOOLBARA = tagTBNOTIFYA;
+ NMTOOLBARA = TBNOTIFYA;
+ LPNMTOOLBARA = LPTBNOTIFYA;
+ tagNMTOOLBARW = tagTBNOTIFYW;
+ NMTOOLBARW = TBNOTIFYW;
+ LPNMTOOLBARW = LPTBNOTIFYW;
+{$ENDIF}
+
+
+{$IFDEF UNICODE}
+ NMTOOLBAR = NMTOOLBARW;
+ LPNMTOOLBAR = LPNMTOOLBARW;
+{$ELSE}
+ NMTOOLBAR = NMTOOLBARA;
+ TNMTOOLBAR = NMTOOLBARA;
+ PNMTOOLBAR = LPNMTOOLBARA;
+
+{$ENDIF}
+
+ TBNOTIFY = NMTOOLBAR;
+{$ENDIF}
+
+{$ENDIF} // NOTOOLBAR
+
+ LPTBNOTIFYW = LPNMTOOLBARW;
+
+{$ifdef ie3plus}
+//====== REBAR CONTROL ========================================================
+
+{$IFNDEF NOREBAR}
+
+{$IFDEF _WIN32}
+
+CONST
+ REBARCLASSNAMEW = {L}'ReBarWindow32';
+ REBARCLASSNAMEA = 'ReBarWindow32';
+
+{$IFDEF UNICODE}
+ REBARCLASSNAME = REBARCLASSNAMEW;
+{$ELSE}
+ REBARCLASSNAME = REBARCLASSNAMEA;
+{$ENDIF}
+
+{$ELSE}
+
+CONST
+ REBARCLASSNAME = 'ReBarWindow';
+{$ENDIF}
+
+CONST
+ RBIM_IMAGELIST = $00000001;
+
+// begin_r_commctrl
+
+{$ifdef ie4plus}
+ RBS_TOOLTIPS = $0100;
+ RBS_VARHEIGHT = $0200;
+ RBS_BANDBORDERS = $0400;
+ RBS_FIXEDORDER = $0800;
+ RBS_REGISTERDROP = $1000;
+ RBS_AUTOSIZE = $2000;
+ RBS_VERTICALGRIPPER = $4000; // this always has the vertical gripper (default for horizontal mode)
+ RBS_DBLCLKTOGGLE = $8000;
+{$ELSE}
+ RBS_TOOLTIPS = $00000100;
+ RBS_VARHEIGHT = $00000200;
+ RBS_BANDBORDERS = $00000400;
+ RBS_FIXEDORDER = $00000800;
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+
+// end_r_commctrl
+
+TYPE
+
+ tagREBARINFO = Record
+ cbSize : UINT;
+ fMask : UINT;
+{$IFNDEF NOIMAGEAPIS}
+ himl : HIMAGELIST;
+{$ELSE}
+ himl : HANDLE;
+{$ENDIF}
+ END;
+ REBARINFO = tagREBARINFO;
+ LPREBARINFO = ^tagREBARINFO;
+ TREBARINFO = tagREBARINFO;
+ PREBARINFO = ^tagREBARINFO;
+
+
+CONST
+ RBBS_BREAK = $00000001; // break to new line
+ RBBS_FIXEDSIZE = $00000002; // band can't be sized
+ RBBS_CHILDEDGE = $00000004; // edge around top & bottom of child window
+ RBBS_HIDDEN = $00000008; // don't show
+ RBBS_NOVERT = $00000010; // don't show when vertical
+ RBBS_FIXEDBMP = $00000020; // bitmap doesn't move during band resize
+{$ifdef ie4plus }
+ RBBS_VARIABLEHEIGHT = $00000040; // allow autosizing of this child vertically
+ RBBS_GRIPPERALWAYS = $00000080; // always show the gripper
+ RBBS_NOGRIPPER = $00000100; // never show the gripper
+{$ifdef ie5plus}
+ RBBS_USECHEVRON = $00000200; // display drop-down button for this band if it's sized smaller than ideal width
+{$ifdef IE501plus}
+ RBBS_HIDETITLE = $00000400; // keep band title hidden
+ RBBS_TOPALIGN = $00000800; // keep band title hidden
+{$ENDIF} // 0x0501 //
+{$ENDIF} // 0x0500 //
+{$ENDIF} // 0x0400 //
+
+ RBBIM_STYLE = $00000001;
+ RBBIM_COLORS = $00000002;
+ RBBIM_TEXT = $00000004;
+ RBBIM_IMAGE = $00000008;
+ RBBIM_CHILD = $00000010;
+ RBBIM_CHILDSIZE = $00000020;
+ RBBIM_SIZE = $00000040;
+ RBBIM_BACKGROUND = $00000080;
+ RBBIM_ID = $00000100;
+{$ifdef ie4plus}
+ RBBIM_IDEALSIZE = $00000200;
+ RBBIM_LPARAM = $00000400;
+ RBBIM_HEADERSIZE = $00000800; // control the size of the header
+{$ENDIF}
+{$ifdef win32vista}
+ RBBIM_CHEVRONLOCATION = $00001000;
+ RBBIM_CHEVRONSTATE = $00002000;
+{$endif}
+
+TYPE
+
+ tagREBARBANDINFOA = Record
+ cbSize : UINT;
+ fMask : UINT;
+ fStyle : UINT;
+ clrFore : COLORREF;
+ clrBack : COLORREF;
+ lpText : LPSTR;
+ cch : UINT;
+ iImage : cint;
+ hwndChild : HWND;
+ cxMinChild : UINT;
+ cyMinChild : UINT;
+ cx : UINT;
+ hbmBack : HBITMAP;
+ wID : UINT;
+{$ifdef ie4plus}
+ cyChild : UINT;
+ cyMaxChild : UINT;
+ cyIntegral : UINT;
+ cxIdeal : UINT;
+ lParam : LPARAM;
+ cxHeader : UINT;
+{$ENDIF}
+{$ifdef win32vista}
+ rcChevronLocation : RECT; // the rect is in client co-ord wrt hwndChild
+ uChevronState : cUINT; // STATE_SYSTEM_*
+{$endif}
+ END;
+ REBARBANDINFOA = tagREBARBANDINFOA;
+ LPREBARBANDINFOA = ^tagREBARBANDINFOA;
+ TREBARBANDINFOA = tagREBARBANDINFOA;
+ PREBARBANDINFOA = ^tagREBARBANDINFOA;
+
+ LPCREBARBANDINFOA = ^REBARBANDINFOA;
+
+// #define REBARBANDINFOA_V3_SIZE CCSIZEOF_STRUCT(REBARBANDINFOA, wID)
+// #define REBARBANDINFOW_V3_SIZE CCSIZEOF_STRUCT(REBARBANDINFOW, wID)
+
+ tagREBARBANDINFOW = Record
+ cbSize : UINT;
+ fMask : UINT;
+ fStyle : UINT;
+ clrFore : COLORREF;
+ clrBack : COLORREF;
+ lpText : LPWSTR;
+ cch : UINT;
+ iImage : cint;
+ hwndChild : HWND;
+ cxMinChild : UINT;
+ cyMinChild : UINT;
+ cx : UINT;
+ hbmBack : HBITMAP;
+ wID : UINT;
+{$ifdef ie4plus}
+ cyChild : UINT;
+ cyMaxChild : UINT;
+ cyIntegral : UINT;
+ cxIdeal : UINT;
+ lParam : LPARAM;
+ cxHeader : UINT;
+{$ENDIF}
+{$ifdef win32vista}
+ rcChevronLocation : RECT; // the rect is in client co-ord wrt hwndChild
+ uChevronState : cUINT; // STATE_SYSTEM_*
+{$endif}
+
+ END;
+ REBARBANDINFOW = tagREBARBANDINFOW;
+ LPREBARBANDINFOW = ^tagREBARBANDINFOW;
+ TREBARBANDINFOW = tagREBARBANDINFOW;
+ PREBARBANDINFOW = ^tagREBARBANDINFOW;
+
+ LPCREBARBANDINFOW = {const} ^REBARBANDINFOW;
+
+{$IFDEF UNICODE}
+ REBARBANDINFO = REBARBANDINFOW;
+ LPREBARBANDINFO = LPREBARBANDINFOW;
+ LPCREBARBANDINFO = LPCREBARBANDINFOW;
+
+// REBARBANDINFO_V3_SIZE = REBARBANDINFOW_V3_SIZE;
+{$ELSE}
+
+ REBARBANDINFO = REBARBANDINFOA;
+ LPREBARBANDINFO = LPREBARBANDINFOA;
+ LPCREBARBANDINFO = LPCREBARBANDINFOA;
+
+ TRebarBandInfo = REBARBANDINFO;
+ PRebarBandInfo = ^LPREBARBANDINFO;
+
+// REBARBANDINFO_V3_SIZE = REBARBANDINFOA_V3_SIZE;
+{$ENDIF}
+
+CONST
+ RB_INSERTBANDA = (WM_USER + 1);
+ RB_DELETEBAND = (WM_USER + 2);
+ RB_GETBARINFO = (WM_USER + 3);
+ RB_SETBARINFO = (WM_USER + 4);
+{$ifdef IE4plus}
+ RB_GETBANDINFO = (WM_USER + 5);
+ RB_GETBANDINFO_PRE_IE4 = (WM_USER + 5);
+{$ENDIF}
+ RB_SETBANDINFOA = (WM_USER + 6);
+ RB_SETPARENT = (WM_USER + 7);
+{$ifdef ie4plus}
+ RB_HITTEST = (WM_USER + 8);
+ RB_GETRECT = (WM_USER + 9);
+{$ENDIF}
+ RB_INSERTBANDW = (WM_USER + 10);
+ RB_SETBANDINFOW = (WM_USER + 11);
+ RB_GETBANDCOUNT = (WM_USER + 12);
+ RB_GETROWCOUNT = (WM_USER + 13);
+ RB_GETROWHEIGHT = (WM_USER + 14);
+{$ifdef ie4plus}
+ RB_IDTOINDEX = (WM_USER + 16); // wParam == id
+ RB_GETTOOLTIPS = (WM_USER + 17);
+ RB_SETTOOLTIPS = (WM_USER + 18);
+ RB_SETBKCOLOR = (WM_USER + 19); // sets the default BK color
+ RB_GETBKCOLOR = (WM_USER + 20); // defaults to CLR_NONE
+ RB_SETTEXTCOLOR = (WM_USER + 21);
+ RB_GETTEXTCOLOR = (WM_USER + 22); // defaults to 0x00000000
+
+{$ifdef Win32XP}
+ RBSTR_CHANGERECT = $0001; // flags for RB_SIZETORECT
+{$ENDIF}
+
+ RB_SIZETORECT = (WM_USER + 23); // resize the rebar/break bands and such to this rect (lparam)
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+ RB_SETCOLORSCHEME = CCM_SETCOLORSCHEME; // lParam is color scheme
+ RB_GETCOLORSCHEME = CCM_GETCOLORSCHEME; // fills in COLORSCHEME pointed to by lParam
+
+{$IFDEF UNICODE}
+ RB_INSERTBAND = RB_INSERTBANDW;
+ RB_SETBANDINFO = RB_SETBANDINFOW;
+{$ELSE}
+ RB_INSERTBAND = RB_INSERTBANDA;
+ RB_SETBANDINFO = RB_SETBANDINFOA;
+{$ENDIF}
+
+{$ifdef ie4plus}
+// for manual drag control
+// lparam == cursor pos
+ // -1 means do it yourself.
+ // -2 means use what you had saved before
+
+CONST
+ RB_BEGINDRAG = (WM_USER + 24);
+ RB_ENDDRAG = (WM_USER + 25);
+ RB_DRAGMOVE = (WM_USER + 26);
+ RB_GETBARHEIGHT = (WM_USER + 27);
+ RB_GETBANDINFOW = (WM_USER + 28);
+ RB_GETBANDINFOA = (WM_USER + 29);
+
+//TYPE
+{$IFDEF UNICODE}
+// RB_GETBANDINFO = RB_GETBANDINFOW;
+{$ELSE}
+// RB_GETBANDINFO = RB_GETBANDINFOA;
+{$ENDIF}
+
+CONST
+ RB_MINIMIZEBAND = (WM_USER + 30);
+ RB_MAXIMIZEBAND = (WM_USER + 31);
+
+ RB_GETDROPTARGET = (CCM_GETDROPTARGET);
+
+ RB_GETBANDBORDERS = (WM_USER + 34); // returns in lparam = lprc the amount of edges added to band wparam
+
+ RB_SHOWBAND = (WM_USER + 35); // show/hide band
+ RB_SETPALETTE = (WM_USER + 37);
+ RB_GETPALETTE = (WM_USER + 38);
+ RB_MOVEBAND = (WM_USER + 39);
+
+ RB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+ RB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+{$ifdef win32xp}
+ RB_GETBANDMARGINS = (WM_USER + 40);
+ RB_SETWINDOWTHEME = CCM_SETWINDOWTHEME;
+{$ENDIF}
+{$ifdef win32vista}
+ RB_SETEXTENDEDSTYLE = (WM_USER + 41);
+ RB_GETEXTENDEDSTYLE = (WM_USER + 42);
+{$endif}
+
+{$ifdef ie5plus}
+ RB_PUSHCHEVRON = (WM_USER + 43);
+{$ENDIF} // _WIN32_IE >= 0x0500
+
+{$ifdef win32vista}
+ RB_SETBANDWIDTH = (WM_USER + 44); // set width for docked band
+{$endif}
+
+ RBN_HEIGHTCHANGE = (RBN_FIRST - 0);
+
+{$ifdef ie4plus}
+ RBN_GETOBJECT = (RBN_FIRST - 1);
+ RBN_LAYOUTCHANGED = (RBN_FIRST - 2);
+ RBN_AUTOSIZE = (RBN_FIRST - 3);
+ RBN_BEGINDRAG = (RBN_FIRST - 4);
+ RBN_ENDDRAG = (RBN_FIRST - 5);
+ RBN_DELETINGBAND = (RBN_FIRST - 6); // Uses NMREBAR
+ RBN_DELETEDBAND = (RBN_FIRST - 7); // Uses NMREBAR
+ RBN_CHILDSIZE = (RBN_FIRST - 8);
+
+{$ifdef ie5plus}
+ RBN_CHEVRONPUSHED = (RBN_FIRST - 10);
+{$ENDIF} // _WIN32_IE >= 0x0500
+{$ifdef win32vista}
+ RBN_SPLITTERDRAG = (RBN_FIRST - 11);
+{$endif}
+
+{$ifdef ie5plus}
+ RBN_MINMAX = (RBN_FIRST - 21);
+{$ENDIF}
+
+{$ifdef Win32XP}
+ RBN_AUTOBREAK = (RBN_FIRST - 22);
+{$ENDIF}
+
+TYPE
+
+ tagNMREBARCHILDSIZE = Record
+ hdr : NMHDR;
+ uBand : UINT;
+ wID : UINT;
+ rcChild : RECT;
+ rcBand : RECT;
+ END;
+ NMREBARCHILDSIZE = tagNMREBARCHILDSIZE;
+ LPNMREBARCHILDSIZE = ^tagNMREBARCHILDSIZE;
+ TNMREBARCHILDSIZE = tagNMREBARCHILDSIZE;
+ PNMREBARCHILDSIZE = ^tagNMREBARCHILDSIZE;
+
+
+ tagNMREBAR = Record
+ hdr : NMHDR;
+ dwMask : DWORD; // RBNM_*
+ uBand : UINT;
+ fStyle : UINT;
+ wID : UINT;
+ lParam : LPARAM;
+ END;
+ NMREBAR = tagNMREBAR;
+ LPNMREBAR = ^tagNMREBAR;
+ TNMREBAR = tagNMREBAR;
+ PNMREBAR = ^tagNMREBAR;
+
+// Mask flags for NMREBAR
+
+CONST
+ RBNM_ID = $00000001;
+ RBNM_STYLE = $00000002;
+ RBNM_LPARAM = $00000004;
+
+TYPE
+
+ tagNMRBAUTOSIZE = Record
+ hdr : NMHDR;
+ fChanged : BOOL;
+ rcTarget : RECT;
+ rcActual : RECT;
+ END;
+ NMRBAUTOSIZE = tagNMRBAUTOSIZE;
+ LPNMRBAUTOSIZE = ^tagNMRBAUTOSIZE;
+ TNMRBAUTOSIZE = tagNMRBAUTOSIZE;
+ PNMRBAUTOSIZE = ^tagNMRBAUTOSIZE;
+
+
+{$ifdef ie5plus}
+ tagNMREBARCHEVRON = Record
+ hdr : NMHDR;
+ uBand : UINT;
+ wID : UINT;
+ lParam : LPARAM;
+ rc : RECT;
+ lParamNM : LPARAM;
+ END;
+ NMREBARCHEVRON = tagNMREBARCHEVRON;
+ LPNMREBARCHEVRON = ^tagNMREBARCHEVRON;
+ TNMREBARCHEVRON = tagNMREBARCHEVRON;
+ PNMREBARCHEVRON = ^tagNMREBARCHEVRON;
+
+{$ENDIF}
+{$ifdef win32vista}
+ tagNMREBARSPLITTER = record
+ hdr: NMHDR;
+ rcSizing: RECT;
+ end;
+ NMREBARSPLITTER = tagNMREBARSPLITTER;
+ LPNMREBARSPLITTER = ^tagNMREBARSPLITTER;
+ TNMREBARSPLITTER = tagNMREBARSPLITTER;
+ PNMREBARSPLITTER = LPNMREBARSPLITTER;
+{$endif}
+
+{$ifdef Win32XP}
+CONST
+ RBAB_AUTOSIZE = $0001; // These are not flags and are all mutually exclusive
+ RBAB_ADDBAND = $0002;
+
+TYPE
+
+ tagNMREBARAUTOBREAK = Record
+ hdr : NMHDR;
+ uBand : UINT;
+ wID : UINT;
+ lParam : LPARAM;
+ uMsg : UINT;
+ fStyleCurrent : UINT;
+ fAutoBreak : BOOL;
+ END;
+ NMREBARAUTOBREAK = tagNMREBARAUTOBREAK;
+ LPNMREBARAUTOBREAK = ^tagNMREBARAUTOBREAK;
+ TNMREBARAUTOBREAK = tagNMREBARAUTOBREAK;
+ PNMREBARAUTOBREAK = ^tagNMREBARAUTOBREAK;
+
+{$ENDIF}
+
+CONST
+ RBHT_NOWHERE = $0001;
+ RBHT_CAPTION = $0002;
+ RBHT_CLIENT = $0003;
+ RBHT_GRABBER = $0004;
+{$ifdef ie5plus}
+ RBHT_CHEVRON = $0008;
+{$ENDIF}
+{$ifdef win32vista}
+ RBHT_SPLITTER = $0010;
+{$endif}
+
+TYPE
+ _RB_HITTESTINFO = Record
+ pt : POINT;
+ flags : UINT;
+ iBand : cint;
+ END;
+ RBHITTESTINFO = _RB_HITTESTINFO;
+ LPRBHITTESTINFO = ^_RB_HITTESTINFO;
+ TRB_HITTESTINFO = _RB_HITTESTINFO;
+ PRB_HITTESTINFO = ^_RB_HITTESTINFO;
+ PRBHitTestInfo = PRB_HITTESTINFO;
+ TRBHitTestInfo = TRB_HITTESTINFO;
+
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+{$ENDIF} // NOREBAR
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+//====== TOOLTIPS CONTROL =====================================================
+
+{$IFNDEF NOTOOLTIPS}
+
+{$IFDEF _WIN32}
+
+CONST
+ TOOLTIPS_CLASSW = {L}'tooltips_class32';
+ TOOLTIPS_CLASSA = 'tooltips_class32';
+
+{$IFDEF UNICODE}
+ TOOLTIPS_CLASS = TOOLTIPS_CLASSW;
+{$ELSE}
+ TOOLTIPS_CLASS = TOOLTIPS_CLASSA;
+{$ENDIF}
+
+{$ELSE}
+
+CONST
+ TOOLTIPS_CLASS = 'tooltips_class';
+{$ENDIF}
+
+
+
+TYPE
+
+ tagTOOLINFOA = Record
+ cbSize : UINT;
+ uFlags : UINT;
+ hwnd : HWND;
+ uId : UINT_PTR;
+ rect : RECT;
+ hinst : HINST;
+ lpszText : LPSTR;
+{$ifdef ie3plus}
+ lParam : LPARAM;
+{$ENDIF}
+{$ifdef Win32XP}
+ lpReserved : Pointer;
+{$ENDIF}
+ END;
+ TTTOOLINFOA = tagTOOLINFOA;
+ PTOOLINFOA = {near} ^tagTOOLINFOA;
+ LPTTTOOLINFOA = ^tagTOOLINFOA;
+ TTOOLINFOA = tagTOOLINFOA;
+ LPTOOLINFOA = ^tagTOOLINFOA;
+
+
+ tagTOOLINFOW = Record
+ cbSize : UINT;
+ uFlags : UINT;
+ hwnd : HWND;
+ uId : UINT_PTR;
+ rect : RECT;
+ hinst : HINST;
+ lpszText : LPWSTR;
+{$ifdef ie3plus}
+ lParam : LPARAM;
+{$ENDIF}
+{$ifdef Win32XP}
+ lpReserved : Pointer;
+{$ENDIF}
+ END;
+ TTTOOLINFOW = tagTOOLINFOW;
+ PTOOLINFOW = {near} ^tagTOOLINFOW;
+ LPTTTOOLINFOW = ^tagTOOLINFOW;
+ TTOOLINFOW = tagTOOLINFOW;
+ LPTOOLINFOW = ^tagTOOLINFOW;
+
+
+{$IFDEF UNICODE}
+ TTTOOLINFO = TTTOOLINFOW;
+ PTOOLINFO = PTOOLINFOW;
+ LPTTTOOLINFO = LPTTTOOLINFOW;
+// TTTOOLINFO_V1_SIZE = TTTOOLINFOW_V1_SIZE;
+{$ELSE}
+ PTOOLINFO = PTOOLINFOA;
+ TTTOOLINFO = TTTOOLINFOA;
+ LPTTTOOLINFO = LPTTTOOLINFOA;
+// TTTOOLINFO_V1_SIZE = TTTOOLINFOA_V1_SIZE;
+{$ENDIF}
+
+
+TYPE
+
+{$ifdef ie3plus}
+// LPTOOLINFOA = LPTTTOOLINFOA;
+// LPTOOLINFOW = LPTTTOOLINFOW;
+ TOOLINFOA = TTTOOLINFOA;
+ TOOLINFOW = TTTOOLINFOW;
+{$ELSE}
+// TTTOOLINFOA = TOOLINFOA;
+// LPTTTOOLINFOA = LPTOOLINFOA;
+// TTTOOLINFOW = TOOLINFOW;
+// LPTTTOOLINFOW = LPTOOLINFOW;
+{$ENDIF}
+
+
+
+ LPTOOLINFO = LPTTTOOLINFO;
+
+ TOOLINFO = TTTOOLINFO;
+
+// #define TTTOOLINFOA_V1_SIZE CCSIZEOF_STRUCT(TTTOOLINFOA, lpszText)
+// #define TTTOOLINFOW_V1_SIZE CCSIZEOF_STRUCT(TTTOOLINFOW, lpszText)
+// #define TTTOOLINFOA_V2_SIZE CCSIZEOF_STRUCT(TTTOOLINFOA, lParam)
+// #define TTTOOLINFOW_V2_SIZE CCSIZEOF_STRUCT(TTTOOLINFOW, lParam)
+// #define TTTOOLINFOA_V3_SIZE CCSIZEOF_STRUCT(TTTOOLINFOA, lpReserved)
+// #define TTTOOLINFOW_V3_SIZE CCSIZEOF_STRUCT(TTTOOLINFOW, lpReserved)
+
+
+CONST
+// begin_r_commctrl
+
+ TTS_ALWAYSTIP = $01;
+ TTS_NOPREFIX = $02;
+{$ifdef ie5plus}
+ TTS_NOANIMATE = $10;
+ TTS_NOFADE = $20;
+ TTS_BALLOON = $40;
+ TTS_CLOSE = $80;
+{$ENDIF}
+{$ifdef win32vista}
+ TTS_USEVISUALSTYLE = $100; // Use themed hyperlinks
+{$endif}
+
+// end_r_commctrl
+
+ TTF_IDISHWND = $0001;
+
+// Use this to center around trackpoint in trackmode
+// -OR- to center around tool in normal mode.
+// Use TTF_ABSOLUTE to place the tip exactly at the track coords when
+// in tracking mode. TTF_ABSOLUTE can be used in conjunction with TTF_CENTERTIP
+// to center the tip absolutely about the track point.
+
+ TTF_CENTERTIP = $0002;
+ TTF_RTLREADING = $0004;
+ TTF_SUBCLASS = $0010;
+{$ifdef ie3plus}
+ TTF_TRACK = $0020;
+ TTF_ABSOLUTE = $0080;
+ TTF_TRANSPARENT = $0100;
+{$ifdef ie501plus}
+ TTF_PARSELINKS = $1000;
+{$ENDIF} // _WIN32_IE >= 0x0501
+ TTF_DI_SETITEM = $8000; // valid only on the TTN_NEEDTEXT callback
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+
+ TTDT_AUTOMATIC = 0;
+ TTDT_RESHOW = 1;
+ TTDT_AUTOPOP = 2;
+ TTDT_INITIAL = 3;
+
+// ToolTip Icons (Set with TTM_SETTITLE)
+ TTI_NONE = 0;
+ TTI_INFO = 1;
+ TTI_WARNING = 2;
+ TTI_ERROR = 3;
+{$ifdef win32vista}
+ TTI_INFO_LARGE = 4;
+ TTI_WARNING_LARGE = 5;
+ TTI_ERROR_LARGE = 6;
+{$endif}
+
+// Tool Tip Messages
+ TTM_ACTIVATE = (WM_USER + 1);
+ TTM_SETDELAYTIME = (WM_USER + 3);
+ TTM_ADDTOOLA = (WM_USER + 4);
+ TTM_ADDTOOLW = (WM_USER + 50);
+ TTM_DELTOOLA = (WM_USER + 5);
+ TTM_DELTOOLW = (WM_USER + 51);
+ TTM_NEWTOOLRECTA = (WM_USER + 6);
+ TTM_NEWTOOLRECTW = (WM_USER + 52);
+ TTM_RELAYEVENT = (WM_USER + 7);
+
+ TTM_GETTOOLINFOA = (WM_USER + 8);
+ TTM_GETTOOLINFOW = (WM_USER + 53);
+
+ TTM_SETTOOLINFOA = (WM_USER + 9);
+ TTM_SETTOOLINFOW = (WM_USER + 54);
+
+ TTM_HITTESTA = (WM_USER + 10);
+ TTM_HITTESTW = (WM_USER + 55);
+ TTM_GETTEXTA = (WM_USER + 11);
+ TTM_GETTEXTW = (WM_USER + 56);
+ TTM_UPDATETIPTEXTA = (WM_USER + 12);
+ TTM_UPDATETIPTEXTW = (WM_USER + 57);
+ TTM_GETTOOLCOUNT = (WM_USER + 13);
+ TTM_ENUMTOOLSA = (WM_USER + 14);
+ TTM_ENUMTOOLSW = (WM_USER + 58);
+ TTM_GETCURRENTTOOLA = (WM_USER + 15);
+ TTM_GETCURRENTTOOLW = (WM_USER + 59);
+ TTM_WINDOWFROMPOINT = (WM_USER + 16);
+{$ifdef ie3plus}
+ TTM_TRACKACTIVATE = (WM_USER + 17); // wParam = TRUE/FALSE start end lparam = LPTOOLINFO
+ TTM_TRACKPOSITION = (WM_USER + 18); // lParam = dwPos
+ TTM_SETTIPBKCOLOR = (WM_USER + 19);
+ TTM_SETTIPTEXTCOLOR = (WM_USER + 20);
+ TTM_GETDELAYTIME = (WM_USER + 21);
+ TTM_GETTIPBKCOLOR = (WM_USER + 22);
+ TTM_GETTIPTEXTCOLOR = (WM_USER + 23);
+ TTM_SETMAXTIPWIDTH = (WM_USER + 24);
+ TTM_GETMAXTIPWIDTH = (WM_USER + 25);
+ TTM_SETMARGIN = (WM_USER + 26); // lParam = lprc
+ TTM_GETMARGIN = (WM_USER + 27); // lParam = lprc
+ TTM_POP = (WM_USER + 28);
+{$ENDIF}
+{$ifdef ie4plus}
+ TTM_UPDATE = (WM_USER + 29);
+{$ENDIF}
+{$ifdef ie5plus}
+ TTM_GETBUBBLESIZE = (WM_USER + 30);
+ TTM_ADJUSTRECT = (WM_USER + 31);
+ TTM_SETTITLEA = (WM_USER + 32); // wParam = TTI_*, lParam = char* szTitle
+ TTM_SETTITLEW = (WM_USER + 33); // wParam = TTI_*, lParam = wchar* szTitle
+{$ENDIF}
+
+{$ifdef Win32XP}
+ TTM_POPUP = (WM_USER + 34);
+ TTM_GETTITLE = (WM_USER + 35); // wParam = 0, lParam = TTGETTITLE*
+
+TYPE
+
+ _TTGETTITLE = Record
+ dwSize : DWORD;
+ uTitleBitmap : UINT;
+ cch : UINT;
+ pszTitle : PWCHAR;
+ END;
+ TTGETTITLE = _TTGETTITLE;
+ PTTGETTITLE = ^_TTGETTITLE;
+ TTTGETTITLE = _TTGETTITLE;
+ PTTTGETTITLE = ^TTTGETTITLE;
+
+{$ENDIF}
+
+const
+{$IFDEF UNICODE}
+ TTM_ADDTOOL = TTM_ADDTOOLW;
+ TTM_DELTOOL = TTM_DELTOOLW;
+ TTM_NEWTOOLRECT = TTM_NEWTOOLRECTW;
+ TTM_GETTOOLINFO = TTM_GETTOOLINFOW;
+ TTM_SETTOOLINFO = TTM_SETTOOLINFOW;
+ TTM_HITTEST = TTM_HITTESTW;
+ TTM_GETTEXT = TTM_GETTEXTW;
+ TTM_UPDATETIPTEXT = TTM_UPDATETIPTEXTW;
+ TTM_ENUMTOOLS = TTM_ENUMTOOLSW;
+ TTM_GETCURRENTTOOL = TTM_GETCURRENTTOOLW;
+{$ifdef ie5plus}
+ TTM_SETTITLE = TTM_SETTITLEW;
+{$ENDIF}
+{$ELSE}
+ TTM_ADDTOOL = TTM_ADDTOOLA;
+ TTM_DELTOOL = TTM_DELTOOLA;
+ TTM_NEWTOOLRECT = TTM_NEWTOOLRECTA;
+ TTM_GETTOOLINFO = TTM_GETTOOLINFOA;
+ TTM_SETTOOLINFO = TTM_SETTOOLINFOA;
+ TTM_HITTEST = TTM_HITTESTA;
+ TTM_GETTEXT = TTM_GETTEXTA;
+ TTM_UPDATETIPTEXT = TTM_UPDATETIPTEXTA;
+ TTM_ENUMTOOLS = TTM_ENUMTOOLSA;
+ TTM_GETCURRENTTOOL = TTM_GETCURRENTTOOLA;
+{$ifdef ie5plus}
+ TTM_SETTITLE = TTM_SETTITLEA;
+{$ENDIF}
+{$ENDIF}
+
+{$ifdef win32xp}
+CONST
+ TTM_SETWINDOWTHEME = CCM_SETWINDOWTHEME;
+{$ENDIF}
+
+
+TYPE
+
+
+ _TT_HITTESTINFOA = Record
+ hwnd : HWND;
+ pt : POINT;
+ ti : TTTOOLINFOA;
+ END;
+ TTHITTESTINFOA = _TT_HITTESTINFOA;
+ LPTTHITTESTINFOA = ^_TT_HITTESTINFOA;
+ TTT_HITTESTINFOA = _TT_HITTESTINFOA;
+ PTT_HITTESTINFOA = ^_TT_HITTESTINFOA;
+
+
+
+ _TT_HITTESTINFOW = Record
+ hwnd : HWND;
+ pt : POINT;
+ ti : TTTOOLINFOW;
+ END;
+ TTHITTESTINFOW = _TT_HITTESTINFOW;
+ LPTTHITTESTINFOW = ^_TT_HITTESTINFOW;
+ TTT_HITTESTINFOW = _TT_HITTESTINFOW;
+ PTT_HITTESTINFOW = ^_TT_HITTESTINFOW;
+
+{$IFDEF UNICODE}
+ TTHITTESTINFO = TTHITTESTINFOW;
+ LPTTHITTESTINFO = LPTTHITTESTINFOW;
+{$ELSE}
+ TTHITTESTINFO = TTHITTESTINFOA;
+ LPTTHITTESTINFO = LPTTHITTESTINFOA;
+{$ENDIF}
+ LPHITTESTINFO = LPTTHITTESTINFO;
+{$ifdef ie3plus}
+ LPHITTESTINFOW = LPTTHITTESTINFOW;
+ LPHITTESTINFOA = LPTTHITTESTINFOA;
+{$ELSE}
+// LPTTHITTESTINFOA = LPHITTESTINFOA;
+// LPTTHITTESTINFOW = LPHITTESTINFOW;
+{$ENDIF}
+
+CONST
+ TTN_GETDISPINFOA = (TTN_FIRST - 0);
+ TTN_GETDISPINFOW = (TTN_FIRST - 10);
+ TTN_SHOW = (TTN_FIRST - 1);
+ TTN_POP = (TTN_FIRST - 2);
+ TTN_LINKCLICK = (TTN_FIRST - 3);
+
+CONST
+{$IFDEF UNICODE}
+ TTN_GETDISPINFO = TTN_GETDISPINFOW;
+{$ELSE}
+ TTN_GETDISPINFO = TTN_GETDISPINFOA;
+{$ENDIF}
+
+CONST
+ TTN_NEEDTEXT = TTN_GETDISPINFO;
+
+
+ TTN_NEEDTEXTA = TTN_GETDISPINFOA;
+ TTN_NEEDTEXTW = TTN_GETDISPINFOW;
+
+
+
+
+
+TYPE
+
+
+// #define NMTTDISPINFOA_V1_SIZE CCSIZEOF_STRUCT(NMTTDISPINFOA, uFlags)
+// #define NMTTDISPINFOW_V1_SIZE CCSIZEOF_STRUCT(NMTTDISPINFOW, uFlags)
+
+ tagNMTTDISPINFOA = Record
+ hdr : NMHDR;
+ lpszText : LPSTR;
+ szText : Array[0..79] of char;
+ hinst : HINST;
+ uFlags : UINT;
+{$ifdef ie3plus}
+ lParam : LPARAM;
+{$ENDIF}
+ END;
+ NMTTDISPINFOA = tagNMTTDISPINFOA;
+ LPNMTTDISPINFOA = ^tagNMTTDISPINFOA;
+ TNMTTDISPINFOA = tagNMTTDISPINFOA;
+ PNMTTDISPINFOA = ^tagNMTTDISPINFOA;
+
+
+ tagNMTTDISPINFOW = Record
+ hdr : NMHDR;
+ lpszText : LPWSTR;
+ szText : Array[0..79] of WCHAR;
+ hinst : HINST;
+ uFlags : UINT;
+{$ifdef ie3plus}
+ lParam : LPARAM;
+{$ENDIF}
+ END;
+ NMTTDISPINFOW = tagNMTTDISPINFOW;
+ LPNMTTDISPINFOW = ^tagNMTTDISPINFOW;
+ TNMTTDISPINFOW = tagNMTTDISPINFOW;
+ PNMTTDISPINFOW = ^tagNMTTDISPINFOW;
+
+{$ifdef ie3plus}
+ TOOLTIPTEXTW = NMTTDISPINFOW;
+ TOOLTIPTEXTA = NMTTDISPINFOA;
+ LPTOOLTIPTEXTA = LPNMTTDISPINFOA;
+ LPTOOLTIPTEXTW = LPNMTTDISPINFOW;
+ TTOOLTIPTEXTW = NMTTDISPINFOW;
+ PTOOLTIPTEXTW = LPNMTTDISPINFOW;
+{$ELSE}
+// tagNMTTDISPINFOA = tagTOOLTIPTEXTA;
+ NMTTDISPINFOA = TOOLTIPTEXTA;
+// LPNMTTDISPINFOA = LPTOOLTIPTEXTA;
+ tagNMTTDISPINFOW = tagTOOLTIPTEXTW;
+ NMTTDISPINFOW = TOOLTIPTEXTW;
+ LPNMTTDISPINFOW = LPTOOLTIPTEXTW;
+{$ENDIF}
+
+TYPE
+
+{$IFDEF UNICODE}
+ NMTTDISPINFO = NMTTDISPINFOW;
+ LPNMTTDISPINFO = LPNMTTDISPINFOW;
+// NMTTDISPINFO_V1_SIZE = NMTTDISPINFOW_V1_SIZE;
+{$ELSE}
+ NMTTDISPINFO = NMTTDISPINFOA;
+ LPNMTTDISPINFO = LPNMTTDISPINFOA;
+// NMTTDISPINFO_V1_SIZE = NMTTDISPINFOA_V1_SIZE;
+{$ENDIF}
+
+ TOOLTIPTEXT = NMTTDISPINFO;
+ LPTOOLTIPTEXT = LPNMTTDISPINFO;
+
+{$ENDIF} // NOTOOLTIPS
+
+
+//====== STATUS BAR CONTROL ===================================================
+
+{$IFNDEF NOSTATUSBAR}
+
+// begin_r_commctrl
+CONST
+ SBARS_SIZEGRIP = $0100;
+{$ifdef ie5plus}
+ SBARS_TOOLTIPS = $0800;
+{$ENDIF}
+
+{$ifdef ie4plus}
+// this is a status bar flag, preference to SBARS_TOOLTIPS
+ SBT_TOOLTIPS = $0800;
+{$ENDIF}
+
+// end_r_commctrl
+
+procedure DrawStatusTextA(hDC:HDC;lprc:LPRECT;pszText:LPCSTR;uFlags:UINT); stdcall; external commctrldll name 'DrawStatusTextA';
+Procedure DrawStatusTextW(hDC:HDC;lprc:LPRECT;pszText:LPCWSTR;uFlags:UINT); stdcall; external commctrldll name 'DrawStatusTextW';
+
+function CreateStatusWindowA(style:LONG;lpszText:LPCSTR;hwndParent:HWND;wID:UINT):HWND; stdcall; external commctrldll name 'CreateStatusWindowA';
+function CreateStatusWindowW(style:LONG;lpszText:LPCWSTR;hwndParent:HWND;wID:UINT):HWND; stdcall; external commctrldll name 'CreateStatusWindowW';
+
+function CreateStatusWindow(style:LONG;lpszText:LPCSTR;hwndParent:HWND;wID:UINT):HWND; stdcall; external commctrldll name 'CreateStatusWindowA';
+procedure DrawStatusText(hDC:HDC;lprc:LPRECT;pszText:LPCSTR;uFlags:UINT); stdcall; external commctrldll name 'DrawStatusTextA';
+function CreateStatusWindow(style:LONG;lpszText:LPCWSTR;hwndParent:HWND;wID:UINT):HWND; stdcall; external commctrldll name 'CreateStatusWindowW';
+Procedure DrawStatusText(hDC:HDC;lprc:LPRECT;pszText:LPCWSTR;uFlags:UINT); stdcall; external commctrldll name 'DrawStatusTextW';
+
+CONST
+{$IFDEF _WIN32}
+ STATUSCLASSNAMEW = {L}'msctls_statusbar32';
+ STATUSCLASSNAMEA = 'msctls_statusbar32';
+
+{$IFDEF UNICODE}
+ STATUSCLASSNAME = STATUSCLASSNAMEW;
+{$ELSE}
+ STATUSCLASSNAME = STATUSCLASSNAMEA;
+{$ENDIF}
+{$ELSE}
+ STATUSCLASSNAME = 'msctls_statusbar';
+{$ENDIF}
+
+ SB_SETTEXTA = (WM_USER+1);
+ SB_SETTEXTW = (WM_USER+11);
+ SB_GETTEXTA = (WM_USER+2);
+ SB_GETTEXTW = (WM_USER+13);
+ SB_GETTEXTLENGTHA = (WM_USER+3);
+ SB_GETTEXTLENGTHW = (WM_USER+12);
+
+
+ SB_SETPARTS = (WM_USER+4);
+ SB_GETPARTS = (WM_USER+6);
+ SB_GETBORDERS = (WM_USER+7);
+ SB_SETMINHEIGHT = (WM_USER+8);
+ SB_SIMPLE = (WM_USER+9);
+ SB_GETRECT = (WM_USER+10);
+{$ifdef ie3plus}
+ SB_ISSIMPLE = (WM_USER+14);
+{$ENDIF}
+{$ifdef ie4plus}
+ SB_SETICON = (WM_USER+15);
+ SB_SETTIPTEXTA = (WM_USER+16);
+ SB_SETTIPTEXTW = (WM_USER+17);
+ SB_GETTIPTEXTA = (WM_USER+18);
+ SB_GETTIPTEXTW = (WM_USER+19);
+ SB_GETICON = (WM_USER+20);
+ SB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+ SB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+{$ENDIF}
+{$IFDEF UNICODE}
+ SB_GETTEXT = SB_GETTEXTW;
+ SB_SETTEXT = SB_SETTEXTW;
+ SB_GETTEXTLENGTH = SB_GETTEXTLENGTHW;
+{$ifdef ie4plus}
+ SB_SETTIPTEXT = SB_SETTIPTEXTW;
+ SB_GETTIPTEXT = SB_GETTIPTEXTW;
+{$ENDIF}
+{$ELSE}
+ SB_GETTEXT = SB_GETTEXTA;
+ SB_SETTEXT = SB_SETTEXTA;
+ SB_GETTEXTLENGTH = SB_GETTEXTLENGTHA;
+{$ifdef ie4plus}
+ SB_SETTIPTEXT = SB_SETTIPTEXTA;
+ SB_GETTIPTEXT = SB_GETTIPTEXTA;
+{$ENDIF}
+{$ENDIF}
+
+ SBT_OWNERDRAW = $1000;
+ SBT_NOBORDERS = $0100;
+ SBT_POPOUT = $0200;
+ SBT_RTLREADING = $0400;
+{$ifdef ie5plus}
+ SBT_NOTABPARSING = $0800;
+{$ENDIF}
+
+ SB_SETBKCOLOR = CCM_SETBKCOLOR; // lParam = bkColor
+
+/// status bar notifications
+{$ifdef ie4plus}
+ SBN_SIMPLEMODECHANGE = (SBN_FIRST - 0);
+{$ENDIF}
+
+{$ifdef ie5plus}
+// refers to the data saved for simple mode
+ SB_SIMPLEID = $00ff;
+{$ENDIF}
+
+{$ENDIF} // NOSTATUSBAR
+
+//====== MENU HELP ============================================================
+
+{$IFNDEF NOMENUHELP}
+
+Procedure MenuHelp(uMsg:UINT;wParam:WPARAM;lParam:LPARAM;hMainMenu:HMENU;hInst:HINST;hwndStatus:HWND;lpwIDs:PUINT); stdcall; external commctrldll name 'MenuHelp';
+function ShowHideMenuCtl(hWnd:HWND;uFlags:UINT_PTR;lpInfo:LPINT):BOOL; stdcall; external commctrldll name 'ShowHideMenuCtl';
+Procedure GetEffectiveClientRect(hWnd:HWND;lprc:LPRECT;lpInfo:LPINT); stdcall; external commctrldll name 'GetEffectiveClientRect';
+
+CONST
+ MINSYSCOMMAND = SC_SIZE;
+{$ENDIF}
+
+
+//====== TRACKBAR CONTROL =====================================================
+
+{$IFNDEF NOTRACKBAR}
+
+CONST
+
+{$IFDEF _WIN32}
+
+ TRACKBAR_CLASSA = 'msctls_trackbar32';
+ TRACKBAR_CLASSW = {L}'msctls_trackbar32';
+
+{$IFDEF UNICODE}
+ TRACKBAR_CLASS = TRACKBAR_CLASSW;
+{$ELSE}
+ TRACKBAR_CLASS = TRACKBAR_CLASSA;
+{$ENDIF}
+{$ELSE}
+ TRACKBAR_CLASS = 'msctls_trackbar';
+{$ENDIF}
+
+// begin_r_commctrl
+
+ TBS_AUTOTICKS = $0001;
+ TBS_VERT = $0002;
+ TBS_HORZ = $0000;
+ TBS_TOP = $0004;
+ TBS_BOTTOM = $0000;
+ TBS_LEFT = $0004;
+ TBS_RIGHT = $0000;
+ TBS_BOTH = $0008;
+ TBS_NOTICKS = $0010;
+ TBS_ENABLESELRANGE = $0020;
+ TBS_FIXEDLENGTH = $0040;
+ TBS_NOTHUMB = $0080;
+{$ifdef ie3plus}
+ TBS_TOOLTIPS = $0100;
+{$ENDIF}
+{$ifdef ie5plus}
+ TBS_REVERSED = $0200; // Accessibility hint: the smaller number (usually the min value) means "high" and the larger number (usually the max value) means "low"
+{$ENDIF}
+
+{$ifdef ie501plus}
+ TBS_DOWNISLEFT = $0400; // Down=Left and Up=Right (default is Down=Right and Up=Left)
+{$ENDIF}
+{$ifdef win32vista}
+ TBS_NOTIFYBEFOREMOVE = $0800; // Trackbar should notify parent before repositioning the slider due to user action (enables snapping)
+{$endif}
+{$ifdef NTDDI_VISTA}
+ TBS_TRANSPARENTBKGND = $1000; // Background is painted by the parent via WM_PRINTCLIENT
+{$endif}
+
+// end_r_commctrl
+
+ TBM_GETPOS = (WM_USER);
+ TBM_GETRANGEMIN = (WM_USER+1);
+ TBM_GETRANGEMAX = (WM_USER+2);
+ TBM_GETTIC = (WM_USER+3);
+ TBM_SETTIC = (WM_USER+4);
+ TBM_SETPOS = (WM_USER+5);
+ TBM_SETRANGE = (WM_USER+6);
+ TBM_SETRANGEMIN = (WM_USER+7);
+ TBM_SETRANGEMAX = (WM_USER+8);
+ TBM_CLEARTICS = (WM_USER+9);
+ TBM_SETSEL = (WM_USER+10);
+ TBM_SETSELSTART = (WM_USER+11);
+ TBM_SETSELEND = (WM_USER+12);
+ TBM_GETPTICS = (WM_USER+14);
+ TBM_GETTICPOS = (WM_USER+15);
+ TBM_GETNUMTICS = (WM_USER+16);
+ TBM_GETSELSTART = (WM_USER+17);
+ TBM_GETSELEND = (WM_USER+18);
+ TBM_CLEARSEL = (WM_USER+19);
+ TBM_SETTICFREQ = (WM_USER+20);
+ TBM_SETPAGESIZE = (WM_USER+21);
+ TBM_GETPAGESIZE = (WM_USER+22);
+ TBM_SETLINESIZE = (WM_USER+23);
+ TBM_GETLINESIZE = (WM_USER+24);
+ TBM_GETTHUMBRECT = (WM_USER+25);
+ TBM_GETCHANNELRECT = (WM_USER+26);
+ TBM_SETTHUMBLENGTH = (WM_USER+27);
+ TBM_GETTHUMBLENGTH = (WM_USER+28);
+{$ifdef ie3plus}
+ TBM_SETTOOLTIPS = (WM_USER+29);
+ TBM_GETTOOLTIPS = (WM_USER+30);
+ TBM_SETTIPSIDE = (WM_USER+31);
+// TrackBar Tip Side flags
+ TBTS_TOP = 0;
+ TBTS_LEFT = 1;
+ TBTS_BOTTOM = 2;
+ TBTS_RIGHT = 3;
+
+ TBM_SETBUDDY = (WM_USER+32); // wparam = BOOL fLeft; (or right)
+ TBM_GETBUDDY = (WM_USER+33); // wparam = BOOL fLeft; (or right)
+{$ENDIF}
+{$ifdef ie4plus}
+ TBM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+ TBM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+{$ENDIF}
+
+
+ TB_LINEUP = 0;
+ TB_LINEDOWN = 1;
+ TB_PAGEUP = 2;
+ TB_PAGEDOWN = 3;
+ TB_THUMBPOSITION = 4;
+ TB_THUMBTRACK = 5;
+ TB_TOP = 6;
+ TB_BOTTOM = 7;
+ TB_ENDTRACK = 8;
+
+
+{$ifdef ie3plus}
+// custom draw item specs
+ TBCD_TICS = $0001;
+ TBCD_THUMB = $0002;
+ TBCD_CHANNEL = $0003;
+{$ENDIF}
+{$ifdef win32vista}
+ TRBN_THUMBPOSCHANGING = (TRBN_FIRST-1);
+{$endif}
+{$ENDIF} // trackbar
+
+//====== DRAG LIST CONTROL ====================================================
+
+{$IFNDEF NODRAGLIST}
+TYPE
+
+ tagDRAGLISTINFO = Record
+ uNotification : UINT;
+ hWnd : HWND;
+ ptCursor : POINT;
+ END;
+ DRAGLISTINFO = tagDRAGLISTINFO;
+ LPDRAGLISTINFO = ^tagDRAGLISTINFO;
+ TDRAGLISTINFO = tagDRAGLISTINFO;
+ PDRAGLISTINFO = ^tagDRAGLISTINFO;
+
+
+
+CONST
+ DL_BEGINDRAG = (WM_USER+133);
+ DL_DRAGGING = (WM_USER+134);
+ DL_DROPPED = (WM_USER+135);
+ DL_CANCELDRAG = (WM_USER+136);
+
+ DL_CURSORSET = 0;
+ DL_STOPCURSOR = 1;
+ DL_COPYCURSOR = 2;
+ DL_MOVECURSOR = 3;
+
+ DRAGLISTMSGSTRING = 'commctrl_DragListMsg'; // TEXT("commctrl_DragListMsg");
+
+function MakeDragList(hLB:HWND):BOOL; stdcall; external commctrldll name 'MakeDragList';
+Procedure DrawInsert(handParent:HWND;hLB:HWND;nItem:cint); stdcall; external commctrldll name 'DrawInsert';
+function LBItemFromPt(hLB:HWND;pt:POINT;bAutoScroll:BOOL):cint; stdcall; external commctrldll name 'LBItemFromPt';
+
+{$ENDIF}
+
+//====== UPDOWN CONTROL =======================================================
+
+{$IFNDEF NOUPDOWN}
+CONST
+{$IFDEF _WIN32}
+
+ UPDOWN_CLASSA = 'msctls_updown32';
+ UPDOWN_CLASSW = {L}'msctls_updown32';
+
+{$IFDEF UNICODE}
+ UPDOWN_CLASS = UPDOWN_CLASSW;
+{$ELSE}
+ UPDOWN_CLASS = UPDOWN_CLASSA;
+{$ENDIF}
+{$ELSE}
+ UPDOWN_CLASS = 'msctls_updown';
+{$ENDIF}
+
+TYPE
+
+ _UDACCEL = Record
+ nSec : UINT;
+ nInc : UINT;
+ END;
+ UDACCEL = _UDACCEL;
+ LPUDACCEL = ^_UDACCEL;
+ TUDACCEL = _UDACCEL;
+ PUDACCEL = ^_UDACCEL;
+
+CONST
+ UD_MAXVAL = $7fff;
+ UD_MINVAL = (-UD_MAXVAL);
+
+// begin_r_commctrl
+
+ UDS_WRAP = $0001;
+ UDS_SETBUDDYINT = $0002;
+ UDS_ALIGNRIGHT = $0004;
+ UDS_ALIGNLEFT = $0008;
+ UDS_AUTOBUDDY = $0010;
+ UDS_ARROWKEYS = $0020;
+ UDS_HORZ = $0040;
+ UDS_NOTHOUSANDS = $0080;
+{$ifdef ie3plus}
+ UDS_HOTTRACK = $0100;
+{$ENDIF}
+
+// end_r_commctrl
+
+ UDM_SETRANGE = (WM_USER+101);
+ UDM_GETRANGE = (WM_USER+102);
+ UDM_SETPOS = (WM_USER+103);
+ UDM_GETPOS = (WM_USER+104);
+ UDM_SETBUDDY = (WM_USER+105);
+ UDM_GETBUDDY = (WM_USER+106);
+ UDM_SETACCEL = (WM_USER+107);
+ UDM_GETACCEL = (WM_USER+108);
+ UDM_SETBASE = (WM_USER+109);
+ UDM_GETBASE = (WM_USER+110);
+{$ifdef ie4plus}
+ UDM_SETRANGE32 = (WM_USER+111);
+ UDM_GETRANGE32 = (WM_USER+112); // wParam & lParam are LPINT
+ UDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+ UDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+{$ENDIF}
+{$ifdef ie5plus}
+ UDM_SETPOS32 = (WM_USER+113);
+ UDM_GETPOS32 = (WM_USER+114);
+{$ENDIF}
+
+function CreateUpDownControl(dwStyle:DWORD;x:cint;y:cint;cx:cint;cy:cint;hParent:HWND;nID:cint;hInst:HINST;hBuddy:HWND;nUpper:cint;nLower:cint;nPos:cint):HWND; stdcall; external commctrldll name 'CreateUpDownControl';
+
+TYPE
+ _NM_UPDOWN = Record
+ hdr : NMHDR;
+ iPos : cint;
+ iDelta : cint;
+ END;
+ NMUPDOWN = _NM_UPDOWN;
+ LPNMUPDOWN = ^_NM_UPDOWN;
+ TNM_UPDOWN = _NM_UPDOWN;
+ PNM_UPDOWN = ^_NM_UPDOWN;
+
+{$ifdef ie3plus}
+ NM_UPDOWN = NMUPDOWN;
+ LPNM_UPDOWN = LPNMUPDOWN;
+{$ELSE}
+ NMUPDOWN = NM_UPDOWN;
+ LPNMUPDOWN = LPNM_UPDOWN;
+{$ENDIF}
+
+CONST
+ UDN_DELTAPOS = (UDN_FIRST - 1);
+
+{$ENDIF} // NOUPDOWN
+
+
+//====== PROGRESS CONTROL =====================================================
+
+{$IFNDEF NOPROGRESS}
+
+CONST
+
+{$IFDEF _WIN32}
+
+ PROGRESS_CLASSA = 'msctls_progress32';
+ PROGRESS_CLASSW = {L}'msctls_progress32';
+
+{$IFDEF UNICODE}
+ PROGRESS_CLASS = PROGRESS_CLASSW;
+{$ELSE}
+ PROGRESS_CLASS = PROGRESS_CLASSA;
+{$ENDIF}
+
+{$ELSE}
+ PROGRESS_CLASS = 'msctls_progress';
+{$ENDIF}
+
+// begin_r_commctrl
+
+{$ifdef ie3plus}
+ PBS_SMOOTH = $01;
+ PBS_VERTICAL = $04;
+{$ENDIF}
+
+// end_r_commctrl
+
+ PBM_SETRANGE = (WM_USER+1);
+ PBM_SETPOS = (WM_USER+2);
+ PBM_DELTAPOS = (WM_USER+3);
+ PBM_SETSTEP = (WM_USER+4);
+ PBM_STEPIT = (WM_USER+5);
+{$ifdef ie3plus}
+ PBM_SETRANGE32 = (WM_USER+6); // lParam = high, wParam = low
+
+TYPE
+ PBRANGE = Record
+ iLow : cint;
+ iHigh : cint;
+ END;
+ PPBRANGE = ^PBRANGE;
+ TPBRANGE = PBRANGE;
+// PPBRANGE = ^PBRANGE;
+
+
+CONST
+ PBM_GETRANGE = (WM_USER+7); // wParam = return (TRUE ? low : high). lParam = PPBRANGE or NULL
+ PBM_GETPOS = (WM_USER+8);
+{$ifdef ie4plus}
+ PBM_SETBARCOLOR = (WM_USER+9); // lParam = bar color
+{$ENDIF} // _WIN32_IE >= 0x0400
+ PBM_SETBKCOLOR = CCM_SETBKCOLOR; // lParam = bkColor
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+{$ifdef win32xp} //_WIN32_WINNT >= 0x0501
+ PBS_MARQUEE = $08;
+ PBM_SETMARQUEE = (WM_USER+10);
+{$endif} //_WIN32_WINNT >= 0x0501
+
+{$ifdef win32vista}
+ PBS_SMOOTHREVERSE = $10;
+{$endif}
+
+{$ifdef win32vista}
+
+ PBM_GETSTEP = (WM_USER+13);
+ PBM_GETBKCOLOR = (WM_USER+14);
+ PBM_GETBARCOLOR = (WM_USER+15);
+ PBM_SETSTATE = (WM_USER+16); // wParam = PBST_[State] (NORMAL, ERROR, PAUSED)
+ PBM_GETSTATE = (WM_USER+17);
+
+ PBST_NORMAL = $0001;
+ PBST_ERROR = $0002;
+ PBST_PAUSED = $0003;
+{$endif}
+
+// end_r_commctrl
+
+
+{$ENDIF} // NOPROGRESS
+
+
+//====== HOTKEY CONTROL =======================================================
+
+{$IFNDEF NOHOTKEY}
+ HOTKEYF_SHIFT = $01;
+ HOTKEYF_CONTROL = $02;
+ HOTKEYF_ALT = $04;
+{$IFDEF _MAC}
+ HOTKEYF_EXT = $80;
+{$ELSE}
+ HOTKEYF_EXT = $08;
+{$ENDIF}
+ HKCOMB_NONE = $0001;
+ HKCOMB_S = $0002;
+ HKCOMB_C = $0004;
+ HKCOMB_A = $0008;
+ HKCOMB_SC = $0010;
+ HKCOMB_SA = $0020;
+ HKCOMB_CA = $0040;
+ HKCOMB_SCA = $0080;
+
+ HKM_SETHOTKEY = (WM_USER+1);
+ HKM_GETHOTKEY = (WM_USER+2);
+ HKM_SETRULES = (WM_USER+3);
+
+{$IFDEF _WIN32}
+ HOTKEY_CLASSA = 'msctls_hotkey32';
+ HOTKEY_CLASSW = widestring('msctls_hotkey32');
+{$IFDEF UNICODE}
+ HOTKEY_CLASS = HOTKEY_CLASSW;
+{$ELSE}
+ HOTKEY_CLASS = HOTKEY_CLASSA;
+{$ENDIF}
+{$ELSE}
+ HOTKEY_CLASS = 'msctls_hotkey';
+{$ENDIF}
+
+{$ENDIF} // NOHOTKEY
+ HOTKEYCLASS = HOTKEY_CLASSA;
+
+// begin_r_commctrl
+
+//====== COMMON CONTROL STYLES ================================================
+
+ CCS_TOP = DWORD($00000001){L};
+ CCS_NOMOVEY = DWORD($00000002){L};
+ CCS_BOTTOM = DWORD($00000003){L};
+ CCS_NORESIZE = DWORD($00000004){L};
+ CCS_NOPARENTALIGN = DWORD($00000008){L};
+ CCS_ADJUSTABLE = DWORD($00000020){L};
+ CCS_NODIVIDER = DWORD($00000040){L};
+{$ifdef ie3plus}
+ CCS_VERT = DWORD($00000080){L};
+ CCS_LEFT = (CCS_VERT OR CCS_TOP);
+ CCS_RIGHT = (CCS_VERT OR CCS_BOTTOM);
+ CCS_NOMOVEX = (CCS_VERT OR CCS_NOMOVEY);
+{$ENDIF}
+
+// end_r_commctrl
+
+//====== LISTVIEW CONTROL =====================================================
+
+{$IFNDEF NOLISTVIEW}
+
+{$IFDEF _WIN32}
+ WC_LISTVIEWA = 'SysListView32';
+ WC_LISTVIEWW = {L}'SysListView32';
+{$IFDEF UNICODE}
+ WC_LISTVIEW = WC_LISTVIEWW;
+{$ELSE}
+ WC_LISTVIEW = WC_LISTVIEWA;
+{$ENDIF}
+{$ELSE}
+ WC_LISTVIEW = 'SysListView';
+{$ENDIF}
+
+// begin_r_commctrl
+
+ LVS_ICON = $0000;
+ LVS_REPORT = $0001;
+ LVS_SMALLICON = $0002;
+ LVS_LIST = $0003;
+ LVS_TYPEMASK = $0003;
+ LVS_SINGLESEL = $0004;
+ LVS_SHOWSELALWAYS = $0008;
+ LVS_SORTASCENDING = $0010;
+ LVS_SORTDESCENDING = $0020;
+ LVS_SHAREIMAGELISTS = $0040;
+ LVS_NOLABELWRAP = $0080;
+ LVS_AUTOARRANGE = $0100;
+ LVS_EDITLABELS = $0200;
+{$ifdef ie3plus}
+ LVS_OWNERDATA = $1000;
+{$ENDIF}
+ LVS_NOSCROLL = $2000;
+
+ LVS_TYPESTYLEMASK = $fc00;
+
+ LVS_ALIGNTOP = $0000;
+ LVS_ALIGNLEFT = $0800;
+ LVS_ALIGNMASK = $0c00;
+
+ LVS_OWNERDRAWFIXED = $0400;
+ LVS_NOCOLUMNHEADER = $4000;
+ LVS_NOSORTHEADER = $8000;
+
+// end_r_commctrl
+
+{$ifdef ie4plus}
+ LVM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+
+// Macro 38
+Function ListView_SetUnicodeFormat( hwnd : hwnd; fUnicode : WPARAM):BOOL;
+
+CONST
+ LVM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+
+// Macro 39
+Function ListView_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+{$ENDIF}
+CONST
+ LVM_GETBKCOLOR = (LVM_FIRST + 0);
+
+// Macro 40
+Function ListView_GetBkColor( hwnd : hwnd):COLORREF;
+
+CONST
+ LVM_SETBKCOLOR = (LVM_FIRST + 1);
+
+// Macro 41
+Function ListView_SetBkColor( hwnd : hwnd; clrBk : COLORREF):BOOL;
+
+CONST
+ LVM_GETIMAGELIST = (LVM_FIRST + 2);
+
+// Macro 42
+Function ListView_GetImageList( hwnd : hwnd; iImageList : CINT):HIMAGELIST;
+
+CONST
+ LVSIL_NORMAL = 0;
+ LVSIL_SMALL = 1;
+ LVSIL_STATE = 2;
+ LVSIL_GROUPHEADER = 3;
+ LVM_SETIMAGELIST = (LVM_FIRST + 3);
+
+// Macro 43
+Function ListView_SetImageList( hwnd : hwnd; himl : HIMAGELIST; iImageList : WPARAM):HIMAGELIST;
+
+CONST
+ LVM_GETITEMCOUNT = (LVM_FIRST + 4);
+
+// Macro 44
+Function ListView_GetItemCount( hwnd : hwnd):cint;
+
+CONST
+ LVIF_TEXT = $0001;
+ LVIF_IMAGE = $0002;
+ LVIF_PARAM = $0004;
+ LVIF_STATE = $0008;
+{$ifdef ie3plus}
+ LVIF_INDENT = $0010;
+ LVIF_NORECOMPUTE = $0800;
+{$ENDIF}
+{$ifdef win32xp}
+ LVIF_GROUPID = $0100;
+ LVIF_COLUMNS = $0200;
+{$ENDIF}
+{$ifdef win32vista}
+ LVIF_COLFMT = $00010000; // The piColFmt member is valid in addition to puColumns
+{$endif}
+
+ LVIS_FOCUSED = $0001;
+ LVIS_SELECTED = $0002;
+ LVIS_CUT = $0004;
+ LVIS_DROPHILITED = $0008;
+ LVIS_GLOW = $0010;
+ LVIS_ACTIVATING = $0020;
+
+ LVIS_OVERLAYMASK = $0F00;
+ LVIS_STATEIMAGEMASK = $F000;
+
+// Macro 45
+// #define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
+
+
+CONST
+ I_INDENTCALLBACK = (-1);
+{$ENDIF}
+
+
+{$ifdef win32xp}
+
+CONST
+ I_GROUPIDCALLBACK = (-1);
+ I_GROUPIDNONE = (-2);
+{$ENDIF}
+
+
+// #define LVITEMA_V1_SIZE CCSIZEOF_STRUCT(LVITEMA, lParam)
+// #define LVITEMW_V1_SIZE CCSIZEOF_STRUCT(LVITEMW, lParam)
+
+TYPE
+ tagLVITEMA = Record
+ mask : UINT;
+ iItem : cint;
+ iSubItem : cint;
+ state : UINT;
+ stateMask : UINT;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ lParam : LPARAM;
+{$ifdef ie3plus}
+ iIndent : cint;
+{$ENDIF}
+{$ifdef win32xp}
+ iGroupId : cint;
+ cColumns : UINT; // tile view columns
+ puColumns : PUINT;
+{$ENDIF}
+{$ifdef win32vista}
+ piColFmt : pcint;
+ iGroup : cint; // readonly. only valid for owner data.
+{$endif}
+ END;
+ LVITEMA = tagLVITEMA;
+ LPLVITEMA = ^tagLVITEMA;
+ TLVITEMA = tagLVITEMA;
+ PLVITEMA = ^tagLVITEMA;
+
+
+ tagLVITEMW = Record
+ mask : UINT;
+ iItem : cint;
+ iSubItem : cint;
+ state : UINT;
+ stateMask : UINT;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ lParam : LPARAM;
+{$ifdef ie3plus}
+ iIndent : cint;
+{$ENDIF}
+{$ifdef win32xp}
+ iGroupId : cint;
+ cColumns : UINT; // tile view columns
+ puColumns : PUINT;
+{$ENDIF}
+{$ifdef win32vista}
+ piColFmt : pcint;
+ iGroup : cint; // readonly. only valid for owner data.
+{$endif}
+ END;
+
+ LVITEMW = tagLVITEMW;
+ LPLVITEMW = ^tagLVITEMW;
+ TLVITEMW = tagLVITEMW;
+ PLVITEMW = ^tagLVITEMW;
+
+{$IFDEF UNICODE}
+ LVITEM = LVITEMW;
+ LPLVITEM = LPLVITEMW;
+
+// LVITEM_V1_SIZE = LVITEMW_V1_SIZE;
+{$ELSE}
+
+TYPE
+ LVITEM = LVITEMA;
+ LPLVITEM = LPLVITEMA;
+
+// LVITEM_V1_SIZE = LVITEMA_V1_SIZE;
+{$ENDIF}
+
+Type
+{$ifdef ie3plus}
+
+ LV_ITEMA = LVITEMA;
+ LV_ITEMW = LVITEMW;
+{$ELSE}
+
+ tagLVITEMA = _LV_ITEMA;
+ LVITEMA = LV_ITEMA;
+ tagLVITEMW = _LV_ITEMW;
+ LVITEMW = LV_ITEMW;
+{$ENDIF}
+ LV_ITEM = LVITEM;
+ TLVItem = LVITEM;
+ PLVItem = LPLVITEM;
+ TLV_ITEM = LVITEM;
+ PLV_ITEM = PLVITEM;
+CONST
+ LPSTR_TEXTCALLBACKW = LPWSTR(-1);
+ LPSTR_TEXTCALLBACKA = LPSTR (-1);
+{$IFDEF UNICODE}
+ LPSTR_TEXTCALLBACK = LPSTR_TEXTCALLBACKW;
+{$ELSE}
+ LPSTR_TEXTCALLBACK = LPSTR_TEXTCALLBACKA;
+{$ENDIF}
+
+
+CONST
+ I_IMAGECALLBACK = (-1);
+{$ifdef ie501plus}
+ I_IMAGENONE = (-2);
+{$ENDIF} // 0x0501
+
+{$ifdef win32xp}
+// For tileview
+ I_COLUMNSCALLBACK = UINT(-1);
+{$ENDIF}
+
+ LVM_GETITEMA = (LVM_FIRST + 5);
+ LVM_GETITEMW = (LVM_FIRST + 75);
+
+{$IFDEF UNICODE}
+ LVM_GETITEM = LVM_GETITEMW;
+{$ELSE}
+ LVM_GETITEM = LVM_GETITEMA;
+{$ENDIF}
+
+// Macro 46
+Function ListView_GetItem( hwnd : hwnd;var pitem : LV_ITEM ):BOOL;
+
+CONST
+ LVM_SETITEMA = (LVM_FIRST + 6);
+ LVM_SETITEMW = (LVM_FIRST + 76);
+
+{$IFDEF UNICODE}
+ LVM_SETITEM = LVM_SETITEMW;
+{$ELSE}
+ LVM_SETITEM = LVM_SETITEMA;
+{$ENDIF}
+
+// Macro 47
+Function ListView_SetItem( hwnd : hwnd;const pitem : LV_ITEM ):BOOL;
+
+
+CONST
+ LVM_INSERTITEMA = (LVM_FIRST + 7);
+ LVM_INSERTITEMW = (LVM_FIRST + 77);
+{$IFDEF UNICODE}
+ LVM_INSERTITEM = LVM_INSERTITEMW;
+{$ELSE}
+ LVM_INSERTITEM = LVM_INSERTITEMA;
+{$ENDIF}
+
+// Macro 48
+Function ListView_InsertItem( hwnd : hwnd;Const pitem : LV_ITEM ):cint;
+
+CONST
+ LVM_DELETEITEM = (LVM_FIRST + 8);
+
+// Macro 49
+Function ListView_DeleteItem( hwnd : hwnd; i : cint):BOOL;
+
+CONST
+ LVM_DELETEALLITEMS = (LVM_FIRST + 9);
+
+// Macro 50
+Function ListView_DeleteAllItems( hwnd : hwnd):BOOL;
+
+CONST
+ LVM_GETCALLBACKMASK = (LVM_FIRST + 10);
+
+// Macro 51
+Function ListView_GetCallbackMask( hwnd : hwnd):BOOL;
+
+
+CONST
+ LVM_SETCALLBACKMASK = (LVM_FIRST + 11);
+
+// Macro 52
+Function ListView_SetCallbackMask( hwnd : hwnd; mask : UINT):BOOL;
+
+
+CONST
+ LVNI_ALL = $0000;
+ LVNI_FOCUSED = $0001;
+ LVNI_SELECTED = $0002;
+ LVNI_CUT = $0004;
+ LVNI_DROPHILITED = $0008;
+
+ LVNI_ABOVE = $0100;
+ LVNI_BELOW = $0200;
+ LVNI_TOLEFT = $0400;
+ LVNI_TORIGHT = $0800;
+
+
+ LVM_GETNEXTITEM = (LVM_FIRST + 12);
+
+// Macro 53
+Function ListView_GetNextItem( hwnd : hwnd; i : cint; flags : cint ):cint;
+
+CONST
+ LVFI_PARAM = $0001;
+ LVFI_STRING = $0002;
+ LVFI_PARTIAL = $0008;
+ LVFI_WRAP = $0020;
+ LVFI_NEARESTXY = $0040;
+
+
+TYPE
+
+ tagLVFINDINFOA = Record
+ flags : UINT;
+ psz : LPCSTR;
+ lParam : LPARAM;
+ pt : POINT;
+ vkDirection : UINT;
+ END;
+ LVFINDINFOA = tagLVFINDINFOA;
+ LPFINDINFOA = ^tagLVFINDINFOA;
+ TLVFINDINFOA = tagLVFINDINFOA;
+ PLVFINDINFOA = ^tagLVFINDINFOA;
+
+
+ tagLVFINDINFOW = Record
+ flags : UINT;
+ psz : LPCWSTR;
+ lParam : LPARAM;
+ pt : POINT;
+ vkDirection : UINT;
+ END;
+ LVFINDINFOW = tagLVFINDINFOW;
+ LPFINDINFOW = ^tagLVFINDINFOW;
+ TLVFINDINFOW = tagLVFINDINFOW;
+ PLVFINDINFOW = ^tagLVFINDINFOW;
+
+{$IFDEF UNICODE}
+ LVFINDINFO = LVFINDINFOW;
+{$ELSE}
+ LVFINDINFO = LVFINDINFOA;
+{$ENDIF}
+
+{$ifdef ie3plus}
+ LV_FINDINFOA = LVFINDINFOA;
+ LV_FINDINFOW = LVFINDINFOW;
+{$ELSE}
+ tagLVFINDINFOA = _LV_FINDINFOA;
+ LVFINDINFOA = LV_FINDINFOA;
+ tagLVFINDINFOW = _LV_FINDINFOW;
+ LVFINDINFOW = LV_FINDINFOW;
+{$ENDIF}
+
+ TLVFindInfo = LVFINDINFO;
+ PLVFindInfo = ^LVFindInfo;
+
+ LV_FINDINFO = LVFINDINFO;
+
+CONST
+ LVM_FINDITEMA = (LVM_FIRST + 13);
+ LVM_FINDITEMW = (LVM_FIRST + 83);
+{$IFDEF UNICODE}
+ LVM_FINDITEM = LVM_FINDITEMW;
+{$ELSE}
+ LVM_FINDITEM = LVM_FINDITEMA;
+{$ENDIF}
+
+// Macro 54
+Function ListView_FindItem( hwnd : hwnd; iStart : cint;const plvfi : LV_FINDINFO ):cint;
+
+CONST
+ LVIR_BOUNDS = 0;
+ LVIR_ICON = 1;
+ LVIR_LABEL = 2;
+ LVIR_SELECTBOUNDS = 3;
+
+
+ LVM_GETITEMRECT = (LVM_FIRST + 14);
+
+// Macro 55 NI
+Function ListView_GetItemRect( hwnd : hwnd; i : cint;var prc : TRect;code : cint):BOOL;
+
+CONST
+ LVM_SETITEMPOSITION = (LVM_FIRST + 15);
+
+// Macro 56
+Function ListView_SetItemPosition( hwndLV : hwnd; i : cint; x : cint ; y : cint ):BOOL;
+
+CONST
+ LVM_GETITEMPOSITION = (LVM_FIRST + 16);
+
+// Macro 57
+Function ListView_GetItemPosition( hwndLV : hwnd; i : cint;var ppt : POINT ):BOOL;
+
+CONST
+ LVM_GETSTRINGWIDTHA = (LVM_FIRST + 17);
+ LVM_GETSTRINGWIDTHW = (LVM_FIRST + 87);
+{$IFDEF UNICODE}
+ LVM_GETSTRINGWIDTH = LVM_GETSTRINGWIDTHW;
+{$ELSE}
+ LVM_GETSTRINGWIDTH = LVM_GETSTRINGWIDTHA;
+{$ENDIF}
+
+// Macro 58
+Function ListView_GetStringWidth( hwndLV : hwnd; psz : LPCTSTR):cint;
+
+CONST
+ LVHT_NOWHERE = $0001;
+ LVHT_ONITEMICON = $0002;
+ LVHT_ONITEMLABEL = $0004;
+ LVHT_ONITEMSTATEICON = $0008;
+ LVHT_ONITEM = (LVHT_ONITEMICON OR LVHT_ONITEMLABEL OR LVHT_ONITEMSTATEICON);
+
+ LVHT_ABOVE = $0008;
+ LVHT_BELOW = $0010;
+ LVHT_TORIGHT = $0020;
+ LVHT_TOLEFT = $0040;
+
+
+
+// #define LVHITTESTINFO_V1_SIZE CCSIZEOF_STRUCT(LVHITTESTINFO, iItem)
+
+TYPE
+
+ tagLVHITTESTINFO = Record
+ pt : POINT;
+ flags : UINT;
+ iItem : cint;
+{$ifdef ie3plus}
+ iSubItem : cint; // this is was NOT in win95. valid only for LVM_SUBITEMHITTEST
+{$ENDIF}
+{$ifdef win32vista}
+ iGroup : cint; // readonly. index of group. only valid for owner data.
+ // supports single item in multiple groups.
+{$endif}
+ END;
+ LVHITTESTINFO = tagLVHITTESTINFO;
+ LPLVHITTESTINFO = ^tagLVHITTESTINFO;
+ TLVHITTESTINFO = tagLVHITTESTINFO;
+ PLVHITTESTINFO = ^tagLVHITTESTINFO;
+
+{$ifdef ie3plus}
+ LV_HITTESTINFO = LVHITTESTINFO;
+{$ELSE}
+ tagLVHITTESTINFO = _LV_HITTESTINFO;
+ LVHITTESTINFO = LV_HITTESTINFO;
+{$ENDIF}
+
+CONST
+ LVM_HITTEST = (LVM_FIRST + 18);
+
+// Macro 59
+Function ListView_HitTest( hwndLV : hwnd;var pinfo : LV_HITTESTINFO ):cint;
+
+CONST
+ LVM_ENSUREVISIBLE = (LVM_FIRST + 19);
+
+// Macro 60
+Function ListView_EnsureVisible( hwndLV : hwnd; i : cint; fPartialOK : cint ):BOOL;inline;
+Function ListView_EnsureVisible( hwndLV : hwnd; i : cint; fPartialOK : BOOL ):BOOL;inline;
+
+CONST
+ LVM_SCROLL = (LVM_FIRST + 20);
+
+// Macro 61
+Function ListView_Scroll( hwndLV : hwnd; dx : cint; dy : cint):BOOL;
+
+CONST
+ LVM_REDRAWITEMS = (LVM_FIRST + 21);
+
+// Macro 62
+Function ListView_RedrawItems( hwndLV : hwnd; iFirst : cint; iLast : cint):BOOL;
+
+CONST
+ LVA_DEFAULT = $0000;
+ LVA_ALIGNLEFT = $0001;
+ LVA_ALIGNTOP = $0002;
+ LVA_ALIGNRIGHT = $0003;
+ LVA_ALIGNBOTTOM = $0004;
+ LVA_SNAPTOGRID = $0005;
+ LVA_SORTASCENDING = $0100;
+ LVA_SORTDESCENDING = $0200;
+ LVM_ARRANGE = (LVM_FIRST + 22);
+
+// Macro 63
+Function ListView_Arrange( hwndLV : hwnd; code : UINT):BOOL;
+
+CONST
+ LVM_EDITLABELA = (LVM_FIRST + 23);
+ LVM_EDITLABELW = (LVM_FIRST + 118);
+{$IFDEF UNICODE}
+
+ LVM_EDITLABEL = LVM_EDITLABELW;
+{$ELSE}
+ LVM_EDITLABEL = LVM_EDITLABELA;
+{$ENDIF}
+
+// Macro 64
+Function ListView_EditLabel( hwndLV : hwnd; i : cint):HWND;
+
+CONST
+ LVM_GETEDITCONTROL = (LVM_FIRST + 24);
+
+// Macro 65
+Function ListView_GetEditControl( hwndLV : hwnd):HWND;
+
+
+// #define LVCOLUMNA_V1_SIZE CCSIZEOF_STRUCT(LVCOLUMNA, iSubItem)
+// #define LVCOLUMNW_V1_SIZE CCSIZEOF_STRUCT(LVCOLUMNW, iSubItem)
+
+TYPE
+
+ tagLVCOLUMNA = Record
+ mask : UINT;
+ fmt : cint;
+ cx : cint;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iSubItem : cint;
+{$ifdef ie3plus}
+ iImage : cint;
+ iOrder : cint;
+{$ENDIF}
+{$ifdef win32vista}
+ cxmin : cint; // min snap point
+ cxDefault : cint; // default snap point
+ cxIdeal : cint; // read only. ideal may not eqaul current width if auto sized (LVS_EX_AUTOSIZECOLUMNS) to a lesser width.
+{$endif}
+ END;
+ LVCOLUMNA = tagLVCOLUMNA;
+ LPLVCOLUMNA = ^tagLVCOLUMNA;
+ TLVCOLUMNA = tagLVCOLUMNA;
+ PLVCOLUMNA = ^tagLVCOLUMNA;
+
+
+ tagLVCOLUMNW = Record
+ mask : UINT;
+ fmt : cint;
+ cx : cint;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iSubItem : cint;
+{$ifdef ie3plus}
+ iImage : cint;
+ iOrder : cint;
+{$ENDIF}
+{$ifdef win32vista}
+ cxmin : cint; // min snap point
+ cxDefault : cint; // default snap point
+ cxIdeal : cint; // read only. ideal may not eqaul current width if auto sized (LVS_EX_AUTOSIZECOLUMNS) to a lesser width.
+{$endif}
+ END;
+ LVCOLUMNW = tagLVCOLUMNW;
+ LPLVCOLUMNW = ^tagLVCOLUMNW;
+ TLVCOLUMNW = tagLVCOLUMNW;
+ PLVCOLUMNW = ^tagLVCOLUMNW;
+
+
+{$IFDEF UNICODE}
+ LVCOLUMN = LVCOLUMNW;
+ LPLVCOLUMN = LPLVCOLUMNW;
+// LVCOLUMN_V1_SIZE = LVCOLUMNW_V1_SIZE;
+{$ELSE}
+ LVCOLUMN = LVCOLUMNA;
+ LPLVCOLUMN = LPLVCOLUMNA;
+// LVCOLUMN_V1_SIZE = LVCOLUMNA_V1_SIZE;
+{$ENDIF}
+
+{$ifdef ie3plus}
+ LV_COLUMNA = LVCOLUMNA;
+ LV_COLUMNW = LVCOLUMNW;
+{$ELSE}
+ tagLVCOLUMNA = _LV_COLUMNA;
+ LVCOLUMNA = LV_COLUMNA;
+ tagLVCOLUMNW = _LV_COLUMNW;
+ LVCOLUMNW = LV_COLUMNW;
+{$ENDIF}
+
+
+ LV_COLUMN = LVCOLUMN;
+ TLVColumn = LVCOLUMN;
+ PLVColumn = LPLVCOLUMN;
+
+CONST
+ LVCF_FMT = $0001;
+ LVCF_WIDTH = $0002;
+ LVCF_TEXT = $0004;
+ LVCF_SUBITEM = $0008;
+{$ifdef ie3plus}
+ LVCF_IMAGE = $0010;
+ LVCF_ORDER = $0020;
+{$ENDIF}
+{$ifdef win32vista}
+ LVCF_MINWIDTH = $0040;
+ LVCF_DEFAULTWIDTH = $0080;
+ LVCF_IDEALWIDTH = $0100;
+{$endif}
+
+ LVCFMT_LEFT = $0000;
+ LVCFMT_RIGHT = $0001;
+ LVCFMT_CENTER = $0002;
+ LVCFMT_JUSTIFYMASK = $0003;
+
+{$ifdef ie3plus}
+ LVCFMT_IMAGE = $0800;
+ LVCFMT_BITMAP_ON_RIGHT = $1000;
+ LVCFMT_COL_HAS_IMAGES = $8000;
+{$ENDIF}
+{$ifdef win32vista}
+ LVCFMT_FIXED_WIDTH = $00100; // Can't resize the column; same as HDF_FIXEDWIDTH
+ LVCFMT_NO_DPI_SCALE = $40000; // If not set, CCM_DPISCALE will govern scaling up fixed width
+ LVCFMT_FIXED_RATIO = $80000; // Width will augment with the row height
+{$endif}
+
+ LVM_GETCOLUMNA = (LVM_FIRST + 25);
+ LVM_GETCOLUMNW = (LVM_FIRST + 95);
+{$IFDEF UNICODE}
+ LVM_GETCOLUMN = LVM_GETCOLUMNW;
+{$ELSE}
+ LVM_GETCOLUMN = LVM_GETCOLUMNA;
+{$ENDIF}
+
+// Macro 66
+Function ListView_GetColumn( hwnd : hwnd; iCol : cint;var pcol : LV_COLUMN ):BOOL;
+
+CONST
+ LVM_SETCOLUMNA = (LVM_FIRST + 26);
+ LVM_SETCOLUMNW = (LVM_FIRST + 96);
+{$IFDEF UNICODE}
+ LVM_SETCOLUMN = LVM_SETCOLUMNW;
+{$ELSE}
+ LVM_SETCOLUMN = LVM_SETCOLUMNA;
+{$ENDIF}
+
+// Macro 67
+Function ListView_SetColumn( hwnd : hwnd; iCol : cint;Const pcol : LV_COLUMN ):BOOL;
+
+CONST
+ LVM_INSERTCOLUMNA = (LVM_FIRST + 27);
+ LVM_INSERTCOLUMNW = (LVM_FIRST + 97);
+
+{$IFDEF UNICODE} // was already not active (spaces) in .h
+// # define LVM_INSERTCOLUMN LVM_INSERTCOLUMNW
+{$ELSE}
+// # define LVM_INSERTCOLUMN LVM_INSERTCOLUMNA
+{$ENDIF}
+
+// Macro 68
+Function ListView_InsertColumn( hwnd : hwnd; iCol : cint;Const pcol : LV_COLUMN ):cint;
+
+CONST
+ LVM_DELETECOLUMN = (LVM_FIRST + 28);
+
+// Macro 69
+Function ListView_DeleteColumn( hwnd : hwnd; iCol : cint):BOOL;
+
+CONST
+ LVM_GETCOLUMNWIDTH = (LVM_FIRST + 29);
+
+// Macro 70
+Function ListView_GetColumnWidth( hwnd : hwnd; iCol : cint):cint;
+
+CONST
+ LVSCW_AUTOSIZE = -1;
+ LVSCW_AUTOSIZE_USEHEADER = -2;
+ LVM_SETCOLUMNWIDTH = (LVM_FIRST + 30);
+
+// Macro 71
+Function ListView_SetColumnWidth( hwnd : hwnd; iCol : cint; cx : cint ):BOOL;
+
+
+{$ifdef ie3plus}
+
+CONST
+ LVM_GETHEADER = (LVM_FIRST + 31);
+
+// Macro 72
+Function ListView_GetHeader( hwnd : hwnd):HWND;
+
+{$ENDIF}
+
+CONST
+ LVM_CREATEDRAGIMAGE = (LVM_FIRST + 33);
+
+// Macro 73
+Function ListView_CreateDragImage( hwnd : hwnd; i : cint; lpptUpLeft : LPPOINT):HIMAGELIST;inline;
+Function ListView_CreateDragImage( hwnd : hwnd; i : cint; const lpptUpLeft : POINT):HIMAGELIST;inline;
+
+CONST
+ LVM_GETVIEWRECT = (LVM_FIRST + 34);
+
+// Macro 74
+Function ListView_GetViewRect( hwnd : hwnd;var prc : RECT ):BOOL;
+
+CONST
+ LVM_GETTEXTCOLOR = (LVM_FIRST + 35);
+
+// Macro 75
+Function ListView_GetTextColor( hwnd : hwnd):COLORREF;
+
+CONST
+ LVM_SETTEXTCOLOR = (LVM_FIRST + 36);
+
+// Macro 76
+Function ListView_SetTextColor( hwnd : hwnd; clrText : COLORREF):BOOL;
+
+CONST
+ LVM_GETTEXTBKCOLOR = (LVM_FIRST + 37);
+
+// Macro 77
+Function ListView_GetTextBkColor( hwnd : hwnd):COLORREF;
+
+CONST
+ LVM_SETTEXTBKCOLOR = (LVM_FIRST + 38);
+
+// Macro 78
+Function ListView_SetTextBkColor( hwnd : hwnd; clrTextBk : COLORREF):BOOL;
+
+
+CONST
+ LVM_GETTOPINDEX = (LVM_FIRST + 39);
+
+// Macro 79
+Function ListView_GetTopIndex( hwndLV : hwnd):cint;
+
+CONST
+ LVM_GETCOUNTPERPAGE = (LVM_FIRST + 40);
+
+// Macro 80
+Function ListView_GetCountPerPage( hwndLV : hwnd):cint;
+
+CONST
+ LVM_GETORIGIN = (LVM_FIRST + 41);
+
+// Macro 81
+Function ListView_GetOrigin( hwndLV : hwnd;var ppt : POINT ):BOOL;
+
+CONST
+ LVM_UPDATE = (LVM_FIRST + 42);
+
+// Macro 82
+Function ListView_Update( hwndLV : hwnd; i : WPARAM):BOOL;
+
+CONST
+ LVM_SETITEMSTATE = (LVM_FIRST + 43);
+
+// Macro 83
+Procedure ListView_SetItemState(hwndLV :hwnd; i :cint ;data,mask:UINT);
+
+{$ifdef ie3plus}
+// Macro 84
+Procedure ListView_SetCheckState( hwndLV : hwnd; i : cint ; fCheck : bool );
+
+{$ENDIF}
+
+
+CONST
+ LVM_GETITEMSTATE = (LVM_FIRST + 44);
+
+// Macro 85
+Function ListView_GetItemState( hwndLV : hwnd; i : WPARAM; mask : LPARAM):UINT;
+
+
+{$ifdef ie3plus}
+
+// Macro 86
+Function ListView_GetCheckState( hwndLV : hwnd; i : WPARAM):UINT;
+
+{$ENDIF}
+
+CONST
+ LVM_GETITEMTEXTA = (LVM_FIRST + 45);
+ LVM_GETITEMTEXTW = (LVM_FIRST + 115);
+
+{$IFDEF UNICODE}
+ LVM_GETITEMTEXT = LVM_GETITEMTEXTW;
+{$ELSE}
+ LVM_GETITEMTEXT = LVM_GETITEMTEXTA;
+{$ENDIF}
+
+// Macro 87
+Procedure ListView_GetItemText(hwndLV:hwnd; i : WPARAM ;iSubItem : cint ;pszText : Pointer;cchTextMax :cint);
+
+CONST
+ LVM_SETITEMTEXTA = (LVM_FIRST + 46);
+ LVM_SETITEMTEXTW = (LVM_FIRST + 116);
+
+{$IFDEF UNICODE}
+ LVM_SETITEMTEXT = LVM_SETITEMTEXTW;
+{$ELSE}
+ LVM_SETITEMTEXT = LVM_SETITEMTEXTA;
+{$ENDIF}
+
+// Macro 88
+Procedure ListView_SetItemText(hwndLV:hwnd; i : WPARAM ;iSubItem : cint ;pszText : Pointer);
+
+{$ifdef ie3plus}
+// these flags only apply to LVS_OWNERDATA listviews in report or list mode
+
+CONST
+ LVSICF_NOINVALIDATEALL = $00000001;
+ LVSICF_NOSCROLL = $00000002;
+{$ENDIF}
+
+ LVM_SETITEMCOUNT = (LVM_FIRST + 47);
+
+// Macro 89
+Procedure ListView_SetItemCount( hwndLV : hwnd; cItems : WPARAM);
+
+{$ifdef ie3plus}
+
+// Macro 90
+Procedure ListView_SetItemCountEx( hwndLV : hwnd; cItems : WPARAM; dwFlags : LPARAM);
+
+{$ENDIF}
+
+TYPE
+ PFNLVCOMPARE=Function(a,b,c:LPARAM):cint;
+ TLVCompare = PFNLVCOMPARE;
+
+CONST
+ LVM_SORTITEMS = (LVM_FIRST + 48);
+
+// Macro 91
+Function ListView_SortItems( hwndLV : hwnd;pfnCompare : PFNLVCOMPARE; lPrm : LPARAM):BOOL;
+
+CONST
+ LVM_SETITEMPOSITION32 = (LVM_FIRST + 49);
+
+// Macro 92
+Procedure ListView_SetItemPosition32(hwndLV:hwnd; i:cint;x0,y0:long);
+
+CONST
+ LVM_GETSELECTEDCOUNT = (LVM_FIRST + 50);
+
+// Macro 93
+Function ListView_GetSelectedCount( hwndLV : hwnd):UINT;
+
+CONST
+ LVM_GETITEMSPACING = (LVM_FIRST + 51);
+
+// Macro 94
+Function ListView_GetItemSpacing( hwndLV : hwnd; fSmall : cint ):DWORD;
+
+CONST
+ LVM_GETISEARCHSTRINGA = (LVM_FIRST + 52);
+ LVM_GETISEARCHSTRINGW = (LVM_FIRST + 117);
+
+{$IFDEF UNICODE}
+ LVM_GETISEARCHSTRING = LVM_GETISEARCHSTRINGW;
+{$ELSE}
+ LVM_GETISEARCHSTRING = LVM_GETISEARCHSTRINGA;
+{$ENDIF}
+
+// Macro 95
+Function ListView_GetISearchString( hwndLV : hwnd; lpsz : LPTSTR):BOOL;
+
+
+{$ifdef ie3plus}
+
+CONST
+ LVM_SETICONSPACING = (LVM_FIRST + 53);
+// -1 for cx and cy means we'll use the default (system settings)
+// 0 for cx or cy means use the current setting (allows you to change just one param)
+
+// Macro 96
+Function ListView_SetIconSpacing( hwndLV : hwnd; cx, cy : cint ):DWORD;
+
+CONST
+ LVM_SETEXTENDEDLISTVIEWSTYLE = (LVM_FIRST + 54); // optional wParam == mask
+
+// Macro 97
+Function ListView_SetExtendedListViewStyle( hwndLV : hwnd; dw : cint ):DWORD;
+
+{$ifdef ie4plus}
+
+// Macro 98
+Function ListView_SetExtendedListViewStyleEx( hwndLV : hwnd; dwMask, dw : cint ):DWORD;
+
+{$ENDIF}
+
+CONST
+ LVM_GETEXTENDEDLISTVIEWSTYLE = (LVM_FIRST + 55);
+
+// Macro 99
+Function ListView_GetExtendedListViewStyle( hwndLV : hwnd):DWORD;
+
+CONST
+ LVS_EX_GRIDLINES = $00000001;
+ LVS_EX_SUBITEMIMAGES = $00000002;
+ LVS_EX_CHECKBOXES = $00000004;
+ LVS_EX_TRACKSELECT = $00000008;
+ LVS_EX_HEADERDRAGDROP = $00000010;
+ LVS_EX_FULLROWSELECT = $00000020; // applies to report mode only
+ LVS_EX_ONECLICKACTIVATE = $00000040;
+ LVS_EX_TWOCLICKACTIVATE = $00000080;
+{$ifdef ie4plus}
+ LVS_EX_FLATSB = $00000100;
+ LVS_EX_REGIONAL = $00000200;
+ LVS_EX_INFOTIP = $00000400; // listview does InfoTips for you
+ LVS_EX_UNDERLINEHOT = $00000800;
+ LVS_EX_UNDERLINECOLD = $00001000;
+ LVS_EX_MULTIWORKAREAS = $00002000;
+{$ENDIF}
+{$ifdef ie5plus}
+ LVS_EX_LABELTIP = $00004000; // listview unfolds partly hidden labels if it does not have infotip text
+ LVS_EX_BORDERSELECT = $00008000; // border selection style instead of highlight
+{$ENDIF} // End (_WIN32_IE >= 0x0500)
+{$ifdef win32xp}
+ LVS_EX_DOUBLEBUFFER = $00010000;
+ LVS_EX_HIDELABELS = $00020000;
+ LVS_EX_SINGLEROW = $00040000;
+ LVS_EX_SNAPTOGRID = $00080000; // Icons automatically snap to grid.
+ LVS_EX_SIMPLESELECT = $00100000; // Also changes overlay rendering to top right for icon mode.
+{$ENDIF}
+{$ifdef win32vista}
+ LVS_EX_JUSTIFYCOLUMNS = $00200000; // Icons are lined up in columns that use up the whole view area.
+ LVS_EX_TRANSPARENTBKGND = $00400000; // Background is painted by the parent via WM_PRINTCLIENT
+ LVS_EX_TRANSPARENTSHADOWTEXT = $00800000; // Enable shadow text on transparent backgrounds only (useful with bitmaps)
+ LVS_EX_AUTOAUTOARRANGE = $01000000; // Icons automatically arrange if no icon positions have been set
+ LVS_EX_HEADERINALLVIEWS = $02000000; // Display column header in all view modes
+ LVS_EX_AUTOCHECKSELECT = $08000000;
+ LVS_EX_AUTOSIZECOLUMNS = $10000000;
+ LVS_EX_COLUMNSNAPPOINTS = $40000000;
+ LVS_EX_COLUMNOVERFLOW = $80000000;
+{$endif}
+
+ LVM_GETSUBITEMRECT = (LVM_FIRST + 56);
+
+// Macro 100
+Function ListView_GetSubItemRect( hwnd : hwnd; iItem : cint;iSubItem, code :cint ;prc:LPRECT):BOOL;
+
+CONST
+ LVM_SUBITEMHITTEST = (LVM_FIRST + 57);
+
+// Macro 101
+Function ListView_SubItemHitTest( hwnd : hwnd; plvhti : LPLVHITTESTINFO):cint;
+
+CONST
+ LVM_SETCOLUMNORDERARRAY = (LVM_FIRST + 58);
+
+// Macro 102
+Function ListView_SetColumnOrderArray( hwnd : hwnd; iCount : WPARAM; pi : LPINT):BOOL;
+
+CONST
+ LVM_GETCOLUMNORDERARRAY = (LVM_FIRST + 59);
+
+// Macro 103
+Function ListView_GetColumnOrderArray( hwnd : hwnd; iCount : WPARAM; pi : LPINT):BOOL;
+
+
+CONST
+ LVM_SETHOTITEM = (LVM_FIRST + 60);
+
+// Macro 104
+Function ListView_SetHotItem( hwnd : hwnd; i : WPARAM):cint;
+
+CONST
+ LVM_GETHOTITEM = (LVM_FIRST + 61);
+
+// Macro 105
+Function ListView_GetHotItem( hwnd : hwnd):cint;
+
+CONST
+ LVM_SETHOTCURSOR = (LVM_FIRST + 62);
+
+// Macro 106
+Function ListView_SetHotCursor( hwnd : hwnd; hcur : LPARAM):HCURSOR;
+
+CONST
+ LVM_GETHOTCURSOR = (LVM_FIRST + 63);
+
+// Macro 107
+Function ListView_GetHotCursor( hwnd : hwnd):HCURSOR;
+
+CONST
+ LVM_APPROXIMATEVIEWRECT = (LVM_FIRST + 64);
+
+// Macro 108
+Function ListView_ApproximateViewRect( hwnd : hwnd; iWidth, iHeight, iCount : cint ):DWORD;
+
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+{$ifdef ie4plus}
+
+CONST
+ LV_MAX_WORKAREAS = 16;
+ LVM_SETWORKAREAS = (LVM_FIRST + 65);
+
+// Macro 109
+Function ListView_SetWorkAreas( hwnd : hwnd; nWorkAreas : cint;var prc : RECT ):BOOL;inline;
+Function ListView_SetWorkAreas( hwnd : hwnd; nWorkAreas : cint; prc : PRECT ):BOOL;inline;
+
+CONST
+ LVM_GETWORKAREAS = (LVM_FIRST + 70);
+
+// Macro 110
+Function ListView_GetWorkAreas( hwnd : hwnd; nWorkAreas : cint;var prc : RECT ):BOOL;
+
+CONST
+ LVM_GETNUMBEROFWORKAREAS = (LVM_FIRST + 73);
+
+// Macro 111
+Function ListView_GetNumberOfWorkAreas( hwnd : hwnd;var pnWorkAreas : UINT ):BOOL;
+
+CONST
+ LVM_GETSELECTIONMARK = (LVM_FIRST + 66);
+
+// Macro 112
+Function ListView_GetSelectionMark( hwnd : hwnd):cint;
+
+CONST
+ LVM_SETSELECTIONMARK = (LVM_FIRST + 67);
+
+// Macro 113
+Function ListView_SetSelectionMark( hwnd : hwnd; i : LPARAM):cint;
+
+CONST
+ LVM_SETHOVERTIME = (LVM_FIRST + 71);
+
+// Macro 114
+Function ListView_SetHoverTime( hwndLV : hwnd; dwHoverTimeMs : LPARAM):DWORD;
+
+CONST
+ LVM_GETHOVERTIME = (LVM_FIRST + 72);
+
+// Macro 115
+Function ListView_GetHoverTime( hwndLV : hwnd):DWORD;
+
+CONST
+ LVM_SETTOOLTIPS = (LVM_FIRST + 74);
+
+// Macro 116
+Function ListView_SetToolTips( hwndLV : hwnd; hwndNewHwnd : WPARAM):HWND;
+
+CONST
+ LVM_GETTOOLTIPS = (LVM_FIRST + 78);
+
+// Macro 117
+Function ListView_GetToolTips( hwndLV : hwnd):HWND;
+
+CONST
+ LVM_SORTITEMSEX = (LVM_FIRST + 81);
+
+// Macro 118
+Function ListView_SortItemsEx( hwndLV : hwnd; _pfnCompare : PFNLVCOMPARE; _lPrm : LPARAM):BOOL;
+
+TYPE
+
+ tagLVBKIMAGEA = Record
+ ulFlags : ULONG; // LVBKIF_*
+ hbm : HBITMAP;
+ pszImage : LPSTR;
+ cchImageMax : UINT;
+ xOffsetPercent : cint;
+ yOffsetPercent : cint;
+ END;
+ LVBKIMAGEA = tagLVBKIMAGEA;
+ LPLVBKIMAGEA = ^tagLVBKIMAGEA;
+ TLVBKIMAGEA = tagLVBKIMAGEA;
+ PLVBKIMAGEA = ^tagLVBKIMAGEA;
+
+ tagLVBKIMAGEW = Record
+ ulFlags : ULONG; // LVBKIF_*
+ hbm : HBITMAP;
+ pszImage : LPWSTR;
+ cchImageMax : UINT;
+ xOffsetPercent : cint;
+ yOffsetPercent : cint;
+ END;
+ LVBKIMAGEW = tagLVBKIMAGEW;
+ LPLVBKIMAGEW = ^tagLVBKIMAGEW;
+ TLVBKIMAGEW = tagLVBKIMAGEW;
+ PLVBKIMAGEW = ^tagLVBKIMAGEW;
+
+CONST
+ LVBKIF_SOURCE_NONE = $00000000;
+ LVBKIF_SOURCE_HBITMAP = $00000001;
+ LVBKIF_SOURCE_URL = $00000002;
+ LVBKIF_SOURCE_MASK = $00000003;
+ LVBKIF_STYLE_NORMAL = $00000000;
+ LVBKIF_STYLE_TILE = $00000010;
+ LVBKIF_STYLE_MASK = $00000010;
+{$ifdef win32xp}
+ LVBKIF_FLAG_TILEOFFSET = $00000100;
+ LVBKIF_TYPE_WATERMARK = $10000000;
+{$ENDIF}
+
+ LVM_SETBKIMAGEA = (LVM_FIRST + 68);
+ LVM_SETBKIMAGEW = (LVM_FIRST + 138);
+ LVM_GETBKIMAGEA = (LVM_FIRST + 69);
+ LVM_GETBKIMAGEW = (LVM_FIRST + 139);
+
+{$ifdef win32xp}
+ LVM_SETSELECTEDCOLUMN = (LVM_FIRST + 140);
+
+// Macro 119
+Procedure ListView_SetSelectedColumn( hwnd : hwnd; iCol : WPARAM);
+
+CONST
+ LVM_SETTILEWIDTH = (LVM_FIRST + 141);
+
+// Macro 120
+Procedure ListView_SetTileWidth( hwnd : hwnd; cpWidth : WPARAM);
+
+CONST
+ LV_VIEW_ICON = $0000;
+ LV_VIEW_DETAILS = $0001;
+ LV_VIEW_SMALLICON = $0002;
+ LV_VIEW_LIST = $0003;
+ LV_VIEW_TILE = $0004;
+ LV_VIEW_MAX = $0004;
+ LVM_SETVIEW = (LVM_FIRST + 142);
+
+// Macro 121
+Function ListView_SetView( hwnd : hwnd; iView : DWORD):DWORD;
+
+CONST
+ LVM_GETVIEW = (LVM_FIRST + 143);
+
+// Macro 122
+Function ListView_GetView( hwnd : hwnd):DWORD;
+
+CONST
+ LVGF_NONE = $00000000;
+ LVGF_HEADER = $00000001;
+ LVGF_FOOTER = $00000002;
+ LVGF_STATE = $00000004;
+ LVGF_ALIGN = $00000008;
+ LVGF_GROUPID = $00000010;
+
+{$ifdef win32vista}
+ LVGF_SUBTITLE = $00000100; // pszSubtitle is valid
+ LVGF_TASK = $00000200; // pszTask is valid
+ LVGF_DESCRIPTIONTOP = $00000400; // pszDescriptionTop is valid
+ LVGF_DESCRIPTIONBOTTOM = $00000800; // pszDescriptionBottom is valid
+ LVGF_TITLEIMAGE = $00001000; // iTitleImage is valid
+ LVGF_EXTENDEDIMAGE = $00002000; // iExtendedImage is valid
+ LVGF_ITEMS = $00004000; // iFirstItem and cItems are valid
+ LVGF_SUBSET = $00008000; // pszSubsetTitle is valid
+ LVGF_SUBSETITEMS = $00010000; // readonly, cItems holds count of items in visible subset, iFirstItem is valid
+{$endif}
+
+ LVGS_NORMAL = $00000000;
+ LVGS_COLLAPSED = $00000001;
+ LVGS_HIDDEN = $00000002;
+
+ LVGA_HEADER_LEFT = $00000001;
+ LVGA_HEADER_CENTER = $00000002;
+ LVGA_HEADER_RIGHT = $00000004; // Don't forget to validate exclusivity
+ LVGA_FOOTER_LEFT = $00000008;
+ LVGA_FOOTER_CENTER = $00000010;
+ LVGA_FOOTER_RIGHT = $00000020; // Don't forget to validate exclusivity
+
+TYPE
+
+ tagLVGROUP = Record
+ cbSize : UINT;
+ mask : UINT;
+ pszHeader : LPWSTR;
+ cchHeader : cint;
+ pszFooter : LPWSTR;
+ cchFooter : cint;
+ iGroupId : cint;
+ stateMask : UINT;
+ state : UINT;
+ uAlign : UINT;
+{$ifdef win32vista}
+ pszSubtitle : LPWSTR;
+ cchSubtitle : UINT;
+ pszTask : LPWSTR;
+ cchTask : UINT;
+ pszDescriptionTop : LPWSTR;
+ cchDescriptionTop : UINT;
+ pszDescriptionBottom: LPWSTR;
+ cchDescriptionBottom: UINT;
+ iTitleImage : cint;
+ iExtendedImage : cint;
+ iFirstItem : cint; // Read only
+ cItems : UINT; // Read only
+ pszSubsetTitle : LPWSTR;// NULL if group is not subset
+ cchSubsetTitle : UINT;
+{$endif}
+ END;
+ LVGROUP = tagLVGROUP;
+ PLVGROUP = ^tagLVGROUP;
+ TLVGROUP = tagLVGROUP;
+
+
+CONST
+ LVM_INSERTGROUP = (LVM_FIRST + 145);
+
+// Macro 123
+Procedure ListView_InsertGroup( hwnd : hwnd; index : WPARAM; pgrp : LPARAM);
+
+CONST
+ LVM_SETGROUPINFO = (LVM_FIRST + 147);
+
+// Macro 124
+Procedure ListView_SetGroupInfo( hwnd : hwnd; iGroupId : WPARAM; pgrp : LPARAM);
+
+CONST
+ LVM_GETGROUPINFO = (LVM_FIRST + 149);
+
+// Macro 125
+Procedure ListView_GetGroupInfo( hwnd : hwnd; iGroupId : WPARAM; pgrp : LPARAM);
+
+CONST
+ LVM_REMOVEGROUP = (LVM_FIRST + 150);
+
+// Macro 126
+Procedure ListView_RemoveGroup( hwnd : hwnd; iGroupId : WPARAM);
+
+CONST
+ LVM_MOVEGROUP = (LVM_FIRST + 151);
+
+// Macro 127
+Procedure ListView_MoveGroup( hwnd : hwnd; iGroupId : WPARAM; toIndex : LPARAM);
+
+CONST
+ LVM_MOVEITEMTOGROUP = (LVM_FIRST + 154);
+
+// Macro 128
+Procedure ListView_MoveItemToGroup( hwnd : hwnd; idItemFrom : WPARAM; idGroupTo : LPARAM);
+
+CONST
+ LVGMF_NONE = $00000000;
+ LVGMF_BORDERSIZE = $00000001;
+ LVGMF_BORDERCOLOR = $00000002;
+ LVGMF_TEXTCOLOR = $00000004;
+
+TYPE
+
+ tagLVGROUPMETRICS = Record
+ cbSize : UINT;
+ mask : UINT;
+ Left : UINT;
+ Top : UINT;
+ Right : UINT;
+ Bottom : UINT;
+ crLeft : COLORREF;
+ crTop : COLORREF;
+ crRight : COLORREF;
+ crBottom : COLORREF;
+ crHeader : COLORREF;
+ crFooter : COLORREF;
+ END;
+ LVGROUPMETRICS = tagLVGROUPMETRICS;
+ PLVGROUPMETRICS = ^tagLVGROUPMETRICS;
+ TLVGROUPMETRICS = tagLVGROUPMETRICS;
+
+CONST
+ LVM_SETGROUPMETRICS = (LVM_FIRST + 155);
+
+// Macro 129
+Procedure ListView_SetGroupMetrics( hwnd : hwnd; pGroupMetrics : LPARAM);
+
+CONST
+ LVM_GETGROUPMETRICS = (LVM_FIRST + 156);
+
+// Macro 130
+Procedure ListView_GetGroupMetrics( hwnd : hwnd; pGroupMetrics : LPARAM);
+
+CONST
+ LVM_ENABLEGROUPVIEW = (LVM_FIRST + 157);
+
+// Macro 131
+Procedure ListView_EnableGroupView( hwnd : hwnd; fEnable : WPARAM);
+
+TYPE
+ PFNLVGROUPCOMPARE = function(i,j:cint;k:pointer):cint; StdCall;
+
+CONST
+ LVM_SORTGROUPS = (LVM_FIRST + 158);
+
+// Macro 132
+Procedure ListView_SortGroups( hwnd : hwnd; _pfnGroupCompate : WPARAM; _plv : LPARAM);
+
+TYPE
+
+ tagLVINSERTGROUPSORTED = Record
+ pfnGroupCompare : PFNLVGROUPCOMPARE;
+ pvData : Pointer;
+ lvGroup : LVGROUP;
+ END;
+ LVINSERTGROUPSORTED = tagLVINSERTGROUPSORTED;
+ PLVINSERTGROUPSORTED = ^tagLVINSERTGROUPSORTED;
+ TLVINSERTGROUPSORTED = tagLVINSERTGROUPSORTED;
+
+
+CONST
+ LVM_INSERTGROUPSORTED = (LVM_FIRST + 159);
+
+// Macro 133
+Procedure ListView_InsertGroupSorted( hwnd : hwnd; structInsert : WPARAM);
+
+CONST
+ LVM_REMOVEALLGROUPS = (LVM_FIRST + 160);
+
+// Macro 134
+Procedure ListView_RemoveAllGroups( hwnd : hwnd);
+
+CONST
+ LVM_HASGROUP = (LVM_FIRST + 161);
+
+// Macro 135
+Procedure ListView_HasGroup( hwnd : hwnd; dwGroupId : DWORD );
+
+CONST
+ LVTVIF_AUTOSIZE = $00000000;
+ LVTVIF_FIXEDWIDTH = $00000001;
+ LVTVIF_FIXEDHEIGHT = $00000002;
+ LVTVIF_FIXEDSIZE = $00000003;
+{$ifdef win32vista}
+ LVTVIF_EXTENDED = $00000004;
+{$endif}
+ LVTVIM_TILESIZE = $00000001;
+ LVTVIM_COLUMNS = $00000002;
+ LVTVIM_LABELMARGIN = $00000004;
+
+
+TYPE
+
+ tagLVTILEVIEWINFO = Record
+ cbSize : UINT;
+ dwMask : DWORD; //LVTVIM_*
+ dwFlags : DWORD; //LVTVIF_*
+ sizeTile : SIZE;
+ cLines : cint;
+ rcLabelMargin : RECT;
+ END;
+ LVTILEVIEWINFO = tagLVTILEVIEWINFO;
+ PLVTILEVIEWINFO = ^tagLVTILEVIEWINFO;
+ TLVTILEVIEWINFO = tagLVTILEVIEWINFO;
+
+
+ tagLVTILEINFO = Record
+ cbSize : UINT;
+ iItem : cint;
+ cColumns : UINT;
+ puColumns : PUINT;
+ {$ifdef win32vista}
+ piColFmt : PCINT;
+ {$endif}
+ END;
+ LVTILEINFO = tagLVTILEINFO;
+ PLVTILEINFO = ^tagLVTILEINFO;
+ TLVTILEINFO = tagLVTILEINFO;
+
+
+CONST
+ LVM_SETTILEVIEWINFO = (LVM_FIRST + 162);
+
+// Macro 136
+Procedure ListView_SetTileViewInfo( hwnd : hwnd; ptvi : LPARAM);
+
+CONST
+ LVM_GETTILEVIEWINFO = (LVM_FIRST + 163);
+
+// Macro 137
+Procedure ListView_GetTileViewInfo( hwnd : hwnd; ptvi : LPARAM);
+
+CONST
+ LVM_SETTILEINFO = (LVM_FIRST + 164);
+
+// Macro 138
+Procedure ListView_SetTileInfo( hwnd : hwnd; pti : LPARAM);
+
+CONST
+ LVM_GETTILEINFO = (LVM_FIRST + 165);
+
+// Macro 139
+Procedure ListView_GetTileInfo( hwnd : hwnd; pti : LPARAM);
+
+TYPE
+
+ LVINSERTMARK = Record
+ cbSize : UINT;
+ dwFlags : DWORD;
+ iItem : cint;
+ dwReserved : DWORD;
+ END;
+ LPLVINSERTMARK = ^LVINSERTMARK;
+ TLVINSERTMARK = LVINSERTMARK;
+ PLVINSERTMARK = ^LVINSERTMARK;
+
+CONST
+ LVIM_AFTER = $00000001; // TRUE = insert After iItem, otherwise before
+
+ LVM_SETINSERTMARK = (LVM_FIRST + 166);
+
+// Macro 140
+Function ListView_SetInsertMark( hwnd : hwnd; lvim : lparam ):BOOL;
+
+CONST
+ LVM_GETINSERTMARK = (LVM_FIRST + 167);
+
+// Macro 141
+Function ListView_GetInsertMark( hwnd : hwnd; lvim : lparam ):BOOL;
+
+CONST
+ LVM_INSERTMARKHITTEST = (LVM_FIRST + 168);
+
+// Macro 142
+Function ListView_InsertMarkHitTest( hwnd : hwnd; point : LPPOINT; lvim : LPLVINSERTMARK):cint;
+
+CONST
+ LVM_GETINSERTMARKRECT = (LVM_FIRST + 169);
+
+// Macro 143
+Function ListView_GetInsertMarkRect( hwnd : hwnd; rc : LPRECT):cint;
+
+CONST
+ LVM_SETINSERTMARKCOLOR = (LVM_FIRST + 170);
+
+// Macro 144
+Function ListView_SetInsertMarkColor( hwnd : hwnd; color : COLORREF):COLORREF;
+
+CONST
+ LVM_GETINSERTMARKCOLOR = (LVM_FIRST + 171);
+
+// Macro 145
+Function ListView_GetInsertMarkColor( hwnd : hwnd):COLORREF;
+
+TYPE
+
+ tagLVSETINFOTIP = Record
+ cbSize : UINT;
+ dwFlags : DWORD;
+ pszText : LPWSTR;
+ iItem : cint;
+ iSubItem : cint;
+ END;
+ LVSETINFOTIP = tagLVSETINFOTIP;
+ PLVSETINFOTIP = ^tagLVSETINFOTIP;
+ TLVSETINFOTIP = tagLVSETINFOTIP;
+
+
+CONST
+ LVM_SETINFOTIP = (LVM_FIRST + 173);
+
+// Macro 146
+Function ListView_SetInfoTip( hwndLV : hwnd; plvInfoTip : LPARAM):BOOL;
+
+CONST
+ LVM_GETSELECTEDCOLUMN = (LVM_FIRST + 174);
+
+// Macro 147
+Function ListView_GetSelectedColumn( hwnd : hwnd):UINT;
+
+CONST
+ LVM_ISGROUPVIEWENABLED = (LVM_FIRST + 175);
+
+// Macro 148
+Function ListView_IsGroupViewEnabled( hwnd : hwnd):BOOL;
+
+CONST
+ LVM_GETOUTLINECOLOR = (LVM_FIRST + 176);
+
+// Macro 149
+Function ListView_GetOutlineColor( hwnd : hwnd):COLORREF;
+
+CONST
+ LVM_SETOUTLINECOLOR = (LVM_FIRST + 177);
+
+// Macro 150
+Function ListView_SetOutlineColor( hwnd : hwnd; color : COLORREF):COLORREF;
+
+CONST
+ LVM_CANCELEDITLABEL = (LVM_FIRST + 179);
+
+// Macro 151
+Procedure ListView_CancelEditLabel( hwnd : hwnd);
+
+// These next to methods make it easy to identify an item that can be repositioned
+// within listview. For example: Many developers use the lParam to store an identifier that is
+// unique. Unfortunatly, in order to find this item, they have to iterate through all of the items
+// in the listview. Listview will maintain a unique identifier. The upper bound is the size of a DWORD.
+
+CONST
+ LVM_MAPINDEXTOID = (LVM_FIRST + 180);
+
+// Macro 152
+Function ListView_MapIndexToID( hwnd : hwnd; index : WPARAM):UINT;
+
+CONST
+ LVM_MAPIDTOINDEX = (LVM_FIRST + 181);
+
+// Macro 153
+Function ListView_MapIDToIndex( hwnd : hwnd; id : WPARAM):UINT;
+
+const LVM_ISITEMVISIBLE = (LVM_FIRST + 182);
+
+// macro 153b
+function ListView_IsItemVisible(hwnd:hwnd; aindex:cuint):cuint;
+// (UINT)SNDMSG((hwnd), LVM_ISITEMVISIBLE, (WPARAM)(index), (LPARAM)0)
+
+{$ENDIF}
+
+{$ifdef win32vista}
+CONST
+ LVM_GETEMPTYTEXT = (LVM_FIRST + 204);
+ LVM_GETFOOTERRECT = (LVM_FIRST + 205);
+ LVM_GETFOOTERINFO = (LVM_FIRST + 206);
+ LVM_GETFOOTERITEMRECT = (LVM_FIRST + 207);
+ LVM_GETFOOTERITEM = (LVM_FIRST + 208);
+ LVM_GETITEMINDEXRECT = (LVM_FIRST + 209);
+ LVM_SETITEMINDEXSTATE = (LVM_FIRST + 210);
+ LVM_GETNEXTITEMINDEX = (LVM_FIRST + 211);
+
+// footer flags
+ LVFF_ITEMCOUNT = $00000001;
+
+// footer item flags
+ LVFIF_TEXT = $00000001;
+ LVFIF_STATE = $00000002;
+
+// footer item state
+ LVFIS_FOCUSED = $0001;
+
+TYPE
+ tagLVFOOTERINFO = Record
+ mask : CUINT; // LVFF_*
+ pszText : LPWSTR;
+ cchTextMax: CINT;
+ cItems : CUINT;
+ end;
+
+ LVFOOTERINFO = tagLVFOOTERINFO;
+ LPLVFOOTERINFO = ^tagLVFOOTERINFO;
+ TLVFOOTERINFO = tagLVFOOTERINFO;
+ PLVFOOTERINFO = LPLVFOOTERINFO;
+
+
+ tagLVFOOTERITEM = Record
+ mask : CUINT; // LVFIF_*
+ iItem : CINT;
+ pszText : LPWSTR;
+ cchTextMax: CINT;
+ state : CUINT; // LVFIS_*
+ stateMask : CUINT; // LVFIS_*
+ end;
+
+ LVFOOTERITEM = tagLVFOOTERITEM;
+ LPLVFOOTERITEM = ^tagLVFOOTERITEM;
+ TLVFOOTERITEM = tagLVFOOTERITEM;
+ PLVFOOTERITEM = LPLVFOOTERITEM;
+
+// supports a single item in multiple groups.
+ tagLVITEMINDEX = Record
+ iItem : CINT; // listview item index
+ iGroup : CINT; // group index (must be -1 if group view is not enabled)
+ end;
+ LVITEMINDEX = tagLVITEMINDEX;
+ PLVITEMINDEX = ^tagLVITEMINDEX;
+ tLVITEMINDEX = TAGLVITEMINDEX;
+
+
+function ListView_SetGroupHeaderImageList(hwnd:HWNd;himl:HIMAGELIST):HIMAGELIST;
+
+function ListView_GetGroupHeaderImageList(hwnd:HWND):HIMAGELIST;
+
+function ListView_GetEmptyText(hwnd:HWND;pszText:LPWSTR; cchText:CUINT):BOOL;
+
+function ListView_GetFooterRect(hwnd:HWND; prc:PRECT):BOOL;
+
+function ListView_GetFooterInfo(hwnd:HWND;plvfi: LPLVFOOTERINFO ):BOOL;
+
+function ListView_GetFooterItemRect(hwnd:HWND;iItem:CUINT;prc:PRECT):BOOL;
+
+function ListView_GetFooterItem(hwnd:HWND;iItem:CUINT; pfi:PLVFOOTERITEM):BOOL;
+
+function ListView_GetItemIndexRect(hwnd:hwnd; plvii:PLVITEMINDEX; iSubItem:clong; code:clong; prc:LPRECT) :BOOL;
+
+function ListView_SetItemIndexState(hwndLV:HWND; plvii:PLVITEMINDEX; data:CUINT; mask:CUINT):HRESULT;
+
+function ListView_GetNextItemIndex(hwnd:HWND;plvii:PLVITEMINDEX; flags:LPARAM):BOOL;
+
+{$endif}
+
+Type
+
+{$IFDEF UNICODE}
+ LVBKIMAGE = LVBKIMAGEW;
+ LPLVBKIMAGE = LPLVBKIMAGEW;
+CONST
+ LVM_SETBKIMAGE = LVM_SETBKIMAGEW;
+ LVM_GETBKIMAGE = LVM_GETBKIMAGEW;
+{$ELSE}
+ LVBKIMAGE = LVBKIMAGEA;
+ LPLVBKIMAGE = LPLVBKIMAGEA;
+CONST
+ LVM_SETBKIMAGE = LVM_SETBKIMAGEA;
+ LVM_GETBKIMAGE = LVM_GETBKIMAGEA;
+{$ENDIF}
+
+
+// Macro 154
+Function ListView_SetBkImage( hwnd : hwnd; plvbki : LPARAM):BOOL;
+
+// Macro 155
+Function ListView_GetBkImage( hwnd : hwnd; plvbki : LPARAM):BOOL;
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+TYPE
+
+ tagNMLISTVIEW = Record
+ hdr : NMHDR;
+ iItem : cint;
+ iSubItem : cint;
+ uNewState : UINT;
+ uOldState : UINT;
+ uChanged : UINT;
+ ptAction : POINT;
+ lParam : LPARAM;
+ END;
+ NMLISTVIEW = tagNMLISTVIEW;
+ LPNMLISTVIEW = ^tagNMLISTVIEW;
+ TNMLISTVIEW = tagNMLISTVIEW;
+ PNMLISTVIEW = ^tagNMLISTVIEW;
+
+{$ifdef IE4plus}
+// NMITEMACTIVATE is used instead of NMLISTVIEW in IE >= 0x400
+// therefore all the fields are the same except for extra uKeyFlags
+// they are used to store key flags at the time of the single click with
+// delayed activation - because by the time the timer goes off a user may
+// not hold the keys (shift, ctrl) any more
+ tagNMITEMACTIVATE = Record
+ hdr : NMHDR;
+ iItem : cint;
+ iSubItem : cint;
+ uNewState : UINT;
+ uOldState : UINT;
+ uChanged : UINT;
+ ptAction : POINT;
+ lParam : LPARAM;
+ uKeyFlags : UINT;
+ END;
+ NMITEMACTIVATE = tagNMITEMACTIVATE;
+ LPNMITEMACTIVATE = ^tagNMITEMACTIVATE;
+ TNMITEMACTIVATE = tagNMITEMACTIVATE;
+ PNMITEMACTIVATE = ^tagNMITEMACTIVATE;
+
+// key flags stored in uKeyFlags
+
+CONST
+ LVKF_ALT = $0001;
+ LVKF_CONTROL = $0002;
+ LVKF_SHIFT = $0004;
+{$ENDIF} //(_WIN32_IE >= 0x0400)
+Type
+
+{$ifdef ie3plus}
+ LPNM_LISTVIEW = LPNMLISTVIEW;
+ NM_LISTVIEW = NMLISTVIEW;
+{$ELSE}
+ tagNMLISTVIEW = _NM_LISTVIEW;
+ NMLISTVIEW = NM_LISTVIEW;
+ LPNMLISTVIEW = LPNM_LISTVIEW;
+{$ENDIF}
+
+
+{$ifdef ie3plus}
+// #define NMLVCUSTOMDRAW_V3_SIZE CCSIZEOF_STRUCT(NMLVCUSTOMDRW, clrTextBk)
+
+TYPE
+
+ tagNMLVCUSTOMDRAW = Record
+ nmcd : NMCUSTOMDRAW;
+ clrText : COLORREF;
+ clrTextBk : COLORREF;
+{$ifdef ie4plus}
+ iSubItem : cint;
+{$ENDIF}
+{$ifdef win32xp}
+ dwItemType : DWORD;
+
+ clrFace : COLORREF;
+ iIconEffect : cint;
+ iIconPhase : cint;
+ iPartId : cint;
+ iStateId : cint;
+
+ rcText : RECT;
+ uAlign : UINT; // Alignment. Use LVGA_HEADER_CENTER, LVGA_HEADER_RIGHT, LVGA_HEADER_LEFT
+{$ENDIF}
+ END;
+ NMLVCUSTOMDRAW = tagNMLVCUSTOMDRAW;
+ LPNMLVCUSTOMDRAW = ^tagNMLVCUSTOMDRAW;
+ TNMLVCUSTOMDRAW = tagNMLVCUSTOMDRAW;
+ PNMLVCUSTOMDRAW = ^tagNMLVCUSTOMDRAW;
+
+
+// dwItemType
+
+CONST
+ LVCDI_ITEM = $00000000;
+ LVCDI_GROUP = $00000001;
+
+// ListView custom draw return values
+ LVCDRF_NOSELECT = $00010000;
+ LVCDRF_NOGROUPFRAME = $00020000;
+
+TYPE
+
+ tagNMLVCACHEHINT = Record
+ hdr : NMHDR;
+ iFrom : cint;
+ iTo : cint;
+ END;
+ NMLVCACHEHINT = tagNMLVCACHEHINT;
+ LPNMLVCACHEHINT = ^tagNMLVCACHEHINT;
+ TNMLVCACHEHINT = tagNMLVCACHEHINT;
+ PNMLVCACHEHINT = ^tagNMLVCACHEHINT;
+
+
+ LPNM_CACHEHINT = LPNMLVCACHEHINT;
+ PNM_CACHEHINT = LPNMLVCACHEHINT;
+
+ NM_CACHEHINT = NMLVCACHEHINT;
+
+ tagNMLVFINDITEMA = Record
+ hdr : NMHDR;
+ iStart : cint;
+ lvfi : LVFINDINFOA;
+ END;
+ NMLVFINDITEMA = tagNMLVFINDITEMA;
+ LPNMLVFINDITEMA = ^tagNMLVFINDITEMA;
+ TNMLVFINDITEMA = tagNMLVFINDITEMA;
+ PNMLVFINDITEMA = ^tagNMLVFINDITEMA;
+
+
+ tagNMLVFINDITEMW = Record
+ hdr : NMHDR;
+ iStart : cint;
+ lvfi : LVFINDINFOW;
+ END;
+ NMLVFINDITEMW = tagNMLVFINDITEMW;
+ LPNMLVFINDITEMW = ^tagNMLVFINDITEMW;
+ TNMLVFINDITEMW = tagNMLVFINDITEMW;
+ PNMLVFINDITEMW = ^tagNMLVFINDITEMW;
+
+
+ PNM_FINDITEMA = LPNMLVFINDITEMA;
+ LPNM_FINDITEMA = LPNMLVFINDITEMA;
+ NM_FINDITEMA = NMLVFINDITEMA;
+
+ PNM_FINDITEMW = LPNMLVFINDITEMW;
+ LPNM_FINDITEMW = LPNMLVFINDITEMW;
+ NM_FINDITEMW = NMLVFINDITEMW;
+
+{$IFDEF UNICODE}
+ PNM_FINDITEM = PNM_FINDITEMW;
+ LPNM_FINDITEM = LPNM_FINDITEMW;
+ NM_FINDITEM = NM_FINDITEMW;
+ NMLVFINDITEM = NMLVFINDITEMW;
+ LPNMLVFINDITEM = LPNMLVFINDITEMW;
+{$ELSE}
+ PNM_FINDITEM = PNM_FINDITEMA;
+ LPNM_FINDITEM = LPNM_FINDITEMA;
+ NM_FINDITEM = NM_FINDITEMA;
+ NMLVFINDITEM = NMLVFINDITEMA;
+ LPNMLVFINDITEM = LPNMLVFINDITEMA;
+{$ENDIF}
+ PNMLVFindItem = LPNMLVFINDITEM;
+ TNMLVFindItem = NMLVFINDITEM;
+
+ tagNMLVODSTATECHANGE = Record
+ hdr : NMHDR;
+ iFrom : cint;
+ iTo : cint;
+ uNewState : UINT;
+ uOldState : UINT;
+ END;
+ NMLVODSTATECHANGE = tagNMLVODSTATECHANGE;
+ LPNMLVODSTATECHANGE = ^tagNMLVODSTATECHANGE;
+ TNMLVODSTATECHANGE = tagNMLVODSTATECHANGE;
+ PNMLVODSTATECHANGE = ^tagNMLVODSTATECHANGE;
+
+
+ PNM_ODSTATECHANGE = LPNMLVODSTATECHANGE;
+ LPNM_ODSTATECHANGE = LPNMLVODSTATECHANGE;
+
+
+ NM_ODSTATECHANGE = NMLVODSTATECHANGE;
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+CONST
+ LVN_ITEMCHANGING = (LVN_FIRST-0);
+ LVN_ITEMCHANGED = (LVN_FIRST-1);
+ LVN_INSERTITEM = (LVN_FIRST-2);
+ LVN_DELETEITEM = (LVN_FIRST-3);
+ LVN_DELETEALLITEMS = (LVN_FIRST-4);
+ LVN_BEGINLABELEDITA = (LVN_FIRST-5);
+ LVN_BEGINLABELEDITW = (LVN_FIRST-75);
+ LVN_ENDLABELEDITA = (LVN_FIRST-6);
+ LVN_ENDLABELEDITW = (LVN_FIRST-76);
+ LVN_COLUMNCLICK = (LVN_FIRST-8);
+ LVN_BEGINDRAG = (LVN_FIRST-9);
+ LVN_BEGINRDRAG = (LVN_FIRST-11);
+
+{$ifdef ie3plus}
+ LVN_ODCACHEHINT = (LVN_FIRST-13);
+ LVN_ODFINDITEMA = (LVN_FIRST-52);
+ LVN_ODFINDITEMW = (LVN_FIRST-79);
+
+ LVN_ITEMACTIVATE = (LVN_FIRST-14);
+ LVN_ODSTATECHANGED = (LVN_FIRST-15);
+
+Const
+{$IFDEF UNICODE}
+ LVN_ODFINDITEM = LVN_ODFINDITEMW;
+{$ELSE}
+ LVN_ODFINDITEM = LVN_ODFINDITEMA;
+{$ENDIF}
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+
+CONST
+{$ifdef ie4plus}
+ LVN_HOTTRACK = (LVN_FIRST-21);
+{$ENDIF}
+
+ LVN_GETDISPINFOA = (LVN_FIRST-50);
+ LVN_GETDISPINFOW = (LVN_FIRST-77);
+ LVN_SETDISPINFOA = (LVN_FIRST-51);
+ LVN_SETDISPINFOW = (LVN_FIRST-78);
+
+Const
+{$IFDEF UNICODE}
+ LVN_BEGINLABELEDIT = LVN_BEGINLABELEDITW;
+ LVN_ENDLABELEDIT = LVN_ENDLABELEDITW;
+ LVN_GETDISPINFO = LVN_GETDISPINFOW;
+ LVN_SETDISPINFO = LVN_SETDISPINFOW;
+{$ELSE}
+ LVN_BEGINLABELEDIT = LVN_BEGINLABELEDITA;
+ LVN_ENDLABELEDIT = LVN_ENDLABELEDITA;
+ LVN_GETDISPINFO = LVN_GETDISPINFOA;
+ LVN_SETDISPINFO = LVN_SETDISPINFOA;
+{$ENDIF}
+
+CONST
+ LVIF_DI_SETITEM = $1000;
+
+TYPE
+
+ tagLVDISPINFO = Record
+ hdr : NMHDR;
+ item : LVITEMA;
+ END;
+ NMLVDISPINFOA = tagLVDISPINFO;
+ LPNMLVDISPINFOA = ^tagLVDISPINFO;
+ TLVDISPINFO = tagLVDISPINFO;
+ PLVDISPINFO = ^tagLVDISPINFO;
+
+
+ tagLVDISPINFOW = Record
+ hdr : NMHDR;
+ item : LVITEMW;
+ END;
+ NMLVDISPINFOW = tagLVDISPINFOW;
+ LPNMLVDISPINFOW = ^tagLVDISPINFOW;
+ TLVDISPINFOW = tagLVDISPINFOW;
+ PLVDISPINFOW = ^tagLVDISPINFOW;
+
+
+{$IFDEF UNICODE}
+ NMLVDISPINFO = NMLVDISPINFOW;
+{$ELSE}
+ NMLVDISPINFO = NMLVDISPINFOA;
+{$ENDIF}
+
+{$ifdef ie3plus}
+ LV_DISPINFOA = NMLVDISPINFOA;
+ LV_DISPINFOW = NMLVDISPINFOW;
+{$ELSE}
+ tagLVDISPINFO = _LV_DISPINFO;
+ NMLVDISPINFOA = LV_DISPINFOA;
+ tagLVDISPINFOW = _LV_DISPINFOW;
+ NMLVDISPINFOW = LV_DISPINFOW;
+{$ENDIF}
+
+
+ LV_DISPINFO = NMLVDISPINFO;
+
+CONST
+ LVN_KEYDOWN = (LVN_FIRST-55);
+
+
+
+{$IFDEF _WIN32}
+// include <pshpack1.h>
+{$ENDIF}
+
+TYPE
+ tagLVKEYDOWN = Record
+ hdr : NMHDR;
+ wVKey : WORD;
+ flags : UINT;
+ END;
+ NMLVKEYDOWN = tagLVKEYDOWN;
+ LPNMLVKEYDOWN = ^tagLVKEYDOWN;
+ TLVKEYDOWN = tagLVKEYDOWN;
+ PLVKEYDOWN = ^tagLVKEYDOWN;
+
+
+{$IFDEF _WIN32}
+//include <poppack.h>
+{$ENDIF}
+
+{$ifdef ie3plus}
+CONST
+ LVN_MARQUEEBEGIN = (LVN_FIRST-56);
+{$ENDIF}
+
+{$ifdef win32vista}
+Type
+ tagNMLVLIN = Record
+ hdr: NMHDR;
+ link: LITEM;
+ iItem: cint;
+ iSubItem: cint;
+ end;
+ NMLVLINK = tagNMLVLIN;
+ TNMLVLINK = tagNMLVLIN;
+ PNMLVLINK = ^tagNMLVLIN;
+{$endif}
+
+{$ifdef ie4plus}
+TYPE
+
+ tagNMLVGETINFOTIPA = Record
+ hdr : NMHDR;
+ dwFlags : DWORD;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iItem : cint;
+ iSubItem : cint;
+ lParam : LPARAM;
+ END;
+ NMLVGETINFOTIPA = tagNMLVGETINFOTIPA;
+ LPNMLVGETINFOTIPA = ^tagNMLVGETINFOTIPA;
+ TNMLVGETINFOTIPA = tagNMLVGETINFOTIPA;
+ PNMLVGETINFOTIPA = ^tagNMLVGETINFOTIPA;
+
+
+ tagNMLVGETINFOTIPW = Record
+ hdr : NMHDR;
+ dwFlags : DWORD;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iItem : cint;
+ iSubItem : cint;
+ lParam : LPARAM;
+ END;
+ NMLVGETINFOTIPW = tagNMLVGETINFOTIPW;
+ LPNMLVGETINFOTIPW = ^tagNMLVGETINFOTIPW;
+ TNMLVGETINFOTIPW = tagNMLVGETINFOTIPW;
+ PNMLVGETINFOTIPW = ^tagNMLVGETINFOTIPW;
+
+{$ifdef ie3plus}
+ LV_KEYDOWN = NMLVKEYDOWN;
+{$ELSE}
+ tagLVKEYDOWN = _LV_KEYDOWN;
+ NMLVKEYDOWN = LV_KEYDOWN;
+{$ENDIF}
+
+
+// NMLVGETINFOTIPA.dwFlag values
+
+CONST
+ LVGIT_UNFOLDED = $0001;
+
+ LVN_GETINFOTIPA = (LVN_FIRST-57);
+ LVN_GETINFOTIPW = (LVN_FIRST-58);
+ LVN_INCREMENTALSEARCHA = (LVN_FIRST-62);
+ LVN_INCREMENTALSEARCHW = (LVN_FIRST-63);
+
+ LVNSCH_DEFAULT = -1;
+ LVNSCH_ERROR = -2;
+ LVNSCH_IGNORE = -3;
+
+{$ifdef win32vista}
+ LVN_COLUMNDROPDOWN = (LVN_FIRST-64);
+ LVN_COLUMNOVERFLOWCLICK = (LVN_FIRST-66);
+{$endif}
+
+Const
+{$IFDEF UNICODE}
+ LVN_GETINFOTIP = LVN_GETINFOTIPW;
+type
+ NMLVGETINFOTIP = NMLVGETINFOTIPW;
+ LPNMLVGETINFOTIP = LPNMLVGETINFOTIPW;
+{$ELSE}
+ LVN_GETINFOTIP = LVN_GETINFOTIPA;
+type
+ NMLVGETINFOTIP = NMLVGETINFOTIPA;
+ LPNMLVGETINFOTIP = LPNMLVGETINFOTIPA;
+{$ENDIF}
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+
+{$ifdef win32xp} // actually 2003
+ tagNMLVSCROLL = Record
+ hdr : NMHDR;
+ dx : cint;
+ dy : cint;
+ END;
+ NMLVSCROLL = tagNMLVSCROLL;
+ LPNMLVSCROLL = ^tagNMLVSCROLL;
+ TNMLVSCROLL = tagNMLVSCROLL;
+ PNMLVSCROLL = ^tagNMLVSCROLL;
+
+
+CONST
+ LVN_BEGINSCROLL = (LVN_FIRST-80);
+ LVN_ENDSCROLL = (LVN_FIRST-81);
+// {$ENDIF}
+
+{$ifdef win32vista}
+ LVN_LINKCLICK = (LVN_FIRST-84);
+ LVN_GETEMPTYMARKUP = (LVN_FIRST-87);
+
+ EMF_CENTERED = $00000001; // render markup centered in the listview area
+
+Type
+ tagNMLVEMPTYMARKUP = Record
+ hdr : NMHDR;
+ // out params from client back to listview
+ dwFlags :DWORD; // EMF_*
+ szMarkup : array[0..L_MAX_URL_LENGTH-1] of wchar; // markup displayed
+ end;
+ NMLVEMPTYMARKUP = tagNMLVEMPTYMARKUP;
+ TNMLVEMPTYMARKUP = tagNMLVEMPTYMARKUP;
+ PNMLVEMPTYMARKUP = ^tagNMLVEMPTYMARKUP;
+
+{$endif}
+
+{$ENDIF} // NOLISTVIEW
+
+//====== TREEVIEW CONTROL =====================================================
+
+{$IFNDEF NOTREEVIEW}
+
+CONST
+{$IFDEF _WIN32}
+ WC_TREEVIEWA = 'SysTreeView32';
+ WC_TREEVIEWW = {L}'SysTreeView32';
+
+{$IFDEF UNICODE}
+ WC_TREEVIEW = WC_TREEVIEWW;
+{$ELSE}
+ WC_TREEVIEW = WC_TREEVIEWA;
+{$ENDIF}
+{$ELSE}
+ WC_TREEVIEW = 'SysTreeView';
+{$ENDIF}
+
+// begin_r_commctrl
+
+ TVS_HASBUTTONS = $0001;
+ TVS_HASLINES = $0002;
+ TVS_LINESATROOT = $0004;
+ TVS_EDITLABELS = $0008;
+ TVS_DISABLEDRAGDROP = $0010;
+ TVS_SHOWSELALWAYS = $0020;
+{$ifdef ie3plus}
+ TVS_RTLREADING = $0040;
+
+ TVS_NOTOOLTIPS = $0080;
+ TVS_CHECKBOXES = $0100;
+ TVS_TRACKSELECT = $0200;
+{$ifdef ie4plus}
+ TVS_SINGLEEXPAND = $0400;
+ TVS_INFOTIP = $0800;
+ TVS_FULLROWSELECT = $1000;
+ TVS_NOSCROLL = $2000;
+ TVS_NONEVENHEIGHT = $4000;
+{$ENDIF}
+{$ifdef ie5plus}
+ TVS_NOHSCROLL = $8000; // TVS_NOSCROLL overrides this
+{$ENDIF}
+{$ifdef win32vista}
+ TVS_EX_MULTISELECT = $0002;
+ TVS_EX_DOUBLEBUFFER = $0004;
+ TVS_EX_NOINDENTSTATE = $0008;
+ TVS_EX_RICHTOOLTIP = $0010;
+ TVS_EX_AUTOHSCROLL = $0020;
+ TVS_EX_FADEINOUTEXPANDOS = $0040;
+ TVS_EX_PARTIALCHECKBOXES = $0080;
+ TVS_EX_EXCLUSIONCHECKBOXES = $0100;
+ TVS_EX_DIMMEDCHECKBOXES = $0200;
+ TVS_EX_DRAWIMAGEASYNC = $0400;
+{$endif}
+{$ENDIF}
+
+// end_r_commctrl
+
+TYPE
+ HTREEITEM = ^TREEITEM;
+
+CONST
+ TVIF_TEXT = $0001;
+ TVIF_IMAGE = $0002;
+ TVIF_PARAM = $0004;
+ TVIF_STATE = $0008;
+ TVIF_HANDLE = $0010;
+ TVIF_SELECTEDIMAGE = $0020;
+ TVIF_CHILDREN = $0040;
+{$ifdef ie4plus}
+ TVIF_INTEGRAL = $0080;
+{$ENDIF}
+{$ifdef win32vista}
+ TVIF_STATEEX = $0100;
+ TVIF_EXPANDEDIMAGE = $0200;
+{$endif}
+ TVIS_SELECTED = $0002;
+ TVIS_CUT = $0004;
+ TVIS_DROPHILITED = $0008;
+ TVIS_BOLD = $0010;
+ TVIS_EXPANDED = $0020;
+ TVIS_EXPANDEDONCE = $0040;
+{$ifdef ie3plus}
+ TVIS_EXPANDPARTIAL = $0080;
+{$ENDIF}
+
+ TVIS_OVERLAYMASK = $0F00;
+ TVIS_STATEIMAGEMASK = $F000;
+ TVIS_USERMASK = $F000;
+
+// IE6
+ TVIS_EX_FLAT = $0001;
+{$ifdef win32vista}
+ TVIS_EX_DISABLED = $0002;
+{$endif}
+ TVIS_EX_ALL = $0002;
+Type
+
+// Structure for TreeView's NM_TVSTATEIMAGECHANGING notification
+ tagNMTVSTATEIMAGECHANGING = Record
+ hdr : NMHDR;
+ hti : HTREEITEM;
+ iOldStateImageIndex : cint;
+ iNewStateImageIndex : cint;
+ end;
+ NMTVSTATEIMAGECHANGING = tagNMTVSTATEIMAGECHANGING;
+ LPNMTVSTATEIMAGECHANGING = ^tagNMTVSTATEIMAGECHANGING;
+
+Const
+ I_CHILDRENCALLBACK = (-1);
+Type
+ tagTVITEMA = Record
+ mask : UINT;
+ hItem : HTREEITEM;
+ state : UINT;
+ stateMask : UINT;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ iSelectedImage : cint;
+ cChildren : cint;
+ lParam : LPARAM;
+{$ifdef ie6plus}
+ uStateEx : cUINT;
+ hwnd : HWND;
+ iExpandedImage : cint;
+{$endif}
+{$ifdef NTDDI_WIN7}
+ iPadding : cint;
+{$endif}
+ END;
+ TVITEMA = tagTVITEMA;
+ LPTVITEMA = ^tagTVITEMA;
+ TTVITEMA = tagTVITEMA;
+ PTVITEMA = ^tagTVITEMA;
+
+
+ tagTVITEMW = Record
+ mask : UINT;
+ hItem : HTREEITEM;
+ state : UINT;
+ stateMask : UINT;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ iSelectedImage : cint;
+ cChildren : cint;
+ lParam : LPARAM;
+{$ifdef ie6plus}
+ uStateEx : cUINT;
+ hwnd : HWND;
+ iExpandedImage : cint;
+{$endif}
+{$ifdef NTDDI_WIN7}
+ iPadding : cint;
+{$endif}
+ END;
+ TVITEMW = tagTVITEMW;
+ LPTVITEMW = ^tagTVITEMW;
+ TTVITEMW = tagTVITEMW;
+ PTVITEMW = ^tagTVITEMW;
+
+
+{$ifdef ie4plus}
+// only used for Get and Set messages. no notifies
+ tagTVITEMEXA = Record
+ mask : UINT;
+ hItem : HTREEITEM;
+ state : UINT;
+ stateMask : UINT;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ iSelectedImage : cint;
+ cChildren : cint;
+ lParam : LPARAM;
+ iIntegral : cint;
+ END;
+ TVITEMEXA = tagTVITEMEXA;
+ LPTVITEMEXA = ^tagTVITEMEXA;
+ TTVITEMEXA = tagTVITEMEXA;
+ PTVITEMEXA = ^tagTVITEMEXA;
+
+// only used for Get and Set messages. no notifies
+ tagTVITEMEXW = Record
+ mask : UINT;
+ hItem : HTREEITEM;
+ state : UINT;
+ stateMask : UINT;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ iSelectedImage : cint;
+ cChildren : cint;
+ lParam : LPARAM;
+ iIntegral : cint;
+ END;
+ TVITEMEXW = tagTVITEMEXW;
+ LPTVITEMEXW = ^tagTVITEMEXW;
+ TTVITEMEXW = tagTVITEMEXW;
+ PTVITEMEXW = ^tagTVITEMEXW;
+
+
+TYPE
+{$ifdef ie3plus}
+ LPTV_ITEMW = LPTVITEMW;
+ LPTV_ITEMA = LPTVITEMA;
+ TV_ITEMW = TVITEMW;
+ TV_ITEMA = TVITEMA;
+{$ELSE}
+ tagTVITEMA = _TV_ITEMA;
+ TVITEMA = TV_ITEMA;
+ LPTVITEMA = LPTV_ITEMA;
+ tagTVITEMW = _TV_ITEMW;
+ TVITEMW = TV_ITEMW;
+ LPTVITEMW = LPTV_ITEMW;
+{$ENDIF}
+ TTVItem = TVITEMA;
+ PTVItem = LPTVITEMA;
+
+
+
+
+
+{$IFDEF UNICODE}
+ TVITEMEX = TVITEMEXW;
+ LPTVITEMEX = LPTVITEMEXW;
+{$ELSE}
+ TVITEMEX = TVITEMEXA;
+ LPTVITEMEX = LPTVITEMEXA;
+{$ENDIF} // UNICODE
+
+
+{$ENDIF}
+
+{$IFDEF UNICODE}
+ TVITEM = TVITEMW;
+ LPTVITEM = LPTVITEMW;
+{$ELSE}
+ TVITEM = TVITEMA;
+ LPTVITEM = LPTVITEMA;
+{$ENDIF}
+
+ LPTV_ITEM = LPTVITEM;
+ TV_ITEM = TVITEM;
+
+CONST
+ TVI_ROOT = HTREEITEM(ULONG_PTR(-$10000));
+ TVI_FIRST = HTREEITEM(ULONG_PTR(-$0FFFF));
+ TVI_LAST = HTREEITEM(ULONG_PTR(-$0FFFE));
+ TVI_SORT = HTREEITEM(ULONG_PTR(-$0FFFD));
+
+
+
+// #define TVINSERTSTRUCTA_V1_SIZE CCSIZEOF_STRUCT(TVINSERTSTRUCTA, item)
+// #define TVINSERTSTRUCTW_V1_SIZE CCSIZEOF_STRUCT(TVINSERTSTRUCTW, item)
+Type
+ tagTVINSERTSTRUCTA = Record
+ hParent : HTREEITEM;
+ hInsertAfter : HTREEITEM;
+{$ifdef ie4plus}
+ case boolean of
+ false: (itemex : TVITEMEXA);
+ True: (item : TV_ITEMA);
+{$ELSE}
+ item : TV_ITEMA;
+{$ENDIF}
+ END;
+ TVINSERTSTRUCTA = tagTVINSERTSTRUCTA;
+ LPTVINSERTSTRUCTA = ^tagTVINSERTSTRUCTA;
+ TTVINSERTSTRUCTA = tagTVINSERTSTRUCTA;
+ PTVINSERTSTRUCTA = ^tagTVINSERTSTRUCTA;
+ TTVINSERTSTRUCT = TTVINSERTSTRUCTA;
+ PTVINSERTSTRUCT = PTVINSERTSTRUCTA;
+
+
+ tagTVINSERTSTRUCTW = Record
+ hParent : HTREEITEM;
+ hInsertAfter : HTREEITEM;
+{$ifdef ie4plus}
+ case boolean of
+ false: (itemex : TVITEMEXW);
+ True: (item : TV_ITEMW);
+{$ELSE}
+ item : TV_ITEMW;
+{$ENDIF}
+ END;
+ TVINSERTSTRUCTW = tagTVINSERTSTRUCTW;
+ LPTVINSERTSTRUCTW = ^tagTVINSERTSTRUCTW;
+ TTVINSERTSTRUCTW = tagTVINSERTSTRUCTW;
+ PTVINSERTSTRUCTW = ^tagTVINSERTSTRUCTW;
+
+
+{$IFDEF UNICODE}
+ TVINSERTSTRUCT = TVINSERTSTRUCTW;
+ LPTVINSERTSTRUCT = LPTVINSERTSTRUCTW;
+// TVINSERTSTRUCT_V1_SIZE = TVINSERTSTRUCTW_V1_SIZE;
+{$ELSE}
+ TVINSERTSTRUCT = TVINSERTSTRUCTA;
+ LPTVINSERTSTRUCT = LPTVINSERTSTRUCTA;
+// TVINSERTSTRUCT_V1_SIZE = TVINSERTSTRUCTA_V1_SIZE;
+{$ENDIF}
+CONST
+ TVM_INSERTITEMA = (TV_FIRST + 0);
+ TVM_INSERTITEMW = (TV_FIRST + 50);
+{$IFDEF UNICODE}
+ TVM_INSERTITEM = TVM_INSERTITEMW;
+{$ELSE}
+ TVM_INSERTITEM = TVM_INSERTITEMA;
+{$ENDIF}
+
+TYPE
+{$ifdef ie3plus}
+ LPTV_INSERTSTRUCTA = LPTVINSERTSTRUCTA;
+ LPTV_INSERTSTRUCTW = LPTVINSERTSTRUCTW;
+ TV_INSERTSTRUCTA = TVINSERTSTRUCTA;
+ TV_INSERTSTRUCTW = TVINSERTSTRUCTW;
+{$ELSE}
+ tagTVINSERTSTRUCTA = _TV_INSERTSTRUCTA;
+ TVINSERTSTRUCTA = TV_INSERTSTRUCTA;
+ LPTVINSERTSTRUCTA = LPTV_INSERTSTRUCTA;
+ tagTVINSERTSTRUCTW = _TV_INSERTSTRUCTW;
+ TVINSERTSTRUCTW = TV_INSERTSTRUCTW;
+ LPTVINSERTSTRUCTW = LPTV_INSERTSTRUCTW;
+{$ENDIF}
+
+
+ TV_INSERTSTRUCT = TVINSERTSTRUCT;
+ LPTV_INSERTSTRUCT = LPTVINSERTSTRUCT;
+
+
+// Macro 156
+Function TreeView_InsertItem( hwnd : hwnd; lpis : LPTV_INSERTSTRUCT):HTREEITEM;inline;
+Function TreeView_InsertItem( hwnd : hwnd; const lpis : TV_INSERTSTRUCT):HTREEITEM;inline;
+
+CONST
+ TVM_DELETEITEM = (TV_FIRST + 1);
+
+// Macro 157
+Function TreeView_DeleteItem( hwnd : hwnd; hitem : HTREEITEM):BOOL;
+
+// Macro 158
+Function TreeView_DeleteAllItems( hwnd : hwnd):BOOL;
+
+CONST
+ TVM_EXPAND = (TV_FIRST + 2);
+
+// Macro 159
+Function TreeView_Expand( hwnd : hwnd; hitem : HTREEITEM; code : WPARAM):BOOL;
+
+CONST
+ TVE_COLLAPSE = $0001;
+ TVE_EXPAND = $0002;
+ TVE_TOGGLE = $0003;
+{$ifdef ie3plus}
+ TVE_EXPANDPARTIAL = $4000;
+{$ENDIF}
+ TVE_COLLAPSERESET = $8000;
+
+
+ TVM_GETITEMRECT = (TV_FIRST + 4);
+
+// Macro 160
+Function TreeView_GetItemRect( hwnd : hwnd; hitem: HTREEITEM; code : WPARAM; prc : pRECT):BOOL;inline;
+Function TreeView_GetItemRect( hwnd : hwnd; hitem: HTREEITEM; var prc : TRECT;code : Bool):BOOL;inline;
+
+CONST
+ TVM_GETCOUNT = (TV_FIRST + 5);
+
+// Macro 161
+Function TreeView_GetCount( hwnd : hwnd):UINT;
+
+CONST
+ TVM_GETINDENT = (TV_FIRST + 6);
+
+// Macro 162
+Function TreeView_GetIndent( hwnd : hwnd):UINT;
+
+CONST
+ TVM_SETINDENT = (TV_FIRST + 7);
+
+// Macro 163
+Function TreeView_SetIndent( hwnd : hwnd; indent : WPARAM):BOOL;
+
+CONST
+ TVM_GETIMAGELIST = (TV_FIRST + 8);
+
+// Macro 164
+Function TreeView_GetImageList( hwnd : hwnd; iImage : cint ):HIMAGELIST;
+
+CONST
+ TVSIL_NORMAL = 0;
+ TVSIL_STATE = 2;
+
+
+ TVM_SETIMAGELIST = (TV_FIRST + 9);
+
+// Macro 165
+Function TreeView_SetImageList( hwnd : hwnd; himl : HIMAGELIST; iImage : cint):HIMAGELIST;
+
+CONST
+ TVM_GETNEXTITEM = (TV_FIRST + 10);
+
+// Macro 166
+Function TreeView_GetNextItem( hwnd : hwnd; hitem : HTREEITEM; code : WPARAM):HTREEITEM;
+
+CONST
+ TVGN_ROOT = $0000;
+ TVGN_NEXT = $0001;
+ TVGN_PREVIOUS = $0002;
+ TVGN_PARENT = $0003;
+ TVGN_CHILD = $0004;
+ TVGN_FIRSTVISIBLE = $0005;
+ TVGN_NEXTVISIBLE = $0006;
+ TVGN_PREVIOUSVISIBLE = $0007;
+ TVGN_DROPHILITE = $0008;
+ TVGN_CARET = $0009;
+{$ifdef ie4plus}
+ TVGN_LASTVISIBLE = $000A;
+{$ENDIF} // _WIN32_IE >= 0x0400
+{$ifdef ie6plus}
+ TVGN_NEXTSELECTED = $000B;
+{$endif}
+{$ifdef win32xp} // 0x501
+ TVSI_NOSINGLEEXPAND = $8000; // Should not conflict with TVGN flags.
+{$ENDIF}
+
+function TreeView_GetChild(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;inline;
+function TreeView_GetNextSibling(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;inline;
+function TreeView_GetPrevSibling(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;inline;
+function TreeView_GetParent(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;inline;
+function TreeView_GetFirstVisible(hwnd:hwnd) : HTREEITEM;inline;
+function TreeView_GetNextVisible(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;inline;
+function TreeView_GetPrevVisible(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;inline;
+function TreeView_GetSelection(hwnd:hwnd) : HTREEITEM;inline;
+function TreeView_GetDropHilight(hwnd:hwnd) : HTREEITEM;inline;
+function TreeView_GetDropHilite(hwnd:hwnd) : HTREEITEM;inline;
+function TreeView_GetRoot(hwnd:hwnd) : HTREEITEM;inline;
+function TreeView_GetLastVisible(hwnd:hwnd) : HTREEITEM;inline;
+
+{$ifdef win32vista}
+function TreeView_GetNextSelected(hwnd:hwnd; hitem:HTREEITEM):HTREEITEM;inline;
+{$endif}
+
+CONST
+ TVM_SELECTITEM = (TV_FIRST + 11);
+
+// Macro 178
+Function TreeView_Select( hwnd : hwnd; hitem : HTREEITEM; code : WPARAM):BOOL;
+
+// Macro 179
+Procedure TreeView_SelectItem(hwnd:hwnd; hitem:HTREEITEM);
+
+// Macro 180
+Procedure TreeView_SelectDropTarget(hwnd:hwnd; hitem:HTREEITEM);
+
+// Macro 181
+Procedure TreeView_SelectSetFirstVisible(hwnd:hwnd; hitem:HTREEITEM);
+
+CONST
+ TVM_GETITEMA = (TV_FIRST + 12);
+ TVM_GETITEMW = (TV_FIRST + 62);
+
+{$IFDEF UNICODE}
+
+TYPE
+ TVM_GETITEM = TVM_GETITEMW;
+{$ELSE}
+ TVM_GETITEM = TVM_GETITEMA;
+{$ENDIF}
+
+// Macro 182
+
+
+Function TreeView_GetItem( hwnd : hwnd;var pitem : TV_ITEM ):BOOL;
+
+
+
+
+CONST
+ TVM_SETITEMA = (TV_FIRST + 13);
+ TVM_SETITEMW = (TV_FIRST + 63);
+
+{$IFDEF UNICODE}
+
+TYPE
+ TVM_SETITEM = TVM_SETITEMW;
+{$ELSE}
+ TVM_SETITEM = TVM_SETITEMA;
+{$ENDIF}
+
+// Macro 183
+
+
+Function TreeView_SetItem( hwnd : hwnd;const pitem : TV_ITEM ):BOOL;
+
+
+CONST
+ TVM_EDITLABELA = (TV_FIRST + 14);
+ TVM_EDITLABELW = (TV_FIRST + 65);
+{$IFDEF UNICODE}
+
+TYPE
+ TVM_EDITLABEL = TVM_EDITLABELW;
+{$ELSE}
+ TVM_EDITLABEL = TVM_EDITLABELA;
+{$ENDIF}
+
+// Macro 184
+
+
+Function TreeView_EditLabel( hwnd : hwnd; hitem : HTREEITEM):HWND;
+
+
+
+
+CONST
+ TVM_GETEDITCONTROL = (TV_FIRST + 15);
+// Macro 185
+
+
+Function TreeView_GetEditControl( hwnd : hwnd):HWND;
+
+
+
+
+CONST
+ TVM_GETVISIBLECOUNT = (TV_FIRST + 16);
+// Macro 186
+
+
+Function TreeView_GetVisibleCount( hwnd : hwnd):UINT;
+
+
+
+
+CONST
+ TVM_HITTEST = (TV_FIRST + 17);
+
+TYPE
+
+ tagTVHITTESTINFO = Record
+ pt : POINT;
+ flags : UINT;
+ hItem : HTREEITEM;
+ END;
+ TVHITTESTINFO = tagTVHITTESTINFO;
+ LPTVHITTESTINFO = ^tagTVHITTESTINFO;
+ TTVHITTESTINFO = tagTVHITTESTINFO;
+ PTVHITTESTINFO = ^tagTVHITTESTINFO;
+
+
+{$ifdef ie3plus}
+ LPTV_HITTESTINFO = LPTVHITTESTINFO;
+ TV_HITTESTINFO = TVHITTESTINFO;
+{$ELSE}
+ tagTVHITTESTINFO = _TV_HITTESTINFO;
+ TVHITTESTINFO = TV_HITTESTINFO;
+
+ LPTVHITTESTINFO = LPTV_HITTESTINFO;
+{$ENDIF}
+
+
+CONST
+ TVHT_NOWHERE = $0001;
+ TVHT_ONITEMICON = $0002;
+ TVHT_ONITEMLABEL = $0004;
+ TVHT_ONITEM = (TVHT_ONITEMICON OR TVHT_ONITEMLABEL OR TVHT_ONITEMSTATEICON);
+ TVHT_ONITEMINDENT = $0008;
+ TVHT_ONITEMBUTTON = $0010;
+ TVHT_ONITEMRIGHT = $0020;
+ TVHT_ONITEMSTATEICON = $0040;
+
+ TVHT_ABOVE = $0100;
+ TVHT_BELOW = $0200;
+ TVHT_TORIGHT = $0400;
+ TVHT_TOLEFT = $0800;
+
+
+ TVM_CREATEDRAGIMAGE = (TV_FIRST + 18);
+
+// Macro 187
+Function TreeView_HitTest( hwnd : hwnd; lpht : LPTV_HITTESTINFO):HTREEITEM;inline;
+Function TreeView_HitTest( hwnd : hwnd; var lpht : TV_HITTESTINFO):HTREEITEM;inline;
+
+
+// Macro 188
+
+
+Function TreeView_CreateDragImage( hwnd : hwnd; hitem : HTREEITEM):HIMAGELIST;
+
+
+
+
+CONST
+ TVM_SORTCHILDREN = (TV_FIRST + 19);
+// Macro 189
+
+
+Function TreeView_SortChildren( hwnd : hwnd; hitem : HTREEITEM; recurse : WPARAM):BOOL;
+
+
+
+
+CONST
+ TVM_ENSUREVISIBLE = (TV_FIRST + 20);
+// Macro 190
+
+
+Function TreeView_EnsureVisible( hwnd : hwnd; hitem : HTREEITEM):BOOL;
+
+
+
+
+
+CONST
+ TVM_ENDEDITLABELNOW = (TV_FIRST + 22);
+// Macro 192
+
+
+Function TreeView_EndEditLabelNow( hwnd : hwnd; fCancel : WPARAM):BOOL;inline;
+Function TreeView_EndEditLabelNow( hwnd : hwnd; fCancel : Bool):BOOL;inline;
+
+
+
+
+CONST
+ TVM_GETISEARCHSTRINGA = (TV_FIRST + 23);
+ TVM_GETISEARCHSTRINGW = (TV_FIRST + 64);
+
+{$IFDEF UNICODE}
+
+TYPE
+ TVM_GETISEARCHSTRING= TVM_GETISEARCHSTRINGW;
+{$ELSE}
+ TVM_GETISEARCHSTRING= TVM_GETISEARCHSTRINGA;
+{$ENDIF}
+
+{$ifdef ie3plus}
+
+CONST
+ TVM_SETTOOLTIPS = (TV_FIRST + 24);
+// Macro 193
+
+
+Function TreeView_SetToolTips( hwnd : hwnd; hwndTT : WPARAM):HWND;
+
+
+CONST
+ TVM_GETTOOLTIPS = (TV_FIRST + 25);
+// Macro 194
+
+
+Function TreeView_GetToolTips( hwnd : hwnd):HWND;
+
+{$ENDIF}
+
+// Macro 195
+
+
+Function TreeView_GetISearchString( hwndTV : hwnd; lpsz : LPTSTR):BOOL;
+
+
+{$ifdef ie4plus}
+
+CONST
+ TVM_SETINSERTMARK = (TV_FIRST + 26);
+// Macro 196
+
+
+Function TreeView_SetInsertMark( hwnd : hwnd; hItem : LPARAM ; fAfter : WPARAM ):BOOL;
+
+
+
+CONST
+ TVM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+// Macro 197
+
+
+Function TreeView_SetUnicodeFormat( hwnd : hwnd; fUnicode : WPARAM):BOOL;
+
+
+
+CONST
+ TVM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+// Macro 198
+
+
+Function TreeView_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+
+{$ENDIF}
+
+{$ifdef ie4plus}
+
+CONST
+ TVM_SETITEMHEIGHT = (TV_FIRST + 27);
+// Macro 199
+
+
+Function TreeView_SetItemHeight( hwnd : hwnd; iHeight : WPARAM):cint;
+
+
+CONST
+ TVM_GETITEMHEIGHT = (TV_FIRST + 28);
+// Macro 200
+
+
+Function TreeView_GetItemHeight( hwnd : hwnd):cint;
+
+
+
+CONST
+ TVM_SETBKCOLOR = (TV_FIRST + 29);
+// Macro 201
+
+
+Function TreeView_SetBkColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+
+
+CONST
+ TVM_SETTEXTCOLOR = (TV_FIRST + 30);
+// Macro 202
+
+
+Function TreeView_SetTextColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+
+
+CONST
+ TVM_GETBKCOLOR = (TV_FIRST + 31);
+
+// Macro 203
+Function TreeView_GetBkColor( hwnd : hwnd):COLORREF;
+
+
+CONST
+ TVM_GETTEXTCOLOR = (TV_FIRST + 32);
+
+// Macro 204
+Function TreeView_GetTextColor( hwnd : hwnd):COLORREF;
+
+
+
+CONST
+ TVM_SETSCROLLTIME = (TV_FIRST + 33);
+
+// Macro 205
+Function TreeView_SetScrollTime( hwnd : hwnd; uTime :wparam ):UINT;
+
+
+
+CONST
+ TVM_GETSCROLLTIME = (TV_FIRST + 34);
+// Macro 206
+
+
+Function TreeView_GetScrollTime( hwnd : hwnd):UINT;
+
+
+
+
+CONST
+ TVM_SETINSERTMARKCOLOR = (TV_FIRST + 37);
+// Macro 207
+
+
+Function TreeView_SetInsertMarkColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+
+CONST
+ TVM_GETINSERTMARKCOLOR = (TV_FIRST + 38);
+// Macro 208
+
+
+Function TreeView_GetInsertMarkColor( hwnd : hwnd):COLORREF;
+
+
+{$ENDIF} // (_WIN32_IE >= 0x0400)
+
+{$ifdef ie5plus}
+// tvm_?etitemstate only uses mask, state and stateMask.
+// so unicode or ansi is irrelevant.
+// Macro 209
+
+Procedure TreeView_SetItemState(hwndTV:HWND;hti:HTreeItem;data:UINT;_mask:UINT);
+
+
+// Macro 210
+
+Procedure TreeView_SetCheckState( hwndTV : hwnd; hti : HTreeItem ; fCheck : bool );
+
+
+CONST
+ TVM_GETITEMSTATE = (TV_FIRST + 39);
+
+// Macro 211
+Function TreeView_GetItemState( hwndTV : hwnd; hti : WPARAM; mask : LPARAM):UINT;
+
+
+// Macro 212
+Function TreeView_GetCheckState( hwndTV : hwnd; hti : WPARAM):UINT;
+
+
+CONST
+ TVM_SETLINECOLOR = (TV_FIRST + 40);
+// Macro 213
+Function TreeView_SetLineColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+CONST
+ TVM_GETLINECOLOR = (TV_FIRST + 41);
+
+// Macro 214
+Function TreeView_GetLineColor( hwnd : hwnd):COLORREF;
+
+
+{$ENDIF}
+
+{$ifdef Win32XP}
+
+CONST
+ TVM_MAPACCIDTOHTREEITEM = (TV_FIRST + 42);
+
+// Macro 215
+Function TreeView_MapAccIDToHTREEITEM( hwnd : hwnd; id : UINT ):HTREEITEM;
+
+
+
+CONST
+ TVM_MAPHTREEITEMTOACCID = (TV_FIRST + 43);
+
+// Macro 216
+Function TreeView_MapHTREEITEMToAccID( hwnd : hwnd; htreeitem : WPARAM):UINT;
+
+{$ENDIF}
+
+{$ifdef win32vista}
+CONST
+ TVM_GETSELECTEDCOUNT = (TV_FIRST + 70);
+ TVM_SHOWINFOTIP = (TV_FIRST + 71);
+ TVM_GETITEMPARTRECT = (TV_FIRST + 72);
+
+Type
+ TVITEMPART = (TVGIPR_BUTTON = $0001);
+ pTVITEMPART = ^TVITEMPART;
+
+ tagTVGETITEMPARTRECTINFO = Record
+ hti :HTREEITEM ;
+ prc :PRECT;
+ partID :TVITEMPART;
+ end;
+ TVGETITEMPARTRECTINFO = tagTVGETITEMPARTRECTINFO;
+
+function TreeView_GetSelectedCount(hwnd:hwnd):DWORD;
+// (DWORD)SNDMSG((hwnd), TVM_GETSELECTEDCOUNT, 0, 0)
+
+function TreeView_ShowInfoTip(hwnd:HWND; hitem:HTREEITEM):DWORD;
+// (DWORD)SNDMSG((hwnd), TVM_SHOWINFOTIP, 0, (LPARAM)(hitem))
+
+function TreeView_GetItemPartRect(hwnd:HWND; hitem:HTREEITEM; prc:prect; partid:TVITEMPART):bool;
+//{ TVGETITEMPARTRECTINFO info; \
+// info.hti = (hitem); \
+// info.prc = (prc); \
+// info.partID = (partid); \
+// (BOOL)SNDMSG((hwnd), TVM_GETITEMPARTRECT, 0, (LPARAM)&info); \
+
+{$endif}
+
+
+TYPE
+ PFNTVCOMPARE =function (lparam1:LPARAM;lparam2:LPARAM;lParamSort:LParam): cint; STDCALL;
+ TTVCompare = PFNTVCOMPARE;
+
+
+ tagTVSORTCB = Record
+ hParent : HTREEITEM;
+ lpfnCompare : PFNTVCOMPARE;
+ lParam : LPARAM;
+ END;
+ TVSORTCB = tagTVSORTCB;
+ LPTVSORTCB = ^tagTVSORTCB;
+ TTVSORTCB = tagTVSORTCB;
+ PTVSORTCB = ^tagTVSORTCB;
+
+{$ifdef ie3plus}
+ LPTV_SORTCB = LPTVSORTCB;
+
+
+ TV_SORTCB = TVSORTCB;
+{$ELSE}
+ tagTVSORTCB = _TV_SORTCB;
+ TVSORTCB = TV_SORTCB;
+
+
+ LPTVSORTCB = LPTV_SORTCB;
+{$ENDIF}
+
+
+ tagNMTREEVIEWA = Record
+ hdr : NMHDR;
+ action : UINT;
+ itemOld : TVITEMA;
+ itemNew : TVITEMA;
+ ptDrag : POINT;
+ END;
+ NMTREEVIEWA = tagNMTREEVIEWA;
+ LPNMTREEVIEWA = ^tagNMTREEVIEWA;
+ TNMTREEVIEWA = tagNMTREEVIEWA;
+ PNMTREEVIEWA = ^tagNMTREEVIEWA;
+ PNMTreeView = PNMTreeViewA;
+ TNMTreeView = TNMTreeViewA;
+
+
+
+ tagNMTREEVIEWW = Record
+ hdr : NMHDR;
+ action : UINT;
+ itemOld : TVITEMW;
+ itemNew : TVITEMW;
+ ptDrag : POINT;
+ END;
+ NMTREEVIEWW = tagNMTREEVIEWW;
+ LPNMTREEVIEWW = ^tagNMTREEVIEWW;
+ TNMTREEVIEWW = tagNMTREEVIEWW;
+ PNMTREEVIEWW = ^tagNMTREEVIEWW;
+
+
+
+{$IFDEF UNICODE}
+ NMTREEVIEW = NMTREEVIEWW;
+ LPNMTREEVIEW = LPNMTREEVIEWW;
+{$ELSE}
+ NMTREEVIEW = NMTREEVIEWA;
+ LPNMTREEVIEW = LPNMTREEVIEWA;
+{$ENDIF}
+
+{$ifdef ie3plus}
+ LPNM_TREEVIEWA = LPNMTREEVIEWA;
+ LPNM_TREEVIEWW = LPNMTREEVIEWW;
+ NM_TREEVIEWW = NMTREEVIEWW;
+ NM_TREEVIEWA = NMTREEVIEWA;
+{$ELSE}
+ tagNMTREEVIEWA = _NM_TREEVIEWA;
+ tagNMTREEVIEWW = _NM_TREEVIEWW;
+ NMTREEVIEWA = NM_TREEVIEWA;
+ NMTREEVIEWW = NM_TREEVIEWW;
+ LPNMTREEVIEWA = LPNM_TREEVIEWA;
+ LPNMTREEVIEWW = LPNM_TREEVIEWW;
+{$ENDIF}
+
+ LPNM_TREEVIEW = LPNMTREEVIEW;
+ NM_TREEVIEW = NMTREEVIEW;
+
+
+
+CONST
+ TVN_SELCHANGINGA = (TVN_FIRST-1);
+ TVN_SELCHANGINGW = (TVN_FIRST-50);
+ TVN_SELCHANGEDA = (TVN_FIRST-2);
+ TVN_SELCHANGEDW = (TVN_FIRST-51);
+
+ TVC_UNKNOWN = $0000;
+ TVC_BYMOUSE = $0001;
+ TVC_BYKEYBOARD = $0002;
+
+ TVN_GETDISPINFOA = (TVN_FIRST-3);
+ TVN_GETDISPINFOW = (TVN_FIRST-52);
+ TVN_SETDISPINFOA = (TVN_FIRST-4);
+ TVN_SETDISPINFOW = (TVN_FIRST-53);
+
+ TVIF_DI_SETITEM = $1000;
+
+Type
+ tagTVDISPINFOA = Record
+ hdr : NMHDR;
+ item : TVITEMA;
+ END;
+ NMTVDISPINFOA = tagTVDISPINFOA;
+ LPNMTVDISPINFOA = ^tagTVDISPINFOA;
+ TTVDISPINFOA = tagTVDISPINFOA;
+ PTVDISPINFOA = ^tagTVDISPINFOA;
+ TTVDispInfo = TTVDISPINFOA;
+ PTVDispInfo = PTVDISPINFOA;
+
+
+ tagTVDISPINFOW = Record
+ hdr : NMHDR;
+ item : TVITEMW;
+ END;
+ NMTVDISPINFOW = tagTVDISPINFOW;
+ LPNMTVDISPINFOW = ^tagTVDISPINFOW;
+ TTVDISPINFOW = tagTVDISPINFOW;
+ PTVDISPINFOW = ^tagTVDISPINFOW;
+
+{$IFDEF UNICODE}
+ NMTVDISPINFO = NMTVDISPINFOW;
+ LPNMTVDISPINFO = LPNMTVDISPINFOW;
+{$ELSE}
+ NMTVDISPINFO = NMTVDISPINFOA;
+ LPNMTVDISPINFO = LPNMTVDISPINFOA;
+{$ENDIF}
+
+{$ifdef IE6plus}
+ tagTVDISPINFOEXA = Record
+ hdr : NMHDR;
+ item :TVITEMEXA;
+ end;
+ NMTVDISPINFOEXA = tagTVDISPINFOEXA;
+ LPNMTVDISPINFOEXA = ^tagTVDISPINFOEXA;
+
+ tagTVDISPINFOEXW = Record
+ hdr : NMHDR;
+ item :TVITEMEXW;
+ end;
+ NMTVDISPINFOEXW = tagTVDISPINFOEXW;
+ LPNMTVDISPINFOEXW = ^tagTVDISPINFOEXW;
+
+{$IFDEF UNICODE}
+ NMTVDISPINFOEX = NMTVDISPINFOEXW;
+ LPNMTVDISPINFOEX = LPNMTVDISPINFOEXW;
+{$ELSE}
+ NMTVDISPINFOEX = NMTVDISPINFOEXA;
+ LPNMTVDISPINFOEX = LPNMTVDISPINFOEXA;
+{$ENDIF}
+
+ TV_DISPINFOEXA = NMTVDISPINFOEXA;
+ TV_DISPINFOEXW = NMTVDISPINFOEXW;
+ TV_DISPINFOEX = NMTVDISPINFOEX;
+
+
+{$endif}
+
+{$ifdef ie3plus}
+ TV_DISPINFOA = NMTVDISPINFOA;
+ TV_DISPINFOW = NMTVDISPINFOW;
+{$ELSE}
+ tagTVDISPINFOA = _TV_DISPINFOA;
+ NMTVDISPINFOA = TV_DISPINFOA;
+ tagTVDISPINFOW = _TV_DISPINFOW;
+ NMTVDISPINFOW = TV_DISPINFOW;
+{$ENDIF}
+ TV_DISPINFO = NMTVDISPINFO;
+
+
+CONST
+ TVM_SORTCHILDRENCB = (TV_FIRST + 21);
+
+// Macro 191
+Function TreeView_SortChildrenCB( hwnd : hwnd;psort :lpTV_sortcb; recurse : WPARAM):BOOL;inline;
+Function TreeView_SortChildrenCB( hwnd : hwnd;const psort :tagTVsortcb; recurse : WPARAM):BOOL;inline;
+
+CONST
+ TVN_ITEMEXPANDINGA = (TVN_FIRST-5);
+ TVN_ITEMEXPANDINGW = (TVN_FIRST-54);
+ TVN_ITEMEXPANDEDA = (TVN_FIRST-6);
+ TVN_ITEMEXPANDEDW = (TVN_FIRST-55);
+ TVN_BEGINDRAGA = (TVN_FIRST-7);
+ TVN_BEGINDRAGW = (TVN_FIRST-56);
+ TVN_BEGINRDRAGA = (TVN_FIRST-8);
+ TVN_BEGINRDRAGW = (TVN_FIRST-57);
+ TVN_DELETEITEMA = (TVN_FIRST-9);
+ TVN_DELETEITEMW = (TVN_FIRST-58);
+ TVN_BEGINLABELEDITA = (TVN_FIRST-10);
+ TVN_BEGINLABELEDITW = (TVN_FIRST-59);
+ TVN_ENDLABELEDITA = (TVN_FIRST-11);
+ TVN_ENDLABELEDITW = (TVN_FIRST-60);
+ TVN_KEYDOWN = (TVN_FIRST-12);
+
+{$ifdef ie4plus}
+ TVN_GETINFOTIPA = (TVN_FIRST-13);
+ TVN_GETINFOTIPW = (TVN_FIRST-14);
+ TVN_SINGLEEXPAND = (TVN_FIRST-15);
+
+ TVNRET_DEFAULT = 0;
+ TVNRET_SKIPOLD = 1;
+ TVNRET_SKIPNEW = 2;
+
+{$ifdef win32vista}
+ TVN_ITEMCHANGINGA = (TVN_FIRST-16);
+ TVN_ITEMCHANGINGW = (TVN_FIRST-17);
+ TVN_ITEMCHANGEDA = (TVN_FIRST-18);
+ TVN_ITEMCHANGEDW = (TVN_FIRST-19);
+ TVN_ASYNCDRAW = (TVN_FIRST-20);
+{$endif}
+
+{$ENDIF} // 0x400
+
+
+
+{$IFDEF _WIN32}
+// #include <pshpack1.h>
+{$ENDIF}
+
+TYPE
+
+ tagTVKEYDOWN = Record
+ hdr : NMHDR;
+ wVKey : WORD;
+ flags : UINT;
+ END;
+ NMTVKEYDOWN = tagTVKEYDOWN;
+ LPNMTVKEYDOWN = ^tagTVKEYDOWN;
+ TTVKEYDOWN = tagTVKEYDOWN;
+ PTVKEYDOWN = ^tagTVKEYDOWN;
+
+{$ifdef ie3plus}
+ TV_KEYDOWN = NMTVKEYDOWN;
+{$ELSE}
+ tagTVKEYDOWN = _TV_KEYDOWN;
+ NMTVKEYDOWN = TV_KEYDOWN;
+{$ENDIF}
+
+
+{$IFDEF _WIN32}
+// #include <poppack.h>
+{$ENDIF}
+
+Const
+
+{$IFDEF UNICODE}
+ TVN_SELCHANGING = TVN_SELCHANGINGW;
+ TVN_SELCHANGED = TVN_SELCHANGEDW;
+ TVN_GETDISPINFO = TVN_GETDISPINFOW;
+ TVN_SETDISPINFO = TVN_SETDISPINFOW;
+ TVN_ITEMEXPANDING = TVN_ITEMEXPANDINGW;
+ TVN_ITEMEXPANDED = TVN_ITEMEXPANDEDW;
+ TVN_BEGINDRAG = TVN_BEGINDRAGW;
+ TVN_BEGINRDRAG = TVN_BEGINRDRAGW;
+ TVN_DELETEITEM = TVN_DELETEITEMW;
+ TVN_BEGINLABELEDIT = TVN_BEGINLABELEDITW;
+ TVN_ENDLABELEDIT = TVN_ENDLABELEDITW;
+{$ELSE}
+ TVN_SELCHANGING = TVN_SELCHANGINGA;
+ TVN_SELCHANGED = TVN_SELCHANGEDA;
+ TVN_GETDISPINFO = TVN_GETDISPINFOA;
+ TVN_SETDISPINFO = TVN_SETDISPINFOA;
+ TVN_ITEMEXPANDING = TVN_ITEMEXPANDINGA;
+ TVN_ITEMEXPANDED = TVN_ITEMEXPANDEDA;
+ TVN_BEGINDRAG = TVN_BEGINDRAGA;
+ TVN_BEGINRDRAG = TVN_BEGINRDRAGA;
+ TVN_DELETEITEM = TVN_DELETEITEMA;
+ TVN_BEGINLABELEDIT = TVN_BEGINLABELEDITA;
+ TVN_ENDLABELEDIT = TVN_ENDLABELEDITA;
+{$ENDIF}
+
+
+{$ifdef ie3plus}
+// #define NMTVCUSTOMDRAW_V3_SIZE CCSIZEOF_STRUCT(NMTVCUSTOMDRAW, clrTextBk)
+Type
+ tagNMTVCUSTOMDRAW = Record
+ nmcd : NMCUSTOMDRAW;
+ clrText : COLORREF;
+ clrTextBk : COLORREF;
+{$ifdef ie4plus}
+ iLevel : cint;
+{$ENDIF}
+ END;
+ NMTVCUSTOMDRAW = tagNMTVCUSTOMDRAW;
+ LPNMTVCUSTOMDRAW = ^tagNMTVCUSTOMDRAW;
+ TNMTVCUSTOMDRAW = tagNMTVCUSTOMDRAW;
+ PNMTVCUSTOMDRAW = ^tagNMTVCUSTOMDRAW;
+
+{$ENDIF}
+
+
+{$ifdef ie4plus}
+
+// for tooltips
+
+ tagNMTVGETINFOTIPA = Record
+ hdr : NMHDR;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ hItem : HTREEITEM;
+ lParam : LPARAM;
+ END;
+ NMTVGETINFOTIPA = tagNMTVGETINFOTIPA;
+ LPNMTVGETINFOTIPA = ^tagNMTVGETINFOTIPA;
+ TNMTVGETINFOTIPA = tagNMTVGETINFOTIPA;
+ PNMTVGETINFOTIPA = ^tagNMTVGETINFOTIPA;
+
+
+ tagNMTVGETINFOTIPW = Record
+ hdr : NMHDR;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ hItem : HTREEITEM;
+ lParam : LPARAM;
+ END;
+ NMTVGETINFOTIPW = tagNMTVGETINFOTIPW;
+ LPNMTVGETINFOTIPW = ^tagNMTVGETINFOTIPW;
+ TNMTVGETINFOTIPW = tagNMTVGETINFOTIPW;
+ PNMTVGETINFOTIPW = ^tagNMTVGETINFOTIPW;
+
+
+CONST
+{$IFDEF UNICODE}
+ TVN_GETINFOTIP = TVN_GETINFOTIPW;
+TYPE
+ NMTVGETINFOTIP = NMTVGETINFOTIPW;
+ LPNMTVGETINFOTIP = LPNMTVGETINFOTIPW;
+{$ELSE}
+ TVN_GETINFOTIP = TVN_GETINFOTIPA;
+TYPE
+ NMTVGETINFOTIP = NMTVGETINFOTIPA;
+ LPNMTVGETINFOTIP = LPNMTVGETINFOTIPA;
+{$ENDIF}
+
+// treeview's customdraw return meaning don't draw images. valid on CDRF_NOTIFYITEMPREPAINT
+
+CONST
+ TVCDRF_NOIMAGES = $00010000;
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+{$ifdef ie6plus}
+Type
+ tagTVITEMCHANGE = packed record
+ hdr : NMHDR;
+ uChanged : UINT;
+ hItem : HTREEITEM;
+ uStateNew : UINT;
+ uStateOld : UINT;
+ lParam : LPARAM;
+ end;
+ NMTVITEMCHANGE = tagTVITEMCHANGE;
+ PNMTVITEMCHANGE = ^NMTVITEMCHANGE;
+
+ tagNMTVASYNCDRAW = packed record
+ hdr : NMHDR;
+ pimldp : PIMAGELISTDRAWPARAMS; { the draw that failed }
+ hr : HRESULT; { why it failed }
+ hItem : HTREEITEM; { item that failed to draw icon }
+ lParam : LPARAM; { its data }
+ dwRetFlags : DWORD; { Out Params }
+ iRetImageIndex : longint; { What listview should do on return }
+ end; { used if ADRF_DRAWIMAGE is returned }
+ NMTVASYNCDRAW = tagNMTVASYNCDRAW;
+ PNMTVASYNCDRAW = ^NMTVASYNCDRAW;
+
+CONST
+{$IFDEF UNICODE}
+ TVN_ITEMCHANGING = TVN_ITEMCHANGINGW;
+ TVN_ITEMCHANGED = TVN_ITEMCHANGEDW;
+{$ELSE}
+ TVN_ITEMCHANGING = TVN_ITEMCHANGINGA;
+ TVN_ITEMCHANGED = TVN_ITEMCHANGEDA;
+{$ENDIF}
+{$endif}
+
+{$ENDIF} // NOTREEVIEW
+
+{$ifdef ie3plus}
+
+{$IFNDEF NOUSEREXCONTROLS}
+
+//////////////////// ComboBoxEx ////////////////////////////////
+
+ WC_COMBOBOXEXW = {L}'ComboBoxEx32';
+ WC_COMBOBOXEXA = 'ComboBoxEx32';
+
+
+{$IFDEF UNICODE}
+ WC_COMBOBOXEX = WC_COMBOBOXEXW;
+{$ELSE}
+ WC_COMBOBOXEX = WC_COMBOBOXEXA;
+{$ENDIF}
+
+CONST
+ CBEIF_TEXT = $00000001;
+ CBEIF_IMAGE = $00000002;
+ CBEIF_SELECTEDIMAGE = $00000004;
+ CBEIF_OVERLAY = $00000008;
+ CBEIF_INDENT = $00000010;
+ CBEIF_LPARAM = $00000020;
+ CBEIF_DI_SETITEM = $10000000;
+
+TYPE
+
+ tagCOMBOBOXEXITEMA = Record
+ mask : UINT;
+ iItem : INT_PTR;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ iSelectedImage : cint;
+ iOverlay : cint;
+ iIndent : cint;
+ lParam : LPARAM;
+ END;
+ COMBOBOXEXITEMA = tagCOMBOBOXEXITEMA;
+ PCOMBOBOXEXITEMA = ^tagCOMBOBOXEXITEMA;
+ TCOMBOBOXEXITEMA = tagCOMBOBOXEXITEMA;
+// PCOMBOBOXEXITEMA = ^tagCOMBOBOXEXITEMA;
+
+ PCCOMBOBOXEXITEMA = ^COMBOBOXEXITEMA;
+
+
+ tagCOMBOBOXEXITEMW = Record
+ mask : UINT;
+ iItem : INT_PTR;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ iSelectedImage : cint;
+ iOverlay : cint;
+ iIndent : cint;
+ lParam : LPARAM;
+ END;
+ COMBOBOXEXITEMW = tagCOMBOBOXEXITEMW;
+ PCOMBOBOXEXITEMW = ^tagCOMBOBOXEXITEMW;
+ TCOMBOBOXEXITEMW = tagCOMBOBOXEXITEMW;
+// PCOMBOBOXEXITEMW = ^tagCOMBOBOXEXITEMW;
+
+ PCCOMBOBOXEXITEMW = ^COMBOBOXEXITEMW;
+
+{$IFDEF UNICODE}
+ COMBOBOXEXITEM = COMBOBOXEXITEMW;
+ PCOMBOBOXEXITEM = PCOMBOBOXEXITEMW;
+ PCCOMBOBOXEXITEM = PCCOMBOBOXEXITEMW;
+{$ELSE}
+ COMBOBOXEXITEM = COMBOBOXEXITEMA;
+ PCOMBOBOXEXITEM = PCOMBOBOXEXITEMA;
+ PCCOMBOBOXEXITEM = PCCOMBOBOXEXITEMA;
+{$ENDIF}
+ TComboBoxExItem = COMBOBOXEXITEM;
+
+
+CONST
+ CBEM_INSERTITEMA = (WM_USER + 1);
+ CBEM_SETIMAGELIST = (WM_USER + 2);
+ CBEM_GETIMAGELIST = (WM_USER + 3);
+ CBEM_GETITEMA = (WM_USER + 4);
+ CBEM_SETITEMA = (WM_USER + 5);
+ CBEM_DELETEITEM = CB_DELETESTRING;
+ CBEM_GETCOMBOCONTROL = (WM_USER + 6);
+ CBEM_GETEDITCONTROL = (WM_USER + 7);
+{$ifdef ie4plus}
+ CBEM_SETEXSTYLE = (WM_USER + 8); // use SETEXTENDEDSTYLE instead
+ CBEM_SETEXTENDEDSTYLE = (WM_USER + 14); // lparam == new style, wParam (optional) == mask
+ CBEM_GETEXSTYLE = (WM_USER + 9); // use GETEXTENDEDSTYLE instead
+ CBEM_GETEXTENDEDSTYLE = (WM_USER + 9);
+ CBEM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+ CBEM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+{$ELSE}
+ CBEM_SETEXSTYLE = (WM_USER + 8);
+ CBEM_GETEXSTYLE = (WM_USER + 9);
+{$ENDIF}
+ CBEM_HASEDITCHANGED = (WM_USER + 10);
+ CBEM_INSERTITEMW = (WM_USER + 11);
+ CBEM_SETITEMW = (WM_USER + 12);
+ CBEM_GETITEMW = (WM_USER + 13);
+
+{$IFDEF UNICODE}
+
+ CBEM_INSERTITEM = CBEM_INSERTITEMW;
+ CBEM_SETITEM = CBEM_SETITEMW;
+ CBEM_GETITEM = CBEM_GETITEMW;
+{$ELSE}
+ CBEM_INSERTITEM = CBEM_INSERTITEMA;
+ CBEM_SETITEM = CBEM_SETITEMA;
+ CBEM_GETITEM = CBEM_GETITEMA;
+{$ENDIF}
+
+{$ifdef win32xp}
+
+ CBEM_SETWINDOWTHEME = CCM_SETWINDOWTHEME;
+{$ENDIF}
+
+ CBES_EX_NOEDITIMAGE = $00000001;
+ CBES_EX_NOEDITIMAGEINDENT = $00000002;
+ CBES_EX_PATHWORDBREAKPROC = $00000004;
+{$ifdef ie4plus}
+ CBES_EX_NOSIZELIMIT = $00000008;
+ CBES_EX_CASESENSITIVE = $00000010;
+{$ifdef win32vista}
+ CBES_EX_TEXTENDELLIPSIS = $00000020;
+{$endif}
+TYPE
+
+ DummyStruct9 = Record
+ hdr : NMHDR;
+ ceItem : COMBOBOXEXITEMA;
+ END;
+ NMCOMBOBOXEXA = DummyStruct9;
+ PNMCOMBOBOXEXA = ^DummyStruct9;
+ TDummyStruct9 = DummyStruct9;
+ PDummyStruct9 = ^DummyStruct9;
+
+
+ DummyStruct10 = Record
+ hdr : NMHDR;
+ ceItem : COMBOBOXEXITEMW;
+ END;
+ NMCOMBOBOXEXW = DummyStruct10;
+ PNMCOMBOBOXEXW = ^DummyStruct10;
+ TDummyStruct10 = DummyStruct10;
+ PDummyStruct10 = ^DummyStruct10;
+
+
+
+{$ELSE}
+ DummyStruct11 = Record
+ hdr : NMHDR;
+ ceItem : COMBOBOXEXITEM;
+ END;
+ NMCOMBOBOXEX = DummyStruct11;
+ PNMCOMBOBOXEX = ^DummyStruct11;
+ TDummyStruct11 = DummyStruct11;
+ PDummyStruct11 = ^DummyStruct11;
+
+
+
+CONST
+ CBEN_GETDISPINFO = (CBEN_FIRST - 0);
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+CONST
+{$ifdef ie4plus}
+ CBEN_GETDISPINFOA = (CBEN_FIRST - 0);
+{$ENDIF}
+ CBEN_INSERTITEM = (CBEN_FIRST - 1);
+ CBEN_DELETEITEM = (CBEN_FIRST - 2);
+ CBEN_BEGINEDIT = (CBEN_FIRST - 4);
+ CBEN_ENDEDITA = (CBEN_FIRST - 5);
+ CBEN_ENDEDITW = (CBEN_FIRST - 6);
+
+{$ifdef ie4plus}
+ CBEN_GETDISPINFOW = (CBEN_FIRST - 7);
+{$ENDIF}
+
+{$ifdef ie4plus}
+ CBEN_DRAGBEGINA = (CBEN_FIRST - 8);
+ CBEN_DRAGBEGINW = (CBEN_FIRST - 9);
+
+{$IFDEF UNICODE}
+
+ CBEN_DRAGBEGIN = CBEN_DRAGBEGINW;
+{$ELSE}
+ CBEN_DRAGBEGIN = CBEN_DRAGBEGINA;
+{$ENDIF}
+
+{$ENDIF} //(_WIN32_IE >= 0x0400)
+TYPE
+{$IFDEF UNICODE}
+ NMCOMBOBOXEX = NMCOMBOBOXEXW;
+ PNMCOMBOBOXEX = PNMCOMBOBOXEXW;
+CONST
+ CBEN_GETDISPINFO = CBEN_GETDISPINFOW;
+{$ELSE}
+ NMCOMBOBOXEX = NMCOMBOBOXEXA;
+ PNMCOMBOBOXEX = PNMCOMBOBOXEXA;
+CONST
+ CBEN_GETDISPINFO = CBEN_GETDISPINFOA;
+{$ENDIF}
+
+// lParam specifies why the endedit is happening
+{$IFDEF UNICODE}
+ CBEN_ENDEDIT = CBEN_ENDEDITW;
+{$ELSE}
+ CBEN_ENDEDIT = CBEN_ENDEDITA;
+{$ENDIF}
+
+
+CONST
+ CBENF_KILLFOCUS = 1;
+ CBENF_RETURN = 2;
+ CBENF_ESCAPE = 3;
+ CBENF_DROPDOWN = 4;
+
+ CBEMAXSTRLEN = 260;
+
+{$ifdef ie4plus}
+// CBEN_DRAGBEGIN sends this information ...
+
+TYPE
+
+ DummyStruct12 = Record
+ hdr : NMHDR;
+ iItemid : cint;
+ szText : Array[0..CBEMAXSTRLEN-1] OF WCHAR;
+ END;
+ NMCBEDRAGBEGINW = DummyStruct12;
+ LPNMCBEDRAGBEGINW = ^DummyStruct12;
+ PNMCBEDRAGBEGINW = ^DummyStruct12;
+ TDummyStruct12 = DummyStruct12;
+ PDummyStruct12 = ^DummyStruct12;
+
+
+
+ DummyStruct13 = Record
+ hdr : NMHDR;
+ iItemid : cint;
+ szText : Array[0..CBEMAXSTRLEN-1] OF char;
+ END;
+ NMCBEDRAGBEGINA = DummyStruct13;
+ LPNMCBEDRAGBEGINA = ^DummyStruct13;
+ PNMCBEDRAGBEGINA = ^DummyStruct13;
+ TDummyStruct13 = DummyStruct13;
+ PDummyStruct13 = ^DummyStruct13;
+
+
+{$IFDEF UNICODE}
+ NMCBEDRAGBEGIN = NMCBEDRAGBEGINW;
+ LPNMCBEDRAGBEGIN = LPNMCBEDRAGBEGINW;
+ PNMCBEDRAGBEGIN = PNMCBEDRAGBEGINW;
+{$ELSE}
+ NMCBEDRAGBEGIN = NMCBEDRAGBEGINA;
+ LPNMCBEDRAGBEGIN = LPNMCBEDRAGBEGINA;
+ PNMCBEDRAGBEGIN = PNMCBEDRAGBEGINA;
+{$ENDIF}
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+// CBEN_ENDEDIT sends this information...
+// fChanged if the user actually did anything
+// iNewSelection gives what would be the new selection unless the notify is failed
+// iNewSelection may be CB_ERR if there's no match
+ DummyStruct14 = Record
+ hdr : NMHDR;
+ fChanged : BOOL;
+ iNewSelection : cint;
+ szText : Array[0..CBEMAXSTRLEN-1] OF WCHAR;
+ iWhy : cint;
+ END;
+ NMCBEENDEDITW = DummyStruct14;
+ LPNMCBEENDEDITW = ^DummyStruct14;
+ PNMCBEENDEDITW = ^DummyStruct14;
+ TDummyStruct14 = DummyStruct14;
+ PDummyStruct14 = ^DummyStruct14;
+
+
+ DummyStruct15 = Record
+ hdr : NMHDR;
+ fChanged : BOOL;
+ iNewSelection : cint;
+ szText : Array[0..CBEMAXSTRLEN-1] OF char;
+ iWhy : cint;
+ END;
+ NMCBEENDEDITA = DummyStruct15;
+ LPNMCBEENDEDITA = ^DummyStruct15;
+ PNMCBEENDEDITA = ^DummyStruct15;
+ TDummyStruct15 = DummyStruct15;
+ PDummyStruct15 = ^DummyStruct15;
+
+
+{$IFDEF UNICODE}
+ NMCBEENDEDIT = NMCBEENDEDITW;
+ LPNMCBEENDEDIT = LPNMCBEENDEDITW;
+ PNMCBEENDEDIT = PNMCBEENDEDITW;
+{$ELSE}
+ NMCBEENDEDIT = NMCBEENDEDITA;
+ LPNMCBEENDEDIT = LPNMCBEENDEDITA;
+ PNMCBEENDEDIT = PNMCBEENDEDITA;
+{$ENDIF}
+
+{$ENDIF}
+
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+
+
+//====== TAB CONTROL ==========================================================
+
+{$IFNDEF NOTABCONTROL}
+
+{$IFDEF _WIN32}
+
+
+CONST
+ WC_TABCONTROLA = 'SysTabControl32';
+ WC_TABCONTROLW = {L}'SysTabControl32';
+
+{$IFDEF UNICODE}
+
+TYPE
+ WC_TABCONTROL = WC_TABCONTROLW;
+{$ELSE}
+ WC_TABCONTROL = WC_TABCONTROLA;
+{$ENDIF}
+
+{$ELSE}
+
+CONST
+ WC_TABCONTROL = 'SysTabControl';
+{$ENDIF}
+
+// begin_r_commctrl
+
+{$ifdef ie3plus}
+ TCS_SCROLLOPPOSITE = $0001; // assumes multiline tab
+ TCS_BOTTOM = $0002;
+ TCS_RIGHT = $0002;
+ TCS_MULTISELECT = $0004; // allow multi-select in button mode
+{$ENDIF}
+{$ifdef ie4plus}
+ TCS_FLATBUTTONS = $0008;
+{$ENDIF}
+ TCS_FORCEICONLEFT = $0010;
+ TCS_FORCELABELLEFT = $0020;
+{$ifdef ie3plus}
+ TCS_HOTTRACK = $0040;
+ TCS_VERTICAL = $0080;
+{$ENDIF}
+ TCS_TABS = $0000;
+ TCS_BUTTONS = $0100;
+ TCS_SINGLELINE = $0000;
+ TCS_MULTILINE = $0200;
+ TCS_RIGHTJUSTIFY = $0000;
+ TCS_FIXEDWIDTH = $0400;
+ TCS_RAGGEDRIGHT = $0800;
+ TCS_FOCUSONBUTTONDOWN = $1000;
+ TCS_OWNERDRAWFIXED = $2000;
+ TCS_TOOLTIPS = $4000;
+ TCS_FOCUSNEVER = $8000;
+
+// end_r_commctrl
+
+{$ifdef ie4plus}
+// EX styles for use with TCM_SETEXTENDEDSTYLE
+ TCS_EX_FLATSEPARATORS = $00000001;
+ TCS_EX_REGISTERDROP = $00000002;
+{$ENDIF}
+
+
+ TCM_GETIMAGELIST = (TCM_FIRST + 2);
+// Macro 217
+
+
+Function TabCtrl_GetImageList( hwnd : hwnd):HIMAGELIST;
+
+
+
+
+CONST
+ TCM_SETIMAGELIST = (TCM_FIRST + 3);
+// Macro 218
+
+
+Function TabCtrl_SetImageList( hwnd : hwnd; himl : HIMAGELIST):HIMAGELIST;
+
+
+
+
+CONST
+ TCM_GETITEMCOUNT = (TCM_FIRST + 4);
+// Macro 219
+
+
+Function TabCtrl_GetItemCount( hwnd : hwnd):cint;
+
+
+
+
+CONST
+ TCIF_TEXT = $0001;
+ TCIF_IMAGE = $0002;
+ TCIF_RTLREADING = $0004;
+ TCIF_PARAM = $0008;
+{$ifdef ie3plus}
+ TCIF_STATE = $0010;
+
+
+ TCIS_BUTTONPRESSED = $0001;
+{$ENDIF}
+{$ifdef ie4plus}
+ TCIS_HIGHLIGHTED = $0002;
+{$ENDIF}
+TYPE
+
+
+
+
+ tagTCITEMHEADERA = Record
+ mask : UINT;
+ lpReserved1 : UINT;
+ lpReserved2 : UINT;
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ END;
+ TCITEMHEADERA = tagTCITEMHEADERA;
+ LPTCITEMHEADERA = ^tagTCITEMHEADERA;
+ TTCITEMHEADERA = tagTCITEMHEADERA;
+ PTCITEMHEADERA = ^tagTCITEMHEADERA;
+
+
+ tagTCITEMHEADERW = Record
+ mask : UINT;
+ lpReserved1 : UINT;
+ lpReserved2 : UINT;
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ END;
+ TCITEMHEADERW = tagTCITEMHEADERW;
+ LPTCITEMHEADERW = ^tagTCITEMHEADERW;
+ TTCITEMHEADERW = tagTCITEMHEADERW;
+ PTCITEMHEADERW = ^tagTCITEMHEADERW;
+
+
+{$IFDEF UNICODE}
+ TCITEMHEADER = TCITEMHEADERW;
+ LPTCITEMHEADER = LPTCITEMHEADERW;
+{$ELSE}
+ TCITEMHEADER = TCITEMHEADERA;
+ LPTCITEMHEADER = LPTCITEMHEADERA;
+{$ENDIF}
+
+
+{$ifdef ie3plus}
+ TC_ITEMHEADERA = TCITEMHEADERA;
+ TC_ITEMHEADERW = TCITEMHEADERW;
+{$ELSE}
+ tagTCITEMHEADERA = _TC_ITEMHEADERA;
+ TCITEMHEADERA = TC_ITEMHEADERA;
+ tagTCITEMHEADERW = _TC_ITEMHEADERW;
+ TCITEMHEADERW = TC_ITEMHEADERW;
+{$ENDIF}
+
+
+ TC_ITEMHEADER = TCITEMHEADER;
+
+
+
+
+
+ tagTCITEMA = Record
+ mask : UINT;
+{$ifdef ie3plus}
+ dwState : DWORD;
+ dwStateMask : DWORD;
+{$ELSE}
+ lpReserved1 : UINT;
+ lpReserved2 : UINT;
+{$ENDIF}
+ pszText : LPSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ lParam : LPARAM;
+ END;
+ TCITEMA = tagTCITEMA;
+ LPTCITEMA = ^tagTCITEMA;
+ TTCITEMA = tagTCITEMA;
+ PTCITEMA = ^tagTCITEMA;
+
+
+ tagTCITEMW = Record
+ mask : UINT;
+{$ifdef ie3plus}
+ dwState : DWORD;
+ dwStateMask : DWORD;
+{$ELSE}
+ lpReserved1 : UINT;
+ lpReserved2 : UINT;
+{$ENDIF}
+ pszText : LPWSTR;
+ cchTextMax : cint;
+ iImage : cint;
+ lParam : LPARAM;
+ END;
+ TCITEMW = tagTCITEMW;
+ LPTCITEMW = ^tagTCITEMW;
+ TTCITEMW = tagTCITEMW;
+ PTCITEMW = ^tagTCITEMW;
+
+
+{$IFDEF UNICODE}
+ TCITEM = TCITEMW;
+ LPTCITEM = LPTCITEMW;
+{$ELSE}
+ TCITEM = TCITEMA;
+ LPTCITEM = LPTCITEMA;
+{$ENDIF}
+
+
+{$ifdef ie3plus}
+ TC_ITEMA = TCITEMA;
+ TC_ITEMW = TCITEMW;
+{$ELSE}
+ tagTCITEMA = _TC_ITEMA;
+ TCITEMA = TC_ITEMA;
+ tagTCITEMW = _TC_ITEMW;
+ TCITEMW = TC_ITEMW;
+{$ENDIF}
+
+
+ TC_ITEM = TCITEM;
+
+
+
+
+CONST
+ TCM_GETITEMA = (TCM_FIRST + 5);
+ TCM_GETITEMW = (TCM_FIRST + 60);
+
+{$IFDEF UNICODE}
+
+TYPE
+ TCM_GETITEM = TCM_GETITEMW;
+{$ELSE}
+ TCM_GETITEM = TCM_GETITEMA;
+{$ENDIF}
+
+// Macro 220
+Function TabCtrl_GetItem( hwnd : hwnd; iItem : cint;var pitem : TC_ITEM ):BOOL;
+
+
+
+
+CONST
+ TCM_SETITEMA = (TCM_FIRST + 6);
+ TCM_SETITEMW = (TCM_FIRST + 61);
+
+{$IFDEF UNICODE}
+
+TYPE
+ TCM_SETITEM = TCM_SETITEMW;
+{$ELSE}
+ TCM_SETITEM = TCM_SETITEMA;
+{$ENDIF}
+
+// Macro 221
+Function TabCtrl_SetItem( hwnd : hwnd; iItem : cint;var pitem : TC_ITEM ):BOOL;
+
+
+
+
+CONST
+ TCM_INSERTITEMA = (TCM_FIRST + 7);
+ TCM_INSERTITEMW = (TCM_FIRST + 62);
+
+{$IFDEF UNICODE}
+ TCM_INSERTITEM = TCM_INSERTITEMW;
+{$ELSE}
+ TCM_INSERTITEM = TCM_INSERTITEMA;
+{$ENDIF}
+
+// Macro 222
+Function TabCtrl_InsertItem( hwnd : hwnd; iItem : cint;CONST pitem : TC_ITEM ):cint;
+
+
+CONST
+ TCM_DELETEITEM = (TCM_FIRST + 8);
+
+// Macro 223
+Function TabCtrl_DeleteItem( hwnd : hwnd; i : cint):BOOL;
+
+CONST
+ TCM_DELETEALLITEMS = (TCM_FIRST + 9);
+
+// Macro 224
+Function TabCtrl_DeleteAllItems( hwnd : hwnd):BOOL;
+
+CONST
+ TCM_GETITEMRECT = (TCM_FIRST + 10);
+
+// Macro 225
+Function TabCtrl_GetItemRect( hwnd : hwnd; i : cint;var prc : RECT ):BOOL;
+
+CONST
+ TCM_GETCURSEL = (TCM_FIRST + 11);
+// Macro 226
+
+Function TabCtrl_GetCurSel( hwnd : hwnd):cint;
+
+
+CONST
+ TCM_SETCURSEL = (TCM_FIRST + 12);
+
+// Macro 227
+Function TabCtrl_SetCurSel( hwnd : hwnd; i : WPARAM):cint;
+
+CONST
+ TCHT_NOWHERE = $0001;
+ TCHT_ONITEMICON = $0002;
+ TCHT_ONITEMLABEL = $0004;
+ TCHT_ONITEM = (TCHT_ONITEMICON OR TCHT_ONITEMLABEL);
+
+TYPE
+
+ tagTCHITTESTINFO = Record
+ pt : POINT;
+ flags : UINT;
+ END;
+ TCHITTESTINFO = tagTCHITTESTINFO;
+ LPTCHITTESTINFO = ^tagTCHITTESTINFO;
+ TTCHITTESTINFO = tagTCHITTESTINFO;
+ PTCHITTESTINFO = ^tagTCHITTESTINFO;
+
+{$ifdef ie3plus}
+ LPTC_HITTESTINFO = LPTCHITTESTINFO;
+ TC_HITTESTINFO = TCHITTESTINFO;
+{$ELSE}
+ tagTCHITTESTINFO = _TC_HITTESTINFO;
+ TCHITTESTINFO = TC_HITTESTINFO;
+ LPTCHITTESTINFO = LPTC_HITTESTINFO;
+{$ENDIF}
+
+
+CONST
+ TCM_HITTEST = (TCM_FIRST + 13);
+
+// Macro 228
+Function TabCtrl_HitTest( hwndTC : hwnd;var pinfo : TC_HITTESTINFO ):cint;inline;
+Function TabCtrl_HitTest( hwndTC : hwnd;pinfo : LPTCHITTESTINFO ):cint;inline;
+
+CONST
+ TCM_SETITEMEXTRA = (TCM_FIRST + 14);
+
+// Macro 229
+Function TabCtrl_SetItemExtra( hwndTC : hwnd; cb : WPARAM):BOOL;
+
+
+
+
+CONST
+ TCM_ADJUSTRECT = (TCM_FIRST + 40);
+
+// Macro 230
+Function TabCtrl_AdjustRect( hwnd : hwnd; bLarger : BOOL;var prc : RECT ):cint;
+
+
+
+
+CONST
+ TCM_SETITEMSIZE = (TCM_FIRST + 41);
+
+// Macro 231
+Function TabCtrl_SetItemSize( hwnd : hwnd; x :wparam ; y : lparam ):DWORD;
+
+CONST
+ TCM_REMOVEIMAGE = (TCM_FIRST + 42);
+
+// Macro 232
+Procedure TabCtrl_RemoveImage( hwnd : hwnd; i : wparam );
+
+
+
+
+CONST
+ TCM_SETPADDING = (TCM_FIRST + 43);
+
+// Macro 233
+Procedure TabCtrl_SetPadding( hwnd : hwnd; cx : wparam ; cy : lparam );
+
+
+
+
+CONST
+ TCM_GETROWCOUNT = (TCM_FIRST + 44);
+
+// Macro 234
+Function TabCtrl_GetRowCount( hwnd : hwnd):cint;
+
+
+
+
+CONST
+ TCM_GETTOOLTIPS = (TCM_FIRST + 45);
+
+// Macro 235
+Function TabCtrl_GetToolTips( hwnd : hwnd):HWND;
+
+
+
+
+CONST
+ TCM_SETTOOLTIPS = (TCM_FIRST + 46);
+
+// Macro 236
+Procedure TabCtrl_SetToolTips( hwnd : hwnd; hwndTT : WPARAM);
+
+
+
+
+CONST
+ TCM_GETCURFOCUS = (TCM_FIRST + 47);
+// Macro 237
+
+
+Function TabCtrl_GetCurFocus( hwnd : hwnd):cint;
+
+
+
+CONST
+ TCM_SETCURFOCUS = (TCM_FIRST + 48);
+
+// Macro 238
+Procedure TabCtrl_SetCurFocus( hwnd : hwnd; i : LParam );
+
+
+{$ifdef ie3plus}
+
+CONST
+ TCM_SETMINTABWIDTH = (TCM_FIRST + 49);
+
+// Macro 239
+Function TabCtrl_SetMinTabWidth( hwnd : hwnd; x : WParam ):cint;
+
+
+CONST
+ TCM_DESELECTALL = (TCM_FIRST + 50);
+
+// Macro 240
+Procedure TabCtrl_DeselectAll( hwnd : hwnd; fExcludeFocus : WPARAM );
+
+{$ENDIF}
+
+{$ifdef ie4plus}
+CONST
+ TCM_HIGHLIGHTITEM = (TCM_FIRST + 51);
+
+// Macro 241
+Function TabCtrl_HighlightItem( hwnd : hwnd; i : WPARAM; fHighlight :bool):BOOL;
+
+
+
+CONST
+ TCM_SETEXTENDEDSTYLE = (TCM_FIRST + 52); // optional wParam == mask
+
+// Macro 242
+Function TabCtrl_SetExtendedStyle( hwnd : hwnd; dw :LPARAM ):DWORD;
+
+
+CONST
+ TCM_GETEXTENDEDSTYLE = (TCM_FIRST + 53);
+
+// Macro 243
+Function TabCtrl_GetExtendedStyle( hwnd : hwnd):DWORD;
+
+
+
+CONST
+ TCM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+
+// Macro 244
+Function TabCtrl_SetUnicodeFormat( hwnd : hwnd; fUnicode : WPARAM):BOOL;
+
+
+
+CONST
+ TCM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+
+// Macro 245
+Function TabCtrl_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+
+CONST
+ TCN_KEYDOWN = (TCN_FIRST - 0);
+
+
+{$IFDEF _WIN32}
+// #include <pshpack1.h>
+{$ENDIF}
+
+TYPE
+
+ tagTCKEYDOWN = Record
+ hdr : NMHDR;
+ wVKey : WORD;
+ flags : UINT;
+ END;
+ NMTCKEYDOWN = tagTCKEYDOWN;
+ TTCKEYDOWN = tagTCKEYDOWN;
+ PTCKEYDOWN = ^tagTCKEYDOWN;
+
+{$ifdef ie3plus}
+ TC_KEYDOWN = NMTCKEYDOWN;
+{$ELSE}
+ tagTCKEYDOWN = _TC_KEYDOWN;
+ NMTCKEYDOWN = TC_KEYDOWN;
+{$ENDIF}
+
+
+{$IFDEF _WIN32}
+// #include <poppack.h>
+{$ENDIF}
+
+
+CONST
+ TCN_SELCHANGE = (TCN_FIRST - 1);
+ TCN_SELCHANGING = (TCN_FIRST - 2);
+{$ifdef ie4plus}
+ TCN_GETOBJECT = (TCN_FIRST - 3);
+{$ENDIF} // _WIN32_IE >= 0x0400
+{$ifdef ie5plus}
+ TCN_FOCUSCHANGE = (TCN_FIRST - 4);
+{$ENDIF} // _WIN32_IE >= 0x0500
+{$ENDIF} // NOTABCONTROL
+
+//====== ANIMATE CONTROL ======================================================
+
+{$IFNDEF NOANIMATE}
+
+{$IFDEF _WIN32}
+
+ ANIMATE_CLASSW = {L}'SysAnimate32';
+ ANIMATE_CLASSA = 'SysAnimate32';
+
+{$IFDEF UNICODE}
+ ANIMATE_CLASS = ANIMATE_CLASSW;
+{$ELSE}
+ ANIMATE_CLASS = ANIMATE_CLASSA;
+{$ENDIF}
+
+// begin_r_commctrl
+
+
+CONST
+ ACS_CENTER = $0001;
+ ACS_TRANSPARENT = $0002;
+ ACS_AUTOPLAY = $0004;
+{$ifdef ie3plus}
+ ACS_TIMER = $0008; // don't use threads... use timers
+{$ENDIF}
+
+// end_r_commctrl
+
+ ACM_OPENA = (WM_USER+100);
+ ACM_OPENW = (WM_USER+103);
+
+{$IFDEF UNICODE}
+
+
+ ACM_OPEN = ACM_OPENW;
+{$ELSE}
+ ACM_OPEN = ACM_OPENA;
+{$ENDIF}
+
+
+CONST
+ ACM_PLAY = (WM_USER+101);
+ ACM_STOP = (WM_USER+102);
+
+
+ ACN_START = 1;
+ ACN_STOP = 2;
+
+
+// Macro 246
+
+
+Function Animate_Create(hwndP :HWND;id:HMENU;dwStyle:dword;hInstance:HINST):HWND;
+
+// Macro 247
+
+// #define Animate_Open(hwnd, szName) (BOOL)SNDMSG(hwnd, ACM_OPEN, 0, (LPARAM)(LPTSTR)(szName))
+// Macro 248
+
+// #define Animate_OpenEx(hwnd, hInst, szName) (BOOL)SNDMSG(hwnd, ACM_OPEN, (WPARAM)(hInst), (LPARAM)(LPTSTR)(szName))
+// Macro 249
+
+// #define Animate_Play(hwnd, from, to, rep) (BOOL)SNDMSG(hwnd, ACM_PLAY, (WPARAM)(rep), (LPARAM)MAKELONG(from, to))
+// Macro 250
+
+// #define Animate_Stop(hwnd) (BOOL)SNDMSG(hwnd, ACM_STOP, 0, 0)
+// Macro 251
+
+// #define Animate_Close(hwnd) Animate_Open(hwnd, NULL)
+// Macro 252
+
+// #define Animate_Seek(hwnd, frame) Animate_Play(hwnd, frame, frame, 1)
+{$ENDIF}
+
+{$ENDIF} // NOANIMATE
+
+{$ifdef ie3plus}
+//====== MONTHCAL CONTROL ======================================================
+
+{$IFNDEF NOMONTHCAL}
+{$IFDEF _WIN32}
+
+
+CONST
+ MONTHCAL_CLASSW = {L}'SysMonthCal32';
+ MONTHCAL_CLASSA = 'SysMonthCal32';
+
+
+{$IFDEF UNICODE}
+ MONTHCAL_CLASS = MONTHCAL_CLASSW;
+{$ELSE}
+ MONTHCAL_CLASS = MONTHCAL_CLASSA;
+{$ENDIF}
+
+TYPE
+// bit-packed array of "bold" info for a month
+// if a bit is on, that day is drawn bold
+
+ MONTHDAYSTATE = DWORD;
+ LPMONTHDAYSTATE = ^MONTHDAYSTATE;
+ TMonthDayState = MONTHDAYSTATE;
+ PMonthDayState = LPMONTHDAYSTATE;
+
+
+CONST
+ MCM_FIRST = $1000;
+
+// BOOL MonthCal_GetCurSel(HWND hmc, LPSYSTEMTIME pst)
+// returns FALSE if MCS_MULTISELECT
+// returns TRUE and sets *pst to the currently selected date otherwise
+
+
+
+
+CONST
+ MCM_GETCURSEL = (MCM_FIRST + 1);
+
+// Macro 253
+// #define MonthCal_GetCurSel(hmc, pst) (BOOL)SNDMSG(hmc, MCM_GETCURSEL, 0, (LPARAM)(pst))
+
+function MonthCal_GetCurSel(hwndMC:HWND; lpSysTime :LPSYSTEMTIME):Bool;
+
+// BOOL MonthCal_SetCurSel(HWND hmc, LPSYSTEMTIME pst)
+// returns FALSE if MCS_MULTISELECT
+// returns TURE and sets the currently selected date to *pst otherwise
+
+
+
+CONST
+ MCM_SETCURSEL = (MCM_FIRST + 2);
+
+// Macro 254
+// #define MonthCal_SetCurSel(hmc, pst) (BOOL)SNDMSG(hmc, MCM_SETCURSEL, 0, (LPARAM)(pst))
+// DWORD MonthCal_GetMaxSelCount(HWND hmc)
+// returns the maximum number of selectable days allowed
+
+function MonthCal_SetCurSel(hwndMC:HWND; lpSysTime :LPSYSTEMTIME):Bool;inline;
+function MonthCal_SetCurSel(hwndMC:HWND; var lpSysTime :TSYSTEMTIME):Bool;inline;
+
+
+CONST
+ MCM_GETMAXSELCOUNT = (MCM_FIRST + 3);
+
+// Macro 255
+// #define MonthCal_GetMaxSelCount(hmc) (DWORD)SNDMSG(hmc, MCM_GETMAXSELCOUNT, 0, 0L)
+// BOOL MonthCal_SetMaxSelCount(HWND hmc, UINT n)
+// sets the max number days that can be selected iff MCS_MULTISELECT
+
+function MonthCal_GetMaxSelCount(hwndMC:HWND):Bool;
+
+CONST
+ MCM_SETMAXSELCOUNT = (MCM_FIRST + 4);
+
+// Macro 256
+// #define MonthCal_SetMaxSelCount(hmc, n) (BOOL)SNDMSG(hmc, MCM_SETMAXSELCOUNT, (WPARAM)(n), 0L)
+
+function MonthCal_SetMaxSelCount(hwndMC:HWND;n:uint):Bool;
+
+// BOOL MonthCal_GetSelRange(HWND hmc, LPSYSTEMTIME rgst)
+// sets rgst[0] to the first day of the selection range
+// sets rgst[1] to the last day of the selection range
+
+CONST
+ MCM_GETSELRANGE = (MCM_FIRST + 5);
+
+// Macro 257
+// #define MonthCal_GetSelRange(hmc, rgst) SNDMSG(hmc, MCM_GETSELRANGE, 0, (LPARAM)(rgst))
+// BOOL MonthCal_SetSelRange(HWND hmc, LPSYSTEMTIME rgst)
+// selects the range of days from rgst[0] to rgst[1]
+
+function MonthCal_GetSelRange(hwndMC:HWND; lpSysTime :LPSYSTEMTIME):Bool;
+
+
+CONST
+ MCM_SETSELRANGE = (MCM_FIRST + 6);
+
+// Macro 258
+// #define MonthCal_SetSelRange(hmc, rgst) SNDMSG(hmc, MCM_SETSELRANGE, 0, (LPARAM)(rgst))
+// DWORD MonthCal_GetMonthRange(HWND hmc, DWORD gmr, LPSYSTEMTIME rgst)
+// if rgst specified, sets rgst[0] to the starting date and
+// and rgst[1] to the ending date of the the selectable (non-grayed)
+// days if GMR_VISIBLE or all the displayed days (including grayed)
+// if GMR_DAYSTATE.
+// returns the number of months spanned by the above range.
+
+function MonthCal_SetSelRange(hwndMC:HWND; lpSysTime :LPSYSTEMTIME):Bool;
+
+
+CONST
+ MCM_GETMONTHRANGE = (MCM_FIRST + 7);
+
+// Macro 259
+// #define MonthCal_GetMonthRange(hmc, gmr, rgst) (DWORD)SNDMSG(hmc, MCM_GETMONTHRANGE, (WPARAM)(gmr), (LPARAM)(rgst))
+// BOOL MonthCal_SetDayState(HWND hmc, int cbds, DAYSTATE *rgds)
+// cbds is the count of DAYSTATE items in rgds and it must be equal
+// to the value returned from MonthCal_GetMonthRange(hmc, GMR_DAYSTATE, NULL)
+// This sets the DAYSTATE bits for each month (grayed and non-grayed
+// days) displayed in the calendar. The first bit in a month's DAYSTATE
+// corresponts to bolding day 1, the second bit affects day 2, etc.
+
+function MonthCal_GetMonthRange(hwndMC:HWND; gmr: DWORD;lpSysTime :LPSYSTEMTIME):Bool;
+
+
+CONST
+ MCM_SETDAYSTATE = (MCM_FIRST + 8);
+
+// Macro 260
+// #define MonthCal_SetDayState(hmc, cbds, rgds) SNDMSG(hmc, MCM_SETDAYSTATE, (WPARAM)(cbds), (LPARAM)(rgds))
+// BOOL MonthCal_GetMinReqRect(HWND hmc, LPRECT prc)
+// sets *prc the minimal size needed to display one month
+// To display two months, undo the AdjustWindowRect calculation already done to
+// this rect, double the width, and redo the AdjustWindowRect calculation --
+// the monthcal control will display two calendars in this window (if you also
+// double the vertical size, you will get 4 calendars)
+// NOTE: if you want to gurantee that the "Today" string is not clipped,
+// get the MCM_GETMAXTODAYWIDTH and use the max of that width and this width
+
+function MonthCal_SetDayState(hwndMC:HWND; gmr: Longint;lpDay :LPMONTHDAYSTATE):Bool;
+
+
+CONST
+ MCM_GETMINREQRECT = (MCM_FIRST + 9);
+
+// Macro 261
+// #define MonthCal_GetMinReqRect(hmc, prc) SNDMSG(hmc, MCM_GETMINREQRECT, 0, (LPARAM)(prc))
+// set colors to draw control with -- see MCSC_ bits below
+
+function MonthCal_GetMinReqRect(hwndMC:HWND; lpr :LPRect):Bool;inline;
+function MonthCal_GetMinReqRect(hwndMC:HWND; var lpr :TRect):Bool;inline;
+
+
+CONST
+ MCM_SETCOLOR = (MCM_FIRST + 10);
+
+// Macro 262
+// #define MonthCal_SetColor(hmc, iColor, clr) SNDMSG(hmc, MCM_SETCOLOR, iColor, clr)
+
+function MonthCal_SetColor(hwndMC:HWND; ic:longint;clr:COLORREF):DWORD;inline;
+
+
+CONST
+ MCM_GETCOLOR = (MCM_FIRST + 11);
+
+// Macro 263
+// #define MonthCal_GetColor(hmc, iColor) SNDMSG(hmc, MCM_GETCOLOR, iColor, 0)
+
+function MonthCal_GetColor(hwndMC:HWND; ic:longint):Bool;
+
+
+CONST
+ MCSC_BACKGROUND = 0; // the background color (between months)
+ MCSC_TEXT = 1; // the dates
+ MCSC_TITLEBK = 2; // background of the title
+ MCSC_TITLETEXT = 3;
+ MCSC_MONTHBK = 4; // background within the month cal
+ MCSC_TRAILINGTEXT = 5; // the text color of header & trailing days
+
+// set what day is "today" send NULL to revert back to real date
+ MCM_SETTODAY = (MCM_FIRST + 12);
+
+// Macro 264
+// #define MonthCal_SetToday(hmc, pst) SNDMSG(hmc, MCM_SETTODAY, 0, (LPARAM)(pst))
+// get what day is "today"
+// returns BOOL for success/failure
+
+function MonthCal_SetToday(hwndMC:HWND; lps:LPSYSTEMTIME):Bool;
+
+
+CONST
+ MCM_GETTODAY = (MCM_FIRST + 13);
+
+// Macro 265
+// #define MonthCal_GetToday(hmc, pst) (BOOL)SNDMSG(hmc, MCM_GETTODAY, 0, (LPARAM)(pst))
+// determine what pinfo->pt is over
+
+function MonthCal_GetToday(hwndMC:HWND; lps:LPSYSTEMTIME):Bool;
+
+
+CONST
+ MCM_HITTEST = (MCM_FIRST + 14);
+
+TYPE
+
+ DummyStruct16 = Record
+ cbSize : UINT;
+ pt : POINT;
+ uHit : UINT; // out param
+ st : SYSTEMTIME;
+{$ifdef NTDDI_VISTA}
+ rc : RECT;
+ iOffset : cint;
+ iRow : cint;
+ iCol : cint;
+{$endif}
+ END;
+ MCHITTESTINFO = DummyStruct16;
+ PMCHITTESTINFO = ^DummyStruct16;
+ TDummyStruct16 = DummyStruct16;
+ PDummyStruct16 = ^DummyStruct16;
+
+
+// Macro 266
+FUNCTION MonthCal_HitTest( hmc :HWND ; pinfo : PMCHITTESTINFO):DWORD;
+
+
+CONST
+ MCHT_TITLE = $00010000;
+ MCHT_CALENDAR = $00020000;
+ MCHT_TODAYLINK = $00030000;
+
+ MCHT_NEXT = $01000000; // these indicate that hitting
+ MCHT_PREV = $02000000; // here will go to the next/prev month
+
+ MCHT_NOWHERE = $00000000;
+
+ MCHT_TITLEBK = (MCHT_TITLE);
+ MCHT_TITLEMONTH = (MCHT_TITLE OR $0001);
+ MCHT_TITLEYEAR = (MCHT_TITLE OR $0002);
+ MCHT_TITLEBTNNEXT = (MCHT_TITLE OR MCHT_NEXT OR $0003);
+ MCHT_TITLEBTNPREV = (MCHT_TITLE OR MCHT_PREV OR $0003);
+
+ MCHT_CALENDARBK = (MCHT_CALENDAR);
+ MCHT_CALENDARDATE = (MCHT_CALENDAR OR $0001);
+ MCHT_CALENDARDATENEXT = (MCHT_CALENDARDATE OR MCHT_NEXT);
+ MCHT_CALENDARDATEPREV = (MCHT_CALENDARDATE OR MCHT_PREV);
+ MCHT_CALENDARDAY = (MCHT_CALENDAR OR $0002);
+ MCHT_CALENDARWEEKNUM = (MCHT_CALENDAR OR $0003);
+
+// set first day of week to iDay:
+// 0 for Monday, 1 for Tuesday, ..., 6 for Sunday
+// -1 for means use locale info
+ MCM_SETFIRSTDAYOFWEEK = (MCM_FIRST + 15);
+// Macro 267
+
+
+function MonthCal_SetFirstDayOfWeek( hmc : HWND ; iDay :LONGINT ):DWORD;
+
+
+// DWORD result... low word has the day. high word is bool if this is app set
+// or not (FALSE == using locale info)
+
+CONST
+ MCM_GETFIRSTDAYOFWEEK = (MCM_FIRST + 16);
+// Macro 268
+
+
+Function MonthCal_GetFirstDayOfWeek( hmc : HWND ):DWORD;
+
+
+// DWORD MonthCal_GetRange(HWND hmc, LPSYSTEMTIME rgst)
+// modifies rgst[0] to be the minimum ALLOWABLE systemtime (or 0 if no minimum)
+// modifies rgst[1] to be the maximum ALLOWABLE systemtime (or 0 if no maximum)
+// returns GDTR_MIN|GDTR_MAX if there is a minimum|maximum limit
+
+CONST
+ MCM_GETRANGE = (MCM_FIRST + 17);
+// Macro 269
+
+
+Function MonthCal_GetRange( hmc : HWND ; rgst : LPSYSTEMTIME):DWORD;
+
+
+// BOOL MonthCal_SetRange(HWND hmc, DWORD gdtr, LPSYSTEMTIME rgst)
+// if GDTR_MIN, sets the minimum ALLOWABLE systemtime to rgst[0], otherwise removes minimum
+// if GDTR_MAX, sets the maximum ALLOWABLE systemtime to rgst[1], otherwise removes maximum
+// returns TRUE on success, FALSE on error (such as invalid parameters)
+
+CONST
+ MCM_SETRANGE = (MCM_FIRST + 18);
+// Macro 270
+
+
+Function MonthCal_SetRange( hmc : HWND ; gd : DWORD; rgst : LPSYSTEMTIME):BOOL;
+
+
+// int MonthCal_GetMonthDelta(HWND hmc)
+// returns the number of months one click on a next/prev button moves by
+
+CONST
+ MCM_GETMONTHDELTA = (MCM_FIRST + 19);
+// Macro 271
+
+
+Function MonthCal_GetMonthDelta( hmc :hwnd ):cint;
+
+
+// int MonthCal_SetMonthDelta(HWND hmc, int n)
+// sets the month delta to n. n==0 reverts to moving by a page of months
+// returns the previous value of n.
+
+CONST
+ MCM_SETMONTHDELTA = (MCM_FIRST + 20);
+// Macro 272
+
+
+Function MonthCal_SetMonthDelta( hmc :hwnd ; n :cint ):cint;
+
+
+// DWORD MonthCal_GetMaxTodayWidth(HWND hmc, LPSIZE psz)
+// sets *psz to the maximum width/height of the "Today" string displayed
+// at the bottom of the calendar (as long as MCS_NOTODAY is not specified)
+
+CONST
+ MCM_GETMAXTODAYWIDTH = (MCM_FIRST + 21);
+// Macro 273
+
+
+Function MonthCal_GetMaxTodayWidth( hmc :hwnd ):DWORD;
+
+
+{$ifdef ie4plus}
+
+CONST
+ MCM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+// Macro 274
+
+
+Function MonthCal_SetUnicodeFormat( hwnd : hwnd; fUnicode : bool):BOOL;
+
+
+CONST
+ MCM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+// Macro 275
+
+
+Function MonthCal_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+{$ifdef NTDDI_VISTA}
+Const
+// View
+ MCMV_MONTH = 0;
+ MCMV_YEAR = 1;
+ MCMV_DECADE = 2;
+ MCMV_CENTURY = 3;
+ MCMV_MAX = MCMV_CENTURY;
+
+ MCM_GETCURRENTVIEW = (MCM_FIRST + 22);
+ MCM_GETCALENDARCOUNT = (MCM_FIRST + 23);
+ MCM_GETCALENDARGRIDINFO = (MCM_FIRST + 24);
+ MCM_GETCALID = (MCM_FIRST + 27);
+ MCM_SETCALID = (MCM_FIRST + 28);
+// Returns the min rect that will fit the max number of calendars for the passed in rect.
+ MCM_SIZERECTTOMIN = (MCM_FIRST + 29);
+ MCM_SETCALENDARBORDER = (MCM_FIRST + 30);
+ MCM_GETCALENDARBORDER = (MCM_FIRST + 31);
+ MCM_SETCURRENTVIEW = (MCM_FIRST + 32);
+
+// Part
+ MCGIP_CALENDARCONTROL = 0;
+ MCGIP_NEXT = 1;
+ MCGIP_PREV = 2;
+ MCGIP_FOOTER = 3;
+ MCGIP_CALENDAR = 4;
+ MCGIP_CALENDARHEADER = 5;
+ MCGIP_CALENDARBODY = 6;
+ MCGIP_CALENDARROW = 7;
+ MCGIP_CALENDARCELL = 8;
+
+ MCGIF_DATE = $00000001;
+ MCGIF_RECT = $00000002;
+ MCGIF_NAME = $00000004;
+
+// Note: iRow of -1 refers to the row header and iCol of -1 refers to the col header.
+
+Type
+ tagMCGRIDINFO = record
+ cbSize : UINT;
+ dwPart : DWORD;
+ dwFlags : DWORD;
+ iCalendar : longint;
+ iRow : longint;
+ iCol : longint;
+ bSelected : BOOL;
+ stStart : SYSTEMTIME;
+ stEnd : SYSTEMTIME;
+ rc : RECT;
+ pszName : LPWSTR;
+ cchName : size_t;
+ end;
+ MCGRIDINFO = tagMCGRIDINFO;
+ TPMCGRIDINFO = MCGRIDINFO;
+ PMCGRIDINFO = ^MCGRIDINFO;
+ LPMCGRIDINFO = PMCGRIDINFO;
+
+function MonthCal_GetCurrentView(hmc:HWND):DWORD;
+// (DWORD)SNDMSG(hmc, MCM_GETCURRENTVIEW, 0, 0)
+
+function MonthCal_GetCalendarCount(hmc:HWND):DWORD;
+// (DWORD)SNDMSG(hmc, MCM_GETCALENDARCOUNT, 0, 0)
+
+function MonthCal_GetCalendarGridInfo(hmc:HWND; pmc:pMCGRIDINFO):BOOL;
+// (BOOL)SNDMSG(hmc, MCM_GETCALENDARGRIDINFO, 0, (LPARAM)(PMCGRIDINFO)(pmcGridInfo))
+
+function MonthCal_GetCALID(hmc:HWND):CALID;
+// (CALID)SNDMSG(hmc, MCM_GETCALID, 0, 0)
+
+function MonthCal_SetCALID(hmc:HWND; calid:cuint):LRESULT;
+// SNDMSG(hmc, MCM_SETCALID, (WPARAM)(calid), 0)
+
+function MonthCal_SizeRectToMin(hmc:HWND; prc:prect):LRESULT;
+// SNDMSG(hmc, MCM_SIZERECTTOMIN, 0, (LPARAM)(prc))
+
+function MonthCal_SetCalendarBorder(hmc:HWND; fset:bool; xyborder:cint):LRESULT;
+// SNDMSG(hmc, MCM_SETCALENDARBORDER, (WPARAM)(fset), (LPARAM)(xyborder))
+
+function MonthCal_GetCalendarBorder(hmc:HWND):cint;
+// (int)SNDMSG(hmc, MCM_GETCALENDARBORDER, 0, 0)
+
+function MonthCal_SetCurrentView(hmc:HWND; dwNewView:DWord):BOOL;
+// (BOOL)SNDMSG(hmc, MCM_SETCURRENTVIEW, 0, (LPARAM)(dwNewView))
+
+
+{$endif}
+
+{$ENDIF}
+
+// MCN_SELCHANGE is sent whenever the currently displayed date changes
+// via month change, year change, keyboard navigation, prev/next button
+//
+TYPE
+
+ tagNMSELCHANGE = Record
+ nmhdr : NMHDR; // this must be first, so we don't break WM_NOTIFY
+ stSelStart : SYSTEMTIME;
+ stSelEnd : SYSTEMTIME;
+ END;
+ NMSELCHANGE = tagNMSELCHANGE;
+ LPNMSELCHANGE = ^tagNMSELCHANGE;
+ TNMSELCHANGE = tagNMSELCHANGE;
+ PNMSELCHANGE = ^tagNMSELCHANGE;
+
+
+
+CONST
+ MCN_SELCHANGE = (MCN_FIRST + 1);
+
+// MCN_GETDAYSTATE is sent for MCS_DAYSTATE controls whenever new daystate
+// information is needed (month or year scroll) to draw bolding information.
+// The app must fill in cDayState months worth of information starting from
+// stStart date. The app may fill in the array at prgDayState or change
+// prgDayState to point to a different array out of which the information
+// will be copied. (similar to tooltips)
+//
+TYPE
+
+ tagNMDAYSTATE = Record
+ nmhdr : NMHDR; // this must be first, so we don't break WM_NOTIFY
+ stStart : SYSTEMTIME;
+ cDayState : cint;
+ prgDayState : LPMONTHDAYSTATE; // points to cDayState MONTHDAYSTATEs
+ END;
+ NMDAYSTATE = tagNMDAYSTATE;
+ LPNMDAYSTATE = ^tagNMDAYSTATE;
+ TNMDAYSTATE = tagNMDAYSTATE;
+ PNMDAYSTATE = ^tagNMDAYSTATE;
+
+
+
+CONST
+ MCN_GETDAYSTATE = (MCN_FIRST + 3);
+
+// MCN_SELECT is sent whenever a selection has occured (via mouse or keyboard)
+//
+TYPE
+
+ NMSELECT = NMSELCHANGE;
+ LPNMSELECT = ^NMSELCHANGE;
+
+
+CONST
+ MCN_SELECT = (MCN_FIRST + 4);
+
+
+// begin_r_commctrl
+
+ MCS_DAYSTATE = $0001;
+ MCS_MULTISELECT = $0002;
+ MCS_WEEKNUMBERS = $0004;
+{$ifdef ie4plus}
+ MCS_NOTODAYCIRCLE = $0008;
+ MCS_NOTODAY = $0010;
+{$ELSE}
+ MCS_NOTODAY = $0008;
+{$ENDIF}
+{$ifdef NTDDI_Vista}
+ MCS_NOTRAILINGDATES = $0040;
+ MCS_SHORTDAYSOFWEEK = $0080;
+ MCS_NOSELCHANGEONNAV = $0100;
+{$endif}
+
+ GMR_VISIBLE = 0; // visible portion of display
+ GMR_DAYSTATE = 1; // above plus the grayed out parts of
+ // partially displayed months
+
+
+{$ENDIF} // _WIN32
+{$ENDIF} // NOMONTHCAL
+
+
+//====== DATETIMEPICK CONTROL ==================================================
+
+{$IFNDEF NODATETIMEPICK}
+{$IFDEF _WIN32}
+
+ DATETIMEPICK_CLASSW = {L}'SysDateTimePick32';
+ DATETIMEPICK_CLASSA = 'SysDateTimePick32';
+
+{$IFDEF UNICODE}
+ DATETIMEPICK_CLASS = DATETIMEPICK_CLASSW;
+{$ELSE}
+ DATETIMEPICK_CLASS = DATETIMEPICK_CLASSA;
+{$ENDIF}
+
+{$ifdef NTDDI_VISTA}
+Type
+ tagDATETIMEPICKERINFO = packed record
+ cbSize : DWORD;
+ rcCheck : RECT;
+ stateCheck : DWORD;
+ rcButton : RECT;
+ stateButton : DWORD;
+ hwndEdit : HWND;
+ hwndUD : HWND;
+ hwndDropDown : HWND;
+ end;
+ DATETIMEPICKERINFO = tagDATETIMEPICKERINFO;
+ PDATETIMEPICKERINFO = ^DATETIMEPICKERINFO;
+ LPDATETIMEPICKERINFO = PDATETIMEPICKERINFO;
+ TDATETIMEPICKERINFO = DATETIMEPICKERINFO;
+{$endif}
+
+CONST
+ DTM_FIRST = $1000;
+
+// DWORD DateTimePick_GetSystemtime(HWND hdp, LPSYSTEMTIME pst)
+// returns GDT_NONE if "none" is selected (DTS_SHOWNONE only)
+// returns GDT_VALID and modifies *pst to be the currently selected value
+ DTM_GETSYSTEMTIME = (DTM_FIRST + 1);
+// Macro 276
+
+// #define DateTime_GetSystemtime(hdp, pst) (DWORD)SNDMSG(hdp, DTM_GETSYSTEMTIME, 0, (LPARAM)(pst))
+
+// BOOL DateTime_SetSystemtime(HWND hdp, DWORD gd, LPSYSTEMTIME pst)
+// if gd==GDT_NONE, sets datetimepick to None (DTS_SHOWNONE only)
+// if gd==GDT_VALID, sets datetimepick to *pst
+// returns TRUE on success, FALSE on error (such as bad params)
+
+CONST
+ DTM_SETSYSTEMTIME = (DTM_FIRST + 2);
+// Macro 277
+
+// #define DateTime_SetSystemtime(hdp, gd, pst) (BOOL)SNDMSG(hdp, DTM_SETSYSTEMTIME, (WPARAM)(gd), (LPARAM)(pst))
+function DateTime_SetSystemTime(hdp: HWND; gd: DWORD; const pst: TSystemTime): BOOL;inline;
+
+// DWORD DateTime_GetRange(HWND hdp, LPSYSTEMTIME rgst)
+// modifies rgst[0] to be the minimum ALLOWABLE systemtime (or 0 if no minimum)
+// modifies rgst[1] to be the maximum ALLOWABLE systemtime (or 0 if no maximum)
+// returns GDTR_MIN|GDTR_MAX if there is a minimum|maximum limit
+
+CONST
+ DTM_GETRANGE = (DTM_FIRST + 3);
+// Macro 278
+
+// #define DateTime_GetRange(hdp, rgst) (DWORD)SNDMSG(hdp, DTM_GETRANGE, 0, (LPARAM)(rgst))
+
+// BOOL DateTime_SetRange(HWND hdp, DWORD gdtr, LPSYSTEMTIME rgst)
+// if GDTR_MIN, sets the minimum ALLOWABLE systemtime to rgst[0], otherwise removes minimum
+// if GDTR_MAX, sets the maximum ALLOWABLE systemtime to rgst[1], otherwise removes maximum
+// returns TRUE on success, FALSE on error (such as invalid parameters)
+
+CONST
+ DTM_SETRANGE = (DTM_FIRST + 4);
+// Macro 279
+
+// #define DateTime_SetRange(hdp, gd, rgst) (BOOL)SNDMSG(hdp, DTM_SETRANGE, (WPARAM)(gd), (LPARAM)(rgst))
+function DateTime_SetRange(hdp: HWND; gdtr: DWORD; rgst: PSystemTime): BOOL;inline;
+
+// BOOL DateTime_SetFormat(HWND hdp, LPCTSTR sz)
+// sets the display formatting string to sz (see GetDateFormat and GetTimeFormat for valid formatting chars)
+// NOTE: 'X' is a valid formatting character which indicates that the application
+// will determine how to display information. Such apps must support DTN_WMKEYDOWN,
+// DTN_FORMAT, and DTN_FORMATQUERY.
+
+CONST
+ DTM_SETFORMATA = (DTM_FIRST + 5);
+ DTM_SETFORMATW = (DTM_FIRST + 50);
+
+{$IFDEF UNICODE}
+
+TYPE
+ DTM_SETFORMAT = DTM_SETFORMATW;
+{$ELSE}
+ DTM_SETFORMAT = DTM_SETFORMATA;
+{$ENDIF}
+
+// Macro 280
+
+// #define DateTime_SetFormat(hdp, sz) (BOOL)SNDMSG(hdp, DTM_SETFORMAT, 0, (LPARAM)(sz))
+
+
+
+CONST
+ DTM_SETMCCOLOR = (DTM_FIRST + 6);
+// Macro 281
+
+// #define DateTime_SetMonthCalColor(hdp, iColor, clr) SNDMSG(hdp, DTM_SETMCCOLOR, iColor, clr)
+function DateTime_SetMonthCalColor(hdp: HWND; iColor: DWORD; clr: TColorRef): TColorRef;inline;
+
+CONST
+ DTM_GETMCCOLOR = (DTM_FIRST + 7);
+// Macro 282
+
+// #define DateTime_GetMonthCalColor(hdp, iColor) SNDMSG(hdp, DTM_GETMCCOLOR, iColor, 0)
+
+// HWND DateTime_GetMonthCal(HWND hdp)
+// returns the HWND of the MonthCal popup window. Only valid
+// between DTN_DROPDOWN and DTN_CLOSEUP notifications.
+
+CONST
+ DTM_GETMONTHCAL = (DTM_FIRST + 8);
+// Macro 283
+
+// #define DateTime_GetMonthCal(hdp) (HWND)SNDMSG(hdp, DTM_GETMONTHCAL, 0, 0)
+function DateTime_GetMonthCal(hdp: HWND): HWND;inline;
+
+{$ifdef ie4plus}
+
+
+CONST
+ DTM_SETMCFONT = (DTM_FIRST + 9);
+
+// Macro 284
+procedure DateTime_SetMonthCalFont(hdp:HWND; hfont:HFONT; fRedraw:LPARAM);
+// SNDMSG(hdp, DTM_SETMCFONT, (WPARAM)(hfont), (LPARAM)(fRedraw))
+
+
+CONST
+ DTM_GETMCFONT = (DTM_FIRST + 10);
+
+// Macro 285
+function DateTime_GetMonthCalFont(hdp:HWND):HFONT;
+// SNDMSG(hdp, DTM_GETMCFONT, 0, 0)
+
+{$ifdef NTDDI_VISTA}
+Const
+ DTM_SETMCSTYLE = (DTM_FIRST + 11);
+ DTM_GETMCSTYLE = (DTM_FIRST + 12);
+ DTM_CLOSEMONTHCAL = (DTM_FIRST + 13);
+ DTM_GETDATETIMEPICKERINFO = (DTM_FIRST + 14);
+ DTM_GETIDEALSIZE = (DTM_FIRST + 15);
+
+function DateTime_SetMonthCalStyle(hdp:HWND; dwStyle:DWord):LResult;
+// SNDMSG(hdp, DTM_SETMCSTYLE, 0, (LPARAM)dwStyle)
+
+function DateTime_GetMonthCalStyle(hdp:HWND):LRESULT;
+// SNDMSG(hdp, DTM_GETMCSTYLE, 0, 0)
+
+function DateTime_CloseMonthCal(hdp:HWND):LRESULT;
+// SNDMSG(hdp, DTM_CLOSEMONTHCAL, 0, 0)
+
+// DateTime_GetDateTimePickerInfo(HWND hdp, DATETIMEPICKERINFO* pdtpi)
+// Retrieves information about the selected date time picker.
+
+function DateTime_GetDateTimePickerInfo(hdp:HWND; pdtpi:PDATETIMEPICKERINFO):LRESULT;
+// SNDMSG(hdp, DTM_GETDATETIMEPICKERINFO, 0, (LPARAM)(pdtpi))
+
+function DateTime_GetIdealSize(hdp:HWND; ps:PSIZE): LResult;
+// (BOOL)SNDMSG((hdp), DTM_GETIDEALSIZE, 0, (LPARAM)(psize))
+
+{$endif}
+
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+// begin_r_commctrl
+
+
+CONST
+ DTS_UPDOWN = $0001; // use UPDOWN instead of MONTHCAL
+ DTS_SHOWNONE = $0002; // allow a NONE selection
+ DTS_SHORTDATEFORMAT = $0000; // use the short date format (app must forward WM_WININICHANGE messages)
+ DTS_LONGDATEFORMAT = $0004; // use the long date format (app must forward WM_WININICHANGE messages)
+{$ifdef ie5plus}
+ DTS_SHORTDATECENTURYFORMAT = $000C; // short date format with century (app must forward WM_WININICHANGE messages)
+{$ENDIF} // (_WIN32_IE >= 0x500)
+ DTS_TIMEFORMAT = $0009; // use the time format (app must forward WM_WININICHANGE messages)
+ DTS_APPCANPARSE = $0010; // allow user entered strings (app MUST respond to DTN_USERSTRING)
+ DTS_RIGHTALIGN = $0020; // right-align popup instead of left-align it
+
+// end_r_commctrl
+
+ DTN_DATETIMECHANGE = (DTN_FIRST + 1); // the systemtime has changed
+TYPE
+
+ tagNMDATETIMECHANGE = Record
+ nmhdr : NMHDR;
+ dwFlags : DWORD; // GDT_VALID or GDT_NONE
+ st : SYSTEMTIME; // valid iff dwFlags==GDT_VALID
+ END;
+ NMDATETIMECHANGE = tagNMDATETIMECHANGE;
+ LPNMDATETIMECHANGE = ^tagNMDATETIMECHANGE;
+ TNMDATETIMECHANGE = tagNMDATETIMECHANGE;
+ PNMDATETIMECHANGE = ^tagNMDATETIMECHANGE;
+
+
+
+CONST
+ DTN_USERSTRINGA = (DTN_FIRST + 2); // the user has entered a string
+ DTN_USERSTRINGW = (DTN_FIRST + 15);
+TYPE
+
+ tagNMDATETIMESTRINGA = Record
+ nmhdr : NMHDR;
+ pszUserString : LPCSTR; // string user entered
+ st : SYSTEMTIME; // app fills this in
+ dwFlags : DWORD; // GDT_VALID or GDT_NONE
+ END;
+ NMDATETIMESTRINGA = tagNMDATETIMESTRINGA;
+ LPNMDATETIMESTRINGA = ^tagNMDATETIMESTRINGA;
+ TNMDATETIMESTRINGA = tagNMDATETIMESTRINGA;
+ PNMDATETIMESTRINGA = ^tagNMDATETIMESTRINGA;
+
+
+ tagNMDATETIMESTRINGW = Record
+ nmhdr : NMHDR;
+ pszUserString : LPCWSTR; // string user entered
+ st : SYSTEMTIME; // app fills this in
+ dwFlags : DWORD; // GDT_VALID or GDT_NONE
+ END;
+ NMDATETIMESTRINGW = tagNMDATETIMESTRINGW;
+ LPNMDATETIMESTRINGW = ^tagNMDATETIMESTRINGW;
+ TNMDATETIMESTRINGW = tagNMDATETIMESTRINGW;
+ PNMDATETIMESTRINGW = ^tagNMDATETIMESTRINGW;
+
+
+{$IFDEF UNICODE}
+CONST
+ DTN_USERSTRING = DTN_USERSTRINGW;
+TYPE
+ NMDATETIMESTRING = NMDATETIMESTRINGW;
+ LPNMDATETIMESTRING = LPNMDATETIMESTRINGW;
+{$ELSE}
+CONST
+ DTN_USERSTRING = DTN_USERSTRINGA;
+TYPE
+ NMDATETIMESTRING = NMDATETIMESTRINGA;
+ LPNMDATETIMESTRING = LPNMDATETIMESTRINGA;
+{$ENDIF}
+ TNMDateTimeString = NMDATETIMESTRING;
+ PNMDateTimeString = LPNMDATETIMESTRING;
+
+
+
+CONST
+ DTN_WMKEYDOWNA = (DTN_FIRST + 3); // modify keydown on app format field (X)
+ DTN_WMKEYDOWNW = (DTN_FIRST + 16);
+TYPE
+
+ tagNMDATETIMEWMKEYDOWNA = Record
+ nmhdr : NMHDR;
+ nVirtKey : cint; // virtual key code of WM_KEYDOWN which MODIFIES an X field
+ pszFormat : LPCSTR; // format substring
+ st : SYSTEMTIME; // current systemtime, app should modify based on key
+ END;
+ NMDATETIMEWMKEYDOWNA = tagNMDATETIMEWMKEYDOWNA;
+ LPNMDATETIMEWMKEYDOWNA = ^tagNMDATETIMEWMKEYDOWNA;
+ TNMDATETIMEWMKEYDOWNA = tagNMDATETIMEWMKEYDOWNA;
+ PNMDATETIMEWMKEYDOWNA = ^tagNMDATETIMEWMKEYDOWNA;
+
+
+ tagNMDATETIMEWMKEYDOWNW = Record
+ nmhdr : NMHDR;
+ nVirtKey : cint; // virtual key code of WM_KEYDOWN which MODIFIES an X field
+ pszFormat : LPCWSTR; // format substring
+ st : SYSTEMTIME; // current systemtime, app should modify based on key
+ END;
+ NMDATETIMEWMKEYDOWNW = tagNMDATETIMEWMKEYDOWNW;
+ LPNMDATETIMEWMKEYDOWNW = ^tagNMDATETIMEWMKEYDOWNW;
+ TNMDATETIMEWMKEYDOWNW = tagNMDATETIMEWMKEYDOWNW;
+ PNMDATETIMEWMKEYDOWNW = ^tagNMDATETIMEWMKEYDOWNW;
+
+
+{$IFDEF UNICODE}
+CONST
+ DTN_WMKEYDOWN = DTN_WMKEYDOWNW;
+TYPE
+ NMDATETIMEWMKEYDOWN = NMDATETIMEWMKEYDOWNW;
+ LPNMDATETIMEWMKEYDOWN= LPNMDATETIMEWMKEYDOWNW;
+{$ELSE}
+CONST
+ DTN_WMKEYDOWN = DTN_WMKEYDOWNA;
+TYPE
+ NMDATETIMEWMKEYDOWN = NMDATETIMEWMKEYDOWNA;
+ LPNMDATETIMEWMKEYDOWN= LPNMDATETIMEWMKEYDOWNA;
+{$ENDIF}
+
+
+
+CONST
+ DTN_FORMATA = (DTN_FIRST + 4); // query display for app format field (X)
+ DTN_FORMATW = (DTN_FIRST + 17);
+TYPE
+
+ tagNMDATETIMEFORMATA = Record
+ nmhdr : NMHDR;
+ pszFormat : LPCSTR; // format substring
+ st : SYSTEMTIME; // current systemtime
+ pszDisplay : LPCSTR; // string to display
+ szDisplay : Array [0..63] OF CHAR; // buffer pszDisplay originally points at
+ END;
+ NMDATETIMEFORMATA = tagNMDATETIMEFORMATA;
+ LPNMDATETIMEFORMATA = ^tagNMDATETIMEFORMATA;
+ TNMDATETIMEFORMATA = tagNMDATETIMEFORMATA;
+ PNMDATETIMEFORMATA = ^tagNMDATETIMEFORMATA;
+
+
+ tagNMDATETIMEFORMATW = Record
+ nmhdr : NMHDR;
+ pszFormat : LPCWSTR; // format substring
+ st : SYSTEMTIME; // current systemtime
+ pszDisplay : LPCWSTR; // string to display
+ szDisplay : Array [0..63] OF WCHAR; // buffer pszDisplay originally points at
+ END;
+ NMDATETIMEFORMATW = tagNMDATETIMEFORMATW;
+ LPNMDATETIMEFORMATW = ^tagNMDATETIMEFORMATW;
+ TNMDATETIMEFORMATW = tagNMDATETIMEFORMATW;
+ PNMDATETIMEFORMATW = ^tagNMDATETIMEFORMATW;
+
+
+{$IFDEF UNICODE}
+CONST
+ DTN_FORMAT = DTN_FORMATW;
+TYPE
+ NMDATETIMEFORMAT = NMDATETIMEFORMATW;
+ LPNMDATETIMEFORMAT = LPNMDATETIMEFORMATW;
+{$ELSE}
+CONST
+ DTN_FORMAT = DTN_FORMATA;
+TYPE
+ NMDATETIMEFORMAT = NMDATETIMEFORMATA;
+ LPNMDATETIMEFORMAT = LPNMDATETIMEFORMATA;
+{$ENDIF}
+
+
+
+CONST
+ DTN_FORMATQUERYA = (DTN_FIRST + 5); // query formatting info for app format field (X)
+ DTN_FORMATQUERYW = (DTN_FIRST + 18);
+TYPE
+
+ tagNMDATETIMEFORMATQUERYA = Record
+ nmhdr : NMHDR;
+ pszFormat : LPCSTR; // format substring
+ szMax : SIZE; // max bounding rectangle app will use for this format string
+ END;
+ NMDATETIMEFORMATQUERYA = tagNMDATETIMEFORMATQUERYA;
+ LPNMDATETIMEFORMATQUERYA = ^tagNMDATETIMEFORMATQUERYA;
+ TNMDATETIMEFORMATQUERYA = tagNMDATETIMEFORMATQUERYA;
+ PNMDATETIMEFORMATQUERYA = ^tagNMDATETIMEFORMATQUERYA;
+
+
+ tagNMDATETIMEFORMATQUERYW = Record
+ nmhdr : NMHDR;
+ pszFormat : LPCWSTR; // format substring
+ szMax : SIZE; // max bounding rectangle app will use for this format string
+ END;
+ NMDATETIMEFORMATQUERYW = tagNMDATETIMEFORMATQUERYW;
+ LPNMDATETIMEFORMATQUERYW = ^tagNMDATETIMEFORMATQUERYW;
+ TNMDATETIMEFORMATQUERYW = tagNMDATETIMEFORMATQUERYW;
+ PNMDATETIMEFORMATQUERYW = ^tagNMDATETIMEFORMATQUERYW;
+
+
+{$IFDEF UNICODE}
+CONST
+ DTN_FORMATQUERY = DTN_FORMATQUERYW;
+TYPE
+ NMDATETIMEFORMATQUERY= NMDATETIMEFORMATQUERYW;
+ LPNMDATETIMEFORMATQUERY= LPNMDATETIMEFORMATQUERYW;
+{$ELSE}
+CONST
+ DTN_FORMATQUERY = DTN_FORMATQUERYA;
+TYPE
+ NMDATETIMEFORMATQUERY= NMDATETIMEFORMATQUERYA;
+ LPNMDATETIMEFORMATQUERY= LPNMDATETIMEFORMATQUERYA;
+{$ENDIF}
+
+
+
+CONST
+ DTN_DROPDOWN = (DTN_FIRST + 6); // MonthCal has dropped down
+ DTN_CLOSEUP = (DTN_FIRST + 7); // MonthCal is popping up
+
+
+ GDTR_MIN = $0001;
+ GDTR_MAX = $0002;
+
+ GDT_ERROR = -1;
+ GDT_VALID = 0;
+ GDT_NONE = 1;
+
+
+{$ENDIF} // _WIN32
+{$ENDIF} // NODATETIMEPICK
+
+
+{$ifdef ie4plus}
+
+{$IFNDEF NOIPADDRESS}
+
+///////////////////////////////////////////////
+/// IP Address edit control
+
+// Messages sent to IPAddress controls
+
+ IPM_CLEARADDRESS = (WM_USER+100); // no parameters
+ IPM_SETADDRESS = (WM_USER+101); // lparam = TCP/IP address
+ IPM_GETADDRESS = (WM_USER+102); // lresult = # of non black fields. lparam = LPDWORD for TCP/IP address
+ IPM_SETRANGE = (WM_USER+103); // wparam = field, lparam = range
+ IPM_SETFOCUS = (WM_USER+104); // wparam = field
+ IPM_ISBLANK = (WM_USER+105); // no parameters
+
+ WC_IPADDRESSW = {L}'SysIPAddress32';
+ WC_IPADDRESSA = 'SysIPAddress32';
+
+{$IFDEF UNICODE}
+
+TYPE
+ WC_IPADDRESS = WC_IPADDRESSW;
+{$ELSE}
+ WC_IPADDRESS = WC_IPADDRESSA;
+{$ENDIF}
+
+
+CONST
+ IPN_FIELDCHANGED = (IPN_FIRST - 0);
+TYPE
+
+ tagNMIPADDRESS = Record
+ hdr : NMHDR;
+ iField : cint;
+ iValue : cint;
+ END;
+ NMIPADDRESS = tagNMIPADDRESS;
+ LPNMIPADDRESS = ^tagNMIPADDRESS;
+ TNMIPADDRESS = tagNMIPADDRESS;
+ PNMIPADDRESS = ^tagNMIPADDRESS;
+
+
+// The following is a useful macro for passing the range values in the
+// IPM_SETRANGE message.
+
+// Macro 286
+
+// #define MAKEIPRANGE(low, high) ((LPARAM)(WORD)(((BYTE)(high) << 8) + (BYTE)(low)))
+
+// And this is a useful macro for making the IP Address to be passed
+// as a LPARAM.
+
+// Macro 287
+
+// #define MAKEIPADDRESS(b1,b2,b3,b4) ((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4))))
+
+// Get individual number
+// Macro 288
+
+// #define FIRST_IPADDRESS(x) ((x>>24) & 0xff)
+// Macro 289
+
+// #define SECOND_IPADDRESS(x) ((x>>16) & 0xff)
+// Macro 290
+
+// #define THIRD_IPADDRESS(x) ((x>>8) & 0xff)
+// Macro 291
+
+// #define FOURTH_IPADDRESS(x) (x & 0xff)
+
+
+{$ENDIF} // NOIPADDRESS
+
+
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+/// ====================== Pager Control =============================
+//---------------------------------------------------------------------------------------
+//---------------------------------------------------------------------------------------
+
+{$IFNDEF NOPAGESCROLLER}
+
+//Pager Class Name
+
+CONST
+ WC_PAGESCROLLERW = {L}'SysPager';
+ WC_PAGESCROLLERA = 'SysPager';
+
+{$IFDEF UNICODE}
+
+TYPE
+ WC_PAGESCROLLER = WC_PAGESCROLLERW;
+{$ELSE}
+ WC_PAGESCROLLER = WC_PAGESCROLLERA;
+{$ENDIF}
+
+
+//---------------------------------------------------------------------------------------
+// Pager Control Styles
+//---------------------------------------------------------------------------------------
+// begin_r_commctrl
+
+
+CONST
+ PGS_VERT = $00000000;
+ PGS_HORZ = $00000001;
+ PGS_AUTOSCROLL = $00000002;
+ PGS_DRAGNDROP = $00000004;
+
+// end_r_commctrl
+
+
+//---------------------------------------------------------------------------------------
+// Pager Button State
+//---------------------------------------------------------------------------------------
+//The scroll can be in one of the following control State
+ PGF_INVISIBLE = 0; // Scroll button is not visible
+ PGF_NORMAL = 1; // Scroll button is in normal state
+ PGF_GRAYED = 2; // Scroll button is in grayed state
+ PGF_DEPRESSED = 4; // Scroll button is in depressed state
+ PGF_HOT = 8; // Scroll button is in hot state
+
+
+// The following identifiers specifies the button control
+ PGB_TOPORLEFT = 0;
+ PGB_BOTTOMORRIGHT = 1;
+
+//---------------------------------------------------------------------------------------
+// Pager Control Messages
+//---------------------------------------------------------------------------------------
+ PGM_SETCHILD = (PGM_FIRST + 1); // lParam == hwnd
+// Macro 292
+
+
+Procedure Pager_SetChild( hwnd : hwnd; hwndChild : LPARAM);
+
+
+
+CONST
+ PGM_RECALCSIZE = (PGM_FIRST + 2);
+// Macro 293
+
+
+Procedure Pager_RecalcSize( hwnd : hwnd);
+
+
+
+CONST
+ PGM_FORWARDMOUSE = (PGM_FIRST + 3);
+// Macro 294
+
+
+Procedure Pager_ForwardMouse( hwnd : hwnd; bForward : WPARAM);
+
+
+
+CONST
+ PGM_SETBKCOLOR = (PGM_FIRST + 4);
+// Macro 295
+
+
+Function Pager_SetBkColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+
+
+CONST
+ PGM_GETBKCOLOR = (PGM_FIRST + 5);
+// Macro 296
+
+
+Function Pager_GetBkColor( hwnd : hwnd):COLORREF;
+
+
+
+CONST
+ PGM_SETBORDER = (PGM_FIRST + 6);
+// Macro 297
+
+
+Function Pager_SetBorder( hwnd : hwnd; iBorder : LPARAM):cint;
+
+
+
+CONST
+ PGM_GETBORDER = (PGM_FIRST + 7);
+// Macro 298
+
+
+Function Pager_GetBorder( hwnd : hwnd):cint;
+
+
+
+CONST
+ PGM_SETPOS = (PGM_FIRST + 8);
+// Macro 299
+
+
+Function Pager_SetPos( hwnd : hwnd; iPos : LPARAM):cint;
+
+
+
+CONST
+ PGM_GETPOS = (PGM_FIRST + 9);
+// Macro 300
+
+
+Function Pager_GetPos( hwnd : hwnd):cint;
+
+
+
+CONST
+ PGM_SETBUTTONSIZE = (PGM_FIRST + 10);
+// Macro 301
+
+
+Function Pager_SetButtonSize( hwnd : hwnd; iSize : LPARAM):cint;
+
+
+
+CONST
+ PGM_GETBUTTONSIZE = (PGM_FIRST + 11);
+// Macro 302
+
+
+Function Pager_GetButtonSize( hwnd : hwnd):cint;
+
+
+
+CONST
+ PGM_GETBUTTONSTATE = (PGM_FIRST + 12);
+// Macro 303
+
+
+Function Pager_GetButtonState( hwnd : hwnd; iButton : LPARAM):DWORD;
+
+
+
+CONST
+ PGM_GETDROPTARGET = CCM_GETDROPTARGET;
+// Macro 304
+
+
+Procedure Pager_GetDropTarget( hwnd : hwnd; ppdt : LPARAM);
+
+//---------------------------------------------------------------------------------------
+//Pager Control Notification Messages
+//---------------------------------------------------------------------------------------
+
+
+// PGN_SCROLL Notification Message
+
+
+CONST
+ PGN_SCROLL = (PGN_FIRST-1);
+
+ PGF_SCROLLUP = 1;
+ PGF_SCROLLDOWN = 2;
+ PGF_SCROLLLEFT = 4;
+ PGF_SCROLLRIGHT = 8;
+
+
+//Keys down
+ PGK_SHIFT = 1;
+ PGK_CONTROL = 2;
+ PGK_MENU = 4;
+
+
+{$IFDEF _WIN32}
+// #include <pshpack1.h>
+{$ENDIF}
+
+// This structure is sent along with PGN_SCROLL notifications
+TYPE
+
+ DummyStruct17 = Record
+ hdr : NMHDR;
+ fwKeys : WORD; // Specifies which keys are down when this notification is send
+ rcParent : RECT; // Contains Parent Window Rect
+ iDir : cint; // Scrolling Direction
+ iXpos : cint; // Horizontal scroll position
+ iYpos : cint; // Vertical scroll position
+ iScroll : cint; // [in/out] Amount to scroll
+ END;
+ NMPGSCROLL = DummyStruct17;
+ LPNMPGSCROLL = ^DummyStruct17;
+ TNMPGScroll = NMPGSCROLL;
+ PNMPGScroll = LPNMPGSCROLL;
+
+
+{$IFDEF _WIN32}
+// #include <poppack.h>
+{$ENDIF}
+
+// PGN_CALCSIZE Notification Message
+
+
+CONST
+ PGN_CALCSIZE = (PGN_FIRST-2);
+
+ PGF_CALCWIDTH = 1;
+ PGF_CALCHEIGHT = 2;
+
+TYPE
+
+ DummyStruct18 = Record
+ hdr : NMHDR;
+ dwFlag : DWORD;
+ iWidth : cint;
+ iHeight : cint;
+ END;
+ NMPGCALCSIZE = DummyStruct18;
+ LPNMPGCALCSIZE = ^DummyStruct18;
+ TNMPGCalcSize = DummyStruct18;
+ PNMPGCalcSize = LPNMPGCALCSIZE;
+
+
+
+// PGN_HOTITEMCHANGE Notification Message
+
+
+CONST
+ PGN_HOTITEMCHANGE = (PGN_FIRST-3);
+
+{
+The PGN_HOTITEMCHANGE notification uses these notification
+flags defined in TOOLBAR:
+
+ HICF_ENTERING = $00000010; // idOld is invalid
+ HICF_LEAVING = $00000020; // idNew is invalid
+}
+
+// Structure for PGN_HOTITEMCHANGE notification
+//
+TYPE
+
+ tagNMPGHOTITEM = Record
+ hdr : NMHDR;
+ idOld : cint;
+ idNew : cint;
+ dwFlags : DWORD; // HICF_*
+ END;
+ NMPGHOTITEM = tagNMPGHOTITEM;
+ LPNMPGHOTITEM = ^tagNMPGHOTITEM;
+ TNMPGHOTITEM = tagNMPGHOTITEM;
+ PNMPGHOTITEM = ^tagNMPGHOTITEM;
+
+
+{$ENDIF} // NOPAGESCROLLER
+
+////====================== End Pager Control ==========================================
+
+//
+// === Native Font Control ===
+//
+{$IFNDEF NONATIVEFONTCTL}
+//NativeFont Class Name
+
+CONST
+ WC_NATIVEFONTCTLW = {L}'NativeFontCtl';
+ WC_NATIVEFONTCTLA = 'NativeFontCtl';
+
+{$IFDEF UNICODE}
+
+TYPE
+ WC_NATIVEFONTCTL = WC_NATIVEFONTCTLW;
+{$ELSE}
+ WC_NATIVEFONTCTL = WC_NATIVEFONTCTLA;
+{$ENDIF}
+
+// begin_r_commctrl
+
+// style definition
+
+CONST
+ NFS_EDIT = $0001;
+ NFS_STATIC = $0002;
+ NFS_LISTCOMBO = $0004;
+ NFS_BUTTON = $0008;
+ NFS_ALL = $0010;
+ NFS_USEFONTASSOC = $0020;
+
+// end_r_commctrl
+
+{$ENDIF} // NONATIVEFONTCTL
+// === End Native Font Control ===
+
+/// ====================== Button Control =============================
+
+{$IFNDEF NOBUTTON}
+
+{$IFDEF _WIN32}
+
+// Button Class Name
+ WC_BUTTONA = 'Button';
+ WC_BUTTONW = {L}'Button';
+
+CONST
+{$IFDEF UNICODE}
+ WC_BUTTON = WC_BUTTONW;
+{$ELSE}
+ WC_BUTTON = WC_BUTTONA;
+{$ENDIF}
+
+{$ELSE}
+
+ WC_BUTTON = 'Button';
+{$ENDIF}
+
+{$ifdef win32xp}
+ BUTTON_IMAGELIST_ALIGN_LEFT = 0;
+ BUTTON_IMAGELIST_ALIGN_RIGHT = 1;
+ BUTTON_IMAGELIST_ALIGN_TOP = 2;
+ BUTTON_IMAGELIST_ALIGN_BOTTOM = 3;
+ BUTTON_IMAGELIST_ALIGN_CENTER = 4; // Doesn't draw text
+
+TYPE
+
+ DummyStruct19 = Record
+ himl : HIMAGELIST; // Index: Normal, hot pushed, disabled. If count is less than 4, we use index 1
+ margin : RECT; // Margin around icon.
+ uAlign : UINT;
+ END;
+ BUTTON_IMAGELIST = DummyStruct19;
+ PBUTTON_IMAGELIST = ^DummyStruct19;
+ TDummyStruct19 = DummyStruct19;
+ PDummyStruct19 = ^DummyStruct19;
+
+
+
+CONST
+ BCM_GETIDEALSIZE = (BCM_FIRST + $0001);
+// Macro 305
+
+
+Function Button_GetIdealSize( hwnd : hwnd; psize : LPARAM):BOOL;
+
+
+
+CONST
+ BCM_SETIMAGELIST = (BCM_FIRST + $0002);
+// Macro 306
+
+
+Function Button_SetImageList( hwnd : hwnd; pbuttonImagelist : LPARAM):BOOL;
+
+
+
+CONST
+ BCM_GETIMAGELIST = (BCM_FIRST + $0003);
+// Macro 307
+
+
+Function Button_GetImageList( hwnd : hwnd; pbuttonImagelist : LPARAM):BOOL;
+
+
+
+CONST
+ BCM_SETTEXTMARGIN = (BCM_FIRST + $0004);
+// Macro 308
+
+
+Function Button_SetTextMargin( hwnd : hwnd; pmargin : LPARAM):BOOL;
+
+
+CONST
+ BCM_GETTEXTMARGIN = (BCM_FIRST + $0005);
+// Macro 309
+
+
+Function Button_GetTextMargin( hwnd : hwnd; pmargin : LPARAM):BOOL;
+
+
+TYPE
+
+ tagNMBCHOTITEM = Record
+ hdr : NMHDR;
+ dwFlags : DWORD; // HICF_*
+ END;
+ NMBCHOTITEM = tagNMBCHOTITEM;
+ LPNMBCHOTITEM = ^tagNMBCHOTITEM;
+ TNMBCHOTITEM = tagNMBCHOTITEM;
+ PNMBCHOTITEM = ^tagNMBCHOTITEM;
+
+
+
+CONST
+ BCN_HOTITEMCHANGE = (BCN_FIRST + $0001);
+
+ BST_HOT = $0200;
+{$ifdef win32vista}
+ BST_DROPDOWNPUSHED = $0400;
+
+// BUTTON STYLES
+ BS_SPLITBUTTON = $00000000C; // This block L suffixed (unsigned)
+ BS_DEFSPLITBUTTON = $00000000D;
+ BS_COMMANDLINK = $00000000E;
+ BS_DEFCOMMANDLINK = $00000000F;
+
+// SPLIT BUTTON INFO mask flags
+ BCSIF_GLYPH = $00001;
+ BCSIF_IMAGE = $00002;
+ BCSIF_STYLE = $00004;
+ BCSIF_SIZE = $00008;
+
+// SPLIT BUTTON STYLE flags
+ BCSS_NOSPLIT = $00001;
+ BCSS_STRETCH = $00002;
+ BCSS_ALIGNLEFT = $00004;
+ BCSS_IMAGE = $00008;
+
+ BCM_SETDROPDOWNSTATE = (BCM_FIRST + $0006);
+ BCM_SETSPLITINFO = (BCM_FIRST + $0007);
+ BCM_GETSPLITINFO = (BCM_FIRST + $0008);
+ BCM_SETNOTE = (BCM_FIRST + $0009);
+ BCM_GETNOTE = (BCM_FIRST + $000A);
+ BCM_GETNOTELENGTH = (BCM_FIRST + $000B);
+ BCM_SETSHIELD = (BCM_FIRST + $000C);
+
+
+// Value to pass to BCM_SETIMAGELIST to indicate that no glyph should be
+// displayed
+ BCCL_NOGLYPH = HIMAGELIST(-1);
+
+ BCN_DROPDOWN = (BCN_FIRST + $0002);
+Type
+
+ tagBUTTON_SPLITINFO = record
+ mask : UINT;
+ himlGlyph : HIMAGELIST;
+ uSplitStyle : UINT;
+ size : SIZE;
+ end;
+ BUTTON_SPLITINFO = tagBUTTON_SPLITINFO;
+ PBUTTON_SPLITINFO = ^BUTTON_SPLITINFO;
+ LPBUTTON_SPLITINFO = PBUTTON_SPLITINFO;
+
+ { NOTIFICATION MESSAGES }
+
+ tagNMBCDROPDOWN = packed record
+ hdr : NMHDR;
+ rcButton : RECT;
+ end;
+ NMBCDROPDOWN = tagNMBCDROPDOWN;
+ PNMBCDROPDOWN = ^NMBCDROPDOWN;
+ LPNMBCDROPDOWN = PNMBCDROPDOWN;
+
+// BUTTON MESSAGES
+
+function Button_SetDropDownState(hwnd:HWND; fDropDown:BOOL) : BOOL;
+// (BOOL)SNDMSG((hwnd), BCM_SETDROPDOWNSTATE, (WPARAM)(fDropDown), 0)
+
+function Button_SetSplitInfo(hwnd:HWND; pInfo:PBUTTON_SPLITINFO):BOOL;
+// (BOOL)SNDMSG((hwnd), BCM_SETSPLITINFO, 0, (LPARAM)(pInfo))
+
+function Button_GetSplitInfo(hwnd:HWND; pInfo:PBUTTON_SPLITINFO) :BOOL;
+// (BOOL)SNDMSG((hwnd), BCM_GETSPLITINFO, 0, (LPARAM)(pInfo))
+
+function Button_SetNote(hwnd:HWND; psz:LPCWSTR) :BOOL;
+// (BOOL)SNDMSG((hwnd), BCM_SETNOTE, 0, (LPARAM)(psz))
+
+function Button_GetNote(hwnd:HWND; psz:LPCWSTR; pcc:cint) :BOOL;
+// (BOOL)SNDMSG((hwnd), BCM_GETNOTE, (WPARAM)pcc, (LPARAM)psz)
+
+function Button_GetNoteLength(hwnd:HWND) :LRESULT;
+// (LRESULT)SNDMSG((hwnd), BCM_GETNOTELENGTH, 0, 0)
+
+// Macro to use on a button or command link to display an elevated icon
+
+function Button_SetElevationRequiredState(hwnd:HWND; fRequired:BOOL) :LRESULT;
+// (LRESULT)SNDMSG((hwnd), BCM_SETSHIELD, 0, (LPARAM)fRequired)
+
+{$endif}
+{$ENDIF}
+{$ENDIF} // NOBUTTON
+
+
+/// ===================== End Button Control =========================
+
+/// ====================== Static Control =============================
+
+{$IFNDEF NOSTATIC}
+
+const
+{$IFDEF _WIN32}
+
+// Static Class Name
+ WC_STATICA = 'Static';
+ WC_STATICW = {L}'Static';
+
+{$IFDEF UNICODE}
+
+TYPE
+ WC_STATIC = WC_STATICW;
+{$ELSE}
+ WC_STATIC = WC_STATICA;
+{$ENDIF}
+
+{$ELSE}
+
+CONST
+ WC_STATIC = 'Static';
+{$ENDIF}
+
+{$ENDIF} // NOSTATIC
+
+/// ===================== End Static Control =========================
+
+/// ====================== Edit Control =============================
+
+{$IFNDEF NOEDIT}
+
+{$IFDEF _WIN32}
+
+// Edit Class Name
+ WC_EDITA = 'Edit';
+ WC_EDITW = {L}'Edit';
+
+{$IFDEF UNICODE}
+
+TYPE
+ WC_EDIT = WC_EDITW;
+{$ELSE}
+ WC_EDIT = WC_EDITA;
+{$ENDIF}
+
+{$ELSE}
+
+CONST
+ WC_EDIT = 'Edit';
+{$ENDIF}
+
+{$ifdef win32xp}
+ EM_SETCUEBANNER = (ECM_FIRST + 1); // Set the cue banner with the lParm = LPCWSTR
+// Macro 310
+
+
+Function Edit_SetCueBannerText( hwnd : hwnd; lpcwText : LPARAM):BOOL;
+
+
+CONST
+ EM_GETCUEBANNER = (ECM_FIRST + 2); // Set the cue banner with the lParm = LPCWSTR
+// Macro 311
+
+
+Function Edit_GetCueBannerText( hwnd : hwnd; lpwText : WPARAM; cchText : LPARAM):BOOL;
+
+
+TYPE
+
+ _tagEDITBALLOONTIP = Record
+ cbStruct : DWORD;
+ pszTitle : LPCWSTR;
+ pszText : LPCWSTR;
+ ttiIcon : cint; // From TTI_*
+ END;
+ EDITBALLOONTIP = _tagEDITBALLOONTIP;
+ PEDITBALLOONTIP = ^_tagEDITBALLOONTIP;
+ TEDITBALLOONTIP = _tagEDITBALLOONTIP;
+
+
+
+CONST
+ EM_SHOWBALLOONTIP = (ECM_FIRST + 3); // Show a balloon tip associated to the edit control
+// Macro 312
+
+
+Function Edit_ShowBalloonTip( hwnd : hwnd; peditballoontip : LPARAM):BOOL;
+
+
+CONST
+ EM_HIDEBALLOONTIP = (ECM_FIRST + 4); // Hide any balloon tip associated with the edit control
+// Macro 313
+
+
+Function Edit_HideBalloonTip( hwnd : hwnd):BOOL;
+
+{$ifdef win32vista}
+const
+ EM_SETHILITE = (ECM_FIRST + 5);
+ EM_GETHILITE = (ECM_FIRST + 6);
+
+// both are "unimplemented" in MSDN, so probably typing is off.
+procedure Edit_SetHilite(hwndCtl:hwnd; ichStart:Wparam; ichEnd:lparam);
+// ((void)SNDMSG((hwndCtl), EM_SETHILITE, (ichStart), (ichEnd)))
+
+function Edit_GetHilite(hwndCtl:hwnd):DWORD;
+// ((DWORD)SNDMSG((hwndCtl), EM_GETHILITE, 0L, 0L))
+{$endif}
+
+{$ENDIF}
+
+{$ENDIF} // NOEDIT
+
+/// ===================== End Edit Control =========================
+
+/// ====================== Listbox Control =============================
+
+{$IFNDEF NOLISTBOX}
+
+{$IFDEF _WIN32}
+
+// Listbox Class Name
+
+CONST
+ WC_LISTBOXA = 'ListBox';
+ WC_LISTBOXW = {L}'ListBox';
+
+{$IFDEF UNICODE}
+
+TYPE
+ WC_LISTBOX = WC_LISTBOXW;
+{$ELSE}
+ WC_LISTBOX = WC_LISTBOXA;
+{$ENDIF}
+
+{$ELSE}
+
+CONST
+ WC_LISTBOX = 'ListBox';
+{$ENDIF}
+
+{$ENDIF} // NOLISTBOX
+
+
+/// ===================== End Listbox Control =========================
+
+/// ====================== Combobox Control =============================
+
+{$IFNDEF NOCOMBOBOX}
+
+{$IFDEF _WIN32}
+
+// Combobox Class Name
+ WC_COMBOBOXA = 'ComboBox';
+ WC_COMBOBOXW = {L}'ComboBox';
+
+{$IFDEF UNICODE}
+
+TYPE
+ WC_COMBOBOX = WC_COMBOBOXW;
+{$ELSE}
+ WC_COMBOBOX = WC_COMBOBOXA;
+{$ENDIF}
+
+{$ELSE}
+
+CONST
+ WC_COMBOBOX = 'ComboBox';
+{$ENDIF}
+
+{$ENDIF} // NOCOMBOBOX
+
+
+{$ifdef win32xp}
+
+// custom combobox control messages
+ CB_SETMINVISIBLE = (CBM_FIRST + 1);
+ CB_GETMINVISIBLE = (CBM_FIRST + 2);
+
+// Macro 314
+
+
+Function ComboBox_SetMinVisible( hwnd : hwnd; iMinVisible : WPARAM):BOOL;
+
+
+// Macro 315
+
+
+Function ComboBox_GetMinVisible( hwnd : hwnd):cint;
+
+
+{$ENDIF}
+
+/// ===================== End Combobox Control =========================
+
+/// ====================== Scrollbar Control ============================
+
+{$IFNDEF NOSCROLLBAR}
+
+{$IFDEF _WIN32}
+
+// Scrollbar Class Name
+
+CONST
+ WC_SCROLLBARA = 'ScrollBar';
+ WC_SCROLLBARW = {L}'ScrollBar';
+
+{$IFDEF UNICODE}
+
+TYPE
+ WC_SCROLLBAR = WC_SCROLLBARW;
+{$ELSE}
+ WC_SCROLLBAR = WC_SCROLLBARA;
+{$ENDIF}
+
+{$ELSE}
+
+CONST
+ WC_SCROLLBAR = 'ScrollBar';
+{$ENDIF}
+
+{$ENDIF} // NOSCROLLBAR
+
+
+/// ===================== End Scrollbar Control =========================
+
+
+//====== SysLink control =========================================
+
+{$IFDEF _WIN32}
+{$ifdef win32xp}
+
+ INVALID_LINK_INDEX = (-1);
+
+
+
+ WC_LINK = {L}'SysLink';
+
+ LWS_TRANSPARENT = $0001;
+ LWS_IGNORERETURN = $0002;
+
+{$ifdef win32vista}
+ LWS_NOPREFIX = $0004;
+ LWS_USEVISUALSTYLE = $0008;
+ LWS_USECUSTOMTEXT = $0010;
+ LWS_RIGHT = $0020;
+{$endif}
+
+ LIF_ITEMINDEX = $00000001;
+ LIF_STATE = $00000002;
+ LIF_ITEMID = $00000004;
+ LIF_URL = $00000008;
+
+ LIS_FOCUSED = $00000001;
+ LIS_ENABLED = $00000002;
+ LIS_VISITED = $00000004;
+{$ifdef win32vista}
+ LIS_HOTTRACK = $00000008;
+ LIS_DEFAULTCOLORS = $00000010; // Don't use any custom text colors
+{$endif}
+
+TYPE
+
+
+ tagLHITTESTINFO = Record
+ pt : POINT;
+ item : LITEM;
+ END;
+ LHITTESTINFO = tagLHITTESTINFO;
+ PLHITTESTINFO = ^tagLHITTESTINFO;
+ TLHITTESTINFO = tagLHITTESTINFO;
+// PLHITTESTINFO = ^tagLHITTESTINFO;
+
+
+ tagNMLINK = Record
+ hdr : NMHDR;
+ item : LITEM;
+ END;
+ NMLINK = tagNMLINK;
+ PNMLINK = ^tagNMLINK;
+ TNMLINK = tagNMLINK;
+// PNMLINK = ^tagNMLINK;
+
+
+// SysLink notifications
+// NM_CLICK // wParam: control ID, lParam: PNMLINK, ret: ignored.
+
+// LinkWindow messages
+
+CONST
+ LM_HITTEST = (WM_USER+$300); // wParam: n/a, lparam: PLHITTESTINFO, ret: BOOL
+ LM_GETIDEALHEIGHT = (WM_USER+$301); // wParam: n/a, lparam: n/a, ret: cy
+ LM_SETITEM = (WM_USER+$302); // wParam: n/a, lparam: LITEM*, ret: BOOL
+ LM_GETITEM = (WM_USER+$303); // wParam: n/a, lparam: LITEM*, ret: BOOL
+
+{$ENDIF}
+{$ENDIF} // _WIN32
+//====== End SysLink control =========================================
+
+
+//
+// === MUI APIs ===
+//
+{$IFNDEF NOMUI}
+procedure InitMUILanguage(uiLang:LANGID); stdcall; external commctrldll name 'InitMUILanguage';
+
+
+function GetMUILanguage:LANGID; stdcall; external commctrldll name 'GetMUILanguage';
+{$ENDIF} // NOMUI
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+{$IFDEF _WIN32}
+//====== TrackMouseEvent =====================================================
+
+{$IFNDEF NOTRACKMOUSEEVENT}
+
+//
+// If the messages for TrackMouseEvent have not been defined then define them
+// now.
+//
+{$IFNDEF WM_MOUSEHOVER}
+
+CONST
+ WM_MOUSEHOVER = $02A1;
+ WM_MOUSELEAVE = $02A3;
+{$ENDIF}
+
+//
+// If the TRACKMOUSEEVENT structure and associated flags havent been declared
+// then declare them now.
+//
+{$IFNDEF TME_HOVER}
+
+ TME_HOVER = $00000001;
+ TME_LEAVE = $00000002;
+{$ifdef win32xp}
+ TME_NONCLIENT = $00000010;
+{$ENDIF} { WINVER >= 0x0500 }
+ TME_QUERY = $40000000;
+ TME_CANCEL = $80000000;
+
+
+
+ HOVER_DEFAULT = $FFFFFFFF;
+
+TYPE
+
+ tagTRACKMOUSEEVENT = Record
+ cbSize : DWORD;
+ dwFlags : DWORD;
+ hwndTrack : HWND;
+ dwHoverTime : DWORD;
+ END;
+ TRACKMOUSEEVENT = tagTRACKMOUSEEVENT;
+ LPTRACKMOUSEEVENT = ^tagTRACKMOUSEEVENT;
+ TTRACKMOUSEEVENT = tagTRACKMOUSEEVENT;
+ PTRACKMOUSEEVENT = ^tagTRACKMOUSEEVENT;
+
+
+{$ENDIF} // !TME_HOVER
+
+
+
+//
+// Declare _TrackMouseEvent. This API tries to use the window manager's
+// implementation of TrackMouseEvent if it is present, otherwise it emulates.
+//
+function _TrackMouseEvent(lpEventTrack:LPTRACKMOUSEEVENT):BOOL; stdcall; external commctrldll name '_TrackMouseEvent';
+
+{$ENDIF} // !NOTRACKMOUSEEVENT
+
+{$ifdef ie4plus}
+
+//====== Flat Scrollbar APIs=========================================
+{$IFNDEF NOFLATSBAPIS}
+
+
+CONST
+ WSB_PROP_CYVSCROLL = LONG($00000001);
+ WSB_PROP_CXHSCROLL = LONG($00000002);
+ WSB_PROP_CYHSCROLL = LONG($00000004);
+ WSB_PROP_CXVSCROLL = LONG($00000008);
+ WSB_PROP_CXHTHUMB = LONG($00000010);
+ WSB_PROP_CYVTHUMB = LONG($00000020);
+ WSB_PROP_VBKGCOLOR = LONG($00000040);
+ WSB_PROP_HBKGCOLOR = LONG($00000080);
+ WSB_PROP_VSTYLE = LONG($00000100);
+ WSB_PROP_HSTYLE = LONG($00000200);
+ WSB_PROP_WINSTYLE = LONG($00000400);
+ WSB_PROP_PALETTE = LONG($00000800);
+ WSB_PROP_MASK = LONG($00000FFF);
+
+ FSB_FLAT_MODE = 2;
+ FSB_ENCARTA_MODE = 1;
+ FSB_REGULAR_MODE = 0;
+
+function FlatSB_EnableScrollBar(hwnd:HWND;code : cint;p3 : UINT):BOOL; stdcall; external commctrldll name 'FlatSB_EnableScrollBar';
+function FlatSB_ShowScrollBar(hwnd:HWND;code : cint;p3 : BOOL):BOOL; stdcall; external commctrldll name 'FlatSB_ShowScrollBar';
+
+function FlatSB_GetScrollRange(hwnd:HWND;code : cint;p3 : LPINT;p4 : LPINT):BOOL; stdcall; external commctrldll name 'FlatSB_GetScrollRange';
+function FlatSB_GetScrollRange(hwnd:HWND;code : cint;var p3,p4 : cint):BOOL; stdcall; external commctrldll name 'FlatSB_GetScrollRange';
+function FlatSB_GetScrollInfo(hwnd:HWND;code : cint;ScrollInfo : LPSCROLLINFO):BOOL; stdcall; external commctrldll name 'FlatSB_GetScrollInfo';
+function FlatSB_GetScrollInfo(hwnd:HWND;code : cint;var ScrollInfo : TSCROLLINFO):BOOL; stdcall; external commctrldll name 'FlatSB_GetScrollInfo';
+
+function FlatSB_GetScrollPos(hwnd:HWND;code : cint):cint; stdcall; external commctrldll name 'FlatSB_GetScrollPos';
+
+
+function FlatSB_GetScrollProp(hwnd:HWND):BOOL; stdcall; external commctrldll name 'FlatSB_GetScrollProp';
+{$IFDEF _WIN64}
+function FlatSB_GetScrollPropPtr(hwnd:HWND;propIndex : cint;p3 : LPINT):BOOL; stdcall; external commctrldll name 'FlatSB_GetScrollPropPtr';
+{$ELSE}
+function FlatSB_GetScrollPropPtr(hwnd:HWND;code : cint):BOOL; stdcall; external commctrldll name 'FlatSB_GetScrollProp';
+{$ENDIF}
+
+
+function FlatSB_SetScrollPos(hWnd:HWND;nBar,nPos:cint;bRedraw:BOOL):cint; stdcall; external commctrldll name 'FlatSB_SetScrollPos';
+
+function FlatSB_SetScrollInfo(hWnd:HWND;BarFlag:cint;const ScrollInfo:TScrollInfo;Redraw:BOOL):cint; stdcall; external commctrldll name 'FlatSB_SetScrollInfo';
+
+
+function FlatSB_SetScrollRange(hWnd: HWND; nBar,nMinPos,nMaxPos: cint; bRedraw: BOOL):cint; stdcall; external commctrldll name 'FlatSB_SetScrollRange';
+function FlatSB_SetScrollProp(p1: HWND; index : UINT; newValue: INT_PTR; p4: BOOL):BOOL; stdcall; external commctrldll name 'FlatSB_SetScrollProp';
+
+function InitializeFlatSB(hWnd:HWND):BOOL; stdcall; external commctrldll name 'InitializeFlatSB';
+function UninitializeFlatSB(hWnd:HWND):HRESULT; stdcall; external commctrldll name 'UninitializeFlatSB';
+
+{$ENDIF} // NOFLATSBAPIS
+
+{$ENDIF} // _WIN32_IE >= 0x0400
+
+{$ENDIF} { _WIN32 }
+
+{$ENDIF} // _WIN32_IE >= 0x0300
+
+{$ifdef win32xp}
+//
+// subclassing stuff
+//
+TYPE
+ subclassproc=function (hwnd:HWND;uMsg:cUINT; wParam:WPARAM;lparam:LPARAM;uISubClass : UINT_PTR;dwRefData:DWORD_PTR):LRESULT; stdcall;
+
+{
+ (CALLBACK *SUBCLASSPROC)(HWND hWnd, UINT uMsg, WPARAM wParam, = LRESULT
+ LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
+
+typedef LRESULT (CALLBACK *SUBCLASSPROC)(HWND hWnd, UINT uMsg, WPARAM wParam,
+ LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
+
+ hwnd:HWND;uMsg:cUINT; wParam:WPARAM;lparam:LPARAM;uISubClass : CUINT_PTR;dwRefData:DWORD_PTR):LRESULT; stdcall;
+}
+
+function SetWindowSubclass(hWnd:HWND;pfnSubclass:SUBCLASSPROC;uIdSubclass:UINT_PTR;dwRefData:DWORD_PTR):BOOL; stdcall; external commctrldll name 'SetWindowSubclass';
+function GetWindowSubclass(hWnd:HWND;pfnSubclass:SUBCLASSPROC;uIdSubclass:UINT_PTR;pdwRefData:PDWORD_PTR):BOOL; stdcall; external commctrldll name 'GetWindowSubclass';
+function RemoveWindowSubclass(hWnd:HWND;pfnSubclass:SUBCLASSPROC;uIdSubclass:UINT_PTR):BOOL; stdcall; external commctrldll name 'RemoveWindowSubclass';
+
+function DefSubclassProc(hWnd:HWND;uMsg:UINT;wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall; external commctrldll name 'DefSubclassProc';
+{$ENDIF}
+
+{$ifdef NTDDI_VISTA}
+type _LI_METRIC= (
+
+ LIM_SMALL=0, // corresponds to SM_CXSMICON/SM_CYSMICON
+ LIM_LARGE // corresponds to SM_CXICON/SM_CYICON
+ );
+
+Function LoadIconMetric( hinst:HINST; pszName:LPCWStr;lims:cint; var phico: HICON ):HRESULT; stdcall; external commctrldll name 'LoadIconMetric';
+Function LoadIconWithScaleDown( hinst:HINST; pszName:LPCWStr;cx:cint;cy:cint;var phico: HICON ):HRESULT; stdcall; external commctrldll name 'LoadIconMetric';
+
+{$endif}
+
+{$ifdef win32xp}
+
+function DrawShadowText(hdc:HDC;pszText:LPCWSTR;cch:UINT;prc:PRECT;dwFlags:DWORD;crText:COLORREF;crShadow:COLORREF;ixOffset:cint;iyOffset:cint):cint; stdcall; external commctrldll name 'DrawShadowText';
+{$ENDIF}
+
+// ===================== Task Dialog =========================
+
+Type
+ PFTASKDIALOGCALLBACK = function(hwnd: HWND; msg: UINT; wParam: WPARAM; lParam: LPARAM; lpRefData: LONG_PTR): HRESULT; stdcall;
+
+ // _TASKDIALOG_FLAGS enum
+const
+ TDF_ENABLE_HYPERLINKS = $0001;
+ TDF_USE_HICON_MAIN = $0002;
+ TDF_USE_HICON_FOOTER = $0004;
+ TDF_ALLOW_DIALOG_CANCELLATION = $0008;
+ TDF_USE_COMMAND_LINKS = $0010;
+ TDF_USE_COMMAND_LINKS_NO_ICON = $0020;
+ TDF_EXPAND_FOOTER_AREA = $0040;
+ TDF_EXPANDED_BY_DEFAULT = $0080;
+ TDF_VERIFICATION_FLAG_CHECKED = $0100;
+ TDF_SHOW_PROGRESS_BAR = $0200;
+ TDF_SHOW_MARQUEE_PROGRESS_BAR = $0400;
+ TDF_CALLBACK_TIMER = $0800;
+ TDF_POSITION_RELATIVE_TO_WINDOW = $1000;
+ TDF_RTL_LAYOUT = $2000;
+ TDF_NO_DEFAULT_RADIO_BUTTON = $4000;
+ TDF_CAN_BE_MINIMIZED = $8000;
+
+type
+ TASKDIALOG_FLAGS = Integer; // Note: _TASKDIALOG_FLAGS is an int
+
+ // _TASKDIALOG_MESSAGES enum
+const
+ TDM_NAVIGATE_PAGE = WM_USER+101;
+ TDM_CLICK_BUTTON = WM_USER+102; // wParam = Button ID
+ TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER+103; // wParam = 0 (nonMarque) wParam != 0 (Marquee)
+ TDM_SET_PROGRESS_BAR_STATE = WM_USER+104; // wParam = new progress state
+ TDM_SET_PROGRESS_BAR_RANGE = WM_USER+105; // lParam = MAKELPARAM(nMinRange, nMaxRange)
+ TDM_SET_PROGRESS_BAR_POS = WM_USER+106; // wParam = new position
+ TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER+107; // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
+ TDM_SET_ELEMENT_TEXT = WM_USER+108; // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
+ TDM_CLICK_RADIO_BUTTON = WM_USER+110; // wParam = Radio Button ID
+ TDM_ENABLE_BUTTON = WM_USER+111; // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
+ TDM_ENABLE_RADIO_BUTTON = WM_USER+112; // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
+ TDM_CLICK_VERIFICATION = WM_USER+113; // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
+ TDM_UPDATE_ELEMENT_TEXT = WM_USER+114; // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
+ TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER+115; // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
+ TDM_UPDATE_ICON = WM_USER+116; // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
+
+ // _TASKDIALOG_NOTIFICATIONS enum
+const
+ TDN_CREATED = 0;
+ TDN_NAVIGATED = 1;
+ TDN_BUTTON_CLICKED = 2; // wParam = Button ID
+ TDN_HYPERLINK_CLICKED = 3; // lParam = (LPCWSTR)pszHREF
+ TDN_TIMER = 4; // wParam = Milliseconds since dialog created or timer reset
+ TDN_DESTROYED = 5;
+ TDN_RADIO_BUTTON_CLICKED = 6; // wParam = Radio Button ID
+ TDN_DIALOG_CONSTRUCTED = 7;
+ TDN_VERIFICATION_CLICKED = 8; // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0
+ TDN_HELP = 9;
+ TDN_EXPANDO_BUTTON_CLICKED = 10; // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)
+
+type
+ _TASKDIALOG_BUTTON = packed record
+ nButtonID: Integer;
+ pszButtonText: PCWSTR;
+ end;
+ TASKDIALOG_BUTTON = _TASKDIALOG_BUTTON;
+ TTASKDIALOG_BUTTON = TASKDIALOG_BUTTON;
+ PTASKDIALOG_BUTTON = ^TASKDIALOG_BUTTON;
+
+ // _TASKDIALOG_ELEMENTS enum
+const
+ TDE_CONTENT = 0;
+ TDE_EXPANDED_INFORMATION = 1;
+ TDE_FOOTER = 2;
+ TDE_MAIN_INSTRUCTION = 3;
+
+ // _TASKDIALOG_ICON_ELEMENTS enum
+ TDIE_ICON_MAIN = 0;
+ TDIE_ICON_FOOTER = 1;
+
+ TD_WARNING_ICON = MAKEINTRESOURCEW(Word(-1));
+ TD_ERROR_ICON = MAKEINTRESOURCEW(Word(-2));
+ TD_INFORMATION_ICON = MAKEINTRESOURCEW(Word(-3));
+ TD_SHIELD_ICON = MAKEINTRESOURCEW(Word(-4));
+ TD_SHIELD_GRADIENT_ICON = MAKEINTRESOURCEW(Word(-5));
+ TD_SHIELD_WARNING_ICON = MAKEINTRESOURCEW(Word(-6));
+ TD_SHIELD_ERROR_ICON = MAKEINTRESOURCEW(Word(-7));
+ TD_SHIELD_OK_ICON = MAKEINTRESOURCEW(Word(-8));
+ TD_SHIELD_GRAY_ICON = MAKEINTRESOURCEW(Word(-9));
+
+ // _TASKDIALOG_COMMON_BUTTON_FLAGS enum
+ TDCBF_OK_BUTTON = $0001; // selected control return value IDOK
+ TDCBF_YES_BUTTON = $0002; // selected control return value IDYES
+ TDCBF_NO_BUTTON = $0004; // selected control return value IDNO
+ TDCBF_CANCEL_BUTTON = $0008; // selected control return value IDCANCEL
+ TDCBF_RETRY_BUTTON = $0010; // selected control return value IDRETRY
+ TDCBF_CLOSE_BUTTON = $0020; // selected control return value IDCLOSE
+
+type
+ TASKDIALOG_COMMON_BUTTON_FLAGS = Integer; // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int
+
+ _TASKDIALOGCONFIG = packed record
+ cbSize: UINT;
+ hwndParent: HWND;
+ hInstance: HINST; // used for MAKEINTRESOURCE() strings
+ dwFlags: TASKDIALOG_FLAGS; // TASKDIALOG_FLAGS (TDF_XXX) flags
+ dwCommonButtons: TASKDIALOG_COMMON_BUTTON_FLAGS; // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags
+ pszWindowTitle: PCWSTR; // string or MAKEINTRESOURCE()
+ case PtrInt of
+ 0: (hMainIcon: HICON);
+ 1: (
+ pszMainIcon: PCWSTR;
+ pszMainInstruction: PCWSTR;
+ pszContent: PCWSTR;
+ cButtons: UINT;
+ pButtons: PTASKDIALOG_BUTTON;
+ nDefaultButton: Integer;
+ cRadioButtons: UINT;
+ pRadioButtons: PTASKDIALOG_BUTTON;
+ nDefaultRadioButton: Integer;
+ pszVerificationText: PCWSTR;
+ pszExpandedInformation: PCWSTR;
+ pszExpandedControlText: PCWSTR;
+ pszCollapsedControlText: PCWSTR;
+ case PtrInt of
+ 0: (hFooterIcon: HICON);
+ 1: (
+ pszFooterIcon: PCWSTR;
+ pszFooter: PCWSTR;
+ pfCallback: PFTASKDIALOGCALLBACK;
+ lpCallbackData: LONG_PTR;
+ cxWidth: UINT; // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width.
+ );
+ );
+ end;
+ TASKDIALOGCONFIG = _TASKDIALOGCONFIG;
+ PTASKDIALOGCONFIG = ^TASKDIALOGCONFIG;
+ TTASKDIALOGCONFIG = TASKDIALOGCONFIG;
+
+var
+ TaskDialogIndirect: function(const pTaskConfig: PTASKDIALOGCONFIG; pnButton: PInteger; pnRadioButton: PInteger; pfVerificationFlagChecked: PBOOL): HRESULT; stdcall;
+ TaskDialog: function(hwndParent: HWND; hInstance: HINST; pszWindowTitle: PCWSTR; pszMainInstruction: PCWSTR; pszContent: PCWSTR;
+ dwCommonButtons: TASKDIALOG_COMMON_BUTTON_FLAGS; pszIcon: PCWSTR; pnButton: PInteger): HRESULT; stdcall;
+
+
+// ==================== End TaskDialog =======================
+
+
+IMPLEMENTATION
+
+// Macro 8
+
+//#define HANDLE_WM_NOTIFY(hwnd, wParam, lParam, fn) \
+// (fn)((hwnd), (int)(wParam), (NMHDR *)(lParam))
+
+Procedure HANDLE_WM_NOTIFY( hwnd : hwnd; wParam : cint;var _lParam : NMHDR ;fn:Pointer);
+
+TYPE FnType=procedure ( hwnd : hwnd; wParam : cint;tst:LPARAM); stdcall;
+
+Begin
+ fnType(fn)(hwnd, wParam, LPARAM(@_lParam));
+end;
+
+// Macro 9
+
+//#define FORWARD_WM_NOTIFY(hwnd, idFrom, pnmhdr, fn) \
+// (LRESULT)(fn)((hwnd), WM_NOTIFY, (WPARAM)(int)(idFrom), (LPARAM)(NMHDR *)(pnmhdr))
+
+Function FORWARD_WM_NOTIFY( hwnd : hwnd; idFrom : cint;var pnmhdr : NMHDR ; fn : pointer ):LRESULT;
+
+TYPE FnType=Function( hwnd : hwnd; wParam : cint;wparam2:cint;lparam1:lparam):LResult; stdcall;
+
+Begin
+ Result:=LRESULT(fntype(fn)(hwnd, WM_NOTIFY, idFrom, LPARAM(@pnmhdr)));
+end;
+
+// Macro 10
+// #define CCSIZEOF_STRUCT(structname, member) (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member))
+
+
+// Macro 11
+// #define ImageList_AddIcon(himl, hicon) ImageList_ReplaceIcon(himl, -1, hicon)
+
+Function ImageList_AddIcon(Himl:HIMAGELIST;hicon:HICON):cint;
+Begin
+ Result:=ImageList_ReplaceIcon(himl,-1,hicon);
+end;
+
+
+// Macro 12
+// #define INDEXTOOVERLAYMASK(i) ((i) << 8)
+
+// Macro 13
+// #define ImageList_RemoveAll(himl) ImageList_Remove(himl, -1)
+
+Procedure ImageList_RemoveAll(himl:HIMAGELIST);
+Begin
+ ImageList_Remove(himl, -1)
+End;
+
+// Macro 14
+// #define ImageList_ExtractIcon(hi, himl, i) ImageList_GetIcon(himl, i, 0)
+
+function ImageList_ExtractIcon(hi:longint; himl:HIMAGELIST;i:longint):HICON;
+
+Begin
+ result:=ImageList_GetIcon(himl, i,0);
+end;
+
+
+// Macro 15
+// #define ImageList_LoadBitmap(hi, lpbmp, cx, cGrow, crMask)
+// ImageList_LoadImage(hi, lpbmp, cx, cGrow, crMask, IMAGE_BITMAP, 0)
+
+Procedure ImageList_LoadBitmap(hi:HINST;bmp:LPCTSTR;cx:cint;cGrow:cint;crMask:COLORREF);
+
+Begin
+ ImageList_LoadImage(hi, bmp, cx, cGrow, crMask, IMAGE_BITMAP, 0);
+End;
+
+// Macro 16
+// #define Header_GetItemCount(hwndHD) \
+// (int)SNDMSG((hwndHD), HDM_GETITEMCOUNT, 0, DWord(0))
+
+Function Header_GetItemCount( hwndHD : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwndHD), HDM_GETITEMCOUNT, 0, LPARAM(0)))
+end;
+
+
+// Macro 17
+//#define Header_InsertItem(hwndHD, i, phdi) \
+// (int)SNDMSG((hwndHD), HDM_INSERTITEM, (WPARAM)(int)(i), (LPARAM)(const HD_ITEM *)(phdi))
+
+Function Header_InsertItem( hwndHD : hwnd; i : cint;const phdi : HD_ITEM ):cint;
+
+Begin
+ Result:=cint(SendMessage((hwndHD), HDM_INSERTITEM, (i), LPARAM(@phdi)));
+end;
+
+// Macro 18
+//#define Header_DeleteItem(hwndHD, i) \
+// (BOOL)SNDMSG((hwndHD), HDM_DELETEITEM, (WPARAM)(int)(i), LPARAM(0))
+
+Function Header_DeleteItem( hwndHD : hwnd; i : cint):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndHD), HDM_DELETEITEM, (i), LPARAM(0)));
+end;
+
+
+// Macro 19
+// #define Header_GetItem(hwndHD, i, phdi) \
+// (BOOL)SNDMSG((hwndHD), HDM_GETITEM, (WPARAM)(int)(i), (LPARAM)(HD_ITEM *)(phdi))
+
+Function Header_GetItem( hwndHD : hwnd; i : cint;var phdi : HD_ITEM ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndHD), HDM_GETITEM, (i), LPARAM(@phdi)));
+end;
+
+
+// Macro 20
+// #define Header_SetItem(hwndHD, i, phdi) \
+// (BOOL)SNDMSG((hwndHD), HDM_SETITEM, (WPARAM)(int)(i), (LPARAM)(const HD_ITEM *)(phdi))
+
+Function Header_SetItem( hwndHD : hwnd; i : cint;const phdi : HD_ITEM ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndHD), HDM_SETITEM, (i), LPARAM(@phdi)));
+end;
+
+
+// Macro 21
+// #define Header_Layout(hwndHD, playout) \
+// (BOOL)SNDMSG((hwndHD), HDM_LAYOUT, 0, (LPARAM)(HD_LAYOUT *)(playout))
+
+Function Header_Layout( hwndHD : hwnd;var playout : HD_LAYOUT ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndHD), HDM_LAYOUT, 0, LPARAM(@playout)))
+end;
+
+
+// Macro 22
+// #define Header_GetItemRect(hwnd, iItem, lprc) \
+// (BOOL)SNDMSG((hwnd), HDM_GETITEMRECT, (WPARAM)(iItem), (LPARAM)(lprc))
+
+Function Header_GetItemRect( hwnd : hwnd; iItem : WPARAM; lprc : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), HDM_GETITEMRECT, iItem, lprc));
+end;
+
+
+// Macro 23
+// #define Header_SetImageList(hwnd, himl) \
+// (HIMAGELIST)SNDMSG((hwnd), HDM_SETIMAGELIST, 0, (LPARAM)(himl))
+
+Function Header_SetImageList( hwnd : hwnd; himl : LPARAM):HIMAGELIST;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), HDM_SETIMAGELIST, 0, himl))
+end;
+
+
+// Macro 24
+// #define Header_GetImageList(hwnd) \
+// (HIMAGELIST)SNDMSG((hwnd), HDM_GETIMAGELIST, 0, 0)
+
+Function Header_GetImageList( hwnd : hwnd):HIMAGELIST;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), HDM_GETIMAGELIST, 0, 0))
+end;
+
+
+// Macro 25
+// #define Header_OrderToIndex(hwnd, i) \
+// (int)SNDMSG((hwnd), HDM_ORDERTOINDEX, (WPARAM)(i), 0)
+
+Function Header_OrderToIndex( hwnd : hwnd; i : WPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), HDM_ORDERTOINDEX, (i), 0))
+end;
+
+
+// Macro 26
+// #define Header_CreateDragImage(hwnd, i) \
+// (HIMAGELIST)SNDMSG((hwnd), HDM_CREATEDRAGIMAGE, (WPARAM)(i), 0)
+
+Function Header_CreateDragImage( hwnd : hwnd; i : WPARAM):HIMAGELIST;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), HDM_CREATEDRAGIMAGE, (i), 0))
+end;
+
+
+// Macro 27
+// #define Header_GetOrderArray(hwnd, iCount, lpi) \
+// (BOOL)SNDMSG((hwnd), HDM_GETORDERARRAY, (WPARAM)(iCount), (LPARAM)(lpi))
+
+Function Header_GetOrderArray( hwnd : hwnd; iCount : WPARAM; lpi : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), HDM_GETORDERARRAY, iCount, lpi))
+end;
+
+
+// Macro 28
+// #define Header_SetOrderArray(hwnd, iCount, lpi) \
+// (BOOL)SNDMSG((hwnd), HDM_SETORDERARRAY, (WPARAM)(iCount), (LPARAM)(lpi))
+
+Function Header_SetOrderArray( hwnd : hwnd; iCount : WPARAM; lpi : PInteger):BOOL;inline;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), HDM_SETORDERARRAY, iCount, LPARAM(lpi)))
+end;
+
+
+// Macro 29
+// #define Header_SetHotDivider(hwnd, fPos, dw) \
+// (int)SNDMSG((hwnd), HDM_SETHOTDIVIDER, (WPARAM)(fPos), (LPARAM)(dw))
+
+Function Header_SetHotDivider( hwnd : hwnd; fPos : WPARAM; dw : LPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), HDM_SETHOTDIVIDER, fPos, dw))
+end;
+
+
+{$ifdef ie5plus}
+// Macro 30
+// #define Header_SetBitmapMargin(hwnd, iWidth) \
+// (int)SNDMSG((hwnd), HDM_SETBITMAPMARGIN, (WPARAM)(iWidth), 0)
+
+Function Header_SetBitmapMargin( hwnd : hwnd; iWidth : WPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), HDM_SETBITMAPMARGIN, iWidth, 0))
+end;
+
+
+// Macro 31
+// #define Header_GetBitmapMargin(hwnd) \
+// (int)SNDMSG((hwnd), HDM_GETBITMAPMARGIN, 0, 0)
+
+Function Header_GetBitmapMargin( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), HDM_GETBITMAPMARGIN, 0, 0))
+end;
+
+{$ENDIF}
+
+// Macro 32
+// #define Header_SetUnicodeFormat(hwnd, fUnicode) \
+// (BOOL)SNDMSG((hwnd), HDM_SETUNICODEFORMAT, (WPARAM)(fUnicode), 0)
+
+Function Header_SetUnicodeFormat( hwnd : hwnd; fUnicode : WPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), HDM_SETUNICODEFORMAT, fUnicode, 0));
+end;
+
+
+// Macro 33
+// #define Header_GetUnicodeFormat(hwnd) \
+// (BOOL)SNDMSG((hwnd), HDM_GETUNICODEFORMAT, 0, 0)
+
+Function Header_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), HDM_GETUNICODEFORMAT, 0, 0))
+end;
+
+
+{$ifdef IE5plus}
+// Macro 34
+// #define Header_SetFilterChangeTimeout(hwnd, i) \
+// (int)SNDMSG((hwnd), HDM_SETFILTERCHANGETIMEOUT, 0, (LPARAM)(i))
+
+Function Header_SetFilterChangeTimeout( hwnd : hwnd; i : LPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), HDM_SETFILTERCHANGETIMEOUT, 0, (i)))
+end;
+
+
+// Macro 35
+// #define Header_EditFilter(hwnd, i, fDiscardChanges) \
+// (int)SNDMSG((hwnd), HDM_EDITFILTER, (WPARAM)(i), MAKELPARAM(fDiscardChanges, 0))
+
+Function Header_EditFilter( hwnd : hwnd; i : WPARAM; fDiscardChanges :cint ):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), HDM_EDITFILTER, (i), MAKELPARAM(fDiscardChanges, 0)));
+end;
+
+
+// Macro 36
+// #define Header_ClearFilter(hwnd, i) \
+// (int)SNDMSG((hwnd), HDM_CLEARFILTER, (WPARAM)(i), 0)
+
+Function Header_ClearFilter( hwnd : hwnd; i : WPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), HDM_CLEARFILTER, (i), 0))
+end;
+
+
+// Macro 37
+// #define Header_ClearAllFilters(hwnd) \
+// (int)SNDMSG((hwnd), HDM_CLEARFILTER, (WPARAM)-1, 0)
+
+Function Header_ClearAllFilters( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), HDM_CLEARFILTER, WPARAM(-1), 0))
+end;
+{$endif}
+{$ifdef win32vista}
+// macro 37a ..37d
+function Header_GetOverflowRect( hwnd : hwnd; lprc:lprect):bool;
+begin
+ result:=bool(sendmessage(hwnd, HDM_GETOVERFLOWRECT, 0, LPARAM(lprc)));
+end;
+
+function Header_GetFocusedItem(hwnd : hwnd):cint;
+begin
+ Result:=cint(SendMessage((hwnd), HDM_GETFOCUSEDITEM, WPARAM(0), LPARAM(0)));
+end;
+
+function Header_SetFocusedItem(hwnd:hwnd; iItem:cint):BOOL;
+begin
+ result:=bool(sendmessage(hwnd, HDM_SETFOCUSEDITEM, WPARAM(0),LPARAM(iItem)));
+end;
+function Header_GetItemDropDownRect(hwnd : hwnd;iItem:cint; lprc:lprect):bool;
+begin
+ result:=bool(sendmessage(hwnd, HDM_GETITEMDROPDOWNRECT, WPARAM(iItem), LPARAM(lprc)));
+end;
+{$endif}
+
+// Macro 38
+// #define ListView_SetUnicodeFormat(hwnd, fUnicode) \
+// (BOOL)SNDMSG((hwnd), LVM_SETUNICODEFORMAT, (WPARAM)(fUnicode), 0)
+
+Function ListView_SetUnicodeFormat( hwnd : hwnd; fUnicode : WPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETUNICODEFORMAT, fUnicode, 0));
+end;
+
+
+// Macro 39
+// #define ListView_GetUnicodeFormat(hwnd) \
+// (BOOL)SNDMSG((hwnd), LVM_GETUNICODEFORMAT, 0, 0)
+
+Function ListView_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETUNICODEFORMAT, 0, 0))
+end;
+
+
+// Macro 40
+// #define ListView_GetBkColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), LVM_GETBKCOLOR, 0, LPARAM(0))
+
+Function ListView_GetBkColor( hwnd : hwnd):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), LVM_GETBKCOLOR, 0, LPARAM(0)))
+end;
+
+
+// Macro 41
+// #define ListView_SetBkColor(hwnd, clrBk) \
+// (BOOL)SNDMSG((hwnd), LVM_SETBKCOLOR, 0, (LPARAM)(COLORREF)(clrBk))
+
+Function ListView_SetBkColor( hwnd : hwnd; clrBk : COLORREF):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETBKCOLOR, 0, clrBk))
+end;
+
+
+// Macro 42
+// #define ListView_GetImageList(hwnd, iImageList) \
+// (HIMAGELIST)SNDMSG((hwnd), LVM_GETIMAGELIST, (WPARAM)(INT)(iImageList), DWord(0))
+
+Function ListView_GetImageList( hwnd : hwnd; iImageList : CINT):HIMAGELIST;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), LVM_GETIMAGELIST, iImageList, LPARAM(0)))
+end;
+
+
+// Macro 43
+// #define ListView_SetImageList(hwnd, himl, iImageList) \
+// (HIMAGELIST)SNDMSG((hwnd), LVM_SETIMAGELIST, (WPARAM)(iImageList), (LPARAM)(HIMAGELIST)(himl))
+
+Function ListView_SetImageList( hwnd : hwnd; himl : HIMAGELIST; iImageList : WPARAM):HIMAGELIST;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), LVM_SETIMAGELIST, iImageList, himl))
+end;
+
+
+// Macro 44
+// #define ListView_GetItemCount(hwnd) \
+// (int)SNDMSG((hwnd), LVM_GETITEMCOUNT, 0, DWord(0))
+
+Function ListView_GetItemCount( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_GETITEMCOUNT, 0, LPARAM(0)))
+end;
+
+
+// Macro 45
+// #define INDEXTOSTATEIMAGEMASK(i) ((i) << 12)
+
+// Macro 46
+// #define ListView_GetItem(hwnd, pitem) \
+// (BOOL)SNDMSG((hwnd), LVM_GETITEM, 0, (LPARAM)(LV_ITEM *)(pitem))
+
+Function ListView_GetItem( hwnd : hwnd;var pitem : LV_ITEM ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETITEM, 0, LPARAM(@pitem)))
+end;
+
+
+// Macro 47
+// #define ListView_SetItem(hwnd, pitem) \
+// (BOOL)SNDMSG((hwnd), LVM_SETITEM, 0, (LPARAM)(const LV_ITEM *)(pitem))
+
+Function ListView_SetItem( hwnd : hwnd;const pitem : LV_ITEM ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETITEM, 0, LPARAM(@pitem)))
+end;
+
+
+// Macro 48
+// #define ListView_InsertItem(hwnd, pitem) \
+// (int)SNDMSG((hwnd), LVM_INSERTITEM, 0, (LPARAM)(const LV_ITEM *)(pitem))
+
+Function ListView_InsertItem( hwnd : hwnd;Const pitem : LV_ITEM ):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_INSERTITEM, 0, LPARAM(@pitem)))
+end;
+
+
+// Macro 49
+// #define ListView_DeleteItem(hwnd, i) \
+// (BOOL)SNDMSG((hwnd), LVM_DELETEITEM, (WPARAM)(int)(i), DWord(0))
+
+Function ListView_DeleteItem( hwnd : hwnd; i : cint):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_DELETEITEM, (i), LPARAM(0)))
+end;
+
+
+// Macro 50
+// #define ListView_DeleteAllItems(hwnd) \
+// (BOOL)SNDMSG((hwnd), LVM_DELETEALLITEMS, 0, DWord(0))
+
+Function ListView_DeleteAllItems( hwnd : hwnd):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_DELETEALLITEMS, 0, LPARAM(0)))
+end;
+
+
+// Macro 51
+// #define ListView_GetCallbackMask(hwnd) \
+// (BOOL)SNDMSG((hwnd), LVM_GETCALLBACKMASK, 0, 0)
+
+Function ListView_GetCallbackMask( hwnd : hwnd):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETCALLBACKMASK, 0, 0))
+end;
+
+
+// Macro 52
+// #define ListView_SetCallbackMask(hwnd, mask) \
+// (BOOL)SNDMSG((hwnd), LVM_SETCALLBACKMASK, (WPARAM)(UINT)(mask), 0)
+
+Function ListView_SetCallbackMask( hwnd : hwnd; mask : UINT):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETCALLBACKMASK, mask, 0))
+end;
+
+
+// Macro 53
+// #define ListView_GetNextItem(hwnd, i, flags) \
+// (int)SNDMSG((hwnd), LVM_GETNEXTITEM, (WPARAM)(int)(i), MAKELPARAM((flags), 0))
+
+Function ListView_GetNextItem( hwnd : hwnd; i : cint; flags : cint):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_GETNEXTITEM, (i), MAKELPARAM((flags), 0)))
+end;
+
+
+// Macro 54
+// #define ListView_FindItem(hwnd, iStart, plvfi) \
+// (int)SNDMSG((hwnd), LVM_FINDITEM, (WPARAM)(int)(iStart), (LPARAM)(const LV_FINDINFO *)(plvfi))
+
+Function ListView_FindItem( hwnd : hwnd; iStart : cint;const plvfi : LV_FINDINFO ):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_FINDITEM, iStart, LPARAM(@plvfi)))
+end;
+
+
+// Macro 55
+// #define ListView_GetItemRect(hwnd, i, prc, code) \
+// (BOOL)SNDMSG((hwnd), LVM_GETITEMRECT, (WPARAM)(int)(i), \
+// ((prc) ? (((RECT *)(prc))->left = (code),(LPARAM)(RECT *)(prc)) : (LPARAM)(RECT *)NULL))
+
+Function ListView_GetItemRect( hwnd : hwnd; i : cint;var prc : TRect;code : cint):BOOL;
+begin
+ if assigned(@prc) then
+ begin
+ prc.left:=Code;
+ Result:=BOOL(SendMessage(hWnd,LVM_GETITEMRECT,i,LPARAM(@prc)));
+ end
+ else
+ Result:=BOOL(SendMessage(hWnd,LVM_GETITEMRECT,i,0));
+end;
+
+
+// Macro 56
+// #define ListView_SetItemPosition(hwndLV, i, x, y) \
+// (BOOL)SNDMSG((hwndLV), LVM_SETITEMPOSITION, (WPARAM)(int)(i), MAKELPARAM((x), (y)))
+
+Function ListView_SetItemPosition( hwndLV : hwnd; i : cint; x : cint ; y : cint ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_SETITEMPOSITION, (i), MAKELPARAM((x), (y))))
+end;
+
+
+// Macro 57
+// #define ListView_GetItemPosition(hwndLV, i, ppt) \
+// (BOOL)SNDMSG((hwndLV), LVM_GETITEMPOSITION, (WPARAM)(int)(i), (LPARAM)(POINT *)(ppt))
+
+Function ListView_GetItemPosition( hwndLV : hwnd; i : cint;var ppt : POINT ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_GETITEMPOSITION, (i), LPAram(@ppt)))
+end;
+
+// Macro 58
+// #define ListView_GetStringWidth(hwndLV, psz) \
+// (int)SNDMSG((hwndLV), LVM_GETSTRINGWIDTH, 0, (LPARAM)(LPCTSTR)(psz))
+
+Function ListView_GetStringWidth( hwndLV : hwnd; psz : LPCTSTR):cint;
+
+Begin
+ Result:=cint(SendMessage((hwndLV), LVM_GETSTRINGWIDTH, 0, LPARAM(psz)))
+end;
+
+
+// Macro 59
+// #define ListView_HitTest(hwndLV, pinfo) \
+// (int)SNDMSG((hwndLV), LVM_HITTEST, 0, (LPARAM)(LV_HITTESTINFO *)(pinfo))
+
+Function ListView_HitTest( hwndLV : hwnd;var pinfo : LV_HITTESTINFO ):cint;
+
+Begin
+ Result:=cint(SendMessage((hwndLV), LVM_HITTEST, 0, LParam(@pinfo)))
+end;
+
+
+// Macro 60
+// #define ListView_EnsureVisible(hwndLV, i, fPartialOK) \
+// (BOOL)SNDMSG((hwndLV), LVM_ENSUREVISIBLE, (WPARAM)(int)(i), MAKELPARAM((fPartialOK), 0))
+
+Function ListView_EnsureVisible( hwndLV : hwnd; i : cint; fPartialOK : cint ):BOOL;inline;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_ENSUREVISIBLE, (i), MAKELPARAM((fPartialOK), 0)))
+end;
+
+
+Function ListView_EnsureVisible( hwndLV : hwnd; i : cint; fPartialOK : BOOL ):BOOL;inline;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_ENSUREVISIBLE, (i), LPARAM(fPartialOK)))
+end;
+
+
+// Macro 61
+// #define ListView_Scroll(hwndLV, dx, dy) \
+// (BOOL)SNDMSG((hwndLV), LVM_SCROLL, (WPARAM)(int)(dx), (LPARAM)(int)(dy))
+
+Function ListView_Scroll( hwndLV : hwnd; dx : cint; dy : cint):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_SCROLL, dx, dy))
+end;
+
+
+// Macro 62
+// #define ListView_RedrawItems(hwndLV, iFirst, iLast) \
+// (BOOL)SNDMSG((hwndLV), LVM_REDRAWITEMS, (WPARAM)(int)(iFirst), (LPARAM)(int)(iLast))
+
+Function ListView_RedrawItems( hwndLV : hwnd; iFirst : cint; iLast : cint):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_REDRAWITEMS, iFirst, iLast))
+end;
+
+
+// Macro 63
+// #define ListView_Arrange(hwndLV, code) \
+// (BOOL)SNDMSG((hwndLV), LVM_ARRANGE, (WPARAM)(UINT)(code), DWord(0))
+
+Function ListView_Arrange( hwndLV : hwnd; code : UINT):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_ARRANGE, code, LPARAM(0)))
+end;
+
+
+// Macro 64
+// #define ListView_EditLabel(hwndLV, i) \
+// (HWND)SNDMSG((hwndLV), LVM_EDITLABEL, (WPARAM)(int)(i), DWord(0))
+
+Function ListView_EditLabel( hwndLV : hwnd; i : cint):HWND;
+
+Begin
+ Result:=HWND(SendMessage((hwndLV), LVM_EDITLABEL, (i), LPARAM(0)))
+end;
+
+
+// Macro 65
+// #define ListView_GetEditControl(hwndLV) \
+// (HWND)SNDMSG((hwndLV), LVM_GETEDITCONTROL, 0, DWord(0))
+
+Function ListView_GetEditControl( hwndLV : hwnd):HWND;
+
+Begin
+ Result:=HWND(SendMessage((hwndLV), LVM_GETEDITCONTROL, 0, LPARAM(0)))
+end;
+
+
+// Macro 66
+// #define ListView_GetColumn(hwnd, iCol, pcol) \
+// (BOOL)SNDMSG((hwnd), LVM_GETCOLUMN, (WPARAM)(int)(iCol), (LPARAM)(LV_COLUMN *)(pcol))
+
+Function ListView_GetColumn( hwnd : hwnd; iCol : cint;var pcol : LV_COLUMN ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETCOLUMN, iCol, LPARAM(@pcol)))
+end;
+
+
+// Macro 67
+// #define ListView_SetColumn(hwnd, iCol, pcol) \
+// (BOOL)SNDMSG((hwnd), LVM_SETCOLUMN, (WPARAM)(int)(iCol), (LPARAM)(const LV_COLUMN *)(pcol))
+
+Function ListView_SetColumn( hwnd : hwnd; iCol : cint; Const pcol : LV_COLUMN ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETCOLUMN, iCol, LPARAM(@pcol)))
+end;
+
+
+// Macro 68
+// #define ListView_InsertColumn(hwnd, iCol, pcol) \
+// (int)SNDMSG((hwnd), LVM_INSERTCOLUMN, (WPARAM)(int)(iCol), (LPARAM)(const LV_COLUMN *)(pcol))
+
+Function ListView_InsertColumn( hwnd : hwnd; iCol : cint;const pcol : LV_COLUMN ):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_INSERTCOLUMN, iCol, LPARAM(@pcol)))
+end;
+
+
+// Macro 69
+// #define ListView_DeleteColumn(hwnd, iCol) \
+// (BOOL)SNDMSG((hwnd), LVM_DELETECOLUMN, (WPARAM)(int)(iCol), 0)
+
+Function ListView_DeleteColumn( hwnd : hwnd; iCol : cint):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_DELETECOLUMN, iCol, 0))
+end;
+
+
+// Macro 70
+// #define ListView_GetColumnWidth(hwnd, iCol) \
+// (int)SNDMSG((hwnd), LVM_GETCOLUMNWIDTH, (WPARAM)(int)(iCol), 0)
+
+Function ListView_GetColumnWidth( hwnd : hwnd; iCol : cint):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_GETCOLUMNWIDTH, iCol, 0))
+end;
+
+
+// Macro 71
+// #define ListView_SetColumnWidth(hwnd, iCol, cx) \
+// (BOOL)SNDMSG((hwnd), LVM_SETCOLUMNWIDTH, (WPARAM)(int)(iCol), MAKELPARAM((cx), 0))
+
+Function ListView_SetColumnWidth( hwnd : hwnd; iCol : cint; cx :cint ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETCOLUMNWIDTH, iCol, MAKELPARAM((cx), 0)))
+end;
+
+
+// Macro 72
+// #define ListView_GetHeader(hwnd)\
+// (HWND)SNDMSG((hwnd), LVM_GETHEADER, 0, DWord(0))
+
+Function ListView_GetHeader( hwnd : hwnd):HWND;
+
+Begin
+ Result:=Windows.HWND(SendMessage((hwnd), LVM_GETHEADER, 0, LPARAM(0)));
+end;
+
+
+// Macro 73
+// #define ListView_CreateDragImage(hwnd, i, lpptUpLeft) \
+// (HIMAGELIST)SNDMSG((hwnd), LVM_CREATEDRAGIMAGE, (WPARAM)(int)(i), (LPARAM)(LPPOINT)(lpptUpLeft))
+
+Function ListView_CreateDragImage( hwnd : hwnd; i : cint; lpptUpLeft : LPPOINT):HIMAGELIST;inline;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), LVM_CREATEDRAGIMAGE, WPARAM(i), LPARAM(lpptUpLeft)))
+end;
+
+Function ListView_CreateDragImage( hwnd : hwnd; i : cint; const lpptUpLeft : POINT):HIMAGELIST;inline;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), LVM_CREATEDRAGIMAGE, WPARAM(i), LPARAM(@lpptUpLeft)))
+end;
+
+
+// Macro 74
+// #define ListView_GetViewRect(hwnd, prc) \
+// (BOOL)SNDMSG((hwnd), LVM_GETVIEWRECT, 0, (LPARAM)(RECT *)(prc))
+
+Function ListView_GetViewRect( hwnd : hwnd;var prc : RECT ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETVIEWRECT, 0, LPARAM(@prc)))
+end;
+
+// Macro 75
+// #define ListView_GetTextColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), LVM_GETTEXTCOLOR, 0, DWord(0))
+
+Function ListView_GetTextColor( hwnd : hwnd):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), LVM_GETTEXTCOLOR, 0, LPARAM(0)))
+end;
+
+
+// Macro 76
+// #define ListView_SetTextColor(hwnd, clrText) \
+// (BOOL)SNDMSG((hwnd), LVM_SETTEXTCOLOR, 0, (LPARAM)(COLORREF)(clrText))
+
+Function ListView_SetTextColor( hwnd : hwnd; clrText : COLORREF):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETTEXTCOLOR, 0, clrText))
+end;
+
+
+// Macro 77
+// #define ListView_GetTextBkColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), LVM_GETTEXTBKCOLOR, 0, DWord(0))
+
+Function ListView_GetTextBkColor( hwnd : hwnd):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), LVM_GETTEXTBKCOLOR, 0, LPARAM(0)))
+end;
+
+
+// Macro 78
+// #define ListView_SetTextBkColor(hwnd, clrTextBk) \
+// (BOOL)SNDMSG((hwnd), LVM_SETTEXTBKCOLOR, 0, (LPARAM)(COLORREF)(clrTextBk))
+
+Function ListView_SetTextBkColor( hwnd : hwnd; clrTextBk : COLORREF):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETTEXTBKCOLOR, 0, clrTextBk))
+end;
+
+
+// Macro 79
+// #define ListView_GetTopIndex(hwndLV) \
+// (int)SNDMSG((hwndLV), LVM_GETTOPINDEX, 0, 0)
+
+Function ListView_GetTopIndex( hwndLV : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwndLV), LVM_GETTOPINDEX, 0, 0))
+end;
+
+
+// Macro 80
+// #define ListView_GetCountPerPage(hwndLV) \
+// (int)SNDMSG((hwndLV), LVM_GETCOUNTPERPAGE, 0, 0)
+
+Function ListView_GetCountPerPage( hwndLV : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwndLV), LVM_GETCOUNTPERPAGE, 0, 0))
+end;
+
+
+// Macro 81
+//
+// #define ListView_GetOrigin(hwndLV, ppt) \
+// (BOOL)SNDMSG((hwndLV), LVM_GETORIGIN, (WPARAM)0, (LPARAM)(POINT *)(ppt))
+
+Function ListView_GetOrigin( hwndLV : hwnd;var ppt : POINT ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_GETORIGIN, WPARAM(0), LPARAM(@ppt)))
+end;
+
+
+// Macro 82
+// #define ListView_Update(hwndLV, i) \
+// (BOOL)SNDMSG((hwndLV), LVM_UPDATE, (WPARAM)(i), DWord(0))
+
+Function ListView_Update( hwndLV : hwnd; i : WPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_UPDATE, (i), LPARAM(0)))
+end;
+
+
+// Macro 83
+// #define ListView_SetItemState(hwndLV, i, data, mask) \
+// { LV_ITEM _ms_lvi;\
+// _ms_lvi.stateMask = mask;\
+// _ms_lvi.state = data;\
+// SNDMSG((hwndLV), LVM_SETITEMSTATE, (WPARAM)(i), (LPARAM)(LV_ITEM *)&_ms_lvi);\
+// }
+
+Procedure ListView_SetItemState(hwndLV :hwnd; i :cint ;data,mask:UINT);
+
+Var _ms_lvi : LV_ITEM;
+
+Begin
+ _ms_lvi.stateMask:=mask;
+ _ms_lvi.state:=data;
+ SendMessage(hwndLV, LVM_SETITEMSTATE, i,LPARAM(@_ms_lvi));
+end;
+
+
+// Macro 84
+// #define ListView_SetCheckState(hwndLV, i, fCheck) \
+// ListView_SetItemState(hwndLV, i, INDEXTOSTATEIMAGEMASK((fCheck)?2:1), LVIS_STATEIMAGEMASK)
+
+Procedure ListView_SetCheckState( hwndLV : hwnd; i : cint ; fCheck : BOOL );
+
+var j:longint;
+Begin
+ IF not fCheck Then // (or inc(longint(fCheck)) if you like it dirty)
+ j:=1
+ Else
+ j:=2;
+ListView_SetItemState(hwndLV, i, INDEXTOSTATEIMAGEMASK(j), LVIS_STATEIMAGEMASK);
+end;
+
+
+// Macro 85
+// #define ListView_GetItemState(hwndLV, i, mask) \
+// (UINT)SNDMSG((hwndLV), LVM_GETITEMSTATE, (WPARAM)(i), (LPARAM)(mask))
+
+Function ListView_GetItemState( hwndLV : hwnd; i : WPARAM; mask : LPARAM):UINT;
+
+Begin
+ Result:=UINT(SendMessage((hwndLV), LVM_GETITEMSTATE, (i), mask))
+end;
+
+
+// Macro 86
+// #define ListView_GetCheckState(hwndLV, i) \
+// ((((UINT)(SNDMSG((hwndLV), LVM_GETITEMSTATE, (WPARAM)(i), LVIS_STATEIMAGEMASK))) >> 12) -1)
+
+Function ListView_GetCheckState( hwndLV : hwnd; i : WPARAM):UINT;
+
+Begin
+ Result:=(SendMessage((hwndLV), LVM_GETITEMSTATE, (i), LVIS_STATEIMAGEMASK) shl 12) -1;
+end;
+
+
+// Macro 87
+// #define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_) \
+// { LV_ITEM _ms_lvi;\
+// _ms_lvi.iSubItem = iSubItem_;\
+// _ms_lvi.cchTextMax = cchTextMax_;\
+// _ms_lvi.pszText = pszText_;\
+// SNDMSG((hwndLV), LVM_GETITEMTEXT, (WPARAM)(i), (LPARAM)(LV_ITEM *)&_ms_lvi);\
+// }
+
+Procedure ListView_GetItemText(hwndLV:hwnd; i : WPARAM ;iSubItem : cint ;pszText : Pointer;cchTextMax :cint);
+
+Var _ms_lvi : LV_ITEM;
+
+Begin
+ _ms_lvi.iSubItem := iSubItem;
+ _ms_lvi.cchTextMax := cchTextMax;
+ _ms_lvi.pszText := pszText; // unicode dependant!
+ SendMessage(hwndLV, LVM_GETITEMTEXT, i, LPARAM(@_ms_LVI));
+end;
+
+
+// Macro 88
+// #define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_) \
+// { LV_ITEM _ms_lvi;\
+// _ms_lvi.iSubItem = iSubItem_;\
+// _ms_lvi.pszText = pszText_;\
+// SNDMSG((hwndLV), LVM_SETITEMTEXT, (WPARAM)(i), (LPARAM)(LV_ITEM *)&_ms_lvi);\
+// }
+
+Procedure ListView_SetItemText(hwndLV:hwnd; i : WPARAM ;iSubItem : cint ;pszText : Pointer);
+
+Var _ms_lvi : LV_ITEM;
+
+Begin
+ _ms_lvi.iSubItem := iSubItem;
+ _ms_lvi.pszText := pszText; // unicode dependant!
+ SendMessage(hwndLV, LVM_SETITEMTEXT, i, LPARAM(@_ms_lvi));
+End;
+
+// Macro 89
+// #define ListView_SetItemCount(hwndLV, cItems) \
+// SNDMSG((hwndLV), LVM_SETITEMCOUNT, (WPARAM)(cItems), 0)
+
+Procedure ListView_SetItemCount( hwndLV : hwnd; cItems : WPARAM);
+
+Begin
+ SendMessage((hwndLV), LVM_SETITEMCOUNT, cItems, 0)
+end;
+
+
+// Macro 90
+// #define ListView_SetItemCountEx(hwndLV, cItems, dwFlags) \
+// SNDMSG((hwndLV), LVM_SETITEMCOUNT, (WPARAM)(cItems), (LPARAM)(dwFlags))
+
+Procedure ListView_SetItemCountEx( hwndLV : hwnd; cItems : WPARAM; dwFlags : LPARAM);
+
+Begin
+ SendMessage((hwndLV), LVM_SETITEMCOUNT, cItems, dwFlags)
+end;
+
+
+// Macro 91
+// #define ListView_SortItems(hwndLV, _pfnCompare, _lPrm) \
+// (BOOL)SNDMSG((hwndLV), LVM_SORTITEMS, (WPARAM)(LPARAM)(_lPrm), \
+// (LPARAM)(PFNLVCOMPARE)(_pfnCompare))
+
+Function ListView_SortItems( hwndLV : hwnd;pfnCompare : PFNLVCOMPARE; lPrm : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_SORTITEMS, lPrm, LPARAM(@pfncompare)));
+end;
+
+
+// Macro 92
+// #define ListView_SetItemPosition32(hwndLV, i, x0, y0) \
+// { POINT ptNewPos; \
+// ptNewPos.x = x0; ptNewPos.y = y0; \
+// SNDMSG((hwndLV), LVM_SETITEMPOSITION32, (WPARAM)(int)(i), (LPARAM)&ptNewPos); \
+// }
+
+Procedure ListView_SetItemPosition32(hwndLV:hwnd; i:cint;x0,y0:long);
+
+Var ptNewPos:POINT;
+
+Begin
+ ptNewPos.X:=x0; ptNewPos.Y:=y0;
+ SendMessage(hwndlv, LVM_SETITEMPOSITION32, I,LPARAM(@ptNewPos));
+end;
+
+
+// Macro 93
+// #define ListView_GetSelectedCount(hwndLV) \
+// (UINT)SNDMSG((hwndLV), LVM_GETSELECTEDCOUNT, 0, DWord(0))
+
+Function ListView_GetSelectedCount( hwndLV : hwnd):UINT;
+
+Begin
+ Result:=SendMessage(hwndLV, LVM_GETSELECTEDCOUNT, 0, LPARAM(0));
+end;
+
+// Macro 94
+// #define ListView_GetItemSpacing(hwndLV, fSmall) \
+// (DWORD)SNDMSG((hwndLV), LVM_GETITEMSPACING, fSmall, DWord(0))
+
+Function ListView_GetItemSpacing( hwndLV : hwnd; fSmall : cint ):DWORD;
+
+Begin
+ Result:=LPARAM(SendMessage((hwndLV), LVM_GETITEMSPACING, fSmall, LPARAM(0)));
+end;
+
+// Macro 95
+// #define ListView_GetISearchString(hwndLV, lpsz) \
+// (BOOL)SNDMSG((hwndLV), LVM_GETISEARCHSTRING, 0, (LPARAM)(LPTSTR)(lpsz))
+
+Function ListView_GetISearchString( hwndLV : hwnd; lpsz : LPTSTR):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_GETISEARCHSTRING, 0, LPARAM(lpsz)))
+end;
+
+// Macro 96
+// #define ListView_SetIconSpacing(hwndLV, cx, cy) \
+// (DWORD)SNDMSG((hwndLV), LVM_SETICONSPACING, 0, MAKELONG(cx,cy))
+
+Function ListView_SetIconSpacing( hwndLV : hwnd; cx,cy : cint ):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwndLV), LVM_SETICONSPACING, 0, MAKELONG(cx,cy)))
+end;
+
+
+// Macro 97
+// #define ListView_SetExtendedListViewStyle(hwndLV, dw)\
+// (DWORD)SNDMSG((hwndLV), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dw)
+
+Function ListView_SetExtendedListViewStyle( hwndLV : hwnd; dw :cint ):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwndLV), LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dw))
+end;
+
+
+// Macro 98
+// #define ListView_SetExtendedListViewStyleEx(hwndLV, dwMask, dw)\
+// (DWORD)SNDMSG((hwndLV), LVM_SETEXTENDEDLISTVIEWSTYLE, dwMask, dw)
+
+Function ListView_SetExtendedListViewStyleEx( hwndLV : hwnd; dwMask, dw : cint ):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwndLV), LVM_SETEXTENDEDLISTVIEWSTYLE, dwMask, dw))
+end;
+
+
+// Macro 99
+// #define ListView_GetExtendedListViewStyle(hwndLV)\
+// (DWORD)SNDMSG((hwndLV), LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
+
+Function ListView_GetExtendedListViewStyle( hwndLV : hwnd):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwndLV), LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0))
+end;
+
+
+// Macro 100
+// #define ListView_GetSubItemRect(hwnd, iItem, iSubItem, code, prc) \
+// (BOOL)SNDMSG((hwnd), LVM_GETSUBITEMRECT, (WPARAM)(int)(iItem), \
+// ((prc) ? ((((LPRECT)(prc))->top = iSubItem), (((LPRECT)(prc))->left = code), (LPARAM)(prc)) : (LPARAM)(LPRECT)NULL))
+
+Function ListView_GetSubItemRect( hwnd : hwnd; iItem : cint;iSubItem, code :cint ;prc:LPRECT):BOOL;
+
+VAR LastParam : LPRECT;
+Begin
+ if prc<>nil then
+ begin
+ prc^.top:=iSubItem;
+ prc^.left:=code;
+ lastparam:=prc;
+ end
+ else
+ lastparam:=nil;
+ Result:=bool(SendMessage((hwnd), LVM_GETSUBITEMRECT, iItem, LPARAM(lastparam)));
+End;
+
+// Macro 101
+// #define ListView_SubItemHitTest(hwnd, plvhti) \
+// (int)SNDMSG((hwnd), LVM_SUBITEMHITTEST, 0, (LPARAM)(LPLVHITTESTINFO)(plvhti))
+
+Function ListView_SubItemHitTest( hwnd : hwnd; plvhti : LPLVHITTESTINFO):cint;
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_SUBITEMHITTEST, 0, LParam(plvhti)))
+end;
+
+
+// Macro 102
+// #define ListView_SetColumnOrderArray(hwnd, iCount, pi) \
+// (BOOL)SNDMSG((hwnd), LVM_SETCOLUMNORDERARRAY, (WPARAM)(iCount), (LPARAM)(LPINT)(pi))
+
+Function ListView_SetColumnOrderArray( hwnd : hwnd; iCount : WPARAM; pi : LPINT):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETCOLUMNORDERARRAY, iCount, LPARAM(pi)));
+end;
+
+
+// Macro 103
+// #define ListView_GetColumnOrderArray(hwnd, iCount, pi) \
+// (BOOL)SNDMSG((hwnd), LVM_GETCOLUMNORDERARRAY, (WPARAM)(iCount), (LPARAM)(LPINT)(pi))
+
+Function ListView_GetColumnOrderArray( hwnd : hwnd; iCount : WPARAM; pi : LPINT):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETCOLUMNORDERARRAY, iCount, LPARAM(pi)))
+end;
+
+
+// Macro 104
+// #define ListView_SetHotItem(hwnd, i) \
+// (int)SNDMSG((hwnd), LVM_SETHOTITEM, (WPARAM)(i), 0)
+
+Function ListView_SetHotItem( hwnd : hwnd; i : WPARAM):cint;
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_SETHOTITEM, (i), 0))
+end;
+
+// Macro 105
+// #define ListView_GetHotItem(hwnd) \
+// (int)SNDMSG((hwnd), LVM_GETHOTITEM, 0, 0)
+
+Function ListView_GetHotItem( hwnd : hwnd):cint;
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_GETHOTITEM, 0, 0))
+end;
+
+// Macro 106
+// #define ListView_SetHotCursor(hwnd, hcur) \
+// (HCURSOR)SNDMSG((hwnd), LVM_SETHOTCURSOR, 0, (LPARAM)(hcur))
+
+Function ListView_SetHotCursor( hwnd : hwnd; hcur : LPARAM):HCURSOR;
+Begin
+ Result:=HCURSOR(SendMessage((hwnd), LVM_SETHOTCURSOR, 0, hcur))
+end;
+
+// Macro 107
+// #define ListView_GetHotCursor(hwnd) \
+// (HCURSOR)SNDMSG((hwnd), LVM_GETHOTCURSOR, 0, 0)
+
+Function ListView_GetHotCursor( hwnd : hwnd):HCURSOR;
+Begin
+ Result:=HCURSOR(SendMessage((hwnd), LVM_GETHOTCURSOR, 0, 0))
+end;
+
+
+// Macro 108
+// #define ListView_ApproximateViewRect(hwnd, iWidth, iHeight, iCount) \
+// (DWORD)SNDMSG((hwnd), LVM_APPROXIMATEVIEWRECT, iCount, MAKELPARAM(iWidth, iHeight))
+
+Function ListView_ApproximateViewRect( hwnd : hwnd; iWidth, iHeight, iCount : cint ):DWORD;
+Begin
+ Result:=DWORD(SendMessage((hwnd), LVM_APPROXIMATEVIEWRECT, iCount, MAKELPARAM(iWidth, iHeight)));
+end;
+
+
+// Macro 109
+// #define ListView_SetWorkAreas(hwnd, nWorkAreas, prc) \
+// (BOOL)SNDMSG((hwnd), LVM_SETWORKAREAS, (WPARAM)(int)(nWorkAreas), (LPARAM)(RECT *)(prc))
+
+Function ListView_SetWorkAreas( hwnd : hwnd; nWorkAreas : cint;var prc : RECT ):BOOL;inline;
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETWORKAREAS, nWorkAreas, LPARAM(@prc)))
+end;
+
+
+Function ListView_SetWorkAreas( hwnd : hwnd; nWorkAreas : cint; prc : PRECT ):BOOL;inline;
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETWORKAREAS, nWorkAreas, LPARAM(prc)))
+end;
+
+// Macro 110
+// #define ListView_GetWorkAreas(hwnd, nWorkAreas, prc) \
+// (BOOL)SNDMSG((hwnd), LVM_GETWORKAREAS, (WPARAM)(int)(nWorkAreas), (LPARAM)(RECT *)(prc))
+
+Function ListView_GetWorkAreas( hwnd : hwnd; nWorkAreas : cint;var prc : RECT ):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETWORKAREAS, nWorkAreas, LPARAM(@prc)))
+end;
+
+
+// Macro 111
+// #define ListView_GetNumberOfWorkAreas(hwnd, pnWorkAreas) \
+// (BOOL)SNDMSG((hwnd), LVM_GETNUMBEROFWORKAREAS, 0, (LPARAM)(UINT *)(pnWorkAreas))
+
+Function ListView_GetNumberOfWorkAreas( hwnd : hwnd;var pnWorkAreas : UINT ):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETNUMBEROFWORKAREAS, 0, LPARAM(@pnWorkAreas)))
+end;
+
+
+// Macro 112
+// #define ListView_GetSelectionMark(hwnd) \
+// (int)SNDMSG((hwnd), LVM_GETSELECTIONMARK, 0, 0)
+
+Function ListView_GetSelectionMark( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_GETSELECTIONMARK, 0, 0))
+end;
+
+
+// Macro 113
+// #define ListView_SetSelectionMark(hwnd, i) \
+// (int)SNDMSG((hwnd), LVM_SETSELECTIONMARK, 0, (LPARAM)(i))
+
+Function ListView_SetSelectionMark( hwnd : hwnd; i : LPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_SETSELECTIONMARK, 0, (i)))
+end;
+
+
+// Macro 114
+// #define ListView_SetHoverTime(hwndLV, dwHoverTimeMs)\
+// (DWORD)SNDMSG((hwndLV), LVM_SETHOVERTIME, 0, (LPARAM)(dwHoverTimeMs))
+
+Function ListView_SetHoverTime( hwndLV : hwnd; dwHoverTimeMs : LPARAM):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwndLV), LVM_SETHOVERTIME, 0, dwHoverTimeMs))
+end;
+
+
+// Macro 115
+// #define ListView_GetHoverTime(hwndLV)\
+// (DWORD)SNDMSG((hwndLV), LVM_GETHOVERTIME, 0, 0)
+
+Function ListView_GetHoverTime( hwndLV : hwnd):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwndLV), LVM_GETHOVERTIME, 0, 0))
+end;
+
+
+// Macro 116
+// #define ListView_SetToolTips(hwndLV, hwndNewHwnd)\
+// (HWND)SNDMSG((hwndLV), LVM_SETTOOLTIPS, (WPARAM)(hwndNewHwnd), 0)
+
+Function ListView_SetToolTips( hwndLV : hwnd; hwndNewHwnd : WPARAM):HWND;
+
+Begin
+ Result:=HWND(SendMessage((hwndLV), LVM_SETTOOLTIPS, hwndNewHwnd, 0))
+end;
+
+
+// Macro 117
+// #define ListView_GetToolTips(hwndLV)\
+// (HWND)SNDMSG((hwndLV), LVM_GETTOOLTIPS, 0, 0)
+
+Function ListView_GetToolTips( hwndLV : hwnd):HWND;
+
+Begin
+ Result:=HWND(SendMessage((hwndLV), LVM_GETTOOLTIPS, 0, 0))
+end;
+
+
+// Macro 118
+// #define ListView_SortItemsEx(hwndLV, _pfnCompare, _lPrm) \
+// (BOOL)SNDMSG((hwndLV), LVM_SORTITEMSEX, (WPARAM)(LPARAM)(_lPrm), (LPARAM)(PFNLVCOMPARE)(_pfnCompare))
+
+Function ListView_SortItemsEx( hwndLV : hwnd; _pfnCompare : PFNLVCOMPARE; _lPrm : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_SORTITEMSEX, _lPrm, LPAram(@_pfnCompare)))
+end;
+
+{$ifdef win32xp}
+// Macro 119
+// #define ListView_SetSelectedColumn(hwnd, iCol) \
+// SNDMSG((hwnd), LVM_SETSELECTEDCOLUMN, (WPARAM)iCol, 0)
+
+Procedure ListView_SetSelectedColumn( hwnd : hwnd; iCol : WPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_SETSELECTEDCOLUMN, iCol, 0)
+end;
+
+// Macro 120
+// #define ListView_SetTileWidth(hwnd, cpWidth) \
+// SNDMSG((hwnd), LVM_SETTILEWIDTH, (WPARAM)cpWidth, 0)
+
+Procedure ListView_SetTileWidth( hwnd : hwnd; cpWidth : WPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_SETTILEWIDTH, cpWidth, 0)
+end;
+
+
+// Macro 121
+// #define ListView_SetView(hwnd, iView) \
+// (DWORD)SNDMSG((hwnd), LVM_SETVIEW, (WPARAM)(DWORD)iView, 0)
+
+Function ListView_SetView( hwnd : hwnd; iView : DWORD):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwnd), LVM_SETVIEW, iView, 0))
+end;
+
+
+// Macro 122
+// #define ListView_GetView(hwnd) \
+// (DWORD)SNDMSG((hwnd), LVM_GETVIEW, 0, 0)
+
+Function ListView_GetView( hwnd : hwnd):DWORD;
+Begin
+ Result:=DWORD(SendMessage((hwnd), LVM_GETVIEW, 0, 0))
+end;
+
+
+// Macro 123
+// #define ListView_InsertGroup(hwnd, index, pgrp) \
+// SNDMSG((hwnd), LVM_INSERTGROUP, (WPARAM)index, (LPARAM)pgrp)
+
+Procedure ListView_InsertGroup( hwnd : hwnd; index : WPARAM; pgrp : LPARAM);
+Begin
+ SendMessage((hwnd), LVM_INSERTGROUP, index, pgrp)
+end;
+
+
+// Macro 124
+// #define ListView_SetGroupInfo(hwnd, iGroupId, pgrp) \
+// SNDMSG((hwnd), LVM_SETGROUPINFO, (WPARAM)iGroupId, (LPARAM)pgrp)
+
+Procedure ListView_SetGroupInfo( hwnd : hwnd; iGroupId : WPARAM; pgrp : LPARAM);
+Begin
+ SendMessage((hwnd), LVM_SETGROUPINFO, iGroupId, pgrp)
+end;
+
+
+// Macro 125
+// #define ListView_GetGroupInfo(hwnd, iGroupId, pgrp) \
+// SNDMSG((hwnd), LVM_GETGROUPINFO, (WPARAM)iGroupId, (LPARAM)pgrp)
+
+Procedure ListView_GetGroupInfo( hwnd : hwnd; iGroupId : WPARAM; pgrp : LPARAM);
+Begin
+ SendMessage((hwnd), LVM_GETGROUPINFO, iGroupId, pgrp)
+end;
+
+
+// Macro 126
+// #define ListView_RemoveGroup(hwnd, iGroupId) \
+// SNDMSG((hwnd), LVM_REMOVEGROUP, (WPARAM)iGroupId, 0)
+
+Procedure ListView_RemoveGroup( hwnd : hwnd; iGroupId : WPARAM);
+Begin
+ SendMessage((hwnd), LVM_REMOVEGROUP, iGroupId, 0)
+end;
+
+
+// Macro 127
+// #define ListView_MoveGroup(hwnd, iGroupId, toIndex) \
+// SNDMSG((hwnd), LVM_MOVEGROUP, (WPARAM)iGroupId, (LPARAM)toIndex)
+
+Procedure ListView_MoveGroup( hwnd : hwnd; iGroupId : WPARAM; toIndex : LPARAM);
+Begin
+ SendMessage((hwnd), LVM_MOVEGROUP, iGroupId, toIndex)
+end;
+
+
+// Macro 128
+// #define ListView_MoveItemToGroup(hwnd, idItemFrom, idGroupTo) \
+// SNDMSG((hwnd), LVM_MOVEITEMTOGROUP, (WPARAM)idItemFrom, (LPARAM)idGroupTo)
+
+Procedure ListView_MoveItemToGroup( hwnd : hwnd; idItemFrom : WPARAM; idGroupTo : LPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_MOVEITEMTOGROUP, idItemFrom, idGroupTo)
+end;
+
+
+// Macro 129
+// #define ListView_SetGroupMetrics(hwnd, pGroupMetrics) \
+// SNDMSG((hwnd), LVM_SETGROUPMETRICS, 0, (LPARAM)pGroupMetrics)
+
+Procedure ListView_SetGroupMetrics( hwnd : hwnd; pGroupMetrics : LPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_SETGROUPMETRICS, 0, pGroupMetrics)
+end;
+
+
+// Macro 130
+// #define ListView_GetGroupMetrics(hwnd, pGroupMetrics) \
+// SNDMSG((hwnd), LVM_GETGROUPMETRICS, 0, (LPARAM)pGroupMetrics)
+
+Procedure ListView_GetGroupMetrics( hwnd : hwnd; pGroupMetrics : LPARAM);
+
+Begin
+SendMessage((hwnd), LVM_GETGROUPMETRICS, 0, pGroupMetrics)
+end;
+
+
+// Macro 131
+// #define ListView_EnableGroupView(hwnd, fEnable) \
+// SNDMSG((hwnd), LVM_ENABLEGROUPVIEW, (WPARAM)fEnable, 0)
+
+Procedure ListView_EnableGroupView( hwnd : hwnd; fEnable : WPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_ENABLEGROUPVIEW, fEnable, 0)
+end;
+
+
+// Macro 132
+// #define ListView_SortGroups(hwnd, _pfnGroupCompate, _plv) \
+// SNDMSG((hwnd), LVM_SORTGROUPS, (WPARAM)_pfnGroupCompate, (LPARAM)_plv)
+
+Procedure ListView_SortGroups( hwnd : hwnd; _pfnGroupCompate : WPARAM; _plv : LPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_SORTGROUPS, _pfnGroupCompate, _plv)
+end;
+
+// Macro 133
+// #define ListView_InsertGroupSorted(hwnd, structInsert) \
+// SNDMSG((hwnd), LVM_INSERTGROUPSORTED, (WPARAM)structInsert, 0)
+
+Procedure ListView_InsertGroupSorted( hwnd : hwnd; structInsert : WPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_INSERTGROUPSORTED, structInsert, 0)
+end;
+
+
+// Macro 134
+// #define ListView_RemoveAllGroups(hwnd) \
+// SNDMSG((hwnd), LVM_REMOVEALLGROUPS, 0, 0)
+
+Procedure ListView_RemoveAllGroups( hwnd : hwnd);
+
+Begin
+SendMessage((hwnd), LVM_REMOVEALLGROUPS, 0, 0)
+end;
+
+
+// Macro 135
+// #define ListView_HasGroup(hwnd, dwGroupId) \
+// SNDMSG((hwnd), LVM_HASGROUP, dwGroupId, 0)
+
+Procedure ListView_HasGroup( hwnd : hwnd; dwGroupId :DWORD );
+
+Begin
+ SendMessage((hwnd), LVM_HASGROUP, dwGroupId, 0)
+end;
+
+
+// Macro 136
+// #define ListView_SetTileViewInfo(hwnd, ptvi) \
+// SNDMSG((hwnd), LVM_SETTILEVIEWINFO, 0, (LPARAM)ptvi)
+
+Procedure ListView_SetTileViewInfo( hwnd : hwnd; ptvi : LPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_SETTILEVIEWINFO, 0, ptvi)
+end;
+
+
+// Macro 137
+// #define ListView_GetTileViewInfo(hwnd, ptvi) \
+// SNDMSG((hwnd), LVM_GETTILEVIEWINFO, 0, (LPARAM)ptvi)
+
+Procedure ListView_GetTileViewInfo( hwnd : hwnd; ptvi : LPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_GETTILEVIEWINFO, 0, ptvi)
+end;
+
+
+// Macro 138
+// #define ListView_SetTileInfo(hwnd, pti) \
+// SNDMSG((hwnd), LVM_SETTILEINFO, 0, (LPARAM)pti)
+
+Procedure ListView_SetTileInfo( hwnd : hwnd; pti : LPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_SETTILEINFO, 0, pti)
+end;
+
+
+// Macro 139
+// #define ListView_GetTileInfo(hwnd, pti) \
+// SNDMSG((hwnd), LVM_GETTILEINFO, 0, (LPARAM)pti)
+
+Procedure ListView_GetTileInfo( hwnd : hwnd; pti : LPARAM);
+
+Begin
+ SendMessage((hwnd), LVM_GETTILEINFO, 0, pti)
+end;
+
+
+// Macro 140
+// #define ListView_SetInsertMark(hwnd, lvim) \
+// (BOOL)SNDMSG((hwnd), LVM_SETINSERTMARK, (WPARAM) 0, (LPARAM) (lvim))
+
+Function ListView_SetInsertMark( hwnd : hwnd; lvim : lparam ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETINSERTMARK, 0, lvim));
+end;
+
+
+// Macro 141
+// #define ListView_GetInsertMark(hwnd, lvim) \
+// (BOOL)SNDMSG((hwnd), LVM_GETINSERTMARK, (WPARAM) 0, (LPARAM) (lvim))
+
+Function ListView_GetInsertMark( hwnd : hwnd; lvim : lparam ):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETINSERTMARK, WPARAM (0), LPARAM (lvim)));
+end;
+
+
+// Macro 142
+// #define ListView_InsertMarkHitTest(hwnd, point, lvim) \
+// (int)SNDMSG((hwnd), LVM_INSERTMARKHITTEST, (WPARAM)(LPPOINT)(point), (LPARAM)(LPLVINSERTMARK)(lvim))
+
+Function ListView_InsertMarkHitTest( hwnd : hwnd; point : LPPOINT; lvim : LPLVINSERTMARK):cint;
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_INSERTMARKHITTEST, wparam(point), lparam(lvim)));
+end;
+
+
+// Macro 143
+// #define ListView_GetInsertMarkRect(hwnd, rc) \
+// (int)SNDMSG((hwnd), LVM_GETINSERTMARKRECT, (WPARAM)0, (LPARAM)(LPRECT)(rc))
+
+Function ListView_GetInsertMarkRect( hwnd : hwnd; rc : LPRECT):cint;
+Begin
+ Result:=cint(SendMessage((hwnd), LVM_GETINSERTMARKRECT, WPARAM(0), LPARAM(rc)))
+end;
+
+
+// Macro 144
+// #define ListView_SetInsertMarkColor(hwnd, color) \
+// (COLORREF)SNDMSG((hwnd), LVM_SETINSERTMARKCOLOR, (WPARAM)0, (LPARAM)(COLORREF)(color))
+
+Function ListView_SetInsertMarkColor( hwnd : hwnd; color : COLORREF):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), LVM_SETINSERTMARKCOLOR, WPARAM(0), color));
+end;
+
+// Macro 145
+// #define ListView_GetInsertMarkColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), LVM_GETINSERTMARKCOLOR, (WPARAM)0, (LPARAM)0)
+
+Function ListView_GetInsertMarkColor( hwnd : hwnd):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), LVM_GETINSERTMARKCOLOR, WPARAM(0), LPARAM(0)));
+end;
+
+// Macro 146
+// #define ListView_SetInfoTip(hwndLV, plvInfoTip)\
+// (BOOL)SNDMSG((hwndLV), LVM_SETINFOTIP, (WPARAM)0, (LPARAM)plvInfoTip)
+
+Function ListView_SetInfoTip( hwndLV : hwnd; plvInfoTip : LPARAM):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwndLV), LVM_SETINFOTIP, WPARAM(0), plvInfoTip));
+end;
+
+// Macro 147
+// #define ListView_GetSelectedColumn(hwnd) \
+// (UINT)SNDMSG((hwnd), LVM_GETSELECTEDCOLUMN, 0, 0)
+
+Function ListView_GetSelectedColumn( hwnd : hwnd):UINT;
+Begin
+ Result:=UINT(SendMessage((hwnd), LVM_GETSELECTEDCOLUMN, 0, 0));
+end;
+
+// Macro 148
+// #define ListView_IsGroupViewEnabled(hwnd) \
+// (BOOL)SNDMSG((hwnd), LVM_ISGROUPVIEWENABLED, 0, 0)
+
+Function ListView_IsGroupViewEnabled( hwnd : hwnd):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_ISGROUPVIEWENABLED, 0, 0));
+end;
+
+// Macro 149
+// #define ListView_GetOutlineColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), LVM_GETOUTLINECOLOR, 0, 0)
+
+Function ListView_GetOutlineColor( hwnd : hwnd):COLORREF;
+Begin
+ Result:=COLORREF(SendMessage((hwnd), LVM_GETOUTLINECOLOR, 0, 0));
+end;
+
+
+// Macro 150
+// #define ListView_SetOutlineColor(hwnd, color) \
+// (COLORREF)SNDMSG((hwnd), LVM_SETOUTLINECOLOR, (WPARAM)0, (LPARAM)(COLORREF)(color))
+
+Function ListView_SetOutlineColor( hwnd : hwnd; color : COLORREF):COLORREF;
+Begin
+ Result:=COLORREF(SendMessage((hwnd), LVM_SETOUTLINECOLOR, WPARAM(0), color));
+end;
+
+// Macro 151
+// #define ListView_CancelEditLabel(hwnd) \
+// (VOID)SNDMSG((hwnd), LVM_CANCELEDITLABEL, (WPARAM)0, (LPARAM)0)
+
+procedure ListView_CancelEditLabel( hwnd : hwnd);
+Begin
+ SendMessage((hwnd), LVM_CANCELEDITLABEL, WPARAM(0), LPARAM(0));
+end;
+
+// Macro 152
+// #define ListView_MapIndexToID(hwnd, index) \
+// (UINT)SNDMSG((hwnd), LVM_MAPINDEXTOID, (WPARAM)index, (LPARAM)0)
+
+Function ListView_MapIndexToID( hwnd : hwnd; index : WPARAM):UINT;
+
+Begin
+ Result:=UINT(SendMessage((hwnd), LVM_MAPINDEXTOID, index, LPARAM(0)));
+end;
+
+// Macro 153
+// #define ListView_MapIDToIndex(hwnd, id) \
+// (UINT)SNDMSG((hwnd), LVM_MAPIDTOINDEX, (WPARAM)id, (LPARAM)0)
+
+Function ListView_MapIDToIndex( hwnd : hwnd; id : WPARAM):UINT;
+Begin
+ Result:=UINT(SendMessage((hwnd), LVM_MAPIDTOINDEX, id, LPARAM(0)));
+end;
+
+function ListView_IsItemVisible(hwnd:hwnd; aindex:cuint):cuint;
+begin
+ Result:=UINT(SendMessage((hwnd),LVM_ISITEMVISIBLE, WPARAM(aindex), LPARAM(0)));
+end;
+{$ENDIF}
+
+{$ifdef win32vista}
+
+function ListView_SetGroupHeaderImageList(hwnd:HWNd;himl:HIMAGELIST):HIMAGELIST;
+begin
+ Result:=HIMAGELIST(SendMessage((hwnd),LVM_SETIMAGELIST, WPARAM(LVSIL_GROUPHEADER), LPARAM(HIMAGELIST((himl)))));
+end;
+
+function ListView_GetGroupHeaderImageList(hwnd:HWND):HIMAGELIST;
+begin
+ Result:=HIMAGELIST(SendMessage((hwnd),LVM_GETIMAGELIST, WPARAM(LVSIL_GROUPHEADER),LPARAM(0)));
+end;
+
+function ListView_GetEmptyText(hwnd:HWND;pszText:LPWSTR; cchText:CUINT):BOOL;
+begin
+ Result:=BOOL(SendMessage((hwnd),LVM_GETEMPTYTEXT, WPARAM(cchText), LPARAM(pszText)));
+end;
+
+function ListView_GetFooterRect(hwnd:HWND; prc:PRECT):BOOL;
+begin
+ Result:=BOOL(SendMessage((hwnd),LVM_GETFOOTERRECT, WPARAM(0), LPARAM(prc)));
+end;
+
+function ListView_GetFooterInfo(hwnd:HWND;plvfi: LPLVFOOTERINFO ):BOOL;
+begin
+ Result:=BOOL(SendMessage((hwnd),LVM_GETFOOTERINFO, WPARAM(0), LPARAM(plvfi)));
+end;
+
+function ListView_GetFooterItemRect(hwnd:HWND;iItem:CUINT;prc:PRECT):BOOL;
+begin
+ Result:=BOOL(SendMessage((hwnd),LVM_GETFOOTERITEMRECT, WPARAM(iItem), LPARAM(prc)));
+end;
+
+function ListView_GetFooterItem(hwnd:HWND;iItem:CUINT; pfi:PLVFOOTERITEM):BOOL;
+begin
+ Result:=BOOL(SendMessage((hwnd),LVM_GETFOOTERITEM, WPARAM(iItem), LPARAM(pfi)));
+end;
+
+// (hwnd), LVM_GETITEMINDEXRECT, (WPARAM)(LVITEMINDEX*)(plvii), \
+// ((prc) ? ((((LPRECT)(prc))->top = (iSubItem)), (((LPRECT)(prc))->left = (code)), (LPARAM)(prc)) : (LPARAM)(LPRECT)NULL))
+
+function ListView_GetItemIndexRect(hwnd:hwnd; plvii:PLVITEMINDEX; iSubItem:clong; code:clong; prc:LPRECT) :BOOL;
+begin
+ if assigned(prc) then
+ begin
+ prc^.top:=iSubItem;
+ prc^.left:=code;
+ end;
+ Result:=BOOL(SendMessage((hwnd), LVM_GETITEMINDEXRECT, WPARAM(pLVITEMINDEX(plvii)), LPARAM(PRC)));
+end;
+
+function ListView_SetItemIndexState(hwndLV:HWND; plvii:PLVITEMINDEX; data:CUINT; mask:CUINT):HRESULT;
+ var macro_lvi: LV_ITEM ;
+begin
+ macro_lvi.stateMask := (mask);
+ macro_lvi.state := (data);
+ Result:=HRESULT(SendMessage((hwndLV),LVM_SETITEMINDEXSTATE, WPARAM(pLVITEMINDEX(plvii)), LPARAM(PLV_ITEM(@macro_lvi))));
+end;
+
+function ListView_GetNextItemIndex(hwnd:HWND;plvii:PLVITEMINDEX; flags:LPARAM):BOOL;
+begin
+ Result:=BOOL(SendMessage((hwnd),LVM_GETNEXTITEMINDEX, WPARAM(pLVITEMINDEX(plvii)), MAKELPARAM(flags, 0)));
+end;
+{$endif}
+
+// Macro 154
+// #define ListView_SetBkImage(hwnd, plvbki) \
+// (BOOL)SNDMSG((hwnd), LVM_SETBKIMAGE, 0, (LPARAM)(plvbki))
+
+Function ListView_SetBkImage( hwnd : hwnd; plvbki : LPARAM):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_SETBKIMAGE, 0, plvbki));
+end;
+
+// Macro 155
+// #define ListView_GetBkImage(hwnd, plvbki) \
+// (BOOL)SNDMSG((hwnd), LVM_GETBKIMAGE, 0, (LPARAM)(plvbki))
+
+Function ListView_GetBkImage( hwnd : hwnd; plvbki : LPARAM):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), LVM_GETBKIMAGE, 0, plvbki));
+end;
+
+// Macro 156
+// #define TreeView_InsertItem(hwnd, lpis) \
+// (HTREEITEM)SNDMSG((hwnd), TVM_INSERTITEM, 0, (LPARAM)(LPTV_INSERTSTRUCT)(lpis))
+
+Function TreeView_InsertItem( hwnd : hwnd; lpis : LPTV_INSERTSTRUCT):HTREEITEM;inline;
+Begin
+ Result:=HTREEITEM(SendMessage((hwnd), TVM_INSERTITEM, 0, LPARAM(lpis)));
+end;
+
+
+Function TreeView_InsertItem( hwnd : hwnd; const lpis : TV_INSERTSTRUCT):HTREEITEM;inline;
+Begin
+ Result:=HTREEITEM(SendMessage((hwnd), TVM_INSERTITEM, 0, LPARAM(@lpis)));
+end;
+
+// Macro 157
+// #define TreeView_DeleteItem(hwnd, hitem) \
+// (BOOL)SNDMSG((hwnd), TVM_DELETEITEM, 0, (LPARAM)(HTREEITEM)(hitem))
+
+Function TreeView_DeleteItem( hwnd : hwnd; hitem : HTREEITEM):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_DELETEITEM, 0, LPARAM(hitem)));
+end;
+
+
+// Macro 158
+// #define TreeView_DeleteAllItems(hwnd) \
+// (BOOL)SNDMSG((hwnd), TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT)
+
+Function TreeView_DeleteAllItems( hwnd : hwnd):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_DELETEITEM, 0, LPARAM(HTREEITEM(TVI_ROOT))));
+end;
+
+
+// Macro 159
+// #define TreeView_Expand(hwnd, hitem, code) \
+// (BOOL)SNDMSG((hwnd), TVM_EXPAND, (WPARAM)(code), (LPARAM)(HTREEITEM)(hitem))
+
+Function TreeView_Expand( hwnd : hwnd; hitem : HTREEITEM; code : WPARAM):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_EXPAND, code, lparam(hitem)))
+end;
+
+
+// Macro 160
+// #define TreeView_GetItemRect(hwnd, hitem, prc, code) \
+// (*(HTREEITEM *)prc = (hitem), (BOOL)SNDMSG((hwnd), TVM_GETITEMRECT, (WPARAM)(code), (LPARAM)(RECT *)(prc)))
+
+Function TreeView_GetItemRect( hwnd : hwnd; hitem: HTREEITEM; code : WPARAM; prc : pRECT):BOOL;inline;
+Begin
+ HTREEITEM(prc):=HITEM;
+ Result:=Bool(SendMessage((hwnd), TVM_GETITEMRECT, code, LPARAM(prc)));
+end;
+
+Function TreeView_GetItemRect( hwnd : hwnd; hitem: HTREEITEM; var prc : TRECT;code : Bool):BOOL;inline;
+Begin
+ HTREEITEM(Pointer(@prc)^):=HITEM;
+ Result:=Bool(SendMessage((hwnd), TVM_GETITEMRECT, WPARAM(code), LPARAM(@prc)));
+end;
+
+// Macro 161
+// #define TreeView_GetCount(hwnd) \
+// (UINT)SNDMSG((hwnd), TVM_GETCOUNT, 0, 0)
+
+Function TreeView_GetCount( hwnd : hwnd):UINT;
+Begin
+ Result:=UINT(SendMessage((hwnd), TVM_GETCOUNT, 0, 0))
+end;
+
+// Macro 162
+// #define TreeView_GetIndent(hwnd) \
+// (UINT)SNDMSG((hwnd), TVM_GETINDENT, 0, 0)
+
+Function TreeView_GetIndent( hwnd : hwnd):UINT;
+Begin
+ Result:=UINT(SendMessage((hwnd), TVM_GETINDENT, 0, 0))
+end;
+
+
+// Macro 163
+// #define TreeView_SetIndent(hwnd, indent) \
+// (BOOL)SNDMSG((hwnd), TVM_SETINDENT, (WPARAM)(indent), 0)
+
+Function TreeView_SetIndent( hwnd : hwnd; indent : WPARAM):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_SETINDENT, indent, 0))
+end;
+
+
+// Macro 164
+// #define TreeView_GetImageList(hwnd, iImage) \
+// (HIMAGELIST)SNDMSG((hwnd), TVM_GETIMAGELIST, iImage, 0)
+
+Function TreeView_GetImageList( hwnd : hwnd; iImage : cint ):HIMAGELIST;
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), TVM_GETIMAGELIST, iImage, 0))
+end;
+
+
+// Macro 165
+// #define TreeView_SetImageList(hwnd, himl, iImage) \
+// (HIMAGELIST)SNDMSG((hwnd), TVM_SETIMAGELIST, iImage, (LPARAM)(HIMAGELIST)(himl))
+
+Function TreeView_SetImageList( hwnd : hwnd; himl : HIMAGELIST; iImage : cint ):HIMAGELIST;
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), TVM_SETIMAGELIST, iImage, himl))
+end;
+
+// Macro 166
+// #define TreeView_GetNextItem(hwnd, hitem, code) \
+// (HTREEITEM)SNDMSG((hwnd), TVM_GETNEXTITEM, (WPARAM)(code), (LPARAM)(HTREEITEM)(hitem))
+
+Function TreeView_GetNextItem( hwnd : hwnd; hitem : HTREEITEM; code : WPARAM):HTREEITEM;
+
+Begin
+ Result:=HTREEITEM(SendMessage((hwnd), TVM_GETNEXTITEM, code, lparam(hitem)))
+end;
+
+
+// Macro 167
+
+function TreeView_GetChild(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;
+
+Begin
+ Result:=TreeView_GetNextItem(hwnd, hitem, TVGN_CHILD)
+End;
+// Macro 168
+
+// #define TreeView_GetNextSibling(hwnd:hwnd; hitem:HTREEITEM);
+// (hwnd, hitem)
+// TreeView_GetNextItem(hwnd, hitem, TVGN_NEXT)
+
+
+
+function TreeView_GetNextSibling(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;
+// (hwnd, hitem)
+// TreeView_GetNextItem(hwnd, hitem, TVGN_NEXT)
+
+Begin
+ Result:=TreeView_getNextItem(hwnd,hitem,TVGN_NEXT);
+end;
+
+// Macro 169
+function TreeView_GetPrevSibling(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;
+begin
+ Result:=TreeView_GetNextItem(hwnd, hitem, TVGN_PREVIOUS);
+end;
+
+// Macro 170
+
+function TreeView_GetParent(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;
+begin
+ Result:=TreeView_GetNextItem(hwnd, hitem, TVGN_PARENT)
+end;
+
+// Macro 171
+// #define TreeView_GetFirstVisible(hwnd:hwnd);
+// TreeView_GetNextItem(hwnd, NULL, TVGN_FIRSTVISIBLE)
+
+function TreeView_GetFirstVisible(hwnd:hwnd) : HTREEITEM;inline;
+begin
+ Result:=TreeView_GetNextItem(hwnd, NIL, TVGN_FIRSTVISIBLE)
+end;
+
+// Macro 172
+
+//#define TreeView_GetNextVisible(hwnd:hwnd; hitem:HTREEITEM);
+//(hwnd, hitem) TreeView_GetNextItem(hwnd, hitem, TVGN_NEXTVISIBLE)
+function TreeView_GetNextVisible(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;inline;
+begin
+ Result:=TreeView_GetNextItem(hwnd, hitem, TVGN_NEXTVISIBLE)
+end;
+
+// Macro 173
+//#define TreeView_GetPrevVisible(hwnd:hwnd; hitem:HTREEITEM);
+// (hwnd, hitem) TreeView_GetNextItem(hwnd, hitem, TVGN_PREVIOUSVISIBLE)
+
+
+function TreeView_GetPrevVisible(hwnd:hwnd; hitem:HTREEITEM) : HTREEITEM;inline;
+Begin
+ Result:=TreeView_GetNextItem(hwnd, hitem, TVGN_PREVIOUSVISIBLE);
+end;
+
+// Macro 174
+
+function TreeView_GetSelection(hwnd:hwnd) : HTREEITEM;inline;
+begin
+ Result:=TreeView_GetNextItem(hwnd, NIL, TVGN_CARET);
+end;
+
+// Macro 175
+
+//#define TreeView_GetDropHilight(hwnd:hwnd);
+//TreeView_GetNextItem(hwnd, NULL, TVGN_DROPHILITE)
+
+function TreeView_GetDropHilight(hwnd:hwnd) : HTREEITEM;inline;
+
+begin
+ Result:=TreeView_GetNextItem(hwnd, NIL, TVGN_DROPHILITE);
+end;
+
+function TreeView_GetDropHilite(hwnd:hwnd) : HTREEITEM;inline;
+
+begin
+ Result:=TreeView_GetNextItem(hwnd, NIL, TVGN_DROPHILITE);
+end;
+
+
+// Macro 176
+
+function TreeView_GetRoot(hwnd:hwnd) : HTREEITEM;inline;
+
+begin
+ Result:=TreeView_GetNextItem(hwnd, NIL, TVGN_ROOT);
+end;
+
+// Macro 177
+//#define TreeView_GetLastVisible(hwnd:hwnd);
+//TreeView_GetNextItem(hwnd, NULL, TVGN_LASTVISIBLE)
+
+function TreeView_GetLastVisible(hwnd:hwnd) : HTREEITEM;inline;
+begin
+ Result:=TreeView_GetNextItem(hwnd, NIL, TVGN_LASTVISIBLE)
+end;
+
+// Macro 178
+
+
+Function TreeView_Select( hwnd : hwnd; hitem : HTREEITEM; code : WPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_SELECTITEM, code, LPARAM(hitem)))
+end;
+
+// Macro 179
+// #define TreeView_SelectItem(hwnd, hitem) TreeView_Select(hwnd, hitem, TVGN_CARET)
+// Macro 180
+// #define TreeView_SelectDropTarget(hwnd, hitem) TreeView_Select(hwnd, hitem, TVGN_DROPHILITE)
+// Macro 181
+// #define TreeView_SelectSetFirstVisible(hwnd, hitem) TreeView_Select(hwnd, hitem, TVGN_FIRSTVISIBLE)
+
+// Macro 179
+Procedure TreeView_SelectItem(hwnd:hwnd; hitem:HTREEITEM);
+Begin
+ TreeView_Select(hwnd, hitem, TVGN_CARET)
+End;
+
+// Macro 180
+Procedure TreeView_SelectDropTarget(hwnd:hwnd; hitem:HTREEITEM);
+Begin
+ TreeView_Select(hwnd, hitem, TVGN_DROPHILITE)
+End;
+
+// Macro 181
+Procedure TreeView_SelectSetFirstVisible(hwnd:hwnd; hitem:HTREEITEM);
+Begin
+ TreeView_Select(hwnd, hitem, TVGN_FIRSTVISIBLE)
+End;
+
+// Macro 182
+// #define TreeView_GetItem(hwnd, pitem) \
+// (BOOL)SNDMSG((hwnd), TVM_GETITEM, 0, (LPARAM)(TV_ITEM *)(pitem))
+
+Function TreeView_GetItem( hwnd : hwnd;var pitem : TV_ITEM ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_GETITEM, 0, LPARAM(@pitem)))
+end;
+
+
+// Macro 183
+
+//#define TreeView_SetItem(hwnd, pitem) \
+// (BOOL)SNDMSG((hwnd), TVM_SETITEM, 0, (LPARAM)(const TV_ITEM *)(pitem))
+
+Function TreeView_SetItem( hwnd : hwnd;const pitem : TV_ITEM ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_SETITEM, 0, LParam(@pitem)))
+end;
+
+
+// Macro 184
+
+//#define TreeView_EditLabel(hwnd, hitem) \
+// (HWND)SNDMSG((hwnd), TVM_EDITLABEL, 0, (LPARAM)(HTREEITEM)(hitem))
+
+Function TreeView_EditLabel( hwnd : hwnd; hitem : HTREEITEM):HWND;
+
+Begin
+ Result:=Windows.HWND(SendMessage((hwnd), TVM_EDITLABEL, 0, LParam(hitem)))
+end;
+
+
+// Macro 185
+
+//#define TreeView_GetEditControl(hwnd) \
+// (HWND)SNDMSG((hwnd), TVM_GETEDITCONTROL, 0, 0)
+
+Function TreeView_GetEditControl( hwnd : hwnd):HWND;
+
+Begin
+ Result:=Windows.HWND(SendMessage((hwnd), TVM_GETEDITCONTROL, 0, 0))
+end;
+
+
+// Macro 186
+
+//#define TreeView_GetVisibleCount(hwnd) \
+// (UINT)SNDMSG((hwnd), TVM_GETVISIBLECOUNT, 0, 0)
+
+Function TreeView_GetVisibleCount( hwnd : hwnd):UINT;
+
+Begin
+ Result:=UINT(SendMessage((hwnd), TVM_GETVISIBLECOUNT, 0, 0))
+end;
+
+
+// Macro 187
+
+//#define TreeView_HitTest(hwnd, lpht) \
+// (HTREEITEM)SNDMSG((hwnd), TVM_HITTEST, 0, (LPARAM)(LPTV_HITTESTINFO)(lpht))
+
+Function TreeView_HitTest( hwnd : hwnd; lpht : LPTV_HITTESTINFO):HTREEITEM;inline;
+
+Begin
+ Result:=HTREEITEM(SendMessage((hwnd), TVM_HITTEST, 0, lparam(lpht)))
+end;
+
+
+Function TreeView_HitTest( hwnd : hwnd; var lpht : TV_HITTESTINFO):HTREEITEM;inline;
+
+Begin
+ Result:=HTREEITEM(SendMessage((hwnd), TVM_HITTEST, 0, lparam(@lpht)))
+end;
+// Macro 188
+
+//#define TreeView_CreateDragImage(hwnd, hitem) \
+// (HIMAGELIST)SNDMSG((hwnd), TVM_CREATEDRAGIMAGE, 0, (LPARAM)(HTREEITEM)(hitem))
+
+Function TreeView_CreateDragImage( hwnd : hwnd; hitem : HTREEITEM):HIMAGELIST;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), TVM_CREATEDRAGIMAGE, 0, Lparam(hitem)))
+end;
+
+
+// Macro 189
+
+//#define TreeView_SortChildren(hwnd, hitem, recurse) \
+// (BOOL)SNDMSG((hwnd), TVM_SORTCHILDREN, (WPARAM)(recurse), (LPARAM)(HTREEITEM)(hitem))
+
+Function TreeView_SortChildren( hwnd : hwnd; hitem : HTREEITEM; recurse : WPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_SORTCHILDREN, recurse, LParam(hitem)))
+end;
+
+
+// Macro 190
+
+//#define TreeView_EnsureVisible(hwnd, hitem) \
+// (BOOL)SNDMSG((hwnd), TVM_ENSUREVISIBLE, 0, (LPARAM)(HTREEITEM)(hitem))
+
+Function TreeView_EnsureVisible( hwnd : hwnd; hitem : HTREEITEM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_ENSUREVISIBLE, 0, LParam(hitem)))
+end;
+
+
+// Macro 191
+
+//#define TreeView_SortChildrenCB(hwnd, psort, recurse) \
+// (BOOL)SNDMSG((hwnd), TVM_SORTCHILDRENCB, (WPARAM)(recurse), \
+// (LPARAM)(LPTV_SORTCB)(psort))
+
+Function TreeView_SortChildrenCB( hwnd : hwnd;psort :lpTV_sortcb; recurse : WPARAM):BOOL;inline;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_SORTCHILDRENCB, recurse, LPARAM(psort)))
+end;
+
+
+Function TreeView_SortChildrenCB( hwnd : hwnd;const psort :tagTVsortcb; recurse : WPARAM):BOOL;inline;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_SORTCHILDRENCB, recurse, LPARAM(@psort)))
+end;
+
+
+// Macro 192
+
+//#define TreeView_EndEditLabelNow(hwnd, fCancel) \
+// (BOOL)SNDMSG((hwnd), TVM_ENDEDITLABELNOW, (WPARAM)(fCancel), 0)
+
+Function TreeView_EndEditLabelNow( hwnd : hwnd; fCancel : WPARAM):BOOL;inline;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_ENDEDITLABELNOW, fCancel, 0))
+end;
+
+
+Function TreeView_EndEditLabelNow( hwnd : hwnd; fCancel : Bool):BOOL;inline;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_ENDEDITLABELNOW, WPARAM(fCancel), 0))
+end;
+
+
+// Macro 193
+
+//#define TreeView_SetToolTips(hwnd, hwndTT) \
+// (HWND)SNDMSG((hwnd), TVM_SETTOOLTIPS, (WPARAM)(hwndTT), 0)
+
+Function TreeView_SetToolTips( hwnd : hwnd; hwndTT : WPARAM):HWND;
+
+Begin
+ Result:=Windows.HWND(SendMessage((hwnd), TVM_SETTOOLTIPS, hwndTT, 0))
+end;
+
+
+// Macro 194
+
+//#define TreeView_GetToolTips(hwnd) \
+// (HWND)SNDMSG((hwnd), TVM_GETTOOLTIPS, 0, 0)
+
+Function TreeView_GetToolTips( hwnd : hwnd):HWND;
+
+Begin
+ Result:=Windows.HWND(SendMessage((hwnd), TVM_GETTOOLTIPS, 0, 0))
+end;
+
+
+// Macro 195
+
+//#define TreeView_GetISearchString(hwndTV, lpsz) \
+// (BOOL)SNDMSG((hwndTV), TVM_GETISEARCHSTRING, 0, (LPARAM)(LPTSTR)(lpsz))
+
+Function TreeView_GetISearchString( hwndTV : hwnd; lpsz : LPTSTR):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndTV), TVM_GETISEARCHSTRING, 0, LPARAM(lpsz)))
+end;
+
+
+// Macro 196
+
+//#define TreeView_SetInsertMark(hwnd, hItem, fAfter) \
+// (BOOL)SNDMSG((hwnd), TVM_SETINSERTMARK, (WPARAM) (fAfter), (LPARAM) (hItem))
+
+Function TreeView_SetInsertMark( hwnd : hwnd; hItem : LParam ; fAfter : WParam ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_SETINSERTMARK, (fAfter), (hItem)))
+end;
+
+
+// Macro 197
+
+//#define TreeView_SetUnicodeFormat(hwnd, fUnicode) \
+// (BOOL)SNDMSG((hwnd), TVM_SETUNICODEFORMAT, (WPARAM)(fUnicode), 0)
+
+Function TreeView_SetUnicodeFormat( hwnd : hwnd; fUnicode : WPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_SETUNICODEFORMAT, fUnicode, 0))
+end;
+
+
+// Macro 198
+
+//#define TreeView_GetUnicodeFormat(hwnd) \
+// (BOOL)SNDMSG((hwnd), TVM_GETUNICODEFORMAT, 0, 0)
+
+Function TreeView_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TVM_GETUNICODEFORMAT, 0, 0))
+end;
+
+
+// Macro 199
+
+//#define TreeView_SetItemHeight(hwnd, iHeight) \
+// (int)SNDMSG((hwnd), TVM_SETITEMHEIGHT, (WPARAM)(iHeight), 0)
+
+Function TreeView_SetItemHeight( hwnd : hwnd; iHeight : WPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), TVM_SETITEMHEIGHT, iHeight, 0))
+end;
+
+
+// Macro 200
+
+//#define TreeView_GetItemHeight(hwnd) \
+// (int)SNDMSG((hwnd), TVM_GETITEMHEIGHT, 0, 0)
+
+Function TreeView_GetItemHeight( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), TVM_GETITEMHEIGHT, 0, 0))
+end;
+
+
+// Macro 201
+
+//#define TreeView_SetBkColor(hwnd, clr) \
+// (COLORREF)SNDMSG((hwnd), TVM_SETBKCOLOR, 0, (LPARAM)(clr))
+
+Function TreeView_SetBkColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), TVM_SETBKCOLOR, 0, clr))
+end;
+
+
+// Macro 202
+
+//#define TreeView_SetTextColor(hwnd, clr) \
+// (COLORREF)SNDMSG((hwnd), TVM_SETTEXTCOLOR, 0, (LPARAM)(clr))
+
+Function TreeView_SetTextColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), TVM_SETTEXTCOLOR, 0, clr))
+end;
+
+
+// Macro 203
+
+//#define TreeView_GetBkColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), TVM_GETBKCOLOR, 0, 0)
+
+Function TreeView_GetBkColor( hwnd : hwnd):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), TVM_GETBKCOLOR, 0, 0))
+end;
+
+
+// Macro 204
+
+//#define TreeView_GetTextColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), TVM_GETTEXTCOLOR, 0, 0)
+
+Function TreeView_GetTextColor( hwnd : hwnd):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), TVM_GETTEXTCOLOR, 0, 0))
+end;
+
+
+// Macro 205
+
+//#define TreeView_SetScrollTime(hwnd, uTime) \
+// (UINT)SNDMSG((hwnd), TVM_SETSCROLLTIME, uTime, 0)
+
+Function TreeView_SetScrollTime( hwnd : hwnd; uTime : wparam ):UINT;
+
+Begin
+ Result:=UINT(SendMessage((hwnd), TVM_SETSCROLLTIME, uTime, 0))
+end;
+
+
+// Macro 206
+
+//#define TreeView_GetScrollTime(hwnd) \
+// (UINT)SNDMSG((hwnd), TVM_GETSCROLLTIME, 0, 0)
+
+Function TreeView_GetScrollTime( hwnd : hwnd):UINT;
+
+Begin
+ Result:=UINT(SendMessage((hwnd), TVM_GETSCROLLTIME, 0, 0))
+end;
+
+
+// Macro 207
+
+//#define TreeView_SetInsertMarkColor(hwnd, clr) \
+// (COLORREF)SNDMSG((hwnd), TVM_SETINSERTMARKCOLOR, 0, (LPARAM)(clr))
+
+Function TreeView_SetInsertMarkColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), TVM_SETINSERTMARKCOLOR, 0, clr))
+end;
+
+
+// Macro 208
+
+//#define TreeView_GetInsertMarkColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), TVM_GETINSERTMARKCOLOR, 0, 0)
+
+Function TreeView_GetInsertMarkColor( hwnd : hwnd):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), TVM_GETINSERTMARKCOLOR, 0, 0))
+end;
+
+
+// Macro 209
+
+//#define TreeView_SetItemState(hwndTV, hti, data, _mask) \
+// { TVITEM _ms_TVi;\
+// _ms_TVi.mask = TVIF_STATE; \
+// _ms_TVi.hItem = hti; \
+// _ms_TVi.stateMask = _mask;\
+// _ms_TVi.state = data;\
+// SNDMSG((hwndTV), TVM_SETITEM, 0, (LPARAM)(TV_ITEM *)&_ms_TVi);\
+// }
+
+Procedure TreeView_SetItemState(hwndTV:HWND;hti:HTreeItem;data:UINT;_mask:UINT);
+
+var _ms_TVi : TVITEM;
+
+Begin
+ _ms_TVi.mask:=TVIF_STATE;
+ _ms_TVi.hItem := hti;
+ _ms_TVi.stateMask := _mask;
+ _ms_TVi.state := data;
+ SendMessage(hwndTV,TVM_SETITEM, 0, LPARAM(@_ms_TVi));
+end;
+
+
+// Macro 210
+
+//#define TreeView_SetCheckState(hwndTV, hti, fCheck) \
+// TreeView_SetItemState(hwndTV, hti, INDEXTOSTATEIMAGEMASK((fCheck)?2:1), TVIS_STATEIMAGEMASK)
+
+Procedure TreeView_SetCheckState( hwndTV : hwnd; hti : HTreeItem ; fCheck : bool );
+
+var j : cint;
+
+Begin
+ IF not fCheck Then // (or inc(longint(fCheck)) if you like it dirty)
+ j:=1
+ Else
+ j:=2;
+
+ TreeView_SetItemState(hwndTV, hti, INDEXTOSTATEIMAGEMASK(j), TVIS_STATEIMAGEMASK)
+end;
+
+
+{$ifdef IE5plus}
+// Macro 211
+
+//#define TreeView_GetItemState(hwndTV, hti, mask) \
+// (UINT)SNDMSG((hwndTV), TVM_GETITEMSTATE, (WPARAM)(hti), (LPARAM)(mask))
+
+Function TreeView_GetItemState( hwndTV : hwnd; hti : WPARAM; mask : LPARAM):UINT;
+
+Begin
+ Result:=UINT(SendMessage((hwndTV), TVM_GETITEMSTATE, hti, mask))
+end;
+
+
+
+// Macro 212
+// #define TreeView_GetCheckState(hwndTV, hti) \
+// ((((UINT)(SNDMSG((hwndTV), TVM_GETITEMSTATE, (WPARAM)(hti), TVIS_STATEIMAGEMASK))) >> 12) -1)
+
+Function TreeView_GetCheckState( hwndTV : hwnd; hti : WPARAM):UINT;
+
+Begin
+ Result:=((UINT(SendMessage((hwndTV), TVM_GETITEMSTATE, hti, TVIS_STATEIMAGEMASK) shr 12) -1));
+end;
+
+
+// Macro 213
+
+// #define TreeView_SetLineColor(hwnd, clr) \
+// (COLORREF)SNDMSG((hwnd), TVM_SETLINECOLOR, 0, (LPARAM)(clr))
+
+Function TreeView_SetLineColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), TVM_SETLINECOLOR, 0, clr))
+end;
+
+
+// Macro 214
+
+// #define TreeView_GetLineColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), TVM_GETLINECOLOR, 0, 0)
+
+Function TreeView_GetLineColor( hwnd : hwnd):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), TVM_GETLINECOLOR, 0, 0))
+end;
+
+
+// Macro 215
+// #define TreeView_MapAccIDToHTREEITEM(hwnd, id) \
+// (HTREEITEM)SNDMSG((hwnd), TVM_MAPACCIDTOHTREEITEM, id, 0)
+
+Function TreeView_MapAccIDToHTREEITEM( hwnd : hwnd; id :uint):HTREEITEM;
+
+Begin
+ Result:=HTREEITEM(SendMessage((hwnd), TVM_MAPACCIDTOHTREEITEM, id, 0))
+end;
+
+
+// Macro 216
+// #define TreeView_MapHTREEITEMToAccID(hwnd, htreeitem) \
+// (UINT)SNDMSG((hwnd), TVM_MAPHTREEITEMTOACCID, (WPARAM)htreeitem, 0)
+
+Function TreeView_MapHTREEITEMToAccID( hwnd : hwnd; htreeitem : WPARAM):UINT;
+
+Begin
+ Result:=UINT(SendMessage((hwnd), TVM_MAPHTREEITEMTOACCID, htreeitem, 0))
+end;
+{$endif}
+
+{$ifdef win32vista}
+function TreeView_GetSelectedCount(hwnd:hwnd):DWORD;
+Begin
+ Result:=DWORD(SendMessage((hwnd),TVM_GETSELECTEDCOUNT, 0, 0));
+end;
+
+function TreeView_ShowInfoTip(hwnd:HWND; hitem:HTREEITEM):DWORD;
+Begin
+ Result:=DWORD(SendMessage((hwnd),TVM_SHOWINFOTIP, 0, LPARAM(hitem)));
+end;
+
+function TreeView_GetItemPartRect(hwnd:HWND; hitem:HTREEITEM; prc:prect; partid:TVITEMPART):bool;
+var info : TVGETITEMPARTRECTINFO;
+Begin
+ info.hti := (hitem);
+ info.prc := (prc);
+ info.partID := (partid);
+ Result:=BOOL(SendMessage((hwnd), TVM_GETITEMPARTRECT, 0, LPARAM(@info)));
+end;
+{$endif}
+
+// Macro 217
+
+//#define TabCtrl_GetImageList(hwnd) \
+// (HIMAGELIST)SNDMSG((hwnd), TCM_GETIMAGELIST, 0, DWord(0))
+
+Function TabCtrl_GetImageList( hwnd : hwnd):HIMAGELIST;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), TCM_GETIMAGELIST, 0, LPARAM(0)))
+end;
+
+
+// Macro 218
+
+//#define TabCtrl_SetImageList(hwnd, himl) \
+// (HIMAGELIST)SNDMSG((hwnd), TCM_SETIMAGELIST, 0, (LPARAM)(HIMAGELIST)(himl))
+
+Function TabCtrl_SetImageList( hwnd : hwnd; himl : HIMAGELIST):HIMAGELIST;
+
+Begin
+ Result:=HIMAGELIST(SendMessage((hwnd), TCM_SETIMAGELIST, 0, himl))
+end;
+
+
+// Macro 219
+
+//#define TabCtrl_GetItemCount(hwnd) \
+// (int)SNDMSG((hwnd), TCM_GETITEMCOUNT, 0, DWord(0))
+
+Function TabCtrl_GetItemCount( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), TCM_GETITEMCOUNT, 0, LPARAM(0)))
+end;
+
+
+// Macro 220
+
+//#define TabCtrl_GetItem(hwnd, iItem, pitem) \
+// (BOOL)SNDMSG((hwnd), TCM_GETITEM, (WPARAM)(int)(iItem), (LPARAM)(TC_ITEM *)(pitem))
+
+Function TabCtrl_GetItem( hwnd : hwnd; iItem : cint;var pitem : TC_ITEM ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TCM_GETITEM, iItem, LPARAM(@pitem)))
+end;
+
+
+// Macro 221
+
+//#define TabCtrl_SetItem(hwnd, iItem, pitem) \
+// (BOOL)SNDMSG((hwnd), TCM_SETITEM, (WPARAM)(int)(iItem), (LPARAM)(TC_ITEM *)(pitem))
+
+Function TabCtrl_SetItem( hwnd : hwnd; iItem : cint;var pitem : TC_ITEM ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TCM_SETITEM, iItem, LPARAM(@pitem)))
+end;
+
+
+// Macro 222
+
+//#define TabCtrl_InsertItem(hwnd, iItem, pitem) \
+// (int)SNDMSG((hwnd), TCM_INSERTITEM, (WPARAM)(int)(iItem), (LPARAM)(const TC_ITEM *)(pitem))
+
+Function TabCtrl_InsertItem( hwnd : hwnd; iItem : cint;const pitem : TC_ITEM ):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), TCM_INSERTITEM, iItem, LPARAM(@pitem)));
+end;
+
+
+// Macro 223
+
+//#define TabCtrl_DeleteItem(hwnd, i) \
+// (BOOL)SNDMSG((hwnd), TCM_DELETEITEM, (WPARAM)(int)(i), DWord(0))
+
+Function TabCtrl_DeleteItem( hwnd : hwnd; i : cint):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TCM_DELETEITEM, (i), LPARAM(0)))
+end;
+
+
+// Macro 224
+
+//#define TabCtrl_DeleteAllItems(hwnd) \
+// (BOOL)SNDMSG((hwnd), TCM_DELETEALLITEMS, 0, DWord(0))
+
+Function TabCtrl_DeleteAllItems( hwnd : hwnd):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TCM_DELETEALLITEMS, 0, LPARAM(0)))
+end;
+
+
+// Macro 225
+
+//#define TabCtrl_GetItemRect(hwnd, i, prc) \
+// (BOOL)SNDMSG((hwnd), TCM_GETITEMRECT, (WPARAM)(int)(i), (LPARAM)(RECT *)(prc))
+
+Function TabCtrl_GetItemRect( hwnd : hwnd; i : cint;var prc : RECT ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TCM_GETITEMRECT, (i), LPARAM(@prc)))
+end;
+
+
+// Macro 226
+
+//#define TabCtrl_GetCurSel(hwnd) \
+// (int)SNDMSG((hwnd), TCM_GETCURSEL, 0, 0)
+
+Function TabCtrl_GetCurSel( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), TCM_GETCURSEL, 0, 0))
+end;
+
+
+// Macro 227
+
+//#define TabCtrl_SetCurSel(hwnd, i) \
+// (int)SNDMSG((hwnd), TCM_SETCURSEL, (WPARAM)(i), 0)
+
+Function TabCtrl_SetCurSel( hwnd : hwnd; i : WPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), TCM_SETCURSEL, (i), 0))
+end;
+
+
+// Macro 228
+
+//#define TabCtrl_HitTest(hwndTC, pinfo) \
+// (int)SNDMSG((hwndTC), TCM_HITTEST, 0, (LPARAM)(TC_HITTESTINFO *)(pinfo))
+
+Function TabCtrl_HitTest( hwndTC : hwnd;var pinfo : TC_HITTESTINFO ):cint;inline;
+
+Begin
+ Result:=cint(SendMessage((hwndTC), TCM_HITTEST, 0, LPARAM(@pinfo)))
+end;
+
+
+Function TabCtrl_HitTest( hwndTC : hwnd;pinfo : LPTCHITTESTINFO ):cint;inline;
+
+Begin
+ Result:=cint(SendMessage((hwndTC), TCM_HITTEST, 0, LPARAM(@pinfo)))
+end;
+
+
+// Macro 229
+
+//#define TabCtrl_SetItemExtra(hwndTC, cb) \
+// (BOOL)SNDMSG((hwndTC), TCM_SETITEMEXTRA, (WPARAM)(cb), DWord(0))
+
+Function TabCtrl_SetItemExtra( hwndTC : hwnd; cb : WPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwndTC), TCM_SETITEMEXTRA, cb, LPARAM(0)))
+end;
+
+
+// Macro 230
+
+//#define TabCtrl_AdjustRect(hwnd, bLarger, prc) \
+// (int)SNDMSG(hwnd, TCM_ADJUSTRECT, (WPARAM)(BOOL)(bLarger), (LPARAM)(RECT *)prc)
+
+Function TabCtrl_AdjustRect( hwnd : hwnd; bLarger : BOOL;var prc : RECT ):cint;
+
+Begin
+ Result:=cint(SendMessage(hwnd, TCM_ADJUSTRECT, Wparam(bLarger), Lparam(@prc)));
+end;
+
+
+// Macro 231
+
+//#define TabCtrl_SetItemSize(hwnd, x, y) \
+// (DWORD)SNDMSG((hwnd), TCM_SETITEMSIZE, 0, MAKELPARAM(x,y))
+
+Function TabCtrl_SetItemSize( hwnd : hwnd; x : wparam ; y : lparam ):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwnd), TCM_SETITEMSIZE, 0, MAKELPARAM(x,y)))
+end;
+
+
+// Macro 232
+
+//#define TabCtrl_RemoveImage(hwnd, i) \
+// (void)SNDMSG((hwnd), TCM_REMOVEIMAGE, i, DWord(0))
+
+Procedure TabCtrl_RemoveImage( hwnd : hwnd; i : WPARAM);
+
+Begin
+SendMessage((hwnd), TCM_REMOVEIMAGE, i, LPARAM(0))
+end;
+
+
+// Macro 233
+
+//#define TabCtrl_SetPadding(hwnd, cx, cy) \
+// (void)SNDMSG((hwnd), TCM_SETPADDING, 0, MAKELPARAM(cx, cy))
+
+Procedure TabCtrl_SetPadding( hwnd : hwnd; cx : WPARAM ; cy : LPARAM );
+
+Begin
+SendMessage((hwnd), TCM_SETPADDING, 0, MAKELPARAM(cx, cy))
+end;
+
+
+// Macro 234
+
+//#define TabCtrl_GetRowCount(hwnd) \
+// (int)SNDMSG((hwnd), TCM_GETROWCOUNT, 0, DWord(0))
+
+Function TabCtrl_GetRowCount( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), TCM_GETROWCOUNT, 0, LPARAM(0)))
+end;
+
+
+// Macro 235
+
+//#define TabCtrl_GetToolTips(hwnd) \
+// (HWND)SNDMSG((hwnd), TCM_GETTOOLTIPS, 0, DWord(0))
+
+Function TabCtrl_GetToolTips( hwnd : hwnd):HWND;
+
+Begin
+ Result:=Windows.HWND(SendMessage((hwnd), TCM_GETTOOLTIPS, 0, LPARAM(0)))
+end;
+
+
+// Macro 236
+
+//#define TabCtrl_SetToolTips(hwnd, hwndTT) \
+// (void)SNDMSG((hwnd), TCM_SETTOOLTIPS, (WPARAM)(hwndTT), DWord(0))
+
+Procedure TabCtrl_SetToolTips( hwnd : hwnd; hwndTT : WPARAM);
+
+Begin
+SendMessage((hwnd), TCM_SETTOOLTIPS, hwndTT, LPARAM(0))
+end;
+
+
+// Macro 237
+
+//#define TabCtrl_GetCurFocus(hwnd) \
+// (int)SNDMSG((hwnd), TCM_GETCURFOCUS, 0, 0)
+
+Function TabCtrl_GetCurFocus( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), TCM_GETCURFOCUS, 0, 0))
+end;
+
+
+// Macro 238
+
+//#define TabCtrl_SetCurFocus(hwnd, i) \
+// SNDMSG((hwnd),TCM_SETCURFOCUS, i, 0)
+
+Procedure TabCtrl_SetCurFocus( hwnd : hwnd; i : LPARAM );
+
+Begin
+SendMessage((hwnd),TCM_SETCURFOCUS, i, 0)
+end;
+
+
+// Macro 239
+
+//#define TabCtrl_SetMinTabWidth(hwnd, x) \
+// (int)SNDMSG((hwnd), TCM_SETMINTABWIDTH, 0, x)
+
+Function TabCtrl_SetMinTabWidth( hwnd : hwnd; x : WPARAM ):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), TCM_SETMINTABWIDTH, 0, x))
+end;
+
+
+// Macro 240
+
+//#define TabCtrl_DeselectAll(hwnd, fExcludeFocus)\
+// (void)SNDMSG((hwnd), TCM_DESELECTALL, fExcludeFocus, 0)
+
+Procedure TabCtrl_DeselectAll( hwnd : hwnd; fExcludeFocus : WPARAM );
+
+Begin
+SendMessage((hwnd), TCM_DESELECTALL, fExcludeFocus, 0)
+end;
+
+
+// Macro 241
+
+//#define TabCtrl_HighlightItem(hwnd, i, fHighlight) \
+// (BOOL)SNDMSG((hwnd), TCM_HIGHLIGHTITEM, (WPARAM)(i), (LPARAM)MAKELONG (fHighlight, 0))
+
+Function TabCtrl_HighlightItem( hwnd : hwnd; i : WPARAM; fHighlight :bool ):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TCM_HIGHLIGHTITEM, (i), LPARAM(MAKELONG (cint(fHighlight), 0))))
+end;
+
+
+// Macro 242
+
+//#define TabCtrl_SetExtendedStyle(hwnd, dw)\
+// (DWORD)SNDMSG((hwnd), TCM_SETEXTENDEDSTYLE, 0, dw)
+
+Function TabCtrl_SetExtendedStyle( hwnd : hwnd; dw : LPARAM):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwnd), TCM_SETEXTENDEDSTYLE, 0,lparam(dw)))
+end;
+
+
+// Macro 243
+
+//#define TabCtrl_GetExtendedStyle(hwnd)\
+// (DWORD)SNDMSG((hwnd), TCM_GETEXTENDEDSTYLE, 0, 0)
+
+Function TabCtrl_GetExtendedStyle( hwnd : hwnd):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwnd), TCM_GETEXTENDEDSTYLE, 0, 0))
+end;
+
+
+// Macro 244
+
+//#define TabCtrl_SetUnicodeFormat(hwnd, fUnicode) \
+// (BOOL)SNDMSG((hwnd), TCM_SETUNICODEFORMAT, (WPARAM)(fUnicode), 0)
+
+Function TabCtrl_SetUnicodeFormat( hwnd : hwnd; fUnicode : WPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TCM_SETUNICODEFORMAT, fUnicode, 0))
+end;
+
+
+// Macro 245
+
+//#define TabCtrl_GetUnicodeFormat(hwnd) \
+// (BOOL)SNDMSG((hwnd), TCM_GETUNICODEFORMAT, 0, 0)
+
+Function TabCtrl_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), TCM_GETUNICODEFORMAT, 0, 0));
+end;
+
+
+// Macro 246
+
+//#define Animate_Create(hwndP, id, dwStyle, hInstance) \
+// CreateWindow(ANIMATE_CLASS, NULL, \
+// dwStyle, 0, 0, 0, 0, hwndP, (HMENU)(id), hInstance, NULL)
+
+Function Animate_Create(hwndP :HWND;id:HMENU;dwStyle:dword;hInstance:HINST):HWND;
+
+Begin
+ result:=CreateWindow(ANIMATE_CLASS, NIL,
+ dwStyle, 0, 0, 0, 0, hwndP, id, hInstance, NIL);
+end;
+
+
+// Macro 247
+//#define Animate_Open(hwnd, szName) (BOOL)SNDMSG(hwnd, ACM_OPEN, 0, (LPARAM)(LPTSTR)(szName))
+
+Function Animate_Open(hwndP :HWND;szName:LPTSTR):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage(hwndp, ACM_OPEN, 0, LPARAM(szName)));
+end;
+
+
+// Macro 248
+//#define Animate_OpenEx(hwnd, hInst, szName) (BOOL)SNDMSG(hwnd, ACM_OPEN, (WPARAM)(hInst), (LPARAM)(LPTSTR)(szName))
+
+Function Animate_OpenEx(hwndP :HWND;HInst:HInst; szName:LPTSTR):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage(hwndp, ACM_OPEN, hinst, LPARAM(szName)));
+end;
+
+
+// Macro 249
+//#define Animate_Play(hwnd, from, to, rep) (BOOL)SNDMSG(hwnd, ACM_PLAY, (WPARAM)(rep), (LPARAM)MAKELONG(from, to))
+
+Function Animate_Play(hwndP :HWND;from,_to,rep:uint):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage(hwndP, ACM_PLAY, wparam(rep), LPARAM(MAKELONG(From,_to))));
+end;
+
+
+// Macro 250
+//#define Animate_Stop(hwnd) (BOOL)SNDMSG(hwnd, ACM_STOP, 0, 0)
+
+Function Animate_stop(hwndP :HWND):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage(hwndP, ACM_STOP, 0, 0));
+end;
+
+
+// Macro 251
+//#define Animate_Close(hwnd) Animate_Open(hwnd, NULL)
+
+Function Animate_close(hwndP :HWND):BOOL;
+
+Begin
+ Result:=BOOL(Animate_Open(hwndP,NIL));
+end;
+
+
+// Macro 252
+//#define Animate_Seek(hwnd, frame) Animate_Play(hwnd, frame, frame, 1)
+
+Function Animate_Seek(hwndP :HWND;frame:uint):BOOL;
+
+Begin
+ Result:=BOOL(Animate_Play(hwndP,frame,frame,1));
+end;
+
+// Macro 253
+//#define MonthCal_GetCurSel(hmc, pst) (BOOL)SNDMSG(hmc, MCM_GETCURSEL, 0, (LPARAM)(pst))
+
+function MonthCal_GetCurSel(hwndMC:HWND; lpSysTime :LPSYSTEMTIME):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_GETCURSEL , 0, LPARAM(lpsystime)));
+end;
+
+// Macro 254
+//#define MonthCal_SetCurSel(hmc, pst) (BOOL)SNDMSG(hmc, MCM_SETCURSEL, 0, (LPARAM)(pst))
+
+function MonthCal_SetCurSel(hwndMC:HWND; lpSysTime :LPSYSTEMTIME):Bool; inline;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_SETCURSEL, 0, LPARAM(lpsystime)));
+end;
+
+function MonthCal_SetCurSel(hwndMC:HWND; var lpSysTime :SYSTEMTIME):Bool; inline;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_SETCURSEL, 0, LPARAM(@lpsystime)));
+end;
+
+// Macro 255
+//#define MonthCal_GetMaxSelCount(hmc) (DWORD)SNDMSG(hmc, MCM_GETMAXSELCOUNT, 0, DWord(0))
+
+function MonthCal_GetMaxSelCount(hwndMC:HWND):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_GETMAXSELCOUNT, 0, LPARAM(0)));
+end;
+
+// Macro 256
+//#define MonthCal_SetMaxSelCount(hmc, n) (BOOL)SNDMSG(hmc, MCM_SETMAXSELCOUNT, (WPARAM)(n), DWord(0))
+
+function MonthCal_SetMaxSelCount(hwndMC:HWND;n:uint):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_SETMAXSELCOUNT,WPARAM(N), LPARAM(0)));
+end;
+
+// Macro 257
+//#define MonthCal_GetSelRange(hmc, rgst) SNDMSG(hmc, MCM_GETSELRANGE, 0, (LPARAM)(rgst))
+
+function MonthCal_GetSelRange(hwndMC:HWND; lpSysTime :LPSYSTEMTIME):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_GETSELRANGE,WPARAM(0), LPARAM(lpsystime)));
+end;
+
+// Macro 258
+//#define MonthCal_SetSelRange(hmc, rgst) SNDMSG(hmc, MCM_SETSELRANGE, 0, (LPARAM)(rgst))
+
+function MonthCal_SetSelRange(hwndMC:HWND; lpSysTime :LPSYSTEMTIME):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_SETSELRANGE,WPARAM(0), LPARAM(lpsystime)));
+end;
+
+
+// Macro 259
+//#define MonthCal_GetMonthRange(hmc, gmr, rgst) (DWORD)SNDMSG(hmc, MCM_GETMONTHRANGE, (WPARAM)(gmr), (LPARAM)(rgst))
+
+function MonthCal_GetMonthRange(hwndMC:HWND; gmr: DWORD;lpSysTime :LPSYSTEMTIME):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_GETMONTHRANGE,WPARAM(gmr), LPARAM(lpsystime)));
+end;
+
+// Macro 260
+//#define MonthCal_SetDayState(hmc, cbds, rgds) SNDMSG(hmc, MCM_SETDAYSTATE, (WPARAM)(cbds), (LPARAM)(rgds))
+
+function MonthCal_SetDayState(hwndMC:HWND; gmr: Longint;lpDay :LPMONTHDAYSTATE):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_SETDAYSTATE,WPARAM(gmr), LPARAM(lpDay)));
+end;
+
+// Macro 261
+// #define MonthCal_GetMinReqRect(hmc, prc) SNDMSG(hmc, MCM_GETMINREQRECT, 0, (LPARAM)(prc))
+
+function MonthCal_GetMinReqRect(hwndMC:HWND; lpr :LPRect):Bool;inline;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_GETMINREQRECT,0, LPARAM(lpr)));
+end;
+
+function MonthCal_GetMinReqRect(hwndMC:HWND;var lpr :TRect):Bool;inline;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_GETMINREQRECT,0, LPARAM(@lpr)));
+end;
+
+// Macro 262
+// #define MonthCal_SetColor(hmc, iColor, clr) SNDMSG(hmc, MCM_SETCOLOR, iColor, clr)
+
+function MonthCal_SetColor(hwndMC:HWND; ic:longint;clr:COLORREF):DWORD;inline;
+
+begin
+ Result:=DWORD(SendMessage(hwndmc, MCM_SETCOLOR,ic, LPARAM(clr)));
+end;
+
+// Macro 263
+// #define MonthCal_GetColor(hmc, iColor) SNDMSG(hmc, MCM_GETCOLOR, iColor, 0)
+
+function MonthCal_GetColor(hwndMC:HWND; ic:longint):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_GETCOLOR,ic, 0));
+end;
+
+// Macro 264
+// #define MonthCal_SetToday(hmc, pst) SNDMSG(hmc, MCM_SETTODAY, 0, (LPARAM)(pst))
+
+function MonthCal_SetToday(hwndMC:HWND; lps:LPSYSTEMTIME):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_SETTODAY,0, LPARAM(lps)));
+end;
+
+// Macro 265
+// #define MonthCal_GetToday(hmc, pst) (BOOL)SNDMSG(hmc, MCM_GETTODAY, 0, (LPARAM)(pst))
+
+function MonthCal_GetToday(hwndMC:HWND; lps:LPSYSTEMTIME):Bool;
+
+begin
+ Result:=BOOL(SendMessage(hwndmc, MCM_GETTODAY,0, LPARAM(lps)));
+end;
+
+
+// Macro 266
+// #define MonthCal_HitTest(hmc, pinfo) \
+// SNDMSG(hmc, MCM_HITTEST, 0, (LPARAM)(PMCHITTESTINFO)(pinfo))
+
+FUNCTION MonthCal_HitTest( hmc :HWND ; pinfo : PMCHITTESTINFO):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage(hmc, MCM_HITTEST, 0, LPARAM(pinfo)));
+end;
+
+
+// Macro 267
+// #define MonthCal_SetFirstDayOfWeek(hmc, iDay) \
+// SNDMSG(hmc, MCM_SETFIRSTDAYOFWEEK, 0, iDay)
+
+function MonthCal_SetFirstDayOfWeek( hmc : HWND ; iDay :LONGINT ):DWORD;
+
+Begin
+ Result:=SendMessage(hmc, MCM_SETFIRSTDAYOFWEEK, 0, iDay);
+end;
+
+
+// Macro 268
+// #define MonthCal_GetFirstDayOfWeek(hmc) \
+// (DWORD)SNDMSG(hmc, MCM_GETFIRSTDAYOFWEEK, 0, 0)
+
+Function MonthCal_GetFirstDayOfWeek( hmc : HWND ):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage(hmc, MCM_GETFIRSTDAYOFWEEK, 0, 0))
+end;
+
+
+// Macro 269
+// #define MonthCal_GetRange(hmc, rgst) \
+// (DWORD)SNDMSG(hmc, MCM_GETRANGE, 0, (LPARAM)(rgst))
+
+Function MonthCal_GetRange( hmc : HWND ; rgst : LPSYSTEMTIME):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage(hmc, MCM_GETRANGE, 0, lparam(rgst)));
+end;
+
+
+// Macro 270
+// #define MonthCal_SetRange(hmc, gd, rgst) \
+// (BOOL)SNDMSG(hmc, MCM_SETRANGE, (WPARAM)(gd), (LPARAM)(rgst))
+
+Function MonthCal_SetRange( hmc : HWND ; gd : DWORD; rgst : LPSYSTEMTIME):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage(hmc, MCM_SETRANGE, gd,LPARAM(rgst)))
+end;
+
+
+// Macro 271
+// #define MonthCal_GetMonthDelta(hmc) \
+// (int)SNDMSG(hmc, MCM_GETMONTHDELTA, 0, 0)
+
+Function MonthCal_GetMonthDelta( hmc :hwnd ):cint;
+
+Begin
+ Result:=cint(SendMessage(hmc, MCM_GETMONTHDELTA, 0, 0))
+end;
+
+
+// Macro 272
+// #define MonthCal_SetMonthDelta(hmc, n) \
+// (int)SNDMSG(hmc, MCM_SETMONTHDELTA, n, 0)
+
+Function MonthCal_SetMonthDelta( hmc :hwnd ; n :cint ):cint;
+
+Begin
+ Result:=cint(SendMessage(hmc, MCM_SETMONTHDELTA, n, 0))
+end;
+
+
+// Macro 273
+
+// #define MonthCal_GetMaxTodayWidth(hmc) \
+// (DWORD)SNDMSG(hmc, MCM_GETMAXTODAYWIDTH, 0, 0)
+
+Function MonthCal_GetMaxTodayWidth( hmc :hwnd ):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage(hmc, MCM_GETMAXTODAYWIDTH, 0, 0))
+end;
+
+
+// Macro 274
+// #define MonthCal_SetUnicodeFormat(hwnd, fUnicode) \
+// (BOOL)SNDMSG((hwnd), MCM_SETUNICODEFORMAT, (WPARAM)(fUnicode), 0)
+
+Function MonthCal_SetUnicodeFormat( hwnd : hwnd; fUnicode : bool):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), MCM_SETUNICODEFORMAT, wparam(fUnicode), 0))
+end;
+
+
+// Macro 275
+
+// #define MonthCal_GetUnicodeFormat(hwnd) \
+// (BOOL)SNDMSG((hwnd), MCM_GETUNICODEFORMAT, 0, 0)
+
+Function MonthCal_GetUnicodeFormat( hwnd : hwnd):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), MCM_GETUNICODEFORMAT, 0, 0))
+end;
+
+
+// Macro 276
+// #define DateTime_GetSystemtime(hdp, pst) (DWORD)SNDMSG(hdp, DTM_GETSYSTEMTIME, 0, (LPARAM)(pst))
+
+// Macro 277
+
+//#define DateTime_SetSystemtime(hdp, gd, pst) (BOOL)SNDMSG(hdp, DTM_SETSYSTEMTIME, (WPARAM)(gd), (LPARAM)(pst))
+function DateTime_SetSystemTime(hdp: HWND; gd: DWORD; const pst: TSystemTime): BOOL;inline;
+begin
+ result:=BOOL(SendMessage(hdp, DTM_SETSYSTEMTIME, WPARAM(gd), LPARAM(@pst)));
+end;
+
+// Macro 278
+
+//#define DateTime_GetRange(hdp, rgst) (DWORD)SNDMSG(hdp, DTM_GETRANGE, 0, (LPARAM)(rgst))
+
+// Macro 279
+
+//#define DateTime_SetRange(hdp, gd, rgst) (BOOL)SNDMSG(hdp, DTM_SETRANGE, (WPARAM)(gd), (LPARAM)(rgst))
+function DateTime_SetRange(hdp: HWND; gdtr: DWORD; rgst: PSystemTime): BOOL;inline;
+begin
+ result:=BOOL(SendMessage(hdp, DTM_SETRANGE, WPARAM(gdtr), LPARAM(rgst)));
+end;
+
+// Macro 280
+
+//#define DateTime_SetFormat(hdp, sz) (BOOL)SNDMSG(hdp, DTM_SETFORMAT, 0, (LPARAM)(sz))
+
+// Macro 281
+
+//#define DateTime_SetMonthCalColor(hdp, iColor, clr) SNDMSG(hdp, DTM_SETMCCOLOR, iColor, clr)
+function DateTime_SetMonthCalColor(hdp: HWND; iColor: DWORD; clr: TColorRef): TColorRef;inline;
+begin
+ result:=TColorRef(SendMessage(hdp, DTM_SETMCCOLOR, iColor, clr));
+end;
+
+// Macro 282
+
+//#define DateTime_GetMonthCalColor(hdp, iColor) SNDMSG(hdp, DTM_GETMCCOLOR, iColor, 0)
+
+// Macro 283
+
+//#define DateTime_GetMonthCal(hdp) (HWND)SNDMSG(hdp, DTM_GETMONTHCAL, 0, 0)
+function DateTime_GetMonthCal(hdp: HWND): HWND;inline;
+begin
+ result:=HWND(SendMessage(hdp, DTM_GETMONTHCAL, 0, 0));
+end;
+
+// Macro 284
+
+//#define DateTime_SetMonthCalFont(hdp, hfont, fRedraw) SNDMSG(hdp, DTM_SETMCFONT, (WPARAM)(hfont), (LPARAM)(fRedraw))
+
+// Macro 285
+
+//#define DateTime_GetMonthCalFont(hdp) SNDMSG(hdp, DTM_GETMCFONT, 0, 0)
+
+// Macro 286
+
+//#define MAKEIPRANGE(low, high) ((LPARAM)(WORD)(((BYTE)(high) << 8) + (BYTE)(low)))
+
+// Macro 287
+
+//#define MAKEIPADDRESS(b1,b2,b3,b4) ((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4))))
+
+// Macro 288
+
+//#define FIRST_IPADDRESS(x) ((x>>24) & 0xff)
+
+// Macro 289
+
+//#define SECOND_IPADDRESS(x) ((x>>16) & 0xff)
+
+// Macro 290
+
+//#define THIRD_IPADDRESS(x) ((x>>8) & 0xff)
+
+// Macro 291
+
+//#define FOURTH_IPADDRESS(x) (x & 0xff)
+
+// Macro 292
+
+//#define Pager_SetChild(hwnd, hwndChild) \
+// (void)SNDMSG((hwnd), PGM_SETCHILD, 0, (LPARAM)(hwndChild))
+
+Procedure Pager_SetChild( hwnd : hwnd; hwndChild : LPARAM);
+
+Begin
+SendMessage((hwnd), PGM_SETCHILD, 0, hwndChild)
+end;
+
+
+// Macro 293
+
+//#define Pager_RecalcSize(hwnd) \
+// (void)SNDMSG((hwnd), PGM_RECALCSIZE, 0, 0)
+
+Procedure Pager_RecalcSize( hwnd : hwnd);
+
+Begin
+SendMessage((hwnd), PGM_RECALCSIZE, 0, 0)
+end;
+
+
+// Macro 294
+
+//#define Pager_ForwardMouse(hwnd, bForward) \
+// (void)SNDMSG((hwnd), PGM_FORWARDMOUSE, (WPARAM)(bForward), 0)
+
+Procedure Pager_ForwardMouse( hwnd : hwnd; bForward : WPARAM);
+
+Begin
+SendMessage((hwnd), PGM_FORWARDMOUSE, bForward, 0)
+end;
+
+
+// Macro 295
+
+//#define Pager_SetBkColor(hwnd, clr) \
+// (COLORREF)SNDMSG((hwnd), PGM_SETBKCOLOR, 0, (LPARAM)(clr))
+
+Function Pager_SetBkColor( hwnd : hwnd; clr : LPARAM):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), PGM_SETBKCOLOR, 0, clr))
+end;
+
+
+// Macro 296
+
+//#define Pager_GetBkColor(hwnd) \
+// (COLORREF)SNDMSG((hwnd), PGM_GETBKCOLOR, 0, 0)
+
+Function Pager_GetBkColor( hwnd : hwnd):COLORREF;
+
+Begin
+ Result:=COLORREF(SendMessage((hwnd), PGM_GETBKCOLOR, 0, 0))
+end;
+
+
+// Macro 297
+
+//#define Pager_SetBorder(hwnd, iBorder) \
+// (int)SNDMSG((hwnd), PGM_SETBORDER, 0, (LPARAM)(iBorder))
+
+Function Pager_SetBorder( hwnd : hwnd; iBorder : LPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), PGM_SETBORDER, 0, iBorder))
+end;
+
+
+// Macro 298
+// #define Pager_GetBorder(hwnd) \
+// (int)SNDMSG((hwnd), PGM_GETBORDER, 0, 0)
+
+Function Pager_GetBorder( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), PGM_GETBORDER, 0, 0))
+end;
+
+
+// Macro 299
+
+//#define Pager_SetPos(hwnd, iPos) \
+// (int)SNDMSG((hwnd), PGM_SETPOS, 0, (LPARAM)(iPos))
+
+Function Pager_SetPos( hwnd : hwnd; iPos : LPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), PGM_SETPOS, 0, iPos))
+end;
+
+
+// Macro 300
+
+//#define Pager_GetPos(hwnd) \
+// (int)SNDMSG((hwnd), PGM_GETPOS, 0, 0)
+
+Function Pager_GetPos( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), PGM_GETPOS, 0, 0))
+end;
+
+
+// Macro 301
+
+//#define Pager_SetButtonSize(hwnd, iSize) \
+// (int)SNDMSG((hwnd), PGM_SETBUTTONSIZE, 0, (LPARAM)(iSize))
+
+Function Pager_SetButtonSize( hwnd : hwnd; iSize : LPARAM):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), PGM_SETBUTTONSIZE, 0, iSize))
+end;
+
+
+// Macro 302
+
+//#define Pager_GetButtonSize(hwnd) \
+// (int)SNDMSG((hwnd), PGM_GETBUTTONSIZE, 0,0)
+
+Function Pager_GetButtonSize( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), PGM_GETBUTTONSIZE, 0,0))
+end;
+
+
+// Macro 303
+
+//#define Pager_GetButtonState(hwnd, iButton) \
+// (DWORD)SNDMSG((hwnd), PGM_GETBUTTONSTATE, 0, (LPARAM)(iButton))
+
+Function Pager_GetButtonState( hwnd : hwnd; iButton : LPARAM):DWORD;
+
+Begin
+ Result:=DWORD(SendMessage((hwnd), PGM_GETBUTTONSTATE, 0, iButton))
+end;
+
+
+// Macro 304
+// #define Pager_GetDropTarget(hwnd, ppdt) \
+// (void)SNDMSG((hwnd), PGM_GETDROPTARGET, 0, (LPARAM)(ppdt))
+
+Procedure Pager_GetDropTarget( hwnd : hwnd; ppdt : LPARAM);
+
+Begin
+SendMessage((hwnd), PGM_GETDROPTARGET, 0, ppdt)
+end;
+
+
+// Macro 305
+// #define Button_GetIdealSize(hwnd, psize)\
+// (BOOL)SNDMSG((hwnd), BCM_GETIDEALSIZE, 0, (LPARAM)(psize))
+
+Function Button_GetIdealSize( hwnd : hwnd; psize : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_GETIDEALSIZE, 0, psize))
+end;
+
+
+// Macro 306
+// #define Button_SetImageList(hwnd, pbuttonImagelist)\
+// (BOOL)SNDMSG((hwnd), BCM_SETIMAGELIST, 0, (LPARAM)(pbuttonImagelist))
+
+Function Button_SetImageList( hwnd : hwnd; pbuttonImagelist : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_SETIMAGELIST, 0, pbuttonImagelist))
+end;
+
+// Macro 307
+// #define Button_GetImageList(hwnd, pbuttonImagelist)\
+// (BOOL)SNDMSG((hwnd), BCM_GETIMAGELIST, 0, (LPARAM)(pbuttonImagelist))
+
+Function Button_GetImageList( hwnd : hwnd; pbuttonImagelist : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_GETIMAGELIST, 0, pbuttonImagelist))
+end;
+
+
+// Macro 308
+// #define Button_SetTextMargin(hwnd, pmargin)\
+// (BOOL)SNDMSG((hwnd), BCM_SETTEXTMARGIN, 0, (LPARAM)(pmargin))
+
+Function Button_SetTextMargin( hwnd : hwnd; pmargin : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_SETTEXTMARGIN, 0, pmargin))
+end;
+
+
+// Macro 309
+// #define Button_GetTextMargin(hwnd, pmargin)\
+// (BOOL)SNDMSG((hwnd), BCM_GETTEXTMARGIN, 0, (LPARAM)(pmargin))
+
+Function Button_GetTextMargin( hwnd : hwnd; pmargin : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_GETTEXTMARGIN, 0, pmargin))
+end;
+
+
+// Macro 310
+// #define Edit_SetCueBannerText(hwnd, lpcwText) \
+// (BOOL)SNDMSG((hwnd), EM_SETCUEBANNER, 0, (LPARAM)(lpcwText))
+
+Function Edit_SetCueBannerText( hwnd : hwnd; lpcwText : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), EM_SETCUEBANNER, 0, lpcwText))
+end;
+
+
+// Macro 311
+//#define Edit_GetCueBannerText(hwnd, lpwText, cchText) \
+// (BOOL)SNDMSG((hwnd), EM_GETCUEBANNER, (WPARAM)(lpwText), (LPARAM)(cchText))
+
+Function Edit_GetCueBannerText( hwnd : hwnd; lpwText : WPARAM; cchText : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), EM_GETCUEBANNER, lpwText, cchText))
+end;
+
+
+// Macro 312
+// #define Edit_ShowBalloonTip(hwnd, peditballoontip) \
+// (BOOL)SNDMSG((hwnd), EM_SHOWBALLOONTIP, 0, (LPARAM)(peditballoontip))
+
+Function Edit_ShowBalloonTip( hwnd : hwnd; peditballoontip : LPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), EM_SHOWBALLOONTIP, 0, peditballoontip))
+end;
+
+
+// Macro 313
+// #define Edit_HideBalloonTip(hwnd) \
+// (BOOL)SNDMSG((hwnd), EM_HIDEBALLOONTIP, 0, 0)
+
+Function Edit_HideBalloonTip( hwnd : hwnd):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), EM_HIDEBALLOONTIP, 0, 0))
+end;
+
+
+// Macro 314
+//#define ComboBox_SetMinVisible(hwnd, iMinVisible) \
+// (BOOL)SNDMSG((hwnd), CB_SETMINVISIBLE, (WPARAM)iMinVisible, 0)
+
+Function ComboBox_SetMinVisible( hwnd : hwnd; iMinVisible : WPARAM):BOOL;
+
+Begin
+ Result:=BOOL(SendMessage((hwnd), CB_SETMINVISIBLE, iMinVisible, 0))
+end;
+
+
+// Macro 315
+// #define ComboBox_GetMinVisible(hwnd) \
+// (int)SNDMSG((hwnd), CB_GETMINVISIBLE, 0, 0)
+
+Function ComboBox_GetMinVisible( hwnd : hwnd):cint;
+
+Begin
+ Result:=cint(SendMessage((hwnd), CB_GETMINVISIBLE, 0, 0))
+end;
+
+{$ifdef win32vista}
+function TreeView_GetNextSelected(hwnd:hwnd; hitem:HTREEITEM):HTREEITEM;inline;
+begin
+ result:=TreeView_GetNextItem(hwnd, hitem, TVGN_NEXTSELECTED)
+end;
+{$endif}
+
+{$ifdef win32vista}
+function Button_SetDropDownState(hwnd:HWND; fDropDown:BOOL) : BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_SETDROPDOWNSTATE, WPARAM(fDropDown), 0));
+end;
+
+function Button_SetSplitInfo(hwnd:HWND; pInfo:PBUTTON_SPLITINFO):BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_SETSPLITINFO, 0, LPARAM(pInfo)));
+end;
+
+function Button_GetSplitInfo(hwnd:HWND; pInfo:PBUTTON_SPLITINFO) :BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_GETSPLITINFO, 0, LPARAM(pInfo)));
+end;
+
+function Button_SetNote(hwnd:HWND; psz:LPCWSTR) :BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_SETNOTE, 0, LPARAM(psz)));
+end;
+
+function Button_GetNote(hwnd:HWND; psz:LPCWSTR; pcc:cint) :BOOL;
+Begin
+ Result:=BOOL(SendMessage((hwnd), BCM_GETNOTE, WPARAM(pcc), LPARAM(psz)));
+end;
+
+function Button_GetNoteLength(hwnd:HWND) :LRESULT;
+Begin
+ Result:=LRESULT(SendMessage((hwnd), BCM_GETNOTELENGTH, 0, 0));
+end;
+
+// Macro to use on a button or command link to display an elevated icon
+
+function Button_SetElevationRequiredState(hwnd:HWND; fRequired:BOOL) :LRESULT;
+Begin
+ Result:=LRESULT(SendMessage((hwnd), BCM_SETSHIELD, 0, LPARAM(fRequired)));
+end;
+{$endif}
+{$ifdef win32vista}
+procedure Edit_SetHilite(hwndCtl:hwnd; ichStart:Wparam; ichEnd:lparam);
+begin
+ sendmessage(hwndctl, EM_SETHILITE, (ichStart), (ichEnd));
+end;
+
+function Edit_GetHilite(hwndCtl:hwnd):Dword;
+begin
+ result:=SendMessage((hwndCtl), EM_GETHILITE, 0, 0);
+end;
+{$endif}
+
+{$ifdef ntddi_vista}
+function MonthCal_GetCurrentView(hmc:HWND):DWORD;
+Begin
+ Result:=DWord(SendMessage(hmc, MCM_GETCURRENTVIEW, 0, 0));
+end;
+
+function MonthCal_GetCalendarCount(hmc:HWND):DWORD;
+Begin
+ Result:=DWord(SendMessage(hmc,MCM_GETCALENDARCOUNT, 0, 0));
+end;
+
+function MonthCal_GetCalendarGridInfo(hmc:HWND; pmc:pMCGRIDINFO):BOOL;
+Begin
+ Result:=BOOL(SendMessage(hmc, MCM_GETCALENDARGRIDINFO, 0, LPARAM(PMCGRIDINFO(pmc))));
+end;
+
+function MonthCal_GetCALID(hmc:HWND):CALID;
+Begin
+ Result:=CALID(SendMessage(hmc, MCM_GETCALID, 0, 0));
+end;
+
+function MonthCal_SetCALID(hmc:HWND; calid:cuint):LRESULT;
+Begin
+ Result:=LRESULT(SendMessage(hmc, MCM_SETCALID, WPARAM(calid), 0));
+end;
+
+function MonthCal_SizeRectToMin(hmc:HWND; prc:prect):LRESULT;
+Begin
+ Result:=LRESULT(SendMessage(hmc, MCM_SIZERECTTOMIN, 0, LPARAM(prc)));
+end;
+
+function MonthCal_SetCalendarBorder(hmc:HWND; fset:bool; xyborder:cint):LRESULT;
+Begin
+ Result:=LRESULT(SendMessage(hmc, MCM_SETCALENDARBORDER, WPARAM(fset), LPARAM(xyborder)));
+end;
+
+function MonthCal_GetCalendarBorder(hmc:HWND):cint;
+Begin
+ Result:=cint(SendMessage(hmc, MCM_GETCALENDARBORDER, 0, 0));
+end;
+
+function MonthCal_SetCurrentView(hmc:HWND; dwNewView:DWord):BOOL;
+Begin
+ Result:=BOOL(SendMessage(hmc, MCM_SETCURRENTVIEW, 0, LPARAM(dwNewView)));
+end;
+
+{$endif}
+
+{$ifdef NTDDI_VISTA}
+function DateTime_SetMonthCalStyle(hdp:HWND; dwStyle:DWord):LResult;
+Begin
+ Result:=LRESULT(SendMessage(hdp,DTM_SETMCSTYLE, 0, LPARAM(dwStyle)));
+end;
+
+function DateTime_GetMonthCalStyle(hdp:HWND):LRESULT;
+Begin
+ Result:=LRESULT(SendMessage(hdp,DTM_GETMCSTYLE, 0, 0));
+end;
+
+function DateTime_CloseMonthCal(hdp:HWND):LRESULT;
+Begin
+ Result:=LRESULT(SendMessage(hdp,DTM_CLOSEMONTHCAL, 0, 0));
+end;
+
+// DateTime_GetDateTimePickerInfo(HWND hdp, DATETIMEPICKERINFO* pdtpi)
+// Retrieves information about the selected date time picker.
+
+function DateTime_GetDateTimePickerInfo(hdp:HWND; pdtpi:PDATETIMEPICKERINFO):LRESULT;
+Begin
+ Result:=LRESULT(SendMessage(hdp, DTM_GETDATETIMEPICKERINFO, 0, LPARAM(pdtpi)));
+end;
+
+function DateTime_GetIdealSize(hdp:HWND; ps:PSIZE): LResult;
+Begin
+ Result:=LRESULT(SendMessage(hdp, DTM_GETIDEALSIZE, 0, LPARAM(ps)));
+end;
+
+{$endif}
+
+// Macro 284
+procedure DateTime_SetMonthCalFont(hdp:HWND; hfont:HFONT; fRedraw:LPARAM);
+begin
+ SendMessage(hdp, DTM_SETMCFONT, WPARAM(hfont), LPARAM(fRedraw));
+end;
+
+// Macro 285
+function DateTime_GetMonthCalFont(hdp:HWND):HFONT;
+begin
+ Result:=HFONT(SendMessage(hdp, DTM_GETMCFONT, 0, 0));
+end;
+
+const
+ comctl32lib = 'comctl32.dll';
+
+var
+ comctl32handle: THandle = 0;
+
+function _TaskDialogIndirect(const pTaskConfig: PTASKDIALOGCONFIG; pnButton: PInteger; pnRadioButton: PInteger; pfVerificationFlagChecked: PBOOL): HRESULT; stdcall;
+begin
+ Result := E_NOTIMPL;
+end;
+
+function _TaskDialog(hwndParent: HWND; hInstance: HINST; pszWindowTitle: PCWSTR; pszMainInstruction: PCWSTR; pszContent: PCWSTR;
+ dwCommonButtons: TASKDIALOG_COMMON_BUTTON_FLAGS; pszIcon: PCWSTR; pnButton: PInteger): HRESULT; stdcall;
+begin
+ Result := E_NOTIMPL;
+end;
+
+procedure Initialize;
+var
+ p: Pointer;
+begin
+ // Defaults
+ Pointer(TaskDialogIndirect) := @_TaskDialogIndirect;
+ Pointer(TaskDialog) := @_TaskDialog;
+
+ comctl32handle := LoadLibrary(comctl32lib);
+ if comctl32handle <> 0 then
+ begin
+ p := GetProcAddress(comctl32handle, 'TaskDialogIndirect');
+ if p <> nil
+ then Pointer(TaskDialogIndirect) := p;
+
+ p := GetProcAddress(comctl32handle, 'TaskDialog');
+ if p <> nil
+ then Pointer(TaskDialog) := p;
+ end;
+end;
+
+procedure Finalize;
+begin
+ if comctl32handle <> 0 then
+ FreeLibrary(comctl32handle);
+ comctl32handle := 0;
+end;
+
+initialization
+ Initialize;
+Finalization
+ Finalize;
+End.
diff --git a/plugins/mRadio/i_bass.inc b/plugins/mRadio/i_bass.inc new file mode 100644 index 0000000000..77f0d3650a --- /dev/null +++ b/plugins/mRadio/i_bass.inc @@ -0,0 +1,940 @@ +{BASS dll code}
+const
+ signMP3 = $FBFF;
+ signID3 = $00334449;
+ signOGG = $5367674F;
+ OGGHdrSize = 26; // +1=NumSegments
+const
+ BASSName = 'bass.dll';
+ StationHeader:PByte=nil;
+const
+ basspath:PWideChar=nil;
+var
+ hdrlen:integer;
+ syncMETA,
+ syncOGG,
+ syncWMA,
+ syncWMA1,
+ syncEND:HSYNC;
+ SaveHeader:bool;
+
+procedure SetSndVol(arg:integer);
+begin
+ if arg<0 then
+ arg:=gVolume
+ else
+ gVolume:=arg;
+
+ if chan<>0 then
+ begin
+ if arg<0 then arg:=0;
+ BASS_ChannelSetAttribute(chan,BASS_ATTRIB_VOL,arg/100);
+ end;
+end;
+
+procedure BassError(text:PWideChar);
+begin
+ MessageboxW(0,TranslateW(text),TranslateW('Sorry!'),MB_ICONERROR)
+end;
+
+procedure ErrorCustom(text:pWideChar=nil);
+var
+ buf:array [0..255] of WideChar;
+ idx:integer;
+ pcw:pWideChar;
+begin
+ idx:=BASS_ErrorGetCode();
+ if (idx<0) or (idx>BASS_ERROR_MAXNUMBER) then
+ begin
+ if text=nil then
+ pcw:='Unknown error'
+ else
+ pcw:=text;
+ end
+ else
+ pcw:=FastAnsiToWideBuf(BASS_ERRORS[idx],@buf);
+
+ MessageBoxW(0,TranslateW(pcw),
+ TranslateW('Oops! BASS error'),MB_ICONERROR)
+end;
+
+procedure EQ_OFF;
+var
+ i:dword;
+begin
+ if chan<>0 then
+ for i:=0 to 9 do
+ BASS_ChannelRemoveFX(chan,eq[i].fx);
+ isEQ_OFF:=BST_CHECKED;
+end;
+
+procedure EQ_ON;
+var
+ i:dword;
+begin
+ if chan<>0 then
+ begin
+ for i:=0 to 9 do
+ eq[i].fx:=BASS_ChannelSetFX(chan,BASS_FX_DX8_PARAMEQ,1);
+ for i:=0 to 9 do
+ BASS_FXSetParameters(eq[i].fx,@eq[i].param);
+ isEQ_OFF:=BST_UNCHECKED;
+ end;
+end;
+
+function MyLoadBASS(root:PwideChar;custom:pWideChar):bool;
+var
+ pc:PWideChar;
+ buf:array [0..MAX_PATH-1] of WideChar;
+begin
+ result:=true;
+ mGetMem(basspath,1024);
+ pc:=StrCopyEW(basspath,custom);
+ if (pc-1)^<>'\' then
+ begin
+ pc^:='\';
+ inc(pc);
+ end;
+ StrCopyW(pc,BASSName);
+ if not Load_BASSDLL(basspath) then
+ begin
+ pc:=StrCopyW(StrCopyEW(basspath,root),BASSName);
+ if not Load_BASSDLL(basspath) then
+ begin
+ pc:=StrCopyW(StrCopyEW(pc,'plugins\'),BASSName);
+ if not Load_BASSDLL(basspath) then
+ begin
+ pc:=StrCopyW(StrCopyEW(pc,'bass\'),BASSName);
+ if not Load_BASSDLL(basspath) then
+ begin
+ if (custom<>nil) and (custom^<>#0) then
+ BassError('BASS.DLL not found!');
+ result:=false;
+ end;
+ end;
+ end;
+ end;
+
+ if (not result) and ((custom=nil) or (custom^=#0)) then
+ begin
+ if MessageboxA(0,Translate('BASS.DLL not found! Choose BASS.dll path manually'),
+ cPluginName,MB_YESNO)=IDYES then
+ begin
+ pc := nil;
+ if SelectDirectory(TranslateW('Choose BASS.dll path'),pc,0) then
+ begin
+ CallService(MS_UTILS_PATHTORELATIVEW,wparam(pc),lparam(@buf));
+ pc:=StrCopyEW(basspath,buf);
+ if (pc-1)^<>'\' then
+ begin
+ pc^:='\';
+ inc(pc);
+ end;
+ pc^:=#0;
+ DBWriteUnicode(0,PluginName,optBASSPath,basspath);
+ StrCopyW(pc,BASSName);
+
+ if not Load_BASSDLL(basspath) then
+ BassError('BASS.DLL not found!')
+ else
+ result:=true;
+ end;
+
+ end;
+ end;
+
+ if result then
+ begin
+ if (BASS_GetVersion shr 16)<BASSVERSION then
+ begin
+ Unload_BASSDLL;
+ result:=false;
+ BassError('Wrong version of BASS.DLL');
+ end
+ else
+ begin
+ pc^:=#0; // cut BASSName
+ exit;
+ end;
+ end;
+ mFreeMem(basspath);
+end;
+
+procedure MyStopBASS;
+begin
+ if ActiveContact<>0 then
+ begin
+ if syncMETA<>0 then
+ begin
+ BASS_ChannelRemoveSync(chan,syncMETA);
+ syncMETA:=0
+ end;
+ if syncEND<>0 then
+ begin
+ BASS_ChannelRemoveSync(chan,syncEND);
+ syncEND:=0
+ end;
+ if syncWMA<>0 then
+ begin
+ BASS_ChannelRemoveSync(chan,syncWMA);
+ syncWMA:=0
+ end;
+ if syncOGG<>0 then
+ begin
+ BASS_ChannelRemoveSync(chan,syncOGG);
+ syncOGG:=0
+ end;
+ if syncWMA1<>0 then
+ begin
+ BASS_ChannelRemoveSync(chan,syncWMA1);
+ syncWMA1:=0
+ end;
+ end;
+end;
+
+procedure MyFreeBASS;
+begin
+ MyStopBASS;
+ BASS_Free;
+ BASS_PluginFree(0);
+end;
+
+procedure StopStation;
+begin
+ if chan<>0 then
+ BASS_StreamFree(chan); // close old stream
+ chan:=0;
+ mFreeMem(StationHeader);
+ mFreeMem(ActiveURLw);
+ DBDeleteSetting(ActiveContact,strCList,optStatusMsg);
+ MyStopBASS;
+end;
+
+function MyInitBASS:int;
+var
+ fd:TWin32FindDataW;
+ fh:THANDLE;
+ buf:array [0..MAX_PATH-1] of WideChar;
+// buf1:array [0..31] of WideChar;
+ pc:PWideChar;
+ p:Bool;
+begin
+ if Inited then
+ begin
+ result:=1;
+ exit;
+ end;
+
+ Inited:=true;
+ BASS_Free;
+ p:=BASS_Init(-1,44100,BASS_DEVICE_3D,0,nil);
+ if not p then
+ p:=BASS_Init(-1,44100,0,0,nil);
+ if not p then
+ p:=BASS_Init(1,44100,0,0,nil);
+ if not p then
+ begin
+ ErrorCustom('Can''t initialize device');
+ result:=0;
+ end
+ else
+ begin
+ pc:=StrCopyW(StrCopyEW(buf,basspath),'bass*.dll');
+ fh:=FindFirstFileW(buf,fd);
+ if fh<>INVALID_HANDLE_VALUE then
+ begin
+ repeat
+ StrCopyW(pc,fd.cFileName);
+ if BASS_PluginLoad(pAnsiChar(@buf),BASS_UNICODE)=0 then
+ until not FindNextFileW(fh,fd);
+ FindClose(fh);
+ end;
+ // enable ASX processing (if WMA loaded)
+ BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 2); // 2 - enable internet and local playlists
+
+ fh:=DBReadByte(0,PluginName,optEAXType,0);
+ if fh=0 then
+ BASS_SetEAXParameters(-1,0,-1,-1)
+ else
+ BASS_SetEAXPreset(EAXItems[fh].code);
+ result:=1;
+ end;
+end;
+
+function GetMusicFormat:PAnsiChar;
+var
+ bci:BASS_CHANNELINFO;
+begin
+ BASS_ChannelGetInfo(chan,bci);
+ case bci.ctype of
+ BASS_CTYPE_STREAM_OGG: result:='OGG';
+ BASS_CTYPE_STREAM_MP1,
+ BASS_CTYPE_STREAM_MP2,
+ BASS_CTYPE_STREAM_MP3: result:='MP3';
+ BASS_CTYPE_STREAM_WMA,
+ BASS_CTYPE_STREAM_WMA_MP3: result:='WMA';
+ {BASS_CTYPE_STREAM_AAC,}$10b00: result:='AAC';
+ {BASS_CTYPE_STREAM_MP4:}$10b01: result:='MP4';
+ {BASS_CTYPE_STREAM_AC3:}$11000: result:='AC3';
+ else
+ result:=nil;
+ end;
+end;
+
+function GetFileExt(buf:pWideChar;sign:pointer):pWideChar;
+var
+ pc:pAnsiChar;
+begin
+ result:=buf;
+ pc:=GetMusicFormat;
+ if pc=nil then
+ begin
+ StrCopyW(buf,'sav');
+ if sign<>nil then
+ begin
+ if pdword(sign)^=signOGG then
+ StrCopyW(buf,'ogg')
+ else if ((pdword(sign)^ and $00FFFFFF)=signID3) or (pword(sign)^=signMP3) then
+ StrCopyW(buf,'mp3');
+ end;
+ end
+ else
+ begin
+ FastAnsiToWideBuf(pc,buf);
+ LowerCase(buf);
+ end;
+end;
+
+function MakeFileName(sign:pointer):pWideChar;
+var
+ p,pcw:PWideChar;
+ buf:pWideChar;
+begin
+// allocate buffer
+ mGetMem(buf,MAX_PATH*SizeOf(WideChar));
+// path
+ if recpath<>nil then
+ begin
+ ConvertFileName(recpath,buf,ActiveContact);
+// pcw:=ParseVarString(recpath,ActiveContact);
+// CallService(MS_UTILS_PATHTOABSOLUTEW,dword(pcw),dword(buf));
+// mFreeMem(pcw);
+ if not ForceDirectories(buf) then
+ begin
+ result:=nil;
+ exit;
+ end;
+ pcw:=StrEndW(buf);
+ if (pcw-1)^<>'\' then
+ begin
+ pcw^:='\';
+ inc(pcw);
+ end;
+ end
+ else
+ pcw:=buf;
+// name
+//!!
+ p:=MakeMessage;
+ pcw:=StrCopyEW(pcw,p);
+ mFreeMem(p);
+ if (pcw=buf) or ((pcw-1)^='\') then
+ pcw:=StrEndW(IntToHex(pcw,GetCurrentTime));
+// ext
+ pcw^:='.'; inc(pcw);
+ GetFileExt(pcw,sign);
+
+ result:=buf;
+end;
+
+procedure StatusProc(buffer:Pointer;len,user:DWORD); stdcall;
+var
+ pc:pWideChar;
+ pb:PByte;
+ i,sum:integer;
+ flag:bool;
+ doRecord:bool;
+begin
+ flag:=true;
+ doRecord:=CallService(MS_RADIO_COMMAND,MRC_RECORD,LPARAM(-1))<>0;
+ if (buffer<>nil) and (len<>0) and SaveHeader then
+ begin
+ SaveHeader:=false;
+ if pdword(buffer)^=signOGG then // if header ALL in buffer
+ begin
+ pb:=buffer;
+ flag:=false;
+ repeat
+ inc(pb,OGGHdrSize);
+ i:=pb^; //patterns
+ sum:=0;
+ inc(pb);
+ while i>0 do
+ begin
+ inc(sum,pb^);
+ inc(pb);
+ dec(i);
+ end;
+ inc(pb,sum); //here must be next sign
+ flag:=not flag;
+ until not flag;
+ hdrlen:=PAnsiChar(pb)-PAnsiChar(buffer);
+ mGetMem(StationHeader,hdrlen);
+ move(buffer^,StationHeader^,hdrlen);
+ end;
+ end;
+ if (buffer=nil) or not doRecord then // end of stream or stop record
+ begin
+ if not doRecord or (doContRec=BST_UNCHECKED) then
+ if hRecord<>0 then
+ begin
+ if buffer<>nil then // write tail
+ BlockWrite(hRecord,buffer^,len);
+ CloseHandle(hRecord);
+ hRecord:=0;
+ end;
+ end
+ else
+ begin
+ if len=0 then // HTTP or ICY tags
+ begin
+{
+while PAnsiChar(buffer)^<>#0 do
+begin
+messagebox(0,PAnsiChar(buffer),'ICY-HTTP',0);
+while PAnsiChar(buffer)^<>#0 do inc(PAnsiChar(buffer)); inc(PAnsiChar(buffer));
+end;
+}
+ end
+ else
+ begin
+ if doRecord then
+ begin
+ if hRecord=0 then
+ begin
+ pc:=MakeFileName(StationHeader);
+ if pc<>nil then
+ hRecord:=Rewrite(pc)
+ else
+ hRecord:=THANDLE(INVALID_HANDLE_VALUE);
+ if hRecord=THANDLE(INVALID_HANDLE_VALUE) then
+ hRecord:=0
+ else if flag and (StationHeader<>nil) then
+ begin
+ BlockWrite(hRecord,StationHeader^,hdrlen);
+// permissible to skip to the next Page (OggS) but this is not necessary
+ end;
+ mFreeMem(pc);
+ end;
+ if hRecord<>0 then
+ BlockWrite(hRecord,buffer^,len);
+ end;
+ end;
+ end;
+end;
+
+{$IFDEF Debug}
+procedure logmeta(tag,a,b:pansiChar);
+var
+ f:thandle;
+ p:pansichar;
+begin
+ f:=Append(pansichar('mradio.log'));
+ BlockWrite(f,tag^,StrLen(tag));
+ p:=#13#10; BlockWrite(f,p^,StrLen(p));
+ BlockWrite(f,a^,StrLen(a));
+ p:=#13#10; BlockWrite(f,p^,StrLen(p));
+ BlockWrite(f,b^,StrLen(b));
+ p:=#13#10; BlockWrite(f,p^,StrLen(p));
+ p:=#13#10; BlockWrite(f,p^,StrLen(p));
+ CloseHandle(f);
+end;
+{$ENDIF}
+
+function DoMeta(meta:PAnsiChar;TagType:int_ptr):Boolean;
+var
+ pcw:pWideChar;
+ buf:array [0..511] of AnsiChar;
+ artist,title:PAnsiChar;
+ oldartist,oldtitle:pAnsiChar;
+ ppc,pc:pAnsiChar;
+ idx,lcp:integer;
+ needtofree:Boolean;
+ CurDescrW:PWideChar;
+ old:boolean;
+
+// tag:PAnsiChar;
+ gotartist,gottitle:boolean; // indicate what we got artist/title
+begin
+ result:=false;
+
+ if meta=nil then
+ meta:=BASS_ChannelGetTags(chan,TagType);
+ if meta<>nil then
+ begin
+ // for cases when artist or title presents but empty
+ gotartist:=false;
+ gottitle :=false;
+ needtofree:=false;
+ lcp:=CP_UTF8;
+ buf[0]:=#0;
+ artist:=nil;
+ title :=nil;
+ CurDescrW:=nil;
+
+//tag:=meta;
+ case TagType of
+ BASS_TAG_WMA_META: begin
+ pc:=StrPos(meta,'data=');
+ if pc=meta then
+ begin
+ pc:=StrPos(meta,'artist=');
+ if pc<>nil then
+ begin
+ gotartist:=true;
+ mGetMem(artist,256);
+ Decode(artist,pc+7);
+ end;
+
+ pc:=StrPos(meta,'title=');
+ if pc<>nil then
+ begin
+ gottitle:=true;
+ mGetMem(title,256);
+ Decode(title,pc+6);
+ end;
+
+ pc:=StrPos(meta,'album=');
+ if pc<>nil then
+ begin
+ end;
+
+ pc:=StrPos(meta,'duration=');
+ if pc<>nil then
+ begin
+ end;
+
+ if not gotartist then
+ begin
+ if not gottitle then
+ begin
+ pc:=StrPos(meta,'caption=');
+ if pc<>nil then
+ begin
+ gottitle:=true;
+ mGetMem(title,256);
+ Decode(title,pc+8);
+ end;
+ end;
+
+ // analize title/caption for artist-title
+ if gottitle then
+ begin
+ pc:=StrPos(title,' - ');
+ if pc=nil then
+ pc:=StrScan(title,'-');
+ if pc<>nil then
+ begin
+ artist:=title;
+ if pc^=' ' then
+ title:=pc+3
+ else
+ title:=pc+1;
+ pc^:=#0;
+ CurDescrW:=pWideChar(artist);
+ end
+ else
+ CurDescrW:=pWideChar(title);
+ end;
+ end
+ else
+ needtofree:=true;
+
+ // to avoid mem leak and wrong tag process
+ result:=true;
+ end;
+ StatusProc(nil,0,0); // split records here
+ end;
+
+ BASS_TAG_META: begin
+//tag:='SHOUTCAST';
+ // SHOUTCAST StreamTitle='xxx';StreamUrl='xxx';
+ // "Station=xyz" meta tag="Trackinfo"
+ pc:=StrPos(meta,'StreamTitle=');
+ if pc<>nil then
+ begin
+ inc(pc,13);
+ ppc:=StrScan(pc,';');
+ if (ppc-pc-1)>0 then
+ begin
+ StrCopy(buf,pc,ppc-pc-1);
+ lcp:=GetTextFormat(@buf,ppc-pc-1);
+ end;
+ end;
+ if buf[0]<>#0 then
+ begin
+ case lcp of
+ CP_UTF8: UTF8ToWide(buf,CurDescrW);
+ CP_ACP : AnsiToWide(buf,CurDescrW,MirandaCP);
+ end;
+ end;
+
+ gottitle:=true;
+ title:=pAnsiChar(CurDescrW);
+ pcw:=StrPosW(CurDescrW,' - ');
+ if pcw=nil then
+ pcw:=StrScanW(CurDescrW,'-');
+ if pcw<>nil then
+ begin
+ artist:=pAnsiChar(CurDescrW);
+ if pcw^=' ' then
+ title:=pAnsiChar(pcw+3)
+ else
+ title:=pAnsiChar(pcw+1);
+ pcw^:=#0;
+ end;
+
+ lcp:=CP_UNICODE;
+
+ StatusProc(nil,0,0); // split records here
+ result:=true;
+ end;
+
+ BASS_TAG_ID3: begin // not realized, anyway - at the end of track
+ end;
+
+ BASS_TAG_ID3V2: begin
+ end;
+
+ BASS_TAG_APE, // not sure, need to check. maybe better process BASS_TAG_APEBINARY
+ BASS_TAG_WMA,
+ BASS_TAG_OGG: begin
+//tag:='OGG';
+ while meta^<>#0 do
+ begin
+ CharLowerA(StrCopy(buf,meta,10));
+ if StrCmp(buf,'title',5)=0 then
+ begin
+ title:=meta+6;
+ gottitle:=true;
+ end
+ else if StrCmp(buf,'artist',6)=0 then
+ begin
+ artist:=meta+7;
+ gotartist:=true;
+ end;
+ if gotartist and gottitle then
+ break;
+ while meta^<>#0 do inc(meta); inc(meta);
+ end;
+
+ if (not gotartist) and gottitle then
+ begin
+ pc:=StrPos(title,' - ');
+ if pc=nil then
+ pc:=StrScan(title,'-');
+ if pc<>nil then
+ begin
+ needtofree:=true;
+ StrDup(artist,title,pc-title);
+ if pc^=' ' then
+ idx:=3
+ else
+ idx:=1;
+ StrDup(title,pc+idx);
+ end;
+ end;
+ buf[0]:=#0;
+ end;
+ end;
+
+ old:=true;
+ if gotartist or gottitle then
+ begin
+ // check for old
+ oldartist:=nil;
+ oldtitle :=nil;
+ case lcp of
+ CP_UTF8: begin
+ if gotartist then
+ begin
+ oldartist:=DBReadUTF8(0,PluginName,optArtist);
+ if StrCmp(artist,oldartist)<>0 then
+ old:=false;
+ end;
+
+ if old and gottitle then
+ begin
+ oldtitle:=DBReadUTF8(0,PluginName,optTitle);
+ if StrCmp(title,oldtitle)<>0 then
+ old:=false;
+ end;
+
+ if not old then
+ begin
+ DBWriteUTF8(0,PluginName,optArtist,artist);
+ DBWriteUTF8(0,PluginName,optTitle ,title);
+ end;
+ end;
+
+ CP_UNICODE:begin
+ if gotartist then
+ begin
+ oldartist:=pAnsiChar(DBReadUnicode(0,PluginName,optArtist));
+ if StrCmpW(pWideChar(artist),pWideChar(oldartist))<>0 then
+ old:=false;
+ end;
+
+ if old and gottitle then
+ begin
+ oldtitle:=pAnsiChar(DBReadUnicode(0,PluginName,optTitle));
+ if StrCmpW(pWideChar(title),pWideChar(oldtitle))<>0 then
+ old:=false;
+ end;
+
+ if not old then
+ begin
+ DBWriteUnicode(0,PluginName,optArtist,pWideChar(artist));
+ DBWriteUnicode(0,PluginName,optTitle ,pWideChar(title));
+ end;
+ end;
+ end;
+{$IFDEF Debug}
+logmeta(tag,artist,title);
+{$ENDIF}
+ mFreeMem(oldartist);
+ mFreeMem(oldtitle);
+ mFreeMem(CurDescrW);
+ if needtofree then
+ begin
+ mFreeMem(artist);
+ mFreeMem(title );
+ end;
+ end;
+
+ if not old then
+ CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_NEWTAG);
+ end;
+end;
+
+procedure MetaSync(handle:HSYNC;channel,data:dword;user:pointer); stdcall;
+//var tagtype:Integer;
+begin
+(*
+ if handle=syncOGG then tagtype:=BASS_TAG_OGG
+ else if handle=syncWMA then tagtype:=BASS_TAG_WMA
+ else if handle=syncWMA1 then tagtype:=BASS_TAG_WMA_META
+ else {if handle=syncMETA then} tagtype:=BASS_TAG_META;
+*)
+ DoMeta(nil{PAnsiChar(data)},int_ptr(user){tagtype});
+end;
+
+procedure EndSync(handle:HSYNC;channel,data:dword;user:pointer); stdcall;
+var
+ lContact:cardinal;
+begin
+ if RemoteSong then
+ begin
+ lContact:=ActiveContact;
+ CallService(MS_RADIO_COMMAND,MRC_STOP,0);
+ CallService(MS_RADIO_COMMAND,MRC_PLAY,lContact)
+ end
+ else if plist<>nil then CallService(MS_RADIO_COMMAND,MRC_NEXT,0)
+ else if doLoop=BST_UNCHECKED then CallService(MS_RADIO_COMMAND,MRC_STOP,0);
+end;
+
+type
+ tICYField = record
+ name :PAnsiChar;
+ branch:PAnsiChar;
+ option:PAnsiChar;
+ end;
+const
+ NumICYFields = 4;
+ ICYFields: array [0..NumICYFields-1] of tICYField = (
+ (name:'icy-name:' ; branch:'CList' ; option:'MyHandle'),
+ (name:'icy-genre:' ; branch:cPluginName ; option:'Genre'),
+ (name:'icy-br:' ; branch:cPluginName ; option:'Bitrate'),
+ (name:'icy-description'; branch:cPluginName ; option:'About')
+ );
+
+procedure ProcessStationData;
+var
+ icy:PAnsiChar;
+ i,len:integer;
+begin
+ // get the broadcast name and bitrate
+ icy:=BASS_ChannelGetTags(chan,BASS_TAG_ICY);
+ if icy=nil then
+ icy:=BASS_ChannelGetTags(chan,BASS_TAG_HTTP); // no ICY tags, try HTTP
+ if icy<>nil then
+ begin
+ while icy^<>#0 do
+ begin
+ for i:=0 to NumICYFields-1 do
+ begin
+ with ICYFields[i] do
+ begin
+ len:=StrLen(name);
+ if StrCmp(icy,name,len)=0 then
+ begin
+ if DBReadStringLength(ActiveContact,branch,option)=0 then
+ DBWriteString(ActiveContact,branch,option,icy+len);
+ break;
+ end;
+ end;
+ end;
+ while icy^<>#0 do inc(icy); inc(icy);
+ end;
+ end;
+end;
+
+procedure OpenURL(url:PWideChar); cdecl;
+var
+ len,progress:DWORD;
+ flags:dword;
+ i:integer;
+ EAXUsed:bool;
+ ansiurl:array [0..511] of AnsiChar;
+begin
+ if plist=nil then
+ CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_CONNECT);
+
+ EAXUsed:=DBReadByte(0,PluginName,optEAXType,0)<>0;
+
+{}
+ for i:=0 to NumTries-1 do
+ begin
+ if EAXUsed then
+ flags:=BASS_STREAM_STATUS or BASS_SAMPLE_3D or BASS_SAMPLE_MONO
+ else
+ begin
+ if ForcedMono<>BST_UNCHECKED then
+ flags:=BASS_STREAM_STATUS or BASS_SAMPLE_MONO
+ else
+ flags:=BASS_STREAM_STATUS;
+ end;
+
+ flags:=flags or BASS_UNICODE;
+ if RemoteSong then
+ begin
+ SaveHeader:=true;
+ chan:=BASS_StreamCreateURL(url,0,flags,@StatusProc,nil)
+ end
+ else
+ begin
+ if (plist=nil) and (doLoop<>BST_UNCHECKED) then
+ flags:=flags or BASS_SAMPLE_LOOP;
+ chan:=BASS_StreamCreateFile(FALSE,url,0,0,flags);
+ end;
+
+ if (chan=0) and EAXUsed then
+ begin
+ flags:=flags and not (BASS_SAMPLE_3D or BASS_SAMPLE_MONO);
+ if ForcedMono<>BST_UNCHECKED then
+ flags:=flags or BASS_SAMPLE_MONO;
+
+ if RemoteSong then
+ chan:=BASS_StreamCreateURL({ansi}url,0,flags,@StatusProc,nil)
+ else
+ chan:=BASS_StreamCreateFile(FALSE,url,0,0,flags);
+ end;
+
+ if (chan=0) and RemoteSong then
+ begin
+ if BASS_ErrorGetCode=BASS_ERROR_FILEOPEN then
+ begin
+ flags:=flags and not BASS_UNICODE;
+ chan:=BASS_StreamCreateURL(FastWideToAnsiBuf(url,ansiurl),0,flags,@StatusProc,nil)
+ end;
+ end;
+
+ if chan<>0 then break;
+ end;
+{}
+
+ if chan=0 then
+ begin
+ if (CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET)=RD_STATUS_ABORT) or
+ (plist=nil) then
+ begin
+ CallService(MS_RADIO_COMMAND,MRC_STOP,1);
+ end
+ else if plist<>nil then
+ CallService(MS_RADIO_COMMAND,MRC_NEXT,0);
+ end
+ else
+ begin
+
+ CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_NEWTRACK);
+
+ if RemoteSong then
+ begin
+ if isEQ_OFF=BST_UNCHECKED then
+ EQ_ON;
+
+{$IFDEF CHANGE_NAME_BUFFERED}
+ icy:=DBReadString(ActiveContact,strCList,optMyHandle);
+ mGetMem(url,StrLen(icy)+6);
+ StrCopy(url+6,icy);
+ mFreeMem(icy);
+ url[0]:='[';
+ url[1]:=#0;
+ url[4]:=']';
+ url[5]:=' ';
+{$ENDIF}
+ progress:=0;
+ repeat
+ if CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET)=RD_STATUS_ABORT then
+ begin
+ CallService(MS_RADIO_COMMAND,MRC_STOP,1);
+ exit;
+ end;
+ len:=BASS_StreamGetFilePosition(chan,BASS_FILEPOS_END);
+ if len=DW_ERROR then
+ break;
+ progress:=BASS_StreamGetFilePosition(chan, BASS_FILEPOS_DOWNLOAD);
+ if progress=dword(-1) then
+ break;
+ progress:=(progress-
+ BASS_StreamGetFilePosition(chan,BASS_FILEPOS_CURRENT))*100 div len;
+ // percentage of buffer filled
+{$IFDEF CHANGE_NAME_BUFFERED}
+ IntToStr(url+1,progress,2);
+ url[3]:='%';
+ DBWriteString(ActiveContact,strCList,optMyHandle,url);
+{$ENDIF}
+ until progress>sPreBuf;
+{$IFDEF CHANGE_NAME_BUFFERED}
+ if url[1]<>#0 then
+ DBWriteString(ActiveContact,strCList,optMyHandle,url+6);
+ mFreeMem(url);
+{$ENDIF}
+
+ ProcessStationData; // process ICY-headers
+
+ // get the stream title and set sync for subsequent titles
+ DoMeta(nil,BASS_TAG_META);
+
+ syncMETA:=BASS_ChannelSetSync(chan,BASS_SYNC_META ,0,@MetaSync,pointer(BASS_TAG_META));
+ syncOGG :=BASS_ChannelSetSync(chan,BASS_SYNC_OGG_CHANGE,0,@MetaSync,pointer(BASS_TAG_OGG));
+ syncWMA :=BASS_ChannelSetSync(chan,BASS_SYNC_WMA_CHANGE,0,@MetaSync,pointer(BASS_TAG_WMA));
+ syncWMA1:=BASS_ChannelSetSync(chan,BASS_SYNC_WMA_META ,0,@MetaSync,pointer(BASS_TAG_WMA_META));
+ end
+ else
+ begin
+ if not DoMeta(nil,BASS_TAG_OGG) then
+ if not DoMeta(nil,BASS_TAG_ID3V2) then
+ if not DoMeta(nil,BASS_TAG_ID3) then
+ if not DoMeta(nil,BASS_TAG_APE) then
+ ;
+
+ end;
+
+ syncEND:=BASS_ChannelSetSync(chan,BASS_SYNC_END,0,@EndSync,nil);
+
+ SetSndVol(-1);
+ // play it!
+ BASS_ChannelPlay(chan,FALSE);
+ end;
+end;
diff --git a/plugins/mRadio/i_cc.inc b/plugins/mRadio/i_cc.inc new file mode 100644 index 0000000000..deb993ec0c --- /dev/null +++ b/plugins/mRadio/i_cc.inc @@ -0,0 +1,433 @@ +{}
+
+function GetStatusText(status:integer;toCList:boolean=false):PWideChar;
+begin
+ case status of
+ RD_STATUS_PAUSED : result:='paused';
+ RD_STATUS_STOPPED: if toCList then result:=nil else result:='stopped';
+ RD_STATUS_CONNECT: result:='connecting';
+ RD_STATUS_ABORT : result:='aborting';
+ RD_STATUS_PLAYING: if toCList then result:=nil else result:='playing';
+ else
+ result:=nil;
+ end;
+end;
+
+procedure ConstructMsg(artist,title:PWideChar;status:integer=-1);
+var
+ buf:PWideChar;
+ tstrlen,astrlen,statuslen:integer;
+ sstatus:PWideChar;
+ p:pWideChar;
+begin
+ astrlen:=StrLenW(artist);
+
+ tstrlen:=0;
+ // if need to remove duplicate
+ if (title<>nil) and (title^<>#0) then
+ begin
+ if (astrlen=0) or (StrCmpW(artist,title)<>0) then
+ tstrlen:=StrLenW(title);
+ end;
+ if (astrlen>0) and (tstrlen>0) then
+ inc(tstrlen,3);
+
+ statuslen:=0;
+ if status>=0 then
+ begin
+ sstatus:=TranslateW(GetStatusText(status,true));
+ if sstatus<>nil then
+ statuslen:=StrLenW(sstatus)+3;
+ end
+ else
+ sstatus:=nil;
+
+ if (astrlen+tstrlen+statuslen)>0 then
+ begin
+ mGetMem(buf,(astrlen+tstrlen+statuslen+1)*SizeOf(WideChar));
+ p:=buf;
+ if astrlen>0 then
+ p:=StrCopyEW(p,artist);
+
+ if tstrlen>0 then
+ begin
+ if astrlen>0 then
+ begin
+ p^:=' '; inc(p);
+ p^:='-'; inc(p);
+ p^:=' '; inc(p);
+ end;
+ p:=StrCopyEW(p,title);
+ end;
+
+ if statuslen>0 then
+ begin
+ p^:=' '; inc(p);
+ p^:='('; inc(p);
+ p:=StrCopyEW(p,sstatus);
+ p^:=')'; inc(p);
+ p^:=#0;
+ end;
+
+ DBWriteUnicode(ActiveContact,strCList,optStatusMsg,buf);
+ mFreeMem(buf);
+ end
+ else
+ DBDeleteSetting(ActiveContact,strCList,optStatusMsg);
+end;
+
+{$IFDEF Debug}
+procedure log(a,b:lparam);
+var
+ f:thandle;
+ buf:array [0..31] of ansichar;
+ p:pansichar;
+begin
+ f:=Append(pansichar('mradio.log'));
+ p:=IntToStr(buf,a); BlockWrite(f,p^,StrLen(p));
+ p:=#13#10; BlockWrite(f,p^,StrLen(p));
+ p:=IntToStr(buf,b); BlockWrite(f,p^,StrLen(p));
+ p:=#13#10; BlockWrite(f,p^,StrLen(p));
+ p:=#13#10; BlockWrite(f,p^,StrLen(p));
+ CloseHandle(f);
+end;
+{$ENDIF}
+
+function ControlCenter(code:WPARAM;arg:LPARAM):int_ptr; cdecl;
+const
+ PlayStatus:int_ptr=RD_STATUS_NOSTATION;
+ doRecord:boolean=false;
+var
+ tmpbuf,buf1:array [0..MAX_PATH-1] of WideChar;
+ plFile:pWideChar;
+ plLocal:boolean;
+ artist,title:pWideChar;
+begin
+ result:=0;
+{$IFDEF Debug}
+ log(code,arg);
+{$ENDIF}
+ case code of
+ MRC_PLAY : begin
+ // play new station?
+ if arg<>0 then
+ begin
+ ActiveURLw:=DBReadUnicode(arg,PluginName,optStationURL);
+ // no URL for this contact
+ if (ActiveURLw=nil) or (ActiveURLw^=#0) then exit;
+
+ ActiveContact:=arg;
+ RemoteSong:=StrPosW(ActiveURLw,'://')<>nil;
+
+ if isPlaylist(ActiveURLw)<>0 then
+ begin
+
+ if RemoteSong then
+ begin
+ GetTempPathW(MAX_PATH,tmpbuf);
+ GetTempFileNameW(tmpbuf,'mr',GetCurrentTime,buf1);
+ if not GetFile(ActiveURLw,buf1,hNetLib) then
+ begin
+ exit;
+ end;
+ plFile:=@buf1;
+ plLocal:=false;
+ end
+ else
+ begin
+ plFile:=ActiveURLw;
+ plLocal:=true;
+ end;
+
+ plist:=CreatePlaylist(plFile);
+ if not plLocal then
+ DeleteFileW(plFile);
+
+ if plist<>nil then
+ begin
+ if plist.GetCount=0 then
+ begin
+ plist.Free;
+ plist:=nil;
+ ActiveContact:=0;
+ exit;
+ end;
+ plist.Shuffle:=doShuffle<>BST_UNCHECKED;
+
+ if not plist.Shuffle then
+ begin
+ if PlayFirst=BST_UNCHECKED then
+ plist.Track:=DBReadWord(ActiveContact,PluginName,optCurElement);
+ end;
+
+ mFreeMem(ActiveURLw);
+ ActiveURLw:=plist.GetSong;
+ end;
+ RemoteSong:=StrPosW(ActiveURLw,'://')<>nil; // coz activeuRLw can be changed
+ end
+ else
+ plist:=nil;
+
+ if (ActiveURLw<>nil) and (ActiveURLw^<>#0) then
+ begin
+ if RemoteSong then
+ begin
+ if GetWorkOfflineStatus<>0 then
+ begin
+ BassError('Can''t connect to net. Please, clear ''Work offline'' option in Internet settings');
+ ControlCenter(MRC_STATUS,RD_STATUS_NOSTATION);
+ exit;
+ end;
+ end;
+ ControlCenter(MRC_STATUS,RD_STATUS_NEWSTATION);
+ if Assigned(plist) then
+ ControlCenter(MRC_STATUS,RD_STATUS_CONNECT);
+ CloseHandle(mir_forkthread(@OpenURL,ActiveURLw));
+ end;
+ end
+ // play current from start
+ else if chan<>0 then
+ begin
+ BASS_ChannelPlay(chan,true);
+ code:=MRC_STATUS;
+ arg :=RD_STATUS_PLAYING;
+ end
+ // play playlist entry?
+ else if Assigned(plist) and (ActiveURLw<>nil) and (ActiveURLw^<>#0) then
+ begin
+ CloseHandle(mir_forkthread(@OpenURL,ActiveURLw));
+ end;
+ end;
+
+ MRC_RECORD: begin
+ if arg=LPARAM(-1) then
+ result:=ord(doRecord)
+ else
+ begin
+ case arg of
+ 1: doRecord:=true; // force start
+ 2: doRecord:=false; // force stop
+ else
+ doRecord:=not doRecord;
+ end;
+ result:=ord(doRecord);
+
+ code:=MRC_STATUS;
+ arg :=RD_STATUS_RECORD+(result shl 16);
+ end;
+ end;
+
+ MRC_PAUSE: begin
+ if chan<>0 then
+ begin
+ case ControlCenter(MRC_STATUS,RD_STATUS_GET) of
+ RD_STATUS_PLAYING: begin
+ BASS_ChannelPause(chan);
+ arg:=1;
+ end;
+ RD_STATUS_PAUSED: begin
+ BASS_ChannelPlay(chan,false);
+ arg:=0;
+ end;
+ end;
+ code:=MRC_STATUS;
+ arg :=RD_STATUS_PAUSED+(arg shl 16);
+ end
+ else
+ begin
+ ActiveContact:=LoadContact(PluginName,optLastStn);
+ if ActiveContact<>0 then
+ ControlCenter(MRC_PLAY,ActiveContact);
+ end;
+ end;
+
+ MRC_STOP: begin
+ ControlCenter(MRC_RECORD,2);
+
+ code:=MRC_STATUS;
+ // stop playlist track but not station
+ if Assigned(plist) and (arg=0) then
+ begin
+ if chan<>0 then
+ BASS_ChannelStop(chan);
+
+ arg:=RD_STATUS_STOPPED;
+ end
+ else // forced or "normal" stop
+ begin
+ if Assigned(plist) then
+ begin
+ DBWriteWord(ActiveContact,PluginName,optCurElement,plist.Track);
+ plist.Free;
+ plist:=nil;
+ end;
+ ControlCenter(MRC_STATUS,RD_STATUS_STOPPED);
+ // Save station for next autoplay
+ SaveContact(ActiveContact,PluginName,optLastStn);
+ StopStation;
+
+ arg:=RD_STATUS_NOSTATION;
+ end;
+ end;
+
+ MRC_MUTE: begin
+ CallService(MS_RADIO_MUTE,0,arg);
+ code:=MRC_STATUS;
+ arg :=RD_STATUS_MUTED;
+ end;
+
+ MRC_NEXT: begin
+ if Assigned(plist) then
+ begin
+ StopStation;
+ ActiveURLw:=plist.Next;
+ ControlCenter(MRC_PLAY,0);
+ end;
+ end;
+
+ MRC_PREV: begin
+ if Assigned(plist) then
+ begin
+ StopStation;
+ ActiveURLw:=plist.Previous;
+ ControlCenter(MRC_PLAY,0)
+ end;
+ end;
+
+ MRC_SEEK: begin
+ if not RemoteSong and (chan<>0) then
+ begin
+ if integer(arg)=-1 then // get position
+ begin
+ result:=trunc(BASS_ChannelBytes2Seconds(chan,BASS_ChannelGetPosition(chan,BASS_POS_BYTE)));
+ if result<0 then
+ result:=0;
+ end
+ else
+ begin
+ BASS_ChannelSetPosition(chan,BASS_ChannelSeconds2Bytes(chan,arg),BASS_POS_BYTE);
+
+ code:=MRC_STATUS;
+ arg :=RD_STATUS_POSITION+(arg shl 16);
+ end;
+ end;
+ end;
+ end;
+
+ if code=MRC_STATUS then
+ begin
+ if arg=RD_STATUS_GET then
+ result:=PlayStatus
+ else
+ begin
+
+ code:=(arg and $FFFF);
+ arg :=hiword(arg);
+ // this is just events
+ case code of
+ RD_STATUS_MUTED: begin
+ end;
+
+ RD_STATUS_RECORD: begin
+ end;
+
+ RD_STATUS_POSITION: begin
+ end;
+
+ else
+ // these statuses are for events and some tasks
+ artist:=nil;
+ title :=nil;
+ case code of
+ RD_STATUS_NOSTATION: begin
+ SetStatus(ActiveContact,ID_STATUS_OFFLINE);
+ ActiveContact:=0;
+
+ DBDeleteSetting(0,PluginName,optActiveURL);
+
+ PlayStatus:=RD_STATUS_NOSTATION;
+ // empty message
+ end;
+
+ RD_STATUS_STOPPED: begin
+ if ActiveContact<>0 then //!! fools proof
+ DBDeleteSetting(ActiveContact,strCList,optStatusMsg);
+
+ DBDeleteSetting(0,PluginName,optTitle);
+ DBDeleteSetting(0,PluginName,optArtist);
+
+ PlayStatus:=RD_STATUS_STOPPED;
+ // empty message
+ end;
+
+ RD_STATUS_ABORT: begin
+ PlayStatus:=RD_STATUS_ABORT;
+ // status as message
+ end;
+
+ RD_STATUS_CONNECT: begin
+ SetStatus(ActiveContact,ID_STATUS_AWAY);
+ PlayStatus:=RD_STATUS_CONNECT;
+ // status as message
+ end;
+
+ RD_STATUS_NEWSTATION: begin
+ arg:=ActiveContact;
+ PlayStatus:=RD_STATUS_PLAYING;
+ end;
+
+ RD_STATUS_NEWTRACK: begin
+ SetStatus(ActiveContact,ID_STATUS_ONLINE);
+ DBWriteUnicode(0,PluginName,optActiveURL,ActiveURLw);
+
+ DBWriteString(0,PluginName,optActiveCodec,GetMusicFormat);
+ arg :=lparam(ActiveURLw);
+
+ // for case when tags was in meta
+ artist:=DBReadUnicode(0,PluginName,optArtist);
+ title :=DBReadUnicode(0,PluginName,optTitle);
+ PlayStatus:=RD_STATUS_PLAYING;
+ // status as message
+ end;
+
+ RD_STATUS_NEWTAG: begin
+ // must be updated tags
+ artist:=DBReadUnicode(0,PluginName,optArtist);
+ title :=DBReadUnicode(0,PluginName,optTitle);
+
+ PlayStatus:=RD_STATUS_PLAYING; // maybe keep RD_STATUS_NEWTAG?
+ end;
+
+ RD_STATUS_PLAYING: begin
+ SetStatus(ActiveContact,ID_STATUS_ONLINE);
+ PlayStatus:=RD_STATUS_PLAYING;
+ // status as message
+ end;
+
+ RD_STATUS_PAUSED: begin
+ if arg=0 then
+ begin
+ PlayStatus:=RD_STATUS_PLAYING;
+ if StrPosW(ActiveURLw,'://')=nil then //local only
+ begin
+ artist:=DBReadUnicode(0,PluginName,optArtist);
+ title :=DBReadUnicode(0,PluginName,optTitle);
+ end;
+ end
+ else
+ PlayStatus:=RD_STATUS_PAUSED;
+ // status as message
+ end;
+ else
+ exit;
+ end;
+ ConstructMsg(artist,title,PlayStatus);
+ mFreeMem(artist);
+ mFreeMem(title);
+ end;
+
+ NotifyEventHooks(hhRadioStatus,code,arg);
+ end;
+
+ end;
+end;
diff --git a/plugins/mRadio/i_frameapi.inc b/plugins/mRadio/i_frameapi.inc new file mode 100644 index 0000000000..baca5d885f --- /dev/null +++ b/plugins/mRadio/i_frameapi.inc @@ -0,0 +1,238 @@ +{mRadio frame}
+const
+ frm_back:pAnsiChar = 'Frame background';
+const
+ FrameWnd:HWND = 0;
+ FrameId:integer = -1;
+var
+ colorhook:THANDLE;
+ hbr:HBRUSH;
+ frm_bkg:TCOLORREF;
+ OldSliderWndProc:pointer;
+
+function QSDlgResizer(Dialog:HWND;lParam:LPARAM;urc:PUTILRESIZECONTROL):int; cdecl;
+begin
+ case urc^.wId of
+ IDC_RADIO_MUTE: result:=RD_ANCHORX_RIGHT or RD_ANCHORY_CENTRE;
+ IDC_RADIO_VOL : result:=RD_ANCHORX_WIDTH or RD_ANCHORY_CENTRE;
+ else
+ result:=0;
+ end;
+end;
+
+function SliderWndProc(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
+begin
+ if hMessage=WM_ERASEBKGND then
+ result:=1
+ else
+ result:=CallWindowProc(OldSliderWndProc, Dialog, hMessage, wParam, lParam);
+end;
+
+function RadioFrameProc(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
+var
+ urd:TUTILRESIZEDIALOG;
+ rc:TRECT;
+ ti:TTOOLINFOW;
+ hwndTooltip:HWND;
+ tmp:pAnsiChar;
+begin
+ result:=0;
+ case hMessage of
+ WM_DESTROY: begin
+ hVolFrmCtrl :=0;
+ hMuteFrmCtrl:=0;
+ DeleteObject(hbr);
+ end;
+
+ WM_INITDIALOG: begin
+ hMuteFrmCtrl:=GetDlgItem(Dialog,IDC_RADIO_MUTE);
+ SendMessage(hMuteFrmCtrl, BUTTONSETASFLATBTN,0,0);
+ SetButtonIcon(hMuteFrmCtrl,IcoBtnOn);
+
+ hwndTooltip:=CreateWindowW(TOOLTIPS_CLASS,nil,TTS_ALWAYSTIP,
+ integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
+ integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
+ Dialog,0,hInstance,nil);
+
+ FillChar(ti,SizeOf(ti),0);
+ ti.cbSize :=sizeof(TOOLINFO);
+ ti.uFlags :=TTF_IDISHWND or TTF_SUBCLASS;
+ ti.hwnd :=Dialog;
+ ti.hinst :=hInstance;
+ ti.uId :=hMuteFrmCtrl;
+ ti.lpszText:=pWideChar(TranslateW('Mute'));
+ SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti));
+
+ hVolFrmCtrl:=GetDlgItem(Dialog,IDC_RADIO_VOL);
+ SendMessage(hVolFrmCtrl,TBM_SETRANGE,0,MAKELONG(0,100));
+ SendMessage(hVolFrmCtrl,TBM_SETPAGESIZE,0,20);
+ SendMessage(hVolFrmCtrl,TBM_SETPOS,1,gVolume);
+
+ OldSliderWndProc:=pointer(SetWindowLongPtrW(hVolFrmCtrl,GWL_WNDPROC,LONG_PTR(@SliderWndProc)));
+ end;
+
+ WM_SIZE: begin
+ FillChar(urd,SizeOf(TUTILRESIZEDIALOG),0);
+ urd.cbSize :=SizeOf(urd);
+ urd.hwndDlg :=Dialog;
+ urd.hInstance :=hInstance;
+ urd.lpTemplate:=MAKEINTRESOURCEA(IDD_FRAME);
+ urd.lParam :=0;
+ urd.pfnResizer:=@QSDlgResizer;
+ CallService(MS_UTILS_RESIZEDIALOG,0,tlparam(@urd));
+ end;
+
+ WM_ERASEBKGND: begin
+ GetClientRect(Dialog,rc);
+ FillRect(wParam,rc,hbr);
+ result:=1;
+ end;
+
+ WM_DRAWITEM: begin
+ if wParam=IDC_RADIO_MUTE then
+ begin
+ result:=1;
+ if gVolume<0 then
+ tmp:=IcoBtnOff
+ else
+ tmp:=IcoBtnOn;
+ DrawIconEx(PDRAWITEMSTRUCT(lParam)^.hDC,0,0,
+ CallService(MS_SKIN2_GETICON,0,TLPARAM(tmp)),
+ 16,16,0,hbr,DI_NORMAL);
+ end;
+ end;
+
+ WM_CTLCOLORBTN: begin
+ if THANDLE(lParam)=hMuteFrmCtrl then
+ begin
+ SetBkColor(wParam, frm_bkg);
+ result:=hbr;
+ end;
+ end;
+
+ WM_CTLCOLORSTATIC: begin
+ if THANDLE(lParam)=hVolFrmCtrl then
+ begin
+ SetBkColor(wParam, frm_bkg);
+ result:=hbr;
+ end;
+ end;
+
+ WM_CONTEXTMENU: begin
+ CallService(cPluginName + '/Settings',0,0);
+ end;
+
+ WM_COMMAND: begin
+ case wParam shr 16 of
+
+ BN_CLICKED: begin
+ case loword(wParam) of
+ IDC_RADIO_MUTE: begin
+ Service_RadioMute(0,1);
+ end;
+ end;
+ end;
+ end;
+ end;
+
+ WM_HSCROLL: begin
+// gVolume:=SendMessage(lParam,TBM_GETPOS,0,0);
+ Service_RadioSetVolume(SendMessage(lParam,TBM_GETPOS,0,0){gVolume},2)
+ end;
+
+ else
+ result:=DefWindowProc(Dialog,hMessage,wParam,lParam);
+ end;
+end;
+
+function ColorReload(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ cid:TColourID;
+ wnd:HWND;
+begin
+ result:=0;
+ cid.cbSize:=SizeOf(cid);
+ StrCopy(cid.group,cPluginName);
+ StrCopy(cid.name ,frm_back);
+ frm_bkg:=CallService(MS_COLOUR_GETA,twparam(@cid),0);
+ if hbr<>0 then DeleteObject(hbr);
+ hbr:=CreateSolidBrush(frm_bkg);
+
+ wnd:=GetFocus();
+ InvalidateRect(hVolFrmCtrl,nil,true);
+ SetFocus(hVolFrmCtrl);
+ RedrawWindow(FrameWnd,nil,0,RDW_INVALIDATE or RDW_ALLCHILDREN or RDW_ERASE);
+ SetFocus(wnd);
+end;
+
+procedure CreateFrame(parent:HWND);
+var
+ Frame:TCLISTFrame;
+ wnd:HWND;
+ tmp:cardinal;
+ tr:TRECT;
+ cid:TColourID;
+begin
+ if ServiceExists(MS_CLIST_FRAMES_ADDFRAME)=0 then
+ exit;
+ if parent=0 then
+ parent:=CallService(MS_CLUI_GETHWND,0,0);
+
+ if FrameWnd=0 then
+ FrameWnd:=CreateDialog(hInstance,MAKEINTRESOURCE(IDD_FRAME),parent,@RadioFrameProc);
+
+ if FrameWnd<>0 then
+ begin
+ GetWindowRect(FrameWnd,tr);
+ FillChar(Frame,SizeOf(Frame),0);
+ with Frame do
+ begin
+ cbSize :=SizeOf(Frame);
+ hWnd :=FrameWnd;
+ hIcon :=0;
+ align :=alTop;
+ height :=tr.bottom-tr.top+2;
+ Flags :=F_VISIBLE or F_NOBORDER or F_UNICODE;
+ name.w :=cPluginName;
+ TBName.w:=cPluginName + ' volume control';
+ end;
+
+ FrameId:=CallService(MS_CLIST_FRAMES_ADDFRAME,wparam(@Frame),0);
+ if FrameId>=0 then
+ begin
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME,FrameId, FU_FMPOS);
+
+ wnd:=CallService(MS_CLUI_GETHWND{MS_CLUI_GETHWNDTREE},0,0);
+ tmp:=SendMessage(wnd,CLM_GETEXSTYLE,0,0);
+ SendMessage(wnd,CLM_SETEXSTYLE,tmp or CLS_EX_SHOWSELALWAYS,0);
+
+ cid.cbSize:=SizeOf(cid);
+ cid.flags :=0;
+ StrCopy(cid.group,cPluginName);
+ StrCopy(cid.dbSettingsGroup,cPluginName);
+
+ StrCopy(cid.name ,frm_back);
+ StrCopy(cid.setting,'frame_back');
+ cid.defcolour:=COLOR_3DFACE;
+ cid.order :=0;
+ ColourRegister(@cid);
+
+ hbr:=0;
+ colorhook:=HookEvent(ME_COLOUR_RELOAD,@ColorReload);
+ ColorReload(0,0);
+ Service_RadioSetVolume(gVolume,0);
+ end;
+ end;
+end;
+
+procedure DestroyFrame;
+begin
+ if FrameId>=0 then
+ begin
+ UnhookEvent(colorhook);
+ CallService(MS_CLIST_FRAMES_REMOVEFRAME,FrameId,0);
+ FrameId:=-1;
+ end;
+ DestroyWindow(FrameWnd);
+ FrameWnd:=0;
+end;
diff --git a/plugins/mRadio/i_hotkey.inc b/plugins/mRadio/i_hotkey.inc new file mode 100644 index 0000000000..04271fe824 --- /dev/null +++ b/plugins/mRadio/i_hotkey.inc @@ -0,0 +1,61 @@ +{}
+const
+ hRadioHotkey:THANDLE=0;
+const
+ MS_RADIO_HOTKEY:PAnsiChar = 'mRadio/Hotkey';
+
+ HKN_PLAYPAUSE :PAnsiChar = 'mRadio_PlayPause';
+ HKN_STOP :PAnsiChar = 'mRadio_Stop';
+ HKN_MUTE :PAnsiChar = 'mRadio_Mute';
+
+ DefRadioKeyMute = ((HOTKEYF_EXT or HOTKEYF_SHIFT) shl 8) or ORD('M');
+ DefRadioKeyPlay = ((HOTKEYF_EXT or HOTKEYF_SHIFT) shl 8) or ORD('P');
+ DefRadioKeyStop = ((HOTKEYF_EXT or HOTKEYF_SHIFT) shl 8) or ORD('S');
+
+function mRadio_Hotkey(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl;
+begin
+ if lParam=MRC_MUTE then
+ result:=Service_RadioMute(0,0)
+ else
+ result:=CallService(MS_RADIO_COMMAND,lParam,0);
+end;
+
+procedure RegisterHotKey;
+var
+ hkrec:HOTKEYDESC;
+begin
+ hRadioHotkey:=CreateServiceFunction(MS_RADIO_HOTKEY,@mRadio_Hotkey);
+
+ FillChar(hkrec,SizeOf(hkrec),0);
+
+ hkrec.cbSize :=HOTKEYDESC_SIZE_V1;
+ hkrec.pszSection.a :=PluginName;
+ hkrec.pszService :=MS_RADIO_HOTKEY;
+
+ hkrec.DefHotKey :=DefRadioKeyPlay;
+ hkrec.pszName :=HKN_PLAYPAUSE;
+ hkrec.pszDescription.a:='Play/Pause';
+ hkrec.lParam :=MRC_PAUSE;
+ CallService(MS_HOTKEY_REGISTER,0,lparam(@hkrec));
+
+ hkrec.DefHotKey :=DefRadioKeyStop;
+ hkrec.pszName :=HKN_STOP;
+ hkrec.pszDescription.a:='Stop';
+ hkrec.lParam :=MRC_STOP;
+ CallService(MS_HOTKEY_REGISTER,0,lparam(@hkrec));
+
+ hkrec.DefHotKey :=DefRadioKeyMute;
+ hkrec.pszName :=HKN_MUTE;
+ hkrec.pszDescription.a:='Mute';
+ hkrec.lParam :=MRC_MUTE;
+ CallService(MS_HOTKEY_REGISTER,0,lparam(@hkrec));
+end;
+
+procedure UnregisterHotKey;
+begin
+ CallService(MS_HOTKEY_UNREGISTER,0,lparam(HKN_PLAYPAUSE));
+ CallService(MS_HOTKEY_UNREGISTER,0,lparam(HKN_STOP));
+ CallService(MS_HOTKEY_UNREGISTER,0,lparam(HKN_MUTE));
+
+ DestroyServiceFunction(hRadioHotkey);
+end;
diff --git a/plugins/mRadio/i_myservice.inc b/plugins/mRadio/i_myservice.inc new file mode 100644 index 0000000000..e4e76ba10f --- /dev/null +++ b/plugins/mRadio/i_myservice.inc @@ -0,0 +1,148 @@ +{My services}
+
+function Service_RadioPlayStop(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ p:PAnsiChar;
+ lnew:bool;
+ hContact:THANDLE;
+ cni:TCONTACTINFO;
+ i:integer;
+begin
+ result:=0;
+ if lParam=0 then
+ begin
+ if wParam=0 then
+ wParam:=GetCListSelContact;
+ p:=GetContactProtoAcc(wParam);
+ if (p=nil) or (StrCmp(p,PluginName)<>0) then
+ exit;
+ hContact:=wParam;
+ end
+ // wParam = station name
+ else
+ begin
+ FillChar(cni,SizeOf(cni),0);
+ cni.cbSize :=sizeof(cni);
+ if lParam=1 then
+ cni.dwFlag:=CNF_DISPLAY
+ else
+ cni.dwFlag:=CNF_DISPLAY or CNF_UNICODE;
+ cni.szProto :=PluginName;
+
+ hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ while hContact<>0 do
+ begin
+ p:=PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,hContact,0));
+ if (p<>nil) and (StrCmp(p,PluginName)=0) then
+ begin
+ cni.hContact:=hContact;
+ if CallService(MS_CONTACT_GETCONTACTINFO,0,tlparam(@cni))=0 then
+ begin
+ if lParam=1 then
+ i:=StrCmp(pAnsiChar(wParam),cni.retval.szVal.a)
+ else
+ i:=StrCmpW(pWideChar(wParam),cni.retval.szVal.w);
+ mir_free(cni.retval.szVal.w);
+ if i=0 then
+ break;
+ end;
+ end;
+ hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0);
+ end;
+ end;
+
+ if hContact<>0 then
+ begin
+ result:=1;
+ if PluginStatus=ID_STATUS_OFFLINE then
+ Service_SetStatus(ID_STATUS_ONLINE,0);
+
+ case CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET) of
+ RD_STATUS_CONNECT: begin //break while connect
+ CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_ABORT);
+ exit;
+ end;
+ RD_STATUS_ABORT: exit;
+ end;
+
+ lnew:=ActiveContact<>hContact;
+
+ if ActiveContact<>0 then
+ CallService(MS_RADIO_COMMAND,MRC_STOP,1);
+
+ if lnew then
+ CallService(MS_RADIO_COMMAND,MRC_PLAY,hContact);
+ end;
+end;
+
+function Service_RadioSettings(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ ood:TOPENOPTIONSDIALOG;
+begin
+ result:=0;
+ ood.cbSize:=SizeOf(ood);
+ ood.pszGroup:='Network';
+ ood.pszPage :=PluginName;
+ ood.pszTab :=Translate('Advanced');
+ CallService(MS_OPT_OPENOPTIONS,0,tlparam(@ood));
+end;
+
+function Service_RadioRecord(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ if lParam<>0 then lParam:=TLPARAM(-1) else lParam:=0;
+
+ result:=CallService(MS_RADIO_COMMAND,MRC_RECORD,lParam);
+end;
+
+function Service_RadioGetVolume(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ result:=gVolume;
+end;
+
+function Service_RadioSetVolume(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ result:=Service_RadioGetVolume(0,0);
+ SetSndVol(wParam);
+
+ DBWriteByte(0,PluginName,optVolume,ABS(wParam));
+ if lParam<>2 then // not from Frame
+ if hVolFrmCtrl<>0 then
+ SendMessage(hVolFrmCtrl,TBM_SETPOS,1,ABS(wParam));
+
+ if lParam<>1 then // not from Settings
+ if hVolCtrl<>0 then
+ SendMessage(hVolCtrl,TBM_SETPOS,1,ABS(wParam));
+
+end;
+
+function Service_RadioMute(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ if gVolume=0 then
+ gVolume:=-1
+ else
+ gVolume:=-gVolume;
+ Result:=Service_RadioSetVolume(gVolume,0);
+ if hVolFrmCtrl<>0 then
+ EnableWindow(hVolFrmCtrl,gVolume>=0);
+
+end;
+
+function Service_EqOnOff(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ result:=ord(isEQ_OFF=BST_UNCHECKED);
+ case wParam of
+ 0: begin
+ if isEQ_OFF=BST_UNCHECKED then
+ EQ_OFF
+ else
+ EQ_ON;
+ end;
+ 1: EQ_ON;
+ else
+ EQ_OFF;
+ end;
+ if eq[0].wnd<>0 then // if options opened
+ begin
+ CheckDlgButton(GetParent(eq[0].wnd),IDC_EQOFF,isEQ_OFF);
+ end;
+end;
diff --git a/plugins/mRadio/i_optdlg.inc b/plugins/mRadio/i_optdlg.inc new file mode 100644 index 0000000000..e047fe20a1 --- /dev/null +++ b/plugins/mRadio/i_optdlg.inc @@ -0,0 +1,962 @@ +{Options dialog}
+const
+ OldEQPreset:integer=-1;
+const
+ optOldPreset:pAnsiChar='oldpreset';
+ optPresets :pAnsiChar='numpreset';
+ optPreset :pAnsiChar='preset_';
+ optPreDescr :pAnsiChar='predescr_';
+
+const
+ PresetMax = 17;
+
+procedure InitPresets;
+type
+ tP = array [0..9] of AnsiChar;
+begin
+ StrDupW(Presets[00].name,'Acoustic' ); tP(Presets[00].preset):=#$01#$02#$00#$00#$00#$00#$00#$01#$01#$03;
+ StrDupW(Presets[01].name,'Blues' ); tP(Presets[01].preset):=#$01#$02#$01#$00#$00#$00#$00#$00#$00#$FE;
+ StrDupW(Presets[02].name,'Classical'); tP(Presets[02].preset):=#$01#$04#$01#$00#$00#$00#$00#$00#$01#$01;
+ StrDupW(Presets[03].name,'Country' ); tP(Presets[03].preset):=#$00#$00#$01#$01#$00#$00#$01#$01#$01#$01;
+ StrDupW(Presets[04].name,'Dance' ); tP(Presets[04].preset):=#$04#$03#$02#$01#$FF#$FF#$02#$04#$05#$05;
+ StrDupW(Presets[05].name,'Folk' ); tP(Presets[05].preset):=#$FF#$00#$00#$01#$01#$00#$01#$01#$01#$00;
+ StrDupW(Presets[06].name,'Grunge' ); tP(Presets[06].preset):=#$01#$00#$FF#$00#$00#$02#$01#$FF#$FE#$FD;
+ StrDupW(Presets[07].name,'Jazz' ); tP(Presets[07].preset):=#$00#$01#$02#$03#$03#$01#$01#$03#$04#$05;
+ StrDupW(Presets[08].name,'Metall' ); tP(Presets[08].preset):=#$FE#$00#$00#$00#$00#$03#$02#$04#$06#$05;
+ StrDupW(Presets[09].name,'New Age' ); tP(Presets[09].preset):=#$03#$03#$00#$00#$00#$00#$00#$00#$02#$02;
+ StrDupW(Presets[10].name,'Opera' ); tP(Presets[10].preset):=#$00#$01#$02#$04#$01#$02#$00#$00#$00#$00;
+ StrDupW(Presets[11].name,'Rap' ); tP(Presets[11].preset):=#$00#$04#$04#$00#$00#$00#$01#$04#$05#$07;
+ StrDupW(Presets[12].name,'Reggae' ); tP(Presets[12].preset):=#$03#$00#$FD#$00#$05#$00#$02#$03#$04#$05;
+ StrDupW(Presets[13].name,'Rock' ); tP(Presets[13].preset):=#$00#$02#$04#$00#$00#$00#$02#$04#$05#$06;
+ StrDupW(Presets[14].name,'Speech' ); tP(Presets[14].preset):=#$FE#$02#$00#$00#$00#$00#$FF#$FE#$FD#$FC;
+ StrDupW(Presets[15].name,'Swing' ); tP(Presets[15].preset):=#$FF#$00#$00#$02#$02#$00#$02#$02#$03#$03;
+ StrDupW(Presets[16].name,'Techno' ); tP(Presets[16].preset):=#$05#$08#$FF#$FE#$FD#$FF#$04#$06#$06#$06;
+end;
+
+procedure LoadPresets;
+var
+ num,preset,descr:array [0..63] of AnsiChar;
+ i:integer;
+ p,pd:pAnsiChar;
+begin
+ p :=StrCopyE(preset,optPreset);
+ pd:=StrCopyE(descr ,optPreDescr);
+
+ i:=DBReadByte(0,PluginName,optPresets);
+ if i=0 then
+ begin
+ SetLength(Presets,PresetMax);
+ InitPresets;
+ end
+ else
+ begin
+ OldEQPreset:=integer(DBReadByte(0,PluginName,optOldPreset,byte(-1)));
+ SetLength(Presets,i);
+ for i:=0 to HIGH(Presets) do
+ begin
+ StrCopy(p ,IntToStr(num,i)); DBReadStruct (0,PluginName,preset,@Presets[i].preset,10);
+ StrCopy(pd,num); Presets[i].name:=DBReadUnicode(0,PluginName,descr);
+ end;
+ end;
+end;
+
+procedure SavePresets;
+var
+ num,preset,descr:array [0..63] of AnsiChar;
+ i,j:integer;
+ p,pd:pAnsiChar;
+begin
+ p :=StrCopyE(preset,optPreset);
+ pd:=StrCopyE(descr ,optPreDescr);
+ j:=DBReadByte(0,PluginName,optPresets);
+ for i:=0 to HIGH(Presets) do
+ begin
+ StrCopy(p ,IntToStr(num,i)); DBWriteStruct (0,PluginName,preset,@Presets[i].preset,10);
+ StrCopy(pd,num); DBWriteUnicode(0,PluginName,descr ,Presets[i].name);
+ end;
+ while j>Length(Presets) do
+ begin
+ dec(j);
+ StrCopy(p ,IntToStr(num,j)); DBDeleteSetting(0,PluginName,preset);
+ StrCopy(pd,num); DBDeleteSetting(0,PluginName,descr);
+ end;
+ DBWriteByte(0,PluginName,optOldPreset,OldEQPreset);
+ DBWriteByte(0,PluginName,optPresets ,Length(Presets));
+end;
+
+procedure FreePresets;
+var
+ i:integer;
+begin
+ for i:=0 to HIGH(Presets) do
+ mFreeMem(Presets[i].name);
+end;
+
+function ImportOneStation(group:PAnsiChar;section:pointer):int;
+var
+ p:pWideChar;
+ pc:pAnsiChar;
+begin
+ result:=0;
+ pc:=GetParamSectionStr(section,'URL');
+ if pc<>nil then
+ begin
+ result:=CallService(MS_DB_CONTACT_ADD,0,0);
+ if result<>0 then
+ begin
+ CallService(MS_PROTO_ADDTOCONTACT,result,lparam(PluginName));
+ DBWriteString(result,PluginName,optStationURL,pc);
+ DBWriteString(result,PluginName,optFirstName ,pc);
+
+ pc:=GetParamSectionStr(section,optBitrate,'0');
+ DBWriteString(result,PluginName,optBitrate,pc);
+ DBWriteWord (result,PluginName,optAge ,StrToInt(pc));
+
+ pc:=GetParamSectionStr(section,'Name',GetSectionName(section));
+ DBWriteString(result,strCList ,optMyHandle,pc);
+ DBWriteString(result,PluginName,optNick ,pc);
+
+ pc:=GetParamSectionStr(section,optGenre,'unknown');
+ DBWriteString(result,PluginName,optGenre ,pc);
+ DBWriteString(result,PluginName,optLastName,pc);
+
+ SetStatus(result,ID_STATUS_OFFLINE);
+
+ if group=nil then
+ group:=GetParamSectionStr(section,optGroup);
+
+ AnsiToWide(group,p,MirandaCP);
+ CreateGroupW(p,result);
+ mFreeMem(p);
+ CallService(MS_IGNORE_IGNORE,result,IGNOREEVENT_ALL);
+ end;
+ end;
+end;
+
+function ImportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
+var
+ dst:array [0..MAX_PATH-1] of AnsiChar;
+ pc:pAnsiChar;
+ lstorage,section,list:pointer;
+begin
+ result:=0;
+ if lParam<>0 then
+ StrCopy(dst,PAnsiChar(lParam));
+ if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,true) then
+ begin
+ lstorage:=OpenStorage(dst);
+ if lstorage<>nil then
+ begin
+ list:=GetSectionList(lstorage);
+
+ pc:=list;
+ while pc^<>#0 do
+ begin
+ section:=SearchSection(lstorage,pc);
+ if ImportOneStation(pAnsiChar(wParam),section)<>0 then inc(result);
+ while pc^<>#0 do inc(pc);
+ inc(pc);
+ end;
+
+ FreeSectionList(list);
+
+ CloseStorage(lstorage);
+ end;
+ end;
+end;
+
+procedure ExportRadioContact(num:integer;fname:PAnsiChar;hContact:THANDLE);
+var
+ pc:pAnsiChar;
+ section:array [0..15] of AnsiChar;
+begin
+ IntToStr(section,num);
+ pc:=DBReadString(hContact,strCList,optMyHandle);
+ WritePrivateProfileStringA(section,'Name',pc,fname);
+ mFreeMem(pc);
+
+ pc:=DBReadString(hContact,PluginName,optStationURL);
+ WritePrivateProfileStringA(section,'URL',pc,fname);
+ mFreeMem(pc);
+
+ pc:=DBReadString(hContact,PluginName,optGenre);
+ if pc<>nil then
+ begin
+ WritePrivateProfileStringA(section,optGenre,pc,fname);
+ mFreeMem(pc);
+ end;
+
+ pc:=DBReadString(hContact,PluginName,optBitrate);
+ if pc<>nil then
+ begin
+ WritePrivateProfileStringA(section,optBitrate,pc,fname);
+ mFreeMem(pc);
+ end;
+
+ pc:=DBReadString(hContact,strCList,optGroup);
+ if pc<>nil then
+ begin
+ WritePrivateProfileStringA(section,optGroup,pc,fname);
+ mFreeMem(pc);
+ end;
+end;
+
+function ExportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
+var
+ dst:array [0..MAX_PATH-1] of AnsiChar;
+ hContact:THANDLE;
+begin
+ result:=0;
+ if lParam<>0 then
+ StrCopy(dst,PAnsiChar(lParam));
+ if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,false) then
+ begin
+ if (wParam<>0) and (CallService(MS_DB_CONTACT_IS,wParam,0)<>0) then
+ begin
+ result:=1;
+ ExportRadioContact(result,dst,wParam)
+ end
+ else
+ begin
+ hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ while hContact<>0 do
+ begin
+ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,hContact,0)),
+ PluginName)=0 then
+ begin
+ inc(result);
+ ExportRadioContact(result,dst,hContact);
+ end;
+ hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0);
+ end;
+ end;
+ end;
+end;
+
+function MakeFilter(dst,descr,full,filter:PWideChar;show:bool=true):pWideChar;
+var
+ p:PWideChar;
+begin
+ if full<>nil then
+ begin
+ p:=StrEndW(full);
+ p^:=';';
+ StrCopyW(p+1,filter);
+ end;
+
+ dst:=StrCopyEW(dst,TranslateW(descr));
+ if show then
+ begin
+ dst^ :=' ';
+ (dst+1)^:='(';
+ dst:=StrCopyEW(dst+2,filter);
+ dst^:=')';
+ inc(dst);
+ dst^:=#0;
+ end;
+ inc(dst);
+ result:=StrCopyEW(dst,filter)+1;
+end;
+
+function ConstructFilter:pointer;
+var
+ pc:pWideChar;
+ ph:PDWord;
+ Info:PBASS_PLUGININFO;
+ i:integer;
+ full:array [0..511] of WideChar;
+ tmpbuf1,tmpbuf2:array [0..127] of WideChar;
+begin
+ mGetMem(pc,4096);
+// FillChar(pc^,4096,0);
+ result:=pc;
+ full[0]:=#0;
+ pc:=MakeFilter(pc,'All files' ,nil ,'*.*',false);
+ pc:=MakeFilter(pc,'Playlist files',full,'*.pls;*.m3u;*.m3u8;*.asx');
+ pc:=MakeFilter(pc,'BASS built-in' ,full,'*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aif');
+
+ ph:=pointer(BASS_PluginGetInfo(0));
+ if ph<>nil then
+ begin
+ while ph^<>0 do
+ begin
+ Info:=BASS_PluginGetInfo(ph^);
+ for i:=0 to Info^.formatc-1 do
+//!! need to translate Ansi -> wide
+ with Info^.Formats[i] do
+ begin
+ pc:=MakeFilter(pc,FastAnsiToWideBuf(name,tmpbuf1),full,FastAnsiToWideBuf(exts,tmpbuf2));
+ end;
+ inc(ph);
+ end;
+ end;
+ pc:=MakeFilter(pc,'All supported formats',nil,full,false);
+ pc^:=#0;
+end;
+
+procedure SetButtonIcons(Dialog:HWND);
+var
+ ti:TTOOLINFOW;
+ hwndTooltip:HWND;
+begin
+ hwndTooltip:=CreateWindowW(TOOLTIPS_CLASS,nil,TTS_ALWAYSTIP,
+ integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
+ integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
+ Dialog,0,hInstance,nil);
+
+ FillChar(ti,SizeOf(ti),0);
+ ti.cbSize :=sizeof(TOOLINFO);
+ ti.uFlags :=TTF_IDISHWND or TTF_SUBCLASS;
+ ti.hwnd :=Dialog;
+ ti.hinst :=hInstance;
+
+ ti.uId :=GetDlgItem(Dialog,IDC_EQ_ADD);
+ ti.lpszText:=TranslateW('Add');
+
+ SetButtonIcon(ti.uId,IcoBtnAdd);
+
+ SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti));
+
+ ti.uId :=GetDlgItem(Dialog,IDC_EQ_DEL);
+ ti.lpszText:=TranslateW('Delete');
+ SetButtonIcon(ti.uId,IcoBtnDel);
+ SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,lparam(@ti));
+end;
+
+function DlgProcOpt(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
+const
+ DlgInit:integer=1;
+var
+ buf:array [0..MAX_PATH-1] of WideChar;
+ psr:TPROTOSEARCHRESULT;
+ dst:pWideChar;
+ i:dword;
+// info:BASS_CHANNELINFO;
+ vhi:TVARHELPINFO;
+ wnd:HWND;
+ p:pWideChar;
+begin
+ result:=0;
+ case hMessage of
+ WM_DESTROY: begin
+ DBWriteByte(0,PluginName,optLoop ,doLoop);
+ DBWriteByte(0,PluginName,optShuffle ,doShuffle);
+ DBWriteByte(0,PluginName,optContRec ,doContRec);
+ DBWriteByte(0,PluginName,optPlayFirst,PlayFirst);
+ DBWriteByte(0,PluginName,optConnect ,AuConnect);
+ DBWriteByte(0,PluginName,optAutoMute ,AuMute);
+ DBWriteByte(0,PluginName,optOffline ,AsOffline);
+
+ DBWriteUnicode(0,PluginName,optStatusTmpl,StatusTmpl);
+ end;
+
+ WM_INITDIALOG: begin
+ DlgInit:=1;
+ TranslateDialogDefault(Dialog);
+
+ wnd:=GetDlgItem(Dialog,IDC_HLP_VARS);
+ if isVarsInstalled then
+ begin
+ SendMessage(wnd,BM_SETIMAGE,IMAGE_ICON,
+ CallService(MS_VARS_GETSKINITEM,0,VSI_HELPICON));
+ end
+ else
+ ShowWindow(wnd,SW_HIDE);
+
+ if recpath<>nil then
+ p:=recpath
+ else
+ begin
+ buf[0]:=#0;
+ p:=@buf;
+ end;
+ SetDlgItemTextW(Dialog,IDC_ED_RECPATH,p);
+
+ CheckDlgButton(Dialog,IDC_LOOP ,doLoop);
+ CheckDlgButton(Dialog,IDC_SHUFFLE ,doShuffle);
+ CheckDlgButton(Dialog,IDC_CONTREC ,doContRec);
+ CheckDlgButton(Dialog,IDC_PLAYFIRST,PlayFirst);
+ CheckDlgButton(Dialog,IDC_CONNECT ,AuConnect);
+ CheckDlgButton(Dialog,IDC_AUTOMUTE ,AuMute);
+ CheckDlgButton(Dialog,IDC_OFFLINE ,AsOffline);
+
+ SetDlgItemTextW(Dialog,IDC_STATUS,StatusTmpl);
+
+ DlgInit:=0;
+ end;
+
+ WM_COMMAND: begin
+ case wParam shr 16 of
+ EN_CHANGE: begin
+ if DlgInit=0 then
+ case loword(wParam) of
+ IDC_STATION,IDC_STATIONURL,IDC_GENRE,IDC_BITRATE: ;
+ else
+ SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
+ end;
+ end;
+
+ BN_CLICKED: begin
+ case loword(wParam) of
+
+ IDC_IMPORT: begin
+ ImportAll(0,0);
+ end;
+
+ IDC_EXPORT: begin
+ ExportAll(0,0);
+ end;
+
+ IDC_HLP_VARS: begin
+ FillChar(vhi,SizeOf(vhi),0);
+ with vhi do
+ begin
+ cbSize :=SizeOf(vhi);
+ flags :=VHF_FULLDLG or VHF_SETLASTSUBJECT;
+ hwndCtrl :=GetDlgItem(Dialog,IDC_STATUS);
+ szSubjectDesc:='test your variables';
+ end;
+ CallService(MS_VARS_SHOWHELPEX,Dialog,tlparam(@vhi));
+ end;
+
+ IDC_BN_URLPATH: begin
+
+ dst:=ConstructFilter;
+ if ShowDlgW(@buf,nil,dst) then
+ SetDlgItemTextW(Dialog,IDC_STATIONURL,@buf);
+ mFreeMem(dst);
+ end;
+
+ IDC_BN_RECPATH: begin
+ dst:=nil;
+ if SelectDirectory(pWideChar(nil),dst,Dialog) then
+ begin
+ CallService(MS_UTILS_PATHTORELATIVEW,twparam(dst),tlparam(@buf));
+ SetDlgItemTextW(Dialog,IDC_ED_RECPATH,pWideChar(@buf));
+ mFreeMem(dst);
+ end;
+ end;
+
+ IDC_LOOP,IDC_SHUFFLE,IDC_CONTREC,IDC_CONNECT,IDC_OFFLINE,IDC_AUTOMUTE:
+ SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
+
+ IDC_ADD_LIST,IDC_ADD_INI: begin
+ if GetWindowTextLength(GetDlgItem(Dialog,IDC_STATIONURL))>0 then
+ begin
+ FillChar(psr,SizeOf(psr),0);
+ with psr do
+ begin
+ if loword(wParam)=IDC_ADD_LIST then
+ begin
+ GetDlgItemTextW(Dialog,IDC_STATIONURL,@buf,MAX_PATH);
+ StrDupW(firstname.w,@buf);
+ buf[0]:=#0;
+
+ GetDlgItemTextW(Dialog,IDC_STATION,@buf,MAX_PATH);
+ if buf[0]<>#0 then
+ StrDupW(nick.w,@buf)
+ else
+ StrDupW(nick.w,firstname.w);
+ buf[0]:=#0;
+
+ GetDlgItemTextW(Dialog,IDC_GENRE,@buf,MAX_PATH);
+ StrDupW(lastname.w,@buf);
+ buf[0]:=#0;
+
+ GetDlgItemTextW(Dialog,IDC_BITRATE,@buf,MAX_PATH);
+ StrDupW(email.w,@buf);
+
+ i:=Service_AddToList(0,tlparam(@psr));
+{
+ GetDlgItemTextW(Dialog,IDC_STATION,@buf,SizeOf(buf));
+ DBWriteUnicode(i,strCList,optMyHandle,@buf);
+
+ GetDlgItemTextW(Dialog,IDC_STATIONURL,@buf,SizeOf(buf));
+ DBWriteUnicode(i,PluginName,optStationURL,@buf);
+}
+ // "changing" station group
+ dst:=GetNewGroupName(Dialog);
+ if dst<>nil then
+ DBWriteUnicode(i,strCList,optGroup,dst)
+ else
+ DBDeleteSetting(i,strCList,optGroup);
+
+ end
+ else if loword(wParam)=IDC_ADD_INI then
+ begin
+ GetDlgItemTextA(Dialog,IDC_STATIONURL,PAnsiChar(@buf),SizeOf(buf));
+ StrDup(firstname.a,PAnsiChar(@buf));
+ PAnsiChar(@buf)^:=#0;
+
+ GetDlgItemTextA(Dialog,IDC_STATION,PAnsiChar(@buf),SizeOf(buf));
+ if PAnsiChar(@buf)^<>#0 then
+ StrDup(nick.a,@buf)
+ else
+ StrDup(nick.a,firstname.a);
+ PAnsiChar(@buf)^:=#0;
+
+ GetDlgItemTextA(Dialog,IDC_GENRE,PAnsiChar(@buf),SizeOf(buf));
+ StrDup(lastname.a,@buf);
+ PAnsiChar(@buf)^:=#0;
+
+ GetDlgItemTextA(Dialog,IDC_BITRATE,PAnsiChar(@buf),SizeOf(buf));
+ StrDup(email.a,@buf);
+
+ if WritePrivateProfileStringA(firstname.a,'URL',firstname.a,storage) then
+ begin
+ WritePrivateProfileStringA(firstname.a,'Name' ,nick.a ,storage);
+ WritePrivateProfileStringA(firstname.a,optGenre ,lastname.a ,storage);
+ WritePrivateProfileStringA(firstname.a,optBitrate,email.a ,storage);
+ end
+ else
+ begin
+ WritePrivateProfileStringA(firstname.a,'URL' ,firstname.a,storagep);
+ WritePrivateProfileStringA(firstname.a,'Name' ,nick.a ,storagep);
+ WritePrivateProfileStringA(firstname.a,optGenre ,lastname.a ,storagep);
+ WritePrivateProfileStringA(firstname.a,optBitrate,email.a ,storagep);
+ end;
+
+ end;
+ mFreeMem(nick);
+ mFreeMem(firstname);
+ mFreeMem(lastname);
+ mFreeMem(email);
+ end;
+ end;
+ end;
+
+ end;
+ end;
+
+ end;
+ end;
+
+ WM_NOTIFY: begin
+ if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
+ begin
+
+ doShuffle:=IsDlgButtonChecked(Dialog,IDC_SHUFFLE);
+ doContRec:=IsDlgButtonChecked(Dialog,IDC_CONTREC);
+ PlayFirst:=IsDlgButtonChecked(Dialog,IDC_PLAYFIRST);
+ AuConnect:=IsDlgButtonChecked(Dialog,IDC_CONNECT);
+ AuMute :=IsDlgButtonChecked(Dialog,IDC_AUTOMUTE);
+ AsOffline:=IsDlgButtonChecked(Dialog,IDC_OFFLINE);
+
+ mFreeMem(StatusTmpl);
+ StatusTmpl:=GetDlgText(Dialog,IDC_STATUS);
+
+ doLoop:=IsDlgButtonChecked(Dialog,IDC_LOOP);
+ if chan<>0 then
+ begin
+{
+ BASS_ChannelGetInfo(chan,info);
+ if doLoop<>BST_UNCHECKED then
+ info.flags:=info.flags or BASS_SAMPLE_LOOP
+ else
+ info.flags:=info.flags and not BASS_SAMPLE_LOOP;
+}
+ BASS_ChannelFlags(chan,ord(doLoop<>BST_UNCHECKED),BASS_SAMPLE_LOOP);
+ end;
+
+ mFreeMem(recpath);
+ buf[0]:=#0;
+ GetDlgItemTextW(Dialog,IDC_ED_RECPATH,@buf,SizeOf(buf) div SizeOf(WideChar));
+ if buf[0]<>#0 then
+ begin
+ mGetMem(recpath,MAX_PATH*SizeOf(WideChar));
+ recpath^:=#0;
+ CallService(MS_UTILS_PATHTORELATIVEW,twparam(@buf),tlparam(recpath));
+ end;
+ DBWriteUnicode(0,PluginName,optRecPath,recpath);
+ end;
+ end;
+
+// else
+// result:=DefWindowProc(Dialog,hMessage,wParam,lParam);
+ end;
+end;
+
+function DlgProcOptTech(Dialog:HWnd;hMessage:uint;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
+const
+ DlgInit:integer=1;
+var
+ i:integer;
+ hEAXCombo:THANDLE;
+ ltmp:longbool;
+// info:BASS_CHANNELINFO;
+ buf1:array [0..4] of AnsiChar;
+ wnd:HWND;
+ buf:array [0..MAX_PATH-1] of WideChar;
+ dst:pWideChar;
+begin
+ result:=0;
+ case hMessage of
+ WM_DESTROY: begin
+ hVolCtrl:=0;
+
+ buf1[0]:='E';
+ buf1[1]:='Q';
+ buf1[2]:='_';
+ buf1[4]:=#0;
+ for i:=0 to 9 do
+ begin
+ buf1[3]:=AnsiChar(ORD('0')+i);
+ DBWriteByte(0,PluginName,buf1,trunc(eq[i].param.fGain)+15);
+ eq[i].wnd:=0;
+ end;
+ DBWriteByte(0,PluginName,optEQ_OFF ,isEQ_OFF);
+ end;
+
+ WM_INITDIALOG: begin
+ DlgInit:=1;
+ TranslateDialogDefault(Dialog);
+
+ SetButtonIcons(Dialog);
+ hVolCtrl:=GetDlgItem(Dialog,IDC_VOLUME);
+ SendMessage(hVolCtrl,TBM_SETRANGE,0,(100 shl 16)+0);
+ SendMessage(hVolCtrl,TBM_SETPOS,1,ABS(gVolume));
+
+ SetDlgItemInt(Dialog,IDC_BUFFER ,sBuffer ,false);
+ SetDlgItemInt(Dialog,IDC_PREBUF ,sPreBuf ,false);
+ SetDlgItemInt(Dialog,IDC_TIMEOUT,sTimeout,false);
+ SetDlgItemInt(Dialog,IDC_TRIES ,NumTries,false);
+
+ CheckDlgButton(Dialog,IDC_MONO,ForcedMono);
+
+ hEAXCombo:=GetDlgItem(Dialog,IDC_EAXTYPE);
+ for i:=0 to EAX_ENVIRONMENT_COUNT do
+ SendMessageW(hEAXCombo,CB_ADDSTRING,0,tlparam(TranslateW(EAXItems[i].name)));
+ SendMessage(hEAXCombo,CB_SETCURSEL,DBReadByte(0,PluginName,optEAXType,0),0);
+
+ wnd:=GetDlgItem(Dialog,IDC_PRESET);
+ for i:=0 to HIGH(Presets) do
+ SendMessageW(wnd,CB_ADDSTRING,0,tlparam(Presets[i].name));
+ SendMessage(wnd,CB_SETCURSEL,OldEQPreset,0);
+
+ for i:=0 to 9 do
+ begin
+ eq[i].wnd:=GetDlgItem(Dialog,IDC_EQ00+i);
+ SendMessage(eq[i].wnd,TBM_SETRANGE,1,(16 shl 16)-15);
+ SendMessage(eq[i].wnd,TBM_SETTIC,0,0);
+ SendMessage(eq[i].wnd,TBM_SETPOS,1,-trunc(eq[i].param.fGain));
+ SendDlgItemMessageA(Dialog,IDC_0+i,WM_SETTEXT,0,tlparam(eq[i].text));
+ EnableWindow(eq[i].wnd,isEQ_OFF=BST_UNCHECKED);
+ end;
+
+ CheckDlgButton(Dialog,IDC_EQOFF,isEQ_OFF);
+
+ dst:=DBReadUnicode(0,PluginName,optBASSPath,nil);
+ SetDlgItemTextW(Dialog,IDC_BASSPATH,dst);
+ mFreeMem(dst);
+
+ DlgInit:=0;
+ end;
+
+ WM_COMMAND: begin
+ case wParam shr 16 of
+ EN_CHANGE: begin
+ if DlgInit=0 then
+ SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
+ end;
+
+ BN_CLICKED: begin
+ case loword(wParam) of
+
+ IDC_BASSPTHBTN: begin
+ dst:=nil;
+ if SelectDirectory(pWideChar(nil),dst,Dialog) then
+ begin
+ CallService(MS_UTILS_PATHTORELATIVEW,twparam(dst),tlparam(@buf));
+ SetDlgItemTextW(Dialog,IDC_BASSPATH,pWideChar(@buf));
+ mFreeMem(dst);
+ end;
+ end;
+
+ IDC_EQOFF: begin
+ isEQ_OFF:=IsDlgButtonChecked(Dialog,IDC_EQOFF);
+ if isEQ_OFF=BST_UNCHECKED then
+ EQ_ON
+ else
+ EQ_OFF;
+
+ for i:=0 to 9 do
+ EnableWindow(eq[i].wnd,isEQ_OFF=BST_UNCHECKED);
+ end;
+
+ IDC_ZERO: begin
+ OldEQPreset:=-1;
+ for i:=0 to 9 do
+ begin
+ eq[i].param.fGain:=0;
+ SendMessage(eq[i].wnd,TBM_SETPOS,1,0);
+ if (chan<>0) and (isEQ_OFF=BST_UNCHECKED) then
+ BASS_FXSetParameters(eq[i].fx,@eq[i].param);
+ end;
+ end;
+
+ IDC_EQ_ADD: begin
+ SetLength(Presets,Length(Presets)+1);
+
+ for i:=0 to 9 do
+ Presets[HIGH(Presets)].preset[i]:=-SendMessage(eq[i].wnd,TBM_GETPOS,0,0);
+
+ wnd:=GetDlgItem(Dialog,IDC_PRESET);
+ Presets[HIGH(Presets)].name:=GetDlgText(wnd,false);
+ if Presets[HIGH(Presets)].name=nil then
+ StrDupW(Presets[HIGH(Presets)].name,'New');
+ OldEQPreset:=SendMessage(wnd,CB_SETCURSEL,
+ SendMessageW(wnd,CB_ADDSTRING,0,tlparam(Presets[HIGH(Presets)].name)),0);
+ end;
+
+ IDC_EQ_DEL: begin
+ wnd:=GetDlgItem(Dialog,IDC_PRESET);
+ i:=SendMessage(wnd,CB_GETCURSEL,0,0);
+ if (i>=0) and (i<=HIGH(Presets)) then
+ begin
+ SendMessage(wnd,CB_DELETESTRING,i,0);
+ mFreeMem(Presets[i].name);
+ move(Presets[i+1],Presets[i],(HIGH(Presets)-i)*SizeOf(tPreset));
+ SetLength(Presets,Length(Presets)-1);
+ OldEQPreset:=-1;
+ SendMessage(wnd,CB_SETCURSEL,-1,0);
+ end;
+ end;
+
+ end;
+ end;
+
+ CBN_SELCHANGE: begin
+ SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
+ case loword(wParam) of
+ IDC_PRESET: begin
+ OldEQPreset:=SendDlgItemMessage(Dialog,IDC_PRESET,CB_GETCURSEL,0,0);
+ for i:=0 to 9 do
+ begin
+ SendMessage(eq[i].wnd,TBM_SETPOS,1,-Presets[OldEQPreset].preset[i]);
+ eq[i].param.fGain:=Presets[OldEQPreset].preset[i];
+ if (chan<>0) and (isEQ_OFF=BST_UNCHECKED) then
+ BASS_FXSetParameters(eq[i].fx,@eq[i].param);
+ end;
+ end;
+ IDC_EAXTYPE: begin
+{
+ i:=SendDlgItemMessage(Dialog,IDC_EAXTYPE,CB_GETCURSEL,0,0);
+ DBWriteByte(0,PluginName,optEAXType,i);
+ if i=0 then
+ BASS_SetEAXParameters(-1,0,-1,-1)
+ else
+ BASS_SetEAXPreset(EAXItems[i].code);
+}
+ end;
+ end;
+ end;
+ end;
+ end;
+
+ WM_VSCROLL: begin
+ for i:=0 to 9 do
+ begin
+ if HWND(lParam)=eq[i].wnd then
+ begin
+ eq[i].param.fGain:=-SendMessage(lParam,TBM_GETPOS,0,0);
+ if (chan<>0) and (isEQ_OFF=BST_UNCHECKED) then
+ BASS_FXSetParameters(eq[i].fx,@eq[i].param);
+ OldEQPreset:=-1;
+ break;
+ end;
+ end;
+ end;
+
+ WM_HSCROLL: begin
+ Service_RadioSetVolume(SendMessage(lParam,TBM_GETPOS,0,0),1)
+ end;
+
+ WM_NOTIFY: begin
+ if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
+ begin
+ SavePresets;
+
+//!! bass path saving here
+ dst:=GetDlgText(Dialog,IDC_BASSPATH);
+ DBWriteUnicode(0,PluginName,optBASSPath,dst);
+ mFreeMem(dst);
+
+ ForcedMono:=IsDlgButtonChecked(Dialog,IDC_MONO);
+ DBWriteByte(0,PluginName,optForcedMono,ForcedMono);
+
+ i:=SendDlgItemMessage(Dialog,IDC_EAXTYPE,CB_GETCURSEL,0,0);
+ DBWriteByte(0,PluginName,optEAXType,i);
+ if i=0 then
+ BASS_SetEAXParameters(-1,0,-1,-1)
+ else
+ BASS_SetEAXPreset(EAXItems[i].code);
+
+ NumTries:=GetDlgItemInt(Dialog,IDC_TRIES,ltmp,false);
+ if NumTries<1 then NumTries:=1;
+ DBWriteByte(0,PluginName,optNumTries,NumTries);
+
+ i:=GetDlgItemInt(Dialog,IDC_PREBUF,ltmp,false);
+ if i>100 then i:=100;
+ if cardinal(i)<>sPreBuf then
+ begin
+ sPreBuf:=i;
+ BASS_SetConfig(BASS_CONFIG_NET_PREBUF,i);
+ DBWriteWord(0,PluginName,optPreBuf,sPreBuf);
+ end;
+
+ i:=GetDlgItemInt(Dialog,IDC_BUFFER,ltmp,false);
+ if i>20000 then i:=20000;
+ if cardinal(i)<>sBuffer then
+ begin
+ sBuffer:=i;
+ BASS_SetConfig(BASS_CONFIG_NET_BUFFER,i);
+ DBWriteWord(0,PluginName,optBuffer,sBuffer);
+ end;
+
+ i:=GetDlgItemInt(Dialog,IDC_TIMEOUT,ltmp,false);
+ if i>30000 then i:=30000;
+ if cardinal(i)<>sTimeout then
+ begin
+ sTimeout:=i;
+ BASS_SetConfig(BASS_CONFIG_NET_TIMEOUT,i);
+ DBWriteWord(0,PluginName,optTimeout,sTimeout);
+ end;
+
+ end;
+ end;
+
+// else
+// result:=DefWindowProc(Dialog,hMessage,wParam,lParam);
+ end;
+end;
+
+function OnOptInitialise(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ odp:TOPTIONSDIALOGPAGE;
+begin
+ FillChar(odp,SizeOf(odp),0);
+ odp.cbSize :=SizeOf(odp);
+ odp.flags :=ODPF_BOLDGROUPS;
+ odp.Position :=900003000;
+ odp.hInstance :=hInstance;
+ odp.szGroup.a :='Network';
+ odp.szTitle.a :=PluginName;
+
+ odp.pszTemplate:=MAKEINTRESOURCEA(IDD_SETTING);
+ odp.pfnDlgProc :=@DlgProcOpt;
+ odp.szTab.a :='Common';
+ CallService(MS_OPT_ADDPAGE,wParam,tlparam(@odp));
+
+ odp.pszTemplate:=MAKEINTRESOURCEA(IDD_SETTING_TECH);
+ odp.pfnDlgProc :=@DlgProcOptTech;//!!
+ odp.szTab.a :=Translate('Advanced');
+ CallService(MS_OPT_ADDPAGE,wParam,tlparam(@odp));
+
+ result:=0;
+end;
+
+// checking proto in several places for speed, not size economy
+function OnSettingsChanged(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ buf:array [0..MAX_PATH-1] of AnsiChar;
+ i:integer;
+ pc:PAnsiChar;
+begin
+ result:=0;
+
+ with PDBCONTACTWRITESETTING(lParam)^ do
+ begin
+
+ if AuMute<>BST_UNCHECKED then
+ begin
+ if StrCmp(szModule,'Skin')=0 then
+ begin
+ if StrCmp(szSetting,'UseSound')=0 then
+ begin
+ // Mute
+ if value.bVal=0 then
+ begin
+ if gVolume>=0 then
+ Service_RadioMute(0,0);
+ end
+ // Unmute
+ else
+ begin
+ if gVolume<0 then
+ Service_RadioMute(0,0);
+ end;
+ end;
+
+ exit;
+ end
+ end;
+
+ // works only if called AFTER changes
+ if StrCmp(szModule,strCList)=0 then
+ begin
+ if StrCmp(szSetting,optMyHandle)=0 then
+ begin
+ if value._type=DBVT_DELETED then
+ begin
+ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0)),
+ PluginName)<>0 then exit;
+
+ pc:=DBReadString(wParam,PluginName,optNick);
+ DBWriteString(wParam,strCList,optMyHandle,pc);
+ mFreeMem(pc);
+ end;
+ end;
+ exit;
+ end;
+
+ if StrCmp(szModule,'UserInfo')<>0 then exit;
+
+ if StrCmp(szSetting,optAge)=0 then
+ begin
+ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0)),
+ PluginName)<>0 then exit;
+ if value._type=DBVT_DELETED then
+ i:=DBReadWord(wParam,PluginName,optAge)
+ else
+ i:=value.wVal;
+ DBWriteString(wParam,PluginName,optBitrate,IntToStr(buf,i));
+ exit;
+ end;
+
+ case value._type of
+ DBVT_DELETED,
+ DBVT_ASCIIZ ,
+ DBVT_WCHAR ,
+ DBVT_UTF8 :
+ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0)),
+ PluginName)<>0 then exit;
+ else
+ exit;
+ end;
+
+ case value._type of
+ DBVT_DELETED: pc:=DBReadString(wParam,PluginName,szSetting);
+ DBVT_ASCIIZ : pc:=value.szVal.a;
+ DBVT_WCHAR : WideToAnsi(value.szVal.w,pc,MirandaCP);
+ DBVT_UTF8 : UTF8ToAnsi(value.szVal.a,pc,MirandaCP);
+ end;
+
+ if StrCmp(szSetting,optFirstName)=0 then DBWriteString(wParam,PluginName,optStationURL,pc)
+ else if StrCmp(szSetting,optNick )=0 then DBWriteString(wParam,strCList,optMyHandle,pc)
+ else if StrCmp(szSetting,optLastName )=0 then DBWriteString(wParam,PluginName,optGenre,pc);
+
+ if value._type<>DBVT_ASCIIZ then
+ mFreeMem(pc);
+ end;
+end;
+
+function OnContactDeleted(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+begin
+ result:=0;
+ if ActiveContact<>THANDLE(wParam) then exit;
+ ControlCenter(MRC_STOP,wParam);
+
+{ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0)),
+ PluginName)<>0 then exit;
+}
+end;
diff --git a/plugins/mRadio/i_search.inc b/plugins/mRadio/i_search.inc new file mode 100644 index 0000000000..d4330e84d1 --- /dev/null +++ b/plugins/mRadio/i_search.inc @@ -0,0 +1,444 @@ +{search station code}
+(*
+procedure SetAvatar(hContact:THANDLE);
+var
+ success:boolean;
+ fname:pAnsiChar;
+ url:pWideChar;
+ buf,buf1,buf2:array [0..MAX_PATH-1] of AnsiChar;
+ ext:array [0..15] of AnsiChar;
+ section:pAnsiChar;
+ pc:pAnsiChar;
+ i:integer;
+begin
+ // get url
+ url:=DBReadUnicode(hContact,PluginName,optStationURL);
+ // translate to Ansi
+ FastWideToAnsiBuf(url,buf);
+ mFreeMem(url);
+
+ // search in INI
+ i:=GetFSize(storage);
+ if i=0 then
+ i:=32767;
+ mGetMem(pc,i+1);
+ pc^:=#0;
+ GetPrivateProfileSectionNamesA(pc,i,storage);
+ section:=pc;
+
+ while section^<>#0 do
+ begin
+ GetPrivateProfileStringA(section,'URL','',buf1,SizeOf(buf1),storage);
+ if StrCmp(@buf,@buf1)=0 then
+ break;
+
+ while section^<>#0 do inc(section);
+ inc(section);
+ end;
+ mFreeMem(pc);
+
+ if section^<>#0 then
+ begin
+ // get avatar link
+ buf[0]:=#0;
+ GetPrivateProfileStringA(section,'Avatar','',buf,SizeOf(buf),storage);
+
+ if buf[0]<>#0 then
+ begin
+ // Here we trying to get Avatar chache directory
+ // (create it if needs)
+ // and copy (load) owr avatars there
+ // in : buf = source avatar path
+ // out: fname = destination (file name in cache)
+ // rule for name is?..
+
+
+ if StrPos(buf,'://')=nil then
+ begin
+ fname:=@buf;
+ success:=FileExists(fname);
+ // need to copy this file to avatar cache
+ end
+ else
+ begin
+ // download file
+{
+ GetTempPathA(MAX_PATH,pAnsiChar(@buf1));
+ pc:=extract(pAnsiChar(@buf),true);
+ StrCat(pAnsiChar(@buf1),pc);
+ mFreeMem(pc);
+}
+ //mrAvt
+
+ GetExt(pAnsiChar(@buf),pAnsiChar(@ext));
+ GetTempPathA(MAX_PATH,pAnsiChar(@buf2));
+ GetTempFileNameA(pAnsiChar(@buf2),'mrAvt',GetCurrentTime,pAnsiChar(@buf1));
+ ChangeExt(pAnsiChar(@buf1),PAnsiChar(@ext));
+ //
+ fname:=@buf1;
+ success:=GetFile(pAnsiChar(@buf),fname);
+ end;
+
+ if success then
+ CallService(MS_AV_SETAVATAR,hContact,LPARAM(fname));
+ end;
+ end;
+end;
+*)
+type
+ TMySearchFilter = record
+ lStation,
+ lStationURL,
+ lGenre:PAnsiChar;
+ lBitrate:integer;
+ lBitrateMode:integer;
+ end;
+
+const
+ AckHandle = 427;
+
+// Since mRadio is unicode version only now, translate all strings to Wide
+// coz f*cking jinn will set unicode flag in any cases
+procedure LoadOneStation(section:pointer;const filter:TMySearchFilter);
+var
+ bitrate:integer;
+ l:bool;
+ columns:array [0..3] of TCHAR;
+ csr:CUSTOMSEARCHRESULTS;
+ pc:pAnsiChar;
+ buf:array [0..127] of AnsiChar;
+begin
+ pc:=GetParamSectionStr(section,'URL');
+ if pc<>nil then
+ begin
+ if (filter.lStationURL=nil) or (StrPos(CharLowerA(pc),filter.lStationURL)<>nil) then
+ begin
+ FillChar(csr,SizeOf(csr),0);
+ csr.psr.cbSize:=SizeOf(csr.psr);
+ csr.psr.Flags:=PSR_UNICODE;
+ AnsiToWide(pc,csr.psr.firstname.w,MirandaCP);
+ pc:=GetParamSectionStr(section,optBitrate,'0');
+ bitrate:=StrToInt(pc);
+ if (bitrate<>0) and (filter.lBitrate<>0) then
+ begin
+ if filter.lBitrateMode<0 then l:=bitrate<=filter.lBitrate
+ else if filter.lBitrateMode=0 then l:=bitrate =filter.lBitrate
+ else{if filter.lBitrateMode>0} l:=bitrate>=filter.lBitrate;
+ end
+ else
+ l:=true;
+ if l then
+ begin
+ AnsiToWide(pc,csr.psr.email.w,MirandaCP);
+
+ StrCopy(buf,GetParamSectionStr(section,'Name',GetSectionName(section)),127);
+ if (filter.lStation=nil) or (StrPos(CharLowerA(@buf),filter.lStation)<>nil) then
+ begin
+ AnsiToWide(@buf,csr.psr.nick.w,MirandaCP);
+
+ StrCopy(buf,GetParamSectionStr(section,optGenre,'unknown'),127);
+ if (filter.lGenre=nil) or (StrPos(CharLowerA(@buf),filter.lGenre)<>nil) then
+ AnsiToWide(@buf,csr.psr.lastname.w,MirandaCP)
+ else
+ l:=false;
+ end
+ else
+ l:=false;
+ if l then
+ begin
+ columns[0].w:=csr.psr.nick.w; // Station name
+ columns[1].w:=csr.psr.firstname.w; // URL
+ columns[2].w:=csr.psr.lastname.w; // Genre
+ columns[3].w:=csr.psr.email.w; // Bitrate
+
+ csr.nSize :=SizeOf(csr);
+ csr.nFieldCount:=4;
+ csr.szFields :=@columns;
+ ProtoBroadcastAck(PluginName,0,ACKTYPE_SEARCH,ACKRESULT_SEARCHRESULT,AckHandle,lparam(@csr));
+ end;
+ end;
+ // initial value - nil, so we don't worry
+ mFreeMem(csr.psr.nick);
+ mFreeMem(csr.psr.firstname);
+ mFreeMem(csr.psr.lastname);
+ mFreeMem(csr.psr.email);
+ end;
+ end;
+end;
+
+procedure ProcessSearch(var filter:TMySearchFilter;ini:PAnsiChar);
+var
+ pc:PAnsiChar;
+ csr:CUSTOMSEARCHRESULTS;
+ columns:array [0..3] of TCHAR;
+ lstorage,section,list:pointer;
+begin
+ columns[0].w:='Station Name';
+ columns[1].w:='Station URL';
+ columns[2].w:='Genre';
+ columns[3].w:='Bitrate';
+
+ csr.nSize :=SizeOf(csr);
+ csr.nFieldCount:=4;
+ csr.szFields :=@columns;
+ csr.psr.cbSize :=0;
+ ProtoBroadcastAck(PluginName,0,ACKTYPE_SEARCH,ACKRESULT_SEARCHRESULT,AckHandle,lparam(@csr));
+
+ lstorage:=OpenStorage(ini);
+ if lstorage<>nil then
+ begin
+ list:=GetSectionList(lstorage);
+ pc:=list;
+
+ while pc^<>#0 do
+ begin
+ section:=SearchSection(lstorage,pc);
+ LoadOneStation(section,filter); //!!
+ while pc^<>#0 do inc(pc);
+ inc(pc);
+ end;
+
+ FreeSectionList(list);
+ CloseStorage(lstorage);
+ end;
+
+ ProtoBroadcastAck(PluginName,0,ACKTYPE_SEARCH,ACKRESULT_SUCCESS,AckHandle,0);
+ mFreeMem(filter.lStation);
+ mFreeMem(filter.lStationURL);
+ mFreeMem(filter.lGenre);
+end;
+
+procedure BasicSearch(name:PAnsiChar); cdecl;
+var
+ filter:TMySearchFilter;
+ ini:array [0..MAX_PATH-1] of AnsiChar;
+begin
+ FillChar(filter,SizeOf(filter),0);
+ StrCopy(ini,storage);
+
+ StrDup(filter.lStation,name);
+ if filter.lStation<>nil then
+ CharLowerA(filter.lStation);
+
+ ProcessSearch(filter,ini);
+end;
+
+procedure ExtSearch(wnd:HWND); cdecl;
+var
+ filter:TMySearchFilter;
+ ltmp:longbool;
+ ini1,ini:array [0..MAX_PATH-1] of AnsiChar;
+begin
+ FillChar(filter,SizeOf(filter),0);
+ ini1[0]:=#0;
+ GetDlgItemTextA(wnd,IDC_CUSTOMINI,@ini1,SizeOf(ini1));
+ if ini1[0]=#0 then
+ StrCopy(ini,storage)
+ else
+ ConvertFileName(ini1,ini);
+
+ with filter do
+ begin
+// CallService(MS_UTILS_PATHTOABSOLUTE,dword(@ini1),dword(@ini));
+ lBitrate:=GetDlgItemInt(wnd,IDC_BITRATE,ltmp,false);
+ if IsDlgButtonChecked(wnd,IDC_LT)=BST_CHECKED then lBitrateMode:=-1
+ else if IsDlgButtonChecked(wnd,IDC_EQ)=BST_CHECKED then lBitrateMode:=0
+ else{if IsDlgButtonChecked(lParam,IDC_GT)=BST_CHECKED} lBitrateMode:=1;
+
+ lStation:=GetDlgText(wnd,IDC_STATION,true);
+ if lStation<>nil then
+ CharLowerA(lStation);
+
+ lStationURL:=GetDlgText(wnd,IDC_STATIONURL,true);
+ if lStationURL<>nil then
+ CharLowerA(lStationURL);
+
+ lGenre:=GetDlgText(wnd,IDC_GENRE,true);
+ if lGenre<>nil then
+ CharLowerA(lGenre);
+ end;
+
+ ProcessSearch(filter,ini);
+end;
+
+function Service_SearchBasic(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+begin
+ if lParam=0 then
+ result:=0
+ else
+ begin
+ result:=AckHandle;
+ CloseHandle(mir_forkthread(@BasicSearch,StrDup(PAnsiChar(lParam),PAnsiChar(lParam))));
+ end;
+end;
+
+function Service_SearchByAdvanced(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+begin
+ if lParam=0 then
+ result:=0
+ else
+ begin
+ result:=AckHandle;
+ CloseHandle(mir_forkthread(@ExtSearch,pointer(lParam)));
+ end;
+end;
+
+function Service_GetCaps(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl; forward;
+
+function ExtSearchProc(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
+var
+ buf:array [0..MAX_PATH-1] of AnsiChar;
+begin
+ result:=0;
+ case hMessage of
+ WM_INITDIALOG: begin
+ CheckDlgButton(Dialog,IDC_EQ,BST_CHECKED);
+ TranslateDialogDefault(Dialog);
+ end;
+
+ WM_COMMAND: if (wParam shr 16)=BN_CLICKED then
+ begin
+ if loword(wParam)=IDOK then
+ begin
+ SendMessage(GetParent(Dialog),WM_COMMAND,IDOK+(BN_CLICKED) shl 16,
+ GetDlgItem(GetParent(Dialog),IDOK));
+ end
+ else if loword(wParam)=IDC_BN_INIPATH then
+ begin
+ if ShowDlg(@buf,storage,'*.ini'#0'*.ini'#0#0) then
+ SetDlgItemTextA(Dialog,IDC_CUSTOMINI,@buf);
+ end;
+ end;
+ end;
+end;
+
+function Service_ExtSearchUI(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+type
+ PDLGTEMPLATEEX = ^TDLGTEMPLATEEX;
+ TDLGTEMPLATEEX = packed record
+ dlgVer:word;
+ signature:word;
+ helpID:dword;
+ exStyle:dword;
+ style:dword;
+ cDlgItems:word;
+ x:word;
+ y:word;
+ cx:word;
+ cy:word;
+{
+ sz_Or_Ord menu;
+ sz_Or_Ord windowClass;
+ title:array [0..titleLen] of WideChar;
+ pointsize:word;
+ weight:word;
+ italic:byte;
+ charset:byte;
+ typeface:array [0..stringLen] of WideChar;
+}
+ end;
+
+var
+ hr:HRSRC;
+ pdte:PDLGTEMPLATEEX;
+begin
+ result:=0;
+ if lParam<>0 then
+ begin
+ hr:=FindResource(hInstance,MAKEINTRESOURCE(IDD_SEARCH),RT_DIALOG);
+ if hr<>0 then
+ begin
+ pdte:=PDLGTEMPLATEEX(LoadResource(hInstance,hr));
+ if pdte<>nil then
+ begin
+ if (Service_GetCaps(PFLAGNUM_1,0) and PF1_EXTSEARCHUI)<>0 then
+ pdte^.style:=(pdte^.style and not WS_CHILD) or WS_POPUP or WS_BORDER;
+ result:=CreateDialogIndirect(hInstance,
+ PDlgTemplate(pdte){$IFNDEF FPC}^{$ENDIF},lParam,@ExtSearchProc);
+ end;
+ end;
+ end;
+end;
+
+function Service_AddToList(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+var
+ hContact:THANDLE;
+ p:PWideChar;
+ lurl:pWideChar;
+begin
+ result:=0;
+ if lParam<>0 then
+ begin
+ with PPROTOSEARCHRESULT(lParam)^ do
+ begin
+ if id.w<>nil then
+ lurl:=id.w
+ else
+ lurl:=firstname.w;
+
+ if lurl<>nil then
+ begin
+{
+// find contact
+ hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ while hContact<>0 do
+ begin
+ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,hContact,0)),
+ PluginName)=0 then
+ begin
+ p:=DBReadString(hContact,PluginName,optStationURL);
+ l:=StrCmp(p,lurl)=0;
+ mFreeMem(p);
+ if l then
+ begin
+ DBDeleteSetting(hContact,strCList,'NotOnList');
+ DBDeleteSetting(hContact,strCList,'Hidden');
+ result:=hContact;
+ exit;
+ end;
+ end;
+ hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0);
+ end;
+// if not found
+}
+ hContact:=CallService(MS_DB_CONTACT_ADD,0,0);
+ if hContact<>0 then
+ begin
+ CallService(MS_PROTO_ADDTOCONTACT,hContact,tlparam(PluginName));
+ // URL
+ DBWriteUnicode(hContact,PluginName,optStationURL,lurl);
+ DBWriteUnicode(hContact,PluginName,optFirstName ,lurl);
+
+ // Name
+ if nick.w=nil then
+ p:=lurl
+ else
+ p:=nick.w;
+ DBWriteUnicode(hContact,strCList ,optMyHandle,p);
+ DBWriteUnicode(hContact,PluginName,optNick ,p);
+
+ // Bitrate
+ if email.w<>nil then
+ begin
+ DBWriteWord (hContact,PluginName,optAge ,StrToInt(email.w));
+ DBWriteUnicode(hContact,PluginName,optBitrate,email.w);
+ end;
+
+ // Genre
+ if lastname.w<>nil then
+ begin
+ DBWriteUnicode(hContact,PluginName,optGenre ,lastname.w);
+ DBWriteUnicode(hContact,PluginName,optLastName,lastname.w);
+ end;
+
+ SetStatus(hContact,ID_STATUS_OFFLINE);
+
+// SetAvatar(hContact);
+
+ CallService(MS_IGNORE_IGNORE,hContact,IGNOREEVENT_USERONLINE{IGNOREEVENT_ALL});
+ result:=hContact;
+ end;
+ end;
+ end;
+ end;
+end;
diff --git a/plugins/mRadio/i_service.inc b/plugins/mRadio/i_service.inc new file mode 100644 index 0000000000..4f12544a81 --- /dev/null +++ b/plugins/mRadio/i_service.inc @@ -0,0 +1,241 @@ +{services}
+
+function Service_GetCaps(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+begin
+ case wParam of
+ PFLAGNUM_1:
+ result:=PF1_EXTSEARCH or PF1_MODEMSGRECV or PF1_ADDSEARCHRES or PF1_BASICSEARCH;
+ PFLAGNUM_2:
+ result:=PF2_ONLINE or PF2_INVISIBLE or PF2_SHORTAWAY;
+ PFLAGNUM_3:
+ result:=PF2_ONLINE;// or PF2_INVISIBLE or PF2_SHORTAWAY;
+ PFLAGNUM_4:
+ result:=PF4_NOCUSTOMAUTH or PF4_AVATARS;
+ PFLAG_UNIQUEIDTEXT:
+ result:=int_ptr(Translate('Radio station URL'));
+// PFLAG_UNIQUEIDSETTING:
+// result:=int_ptr(optStationURL)
+ else
+ result:=0;
+ end
+end;
+
+function Service_GetName(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+begin
+ if lParam<>0 then
+ StrCopy(PAnsiChar(lParam),Translate(PluginName),wParam);
+ result:=0;
+end;
+
+procedure GetAwayMsgProc(hContact:THANDLE); cdecl;
+var
+ buf,p:PWideChar;
+begin
+ if isVarsInstalled then
+ begin
+ buf:=ParseVarString(StatusTmpl,ActiveContact);
+ end
+ else
+ begin
+ mGetMem(buf,1024);
+ StrCopyW(buf,StatusTmpl);
+ if StrPosW(buf,'%radio_name%')<>nil then
+ begin
+ p:=DBReadUnicode(ActiveContact,strCList,optMyHandle);
+ StrReplaceW(buf,'%radio_name%',p);
+ mFreeMem(p);
+ end;
+ if StrPosW(buf,'%radio_url%')<>nil then
+ begin
+ p:=DBReadUnicode(ActiveContact,PluginName,optStationURL);
+ StrReplaceW(buf,'%radio_url%',p);
+ mFreeMem(p);
+ end;
+ if StrPosW(buf,'%radio_active%')<>nil then
+ begin
+ StrReplaceW(buf,'%radio_active%',ActiveURLw);
+ end;
+ if StrPosW(buf,'%radio_genre%')<>nil then // saved as String
+ begin
+ p:=DBReadUnicode(ActiveContact,PluginName,optGenre);
+ StrReplaceW(buf,'%radio_genre%',p);
+ mFreeMem(p);
+ end;
+ if StrPosW(buf,'%radio_bitrate%')<>nil then // saved as String
+ begin
+ p:=DBReadUnicode(ActiveContact,PluginName,optBitrate);
+ StrReplaceW(buf,'%radio_bitrate%',p);
+ mFreeMem(p);
+ end;
+ if StrPosW(buf,'%radio_title%')<>nil then
+ begin
+ p:=MakeMessage;
+ StrReplaceW(buf,'%radio_title%',p);
+ mFreeMem(p);
+ end;
+ if StrPosW(buf,'%radio_codec%')<>nil then
+ begin
+ p:=DBReadUnicode(ActiveContact,PluginName,optActiveCodec);
+ StrReplaceW(buf,'%radio_codec%',p);
+ mFreeMem(p);
+ end;
+ if StrPosW(buf,'%radio_status%')<>nil then
+ begin
+ StrReplaceW(buf,'%radio_status%',
+ TranslateW(GetStatusText(
+ CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET))));
+ end;
+ end;
+
+ ProtoBroadcastAck(PluginName,hContact,ACKTYPE_AWAYMSG,ACKRESULT_SUCCESS,AckHandle,lParam(buf));
+ mFreeMem(buf);
+end;
+
+function Service_GetAwayMsg(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+var
+ ccs:PCCSDATA;
+begin
+ ccs:=PCCSDATA(lParam);
+ if (ccs^.hContact<>0) and (PluginStatus=ID_STATUS_ONLINE) and
+ (DBReadWord(ccs^.hContact,PluginName,optStatus,ID_STATUS_OFFLINE)=ID_STATUS_ONLINE) then
+ begin
+ CloseHandle(mir_forkthread(@GetAwayMsgProc,pointer(ccs^.hContact)));
+ result:=AckHandle;
+ end
+ else
+ result:=0;
+end;
+
+function Service_GetStatus(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+begin
+ result:=PluginStatus;
+end;
+
+function Service_LoadIcon(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+begin
+ case loword(wParam) of
+ PLI_PROTOCOL: result:=LoadImage(hInstance,MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,16,16,LR_SHARED);
+// PLI_ONLINE : result:=0;
+// PLI_OFFLINE : result:=0;
+ else
+ result:=0;
+ end;
+end;
+
+function Service_SetStatus(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
+var
+ OldStatus:integer;
+begin
+ result:=0;
+ OldStatus:=PluginStatus;
+ if wParam<>ID_STATUS_OFFLINE then
+ wParam:=ID_STATUS_ONLINE;
+
+ if wParam=PluginStatus then
+ exit;
+
+ mFreeMem(proxy);
+ PluginStatus:=ID_STATUS_OFFLINE;
+
+ if wParam<>ID_STATUS_OFFLINE then
+ begin
+ if MyInitBASS<>0 then
+ begin
+ PluginStatus:=ID_STATUS_ONLINE;
+
+ proxy:=GetProxy(hNetLib);
+ BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,proxy);
+
+ if (ActiveContact<>0) and (AuConnect<>0) then
+ CallService(MS_RADIO_COMMAND,MRC_PLAY,ActiveContact);
+ end;
+ end
+ else //offline
+ begin
+ CallService(MS_RADIO_COMMAND,MRC_STOP,0);
+// StopStation;
+ end;
+ SetStatus(0,ID_STATUS_OFFLINE);
+
+ ProtoBroadcastAck(PluginName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,OldStatus,PluginStatus);
+end;
+
+function CreateProtoService(serviceName:PAnsiChar;pFunc:pointer):THANDLE;
+var
+ temp:array [0..MAXMODULELABELLENGTH-1] of AnsiChar;
+begin
+ StrCopy(StrCopyE(temp,PluginName),serviceName);
+ result:=CreateServiceFunction(temp,pFunc);
+end;
+
+var
+ prh0,prh1,prh2,prh3,prh4,prh5,prh6,prh7,prh8,prh9:THANDLE;
+
+procedure DestroyProtoServices;
+begin
+ DestroyServiceFunction(prh0);
+ DestroyServiceFunction(prh1);
+ DestroyServiceFunction(prh2);
+ DestroyServiceFunction(prh3);
+ DestroyServiceFunction(prh4);
+ DestroyServiceFunction(prh5);
+ DestroyServiceFunction(prh6);
+ DestroyServiceFunction(prh7);
+ DestroyServiceFunction(prh8);
+ DestroyServiceFunction(prh9);
+end;
+
+procedure CreateProtoServices;
+begin
+ prh0:=CreateProtoService(PS_GETCAPS ,@Service_GetCaps);
+ prh1:=CreateProtoService(PS_ADDTOLIST ,@Service_AddToList);
+ prh2:=CreateProtoService(PS_CREATEADVSEARCHUI,@Service_ExtSearchUI);
+ prh3:=CreateProtoService(PS_SEARCHBYADVANCED ,@Service_SearchByAdvanced);
+ prh4:=CreateProtoService(PS_BASICSEARCH ,@Service_SearchBasic);
+ prh5:=CreateProtoService(PS_GETNAME ,@Service_GetName);
+ prh6:=CreateProtoService(PS_LOADICON ,@Service_LoadIcon);
+ prh7:=CreateProtoService(PS_GETSTATUS ,@Service_GetStatus);
+ prh8:=CreateProtoService(PS_SETSTATUS ,@Service_SetStatus);
+ prh9:=CreateProtoService(PSS_GETAWAYMSG ,@Service_GetAwayMsg);
+(*
+{
+ Asks protocol for the status message for a status
+ wParam=(WORD) 0 for current status or a status id
+ lParam=SGMA_xxx
+ Returns status msg or NULL if there is none. The protocol have to handle only the current
+ status. Handling messages for other statuses is optional.
+ Remember to mir_free the return value
+}
+ SGMA_UNICODE = 1; // return Unicode status
+
+ PS_GETMYAWAYMSG = '/GetMyAwayMsg';
+
+*)
+(* {
+ wParam : 0
+ lParam : Pointer to a null terminated string containing an ID to search for
+ Affect : Send a basic search request, see notes
+ Returns: A handle to the search request or NULL(0) on failure
+ Notes : All protocols identify users uniquely by a single field
+ this service will search by that field.
+ -
+ All search replies (even protocol-spec extended searches)
+ are replied by a series of ack's,-
+ -
+ Result acks are a series of:
+ type=ACKTYPE_SEARCH, result=ACKRESULT_DATA, lParam=Pointer to a TPROTOSEARCHRESULT structure
+ -
+ ending ack:
+ type=ACKTYPE_SEARCH, result=ACKRESULT_SUCCESS, lParam=0
+ -
+ The pointers in the structure are not guaranteed to be
+ valid after the ack is complete.
+ -
+ The structure to reply with search results can be extended
+ per protocol basis (see below)
+
+ }
+ PS_BASICSEARCH = '/BasicSearch';
+ PS_BASICSEARCHW = '/BasicSearchW';
+*)
+end;
diff --git a/plugins/mRadio/i_tray.inc b/plugins/mRadio/i_tray.inc new file mode 100644 index 0000000000..fa63acc720 --- /dev/null +++ b/plugins/mRadio/i_tray.inc @@ -0,0 +1,228 @@ +{}
+var
+ trayradioparent:THANDLE;
+ trayparent:THANDLE;
+ traymute :THANDLE;
+ trayplay :THANDLE;
+ srvtrayplaypause:THANDLE;
+ srvtraystop:THANDLE;
+const
+ trayStations:TSortedList = (items:nil; realCount:0; limit:0; increment:8; sortFunc: nil);
+
+type
+ pTrayRadioStation = ^tTrayRadioStation;
+ tTrayRadioStation = record
+ name :pWideChar;
+ hContact:THANDLE;
+ service :THANDLE;
+ menuitem:THANDLE;
+ presents:int; // 0 - not used, 1 - ok, 2 - new
+ end;
+
+function MyStrSort(para1:pointer; para2:pointer):int; cdecl;
+begin
+ result:=lstrcmpiW{StrCmpW}(pTrayRadioStation(para1).name,pTrayRadioStation(para2).name);
+end;
+
+function ChooseStation(wParam:WPARAM;lParam,lParam1:LPARAM):int; cdecl;
+begin
+ result:=Service_RadioPlayStop(lParam1,0);
+end;
+
+procedure MakeStationsMenu;
+var
+ hContact:Cardinal;
+ p:pWideChar;
+ i,idx:integer;
+ tmp:pTrayRadioStation;
+ srch:tTrayRadioStation;
+ pc:pAnsiChar;
+ buf:array [0..63] of AnsiChar;
+ mi:TCListMenuItem;
+begin
+ trayStations.sortFunc:=@MyStrSort;
+
+ // clear presents flag
+ if trayStations.realCount>0 then
+ for i:=0 to trayStations.realCount-1 do
+ pTrayRadioStation(trayStations.Items[i]).presents:=0;
+
+ // Fill list
+ FillChar(srch,SizeOf(srch),0);
+ hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ while hContact<>0 do
+ begin
+ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,hContact,0)),cPluginName)=0 then
+ begin
+ p:=DBReadUnicode(hContact,strCList,'MyHandle',nil);
+ if p<>nil then
+ begin
+ srch.name:=p;
+ // search in list
+ if List_GetIndex(@trayStations,@srch,@idx)<>0 then
+ // found - set mark
+ pTrayRadioStation(trayStations.Items[idx]).presents:=1
+ else // add if not found
+ begin
+ mGetMem(tmp,SizeOf(tTrayRadioStation));
+ tmp.name :=p;
+ tmp.presents:=2;
+ tmp.hContact:=hContact;
+ List_InsertPtr(@trayStations,tmp);
+ end;
+ end;
+ end;
+ hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0);
+ end;
+
+ // delete obsolete elements
+ for i:=trayStations.realCount-1 downto 0 do
+ begin
+ tmp:=pTrayRadioStation(trayStations.Items[i]);
+ if tmp.presents=0 then
+ begin
+ mFreeMem(tmp.name);
+ DestroyServiceFunction(tmp.service);
+ CallService(MS_CLIST_REMOVETRAYMENUITEM,tmp.menuitem,0);
+ mFreeMem(tmp);
+ List_Remove(@trayStations,i);
+ end;
+ end;
+
+ // build menu from sorted list
+ FillChar(mi,SizeOf(mi),0);
+ mi.cbSize:=sizeof(mi);
+ mi.Flags :=CMIF_KEEPUNTRANSLATED or CMIF_UNICODE or CMIF_ROOTHANDLE;
+ mi.szPopupName:=TChar(trayparent);
+ pc:=StrCopyE(@buf,'mRadio/Choose');
+ for i:=0 to trayStations.realCount-1 do
+ begin
+ tmp:=pTrayRadioStation(trayStations.Items[i]);
+ if tmp.presents=2 then
+ begin
+ IntToStr(pc,tmp.hContact);
+ tmp.service:=CreateServiceFunctionParam(@buf,@ChooseStation,tmp.hContact);
+ mi.position :=i;
+ mi.pszService:=@buf;
+ mi.szName.w :=tmp.name;
+ tmp.menuitem:=Menu_AddTrayMenuItem(@mi);
+ end;
+ end;
+end;
+
+function TrayPlayPause(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl;
+begin
+ result:=CallService(MS_RADIO_COMMAND,MRC_PAUSE,0);
+end;
+
+function TrayStop(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl;
+begin
+ result:=CallService(MS_RADIO_COMMAND,MRC_STOP,0);
+end;
+
+procedure CreateTrayMenu();
+var
+ mi:TCListMenuItem;
+ playstr:pWideChar;
+begin
+ FillChar(mi, sizeof(mi), 0);
+ mi.cbSize :=sizeof(mi);
+ mi.flags :=CMIF_UNICODE;
+ mi.szName.w:=cPluginName;
+ mi.hIcon :=CallService(MS_SKIN2_GETICON,0,lparam(IcoBtnSettings));
+ trayradioparent:=Menu_AddTrayMenuItem(@mi);
+
+ FillChar(mi, sizeof(mi), 0);
+ mi.cbSize :=sizeof(mi);
+ mi.szPopupName:=TChar(trayradioparent);
+
+ if gVolume<0 then
+ mi.flags:=CMIF_UNICODE or CMIF_ROOTHANDLE or CMIF_CHECKED
+ else
+ mi.flags:=CMIF_UNICODE or CMIF_ROOTHANDLE;
+ mi.szName.w :='Mute';
+ mi.pszService:=MS_RADIO_MUTE;
+ mi.position :=1;
+ traymute:=Menu_AddTrayMenuItem(@mi);
+
+ mi.flags:=CMIF_UNICODE or CMIF_ROOTHANDLE;
+ if CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET)<>RD_STATUS_PLAYING then
+ playstr:='Play'
+ else
+ playstr:='Pause';
+ mi.szName.w :=playstr;
+ mi.position :=2;
+ srvtrayplaypause:=CreateServiceFunction('mRadio/TrayPlayPause',@TrayPlayPause);
+ mi.pszService:='mRadio/TrayPlayPause';
+ trayplay:=Menu_AddTrayMenuItem(@mi);
+
+ mi.szName.w :='Stop';
+ mi.position :=3;
+ srvtraystop:=CreateServiceFunction('mRadio/TrayStop',@TrayStop);
+ mi.pszService:='mRadio/TrayStop';
+ Menu_AddTrayMenuItem(@mi);
+
+ mi.szName.w :='Play Station';
+ mi.position :=1000;
+ mi.pszService:=nil;
+ trayparent:=Menu_AddTrayMenuItem(@mi);
+end;
+
+function TrayPrebuild(wParam:WPARAM;lParam:LPARAM):int; cdecl;
+var
+ mi:tClistMenuItem;
+ playstr:pWideChar;
+begin
+ FillChar(mi,sizeof(mi),0);
+ mi.cbSize:=sizeof(mi);
+ if gVolume<0 then
+ mi.flags:=CMIM_FLAGS or CMIF_CHECKED
+ else
+ mi.flags:=CMIM_FLAGS;
+ CallService(MS_CLIST_MODIFYMENUITEM,traymute,tlparam(@mi));
+
+ mi.flags:=CMIM_NAME or CMIF_UNICODE;
+ if CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET)<>RD_STATUS_PLAYING then
+ playstr:='Play'
+ else
+ playstr:='Pause';
+ mi.szName.w:=playstr;
+ CallService(MS_CLIST_MODIFYMENUITEM,trayplay,tlparam(@mi));
+
+ MakeStationsMenu();
+ result:=0;
+end;
+
+procedure CreateMIMTrayMenu;
+begin
+ if ServiceExists(MS_CLIST_ADDTRAYMENUITEM)<>0 then
+// if hiddenwindow<>0 then
+ begin
+ CreateTrayMenu();
+ MakeStationsMenu();
+ HookEvent(ME_CLIST_PREBUILDTRAYMENU,@TrayPrebuild);
+ end;
+end;
+
+procedure RemoveTrayItems;
+var
+ i:integer;
+ tmp:pTrayRadioStation;
+begin
+ // remove stations
+ for i:=trayStations.realCount-1 downto 0 do
+ begin
+ tmp:=pTrayRadioStation(trayStations.Items[i]);
+ mFreeMem(tmp.name);
+ DestroyServiceFunction(tmp.service);
+// CallService(MS_CLIST_REMOVETRAYMENUITEM,tmp.menuitem,0);
+ mFreeMem(tmp);
+ end;
+ List_Destroy(@trayStations);
+ DestroyServiceFunction(srvtrayplaypause);
+ DestroyServiceFunction(srvtraystop);
+
+ if ServiceExists(MS_CLIST_REMOVETRAYMENUITEM)<>0 then
+ CallService(MS_CLIST_REMOVETRAYMENUITEM,trayradioparent,0);
+
+end;
diff --git a/plugins/mRadio/i_variables.inc b/plugins/mRadio/i_variables.inc new file mode 100644 index 0000000000..fead4afad8 --- /dev/null +++ b/plugins/mRadio/i_variables.inc @@ -0,0 +1,82 @@ +{Variables support}
+const
+ numvars = 8;
+type
+ tvar = packed record
+ name :PWideChar;
+ help :PAnsiChar;
+ end;
+const
+ vars:array [0..numvars-1] of tvar = (
+ (name:'radio_name' ;help:'Station Name'),
+ (name:'radio_url' ;help:'Station/playlist URL'),
+ (name:'radio_active' ;help:'Currently played URL'),
+ (name:'radio_genre' ;help:'Genre'),
+ (name:'radio_bitrate';help:'Bitrate'),
+ (name:'radio_title' ;help:'Current stream title'),
+ (name:'radio_codec' ;help:'Currently used decoder'),
+ (name:'radio_status' ;help:'Current status'));
+// contact,protocol,host,port,file/path
+
+function GetField(ai:PARGUMENTSINFO):pWideChar; cdecl;
+var
+ i:integer;
+ res:PWideChar;
+begin
+ res:=nil;
+ if ActiveContact<>0 then
+ begin
+ i:=0;
+ repeat
+ if lstrcmpiw(PWideChar(ai^.argv^),vars[i].name)=0 then
+ break;
+ inc(i);
+ until i=numvars;
+ case i of
+ 0: res:=DBReadUnicode(ActiveContact,strCList ,optMyHandle);
+ 1: res:=DBReadUnicode(ActiveContact,PluginName,optStationURL);
+ 2: StrDupW(res,ActiveURLw);
+ 3: res:=DBReadUnicode(ActiveContact,PluginName,optGenre);
+ 4: res:=DBReadUnicode(ActiveContact,PluginName,optBitrate);
+ 5: res:=MakeMessage;
+ 6: res:=DBReadUnicode(0,PluginName,optActiveCodec);
+ 7: StrDupW(res,TranslateW(GetStatusText(CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET))));
+ end;
+ end;
+ if res=nil then
+ begin
+ mGetMem(res,2);
+ res^:=#0;
+ end;
+ result:=res;
+end;
+
+function FreeField(szReturn:PWideChar):int; cdecl;
+begin
+ mFreeMem(szReturn);
+ result:=1;
+end;
+
+procedure RegisterVariables;
+const
+ Prefix:PAnsiChar = 'Radio'#9;
+var
+ rt:TTOKENREGISTER;
+ i:integer;
+ s:array [0..127] of AnsiChar;
+ p:pAnsiChar;
+begin
+ rt.cbSize :=SizeOf(rt);
+ rt.memType :=TR_MEM_OWNER;
+ rt.szService :=@GetField;
+ rt.szCleanupService:=@FreeField;
+ rt.flags:=TRF_FIELD or TRF_CLEANUP or TRF_PARSEFUNC or TRF_CLEANUPFUNC or TRF_UNICODE;
+ p:=StrCopyE(s,Prefix);
+ rt.szHelpText:=@s;
+ for i:=0 to numvars-1 do
+ begin
+ rt.szTokenString.w:=vars[i].name;
+ StrCopy(p,vars[i].help);
+ CallService(MS_VARS_REGISTERTOKEN,0,lparam(@rt));
+ end;
+end;
diff --git a/plugins/mRadio/i_vars.inc b/plugins/mRadio/i_vars.inc new file mode 100644 index 0000000000..5d75dc7fae --- /dev/null +++ b/plugins/mRadio/i_vars.inc @@ -0,0 +1,180 @@ +{used variables}
+
+{$include m_radio.inc}
+
+const
+ optActiveCodec:PAnsiChar = 'ActiveCodec';
+ optLastStn :PAnsiChar = 'LastStation';
+ optConnect :PAnsiChar = 'AutoConnect';
+ optAutoMute :PAnsiChar = 'AutoMute';
+ optEQ_OFF :PAnsiChar = 'eqoff';
+ optStatusMsg :PAnsiChar = 'StatusMsg';
+ optCurElement :PAnsiChar = 'LastPlayed';
+ optPlayFirst :PAnsiChar = 'PlayFromFirst';
+ optActiveURL :PAnsiChar = 'ActiveURL';
+ optContRec :PAnsiChar = 'ContRec';
+ optLoop :PAnsiChar = 'Loop';
+ optShuffle :PAnsiChar = 'Shuffle';
+ optRecPath :PAnsiChar = 'RecordPath';
+ optStatus :PAnsiChar = 'Status';
+ optVolume :PAnsiChar = 'Volume';
+ optBuffer :PAnsiChar = 'Buffer';
+ optPreBuf :PAnsiChar = 'PreBuf';
+ optTimeout :PAnsiChar = 'Timeout';
+ optVersion :PAnsiChar = 'version';
+ optStatusTmpl :PAnsiChar = 'StatusTmpl';
+ optNumTries :PAnsiChar = 'NumTries';
+ optOffline :PAnsiChar = 'asOffline';
+ // mRadio compatibility
+ optStationURL :PAnsiChar = 'StationURL';
+ optMyHandle :PAnsiChar = 'MyHandle';
+ optGenre :PAnsiChar = 'Genre';
+ optBitrate :PAnsiChar = 'Bitrate';
+ // UserInfo compatibility
+ optFirstName :PAnsiChar = 'FirstName';
+ optNick :PAnsiChar = 'Nick';
+ optLastName :PAnsiChar = 'LastName';
+ optAge :PAnsiChar = 'Age';
+ // 3D sound support
+ optEAXType :PAnsiChar = 'EAXtype';
+ optForcedMono :PAnsiChar = 'ForcedMono';
+
+ optGroup :PAnsiChar = 'Group';
+ optBASSPath :PAnsiChar = 'BASSpath';
+ optTitle :PAnsiChar = 'Title';
+ optArtist :PAnsiChar = 'Artist';
+
+var
+ hhRadioStatus,
+ // service handles
+ hsPlayStop,
+ hsRecord,
+ hsSettings,
+ hsSetVol,
+ hsGetVol,
+ hsMute,
+ hsCommand,
+ hsExport,
+ hsImport,
+ hsTrayMenu,
+ hsEqOnOff,
+
+ hNetLib,
+ hDblClick,
+ hHookShutdown,
+ hCMenuItemRec,
+ hCMenuItemPlay,
+ contexthook,
+ opthook,
+ onsetting,
+ ondelete,
+ onloadhook:THANDLE;
+ hiddenwindow:HWND;
+var
+ plist:tPlaylist;
+// plFile:pWideChar; // playlist file name (for delete after using?)
+// plLocal:boolean; // true - no need to delete playlist
+var
+ RemoteSong:bool;
+ gVolume:integer;
+ NumTries:cardinal;
+ doLoop:cardinal;
+ PlayFirst:cardinal;
+ doShuffle:cardinal;
+ ForcedMono:cardinal;
+ doContRec:cardinal;
+ AuConnect:cardinal;
+ AuMute:cardinal;
+ AsOffline:cardinal;
+ isEQ_OFF:cardinal;
+ PluginStatus:integer;
+ storagep,storage:PAnsiChar;
+ recpath:pWideChar;
+ sBuffer,
+ sTimeout,
+ sPreBuf:cardinal;
+const
+ hVolCtrl :HWND=0;
+ hVolFrmCtrl :HWND=0;
+const
+ hMuteFrmCtrl:HWND=0;
+const
+ Inited:boolean=false;
+const
+ StatusTmpl:pWideChar = nil;
+ proxy:pAnsiChar = nil;
+type
+ tEQRec = record
+ fx :HFX;
+ wnd :HWND;
+ param :BASS_DX8_PARAMEQ;
+ text :PAnsiChar;
+ end;
+var
+ eq:array [0..9] of tEQRec = (
+ (fx:0;wnd:0;param:(fCenter:80 ;fBandwidth:18;fGain:0);text:'80'),
+ (fx:0;wnd:0;param:(fCenter:170 ;fBandwidth:18;fGain:0);text:'170'),
+ (fx:0;wnd:0;param:(fCenter:310 ;fBandwidth:18;fGain:0);text:'310'),
+ (fx:0;wnd:0;param:(fCenter:600 ;fBandwidth:18;fGain:0);text:'600'),
+ (fx:0;wnd:0;param:(fCenter:1000 ;fBandwidth:18;fGain:0);text:'1k'),
+ (fx:0;wnd:0;param:(fCenter:3000 ;fBandwidth:18;fGain:0);text:'3k'),
+ (fx:0;wnd:0;param:(fCenter:6000 ;fBandwidth:18;fGain:0);text:'6k'),
+ (fx:0;wnd:0;param:(fCenter:12000;fBandwidth:18;fGain:0);text:'12k'),
+ (fx:0;wnd:0;param:(fCenter:14000;fBandwidth:18;fGain:0);text:'14k'),
+ (fx:0;wnd:0;param:(fCenter:16000;fBandwidth:18;fGain:0);text:'16k'));
+const
+ IcoBtnSettings:PAnsiChar = 'Radio_Setting';
+ IcoBtnOn :PAnsiChar = 'Radio_On';
+ IcoBtnOff :PAnsiChar = 'Radio_Off';
+ IcoBtnRecUp :PAnsiChar = 'Radio_RecUp';
+ IcoBtnRecDn :PAnsiChar = 'Radio_RecDn';
+ IcoBtnAdd :PAnsiChar = 'Radio_Add';
+ IcoBtnDel :PAnsiChar = 'Radio_Del';
+const
+ hRecord :THANDLE = 0;
+ chan :HSTREAM = 0;
+ ActiveContact:THANDLE = 0;
+ ActiveURLw :PWideChar = nil;
+
+type
+ TEAXItem = record
+ name:PWideChar;
+ code:dword;
+ end;
+const
+ EAXItems:array [0..EAX_ENVIRONMENT_COUNT] of TEAXItem=(
+ (name:'Off' ; code:0),
+ (name:'Generic' ; code:EAX_ENVIRONMENT_GENERIC),
+ (name:'Padded Cell' ; code:EAX_ENVIRONMENT_PADDEDCELL),
+ (name:'Room' ; code:EAX_ENVIRONMENT_ROOM),
+ (name:'Bathroom' ; code:EAX_ENVIRONMENT_BATHROOM),
+ (name:'Living Room' ; code:EAX_ENVIRONMENT_LIVINGROOM),
+ (name:'Stone Room' ; code:EAX_ENVIRONMENT_STONEROOM),
+ (name:'Auditorium' ; code:EAX_ENVIRONMENT_AUDITORIUM),
+ (name:'Concert Hall' ; code:EAX_ENVIRONMENT_CONCERTHALL),
+ (name:'Cave' ; code:EAX_ENVIRONMENT_CAVE),
+ (name:'Arena' ; code:EAX_ENVIRONMENT_ARENA),
+ (name:'Hangar' ; code:EAX_ENVIRONMENT_HANGAR),
+ (name:'Carpeted Hallway'; code:EAX_ENVIRONMENT_CARPETEDHALLWAY),
+ (name:'Hallway' ; code:EAX_ENVIRONMENT_HALLWAY),
+ (name:'Stone Corridor' ; code:EAX_ENVIRONMENT_STONECORRIDOR),
+ (name:'Alley' ; code:EAX_ENVIRONMENT_ALLEY),
+ (name:'Forrest' ; code:EAX_ENVIRONMENT_FOREST),
+ (name:'City' ; code:EAX_ENVIRONMENT_CITY),
+ (name:'Mountains' ; code:EAX_ENVIRONMENT_MOUNTAINS),
+ (name:'Quarry' ; code:EAX_ENVIRONMENT_QUARRY),
+ (name:'Plain' ; code:EAX_ENVIRONMENT_PLAIN),
+ (name:'Parking Lot' ; code:EAX_ENVIRONMENT_PARKINGLOT),
+ (name:'Sewer Pipe' ; code:EAX_ENVIRONMENT_SEWERPIPE),
+ (name:'Under Water' ; code:EAX_ENVIRONMENT_UNDERWATER),
+ (name:'Drugged' ; code:EAX_ENVIRONMENT_DRUGGED),
+ (name:'Dizzy' ; code:EAX_ENVIRONMENT_DIZZY),
+ (name:'Psychotic' ; code:EAX_ENVIRONMENT_PSYCHOTIC));
+
+type
+ tPreset = record
+ name :PWideChar;
+ preset:array [0..9] of shortint;
+ end;
+var
+ Presets: array of tPreset;
diff --git a/plugins/mRadio/i_visual.inc b/plugins/mRadio/i_visual.inc new file mode 100644 index 0000000000..77012b55f2 --- /dev/null +++ b/plugins/mRadio/i_visual.inc @@ -0,0 +1,115 @@ +{Visual part}
+function OnContactMenu(hContact:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ mi:TCListMenuItem;
+begin
+ FillChar(mi,SizeOf(mi),0);
+ mi.cbSize:=sizeof(mi);
+ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,hContact,0)),
+ PluginName)<>0 then
+ begin
+ mi.flags:=CMIM_FLAGS or CMIF_HIDDEN;
+ CallService(MS_CLIST_MODIFYMENUITEM,hCMenuItemPlay,tlparam(@mi));
+ end
+ else
+ begin
+ // play/Stop
+ mi.flags:=CMIM_FLAGS or CMIM_ICON or CMIM_NAME;
+ if THANDLE(hContact)<>ActiveContact then
+ begin
+ mi.szName.a:='Start broadcasting';
+ mi.hIcon:=CallService(MS_SKIN2_GETICON,0,tlparam(IcoBtnOn));
+ end
+ else
+ begin
+ mi.szName.a:='Stop broadcasting';
+ mi.hIcon:=CallService(MS_SKIN2_GETICON,0,tlparam(IcoBtnOff));
+ end;
+ CallService(MS_CLIST_MODIFYMENUITEM,hCMenuItemPlay,tlparam(@mi));
+
+ // record
+ mi.flags:=CMIM_FLAGS or CMIM_ICON or CMIM_NAME;
+ if Service_RadioRecord(0,1)<>0 then
+ begin
+ mi.szName.a:='Stop record';
+ mi.hIcon:=CallService(MS_SKIN2_GETICON,0,tlparam(IcoBtnRecDn));
+ end
+ else
+ begin
+ mi.szName.a:='Start record';
+ mi.hIcon:=CallService(MS_SKIN2_GETICON,0,tlparam(IcoBtnRecUp));
+ end;
+ end;
+ CallService(MS_CLIST_MODIFYMENUITEM,hCMenuItemRec,tlparam(@mi));
+ result:=0;
+end;
+
+procedure CreateMenu;
+var
+ mi:TCListMenuItem;
+begin
+ FillChar(mi, sizeof(mi), 0);
+ mi.cbSize :=sizeof(mi);
+// mi.popupPosition:=MenuUserInfoPos;
+ mi.pszService:=MS_RADIO_RECORD;
+ mi.szName.a :='Start/Stop Record';
+ hCMenuItemRec:=Menu_AddContactMenuItem(@mi);
+
+//!! mi.flags :=CMIF_NOTOFFLINE or CMIF_NOTOFFLIST;
+ mi.hIcon :=CallService(MS_SKIN2_GETICON,0,lparam(IcoBtnOn));
+ mi.pszService :=MS_RADIO_PLAYSTOP;
+ mi.szName.a :='Start/Stop broadcasting';
+ hCMenuItemPlay:=Menu_AddContactMenuItem(@mi);
+end;
+
+procedure RegisterIcons;
+var
+ sid:TSKINICONDESC;
+begin
+ FillChar(sid,SizeOf(TSKINICONDESC),0);
+ sid.cbSize:=SizeOf(TSKINICONDESC);
+ sid.cx:=16;
+ sid.cy:=16;
+ sid.szSection.a:='Protocols/mRadio';
+ sid.hDefaultIcon :=LoadImage(hInstance,MAKEINTRESOURCE(BTN_RECUP),IMAGE_ICON,16,16,0);
+ sid.pszName :=IcoBtnRecUp;
+ sid.szDescription.a:='Start record';
+ Skin_AddIcon(@sid);
+ DestroyIcon(sid.hDefaultIcon);
+
+ sid.hDefaultIcon :=LoadImage(hInstance,MAKEINTRESOURCE(BTN_RECDN),IMAGE_ICON,16,16,0);
+ sid.pszName :=IcoBtnRecDn;
+ sid.szDescription.a:='Stop record';
+ Skin_AddIcon(@sid);
+ DestroyIcon(sid.hDefaultIcon);
+
+ sid.hDefaultIcon :=LoadImage(hInstance,MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,16,16,0);
+ sid.pszName :=IcoBtnSettings;
+ sid.szDescription.a:='Settings';
+ Skin_AddIcon(@sid);
+ DestroyIcon(sid.hDefaultIcon);
+
+ sid.hDefaultIcon :=LoadImage(hInstance,MAKEINTRESOURCE(IDI_ON),IMAGE_ICON,16,16,0);
+ sid.pszName :=IcoBtnOn;
+ sid.szDescription.a:='Broadcast ON';
+ Skin_AddIcon(@sid);
+ DestroyIcon(sid.hDefaultIcon);
+
+ sid.hDefaultIcon :=LoadImage(hInstance,MAKEINTRESOURCE(IDI_OFF),IMAGE_ICON,16,16,0);
+ sid.pszName :=IcoBtnOff;
+ sid.szDescription.a:='Broadcast OFF';
+ Skin_AddIcon(@sid);
+ DestroyIcon(sid.hDefaultIcon);
+
+ sid.hDefaultIcon :=LoadImage(hInstance,MAKEINTRESOURCE(IDI_ADD),IMAGE_ICON,16,16,0);
+ sid.pszName :=IcoBtnAdd;
+ sid.szDescription.a:='Add EQ preset';
+ Skin_AddIcon(@sid);
+ DestroyIcon(sid.hDefaultIcon);
+
+ sid.hDefaultIcon :=LoadImage(hInstance,MAKEINTRESOURCE(IDI_DEL),IMAGE_ICON,16,16,0);
+ sid.pszName :=IcoBtnDel;
+ sid.szDescription.a:='Delete EQ preset';
+ Skin_AddIcon(@sid);
+ DestroyIcon(sid.hDefaultIcon);
+end;
diff --git a/plugins/mRadio/ico/delete.ico b/plugins/mRadio/ico/delete.ico Binary files differnew file mode 100644 index 0000000000..eea851da19 --- /dev/null +++ b/plugins/mRadio/ico/delete.ico diff --git a/plugins/mRadio/ico/mradio.ico b/plugins/mRadio/ico/mradio.ico Binary files differnew file mode 100644 index 0000000000..e95c6fe21a --- /dev/null +++ b/plugins/mRadio/ico/mradio.ico diff --git a/plugins/mRadio/ico/new.ico b/plugins/mRadio/ico/new.ico Binary files differnew file mode 100644 index 0000000000..73937210e0 --- /dev/null +++ b/plugins/mRadio/ico/new.ico diff --git a/plugins/mRadio/ico/off.ico b/plugins/mRadio/ico/off.ico Binary files differnew file mode 100644 index 0000000000..041e55bb9e --- /dev/null +++ b/plugins/mRadio/ico/off.ico diff --git a/plugins/mRadio/ico/on.ico b/plugins/mRadio/ico/on.ico Binary files differnew file mode 100644 index 0000000000..35bf39e0b9 --- /dev/null +++ b/plugins/mRadio/ico/on.ico diff --git a/plugins/mRadio/ico/recoff.ico b/plugins/mRadio/ico/recoff.ico Binary files differnew file mode 100644 index 0000000000..4bb6000ef0 --- /dev/null +++ b/plugins/mRadio/ico/recoff.ico diff --git a/plugins/mRadio/ico/recon.ico b/plugins/mRadio/ico/recon.ico Binary files differnew file mode 100644 index 0000000000..d8007b1c8c --- /dev/null +++ b/plugins/mRadio/ico/recon.ico diff --git a/plugins/mRadio/make.bat b/plugins/mRadio/make.bat new file mode 100644 index 0000000000..2917577c4a --- /dev/null +++ b/plugins/mRadio/make.bat @@ -0,0 +1,20 @@ +@echo off
+if /i '%1' == 'fpc' (
+ set OUTDIR="..\..\bin10\Release\Plugins"
+ set FPCBIN=fpc.exe
+) else if /i '%1' == 'fpc64' (
+ set OUTDIR="..\..\bin10\Release64\Plugins"
+ set FPCBIN=ppcrossx64.exe
+)
+set PROJECT=mRadio
+
+if not exist %OUTDIR% mkdir %OUTDIR%
+md tmp
+
+rem brcc32.exe mradio.rc -fomradio.res
+
+%FPCBIN% @..\..\plugins\Utils.pas\fpc.cfg %PROJECT%.dpr %2 %3 %4 %5 %6 %7 %8 %9
+
+move .\tmp\%PROJECT%.dll %OUTDIR%
+del /Q tmp\*
+rd tmp
diff --git a/plugins/mRadio/mr_rc.inc b/plugins/mRadio/mr_rc.inc new file mode 100644 index 0000000000..41998194b6 --- /dev/null +++ b/plugins/mRadio/mr_rc.inc @@ -0,0 +1,87 @@ +const
+ IDD_SEARCH = 101;
+ IDD_SETTING = 102;
+ IDD_SETTING_TECH = 103;
+ IDD_FRAME = 104;
+
+ IDC_GENRE = 1025;
+ IDC_BITRATE = 1026;
+ IDC_STATION = 1027;
+ IDC_LT = 1029;
+ IDC_EQ = 1030;
+ IDC_GT = 1031;
+
+ IDC_LOOP = 1032;
+ IDC_SHUFFLE = 1033;
+ IDC_CONTREC = 1034;
+ IDC_PLAYFIRST = 1035;
+ IDC_EQOFF = 1036;
+ IDC_BN_INIPATH = 1037;
+ IDC_BN_URLPATH = 1038;
+ IDC_CUSTOMINI = 1039;
+
+ IDC_VOLUME = 1040;
+ IDC_STATIONURL = 1041;
+ IDC_ADD_LIST = 1042;
+ IDC_ADD_INI = 1043;
+ IDC_BN_RECPATH = 1044;
+ IDC_ED_RECPATH = 1045;
+ IDC_BN_RECORD = 1046;
+ IDC_EAXTYPE = 1047;
+ IDC_USEEAX = 1048;
+ IDC_BUFFER = 1049;
+ IDC_PREBUF = 1050;
+ IDC_TIMEOUT = 1051;
+ IDC_PRESET = 1052;
+ IDC_TRIES = 1053;
+ IDC_MONO = 1054;
+
+ IDC_BASSPATH = 1100;
+ IDC_BASSPTHBTN = 1101;
+
+ IDC_ZERO = 1060;
+ IDC_EQ00 = 1061;
+ IDC_EQ01 = 1062;
+ IDC_EQ02 = 1063;
+ IDC_EQ03 = 1064;
+ IDC_EQ04 = 1065;
+ IDC_EQ05 = 1066;
+ IDC_EQ06 = 1067;
+ IDC_EQ07 = 1068;
+ IDC_EQ08 = 1069;
+ IDC_EQ09 = 1070;
+ IDC_0 = 1161;
+ IDC_1 = 1162;
+ IDC_2 = 1163;
+ IDC_3 = 1164;
+ IDC_4 = 1165;
+ IDC_5 = 1166;
+ IDC_6 = 1167;
+ IDC_7 = 1168;
+ IDC_8 = 1169;
+ IDC_9 = 1170;
+
+ IDC_CONNECT = 1072;
+ IDC_OFFLINE = 1073;
+ IDC_AUTOMUTE = 1074;
+
+ IDC_STATUS = 1075;
+ IDC_HLP_VARS = 1076;
+
+ IDC_IMPORT = 1077;
+ IDC_EXPORT = 1078;
+
+ IDC_EQ_ADD = 1079;
+ IDC_EQ_DEL = 1080;
+
+ IDC_RADIO_MUTE = 1025;
+ IDC_RADIO_VOL = 1026;
+
+ BTN_RECUP = 202;
+ BTN_RECDN = 203;
+
+ IDI_MAIN = 302;
+ IDI_ON = 303;
+ IDI_OFF = 304;
+ IDI_ADD = 305;
+ IDI_DEL = 306;
diff --git a/plugins/mRadio/mradio.dpr b/plugins/mRadio/mradio.dpr new file mode 100644 index 0000000000..f5e09dab4f --- /dev/null +++ b/plugins/mRadio/mradio.dpr @@ -0,0 +1,346 @@ +{.$DEFINE CHANGE_NAME_BUFFERED}
+{$include compilers.inc}
+{$IFDEF COMPILER_16_UP}
+ {$WEAKLINKRTTI ON}
+ {.$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
+{$ENDIF}
+{$IMAGEBASE $13300000}
+library mradio;
+
+uses
+// FastMM4,
+ Windows,messages,commctrl
+ ,common,io,wrapper,wrapdlgs,syswin
+ ,Dynamic_Bass,dynbasswma
+ ,m_api,dbsettings,mirutils,playlist,memini;
+
+{$include mr_rc.inc}
+{$r mradio.res}
+
+{$include i_vars.inc}
+
+const
+ cPluginName = 'mRadio';
+const
+ PluginName:PAnsiChar = cPluginName;
+
+function MakeMessage:pWideChar;
+var
+ p,artist,title:pWideChar;
+ len:cardinal;
+begin
+ artist:=DBReadUnicode(0,PluginName,optArtist);
+ title :=DBReadUnicode(0,PluginName,optTitle);
+ len:=StrLenW(artist);
+ if (artist<>nil) and (title<>nil) then
+ inc(len,3);
+ inc(len,StrLenW(title));
+
+ if len>0 then
+ begin
+ mGetMem(result,(len+1)*SizeOf(WideChar));
+ p:=result;
+ if artist<>nil then
+ begin
+ p:=StrCopyEW(p,artist);
+ if title<>nil then
+ p:=StrCopyEW(p,' - ');
+ mFreeMem(artist);
+ end;
+ if title<>nil then
+ begin
+ StrCopyW(p,title);
+ mFreeMem(title);
+ end;
+ end
+ else
+ result:=nil;
+end;
+
+procedure SetStatus(hContact:THANDLE;status:integer);
+begin
+// if Status=ID_STATUS_OFFLINE then
+// MyStopBass;
+
+ if status=ID_STATUS_OFFLINE then
+ begin
+ if (AsOffline=BST_UNCHECKED) or (PluginStatus<>ID_STATUS_OFFLINE) then
+ status:=ID_STATUS_INVISIBLE;
+ end;
+
+ if hContact=0 then
+ begin
+ hContact:=CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ while hContact<>0 do
+ begin
+ if StrCmp(PAnsiChar(CallService(MS_PROTO_GETCONTACTBASEPROTO,hContact,0)),PluginName)=0 then
+ begin
+ DBWriteWord(hContact,PluginName,optStatus,status);
+ end;
+ hContact:=CallService(MS_DB_CONTACT_FINDNEXT,hContact,0);
+ end;
+ end
+ else
+ DBWriteWord(hContact,PluginName,optStatus,status);
+end;
+
+{$include i_search.inc}
+{$include i_bass.inc}
+{$include i_cc.inc}
+{$include i_variables.inc}
+{$include i_service.inc}
+{$include i_myservice.inc}
+{$include i_hotkey.inc}
+{$include i_frameapi.inc}
+{$include i_tray.inc}
+{$include i_visual.inc}
+{$include i_optdlg.inc}
+
+function MirandaPluginInfoEx(mirandaVersion:DWORD):PPLUGININFOEX; cdecl;
+begin
+ result:=@PluginInfo;
+ PluginInfo.cbSize :=SizeOf(TPLUGININFOEX);
+ PluginInfo.shortName :='mRadio Mod';
+ PluginInfo.version :=$00000202;
+ PluginInfo.description:='This plugin plays and records Internet radio streams.'+
+ ' Also local media files can be played.';
+ PluginInfo.author :='Awkward';
+ PluginInfo.authorEmail:='panda75@bk.ru; awk1975@ya.ru';
+ PluginInfo.copyright :='(c) 2007-2012 Awkward';
+ PluginInfo.homepage :='http://code.google.com/p/delphi-miranda-plugins/';
+ PluginInfo.flags :=UNICODE_AWARE;
+ PluginInfo.uuid :=MIID_MRADIO;
+end;
+
+function OnModulesLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+var
+ nlu:TNETLIBUSER;
+ szTemp:array [0..255] of AnsiChar;
+ i:integer;
+begin
+ UnhookEvent(onloadhook);
+
+ DBWriteDWord(0,PluginName,optVersion,PluginInfo.version);
+
+ szTemp[0]:='E';
+ szTemp[1]:='Q';
+ szTemp[2]:='_';
+ szTemp[4]:=#0;
+ for i:=0 to 9 do
+ begin
+ szTemp[3]:=AnsiChar(ORD('0')+i);
+ eq[i].param.fGain:=DBReadByte(0,PluginName,szTemp,15)-15;
+ end;
+ LoadPresets;
+
+ RegisterIcons;
+ CreateMenu;
+ CreateMIMTrayMenu;
+
+ FillChar(nlu,SizeOf(nlu),0);
+ StrCopy(szTemp,Translate('%s server connection'));
+ StrReplace(szTemp,'%s',PluginName);
+ nlu.szDescriptiveName.a:=szTemp;
+ nlu.cbSize :=SizeOf(nlu);
+ nlu.flags :=NUF_HTTPCONNS or NUF_NOHTTPSOPTION or NUF_OUTGOING;
+ nlu.szSettingsModule :=PluginName;
+ hNetLib:=CallService(MS_NETLIB_REGISTERUSER,0,tlparam(@nlu));
+
+// CallService(MS_RADIO_COMMAND,MRC_RECORD,2); record off - not so necessary
+
+ recpath:=DBReadUnicode(0,PluginName,optRecPath);
+
+ sPreBuf:=DBReadWord(0,PluginName,optPreBuf,75);
+ BASS_SetConfig(BASS_CONFIG_NET_PREBUF,sPreBuf);
+
+ sBuffer:=DBReadWord(0,PluginName,optBuffer,5000);
+ BASS_SetConfig(BASS_CONFIG_NET_BUFFER,sBuffer);
+
+ sTimeout:=DBReadWord(0,PluginName,optTimeout,5000);
+ BASS_SetConfig(BASS_CONFIG_NET_TIMEOUT,sTimeout);
+
+ doLoop :=DBReadByte(0,PluginName,optLoop);
+ doShuffle :=DBReadByte(0,PluginName,optShuffle);
+ doContRec :=DBReadByte(0,PluginName,optContRec);
+ PlayFirst :=DBReadByte(0,PluginName,optPlayFirst);
+ isEQ_OFF :=DBReadByte(0,PluginName,optEQ_OFF);
+ AuConnect :=DBReadByte(0,PluginName,optConnect);
+ AuMute :=DBReadByte(0,PluginName,optAutoMute);
+ AsOffline :=DBReadByte(0,PluginName,optOffline);
+ gVolume :=DBReadByte(0,PluginName,optVolume,50);
+ NumTries :=DBReadByte(0,PluginName,optNumTries,1);
+ ForcedMono:=DBReadByte(0,PluginName,optForcedMono);
+ if NumTries<1 then NumTries:=1;
+
+ SetStatus(0,ID_STATUS_OFFLINE);
+
+ StatusTmpl:=DBReadUnicode(0,PluginName,optStatusTmpl,'%radio_title%');
+
+ CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_NOSTATION);
+
+ IsMultiThread:=true;
+
+ RegisterVariables;
+
+ if AuConnect<>BST_UNCHECKED then
+ ActiveContact:=LoadContact(PluginName,optLastStn)
+ else
+ ActiveContact:=0;
+
+ onsetting:=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,@OnSettingsChanged);
+ ondelete :=HookEvent(ME_DB_CONTACT_DELETED ,@OnContactDeleted);
+ randomize;
+ CreateFrame(0);
+
+ RegisterHotKey;
+
+ result:=0;
+end;
+
+function PreShutdown(wParam:WPARAM;lParam:LPARAM):int;cdecl;
+{
+var
+ buf:array [0..MAX_PATH-1] of AnsiChar;
+ fdata:WIN32_FIND_DATAA;
+ p:pAnsiChar;
+ fi:THANDLE;
+}
+begin
+ RemoveTrayItems;
+
+ CallService(MS_RADIO_COMMAND,MRC_STOP,1);
+ UnregisterHotKey;
+
+ DestroyProtoServices;
+ DestroyWindow(hiddenwindow);
+ DestroyFrame();
+ MyFreeBASS;
+ DBWriteByte(0,PluginName,optVolume,gVolume);
+
+ DestroyServiceFunction(hsTrayMenu);
+ DestroyServiceFunction(hsPlayStop);
+ DestroyServiceFunction(hsRecord);
+ DestroyServiceFunction(hsSettings);
+ DestroyServiceFunction(hsSetVol);
+ DestroyServiceFunction(hsGetVol);
+ DestroyServiceFunction(hsMute);
+ DestroyServiceFunction(hsCommand);
+ DestroyServiceFunction(hsEqOnOff);
+
+ DestroyServiceFunction(hsExport);
+ DestroyServiceFunction(hsImport);
+
+ DestroyHookableEvent(hhRadioStatus);
+
+ UnhookEvent(onsetting);
+ UnhookEvent(ondelete);
+ UnhookEvent(hHookShutdown);
+ UnhookEvent(hDblClick);
+ UnhookEvent(opthook);
+ UnhookEvent(contexthook);
+
+ CallService(MS_NETLIB_CLOSEHANDLE,hNetLib,0);
+ mFreeMem(storage);
+ mFreeMem(storagep);
+ mFreeMem(recpath);
+ mFreeMem(StatusTmpl);
+ mFreeMem(basspath);
+ FreePresets;
+{
+ //delete cover files
+ buf[0]:=#0;
+ GetTempPathA(MAX_PATH,buf);
+ p:=StrEnd(buf);
+ StrCopy(p,'mrAvt*.*');
+
+ fi:=FindFirstFileA(buf,fdata);
+ if fi<>THANDLE(INVALID_HANDLE_VALUE) then
+ begin
+ repeat
+ StrCopy(p,fdata.cFileName);
+ DeleteFileA(buf);
+ until not FindNextFileA(fi,fdata);
+ FindClose(fi);
+ end;
+}
+ result:=0;
+end;
+
+function Load(): int; cdecl;
+var
+ desc:TPROTOCOLDESCRIPTOR;
+ szTemp:array [0..MAX_PATH-1] of WideChar;
+ pc:pWideChar;
+ custom:pWideChar;
+begin
+ Langpack_register;
+
+ GetModuleFileNameW(0,szTemp,MAX_PATH-1);
+ pc:=StrEndW(szTemp);
+ repeat
+ dec(pc);
+ until pc^='\';
+ inc(pc);
+ pc^:=#0;
+
+ custom:=DBReadUnicode(0,PluginName,optBASSPath,nil);
+
+ if MyLoadBASS(szTemp,custom) then
+ begin
+ StrCopyW(pc,'plugins\mradio.ini');
+// StrDup(storage,szTemp);
+ FastWideToAnsi(szTemp,storage);
+ mGetMem(storagep,MAX_PATH+32);
+ CallService(MS_DB_GETPROFILEPATH,MAX_PATH-1,lparam(storagep));
+ StrCat(storagep,'\mradio.ini');
+
+ FillChar(desc,SizeOf(desc),0);
+ desc.cbSize:=PROTOCOLDESCRIPTOR_V3_SIZE;//SizeOf(desc);
+ desc.szName:=PluginName;
+ desc._type :=PROTOTYPE_VIRTUAL;
+ CallService(MS_PROTO_REGISTERMODULE,0,lparam(@desc));
+
+ hhRadioStatus:=CreateHookableEvent(ME_RADIO_STATUS);
+
+ hsPlayStop:=CreateServiceFunction(MS_RADIO_PLAYSTOP,@Service_RadioPlayStop);
+ hsRecord :=CreateServiceFunction(MS_RADIO_RECORD ,@Service_RadioRecord);
+ hsSettings:=CreateServiceFunction(MS_RADIO_SETTINGS,@Service_RadioSettings);
+ hsSetVol :=CreateServiceFunction(MS_RADIO_SETVOL ,@Service_RadioSetVolume);
+ hsGetVol :=CreateServiceFunction(MS_RADIO_GETVOL ,@Service_RadioGetVolume);
+ hsMute :=CreateServiceFunction(MS_RADIO_MUTE ,@Service_RadioMute);
+ hsCommand :=CreateServiceFunction(MS_RADIO_COMMAND ,@ControlCenter);
+ hsEqOnOff :=CreateServiceFunction(MS_RADIO_EQONOFF ,@Service_EqOnOff);
+
+ hiddenwindow:=CreateHiddenWindow;
+ hsTrayMenu:=CreateServiceFunction(MS_RADIO_TRAYMENU,@CreateTrayMenu);
+
+ hsExport :=CreateServiceFunction(MS_RADIO_EXPORT ,@ExportAll);
+ hsImport :=CreateServiceFunction(MS_RADIO_IMPORT ,@ImportAll);
+
+
+ CreateProtoServices;
+ onloadhook :=HookEvent(ME_SYSTEM_MODULESLOADED ,@OnModulesLoaded);
+ hHookShutdown:=HookEvent(ME_SYSTEM_OKTOEXIT ,@PreShutdown);
+ hDblClick :=HookEvent(ME_CLIST_DOUBLECLICKED ,@Service_RadioPlayStop{@DblClickProc});
+ opthook :=HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise);
+ contexthook :=HookEvent(ME_CLIST_PREBUILDCONTACTMENU,@OnContactMenu);
+
+ PluginStatus:=ID_STATUS_OFFLINE;
+ end;
+ mFreeMem(custom);
+
+ Result:=0;
+end;
+
+function Unload: int; cdecl;
+begin
+ Unload_BASSDLL;
+ Result:=0;
+end;
+
+exports
+ Load, Unload,
+ MirandaPluginInfoEx;
+
+begin
+end.
diff --git a/plugins/mRadio/mradio.rc b/plugins/mRadio/mradio.rc new file mode 100644 index 0000000000..2b81408090 --- /dev/null +++ b/plugins/mRadio/mradio.rc @@ -0,0 +1,182 @@ +#include "mr_rc.inc"
+
+LANGUAGE 0,0
+
+IDD_SETTING DIALOGEX 0, 0, 304, 226, 0
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0
+{
+ GROUPBOX "Add Station",-1,1,1,200,108, WS_TABSTOP
+ LTEXT "Station Name",IDC_STATIC,6,12,192,8
+ EDITTEXT IDC_STATION,4,22,194,11,ES_AUTOHSCROLL
+ LTEXT "Station URL (required)",IDC_STATIC,6,36,178,8
+ PUSHBUTTON "...", IDC_BN_URLPATH, 184,47,14,11, BS_BOTTOM
+ EDITTEXT IDC_STATIONURL,4,47,178,11,ES_AUTOHSCROLL
+ LTEXT "Genre",IDC_STATIC,6,60,192,8
+ EDITTEXT IDC_GENRE,4,71,194,11,ES_AUTOHSCROLL
+ LTEXT "Bitrate",IDC_STATIC,6,84,46,8
+ EDITTEXT IDC_BITRATE,4,94,48,11, ES_RIGHT | ES_NUMBER
+ CTEXT "Add station",IDC_STATIC,74,84,124,8
+ PUSHBUTTON "To list", IDC_ADD_LIST, 74,94,60,11
+ PUSHBUTTON "To INI" , IDC_ADD_INI , 138,94,60,11
+
+ GROUPBOX "Record",-1,1,114,200,34, WS_TABSTOP
+ CTEXT "Record path",IDC_STATIC,4,122,194,8,SS_CENTERIMAGE
+ EDITTEXT IDC_ED_RECPATH,4,132,178,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...", IDC_BN_RECPATH, 184,132,14,12
+
+ GROUPBOX "Status Message",-1,1,152,200,70, WS_TABSTOP
+ CONTROL "V", IDC_HLP_VARS, "MButtonClass",WS_TABSTOP, 4,162,16,16,$18000000
+ RTEXT "Status message template",IDC_STATIC,22,170,174,10
+ EDITTEXT IDC_STATUS,4,180,194,40,
+ ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN
+
+ AUTOCHECKBOX "Shuffle playlist" ,IDC_SHUFFLE , 204, 4,98,22, BS_VCENTER | BS_MULTILINE
+ AUTOCHECKBOX "Play from first" ,IDC_PLAYFIRST, 204, 28,98,22, BS_VCENTER | BS_MULTILINE
+ AUTOCHECKBOX "Loop single media" ,IDC_LOOP , 204, 52,98,22, BS_VCENTER | BS_MULTILINE
+ AUTOCHECKBOX "Continuous record" ,IDC_CONTREC , 204, 76,98,22, BS_VCENTER | BS_MULTILINE
+ AUTOCHECKBOX "Autoconnect last station" ,IDC_CONNECT , 204,100,98,22, BS_VCENTER | BS_MULTILINE
+ AUTOCHECKBOX "Protocol depending status" ,IDC_OFFLINE , 204,124,98,22, BS_VCENTER | BS_MULTILINE
+ AUTOCHECKBOX "Mute with Miranda" ,IDC_AUTOMUTE , 204,148,98,22, BS_VCENTER | BS_MULTILINE
+
+ PUSHBUTTON "Import File", IDC_IMPORT, 204,188,98,16, BS_MULTILINE
+ PUSHBUTTON "Export All" , IDC_EXPORT, 204,206,98,16, BS_MULTILINE
+}
+
+IDD_SETTING_TECH DIALOGEX 0, 0, 304, 226, 0
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0
+{
+ CTEXT "Use EAX",IDC_USEEAX,2,34,72,16,SS_CENTERIMAGE
+ COMBOBOX IDC_EAXTYPE,75,34,96,75,CBS_DROPDOWNLIST | WS_VSCROLL
+
+ AUTOCHECKBOX "Forced Mono",IDC_MONO,2,52,169,16, BS_RIGHT | BS_VCENTER | BS_LEFTTEXT
+
+ CONTROL "",IDC_VOLUME,"msctls_trackbar32",TBS_NOTICKS | WS_TABSTOP|$100,19,12,129,16
+ CTEXT "min",IDC_STATIC,5,15,18,8
+ CTEXT "max",IDC_STATIC,150,15,18,8
+ GROUPBOX "Volume",-1,2,2,170,28, WS_TABSTOP
+
+ GROUPBOX "",-1,174,2,128,73, WS_TABSTOP
+ LTEXT "Buffer, ms (5000)",IDC_STATIC,210,8,90,16,SS_CENTERIMAGE
+ EDITTEXT IDC_BUFFER,178,10,30,12, ES_RIGHT | ES_NUMBER
+ LTEXT "PreBuf, % (75%)",IDC_STATIC,210,24,90,16,SS_CENTERIMAGE
+ EDITTEXT IDC_PREBUF,178,26,30,12, ES_RIGHT | ES_NUMBER
+ LTEXT "Timeout, ms (5000)",IDC_STATIC,210,40,90,16,SS_CENTERIMAGE
+ EDITTEXT IDC_TIMEOUT,178,42,30,12, ES_RIGHT | ES_NUMBER
+ LTEXT "Tries to connect",IDC_STATIC,210,56,90,16,SS_CENTERIMAGE
+ EDITTEXT IDC_TRIES,178,58,30,12, ES_RIGHT | ES_NUMBER
+
+ LTEXT "BASS library path (empty for default)",IDC_STATIC,6,76,276,14,SS_CENTERIMAGE
+ EDITTEXT IDC_BASSPATH, 2,90,284,11,ES_AUTOHSCROLL
+ PUSHBUTTON "...", IDC_BASSPTHBTN, 288,90,14,11, BS_BOTTOM
+
+ PUSHBUTTON "OFF", IDC_EQOFF,6 ,154,22,12,BS_PUSHLIKE | BS_CHECKBOX | BS_DEFPUSHBUTTON
+ PUSHBUTTON "0" ,IDC_ZERO ,9 ,171,14,13
+ RTEXT "15" ,IDC_STATIC,13,141,16,10
+ RTEXT "-15",IDC_STATIC,13,199,16,10
+
+ COMBOBOX IDC_PRESET,2,116,150,75,CBS_DROPDOWN | WS_VSCROLL
+ CONTROL "+", IDC_EQ_ADD, "MButtonClass",WS_TABSTOP, 154,114,16,16,$18000000
+ CONTROL "-", IDC_EQ_DEL, "MButtonClass",WS_TABSTOP, 174,114,16,16,$18000000
+ LTEXT "Equalizer presets",IDC_STATIC,194,114,106,16,SS_CENTERIMAGE
+
+ CTEXT "",IDC_0,34,211,16,9
+ CONTROL "",IDC_EQ00,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP, 29,136,22,75
+ CTEXT "",IDC_1,61,211,16,9
+ CONTROL "",IDC_EQ01,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP, 55,136,22,75
+ CTEXT "",IDC_2,87,211,16,9
+ CONTROL "",IDC_EQ02,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP, 81,136,22,75
+ CTEXT "",IDC_3,113,211,16,9
+ CONTROL "",IDC_EQ03,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP,107,136,22,75
+ CTEXT "",IDC_4,139,211,16,9
+ CONTROL "",IDC_EQ04,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP,133,136,22,75
+ CTEXT "",IDC_5,165,211,16,9
+ CONTROL "",IDC_EQ05,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP,159,136,22,75
+ CTEXT "",IDC_6,191,211,16,9
+ CONTROL "",IDC_EQ06,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP,185,136,22,75
+ CTEXT "",IDC_7,217,211,16,9
+ CONTROL "",IDC_EQ07,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP,211,136,22,75
+ CTEXT "",IDC_8,243,211,16,9
+ CONTROL "",IDC_EQ08,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP,237,136,22,75
+ CTEXT "",IDC_9,269,211,16,9
+ CONTROL "",IDC_EQ09,"msctls_trackbar32",TBS_LEFT|TBS_VERT|WS_TABSTOP,263,136,22,75
+ GROUPBOX "Equalizer",IDC_STATIC,2,130,298,92
+}
+
+IDD_SEARCH DIALOGEX 0, 0, 110, 140
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0
+BEGIN
+ LTEXT "Station",IDC_STATIC,8,1,98,8
+ EDITTEXT IDC_STATION,4,11,102,12,ES_AUTOHSCROLL
+ LTEXT "URL",IDC_STATIC,8,27,98,8
+ EDITTEXT IDC_STATIONURL,4,37,102,12,ES_AUTOHSCROLL
+ LTEXT "Genre",IDC_STATIC,8,53,98,8
+ EDITTEXT IDC_GENRE,4,63,102,12,ES_AUTOHSCROLL
+ LTEXT "Bitrate",IDC_STATIC,8,79,72,8
+ EDITTEXT IDC_BITRATE,4,89,76,12, ES_RIGHT | ES_NUMBER
+
+ AUTORADIOBUTTON "<",IDC_LT,86,80,20,10
+ AUTORADIOBUTTON "=",IDC_EQ,86,91,20,10
+ AUTORADIOBUTTON ">",IDC_GT,86,102,20,10
+
+ LTEXT "Custom INI file",IDC_STATIC,8,112,98,8
+ EDITTEXT IDC_CUSTOMINI,4,122,84,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",IDC_BN_INIPATH, 90,122,14,12
+END
+
+// just for frame API version
+IDD_FRAME DIALOGEX 0, 0, 114, 16, 0
+STYLE DS_SETFONT | WS_CHILD | DS_FIXEDSYS | WS_VISIBLE
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0
+BEGIN
+ CONTROL "" ,IDC_RADIO_VOL ,"msctls_trackbar32", TBS_BOTTOM|TBS_NOTICKS|$100,0,2,98,11
+// CONTROL "*",IDC_RADIO_MUTE,"MButtonClass" ,WS_TABSTOP,100,1,12,12//,$18000000
+ PUSHBUTTON "*" ,IDC_RADIO_MUTE, 100,1,12,12,
+ BS_OWNERDRAW
+// BS_FLAT | BS_ICON | BS_PUSHLIKE | BS_CHECKBOX | BS_DEFPUSHBUTTON | BS_CENTER | BS_VCENTER
+END
+
+
+IDI_MAIN ICON "ico\mradio.ico"
+IDI_ON ICON "ico\on.ico"
+IDI_OFF ICON "ico\off.ico"
+IDI_ADD ICON "ico\new.ico"
+IDI_DEL ICON "ico\delete.ico"
+BTN_RECUP ICON "ico\recon.ico"
+BTN_RECDN ICON "ico\recoff.ico"
+
+LANGUAGE 0,0
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 0,0,2,2
+ PRODUCTVERSION 0,0,8,0
+ FILEFLAGSMASK $3F
+ FILEOS 4
+ FILETYPE 2
+ FILESUBTYPE 0
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "CompanyName",""0
+ VALUE "Comments", "Plugin to play Internet radio"0
+ VALUE "FileDescription", "mRadio Mod plugin for Miranda NG"0
+ VALUE "FileVersion", "0, 0, 2, 2 "0
+ VALUE "InternalName", "mRadio Mod"0
+ VALUE "OriginalFilename", "mradio.dll"0
+ VALUE "ProductName", "mRadio Mod Dynamic Link Library (DLL)"0
+ VALUE "ProductVersion", "0, 0, 8, 0 "0
+ VALUE "SpecialBuild", "10.05.2012 "0
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation",0,1200
+ END
+END
diff --git a/plugins/mRadio/mradio.res b/plugins/mRadio/mradio.res Binary files differnew file mode 100644 index 0000000000..10d008f143 --- /dev/null +++ b/plugins/mRadio/mradio.res diff --git a/plugins/mRadio/proto_mradio/Proto_mRadio.vcxproj b/plugins/mRadio/proto_mradio/Proto_mRadio.vcxproj new file mode 100644 index 0000000000..f78dc543ae --- /dev/null +++ b/plugins/mRadio/proto_mradio/Proto_mRadio.vcxproj @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{2BCC460C-E7C0-4AA8-B680-B9DE561A8408}</ProjectGuid>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Icons\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Icons\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <NoEntryPoint>true</NoEntryPoint>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalLibraryDirectories>$(SolutionDir)\lib</AdditionalLibraryDirectories>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/mRadio/proto_mradio/Proto_mRadio.vcxproj.filters b/plugins/mRadio/proto_mradio/Proto_mRadio.vcxproj.filters new file mode 100644 index 0000000000..adb1b35427 --- /dev/null +++ b/plugins/mRadio/proto_mradio/Proto_mRadio.vcxproj.filters @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\resource.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/plugins/mRadio/proto_mradio/res/proto_away.ico b/plugins/mRadio/proto_mradio/res/proto_away.ico Binary files differnew file mode 100644 index 0000000000..f9d97408f8 --- /dev/null +++ b/plugins/mRadio/proto_mradio/res/proto_away.ico diff --git a/plugins/mRadio/proto_mradio/res/proto_invisible.ico b/plugins/mRadio/proto_mradio/res/proto_invisible.ico Binary files differnew file mode 100644 index 0000000000..6a868bc106 --- /dev/null +++ b/plugins/mRadio/proto_mradio/res/proto_invisible.ico diff --git a/plugins/mRadio/proto_mradio/res/proto_offline.ico b/plugins/mRadio/proto_mradio/res/proto_offline.ico Binary files differnew file mode 100644 index 0000000000..5a7e6172ac --- /dev/null +++ b/plugins/mRadio/proto_mradio/res/proto_offline.ico diff --git a/plugins/mRadio/proto_mradio/res/proto_online.ico b/plugins/mRadio/proto_mradio/res/proto_online.ico Binary files differnew file mode 100644 index 0000000000..53f13cddca --- /dev/null +++ b/plugins/mRadio/proto_mradio/res/proto_online.ico diff --git a/plugins/mRadio/proto_mradio/res/resource.rc b/plugins/mRadio/proto_mradio/res/resource.rc new file mode 100644 index 0000000000..43ad52b944 --- /dev/null +++ b/plugins/mRadio/proto_mradio/res/resource.rc @@ -0,0 +1,37 @@ +//Microsoft Developer Studio generated resource script.
+//
+
+#include "..\src\resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON1 ICON "proto_online.ico"
+IDI_ICON2 ICON "proto_offline.ico"
+IDI_ICON3 ICON "proto_away.ico"
+IDI_ICON4 ICON "proto_invisible.ico"
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
\ No newline at end of file diff --git a/plugins/mRadio/proto_mradio/src/resource.h b/plugins/mRadio/proto_mradio/src/resource.h Binary files differnew file mode 100644 index 0000000000..d425e7b8b1 --- /dev/null +++ b/plugins/mRadio/proto_mradio/src/resource.h diff --git a/plugins/mRadio/readme.txt b/plugins/mRadio/readme.txt new file mode 100644 index 0000000000..ea111e1056 --- /dev/null +++ b/plugins/mRadio/readme.txt @@ -0,0 +1,147 @@ +Description:
+------------
+This plugin plays and records Internet radio streams. Also local media files can be played.
+
+This is not 'clear' mod of mRadio plugin from Bankrut.
+So, some things can be different or even uncomplete.
+
+Notes:
+------
+1) Supported formats
+BASS library support plugins, so format list can be expanded.
+BASS.dll give support for MP3 and OGG formats
+BASSWMA.dll give WMA/ASX stream support
+PLS (ansi), M3U (old and new format, ansi), M3U8 (old and new format utf8) supported.
+This is plugin processing and now all strings converted to ansi.
+
+2) Tooltip templates
+Tipper template:
+Common status message (not only mRadio): %sys:status_msg%
+also you can check CList/StatusMsg or StationURL values.
+
+mToolTip templates:
+[Station_Codec]
+DBSub=mRadio
+DBSet=ActiveCodec
+
+[Station_URL]
+DBSub=mRadio
+DBSet=StationURL
+
+[Station_Bitrate]
+DBSub=mRadio
+DBSet=Bitrate
+
+[Station_Genre]
+DBSub=mRadio
+DBSet=Genre
+
+3) Different info
+ WMA stations don't recorded, only MP3 and OGG stream record tested.
+ Not all metatags supported.
+ Manual proxy settings supported.
+ BASS Plugins loading ONLY when protocol going Online
+
+Changelog:
+----------
+0.0.2.1 ()
+ 64 bit compatibility fix
+ new event notifications
+0.0.2.0 (19 mar 2011)
+ Adapted for FreePascal and 64 bit support
+0.0.1.7 ()
+ Added internet radio reconnect on track end
+ Added button to import all radiostations from file
+ Added frame right-click action "Open mradio settings"
+ Improved frame coloration
+ Added Frame (1st try)
+ Added another WMA stream processing
+ Added option for several tries to connect radiostation
+0.0.1.6 (20 sep 2010)
+ Changed streams/files tag process
+0.0.1.5 (6 sep 2010)
+ Fixed simple form of M3U playlist reading
+ Improved compatibility with Watrack plugin
+ Restored ANSI URL processing if no Unicode possible (especially for BASSWMA)
+ Fixed group choosing for "Add to List" of new stations
+ Fixed some memory leaks
+ Changed proxy processing to ability to use IE settings (through miranda proxy settings)
+ Fixed crash when contact goin offline (Offline as offline setting)
+ Code changed to BASS 2.4.6 support (unicode URL support)
+0.0.1.4 ()
+ Added event ME_RADIO_STATUS
+ Added Variables plugin parsing for record filename
+ Added ability to choose BASS.dll placement
+ Radio stopping now if active contact deleting
+ Added services for import/export stations
+0.0.1.3 (15 oct 2009)
+ Radio record filename must calc from media info
+ Radio record fixed
+0.0.1.2 (15 oct 2009)
+ Added equalizer preset work
+ "Record" crash fixed
+ Added changing icon in contact menu for start/stop broadcasting
+0.0.1.1 (10 oct 2009)
+ Added option to export all radio station from list to choosed INI-file
+0.0.1.0 ()
+ Fixed UTF8 station track info showing
+ Dropped ANSI and pre-0.7 Miranda IM version support
+0.0.0.15 (14 jan 2008)
+ Toolbar button to switch sound on/off affect now on mRadio sound
+ Added 'radio_codec' variable
+ Added GUID to header files
+ Added option to show offline stations as Offline (not invisible)
+ Added option to autconnect last played station
+0.0.0.14 ( nov 2007)
+ Fixed: record directory not created if it not exists
+ Fixed: Database hook error
+ Station choosing change plugin status from Offline to Online
+ Fixed: last played track wrongly restored at start
+0.0.0.13 (24 jun 2007)
+ Added notification for 'Work Offline' IE mode
+ New option for network timeout
+0.0.0.12 (20 jun 2007)
+ Small fixes
+ Added Unicode for file select dialog in Options
+0.0.0.11 (18 jun 2007)
+ Added test unicode support (can work wrong)
+ Added ability to change INI-file for station search
+ Changed search interface for Miranda version 0.7+
+ Added button to switch equalizer off
+ Options interface changed
+0.0.0.10 (13 jun 2007)
+ Added partial SHOUTcast metatags support
+ Added playing station status info
+0.0.0.9 (10 jun 2007)
+ Added support old and new ANSI and UTF8 M3U (M3U8) playlists
+ Added relative pathnames in playlist support
+0.0.0.8 (9 jun 2007)
+ Added partial updater support
+ Small fixes
+ Added new option for playlist
+0.0.0.7 (7 jun 2007)
+ Fixed: equalizer values was reversed
+ Added PLS and M3U playlist support
+ Code changes
+0.0.0.6 (3 jun 2007)
+ Fixed: Global volume (not music only) used
+ Fixed: Can't break slowly connected stations
+0.0.0.5 (2 jun 2007)
+ Fixed: Double click contact dialog can't open
+ Changed: OGG station stream saving
+0.0.0.4 (1 jun 2007)
+ Small Radio station search dialog adaptation for 0.7 and 0.6 Miranda versions
+ Added volume control synchronization with SndVol
+ Added option to repeat media
+ Added global 'Record' menu item to contact menu
+ Fixed: exit while online Radio status make crash
+ Added: Equalizer
+0.0.0.3 (30 may 2007)
+ Added UserInfoEx (station editing) compatibility
+ Code cleaning and optimization
+ Convert to (2 in 1)
+0.0.0.2 (30 may 2007)
+ Added Variables plugin support
+ Added Buffer size changing ability
+0.0.0.1 (29 may 2007)
+ First release
diff --git a/plugins/mRadio/variants.pas b/plugins/mRadio/variants.pas new file mode 100644 index 0000000000..c7c8fdc824 --- /dev/null +++ b/plugins/mRadio/variants.pas @@ -0,0 +1,7 @@ +unit variants;
+
+interface
+
+implementation
+
+end.
\ No newline at end of file |