summaryrefslogtreecommitdiff
path: root/plugins/!NotAdopted/WinterSpeak/speak/announce/protocol_information.cpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2013-03-17 13:41:49 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2013-03-17 13:41:49 +0000
commit5e6e1e8838fe7637ef588e0fb080ad07fc5700aa (patch)
tree2cc32c95da0cf49f8361879eec1fa5a4a4b557d8 /plugins/!NotAdopted/WinterSpeak/speak/announce/protocol_information.cpp
parent561f00a7d38c61ec30c5898b90766314011d32d8 (diff)
Winter Speak plugin added (not adopted)
git-svn-id: http://svn.miranda-ng.org/main/trunk@4076 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/WinterSpeak/speak/announce/protocol_information.cpp')
-rw-r--r--plugins/!NotAdopted/WinterSpeak/speak/announce/protocol_information.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/WinterSpeak/speak/announce/protocol_information.cpp b/plugins/!NotAdopted/WinterSpeak/speak/announce/protocol_information.cpp
new file mode 100644
index 0000000000..b3d9752bd4
--- /dev/null
+++ b/plugins/!NotAdopted/WinterSpeak/speak/announce/protocol_information.cpp
@@ -0,0 +1,100 @@
+//==============================================================================
+// Miranda Speak Plugin, © 2002 Ryan Winter
+//==============================================================================
+
+#pragma warning(disable:4786)
+
+#include "protocol_information.h"
+
+#include <general/debug/debug.h>
+
+//------------------------------------------------------------------------------
+ProtocolInformation *ProtocolInformation::m_instance = 0;
+
+//------------------------------------------------------------------------------
+// public:
+//------------------------------------------------------------------------------
+ProtocolInformation::ProtocolInformation()
+ :
+ m_protocol_timeout()
+{
+ CLASSCERR("ProtocolInformation::ProtocolInformation");
+
+ m_instance = this;
+}
+
+//------------------------------------------------------------------------------
+ProtocolInformation::~ProtocolInformation()
+{
+ CLASSCERR("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)
+{
+ CLASSCERR("ProtocolInformation::disable(" << 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
+{
+ CLASSCERR("ProtocolInformation::isDisable(" << protocol << ")");
+
+ 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)
+{
+ CERR("ProtocolInformation::timeout(,,,)");
+
+ ProtocolTimeout pt = m_instance->m_protocol_timeout.front();
+
+ KillTimer(NULL, pt.second);
+
+ m_instance->m_protocol_timeout.pop_front();
+}
+
+//==============================================================================