diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-26 23:34:30 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-26 23:34:30 +0300 |
commit | ab3d423b1dc514e9db61c170ca14bab49e5280cb (patch) | |
tree | f8c76c7b8cb5ad8804aff7222960126e9180d66c | |
parent | 395ecbc7e8f02c0ea659a598e5f9bab8995f3451 (diff) |
major atavism, PROTORECVEVENT, died with its own set of constants
73 files changed, 393 insertions, 543 deletions
diff --git a/include/delphi/m_protosvc.inc b/include/delphi/m_protosvc.inc index de4c151296..a8650ebfe5 100644 --- a/include/delphi/m_protosvc.inc +++ b/include/delphi/m_protosvc.inc @@ -176,16 +176,6 @@ type // they put there will be retained by anyone trying to save this structure.
end;
- PPROTORECVEVENT = ^TPROTORECVEVENT;
- TPROTORECVEVENT = record
- flags : dword;
- timestamp : dword;
- szMessage : TChar;
- lParam : LPARAM;
- szUserId : PAnsiChar; // user id of event
- szReplyId : PAnsiChar; // reply id of event
- end;
-
const
{
wParam : PFLAGNUM_* (see above)
diff --git a/include/m_protoint.h b/include/m_protoint.h index a3df748937..0bf9f73a62 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -217,7 +217,7 @@ public: virtual int Authorize(MEVENT hDbEvent);
virtual int AuthDeny(MEVENT hDbEvent, const wchar_t *szReason);
- virtual int AuthRecv(MCONTACT hContact, PROTORECVEVENT *);
+ virtual int AuthRecv(MCONTACT hContact, DB::EventInfo &dbei);
virtual int AuthRequest(MCONTACT hContact, const wchar_t *szMessage);
virtual HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szPath);
@@ -234,9 +234,9 @@ public: virtual HANDLE SearchAdvanced(MWindow owner);
virtual MWindow CreateExtendedSearchUI(MWindow owner);
- virtual int RecvContacts(MCONTACT hContact, PROTORECVEVENT *);
+ virtual int RecvContacts(MCONTACT hContact, DB::EventInfo &dbei);
virtual MEVENT RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei);
- virtual MEVENT RecvMsg(MCONTACT hContact, PROTORECVEVENT *);
+ virtual MEVENT RecvMsg(MCONTACT hContact, DB::EventInfo &dbei);
virtual int SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList);
virtual HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles);
diff --git a/include/m_protosvc.h b/include/m_protosvc.h index a1f1a6a193..64d31b6aa8 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -666,42 +666,18 @@ struct PROTOFILERESUME // just want to know the final result should hook.
// In all cases, the database should store what the user read/wrote.
-// An instant message has been received
-// wParam = 0
-// lParam = (LPARAM)(PROTORECVEVENT*)&pre
-// DB event: EVENTTYPE_MESSAGE, blob contains szMessage without 0 terminator
-// Return 0 - success, other failure
-
-#define PREF_CREATEREAD 1 // create the database event with the 'read' flag set
-#define PREF_RTL 4 // 0.5+ addition: support for right-to-left messages
-#define PREF_SENT 16 // message will be created with the DBEF_SENT flag
-#define PREF_ENCRYPTED 32 // message is encrypted
-#define PREF_ENCRYPTED_STRONG 64 // message is encrypted with verified key
-
-struct PROTORECVEVENT
-{
- uint32_t flags; // combination of PREF_*
- uint32_t timestamp; // unix time
- char* szMessage; // message body in utf8
- LPARAM lParam; // extra space for the network level protocol module
- const char* szMsgId; // server message id, optional, should be NULL otherwise
- // ignored for protocols without PF4_SERVERMSGID in GetCaps()
- const char *szUserId; // user id, for group chats stored in the database
- const char *szReplyId; // this message is a reply to a message with that server id
-};
-
///////////////////////////////////////////////////////////////////////////////
// Proto/RecvMessage
-// Copies a message from a PROTORECVEVENT event into the database
+// Copies a message from a DB::EventInfo event into the database
// wParam = 0 (unused)
// lParam = CCSDATA*
// Returns the result of db_event_add()
#define PSR_MESSAGE "/RecvMessage"
-__forceinline INT_PTR ProtoChainRecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
+__forceinline INT_PTR ProtoChainRecvMsg(MCONTACT hContact, const DB::EventInfo &dbei)
{
- CCSDATA ccs = { hContact, PSR_MESSAGE, 0, (LPARAM)pre };
+ CCSDATA ccs = { hContact, PSR_MESSAGE, 0, (LPARAM)&dbei };
return Proto_ChainRecv(0, &ccs);
}
@@ -715,7 +691,7 @@ __forceinline INT_PTR ProtoChainRecvMsg(MCONTACT hContact, PROTORECVEVENT *pre) #define PSR_AUTH "/RecvAuth"
// adds the standard EVENTTYPE_AUTHREQUEST event to the database
-EXTERN_C MIR_APP_DLL(MEVENT) Proto_AuthRecv(const char *szProtoName, PROTORECVEVENT *pcre);
+EXTERN_C MIR_APP_DLL(MEVENT) Proto_AuthRecv(const char *szProtoName, DB::EventInfo &dbei);
///////////////////////////////////////////////////////////////////////////////
// File(s) have been received
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 44b1917175..eca65d4159 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 2054a5d1c6..ce38cff252 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/FileAsMessage/src/main.cpp b/plugins/FileAsMessage/src/main.cpp index 213c64d6de..d19e7c2b37 100644 --- a/plugins/FileAsMessage/src/main.cpp +++ b/plugins/FileAsMessage/src/main.cpp @@ -124,9 +124,9 @@ INT_PTR OnSendFile(WPARAM wParam, LPARAM) INT_PTR OnRecvMessage(WPARAM wParam, LPARAM lParam)
{
CCSDATA *ccs = (CCSDATA *)lParam;
- PROTORECVEVENT *ppre = (PROTORECVEVENT *)ccs->lParam;
+ auto *dbei = (DB::EventInfo*)ccs->lParam;
- if (strncmp(ppre->szMessage, szServicePrefix, mir_strlen(szServicePrefix)))
+ if (strncmp(dbei->pBlob, szServicePrefix, mir_strlen(szServicePrefix)))
return Proto_ChainRecv(wParam, ccs);
HWND hwnd = WindowList_Find(hFileList, ccs->hContact);
@@ -142,7 +142,7 @@ INT_PTR OnRecvMessage(WPARAM wParam, LPARAM lParam) return 0;
}
}
- char *msg = mir_strdup(ppre->szMessage + mir_strlen(szServicePrefix));
+ char *msg = mir_strdup(dbei->pBlob + mir_strlen(szServicePrefix));
PostMessage(hwnd, WM_FE_MESSAGE, (WPARAM)ccs->hContact, (LPARAM)msg);
return 0;
diff --git a/plugins/Jingle/src/account.cpp b/plugins/Jingle/src/account.cpp index b2be77922b..9a334942e1 100644 --- a/plugins/Jingle/src/account.cpp +++ b/plugins/Jingle/src/account.cpp @@ -127,10 +127,10 @@ static BOOL OnProcessJingle(struct IJabberInterface *api, const TiXmlElement *no } // Save this event to history - PROTORECVEVENT recv = {}; - recv.timestamp = (uint32_t)time(0); - recv.szMessage = "** A call while we were busy **"; - ProtoChainRecvMsg(api->ContactFromJID(from), &recv); + DB::EventInfo dbei; + dbei.timestamp = (uint32_t)time(0); + dbei.pBlob = "** A call while we were busy **"; + ProtoChainRecvMsg(api->ContactFromJID(from), dbei); reason = "busy"; } diff --git a/plugins/MirLua/src/Modules/m_protocols.cpp b/plugins/MirLua/src/Modules/m_protocols.cpp index a34f262780..32c8e34590 100644 --- a/plugins/MirLua/src/Modules/m_protocols.cpp +++ b/plugins/MirLua/src/Modules/m_protocols.cpp @@ -299,10 +299,5 @@ LUAMOD_API int luaopen_m_protocols(lua_State *L) .Field(&CCSDATA::lParam, "lParam", LUA_TLIGHTUSERDATA)
.Field(&CCSDATA::lParam, "Message", LUA_TSTRING);
- MT<PROTORECVEVENT>(L, "PROTORECVEVENT")
- .Field(&PROTORECVEVENT::timestamp, "Timestamp", LUA_TINTEGER)
- .Field(&PROTORECVEVENT::flags, "Flags", LUA_TINTEGER)
- .Field(&PROTORECVEVENT::szMessage, "Message", LUA_TSTRING);
-
return 1;
}
diff --git a/plugins/MirOTR/src/svcs_proto.cpp b/plugins/MirOTR/src/svcs_proto.cpp index 038500363b..38f1bb401c 100644 --- a/plugins/MirOTR/src/svcs_proto.cpp +++ b/plugins/MirOTR/src/svcs_proto.cpp @@ -76,13 +76,13 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam) { CCSDATA *ccs = (CCSDATA *) lParam; - PROTORECVEVENT *pre = (PROTORECVEVENT *) ccs->lParam; + auto *dbei = (DB::EventInfo *) ccs->lParam; DEBUGOUTA("OTR - receiving message: '"); - DEBUGOUTA(pre->szMessage); + DEBUGOUTA(dbei->pBlob); DEBUGOUTA("'\n"); - if (pre->flags & PREF_BYPASS_OTR) // bypass for our inline messages + if (dbei->flags & PREF_BYPASS_OTR) // bypass for our inline messages return Proto_ChainRecv(wParam, ccs); char *proto = Proto_GetBaseAccountName(ccs->hContact); @@ -91,7 +91,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam) else if(proto && mir_strcmp(proto, META_PROTO) == 0) // bypass for metacontacts return Proto_ChainRecv(wParam, ccs); - char *oldmessage = pre->szMessage; + char *oldmessage = dbei->pBlob; // convert oldmessage to utf-8 if (!oldmessage) return 1; @@ -125,7 +125,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam) if (newmessage == nullptr) return Proto_ChainRecv(wParam, ccs); - uint32_t oldflags = pre->flags; + uint32_t oldflags = dbei->flags; typedef void (*msg_free_t)(void*); msg_free_t msg_free = (msg_free_t)otrl_message_free; @@ -142,11 +142,11 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam) replaceStr(newmessage, tmp.Detach()); msg_free = mir_free; } - pre->szMessage = newmessage; + dbei->pBlob = newmessage; BOOL ret = Proto_ChainRecv(wParam, ccs); /// @todo (White-Tiger#1#03/23/15): why are we doing this? - pre->flags = oldflags; - pre->szMessage = oldmessage; + dbei->flags = oldflags; + dbei->pBlob = oldmessage; msg_free(newmessage); return ret; } diff --git a/plugins/MirOTR/src/utils.cpp b/plugins/MirOTR/src/utils.cpp index 76b4d03c96..af6c8eb928 100644 --- a/plugins/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/src/utils.cpp @@ -215,11 +215,11 @@ void ShowMessageInline(const MCONTACT hContact, const wchar_t *msg) mir_snwprintf(buff, L"%s%s", _A2W(LANG_INLINE_PREFIX), msg); T2Utf utf(buff); - PROTORECVEVENT pre = { 0 }; - pre.timestamp = time(0); - pre.szMessage = utf; - pre.flags = PREF_BYPASS_OTR; - ProtoChainRecvMsg(hContact, &pre); + DB::EventInfo dbei; + dbei.timestamp = time(0); + dbei.pBlob = utf; + dbei.flags = PREF_BYPASS_OTR; + ProtoChainRecvMsg(hContact, dbei); } void ShowMessageInlineUtf(const MCONTACT hContact, const char *msg) @@ -227,11 +227,11 @@ void ShowMessageInlineUtf(const MCONTACT hContact, const char *msg) char buff[1024]; mir_snprintf(buff, "%s%s", LANG_INLINE_PREFIX, msg); - PROTORECVEVENT pre = { 0 }; - pre.timestamp = time(0); - pre.szMessage = buff; - pre.flags = PREF_BYPASS_OTR; - ProtoChainRecvMsg(hContact, &pre); + DB::EventInfo dbei; + dbei.timestamp = time(0); + dbei.pBlob = buff; + dbei.flags = PREF_BYPASS_OTR; + ProtoChainRecvMsg(hContact, dbei); } void ShowMessageUtf(const MCONTACT hContact, const char *msg) diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index c9c89bf0f3..b3bd5e286c 100644 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -299,11 +299,11 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) if (!ccs)
return Proto_ChainRecv(w, ccs);
- PROTORECVEVENT *pre = (PROTORECVEVENT*)(ccs->lParam);
- if (!pre)
+ auto *dbei = (DB::EventInfo*)(ccs->lParam);
+ if (!dbei)
return Proto_ChainRecv(w, ccs);
- char *msg = pre->szMessage;
+ char *msg = dbei->pBlob;
if (!msg)
return Proto_ChainRecv(w, ccs);
@@ -497,7 +497,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l) if (!strstr(msg, "-----BEGIN PGP MESSAGE-----"))
return Proto_ChainRecv(w, ccs);
- mir_forkThread<RecvParams>(RecvMsgSvc_func, new RecvParams(ccs->hContact, str, msg, pre->timestamp));
+ mir_forkThread<RecvParams>(RecvMsgSvc_func, new RecvParams(ccs->hContact, str, msg, dbei->timestamp));
return 0;
}
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index 23bbc7af31..6ec8c203bd 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -127,7 +127,7 @@ static int ackevent(WPARAM, LPARAM lParam) DBEVENTINFO dbei = {};
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_UTF | DBEF_SENT | ((item->flags & PREF_RTL) ? DBEF_RTL : 0);
+ dbei.flags = DBEF_UTF | DBEF_SENT | (item->flags & DBEF_RTL);
dbei.szModule = Proto_GetBaseAccountName(hContact);
dbei.timestamp = time(0);
dbei.cbBlob = (int)mir_strlen(item->sendBuffer) + 1;
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 0ab0d77f11..b75ab78c42 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -298,7 +298,7 @@ void CMsgDialog::onClick_Ok(CCtrlButton *pButton) SendQueue::Item msi = {};
if (pf2.wEffects & PFE_RTLPARA)
- msi.flags |= PREF_RTL;
+ msi.flags |= DBEF_RTL;
msi.sendBuffer = m_message.GetRichTextRtf(true);
msi.sendBufferSize = (int)mir_strlen(msi.sendBuffer);
@@ -306,7 +306,7 @@ void CMsgDialog::onClick_Ok(CCtrlButton *pButton) return;
if (Utils_IsRtl(ptrW(mir_utf8decodeW(msi.sendBuffer))))
- msi.flags |= PREF_RTL;
+ msi.flags |= DBEF_RTL;
// Store messaging history
TCmdList *cmdListNew = tcmdlist_last(cmdList);
diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp index dbf655111f..c23663cd19 100644 --- a/plugins/SecureIM/src/crypt_dll.cpp +++ b/plugins/SecureIM/src/crypt_dll.cpp @@ -129,7 +129,7 @@ LPSTR encodeMsg(pUinKey ptr, LPARAM lParam) LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg)
{
CCSDATA *pccsd = (CCSDATA *)lParam;
- PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam;
+ auto *dbei = (DB::EventInfo *)pccsd->lParam;
LPSTR szNewMsg = nullptr;
LPSTR szOldMsg = cpp_decodeU(ptr->cntx, szEncMsg);
@@ -155,7 +155,7 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) szNewMsg = (LPSTR)mir_alloc(olen);
memcpy(szNewMsg, szOldMsg, olen);
}
- ppre->szMessage = szNewMsg;
+ dbei->pBlob = szNewMsg;
return szNewMsg;
}
diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp index d1079c8276..98ae3ae07d 100644 --- a/plugins/SecureIM/src/svcs_proto.cpp +++ b/plugins/SecureIM/src/svcs_proto.cpp @@ -66,13 +66,13 @@ LPSTR szUnrtfMsg = nullptr; INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam)
{
CCSDATA *ccs = (CCSDATA *)lParam;
- PROTORECVEVENT *ppre = (PROTORECVEVENT *)ccs->lParam;
+ auto *dbei = (DB::EventInfo *)ccs->lParam;
pUinKey ptr = getUinKey(ccs->hContact);
- LPSTR szEncMsg = ppre->szMessage, szPlainMsg = nullptr;
+ LPSTR szEncMsg = dbei->pBlob, szPlainMsg = nullptr;
Sent_NetLog("onRecvMsg: %s", szEncMsg);
- int ssig = getSecureSig(ppre->szMessage, &szEncMsg);
+ int ssig = getSecureSig(dbei->pBlob, &szEncMsg);
bool bSecured = (isContactSecured(ccs->hContact)&SECURED) != 0;
bool bPGP = isContactPGP(ccs->hContact);
bool bGPG = isContactGPG(ccs->hContact);
@@ -96,7 +96,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) Sent_NetLog("onRecvMsg: non-secure message");
ptrA szPlainMsg(m_aastrcat(Translate("SecureIM received unencrypted message:\n"), szEncMsg));
- ppre->szMessage = szPlainMsg;
+ dbei->pBlob = szPlainMsg;
ccs->wParam |= PREF_SIMNOMETA;
return Proto_ChainRecv(wParam, ccs);
}
@@ -131,7 +131,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) mir_strcpy(tmp, ptr->msgSplitted);
mir_strcat(tmp, szEncMsg);
mir_free(ptr->msgSplitted);
- ptr->msgSplitted = szEncMsg = ppre->szMessage = tmp;
+ ptr->msgSplitted = szEncMsg = dbei->pBlob = tmp;
ssig = getSecureSig(tmp, &szEncMsg);
}
else SAFE_FREE(ptr->msgSplitted);
@@ -140,7 +140,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (ssig == SiG_SECP || ssig == SiG_PART) {
LPSTR msg = combineMessage(ptr, szEncMsg);
if (!msg) return 1;
- szEncMsg = ppre->szMessage = msg;
+ szEncMsg = dbei->pBlob = msg;
ssig = getSecureSig(msg, &szEncMsg);
}
@@ -148,7 +148,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (ssig == SiG_PGPM && ((bPGPloaded && (bPGPkeyrings || bPGPprivkey)) || (bGPGloaded && bGPGkeyrings))) {
Sent_NetLog("onRecvMsg: PGP/GPG message");
- szEncMsg = ppre->szMessage;
+ szEncMsg = dbei->pBlob;
if (!ptr->cntx) {
ptr->cntx = cpp_create_context(((bGPGloaded && bGPGkeyrings) ? CPP_MODE_GPG : CPP_MODE_PGP) | ((db_get_b(ccs->hContact, MODULENAME, "gpgANSI", 0)) ? CPP_MODE_GPG_ANSI : 0));
ptr->keyLoaded = 0;
@@ -169,7 +169,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (!szOldMsg) { // error while decrypting message, send error
SAFE_FREE(ptr->msgSplitted);
- ppre->szMessage = Translate("SecureIM: Sorry, unable to decrypt this message because you have no PGP/GPG installed. Visit www.pgp.com or www.gnupg.org for more info.");
+ dbei->pBlob = Translate("SecureIM: Sorry, unable to decrypt this message because you have no PGP/GPG installed. Visit www.pgp.com or www.gnupg.org for more info.");
return Proto_ChainRecv(wParam, ccs);
}
@@ -178,9 +178,9 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) szNewMsg = m_ustrcat(Translate("SecureIM received encrypted message:\n"), szOldMsg);
szOldMsg = szNewMsg;
}
- ptrA szMsgUtf(utf8_to_miranda(szOldMsg, ppre->flags));
- ccs->wParam = ppre->flags;
- ppre->szMessage = szMsgUtf;
+ ptrA szMsgUtf(utf8_to_miranda(szOldMsg, dbei->flags));
+ ccs->wParam = dbei->flags;
+ dbei->pBlob = szMsgUtf;
// show decoded message
showPopupRM(ptr->hContact);
@@ -213,9 +213,9 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) if (!szOldMsg)
return 1; // don't display it ...
- ptrA szNewMsg(utf8_to_miranda(szOldMsg, ppre->flags));
- ccs->wParam = ppre->flags;
- ppre->szMessage = szNewMsg;
+ ptrA szNewMsg(utf8_to_miranda(szOldMsg, dbei->flags));
+ ccs->wParam = dbei->flags;
+ dbei->pBlob = szNewMsg;
// show decoded message
showPopupRM(ptr->hContact);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index f4bf62111c..172bb9fef5 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -849,7 +849,7 @@ void CMsgDialog::onClick_Ok(CCtrlButton *) int flags = 0;
if (pf2.wEffects & PFE_RTLPARA)
if (Utils_IsRtl(decoded))
- flags |= PREF_RTL;
+ flags |= DBEF_RTL;
SendMessage(hwndEdit, WM_SETREDRAW, TRUE, 0);
SendMessage(hwndEdit, EM_SETSEL, -1, -1);
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 824cbe3017..e009e98496 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -471,7 +471,7 @@ int SendQueue::ackMessage(CMsgDialog *dat, WPARAM wParam, LPARAM lParam) cc->updateStats(TSessionStats::BYTES_SENT, dbei.cbBlob - 1);
}
- if (job.dwFlags & PREF_RTL)
+ if (job.dwFlags & DBEF_RTL)
dbei.flags |= DBEF_RTL;
dbei.pBlob = job.szSendBuffer;
dbei.szId = (char *)ack->lParam;
diff --git a/plugins/Watrack/proto/proto.pas b/plugins/Watrack/proto/proto.pas index c37c19bb68..d6b202b529 100644 --- a/plugins/Watrack/proto/proto.pas +++ b/plugins/Watrack/proto/proto.pas @@ -84,6 +84,7 @@ const var
ccs:PCCSDATA;
ccdata:TCCSDATA;
+ dbei:PDBEVENTINFO;
s:pWideChar;
buf:PWideChar;
data:PByte;
@@ -102,12 +103,11 @@ begin result:=0;
mGetMem(buf,bufsize);
- isNewRequest:=StrCmp(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a,
- wpRequestNew,Length(wpRequestNew))=0;
+ dbei:=PDBEVENTINFO(ccs^.lParam);
+ isNewRequest:=StrCmp(PAnsiChar(dbei.pBlob),wpRequestNew,Length(wpRequestNew))=0;
if isNewRequest or
- (StrCmp(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a,
- wpRequest,Length(wpRequest))=0) then
+ (StrCmp(PAnsiChar(dbei.pBlob),wpRequest,Length(wpRequest))=0) then
begin
StrCopy(PAnsiChar(buf),Proto_GetBaseAccountName(ccs^.hContact));
i:=DBReadWord(ccs^.hContact,PAnsiChar(buf),'ApparentMode');
@@ -120,8 +120,7 @@ begin // or (NotListedAllow and (DBReadByte(ccs^.hContact,strCList,'NotOnList',0))
begin
if (HistMask and hmInRequest)<>0 then
- AddEvent(ccs^.hContact,EVENTTYPE_WAT_REQUEST,DBEF_READ,nil,0,
- PPROTORECVEVENT(ccs^.lParam)^.Timestamp);
+ AddEvent(ccs^.hContact,EVENTTYPE_WAT_REQUEST,DBEF_READ,nil,0,dbei.Timestamp);
if GetContactStatus(ccs^.hContact)<>ID_STATUS_OFFLINE then
begin
//!! Request Answer
@@ -204,8 +203,7 @@ begin else
begin
if (HistMask and hmIRequest)<>0 then
- AddEvent(ccs^.hContact,EVENTTYPE_WAT_REQUEST,DBEF_READ,nil,0,
- PPROTORECVEVENT(ccs^.lParam)^.Timestamp);
+ AddEvent(ccs^.hContact,EVENTTYPE_WAT_REQUEST,DBEF_READ,nil,0,dbei.Timestamp);
if (HistMask and hmISend)<>0 then
begin
//!! Request Error Answer
@@ -224,16 +222,15 @@ begin Proto_ChainSend(0, @ccdata);
if (HistMask and hmOutError)<>0 then
begin
- AddEvent(ccs^.hContact,EVENTTYPE_WAT_ERROR,DBEF_SENT,nil,0,
- PPROTORECVEVENT(ccs^.lParam)^.Timestamp);
+ AddEvent(ccs^.hContact,EVENTTYPE_WAT_ERROR,DBEF_SENT,nil,0,dbei.Timestamp);
end;
end;
end;
end
- else if StrCmp(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a,wpAnswer,Length(wpAnswer))=0 then
+ else if StrCmp(PAnsiChar(dbei.pBlob),wpAnswer,Length(wpAnswer))=0 then
begin
// decode
- data:=mir_base64_decode(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a+Length(wpAnswer),dataSize);
+ data:=mir_base64_decode(PAnsiChar(dbei.pBlob)+Length(wpAnswer),dataSize);
curpos:=pWideChar(data); // pos_artist:=curpos;
while curpos^<>#0 do inc(curpos); inc(curpos); // pos_title :=curpos;
@@ -242,9 +239,7 @@ begin pos_template:=curpos;
if (HistMask and hmInInfo)<>0 then
- AddEvent(ccs^.hContact,EVENTTYPE_WAT_ANSWER,DBEF_READ,
- data,dataSize,
- PPROTORECVEVENT(ccs^.lParam)^.Timestamp);
+ AddEvent(ccs^.hContact,EVENTTYPE_WAT_ANSWER,DBEF_READ,data,dataSize,dbei.Timestamp);
// Action
StrCopyW(buf,TranslateW('Music Info from '));
@@ -254,12 +249,11 @@ begin mFreeMem(data);
end
- else if StrCmp(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a,wpError,Length(wpError))=0 then
+ else if StrCmp(PAnsiChar(dbei.pBlob),wpError,Length(wpError))=0 then
begin
if (HistMask and hmInError)<>0 then
- AddEvent(ccs^.hContact,EVENTTYPE_WAT_ERROR,DBEF_READ,nil,0,
- PPROTORECVEVENT(ccs^.lParam)^.Timestamp);
- MessageBoxA(0,Translate(PPROTORECVEVENT(ccs^.lParam)^.szMessage.a+Length(wpError)),
+ AddEvent(ccs^.hContact,EVENTTYPE_WAT_ERROR,DBEF_READ,nil,0,dbei.Timestamp);
+ MessageBoxA(0,Translate(PAnsiChar(dbei.pBlob)+Length(wpError)),
Translate('You Get Error'),MB_ICONERROR);
end
else
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 536eff688f..0c6062f1d5 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -408,23 +408,23 @@ void CDiscordProto::OnCommandMessage(const JSONNode &pRoot, bool bIsNew) wszText.AppendFormat(L" (%s %s)", TranslateT("edited at"), edited.as_mstring().c_str());
// if a message has myself as an author, add some flags
- PROTORECVEVENT recv = {};
+ DB::EventInfo dbei;
if (bOurMessage)
- recv.flags = PREF_CREATEREAD | PREF_SENT;
+ dbei.flags = DBEF_READ | DBEF_SENT;
debugLogA("store a message from private user %lld, channel id %lld", pUser->id, pUser->channelId);
ptrA buf(mir_utf8encodeW(wszText));
- recv.timestamp = (uint32_t)StringToDate(pRoot["timestamp"].as_mstring());
- recv.szMessage = buf;
- recv.szMsgId = szMsgId;
+ dbei.timestamp = (uint32_t)StringToDate(pRoot["timestamp"].as_mstring());
+ dbei.pBlob = buf;
+ dbei.szId = szMsgId;
if (!pUser->bIsPrivate || pUser->bIsGroup) {
- recv.szUserId = szUserId;
+ dbei.szUserId = szUserId;
ProcessChatUser(pUser, userId, pRoot);
}
- ProtoChainRecvMsg(pUser->hContact, &recv);
+ ProtoChainRecvMsg(pUser->hContact, dbei);
}
pUser->lastMsgId = msgId;
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index e2f0658819..00c7daf351 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -369,9 +369,9 @@ int CDiscordProto::AuthRequest(MCONTACT hContact, const wchar_t*) return 0;
}
-int CDiscordProto::AuthRecv(MCONTACT, PROTORECVEVENT *pre)
+int CDiscordProto::AuthRecv(MCONTACT, DB::EventInfo &dbei)
{
- return Proto_AuthRecv(m_szModuleName, pre);
+ return Proto_AuthRecv(m_szModuleName, dbei);
}
int CDiscordProto::Authorize(MEVENT hDbEvent)
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 1bc7c04444..4c9f74e181 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -427,7 +427,7 @@ public: MCONTACT AddToList(int flags, PROTOSEARCHRESULT *psr) override;
MCONTACT AddToListByEvent(int flags, int, MEVENT hDbEvent) override;
- int AuthRecv(MCONTACT, PROTORECVEVENT *pre) override;
+ int AuthRecv(MCONTACT, DB::EventInfo &dbei) override;
int Authorize(MEVENT hDbEvent) override;
int AuthDeny(MEVENT hDbEvent, const wchar_t* szReason) override;
int AuthRequest(MCONTACT hContact, const wchar_t*) override;
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp index cc2e4fff3a..dcd94ebe71 100644 --- a/protocols/Discord/src/utils.cpp +++ b/protocols/Discord/src/utils.cpp @@ -334,11 +334,11 @@ void CDiscordProto::ProcessType(CDiscordUser *pUser, const JSONNode &pRoot) CMStringA szId(FORMAT, "%lld", pUser->id);
DB::AUTH_BLOB blob(pUser->hContact, T2Utf(pUser->wszUsername), nullptr, nullptr, szId, nullptr);
- PROTORECVEVENT pre = {};
- pre.timestamp = (uint32_t)time(0);
- pre.lParam = blob.size();
- pre.szMessage = blob;
- ProtoChainRecv(pUser->hContact, PSR_AUTH, 0, (LPARAM)&pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = (uint32_t)time(0);
+ dbei.cbBlob = blob.size();
+ dbei.pBlob = blob;
+ ProtoChainRecv(pUser->hContact, PSR_AUTH, 0, (LPARAM)&dbei);
}
break;
}
diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp index a1c764d125..662df2d566 100644 --- a/protocols/EmLanProto/src/mlan.cpp +++ b/protocols/EmLanProto/src/mlan.cpp @@ -266,10 +266,10 @@ void CMLan::OnRecvPacket(u_char *mes, int len, in_addr from) if (!cont) RequestStatus(true, from.S_un.S_addr); else { - PROTORECVEVENT pre = { 0 }; - pre.timestamp = get_time(); - pre.szMessage = pak.strMessage; - ProtoChainRecv(FindContact(cont->m_addr, cont->m_nick, true, false, false, cont->m_status), PSR_MESSAGE, 0, (LPARAM)&pre); + DB::EventInfo dbei; + dbei.timestamp = get_time(); + dbei.pBlob = pak.strMessage; + ProtoChainRecvMsg(FindContact(cont->m_addr, cont->m_nick, true, false, false, cont->m_status), dbei); TPacket npak; memset(&npak, 0, sizeof(npak)); @@ -285,11 +285,11 @@ void CMLan::OnRecvPacket(u_char *mes, int len, in_addr from) } if (pak.strAwayMessage && cont) { - PROTORECVEVENT pre = { 0 }; - pre.timestamp = get_time(); - pre.szMessage = pak.strAwayMessage; - pre.lParam = pak.idAckAwayMessage; - ProtoChainRecv(FindContact(cont->m_addr, cont->m_nick, true, false, false, cont->m_status), PSR_AWAYMSG, 0, (LPARAM)&pre); + DB::EventInfo dbei; + dbei.timestamp = get_time(); + dbei.pBlob = pak.strAwayMessage; + dbei.cbBlob = pak.idAckAwayMessage; + ProtoChainRecv(FindContact(cont->m_addr, cont->m_nick, true, false, false, cont->m_status), PSR_AWAYMSG, 0, (LPARAM)&dbei); } if (pak.idReqAwayMessage && cont) { @@ -320,16 +320,14 @@ void CMLan::RecvMessageUrl(CCSDATA *ccs) { Contact::Hide(ccs->hContact, false); - PROTORECVEVENT *pre = (PROTORECVEVENT*)ccs->lParam; - ptrA szMessage(mir_utf8encode(pre->szMessage)); + DB::EventInfo &dbei = *(DB::EventInfo *)ccs->lParam; + ptrA szMsg(mir_utf8encode(dbei.pBlob)); - DBEVENTINFO dbei = {}; dbei.eventType = EVENTTYPE_MESSAGE; dbei.szModule = MODULENAME; - dbei.timestamp = pre->timestamp; - dbei.flags = DBEF_UTF + ((pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0); - dbei.cbBlob = (uint32_t)mir_strlen(szMessage) + 1; - dbei.pBlob = szMessage.get(); + dbei.flags |= DBEF_UTF; + dbei.cbBlob = (uint32_t)mir_strlen(szMsg) + 1; + dbei.pBlob = szMsg; db_event_add(ccs->hContact, &dbei); } @@ -375,8 +373,8 @@ int CMLan::GetAwayMsg(CCSDATA *ccs) int CMLan::RecvAwayMsg(CCSDATA *ccs) { - PROTORECVEVENT *pre = (PROTORECVEVENT*)ccs->lParam; - ProtoBroadcastAck(MODULENAME, ccs->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)pre->lParam, (LPARAM)pre->szMessage); + auto *pre = (DB::EventInfo *)ccs->lParam; + ProtoBroadcastAck(MODULENAME, ccs->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)pre->cbBlob, (LPARAM)pre->pBlob); return 0; } @@ -900,17 +898,14 @@ void CMLan::FileRemoveFromList(TFileConnection *conn) void CMLan::RecvFile(CCSDATA *ccs) { - PROTORECVEVENT *pre = (PROTORECVEVENT *)ccs->lParam; + auto &dbei = *(DB::EventInfo *)ccs->lParam; Contact::Hide(ccs->hContact, false); - char *szFile = pre->szMessage + sizeof(uint32_t); + char *szFile = dbei.pBlob + sizeof(uint32_t); char *szDesc = szFile + mir_strlen(szFile) + 1; - DB::EventInfo dbei; dbei.szModule = MODULENAME; - dbei.timestamp = pre->timestamp; - dbei.flags = pre->flags & (PREF_CREATEREAD ? DBEF_READ : 0); dbei.eventType = EVENTTYPE_FILE; DB::FILE_BLOB(_A2T(szFile), _A2T(szDesc)).write(dbei); db_event_add(ccs->hContact, &dbei); @@ -946,10 +941,10 @@ void CMLan::OnInTCPConnection(u_long addr, SOCKET in_sock) int rcTotalSize = *((int*)(conn->m_buf + 1)); int rcTotalFiles = *((int*)(conn->m_buf + 1 + 4)); - PROTORECVEVENT pre; - pre.szMessage = new char[conn->m_recSize + rcTotalFiles]; - *((int*)pre.szMessage) = conn->m_cid; - char* pf_to = pre.szMessage + 4; + DB::EventInfo dbei; + dbei.pBlob = (char*)mir_alloc(conn->m_recSize + rcTotalFiles); + *((int*)dbei.pBlob) = conn->m_cid; + char* pf_to = dbei.pBlob + 4; char* pf_fr = (char*)conn->m_buf + 1 + 4 + 4; conn->m_szFiles = new wchar_t*[rcTotalFiles + 1]; @@ -971,12 +966,8 @@ void CMLan::OnInTCPConnection(u_long addr, SOCKET in_sock) *pf_to++ = *pf_fr++; conn->m_hContact = FindContact(cont->m_addr, cont->m_nick, true, false, false, cont->m_status); - pre.flags = 0; - pre.timestamp = get_time(); - pre.lParam = 0; - ProtoChainRecv(conn->m_hContact, PSR_FILE, 0, (LPARAM)&pre); - - delete[] pre.szMessage; + dbei.timestamp = get_time(); + ProtoChainRecv(conn->m_hContact, PSR_FILE, 0, (LPARAM)&dbei); while (!conn->m_state) Sleep(10); diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index 14f71fc032..63f6f9d09a 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -844,15 +844,15 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root) // if that's a group chat, send it to the room
auto szActorFbId(metadata["actorFbId"].as_string());
- PROTORECVEVENT pre = {};
- pre.timestamp = uint32_t(_wtoi64(metadata["timestamp"].as_mstring()) / 1000);
- pre.szMessage = (char *)szBody.c_str();
- pre.szMsgId = (char *)szId.c_str();
+ DB::EventInfo dbei;
+ dbei.timestamp = uint32_t(_wtoi64(metadata["timestamp"].as_mstring()) / 1000);
+ dbei.pBlob = (char *)szBody.c_str();
+ dbei.szId = (char *)szId.c_str();
if (m_uid == _atoi64(szActorFbId.c_str()))
- pre.flags |= PREF_SENT;
+ dbei.flags |= DBEF_SENT;
if (pUser->bIsChat)
- pre.szUserId = szActorFbId.c_str();
- ProtoChainRecvMsg(pUser->hContact, &pre);
+ dbei.szUserId = szActorFbId.c_str();
+ ProtoChainRecvMsg(pUser->hContact, dbei);
}
// changing thread name
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index e7ed33b01b..6a84c1b251 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -822,11 +822,11 @@ retry: }
// Check if not empty message ( who needs it? )
else if (!e->event.msg.recipients_count && e->event.msg.message && *e->event.msg.message && mir_strcmp(e->event.msg.message, "\xA0\0")) {
- PROTORECVEVENT pre = {};
+ DB::EventInfo dbei;
time_t t = time(0);
- pre.timestamp = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
- pre.szMessage = e->event.msg.message;
- ProtoChainRecvMsg(getcontact(e->event.msg.sender, 1, 0, nullptr), &pre);
+ dbei.timestamp = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
+ dbei.pBlob = e->event.msg.message;
+ ProtoChainRecvMsg(getcontact(e->event.msg.sender, 1, 0, nullptr), dbei);
}
// RichEdit format included (image)
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 595151e1ed..79ffd36e22 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -866,10 +866,10 @@ int GaduProto::img_displayasmsg(MCONTACT hContact, void *img) mir_snwprintf(image_msg, L"[img]%s[/img]", szPath);
T2Utf szMessage(image_msg);
- PROTORECVEVENT pre = {};
- pre.timestamp = time(0);
- pre.szMessage = szMessage;
- ProtoChainRecvMsg(hContact, &pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = time(0);
+ dbei.pBlob = szMessage;
+ ProtoChainRecvMsg(hContact, dbei);
debugLogW(L"img_displayasmsg(): Image saved to %s.", szPath);
}
else
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index ffefe1846c..48f94f5714 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -467,9 +467,9 @@ MCONTACT CIcqProto::AddToList(int, PROTOSEARCHRESULT *psr) ////////////////////////////////////////////////////////////////////////////////////////
// PSR_AUTH
-int CIcqProto::AuthRecv(MCONTACT, PROTORECVEVENT *pre)
+int CIcqProto::AuthRecv(MCONTACT, DB::EventInfo &dbei)
{
- return Proto_AuthRecv(m_szModuleName, pre);
+ return Proto_AuthRecv(m_szModuleName, dbei);
}
////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index eb363bffd5..7fe31a13e0 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -425,7 +425,7 @@ class CIcqProto : public PROTO<CIcqProto> MCONTACT AddToList( int flags, PROTOSEARCHRESULT *psr) override;
- int AuthRecv(MCONTACT, PROTORECVEVENT *pre) override;
+ int AuthRecv(MCONTACT, DB::EventInfo &dbei) override;
int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override;
INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override;
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index ae12f8de57..d86c76cfc5 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -87,13 +87,13 @@ MCONTACT CIcqProto::CheckOwnMessage(const CMStringA &reqId, const CMStringA &msg else {
T2Utf szOwnId(m_szOwnId);
- PROTORECVEVENT pre = {};
- pre.szMsgId = msgId.c_str();
- pre.timestamp = time(0);
- pre.szMessage = pOwn->m_szText;
- pre.flags = PREF_SENT | PREF_CREATEREAD;
- pre.szUserId = szOwnId;
- ProtoChainRecvMsg(pOwn->m_hContact, &pre);
+ DB::EventInfo dbei;
+ dbei.szId = msgId.c_str();
+ dbei.timestamp = time(0);
+ dbei.pBlob = pOwn->m_szText;
+ dbei.flags = DBEF_SENT | DBEF_READ;
+ dbei.szUserId = szOwnId;
+ ProtoChainRecvMsg(pOwn->m_hContact, dbei);
}
if (bRemove) {
@@ -495,11 +495,11 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo CMStringA nick = (pos == -1) ? id : id.Left(pos);
DB::AUTH_BLOB blob(hContact, nick, nullptr, nullptr, id, nullptr);
- PROTORECVEVENT pre = {};
- pre.timestamp = (uint32_t)time(0);
- pre.lParam = blob.size();
- pre.szMessage = blob;
- ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = (uint32_t)time(0);
+ dbei.cbBlob = blob.size();
+ dbei.pBlob = blob;
+ ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei);
}
return;
}
@@ -626,38 +626,29 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo ptrA szUtf(mir_utf8encodeW(wszText));
- if (hOldEvent) {
- DBEVENTINFO dbei = {};
- dbei.szModule = m_szModuleName;
- dbei.timestamp = iMsgTime;
- dbei.flags = DBEF_UTF;
- if (bIsOutgoing)
- dbei.flags |= DBEF_SENT;
- if (bCreateRead)
- dbei.flags |= DBEF_READ;
- dbei.cbBlob = (int)mir_strlen(szUtf);
- dbei.pBlob = szUtf.get();
- dbei.szId = szMsgId;
- if (isChatRoom(hContact))
- dbei.szUserId = szSender;
- if (!szReply.IsEmpty())
- dbei.szReplyId = szReply;
+ DB::EventInfo dbei(hOldEvent);
+ dbei.szModule = m_szModuleName;
+ dbei.timestamp = iMsgTime;
+ dbei.flags = DBEF_UTF;
+ if (bIsOutgoing)
+ dbei.flags |= DBEF_SENT;
+ if (bCreateRead)
+ dbei.flags |= DBEF_READ;
+ dbei.cbBlob = (int)mir_strlen(szUtf);
+ dbei.pBlob = szUtf.get();
+ dbei.szId = szMsgId;
+ if (isChatRoom(hContact))
+ dbei.szUserId = szSender;
+ if (!szReply.IsEmpty())
+ dbei.szReplyId = szReply;
+
+ if (dbei) {
+ replaceStr(dbei.pBlob, szUtf.detach());
db_event_edit(hOldEvent, &dbei, true);
}
else {
- PROTORECVEVENT pre = {};
- pre.timestamp = iMsgTime;
- pre.szMessage = szUtf;
- if (bIsOutgoing)
- pre.flags |= PREF_SENT;
- if (bCreateRead)
- pre.flags |= PREF_CREATEREAD;
- pre.szMsgId = szMsgId;
- if (isChatRoom(hContact))
- pre.szUserId = szSender;
- if (!szReply.IsEmpty())
- pre.szReplyId = szReply;
- ProtoChainRecvMsg(hContact, &pre);
+ dbei.pBlob = szUtf;
+ ProtoChainRecvMsg(hContact, dbei);
}
}
diff --git a/protocols/ICQCorp/src/protocol.cpp b/protocols/ICQCorp/src/protocol.cpp index cb24b1ddf4..576bf6eb76 100644 --- a/protocols/ICQCorp/src/protocol.cpp +++ b/protocols/ICQCorp/src/protocol.cpp @@ -1984,18 +1984,10 @@ void ICQ::addMessage(ICQUser *u, char *m, time_t t) {
Netlib_Logf(hNetlibUser, "message: %s\n", m);
- PROTORECVEVENT pre;
- pre.flags = 0;
- pre.timestamp = t;
- pre.szMessage = (char*)m;
- pre.lParam = 0;
-
- CCSDATA ccs;
- ccs.hContact = u->hContact;
- ccs.szProtoService = PSR_MESSAGE;
- ccs.wParam = 0;
- ccs.lParam = (LPARAM)⪯
- Proto_ChainRecv(0, &ccs);
+ DB::EventInfo dbei;
+ dbei.timestamp = t;
+ dbei.pBlob = m;
+ ProtoChainRecvMsg(u->hContact, dbei);
}
///////////////////////////////////////////////////////////////////////////////
@@ -2004,17 +1996,12 @@ void ICQ::addAwayMsg(ICQUser *u, char *m, unsigned long theSequence, time_t t) {
Netlib_Logf(hNetlibUser, "away msg: %s\n", m);
- PROTORECVEVENT pre;
- pre.flags = 0;
- pre.timestamp = t;
- pre.szMessage = (char*)m;
- pre.lParam = theSequence;
-
- CCSDATA ccs;
- ccs.hContact = u->hContact;
- ccs.szProtoService = PSR_AWAYMSG;
- ccs.wParam = u->statusVal;
- ccs.lParam = (LPARAM)⪯
+ DB::EventInfo dbei;
+ dbei.timestamp = t;
+ dbei.pBlob = m;
+ dbei.cbBlob = theSequence;
+
+ CCSDATA ccs = { u->hContact, PSR_AWAYMSG, u->statusVal, (LPARAM)&dbei };
Proto_ChainRecv(0, &ccs);
}
@@ -2029,26 +2016,16 @@ void ICQ::addFileReq(ICQUser *u, char *m, char *filename, unsigned long size, un icqTransfers.push_back(transfer);
// Send chain event
- char *szBlob = new char[sizeof(uint32_t) + mir_strlen(filename) + mir_strlen(m) + 2];
-
- *(PDWORD)szBlob = (UINT_PTR)transfer;
- mir_strcpy(szBlob + sizeof(uint32_t), filename);
- mir_strcpy(szBlob + sizeof(uint32_t) + mir_strlen(filename) + 1, m);
-
- PROTORECVEVENT pre;
- pre.flags = 0;
- pre.timestamp = t;
- pre.szMessage = szBlob;
- pre.lParam = theSequence;
-
- CCSDATA ccs;
- ccs.hContact = u->hContact;
- ccs.szProtoService = PSR_FILE;
- ccs.wParam = 0;
- ccs.lParam = (LPARAM)⪯
+ DB::FILE_BLOB blob(transfer, filename, m);
+
+ DB::EventInfo dbei;
+ dbei.timestamp = t;
+ blob.write(dbei);
+
+ CCSDATA ccs = { u->hContact, PSR_FILE, 0, (LPARAM)&dbei };
Proto_ChainRecv(0, &ccs);
- delete[] szBlob;
+ mir_free(dbei.pBlob);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/ICQCorp/src/services.cpp b/protocols/ICQCorp/src/services.cpp index 8dc6f047dd..d68f44e266 100644 --- a/protocols/ICQCorp/src/services.cpp +++ b/protocols/ICQCorp/src/services.cpp @@ -183,18 +183,14 @@ static INT_PTR icqRecvMessage(WPARAM, LPARAM lParam) CCSDATA *ccs = (CCSDATA*)lParam;
Contact::Hide(ccs->hContact, false);
- PROTORECVEVENT *pre = (PROTORECVEVENT*)ccs->lParam;
- ptrA szMsg(mir_utf8encode(pre->szMessage));
+ auto &dbei = *(DB::EventInfo*)ccs->lParam;
+ ptrA szMsg(mir_utf8encode(dbei.pBlob));
- DBEVENTINFO dbei = {};
dbei.szModule = protoName;
- dbei.timestamp = pre->timestamp;
dbei.flags = DBEF_UTF;
- if (pre->flags & PREF_CREATEREAD)
- dbei.flags |= DBEF_READ;
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.cbBlob = (uint32_t)mir_strlen(szMsg) + 1;
- dbei.pBlob = szMsg.get();
+ dbei.pBlob = szMsg;
db_event_add(ccs->hContact, &dbei);
return 0;
}
@@ -235,8 +231,8 @@ static INT_PTR icqRecvAwayMsg(WPARAM, LPARAM lParam) Netlib_Logf(hNetlibUser, "[ ] receive away message\n");
CCSDATA *ccs = (CCSDATA *)lParam;
- PROTORECVEVENT *pre = (PROTORECVEVENT *)ccs->lParam;
- ProtoBroadcastAck(protoName, ccs->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)pre->lParam, _A2T(pre->szMessage));
+ auto *dbei = (DB::EventInfo *)ccs->lParam;
+ ProtoBroadcastAck(protoName, ccs->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)dbei->cbBlob, _A2T(dbei->pBlob));
return 0;
}
@@ -356,16 +352,9 @@ static INT_PTR icqRecvFile(WPARAM, LPARAM lParam) CCSDATA *ccs = (CCSDATA *)lParam;
Contact::Hide(ccs->hContact, false);
- PROTORECVEVENT *pre = (PROTORECVEVENT *)ccs->lParam;
- char *szFile = pre->szMessage + sizeof(uint32_t);
- char *szDesc = szFile + mir_strlen(szFile) + 1;
-
- DB::EventInfo dbei;
+ auto &dbei = *(DB::EventInfo *)ccs->lParam;
dbei.szModule = protoName;
- dbei.timestamp = pre->timestamp;
- dbei.flags = pre->flags & (PREF_CREATEREAD ? DBEF_READ : 0);
dbei.eventType = EVENTTYPE_FILE;
- DB::FILE_BLOB(_A2T(szFile), _A2T(szDesc)).write(dbei);
db_event_add(ccs->hContact, &dbei);
return 0;
}
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index f36ec8d236..28350171b2 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -697,14 +697,14 @@ bool CIrcProto::OnIrc_PRIVMSG(const CIrcMessage *pmsg) }
MCONTACT hContact = CList_AddContact(&user, false, true);
+ T2Utf utf(mess);
- PROTORECVEVENT pre = {};
- pre.timestamp = (uint32_t)time(0);
- pre.szMessage = mir_utf8encodeW(mess);
+ DB::EventInfo dbei;
+ dbei.timestamp = (uint32_t)time(0);
+ dbei.pBlob = utf;
setWString(hContact, "User", pmsg->prefix.sUser);
setWString(hContact, "Host", pmsg->prefix.sHost);
- ProtoChainRecvMsg(hContact, &pre);
- mir_free(pre.szMessage);
+ ProtoChainRecvMsg(hContact, dbei);
return true;
}
diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp index 4b6737f153..2861324bb0 100644 --- a/protocols/IRCG/src/irclib.cpp +++ b/protocols/IRCG/src/irclib.cpp @@ -1274,10 +1274,10 @@ void CDccSession::DoChatReceive() if (*pStart) { // send it off to some messaging module - PROTORECVEVENT pre = {}; - pre.timestamp = (uint32_t)time(0); - pre.szMessage = pStart; - ProtoChainRecvMsg(di->hContact, &pre); + DB::EventInfo dbei; + dbei.timestamp = (uint32_t)time(0); + dbei.pBlob = pStart; + ProtoChainRecvMsg(di->hContact, dbei); } cbInBuf -= pEnd - pStart; diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index 10900907f1..ed17240b5b 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -871,11 +871,11 @@ bool CJabberProto::FtTryInlineFile(filetransfer *ft) // emulate a message for us
CMStringA szMsg(FORMAT, "[img]%s[/img]", T2Utf(wszFileName).get());
- PROTORECVEVENT recv = {};
- recv.flags = PREF_CREATEREAD | PREF_SENT;
- recv.szMessage = szMsg.GetBuffer();
- recv.timestamp = time(0);
- ProtoChainRecvMsg(ft->std.hContact, &recv);
+ DB::EventInfo dbei;
+ dbei.flags = DBEF_READ | DBEF_SENT;
+ dbei.pBlob = szMsg.GetBuffer();
+ dbei.timestamp = time(0);
+ ProtoChainRecvMsg(ft->std.hContact, dbei);
return true;
}
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index a8e859f5ac..c1b7705855 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -52,11 +52,11 @@ void CJabberProto::DBAddAuthRequest(const char *jid, const char *nick) DB::AUTH_BLOB blob(hContact, nick, nullptr, nullptr, jid, nullptr);
- PROTORECVEVENT pre = {};
- pre.timestamp = (uint32_t)time(0);
- pre.lParam = blob.size();
- pre.szMessage = blob;
- ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = (uint32_t)time(0);
+ dbei.cbBlob = blob.size();
+ dbei.pBlob = blob;
+ ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei);
debugLogA("Setup DBAUTHREQUEST with nick='%s' jid='%s'", blob.get_nick(), blob.get_email());
}
@@ -499,10 +499,10 @@ void CJabberProto::OnGetBob(const TiXmlElement *node, CJabberIqInfo *pReq) wszFileName.Insert(0, L"[img]"); wszFileName.Append(L"[/img]");
T2Utf szMsg(wszFileName);
- PROTORECVEVENT pre = {};
- pre.timestamp = time(0);
- pre.szMessage = szMsg;
- ProtoChainRecvMsg(pReq->GetHContact(), &pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = time(0);
+ dbei.pBlob = szMsg;
+ ProtoChainRecvMsg(pReq->GetHContact(), dbei);
}
}
}
diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index f2e018e136..da350e9deb 100644 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -1377,14 +1377,14 @@ bool CJabberProto::OmemoHandleMessage(const TiXmlElement *node, const char *jid, db_event_add(hContact, &dbei);
}
else {
- PROTORECVEVENT recv = {};
- recv.timestamp = (uint32_t)msgTime;
- recv.szMessage = result.GetBuffer();
+ DB::EventInfo dbei;
+ dbei.timestamp = (uint32_t)msgTime;
+ dbei.pBlob = result.GetBuffer();
if (trusted)
- recv.flags = PREF_ENCRYPTED;
+ dbei.flags = DBEF_STRONG;
if (isCarbon)
- recv.flags = PREF_SENT;
- ProtoChainRecvMsg(hContact, &recv);
+ dbei.flags = DBEF_SENT;
+ ProtoChainRecvMsg(hContact, dbei);
}
return true;
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index e9c9858219..193ad5d92f 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -454,9 +454,9 @@ int CJabberProto::AuthDeny(MEVENT hDbEvent, const wchar_t*) ////////////////////////////////////////////////////////////////////////////////////////
// AuthRecv - receives a auth
-int CJabberProto::AuthRecv(MCONTACT, PROTORECVEVENT *pre)
+int CJabberProto::AuthRecv(MCONTACT, DB::EventInfo &dbei)
{
- return Proto_AuthRecv(m_szModuleName, pre);
+ return Proto_AuthRecv(m_szModuleName, dbei);
}
////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 74265aca85..3a982c1958 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -119,7 +119,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface int Authorize(MEVENT hDbEvent) override;
int AuthDeny(MEVENT hDbEvent, const wchar_t *szReason) override;
- int AuthRecv(MCONTACT, PROTORECVEVENT *pre) override;
+ int AuthRecv(MCONTACT, DB::EventInfo &dbei) override;
int AuthRequest(MCONTACT, const wchar_t *pwszReason) override;
HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szPath) override;
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 27fe3246a9..fd8a9abf68 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1416,17 +1416,17 @@ void CJabberProto::OnProcessMessage(const TiXmlElement *node, ThreadData *info) if (!bOffline)
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
- PROTORECVEVENT recv = {};
+ DB::EventInfo dbei;
if (bCreateRead)
- recv.flags |= PREF_CREATEREAD;
+ dbei.flags |= DBEF_READ;
if (bWasSent)
- recv.flags |= PREF_SENT;
+ dbei.flags |= DBEF_SENT;
- recv.timestamp = (uint32_t)msgTime;
- recv.szMessage = szMessage.GetBuffer();
- recv.szMsgId = szMsgId;
+ dbei.timestamp = (uint32_t)msgTime;
+ dbei.pBlob = szMessage.GetBuffer();
+ dbei.szId = szMsgId;
- MEVENT hDbEVent = (MEVENT)ProtoChainRecvMsg(hContact, &recv);
+ MEVENT hDbEVent = (MEVENT)ProtoChainRecvMsg(hContact, dbei);
if (idStr)
m_arChatMarks.insert(new CChatMark(hDbEVent, idStr, from));
}
diff --git a/protocols/NewsAggregator/Src/CheckFeed.cpp b/protocols/NewsAggregator/Src/CheckFeed.cpp index 60502647cc..b15724266c 100644 --- a/protocols/NewsAggregator/Src/CheckFeed.cpp +++ b/protocols/NewsAggregator/Src/CheckFeed.cpp @@ -187,10 +187,10 @@ static void XmlToMsg(MCONTACT hContact, CMStringW &title, CMStringW &link, CMStr T2Utf pszMessage(message); - PROTORECVEVENT recv = {}; - recv.timestamp = (uint32_t)stamp; - recv.szMessage = pszMessage; - ProtoChainRecvMsg(hContact, &recv); + DB::EventInfo dbei; + dbei.timestamp = (uint32_t)stamp; + dbei.pBlob = pszMessage; + ProtoChainRecvMsg(hContact, dbei); } } diff --git a/protocols/NewsAggregator/Src/Services.cpp b/protocols/NewsAggregator/Src/Services.cpp index f809cd4058..3f0a4855ba 100644 --- a/protocols/NewsAggregator/Src/Services.cpp +++ b/protocols/NewsAggregator/Src/Services.cpp @@ -159,7 +159,7 @@ INT_PTR NewsAggrRecvMessage(WPARAM, LPARAM lParam) PROTOACCOUNT *pa = Proto_GetAccount(MODULENAME); if (pa && pa->ppro) { CCSDATA *ccs = (CCSDATA*)lParam; - pa->ppro->PROTO_INTERFACE::RecvMsg(ccs->hContact, (PROTORECVEVENT*)ccs->lParam); + pa->ppro->PROTO_INTERFACE::RecvMsg(ccs->hContact, *(DB::EventInfo*)ccs->lParam); } return 0; diff --git a/protocols/Sametime/src/messaging.cpp b/protocols/Sametime/src/messaging.cpp index 4def7ca30d..15650b9c6f 100644 --- a/protocols/Sametime/src/messaging.cpp +++ b/protocols/Sametime/src/messaging.cpp @@ -81,11 +81,10 @@ void mwIm_conversation_recv(mwConversation* conv, mwImSendType type, gconstpoint if (type != mwImSend_PLAIN)
return;
- PROTORECVEVENT pre = {};
- time_t t = time(0);
- pre.timestamp = t;
- pre.szMessage = (char*)msg;
- ProtoChainRecvMsg(hContact, &pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = time(0);
+ dbei.pBlob = (char*)msg;
+ ProtoChainRecvMsg(hContact, dbei);
}
void mwIm_place_invite(struct mwConversation* conv, const char* message, const char*, const char*)
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index 1174ec9481..9359562cca 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -171,14 +171,14 @@ MEVENT CSametimeProto::RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::Even return CSuper::RecvFile(hContact, blob, dbei);
}
-MEVENT CSametimeProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre)
+MEVENT CSametimeProto::RecvMsg(MCONTACT hContact, DB::EventInfo &dbei)
{
debugLogW(L"CSametimeProto::RecvMsg() hContact=[%x]", hContact);
Contact::Hide(hContact, false);
Contact::PutOnList(hContact);
- return CSuper::RecvMsg(hContact, pre);
+ return CSuper::RecvMsg(hContact, dbei);
}
HANDLE CSametimeProto::SendFile(MCONTACT hContact, const wchar_t* szDescription, wchar_t** ppszFiles)
diff --git a/protocols/Sametime/src/sametime_proto.h b/protocols/Sametime/src/sametime_proto.h index 11d5002beb..b1eb82a7b0 100644 --- a/protocols/Sametime/src/sametime_proto.h +++ b/protocols/Sametime/src/sametime_proto.h @@ -25,7 +25,7 @@ struct CSametimeProto : public PROTO<CSametimeProto> HWND CreateExtendedSearchUI(HWND owner) override;
MEVENT RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei) override;
- MEVENT RecvMsg(MCONTACT hContact, PROTORECVEVENT*) override;
+ MEVENT RecvMsg(MCONTACT hContact, DB::EventInfo &dbei) override;
HANDLE SendFile(MCONTACT hContact, const wchar_t* szDescription, wchar_t** ppszFiles) override;
int SendMsg(MCONTACT hContact, MEVENT, const char* msg) override;
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index 52b04369fd..c16ccaa97a 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -130,12 +130,11 @@ void CSkypeProto::LoadContactsAuth(MHttpResponse *response, AsyncHttpRequest*) DB::AUTH_BLOB blob(hContact, displayName.c_str(), nullptr, nullptr, skypeId.c_str(), reason.c_str());
- PROTORECVEVENT pre = {};
- pre.timestamp = time(0);
- pre.lParam = blob.size();
- pre.szMessage = blob;
-
- ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = time(0);
+ dbei.cbBlob = blob.size();
+ dbei.pBlob = blob;
+ ProtoChainRecv(hContact, PSR_AUTH, 0, dbei);
}
}
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 99a84cb78d..ddb4af3433 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -134,12 +134,12 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node) EditEvent(hDbEvent, wszContent, timestamp);
else {
T2Utf szMsg(wszContent);
- PROTORECVEVENT recv = {};
- recv.timestamp = timestamp;
- recv.szMessage = szMsg;
- recv.lParam = nEmoteOffset;
- recv.szMsgId = szMessageId;
- ProtoChainRecvMsg(hContact, &recv);
+ DB::EventInfo dbei;
+ dbei.timestamp = timestamp;
+ dbei.pBlob = szMsg;
+ dbei.cbBlob = nEmoteOffset;
+ dbei.szId = szMessageId;
+ ProtoChainRecvMsg(hContact, dbei);
}
}
}
@@ -214,25 +214,17 @@ void CSkypeProto::ProcessContactRecv(MCONTACT hContact, time_t timestamp, const }
if (nCount) {
- PROTORECVEVENT pre = {};
- pre.timestamp = (uint32_t)timestamp;
- pre.szMessage = (char*)psr;
-
- uint8_t *b = (uint8_t*)mir_calloc(sizeof(uint32_t) + mir_strlen(szMessageId) + 1);
- uint8_t *pCur = b;
- *((PDWORD)pCur) = nCount;
- pCur += sizeof(uint32_t);
-
- mir_strcpy((char*)pCur, szMessageId);
-
- pre.lParam = (LPARAM)b;
-
- ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
- for (uint32_t i = 0; i < *((PDWORD)b); i++) {
+ DB::EventInfo dbei;
+ dbei.timestamp = (uint32_t)timestamp;
+ dbei.pBlob = (char*)psr;
+ dbei.cbBlob = nCount;
+ dbei.szId = szMessageId;
+
+ ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&dbei);
+ for (int i = 0; i < nCount; i++) {
mir_free(psr[i]->id.a);
mir_free(psr[i]);
}
- mir_free(b);
}
mir_free(psr);
}
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index 17fd5b2426..3e77308bbf 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -201,9 +201,9 @@ int CSkypeProto::AuthDeny(MEVENT hDbEvent, const wchar_t*) return 0;
}
-int CSkypeProto::AuthRecv(MCONTACT, PROTORECVEVENT* pre)
+int CSkypeProto::AuthRecv(MCONTACT, DB::EventInfo &dbei)
{
- return Proto_AuthRecv(m_szModuleName, pre);
+ return Proto_AuthRecv(m_szModuleName, dbei);
}
int CSkypeProto::AuthRequest(MCONTACT hContact, const wchar_t *szMessage)
@@ -273,18 +273,15 @@ int CSkypeProto::UserIsTyping(MCONTACT hContact, int type) return 0;
}
-int CSkypeProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
+int CSkypeProto::RecvContacts(MCONTACT hContact, DB::EventInfo &dbei)
{
- PROTOSEARCHRESULT **isrList = (PROTOSEARCHRESULT**)pre->szMessage;
+ PROTOSEARCHRESULT **isrList = (PROTOSEARCHRESULT**)dbei.pBlob;
- int nCount = *((LPARAM*)pre->lParam);
- char* szMessageId = ((char*)pre->lParam + sizeof(LPARAM));
-
- //if (GetMessageFromDb(hContact, szMessageId, pre->timestamp)) return 0;
+ int nCount = dbei.cbBlob;
uint32_t cbBlob = 0;
for (int i = 0; i < nCount; i++)
- cbBlob += int(/*mir_wstrlen(isrList[i]->nick.w)*/0 + 2 + mir_wstrlen(isrList[i]->id.w) + mir_strlen(szMessageId));
+ cbBlob += int(/*mir_wstrlen(isrList[i]->nick.w)*/0 + 2 + mir_wstrlen(isrList[i]->id.w));
char *pBlob = (char *)mir_calloc(cbBlob);
char *pCurBlob = pBlob;
@@ -296,13 +293,10 @@ int CSkypeProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre) pCurBlob += mir_strlen(pCurBlob) + 1;
}
- DBEVENTINFO dbei = {};
dbei.szModule = m_szModuleName;
- dbei.timestamp = pre->timestamp;
dbei.eventType = EVENTTYPE_CONTACTS;
dbei.cbBlob = cbBlob;
dbei.pBlob = pBlob;
- dbei.flags = (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0;
db_event_add(hContact, &dbei);
mir_free(pBlob);
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 11d91a6aa0..b2772ddc8d 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -55,14 +55,14 @@ public: int AuthRequest(MCONTACT hContact, const wchar_t* szMessage) override;
int Authorize(MEVENT hDbEvent) override;
int AuthDeny(MEVENT hDbEvent, const wchar_t* szReason) override;
- int AuthRecv(MCONTACT hContact, PROTORECVEVENT*) override;
+ int AuthRecv(MCONTACT hContact, DB::EventInfo &dbei) override;
INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override;
int GetInfo(MCONTACT hContact, int infoType) override;
HANDLE SearchBasic(const wchar_t* id) override;
int SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char* msg) override;
int SetStatus(int iNewStatus) override;
int UserIsTyping(MCONTACT hContact, int type) override;
- int RecvContacts(MCONTACT hContact, PROTORECVEVENT*) override;
+ int RecvContacts(MCONTACT hContact, DB::EventInfo &dbei) override;
HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override;
HANDLE GetAwayMsg(MCONTACT hContact) override;
int SetAwayMsg(int m_iStatus, const wchar_t *msg) override;
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index 9ed0746a48..8f0d7e3306 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -308,11 +308,11 @@ void CSteamProto::ContactIsAskingAuth(MCONTACT hContact) DB::AUTH_BLOB blob(hContact, nickName, firstName, lastName, steamId, reason); - PROTORECVEVENT recv = {}; - recv.timestamp = now(); - recv.szMessage = blob; - recv.lParam = blob.size(); - ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&recv); + DB::EventInfo dbei; + dbei.timestamp = now(); + dbei.pBlob = blob; + dbei.cbBlob = blob.size(); + ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei); } MCONTACT CSteamProto::AddContact(const char *steamId, const wchar_t *nick, bool isTemporary) diff --git a/protocols/Steam/src/steam_history.cpp b/protocols/Steam/src/steam_history.cpp index 9590ceb26d..a57f59a9e3 100644 --- a/protocols/Steam/src/steam_history.cpp +++ b/protocols/Steam/src/steam_history.cpp @@ -53,14 +53,14 @@ void CSteamProto::OnGotHistoryMessages(const JSONNode &root, void *arg) if (timestamp <= storedMessageTS) continue; - PROTORECVEVENT recv = {}; - recv.timestamp = timestamp; - recv.szMessage = (char *)text.c_str(); + DB::EventInfo dbei; + dbei.timestamp = timestamp; + dbei.pBlob = (char *)text.c_str(); if (IsMe(steamId)) - recv.flags = PREF_SENT; + dbei.flags = DBEF_SENT; - RecvMsg(hContact, &recv); + RecvMsg(hContact, dbei); if (timestamp > newTS) newTS = timestamp; diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index f41698b34b..7cb7ec5ae5 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -139,11 +139,11 @@ int CSteamProto::Authorize(MEVENT hDbEvent) return 1;
}
-int CSteamProto::AuthRecv(MCONTACT hContact, PROTORECVEVENT *pre)
+int CSteamProto::AuthRecv(MCONTACT hContact, DB::EventInfo &dbei)
{
// remember to not create this event again, unless authorization status changes again
setByte(hContact, "AuthAsked", 1);
- return Proto_AuthRecv(m_szModuleName, pre);
+ return Proto_AuthRecv(m_szModuleName, dbei);
}
int CSteamProto::AuthDeny(MEVENT hDbEvent, const wchar_t*)
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 8cb7fdf0c0..7110861a58 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -268,7 +268,7 @@ public: MCONTACT AddToListByEvent(int flags, int iContact, MEVENT hDbEvent) override;
int Authorize(MEVENT hDbEvent) override;
- int AuthRecv(MCONTACT, PROTORECVEVENT*) override;
+ int AuthRecv(MCONTACT, DB::EventInfo &dbei) override;
int AuthDeny(MEVENT hDbEvent, const wchar_t *szReason) override;
int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override;
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 8fd72e3e59..8c39fe9a0f 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -787,40 +787,27 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage) Contact::RemoveFromList(pUser->hContact);
}
- if (hOldEvent) {
- DB::EventInfo dbei(hOldEvent);
- mir_free(dbei.pBlob);
- dbei.cbBlob = szText.GetLength();
- dbei.pBlob = szText.GetBuffer();
- dbei.timestamp = pMessage->date_;
- if (pMessage->is_outgoing_)
- dbei.flags |= DBEF_SENT;
- if (!pUser->bInited)
- dbei.flags |= DBEF_READ;
- if (GetGcUserId(pUser, pMessage, szUserId))
- dbei.szUserId = szUserId;
- if (pMessage->reply_to_message_id_) {
- szReplyId = msg2id(pMessage->chat_id_, pMessage->reply_to_message_id_);
- dbei.szReplyId = szReplyId;
- }
+ DB::EventInfo dbei(hOldEvent);
+ dbei.cbBlob = szText.GetLength();
+ dbei.timestamp = pMessage->date_;
+ if (pMessage->is_outgoing_)
+ dbei.flags |= DBEF_SENT;
+ if (!pUser->bInited)
+ dbei.flags |= DBEF_READ;
+ if (GetGcUserId(pUser, pMessage, szUserId))
+ dbei.szUserId = szUserId;
+ if (pMessage->reply_to_message_id_) {
+ szReplyId = msg2id(pMessage->chat_id_, pMessage->reply_to_message_id_);
+ dbei.szReplyId = szReplyId;
+ }
+
+ if (dbei) {
+ replaceStr(dbei.pBlob, szText.Detach());
db_event_edit(hOldEvent, &dbei, true);
}
else {
- PROTORECVEVENT pre = {};
- pre.szMessage = szText.GetBuffer();
- pre.szMsgId = szMsgId;
- pre.timestamp = pMessage->date_;
- if (pMessage->is_outgoing_)
- pre.flags |= PREF_SENT;
- if (!pUser->bInited)
- pre.flags |= PREF_CREATEREAD;
- if (GetGcUserId(pUser, pMessage, szUserId))
- pre.szUserId = szUserId;
- if (pMessage->reply_to_message_id_) {
- szReplyId = msg2id(pMessage->chat_id_, pMessage->reply_to_message_id_);
- pre.szReplyId = szReplyId;
- }
- ProtoChainRecvMsg(GetRealContact(pUser), &pre);
+ dbei.pBlob = szText.GetBuffer();
+ ProtoChainRecvMsg(GetRealContact(pUser), dbei);
}
}
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index db472e3ed0..869386523c 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -234,11 +234,11 @@ void CToxProto::OnFriendRequest(Tox*, const uint8_t *pubKey, const uint8_t *mess DB::AUTH_BLOB blob(hContact, nullptr, nullptr, nullptr, (LPCSTR)address, (LPCSTR)message);
- PROTORECVEVENT pre = {};
- pre.timestamp = now();
- pre.lParam = blob.size();
- pre.szMessage = blob;
- ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = now();
+ dbei.cbBlob = blob.size();
+ dbei.pBlob = blob;
+ ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei);
}
void CToxProto::OnFriendNameChange(Tox *tox, uint32_t friendNumber, const uint8_t *name, size_t length, void *arg)
diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp index 3cf6054f9e..74994f6ddd 100644 --- a/protocols/Tox/src/tox_messages.cpp +++ b/protocols/Tox/src/tox_messages.cpp @@ -51,18 +51,18 @@ void CToxProto::OnFriendMessage(Tox *tox, uint32_t friendNumber, TOX_MESSAGE_TYP else mir_strncpy(rawMessage, (const char*)message, length + 1);
rawMessage[length] = 0;
- PROTORECVEVENT recv = {};
- recv.timestamp = now();
- recv.szMessage = rawMessage;
+ DB::EventInfo dbei;
+ dbei.timestamp = now();
+ dbei.pBlob = rawMessage;
switch (type) {
case TOX_MESSAGE_TYPE_NORMAL:
- recv.lParam = EVENTTYPE_MESSAGE;
+ dbei.eventType = EVENTTYPE_MESSAGE;
break;
case TOX_MESSAGE_TYPE_ACTION:
- recv.lParam = DB_EVENT_ACTION;
+ dbei.eventType = DB_EVENT_ACTION;
break;
}
- ProtoChainRecvMsg(hContact, &recv);
+ ProtoChainRecvMsg(hContact, dbei);
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
}
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index d701171a0f..331475be6d 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -95,9 +95,9 @@ int CToxProto::Authorize(MEVENT hDbEvent) return OnGrantAuth(hContact, 0);
}
-int CToxProto::AuthRecv(MCONTACT, PROTORECVEVENT* pre)
+int CToxProto::AuthRecv(MCONTACT, DB::EventInfo &dbei)
{
- return Proto_AuthRecv(m_szModuleName, pre);
+ return Proto_AuthRecv(m_szModuleName, dbei);
}
int CToxProto::AuthRequest(MCONTACT hContact, const wchar_t *szMessage)
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index f5969c8f5e..36fde9576b 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -42,7 +42,7 @@ public: MCONTACT AddToList(int flags, PROTOSEARCHRESULT *psr) override;
int Authorize(MEVENT hDbEvent) override;
- int AuthRecv(MCONTACT hContact, PROTORECVEVENT *) override;
+ int AuthRecv(MCONTACT hContact, DB::EventInfo &dbei) override;
int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override;
HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t *tszPath) override;
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index d61254228d..34e4693848 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -539,18 +539,16 @@ void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessage T2Utf pszBody(pwszBody);
- PROTORECVEVENT pre = {};
- pre.szMsgId = szMid;
- pre.timestamp = tMsgTime;
- pre.szMessage = pszBody;
+ DB::EventInfo dbei;
+ dbei.szId = szMid;
+ dbei.timestamp = tMsgTime;
+ dbei.pBlob = pszBody;
if (iUserId == m_iMyUserId)
- pre.flags |= PREF_SENT;
+ dbei.flags |= DBEF_SENT;
if (bIsHistory)
- pre.flags |= PREF_CREATEREAD;
-
- pre.szUserId = szId;
-
- ProtoChainRecvMsg(hChatContact, &pre);
+ dbei.flags |= DBEF_READ;
+ dbei.szUserId = szId;
+ ProtoChainRecvMsg(hChatContact, dbei);
}
StopChatContactTyping(vkChatInfo->m_iChatId, iUserId);
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 1fc2a5587f..b3bc4e5424 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -55,16 +55,16 @@ void CVkProto::AddFeedEvent(CVKNewsItem& vkNewsItem) MCONTACT hContact = FindUser(VK_FEED_USER, true);
T2Utf pszBody(vkNewsItem.wszText);
- PROTORECVEVENT recv = {};
- recv.timestamp = vkNewsItem.tDate;
- recv.szMessage = pszBody;
+ DB::EventInfo dbei;
+ dbei.timestamp = vkNewsItem.tDate;
+ dbei.pBlob = pszBody;
if (m_vkOptions.bUseNonStandardNotifications) {
- recv.flags = PREF_CREATEREAD;
+ dbei.flags = DBEF_READ;
MsgPopup(hContact, vkNewsItem.wszPopupText, vkNewsItem.wszPopupTitle);
}
- ProtoChainRecvMsg(hContact, &recv);
+ ProtoChainRecvMsg(hContact, dbei);
}
void CVkProto::AddCListEvent(bool bNews)
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index fb40e9b444..bb386c812d 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -273,11 +273,11 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * wszBody += SetBBCString(TranslateT("Message link"), m_vkOptions.BBCForAttachments(), vkbbcUrl,
CMStringW(FORMAT, L"https://vk.com/im?sel=%d&msgid=%d", iUserId, iMessageId));
- PROTORECVEVENT recv = {};
+ DB::EventInfo dbei;
if (bIsRead)
- recv.flags |= PREF_CREATEREAD;
+ dbei.flags |= DBEF_READ;
if (bIsOut)
- recv.flags |= PREF_SENT;
+ dbei.flags |= DBEF_SENT;
time_t tUpdateTime = (time_t)jnMsg["update_time"].as_int();
if (tUpdateTime) {
@@ -298,14 +298,14 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * T2Utf pszBody(wszBody);
- recv.timestamp = tDateTime;
- recv.szMessage = pszBody;
- recv.szMsgId = szMid;
+ dbei.timestamp = tDateTime;
+ dbei.pBlob = pszBody;
+ dbei.szId = szMid;
if (!m_vkOptions.bShowReplyInMessage && szReplyId)
- recv.szReplyId = szReplyId;
+ dbei.szReplyId = szReplyId;
- ProtoChainRecvMsg(hContact, &recv);
+ ProtoChainRecvMsg(hContact, dbei);
MEVENT hDbEvent = db_event_getById(m_szModuleName, strcat(szMid, "_"));
if (hDbEvent)
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index ced871a809..89d6ec54cc 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -440,30 +440,29 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) wszOldMsg;
}
- PROTORECVEVENT recv = {};
+ DB::EventInfo dbei;
if (isRead && bUseServerReadFlag)
- recv.flags |= PREF_CREATEREAD;
+ dbei.flags |= DBEF_READ;
if (isOut)
- recv.flags |= PREF_SENT;
+ dbei.flags |= DBEF_SENT;
else if (m_vkOptions.bUserForceInvisibleOnActivity && ((time(0) - tDateTime) < (60 * m_vkOptions.iInvisibleInterval)))
SetInvisible(hContact);
T2Utf pszBody(wszBody);
- recv.timestamp = bEdited ? tDateTime : (m_vkOptions.bUseLocalTime ? time(0) : tDateTime);
- recv.szMessage = pszBody;
+ dbei.timestamp = bEdited ? tDateTime : (m_vkOptions.bUseLocalTime ? time(0) : tDateTime);
+ dbei.pBlob = pszBody;
if (!m_vkOptions.bShowReplyInMessage && szReplyId)
- recv.szReplyId = szReplyId;
+ dbei.szReplyId = szReplyId;
debugLogA("CVkProto::OnReceiveMessages mid = %d, datetime = %d, isOut = %d, isRead = %d, iUserId = %d, Edited = %d", iMessageId, tDateTime, isOut, isRead, iUserId, (int)bEdited);
-
if (!IsMessageExist(iMessageId, vkALL) || bEdited || (m_vkOptions.bShowReplyInMessage && szReplyId)) {
debugLogA("CVkProto::OnReceiveMessages new or edited message");
- recv.szMsgId = szMid;
- ProtoChainRecvMsg(hContact, &recv);
+ dbei.szId = szMid;
+ ProtoChainRecvMsg(hContact, dbei);
if (iMessageId > ReadQSWord(hContact, "lastmsgid", -1))
WriteQSWord(hContact, "lastmsgid", iMessageId);
}
@@ -479,10 +478,10 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) debugLogA("CVkProto::OnReceiveMessages add attachments");
T2Utf pszAttach(wszAttachmentDescr);
- recv.timestamp = isOut ? time(0) : tDateTime;
- recv.szMessage = pszAttach;
- recv.szMsgId = strcat(szMid, "_");
- ProtoChainRecvMsg(hContact, &recv);
+ dbei.timestamp = isOut ? time(0) : tDateTime;
+ dbei.pBlob = pszAttach;
+ dbei.szId = strcat(szMid, "_");
+ ProtoChainRecvMsg(hContact, dbei);
}
}
}
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp index 10bd5c7e43..00c0928749 100644 --- a/protocols/VKontakte/src/vk_pollserver.cpp +++ b/protocols/VKontakte/src/vk_pollserver.cpp @@ -137,9 +137,9 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates) m_vkOptions.BBCForAttachments(), vkbbcB) +
wszMsg;
- PROTORECVEVENT recv = {};
+ DB::EventInfo dbei;
if (iUserId == m_iMyUserId)
- recv.flags |= PREF_SENT;
+ dbei.flags |= DBEF_SENT;
else if (m_vkOptions.bUserForceInvisibleOnActivity && time(0) - tDateTime < 60 * m_vkOptions.iInvisibleInterval)
SetInvisible(hContact);
@@ -147,10 +147,10 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates) _itoa(iMessageId, szMid, 10);
T2Utf pszMsg(wszMsg);
- recv.timestamp = tDateTime;
- recv.szMessage = pszMsg;
- recv.szMsgId = szMid;
- ProtoChainRecvMsg(hContact, &recv);
+ dbei.timestamp = tDateTime;
+ dbei.pBlob = pszMsg;
+ dbei.szId = szMid;
+ ProtoChainRecvMsg(hContact, dbei);
}
break;
diff --git a/protocols/WhatsApp/src/appsync.cpp b/protocols/WhatsApp/src/appsync.cpp index 6eb435db02..62ca86b979 100644 --- a/protocols/WhatsApp/src/appsync.cpp +++ b/protocols/WhatsApp/src/appsync.cpp @@ -274,16 +274,16 @@ void WhatsAppProto::ProcessHistorySync(const Wa__HistorySync *pSync) if (!szMessageText.IsEmpty()) {
auto *key = pMessage->message->key;
- PROTORECVEVENT pre = {};
- pre.timestamp = pMessage->message->messagetimestamp;
- pre.szMessage = szMessageText.GetBuffer();
- pre.szMsgId = key->id;
- pre.flags = PREF_CREATEREAD;
+ DB::EventInfo dbei;
+ dbei.timestamp = pMessage->message->messagetimestamp;
+ dbei.pBlob = szMessageText.GetBuffer();
+ dbei.szId = key->id;
+ dbei.flags = DBEF_READ;
if (key->fromme)
- pre.flags |= PREF_SENT;
+ dbei.flags |= DBEF_SENT;
if (pUser->bIsGroupChat)
- pre.szUserId = key->participant;
- ProtoChainRecvMsg(pUser->hContact, &pre);
+ dbei.szUserId = key->participant;
+ ProtoChainRecvMsg(pUser->hContact, dbei);
}
}
}
diff --git a/protocols/WhatsApp/src/message.cpp b/protocols/WhatsApp/src/message.cpp index 96f23dde17..a664e49953 100644 --- a/protocols/WhatsApp/src/message.cpp +++ b/protocols/WhatsApp/src/message.cpp @@ -211,17 +211,17 @@ void WhatsAppProto::ProcessMessage(WAMSG type, const Wa__WebMessageInfo &msg) if (!szMessageText.IsEmpty()) {
// for chats & group chats store message in profile
if (type.bPrivateChat || type.bGroupChat) {
- PROTORECVEVENT pre = {};
- pre.timestamp = timestamp;
- pre.szMessage = szMessageText.GetBuffer();
- pre.szMsgId = msgId;
+ DB::EventInfo dbei;
+ dbei.timestamp = timestamp;
+ dbei.pBlob = szMessageText.GetBuffer();
+ dbei.szId = msgId;
if (type.bOffline)
- pre.flags |= PREF_CREATEREAD;
+ dbei.flags |= DBEF_READ;
if (key->fromme)
- pre.flags |= PREF_SENT;
+ dbei.flags |= DBEF_SENT;
if (pUser->bIsGroupChat)
- pre.szUserId = participant;
- ProtoChainRecvMsg(pUser->hContact, &pre);
+ dbei.szUserId = participant;
+ ProtoChainRecvMsg(pUser->hContact, dbei);
}
// translate statuses into status messages
else if (type.bOtherStatus || type.bDirectStatus || type.bPeerBroadcast || type.bOtherBroadcast) {
diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index 40aeeb1fb1..ab90a67a1f 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -91,7 +91,7 @@ void msgQueue_processack(MCONTACT hContact, int id, BOOL success, LPARAM lParam) DBEVENTINFO dbei = {};
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.flags = DBEF_SENT | DBEF_UTF | (p->flags & PREF_RTL ? DBEF_RTL : 0);
+ dbei.flags = DBEF_SENT | DBEF_UTF | (p->flags & DBEF_RTL ? DBEF_RTL : 0);
dbei.szModule = Proto_GetBaseAccountName(hContact);
dbei.timestamp = time(0);
dbei.cbBlob = (uint32_t)(mir_strlen(p->szMsg) + 1);
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 7e084916fa..88d2beccff 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -36,7 +36,7 @@ int SendMessageDirect(MCONTACT hContact, MEVENT hEvent, const wchar_t *szMsg) int flags = 0;
if (Utils_IsRtl(szMsg))
- flags |= PREF_RTL;
+ flags |= DBEF_RTL;
T2Utf sendBuffer(szMsg);
if (!mir_strlen(sendBuffer))
diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp index f8e34191de..45936d8900 100644 --- a/src/mir_app/src/db_events.cpp +++ b/src/mir_app/src/db_events.cpp @@ -264,7 +264,8 @@ DB::EventInfo::EventInfo() : DB::EventInfo::~EventInfo()
{
- mir_free(pBlob);
+ if (bValid)
+ mir_free(pBlob);
}
bool DB::EventInfo::fetch(MEVENT hEvent, bool bFetchBlob)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 7ebde24f72..42d8f60e6c 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -34,7 +34,7 @@ Button_SetSkin_IcoLib @24 ?AddToList@PROTO_INTERFACE@@UAEIHPAUPROTOSEARCHRESULT@@@Z @34 NONAME
?AddToListByEvent@PROTO_INTERFACE@@UAEIHHI@Z @35 NONAME
?AuthDeny@PROTO_INTERFACE@@UAEHIPB_W@Z @36 NONAME
-?AuthRecv@PROTO_INTERFACE@@UAEHIPAUPROTORECVEVENT@@@Z @37 NONAME
+?AuthRecv@PROTO_INTERFACE@@UAEHIAAVEventInfo@DB@@@Z @37 NONAME
?AuthRequest@PROTO_INTERFACE@@UAEHIPB_W@Z @38 NONAME
?Authorize@PROTO_INTERFACE@@UAEHI@Z @39 NONAME
?CreateExtendedSearchUI@PROTO_INTERFACE@@UAEPAUHWND__@@PAU2@@Z @40 NONAME
@@ -53,9 +53,9 @@ Button_SetSkin_IcoLib @24 ?OnProtoCheckOnline@CProtoIntDlgBase@@MAEXIJ@Z @54 NONAME
?OnProtoRefresh@CProtoIntDlgBase@@MAEXIJ@Z @55 NONAME
?ProtoBroadcastAck@PROTO_INTERFACE@@QAEHIHHPAXJ@Z @56 NONAME
-?RecvContacts@PROTO_INTERFACE@@UAEHIPAUPROTORECVEVENT@@@Z @58 NONAME
+?RecvContacts@PROTO_INTERFACE@@UAEHIAAVEventInfo@DB@@@Z @57 NONAME
?RecvFile@PROTO_INTERFACE@@UAEIIAAVFILE_BLOB@DB@@AAVEventInfo@3@@Z @59 NONAME
-?RecvMsg@PROTO_INTERFACE@@UAEIIPAUPROTORECVEVENT@@@Z @60 NONAME
+?RecvMsg@PROTO_INTERFACE@@UAEIIAAVEventInfo@DB@@@Z @60 NONAME
?SearchAdvanced@PROTO_INTERFACE@@UAEPAXPAUHWND__@@@Z @62 NONAME
?SearchBasic@PROTO_INTERFACE@@UAEPAXPB_W@Z @63 NONAME
?SearchByEmail@PROTO_INTERFACE@@UAEPAXPB_W@Z @64 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 6de004a53d..7274527130 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -34,7 +34,7 @@ Button_SetSkin_IcoLib @24 ?AddToList@PROTO_INTERFACE@@UEAAIHPEAUPROTOSEARCHRESULT@@@Z @34 NONAME
?AddToListByEvent@PROTO_INTERFACE@@UEAAIHHI@Z @35 NONAME
?AuthDeny@PROTO_INTERFACE@@UEAAHIPEB_W@Z @36 NONAME
-?AuthRecv@PROTO_INTERFACE@@UEAAHIPEAUPROTORECVEVENT@@@Z @37 NONAME
+?AuthRecv@PROTO_INTERFACE@@UEAAHIAEAVEventInfo@DB@@@Z @37 NONAME
?AuthRequest@PROTO_INTERFACE@@UEAAHIPEB_W@Z @38 NONAME
?Authorize@PROTO_INTERFACE@@UEAAHI@Z @39 NONAME
?CreateExtendedSearchUI@PROTO_INTERFACE@@UEAAPEAUHWND__@@PEAU2@@Z @40 NONAME
@@ -53,9 +53,9 @@ Button_SetSkin_IcoLib @24 ?OnProtoCheckOnline@CProtoIntDlgBase@@MEAAX_K_J@Z @54 NONAME
?OnProtoRefresh@CProtoIntDlgBase@@MEAAX_K_J@Z @55 NONAME
?ProtoBroadcastAck@PROTO_INTERFACE@@QEAA_JIHHPEAX_J@Z @56 NONAME
-?RecvContacts@PROTO_INTERFACE@@UEAAHIPEAUPROTORECVEVENT@@@Z @58 NONAME
+?RecvContacts@PROTO_INTERFACE@@UEAAHIAEAVEventInfo@DB@@@Z @57 NONAME
?RecvFile@PROTO_INTERFACE@@UEAAIIAEAVFILE_BLOB@DB@@AEAVEventInfo@3@@Z @59 NONAME
-?RecvMsg@PROTO_INTERFACE@@UEAAIIPEAUPROTORECVEVENT@@@Z @60 NONAME
+?RecvMsg@PROTO_INTERFACE@@UEAAIIAEAVEventInfo@DB@@@Z @60 NONAME
?SearchAdvanced@PROTO_INTERFACE@@UEAAPEAXPEAUHWND__@@@Z @62 NONAME
?SearchBasic@PROTO_INTERFACE@@UEAAPEAXPEB_W@Z @63 NONAME
?SearchByEmail@PROTO_INTERFACE@@UEAAPEAXPEB_W@Z @64 NONAME
diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp index 315ad6ff2b..cd937f23fc 100644 --- a/src/mir_app/src/proto_chains.cpp +++ b/src/mir_app/src/proto_chains.cpp @@ -62,7 +62,7 @@ MIR_APP_DLL(INT_PTR) Proto_ChainSend(int iOrder, CCSDATA *ccs) for (int i = iOrder; i < g_arFilters.getCount(); i++) {
if ((ret = CallProtoService(g_arFilters[i]->szName, ccs->szProtoService, i + 1, LPARAM(ccs))) != CALLSERVICE_NOTFOUND) {
- //chain was started, exit
+ // chain was started, exit
return ret;
}
}
diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp index 76b7b17778..83c4f994f1 100644 --- a/src/mir_app/src/proto_interface.cpp +++ b/src/mir_app/src/proto_interface.cpp @@ -134,7 +134,7 @@ int PROTO_INTERFACE::AuthDeny(MEVENT, const wchar_t*) return 1; // error
}
-int PROTO_INTERFACE::AuthRecv(MCONTACT, PROTORECVEVENT*)
+int PROTO_INTERFACE::AuthRecv(MCONTACT, DB::EventInfo&)
{
return 1; // error
}
@@ -199,7 +199,7 @@ MWindow PROTO_INTERFACE::CreateExtendedSearchUI(MWindow) return nullptr; // error
}
-int PROTO_INTERFACE::RecvContacts(MCONTACT, PROTORECVEVENT*)
+int PROTO_INTERFACE::RecvContacts(MCONTACT, DB::EventInfo &)
{
return 1; // error
}
@@ -209,37 +209,19 @@ MEVENT PROTO_INTERFACE::RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::Eve return Proto_RecvFile(hContact, blob, dbei);
}
-MEVENT PROTO_INTERFACE::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
+MEVENT PROTO_INTERFACE::RecvMsg(MCONTACT hContact, DB::EventInfo &dbei)
{
- if (pre->szMessage == nullptr)
- return 0;
-
- DBEVENTINFO dbei = {};
- dbei.flags = DBEF_UTF;
+ dbei.flags |= DBEF_UTF;
dbei.szModule = Proto_GetBaseAccountName(hContact);
- dbei.timestamp = pre->timestamp;
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.cbBlob = (uint32_t)mir_strlen(pre->szMessage) + 1;
- dbei.pBlob = pre->szMessage;
- dbei.szUserId = pre->szUserId;
- dbei.szReplyId = pre->szReplyId;
-
- if (pre->flags & PREF_CREATEREAD)
- dbei.flags |= DBEF_READ;
- if (pre->flags & PREF_SENT)
- dbei.flags |= DBEF_SENT;
- if (pre->flags & PREF_ENCRYPTED)
- dbei.flags |= DBEF_SECURE;
- if (pre->flags & PREF_ENCRYPTED_STRONG)
- dbei.flags |= DBEF_STRONG;
+ dbei.cbBlob = (uint32_t)mir_strlen(dbei.pBlob) + 1;
// if it's possible to find an existing event by its id, do that
- if ((GetCaps(PFLAGNUM_4) & PF4_SERVERMSGID) && pre->szMsgId != nullptr) {
- MEVENT hDbEvent = db_event_getById(m_szModuleName, pre->szMsgId);
- if (hDbEvent == 0 || db_event_edit(hDbEvent, &dbei)) {
- dbei.szId = pre->szMsgId;
+ if ((GetCaps(PFLAGNUM_4) & PF4_SERVERMSGID) && dbei.szId != nullptr) {
+ MEVENT hDbEvent = db_event_getById(m_szModuleName, dbei.szId);
+ if (hDbEvent == 0 || db_event_edit(hDbEvent, &dbei))
hDbEvent = db_event_add(hContact, &dbei);
- }
+
return hDbEvent;
}
diff --git a/src/mir_app/src/proto_internal.cpp b/src/mir_app/src/proto_internal.cpp index d70491b902..50fa594489 100644 --- a/src/mir_app/src/proto_internal.cpp +++ b/src/mir_app/src/proto_internal.cpp @@ -58,9 +58,9 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return (int)ProtoCallService(m_szModuleName, PS_AUTHDENY, hDbEvent, _T2A(szReason));
}
- int AuthRecv(MCONTACT hContact, PROTORECVEVENT *evt) override
+ int AuthRecv(MCONTACT hContact, DB::EventInfo &dbei) override
{
- CCSDATA ccs = { hContact, PSR_AUTH, 0, (LPARAM)evt };
+ CCSDATA ccs = { hContact, PSR_AUTH, 0, (LPARAM)&dbei };
return (int)ProtoCallService(m_szModuleName, PSR_AUTH, 0, (LPARAM)&ccs);
}
@@ -169,9 +169,9 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return (HWND)ProtoCallService(m_szModuleName, PS_CREATEADVSEARCHUI, 0, (LPARAM)owner);
}
- int RecvContacts(MCONTACT hContact, PROTORECVEVENT* evt) override
+ int RecvContacts(MCONTACT hContact, DB::EventInfo &dbei) override
{
- CCSDATA ccs = { hContact, PSR_CONTACTS, 0, (LPARAM)evt };
+ CCSDATA ccs = { hContact, PSR_CONTACTS, 0, (LPARAM)&dbei };
return (int)ProtoCallService(m_szModuleName, PSR_CONTACTS, 0, (LPARAM)&ccs);
}
@@ -181,9 +181,9 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return ProtoCallService(m_szModuleName, PSR_FILE, 0, (LPARAM)&ccs);
}
- MEVENT RecvMsg(MCONTACT hContact, PROTORECVEVENT* evt) override
+ MEVENT RecvMsg(MCONTACT hContact, DB::EventInfo &dbei) override
{
- CCSDATA ccs = { hContact, PSR_MESSAGE, 0, (LPARAM)evt };
+ CCSDATA ccs = { hContact, PSR_MESSAGE, 0, (LPARAM)&dbei };
INT_PTR res = ProtoCallService(m_szModuleName, PSR_MESSAGE, 0, (LPARAM)&ccs);
return (res == CALLSERVICE_NOTFOUND) ? -1 : (int)res;
}
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp index 0bf7bcf8da..563d9272e7 100644 --- a/src/mir_app/src/protocols.cpp +++ b/src/mir_app/src/protocols.cpp @@ -169,18 +169,14 @@ MIR_APP_DLL(const char*) Proto_GetUniqueId(const char *szModuleName) /////////////////////////////////////////////////////////////////////////////////////////
// Basic core services
-MIR_APP_DLL(MEVENT) Proto_AuthRecv(const char *szProtoName, PROTORECVEVENT *pcre)
+MIR_APP_DLL(MEVENT) Proto_AuthRecv(const char *szProtoName, DB::EventInfo &dbei)
{
- if (szProtoName == nullptr || pcre == nullptr)
+ if (szProtoName == nullptr)
return 0;
- DBEVENTINFO dbei = {};
dbei.szModule = (char*)szProtoName;
- dbei.timestamp = pcre->timestamp;
- dbei.flags = DBEF_UTF | pcre->flags & (PREF_CREATEREAD ? DBEF_READ : 0);
+ dbei.flags |= DBEF_UTF;
dbei.eventType = EVENTTYPE_AUTHREQUEST;
- dbei.cbBlob = pcre->lParam;
- dbei.pBlob = pcre->szMessage;
return db_event_add(0, &dbei);
}
@@ -390,7 +386,7 @@ INT_PTR CallContactServiceInt(MCONTACT hContact, const char *szModule, const cha case 2: return (INT_PTR)ppi->AddToListByEvent(LOWORD(wParam), HIWORD(wParam), (MEVENT)lParam);
case 3: return (INT_PTR)ppi->Authorize((MEVENT)wParam);
case 4: return (INT_PTR)ppi->AuthDeny((MEVENT)wParam, (wchar_t *)lParam);
- case 5: return (INT_PTR)ppi->AuthRecv(hContact, (PROTORECVEVENT *)lParam);
+ case 5: return (INT_PTR)ppi->AuthRecv(hContact, *(DB::EventInfo*)lParam);
case 6: return (INT_PTR)ppi->AuthRequest(hContact, (wchar_t *)lParam);
case 8: return (INT_PTR)ppi->FileAllow(hContact, (HANDLE)wParam, (wchar_t *)lParam);
case 9: return (INT_PTR)ppi->FileCancel(hContact, (HANDLE)wParam);
@@ -413,9 +409,9 @@ INT_PTR CallContactServiceInt(MCONTACT hContact, const char *szModule, const cha }
case 18: return (INT_PTR)ppi->SearchAdvanced((HWND)lParam);
case 19: return (INT_PTR)ppi->CreateExtendedSearchUI((HWND)lParam);
- case 20: return (INT_PTR)ppi->RecvContacts(hContact, (PROTORECVEVENT *)lParam);
+ case 20: return (INT_PTR)ppi->RecvContacts(hContact, *(DB::EventInfo *)lParam);
case 21: return (INT_PTR)ppi->RecvFile(hContact, *(DB::FILE_BLOB *)wParam, *(DB::EventInfo *)lParam);
- case 22: return (INT_PTR)ppi->RecvMsg(hContact, (PROTORECVEVENT *)lParam);
+ case 22: return (INT_PTR)ppi->RecvMsg(hContact, *(DB::EventInfo *)lParam);
case 23: return (INT_PTR)ppi->SendContacts(hContact, LOWORD(wParam), HIWORD(wParam), (MCONTACT *)lParam);
case 24: return (INT_PTR)ppi->SendFile(hContact, (wchar_t *)wParam, (wchar_t **)lParam);
case 25:
|