diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2012-06-06 08:58:27 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2012-06-06 08:58:27 +0000 |
commit | b61ba851da0157ace3bdfc1ebbf87156b0b76413 (patch) | |
tree | d6c567db57af1eb09c254a8bee13c305282334f8 /protocols/Quotes/QuotesProviderBase.h | |
parent | a4c70f6bedb25e5cffb08dfc5cbc2597d1642d6b (diff) |
protocols plugins moved to protocols
git-svn-id: http://svn.miranda-ng.org/main/trunk@327 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Quotes/QuotesProviderBase.h')
-rw-r--r-- | protocols/Quotes/QuotesProviderBase.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/protocols/Quotes/QuotesProviderBase.h b/protocols/Quotes/QuotesProviderBase.h new file mode 100644 index 0000000000..76db155f4c --- /dev/null +++ b/protocols/Quotes/QuotesProviderBase.h @@ -0,0 +1,112 @@ +#ifndef __3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__
+#define __3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__
+
+#include "iquotesprovider.h"
+#include <vector>
+#include "LightMutex.h"
+
+class CQuotesProviderBase : public IQuotesProvider
+{
+public:
+ class CQuote
+ {
+ public:
+ CQuote(const tstring& rsID = _T(""),const tstring& rsSymbol = _T(""),const tstring& rsName = _T(""))
+ : m_sSymbol(rsSymbol),m_sName(rsName),m_sID(rsID){}
+
+ const tstring& GetSymbol()const{return m_sSymbol;}
+ const tstring& GetName()const{return m_sName;}
+ const tstring& GetID()const{return m_sID;}
+
+ private:
+ tstring m_sSymbol;
+ tstring m_sName;
+ tstring m_sID;
+ };
+
+ class CQuoteSection
+ {
+ public:
+ typedef std::vector<CQuoteSection> TSections;
+ typedef std::vector<CQuote> TQuotes;
+
+ public:
+ CQuoteSection(const tstring& rsName = _T(""),const TSections& raSections = TSections(),const TQuotes& raQuotes = TQuotes())
+ : m_sName(rsName),m_aSections(raSections),m_aQuotes(raQuotes){}
+
+ const tstring& GetName()const
+ {return m_sName;}
+
+ size_t GetSectionCount()const
+ {return m_aSections.size();}
+ CQuoteSection GetSection(size_t nIndex)const
+ {return ((nIndex < m_aSections.size()) ? m_aSections[nIndex] : CQuoteSection());}
+
+ size_t GetQuoteCount()const
+ {return m_aQuotes.size();}
+ CQuote GetQuote(size_t nIndex)const
+ {return ((nIndex < m_aQuotes.size()) ? m_aQuotes[nIndex] : CQuote());}
+
+ private:
+ tstring m_sName;
+ TSections m_aSections;
+ TQuotes m_aQuotes;
+ };
+
+protected:
+ typedef std::vector<HANDLE> TContracts;
+
+public:
+ struct CXMLFileInfo;
+
+public:
+ CQuotesProviderBase();
+ ~CQuotesProviderBase();
+
+
+ const CQuoteSection& GetQuotes()const;
+// void SetSettingsEvent();
+
+ virtual bool Init();
+ virtual const CProviderInfo& GetInfo()const;
+ virtual void AddContact(HANDLE hContact);
+ virtual void DeleteContact(HANDLE hContact);
+ virtual void Run();
+ virtual void Accept(CQuotesProviderVisitor& visitor)const;
+ virtual void RefreshAll();
+ virtual void RefreshContact(HANDLE hContact);
+ virtual void SetContactExtraIcon(HANDLE hContact)const;
+
+protected:
+ const tstring& GetURL()const;
+ HANDLE CreateNewContact(const tstring& rsName);
+ static bool IsOnline();
+ static void SetContactStatus(HANDLE hContact,int nNewStatus);
+ void WriteContactRate(HANDLE hContact,double dRate,const tstring& rsSymbol = _T(""));
+
+private:
+ virtual void RefreshQuotes(TContracts& anContacts) = 0;
+
+private:
+ virtual void OnEndRun();
+
+private:
+ CXMLFileInfo* GetXMLFileInfo()const;
+
+protected:
+ TContracts m_aContacts;
+ mutable CLightMutex m_cs;
+
+private:
+ typedef boost::scoped_ptr<CXMLFileInfo> TXMLFileInfoPtr;
+ mutable TXMLFileInfoPtr m_pXMLInfo;
+ HANDLE m_hEventSettingsChanged;
+ HANDLE m_hEventRefreshContact;
+ tstring m_sContactListFormat;
+ tstring m_sStatusMsgFormat;
+ tstring m_sTendencyFormat;
+ TContracts m_aRefreshingContacts;
+ bool m_bRefreshInProgress;
+};
+
+#endif //__3e6cb4ec_fc47_468f_a2c8_a77941176bc9_QuotesProviderBase_h__
|