diff options
Diffstat (limited to 'plugins/NewXstatusNotify/src')
-rw-r--r-- | plugins/NewXstatusNotify/src/main.cpp | 57 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/options.cpp | 7 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/options.h | 1 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/resource.h | 3 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/xstatus.cpp | 44 |
5 files changed, 88 insertions, 24 deletions
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);
}
|