summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/globals.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-27 18:53:10 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-27 18:53:10 +0000
commitb1dc0111247ffd219585458edcf24c07c0b55ddf (patch)
tree46e530f5cadd764a55f25611fb403fc6e2d0beb0 /plugins/TabSRMM/src/globals.cpp
parent1343831cad692ce0244644f708b023f7962246b4 (diff)
status changes are not added to a database anymore, only printed in the message log
git-svn-id: http://svn.miranda-ng.org/main/trunk@7395 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/globals.cpp')
-rw-r--r--plugins/TabSRMM/src/globals.cpp77
1 files changed, 34 insertions, 43 deletions
diff --git a/plugins/TabSRMM/src/globals.cpp b/plugins/TabSRMM/src/globals.cpp
index 58c58f38e7..eccaaa9847 100644
--- a/plugins/TabSRMM/src/globals.cpp
+++ b/plugins/TabSRMM/src/globals.cpp
@@ -624,55 +624,46 @@ void CGlobals::RestoreUnreadMessageAlerts(void)
void CGlobals::logStatusChange(WPARAM wParam, const CContactCache *c)
{
- if (c == 0)
+ if (c == 0 || !c->isValid())
return;
- HANDLE hContact = c->getContact();
-
- bool fGlobal = PluginConfig.m_LogStatusChanges ? true : false;
- DWORD dwMask = db_get_dw(hContact, SRMSGMOD_T, "mwmask", 0);
- DWORD dwFlags = db_get_dw(hContact, SRMSGMOD_T, "mwflags", 0);
-
- BYTE fLocal = M.GetByte(hContact, "logstatuschanges", 0);
-
- if (fGlobal || fLocal) {
- /*
- * don't log them if WE are logging off
- */
- if (CallProtoService(c->getProto(), PS_GETSTATUS, 0, 0) == ID_STATUS_OFFLINE)
- return;
-
- WORD wStatus = LOWORD(wParam);
- WORD wOldStatus = HIWORD(wParam);
- if (wStatus == wOldStatus)
- return;
+ HANDLE hContact = c->getContact();
+ if (!PluginConfig.m_LogStatusChanges && !M.GetByte(hContact, "logstatuschanges", 0))
+ return;
- TCHAR buffer[450];
+ /*
+ * don't log them if WE are logging off
+ */
+ if (CallProtoService(c->getProto(), PS_GETSTATUS, 0, 0) == ID_STATUS_OFFLINE)
+ return;
- TCHAR *szOldStatus = pcli->pfnGetStatusModeDescription(wOldStatus, 0);
- TCHAR *szNewStatus = pcli->pfnGetStatusModeDescription(wStatus, 0);
- if (szOldStatus == 0 || szNewStatus == 0)
- return;
+ WORD wStatus = LOWORD(wParam);
+ WORD wOldStatus = HIWORD(wParam);
+ if (wStatus == wOldStatus)
+ return;
- if (c->isValid()) {
- if (wStatus == ID_STATUS_OFFLINE)
- mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("signed off."));
- else if (wOldStatus == ID_STATUS_OFFLINE)
- mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("signed on and is now %s."), szNewStatus);
- else
- mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("changed status from %s to %s."), szOldStatus, szNewStatus);
- }
+ TCHAR *szOldStatus = pcli->pfnGetStatusModeDescription(wOldStatus, 0);
+ TCHAR *szNewStatus = pcli->pfnGetStatusModeDescription(wStatus, 0);
+ if (szOldStatus == 0 || szNewStatus == 0)
+ return;
- ptrA szMsg( mir_utf8encodeT(buffer));
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.pBlob = (PBYTE)(char*)szMsg;
- dbei.cbBlob = lstrlenA(szMsg) + 1;
- dbei.flags = DBEF_UTF | DBEF_READ;
- dbei.eventType = EVENTTYPE_STATUSCHANGE;
- dbei.timestamp = time(NULL);
- dbei.szModule = const_cast<char *>(c->getProto());
- db_event_add(hContact, &dbei);
- }
+ CMString text;
+ if (wStatus == ID_STATUS_OFFLINE)
+ text = TranslateT("signed off.");
+ else if (wOldStatus == ID_STATUS_OFFLINE)
+ text.Format(TranslateT("signed on and is now %s."), szNewStatus);
+ else
+ text.Format(TranslateT("changed status from %s to %s."), szOldStatus, szNewStatus);
+
+ ptrA szMsg(mir_utf8encodeT(text));
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.pBlob = (PBYTE)(char*)szMsg;
+ dbei.cbBlob = lstrlenA(szMsg) + 1;
+ dbei.flags = DBEF_UTF | DBEF_READ;
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.timestamp = time(NULL);
+ dbei.szModule = const_cast<char *>(c->getProto());
+ StreamInEvents(c->getDat()->hwnd, NULL, 1, 1, &dbei);
}
/**