From 4e5548a98703325099017bf6bf04b2fb5edefbd4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 12 Aug 2014 18:59:44 +0000 Subject: this code was too crazy to work git-svn-id: http://svn.miranda-ng.org/main/trunk@10169 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Quotes/src/ExtraImages.cpp | 40 +++++-------------------------- plugins/Quotes/src/ExtraImages.h | 35 +++++++-------------------- plugins/Quotes/src/Forex.cpp | 1 + plugins/Quotes/src/QuotesProviderBase.cpp | 22 +++++++---------- 4 files changed, 24 insertions(+), 74 deletions(-) (limited to 'plugins/Quotes/src') diff --git a/plugins/Quotes/src/ExtraImages.cpp b/plugins/Quotes/src/ExtraImages.cpp index 8b14ce5c4c..83f10fa4f3 100644 --- a/plugins/Quotes/src/ExtraImages.cpp +++ b/plugins/Quotes/src/ExtraImages.cpp @@ -1,31 +1,15 @@ #include "StdAfx.h" -CExtraImages::CExtraImages() : - m_hExtraIcons(ExtraIcon_Register(ICON_STR_QUOTE,QUOTES_PROTOCOL_NAME,Quotes_MakeIconName(ICON_STR_MAIN).c_str())), - m_bExtraImagesInit(false) -{ - m_ahExtraImages[eiUp] = INVALID_HANDLE_VALUE; - m_ahExtraImages[eiDown] = INVALID_HANDLE_VALUE; - m_ahExtraImages[eiNotChanged] = INVALID_HANDLE_VALUE; -} - -CExtraImages::~CExtraImages() -{ -} +static HANDLE hExtraIcon; -CExtraImages& CExtraImages::GetInstance() +void Quotes_InitExtraIcons() { - static CExtraImages s_ei; - return s_ei; + hExtraIcon = ExtraIcon_Register(ICON_STR_QUOTE, QUOTES_PROTOCOL_NAME, Quotes_MakeIconName(ICON_STR_MAIN).c_str()); } -void CExtraImages::RebuildExtraImages() +bool SetContactExtraImage(MCONTACT hContact,EImageIndex nIndex) { -} - -bool CExtraImages::SetContactExtraImage(MCONTACT hContact,EImageIndex nIndex)const -{ - if (!m_hExtraIcons) + if (!hExtraIcon) return false; HANDLE hIcolib; @@ -42,17 +26,5 @@ bool CExtraImages::SetContactExtraImage(MCONTACT hContact,EImageIndex nIndex)con default: hIcolib = NULL; } - return ExtraIcon_SetIcon(m_hExtraIcons, hContact, hIcolib) == 0; + return ExtraIcon_SetIcon(hExtraIcon, hContact, hIcolib) == 0; } - -// int QuotesEventFunc_onExtraImageApply(WPARAM wp,LPARAM lp) -// { -// MCONTACT hContact = MCONTACT(wp); -// -// const CModuleInfo::TQuotesProvidersPtr& pProviders = CModuleInfo::GetQuoteProvidersPtr(); -// CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact); -// if(pProvider) -// pProvider->SetContactExtraIcon(hContact); -// -// return 0; -// } diff --git a/plugins/Quotes/src/ExtraImages.h b/plugins/Quotes/src/ExtraImages.h index d5581c6df3..ccad667636 100644 --- a/plugins/Quotes/src/ExtraImages.h +++ b/plugins/Quotes/src/ExtraImages.h @@ -1,35 +1,16 @@ #ifndef __9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__ #define __9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__ -class CExtraImages : private boost::noncopyable +enum EImageIndex { -public: - enum EImageIndex - { - eiUp = 0, - eiDown = 1, - eiNotChanged = 2, - eiEmpty = 3, - ImageCount = 3 - }; - -private: - CExtraImages(); - ~CExtraImages(); - -public: - static CExtraImages& GetInstance(); - - void RebuildExtraImages(); - bool SetContactExtraImage(MCONTACT hContact,EImageIndex nIndex)const; - -private: - mutable CLightMutex m_lmExtraImages; - HANDLE m_ahExtraImages[ImageCount]; - HANDLE m_hExtraIcons; - bool m_bExtraImagesInit; + eiUp = 0, + eiDown = 1, + eiNotChanged = 2, + eiEmpty = 3 }; -// int QuotesEventFunc_onExtraImageApply(WPARAM wp,LPARAM lp); +bool SetContactExtraImage(MCONTACT hContact,EImageIndex nIndex); + +void Quotes_InitExtraIcons(void); #endif //__9d0dac0c_12e4_46ce_809a_db6dc7d6f269_ExtraImages_h__ diff --git a/plugins/Quotes/src/Forex.cpp b/plugins/Quotes/src/Forex.cpp index 6eda62e7d2..e03f8fccd9 100644 --- a/plugins/Quotes/src/Forex.cpp +++ b/plugins/Quotes/src/Forex.cpp @@ -472,6 +472,7 @@ extern "C" } Quotes_IconsInit(); + Quotes_InitExtraIcons(); PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE }; pd.szName = QUOTES_PROTOCOL_NAME; diff --git a/plugins/Quotes/src/QuotesProviderBase.cpp b/plugins/Quotes/src/QuotesProviderBase.cpp index 560bfde7c2..d05d21f304 100644 --- a/plugins/Quotes/src/QuotesProviderBase.cpp +++ b/plugins/Quotes/src/QuotesProviderBase.cpp @@ -273,7 +273,7 @@ void CQuotesProviderBase::SetContactStatus(MCONTACT hContact,int nNewStatus) db_set_ts(hContact,LIST_MODULE_NAME,CONTACT_LIST_NAME,sSymbol.c_str()); } - CExtraImages::GetInstance().SetContactExtraImage(hContact,CExtraImages::eiEmpty); + SetContactExtraImage(hContact, eiEmpty); } } } @@ -588,19 +588,15 @@ namespace //if(true == IsWithinAccuracy(dCurrRate,dPrevRate)) if(CTendency::NotChanged == nComparison) - { - bResult = CExtraImages::GetInstance().SetContactExtraImage(hContact,CExtraImages::eiNotChanged); - } - else if(CTendency::Up == nComparison)//(dCurrRate > dPrevRate) - { - bResult = CExtraImages::GetInstance().SetContactExtraImage(hContact,CExtraImages::eiUp); - } - else if(CTendency::Down == nComparison)//(dCurrRate < dPrevRate) - { - bResult = CExtraImages::GetInstance().SetContactExtraImage(hContact,CExtraImages::eiDown); - } + return SetContactExtraImage(hContact, eiNotChanged); + + if(CTendency::Up == nComparison)//(dCurrRate > dPrevRate) + return SetContactExtraImage(hContact, eiUp); + + if(CTendency::Down == nComparison)//(dCurrRate < dPrevRate) + return SetContactExtraImage(hContact, eiDown); - return bResult; + return false; } bool show_popup(const IQuotesProvider* pProvider, -- cgit v1.2.3