blob: 67e39012faa62553e7d37aa2ff9a96ad038203b3 [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* Copyright (C) 2005 TightVNC Team. All Rights Reserved.
2 *
3 * Developed by Dennis Syrovatsky
4 *
5 * This is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This software is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this software; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 * USA.
19 *
Peter Åstrand7877cd62009-02-25 16:15:48 +000020 *
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000021 *
22 */
23
24// -=- FileTransfer.h
25
26#ifndef __RFB_WIN32_FILETRANSFER_H__
27#define __RFB_WIN32_FILETRANSFER_H__
28
29#include <rdr/InStream.h>
30#include <rdr/OutStream.h>
31#include <rfb/msgTypes.h>
32#include <rfb/FileInfo.h>
33#include <rfb/FileReader.h>
34#include <rfb/FileWriter.h>
35#include <rfb/TransferQueue.h>
36#include <rfb/CFTMsgReader.h>
37#include <rfb/CFTMsgWriter.h>
38#include <vncviewer/FTDialog.h>
39
40namespace rfb {
41 namespace win32 {
42 class FTDialog;
43
44 class FileTransfer
45 {
46 public:
47 FileTransfer();
48 ~FileTransfer();
49
50 bool initialize(rdr::InStream *pIS, rdr::OutStream *pOS);
51 bool processFTMsg(int type);
52 bool show(HWND hwndParent);
53
54 void requestFileList(char *pPath, int dest, bool bDirOnly);
55
56 void addTransferQueue(char *pLocalPath, char *pRemotePath,
57 FileInfo *pFI, unsigned int flags);
58 void addDeleteQueue(char *pPathPrefix, FileInfo *pFI,
59 unsigned int flags);
60
61 bool isTransferEnable();
62
63 void checkTransferQueue();
64 void checkDeleteQueue();
65 bool checkCancelOperations();
66
67 void uploadFilePortion();
68
69 void createRemoteFolder(char *pPath, char *pName);
70 void renameRemote(char *pPath, char *pOldName, char *pNewName);
71
72 bool m_bCancel;
73
74 private:
75 bool m_bFTDlgShown;
76 bool m_bInitialized;
77 bool m_bResized;
78 bool m_bTransferSuccess;
79 bool m_bOverwriteAll;
80
81 FTDialog *m_pFTDialog;
82
83 rfb::CFTMsgReader *m_pReader;
84 rfb::CFTMsgWriter *m_pWriter;
85
86 FileReader m_fileReader;
87 FileWriter m_fileWriter;
88
89 FileInfo m_queueFileListRqst;
90
91 TransferQueue m_TransferQueue;
92 TransferQueue m_DeleteQueue;
93
94 bool resizeSending();
95 bool uploadFile();
96 bool downloadFile();
97
98 int isExistName(FileInfo *pFI, char *pName);
99 void freeQueues();
100
101 void endUndoneOperation();
102
103 bool procFileListDataMsg();
104 bool procFileDownloadDataMsg();
105 bool procFileUploadCancelMsg();
106 bool procFileDownloadFailedMsg();
107 bool procFileDirSizeDataMsg();
108 bool procFileLastRqstFailedMsg();
109
110 bool procFLRMain(FileInfo *pFI);
111 bool procFLRBrowse(FileInfo *pFI);
112 bool procFLRUpload(FileInfo *pFI);
113 bool procFLRDownload(FileInfo *pFI);
114 bool procFLRDelete(FileInfo *pFI);
115 bool procFLRRename(FileInfo *pFI);
116
117 int convertToUnixPath(char *path);
118
119 bool writeFileListRqst(unsigned short dirnameLen, char *pDirName, bool bDirOnly);
120 bool writeFileDownloadRqst(unsigned short filenameLen, char *pFilename,
121 unsigned int position);
122 bool writeFileUploadRqst(unsigned short filenameLen, char *pFilename,
123 unsigned int position);
124 bool writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName);
125 bool writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName);
126 bool writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen,
127 char *pOldName, char *pNewName);
128 bool writeFileDeleteRqst(unsigned short nameLen, char *pName);
129
130 DWORD64 m_dw64SizeSending;
131 unsigned int m_dirSizeRqstNum;
132 };
133 }
134}
135
136#endif // __RFB_WIN32_FILETRANSFER_H__