From ac9b7f8cae2299f38187a5d239658cc9c2b8ef96 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 1 Oct 2024 19:28:00 +0300 Subject: =?UTF-8?q?fixes=20#4657=20(NewStory:=20=D0=BD=D0=B5=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B0=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BF=D1=80=D0=BE=D1=81=D0=BC?= =?UTF-8?q?=D0=BE=D1=82=D1=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mir_core/src/db.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src') 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 #include 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) -- cgit v1.2.3