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 /protocols | |
parent | 395ecbc7e8f02c0ea659a598e5f9bab8995f3451 (diff) |
major atavism, PROTORECVEVENT, died with its own set of constants
Diffstat (limited to 'protocols')
46 files changed, 291 insertions, 375 deletions
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) {
|