diff options
author | George Hazan <ghazan@miranda.im> | 2021-06-05 20:35:52 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-06-05 20:35:52 +0300 |
commit | fd1b0654d57acf6b2f39e36259f5352c96ac965f (patch) | |
tree | 19cb39c4637a0e3aa807aaa4b3f57dbba76e4697 /plugins/Msg_Export/src | |
parent | 651f3b245250ead78cbcdb43b32add6d77817647 (diff) |
MsgExport: fix for exporting file descriptions
Diffstat (limited to 'plugins/Msg_Export/src')
-rwxr-xr-x | plugins/Msg_Export/src/utils.cpp | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index e5cba7f1f7..a48c3df5ef 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -622,6 +622,13 @@ const char *pSettings[] = LPGEN("About")
};
+static wchar_t* getEventString(DBEVENTINFO &dbei, char *&buf)
+{
+ char *in = buf;
+ buf += mir_strlen(buf) + 1;
+ 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)
{
wstring sLocalUser;
@@ -771,9 +778,20 @@ static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sF flags += "r";
pRoot.push_back(JSONNode("flags", flags));
- ptrW msg(DbEvent_GetTextW(&dbei, CP_ACP));
- if (msg)
- pRoot.push_back(JSONNode("body", T2Utf(msg).get()));
+ if (dbei.eventType == EVENTTYPE_FILE) {
+ char *p = (char*)dbei.pBlob + sizeof(DWORD);
+ ptrW wszFileName(getEventString(dbei, p));
+ ptrW wszDescr(getEventString(dbei, p));
+
+ pRoot << WCHAR_PARAM("file", wszFileName);
+ if (mir_wstrlen(wszDescr))
+ pRoot << WCHAR_PARAM("descr", wszFileName);
+ }
+ else {
+ ptrW msg(DbEvent_GetTextW(&dbei, CP_ACP));
+ if (msg)
+ pRoot.push_back(JSONNode("body", T2Utf(msg).get()));
+ }
std::string output = pRoot.write_formatted();
output += "\n]}";
@@ -806,24 +824,18 @@ static bool ExportDBEventInfo(MCONTACT hContact, HANDLE hFile, const wstring &sF case EVENTTYPE_FILE:
{
+ char *p = (char*)dbei.pBlob + sizeof(DWORD);
+ ptrW wszFileName(getEventString(dbei, p));
+ ptrW wszDescr(getEventString(dbei, p));
+
const wchar_t *pszType = LPGENW("File: ");
- const char *pszData = (char *)(dbei.pBlob + sizeof(DWORD));
-
- int nLen = (int)mir_strlen(pszData);
- if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob) {
- if (bWriteTextToFile(hFile, pszType, bWriteUTF8Format) &&
- bWriteIndentedToFile(hFile, nIndent, _A2T(pszData), bWriteUTF8Format)) {
- pszData += nLen + 1;
- if ((pszData - (char *)dbei.pBlob) < (int)dbei.cbBlob) {
- nLen = (int)mir_strlen(pszData);
- if ((pszData - (char *)dbei.pBlob) + nLen < (int)dbei.cbBlob) {
- if (bWriteNewLine(hFile, nIndent) &&
- bWriteTextToFile(hFile, LPGENW("Description: "), bWriteUTF8Format) &&
- bWriteIndentedToFile(hFile, nIndent, _A2T(pszData), bWriteUTF8Format)) {
- }
- }
- }
- }
+ bWriteTextToFile(hFile, pszType, bWriteUTF8Format);
+ bWriteIndentedToFile(hFile, nIndent, wszFileName, bWriteUTF8Format);
+
+ if (mir_wstrlen(wszDescr)) {
+ bWriteNewLine(hFile, nIndent);
+ bWriteTextToFile(hFile, LPGENW("Description: "), bWriteUTF8Format);
+ bWriteIndentedToFile(hFile, nIndent, wszDescr, bWriteUTF8Format);
}
}
break;
|