summaryrefslogtreecommitdiff
path: root/message_notify/messagenotify.cpp
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-10 06:07:39 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-07-10 06:07:39 +0000
commitdef15f7b4ab039525ea2a9028c18b497128f8c0d (patch)
tree4b0b31ade0c42e8181357bda0e40a7775c29d358 /message_notify/messagenotify.cpp
parent27291d65ae67151975d557424883d58afa920d4e (diff)
use new YAPP popup class API
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@267 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'message_notify/messagenotify.cpp')
-rw-r--r--message_notify/messagenotify.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/message_notify/messagenotify.cpp b/message_notify/messagenotify.cpp
index 437b614..640a127 100644
--- a/message_notify/messagenotify.cpp
+++ b/message_notify/messagenotify.cpp
@@ -27,7 +27,7 @@ DWORD focusTimerId = 0;
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
"Message Notify",
- PLUGIN_MAKE_VERSION(0,2,2,0),
+ PLUGIN_MAKE_VERSION(0,3,0,0),
"Show a popup when a message is received",
"Scott Ellis",
"mail@scottellis.com.au",
@@ -167,11 +167,15 @@ typedef struct {
} CheckWindowData;
unsigned int __stdcall sttCheckWindowProc( VOID *dwParam ) {
+ //bool debug = (DBGetContactSettingByte(0, MODULE, "Debug", 0) != 0);
+
CheckWindowData *cd = (CheckWindowData *)dwParam;
if(!thread_api) SetEvent(cd->hEvent);
Sleep(500); // wait for message window to open from event, if it's going to
+ //if(debug) PUShowMessage("start of notify thread", SM_NOTIFY);
+
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);
@@ -181,6 +185,7 @@ unsigned int __stdcall sttCheckWindowProc( VOID *dwParam ) {
|| (options.notify_when == NOTIFY_CLOSED && !window_open))
{
if(IsUnicodePopupsEnabled()) {
+ //if(debug) PUShowMessage("showing popup (unicode)", SM_NOTIFY);
// get contact display name from clist
wchar_t swzContactDisplayName[512];
@@ -215,6 +220,7 @@ unsigned int __stdcall sttCheckWindowProc( VOID *dwParam ) {
ShowPopupW(cd->hContact, swzContactDisplayName, 0);
}
} else {
+ //if(debug) PUShowMessage("showing popup (ansi)", SM_NOTIFY);
char *szCDN = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)cd->hContact, 0);
if(szCDN && szCDN[0]) {
if(cd->blobsize) {
@@ -226,6 +232,8 @@ unsigned int __stdcall sttCheckWindowProc( VOID *dwParam ) {
ShowPopup(cd->hContact, szCDN, 0);
}
}
+ } else {
+ //if(debug) PUShowMessage("no popup - notify when condition not met", SM_NOTIFY);
}
if(cd->blobsize)
@@ -238,26 +246,36 @@ unsigned int __stdcall sttCheckWindowProc( VOID *dwParam ) {
int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) {
DBEVENTINFO *dbei = (DBEVENTINFO *)lParam;
+ //bool debug = (DBGetContactSettingByte(0, MODULE, "Debug", 0) != 0);
// safety checks
if ((dbei == 0) || (wParam == 0) || (dbei->flags & DBEF_SENT) || (dbei->eventType != EVENTTYPE_MESSAGE) || (dbei->flags & DBEF_READ)) {
+ //if(debug) PUShowMessage("ignoring event (read, sent, no contact, or type != message)", SM_NOTIFY);
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])
+ if(status >= ID_STATUS_ONLINE && status <= ID_STATUS_OUTTOLUNCH && options.disable_status[status - ID_STATUS_ONLINE]) {
+ //if(debug) PUShowMessage("ignoring event (disabled for this status)", SM_NOTIFY);
return 0;
+ }
// messages from this contact ignored
- if(CallService(MS_IGNORE_ISIGNORED, wParam, (LPARAM)IGNOREEVENT_MESSAGE))
+ if(CallService(MS_IGNORE_ISIGNORED, wParam, (LPARAM)IGNOREEVENT_MESSAGE)) {
+ //if(debug) PUShowMessage("ignoring event (contact ignored)", SM_NOTIFY);
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))
+ if(DBGetContactSettingByte((HANDLE)wParam, "CList", "NotOnList", 0) && CallService(MS_IGNORE_ISIGNORED, 0, (LPARAM)IGNOREEVENT_MESSAGE)) {
+ //if(debug) PUShowMessage("ignoring event (contact not on list and defaulting to ignored)", SM_NOTIFY);
return 0;
+ }
- if(dbei->cbBlob == 0 || dbei->pBlob == 0)
+ if(dbei->cbBlob == 0 || dbei->pBlob == 0) {
+ //if(debug) PUShowMessage("ignoring event (no text)", SM_NOTIFY);
return 0; // just to be safe
+ }
CheckWindowData *cd = new CheckWindowData;
@@ -273,11 +291,13 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) {
// spawn a thread to deal with the copied data
if(thread_api) {
+ //if(debug) PUShowMessage("spawning notify thread (thread api)", SM_NOTIFY);
FORK_THREADEX_PARAMS tparam = {0};
tparam.arg = (VOID *)cd;
tparam.pFunc = sttCheckWindowProc;
CallService(MS_SYSTEM_FORK_THREAD_EX, 0, (LPARAM)&tparam);
} else {
+ //if(debug) PUShowMessage("spawning notify thread (no thread api)", SM_NOTIFY);
cd->hEvent = CreateEvent(0, 0, 0, 0);
CloseHandle((HANDLE)_beginthreadex(0, 0, sttCheckWindowProc, (VOID *)cd, 0, 0));
WaitForSingleObject(cd->hEvent, INFINITE);