diff options
author | Pierre Ossman <ossman@cendio.se> | 2009-03-13 14:41:27 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2009-03-13 14:41:27 +0000 |
commit | f99c5719e465eb00b7e1bd9c16720ede6fa08b52 (patch) | |
tree | 9e5898466b865e4cad6c451703ce3acfdb47954f /win | |
parent | 4f0f7db92b11a87660424132bfbbf872ec3cc2e6 (diff) | |
download | tigervnc-f99c5719e465eb00b7e1bd9c16720ede6fa08b52.tar.gz tigervnc-f99c5719e465eb00b7e1bd9c16720ede6fa08b52.zip |
Remove file transfer support.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3677 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'win')
31 files changed, 0 insertions, 4063 deletions
diff --git a/win/rfb_win32/FolderManager.cxx b/win/rfb_win32/FolderManager.cxx deleted file mode 100644 index f6b94eb9..00000000 --- a/win/rfb_win32/FolderManager.cxx +++ /dev/null @@ -1,277 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky. - * - * 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. - * - * - * - */ - -// -=- FolderManager.cxx - -#include <rfb_win32/FolderManager.h> - -using namespace rfb; -using namespace rfb::win32; - -FolderManager::FolderManager() -{ - -} - -FolderManager::~FolderManager() -{ - -} - -bool -FolderManager::createDir(char *pFullPath) -{ - if (CreateDirectory(pFullPath, NULL) == 0) return false; - - return true; -} - -bool -FolderManager::renameIt(char *pPath, char *pOldName, char *pNewName) -{ - char fullOldName[FT_FILENAME_SIZE]; - char fullNewName[FT_FILENAME_SIZE]; - - sprintf(fullOldName, "%s\\%s", pPath, pOldName); - sprintf(fullNewName, "%s\\%s", pPath, pNewName); - - return renameIt(fullOldName, fullNewName); -} - -bool -FolderManager::renameIt(char *pOldName, char *pNewName) -{ - if (MoveFile(pOldName, pNewName)) return true; - - return false; -} - -bool -FolderManager::deleteIt(char *pFullPath) -{ - FileInfo fileInfo; - - FILEINFO FIStruct; - if (!getInfo(pFullPath, &FIStruct)) return false; - - fileInfo.add(&FIStruct); - - return deleteIt(&fileInfo); -} - -bool -FolderManager::deleteIt(char *pPrefix, FileInfo *pFI) -{ - char buf[FT_FILENAME_SIZE]; - for (unsigned int i = 0; i < pFI->getNumEntries(); i++) { - sprintf(buf, "%s\\%s", pPrefix, pFI->getNameAt(i)); - pFI->setNameAt(i,buf); - } - return deleteIt(pFI); -} - -bool -FolderManager::deleteIt(FileInfo *pFI) -{ - unsigned int num = pFI->getNumEntries(); - unsigned int last = num - 1; - - while (num > 0) { - if (pFI->getFlagsAt(last) & FT_ATTR_DIR) { - if (RemoveDirectory(pFI->getNameAt(last)) == 0) { - if (GetLastError() == ERROR_DIR_NOT_EMPTY) { - if (!getFolderInfoWithPrefix(pFI->getNameAt(last), pFI)) { - pFI->free(); - return false; - } - } - } else { - pFI->deleteAt(last); - } - } else { - if (DeleteFile(pFI->getNameAt(last)) == 0) { - pFI->free(); - return false; - } else { - pFI->deleteAt(last); - } - } - num = pFI->getNumEntries(); - last = num - 1; - } - - return true; -} - -bool -FolderManager::getFolderInfoWithPrefix(char *pPrefix, FileInfo *pFileInfo) -{ - char prefix[FT_FILENAME_SIZE]; - strcpy(prefix, pPrefix); - - FileInfo tmpFileInfo; - if (!getDirInfo(prefix, &tmpFileInfo, 0)) { - tmpFileInfo.free(); - return false; - } else { - char buf[FT_FILENAME_SIZE]; - for (unsigned int i = 0; i < tmpFileInfo.getNumEntries(); i++) { - sprintf(buf, "%s\\%s", prefix, tmpFileInfo.getNameAt(i)); - pFileInfo->add(buf, tmpFileInfo.getSizeAt(i), tmpFileInfo.getDataAt(i), tmpFileInfo.getFlagsAt(i)); - } - } - tmpFileInfo.free(); - return true; -} - -bool -FolderManager::getDirInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirOnly) -{ - if (strlen(pPath) == 0) return getDrivesInfo(pFileInfo); - - char path[FT_FILENAME_SIZE]; - sprintf(path, "%s\\*", pPath); - - WIN32_FIND_DATA FindFileData; - SetErrorMode(SEM_FAILCRITICALERRORS); - HANDLE handle = FindFirstFile(path, &FindFileData); - SetErrorMode(0); - - if (handle != INVALID_HANDLE_VALUE) { - do { - if (strcmp(FindFileData.cFileName, ".") != 0 && - strcmp(FindFileData.cFileName, "..") != 0) { - unsigned int lastWriteTime = getTime70(FindFileData.ftLastWriteTime); - if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - pFileInfo->add(FindFileData.cFileName, 0, lastWriteTime, FT_ATTR_DIR); - } else { - if (!dirOnly) - pFileInfo->add(FindFileData.cFileName, FindFileData.nFileSizeLow, lastWriteTime, FT_ATTR_FILE); - } - } - - } while (FindNextFile(handle, &FindFileData)); - } else { - return false; - } - FindClose(handle); - return true; -} - -bool -FolderManager::getDrivesInfo(FileInfo *pFileInfo) -{ - TCHAR szDrivesList[256]; - if (GetLogicalDriveStrings(255, szDrivesList) == 0) - return false; - - int i = 0; - while (szDrivesList[i] != '\0') { - char *drive = strdup(&szDrivesList[i]); - char *backslash = strrchr(drive, '\\'); - if (backslash != NULL) - *backslash = '\0'; - pFileInfo->add(drive, 0, 0, FT_ATTR_DIR); - free(drive); - i += strcspn(&szDrivesList[i], "\0") + 1; - } - return true; -} - -bool -FolderManager::getInfo(char *pFullPath, FILEINFO *pFIStruct) -{ - WIN32_FIND_DATA FindFileData; - SetErrorMode(SEM_FAILCRITICALERRORS); - HANDLE hFile = FindFirstFile(pFullPath, &FindFileData); - SetErrorMode(0); - if (hFile != INVALID_HANDLE_VALUE) { - FindClose(hFile); - strcpy(pFIStruct->name, pFullPath); - pFIStruct->info.data = getTime70(FindFileData.ftLastWriteTime); - if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - pFIStruct->info.size = 0; - pFIStruct->info.flags = FT_ATTR_DIR; - return true; - } else { - pFIStruct->info.size = FindFileData.nFileSizeLow; - pFIStruct->info.flags = FT_ATTR_FILE; - return true; - } - } - return false; -} - -unsigned int -FolderManager::getTime70(FILETIME ftime) -{ - LARGE_INTEGER uli; - uli.LowPart = ftime.dwLowDateTime; - uli.HighPart = ftime.dwHighDateTime; - uli.QuadPart = (uli.QuadPart - 116444736000000000LL) / 10000000; - return uli.LowPart; -} - -void -FolderManager::getFiletime(unsigned int time70, FILETIME *pftime) -{ - LONGLONG ll = Int32x32To64(time70, 10000000) + 116444736000000000LL; - pftime->dwLowDateTime = (DWORD) ll; - pftime->dwHighDateTime = (DWORD) (ll >> 32); -} - -bool -FolderManager::getDirSize(char *pFullPath, DWORD64 *dirSize) -{ - char fullPath[FT_FILENAME_SIZE]; - FileInfo fi; - fi.add(pFullPath, 0, 0, FT_ATTR_DIR); - DWORD64 dirFileSize64 = 0; - do { - sprintf(fullPath, "%s\\*", fi.getNameAt(0)); - WIN32_FIND_DATA FindFileData; - SetErrorMode(SEM_FAILCRITICALERRORS); - HANDLE hFile = FindFirstFile(fullPath, &FindFileData); - SetErrorMode(0); - - if (hFile != INVALID_HANDLE_VALUE) { - do { - if (strcmp(FindFileData.cFileName, ".") != 0 && - strcmp(FindFileData.cFileName, "..") != 0) { - char buff[MAX_PATH]; - if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - sprintf(buff, "%s\\%s", fi.getNameAt(0), FindFileData.cFileName); - fi.add(buff, 0, 0, FT_ATTR_DIR); - } else { - dirFileSize64 += FindFileData.nFileSizeLow; - } - } - } while (FindNextFile(hFile, &FindFileData)); - FindClose(hFile); - } - fi.deleteAt(0); - } while (fi.getNumEntries() > 0); - - *dirSize = dirFileSize64; - return true; -} diff --git a/win/rfb_win32/FolderManager.h b/win/rfb_win32/FolderManager.h deleted file mode 100644 index 9ce757fe..00000000 --- a/win/rfb_win32/FolderManager.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky. - * - * 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. - * - * - * - */ - -// -=- FolderManager.h - -#ifndef __RFB_WIN32_FOLDERMANAGER_H__ -#define __RFB_WIN32_FOLDERMANAGER_H__ - -#include <windows.h> - -#include <rfb/FileInfo.h> -#include <rfb/DirManager.h> - -namespace rfb { - namespace win32{ - class FolderManager : public DirManager { - public: - FolderManager(); - ~FolderManager(); - - bool createDir(char *pFullPath); - - bool renameIt(char *pOldName, char *pNewName); - bool renameIt(char *pPath, char *pOldName, char *pNewName); - - bool deleteIt(char *pPrefix, FileInfo *pFI); - bool deleteIt(char *pFullPath); - bool deleteIt(FileInfo *pFI); - - bool getInfo(char *pFullPath, FILEINFO *pFIStruct); - - bool getDirInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirOnly); - bool getDrivesInfo(FileInfo *pFI); - - unsigned int getTime70(FILETIME ftime); - void getFiletime(unsigned int time70, FILETIME *pftime); - - bool getDirSize(char *pFullPath, DWORD64 *dirSize); - - private: - bool getFolderInfoWithPrefix(char *pPrefix, FileInfo *pFileInfo); - }; - } -} - -#endif // __RFB_WIN32_FOLDERMANAGER_H__ diff --git a/win/rfb_win32/Makefile.am b/win/rfb_win32/Makefile.am index 9ba8e4b7..e1e9c7c4 100644 --- a/win/rfb_win32/Makefile.am +++ b/win/rfb_win32/Makefile.am @@ -16,7 +16,6 @@ HDRS = \ DIBSectionBuffer.h \ DynamicFn.h \ EventManager.h \ - FolderManager.h \ Handle.h \ IconInfo.h \ IntervalTimer.h \ @@ -41,8 +40,6 @@ HDRS = \ SDisplay.h \ Security.h \ Service.h \ - SFileTransferManagerWin32.h \ - SFileTransferWin32.h \ SInput.h \ SocketManager.h \ TCharArray.h \ @@ -73,7 +70,6 @@ librfb_win32_la_SOURCES = $(HDRS) \ DIBSectionBuffer.cxx \ DynamicFn.cxx \ EventManager.cxx \ - FolderManager.cxx \ LaunchProcess.cxx \ ListViewControl.cxx \ LowLevelKeyEvents.cxx \ @@ -89,8 +85,6 @@ librfb_win32_la_SOURCES = $(HDRS) \ SDisplay.cxx \ Security.cxx \ Service.cxx \ - SFileTransferManagerWin32.cxx \ - SFileTransferWin32.cxx \ SInput.cxx \ SocketManager.cxx \ TCharArray.cxx \ diff --git a/win/rfb_win32/SFileTransferManagerWin32.cxx b/win/rfb_win32/SFileTransferManagerWin32.cxx deleted file mode 100644 index 048e3aac..00000000 --- a/win/rfb_win32/SFileTransferManagerWin32.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (C) 2006 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky. - * - * 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. - * - * - * - */ - -// -=- SFileTransferManagerWin32.cxx - -#include <rfb_win32/SFileTransferManagerWin32.h> - -using namespace rfb; -using namespace win32; - -SFileTransferManagerWin32::SFileTransferManagerWin32() -{ - -} - -SFileTransferManagerWin32::~SFileTransferManagerWin32() -{ - -} - -SFileTransfer * -SFileTransferManagerWin32::createObject(network::Socket *sock) -{ - rfb::SFileTransfer *pFT = 0; - rfb::win32::SFileTransferWin32 *pFTWin32 = 0; - - pFTWin32 = new SFileTransferWin32(sock); - if (pFTWin32 == NULL) return NULL; - - pFT = (SFileTransfer *) pFTWin32; - - m_lstFTObjects.push_front(pFT); - - return pFT; -} - -void -SFileTransferManagerWin32::processDownloadMsg(MSG msg) -{ - SFileTransfer *pFT = (SFileTransfer *)msg.lParam; - - if (pFT != NULL) { - std::list<SFileTransfer*>::iterator i; - for (i=m_lstFTObjects.begin(); i!=m_lstFTObjects.end(); i++) { - if ((*i) == pFT) { - (*i)->sendFileDownloadPortion(); - return; - } - } - } -} diff --git a/win/rfb_win32/SFileTransferManagerWin32.h b/win/rfb_win32/SFileTransferManagerWin32.h deleted file mode 100644 index c12e3df9..00000000 --- a/win/rfb_win32/SFileTransferManagerWin32.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2006 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky. - * - * 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. - * - * - * - */ - -// -=- SFileTransferManagerWin32.h - -#ifndef __RFB_WIN32_SFILETRANSFERMANAGERWIN32_H__ -#define __RFB_WIN32_SFILETRANSFERMANAGERWIN32_H__ - -#include <rfb/SFileTransfer.h> -#include <rfb/SFileTransferManager.h> -#include <rfb_win32/SFileTransferWin32.h> - -namespace rfb { - namespace win32 { - class SFileTransferManagerWin32 : public rfb::SFileTransferManager - { - public: - SFileTransferManagerWin32(); - virtual ~SFileTransferManagerWin32(); - - void processDownloadMsg(MSG msg); - - virtual SFileTransfer *createObject(network::Socket *sock); - }; - }; -} - -#endif // __RFB_WIN32_SFILETRANSFERMANAGERWIN32_H__ diff --git a/win/rfb_win32/SFileTransferWin32.cxx b/win/rfb_win32/SFileTransferWin32.cxx deleted file mode 100644 index ad77bd09..00000000 --- a/win/rfb_win32/SFileTransferWin32.cxx +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (C) 2006 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky. - * - * 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. - * - * - * - */ - -// -=- SFileTransferWin32.cxx - -#include <rfb/msgTypes.h> -#include <rfb_win32/FolderManager.h> -#include <rfb_win32/SFileTransferWin32.h> - -using namespace rfb; -using namespace rfb::win32; - -SFileTransferWin32::SFileTransferWin32(network::Socket *sock) : SFileTransfer(sock) -{ -} - -SFileTransferWin32::~SFileTransferWin32() -{ -} - -bool -SFileTransferWin32::initDownloadCallback() -{ - PostThreadMessage(GetCurrentThreadId(), VNCM_FT_DOWNLOAD, (WPARAM) 0, (LPARAM) this); - return true; -} - -bool -SFileTransferWin32::processDownloadCallback() -{ - return sendFileDownloadPortion(); -} - -bool -SFileTransferWin32::convertPathFromNet(char *pszPath) -{ - int len = strlen(pszPath); - if (pszPath[0] == '/') { - if (len == 1) { - pszPath[0] = '\0'; - return true; - } - } else { - return false; - } - - for(int i = 0; i < (len - 1); i++) { - if(pszPath[i+1] == '/') pszPath[i+1] = '\\'; - pszPath[i] = pszPath[i+1]; - } - - pszPath[len-1] = '\0'; - return true; -} - -bool -SFileTransferWin32::makeFileList(char *pszPath, FileInfo *pFI, bool bDirOnly) -{ - FolderManager fm; - if (fm.getDirInfo(pszPath, pFI, bDirOnly)) - return true; - else - return false; -} - -bool -SFileTransferWin32::deleteIt(char *pszPath) -{ - FolderManager fm; - - return fm.deleteIt(pszPath); -} - -bool -SFileTransferWin32::renameIt(char *pszOldPath, char *pszNewPath) -{ - FolderManager fm; - - return fm.renameIt(pszOldPath, pszNewPath); -} - -bool -SFileTransferWin32::createDir(char *pszPath) -{ - FolderManager fm; - - return fm.createDir(pszPath); -} - -bool -SFileTransferWin32::getDirSize(char *pszName, unsigned short *pHighSize16, - unsigned int *pLowSize32) -{ - FolderManager fm; - DWORD64 dw64DirSize = 0; - - if (!fm.getDirSize(pszName, &dw64DirSize)) return false; - - if (dw64DirSize & 0xFFFF000000000000LL) return false; - - *pHighSize16 = (unsigned short)((dw64DirSize >> 32) & 0xFFFF); - *pLowSize32 = (unsigned int)(dw64DirSize & 0xFFFFFFFF); - - return true; -} diff --git a/win/rfb_win32/SFileTransferWin32.h b/win/rfb_win32/SFileTransferWin32.h deleted file mode 100644 index 49cdf5f4..00000000 --- a/win/rfb_win32/SFileTransferWin32.h +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2006 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky. - * - * 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. - * - * - * - */ - -// -=- SFileTransferWin32.h - -#ifndef __RFB_SFILETRANSFERWIN32_H__ -#define __RFB_SFILETRANSFERWIN32_H__ - -#include <windows.h> - -#include <rfb/SFileTransfer.h> - -const UINT VNCM_FT_DOWNLOAD = WM_USER + 2; - -namespace rfb { - namespace win32 { - class SFileTransferWin32 : public rfb::SFileTransfer - { - public: - SFileTransferWin32(network::Socket *sock); - virtual ~SFileTransferWin32(); - - bool processDownloadCallback(); - virtual bool initDownloadCallback(); - - virtual bool convertPathFromNet(char *pszPath); - virtual bool makeFileList(char *pszPath, FileInfo *pFI, bool bDirOnly); - - virtual bool deleteIt(char *pszPath); - virtual bool renameIt(char *pszOldPath, char *pszNewPath); - virtual bool createDir(char *pszPath); - - virtual bool getDirSize(char *pszName, unsigned short *pHighSize16, unsigned int *pLowSize32); - - }; - }; -} - -#endif // __RFB_SFILETRANSFERWIN32_H__ diff --git a/win/rfb_win32/rfb_win32.dsp b/win/rfb_win32/rfb_win32.dsp index acfb5aaf..e4843435 100644 --- a/win/rfb_win32/rfb_win32.dsp +++ b/win/rfb_win32/rfb_win32.dsp @@ -158,10 +158,6 @@ SOURCE=.\EventManager.cxx # End Source File
# Begin Source File
-SOURCE=.\FolderManager.cxx
-# End Source File
-# Begin Source File
-
SOURCE=.\LaunchProcess.cxx
# End Source File
# Begin Source File
@@ -222,14 +218,6 @@ SOURCE=.\Service.cxx # End Source File
# Begin Source File
-SOURCE=.\SFileTransferManagerWin32.cxx
-# End Source File
-# Begin Source File
-
-SOURCE=.\SFileTransferWin32.cxx
-# End Source File
-# Begin Source File
-
SOURCE=.\SInput.cxx
# End Source File
# Begin Source File
@@ -346,10 +334,6 @@ SOURCE=.\EventManager.h # End Source File
# Begin Source File
-SOURCE=.\FolderManager.h
-# End Source File
-# Begin Source File
-
SOURCE=.\Handle.h
# End Source File
# Begin Source File
@@ -446,14 +430,6 @@ SOURCE=.\Service.h # End Source File
# Begin Source File
-SOURCE=.\SFileTransferManagerWin32.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\SFileTransferWin32.h
-# End Source File
-# Begin Source File
-
SOURCE=.\SInput.h
# End Source File
# Begin Source File
diff --git a/win/vncviewer/CConn.cxx b/win/vncviewer/CConn.cxx index 874db094..41b3aa3d 100644 --- a/win/vncviewer/CConn.cxx +++ b/win/vncviewer/CConn.cxx @@ -51,7 +51,6 @@ const int IDM_NEWCONN = ID_NEW_CONNECTION; const int IDM_REQUEST_REFRESH = ID_REQUEST_REFRESH; const int IDM_CTRL_KEY = ID_CTRL_KEY; const int IDM_ALT_KEY = ID_ALT_KEY; -const int IDM_FILE_TRANSFER = ID_FILE_TRANSFER; const int IDM_CONN_SAVE_AS = ID_CONN_SAVE_AS; const int IDM_ZOOM_IN = ID_ZOOM_IN; const int IDM_ZOOM_OUT = ID_ZOOM_OUT; @@ -108,8 +107,6 @@ bool CConn::initialise(network::Socket* s, bool reverse) { reverseConnection = reverse; initialiseProtocol(); - m_fileTransfer.initialize(&s->inStream(), &s->outStream()); - return true; } @@ -281,9 +278,6 @@ CConn::sysCommand(WPARAM wParam, LPARAM lParam) { case IDM_ABOUT: AboutDialog::instance.showDialog(); return true; - case IDM_FILE_TRANSFER: - m_fileTransfer.show(window->getHandle()); - return true; case IDM_CONN_SAVE_AS: return true; }; @@ -770,6 +764,3 @@ void CConn::getUserPasswd(char** user, char** password) { if (password) options.setPassword(*password); } -bool CConn::processFTMsg(int type) { - return m_fileTransfer.processFTMsg(type); -} diff --git a/win/vncviewer/CConn.h b/win/vncviewer/CConn.h index d294f9e0..5dacb1ee 100644 --- a/win/vncviewer/CConn.h +++ b/win/vncviewer/CConn.h @@ -33,7 +33,6 @@ #include <vncviewer/OptionsDialog.h> #include <vncviewer/CConnOptions.h> #include <vncviewer/DesktopWindow.h> -#include <vncviewer/FileTransfer.h> #include <list> @@ -81,8 +80,6 @@ namespace rfb { // Global user-config registry key static RegKey userConfigKey; - bool processFTMsg(int type); - protected: // InputHandler interface (via DesktopWindow::Callback) void keyEvent(rdr::U32 key, bool down); @@ -152,8 +149,6 @@ namespace rfb { std::list<Rect> debugRects; CharArray closeReason_; bool isClosed_; - - FileTransfer m_fileTransfer; }; }; diff --git a/win/vncviewer/FTBrowseDlg.cxx b/win/vncviewer/FTBrowseDlg.cxx deleted file mode 100644 index 761e03b2..00000000 --- a/win/vncviewer/FTBrowseDlg.cxx +++ /dev/null @@ -1,196 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky - * - * 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. - * - * - * - */ - -// -=- FTBrpwseDlg.cxx - -#include <vncviewer/FTBrowseDlg.h> - -using namespace rfb; -using namespace rfb::win32; - -FTBrowseDlg::FTBrowseDlg(FTDialog *pFTDlg) -{ - m_pFTDlg = pFTDlg; - m_hwndDlg = NULL; - m_hwndTree = NULL; - m_hParentItem = NULL; -} - -FTBrowseDlg::~FTBrowseDlg() -{ - destroy(); -} - -bool -FTBrowseDlg::create() -{ - m_hwndDlg = CreateDialogParam(GetModuleHandle(0), MAKEINTRESOURCE(IDD_FTBROWSE), - m_pFTDlg->getWndHandle(), (DLGPROC) FTBrowseDlgProc, - (LONG) this); - - if (m_hwndDlg == NULL) return false; - - m_hwndTree = GetDlgItem(m_hwndDlg, IDC_FTBROWSETREE); - - ShowWindow(m_hwndDlg, SW_SHOW); - UpdateWindow(m_hwndDlg); - - return true; -} - -void -FTBrowseDlg::destroy() -{ - EndDialog(m_hwndDlg, 0); -} - -void -FTBrowseDlg::addItems(FileInfo *pFI) -{ - TVITEM tvi; - TVINSERTSTRUCT tvins; - - if (pFI->getNumEntries() <= 0) return; - - for (unsigned int i = 0; i < pFI->getNumEntries(); i++) - { - tvi.mask = TVIF_TEXT; - tvi.pszText = pFI->getNameAt(i);; - tvins.hParent = m_hParentItem; - tvins.item = tvi; - tvins.hParent = TreeView_InsertItem(m_hwndTree, &tvins); - TreeView_InsertItem(m_hwndTree, &tvins); - } -} - -char * -FTBrowseDlg::getTVPath(HTREEITEM hTItem) -{ - char path[FT_FILENAME_SIZE]; - char szText[FT_FILENAME_SIZE]; - - TVITEM tvi; - path[0] = '\0'; - - do { - tvi.mask = TVIF_TEXT | TVIF_HANDLE; - tvi.hItem = hTItem; - tvi.pszText = szText; - tvi.cchTextMax = FT_FILENAME_SIZE; - TreeView_GetItem(m_hwndTree, &tvi); - sprintf(path, "%s\\%s", path, tvi.pszText); - hTItem = TreeView_GetParent(m_hwndTree, hTItem); - } while(hTItem != NULL); - - return pathInvert(path); -} - -char * -FTBrowseDlg::pathInvert(char *pPath) -{ - int len = strlen(pPath); - m_szPath[0] = '\0'; - char *pos = NULL; - - while ((pos = strrchr(pPath, '\\')) != NULL) { - if (strlen(m_szPath) == 0) { - strcpy(m_szPath, (pos + 1)); - } else { - sprintf(m_szPath, "%s\\%s", m_szPath, (pos + 1)); - } - *pos = '\0'; - } - - m_szPath[len] = '\0'; - return m_szPath; -} - -char * -FTBrowseDlg::getPath() -{ - GetDlgItemText(m_hwndDlg, IDC_FTBROWSEPATH, m_szPath, FT_FILENAME_SIZE); - return m_szPath; -} - -void -FTBrowseDlg::deleteChildItems() -{ - while (TreeView_GetChild(m_hwndTree, m_hParentItem) != NULL) { - TreeView_DeleteItem(m_hwndTree, TreeView_GetChild(m_hwndTree, m_hParentItem)); - } -} - -BOOL CALLBACK -FTBrowseDlg::FTBrowseDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - FTBrowseDlg *_this = (FTBrowseDlg *) GetWindowLong(hwnd, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - { - SetWindowLong(hwnd, GWL_USERDATA, lParam); - return FALSE; - } - break; - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDOK: - _this->m_pFTDlg->onEndBrowseDlg(true); - return FALSE; - case IDCANCEL: - _this->m_pFTDlg->onEndBrowseDlg(false); - return FALSE; - } - } - break; - case WM_NOTIFY: - switch (LOWORD(wParam)) - { - case IDC_FTBROWSETREE: - switch (((LPNMHDR) lParam)->code) - { - case TVN_SELCHANGED: - SetDlgItemText(hwnd, IDC_FTBROWSEPATH, _this->getTVPath(((NMTREEVIEW *) lParam)->itemNew.hItem)); - return FALSE; -// case TVN_ITEMEXPANDING: - case TVN_ITEMEXPANDED: - { - NMTREEVIEW *nmCode = (NMTREEVIEW *) lParam; - if (nmCode->action == 2) { - _this->m_hParentItem = nmCode->itemNew.hItem; - _this->deleteChildItems(); - _this->m_pFTDlg->getBrowseItems(_this->getTVPath(_this->m_hParentItem)); - } - } - return FALSE; - } - break; - case WM_CLOSE: - _this->m_pFTDlg->onEndBrowseDlg(false); - return FALSE; - } - } - return 0; -} diff --git a/win/vncviewer/FTBrowseDlg.h b/win/vncviewer/FTBrowseDlg.h deleted file mode 100644 index b50b1a71..00000000 --- a/win/vncviewer/FTBrowseDlg.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky - * - * 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. - * - * - * - */ - -// -=- FTBrowseDlg.h - -#ifndef __RFB_WIN32_FTBROWSEDLG_H__ -#define __RFB_WIN32_FTBROWSEDLG_H__ - -#include <windows.h> -#include <commctrl.h> - -#include <rfb/FileInfo.h> -#include <vncviewer/FTDialog.h> -#include <vncviewer/resource.h> - -namespace rfb { - namespace win32 { - class FTDialog; - - class FTBrowseDlg - { - public: - FTBrowseDlg(FTDialog *pFTDlg); - ~FTBrowseDlg(); - - static BOOL CALLBACK FTBrowseDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - bool create(); - void destroy(); - - void addItems(FileInfo *pFI); - char *getPath(); - - void deleteChildItems(); - - private: - HWND m_hwndDlg; - HWND m_hwndTree; - FTDialog *m_pFTDlg; - HTREEITEM m_hParentItem; - - char m_szPath[FT_FILENAME_SIZE]; - - char *pathInvert(char *pPath); - char *getTVPath(HTREEITEM hTItem); - }; - } -} - -#endif // __RFB_WIN32_FTBROWSEDLG_H__ diff --git a/win/vncviewer/FTDialog.cxx b/win/vncviewer/FTDialog.cxx deleted file mode 100644 index bf819a32..00000000 --- a/win/vncviewer/FTDialog.cxx +++ /dev/null @@ -1,1162 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky - * - * 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. - * - * - * - */ - -// -=- FTDialog.cxx - -#include <vncviewer/FTDialog.h> - -using namespace rfb; -using namespace rfb::win32; - -const char FTDialog::szCheckDeleteQueueText[] = "TigerVNC.Viewer.CheckDeleteQueue.Msg"; -const char FTDialog::szCheckTransferQueueText[] = "TigerVNC.Viewer.CheckTransferQueue.Msg"; -const char FTDialog::szUploadFilePortionText[] = "TigerVNC.Viewer.UploadFilePortion.Msg"; - -FTDialog::FTDialog(HINSTANCE hInst, FileTransfer *pFT) -{ - m_pFileTransfer = pFT; - m_hInstance = hInst; - - m_bDlgShown = false; - m_bLocalBrowsing = true; - m_bCloseDlgAfterCancel = false; - - m_pLocalLV = NULL; - m_pRemoteLV = NULL; - m_pProgress = NULL; - m_pCancelingDlg = NULL; - m_pCreateFolderDlg = NULL; - m_pRenameDlg = NULL; - m_pBrowseDlg = NULL; - - m_hwndFTDialog = NULL; - m_hwndLocalPath = NULL; - m_hwndRemotePath = NULL; - - m_FTMenuSource = 0; - m_dwNumStatusStrings = 0; - - m_szLocalPath[0] = '\0'; - m_szRemotePath[0] = '\0'; - m_szLocalPathTmp[0] = '\0'; - m_szRemotePathTmp[0] = '\0'; - m_szCreateFolderName[0] = '\0'; -} - -FTDialog::~FTDialog() -{ - destroyFTDialog(); -} - -bool -FTDialog::createFTDialog(HWND hwndParent) -{ - if (m_hwndFTDialog != NULL) { - ShowWindow(m_hwndFTDialog, SW_SHOW); - m_bDlgShown = true; - showLocalLVItems(); - showRemoteLVItems(); - return true; - } - - if (!initFTWndMsgs()) return false; - - m_hwndFTDialog = CreateDialogParam(m_hInstance, - MAKEINTRESOURCE(IDD_FILETRANSFER_DLG), - hwndParent, - (DLGPROC) FTDialogProc, - (LONG) this); - - if (m_hwndFTDialog == NULL) return false; - - HWND hwndLocalList = GetDlgItem(m_hwndFTDialog, IDC_FTLOCALLIST); - HWND hwndRemoteList = GetDlgItem(m_hwndFTDialog, IDC_FTREMOTELIST); - - if ((hwndLocalList == NULL) || (hwndRemoteList == NULL)) { - destroyFTDialog(); - return false; - } - - m_pLocalLV = new FTListView(hwndLocalList); - m_pRemoteLV = new FTListView(hwndRemoteList); - - m_pProgress = new FTProgress(m_hwndFTDialog); - - if ((m_pLocalLV == NULL) || (m_pRemoteLV == NULL) || (m_pProgress == NULL)) { - destroyFTDialog(); - return false; - } - - initFTDialog(); - - ShowWindow(m_hwndFTDialog, SW_SHOW); - UpdateWindow(m_hwndFTDialog); - m_bDlgShown = true; - return true; -} - -bool -FTDialog::initFTDialog() -{ - m_pLocalLV->initialize(m_hInstance); - m_pRemoteLV->initialize(m_hInstance); - - m_hwndLocalPath = GetDlgItem(m_hwndFTDialog, IDC_FTLOCALPATH); - m_hwndRemotePath = GetDlgItem(m_hwndFTDialog, IDC_FTREMOTEPATH); - - setIcon(IDC_FTLOCALUP, IDI_FTUP); - setIcon(IDC_FTREMOTEUP, IDI_FTUP); - setIcon(IDC_FTLOCALRELOAD, IDI_FTRELOAD); - setIcon(IDC_FTREMOTERELOAD, IDI_FTRELOAD); - - showLocalLVItems(); - showRemoteLVItems(); - - return true; -} - -bool -FTDialog::initFTWndMsgs() -{ - m_msgCheckDeleteQueue = RegisterWindowMessage(szCheckDeleteQueueText); - m_msgCheckTransferQueue = RegisterWindowMessage(szCheckTransferQueueText); - m_msgUploadFilePortion = RegisterWindowMessage(szUploadFilePortionText); - - if ((m_msgCheckDeleteQueue) && - (m_msgCheckTransferQueue) && - (m_msgUploadFilePortion)) return true; - - return false; -} - -bool -FTDialog::closeFTDialog() -{ - ShowWindow(m_hwndFTDialog, SW_HIDE); - m_bDlgShown = false; - return true; -} - -void -FTDialog::destroyFTDialog() -{ - if (m_pLocalLV != NULL) { - delete m_pLocalLV; - m_pLocalLV = NULL; - } - - if (m_pRemoteLV != NULL) { - delete m_pRemoteLV; - m_pRemoteLV = NULL; - } - - if (m_pProgress != NULL) { - delete m_pProgress; - m_pProgress = NULL; - } - - if(m_pCancelingDlg != NULL) { - delete m_pCancelingDlg; - m_pCancelingDlg = NULL; - } - - if (m_pCreateFolderDlg != NULL) { - delete m_pCreateFolderDlg; - m_pCreateFolderDlg = NULL; - } - - if(m_pRenameDlg != NULL) { - delete m_pRenameDlg; - m_pRenameDlg = NULL; - } - - if (DestroyWindow(m_hwndFTDialog)) m_hwndFTDialog = NULL; -} - -BOOL CALLBACK -FTDialog::FTDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - FTDialog *_this = (FTDialog *) GetWindowLong(hwnd, GWL_USERDATA); - - switch (uMsg) - { - case WM_INITDIALOG: - _this = (FTDialog*)lParam; - SetWindowLong(hwnd, GWL_USERDATA, (LONG) lParam); - SetForegroundWindow(hwnd); - return TRUE; - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_FTLOCALPATH: - switch (HIWORD (wParam)) - { - case CBN_SETFOCUS: - _this->setButtonsState(); - return FALSE; - } - break; - case IDC_FTREMOTEPATH: - switch (HIWORD (wParam)) - { - case CBN_SETFOCUS: - _this->setButtonsState(); - return FALSE; - } - break; - case IDC_FTCLOSE: - _this->onClose(); - return FALSE; - case IDC_FTLOCALBROWSE: - _this->onLocalBrowse(); - return FALSE; - case IDC_FTREMOTEBROWSE: - _this->onRemoteBrowse(); - return FALSE; - case IDC_FTLOCALUP: - _this->setButtonsState(); - _this->onLocalOneUpFolder(); - return FALSE; - case IDC_FTREMOTEUP: - _this->setButtonsState(); - _this->onRemoteOneUpFolder(); - return FALSE; - case IDC_FTLOCALRELOAD: - _this->setButtonsState(); - _this->onLocalReload(); - return FALSE; - case IDC_FTREMOTERELOAD: - _this->setButtonsState(); - _this->onRemoteReload(); - return FALSE; - case IDC_FTUPLOAD: - _this->onUpload(); - return FALSE; - case IDC_FTDOWNLOAD: - _this->onDownload(); - return FALSE; - case IDC_FTCANCEL: - _this->onFTCancel(); - return FALSE; - case IDM_FTCOPY: - case IDM_FTRENAME: - case IDM_FTDELETE: - case IDM_FTCANCEL: - case IDM_FTCREATEFOLDER: - _this->onFTMenuCommand(LOWORD(wParam)); - return FALSE; - } - } - break; - - case WM_NOTIFY: - switch (LOWORD(wParam)) - { - case IDC_FTLOCALLIST: - switch (((LPNMHDR) lParam)->code) - { - case NM_CLICK: - case NM_SETFOCUS: - case LVN_ITEMCHANGED: - _this->setButtonsState(); - return FALSE; - case LVN_GETDISPINFO: - _this->m_pLocalLV->onGetDispInfo((NMLVDISPINFO *) lParam); - return FALSE; - case LVN_ITEMACTIVATE: - _this->onLocalItemActivate((LPNMITEMACTIVATE) lParam); - return FALSE; - case NM_RCLICK: - _this->onLocalRButton(); - return FALSE; - } - break; - case IDC_FTREMOTELIST: - switch (((LPNMHDR) lParam)->code) - { - case NM_CLICK: - case NM_SETFOCUS: - case LVN_ITEMCHANGED: - _this->setButtonsState(); - case LVN_GETDISPINFO: - _this->m_pRemoteLV->onGetDispInfo((NMLVDISPINFO *) lParam); - return FALSE; - case LVN_ITEMACTIVATE: - _this->onRemoteItemActivate((LPNMITEMACTIVATE) lParam); - return FALSE; - case NM_RCLICK: - _this->onRemoteRButton(); - return FALSE; - } - break; - } - break; - case WM_CLOSE: - _this->onClose(); - return FALSE; - } - - if (_this != NULL) { - if (uMsg == _this->m_msgCheckTransferQueue) - _this->m_pFileTransfer->checkTransferQueue(); - - if (uMsg == _this->m_msgUploadFilePortion) - _this->m_pFileTransfer->uploadFilePortion(); - - if (uMsg == _this->m_msgCheckDeleteQueue) - _this->m_pFileTransfer->checkDeleteQueue(); - } - - return FALSE; -} - -void -FTDialog::onClose() -{ - if (m_pFileTransfer->isTransferEnable()) { - m_bCloseDlgAfterCancel = true; - onFTCancel(); - } else { - closeFTDialog(); - } -} - -void -FTDialog::onLocalItemActivate(LPNMITEMACTIVATE lpnmia) -{ - if (strlen(m_szLocalPath) == 0) { - strcpy(m_szLocalPathTmp, m_pLocalLV->getActivateItemName(lpnmia)); - } else { - sprintf(m_szLocalPathTmp, "%s\\%s", m_szLocalPath, m_pLocalLV->getActivateItemName(lpnmia)); - } - showLocalLVItems(); -} - -void -FTDialog::onRemoteItemActivate(LPNMITEMACTIVATE lpnmia) -{ - if (strlen(m_szRemotePath) == 0) { - strcpy(m_szRemotePathTmp, m_pRemoteLV->getActivateItemName(lpnmia)); - } else { - sprintf(m_szRemotePathTmp, "%s\\%s", m_szRemotePath, m_pRemoteLV->getActivateItemName(lpnmia)); - } - showRemoteLVItems(); -} - -void -FTDialog::onEndBrowseDlg(bool bResult) -{ - if (m_pBrowseDlg == NULL) return; - - if (bResult) { - if (m_bLocalBrowsing) { - strcpy(m_szLocalPathTmp, m_pBrowseDlg->getPath()); - showLocalLVItems(); - } else { - strcpy(m_szRemotePathTmp, m_pBrowseDlg->getPath()); - showRemoteLVItems(); - } - } - delete m_pBrowseDlg; - m_pBrowseDlg = NULL; -} - -void -FTDialog::onLocalBrowse() -{ - if (m_pBrowseDlg != NULL) return; - - m_bLocalBrowsing = true; - - m_pBrowseDlg = new FTBrowseDlg(this); - m_pBrowseDlg->create(); - - getBrowseItems(""); -} - -void -FTDialog::onRemoteBrowse() -{ - if (m_pBrowseDlg != NULL) return; - - m_bLocalBrowsing = false; - - m_pBrowseDlg = new FTBrowseDlg(this); - if (m_pBrowseDlg->create()) { - m_pFileTransfer->requestFileList("", FT_FLR_DEST_BROWSE, true); - } else { - delete m_pBrowseDlg; - m_pBrowseDlg = NULL; - } -} - -void -FTDialog::onLocalReload() -{ - strcpy(m_szLocalPathTmp, m_szLocalPath); - showLocalLVItems(); -} - -void -FTDialog::onRemoteReload() -{ - strcpy(m_szRemotePathTmp, m_szRemotePath); - showRemoteLVItems(); -} - -void -FTDialog::showLocalLVItems() -{ - FolderManager fm; - FileInfo fileInfo; - if (fm.getDirInfo(m_szLocalPathTmp, &fileInfo, 0)) { - fileInfo.sort(); - m_pLocalLV->deleteAllItems(); - m_pLocalLV->addItems(&fileInfo); - strcpy(m_szLocalPath, m_szLocalPathTmp); - SetWindowText(m_hwndLocalPath, m_szLocalPath); - } -} - -void -FTDialog::showRemoteLVItems() -{ - m_pFileTransfer->requestFileList(m_szRemotePathTmp, FT_FLR_DEST_MAIN, false); -} - -void -FTDialog::addRemoteLVItems(FileInfo *pFI) -{ - pFI->sort(); - m_pRemoteLV->deleteAllItems(); - m_pRemoteLV->addItems(pFI); - strcpy(m_szRemotePath, m_szRemotePathTmp); - SetWindowText(m_hwndRemotePath, m_szRemotePath); - UpdateWindow(m_hwndFTDialog); -} - -void -FTDialog::onLocalOneUpFolder() -{ - strcpy(m_szLocalPathTmp, m_szLocalPath); - makeOneUpFolder(m_szLocalPathTmp); - showLocalLVItems(); -} - -void -FTDialog::onRemoteOneUpFolder() -{ - strcpy(m_szRemotePathTmp, m_szRemotePath); - makeOneUpFolder(m_szRemotePathTmp); - showRemoteLVItems(); -} - -void -FTDialog::reqFolderUnavailable() -{ - strcpy(m_szRemotePathTmp, m_szRemotePath); - SetWindowText(m_hwndRemotePath, m_szRemotePath); - UpdateWindow(m_hwndFTDialog); -} - -int -FTDialog::makeOneUpFolder(char *pPath) -{ - if (strcmp(pPath, "") == 0) return strlen(pPath); - for (int i=(strlen(pPath)-2); i>=0; i--) { - if (pPath[i] == '\\') { - pPath[i] = '\0'; - break; - } - if (i == 0) pPath[0] = '\0'; - } - return strlen(pPath); -} - -void -FTDialog::onUpload() -{ - FileInfo fi; - char prefix[FT_FILENAME_SIZE]; - prefix[0] = '\0'; - - if (m_pFileTransfer->isTransferEnable()) - strcpy(prefix, "File Transfer is active.\nDo you want to add selected file(s)/folder(s) to transfer queue?\n\n"); - - int numSel = m_pLocalLV->getSelectedItems(&fi); - if (numSel > 0) { - char *pBuf = new char [(numSel + 4) * (MAX_PATH + 3) + strlen(prefix) + 1]; - sprintf(pBuf, "%sFrom: Local Computer %s\\\n\n", prefix, m_szLocalPath); - - for (unsigned int i = 0; i < fi.getNumEntries(); i++) - sprintf(pBuf, "%s%s, ", pBuf, fi.getNameAt(i)); - - sprintf(pBuf, "%s\n\nTo: Remote Computer %s\\", pBuf, m_szRemotePath); - - if (strlen(pBuf) > 2048) - sprintf(pBuf, "%sFrom: Local Computer %s\\\n\nTo: Remote Computer %s\\\n\nTotal %d file(s)/folder(s)", - prefix, m_szLocalPath, m_szRemotePath, numSel); - - if (MessageBox(m_hwndFTDialog, pBuf, "Copy Selected Files and Folders", MB_OKCANCEL) == IDOK) - m_pFileTransfer->addTransferQueue(m_szLocalPath, m_szRemotePath, &fi, FT_ATTR_COPY_UPLOAD); - - setButtonsState(); - - delete [] pBuf; - return; - } - - setButtonsState(); - setStatusText("File Transfer Impossible. No file(s) selected for transfer"); -} - -void -FTDialog::onDownload() -{ - FileInfo fi; - char prefix[FT_FILENAME_SIZE]; - prefix[0] = '\0'; - - if (m_pFileTransfer->isTransferEnable()) - strcpy(prefix, "File Transfer is active.\nDo you want to add selected file(s)/folder(s) to transfer queue?\n\n"); - - int numSel = m_pRemoteLV->getSelectedItems(&fi); - if (numSel > 0) { - char *pBuf = new char [(numSel + 4) * (MAX_PATH + 3) + strlen(prefix) + 1]; - sprintf(pBuf, "%sFrom: Remote Computer %s\\\n\n", prefix, m_szRemotePath); - - for (unsigned int i = 0; i < fi.getNumEntries(); i++) - sprintf(pBuf, "%s%s, ", pBuf, fi.getNameAt(i)); - - sprintf(pBuf, "%s\n\nTo: Local Computer %s\\", pBuf, m_szLocalPath); - - if (strlen(pBuf) > 2048) - sprintf(pBuf, "%sFrom: Remote Computer %s\\\n\nTo: Local Computer %s\\\n\nTotal %d file(s)/folder(s)", - prefix, m_szRemotePath, m_szLocalPath, numSel); - - if (MessageBox(m_hwndFTDialog, pBuf, "Copy Selected Files and Folders", MB_OKCANCEL) == IDOK) - m_pFileTransfer->addTransferQueue(m_szLocalPath, m_szRemotePath, &fi, FT_ATTR_COPY_DOWNLOAD); - - setButtonsState(); - - delete [] pBuf; - return; - } - - setButtonsState(); - setStatusText("File Transfer Impossible. No file(s) selected for transfer"); -} - -void -FTDialog::onLocalRename() -{ - if (m_pRenameDlg != NULL) return; - - FileInfo fi; - if (m_pLocalLV->getSelectedItems(&fi) == 1) { - unsigned int flags = fi.getFlagsAt(0); - m_pRenameDlg = new FTDialog::RenameDlg(this); - if (m_pRenameDlg != NULL) { - if (flags & FT_ATTR_DIR) { - m_pRenameDlg->create(fi.getNameAt(0), true); - } else { - m_pRenameDlg->create(fi.getNameAt(0), false); - } - if (strlen(m_pRenameDlg->getFolderName()) > 0) { - FolderManager fm; - fm.renameIt(m_szLocalPath, fi.getNameAt(0), m_pRenameDlg->getFolderName()); - showLocalLVItems(); - } - delete m_pRenameDlg; - m_pRenameDlg = NULL; - } - } - setButtonsState(); -} - -void -FTDialog::onRemoteRename() -{ - if (m_pRenameDlg != NULL) return; - - FileInfo fi; - if (m_pRemoteLV->getSelectedItems(&fi) == 1) { - unsigned int flags = fi.getFlagsAt(0); - m_pRenameDlg = new FTDialog::RenameDlg(this); - if (m_pRenameDlg != NULL) { - if (flags & FT_ATTR_DIR) { - m_pRenameDlg->create(fi.getNameAt(0), true); - } else { - m_pRenameDlg->create(fi.getNameAt(0), false); - } - if (strlen(m_pRenameDlg->getFolderName()) > 0) { - m_pFileTransfer->renameRemote(m_szRemotePath, fi.getNameAt(0), m_pRenameDlg->getFolderName()); - } - delete m_pRenameDlg; - m_pRenameDlg = NULL; - } - } - setButtonsState(); -} - -void -FTDialog::onLocalDelete() -{ - FileInfo fi; - if (m_pLocalLV->getSelectedItems(&fi) > 0) { - m_pFileTransfer->addDeleteQueue(m_szLocalPath, &fi, FT_ATTR_DELETE_LOCAL); - } - setButtonsState(); -} - -void -FTDialog::onRemoteDelete() -{ - FileInfo fi; - if (m_pRemoteLV->getSelectedItems(&fi) > 0) { - m_pFileTransfer->addDeleteQueue(m_szRemotePath, &fi, FT_ATTR_DELETE_REMOTE); - } - setButtonsState(); -} - -bool -FTDialog::getCreateFolderName() -{ - if (m_pCreateFolderDlg != NULL) return false; - - bool bResult = false; - - m_pCreateFolderDlg = new FTDialog::CreateFolderDlg(this); - m_pCreateFolderDlg->create(); - if (strlen(m_pCreateFolderDlg->getFolderName()) != 0) { - strcpy(m_szCreateFolderName, m_pCreateFolderDlg->getFolderName()); - bResult = true; - } else { - m_szCreateFolderName[0] = '\0'; - bResult = false; - } - delete m_pCreateFolderDlg; - m_pCreateFolderDlg = NULL; - - return bResult; -} - -void -FTDialog::onLocalCreateFolder() -{ - if (getCreateFolderName()) { - char path[FT_FILENAME_SIZE]; - sprintf(path, "%s\\%s", m_szLocalPath, m_szCreateFolderName); - setStatusText("Creating Local Folder: %s", path); - FolderManager fm; - if (fm.createDir(path)) showLocalLVItems(); - } -} - -void -FTDialog::onRemoteCreateFolder() -{ - if (getCreateFolderName()) { - m_pFileTransfer->createRemoteFolder(m_szRemotePath, m_szCreateFolderName); - } -} - -void -FTDialog::onFTCancel() -{ - if (m_pCancelingDlg != NULL) return; - - m_pCancelingDlg = new CancelingDlg(this); - - m_pCancelingDlg->create(); -} - -void -FTDialog::cancelTransfer(bool bResult) -{ - if (m_pCancelingDlg != NULL) { - delete m_pCancelingDlg; - m_pCancelingDlg = NULL; - } - - setButtonsState(); - - if ((m_bCloseDlgAfterCancel) && (bResult)) { - m_bCloseDlgAfterCancel = false; - closeFTDialog(); - } - - m_pFileTransfer->m_bCancel = bResult; -} - -void -FTDialog::afterCancelTransfer() -{ - if (m_pCancelingDlg != NULL) { - delete m_pCancelingDlg; - m_pCancelingDlg = NULL; - } -} - -void -FTDialog::onFTMenuCommand(int command) -{ - switch (command) - { - case IDM_FTCOPY: - { - switch (m_FTMenuSource) - { - case IDC_FTLOCALLIST: onUpload(); break; - case IDC_FTREMOTELIST: onDownload(); break; - default: break; - } - } - break; - case IDM_FTRENAME: - { - switch (m_FTMenuSource) - { - case IDC_FTLOCALLIST: onLocalRename(); break; - case IDC_FTREMOTELIST: onRemoteRename(); break; - default: break; - } - } - break; - case IDM_FTDELETE: - { - switch (m_FTMenuSource) - { - case IDC_FTLOCALLIST: onLocalDelete(); break; - case IDC_FTREMOTELIST: onRemoteDelete(); break; - default: break; - } - } - break; - case IDM_FTCANCEL: onFTCancel(); break; - case IDM_FTCREATEFOLDER: - { - switch (m_FTMenuSource) - { - case IDC_FTLOCALLIST: onLocalCreateFolder(); break; - case IDC_FTREMOTELIST: onRemoteCreateFolder(); break; - default: break; - } - } - break; - default: - break; - } -} - -void -FTDialog::onLocalRButton() -{ - refreshBtnState(); - m_FTMenuSource = IDC_FTLOCALLIST; - showFTMenu(m_BtnState.uploadBtn, m_BtnState.createLocalFldBtn, - m_BtnState.renameLocalBtn, m_BtnState.deleteLocalBtn, - m_BtnState.cancelBtn); -} - -void -FTDialog::onRemoteRButton() -{ - refreshBtnState(); - m_FTMenuSource = IDC_FTREMOTELIST; - showFTMenu(m_BtnState.downloadBtn, m_BtnState.createRemoteFldBtn, - m_BtnState.renameRemoteBtn, m_BtnState.deleteRemoteBtn, - m_BtnState.cancelBtn); -} - -void -FTDialog::showFTMenu(bool copyBtnState, bool createFldBtnState, bool renameBtnState, - bool deleteBtnState, bool cancelBtnState) -{ - HMENU hMenu = LoadMenu(m_hInstance, MAKEINTRESOURCE(IDR_FTMENU)); - HMENU hFTMenu = GetSubMenu(hMenu, 0); - - SetMenuDefaultItem(hFTMenu, IDM_FTCOPY, FALSE); - - SetForegroundWindow(m_hwndFTDialog); - - if (copyBtnState) { - EnableMenuItem(hMenu, IDM_FTCOPY, MF_ENABLED); - } else { - EnableMenuItem(hMenu, IDM_FTCOPY, MF_DISABLED | MF_GRAYED); - } - if (createFldBtnState) { - EnableMenuItem(hMenu, IDM_FTCREATEFOLDER, MF_ENABLED); - } else { - EnableMenuItem(hMenu, IDM_FTCREATEFOLDER, MF_DISABLED | MF_GRAYED); - } - if (renameBtnState) { - EnableMenuItem(hMenu, IDM_FTRENAME, MF_ENABLED); - } else { - EnableMenuItem(hMenu, IDM_FTRENAME, MF_DISABLED | MF_GRAYED); - } - if (deleteBtnState) { - EnableMenuItem(hMenu, IDM_FTDELETE, MF_ENABLED); - } else { - EnableMenuItem(hMenu, IDM_FTDELETE, MF_DISABLED | MF_GRAYED); - } - if (cancelBtnState) { - EnableMenuItem(hMenu, IDM_FTCANCEL, MF_ENABLED); - } else { - EnableMenuItem(hMenu, IDM_FTCANCEL, MF_DISABLED | MF_GRAYED); - } - DrawMenuBar(m_hwndFTDialog); - - POINT cursorPosition; - GetCursorPos(&cursorPosition); - TrackPopupMenu(hFTMenu, 0, cursorPosition.x, cursorPosition.y, 0, m_hwndFTDialog, 0); - DestroyMenu(hFTMenu); -} - -void -FTDialog::setIcon(int dest, int idIcon) -{ - HANDLE hIcon = LoadImage(m_hInstance, MAKEINTRESOURCE(idIcon), IMAGE_ICON, 16, 16, LR_SHARED); - SendMessage(GetDlgItem(m_hwndFTDialog, dest), BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) hIcon); - DestroyIcon((HICON) hIcon); -} - -void -FTDialog::refreshBtnState() -{ - if (!m_bDlgShown) return; - - int locPathLen = strlen(m_szLocalPath); - int remPathLen = strlen(m_szRemotePath); - - if (GetFocus() == m_pLocalLV->getWndHandle()) { - m_BtnState.downloadBtn = false; - if (strlen(m_szLocalPath) != 0) { - m_BtnState.createLocalFldBtn = true; - int nCount = ListView_GetSelectedCount(m_pLocalLV->getWndHandle()); - if (nCount <= 0) { - m_BtnState.uploadBtn = false; - m_BtnState.deleteLocalBtn = false; - m_BtnState.renameLocalBtn = false; - } else { - m_BtnState.deleteLocalBtn = true; - if (remPathLen == 0) { - m_BtnState.uploadBtn = false; - } else { - m_BtnState.uploadBtn = true; - } - if (nCount == 1) { - m_BtnState.renameLocalBtn = true; - } else { - m_BtnState.renameLocalBtn = false; - } - } - } else { - m_BtnState.uploadBtn = false; - m_BtnState.createLocalFldBtn = false; - m_BtnState.deleteLocalBtn = false; - m_BtnState.renameLocalBtn = false; - m_BtnState.downloadBtn = false; - } - } else { - if (GetFocus() == m_pRemoteLV->getWndHandle()) { - m_BtnState.uploadBtn = false; - if (strlen(m_szRemotePath) != 0) { - m_BtnState.createRemoteFldBtn = true; - int nCount = ListView_GetSelectedCount(m_pRemoteLV->getWndHandle()); - if (nCount <= 0) { - m_BtnState.downloadBtn = false; - m_BtnState.deleteRemoteBtn = false; - m_BtnState.renameRemoteBtn = false; - } else { - m_BtnState.deleteRemoteBtn = true; - if (locPathLen == 0) { - m_BtnState.downloadBtn = false; - } else { - m_BtnState.downloadBtn = true; - } - if (nCount == 1) { - m_BtnState.renameRemoteBtn = true; - } else { - m_BtnState.renameRemoteBtn = false; - } - } - } else { - m_BtnState.downloadBtn = false; - m_BtnState.createRemoteFldBtn = false; - m_BtnState.deleteRemoteBtn = false; - m_BtnState.renameRemoteBtn = false; - m_BtnState.uploadBtn = false; - } - } else { - } - } - if (m_pFileTransfer->isTransferEnable()) - m_BtnState.cancelBtn = true; - else - m_BtnState.cancelBtn = false; -} - -void -FTDialog::setButtonsState() -{ - refreshBtnState(); - - switch (m_BtnState.uploadBtn) - { - case false: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTUPLOAD), FALSE); break; - case true: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTUPLOAD), TRUE); break; - } - - switch (m_BtnState.downloadBtn) - { - case false: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTDOWNLOAD), FALSE); break; - case true: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTDOWNLOAD), TRUE); break; - } - - switch (m_BtnState.cancelBtn) - { - case false: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTCANCEL), FALSE); break; - case true: EnableWindow(GetDlgItem(m_hwndFTDialog, IDC_FTCANCEL), TRUE); break; - } - - UpdateWindow(m_hwndFTDialog); -} - -void -FTDialog::setStatusText(LPCSTR format,...) -{ - char text[1024]; - va_list args; - va_start(args, format); - int nSize = _vsnprintf(text, sizeof(text), format, args); - - HWND hStatusBox = GetDlgItem(m_hwndFTDialog, IDC_FTSTATUS); - - LRESULT lRes = SendMessage(hStatusBox, (UINT) CB_INSERTSTRING, (WPARAM) 0, (LPARAM) text); - if ((lRes != CB_ERR) && (lRes != CB_ERRSPACE)) { - lRes = SendMessage(hStatusBox, (UINT) CB_SETCURSEL, (WPARAM) lRes, (LPARAM) 0); - } - - m_dwNumStatusStrings++; - if (m_dwNumStatusStrings > FT_MAX_STATUS_STRINGS) { - int numItems = SendMessage(hStatusBox, (UINT) CB_GETCOUNT, (WPARAM) 0, (LPARAM) 0); - if (numItems != CB_ERR) { - m_dwNumStatusStrings--; - SendMessage(hStatusBox, (UINT) CB_DELETESTRING, (WPARAM) numItems - 1, (LPARAM) 0); - } - } -} - -void -FTDialog::getBrowseItems(char *pPath) -{ - if (m_bLocalBrowsing) { - FileInfo fi; - FolderManager fm; - fm.getDirInfo(pPath, &fi, 1); - if (m_pBrowseDlg != NULL) m_pBrowseDlg->addItems(&fi); - } else { - m_pFileTransfer->requestFileList(pPath, FT_FLR_DEST_BROWSE, true); - } -} - -void -FTDialog::addBrowseItems(FileInfo *pFI) -{ - if (m_pBrowseDlg == NULL) return; - - m_pBrowseDlg->addItems(pFI); -} - -void -FTDialog::processDlgMsgs() -{ - MSG msg; - while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } -} - -void -FTDialog::postCheckTransferQueueMsg() -{ - PostMessage(m_hwndFTDialog, m_msgCheckTransferQueue, 0, 0); -} - -void -FTDialog::postUploadFilePortionMsg() -{ - PostMessage(m_hwndFTDialog, m_msgUploadFilePortion, 0, 0); -} - -void -FTDialog::postCheckDeleteQueueMsg() -{ - PostMessage(m_hwndFTDialog, m_msgCheckDeleteQueue, 0, 0); -} - -FTDialog::CancelingDlg::CancelingDlg(FTDialog *pFTDlg) -{ - m_pFTDlg = pFTDlg; - m_hwndDlg = NULL; -} - -FTDialog::CancelingDlg::~CancelingDlg() -{ - destroy(); -} - -bool -FTDialog::CancelingDlg::create() -{ - if (m_hwndDlg != NULL) return false; - - m_hwndDlg = CreateDialogParam(GetModuleHandle(0), - MAKEINTRESOURCE(IDD_FTCANCELING), - NULL, - (DLGPROC) cancelingDlgProc, - (LONG) this); - - if (m_hwndDlg == NULL) return false; - - ShowWindow(m_hwndDlg, SW_SHOW); - DrawIcon(GetDC(m_hwndDlg), 15, 22, LoadIcon(NULL, IDI_QUESTION)); - UpdateWindow(m_hwndDlg); - - return true; -} - -bool -FTDialog::CancelingDlg::destroy() -{ - if (m_hwndDlg == NULL) return true; - - if (DestroyWindow(m_hwndDlg)) { - m_hwndDlg = NULL; - return true; - } else { - return false; - } -} - -bool -FTDialog::CancelingDlg::close(bool bResult) -{ - if (m_hwndDlg == NULL) return true; - - destroy(); - - m_pFTDlg->cancelTransfer(bResult); - - return false; -} - -BOOL CALLBACK -FTDialog::CancelingDlg::cancelingDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - FTDialog::CancelingDlg *_this = (FTDialog::CancelingDlg *) GetWindowLong(hwnd, GWL_USERDATA); - switch (uMsg) - { - case WM_INITDIALOG: - SetWindowLong(hwnd, GWL_USERDATA, (LONG) lParam); - SetForegroundWindow(hwnd); - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - _this->close(true); - return TRUE; - case IDCANCEL: - _this->close(false); - return TRUE; - } - break; - case WM_CLOSE: - _this->close(false); - return TRUE; - } - return FALSE; -} - -FTDialog::CreateFolderDlg::CreateFolderDlg(FTDialog *pFTDlg) : Dialog(GetModuleHandle(0)) -{ - m_pFTDlg = pFTDlg; - m_szFolderName[0] = '\0'; -} - -FTDialog::CreateFolderDlg::~CreateFolderDlg() -{ - -} - -bool -FTDialog::CreateFolderDlg::create() -{ - return showDialog(MAKEINTRESOURCE(IDD_FTCREATEFOLDER), m_pFTDlg->getWndHandle()); -} - -bool -FTDialog::CreateFolderDlg::onOk() -{ - strcpy(m_szFolderName, getItemString(IDC_FTFOLDERNAME)); - return true; -} - -FTDialog::RenameDlg::RenameDlg(FTDialog *pFTDlg) : CreateFolderDlg(pFTDlg) -{ - m_bFolder = false; -} - -FTDialog::RenameDlg::~RenameDlg() -{ -} - -bool -FTDialog::RenameDlg::create(char *pFilename, bool bFolder) -{ - m_bFolder = bFolder; - strcpy(m_szFilename, pFilename); - return showDialog(MAKEINTRESOURCE(IDD_FTCREATEFOLDER), m_pFTDlg->getWndHandle()); -} - -void -FTDialog::RenameDlg::initDialog() -{ - char buf[2*FT_FILENAME_SIZE]; - if (m_bFolder) { - SetWindowText(handle, "Rename Folder"); - sprintf(buf, "Rename Folder '%s'", m_szFilename); - } else { - SetWindowText(handle, "Rename File"); - sprintf(buf, "Rename File '%s'", m_szFilename); - } - - setItemString(IDC_FTTEXT, buf); - setItemString(IDC_FTFOLDERNAME, m_szFilename); - SendDlgItemMessage(handle, IDC_FTFOLDERNAME, EM_SETSEL, (WPARAM) 0, (LPARAM) -1); -} diff --git a/win/vncviewer/FTDialog.h b/win/vncviewer/FTDialog.h deleted file mode 100644 index 883ccd91..00000000 --- a/win/vncviewer/FTDialog.h +++ /dev/null @@ -1,243 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky - * - * 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. - * - * - * - */ - -// -=- FTDialog.h - -#ifndef __RFB_WIN32_FTDIALOG_H__ -#define __RFB_WIN32_FTDIALOG_H__ - -#include <windows.h> -#include <commctrl.h> - -#include <rfb/FileInfo.h> -#include <rfb_win32/Dialog.h> -#include <vncviewer/FileTransfer.h> -#include <vncviewer/FTListView.h> -#include <vncviewer/FTProgress.h> -#include <vncviewer/FTBrowseDlg.h> -#include <vncviewer/resource.h> - -namespace rfb { - namespace win32 { - class FileTransfer; - class FTBrowseDlg; - - class FTDialog - { - public: - FTDialog(HINSTANCE hInst, FileTransfer *pFT); - ~FTDialog(); - - bool createFTDialog(HWND hwndParent); - bool closeFTDialog(); - void destroyFTDialog(); - - void processDlgMsgs(); - - void cancelTransfer(bool bResult); - void afterCancelTransfer(); - - static BOOL CALLBACK FTDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - void addRemoteLVItems(FileInfo *pFI); - void reqFolderUnavailable(); - - void onEndBrowseDlg(bool bResult); - void getBrowseItems(char *pPath); - void addBrowseItems(FileInfo *pFI); - - void setStatusText(LPCSTR format,...); - - HWND getWndHandle() { return m_hwndFTDialog; } - - void postCheckDeleteQueueMsg(); - void postCheckTransferQueueMsg(); - void postUploadFilePortionMsg(); - void postDownloadFilePortionMsg(); - - char *getLocalPath() { return m_szLocalPath; } - char *getRemotePath() { return m_szRemotePath; } - - FTProgress *m_pProgress; - FileTransfer *m_pFileTransfer; - - private: - HWND m_hwndFTDialog; - HWND m_hwndLocalPath; - HWND m_hwndRemotePath; - HINSTANCE m_hInstance; - - void showLocalLVItems(); - void showRemoteLVItems(); - - void onClose(); - - void onLocalItemActivate(LPNMITEMACTIVATE lpnmia); - void onRemoteItemActivate(LPNMITEMACTIVATE lpnmia); - - void onLocalBrowse(); - void onRemoteBrowse(); - - void onLocalReload(); - void onRemoteReload(); - - void onLocalRButton(); - void onRemoteRButton(); - - bool getCreateFolderName(); - void onLocalCreateFolder(); - void onRemoteCreateFolder(); - - void showFTMenu(bool copyBtnState, bool createFldBtnState, - bool renameBtnState, bool deleteBtnState, - bool cancelBtnState); - void onFTMenuCommand(int command); - - void onUpload(); - void onDownload(); - - void onLocalRename(); - void onRemoteRename(); - - void onLocalDelete(); - void onRemoteDelete(); - - void onFTCancel(); - - void setIcon(int dest, int idIcon); - bool initFTDialog(); - bool initFTWndMsgs(); - - void onLocalOneUpFolder(); - void onRemoteOneUpFolder(); - int makeOneUpFolder(char *pPath); - - void refreshBtnState(); - void setButtonsState(); - - bool m_bDlgShown; - bool m_bLocalBrowsing; - bool m_bCloseDlgAfterCancel; - - UINT m_msgCheckDeleteQueue; - UINT m_msgCheckTransferQueue; - UINT m_msgUploadFilePortion; - UINT m_msgDownloadFilePortion; - - DWORD m_dwNumStatusStrings; - - FTListView *m_pLocalLV; - FTListView *m_pRemoteLV; - - FTBrowseDlg *m_pBrowseDlg; - - int m_FTMenuSource; - - char m_szLocalPath[FT_FILENAME_SIZE]; - char m_szRemotePath[FT_FILENAME_SIZE]; - char m_szLocalPathTmp[FT_FILENAME_SIZE]; - char m_szRemotePathTmp[FT_FILENAME_SIZE]; - char m_szCreateFolderName[FT_FILENAME_SIZE]; - - static const char szCheckDeleteQueueText[]; - static const char szCheckTransferQueueText[]; - static const char szUploadFilePortionText[]; - - typedef struct tagFTBUTTONSSTATE - { - bool uploadBtn; - bool downloadBtn; - bool createLocalFldBtn; - bool createRemoteFldBtn; - bool renameLocalBtn; - bool renameRemoteBtn; - bool deleteLocalBtn; - bool deleteRemoteBtn; - bool cancelBtn; - } FTBUTTONSSTATE; - - FTBUTTONSSTATE m_BtnState; - - public: - class CancelingDlg - { - public: - CancelingDlg(FTDialog *pFTDlg); - ~CancelingDlg(); - - static BOOL CALLBACK cancelingDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - - bool create(); - bool destroy(); - - private: - FTDialog *m_pFTDlg; - HWND m_hwndDlg; - - bool close(bool bResult); - }; - - private: - CancelingDlg *m_pCancelingDlg; - - public: - class CreateFolderDlg : public Dialog - { - public: - CreateFolderDlg(FTDialog *pFTDlg); - ~CreateFolderDlg(); - - bool onOk(); - bool create(); - char *getFolderName() { return m_szFolderName; } - - protected: - FTDialog *m_pFTDlg; - char m_szFolderName[FT_FILENAME_SIZE]; - }; - - private: - CreateFolderDlg *m_pCreateFolderDlg; - - public: - class RenameDlg : public CreateFolderDlg - { - public: - RenameDlg(FTDialog *pFTDlg); - ~RenameDlg(); - - bool create(char *pFilename, bool bFolder); - void initDialog(); - - private: - bool m_bFolder; - char m_szFilename[FT_FILENAME_SIZE]; - }; - - private: - RenameDlg *m_pRenameDlg; - }; - } -} - -#endif // __RFB_WIN32_FTDIALOG_H__ diff --git a/win/vncviewer/FTListView.cxx b/win/vncviewer/FTListView.cxx deleted file mode 100644 index b2b472b4..00000000 --- a/win/vncviewer/FTListView.cxx +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky - * - * 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. - * - * - * - */ - -// -=- FTListView.cxx - -#include <vncviewer/FTListView.h> - -using namespace rfb; -using namespace rfb::win32; - -FTListView::FTListView(HWND hListView) -{ - m_bInitialized = false; - m_hListView = hListView; - m_fileInfo.free(); -} - -FTListView::~FTListView() -{ - m_fileInfo.free(); -} - - -bool -FTListView::initialize(HINSTANCE hInst) -{ - if (m_bInitialized) return false; - - initImageList(hInst); - - RECT Rect; - GetClientRect(m_hListView, &Rect); - Rect.right -= GetSystemMetrics(SM_CXHSCROLL); - int xwidth0 = (int) (0.35 * Rect.right); - int xwidth1 = (int) (0.22 * Rect.right); - int xwidth2 = (int) (0.43 * Rect.right); - - addColumn("Name", 0, xwidth0, LVCFMT_LEFT); - addColumn("Size", 1, xwidth1, LVCFMT_RIGHT); - addColumn("Data", 2, xwidth2, LVCFMT_LEFT); - - ListView_SetExtendedListViewStyleEx(m_hListView, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); - - return true; -} - -void -FTListView::onGetDispInfo(NMLVDISPINFO *pDI) -{ - if (m_fileInfo.getFlagsAt(pDI->item.iItem) & FT_ATTR_DIR) { - pDI->item.iImage = 0; - } else { - pDI->item.iImage = 1; - } - - switch (pDI->item.iSubItem) - { - case 0: - pDI->item.pszText = m_fileInfo.getNameAt(pDI->item.iItem); - break; - case 1: - { - unsigned int flags = m_fileInfo.getFlagsAt(pDI->item.iItem); - switch(flags & 0x000000FF) - { - case FT_ATTR_FILE: - { - char buf[32]; - unsigned int size = m_fileInfo.getSizeAt(pDI->item.iItem); - sprintf(buf, "%u", size); - pDI->item.pszText = buf; - } - break; - case FT_ATTR_DIR: - pDI->item.pszText = ""; - break; - default: - pDI->item.pszText = "Unspecified"; - } - } - break; - case 2: - { - unsigned int data = m_fileInfo.getDataAt(pDI->item.iItem); - if (data == 0) { - pDI->item.pszText = "Unspecified"; - } else { - FILETIME ft; - FolderManager fm; - fm.getFiletime(data, &ft); - - SYSTEMTIME st; - FileTimeToSystemTime(&ft, &st); - - char pDateTimeStr[1024]; - char timeFmt[128]; - GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, timeFmt, 128); - char dateFmt[128]; - GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, dateFmt, 128); - - char timeStr[128]; - GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, timeFmt, timeStr, 128); - char dateStr[128]; - GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, dateFmt, dateStr, 128); - - sprintf(pDateTimeStr, "%s %s", dateStr, timeStr); - pDI->item.pszText = pDateTimeStr; - } - } - break; - default: - break; - } -} - -void -FTListView::addItems(FileInfo *pFI) -{ - m_fileInfo.add(pFI); - LVITEM LVItem; - LVItem.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE; - LVItem.state = 0; - LVItem.stateMask = 0; - for (unsigned int i = 0; i < m_fileInfo.getNumEntries(); i++) { - LVItem.iItem = i; - LVItem.iSubItem = 0; - LVItem.iImage = I_IMAGECALLBACK; - LVItem.pszText = LPSTR_TEXTCALLBACK; - ListView_InsertItem(m_hListView, &LVItem); - } -} - -void -FTListView::deleteAllItems() -{ - ListView_DeleteAllItems(m_hListView); - m_fileInfo.free(); -} - -char * -FTListView::getActivateItemName(LPNMITEMACTIVATE lpnmia) -{ - return m_fileInfo.getNameAt(lpnmia->iItem); -} - -int -FTListView::getSelectedItems(FileInfo *pFI) -{ - int selCount = ListView_GetSelectedCount(m_hListView); - int selItem = ListView_GetSelectionMark(m_hListView); - if ((selCount < 1) || (selItem < 0)) return -1; - - selItem = -1; - selItem = ListView_GetNextItem(m_hListView, selItem, LVNI_SELECTED); - do { - pFI->add(m_fileInfo.getFullDataAt(selItem)); - selItem = ListView_GetNextItem(m_hListView, selItem, LVNI_SELECTED); - } while (selItem >= 0); - - return selCount; -} - -void -FTListView::initImageList(HINSTANCE hInst) -{ - m_hImageList = ImageList_Create(16, 16, ILC_MASK, 2, 2); - - HICON hiconItem = LoadIcon(hInst, MAKEINTRESOURCE(IDI_FTDIR)); - ImageList_AddIcon(m_hImageList, hiconItem); - DestroyIcon(hiconItem); - - hiconItem = LoadIcon(hInst, MAKEINTRESOURCE(IDI_FTFILE)); - ImageList_AddIcon(m_hImageList, hiconItem); - DestroyIcon(hiconItem); - - ListView_SetImageList(m_hListView, m_hImageList, LVSIL_SMALL); -} - -void -FTListView::addColumn(char *iText, int iOrder, int xWidth, int alignFmt) -{ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER; - lvc.fmt = alignFmt; - lvc.iSubItem = iOrder; - lvc.pszText = iText; - lvc.cchTextMax = 32; - lvc.cx = xWidth; - lvc.iOrder = iOrder; - ListView_InsertColumn(m_hListView, iOrder, &lvc); -} diff --git a/win/vncviewer/FTListView.h b/win/vncviewer/FTListView.h deleted file mode 100644 index 9bd3c2af..00000000 --- a/win/vncviewer/FTListView.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky. - * - * 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. - * - * - * - */ - -// -=- FTListView.h - -#ifndef __RFB_WIN32_FTLISTVIEW_H__ -#define __RFB_WIN32_FTLISTVIEW_H__ - -#include <windows.h> -#include <commctrl.h> - -#include <rfb/FileInfo.h> -#include <rfb_win32/FolderManager.h> -#include <vncviewer/resource.h> - -namespace rfb { - namespace win32{ - class FTListView - { - public: - FTListView(HWND hListView); - ~FTListView(); - - bool initialize(HINSTANCE hInst); - - void onGetDispInfo(NMLVDISPINFO *di); - void addItems(FileInfo *pFI); - void deleteAllItems(); - - char *getActivateItemName(LPNMITEMACTIVATE lpnmia); - int getSelectedItems(FileInfo *pFI); - - HWND getWndHandle() { return m_hListView; }; - - private: - HWND m_hListView; - FileInfo m_fileInfo; - HIMAGELIST m_hImageList; - - bool m_bInitialized; - - void addColumn(char *iText, int iOrder, int xWidth, int alignFmt); - void initImageList(HINSTANCE hInst); - - }; - } -} - -#endif // __RFB_WIN32_FTLISTVIEW_H__ diff --git a/win/vncviewer/FTProgress.cxx b/win/vncviewer/FTProgress.cxx deleted file mode 100644 index 04f0186b..00000000 --- a/win/vncviewer/FTProgress.cxx +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky - * - * 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. - * - * - * - */ - -// -=- FTProgress.cxx - -#include <vncviewer/FTProgress.h> - -using namespace rfb; -using namespace rfb::win32; - -FTProgress::FTProgress(HWND hwndParent) -{ - m_bInitialized = false; - m_hwndParent = hwndParent; - - m_pSingleProgress = NULL; - m_pGeneralProgress = NULL; - - m_hwndSinglePercent = GetDlgItem(m_hwndParent, IDC_FTSINGLEPERCENT); - m_hwndGeneralPercent = GetDlgItem(m_hwndParent, IDC_FTGENERALPERCENT); - - m_bInitialized = createProgressBarObjects(); -} - -FTProgress::~FTProgress() -{ - destroyProgressBarObjects(); -} - -void -FTProgress::increase(DWORD value) -{ - if (!m_bInitialized) return; - - m_pSingleProgress->increase(value); - m_pGeneralProgress->increase(value); - - setProgressText(); -} - -void -FTProgress::clearAndInitGeneral(DWORD64 dw64MaxValue, DWORD64 dw64Position) -{ - if (!m_bInitialized) return; - - m_pGeneralProgress->clear(); - m_pGeneralProgress->init(dw64MaxValue, dw64Position); - - setProgressText(); -} - -void -FTProgress::clearAndInitSingle(DWORD dwMaxValue, DWORD dwPosition) -{ - if (!m_bInitialized) return; - - m_pSingleProgress->clear(); - m_pSingleProgress->init(dwMaxValue, dwPosition); - - setProgressText(); -} - -void -FTProgress::clearAll() -{ - if (!m_bInitialized) return; - - m_pSingleProgress->clear(); - m_pGeneralProgress->clear(); - - setProgressText(); -} - -bool -FTProgress::createProgressBarObjects() -{ - if ((m_pSingleProgress != NULL) || (m_pGeneralProgress != NULL)) { - return false; - } else { - HWND hwndSingleProgr = GetDlgItem(m_hwndParent, IDC_FTSINGLEPROGRESS); - HWND hwndGeneralProgr = GetDlgItem(m_hwndParent, IDC_FTGENERALPROGRESS); - - m_pSingleProgress = new ProgressControl(hwndSingleProgr); - if (m_pSingleProgress == NULL) return false; - - m_pGeneralProgress = new ProgressControl(hwndGeneralProgr); - if (m_pGeneralProgress == NULL) { - delete m_pSingleProgress; - m_pSingleProgress = NULL; - return false; - } - } - return true; -} - -bool -FTProgress::destroyProgressBarObjects() -{ - clearAll(); - - if (m_pSingleProgress != NULL) { - delete m_pSingleProgress; - m_pSingleProgress = NULL; - } - - if (m_pGeneralProgress != NULL) { - delete m_pGeneralProgress; - m_pGeneralProgress = NULL; - } - - return true; -} - -void -FTProgress::setProgressText() -{ - char buf[16] = {0}; - char buf2[16] = {0}; - - int percent = m_pSingleProgress->getCurrentPercent(); - sprintf(buf, "%d%%", percent); - GetWindowText(m_hwndSinglePercent, buf2, 16); - if (strcmp(buf, buf2) != 0) - SetWindowText(m_hwndSinglePercent, buf); - - percent = m_pGeneralProgress->getCurrentPercent(); - sprintf(buf, "%d%%", percent); - GetWindowText(m_hwndGeneralPercent, buf2, 16); - if (strcmp(buf, buf2) != 0) - SetWindowText(m_hwndGeneralPercent, buf); -} diff --git a/win/vncviewer/FTProgress.h b/win/vncviewer/FTProgress.h deleted file mode 100644 index b51f19a8..00000000 --- a/win/vncviewer/FTProgress.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky - * - * 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. - * - * - * - */ - -// -=- FTProgress.h - -#ifndef __RFB_WIN32_FTPROGRESS_H__ -#define __RFB_WIN32_FTPROGRESS_H__ - -#include <windows.h> -#include <commctrl.h> -#include <stdio.h> - -#include <rfb_win32/ProgressControl.h> -#include <vncviewer/resource.h> - -namespace rfb { - namespace win32 { - class FTProgress - { - public: - FTProgress(HWND hwndParent); - ~FTProgress(); - - void increase(DWORD value); - void clearAndInitGeneral(DWORD64 dw64MaxValue, DWORD64 dw64Position); - void clearAndInitSingle(DWORD dwMaxValue, DWORD dwPosition); - void clearAll(); - - private: - ProgressControl *m_pSingleProgress; - ProgressControl *m_pGeneralProgress; - - HWND m_hwndParent; - HWND m_hwndSinglePercent; - HWND m_hwndGeneralPercent; - - bool m_bInitialized; - - void setProgressText(); - bool createProgressBarObjects(); - bool destroyProgressBarObjects(); - }; - } -} - -#endif // __RFB_WIN32_FTPROGRESS_H__ diff --git a/win/vncviewer/FileTransfer.cxx b/win/vncviewer/FileTransfer.cxx deleted file mode 100644 index 44c527b5..00000000 --- a/win/vncviewer/FileTransfer.cxx +++ /dev/null @@ -1,803 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky. - * - * 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. - * - * - * - */ - -// -=- FileTransfer.cxx - -#include <vncviewer/FileTransfer.h> - -using namespace rfb; -using namespace rfb::win32; - -FileTransfer::FileTransfer() -{ - m_bFTDlgShown = false; - m_bInitialized = false; - m_bResized = false; - m_bCancel = false; - m_bOverwriteAll = false; - - m_pFTDialog = new FTDialog(GetModuleHandle(0), this); - - m_pReader = NULL; - m_pWriter = NULL; - - m_dw64SizeSending = 0; - m_dirSizeRqstNum = 0; -} - -FileTransfer::~FileTransfer() -{ - if (m_pFTDialog != NULL) { - delete m_pFTDialog; - m_pFTDialog = NULL; - } - - if (m_pReader != NULL) { - delete m_pReader; - m_pReader = NULL; - } - - if (m_pWriter != NULL) { - delete m_pWriter; - m_pWriter = NULL; - } - - freeQueues(); -} - -bool -FileTransfer::initialize(rdr::InStream *pIS, rdr::OutStream *pOS) -{ - if (m_bInitialized) return false; - - m_pReader = new CFTMsgReader(pIS); - m_pWriter = new CFTMsgWriter(pOS); - - freeQueues(); - - m_bInitialized = true; - return true; -} - -bool -FileTransfer::show(HWND hwndParent) -{ - if (!m_bInitialized) return false; - - m_bFTDlgShown = m_pFTDialog->createFTDialog(hwndParent); - - return m_bFTDlgShown; -} - -bool -FileTransfer::processFTMsg(int type) -{ - if (!m_bInitialized) return false; - - switch (type) - { - case msgTypeFileListData: - return procFileListDataMsg(); - case msgTypeFileDownloadData: - return procFileDownloadDataMsg(); - case msgTypeFileUploadCancel: - return procFileUploadCancelMsg(); - case msgTypeFileDownloadFailed: - return procFileDownloadFailedMsg(); - case msgTypeFileDirSizeData: - return procFileDirSizeDataMsg(); - case msgTypeFileLastRequestFailed: - return procFileLastRqstFailedMsg(); - default: - return false; - } -} - -bool -FileTransfer::isTransferEnable() -{ - if (m_TransferQueue.getNumEntries() > 0) return true; else return false; -} - -void -FileTransfer::addDeleteQueue(char *pPathPrefix, FileInfo *pFI, unsigned int flags) -{ - if ((m_bFTDlgShown) && (m_DeleteQueue.getNumEntries() > 0)) - m_pFTDialog->setStatusText("Starting Delete Operation"); - - m_DeleteQueue.add(pPathPrefix, pPathPrefix, pFI, flags); - - checkDeleteQueue(); -} - -void -FileTransfer::checkDeleteQueue() -{ - if (m_DeleteQueue.getNumEntries() > 0) { - if (m_bFTDlgShown) - m_pFTDialog->setStatusText("Delete Operation Executing: %s", m_DeleteQueue.getFullLocPathAt(0)); - if (m_DeleteQueue.getFlagsAt(0) & FT_ATTR_DELETE_LOCAL) { - FolderManager fm; - if (!fm.deleteIt(m_DeleteQueue.getFullLocPathAt(0))) { - if (m_bFTDlgShown) m_pFTDialog->setStatusText("Delete Operation Failed"); - } else { - if (m_bFTDlgShown) m_pFTDialog->setStatusText("Delete Operation Completed"); - } - m_DeleteQueue.deleteAt(0); - m_pFTDialog->postCheckDeleteQueueMsg(); - } else { - if (m_DeleteQueue.getFlagsAt(0) & FT_ATTR_DELETE_REMOTE) { - writeFileDeleteRqst(strlen(m_DeleteQueue.getFullLocPathAt(0)), - m_DeleteQueue.getFullLocPathAt(0)); - - char *pPath = m_DeleteQueue.getLocPathAt(0); - m_queueFileListRqst.add(pPath, 0, 0, FT_FLR_DEST_DELETE); - writeFileListRqst(strlen(pPath), pPath, false); - } - } - } else { - if (m_bFTDlgShown) { - m_pFTDialog->setStatusText("Delete Operation Completed Successfully"); - PostMessage(m_pFTDialog->getWndHandle(), WM_COMMAND, MAKEWPARAM(IDC_FTLOCALRELOAD, 0), 0); - PostMessage(m_pFTDialog->getWndHandle(), WM_COMMAND, MAKEWPARAM(IDC_FTREMOTERELOAD, 0), 0); - } - } -} - -void -FileTransfer::addTransferQueue(char *pLocalPath, char *pRemotePath, - FileInfo *pFI, unsigned int flags) -{ - if (!isTransferEnable()) { - if (m_bFTDlgShown) m_pFTDialog->setStatusText("Starting Copy Operation"); - m_bTransferSuccess = true; - } - - m_TransferQueue.add(pLocalPath, pRemotePath, pFI, (flags | FT_ATTR_RESIZE_NEEDED)); - - checkTransferQueue(); -} - -bool -FileTransfer::resizeSending() -{ - for (unsigned int i = 0; i < m_TransferQueue.getNumEntries(); i++) { - unsigned int flags = m_TransferQueue.getFlagsAt(i); - if (flags & FT_ATTR_RESIZE_NEEDED) { - if (flags & FT_ATTR_FILE) { - m_bResized = true; - m_dw64SizeSending += m_TransferQueue.getSizeAt(i); - m_TransferQueue.clearFlagAt(i, FT_ATTR_RESIZE_NEEDED); - } else { - if (flags & FT_ATTR_DIR) { - if (flags & FT_ATTR_COPY_DOWNLOAD) { - m_bResized = true; - char *pPath = m_TransferQueue.getFullRemPathAt(i); - m_dirSizeRqstNum = i; - writeFileDirSizeRqst(strlen(pPath), pPath); - return false; - } else { - if (flags & FT_ATTR_COPY_UPLOAD) { - FolderManager fm; - DWORD64 dw64Size; - m_bResized = true; - fm.getDirSize(m_TransferQueue.getFullLocPathAt(i), &dw64Size); - m_dw64SizeSending += dw64Size; - m_TransferQueue.clearFlagAt(i, FT_ATTR_RESIZE_NEEDED); - } - } // if (flags & FT_ATTR_COPY_DOWNLOAD) - } // if (flags & FT_ATTR_FOLDER) - } // if (flags & FT_ATTR_FILE) - } // if (flags & FT_ATTR_NEEDED_RESIZE) - } // for (unsigned int i = 0; i < m_TransferQueue.getNumEntries(); i++) - - if ((m_bFTDlgShown) && (m_bResized)) { - m_pFTDialog->m_pProgress->clearAndInitGeneral(m_dw64SizeSending, 0); - m_bResized = false; - } - - return true; -} - -void -FileTransfer::checkTransferQueue() -{ - if (!isTransferEnable()) { - if (m_bFTDlgShown) { - m_pFTDialog->m_pProgress->clearAll(); - m_dw64SizeSending = 0; - m_bResized = false; - - if (m_bTransferSuccess) - m_pFTDialog->setStatusText("File Transfer Operation Completed Successfully"); - else - m_pFTDialog->setStatusText("File Transfer Operation Completed"); - - m_pFTDialog->afterCancelTransfer(); - PostMessage(m_pFTDialog->getWndHandle(), WM_COMMAND, MAKEWPARAM(IDC_FTLOCALRELOAD, 0), 0); - PostMessage(m_pFTDialog->getWndHandle(), WM_COMMAND, MAKEWPARAM(IDC_FTREMOTERELOAD, 0), 0); - return; - } - } else { - if (!resizeSending()) return; - - unsigned int flag0 = m_TransferQueue.getFlagsAt(0); - - if (flag0 & FT_ATTR_COPY_UPLOAD) { - if (flag0 & FT_ATTR_FILE) { - uploadFile(); - return; - } - if (flag0 & FT_ATTR_DIR) { - char *pFullPath = m_TransferQueue.getFullRemPathAt(0); - if (m_bFTDlgShown) m_pFTDialog->setStatusText("Creating Remote Folder. %s", pFullPath); - writeFileCreateDirRqst(strlen(pFullPath), pFullPath); - - char *pPath = m_TransferQueue.getRemPathAt(0); - m_TransferQueue.setFlagsAt(0, (flag0 | FT_ATTR_FLR_UPLOAD_CHECK)); - m_queueFileListRqst.add(pPath, 0, 0, FT_FLR_DEST_UPLOAD); - writeFileListRqst(strlen(pPath), pPath, false); - return; - } - } else { - if (flag0 & FT_ATTR_COPY_DOWNLOAD) { - if (flag0 & FT_ATTR_FILE) { - downloadFile(); - return; - } - if (flag0 & FT_ATTR_DIR) { - FolderManager fm; - char *pLocPath = m_TransferQueue.getFullLocPathAt(0); - if (m_bFTDlgShown) m_pFTDialog->setStatusText("Creating Local Folder. %s", pLocPath); - - if (!fm.createDir(pLocPath)) { - if (m_bFTDlgShown) m_pFTDialog->setStatusText("Creating Local Folder Failed."); - m_bTransferSuccess = false; - m_TransferQueue.deleteAt(0); - m_pFTDialog->postCheckTransferQueueMsg(); - return; - } else { - if ((m_bFTDlgShown) && (strcmp(m_TransferQueue.getLocPathAt(0), m_pFTDialog->getLocalPath()) == 0)) - PostMessage(m_pFTDialog->getWndHandle(), WM_COMMAND, MAKEWPARAM(IDC_FTLOCALRELOAD, 0), 0); - - m_TransferQueue.setFlagsAt(0, (m_TransferQueue.getFlagsAt(0) | FT_ATTR_FLR_DOWNLOAD_ADD)); - char *pRemPath = m_TransferQueue.getFullRemPathAt(0); - m_queueFileListRqst.add(pRemPath, 0, 0, FT_FLR_DEST_DOWNLOAD); - writeFileListRqst(strlen(pRemPath), pRemPath, 0); - return; - } - } - } - } - m_bTransferSuccess = false; - if (m_bFTDlgShown) m_pFTDialog->setStatusText("File Transfer Operation Failed. Unknown data in the transfer queue"); - } // if (!isTransferEnable()) -} - -bool -FileTransfer::uploadFile() -{ - if (m_TransferQueue.getFlagsAt(0) & FT_ATTR_FILE) { - if (m_fileReader.create(m_TransferQueue.getFullLocPathAt(0))) { - - if (m_bFTDlgShown) { - m_pFTDialog->setStatusText("Upload Started: %s to %s", - m_TransferQueue.getFullLocPathAt(0), - m_TransferQueue.getFullRemPathAt(0)); - m_pFTDialog->m_pProgress->clearAndInitSingle(m_TransferQueue.getSizeAt(0), 0); - } - - writeFileUploadRqst(strlen(m_TransferQueue.getFullRemPathAt(0)), - m_TransferQueue.getFullRemPathAt(0), 0); - uploadFilePortion(); - } - } - return false; -} - -bool -FileTransfer::downloadFile() -{ - if (m_TransferQueue.getFlagsAt(0) & FT_ATTR_FILE) { - if (m_fileWriter.create(m_TransferQueue.getFullLocPathAt(0))) { - if (m_bFTDlgShown) { - m_pFTDialog->setStatusText("Download Started: %s to %s", - m_TransferQueue.getFullRemPathAt(0), - m_TransferQueue.getFullLocPathAt(0)); - m_pFTDialog->m_pProgress->clearAndInitSingle(m_TransferQueue.getSizeAt(0), 0); - } - writeFileDownloadRqst(strlen(m_TransferQueue.getFullRemPathAt(0)), - m_TransferQueue.getFullRemPathAt(0), 0); - return true; - } else return false; - } - return false; -} - -void -FileTransfer::uploadFilePortion() -{ - if (checkCancelOperations()) { - char reason[] = "The user cancel transfer"; - m_pWriter->writeFileUploadFailed(strlen(reason), reason); - } - - if (m_fileReader.isCreated()) { - char buf[FT_MAX_SENDING_SIZE]; - unsigned int bytesRead = 0; - if (m_fileReader.read((void *)buf, FT_MAX_SENDING_SIZE, &bytesRead)) { - if (bytesRead == 0) { - m_pWriter->writeFileUploadData(m_TransferQueue.getDataAt(0)); - m_fileReader.close(); - if (m_bFTDlgShown) { - m_pFTDialog->m_pProgress->clearAndInitSingle(0, 0); - m_pFTDialog->setStatusText("Upload Completed"); - } - m_TransferQueue.deleteAt(0); - m_pFTDialog->postCheckTransferQueueMsg(); - } else { - if (m_bFTDlgShown) m_pFTDialog->m_pProgress->increase(bytesRead); - m_pWriter->writeFileUploadData(bytesRead, (char *)buf); - m_pFTDialog->postUploadFilePortionMsg(); - } - } else { - m_fileReader.close(); - m_bTransferSuccess = false; - char reason[] = "Error While Reading File"; - m_pWriter->writeFileUploadFailed(strlen(reason), reason); - if (m_bFTDlgShown) { - m_pFTDialog->m_pProgress->clearAndInitSingle(0, 0); - m_pFTDialog->setStatusText("Upload Failed"); - } - m_TransferQueue.deleteAt(0); - m_pFTDialog->postCheckTransferQueueMsg(); - } - } -} - -void -FileTransfer::createRemoteFolder(char *pPath, char *pName) -{ - char fullPath[FT_FILENAME_SIZE]; - sprintf(fullPath, "%s\\%s", pPath, pName); - m_pFTDialog->setStatusText("Creating Remote Folder: %s", fullPath); - writeFileCreateDirRqst(strlen(fullPath), fullPath); - requestFileList(pPath, FT_FLR_DEST_MAIN, false); -} - -void -FileTransfer::renameRemote(char *pPath, char *pOldName, char *pNewName) -{ - char fullOldName[FT_FILENAME_SIZE]; - char fullNewName[FT_FILENAME_SIZE]; - - sprintf(fullOldName, "%s\\%s", pPath, pOldName); - sprintf(fullNewName, "%s\\%s", pPath, pNewName); - - writeFileRenameRqst(strlen(fullOldName), strlen(fullNewName), - fullOldName, fullNewName); - requestFileList(pPath, FT_FLR_DEST_MAIN, false); -} - -bool -FileTransfer::procFileListDataMsg() -{ - FileInfo fileInfo; - int res = m_pReader->readFileListData(&fileInfo); - - bool bResult = false; - switch (m_queueFileListRqst.getFlagsAt(0)) - { - case FT_FLR_DEST_MAIN: - if (!m_bFTDlgShown) break; - - if (res < 0) { - m_pFTDialog->reqFolderUnavailable(); - bResult = true; - } else { - bResult = procFLRMain(&fileInfo); - } - break; - case FT_FLR_DEST_BROWSE: - bResult = procFLRBrowse(&fileInfo); - break; - case FT_FLR_DEST_UPLOAD: - bResult = procFLRUpload(&fileInfo); - break; - case FT_FLR_DEST_DOWNLOAD: - bResult = procFLRDownload(&fileInfo); - break; - case FT_FLR_DEST_DELETE: - bResult = procFLRDelete(&fileInfo); - break; - case FT_FLR_DEST_RENAME: - bResult = procFLRRename(&fileInfo); - break; - } - m_queueFileListRqst.deleteAt(0); - return bResult; -} - -bool -FileTransfer::procFileDownloadDataMsg() -{ - unsigned int bufSize = 0; - unsigned int modTime = 0; - - void *pFile = m_pReader->readFileDownloadData(&bufSize, &modTime); - - if (checkCancelOperations()) { - char reason[] = "The user cancel transfer"; - m_pWriter->writeFileDownloadCancel(strlen(reason), reason); - } - - if ((!m_fileWriter.isCreated()) || (!isTransferEnable())) { - m_bTransferSuccess = false; - if (pFile != NULL) delete [] pFile; - return false; - } - - if (bufSize > 0) { - unsigned int bytesWritten = 0; - m_fileWriter.write(pFile, bufSize, &bytesWritten); - delete [] pFile; - if (bytesWritten != bufSize) { - m_bTransferSuccess = false; - char reason[] = "Error File Writting to File"; - m_pWriter->writeFileDownloadCancel(strlen(reason), reason); - if (m_bFTDlgShown) { - m_pFTDialog->setStatusText("Download Failed"); - m_pFTDialog->m_pProgress->clearAndInitSingle(0, 0); - } - m_TransferQueue.deleteAt(0); - m_pFTDialog->postCheckTransferQueueMsg(); - return false; - } else { - if (m_bFTDlgShown) { - m_pFTDialog->m_pProgress->increase(bufSize); - } - } - return true; - } else { - if (modTime != 0) { - m_fileWriter.setTime(modTime); - m_fileWriter.close(); - if (m_bFTDlgShown) { - m_pFTDialog->setStatusText("Download Completed"); - m_pFTDialog->m_pProgress->clearAndInitSingle(0, 0); - } - m_TransferQueue.deleteAt(0); - m_pFTDialog->postCheckTransferQueueMsg(); - return true; - } else { - m_fileWriter.close(); - m_bTransferSuccess = false; - char reason[] = "Error File Writting"; - if (m_bFTDlgShown) { - m_pFTDialog->setStatusText("Download Failed"); - m_pFTDialog->m_pProgress->clearAndInitSingle(0, 0); - } - m_pWriter->writeFileDownloadCancel(strlen(reason), reason); - m_TransferQueue.deleteAt(0); - m_pFTDialog->postCheckTransferQueueMsg(); - } - } - return false; -} - -bool -FileTransfer::procFileUploadCancelMsg() -{ - unsigned int reasonSize = 0; - char *pReason = m_pReader->readFileUploadCancel(&reasonSize); - - if (m_bFTDlgShown) { - m_pFTDialog->setStatusText("Upload Canceled by Remote Computer : %s", pReason); - } - endUndoneOperation(); - m_pFTDialog->postCheckTransferQueueMsg(); - - delete [] pReason; - return true; -} - -bool -FileTransfer::procFileDownloadFailedMsg() -{ - unsigned int reasonSize = 0; - char *pReason = m_pReader->readFileDownloadFailed(&reasonSize); - - if (m_bFTDlgShown) { - m_pFTDialog->setStatusText("Download Failed by Remote Computer : %s", pReason); - } - endUndoneOperation(); - m_pFTDialog->postCheckTransferQueueMsg(); - - delete [] pReason; - return true; -} - -bool -FileTransfer::procFileDirSizeDataMsg() -{ - DWORD64 dw64DirSize = 0; - unsigned short dirSizeLow16 = 0; - unsigned int dirSizeHigh32 = 0; - m_pReader->readFileDirSizeData(&dirSizeLow16, &dirSizeHigh32); - - dw64DirSize = dirSizeLow16; - dw64DirSize = (dw64DirSize << 32) + dirSizeHigh32; - - m_dw64SizeSending += dw64DirSize; - m_TransferQueue.clearFlagAt(m_dirSizeRqstNum, FT_ATTR_RESIZE_NEEDED); - checkTransferQueue(); - return true; -} - -bool -FileTransfer::procFileLastRqstFailedMsg() -{ - unsigned int reasonSize = 0; - int requestType; - char *pReason = m_pReader->readFileLastRqstFailed(&requestType, &reasonSize); - delete [] pReason; - return true; -} - -bool -FileTransfer::procFLRMain(FileInfo *pFI) -{ - if (m_bFTDlgShown) m_pFTDialog->addRemoteLVItems(pFI); - return true; -} - -bool -FileTransfer::procFLRBrowse(FileInfo *pFI) -{ - m_pFTDialog->addBrowseItems(pFI); - return false; -} - -bool -FileTransfer::procFLRUpload(FileInfo *pFI) -{ - unsigned int flags = m_TransferQueue.getFlagsAt(0); - if (flags & FT_ATTR_FLR_UPLOAD_CHECK) { - int num = isExistName(pFI, m_TransferQueue.getRemNameAt(0)); - if (num >= 0) { - if ((m_bFTDlgShown) && (strcmp(m_TransferQueue.getRemPathAt(0), m_pFTDialog->getRemotePath()) == 0)) { - m_pFTDialog->addRemoteLVItems(pFI); - } - } else { - if (flags & FT_ATTR_DIR) { - m_TransferQueue.deleteAt(0); - m_bTransferSuccess = false; - if (m_bFTDlgShown) m_pFTDialog->setStatusText("Create Remote Folder Failed."); - } - } - } - FolderManager fm; - FileInfo fi; - flags = m_TransferQueue.getFlagsAt(0); - if (flags & FT_ATTR_FILE) { - uploadFile(); - return true; - } else { - if (fm.getDirInfo(m_TransferQueue.getFullLocPathAt(0), &fi, 0)) { - m_TransferQueue.add(m_TransferQueue.getFullLocPathAt(0), - m_TransferQueue.getFullRemPathAt(0), - &fi, FT_ATTR_COPY_UPLOAD); - } - } - m_TransferQueue.deleteAt(0); - m_pFTDialog->postCheckTransferQueueMsg(); - return true; -} - -bool -FileTransfer::procFLRDownload(FileInfo *pFI) -{ - unsigned int flags = m_TransferQueue.getFlagsAt(0); - - if ((flags & FT_ATTR_DIR) && (flags & FT_ATTR_FLR_DOWNLOAD_ADD)) { - m_TransferQueue.add(m_TransferQueue.getFullLocPathAt(0), - m_TransferQueue.getFullRemPathAt(0), - pFI, FT_ATTR_COPY_DOWNLOAD); - m_TransferQueue.deleteAt(0); - m_pFTDialog->postCheckTransferQueueMsg(); - return true; - } else { - m_bTransferSuccess = false; - if (m_bFTDlgShown) m_pFTDialog->setStatusText("File Transfer Operation Failed: Unknown data from server."); - } - return false; -} - -bool -FileTransfer::procFLRDelete(FileInfo *pFI) -{ - if (isExistName(pFI, m_DeleteQueue.getLocNameAt(0)) >= 0) { - if (m_bFTDlgShown) m_pFTDialog->setStatusText("Delete Operation Failed."); - } else { - if (m_bFTDlgShown) m_pFTDialog->setStatusText("Delete Operation Completed."); - } - m_DeleteQueue.deleteAt(0); - checkDeleteQueue(); - return true; -} - -bool -FileTransfer::procFLRRename(FileInfo *pFI) -{ - return false; -} - -void -FileTransfer::requestFileList(char *pPath, int dest, bool bDirOnly) -{ - m_queueFileListRqst.add(pPath, 0, 0, dest); - - writeFileListRqst(strlen(pPath), pPath, bDirOnly); -} - -int -FileTransfer::isExistName(FileInfo *pFI, char *pName) -{ - for (unsigned int i = 0; i < pFI->getNumEntries(); i++) { - if (strcmp(pFI->getNameAt(i), pName) == 0) { - return i; - } - } - return -1; -} - -bool -FileTransfer::checkCancelOperations() -{ - if (m_bFTDlgShown) m_pFTDialog->processDlgMsgs(); - if (m_bCancel) { - endUndoneOperation(); - if (m_bFTDlgShown) { - m_pFTDialog->setStatusText("All Operations Canceled"); - } - return true; - } else { - return false; - } -} - -void -FileTransfer::endUndoneOperation() -{ - m_bCancel = false; - m_bTransferSuccess = false; - m_fileReader.close(); - m_fileWriter.close(); - freeQueues(); - m_dw64SizeSending = 0; - m_pFTDialog->m_pProgress->clearAll(); -} - -void -FileTransfer::freeQueues() -{ - m_TransferQueue.free(); - m_DeleteQueue.free(); - m_queueFileListRqst.free(); -} - -int -FileTransfer::convertToUnixPath(char *path) -{ - int len = strlen(path); - if (len >= FT_FILENAME_SIZE) return -1; - if (len == 0) {strcpy(path, "/"); return 1;} - for (int i = (len - 1); i >= 0; i--) { - if (path[i] == '\\') path[i] = '/'; - path[i+1] = path[i]; - } - path[len + 1] = '\0'; - path[0] = '/'; - return strlen(path); -} - -bool -FileTransfer::writeFileListRqst(unsigned short dirnameLen, char *pDirName, bool bDirOnly) -{ - char dirName[FT_FILENAME_SIZE]; - strcpy(dirName, pDirName); - int len = convertToUnixPath(dirName); - if (len <= 0) return false; - - return m_pWriter->writeFileListRqst(len, dirName, bDirOnly); -} - -bool -FileTransfer::writeFileDownloadRqst(unsigned short filenameLen, char *pFilename, - unsigned int position) -{ - char filename[FT_FILENAME_SIZE]; - strcpy(filename, pFilename); - unsigned short len = (unsigned short) convertToUnixPath(filename); - if (len <= 0) return false; - - return m_pWriter->writeFileDownloadRqst(len, filename, position); -} - -bool -FileTransfer::writeFileUploadRqst(unsigned short filenameLen, char *pFilename, - unsigned int position) -{ - char filename[FT_FILENAME_SIZE]; - strcpy(filename, pFilename); - unsigned short len = (unsigned short) convertToUnixPath(filename); - if (len <= 0) return false; - - return m_pWriter->writeFileUploadRqst(len, filename, position); -} - -bool -FileTransfer::writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName) -{ - char path[FT_FILENAME_SIZE]; - strcpy(path, pDirName); - int nameLen = convertToUnixPath(path); - - return m_pWriter->writeFileCreateDirRqst(nameLen, path); -} - -bool -FileTransfer::writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName) -{ - char path[FT_FILENAME_SIZE]; - strcpy(path, pDirName); - int nameLen = convertToUnixPath(path); - - return m_pWriter->writeFileDirSizeRqst(nameLen, path); -} - -bool -FileTransfer::writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen, - char *pOldName, char *pNewName) -{ - char oldName[FT_FILENAME_SIZE]; - char newName[FT_FILENAME_SIZE]; - - strcpy(oldName, pOldName); - strcpy(newName, pNewName); - - int _oldNameLen = convertToUnixPath(oldName); - int _newNameLen = convertToUnixPath(newName); - - return m_pWriter->writeFileRenameRqst(_oldNameLen, _newNameLen, oldName, newName); -} - -bool -FileTransfer::writeFileDeleteRqst(unsigned short nameLen, char *pName) -{ - char path[FT_FILENAME_SIZE]; - strcpy(path, pName); - int _nameLen = convertToUnixPath(path); - - return m_pWriter->writeFileDeleteRqst(_nameLen, path); -} diff --git a/win/vncviewer/FileTransfer.h b/win/vncviewer/FileTransfer.h deleted file mode 100644 index 67e39012..00000000 --- a/win/vncviewer/FileTransfer.h +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * Developed by Dennis Syrovatsky - * - * 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. - * - * - * - */ - -// -=- 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 <rfb/CFTMsgReader.h> -#include <rfb/CFTMsgWriter.h> -#include <vncviewer/FTDialog.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(); - bool checkCancelOperations(); - - void uploadFilePortion(); - - void createRemoteFolder(char *pPath, char *pName); - void renameRemote(char *pPath, char *pOldName, char *pNewName); - - bool m_bCancel; - - private: - bool m_bFTDlgShown; - bool m_bInitialized; - bool m_bResized; - bool m_bTransferSuccess; - bool m_bOverwriteAll; - - FTDialog *m_pFTDialog; - - rfb::CFTMsgReader *m_pReader; - rfb::CFTMsgWriter *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(); - - void endUndoneOperation(); - - 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); - - int convertToUnixPath(char *path); - - bool writeFileListRqst(unsigned short dirnameLen, char *pDirName, bool bDirOnly); - bool writeFileDownloadRqst(unsigned short filenameLen, char *pFilename, - unsigned int position); - bool writeFileUploadRqst(unsigned short filenameLen, char *pFilename, - unsigned int position); - bool writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName); - bool writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName); - bool writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen, - char *pOldName, char *pNewName); - bool writeFileDeleteRqst(unsigned short nameLen, char *pName); - - DWORD64 m_dw64SizeSending; - unsigned int m_dirSizeRqstNum; - }; - } -} - -#endif // __RFB_WIN32_FILETRANSFER_H__ diff --git a/win/vncviewer/Makefile.am b/win/vncviewer/Makefile.am index 2e85f133..448729f6 100644 --- a/win/vncviewer/Makefile.am +++ b/win/vncviewer/Makefile.am @@ -7,11 +7,6 @@ HDRS = \ ConnectingDialog.h \ ConnectionDialog.h \ DesktopWindow.h \ - FileTransfer.h \ - FTBrowseDlg.h \ - FTDialog.h \ - FTListView.h \ - FTProgress.h \ InfoDialog.h \ ListenServer.h \ ListenTrayIcon.h \ @@ -29,11 +24,6 @@ vncviewer_SOURCES = $(HDRS) \ ConnectingDialog.cxx \ ConnectionDialog.cxx \ DesktopWindow.cxx \ - FileTransfer.cxx \ - FTBrowseDlg.cxx \ - FTDialog.cxx \ - FTListView.cxx \ - FTProgress.cxx \ InfoDialog.cxx \ OptionsDialog.cxx \ UserPasswdDialog.cxx \ diff --git a/win/vncviewer/ViewerToolBar.cxx b/win/vncviewer/ViewerToolBar.cxx index 66a50c36..38e84c45 100644 --- a/win/vncviewer/ViewerToolBar.cxx +++ b/win/vncviewer/ViewerToolBar.cxx @@ -44,7 +44,6 @@ void ViewerToolBar::create(HWND parentHwnd) { addButton(10, ID_CTRL_KEY); addButton(11, ID_ALT_KEY); addButton(0, 0, TBSTATE_ENABLED, TBSTYLE_SEP); - addButton(12, ID_FILE_TRANSFER); addButton(0, 0, TBSTATE_ENABLED, TBSTYLE_SEP); addButton(13, ID_NEW_CONNECTION); addButton(14, ID_CONN_SAVE_AS); @@ -87,9 +86,6 @@ LRESULT ViewerToolBar::processWM_NOTIFY(WPARAM wParam, LPARAM lParam) { case ID_ALT_KEY: TTStr->lpszText = "Send Alt key press/release"; break; - case ID_FILE_TRANSFER: - TTStr->lpszText = "Transfer files..."; - break; case ID_NEW_CONNECTION: TTStr->lpszText = "New connection..."; break; diff --git a/win/vncviewer/ftdir.ico b/win/vncviewer/ftdir.ico Binary files differdeleted file mode 100644 index 7a7f7419..00000000 --- a/win/vncviewer/ftdir.ico +++ /dev/null diff --git a/win/vncviewer/ftfile.ico b/win/vncviewer/ftfile.ico Binary files differdeleted file mode 100644 index a8084b88..00000000 --- a/win/vncviewer/ftfile.ico +++ /dev/null diff --git a/win/vncviewer/ftreload.ico b/win/vncviewer/ftreload.ico Binary files differdeleted file mode 100644 index 34383e90..00000000 --- a/win/vncviewer/ftreload.ico +++ /dev/null diff --git a/win/vncviewer/ftup.ico b/win/vncviewer/ftup.ico Binary files differdeleted file mode 100644 index fc215ada..00000000 --- a/win/vncviewer/ftup.ico +++ /dev/null diff --git a/win/vncviewer/resource.h b/win/vncviewer/resource.h index 5bc4bdc0..3f4a921c 100644 --- a/win/vncviewer/resource.h +++ b/win/vncviewer/resource.h @@ -17,17 +17,7 @@ #define IDD_CONNECTION_INFO 113 #define IDD_DEFAULTS 116 #define IDB_BITMAP 120 -#define IDD_FILETRANSFER_DLG 121 #define IDB_TOOLBAR 122 -#define IDD_FTCONFIRM_DLG 124 -#define IDI_FTUP 125 -#define IDI_FTDIR 126 -#define IDI_FTFILE 127 -#define IDI_FTRELOAD 128 -#define IDR_FTMENU 130 -#define IDD_FTCANCELING 131 -#define IDD_FTCREATEFOLDER 132 -#define IDD_FTBROWSE 133 #define IDC_PASSWORD 1000 #define IDC_CONNECTING_TEXT 1001 #define IDC_SERVER_EDIT 1002 @@ -82,42 +72,15 @@ #define IDC_AUTO_RECONNECT 1056 #define IDC_DISABLE_WINKEYS 1057 #define IDC_QUALITYLEVEL 1058 -#define IDC_FTLOCALUP 1058 #define IDC_SEND_SYSKEYS 1059 -#define IDC_FTLOCALBROWSE 1059 -#define IDC_FTREMOTERELOAD 1060 -#define IDC_FTREMOTEUP 1061 -#define IDC_FTREMOTEBROWSE 1062 -#define IDC_FTPROGRESS 1063 -#define IDC_FTGENERALPROGRESS 1063 #define IDC_PROGRESS 1064 -#define IDC_FTSINGLEPROGRESS 1064 -#define IDC_FTSTATUS 1065 -#define IDC_FTCURRENTPROCENT 1066 -#define IDC_FTSINGLEPERCENT 1066 -#define IDC_FTTOTALPROCENT 1067 -#define IDC_FTGENERALPERCENT 1067 -#define IDC_FTUPLOAD 1072 -#define IDC_FTCANCEL 1073 -#define IDC_FTDOWNLOAD 1074 -#define IDC_FTCLOSE 1075 -#define IDC_FTLOCALLABEL 1076 -#define IDC_FTREMOTELABEL 1077 -#define IDC_FTDIRNAME 1078 #define IDC_CONFIRM_YESTOALL 1079 #define IDC_CONFIRM_TEXT 1080 #define IDC_EDIT2 1082 -#define IDC_FTFOLDERNAME 1083 -#define IDC_FTTEXT 1084 -#define IDC_FTBROWSEPATH 1085 -#define IDC_FTBROWSETREE 1086 #define IDC_TYPE 1088 #define IDC_ENCODING_TIGHT 1089 -#define IDC_FTLOCALPATH 1090 #define IDC_CUSTOM_COMPRESSLEVEL 1091 -#define IDC_FTREMOTEPATH 1092 #define IDC_COMPRESSLEVEL 1093 -#define IDC_FTREMOTELIST 1094 #define IDC_ALLOW_JPEG 1095 #define IDC_FTLOCALRELOAD 1096 #define IDC_STATIC_SCALE 1097 @@ -137,16 +100,10 @@ #define ID_SEND_MENU_KEY 40013 #define ID_SEND_CTLESC 40014 #define ID_CONN_SAVE_AS 40015 -#define ID_FILE_TRANSFER 40016 #define ID_ZOOM_IN 40017 #define ID_ZOOM_OUT 40018 #define ID_ACTUAL_SIZE 40019 #define ID_AUTO_SIZE 40020 -#define IDM_FTCOPY 40022 -#define IDM_FTRENAME 40023 -#define IDM_FTDELETE 40024 -#define IDM_FTCANCEL 40025 -#define IDM_FTCREATEFOLDER 40026 #define IDM_SHOW_TOOLBAR 40027 // Next default values for new objects diff --git a/win/vncviewer/vncviewer.dsp b/win/vncviewer/vncviewer.dsp index e245cd6e..044a05a3 100644 --- a/win/vncviewer/vncviewer.dsp +++ b/win/vncviewer/vncviewer.dsp @@ -158,26 +158,6 @@ SOURCE=.\DesktopWindow.cxx # End Source File
# Begin Source File
-SOURCE=.\FileTransfer.cxx
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTBrowseDlg.cxx
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTDialog.cxx
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTListView.cxx
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTProgress.cxx
-# End Source File
-# Begin Source File
-
SOURCE=.\InfoDialog.cxx
# End Source File
# Begin Source File
@@ -230,26 +210,6 @@ SOURCE=.\DesktopWindow.h # End Source File
# Begin Source File
-SOURCE=.\FileTransfer.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTBrowseDlg.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTDialog.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTListView.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTProgress.h
-# End Source File
-# Begin Source File
-
SOURCE=.\InfoDialog.h
# End Source File
# Begin Source File
diff --git a/win/vncviewer/vncviewer.rc b/win/vncviewer/vncviewer.rc index 91d05672..7e2f6300 100644 --- a/win/vncviewer/vncviewer.rc +++ b/win/vncviewer/vncviewer.rc @@ -55,10 +55,6 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ICON ICON DISCARDABLE "vncviewer.ico" -IDI_FTDIR ICON DISCARDABLE "ftdir.ico" -IDI_FTFILE ICON DISCARDABLE "ftfile.ico" -IDI_FTRELOAD ICON DISCARDABLE "ftreload.ico" -IDI_FTUP ICON DISCARDABLE "ftup.ico" #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// @@ -309,99 +305,6 @@ BEGIN GROUPBOX "Defaults",IDC_STATIC,113,7,97,53 END -IDD_FILETRANSFER_DLG DIALOGEX 0, 0, 530, 282 -STYLE DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | WS_CAPTION | - WS_SYSMENU -EXSTYLE WS_EX_CONTEXTHELP | WS_EX_CONTROLPARENT -CAPTION "TigerVNC File Transfers" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - CONTROL "List1",IDC_FTLOCALLIST,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | - WS_TABSTOP,7,40,200,196 - CONTROL "List2",IDC_FTREMOTELIST,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | - WS_TABSTOP,323,40,200,196 - PUSHBUTTON "Upload Files and Folders",IDC_FTUPLOAD,218,66,94,12, - WS_DISABLED - PUSHBUTTON "Download Files and Folders",IDC_FTDOWNLOAD,218,85,94,12, - WS_DISABLED - PUSHBUTTON "Cancel File Transfer",IDC_FTCANCEL,218,167,94,12, - WS_DISABLED - PUSHBUTTON "Close",IDC_FTCLOSE,218,217,94,12 - EDITTEXT IDC_FTLOCALPATH,7,20,155,12,ES_AUTOHSCROLL | NOT - WS_TABSTOP - CTEXT "Local Computer",IDC_FTLOCALLABEL,7,7,200,10 - PUSHBUTTON "...",IDC_FTLOCALBROWSE,165,20,14,12,NOT WS_TABSTOP - PUSHBUTTON "",IDC_FTLOCALUP,179,20,14,12,BS_ICON | NOT WS_TABSTOP - PUSHBUTTON "",IDC_FTLOCALRELOAD,193,20,14,12,BS_ICON | NOT - WS_TABSTOP - CONTROL "Progress1",IDC_FTGENERALPROGRESS,"msctls_progress32", - WS_BORDER,55,244,128,10 - LTEXT "File Transfer",IDC_STATIC,7,245,40,8 - COMBOBOX IDC_FTSTATUS,7,263,516,65,CBS_DROPDOWNLIST | - CBS_NOINTEGRALHEIGHT | WS_VSCROLL - CONTROL "Progress1",IDC_FTSINGLEPROGRESS,"msctls_progress32", - WS_BORDER,370,244,128,10 - EDITTEXT IDC_FTREMOTEPATH,323,20,155,12,ES_AUTOHSCROLL | NOT - WS_TABSTOP - PUSHBUTTON "...",IDC_FTREMOTEBROWSE,481,20,14,12,NOT WS_TABSTOP - PUSHBUTTON "",IDC_FTREMOTEUP,495,20,14,12,BS_ICON | NOT WS_TABSTOP - PUSHBUTTON "",IDC_FTREMOTERELOAD,509,20,14,12,BS_ICON | NOT - WS_TABSTOP - CTEXT "TigerVNC Server",IDC_FTREMOTELABEL,323,7,200,10 - LTEXT "Current File",IDC_STATIC,323,245,36,8 - CTEXT "0%",IDC_FTGENERALPERCENT,189,245,18,8 - CTEXT "0%",IDC_FTSINGLEPERCENT,505,245,18,8 -END - -IDD_FTBROWSE DIALOGEX 0, 0, 183, 196 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Browse Folders" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,38,175,50,14 - PUSHBUTTON "Cancel",IDCANCEL,95,175,50,14 - EDITTEXT IDC_FTBROWSEPATH,7,7,169,12,ES_AUTOHSCROLL | ES_READONLY | - NOT WS_TABSTOP - CONTROL "Tree1",IDC_FTBROWSETREE,"SysTreeView32",TVS_HASBUTTONS | - TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | - TVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,25,169,143 -END - -IDD_FTCANCELING DIALOG DISCARDABLE 0, 0, 193, 63 -STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Canceling Active File Transfer" -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Yes",IDOK,40,42,50,14 - PUSHBUTTON "No",IDCANCEL,102,42,50,14 - LTEXT "FileTransfer is active.\nAre you sure you want to cancel transfer?", - IDC_STATIC,42,14,133,19 -END - -IDD_FTCONFIRM_DLG DIALOG DISCARDABLE 0, 0, 188, 143 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -FONT 8, "MS Sans Serif" -BEGIN - DEFPUSHBUTTON "Yes",IDOK,69,122,50,14,WS_GROUP - PUSHBUTTON "No",IDCANCEL,131,122,50,14 - PUSHBUTTON "Yes to All",IDC_CONFIRM_YESTOALL,7,122,50,14 - LTEXT "Static",IDC_CONFIRM_TEXT,7,7,174,107 -END - -IDD_FTCREATEFOLDER DIALOG DISCARDABLE 0, 0, 193, 63 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Create a New Folder" -FONT 8, "MS Sans Serif" -BEGIN - EDITTEXT IDC_FTFOLDERNAME,7,19,179,14,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,80,42,50,14 - PUSHBUTTON "Cancel",IDCANCEL,136,42,50,14 - LTEXT "New folder name:",IDC_FTTEXT,7,7,179,8 -END - ///////////////////////////////////////////////////////////////////////////// // @@ -579,54 +482,6 @@ BEGIN HORZGUIDE, 60 HORZGUIDE, 75 END - - IDD_FILETRANSFER_DLG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 523 - VERTGUIDE, 207 - VERTGUIDE, 265 - VERTGUIDE, 323 - TOPMARGIN, 7 - BOTTOMMARGIN, 275 - HORZGUIDE, 12 - HORZGUIDE, 26 - HORZGUIDE, 40 - HORZGUIDE, 47 - HORZGUIDE, 249 - END - - IDD_FTBROWSE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 176 - TOPMARGIN, 7 - BOTTOMMARGIN, 189 - END - - IDD_FTCANCELING, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 186 - TOPMARGIN, 7 - BOTTOMMARGIN, 56 - END - - IDD_FTCONFIRM_DLG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 181 - TOPMARGIN, 7 - BOTTOMMARGIN, 136 - END - - IDD_FTCREATEFOLDER, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 186 - TOPMARGIN, 7 - BOTTOMMARGIN, 56 - END END #endif // APSTUDIO_INVOKED @@ -669,20 +524,6 @@ BEGIN END END -IDR_FTMENU MENU DISCARDABLE -BEGIN - POPUP "File Transfer" - BEGIN - MENUITEM "Copy Files and Folders", IDM_FTCOPY - MENUITEM SEPARATOR - MENUITEM "Create a Folder", IDM_FTCREATEFOLDER - MENUITEM "Rename File or Folder", IDM_FTRENAME - MENUITEM "Delete Files and Folders", IDM_FTDELETE - MENUITEM SEPARATOR - MENUITEM "Cancel File Transfer", IDM_FTCANCEL - END -END - ///////////////////////////////////////////////////////////////////////////// // diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx index 6412aaec..9e8fa887 100644 --- a/win/winvnc/VNCServerWin32.cxx +++ b/win/winvnc/VNCServerWin32.cxx @@ -27,7 +27,6 @@ #include <rfb/SSecurityFactoryStandard.h> #include <rfb/Hostname.h> #include <rfb/LogWriter.h> -#include <rfb_win32/SFileTransferWin32.h> using namespace rfb; using namespace win32; @@ -39,9 +38,6 @@ static LogWriter vlog("VNCServerWin32"); const TCHAR* winvnc::VNCServerWin32::RegConfigPath = _T("Software\\TigerVNC\\WinVNC4"); -// FIXME: Move into an .h file? -extern const UINT VNCM_FT_DOWNLOAD; - static IntParameter http_port("HTTPPortNumber", "TCP/IP port on which the server will serve the Java applet VNC Viewer ", 5800); @@ -75,8 +71,6 @@ VNCServerWin32::VNCServerWin32() // Register the queued command event to be handled sockMgr.addEvent(commandEvent, this); - - vncServer.setFTManager((rfb::SFileTransferManager *)&m_FTManager); } VNCServerWin32::~VNCServerWin32() { @@ -183,8 +177,6 @@ int VNCServerWin32::run() { throw rdr::SystemException("getMessage", GetLastError()); if (!isServiceProcess() && (result == 0)) break; - if (msg.message == VNCM_FT_DOWNLOAD) - m_FTManager.processDownloadMsg(msg); TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/win/winvnc/VNCServerWin32.h b/win/winvnc/VNCServerWin32.h index 579a6a0b..f05f2c70 100644 --- a/win/winvnc/VNCServerWin32.h +++ b/win/winvnc/VNCServerWin32.h @@ -26,7 +26,6 @@ #include <rfb_win32/SDisplay.h> #include <rfb_win32/SocketManager.h> #include <rfb_win32/TCharArray.h> -#include <rfb_win32/SFileTransferManagerWin32.h> #include <winvnc/QueryConnectDialog.h> #include <winvnc/JavaViewer.h> #include <winvnc/ManagedListener.h> @@ -122,7 +121,6 @@ namespace winvnc { //rfb::SSecurityFactoryStandard securityFactory; QueryConnectDialog* queryConnectDialog; - rfb::win32::SFileTransferManagerWin32 m_FTManager; }; }; |