From 8f9292d483fcf3a10d9284512359c4562f5311eb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 11 Apr 2023 17:07:04 +0300 Subject: DB::FILE_BLOB - file events' access unification --- plugins/Msg_Export/src/utils.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'plugins/Msg_Export') diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 6efee874e7..ba97c46228 100644 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -629,7 +629,7 @@ static wchar_t* getEventString(DBEVENTINFO &dbei, char *&buf) return (dbei.flags & DBEF_UTF) ? mir_utf8decodeW(in) : mir_a2u(in); } -static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sFilePath, DBEVENTINFO &dbei, bool bAppendOnly) +static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sFilePath, DB::EventInfo &dbei, bool bAppendOnly) { wstring sLocalUser; wstring sRemoteUser; @@ -779,13 +779,11 @@ static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sF pRoot.push_back(JSONNode("flags", flags)); if (dbei.eventType == EVENTTYPE_FILE) { - char *p = (char*)dbei.pBlob + sizeof(uint32_t); - ptrW wszFileName(getEventString(dbei, p)); - ptrW wszDescr(getEventString(dbei, p)); + DB::FILE_BLOB blob(dbei); - pRoot << WCHAR_PARAM("file", wszFileName); - if (mir_wstrlen(wszDescr)) - pRoot << WCHAR_PARAM("descr", wszDescr); + pRoot << WCHAR_PARAM("file", blob.getName()); + if (mir_wstrlen(blob.getDescr())) + pRoot << WCHAR_PARAM("descr", blob.getDescr()); } else { ptrW msg(DbEvent_GetTextW(&dbei, CP_ACP)); @@ -824,18 +822,16 @@ static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sF case EVENTTYPE_FILE: { - char *p = (char*)dbei.pBlob + sizeof(uint32_t); - ptrW wszFileName(getEventString(dbei, p)); - ptrW wszDescr(getEventString(dbei, p)); + DB::FILE_BLOB blob(dbei); const wchar_t *pszType = LPGENW("File: "); bWriteTextToFile(hFile, pszType, bWriteUTF8Format); - bWriteIndentedToFile(hFile, nIndent, wszFileName, bWriteUTF8Format); + bWriteIndentedToFile(hFile, nIndent, blob.getName(), bWriteUTF8Format); - if (mir_wstrlen(wszDescr)) { + if (mir_wstrlen(blob.getDescr())) { bWriteNewLine(hFile, nIndent); bWriteTextToFile(hFile, LPGENW("Description: "), bWriteUTF8Format); - bWriteIndentedToFile(hFile, nIndent, wszDescr, bWriteUTF8Format); + bWriteIndentedToFile(hFile, nIndent, blob.getDescr(), bWriteUTF8Format); } } break; -- cgit v1.2.3