summaryrefslogtreecommitdiffstats
path: root/win/vncviewer/FileTransfer.h
blob: 67e39012faa62553e7d37aa2ff9a96ad038203b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* Copyright (C) 2005 TightVNC Team.  All Rights Reserved.
 *
 * Developed by Dennis Syrovatsky
 *    
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this software; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 * USA.
 *
 * 
 *
 */

// -=- FileTransfer.h

#ifndef __RFB_WIN32_FILETRANSFER_H__
#define __RFB_WIN32_FILETRANSFER_H__

#include <rdr/InStream.h>
#include <rdr/OutStream.h>
#include <rfb/msgTypes.h>
#include <rfb/FileInfo.h>
#include <rfb/FileReader.h>
#include <rfb/FileWriter.h>
#include <rfb/TransferQueue.h>
#include <rfb/CFTMsgReader.h>
#include <rfb/CFTMsgWriter.h>
#include <vncviewer/FTDialog.h>

namespace rfb {
  namespace win32 {
    class FTDialog;

    class FileTransfer
    {
    public:
      FileTransfer();
      ~FileTransfer();

      bool initialize(rdr::InStream *pIS, rdr::OutStream *pOS);
      bool processFTMsg(int type);
      bool show(HWND hwndParent);

      void requestFileList(char *pPath, int dest, bool bDirOnly);

      void addTransferQueue(char *pLocalPath, char *pRemotePath, 
                            FileInfo *pFI, unsigned int flags);
      void addDeleteQueue(char *pPathPrefix, FileInfo *pFI, 
                          unsigned int flags);

      bool isTransferEnable();

      void checkTransferQueue();
      void checkDeleteQueue();
      bool checkCancelOperations();

      void uploadFilePortion();

      void createRemoteFolder(char *pPath, char *pName);
      void renameRemote(char *pPath, char *pOldName, char *pNewName);

      bool m_bCancel;

    private:
      bool m_bFTDlgShown;
      bool m_bInitialized;
      bool m_bResized;
      bool m_bTransferSuccess;
      bool m_bOverwriteAll;

      FTDialog *m_pFTDialog;

      rfb::CFTMsgReader *m_pReader;
      rfb::CFTMsgWriter *m_pWriter;

      FileReader m_fileReader;
      FileWriter m_fileWriter;

      FileInfo m_queueFileListRqst;

      TransferQueue m_TransferQueue;
      TransferQueue m_DeleteQueue;

      bool resizeSending();
      bool uploadFile();
      bool downloadFile();

      int  isExistName(FileInfo *pFI, char *pName);
      void freeQueues();

      void endUndoneOperation();
      
      bool procFileListDataMsg();
      bool procFileDownloadDataMsg();
      bool procFileUploadCancelMsg();
      bool procFileDownloadFailedMsg();
      bool procFileDirSizeDataMsg();
      bool procFileLastRqstFailedMsg();
      
      bool procFLRMain(FileInfo *pFI);
      bool procFLRBrowse(FileInfo *pFI);
      bool procFLRUpload(FileInfo *pFI);
      bool procFLRDownload(FileInfo *pFI);
      bool procFLRDelete(FileInfo *pFI);
      bool procFLRRename(FileInfo *pFI);

      int convertToUnixPath(char *path);

      bool writeFileListRqst(unsigned short dirnameLen, char *pDirName, bool bDirOnly);
      bool writeFileDownloadRqst(unsigned short filenameLen, char *pFilename, 
                                 unsigned int position);
      bool writeFileUploadRqst(unsigned short filenameLen, char *pFilename, 
                               unsigned int position);
      bool writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName);
      bool writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName);
      bool writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen,
                               char *pOldName, char *pNewName);
      bool writeFileDeleteRqst(unsigned short nameLen, char *pName);

      DWORD64 m_dw64SizeSending;
      unsigned int m_dirSizeRqstNum;
    };
  }
}

#endif // __RFB_WIN32_FILETRANSFER_H__