summaryrefslogtreecommitdiffstats
path: root/vncviewer/FileTransfer.h
blob: c2facd57d7fe8eb1b0ee94716e66d1b4c47d975f (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
/* Copyright (C) 2005 TightVNC Team.  All Rights Reserved.
 *    
 * 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.
 *
 * TightVNC distribution homepage on the Web: http://www.tightvnc.com/
 *
 */

// -=- 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 <vncviewer/FTDialog.h>
#include <vncviewer/FTMsgReader.h>
#include <vncviewer/FTMsgWriter.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();

      void uploadFilePortion();

    private:
      bool m_bFTDlgShown;
      bool m_bInitialized;
      bool m_bResized;

      FTDialog *m_pFTDialog;

      FTMsgReader *m_pReader;
      FTMsgWriter *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();
      
      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);

      DWORD64 m_dw64SizeSending;
      unsigned int m_dirSizeRqstNum;
    };
  }
}

#endif // __RFB_WIN32_FILETRANSFER_H__