diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-19 15:44:57 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-19 15:44:57 +0300 |
commit | 010952c5c2dde278a024f6876e8189b949ea5dcf (patch) | |
tree | 06d2a2cadd982b4c742e4d839d7c1924faefc351 /protocols | |
parent | b509e969b7e5e6991c0590cbe43282f219bcc2c1 (diff) |
the ancient atavism extincted: PROTORECVFILE structure with its own set of flags
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Gadu-Gadu/src/core.cpp | 10 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/filetransfer.cpp | 10 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 30 | ||||
-rw-r--r-- | protocols/IRCG/src/commandmonitor.cpp | 12 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_file.cpp | 12 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_ft.cpp | 11 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iq_handlers.cpp | 11 | ||||
-rw-r--r-- | protocols/Sametime/src/files.cpp | 10 | ||||
-rw-r--r-- | protocols/Sametime/src/sametime_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/Sametime/src/sametime_proto.h | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 6 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 24 | ||||
-rw-r--r-- | protocols/Tox/src/tox_transfer.cpp | 23 | ||||
-rw-r--r-- | protocols/Tox/src/tox_transfer.h | 6 |
15 files changed, 62 insertions, 111 deletions
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 22513f3cf2..3e39833635 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -1026,13 +1026,9 @@ retry: const char *fileName = (const char*)dcc7->filename;
- PROTORECVFILE pre = {};
- pre.fileCount = 1;
- pre.timestamp = time(0);
- pre.descr.a = fileName;
- pre.files.a = &fileName;
- pre.pUserInfo = dcc7;
- ProtoChainRecvFile((UINT_PTR)dcc7->contact, &pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = time(0);
+ ProtoChainRecvFile((UINT_PTR)dcc7->contact, DB::FILE_BLOB(dcc7, fileName, fileName), dbei);
e->event.dcc7_new = nullptr;
}
diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp index cebb9279a1..9377736402 100644 --- a/protocols/Gadu-Gadu/src/filetransfer.cpp +++ b/protocols/Gadu-Gadu/src/filetransfer.cpp @@ -367,15 +367,11 @@ void __cdecl GaduProto::dccmainthread(void*) local_dcc->contact = (void*)getcontact(local_dcc->peer_uin, 0, 0, nullptr);
const char *pszFileName = (const char *)m_dcc->file_info.filename;
- PROTORECVFILE pre = {};
- pre.fileCount = 1;
- pre.timestamp = time(0);
- pre.descr.a = pszFileName;
- pre.files.a = &pszFileName;
- pre.pUserInfo = local_dcc;
+ DB::EventInfo dbei;
+ dbei.timestamp = time(0);
gg_LeaveCriticalSection(&ft_mutex, "dccmainthread", 37, 7, "ft_mutex", 1);
- ProtoChainRecvFile((UINT_PTR)local_dcc->contact, &pre);
+ ProtoChainRecvFile((UINT_PTR)local_dcc->contact, DB::FILE_BLOB(local_dcc, pszFileName, pszFileName), dbei);
gg_EnterCriticalSection(&ft_mutex, "dccmainthread", 37, "ft_mutex", 1);
}
break;
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 7fd5181ea7..137be511a4 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -590,30 +590,22 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo // convert a file info into Miranda's file transfer
if (pFileInfo) {
- ptrW pwszFileName(mir_utf8decodeW(pFileInfo->szUrl));
- if (pwszFileName == nullptr)
- pwszFileName = mir_a2u(pFileInfo->szUrl);
+ auto *p = strrchr(pFileInfo->szUrl, '/');
+ auto *pszShortName = (p == nullptr) ? pFileInfo->szUrl.c_str() : p + 1;
- const wchar_t *p = wcsrchr(pwszFileName, '/');
- const wchar_t *m_wszShortName = (p == nullptr) ? pwszFileName : p + 1;
-
- PROTORECVFILE pre = {};
- pre.dwFlags = PRFF_UNICODE | PRFF_SILENT;
- pre.fileCount = 1;
- pre.szId = szMsgId;
- pre.timestamp = iMsgTime;
- pre.files.w = &m_wszShortName;
- pre.descr.w = pFileInfo->wszDescr;
- pre.pUserInfo = pFileInfo;
+ DB::EventInfo dbei;
+ dbei.flags = DBEF_TEMPORARY;
+ dbei.szId = szMsgId;
+ dbei.timestamp = iMsgTime;
if (bCreateRead)
- pre.dwFlags |= PRFF_READ;
+ dbei.flags |= DBEF_READ;
if (bIsOutgoing)
- pre.dwFlags |= PRFF_SENT;
+ dbei.flags |= DBEF_SENT;
if (!szReply.IsEmpty())
- pre.szReplyId = szReply;
+ dbei.szReplyId = szReply;
if (isChatRoom(hContact))
- pre.szUserId = szSender;
- ProtoChainRecvFile(hContact, &pre);
+ dbei.szUserId = szSender;
+ ProtoChainRecvFile(hContact, DB::FILE_BLOB(pFileInfo, pszShortName, T2Utf(pFileInfo->wszDescr)), dbei);
return;
}
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index 917147ea89..f36ec8d236 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -1148,15 +1148,9 @@ bool CIrcProto::IsCTCP(const CIrcMessage *pmsg) setWString(hContact, "User", pmsg->prefix.sUser);
setWString(hContact, "Host", pmsg->prefix.sHost);
- const wchar_t* tszTemp = sFile;
-
- PROTORECVFILE pre = {};
- pre.dwFlags = PRFF_UNICODE;
- pre.timestamp = (uint32_t)time(0);
- pre.fileCount = 1;
- pre.files.w = &tszTemp;
- pre.pUserInfo = di;
- ProtoChainRecvFile(hContact, &pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = (uint32_t)time(0);
+ ProtoChainRecvFile(hContact, DB::FILE_BLOB(di, T2Utf(sFile)), dbei);
}
}
}
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index 30ee8c1fed..f6b5520c8d 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -175,14 +175,10 @@ void CJabberProto::FileProcessHttpDownload(MCONTACT hContact, const char *jid, c ft->dwExpectedRecvFileSize = ft->std.currentFileSize = atoi(p);
}
- PROTORECVFILE pre = {};
- pre.dwFlags = PRFF_UTF | PRFF_SILENT;
- pre.fileCount = 1;
- pre.timestamp = time(0);
- pre.files.a = &pszName;
- pre.pUserInfo = ft;
- pre.descr.a = pszDescr;
- ProtoChainRecvFile(ft->std.hContact, &pre);
+ DB::EventInfo dbei;
+ dbei.flags = DBEF_TEMPORARY;
+ dbei.timestamp = time(0);
+ ProtoChainRecvFile(ft->std.hContact, DB::FILE_BLOB(ft, szName, pszDescr), dbei);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index 0da72701ad..10900907f1 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -466,14 +466,9 @@ void CJabberProto::FtHandleSiRequest(const TiXmlElement *iqNode) ft->std.szCurrentFile.w = mir_utf8decodeW(filename);
ft->std.totalBytes = ft->std.currentFileSize = filesize;
- PROTORECVFILE pre = {};
- pre.dwFlags = PRFF_UTF;
- pre.fileCount = 1;
- pre.timestamp = time(0);
- pre.files.a = &filename;
- pre.pUserInfo = ft;
- pre.descr.a = XmlGetChildText(fileNode, "desc");
- ProtoChainRecvFile(ft->std.hContact, &pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = time(0);
+ ProtoChainRecvFile(ft->std.hContact, DB::FILE_BLOB(ft, filename, XmlGetChildText(fileNode, "desc")), dbei);
return;
}
}
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index d7abb95ff2..1dd1dd43c6 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -323,14 +323,9 @@ bool CJabberProto::OnIqRequestOOB(const TiXmlElement*, CJabberIqInfo *pInfo) else
str2 = ft->httpPath;
- PROTORECVFILE pre = {};
- pre.dwFlags = PRFF_UTF;
- pre.timestamp = time(0);
- pre.descr.a = desc;
- pre.files.a = &str2;
- pre.fileCount = 1;
- pre.pUserInfo = ft;
- ProtoChainRecvFile(ft->std.hContact, &pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = time(0);
+ ProtoChainRecvFile(ft->std.hContact, DB::FILE_BLOB(ft, str2, desc), dbei);
}
else { // reject
XmlNodeIq iq("error", pInfo);
diff --git a/protocols/Sametime/src/files.cpp b/protocols/Sametime/src/files.cpp index 7f82f74ca5..d5c375682d 100644 --- a/protocols/Sametime/src/files.cpp +++ b/protocols/Sametime/src/files.cpp @@ -36,13 +36,9 @@ void mwFileTransfer_offered(mwFileTransfer* ft) else
strncpy_s(description, filename, _TRUNCATE);
- PROTORECVFILE pre = {};
- pre.fileCount = 1;
- pre.timestamp = time(0);
- pre.descr.a = description;
- pre.files.a = &filename;
- pre.pUserInfo = ft;
- ProtoChainRecvFile(hContact, &pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = time(0);
+ ProtoChainRecvFile(hContact, DB::FILE_BLOB(ft, filename, description), dbei);
}
//returns 0 if finished with current file
diff --git a/protocols/Sametime/src/sametime_proto.cpp b/protocols/Sametime/src/sametime_proto.cpp index 50987d47f5..7f6c4e6cc5 100644 --- a/protocols/Sametime/src/sametime_proto.cpp +++ b/protocols/Sametime/src/sametime_proto.cpp @@ -162,14 +162,14 @@ HWND CSametimeProto::CreateExtendedSearchUI(HWND owner) }
-MEVENT CSametimeProto::RecvFile(MCONTACT hContact, PROTORECVFILE* pre)
+MEVENT CSametimeProto::RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei)
{
debugLogW(L"CSametimeProto::RecvFile() hContact=[%x]", hContact);
Contact::Hide(hContact, false);
Contact::PutOnList(hContact);
- return CSuper::RecvFile(hContact, pre);
+ return CSuper::RecvFile(hContact, blob, dbei);
}
MEVENT CSametimeProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT* pre)
diff --git a/protocols/Sametime/src/sametime_proto.h b/protocols/Sametime/src/sametime_proto.h index fb8bdc629c..159dfa36e8 100644 --- a/protocols/Sametime/src/sametime_proto.h +++ b/protocols/Sametime/src/sametime_proto.h @@ -24,7 +24,7 @@ struct CSametimeProto : public PROTO<CSametimeProto> HANDLE SearchAdvanced(HWND owner) override;
HWND CreateExtendedSearchUI(HWND owner) override;
- MEVENT RecvFile(MCONTACT hContact, PROTORECVFILE*) override;
+ MEVENT RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei) override;
MEVENT RecvMsg(MCONTACT hContact, PROTORECVEVENT*) override;
HANDLE SendFile(MCONTACT hContact, const wchar_t* szDescription, wchar_t** ppszFiles) override;
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index b506218b48..30b096813b 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -355,10 +355,10 @@ INT_PTR CTelegramProto::GetCaps(int type, MCONTACT) ///////////////////////////////////////////////////////////////////////////////////////// -MEVENT CTelegramProto::RecvFile(MCONTACT hContact, PROTORECVFILE *pre) +MEVENT CTelegramProto::RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei) { - auto *ft = (TG_FILE_REQUEST *)pre->pUserInfo; - return (ft->m_bRecv) ? CSuper::RecvFile(hContact, pre) : 0; + auto *ft = (TG_FILE_REQUEST *)blob.getUserInfo(); + return (ft->m_bRecv) ? CSuper::RecvFile(hContact, blob, dbei) : 0; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 99e703d02c..a963e17119 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -357,7 +357,7 @@ public: INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override; HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override; - MEVENT RecvFile(MCONTACT hContact, PROTORECVFILE *pre) override; + MEVENT RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei) override; HANDLE SearchByName(const wchar_t *nick, const wchar_t *firstName, const wchar_t *lastName) override; int SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *pszMessage) override; diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 48445a4a45..af638e1d11 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -402,26 +402,24 @@ bool CTelegramProto::GetMessageFile( }
char szReplyId[100];
+ const char *szDesc = nullptr;
MCONTACT hContact = GetRealContact(pUser);
- PROTORECVFILE pre = {};
- pre.dwFlags = PRFF_UTF | PRFF_SILENT;
- pre.fileCount = 1;
- pre.timestamp = pMsg->date_;
- pre.files.a = &pszFileName;
- pre.pUserInfo = pRequest;
- pre.szId = pszId;
- pre.szUserId = pszUserId;
+ DB::EventInfo dbei;
+ dbei.flags = DBEF_TEMPORARY;
+ dbei.timestamp = pMsg->date_;
+ dbei.szId = pszId;
+ dbei.szUserId = pszUserId;
if (!caption.empty())
- pre.descr.a = caption.c_str();
+ szDesc = caption.c_str();
if (pMsg->is_outgoing_)
- pre.dwFlags |= PRFF_SENT;
+ dbei.flags |= DBEF_SENT;
if (Contact::IsGroupChat(hContact) || !pUser->bInited)
- pre.dwFlags |= PRFF_READ;
+ dbei.flags |= DBEF_READ;
if (pMsg->reply_to_message_id_) {
_i64toa(pMsg->reply_to_message_id_, szReplyId, 10);
- pre.szReplyId = szReplyId;
+ dbei.szReplyId = szReplyId;
}
- ProtoChainRecvFile(hContact, &pre);
+ ProtoChainRecvFile(hContact, DB::FILE_BLOB(pRequest, pszFileName, szDesc), dbei);
return true;
}
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp index e5f12a2b8c..1b7b6e4fc3 100644 --- a/protocols/Tox/src/tox_transfer.cpp +++ b/protocols/Tox/src/tox_transfer.cpp @@ -21,11 +21,10 @@ void CToxProto::OnFriendFile(Tox *tox, uint32_t friendNumber, uint32_t fileNumbe {
proto->debugLogA(__FUNCTION__": incoming avatar (%d) from %s (%d)", fileNumber, (const char*)pubKey, friendNumber);
- ptrW address(proto->getWStringA(hContact, TOX_SETTINGS_ID));
- wchar_t avatarName[MAX_PATH];
- mir_snwprintf(avatarName, MAX_PATH, L"%s.png", address.get());
+ CMStringA address(proto->getMStringU(hContact, TOX_SETTINGS_ID));
+ address += "%s.png";
- AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, avatarName, fileSize);
+ AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, address, fileSize);
transfer->pfts.flags |= PFTS_RECEIVING;
transfer->pfts.hContact = hContact;
proto->transfers.Add(transfer);
@@ -45,21 +44,15 @@ void CToxProto::OnFriendFile(Tox *tox, uint32_t friendNumber, uint32_t fileNumbe proto->debugLogA(__FUNCTION__": incoming file (%d) from %s (%d)", fileNumber, (const char*)pubKey, friendNumber);
CMStringA rawName((char*)fileName, (int)fileNameLength);
- const wchar_t *name = mir_utf8decodeW(rawName);
- FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, name, fileSize);
+ FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, rawName, fileSize);
transfer->pfts.flags |= PFTS_RECEIVING;
transfer->pfts.hContact = hContact;
proto->transfers.Add(transfer);
- PROTORECVFILE pre = {};
- pre.dwFlags = PRFF_UNICODE;
- pre.fileCount = 1;
- pre.timestamp = now();
- pre.descr.w = L"";
- pre.files.w = &name;
- pre.pUserInfo = transfer;
- ProtoChainRecvFile(hContact, &pre);
+ DB::EventInfo dbei;
+ dbei.timestamp = now();
+ ProtoChainRecvFile(hContact, DB::FILE_BLOB(transfer, rawName), dbei);
}
break;
@@ -270,7 +263,7 @@ HANDLE CToxProto::OnSendFile(Tox *tox, MCONTACT hContact, const wchar_t*, wchar_ }
debugLogA(__FUNCTION__": start sending file (%d) to %s (%d)", fileNumber, (const char*)pubKey, friendNumber);
- FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, fileName, fileSize);
+ FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, rawName, fileSize);
transfer->pfts.flags |= PFTS_SENDING;
transfer->pfts.hContact = hContact;
transfer->pfts.szWorkingDir.w = fileDir;
diff --git a/protocols/Tox/src/tox_transfer.h b/protocols/Tox/src/tox_transfer.h index 0e72a4cf77..3d79f6d9ca 100644 --- a/protocols/Tox/src/tox_transfer.h +++ b/protocols/Tox/src/tox_transfer.h @@ -11,7 +11,7 @@ struct FileTransferParam TOX_FILE_KIND transferType;
- FileTransferParam(uint32_t friendNumber, uint32_t fileNumber, const wchar_t *fileName, uint64_t fileSize)
+ FileTransferParam(uint32_t friendNumber, uint32_t fileNumber, const char *fileName, uint64_t fileSize)
{
hFile = nullptr;
this->friendNumber = friendNumber;
@@ -22,7 +22,7 @@ struct FileTransferParam pfts.hContact = NULL;
pfts.totalFiles = 1;
pfts.pszFiles.w = (wchar_t**)mir_alloc(sizeof(wchar_t*)*(pfts.totalFiles + 1));
- pfts.pszFiles.w[0] = pfts.szCurrentFile.w = mir_wstrdup(fileName);
+ pfts.pszFiles.w[0] = pfts.szCurrentFile.w = mir_utf8decodeW(fileName);
pfts.pszFiles.w[pfts.totalFiles] = nullptr;
pfts.totalBytes = pfts.currentFileSize = fileSize;
pfts.totalProgress = pfts.currentFileProgress = 0;
@@ -77,7 +77,7 @@ struct AvatarTransferParam : public FileTransferParam {
uint8_t hash[TOX_HASH_LENGTH];
- AvatarTransferParam(uint32_t friendNumber, uint32_t fileNumber, const wchar_t *fileName, uint64_t fileSize)
+ AvatarTransferParam(uint32_t friendNumber, uint32_t fileNumber, const char *fileName, uint64_t fileSize)
: FileTransferParam(friendNumber, fileNumber, fileName, fileSize)
{
transferType = TOX_FILE_KIND_AVATAR;
|