From b1dc0111247ffd219585458edcf24c07c0b55ddf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 27 Dec 2013 18:53:10 +0000 Subject: 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 --- plugins/TabSRMM/src/commonheaders.h | 1 + plugins/TabSRMM/src/globals.cpp | 77 ++++++++++++++++--------------------- plugins/TabSRMM/src/msgdlgutils.cpp | 1 - plugins/TabSRMM/src/msglog.cpp | 3 +- plugins/TabSRMM/src/msgs.h | 1 - plugins/TabSRMM/src/templates.cpp | 3 +- plugins/TabSRMM/src/version.h | 2 +- 7 files changed, 38 insertions(+), 50 deletions(-) (limited to 'plugins/TabSRMM') diff --git a/plugins/TabSRMM/src/commonheaders.h b/plugins/TabSRMM/src/commonheaders.h index 3e44201cf7..c06881e15b 100644 --- a/plugins/TabSRMM/src/commonheaders.h +++ b/plugins/TabSRMM/src/commonheaders.h @@ -87,6 +87,7 @@ #include #include #include +#include #include #include 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(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(c->getProto()); + StreamInEvents(c->getDat()->hwnd, NULL, 1, 1, &dbei); } /** diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index feb3292d8c..0d50727f04 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -41,7 +41,6 @@ #define EVENTTYPE_JABBER_PRESENCE 2001 static int g_status_events[] = { - EVENTTYPE_STATUSCHANGE, EVENTTYPE_CONTACTLEFTCHANNEL, EVENTTYPE_WAT_ANSWER, EVENTTYPE_JABBER_CHATSTATES, diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index d851c6c87c..549351f151 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -976,11 +976,10 @@ static char *Template_CreateRTFFromDbEvent(TWindowData *dat, HANDLE hContact, HA break; case 'M': // message if (bIsStatusChangeEvent) - dbei.eventType = EVENTTYPE_STATUSCHANGE; + dbei.eventType = EVENTTYPE_MESSAGE; switch (dbei.eventType) { case EVENTTYPE_MESSAGE: case EVENTTYPE_ERRMSG: - case EVENTTYPE_STATUSCHANGE: if (bIsStatusChangeEvent || dbei.eventType == EVENTTYPE_ERRMSG) { if (dbei.eventType == EVENTTYPE_ERRMSG && dbei.cbBlob == 0) break; diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index bf2af3e24d..467083fbb6 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -770,7 +770,6 @@ extern const int msgDlgFontCount; #define IDM_CONTAINERMENU 50500 -#define EVENTTYPE_STATUSCHANGE 25368 #define EVENTTYPE_DIVIDER 25367 #define EVENTTYPE_ERRMSG 25366 diff --git a/plugins/TabSRMM/src/templates.cpp b/plugins/TabSRMM/src/templates.cpp index 6c2d2c3dcb..eb0764cd0d 100644 --- a/plugins/TabSRMM/src/templates.cpp +++ b/plugins/TabSRMM/src/templates.cpp @@ -352,8 +352,7 @@ INT_PTR CALLBACK DlgProcTemplateEditor(HWND hwndDlg, UINT msg, WPARAM wParam, LP } dbei.szModule = dat->szProto; dbei.timestamp = time(NULL); - dbei.eventType = (iIndex == 6) ? EVENTTYPE_STATUSCHANGE : EVENTTYPE_MESSAGE; - dbei.eventType = (iIndex == 7) ? EVENTTYPE_ERRMSG : dbei.eventType; + dbei.eventType = (iIndex == 7) ? EVENTTYPE_ERRMSG : EVENTTYPE_MESSAGE; if (dbei.eventType == EVENTTYPE_ERRMSG) dbei.szModule = "Sample error message"; dbei.cbSize = sizeof(dbei); diff --git a/plugins/TabSRMM/src/version.h b/plugins/TabSRMM/src/version.h index f95ae955ae..0a635936e8 100644 --- a/plugins/TabSRMM/src/version.h +++ b/plugins/TabSRMM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 3 #define __MINOR_VERSION 2 #define __RELEASE_NUM 0 -#define __BUILD_NUM 0 +#define __BUILD_NUM 1 #define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -- cgit v1.2.3