From 8d3307adf7ba64b75fb4de363f873c97286b0e9b Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 2 Apr 2013 13:26:06 +0000 Subject: - XSoundNotify - adopted git-svn-id: http://svn.miranda-ng.org/main/trunk@4284 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/XSoundNotify/src/xsn_main.cpp | 105 ++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 plugins/XSoundNotify/src/xsn_main.cpp (limited to 'plugins/XSoundNotify/src/xsn_main.cpp') diff --git a/plugins/XSoundNotify/src/xsn_main.cpp b/plugins/XSoundNotify/src/xsn_main.cpp new file mode 100644 index 0000000000..5bd0c3b530 --- /dev/null +++ b/plugins/XSoundNotify/src/xsn_main.cpp @@ -0,0 +1,105 @@ +/* +Miranda plugin template, originally by Richard Hughes +http://miranda-icq.sourceforge.net/ + +This file is placed in the public domain. Anybody is free to use or +modify it as they wish with no restriction. +There is no warranty. +*/ + +#include "Common.h" + +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {08B86253-EC6E-4D09-B7A9-64ACDF0627B8} + {0x8b86253, 0xec6e, 0x4d09, {0xb7, 0xa9, 0x64, 0xac, 0xdf, 0x6, 0x27, 0xb8}} +}; + +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +static INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam) +{ + try + { + SoundNotifyDataStorage storage; + storage.init(); + SettingsDialog dlg(storage); + if (dlg.DoModal() == IDOK) + storage.commit(); + } + catch (...) + { + MessageBox(0, TEXT("Unknown error occured while configuring"), TEXT("XSoundNotify Error"), MB_OK | MB_ICONERROR); + } + + return 0; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +INT processEvent(WPARAM wParam, LPARAM lParam) +{ + try + { + if (!isReceiveMessage(lParam)) + return 0; + + xsn_string sound = getContactSound((HANDLE)wParam); + if (!sound.empty()) + PlaySound(sound.c_str(), nullptr, SND_ASYNC | SND_FILENAME); + } + catch (std::exception & ) + { + // log + } + catch (...) + { + // log + } + + return 0; +} + +extern "C" int __declspec(dllexport) Load() +{ + mir_getLP(&pluginInfo); + + CLISTMENUITEM mi; + + CreateServiceFunction("XSoundNotify/MenuCommand", PluginMenuCommand); + ZeroMemory(&mi, sizeof(mi)); + mi.cbSize = sizeof(mi); + mi.position = -0x7FFFFFFF; + mi.flags = 0; + mi.hIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA); + mi.pszName = LPGEN("&XSoundNotify Plugin"); + mi.pszService = "XSoundNotify/MenuCommand"; + Menu_AddMainMenuItem(&mi); + HookEvent(ME_DB_EVENT_ADDED, processEvent); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} + -- cgit v1.2.3