From 942fbc5f4ad0df4beef9a664cdccaa3609e228f4 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Tue, 29 Oct 2013 20:03:26 +0000 Subject: revert connection timeout git-svn-id: http://svn.miranda-ng.org/main/trunk@6685 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NewXstatusNotify/res/resource.rc | 26 +++++++++------ plugins/NewXstatusNotify/src/main.cpp | 57 ++++++++++++++++++++++++++++++-- plugins/NewXstatusNotify/src/options.cpp | 7 ++++ plugins/NewXstatusNotify/src/options.h | 1 + plugins/NewXstatusNotify/src/resource.h | 3 ++ plugins/NewXstatusNotify/src/xstatus.cpp | 44 ++++++++++++------------ 6 files changed, 103 insertions(+), 35 deletions(-) (limited to 'plugins/NewXstatusNotify') diff --git a/plugins/NewXstatusNotify/res/resource.rc b/plugins/NewXstatusNotify/res/resource.rc index 0c64a7d15b..a8ef4b0729 100644 --- a/plugins/NewXstatusNotify/res/resource.rc +++ b/plugins/NewXstatusNotify/res/resource.rc @@ -204,21 +204,21 @@ BEGIN GROUPBOX "Popup text",IDC_STATIC,144,44,164,85,WS_GROUP CONTROL "Read status message",IDC_READAWAYMSG,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,148,102,151,13 CONTROL "Show previous status too",IDC_SHOWPREVIOUSSTATUS,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,148,90,151,13 - GROUPBOX "Timeout",IDC_STATIC,143,129,164,35 - EDITTEXT IDC_TIMEOUT_VALUE,159,143,32,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_TIMEOUT_VALUE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,180,143,11,12 + GROUPBOX "Timeout",IDC_STATIC,143,129,164,42 + EDITTEXT IDC_TIMEOUT_VALUE,159,138,32,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_TIMEOUT_VALUE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,180,138,11,12 PUSHBUTTON "Preview",IDC_PREVIEW,43,206,57,15 GROUPBOX "Popups when status changes to:",IDC_STATIC,1,0,138,200,WS_GROUP - GROUPBOX "Click action",IDC_STATIC,143,164,164,67,WS_GROUP + GROUPBOX "Click action",IDC_STATIC,143,172,164,59,WS_GROUP CONTROL "Show contact group name",IDC_SHOWGROUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,56,151,9 CONTROL "Use alternative descriptions",IDC_SHOWALTDESCS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,78,151,13 - CTEXT "0 = Default",IDC_STATUS_STATIC_DEFAULT,224,140,76,8 - CTEXT "-1 = Infinite",IDC_STATUS_STATIC_INFINITE,222,150,76,8 - LTEXT "Sec",IDC_STATUS_STATIC_SEC,196,144,21,8 - COMBOBOX IDC_STATUS_LC,150,185,150,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_STATUS_RC,150,212,150,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "On left click",IDC_STATIC,152,174,151,8 - LTEXT "On right click",IDC_STATIC,152,201,151,8 + CTEXT "0 = Default",IDC_STATIC,224,135,76,8 + CTEXT "-1 = Infinite",IDC_STATIC,222,145,76,8 + LTEXT "Sec",IDC_STATIC,196,139,21,8 + COMBOBOX IDC_STATUS_LC,150,190,150,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_STATUS_RC,150,215,150,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "On left click",IDC_STATIC,152,180,151,8 + LTEXT "On right click",IDC_STATIC,152,205,151,8 CONTROL "",IDC_XSTATUS_TX,"ColourPicker",WS_TABSTOP,106,182,24,12 CONTROL "",IDC_XSTATUS_BG,"ColourPicker",WS_TABSTOP,73,182,24,12 LTEXT "Offline",IDC_STATIC,6,24,56,8 @@ -235,6 +235,10 @@ BEGIN CONTROL "Show status description",IDC_SHOWSTATUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,66,151,13 CONTROL "Ignore empty status and xStatus messages",IDC_PUIGNOREREMOVE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,117,152,8 + EDITTEXT IDC_CONNECTIONTIMEOUT_VALUE,159,154,32,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_CONNECTIONTIMEOUT_VALUE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS,179,154,11,12 + LTEXT "Sec",IDC_STATIC,195,156,21,8 + LTEXT "Connection timeout",IDC_STATIC,222,156,79,8 END IDD_OPT_XPOPUP DIALOGEX 0, 0, 305, 230 diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index 8cd93caacf..26f2375d0a 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -485,7 +485,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) if (opt.IgnoreEmpty && (smi.compare == 2)) retem = FALSE; - else if (!opt.PopupOnConnect) + else if (!db_get_b(0, MODULE, smi.proto, 1) && !opt.PopupOnConnect) rettime = FALSE; char status[8]; @@ -781,10 +781,13 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) } else db_set_s(hContact, szProto, "LastOnline", szSubProto); + if (!db_get_b(0, MODULE, szSubProto, 1)) + return 0; + strcpy(szProto, szSubProto); } else { - if (myStatus == ID_STATUS_OFFLINE) + if (myStatus == ID_STATUS_OFFLINE || !db_get_b(0, MODULE, szProto, 1)) return 0; } @@ -987,6 +990,48 @@ 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) { + KillTimer(hwnd, idEvent); + + //We've received a timer message: enable the popups for a specified protocol. + char szProto[256]; + if ( GetAtomNameA((ATOM)idEvent, szProto, sizeof(szProto)) > 0) { + db_set_b(0, MODULE, szProto, 1); + DeleteAtom((ATOM)idEvent); + } + } +} + +int ProtoAck(WPARAM wParam,LPARAM lParam) +{ + ACKDATA *ack = (ACKDATA *)lParam; + + if (ack->type == ACKTYPE_STATUS) { + WORD newStatus = (WORD)ack->lParam; + WORD oldStatus = (WORD)ack->hProcess; + char *szProto = (char *)ack->szModule; + + if (oldStatus == newStatus) + return 0; + + if (newStatus == ID_STATUS_OFFLINE) { + //The protocol switched to offline. Disable the popups for this protocol + db_set_b(NULL, MODULE, szProto, 0); + } + 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. + int idTimer = AddAtomA(szProto); + if (idTimer) + SetTimer(NULL, idTimer, (UINT)opt.PopupConnectionTimeout*1000, ConnectionTimerProc); + } + } + + return 0; +} + INT_PTR EnableDisableMenuCommand(WPARAM wParam, LPARAM lParam) { opt.TempDisabled = !opt.TempDisabled; @@ -1068,6 +1113,13 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent); HookEvent(ME_TTB_MODULELOADED, InitTopToolbar); + int count = 0; + PROTOACCOUNT **accounts = NULL; + CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&count, (LPARAM)&accounts); + for (int i = 0; i < count; i++) + if (IsAccountEnabled(accounts[i])) + db_set_b(NULL, MODULE, accounts[i]->szModuleName, 0); + if (ServiceExists(MS_MC_GETPROTOCOLNAME)) strcpy(szMetaModuleName, (char *)CallService(MS_MC_GETPROTOCOLNAME, 0, 0)); @@ -1087,6 +1139,7 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_OPT_INITIALISE, OptionsInitialize); //This is needed for "NoSound"-like routines. HookEvent(ME_CLIST_STATUSMODECHANGE, StatusModeChanged); + HookEvent(ME_PROTO_ACK, ProtoAck); LoadOptions(); InitStatusList(); diff --git a/plugins/NewXstatusNotify/src/options.cpp b/plugins/NewXstatusNotify/src/options.cpp index 3d1bcb0d6d..d601613fa8 100644 --- a/plugins/NewXstatusNotify/src/options.cpp +++ b/plugins/NewXstatusNotify/src/options.cpp @@ -55,6 +55,7 @@ void LoadOptions() opt.ShowPreviousStatus = db_get_b(0, MODULE, "ShowPreviousStatus", 0); opt.ReadAwayMsg = db_get_b(0, MODULE, "ReadAwayMsg", 0); opt.PopupTimeout = db_get_dw(0, MODULE, "PopupTimeout", 0); + opt.PopupConnectionTimeout = db_get_dw(0, MODULE, "PopupConnectionTimeout", 15); opt.LeftClickAction= db_get_b(0, MODULE, "LeftClickAction", 5); opt.RightClickAction = db_get_b(0, MODULE, "RightClickAction", 1); opt.IgnoreEmpty = db_get_b(0, MODULE, "IgnoreEmpty", 1); @@ -125,6 +126,7 @@ void SaveOptions() db_set_b(0, MODULE, "ShowPreviousStatus", opt.ShowPreviousStatus); db_set_b(0, MODULE, "ReadAwayMsg", opt.ReadAwayMsg); db_set_dw(0, MODULE, "PopupTimeout", opt.PopupTimeout); + db_set_dw(0, MODULE, "PopupConnectionTimeout", opt.PopupConnectionTimeout); db_set_b(0, MODULE, "LeftClickAction", opt.LeftClickAction); db_set_b(0, MODULE, "RightClickAction", opt.RightClickAction); db_set_b(0, MODULE, "IgnoreEmpty", opt.IgnoreEmpty); @@ -318,6 +320,10 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 999); SetDlgItemInt(hwndDlg, IDC_TIMEOUT_VALUE, opt.PopupTimeout, TRUE); + SendDlgItemMessage(hwndDlg, IDC_CONNECTIONTIMEOUT_VALUE, EM_LIMITTEXT, 3, 0); + SendDlgItemMessage(hwndDlg, IDC_CONNECTIONTIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999); + SetDlgItemInt(hwndDlg, IDC_CONNECTIONTIMEOUT_VALUE, opt.PopupConnectionTimeout, TRUE); + //Mouse actions for (int i = 0; i < SIZEOF(PopupActions); i++) { @@ -464,6 +470,7 @@ INT_PTR CALLBACK DlgProcPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM opt.ShowPreviousStatus = IsDlgButtonChecked(hwndDlg, IDC_SHOWPREVIOUSSTATUS); opt.ShowGroup = IsDlgButtonChecked(hwndDlg, IDC_SHOWGROUP); opt.PopupTimeout = GetDlgItemInt(hwndDlg, IDC_TIMEOUT_VALUE, 0, TRUE); + opt.PopupConnectionTimeout = GetDlgItemInt(hwndDlg, IDC_CONNECTIONTIMEOUT_VALUE, 0, TRUE); opt.LeftClickAction = (BYTE)SendDlgItemMessage(hwndDlg, IDC_STATUS_LC, CB_GETCURSEL, 0, 0); opt.RightClickAction = (BYTE)SendDlgItemMessage(hwndDlg, IDC_STATUS_RC, CB_GETCURSEL, 0, 0); opt.IgnoreEmpty = IsDlgButtonChecked(hwndDlg, IDC_PUIGNOREREMOVE); diff --git a/plugins/NewXstatusNotify/src/options.h b/plugins/NewXstatusNotify/src/options.h index 6d3c018570..b5e2eff5c9 100644 --- a/plugins/NewXstatusNotify/src/options.h +++ b/plugins/NewXstatusNotify/src/options.h @@ -33,6 +33,7 @@ typedef struct tagOPTIONS { BYTE ShowPreviousStatus; BYTE ReadAwayMsg; int PopupTimeout; + UINT PopupConnectionTimeout; BYTE LeftClickAction; BYTE RightClickAction; // IDD_OPT_XPOPUP diff --git a/plugins/NewXstatusNotify/src/resource.h b/plugins/NewXstatusNotify/src/resource.h index b68a263716..58a41599b1 100644 --- a/plugins/NewXstatusNotify/src/resource.h +++ b/plugins/NewXstatusNotify/src/resource.h @@ -28,6 +28,8 @@ #define IDC_STATUS_LC 1006 #define IDC_USEWINCOLORS 1007 #define IDC_STATUS_RC 1008 +#define IDC_CONNECTIONTIMEOUT_VALUE_SPIN 1009 +#define IDC_STATUS_STATIC_SEC2 1010 #define IDC_READAWAYMSG 1011 #define IDC_CHK_DISABLEMUSIC 1011 #define IDC_SHOWPREVIOUSSTATUS 1012 @@ -63,6 +65,7 @@ #define IDC_LOG 1061 #define IDC_TIMEOUT_VALUE 1066 #define IDC_BLINKICON 1067 +#define IDC_CONNECTIONTIMEOUT_VALUE 1067 #define IDC_BLINKICON_STATUS 1068 #define IDC_SOUNDICON 1069 #define IDC_POPUPICON 1070 diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index 1dcf8e69ef..8add5a6218 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -41,7 +41,7 @@ void FreeXSC(XSTATUSCHANGE *xsc) } } -void RemoveLoggedEvents(HANDLE hContact) +void RemoveLoggedEvents(HANDLE hContact) { for (int i = eventList.getCount()-1; i >= 0; i--) { DBEVENT *dbevent = eventList[i]; @@ -49,7 +49,7 @@ void RemoveLoggedEvents(HANDLE hContact) db_event_delete(dbevent->hContact, dbevent->hDBEvent); eventList.remove(i); mir_free(dbevent); - } + } } } @@ -84,7 +84,7 @@ void ReplaceVars(XSTATUSCHANGE *xsc , TCHAR *Template, TCHAR *delimiter, TCHAR * { TCHAR stzType[32]; _tcscat(buff, GetStatusTypeAsString(xsc->type, stzType)); - } + } break; case _T('T'): if (xsc->stzTitle) @@ -118,7 +118,7 @@ void ReplaceVars(XSTATUSCHANGE *xsc , TCHAR *Template, TCHAR *delimiter, TCHAR * } // append rest of the text - if (Template != NULL) + if (Template != NULL) _tcscat(buff, Template); } @@ -164,8 +164,8 @@ void ShowPopup(XSTATUSCHANGE *xsc) break; } - TCHAR *ptszGroup = NULL, - *ptszNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GSMDF_TCHAR); + TCHAR *ptszGroup = NULL; + TCHAR *ptszNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GSMDF_TCHAR); if (opt.ShowGroup) { //add group name to popup title if (!db_get_ts(xsc->hContact, "CList", "Group", &dbv)) { ptszGroup = NEWTSTR_ALLOCA(dbv.ptszVal); @@ -200,13 +200,13 @@ void ShowPopup(XSTATUSCHANGE *xsc) Template = templates.LogOpening; break; } - TCHAR stzPopupText[2*MAX_TEXT_LEN]; + TCHAR stzPopupText[2*MAX_TEXT_LEN]; ReplaceVars(xsc, Template, templates.PopupDelimiter, stzPopupText); _tcsncpy(ppd.lptzText, stzPopupText, SIZEOF(ppd.lptzText)); ppd.lptzText[SIZEOF(ppd.lptzText) - 1] = 0; ppd.PluginWindowProc = (WNDPROC)PopupDlgProc; - ppd.iSeconds = opt.PopupTimeout; + ppd.iSeconds = opt.PopupTimeout; PUAddPopupT(&ppd); } @@ -246,8 +246,8 @@ void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening) Template = templates.LogOpening; break; } - TCHAR stzLogText[2*MAX_TEXT_LEN]; - TCHAR stzLastLog[2*MAX_TEXT_LEN]; + TCHAR stzLogText[2*MAX_TEXT_LEN]; + TCHAR stzLastLog[2*MAX_TEXT_LEN]; ReplaceVars(xsc, Template, templates.LogDelimiter, stzLogText); DBGetStringDefault(xsc->hContact, MODULE, DB_LASTLOG, stzLastLog, SIZEOF(stzLastLog), _T("")); @@ -273,7 +273,7 @@ void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening) if (!opt.KeepInHistory) { DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT)); dbevent->hContact = xsc->hContact; - dbevent->hDBEvent = hDBEvent; + dbevent->hDBEvent = hDBEvent; eventList.insert(dbevent); } } @@ -299,7 +299,7 @@ void LogChangeToFile(XSTATUSCHANGE *xsc) LogToFile(stzText); } -void ExtraStatusChanged(XSTATUSCHANGE *xsc) +void ExtraStatusChanged(XSTATUSCHANGE *xsc) { if (xsc == NULL) return; @@ -307,7 +307,7 @@ void ExtraStatusChanged(XSTATUSCHANGE *xsc) BOOL bEnablePopup = true, bEnableSound = true; char buff[12] = {0}; - mir_snprintf(buff, SIZEOF(buff), "%d", ID_STATUS_EXTRASTATUS); + mir_snprintf(buff, SIZEOF(buff), "%d", ID_STATUS_EXTRASTATUS); if (( db_get_b(0, MODULE, buff, 1) == 0) || (db_get_w(xsc->hContact, xsc->szProto, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) @@ -320,7 +320,7 @@ void ExtraStatusChanged(XSTATUSCHANGE *xsc) char statusIDs[12], statusIDp[12]; if (opt.AutoDisable) { - WORD myStatus = (WORD)CallProtoService(xsc->szProto, PS_GETSTATUS, 0, 0); + WORD myStatus = (WORD)CallProtoService(xsc->szProto, PS_GETSTATUS, 0, 0); mir_snprintf(statusIDs, SIZEOF(statusIDs), "s%d", myStatus); mir_snprintf(statusIDp, SIZEOF(statusIDp), "p%d", myStatus); bEnableSound = db_get_b(0, MODULE, statusIDs, 1) ? FALSE : TRUE; @@ -334,7 +334,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)) + 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)) @@ -351,7 +351,7 @@ void ExtraStatusChanged(XSTATUSCHANGE *xsc) && CallService(MS_MSG_MOD_MESSAGEDIALOGOPENED, (WPARAM)xsc->hContact, 0)) LogToMessageWindow(xsc, FALSE); - if (opt.Log) + if (opt.Log) LogChangeToFile(xsc); FreeXSC(xsc); @@ -392,11 +392,11 @@ TCHAR *GetIcqXStatus(HANDLE hContact, char *szProto, char *szValue, TCHAR *buff, db_free(&dbv); } } - + return buff; } -TCHAR *GetJabberAdvStatusText(HANDLE hContact, char *szProto, char *szSlot, char *szValue, TCHAR *buff, int bufflen) +TCHAR *GetJabberAdvStatusText(HANDLE hContact, char *szProto, char *szSlot, char *szValue, TCHAR *buff, int bufflen) { DBVARIANT dbv; char szSetting[128]; @@ -424,11 +424,11 @@ void LogXstatusChange(HANDLE hContact, char *szProto, int xstatusType, TCHAR *st stzText[0] ? mir_tstrdup(stzText) : NULL ); - LogToMessageWindow(xsc, TRUE); + LogToMessageWindow(xsc, TRUE); FreeXSC(xsc); } -void AddEventThread(void *arg) +void AddEventThread(void *arg) { HANDLE hContact = (HANDLE)arg; TCHAR stzTitle[MAX_TITLE_LEN], stzText[MAX_TEXT_LEN]; @@ -459,7 +459,7 @@ void AddEventThread(void *arg) } } -int OnWindowEvent(WPARAM wParam, LPARAM lParam) +int OnWindowEvent(WPARAM wParam, LPARAM lParam) { MessageWindowEventData *mwed = (MessageWindowEventData *)lParam; @@ -471,7 +471,7 @@ int OnWindowEvent(WPARAM wParam, LPARAM lParam) if (opt.EnableLogging && (mwed->uType == MSG_WINDOW_EVT_OPEN) && (templates.LogFlags & NOTIFY_OPENING_ML) && - (db_get_b(mwed->hContact, MODULE, "EnableLogging", 1) == 1)) + (db_get_b(mwed->hContact, MODULE, "EnableLogging", 1) == 1)) { mir_forkthread(AddEventThread, mwed->hContact); } -- cgit v1.2.3