summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-10-15 19:53:52 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-10-15 19:53:52 +0300
commitbb8e49d3e4a63cceaa9a68ef62229d87c1792535 (patch)
tree8d78a50f3a84ec7ebff5b16086c2ea1175998b42
parentf9b6402b4ea11142d078f1446bd3ca487b5df172 (diff)
fixes #3738 (CrashDumper: ошибочный показ активного журнала)
-rw-r--r--include/m_srmm_int.h20
-rw-r--r--libs/win32/mir_app.libbin271936 -> 272382 bytes
-rw-r--r--libs/win64/mir_app.libbin271108 -> 271564 bytes
-rw-r--r--plugins/CrashDumper/src/dumper.cpp6
-rw-r--r--plugins/CrashDumper/src/stdafx.h1
-rw-r--r--src/mir_app/src/chat.h2
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/srmm_base.cpp13
-rw-r--r--src/mir_app/src/srmm_log.cpp38
10 files changed, 48 insertions, 34 deletions
diff --git a/include/m_srmm_int.h b/include/m_srmm_int.h
index 5e11a4b95a..4be18ba906 100644
--- a/include/m_srmm_int.h
+++ b/include/m_srmm_int.h
@@ -154,6 +154,26 @@ MIR_APP_DLL(void) UnregisterSrmmLog(HANDLE);
MIR_APP_DLL(bool) Srmm_IsCustomLogUsed();
/////////////////////////////////////////////////////////////////////////////////////////
+// SRMM log window class
+
+struct SrmmLogWindowClass
+{
+ SrmmLogWindowClass(CMPlugin *p1, const char *p2, const wchar_t *p3, pfnSrmmLogCreator p4) :
+ pPlugin(p1),
+ szShortName(mir_strdup(p2)),
+ wszScreenName(mir_wstrdup(p3)),
+ pfnBuilder(p4)
+ {}
+
+ CMPlugin *pPlugin;
+ ptrA szShortName;
+ ptrW wszScreenName;
+ pfnSrmmLogCreator pfnBuilder;
+};
+
+MIR_APP_DLL(SrmmLogWindowClass *) Srmm_GetWindowClass(CMsgDialog *pDlg);
+
+/////////////////////////////////////////////////////////////////////////////////////////
// Simple single-event based logger
class MIR_APP_EXPORT CSimpleLogWindow : public CSrmmLogWindow
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index b5d4a97c1e..d625caaa61 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index ed1f24f383..66a8412127 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/CrashDumper/src/dumper.cpp b/plugins/CrashDumper/src/dumper.cpp
index a7797da086..86bf2ebf47 100644
--- a/plugins/CrashDumper/src/dumper.cpp
+++ b/plugins/CrashDumper/src/dumper.cpp
@@ -142,8 +142,10 @@ static void GetPluginsString(CMStringW &buffer, unsigned &flags)
{
buffer.AppendFormat(L"Service Mode: %s\r\n", g_plugin.bServiceMode ? L"Yes" : L"No");
- CMStringW szViewerName(db_get_wsm(0, "SRMM", "Logger", L"built-in"));
- buffer.AppendFormat(L"SRMM Log Viewer: %s\r\n", szViewerName.c_str());
+ if (auto *pLogClass = Srmm_GetWindowClass(0))
+ buffer.AppendFormat(L"SRMM Log Viewer: %s\r\n", _A2T(pLogClass->szShortName).get());
+ else
+ buffer.AppendFormat(L"SRMM Log Viewer: %s\r\n", L"missing");
wchar_t path[MAX_PATH];
GetModuleFileName(nullptr, path, MAX_PATH);
diff --git a/plugins/CrashDumper/src/stdafx.h b/plugins/CrashDumper/src/stdafx.h
index dfe9421cb0..72c153afed 100644
--- a/plugins/CrashDumper/src/stdafx.h
+++ b/plugins/CrashDumper/src/stdafx.h
@@ -37,6 +37,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <m_popup.h>
#include <m_netlib.h>
#include <m_db_int.h>
+#include <m_srmm_int.h>
#include <m_gui.h>
#include "m_folders.h"
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h
index 6ba50be865..3f4fcc8dda 100644
--- a/src/mir_app/src/chat.h
+++ b/src/mir_app/src/chat.h
@@ -129,8 +129,6 @@ BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce);
BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce);
int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, wchar_t* pszRoomName, COLORREF crBkg, const wchar_t* fmt, ...);
-CSrmmLogWindow *Srmm_GetLogWindow(CMsgDialog *pDlg);
-
void Chat_EventToGC(SESSION_INFO *si, MEVENT hDbEvent);
void Chat_RemoveContact(MCONTACT hContact);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 8359cb841b..fb83d97f00 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -907,3 +907,4 @@ Clist_GroupSaveExpanded @1003 NONAME
?GetInput@CSrmmBaseDialog@@QBEPAUHWND__@@XZ @1024 NONAME
?Srmm_ApplyOptions@@YGXXZ @1025 NONAME
?OnOptionsApplied@CSrmmBaseDialog@@UAEXXZ @1026 NONAME
+?Srmm_GetWindowClass@@YGPAUSrmmLogWindowClass@@PAVCMsgDialog@@@Z @1027 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 7cedefa3d5..d977ff1183 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -907,3 +907,4 @@ Clist_GroupSaveExpanded @1003 NONAME
?GetInput@CSrmmBaseDialog@@QEBAPEAUHWND__@@XZ @1024 NONAME
?Srmm_ApplyOptions@@YAXXZ @1025 NONAME
?OnOptionsApplied@CSrmmBaseDialog@@UEAAXXZ @1026 NONAME
+?Srmm_GetWindowClass@@YAPEAUSrmmLogWindowClass@@PEAVCMsgDialog@@@Z @1027 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp
index 6176b753d1..d8572c2700 100644
--- a/src/mir_app/src/srmm_base.cpp
+++ b/src/mir_app/src/srmm_base.cpp
@@ -519,11 +519,14 @@ bool CSrmmBaseDialog::OnInitDialog()
WindowList_Add(g_hWindowList, m_hwnd, m_hContact);
SetWindowLongPtr(m_hwnd, GWLP_USERDATA, (LONG_PTR)this);
- m_pLog = Srmm_GetLogWindow((CMsgDialog*)this);
- m_pLog->Attach();
- if (m_pLog->GetType() != 0) { // custom log type
- DestroyWindow(GetDlgItem(m_hwnd, IDC_SRMM_LOG));
- SetWindowLong(m_pLog->GetHwnd(), GWLP_ID, IDC_SRMM_LOG);
+ auto *pDlg = (CMsgDialog *)this;
+ if (auto *pLogWindowClass = Srmm_GetWindowClass(pDlg)) {
+ m_pLog = pLogWindowClass->pfnBuilder(*pDlg);
+ m_pLog->Attach();
+ if (m_pLog->GetType() != 0) { // custom log type
+ DestroyWindow(GetDlgItem(m_hwnd, IDC_SRMM_LOG));
+ SetWindowLong(m_pLog->GetHwnd(), GWLP_ID, IDC_SRMM_LOG);
+ }
}
SetWindowLongPtr(m_message.GetHwnd(), GWLP_USERDATA, LPARAM(this));
diff --git a/src/mir_app/src/srmm_log.cpp b/src/mir_app/src/srmm_log.cpp
index b91204a59c..647304eb86 100644
--- a/src/mir_app/src/srmm_log.cpp
+++ b/src/mir_app/src/srmm_log.cpp
@@ -27,22 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "chat.h"
-struct LoggerClass
-{
- LoggerClass(CMPlugin *p1, const char *p2, const wchar_t *p3, pfnSrmmLogCreator p4) :
- pPlugin(p1),
- szShortName(mir_strdup(p2)),
- wszScreenName(mir_wstrdup(p3)),
- pfnBuilder(p4)
- {}
-
- CMPlugin *pPlugin;
- ptrA szShortName;
- ptrW wszScreenName;
- pfnSrmmLogCreator pfnBuilder;
-};
-
-static OBJLIST<LoggerClass> g_arLogClasses(1, PtrKeySortT);
+static OBJLIST<SrmmLogWindowClass> g_arLogClasses(1, PtrKeySortT);
static CMOption<char *> g_logger(SRMM_MODULE, "Logger", "built-in");
@@ -51,7 +36,7 @@ static CMOption<char *> g_logger(SRMM_MODULE, "Logger", "built-in");
static bool sttEnableCustomLogs(CMsgDialog *pDlg)
{
// always enable custom log viewers for private chats
- if (!pDlg->isChat())
+ if (!pDlg || !pDlg->isChat())
return true;
// if custom log viewers are disable, use build-in one
@@ -79,21 +64,23 @@ static bool sttEnableCustomLogs(CMsgDialog *pDlg)
return true;
}
-CSrmmLogWindow* Srmm_GetLogWindow(CMsgDialog *pDlg)
+MIR_APP_DLL(SrmmLogWindowClass *) Srmm_GetWindowClass(CMsgDialog *pDlg)
{
if (sttEnableCustomLogs(pDlg)) {
- CMStringA szViewerName(db_get_sm(pDlg->m_hContact, SRMSGMOD, "Logger"));
+ CMStringA szViewerName;
+ if (pDlg != nullptr)
+ szViewerName = db_get_sm(pDlg->m_hContact, SRMSGMOD, "Logger");
if (szViewerName.IsEmpty())
szViewerName = g_logger;
for (auto &it : g_arLogClasses)
if (szViewerName == it->szShortName)
- return it->pfnBuilder(*pDlg);
+ return it;
}
for (auto &it : g_arLogClasses)
if (!mir_strcmp(it->szShortName, "built-in"))
- return it->pfnBuilder(*pDlg);
+ return it;
return nullptr; // shall never happen
}
@@ -141,9 +128,10 @@ public:
{
pDialog = this;
+ auto *pClass = Srmm_GetWindowClass(0);
for (auto &it : g_arLogClasses) {
int idx = m_list.AddString(TranslateW_LP(it->wszScreenName, it->pPlugin), LPARAM(it));
- if (!mir_strcmp(g_logger, it->szShortName))
+ if (it == pClass)
m_list.SetCurSel(idx);
}
@@ -156,7 +144,7 @@ public:
if (idx == -1)
return false;
- if (auto *pLogger = (LoggerClass *)m_list.GetItemData(idx))
+ if (auto *pLogger = (SrmmLogWindowClass *)m_list.GetItemData(idx))
g_logger = pLogger->szShortName;
PostMessage(m_hwndParent, WM_CLOSE, 1, 0);
@@ -199,7 +187,7 @@ MIR_APP_DLL(HANDLE) RegisterSrmmLog(CMPlugin *pPlugin, const char *pszShortName,
if (!pszShortName || !pwszScreenName || !fnBuilder)
return nullptr;
- auto *p = new LoggerClass(pPlugin, pszShortName, pwszScreenName, fnBuilder);
+ auto *p = new SrmmLogWindowClass(pPlugin, pszShortName, pwszScreenName, fnBuilder);
g_arLogClasses.insert(p);
if (pDialog)
@@ -209,7 +197,7 @@ MIR_APP_DLL(HANDLE) RegisterSrmmLog(CMPlugin *pPlugin, const char *pszShortName,
MIR_APP_DLL(void) UnregisterSrmmLog(HANDLE pLogger)
{
- g_arLogClasses.remove((LoggerClass *)pLogger);
+ g_arLogClasses.remove((SrmmLogWindowClass *)pLogger);
if (pDialog)
pDialog->Rebuild();