diff options
Diffstat (limited to 'no_history/dllmain.cpp')
-rw-r--r-- | no_history/dllmain.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/no_history/dllmain.cpp b/no_history/dllmain.cpp index 961ced8..17e161e 100644 --- a/no_history/dllmain.cpp +++ b/no_history/dllmain.cpp @@ -17,8 +17,6 @@ HANDLE hEventDbEventAdded, hEventMenuPrebuild, hMenuToggle, hMenuClear, hService CRITICAL_SECTION list_cs;
-UINT timer_id;
-
#define MS_NOHISTORY_TOGGLE MODULE "/ToggleOnOff"
#define MS_NOHISTORY_CLEAR MODULE "/Clear"
@@ -72,23 +70,24 @@ extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) { -void RemoveReadEvents() {
+void RemoveReadEvents(HANDLE hContact = 0) {
DBEVENTINFO info = {0};
info.cbSize = sizeof(info);
bool remove;
- DWORD current_time = (DWORD)time(0);
EnterCriticalSection(&list_cs);
EventListNode *node = event_list, *prev = 0;
while(node) {
remove = false;
- info.cbBlob = 0;
- if(!CallService(MS_DB_EVENT_GET, (WPARAM)node->hDBEvent, (LPARAM)&info)) {
- if((info.flags & DBEF_READ) || (info.flags & DBEF_SENT)) // note: already checked event type when added to list
- if(current_time - info.timestamp >= event_timeout) remove = true;
- } else {
- // could not get event info - maybe someone else deleted it - so remove list node
- remove = true;
+ if(hContact == 0 || hContact == node->hContact) {
+ info.cbBlob = 0;
+ if(!CallService(MS_DB_EVENT_GET, (WPARAM)node->hDBEvent, (LPARAM)&info)) {
+ if((info.flags & DBEF_READ) || (info.flags & DBEF_SENT)) // note: already checked event type when added to list
+ remove = true;
+ } else {
+ // could not get event info - maybe someone else deleted it - so remove list node
+ remove = true;
+ }
}
if(remove) {
@@ -146,9 +145,6 @@ int OnDatabaseEventAdd(WPARAM wParam, LPARAM lParam) { node->next = event_list;
event_list = node;
LeaveCriticalSection(&list_cs);
-
- // make sure it waits 1 sec before deleting this event
- timer_id = SetTimer(0, 0, 1000, TimerProc);
}
}
@@ -214,12 +210,18 @@ int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { int WindowEvent(WPARAM wParam, LPARAM lParam) {
MessageWindowEventData *mwd = (MessageWindowEventData *)lParam;
+ HANDLE hContact = mwd->hContact;
+ bool remove = (DBGetContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, 0) != 0);
+
+ if(mwd->uType == MSG_WINDOW_EVT_CLOSE) {
+ RemoveReadEvents(hContact);
+ return 0;
+ }
+
if(mwd->uType != MSG_WINDOW_EVT_OPEN) return 0;
+
if(!ServiceExists(MS_MSG_MODIFYICON)) return 0;
- HANDLE hContact = mwd->hContact;
-
- bool remove = (DBGetContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, 0) != 0);
char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0);
@@ -320,8 +322,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) { hEventIconPressed = HookEvent(ME_MSG_ICONPRESSED, IconPressed);
}
- timer_id = SetTimer(0, 0, 1000, TimerProc);
-
return 0;
}
@@ -365,13 +365,11 @@ extern "C" __declspec (dllexport) int Unload(void) { UnhookEvent(hModulesLoaded);
DeinitOptions();
- KillTimer(0, timer_id);
UnhookEvent(hEventDbEventAdded);
UnhookEvent(hEventMenuPrebuild);
DestroyServiceFunction(hServiceToggle);
DestroyServiceFunction(hServiceClear);
- event_timeout = 0;
RemoveReadEvents();
DeleteCriticalSection(&list_cs);
|