-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOperationSupport.cpp
137 lines (113 loc) · 4.85 KB
/
OperationSupport.cpp
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
// 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.
//-------------------------------------------------------------------------
//
#include "OperationSupport.h"
#include "ft-common/FTMessage.h"
#include <algorithm>
OperationSupport::OperationSupport()
{
m_isFileListSupported = false;
m_isRenameSupported = false;
m_isRemoveSupported = false;
m_isMkDirSupported = false;
m_isCompressionSupported = false;
m_isMD5Supported = false;
m_isDirSizeSupported = false;
m_isUploadSupported = false;
m_isDownloadSupported = false;
}
OperationSupport::OperationSupport(const std::vector<UINT32> &clientCodes,
const std::vector<UINT32> &serverCodes)
{
m_isFileListSupported = isSupport(clientCodes, FTMessage::FILE_LIST_REQUEST) &&
isSupport(serverCodes, FTMessage::FILE_LIST_REPLY);
m_isRenameSupported = isSupport(clientCodes, FTMessage::RENAME_REQUEST) &&
isSupport(serverCodes, FTMessage::RENAME_REPLY);
m_isRemoveSupported = isSupport(clientCodes, FTMessage::REMOVE_REQUEST) &&
isSupport(serverCodes, FTMessage::REMOVE_REPLY) &&
m_isFileListSupported;
m_isMkDirSupported = isSupport(clientCodes, FTMessage::MKDIR_REQUEST) &&
isSupport(serverCodes, FTMessage::MKDIR_REPLY);
m_isCompressionSupported = isSupport(clientCodes, FTMessage::COMPRESSION_SUPPORT_REQUEST) &&
isSupport(serverCodes, FTMessage::COMPRESSION_SUPPORT_REPLY);
m_isMD5Supported = isSupport(clientCodes, FTMessage::MD5_REQUEST) &&
isSupport(serverCodes, FTMessage::MD5_REPLY);
m_isDirSizeSupported = isSupport(clientCodes, FTMessage::DIRSIZE_REQUEST) &&
isSupport(serverCodes, FTMessage::DIRSIZE_REPLY);
m_isUploadSupported = isSupport(clientCodes, FTMessage::UPLOAD_START_REQUEST) &&
isSupport(clientCodes, FTMessage::UPLOAD_DATA_REQUEST) &&
isSupport(clientCodes, FTMessage::UPLOAD_END_REQUEST) &&
isSupport(serverCodes, FTMessage::UPLOAD_START_REPLY) &&
isSupport(serverCodes, FTMessage::UPLOAD_DATA_REPLY) &&
isSupport(serverCodes, FTMessage::UPLOAD_END_REPLY) &&
m_isMkDirSupported && m_isFileListSupported;
m_isDownloadSupported = (isSupport(clientCodes, FTMessage::DOWNLOAD_START_REQUEST) &&
isSupport(clientCodes, FTMessage::DOWNLOAD_DATA_REQUEST) &&
isSupport(serverCodes, FTMessage::DOWNLOAD_START_REPLY) &&
isSupport(serverCodes, FTMessage::DOWNLOAD_DATA_REPLY) &&
isSupport(serverCodes, FTMessage::DOWNLOAD_END_REPLY) &&
m_isFileListSupported && m_isDirSizeSupported);
}
OperationSupport::~OperationSupport()
{
}
bool OperationSupport::isFileListSupported() const
{
return m_isFileListSupported;
}
bool OperationSupport::isUploadSupported() const
{
return m_isUploadSupported;
}
bool OperationSupport::isDownloadSupported() const
{
return m_isDownloadSupported;
}
bool OperationSupport::isRenameSupported() const
{
return m_isRenameSupported;
}
bool OperationSupport::isRemoveSupported() const
{
return m_isRemoveSupported;
}
bool OperationSupport::isMkDirSupported() const
{
return m_isMkDirSupported;
}
bool OperationSupport::isCompressionSupported() const
{
return m_isCompressionSupported;
}
bool OperationSupport::isMD5Supported() const
{
return m_isMD5Supported;
}
bool OperationSupport::isDirSizeSupported() const
{
return m_isDirSizeSupported;
}
bool OperationSupport::isSupport(const std::vector<UINT32> &codes, UINT32 code)
{
return std::find(codes.begin(), codes.end(), code) != codes.end();
}