-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileTransferCore.h
206 lines (164 loc) · 6.53 KB
/
FileTransferCore.h
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
// Copyright (C) 2012 GlavSoft LLC.
// All rights reserved.
//
//-------------------------------------------------------------------------
// This file is part of the TightVNC software. Please visit our Web site:
//
// http://www.tightvnc.com/
//
// This program 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 program 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 program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//-------------------------------------------------------------------------
//
#ifndef _FILE_TRANSFER_CORE_H_
#define _FILE_TRANSFER_CORE_H_
#include "ft-common/FileInfo.h"
#include "log-writer/LogWriter.h"
#include "FileTransferEventHandler.h"
#include "FileTransferRequestSender.h"
#include "FileTransferReplyBuffer.h"
#include "FileTransferOperation.h"
#include "OperationEventListener.h"
#include "CopyFileEventListener.h"
#include "OperationSupport.h"
#include "FileTransferInterface.h"
class FileTransferInterface;
class FileTransferCore : public OperationEventListener,
public CopyFileEventListener
{
public:
//
// Creates new instance of class.
//
// Parameters:
// sender - object that needs for file transfer operations
// replyBuffer - object that needs for file transfer operations
// ftListeners - needs for executing file transfer operations
//
FileTransferCore(LogWriter *logWriter,
FileTransferRequestSender *sender,
FileTransferReplyBuffer *replyBuffer,
ListenerContainer<FileTransferEventHandler *> *ftListeners);
virtual ~FileTransferCore();
void setInterface(FileTransferInterface *ftInterface);
const OperationSupport &getSupportedOps();
vector<FileInfo> *getListLocalFolder(const TCHAR *pathToFile);
vector<FileInfo> *getListRemoteFolder();
void downloadOperation(const FileInfo *filesToDownload,
size_t filesCount,
const TCHAR *pathToTargetRoot,
const TCHAR *pathToSourceRoot);
void uploadOperation(const FileInfo *filesToDownload,
size_t filesCount,
const TCHAR *pathToSourceRoot,
const TCHAR *pathToTargetRoot);
void localFilesDeleteOperation(const FileInfo *filesToDelete,
UINT32 filesCount,
const TCHAR *pathToTargetRoot);
void remoteFilesDeleteOperation(const FileInfo *filesInfoToDelete,
size_t filesCount,
const TCHAR *pathToTargetRoot);
void remoteFolderCreateOperation(FileInfo file, const TCHAR *pathToTargetRoot);
void remoteFileRenameOperation(FileInfo sourceFileInfo,
FileInfo targetFileInfo,
const TCHAR *pathToTargetRoot);
void remoteFileListOperation(const TCHAR *pathToFile);
void terminateCurrentOperation();
bool isNothingState();
void onOperationFinished();
void onUpdateState(int state, int result);
// FIXME: Debug.
void updateSupportedOperations(const vector<UINT32> *clientCaps,
const vector<UINT32> *serverCaps);
protected:
//
// Inherited from CopyFileEventListener
//
virtual void dataChunkCopied(UINT64 totalBytesCopied, UINT64 totalBytesToCopy);
virtual int targetFileExists(FileInfo *sourceFileInfo,
FileInfo *targetFileInfo,
const TCHAR *pathToTargetFile);
//
// Inherited from OperationEventListener
//
virtual void ftOpStarted(FileTransferOperation *sender);
virtual void ftOpFinished(FileTransferOperation *sender) throw(IOException);
virtual void ftOpErrorMessage(FileTransferOperation *sender, const TCHAR *message);
virtual void ftOpInfoMessage(FileTransferOperation *sender,
const TCHAR *message);
//
// Interface of log
//
LogWriter *m_logWriter;
//
// Current dialog state, needed for checking what type of
// file transfer operation is executing now (means nothing or
// delete, upload, download etc).
//
int m_state;
//
// Current file transfer operation.
// Remark: only one file operation can be executed at one time
//
FileTransferOperation *m_currentOperation;
//
// File transfer message listener container.
//
// This member needs for executing file transfer operations,
// after operation is created, but before it has started it needs
// to be added to these listeners, after it has finished work needs
// to remove operation from listeners list.
//
ListenerContainer<FileTransferEventHandler *> *m_fileTransferListeners;
//
// Request sender, reply buffer
//
FileTransferRequestSender *m_sender;
FileTransferReplyBuffer *m_replyBuffer;
//
// Class that knows about supported operations.
//
OperationSupport m_supportedOps;
//
// File list request variables
//
vector <FileInfo> m_remoteFilesInfo;
//
// Local file list variables
//
vector <FileInfo> m_localFilesInfo;
//
// file transfer interface
//
FileTransferInterface *m_ftInterface;
//
// Frees previous file transfer operation if it was, sets
// common file transfer operation parameters to new operation, made
// new operation current and executes it.
//
void executeOperation(FileTransferOperation *newOperation) throw(IOException);
//
// Avaliable m_state values
// FIXME: Maybe make m_state enumeration?
//
static const int NOTHING_STATE = 0x0;
static const int FILE_LIST_STATE = 0x1;
static const int REMOVE_STATE = 0x2;
static const int MKDIR_STATE = 0x3;
static const int RENAME_STATE = 0x4;
static const int LOCAL_REMOVE_STATE = 0x5;
static const int UPLOAD_STATE = 0x6;
static const int DOWNLOAD_STATE = 0x7;
};
#endif