From c1cac0e54f6c6e906cacc4538c79930b7c85669b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 6 Jun 2025 15:36:02 +0300 Subject: MsgExport: reactions to be properly exported even in the text mode --- plugins/Msg_Export/src/utils.cpp | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'plugins/Msg_Export/src/utils.cpp') diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 8544154802..b56e401369 100644 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -554,3 +554,50 @@ int nExportEvent(WPARAM hContact, LPARAM hDbEvent) return 0; } + +///////////////////////////////////////////////////////////////////////////////////////// + +int nExportReaction(WPARAM wParam, LPARAM lParam) +{ + auto *dbei = (DB::EventInfo *)wParam; + auto *p = (DBEventReaction *)lParam; + if (!p || !dbei) + return 0; + + if (!bIsExportEnabled(p->hContact)) + return 0; + + // Open/create file for writing + wstring sFilePath = GetFilePathFromUser(p->hContact); + MDatabaseExport *pJson = nullptr; + HANDLE hFile; + + if (g_bUseJson) { + pJson = g_pDriver->Export(sFilePath.c_str()); + if (pJson == nullptr) { + DisplayErrorDialog(LPGENW("Failed to open or create file:\n"), sFilePath); + return 0; + } + + hFile = pJson; + } + else { + hFile = openCreateFile(sFilePath); + if (hFile == INVALID_HANDLE_VALUE) { + DisplayErrorDialog(LPGENW("Failed to open or create file:\n"), sFilePath); + return 0; + } + } + + // Write the event + bExportReaction(*dbei, *p, hFile, sFilePath); + + // Close the file + if (pJson) { + pJson->EndExport(); + delete pJson; + } + else CloseHandle(hFile); + + return 0; +} -- cgit v1.2.3