diff options
-rw-r--r-- | message_notify/MessageNotify.mdsp | 101 | ||||
-rw-r--r-- | message_notify/common.h | 45 | ||||
-rw-r--r-- | message_notify/docs/licence_MessageNotify.txt | 6 | ||||
-rw-r--r-- | message_notify/messagenotify.cpp | 372 | ||||
-rw-r--r-- | message_notify/messagenotify.dsp | 145 | ||||
-rw-r--r-- | message_notify/messagenotify.dsw | 29 | ||||
-rw-r--r-- | message_notify/messagenotify.plg | 66 | ||||
-rw-r--r-- | message_notify/messagenotify.sln | 20 | ||||
-rw-r--r-- | message_notify/messagenotify.vcproj | 371 | ||||
-rw-r--r-- | message_notify/mywindowlist.cpp | 221 | ||||
-rw-r--r-- | message_notify/mywindowlist.h | 18 | ||||
-rw-r--r-- | message_notify/options.cpp | 250 | ||||
-rw-r--r-- | message_notify/options.h | 37 | ||||
-rw-r--r-- | message_notify/popups.cpp | 271 | ||||
-rw-r--r-- | message_notify/popups.h | 21 | ||||
-rw-r--r-- | message_notify/resource.h | 29 | ||||
-rw-r--r-- | message_notify/resource.rc | 114 |
17 files changed, 2116 insertions, 0 deletions
diff --git a/message_notify/MessageNotify.mdsp b/message_notify/MessageNotify.mdsp new file mode 100644 index 0000000..d49a6a2 --- /dev/null +++ b/message_notify/MessageNotify.mdsp @@ -0,0 +1,101 @@ +[Project]
+name=MessageNotify
+type=2
+defaultConfig=0
+
+
+[Debug]
+// compiler
+workingDirectory=
+arguments=
+intermediateFilesDirectory=Debug
+outputFilesDirectory=Debug
+compilerPreprocessor=MESSAGENOTIFY_EXPORTS,_UNICODE,UNICODE
+extraCompilerOptions=
+compilerIncludeDirectory=..\..\include
+noWarning=0
+defaultWarning=0
+allWarning=1
+extraWarning=0
+isoWarning=0
+warningsAsErrors=0
+debugType=1
+debugLevel=2
+exceptionEnabled=1
+runtimeTypeEnabled=1
+optimizeLevel=0
+
+// linker
+libraryPath=
+outputFilename=Debug\MessageNotify.dll
+libraries=unicows,comctl32
+extraLinkerOptions=
+ignoreStartupFile=0
+ignoreDefaultLibs=0
+stripExecutableFile=0
+
+// archive
+extraArchiveOptions=
+
+//resource
+resourcePreprocessor=
+resourceIncludeDirectory=
+extraResourceOptions=
+
+[Release]
+// compiler
+workingDirectory=
+arguments=
+intermediateFilesDirectory=Release
+outputFilesDirectory=Release
+compilerPreprocessor=MESSAGENOTIFY_EXPORTS,_UNICODE,UNICODE
+extraCompilerOptions=
+compilerIncludeDirectory=..\..\include
+noWarning=0
+defaultWarning=0
+allWarning=1
+extraWarning=0
+isoWarning=0
+warningAsErrors=0
+debugType=0
+debugLevel=1
+exceptionEnabled=1
+runtimeTypeEnabled=1
+optimizeLevel=2
+
+// linker
+libraryPath=
+outputFilename=Release\MessageNotify.dll
+libraries=unicows,comctl32
+extraLinkerOptions=
+ignoreStartupFile=0
+ignoreDefaultLibs=0
+stripExecutableFile=1
+
+// archive
+extraArchiveOptions=
+
+//resource
+resourcePreprocessor=
+resourceIncludeDirectory=
+extraResourceOptions=
+
+[Source]
+1=messagenotify.cpp
+2=mywindowlist.cpp
+3=options.cpp
+4=popups.cpp
+[Header]
+1=common.h
+2=mywindowlist.h
+3=options.h
+4=popups.h
+5=resource.h
+[Resource]
+1=resource.rc
+[Other]
+[History]
+options.cpp,5183
+popups.cpp,6075
+common.h,643
+messagenotify.cpp,696
diff --git a/message_notify/common.h b/message_notify/common.h new file mode 100644 index 0000000..1accfe7 --- /dev/null +++ b/message_notify/common.h @@ -0,0 +1,45 @@ +//#ifndef __COMMON_INC
+//#define __COMMON_INC
+
+#define MODULE "MessageNotify"
+
+#define _WIN32_WINNT 0x400 // for QueueUserAPC
+#define _WIN32_IE 0x300 // for InitCommonControlsEx
+
+#include <stdio.h>
+#include <windows.h>
+#include <process.h>
+#include <malloc.h>
+#include "resource.h"
+#include <commctrl.h>
+
+#include <newpluginapi.h>
+
+#include <m_system.h>
+#include <m_langpack.h>
+#include <m_options.h>
+#include <m_idle.h>
+#include <m_skin.h>
+#include <m_database.h>
+#include <m_clist.h>
+#include <m_message.h>
+#include <m_utils.h>
+#include <m_ignore.h>
+
+#include <m_updater.h>
+#include <m_metacontacts.h>
+
+
+extern HINSTANCE hInst;
+extern PLUGINLINK *pluginLink;
+
+extern HANDLE mainThread;
+
+extern HANDLE popupWindowList;
+
+void StartFocusTimer();
+void StopFocusTimer();
+
+
+//#endif
+
diff --git a/message_notify/docs/licence_MessageNotify.txt b/message_notify/docs/licence_MessageNotify.txt new file mode 100644 index 0000000..849f647 --- /dev/null +++ b/message_notify/docs/licence_MessageNotify.txt @@ -0,0 +1,6 @@ +The MessageNotify plugin for Miranda-IM is Copyright (c) 2006 Scott Ellis (mail@scottellis.com.au)
+
+http://www.scottellis.com.au
+
+It is released under the General Public Licence, available here:
+http://www.gnu.org/copyleft/gpl.html
\ No newline at end of file diff --git a/message_notify/messagenotify.cpp b/message_notify/messagenotify.cpp new file mode 100644 index 0000000..69595b2 --- /dev/null +++ b/message_notify/messagenotify.cpp @@ -0,0 +1,372 @@ +////////////////////////////////////
+/// This Miranda plugin (http://www.miranda-im.org) is released under the General Public Licence,
+/// available at http://www.gnu.org/copyleft/gpl.html
+/// Copyright Scott Ellis 2005 (mail@scottellis.com.au .. www.scottellis.com.au)
+////////////////////////////////////
+
+#include "common.h"
+#include "options.h"
+#include "popups.h"
+#include <time.h>
+
+HINSTANCE hInst;
+PLUGINLINK *pluginLink;
+
+HANDLE mainThread;
+
+bool metacontacts_installed;
+bool unicode_system;
+
+int code_page = CP_ACP;
+
+HANDLE popupWindowList;
+
+DWORD focusTimerId = 0;
+
+PLUGININFO pluginInfo={
+ sizeof(PLUGININFO),
+ "Message Notify",
+ PLUGIN_MAKE_VERSION(0,1,1,1),
+ "Show a popup when a message is received",
+ "Scott Ellis",
+ "mail@scottellis.com.au",
+ "© 2005 Scott Ellis",
+ "http://www.scottellis.com.au/",
+ 0, //not transient
+ 0 //doesn't replace anything built-in
+};
+
+
+extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+{
+ hInst=hinstDLL;
+ DisableThreadLibraryCalls(hInst);
+ return TRUE;
+}
+
+extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+HANDLE hWindowEvent, hEventDbEventAdded, hIdle;
+BOOL bIsIdle = FALSE;
+
+bool window_focussed(HWND hwnd, HANDLE hContact) {
+ HWND parent;
+ while((parent = GetParent(hwnd)) != 0) hwnd = parent; // ensure we have the top level window (need parent window for scriver & tabsrmm)
+
+ // consider minimized window not-focussed
+ WINDOWPLACEMENT wp = {0};
+ wp.length = sizeof(wp);
+ GetWindowPlacement(hwnd, &wp);
+ if(hwnd == GetForegroundWindow() && !(wp.showCmd & SW_SHOWMINIMIZED)) {
+
+ // check message API for focus too
+ if(options.consider_tabs) {
+ MessageWindowInputData mwid = {0};
+ MessageWindowData mwd = {0};
+
+ mwid.cbSize = sizeof(mwid);
+ mwid.hContact = hContact;
+ mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+
+ mwd.cbSize = sizeof(mwd);
+
+ if(!CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd)) {
+ if((mwd.uState & MSG_WINDOW_STATE_VISIBLE) != 0) {
+ return true;
+ }
+ } else
+ return true;
+
+ } else
+ return true;
+ }
+
+ return false;
+}
+
+void __stdcall FocusTimerProc(struct HWND__ *,unsigned int,unsigned int,unsigned long) {
+ if(options.notify_when != NOTIFY_NFORE) return;
+
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while (hContact) {
+ HWND hwnd;
+ if((hwnd = (HWND)DBGetContactSettingDword(hContact, MODULE, "WindowHandle", 0)) != 0) {
+ if(!EmptyList(hContact)) {
+ if(window_focussed(hwnd, hContact))
+ PostMessageWindowList(WMU_CLOSEPOPUP, (WPARAM)hContact, 0); // close popups
+ }
+ }
+ hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
+ }
+}
+
+void StartFocusTimer() {
+ if(!focusTimerId)
+ focusTimerId = SetTimer(0, 0, 500, FocusTimerProc);
+}
+
+void StopFocusTimer() {
+ if(focusTimerId) {
+ KillTimer(0, focusTimerId);
+ focusTimerId = 0;
+ }
+}
+
+
+
+//#define CONTROL_GLOBAL_STATUS
+
+#ifdef CONTROL_GLOBAL_STATUS
+WORD saved_status;
+#endif
+
+int OnIdleChanged(WPARAM wParam, LPARAM lParam) {
+#ifdef CONTROL_GLOBAL_STATUS
+ int st;
+#endif
+
+ bIsIdle = (lParam & IDF_ISIDLE);
+
+#ifdef CONTROL_GLOBAL_STATUS
+ st = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
+ if(bIsIdle && st != ID_STATUS_OFFLINE) {
+ saved_status = st;
+ CallService(MS_CLIST_SETSTATUSMODE, (WPARAM)ID_STATUS_AWAY, 0);
+ } else if(!bIsIdle && saved_status != ID_STATUS_OFFLINE) {
+ CallService(MS_CLIST_SETSTATUSMODE, (WPARAM)saved_status, 0);
+ }
+#endif
+
+ return 0;
+}
+
+typedef struct {
+ HANDLE hContact;
+ BYTE *blob;
+ int blobsize;
+} CheckWindowData;
+
+unsigned int __stdcall sttCheckWindowProc( VOID *dwParam ) {
+ CheckWindowData *cd = (CheckWindowData *)dwParam;
+
+ Sleep(500); // wait for message window to open from event, if it's going to
+
+ HWND hwnd = (HWND)DBGetContactSettingDword(cd->hContact, MODULE, "WindowHandle", 0);
+ bool window_open = (hwnd != 0);
+ bool window_has_focus = window_open && window_focussed(hwnd, cd->hContact);
+
+ if(options.notify_when == NOTIFY_ALWAYS
+ || (options.notify_when == NOTIFY_NFORE && !window_has_focus)
+ || (options.notify_when == NOTIFY_CLOSED && !window_open))
+ {
+ if(IsUnicodePopupsEnabled()) {
+ // get contact display name from clist
+ wchar_t *swzContactDisplayName = 0;
+
+ if(unicode_system)
+ swzContactDisplayName = (wchar_t *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)cd->hContact, GCDNF_UNICODE);
+ else {
+ char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)cd->hContact, 0);
+ if(szCDN && szCDN[0]) {
+ int size = MultiByteToWideChar(code_page, 0, (char *) szCDN, -1, 0, 0);
+ swzContactDisplayName = (wchar_t *) malloc(sizeof(wchar_t) * size);
+ MultiByteToWideChar(code_page, 0, (char *) szCDN, -1, swzContactDisplayName, size);
+ } else {
+ swzContactDisplayName = (wchar_t *) malloc(sizeof(wchar_t) * (wcslen(TranslateT("(Unknown)") + 1)));
+ wcscpy(swzContactDisplayName, TranslateT("(Unknown)"));
+ }
+ }
+
+ wchar_t *msg;
+ int msglen = strlen((char *)cd->blob) + 1;
+
+ // does blob contain unicode message?
+ if(msglen != cd->blobsize && wcslen((wchar_t *)(&cd->blob[msglen]))) {
+ // yes
+ msg = (wchar_t *)(&cd->blob[msglen]);
+ ShowPopupW(cd->hContact, swzContactDisplayName, msg);
+ } else if(cd->blobsize) {
+ // no, convert to unciode
+ int size = MultiByteToWideChar(code_page, 0, (char *) cd->blob, -1, 0, 0);
+ msg = (wchar_t *) malloc(sizeof(wchar_t) * size);
+ MultiByteToWideChar(code_page, 0, (char *) cd->blob, -1, msg, size);
+ ShowPopupW(cd->hContact, swzContactDisplayName, msg);
+ free(msg);
+ }
+ if(!unicode_system) free(swzContactDisplayName);
+ } else {
+ char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)cd->hContact, 0);
+ if(szCDN && szCDN[0]) {
+ char msg[MAX_SECONDLINE];
+ strncpy(msg, (char *)cd->blob, MAX_SECONDLINE - 1);
+ msg[MAX_SECONDLINE - 1] = 0;
+ ShowPopup(cd->hContact, szCDN, (char *)msg);
+ }
+ }
+ }
+
+ delete[] cd->blob;
+ delete cd;
+
+ return 0;
+}
+
+int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) {
+ DBEVENTINFO *dbei = (DBEVENTINFO *)lParam;
+
+ // safety checks
+
+ if ((dbei == 0) || (wParam == 0) || (dbei->flags & DBEF_SENT) || (dbei->eventType != EVENTTYPE_MESSAGE) || (dbei->flags & DBEF_READ)) {
+ return 0;
+ }
+
+ int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
+ if(status >= ID_STATUS_ONLINE && status <= ID_STATUS_OUTTOLUNCH && options.disable_status[status - ID_STATUS_ONLINE])
+ return 0;
+
+ // messages from this contact ignored
+ if(CallService(MS_IGNORE_ISIGNORED, wParam, (LPARAM)IGNOREEVENT_MESSAGE))
+ return 0;
+
+ // if contact 'not on list', use default ignore setting
+ if(DBGetContactSettingByte((HANDLE)wParam, "CList", "NotOnList", 0) && CallService(MS_IGNORE_ISIGNORED, 0, (LPARAM)IGNOREEVENT_MESSAGE))
+ return 0;
+
+ if(dbei->cbBlob == 0 || dbei->pBlob == 0)
+ return 0; // just to be safe
+
+
+ // copy blob data
+ CheckWindowData *cd = new CheckWindowData;
+ cd->hContact = (HANDLE)wParam;
+ cd->blobsize = dbei->cbBlob;
+ cd->blob = new BYTE[cd->blobsize];
+ memcpy(cd->blob, dbei->pBlob, cd->blobsize);
+
+ // spawn a thread to deal with the copied data
+ CloseHandle((HANDLE)_beginthreadex(0, 0, sttCheckWindowProc, (VOID *)cd, 0, 0));
+ return 0;
+}
+
+int OnWindowEvent(WPARAM wParam, LPARAM lParam) {
+ MessageWindowEventData *mwed = (MessageWindowEventData *)lParam;
+
+ switch(mwed->uType) {
+ case MSG_WINDOW_EVT_OPENING:
+ case MSG_WINDOW_EVT_OPEN:
+ DBWriteContactSettingDword(mwed->hContact, MODULE, "WindowHandle", (DWORD)mwed->hwndWindow);
+ if(options.notify_when == NOTIFY_CLOSED)
+ PostMessageWindowList(WMU_CLOSEPOPUP, (WPARAM)mwed->hContact, 0);
+ break;
+ case MSG_WINDOW_EVT_CLOSING:
+ case MSG_WINDOW_EVT_CLOSE:
+ DBWriteContactSettingDword(mwed->hContact, MODULE, "WindowHandle", 0);
+ break;
+ default:
+ //ShowWarning("Window custom");
+ break;
+ }
+
+ return 0;
+}
+
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam) {
+ InitUtils(); // depends on popup module being loaded already
+
+ if(ServiceExists(MS_UPDATE_REGISTER)) {
+ // register with updater
+ Update update = {0};
+ char szVersion[16];
+
+ update.cbSize = sizeof(Update);
+
+ update.szComponentName = pluginInfo.shortName;
+ update.pbVersion = (BYTE *)CreateVersionString(pluginInfo.version, szVersion);
+ update.cpbVersion = strlen((char *)update.pbVersion);
+
+ update.szUpdateURL = UPDATER_AUTOREGISTER;
+
+ update.szBetaUpdateURL = "http://www.scottellis.com.au/miranda_plugins/messagenotify.zip";
+ update.szBetaVersionURL = "http://www.scottellis.com.au/miranda_plugins/ver_messagenotify.html";
+ update.pbBetaVersionPrefix = (BYTE *)"Message Notify version ";
+
+ update.cpbBetaVersionPrefix = strlen((char *)update.pbBetaVersionPrefix);
+
+ CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
+ }
+
+ metacontacts_installed = (ServiceExists(MS_MC_GETMETACONTACT) != 0);
+
+ hIdle = HookEvent(ME_IDLE_CHANGED, OnIdleChanged);
+ hWindowEvent = HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
+
+ if(options.notify_when == NOTIFY_NFORE)
+ StartFocusTimer();
+
+ return 0;
+}
+
+int OnPreShutdown(WPARAM wParam, LPARAM lParam) {
+ StopFocusTimer();
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
+{
+ pluginLink = link;
+ DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 );
+
+ char szVer[128];
+ unicode_system = (CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)sizeof(szVer), (LPARAM)szVer) == 0 && strstr(szVer, "Unicode"));
+
+ INITCOMMONCONTROLSEX icex;
+
+ // Ensure that the common control DLL is loaded (for listview)
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_LISTVIEW_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ if(ServiceExists(MS_DB_SETSETTINGRESIDENT)) { // 0.6+
+ CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(MODULE "/WindowHandle"));
+ }
+
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while (hContact) {
+ if(DBGetContactSettingDword(hContact, MODULE, "WindowHandle", 0) != 0)
+ DBWriteContactSettingDword(hContact, MODULE, "WindowHandle", 0);
+
+ hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
+ }
+
+ InitWindowList();
+
+ LoadOptions();
+
+ if(ServiceExists(MS_LANGPACK_GETCODEPAGE))
+ code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
+
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
+ HookEvent(ME_OPT_INITIALISE, OptInit);
+
+ popupWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+
+ hEventDbEventAdded = HookEvent(ME_DB_EVENT_FILTER_ADD, OnDatabaseEventPreAdd);
+
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ UnhookEvent(hIdle);
+ UnhookEvent(hWindowEvent);
+ UnhookEvent(hEventDbEventAdded);
+
+ DeinitUtils();
+ DeinitWindowList();
+
+ return 0;
+}
diff --git a/message_notify/messagenotify.dsp b/message_notify/messagenotify.dsp new file mode 100644 index 0000000..4249c37 --- /dev/null +++ b/message_notify/messagenotify.dsp @@ -0,0 +1,145 @@ +# Microsoft Developer Studio Project File - Name="messagenotify" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=messagenotify - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "messagenotify.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "messagenotify.mak" CFG="messagenotify - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "messagenotify - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "messagenotify - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "messagenotify - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 2
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MESSAGENOTIFY_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MESSAGENOTIFY_EXPORTS" /D "UNICODE" /D "_UNICODE" /D "_WINDLL" /D "_AFXDLL" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /d "NDEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 user32.lib /nologo /base:"0x22080000" /dll /machine:I386 /out:"../../bin/release/plugins/messagenotify.dll"
+# SUBTRACT LINK32 /nodefaultlib
+
+!ELSEIF "$(CFG)" == "messagenotify - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 2
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MESSAGENOTIFY_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MESSAGENOTIFY_EXPORTS" /D "UNICODE" /D "_UNICODE" /D "_WINDLL" /D "_AFXDLL" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /d "_DEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 user32.lib /nologo /dll /debug /machine:I386 /out:"../../bin/debug/plugins/messagenotify.dll" /pdbtype:sept
+# SUBTRACT LINK32 /nodefaultlib
+
+!ENDIF
+
+# Begin Target
+
+# Name "messagenotify - Win32 Release"
+# Name "messagenotify - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\messagenotify.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\mywindowlist.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\options.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\popups.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\common.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\mywindowlist.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\options.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\popups.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\resource.rc
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/message_notify/messagenotify.dsw b/message_notify/messagenotify.dsw new file mode 100644 index 0000000..75b04cc --- /dev/null +++ b/message_notify/messagenotify.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "messagenotify"=".\messagenotify.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/message_notify/messagenotify.plg b/message_notify/messagenotify.plg new file mode 100644 index 0000000..8e81db8 --- /dev/null +++ b/message_notify/messagenotify.plg @@ -0,0 +1,66 @@ +<html>
+<body>
+<pre>
+<h1>Build Log</h1>
+<h3>
+--------------------Configuration: messagenotify - Win32 Release--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSPC6.tmp" with contents
+[
+/nologo /MD /W3 /GX /O2 /I "../../include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MESSAGENOTIFY_EXPORTS" /D "UNICODE" /D "_UNICODE" /D "_WINDLL" /D "_AFXDLL" /Fp"Release/messagenotify.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\MessageNotify\messagenotify.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSPC6.tmp"
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSPC7.tmp" with contents
+[
+user32.lib /nologo /base:"0x22080000" /dll /incremental:no /pdb:"Release/messagenotify.pdb" /machine:I386 /out:"../../bin/release/plugins/messagenotify.dll" /implib:"Release/messagenotify.lib"
+".\Release\messagenotify.obj"
+".\Release\mywindowlist.obj"
+".\Release\options.obj"
+".\Release\popups.obj"
+".\Release\resource.res"
+]
+Creating command line "link.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSPC7.tmp"
+<h3>Output Window</h3>
+Compiling...
+messagenotify.cpp
+Linking...
+ Creating library Release/messagenotify.lib and object Release/messagenotify.exp
+
+
+
+<h3>Results</h3>
+messagenotify.dll - 0 error(s), 0 warning(s)
+<h3>
+--------------------Configuration: messagenotify - Win32 Debug--------------------
+</h3>
+<h3>Command Lines</h3>
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSPCB.tmp" with contents
+[
+/nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MESSAGENOTIFY_EXPORTS" /D "UNICODE" /D "_UNICODE" /D "_WINDLL" /D "_AFXDLL" /Fp"Debug/messagenotify.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
+"C:\Documents and Settings\sje\My Documents\MyProjects\miranda\plugins\MessageNotify\messagenotify.cpp"
+]
+Creating command line "cl.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSPCB.tmp"
+Creating temporary file "C:\DOCUME~1\sje\LOCALS~1\Temp\RSPCC.tmp" with contents
+[
+user32.lib /nologo /dll /incremental:yes /pdb:"Debug/messagenotify.pdb" /debug /machine:I386 /out:"../../bin/debug/plugins/messagenotify.dll" /implib:"Debug/messagenotify.lib" /pdbtype:sept
+".\Debug\messagenotify.obj"
+".\Debug\mywindowlist.obj"
+".\Debug\options.obj"
+".\Debug\popups.obj"
+".\Debug\resource.res"
+]
+Creating command line "link.exe @C:\DOCUME~1\sje\LOCALS~1\Temp\RSPCC.tmp"
+<h3>Output Window</h3>
+Compiling...
+messagenotify.cpp
+Linking...
+
+
+
+<h3>Results</h3>
+messagenotify.dll - 0 error(s), 0 warning(s)
+</pre>
+</body>
+</html>
diff --git a/message_notify/messagenotify.sln b/message_notify/messagenotify.sln new file mode 100644 index 0000000..5c45455 --- /dev/null +++ b/message_notify/messagenotify.sln @@ -0,0 +1,20 @@ +
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "messagenotify", "messagenotify.vcproj", "{16D994CE-6E37-4A69-9B5B-02E780895984}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {16D994CE-6E37-4A69-9B5B-02E780895984}.Debug|Win32.ActiveCfg = Debug|Win32
+ {16D994CE-6E37-4A69-9B5B-02E780895984}.Debug|Win32.Build.0 = Debug|Win32
+ {16D994CE-6E37-4A69-9B5B-02E780895984}.Release|Win32.ActiveCfg = Release|Win32
+ {16D994CE-6E37-4A69-9B5B-02E780895984}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/message_notify/messagenotify.vcproj b/message_notify/messagenotify.vcproj new file mode 100644 index 0000000..c2a4a18 --- /dev/null +++ b/message_notify/messagenotify.vcproj @@ -0,0 +1,371 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="messagenotify"
+ ProjectGUID="{16D994CE-6E37-4A69-9B5B-02E780895984}"
+ RootNamespace="messagenotify"
+ Keyword="MFCProj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/messagenotify.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;MESSAGENOTIFY_EXPORTS;UNICODE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="common.h"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="2057"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="unicows.lib user32.lib comctl32.lib"
+ OutputFile="../../bin/debug/plugins/messagenotify.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ IgnoreDefaultLibraryNames="Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/messagenotify.pdb"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ EmbedManifest="false"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\Debug/messagenotify.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/messagenotify.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;MESSAGENOTIFY_EXPORTS;UNICODE"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="common.h"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="2057"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="unicows.lib user32.lib comctl32.lib"
+ OutputFile="../../bin/release/plugins/messagenotify.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ IgnoreDefaultLibraryNames="Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib"
+ ProgramDatabaseFile=".\Release/messagenotify.pdb"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ BaseAddress="0x22080000"
+ ImportLibrary="$(IntDir)/$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\Release/messagenotify.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath="messagenotify.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="mywindowlist.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="options.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="popups.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath="common.h"
+ >
+ </File>
+ <File
+ RelativePath="mywindowlist.h"
+ >
+ </File>
+ <File
+ RelativePath="options.h"
+ >
+ </File>
+ <File
+ RelativePath="popups.h"
+ >
+ </File>
+ <File
+ RelativePath="resource.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath="resource.rc"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/message_notify/mywindowlist.cpp b/message_notify/mywindowlist.cpp new file mode 100644 index 0000000..72a82e7 --- /dev/null +++ b/message_notify/mywindowlist.cpp @@ -0,0 +1,221 @@ +#include "common.h"
+#include "mywindowlist.h"
+
+class WindowList {
+public:
+ struct ListNode {
+ HWND hwnd;
+ ListNode *next;
+ };
+
+ WindowList(): head(0), count(0) {}
+ ~WindowList() {clear();}
+
+ void clear() {
+ ListNode *n;
+ while(head) {
+ n = head;
+ head = head->next;
+ delete n;
+ }
+ }
+
+ void AddWindow(HWND hwnd) {
+ if(HasWindow(hwnd)) return;
+
+ ListNode *n = new ListNode;
+ n->hwnd = hwnd;
+ n->next = head;
+ head = n;
+ count++;
+ }
+
+ void RemoveWindow(HWND hwnd) {
+ ListNode *n = head, *prev = 0;
+ while(n) {
+ if(n->hwnd == hwnd) {
+ if(prev) prev->next = n->next;
+ else head = n->next;
+ delete n;
+ count--;
+ break;
+ }
+ prev = n;
+ n = n->next;
+ }
+ }
+
+ void PostListMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
+ ListNode *n = head;
+ while(n) {
+ PostMessage(n->hwnd, msg, wParam, lParam);
+ n = n->next;
+ }
+ }
+
+ bool HasWindow(HWND hwnd) {
+ ListNode *n = head;
+ while(n) {
+ if(n->hwnd == hwnd)
+ return true;
+ n = n->next;
+ }
+ return false;
+ }
+
+ int GetCount() {
+ return count;
+ }
+
+protected:
+ ListNode *head;
+ int count;
+};
+
+class WindowMap {
+public:
+ struct ListNode {
+ HANDLE hContact;
+ WindowList list;
+ ListNode *next;
+ };
+
+ WindowMap(): head(0) {}
+ ~WindowMap() {clear();}
+
+ void clear() {
+ ListNode *n = head;
+ while(head) {
+ n = head;
+ head = head->next;
+ delete n;
+ }
+ }
+
+ WindowList *FindList(HANDLE hContact) {
+ ListNode *n = head;
+ while(n) {
+ if(n->hContact == hContact)
+ return &n->list;
+ n = n->next;
+ }
+ return 0;
+ }
+
+ void Add(HANDLE hContact, HWND hWnd) {
+ WindowList *l = FindList(hContact);
+ if(l) l->AddWindow(hWnd);
+ else {
+ ListNode *n = new ListNode;
+ n->hContact = hContact;
+ n->list.AddWindow(hWnd);
+ n->next = head;
+ head = n;
+ }
+ }
+
+ void Remove(HANDLE hContact, HWND hWnd) {
+ ListNode *n = head, *prev = 0;
+ while(n) {
+ if(n->hContact == hContact) {
+ n->list.RemoveWindow(hWnd);
+ if(n->list.GetCount() == 0) {
+ if(prev) prev->next = n->next;
+ else head = n->next;
+ delete n;
+ }
+ break;
+ }
+ prev = n;
+ n = n->next;
+ }
+ }
+
+ void PostMapMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
+ ListNode *n = head;
+ while(n) {
+ n->list.PostListMessage(msg, wParam, lParam);
+ n = n->next;
+ }
+ }
+
+protected:
+ ListNode *head;
+};
+
+WindowMap window_map;
+
+CRITICAL_SECTION list_cs;
+
+void AddToWindowList(HANDLE hContact, HWND hWnd) {
+ EnterCriticalSection(&list_cs);
+
+ window_map.Add(hContact, hWnd);
+
+ LeaveCriticalSection(&list_cs);
+}
+
+void RemoveFromWindowList(HANDLE hContact, HWND hWnd) {
+ EnterCriticalSection(&list_cs);
+
+ window_map.Remove(hContact, hWnd);
+
+ LeaveCriticalSection(&list_cs);
+}
+
+void PostMessageWindowList(UINT msg, WPARAM wParam, LPARAM lParam) {
+ EnterCriticalSection(&list_cs);
+
+ window_map.PostMapMessage(msg, wParam, lParam);
+
+ LeaveCriticalSection(&list_cs);
+}
+
+void PostMessageWindowListContact(HANDLE hContact, UINT msg, WPARAM wParam, LPARAM lParam) {
+ EnterCriticalSection(&list_cs);
+
+ WindowList *l = window_map.FindList(hContact);
+ if(l) l->PostListMessage(msg, wParam, lParam);
+
+ LeaveCriticalSection(&list_cs);
+}
+
+bool InList(HANDLE hContact, HWND hWnd) {
+ bool ret = false;
+ EnterCriticalSection(&list_cs);
+
+ WindowList *l = window_map.FindList(hContact);
+ if(l) ret = l->HasWindow(hWnd);
+
+ LeaveCriticalSection(&list_cs);
+ return ret;
+}
+
+int CountList(HANDLE hContact) {
+ int count = 0;
+ EnterCriticalSection(&list_cs);
+
+ WindowList *l = window_map.FindList(hContact);
+ if(l) count = l->GetCount();
+
+ LeaveCriticalSection(&list_cs);
+ return count;
+}
+
+bool EmptyList(HANDLE hContact) {
+ EnterCriticalSection(&list_cs);
+
+ bool ret = (window_map.FindList(hContact) == 0);
+
+ LeaveCriticalSection(&list_cs);
+ return ret;
+}
+
+void InitWindowList() {
+ InitializeCriticalSection(&list_cs);
+}
+
+void DeinitWindowList() {
+ DeleteCriticalSection(&list_cs);
+}
+
diff --git a/message_notify/mywindowlist.h b/message_notify/mywindowlist.h new file mode 100644 index 0000000..f5fe2f6 --- /dev/null +++ b/message_notify/mywindowlist.h @@ -0,0 +1,18 @@ +#ifndef _MYWINDOWLIST_INC
+#define _MYWINDOWLIST_INC
+
+bool InList(HANDLE hContact, HWND hWnd);
+void AddToWindowList(HANDLE hContact, HWND hWnd);
+void RemoveFromWindowList(HANDLE hContact, HWND hWnd);
+
+void PostMessageWindowList(UINT msg, WPARAM wParam, LPARAM lParam);
+void PostMessageWindowListContact(HANDLE hContact, UINT msg, WPARAM wParam, LPARAM lParam);
+
+
+int CountList(HANDLE hContact);
+bool EmptyList(HANDLE hContact);
+
+void InitWindowList();
+void DeinitWindowList();
+
+#endif
diff --git a/message_notify/options.cpp b/message_notify/options.cpp new file mode 100644 index 0000000..9460843 --- /dev/null +++ b/message_notify/options.cpp @@ -0,0 +1,250 @@ +#include "common.h"
+#include "options.h"
+
+Options options;
+
+static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+
+ {
+ // initialise and fill listbox
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_LST_STATUS);
+ ListView_DeleteAllItems(hwndList);
+
+ SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
+
+ LVCOLUMN lvc = {0};
+ // Initialize the LVCOLUMN structure.
+ // The mask specifies that the format, width, text, and
+ // subitem members of the structure are valid.
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvc.fmt = LVCFMT_LEFT;
+
+ lvc.iSubItem = 0;
+ lvc.pszText = TranslateT("Status");
+ lvc.cx = 120; // width of column in pixels
+ ListView_InsertColumn(hwndList, 0, &lvc);
+
+
+ LVITEM lvI = {0};
+
+ // Some code to create the list-view control.
+ // Initialize LVITEM members that are common to all
+ // items.
+ lvI.mask = LVIF_TEXT;
+
+ char *strptr;
+ wchar_t buff[256];
+ for(int i = 0; i < 9; i++) {
+ strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(ID_STATUS_ONLINE + i), (LPARAM)0);
+ MultiByteToWideChar((int)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0), 0, strptr, -1, buff, 256);
+ lvI.pszText = buff;
+ lvI.iItem = i;
+ ListView_InsertItem(hwndList, &lvI);
+ ListView_SetCheckState(hwndList, i, options.disable_status[i]);
+ }
+ }
+
+ {
+ CheckDlgButton(hwndDlg, IDC_CHK_TABS, options.consider_tabs ? TRUE : FALSE);
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CHK_TABS);
+ switch(options.notify_when) {
+ case NOTIFY_CLOSED:
+ CheckDlgButton(hwndDlg, IDC_RAD_CLOSED, TRUE);
+ EnableWindow(hwnd, FALSE);
+ break;
+ case NOTIFY_NFORE:
+ CheckDlgButton(hwndDlg, IDC_RAD_NFORE, TRUE);
+ EnableWindow(hwnd, TRUE);
+ break;
+ case NOTIFY_ALWAYS:
+ CheckDlgButton(hwndDlg, IDC_RAD_ALWAYS, TRUE);
+ EnableWindow(hwnd, FALSE);
+ break;
+ };
+ }
+ CheckDlgButton(hwndDlg, IDC_CHK_CLOSE, options.close_win ? TRUE : FALSE);
+ if(options.timeout == -1) {
+ CheckDlgButton(hwndDlg, IDC_CHK_SETTIMEOUT, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, 0, FALSE);
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
+ EnableWindow(hwnd, FALSE);
+ } else {
+ CheckDlgButton(hwndDlg, IDC_CHK_SETTIMEOUT, TRUE);
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, options.timeout, FALSE);
+ }
+
+ CheckDlgButton(hwndDlg, IDC_CHK_SETCOLOURS, options.set_colours ? TRUE : FALSE);
+ SendDlgItemMessage(hwndDlg, IDC_CP_BK, CPM_SETCOLOUR, 0, (LPARAM)options.bkCol);
+ SendDlgItemMessage(hwndDlg, IDC_CP_TXT, CPM_SETCOLOUR, 0, (LPARAM)options.textCol);
+ if(!options.set_colours) {
+ CheckDlgButton(hwndDlg, IDC_CHK_SETCOLOURS, FALSE);
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CP_BK);
+ EnableWindow(hwnd, FALSE);
+ hwnd = GetDlgItem(hwndDlg, IDC_CP_TXT);
+ EnableWindow(hwnd, FALSE);
+ }
+
+ return FALSE;
+ case WM_COMMAND:
+ if(LOWORD(wParam) == IDC_CP_BK || LOWORD(wParam) == IDC_CP_TXT) {
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ }
+ if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ switch( LOWORD( wParam )) {
+ case IDC_ED_TIMEOUT:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ break;
+ }
+ if ( HIWORD( wParam ) == BN_CLICKED ) {
+ switch( LOWORD( wParam )) {
+ case IDC_RAD_CLOSED:
+ case IDC_RAD_ALWAYS:
+ {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CHK_TABS);
+ EnableWindow(hwnd, FALSE);
+ }
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ case IDC_RAD_NFORE:
+ {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CHK_TABS);
+ EnableWindow(hwnd, TRUE);
+ }
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ case IDC_CHK_SETTIMEOUT:
+ {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_ED_TIMEOUT);
+ EnableWindow(hwnd, IsDlgButtonChecked(hwndDlg, IDC_CHK_SETTIMEOUT));
+ }
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ case IDC_CHK_SETCOLOURS:
+ {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_CP_BK);
+ EnableWindow(hwnd, IsDlgButtonChecked(hwndDlg, IDC_CHK_SETCOLOURS));
+ hwnd = GetDlgItem(hwndDlg, IDC_CP_TXT);
+ EnableWindow(hwnd, IsDlgButtonChecked(hwndDlg, IDC_CHK_SETCOLOURS));
+ }
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ case IDC_CHK_CLOSE:
+ case IDC_CHK_TABS:
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ return TRUE;
+ }
+ }
+ break;
+
+ case WM_NOTIFY:
+ if(IsWindowVisible(hwndDlg) && ((LPNMHDR) lParam)->hwndFrom == GetDlgItem(hwndDlg, IDC_LST_STATUS)) {
+ switch (((LPNMHDR) lParam)->code) {
+
+ case LVN_ITEMCHANGED:
+ {
+ NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
+ if((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ }
+ }
+ break;
+ }
+ } else
+ if (((LPNMHDR)lParam)->code == (DWORD)PSN_APPLY ) {
+ options.consider_tabs = IsDlgButtonChecked(hwndDlg, IDC_CHK_TABS) ? true : false;
+ if(IsDlgButtonChecked(hwndDlg, IDC_RAD_CLOSED))
+ options.notify_when = NOTIFY_CLOSED;
+ else if(IsDlgButtonChecked(hwndDlg, IDC_RAD_NFORE))
+ options.notify_when = NOTIFY_NFORE;
+ else
+ options.notify_when = NOTIFY_ALWAYS;
+ options.close_win = IsDlgButtonChecked(hwndDlg, IDC_CHK_CLOSE) ? true : false;
+
+ if(IsDlgButtonChecked(hwndDlg, IDC_CHK_SETTIMEOUT)) {
+ BOOL trans;
+ int t = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &trans, FALSE);
+ if(trans) options.timeout = t;
+ } else
+ options.timeout = -1;
+
+ options.set_colours = IsDlgButtonChecked(hwndDlg, IDC_CHK_SETCOLOURS) ? true : false;
+ options.bkCol = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_CP_BK, CPM_GETCOLOUR, 0, 0);
+ options.textCol = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_CP_TXT, CPM_GETCOLOUR, 0, 0);
+
+ for(int i = 0; i < 9; i++)
+ options.disable_status[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_LST_STATUS), i) ? true : false);
+ SaveOptions();
+
+ if(options.notify_when == NOTIFY_NFORE)
+ StartFocusTimer();
+ else
+ StopFocusTimer();
+ return TRUE;
+ }
+ break;
+ case WM_DESTROY:
+ break;
+ }
+ return FALSE;
+
+}
+
+
+int OptInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+#define OPTIONPAGE_OLD_SIZE2 60
+ //odp.cbSize = sizeof(odp);
+ odp.cbSize = OPTIONPAGE_OLD_SIZE2;
+ odp.position = -790000000;
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
+ odp.pszTitle = Translate(MODULE);
+ odp.pszGroup = Translate("Popups");
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.nIDBottomSimpleControl = 0;
+ odp.pfnDlgProc = DlgProcOpts;
+
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ return 0;
+}
+
+void LoadOptions() {
+ options.notify_when = DBGetContactSettingByte(0, MODULE, "NotifyWhen", NOTIFY_NFORE);
+ options.timeout = (int)DBGetContactSettingDword(0, MODULE, "Timeout", 5);
+ options.set_colours = (DBGetContactSettingByte(0, MODULE, "SetColours", 0) == 1);
+ options.bkCol = (COLORREF)DBGetContactSettingDword(0, MODULE, "BkColour", (DWORD)0xFFFFFF);
+ options.textCol = (COLORREF)DBGetContactSettingDword(0, MODULE, "TextColour", (DWORD)0x000000);
+ options.consider_tabs = (DBGetContactSettingByte(0, MODULE, "ConsiderTabs", 1) == 1);
+ options.close_win = (DBGetContactSettingByte(0, MODULE, "CloseWin", 0) == 1);
+
+ char buff[128];
+ for(int i = 0; i < 9; i++) {
+ sprintf(buff, "DisableStatus%d", i);
+ options.disable_status[i] = (DBGetContactSettingByte(0, MODULE, buff, 0) == 1);
+ }
+}
+
+void SaveOptions() {
+ DBWriteContactSettingByte(0, MODULE, "NotifyWhen", options.notify_when);
+ DBWriteContactSettingDword(0, MODULE, "Timeout", (DWORD)options.timeout);
+ DBWriteContactSettingByte(0, MODULE, "SetColours", options.set_colours ? 1 : 0);
+ DBWriteContactSettingDword(0, MODULE, "BkColour", (DWORD)options.bkCol);
+ DBWriteContactSettingDword(0, MODULE, "TextColour", (DWORD)options.textCol);
+ DBWriteContactSettingByte(0, MODULE, "ConsiderTabs", options.consider_tabs ? 1 : 0);
+ DBWriteContactSettingByte(0, MODULE, "CloseWin", options.close_win ? 1 : 0);
+ char buff[128];
+ for(int i = 0; i < 9; i++) {
+ sprintf(buff, "DisableStatus%d", i);
+ DBWriteContactSettingByte(0, MODULE, buff, options.disable_status[i] ? 1 : 0);
+ }
+}
+
+
diff --git a/message_notify/options.h b/message_notify/options.h new file mode 100644 index 0000000..75f1c88 --- /dev/null +++ b/message_notify/options.h @@ -0,0 +1,37 @@ +#ifndef _OPTIONS_INC
+#define _OPTIONS_INC
+
+#define NOTIFY_NONE 0
+#define NOTIFY_CLOSED 1
+#define NOTIFY_NFORE 2
+#define NOTIFY_ALWAYS 3
+/*
+#define ID_STATUS_ONLINE 40072
+#define ID_STATUS_AWAY 40073
+#define ID_STATUS_DND 40074
+#define ID_STATUS_NA 40075
+#define ID_STATUS_OCCUPIED 40076
+#define ID_STATUS_FREECHAT 40077
+#define ID_STATUS_INVISIBLE 40078
+#define ID_STATUS_ONTHEPHONE 40079
+#define ID_STATUS_OUTTOLUNCH 40080
+*/
+typedef struct Options_tag {
+ int notify_when;
+ int timeout;
+ bool set_colours;
+ COLORREF bkCol;
+ COLORREF textCol;
+ bool consider_tabs;
+ bool close_win;
+ bool disable_status[9];
+} Options;
+
+extern Options options;
+
+int OptInit(WPARAM wParam, LPARAM lParam);
+
+void LoadOptions();
+void SaveOptions();
+
+#endif
diff --git a/message_notify/popups.cpp b/message_notify/popups.cpp new file mode 100644 index 0000000..1a40583 --- /dev/null +++ b/message_notify/popups.cpp @@ -0,0 +1,271 @@ +#include "common.h"
+#include "popups.h"
+#include "options.h"
+
+#include <tchar.h>
+
+HICON hPopupIcon;
+bool unicode_enabled;
+
+void __stdcall sttOpenSRMMWindowProc( ULONG dwParam )
+{
+ //CallService(MS_MSG_SENDMESSAGE, (WPARAM)dwParam, 0);
+
+ // simulate double-click on contact
+ CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)dwParam, 0);
+}
+
+void __stdcall sttCloseSRMMWindowProc( ULONG dwParam )
+{
+ HANDLE hContact = (HANDLE)dwParam;
+ MessageWindowInputData mwid = {0};
+ MessageWindowData mwd = {0};
+
+ mwid.cbSize = sizeof(mwid);
+ mwid.hContact = hContact;
+ mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
+
+ mwd.cbSize = sizeof(mwd);
+
+ if(!CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd)) {
+ HWND hwnd = mwd.hwndWindow;//, parent;
+ //while((parent = GetParent(hwnd)) != 0) hwnd = parent; // ensure we have the top level window (need parent window for scriver & tabsrmm)
+
+ //PostMessage(hwnd, WM_COMMAND, 1023, 0); // chat close tab? (unfortunately, chat doesn't implement the messaging API to notify us of window open/close events
+ PostMessage(hwnd, WM_COMMAND, IDCANCEL, 0); // srmm/scriver close session button
+ PostMessage(hwnd, WM_COMMAND, 1025, 0); // tabsrmm close session button
+
+ PostMessageWindowList(WMU_CLOSEPOPUP, (WPARAM)hContact, 0); // close popups
+ }
+}
+
+LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
+{
+ switch( message ) {
+ case WM_COMMAND: {
+ HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
+ QueueUserAPC( sttOpenSRMMWindowProc , mainThread, ( ULONG )hContact );
+ PUDeletePopUp( hWnd );
+ return TRUE;
+ }
+
+ case WMU_CLOSEPOPUP: {
+ HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
+ if((HANDLE)wParam == hContact)
+ PUDeletePopUp( hWnd );
+ return TRUE;
+ }
+
+ case WM_CONTEXTMENU: {
+ // mark most recent event read...FIXME (may not be correct event)
+ HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
+ HANDLE lastDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)hContact, 0);
+ int count = 0;
+ while(lastDbEvent && count++ < 10) {
+ CallService(MS_DB_EVENT_MARKREAD, (WPARAM)hContact, (LPARAM)lastDbEvent);
+ CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)lastDbEvent);
+ lastDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)lastDbEvent, 0);
+ }
+ if(options.close_win)
+ QueueUserAPC( sttCloseSRMMWindowProc , mainThread, ( ULONG )hContact );
+ PUDeletePopUp( hWnd );
+ return TRUE;
+ }
+
+ case UM_FREEPLUGINDATA: {
+ HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
+ RemoveFromWindowList(hContact, hWnd);
+ return TRUE;
+ }
+
+ case UM_INITPOPUP:
+ HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
+ if(!InList(hContact, hWnd)) AddToWindowList(hContact, hWnd);
+ return TRUE;
+ }
+
+ return DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+void __stdcall sttPopupProc( ULONG param ){
+//DWORD sttPopupProc(LPVOID param) {
+ POPUPDATAEX* ppd = ( POPUPDATAEX* )param;
+
+ if ( ServiceExists(MS_POPUP_ADDPOPUPEX) )
+ CallService( MS_POPUP_ADDPOPUPEX, ( WPARAM )ppd, 0 );
+ else
+ if ( ServiceExists(MS_POPUP_ADDPOPUP) )
+ CallService( MS_POPUP_ADDPOPUP, ( WPARAM )ppd, 0 );
+
+ free( ppd );
+
+ //return 0;
+}
+
+void __stdcall sttPopupProcW( ULONG param ) {
+//DWORD sttPopupProcW(LPVOID param) {
+ POPUPDATAW* ppd = ( POPUPDATAW* )param;
+
+ if ( ServiceExists(MS_POPUP_ADDPOPUPW) )
+ CallService( MS_POPUP_ADDPOPUPW, ( WPARAM )ppd, 0 );
+
+ free( ppd );
+
+ //return 0;
+}
+
+void ShowPopup( HANDLE hContact, const char* line1, const char* line2, int flags )
+{
+ if(CallService(MS_SYSTEM_TERMINATED, 0, 0)) return;
+
+ if ( !ServiceExists( MS_POPUP_ADDPOPUP )) {
+ char title[256];
+ sprintf(title, "%s Message", MODULE);
+
+ if(line1 && line2) {
+ char *message = new char[strlen(line1) + strlen(line2) + 2]; // newline and null terminator
+ sprintf(message, "%s\n%s", line1, line2);
+ MessageBoxA( NULL, message, title, MB_OK | MB_ICONINFORMATION );
+ delete message;
+ } else if(line1) {
+ MessageBoxA( NULL, line1, title, MB_OK | MB_ICONINFORMATION );
+ } else if(line2) {
+ MessageBoxA( NULL, line2, title, MB_OK | MB_ICONINFORMATION );
+ }
+ return;
+ }
+
+ POPUPDATAEX* ppd = ( POPUPDATAEX* )malloc( sizeof( POPUPDATAEX ));
+ memset((void *)ppd, 0, sizeof(POPUPDATAEX));
+
+ ppd->lchContact = hContact;
+
+ HANDLE hMeta = 0;
+ if((hMeta = (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0)) != 0)
+ ppd->lchContact = hMeta;
+
+ ppd->lchIcon = hPopupIcon;
+
+ if(line1 && line2) {
+ strncpy( ppd->lpzContactName, line1, MAX_CONTACTNAME );
+ strncpy( ppd->lpzText, line2, MAX_SECONDLINE );
+ } else {
+ if(line1) {
+ strncpy( ppd->lpzText, line1, MAX_SECONDLINE );
+ } else {
+ if(line2)
+ strncpy( ppd->lpzText, line2, MAX_SECONDLINE );
+ }
+ }
+
+ if(options.set_colours) {
+ ppd->colorBack = options.bkCol;
+ ppd->colorText = options.textCol;
+ }
+ ppd->iSeconds = options.timeout;
+
+ ppd->PluginWindowProc = ( WNDPROC )NullWindowProc;
+ ppd->PluginData = NULL;
+
+ ppd->PluginData = (void *)hContact;
+
+ QueueUserAPC( sttPopupProc , mainThread, ( ULONG )ppd );
+ //CloseHandle(CreateThread(0, 0, (LPTHREAD_START_ROUTINE)sttPopupProc, (LPVOID)ppd, 0, 0));
+}
+
+void ShowPopupW( HANDLE hContact, const wchar_t* line1, const wchar_t* line2, int flags )
+{
+ if(CallService(MS_SYSTEM_TERMINATED, 0, 0)) return;
+
+ if ( !ServiceExists( MS_POPUP_ADDPOPUPW )) {
+ wchar_t title[256];
+ _stprintf(title, _T("%s Message"), _T(MODULE));
+
+ if(line1 && line2) {
+ wchar_t *message = new wchar_t[_tcslen(line1) + _tcslen(line2) + 2]; // newline and null terminator
+ _stprintf(message, _T("%s\n%s"), line1, line2);
+ MessageBoxW( NULL, message, title, MB_OK | MB_ICONINFORMATION );
+ delete message;
+ } else if(line1) {
+ MessageBoxW( NULL, line1, title, MB_OK | MB_ICONINFORMATION );
+ } else if(line2) {
+ MessageBoxW( NULL, line2, title, MB_OK | MB_ICONINFORMATION );
+ }
+ return;
+ }
+
+ POPUPDATAW* ppd = ( POPUPDATAW* )malloc( sizeof( POPUPDATAW ));
+ memset((void *)ppd, 0, sizeof(POPUPDATAW));
+
+ ppd->lchContact = hContact;
+
+ HANDLE hMeta = 0;
+ if((hMeta = (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0)) != 0)
+ ppd->lchContact = hMeta;
+
+ ppd->lchIcon = hPopupIcon;
+
+ if(line1 && line2) {
+ _tcsncpy( ppd->lpwzContactName, line1, MAX_CONTACTNAME );
+ _tcsncpy( ppd->lpwzText, line2, MAX_SECONDLINE );
+ } else {
+ if(line1) {
+ _tcsncpy( ppd->lpwzText, line1, MAX_SECONDLINE );
+ } else {
+ if(line2)
+ _tcsncpy( ppd->lpwzText, line2, MAX_SECONDLINE );
+ }
+ }
+
+ if(options.set_colours) {
+ ppd->colorBack = options.bkCol;
+ ppd->colorText = options.textCol;
+ }
+ ppd->iSeconds = options.timeout;
+
+ ppd->PluginWindowProc = ( WNDPROC )NullWindowProc;
+ ppd->PluginData = NULL;
+
+ ppd->PluginData = (void *)hContact;
+
+ QueueUserAPC( sttPopupProcW , mainThread, ( ULONG )ppd );
+ //CloseHandle(CreateThread(0, 0, (LPTHREAD_START_ROUTINE)sttPopupProcW, (LPVOID)ppd, 0, 0));
+}
+
+void ShowWarning(char *msg) {
+ if(ServiceExists(MS_POPUP_SHOWMESSAGE)) {
+ char message[1024];
+ sprintf(message, "%s: %s", MODULE, msg);
+ PUShowMessage(message, SM_WARNING);
+ } else {
+ char title[512];
+ sprintf(title, "%s Warning", MODULE);
+ MessageBoxA(0, msg, title, MB_OK | MB_ICONWARNING);
+ }
+}
+
+void ShowError(char *msg) {
+ if(ServiceExists(MS_POPUP_SHOWMESSAGE)) {
+ char message[1024];
+ sprintf(message, "%s: %s", MODULE, msg);
+ PUShowMessage(message, SM_WARNING);
+ } else {
+ char title[512];
+ sprintf(title, "%s Error", MODULE);
+ MessageBoxA(0, msg, title, MB_OK | MB_ICONERROR);
+ }
+}
+
+bool IsUnicodePopupsEnabled() {
+ return unicode_enabled;
+}
+
+void InitUtils() {
+ hPopupIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
+ unicode_enabled = ServiceExists(MS_POPUP_ADDPOPUPW) ? true : false;
+}
+
+void DeinitUtils() {
+ DestroyIcon(hPopupIcon);
+}
+
diff --git a/message_notify/popups.h b/message_notify/popups.h new file mode 100644 index 0000000..eb71d85 --- /dev/null +++ b/message_notify/popups.h @@ -0,0 +1,21 @@ +#ifndef _POPUPS_INC
+#define _POPUPS_INC
+
+#include "../../include/m_popup.h"
+
+#include "options.h"
+#include "mywindowlist.h"
+
+void InitUtils();
+void DeinitUtils();
+
+void ShowPopup(HANDLE hContact, const char* line1, const char* line2, int flags = 0);
+void ShowWarning(char *msg);
+void ShowError(char *msg);
+
+bool IsUnicodePopupsEnabled();
+void ShowPopupW(HANDLE hContact, const wchar_t* line1, const wchar_t* line2, int flags = 0);
+
+#define WMU_CLOSEPOPUP (WM_USER + 200)
+
+#endif
diff --git a/message_notify/resource.h b/message_notify/resource.h new file mode 100644 index 0000000..d8de870 --- /dev/null +++ b/message_notify/resource.h @@ -0,0 +1,29 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by resource.rc
+//
+#define IDD_OPTIONS 101
+#define IDC_CHK_DISABLEPOPUPS 1000
+#define IDC_RAD_CLOSED 1001
+#define IDC_RAD_NFORE 1002
+#define IDC_RAD_ALWAYS 1003
+#define IDC_CHK_SETTIMEOUT 1004
+#define IDC_ED_TIMEOUT 1005
+#define IDC_CHK_SETCOLOURS 1006
+#define IDC_CP_BK 1007
+#define IDC_CP_TXT 1008
+#define IDC_CHK_TABS 1009
+#define IDC_CHK_CLOSE 1010
+#define IDC_LIST1 1012
+#define IDC_LST_STATUS 1012
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1013
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/message_notify/resource.rc b/message_notify/resource.rc new file mode 100644 index 0000000..44b0fe0 --- /dev/null +++ b/message_notify/resource.rc @@ -0,0 +1,114 @@ +// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (Australia) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPTIONS DIALOGEX 0, 0, 250, 196
+STYLE DS_SETFONT | WS_CHILD
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+ GROUPBOX "Notification Options",IDC_STATIC,7,7,144,83
+ CONTROL "Notify if window not open",IDC_RAD_CLOSED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,20,136,10
+ CONTROL "Notify if window isn't 'foreground'",IDC_RAD_NFORE,
+ "Button",BS_AUTORADIOBUTTON,10,34,136,10
+ CONTROL "Notify always",IDC_RAD_ALWAYS,"Button",BS_AUTORADIOBUTTON,10,59,136,10
+ GROUPBOX "Timeout",IDC_STATIC,7,96,236,40
+ CONTROL "Set timeout (otherwise, infinite)",IDC_CHK_SETTIMEOUT,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,104,205,10
+ RTEXT "Timeout (seconds, 0 == default):",IDC_STATIC,19,119,137,8
+ EDITTEXT IDC_ED_TIMEOUT,168,117,29,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
+ GROUPBOX "Colours",IDC_STATIC,7,140,236,49
+ CONTROL "Set popup colours",IDC_CHK_SETCOLOURS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,161,95,10
+ RTEXT "Background:",IDC_STATIC,122,154,63,8
+ RTEXT "Text:",IDC_STATIC,122,173,63,8
+ CONTROL "Custom1",IDC_CP_BK,"ColourPicker",WS_TABSTOP,193,151,41,12
+ CONTROL "Custom1",IDC_CP_TXT,"ColourPicker",WS_TABSTOP,193,171,41,12
+ CONTROL "Consider tabs",IDC_CHK_TABS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,33,46,112,10
+ CONTROL "Close window on right click",IDC_CHK_CLOSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,74,136,10
+ GROUPBOX "Disable when",IDC_STATIC,157,7,86,83
+ CONTROL "",IDC_LST_STATUS,"SysListView32",LVS_REPORT | LVS_NOLABELWRAP | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_TABSTOP,161,19,79,64,WS_EX_CLIENTEDGE
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPTIONS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 243
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 189
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (Australia) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
|