From 9b119cadd74e1343cad493e8b366e69743a620d0 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sun, 21 Dec 2014 09:49:05 +0000 Subject: Quotes: changed warning level to w4 git-svn-id: http://svn.miranda-ng.org/main/trunk@11552 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Quotes/src/QuotesProviderFinance.cpp | 248 +++++++++++++-------------- 1 file changed, 124 insertions(+), 124 deletions(-) (limited to 'plugins/Quotes/src/QuotesProviderFinance.cpp') diff --git a/plugins/Quotes/src/QuotesProviderFinance.cpp b/plugins/Quotes/src/QuotesProviderFinance.cpp index 97fa950de3..78e7444987 100644 --- a/plugins/Quotes/src/QuotesProviderFinance.cpp +++ b/plugins/Quotes/src/QuotesProviderFinance.cpp @@ -3,12 +3,12 @@ void CQuotesProviderFinance::GetWatchedQuotes(TQuotes& raQuotes)const { raQuotes.clear(); - BOOST_FOREACH(MCONTACT hContact,m_aContacts) + 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); + 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); } @@ -18,20 +18,20 @@ namespace { inline tstring get_quote_id(MCONTACT hContact) { - return Quotes_DBGetStringT(hContact,QUOTES_MODULE_NAME,DB_STR_QUOTE_ID); + return Quotes_DBGetStringT(hContact, QUOTES_MODULE_NAME, DB_STR_QUOTE_ID); } - inline bool is_quote_id_equal(MCONTACT hContact,const tstring& sID) + 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) +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)); + 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())) { @@ -47,12 +47,12 @@ bool CQuotesProviderFinance::WatchForQuote(const CQuote& rQuote,bool bWatch) else if ((true == bWatch) && (i == m_aContacts.end())) { MCONTACT hContact = CreateNewContact(rQuote.GetSymbol()); - if(hContact) + if (hContact) { - db_set_ts(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_ID,sQuoteID.c_str()); - if(false == rQuote.GetName().empty()) + db_set_ts(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_ID, sQuoteID.c_str()); + if (false == rQuote.GetName().empty()) { - db_set_ts(hContact,QUOTES_PROTOCOL_NAME,DB_STR_QUOTE_DESCRIPTION,rQuote.GetName().c_str()); + db_set_ts(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_DESCRIPTION, rQuote.GetName().c_str()); } return true; @@ -66,9 +66,9 @@ MCONTACT CQuotesProviderFinance::GetContactByQuoteID(const tstring& rsQuoteID)co { CGuard cs(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()) + 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; } @@ -91,15 +91,15 @@ namespace const tstring& rsDesc = rQuote.GetName(); return((false == rsDesc.empty()) ? rsDesc : rQuote.GetSymbol()); } - - int add_quote_to_wnd(const CQuotesProviderBase::CQuote& rQuote,HWND hwnd) + + 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) + 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))) + if (LB_ERR == ::SendMessage(hwnd, LB_SETITEMDATA, nIndex, reinterpret_cast(pQuote))) { delete pQuote; } @@ -107,30 +107,30 @@ namespace return nIndex; } -// typedef CQuotesProviderFinance::TQuotes TQuotes; -// TQuotes g_aWatchedQuotes; + // typedef CQuotesProviderFinance::TQuotes TQuotes; + // TQuotes g_aWatchedQuotes; -// inline bool cmp_quotes(const tstring& rsQuoteId,const CQuotesProviderBase::CQuote& quote) -// { -// return (0 == quotes_stricmp(rsQuoteId.c_str(),quote.GetID().c_str())); -// } + // inline bool cmp_quotes(const tstring& rsQuoteId,const CQuotesProviderBase::CQuote& quote) + // { + // return (0 == quotes_stricmp(rsQuoteId.c_str(),quote.GetID().c_str())); + // } - CQuotesProviderBase::CQuote* get_quote_ptr_from_lb_index(HWND hwndListBox,int nIndex) + CQuotesProviderBase::CQuote* get_quote_ptr_from_lb_index(HWND hwndListBox, int nIndex) { - LRESULT lResult = ::SendMessage(hwndListBox,LB_GETITEMDATA,nIndex,0); + 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 is_quote_added(HWND hwndList, const tstring& rsQuoteID) { - int cItems = ::SendMessage(hwndList,LB_GETCOUNT,0,0); - for(int i = 0;i < cItems;++i) + int cItems = ::SendMessage(hwndList, LB_GETCOUNT, 0, 0); + for (int i = 0; i < cItems; ++i) { - const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndList,i); - if ((nullptr != pQuote) - && ((0 == quotes_stricmp(rsQuoteID.c_str(),pQuote->GetID().c_str())) - || (0 == quotes_stricmp(rsQuoteID.c_str(),pQuote->GetName().c_str())) - || (0 == quotes_stricmp(rsQuoteID.c_str(),pQuote->GetSymbol().c_str())))) + const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndList, i); + if ((nullptr != pQuote) + && ((0 == quotes_stricmp(rsQuoteID.c_str(), pQuote->GetID().c_str())) + || (0 == quotes_stricmp(rsQuoteID.c_str(), pQuote->GetName().c_str())) + || (0 == quotes_stricmp(rsQuoteID.c_str(), pQuote->GetSymbol().c_str())))) { return i; } @@ -138,63 +138,63 @@ namespace return LB_ERR; } - INT_PTR CALLBACK GoogleFinanceOptDlgProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam) + INT_PTR CALLBACK GoogleFinanceOptDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { CQuotesProviderFinance* pProvider = nullptr; - if(WM_INITDIALOG == message) + if (WM_INITDIALOG == message) { pProvider = reinterpret_cast(lParam); - SetWindowLongPtr(hDlg,GWLP_USERDATA,lParam); + SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); } else { - pProvider = reinterpret_cast(GetWindowLongPtr(hDlg,GWLP_USERDATA)); + pProvider = reinterpret_cast(GetWindowLongPtr(hDlg, GWLP_USERDATA)); } CCommonDlgProcData d(pProvider); - CommonOptionDlgProc(hDlg,message,wParam,lParam,d); + CommonOptionDlgProc(hDlg, message, wParam, lParam, d); - switch(message) + switch (message) { case WM_INITDIALOG: - { - TranslateDialogDefault(hDlg); + { + TranslateDialogDefault(hDlg); - CQuotesProviderFinance::TQuotes aQuotes; - pProvider->GetWatchedQuotes(aQuotes); + 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)); + 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); + ::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)) + if (EN_CHANGE == HIWORD(wParam)) { - ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_ADD),GetWindowTextLength(GetDlgItem(hDlg,IDC_EDIT_QUOTE)) > 0); + ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_ADD), GetWindowTextLength(GetDlgItem(hDlg, IDC_EDIT_QUOTE)) > 0); } return (TRUE); case IDC_BUTTON_ADD: - if(BN_CLICKED == HIWORD(wParam)) + if (BN_CLICKED == HIWORD(wParam)) { - HWND hEdit = GetDlgItem(hDlg,IDC_EDIT_QUOTE); + 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)) + 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) + CQuotesProviderBase::CQuote quote(sQuoteSymbol, sQuoteSymbol); + if (add_quote_to_wnd(quote, hwndList) >= 0) { - SetDlgItemText(hDlg,IDC_EDIT_QUOTE,_T("")); + SetDlgItemText(hDlg, IDC_EDIT_QUOTE, _T("")); SetFocus(hEdit); - PropSheet_Changed(::GetParent(hDlg),hDlg); + PropSheet_Changed(::GetParent(hDlg), hDlg); } else { @@ -204,93 +204,93 @@ namespace } return (TRUE); case IDC_BUTTON_REMOVE: - if(BN_CLICKED == HIWORD(wParam)) + if (BN_CLICKED == HIWORD(wParam)) { - HWND hWnd = ::GetDlgItem(hDlg,IDC_LIST_RATES); - int nSel = ::SendMessage(hWnd,LB_GETCURSEL,0,0); - if(LB_ERR != nSel) + 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); + CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hWnd, nSel); delete pQuote; - if(LB_ERR != ::SendMessage(hWnd,LB_DELETESTRING,nSel,0)) + if (LB_ERR != ::SendMessage(hWnd, LB_DELETESTRING, nSel, 0)) { - PropSheet_Changed(::GetParent(hDlg),hDlg); + PropSheet_Changed(::GetParent(hDlg), hDlg); } } - nSel = ::SendMessage(hWnd,LB_GETCURSEL,0,0); - ::EnableWindow(::GetDlgItem(hDlg,IDC_BUTTON_REMOVE),(LB_ERR != nSel)); + 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)) + 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)); + ::EnableWindow(::GetDlgItem(hDlg, IDC_BUTTON_REMOVE), (LB_ERR != nSel)); } return (TRUE); } return (FALSE); case WM_NOTIFY: + { + LPNMHDR pNMHDR = reinterpret_cast(lParam); + switch (pNMHDR->code) { - LPNMHDR pNMHDR = reinterpret_cast(lParam); - switch(pNMHDR->code) + case PSN_APPLY: + if (pProvider) { - 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) { - 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) { - const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndListBox,i); - if(pQuote) - { - apCurrent.push_back(pQuote); - } + apCurrent.push_back(pQuote); } - - std::for_each(aTemp.begin(),aTemp.end(), - [&apCurrent,pProvider](const CQuotesProviderBase::CQuote& quote) - { - if(apCurrent.end() == std::find_if(apCurrent.begin(),apCurrent.end(), - ["e](const CQuotesProviderBase::CQuote* pQuote){return 0 == quotes_stricmp(pQuote->GetID().c_str(),quote.GetID().c_str());})) - { - pProvider->WatchForQuote(quote,false); - } - }); - - std::for_each(apCurrent.begin(),apCurrent.end(), - [&aTemp,pProvider](const CQuotesProviderBase::CQuote* pQuote) - { - if(aTemp.end() == - std::find_if(aTemp.begin(),aTemp.end(), - [pQuote](const CQuotesProviderBase::CQuote& quote){return 0 == quotes_stricmp(pQuote->GetID().c_str(),quote.GetID().c_str());})) - { - pProvider->WatchForQuote(*pQuote,true); - } - - }); - - pProvider->RefreshSettings(); } - return (TRUE); + std::for_each(aTemp.begin(), aTemp.end(), + [&apCurrent, pProvider](const CQuotesProviderBase::CQuote& quote) + { + if (apCurrent.end() == std::find_if(apCurrent.begin(), apCurrent.end(), + ["e](const CQuotesProviderBase::CQuote* pQuote){return 0 == quotes_stricmp(pQuote->GetID().c_str(), quote.GetID().c_str()); })) + { + pProvider->WatchForQuote(quote, false); + } + }); + + std::for_each(apCurrent.begin(), apCurrent.end(), + [&aTemp, pProvider](const CQuotesProviderBase::CQuote* pQuote) + { + if (aTemp.end() == + std::find_if(aTemp.begin(), aTemp.end(), + [pQuote](const CQuotesProviderBase::CQuote& quote){return 0 == quotes_stricmp(pQuote->GetID().c_str(), quote.GetID().c_str()); })) + { + pProvider->WatchForQuote(*pQuote, true); + } + + }); + + pProvider->RefreshSettings(); } + + return (TRUE); } - return (FALSE); + } + 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) + 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); + const CQuotesProviderBase::CQuote* pQuote = get_quote_ptr_from_lb_index(hwndListBox, i); delete pQuote; } return (FALSE); @@ -305,5 +305,5 @@ void CQuotesProviderFinance::ShowPropertyPage(WPARAM wp, OPTIONSDIALOGPAGE &odp) odp.pfnDlgProc = GoogleFinanceOptDlgProc; odp.dwInitParam = reinterpret_cast(static_cast(this)); odp.ptszTab = const_cast(GetInfo().m_sName.c_str()); - Options_AddPage(wp, &odp); + Options_AddPage(wp, &odp); } -- cgit v1.2.3