diff options
Diffstat (limited to 'message_notify')
-rw-r--r-- | message_notify/MessageNotify.mdsp | 10 | ||||
-rw-r--r-- | message_notify/messagenotify.cpp | 66 | ||||
-rw-r--r-- | message_notify/popups.cpp | 13 |
3 files changed, 52 insertions, 37 deletions
diff --git a/message_notify/MessageNotify.mdsp b/message_notify/MessageNotify.mdsp index fd8763c..dc766df 100644 --- a/message_notify/MessageNotify.mdsp +++ b/message_notify/MessageNotify.mdsp @@ -96,9 +96,9 @@ extraResourceOptions= [Other]
1=..\..\include\m_database.h
[History]
-..\..\include\m_database.h,16842
-common.h,643
-options.cpp,5097
+popups.cpp,6329
mywindowlist.cpp,0
-popups.cpp,6337
-messagenotify.cpp,726
+options.cpp,5097
+common.h,643
+..\..\include\m_database.h,16842
+messagenotify.cpp,627
diff --git a/message_notify/messagenotify.cpp b/message_notify/messagenotify.cpp index f21c3f3..7cde52e 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,3,0,2),
+ PLUGIN_MAKE_VERSION(0,3,1,0),
"Show a popup when a message is received",
"Scott Ellis",
"mail@scottellis.com.au",
@@ -243,53 +243,67 @@ unsigned int __stdcall sttCheckWindowProc( VOID *dwParam ) { return 0;
}
-int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) {
- DBEVENTINFO *dbei = (DBEVENTINFO *)lParam;
-
+int OnDatabaseEventAdded(WPARAM wParam, LPARAM lParam) {
+ HANDLE hContact = (HANDLE)wParam;
+
//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);
+ // messages from this contact ignored
+ if(CallService(MS_IGNORE_ISIGNORED, (WPARAM)hContact, (LPARAM)IGNOREEVENT_MESSAGE)) {
+ //if(debug) PUShowMessage("ignoring event (contact ignored)", 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(debug) PUShowMessage("ignoring event (disabled for this status)", SM_NOTIFY);
+ // if contact 'not on list', use default ignore setting
+ if(DBGetContactSettingByte(hContact, "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;
}
- // messages from this contact ignored
- if(CallService(MS_IGNORE_ISIGNORED, wParam, (LPARAM)IGNOREEVENT_MESSAGE)) {
- //if(debug) PUShowMessage("ignoring event (contact ignored)", SM_NOTIFY);
+ HANDLE hDbEvent = (HANDLE)lParam;
+ DBEVENTINFO dbei = {0};
+ dbei.cbSize = sizeof(dbei);
+
+ if((dbei.cbBlob = (DWORD)CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) == (DWORD)-1)
+ //if(debug) PUShowMessage("invalid event", SM_NOTIFY);
+ return 0;
+
+ if(dbei.cbBlob > 0) dbei.pBlob = new BYTE[dbei.cbBlob];
+ if(CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei)) {
+ //if(debug) PUShowMessage("get event failed", 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(debug) PUShowMessage("ignoring event (contact not on list and defaulting to ignored)", SM_NOTIFY);
+ if ((dbei.flags & DBEF_SENT) || (dbei.eventType != EVENTTYPE_MESSAGE) || (dbei.flags & DBEF_READ)) {
+ //if(debug) PUShowMessage("ignoring event (read, sent, 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(debug) PUShowMessage("ignoring event (disabled for this status)", 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;
- cd->hContact = (HANDLE)wParam;
+ cd->hContact = hContact;
if(options.show_msg) {
- // copy blob data
- cd->blobsize = dbei->cbBlob;
- cd->blob = new BYTE[cd->blobsize];
- cd->flags = dbei->flags;
- memcpy(cd->blob, dbei->pBlob, cd->blobsize);
- } else
+ // send blob data
+ cd->blobsize = dbei.cbBlob;
+ cd->blob = dbei.pBlob;
+ cd->flags = dbei.flags;
+ } else {
cd->blobsize = 0;
+ delete dbei.pBlob;
+ }
- // spawn a thread to deal with the copied data
+ // spawn a thread to deal with the data
if(thread_api) {
//if(debug) PUShowMessage("spawning notify thread (thread api)", SM_NOTIFY);
FORK_THREADEX_PARAMS tparam = {0};
@@ -356,7 +370,7 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { metacontacts_installed = (ServiceExists(MS_MC_GETMETACONTACT) != 0);
- hEventDbEventAdded = HookEvent(ME_DB_EVENT_FILTER_ADD, OnDatabaseEventPreAdd);
+ hEventDbEventAdded = HookEvent(ME_DB_EVENT_ADDED, OnDatabaseEventAdded);
hIdle = HookEvent(ME_IDLE_CHANGED, OnIdleChanged);
hWindowEvent = HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
diff --git a/message_notify/popups.cpp b/message_notify/popups.cpp index 20a58f0..3bcc7d6 100644 --- a/message_notify/popups.cpp +++ b/message_notify/popups.cpp @@ -41,21 +41,22 @@ void __stdcall sttCloseSRMMWindowProc( ULONG dwParam ) LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
+ HANDLE hContact, lastDbEvent;
switch( message ) {
case UM_INITPOPUP:
- HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
+ hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
if(!InList(hContact, hWnd)) AddToWindowList(hContact, hWnd);
return TRUE;
case WM_COMMAND: {
- HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
+ 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);
+ hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
if((HANDLE)wParam == hContact)
PUDeletePopUp( hWnd );
return TRUE;
@@ -63,8 +64,8 @@ LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM 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);
+ hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
+ 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);
@@ -78,7 +79,7 @@ LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM }
case UM_FREEPLUGINDATA: {
- HANDLE hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
+ hContact = (HANDLE)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, (LPARAM)&hContact);
RemoveFromWindowList(hContact, hWnd);
return TRUE;
}
|