From 66526765714b08969548a414d3fa87dbe333242d Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Sat, 28 Jul 2012 19:25:08 +0000 Subject: "!Deprecated" folders moved from root directory to plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@1230 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../!NotAdopted/XSoundNotify/EventProcessor.cpp | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 plugins/!NotAdopted/XSoundNotify/EventProcessor.cpp (limited to 'plugins/!NotAdopted/XSoundNotify/EventProcessor.cpp') diff --git a/plugins/!NotAdopted/XSoundNotify/EventProcessor.cpp b/plugins/!NotAdopted/XSoundNotify/EventProcessor.cpp new file mode 100644 index 0000000000..6a97b6b125 --- /dev/null +++ b/plugins/!NotAdopted/XSoundNotify/EventProcessor.cpp @@ -0,0 +1,84 @@ +#include "EventProcessor.h" +#include +#include "m_protocols.h" +#include +#include "DebugLogger.hpp" + +// static area + +static std::unique_ptr XSN_EventProcessorPtr; + +void XSN_EventProcessor::make(PLUGINLINK * pl) +{ + XSN_EventProcessorPtr.reset(new XSN_EventProcessor(pl)); +} + +XSN_EventProcessor & XSN_EventProcessor::instance() +{ + return *XSN_EventProcessorPtr; +} + +// class methods + +XSN_EventProcessor::XSN_EventProcessor(PLUGINLINK * pl) : pluginLink(pl) +{ + +} + +void XSN_EventProcessor::process(WPARAM wParam, LPARAM lParam) +{ + if (!wParam || !lParam || !isReceiveMessage(lParam)) + return ; + try + { + MessageBox(0, "Receive message", "INFO", MB_OK); + /*GRS_DEBUG_LOG("Receive message"); + HANDLE contact = (HANDLE)wParam; + MessageBox(0, "Get protocol", "INFO", MB_OK); + GRS_DEBUG_LOG("Protocol : "); + xsn_string proto = getProtocol(wParam); + MessageBox(0, "Protocol is", proto.c_str(), MB_OK); + GRS_DEBUG_FORMAT_LOG(proto) + //xsn_string nick = getNick(wParam, proto.c_str()); + XSN_Variant sound; + DBGetContactSettingTString(contact, proto.c_str(), "XSNPlugin_sound", &sound); + if (!sound.empty()) + { + GRS_DEBUG_LOG("Sound for user exist"); + GRS_DEBUG_FORMAT_LOG("Playing sound : " << sound.ptszVal << ", for user : " << getNick(wParam, proto.c_str())); + PlaySound(sound.toString().c_str(), nullptr, SND_FILENAME | SND_ASYNC); + }*/ + } + catch (std::runtime_error &) + { + //MessageBoxA(0, e.what(), "Runtime error", MB_OK); + } + catch (...) + { + //MessageBoxA(0, "Unknown error occured", "Exception", MB_OK); + } +} + +bool XSN_EventProcessor::isReceiveMessage(LPARAM event) +{ + DBEVENTINFO info ={ sizeof(info) }; + CallService(MS_DB_EVENT_GET, event, (LPARAM)&info); + + // TODO : rec msg flag : 16, send msg flag : 18 - WTF? + // return (info.eventType == EVENTTYPE_MESSAGE) && (info.flags & DBEF_READ); + // It's condition work well - magic? + return !(((info.eventType != EVENTTYPE_MESSAGE) && !(info.flags & DBEF_READ)) || (info.flags & DBEF_SENT)); +} + +xsn_string XSN_EventProcessor::getProtocol(WPARAM contact) +{ + char *pszProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, contact, 0); + return xsn_string(pszProto); +} + +xsn_string XSN_EventProcessor::getNick(WPARAM contact, LPCTSTR protocol) +{ + XSN_Variant nick; + DBGetContactSettingTString((HANDLE)contact, protocol, "Nick", &nick); + return nick.toString(); +} -- cgit v1.2.3