From 907045128b7dae896d45a40319eb86007df3e36b Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Mon, 4 Mar 2013 18:30:02 +0000 Subject: fix for the broken timer (patch by zaltys) (fixes #250) git-svn-id: http://svn.miranda-ng.org/main/trunk@3885 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NewXstatusNotify/src/main.cpp | 41 ++++++++++++++++++++++---------- plugins/NewXstatusNotify/src/xstatus.cpp | 2 +- plugins/NewXstatusNotify/src/xstatus.h | 1 - 3 files changed, 29 insertions(+), 15 deletions(-) (limited to 'plugins') diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index b45602279d..fcd3287d23 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -30,7 +30,7 @@ HANDLE hToolbarButton; char szMetaModuleName[256] = {0}; STATUS StatusList[STATUS_COUNT]; -DWORD LoadTime = 0; +HWND SecretWnd; int hLangpack; PLUGININFOEX pluginInfoEx = { @@ -301,14 +301,6 @@ BOOL FreeSmiStr(STATUSMSGINFO *smi) return 0; } -// return TRUE if timeout is over -BOOL TimeoutCheck() -{ - if (GetTickCount() - LoadTime > TMR_CONNECTIONTIMEOUT) - return TRUE; - return FALSE; -} - TCHAR* AddCR(const TCHAR *statusmsg) { const TCHAR *found; @@ -498,7 +490,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) if (opt.IgnoreEmpty && (smi.compare == 2)) retem = FALSE; - else if (!TimeoutCheck() && !opt.PopupOnConnect) + else if (!db_get_b(0, MODULE, smi.proto, 1) && !opt.PopupOnConnect) rettime = FALSE; char status[8]; @@ -795,7 +787,7 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) strcpy(szProto, szSubProto); } else { - if (myStatus == ID_STATUS_OFFLINE) + if (myStatus == ID_STATUS_OFFLINE || !db_get_b(0, MODULE, szProto, 1)) return 0; } @@ -821,7 +813,7 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) bEnablePopup = db_get_b(0, MODULE, statusIDp, 1) ? FALSE : TRUE; } - if (bEnablePopup && db_get_b(hContact, MODULE, "EnablePopups", 1) && TimeoutCheck()) + if (bEnablePopup && db_get_b(hContact, MODULE, "EnablePopups", 1)) ShowStatusChangePopup(hContact, szProto, oldStatus, newStatus); if (opt.BlinkIcon) @@ -997,6 +989,18 @@ void InitStatusList() StatusList[index].colorText = db_get_dw(NULL, MODULE, "40081tx", COLOR_TX_DEFAULT); } +VOID CALLBACK ConnectionTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + if (uMsg == WM_TIMER) + { + char szProto[256]; + //We've received a timer message: enable the popups for a specified protocol. + KillTimer(hwnd, idEvent); + DWORD dwResult = (DWORD)GetAtomNameA((ATOM)idEvent, szProto, sizeof(szProto)); + if (dwResult) db_set_b(0, MODULE, szProto, 1); + } +} + int ProtoAck(WPARAM wParam,LPARAM lParam) { ACKDATA *ack = (ACKDATA *)lParam; @@ -1016,7 +1020,14 @@ int ProtoAck(WPARAM wParam,LPARAM lParam) else if (oldStatus < ID_STATUS_ONLINE && newStatus >= ID_STATUS_ONLINE) { //The protocol changed from a disconnected status to a connected status. //Enable the popups for this protocol. - LoadTime = GetTickCount(); + int idTimer = AddAtomA(szProto); + if (idTimer) + { + char TimerProtoName[256]; + mir_snprintf(TimerProtoName, sizeof(TimerProtoName), "ConnectionTimeout%s", szProto); + UINT ConnectTimer = db_get_dw(0, MODULE, TimerProtoName, db_get_dw(0, MODULE, "ConnectionTimeout", 10000)); + SetTimer(SecretWnd, idTimer, ConnectTimer, ConnectionTimerProc); + } } } @@ -1105,6 +1116,10 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent); HookEvent(ME_TTB_MODULELOADED, InitTopToolbar); + SecretWnd = CreateWindowEx(WS_EX_TOOLWINDOW,_T("static"),_T("ConnectionTimerWindow"),0, + CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,HWND_DESKTOP, + NULL,hInst,NULL); + int count = 0; PROTOACCOUNT **accounts = NULL; CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&count, (LPARAM)&accounts); diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index 8052a5526b..3fc36c9f64 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -331,7 +331,7 @@ void ExtraStatusChanged(XSTATUSCHANGE *xsc) if (opt.PDisableForMusic && xsc->type == TYPE_ICQ_XSTATUS && xstatusID == XSTATUS_MUSIC) bEnableSound = bEnablePopup = false; - if (bEnablePopup && db_get_b(xsc->hContact, MODULE, "EnableXStatusNotify", 1) && TimeoutCheck()) + if (bEnablePopup && db_get_b(xsc->hContact, MODULE, "EnableXStatusNotify", 1) && db_get_b(0, MODULE, xsc->szProto, 1)) ShowPopup(xsc); if (bEnableSound && db_get_b(xsc->hContact, MODULE, "EnableXStatusNotify", 1)) diff --git a/plugins/NewXstatusNotify/src/xstatus.h b/plugins/NewXstatusNotify/src/xstatus.h index 4e7aabc9a0..dd2fed81c5 100644 --- a/plugins/NewXstatusNotify/src/xstatus.h +++ b/plugins/NewXstatusNotify/src/xstatus.h @@ -101,6 +101,5 @@ XSTATUSCHANGE *NewXSC(HANDLE hContact, char *szProto, int xstatusType, int actio void ExtraStatusChanged(XSTATUSCHANGE *xsc); void FreeXSC(XSTATUSCHANGE *xsc); int OnWindowEvent(WPARAM wParam, LPARAM lParam); -BOOL TimeoutCheck(); #endif \ No newline at end of file -- cgit v1.2.3