summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-09-06 15:14:07 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-09-06 15:14:07 +0300
commit38b24044db30c606e9bb3ebe0849b16c9fdc6e62 (patch)
treeaf2822805df50b5f3cc18abc2d709ace3140342d /src
parent5e232971e1eb3a0ce665a3e34b982db49676e653 (diff)
fixes #3667 (Telegram: add message edit feature)
Diffstat (limited to 'src')
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/proto_accs.cpp10
-rw-r--r--src/mir_app/src/proto_interface.cpp2
-rw-r--r--src/mir_core/src/db.cpp14
5 files changed, 16 insertions, 14 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 3a1b7cd89d..08989886ce 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -708,7 +708,7 @@ Chat_CreateMenu @824 NONAME
?PasteFilesAsURL@CSrmmBaseDialog@@IAE_NPAUHDROP__@@@Z @825 NONAME
?Proto_GetInstance@@YGPAUPROTO_INTERFACE@@I@Z @826 NONAME
?Proto_GetInstance@@YGPAUPROTO_INTERFACE@@PBD@Z @827 NONAME
-?OnEventEdited@PROTO_INTERFACE@@UAEXII@Z @828 NONAME
+?OnEventEdited@PROTO_INTERFACE@@UAEXIIABUDBEVENTINFO@@@Z @828 NONAME
?GetChecker@MDatabaseCommon@@UAGPAUMIDatabaseChecker@@XZ @829 NONAME
?GetMenuItem@PROTO_INTERFACE@@QAEPAUTMO_IntMenuItem@@W4ProtoMenuItemType@@@Z @830 NONAME
_Netlib_GetTlsUnique@12 @831 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index eb3ea2ac3b..d15c8b7a46 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -708,7 +708,7 @@ Chat_CreateMenu @824 NONAME
?PasteFilesAsURL@CSrmmBaseDialog@@IEAA_NPEAUHDROP__@@@Z @825 NONAME
?Proto_GetInstance@@YAPEAUPROTO_INTERFACE@@I@Z @826 NONAME
?Proto_GetInstance@@YAPEAUPROTO_INTERFACE@@PEBD@Z @827 NONAME
-?OnEventEdited@PROTO_INTERFACE@@UEAAXII@Z @828 NONAME
+?OnEventEdited@PROTO_INTERFACE@@UEAAXIIAEBUDBEVENTINFO@@@Z @828 NONAME
?GetChecker@MDatabaseCommon@@UEAAPEAUMIDatabaseChecker@@XZ @829 NONAME
?GetMenuItem@PROTO_INTERFACE@@QEAAPEAUTMO_IntMenuItem@@W4ProtoMenuItemType@@@Z @830 NONAME
Netlib_GetTlsUnique @831 NONAME
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp
index 5cf681bf0f..20f25c851d 100644
--- a/src/mir_app/src/proto_accs.cpp
+++ b/src/mir_app/src/proto_accs.cpp
@@ -32,7 +32,7 @@ void BuildProtoMenus();
HICON Proto_GetIcon(PROTO_INTERFACE *ppro, int iconIndex);
static bool bModuleInitialized = false;
-static HANDLE hHooks[2];
+static HANDLE hHooks[1];
static int CompareAccounts(const PROTOACCOUNT* p1, const PROTOACCOUNT* p2)
{
@@ -150,13 +150,6 @@ void WriteDbAccounts()
/////////////////////////////////////////////////////////////////////////////////////////
-static int OnEventEdited(WPARAM hContact, LPARAM hDbEvent)
-{
- if (auto *ppro = Proto_GetInstance(hContact))
- ppro->OnEventEdited(hContact, hDbEvent);
- return 0;
-}
-
void InitStaticAccounts()
{
int count = 0;
@@ -218,7 +211,6 @@ int LoadAccountsModule(void)
}
hHooks[0] = HookEvent(ME_SYSTEM_PRESHUTDOWN, UninitializeStaticAccounts);
- hHooks[1] = HookEvent(ME_DB_EVENT_EDITED, OnEventEdited);
return 0;
}
diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp
index db4da573d8..716cc7bb29 100644
--- a/src/mir_app/src/proto_interface.cpp
+++ b/src/mir_app/src/proto_interface.cpp
@@ -83,7 +83,7 @@ MWindow PROTO_INTERFACE::OnCreateAccMgrUI(MWindow)
void PROTO_INTERFACE::OnEventDeleted(MCONTACT, MEVENT)
{}
-void PROTO_INTERFACE::OnEventEdited(MCONTACT, MEVENT)
+void PROTO_INTERFACE::OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &)
{}
void PROTO_INTERFACE::OnErase()
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp
index 982d289e29..0dec7c5ee6 100644
--- a/src/mir_core/src/db.cpp
+++ b/src/mir_core/src/db.cpp
@@ -426,9 +426,19 @@ MIR_CORE_DLL(int) db_event_delete(MEVENT hDbEvent, bool bFromServer)
return g_pCurrDb->DeleteEvent(hDbEvent);
}
-MIR_CORE_DLL(int) db_event_edit(MEVENT hDbEvent, const DBEVENTINFO *dbei)
+MIR_CORE_DLL(int) db_event_edit(MEVENT hDbEvent, const DBEVENTINFO *dbei, bool bFromServer)
{
- return (g_pCurrDb == nullptr) ? 0 : g_pCurrDb->EditEvent(hDbEvent, dbei);
+ if (g_pCurrDb == nullptr)
+ return 0;
+
+ int rc = g_pCurrDb->EditEvent(hDbEvent, dbei);
+ if (!rc && !bFromServer) {
+ MCONTACT hContact = g_pCurrDb->GetEventContact(hDbEvent);
+ if (auto *ppro = Proto_GetInstance(hContact))
+ ppro->OnEventEdited(hContact, hDbEvent, *dbei);
+ }
+
+ return rc;
}
MIR_CORE_DLL(MEVENT) db_event_first(MCONTACT hContact)