summaryrefslogtreecommitdiff
path: root/protocols/Tox/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r--protocols/Tox/src/tox_avatars.cpp24
-rw-r--r--protocols/Tox/src/tox_contacts.cpp5
-rw-r--r--protocols/Tox/src/tox_core.cpp3
-rw-r--r--protocols/Tox/src/tox_proto.h8
-rw-r--r--protocols/Tox/src/tox_transfer.cpp167
-rw-r--r--protocols/Tox/src/tox_transfer.h41
6 files changed, 104 insertions, 144 deletions
diff --git a/protocols/Tox/src/tox_avatars.cpp b/protocols/Tox/src/tox_avatars.cpp
index 33bde952d8..cfab678533 100644
--- a/protocols/Tox/src/tox_avatars.cpp
+++ b/protocols/Tox/src/tox_avatars.cpp
@@ -215,18 +215,16 @@ INT_PTR CToxProto::SetMyAvatar(WPARAM, LPARAM lParam)
return 0;
}
-void CToxProto::OnGotFriendAvatarInfo(FileTransferParam *transfer, const uint8_t *hash)
+void CToxProto::OnGotFriendAvatarInfo(AvatarTransferParam *transfer)
{
MCONTACT hContact = transfer->pfts.hContact;
if (transfer->pfts.totalBytes == 0)
{
delSetting(hContact, TOX_SETTINGS_AVATAR_HASH);
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, 0, 0);
- std::tstring path = GetAvatarFilePath();
+ std::tstring path = GetAvatarFilePath(hContact);
if (IsFileExists(path))
- {
DeleteFile(path.c_str());
- }
OnFileCancel(hContact, transfer);
}
else
@@ -234,7 +232,7 @@ void CToxProto::OnGotFriendAvatarInfo(FileTransferParam *transfer, const uint8_t
DBVARIANT dbv;
if (!db_get(transfer->pfts.hContact, m_szModuleName, TOX_SETTINGS_AVATAR_HASH, &dbv))
{
- if (memcmp(hash, dbv.pbVal, TOX_HASH_LENGTH) == 0)
+ if (memcmp(transfer->hash, dbv.pbVal, TOX_HASH_LENGTH) == 0)
{
db_free(&dbv);
OnFileCancel(hContact, transfer);
@@ -246,4 +244,20 @@ void CToxProto::OnGotFriendAvatarInfo(FileTransferParam *transfer, const uint8_t
mir_sntprintf(path, SIZEOF(path), _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
OnFileAllow(hContact, transfer, path);
}
+}
+
+void CToxProto::OnGotFriendAvatarData(AvatarTransferParam *transfer)
+{
+ db_set_blob(transfer->pfts.hContact, m_szModuleName, TOX_SETTINGS_AVATAR_HASH, transfer->hash, TOX_HASH_LENGTH);
+
+ PROTO_AVATAR_INFORMATIONT pai = { sizeof(pai) };
+ pai.format = PA_FORMAT_PNG;
+ pai.hContact = transfer->pfts.hContact;
+ mir_tstrcpy(pai.filename, transfer->pfts.tszCurrentFile);
+
+ fclose(transfer->hFile);
+ transfer->hFile = NULL;
+
+ ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
+ transfers.Remove(transfer);
} \ No newline at end of file
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp
index 8f6484f39e..2c410f4cad 100644
--- a/protocols/Tox/src/tox_contacts.cpp
+++ b/protocols/Tox/src/tox_contacts.cpp
@@ -348,7 +348,6 @@ void CToxProto::OnConnectionStatusChanged(Tox*, uint32_t friendNumber, TOX_CONNE
if (transfer->friendNumber == friendNumber && transfer->GetDirection() == 1)
{
proto->debugLogA(__FUNCTION__": sending ask to resume the transfer of file (%d)", transfer->fileNumber);
- transfer->status = STARTED;
TOX_ERR_FILE_CONTROL error;
if (!tox_file_control(proto->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_RESUME, &error))
{
@@ -402,12 +401,12 @@ void CToxProto::OnConnectionStatusChanged(Tox*, uint32_t friendNumber, TOX_CONNE
proto->SetContactStatus(hContact, ID_STATUS_OFFLINE);
proto->setDword(hContact, "LastEventDateTS", time(NULL));
- for (size_t i = 0; i < proto->transfers.Count(); i++)
+ /*for (size_t i = 0; i < proto->transfers.Count(); i++)
{
FileTransferParam *transfer = proto->transfers.GetAt(i);
if (transfer->friendNumber == friendNumber)
transfer->status = BROKEN;
- }
+ }*/
}
}
}
diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp
index 8e5ea7e63d..a08ca0a57b 100644
--- a/protocols/Tox/src/tox_core.cpp
+++ b/protocols/Tox/src/tox_core.cpp
@@ -55,7 +55,7 @@ bool CToxProto::InitToxCore()
// transfers
tox_callback_file_recv_control(tox, OnFileRequest, this);
tox_callback_file_recv(tox, OnFriendFile, this);
- tox_callback_file_recv_chunk(tox, OnFileReceiveData, this);
+ tox_callback_file_recv_chunk(tox, OnDataReceiving, this);
tox_callback_file_chunk_request(tox, OnFileSendData, this);
// group chats
//tox_callback_group_invite(tox, OnGroupChatInvite, this);
@@ -98,7 +98,6 @@ void CToxProto::UninitToxCore()
for (size_t i = 0; i < transfers.Count(); i++)
{
FileTransferParam *transfer = transfers.GetAt(i);
- transfer->status = CANCELED;
tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)transfer, 0);
transfers.Remove(transfer);
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h
index 61041a2eb4..37a41138c9 100644
--- a/protocols/Tox/src/tox_proto.h
+++ b/protocols/Tox/src/tox_proto.h
@@ -221,6 +221,7 @@ private:
int __cdecl OnPreCreateMessage(WPARAM wParam, LPARAM lParam);
// transfer
+
HANDLE OnFileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR *tszPath);
int OnFileResume(HANDLE hTransfer, int *action, const PROTOCHAR **szFilename);
int OnFileCancel(MCONTACT hContact, HANDLE hTransfer);
@@ -228,10 +229,12 @@ private:
static void OnFileRequest(Tox *tox, uint32_t friendNumber, uint32_t fileNumber, TOX_FILE_CONTROL control, void *arg);
static void OnFriendFile(Tox *tox, uint32_t friendNumber, uint32_t fileNumber, uint32_t kind, uint64_t fileSize, const uint8_t *fileName, size_t filenameLength, void *arg);
- static void OnFileReceiveData(Tox *tox, uint32_t friendNumber, uint32_t fileNumber, uint64_t position, const uint8_t *data, size_t length, void *arg);
+ static void OnDataReceiving(Tox *tox, uint32_t friendNumber, uint32_t fileNumber, uint64_t position, const uint8_t *data, size_t length, void *arg);
static void OnFileSendData(Tox *tox, uint32_t friendNumber, uint32_t fileNumber, uint64_t position, size_t length, void *arg);
+ void OnTransferCompleted(FileTransferParam *transfer);
+
// avatars
std::tstring GetAvatarFilePath(MCONTACT hContact = NULL);
void SetToxAvatar(std::tstring path, bool checkHash = false);
@@ -241,7 +244,8 @@ private:
INT_PTR __cdecl GetMyAvatar(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl SetMyAvatar(WPARAM wParam, LPARAM lParam);
- void OnGotFriendAvatarInfo(FileTransferParam *transfer, const uint8_t *hash);
+ void OnGotFriendAvatarInfo(AvatarTransferParam *transfer);
+ void OnGotFriendAvatarData(AvatarTransferParam *transfer);
// multimedia
HANDLE hAudioDialogs;
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp
index 3d140b5e5c..110b1fc895 100644
--- a/protocols/Tox/src/tox_transfer.cpp
+++ b/protocols/Tox/src/tox_transfer.cpp
@@ -2,7 +2,7 @@
/* FILE RECEIVING */
-// incoming file flow
+// incoming transfer flow
void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, uint32_t kind, uint64_t fileSize, const uint8_t *fileName, size_t filenameLength, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
@@ -19,7 +19,22 @@ void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, u
mir_snprintf(avatarName, MAX_PATH, "%s.png", id);
fileName = (const uint8_t*)avatarName;
filenameLength = mir_strlen(avatarName);
+
+ AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, NULL, fileSize);
+ transfer->pfts.hContact = hContact;
+ proto->transfers.Add(transfer);
+
+ TOX_ERR_FILE_GET error;
+ tox_file_get_file_id(proto->tox, friendNumber, fileNumber, transfer->hash, &error);
+ if (error != TOX_ERR_FILE_GET_OK)
+ {
+ proto->debugLogA(__FUNCTION__": unable to get avatar hash (%d)", error);
+ memset(transfer->hash, 0, TOX_HASH_LENGTH);
+ }
+ proto->OnGotFriendAvatarInfo(transfer);
}
+ break;
+
case TOX_FILE_KIND_DATA:
{
ptrA rawName((char*)mir_alloc(filenameLength + 1));
@@ -31,16 +46,6 @@ void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, u
transfer->pfts.hContact = hContact;
proto->transfers.Add(transfer);
- if(kind == TOX_FILE_KIND_AVATAR)
- {
- transfer->isAvatar = true;
- uint8_t hash[TOX_HASH_LENGTH];
- TOX_ERR_FILE_GET error;
- tox_file_get_file_id(proto->tox, friendNumber, fileNumber, hash, &error);
- proto->OnGotFriendAvatarInfo(transfer, hash);
- return;
- }
-
PROTORECVFILET pre = { 0 };
pre.flags = PREF_TCHAR;
pre.fileCount = 1;
@@ -55,7 +60,7 @@ void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, u
break;
default:
- proto->debugLogA(__FUNCTION__": unknown file kind (%d)", kind);
+ proto->debugLogA(__FUNCTION__": unsupported transfer type (%d)", kind);
return;
}
}
@@ -74,23 +79,11 @@ HANDLE CToxProto::OnFileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCH
if (!ProtoBroadcastAck(hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, (HANDLE)transfer, (LPARAM)&transfer->pfts))
{
- if (!transfer->OpenFile(_T("wb")))
- {
- debugLogA("CToxProto::FileAllow: failed to open file (%d)", transfer->fileNumber);
- transfer->status = FAILED;
- tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
- transfers.Remove(transfer);
- return NULL;
- }
-
- debugLogA("CToxProto::FileAllow: start receiving file (%d)", transfer->fileNumber);
- transfer->status = STARTED;
- TOX_ERR_FILE_CONTROL error;
- if (!tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_RESUME, &error))
- {
- debugLogA("CToxProto::FileAllow: failed to start the transfer (%d)", error);
- tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
- }
+ int action = FILERESUME_OVERWRITE;
+ const TCHAR **szFilename = (const TCHAR**)mir_alloc(sizeof(TCHAR) * 2);
+ szFilename[0] = &fullPath[0];
+ szFilename[1] = NULL;
+ OnFileResume(hTransfer, &action, szFilename);
}
return hTransfer;
@@ -99,100 +92,74 @@ HANDLE CToxProto::OnFileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCH
// if file is exists
int CToxProto::OnFileResume(HANDLE hTransfer, int *action, const PROTOCHAR **szFilename)
{
- bool result = false;
FileTransferParam *transfer = (FileTransferParam*)hTransfer;
- switch (*action)
+ if (*action = FILERESUME_SKIP)
{
- case FILERESUME_RENAME:
- transfer->ChangeName(*szFilename);
- case FILERESUME_OVERWRITE:
- result = transfer->OpenFile(_T("wb"));
- break;
+ tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
+ transfers.Remove(transfer);
+ return 0;
+ }
- case FILERESUME_RESUME:
- result = transfer->OpenFile(_T("ab"));
- break;
+ if (*action = FILERESUME_RENAME)
+ transfer->ChangeName(*szFilename);
- case FILERESUME_SKIP:
- result = false;
- break;
+ TCHAR *mode = *action == FILERESUME_OVERWRITE ? _T("wb") : _T("ab");
+ if (!transfer->OpenFile(mode))
+ {
+ debugLogA(__FUNCTION__": failed to open file (%d)", transfer->fileNumber);
+ tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
+ transfers.Remove(transfer);
+ return NULL;
}
TOX_ERR_FILE_CONTROL error;
- if (result)
+ debugLogA(__FUNCTION__": start receiving file (%d) to (%d)", transfer->fileNumber, transfer->friendNumber);
+ if (!tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_RESUME, &error))
{
- debugLogA("CToxProto::FileResume: start receiving file (%d)", transfer->fileNumber);
- transfer->status = STARTED;
- if (!tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_RESUME, &error))
- {
- debugLogA("CToxProto::FileResume: failed to start the transfer (%d)", error);
- tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, &error);
- }
- }
- else
- {
- transfer->status = CANCELED;
- tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, &error);
+ debugLogA(__FUNCTION__": failed to start the transfer of file(%d) to (%d): (%d)", transfer->fileNumber, transfer->friendNumber, error);
+ ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
+ tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
transfers.Remove(transfer);
}
- ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, result ? ACKRESULT_CONNECTED : ACKRESULT_DENIED, (HANDLE)transfer, 0);
return 0;
}
+void CToxProto::OnTransferCompleted(FileTransferParam *transfer)
+{
+ debugLogA(__FUNCTION__": finised the transfer of file (%d)", transfer->fileNumber);
+ bool isFileFullyTransfered = transfer->pfts.currentFileProgress == transfer->pfts.currentFileSize;
+ if (!isFileFullyTransfered)
+ debugLogA(__FUNCTION__": file (%d) is transferred not completely", transfer->fileNumber);
+
+ if (transfer->transferType == TOX_FILE_KIND_AVATAR)
+ {
+ OnGotFriendAvatarData((AvatarTransferParam*)transfer);
+ return;
+ }
+
+ ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, isFileFullyTransfered ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)transfer, 0);
+ transfers.Remove(transfer);
+}
+
// getting the file data
-void CToxProto::OnFileReceiveData(Tox*, uint32_t friendNumber, uint32_t fileNumber, uint64_t position, const uint8_t *data, size_t length, void *arg)
+void CToxProto::OnDataReceiving(Tox*, uint32_t friendNumber, uint32_t fileNumber, uint64_t position, const uint8_t *data, size_t length, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
FileTransferParam *transfer = proto->transfers.Get(friendNumber, fileNumber);
if (transfer == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to fing transfer (%d)", fileNumber);
+ proto->debugLogA(__FUNCTION__": failed to find transfer (%d)", fileNumber);
return;
}
+ //receiving is finished
if (length == 0 || position == UINT64_MAX)
{
- //receiving is finished
- proto->debugLogA(__FUNCTION__": finised the transfer of file (%d)", fileNumber);
- bool isFileFullyTransfered = transfer->pfts.currentFileProgress == transfer->pfts.currentFileSize;
- transfer->status = isFileFullyTransfered ? FINISHED : FAILED;
- if (!isFileFullyTransfered)
- {
- proto->debugLogA(__FUNCTION__": file (%d) is transferred not completely", fileNumber);
- }
-
- if(transfer->isAvatar)
- {
- uint8_t *avatar = (uint8_t*)mir_alloc(length);
- if (fread(avatar, sizeof(uint8_t), length, transfer->hFile) != length)
- {
- proto->debugLogA(__FUNCTION__": failed to read avatar file");
- mir_free(avatar);
- return;
- }
-
- uint8_t hash[TOX_HASH_LENGTH];
- tox_hash(hash, avatar, TOX_HASH_LENGTH);
- db_set_blob(transfer->pfts.hContact, proto->m_szModuleName, TOX_SETTINGS_AVATAR_HASH, hash, TOX_HASH_LENGTH);
- mir_free(avatar);
-
- fclose(transfer->hFile);
- transfer->hFile = NULL;
-
- PROTO_AVATAR_INFORMATIONT pai = { sizeof(pai) };
- pai.format = PA_FORMAT_PNG;
- pai.hContact = transfer->pfts.hContact;
- mir_tstrcpy(pai.filename, transfer->pfts.tszCurrentFile);
- proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
- proto->transfers.Remove(transfer);
- return;
- }
-
- proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, isFileFullyTransfered ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)transfer, 0);
- proto->transfers.Remove(transfer);
+ proto->OnTransferCompleted(transfer);
+ return;
}
MCONTACT hContact = proto->GetContact(friendNumber);
@@ -207,7 +174,6 @@ void CToxProto::OnFileReceiveData(Tox*, uint32_t friendNumber, uint32_t fileNumb
{
proto->debugLogA(__FUNCTION__": failed write to file (%d)", fileNumber);
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
- transfer->status = FAILED;
tox_file_control(proto->tox, friendNumber, fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
return;
}
@@ -280,7 +246,6 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber,
// file sending is finished
proto->debugLogA(__FUNCTION__": finised the transfer of file (%d)", fileNumber);
bool isFileFullyTransfered = transfer->pfts.currentFileProgress == transfer->pfts.currentFileSize;
- transfer->status = isFileFullyTransfered ? FINISHED : FAILED;
if (!isFileFullyTransfered)
{
proto->debugLogA(__FUNCTION__": file (%d) is transferred not completely", fileNumber);
@@ -299,7 +264,6 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber,
{
proto->debugLogA(__FUNCTION__": failed to read from file (%d)", transfer->fileNumber);
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
- transfer->status = FAILED;
tox_file_control(proto->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
mir_free(data);
return;
@@ -310,7 +274,6 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber,
{
proto->debugLogA(__FUNCTION__": failed to send file chunk (%d)", error);
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
- transfer->status = FAILED;
tox_file_control(proto->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
mir_free(data);
return;
@@ -327,7 +290,6 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber,
int CToxProto::OnFileCancel(MCONTACT, HANDLE hTransfer)
{
FileTransferParam *transfer = (FileTransferParam*)hTransfer;
- transfer->status = CANCELED;
tox_file_control(tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
transfers.Remove(transfer);
@@ -351,16 +313,13 @@ void CToxProto::OnFileRequest(Tox*, uint32_t friendNumber, uint32_t fileNumber,
switch (control)
{
case TOX_FILE_CONTROL_PAUSE:
- transfer->status = PAUSED;
break;
case TOX_FILE_CONTROL_RESUME:
- transfer->status = STARTED;
proto->debugLogA("CToxProto::OnFileRequest: start/resume the transfer of file (%d)", transfer->fileNumber);
break;
case TOX_FILE_CONTROL_CANCEL:
- transfer->status = CANCELED;
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)transfer, 0);
proto->transfers.Remove(transfer);
break;
diff --git a/protocols/Tox/src/tox_transfer.h b/protocols/Tox/src/tox_transfer.h
index 2ac2726b9d..b8511779f3 100644
--- a/protocols/Tox/src/tox_transfer.h
+++ b/protocols/Tox/src/tox_transfer.h
@@ -1,32 +1,18 @@
#ifndef _TOX_TRANSFERS_H_
#define _TOX_TRANSFERS_H_
-enum FILE_TRANSFER_STATUS
-{
- NONE,
- STARTED,
- PAUSED,
- BROKEN,
- FAILED,
- CANCELED,
- FINISHED,
- DESTROYED
-};
-
struct FileTransferParam
{
PROTOFILETRANSFERSTATUS pfts;
- FILE_TRANSFER_STATUS status;
FILE *hFile;
uint32_t friendNumber;
uint32_t fileNumber;
uint64_t transferNumber;
- bool isAvatar;
+ TOX_FILE_KIND transferType;
FileTransferParam(uint32_t friendNumber, uint32_t fileNumber, const TCHAR *fileName, uint64_t fileSize)
{
- status = NONE;
hFile = NULL;
this->friendNumber = friendNumber;
this->fileNumber = fileNumber;
@@ -43,7 +29,7 @@ struct FileTransferParam
pfts.currentFileNumber = 0;
pfts.tszWorkingDir = NULL;
- isAvatar = false;
+ transferType = TOX_FILE_KIND_DATA;
}
bool OpenFile(const TCHAR *mode)
@@ -64,7 +50,6 @@ struct FileTransferParam
~FileTransferParam()
{
- status = DESTROYED;
if (pfts.tszWorkingDir != NULL)
{
mir_free(pfts.tszWorkingDir);
@@ -79,6 +64,17 @@ struct FileTransferParam
}
};
+struct AvatarTransferParam : public FileTransferParam
+{
+ uint8_t hash[TOX_HASH_LENGTH];
+
+ AvatarTransferParam(uint32_t friendNumber, uint32_t fileNumber, const TCHAR *fileName, uint64_t fileSize)
+ : FileTransferParam(friendNumber, fileNumber, NULL, fileSize)
+ {
+ transferType = TOX_FILE_KIND_AVATAR;
+ }
+};
+
class CTransferList
{
private:
@@ -119,17 +115,6 @@ public:
return NULL;
}
- void Remove(uint32_t friendNumber, uint32_t fileNumber)
- {
- int64_t transferNumber = (((int64_t)friendNumber) << 32) | ((int64_t)fileNumber);
- if (transfers.find(transferNumber) != transfers.end())
- {
- FileTransferParam *transfer = transfers.at(transferNumber);
- transfers.erase(transferNumber);
- delete transfer;
- }
- }
-
void Remove(FileTransferParam *transfer)
{
if (transfers.find(transfer->transferNumber) != transfers.end())