From beaf93e92827b7bcc77c9f6b2a0c7097d355151c Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 29 Aug 2014 22:11:08 +0000 Subject: Tox: added files receiving git-svn-id: http://svn.miranda-ng.org/main/trunk@10339 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_proto.h | 48 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'protocols/Tox/src/tox_proto.h') diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index c910317abb..81d03f952c 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -1,7 +1,38 @@ #ifndef _TOX_PROTO_H_ #define _TOX_PROTO_H_ -class CFile; +class CFileTransfer; + +struct FileTransferParam +{ + PROTOFILETRANSFERSTATUS pfts; + uint8_t number; + + FileTransferParam(uint8_t number, const TCHAR* fileName, size_t fileSize) + { + pfts = { sizeof(PROTOFILETRANSFERSTATUS) }; + pfts.flags = PFTS_TCHAR; + pfts.totalFiles = 1; + pfts.ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*)*(pfts.totalFiles + 1)); + pfts.ptszFiles[0] = pfts.tszCurrentFile = mir_tstrdup(fileName); + pfts.ptszFiles[pfts.totalFiles] = NULL; + pfts.totalBytes = pfts.currentFileSize = fileSize; + pfts.totalProgress = pfts.currentFileProgress = 0; + pfts.currentFileNumber = 0; + pfts.tszWorkingDir = NULL; + } + + ~FileTransferParam() + { + if (pfts.tszWorkingDir != NULL) + { + mir_free(pfts.tszWorkingDir); + } + + mir_free(pfts.pszFiles[0]); + mir_free(pfts.pszFiles); + } +}; struct CToxProto : public PROTO { @@ -26,10 +57,10 @@ public: virtual HANDLE __cdecl ChangeInfo(int iInfoType, void* pInfoData); - virtual HANDLE __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szPath); + virtual HANDLE __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* tszPath); virtual int __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer); - virtual int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szReason); - virtual int __cdecl FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** szFilename); + virtual int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* tszReason); + virtual int __cdecl FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** tszFilename); virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL); virtual int __cdecl GetInfo(MCONTACT hContact, int infoType); @@ -76,7 +107,8 @@ private: bool isConnected; HANDLE hNetlibUser; ULONG hFileProcess; - LIST fileSendQueue; + LIST fileTransfers; + std::map transfers; // tox void InitToxCore(); @@ -122,6 +154,8 @@ private: //static void OnFileControlCallback(Tox *tox, int32_t number, uint8_t hFile, uint64_t fileSize, uint8_t *name, uint16_t nameSize, void *arg); static void OnFileRequest(Tox *tox, int32_t number, uint8_t isSend, uint8_t fileNumber, uint8_t type, const uint8_t *data, uint16_t length, void *arg); + static void OnFriendFile(Tox *tox, int32_t number, uint8_t fileNumber, uint64_t fileSize, const uint8_t *fileName, uint16_t length, void *arg); + static void OnFileData(Tox *tox, int32_t number, uint8_t fileNumber, const uint8_t *data, uint16_t length, void *arg); // contacts WORD GetContactStatus(MCONTACT hContact); @@ -141,9 +175,11 @@ private: void __cdecl SearchByNameAsync(void* arg); // file transfer - static int FileSendQueueCompare(const CFile* p1, const CFile* p2); + void __cdecl SendFileAsync(void* arg); void __cdecl SendFilesAsync(void* arg); + CFileTransfer *GetFileTransferByFileNumber(int fileNumber); + // utils TOX_USERSTATUS MirandaToToxStatus(int status); int ToxToMirandaStatus(TOX_USERSTATUS userstatus); -- cgit v1.2.3