summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-02-01 17:15:02 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-02-01 17:15:02 +0000
commit0a377fe6d1ca13161fc6ced1375b7926476fe44a (patch)
tree93e509d813b9bea10563ef6ddcb1430dd0d987af
parent5f169b7d934be793f2a3fdb5baff3ef9b6e0f7fa (diff)
Tox: file transfer is canceled when we going to offline
git-svn-id: http://svn.miranda-ng.org/main/trunk@11976 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/Tox/src/tox_account.cpp12
-rw-r--r--protocols/Tox/src/tox_proto.cpp2
-rw-r--r--protocols/Tox/src/tox_transfer.cpp13
-rw-r--r--protocols/Tox/src/tox_transfer.h2
4 files changed, 22 insertions, 7 deletions
diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp
index 2aa3081442..49eb5fa146 100644
--- a/protocols/Tox/src/tox_account.cpp
+++ b/protocols/Tox/src/tox_account.cpp
@@ -115,6 +115,18 @@ bool CToxProto::InitToxCore()
void CToxProto::UninitToxCore()
{
+ for (size_t i = 0; i < transfers->Count(); i++)
+ {
+ FileTransferParam *transfer = transfers->GetAt(i);
+ {
+ mir_cslock(transfer->fileLock);
+
+ transfer->Cancel(tox);
+ ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)transfer, 0);
+ }
+ transfers->Remove(transfer);
+ }
+
ptrA nickname(mir_utf8encodeW(ptrT(getTStringA("Nick"))));
tox_set_name(tox, (uint8_t*)(char*)nickname, mir_strlen(nickname));
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index bf122b72e7..419dbb2814 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -260,8 +260,6 @@ int __cdecl CToxProto::SetAwayMsg(int iStatus, const PROTOCHAR *msg)
{
if (IsOnline())
{
- //WaitForSingleObject(hToxEvent, INFINITE);
-
ptrA statusMessage(msg == NULL ? mir_strdup("") : mir_utf8encodeT(msg));
if (tox_set_status_message(tox, (uint8_t*)(char*)statusMessage, min(TOX_MAX_STATUSMESSAGE_LENGTH, mir_strlen(statusMessage))) == TOX_ERROR)
{
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp
index a56799f971..fd244f5136 100644
--- a/protocols/Tox/src/tox_transfer.cpp
+++ b/protocols/Tox/src/tox_transfer.cpp
@@ -142,7 +142,13 @@ void CToxProto::OnFileData(Tox *tox, int32_t friendNumber, uint8_t fileNumber, c
// outcoming file flow
HANDLE __cdecl CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR*, PROTOCHAR **ppszFiles)
{
- uint32_t friendNumber = 0;// getDword(hContact, TOX_SETTINGS_NUMBER, TOX_ERROR);
+ ToxBinAddress pubKey = ptrA(getStringA(hContact, TOX_SETTINGS_ID));
+ int32_t friendNumber = tox_get_friend_number(tox, pubKey);
+ if (friendNumber == TOX_ERROR)
+ {
+ debugLogA("CToxProto::SendFilesAsync: cannot get friend number by public key");
+ return NULL;
+ }
TCHAR *fileName = _tcsrchr(ppszFiles[0], '\\') + 1;
@@ -237,11 +243,10 @@ void CToxProto::SendFileAsync(void *arg)
mir_free(data);
- if (transfer->status != STARTED)
+ if (transfer->status == STARTED)
{
- transfer->Fail(tox);
+ transfer->Finish(tox);
}
- transfer->Finish(tox);
}
/* COMMON */
diff --git a/protocols/Tox/src/tox_transfer.h b/protocols/Tox/src/tox_transfer.h
index 7cbbffe3ee..8bc1987bea 100644
--- a/protocols/Tox/src/tox_transfer.h
+++ b/protocols/Tox/src/tox_transfer.h
@@ -67,7 +67,7 @@ struct FileTransferParam
int Cancel(Tox *tox)
{
- status = FINISHED;
+ status = CANCELED;
return tox_file_send_control(tox, friendNumber, GetDirection(), fileNumber, TOX_FILECONTROL_KILL, NULL, 0);
}