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/EventInformation.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/EventInformation.cpp')
-rw-r--r-- | plugins/WinterSpeak/src/EventInformation.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/plugins/WinterSpeak/src/EventInformation.cpp b/plugins/WinterSpeak/src/EventInformation.cpp new file mode 100644 index 0000000000..69437a71ea --- /dev/null +++ b/plugins/WinterSpeak/src/EventInformation.cpp @@ -0,0 +1,85 @@ +#include "Common.h"
+#include "EventInformation.h"
+
+
+//------------------------------------------------------------------------------
+// public:
+//------------------------------------------------------------------------------
+EventInformation::EventInformation() : m_event_strings(), m_event_info()
+{
+ // insert the event strings into a map for easy access
+ m_event_strings[EVENTTYPE_MESSAGE] = TranslateW(L"incoming message from %u");
+ m_event_strings[EVENTTYPE_URL] = TranslateW(L"incoming U R L from %u");
+ m_event_strings[EVENTTYPE_ADDED] = TranslateW(L"you have been added to %u's contact list");
+ m_event_strings[EVENTTYPE_AUTHREQUEST] = TranslateW(L"%u requests your authorization");
+ m_event_strings[EVENTTYPE_FILE] = TranslateW(L"there is an incoming file from %u");
+
+ ZeroMemory(&m_event_info, sizeof(m_event_info));
+}
+
+//------------------------------------------------------------------------------
+EventInformation::~EventInformation()
+{
+}
+
+//------------------------------------------------------------------------------
+bool EventInformation::isValidEvent(HANDLE event)
+{
+ // clean up the old event
+ if (m_event_info.pBlob)
+ {
+ delete m_event_info.pBlob;
+ }
+ ZeroMemory(&m_event_info, sizeof(m_event_info));
+
+ // find out and assign the space we need for the new event
+ m_event_info.cbSize = sizeof(m_event_info);
+ m_event_info.cbBlob = db_event_getBlobSize(event);// CallService(MS_DB_EVENT_GETBLOBSIZE, reinterpret_cast<LPARAM>(event), 0);
+
+ if (-1 == m_event_info.cbBlob)
+ {
+ return false;
+ }
+ m_event_info.pBlob = new unsigned char[m_event_info.cbBlob];
+
+ // get the event info
+ db_event_get(event, &m_event_info);
+ //CallService(MS_DB_EVENT_GET, reinterpret_cast<LPARAM>(event), reinterpret_cast<LPARAM>(&m_event_info));
+
+ // if the event has already been read or was sent by me then exit
+ if (m_event_info.flags & (DBEF_SENT | DBEF_READ))
+ {
+ return false;
+ }
+
+ // if the event string doesn't exist in our list then exit
+ if (m_event_strings.find(m_event_info.eventType) == m_event_strings.end())
+ {
+ return false;
+ }
+
+ // event was good
+ return true;
+}
+
+//------------------------------------------------------------------------------
+std::wstring EventInformation::getMessage()
+{
+ const std::wstring intro = TranslateW(L"%u says");
+
+ return intro + L" " + mir_a2t_cp((char*)m_event_info.pBlob,CP_UTF8);
+}
+
+//------------------------------------------------------------------------------
+unsigned int EventInformation::getMessageSize()
+{
+ return std::wstring((WCHAR *)m_event_info.pBlob).size();
+}
+
+//------------------------------------------------------------------------------
+std::wstring EventInformation::eventString()
+{
+ return m_event_strings[m_event_info.eventType];
+}
+
+//==============================================================================
\ No newline at end of file |