From 0a776a22a99c20a23763aac28209a00a36126b7b Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Mon, 25 Aug 2014 18:32:33 +0000 Subject: Tox: - updated tox core - fixdd contacts adding - some code for file sending git-svn-id: http://svn.miranda-ng.org/main/trunk@10320 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_proto.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'protocols/Tox/src/tox_proto.cpp') diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 769679cdf8..9547b33f90 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -1,7 +1,9 @@ #include "common.h" CToxProto::CToxProto(const char* protoName, const TCHAR* userName) : -PROTO(protoName, userName) + PROTO(protoName, userName), + fileSendQueue(1, NumericKeySortT), + hFileProcess(0) { InitToxCore(); @@ -61,7 +63,7 @@ MCONTACT __cdecl CToxProto::AddToList(int flags, PROTOSEARCHRESULT* psr) std::string address(mir_t2a(psr->id)); std::string id = ToxAddressToId(address); std::string myId = ToxAddressToId(getStringA(TOX_SETTINGS_ID)); - if (myId.compare(id)) + if (myId == id) { debugLogA("CToxProto::AddToList: you cannot add yourself to friend list"); return NULL; @@ -215,7 +217,16 @@ int __cdecl CToxProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre) int __cdecl CToxProto::RecvUrl(MCONTACT hContact, PROTORECVEVENT*) { return 0; } int __cdecl CToxProto::SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT* hContactsList) { return 0; } -HANDLE __cdecl CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles) { return 0; } + +HANDLE __cdecl CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles) +{ + CFileTransfer *transfer = new CFileSendTransfer(hContact, InterlockedIncrement(&hFileProcess)); + transfer->ProcessTransferedFiles(ppszFiles); + + ForkThread(&CToxProto::SendFilesAsync, transfer); + + return transfer->GetTransferHandler(); +} int __cdecl CToxProto::SendMsg(MCONTACT hContact, int flags, const char* msg) { @@ -257,10 +268,15 @@ int __cdecl CToxProto::SetStatus(int iNewStatus) SetAllContactsStatus(ID_STATUS_OFFLINE); } - m_iStatus = ID_STATUS_OFFLINE; + m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; } else { + if (old_status == ID_STATUS_CONNECTING) + { + return 0; + } + if (old_status == ID_STATUS_OFFLINE && !IsOnline()) { m_iStatus = ID_STATUS_CONNECTING; -- cgit v1.2.3