From 0c3d3e587e699d06352f269d887d749a8542559a Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 1 Nov 2006 14:58:39 +0000 Subject: git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@26 4f64403b-2f21-0410-a795-97e2b3489a10 --- yapp/notify_imp.cpp | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 yapp/notify_imp.cpp (limited to 'yapp/notify_imp.cpp') diff --git a/yapp/notify_imp.cpp b/yapp/notify_imp.cpp new file mode 100644 index 0000000..acb9d36 --- /dev/null +++ b/yapp/notify_imp.cpp @@ -0,0 +1,125 @@ +#include "common.h" +#include "resource.h" +#include "notify.h" +#include "message_pump.h" +#include "docs/m_popup2.h" + +HANDLE hhkShow=0, hhkUpdate=0, hhkRemove=0; + +//struct + +int Popup2Show(WPARAM wParam, LPARAM lParam) { + + HANDLE hNotify = (HANDLE)lParam; + + POPUPDATAW *pd_out = (POPUPDATAW *)malloc(sizeof(POPUPDATAW)); + memset(pd_out, 0, sizeof(POPUPDATAW)); + + PostMPMessage(MUM_CREATEPOPUP, (WPARAM)hNotify, (LPARAM)pd_out); + PostMPMessage(MUM_NMUPDATE, (WPARAM)hNotify, (LPARAM)0); + return 0; +} + +int Popup2Update(WPARAM wParam, LPARAM lParam) { + HANDLE hNotify = (HANDLE)lParam; + PostMPMessage(MUM_NMUPDATE, (WPARAM)hNotify, (LPARAM)0); + return 0; +} + +int Popup2Remove(WPARAM wParam, LPARAM lParam) { + HANDLE hNotify = (HANDLE)lParam; + PostMPMessage(MUM_NMREMOVE, (WPARAM)hNotify, (LPARAM)0); + return 0; +} + +int svcPopup2DefaultActions(WPARAM wParam, LPARAM lParam) +{ + //PopupWindow *wnd = (PopupWindow *)MNotifyGetDWord((HANDLE)lParam, "Popup2/data", (DWORD)NULL); + //if (!wnd) return 0; + switch (wParam) + { + case 0: + { // send message + //if (wnd->lchContact) CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)wnd->lchContact, 0); + //SendMessage(wnd->lchMain, UM_DESTROYPOPUP, 0, 0); + break; + } + case 1: + { // dismiss popup + //SendMessage(wnd->lchMain, UM_DESTROYPOPUP, 0, 0); + break; + } + } + return 0; +} + +BOOL CALLBACK DlgProcPopUps(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ +/* To change options use MNotifySet*(hNotify, ....) Apply/Cancel is implemented in notify.dll */ + HANDLE hNotify = (HANDLE)GetWindowLong(hwnd, GWL_USERDATA); + switch (msg) + { + case WM_USER+100: + { + // This will be extendet to handle array of handles for multiselect lParam + // will be HANDLE * and wParam wil; store amount of handles passed + hNotify = (HANDLE)lParam; + SetWindowLong(hwnd, GWL_USERDATA, lParam); + return TRUE; + } + + case WM_COMMAND: + // This in different from Miranda options! + SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); + break; + } + return FALSE; +} + +int NotifyOptionsInitialize(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = {0}; + odp.cbSize = sizeof(odp); + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NOTIFY); + odp.pszTitle = Translate("YAPP Popups"); + odp.flags=ODPF_BOLDGROUPS; + odp.pfnDlgProc = DlgProcPopUps; + CallService(MS_NOTIFY_OPT_ADDPAGE, wParam, (LPARAM)&odp); + return 0; +} + +HANDLE hEventNotifyOptInit, hEventNotifyModulesLoaded; + +int NotifyModulesLoaded(WPARAM wParam,LPARAM lParam) +{ + hEventNotifyOptInit = HookEvent(ME_NOTIFY_OPT_INITIALISE, NotifyOptionsInitialize); + return 0; +} + +HANDLE hServicesNotify[4]; +void InitNotify() { + hhkShow = HookEvent(ME_NOTIFY_SHOW, Popup2Show); + hhkUpdate = HookEvent(ME_NOTIFY_UPDATE, Popup2Update); + hhkRemove = HookEvent(ME_NOTIFY_REMOVE, Popup2Remove); + + hServicesNotify[0] = CreateServiceFunction("Popup2/DefaultActions", svcPopup2DefaultActions); + + hServicesNotify[1] = CreateServiceFunction(MS_POPUP2_SHOW, Popup2Show); + hServicesNotify[2] = CreateServiceFunction(MS_POPUP2_UPDATE, Popup2Update); + hServicesNotify[3] = CreateServiceFunction(MS_POPUP2_REMOVE, Popup2Remove); + + hEventNotifyModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, NotifyModulesLoaded); +} + +void DeinitNotify() { + UnhookEvent(hhkShow); + UnhookEvent(hhkUpdate); + UnhookEvent(hhkRemove); + + UnhookEvent(hEventNotifyOptInit); + UnhookEvent(hEventNotifyModulesLoaded); + + for(int i = 0; i < 4; i++) + DestroyServiceFunction(hServicesNotify[i]); +} -- cgit v1.2.3