diff options
author | Philip Schell <github.com@blubbfish.net> | 2013-10-19 13:05:02 +0000 |
---|---|---|
committer | Philip Schell <github.com@blubbfish.net> | 2013-10-19 13:05:02 +0000 |
commit | 397e25f2b71347c7c83495fe5b25496ff3b02b75 (patch) | |
tree | 71f6ad2ef525218541a7a35cc659b4fb7bf047d6 /plugins/WinterSpeak/src/ProtocolInformation.cpp | |
parent | 9e786b686fae94e71279a797047a91ffdc4b0443 (diff) |
WinterSpeak: ticket:269 WinterSpeak now rewritten
git-svn-id: http://svn.miranda-ng.org/main/trunk@6532 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/WinterSpeak/src/ProtocolInformation.cpp')
-rw-r--r-- | plugins/WinterSpeak/src/ProtocolInformation.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/plugins/WinterSpeak/src/ProtocolInformation.cpp b/plugins/WinterSpeak/src/ProtocolInformation.cpp new file mode 100644 index 0000000000..d04f485a9b --- /dev/null +++ b/plugins/WinterSpeak/src/ProtocolInformation.cpp @@ -0,0 +1,78 @@ +#include "Common.h"
+#include "ProtocolInformation.h"
+
+
+//------------------------------------------------------------------------------
+ProtocolInformation *ProtocolInformation::m_instance = 0;
+
+//------------------------------------------------------------------------------
+// public:
+//------------------------------------------------------------------------------
+ProtocolInformation::ProtocolInformation() : m_protocol_timeout()
+{
+ m_instance = this;
+}
+
+//------------------------------------------------------------------------------
+ProtocolInformation::~ProtocolInformation()
+{
+ m_instance = 0;
+
+ // kill all the timers
+ for (ProtocolTimeoutQueue::const_iterator iter = m_protocol_timeout.begin();
+ iter != m_protocol_timeout.end();
+ ++iter)
+ {
+ KillTimer(NULL, (*iter).second);
+ }
+}
+
+//------------------------------------------------------------------------------
+void ProtocolInformation::disable(const char *protocol)
+{
+ if (NULL == protocol)
+ {
+ return;
+ }
+
+ const unsigned int TIMEOUT = 10000;
+
+ unsigned int t = SetTimer(NULL, NULL, TIMEOUT, ProtocolInformation::timeout);
+ m_protocol_timeout.push_back(std::make_pair(protocol, t));
+}
+
+//------------------------------------------------------------------------------
+bool ProtocolInformation::isDisabled(const char *protocol) const
+{
+ if (NULL == protocol)
+ {
+ return false;
+ }
+
+ // iterate through the list and see if the protocol has a timer callback
+ for (ProtocolTimeoutQueue::const_iterator iter = m_protocol_timeout.begin();
+ iter != m_protocol_timeout.end();
+ ++iter)
+ {
+ if (0 == (*iter).first.compare(protocol))
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+//------------------------------------------------------------------------------
+// private:
+//------------------------------------------------------------------------------
+void CALLBACK ProtocolInformation::timeout(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
+{
+ ProtocolTimeout pt = m_instance->m_protocol_timeout.front();
+
+ KillTimer(NULL, pt.second);
+
+ m_instance->m_protocol_timeout.pop_front();
+}
+
+//==============================================================================
|