summaryrefslogtreecommitdiff
path: root/plugins/NewXstatusNotify/src/xstatus.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2014-07-31 14:34:46 +0000
committerKirill Volinsky <mataes2007@gmail.com>2014-07-31 14:34:46 +0000
commit35586e08f45e41070186cd32038da1af98adc9d2 (patch)
tree48be4432293f835f91a77d00c42f890ce866a215 /plugins/NewXstatusNotify/src/xstatus.cpp
parent3bdff57b5868e9d333f61297021f7943ed160500 (diff)
options refactoring (thx slotwin)
git-svn-id: http://svn.miranda-ng.org/main/trunk@10003 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NewXstatusNotify/src/xstatus.cpp')
-rw-r--r--plugins/NewXstatusNotify/src/xstatus.cpp486
1 files changed, 299 insertions, 187 deletions
diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp
index b6478f3a6f..366a750dc8 100644
--- a/plugins/NewXstatusNotify/src/xstatus.cpp
+++ b/plugins/NewXstatusNotify/src/xstatus.cpp
@@ -41,13 +41,37 @@ void FreeXSC(XSTATUSCHANGE *xsc)
}
}
-void RemoveLoggedEvents(MCONTACT hContact)
+void RemoveLoggedEventsXStatus(MCONTACT hContact)
{
- for (int i = eventList.getCount()-1; i >= 0; i--) {
- DBEVENT *dbevent = eventList[i];
+ for (int i = eventListXStatus.getCount() - 1; i >= 0; i--) {
+ DBEVENT *dbevent = eventListXStatus[i];
if (dbevent->hContact == hContact) {
db_event_delete(dbevent->hContact, dbevent->hDBEvent);
- eventList.remove(i);
+ eventListXStatus.remove(i);
+ mir_free(dbevent);
+ }
+ }
+}
+
+void RemoveLoggedEventsStatus(MCONTACT hContact)
+{
+ for (int i = eventListStatus.getCount() - 1; i >= 0; i--) {
+ DBEVENT *dbevent = eventListStatus[i];
+ if (dbevent->hContact == hContact) {
+ db_event_delete(dbevent->hContact, dbevent->hDBEvent);
+ eventListStatus.remove(i);
+ mir_free(dbevent);
+ }
+ }
+}
+
+void RemoveLoggedEventsSMsg(MCONTACT hContact)
+{
+ for (int i = eventListSMsg.getCount() - 1; i >= 0; i--) {
+ DBEVENT *dbevent = eventListSMsg[i];
+ if (dbevent->hContact == hContact) {
+ db_event_delete(dbevent->hContact, dbevent->hDBEvent);
+ eventListSMsg.remove(i);
mir_free(dbevent);
}
}
@@ -69,120 +93,125 @@ TCHAR *GetStatusTypeAsString(int type, TCHAR *buff)
return buff;
}
-void ReplaceVars(XSTATUSCHANGE *xsc , TCHAR *Template, TCHAR *delimiter, TCHAR *buff)
+TCHAR *ReplaceVars(XSTATUSCHANGE *xsc, const TCHAR *tmplt)
{
- buff[0] = 0;
- TCHAR *pch = _tcschr(Template, _T('%'));
- while (pch != NULL) {
- size_t len = _tcslen(buff);
- _tcsncat(buff, Template, pch - Template);
- buff[len + pch - Template] = 0;
-
- if (pch[1] == _T('N') || pch[1] == _T('T') || pch[1] == _T('I') || pch[1] == _T('D') || pch[1] == _T('B')) {
- switch (pch[1]) {
- case _T('N'):
+ TCHAR tmp[1024];
+
+ if (tmplt == NULL || tmplt[0] == _T('\0'))
+ return NULL;
+
+ TCHAR *str = (TCHAR *)mir_alloc(2048 * sizeof(TCHAR));
+ str[0] = _T('\0');
+ int len = lstrlen(tmplt);
+
+ for (int i = 0; i < len; i++) {
+ tmp[0] = _T('\0');
+
+ if (tmplt[i] == _T('%')) {
+ i++;
+ switch (tmplt[i]) {
+ case 'n':
{
TCHAR stzType[32];
- _tcscat(buff, GetStatusTypeAsString(xsc->type, stzType));
+ lstrcpyn(tmp, GetStatusTypeAsString(xsc->type, stzType), SIZEOF(tmp));
}
break;
- case _T('T'):
- if (xsc->stzTitle)
- _tcscat(buff, xsc->stzTitle);
- break;
- case _T('I'):
- if (xsc->stzText)
- _tcscat(buff, xsc->stzText);
+
+ case 't':
+ if (xsc->stzTitle == NULL || xsc->stzTitle[0] == _T('\0'))
+ lstrcpyn(tmp, TranslateT("<no title>"), SIZEOF(tmp));
+ else
+ lstrcpyn(tmp, xsc->stzTitle, SIZEOF(tmp));
break;
- case _T('D'):
- if (xsc->stzText) {
- if (_tcscmp(delimiter, _T("%B")) == 0)
- _tcscat(buff, _T("\r\n"));
- else
- _tcscat(buff, delimiter);
+
+ case 'm':
+ if (xsc->stzText == NULL || xsc->stzText[0] == _T('\0'))
+ lstrcpyn(tmp, TranslateT("<no status message>"), SIZEOF(tmp));
+ else {
+ TCHAR *_tmp = AddCR(xsc->stzText);
+ lstrcpyn(tmp, _tmp, SIZEOF(tmp));
+ mir_free(_tmp);
}
break;
- case _T('B'):
- _tcscat(buff, _T("\r\n"));
+
+ case 'c':
+ if (xsc->hContact == NULL)
+ lstrcpyn(tmp, TranslateT("Contact"), SIZEOF(tmp));
+ else
+ lstrcpyn(tmp, (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GCDNF_TCHAR), SIZEOF(tmp));
break;
- }
- Template = pch + 2;
+ default:
+ i--;
+ tmp[0] = tmplt[i], tmp[1] = _T('\0');
+ break;
+ }
}
- else {
- _tcscat(buff, _T("%"));
- Template = pch + 1;
+ else if (tmplt[i] == _T('\\')) {
+ i++;
+ switch (tmplt[i]) {
+ case 'n':
+ tmp[0] = _T('\r'), tmp[1] = _T('\n'), tmp[2] = _T('\0');
+ break;
+ case 't':
+ tmp[0] = _T('\t'), tmp[1] = _T('\0');
+ break;
+ default:
+ i--;
+ tmp[0] = tmplt[i], tmp[1] = _T('\0');
+ break;
+ }
+ }
+ else
+ tmp[0] = tmplt[i], tmp[1] = _T('\0');
+
+ if (tmp[0] != _T('\0')) {
+ if (lstrlen(tmp) + lstrlen(str) < 2044)
+ lstrcat(str, tmp);
+ else {
+ lstrcat(str, _T("..."));
+ break;
+ }
}
-
- pch = _tcschr(Template, _T('%'));
}
- // append rest of the text
- if (Template != NULL)
- _tcscat(buff, Template);
+ return str;
}
-void ShowPopup(XSTATUSCHANGE *xsc)
+void ShowXStatusPopup(XSTATUSCHANGE *xsc)
{
- DBVARIANT dbv;
- char szSetting[64];
+ HICON hIcon = NULL;
- POPUPDATAT ppd = {0};
- ppd.lchContact = xsc->hContact;
-
- switch(xsc->type) {
+ switch (xsc->type) {
case TYPE_JABBER_MOOD:
case TYPE_JABBER_ACTIVITY:
- mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", xsc->szProto, (xsc->type == TYPE_JABBER_MOOD) ? "mood" : "activity", "icon");
- if (!db_get_s(xsc->hContact, "AdvStatus", szSetting, &dbv)) {
- ppd.lchIcon = Skin_GetIcon(dbv.pszVal);
- db_free(&dbv);
+ {
+ DBVARIANT dbv;
+ char szSetting[64];
+ mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", xsc->szProto, (xsc->type == TYPE_JABBER_MOOD) ? "mood" : "activity", "icon");
+ if (!db_get_s(xsc->hContact, "AdvStatus", szSetting, &dbv)) {
+ hIcon = Skin_GetIcon(dbv.pszVal);
+ db_free(&dbv);
+ }
+ break;
}
- break;
-
case TYPE_ICQ_XSTATUS:
{
int statusId = db_get_b(xsc->hContact, xsc->szProto, "XStatusId", 0);
- ppd.lchIcon = (HICON)CallProtoService(xsc->szProto, PS_GETCUSTOMSTATUSICON, statusId, LR_SHARED);
+ hIcon = (HICON)CallProtoService(xsc->szProto, PS_GETCUSTOMSTATUSICON, statusId, LR_SHARED);
}
}
- if (ppd.lchIcon == NULL)
- ppd.lchIcon = LoadSkinnedProtoIcon(xsc->szProto, db_get_w(xsc->hContact, xsc->szProto, "Status", ID_STATUS_ONLINE));
-
- switch (opt.Colors) {
- case POPUP_COLOR_OWN:
- ppd.colorBack = db_get_dw(0, MODULE, "40081bg", COLOR_BG_AVAILDEFAULT);
- ppd.colorText = db_get_dw(0, MODULE, "40081tx", COLOR_TX_DEFAULT);
- break;
- case POPUP_COLOR_WINDOWS:
- ppd.colorBack = GetSysColor(COLOR_BTNFACE);
- ppd.colorText = GetSysColor(COLOR_WINDOWTEXT);
- break;
- case POPUP_COLOR_POPUP:
- ppd.colorBack = ppd.colorText = 0;
- break;
- }
-
- 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);
- db_free(&dbv);
- }
- }
-
- if (ptszGroup)
- mir_sntprintf(ppd.lptzContactName, MAX_CONTACTNAME,_T("%s (%s)"), ptszNick, ptszGroup);
- else
- _tcsncpy(ppd.lptzContactName, ptszNick, MAX_CONTACTNAME);
+ if (hIcon == NULL)
+ hIcon = LoadSkinnedProtoIcon(xsc->szProto, db_get_w(xsc->hContact, xsc->szProto, "Status", ID_STATUS_ONLINE));
// cut message if needed
- if (opt.PTruncateMsg && (opt.PMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.PMsgLen)) {
+ TCHAR *copyText = NULL;
+ if (opt.PXMsgTruncate && (opt.PXMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.PXMsgLen)) {
TCHAR buff[MAX_TEXT_LEN + 3];
- _tcsncpy(buff, xsc->stzText, opt.PMsgLen);
- buff[opt.PMsgLen] = 0;
+ copyText = mir_tstrdup(xsc->stzText);
+ _tcsncpy(buff, xsc->stzText, opt.PXMsgLen);
+ buff[opt.PXMsgLen] = 0;
_tcscat(buff, _T("..."));
mir_free(xsc->stzText);
xsc->stzText = mir_tstrdup(buff);
@@ -191,66 +220,102 @@ void ShowPopup(XSTATUSCHANGE *xsc)
TCHAR *Template = _T("");
switch (xsc->action) {
case NOTIFY_NEW_XSTATUS:
- Template = templates.PopupNewXstatus; break;
+ Template = templates.PopupXstatusChanged; break;
case NOTIFY_NEW_MESSAGE:
- Template = templates.PopupNewMsg; break;
- case NOTIFY_REMOVE:
- Template = templates.PopupRemove; break;
- case NOTIFY_OPENING_ML:
- Template = templates.LogOpening; break;
+ Template = templates.PopupXMsgChanged; break;
+ case NOTIFY_REMOVE_XSTATUS:
+ Template = templates.PopupXstatusRemoved; break;
+ case NOTIFY_REMOVE_MESSAGE:
+ Template = templates.PopupXMsgRemoved; break;
+ }
+
+ TCHAR *stzPopupText = ReplaceVars(xsc, Template);
+
+ ShowChangePopup(xsc->hContact, xsc->szProto, hIcon, ID_STATUS_EXTRASTATUS, stzPopupText);
+ mir_free(stzPopupText);
+
+ if (copyText) {
+ mir_free(xsc->stzText);
+ xsc->stzText = mir_tstrdup(copyText);
+ mir_free(copyText);
+ }
+}
+
+void BlinkXStatusIcon(XSTATUSCHANGE *xsc)
+{
+ HICON hIcon = NULL;
+ TCHAR str[256] = {0};
+ TCHAR stzType[32];
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s changed %s"),
+ CallService(MS_CLIST_GETCONTACTDISPLAYNAME, xsc->hContact, GCDNF_TCHAR), GetStatusTypeAsString(xsc->type, stzType));
+
+ if (opt.BlinkIcon_Status) {
+ DBVARIANT dbv;
+ char szSetting[64];
+
+ switch (xsc->type) {
+ case TYPE_JABBER_MOOD:
+ case TYPE_JABBER_ACTIVITY:
+ mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", xsc->szProto, (xsc->type == TYPE_JABBER_MOOD) ? "mood" : "activity", "icon");
+ if (!db_get_s(xsc->hContact, "AdvStatus", szSetting, &dbv)) {
+ hIcon = Skin_GetIcon(dbv.pszVal);
+ db_free(&dbv);
+ }
+ break;
+ case TYPE_ICQ_XSTATUS:
+ {
+ int statusId = db_get_b(xsc->hContact, xsc->szProto, "XStatusId", 0);
+ hIcon = (HICON)CallProtoService(xsc->szProto, PS_GETCUSTOMSTATUSICON, statusId, LR_SHARED);
+ }
+ }
}
- 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;
+ if (hIcon == NULL)
+ hIcon = LoadSkinnedIcon(SKINICON_OTHER_USERONLINE);
- ppd.PluginWindowProc = PopupDlgProc;
- ppd.iSeconds = opt.PopupTimeout;
- PUAddPopupT(&ppd);
+ BlinkIcon(xsc->hContact, xsc->szProto, hIcon, str);
+ mir_free(str);
}
-void PlayXStatusSound(int action)
+void PlayXStatusSound(MCONTACT hContact, int action)
{
switch (action) {
case NOTIFY_NEW_XSTATUS:
- SkinPlaySound(XSTATUS_SOUND_CHANGED); break;
+ PlayChangeSound(hContact, XSTATUS_SOUND_CHANGED); break;
+ case NOTIFY_REMOVE_XSTATUS:
+ PlayChangeSound(hContact, XSTATUS_SOUND_REMOVED); break;
case NOTIFY_NEW_MESSAGE:
- SkinPlaySound(XSTATUS_SOUND_MSGCHANGED); break;
- case NOTIFY_REMOVE:
- SkinPlaySound(XSTATUS_SOUND_REMOVED); break;
+ PlayChangeSound(hContact, XSTATUS_SOUND_MSGCHANGED); break;
+ case NOTIFY_REMOVE_MESSAGE:
+ PlayChangeSound(hContact, XSTATUS_SOUND_MSGREMOVED); break;
}
}
-void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening)
+void LogChangeToDB(XSTATUSCHANGE *xsc)
{
- // cut message if needed
- if (opt.LTruncateMsg && (opt.LMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.LMsgLen)) {
- TCHAR buff[MAX_TEXT_LEN + 3];
- _tcsncpy(buff, xsc->stzText, opt.LMsgLen);
- buff[opt.LMsgLen] = 0;
- _tcscat(buff, _T("..."));
- mir_free(xsc->stzText);
- xsc->stzText = mir_tstrdup(buff);
- }
+ if (opt.XLogToDB_WinOpen && (CheckMsgWnd(xsc->hContact) == false))
+ return;
TCHAR *Template = _T("");
switch (xsc->action) {
case NOTIFY_NEW_XSTATUS:
- Template = templates.LogNewXstatus; break;
+ Template = templates.LogXstatusChanged; break;
+ case NOTIFY_REMOVE_XSTATUS:
+ Template = templates.LogXstatusRemoved; break;
case NOTIFY_NEW_MESSAGE:
- Template = templates.LogNewMsg; break;
- case NOTIFY_REMOVE:
- Template = templates.LogRemove; break;
+ Template = templates.LogXMsgChanged; break;
+ case NOTIFY_REMOVE_MESSAGE:
+ Template = templates.LogXMsgRemoved; break;
case NOTIFY_OPENING_ML:
- Template = templates.LogOpening; break;
+ Template = templates.LogXstatusOpening; break;
}
- TCHAR stzLogText[2*MAX_TEXT_LEN], stzLastLog[2*MAX_TEXT_LEN];
- ReplaceVars(xsc, Template, templates.LogDelimiter, stzLogText);
+ TCHAR *stzLogText, stzLastLog[2 * MAX_TEXT_LEN];
+ stzLogText = ReplaceVars(xsc, Template);
DBGetStringDefault(xsc->hContact, MODULE, DB_LASTLOG, stzLastLog, SIZEOF(stzLastLog), _T(""));
- if (!opt.KeepInHistory || !(opt.PreventIdentical && _tcscmp(stzLastLog, stzLogText) == 0)) {
+// if (!opt.KeepInHistory || !(opt.PreventIdentical && _tcscmp(stzLastLog, stzLogText) == 0)) {
+ if (opt.XLogToDB/* || !(opt.PreventIdentical && _tcscmp(stzLastLog, stzLogText) == 0)*/) {
db_set_ws(xsc->hContact, MODULE, DB_LASTLOG, stzLogText);
char *blob = mir_utf8encodeT(stzLogText);
@@ -258,7 +323,7 @@ void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening)
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
dbei.cbBlob = (DWORD)strlen(blob) + 1;
- dbei.pBlob = (PBYTE) blob;
+ dbei.pBlob = (PBYTE)blob;
dbei.eventType = EVENTTYPE_STATUSCHANGE;
dbei.flags = DBEF_READ | DBEF_UTF;
@@ -267,32 +332,43 @@ void LogToMessageWindow(XSTATUSCHANGE *xsc, BOOL opening)
HANDLE hDBEvent = db_event_add(xsc->hContact, &dbei);
mir_free(blob);
- if (!opt.KeepInHistory) {
+ if (opt.XLogToDB_WinOpen && opt.XLogToDB_Remove) {
DBEVENT *dbevent = (DBEVENT *)mir_alloc(sizeof(DBEVENT));
dbevent->hContact = xsc->hContact;
dbevent->hDBEvent = hDBEvent;
- eventList.insert(dbevent);
+ eventListXStatus.insert(dbevent);
}
}
+ mir_free(stzLogText);
}
void LogChangeToFile(XSTATUSCHANGE *xsc)
{
- TCHAR stzType[32], stzDate[32], stzTime[32], stzText[MAX_TEXT_LEN];
-
- GetStatusTypeAsString(xsc->type, stzType);
-
- INT_PTR stzName = CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GCDNF_TCHAR);
+ TCHAR stzDate[32], stzTime[32], stzText[MAX_TEXT_LEN];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL,_T("HH':'mm"), stzTime, SIZEOF(stzTime));
GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL,_T("dd/MM/yyyy"), stzDate, SIZEOF(stzDate));
- if (xsc->action == NOTIFY_REMOVE)
- mir_sntprintf(stzText, SIZEOF(stzText), TranslateT("%s, %s. %s removed %s.\r\n"), stzDate, stzTime, stzName, stzType);
- else
- mir_sntprintf(stzText, SIZEOF(stzText), TranslateT("%s, %s. %s changed %s to: %s.\r\n"), stzDate, stzTime, stzName, stzType, xsc->stzTitle);
+ TCHAR *Template = _T("");
+ switch (xsc->action) {
+ case NOTIFY_NEW_XSTATUS:
+ Template = templates.LogXstatusChanged; break;
+ case NOTIFY_REMOVE_XSTATUS:
+ Template = templates.LogXstatusRemoved; break;
+ case NOTIFY_NEW_MESSAGE:
+ Template = templates.LogXMsgChanged; break;
+ case NOTIFY_REMOVE_MESSAGE:
+ Template = templates.LogXMsgRemoved; break;
+ }
+
+ TCHAR *stzLogText;
+ stzLogText = ReplaceVars(xsc, Template);
+
+ mir_sntprintf(stzText, SIZEOF(stzText), TranslateT("%s, %s. %s %s\r\n"), stzDate, stzTime,
+ CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GCDNF_TCHAR), stzLogText);
LogToFile(stzText);
+ mir_free(stzLogText);
}
void ExtraStatusChanged(XSTATUSCHANGE *xsc)
@@ -300,53 +376,62 @@ void ExtraStatusChanged(XSTATUSCHANGE *xsc)
if (xsc == NULL)
return;
- BOOL bEnablePopup = true, bEnableSound = true;
- char buff[12] = {0};
+ BOOL bEnablePopup = true, bEnableSound = true, bEnableLog = opt.XLogToDB;
+ char buff[12] = {0};
mir_snprintf(buff, SIZEOF(buff), "%d", ID_STATUS_EXTRASTATUS);
-
- if (( db_get_b(0, MODULE, buff, 1) == 0)
+ if ((db_get_b(0, MODULE, buff, 1) == 0)
|| (db_get_w(xsc->hContact, xsc->szProto, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
- || (!opt.HiddenContactsToo && db_get_b(xsc->hContact, "CList", "Hidden", 0))
- || (opt.TempDisabled)
- || (opt.IgnoreEmpty && (xsc->stzTitle == NULL || xsc->stzTitle[0] == '\0') && (xsc->stzText == NULL || xsc->stzText[0] == '\0'))) {
- FreeXSC(xsc);
- return;
+ || (!opt.HiddenContactsToo && (db_get_b(xsc->hContact, "CList", "Hidden", 0) == 1))
+ || (CallProtoService(xsc->szProto, PS_GETSTATUS, 0, 0) == ID_STATUS_OFFLINE))
+ {
+ FreeXSC(xsc);
+ return;
}
- char statusIDs[12], statusIDp[12];
+ // check per-contact ignored events
+ if (db_get_b(xsc->hContact, MODULE, "EnableXStatusNotify", 1) == 0)
+ bEnableSound = bEnablePopup = false;
+
+ // check if our status isn't on autodisable list
if (opt.AutoDisable) {
+ char statusIDs[12], statusIDp[12];
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;
- bEnablePopup = db_get_b(0, MODULE, statusIDp, 1) ? FALSE : TRUE;
+ bEnableSound = db_get_b(0, MODULE, statusIDs, 1) ? FALSE : bEnableSound;
+ bEnablePopup = db_get_b(0, MODULE, statusIDp, 1) ? FALSE : bEnablePopup;
}
- if (!(templates.PopupFlags & xsc->action))
- bEnableSound = bEnablePopup = false;
+ if (!(templates.PopupXFlags & xsc->action))
+ bEnablePopup = false;
+
+ if (db_get_b(0, MODULE, xsc->szProto, 1) == 0 && !opt.PXOnConnect)
+ bEnablePopup = false;
int xstatusID = db_get_b(xsc->hContact, xsc->szProto, "XStatusId", 0);
- if (opt.PDisableForMusic && xsc->type == TYPE_ICQ_XSTATUS && xstatusID == XSTATUS_MUSIC)
+ if (opt.PXDisableForMusic && xsc->type == TYPE_ICQ_XSTATUS && xstatusID == XSTATUS_MUSIC)
bEnableSound = bEnablePopup = false;
- if (bEnablePopup && db_get_b(xsc->hContact, MODULE, "EnableXStatusNotify", 1) && db_get_b(0, MODULE, xsc->szProto, 1))
- ShowPopup(xsc);
+ if (bEnablePopup && db_get_b(xsc->hContact, MODULE, "EnablePopups", 1) && !opt.TempDisabled)
+ ShowXStatusPopup(xsc);
+
+ if (bEnableSound && db_get_b(0, "Skin", "UseSound", 1) && db_get_b(xsc->hContact, MODULE, "EnableSounds", 1) && !opt.TempDisabled)
+ PlayXStatusSound(xsc->hContact, xsc->action);
- if (bEnableSound && db_get_b(xsc->hContact, MODULE, "EnableXStatusNotify", 1))
- PlayXStatusSound(xsc->action);
+ if (opt.BlinkIcon && opt.BlinkIcon_ForMsgs && !opt.TempDisabled)
+ BlinkXStatusIcon(xsc);
- BYTE enableLog = opt.EnableLogging;
- if (opt.LDisableForMusic && xsc->type == TYPE_ICQ_XSTATUS && xstatusID == XSTATUS_MUSIC)
- enableLog = FALSE;
+ if (opt.XLogDisableForMusic && xsc->type == TYPE_ICQ_XSTATUS && xstatusID == XSTATUS_MUSIC)
+ bEnableLog = false;
- if (!(templates.LogFlags & xsc->action))
- enableLog = FALSE;
+ if (!(templates.LogXFlags & xsc->action))
+ bEnableLog = false;
- if (enableLog && db_get_b(xsc->hContact, MODULE, "EnableLogging", 1) && CheckMsgWnd(xsc->hContact))
- LogToMessageWindow(xsc, FALSE);
+ if (bEnableLog && db_get_b(xsc->hContact, MODULE, "EnableXLogging", 1))
+ LogChangeToDB(xsc);
- if (opt.Log)
+ if (opt.XLogToFile && db_get_b(xsc->hContact, MODULE, "EnableXLogging", 1))
LogChangeToFile(xsc);
FreeXSC(xsc);
@@ -398,7 +483,7 @@ TCHAR *GetJabberAdvStatusText(MCONTACT hContact, char *szProto, char *szSlot, ch
buff[0] = 0;
mir_snprintf(szSetting, SIZEOF(szSetting), "%s/%s/%s", szProto, szSlot, szValue);
- if ( !db_get_ts(hContact, "AdvStatus", szSetting, &dbv)) {
+ if (!db_get_ts(hContact, "AdvStatus", szSetting, &dbv)) {
_tcsncpy(buff, dbv.ptszVal, bufflen);
buff[bufflen - 1] = 0;
db_free(&dbv);
@@ -409,21 +494,13 @@ TCHAR *GetJabberAdvStatusText(MCONTACT hContact, char *szProto, char *szSlot, ch
void LogXstatusChange(MCONTACT hContact, char *szProto, int xstatusType, TCHAR *stzTitle, TCHAR *stzText)
{
- XSTATUSCHANGE *xsc =
- NewXSC(
- hContact,
- szProto,
- xstatusType,
- NOTIFY_OPENING_ML,
- stzTitle[0] ? mir_tstrdup(stzTitle): NULL,
- stzText[0] ? mir_tstrdup(stzText) : NULL
- );
-
- LogToMessageWindow(xsc, TRUE);
+ XSTATUSCHANGE *xsc = NewXSC(hContact, szProto, xstatusType, NOTIFY_OPENING_ML, stzTitle[0] ? mir_tstrdup(stzTitle) : NULL, stzText[0] ? mir_tstrdup(stzText) : NULL);
+
+ LogChangeToDB(xsc);
FreeXSC(xsc);
}
-void AddEventThread(void *arg)
+void AddXStatusEventThread(void *arg)
{
MCONTACT hContact = (MCONTACT)arg;
TCHAR stzTitle[MAX_TITLE_LEN], stzText[MAX_TEXT_LEN];
@@ -454,22 +531,57 @@ void AddEventThread(void *arg)
}
}
+void AddSMsgEventThread(void *arg)
+{
+ MCONTACT hContact = (MCONTACT)arg;
+ STATUSMSGINFO smi;
+
+ smi.hContact = hContact;
+ smi.proto = GetContactProto(hContact);
+ if (smi.proto == NULL)
+ return;
+
+ DBVARIANT dbv;
+ if (!db_get_s(smi.hContact, "CList", "StatusMsg", &dbv, 0)) {
+ switch (dbv.type) {
+ case DBVT_ASCIIZ:
+ smi.newstatusmsg = mir_dupToUnicodeEx(dbv.pszVal, CP_ACP);
+ break;
+ case DBVT_UTF8:
+ smi.newstatusmsg = mir_dupToUnicodeEx(dbv.pszVal, CP_UTF8);
+ break;
+ case DBVT_WCHAR:
+ smi.newstatusmsg = mir_wstrdup(dbv.pwszVal);
+ break;
+ default:
+ smi.newstatusmsg = NULL;
+ break;
+ }
+ db_free(&dbv);
+ }
+
+ LogSMsgToDB(&smi, templates.LogSMsgOpening);
+ mir_free(smi.newstatusmsg);
+}
+
int OnWindowEvent(WPARAM wParam, LPARAM lParam)
{
MessageWindowEventData *mwed = (MessageWindowEventData *)lParam;
- if (mwed->uType == MSG_WINDOW_EVT_CLOSE && !opt.KeepInHistory) {
- RemoveLoggedEvents(mwed->hContact);
- return 0;
- }
+ if ((mwed->uType == MSG_WINDOW_EVT_CLOSE) && opt.XLogToDB && opt.XLogToDB_WinOpen && opt.XLogToDB_Remove)
+ RemoveLoggedEventsXStatus(mwed->hContact);
- if (opt.EnableLogging &&
- (mwed->uType == MSG_WINDOW_EVT_OPEN) &&
- (templates.LogFlags & NOTIFY_OPENING_ML) &&
- (db_get_b(mwed->hContact, MODULE, "EnableLogging", 1) == 1))
- {
- mir_forkthread(AddEventThread, (void*)mwed->hContact);
- }
+ if ((mwed->uType == MSG_WINDOW_EVT_CLOSE) && opt.LogToDB && opt.LogToDB_WinOpen && opt.LogToDB_Remove)
+ RemoveLoggedEventsStatus(mwed->hContact);
+
+ if ((mwed->uType == MSG_WINDOW_EVT_CLOSE) && opt.SMsgLogToDB && opt.SMsgLogToDB_WinOpen && opt.SMsgLogToDB_Remove)
+ RemoveLoggedEventsSMsg(mwed->hContact);
+
+ if ((mwed->uType == MSG_WINDOW_EVT_OPEN) && opt.XLogToDB && (templates.LogXFlags & NOTIFY_OPENING_ML) && db_get_b(mwed->hContact, MODULE, "EnableXLogging", 1))
+ mir_forkthread(AddXStatusEventThread, (void *)mwed->hContact);
+
+ if ((mwed->uType == MSG_WINDOW_EVT_OPEN) && opt.SMsgLogToDB && (templates.LogSMsgFlags & NOTIFY_OPENING_ML) && db_get_b(mwed->hContact, MODULE, "EnableSMsgLogging", 1))
+ mir_forkthread(AddSMsgEventThread, (void *)mwed->hContact);
return 0;
}