diff options
30 files changed, 100 insertions, 191 deletions
diff --git a/include/m_database.h b/include/m_database.h index 7620c8b07d..55e24ff97e 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -712,14 +712,17 @@ namespace DB ptrW m_wszFileName, m_wszDescription, m_wszLocalName;
ptrA m_szProtoString;
int64_t m_iFileSize = -1, m_iTransferred = -1;
+ void *m_pUserInfo = 0;
public:
+ explicit FILE_BLOB(void *pUserInfo, const char *pszName, const char *pszDescr = nullptr, bool bUtf = true);
explicit FILE_BLOB(const wchar_t *pwszName, const wchar_t *pwszDescr = nullptr);
explicit FILE_BLOB(const EventInfo &dbei);
~FILE_BLOB();
void write(EventInfo &dbei);
+ __forceinline void* getUserInfo() const { return m_pUserInfo; }
__forceinline const char* getUrl() const { return m_szProtoString; }
__forceinline const wchar_t* getLocalName() const { return m_wszLocalName; }
__forceinline const wchar_t* getName() const { return m_wszFileName; }
@@ -736,6 +739,7 @@ namespace DB __forceinline void setName(const wchar_t *pszFileName) { m_wszFileName = mir_wstrdup(pszFileName); }
__forceinline void setSize(int64_t iSize) { m_iFileSize = iSize; }
__forceinline void setLocalName(const wchar_t *pszFileName) { m_wszLocalName = mir_wstrdup(pszFileName); }
+ __forceinline void setUserInfo(void *pUserInfo) { m_pUserInfo = pUserInfo; }
};
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/include/m_protoint.h b/include/m_protoint.h index 51eb352f22..09f31ef992 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -235,7 +235,7 @@ public: virtual MWindow CreateExtendedSearchUI(MWindow owner);
virtual int RecvContacts(MCONTACT hContact, PROTORECVEVENT *);
- virtual MEVENT RecvFile(MCONTACT hContact, PROTORECVFILE *);
+ virtual MEVENT RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei);
virtual MEVENT RecvMsg(MCONTACT hContact, PROTORECVEVENT *);
virtual int SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList);
diff --git a/include/m_protosvc.h b/include/m_protosvc.h index 74626d3c0c..01eae97a2c 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_PROTOSVC_H__
#define M_PROTOSVC_H__ 1
+#include "m_database.h"
#include "m_protocols.h"
#include "m_utils.h"
@@ -759,33 +760,12 @@ EXTERN_C MIR_APP_DLL(MEVENT) Proto_AuthRecv(const char *szProtoName, PROTORECVEV ///////////////////////////////////////////////////////////////////////////////
// File(s) have been received
-// wParam = 0
-// lParam = (LPARAM)(PROTORECVFILE*)&prf
-
-#define PRFF_UNICODE 0x0001 // in all MAllCStrings .w is valid
-#define PRFF_UTF 0x0002 // in all MAllCStrings .a contains text in UTF8
-#define PRFF_SILENT 0x0004 // do not show file send/receive dialog
-#define PRFF_SENT 0x0008 // this is an outgoing file
-#define PRFF_READ 0x0010 // this event is marked read
-
-struct PROTORECVFILE
-{
- uint32_t dwFlags; // PRFF_*
- uint32_t timestamp; // unix time
- MAllCStrings descr; // file description
- int fileCount; // number of files being transferred
- MAllCStringArray files; // array of file names
- void *pUserInfo; // extra space for the network level protocol module
- const char *szId; // server message id
- const char *szUserId; // groupchat user id
- const char *szReplyId; // this message is a reply to a message with that server id
-};
#define PSR_FILE "/RecvFile"
-__forceinline INT_PTR ProtoChainRecvFile(MCONTACT hContact, PROTORECVFILE *pre)
+__forceinline INT_PTR ProtoChainRecvFile(MCONTACT hContact, const DB::FILE_BLOB &blob, const DB::EventInfo &dbei)
{
- CCSDATA ccs = { hContact, PSR_FILE, 0, (LPARAM)pre };
+ CCSDATA ccs = { hContact, PSR_FILE, (WPARAM)&blob, (LPARAM)&dbei };
return Proto_ChainRecv(0, &ccs);
}
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 52671be255..2289b8521d 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 6eac23f154..1e742b6513 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib 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;
diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp index e4296816b1..f8e34191de 100644 --- a/src/mir_app/src/db_events.cpp +++ b/src/mir_app/src/db_events.cpp @@ -331,6 +331,12 @@ wchar_t* DB::EventInfo::getString(const char *str) const /////////////////////////////////////////////////////////////////////////////////////////
// File blob helper
+DB::FILE_BLOB::FILE_BLOB(void *pUserInfo, const char *pszName, const char *pszDescr, bool bUtf) :
+ m_wszFileName(bUtf ? mir_utf8decodeW(pszName) : mir_a2u(pszName)),
+ m_wszDescription(bUtf ? mir_utf8decodeW(pszDescr) : mir_a2u(pszDescr)),
+ m_pUserInfo(pUserInfo)
+{}
+
DB::FILE_BLOB::FILE_BLOB(const wchar_t *pwszName, const wchar_t *pwszDescr) :
m_wszFileName(mir_wstrdup(pwszName)),
m_wszDescription(mir_wstrdup(pwszDescr))
diff --git a/src/mir_app/src/file.cpp b/src/mir_app/src/file.cpp index 4be92ea9be..7410ac05f4 100644 --- a/src/mir_app/src/file.cpp +++ b/src/mir_app/src/file.cpp @@ -211,58 +211,20 @@ INT_PTR openRecDir(WPARAM, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// -MEVENT Proto_RecvFile(MCONTACT hContact, PROTORECVFILE *pre) +MEVENT Proto_RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei) { - if (!pre || !pre->fileCount) - return 0; - - bool bSilent = (pre->dwFlags & PRFF_SILENT) != 0; - bool bSent = (pre->dwFlags & PRFF_SENT) != 0; - bool bRead = (pre->dwFlags & PRFF_READ) != 0; + bool bSilent = (dbei.flags & DBEF_TEMPORARY) != 0; + bool bSent = (dbei.flags & DBEF_SENT) != 0; + bool bRead = (dbei.flags & DBEF_READ) != 0; - DB::EventInfo dbei; dbei.szModule = Proto_GetBaseAccountName(hContact); - dbei.timestamp = pre->timestamp; - dbei.szId = pre->szId; - dbei.szUserId = pre->szUserId; - dbei.szReplyId = pre->szReplyId; dbei.eventType = EVENTTYPE_FILE; - dbei.flags = DBEF_UTF; - if (bSent) - dbei.flags |= DBEF_SENT; - if (bRead) - dbei.flags |= DBEF_READ; + dbei.flags = (dbei.flags & ~DBEF_TEMPORARY) | DBEF_UTF; CMStringW wszFiles, wszDescr; - if ((pre->dwFlags & PRFF_UNICODE) == PRFF_UNICODE) { - for (int i = 0; i < pre->fileCount; i++) { - if (i != 0) - wszFiles.AppendChar(','); - wszFiles.Append(pre->files.w[i]); - } - - wszDescr = pre->descr.w; - } - else { - bool bUtf = (pre->dwFlags & PRFF_UTF) != 0; - - for (int i = 0; i < pre->fileCount; i++) { - if (i != 0) - wszFiles.AppendChar(','); - - if (bUtf) - wszFiles.Append(Utf2T(pre->files.a[i])); - else - wszFiles.Append(_A2T(pre->files.a[i])); - } - - wszDescr = (bUtf) ? Utf2T(pre->descr.a).get() : _A2T(pre->descr.a); - } - - DB::FILE_BLOB blob(wszFiles, wszDescr); if (auto *ppro = Proto_GetContactInstance(hContact)) - ppro->OnReceiveOfflineFile(blob, pre->pUserInfo); + ppro->OnReceiveOfflineFile(blob, blob.getUserInfo()); blob.write(dbei); MEVENT hdbe = db_event_add(hContact, &dbei); @@ -273,7 +235,7 @@ MEVENT Proto_RecvFile(MCONTACT hContact, PROTORECVFILE *pre) CLISTEVENT cle = {}; cle.hContact = hContact; cle.hDbEvent = hdbe; - cle.lParam = LPARAM(pre->pUserInfo); + cle.lParam = LPARAM(blob.getUserInfo()); if (!bSilent && File::bAutoAccept && Contact::OnList(hContact)) LaunchRecvDialog(&cle); diff --git a/src/mir_app/src/file.h b/src/mir_app/src/file.h index a0d3937872..28ce186397 100644 --- a/src/mir_app/src/file.h +++ b/src/mir_app/src/file.h @@ -68,7 +68,7 @@ struct FileDlgData : public MZeroedObject }; // file.c -MEVENT Proto_RecvFile(MCONTACT hContact, PROTORECVFILE *pre); +MEVENT Proto_RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei); // filerecv.c void LaunchRecvDialog(CLISTEVENT *cle); diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 20d41c159c..1fa9ad6573 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -54,7 +54,7 @@ Button_SetSkin_IcoLib @24 ?OnProtoRefresh@CProtoIntDlgBase@@MAEXIJ@Z @55 NONAME
?ProtoBroadcastAck@PROTO_INTERFACE@@QAEHIHHPAXJ@Z @56 NONAME
?RecvContacts@PROTO_INTERFACE@@UAEHIPAUPROTORECVEVENT@@@Z @58 NONAME
-?RecvFile@PROTO_INTERFACE@@UAEIIPAUPROTORECVFILE@@@Z @59 NONAME
+?RecvFile@PROTO_INTERFACE@@UAEIIAAVFILE_BLOB@DB@@AAVEventInfo@3@@Z @59 NONAME
?RecvMsg@PROTO_INTERFACE@@UAEIIPAUPROTORECVEVENT@@@Z @60 NONAME
?SearchAdvanced@PROTO_INTERFACE@@UAEPAXPAUHWND__@@@Z @62 NONAME
?SearchBasic@PROTO_INTERFACE@@UAEPAXPB_W@Z @63 NONAME
@@ -960,3 +960,6 @@ Netlib_HttpResult @1096 ?SetData@MHttpRequest@@QAEXPBXI@Z @1097 NONAME
?DeleteHeader@MHttpHeaders@@QAEXPBD@Z @1098 NONAME
_Netlib_DownloadFile@20 @1099 NONAME
+??0FILE_BLOB@DB@@QAE@PAXPBD1_N@Z @1100 NONAME
+?getUserInfo@FILE_BLOB@DB@@QBEPAXXZ @1101 NONAME
+?setUserInfo@FILE_BLOB@DB@@QAEXPAX@Z @1102 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 5761132572..6b2391f2cb 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -54,7 +54,7 @@ Button_SetSkin_IcoLib @24 ?OnProtoRefresh@CProtoIntDlgBase@@MEAAX_K_J@Z @55 NONAME
?ProtoBroadcastAck@PROTO_INTERFACE@@QEAA_JIHHPEAX_J@Z @56 NONAME
?RecvContacts@PROTO_INTERFACE@@UEAAHIPEAUPROTORECVEVENT@@@Z @58 NONAME
-?RecvFile@PROTO_INTERFACE@@UEAAIIPEAUPROTORECVFILE@@@Z @59 NONAME
+?RecvFile@PROTO_INTERFACE@@UEAAIIAEAVFILE_BLOB@DB@@AEAVEventInfo@3@@Z @59 NONAME
?RecvMsg@PROTO_INTERFACE@@UEAAIIPEAUPROTORECVEVENT@@@Z @60 NONAME
?SearchAdvanced@PROTO_INTERFACE@@UEAAPEAXPEAUHWND__@@@Z @62 NONAME
?SearchBasic@PROTO_INTERFACE@@UEAAPEAXPEB_W@Z @63 NONAME
@@ -960,3 +960,6 @@ Netlib_HttpResult @1090 ?SetData@MHttpRequest@@QEAAXPEBX_K@Z @1091 NONAME
?DeleteHeader@MHttpHeaders@@QEAAXPEBD@Z @1092 NONAME
Netlib_DownloadFile @1093 NONAME
+??0FILE_BLOB@DB@@QEAA@PEAXPEBD1_N@Z @1094 NONAME
+?getUserInfo@FILE_BLOB@DB@@QEBAPEAXXZ @1095 NONAME
+?setUserInfo@FILE_BLOB@DB@@QEAAXPEAX@Z @1096 NONAME
diff --git a/src/mir_app/src/netlib_http.cpp b/src/mir_app/src/netlib_http.cpp index de0a5255cd..cfe28998f1 100644 --- a/src/mir_app/src/netlib_http.cpp +++ b/src/mir_app/src/netlib_http.cpp @@ -1150,7 +1150,7 @@ void MFileChunkStorage::apply(MHttpResponse *nlhr) bool MFileChunkStorage::updateChunk(const void *pData, size_t cbLen)
{
- if (cbLen != _write(fileId, pData, unsigned(cbLen))) {
+ if (cbLen != (unsigned)_write(fileId, pData, unsigned(cbLen))) {
_close(fileId);
fileId = -1;
return false;
diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp index 707e8996f9..315ad6ff2b 100644 --- a/src/mir_app/src/proto_chains.cpp +++ b/src/mir_app/src/proto_chains.cpp @@ -105,10 +105,10 @@ MIR_APP_DLL(INT_PTR) Proto_ChainRecv(int iOrder, CCSDATA *ccs) for (int i = iOrder - 1; i >= 0; 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;
- //end of chain, call network protocol again
+ // end of chain, call network protocol again
char szProto[40];
if (GetProtocolP(ccs->hContact, szProto, sizeof(szProto)))
return 1;
diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp index 42584b0f86..31f04aaf0d 100644 --- a/src/mir_app/src/proto_interface.cpp +++ b/src/mir_app/src/proto_interface.cpp @@ -204,9 +204,9 @@ int PROTO_INTERFACE::RecvContacts(MCONTACT, PROTORECVEVENT*) return 1; // error
}
-MEVENT PROTO_INTERFACE::RecvFile(MCONTACT hContact, PROTORECVFILE *pre)
+MEVENT PROTO_INTERFACE::RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei)
{
- return Proto_RecvFile(hContact, pre);
+ return Proto_RecvFile(hContact, blob, dbei);
}
MEVENT PROTO_INTERFACE::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
diff --git a/src/mir_app/src/proto_internal.cpp b/src/mir_app/src/proto_internal.cpp index 6a17124f8e..d70491b902 100644 --- a/src/mir_app/src/proto_internal.cpp +++ b/src/mir_app/src/proto_internal.cpp @@ -175,9 +175,9 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE return (int)ProtoCallService(m_szModuleName, PSR_CONTACTS, 0, (LPARAM)&ccs);
}
- MEVENT RecvFile(MCONTACT hContact, PROTORECVFILE* evt) override
+ MEVENT RecvFile(MCONTACT hContact, DB::FILE_BLOB &blob, DB::EventInfo &dbei) override
{
- CCSDATA ccs = { hContact, PSR_FILE, 0, (LPARAM)evt };
+ CCSDATA ccs = { hContact, PSR_FILE, (WPARAM)&blob, (LPARAM)&dbei };
return ProtoCallService(m_szModuleName, PSR_FILE, 0, (LPARAM)&ccs);
}
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp index 4b14130520..509f1bbedb 100644 --- a/src/mir_app/src/protocols.cpp +++ b/src/mir_app/src/protocols.cpp @@ -418,7 +418,7 @@ 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 21: return (INT_PTR)ppi->RecvFile(hContact, (PROTORECVFILE *)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 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);
|