-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileTransferOperation.h
141 lines (107 loc) · 3.84 KB
/
FileTransferOperation.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
// Copyright (C) 2009,2010,2011,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_OPERATION_H_
#define _FILE_TRANSFER_OPERATION_H_
#include "FileTransferEventAdapter.h"
#include "OperationNotPermittedException.h"
#include "FileTransferRequestSender.h"
#include "FileTransferReplyBuffer.h"
#include "FileInfoList.h"
#include "log-writer/LogWriter.h"
#include "util/ListenerContainer.h"
class OperationEventListener;
//
// Empty file transfer operation class that do nothing and
// reject all messages (FileTransferEventAdapter policy by default).
//
// Class will throw OperationNotPermitted exception when caller
// tryies to use it as event handler for file transfer messages.
//
class FileTransferOperation : public FileTransferEventAdapter,
public ListenerContainer<OperationEventListener *>
{
public:
FileTransferOperation(LogWriter *logWriter);
virtual ~FileTransferOperation();
//
// Sets request sender member
//
void setRequestSender(FileTransferRequestSender *sender);
//
// Sets reply buffer member
//
void setReplyBuffer(FileTransferReplyBuffer *replyBuffer);
//
// Start executing of operation.
// Method must be overrided by child classes.
//
virtual void start() throw(IOException) = 0;
//
// Sets terminating flag to true in this operation.
//
// Remark: subclasses of FileTransferOperation must finish
// execution when protected isTerminating method returns true.
//
virtual void terminate();
protected:
//
// Returns value of m_isTerminating flag
//
virtual bool isTerminating();
//
// Some helper methods that will be used by child classes.
//
//
// Notify all listeners that operation has started.
//
void notifyStart();
//
// Notify all listeners that operation has finished.
//
void notifyFinish();
//
// Notify all listeners that was error during operation execution
//
void notifyError(const TCHAR *message);
//
// Notify all listeners with text message
//
void notifyInformation(const TCHAR *message);
//
// Sets absolute path to @currentFile, using @localFolder string as root folder
// to @out parameter, '\' character used as separator for splitting directories.
//
void getLocalPath(FileInfoList *currentFile, const TCHAR *localFolder, StringStorage *out);
//
// Sets absolute path to @currentFile, using @remoteFolder string as root folder
// to @out parameter, '/' character used as separator for splitting directories.
//
void getRemotePath(FileInfoList *currentFile, const TCHAR *remoteFolder, StringStorage *out);
protected:
LogWriter *m_logWriter;
FileTransferRequestSender *m_sender;
FileTransferReplyBuffer *m_replyBuffer;
bool m_isTerminating;
};
#endif