summaryrefslogtreecommitdiff
path: root/src/mir_core
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-10-01 19:28:00 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-10-01 19:28:00 +0300
commitac9b7f8cae2299f38187a5d239658cc9c2b8ef96 (patch)
treef17714dc04998622c15c39c225c08688b370b528 /src/mir_core
parent0a45ee17d65e81de34fca97a5cea6956150081ec (diff)
fixes #4657 (NewStory: не отображается предпросмотр)
Diffstat (limited to 'src/mir_core')
-rw-r--r--src/mir_core/src/db.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp
index fb5095afdc..b691461e66 100644
--- a/src/mir_core/src/db.cpp
+++ b/src/mir_core/src/db.cpp
@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
+#include <m_json.h>
#include <m_messagestate.h>
MIR_CORE_EXPORT MDatabaseCommon* g_pCurrDb = nullptr;
@@ -527,7 +528,35 @@ MIR_CORE_DLL(MEVENT) db_event_getById(const char *szModule, const char *szId)
MIR_CORE_DLL(int) db_event_setJson(MEVENT hDbEvent, const char *szSetting, DBVARIANT *dbv)
{
- return (g_pCurrDb == nullptr) ? 1 : g_pCurrDb->SetEventJson(hDbEvent, szSetting, dbv);
+ if (g_pCurrDb == nullptr)
+ return 1;
+
+ if (!g_pCurrDb->isEncrypted())
+ return g_pCurrDb->SetEventJson(hDbEvent, szSetting, dbv);
+
+ DB::EventInfo dbei(hDbEvent);
+ if (!dbei)
+ return 3;
+
+ auto &json = dbei.setJson();
+
+ switch (dbv->type) {
+ case DBVT_BYTE: json << INT_PARAM(szSetting, dbv->bVal); break;
+ case DBVT_WORD: json << INT_PARAM(szSetting, dbv->wVal); break;
+ case DBVT_DWORD: json << INT_PARAM(szSetting, dbv->dVal); break;
+ case DBVT_ASCIIZ:
+ case DBVT_UTF8:
+ json << CHAR_PARAM(szSetting, dbv->pszVal);
+ break;
+ case DBVT_WCHAR:
+ json << WCHAR_PARAM(szSetting, dbv->pwszVal);
+ break;
+ default:
+ return 2;
+ }
+ dbei.flushJson();
+
+ return db_event_edit(hDbEvent, &dbei);
}
MIR_CORE_DLL(int) db_event_updateId(MEVENT hDbEvent, const char *szId)