From c40552cd30b3e028abda8e01d9c0dd2ed6a03455 Mon Sep 17 00:00:00 2001 From: Dioksin Date: Tue, 24 Jul 2018 17:51:36 +0300 Subject: Quotes plugin redesign to use only exchange rates --- plugins/Quotes/docs/Utility/DukasCopy.py | 48 - plugins/Quotes/docs/Utility/Dukascopy.xml | 1635 -------------------- plugins/Quotes/docs/Utility/GoogleFinance.xml | 7 - plugins/Quotes/docs/Utility/Quotes_Readme.txt | 112 -- plugins/Quotes/docs/Utility/Yahoo.xml | 7 - plugins/Quotes/res/Forex.rc | 63 - plugins/Quotes/src/EconomicRateInfo.h | 2 +- plugins/Quotes/src/Forex.cpp | 16 +- plugins/Quotes/src/ImportExport.cpp | 16 - plugins/Quotes/src/OptionDukasCopy.cpp | 319 ---- plugins/Quotes/src/OptionDukasCopy.h | 8 - plugins/Quotes/src/QuotesProviderDukasCopy.cpp | 226 --- plugins/Quotes/src/QuotesProviderDukasCopy.h | 35 - plugins/Quotes/src/QuotesProviderFinance.cpp | 265 ---- plugins/Quotes/src/QuotesProviderFinance.h | 19 - plugins/Quotes/src/QuotesProviderGoogleFinance.cpp | 283 ---- plugins/Quotes/src/QuotesProviderGoogleFinance.h | 23 - .../Quotes/src/QuotesProviderVisitorDbSettings.cpp | 83 - .../Quotes/src/QuotesProviderVisitorDbSettings.h | 3 - .../Quotes/src/QuotesProviderVisitorFormater.cpp | 47 - plugins/Quotes/src/QuotesProviderVisitorFormater.h | 3 - .../Quotes/src/QuotesProviderVisitorTendency.cpp | 36 - plugins/Quotes/src/QuotesProviderVisitorTendency.h | 2 - plugins/Quotes/src/QuotesProviderYahoo.cpp | 149 -- plugins/Quotes/src/QuotesProviderYahoo.h | 17 - plugins/Quotes/src/QuotesProviders.cpp | 3 - plugins/Quotes/src/resource.h | 4 - plugins/Quotes/src/stdafx.h | 5 - plugins/Quotes/src/version.h | 4 +- 29 files changed, 11 insertions(+), 3429 deletions(-) delete mode 100644 plugins/Quotes/docs/Utility/DukasCopy.py delete mode 100644 plugins/Quotes/docs/Utility/Dukascopy.xml delete mode 100644 plugins/Quotes/docs/Utility/GoogleFinance.xml delete mode 100644 plugins/Quotes/docs/Utility/Quotes_Readme.txt delete mode 100644 plugins/Quotes/docs/Utility/Yahoo.xml delete mode 100644 plugins/Quotes/src/OptionDukasCopy.cpp delete mode 100644 plugins/Quotes/src/OptionDukasCopy.h delete mode 100644 plugins/Quotes/src/QuotesProviderDukasCopy.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderDukasCopy.h delete mode 100644 plugins/Quotes/src/QuotesProviderFinance.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderFinance.h delete mode 100644 plugins/Quotes/src/QuotesProviderGoogleFinance.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderGoogleFinance.h delete mode 100644 plugins/Quotes/src/QuotesProviderYahoo.cpp delete mode 100644 plugins/Quotes/src/QuotesProviderYahoo.h (limited to 'plugins/Quotes') diff --git a/plugins/Quotes/docs/Utility/DukasCopy.py b/plugins/Quotes/docs/Utility/DukasCopy.py deleted file mode 100644 index 2d12d1c4ec..0000000000 --- a/plugins/Quotes/docs/Utility/DukasCopy.py +++ /dev/null @@ -1,48 +0,0 @@ -from html.parser import HTMLParser -import sys - -class MyHTMLParser(HTMLParser): - def __init__(self, in_fn,out_fn): - HTMLParser.__init__(self) - f_in = open(in_fn,'r') - self.quote = 0 - self.descr = '' - self.f_out = open(out_fn,'w') - self.feed(f_in.read()) - f_in.close() - self.f_out.close() - - def handle_starttag(self, tag, attrs): - #print ("start of a %s" % tag) - #print (attrs) - self.start = 1 - if tag == 'input': - self.f_out.write('\n') - for k in attrs: - if k[0] == 'stname': - self.f_out.write('\n\t%s'%k[1]) - if k[0] == 'stid': - self.f_out.write('\n\t%s'%k[1]) - self.quote = 1 - - - def handle_endtag(self, tag): - self.start = 0 - if tag == 'tr' and self.quote == 1: - if self.descr: - self.f_out.write('\n\t%s'%self.descr) - self.f_out.write('\n') - self.quote = 0 - self.descr = 1 - #print ("end of a %s" % tag) - - def handle_data(self, data): - if self.start == 1: - self.descr = data - #print ("Data %s" % self.descr) - - - -parser = MyHTMLParser(sys.argv[1],sys.argv[2]) -parser.close() - \ No newline at end of file diff --git a/plugins/Quotes/docs/Utility/Dukascopy.xml b/plugins/Quotes/docs/Utility/Dukascopy.xml deleted file mode 100644 index 92890888b9..0000000000 --- a/plugins/Quotes/docs/Utility/Dukascopy.xml +++ /dev/null @@ -1,1635 +0,0 @@ - - - - Dukascopy Swiss Forex Group - http://www.dukascopy.com - http://freeserv.dukascopy.com/qt/?&STOCKS= - - - -
- European Stocks - - - 127 - BA - BAE Systems - - - 130 - BKIR - Bank of Ireland - - - 131 - BP - British Petroleum - - - 138 - SBRY - Sainsbury - - - 142 - AZN - Astrazeneca - - - 145 - CNA - Centrica - - - 153 - MKS - Spencer - - - 155 - RTR - Reuters Group - - - 156 - RR - Rolls Royce - - - 158 - TSCO - Tesco - - - 165 - ALV - Alliaz AG - - - 167 - BAY - Bayer AG - - - 169 - CBK - Commerzbank AG - - - 171 - DBK - Deutsche Bank AG - - - 177 - SIE - Siemens AG - - - 178 - TKA - Thyssenkrupp AG - - - 179 - VOW - Volkswagen AG - - - 183 - FTE - France Telecom - - - 191 - OR - LOreal - - - 192 - ML - Michelin - - - 193 - RNO - Renault - - - 195 - UG - Peugeot SA - - - 198 - LG - Lafarge - - - 206 - PIN - Pinguin - - - 213 - RBACW - Rabo Agaath Bank - - - 221 - ABBN - ABB Finance - - - 222 - ADEN - Adecco SA - - - 224 - RUKN - Swiss Reinsurance - - - 232 - GFC - Gecina - - - 234 - VK - Vallourec - - - 235 - FLE - Fleury Michon - - - 242 - NEX - National Express Group - - - 245 - IMT - Imperial Tobacco - - - 338 - Pseudo - Pseudo - - - 340 - Pseudo1 - Pseudo1 - - - 321 - ROS - OAO Rostelecom - - - 325 - FIA - Fiat S.p.A. - - - 326 - E - Eni S.p.A. - - - 327 - EN - Enel S.p.A. - - - 152 - LLOY - Lloyds TSB Bank - - - 226 - AKZA - Akzo Nobel NV - - - 135 - BSY - British Sky Broadcast - - - 144 - CW - Wireless - - - 146 - GSK - Glaxosmithkline - - - 149 - HSBA - HSBC Bank - - - 151 - KGF - Kingfisher - - - 166 - BAS - BASF AG - - - 172 - DPW - Deutsche Post AG - - - 173 - DTE - Deutsche Telecom - - - 249 - CA - Carrefour - - - 218 - NESN - Nestle SA - - - 219 - UBSN - UBS AG - - - 229 - DIE - DIeteren Trading - - - 237 - GAM - Gaumont - - - 238 - AGE - AGFA Gevaert NV - - - 243 - CBRY - Cadbury Schweppes - - - 246 - MLW - Merrill Lynch World - - - 248 - MASN - Micronas Semiconductors - - - 255 - ARE - Groupe Ares - - - 200 - DELB - Delhaize Group - - - 215 - PHIA - Philips Electronics - - - 216 - CSGN - Credit Suisse Groupe CAP - - - 772 - VOD - VODAFONE - - - 773 - BA - British Airways - - -
- - - -
- US Stocks - - - - 99 - INTC - Intel Corp. - - - 98 - QCOM - QUALCOMM Incorporated - - - 97 - CSCO - Cisco Systems, Inc. - - - 96 - AMGN - Amgen Inc. - - - 94 - ORCL - Oracle Corp. - - - 92 - MXIM - Maxim Integrated Products, Inc. - - - 85 - SBUX - Starbucks Corp. - - - 82 - CTAS - Cintas Corp. - - - 81 - BMET - Biomet, Inc. - - - 80 - PAYX - Paychex, Inc - - - 79 - XLNX - Xilinx, Inc. - - - 75 - FISV - Fiserv, Inc. - - - 69 - COST - Costco Wholesale Corp. - - - 64 - PCAR - PACCAR Inc. - - - 62 - ADBE - Adobe Systems Incorporated - - - 61 - SPLS - Staples, Inc. - - - 33 - T - T Corp. - - - 31 - AA - Alcoa - - - 32 - AXP - American Express Co. - - - 34 - BA - The Boeing Co. - - - 35 - CAT - Caterpillar Inc. - - - 36 - C - Citigroup, Inc. - - - 37 - KO - The Coca-Cola Co. - - - 40 - EK - Eastman Kodak Co. - - - 43 - GM - General Motors Corp. - - - 49 - JNJ - Johnson - - - 50 - MCD - McDonald's Corp. - - - 51 - MRK - Merck Company, Inc. - - - 52 - MMM - Manufacturing Co. - - - 53 - JPM - J.P. Morgan Company Inc. - - - 57 - UTX - United Technologies Corp. - - - 58 - WMT - Wal-Mart Stores, Inc. - - - 104 - CDWC - CDW Computer Centers, Inc. - - - 116 - SGA - Saga Communications, Inc. - - - 118 - MPP - Medical Technology System - - - 119 - ACU - Acme United Corp. - - - 128 - BAL - Barclays - - - 141 - RBS - Royal Bank of Scotland - - - 250 - BMO - Bank of Montreal - - - 254 - TRP - TransCanada PipeLines Ltd - - - 329 - QQQQ - TransCanada PipeLines Ltd - - - 330 - DIA - TransCanada PipeLines Ltd - - - 332 - SMH - TransCanada PipeLines Ltd - - - 122 - DW - Drew Industries, Inc. - - - 123 - FPU - Florida Public Utilities - - - 280 - NOK - Nokia - - - 281 - UPM - UPM-Kymmene OYJ - - - 282 - SEO - Stora Enso OYJ - - - 287 - BEAS - BEA System INC. - - - 288 - BRCD - Brocade Communication System Inc. - - - 291 - CEPH - Cephalon Inc. - - - 292 - CIEN - Ciena Corp. - - - 293 - CHKP - Checkpoint Software - - - 295 - DISH - Echostar Communications - - - 100 - MSFT - Microsoft Corp. - - - 95 - DELL - Dell Computer Corp. - - - 91 - EBAY - eBay Inc. - - - 88 - BBBY - Beyond Inc. - - - 87 - LLTC - Linear Technology Corp. - - - 84 - IACI - USA Interactive - - - 76 - KLAC - KLA-Tencor Corp. - - - 70 - APOL - Apollo Group, Inc. - - - 68 - TEVA - Teva Pharmaceutical Industries Limited - - - 65 - ALTR - Altera Corp. - - - 63 - SYMC - Symantec Corp. - - - 42 - GE - General Electric Co. - - - 44 - HPQ - Hewlett-Packard Co. - - - 46 - HON - Honeywell International Inc. - - - 47 - IBM - International Business Machines Corp. - - - 54 - MO - Morris Companies, Inc. - - - 55 - PG - Gamble Co. - - - 103 - FLEX - Flextronics International Ltd. - - - 115 - OHB - Orleans Homebuilders - - - 251 - BNS - Bank of Nova Scotia - - - 252 - BCE - BCE, Inc. - - - 331 - SPY - BCE, Inc. - - - 286 - AMCC - Applied Micro Circuit Corp. - - - 294 - CTXS - Citrix Systems - - - 738 - MCHP - Microchip Technology - - - 747 - NTE - NAM TAI Electronics - - - 759 - TTWO - Take-Two Interactive Software - - - 700 - ADI - Analog Devices - - - 701 - ADTN - Adtran - - - 702 - AIG - American International Group - - - 703 - APA - Apache Corp - - - 704 - BAC - Bank of America Corp - - - 705 - BBY - Best Buy Co - - - 706 - BIIB - Biogen Idec - - - 707 - BOBJ - Business Objects SA - - - 708 - BRCM - Broadcom Corp - - - 709 - CALM - Cal-Maine Foods - - - 710 - CCU - Clear Channel Communications - - - 711 - COF - Capital One Financial Corp - - - 714 - DLTR - Dollar Tree Stores - - - 716 - FITB - Fifth Third Bancorp - - - 717 - FNM - Fannie Mae - - - 718 - FRE - Freddie Mac - - - 719 - FRX - Forest Laboratories - - - 720 - GCI - Gannett Co - - - 721 - GD - General Dynamics Corp - - - 724 - GS - Goldman Sachs Group - - - 726 - HOV - Hovnanian Enterprises - - - 727 - ICOS - ICOS Corp - - - 728 - IMCL - ImClone Systems - - - 731 - KSS - Kohl's Corp - - - 732 - LEH - Lehman Brothers Holdings Inc - - - 734 - LLY - Co - - - 737 - LXK - Lexmark International - - - 743 - NEM - Newmont Mining Corp - - - 744 - NFLX - NetFlix - - - 745 - NOC - Northrop Grumman Corp - - - 748 - NTES - Netease.com - - - 749 - NVLS - Novellus Systems - - - 750 - OVTI - Omnivision Technologies - - - 753 - RMBS - Rambus - - - 755 - SINA - Sina Corp - - - 756 - SNDK - Sandisk Corp - - - 757 - SNPS - Synopsys - - - 758 - SOHU - Sohu.com - - - 760 - UTSI - Utstarcom - - - 762 - WLP - WellPoint Health Networks - - - 763 - WY - Weyerhaeuser Co - - - 764 - XMSR - XM Satellite Radio Holdings - - - 765 - YHOO - Yahoo! - - - 38 - DIS - The Walt Disney Co. - - - 39 - DD - E.I. duPont de Nemours Co. - - - 78 - ERTS - Electronic Arts Inc. - - - 77 - GENZ - Genzyme General - - - 766 - GOOGL - Google! - - - 45 - HD - Home Depot Inc. - - - 48 - IP - International Paper Co. - - - 121 - DLA - Delta Apparel Inc. - - - 86 - AMAT - Applied Materials, Inc. - - - 41 - XOM - Exxon Mobil Corp. - - - 102 - AMZN - Amazon.com, Inc. - - - 729 - IVGN - Invitrogen Corp - - - 736 - LRCX - Lam Research Corp - - - 712 - CTSH - Cognizant Technology Solutions Corp - - - 713 - DHI - DR Horton - - - 740 - MNST - Monster Worldwide - - -
- - - - -
- Indices - -
- on the basis of US Indices - - - 22 - SandP-500 - P 500 - - - 23 - NQ-100 - CFD statistics for Nasdaq 100 - - - 28 - Nyssee-comp - CFD statistics for NYSE Composite - - - 21 - D&J-Ind - CFD statistics for Dow Jones Industrial Average - - - 26 - NQ-comp - CFD statistics for Nasdaq Composite - - - 27 - AMMEKS - CFD statistics for AMEX - - - 768 - VIXX - Volatility Index - - - 769 - 10Y note - 10Y note yield - - - 770 - 5Y note - 5Y note yield - - - 771 - ST note - Short term note yield - - -
- -
- on the basis of European Indices - - - 24 - CAAC-40 - CFD statistics for CAC 40 - - - 25 - DAAX - CFD statistics for XETRA DAX - - - 225 - SWMI - CFD statistics for SMI - - - 345 - Futsee-100 - CFD statistics for FTSE - - - 503 - DJE50XX - CFD statistics for DJ Euro Stoxx50 - - -
- -
- on the basis of Asian Indices - - - 500 - N225Jap - CFD statistics for Nikkei 225 - - - 501 - SC-Korea - CFD statistics for KOSPI - - - 502 - H-Kong - CFD statistics for Hang Seng - - -
-
- - -
- FOREX - -
- Major - - - 3 - USD/CHF - USD/CHF - - - 9 - USD/CAD - USD/CAD - - - 10 - AUD/USD - AUD/USD - - - 11 - NZD/USD - NZD/USD - - - 1 - EUR/USD - EUR/USD - - - 2 - GBP/USD - GBP/USD - - -
- -
- Other Currencies - - - - 12 - USD/NOK - USD/NOK - - - 13 - USD/DKK - USD/DKK - - - 14 - USD/SEK - USD/SEK - - - 15 - USD/SAR - USD/SAR - - - 507 - USD/EUR - USD/EUR - - - 508 - USD/GBP - USD/GBP - - - 512 - JPY/USD - JPY/USD - - - 513 - JPY/EUR - JPY/EUR - - - 516 - GBP/EUR - GBP/EUR - - - 519 - CHF/USD - CHF/USD - - - 521 - CHF/JPY - CHF/JPY - - - 514 - JPY/GBP - JPY/GBP - - - 515 - JPY/CHF - JPY/CHF - - - 520 - CHF/EUR - CHF/EUR - - - 522 - CHF/GBP - CHF/GBP - - - 74 - USD/ZAR - USD/ZAR - - - 30 - USD/SGD - USD/SGD - - - 29 - EUR/SEK - EUR/SEK - -
- -
- Crosses - - - - 509 - EUR/JPY - EUR/JPY - - - 510 - EUR/GBP - EUR/GBP - - - 511 - EUR/CHF - EUR/CHF - - - 517 - GBP/JPY - GBP/JPY - - - 518 - GBP/CHF - GBP/CHF - - - 60 - AUD/JPY - AUD/JPY - - - 767 - CAD/JPY - CAD/JPY - -
- -
- Other Arab Currencies - - - - 4 - USD/JPY - USD/JPY - - - 5 - USD/EGP - USD/EGP - - - 6 - USD/JOD - USD/JOD - - - 7 - USD/QAR - USD/QAR - - - 16 - USD/TND - USD/TND - - - 17 - EUR/EGP - EUR/EGP - - - 18 - EUR/JOD - EUR/JOD - - - 19 - EUR/QAR - EUR/QAR - - - 59 - EUR/TND - EUR/TND - - - 523 - EGP/USD - EGP/USD - - - 524 - EGP/EUR - EGP/EUR - - - 527 - EGP/CHF - EGP/CHF - - - 528 - JOD/USD - JOD/USD - - - 529 - JOD/EUR - JOD/EUR - - - 530 - JOD/JPY - JOD/JPY - - - 531 - JOD/GBP - JOD/GBP - - - 533 - JOD/CHF - JOD/CHF - - - 534 - QAR/EUR - QAR/EUR - - - 535 - QAR/USD - QAR/USD - - - 536 - QAR/JPY - QAR/JPY - - - 537 - QAR/GBP - QAR/GBP - - - 538 - QAR/CHF - QAR/CHF - - - 539 - SAR/USD - SAR/USD - - - 540 - SAR/EUR - SAR/EUR - - - 541 - SAR/JPY - SAR/JPY - - - 542 - SAR/GBP - SAR/GBP - - - 543 - GBP/SAR - GBP/SAR - - - 544 - SAR/CHF - SAR/CHF - - - 545 - TND/USD - TND/USD - - - 546 - TND/EUR - TND/EUR - - - 547 - TND/JPY - TND/JPY - - - 548 - TND/GBP - TND/GBP - - - 549 - TND/CHF - TND/CHF - - - 20 - EUR/SAR - EUR/SAR - - - 525 - EGP/JPY - EGP/JPY - - - 526 - EGP/GBP - EGP/GBP - - - 532 - GBP/JOD - GBP/JOD - - -
-
- - -
- Asian Stocks - - - - 307 - TSM - Taiwan Semiconductor Mfg - - - 308 - SNE - Sony Corp. - - - 310 - MITSY - Mitsui Co., Ltd. - - - 314 - NSANY - Nissan Motor Co., Ltd. - - - 317 - CAJ - Canon, Inc. - - - 323 - CHL - China Mobile Limited - - - 324 - SNP - Chemical Corp. - - - 313 - HMC - Honda Motor Co., Ltd. - - - 315 - MC - Matsushita Electric Ind. - - - 311 - NTT - Telephone - - - 312 - HIT - Hitachi, Ltd. - - -
- - -
- Commodities - - - - 333 - XAU/USD - XAU/USD - - - 334 - XAG/USD - XAG/USD - - - 335 - Platinum - Platinum - - - 336 - Palladium - Palladium - - - 504 - Light - Light - - - 505 - Brent - Brent - - - 506 - Copper - Copper - - -
-
diff --git a/plugins/Quotes/docs/Utility/GoogleFinance.xml b/plugins/Quotes/docs/Utility/GoogleFinance.xml deleted file mode 100644 index 031afbcdd5..0000000000 --- a/plugins/Quotes/docs/Utility/GoogleFinance.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - Google Finance - http://www.google.com - http://www.google.com/finance - \ No newline at end of file diff --git a/plugins/Quotes/docs/Utility/Quotes_Readme.txt b/plugins/Quotes/docs/Utility/Quotes_Readme.txt deleted file mode 100644 index 7c0bf2ca10..0000000000 --- a/plugins/Quotes/docs/Utility/Quotes_Readme.txt +++ /dev/null @@ -1,112 +0,0 @@ -Quotes version 0.0.24.0 plugin for Miranda - -This plugin displays periodically updated economic quotes, currency exchanges and different economic and financial indexes in Miranda contact list. - -Author: Dioksin. -You can always contact me via email dioksin@ua.fm - -How to install: -unpack zip archive; -copy quotes.dll and Quotes subdirectory from Plugins folder to miranda plugins floder. -copy proto_Quotes.dll from Icons folder to miranda icons folder - -[2011-10-24] Changelog Release 0.0.24.0 -1. Tendency calculation for Yahoo was fixed - -[2011-10-18] Changelog Release 0.0.23.0 -1. Previous Close and Change values were added to YAHOO -2. If there is no xml file corresponding options page is not show in properties window - -[2011-10-14] Changelog Release 0.0.22.0 -1. Supports YAHOO -2. Options location was moved from "Plugins\Quotes" to "Network\Quotes" - -[2011-08-19] Changelog Release 0.0.21.0 -1. Tendency format specification -2. Main icon was changed -3. Currency converter icon was changed -4. Popup plugin support -5. Per-contact options -6. Menu redesign -7. Import/export from/to xml file - -[2011-08-14] Changelog Release 0.0.20.0 -1. Updation of code to use new format of Google finance HTML page - -[2010-09-26] Changelog Release 0.0.19.0 -1. Currency converter shown values in the sientific format -2. Currency converter didn't convert big values -3. Currency converter output is formatted with user-defined locale preferences -4. Swap button in the currency converter has an icon -5. Big icon is set for the currency converter to correct show in ALT+TAB dialog - -[2010-09-19] Changelog Release 0.0.18.0 -1. Thousand separator error for non USA locale in Google Finance - -Changelog Release 0.0.17.0 -1. The percent change with respecto to yesterday close variable was added to the Google Finance -2. The Vietnamese Dong was added to the Currency Converter - -Changelog Release 0.0.16.0 -1. It was impossible to get quotes from google finance on non-USA locale - -Changelog Release 0.0.15.0 -1. Crash if invalid display name format was used - -Changelog Release 0.0.14.0 -1. References to Microsoft's XML parser were removed. - -Changelog Release 0.0.12.0 -1. The Swap button had been added to the Currency Converter - -Changelog Release 0.0.11.0 -1. Google finance is supported -2. Occupied status was made optionally (To use it's necessary to set the 'ExtendedStatus' option in the Miranda's database). - -Changelog Release 0.0.9.981 -1. Currency converter -2. Refresh all Quotes\Rates -3. Refresh particular Quote\Rate -2. Minor fixings to better support national language pack - -Changelog Release 0.0.0.8 -1. Minor changing in logic of status -2. Minor resource modification to better support national language pack - -Changelog Release 0.0.0.7 -1. Status message may be set on per contact basis (second line in contact list) -2. Two new modes were added. Occupied - it's set if error occurred during rate/quote updation. DND - it's set if updation is in progress. -3. Open Log File menu item was added and Quotes related menu items are grouped in Quotes popup menu. -4. Several new variables were added: previous rate, fetch date, fetch time. -5. New empty icon was added. This icon is used when rate/quote was not changed. -6. Quotes\rate info page was changed to show both current and previous rates. -7. Database ForceToAddArrowToNick setting was added. This value governs an up\down arrow appearance in contact name. If it's equal 0 (default value) - arrows will be added only if extraicons were set . It it' equal 1 - arrows will be shown always and if it's equal 2 - arrows will be never shown. - -Changelog Release 0.0.0.6 -1. Change to log and to history only if rate (quote) value changed option has been added -2. Several minor bugs were fixed - -Changelog Release 0.0.0.5 -1. Extraicons supporting -2. Ability to change name in contact list with variables -3. Log to file -4. Log to Miranda's history -5. Proxy server supporting -6. Protocol icons were changes and removed to separate dll - -Changelog Release 0.0.0.4 -1. It is possible to get currency exchange rates from Google site -2. Unicode supporting was improved -3. User info page was modified -4. Option pages were moved under Plugin section - -Changelog Release 0.0.0.3 -1. Fix bug when decimal separator was not dot -2. User info page was added - -Changelog Release 0.0.0.2 -1. The size of plugin was reduced -2. The plugin was statically link with CRT library to resolve some dependencies to system modules -3. The updater plugin is supported now. - - diff --git a/plugins/Quotes/docs/Utility/Yahoo.xml b/plugins/Quotes/docs/Utility/Yahoo.xml deleted file mode 100644 index 1c2a156d89..0000000000 --- a/plugins/Quotes/docs/Utility/Yahoo.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - Yahoo - http://finance.yahoo.com/ - http://finance.yahoo.com/d/ - \ No newline at end of file diff --git a/plugins/Quotes/res/Forex.rc b/plugins/Quotes/res/Forex.rc index 451b780d9d..ec4b7943d5 100644 --- a/plugins/Quotes/res/Forex.rc +++ b/plugins/Quotes/res/Forex.rc @@ -208,27 +208,6 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,167,139,50,14 END -IDD_DIALOG_ECONOMIC_RATES DIALOGEX 0, 0, 310, 230 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - LTEXT "&Choose Quotes to watch in contact list:",IDC_STATIC,7,7,298,8 - CONTROL "",IDC_TREE_ECONOMIC_RATES,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_CHECKBOXES | TVS_NOHSCROLL | WS_BORDER | WS_TABSTOP,21,18,284,126 - LTEXT "&Refresh Quotes Every:",IDC_STATIC,7,150,108,8 - EDITTEXT IDC_EDIT_REFRESH_RATE,118,148,40,12,ES_AUTOHSCROLL - CONTROL "",IDC_SPIN_REFRESH_RATE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_HOTTRACK,230,147,11,14 - COMBOBOX IDC_COMBO_REFRESH_RATE,161,148,69,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "&Display in Contact List as:",IDC_STATIC,7,165,109,8 - EDITTEXT IDC_EDIT_CONTACT_LIST_FORMAT,118,162,120,12,ES_AUTOHSCROLL - PUSHBUTTON "&Variables...",IDC_BUTTON_DESCRIPTION,240,162,65,12 - LTEXT "&Status Message:",IDC_STATIC,7,178,107,8 - EDITTEXT IDC_EDIT_STATUS_MESSAGE_FORMAT,118,176,120,12,ES_AUTOHSCROLL - LTEXT "&Tendency:",IDC_STATIC,7,192,102,8 - EDITTEXT IDC_EDIT_TENDENCY_FORMAT,118,190,120,12,ES_AUTOHSCROLL - PUSHBUTTON "&Advanced Settings...",IDC_BUTTON_ADVANCED_SETTINGS,103,208,110,14 -END - IDD_DIALOG_QUOTE_INFO DIALOGEX 0, 0, 222, 132 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -286,31 +265,6 @@ BEGIN PUSHBUTTON "Close",IDOK,85,122,50,14 END -IDD_DIALOG_OPT_FINANCE DIALOGEX 0, 0, 310, 232 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - LTEXT "Type &Stock Name or Symbol:",IDC_STATIC,7,10,96,8 - EDITTEXT IDC_EDIT_QUOTE,106,7,143,14,ES_AUTOHSCROLL - PUSHBUTTON "&Add",IDC_BUTTON_ADD,255,7,50,14 - LTEXT "&Watched Quotes:",IDC_STATIC,7,23,110,8 - LISTBOX IDC_LIST_RATES,19,35,231,112,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "&Remove",IDC_BUTTON_REMOVE,255,35,50,14 - LTEXT "&Refresh Rates Every:",IDC_STATIC,7,153,107,8 - EDITTEXT IDC_EDIT_REFRESH_RATE,117,151,40,12,ES_AUTOHSCROLL - CONTROL "",IDC_SPIN_REFRESH_RATE,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_HOTTRACK,234,150,11,14 - COMBOBOX IDC_COMBO_REFRESH_RATE,160,151,69,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "&Display in Contact List as:",IDC_STATIC,7,168,107,8 - EDITTEXT IDC_EDIT_CONTACT_LIST_FORMAT,117,165,120,12,ES_AUTOHSCROLL - PUSHBUTTON "&Variables...",IDC_BUTTON_DESCRIPTION,240,165,65,12 - LTEXT "Status &Message:",IDC_STATIC,7,181,108,8 - EDITTEXT IDC_EDIT_STATUS_MESSAGE_FORMAT,117,179,120,12,ES_AUTOHSCROLL - LTEXT "&Tendency:",IDC_STATIC,7,195,102,8 - EDITTEXT IDC_EDIT_TENDENCY_FORMAT,117,193,120,12,ES_AUTOHSCROLL - PUSHBUTTON "&Advanced Settings...",IDC_BUTTON_ADVANCED_SETTINGS,99,210,110,14 -END - ///////////////////////////////////////////////////////////////////////////// // @@ -360,14 +314,6 @@ BEGIN BOTTOMMARGIN, 153 END - IDD_DIALOG_ECONOMIC_RATES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 305 - TOPMARGIN, 7 - BOTTOMMARGIN, 222 - END - IDD_DIALOG_QUOTE_INFO, DIALOG BEGIN LEFTMARGIN, 7 @@ -392,15 +338,6 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 135 END - - IDD_DIALOG_OPT_FINANCE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 305 - VERTGUIDE, 249 - TOPMARGIN, 7 - BOTTOMMARGIN, 224 - END END #endif // APSTUDIO_INVOKED diff --git a/plugins/Quotes/src/EconomicRateInfo.h b/plugins/Quotes/src/EconomicRateInfo.h index 73e269619c..af881c7bff 100644 --- a/plugins/Quotes/src/EconomicRateInfo.h +++ b/plugins/Quotes/src/EconomicRateInfo.h @@ -3,7 +3,7 @@ #define QUOTES_PROTOCOL_NAME "Quotes"// protocol name -#define QUOTES_MODULE_NAME QUOTES_PROTOCOL_NAME // db settings module path +#define QUOTES_MODULE_NAME "Quotes" // db settings module path enum ERefreshRateType { diff --git a/plugins/Quotes/src/Forex.cpp b/plugins/Quotes/src/Forex.cpp index 2ee56b9554..a951a5667c 100644 --- a/plugins/Quotes/src/Forex.cpp +++ b/plugins/Quotes/src/Forex.cpp @@ -63,7 +63,7 @@ void InitMenu() { CMenuItem mi(&g_plugin); mi.flags = CMIF_UNICODE; - mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Quotes"), 0, Quotes_GetIconHandle(IDI_ICON_MAIN)); + 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); @@ -76,7 +76,7 @@ void InitMenu() UpdateMenu(g_bAutoUpdate); SET_UID(mi, 0x91cbabf6, 0x5073, 0x4a78, 0x84, 0x8, 0x34, 0x61, 0xc1, 0x8a, 0x34, 0xd9); - mi.name.w = LPGENW("Refresh All Quotes\\Rates"); + mi.name.w = LPGENW("Refresh All Rates"); mi.position = 20100001; mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_MAIN); mi.pszService = "Quotes/RefreshAll"; @@ -92,7 +92,7 @@ void InitMenu() 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 Quotes"); + mi.name.w = LPGENW("Export All Currency Rates"); mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_EXPORT); mi.pszService = "Quotes/ExportAll"; mi.position = 20100003; @@ -100,7 +100,7 @@ void InitMenu() 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 Quotes"); + mi.name.w = LPGENW("Import All Currency Rates"); mi.hIcolibItem = Quotes_GetIconHandle(IDI_ICON_IMPORT); mi.pszService = "Quotes/ImportAll"; mi.position = 20100004; @@ -153,10 +153,10 @@ void InitMenu() int Quotes_OnToolbarLoaded(WPARAM, LPARAM) { TTBButton ttb = {}; - ttb.name = LPGEN("Enable/Disable Quotes Auto Update"); + ttb.name = LPGEN("Enable/Disable Currency Rates Auto Update"); ttb.pszService = g_pszAutoUpdateCmd; - ttb.pszTooltipUp = LPGEN("Quotes Auto Update Enabled"); - ttb.pszTooltipDn = LPGEN("Quotes Auto Update Disabled"); + 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; @@ -226,7 +226,7 @@ INT_PTR QuoteProtoFunc_GetCaps(WPARAM wParam, LPARAM) { switch (wParam) { case PFLAG_UNIQUEIDTEXT: - return (INT_PTR)Translate("Quote Symbol"); + return (INT_PTR)Translate("Currency Symbol"); } return 0; diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp index 564fb7b960..c3d5cada0b 100644 --- a/plugins/Quotes/src/ImportExport.cpp +++ b/plugins/Quotes/src/ImportExport.cpp @@ -463,14 +463,6 @@ bool get_contact_state(const IXMLNode::TXMLNodePtr& pXmlContact, CContactState& MCONTACT GetContact()const { return m_hContact; } private: - virtual void Visit(const CQuotesProviderDukasCopy& rProvider)override - { - tstring sQuoteID = GetXMLNodeValue(DB_STR_QUOTE_ID); - if (false == sQuoteID.empty()) { - m_hContact = rProvider.GetContactByQuoteID(sQuoteID); - } - } - virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override { static const tstring g_sFromID = quotes_a2t(DB_STR_FROM_ID);//A2CT(DB_STR_FROM_ID); @@ -497,14 +489,6 @@ bool get_contact_state(const IXMLNode::TXMLNodePtr& pXmlContact, CContactState& } } - virtual void Visit(const CQuotesProviderFinance& rProvider)override - { - tstring sQuoteID = GetXMLNodeValue(DB_STR_QUOTE_ID); - if (false == sQuoteID.empty()) { - m_hContact = rProvider.GetContactByQuoteID(sQuoteID); - } - } - tstring GetXMLNodeValue(const char* pszXMLNodeName)const { tstring sXMLNodeName = quotes_a2t(pszXMLNodeName); diff --git a/plugins/Quotes/src/OptionDukasCopy.cpp b/plugins/Quotes/src/OptionDukasCopy.cpp deleted file mode 100644 index 3d7a226cc5..0000000000 --- a/plugins/Quotes/src/OptionDukasCopy.cpp +++ /dev/null @@ -1,319 +0,0 @@ -#include "StdAfx.h" - -enum ETreeCheckBoxState -{ - // tree check box state - TCBS_NOSTATEBOX = 0, - TCBS_UNCHECKED = 1, - TCBS_CHECKED = 2, -}; - -enum -{ - TREE_VIEW_CHECK_STATE_CHANGE = WM_USER + 100, - IMAGE_INDEX_SECTION = 0, - IMAGE_INDEX_QUOTE = 1 -}; - -HTREEITEM tree_insert_item(HWND hwndTree, - const tstring& rsName, - HTREEITEM htiParent, - int nImage, - LPARAM lp = 0) -{ - TVINSERTSTRUCT tvi = {}; - tvi.hParent = htiParent; - tvi.hInsertAfter = TVI_LAST; - tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvi.item.pszText = const_cast(rsName.c_str());//name; - tvi.item.lParam = lp; - tvi.item.iImage = nImage; - tvi.item.iSelectedImage = nImage; - return TreeView_InsertItem(hwndTree, &tvi); -} - -bool add_quote_to_tree(const CQuotesProviderDukasCopy::CQuote& q, HWND hwndTree, HTREEITEM htiParent, const CQuotesProviderDukasCopy* pQuotesProvier) -{ - bool bChecked = pQuotesProvier->IsQuoteWatched(q); - HTREEITEM hti = tree_insert_item(hwndTree, ((false == q.GetName().empty()) ? q.GetName() : q.GetSymbol()), htiParent, IMAGE_INDEX_QUOTE); - if (hti && bChecked) { - HWND hDlg = ::GetParent(hwndTree); - assert(::IsWindow(hDlg)); - ::PostMessage(hDlg, TREE_VIEW_CHECK_STATE_CHANGE, MAKEWPARAM(0, TCBS_CHECKED), reinterpret_cast(hti)); - } - - return (nullptr != hti && bChecked); -} - -void add_section_to_tree(const CQuotesProviderDukasCopy::CQuoteSection& qs, - HWND hwndTree, - HTREEITEM htiParent, - const CQuotesProviderDukasCopy* pQuotesProvier, - bool& rbIsChecked, - bool& rbIsExpended, - bool bExpand = false) -{ - rbIsChecked = false; - rbIsExpended = false; - HTREEITEM hti = tree_insert_item(hwndTree, qs.GetName(), htiParent, IMAGE_INDEX_SECTION); - - size_t cCheckedItems = 0; - size_t cSection = qs.GetSectionCount(); - for (size_t i = 0; i < cSection; ++i) { - bool bIsChecked = false; - bool bIsExpanded = false; - CQuotesProviderDukasCopy::CQuoteSection other = qs.GetSection(i); - add_section_to_tree(other, hwndTree, hti, pQuotesProvier, bIsChecked, bIsExpanded); - - if (bIsChecked) - ++cCheckedItems; - - if (bIsExpanded) - bExpand = true; - } - - size_t cQuotes = qs.GetQuoteCount(); - for (size_t i = 0; i < cQuotes; ++i) { - CQuotesProviderDukasCopy::CQuote q = qs.GetQuote(i); - if (true == add_quote_to_tree(q, hwndTree, hti, pQuotesProvier)) - ++cCheckedItems; - } - - if (bExpand || cCheckedItems > 0) { - rbIsExpended = true; - TreeView_Expand(hwndTree, hti, TVE_EXPAND); - } - - if (cCheckedItems == (cSection + cQuotes)) { - rbIsChecked = true; - HWND hDlg = ::GetParent(hwndTree); - assert(::IsWindow(hDlg)); - ::PostMessage(hDlg, TREE_VIEW_CHECK_STATE_CHANGE, MAKEWPARAM(0, TCBS_CHECKED), reinterpret_cast(hti)); - } -} - -void add_provider_to_tree(const CQuotesProviderDukasCopy* pQuotesProvier, HWND hwndTree) -{ - CQuotesProviderDukasCopy::CQuoteSection qs = pQuotesProvier->GetQuotes(); - bool bIsChecked = false; - bool bIsExpanded = false; - add_section_to_tree(qs, hwndTree, TVI_ROOT, pQuotesProvier, bIsChecked, bIsExpanded, true); -} - -inline HTREEITEM tree_get_child_item(HWND hwndTree, HTREEITEM hti) -{ - return reinterpret_cast(::SendMessage(hwndTree, TVM_GETNEXTITEM, TVGN_CHILD, reinterpret_cast(hti))); -} - -inline HTREEITEM tree_get_next_sibling_item(HWND hwndTree, HTREEITEM hti) -{ - return reinterpret_cast(::SendMessage(hwndTree, TVM_GETNEXTITEM, TVGN_NEXT, reinterpret_cast(hti))); -} - -inline ETreeCheckBoxState tree_get_state_image(HWND hwndTree, HTREEITEM hti) -{ - TVITEM tvi; - tvi.hItem = hti; - tvi.mask = TVIF_STATE | TVIF_HANDLE; - tvi.stateMask = TVIS_STATEIMAGEMASK; - if (TRUE == ::SendMessage(hwndTree, TVM_GETITEM, 0, reinterpret_cast(&tvi))) { - UINT nState = (tvi.state >> 12); - return static_cast(nState); - } - - return TCBS_UNCHECKED; -} - -void tree_do_set_item_state(HWND hwndTree, HTREEITEM hti, ETreeCheckBoxState nState) -{ - TVITEM tvi = {}; - tvi.mask = TVIF_STATE | TVIF_HANDLE; - tvi.hItem = hti; - tvi.stateMask = TVIS_STATEIMAGEMASK; - tvi.state = INDEXTOSTATEIMAGEMASK(nState); - ::SendMessage(hwndTree, TVM_SETITEM, 0, reinterpret_cast(&tvi)); -} - -void tree_set_item_state(HWND hwndTree, HTREEITEM hti, ETreeCheckBoxState nState, bool bRecursively) -{ - if (true == bRecursively) { - for (hti = tree_get_child_item(hwndTree, hti); hti; hti = tree_get_next_sibling_item(hwndTree, hti)) { - tree_do_set_item_state(hwndTree, hti, nState); - tree_set_item_state(hwndTree, hti, nState, bRecursively); - } - } - else tree_do_set_item_state(hwndTree, hti, nState); -} - -void save_quote_selection(HWND hwndTree, HTREEITEM h, const CQuotesProviderDukasCopy::CQuote& q, CQuotesProviderDukasCopy* pQuotesProvier) -{ - ETreeCheckBoxState nState = tree_get_state_image(hwndTree, h); - pQuotesProvier->WatchForQuote(q, (TCBS_CHECKED == nState)); -} - -void recursive_save_quote_section_selection(HWND hwndTree, HTREEITEM h, const CQuotesProviderDukasCopy::CQuoteSection& qs, CQuotesProviderDukasCopy* pQuotesProvier) -{ - size_t cSection = qs.GetSectionCount(); - h = tree_get_child_item(hwndTree, h); - for (size_t i = 0; h && (i < cSection); ++i, h = tree_get_next_sibling_item(hwndTree, h)) { - CQuotesProviderDukasCopy::CQuoteSection other = qs.GetSection(i); - recursive_save_quote_section_selection(hwndTree, h, other, pQuotesProvier); - } - - size_t cQuotes = qs.GetQuoteCount(); - for (size_t i = 0; h && (i < cQuotes); ++i, h = tree_get_next_sibling_item(hwndTree, h)) { - CQuotesProviderDukasCopy::CQuote q = qs.GetQuote(i); - save_quote_selection(hwndTree, h, q, pQuotesProvier); - } -} - -void recursive_save_selection(HWND hwndTree, CQuotesProviderDukasCopy* pQuotesProvider) -{ - CQuotesProviderDukasCopy::CQuoteSection qs = pQuotesProvider->GetQuotes(); - recursive_save_quote_section_selection(hwndTree, tree_get_child_item(hwndTree, TVI_ROOT), qs, pQuotesProvider); -} - -class CImageListWrapper -{ -public: - CImageListWrapper() - : m_hImageList(ImageList_Create(::GetSystemMetrics(SM_CXSMICON), - ::GetSystemMetrics(SM_CYSMICON), - ILC_COLOR24 | ILC_MASK, 2, 0)) - { - if (m_hImageList) { - ImageList_AddIcon(m_hImageList, Quotes_LoadIconEx(IDI_ICON_SECTION)); - ImageList_AddIcon(m_hImageList, Quotes_LoadIconEx(IDI_ICON_QUOTE)); - } - } - - ~CImageListWrapper() - { - if (m_hImageList) - ImageList_Destroy(m_hImageList); - } - - operator HIMAGELIST()const - { - return m_hImageList; - } - -private: - HIMAGELIST m_hImageList; -}; - -HIMAGELIST get_image_list() -{ - static CImageListWrapper wrapper; - return wrapper; -} - -CQuotesProviderDukasCopy* get_dukas_copy_provider() -{ - CModuleInfo::TQuotesProvidersPtr pProviders = CModuleInfo::GetQuoteProvidersPtr(); - const CQuotesProviders::TQuotesProviders& rapQuotesProviders = pProviders->GetProviders(); - for (CQuotesProviders::TQuotesProviders::const_iterator i = rapQuotesProviders.begin(); i != rapQuotesProviders.end(); ++i) { - const CQuotesProviders::TQuotesProviderPtr& pProvider = *i; - CQuotesProviderDukasCopy* pDukas = dynamic_cast(pProvider.get()); - if (pDukas) - return pDukas; - } - - assert(!"We should never get here!"); - return nullptr; -} - -INT_PTR CALLBACK EconomicRatesDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - CCommonDlgProcData d(get_dukas_copy_provider()); - CommonOptionDlgProc(hdlg, message, wParam, lParam, d); - - switch (message) { - case WM_INITDIALOG: - TranslateDialogDefault(hdlg); - { - HWND hwndTree = ::GetDlgItem(hdlg, IDC_TREE_ECONOMIC_RATES); - HIMAGELIST hImage = get_image_list(); - if (hImage) { - TreeView_SetImageList(hwndTree, hImage, TVSIL_NORMAL); - } - - const CQuotesProviderDukasCopy* pDukasProvider = get_dukas_copy_provider(); - if (pDukasProvider) - add_provider_to_tree(pDukasProvider, hwndTree); - } - return TRUE; - - case WM_NOTIFY: - { - LPNMHDR pNMHDR = reinterpret_cast(lParam); - switch (pNMHDR->code) { - case TVN_KEYDOWN: - if (IDC_TREE_ECONOMIC_RATES == wParam) { - LPNMTVKEYDOWN pKeyDown = reinterpret_cast(lParam); - if (VK_SPACE == pKeyDown->wVKey) { - HTREEITEM hti = TreeView_GetSelection(::GetDlgItem(hdlg, IDC_TREE_ECONOMIC_RATES)); - ::PostMessage(hdlg, TREE_VIEW_CHECK_STATE_CHANGE, MAKEWPARAM(1, 0), reinterpret_cast(hti)); - PropSheet_Changed(::GetParent(hdlg), hdlg); - } - } - break; - - case NM_CLICK: - if (IDC_TREE_ECONOMIC_RATES == wParam) { - DWORD pos = ::GetMessagePos(); - - HWND hwndTree = ::GetDlgItem(hdlg, IDC_TREE_ECONOMIC_RATES); - - TVHITTESTINFO tvhti; - tvhti.pt.x = LOWORD(pos); - tvhti.pt.y = HIWORD(pos); - ::ScreenToClient(hwndTree, &(tvhti.pt)); - - HTREEITEM hti = reinterpret_cast(::SendMessage(hwndTree, TVM_HITTEST, 0, reinterpret_cast(&tvhti))); - if (hti && (tvhti.flags&TVHT_ONITEMSTATEICON)) { - ::PostMessage(hdlg, TREE_VIEW_CHECK_STATE_CHANGE, MAKEWPARAM(1, 0), reinterpret_cast(hti)); - PropSheet_Changed(::GetParent(hdlg), hdlg); - } - } - break; - - case PSN_APPLY: - CQuotesProviderDukasCopy* pDukasProvider = get_dukas_copy_provider(); - if (pDukasProvider) { - recursive_save_selection(::GetDlgItem(hdlg, IDC_TREE_ECONOMIC_RATES), pDukasProvider); - pDukasProvider->RefreshSettings(); - } - break; - } - } - return TRUE; - - case TREE_VIEW_CHECK_STATE_CHANGE: - HWND hwndTree = ::GetDlgItem(hdlg, IDC_TREE_ECONOMIC_RATES); - HTREEITEM hti = reinterpret_cast(lParam); - - ETreeCheckBoxState nState; - - bool bRecursively = 1 == LOWORD(wParam); - if (bRecursively) - nState = tree_get_state_image(hwndTree, hti); - else - nState = static_cast(HIWORD(wParam)); - - tree_set_item_state(hwndTree, hti, nState, bRecursively); - break; - } - - return FALSE; -} - -void ShowDukasCopyPropPage(CQuotesProviderDukasCopy* pProvider, WPARAM wp, OPTIONSDIALOGPAGE& odp) -{ - const IQuotesProvider::CProviderInfo& pi = pProvider->GetInfo(); - - odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_ECONOMIC_RATES); - odp.pfnDlgProc = EconomicRatesDlgProc; - odp.szTab.w = const_cast(pi.m_sName.c_str()); - g_plugin.addOptions(wp, &odp); -} diff --git a/plugins/Quotes/src/OptionDukasCopy.h b/plugins/Quotes/src/OptionDukasCopy.h deleted file mode 100644 index 617d370f3b..0000000000 --- a/plugins/Quotes/src/OptionDukasCopy.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __60a5d152_872c_4bc4_b9ae_cd561d110b2dOptionDukasCopy_h__ -#define __60a5d152_872c_4bc4_b9ae_cd561d110b2dOptionDukasCopy_h__ - -class CQuotesProviderDukasCopy; - -void ShowDukasCopyPropPage(CQuotesProviderDukasCopy* pProvider, WPARAM wp, OPTIONSDIALOGPAGE& odp); - -#endif //__60a5d152_872c_4bc4_b9ae_cd561d110b2dOptionDukasCopy_h__ diff --git a/plugins/Quotes/src/QuotesProviderDukasCopy.cpp b/plugins/Quotes/src/QuotesProviderDukasCopy.cpp deleted file mode 100644 index 064ce9dcec..0000000000 --- a/plugins/Quotes/src/QuotesProviderDukasCopy.cpp +++ /dev/null @@ -1,226 +0,0 @@ -#include "StdAfx.h" - -CQuotesProviderDukasCopy::CQuotesProviderDukasCopy() -{ -} - -CQuotesProviderDukasCopy::~CQuotesProviderDukasCopy() -{ -} - -inline tstring get_quote_id(MCONTACT hContact) -{ - return Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_ID); -} - -inline bool is_quote_id_equal(MCONTACT hContact, const tstring& sID) -{ - return sID == get_quote_id(hContact); -} - -bool CQuotesProviderDukasCopy::IsQuoteWatched(const CQuote& rQuote)const -{ - return m_aContacts.end() != std::find_if(m_aContacts.begin(), m_aContacts.end(), - boost::bind(is_quote_id_equal, _1, rQuote.GetID())); -} - -bool CQuotesProviderDukasCopy::WatchForQuote(const CQuote& rQuote, bool bWatch) -{ - const tstring& sQuoteID = rQuote.GetID(); - TContracts::iterator i = - std::find_if(m_aContacts.begin(), m_aContacts.end(), - boost::bind(is_quote_id_equal, _1, sQuoteID)); - - if ((false == bWatch) && (i != m_aContacts.end())) { - MCONTACT hContact = *i; - {// for CCritSection - mir_cslock lck(m_cs); - m_aContacts.erase(i); - } - - db_delete_contact(hContact); - return true; - } - else if ((true == bWatch) && (i == m_aContacts.end())) { - MCONTACT hContact = CreateNewContact(rQuote.GetSymbol()); - if (hContact) { - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_ID, sQuoteID.c_str()); - if (false == rQuote.GetName().empty()) { - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_DESCRIPTION, rQuote.GetName().c_str()); - } - - return true; - } - - } - return false; -} - -tstring CQuotesProviderDukasCopy::BuildHTTPURL()const -{ - tostringstream sURL; - sURL << GetURL(); - - { - mir_cslock lck(m_cs); - for (TContracts::const_iterator i = m_aContacts.begin(); i != m_aContacts.end(); ++i) { - MCONTACT hContact = *i; - tstring sID = get_quote_id(hContact); - if (false == sID.empty()) - sURL << sID << L","; - } - } - - return sURL.str(); -} - -struct CEconomicRateInfo -{ - CEconomicRateInfo() : m_dCurRate(0.0), m_dPrevRate(0.0) {} - tstring m_sName; - double m_dCurRate; - double m_dPrevRate; - tstring m_sID; -}; - -typedef std::vector TEconomicRates; -typedef IHTMLNode::THTMLNodePtr THTMLNodePtr; - -bool string2double(const wchar_t* pszText, double& rValue) -{ - assert(pszText); - try { - rValue = boost::lexical_cast(pszText); - } - catch (boost::bad_lexical_cast &) { - return false; - } - - return true; -} - - -void parse_row(const THTMLNodePtr& pRow, TEconomicRates& raRates) -{ - CEconomicRateInfo ri; - ri.m_sID = pRow->GetAttribute(L"sid"); - if (false == ri.m_sID.empty()) { - unsigned short cColsHandled = 0; - tostringstream sSidID; - sSidID << L"id" << ri.m_sID; - size_t cNodes = pRow->GetChildCount(); - for (size_t i = 0; i < cNodes && cColsHandled < 2; ++i) { - THTMLNodePtr pCol = pRow->GetChildPtr(i); - if (pCol) { - tstring sColID = pCol->GetAttribute(L"id"); - if (false == sColID.empty()) { - if (0 == mir_wstrcmpi(sColID.c_str(), L"stock")) { - ri.m_sName = pCol->GetText(); - if (false == ri.m_sName.empty()) { - ++cColsHandled; - } - } - else if (0 == mir_wstrcmpi(sSidID.str().c_str(), sColID.c_str())) { - tstring sRate = pCol->GetText(); - if ((false == sRate.empty()) && (true == string2double(sRate.c_str(), ri.m_dCurRate))) { - ri.m_dPrevRate = ri.m_dCurRate; - ++cColsHandled; - tstring sOldRate = pCol->GetAttribute(L"oldPrice"); - if (false == sOldRate.empty()) { - string2double(sOldRate.c_str(), ri.m_dPrevRate); - } - } - } - } - } - } - - if (2 == cColsHandled) - raRates.push_back(ri); - } -} - -void parser_html_node(const THTMLNodePtr& pNode, TEconomicRates& raRates) -{ - size_t cNodes = pNode->GetChildCount(); - for (size_t i = 0; i < cNodes; ++i) { - THTMLNodePtr pChild = pNode->GetChildPtr(i); - if (pChild && pChild->Is(IHTMLNode::TableRow)) - parse_row(pChild, raRates); - } -} - -bool parse_HTML(const tstring& sHTML, TEconomicRates& raRates) -{ - IHTMLEngine::THTMLParserPtr pHTMLParser = CModuleInfo::GetHTMLEngine()->GetParserPtr(); - THTMLNodePtr pRoot = pHTMLParser->ParseString(sHTML); - if (pRoot) { - parser_html_node(pRoot, raRates); - return true; - } - - return false; -} - - -void CQuotesProviderDukasCopy::RefreshQuotes(TContracts& anContacts) -{ - tstring sURL = BuildHTTPURL(); - - CHTTPSession http; - // LogIt(Info,sURL); - if (true == http.OpenURL(sURL)) { - // if(true == IsOnline()) - { - tstring sHTML; - if (true == http.ReadResponce(sHTML)) { - // LogIt(Info,sHTML); - // if(true == IsOnline()) - { - TEconomicRates aRates; - if (true == parse_HTML(sHTML, aRates) - && (true == IsOnline())) { - for (TEconomicRates::const_iterator it = aRates.begin(); (it != aRates.end()) && (true == IsOnline()); ++it) { - const CEconomicRateInfo& ri = *it; - - TContracts::iterator i = std::find_if(anContacts.begin(), anContacts.end(), - boost::bind(is_quote_id_equal, _1, ri.m_sID)); - if (i != anContacts.end() && (true == IsOnline())) { - MCONTACT hContact = *i; - anContacts.erase(i); - - WriteContactRate(hContact, ri.m_dCurRate, ri.m_sName); - } - } - } - } - } - } - } - - std::for_each(anContacts.begin(), anContacts.end(), - boost::bind(&SetContactStatus, _1, ID_STATUS_NA)); -} - -void CQuotesProviderDukasCopy::ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp) -{ - ShowDukasCopyPropPage(this, wp, odp); -} - -void CQuotesProviderDukasCopy::Accept(CQuotesProviderVisitor& visitor)const -{ - CQuotesProviderBase::Accept(visitor); - visitor.Visit(*this); -} - -MCONTACT CQuotesProviderDukasCopy::GetContactByQuoteID(const tstring& rsQuoteID)const -{ - mir_cslock lck(m_cs); - - TContracts::const_iterator i = std::find_if(m_aContacts.begin(), m_aContacts.end(), - boost::bind(std::equal_to(), rsQuoteID, boost::bind(get_quote_id, _1))); - if (i != m_aContacts.end()) - return *i; - - return NULL; -} diff --git a/plugins/Quotes/src/QuotesProviderDukasCopy.h b/plugins/Quotes/src/QuotesProviderDukasCopy.h deleted file mode 100644 index 596c6bb79e..0000000000 --- a/plugins/Quotes/src/QuotesProviderDukasCopy.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __93121758_68c7_4836_b571_da84dfe82b84_QuotesProviderDukasCopy_h__ -#define __93121758_68c7_4836_b571_da84dfe82b84_QuotesProviderDukasCopy_h__ - -#define DB_STR_REFRESH_RATE_TYPE "RefreshRateType" -#define DB_STR_REFRESH_RATE_VALUE "RefreshRateValue" -#define DB_STR_DC_DISPLAY_NAME_FORMAT "DC_DisplayNameFormat" -// #define DB_STR_DC_LOG_FILE_FORMAT "DC_LogFileFormat" -// #define DB_STR_DC_HISTORY_FORMAT "DC_HistoryFormat" - -class CQuotesProviderDukasCopy : public CQuotesProviderBase -{ -public: - CQuotesProviderDukasCopy(); - ~CQuotesProviderDukasCopy(); - - bool WatchForQuote(const CQuote& rQuote, bool bWatch); - bool IsQuoteWatched(const CQuote& rQuote)const; - - MCONTACT GetContactByQuoteID(const tstring& rsQuoteID)const; - // #ifdef CHART_IMPLEMENT - // bool Chart(MCONTACT hContact,const tstring& url)const; - // #endif - -private: - //IQuotesProvider implementation - virtual void RefreshQuotes(TContracts& anContacts); - virtual void ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp); - virtual void Accept(CQuotesProviderVisitor& visitor)const; - -private: - tstring BuildHTTPURL()const; - -}; - -#endif //__93121758_68c7_4836_b571_da84dfe82b84_QuotesProviderDukasCopy_h__ diff --git a/plugins/Quotes/src/QuotesProviderFinance.cpp b/plugins/Quotes/src/QuotesProviderFinance.cpp deleted file mode 100644 index c80559a6b6..0000000000 --- a/plugins/Quotes/src/QuotesProviderFinance.cpp +++ /dev/null @@ -1,265 +0,0 @@ -#include "stdafx.h" - -void CQuotesProviderFinance::GetWatchedQuotes(TQuotes& raQuotes)const -{ - raQuotes.clear(); - BOOST_FOREACH(MCONTACT hContact, m_aContacts) - { - tstring sID = Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_ID); - tstring sSymbol = Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_SYMBOL, sID.c_str()); - tstring sDescr = Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_DESCRIPTION); - CQuotesProviderBase::CQuote quote(sID, sSymbol, sDescr); - - raQuotes.push_back(quote); - } -} - -inline tstring get_quote_id(MCONTACT hContact) -{ - return Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_ID); -} - -inline bool is_quote_id_equal(MCONTACT hContact, const tstring& sID) -{ - return sID == get_quote_id(hContact); -} - -bool CQuotesProviderFinance::WatchForQuote(const CQuote& rQuote, bool bWatch) -{ - const tstring& sQuoteID = rQuote.GetID(); - TContracts::iterator i = std::find_if(m_aContacts.begin(), m_aContacts.end(), - boost::bind(is_quote_id_equal, _1, sQuoteID)); - - if (!bWatch && i != m_aContacts.end()) { - MCONTACT hContact = *i; - { - mir_cslock lck(m_cs); - m_aContacts.erase(i); - } - - db_delete_contact(hContact); - return true; - } - - if (bWatch && i == m_aContacts.end()) { - MCONTACT hContact = CreateNewContact(rQuote.GetSymbol()); - if (hContact) { - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_ID, sQuoteID.c_str()); - if (false == rQuote.GetName().empty()) - db_set_ws(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_DESCRIPTION, rQuote.GetName().c_str()); - - return true; - } - } - - return false; -} - -MCONTACT CQuotesProviderFinance::GetContactByQuoteID(const tstring& rsQuoteID)const -{ - mir_cslock lck(m_cs); - - TContracts::const_iterator i = std::find_if(m_aContacts.begin(), m_aContacts.end(), - boost::bind(std::equal_to(), rsQuoteID, boost::bind(get_quote_id, _1))); - if (i != m_aContacts.end()) - return *i; - - return NULL; -} - -void CQuotesProviderFinance::Accept(CQuotesProviderVisitor& visitor)const -{ - CQuotesProviderBase::Accept(visitor); - visitor.Visit(*this); -} - -namespace -{ - inline tstring make_quote_name(const CQuotesProviderBase::CQuote& rQuote) - { - const tstring &rsDesc = rQuote.GetName(); - return((false == rsDesc.empty()) ? rsDesc : rQuote.GetSymbol()); - } - - int add_quote_to_wnd(const CQuotesProviderBase::CQuote& rQuote, HWND hwnd) - { - tstring sName = make_quote_name(rQuote); - int nIndex = ::SendMessage(hwnd, LB_ADDSTRING, 0, reinterpret_cast(sName.c_str())); - if (nIndex >= 0) { - CQuotesProviderBase::CQuote* pQuote = new CQuotesProviderBase::CQuote(rQuote); - if (LB_ERR == ::SendMessage(hwnd, LB_SETITEMDATA, nIndex, reinterpret_cast(pQuote))) { - delete pQuote; - } - } - return nIndex; - } - - CQuotesProviderBase::CQuote* get_quote_ptr_from_lb_index(HWND hwndListBox, int nIndex) - { - LRESULT lResult = ::SendMessage(hwndListBox, LB_GETITEMDATA, nIndex, 0); - return (((LB_ERR != lResult) && (0 != lResult)) ? (reinterpret_cast(lResult)) : nullptr); - } - - int is_quote_added(HWND hwndList, const tstring& rsQuoteID) - { - int cItems = ::SendMessage(hwndList, LB_GETCOUNT, 0, 0); - for (int i = 0; i < cItems; ++i) { - const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndList, i); - if ((nullptr != pQuote) - && ((0 == mir_wstrcmpi(rsQuoteID.c_str(), pQuote->GetID().c_str())) - || (0 == mir_wstrcmpi(rsQuoteID.c_str(), pQuote->GetName().c_str())) - || (0 == mir_wstrcmpi(rsQuoteID.c_str(), pQuote->GetSymbol().c_str())))) { - return i; - } - } - return LB_ERR; - } - - INT_PTR CALLBACK GoogleFinanceOptDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) - { - CQuotesProviderFinance* pProvider = nullptr; - if (WM_INITDIALOG == message) { - pProvider = reinterpret_cast(lParam); - SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); - } - else pProvider = reinterpret_cast(GetWindowLongPtr(hDlg, GWLP_USERDATA)); - - CCommonDlgProcData d(pProvider); - CommonOptionDlgProc(hDlg, message, wParam, lParam, d); - - switch (message) { - case WM_INITDIALOG: - TranslateDialogDefault(hDlg); - { - CQuotesProviderFinance::TQuotes aQuotes; - pProvider->GetWatchedQuotes(aQuotes); - - HWND hwndList = GetDlgItem(hDlg, IDC_LIST_RATES); - std::for_each(aQuotes.begin(), aQuotes.end(), - boost::bind(add_quote_to_wnd, _1, hwndList)); - - ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_ADD), FALSE); - ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_REMOVE), FALSE); - } - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_EDIT_QUOTE: - if (EN_CHANGE == HIWORD(wParam)) { - ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_ADD), GetWindowTextLength(GetDlgItem(hDlg, IDC_EDIT_QUOTE)) > 0); - } - return TRUE; - case IDC_BUTTON_ADD: - if (BN_CLICKED == HIWORD(wParam)) { - HWND hEdit = GetDlgItem(hDlg, IDC_EDIT_QUOTE); - tstring sQuoteSymbol = get_window_text(hEdit); - assert(false == sQuoteSymbol.empty()); - HWND hwndList = GetDlgItem(hDlg, IDC_LIST_RATES); - if (LB_ERR == is_quote_added(hwndList, sQuoteSymbol)) { - CQuotesProviderBase::CQuote quote(sQuoteSymbol, sQuoteSymbol); - if (add_quote_to_wnd(quote, hwndList) >= 0) { - SetDlgItemText(hDlg, IDC_EDIT_QUOTE, L""); - SetFocus(hEdit); - PropSheet_Changed(::GetParent(hDlg), hDlg); - } - else { - ::MessageBeep(MB_ICONERROR); - } - } - } - return TRUE; - case IDC_BUTTON_REMOVE: - if (BN_CLICKED == HIWORD(wParam)) { - HWND hWnd = ::GetDlgItem(hDlg, IDC_LIST_RATES); - int nSel = ::SendMessage(hWnd, LB_GETCURSEL, 0, 0); - if (LB_ERR != nSel) { - CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hWnd, nSel); - delete pQuote; - if (LB_ERR != ::SendMessage(hWnd, LB_DELETESTRING, nSel, 0)) { - PropSheet_Changed(::GetParent(hDlg), hDlg); - } - } - - nSel = ::SendMessage(hWnd, LB_GETCURSEL, 0, 0); - ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_REMOVE), (LB_ERR != nSel)); - } - return TRUE; - case IDC_LIST_RATES: - if (CBN_SELCHANGE == HIWORD(wParam)) { - int nSel = ::SendDlgItemMessage(hDlg, IDC_LIST_RATES, LB_GETCURSEL, 0, 0); - ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_REMOVE), (LB_ERR != nSel)); - } - return TRUE; - } - return FALSE; - - case WM_NOTIFY: - { - LPNMHDR pNMHDR = reinterpret_cast(lParam); - switch (pNMHDR->code) { - case PSN_APPLY: - if (pProvider) { - CQuotesProviderFinance::TQuotes aTemp; - pProvider->GetWatchedQuotes(aTemp); - - typedef std::vector TQuotesPtr; - TQuotesPtr apCurrent; - HWND hwndListBox = GetDlgItem(hDlg, IDC_LIST_RATES); - int cItems = ::SendMessage(hwndListBox, LB_GETCOUNT, 0, 0); - for (int i = 0; i < cItems; ++i) { - const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndListBox, i); - if (pQuote) { - apCurrent.push_back(pQuote); - } - } - - std::for_each(aTemp.begin(), aTemp.end(), - [&apCurrent, pProvider](const CQuotesProviderBase::CQuote& quote) - { - if (apCurrent.end() == std::find_if(apCurrent.begin(), apCurrent.end(), - ["e](const CQuotesProviderBase::CQuote* pQuote) { return 0 == mir_wstrcmpi(pQuote->GetID().c_str(), quote.GetID().c_str()); })) { - pProvider->WatchForQuote(quote, false); - } - }); - - std::for_each(apCurrent.begin(), apCurrent.end(), - [&aTemp, pProvider](const CQuotesProviderBase::CQuote* pQuote) - { - if (aTemp.end() == - std::find_if(aTemp.begin(), aTemp.end(), - [pQuote](const CQuotesProviderBase::CQuote& quote) { return 0 == mir_wstrcmpi(pQuote->GetID().c_str(), quote.GetID().c_str()); })) { - pProvider->WatchForQuote(*pQuote, true); - } - - }); - - pProvider->RefreshSettings(); - } - - return TRUE; - } - } - return FALSE; - - case WM_DESTROY: - HWND hwndListBox = GetDlgItem(hDlg, IDC_LIST_RATES); - int cItems = ::SendMessage(hwndListBox, LB_GETCOUNT, 0, 0); - for (int i = 0; i < cItems; ++i) { - const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndListBox, i); - delete pQuote; - } - return FALSE; - } - return FALSE; - } -} - -void CQuotesProviderFinance::ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE &odp) -{ - odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG_OPT_FINANCE); - odp.pfnDlgProc = GoogleFinanceOptDlgProc; - odp.dwInitParam = LPARAM(this); - odp.szTab.w = const_cast(GetInfo().m_sName.c_str()); - g_plugin.addOptions(wp, &odp); -} diff --git a/plugins/Quotes/src/QuotesProviderFinance.h b/plugins/Quotes/src/QuotesProviderFinance.h deleted file mode 100644 index d50d459640..0000000000 --- a/plugins/Quotes/src/QuotesProviderFinance.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __95A13A68_0DF0_43FA_B6C1_81D83AED59AA_QuotesProviderFinance_h__ -#define __95A13A68_0DF0_43FA_B6C1_81D83AED59AA_QuotesProviderFinance_h__ - -class CQuotesProviderFinance : public CQuotesProviderBase -{ -public: - typedef std::vector TQuotes; - -public: - void GetWatchedQuotes(TQuotes& raQuotes)const; - bool WatchForQuote(const CQuote& rQuote, bool bWatch); - MCONTACT GetContactByQuoteID(const tstring& rsQuoteID)const; - -protected: - virtual void ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE& odp); - virtual void Accept(CQuotesProviderVisitor& visitor)const; -}; - -#endif //__95A13A68_0DF0_43FA_B6C1_81D83AED59AA_QuotesProviderFinance_h__ \ No newline at end of file diff --git a/plugins/Quotes/src/QuotesProviderGoogleFinance.cpp b/plugins/Quotes/src/QuotesProviderGoogleFinance.cpp deleted file mode 100644 index dcda584269..0000000000 --- a/plugins/Quotes/src/QuotesProviderGoogleFinance.cpp +++ /dev/null @@ -1,283 +0,0 @@ -#include "StdAfx.h" - -CQuotesProviderGoogleFinance::CQuotesProviderGoogleFinance() -{ -} - -CQuotesProviderGoogleFinance::~CQuotesProviderGoogleFinance() -{ -} - -static tstring build_url(MCONTACT hContact, const tstring& rsURL) -{ - tostringstream o; - o << rsURL << L"?q=" << Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_ID); - return o.str(); -} - -struct CGoogleInfo -{ - enum - { - giRate = 0x0001, - giOpen = 0x0002, - giPercentChangeAfterHours = 0x0004, - giPercentChangeToYesterdayClose = 0x0008 - }; - - CGoogleInfo() - : m_dRate(0.0), m_dOpenValue(0.0), m_dPercentChangeAfterHours(0.0), m_dPercentChangeToYersterdayClose(0.0), m_nFlags(0) - { - } - - tstring m_sCmpName; - double m_dRate; - double m_dOpenValue; - double m_dPercentChangeAfterHours; - double m_dPercentChangeToYersterdayClose; - byte m_nFlags; -}; - -tstring make_rate_id_value(const tstring& rsCmpID, int nFlags) -{ - tostringstream o; - o << L"ref_" << rsCmpID; - switch (nFlags) { - default: - assert(!"Unknown type of value"); - case CGoogleInfo::giRate: - o << L"_l"; - break; - case CGoogleInfo::giPercentChangeAfterHours: - o << L"_ecp"; - break; - case CGoogleInfo::giPercentChangeToYesterdayClose: - o << L"_cp"; - break; - } - - return o.str(); -} - -tstring get_var_value(const tstring& rsHTML, LPCTSTR pszVarName, size_t cVarNameLength) -{ - tstring sResult; - tstring::size_type n = rsHTML.find(pszVarName); - if (tstring::npos != n) { - size_t cLengthHTML = rsHTML.size(); - for (size_t i = n + cVarNameLength; i < cLengthHTML; ++i) { - wchar_t c = rsHTML[i]; - if (';' == c) - break; - - sResult.push_back(c); - } - } - - return sResult; -} - -tstring get_company_id(const tstring& rsHTML) -{ - static LPCTSTR pszVarName = L"setCompanyId("; - static size_t cVarNameLength = mir_wstrlen(pszVarName); - - tstring sResult; - tstring::size_type n = rsHTML.find(pszVarName); - if (tstring::npos != n) { - size_t cLengthHTML = rsHTML.size(); - for (size_t i = n + cVarNameLength; i < cLengthHTML; ++i) { - wchar_t c = rsHTML[i]; - if (')' == c) - break; - - sResult.push_back(c); - } - } - return sResult; -} - -tstring get_company_name(const tstring& rsHTML) -{ - static LPCTSTR pszVarName = L"var _companyName = "; - static size_t cVarNameLength = mir_wstrlen(pszVarName); - - tstring s = get_var_value(rsHTML, pszVarName, cVarNameLength); - if (s.size() > 0 && '\'' == s[0]) - s.erase(s.begin()); - - if (s.size() > 0 && '\'' == s[s.size() - 1]) - s.erase(s.rbegin().base() - 1); - - return s; -} - -bool get_double_value(const tstring& rsText, double& rdValue) -{ - tistringstream input(rsText); - input.imbue(std::locale("English_United States.1252")); - input >> rdValue; - - if ((true == input.bad()) || (true == input.fail())) { - tistringstream inputSys(rsText); - input.imbue(GetSystemLocale()); - input >> rdValue; - return (false == inputSys.bad()) && (false == inputSys.fail()); - } - - return true; -} - -bool get_rate(const IHTMLNode::THTMLNodePtr& pRate, CGoogleInfo& rInfo) -{ - tstring sRate = pRate->GetText(); - - if (true == get_double_value(sRate, rInfo.m_dRate)) { - rInfo.m_nFlags |= CGoogleInfo::giRate; - return true; - } - - return false; -} - -bool get_inline_data(const IHTMLNode::THTMLNodePtr& pNode, CGoogleInfo& rInfo) -{ - size_t cChild = pNode->GetChildCount(); - for (size_t i = 0; i < cChild; ++i) { - IHTMLNode::THTMLNodePtr pChild = pNode->GetChildPtr(i); - size_t c = pChild->GetChildCount(); - assert(2 == c); - if (c >= 2) { - IHTMLNode::THTMLNodePtr pName = pChild->GetChildPtr(0); - - tstring sName = pName->GetText(); - if (0 == mir_wstrcmpi(sName.c_str(), L"Open")) { - IHTMLNode::THTMLNodePtr pValue = pChild->GetChildPtr(1); - tstring sValue = pValue->GetText(); - if (true == get_double_value(sValue, rInfo.m_dOpenValue)) { - rInfo.m_nFlags |= CGoogleInfo::giOpen; - } - return true; - } - } - } - - return false; -} - -bool get_dif_value(const IHTMLNode::THTMLNodePtr& pNode, CGoogleInfo& rInfo, int nItem) -{ - tstring sDiff = pNode->GetText(); - // this value is in brackets and it has percentage sign. - // Remove these symbols. - for (tstring::iterator i = sDiff.begin(); i != sDiff.end();) { - wchar_t s = *i; - if ('(' == s || ')' == s || '%' == s) - i = sDiff.erase(i); - else - ++i; - } - - double* pValue = nullptr; - switch (nItem) { - case CGoogleInfo::giPercentChangeAfterHours: - pValue = &rInfo.m_dPercentChangeAfterHours; - break; - case CGoogleInfo::giPercentChangeToYesterdayClose: - pValue = &rInfo.m_dPercentChangeToYersterdayClose; - break; - } - - assert(pValue); - - if ((pValue) && (true == get_double_value(sDiff, *pValue))) { - rInfo.m_nFlags |= nItem; - return true; - } - - return false; -} - -bool parse_responce(const tstring& rsHTML, CGoogleInfo& rInfo) -{ - IHTMLEngine::THTMLParserPtr pHTMLParser = CModuleInfo::GetHTMLEngine()->GetParserPtr(); - IHTMLNode::THTMLNodePtr pRoot = pHTMLParser->ParseString(rsHTML); - if (pRoot) { - tstring sCmpID = get_company_id(rsHTML); - if (false == sCmpID.empty()) { - tstring sRateID = make_rate_id_value(sCmpID, CGoogleInfo::giRate); - IHTMLNode::THTMLNodePtr pRate = pRoot->GetElementByID(sRateID); - if (pRate && get_rate(pRate, rInfo)) { - rInfo.m_sCmpName = get_company_name(rsHTML); - - IHTMLNode::THTMLNodePtr pInline = pRoot->GetElementByID(L"snap-data"); - if (pInline) { - get_inline_data(pInline, rInfo); - } - - tstring sDiffID = make_rate_id_value(sCmpID, CGoogleInfo::giPercentChangeAfterHours); - IHTMLNode::THTMLNodePtr pDiff = pRoot->GetElementByID(sDiffID); - if (pDiff) { - get_dif_value(pDiff, rInfo, CGoogleInfo::giPercentChangeAfterHours); - } - - sDiffID = make_rate_id_value(sCmpID, CGoogleInfo::giPercentChangeToYesterdayClose); - pDiff = pRoot->GetElementByID(sDiffID); - if (pDiff) { - get_dif_value(pDiff, rInfo, CGoogleInfo::giPercentChangeToYesterdayClose); - } - - return true; - } - } - } - - return false; -} - -void CQuotesProviderGoogleFinance::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())) { - CGoogleInfo Info; - parse_responce(sHTML, Info); - if (true == IsOnline()) { - if (Info.m_nFlags&CGoogleInfo::giRate) { - if (Info.m_nFlags&CGoogleInfo::giOpen) { - Quotes_DBWriteDouble(hContact, QUOTES_MODULE_NAME, DB_STR_GOOGLE_FINANCE_OPEN_VALUE, Info.m_dOpenValue); - } - if (Info.m_nFlags&CGoogleInfo::giPercentChangeAfterHours) { - Quotes_DBWriteDouble(hContact, QUOTES_MODULE_NAME, DB_STR_GOOGLE_FINANCE_DIFF, Info.m_dPercentChangeAfterHours); - } - if (Info.m_nFlags&CGoogleInfo::giPercentChangeToYesterdayClose) { - Quotes_DBWriteDouble(hContact, QUOTES_MODULE_NAME, DB_STR_GOOGLE_FINANCE_PERCENT_CHANGE_TO_YERSTERDAY_CLOSE, Info.m_dPercentChangeToYersterdayClose); - } - if (false == Info.m_sCmpName.empty()) { - db_set_ws(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_DESCRIPTION, Info.m_sCmpName.c_str()); - } - - WriteContactRate(hContact, Info.m_dRate); - continue; - } - } - } - } - - SetContactStatus(hContact, ID_STATUS_NA); - } -} - -void CQuotesProviderGoogleFinance::Accept(CQuotesProviderVisitor& visitor)const -{ - CQuotesProviderFinance::Accept(visitor); - visitor.Visit(*this); -} diff --git a/plugins/Quotes/src/QuotesProviderGoogleFinance.h b/plugins/Quotes/src/QuotesProviderGoogleFinance.h deleted file mode 100644 index de419225c9..0000000000 --- a/plugins/Quotes/src/QuotesProviderGoogleFinance.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __89D3CC58_7DED_484f_AA25_62BDBB57E18B_QuotesProvider_Google_Finance_h__ -#define __89D3CC58_7DED_484f_AA25_62BDBB57E18B_QuotesProvider_Google_Finance_h__ - -#define DB_STR_GOOGLE_FINANCE_OPEN_VALUE "OpenQuotePrice" -#define DB_STR_GOOGLE_FINANCE_DIFF "DifferentFromStartOfDay" -#define DB_STR_GOOGLE_FINANCE_PERCENT_CHANGE_TO_YERSTERDAY_CLOSE "PercentChangeToYersterdayClose" - -// #define DB_STR_GOOGLE_FINANCE_COMP_NAME "CompanyName" - - -class CQuotesProviderGoogleFinance : public CQuotesProviderFinance -{ - -public: - CQuotesProviderGoogleFinance(); - ~CQuotesProviderGoogleFinance(); - -private: - virtual void RefreshQuotes(TContracts& anContacts); - virtual void Accept(CQuotesProviderVisitor& visitor)const; -}; - -#endif //__89D3CC58_7DED_484f_AA25_62BDBB57E18B_QuotesProvider_Google_Finance_h__ diff --git a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp index 2208d7561f..d7d9055d33 100644 --- a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp +++ b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.cpp @@ -41,89 +41,6 @@ void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderBase&/* rProvi m_pszDefPopupFormat = L"\\nCurrent = %r\\nPrevious = %p"; } -void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderDukasCopy&/* rProvider*/) -{ - m_pszDbRefreshRateType = DB_STR_REFRESH_RATE_TYPE; - m_pszDbRefreshRateValue = DB_STR_REFRESH_RATE_VALUE; - m_pszDbDisplayNameFormat = DB_STR_DC_DISPLAY_NAME_FORMAT; - m_pszDefDisplayFormat = L"%s %r"; - m_pszXMLIniFileName = L"Dukascopy.xml"; - m_pszDbStatusMsgFormat = "DC_StatusMessageFormat"; - - m_pszDbLogMode = "DC_LogMode"; - m_pszDbHistoryFormat = "DC_HistoryFormat"; - m_pszDbHistoryCondition = "DC_AddToHistoryOnlyIfValueIsChanged"; - m_pszDbLogFile = "DC_LogFile"; - m_pszDbLogFormat = "DC_LogFileFormat"; - m_pszDbLogCondition = "DC_AddToLogOnlyIfValueIsChanged"; - m_pszDbPopupFormat = "DC_PopupFormat"; - m_pszDbPopupCondition = "DC_ShowPopupOnlyIfValueChanged"; - - m_pszDbPopupColourMode = "DC_PopupColourMode"; - m_pszDbPopupBkColour = "DC_PopupColourBk"; - m_pszDbPopupTextColour = "DC_PopupColourText"; - m_pszDbPopupDelayMode = "DC_PopupDelayMode"; - m_pszDbPopupDelayTimeout = "DC_PopupDelayTimeout"; - m_pszDbPopupHistoryFlag = "DC_PopupHistoryFlag"; - m_pszDbTendencyFormat = "DC_TendencyFormat"; -} - -void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderGoogleFinance&/* rProvider*/) -{ - m_pszDbRefreshRateType = "GoogleFinance_RefreshRateType"; - m_pszDbRefreshRateValue = "GoogleFinance_RefreshRateValue"; - m_pszDbDisplayNameFormat = "GoogleFinance_DspNameFrmt"; - m_pszDefDisplayFormat = L"%s %r"; - m_pszXMLIniFileName = L"GoogleFinance.xml"; - m_pszDbStatusMsgFormat = "GoogleFinance_StatusMessageFormat"; - - m_pszDbLogMode = "GoogleFinance_LogMode"; - m_pszDbHistoryFormat = "GoogleFinance_HistoryFormat"; - m_pszDbHistoryCondition = "GoogleFinance_AddToHistoryOnlyIfValueIsChanged"; - m_pszDbLogFile = "GoogleFinance_LogFile"; - m_pszDbLogFormat = "GoogleFinance_LogFileFormat"; - m_pszDbLogCondition = "GoogleFinance_AddToLogOnlyIfValueIsChanged"; - m_pszDbPopupFormat = "GoogleFinance_PopupFormat"; - m_pszDbPopupCondition = "GoogleFinance_ShowPopupOnlyIfValueChanged"; - - m_pszDbPopupColourMode = "GoogleFinance_PopupColourMode"; - m_pszDbPopupBkColour = "GoogleFinance_PopupColourBk"; - m_pszDbPopupTextColour = "GoogleFinance_PopupColourText"; - m_pszDbPopupDelayMode = "GoogleFinance_PopupDelayMode"; - m_pszDbPopupDelayTimeout = "GoogleFinance_PopupDelayTimeout"; - m_pszDbPopupHistoryFlag = "GoogleFinance_PopupHistoryFlag"; - - m_pszDbTendencyFormat = "GoogleFinance_TendencyFormat"; -} - -void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderYahoo&) -{ - m_pszDbRefreshRateType = "Yahoo_RefreshRateType"; - m_pszDbRefreshRateValue = "Yahoo_RefreshRateValue"; - m_pszDbDisplayNameFormat = "Yahoo_DspNameFrmt"; - m_pszDefDisplayFormat = L"%s %r"; - m_pszXMLIniFileName = L"Yahoo.xml"; - m_pszDbStatusMsgFormat = "Yahoo_StatusMessageFormat"; - - m_pszDbLogMode = "Yahoo_LogMode"; - m_pszDbHistoryFormat = "Yahoo_HistoryFormat"; - m_pszDbHistoryCondition = "Yahoo_AddToHistoryOnlyIfValueIsChanged"; - m_pszDbLogFile = "Yahoo_LogFile"; - m_pszDbLogFormat = "Yahoo_LogFileFormat"; - m_pszDbLogCondition = "Yahoo_AddToLogOnlyIfValueIsChanged"; - m_pszDbPopupFormat = "Yahoo_PopupFormat"; - m_pszDbPopupCondition = "Yahoo_ShowPopupOnlyIfValueChanged"; - - m_pszDbPopupColourMode = "Yahoo_PopupColourMode"; - m_pszDbPopupBkColour = "Yahoo_PopupColourBk"; - m_pszDbPopupTextColour = "Yahoo_PopupColourText"; - m_pszDbPopupDelayMode = "Yahoo_PopupDelayMode"; - m_pszDbPopupDelayTimeout = "Yahoo_PopupDelayTimeout"; - m_pszDbPopupHistoryFlag = "Yahoo_PopupHistoryFlag"; - - m_pszDbTendencyFormat = "Yahoo_TendencyFormat"; -} - void CQuotesProviderVisitorDbSettings::Visit(const CQuotesProviderCurrencyConverter&) { m_pszDbRefreshRateType = "CC_RefreshRateType"; diff --git a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h index 12ce87ee14..8c7003303e 100644 --- a/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h +++ b/plugins/Quotes/src/QuotesProviderVisitorDbSettings.h @@ -9,9 +9,6 @@ public: private: virtual void Visit(const CQuotesProviderBase& rProvider)override; - virtual void Visit(const CQuotesProviderDukasCopy& rProvider)override; - virtual void Visit(const CQuotesProviderGoogleFinance& rProvider)override; - virtual void Visit(const CQuotesProviderYahoo& rProvider)override; virtual void Visit(const CQuotesProviderCurrencyConverter& rProvider)override; public: LPCSTR m_pszDbRefreshRateType; diff --git a/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp b/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp index f6af082980..462776a5b7 100644 --- a/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp +++ b/plugins/Quotes/src/QuotesProviderVisitorFormater.cpp @@ -17,12 +17,6 @@ const tstring& CQuotesProviderVisitorFormater::GetResult()const return m_sResult; } -void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderDukasCopy&) -{ - if ('d' == m_chr || 'D' == m_chr) - m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_DESCRIPTION); -} - static bool get_fetch_time(MCONTACT hContact, time_t& rTime) { DBVARIANT dbv; @@ -85,23 +79,6 @@ void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderBase& rProvider) } } -void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderGoogleFinance&/* rProvider*/) -{ - switch (m_chr) { - case 'o': - FormatDoubleHelper(DB_STR_GOOGLE_FINANCE_OPEN_VALUE); - break; - case 'd': - FormatDoubleHelper(DB_STR_GOOGLE_FINANCE_DIFF, L"0"); - break; - case 'y': - FormatDoubleHelper(DB_STR_GOOGLE_FINANCE_PERCENT_CHANGE_TO_YERSTERDAY_CLOSE, L"0"); - break; - case 'n': - m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_DESCRIPTION); - break; - } -} tstring format_double(double dValue, int nWidth) { @@ -126,30 +103,6 @@ void CQuotesProviderVisitorFormater::FormatDoubleHelper(LPCSTR pszDbSet, m_sResult = sInvalid; } -void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderYahoo&) -{ - switch (m_chr) { - case 'o': - FormatDoubleHelper(DB_STR_YAHOO_OPEN_VALUE); - break; - case 'h': - FormatDoubleHelper(DB_STR_YAHOO_DAY_HIGH); - break; - case 'P': - FormatDoubleHelper(DB_STR_YAHOO_PREVIOUS_CLOSE); - break; - case 'c': - FormatDoubleHelper(DB_STR_YAHOO_CHANGE); - break; - case 'g': - FormatDoubleHelper(DB_STR_YAHOO_DAY_LOW); - break; - case 'n': - m_sResult = Quotes_DBGetStringT(m_hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_DESCRIPTION); - break; - } -} - void CQuotesProviderVisitorFormater::Visit(const CQuotesProviderCurrencyConverter&) { switch (m_chr) { diff --git a/plugins/Quotes/src/QuotesProviderVisitorFormater.h b/plugins/Quotes/src/QuotesProviderVisitorFormater.h index 5017edd33b..b3c55f7108 100644 --- a/plugins/Quotes/src/QuotesProviderVisitorFormater.h +++ b/plugins/Quotes/src/QuotesProviderVisitorFormater.h @@ -10,10 +10,7 @@ public: const tstring& GetResult()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: diff --git a/plugins/Quotes/src/QuotesProviderVisitorTendency.cpp b/plugins/Quotes/src/QuotesProviderVisitorTendency.cpp index 1e6d4fe384..1ebe6d7c0c 100644 --- a/plugins/Quotes/src/QuotesProviderVisitorTendency.cpp +++ b/plugins/Quotes/src/QuotesProviderVisitorTendency.cpp @@ -18,42 +18,6 @@ void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderBase&) } } -void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderGoogleFinance&) -{ - switch (m_chr) { - case 'o': - GetValue(DB_STR_GOOGLE_FINANCE_OPEN_VALUE); - break; - case 'd': - GetValue(DB_STR_GOOGLE_FINANCE_DIFF); - break; - case 'y': - GetValue(DB_STR_GOOGLE_FINANCE_PERCENT_CHANGE_TO_YERSTERDAY_CLOSE); - break; - } -} - -void CQuotesProviderVisitorTendency::Visit(const CQuotesProviderYahoo&) -{ - switch (m_chr) { - case 'o': - GetValue(DB_STR_YAHOO_OPEN_VALUE); - break; - case 'h': - GetValue(DB_STR_YAHOO_DAY_HIGH); - break; - case 'P': - GetValue(DB_STR_YAHOO_PREVIOUS_CLOSE); - break; - case 'c': - GetValue(DB_STR_YAHOO_CHANGE); - break; - case 'g': - GetValue(DB_STR_YAHOO_DAY_LOW); - break; - } -} - void CQuotesProviderVisitorTendency::GetValue(LPCSTR pszDbKeyName) { m_bValid = Quotes_DBReadDouble(m_hContact, QUOTES_MODULE_NAME, pszDbKeyName, m_dResult); diff --git a/plugins/Quotes/src/QuotesProviderVisitorTendency.h b/plugins/Quotes/src/QuotesProviderVisitorTendency.h index 537f8bd0a6..7567bb65c6 100644 --- a/plugins/Quotes/src/QuotesProviderVisitorTendency.h +++ b/plugins/Quotes/src/QuotesProviderVisitorTendency.h @@ -11,8 +11,6 @@ public: private: virtual void Visit(const CQuotesProviderBase& rProvider); - virtual void Visit(const CQuotesProviderGoogleFinance& rProvider); - virtual void Visit(const CQuotesProviderYahoo& rProvider); private: void GetValue(LPCSTR pszDbKeyName); diff --git a/plugins/Quotes/src/QuotesProviderYahoo.cpp b/plugins/Quotes/src/QuotesProviderYahoo.cpp deleted file mode 100644 index c08a7c1ce8..0000000000 --- a/plugins/Quotes/src/QuotesProviderYahoo.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include "stdafx.h" - -void remove_quotes(tstring& s) -{ - if (*s.begin() == '"') - s.erase(s.begin()); - - if (*s.rbegin() == '"') { - tstring::iterator i(s.begin()); - std::advance(i, s.size() - 1); - s.erase(i); - } -} - -void remove_end_of_line(tstring& s) -{ - if (*s.rbegin() == '\n') { - tstring::iterator i(s.begin()); - std::advance(i, s.size() - 1); - s.erase(i); - } - if (*s.rbegin() == '\r') { - tstring::iterator i(s.begin()); - std::advance(i, s.size() - 1); - s.erase(i); - } -} - -bool t2d(const tstring& s, double& d) -{ - tistringstream stream(s); - stream >> d; - return ((false == stream.fail()) && (false == stream.bad())); -} - -typedef std::vector TStrings; - -bool get_double_from_parsed_line(MCONTACT hContact, const TStrings& rasParsedLine, size_t nIndex, const char* pszDbName) -{ - if (rasParsedLine.size() > nIndex) { - double d = 0.0; - if (true == t2d(rasParsedLine[nIndex], d)) - return Quotes_DBWriteDouble(hContact, QUOTES_MODULE_NAME, pszDbName, d); - } - - db_set_ws(hContact, QUOTES_MODULE_NAME, pszDbName, L""); - return false; -} - -void CQuotesProviderYahoo::RefreshQuotes(TContracts& anContacts) -{ - tstring sURL = GetURL(); - - typedef std::map TQuoteID2ContractHandles; - TQuoteID2ContractHandles aQuoteID2Handles; - tostringstream oURL; - oURL << sURL << L"dioksin.txt?s="; - for (TContracts::const_iterator i = anContacts.begin(); i != anContacts.end() && IsOnline(); ++i) { - MCONTACT hContact = *i; - - tstring sQuoteID = Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_ID); - aQuoteID2Handles[sQuoteID] = hContact; - if (i != anContacts.begin()) - oURL << L"+"; - - oURL << sQuoteID; - } - - if (true == IsOnline()) { - oURL << L"&f=snl1ohgpc1"; - CHTTPSession http; - if ((true == http.OpenURL(oURL.str())) && (true == IsOnline())) { - tstring sFile; - if ((true == http.ReadResponce(sFile)) && (true == IsOnline())) { - tistringstream out_str(sFile.c_str()); - while (false == out_str.eof()) { - tstring sLine; - std::getline(out_str, sLine); - if (false == sLine.empty()) { - remove_end_of_line(sLine); - - TStrings asStrings; - for (tstring::size_type nPos = sLine.find(','); nPos != tstring::npos; nPos = sLine.find(',')) { - tstring::iterator i(sLine.begin()); - std::advance(i, nPos); - tstring s(sLine.begin(), i); - remove_quotes(s); - asStrings.push_back(s); - - if (i != sLine.end()) { - std::advance(i, 1); - } - sLine.erase(sLine.begin(), i); - } - - if (false == sLine.empty()) { - remove_quotes(sLine); - - if (false == sLine.empty()) - asStrings.push_back(sLine); - } - - size_t cItems = asStrings.size(); - if (cItems >= 3) { - enum - { - indexSymbol = 0, - indexName, - indexLastTrade, - indexOpen, - indexDayHigh, - indexDayLow, - indexPreviousClose, - indexChange - }; - auto it3 = aQuoteID2Handles.find(asStrings[indexSymbol]); - if (it3 != aQuoteID2Handles.end()) { - MCONTACT hContact = it3->second; - double dRate = 0.0; - if (true == t2d(asStrings[indexLastTrade], dRate)) { - db_set_ws(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_DESCRIPTION, asStrings[indexName].c_str()); - - get_double_from_parsed_line(hContact, asStrings, indexOpen, DB_STR_YAHOO_OPEN_VALUE); - get_double_from_parsed_line(hContact, asStrings, indexDayHigh, DB_STR_YAHOO_DAY_HIGH); - get_double_from_parsed_line(hContact, asStrings, indexDayLow, DB_STR_YAHOO_DAY_LOW); - get_double_from_parsed_line(hContact, asStrings, indexPreviousClose, DB_STR_YAHOO_PREVIOUS_CLOSE); - get_double_from_parsed_line(hContact, asStrings, indexChange, DB_STR_YAHOO_CHANGE); - WriteContactRate(hContact, dRate); - aQuoteID2Handles.erase(it3); - } - } - } - } - } - } - } - - if (true == IsOnline()) { - std::for_each(aQuoteID2Handles.begin(), aQuoteID2Handles.end(), - [](const TQuoteID2ContractHandles::value_type& pair) { SetContactStatus(pair.second, ID_STATUS_NA); }); - } - } -} - -void CQuotesProviderYahoo::Accept(CQuotesProviderVisitor& visitor)const -{ - CQuotesProviderFinance::Accept(visitor); - visitor.Visit(*this); -} diff --git a/plugins/Quotes/src/QuotesProviderYahoo.h b/plugins/Quotes/src/QuotesProviderYahoo.h deleted file mode 100644 index a5209c504a..0000000000 --- a/plugins/Quotes/src/QuotesProviderYahoo.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __E927F394_5452_458E_AF48_71E44F9EE793_QuotesProviderYahoo_h__ -#define __E927F394_5452_458E_AF48_71E44F9EE793_QuotesProviderYahoo_h__ - -#define DB_STR_YAHOO_OPEN_VALUE "OpenQuotePrice" -#define DB_STR_YAHOO_DAY_HIGH "DayHigh" -#define DB_STR_YAHOO_DAY_LOW "DayLow" -#define DB_STR_YAHOO_PREVIOUS_CLOSE "PreviousClose" -#define DB_STR_YAHOO_CHANGE "Change" - -class CQuotesProviderYahoo : public CQuotesProviderFinance -{ -private: - virtual void RefreshQuotes(TContracts& anContacts); - virtual void Accept(CQuotesProviderVisitor& visitor)const; -}; - -#endif //__E927F394_5452_458E_AF48_71E44F9EE793_QuotesProviderYahoo_h__ diff --git a/plugins/Quotes/src/QuotesProviders.cpp b/plugins/Quotes/src/QuotesProviders.cpp index c9bb5fc045..e8c202e3af 100644 --- a/plugins/Quotes/src/QuotesProviders.cpp +++ b/plugins/Quotes/src/QuotesProviders.cpp @@ -27,9 +27,6 @@ templatevoid create_provider(CQuotesProviders::TQuotesProviders& apProv void CQuotesProviders::CreateProviders() { - create_provider(m_apProviders); - create_provider(m_apProviders); - create_provider(m_apProviders); create_provider(m_apProviders); } diff --git a/plugins/Quotes/src/resource.h b/plugins/Quotes/src/resource.h index c0154194f1..0cbfb68af1 100644 --- a/plugins/Quotes/src/resource.h +++ b/plugins/Quotes/src/resource.h @@ -2,7 +2,6 @@ // Microsoft Visual C++ generated include file. // Used by C:\Code\miranda-ng-from-github\plugins\Quotes\res\Forex.rc // -#define IDD_DIALOG_ECONOMIC_RATES 101 #define IDI_ICON_MAIN 102 #define IDD_DIALOG_QUOTE_INFO 102 #define IDD_DIALOG_OPT_GOOGLE 103 @@ -16,7 +15,6 @@ #define IDI_ICON_CURRENCY_CONVERTER 117 #define IDD_DIALOG_QUOTE_INFO_1 118 #define IDI_ICON_REFRESH 118 -#define IDD_DIALOG_OPT_FINANCE 119 #define IDI_ICON_IMPORT 119 #define IDI_ICON_EXPORT 120 #define IDD_PROVIDER_ADV_SETTINGS 120 @@ -25,7 +23,6 @@ #define IDI_ICON_MAIN1 122 #define IDI_ICON_DISABLED 122 #define IDD_DIALOG_VARIABLE_LIST 123 -#define IDC_TREE_ECONOMIC_RATES 1001 #define IDC_EDIT_REFRESH_RATE 1002 #define IDC_SPIN_REFRESH_RATE 1003 #define IDC_COMBO_REFRESH_RATE 1004 @@ -69,7 +66,6 @@ #define IDC_BUTTON_LOG_FILE_DESCRIPTION2 1037 #define IDC_BUTTON_POPUP_FORMAT_DESCRIPTION 1037 #define IDC_EDIT_RESULT 1039 -#define IDC_EDIT_QUOTE 1059 #define IDC_BUTTON_SWAP 1060 #define IDC_BUTTON_ADVANCED_SETTINGS 1061 #define IDC_BUTTON_POPUP_SETTINGS 1061 diff --git a/plugins/Quotes/src/stdafx.h b/plugins/Quotes/src/stdafx.h index 4c2eb96152..fe54397d9f 100644 --- a/plugins/Quotes/src/stdafx.h +++ b/plugins/Quotes/src/stdafx.h @@ -91,14 +91,9 @@ inline tstring quotes_a2t(const char* s) #include "Locale.h" #include "ExtraImages.h" #include "IsWithinAccuracy.h" -#include "OptionDukasCopy.h" #include "IQuotesProvider.h" #include "QuotesProviders.h" #include "QuotesProviderBase.h" -#include "QuotesProviderFinance.h" -#include "QuotesProviderYahoo.h" -#include "QuotesProviderDukasCopy.h" -#include "QuotesProviderGoogleFinance.h" #include "QuotesProviderVisitor.h" #include "QuotesProviderVisitorDbSettings.h" #include "QuotesProviderVisitorFormater.h" diff --git a/plugins/Quotes/src/version.h b/plugins/Quotes/src/version.h index b153c00a64..94b91a4834 100644 --- a/plugins/Quotes/src/version.h +++ b/plugins/Quotes/src/version.h @@ -5,9 +5,9 @@ #include -#define __PLUGIN_NAME "Quotes" +#define __PLUGIN_NAME "Currency Rates" #define __FILENAME "Quotes.dll" -#define __DESCRIPTION "Shows currency rates and economic quotes." +#define __DESCRIPTION "Shows currency rates." #define __AUTHOR "Dioksin" #define __AUTHORWEB "https://miranda-ng.org/p/Quotes/" #define __COPYRIGHT "" -- cgit v1.2.3