summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--no_history/NoHistory.mdsp8
-rw-r--r--no_history/dllmain.cpp40
-rw-r--r--no_history/options.cpp11
-rw-r--r--no_history/private.h2
4 files changed, 24 insertions, 37 deletions
diff --git a/no_history/NoHistory.mdsp b/no_history/NoHistory.mdsp
index 81baa2e..e0632f4 100644
--- a/no_history/NoHistory.mdsp
+++ b/no_history/NoHistory.mdsp
@@ -95,8 +95,8 @@ extraResourceOptions=
1=resource.rc
[Other]
[History]
-private.h,701
+options.cpp,5214
+..\tipper\options.cpp,37783
common.h,481
-dllmain.cpp,0
-..\tipper\options.cpp,37918
-options.cpp,5229
+private.h,701
+dllmain.cpp,2225
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);
diff --git a/no_history/options.cpp b/no_history/options.cpp
index 349a2b0..16d93f4 100644
--- a/no_history/options.cpp
+++ b/no_history/options.cpp
@@ -3,8 +3,6 @@
#include "resource.h"
#include "icons.h"
-DWORD event_timeout;
-
static void SetListGroupIcons(HWND hwndList,HANDLE hFirstItem,HANDLE hParentItem,int *groupChildCount)
{
int typeOfFirst;
@@ -129,7 +127,6 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
SetListGroupIcons(GetDlgItem(hwndDlg,IDC_LIST),(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETNEXTITEM,CLGN_ROOT,0),hItemAll,NULL);
SendDlgItemMessage(hwndDlg, IDC_SPN_TIMEOUT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(60 * 60, 1));
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, event_timeout, FALSE);
return FALSE;
case WM_SETFOCUS:
@@ -228,13 +225,6 @@ static BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
}
} while(hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0));
- BOOL trans;
- int val = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &trans, FALSE);
- if(trans) {
- event_timeout = val;
- DBWriteContactSettingDword(0, MODULE, "EventTimeout", event_timeout);
- }
-
return TRUE;
}
}
@@ -275,7 +265,6 @@ int OptInit(WPARAM wParam, LPARAM lParam) {
HANDLE hEventOptInit;
void InitOptions() {
hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit);
- event_timeout = DBGetContactSettingDword(0, MODULE, "EventTimeout", 1);
}
void DeinitOptions() {
diff --git a/no_history/private.h b/no_history/private.h
index 497a017..2cda9be 100644
--- a/no_history/private.h
+++ b/no_history/private.h
@@ -4,7 +4,7 @@
/* VERSION DEFINITIONS */
#define VER_MAJOR 0
#define VER_MINOR 1
-#define VER_RELEASE 1
+#define VER_RELEASE 2
#define VER_BUILD 0
#define __STRINGIZE(x) #x