From ab3d423b1dc514e9db61c170ca14bab49e5280cb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 26 Jan 2024 23:34:30 +0300 Subject: major atavism, PROTORECVEVENT, died with its own set of constants --- protocols/ICQCorp/src/protocol.cpp | 59 ++++++++++++-------------------------- protocols/ICQCorp/src/services.cpp | 23 ++++----------- 2 files changed, 24 insertions(+), 58 deletions(-) (limited to 'protocols/ICQCorp/src') 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; } -- cgit v1.2.3