FileTransfer.h
7.32 KB
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) 2002-2007 Ultr@VNC Team Members. All Rights Reserved.
//
// 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// If the source code for the program is not available from the place from
// which you received this file, check
// http://ultravnc.sourceforge.net/
//
////////////////////////////////////////////////////////////////////////////
#ifndef FILETRANSFER_H__
#define FILETRANSFER_H__
#pragma once
#include <list>
#include "ZipUnZip32/zipUnZip32.h"
#define CONFIRM_YES 1
#define CONFIRM_YESALL 2
#define CONFIRM_NO 3
#define CONFIRM_NOALL 4
typedef std::list<int> FilesList; // List of files indexes to be sent or received
class ClientConnection;
class FileTransfer
{
public:
// Props
VNCviewerApp *m_pApp;
ClientConnection *m_pCC;
HWND hWnd;
bool m_fAbort;
bool m_fUserAbortedFileTransfer; // 21 April 2008 jdp
bool m_fAborted; // Async Reception file only
int m_nDeleteCount; // Grouped file deletion trick
FilesList m_FilesList; // List of files indexes to be sent or received
FilesList::iterator m_iFile;
int m_nFilesToTransfer;
int m_nFilesTransfered;
bool m_fFileCommandPending;
bool m_fFileTransferRunning;
bool m_fVisible;
bool m_fFTAllowed;
int m_timer;
bool m_fFocusLocal;
char m_szFTParamTitle[128];
char m_szFTParamComment[64];
char m_szFTParam[248];
char m_szFTConfirmTitle[128];
char m_szFTConfirmComment[364];
int m_nConfirmAnswer;
CZipUnZip32 *m_pZipUnZip;
bool m_fApplyToAll;
bool m_fShowApplyToAll;
char m_szDeleteButtonLabel[64];
char m_szNewFolderButtonLabel[64];
char m_szRenameButtonLabel[64];
__int64 m_nnFileSize;
DWORD m_dwCurrentValue;
DWORD m_dwCurrentPercent;
// File Sending (upload)
HANDLE m_hSrcFile;
char m_szSrcFileName[MAX_PATH + 32];
DWORD m_dwNbBytesRead;
__int64 m_dwTotalNbBytesRead;
bool m_fEof;
bool m_fFileUploadError;
bool m_fFileUploadRunning;
bool m_fSendFileChunk;
bool m_fCompress;
char* m_lpCSBuffer;
int m_nCSOffset;
int m_nCSBufferSize;
// Directory list reception
WIN32_FIND_DATA m_fd;
int m_nFileCount;
bool m_fDirectoryReceptionRunning;
char m_szFileSpec[MAX_PATH + 64];
// File reception (download)
char m_szDestFileName[MAX_PATH + 32];
HANDLE m_hDestFile;
DWORD m_dwNbReceivedPackets;
DWORD m_dwNbBytesWritten;
__int64 m_dwTotalNbBytesWritten;
__int64 m_dwTotalNbBytesNotReallyWritten;
int m_nPacketCount;
bool m_fPacketCompressed;
bool m_fFileDownloadRunning;
bool m_fFileDownloadError;
char m_szIncomingFileTime[18];
bool m_fOldFTProtocole;
int m_nBlockSize;
int m_nNotSent;
DWORD m_dwLastChunkTime;
MMRESULT m_mmRes;
bool bSortDirectionsL[3];
bool bSortDirectionsR[3];
HMODULE m_hRichEdit; // 16 April 2008 jdp
// Methods
FileTransfer(VNCviewerApp *pApp, ClientConnection *pCC);
int DoDialog();
virtual ~FileTransfer();
static BOOL CALLBACK FileTransferDlgProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
static BOOL CALLBACK LFBWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static BOOL CALLBACK RFBWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int DoFTParamDialog(LPSTR szTitle, LPSTR szComment);
static BOOL CALLBACK FTParamDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
int DoFTConfirmDialog(LPSTR szTitle, LPSTR szComment);
static BOOL CALLBACK FTConfirmDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
static int CALLBACK ListViewLocalCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); /*TAW*/
static int CALLBACK ListViewRemoteCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); /*TAW*/
void DisableButtons(HWND hWnd);
void EnableButtons(HWND hWnd);
bool SendFile(long lSize, int nLen);
bool SendFileChunk();
bool FinishFileReception();
int UnzipPossibleDirectory(LPSTR szFileName);
bool SendFiles(long lSize, int nLen);
bool OfferNextFile();
void ListRemoteDrives(HWND hWnd, int nLen);
void ProcessFileTransferMsg(void);
void RequestPermission();
bool TestPermission(long lSize, int nVersion);
void AddFileToFileList(HWND hWnd, int nListId, WIN32_FIND_DATA& fd, bool fLocalSide);
void RequestRemoteDirectoryContent(HWND hWnd, LPSTR szPath);
void RequestRemoteDrives();
void RequestRemoteFile(LPSTR szRemoteFileName);
bool OfferLocalFile(LPSTR szSrcFileName);
int ZipPossibleDirectory(LPSTR szSrcFileName);
bool ReceiveFile(unsigned long lSize, int nLen);
bool ReceiveFileChunk(int nLen, int nSize);
bool FinishFileSending();
bool AbortFileReception();
bool ReceiveFiles(unsigned long lSize, int nLen);
bool RequestNextFile();
bool ReceiveDestinationFileChecksums(int nSize, int nLen);
void HighlightTransferedFiles(HWND hSrcList, HWND hDstList);
void PopulateRemoteListBox(HWND hWnd, int nLen);
void ReceiveDirectoryItem(HWND hWnd, int nLen);
void FinishDirectoryReception();
bool IsShortcutFolder(LPSTR szPath);
bool ResolvePossibleShortcutFolder(HWND hWnd, LPSTR szFolder);
void PopulateLocalListBox(HWND hWnd, LPSTR szPath);
void ListDrives(HWND hWnd);
void CreateRemoteDirectory(LPSTR szDir);
void DeleteRemoteFile(LPSTR szFile);
bool CreateRemoteDirectoryFeedback(long lSize, int nLen);
bool DeleteRemoteFileFeedback(long lSize, int nLen);
void RenameRemoteFileOrDirectory(LPSTR szCurrentName, LPSTR szNewName);
bool RenameRemoteFileOrDirectoryFeedback(long lSize, int nLen);
int GenerateFileChecksums(HANDLE hFile, char* lpCSBuffer, int nCSBufferSize);
void SetTotalSize(HWND hwnd,DWORD dwTotalSize);
void SetGauge(HWND hwnd,__int64 dwCount);
void SetGlobalCount();
void SetStatus(LPSTR szStatus);
void ShowFileTransferWindow(bool fVisible);
bool IsDirectoryGetIt(char* szName);
bool GetSpecialFolderPath(int nId, char* szPath);
void GetFriendlyFileSizeString(__int64 Size, char* szText);
bool MyGetFileSize(char* szFilePath, ULARGE_INTEGER* n2FileSize);
void InitListViewImagesList(HWND hListView);
bool DeleteFileOrDirectory(TCHAR *srcpath); // 14 April 2008 jdp
void FileTransfer::InitFTTimer();
void FileTransfer::KillFTTimer();
static void CALLBACK fpTimer(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2);
static __int64 GetFileSizeFromString(char* szSize);
static FILETIME GetFileTimeFromString(char* szFileSystemTime);
};
#endif // FILETRANSFER_H__