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/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 +- 23 files changed, 11 insertions(+), 1557 deletions(-) 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/src') 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