From 23729c4f6a62de7a71368ffdeeeb08470ff4731e Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 25 Jul 2018 09:14:43 +0300 Subject: Quotes renamed to CurrencyRates --- bin15/mir_full.sln | 2 +- bin15/mir_icons.sln | 2 +- plugins/CurrencyRates/Forex.vcxproj | 36 + plugins/CurrencyRates/Forex.vcxproj.filters | 4 + .../CurrencyRates/QuotesChart/Form1.Designer.cs | 123 +++ plugins/CurrencyRates/QuotesChart/Form1.cs | 155 +++ plugins/CurrencyRates/QuotesChart/Form1.resx | 216 +++++ plugins/CurrencyRates/QuotesChart/Program.cs | 21 + .../QuotesChart/Properties/AssemblyInfo.cs | 36 + .../QuotesChart/Properties/Resources.Designer.cs | 63 ++ .../QuotesChart/Properties/Resources.resx | 117 +++ .../QuotesChart/Properties/Settings.Designer.cs | 26 + .../QuotesChart/Properties/Settings.settings | 7 + .../CurrencyRates/QuotesChart/QuotesChart.csproj | 124 +++ plugins/CurrencyRates/QuotesChart/app.config | 3 + .../QuotesChart/bin/x32/QuotesChart.exe | Bin 0 -> 23552 bytes .../QuotesChart/bin/x64/QuotesChart.exe | Bin 0 -> 23040 bytes plugins/CurrencyRates/QuotesChart/main.ico | Bin 0 -> 5430 bytes plugins/CurrencyRates/docs/Utility/cc.xml | 518 ++++++++++ .../proto_CurrencyRates.vcxproj | 28 + .../proto_CurrencyRates.vcxproj.filters | 4 + .../proto_CurrencyRates/res/proto_CurrencyRates.rc | 121 +++ .../proto_CurrencyRates/res/proto_na.ico | Bin 0 -> 5430 bytes .../proto_CurrencyRates/res/proto_offline.ico | Bin 0 -> 5430 bytes .../proto_CurrencyRates/res/proto_online.ico | Bin 0 -> 5430 bytes plugins/CurrencyRates/res/AutoUpdateDisabled.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/res/CurrencyConverter.ico | Bin 0 -> 5430 bytes plugins/CurrencyRates/res/Export quotes.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/res/Forex.rc | 369 +++++++ plugins/CurrencyRates/res/Import quotes.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/res/Refresh.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/res/Section.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/res/Version.rc | 9 + plugins/CurrencyRates/res/down.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/res/main.ico | Bin 0 -> 5430 bytes plugins/CurrencyRates/res/notchanged.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/res/quote.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/res/swap.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/res/up.ico | Bin 0 -> 1150 bytes plugins/CurrencyRates/src/Chart.h | 280 ++++++ plugins/CurrencyRates/src/ComHelper.cpp | 28 + plugins/CurrencyRates/src/ComHelper.h | 7 + plugins/CurrencyRates/src/CommonOptionDlg.cpp | 228 +++++ plugins/CurrencyRates/src/CommonOptionDlg.h | 17 + plugins/CurrencyRates/src/CreateFilePath.cpp | 33 + plugins/CurrencyRates/src/CreateFilePath.h | 6 + plugins/CurrencyRates/src/CurrencyConverter.cpp | 266 +++++ plugins/CurrencyRates/src/CurrencyConverter.h | 6 + plugins/CurrencyRates/src/DBUtils.cpp | 47 + plugins/CurrencyRates/src/DBUtils.h | 13 + plugins/CurrencyRates/src/EconomicRateInfo.h | 59 ++ plugins/CurrencyRates/src/ExtraImages.cpp | 30 + plugins/CurrencyRates/src/ExtraImages.h | 16 + plugins/CurrencyRates/src/Forex.cpp | 337 +++++++ plugins/CurrencyRates/src/HTMLParserMS.cpp | 254 +++++ plugins/CurrencyRates/src/HTMLParserMS.h | 32 + plugins/CurrencyRates/src/HTTPSession.cpp | 150 +++ plugins/CurrencyRates/src/HTTPSession.h | 25 + plugins/CurrencyRates/src/IHTMLEngine.h | 18 + plugins/CurrencyRates/src/IHTMLParser.h | 41 + plugins/CurrencyRates/src/IQuotesProvider.h | 39 + plugins/CurrencyRates/src/IXMLEngine.h | 43 + plugins/CurrencyRates/src/IconLib.cpp | 40 + plugins/CurrencyRates/src/IconLib.h | 11 + plugins/CurrencyRates/src/ImportExport.cpp | 635 ++++++++++++ plugins/CurrencyRates/src/ImportExport.h | 9 + plugins/CurrencyRates/src/IsWithinAccuracy.h | 15 + plugins/CurrencyRates/src/Locale.cpp | 59 ++ plugins/CurrencyRates/src/Locale.h | 9 + plugins/CurrencyRates/src/Log.cpp | 41 + plugins/CurrencyRates/src/Log.h | 13 + plugins/CurrencyRates/src/ModuleInfo.cpp | 99 ++ plugins/CurrencyRates/src/ModuleInfo.h | 41 + plugins/CurrencyRates/src/QuoteChart.cpp | 101 ++ plugins/CurrencyRates/src/QuoteChart.h | 12 + plugins/CurrencyRates/src/QuoteInfoDlg.cpp | 263 +++++ plugins/CurrencyRates/src/QuoteInfoDlg.h | 11 + plugins/CurrencyRates/src/QuotesProviderBase.cpp | 883 +++++++++++++++++ plugins/CurrencyRates/src/QuotesProviderBase.h | 119 +++ .../src/QuotesProviderCurrencyConverter.cpp | 425 ++++++++ .../src/QuotesProviderCurrencyConverter.h | 29 + plugins/CurrencyRates/src/QuotesProviderVisitor.h | 25 + .../src/QuotesProviderVisitorDbSettings.cpp | 70 ++ .../src/QuotesProviderVisitorDbSettings.h | 44 + .../QuotesProviderVisitorFormatSpecificator.cpp | 62 ++ .../src/QuotesProviderVisitorFormatSpecificator.h | 33 + .../src/QuotesProviderVisitorFormater.cpp | 122 +++ .../src/QuotesProviderVisitorFormater.h | 27 + .../src/QuotesProviderVisitorTendency.cpp | 24 + .../src/QuotesProviderVisitorTendency.h | 25 + plugins/CurrencyRates/src/QuotesProviders.cpp | 90 ++ plugins/CurrencyRates/src/QuotesProviders.h | 29 + plugins/CurrencyRates/src/SettingsDlg.cpp | 1023 ++++++++++++++++++++ plugins/CurrencyRates/src/SettingsDlg.h | 118 +++ plugins/CurrencyRates/src/WinCtrlHelper.cpp | 40 + plugins/CurrencyRates/src/WinCtrlHelper.h | 37 + plugins/CurrencyRates/src/XMLEngineMI.cpp | 163 ++++ plugins/CurrencyRates/src/XMLEngineMI.h | 15 + plugins/CurrencyRates/src/resource.h | 100 ++ plugins/CurrencyRates/src/stdafx.cxx | 18 + plugins/CurrencyRates/src/stdafx.h | 119 +++ plugins/CurrencyRates/src/version.h | 13 + plugins/ExternalAPI/m_CurrencyRates.h | 35 + plugins/ExternalAPI/m_Quotes.h | 35 - plugins/PluginUpdater/src/DlgUpdate.cpp | 2 + plugins/Quotes/Forex.vcxproj | 36 - plugins/Quotes/Forex.vcxproj.filters | 4 - plugins/Quotes/QuotesChart/Form1.Designer.cs | 123 --- plugins/Quotes/QuotesChart/Form1.cs | 155 --- plugins/Quotes/QuotesChart/Form1.resx | 216 ----- plugins/Quotes/QuotesChart/Program.cs | 21 - .../Quotes/QuotesChart/Properties/AssemblyInfo.cs | 36 - .../QuotesChart/Properties/Resources.Designer.cs | 63 -- .../Quotes/QuotesChart/Properties/Resources.resx | 117 --- .../QuotesChart/Properties/Settings.Designer.cs | 26 - .../QuotesChart/Properties/Settings.settings | 7 - plugins/Quotes/QuotesChart/QuotesChart.csproj | 124 --- plugins/Quotes/QuotesChart/app.config | 3 - plugins/Quotes/QuotesChart/bin/x32/QuotesChart.exe | Bin 23552 -> 0 bytes plugins/Quotes/QuotesChart/bin/x64/QuotesChart.exe | Bin 23040 -> 0 bytes plugins/Quotes/QuotesChart/main.ico | Bin 5430 -> 0 bytes plugins/Quotes/docs/Utility/cc.xml | 518 ---------- plugins/Quotes/proto_Quotes/proto_Quotes.vcxproj | 28 - .../proto_Quotes/proto_Quotes.vcxproj.filters | 4 - plugins/Quotes/proto_Quotes/res/proto_Quotes.rc | 121 --- plugins/Quotes/proto_Quotes/res/proto_na.ico | Bin 5430 -> 0 bytes plugins/Quotes/proto_Quotes/res/proto_offline.ico | Bin 5430 -> 0 bytes plugins/Quotes/proto_Quotes/res/proto_online.ico | Bin 5430 -> 0 bytes plugins/Quotes/res/AutoUpdateDisabled.ico | Bin 1150 -> 0 bytes plugins/Quotes/res/CurrencyConverter.ico | Bin 5430 -> 0 bytes plugins/Quotes/res/Export quotes.ico | Bin 1150 -> 0 bytes plugins/Quotes/res/Forex.rc | 369 ------- plugins/Quotes/res/Import quotes.ico | Bin 1150 -> 0 bytes plugins/Quotes/res/Refresh.ico | Bin 1150 -> 0 bytes plugins/Quotes/res/Section.ico | Bin 1150 -> 0 bytes plugins/Quotes/res/Version.rc | 9 - plugins/Quotes/res/down.ico | Bin 1150 -> 0 bytes plugins/Quotes/res/main.ico | Bin 5430 -> 0 bytes plugins/Quotes/res/notchanged.ico | Bin 1150 -> 0 bytes plugins/Quotes/res/quote.ico | Bin 1150 -> 0 bytes plugins/Quotes/res/swap.ico | Bin 1150 -> 0 bytes plugins/Quotes/res/up.ico | Bin 1150 -> 0 bytes plugins/Quotes/src/Chart.h | 280 ------ plugins/Quotes/src/ComHelper.cpp | 28 - plugins/Quotes/src/ComHelper.h | 7 - plugins/Quotes/src/CommonOptionDlg.cpp | 228 ----- plugins/Quotes/src/CommonOptionDlg.h | 17 - plugins/Quotes/src/CreateFilePath.cpp | 33 - plugins/Quotes/src/CreateFilePath.h | 6 - plugins/Quotes/src/CurrencyConverter.cpp | 266 ----- plugins/Quotes/src/CurrencyConverter.h | 6 - plugins/Quotes/src/DBUtils.cpp | 47 - plugins/Quotes/src/DBUtils.h | 13 - plugins/Quotes/src/EconomicRateInfo.h | 59 -- plugins/Quotes/src/ExtraImages.cpp | 30 - plugins/Quotes/src/ExtraImages.h | 16 - plugins/Quotes/src/Forex.cpp | 337 ------- plugins/Quotes/src/HTMLParserMS.cpp | 254 ----- plugins/Quotes/src/HTMLParserMS.h | 32 - plugins/Quotes/src/HTTPSession.cpp | 150 --- plugins/Quotes/src/HTTPSession.h | 25 - plugins/Quotes/src/IHTMLEngine.h | 18 - plugins/Quotes/src/IHTMLParser.h | 41 - plugins/Quotes/src/IQuotesProvider.h | 39 - plugins/Quotes/src/IXMLEngine.h | 43 - plugins/Quotes/src/IconLib.cpp | 40 - plugins/Quotes/src/IconLib.h | 11 - plugins/Quotes/src/ImportExport.cpp | 635 ------------ plugins/Quotes/src/ImportExport.h | 9 - plugins/Quotes/src/IsWithinAccuracy.h | 15 - plugins/Quotes/src/Locale.cpp | 59 -- plugins/Quotes/src/Locale.h | 9 - plugins/Quotes/src/Log.cpp | 41 - plugins/Quotes/src/Log.h | 13 - plugins/Quotes/src/ModuleInfo.cpp | 99 -- plugins/Quotes/src/ModuleInfo.h | 41 - plugins/Quotes/src/QuoteChart.cpp | 101 -- plugins/Quotes/src/QuoteChart.h | 12 - plugins/Quotes/src/QuoteInfoDlg.cpp | 263 ----- plugins/Quotes/src/QuoteInfoDlg.h | 11 - plugins/Quotes/src/QuotesProviderBase.cpp | 883 ----------------- plugins/Quotes/src/QuotesProviderBase.h | 119 --- .../Quotes/src/QuotesProviderCurrencyConverter.cpp | 425 -------- .../Quotes/src/QuotesProviderCurrencyConverter.h | 29 - plugins/Quotes/src/QuotesProviderVisitor.h | 25 - .../Quotes/src/QuotesProviderVisitorDbSettings.cpp | 70 -- .../Quotes/src/QuotesProviderVisitorDbSettings.h | 44 - .../QuotesProviderVisitorFormatSpecificator.cpp | 62 -- .../src/QuotesProviderVisitorFormatSpecificator.h | 33 - .../Quotes/src/QuotesProviderVisitorFormater.cpp | 122 --- plugins/Quotes/src/QuotesProviderVisitorFormater.h | 27 - .../Quotes/src/QuotesProviderVisitorTendency.cpp | 24 - plugins/Quotes/src/QuotesProviderVisitorTendency.h | 25 - plugins/Quotes/src/QuotesProviders.cpp | 90 -- plugins/Quotes/src/QuotesProviders.h | 29 - plugins/Quotes/src/SettingsDlg.cpp | 1023 -------------------- plugins/Quotes/src/SettingsDlg.h | 118 --- plugins/Quotes/src/WinCtrlHelper.cpp | 40 - plugins/Quotes/src/WinCtrlHelper.h | 37 - plugins/Quotes/src/XMLEngineMI.cpp | 163 ---- plugins/Quotes/src/XMLEngineMI.h | 15 - plugins/Quotes/src/resource.h | 100 -- plugins/Quotes/src/stdafx.cxx | 18 - plugins/Quotes/src/stdafx.h | 119 --- plugins/Quotes/src/version.h | 13 - 205 files changed, 9006 insertions(+), 9004 deletions(-) create mode 100644 plugins/CurrencyRates/Forex.vcxproj create mode 100644 plugins/CurrencyRates/Forex.vcxproj.filters create mode 100644 plugins/CurrencyRates/QuotesChart/Form1.Designer.cs create mode 100644 plugins/CurrencyRates/QuotesChart/Form1.cs create mode 100644 plugins/CurrencyRates/QuotesChart/Form1.resx create mode 100644 plugins/CurrencyRates/QuotesChart/Program.cs create mode 100644 plugins/CurrencyRates/QuotesChart/Properties/AssemblyInfo.cs create mode 100644 plugins/CurrencyRates/QuotesChart/Properties/Resources.Designer.cs create mode 100644 plugins/CurrencyRates/QuotesChart/Properties/Resources.resx create mode 100644 plugins/CurrencyRates/QuotesChart/Properties/Settings.Designer.cs create mode 100644 plugins/CurrencyRates/QuotesChart/Properties/Settings.settings create mode 100644 plugins/CurrencyRates/QuotesChart/QuotesChart.csproj create mode 100644 plugins/CurrencyRates/QuotesChart/app.config create mode 100644 plugins/CurrencyRates/QuotesChart/bin/x32/QuotesChart.exe create mode 100644 plugins/CurrencyRates/QuotesChart/bin/x64/QuotesChart.exe create mode 100644 plugins/CurrencyRates/QuotesChart/main.ico create mode 100644 plugins/CurrencyRates/docs/Utility/cc.xml create mode 100644 plugins/CurrencyRates/proto_CurrencyRates/proto_CurrencyRates.vcxproj create mode 100644 plugins/CurrencyRates/proto_CurrencyRates/proto_CurrencyRates.vcxproj.filters create mode 100644 plugins/CurrencyRates/proto_CurrencyRates/res/proto_CurrencyRates.rc create mode 100644 plugins/CurrencyRates/proto_CurrencyRates/res/proto_na.ico create mode 100644 plugins/CurrencyRates/proto_CurrencyRates/res/proto_offline.ico create mode 100644 plugins/CurrencyRates/proto_CurrencyRates/res/proto_online.ico create mode 100644 plugins/CurrencyRates/res/AutoUpdateDisabled.ico create mode 100644 plugins/CurrencyRates/res/CurrencyConverter.ico create mode 100644 plugins/CurrencyRates/res/Export quotes.ico create mode 100644 plugins/CurrencyRates/res/Forex.rc create mode 100644 plugins/CurrencyRates/res/Import quotes.ico create mode 100644 plugins/CurrencyRates/res/Refresh.ico create mode 100644 plugins/CurrencyRates/res/Section.ico create mode 100644 plugins/CurrencyRates/res/Version.rc create mode 100644 plugins/CurrencyRates/res/down.ico create mode 100644 plugins/CurrencyRates/res/main.ico create mode 100644 plugins/CurrencyRates/res/notchanged.ico create mode 100644 plugins/CurrencyRates/res/quote.ico create mode 100644 plugins/CurrencyRates/res/swap.ico create mode 100644 plugins/CurrencyRates/res/up.ico create mode 100644 plugins/CurrencyRates/src/Chart.h create mode 100644 plugins/CurrencyRates/src/ComHelper.cpp create mode 100644 plugins/CurrencyRates/src/ComHelper.h create mode 100644 plugins/CurrencyRates/src/CommonOptionDlg.cpp create mode 100644 plugins/CurrencyRates/src/CommonOptionDlg.h create mode 100644 plugins/CurrencyRates/src/CreateFilePath.cpp create mode 100644 plugins/CurrencyRates/src/CreateFilePath.h create mode 100644 plugins/CurrencyRates/src/CurrencyConverter.cpp create mode 100644 plugins/CurrencyRates/src/CurrencyConverter.h create mode 100644 plugins/CurrencyRates/src/DBUtils.cpp create mode 100644 plugins/CurrencyRates/src/DBUtils.h create mode 100644 plugins/CurrencyRates/src/EconomicRateInfo.h create mode 100644 plugins/CurrencyRates/src/ExtraImages.cpp create mode 100644 plugins/CurrencyRates/src/ExtraImages.h create mode 100644 plugins/CurrencyRates/src/Forex.cpp create mode 100644 plugins/CurrencyRates/src/HTMLParserMS.cpp create mode 100644 plugins/CurrencyRates/src/HTMLParserMS.h create mode 100644 plugins/CurrencyRates/src/HTTPSession.cpp create mode 100644 plugins/CurrencyRates/src/HTTPSession.h create mode 100644 plugins/CurrencyRates/src/IHTMLEngine.h create mode 100644 plugins/CurrencyRates/src/IHTMLParser.h create mode 100644 plugins/CurrencyRates/src/IQuotesProvider.h create mode 100644 plugins/CurrencyRates/src/IXMLEngine.h create mode 100644 plugins/CurrencyRates/src/IconLib.cpp create mode 100644 plugins/CurrencyRates/src/IconLib.h create mode 100644 plugins/CurrencyRates/src/ImportExport.cpp create mode 100644 plugins/CurrencyRates/src/ImportExport.h create mode 100644 plugins/CurrencyRates/src/IsWithinAccuracy.h create mode 100644 plugins/CurrencyRates/src/Locale.cpp create mode 100644 plugins/CurrencyRates/src/Locale.h create mode 100644 plugins/CurrencyRates/src/Log.cpp create mode 100644 plugins/CurrencyRates/src/Log.h create mode 100644 plugins/CurrencyRates/src/ModuleInfo.cpp create mode 100644 plugins/CurrencyRates/src/ModuleInfo.h create mode 100644 plugins/CurrencyRates/src/QuoteChart.cpp create mode 100644 plugins/CurrencyRates/src/QuoteChart.h create mode 100644 plugins/CurrencyRates/src/QuoteInfoDlg.cpp create mode 100644 plugins/CurrencyRates/src/QuoteInfoDlg.h create mode 100644 plugins/CurrencyRates/src/QuotesProviderBase.cpp create mode 100644 plugins/CurrencyRates/src/QuotesProviderBase.h create mode 100644 plugins/CurrencyRates/src/QuotesProviderCurrencyConverter.cpp create mode 100644 plugins/CurrencyRates/src/QuotesProviderCurrencyConverter.h create mode 100644 plugins/CurrencyRates/src/QuotesProviderVisitor.h create mode 100644 plugins/CurrencyRates/src/QuotesProviderVisitorDbSettings.cpp create mode 100644 plugins/CurrencyRates/src/QuotesProviderVisitorDbSettings.h create mode 100644 plugins/CurrencyRates/src/QuotesProviderVisitorFormatSpecificator.cpp create mode 100644 plugins/CurrencyRates/src/QuotesProviderVisitorFormatSpecificator.h create mode 100644 plugins/CurrencyRates/src/QuotesProviderVisitorFormater.cpp create mode 100644 plugins/CurrencyRates/src/QuotesProviderVisitorFormater.h create mode 100644 plugins/CurrencyRates/src/QuotesProviderVisitorTendency.cpp create mode 100644 plugins/CurrencyRates/src/QuotesProviderVisitorTendency.h create mode 100644 plugins/CurrencyRates/src/QuotesProviders.cpp create mode 100644 plugins/CurrencyRates/src/QuotesProviders.h create mode 100644 plugins/CurrencyRates/src/SettingsDlg.cpp create mode 100644 plugins/CurrencyRates/src/SettingsDlg.h create mode 100644 plugins/CurrencyRates/src/WinCtrlHelper.cpp create mode 100644 plugins/CurrencyRates/src/WinCtrlHelper.h create mode 100644 plugins/CurrencyRates/src/XMLEngineMI.cpp create mode 100644 plugins/CurrencyRates/src/XMLEngineMI.h create mode 100644 plugins/CurrencyRates/src/resource.h create mode 100644 plugins/CurrencyRates/src/stdafx.cxx create mode 100644 plugins/CurrencyRates/src/stdafx.h create mode 100644 plugins/CurrencyRates/src/version.h create mode 100644 plugins/ExternalAPI/m_CurrencyRates.h delete mode 100644 plugins/ExternalAPI/m_Quotes.h delete mode 100644 plugins/Quotes/Forex.vcxproj delete mode 100644 plugins/Quotes/Forex.vcxproj.filters delete mode 100644 plugins/Quotes/QuotesChart/Form1.Designer.cs delete mode 100644 plugins/Quotes/QuotesChart/Form1.cs delete mode 100644 plugins/Quotes/QuotesChart/Form1.resx delete mode 100644 plugins/Quotes/QuotesChart/Program.cs delete mode 100644 plugins/Quotes/QuotesChart/Properties/AssemblyInfo.cs delete mode 100644 plugins/Quotes/QuotesChart/Properties/Resources.Designer.cs delete mode 100644 plugins/Quotes/QuotesChart/Properties/Resources.resx delete mode 100644 plugins/Quotes/QuotesChart/Properties/Settings.Designer.cs delete mode 100644 plugins/Quotes/QuotesChart/Properties/Settings.settings delete mode 100644 plugins/Quotes/QuotesChart/QuotesChart.csproj delete mode 100644 plugins/Quotes/QuotesChart/app.config delete mode 100644 plugins/Quotes/QuotesChart/bin/x32/QuotesChart.exe delete mode 100644 plugins/Quotes/QuotesChart/bin/x64/QuotesChart.exe delete mode 100644 plugins/Quotes/QuotesChart/main.ico delete mode 100644 plugins/Quotes/docs/Utility/cc.xml delete mode 100644 plugins/Quotes/proto_Quotes/proto_Quotes.vcxproj delete mode 100644 plugins/Quotes/proto_Quotes/proto_Quotes.vcxproj.filters delete mode 100644 plugins/Quotes/proto_Quotes/res/proto_Quotes.rc delete mode 100644 plugins/Quotes/proto_Quotes/res/proto_na.ico delete mode 100644 plugins/Quotes/proto_Quotes/res/proto_offline.ico delete mode 100644 plugins/Quotes/proto_Quotes/res/proto_online.ico delete mode 100644 plugins/Quotes/res/AutoUpdateDisabled.ico delete mode 100644 plugins/Quotes/res/CurrencyConverter.ico delete mode 100644 plugins/Quotes/res/Export quotes.ico delete mode 100644 plugins/Quotes/res/Forex.rc delete mode 100644 plugins/Quotes/res/Import quotes.ico delete mode 100644 plugins/Quotes/res/Refresh.ico delete mode 100644 plugins/Quotes/res/Section.ico delete mode 100644 plugins/Quotes/res/Version.rc delete mode 100644 plugins/Quotes/res/down.ico delete mode 100644 plugins/Quotes/res/main.ico delete mode 100644 plugins/Quotes/res/notchanged.ico delete mode 100644 plugins/Quotes/res/quote.ico delete mode 100644 plugins/Quotes/res/swap.ico delete mode 100644 plugins/Quotes/res/up.ico delete mode 100644 plugins/Quotes/src/Chart.h delete mode 100644 plugins/Quotes/src/ComHelper.cpp delete mode 100644 plugins/Quotes/src/ComHelper.h delete mode 100644 plugins/Quotes/src/CommonOptionDlg.cpp delete mode 100644 plugins/Quotes/src/CommonOptionDlg.h delete mode 100644 plugins/Quotes/src/CreateFilePath.cpp delete mode 100644 plugins/Quotes/src/CreateFilePath.h delete mode 100644 plugins/Quotes/src/CurrencyConverter.cpp delete mode 100644 plugins/Quotes/src/CurrencyConverter.h delete mode 100644 plugins/Quotes/src/DBUtils.cpp delete mode 100644 plugins/Quotes/src/DBUtils.h delete mode 100644 plugins/Quotes/src/EconomicRateInfo.h delete mode 100644 plugins/Quotes/src/ExtraImages.cpp delete mode 100644 plugins/Quotes/src/ExtraImages.h delete mode 100644 plugins/Quotes/src/Forex.cpp delete mode 100644 plugins/Quotes/src/HTMLParserMS.cpp delete mode 100644 plugins/Quotes/src/HTMLParserMS.h delete mode 100644 plugins/Quotes/src/HTTPSession.cpp delete mode 100644 plugins/Quotes/src/HTTPSession.h delete mode 100644 plugins/Quotes/src/IHTMLEngine.h delete mode 100644 plugins/Quotes/src/IHTMLParser.h delete mode 100644 plugins/Quotes/src/IQuotesProvider.h delete mode 100644 plugins/Quotes/src/IXMLEngine.h delete mode 100644 plugins/Quotes/src/IconLib.cpp delete mode 100644 plugins/Quotes/src/IconLib.h delete mode 100644 plugins/Quotes/src/ImportExport.cpp delete mode 100644 plugins/Quotes/src/ImportExport.h delete mode 100644 plugins/Quotes/src/IsWithinAccuracy.h delete mode 100644 plugins/Quotes/src/Locale.cpp delete mode 100644 plugins/Quotes/src/Locale.h delete mode 100644 plugins/Quotes/src/Log.cpp delete mode 100644 plugins/Quotes/src/Log.h delete mode 100644 plugins/Quotes/src/ModuleInfo.cpp delete mode 100644 plugins/Quotes/src/ModuleInfo.h delete mode 100644 plugins/Quotes/src/QuoteChart.cpp delete mode 100644 plugins/Quotes/src/QuoteChart.h delete mode 100644 plugins/Quotes/src/QuoteInfoDlg.cpp delete mode 100644 plugins/Quotes/src/QuoteInfoDlg.h delete mode 100644 plugins/Quotes/src/QuotesProviderBase.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderBase.h delete mode 100644 plugins/Quotes/src/QuotesProviderCurrencyConverter.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderCurrencyConverter.h delete mode 100644 plugins/Quotes/src/QuotesProviderVisitor.h delete mode 100644 plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderVisitorDbSettings.h delete mode 100644 plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.h delete mode 100644 plugins/Quotes/src/QuotesProviderVisitorFormater.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderVisitorFormater.h delete mode 100644 plugins/Quotes/src/QuotesProviderVisitorTendency.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderVisitorTendency.h delete mode 100644 plugins/Quotes/src/QuotesProviders.cpp delete mode 100644 plugins/Quotes/src/QuotesProviders.h delete mode 100644 plugins/Quotes/src/SettingsDlg.cpp delete mode 100644 plugins/Quotes/src/SettingsDlg.h delete mode 100644 plugins/Quotes/src/WinCtrlHelper.cpp delete mode 100644 plugins/Quotes/src/WinCtrlHelper.h delete mode 100644 plugins/Quotes/src/XMLEngineMI.cpp delete mode 100644 plugins/Quotes/src/XMLEngineMI.h delete mode 100644 plugins/Quotes/src/resource.h delete mode 100644 plugins/Quotes/src/stdafx.cxx delete mode 100644 plugins/Quotes/src/stdafx.h delete mode 100644 plugins/Quotes/src/version.h diff --git a/bin15/mir_full.sln b/bin15/mir_full.sln index ea4dd06f21..c76729cd40 100644 --- a/bin15/mir_full.sln +++ b/bin15/mir_full.sln @@ -269,7 +269,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "YAMN", "..\plugins\YAMN\YAM EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NewsAggregator", "..\plugins\NewsAggregator\NewsAggregator.vcxproj", "{6DE11A47-2268-4B08-8DE5-15A1705FCE28}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Quotes", "..\plugins\Quotes\Forex.vcxproj", "{C619A811-8023-4441-B3D7-785388A09DF0}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CurrencyRates", "..\plugins\CurrencyRates\Forex.vcxproj", "{C619A811-8023-4441-B3D7-785388A09DF0}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Weather", "..\plugins\Weather\weather.vcxproj", "{6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}" EndProject diff --git a/bin15/mir_icons.sln b/bin15/mir_icons.sln index 9dd43101c8..79409e1b37 100644 --- a/bin15/mir_icons.sln +++ b/bin15/mir_icons.sln @@ -48,7 +48,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Proto_mRadio", "..\plugins\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Proto_NewsAggregator", "..\plugins\NewsAggregator\proto_newsaggregator\Proto_NewsAggregator.vcxproj", "{B97882DC-7462-41DB-A390-BDFCE5295265}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Proto_Quotes", "..\plugins\Quotes\proto_Quotes\proto_Quotes.vcxproj", "{5A0A9761-78E1-4E0F-AD8C-8931A667A5F2}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Proto_CurrencyRates", "..\plugins\CurrencyRates\proto_CurrencyRates\proto_CurrencyRates.vcxproj", "{5A0A9761-78E1-4E0F-AD8C-8931A667A5F2}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Proto_Weather", "..\plugins\Weather\proto_weather\proto_weather.vcxproj", "{B2F4BA6C-1BD6-4A50-A706-DCBC6A5D439B}" EndProject diff --git a/plugins/CurrencyRates/Forex.vcxproj b/plugins/CurrencyRates/Forex.vcxproj new file mode 100644 index 0000000000..fec30452f6 --- /dev/null +++ b/plugins/CurrencyRates/Forex.vcxproj @@ -0,0 +1,36 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C619A811-8023-4441-B3D7-785388A09DF0} + CurrencyRates + + + + + + $(WindowsSdkDir)include;$(VCInstallDir)include;$(IncludePath) + + + + Sync + + + \ No newline at end of file diff --git a/plugins/CurrencyRates/Forex.vcxproj.filters b/plugins/CurrencyRates/Forex.vcxproj.filters new file mode 100644 index 0000000000..fcae13a9d8 --- /dev/null +++ b/plugins/CurrencyRates/Forex.vcxproj.filters @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/CurrencyRates/QuotesChart/Form1.Designer.cs b/plugins/CurrencyRates/QuotesChart/Form1.Designer.cs new file mode 100644 index 0000000000..39c45d2e6d --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/Form1.Designer.cs @@ -0,0 +1,123 @@ +namespace QuotesChart +{ + partial class FormMirandaQuotesChart + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); + System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMirandaQuotesChart)); + this.chartQuotes = new System.Windows.Forms.DataVisualization.Charting.Chart(); + this.label1 = new System.Windows.Forms.Label(); + this.dateFrom = new System.Windows.Forms.DateTimePicker(); + this.dateTo = new System.Windows.Forms.DateTimePicker(); + this.label2 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.chartQuotes)).BeginInit(); + this.SuspendLayout(); + // + // chartQuotes + // + this.chartQuotes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + chartArea1.Name = "ChartArea1"; + this.chartQuotes.ChartAreas.Add(chartArea1); + legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Bottom; + legend1.Name = "Legend1"; + this.chartQuotes.Legends.Add(legend1); + this.chartQuotes.Location = new System.Drawing.Point(2, 45); + this.chartQuotes.Name = "chartQuotes"; + this.chartQuotes.Size = new System.Drawing.Size(423, 433); + this.chartQuotes.TabIndex = 0; + this.chartQuotes.Text = "chart1"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(-1, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(30, 13); + this.label1.TabIndex = 1; + this.label1.Text = "From"; + // + // dateFrom + // + this.dateFrom.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dateFrom.Location = new System.Drawing.Point(35, 9); + this.dateFrom.Name = "dateFrom"; + this.dateFrom.Size = new System.Drawing.Size(98, 20); + this.dateFrom.TabIndex = 2; + this.dateFrom.ValueChanged += new System.EventHandler(this.dateFrom_ValueChanged); + // + // dateTo + // + this.dateTo.Format = System.Windows.Forms.DateTimePickerFormat.Short; + this.dateTo.Location = new System.Drawing.Point(177, 10); + this.dateTo.Name = "dateTo"; + this.dateTo.Size = new System.Drawing.Size(98, 20); + this.dateTo.TabIndex = 4; + this.dateTo.ValueChanged += new System.EventHandler(this.dateTo_ValueChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(151, 16); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(20, 13); + this.label2.TabIndex = 3; + this.label2.Text = "To"; + // + // FormMirandaQuotesChart + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(425, 477); + this.Controls.Add(this.dateTo); + this.Controls.Add(this.label2); + this.Controls.Add(this.dateFrom); + this.Controls.Add(this.label1); + this.Controls.Add(this.chartQuotes); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "FormMirandaQuotesChart"; + this.Text = "Miranda Quotes Chart"; + this.Load += new System.EventHandler(this.Form1_Load); + ((System.ComponentModel.ISupportInitialize)(this.chartQuotes)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.DataVisualization.Charting.Chart chartQuotes; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.DateTimePicker dateFrom; + private System.Windows.Forms.DateTimePicker dateTo; + private System.Windows.Forms.Label label2; + } +} + diff --git a/plugins/CurrencyRates/QuotesChart/Form1.cs b/plugins/CurrencyRates/QuotesChart/Form1.cs new file mode 100644 index 0000000000..b6295d4b56 --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/Form1.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using Microsoft.VisualBasic.FileIO; +using System.Runtime.InteropServices; + +namespace QuotesChart +{ + public partial class FormMirandaQuotesChart : Form + { + public FormMirandaQuotesChart() + { + InitializeComponent(); + } + + private void Form1_Load(object sender, EventArgs e) + { + string[] cmd_line_args = Environment.GetCommandLineArgs(); + + for (int i = 1; i < cmd_line_args.Length; ++i) + { + string data_file = cmd_line_args[i]; + AddDataFromFile(data_file); + } + } + + private void dateFrom_ValueChanged(object sender, EventArgs e) + { + if (dateFrom.Value < dateTo.Value) + { + chartQuotes.ChartAreas[0].AxisX.Minimum = dateFrom.Value.ToOADate(); + chartQuotes.Invalidate(); + } + } + + private void dateTo_ValueChanged(object sender, EventArgs e) + { + if (dateTo.Value > dateFrom.Value) + { + chartQuotes.ChartAreas[0].AxisX.Maximum = dateTo.Value.ToOADate(); + chartQuotes.Invalidate(); + } + } + + int WM_COPYDATA = 0x4A; + + public struct COPYDATASTRUCT + { + public IntPtr dwData; + public int cbData; + [MarshalAs(UnmanagedType.LPWStr)] + public String lpData; + } + + protected override void WndProc(ref Message msg) + { + if (msg.Msg == WM_COPYDATA) + { + COPYDATASTRUCT cp = (COPYDATASTRUCT)Marshal.PtrToStructure(msg.LParam, typeof(COPYDATASTRUCT)); + + if (/**(cp.dwData) == 0x1945 && */cp.lpData != null) + { + AddDataFromFile(cp.lpData); + } + + } + base.WndProc(ref msg); + } + + private void AddDataFromFile(string data_file) + { + using (TextFieldParser parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(data_file)) + { + parser.TrimWhiteSpace = true; + parser.TextFieldType = FieldType.Delimited; + parser.SetDelimiters("\t"); + + System.Windows.Forms.DataVisualization.Charting.Series series = null; + while (true) + { + string[] parts = parser.ReadFields(); + if (parts == null) + { + break; + } + + if (parts.Length >= 3) + { + string name = parts[0]; + string date = parts[1]; + string value = parts[2]; + + if (series == null) + { + if (chartQuotes.Series.FindByName(name) == null) + { + chartQuotes.Series.Add(name); + series = chartQuotes.Series[name]; + series.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; + } + else + { + break; + } + } + + DateTime dt; + double d; + if (Double.TryParse(value, out d) && DateTime.TryParse(date, out dt)) + { + series.Points.AddXY(dt, d); + + if (!dateMin.HasValue) + { + dateMin = new DateTime(); + dateMin = dt; + } + else if (dt < dateMin) + { + dateMin = dt; + } + + if (!dateMax.HasValue) + { + dateMax = new DateTime(); + dateMax = dt; + } + else if (dt > dateMax) + { + dateMax = dt; + } + } + } + } + } + + if (dateMin.HasValue && dateMax.HasValue) + { + chartQuotes.ChartAreas[0].AxisX.Minimum = dateMin.Value.ToOADate(); + chartQuotes.ChartAreas[0].AxisX.Maximum = dateMax.Value.ToOADate(); + + dateFrom.Value = dateMin.Value; + dateTo.Value = dateMax.Value; + } + } + + private DateTime? dateMin = null; + private DateTime? dateMax = null; + } +} diff --git a/plugins/CurrencyRates/QuotesChart/Form1.resx b/plugins/CurrencyRates/QuotesChart/Form1.resx new file mode 100644 index 0000000000..3d63dcc355 --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/Form1.resx @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAIAICAAAAEAIACoEAAAJgAAABAQAAABACAAaAQAAM4QAAAoAAAAIAAAAEAAAAABACAAAAAAAIAQ + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAYAAAAOAAAAFgAAABwAAAAgAAAAIAAAABwAAAAWAAAADgAA + AAYAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAASAAAAJgAAADQAAABAAAAARAAAAEgAAABIAAAARAAA + AEAAAAA0AAAAJgAAABIAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAOAx80NAZKcmoUdaazH47D4ymh0vktrNf/L7DZ/yyo + 1v8lmMzzHYa72Q1ciJsFNldwAAAAPgAAACoAAAAOAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAFAdCb1QSgLO/MKjW71XI6/9l1PT/b9n4/3Xb + +v923Pr/cdn5/2nV9v9gz/L/Rbji+yecy+kIW42jAx0yWAAAADAAAAAUAAAAAgAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgQjPBoQcqKPKqPS81jR9P9j2fr/TtX6/zXQ + +f8eyvn/Esf4/wzE+P8Vxvj/Jcj4/zjM+P9R0fn/W9P4/z+75/8fkMXnBjVUcAMIDD4AAAAUAAAAAgAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFK0sWD2+mhzO14fdS0fb/RdP6/ybM + +f8PyPn/B8f5/wbH+f8Gx/n/Bsb5/wbE+P8Hw/j/CsL3/xXD9/8qx/j/Rcz3/1HN8/9RoLflO01JgQAA + ADAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA14roMosuD3RNH6/ynN + +f8Kx/n/Bcj6/wTK+v8Eyvr/BMr7/wTK+v8Fyfr/Bcj6/wbG+f8GxPj/B8L3/wjA9/8ryvb/ecfE/8uj + Q/+ogjLxMicYZAAAACoAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIKW5g+Gp7R7zTJ + 9P8iyvn/Ccf5/wXJ+v8Ey/r/BMz7/wPN+/8Dzfv/A837/wTM+/8Eyvr/Bcj5/wbG+f8Hw/j/F8j4/2LC + wP+4mzT/4a40/9anNf9+YizHJBwWUAAAABIAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACViSEgyG + wLElw/H/I8r5/wnG+f8FyPr/BMv7/wPN+/8C0Pz/AtD8/wLR/f8C0Pz/A8/8/wPN+/8Eyvr/Bcj6/x7N + +P9hxcL/xZMY/9yiGP/epR//4Kwv/7uPKvtkTSSXAAAAJgAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAJcrBEEqDV6yPI+P8Sxvn/Bcf5/wXK+v8Dzfv/A8/8/wLS/f8B0/3/AdP9/wHS/f8C0fz/A8/8/wTM + +/8Rzfr/YsjE/7ecMP/doxf/3aMY/92jGf/epyT/1qMq/5ZzLd8AAAA0AAAADgAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAyEv5kYtef/GMf4/wnF+P8FyPr/BMv6/wPO/P8C0fz/AdP9/wHV/v8A1v7/AdT+/wHS + /f8C0Pz/GdT7/2PMxf/JnBT/4asU/+CoFf/epRb/3aMX/92kG//eqCj/v5Aj/0U3KWoAAAAWAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAADo3J1xi+8P8Rxfj/BsX5/wXI+v8Ey/v/A8/8/wLR/f8B1P7/ANb+/wDX + //8A1v7/AdP9/wzT/f9lz8b/vqgs/+ayEf/lrxL/4qwT/+CoFf/epBf/3aMY/96oJP/RnSD/bFMvnQAA + ABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOmdD3GMH0/wzD+P8Gxfj/Bcj6/wTL+v8Dzvz/AtH8/wHU + /f8B1f7/ANb+/wTV/v8d2v3/ZdLG/9CqDv/svAz/67kN/+m1D//msBH/46wT/+CnFv/epBf/3qYf/9ij + I/+IZiS5AAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2h1f8Ywvb/CcL4/wfE+P8FyPr/BMr6/wPO + +/8C0Pz/AtL9/wzW/f844/7/Tub9/17Gyv/Fujz/8sQI//HCCf/uvgv/7LoN/+i0EP/lrxL/4aoU/9+m + Fv/dpB3/3KYl/5hxGb0AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADqbY/xnD9/8Iwff/B8P4/wfG + +f8Qzfr/JNf8/zPZ+v9IwOb/SaLU/yFZs/8MGZH/JCqJ/7+rXP/4zRD/9cgH//LDCf/vvwv/6rgO/+ey + Ef/jrBP/4KgV/96lHf/eqCX/oXYTuwAAABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASoNT9HcP2/w7C + 9/8izvn/R9/8/0nW9f81isj/Jlmy/xQ1sf8LGaz/DBu0/w0ct/8NHLD/Q0WF//zaOv/4zQj/9McH//DB + Cf/rug3/6LQP/+OtE//gqRX/3qYe/9umJf+Ych25AAAAFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACql + 1PNNze//UbLc/zqOz/8UOKv/CRel/woavf8KG8f/ChvH/wobx/8KG8T/CxvB/wwcvP8MGrH/mItl//nW + KP/2yQb/8sMJ/+28DP/ptQ//5K4S/+GqFP/fqCH/1aEj/4ZlLKcAAAAOAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAALWeswTBar/8ZL7D/Cxqz/woaw/8JG8r/CRrN/wgaz/8IG9D/CRvP/wkbzP8KG8n/ChvD/wwc + vv8qMZj/y7Zb//bLDv/ywwn/7bwM/+m1D//krhL/4aoW/+CqJv/PnCH/clk3gwAAAAYAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAOGpNcGyiw8x4txv8NHsn/CBrP/wga0/8HGtf/BhnZ/wYa2v8GGtn/BxrW/wga + 0v8JGsz/ChvG/wsauv9MTIP/9tU///HDD//rug3/6LQP/+OtE//hqxz/3akq/7CGKPdLPDIqAAAAAgAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwZlyoVI6vRJTTN/xUl0P8IGtX/Bhna/wYZ3/8FGeH/BRni/wUZ + 4f8GGd3/BxnZ/wga0v8JGsz/ChvD/woZsv+ajGb/9Msq/+q4Dv/nshH/460V/+KuJv/Woyv/mHQwxwAA + AAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoXnWgiMcb7JTXZ/wsd3P8FGeL/BBjo/wMY + 6/8DGOv/Axjq/wQZ5v8FGeD/BxnZ/wga0v8KG8n/CxvB/ywzmP/IsV7/67oa/+WvEv/iryL/4a8x/7GI + Lel6XzNEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACxecFBknuM0wP9r/IDHk/wcb + 5/8DGO3/Ahfx/wIY8v8CGPD/Axjr/wQY5v8GGd3/BxnW/wkazP8KG8T/Cxu1/0xNgv/zzkH/5bIf/+S0 + OP/WpjH/i2w4l2RQPQ4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACRemLCEw + xMs/Tun/L0Dv/w0h8/8CGff/ARf5/wEX9v8CF/D/Axjq/wUZ4f8GGdn/CRvP/wobx/8MHLz/EB+u/6OV + dv/vy17/1Kg/+515OLkAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAALGKYEER6tPik4zuVJWO7/QVL3/yY4+/8HHf3/ARj5/wIX8v8DGOv/BRni/wYa2v8IG9D/DR3I/yAv + wv87R8P/ZWmt/868e/+jgT67fGJCKgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAACBauJB8uxKtDUuX1WWf2/1tp+/9EVPn/L0Hz/yg67v8mOOX/Lj7f/z5M + 2v9SXtf/XmjR/1Rexf0yPaXVTEt5hwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACBesGBMivmgkMsrPQE/i/Vto8P9qdvL/b3rx/3B7 + 7f9teOb/Ym3b/1Jczf8zPrHnIy+ipQ0ZjDAPGooIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIF6s8BxWveAUV + tZ0FFbalBRWzqQYWq6MJF6KHCxicXg0ZlRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////+AB///AAP//AAA//gAAH/wA + AA/8AAAP+AAAB/AAAAPwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAD8AAAA/AA + AAf4AAAP+AAAD/wAAB/8AAA//wAA//+AAP//8Af/////////////////KAAAABAAAAAgAAAAAQAgAAAA + AABABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAcAAAALgAA + ADQAAAAuAAAAHAAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUuTR4bfqqTQK3W5U/A + 5/1Qw+n/RbLd8yaJtL0EME1YAAAAFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxaiS40rtndSdL4/ybN + +f8PyPn/C8X4/xzG+P87zPj/Prrm+TJkc4UAAAAWAAAAAAAAAAAAAAAAAAAAAAlTihAkq9rbJsz5/wbJ + +v8Ey/v/BMz7/wXK+v8Gxvn/C8P4/3C7rP/Lnzj7Tj0faAAAAAYAAAAAAAAAAAAAAAAOjsZ8H8f2/wbI + +v8Dzfv/AtH8/wLS/f8Dz/z/CMv6/2a9rP/Xnxj/3qci/6uCKdsAAAAcAAAAAAAAAAAAAAAAFKXb2w7F + +P8Fyvr/AtD8/wHU/v8A1v7/BNL9/2jGrP/dqhP/4KgV/92kGP/TnyT/TTwlTgAAAAAAAAAAAAAAABOv + 5P0IxPj/Bcn6/wPP/P8E1P3/I93+/2nLsv/ouwv/67oN/+WwEv/fpxb/3KUh/3tcGmwAAAAAAAAAAAAA + AAAWs+b/EMX4/yrS+f8spdz/LGzG/xEqrP9NTob/+M8W//HCCf/ptg//4aoU/92mIf+KZhVoAAAAAAAA + AAAAAAAANo/J7SxixP8MIbf/CRrI/wkby/8KG8b/Cxu8/6KSYP/0xwn/67kO/+OsFP/ZpCP/dlouTgAA + AAAAAAAAAAAAABYjqJMZKcv/BxrU/wYZ3P8GGd7/BxnY/wkazP8bJ63/3bw3/+m2D//irRr/wZMr70I0 + LAwAAAAAAAAAAAAAAAAKF50eJDTN8Q4g4v8DGOz/Axju/wQY5v8HGdj/ChvG/1NTi//quiP/364v/5p3 + MnQAAAAAAAAAAAAAAAAAAAAAAAAAABopu044SOb5HjH3/wIZ+f8DGO7/Bhne/woby/8eLLz/saF//7GM + PacAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGSi+OjxK38tPXfL/TFvx/0xa5v9RXdb/RlC94zY8 + k2QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABxauLgUVtlAGFa9SChefOA0Z + lQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAA+A8AAPAHAADgAwAAwAEAAMABAADAAQAAwAEAAMAB + AADAAQAAwAEAAMADAADgBwAA8A8AAPwfAAD//wAA + + + \ No newline at end of file diff --git a/plugins/CurrencyRates/QuotesChart/Program.cs b/plugins/CurrencyRates/QuotesChart/Program.cs new file mode 100644 index 0000000000..d2c79f5966 --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace QuotesChart +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new FormMirandaQuotesChart()); + } + } +} diff --git a/plugins/CurrencyRates/QuotesChart/Properties/AssemblyInfo.cs b/plugins/CurrencyRates/QuotesChart/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c90728eff3 --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("QuotesChart")] +[assembly: AssemblyDescription("Chart Application for Miranda Quotes plugin")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Dioksin")] +[assembly: AssemblyProduct("Miranda")] +[assembly: AssemblyCopyright("Don't worry!")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9b8250c7-ffbe-4f8a-985e-2e562e253dc4")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("0.0.1.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/plugins/CurrencyRates/QuotesChart/Properties/Resources.Designer.cs b/plugins/CurrencyRates/QuotesChart/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..0bef6c885c --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace QuotesChart.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("QuotesChart.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/plugins/CurrencyRates/QuotesChart/Properties/Resources.resx b/plugins/CurrencyRates/QuotesChart/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/plugins/CurrencyRates/QuotesChart/Properties/Settings.Designer.cs b/plugins/CurrencyRates/QuotesChart/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..02c737069d --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace QuotesChart.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/plugins/CurrencyRates/QuotesChart/Properties/Settings.settings b/plugins/CurrencyRates/QuotesChart/Properties/Settings.settings new file mode 100644 index 0000000000..39645652af --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/CurrencyRates/QuotesChart/QuotesChart.csproj b/plugins/CurrencyRates/QuotesChart/QuotesChart.csproj new file mode 100644 index 0000000000..a502da630a --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/QuotesChart.csproj @@ -0,0 +1,124 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {C255CA56-D05E-4389-A32E-CA3EBE412684} + WinExe + Properties + QuotesChart + QuotesChart + v4.0 + 512 + + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + bin\Debug\QuotesChart.exe.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + bin\Release\QuotesChart.exe.CodeAnalysisLog.xml + true + GlobalSuppressions.cs + prompt + MinimumRecommendedRules.ruleset + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets + ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules + + + main.ico + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/plugins/CurrencyRates/QuotesChart/app.config b/plugins/CurrencyRates/QuotesChart/app.config new file mode 100644 index 0000000000..e365603337 --- /dev/null +++ b/plugins/CurrencyRates/QuotesChart/app.config @@ -0,0 +1,3 @@ + + + diff --git a/plugins/CurrencyRates/QuotesChart/bin/x32/QuotesChart.exe b/plugins/CurrencyRates/QuotesChart/bin/x32/QuotesChart.exe new file mode 100644 index 0000000000..5a96cbbcfb Binary files /dev/null and b/plugins/CurrencyRates/QuotesChart/bin/x32/QuotesChart.exe differ diff --git a/plugins/CurrencyRates/QuotesChart/bin/x64/QuotesChart.exe b/plugins/CurrencyRates/QuotesChart/bin/x64/QuotesChart.exe new file mode 100644 index 0000000000..d85e08c0f1 Binary files /dev/null and b/plugins/CurrencyRates/QuotesChart/bin/x64/QuotesChart.exe differ diff --git a/plugins/CurrencyRates/QuotesChart/main.ico b/plugins/CurrencyRates/QuotesChart/main.ico new file mode 100644 index 0000000000..da85d1f7c6 Binary files /dev/null and b/plugins/CurrencyRates/QuotesChart/main.ico differ diff --git a/plugins/CurrencyRates/docs/Utility/cc.xml b/plugins/CurrencyRates/docs/Utility/cc.xml new file mode 100644 index 0000000000..874d03e457 --- /dev/null +++ b/plugins/CurrencyRates/docs/Utility/cc.xml @@ -0,0 +1,518 @@ + + + + Currency Converter API + https://www.currencyconverterapi.com/ + https://free.currencyconverterapi.com/api/v5/convert + +
+ Currencies + + AEDAEDUnited Arab Emirates Dirham (AED) + + + AFNAFNAfghan Afghani (AFN) + + + ALLALLAlbanian Lek (ALL) + + + AMDAMDArmenian Dram (AMD) + + + ANGANGNetherlands Antillean Gulden (ANG) + + + AOAAOAAngolan Kwanza (AOA) + + + ARSARSArgentine Peso (ARS) + + + AUDAUDAustralian Dollar (AUD) + + + AWGAWGAruban Florin (AWG) + + + AZNAZNAzerbaijani Manat (AZN) + + + BAMBAMBosnia-Herzegovina Convertible Mark (BAM) + + + BBDBBDBarbadian Dollar (BBD) + + + BDTBDTBangladeshi Taka (BDT) + + + BGNBGNBulgarian Lev (BGN) + + + BHDBHDBahraini Dinar (BHD) + + + BIFBIFBurundian Franc (BIF) + + + BMDBMDBermudan Dollar (BMD) + + + BNDBNDBrunei Dollar (BND) + + + BOBBOBBolivian Boliviano (BOB) + + + BRLBRLBrazilian Real (BRL) + + + BSDBSDBahamian Dollar (BSD) + + + BTCBTCBitcoin (BTC) + + + BTNBTNBhutanese Ngultrum (BTN) + + + BWPBWPBotswana Pula (BWP) + + + BYNBYNBelarusian Ruble (BYN) + + + BYRBYRBelarusian Ruble (2000–2016) (BYR) + + + BZDBZDBelize Dollar (BZD) + + + CADCADCanadian Dollar (CAD) + + + CDFCDFCongolese Franc (CDF) + + + CHFCHFSwiss Franc (CHF) + + + CLFCLFChilean Unit of Account (UF) (CLF) + + + CLPCLPChilean Peso (CLP) + + + CNHCNHCNH (CNH) + + + CNYCNYChinese Yuan (CNY) + + + COPCOPColombian Peso (COP) + + + CRCCRCCosta Rican Colón (CRC) + + + CUPCUPCuban Peso (CUP) + + + CVECVECape Verdean Escudo (CVE) + + + CZKCZKCzech Koruna (CZK) + + + DEMDEMGerman Mark (DEM) + + + DJFDJFDjiboutian Franc (DJF) + + + DKKDKKDanish Krone (DKK) + + + DOPDOPDominican Peso (DOP) + + + DZDDZDAlgerian Dinar (DZD) + + + EGPEGPEgyptian Pound (EGP) + + + ERNERNEritrean Nakfa (ERN) + + + ETBETBEthiopian Birr (ETB) + + + EUREUREuro (EUR) + + + FIMFIMFinnish Markka (FIM) + + + FJDFJDFijian Dollar (FJD) + + + FKPFKPFalkland Islands Pound (FKP) + + + FRFFRFFrench Franc (FRF) + + + GBPGBPBritish Pound (GBP) + + + GELGELGeorgian Lari (GEL) + + + GHSGHSGhanaian Cedi (GHS) + + + GIPGIPGibraltar Pound (GIP) + + + GMDGMDGambian Dalasi (GMD) + + + GNFGNFGuinean Franc (GNF) + + + GTQGTQGuatemalan Quetzal (GTQ) + + + GYDGYDGuyanaese Dollar (GYD) + + + HKDHKDHong Kong Dollar (HKD) + + + HNLHNLHonduran Lempira (HNL) + + + HRKHRKCroatian Kuna (HRK) + + + HTGHTGHaitian Gourde (HTG) + + + HUFHUFHungarian Forint (HUF) + + + IDRIDRIndonesian Rupiah (IDR) + + + IEPIEPIrish Pound (IEP) + + + ILSILSIsraeli New Shekel (ILS) + + + INRINRIndian Rupee (INR) + + + IQDIQDIraqi Dinar (IQD) + + + IRRIRRIranian Rial (IRR) + + + ISKISKIcelandic Króna (ISK) + + + ITLITLItalian Lira (ITL) + + + JMDJMDJamaican Dollar (JMD) + + + JODJODJordanian Dinar (JOD) + + + JPYJPYJapanese Yen (JPY) + + + KESKESKenyan Shilling (KES) + + + KGSKGSKyrgystani Som (KGS) + + + KHRKHRCambodian Riel (KHR) + + + KMFKMFComorian Franc (KMF) + + + KPWKPWNorth Korean Won (KPW) + + + KRWKRWSouth Korean Won (KRW) + + + KWDKWDKuwaiti Dinar (KWD) + + + KYDKYDCayman Islands Dollar (KYD) + + + KZTKZTKazakhstani Tenge (KZT) + + + LAKLAKLaotian Kip (LAK) + + + LBPLBPLebanese Pound (LBP) + + + LKRLKRSri Lankan Rupee (LKR) + + + LRDLRDLiberian Dollar (LRD) + + + LSLLSLLesotho Loti (LSL) + + + LTLLTLLithuanian Litas (LTL) + + + LVLLVLLatvian Lats (LVL) + + + LYDLYDLibyan Dinar (LYD) + + + MADMADMoroccan Dirham (MAD) + + + MDLMDLMoldovan Leu (MDL) + + + MGAMGAMalagasy Ariary (MGA) + + + MKDMKDMacedonian Denar (MKD) + + + MNTMNTMongolian Tugrik (MNT) + + + MOPMOPMacanese Pataca (MOP) + + + MROMROMauritanian Ouguiya (MRO) + + + MURMURMauritian Rupee (MUR) + + + MVRMVRMaldivian Rufiyaa (MVR) + + + MWKMWKMalawian Kwacha (MWK) + + + MXNMXNMexican Peso (MXN) + + + MYRMYRMalaysian Ringgit (MYR) + + + MZNMZNMozambican Metical (MZN) + + + NADNADNamibian Dollar (NAD) + + + NGNNGNNigerian Naira (NGN) + + + NIONIONicaraguan Córdoba (NIO) + + + NOKNOKNorwegian Krone (NOK) + + + NPRNPRNepalese Rupee (NPR) + + + NZDNZDNew Zealand Dollar (NZD) + + + OMROMROmani Rial (OMR) + + + PABPABPanamanian Balboa (PAB) + + + PENPENPeruvian Nuevo Sol (PEN) + + + PGKPGKPapua New Guinean Kina (PGK) + + + PHPPHPPhilippine Peso (PHP) + + + PKGPKGPKG (PKG) + + + PKRPKRPakistani Rupee (PKR) + + + PLNPLNPolish Zloty (PLN) + + + PYGPYGParaguayan Guarani (PYG) + + + QARQARQatari Riyal (QAR) + + + RONRONNew Romanian Leu (RON) + + + RSDRSDSerbian Dinar (RSD) + + + RUBRUBRussian Ruble (RUB) + + + RWFRWFRwandan Franc (RWF) + + + SARSARSaudi Riyal (SAR) + + + SBDSBDSolomon Islands Dollar (SBD) + + + SCRSCRSeychellois Rupee (SCR) + + + SDGSDGSudanese Pound (SDG) + + + SEKSEKSwedish Krona (SEK) + + + SGDSGDSingapore Dollar (SGD) + + + SHPSHPSt. Helena Pound (SHP) + + + SKKSKKSlovak Koruna (SKK) + + + SLLSLLSierra Leonean Leone (SLL) + + + SOSSOSSomali Shilling (SOS) + + + SRDSRDSurinamese Dollar (SRD) + + + STDSTDSão Tomé and Príncipe Dobra (STD) + + + SVCSVCSalvadoran Colón (SVC) + + + SYPSYPSyrian Pound (SYP) + + + SZLSZLSwazi Lilangeni (SZL) + + + THBTHBThai Baht (THB) + + + TJSTJSTajikistani Somoni (TJS) + + + TMTTMTTurkmenistani Manat (TMT) + + + TNDTNDTunisian Dinar (TND) + + + TOPTOPTongan Paʻanga (TOP) + + + TRYTRYTurkish Lira (TRY) + + + TTDTTDTrinidad and Tobago Dollar (TTD) + + + TWDTWDNew Taiwan Dollar (TWD) + + + TZSTZSTanzanian Shilling (TZS) + + + UAHUAHUkrainian Hryvnia (UAH) + + + UGXUGXUgandan Shilling (UGX) + + + USDUSDUnited States Dollar (USD) + + + UYUUYUUruguayan Peso (UYU) + + + UZSUZSUzbekistani Som (UZS) + + + VEFVEFVenezuelan Bolívar (VEF) + + + VNDVNDVietnamese Dong (VND) + + + VUVVUVVanuatu Vatu (VUV) + + + WSTWSTSamoan Tala (WST) + + + XAFXAFCentral African CFA Franc (FCFA) + + + XCDXCDEast Caribbean Dollar (XCD) + + + XDRXDRSpecial Drawing Rights (XDR) + + + XOFXOFWest African CFA Franc (CFA) + + + XPFXPFCFP Franc (CFPF) + + + YERYERYemeni Rial (YER) + + + ZARZARSouth African Rand (ZAR) + + + ZMKZMKZambian Kwacha (1968–2012) (ZMK) + + + ZMWZMWZambian Kwacha (ZMW) + + + ZWLZWLZimbabwean Dollar (2009) (ZWL) + +
+
\ No newline at end of file diff --git a/plugins/CurrencyRates/proto_CurrencyRates/proto_CurrencyRates.vcxproj b/plugins/CurrencyRates/proto_CurrencyRates/proto_CurrencyRates.vcxproj new file mode 100644 index 0000000000..b3b9b70855 --- /dev/null +++ b/plugins/CurrencyRates/proto_CurrencyRates/proto_CurrencyRates.vcxproj @@ -0,0 +1,28 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Proto_CurrencyRates + {5A0A9761-78E1-4E0F-AD8C-8931A667A5F2} + + + + + \ No newline at end of file diff --git a/plugins/CurrencyRates/proto_CurrencyRates/proto_CurrencyRates.vcxproj.filters b/plugins/CurrencyRates/proto_CurrencyRates/proto_CurrencyRates.vcxproj.filters new file mode 100644 index 0000000000..28f81e7f1b --- /dev/null +++ b/plugins/CurrencyRates/proto_CurrencyRates/proto_CurrencyRates.vcxproj.filters @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/CurrencyRates/proto_CurrencyRates/res/proto_CurrencyRates.rc b/plugins/CurrencyRates/proto_CurrencyRates/res/proto_CurrencyRates.rc new file mode 100644 index 0000000000..f85d1993b2 --- /dev/null +++ b/plugins/CurrencyRates/proto_CurrencyRates/res/proto_CurrencyRates.rc @@ -0,0 +1,121 @@ +//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" + +#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", "CurrencyRates protocol icons" + VALUE "FileVersion", "0, 0, 0, 1" + VALUE "InternalName", "proto_Quotes" + VALUE "LegalCopyright", "Do not worry!" + VALUE "OriginalFilename", "proto_CurrencyRates.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/CurrencyRates/proto_CurrencyRates/res/proto_na.ico b/plugins/CurrencyRates/proto_CurrencyRates/res/proto_na.ico new file mode 100644 index 0000000000..385d27fb15 Binary files /dev/null and b/plugins/CurrencyRates/proto_CurrencyRates/res/proto_na.ico differ diff --git a/plugins/CurrencyRates/proto_CurrencyRates/res/proto_offline.ico b/plugins/CurrencyRates/proto_CurrencyRates/res/proto_offline.ico new file mode 100644 index 0000000000..f6fc5e9f20 Binary files /dev/null and b/plugins/CurrencyRates/proto_CurrencyRates/res/proto_offline.ico differ diff --git a/plugins/CurrencyRates/proto_CurrencyRates/res/proto_online.ico b/plugins/CurrencyRates/proto_CurrencyRates/res/proto_online.ico new file mode 100644 index 0000000000..da85d1f7c6 Binary files /dev/null and b/plugins/CurrencyRates/proto_CurrencyRates/res/proto_online.ico differ diff --git a/plugins/CurrencyRates/res/AutoUpdateDisabled.ico b/plugins/CurrencyRates/res/AutoUpdateDisabled.ico new file mode 100644 index 0000000000..30c9dbf220 Binary files /dev/null and b/plugins/CurrencyRates/res/AutoUpdateDisabled.ico differ diff --git a/plugins/CurrencyRates/res/CurrencyConverter.ico b/plugins/CurrencyRates/res/CurrencyConverter.ico new file mode 100644 index 0000000000..67ac2095f5 Binary files /dev/null and b/plugins/CurrencyRates/res/CurrencyConverter.ico differ diff --git a/plugins/CurrencyRates/res/Export quotes.ico b/plugins/CurrencyRates/res/Export quotes.ico new file mode 100644 index 0000000000..31c7aa2ba1 Binary files /dev/null and b/plugins/CurrencyRates/res/Export quotes.ico differ diff --git a/plugins/CurrencyRates/res/Forex.rc b/plugins/CurrencyRates/res/Forex.rc new file mode 100644 index 0000000000..088587b982 --- /dev/null +++ b/plugins/CurrencyRates/res/Forex.rc @@ -0,0 +1,369 @@ +// 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" + +IDI_ICON_DISABLED ICON "AutoUpdateDisabled.ico" + + +#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 + +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 Google",IDC_SYSLINK_PROVIDER, + "SysLink",WS_TABSTOP,7,61,328,11 + PUSHBUTTON "Close",IDCANCEL,148,80,50,14 +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 "Colors",IDC_STATIC,7,7,149,82,WS_GROUP + CONTROL "Use default colors",IDC_RADIO_DEFAULT_COLOURS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,20,82,10 + CONTROL "Use user-defined colors",IDC_RADIO_USER_DEFINED_COLOURS, + "Button",BS_AUTORADIOBUTTON,15,34,97,10 + LTEXT "Background color",IDC_STATIC,70,53,66,8 + CONTROL "",IDC_BGCOLOR,"ColourPicker",WS_TABSTOP,26,49,35,14 + LTEXT "Text color",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,90,10 + CONTROL "Custom",IDC_DELAYCUSTOM,"Button",BS_AUTORADIOBUTTON,174,35,70,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 + +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 "",IDC_STATIC_QUOTE_NAME,7,7,208,8 + CONTROL "",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_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 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 "",IDC_STATIC_QUOTE_NAME,7,7,208,8 + CONTROL "",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 + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DIALOG_VARIABLE_LIST, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 209 + TOPMARGIN, 7 + BOTTOMMARGIN, 175 + END + + 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_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 + + 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 +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// AFX_DIALOG_LAYOUT +// + +IDD_CURRENCY_CONVERTER AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +#endif // Neutral resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/CurrencyRates/res/Import quotes.ico b/plugins/CurrencyRates/res/Import quotes.ico new file mode 100644 index 0000000000..506aa62af3 Binary files /dev/null and b/plugins/CurrencyRates/res/Import quotes.ico differ diff --git a/plugins/CurrencyRates/res/Refresh.ico b/plugins/CurrencyRates/res/Refresh.ico new file mode 100644 index 0000000000..f09a47cd9e Binary files /dev/null and b/plugins/CurrencyRates/res/Refresh.ico differ diff --git a/plugins/CurrencyRates/res/Section.ico b/plugins/CurrencyRates/res/Section.ico new file mode 100644 index 0000000000..768b3775aa Binary files /dev/null and b/plugins/CurrencyRates/res/Section.ico differ diff --git a/plugins/CurrencyRates/res/Version.rc b/plugins/CurrencyRates/res/Version.rc new file mode 100644 index 0000000000..5a5ddd63ed --- /dev/null +++ b/plugins/CurrencyRates/res/Version.rc @@ -0,0 +1,9 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "..\src\version.h" + +#include "..\..\build\Version.rc" diff --git a/plugins/CurrencyRates/res/down.ico b/plugins/CurrencyRates/res/down.ico new file mode 100644 index 0000000000..20722f63ca Binary files /dev/null and b/plugins/CurrencyRates/res/down.ico differ diff --git a/plugins/CurrencyRates/res/main.ico b/plugins/CurrencyRates/res/main.ico new file mode 100644 index 0000000000..da85d1f7c6 Binary files /dev/null and b/plugins/CurrencyRates/res/main.ico differ diff --git a/plugins/CurrencyRates/res/notchanged.ico b/plugins/CurrencyRates/res/notchanged.ico new file mode 100644 index 0000000000..39a8f1ea3c Binary files /dev/null and b/plugins/CurrencyRates/res/notchanged.ico differ diff --git a/plugins/CurrencyRates/res/quote.ico b/plugins/CurrencyRates/res/quote.ico new file mode 100644 index 0000000000..1367c475d6 Binary files /dev/null and b/plugins/CurrencyRates/res/quote.ico differ diff --git a/plugins/CurrencyRates/res/swap.ico b/plugins/CurrencyRates/res/swap.ico new file mode 100644 index 0000000000..f4a410da41 Binary files /dev/null and b/plugins/CurrencyRates/res/swap.ico differ diff --git a/plugins/CurrencyRates/res/up.ico b/plugins/CurrencyRates/res/up.ico new file mode 100644 index 0000000000..0379c80d17 Binary files /dev/null and b/plugins/CurrencyRates/res/up.ico differ diff --git a/plugins/CurrencyRates/src/Chart.h b/plugins/CurrencyRates/src/Chart.h new file mode 100644 index 0000000000..d33772b7c8 --- /dev/null +++ b/plugins/CurrencyRates/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 struct CConverter + { + static double Convert(const T& v) + { + return boost::numeric_cast(v); + } + + static tstring ToString(const T& v) + { + return boost::lexical_cast(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 TYConverter = detail::CConverter > +class CChart +{ +private: + typedef std::pair TValue; + typedef std::vector TValues; + +public: + CChart() : m_MaxY(), m_MinY() + { + memset(&m_rect, 0, 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(::GetStockObject(DEFAULT_GUI_FONT)); + HFONT hOldFont = static_cast(::SelectObject(hdc, hFont)); + + LPCTSTR pszText = TranslateT("There is nothing to show"); + int nDrawTextResult = ::DrawText(hdc, pszText, -1, &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(::SelectObject(hdc, hPen)); + HFONT hFont = static_cast(::GetStockObject(DEFAULT_GUI_FONT)); + HFONT hOldFont = static_cast(::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(), -1, &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(::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((rc.right - rc.left)*(k / dx)); + k = TYConverter::Convert(v.second - m_MinY); + int y = rc.bottom - boost::numeric_cast((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/CurrencyRates/src/ComHelper.cpp b/plugins/CurrencyRates/src/ComHelper.cpp new file mode 100644 index 0000000000..9c77e6d7ad --- /dev/null +++ b/plugins/CurrencyRates/src/ComHelper.cpp @@ -0,0 +1,28 @@ +#include "StdAfx.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() << L" (" << std::hex << hError << L")"; + + IErrorInfo* p = e.ErrorInfo(); + CComPtr pErrorInfo(p); + if (nullptr != p) + p->Release(); + + if (pErrorInfo) + o << L"\n" << e.Description(); + + return o.str(); +} + +void ShowComError(_com_error& e, const tstring& rsAdditionalInfo) +{ + tstring sErrorMsg = ComException2Msg(e, rsAdditionalInfo); + LogIt(sErrorMsg); + Quotes_MessageBox(nullptr, sErrorMsg.c_str(), MB_OK | MB_ICONERROR); +} diff --git a/plugins/CurrencyRates/src/ComHelper.h b/plugins/CurrencyRates/src/ComHelper.h new file mode 100644 index 0000000000..343d436785 --- /dev/null +++ b/plugins/CurrencyRates/src/ComHelper.h @@ -0,0 +1,7 @@ +#ifndef __37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__ +#define __37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__ + +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/CurrencyRates/src/CommonOptionDlg.cpp b/plugins/CurrencyRates/src/CommonOptionDlg.cpp new file mode 100644 index 0000000000..0fdd483abb --- /dev/null +++ b/plugins/CurrencyRates/src/CommonOptionDlg.cpp @@ -0,0 +1,228 @@ +#include "StdAfx.h" + +typedef boost::shared_ptr TAdvSettingsPtr; +typedef std::map 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(); + + if (true == bCreateIfNonExist) { + TAdvSettingsPtr pAdvSet(new CAdvProviderSettings(pProvider)); + g_aAdvSettings.insert(std::make_pair(pProvider, pAdvSet)); + return pAdvSet.get(); + } + + return nullptr; +} + +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 < _countof(pszRefreshRateTypes); ++i) + ::SendMessage(hwndCombo, CB_ADDSTRING, 0, reinterpret_cast(pszRefreshRateTypes[i])); + + int nRefreshRateType = db_get_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateType, RRT_MINUTES); + if (nRefreshRateType < RRT_SECONDS || nRefreshRateType > RRT_HOURS) + nRefreshRateType = RRT_MINUTES; + + UINT nRate = db_get_w(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(::SendMessage(reinterpret_cast(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(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(lp); + switch (pNMHDR->code) { + case PSN_KILLACTIVE: + { + BOOL bOk = FALSE; + UINT nRefreshRate = ::GetDlgItemInt(hWnd, IDC_EDIT_REFRESH_RATE, &bOk, FALSE); + ERefreshRateType nType = static_cast(::SendDlgItemMessage(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(::SendDlgItemMessage(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; + db_set_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateType, nType); + db_set_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateValue, nRefreshRate); + + tstring s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_CONTACT_LIST_FORMAT)); + db_set_ws(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbDisplayNameFormat, s.c_str()); + + s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_STATUS_MESSAGE_FORMAT)); + db_set_ws(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbStatusMsgFormat, s.c_str()); + + s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_TENDENCY_FORMAT)); + db_set_ws(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; + } +} diff --git a/plugins/CurrencyRates/src/CommonOptionDlg.h b/plugins/CurrencyRates/src/CommonOptionDlg.h new file mode 100644 index 0000000000..5e39582da0 --- /dev/null +++ b/plugins/CurrencyRates/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/CurrencyRates/src/CreateFilePath.cpp b/plugins/CurrencyRates/src/CreateFilePath.cpp new file mode 100644 index 0000000000..449d8b7ae7 --- /dev/null +++ b/plugins/CurrencyRates/src/CreateFilePath.cpp @@ -0,0 +1,33 @@ +#include "StdAfx.h" + +static wchar_t InvalidSymbols[] = { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }; + +static wchar_t replace_invalid_symbol(wchar_t chr) +{ + for (int i = 0; i < _countof(InvalidSymbols); ++i) + if (chr == InvalidSymbols[i]) + return '_'; + + 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) +{ + wchar_t szPath[_MAX_PATH]; + ::GetModuleFileName(g_plugin.getInst(), szPath, _MAX_PATH); + + wchar_t* p = wcsrchr(szPath, '\\'); + if (p) + *p = 0; + + tstring s(rsName); + prepare_name(s); + tostringstream o; + o << szPath << L"\\Quotes\\" << s; + return o.str(); +} \ No newline at end of file diff --git a/plugins/CurrencyRates/src/CreateFilePath.h b/plugins/CurrencyRates/src/CreateFilePath.h new file mode 100644 index 0000000000..e4a88494fb --- /dev/null +++ b/plugins/CurrencyRates/src/CreateFilePath.h @@ -0,0 +1,6 @@ +#ifndef _aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__ +#define _aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__ + +tstring CreateFilePath(const tstring& rsName); + +#endif //_aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__ diff --git a/plugins/CurrencyRates/src/CurrencyConverter.cpp b/plugins/CurrencyRates/src/CurrencyConverter.cpp new file mode 100644 index 0000000000..6edf7f812b --- /dev/null +++ b/plugins/CurrencyRates/src/CurrencyConverter.cpp @@ -0,0 +1,266 @@ +#include "StdAfx.h" +#include "QuotesProviderCurrencyConverter.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" + +static CQuotesProviderCurrencyConverter* get_currency_converter_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; + if (auto p = dynamic_cast(pProvider.get())) + { + return p; + } + } + + assert(!"We should never get here!"); + return nullptr; +} + +CQuotesProviderBase::CQuoteSection get_quotes(const CQuotesProviderCurrencyConverter* pProvider = nullptr) +{ + if (nullptr == pProvider) + pProvider = get_currency_converter_provider(); + + if (pProvider) { + const auto& rQuotes = pProvider->GetQuotes(); + if (rQuotes.GetSectionCount() > 0) + return rQuotes.GetSection(0); + } + + return CQuotesProviderBase::CQuoteSection(); +} + +inline tstring make_quote_name(const CQuotesProviderBase::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(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); + int nTo = static_cast(::SendDlgItemMessage(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(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); + int nTo = static_cast(::SendDlgItemMessage(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: + TranslateDialogDefault(hDlg); + { + MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX, false); + assert(hWL); + WindowList_Add(hWL, hDlg); + + Window_SetIcon_IcoLib(hDlg, Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER)); + + 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 auto pProvider = get_currency_converter_provider(); + const auto& rSection = get_quotes(pProvider); + auto cQuotes = rSection.GetQuoteCount(); + for (auto i = 0u; i < cQuotes; ++i) { + const auto& rQuote = rSection.GetQuote(i); + tstring sName = make_quote_name(rQuote); + LPCTSTR pszName = sName.c_str(); + LRESULT nFrom = ::SendMessage(hcbxFrom, CB_ADDSTRING, 0, reinterpret_cast(pszName)); + LRESULT nTo = ::SendMessage(hcbxTo, CB_ADDSTRING, 0, reinterpret_cast(pszName)); + + if (0 == mir_wstrcmpi(rQuote.GetID().c_str(), sFromQuoteID.c_str())) { + ::SendMessage(hcbxFrom, CB_SETCURSEL, nFrom, 0); + } + + if (0 == mir_wstrcmpi(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") << L" " << pi.m_sName << L""; + + ::SetDlgItemText(hDlg, IDC_SYSLINK_PROVIDER, o.str().c_str()); + + ::SendDlgItemMessage(hDlg, IDC_BUTTON_SWAP, BM_SETIMAGE, IMAGE_ICON, LPARAM(Quotes_LoadIconEx(IDI_ICON_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: + { + MWindowList 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_DESTROY: + Window_FreeIcon_IcoLib(hDlg); + break; + + 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(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); + size_t nTo = static_cast(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_INTO, CB_GETCURSEL, 0, 0)); + if ((CB_ERR != nFrom) && (CB_ERR != nTo) && (nFrom != nTo)) { + const auto& rSection = get_quotes(); + size_t cQuotes = rSection.GetQuoteCount(); + if ((nFrom < cQuotes) && (nTo < cQuotes)) { + auto from = rSection.GetQuote(nFrom); + auto to = rSection.GetQuote(nTo); + + db_set_ws(NULL, QUOTES_MODULE_NAME, DB_STR_CC_QUOTE_FROM_ID, from.GetID().c_str()); + db_set_ws(NULL, QUOTES_MODULE_NAME, DB_STR_CC_QUOTE_TO_ID, to.GetID().c_str()); + + const auto pProvider = get_currency_converter_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(); + } + + if (false == sError.empty()) + 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; + } + break; + + case WM_NOTIFY: + LPNMHDR pNMHDR = reinterpret_cast(lp); + switch (pNMHDR->code) { + case NM_CLICK: + if (IDC_SYSLINK_PROVIDER == wp) { + PNMLINK pNMLink = reinterpret_cast(pNMHDR); + ::ShellExecute(hDlg, L"open", pNMLink->item.szUrl, nullptr, nullptr, SW_SHOWNORMAL); + } + break; + } + break; + } + return (FALSE); +} + +INT_PTR QuotesMenu_CurrencyConverter(WPARAM, LPARAM) +{ + MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX, true); + HWND hWnd = WindowList_Find(hWL, NULL); + if (nullptr != hWnd) { + SetForegroundWindow(hWnd); + SetFocus(hWnd); + } + else CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CURRENCY_CONVERTER), nullptr, CurrencyConverterDlgProc, 0); + + return 0; +} diff --git a/plugins/CurrencyRates/src/CurrencyConverter.h b/plugins/CurrencyRates/src/CurrencyConverter.h new file mode 100644 index 0000000000..57988413fe --- /dev/null +++ b/plugins/CurrencyRates/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/CurrencyRates/src/DBUtils.cpp b/plugins/CurrencyRates/src/DBUtils.cpp new file mode 100644 index 0000000000..c041bbf51c --- /dev/null +++ b/plugins/CurrencyRates/src/DBUtils.cpp @@ -0,0 +1,47 @@ +#include "StdAfx.h" + +std::string Quotes_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue /*= NULL*/) +{ + std::string sResult; + char* pszSymbol = db_get_sa(hContact, szModule, szSetting); + if (nullptr != pszSymbol) { + sResult = pszSymbol; + mir_free(pszSymbol); + } + else if (nullptr != pszDefValue) + sResult = pszDefValue; + + return sResult; +} + +std::wstring Quotes_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue/* = NULL*/) +{ + std::wstring sResult; + wchar_t* pszSymbol = db_get_wsa(hContact, szModule, szSetting); + if (nullptr != pszSymbol) { + sResult = pszSymbol; + mir_free(pszSymbol); + } + else if (nullptr != pszDefValue) + sResult = pszDefValue; + + return sResult; +} + +bool Quotes_DBWriteDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double dValue) +{ + return 0 == db_set_blob(hContact, szModule, szSetting, &dValue, sizeof(dValue)); +} + +bool Quotes_DBReadDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double& rdValue) +{ + DBVARIANT dbv = { 0 }; + dbv.type = DBVT_BLOB; + + bool bResult = ((0 == db_get(hContact, szModule, szSetting, &dbv)) && (DBVT_BLOB == dbv.type)); + if (bResult) + rdValue = *reinterpret_cast(dbv.pbVal); + + db_free(&dbv); + return bResult; +} diff --git a/plugins/CurrencyRates/src/DBUtils.h b/plugins/CurrencyRates/src/DBUtils.h new file mode 100644 index 0000000000..ae2d1d2a00 --- /dev/null +++ b/plugins/CurrencyRates/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(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue = NULL); +std::wstring Quotes_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue = NULL); + + +#define Quotes_DBGetStringT Quotes_DBGetStringW + +bool Quotes_DBWriteDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double dValue); +bool Quotes_DBReadDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double& rdValue); + +#endif //__54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__ diff --git a/plugins/CurrencyRates/src/EconomicRateInfo.h b/plugins/CurrencyRates/src/EconomicRateInfo.h new file mode 100644 index 0000000000..0e47893ee0 --- /dev/null +++ b/plugins/CurrencyRates/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" // 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/CurrencyRates/src/ExtraImages.cpp b/plugins/CurrencyRates/src/ExtraImages.cpp new file mode 100644 index 0000000000..2111ccf089 --- /dev/null +++ b/plugins/CurrencyRates/src/ExtraImages.cpp @@ -0,0 +1,30 @@ +#include "StdAfx.h" + +static HANDLE hExtraIcon; + +void Quotes_InitExtraIcons() +{ + hExtraIcon = ExtraIcon_RegisterIcolib(ICON_STR_QUOTE, QUOTES_PROTOCOL_NAME, QUOTES_PROTOCOL_NAME "_" ICON_STR_MAIN); +} + +bool SetContactExtraImage(MCONTACT hContact, EImageIndex nIndex) +{ + if (!hExtraIcon) + 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 = nullptr; + } + return ExtraIcon_SetIcon(hExtraIcon, hContact, hIcolib) == 0; +} diff --git a/plugins/CurrencyRates/src/ExtraImages.h b/plugins/CurrencyRates/src/ExtraImages.h new file mode 100644 index 0000000000..4888203a6d --- /dev/null +++ b/plugins/CurrencyRates/src/ExtraImages.h @@ -0,0 +1,16 @@ +#ifndef __9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__ +#define __9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__ + +enum EImageIndex +{ + eiUp = 0, + eiDown = 1, + eiNotChanged = 2, + eiEmpty = 3 +}; + +bool SetContactExtraImage(MCONTACT hContact, EImageIndex nIndex); + +void Quotes_InitExtraIcons(void); + +#endif //__9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__ diff --git a/plugins/CurrencyRates/src/Forex.cpp b/plugins/CurrencyRates/src/Forex.cpp new file mode 100644 index 0000000000..6a1845cf93 --- /dev/null +++ b/plugins/CurrencyRates/src/Forex.cpp @@ -0,0 +1,337 @@ +// Forex.cpp : Defines the exported functions for the DLL application. +// + +#include "stdafx.h" + +CMPlugin g_plugin; + +HANDLE g_hEventWorkThreadStop; +//int g_nStatus = ID_STATUS_OFFLINE; +bool g_bAutoUpdate = true; +HGENMENU g_hMenuEditSettings = nullptr; +HGENMENU g_hMenuOpenLogFile = nullptr; +#ifdef CHART_IMPLEMENT +HGENMENU g_hMenuChart = nullptr; +#endif +HGENMENU g_hMenuRefresh = nullptr, g_hMenuRoot = nullptr; + +#define DB_STR_AUTO_UPDATE "AutoUpdate" + +typedef std::vector THandles; +THandles g_ahThreads; +HGENMENU g_hEnableDisableMenu; +HANDLE g_hTBButton; + +LPSTR g_pszAutoUpdateCmd = "Quotes/Enable-Disable Auto Update"; +LPSTR g_pszCurrencyConverter = "Quotes/CurrencyConverter"; + +void UpdateMenu(bool bAutoUpdate) +{ + if (bAutoUpdate) // to enable auto-update + Menu_ModifyItem(g_hEnableDisableMenu, LPGENW("Auto Update Enabled"), Quotes_GetIconHandle(IDI_ICON_MAIN)); + else // to disable auto-update + Menu_ModifyItem(g_hEnableDisableMenu, LPGENW("Auto Update Disabled"), Quotes_GetIconHandle(IDI_ICON_DISABLED)); + + CallService(MS_TTB_SETBUTTONSTATE, reinterpret_cast(g_hTBButton), !bAutoUpdate ? TTBST_PUSHED : 0); +} + +INT_PTR QuotesMenu_RefreshAll(WPARAM, LPARAM) +{ + const CQuotesProviders::TQuotesProviders& apProviders = CModuleInfo::GetQuoteProvidersPtr()->GetProviders(); + std::for_each(apProviders.begin(), apProviders.end(), boost::bind(&IQuotesProvider::RefreshAllContacts, _1)); + return 0; +} + +INT_PTR QuotesMenu_EnableDisable(WPARAM, LPARAM) +{ + g_bAutoUpdate = (g_bAutoUpdate) ? false : true; + db_set_b(NULL, QUOTES_MODULE_NAME, DB_STR_AUTO_UPDATE, g_bAutoUpdate); + + const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr(); + const CQuotesProviders::TQuotesProviders& rapProviders = pProviders->GetProviders(); + std::for_each(std::begin(rapProviders), std::end(rapProviders), [](const CQuotesProviders::TQuotesProviderPtr& pProvider) { + pProvider->RefreshSettings(); + if (g_bAutoUpdate) + pProvider->RefreshAllContacts(); + }); + UpdateMenu(g_bAutoUpdate); + + return 0; +} + +void InitMenu() +{ + CMenuItem mi(&g_plugin); + mi.flags = CMIF_UNICODE; + mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Currency rates"), 0, Quotes_GetIconHandle(IDI_ICON_MAIN)); + Menu_ConfigureItem(mi.root, MCI_OPT_UID, "B474F556-22B6-42A1-A91E-22FE4F671388"); + + SET_UID(mi, 0x9de6716, 0x3591, 0x48c4, 0x9f, 0x64, 0x1b, 0xfd, 0xc6, 0xd1, 0x34, 0x97); + mi.name.w = LPGENW("Enable/Disable Auto Update"); + mi.position = 10100001; + mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN); + mi.pszService = g_pszAutoUpdateCmd; + g_hEnableDisableMenu = Menu_AddMainMenuItem(&mi); + CreateServiceFunction(mi.pszService, QuotesMenu_EnableDisable); + UpdateMenu(g_bAutoUpdate); + + SET_UID(mi, 0x91cbabf6, 0x5073, 0x4a78, 0x84, 0x8, 0x34, 0x61, 0xc1, 0x8a, 0x34, 0xd9); + mi.name.w = LPGENW("Refresh All Rates"); + mi.position = 20100001; + mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN); + mi.pszService = "Quotes/RefreshAll"; + Menu_AddMainMenuItem(&mi); + CreateServiceFunction(mi.pszService, QuotesMenu_RefreshAll); + + SET_UID(mi, 0x3663409c, 0xbd36, 0x473b, 0x9b, 0x4f, 0xff, 0x80, 0xf6, 0x2c, 0xdf, 0x9b); + mi.name.w = LPGENW("Currency Converter..."); + mi.position = 20100002; + mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER); + mi.pszService = g_pszCurrencyConverter; + Menu_AddMainMenuItem(&mi); + CreateServiceFunction(mi.pszService, QuotesMenu_CurrencyConverter); + + SET_UID(mi, 0x7cca4fd9, 0x903f, 0x4b7d, 0x93, 0x7a, 0x18, 0x63, 0x23, 0xd4, 0xa9, 0xa9); + mi.name.w = LPGENW("Export All Currency Rates"); + mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_EXPORT); + mi.pszService = "Quotes/ExportAll"; + mi.position = 20100003; + Menu_AddMainMenuItem(&mi); + CreateServiceFunction(mi.pszService, QuotesMenu_ExportAll); + + SET_UID(mi, 0xa994d3b, 0x77c2, 0x4612, 0x8d, 0x5, 0x6a, 0xae, 0x8c, 0x21, 0xbd, 0xc9); + mi.name.w = LPGENW("Import All Currency Rates"); + mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_IMPORT); + mi.pszService = "Quotes/ImportAll"; + mi.position = 20100004; + Menu_AddMainMenuItem(&mi); + CreateServiceFunction(mi.pszService, QuotesMenu_ImportAll); + + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Quotes_PrebuildContactMenu); + + g_hMenuRoot = mi.root = g_plugin.addRootMenu(MO_CONTACT, _T(QUOTES_PROTOCOL_NAME), 0, Quotes_GetIconHandle(IDI_ICON_MAIN)); + Menu_ConfigureItem(mi.root, MCI_OPT_UID, "C259BE01-642C-461E-997D-0E756B2A3AD6"); + + SET_UID(mi, 0xb9812194, 0x3235, 0x4e76, 0xa3, 0xa4, 0x73, 0x32, 0x96, 0x1c, 0x1c, 0xf4); + mi.name.w = LPGENW("Refresh"); + mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_REFRESH); + mi.pszService = "Quotes/RefreshContact"; + g_hMenuRefresh = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); + Menu_ConfigureItem(g_hMenuRefresh, MCI_OPT_EXECPARAM, INT_PTR(0)); + CreateServiceFunction(mi.pszService, QuotesMenu_RefreshContact); + + SET_UID(mi, 0x19a16fa2, 0xf370, 0x4201, 0x92, 0x9, 0x25, 0xde, 0x4e, 0x55, 0xf9, 0x1a); + mi.name.w = LPGENW("Open Log File..."); + mi.hIcolibItem = nullptr; + mi.pszService = "Quotes/OpenLogFile"; + g_hMenuOpenLogFile = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); + Menu_ConfigureItem(g_hMenuOpenLogFile, MCI_OPT_EXECPARAM, 1); + CreateServiceFunction(mi.pszService, QuotesMenu_OpenLogFile); + +#ifdef CHART_IMPLEMENT + SET_UID(mi, 0x65da7256, 0x43a2, 0x4857, 0xac, 0x52, 0x1c, 0xb7, 0xff, 0xd7, 0x96, 0xfa); + mi.name.w = LPGENW("Chart..."); + mi.hIcolibItem = nullptr; + mi.pszService = "Quotes/Chart"; + g_hMenuChart = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); + CreateServiceFunction(mi.pszService, QuotesMenu_Chart); +#endif + + SET_UID(mi, 0xac5fc17, 0x5640, 0x4f81, 0xa3, 0x44, 0x8c, 0xb6, 0x9a, 0x5c, 0x98, 0xf); + mi.name.w = LPGENW("Edit Settings..."); + mi.hIcolibItem = nullptr; + mi.pszService = "Quotes/EditSettings"; + g_hMenuEditSettings = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); +#ifdef CHART_IMPLEMENT + Menu_ConfigureItem(g_hMenuEditSettings, MCI_OPT_EXECPARAM, 3); +#else + Menu_ConfigureItem(g_hMenuEditSettings, MCI_OPT_EXECPARAM, 2); +#endif + CreateServiceFunction(mi.pszService, QuotesMenu_EditSettings); +} + +int Quotes_OnToolbarLoaded(WPARAM, LPARAM) +{ + TTBButton ttb = {}; + ttb.name = LPGEN("Enable/Disable Currency Rates Auto Update"); + ttb.pszService = g_pszAutoUpdateCmd; + ttb.pszTooltipUp = LPGEN("Currency Rates Auto Update Enabled"); + ttb.pszTooltipDn = LPGEN("Currency Rates Auto Update Disabled"); + ttb.hIconHandleUp = Quotes_GetIconHandle(IDI_ICON_MAIN); + ttb.hIconHandleDn = Quotes_GetIconHandle(IDI_ICON_DISABLED); + ttb.dwFlags = ((g_bAutoUpdate) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE; + g_hTBButton = g_plugin.addTTB(&ttb); + + ttb.name = LPGEN("Currency Converter"); + ttb.pszService = g_pszCurrencyConverter; + ttb.pszTooltipUp = LPGEN("Currency Converter"); + ttb.pszTooltipDn = LPGEN("Currency Converter"); + ttb.hIconHandleUp = Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER); + ttb.hIconHandleDn = Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER); + ttb.dwFlags = TTBBF_VISIBLE; + g_plugin.addTTB(&ttb); + + return 0; +} + +static void WorkingThread(void *pParam) +{ + IQuotesProvider *pProvider = reinterpret_cast(pParam); + assert(pProvider); + + if (pProvider) + pProvider->Run(); +} + +int QuotesEventFunc_OnModulesLoaded(WPARAM, LPARAM) +{ + CHTTPSession::Init(); + + g_hEventWorkThreadStop = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); + HookEvent(ME_USERINFO_INITIALISE, QuotesEventFunc_OnUserInfoInit); + + HookEvent(ME_CLIST_DOUBLECLICKED, Quotes_OnContactDoubleClick); + + HookEvent(ME_TTB_MODULELOADED, Quotes_OnToolbarLoaded); + + g_bAutoUpdate = 1 == db_get_b(NULL, QUOTES_MODULE_NAME, DB_STR_AUTO_UPDATE, 1); + + InitMenu(); + + 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; + g_ahThreads.push_back(mir_forkthread(WorkingThread, pProvider.get())); + } + + return 0; +} + +int QuotesEventFunc_OnContactDeleted(WPARAM wParam, LPARAM) +{ + MCONTACT hContact = MCONTACT(wParam); + + const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr(); + CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact); + if (pProvider) + pProvider->DeleteContact(hContact); + return 0; +} + +INT_PTR QuoteProtoFunc_GetCaps(WPARAM wParam, LPARAM) +{ + switch (wParam) { + case PFLAG_UNIQUEIDTEXT: + return (INT_PTR)Translate("Currency Symbol"); + } + + return 0; +} + +INT_PTR QuoteProtoFunc_GetStatus(WPARAM, LPARAM) +{ + return g_bAutoUpdate ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; +} + +void WaitForWorkingThreads() +{ + size_t cThreads = g_ahThreads.size(); + if (cThreads > 0) { + HANDLE* paHandles = &*(g_ahThreads.begin()); + ::WaitForMultipleObjects((DWORD)cThreads, paHandles, TRUE, INFINITE); + } +} + + +int QuotesEventFunc_PreShutdown(WPARAM, LPARAM) +{ + ::SetEvent(g_hEventWorkThreadStop); + + CModuleInfo::GetInstance().OnMirandaShutdown(); + return 0; +} + +int QuotesEventFunc_OptInitialise(WPARAM wp, LPARAM/* lp*/) +{ + const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr(); + const CQuotesProviders::TQuotesProviders& rapProviders = pProviders->GetProviders(); + + OPTIONSDIALOGPAGE odp = {}; + odp.position = 910000000; + odp.szTitle.w = _T(QUOTES_PROTOCOL_NAME); + odp.szGroup.w = LPGENW("Network"); + odp.flags = ODPF_USERINFOTAB | ODPF_UNICODE; + + std::for_each(rapProviders.begin(), rapProviders.end(), boost::bind(&IQuotesProvider::ShowPropertyPage, _1, wp, boost::ref(odp))); + return 0; +} + +inline int Quotes_UnhookEvent(HANDLE h) +{ + return UnhookEvent(h); +} + +///////////////////////////////////////////////////////////////////////////////////////// + +EXTERN_C __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; + +///////////////////////////////////////////////////////////////////////////////////////// + +PLUGININFOEX pluginInfoEx = +{ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {E882056D-0D1D-4131-9A98-404CBAEA6A9C} + { 0xe882056d, 0xd1d, 0x4131, { 0x9a, 0x98, 0x40, 0x4c, 0xba, 0xea, 0x6a, 0x9c } } +}; + +CMPlugin::CMPlugin() : + PLUGIN(QUOTES_PROTOCOL_NAME, pluginInfoEx) +{ + RegisterProtocol(PROTOTYPE_VIRTUAL); + SetUniqueId(DB_STR_QUOTE_SYMBOL); +} + +///////////////////////////////////////////////////////////////////////////////////////// + +int CMPlugin::Load(void) +{ + if (!CModuleInfo::Verify()) + return 1; + + Quotes_IconsInit(); + Quotes_InitExtraIcons(); + + CreateProtoServiceFunction(QUOTES_PROTOCOL_NAME, PS_GETCAPS, QuoteProtoFunc_GetCaps); + CreateProtoServiceFunction(QUOTES_PROTOCOL_NAME, PS_GETSTATUS, QuoteProtoFunc_GetStatus); + + HookEvent(ME_SYSTEM_MODULESLOADED, QuotesEventFunc_OnModulesLoaded); + HookEvent(ME_DB_CONTACT_DELETED, QuotesEventFunc_OnContactDeleted); + HookEvent(ME_SYSTEM_PRESHUTDOWN, QuotesEventFunc_PreShutdown); + HookEvent(ME_OPT_INITIALISE, QuotesEventFunc_OptInitialise); + + CreateServiceFunction(MS_QUOTES_EXPORT, Quotes_Export); + CreateServiceFunction(MS_QUOTES_IMPORT, Quotes_Import); + + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +int CMPlugin::Unload(void) +{ + WaitForWorkingThreads(); + + ::CloseHandle(g_hEventWorkThreadStop); + return 0; +} diff --git a/plugins/CurrencyRates/src/HTMLParserMS.cpp b/plugins/CurrencyRates/src/HTMLParserMS.cpp new file mode 100644 index 0000000000..7fa5449444 --- /dev/null +++ b/plugins/CurrencyRates/src/HTMLParserMS.cpp @@ -0,0 +1,254 @@ +#include "StdAfx.h" + +using _com_util::CheckError; + +class CHTMLNode : public IHTMLNode +{ +public: + typedef CComPtr TComPtr; + typedef CComPtr TDocumentPtr; + +protected: + typedef CComPtr 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 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 pTable; + return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTable, reinterpret_cast(&pTable))) && (pTable)); + } + case TableRow: + { + CComPtr pRow; + return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTableRow, reinterpret_cast(&pRow))) && (pRow)); + } + case TableColumn: + { + CComPtr pCol; + return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTableCol, reinterpret_cast(&pCol))) && (pCol)); + } + } + + return false; + } + + virtual tstring GetAttribute(const tstring& rsAttrName)const + { + tstring sAttr; + CComPtr pElement; + if (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast(&pElement))) && pElement) { + _variant_t vAttribute; + BSTR pbstrAttrName = ::SysAllocString(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&) { + } + } + ::SysFreeString(pbstrAttrName); + } + + return sAttr; + } + + virtual tstring GetText()const + { + tstring sText; + CComPtr pElement; + if (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast(&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(&pColl)); + if (FAILED(hr)) { + CComPtr pElement; + if (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast(&pElement))) && pElement) { + CComPtr pDisp; + if (SUCCEEDED(pElement->get_children(&pDisp)) && pDisp) + pDisp->QueryInterface(IID_IHTMLElementCollection, reinterpret_cast(&pColl)); + } + } + + return pColl; + } + +private: + TComPtr m_pElement; + TDocumentPtr m_pDocument; +}; + +CHTMLParserMS::CHTMLParserMS() : m_bCallUninit(false) +{ + try { + CheckError(::CoInitialize(nullptr)); + + m_bCallUninit = true; + + _com_util::CheckError( + ::CoCreateInstance(CLSID_HTMLDocument, + nullptr, + CLSCTX_INPROC_SERVER, + IID_IHTMLDocument2, + (LPVOID*)&m_pDoc) + ); + + CComPtr 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 (m_bCallUninit) + ::CoUninitialize(); +} + +CHTMLParserMS::THTMLNodePtr CHTMLParserMS::ParseString(const tstring& rsHTML) +{ + mir_cslock lck(m_cs); + + CComPtr pMC; + HRESULT hr = m_pMS->ParseString((OLECHAR*)rsHTML.c_str(), 0, &pMC, m_pMkStart, m_pMkFinish); + if (SUCCEEDED(hr) && pMC) { + CComPtr pNewDoc; + hr = pMC->QueryInterface(IID_IHTMLDocument, (LPVOID*)&pNewDoc); + if (SUCCEEDED(hr) && pNewDoc) { + CComPtr pColl; + pNewDoc->get_all(&pColl); + + CHTMLNode::TDocumentPtr pDoc; + pMC->QueryInterface(IID_IHTMLDocument3, (LPVOID*)&pDoc); + return THTMLNodePtr(new CHTMLNode(CHTMLNode::TComPtr(pColl), pDoc)); + } + } + + return THTMLNodePtr(); +} + +bool CHTMLParserMS::IsInstalled() +{ + bool bResult = true; + bool bCallUninit = false; + try { + CheckError(::CoInitialize(nullptr)); + + bCallUninit = true; + + CComPtr pDoc; + _com_util::CheckError( + ::CoCreateInstance(CLSID_HTMLDocument, + nullptr, + CLSCTX_INPROC_SERVER, + IID_IHTMLDocument2, + reinterpret_cast(&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/CurrencyRates/src/HTMLParserMS.h b/plugins/CurrencyRates/src/HTMLParserMS.h new file mode 100644 index 0000000000..4580482dc5 --- /dev/null +++ b/plugins/CurrencyRates/src/HTMLParserMS.h @@ -0,0 +1,32 @@ +#ifndef __3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__ +#define __3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__ + +class CHTMLParserMS : public IHTMLParser +{ +public: + CHTMLParserMS(); + ~CHTMLParserMS(); + + virtual THTMLNodePtr ParseString(const tstring& rsHTML); + + static bool IsInstalled(); + +private: + bool m_bCallUninit; + CComPtr m_pDoc; + CComPtr m_pMS; + CComPtr m_pMkStart; + CComPtr m_pMkFinish; + mutable mir_cs 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/CurrencyRates/src/HTTPSession.cpp b/plugins/CurrencyRates/src/HTTPSession.cpp new file mode 100644 index 0000000000..20f3498e8a --- /dev/null +++ b/plugins/CurrencyRates/src/HTTPSession.cpp @@ -0,0 +1,150 @@ +#include "StdAfx.h" + +class CHTTPSession::CImpl +{ +public: + CImpl() {} + virtual ~CImpl() {} + + virtual bool OpenURL(const tstring& rsURL) = 0; + virtual bool ReadResponce(tstring& rsResponce)const = 0; +}; + +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(nullptr == g_hNetLib); + + NETLIBUSER nlu = {}; + nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE; + nlu.szSettingsModule = QUOTES_PROTOCOL_NAME; + nlu.szDescriptiveName.w = TranslateT("Quotes HTTP connections"); + g_hNetLib = Netlib_RegisterUser(&nlu); + return (nullptr != g_hNetLib); + } + + static bool IsValid() { return nullptr != g_hNetLib; } + + virtual bool OpenURL(const tstring& rsURL) + { + m_aURL.clear(); + + std::string s = quotes_t2a(rsURL.c_str()); + const char* psz = s.c_str(); + m_aURL.insert(m_aURL.begin(), psz, psz + mir_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 = NETLIB_USER_AGENT; + 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 = nullptr; + { + mir_cslock lck(m_mx); + pReply = Netlib_HttpTransaction(g_hNetLib, &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) && (nullptr != strstr(_strlwr(pReply->headers[nIndex].szValue), "utf-8"))) { + wchar_t* p = mir_utf8decodeW(pResult); + rsResponce = p; + mir_free(p); + } + else { + // USES_CONVERSION; + // LPCTSTR p = A2CT(pResult); + rsResponce = quotes_a2t(pResult);//p; + } + + bResult = true; + } + + Netlib_FreeHttpRequest(pReply); + } + + mir_free(nlhr.headers); + + return bResult; + } + +private: + static HNETLIBUSER g_hNetLib; + typedef std::vector TBuffer; + mutable TBuffer m_aURL; + mutable mir_cs m_mx; +}; + +HNETLIBUSER CImplMI::g_hNetLib = nullptr; + +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/CurrencyRates/src/HTTPSession.h b/plugins/CurrencyRates/src/HTTPSession.h new file mode 100644 index 0000000000..ba28a1493c --- /dev/null +++ b/plugins/CurrencyRates/src/HTTPSession.h @@ -0,0 +1,25 @@ +#ifndef __8C9706FF_6B05_4d0d_85B8_5724E5DC0BA4_HTTPSession_h__ +#define __8C9706FF_6B05_4d0d_85B8_5724E5DC0BA4_HTTPSession_h__ + +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 TImpl; + +private: + TImpl m_pImpl; +}; + +#endif //__8C9706FF_6B05_4d0d_85B8_5724E5DC0BA4_HTTPSession_h__ diff --git a/plugins/CurrencyRates/src/IHTMLEngine.h b/plugins/CurrencyRates/src/IHTMLEngine.h new file mode 100644 index 0000000000..48a35b0255 --- /dev/null +++ b/plugins/CurrencyRates/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 THTMLParserPtr; + +public: + IHTMLEngine(void){} + virtual ~IHTMLEngine() {} + + virtual THTMLParserPtr GetParserPtr()const = 0; +}; + +#endif //__85dbfa97_919b_4776_919c_7410a1c3d787_HTMLEngine_h__ diff --git a/plugins/CurrencyRates/src/IHTMLParser.h b/plugins/CurrencyRates/src/IHTMLParser.h new file mode 100644 index 0000000000..5756079eed --- /dev/null +++ b/plugins/CurrencyRates/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 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/CurrencyRates/src/IQuotesProvider.h b/plugins/CurrencyRates/src/IQuotesProvider.h new file mode 100644 index 0000000000..763248aa7f --- /dev/null +++ b/plugins/CurrencyRates/src/IQuotesProvider.h @@ -0,0 +1,39 @@ +#pragma once + +#ifndef __ac71e133_786c_41a7_ab07_625b76ff2a8c_QuotesProvider_h__ +#define __ac71e133_786c_41a7_ab07_625b76ff2a8c_QuotesProvider_h__ + +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(MCONTACT hContact) = 0; + virtual void DeleteContact(MCONTACT hContact) = 0; + + virtual void ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp) = 0; + virtual void RefreshAllContacts() = 0; + virtual void RefreshSettings() = 0; + virtual void RefreshContact(MCONTACT hContact) = 0; + // virtual void SetContactExtraIcon(MCONTACT 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/CurrencyRates/src/IXMLEngine.h b/plugins/CurrencyRates/src/IXMLEngine.h new file mode 100644 index 0000000000..4b87a17166 --- /dev/null +++ b/plugins/CurrencyRates/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 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/CurrencyRates/src/IconLib.cpp b/plugins/CurrencyRates/src/IconLib.cpp new file mode 100644 index 0000000000..9e0a079edc --- /dev/null +++ b/plugins/CurrencyRates/src/IconLib.cpp @@ -0,0 +1,40 @@ +#include "StdAfx.h" + +static IconItem iconList[] = +{ + { LPGEN("Protocol icon"), ICON_STR_MAIN, IDI_ICON_MAIN }, + { LPGEN("Auto Update Disabled"), "auto_update_disabled", IDI_ICON_DISABLED }, + { LPGEN("Quote/Rate up"), "quote_up", IDI_ICON_UP }, + { LPGEN("Quote/Rate down"), "quote_down", IDI_ICON_DOWN }, + { LPGEN("Quote/Rate not changed"), "quote_not_changed", IDI_ICON_NOTCHANGED }, + { LPGEN("Quote Section"), "quote_section", IDI_ICON_SECTION }, + { LPGEN("Quote"), ICON_STR_QUOTE, IDI_ICON_QUOTE }, + { LPGEN("Currency Converter"), "currency_converter", IDI_ICON_CURRENCY_CONVERTER }, + { LPGEN("Refresh"), "refresh", IDI_ICON_REFRESH }, + { LPGEN("Export"), "export", IDI_ICON_EXPORT }, + { LPGEN("Swap button"), "swap", IDI_ICON_SWAP }, + { LPGEN("Import"), "import", IDI_ICON_IMPORT } +}; + +void Quotes_IconsInit() +{ + ::g_plugin.registerIcon(QUOTES_PROTOCOL_NAME, iconList, QUOTES_PROTOCOL_NAME); +} + +HICON Quotes_LoadIconEx(int iconId, bool bBig /*= false*/) +{ + for (int i = 0; i < _countof(iconList); i++) + if (iconList[i].defIconID == iconId) + return IcoLib_GetIconByHandle(iconList[i].hIcolib, bBig); + + return nullptr; +} + +HANDLE Quotes_GetIconHandle(int iconId) +{ + for (int i = 0; i < _countof(iconList); i++) + if (iconList[i].defIconID == iconId) + return iconList[i].hIcolib; + + return nullptr; +} diff --git a/plugins/CurrencyRates/src/IconLib.h b/plugins/CurrencyRates/src/IconLib.h new file mode 100644 index 0000000000..fff9e3a571 --- /dev/null +++ b/plugins/CurrencyRates/src/IconLib.h @@ -0,0 +1,11 @@ +#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 "quote" + +void Quotes_IconsInit(); +HICON Quotes_LoadIconEx(int iconId, bool bBig = false); +HANDLE Quotes_GetIconHandle(int iconId); + +#endif //__8821d334_afac_439e_9a81_76318e1ac4ef_IconLib_h__ diff --git a/plugins/CurrencyRates/src/ImportExport.cpp b/plugins/CurrencyRates/src/ImportExport.cpp new file mode 100644 index 0000000000..31bdd33913 --- /dev/null +++ b/plugins/CurrencyRates/src/ImportExport.cpp @@ -0,0 +1,635 @@ +#include "StdAfx.h" +#include "QuotesProviderCurrencyConverter.h" + +LPCTSTR g_pszXmlValue = L"Value"; +LPCTSTR g_pszXmlName = L"Name"; +LPCTSTR g_pszXmlSetting = L"Setting"; +LPCTSTR g_pszXmlModule = L"Module"; +LPCTSTR g_pszXmlContact = L"Contact"; +LPCTSTR g_pszXmlContacts = L"Contacts"; +LPCTSTR g_pszXmlType = L"type"; +LPCTSTR g_pszXmlTypeByte = L"byte"; +LPCTSTR g_pszXmlTypeWord = L"word"; +LPCTSTR g_pszXmlTypeDword = L"dword"; +LPCTSTR g_pszXmlTypeAsciiz = L"asciiz"; +LPCTSTR g_pszXmlTypeWchar = L"wchar"; +LPCTSTR g_pszXmlTypeUtf8 = L"utf8"; +LPCTSTR g_pszXmlTypeBlob = L"blob"; + +struct CEnumContext +{ + CModuleInfo::TXMLEnginePtr m_pXmlEngine; + IXMLNode::TXMLNodePtr m_pNode; + MCONTACT m_hContact; + LPCSTR m_pszModule; +}; + +struct mir_safety_dbvar +{ + mir_safety_dbvar(DBVARIANT* p) : m_p(p) {} + ~mir_safety_dbvar() { db_free(m_p); } + DBVARIANT* m_p; +}; + +static int enum_contact_settings(const char* szSetting, void *lp) +{ + CEnumContext* ctx = reinterpret_cast(lp); + + DBVARIANT dbv; + if (0 == db_get(ctx->m_hContact, ctx->m_pszModule, szSetting, &dbv)) { + 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; + break; + case DBVT_WCHAR: + sType = g_pszXmlTypeWchar; + if (dbv.pwszVal) + sValue << dbv.pwszVal; + break; + case DBVT_UTF8: + sType = g_pszXmlTypeUtf8; + if (dbv.pszVal) + sValue << dbv.pszVal; + break; + case DBVT_BLOB: + sType = g_pszXmlTypeBlob; + if (dbv.pbVal) { + ptrA buf(mir_base64_encode(dbv.pbVal, dbv.cpbVal)); + if (buf) + sValue << buf; + } + break; + } + + 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, void *lp) +{ + CEnumContext *ctx = (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; + db_enum_settings(ctx->m_hContact, &enum_contact_settings, szModuleName, ctx); + + if (pModule->GetChildCount() > 0) + pXml->AddChild(pModule); + + ctx->m_pNode = pXml; + } + + return 0; +} + +IXMLNode::TXMLNodePtr export_contact(MCONTACT 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; + + db_enum_modules(EnumDbModules, &ctx); + } + return pNode; +} + +LPCTSTR prepare_filter(LPTSTR pszBuffer, size_t cBuffer) +{ + LPTSTR p = pszBuffer; + LPCTSTR pszXml = TranslateT("XML File (*.xml)"); + mir_wstrncpy(p, pszXml, (int)cBuffer); + size_t nLen = mir_wstrlen(pszXml) + 1; + p += nLen; + if (nLen < cBuffer) { + mir_wstrncpy(p, L"*.xml", (int)(cBuffer - nLen)); + p += 6; + nLen += 6; + } + + if (nLen < cBuffer) { + LPCTSTR pszAll = TranslateT("All files (*.*)"); + mir_wstrncpy(p, pszAll, (int)(cBuffer - nLen)); + size_t n = mir_wstrlen(pszAll) + 1; + nLen += n; + p += n; + } + + if (nLen < cBuffer) { + mir_wstrncpy(p, L"*.*", (int)(cBuffer - nLen)); + p += 4; + nLen += 4; + } + + if (nLen < cBuffer) + *p = '\0'; + + return pszBuffer; +} + +bool show_open_file_dialog(bool bOpen, tstring& rsFile) +{ + wchar_t szBuffer[MAX_PATH]; + wchar_t szFilter[MAX_PATH]; + OPENFILENAME ofn; + memset(&ofn, 0, sizeof(ofn)); + + ofn.lStructSize = sizeof(OPENFILENAME); + + ofn.hwndOwner = nullptr; + ofn.lpstrFilter = prepare_filter(szFilter, MAX_PATH); + ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER; + ofn.lpstrDefExt = L"xml"; + if (bOpen) + ofn.Flags |= OFN_FILEMUSTEXIST; + else + ofn.Flags |= OFN_OVERWRITEPROMPT; + + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFile = szBuffer; + ofn.lpstrFile[0] = '\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) +{ + tstring sFileName; + const char* pszFile = reinterpret_cast(lp); + if (nullptr == 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()); + MCONTACT hContact = MCONTACT(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 (auto &cc : Contacts(QUOTES_MODULE_NAME)) { + CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(cc); + if (pProvider) { + IXMLNode::TXMLNodePtr pNode = export_contact(cc, pXmlEngine); + if (pNode) + pRoot->AddChild(pNode); + } + } + } + + return ((true == pXmlEngine->SaveFile(sFileName, pRoot)) ? 0 : 1); +} + +bool set_contact_settings(MCONTACT hContact, DBCONTACTWRITESETTING& dbs) +{ + assert(DBVT_DELETED != dbs.value.type); + return (0 == db_set(hContact, dbs.szModule, dbs.szSetting, &dbs.value)); +} + +bool handle_module(MCONTACT hContact, const IXMLNode::TXMLNodePtr& pXmlModule) +{ + 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 == mir_wstrcmpi(sModuleName.c_str(), L"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 == mir_wstrcmpi(g_pszXmlSetting, sSetting.c_str())) { + size_t cSetChild = pSetting->GetChildCount(); + if (cSetChild >= 2) { + tstring sName; + tstring sValue; + tstring sType; + for (size_t j = 0; j < cSetChild; ++j) { + IXMLNode::TXMLNodePtr pNode = pSetting->GetChildNode(j); + tstring sNode = pNode->GetName(); + if (0 == mir_wstrcmpi(g_pszXmlName, sNode.c_str())) { + sName = pNode->GetText(); + } + else if (0 == mir_wstrcmpi(g_pszXmlValue, sNode.c_str())) { + sValue = pNode->GetText(); + sType = pNode->GetAttributeValue(g_pszXmlType); + } + } + + if ((false == sName.empty()) && (false == sType.empty())) { + std::string s1 = quotes_t2a(sName.c_str()); + dbs.szSetting = s1.c_str(); + if (0 == mir_wstrcmpi(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 == mir_wstrcmpi(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 == mir_wstrcmpi(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 == mir_wstrcmpi(g_pszXmlTypeAsciiz, sType.c_str())) { + ptrA v(mir_u2a(sValue.c_str())); + dbs.value.pszVal = v; + dbs.value.type = DBVT_ASCIIZ; + if (set_contact_settings(hContact, dbs)) + ++cCreatedRecords; + } + else if (0 == mir_wstrcmpi(g_pszXmlTypeUtf8, sType.c_str())) { + T2Utf szValue(sValue.c_str()); + dbs.value.pszVal = szValue; + dbs.value.type = DBVT_UTF8; + if (set_contact_settings(hContact, dbs)) + ++cCreatedRecords; + } + else if (0 == mir_wstrcmpi(g_pszXmlTypeWchar, sType.c_str())) { + ptrW val(mir_wstrdup(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 == mir_wstrcmpi(g_pszXmlTypeBlob, sType.c_str())) { + size_t bufLen; + mir_ptr buf((PBYTE)mir_base64_decode(_T2A(sValue.c_str()), &bufLen)); + if (buf) { + dbs.value.pbVal = buf; + dbs.value.cpbVal = (WORD)bufLen; + dbs.value.type = DBVT_BLOB; + + if (set_contact_settings(hContact, dbs)) + ++cCreatedRecords; + } + } + + if ((true == bCListModule) && (0 == mir_wstrcmpi(sName.c_str(), L"Group"))) + Clist_GroupCreate(NULL, 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 == mir_wstrcmpi(g_pszXmlContacts, sName.c_str())) + cContacts += count_contacts(pNode, true); + else + cContacts += count_contacts(pNode, false); + } + else { + if (0 == mir_wstrcmpi(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) {} + MCONTACT m_hContact; + CQuotesProviders::TQuotesProviderPtr m_pProvider; + bool m_bNewContact; +}; + +IXMLNode::TXMLNodePtr find_quotes_module(const IXMLNode::TXMLNodePtr& pXmlContact) +{ + 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 == mir_wstrcmpi(g_pszXmlModule, sName.c_str())) + && (0 == mir_wstrcmpi(g_sQuotes.c_str(), pNode->GetText().c_str()))) { + return pNode; + } + } + + return IXMLNode::TXMLNodePtr(); +} + +typedef std::pair 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 == mir_wstrcmpi(g_pszXmlName, pXMLSetChild->GetName().c_str())) { + sName = pXMLSetChild->GetText(); + } + else if (0 == mir_wstrcmpi(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 == mir_wstrcmpi(g_pszXmlSetting, pXMLSetting->GetName().c_str()))) { + TNameValue Item = parse_setting_node(pXMLSetting); + if ((0 == mir_wstrcmpi(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) + { + } + + MCONTACT GetContact()const { return m_hContact; } + + private: + virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override + { + 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 == mir_wstrcmpi(g_pszXmlSetting, pNode->GetName().c_str()))) { + TNameValue Item = parse_setting_node(pNode); + if (0 == mir_wstrcmpi(g_sFromID.c_str(), Item.first.c_str())) { + sFromID = Item.second; + } + else if (0 == mir_wstrcmpi(g_sToID.c_str(), Item.first.c_str())) { + sToID = Item.second; + } + } + } + + if ((false == sFromID.empty()) && (false == sToID.empty())) { + m_hContact = rProvider.GetContactByID(sFromID, sToID); + } + } + + tstring GetXMLNodeValue(const char* pszXMLNodeName)const + { + tstring sXMLNodeName = quotes_a2t(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 == mir_wstrcmpi(g_pszXmlSetting, pNode->GetName().c_str()))) { + TNameValue Item = parse_setting_node(pNode); + if (0 == mir_wstrcmpi(Item.first.c_str(), sXMLNodeName.c_str())) { + sValue = Item.second; + break; + } + } + } + + return sValue; + } + + private: + MCONTACT 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 = db_add_contact(); + cst.m_bNewContact = true; + } + else if (impctx.m_nFlags & QUOTES_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 == mir_wstrcmpi(g_pszXmlModule, sName.c_str())) + bResult &= handle_module(cst.m_hContact, pNode); + } + + 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 == mir_wstrcmpi(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 == mir_wstrcmpi(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(lp); + if (nullptr == 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; +} + +INT_PTR QuotesMenu_ImportAll(WPARAM, LPARAM) +{ + return CallService(MS_QUOTES_IMPORT, 0, 0); +} + +INT_PTR QuotesMenu_ExportAll(WPARAM, LPARAM) +{ + return CallService(MS_QUOTES_EXPORT, 0, 0); +} diff --git a/plugins/CurrencyRates/src/ImportExport.h b/plugins/CurrencyRates/src/ImportExport.h new file mode 100644 index 0000000000..f6f29f68c9 --- /dev/null +++ b/plugins/CurrencyRates/src/ImportExport.h @@ -0,0 +1,9 @@ +#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); + +INT_PTR QuotesMenu_ImportAll(WPARAM wp, LPARAM lp); +INT_PTR QuotesMenu_ExportAll(WPARAM wp, LPARAM lp); +#endif //__F86374E6_713C_4600_85FB_903A5CDF7251_IMPORT_EXPORT_H__ diff --git a/plugins/CurrencyRates/src/IsWithinAccuracy.h b/plugins/CurrencyRates/src/IsWithinAccuracy.h new file mode 100644 index 0000000000..558dbb87d3 --- /dev/null +++ b/plugins/CurrencyRates/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/CurrencyRates/src/Locale.cpp b/plugins/CurrencyRates/src/Locale.cpp new file mode 100644 index 0000000000..f4515b847e --- /dev/null +++ b/plugins/CurrencyRates/src/Locale.cpp @@ -0,0 +1,59 @@ +#include "StdAfx.h" + +const std::locale GetSystemLocale() +{ + return std::locale(""); +} + +tstring get_int_registry_value(LPCTSTR pszValueName) +{ + tstring sResult; + HKEY hKey = nullptr; + LONG lResult = ::RegOpenKeyEx(HKEY_CURRENT_USER, + L"Control Panel\\International", 0, KEY_QUERY_VALUE, &hKey); + if ((ERROR_SUCCESS == lResult) && (nullptr != 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 aBuffer(dwSize); + lResult = ::RegQueryValueEx(hKey, pszValueName, nullptr, nullptr, reinterpret_cast(&*aBuffer.begin()), &dwSize); + if (ERROR_SUCCESS == lResult) + std::copy(aBuffer.begin(), aBuffer.end(), std::back_inserter(sResult)); + } + } + + if (nullptr != hKey) { + lResult = ::RegCloseKey(hKey); + assert(ERROR_SUCCESS == lResult); + } + + return sResult; +} + +LPCTSTR date_win_2_boost(const tstring& sFrmt) +{ + if (sFrmt == L"dd/MM/yy") + return L"%d/%m/%y"; + if (sFrmt == L"yyyy-MM-dd") + return L"%y-%m-%d"; + return L"%d.%m.%y"; +} + +LPCTSTR time_win_2_boost(const tstring& sFrmt) +{ + if (sFrmt == L"H:mm" || sFrmt == L"HH:mm") + return L"%H:%M"; + + return L"%H:%M:%S"; +} + +LPCTSTR Quotes_GetDateFormat(bool bShort) +{ + return date_win_2_boost(get_int_registry_value(bShort ? L"sShortDate" : L"sLongDate")); +} + +LPCTSTR Quotes_GetTimeFormat(bool bShort) +{ + return time_win_2_boost(get_int_registry_value(bShort ? L"sShortTime" : L"sTimeFormat")); +} diff --git a/plugins/CurrencyRates/src/Locale.h b/plugins/CurrencyRates/src/Locale.h new file mode 100644 index 0000000000..1add176847 --- /dev/null +++ b/plugins/CurrencyRates/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(); +LPCTSTR Quotes_GetDateFormat(bool bShort); +LPCTSTR Quotes_GetTimeFormat(bool bShort); + +#endif //__11f7afd0_5a66_4029_8bf3_e3c66346b349_Locale_h_ diff --git a/plugins/CurrencyRates/src/Log.cpp b/plugins/CurrencyRates/src/Log.cpp new file mode 100644 index 0000000000..fcfb0adc35 --- /dev/null +++ b/plugins/CurrencyRates/src/Log.cpp @@ -0,0 +1,41 @@ +#include "StdAfx.h" + +namespace +{ + mir_cs g_Mutex; + + tstring get_log_file_name() + { + return CreateFilePath(L"Quotes.log"); + } + + bool is_log_enabled() + { +#ifdef _DEBUG + return true; +#else + return (1 == db_get_b(NULL, QUOTES_PROTOCOL_NAME, DB_STR_ENABLE_LOG, false)); +#endif + } + + void do_log(const tstring& rsFileName, const tstring& rsMsg) + { + mir_cslock lck(g_Mutex); + tofstream file(rsFileName.c_str(), std::ios::ate | std::ios::app); + if (file.good()) + { + wchar_t szTime[20]; + _tstrtime_s(szTime); + file << szTime << L" ================================>\n" << rsMsg << L"\n\n"; + } + } +} + +void LogIt(const tstring& rsMsg) +{ + if (is_log_enabled()) + { + tstring sFileName = get_log_file_name(); + do_log(sFileName, rsMsg); + } +} diff --git a/plugins/CurrencyRates/src/Log.h b/plugins/CurrencyRates/src/Log.h new file mode 100644 index 0000000000..b62ae9ac52 --- /dev/null +++ b/plugins/CurrencyRates/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(const tstring& rsMsg); + +#endif //__653719be_16d6_4058_8555_8aa7d5404214_OutputDlg_h__ diff --git a/plugins/CurrencyRates/src/ModuleInfo.cpp b/plugins/CurrencyRates/src/ModuleInfo.cpp new file mode 100644 index 0000000000..f5679630f6 --- /dev/null +++ b/plugins/CurrencyRates/src/ModuleInfo.cpp @@ -0,0 +1,99 @@ +#include "StdAfx.h" + +static CModuleInfo::TXMLEnginePtr g_pXMLEngine; +static CModuleInfo::THTMLEnginePtr g_pHTMLEngine; +static mir_cs g_lmParsers; + +CModuleInfo::CModuleInfo() +{ +} + +CModuleInfo::~CModuleInfo() +{ +} + +CModuleInfo& CModuleInfo::GetInstance() +{ + static CModuleInfo mi; + return mi; +} + +MWindowList CModuleInfo::GetWindowList(const std::string& rsKey, bool bAllocateIfNonExist /*= true*/) +{ + MWindowList hResult = nullptr; + THandles::const_iterator i = m_ahWindowLists.find(rsKey); + if (i != m_ahWindowLists.end()) { + hResult = i->second; + } + else if (bAllocateIfNonExist) { + hResult = WindowList_Create(); + 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) { + mir_cslock lck(g_lmParsers); + if (!g_pXMLEngine) + g_pXMLEngine = TXMLEnginePtr(new CXMLEngineMI); + } + + return g_pXMLEngine; +} + +CModuleInfo::THTMLEnginePtr CModuleInfo::GetHTMLEngine() +{ + if (!g_pHTMLEngine) { + mir_cslock lck(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(nullptr, 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(nullptr, + TranslateT("Miranda could not load Quotes plugin. Microsoft HTML parser is missing."), + MB_YESNO | MB_ICONQUESTION); + return false; + } + + return true; +} \ No newline at end of file diff --git a/plugins/CurrencyRates/src/ModuleInfo.h b/plugins/CurrencyRates/src/ModuleInfo.h new file mode 100644 index 0000000000..f33a68ff83 --- /dev/null +++ b/plugins/CurrencyRates/src/ModuleInfo.h @@ -0,0 +1,41 @@ +#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 TQuotesProvidersPtr; + typedef boost::shared_ptr TXMLEnginePtr; + typedef boost::shared_ptr THTMLEnginePtr; + +private: + CModuleInfo(); + ~CModuleInfo(void); + +public: + static CModuleInfo& GetInstance(); + + void OnMirandaShutdown(); + MWindowList GetWindowList(const std::string& rsKey, bool bAllocateIfNonExist = true); + + 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 THandles; + THandles m_ahWindowLists; +}; + +#endif //__d0f22b66_3135_4bbe_bee5_a31ea631ce58_ModuleInfo__ diff --git a/plugins/CurrencyRates/src/QuoteChart.cpp b/plugins/CurrencyRates/src/QuoteChart.cpp new file mode 100644 index 0000000000..b1f4ec8f91 --- /dev/null +++ b/plugins/CurrencyRates/src/QuoteChart.cpp @@ -0,0 +1,101 @@ +#include "StdAfx.h" + +#ifdef CHART_IMPLEMENT + +namespace +{ + class CMyJob : private boost::noncopyable + { + private: + CMyJob(LPCTSTR pszName = nullptr): m_hJob(::CreateJobObject(nullptr,pszName)) + { + if(m_hJob) + { + JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 }; + jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; + if(0 == ::SetInformationJobObject(m_hJob,JobObjectExtendedLimitInformation,&jeli,sizeof(jeli))) + { +#ifdef OUTPUT_TO_DEBUG_VIEWER + ::OutputDebugString(_T("Error occurred during the job initialization\n")); +#endif + } + } + + } + ~CMyJob() + { + if(m_hJob) + { + ::CloseHandle(m_hJob); + } + } + + public: + static CMyJob& GetInstance() + { + static CMyJob g_job(_T("MirandaJob_E12D5E9C_00E7_4FFA_9831_F35E45C6EBDA")); + return g_job; + } + + bool AssignProcess(HANDLE hProcess) + { + if(m_hJob && hProcess) + { + auto b = (TRUE == ::AssignProcessToJobObject(m_hJob,hProcess)); + return b; + } + + return false; + } + + private: + HANDLE m_hJob; + }; + +} + +INT_PTR QuotesMenu_Chart(WPARAM wp, LPARAM /*lp*/) +{ +#ifdef _UNICODE + MCONTACT hContact = static_cast(wp); + if (NULL == hContact) + return 0; + + auto sLogFileName = GetContactLogFileName(hContact); + + if(auto hWnd = ::FindWindow(nullptr,_T("Miranda Quotes Chart"))) + { + COPYDATASTRUCT copydata_struct; + copydata_struct.cbData = static_cast(sLogFileName.size()*sizeof(TCHAR)); + copydata_struct.lpData = const_cast(static_cast(sLogFileName.c_str())); + copydata_struct.dwData = 0x1945; + + SendMessage(hWnd,WM_COPYDATA,0,reinterpret_cast(©data_struct)); + } + else + { + STARTUPINFO si; + PROCESS_INFORMATION pi; + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + si.dwFlags = STARTF_USESHOWWINDOW; + si.wShowWindow = SW_SHOWNORMAL; + ZeroMemory(&pi, sizeof(pi)); + + auto sCmdLine = CreateFilePath(_T("QuotesChart.exe")); + sCmdLine += _T(" \""); + sCmdLine += sLogFileName; + sCmdLine += _T("\""); + if(::CreateProcess(nullptr,const_cast(sCmdLine.c_str()),nullptr,nullptr,FALSE,0,nullptr,nullptr,&si,&pi)) + { + CMyJob::GetInstance().AssignProcess(pi.hProcess); + + ::CloseHandle(pi.hThread); + ::CloseHandle(pi.hProcess); + } + } +#endif + return 0; +} + +#endif //CHART_IMPLEMENT diff --git a/plugins/CurrencyRates/src/QuoteChart.h b/plugins/CurrencyRates/src/QuoteChart.h new file mode 100644 index 0000000000..f42ca17a53 --- /dev/null +++ b/plugins/CurrencyRates/src/QuoteChart.h @@ -0,0 +1,12 @@ +#ifndef __39BE8775_A837_494f_925C_0ABF7910F238_QuoteChart_h__ +#define __39BE8775_A837_494f_925C_0ABF7910F238_QuoteChart_h__ + +#pragma once + +#ifdef CHART_IMPLEMENT + +INT_PTR QuotesMenu_Chart(WPARAM wp, LPARAM lp); + +#endif + +#endif //__39BE8775_A837_494f_925C_0ABF7910F238_QuoteChart_h__ diff --git a/plugins/CurrencyRates/src/QuoteInfoDlg.cpp b/plugins/CurrencyRates/src/QuoteInfoDlg.cpp new file mode 100644 index 0000000000..8f48dd4252 --- /dev/null +++ b/plugins/CurrencyRates/src/QuoteInfoDlg.cpp @@ -0,0 +1,263 @@ +#include "StdAfx.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, g_hMenuRoot; + +#define WINDOW_PREFIX_INFO "Quote Info" + +MCONTACT g_hContact; + +inline bool IsMyContact(MCONTACT hContact) +{ + CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact); + return (nullptr != pProvider); +} + +inline MCONTACT get_contact(HWND hWnd) +{ + return MCONTACT(GetWindowLongPtr(hWnd, GWLP_USERDATA)); +} + +static bool get_fetch_time(time_t& rTime, MCONTACT hContact) +{ + rTime = db_get_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FETCH_TIME, -1); + return (rTime != -1); +} + +INT_PTR CALLBACK QuoteInfoDlgProcImpl(MCONTACT 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)) { + wchar_t szTime[50] = { 0 }; + if (0 == _tctime_s(szTime, 50, &nFetchTime)) { + ::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") << L" " << pi.m_sName << L""; + + ::SetDlgItemText(hdlg, IDC_SYSLINK_PROVIDER, o.str().c_str()); + } + return TRUE; + + case WM_NOTIFY: + LPNMHDR pNMHDR = reinterpret_cast(lParam); + switch (pNMHDR->code) { + case NM_CLICK: + if (IDC_SYSLINK_PROVIDER == wParam) { + PNMLINK pNMLink = reinterpret_cast(pNMHDR); + ::ShellExecute(hdlg, L"open", pNMLink->item.szUrl, nullptr, nullptr, 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) +{ + MCONTACT hContact = MCONTACT(lp); + if (NULL == hContact) + return 0; + + if (false == IsMyContact(hContact)) + return 0; + + g_hContact = hContact; + + OPTIONSDIALOGPAGE odp = {}; + odp.pfnDlgProc = QuoteInfoDlgProc; + odp.position = -2000000000; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_QUOTE_INFO); + odp.szTitle.a = LPGEN("Quote"); + g_plugin.addUserInfo(wp, &odp); + return 0; +} + + +INT_PTR QuotesMenu_EditSettings(WPARAM wp, LPARAM) +{ + MCONTACT hContact = MCONTACT(wp); + if (NULL != hContact) + ShowSettingsDlg(hContact); + return 0; +} + +namespace +{ + bool get_log_file(MCONTACT hContact, tstring& rsLogfile) + { + rsLogfile = GetContactLogFileName(hContact); + return ((rsLogfile.empty()) ? false : true); + } +} + +INT_PTR QuotesMenu_OpenLogFile(WPARAM wp, LPARAM) +{ + MCONTACT hContact = MCONTACT(wp); + if (NULL == hContact) + return 0; + + tstring sLogFileName; + if ((true == get_log_file(hContact, sLogFileName)) && (false == sLogFileName.empty())) + ::ShellExecute(nullptr, L"open", sLogFileName.c_str(), nullptr, nullptr, SW_SHOWNORMAL); + + return 0; +} + +INT_PTR QuotesMenu_RefreshContact(WPARAM wp, LPARAM) +{ + MCONTACT hContact = MCONTACT(wp); + if (NULL == hContact) + return 0; + + CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact); + if (!pProvider) + return 0; + + pProvider->RefreshContact(hContact); + return 0; +} + +static INT_PTR CALLBACK QuoteInfoDlgProc1(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + MCONTACT hContact = NULL; + MWindowList hWL; + + switch (msg) { + case WM_INITDIALOG: + hContact = MCONTACT(lParam); + hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, false); + assert(hWL); + WindowList_Add(hWL, hdlg, hContact); + + ::SetWindowLongPtr(hdlg, GWLP_USERDATA, 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: + hContact = get_contact(hdlg); + if (hContact) { + SetWindowLongPtr(hdlg, GWLP_USERDATA, 0); + + 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*/) +{ + MCONTACT hContact = MCONTACT(wp); + if (CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact)) { + MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, true); + assert(hWL); + HWND hWnd = WindowList_Find(hWL, hContact); + if (nullptr != hWnd) { + SetForegroundWindow(hWnd); + SetFocus(hWnd); + } + else if (true == IsMyContact(hContact)) + CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG_QUOTE_INFO_1), nullptr, QuoteInfoDlgProc1, LPARAM(hContact)); + + return 1; + } + + return 0; +} + +int Quotes_PrebuildContactMenu(WPARAM wp, LPARAM) +{ + Menu_EnableItem(g_hMenuEditSettings, false); + Menu_EnableItem(g_hMenuOpenLogFile, false); + #ifdef CHART_IMPLEMENT + Menu_EnableItem(g_hMenuChart, false); + #endif + Menu_EnableItem(g_hMenuRefresh, false); + + MCONTACT hContact = MCONTACT(wp); + char *szProto = GetContactProto(hContact); + if (mir_strcmp(szProto, QUOTES_MODULE_NAME)) { + Menu_ShowItem(g_hMenuRoot, false); + return 0; + } + + Menu_ShowItem(g_hMenuRoot, true); + Menu_EnableItem(g_hMenuEditSettings, true); + + Menu_EnableItem(g_hMenuRefresh, true); + + tstring sLogFileName; + bool bThereIsLogFile = (true == get_log_file(hContact, sLogFileName)) + && (false == sLogFileName.empty()) && (0 == _waccess(sLogFileName.c_str(), 04)); + if (true == bThereIsLogFile) { + #ifdef CHART_IMPLEMENT + Menu_EnableItem(g_hMenuChart, true); + #endif + Menu_EnableItem(g_hMenuOpenLogFile, true); + } + + return 0; +} diff --git a/plugins/CurrencyRates/src/QuoteInfoDlg.h b/plugins/CurrencyRates/src/QuoteInfoDlg.h new file mode 100644 index 0000000000..51bcebbf64 --- /dev/null +++ b/plugins/CurrencyRates/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/CurrencyRates/src/QuotesProviderBase.cpp b/plugins/CurrencyRates/src/QuotesProviderBase.cpp new file mode 100644 index 0000000000..4d4dc760b5 --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderBase.cpp @@ -0,0 +1,883 @@ +#include "StdAfx.h" + +extern bool g_bAutoUpdate; +extern HANDLE g_hEventWorkThreadStop; + +struct CQuotesProviderBase::CXMLFileInfo +{ + CXMLFileInfo() : m_qs(L"Unknown") {} + IQuotesProvider::CProviderInfo m_pi; + CQuotesProviderBase::CQuoteSection m_qs; + tstring m_sURL; +}; + +inline tstring get_ini_file_name(LPCTSTR pszFileName) +{ + return CreateFilePath(pszFileName); +} + +bool parse_quote(const IXMLNode::TXMLNodePtr& pTop, CQuotesProviderBase::CQuote& q) +{ + tstring sSymbol; + tstring sDescription; + tstring sID; + + size_t cChild = pTop->GetChildCount(); + for (size_t i = 0; i < cChild; ++i) { + IXMLNode::TXMLNodePtr pNode = pTop->GetChildNode(i); + tstring sName = pNode->GetName(); + if (0 == mir_wstrcmpi(L"symbol", sName.c_str())) { + sSymbol = pNode->GetText(); + if (true == sSymbol.empty()) + return false; + } + else if (0 == mir_wstrcmpi(L"description", sName.c_str())) { + sDescription = pNode->GetText(); + } + else if (0 == mir_wstrcmpi(L"id", sName.c_str())) { + sID = pNode->GetText(); + if (true == sID.empty()) + return false; + } + } + + q = CQuotesProviderBase::CQuote(sID, TranslateW(sSymbol.c_str()), TranslateW(sDescription.c_str())); + return true; +} + +bool parse_section(const IXMLNode::TXMLNodePtr& pTop, CQuotesProviderBase::CQuoteSection& qs) +{ + CQuotesProviderBase::CQuoteSection::TSections aSections; + CQuotesProviderBase::CQuoteSection::TQuotes aQuotes; + tstring sSectionName; + + size_t cChild = pTop->GetChildCount(); + for (size_t i = 0; i < cChild; ++i) { + IXMLNode::TXMLNodePtr pNode = pTop->GetChildNode(i); + tstring sName = pNode->GetName(); + if (0 == mir_wstrcmpi(L"section", sName.c_str())) { + CQuotesProviderBase::CQuoteSection qs1; + if (true == parse_section(pNode, qs1)) + aSections.push_back(qs1); + } + else if (0 == mir_wstrcmpi(L"quote", sName.c_str())) { + CQuotesProviderBase::CQuote q; + if (true == parse_quote(pNode, q)) + aQuotes.push_back(q); + } + else if (0 == mir_wstrcmpi(L"name", sName.c_str())) { + sSectionName = pNode->GetText(); + if (true == sSectionName.empty()) + return false; + } + } + + qs = CQuotesProviderBase::CQuoteSection(TranslateW(sSectionName.c_str()), aSections, aQuotes); + return true; +} + +IXMLNode::TXMLNodePtr find_provider(const IXMLNode::TXMLNodePtr& pRoot) +{ + IXMLNode::TXMLNodePtr pProvider; + size_t cChild = pRoot->GetChildCount(); + for (size_t i = 0; i < cChild; ++i) { + IXMLNode::TXMLNodePtr pNode = pRoot->GetChildNode(i); + tstring sName = pNode->GetName(); + if (0 == mir_wstrcmpi(L"Provider", sName.c_str())) { + pProvider = pNode; + break; + } + + pProvider = find_provider(pNode); + if (pProvider) + break; + } + + return pProvider; +} + +CQuotesProviderBase::CXMLFileInfo parse_ini_file(const tstring& rsXMLFile, bool& rbSucceded) +{ + CQuotesProviderBase::CXMLFileInfo res; + CQuotesProviderBase::CQuoteSection::TSections aSections; + + const CModuleInfo::TXMLEnginePtr& pXMLEngine = CModuleInfo::GetXMLEnginePtr(); + IXMLNode::TXMLNodePtr pRoot = pXMLEngine->LoadFile(rsXMLFile); + if (pRoot) { + IXMLNode::TXMLNodePtr pProvider = find_provider(pRoot); + if (pProvider) { + rbSucceded = true; + size_t cChild = pProvider->GetChildCount(); + for (size_t i = 0; i < cChild; ++i) { + IXMLNode::TXMLNodePtr pNode = pProvider->GetChildNode(i); + tstring sName = pNode->GetName(); + if (0 == mir_wstrcmpi(L"section", sName.c_str())) { + CQuotesProviderBase::CQuoteSection qs; + if (true == parse_section(pNode, qs)) + aSections.push_back(qs); + } + else if (0 == mir_wstrcmpi(L"Name", sName.c_str())) + res.m_pi.m_sName = pNode->GetText(); + else if (0 == mir_wstrcmpi(L"ref", sName.c_str())) + res.m_pi.m_sURL = pNode->GetText(); + else if (0 == mir_wstrcmpi(L"url", sName.c_str())) + res.m_sURL = pNode->GetText(); + } + } + } + + res.m_qs = CQuotesProviderBase::CQuoteSection(res.m_pi.m_sName, aSections); + return res; +} + +CQuotesProviderBase::CXMLFileInfo init_xml_info(LPCTSTR pszFileName, bool& rbSucceded) +{ + rbSucceded = false; + tstring sIniFile = get_ini_file_name(pszFileName); + return parse_ini_file(sIniFile, rbSucceded); +} + +CQuotesProviderBase::CQuotesProviderBase() + : m_hEventSettingsChanged(::CreateEvent(nullptr, FALSE, FALSE, nullptr)), + m_hEventRefreshContact(::CreateEvent(nullptr, FALSE, FALSE, nullptr)), + m_bRefreshInProgress(false) +{ +} + +CQuotesProviderBase::~CQuotesProviderBase() +{ + ::CloseHandle(m_hEventSettingsChanged); + ::CloseHandle(m_hEventRefreshContact); +} + +bool CQuotesProviderBase::Init() +{ + bool bSucceded = m_pXMLInfo != nullptr; + if (!m_pXMLInfo) { + CQuotesProviderVisitorDbSettings visitor; + Accept(visitor); + assert(visitor.m_pszXMLIniFileName); + + m_pXMLInfo.reset(new CXMLFileInfo(init_xml_info(visitor.m_pszXMLIniFileName, bSucceded))); + } + + return bSucceded; +} + +CQuotesProviderBase::CXMLFileInfo* CQuotesProviderBase::GetXMLFileInfo()const +{ + // if(!m_pXMLInfo) + // { + // CQuotesProviderVisitorDbSettings visitor; + // Accept(visitor); + // assert(visitor.m_pszXMLIniFileName); + // m_pXMLInfo.reset(new CXMLFileInfo(init_xml_info(visitor.m_pszXMLIniFileName))); + // } + + return m_pXMLInfo.get(); +} + +const CQuotesProviderBase::CProviderInfo& CQuotesProviderBase::GetInfo()const +{ + return GetXMLFileInfo()->m_pi; +} + +const CQuotesProviderBase::CQuoteSection& CQuotesProviderBase::GetQuotes()const +{ + return GetXMLFileInfo()->m_qs; +} + +const tstring& CQuotesProviderBase::GetURL()const +{ + return GetXMLFileInfo()->m_sURL; +} + +bool CQuotesProviderBase::IsOnline() +{ + return /*g_bAutoUpdate*/true; +} + +void CQuotesProviderBase::AddContact(MCONTACT hContact) +{ + // CCritSection cs(m_cs); + assert(m_aContacts.end() == std::find(m_aContacts.begin(), m_aContacts.end(), hContact)); + + m_aContacts.push_back(hContact); +} + +void CQuotesProviderBase::DeleteContact(MCONTACT hContact) +{ + mir_cslock lck(m_cs); + + TContracts::iterator i = std::find(m_aContacts.begin(), m_aContacts.end(), hContact); + if (i != m_aContacts.end()) + m_aContacts.erase(i); +} + +void CQuotesProviderBase::SetContactStatus(MCONTACT hContact, int nNewStatus) +{ + int nStatus = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_STATUS, ID_STATUS_OFFLINE); + if (nNewStatus != nStatus) { + db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_STATUS, nNewStatus); + + if (ID_STATUS_ONLINE != nNewStatus) { + db_unset(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME); + tstring sSymbol = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL); + if (false == sSymbol.empty()) + db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, sSymbol.c_str()); + + SetContactExtraImage(hContact, eiEmpty); + } + } +} + +class CTendency +{ + enum { NumValues = 2 }; + enum EComparison + { + NonValid, + Greater, + Less, + Equal, + GreaterOrEqual, + LessOrEqual + }; + +public: + enum EResult + { + NotChanged, + Up, + Down + }; + +public: + CTendency() : m_nComparison(NonValid) {} + + bool Parse(const IQuotesProvider* pProvider, const tstring& rsFrmt, MCONTACT hContact) + { + m_abValueFlags[0] = false; + m_abValueFlags[1] = false; + m_nComparison = NonValid; + bool bValid = true; + int nCurValue = 0; + for (tstring::const_iterator i = rsFrmt.begin(); i != rsFrmt.end() && bValid && nCurValue < NumValues;) { + wchar_t chr = *i; + switch (chr) { + default: + if (false == std::isspace(chr)) + bValid = false; + else + ++i; + break; + + case '%': + ++i; + if (i != rsFrmt.end()) { + wchar_t t = *i; + ++i; + CQuotesProviderVisitorTendency visitor(hContact, t); + pProvider->Accept(visitor); + if (false == visitor.IsValid()) { + bValid = false; + } + else { + double d = visitor.GetResult(); + m_adValues[nCurValue] = d; + m_abValueFlags[nCurValue] = true; + ++nCurValue; + } + } + else bValid = false; + break; + case '>': + m_nComparison = Greater; + ++i; + break; + case '<': + m_nComparison = Less; + ++i; + break; + case '=': + switch (m_nComparison) { + default: + bValid = false; + break; + case NonValid: + m_nComparison = Equal; + break; + case Greater: + m_nComparison = GreaterOrEqual; + break; + case Less: + m_nComparison = LessOrEqual; + break; + } + ++i; + break; + } + } + + return (bValid && IsValid()); + } + + bool IsValid()const { return (m_abValueFlags[0] && m_abValueFlags[1] && (m_nComparison != NonValid)); } + + EResult Compare()const + { + switch (m_nComparison) { + case Greater: + if (true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) + return NotChanged; + + if (m_adValues[0] > m_adValues[1]) + return Up; + return Down; + + case GreaterOrEqual: + if ((true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) || (m_adValues[0] > m_adValues[1])) + return Up; + return Down; + + case Less: + if (true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) + return NotChanged; + + if (m_adValues[0] < m_adValues[1]) + return Up; + return Down; + + case LessOrEqual: + if ((true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) || (m_adValues[0] < m_adValues[1])) + return Up; + return Down; + + case Equal: + if (true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) + return Up; + return Down; + } + return NotChanged; + } + +private: + double m_adValues[NumValues]; + bool m_abValueFlags[NumValues]; + EComparison m_nComparison; +}; + +tstring format_rate(const IQuotesProvider *pProvider, MCONTACT hContact, const tstring &rsFrmt) +{ + tstring sResult; + + for (tstring::const_iterator i = rsFrmt.begin(); i != rsFrmt.end();) { + wchar_t chr = *i; + switch (chr) { + default: + sResult += chr; + ++i; + break; + + case '\\': + ++i; + if (i != rsFrmt.end()) { + wchar_t t = *i; + switch (t) { + case '%': sResult += L"%"; break; + case 't': sResult += L"\t"; break; + case 'n': sResult += L"\n"; break; + case '\\': sResult += L"\\"; break; + default: sResult += chr; sResult += t; break; + } + ++i; + } + else sResult += chr; + break; + + case '%': + ++i; + if (i != rsFrmt.end()) { + chr = *i; + + byte nWidth = 0; + if (::isdigit(chr)) { + nWidth = chr - 0x30; + ++i; + if (i == rsFrmt.end()) { + sResult += chr; + break; + } + else chr = *i; + } + + CQuotesProviderVisitorFormater visitor(hContact, chr, nWidth); + pProvider->Accept(visitor); + const tstring& s = visitor.GetResult(); + sResult += s; + ++i; + } + else sResult += chr; + break; + } + } + + return sResult; +} + +void log_to_file(const IQuotesProvider* pProvider, + MCONTACT hContact, + const tstring& rsLogFileName, + const tstring& rsFormat) +{ + std::string sPath = quotes_t2a(rsLogFileName.c_str()); + + std::string::size_type n = sPath.find_last_of("\\/"); + if (std::string::npos != n) + sPath.erase(n); + + DWORD dwAttributes = ::GetFileAttributesA(sPath.c_str()); + if ((0xffffffff == dwAttributes) || (0 == (dwAttributes&FILE_ATTRIBUTE_DIRECTORY))) + CreateDirectoryTree(sPath.c_str()); + + tofstream file(rsLogFileName.c_str(), std::ios::app | std::ios::out); + file.imbue(GetSystemLocale()); + if (file.good()) { + tstring s = format_rate(pProvider, hContact, rsFormat); + file << s; + } +} + +void log_to_history(const IQuotesProvider* pProvider, + MCONTACT hContact, + time_t nTime, + const tstring& rsFormat) +{ + tstring s = format_rate(pProvider, hContact, rsFormat); + T2Utf psz(s.c_str()); + + DBEVENTINFO dbei = {}; + dbei.szModule = QUOTES_PROTOCOL_NAME; + dbei.timestamp = static_cast(nTime); + dbei.flags = DBEF_READ | DBEF_UTF; + dbei.eventType = EVENTTYPE_MESSAGE; + dbei.cbBlob = (int)::mir_strlen(psz) + 1; + dbei.pBlob = (PBYTE)(char*)psz; + db_event_add(hContact, &dbei); +} + +bool do_set_contact_extra_icon(MCONTACT hContact, const CTendency& tendency) +{ + CTendency::EResult nComparison = tendency.Compare(); + + if (CTendency::NotChanged == nComparison) + return SetContactExtraImage(hContact, eiNotChanged); + + if (CTendency::Up == nComparison) + return SetContactExtraImage(hContact, eiUp); + + if (CTendency::Down == nComparison) + return SetContactExtraImage(hContact, eiDown); + + return false; +} + +bool show_popup(const IQuotesProvider* pProvider, + MCONTACT hContact, + const CTendency& tendency, + const tstring& rsFormat, + const CPopupSettings& ps) +{ + if (!ServiceExists(MS_POPUP_ADDPOPUPT)) + return false; + + POPUPDATAT ppd; + memset(&ppd, 0, sizeof(ppd)); + ppd.lchContact = hContact; + + if (tendency.IsValid()) { + CTendency::EResult nComparison = tendency.Compare(); + if (CTendency::NotChanged == nComparison) + ppd.lchIcon = Quotes_LoadIconEx(IDI_ICON_NOTCHANGED); + else if (CTendency::Up == nComparison) + ppd.lchIcon = Quotes_LoadIconEx(IDI_ICON_UP); + else if (CTendency::Down == nComparison) + ppd.lchIcon = Quotes_LoadIconEx(IDI_ICON_DOWN); + } + + CQuotesProviderVisitorFormater visitor(hContact, 's', 0); + pProvider->Accept(visitor); + const tstring& sTitle = visitor.GetResult(); + mir_wstrncpy(ppd.lptzContactName, sTitle.c_str(), MAX_CONTACTNAME); + { + ptrW ss(variables_parsedup((wchar_t*)rsFormat.c_str(), nullptr, hContact)); + tstring sText = format_rate(pProvider, hContact, tstring(ss)); + mir_wstrncpy(ppd.lptzText, sText.c_str(), MAX_SECONDLINE); + } + + if (CPopupSettings::colourDefault == ps.GetColourMode()) { + ppd.colorText = CPopupSettings::GetDefColourText(); + ppd.colorBack = CPopupSettings::GetDefColourBk(); + } + else { + ppd.colorText = ps.GetColourText(); + ppd.colorBack = ps.GetColourBk(); + } + + switch (ps.GetDelayMode()) { + default: + assert(!"Unknown popup delay mode"); + case CPopupSettings::delayFromPopup: + ppd.iSeconds = 0; + break; + case CPopupSettings::delayPermanent: + ppd.iSeconds = -1; + break; + case CPopupSettings::delayCustom: + ppd.iSeconds = ps.GetDelayTimeout(); + break; + } + + LPARAM lp = 0; + if (false == ps.GetHistoryFlag()) + lp |= 0x08; + + return (0 == CallService(MS_POPUP_ADDPOPUPT, reinterpret_cast(&ppd), lp)); +} + +void CQuotesProviderBase::WriteContactRate(MCONTACT hContact, double dRate, const tstring& rsSymbol/* = ""*/) +{ + time_t nTime = ::time(0); + + if (false == rsSymbol.empty()) + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL, rsSymbol.c_str()); + + double dPrev = 0.0; + bool bValidPrev = Quotes_DBReadDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_CURR_VALUE, dPrev); + if (true == bValidPrev) + Quotes_DBWriteDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_PREV_VALUE, dPrev); + + Quotes_DBWriteDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_CURR_VALUE, dRate); + db_set_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FETCH_TIME, nTime); + + tstring sSymbol = rsSymbol; + + tostringstream oNick; + oNick.imbue(GetSystemLocale()); + if (false == m_sContactListFormat.empty()) { + tstring s = format_rate(this, hContact, m_sContactListFormat); + oNick << s; + } + else { + if (true == sSymbol.empty()) + sSymbol = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL); + + oNick << std::setfill(L' ') << std::setw(10) << std::left << sSymbol << std::setw(6) << std::right << dRate; + } + CTendency tendency; + + if (true == tendency.Parse(this, m_sTendencyFormat, hContact)) + do_set_contact_extra_icon(hContact, tendency); + + db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, oNick.str().c_str()); + + tstring sStatusMsg = format_rate(this, hContact, m_sStatusMsgFormat); + if (false == sStatusMsg.empty()) + db_set_ws(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME, sStatusMsg.c_str()); + else + db_unset(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME); + + bool bUseContactSpecific = (db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 0) > 0); + + CAdvProviderSettings global_settings(this); + + WORD dwMode = (bUseContactSpecific) + ? db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, static_cast(lmDisabled)) + : global_settings.GetLogMode(); + if (dwMode&lmExternalFile) { + bool bAdd = true; + bool bOnlyIfChanged = (bUseContactSpecific) + ? (db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE_CONDITION, 1) > 0) + : global_settings.GetLogOnlyChangedFlag(); + if (true == bOnlyIfChanged) { + bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev))); + } + if (true == bAdd) { + tstring sLogFileName = (bUseContactSpecific) + ? Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE, global_settings.GetLogFileName().c_str()) + : global_settings.GetLogFileName(); + + if (true == sSymbol.empty()) { + sSymbol = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL); + } + + sLogFileName = GenerateLogFileName(sLogFileName, sSymbol); + + tstring sFormat = global_settings.GetLogFormat(); + if (bUseContactSpecific) { + CQuotesProviderVisitorDbSettings visitor; + Accept(visitor); + sFormat = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_LOG_FILE, visitor.m_pszDefLogFileFormat); + } + + log_to_file(this, hContact, sLogFileName, sFormat); + } + } + if (dwMode&lmInternalHistory) { + bool bAdd = true; + bool bOnlyIfChanged = (bUseContactSpecific) + ? (db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_HISTORY_CONDITION, 1) > 0) + : global_settings.GetHistoryOnlyChangedFlag(); + + if (true == bOnlyIfChanged) { + bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev))); + } + if (true == bAdd) { + tstring sFormat = (bUseContactSpecific) + ? Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_HISTORY, global_settings.GetHistoryFormat().c_str()) + : global_settings.GetHistoryFormat(); + + log_to_history(this, hContact, nTime, sFormat); + } + } + + if (dwMode&lmPopup) { + bool bOnlyIfChanged = (bUseContactSpecific) + ? (1 == db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_CONDITION, 1) > 0) + : global_settings.GetShowPopupIfValueChangedFlag(); + if ((false == bOnlyIfChanged) + || ((true == bOnlyIfChanged) && (true == bValidPrev) && (false == IsWithinAccuracy(dRate, dPrev)))) { + tstring sFormat = (bUseContactSpecific) + ? Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_POPUP, global_settings.GetPopupFormat().c_str()) + : global_settings.GetPopupFormat(); + + CPopupSettings ps = *(global_settings.GetPopupSettingsPtr()); + ps.InitForContact(hContact); + show_popup(this, hContact, tendency, sFormat, ps); + } + } + + SetContactStatus(hContact, ID_STATUS_ONLINE); +} + +MCONTACT CQuotesProviderBase::CreateNewContact(const tstring& rsName) +{ + MCONTACT hContact = db_add_contact(); + if (hContact) { + if (0 == Proto_AddToContact(hContact, QUOTES_PROTOCOL_NAME)) { + tstring sProvName = GetInfo().m_sName; + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_PROVIDER, sProvName.c_str()); + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL, rsName.c_str()); + db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, rsName.c_str()); + + mir_cslock lck(m_cs); + m_aContacts.push_back(hContact); + } + else { + db_delete_contact(hContact); + hContact = NULL; + } + } + + return hContact; +} + +DWORD get_refresh_timeout_miliseconds(const CQuotesProviderVisitorDbSettings& visitor) +{ + if (!g_bAutoUpdate) + return INFINITE; + + assert(visitor.m_pszDbRefreshRateType); + assert(visitor.m_pszDbRefreshRateValue); + + int nRefreshRateType = db_get_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateType, RRT_MINUTES); + if (nRefreshRateType < RRT_SECONDS || nRefreshRateType > RRT_HOURS) + nRefreshRateType = RRT_MINUTES; + + DWORD nTimeout = db_get_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateValue, 1); + switch (nRefreshRateType) { + default: + case RRT_SECONDS: + if (nTimeout < 1 || nTimeout > 60) + nTimeout = 1; + + nTimeout *= 1000; + break; + case RRT_MINUTES: + if (nTimeout < 1 || nTimeout > 60) + nTimeout = 1; + + nTimeout *= 1000 * 60; + break; + case RRT_HOURS: + if (nTimeout < 1 || nTimeout > 24) + nTimeout = 1; + + nTimeout *= 1000 * 60 * 60; + break; + } + + return nTimeout; +} + +class CBoolGuard +{ +public: + CBoolGuard(bool& rb) : m_b(rb) { m_b = true; } + ~CBoolGuard() { m_b = false; } + +private: + bool m_b; +}; + +void CQuotesProviderBase::Run() +{ + CQuotesProviderVisitorDbSettings visitor; + Accept(visitor); + + DWORD nTimeout = get_refresh_timeout_miliseconds(visitor); + m_sContactListFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); + m_sStatusMsgFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); + m_sTendencyFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); + + enum + { + STOP_THREAD = 0, + SETTINGS_CHANGED = 1, + REFRESH_CONTACT = 2, + COUNT_SYNC_OBJECTS = 3 + }; + + HANDLE anEvents[COUNT_SYNC_OBJECTS]; + anEvents[STOP_THREAD] = g_hEventWorkThreadStop; + anEvents[SETTINGS_CHANGED] = m_hEventSettingsChanged; + anEvents[REFRESH_CONTACT] = m_hEventRefreshContact; + + TContracts anContacts; + { + mir_cslock lck(m_cs); + anContacts = m_aContacts; + } + + bool bGoToBed = false; + + if (g_bAutoUpdate) { + CBoolGuard bg(m_bRefreshInProgress); + RefreshQuotes(anContacts); + } + + while (false == bGoToBed) { + anContacts.clear(); + + DWORD dwBegin = ::GetTickCount(); + DWORD dwResult = ::WaitForMultipleObjects(COUNT_SYNC_OBJECTS, anEvents, FALSE, nTimeout); + switch (dwResult) { + case WAIT_FAILED: + assert(!"WaitForMultipleObjects failed"); + bGoToBed = true; + break; + + case WAIT_ABANDONED_0 + STOP_THREAD: + case WAIT_ABANDONED_0 + SETTINGS_CHANGED: + case WAIT_ABANDONED_0 + REFRESH_CONTACT: + assert(!"WaitForMultipleObjects abandoned"); + + case WAIT_OBJECT_0 + STOP_THREAD: + bGoToBed = true; + break; + + case WAIT_OBJECT_0 + SETTINGS_CHANGED: + nTimeout = get_refresh_timeout_miliseconds(visitor); + m_sContactListFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); + m_sStatusMsgFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); + m_sTendencyFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); + { + mir_cslock lck(m_cs); + anContacts = m_aContacts; + } + break; + case WAIT_OBJECT_0 + REFRESH_CONTACT: + { + DWORD dwTimeRest = ::GetTickCount() - dwBegin; + if (INFINITE != nTimeout && dwTimeRest < nTimeout) { + nTimeout -= dwTimeRest; + } + + { + mir_cslock lck(m_cs); + anContacts = m_aRefreshingContacts; + m_aRefreshingContacts.clear(); + } + + { + CBoolGuard bg(m_bRefreshInProgress); + RefreshQuotes(anContacts); + } + } + break; + case WAIT_TIMEOUT: + nTimeout = get_refresh_timeout_miliseconds(visitor); + { + mir_cslock lck(m_cs); + anContacts = m_aContacts; + } + { + CBoolGuard bg(m_bRefreshInProgress); + RefreshQuotes(anContacts); + } + break; + + default: + assert(!"What is the hell?"); + } + } + + OnEndRun(); +} + +void CQuotesProviderBase::OnEndRun() +{ + TContracts anContacts; + { + mir_cslock lck(m_cs); + anContacts = m_aContacts; + m_aRefreshingContacts.clear(); + } + + CBoolGuard bg(m_bRefreshInProgress); + std::for_each(anContacts.begin(), anContacts.end(), boost::bind(&SetContactStatus, _1, ID_STATUS_OFFLINE)); +} + +void CQuotesProviderBase::Accept(CQuotesProviderVisitor &visitor)const +{ + visitor.Visit(*this); +} + +void CQuotesProviderBase::RefreshSettings() +{ + BOOL b = ::SetEvent(m_hEventSettingsChanged); + assert(b && "Failed to set event"); +} + +void CQuotesProviderBase::RefreshAllContacts() +{ + {// for CCritSection + mir_cslock lck(m_cs); + m_aRefreshingContacts.clear(); + std::for_each(std::begin(m_aContacts), std::end(m_aContacts), [&](MCONTACT hContact) { m_aRefreshingContacts.push_back(hContact); }); + } + + BOOL b = ::SetEvent(m_hEventRefreshContact); + assert(b && "Failed to set event"); +} + +void CQuotesProviderBase::RefreshContact(MCONTACT hContact) +{ + {// for CCritSection + mir_cslock lck(m_cs); + m_aRefreshingContacts.push_back(hContact); + } + + BOOL b = ::SetEvent(m_hEventRefreshContact); + assert(b && "Failed to set event"); +} diff --git a/plugins/CurrencyRates/src/QuotesProviderBase.h b/plugins/CurrencyRates/src/QuotesProviderBase.h new file mode 100644 index 0000000000..40f8c1ec24 --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderBase.h @@ -0,0 +1,119 @@ +#ifndef __3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__ +#define __3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__ + +class CQuotesProviderBase : public IQuotesProvider +{ +public: + class CQuote + { + public: + CQuote(const tstring& rsID = L"", const tstring& rsSymbol = L"", const tstring& rsName = L"") + : 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 TSections; + typedef std::vector TQuotes; + + public: + CQuoteSection(const tstring& rsName = L"", 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 TContracts; + +public: + struct CXMLFileInfo; + +public: + CQuotesProviderBase(); + ~CQuotesProviderBase(); + + + const CQuoteSection& GetQuotes()const; + // void SetSettingsEvent(); + + virtual bool Init(); + virtual const CProviderInfo& GetInfo()const; + virtual void AddContact(MCONTACT hContact); + virtual void DeleteContact(MCONTACT hContact); + virtual void Run(); + virtual void Accept(CQuotesProviderVisitor& visitor)const; + virtual void RefreshAllContacts(); + virtual void RefreshSettings(); + virtual void RefreshContact(MCONTACT hContact); + // virtual void SetContactExtraIcon(MCONTACT hContact)const; + +protected: + const tstring& GetURL()const; + MCONTACT CreateNewContact(const tstring& rsName); + static bool IsOnline(); + static void SetContactStatus(MCONTACT hContact, int nNewStatus); + void WriteContactRate(MCONTACT hContact, double dRate, const tstring& rsSymbol = L""); + +private: + virtual void RefreshQuotes(TContracts& anContacts) = 0; + +private: + virtual void OnEndRun(); + +private: + CXMLFileInfo* GetXMLFileInfo()const; + +protected: + TContracts m_aContacts; + mutable mir_cs m_cs; + +private: + typedef boost::scoped_ptr 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/CurrencyRates/src/QuotesProviderCurrencyConverter.cpp b/plugins/CurrencyRates/src/QuotesProviderCurrencyConverter.cpp new file mode 100644 index 0000000000..f51a662721 --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderCurrencyConverter.cpp @@ -0,0 +1,425 @@ +#include "stdafx.h" +#include "QuotesProviderCurrencyConverter.h" +#include +#include + +namespace +{ + tstring build_url(const tstring& rsURL, const tstring& from, const tstring& to) + { + tostringstream o; + o << rsURL << L"?q=" << from << L"_" << to << "&compact=ultra"; + return o.str(); + } + + tstring build_url(MCONTACT hContact, const tstring& rsURL) + { + 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); + } + + bool parse_responce(const tstring& rsJSON, double& dRate) + { + try + { + boost::property_tree::ptree pt; + std::istringstream i_stream(quotes_t2a(rsJSON.c_str())); + + boost::property_tree::read_json(i_stream, pt); + if (!pt.empty()) + { + auto pt_nested = pt.begin()->second; + dRate = pt_nested.get_value(); + } + else + { + dRate = pt.get_value(); + } + + return true; + } + catch (boost::property_tree::ptree_error& ) + { + } + return false; + } + + using TWatchedRates = std::vector; + TWatchedRates g_aWatchedRates; + + INT_PTR CALLBACK OptDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) + { + auto get_provider = []()->CQuotesProviderCurrencyConverter* + { + auto pProviders = CModuleInfo::GetQuoteProvidersPtr(); + const auto& rapQuotesProviders = pProviders->GetProviders(); + for (auto i = rapQuotesProviders.begin(); i != rapQuotesProviders.end(); ++i) { + const auto& pProvider = *i; + if (auto p = dynamic_cast(pProvider.get())) + { + return p; + } + } + + assert(!"We should never get here!"); + return nullptr; + }; + + auto make_quote_name = [](const CQuotesProviderBase::CQuote& rQuote)->tstring + { + const tstring& rsDesc = rQuote.GetName(); + return((false == rsDesc.empty()) ? rsDesc : rQuote.GetSymbol()); + }; + + auto make_contact_name = [](const tstring& rsSymbolFrom, const tstring& rsSymbolTo)->tstring + { + tostringstream o; + o << rsSymbolFrom << L"/" << rsSymbolTo; + return o.str(); + }; + + + auto make_rate_name = [make_contact_name](const CQuotesProviderCurrencyConverter::TRateInfo& ri)->tstring + { + if ((false == ri.first.GetName().empty()) && (false == ri.second.GetName().empty())) + return make_contact_name(ri.first.GetName(), ri.second.GetName()); + + return make_contact_name(ri.first.GetSymbol(), ri.second.GetSymbol()); + }; + + + auto pProvider = get_provider(); + + CCommonDlgProcData d(pProvider); + CommonOptionDlgProc(hdlg, message, wParam, lParam, d); + + switch (message) { + case WM_NOTIFY: + { + LPNMHDR pNMHDR = reinterpret_cast(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) { + CQuotesProviderCurrencyConverter::TRateInfo ri; + if (true == pProvider->GetWatchedRateInfo(i, ri)) { + auto it = std::find_if(aTemp.begin(), aTemp.end(), [&ri](const auto& other)->bool + { + return ((0 == mir_wstrcmpi(ri.first.GetID().c_str(), other.first.GetID().c_str())) + && ((0 == mir_wstrcmpi(ri.second.GetID().c_str(), other.second.GetID().c_str())))); + }); + if (it == aTemp.end()) { + aRemove.push_back(ri); + } + else { + aTemp.erase(it); + } + } + } + + std::for_each(aRemove.begin(), aRemove.end(), [pProvider](const auto& ri) {pProvider->WatchForRate(ri, false); }); + std::for_each(aTemp.begin(), aTemp.end(), [pProvider](const auto& ri) {pProvider->WatchForRate(ri, true); }); + pProvider->RefreshSettings(); + } + } + 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); + + CQuotesProviderBase::CQuoteSection rSection; + const auto& rQuotes = pProvider->GetQuotes(); + if (rQuotes.GetSectionCount() > 0) + { + rSection = rQuotes.GetSection(0); + } + + auto cQuotes = rSection.GetQuoteCount(); + for (auto i = 0u; i < cQuotes; ++i) + { + const auto& rQuote = rSection.GetQuote(i); + tstring sName = make_quote_name(rQuote); + LPCTSTR pszName = sName.c_str(); + ::SendMessage(hcbxFrom, CB_ADDSTRING, 0, reinterpret_cast(pszName)); + ::SendMessage(hcbxTo, CB_ADDSTRING, 0, reinterpret_cast(pszName)); + } + + auto cWatchedRates = pProvider->GetWatchedRateCount(); + for (auto i = 0u; i < cWatchedRates; ++i) + { + CQuotesProviderCurrencyConverter::TRateInfo ri; + if (true == pProvider->GetWatchedRateInfo(i, ri)) + { + g_aWatchedRates.push_back(ri); + tstring sRate = make_rate_name(ri); + LPCTSTR pszRateName = sRate.c_str(); + ::SendDlgItemMessage(hdlg, IDC_LIST_RATES, LB_ADDSTRING, 0, reinterpret_cast(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(::SendDlgItemMessage(hdlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); + int nTo = static_cast(::SendDlgItemMessage(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 = ::SendDlgItemMessage(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(::SendDlgItemMessage(hdlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); + size_t nTo = static_cast(::SendDlgItemMessage(hdlg, IDC_COMBO_CONVERT_INTO, CB_GETCURSEL, 0, 0)); + if ((CB_ERR != nFrom) && (CB_ERR != nTo) && (nFrom != nTo)) + { + CQuotesProviderBase::CQuoteSection rSection; + const auto& rQuotes = pProvider->GetQuotes(); + if (rQuotes.GetSectionCount() > 0) + { + rSection = rQuotes.GetSection(0); + } + + auto cQuotes = rSection.GetQuoteCount(); + if ((nFrom < cQuotes) && (nTo < cQuotes)) + { + CQuotesProviderCurrencyConverter::TRateInfo ri; + ri.first = rSection.GetQuote(nFrom); + ri.second = rSection.GetQuote(nTo); + + g_aWatchedRates.push_back(ri); + + tstring sRate = make_rate_name(ri); + LPCTSTR pszRateName = sRate.c_str(); + ::SendDlgItemMessage(hdlg, IDC_LIST_RATES, LB_ADDSTRING, 0, reinterpret_cast(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(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; + } + break; + } + + return FALSE; + } + +} + + +CQuotesProviderCurrencyConverter::CQuotesProviderCurrencyConverter() +{ +} + + +CQuotesProviderCurrencyConverter::~CQuotesProviderCurrencyConverter() +{ +} + +void CQuotesProviderCurrencyConverter::Accept(CQuotesProviderVisitor& visitor)const +{ + CQuotesProviderBase::Accept(visitor); + visitor.Visit(*this); +} + +void CQuotesProviderCurrencyConverter::ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp) +{ + odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_OPT_GOOGLE); + odp.pfnDlgProc = OptDlgProc; + odp.szTab.w = const_cast(GetInfo().m_sName.c_str()); + g_plugin.addOptions(wp, &odp); +} + +void CQuotesProviderCurrencyConverter::RefreshQuotes(TContracts& anContacts) +{ + CHTTPSession http; + tstring sURL = GetURL(); + + for (TContracts::const_iterator i = anContacts.begin(); i != anContacts.end() && IsOnline(); ++i) { + MCONTACT hContact = *i; + + tstring sFullURL = build_url(hContact, sURL); + if ((true == http.OpenURL(sFullURL)) && (true == IsOnline())) { + tstring sHTML; + if ((true == http.ReadResponce(sHTML)) && (true == IsOnline())) { + double dRate = 0.0; + if ((true == parse_responce(sHTML, dRate)) && (true == IsOnline())) { + WriteContactRate(hContact, dRate); + continue; + } + } + } + + SetContactStatus(hContact, ID_STATUS_NA); + } +} + +double CQuotesProviderCurrencyConverter::Convert(double dAmount, const CQuote& from, const CQuote& to)const +{ + tstring sFullURL = build_url(GetURL(), from.GetID(), to.GetID()); + + CHTTPSession http; + if ((true == http.OpenURL(sFullURL))) { + tstring sHTML; + if ((true == http.ReadResponce(sHTML))) { + double dResult = 0.0; + if ((true == parse_responce(sHTML, dResult))) + { + return dResult*dAmount; + } + + 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; +} + +size_t CQuotesProviderCurrencyConverter::GetWatchedRateCount()const +{ + return m_aContacts.size(); +} + +bool CQuotesProviderCurrencyConverter::GetWatchedRateInfo(size_t nIndex, TRateInfo& rRateInfo) +{ + if(nIndex < m_aContacts.size()) { + MCONTACT 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.first = CQuote(sSymbolFrom, sSymbolFrom, sDescFrom); + rRateInfo.second = CQuote(sSymbolTo, sSymbolTo, sDescTo); + return true; + } + else { + return false; + } +} + +bool CQuotesProviderCurrencyConverter::WatchForRate(const TRateInfo& ri, bool bWatch) +{ + auto i = std::find_if(m_aContacts.begin(), m_aContacts.end(), [&ri](auto hContact)->bool + { + 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 == mir_wstrcmpi(ri.first.GetID().c_str(), sFrom.c_str())) + && (0 == mir_wstrcmpi(ri.second.GetID().c_str(), sTo.c_str()))); + }); + + auto make_contact_name = [](const tstring& rsSymbolFrom, const tstring& rsSymbolTo)->tstring + { + tostringstream o; + o << rsSymbolFrom << L"/" << rsSymbolTo; + return o.str(); + }; + + + if ((true == bWatch) && (i == m_aContacts.end())) + { + tstring sName = make_contact_name(ri.first.GetSymbol(), ri.second.GetSymbol()); + MCONTACT hContact = CreateNewContact(sName); + if (hContact) + { + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_FROM_ID, ri.first.GetID().c_str()); + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_TO_ID, ri.second.GetID().c_str()); + if (false == ri.first.GetName().empty()) + { + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_FROM_DESCRIPTION, ri.first.GetName().c_str()); + } + if (false == ri.second.GetName().empty()) + { + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_TO_DESCRIPTION, ri.second.GetName().c_str()); + } + + return true; + } + } + else if ((false == bWatch) && (i != m_aContacts.end())) + { + MCONTACT hContact = *i; + {// for CCritSection + mir_cslock lck(m_cs); + m_aContacts.erase(i); + } + + db_delete_contact(hContact); + return true; + } + + return false; +} + +MCONTACT CQuotesProviderCurrencyConverter::GetContactByID(const tstring& rsFromID, const tstring& rsToID)const +{ + mir_cslock lck(m_cs); + + auto i = std::find_if(m_aContacts.begin(), m_aContacts.end(), [rsFromID, rsToID](MCONTACT hContact)->bool + { + 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 == mir_wstrcmpi(rsFromID.c_str(), sFrom.c_str())) && (0 == mir_wstrcmpi(rsToID.c_str(), sTo.c_str()))); + + }); + if (i != m_aContacts.end()) + return *i; + + return NULL; +} diff --git a/plugins/CurrencyRates/src/QuotesProviderCurrencyConverter.h b/plugins/CurrencyRates/src/QuotesProviderCurrencyConverter.h new file mode 100644 index 0000000000..c6138756b3 --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderCurrencyConverter.h @@ -0,0 +1,29 @@ +#pragma once + +#define DB_STR_FROM_ID "FromID" +#define DB_STR_TO_ID "ToID" +#define DB_STR_FROM_DESCRIPTION "FromDesc" +#define DB_STR_TO_DESCRIPTION "ToDesc" + + +class CQuotesProviderCurrencyConverter : public CQuotesProviderBase +{ +public: + using TRateInfo = std::pair; + +public: + CQuotesProviderCurrencyConverter(); + ~CQuotesProviderCurrencyConverter(); + + double Convert(double dAmount, const CQuote& from, const CQuote& to)const; + size_t GetWatchedRateCount()const; + bool GetWatchedRateInfo(size_t nIndex, TRateInfo& rRateInfo); + bool WatchForRate(const TRateInfo& ri, bool bWatch); + MCONTACT GetContactByID(const tstring& rsFromID, const tstring& rsToID)const; + +private: + virtual void Accept(CQuotesProviderVisitor& visitor)const override; + virtual void ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp)override; + virtual void RefreshQuotes(TContracts& anContacts)override; +}; + diff --git a/plugins/CurrencyRates/src/QuotesProviderVisitor.h b/plugins/CurrencyRates/src/QuotesProviderVisitor.h new file mode 100644 index 0000000000..934e0f80d0 --- /dev/null +++ b/plugins/CurrencyRates/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 CQuotesProviderGoogleFinance; +class CQuotesProviderYahoo; +class CQuotesProviderCurrencyConverter; + +class CQuotesProviderVisitor +{ +public: + CQuotesProviderVisitor() {} + virtual ~CQuotesProviderVisitor() {} + + virtual void Visit(const CQuotesProviderBase&){} + virtual void Visit(const CQuotesProviderFinance&){} + virtual void Visit(const CQuotesProviderDukasCopy&){} + virtual void Visit(const CQuotesProviderGoogleFinance&){} + virtual void Visit(const CQuotesProviderYahoo&){} + virtual void Visit(const CQuotesProviderCurrencyConverter&) {} +}; + +#endif //__7fca59e7_17b2_4849_bd7a_02c7675f2d76_QuotesProviderVisitor_h__ diff --git a/plugins/CurrencyRates/src/QuotesProviderVisitorDbSettings.cpp b/plugins/CurrencyRates/src/QuotesProviderVisitorDbSettings.cpp new file mode 100644 index 0000000000..3793e91699 --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderVisitorDbSettings.cpp @@ -0,0 +1,70 @@ +#include "StdAfx.h" + +CQuotesProviderVisitorDbSettings::CQuotesProviderVisitorDbSettings() + : m_pszDbRefreshRateType(nullptr), + m_pszDbRefreshRateValue(nullptr), + m_pszDbDisplayNameFormat(nullptr), + m_pszDefDisplayFormat(nullptr), + m_pszDefLogFileFormat(nullptr), + m_pszDefHistoryFormat(nullptr), + m_pszXMLIniFileName(nullptr), + m_pszDbStatusMsgFormat(nullptr), + m_pszDefStatusMsgFormat(nullptr), + m_pszDbLogMode(nullptr), + m_pszDbHistoryFormat(nullptr), + m_pszDbHistoryCondition(nullptr), + m_pszDbLogFile(nullptr), + m_pszDbLogFormat(nullptr), + m_pszDbLogCondition(nullptr), + m_pszDbPopupFormat(nullptr), + m_pszDefPopupFormat(nullptr), + m_pszDbPopupCondition(nullptr), + m_pszDbPopupColourMode(nullptr), + m_pszDbPopupBkColour(nullptr), + m_pszDbPopupTextColour(nullptr), + m_pszDbPopupDelayMode(nullptr), + m_pszDbPopupDelayTimeout(nullptr), + m_pszDbPopupHistoryFlag(nullptr), + m_pszDbTendencyFormat(nullptr), + m_pszDefTendencyFormat(L"%r>%p") +{ +} + +CQuotesProviderVisitorDbSettings::~CQuotesProviderVisitorDbSettings() +{ +} + +void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderBase&/* rProvider*/) +{ + m_pszDefLogFileFormat = L"%s\\t%t\\t%r\\n"; + m_pszDefHistoryFormat = L"%s %r"; + m_pszDefPopupFormat = L"\\nCurrent = %r\\nPrevious = %p"; +} + +void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderCurrencyConverter&) +{ + m_pszDbRefreshRateType = "CC_RefreshRateType"; + m_pszDbRefreshRateValue = "CC_RefreshRateValue"; + m_pszDbDisplayNameFormat = "CC_DspNameFrmt"; + m_pszDefDisplayFormat = L"1 %f = %r %i"; + m_pszXMLIniFileName = L"CC.xml"; + m_pszDbStatusMsgFormat = "CC_StatusMessageFormat"; + + m_pszDbLogMode = "CC_LogMode"; + m_pszDbHistoryFormat = "CC_HistoryFormat"; + m_pszDbHistoryCondition = "CC_AddToHistoryOnlyIfValueIsChanged"; + m_pszDbLogFile = "CC_LogFile"; + m_pszDbLogFormat = "CC_LogFileFormat"; + m_pszDbLogCondition = "CC_AddToLogOnlyIfValueIsChanged"; + m_pszDbPopupFormat = "CC_PopupFormat"; + m_pszDbPopupCondition = "CC_ShowPopupOnlyIfValueChanged"; + + m_pszDbPopupColourMode = "CC_PopupColourMode"; + m_pszDbPopupBkColour = "CC_PopupColourBk"; + m_pszDbPopupTextColour = "CC_PopupColourText"; + m_pszDbPopupDelayMode = "CC_PopupDelayMode"; + m_pszDbPopupDelayTimeout = "CC_PopupDelayTimeout"; + m_pszDbPopupHistoryFlag = "CC_PopupHistoryFlag"; + + m_pszDbTendencyFormat = "CC_TendencyFormat"; +} diff --git a/plugins/CurrencyRates/src/QuotesProviderVisitorDbSettings.h b/plugins/CurrencyRates/src/QuotesProviderVisitorDbSettings.h new file mode 100644 index 0000000000..6a5b180b0d --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderVisitorDbSettings.h @@ -0,0 +1,44 @@ +#ifndef __97cd432a_1119_4803_a96f_0abc1cc2653f_QuotesProviderVisitorDbSettings_h__ +#define __97cd432a_1119_4803_a96f_0abc1cc2653f_QuotesProviderVisitorDbSettings_h__ + +class CQuotesProviderVisitorDbSettings : public CQuotesProviderVisitor +{ +public: + CQuotesProviderVisitorDbSettings(); + ~CQuotesProviderVisitorDbSettings(); + +private: + virtual void Visit(const CQuotesProviderBase& rProvider)override; + virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override; +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/CurrencyRates/src/QuotesProviderVisitorFormatSpecificator.cpp b/plugins/CurrencyRates/src/QuotesProviderVisitorFormatSpecificator.cpp new file mode 100644 index 0000000000..451eaa4f2f --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderVisitorFormatSpecificator.cpp @@ -0,0 +1,62 @@ +#include "StdAfx.h" + +CQuotesProviderVisitorFormatSpecificator::CQuotesProviderVisitorFormatSpecificator() +{ +} + +CQuotesProviderVisitorFormatSpecificator::~CQuotesProviderVisitorFormatSpecificator() +{ +} + +void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderDukasCopy&/* rProvider*/) +{ + m_aSpecificators.push_back(CFormatSpecificator(L"%s", TranslateT("Quote Symbol"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%d", TranslateT("Quote Name"))); +} + +void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderBase&/* rProvider*/) +{ + m_aSpecificators.push_back(CFormatSpecificator(L"%S", TranslateT("Source of Information"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%r", TranslateT("Rate Value"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%p", TranslateT("Previous Rate Value"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%X", TranslateT("Fetch Time"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%x", TranslateT("Fetch Date"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%t", TranslateT("Fetch Time and Date"))); + m_aSpecificators.push_back(CFormatSpecificator(L"\\%", TranslateT("Percentage Character (%)"))); + m_aSpecificators.push_back(CFormatSpecificator(L"\\t", TranslateT("Tabulation"))); + m_aSpecificators.push_back(CFormatSpecificator(L"\\\\", TranslateT("Left slash (\\)"))); +} + +void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderGoogleFinance&/* rProvider*/) +{ + m_aSpecificators.push_back(CFormatSpecificator(L"%s", TranslateT("Quote Symbol"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%n", TranslateT("Quote Name"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%o", TranslateT("Open Price"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%d", TranslateT("Percent Change to After Hours"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%y", TranslateT("Percent Change to Yesterday Close"))); +} + +const CQuotesProviderVisitorFormatSpecificator::TFormatSpecificators& CQuotesProviderVisitorFormatSpecificator::GetSpecificators()const +{ + return m_aSpecificators; +} + +void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderYahoo&) +{ + m_aSpecificators.push_back(CFormatSpecificator(L"%s", TranslateT("Quote Symbol"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%n", TranslateT("Quote Name"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%o", TranslateT("Open Price"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%h", TranslateT("Day's High"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%g", TranslateT("Day's Low"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%P", TranslateT("Previous Close"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%c", TranslateT("Change"))); +} + +void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderCurrencyConverter&) +{ + m_aSpecificators.push_back(CFormatSpecificator(L"%F", TranslateT("From Currency Full Name"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%f", TranslateT("From Currency Short Name"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%I", TranslateT("Into Currency Full Name"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%i", TranslateT("Into Currency Short Name"))); + m_aSpecificators.push_back(CFormatSpecificator(L"%s", TranslateT("Short notation for \"%f/%i\""))); +} \ No newline at end of file diff --git a/plugins/CurrencyRates/src/QuotesProviderVisitorFormatSpecificator.h b/plugins/CurrencyRates/src/QuotesProviderVisitorFormatSpecificator.h new file mode 100644 index 0000000000..445a7d168c --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderVisitorFormatSpecificator.h @@ -0,0 +1,33 @@ +#ifndef __00c159f3_525a_41e9_8fc5_00464b6fafa3_QuotesProviderVisitorFormatSpecificator_h__ +#define __00c159f3_525a_41e9_8fc5_00464b6fafa3_QuotesProviderVisitorFormatSpecificator_h__ + +class CQuotesProviderVisitorFormatSpecificator : public CQuotesProviderVisitor +{ +public: + struct CFormatSpecificator + { + CFormatSpecificator(const tstring& rsSymbol = L"", const tstring& rsDec = L"") + : m_sSymbol(rsSymbol), m_sDesc(rsDec){} + + tstring m_sSymbol; + tstring m_sDesc; + }; + typedef std::vector TFormatSpecificators; + +public: + CQuotesProviderVisitorFormatSpecificator(); + ~CQuotesProviderVisitorFormatSpecificator(); + + const TFormatSpecificators& GetSpecificators()const; + +private: + virtual void Visit(const CQuotesProviderDukasCopy& rProvider)override; + virtual void Visit(const CQuotesProviderBase& rProvider)override; + virtual void Visit(const CQuotesProviderGoogleFinance& rProvider)override; + virtual void Visit(const CQuotesProviderYahoo& rProvider)override; + virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override; +private: + TFormatSpecificators m_aSpecificators; +}; + +#endif//__00c159f3_525a_41e9_8fc5_00464b6fafa3_QuotesProviderVisitorFormatSpecificator_h__ diff --git a/plugins/CurrencyRates/src/QuotesProviderVisitorFormater.cpp b/plugins/CurrencyRates/src/QuotesProviderVisitorFormater.cpp new file mode 100644 index 0000000000..50d3b7e8cc --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderVisitorFormater.cpp @@ -0,0 +1,122 @@ +#include "StdAfx.h" +#include "QuotesProviderCurrencyConverter.h" + +CQuotesProviderVisitorFormater::CQuotesProviderVisitorFormater(MCONTACT hContact, wchar_t chr, int nWidth) + : m_hContact(hContact), + m_chr(chr), + m_nWidth(nWidth) +{ +} + +CQuotesProviderVisitorFormater::~CQuotesProviderVisitorFormater() +{ +} + +const tstring& CQuotesProviderVisitorFormater::GetResult()const +{ + return m_sResult; +} + +static bool get_fetch_time(MCONTACT hContact, time_t& rTime) +{ + DBVARIANT dbv; + if (db_get(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_FETCH_TIME, &dbv) || (DBVT_DWORD != dbv.type)) + return false; + + rTime = dbv.dVal; + return true; +} + +static tstring format_fetch_time(const CQuotesProviderBase&, MCONTACT 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::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) { + case '%': + case '\t': + case '\\': + m_sResult = m_chr; + break; + case 'S': + m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_PROVIDER); + break; + case 's': + m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_SYMBOL); + break; + case 'X': + m_sResult = format_fetch_time(rProvider, m_hContact, Quotes_GetTimeFormat(true)); + break; + case 'x': + m_sResult = format_fetch_time(rProvider, m_hContact, Quotes_GetDateFormat(true)); + break; + case 't': + { + tstring sFrmt = Quotes_GetDateFormat(true); + sFrmt += L" "; + sFrmt += Quotes_GetTimeFormat(true); + m_sResult = format_fetch_time(rProvider, m_hContact, sFrmt); + } + break; + case 'r': + case 'R': + FormatDoubleHelper(DB_STR_QUOTE_CURR_VALUE); + break; + case 'p': + FormatDoubleHelper(DB_STR_QUOTE_PREV_VALUE); + break; + } +} + + +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/* = L"-"*/) +{ + 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 CQuotesProviderCurrencyConverter&) +{ + switch (m_chr) { + case 'F': + m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_FROM_DESCRIPTION); + break; + case 'f': + m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_FROM_ID); + break; + case 'I': + m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_TO_DESCRIPTION); + break; + case 'i': + m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_TO_ID); + break; + } +} \ No newline at end of file diff --git a/plugins/CurrencyRates/src/QuotesProviderVisitorFormater.h b/plugins/CurrencyRates/src/QuotesProviderVisitorFormater.h new file mode 100644 index 0000000000..27890694ae --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderVisitorFormater.h @@ -0,0 +1,27 @@ +#ifndef __2b5ddd05_9255_4be0_9408_e59768b70568_QuotesProviderVisitorFormater_h__ +#define __2b5ddd05_9255_4be0_9408_e59768b70568_QuotesProviderVisitorFormater_h__ + +class CQuotesProviderVisitorFormater : public CQuotesProviderVisitor +{ +public: + CQuotesProviderVisitorFormater(MCONTACT hContact, wchar_t chr, int nWidth); + ~CQuotesProviderVisitorFormater(); + + const tstring& GetResult()const; + +private: + virtual void Visit(const CQuotesProviderBase& rProvider)override; + virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override; + +private: + void FormatDoubleHelper(LPCSTR pszDbSet, const tstring sInvalid = L"-"); + // void FormatChangeValueHelper(bool bPercentage); + +private: + MCONTACT m_hContact; + wchar_t m_chr; + tstring m_sResult; + int m_nWidth; +}; + +#endif //__2b5ddd05_9255_4be0_9408_e59768b70568_QuotesProviderVisitorFormater_h__ diff --git a/plugins/CurrencyRates/src/QuotesProviderVisitorTendency.cpp b/plugins/CurrencyRates/src/QuotesProviderVisitorTendency.cpp new file mode 100644 index 0000000000..123fed5015 --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderVisitorTendency.cpp @@ -0,0 +1,24 @@ +#include "stdafx.h" + +CQuotesProviderVisitorTendency::CQuotesProviderVisitorTendency(MCONTACT hContact, wchar_t chr) + : m_hContact(hContact), m_chr(chr), m_bValid(false), m_dResult(0.0) +{ +} + +void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderBase&) +{ + switch (m_chr) { + case 'r': + case 'R': + GetValue(DB_STR_QUOTE_CURR_VALUE); + break; + case 'p': + GetValue(DB_STR_QUOTE_PREV_VALUE); + break; + } +} + +void CQuotesProviderVisitorTendency::GetValue(LPCSTR pszDbKeyName) +{ + m_bValid = Quotes_DBReadDouble(m_hContact, QUOTES_MODULE_NAME, pszDbKeyName, m_dResult); +} diff --git a/plugins/CurrencyRates/src/QuotesProviderVisitorTendency.h b/plugins/CurrencyRates/src/QuotesProviderVisitorTendency.h new file mode 100644 index 0000000000..ef867423d9 --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviderVisitorTendency.h @@ -0,0 +1,25 @@ +#ifndef __AD721194_E9944366_9CF1_0307460EF32F_QuotesProviderVisitorTendency_h__ +#define __AD721194_E9944366_9CF1_0307460EF32F_QuotesProviderVisitorTendency_h__ + +class CQuotesProviderVisitorTendency : public CQuotesProviderVisitor +{ +public: + CQuotesProviderVisitorTendency(MCONTACT hContact, wchar_t chr); + + bool IsValid()const{ return m_bValid; } + double GetResult()const{ return m_dResult; } + +private: + virtual void Visit(const CQuotesProviderBase& rProvider); + +private: + void GetValue(LPCSTR pszDbKeyName); + +private: + MCONTACT m_hContact; + wchar_t m_chr; + bool m_bValid; + double m_dResult; +}; + +#endif //__AD721194_E9944366_9CF1_0307460EF32F_QuotesProviderVisitorTendency_h__ diff --git a/plugins/CurrencyRates/src/QuotesProviders.cpp b/plugins/CurrencyRates/src/QuotesProviders.cpp new file mode 100644 index 0000000000..384df4277e --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviders.cpp @@ -0,0 +1,90 @@ +#include "StdAfx.h" +#include "QuotesProviderCurrencyConverter.h" + +#define LAST_RUN_VERSION "LastRunVersion" + +CQuotesProviders::CQuotesProviders() +{ + InitProviders(); +} + +CQuotesProviders::~CQuotesProviders() +{ + ClearProviders(); +} + +const CQuotesProviders::TQuotesProviders& CQuotesProviders::GetProviders()const +{ + return m_apProviders; +} + +templatevoid create_provider(CQuotesProviders::TQuotesProviders& apProviders) +{ + CQuotesProviders::TQuotesProviderPtr pProvider(new T); + if (pProvider->Init()) + apProviders.push_back(pProvider); +}; + +void CQuotesProviders::CreateProviders() +{ + create_provider(m_apProviders); +} + +void CQuotesProviders::ClearProviders() +{ + m_apProviders.clear(); +} + +void convert_contact_settings(MCONTACT hContact) +{ + WORD dwLogMode = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, static_cast(lmDisabled)); + if ((dwLogMode&lmInternalHistory) || (dwLogMode&lmExternalFile)) + db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 1); +} + +void CQuotesProviders::InitProviders() +{ + CreateProviders(); + + const WORD nCurrentVersion = 17; + WORD nVersion = db_get_w(NULL, QUOTES_MODULE_NAME, LAST_RUN_VERSION, 1); + + for (auto &hContact : Contacts(QUOTES_MODULE_NAME)) { + TQuotesProviderPtr pProvider = GetContactProviderPtr(hContact); + if (pProvider) { + pProvider->AddContact(hContact); + if (nVersion < nCurrentVersion) + convert_contact_settings(hContact); + } + } + + db_set_w(NULL, QUOTES_MODULE_NAME, LAST_RUN_VERSION, nCurrentVersion); +} + +CQuotesProviders::TQuotesProviderPtr CQuotesProviders::GetContactProviderPtr(MCONTACT hContact)const +{ + char* szProto = GetContactProto(hContact); + if (nullptr == 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 == ::mir_wstrcmpi(rsName.c_str(), rInfo.m_sName.c_str())) { + pResult = pProvider; + break; + } + } + + return pResult; +} diff --git a/plugins/CurrencyRates/src/QuotesProviders.h b/plugins/CurrencyRates/src/QuotesProviders.h new file mode 100644 index 0000000000..71aca86303 --- /dev/null +++ b/plugins/CurrencyRates/src/QuotesProviders.h @@ -0,0 +1,29 @@ +#ifndef __148306d1_da2a_43df_b1ad_0cdc8ef8a79e_QuotesProviders_h__ +#define __148306d1_da2a_43df_b1ad_0cdc8ef8a79e_QuotesProviders_h__ + +class IQuotesProvider; + +class CQuotesProviders +{ +public: + typedef boost::shared_ptr TQuotesProviderPtr; + typedef std::vector TQuotesProviders; + +public: + CQuotesProviders(); + ~CQuotesProviders(); + + TQuotesProviderPtr FindProvider(const tstring& rsName)const; + TQuotesProviderPtr GetContactProviderPtr(MCONTACT 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/CurrencyRates/src/SettingsDlg.cpp b/plugins/CurrencyRates/src/SettingsDlg.cpp new file mode 100644 index 0000000000..a3de4ddea1 --- /dev/null +++ b/plugins/CurrencyRates/src/SettingsDlg.cpp @@ -0,0 +1,1023 @@ +#include "StdAfx.h" + +#define WINDOW_PREFIX_SETTINGS "Edit Settings_" + +LPCTSTR g_pszVariableQuoteName = L"%quotename%"; +LPCTSTR g_pszVariableUserProfile = L"%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 get_filter() +{ + std::vector aFilter; + LPCTSTR pszFilterParts[] = { LPGENW("Log Files (*.txt,*.log)"), L"*.txt;*.log", LPGENW("All files (*.*)"), L"*.*" }; + for (int i = 0; i < sizeof(pszFilterParts) / sizeof(pszFilterParts[0]); ++i) { + tstring sPart = TranslateW(pszFilterParts[i]); + std::copy(sPart.begin(), sPart.end(), std::back_inserter(aFilter)); + aFilter.push_back('\0'); + + } + aFilter.push_back('\0'); + return aFilter; +} +void select_log_file(HWND hDlg) +{ + std::vector aFileBuffer(_MAX_PATH * 2, '\0'); + LPTSTR pszFile = &*aFileBuffer.begin(); + + std::vector 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_plugin.getInst(); + ofn.lpstrDefExt = L"log"; + 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(MCONTACT hContact) : m_hContact(hContact), m_pPopupSettings(nullptr) {} + ~CSettingWindowParam() { delete m_pPopupSettings; } + + MCONTACT m_hContact; + CPopupSettings* m_pPopupSettings; +}; + +inline CSettingWindowParam* get_param(HWND hWnd) +{ + return reinterpret_cast(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(lp); + TranslateDialogDefault(hWnd); + ::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() ? BST_CHECKED : BST_UNCHECKED); + + ::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(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(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(::SendDlgItemMessage(hWnd, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0))); + pSettings->SetColourText(static_cast(::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: + TranslateDialogDefault(hWnd); + { + MCONTACT hContact = MCONTACT(lp); + + MWindowList 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 = db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 0); + ::CheckDlgButton(hWnd, IDC_CHECK_CONTACT_SPECIFIC, bUseContactSpecific ? BST_CHECKED : BST_UNCHECKED); + + CAdvProviderSettings setGlobal(pProvider.get()); + // log to history + WORD dwLogMode = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, setGlobal.GetLogMode()); + UINT nCheck = (dwLogMode&lmInternalHistory) ? 1 : 0; + ::CheckDlgButton(hWnd, IDC_CHECK_INTERNAL_HISTORY, nCheck ? BST_CHECKED : BST_UNCHECKED); + + 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 = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_HISTORY_CONDITION, setGlobal.GetHistoryOnlyChangedFlag()); + ::CheckDlgButton(hWnd, IDC_CHECK_HISTORY_CONDITION, (1 == wOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); + + // log to file + nCheck = (dwLogMode&lmExternalFile) ? 1 : 0; + ::CheckDlgButton(hWnd, IDC_CHECK_EXTERNAL_FILE, nCheck ? BST_CHECKED : BST_UNCHECKED); + + 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 = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE_CONDITION, setGlobal.GetLogOnlyChangedFlag()); + ::CheckDlgButton(hWnd, IDC_CHECK_LOG_FILE_CONDITION, (1 == wOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); + + // popup + nCheck = (dwLogMode&lmPopup) ? 1 : 0; + ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP, nCheck ? BST_CHECKED : BST_UNCHECKED); + 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 == db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_CONDITION, setGlobal.GetShowPopupIfValueChangedFlag()); + ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED, (bOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); + + update_all_controls(hWnd); + + CSettingWindowParam* pParam = new CSettingWindowParam(hContact); + ::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast(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_plugin.getInst(), + MAKEINTRESOURCE(IDD_DIALOG_POPUP), + hWnd, + EditPopupSettingsDlgProc, reinterpret_cast(pParam->m_pPopupSettings)); + } + break; + + case IDOK: + { + CSettingWindowParam* pParam = get_param(hWnd); + MCONTACT 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)); + + db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, bUseContactSpec); + db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, nLogMode); + db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE_CONDITION, nIfChangedFile); + db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_HISTORY_CONDITION, nIfChangedHistory); + db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_CONDITION, bIfChangedPopup); + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE, sLogFile.c_str()); + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_LOG_FILE, sLogFileFormat.c_str()); + db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_HISTORY, sHistoryFormat.c_str()); + db_set_ws(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); + + MWindowList 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(MCONTACT hContact) +{ + MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_SETTINGS, true); + assert(hWL); + HWND hWnd = WindowList_Find(hWL, hContact); + if (nullptr != hWnd) { + SetForegroundWindow(hWnd); + SetFocus(hWnd); + } + else CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTACT_SETTINGS), nullptr, EditSettingsPerContactDlgProc, LPARAM(hContact)); +} + +////////////////////////////////////////////////////////////////////////// + +INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) +{ + switch (msg) { + case WM_INITDIALOG: + { + TranslateDialogDefault(hWnd); + CAdvProviderSettings* pAdvSettings = reinterpret_cast(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 ? BST_CHECKED : BST_UNCHECKED); + ::SetDlgItemText(hWnd, IDC_EDIT_HISTORY_FORMAT, pAdvSettings->GetHistoryFormat().c_str()); + ::CheckDlgButton(hWnd, IDC_CHECK_HISTORY_CONDITION, (pAdvSettings->GetHistoryOnlyChangedFlag()) ? BST_CHECKED : BST_UNCHECKED); + + // log to file + nCheck = (dwLogMode&lmExternalFile) ? 1 : 0; + ::CheckDlgButton(hWnd, IDC_CHECK_EXTERNAL_FILE, nCheck ? BST_CHECKED : BST_UNCHECKED); + ::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, (pAdvSettings->GetLogOnlyChangedFlag()) ? BST_CHECKED : BST_UNCHECKED); + + update_file_controls(hWnd); + update_history_controls(hWnd); + + // popup + nCheck = (dwLogMode&lmPopup) ? 1 : 0; + ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP, nCheck ? BST_CHECKED : BST_UNCHECKED); + ::SetDlgItemText(hWnd, IDC_EDIT_POPUP_FORMAT, pAdvSettings->GetPopupFormat().c_str()); + ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED, (pAdvSettings->GetShowPopupIfValueChangedFlag()) ? BST_CHECKED : BST_UNCHECKED); + + if (true == enable_popup_controls(hWnd)) + update_popup_controls(hWnd); + + ::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast(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(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(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(GetWindowLongPtr(hWnd, GWLP_USERDATA)); + DialogBoxParam(g_plugin.getInst(), + MAKEINTRESOURCE(IDD_DIALOG_POPUP), + hWnd, + EditPopupSettingsDlgProc, reinterpret_cast(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 = db_get_w(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogMode, static_cast(lmDisabled)); + m_sFormatHistory = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbHistoryFormat, visitor.m_pszDefHistoryFormat); + m_bIsOnlyChangedHistory = 1 == db_get_b(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 += L"\\Quotes\\"; + m_sLogFileName += g_pszVariableQuoteName; + m_sLogFileName += L".log"; + } + + m_sFormatLogFile = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogFormat, visitor.m_pszDefLogFileFormat); + m_bIsOnlyChangedLogFile = (1 == db_get_b(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 == db_get_b(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); + + db_set_w(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogMode, m_wLogMode); + db_set_ws(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbHistoryFormat, m_sFormatHistory.c_str()); + db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbHistoryCondition, m_bIsOnlyChangedHistory); + db_set_ws(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogFile, m_sLogFileName.c_str()); + db_set_ws(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogFormat, m_sFormatLogFile.c_str()); + db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogCondition, m_bIsOnlyChangedLogFile); + db_set_ws(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupFormat, m_sPopupFormat.c_str()); + db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupCondition, m_bShowPopupIfValueChanged); + + if (nullptr != m_pPopupSettings) { + db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupColourMode, static_cast(m_pPopupSettings->GetColourMode())); + db_set_dw(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupBkColour, m_pPopupSettings->GetColourBk()); + db_set_dw(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupTextColour, m_pPopupSettings->GetColourText()); + db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupDelayMode, static_cast(m_pPopupSettings->GetDelayMode())); + db_set_w(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupDelayTimeout, m_pPopupSettings->GetDelayTimeout()); + db_set_b(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 = db_get_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupColourMode, static_cast(m_modeColour)); + if (m >= colourDefault && m <= colourUserDefined) + m_modeColour = static_cast(m); + + m_rgbBkg = db_get_dw(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupBkColour, m_rgbBkg); + m_rgbText = db_get_dw(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupTextColour, m_rgbText); + + m = db_get_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupDelayMode, static_cast(m_modeDelay)); + if (m >= delayFromPopup && m <= delayPermanent) { + m_modeDelay = static_cast(m); + } + m_wDelay = db_get_w(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupDelayTimeout, m_wDelay); + m_bUseHistory = (1 == db_get_b(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(MCONTACT hContact) +{ + BYTE m = db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_MODE, static_cast(m_modeColour)); + if (m >= CPopupSettings::colourDefault && m <= CPopupSettings::colourUserDefined) { + m_modeColour = static_cast(m); + } + + m_rgbBkg = db_get_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_BK, m_rgbBkg); + m_rgbText = db_get_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_TEXT, m_rgbText); + + m = db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_DELAY_MODE, static_cast(m_modeDelay)); + if (m >= CPopupSettings::delayFromPopup && m <= CPopupSettings::delayPermanent) { + m_modeDelay = static_cast(m); + } + m_wDelay = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_DELAY_TIMEOUT, m_wDelay); + m_bUseHistory = 1 == db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_HISTORY_FLAG, m_bUseHistory); +} + +void CPopupSettings::SaveForContact(MCONTACT hContact)const +{ + db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_MODE, static_cast(m_modeColour)); + db_set_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_BK, m_rgbBkg); + db_set_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_TEXT, m_rgbText); + db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_DELAY_MODE, static_cast(m_modeDelay)); + db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_DELAY_TIMEOUT, m_wDelay); + db_set_b(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_plugin.getInst(), + MAKEINTRESOURCE(IDD_PROVIDER_ADV_SETTINGS), + hWndParent, + EditSettingsPerProviderDlgProc, + reinterpret_cast(pAdvSettings))); +} + +static void replace_invalid_char(tstring::value_type& rChar, tstring::value_type repl) +{ + static const wchar_t charInvalidSigns[] = { '\\', '/', ':', '*', '?', '\"', '<', '>', '|' }; + + 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) +{ + 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, '_')); + sPath.replace(n, mir_wstrlen(g_pszVariableQuoteName), s.c_str()); + } + } + + if (nFlags & glfnResolveUserProfile) { + wchar_t *ptszParsedName = Utils_ReplaceVarsW(sPath.c_str()); + if (ptszParsedName) { + sPath = ptszParsedName; + mir_free(ptszParsedName); + } + } + + return sPath; +} + +tstring GetContactLogFileName(MCONTACT hContact) +{ + tstring result; + + const CQuotesProviders::TQuotesProviderPtr& pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact); + if (pProvider) { + tstring sPattern; + bool bUseContactSpecific = (db_get_b(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(MCONTACT 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/CurrencyRates/src/SettingsDlg.h b/plugins/CurrencyRates/src/SettingsDlg.h new file mode 100644 index 0000000000..b462d7a901 --- /dev/null +++ b/plugins/CurrencyRates/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(MCONTACT hContact); + void SaveForContact(MCONTACT 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(MCONTACT 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(MCONTACT hContact); +tstring GetContactName(MCONTACT hContact); + +#endif //__E211E4D9_383C_43BE_A787_7EF1D585B90D_SettingsDlg_h__ + diff --git a/plugins/CurrencyRates/src/WinCtrlHelper.cpp b/plugins/CurrencyRates/src/WinCtrlHelper.cpp new file mode 100644 index 0000000000..03da055dbe --- /dev/null +++ b/plugins/CurrencyRates/src/WinCtrlHelper.cpp @@ -0,0 +1,40 @@ +#include "stdafx.h" + +static INT_PTR CALLBACK VariableListDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) +{ + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hWnd); + { + const IQuotesProvider* pProvider = reinterpret_cast(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' << spec.m_sDesc << L"\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_plugin.getInst(), + MAKEINTRESOURCE(IDD_DIALOG_VARIABLE_LIST), + hwndParent, + VariableListDlgProc, + reinterpret_cast(pProvider)); +} diff --git a/plugins/CurrencyRates/src/WinCtrlHelper.h b/plugins/CurrencyRates/src/WinCtrlHelper.h new file mode 100644 index 0000000000..20444ce41e --- /dev/null +++ b/plugins/CurrencyRates/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 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/CurrencyRates/src/XMLEngineMI.cpp b/plugins/CurrencyRates/src/XMLEngineMI.cpp new file mode 100644 index 0000000000..0224b2c7d9 --- /dev/null +++ b/plugins/CurrencyRates/src/XMLEngineMI.cpp @@ -0,0 +1,163 @@ +#include "StdAfx.h" + +class CXMLNodeMI : public IXMLNode, private boost::noncopyable +{ +public: + typedef boost::shared_ptr TXMLNodePtr; + +public: + explicit CXMLNodeMI(HXML hXMl, bool bDestroy = false) : m_hXML(hXMl), m_bDestroy(bDestroy) + { + assert(m_hXML); + } + + virtual ~CXMLNodeMI() + { + if (m_bDestroy) + xmlDestroyNode(m_hXML); + } + + virtual size_t GetChildCount()const + { + return xmlGetChildCount(m_hXML); + } + + virtual TXMLNodePtr GetChildNode(size_t nIndex)const + { + HXML h = xmlGetChild(m_hXML, (int)nIndex); + if (h) + return TXMLNodePtr(new CXMLNodeMI(h)); + + return TXMLNodePtr(); + } + + virtual tstring GetText()const + { + tstring sResult; + LPCTSTR psz = xmlGetText(m_hXML); + if (psz) + sResult = psz; + + return sResult; + } + + virtual tstring GetName()const + { + tstring sResult; + LPCTSTR psz = xmlGetName(m_hXML); + if (psz) + sResult = psz; + + return sResult; + } + + virtual bool AddChild(const TXMLNodePtr& pNode) + { + CXMLNodeMI* pXML = dynamic_cast(pNode.get()); + if (pXML) { + xmlAddChild2(pXML->m_hXML, m_hXML); + pXML->m_bDestroy = false; + return true; + } + + return false; + } + + virtual bool AddAttribute(const tstring& rsName, const tstring& rsValue) + { + xmlAddAttr(m_hXML, rsName.c_str(), rsValue.c_str()); + return true; + } + + virtual tstring GetAttributeValue(const tstring& rsAttrName) + { + LPCTSTR pszValue = xmlGetAttrValue(m_hXML, rsAttrName.c_str()); + return ((nullptr != pszValue) ? tstring(pszValue) : tstring()); + } + + virtual void Write(tostream& o)const + { + ptrW ss(xmlToString(m_hXML, nullptr)); + if (ss != NULL) + o << (char*)T2Utf(ss); + } + +private: + HXML m_hXML; + bool m_bDestroy; +}; + +CXMLEngineMI::CXMLEngineMI() +{ +} + +CXMLEngineMI::~CXMLEngineMI() +{ +} + +IXMLNode::TXMLNodePtr CXMLEngineMI::LoadFile(const tstring& rsFileName)const +{ + IXMLNode::TXMLNodePtr pResult; + FILE *stream; + if (0 == ::_tfopen_s(&stream, rsFileName.c_str(), L"r")) { + struct _stat st; + if (-1 != ::_fstat(::_fileno(stream), &st)) { + std::vector 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(st.st_size)) { + pBuffer[cBytes] = '\0'; + + int nLen = (int)cBytes; + ptrW ss(mir_utf8decodeW(pBuffer)); + if (ss) { + HXML h = xmlParseString(ss, &nLen, nullptr); + if (h) + pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h, true)); + } + } + } + ::fclose(stream); + } + + return pResult; +} + +static IXMLNode::TXMLNodePtr create_node(const tstring& rsName, const tstring& rsText, bool bIsDecl) +{ + IXMLNode::TXMLNodePtr pResult; + HXML h = xmlCreateNode(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(pNode.get()); + if (pXML) { + tofstream file(rsFileName.c_str()); + if (file.good()) { + IXMLNode::TXMLNodePtr pRoot(create_node(L"xml", tstring(), true)); + if (pRoot) { + pRoot->AddAttribute(L"version", L"1.0"); + pRoot->AddAttribute(L"encoding", L"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); +} diff --git a/plugins/CurrencyRates/src/XMLEngineMI.h b/plugins/CurrencyRates/src/XMLEngineMI.h new file mode 100644 index 0000000000..d9015613ab --- /dev/null +++ b/plugins/CurrencyRates/src/XMLEngineMI.h @@ -0,0 +1,15 @@ +#ifndef __0c3d1da4_92b7_431c_83e5_f998cd513f0d_XMLEngineMI_h__ +#define __0c3d1da4_92b7_431c_83e5_f998cd513f0d_XMLEngineMI_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/CurrencyRates/src/resource.h b/plugins/CurrencyRates/src/resource.h new file mode 100644 index 0000000000..46a35fe06e --- /dev/null +++ b/plugins/CurrencyRates/src/resource.h @@ -0,0 +1,100 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by C:\Code\miranda-ng-from-github\plugins\Quotes\res\Forex.rc +// +#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_DIALOG_QUOTE_INFO_1 118 +#define IDI_ICON_REFRESH 118 +#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 IDI_ICON_MAIN1 122 +#define IDI_ICON_DISABLED 122 +#define IDD_DIALOG_VARIABLE_LIST 123 +#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_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_EDIT_FROM2 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 125 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1073 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/CurrencyRates/src/stdafx.cxx b/plugins/CurrencyRates/src/stdafx.cxx new file mode 100644 index 0000000000..1fcbafc511 --- /dev/null +++ b/plugins/CurrencyRates/src/stdafx.cxx @@ -0,0 +1,18 @@ +/* +Copyright (C) 2012-18 Miranda NG team (https://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 . +*/ + +#include "stdafx.h" diff --git a/plugins/CurrencyRates/src/stdafx.h b/plugins/CurrencyRates/src/stdafx.h new file mode 100644 index 0000000000..1e455e5f2f --- /dev/null +++ b/plugins/CurrencyRates/src/stdafx.h @@ -0,0 +1,119 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +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 std::string quotes_t2a(const wchar_t* t) +{ + std::string s; + char* p = mir_u2a(t); + if (p) { + s = p; + mir_free(p); + } + return s; +} + +inline tstring quotes_a2t(const char* s) +{ + tstring t; + wchar_t* p = mir_a2u(s); + if (p) { + t = p; + mir_free(p); + } + return t; +} + +#include "resource.h" +#include "version.h" +#include "IconLib.h" +#include "QuoteInfoDlg.h" +#include "ModuleInfo.h" +#include "DBUtils.h" +#include "HTTPSession.h" +#include "CurrencyConverter.h" +#include "WinCtrlHelper.h" +#include "ImportExport.h" +#include "ComHelper.h" +#include "Log.h" +#include "CommonOptionDlg.h" +#include "EconomicRateInfo.h" +#include "SettingsDlg.h" +#include "CreateFilePath.h" +#include "Locale.h" +#include "ExtraImages.h" +#include "IsWithinAccuracy.h" +#include "IQuotesProvider.h" +#include "QuotesProviders.h" +#include "QuotesProviderBase.h" +#include "QuotesProviderVisitor.h" +#include "QuotesProviderVisitorDbSettings.h" +#include "QuotesProviderVisitorFormater.h" +#include "QuotesProviderVisitorTendency.h" +#include "QuotesProviderVisitorFormatSpecificator.h" +#define CHART_IMPLEMENT +#ifdef CHART_IMPLEMENT +#include "QuoteChart.h" +#include "Chart.h" +#endif +#include "IHTMLParser.h" +#include "IHTMLEngine.h" +#include "HTMLParserMS.h" +#include "IXMLEngine.h" +#include "XMLEngineMI.h" + +struct CMPlugin : public PLUGIN +{ + CMPlugin(); + + int Load() override; + int Unload() override; +}; diff --git a/plugins/CurrencyRates/src/version.h b/plugins/CurrencyRates/src/version.h new file mode 100644 index 0000000000..3e294ffd83 --- /dev/null +++ b/plugins/CurrencyRates/src/version.h @@ -0,0 +1,13 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 1 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 101 + +#include + +#define __PLUGIN_NAME "Currency Rates" +#define __FILENAME "CurrencyRates.dll" +#define __DESCRIPTION "Shows currency rates." +#define __AUTHOR "Dioksin" +#define __AUTHORWEB "https://miranda-ng.org/p/CurrencyRates/" +#define __COPYRIGHT "" diff --git a/plugins/ExternalAPI/m_CurrencyRates.h b/plugins/ExternalAPI/m_CurrencyRates.h new file mode 100644 index 0000000000..5535b69571 --- /dev/null +++ b/plugins/ExternalAPI/m_CurrencyRates.h @@ -0,0 +1,35 @@ +#ifndef __7D8F07A4_72AF_4838_9C5C_6FDFF57D0DC6_m_Quotes_h__ +#define __7D8F07A4_72AF_4838_9C5C_6FDFF57D0DC6_m_Quotes_h__ + +/* + * Export the contact (or all contacts) to xml file + * wParam = (WPARAM)(HANDLE)hContact to export or 0 to export all contacts + * lParam = (LPARAM)(const char*)pszFileName - pointer to file name to export or + * 0 in this case the dialog to select a file to export would be shown + * returns 0 if export was successfull, + * -1 if user canceled export and + * value greater than zero if error occurred during exporting + */ +#define MS_QUOTES_EXPORT "Quotes/Export" + +/* + * Import the contact (or all contacts) from xml file + * wParam = flags + * lParam = (LPARAM)(const char*)pszFileName - pointer to file name to import or + * 0 in this case the dialog to select a file to import would be shown + * returns 0 if import was successfull, + * -1 if user canceled import and + * value greater than zero if error occurred during importing + */ + +// if contact(s) exists user would be asked to overwrite these contacts +// #define QUOTES_IMPORT_PROMPT_TO_OVERWRITE_EXISTING_CONTACTS 0x0000 +// if contact(s) exists it would be overwrite without any prompt +// #define QUOTES_IMPORT_SILENT_OVERWRITE_EXISTING_CONTACTS 0x0001 +// if contact(s) exists during importing it would be ignored +#define QUOTES_IMPORT_SKIP_EXISTING_CONTACTS 0x0002 + +#define MS_QUOTES_IMPORT "Quotes/Import" + + +#endif //__7D8F07A4_72AF_4838_9C5C_6FDFF57D0DC6_m_Quotes_h__ diff --git a/plugins/ExternalAPI/m_Quotes.h b/plugins/ExternalAPI/m_Quotes.h deleted file mode 100644 index f4bbb06cd3..0000000000 --- a/plugins/ExternalAPI/m_Quotes.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __7D8F07A4_72AF_4838_9C5C_6FDFF57D0DC6_m_Quotes_h__ -#define __7D8F07A4_72AF_4838_9C5C_6FDFF57D0DC6_m_Quotes_h__ - -/* - * Export the contact (or all contacts) to xml file - * wParam = (WPARAM)(HANDLE)hContact to export or 0 to export all contacts - * lParam = (LPARAM)(const char*)pszFileName - pointer to file name to export or - * 0 in this case the dialog to select a file to export would be shown - * returns 0 if export was successfull, - * -1 if user canceled export and - * value greater than zero if error occurred during exporting - */ -#define MS_QUOTES_EXPORT "Quotes/Export" - -/* - * Import the contact (or all contacts) from xml file - * wParam = flags - * lParam = (LPARAM)(const char*)pszFileName - pointer to file name to import or - * 0 in this case the dialog to select a file to import would be shown - * returns 0 if import was successfull, - * -1 if user canceled import and - * value greater than zero if error occurred during importing - */ - -// if contact(s) exists user would be asked to overwrite these contacts -// #define QUOTES_IMPORT_PROMPT_TO_OVERWRITE_EXISTING_CONTACTS 0x0000 -// if contact(s) exists it would be overwrite without any prompt -// #define QUOTES_IMPORT_SILENT_OVERWRITE_EXISTING_CONTACTS 0x0001 -// if contact(s) exists during importing it would be ignored -#define QUOTES_IMPORT_SKIP_EXISTING_CONTACTS 0x0002 - -#define MS_QUOTES_IMPORT "Quotes/Import" - - -#endif //__7D8F07A4_72AF_4838_9C5C_6FDFF57D0DC6_m_Quotes_h__ diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp index ade2b2be16..5d8f7a7b5d 100644 --- a/plugins/PluginUpdater/src/DlgUpdate.cpp +++ b/plugins/PluginUpdater/src/DlgUpdate.cpp @@ -574,6 +574,8 @@ static renameTable[] = { L"yahoo.dll", nullptr }, { L"yahoogroups.dll", nullptr }, { L"WART-*.exe", nullptr }, + { L"Quotes.dll", L"Plugins\\CurrencyRates.dll" }, + { L"Proto_Quotes.dll, L"Icons\\Proto_CurrencyRates.dll" }, }; // Checks if file needs to be renamed and copies it in pNewName diff --git a/plugins/Quotes/Forex.vcxproj b/plugins/Quotes/Forex.vcxproj deleted file mode 100644 index 6aa12c214f..0000000000 --- a/plugins/Quotes/Forex.vcxproj +++ /dev/null @@ -1,36 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C619A811-8023-4441-B3D7-785388A09DF0} - Quotes - - - - - - $(WindowsSdkDir)include;$(VCInstallDir)include;$(IncludePath) - - - - Sync - - - \ No newline at end of file diff --git a/plugins/Quotes/Forex.vcxproj.filters b/plugins/Quotes/Forex.vcxproj.filters deleted file mode 100644 index de5ad9f66c..0000000000 --- a/plugins/Quotes/Forex.vcxproj.filters +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/plugins/Quotes/QuotesChart/Form1.Designer.cs b/plugins/Quotes/QuotesChart/Form1.Designer.cs deleted file mode 100644 index 39c45d2e6d..0000000000 --- a/plugins/Quotes/QuotesChart/Form1.Designer.cs +++ /dev/null @@ -1,123 +0,0 @@ -namespace QuotesChart -{ - partial class FormMirandaQuotesChart - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMirandaQuotesChart)); - this.chartQuotes = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.label1 = new System.Windows.Forms.Label(); - this.dateFrom = new System.Windows.Forms.DateTimePicker(); - this.dateTo = new System.Windows.Forms.DateTimePicker(); - this.label2 = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.chartQuotes)).BeginInit(); - this.SuspendLayout(); - // - // chartQuotes - // - this.chartQuotes.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - chartArea1.Name = "ChartArea1"; - this.chartQuotes.ChartAreas.Add(chartArea1); - legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Bottom; - legend1.Name = "Legend1"; - this.chartQuotes.Legends.Add(legend1); - this.chartQuotes.Location = new System.Drawing.Point(2, 45); - this.chartQuotes.Name = "chartQuotes"; - this.chartQuotes.Size = new System.Drawing.Size(423, 433); - this.chartQuotes.TabIndex = 0; - this.chartQuotes.Text = "chart1"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(-1, 16); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(30, 13); - this.label1.TabIndex = 1; - this.label1.Text = "From"; - // - // dateFrom - // - this.dateFrom.Format = System.Windows.Forms.DateTimePickerFormat.Short; - this.dateFrom.Location = new System.Drawing.Point(35, 9); - this.dateFrom.Name = "dateFrom"; - this.dateFrom.Size = new System.Drawing.Size(98, 20); - this.dateFrom.TabIndex = 2; - this.dateFrom.ValueChanged += new System.EventHandler(this.dateFrom_ValueChanged); - // - // dateTo - // - this.dateTo.Format = System.Windows.Forms.DateTimePickerFormat.Short; - this.dateTo.Location = new System.Drawing.Point(177, 10); - this.dateTo.Name = "dateTo"; - this.dateTo.Size = new System.Drawing.Size(98, 20); - this.dateTo.TabIndex = 4; - this.dateTo.ValueChanged += new System.EventHandler(this.dateTo_ValueChanged); - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(151, 16); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(20, 13); - this.label2.TabIndex = 3; - this.label2.Text = "To"; - // - // FormMirandaQuotesChart - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(425, 477); - this.Controls.Add(this.dateTo); - this.Controls.Add(this.label2); - this.Controls.Add(this.dateFrom); - this.Controls.Add(this.label1); - this.Controls.Add(this.chartQuotes); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Name = "FormMirandaQuotesChart"; - this.Text = "Miranda Quotes Chart"; - this.Load += new System.EventHandler(this.Form1_Load); - ((System.ComponentModel.ISupportInitialize)(this.chartQuotes)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.DataVisualization.Charting.Chart chartQuotes; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.DateTimePicker dateFrom; - private System.Windows.Forms.DateTimePicker dateTo; - private System.Windows.Forms.Label label2; - } -} - diff --git a/plugins/Quotes/QuotesChart/Form1.cs b/plugins/Quotes/QuotesChart/Form1.cs deleted file mode 100644 index b6295d4b56..0000000000 --- a/plugins/Quotes/QuotesChart/Form1.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using Microsoft.VisualBasic.FileIO; -using System.Runtime.InteropServices; - -namespace QuotesChart -{ - public partial class FormMirandaQuotesChart : Form - { - public FormMirandaQuotesChart() - { - InitializeComponent(); - } - - private void Form1_Load(object sender, EventArgs e) - { - string[] cmd_line_args = Environment.GetCommandLineArgs(); - - for (int i = 1; i < cmd_line_args.Length; ++i) - { - string data_file = cmd_line_args[i]; - AddDataFromFile(data_file); - } - } - - private void dateFrom_ValueChanged(object sender, EventArgs e) - { - if (dateFrom.Value < dateTo.Value) - { - chartQuotes.ChartAreas[0].AxisX.Minimum = dateFrom.Value.ToOADate(); - chartQuotes.Invalidate(); - } - } - - private void dateTo_ValueChanged(object sender, EventArgs e) - { - if (dateTo.Value > dateFrom.Value) - { - chartQuotes.ChartAreas[0].AxisX.Maximum = dateTo.Value.ToOADate(); - chartQuotes.Invalidate(); - } - } - - int WM_COPYDATA = 0x4A; - - public struct COPYDATASTRUCT - { - public IntPtr dwData; - public int cbData; - [MarshalAs(UnmanagedType.LPWStr)] - public String lpData; - } - - protected override void WndProc(ref Message msg) - { - if (msg.Msg == WM_COPYDATA) - { - COPYDATASTRUCT cp = (COPYDATASTRUCT)Marshal.PtrToStructure(msg.LParam, typeof(COPYDATASTRUCT)); - - if (/**(cp.dwData) == 0x1945 && */cp.lpData != null) - { - AddDataFromFile(cp.lpData); - } - - } - base.WndProc(ref msg); - } - - private void AddDataFromFile(string data_file) - { - using (TextFieldParser parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(data_file)) - { - parser.TrimWhiteSpace = true; - parser.TextFieldType = FieldType.Delimited; - parser.SetDelimiters("\t"); - - System.Windows.Forms.DataVisualization.Charting.Series series = null; - while (true) - { - string[] parts = parser.ReadFields(); - if (parts == null) - { - break; - } - - if (parts.Length >= 3) - { - string name = parts[0]; - string date = parts[1]; - string value = parts[2]; - - if (series == null) - { - if (chartQuotes.Series.FindByName(name) == null) - { - chartQuotes.Series.Add(name); - series = chartQuotes.Series[name]; - series.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; - } - else - { - break; - } - } - - DateTime dt; - double d; - if (Double.TryParse(value, out d) && DateTime.TryParse(date, out dt)) - { - series.Points.AddXY(dt, d); - - if (!dateMin.HasValue) - { - dateMin = new DateTime(); - dateMin = dt; - } - else if (dt < dateMin) - { - dateMin = dt; - } - - if (!dateMax.HasValue) - { - dateMax = new DateTime(); - dateMax = dt; - } - else if (dt > dateMax) - { - dateMax = dt; - } - } - } - } - } - - if (dateMin.HasValue && dateMax.HasValue) - { - chartQuotes.ChartAreas[0].AxisX.Minimum = dateMin.Value.ToOADate(); - chartQuotes.ChartAreas[0].AxisX.Maximum = dateMax.Value.ToOADate(); - - dateFrom.Value = dateMin.Value; - dateTo.Value = dateMax.Value; - } - } - - private DateTime? dateMin = null; - private DateTime? dateMax = null; - } -} diff --git a/plugins/Quotes/QuotesChart/Form1.resx b/plugins/Quotes/QuotesChart/Form1.resx deleted file mode 100644 index 3d63dcc355..0000000000 --- a/plugins/Quotes/QuotesChart/Form1.resx +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - - AAABAAIAICAAAAEAIACoEAAAJgAAABAQAAABACAAaAQAAM4QAAAoAAAAIAAAAEAAAAABACAAAAAAAIAQ - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAYAAAAOAAAAFgAAABwAAAAgAAAAIAAAABwAAAAWAAAADgAA - AAYAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAASAAAAJgAAADQAAABAAAAARAAAAEgAAABIAAAARAAA - AEAAAAA0AAAAJgAAABIAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAOAx80NAZKcmoUdaazH47D4ymh0vktrNf/L7DZ/yyo - 1v8lmMzzHYa72Q1ciJsFNldwAAAAPgAAACoAAAAOAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAFAdCb1QSgLO/MKjW71XI6/9l1PT/b9n4/3Xb - +v923Pr/cdn5/2nV9v9gz/L/Rbji+yecy+kIW42jAx0yWAAAADAAAAAUAAAAAgAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgQjPBoQcqKPKqPS81jR9P9j2fr/TtX6/zXQ - +f8eyvn/Esf4/wzE+P8Vxvj/Jcj4/zjM+P9R0fn/W9P4/z+75/8fkMXnBjVUcAMIDD4AAAAUAAAAAgAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFK0sWD2+mhzO14fdS0fb/RdP6/ybM - +f8PyPn/B8f5/wbH+f8Gx/n/Bsb5/wbE+P8Hw/j/CsL3/xXD9/8qx/j/Rcz3/1HN8/9RoLflO01JgQAA - ADAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA14roMosuD3RNH6/ynN - +f8Kx/n/Bcj6/wTK+v8Eyvr/BMr7/wTK+v8Fyfr/Bcj6/wbG+f8GxPj/B8L3/wjA9/8ryvb/ecfE/8uj - Q/+ogjLxMicYZAAAACoAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIKW5g+Gp7R7zTJ - 9P8iyvn/Ccf5/wXJ+v8Ey/r/BMz7/wPN+/8Dzfv/A837/wTM+/8Eyvr/Bcj5/wbG+f8Hw/j/F8j4/2LC - wP+4mzT/4a40/9anNf9+YizHJBwWUAAAABIAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACViSEgyG - wLElw/H/I8r5/wnG+f8FyPr/BMv7/wPN+/8C0Pz/AtD8/wLR/f8C0Pz/A8/8/wPN+/8Eyvr/Bcj6/x7N - +P9hxcL/xZMY/9yiGP/epR//4Kwv/7uPKvtkTSSXAAAAJgAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAJcrBEEqDV6yPI+P8Sxvn/Bcf5/wXK+v8Dzfv/A8/8/wLS/f8B0/3/AdP9/wHS/f8C0fz/A8/8/wTM - +/8Rzfr/YsjE/7ecMP/doxf/3aMY/92jGf/epyT/1qMq/5ZzLd8AAAA0AAAADgAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAyEv5kYtef/GMf4/wnF+P8FyPr/BMv6/wPO/P8C0fz/AdP9/wHV/v8A1v7/AdT+/wHS - /f8C0Pz/GdT7/2PMxf/JnBT/4asU/+CoFf/epRb/3aMX/92kG//eqCj/v5Aj/0U3KWoAAAAWAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAADo3J1xi+8P8Rxfj/BsX5/wXI+v8Ey/v/A8/8/wLR/f8B1P7/ANb+/wDX - //8A1v7/AdP9/wzT/f9lz8b/vqgs/+ayEf/lrxL/4qwT/+CoFf/epBf/3aMY/96oJP/RnSD/bFMvnQAA - ABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOmdD3GMH0/wzD+P8Gxfj/Bcj6/wTL+v8Dzvz/AtH8/wHU - /f8B1f7/ANb+/wTV/v8d2v3/ZdLG/9CqDv/svAz/67kN/+m1D//msBH/46wT/+CnFv/epBf/3qYf/9ij - I/+IZiS5AAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2h1f8Ywvb/CcL4/wfE+P8FyPr/BMr6/wPO - +/8C0Pz/AtL9/wzW/f844/7/Tub9/17Gyv/Fujz/8sQI//HCCf/uvgv/7LoN/+i0EP/lrxL/4aoU/9+m - Fv/dpB3/3KYl/5hxGb0AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADqbY/xnD9/8Iwff/B8P4/wfG - +f8Qzfr/JNf8/zPZ+v9IwOb/SaLU/yFZs/8MGZH/JCqJ/7+rXP/4zRD/9cgH//LDCf/vvwv/6rgO/+ey - Ef/jrBP/4KgV/96lHf/eqCX/oXYTuwAAABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASoNT9HcP2/w7C - 9/8izvn/R9/8/0nW9f81isj/Jlmy/xQ1sf8LGaz/DBu0/w0ct/8NHLD/Q0WF//zaOv/4zQj/9McH//DB - Cf/rug3/6LQP/+OtE//gqRX/3qYe/9umJf+Ych25AAAAFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACql - 1PNNze//UbLc/zqOz/8UOKv/CRel/woavf8KG8f/ChvH/wobx/8KG8T/CxvB/wwcvP8MGrH/mItl//nW - KP/2yQb/8sMJ/+28DP/ptQ//5K4S/+GqFP/fqCH/1aEj/4ZlLKcAAAAOAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAALWeswTBar/8ZL7D/Cxqz/woaw/8JG8r/CRrN/wgaz/8IG9D/CRvP/wkbzP8KG8n/ChvD/wwc - vv8qMZj/y7Zb//bLDv/ywwn/7bwM/+m1D//krhL/4aoW/+CqJv/PnCH/clk3gwAAAAYAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAOGpNcGyiw8x4txv8NHsn/CBrP/wga0/8HGtf/BhnZ/wYa2v8GGtn/BxrW/wga - 0v8JGsz/ChvG/wsauv9MTIP/9tU///HDD//rug3/6LQP/+OtE//hqxz/3akq/7CGKPdLPDIqAAAAAgAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwZlyoVI6vRJTTN/xUl0P8IGtX/Bhna/wYZ3/8FGeH/BRni/wUZ - 4f8GGd3/BxnZ/wga0v8JGsz/ChvD/woZsv+ajGb/9Msq/+q4Dv/nshH/460V/+KuJv/Woyv/mHQwxwAA - AAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoXnWgiMcb7JTXZ/wsd3P8FGeL/BBjo/wMY - 6/8DGOv/Axjq/wQZ5v8FGeD/BxnZ/wga0v8KG8n/CxvB/ywzmP/IsV7/67oa/+WvEv/iryL/4a8x/7GI - Lel6XzNEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACxecFBknuM0wP9r/IDHk/wcb - 5/8DGO3/Ahfx/wIY8v8CGPD/Axjr/wQY5v8GGd3/BxnW/wkazP8KG8T/Cxu1/0xNgv/zzkH/5bIf/+S0 - OP/WpjH/i2w4l2RQPQ4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACRemLCEw - xMs/Tun/L0Dv/w0h8/8CGff/ARf5/wEX9v8CF/D/Axjq/wUZ4f8GGdn/CRvP/wobx/8MHLz/EB+u/6OV - dv/vy17/1Kg/+515OLkAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAALGKYEER6tPik4zuVJWO7/QVL3/yY4+/8HHf3/ARj5/wIX8v8DGOv/BRni/wYa2v8IG9D/DR3I/yAv - wv87R8P/ZWmt/868e/+jgT67fGJCKgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAACBauJB8uxKtDUuX1WWf2/1tp+/9EVPn/L0Hz/yg67v8mOOX/Lj7f/z5M - 2v9SXtf/XmjR/1Rexf0yPaXVTEt5hwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACBesGBMivmgkMsrPQE/i/Vto8P9qdvL/b3rx/3B7 - 7f9teOb/Ym3b/1Jczf8zPrHnIy+ipQ0ZjDAPGooIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIF6s8BxWveAUV - tZ0FFbalBRWzqQYWq6MJF6KHCxicXg0ZlRQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////+AB///AAP//AAA//gAAH/wA - AA/8AAAP+AAAB/AAAAPwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAD8AAAA/AA - AAf4AAAP+AAAD/wAAB/8AAA//wAA//+AAP//8Af/////////////////KAAAABAAAAAgAAAAAQAgAAAA - AABABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAcAAAALgAA - ADQAAAAuAAAAHAAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUuTR4bfqqTQK3W5U/A - 5/1Qw+n/RbLd8yaJtL0EME1YAAAAFgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxaiS40rtndSdL4/ybN - +f8PyPn/C8X4/xzG+P87zPj/Prrm+TJkc4UAAAAWAAAAAAAAAAAAAAAAAAAAAAlTihAkq9rbJsz5/wbJ - +v8Ey/v/BMz7/wXK+v8Gxvn/C8P4/3C7rP/Lnzj7Tj0faAAAAAYAAAAAAAAAAAAAAAAOjsZ8H8f2/wbI - +v8Dzfv/AtH8/wLS/f8Dz/z/CMv6/2a9rP/Xnxj/3qci/6uCKdsAAAAcAAAAAAAAAAAAAAAAFKXb2w7F - +P8Fyvr/AtD8/wHU/v8A1v7/BNL9/2jGrP/dqhP/4KgV/92kGP/TnyT/TTwlTgAAAAAAAAAAAAAAABOv - 5P0IxPj/Bcn6/wPP/P8E1P3/I93+/2nLsv/ouwv/67oN/+WwEv/fpxb/3KUh/3tcGmwAAAAAAAAAAAAA - AAAWs+b/EMX4/yrS+f8spdz/LGzG/xEqrP9NTob/+M8W//HCCf/ptg//4aoU/92mIf+KZhVoAAAAAAAA - AAAAAAAANo/J7SxixP8MIbf/CRrI/wkby/8KG8b/Cxu8/6KSYP/0xwn/67kO/+OsFP/ZpCP/dlouTgAA - AAAAAAAAAAAAABYjqJMZKcv/BxrU/wYZ3P8GGd7/BxnY/wkazP8bJ63/3bw3/+m2D//irRr/wZMr70I0 - LAwAAAAAAAAAAAAAAAAKF50eJDTN8Q4g4v8DGOz/Axju/wQY5v8HGdj/ChvG/1NTi//quiP/364v/5p3 - MnQAAAAAAAAAAAAAAAAAAAAAAAAAABopu044SOb5HjH3/wIZ+f8DGO7/Bhne/woby/8eLLz/saF//7GM - PacAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGSi+OjxK38tPXfL/TFvx/0xa5v9RXdb/RlC94zY8 - k2QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABxauLgUVtlAGFa9SChefOA0Z - lQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAA+A8AAPAHAADgAwAAwAEAAMABAADAAQAAwAEAAMAB - AADAAQAAwAEAAMADAADgBwAA8A8AAPwfAAD//wAA - - - \ No newline at end of file diff --git a/plugins/Quotes/QuotesChart/Program.cs b/plugins/Quotes/QuotesChart/Program.cs deleted file mode 100644 index d2c79f5966..0000000000 --- a/plugins/Quotes/QuotesChart/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows.Forms; - -namespace QuotesChart -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new FormMirandaQuotesChart()); - } - } -} diff --git a/plugins/Quotes/QuotesChart/Properties/AssemblyInfo.cs b/plugins/Quotes/QuotesChart/Properties/AssemblyInfo.cs deleted file mode 100644 index c90728eff3..0000000000 --- a/plugins/Quotes/QuotesChart/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("QuotesChart")] -[assembly: AssemblyDescription("Chart Application for Miranda Quotes plugin")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Dioksin")] -[assembly: AssemblyProduct("Miranda")] -[assembly: AssemblyCopyright("Don't worry!")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9b8250c7-ffbe-4f8a-985e-2e562e253dc4")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.0.1.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/plugins/Quotes/QuotesChart/Properties/Resources.Designer.cs b/plugins/Quotes/QuotesChart/Properties/Resources.Designer.cs deleted file mode 100644 index 0bef6c885c..0000000000 --- a/plugins/Quotes/QuotesChart/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace QuotesChart.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("QuotesChart.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/plugins/Quotes/QuotesChart/Properties/Resources.resx b/plugins/Quotes/QuotesChart/Properties/Resources.resx deleted file mode 100644 index af7dbebbac..0000000000 --- a/plugins/Quotes/QuotesChart/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/plugins/Quotes/QuotesChart/Properties/Settings.Designer.cs b/plugins/Quotes/QuotesChart/Properties/Settings.Designer.cs deleted file mode 100644 index 02c737069d..0000000000 --- a/plugins/Quotes/QuotesChart/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace QuotesChart.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/plugins/Quotes/QuotesChart/Properties/Settings.settings b/plugins/Quotes/QuotesChart/Properties/Settings.settings deleted file mode 100644 index 39645652af..0000000000 --- a/plugins/Quotes/QuotesChart/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/plugins/Quotes/QuotesChart/QuotesChart.csproj b/plugins/Quotes/QuotesChart/QuotesChart.csproj deleted file mode 100644 index a502da630a..0000000000 --- a/plugins/Quotes/QuotesChart/QuotesChart.csproj +++ /dev/null @@ -1,124 +0,0 @@ - - - - Debug - x86 - 8.0.30703 - 2.0 - {C255CA56-D05E-4389-A32E-CA3EBE412684} - WinExe - Properties - QuotesChart - QuotesChart - v4.0 - 512 - - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - x86 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - bin\Debug\QuotesChart.exe.CodeAnalysisLog.xml - true - GlobalSuppressions.cs - prompt - MinimumRecommendedRules.ruleset - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - bin\Release\QuotesChart.exe.CodeAnalysisLog.xml - true - GlobalSuppressions.cs - prompt - MinimumRecommendedRules.ruleset - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets - ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules - - - main.ico - - - - - - - - - - - - - - - - - Form - - - Form1.cs - - - - - Form1.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - - \ No newline at end of file diff --git a/plugins/Quotes/QuotesChart/app.config b/plugins/Quotes/QuotesChart/app.config deleted file mode 100644 index e365603337..0000000000 --- a/plugins/Quotes/QuotesChart/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/plugins/Quotes/QuotesChart/bin/x32/QuotesChart.exe b/plugins/Quotes/QuotesChart/bin/x32/QuotesChart.exe deleted file mode 100644 index 5a96cbbcfb..0000000000 Binary files a/plugins/Quotes/QuotesChart/bin/x32/QuotesChart.exe and /dev/null differ diff --git a/plugins/Quotes/QuotesChart/bin/x64/QuotesChart.exe b/plugins/Quotes/QuotesChart/bin/x64/QuotesChart.exe deleted file mode 100644 index d85e08c0f1..0000000000 Binary files a/plugins/Quotes/QuotesChart/bin/x64/QuotesChart.exe and /dev/null differ diff --git a/plugins/Quotes/QuotesChart/main.ico b/plugins/Quotes/QuotesChart/main.ico deleted file mode 100644 index da85d1f7c6..0000000000 Binary files a/plugins/Quotes/QuotesChart/main.ico and /dev/null differ diff --git a/plugins/Quotes/docs/Utility/cc.xml b/plugins/Quotes/docs/Utility/cc.xml deleted file mode 100644 index 874d03e457..0000000000 --- a/plugins/Quotes/docs/Utility/cc.xml +++ /dev/null @@ -1,518 +0,0 @@ - - - - Currency Converter API - https://www.currencyconverterapi.com/ - https://free.currencyconverterapi.com/api/v5/convert - -
- Currencies - - AEDAEDUnited Arab Emirates Dirham (AED) - - - AFNAFNAfghan Afghani (AFN) - - - ALLALLAlbanian Lek (ALL) - - - AMDAMDArmenian Dram (AMD) - - - ANGANGNetherlands Antillean Gulden (ANG) - - - AOAAOAAngolan Kwanza (AOA) - - - ARSARSArgentine Peso (ARS) - - - AUDAUDAustralian Dollar (AUD) - - - AWGAWGAruban Florin (AWG) - - - AZNAZNAzerbaijani Manat (AZN) - - - BAMBAMBosnia-Herzegovina Convertible Mark (BAM) - - - BBDBBDBarbadian Dollar (BBD) - - - BDTBDTBangladeshi Taka (BDT) - - - BGNBGNBulgarian Lev (BGN) - - - BHDBHDBahraini Dinar (BHD) - - - BIFBIFBurundian Franc (BIF) - - - BMDBMDBermudan Dollar (BMD) - - - BNDBNDBrunei Dollar (BND) - - - BOBBOBBolivian Boliviano (BOB) - - - BRLBRLBrazilian Real (BRL) - - - BSDBSDBahamian Dollar (BSD) - - - BTCBTCBitcoin (BTC) - - - BTNBTNBhutanese Ngultrum (BTN) - - - BWPBWPBotswana Pula (BWP) - - - BYNBYNBelarusian Ruble (BYN) - - - BYRBYRBelarusian Ruble (2000–2016) (BYR) - - - BZDBZDBelize Dollar (BZD) - - - CADCADCanadian Dollar (CAD) - - - CDFCDFCongolese Franc (CDF) - - - CHFCHFSwiss Franc (CHF) - - - CLFCLFChilean Unit of Account (UF) (CLF) - - - CLPCLPChilean Peso (CLP) - - - CNHCNHCNH (CNH) - - - CNYCNYChinese Yuan (CNY) - - - COPCOPColombian Peso (COP) - - - CRCCRCCosta Rican Colón (CRC) - - - CUPCUPCuban Peso (CUP) - - - CVECVECape Verdean Escudo (CVE) - - - CZKCZKCzech Koruna (CZK) - - - DEMDEMGerman Mark (DEM) - - - DJFDJFDjiboutian Franc (DJF) - - - DKKDKKDanish Krone (DKK) - - - DOPDOPDominican Peso (DOP) - - - DZDDZDAlgerian Dinar (DZD) - - - EGPEGPEgyptian Pound (EGP) - - - ERNERNEritrean Nakfa (ERN) - - - ETBETBEthiopian Birr (ETB) - - - EUREUREuro (EUR) - - - FIMFIMFinnish Markka (FIM) - - - FJDFJDFijian Dollar (FJD) - - - FKPFKPFalkland Islands Pound (FKP) - - - FRFFRFFrench Franc (FRF) - - - GBPGBPBritish Pound (GBP) - - - GELGELGeorgian Lari (GEL) - - - GHSGHSGhanaian Cedi (GHS) - - - GIPGIPGibraltar Pound (GIP) - - - GMDGMDGambian Dalasi (GMD) - - - GNFGNFGuinean Franc (GNF) - - - GTQGTQGuatemalan Quetzal (GTQ) - - - GYDGYDGuyanaese Dollar (GYD) - - - HKDHKDHong Kong Dollar (HKD) - - - HNLHNLHonduran Lempira (HNL) - - - HRKHRKCroatian Kuna (HRK) - - - HTGHTGHaitian Gourde (HTG) - - - HUFHUFHungarian Forint (HUF) - - - IDRIDRIndonesian Rupiah (IDR) - - - IEPIEPIrish Pound (IEP) - - - ILSILSIsraeli New Shekel (ILS) - - - INRINRIndian Rupee (INR) - - - IQDIQDIraqi Dinar (IQD) - - - IRRIRRIranian Rial (IRR) - - - ISKISKIcelandic Króna (ISK) - - - ITLITLItalian Lira (ITL) - - - JMDJMDJamaican Dollar (JMD) - - - JODJODJordanian Dinar (JOD) - - - JPYJPYJapanese Yen (JPY) - - - KESKESKenyan Shilling (KES) - - - KGSKGSKyrgystani Som (KGS) - - - KHRKHRCambodian Riel (KHR) - - - KMFKMFComorian Franc (KMF) - - - KPWKPWNorth Korean Won (KPW) - - - KRWKRWSouth Korean Won (KRW) - - - KWDKWDKuwaiti Dinar (KWD) - - - KYDKYDCayman Islands Dollar (KYD) - - - KZTKZTKazakhstani Tenge (KZT) - - - LAKLAKLaotian Kip (LAK) - - - LBPLBPLebanese Pound (LBP) - - - LKRLKRSri Lankan Rupee (LKR) - - - LRDLRDLiberian Dollar (LRD) - - - LSLLSLLesotho Loti (LSL) - - - LTLLTLLithuanian Litas (LTL) - - - LVLLVLLatvian Lats (LVL) - - - LYDLYDLibyan Dinar (LYD) - - - MADMADMoroccan Dirham (MAD) - - - MDLMDLMoldovan Leu (MDL) - - - MGAMGAMalagasy Ariary (MGA) - - - MKDMKDMacedonian Denar (MKD) - - - MNTMNTMongolian Tugrik (MNT) - - - MOPMOPMacanese Pataca (MOP) - - - MROMROMauritanian Ouguiya (MRO) - - - MURMURMauritian Rupee (MUR) - - - MVRMVRMaldivian Rufiyaa (MVR) - - - MWKMWKMalawian Kwacha (MWK) - - - MXNMXNMexican Peso (MXN) - - - MYRMYRMalaysian Ringgit (MYR) - - - MZNMZNMozambican Metical (MZN) - - - NADNADNamibian Dollar (NAD) - - - NGNNGNNigerian Naira (NGN) - - - NIONIONicaraguan Córdoba (NIO) - - - NOKNOKNorwegian Krone (NOK) - - - NPRNPRNepalese Rupee (NPR) - - - NZDNZDNew Zealand Dollar (NZD) - - - OMROMROmani Rial (OMR) - - - PABPABPanamanian Balboa (PAB) - - - PENPENPeruvian Nuevo Sol (PEN) - - - PGKPGKPapua New Guinean Kina (PGK) - - - PHPPHPPhilippine Peso (PHP) - - - PKGPKGPKG (PKG) - - - PKRPKRPakistani Rupee (PKR) - - - PLNPLNPolish Zloty (PLN) - - - PYGPYGParaguayan Guarani (PYG) - - - QARQARQatari Riyal (QAR) - - - RONRONNew Romanian Leu (RON) - - - RSDRSDSerbian Dinar (RSD) - - - RUBRUBRussian Ruble (RUB) - - - RWFRWFRwandan Franc (RWF) - - - SARSARSaudi Riyal (SAR) - - - SBDSBDSolomon Islands Dollar (SBD) - - - SCRSCRSeychellois Rupee (SCR) - - - SDGSDGSudanese Pound (SDG) - - - SEKSEKSwedish Krona (SEK) - - - SGDSGDSingapore Dollar (SGD) - - - SHPSHPSt. Helena Pound (SHP) - - - SKKSKKSlovak Koruna (SKK) - - - SLLSLLSierra Leonean Leone (SLL) - - - SOSSOSSomali Shilling (SOS) - - - SRDSRDSurinamese Dollar (SRD) - - - STDSTDSão Tomé and Príncipe Dobra (STD) - - - SVCSVCSalvadoran Colón (SVC) - - - SYPSYPSyrian Pound (SYP) - - - SZLSZLSwazi Lilangeni (SZL) - - - THBTHBThai Baht (THB) - - - TJSTJSTajikistani Somoni (TJS) - - - TMTTMTTurkmenistani Manat (TMT) - - - TNDTNDTunisian Dinar (TND) - - - TOPTOPTongan Paʻanga (TOP) - - - TRYTRYTurkish Lira (TRY) - - - TTDTTDTrinidad and Tobago Dollar (TTD) - - - TWDTWDNew Taiwan Dollar (TWD) - - - TZSTZSTanzanian Shilling (TZS) - - - UAHUAHUkrainian Hryvnia (UAH) - - - UGXUGXUgandan Shilling (UGX) - - - USDUSDUnited States Dollar (USD) - - - UYUUYUUruguayan Peso (UYU) - - - UZSUZSUzbekistani Som (UZS) - - - VEFVEFVenezuelan Bolívar (VEF) - - - VNDVNDVietnamese Dong (VND) - - - VUVVUVVanuatu Vatu (VUV) - - - WSTWSTSamoan Tala (WST) - - - XAFXAFCentral African CFA Franc (FCFA) - - - XCDXCDEast Caribbean Dollar (XCD) - - - XDRXDRSpecial Drawing Rights (XDR) - - - XOFXOFWest African CFA Franc (CFA) - - - XPFXPFCFP Franc (CFPF) - - - YERYERYemeni Rial (YER) - - - ZARZARSouth African Rand (ZAR) - - - ZMKZMKZambian Kwacha (1968–2012) (ZMK) - - - ZMWZMWZambian Kwacha (ZMW) - - - ZWLZWLZimbabwean Dollar (2009) (ZWL) - -
-
\ No newline at end of file diff --git a/plugins/Quotes/proto_Quotes/proto_Quotes.vcxproj b/plugins/Quotes/proto_Quotes/proto_Quotes.vcxproj deleted file mode 100644 index 30176779b5..0000000000 --- a/plugins/Quotes/proto_Quotes/proto_Quotes.vcxproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - Proto_Quotes - {5A0A9761-78E1-4E0F-AD8C-8931A667A5F2} - - - - - \ No newline at end of file diff --git a/plugins/Quotes/proto_Quotes/proto_Quotes.vcxproj.filters b/plugins/Quotes/proto_Quotes/proto_Quotes.vcxproj.filters deleted file mode 100644 index e39f86d5d6..0000000000 --- a/plugins/Quotes/proto_Quotes/proto_Quotes.vcxproj.filters +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ 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 deleted file mode 100644 index a730c5be28..0000000000 --- a/plugins/Quotes/proto_Quotes/res/proto_Quotes.rc +++ /dev/null @@ -1,121 +0,0 @@ -//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" - -#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 deleted file mode 100644 index 385d27fb15..0000000000 Binary files a/plugins/Quotes/proto_Quotes/res/proto_na.ico and /dev/null differ diff --git a/plugins/Quotes/proto_Quotes/res/proto_offline.ico b/plugins/Quotes/proto_Quotes/res/proto_offline.ico deleted file mode 100644 index f6fc5e9f20..0000000000 Binary files a/plugins/Quotes/proto_Quotes/res/proto_offline.ico and /dev/null differ diff --git a/plugins/Quotes/proto_Quotes/res/proto_online.ico b/plugins/Quotes/proto_Quotes/res/proto_online.ico deleted file mode 100644 index da85d1f7c6..0000000000 Binary files a/plugins/Quotes/proto_Quotes/res/proto_online.ico and /dev/null differ diff --git a/plugins/Quotes/res/AutoUpdateDisabled.ico b/plugins/Quotes/res/AutoUpdateDisabled.ico deleted file mode 100644 index 30c9dbf220..0000000000 Binary files a/plugins/Quotes/res/AutoUpdateDisabled.ico and /dev/null differ diff --git a/plugins/Quotes/res/CurrencyConverter.ico b/plugins/Quotes/res/CurrencyConverter.ico deleted file mode 100644 index 67ac2095f5..0000000000 Binary files a/plugins/Quotes/res/CurrencyConverter.ico and /dev/null differ diff --git a/plugins/Quotes/res/Export quotes.ico b/plugins/Quotes/res/Export quotes.ico deleted file mode 100644 index 31c7aa2ba1..0000000000 Binary files a/plugins/Quotes/res/Export quotes.ico and /dev/null differ diff --git a/plugins/Quotes/res/Forex.rc b/plugins/Quotes/res/Forex.rc deleted file mode 100644 index ec4b7943d5..0000000000 --- a/plugins/Quotes/res/Forex.rc +++ /dev/null @@ -1,369 +0,0 @@ -// 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" - -IDI_ICON_DISABLED ICON "AutoUpdateDisabled.ico" - - -#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 - -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 Google",IDC_SYSLINK_PROVIDER, - "SysLink",WS_TABSTOP,7,61,328,11 - PUSHBUTTON "Close",IDCANCEL,148,80,50,14 -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 "Colors",IDC_STATIC,7,7,149,82,WS_GROUP - CONTROL "Use default colors",IDC_RADIO_DEFAULT_COLOURS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,20,82,10 - CONTROL "Use user-defined colors",IDC_RADIO_USER_DEFINED_COLOURS, - "Button",BS_AUTORADIOBUTTON,15,34,97,10 - LTEXT "Background color",IDC_STATIC,70,53,66,8 - CONTROL "",IDC_BGCOLOR,"ColourPicker",WS_TABSTOP,26,49,35,14 - LTEXT "Text color",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,90,10 - CONTROL "Custom",IDC_DELAYCUSTOM,"Button",BS_AUTORADIOBUTTON,174,35,70,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 - -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 "",IDC_STATIC_QUOTE_NAME,7,7,208,8 - CONTROL "",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_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 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 "",IDC_STATIC_QUOTE_NAME,7,7,208,8 - CONTROL "",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 - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_DIALOG_VARIABLE_LIST, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 209 - TOPMARGIN, 7 - BOTTOMMARGIN, 175 - END - - 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_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 - - 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 -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// AFX_DIALOG_LAYOUT -// - -IDD_CURRENCY_CONVERTER AFX_DIALOG_LAYOUT -BEGIN - 0 -END - -#endif // Neutral 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 deleted file mode 100644 index 506aa62af3..0000000000 Binary files a/plugins/Quotes/res/Import quotes.ico and /dev/null differ diff --git a/plugins/Quotes/res/Refresh.ico b/plugins/Quotes/res/Refresh.ico deleted file mode 100644 index f09a47cd9e..0000000000 Binary files a/plugins/Quotes/res/Refresh.ico and /dev/null differ diff --git a/plugins/Quotes/res/Section.ico b/plugins/Quotes/res/Section.ico deleted file mode 100644 index 768b3775aa..0000000000 Binary files a/plugins/Quotes/res/Section.ico and /dev/null differ diff --git a/plugins/Quotes/res/Version.rc b/plugins/Quotes/res/Version.rc deleted file mode 100644 index 5a5ddd63ed..0000000000 --- a/plugins/Quotes/res/Version.rc +++ /dev/null @@ -1,9 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "..\src\version.h" - -#include "..\..\build\Version.rc" diff --git a/plugins/Quotes/res/down.ico b/plugins/Quotes/res/down.ico deleted file mode 100644 index 20722f63ca..0000000000 Binary files a/plugins/Quotes/res/down.ico and /dev/null differ diff --git a/plugins/Quotes/res/main.ico b/plugins/Quotes/res/main.ico deleted file mode 100644 index da85d1f7c6..0000000000 Binary files a/plugins/Quotes/res/main.ico and /dev/null differ diff --git a/plugins/Quotes/res/notchanged.ico b/plugins/Quotes/res/notchanged.ico deleted file mode 100644 index 39a8f1ea3c..0000000000 Binary files a/plugins/Quotes/res/notchanged.ico and /dev/null differ diff --git a/plugins/Quotes/res/quote.ico b/plugins/Quotes/res/quote.ico deleted file mode 100644 index 1367c475d6..0000000000 Binary files a/plugins/Quotes/res/quote.ico and /dev/null differ diff --git a/plugins/Quotes/res/swap.ico b/plugins/Quotes/res/swap.ico deleted file mode 100644 index f4a410da41..0000000000 Binary files a/plugins/Quotes/res/swap.ico and /dev/null differ diff --git a/plugins/Quotes/res/up.ico b/plugins/Quotes/res/up.ico deleted file mode 100644 index 0379c80d17..0000000000 Binary files a/plugins/Quotes/res/up.ico and /dev/null differ diff --git a/plugins/Quotes/src/Chart.h b/plugins/Quotes/src/Chart.h deleted file mode 100644 index 3eebd5d11e..0000000000 --- a/plugins/Quotes/src/Chart.h +++ /dev/null @@ -1,280 +0,0 @@ -#ifndef __FAE7F26E_61ED_4951_BE87_5E022CDF21DF_Chart_h__ -#define __FAE7F26E_61ED_4951_BE87_5E022CDF21DF_Chart_h__ - -#pragma once - -namespace detail -{ - template struct CConverter - { - static double Convert(const T& v) - { - return boost::numeric_cast(v); - } - - static tstring ToString(const T& v) - { - return boost::lexical_cast(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 TYConverter = detail::CConverter > -class CChart -{ -private: - typedef std::pair TValue; - typedef std::vector TValues; - -public: - CChart() : m_MaxY(), m_MinY() - { - memset(&m_rect, 0, 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(::GetStockObject(DEFAULT_GUI_FONT)); - HFONT hOldFont = static_cast(::SelectObject(hdc, hFont)); - - LPCTSTR pszText = TranslateT("There is nothing to show"); - int nDrawTextResult = ::DrawText(hdc, pszText, -1, &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(::SelectObject(hdc, hPen)); - HFONT hFont = static_cast(::GetStockObject(DEFAULT_GUI_FONT)); - HFONT hOldFont = static_cast(::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(), -1, &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(::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((rc.right - rc.left)*(k / dx)); - k = TYConverter::Convert(v.second - m_MinY); - int y = rc.bottom - boost::numeric_cast((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 deleted file mode 100644 index 0dc689133f..0000000000 --- a/plugins/Quotes/src/ComHelper.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "StdAfx.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() << L" (" << std::hex << hError << L")"; - - IErrorInfo* p = e.ErrorInfo(); - CComPtr pErrorInfo(p); - if (nullptr != p) - p->Release(); - - if (pErrorInfo) - o << L"\n" << e.Description(); - - return o.str(); -} - -void ShowComError(_com_error& e, const tstring& rsAdditionalInfo) -{ - tstring sErrorMsg = ComException2Msg(e, rsAdditionalInfo); - LogIt(sErrorMsg); - Quotes_MessageBox(nullptr, sErrorMsg.c_str(), MB_OK | MB_ICONERROR); -} diff --git a/plugins/Quotes/src/ComHelper.h b/plugins/Quotes/src/ComHelper.h deleted file mode 100644 index 16f565b5be..0000000000 --- a/plugins/Quotes/src/ComHelper.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef __37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__ -#define __37ae28ab_c414_4aba_bbef_d23dd68643a5_ComHelper_h__ - -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 deleted file mode 100644 index 4429ff1aa3..0000000000 --- a/plugins/Quotes/src/CommonOptionDlg.cpp +++ /dev/null @@ -1,228 +0,0 @@ -#include "StdAfx.h" - -typedef boost::shared_ptr TAdvSettingsPtr; -typedef std::map 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(); - - if (true == bCreateIfNonExist) { - TAdvSettingsPtr pAdvSet(new CAdvProviderSettings(pProvider)); - g_aAdvSettings.insert(std::make_pair(pProvider, pAdvSet)); - return pAdvSet.get(); - } - - return nullptr; -} - -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 < _countof(pszRefreshRateTypes); ++i) - ::SendMessage(hwndCombo, CB_ADDSTRING, 0, reinterpret_cast(pszRefreshRateTypes[i])); - - int nRefreshRateType = db_get_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateType, RRT_MINUTES); - if (nRefreshRateType < RRT_SECONDS || nRefreshRateType > RRT_HOURS) - nRefreshRateType = RRT_MINUTES; - - UINT nRate = db_get_w(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(::SendMessage(reinterpret_cast(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(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(lp); - switch (pNMHDR->code) { - case PSN_KILLACTIVE: - { - BOOL bOk = FALSE; - UINT nRefreshRate = ::GetDlgItemInt(hWnd, IDC_EDIT_REFRESH_RATE, &bOk, FALSE); - ERefreshRateType nType = static_cast(::SendDlgItemMessage(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(::SendDlgItemMessage(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; - db_set_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateType, nType); - db_set_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateValue, nRefreshRate); - - tstring s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_CONTACT_LIST_FORMAT)); - db_set_ws(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbDisplayNameFormat, s.c_str()); - - s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_STATUS_MESSAGE_FORMAT)); - db_set_ws(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbStatusMsgFormat, s.c_str()); - - s = get_window_text(::GetDlgItem(hWnd, IDC_EDIT_TENDENCY_FORMAT)); - db_set_ws(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; - } -} diff --git a/plugins/Quotes/src/CommonOptionDlg.h b/plugins/Quotes/src/CommonOptionDlg.h deleted file mode 100644 index 42366b70b9..0000000000 --- a/plugins/Quotes/src/CommonOptionDlg.h +++ /dev/null @@ -1,17 +0,0 @@ -#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 deleted file mode 100644 index f2a28621fb..0000000000 --- a/plugins/Quotes/src/CreateFilePath.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "StdAfx.h" - -static wchar_t InvalidSymbols[] = { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }; - -static wchar_t replace_invalid_symbol(wchar_t chr) -{ - for (int i = 0; i < _countof(InvalidSymbols); ++i) - if (chr == InvalidSymbols[i]) - return '_'; - - 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) -{ - wchar_t szPath[_MAX_PATH]; - ::GetModuleFileName(g_plugin.getInst(), szPath, _MAX_PATH); - - wchar_t* p = wcsrchr(szPath, '\\'); - if (p) - *p = 0; - - tstring s(rsName); - prepare_name(s); - tostringstream o; - o << szPath << L"\\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 deleted file mode 100644 index 17aca8ab83..0000000000 --- a/plugins/Quotes/src/CreateFilePath.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__ -#define _aaf3bee6_cee7_4023_8848_5911ad7a9660_CreateFilePath_h__ - -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 deleted file mode 100644 index e66511ce91..0000000000 --- a/plugins/Quotes/src/CurrencyConverter.cpp +++ /dev/null @@ -1,266 +0,0 @@ -#include "StdAfx.h" -#include "QuotesProviderCurrencyConverter.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" - -static CQuotesProviderCurrencyConverter* get_currency_converter_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; - if (auto p = dynamic_cast(pProvider.get())) - { - return p; - } - } - - assert(!"We should never get here!"); - return nullptr; -} - -CQuotesProviderBase::CQuoteSection get_quotes(const CQuotesProviderCurrencyConverter* pProvider = nullptr) -{ - if (nullptr == pProvider) - pProvider = get_currency_converter_provider(); - - if (pProvider) { - const auto& rQuotes = pProvider->GetQuotes(); - if (rQuotes.GetSectionCount() > 0) - return rQuotes.GetSection(0); - } - - return CQuotesProviderBase::CQuoteSection(); -} - -inline tstring make_quote_name(const CQuotesProviderBase::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(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); - int nTo = static_cast(::SendDlgItemMessage(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(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); - int nTo = static_cast(::SendDlgItemMessage(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: - TranslateDialogDefault(hDlg); - { - MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX, false); - assert(hWL); - WindowList_Add(hWL, hDlg); - - Window_SetIcon_IcoLib(hDlg, Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER)); - - 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 auto pProvider = get_currency_converter_provider(); - const auto& rSection = get_quotes(pProvider); - auto cQuotes = rSection.GetQuoteCount(); - for (auto i = 0u; i < cQuotes; ++i) { - const auto& rQuote = rSection.GetQuote(i); - tstring sName = make_quote_name(rQuote); - LPCTSTR pszName = sName.c_str(); - LRESULT nFrom = ::SendMessage(hcbxFrom, CB_ADDSTRING, 0, reinterpret_cast(pszName)); - LRESULT nTo = ::SendMessage(hcbxTo, CB_ADDSTRING, 0, reinterpret_cast(pszName)); - - if (0 == mir_wstrcmpi(rQuote.GetID().c_str(), sFromQuoteID.c_str())) { - ::SendMessage(hcbxFrom, CB_SETCURSEL, nFrom, 0); - } - - if (0 == mir_wstrcmpi(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") << L" " << pi.m_sName << L""; - - ::SetDlgItemText(hDlg, IDC_SYSLINK_PROVIDER, o.str().c_str()); - - ::SendDlgItemMessage(hDlg, IDC_BUTTON_SWAP, BM_SETIMAGE, IMAGE_ICON, LPARAM(Quotes_LoadIconEx(IDI_ICON_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: - { - MWindowList 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_DESTROY: - Window_FreeIcon_IcoLib(hDlg); - break; - - 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(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); - size_t nTo = static_cast(::SendDlgItemMessage(hDlg, IDC_COMBO_CONVERT_INTO, CB_GETCURSEL, 0, 0)); - if ((CB_ERR != nFrom) && (CB_ERR != nTo) && (nFrom != nTo)) { - const auto& rSection = get_quotes(); - size_t cQuotes = rSection.GetQuoteCount(); - if ((nFrom < cQuotes) && (nTo < cQuotes)) { - auto from = rSection.GetQuote(nFrom); - auto to = rSection.GetQuote(nTo); - - db_set_ws(NULL, QUOTES_MODULE_NAME, DB_STR_CC_QUOTE_FROM_ID, from.GetID().c_str()); - db_set_ws(NULL, QUOTES_MODULE_NAME, DB_STR_CC_QUOTE_TO_ID, to.GetID().c_str()); - - const auto pProvider = get_currency_converter_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(); - } - - if (false == sError.empty()) - 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; - } - break; - - case WM_NOTIFY: - LPNMHDR pNMHDR = reinterpret_cast(lp); - switch (pNMHDR->code) { - case NM_CLICK: - if (IDC_SYSLINK_PROVIDER == wp) { - PNMLINK pNMLink = reinterpret_cast(pNMHDR); - ::ShellExecute(hDlg, L"open", pNMLink->item.szUrl, nullptr, nullptr, SW_SHOWNORMAL); - } - break; - } - break; - } - return (FALSE); -} - -INT_PTR QuotesMenu_CurrencyConverter(WPARAM, LPARAM) -{ - MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX, true); - HWND hWnd = WindowList_Find(hWL, NULL); - if (nullptr != hWnd) { - SetForegroundWindow(hWnd); - SetFocus(hWnd); - } - else CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CURRENCY_CONVERTER), nullptr, CurrencyConverterDlgProc, 0); - - return 0; -} diff --git a/plugins/Quotes/src/CurrencyConverter.h b/plugins/Quotes/src/CurrencyConverter.h deleted file mode 100644 index c700fa5b22..0000000000 --- a/plugins/Quotes/src/CurrencyConverter.h +++ /dev/null @@ -1,6 +0,0 @@ -#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 deleted file mode 100644 index 19e8088286..0000000000 --- a/plugins/Quotes/src/DBUtils.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "StdAfx.h" - -std::string Quotes_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue /*= NULL*/) -{ - std::string sResult; - char* pszSymbol = db_get_sa(hContact, szModule, szSetting); - if (nullptr != pszSymbol) { - sResult = pszSymbol; - mir_free(pszSymbol); - } - else if (nullptr != pszDefValue) - sResult = pszDefValue; - - return sResult; -} - -std::wstring Quotes_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue/* = NULL*/) -{ - std::wstring sResult; - wchar_t* pszSymbol = db_get_wsa(hContact, szModule, szSetting); - if (nullptr != pszSymbol) { - sResult = pszSymbol; - mir_free(pszSymbol); - } - else if (nullptr != pszDefValue) - sResult = pszDefValue; - - return sResult; -} - -bool Quotes_DBWriteDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double dValue) -{ - return 0 == db_set_blob(hContact, szModule, szSetting, &dValue, sizeof(dValue)); -} - -bool Quotes_DBReadDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double& rdValue) -{ - DBVARIANT dbv = { 0 }; - dbv.type = DBVT_BLOB; - - bool bResult = ((0 == db_get(hContact, szModule, szSetting, &dbv)) && (DBVT_BLOB == dbv.type)); - if (bResult) - rdValue = *reinterpret_cast(dbv.pbVal); - - db_free(&dbv); - return bResult; -} diff --git a/plugins/Quotes/src/DBUtils.h b/plugins/Quotes/src/DBUtils.h deleted file mode 100644 index 3f758c2b5a..0000000000 --- a/plugins/Quotes/src/DBUtils.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__ -#define __54294385_3fdd_4f0c_98c3_c583a96e7fb4_DBUtils_h__ - -std::string Quotes_DBGetStringA(MCONTACT hContact, const char* szModule, const char* szSetting, const char* pszDefValue = NULL); -std::wstring Quotes_DBGetStringW(MCONTACT hContact, const char* szModule, const char* szSetting, const wchar_t* pszDefValue = NULL); - - -#define Quotes_DBGetStringT Quotes_DBGetStringW - -bool Quotes_DBWriteDouble(MCONTACT hContact, const char* szModule, const char* szSetting, double dValue); -bool Quotes_DBReadDouble(MCONTACT 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 deleted file mode 100644 index af881c7bff..0000000000 --- a/plugins/Quotes/src/EconomicRateInfo.h +++ /dev/null @@ -1,59 +0,0 @@ -#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" // 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 deleted file mode 100644 index 5fdff8d004..0000000000 --- a/plugins/Quotes/src/ExtraImages.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "StdAfx.h" - -static HANDLE hExtraIcon; - -void Quotes_InitExtraIcons() -{ - hExtraIcon = ExtraIcon_RegisterIcolib(ICON_STR_QUOTE, QUOTES_PROTOCOL_NAME, QUOTES_PROTOCOL_NAME "_" ICON_STR_MAIN); -} - -bool SetContactExtraImage(MCONTACT hContact, EImageIndex nIndex) -{ - if (!hExtraIcon) - 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 = nullptr; - } - return ExtraIcon_SetIcon(hExtraIcon, hContact, hIcolib) == 0; -} diff --git a/plugins/Quotes/src/ExtraImages.h b/plugins/Quotes/src/ExtraImages.h deleted file mode 100644 index 717e0df155..0000000000 --- a/plugins/Quotes/src/ExtraImages.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__ -#define __9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__ - -enum EImageIndex -{ - eiUp = 0, - eiDown = 1, - eiNotChanged = 2, - eiEmpty = 3 -}; - -bool SetContactExtraImage(MCONTACT hContact, EImageIndex nIndex); - -void Quotes_InitExtraIcons(void); - -#endif //__9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__ diff --git a/plugins/Quotes/src/Forex.cpp b/plugins/Quotes/src/Forex.cpp deleted file mode 100644 index a951a5667c..0000000000 --- a/plugins/Quotes/src/Forex.cpp +++ /dev/null @@ -1,337 +0,0 @@ -// Forex.cpp : Defines the exported functions for the DLL application. -// - -#include "stdafx.h" - -CMPlugin g_plugin; - -HANDLE g_hEventWorkThreadStop; -//int g_nStatus = ID_STATUS_OFFLINE; -bool g_bAutoUpdate = true; -HGENMENU g_hMenuEditSettings = nullptr; -HGENMENU g_hMenuOpenLogFile = nullptr; -#ifdef CHART_IMPLEMENT -HGENMENU g_hMenuChart = nullptr; -#endif -HGENMENU g_hMenuRefresh = nullptr, g_hMenuRoot = nullptr; - -#define DB_STR_AUTO_UPDATE "AutoUpdate" - -typedef std::vector THandles; -THandles g_ahThreads; -HGENMENU g_hEnableDisableMenu; -HANDLE g_hTBButton; - -LPSTR g_pszAutoUpdateCmd = "Quotes/Enable-Disable Auto Update"; -LPSTR g_pszCurrencyConverter = "Quotes/CurrencyConverter"; - -void UpdateMenu(bool bAutoUpdate) -{ - if (bAutoUpdate) // to enable auto-update - Menu_ModifyItem(g_hEnableDisableMenu, LPGENW("Auto Update Enabled"), Quotes_GetIconHandle(IDI_ICON_MAIN)); - else // to disable auto-update - Menu_ModifyItem(g_hEnableDisableMenu, LPGENW("Auto Update Disabled"), Quotes_GetIconHandle(IDI_ICON_DISABLED)); - - CallService(MS_TTB_SETBUTTONSTATE, reinterpret_cast(g_hTBButton), !bAutoUpdate ? TTBST_PUSHED : 0); -} - -INT_PTR QuotesMenu_RefreshAll(WPARAM, LPARAM) -{ - const CQuotesProviders::TQuotesProviders& apProviders = CModuleInfo::GetQuoteProvidersPtr()->GetProviders(); - std::for_each(apProviders.begin(), apProviders.end(), boost::bind(&IQuotesProvider::RefreshAllContacts, _1)); - return 0; -} - -INT_PTR QuotesMenu_EnableDisable(WPARAM, LPARAM) -{ - g_bAutoUpdate = (g_bAutoUpdate) ? false : true; - db_set_b(NULL, QUOTES_MODULE_NAME, DB_STR_AUTO_UPDATE, g_bAutoUpdate); - - const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr(); - const CQuotesProviders::TQuotesProviders& rapProviders = pProviders->GetProviders(); - std::for_each(std::begin(rapProviders), std::end(rapProviders), [](const CQuotesProviders::TQuotesProviderPtr& pProvider) { - pProvider->RefreshSettings(); - if (g_bAutoUpdate) - pProvider->RefreshAllContacts(); - }); - UpdateMenu(g_bAutoUpdate); - - return 0; -} - -void InitMenu() -{ - CMenuItem mi(&g_plugin); - mi.flags = CMIF_UNICODE; - mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Currency rates"), 0, Quotes_GetIconHandle(IDI_ICON_MAIN)); - Menu_ConfigureItem(mi.root, MCI_OPT_UID, "B474F556-22B6-42A1-A91E-22FE4F671388"); - - SET_UID(mi, 0x9de6716, 0x3591, 0x48c4, 0x9f, 0x64, 0x1b, 0xfd, 0xc6, 0xd1, 0x34, 0x97); - mi.name.w = LPGENW("Enable/Disable Auto Update"); - mi.position = 10100001; - mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN); - mi.pszService = g_pszAutoUpdateCmd; - g_hEnableDisableMenu = Menu_AddMainMenuItem(&mi); - CreateServiceFunction(mi.pszService, QuotesMenu_EnableDisable); - UpdateMenu(g_bAutoUpdate); - - SET_UID(mi, 0x91cbabf6, 0x5073, 0x4a78, 0x84, 0x8, 0x34, 0x61, 0xc1, 0x8a, 0x34, 0xd9); - mi.name.w = LPGENW("Refresh All Rates"); - mi.position = 20100001; - mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN); - mi.pszService = "Quotes/RefreshAll"; - Menu_AddMainMenuItem(&mi); - CreateServiceFunction(mi.pszService, QuotesMenu_RefreshAll); - - SET_UID(mi, 0x3663409c, 0xbd36, 0x473b, 0x9b, 0x4f, 0xff, 0x80, 0xf6, 0x2c, 0xdf, 0x9b); - mi.name.w = LPGENW("Currency Converter..."); - mi.position = 20100002; - mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER); - mi.pszService = g_pszCurrencyConverter; - Menu_AddMainMenuItem(&mi); - CreateServiceFunction(mi.pszService, QuotesMenu_CurrencyConverter); - - SET_UID(mi, 0x7cca4fd9, 0x903f, 0x4b7d, 0x93, 0x7a, 0x18, 0x63, 0x23, 0xd4, 0xa9, 0xa9); - mi.name.w = LPGENW("Export All Currency Rates"); - mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_EXPORT); - mi.pszService = "Quotes/ExportAll"; - mi.position = 20100003; - Menu_AddMainMenuItem(&mi); - CreateServiceFunction(mi.pszService, QuotesMenu_ExportAll); - - SET_UID(mi, 0xa994d3b, 0x77c2, 0x4612, 0x8d, 0x5, 0x6a, 0xae, 0x8c, 0x21, 0xbd, 0xc9); - mi.name.w = LPGENW("Import All Currency Rates"); - mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_IMPORT); - mi.pszService = "Quotes/ImportAll"; - mi.position = 20100004; - Menu_AddMainMenuItem(&mi); - CreateServiceFunction(mi.pszService, QuotesMenu_ImportAll); - - HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Quotes_PrebuildContactMenu); - - g_hMenuRoot = mi.root = g_plugin.addRootMenu(MO_CONTACT, _T(QUOTES_PROTOCOL_NAME), 0, Quotes_GetIconHandle(IDI_ICON_MAIN)); - Menu_ConfigureItem(mi.root, MCI_OPT_UID, "C259BE01-642C-461E-997D-0E756B2A3AD6"); - - SET_UID(mi, 0xb9812194, 0x3235, 0x4e76, 0xa3, 0xa4, 0x73, 0x32, 0x96, 0x1c, 0x1c, 0xf4); - mi.name.w = LPGENW("Refresh"); - mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_REFRESH); - mi.pszService = "Quotes/RefreshContact"; - g_hMenuRefresh = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); - Menu_ConfigureItem(g_hMenuRefresh, MCI_OPT_EXECPARAM, INT_PTR(0)); - CreateServiceFunction(mi.pszService, QuotesMenu_RefreshContact); - - SET_UID(mi, 0x19a16fa2, 0xf370, 0x4201, 0x92, 0x9, 0x25, 0xde, 0x4e, 0x55, 0xf9, 0x1a); - mi.name.w = LPGENW("Open Log File..."); - mi.hIcolibItem = nullptr; - mi.pszService = "Quotes/OpenLogFile"; - g_hMenuOpenLogFile = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); - Menu_ConfigureItem(g_hMenuOpenLogFile, MCI_OPT_EXECPARAM, 1); - CreateServiceFunction(mi.pszService, QuotesMenu_OpenLogFile); - -#ifdef CHART_IMPLEMENT - SET_UID(mi, 0x65da7256, 0x43a2, 0x4857, 0xac, 0x52, 0x1c, 0xb7, 0xff, 0xd7, 0x96, 0xfa); - mi.name.w = LPGENW("Chart..."); - mi.hIcolibItem = nullptr; - mi.pszService = "Quotes/Chart"; - g_hMenuChart = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); - CreateServiceFunction(mi.pszService, QuotesMenu_Chart); -#endif - - SET_UID(mi, 0xac5fc17, 0x5640, 0x4f81, 0xa3, 0x44, 0x8c, 0xb6, 0x9a, 0x5c, 0x98, 0xf); - mi.name.w = LPGENW("Edit Settings..."); - mi.hIcolibItem = nullptr; - mi.pszService = "Quotes/EditSettings"; - g_hMenuEditSettings = Menu_AddContactMenuItem(&mi, QUOTES_PROTOCOL_NAME); -#ifdef CHART_IMPLEMENT - Menu_ConfigureItem(g_hMenuEditSettings, MCI_OPT_EXECPARAM, 3); -#else - Menu_ConfigureItem(g_hMenuEditSettings, MCI_OPT_EXECPARAM, 2); -#endif - CreateServiceFunction(mi.pszService, QuotesMenu_EditSettings); -} - -int Quotes_OnToolbarLoaded(WPARAM, LPARAM) -{ - TTBButton ttb = {}; - ttb.name = LPGEN("Enable/Disable Currency Rates Auto Update"); - ttb.pszService = g_pszAutoUpdateCmd; - ttb.pszTooltipUp = LPGEN("Currency Rates Auto Update Enabled"); - ttb.pszTooltipDn = LPGEN("Currency Rates Auto Update Disabled"); - ttb.hIconHandleUp = Quotes_GetIconHandle(IDI_ICON_MAIN); - ttb.hIconHandleDn = Quotes_GetIconHandle(IDI_ICON_DISABLED); - ttb.dwFlags = ((g_bAutoUpdate) ? 0 : TTBBF_PUSHED) | TTBBF_ASPUSHBUTTON | TTBBF_VISIBLE; - g_hTBButton = g_plugin.addTTB(&ttb); - - ttb.name = LPGEN("Currency Converter"); - ttb.pszService = g_pszCurrencyConverter; - ttb.pszTooltipUp = LPGEN("Currency Converter"); - ttb.pszTooltipDn = LPGEN("Currency Converter"); - ttb.hIconHandleUp = Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER); - ttb.hIconHandleDn = Quotes_GetIconHandle(IDI_ICON_CURRENCY_CONVERTER); - ttb.dwFlags = TTBBF_VISIBLE; - g_plugin.addTTB(&ttb); - - return 0; -} - -static void WorkingThread(void *pParam) -{ - IQuotesProvider *pProvider = reinterpret_cast(pParam); - assert(pProvider); - - if (pProvider) - pProvider->Run(); -} - -int QuotesEventFunc_OnModulesLoaded(WPARAM, LPARAM) -{ - CHTTPSession::Init(); - - g_hEventWorkThreadStop = ::CreateEvent(nullptr, TRUE, FALSE, nullptr); - HookEvent(ME_USERINFO_INITIALISE, QuotesEventFunc_OnUserInfoInit); - - HookEvent(ME_CLIST_DOUBLECLICKED, Quotes_OnContactDoubleClick); - - HookEvent(ME_TTB_MODULELOADED, Quotes_OnToolbarLoaded); - - g_bAutoUpdate = 1 == db_get_b(NULL, QUOTES_MODULE_NAME, DB_STR_AUTO_UPDATE, 1); - - InitMenu(); - - 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; - g_ahThreads.push_back(mir_forkthread(WorkingThread, pProvider.get())); - } - - return 0; -} - -int QuotesEventFunc_OnContactDeleted(WPARAM wParam, LPARAM) -{ - MCONTACT hContact = MCONTACT(wParam); - - const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr(); - CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact); - if (pProvider) - pProvider->DeleteContact(hContact); - return 0; -} - -INT_PTR QuoteProtoFunc_GetCaps(WPARAM wParam, LPARAM) -{ - switch (wParam) { - case PFLAG_UNIQUEIDTEXT: - return (INT_PTR)Translate("Currency Symbol"); - } - - return 0; -} - -INT_PTR QuoteProtoFunc_GetStatus(WPARAM, LPARAM) -{ - return g_bAutoUpdate ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; -} - -void WaitForWorkingThreads() -{ - size_t cThreads = g_ahThreads.size(); - if (cThreads > 0) { - HANDLE* paHandles = &*(g_ahThreads.begin()); - ::WaitForMultipleObjects((DWORD)cThreads, paHandles, TRUE, INFINITE); - } -} - - -int QuotesEventFunc_PreShutdown(WPARAM, LPARAM) -{ - ::SetEvent(g_hEventWorkThreadStop); - - CModuleInfo::GetInstance().OnMirandaShutdown(); - return 0; -} - -int QuotesEventFunc_OptInitialise(WPARAM wp, LPARAM/* lp*/) -{ - const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr(); - const CQuotesProviders::TQuotesProviders& rapProviders = pProviders->GetProviders(); - - OPTIONSDIALOGPAGE odp = {}; - odp.position = 910000000; - odp.szTitle.w = _T(QUOTES_PROTOCOL_NAME); - odp.szGroup.w = LPGENW("Network"); - odp.flags = ODPF_USERINFOTAB | ODPF_UNICODE; - - std::for_each(rapProviders.begin(), rapProviders.end(), boost::bind(&IQuotesProvider::ShowPropertyPage, _1, wp, boost::ref(odp))); - return 0; -} - -inline int Quotes_UnhookEvent(HANDLE h) -{ - return UnhookEvent(h); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -EXTERN_C __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST }; - -///////////////////////////////////////////////////////////////////////////////////////// - -PLUGININFOEX pluginInfoEx = -{ - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __DESCRIPTION, - __AUTHOR, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // {E882056D-0D1D-4131-9A98-404CBAEA6A9C} - { 0xe882056d, 0xd1d, 0x4131, { 0x9a, 0x98, 0x40, 0x4c, 0xba, 0xea, 0x6a, 0x9c } } -}; - -CMPlugin::CMPlugin() : - PLUGIN(QUOTES_PROTOCOL_NAME, pluginInfoEx) -{ - RegisterProtocol(PROTOTYPE_VIRTUAL); - SetUniqueId(DB_STR_QUOTE_SYMBOL); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int CMPlugin::Load(void) -{ - if (!CModuleInfo::Verify()) - return 1; - - Quotes_IconsInit(); - Quotes_InitExtraIcons(); - - CreateProtoServiceFunction(QUOTES_PROTOCOL_NAME, PS_GETCAPS, QuoteProtoFunc_GetCaps); - CreateProtoServiceFunction(QUOTES_PROTOCOL_NAME, PS_GETSTATUS, QuoteProtoFunc_GetStatus); - - HookEvent(ME_SYSTEM_MODULESLOADED, QuotesEventFunc_OnModulesLoaded); - HookEvent(ME_DB_CONTACT_DELETED, QuotesEventFunc_OnContactDeleted); - HookEvent(ME_SYSTEM_PRESHUTDOWN, QuotesEventFunc_PreShutdown); - HookEvent(ME_OPT_INITIALISE, QuotesEventFunc_OptInitialise); - - CreateServiceFunction(MS_QUOTES_EXPORT, Quotes_Export); - CreateServiceFunction(MS_QUOTES_IMPORT, Quotes_Import); - - return 0; -} - -///////////////////////////////////////////////////////////////////////////////////////// - -int CMPlugin::Unload(void) -{ - WaitForWorkingThreads(); - - ::CloseHandle(g_hEventWorkThreadStop); - return 0; -} diff --git a/plugins/Quotes/src/HTMLParserMS.cpp b/plugins/Quotes/src/HTMLParserMS.cpp deleted file mode 100644 index c2f8962063..0000000000 --- a/plugins/Quotes/src/HTMLParserMS.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include "StdAfx.h" - -using _com_util::CheckError; - -class CHTMLNode : public IHTMLNode -{ -public: - typedef CComPtr TComPtr; - typedef CComPtr TDocumentPtr; - -protected: - typedef CComPtr 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 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 pTable; - return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTable, reinterpret_cast(&pTable))) && (pTable)); - } - case TableRow: - { - CComPtr pRow; - return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTableRow, reinterpret_cast(&pRow))) && (pRow)); - } - case TableColumn: - { - CComPtr pCol; - return (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLTableCol, reinterpret_cast(&pCol))) && (pCol)); - } - } - - return false; - } - - virtual tstring GetAttribute(const tstring& rsAttrName)const - { - tstring sAttr; - CComPtr pElement; - if (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast(&pElement))) && pElement) { - _variant_t vAttribute; - BSTR pbstrAttrName = ::SysAllocString(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&) { - } - } - ::SysFreeString(pbstrAttrName); - } - - return sAttr; - } - - virtual tstring GetText()const - { - tstring sText; - CComPtr pElement; - if (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast(&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(&pColl)); - if (FAILED(hr)) { - CComPtr pElement; - if (SUCCEEDED(m_pElement->QueryInterface(IID_IHTMLElement, reinterpret_cast(&pElement))) && pElement) { - CComPtr pDisp; - if (SUCCEEDED(pElement->get_children(&pDisp)) && pDisp) - pDisp->QueryInterface(IID_IHTMLElementCollection, reinterpret_cast(&pColl)); - } - } - - return pColl; - } - -private: - TComPtr m_pElement; - TDocumentPtr m_pDocument; -}; - -CHTMLParserMS::CHTMLParserMS() : m_bCallUninit(false) -{ - try { - CheckError(::CoInitialize(nullptr)); - - m_bCallUninit = true; - - _com_util::CheckError( - ::CoCreateInstance(CLSID_HTMLDocument, - nullptr, - CLSCTX_INPROC_SERVER, - IID_IHTMLDocument2, - (LPVOID*)&m_pDoc) - ); - - CComPtr 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 (m_bCallUninit) - ::CoUninitialize(); -} - -CHTMLParserMS::THTMLNodePtr CHTMLParserMS::ParseString(const tstring& rsHTML) -{ - mir_cslock lck(m_cs); - - CComPtr pMC; - HRESULT hr = m_pMS->ParseString((OLECHAR*)rsHTML.c_str(), 0, &pMC, m_pMkStart, m_pMkFinish); - if (SUCCEEDED(hr) && pMC) { - CComPtr pNewDoc; - hr = pMC->QueryInterface(IID_IHTMLDocument, (LPVOID*)&pNewDoc); - if (SUCCEEDED(hr) && pNewDoc) { - CComPtr pColl; - pNewDoc->get_all(&pColl); - - CHTMLNode::TDocumentPtr pDoc; - pMC->QueryInterface(IID_IHTMLDocument3, (LPVOID*)&pDoc); - return THTMLNodePtr(new CHTMLNode(CHTMLNode::TComPtr(pColl), pDoc)); - } - } - - return THTMLNodePtr(); -} - -bool CHTMLParserMS::IsInstalled() -{ - bool bResult = true; - bool bCallUninit = false; - try { - CheckError(::CoInitialize(nullptr)); - - bCallUninit = true; - - CComPtr pDoc; - _com_util::CheckError( - ::CoCreateInstance(CLSID_HTMLDocument, - nullptr, - CLSCTX_INPROC_SERVER, - IID_IHTMLDocument2, - reinterpret_cast(&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 deleted file mode 100644 index ac01ac2d32..0000000000 --- a/plugins/Quotes/src/HTMLParserMS.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef __3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__ -#define __3c99e3f7_ecd9_4d9b_8f86_fe293c5fc8e6_HTMLParserMS_h__ - -class CHTMLParserMS : public IHTMLParser -{ -public: - CHTMLParserMS(); - ~CHTMLParserMS(); - - virtual THTMLNodePtr ParseString(const tstring& rsHTML); - - static bool IsInstalled(); - -private: - bool m_bCallUninit; - CComPtr m_pDoc; - CComPtr m_pMS; - CComPtr m_pMkStart; - CComPtr m_pMkFinish; - mutable mir_cs 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 deleted file mode 100644 index 0dbfac3441..0000000000 --- a/plugins/Quotes/src/HTTPSession.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "StdAfx.h" - -class CHTTPSession::CImpl -{ -public: - CImpl() {} - virtual ~CImpl() {} - - virtual bool OpenURL(const tstring& rsURL) = 0; - virtual bool ReadResponce(tstring& rsResponce)const = 0; -}; - -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(nullptr == g_hNetLib); - - NETLIBUSER nlu = {}; - nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE; - nlu.szSettingsModule = QUOTES_PROTOCOL_NAME; - nlu.szDescriptiveName.w = TranslateT("Quotes HTTP connections"); - g_hNetLib = Netlib_RegisterUser(&nlu); - return (nullptr != g_hNetLib); - } - - static bool IsValid() { return nullptr != g_hNetLib; } - - virtual bool OpenURL(const tstring& rsURL) - { - m_aURL.clear(); - - std::string s = quotes_t2a(rsURL.c_str()); - const char* psz = s.c_str(); - m_aURL.insert(m_aURL.begin(), psz, psz + mir_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 = NETLIB_USER_AGENT; - 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 = nullptr; - { - mir_cslock lck(m_mx); - pReply = Netlib_HttpTransaction(g_hNetLib, &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) && (nullptr != strstr(_strlwr(pReply->headers[nIndex].szValue), "utf-8"))) { - wchar_t* p = mir_utf8decodeW(pResult); - rsResponce = p; - mir_free(p); - } - else { - // USES_CONVERSION; - // LPCTSTR p = A2CT(pResult); - rsResponce = quotes_a2t(pResult);//p; - } - - bResult = true; - } - - Netlib_FreeHttpRequest(pReply); - } - - mir_free(nlhr.headers); - - return bResult; - } - -private: - static HNETLIBUSER g_hNetLib; - typedef std::vector TBuffer; - mutable TBuffer m_aURL; - mutable mir_cs m_mx; -}; - -HNETLIBUSER CImplMI::g_hNetLib = nullptr; - -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 deleted file mode 100644 index a37e109a43..0000000000 --- a/plugins/Quotes/src/HTTPSession.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __8C9706FF_6B05_4d0d_85B8_5724E5DC0BA4_HTTPSession_h__ -#define __8C9706FF_6B05_4d0d_85B8_5724E5DC0BA4_HTTPSession_h__ - -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 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 deleted file mode 100644 index 7df3074d3e..0000000000 --- a/plugins/Quotes/src/IHTMLEngine.h +++ /dev/null @@ -1,18 +0,0 @@ -#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 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 deleted file mode 100644 index 6fc00e30c1..0000000000 --- a/plugins/Quotes/src/IHTMLParser.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __98ad6d6d_2a27_43fd_bf3e_c18416a45e54_IHTMLParser_h__ -#define __98ad6d6d_2a27_43fd_bf3e_c18416a45e54_IHTMLParser_h__ - -class IHTMLNode -{ -public: - typedef boost::shared_ptr 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 deleted file mode 100644 index 2875904dcf..0000000000 --- a/plugins/Quotes/src/IQuotesProvider.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#ifndef __ac71e133_786c_41a7_ab07_625b76ff2a8c_QuotesProvider_h__ -#define __ac71e133_786c_41a7_ab07_625b76ff2a8c_QuotesProvider_h__ - -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(MCONTACT hContact) = 0; - virtual void DeleteContact(MCONTACT hContact) = 0; - - virtual void ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp) = 0; - virtual void RefreshAllContacts() = 0; - virtual void RefreshSettings() = 0; - virtual void RefreshContact(MCONTACT hContact) = 0; - // virtual void SetContactExtraIcon(MCONTACT 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 deleted file mode 100644 index 7130f0e380..0000000000 --- a/plugins/Quotes/src/IXMLEngine.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __f88e20d7_5e65_40fb_a7b5_7c7af1ee1c78_IXMLEngine_h__ -#define __f88e20d7_5e65_40fb_a7b5_7c7af1ee1c78_IXMLEngine_h__ - -class IXMLNode -{ -public: - typedef boost::shared_ptr 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 deleted file mode 100644 index d649d4bad3..0000000000 --- a/plugins/Quotes/src/IconLib.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "StdAfx.h" - -static IconItem iconList[] = -{ - { LPGEN("Protocol icon"), ICON_STR_MAIN, IDI_ICON_MAIN }, - { LPGEN("Auto Update Disabled"), "auto_update_disabled", IDI_ICON_DISABLED }, - { LPGEN("Quote/Rate up"), "quote_up", IDI_ICON_UP }, - { LPGEN("Quote/Rate down"), "quote_down", IDI_ICON_DOWN }, - { LPGEN("Quote/Rate not changed"), "quote_not_changed", IDI_ICON_NOTCHANGED }, - { LPGEN("Quote Section"), "quote_section", IDI_ICON_SECTION }, - { LPGEN("Quote"), ICON_STR_QUOTE, IDI_ICON_QUOTE }, - { LPGEN("Currency Converter"), "currency_converter", IDI_ICON_CURRENCY_CONVERTER }, - { LPGEN("Refresh"), "refresh", IDI_ICON_REFRESH }, - { LPGEN("Export"), "export", IDI_ICON_EXPORT }, - { LPGEN("Swap button"), "swap", IDI_ICON_SWAP }, - { LPGEN("Import"), "import", IDI_ICON_IMPORT } -}; - -void Quotes_IconsInit() -{ - ::g_plugin.registerIcon(QUOTES_PROTOCOL_NAME, iconList, QUOTES_PROTOCOL_NAME); -} - -HICON Quotes_LoadIconEx(int iconId, bool bBig /*= false*/) -{ - for (int i = 0; i < _countof(iconList); i++) - if (iconList[i].defIconID == iconId) - return IcoLib_GetIconByHandle(iconList[i].hIcolib, bBig); - - return nullptr; -} - -HANDLE Quotes_GetIconHandle(int iconId) -{ - for (int i = 0; i < _countof(iconList); i++) - if (iconList[i].defIconID == iconId) - return iconList[i].hIcolib; - - return nullptr; -} diff --git a/plugins/Quotes/src/IconLib.h b/plugins/Quotes/src/IconLib.h deleted file mode 100644 index 9979c8a56d..0000000000 --- a/plugins/Quotes/src/IconLib.h +++ /dev/null @@ -1,11 +0,0 @@ -#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 "quote" - -void Quotes_IconsInit(); -HICON Quotes_LoadIconEx(int iconId, bool bBig = false); -HANDLE Quotes_GetIconHandle(int iconId); - -#endif //__8821d334_afac_439e_9a81_76318e1ac4ef_IconLib_h__ diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp deleted file mode 100644 index c3d5cada0b..0000000000 --- a/plugins/Quotes/src/ImportExport.cpp +++ /dev/null @@ -1,635 +0,0 @@ -#include "StdAfx.h" -#include "QuotesProviderCurrencyConverter.h" - -LPCTSTR g_pszXmlValue = L"Value"; -LPCTSTR g_pszXmlName = L"Name"; -LPCTSTR g_pszXmlSetting = L"Setting"; -LPCTSTR g_pszXmlModule = L"Module"; -LPCTSTR g_pszXmlContact = L"Contact"; -LPCTSTR g_pszXmlContacts = L"Contacts"; -LPCTSTR g_pszXmlType = L"type"; -LPCTSTR g_pszXmlTypeByte = L"byte"; -LPCTSTR g_pszXmlTypeWord = L"word"; -LPCTSTR g_pszXmlTypeDword = L"dword"; -LPCTSTR g_pszXmlTypeAsciiz = L"asciiz"; -LPCTSTR g_pszXmlTypeWchar = L"wchar"; -LPCTSTR g_pszXmlTypeUtf8 = L"utf8"; -LPCTSTR g_pszXmlTypeBlob = L"blob"; - -struct CEnumContext -{ - CModuleInfo::TXMLEnginePtr m_pXmlEngine; - IXMLNode::TXMLNodePtr m_pNode; - MCONTACT m_hContact; - LPCSTR m_pszModule; -}; - -struct mir_safety_dbvar -{ - mir_safety_dbvar(DBVARIANT* p) : m_p(p) {} - ~mir_safety_dbvar() { db_free(m_p); } - DBVARIANT* m_p; -}; - -static int enum_contact_settings(const char* szSetting, void *lp) -{ - CEnumContext* ctx = reinterpret_cast(lp); - - DBVARIANT dbv; - if (0 == db_get(ctx->m_hContact, ctx->m_pszModule, szSetting, &dbv)) { - 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; - break; - case DBVT_WCHAR: - sType = g_pszXmlTypeWchar; - if (dbv.pwszVal) - sValue << dbv.pwszVal; - break; - case DBVT_UTF8: - sType = g_pszXmlTypeUtf8; - if (dbv.pszVal) - sValue << dbv.pszVal; - break; - case DBVT_BLOB: - sType = g_pszXmlTypeBlob; - if (dbv.pbVal) { - ptrA buf(mir_base64_encode(dbv.pbVal, dbv.cpbVal)); - if (buf) - sValue << buf; - } - break; - } - - 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, void *lp) -{ - CEnumContext *ctx = (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; - db_enum_settings(ctx->m_hContact, &enum_contact_settings, szModuleName, ctx); - - if (pModule->GetChildCount() > 0) - pXml->AddChild(pModule); - - ctx->m_pNode = pXml; - } - - return 0; -} - -IXMLNode::TXMLNodePtr export_contact(MCONTACT 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; - - db_enum_modules(EnumDbModules, &ctx); - } - return pNode; -} - -LPCTSTR prepare_filter(LPTSTR pszBuffer, size_t cBuffer) -{ - LPTSTR p = pszBuffer; - LPCTSTR pszXml = TranslateT("XML File (*.xml)"); - mir_wstrncpy(p, pszXml, (int)cBuffer); - size_t nLen = mir_wstrlen(pszXml) + 1; - p += nLen; - if (nLen < cBuffer) { - mir_wstrncpy(p, L"*.xml", (int)(cBuffer - nLen)); - p += 6; - nLen += 6; - } - - if (nLen < cBuffer) { - LPCTSTR pszAll = TranslateT("All files (*.*)"); - mir_wstrncpy(p, pszAll, (int)(cBuffer - nLen)); - size_t n = mir_wstrlen(pszAll) + 1; - nLen += n; - p += n; - } - - if (nLen < cBuffer) { - mir_wstrncpy(p, L"*.*", (int)(cBuffer - nLen)); - p += 4; - nLen += 4; - } - - if (nLen < cBuffer) - *p = '\0'; - - return pszBuffer; -} - -bool show_open_file_dialog(bool bOpen, tstring& rsFile) -{ - wchar_t szBuffer[MAX_PATH]; - wchar_t szFilter[MAX_PATH]; - OPENFILENAME ofn; - memset(&ofn, 0, sizeof(ofn)); - - ofn.lStructSize = sizeof(OPENFILENAME); - - ofn.hwndOwner = nullptr; - ofn.lpstrFilter = prepare_filter(szFilter, MAX_PATH); - ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER; - ofn.lpstrDefExt = L"xml"; - if (bOpen) - ofn.Flags |= OFN_FILEMUSTEXIST; - else - ofn.Flags |= OFN_OVERWRITEPROMPT; - - ofn.nMaxFile = MAX_PATH; - ofn.lpstrFile = szBuffer; - ofn.lpstrFile[0] = '\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) -{ - tstring sFileName; - const char* pszFile = reinterpret_cast(lp); - if (nullptr == 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()); - MCONTACT hContact = MCONTACT(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 (auto &cc : Contacts(QUOTES_MODULE_NAME)) { - CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(cc); - if (pProvider) { - IXMLNode::TXMLNodePtr pNode = export_contact(cc, pXmlEngine); - if (pNode) - pRoot->AddChild(pNode); - } - } - } - - return ((true == pXmlEngine->SaveFile(sFileName, pRoot)) ? 0 : 1); -} - -bool set_contact_settings(MCONTACT hContact, DBCONTACTWRITESETTING& dbs) -{ - assert(DBVT_DELETED != dbs.value.type); - return (0 == db_set(hContact, dbs.szModule, dbs.szSetting, &dbs.value)); -} - -bool handle_module(MCONTACT hContact, const IXMLNode::TXMLNodePtr& pXmlModule) -{ - 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 == mir_wstrcmpi(sModuleName.c_str(), L"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 == mir_wstrcmpi(g_pszXmlSetting, sSetting.c_str())) { - size_t cSetChild = pSetting->GetChildCount(); - if (cSetChild >= 2) { - tstring sName; - tstring sValue; - tstring sType; - for (size_t j = 0; j < cSetChild; ++j) { - IXMLNode::TXMLNodePtr pNode = pSetting->GetChildNode(j); - tstring sNode = pNode->GetName(); - if (0 == mir_wstrcmpi(g_pszXmlName, sNode.c_str())) { - sName = pNode->GetText(); - } - else if (0 == mir_wstrcmpi(g_pszXmlValue, sNode.c_str())) { - sValue = pNode->GetText(); - sType = pNode->GetAttributeValue(g_pszXmlType); - } - } - - if ((false == sName.empty()) && (false == sType.empty())) { - std::string s1 = quotes_t2a(sName.c_str()); - dbs.szSetting = s1.c_str(); - if (0 == mir_wstrcmpi(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 == mir_wstrcmpi(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 == mir_wstrcmpi(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 == mir_wstrcmpi(g_pszXmlTypeAsciiz, sType.c_str())) { - ptrA v(mir_u2a(sValue.c_str())); - dbs.value.pszVal = v; - dbs.value.type = DBVT_ASCIIZ; - if (set_contact_settings(hContact, dbs)) - ++cCreatedRecords; - } - else if (0 == mir_wstrcmpi(g_pszXmlTypeUtf8, sType.c_str())) { - T2Utf szValue(sValue.c_str()); - dbs.value.pszVal = szValue; - dbs.value.type = DBVT_UTF8; - if (set_contact_settings(hContact, dbs)) - ++cCreatedRecords; - } - else if (0 == mir_wstrcmpi(g_pszXmlTypeWchar, sType.c_str())) { - ptrW val(mir_wstrdup(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 == mir_wstrcmpi(g_pszXmlTypeBlob, sType.c_str())) { - size_t bufLen; - mir_ptr buf((PBYTE)mir_base64_decode(_T2A(sValue.c_str()), &bufLen)); - if (buf) { - dbs.value.pbVal = buf; - dbs.value.cpbVal = (WORD)bufLen; - dbs.value.type = DBVT_BLOB; - - if (set_contact_settings(hContact, dbs)) - ++cCreatedRecords; - } - } - - if ((true == bCListModule) && (0 == mir_wstrcmpi(sName.c_str(), L"Group"))) - Clist_GroupCreate(NULL, 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 == mir_wstrcmpi(g_pszXmlContacts, sName.c_str())) - cContacts += count_contacts(pNode, true); - else - cContacts += count_contacts(pNode, false); - } - else { - if (0 == mir_wstrcmpi(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) {} - MCONTACT m_hContact; - CQuotesProviders::TQuotesProviderPtr m_pProvider; - bool m_bNewContact; -}; - -IXMLNode::TXMLNodePtr find_quotes_module(const IXMLNode::TXMLNodePtr& pXmlContact) -{ - 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 == mir_wstrcmpi(g_pszXmlModule, sName.c_str())) - && (0 == mir_wstrcmpi(g_sQuotes.c_str(), pNode->GetText().c_str()))) { - return pNode; - } - } - - return IXMLNode::TXMLNodePtr(); -} - -typedef std::pair 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 == mir_wstrcmpi(g_pszXmlName, pXMLSetChild->GetName().c_str())) { - sName = pXMLSetChild->GetText(); - } - else if (0 == mir_wstrcmpi(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 == mir_wstrcmpi(g_pszXmlSetting, pXMLSetting->GetName().c_str()))) { - TNameValue Item = parse_setting_node(pXMLSetting); - if ((0 == mir_wstrcmpi(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) - { - } - - MCONTACT GetContact()const { return m_hContact; } - - private: - virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override - { - 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 == mir_wstrcmpi(g_pszXmlSetting, pNode->GetName().c_str()))) { - TNameValue Item = parse_setting_node(pNode); - if (0 == mir_wstrcmpi(g_sFromID.c_str(), Item.first.c_str())) { - sFromID = Item.second; - } - else if (0 == mir_wstrcmpi(g_sToID.c_str(), Item.first.c_str())) { - sToID = Item.second; - } - } - } - - if ((false == sFromID.empty()) && (false == sToID.empty())) { - m_hContact = rProvider.GetContactByID(sFromID, sToID); - } - } - - tstring GetXMLNodeValue(const char* pszXMLNodeName)const - { - tstring sXMLNodeName = quotes_a2t(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 == mir_wstrcmpi(g_pszXmlSetting, pNode->GetName().c_str()))) { - TNameValue Item = parse_setting_node(pNode); - if (0 == mir_wstrcmpi(Item.first.c_str(), sXMLNodeName.c_str())) { - sValue = Item.second; - break; - } - } - } - - return sValue; - } - - private: - MCONTACT 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 = db_add_contact(); - cst.m_bNewContact = true; - } - else if (impctx.m_nFlags & QUOTES_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 == mir_wstrcmpi(g_pszXmlModule, sName.c_str())) - bResult &= handle_module(cst.m_hContact, pNode); - } - - 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 == mir_wstrcmpi(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 == mir_wstrcmpi(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(lp); - if (nullptr == 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; -} - -INT_PTR QuotesMenu_ImportAll(WPARAM, LPARAM) -{ - return CallService(MS_QUOTES_IMPORT, 0, 0); -} - -INT_PTR QuotesMenu_ExportAll(WPARAM, LPARAM) -{ - return CallService(MS_QUOTES_EXPORT, 0, 0); -} diff --git a/plugins/Quotes/src/ImportExport.h b/plugins/Quotes/src/ImportExport.h deleted file mode 100644 index 1d4043210a..0000000000 --- a/plugins/Quotes/src/ImportExport.h +++ /dev/null @@ -1,9 +0,0 @@ -#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); - -INT_PTR QuotesMenu_ImportAll(WPARAM wp, LPARAM lp); -INT_PTR QuotesMenu_ExportAll(WPARAM wp, LPARAM lp); -#endif //__F86374E6_713C_4600_85FB_903A5CDF7251_IMPORT_EXPORT_H__ diff --git a/plugins/Quotes/src/IsWithinAccuracy.h b/plugins/Quotes/src/IsWithinAccuracy.h deleted file mode 100644 index 2430cd8675..0000000000 --- a/plugins/Quotes/src/IsWithinAccuracy.h +++ /dev/null @@ -1,15 +0,0 @@ -#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/Locale.cpp b/plugins/Quotes/src/Locale.cpp deleted file mode 100644 index 43493fb127..0000000000 --- a/plugins/Quotes/src/Locale.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "StdAfx.h" - -const std::locale GetSystemLocale() -{ - return std::locale(""); -} - -tstring get_int_registry_value(LPCTSTR pszValueName) -{ - tstring sResult; - HKEY hKey = nullptr; - LONG lResult = ::RegOpenKeyEx(HKEY_CURRENT_USER, - L"Control Panel\\International", 0, KEY_QUERY_VALUE, &hKey); - if ((ERROR_SUCCESS == lResult) && (nullptr != 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 aBuffer(dwSize); - lResult = ::RegQueryValueEx(hKey, pszValueName, nullptr, nullptr, reinterpret_cast(&*aBuffer.begin()), &dwSize); - if (ERROR_SUCCESS == lResult) - std::copy(aBuffer.begin(), aBuffer.end(), std::back_inserter(sResult)); - } - } - - if (nullptr != hKey) { - lResult = ::RegCloseKey(hKey); - assert(ERROR_SUCCESS == lResult); - } - - return sResult; -} - -LPCTSTR date_win_2_boost(const tstring& sFrmt) -{ - if (sFrmt == L"dd/MM/yy") - return L"%d/%m/%y"; - if (sFrmt == L"yyyy-MM-dd") - return L"%y-%m-%d"; - return L"%d.%m.%y"; -} - -LPCTSTR time_win_2_boost(const tstring& sFrmt) -{ - if (sFrmt == L"H:mm" || sFrmt == L"HH:mm") - return L"%H:%M"; - - return L"%H:%M:%S"; -} - -LPCTSTR Quotes_GetDateFormat(bool bShort) -{ - return date_win_2_boost(get_int_registry_value(bShort ? L"sShortDate" : L"sLongDate")); -} - -LPCTSTR Quotes_GetTimeFormat(bool bShort) -{ - return time_win_2_boost(get_int_registry_value(bShort ? L"sShortTime" : L"sTimeFormat")); -} diff --git a/plugins/Quotes/src/Locale.h b/plugins/Quotes/src/Locale.h deleted file mode 100644 index 05288c146f..0000000000 --- a/plugins/Quotes/src/Locale.h +++ /dev/null @@ -1,9 +0,0 @@ -#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(); -LPCTSTR Quotes_GetDateFormat(bool bShort); -LPCTSTR 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 deleted file mode 100644 index f3a038d2a7..0000000000 --- a/plugins/Quotes/src/Log.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "StdAfx.h" - -namespace -{ - mir_cs g_Mutex; - - tstring get_log_file_name() - { - return CreateFilePath(L"Quotes.log"); - } - - bool is_log_enabled() - { -#ifdef _DEBUG - return true; -#else - return (1 == db_get_b(NULL, QUOTES_PROTOCOL_NAME, DB_STR_ENABLE_LOG, false)); -#endif - } - - void do_log(const tstring& rsFileName, const tstring& rsMsg) - { - mir_cslock lck(g_Mutex); - tofstream file(rsFileName.c_str(), std::ios::ate | std::ios::app); - if (file.good()) - { - wchar_t szTime[20]; - _tstrtime_s(szTime); - file << szTime << L" ================================>\n" << rsMsg << L"\n\n"; - } - } -} - -void LogIt(const tstring& rsMsg) -{ - if (is_log_enabled()) - { - tstring sFileName = get_log_file_name(); - do_log(sFileName, rsMsg); - } -} diff --git a/plugins/Quotes/src/Log.h b/plugins/Quotes/src/Log.h deleted file mode 100644 index 00d1cc76e3..0000000000 --- a/plugins/Quotes/src/Log.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __653719be_16d6_4058_8555_8aa7d5404214_OutputDlg_h__ -#define __653719be_16d6_4058_8555_8aa7d5404214_OutputDlg_h__ - -enum ESeverity -{ - Info, - Warning, - Error -}; - -void LogIt(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 deleted file mode 100644 index 7a72063270..0000000000 --- a/plugins/Quotes/src/ModuleInfo.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "StdAfx.h" - -static CModuleInfo::TXMLEnginePtr g_pXMLEngine; -static CModuleInfo::THTMLEnginePtr g_pHTMLEngine; -static mir_cs g_lmParsers; - -CModuleInfo::CModuleInfo() -{ -} - -CModuleInfo::~CModuleInfo() -{ -} - -CModuleInfo& CModuleInfo::GetInstance() -{ - static CModuleInfo mi; - return mi; -} - -MWindowList CModuleInfo::GetWindowList(const std::string& rsKey, bool bAllocateIfNonExist /*= true*/) -{ - MWindowList hResult = nullptr; - THandles::const_iterator i = m_ahWindowLists.find(rsKey); - if (i != m_ahWindowLists.end()) { - hResult = i->second; - } - else if (bAllocateIfNonExist) { - hResult = WindowList_Create(); - 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) { - mir_cslock lck(g_lmParsers); - if (!g_pXMLEngine) - g_pXMLEngine = TXMLEnginePtr(new CXMLEngineMI); - } - - return g_pXMLEngine; -} - -CModuleInfo::THTMLEnginePtr CModuleInfo::GetHTMLEngine() -{ - if (!g_pHTMLEngine) { - mir_cslock lck(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(nullptr, 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(nullptr, - TranslateT("Miranda could not load Quotes plugin. Microsoft HTML parser is missing."), - MB_YESNO | MB_ICONQUESTION); - return false; - } - - return true; -} \ No newline at end of file diff --git a/plugins/Quotes/src/ModuleInfo.h b/plugins/Quotes/src/ModuleInfo.h deleted file mode 100644 index 6f33844c83..0000000000 --- a/plugins/Quotes/src/ModuleInfo.h +++ /dev/null @@ -1,41 +0,0 @@ -#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 TQuotesProvidersPtr; - typedef boost::shared_ptr TXMLEnginePtr; - typedef boost::shared_ptr THTMLEnginePtr; - -private: - CModuleInfo(); - ~CModuleInfo(void); - -public: - static CModuleInfo& GetInstance(); - - void OnMirandaShutdown(); - MWindowList GetWindowList(const std::string& rsKey, bool bAllocateIfNonExist = true); - - 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 THandles; - THandles m_ahWindowLists; -}; - -#endif //__d0f22b66_3135_4bbe_bee5_a31ea631ce58_ModuleInfo__ diff --git a/plugins/Quotes/src/QuoteChart.cpp b/plugins/Quotes/src/QuoteChart.cpp deleted file mode 100644 index 16c6bfc1da..0000000000 --- a/plugins/Quotes/src/QuoteChart.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "StdAfx.h" - -#ifdef CHART_IMPLEMENT - -namespace -{ - class CMyJob : private boost::noncopyable - { - private: - CMyJob(LPCTSTR pszName = nullptr): m_hJob(::CreateJobObject(nullptr,pszName)) - { - if(m_hJob) - { - JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 }; - jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; - if(0 == ::SetInformationJobObject(m_hJob,JobObjectExtendedLimitInformation,&jeli,sizeof(jeli))) - { -#ifdef OUTPUT_TO_DEBUG_VIEWER - ::OutputDebugString(_T("Error occurred during the job initialization\n")); -#endif - } - } - - } - ~CMyJob() - { - if(m_hJob) - { - ::CloseHandle(m_hJob); - } - } - - public: - static CMyJob& GetInstance() - { - static CMyJob g_job(_T("MirandaJob_E12D5E9C_00E7_4FFA_9831_F35E45C6EBDA")); - return g_job; - } - - bool AssignProcess(HANDLE hProcess) - { - if(m_hJob && hProcess) - { - auto b = (TRUE == ::AssignProcessToJobObject(m_hJob,hProcess)); - return b; - } - - return false; - } - - private: - HANDLE m_hJob; - }; - -} - -INT_PTR QuotesMenu_Chart(WPARAM wp, LPARAM /*lp*/) -{ -#ifdef _UNICODE - MCONTACT hContact = static_cast(wp); - if (NULL == hContact) - return 0; - - auto sLogFileName = GetContactLogFileName(hContact); - - if(auto hWnd = ::FindWindow(nullptr,_T("Miranda Quotes Chart"))) - { - COPYDATASTRUCT copydata_struct; - copydata_struct.cbData = static_cast(sLogFileName.size()*sizeof(TCHAR)); - copydata_struct.lpData = const_cast(static_cast(sLogFileName.c_str())); - copydata_struct.dwData = 0x1945; - - SendMessage(hWnd,WM_COPYDATA,0,reinterpret_cast(©data_struct)); - } - else - { - STARTUPINFO si; - PROCESS_INFORMATION pi; - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - si.dwFlags = STARTF_USESHOWWINDOW; - si.wShowWindow = SW_SHOWNORMAL; - ZeroMemory(&pi, sizeof(pi)); - - auto sCmdLine = CreateFilePath(_T("QuotesChart.exe")); - sCmdLine += _T(" \""); - sCmdLine += sLogFileName; - sCmdLine += _T("\""); - if(::CreateProcess(nullptr,const_cast(sCmdLine.c_str()),nullptr,nullptr,FALSE,0,nullptr,nullptr,&si,&pi)) - { - CMyJob::GetInstance().AssignProcess(pi.hProcess); - - ::CloseHandle(pi.hThread); - ::CloseHandle(pi.hProcess); - } - } -#endif - return 0; -} - -#endif //CHART_IMPLEMENT diff --git a/plugins/Quotes/src/QuoteChart.h b/plugins/Quotes/src/QuoteChart.h deleted file mode 100644 index baaf6826b8..0000000000 --- a/plugins/Quotes/src/QuoteChart.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef __39BE8775_A837_494f_925C_0ABF7910F238_QuoteChart_h__ -#define __39BE8775_A837_494f_925C_0ABF7910F238_QuoteChart_h__ - -#pragma once - -#ifdef CHART_IMPLEMENT - -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 deleted file mode 100644 index 4e454fd7f9..0000000000 --- a/plugins/Quotes/src/QuoteInfoDlg.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#include "StdAfx.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, g_hMenuRoot; - -#define WINDOW_PREFIX_INFO "Quote Info" - -MCONTACT g_hContact; - -inline bool IsMyContact(MCONTACT hContact) -{ - CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact); - return (nullptr != pProvider); -} - -inline MCONTACT get_contact(HWND hWnd) -{ - return MCONTACT(GetWindowLongPtr(hWnd, GWLP_USERDATA)); -} - -static bool get_fetch_time(time_t& rTime, MCONTACT hContact) -{ - rTime = db_get_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FETCH_TIME, -1); - return (rTime != -1); -} - -INT_PTR CALLBACK QuoteInfoDlgProcImpl(MCONTACT 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)) { - wchar_t szTime[50] = { 0 }; - if (0 == _tctime_s(szTime, 50, &nFetchTime)) { - ::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") << L" " << pi.m_sName << L""; - - ::SetDlgItemText(hdlg, IDC_SYSLINK_PROVIDER, o.str().c_str()); - } - return TRUE; - - case WM_NOTIFY: - LPNMHDR pNMHDR = reinterpret_cast(lParam); - switch (pNMHDR->code) { - case NM_CLICK: - if (IDC_SYSLINK_PROVIDER == wParam) { - PNMLINK pNMLink = reinterpret_cast(pNMHDR); - ::ShellExecute(hdlg, L"open", pNMLink->item.szUrl, nullptr, nullptr, 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) -{ - MCONTACT hContact = MCONTACT(lp); - if (NULL == hContact) - return 0; - - if (false == IsMyContact(hContact)) - return 0; - - g_hContact = hContact; - - OPTIONSDIALOGPAGE odp = {}; - odp.pfnDlgProc = QuoteInfoDlgProc; - odp.position = -2000000000; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_QUOTE_INFO); - odp.szTitle.a = LPGEN("Quote"); - g_plugin.addUserInfo(wp, &odp); - return 0; -} - - -INT_PTR QuotesMenu_EditSettings(WPARAM wp, LPARAM) -{ - MCONTACT hContact = MCONTACT(wp); - if (NULL != hContact) - ShowSettingsDlg(hContact); - return 0; -} - -namespace -{ - bool get_log_file(MCONTACT hContact, tstring& rsLogfile) - { - rsLogfile = GetContactLogFileName(hContact); - return ((rsLogfile.empty()) ? false : true); - } -} - -INT_PTR QuotesMenu_OpenLogFile(WPARAM wp, LPARAM) -{ - MCONTACT hContact = MCONTACT(wp); - if (NULL == hContact) - return 0; - - tstring sLogFileName; - if ((true == get_log_file(hContact, sLogFileName)) && (false == sLogFileName.empty())) - ::ShellExecute(nullptr, L"open", sLogFileName.c_str(), nullptr, nullptr, SW_SHOWNORMAL); - - return 0; -} - -INT_PTR QuotesMenu_RefreshContact(WPARAM wp, LPARAM) -{ - MCONTACT hContact = MCONTACT(wp); - if (NULL == hContact) - return 0; - - CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact); - if (!pProvider) - return 0; - - pProvider->RefreshContact(hContact); - return 0; -} - -static INT_PTR CALLBACK QuoteInfoDlgProc1(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - MCONTACT hContact = NULL; - MWindowList hWL; - - switch (msg) { - case WM_INITDIALOG: - hContact = MCONTACT(lParam); - hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, false); - assert(hWL); - WindowList_Add(hWL, hdlg, hContact); - - ::SetWindowLongPtr(hdlg, GWLP_USERDATA, 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: - hContact = get_contact(hdlg); - if (hContact) { - SetWindowLongPtr(hdlg, GWLP_USERDATA, 0); - - 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*/) -{ - MCONTACT hContact = MCONTACT(wp); - if (CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact)) { - MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, true); - assert(hWL); - HWND hWnd = WindowList_Find(hWL, hContact); - if (nullptr != hWnd) { - SetForegroundWindow(hWnd); - SetFocus(hWnd); - } - else if (true == IsMyContact(hContact)) - CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DIALOG_QUOTE_INFO_1), nullptr, QuoteInfoDlgProc1, LPARAM(hContact)); - - return 1; - } - - return 0; -} - -int Quotes_PrebuildContactMenu(WPARAM wp, LPARAM) -{ - Menu_EnableItem(g_hMenuEditSettings, false); - Menu_EnableItem(g_hMenuOpenLogFile, false); - #ifdef CHART_IMPLEMENT - Menu_EnableItem(g_hMenuChart, false); - #endif - Menu_EnableItem(g_hMenuRefresh, false); - - MCONTACT hContact = MCONTACT(wp); - char *szProto = GetContactProto(hContact); - if (mir_strcmp(szProto, QUOTES_MODULE_NAME)) { - Menu_ShowItem(g_hMenuRoot, false); - return 0; - } - - Menu_ShowItem(g_hMenuRoot, true); - Menu_EnableItem(g_hMenuEditSettings, true); - - Menu_EnableItem(g_hMenuRefresh, true); - - tstring sLogFileName; - bool bThereIsLogFile = (true == get_log_file(hContact, sLogFileName)) - && (false == sLogFileName.empty()) && (0 == _waccess(sLogFileName.c_str(), 04)); - if (true == bThereIsLogFile) { - #ifdef CHART_IMPLEMENT - Menu_EnableItem(g_hMenuChart, true); - #endif - Menu_EnableItem(g_hMenuOpenLogFile, true); - } - - return 0; -} diff --git a/plugins/Quotes/src/QuoteInfoDlg.h b/plugins/Quotes/src/QuoteInfoDlg.h deleted file mode 100644 index c650123e02..0000000000 --- a/plugins/Quotes/src/QuoteInfoDlg.h +++ /dev/null @@ -1,11 +0,0 @@ -#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 deleted file mode 100644 index 9acd7c06f0..0000000000 --- a/plugins/Quotes/src/QuotesProviderBase.cpp +++ /dev/null @@ -1,883 +0,0 @@ -#include "StdAfx.h" - -extern bool g_bAutoUpdate; -extern HANDLE g_hEventWorkThreadStop; - -struct CQuotesProviderBase::CXMLFileInfo -{ - CXMLFileInfo() : m_qs(L"Unknown") {} - IQuotesProvider::CProviderInfo m_pi; - CQuotesProviderBase::CQuoteSection m_qs; - tstring m_sURL; -}; - -inline tstring get_ini_file_name(LPCTSTR pszFileName) -{ - return CreateFilePath(pszFileName); -} - -bool parse_quote(const IXMLNode::TXMLNodePtr& pTop, CQuotesProviderBase::CQuote& q) -{ - tstring sSymbol; - tstring sDescription; - tstring sID; - - size_t cChild = pTop->GetChildCount(); - for (size_t i = 0; i < cChild; ++i) { - IXMLNode::TXMLNodePtr pNode = pTop->GetChildNode(i); - tstring sName = pNode->GetName(); - if (0 == mir_wstrcmpi(L"symbol", sName.c_str())) { - sSymbol = pNode->GetText(); - if (true == sSymbol.empty()) - return false; - } - else if (0 == mir_wstrcmpi(L"description", sName.c_str())) { - sDescription = pNode->GetText(); - } - else if (0 == mir_wstrcmpi(L"id", sName.c_str())) { - sID = pNode->GetText(); - if (true == sID.empty()) - return false; - } - } - - q = CQuotesProviderBase::CQuote(sID, TranslateW(sSymbol.c_str()), TranslateW(sDescription.c_str())); - return true; -} - -bool parse_section(const IXMLNode::TXMLNodePtr& pTop, CQuotesProviderBase::CQuoteSection& qs) -{ - CQuotesProviderBase::CQuoteSection::TSections aSections; - CQuotesProviderBase::CQuoteSection::TQuotes aQuotes; - tstring sSectionName; - - size_t cChild = pTop->GetChildCount(); - for (size_t i = 0; i < cChild; ++i) { - IXMLNode::TXMLNodePtr pNode = pTop->GetChildNode(i); - tstring sName = pNode->GetName(); - if (0 == mir_wstrcmpi(L"section", sName.c_str())) { - CQuotesProviderBase::CQuoteSection qs1; - if (true == parse_section(pNode, qs1)) - aSections.push_back(qs1); - } - else if (0 == mir_wstrcmpi(L"quote", sName.c_str())) { - CQuotesProviderBase::CQuote q; - if (true == parse_quote(pNode, q)) - aQuotes.push_back(q); - } - else if (0 == mir_wstrcmpi(L"name", sName.c_str())) { - sSectionName = pNode->GetText(); - if (true == sSectionName.empty()) - return false; - } - } - - qs = CQuotesProviderBase::CQuoteSection(TranslateW(sSectionName.c_str()), aSections, aQuotes); - return true; -} - -IXMLNode::TXMLNodePtr find_provider(const IXMLNode::TXMLNodePtr& pRoot) -{ - IXMLNode::TXMLNodePtr pProvider; - size_t cChild = pRoot->GetChildCount(); - for (size_t i = 0; i < cChild; ++i) { - IXMLNode::TXMLNodePtr pNode = pRoot->GetChildNode(i); - tstring sName = pNode->GetName(); - if (0 == mir_wstrcmpi(L"Provider", sName.c_str())) { - pProvider = pNode; - break; - } - - pProvider = find_provider(pNode); - if (pProvider) - break; - } - - return pProvider; -} - -CQuotesProviderBase::CXMLFileInfo parse_ini_file(const tstring& rsXMLFile, bool& rbSucceded) -{ - CQuotesProviderBase::CXMLFileInfo res; - CQuotesProviderBase::CQuoteSection::TSections aSections; - - const CModuleInfo::TXMLEnginePtr& pXMLEngine = CModuleInfo::GetXMLEnginePtr(); - IXMLNode::TXMLNodePtr pRoot = pXMLEngine->LoadFile(rsXMLFile); - if (pRoot) { - IXMLNode::TXMLNodePtr pProvider = find_provider(pRoot); - if (pProvider) { - rbSucceded = true; - size_t cChild = pProvider->GetChildCount(); - for (size_t i = 0; i < cChild; ++i) { - IXMLNode::TXMLNodePtr pNode = pProvider->GetChildNode(i); - tstring sName = pNode->GetName(); - if (0 == mir_wstrcmpi(L"section", sName.c_str())) { - CQuotesProviderBase::CQuoteSection qs; - if (true == parse_section(pNode, qs)) - aSections.push_back(qs); - } - else if (0 == mir_wstrcmpi(L"Name", sName.c_str())) - res.m_pi.m_sName = pNode->GetText(); - else if (0 == mir_wstrcmpi(L"ref", sName.c_str())) - res.m_pi.m_sURL = pNode->GetText(); - else if (0 == mir_wstrcmpi(L"url", sName.c_str())) - res.m_sURL = pNode->GetText(); - } - } - } - - res.m_qs = CQuotesProviderBase::CQuoteSection(res.m_pi.m_sName, aSections); - return res; -} - -CQuotesProviderBase::CXMLFileInfo init_xml_info(LPCTSTR pszFileName, bool& rbSucceded) -{ - rbSucceded = false; - tstring sIniFile = get_ini_file_name(pszFileName); - return parse_ini_file(sIniFile, rbSucceded); -} - -CQuotesProviderBase::CQuotesProviderBase() - : m_hEventSettingsChanged(::CreateEvent(nullptr, FALSE, FALSE, nullptr)), - m_hEventRefreshContact(::CreateEvent(nullptr, FALSE, FALSE, nullptr)), - m_bRefreshInProgress(false) -{ -} - -CQuotesProviderBase::~CQuotesProviderBase() -{ - ::CloseHandle(m_hEventSettingsChanged); - ::CloseHandle(m_hEventRefreshContact); -} - -bool CQuotesProviderBase::Init() -{ - bool bSucceded = m_pXMLInfo != nullptr; - if (!m_pXMLInfo) { - CQuotesProviderVisitorDbSettings visitor; - Accept(visitor); - assert(visitor.m_pszXMLIniFileName); - - m_pXMLInfo.reset(new CXMLFileInfo(init_xml_info(visitor.m_pszXMLIniFileName, bSucceded))); - } - - return bSucceded; -} - -CQuotesProviderBase::CXMLFileInfo* CQuotesProviderBase::GetXMLFileInfo()const -{ - // if(!m_pXMLInfo) - // { - // CQuotesProviderVisitorDbSettings visitor; - // Accept(visitor); - // assert(visitor.m_pszXMLIniFileName); - // m_pXMLInfo.reset(new CXMLFileInfo(init_xml_info(visitor.m_pszXMLIniFileName))); - // } - - return m_pXMLInfo.get(); -} - -const CQuotesProviderBase::CProviderInfo& CQuotesProviderBase::GetInfo()const -{ - return GetXMLFileInfo()->m_pi; -} - -const CQuotesProviderBase::CQuoteSection& CQuotesProviderBase::GetQuotes()const -{ - return GetXMLFileInfo()->m_qs; -} - -const tstring& CQuotesProviderBase::GetURL()const -{ - return GetXMLFileInfo()->m_sURL; -} - -bool CQuotesProviderBase::IsOnline() -{ - return /*g_bAutoUpdate*/true; -} - -void CQuotesProviderBase::AddContact(MCONTACT hContact) -{ - // CCritSection cs(m_cs); - assert(m_aContacts.end() == std::find(m_aContacts.begin(), m_aContacts.end(), hContact)); - - m_aContacts.push_back(hContact); -} - -void CQuotesProviderBase::DeleteContact(MCONTACT hContact) -{ - mir_cslock lck(m_cs); - - TContracts::iterator i = std::find(m_aContacts.begin(), m_aContacts.end(), hContact); - if (i != m_aContacts.end()) - m_aContacts.erase(i); -} - -void CQuotesProviderBase::SetContactStatus(MCONTACT hContact, int nNewStatus) -{ - int nStatus = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_STATUS, ID_STATUS_OFFLINE); - if (nNewStatus != nStatus) { - db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_STATUS, nNewStatus); - - if (ID_STATUS_ONLINE != nNewStatus) { - db_unset(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME); - tstring sSymbol = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL); - if (false == sSymbol.empty()) - db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, sSymbol.c_str()); - - SetContactExtraImage(hContact, eiEmpty); - } - } -} - -class CTendency -{ - enum { NumValues = 2 }; - enum EComparison - { - NonValid, - Greater, - Less, - Equal, - GreaterOrEqual, - LessOrEqual - }; - -public: - enum EResult - { - NotChanged, - Up, - Down - }; - -public: - CTendency() : m_nComparison(NonValid) {} - - bool Parse(const IQuotesProvider* pProvider, const tstring& rsFrmt, MCONTACT hContact) - { - m_abValueFlags[0] = false; - m_abValueFlags[1] = false; - m_nComparison = NonValid; - bool bValid = true; - int nCurValue = 0; - for (tstring::const_iterator i = rsFrmt.begin(); i != rsFrmt.end() && bValid && nCurValue < NumValues;) { - wchar_t chr = *i; - switch (chr) { - default: - if (false == std::isspace(chr)) - bValid = false; - else - ++i; - break; - - case '%': - ++i; - if (i != rsFrmt.end()) { - wchar_t t = *i; - ++i; - CQuotesProviderVisitorTendency visitor(hContact, t); - pProvider->Accept(visitor); - if (false == visitor.IsValid()) { - bValid = false; - } - else { - double d = visitor.GetResult(); - m_adValues[nCurValue] = d; - m_abValueFlags[nCurValue] = true; - ++nCurValue; - } - } - else bValid = false; - break; - case '>': - m_nComparison = Greater; - ++i; - break; - case '<': - m_nComparison = Less; - ++i; - break; - case '=': - switch (m_nComparison) { - default: - bValid = false; - break; - case NonValid: - m_nComparison = Equal; - break; - case Greater: - m_nComparison = GreaterOrEqual; - break; - case Less: - m_nComparison = LessOrEqual; - break; - } - ++i; - break; - } - } - - return (bValid && IsValid()); - } - - bool IsValid()const { return (m_abValueFlags[0] && m_abValueFlags[1] && (m_nComparison != NonValid)); } - - EResult Compare()const - { - switch (m_nComparison) { - case Greater: - if (true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) - return NotChanged; - - if (m_adValues[0] > m_adValues[1]) - return Up; - return Down; - - case GreaterOrEqual: - if ((true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) || (m_adValues[0] > m_adValues[1])) - return Up; - return Down; - - case Less: - if (true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) - return NotChanged; - - if (m_adValues[0] < m_adValues[1]) - return Up; - return Down; - - case LessOrEqual: - if ((true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) || (m_adValues[0] < m_adValues[1])) - return Up; - return Down; - - case Equal: - if (true == IsWithinAccuracy(m_adValues[0], m_adValues[1])) - return Up; - return Down; - } - return NotChanged; - } - -private: - double m_adValues[NumValues]; - bool m_abValueFlags[NumValues]; - EComparison m_nComparison; -}; - -tstring format_rate(const IQuotesProvider *pProvider, MCONTACT hContact, const tstring &rsFrmt) -{ - tstring sResult; - - for (tstring::const_iterator i = rsFrmt.begin(); i != rsFrmt.end();) { - wchar_t chr = *i; - switch (chr) { - default: - sResult += chr; - ++i; - break; - - case '\\': - ++i; - if (i != rsFrmt.end()) { - wchar_t t = *i; - switch (t) { - case '%': sResult += L"%"; break; - case 't': sResult += L"\t"; break; - case 'n': sResult += L"\n"; break; - case '\\': sResult += L"\\"; break; - default: sResult += chr; sResult += t; break; - } - ++i; - } - else sResult += chr; - break; - - case '%': - ++i; - if (i != rsFrmt.end()) { - chr = *i; - - byte nWidth = 0; - if (::isdigit(chr)) { - nWidth = chr - 0x30; - ++i; - if (i == rsFrmt.end()) { - sResult += chr; - break; - } - else chr = *i; - } - - CQuotesProviderVisitorFormater visitor(hContact, chr, nWidth); - pProvider->Accept(visitor); - const tstring& s = visitor.GetResult(); - sResult += s; - ++i; - } - else sResult += chr; - break; - } - } - - return sResult; -} - -void log_to_file(const IQuotesProvider* pProvider, - MCONTACT hContact, - const tstring& rsLogFileName, - const tstring& rsFormat) -{ - std::string sPath = quotes_t2a(rsLogFileName.c_str()); - - std::string::size_type n = sPath.find_last_of("\\/"); - if (std::string::npos != n) - sPath.erase(n); - - DWORD dwAttributes = ::GetFileAttributesA(sPath.c_str()); - if ((0xffffffff == dwAttributes) || (0 == (dwAttributes&FILE_ATTRIBUTE_DIRECTORY))) - CreateDirectoryTree(sPath.c_str()); - - tofstream file(rsLogFileName.c_str(), std::ios::app | std::ios::out); - file.imbue(GetSystemLocale()); - if (file.good()) { - tstring s = format_rate(pProvider, hContact, rsFormat); - file << s; - } -} - -void log_to_history(const IQuotesProvider* pProvider, - MCONTACT hContact, - time_t nTime, - const tstring& rsFormat) -{ - tstring s = format_rate(pProvider, hContact, rsFormat); - T2Utf psz(s.c_str()); - - DBEVENTINFO dbei = {}; - dbei.szModule = QUOTES_PROTOCOL_NAME; - dbei.timestamp = static_cast(nTime); - dbei.flags = DBEF_READ | DBEF_UTF; - dbei.eventType = EVENTTYPE_MESSAGE; - dbei.cbBlob = (int)::mir_strlen(psz) + 1; - dbei.pBlob = (PBYTE)(char*)psz; - db_event_add(hContact, &dbei); -} - -bool do_set_contact_extra_icon(MCONTACT hContact, const CTendency& tendency) -{ - CTendency::EResult nComparison = tendency.Compare(); - - if (CTendency::NotChanged == nComparison) - return SetContactExtraImage(hContact, eiNotChanged); - - if (CTendency::Up == nComparison) - return SetContactExtraImage(hContact, eiUp); - - if (CTendency::Down == nComparison) - return SetContactExtraImage(hContact, eiDown); - - return false; -} - -bool show_popup(const IQuotesProvider* pProvider, - MCONTACT hContact, - const CTendency& tendency, - const tstring& rsFormat, - const CPopupSettings& ps) -{ - if (!ServiceExists(MS_POPUP_ADDPOPUPT)) - return false; - - POPUPDATAT ppd; - memset(&ppd, 0, sizeof(ppd)); - ppd.lchContact = hContact; - - if (tendency.IsValid()) { - CTendency::EResult nComparison = tendency.Compare(); - if (CTendency::NotChanged == nComparison) - ppd.lchIcon = Quotes_LoadIconEx(IDI_ICON_NOTCHANGED); - else if (CTendency::Up == nComparison) - ppd.lchIcon = Quotes_LoadIconEx(IDI_ICON_UP); - else if (CTendency::Down == nComparison) - ppd.lchIcon = Quotes_LoadIconEx(IDI_ICON_DOWN); - } - - CQuotesProviderVisitorFormater visitor(hContact, 's', 0); - pProvider->Accept(visitor); - const tstring& sTitle = visitor.GetResult(); - mir_wstrncpy(ppd.lptzContactName, sTitle.c_str(), MAX_CONTACTNAME); - { - ptrW ss(variables_parsedup((wchar_t*)rsFormat.c_str(), nullptr, hContact)); - tstring sText = format_rate(pProvider, hContact, tstring(ss)); - mir_wstrncpy(ppd.lptzText, sText.c_str(), MAX_SECONDLINE); - } - - if (CPopupSettings::colourDefault == ps.GetColourMode()) { - ppd.colorText = CPopupSettings::GetDefColourText(); - ppd.colorBack = CPopupSettings::GetDefColourBk(); - } - else { - ppd.colorText = ps.GetColourText(); - ppd.colorBack = ps.GetColourBk(); - } - - switch (ps.GetDelayMode()) { - default: - assert(!"Unknown popup delay mode"); - case CPopupSettings::delayFromPopup: - ppd.iSeconds = 0; - break; - case CPopupSettings::delayPermanent: - ppd.iSeconds = -1; - break; - case CPopupSettings::delayCustom: - ppd.iSeconds = ps.GetDelayTimeout(); - break; - } - - LPARAM lp = 0; - if (false == ps.GetHistoryFlag()) - lp |= 0x08; - - return (0 == CallService(MS_POPUP_ADDPOPUPT, reinterpret_cast(&ppd), lp)); -} - -void CQuotesProviderBase::WriteContactRate(MCONTACT hContact, double dRate, const tstring& rsSymbol/* = ""*/) -{ - time_t nTime = ::time(0); - - if (false == rsSymbol.empty()) - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL, rsSymbol.c_str()); - - double dPrev = 0.0; - bool bValidPrev = Quotes_DBReadDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_CURR_VALUE, dPrev); - if (true == bValidPrev) - Quotes_DBWriteDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_PREV_VALUE, dPrev); - - Quotes_DBWriteDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_CURR_VALUE, dRate); - db_set_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FETCH_TIME, nTime); - - tstring sSymbol = rsSymbol; - - tostringstream oNick; - oNick.imbue(GetSystemLocale()); - if (false == m_sContactListFormat.empty()) { - tstring s = format_rate(this, hContact, m_sContactListFormat); - oNick << s; - } - else { - if (true == sSymbol.empty()) - sSymbol = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL); - - oNick << std::setfill(L' ') << std::setw(10) << std::left << sSymbol << std::setw(6) << std::right << dRate; - } - CTendency tendency; - - if (true == tendency.Parse(this, m_sTendencyFormat, hContact)) - do_set_contact_extra_icon(hContact, tendency); - - db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, oNick.str().c_str()); - - tstring sStatusMsg = format_rate(this, hContact, m_sStatusMsgFormat); - if (false == sStatusMsg.empty()) - db_set_ws(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME, sStatusMsg.c_str()); - else - db_unset(hContact, LIST_MODULE_NAME, STATUS_MSG_NAME); - - bool bUseContactSpecific = (db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 0) > 0); - - CAdvProviderSettings global_settings(this); - - WORD dwMode = (bUseContactSpecific) - ? db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, static_cast(lmDisabled)) - : global_settings.GetLogMode(); - if (dwMode&lmExternalFile) { - bool bAdd = true; - bool bOnlyIfChanged = (bUseContactSpecific) - ? (db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE_CONDITION, 1) > 0) - : global_settings.GetLogOnlyChangedFlag(); - if (true == bOnlyIfChanged) { - bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev))); - } - if (true == bAdd) { - tstring sLogFileName = (bUseContactSpecific) - ? Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE, global_settings.GetLogFileName().c_str()) - : global_settings.GetLogFileName(); - - if (true == sSymbol.empty()) { - sSymbol = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL); - } - - sLogFileName = GenerateLogFileName(sLogFileName, sSymbol); - - tstring sFormat = global_settings.GetLogFormat(); - if (bUseContactSpecific) { - CQuotesProviderVisitorDbSettings visitor; - Accept(visitor); - sFormat = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_LOG_FILE, visitor.m_pszDefLogFileFormat); - } - - log_to_file(this, hContact, sLogFileName, sFormat); - } - } - if (dwMode&lmInternalHistory) { - bool bAdd = true; - bool bOnlyIfChanged = (bUseContactSpecific) - ? (db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_HISTORY_CONDITION, 1) > 0) - : global_settings.GetHistoryOnlyChangedFlag(); - - if (true == bOnlyIfChanged) { - bAdd = ((false == bValidPrev) || (false == IsWithinAccuracy(dRate, dPrev))); - } - if (true == bAdd) { - tstring sFormat = (bUseContactSpecific) - ? Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_HISTORY, global_settings.GetHistoryFormat().c_str()) - : global_settings.GetHistoryFormat(); - - log_to_history(this, hContact, nTime, sFormat); - } - } - - if (dwMode&lmPopup) { - bool bOnlyIfChanged = (bUseContactSpecific) - ? (1 == db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_CONDITION, 1) > 0) - : global_settings.GetShowPopupIfValueChangedFlag(); - if ((false == bOnlyIfChanged) - || ((true == bOnlyIfChanged) && (true == bValidPrev) && (false == IsWithinAccuracy(dRate, dPrev)))) { - tstring sFormat = (bUseContactSpecific) - ? Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_POPUP, global_settings.GetPopupFormat().c_str()) - : global_settings.GetPopupFormat(); - - CPopupSettings ps = *(global_settings.GetPopupSettingsPtr()); - ps.InitForContact(hContact); - show_popup(this, hContact, tendency, sFormat, ps); - } - } - - SetContactStatus(hContact, ID_STATUS_ONLINE); -} - -MCONTACT CQuotesProviderBase::CreateNewContact(const tstring& rsName) -{ - MCONTACT hContact = db_add_contact(); - if (hContact) { - if (0 == Proto_AddToContact(hContact, QUOTES_PROTOCOL_NAME)) { - tstring sProvName = GetInfo().m_sName; - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_PROVIDER, sProvName.c_str()); - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_SYMBOL, rsName.c_str()); - db_set_ws(hContact, LIST_MODULE_NAME, CONTACT_LIST_NAME, rsName.c_str()); - - mir_cslock lck(m_cs); - m_aContacts.push_back(hContact); - } - else { - db_delete_contact(hContact); - hContact = NULL; - } - } - - return hContact; -} - -DWORD get_refresh_timeout_miliseconds(const CQuotesProviderVisitorDbSettings& visitor) -{ - if (!g_bAutoUpdate) - return INFINITE; - - assert(visitor.m_pszDbRefreshRateType); - assert(visitor.m_pszDbRefreshRateValue); - - int nRefreshRateType = db_get_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateType, RRT_MINUTES); - if (nRefreshRateType < RRT_SECONDS || nRefreshRateType > RRT_HOURS) - nRefreshRateType = RRT_MINUTES; - - DWORD nTimeout = db_get_w(NULL, QUOTES_MODULE_NAME, visitor.m_pszDbRefreshRateValue, 1); - switch (nRefreshRateType) { - default: - case RRT_SECONDS: - if (nTimeout < 1 || nTimeout > 60) - nTimeout = 1; - - nTimeout *= 1000; - break; - case RRT_MINUTES: - if (nTimeout < 1 || nTimeout > 60) - nTimeout = 1; - - nTimeout *= 1000 * 60; - break; - case RRT_HOURS: - if (nTimeout < 1 || nTimeout > 24) - nTimeout = 1; - - nTimeout *= 1000 * 60 * 60; - break; - } - - return nTimeout; -} - -class CBoolGuard -{ -public: - CBoolGuard(bool& rb) : m_b(rb) { m_b = true; } - ~CBoolGuard() { m_b = false; } - -private: - bool m_b; -}; - -void CQuotesProviderBase::Run() -{ - CQuotesProviderVisitorDbSettings visitor; - Accept(visitor); - - DWORD nTimeout = get_refresh_timeout_miliseconds(visitor); - m_sContactListFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); - m_sStatusMsgFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); - m_sTendencyFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); - - enum - { - STOP_THREAD = 0, - SETTINGS_CHANGED = 1, - REFRESH_CONTACT = 2, - COUNT_SYNC_OBJECTS = 3 - }; - - HANDLE anEvents[COUNT_SYNC_OBJECTS]; - anEvents[STOP_THREAD] = g_hEventWorkThreadStop; - anEvents[SETTINGS_CHANGED] = m_hEventSettingsChanged; - anEvents[REFRESH_CONTACT] = m_hEventRefreshContact; - - TContracts anContacts; - { - mir_cslock lck(m_cs); - anContacts = m_aContacts; - } - - bool bGoToBed = false; - - if (g_bAutoUpdate) { - CBoolGuard bg(m_bRefreshInProgress); - RefreshQuotes(anContacts); - } - - while (false == bGoToBed) { - anContacts.clear(); - - DWORD dwBegin = ::GetTickCount(); - DWORD dwResult = ::WaitForMultipleObjects(COUNT_SYNC_OBJECTS, anEvents, FALSE, nTimeout); - switch (dwResult) { - case WAIT_FAILED: - assert(!"WaitForMultipleObjects failed"); - bGoToBed = true; - break; - - case WAIT_ABANDONED_0 + STOP_THREAD: - case WAIT_ABANDONED_0 + SETTINGS_CHANGED: - case WAIT_ABANDONED_0 + REFRESH_CONTACT: - assert(!"WaitForMultipleObjects abandoned"); - - case WAIT_OBJECT_0 + STOP_THREAD: - bGoToBed = true; - break; - - case WAIT_OBJECT_0 + SETTINGS_CHANGED: - nTimeout = get_refresh_timeout_miliseconds(visitor); - m_sContactListFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbDisplayNameFormat, visitor.m_pszDefDisplayFormat); - m_sStatusMsgFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbStatusMsgFormat, visitor.m_pszDefStatusMsgFormat); - m_sTendencyFormat = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbTendencyFormat, visitor.m_pszDefTendencyFormat); - { - mir_cslock lck(m_cs); - anContacts = m_aContacts; - } - break; - case WAIT_OBJECT_0 + REFRESH_CONTACT: - { - DWORD dwTimeRest = ::GetTickCount() - dwBegin; - if (INFINITE != nTimeout && dwTimeRest < nTimeout) { - nTimeout -= dwTimeRest; - } - - { - mir_cslock lck(m_cs); - anContacts = m_aRefreshingContacts; - m_aRefreshingContacts.clear(); - } - - { - CBoolGuard bg(m_bRefreshInProgress); - RefreshQuotes(anContacts); - } - } - break; - case WAIT_TIMEOUT: - nTimeout = get_refresh_timeout_miliseconds(visitor); - { - mir_cslock lck(m_cs); - anContacts = m_aContacts; - } - { - CBoolGuard bg(m_bRefreshInProgress); - RefreshQuotes(anContacts); - } - break; - - default: - assert(!"What is the hell?"); - } - } - - OnEndRun(); -} - -void CQuotesProviderBase::OnEndRun() -{ - TContracts anContacts; - { - mir_cslock lck(m_cs); - anContacts = m_aContacts; - m_aRefreshingContacts.clear(); - } - - CBoolGuard bg(m_bRefreshInProgress); - std::for_each(anContacts.begin(), anContacts.end(), boost::bind(&SetContactStatus, _1, ID_STATUS_OFFLINE)); -} - -void CQuotesProviderBase::Accept(CQuotesProviderVisitor &visitor)const -{ - visitor.Visit(*this); -} - -void CQuotesProviderBase::RefreshSettings() -{ - BOOL b = ::SetEvent(m_hEventSettingsChanged); - assert(b && "Failed to set event"); -} - -void CQuotesProviderBase::RefreshAllContacts() -{ - {// for CCritSection - mir_cslock lck(m_cs); - m_aRefreshingContacts.clear(); - std::for_each(std::begin(m_aContacts), std::end(m_aContacts), [&](MCONTACT hContact) { m_aRefreshingContacts.push_back(hContact); }); - } - - BOOL b = ::SetEvent(m_hEventRefreshContact); - assert(b && "Failed to set event"); -} - -void CQuotesProviderBase::RefreshContact(MCONTACT hContact) -{ - {// for CCritSection - mir_cslock lck(m_cs); - m_aRefreshingContacts.push_back(hContact); - } - - BOOL b = ::SetEvent(m_hEventRefreshContact); - assert(b && "Failed to set event"); -} diff --git a/plugins/Quotes/src/QuotesProviderBase.h b/plugins/Quotes/src/QuotesProviderBase.h deleted file mode 100644 index 7370318b3d..0000000000 --- a/plugins/Quotes/src/QuotesProviderBase.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef __3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__ -#define __3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__ - -class CQuotesProviderBase : public IQuotesProvider -{ -public: - class CQuote - { - public: - CQuote(const tstring& rsID = L"", const tstring& rsSymbol = L"", const tstring& rsName = L"") - : 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 TSections; - typedef std::vector TQuotes; - - public: - CQuoteSection(const tstring& rsName = L"", 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 TContracts; - -public: - struct CXMLFileInfo; - -public: - CQuotesProviderBase(); - ~CQuotesProviderBase(); - - - const CQuoteSection& GetQuotes()const; - // void SetSettingsEvent(); - - virtual bool Init(); - virtual const CProviderInfo& GetInfo()const; - virtual void AddContact(MCONTACT hContact); - virtual void DeleteContact(MCONTACT hContact); - virtual void Run(); - virtual void Accept(CQuotesProviderVisitor& visitor)const; - virtual void RefreshAllContacts(); - virtual void RefreshSettings(); - virtual void RefreshContact(MCONTACT hContact); - // virtual void SetContactExtraIcon(MCONTACT hContact)const; - -protected: - const tstring& GetURL()const; - MCONTACT CreateNewContact(const tstring& rsName); - static bool IsOnline(); - static void SetContactStatus(MCONTACT hContact, int nNewStatus); - void WriteContactRate(MCONTACT hContact, double dRate, const tstring& rsSymbol = L""); - -private: - virtual void RefreshQuotes(TContracts& anContacts) = 0; - -private: - virtual void OnEndRun(); - -private: - CXMLFileInfo* GetXMLFileInfo()const; - -protected: - TContracts m_aContacts; - mutable mir_cs m_cs; - -private: - typedef boost::scoped_ptr 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/QuotesProviderCurrencyConverter.cpp b/plugins/Quotes/src/QuotesProviderCurrencyConverter.cpp deleted file mode 100644 index f51a662721..0000000000 --- a/plugins/Quotes/src/QuotesProviderCurrencyConverter.cpp +++ /dev/null @@ -1,425 +0,0 @@ -#include "stdafx.h" -#include "QuotesProviderCurrencyConverter.h" -#include -#include - -namespace -{ - tstring build_url(const tstring& rsURL, const tstring& from, const tstring& to) - { - tostringstream o; - o << rsURL << L"?q=" << from << L"_" << to << "&compact=ultra"; - return o.str(); - } - - tstring build_url(MCONTACT hContact, const tstring& rsURL) - { - 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); - } - - bool parse_responce(const tstring& rsJSON, double& dRate) - { - try - { - boost::property_tree::ptree pt; - std::istringstream i_stream(quotes_t2a(rsJSON.c_str())); - - boost::property_tree::read_json(i_stream, pt); - if (!pt.empty()) - { - auto pt_nested = pt.begin()->second; - dRate = pt_nested.get_value(); - } - else - { - dRate = pt.get_value(); - } - - return true; - } - catch (boost::property_tree::ptree_error& ) - { - } - return false; - } - - using TWatchedRates = std::vector; - TWatchedRates g_aWatchedRates; - - INT_PTR CALLBACK OptDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) - { - auto get_provider = []()->CQuotesProviderCurrencyConverter* - { - auto pProviders = CModuleInfo::GetQuoteProvidersPtr(); - const auto& rapQuotesProviders = pProviders->GetProviders(); - for (auto i = rapQuotesProviders.begin(); i != rapQuotesProviders.end(); ++i) { - const auto& pProvider = *i; - if (auto p = dynamic_cast(pProvider.get())) - { - return p; - } - } - - assert(!"We should never get here!"); - return nullptr; - }; - - auto make_quote_name = [](const CQuotesProviderBase::CQuote& rQuote)->tstring - { - const tstring& rsDesc = rQuote.GetName(); - return((false == rsDesc.empty()) ? rsDesc : rQuote.GetSymbol()); - }; - - auto make_contact_name = [](const tstring& rsSymbolFrom, const tstring& rsSymbolTo)->tstring - { - tostringstream o; - o << rsSymbolFrom << L"/" << rsSymbolTo; - return o.str(); - }; - - - auto make_rate_name = [make_contact_name](const CQuotesProviderCurrencyConverter::TRateInfo& ri)->tstring - { - if ((false == ri.first.GetName().empty()) && (false == ri.second.GetName().empty())) - return make_contact_name(ri.first.GetName(), ri.second.GetName()); - - return make_contact_name(ri.first.GetSymbol(), ri.second.GetSymbol()); - }; - - - auto pProvider = get_provider(); - - CCommonDlgProcData d(pProvider); - CommonOptionDlgProc(hdlg, message, wParam, lParam, d); - - switch (message) { - case WM_NOTIFY: - { - LPNMHDR pNMHDR = reinterpret_cast(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) { - CQuotesProviderCurrencyConverter::TRateInfo ri; - if (true == pProvider->GetWatchedRateInfo(i, ri)) { - auto it = std::find_if(aTemp.begin(), aTemp.end(), [&ri](const auto& other)->bool - { - return ((0 == mir_wstrcmpi(ri.first.GetID().c_str(), other.first.GetID().c_str())) - && ((0 == mir_wstrcmpi(ri.second.GetID().c_str(), other.second.GetID().c_str())))); - }); - if (it == aTemp.end()) { - aRemove.push_back(ri); - } - else { - aTemp.erase(it); - } - } - } - - std::for_each(aRemove.begin(), aRemove.end(), [pProvider](const auto& ri) {pProvider->WatchForRate(ri, false); }); - std::for_each(aTemp.begin(), aTemp.end(), [pProvider](const auto& ri) {pProvider->WatchForRate(ri, true); }); - pProvider->RefreshSettings(); - } - } - 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); - - CQuotesProviderBase::CQuoteSection rSection; - const auto& rQuotes = pProvider->GetQuotes(); - if (rQuotes.GetSectionCount() > 0) - { - rSection = rQuotes.GetSection(0); - } - - auto cQuotes = rSection.GetQuoteCount(); - for (auto i = 0u; i < cQuotes; ++i) - { - const auto& rQuote = rSection.GetQuote(i); - tstring sName = make_quote_name(rQuote); - LPCTSTR pszName = sName.c_str(); - ::SendMessage(hcbxFrom, CB_ADDSTRING, 0, reinterpret_cast(pszName)); - ::SendMessage(hcbxTo, CB_ADDSTRING, 0, reinterpret_cast(pszName)); - } - - auto cWatchedRates = pProvider->GetWatchedRateCount(); - for (auto i = 0u; i < cWatchedRates; ++i) - { - CQuotesProviderCurrencyConverter::TRateInfo ri; - if (true == pProvider->GetWatchedRateInfo(i, ri)) - { - g_aWatchedRates.push_back(ri); - tstring sRate = make_rate_name(ri); - LPCTSTR pszRateName = sRate.c_str(); - ::SendDlgItemMessage(hdlg, IDC_LIST_RATES, LB_ADDSTRING, 0, reinterpret_cast(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(::SendDlgItemMessage(hdlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); - int nTo = static_cast(::SendDlgItemMessage(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 = ::SendDlgItemMessage(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(::SendDlgItemMessage(hdlg, IDC_COMBO_CONVERT_FROM, CB_GETCURSEL, 0, 0)); - size_t nTo = static_cast(::SendDlgItemMessage(hdlg, IDC_COMBO_CONVERT_INTO, CB_GETCURSEL, 0, 0)); - if ((CB_ERR != nFrom) && (CB_ERR != nTo) && (nFrom != nTo)) - { - CQuotesProviderBase::CQuoteSection rSection; - const auto& rQuotes = pProvider->GetQuotes(); - if (rQuotes.GetSectionCount() > 0) - { - rSection = rQuotes.GetSection(0); - } - - auto cQuotes = rSection.GetQuoteCount(); - if ((nFrom < cQuotes) && (nTo < cQuotes)) - { - CQuotesProviderCurrencyConverter::TRateInfo ri; - ri.first = rSection.GetQuote(nFrom); - ri.second = rSection.GetQuote(nTo); - - g_aWatchedRates.push_back(ri); - - tstring sRate = make_rate_name(ri); - LPCTSTR pszRateName = sRate.c_str(); - ::SendDlgItemMessage(hdlg, IDC_LIST_RATES, LB_ADDSTRING, 0, reinterpret_cast(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(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; - } - break; - } - - return FALSE; - } - -} - - -CQuotesProviderCurrencyConverter::CQuotesProviderCurrencyConverter() -{ -} - - -CQuotesProviderCurrencyConverter::~CQuotesProviderCurrencyConverter() -{ -} - -void CQuotesProviderCurrencyConverter::Accept(CQuotesProviderVisitor& visitor)const -{ - CQuotesProviderBase::Accept(visitor); - visitor.Visit(*this); -} - -void CQuotesProviderCurrencyConverter::ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp) -{ - odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_OPT_GOOGLE); - odp.pfnDlgProc = OptDlgProc; - odp.szTab.w = const_cast(GetInfo().m_sName.c_str()); - g_plugin.addOptions(wp, &odp); -} - -void CQuotesProviderCurrencyConverter::RefreshQuotes(TContracts& anContacts) -{ - CHTTPSession http; - tstring sURL = GetURL(); - - for (TContracts::const_iterator i = anContacts.begin(); i != anContacts.end() && IsOnline(); ++i) { - MCONTACT hContact = *i; - - tstring sFullURL = build_url(hContact, sURL); - if ((true == http.OpenURL(sFullURL)) && (true == IsOnline())) { - tstring sHTML; - if ((true == http.ReadResponce(sHTML)) && (true == IsOnline())) { - double dRate = 0.0; - if ((true == parse_responce(sHTML, dRate)) && (true == IsOnline())) { - WriteContactRate(hContact, dRate); - continue; - } - } - } - - SetContactStatus(hContact, ID_STATUS_NA); - } -} - -double CQuotesProviderCurrencyConverter::Convert(double dAmount, const CQuote& from, const CQuote& to)const -{ - tstring sFullURL = build_url(GetURL(), from.GetID(), to.GetID()); - - CHTTPSession http; - if ((true == http.OpenURL(sFullURL))) { - tstring sHTML; - if ((true == http.ReadResponce(sHTML))) { - double dResult = 0.0; - if ((true == parse_responce(sHTML, dResult))) - { - return dResult*dAmount; - } - - 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; -} - -size_t CQuotesProviderCurrencyConverter::GetWatchedRateCount()const -{ - return m_aContacts.size(); -} - -bool CQuotesProviderCurrencyConverter::GetWatchedRateInfo(size_t nIndex, TRateInfo& rRateInfo) -{ - if(nIndex < m_aContacts.size()) { - MCONTACT 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.first = CQuote(sSymbolFrom, sSymbolFrom, sDescFrom); - rRateInfo.second = CQuote(sSymbolTo, sSymbolTo, sDescTo); - return true; - } - else { - return false; - } -} - -bool CQuotesProviderCurrencyConverter::WatchForRate(const TRateInfo& ri, bool bWatch) -{ - auto i = std::find_if(m_aContacts.begin(), m_aContacts.end(), [&ri](auto hContact)->bool - { - 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 == mir_wstrcmpi(ri.first.GetID().c_str(), sFrom.c_str())) - && (0 == mir_wstrcmpi(ri.second.GetID().c_str(), sTo.c_str()))); - }); - - auto make_contact_name = [](const tstring& rsSymbolFrom, const tstring& rsSymbolTo)->tstring - { - tostringstream o; - o << rsSymbolFrom << L"/" << rsSymbolTo; - return o.str(); - }; - - - if ((true == bWatch) && (i == m_aContacts.end())) - { - tstring sName = make_contact_name(ri.first.GetSymbol(), ri.second.GetSymbol()); - MCONTACT hContact = CreateNewContact(sName); - if (hContact) - { - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_FROM_ID, ri.first.GetID().c_str()); - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_TO_ID, ri.second.GetID().c_str()); - if (false == ri.first.GetName().empty()) - { - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_FROM_DESCRIPTION, ri.first.GetName().c_str()); - } - if (false == ri.second.GetName().empty()) - { - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_TO_DESCRIPTION, ri.second.GetName().c_str()); - } - - return true; - } - } - else if ((false == bWatch) && (i != m_aContacts.end())) - { - MCONTACT hContact = *i; - {// for CCritSection - mir_cslock lck(m_cs); - m_aContacts.erase(i); - } - - db_delete_contact(hContact); - return true; - } - - return false; -} - -MCONTACT CQuotesProviderCurrencyConverter::GetContactByID(const tstring& rsFromID, const tstring& rsToID)const -{ - mir_cslock lck(m_cs); - - auto i = std::find_if(m_aContacts.begin(), m_aContacts.end(), [rsFromID, rsToID](MCONTACT hContact)->bool - { - 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 == mir_wstrcmpi(rsFromID.c_str(), sFrom.c_str())) && (0 == mir_wstrcmpi(rsToID.c_str(), sTo.c_str()))); - - }); - if (i != m_aContacts.end()) - return *i; - - return NULL; -} diff --git a/plugins/Quotes/src/QuotesProviderCurrencyConverter.h b/plugins/Quotes/src/QuotesProviderCurrencyConverter.h deleted file mode 100644 index c6138756b3..0000000000 --- a/plugins/Quotes/src/QuotesProviderCurrencyConverter.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#define DB_STR_FROM_ID "FromID" -#define DB_STR_TO_ID "ToID" -#define DB_STR_FROM_DESCRIPTION "FromDesc" -#define DB_STR_TO_DESCRIPTION "ToDesc" - - -class CQuotesProviderCurrencyConverter : public CQuotesProviderBase -{ -public: - using TRateInfo = std::pair; - -public: - CQuotesProviderCurrencyConverter(); - ~CQuotesProviderCurrencyConverter(); - - double Convert(double dAmount, const CQuote& from, const CQuote& to)const; - size_t GetWatchedRateCount()const; - bool GetWatchedRateInfo(size_t nIndex, TRateInfo& rRateInfo); - bool WatchForRate(const TRateInfo& ri, bool bWatch); - MCONTACT GetContactByID(const tstring& rsFromID, const tstring& rsToID)const; - -private: - virtual void Accept(CQuotesProviderVisitor& visitor)const override; - virtual void ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp)override; - virtual void RefreshQuotes(TContracts& anContacts)override; -}; - diff --git a/plugins/Quotes/src/QuotesProviderVisitor.h b/plugins/Quotes/src/QuotesProviderVisitor.h deleted file mode 100644 index f262763871..0000000000 --- a/plugins/Quotes/src/QuotesProviderVisitor.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __7fca59e7_17b2_4849_bd7a_02c7675f2d76_QuotesProviderVisitor_h__ -#define __7fca59e7_17b2_4849_bd7a_02c7675f2d76_QuotesProviderVisitor_h__ - -class CQuotesProviderBase; -class CQuotesProviderFinance; -class CQuotesProviderDukasCopy; -class CQuotesProviderGoogleFinance; -class CQuotesProviderYahoo; -class CQuotesProviderCurrencyConverter; - -class CQuotesProviderVisitor -{ -public: - CQuotesProviderVisitor() {} - virtual ~CQuotesProviderVisitor() {} - - virtual void Visit(const CQuotesProviderBase&){} - virtual void Visit(const CQuotesProviderFinance&){} - virtual void Visit(const CQuotesProviderDukasCopy&){} - virtual void Visit(const CQuotesProviderGoogleFinance&){} - virtual void Visit(const CQuotesProviderYahoo&){} - virtual void Visit(const CQuotesProviderCurrencyConverter&) {} -}; - -#endif //__7fca59e7_17b2_4849_bd7a_02c7675f2d76_QuotesProviderVisitor_h__ diff --git a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp deleted file mode 100644 index d7d9055d33..0000000000 --- a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "StdAfx.h" - -CQuotesProviderVisitorDbSettings::CQuotesProviderVisitorDbSettings() - : m_pszDbRefreshRateType(nullptr), - m_pszDbRefreshRateValue(nullptr), - m_pszDbDisplayNameFormat(nullptr), - m_pszDefDisplayFormat(nullptr), - m_pszDefLogFileFormat(nullptr), - m_pszDefHistoryFormat(nullptr), - m_pszXMLIniFileName(nullptr), - m_pszDbStatusMsgFormat(nullptr), - m_pszDefStatusMsgFormat(nullptr), - m_pszDbLogMode(nullptr), - m_pszDbHistoryFormat(nullptr), - m_pszDbHistoryCondition(nullptr), - m_pszDbLogFile(nullptr), - m_pszDbLogFormat(nullptr), - m_pszDbLogCondition(nullptr), - m_pszDbPopupFormat(nullptr), - m_pszDefPopupFormat(nullptr), - m_pszDbPopupCondition(nullptr), - m_pszDbPopupColourMode(nullptr), - m_pszDbPopupBkColour(nullptr), - m_pszDbPopupTextColour(nullptr), - m_pszDbPopupDelayMode(nullptr), - m_pszDbPopupDelayTimeout(nullptr), - m_pszDbPopupHistoryFlag(nullptr), - m_pszDbTendencyFormat(nullptr), - m_pszDefTendencyFormat(L"%r>%p") -{ -} - -CQuotesProviderVisitorDbSettings::~CQuotesProviderVisitorDbSettings() -{ -} - -void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderBase&/* rProvider*/) -{ - m_pszDefLogFileFormat = L"%s\\t%t\\t%r\\n"; - m_pszDefHistoryFormat = L"%s %r"; - m_pszDefPopupFormat = L"\\nCurrent = %r\\nPrevious = %p"; -} - -void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderCurrencyConverter&) -{ - m_pszDbRefreshRateType = "CC_RefreshRateType"; - m_pszDbRefreshRateValue = "CC_RefreshRateValue"; - m_pszDbDisplayNameFormat = "CC_DspNameFrmt"; - m_pszDefDisplayFormat = L"1 %f = %r %i"; - m_pszXMLIniFileName = L"CC.xml"; - m_pszDbStatusMsgFormat = "CC_StatusMessageFormat"; - - m_pszDbLogMode = "CC_LogMode"; - m_pszDbHistoryFormat = "CC_HistoryFormat"; - m_pszDbHistoryCondition = "CC_AddToHistoryOnlyIfValueIsChanged"; - m_pszDbLogFile = "CC_LogFile"; - m_pszDbLogFormat = "CC_LogFileFormat"; - m_pszDbLogCondition = "CC_AddToLogOnlyIfValueIsChanged"; - m_pszDbPopupFormat = "CC_PopupFormat"; - m_pszDbPopupCondition = "CC_ShowPopupOnlyIfValueChanged"; - - m_pszDbPopupColourMode = "CC_PopupColourMode"; - m_pszDbPopupBkColour = "CC_PopupColourBk"; - m_pszDbPopupTextColour = "CC_PopupColourText"; - m_pszDbPopupDelayMode = "CC_PopupDelayMode"; - m_pszDbPopupDelayTimeout = "CC_PopupDelayTimeout"; - m_pszDbPopupHistoryFlag = "CC_PopupHistoryFlag"; - - m_pszDbTendencyFormat = "CC_TendencyFormat"; -} diff --git a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h deleted file mode 100644 index 8c7003303e..0000000000 --- a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __97cd432a_1119_4803_a96f_0abc1cc2653f_QuotesProviderVisitorDbSettings_h__ -#define __97cd432a_1119_4803_a96f_0abc1cc2653f_QuotesProviderVisitorDbSettings_h__ - -class CQuotesProviderVisitorDbSettings : public CQuotesProviderVisitor -{ -public: - CQuotesProviderVisitorDbSettings(); - ~CQuotesProviderVisitorDbSettings(); - -private: - virtual void Visit(const CQuotesProviderBase& rProvider)override; - virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override; -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 deleted file mode 100644 index 09a62442ab..0000000000 --- a/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "StdAfx.h" - -CQuotesProviderVisitorFormatSpecificator::CQuotesProviderVisitorFormatSpecificator() -{ -} - -CQuotesProviderVisitorFormatSpecificator::~CQuotesProviderVisitorFormatSpecificator() -{ -} - -void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderDukasCopy&/* rProvider*/) -{ - m_aSpecificators.push_back(CFormatSpecificator(L"%s", TranslateT("Quote Symbol"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%d", TranslateT("Quote Name"))); -} - -void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderBase&/* rProvider*/) -{ - m_aSpecificators.push_back(CFormatSpecificator(L"%S", TranslateT("Source of Information"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%r", TranslateT("Rate Value"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%p", TranslateT("Previous Rate Value"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%X", TranslateT("Fetch Time"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%x", TranslateT("Fetch Date"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%t", TranslateT("Fetch Time and Date"))); - m_aSpecificators.push_back(CFormatSpecificator(L"\\%", TranslateT("Percentage Character (%)"))); - m_aSpecificators.push_back(CFormatSpecificator(L"\\t", TranslateT("Tabulation"))); - m_aSpecificators.push_back(CFormatSpecificator(L"\\\\", TranslateT("Left slash (\\)"))); -} - -void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderGoogleFinance&/* rProvider*/) -{ - m_aSpecificators.push_back(CFormatSpecificator(L"%s", TranslateT("Quote Symbol"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%n", TranslateT("Quote Name"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%o", TranslateT("Open Price"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%d", TranslateT("Percent Change to After Hours"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%y", TranslateT("Percent Change to Yesterday Close"))); -} - -const CQuotesProviderVisitorFormatSpecificator::TFormatSpecificators& CQuotesProviderVisitorFormatSpecificator::GetSpecificators()const -{ - return m_aSpecificators; -} - -void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderYahoo&) -{ - m_aSpecificators.push_back(CFormatSpecificator(L"%s", TranslateT("Quote Symbol"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%n", TranslateT("Quote Name"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%o", TranslateT("Open Price"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%h", TranslateT("Day's High"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%g", TranslateT("Day's Low"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%P", TranslateT("Previous Close"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%c", TranslateT("Change"))); -} - -void CQuotesProviderVisitorFormatSpecificator::Visit(const CQuotesProviderCurrencyConverter&) -{ - m_aSpecificators.push_back(CFormatSpecificator(L"%F", TranslateT("From Currency Full Name"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%f", TranslateT("From Currency Short Name"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%I", TranslateT("Into Currency Full Name"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%i", TranslateT("Into Currency Short Name"))); - m_aSpecificators.push_back(CFormatSpecificator(L"%s", TranslateT("Short notation for \"%f/%i\""))); -} \ No newline at end of file diff --git a/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.h b/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.h deleted file mode 100644 index 156b82b9aa..0000000000 --- a/plugins/Quotes/src/QuotesProviderVisitorFormatSpecificator.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __00c159f3_525a_41e9_8fc5_00464b6fafa3_QuotesProviderVisitorFormatSpecificator_h__ -#define __00c159f3_525a_41e9_8fc5_00464b6fafa3_QuotesProviderVisitorFormatSpecificator_h__ - -class CQuotesProviderVisitorFormatSpecificator : public CQuotesProviderVisitor -{ -public: - struct CFormatSpecificator - { - CFormatSpecificator(const tstring& rsSymbol = L"", const tstring& rsDec = L"") - : m_sSymbol(rsSymbol), m_sDesc(rsDec){} - - tstring m_sSymbol; - tstring m_sDesc; - }; - typedef std::vector TFormatSpecificators; - -public: - CQuotesProviderVisitorFormatSpecificator(); - ~CQuotesProviderVisitorFormatSpecificator(); - - const TFormatSpecificators& GetSpecificators()const; - -private: - virtual void Visit(const CQuotesProviderDukasCopy& rProvider)override; - virtual void Visit(const CQuotesProviderBase& rProvider)override; - virtual void Visit(const CQuotesProviderGoogleFinance& rProvider)override; - virtual void Visit(const CQuotesProviderYahoo& rProvider)override; - virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override; -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 deleted file mode 100644 index 462776a5b7..0000000000 --- a/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "StdAfx.h" -#include "QuotesProviderCurrencyConverter.h" - -CQuotesProviderVisitorFormater::CQuotesProviderVisitorFormater(MCONTACT hContact, wchar_t chr, int nWidth) - : m_hContact(hContact), - m_chr(chr), - m_nWidth(nWidth) -{ -} - -CQuotesProviderVisitorFormater::~CQuotesProviderVisitorFormater() -{ -} - -const tstring& CQuotesProviderVisitorFormater::GetResult()const -{ - return m_sResult; -} - -static bool get_fetch_time(MCONTACT hContact, time_t& rTime) -{ - DBVARIANT dbv; - if (db_get(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_FETCH_TIME, &dbv) || (DBVT_DWORD != dbv.type)) - return false; - - rTime = dbv.dVal; - return true; -} - -static tstring format_fetch_time(const CQuotesProviderBase&, MCONTACT 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::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) { - case '%': - case '\t': - case '\\': - m_sResult = m_chr; - break; - case 'S': - m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_PROVIDER); - break; - case 's': - m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_SYMBOL); - break; - case 'X': - m_sResult = format_fetch_time(rProvider, m_hContact, Quotes_GetTimeFormat(true)); - break; - case 'x': - m_sResult = format_fetch_time(rProvider, m_hContact, Quotes_GetDateFormat(true)); - break; - case 't': - { - tstring sFrmt = Quotes_GetDateFormat(true); - sFrmt += L" "; - sFrmt += Quotes_GetTimeFormat(true); - m_sResult = format_fetch_time(rProvider, m_hContact, sFrmt); - } - break; - case 'r': - case 'R': - FormatDoubleHelper(DB_STR_QUOTE_CURR_VALUE); - break; - case 'p': - FormatDoubleHelper(DB_STR_QUOTE_PREV_VALUE); - break; - } -} - - -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/* = L"-"*/) -{ - 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 CQuotesProviderCurrencyConverter&) -{ - switch (m_chr) { - case 'F': - m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_FROM_DESCRIPTION); - break; - case 'f': - m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_FROM_ID); - break; - case 'I': - m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_TO_DESCRIPTION); - break; - case 'i': - m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_TO_ID); - break; - } -} \ No newline at end of file diff --git a/plugins/Quotes/src/QuotesProviderVisitorFormater.h b/plugins/Quotes/src/QuotesProviderVisitorFormater.h deleted file mode 100644 index b3c55f7108..0000000000 --- a/plugins/Quotes/src/QuotesProviderVisitorFormater.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __2b5ddd05_9255_4be0_9408_e59768b70568_QuotesProviderVisitorFormater_h__ -#define __2b5ddd05_9255_4be0_9408_e59768b70568_QuotesProviderVisitorFormater_h__ - -class CQuotesProviderVisitorFormater : public CQuotesProviderVisitor -{ -public: - CQuotesProviderVisitorFormater(MCONTACT hContact, wchar_t chr, int nWidth); - ~CQuotesProviderVisitorFormater(); - - const tstring& GetResult()const; - -private: - virtual void Visit(const CQuotesProviderBase& rProvider)override; - virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override; - -private: - void FormatDoubleHelper(LPCSTR pszDbSet, const tstring sInvalid = L"-"); - // void FormatChangeValueHelper(bool bPercentage); - -private: - MCONTACT m_hContact; - wchar_t 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 deleted file mode 100644 index 1ebe6d7c0c..0000000000 --- a/plugins/Quotes/src/QuotesProviderVisitorTendency.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "stdafx.h" - -CQuotesProviderVisitorTendency::CQuotesProviderVisitorTendency(MCONTACT hContact, wchar_t chr) - : m_hContact(hContact), m_chr(chr), m_bValid(false), m_dResult(0.0) -{ -} - -void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderBase&) -{ - switch (m_chr) { - case 'r': - case 'R': - GetValue(DB_STR_QUOTE_CURR_VALUE); - break; - case 'p': - GetValue(DB_STR_QUOTE_PREV_VALUE); - 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 deleted file mode 100644 index 7567bb65c6..0000000000 --- a/plugins/Quotes/src/QuotesProviderVisitorTendency.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __AD721194_E9944366_9CF1_0307460EF32F_QuotesProviderVisitorTendency_h__ -#define __AD721194_E9944366_9CF1_0307460EF32F_QuotesProviderVisitorTendency_h__ - -class CQuotesProviderVisitorTendency : public CQuotesProviderVisitor -{ -public: - CQuotesProviderVisitorTendency(MCONTACT hContact, wchar_t chr); - - bool IsValid()const{ return m_bValid; } - double GetResult()const{ return m_dResult; } - -private: - virtual void Visit(const CQuotesProviderBase& rProvider); - -private: - void GetValue(LPCSTR pszDbKeyName); - -private: - MCONTACT m_hContact; - wchar_t m_chr; - bool m_bValid; - double m_dResult; -}; - -#endif //__AD721194_E9944366_9CF1_0307460EF32F_QuotesProviderVisitorTendency_h__ diff --git a/plugins/Quotes/src/QuotesProviders.cpp b/plugins/Quotes/src/QuotesProviders.cpp deleted file mode 100644 index e8c202e3af..0000000000 --- a/plugins/Quotes/src/QuotesProviders.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "StdAfx.h" -#include "QuotesProviderCurrencyConverter.h" - -#define LAST_RUN_VERSION "LastRunVersion" - -CQuotesProviders::CQuotesProviders() -{ - InitProviders(); -} - -CQuotesProviders::~CQuotesProviders() -{ - ClearProviders(); -} - -const CQuotesProviders::TQuotesProviders& CQuotesProviders::GetProviders()const -{ - return m_apProviders; -} - -templatevoid create_provider(CQuotesProviders::TQuotesProviders& apProviders) -{ - CQuotesProviders::TQuotesProviderPtr pProvider(new T); - if (pProvider->Init()) - apProviders.push_back(pProvider); -}; - -void CQuotesProviders::CreateProviders() -{ - create_provider(m_apProviders); -} - -void CQuotesProviders::ClearProviders() -{ - m_apProviders.clear(); -} - -void convert_contact_settings(MCONTACT hContact) -{ - WORD dwLogMode = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, static_cast(lmDisabled)); - if ((dwLogMode&lmInternalHistory) || (dwLogMode&lmExternalFile)) - db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 1); -} - -void CQuotesProviders::InitProviders() -{ - CreateProviders(); - - const WORD nCurrentVersion = 17; - WORD nVersion = db_get_w(NULL, QUOTES_MODULE_NAME, LAST_RUN_VERSION, 1); - - for (auto &hContact : Contacts(QUOTES_MODULE_NAME)) { - TQuotesProviderPtr pProvider = GetContactProviderPtr(hContact); - if (pProvider) { - pProvider->AddContact(hContact); - if (nVersion < nCurrentVersion) - convert_contact_settings(hContact); - } - } - - db_set_w(NULL, QUOTES_MODULE_NAME, LAST_RUN_VERSION, nCurrentVersion); -} - -CQuotesProviders::TQuotesProviderPtr CQuotesProviders::GetContactProviderPtr(MCONTACT hContact)const -{ - char* szProto = GetContactProto(hContact); - if (nullptr == 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 == ::mir_wstrcmpi(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 deleted file mode 100644 index 68628faa2a..0000000000 --- a/plugins/Quotes/src/QuotesProviders.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __148306d1_da2a_43df_b1ad_0cdc8ef8a79e_QuotesProviders_h__ -#define __148306d1_da2a_43df_b1ad_0cdc8ef8a79e_QuotesProviders_h__ - -class IQuotesProvider; - -class CQuotesProviders -{ -public: - typedef boost::shared_ptr TQuotesProviderPtr; - typedef std::vector TQuotesProviders; - -public: - CQuotesProviders(); - ~CQuotesProviders(); - - TQuotesProviderPtr FindProvider(const tstring& rsName)const; - TQuotesProviderPtr GetContactProviderPtr(MCONTACT 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 deleted file mode 100644 index a3d7fb8aaf..0000000000 --- a/plugins/Quotes/src/SettingsDlg.cpp +++ /dev/null @@ -1,1023 +0,0 @@ -#include "StdAfx.h" - -#define WINDOW_PREFIX_SETTINGS "Edit Settings_" - -LPCTSTR g_pszVariableQuoteName = L"%quotename%"; -LPCTSTR g_pszVariableUserProfile = L"%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 get_filter() -{ - std::vector aFilter; - LPCTSTR pszFilterParts[] = { LPGENW("Log Files (*.txt,*.log)"), L"*.txt;*.log", LPGENW("All files (*.*)"), L"*.*" }; - for (int i = 0; i < sizeof(pszFilterParts) / sizeof(pszFilterParts[0]); ++i) { - tstring sPart = TranslateW(pszFilterParts[i]); - std::copy(sPart.begin(), sPart.end(), std::back_inserter(aFilter)); - aFilter.push_back('\0'); - - } - aFilter.push_back('\0'); - return aFilter; -} -void select_log_file(HWND hDlg) -{ - std::vector aFileBuffer(_MAX_PATH * 2, '\0'); - LPTSTR pszFile = &*aFileBuffer.begin(); - - std::vector 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_plugin.getInst(); - ofn.lpstrDefExt = L"log"; - 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(MCONTACT hContact) : m_hContact(hContact), m_pPopupSettings(nullptr) {} - ~CSettingWindowParam() { delete m_pPopupSettings; } - - MCONTACT m_hContact; - CPopupSettings* m_pPopupSettings; -}; - -inline CSettingWindowParam* get_param(HWND hWnd) -{ - return reinterpret_cast(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(lp); - TranslateDialogDefault(hWnd); - ::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() ? BST_CHECKED : BST_UNCHECKED); - - ::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(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(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(::SendDlgItemMessage(hWnd, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0))); - pSettings->SetColourText(static_cast(::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: - TranslateDialogDefault(hWnd); - { - MCONTACT hContact = MCONTACT(lp); - - MWindowList 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 = db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, 0); - ::CheckDlgButton(hWnd, IDC_CHECK_CONTACT_SPECIFIC, bUseContactSpecific ? BST_CHECKED : BST_UNCHECKED); - - CAdvProviderSettings setGlobal(pProvider.get()); - // log to history - WORD dwLogMode = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, setGlobal.GetLogMode()); - UINT nCheck = (dwLogMode&lmInternalHistory) ? 1 : 0; - ::CheckDlgButton(hWnd, IDC_CHECK_INTERNAL_HISTORY, nCheck ? BST_CHECKED : BST_UNCHECKED); - - 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 = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_HISTORY_CONDITION, setGlobal.GetHistoryOnlyChangedFlag()); - ::CheckDlgButton(hWnd, IDC_CHECK_HISTORY_CONDITION, (1 == wOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); - - // log to file - nCheck = (dwLogMode&lmExternalFile) ? 1 : 0; - ::CheckDlgButton(hWnd, IDC_CHECK_EXTERNAL_FILE, nCheck ? BST_CHECKED : BST_UNCHECKED); - - 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 = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE_CONDITION, setGlobal.GetLogOnlyChangedFlag()); - ::CheckDlgButton(hWnd, IDC_CHECK_LOG_FILE_CONDITION, (1 == wOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); - - // popup - nCheck = (dwLogMode&lmPopup) ? 1 : 0; - ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP, nCheck ? BST_CHECKED : BST_UNCHECKED); - 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 == db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_CONDITION, setGlobal.GetShowPopupIfValueChangedFlag()); - ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED, (bOnlyIfChanged) ? BST_CHECKED : BST_UNCHECKED); - - update_all_controls(hWnd); - - CSettingWindowParam* pParam = new CSettingWindowParam(hContact); - ::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast(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_plugin.getInst(), - MAKEINTRESOURCE(IDD_DIALOG_POPUP), - hWnd, - EditPopupSettingsDlgProc, reinterpret_cast(pParam->m_pPopupSettings)); - } - break; - - case IDOK: - { - CSettingWindowParam* pParam = get_param(hWnd); - MCONTACT 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)); - - db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_CONTACT_SPEC_SETTINGS, bUseContactSpec); - db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG, nLogMode); - db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE_CONDITION, nIfChangedFile); - db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_HISTORY_CONDITION, nIfChangedHistory); - db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_CONDITION, bIfChangedPopup); - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_LOG_FILE, sLogFile.c_str()); - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_LOG_FILE, sLogFileFormat.c_str()); - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_FORMAT_HISTORY, sHistoryFormat.c_str()); - db_set_ws(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); - - MWindowList 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(MCONTACT hContact) -{ - MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_SETTINGS, true); - assert(hWL); - HWND hWnd = WindowList_Find(hWL, hContact); - if (nullptr != hWnd) { - SetForegroundWindow(hWnd); - SetFocus(hWnd); - } - else CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTACT_SETTINGS), nullptr, EditSettingsPerContactDlgProc, LPARAM(hContact)); -} - -////////////////////////////////////////////////////////////////////////// - -INT_PTR CALLBACK EditSettingsPerProviderDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) -{ - switch (msg) { - case WM_INITDIALOG: - { - TranslateDialogDefault(hWnd); - CAdvProviderSettings* pAdvSettings = reinterpret_cast(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 ? BST_CHECKED : BST_UNCHECKED); - ::SetDlgItemText(hWnd, IDC_EDIT_HISTORY_FORMAT, pAdvSettings->GetHistoryFormat().c_str()); - ::CheckDlgButton(hWnd, IDC_CHECK_HISTORY_CONDITION, (pAdvSettings->GetHistoryOnlyChangedFlag()) ? BST_CHECKED : BST_UNCHECKED); - - // log to file - nCheck = (dwLogMode&lmExternalFile) ? 1 : 0; - ::CheckDlgButton(hWnd, IDC_CHECK_EXTERNAL_FILE, nCheck ? BST_CHECKED : BST_UNCHECKED); - ::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, (pAdvSettings->GetLogOnlyChangedFlag()) ? BST_CHECKED : BST_UNCHECKED); - - update_file_controls(hWnd); - update_history_controls(hWnd); - - // popup - nCheck = (dwLogMode&lmPopup) ? 1 : 0; - ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP, nCheck ? BST_CHECKED : BST_UNCHECKED); - ::SetDlgItemText(hWnd, IDC_EDIT_POPUP_FORMAT, pAdvSettings->GetPopupFormat().c_str()); - ::CheckDlgButton(hWnd, IDC_CHECK_SHOW_POPUP_ONLY_VALUE_CHANGED, (pAdvSettings->GetShowPopupIfValueChangedFlag()) ? BST_CHECKED : BST_UNCHECKED); - - if (true == enable_popup_controls(hWnd)) - update_popup_controls(hWnd); - - ::SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast(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(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(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(GetWindowLongPtr(hWnd, GWLP_USERDATA)); - DialogBoxParam(g_plugin.getInst(), - MAKEINTRESOURCE(IDD_DIALOG_POPUP), - hWnd, - EditPopupSettingsDlgProc, reinterpret_cast(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 = db_get_w(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogMode, static_cast(lmDisabled)); - m_sFormatHistory = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbHistoryFormat, visitor.m_pszDefHistoryFormat); - m_bIsOnlyChangedHistory = 1 == db_get_b(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 += L"\\Quotes\\"; - m_sLogFileName += g_pszVariableQuoteName; - m_sLogFileName += L".log"; - } - - m_sFormatLogFile = Quotes_DBGetStringT(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogFormat, visitor.m_pszDefLogFileFormat); - m_bIsOnlyChangedLogFile = (1 == db_get_b(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 == db_get_b(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); - - db_set_w(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogMode, m_wLogMode); - db_set_ws(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbHistoryFormat, m_sFormatHistory.c_str()); - db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbHistoryCondition, m_bIsOnlyChangedHistory); - db_set_ws(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogFile, m_sLogFileName.c_str()); - db_set_ws(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogFormat, m_sFormatLogFile.c_str()); - db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbLogCondition, m_bIsOnlyChangedLogFile); - db_set_ws(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupFormat, m_sPopupFormat.c_str()); - db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupCondition, m_bShowPopupIfValueChanged); - - if (nullptr != m_pPopupSettings) { - db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupColourMode, static_cast(m_pPopupSettings->GetColourMode())); - db_set_dw(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupBkColour, m_pPopupSettings->GetColourBk()); - db_set_dw(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupTextColour, m_pPopupSettings->GetColourText()); - db_set_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupDelayMode, static_cast(m_pPopupSettings->GetDelayMode())); - db_set_w(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupDelayTimeout, m_pPopupSettings->GetDelayTimeout()); - db_set_b(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 = db_get_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupColourMode, static_cast(m_modeColour)); - if (m >= colourDefault && m <= colourUserDefined) - m_modeColour = static_cast(m); - - m_rgbBkg = db_get_dw(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupBkColour, m_rgbBkg); - m_rgbText = db_get_dw(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupTextColour, m_rgbText); - - m = db_get_b(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupDelayMode, static_cast(m_modeDelay)); - if (m >= delayFromPopup && m <= delayPermanent) { - m_modeDelay = static_cast(m); - } - m_wDelay = db_get_w(NULL, QUOTES_PROTOCOL_NAME, visitor.m_pszDbPopupDelayTimeout, m_wDelay); - m_bUseHistory = (1 == db_get_b(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(MCONTACT hContact) -{ - BYTE m = db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_MODE, static_cast(m_modeColour)); - if (m >= CPopupSettings::colourDefault && m <= CPopupSettings::colourUserDefined) { - m_modeColour = static_cast(m); - } - - m_rgbBkg = db_get_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_BK, m_rgbBkg); - m_rgbText = db_get_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_TEXT, m_rgbText); - - m = db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_DELAY_MODE, static_cast(m_modeDelay)); - if (m >= CPopupSettings::delayFromPopup && m <= CPopupSettings::delayPermanent) { - m_modeDelay = static_cast(m); - } - m_wDelay = db_get_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_DELAY_TIMEOUT, m_wDelay); - m_bUseHistory = 1 == db_get_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_HISTORY_FLAG, m_bUseHistory); -} - -void CPopupSettings::SaveForContact(MCONTACT hContact)const -{ - db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_MODE, static_cast(m_modeColour)); - db_set_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_BK, m_rgbBkg); - db_set_dw(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_COLOUR_TEXT, m_rgbText); - db_set_b(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_DELAY_MODE, static_cast(m_modeDelay)); - db_set_w(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_POPUP_DELAY_TIMEOUT, m_wDelay); - db_set_b(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_plugin.getInst(), - MAKEINTRESOURCE(IDD_PROVIDER_ADV_SETTINGS), - hWndParent, - EditSettingsPerProviderDlgProc, - reinterpret_cast(pAdvSettings))); -} - -static void replace_invalid_char(tstring::value_type& rChar, tstring::value_type repl) -{ - static const wchar_t charInvalidSigns[] = { '\\', '/', ':', '*', '?', '\"', '<', '>', '|' }; - - 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) -{ - 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, '_')); - sPath.replace(n, mir_wstrlen(g_pszVariableQuoteName), s.c_str()); - } - } - - if (nFlags & glfnResolveUserProfile) { - wchar_t *ptszParsedName = Utils_ReplaceVarsW(sPath.c_str()); - if (ptszParsedName) { - sPath = ptszParsedName; - mir_free(ptszParsedName); - } - } - - return sPath; -} - -tstring GetContactLogFileName(MCONTACT hContact) -{ - tstring result; - - const CQuotesProviders::TQuotesProviderPtr& pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact); - if (pProvider) { - tstring sPattern; - bool bUseContactSpecific = (db_get_b(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(MCONTACT 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 deleted file mode 100644 index 4209804d2e..0000000000 --- a/plugins/Quotes/src/SettingsDlg.h +++ /dev/null @@ -1,118 +0,0 @@ -#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(MCONTACT hContact); - void SaveForContact(MCONTACT 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(MCONTACT 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(MCONTACT hContact); -tstring GetContactName(MCONTACT hContact); - -#endif //__E211E4D9_383C_43BE_A787_7EF1D585B90D_SettingsDlg_h__ - diff --git a/plugins/Quotes/src/WinCtrlHelper.cpp b/plugins/Quotes/src/WinCtrlHelper.cpp deleted file mode 100644 index 300612dcf1..0000000000 --- a/plugins/Quotes/src/WinCtrlHelper.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "stdafx.h" - -static INT_PTR CALLBACK VariableListDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) -{ - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hWnd); - { - const IQuotesProvider* pProvider = reinterpret_cast(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' << spec.m_sDesc << L"\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_plugin.getInst(), - MAKEINTRESOURCE(IDD_DIALOG_VARIABLE_LIST), - hwndParent, - VariableListDlgProc, - reinterpret_cast(pProvider)); -} diff --git a/plugins/Quotes/src/WinCtrlHelper.h b/plugins/Quotes/src/WinCtrlHelper.h deleted file mode 100644 index 1c5777d45d..0000000000 --- a/plugins/Quotes/src/WinCtrlHelper.h +++ /dev/null @@ -1,37 +0,0 @@ -#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 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/XMLEngineMI.cpp b/plugins/Quotes/src/XMLEngineMI.cpp deleted file mode 100644 index 413ed619dd..0000000000 --- a/plugins/Quotes/src/XMLEngineMI.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include "StdAfx.h" - -class CXMLNodeMI : public IXMLNode, private boost::noncopyable -{ -public: - typedef boost::shared_ptr TXMLNodePtr; - -public: - explicit CXMLNodeMI(HXML hXMl, bool bDestroy = false) : m_hXML(hXMl), m_bDestroy(bDestroy) - { - assert(m_hXML); - } - - virtual ~CXMLNodeMI() - { - if (m_bDestroy) - xmlDestroyNode(m_hXML); - } - - virtual size_t GetChildCount()const - { - return xmlGetChildCount(m_hXML); - } - - virtual TXMLNodePtr GetChildNode(size_t nIndex)const - { - HXML h = xmlGetChild(m_hXML, (int)nIndex); - if (h) - return TXMLNodePtr(new CXMLNodeMI(h)); - - return TXMLNodePtr(); - } - - virtual tstring GetText()const - { - tstring sResult; - LPCTSTR psz = xmlGetText(m_hXML); - if (psz) - sResult = psz; - - return sResult; - } - - virtual tstring GetName()const - { - tstring sResult; - LPCTSTR psz = xmlGetName(m_hXML); - if (psz) - sResult = psz; - - return sResult; - } - - virtual bool AddChild(const TXMLNodePtr& pNode) - { - CXMLNodeMI* pXML = dynamic_cast(pNode.get()); - if (pXML) { - xmlAddChild2(pXML->m_hXML, m_hXML); - pXML->m_bDestroy = false; - return true; - } - - return false; - } - - virtual bool AddAttribute(const tstring& rsName, const tstring& rsValue) - { - xmlAddAttr(m_hXML, rsName.c_str(), rsValue.c_str()); - return true; - } - - virtual tstring GetAttributeValue(const tstring& rsAttrName) - { - LPCTSTR pszValue = xmlGetAttrValue(m_hXML, rsAttrName.c_str()); - return ((nullptr != pszValue) ? tstring(pszValue) : tstring()); - } - - virtual void Write(tostream& o)const - { - ptrW ss(xmlToString(m_hXML, nullptr)); - if (ss != NULL) - o << (char*)T2Utf(ss); - } - -private: - HXML m_hXML; - bool m_bDestroy; -}; - -CXMLEngineMI::CXMLEngineMI() -{ -} - -CXMLEngineMI::~CXMLEngineMI() -{ -} - -IXMLNode::TXMLNodePtr CXMLEngineMI::LoadFile(const tstring& rsFileName)const -{ - IXMLNode::TXMLNodePtr pResult; - FILE *stream; - if (0 == ::_tfopen_s(&stream, rsFileName.c_str(), L"r")) { - struct _stat st; - if (-1 != ::_fstat(::_fileno(stream), &st)) { - std::vector 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(st.st_size)) { - pBuffer[cBytes] = '\0'; - - int nLen = (int)cBytes; - ptrW ss(mir_utf8decodeW(pBuffer)); - if (ss) { - HXML h = xmlParseString(ss, &nLen, nullptr); - if (h) - pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h, true)); - } - } - } - ::fclose(stream); - } - - return pResult; -} - -static IXMLNode::TXMLNodePtr create_node(const tstring& rsName, const tstring& rsText, bool bIsDecl) -{ - IXMLNode::TXMLNodePtr pResult; - HXML h = xmlCreateNode(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(pNode.get()); - if (pXML) { - tofstream file(rsFileName.c_str()); - if (file.good()) { - IXMLNode::TXMLNodePtr pRoot(create_node(L"xml", tstring(), true)); - if (pRoot) { - pRoot->AddAttribute(L"version", L"1.0"); - pRoot->AddAttribute(L"encoding", L"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); -} diff --git a/plugins/Quotes/src/XMLEngineMI.h b/plugins/Quotes/src/XMLEngineMI.h deleted file mode 100644 index d800b20f51..0000000000 --- a/plugins/Quotes/src/XMLEngineMI.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __0c3d1da4_92b7_431c_83e5_f998cd513f0d_XMLEngineMI_h__ -#define __0c3d1da4_92b7_431c_83e5_f998cd513f0d_XMLEngineMI_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 deleted file mode 100644 index 0cbfb68af1..0000000000 --- a/plugins/Quotes/src/resource.h +++ /dev/null @@ -1,100 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by C:\Code\miranda-ng-from-github\plugins\Quotes\res\Forex.rc -// -#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_DIALOG_QUOTE_INFO_1 118 -#define IDI_ICON_REFRESH 118 -#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 IDI_ICON_MAIN1 122 -#define IDI_ICON_DISABLED 122 -#define IDD_DIALOG_VARIABLE_LIST 123 -#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_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_EDIT_FROM2 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 125 -#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.cxx b/plugins/Quotes/src/stdafx.cxx deleted file mode 100644 index 6ef3c8471b..0000000000 --- a/plugins/Quotes/src/stdafx.cxx +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright (C) 2012-18 Miranda NG team (https://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 . -*/ - -#include "stdafx.h" diff --git a/plugins/Quotes/src/stdafx.h b/plugins/Quotes/src/stdafx.h deleted file mode 100644 index fe54397d9f..0000000000 --- a/plugins/Quotes/src/stdafx.h +++ /dev/null @@ -1,119 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -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 std::string quotes_t2a(const wchar_t* t) -{ - std::string s; - char* p = mir_u2a(t); - if (p) { - s = p; - mir_free(p); - } - return s; -} - -inline tstring quotes_a2t(const char* s) -{ - tstring t; - wchar_t* p = mir_a2u(s); - if (p) { - t = p; - mir_free(p); - } - return t; -} - -#include "resource.h" -#include "version.h" -#include "IconLib.h" -#include "QuoteInfoDlg.h" -#include "ModuleInfo.h" -#include "DBUtils.h" -#include "HTTPSession.h" -#include "CurrencyConverter.h" -#include "WinCtrlHelper.h" -#include "ImportExport.h" -#include "ComHelper.h" -#include "Log.h" -#include "CommonOptionDlg.h" -#include "EconomicRateInfo.h" -#include "SettingsDlg.h" -#include "CreateFilePath.h" -#include "Locale.h" -#include "ExtraImages.h" -#include "IsWithinAccuracy.h" -#include "IQuotesProvider.h" -#include "QuotesProviders.h" -#include "QuotesProviderBase.h" -#include "QuotesProviderVisitor.h" -#include "QuotesProviderVisitorDbSettings.h" -#include "QuotesProviderVisitorFormater.h" -#include "QuotesProviderVisitorTendency.h" -#include "QuotesProviderVisitorFormatSpecificator.h" -#define CHART_IMPLEMENT -#ifdef CHART_IMPLEMENT -#include "QuoteChart.h" -#include "Chart.h" -#endif -#include "IHTMLParser.h" -#include "IHTMLEngine.h" -#include "HTMLParserMS.h" -#include "IXMLEngine.h" -#include "XMLEngineMI.h" - -struct CMPlugin : public PLUGIN -{ - CMPlugin(); - - int Load() override; - int Unload() override; -}; diff --git a/plugins/Quotes/src/version.h b/plugins/Quotes/src/version.h deleted file mode 100644 index 94b91a4834..0000000000 --- a/plugins/Quotes/src/version.h +++ /dev/null @@ -1,13 +0,0 @@ -#define __MAJOR_VERSION 0 -#define __MINOR_VERSION 1 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 101 - -#include - -#define __PLUGIN_NAME "Currency Rates" -#define __FILENAME "Quotes.dll" -#define __DESCRIPTION "Shows currency rates." -#define __AUTHOR "Dioksin" -#define __AUTHORWEB "https://miranda-ng.org/p/Quotes/" -#define __COPYRIGHT "" -- cgit v1.2.3