From cfc04a114e5d83318f26e0641cfd36ed26736196 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 May 2020 13:31:16 +0300 Subject: =?UTF-8?q?fixes=20#2390=20(ICQ=20=D0=B8=D0=B3=D0=BD=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D1=80=D1=83=D0=B5=D1=82=20=D0=BD=D0=B0=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B9=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8=D1=91=D0=BC=D0=B0?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/ICQ-WIM/src/proto.cpp | 13 +++++++++++++ protocols/ICQ-WIM/src/proto.h | 2 ++ protocols/ICQ-WIM/src/server.cpp | 11 ++++++++--- protocols/JabberG/src/stdafx.h | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 3fc7005795..3aaba62d5c 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -431,6 +431,19 @@ int CIcqProto::FileCancel(MCONTACT hContact, HANDLE hTransfer) return 0; } +int CIcqProto::FileResume(HANDLE hTransfer, int *action, const wchar_t **szFilename) +{ + auto *ft = (IcqFileTransfer *)hTransfer; + if (!m_bOnline || ft == nullptr) + return 1; + + if (*action == FILERESUME_RENAME) { + ft->m_wszFileName = *szFilename; + ft->pfts.szCurrentFile.w = ft->m_wszFileName.GetBuffer(); + } + return 0; +} + //////////////////////////////////////////////////////////////////////////////////////// // GetCaps - return protocol capabilities bits diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 0542497ee4..34f8ab8321 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -171,6 +171,7 @@ struct IcqFileTransfer : public MZeroedObject CMStringW m_wszFileName, m_wszDescr; const wchar_t *m_wszShortName; PROTOFILETRANSFERSTATUS pfts; + HANDLE hWaitEvent; void FillHeaders(AsyncHttpRequest *pReq) { @@ -412,6 +413,7 @@ class CIcqProto : public PROTO HANDLE FileAllow(MCONTACT hContact, HANDLE hTransfer, const wchar_t *szPath) override; int FileCancel(MCONTACT hContact, HANDLE hTransfer) override; + int FileResume(HANDLE hTransfer, int *action, const wchar_t **szFilename) override; HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override; int SendMsg(MCONTACT hContact, int flags, const char *msg) override; diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 6f37950339..29528b9af1 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -865,9 +865,10 @@ LBL_Error: return; } - ft->pfts.totalProgress += pReply->dataLength; - ft->pfts.currentFileProgress += pReply->dataLength; - ProtoBroadcastAck(ft->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->pfts); + ft->hWaitEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); + if (ProtoBroadcastAck(ft->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, ft, (LPARAM)&ft->pfts)) + WaitForSingleObject(ft->hWaitEvent, INFINITE); + CloseHandle(ft->hWaitEvent); debugLogW(L"Saving to [%s]", ft->pfts.szCurrentFile.w); int fileId = _wopen(ft->pfts.szCurrentFile.w, _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY, _S_IREAD | _S_IWRITE); @@ -883,6 +884,10 @@ LBL_Error: goto LBL_Error; } + ft->pfts.totalProgress += pReply->dataLength; + ft->pfts.currentFileProgress += pReply->dataLength; + ProtoBroadcastAck(ft->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&ft->pfts); + ProtoBroadcastAck(ft->pfts.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); delete ft; } diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 5fd07d23e3..2082acca92 100755 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -431,7 +431,7 @@ struct filetransfer : public MZeroedObject char* szId; char* sid; int bCompleted; - HANDLE hWaitEvent; + HANDLE hWaitEvent = INVALID_HANDLE_VALUE; // For type == FT_BYTESTREAM JABBER_BYTE_TRANSFER *jbt; -- cgit v1.2.3