+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- CFTMsgReader.cxx
-
-#include <rfb/CFTMsgReader.h>
-
-using namespace rfb;
-
-CFTMsgReader::CFTMsgReader(rdr::InStream *pIS)
-{
- m_pInStream = pIS;
-}
-
-CFTMsgReader::~CFTMsgReader()
-{
-
-}
-
-int
-CFTMsgReader::readFileListData(FileInfo *pFileInfo)
-{
- unsigned char flags = m_pInStream->readU8();
- int numFiles = m_pInStream->readU16();
- int dataSize = m_pInStream->readU16();
- int compressedSize = m_pInStream->readU16();
-
- if (flags & 0x80) {
- return -1;
- } else {
- if (numFiles > 0) {
- char *pFilenames = new char[compressedSize];
- SIZEDATAINFO *pSDI = new SIZEDATAINFO[numFiles];
- for (int i = 0; i < numFiles; i++) {
- pSDI[i].size = m_pInStream->readU32();
- pSDI[i].data = m_pInStream->readU32();
- }
- m_pInStream->readBytes((void *)pFilenames, compressedSize);
- createFileInfo(numFiles, pFileInfo, pSDI, pFilenames);
- delete [] pSDI;
- delete [] pFilenames;
- }
- }
- return numFiles;
-}
-
-void *
-CFTMsgReader::readFileDownloadData(unsigned int *pSize, unsigned int *pModTime)
-{
- unsigned char compressLevel = m_pInStream->readU8();
- int realSize = m_pInStream->readU16();
- int compressedSize = m_pInStream->readU16();
-
- if ((realSize == 0) && (compressedSize == 0)) {
- *pSize = 0;
- *pModTime = m_pInStream->readU32();
- return NULL;
- } else {
- char *pFile = new char [compressedSize];
- if (pFile == NULL) {
- m_pInStream->skip(compressedSize);
- *pModTime = 0;
- return NULL;
- } else {
- m_pInStream->readBytes(pFile, compressedSize);
- *pSize = compressedSize;
- return pFile;
- }
- }
-}
-
-char *
-CFTMsgReader::readFileUploadCancel(unsigned int *pReasonSize)
-{
- m_pInStream->skip(1);
- return readReasonMsg(pReasonSize);
-}
-
-char *
-CFTMsgReader::readFileDownloadFailed(unsigned int *pReasonSize)
-{
- m_pInStream->skip(1);
- return readReasonMsg(pReasonSize);
-}
-
-int
-CFTMsgReader::readFileDirSizeData(unsigned short *pDirSizeLow16,
- unsigned int *pDirSizeHigh32)
-{
- m_pInStream->skip(1);
- *pDirSizeLow16 = m_pInStream->readU16();
- *pDirSizeHigh32 = m_pInStream->readU32();
- return 1;
-}
-
-char *
-CFTMsgReader::readFileLastRqstFailed(int *pTypeOfRequest, unsigned int *pReasonSize)
-{
- *pTypeOfRequest = m_pInStream->readU8();
- return readReasonMsg(pReasonSize);
-}
-
-bool
-CFTMsgReader::createFileInfo(unsigned int numFiles, FileInfo *fi,
- SIZEDATAINFO *pSDInfo, char *pFilenames)
-{
- int pos = 0;
- int size = 0;
- for (unsigned int i = 0; i < numFiles; i++) {
- size = pSDInfo[i].size;
- if (size == FT_NET_ATTR_DIR) {
- fi->add((pFilenames + pos), size, pSDInfo[i].data, FT_ATTR_DIR);
- } else {
- fi->add((pFilenames + pos), size, pSDInfo[i].data, FT_ATTR_FILE);
- }
- pos += strlen(pFilenames + pos) + 1;
- }
- return true;
-}
-
-char *
-CFTMsgReader::readReasonMsg(unsigned int *pReasonSize)
-{
- int reasonLen = m_pInStream->readU16();
- int _reasonLen = reasonLen + 1;
- char *pReason;
- if (reasonLen == 0) {
- *pReasonSize = 0;
- return NULL;
- } else {
- pReason = new char [_reasonLen];
- if (pReason == NULL) {
- m_pInStream->skip(reasonLen);
- *pReasonSize = 0;
- return NULL;
- }
- m_pInStream->readBytes(pReason, reasonLen);
- memset(((char *)pReason+reasonLen), '\0', 1);
- return pReason;
- }
-}
-
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- CFTMsgReader.h
-
-#ifndef __RFB_CFTMSGREADER_H__
-#define __RFB_CFTMSGREADER_H__
-
-#include <rdr/InStream.h>
-#include <rfb/FileInfo.h>
-
-namespace rfb {
- class CFTMsgReader
- {
- public:
- CFTMsgReader(rdr::InStream *pIS);
- ~CFTMsgReader();
-
- int readFileListData(FileInfo *pFileInfo);
- int readFileDirSizeData(unsigned short *pDirSizeLow16, unsigned int *pDirSizeHigh32);
-
- char *readFileUploadCancel(unsigned int *pReasonSize);
- char *readFileDownloadFailed(unsigned int *pReasonSize);
- char *readFileLastRqstFailed(int *pTypeOfRequest, unsigned int *pReasonSize);
- void *readFileDownloadData(unsigned int *pSize, unsigned int *pModTime);
-
- private:
- rdr::InStream *m_pInStream;
-
- bool createFileInfo(unsigned int numFiles, FileInfo *fi,
- SIZEDATAINFO *pSDInfo, char *pFilenames);
- char *readReasonMsg(unsigned int *pReasonSize);
- };
-}
-
-#endif // __RFB_CFTMSGREADER_H__
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- CFTMsgWriter.cxx
-
-#include <rfb/CFTMsgWriter.h>
-
-using namespace rfb;
-
-CFTMsgWriter::CFTMsgWriter(rdr::OutStream *pOS)
-{
- m_pOutStream = pOS;
-}
-
-CFTMsgWriter::~CFTMsgWriter()
-{
-}
-
-bool
-CFTMsgWriter::writeFileListRqst(unsigned short dirnameLen, char *pDirName,
- bool bDirOnly)
-{
- if (dirnameLen >= FT_FILENAME_SIZE) return false;
-
- unsigned char flags = 0;
- if (bDirOnly) flags = 0x10;
-
- m_pOutStream->writeU8(msgTypeFileListRequest);
- m_pOutStream->writeU8(flags);
- m_pOutStream->writeU16(dirnameLen);
- m_pOutStream->writeBytes((void *)pDirName, dirnameLen);
- m_pOutStream->flush();
-
- return true;
-}
-
-
-bool
-CFTMsgWriter::writeFileDownloadCancel(unsigned short reasonLen, char *pReason)
-{
- m_pOutStream->writeU8(msgTypeFileDownloadCancel);
- return writeU8U16StringMsg(reasonLen, pReason);
-}
-
-bool
-CFTMsgWriter::writeFileDownloadRqst(unsigned short filenameLen, char *pFilename,
- unsigned int position)
-{
- if (filenameLen >= FT_FILENAME_SIZE) return false;
-
- m_pOutStream->writeU8(msgTypeFileDownloadRequest);
- m_pOutStream->writeU8(0);
- m_pOutStream->writeU16(filenameLen);
- m_pOutStream->writeU32(position);
- m_pOutStream->writeBytes(pFilename, filenameLen);
- m_pOutStream->flush();
-
- return true;
-}
-
-bool
-CFTMsgWriter::writeFileUploadData(unsigned short dataSize, char *pData)
-{
- m_pOutStream->writeU8(msgTypeFileUploadData);
- m_pOutStream->writeU8(0);
- m_pOutStream->writeU16(dataSize);
- m_pOutStream->writeU16(dataSize);
- m_pOutStream->writeBytes(pData, dataSize);
- m_pOutStream->flush();
-
- return true;
-}
-
-bool
-CFTMsgWriter::writeFileUploadData(unsigned int modTime)
-{
- m_pOutStream->writeU8(msgTypeFileUploadData);
- m_pOutStream->writeU8(0);
- m_pOutStream->writeU16(0);
- m_pOutStream->writeU16(0);
- m_pOutStream->writeU32(modTime);
- m_pOutStream->flush();
-
- return true;
-}
-
-bool
-CFTMsgWriter::writeFileUploadFailed(unsigned short reasonLen, char *pReason)
-{
- m_pOutStream->writeU8(msgTypeFileUploadFailed);
- return writeU8U16StringMsg(reasonLen, pReason);
-}
-
-bool
-CFTMsgWriter::writeFileUploadRqst(unsigned short filenameLen, char *pFilename,
- unsigned int position)
-{
- if (filenameLen >= FT_FILENAME_SIZE) return false;
-
- m_pOutStream->writeU8(msgTypeFileUploadRequest);
- m_pOutStream->writeU8(0);
- m_pOutStream->writeU16(filenameLen);
- m_pOutStream->writeU32(position);
- m_pOutStream->writeBytes((void *)pFilename, filenameLen);
- m_pOutStream->flush();
-
- return true;
-}
-
-bool
-CFTMsgWriter::writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName)
-{
- if (dirNameLen >= FT_FILENAME_SIZE) return false;
-
- m_pOutStream->writeU8(msgTypeFileCreateDirRequest);
- return writeU8U16StringMsg(dirNameLen, pDirName);
-}
-
-bool
-CFTMsgWriter::writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName)
-{
- if (dirNameLen >= FT_FILENAME_SIZE) return false;
-
- m_pOutStream->writeU8(msgTypeFileDirSizeRequest);
- return writeU8U16StringMsg(dirNameLen, pDirName);
-}
-
-bool
-CFTMsgWriter::writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen,
- char *pOldName, char *pNewName)
-{
- if ((oldNameLen >= FT_FILENAME_SIZE) || (newNameLen >= FT_FILENAME_SIZE)) return false;
-
- m_pOutStream->writeU8(msgTypeFileRenameRequest);
- m_pOutStream->writeU8(0);
- m_pOutStream->writeU16(oldNameLen);
- m_pOutStream->writeU16(newNameLen);
- m_pOutStream->writeBytes(pOldName, oldNameLen);
- m_pOutStream->writeBytes(pNewName, newNameLen);
- m_pOutStream->flush();
-
- return true;
-}
-
-bool
-CFTMsgWriter::writeFileDeleteRqst(unsigned short nameLen, char *pName)
-{
- if (nameLen >= FT_FILENAME_SIZE) return false;
-
- m_pOutStream->writeU8(msgTypeFileDeleteRequest);
- return writeU8U16StringMsg(nameLen, pName);
-}
-
-bool
-CFTMsgWriter::writeU8U16StringMsg(unsigned short strLength, char *pString)
-{
- m_pOutStream->writeU8(0);
- m_pOutStream->writeU16(strLength);
- m_pOutStream->writeBytes(pString, strLength);
- m_pOutStream->flush();
- return true;
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- CFTMsgWriter.h
-
-#ifndef __RFB_CFTMSGWRITER_H__
-#define __RFB_CFTMSGWRITER_H__
-
-#include <rdr/types.h>
-#include <rdr/OutStream.h>
-#include <rfb/msgTypes.h>
-#include <rfb/fttypes.h>
-
-namespace rfb {
- class CFTMsgWriter
- {
- public:
- CFTMsgWriter(rdr::OutStream *pOS);
- ~CFTMsgWriter();
-
- bool writeFileListRqst(unsigned short dirnameLen, char *pDirName, bool bDirOnly);
-
- bool writeFileDownloadCancel(unsigned short reasonLen, char *pReason);
- bool writeFileDownloadRqst(unsigned short filenameLen, char *pFilename,
- unsigned int position);
-
- bool writeFileUploadData(unsigned short dataSize, char *pData);
- bool writeFileUploadData(unsigned int modTime);
- bool writeFileUploadFailed(unsigned short reasonLen, char *pReason);
- 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);
-
- private:
- rdr::OutStream *m_pOutStream;
-
- bool writeU8U16StringMsg(unsigned short strLength, char *pString);
- };
-}
-
-#endif // __RFB_CFTMSGWRITER_H__
case msgTypeBell: readBell(); break;
case msgTypeServerCutText: readServerCutText(); break;
- case msgTypeFileListData:
- case msgTypeFileDownloadData:
- case msgTypeFileUploadCancel:
- case msgTypeFileDownloadFailed:
- case msgTypeFileDirSizeData:
- case msgTypeFileLastRequestFailed:
- handler->processFTMsg(type); break;
-
default:
fprintf(stderr, "unknown message type %d\n", type);
throw Exception("unknown message type");
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- DirManager.cxx
-
-#ifndef __RFB_DIRMANAGER_H__
-#define __RFB_DIRMANAGER_H__
-
-#include <rfb/FileInfo.h>
-
-namespace rfb {
- class DirManager {
- public:
- virtual ~DirManager() {};
- virtual bool createDir(char *pFullPath) = 0;
- virtual bool renameIt(char *pOldName, char *pNewName) = 0;
- virtual bool deleteIt(char *pFullPath) = 0;
-
- virtual bool getDirInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirOnly) = 0;
- };
-}
-
-#endif // __RFB_DIRMANAGER_H__
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-#include <rfb/FileInfo.h>
-#include <rfb/util.h>
-
-#ifdef _WIN32
-#define strcasecmp _stricmp
-#endif
-
-using namespace rfb;
-
-// FIXME: Under Unix, file names are case-sensitive.
-
-int
-CompareFileInfo(const void *F, const void *S)
-{
- FILEINFO *pF = (FILEINFO *) F;
- FILEINFO *pS = (FILEINFO *) S;
- if (pF->info.flags == pS->info.flags) {
- return strcasecmp(pF->name, pS->name);
- } else {
- if (pF->info.flags == FT_ATTR_DIR) return -1;
- if (pS->info.flags == FT_ATTR_DIR)
- return 1;
- else
- return strcasecmp(pF->name, pS->name);
- }
-
- return 0;
-}
-
-FileInfo::FileInfo()
-{
- m_numEntries = 0;
- m_pEntries = NULL;
-}
-
-FileInfo::~FileInfo()
-{
- free();
-}
-
-void
-FileInfo::add(FileInfo *pFI)
-{
- m_numEntries = pFI->getNumEntries();
- FILEINFO *pTemporary = new FILEINFO[m_numEntries];
- memcpy(pTemporary, pFI->getNameAt(0), m_numEntries * sizeof(FILEINFO));
-
- m_pEntries = pTemporary;
- pTemporary = NULL;
-}
-
-void
-FileInfo::add(FILEINFO *pFIStruct)
-{
- add(pFIStruct->name, pFIStruct->info.size, pFIStruct->info.data, pFIStruct->info.flags);
-}
-
-void
-FileInfo::add(char *pName, unsigned int size, unsigned int data, unsigned int flags)
-{
- FILEINFO *pTemporary = new FILEINFO[m_numEntries + 1];
- if (m_numEntries != 0)
- memcpy(pTemporary, m_pEntries, m_numEntries * sizeof(FILEINFO));
- strcpy(pTemporary[m_numEntries].name, pName);
- pTemporary[m_numEntries].info.size = size;
- pTemporary[m_numEntries].info.data = data;
- pTemporary[m_numEntries].info.flags = flags;
- if (m_pEntries != NULL) {
- delete [] m_pEntries;
- m_pEntries = NULL;
- }
- m_pEntries = pTemporary;
- pTemporary = NULL;
- m_numEntries++;
-}
-
-char *
-FileInfo::getNameAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].name;
- }
- return NULL;
-}
-
-bool
-FileInfo::setNameAt(unsigned int number, char *pName)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- strcpy(m_pEntries[number].name, pName);
- return true;
- }
- return false;
-}
-
-unsigned int
-FileInfo::getSizeAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].info.size;
- }
- return 0;
-}
-
-unsigned int
-FileInfo::getDataAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].info.data;
- }
- return 0;
-}
-
-unsigned int
-FileInfo::getFlagsAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].info.flags;
- }
- return 0;
-}
-
-FILEINFO *
-FileInfo::getFullDataAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return &m_pEntries[number];
- }
- return NULL;
-}
-
-bool
-FileInfo::setSizeAt(unsigned int number, unsigned int value)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- m_pEntries[number].info.size = value;
- return true;
- }
- return false;
-}
-
-bool
-FileInfo::setDataAt(unsigned int number, unsigned int value)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- m_pEntries[number].info.data = value;
- return true;
- }
- return false;
-}
-
-bool
-FileInfo::setFlagsAt(unsigned int number, unsigned int value)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- m_pEntries[number].info.flags = value;
- return true;
- }
- return false;
-}
-
-bool
-FileInfo::deleteAt(unsigned int number)
-{
- if ((number >= m_numEntries) || (number < 0)) return false;
-
- FILEINFO *pTemporary = new FILEINFO[m_numEntries - 1];
-
- if (number == 0) {
- memcpy(pTemporary, &m_pEntries[1], (m_numEntries - 1) * sizeof(FILEINFO));
- } else {
- memcpy(pTemporary, m_pEntries, number * sizeof(FILEINFO));
- if (number != (m_numEntries - 1))
- memcpy(&pTemporary[number], &m_pEntries[number + 1], (m_numEntries - number - 1) * sizeof(FILEINFO));
- }
-
- if (m_pEntries != NULL) {
- delete [] m_pEntries;
- m_pEntries = NULL;
- }
- m_pEntries = pTemporary;
- pTemporary = NULL;
- m_numEntries--;
- return true;
-}
-
-unsigned int
-FileInfo::getNumEntries()
-{
- return m_numEntries;
-}
-
-void
-FileInfo::sort()
-{
- qsort(m_pEntries, m_numEntries, sizeof(FILEINFO), CompareFileInfo);
-}
-
-void
-FileInfo::free()
-{
- if (m_pEntries != NULL) {
- delete [] m_pEntries;
- m_pEntries = NULL;
- }
- m_numEntries = 0;
-}
-
-unsigned int
-FileInfo::getFilenamesSize()
-{
- if (getNumEntries() == 0) return 0;
-
- unsigned int filenamesSize = 0;
-
- for (unsigned int i = 0; i < getNumEntries(); i++) {
- filenamesSize += strlen(getNameAt(i));
- }
-
- return filenamesSize;
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- FileInfo.
-
-#ifndef __RFB_FILEINFO_H__
-#define __RFB_FILEINFO_H__
-
-#include <stdlib.h>
-
-#include <rfb/fttypes.h>
-
-namespace rfb {
- class FileInfo
- {
- public:
- void add(FileInfo *pFI);
- void add(FILEINFO *pFIStruct);
- void add(char *pName, unsigned int size, unsigned int data, unsigned int flags);
-
- char *getNameAt(unsigned int number);
-
- bool setNameAt(unsigned int number, char *pName);
-
- unsigned int getSizeAt(unsigned int number);
- unsigned int getDataAt(unsigned int number);
- unsigned int getFlagsAt(unsigned int number);
-
- FILEINFO *getFullDataAt(unsigned int number);
-
- bool setSizeAt(unsigned int number, unsigned int value);
- bool setDataAt(unsigned int number, unsigned int value);
- bool setFlagsAt(unsigned int number, unsigned int value);
-
- bool deleteAt(unsigned int number);
-
- unsigned int getNumEntries();
-
- unsigned int getFilenamesSize();
-
- void sort();
- void free();
-
- FileInfo();
- ~FileInfo();
-
- private:
- FILEINFO *m_pEntries;
- unsigned int m_numEntries;
-
- };
-}
-
-#endif // __RFB_FILEINFO_H__
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- FileManager.cxx
-
-#include <rfb/FileManager.h>
-
-using namespace rfb;
-
-FileManager::FileManager()
-{
- m_pFile = NULL;
-}
-
-FileManager::~FileManager()
-{
- close();
-}
-
-bool
-FileManager::create(char *pFilename)
-{
- if (m_pFile != NULL) return false;
-
- strcpy(m_szFilename, pFilename);
-
- m_pFile = fopen(m_szFilename, m_szMode);
-
- if (m_pFile == NULL) {
- return false;
- } else {
- return true;
- }
-}
-
-bool
-FileManager::close()
-{
- if (m_pFile == NULL) return false;
-
- int result = fclose(m_pFile);
-
- if (result != 0) {
- return false;
- } else {
- m_pFile = NULL;
- return true;
- }
-}
-
-bool
-FileManager::isCreated()
-{
- if (m_pFile != NULL) return true; else return false;
-}
-
-char *
-FileManager::getFilename()
-{
- return m_szFilename;
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- FileManager.
-
-#ifndef __RFB_FILEMANAGER_H__
-#define __RFB_FILEMANAGER_H__
-
-#include <rfb/fttypes.h>
-
-namespace rfb {
- class FileManager {
- public:
- FileManager();
- ~FileManager();
-
- bool create(char *pFilename);
- bool close();
-
- bool isCreated();
-
- char *getFilename();
-
- protected:
- FILE *m_pFile;
- char m_szMode[4];
- char m_szFilename[FT_FILENAME_SIZE];
- };
-}
-#endif // __RFB_FILEMANAGER_H__
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- FileReader.cxx
-
-#include <rfb/FileReader.h>
-
-using namespace rfb;
-
-FileReader::FileReader()
-{
- strcpy(m_szMode, "rb");
-}
-
-bool
-FileReader::read(void *pBuf, unsigned int count, unsigned int *pBytesRead)
-{
- if (!isCreated()) return false;
-
- *pBytesRead = fread(pBuf, 1, count, m_pFile);
-
- if (ferror(m_pFile)) return false;
-
- return true;
-}
-
-unsigned int
-FileReader::getTime()
-{
- return 0;
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- FileReader.h
-
-#ifndef __RFB_FILEREADER_H__
-#define __RFB_FILEREADER_H__
-
-#include <rfb/FileManager.h>
-
-namespace rfb {
- class FileReader : public FileManager {
- public:
- FileReader();
-
- bool read(void *pBuf, unsigned int count, unsigned int *pBytesRead);
-
- unsigned int getTime();
- };
-}
-#endif // __RFB_FILEREADER_H__
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- FileWriter.cxx
-
-#include <rfb/FileWriter.h>
-
-using namespace rfb;
-
-FileWriter::FileWriter()
-{
- strcpy(m_szMode, "wb");
-}
-
-bool
-FileWriter::write(const void *pBuf, unsigned int count, unsigned int *pBytesWritten)
-{
- if (!isCreated()) return false;
-
- unsigned int bytesWritten = fwrite(pBuf, 1, count, m_pFile);
-
- if (ferror(m_pFile)) return false;
-
- *pBytesWritten = bytesWritten;
- return true;
-}
-
-bool
-FileWriter::setTime(unsigned int modTime)
-{
- return false;
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- FileWriter.h
-
-#ifndef __RFB_FILEWRITER_H__
-#define __RFB_FILEWRITER_H__
-
-#include <rfb/FileManager.h>
-
-namespace rfb {
- class FileWriter : public FileManager {
- public:
- FileWriter();
-
- bool write(const void *pBuf, unsigned int count, unsigned int *pBytesWritten);
- bool setTime(unsigned int modTime);
- };
-}
-
-#endif // __RFB_FILEWRITER_H__
noinst_LTLIBRARIES = librfb.la
-HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h CFTMsgReader.h \
- CFTMsgWriter.h CMsgHandler.h CMsgReader.h CMsgReaderV3.h CMsgWriter.h \
+HDRS = Blacklist.h CapsContainer.h CapsList.h CConnection.h \
+ CMsgHandler.h CMsgReader.h CMsgReaderV3.h CMsgWriter.h \
CMsgWriterV3.h ColourCube.h ColourMap.h ComparingUpdateTracker.h \
Configuration.h ConnParams.h CSecurity.h CSecurityNone.h \
- CSecurityVncAuth.h Cursor.h Decoder.h DirManager.h d3des.h Encoder.h \
- encodings.h Exception.h FileInfo.h FileManager.h FileReader.h \
- FileWriter.h fttypes.h hextileConstants.h hextileDecode.h \
+ CSecurityVncAuth.h Cursor.h Decoder.h d3des.h Encoder.h \
+ encodings.h Exception.h fttypes.h hextileConstants.h hextileDecode.h \
HextileDecoder.h hextileEncodeBetter.h hextileEncode.h \
HextileEncoder.h Hostname.h HTTPServer.h ImageGetter.h InputHandler.h \
KeyRemapper.h keysymdef.h \
msgTypes.h Password.h PixelBuffer.h PixelFormat.h PixelFormat.inl Pixel.h \
RawDecoder.h RawEncoder.h Rect.h Region.h rreDecode.h RREDecoder.h \
rreEncode.h RREEncoder.h ScaledPixelBuffer.h ScaleFilters.h \
- SConnection.h SDesktop.h secTypes.h ServerCore.h SFileTransfer.h \
- SFileTransferManager.h SFTMsgReader.h SFTMsgWriter.h SMsgHandler.h \
+ SConnection.h SDesktop.h secTypes.h ServerCore.h SMsgHandler.h \
SMsgReader.h SMsgReaderV3.h SMsgWriter.h SMsgWriterV3.h \
SSecurityFactoryStandard.h SSecurity.h SSecurityNone.h \
SSecurityVncAuth.h Threading.h tightDecode.h TightDecoder.h \
- tightEncode.h TightEncoder.h TightPalette.h Timer.h TransferQueue.h \
+ tightEncode.h TightEncoder.h TightPalette.h Timer.h \
TransImageGetter.h transInitTempl.h transTempl.h TrueColourMap.h \
UpdateTracker.h UserPasswdGetter.h util.h VNCSConnectionST.h \
VNCServer.h VNCServerST.h zrleDecode.h ZRLEDecoder.h zrleEncode.h \
ZRLEEncoder.h
-librfb_la_SOURCES = $(HDRS) Blacklist.cxx CConnection.cxx CFTMsgReader.cxx CFTMsgWriter.cxx CMsgHandler.cxx \
+librfb_la_SOURCES = $(HDRS) Blacklist.cxx CConnection.cxx CMsgHandler.cxx \
CMsgReader.cxx CMsgReaderV3.cxx CMsgWriter.cxx CMsgWriterV3.cxx \
CSecurityVncAuth.cxx CapsContainer.cxx CapsList.cxx \
ComparingUpdateTracker.cxx Configuration.cxx ConnParams.cxx \
- Cursor.cxx Decoder.cxx d3des.c Encoder.cxx FileInfo.cxx \
- FileManager.cxx FileReader.cxx FileWriter.cxx \
+ Cursor.cxx Decoder.cxx d3des.c Encoder.cxx \
HTTPServer.cxx HextileDecoder.cxx HextileEncoder.cxx \
KeyRemapper.cxx LogWriter.cxx Logger.cxx Logger_file.cxx \
Logger_stdio.cxx Password.cxx PixelBuffer.cxx PixelFormat.cxx \
RREEncoder.cxx RREDecoder.cxx RawDecoder.cxx RawEncoder.cxx \
- Region.cxx SConnection.cxx SFTMsgReader.cxx SFTMsgWriter.cxx \
- SFileTransfer.cxx SFileTransferManager.cxx SMsgHandler.cxx \
+ Region.cxx SConnection.cxx SMsgHandler.cxx \
SMsgReader.cxx SMsgReaderV3.cxx SMsgWriter.cxx SMsgWriterV3.cxx \
ServerCore.cxx SSecurityFactoryStandard.cxx SSecurityVncAuth.cxx \
ScaledPixelBuffer.cxx ScaleFilters.cxx Timer.cxx TightDecoder.cxx \
TightEncoder.cxx TightPalette.cxx TransImageGetter.cxx \
- TransferQueue.cxx UpdateTracker.cxx VNCSConnectionST.cxx \
+ UpdateTracker.cxx VNCSConnectionST.cxx \
VNCServerST.cxx ZRLEEncoder.cxx ZRLEDecoder.cxx encodings.cxx \
secTypes.cxx util.cxx
CapsList scaps;
- // File transfer:
- /* FIXME: File transfers are not finished yet:
- scaps.addTightExt(msgTypeFileListData, "FTS_LSDT");
- scaps.addTightExt(msgTypeFileDownloadData, "FTS_DNDT");
- scaps.addTightExt(msgTypeFileUploadCancel, "FTS_UPCN");
- scaps.addTightExt(msgTypeFileDownloadFailed, "FTS_DNFL");
- scaps.addTightExt(msgTypeFileDirSizeData, "FTS_DSDT");
- scaps.addTightExt(msgTypeFileLastRequestFailed, "FTS_RQFL");
- */
-
//
// Advertise support for non-standard client-to-server messages
//
CapsList ccaps;
- // File transfer:
- /* FIXME: File transfers are not finished yet:
- ccaps.addTightExt(msgTypeFileListRequest, "FTC_LSRQ");
- ccaps.addTightExt(msgTypeFileDownloadRequest, "FTC_DNRQ");
- ccaps.addTightExt(msgTypeFileUploadRequest, "FTC_UPRQ");
- ccaps.addTightExt(msgTypeFileUploadRequest, "FTC_UPDT");
- ccaps.addTightExt(msgTypeFileDownloadCancel, "FTC_DNCN");
- ccaps.addTightExt(msgTypeFileUploadFailed, "FTC_UPFL");
- ccaps.addTightExt(msgTypeFileCreateDirRequest, "FTC_FCDR");
- ccaps.addTightExt(msgTypeFileDirSizeRequest, "FTC_DSRQ");
- ccaps.addTightExt(msgTypeFileRenameRequest, "FTC_RNRQ");
- ccaps.addTightExt(msgTypeFileDeleteRequest, "FTC_RMRQ");
- */
-
//
// Advertise all supported encoding types (except raw encoding).
//
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- SFTMsgReader.cxx
-
-#include <rfb/SFTMsgReader.h>
-
-using namespace rfb;
-
-SFTMsgReader::SFTMsgReader(rdr::InStream *pIS)
-{
- m_pIS = pIS;
-}
-
-SFTMsgReader::~SFTMsgReader()
-{
-}
-
-bool
-SFTMsgReader::readFileListRqst(unsigned int *pDirNameSize, char *pDirName,
- unsigned int *pFlags)
-{
- *pFlags = m_pIS->readU8();
- unsigned int dirNameSize = m_pIS->readU16();
-
- if (dirNameSize >= FT_FILENAME_SIZE) {
- m_pIS->skip(dirNameSize);
- return false;
- } else {
- m_pIS->readBytes(pDirName, dirNameSize);
- *pDirNameSize = dirNameSize;
- pDirName[dirNameSize] = '\0';
- return true;
- }
-}
-
-bool
-SFTMsgReader::readFileDownloadRqst(unsigned int *pFilenameSize, char *pFilename,
- unsigned int *pPosition)
-{
- unsigned char compressedLevel = 0;
- return readU8U16U32StringMsg(&compressedLevel, pFilenameSize, pPosition, pFilename);
-}
-
-bool
-SFTMsgReader::readFileUploadRqst(unsigned int *pFilenameSize, char *pFilename,
- unsigned int *pPosition)
-{
- unsigned char compressedLevel = 0;
- return readU8U16U32StringMsg(&compressedLevel, pFilenameSize, pPosition, pFilename);
-}
-
-char *
-SFTMsgReader::readFileUploadData(unsigned int *pDataSize, unsigned int *pModTime)
-{
- /*
- * Compressed level is not used now so we have to skip one byte
- *
- * unsigned char compressedLevel = m_pIS->readU8();
- */
- (void) m_pIS->readU8();
- unsigned int realSize = m_pIS->readU16();
- unsigned int compressedSize = m_pIS->readU16();
-
- if ((realSize == 0) && (compressedSize == 0)) {
- *pDataSize = 0;
- *pModTime = m_pIS->readU32();
- return NULL;
- } else {
- char *pData = new char [compressedSize];
- m_pIS->readBytes(pData, compressedSize);
- *pDataSize = compressedSize;
- *pModTime = 0;
- return pData;
- }
-}
-
-bool
-SFTMsgReader::readFileCreateDirRqst(unsigned int *pDirNameSize, char *pDirName)
-{
- return readU8U16StringMsg(pDirNameSize, pDirName);
-}
-
-bool
-SFTMsgReader::readFileDirSizeRqst(unsigned int *pDirNameSize, char *pDirName)
-{
- return readU8U16StringMsg(pDirNameSize, pDirName);
-}
-
-bool
-SFTMsgReader::readFileDeleteRqst(unsigned int *pNameSize, char *pName)
-{
- return readU8U16StringMsg(pNameSize, pName);
-}
-
-bool
-SFTMsgReader::readFileRenameRqst(unsigned int *pOldNameSize,
- unsigned int *pNewNameSize,
- char *pOldName, char *pNewName)
-{
- m_pIS->skip(1);
-
- unsigned int oldNameSize = m_pIS->readU16();
- unsigned int newNameSize = m_pIS->readU16();
-
- if ((oldNameSize >= *pOldNameSize) || (newNameSize >= *pNewNameSize)) {
- m_pIS->skip(oldNameSize);
- m_pIS->skip(newNameSize);
- return false;
- }
-
- if (oldNameSize != 0) {
- m_pIS->readBytes(pOldName, oldNameSize);
- pOldName[oldNameSize] = '\0';
- *pOldNameSize = oldNameSize;
- } else {
- *pOldNameSize = 0;
- pOldName[0] = '\0';
- }
-
- if (newNameSize != 0) {
- m_pIS->readBytes(pNewName, newNameSize);
- pNewName[newNameSize] = '\0';
- } else {
- *pNewNameSize = 0;
- pNewName[0] = '\0';
- }
-
- return true;
-}
-
-bool
-SFTMsgReader::readFileDownloadCancel(unsigned int *pReasonSize, char *pReason)
-{
- return readU8U16StringMsg(pReasonSize, pReason);
-}
-
-bool
-SFTMsgReader::readFileUploadFailed(unsigned int *pReasonSize, char *pReason)
-{
- return readU8U16StringMsg(pReasonSize, pReason);
-}
-
-bool
-SFTMsgReader::readU8U16StringMsg(unsigned int *pReasonSize, char *pReason)
-{
- m_pIS->skip(1);
- unsigned int reasonSize = m_pIS->readU16();
-
- if (reasonSize >= FT_FILENAME_SIZE) {
- m_pIS->skip(reasonSize);
- return false;
- } else {
- if (reasonSize == 0) {
- pReason[0] = '\0';
- } else {
- m_pIS->readBytes(pReason, reasonSize);
- pReason[reasonSize] = '\0';
- }
- *pReasonSize = reasonSize;
- return true;
- }
-}
-
-bool
-SFTMsgReader::readU8U16U32StringMsg(unsigned char *pU8, unsigned int *pU16,
- unsigned int *pU32, char *pString)
-{
- *pU8 = m_pIS->readU8();
- unsigned int strSize = m_pIS->readU16();
- *pU32 = m_pIS->readU32();
-
- if (strSize >= FT_FILENAME_SIZE) {
- m_pIS->skip(strSize);
- return false;
- } else {
- *pU16 = strSize;
- if (strSize == 0) {
- pString[0] = '\0';
- } else {
- m_pIS->readBytes(pString, strSize);
- pString[strSize] = '\0';
- }
- return true;
- }
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- SFTMsgReader.h
-
-#ifndef __RFB_SFTMSGREADER_H__
-#define __RFB_SFTMSGREADER_H__
-
-#include <rdr/InStream.h>
-#include <rfb/fttypes.h>
-
-namespace rfb {
- class SFTMsgReader
- {
- public:
- SFTMsgReader(rdr::InStream *pIS);
- ~SFTMsgReader();
-
- bool readFileListRqst(unsigned int *pDirNameSize, char *pDirName,
- unsigned int *pFlags);
-
-
- bool readFileDownloadRqst(unsigned int *pFilenameSize, char *pFilename,
- unsigned int *pPosition);
-
- bool readFileUploadRqst(unsigned int *pFilenameSize, char *pFilename,
- unsigned int *pPosition);
-
- char *readFileUploadData(unsigned int *pDataSize, unsigned int *pModTime);
-
-
- bool readFileCreateDirRqst(unsigned int *pDirNameSize, char *pDirName);
- bool readFileDirSizeRqst(unsigned int *pDirNameSize, char *pDirName);
- bool readFileDeleteRqst(unsigned int *pNameSize, char *pName);
-
- bool readFileRenameRqst(unsigned int *pOldNameSize, unsigned int *pNewNameSize,
- char *pOldName, char *pNewName);
-
- bool readFileDownloadCancel(unsigned int *pReasonSize, char *pReason);
- bool readFileUploadFailed(unsigned int *pReasonSize, char *pReason);
-
- private:
- rdr::InStream *m_pIS;
-
- bool readU8U16StringMsg(unsigned int *pReasonSize, char *pReason);
- bool readU8U16U32StringMsg(unsigned char *pU8, unsigned int *pU16,
- unsigned int *pU32, char *pString);
- };
-}
-
-#endif // __RFB_SFTMSGREADER_H__
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- SFTMsgWriter.cxx
-
-#include <rfb/SFTMsgWriter.h>
-
-using namespace rfb;
-
-SFTMsgWriter::SFTMsgWriter(rdr::OutStream *pOS)
-{
- m_pOS = pOS;
-}
-
-SFTMsgWriter::~SFTMsgWriter()
-{
-}
-
-bool
-SFTMsgWriter::writeFileListData(unsigned char flags, rfb::FileInfo *pFileInfo)
-{
- unsigned int numFiles = pFileInfo->getNumEntries();
-
- m_pOS->writeU8(msgTypeFileListData);
- m_pOS->writeU8(flags);
- m_pOS->writeU16(numFiles);
-
- if (numFiles == 0) {
- m_pOS->writeU16(0);
- m_pOS->writeU16(0);
- } else {
- unsigned int filenamesSize = pFileInfo->getFilenamesSize() + numFiles;
-
- m_pOS->writeU16(filenamesSize);
- m_pOS->writeU16(filenamesSize);
-
- char *pFilenames = new char [filenamesSize];
- unsigned int pos = 0;
-
- for (unsigned int i = 0; i < numFiles; i++) {
- char *pName = pFileInfo->getNameAt(i);
- unsigned int len = strlen(pName);
-
- memcpy((void *)&pFilenames[pos], pName, len + 1);
- pos += (len + 1);
-
- if (pFileInfo->getFlagsAt(i) & FT_ATTR_DIR) {
- m_pOS->writeU32(FT_NET_ATTR_DIR);
- } else {
- m_pOS->writeU32(pFileInfo->getSizeAt(i));
- }
- m_pOS->writeU32(pFileInfo->getDataAt(i));
- }
-
- m_pOS->writeBytes(pFilenames, filenamesSize);
-
- delete [] pFilenames;
- }
-
- m_pOS->flush();
-
- return true;
-}
-
-bool
-SFTMsgWriter::writeFileDownloadData(unsigned int dataSize, void *pData)
-{
- m_pOS->writeU8(msgTypeFileDownloadData);
- m_pOS->writeU8(0);
- m_pOS->writeU16(dataSize);
- m_pOS->writeU16(dataSize);
- m_pOS->writeBytes(pData, dataSize);
- m_pOS->flush();
- return true;
-}
-
-bool
-SFTMsgWriter::writeFileDownloadData(unsigned int modTime)
-{
- m_pOS->writeU8(msgTypeFileDownloadData);
- m_pOS->writeU8(0);
- m_pOS->writeU16(0);
- m_pOS->writeU16(0);
- m_pOS->writeU32(modTime);
- m_pOS->flush();
- return true;
-}
-
-bool
-SFTMsgWriter::writeFileUploadCancel(unsigned int reasonLen, char *pReason)
-{
- m_pOS->writeU8(msgTypeFileUploadCancel);
- return writeU8U16StringMsg(0, reasonLen, pReason);
-}
-
-bool
-SFTMsgWriter::writeFileDownloadFailed(unsigned int reasonLen, char *pReason)
-{
- m_pOS->writeU8(msgTypeFileDownloadFailed);
- return writeU8U16StringMsg(0, reasonLen, pReason);
-}
-
-bool
-SFTMsgWriter::writeFileDirSizeData(unsigned int dirSizeLow,
- unsigned short dirSizeHigh)
-{
- m_pOS->writeU8(msgTypeFileDirSizeData);
- m_pOS->writeU8(0);
- m_pOS->writeU16(dirSizeHigh);
- m_pOS->writeU32(dirSizeLow);
- m_pOS->flush();
- return true;
-}
-
-bool
-SFTMsgWriter::writeFileLastRqstFailed(unsigned char lastRequest,
- unsigned short reasonLen,
- char *pReason)
-{
- m_pOS->writeU8(msgTypeFileLastRequestFailed);
- return writeU8U16StringMsg(lastRequest, reasonLen, pReason);
-}
-
-bool
-SFTMsgWriter::writeU8U16StringMsg(unsigned char p1, unsigned short p2, char *pP3)
-{
- m_pOS->writeU8(p1);
- m_pOS->writeU16(p2);
- m_pOS->writeBytes(pP3, p2);
- m_pOS->flush();
- return true;
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- SFTMsgWriter.h
-
-#ifndef __RFB_SFTMSGWRITER_H__
-#define __RFB_SFTMSGWRITER_H__
-
-#include <rdr/OutStream.h>
-#include <rfb/FileInfo.h>
-#include <rfb/msgTypes.h>
-
-namespace rfb {
- class SFTMsgWriter
- {
- public:
- SFTMsgWriter(rdr::OutStream *pOS);
- ~SFTMsgWriter();
-
- bool writeFileListData(unsigned char flags, rfb::FileInfo *pFileInfo);
- bool writeFileDownloadData(unsigned int dataSize, void *pData);
- bool writeFileDownloadData(unsigned int modTime);
- bool writeFileUploadCancel(unsigned int reasonLen, char *pReason);
- bool writeFileDownloadFailed(unsigned int reasonLen, char *pReason);
- bool writeFileDirSizeData(unsigned int dirSizeLow, unsigned short dirSizeHigh);
- bool writeFileLastRqstFailed(unsigned char lastRequest, unsigned short reasonLen,
- char *pReason);
-
- private:
- rdr::OutStream *m_pOS;
-
- bool writeU8U16StringMsg(unsigned char p1, unsigned short p2, char *pP3);
- };
-}
-
-#endif // __RFB_SFTMSGWRITER_H__
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- SFileTransfer.cxx
-
-#include <rfb/msgTypes.h>
-#include <rfb/SFileTransfer.h>
-
-using namespace rfb;
-
-SFileTransfer::SFileTransfer(network::Socket *sock) :
- m_bUploadStarted(false), m_bDownloadStarted(false),
- m_reader(&sock->inStream()), m_writer(&sock->outStream()), m_pSocket(sock)
-{
-}
-
-SFileTransfer::~SFileTransfer()
-{
-}
-
-bool
-SFileTransfer::processMessages(int type)
-{
- switch(type)
- {
- case msgTypeFileListRequest:
- return processFileListRequest();
- case msgTypeFileDownloadRequest:
- return processFileDownloadRequest();
- case msgTypeFileUploadRequest:
- return processFileUploadRequest();
- case msgTypeFileUploadData:
- return processFileUploadData();
- case msgTypeFileDownloadCancel:
- return processFileDownloadCancel();
- case msgTypeFileUploadFailed:
- return processFileUploadFailed();
- case msgTypeFileCreateDirRequest:
- return processFileCreateDirRequest();
- case msgTypeFileDirSizeRequest:
- return processFileDirSizeRequest();
- case msgTypeFileRenameRequest:
- return processFileRenameRequest();
- case msgTypeFileDeleteRequest:
- return processFileDeleteRequest();
- default:
- return false;
- }
-}
-
-bool
-SFileTransfer::processFileListRequest()
-{
- char szDirName[FT_FILENAME_SIZE] = {0};
- unsigned int dirNameSize = FT_FILENAME_SIZE;
- unsigned int flags = 0;
-
- if (!m_reader.readFileListRqst(&dirNameSize, szDirName, &flags)) return false;
-
- if (!convertPathFromNet(szDirName)) return false;
-
- bool bDirOnly = false;
- if (flags & 0x10) bDirOnly = true;
-
- FileInfo fi;
- if (!makeFileList(szDirName, &fi, bDirOnly)) {
- flags = (flags | 0x80);
- }
- return m_writer.writeFileListData((unsigned char)flags, &fi);
-}
-
-bool
-SFileTransfer::processFileDownloadRequest()
-{
- char szName[FT_FILENAME_SIZE] = {0};
- unsigned int nameSize = FT_FILENAME_SIZE;
- unsigned int position = 0;
-
- if (!m_reader.readFileDownloadRqst(&nameSize, szName, &position)) return false;
-
- if (!convertPathFromNet(szName)) return false;
-
- if (m_bDownloadStarted) {
- char reason[] = "The download is already started";
- m_writer.writeFileLastRqstFailed(msgTypeFileDownloadRequest, strlen(reason), reason);
- return false;
- }
-
- if (!m_fileReader.create(szName)) return false;
-
- m_bDownloadStarted = true;
-
- sendFileDownloadPortion();
-
- return true;
-}
-
-bool
-SFileTransfer::sendFileDownloadPortion()
-{
- char buffer[FT_MAX_SENDING_SIZE];
- unsigned int bytesRead = 0;
-
- if (m_fileReader.read((void *)buffer, FT_MAX_SENDING_SIZE, &bytesRead)) {
- if (bytesRead == 0) {
- m_writer.writeFileDownloadData(m_fileReader.getTime());
- m_fileReader.close();
- m_bDownloadStarted = false;
- return true;
- } else {
- m_writer.writeFileDownloadData(bytesRead, buffer);
- return initDownloadCallback();
- }
- } else {
- char reason[] = "Error while reading from file";
- m_writer.writeFileDownloadFailed(strlen(reason), reason);
- m_fileReader.close();
- m_bDownloadStarted = false;
- return true;
- }
-}
-
-bool
-SFileTransfer::processFileUploadRequest()
-{
- char szName[FT_FILENAME_SIZE] = {0};
- unsigned int nameSize = FT_FILENAME_SIZE;
- unsigned int position = 0;
-
- if (!m_reader.readFileUploadRqst(&nameSize, szName, &position)) return false;
-
- if (!convertPathFromNet(szName)) return false;
-
- if (m_bUploadStarted) {
- char reason[] = "The upload is already started";
- m_writer.writeFileLastRqstFailed(msgTypeFileUploadRequest, strlen(reason), reason);
- return false;
- }
-
- if (!m_fileWriter.create(szName)) {
- char reason[] = "Can't create local file";
- m_writer.writeFileLastRqstFailed(msgTypeFileUploadRequest, strlen(reason), reason);
- return true;
- }
-
- m_bUploadStarted = true;
-
- return true;
-}
-
-bool
-SFileTransfer::processFileUploadData()
-{
- unsigned int dataSize = 0;
- unsigned int modTime = 0;
-
- char *pUploadData = m_reader.readFileUploadData(&dataSize, &modTime);
-
- if (!m_bUploadStarted) {
- char reason[] = "Upload is impossible";
- m_writer.writeFileUploadCancel(strlen(reason), reason);
- } else {
- if (pUploadData == NULL) {
- if (modTime == 0) {
- char reason[] = "Upload failed";
- m_writer.writeFileUploadCancel(strlen(reason), reason);
- } else {
- m_fileWriter.setTime(modTime);
- }
- m_fileWriter.close();
- m_bUploadStarted = false;
- } else {
- unsigned int dataWritten = 0;
- m_fileWriter.write(pUploadData, dataSize, &dataWritten);
- if (dataWritten != dataSize) {
- char reason[] = "Upload failed";
- m_writer.writeFileUploadCancel(strlen(reason), reason);
- m_fileWriter.close();
- m_bUploadStarted = false;
- }
- }
- }
- delete [] pUploadData;
- return true;
-}
-
-bool
-SFileTransfer::processFileDownloadCancel()
-{
- char szReason[FT_FILENAME_SIZE] = {0};
- unsigned int reasonSize = FT_FILENAME_SIZE;
-
- if (!m_reader.readFileDownloadCancel(&reasonSize, szReason)) return false;
-
- m_fileReader.close();
- m_bDownloadStarted = false;
- return true;
-}
-
-bool
-SFileTransfer::processFileUploadFailed()
-{
- char szReason[FT_FILENAME_SIZE] = {0};
- unsigned int reasonSize = FT_FILENAME_SIZE;
-
- if (!m_reader.readFileUploadFailed(&reasonSize, szReason)) return false;
-
- deleteIt(m_fileWriter.getFilename());
- m_fileWriter.close();
- m_bUploadStarted = false;
- return true;
-}
-
-bool
-SFileTransfer::processFileCreateDirRequest()
-{
- char szName[FT_FILENAME_SIZE] = {0};
- unsigned int nameSize = FT_FILENAME_SIZE;
-
- if (!m_reader.readFileCreateDirRqst(&nameSize, szName)) return false;
-
- if (!convertPathFromNet(szName)) return false;
-
- return createDir(szName);
-}
-
-bool
-SFileTransfer::processFileDirSizeRequest()
-{
- char szName[FT_FILENAME_SIZE] = {0};
- unsigned int nameSize = FT_FILENAME_SIZE;
-
- if (!m_reader.readFileDirSizeRqst(&nameSize, szName)) return false;
-
- if (!convertPathFromNet(szName)) return false;
-
- unsigned short highSize16 = 0;
- unsigned int lowSize32 = 0;
-
- if (!getDirSize(szName, &highSize16, &lowSize32)) return false;
-
- return m_writer.writeFileDirSizeData(lowSize32, highSize16);
-}
-
-bool
-SFileTransfer::processFileRenameRequest()
-{
- char szOldName[FT_FILENAME_SIZE] = {0};
- char szNewName[FT_FILENAME_SIZE] = {0};
-
- unsigned int oldNameSize = FT_FILENAME_SIZE;
- unsigned int newNameSize = FT_FILENAME_SIZE;
-
- if (!m_reader.readFileRenameRqst(&oldNameSize, &newNameSize, szOldName, szNewName)) return false;
-
- if ((!convertPathFromNet(szOldName)) || (!convertPathFromNet(szNewName))) return false;
-
- return renameIt(szOldName, szNewName);
-}
-
-bool
-SFileTransfer::processFileDeleteRequest()
-{
- char szName[FT_FILENAME_SIZE] = {0};
- unsigned int nameSize = FT_FILENAME_SIZE;
-
- if (!m_reader.readFileDeleteRqst(&nameSize, szName)) return false;
-
- if (!convertPathFromNet(szName)) return false;
-
- return deleteIt(szName);
-}
-
-bool
-SFileTransfer::convertPathFromNet(char *pszPath)
-{
- return true;
-}
-
-bool
-SFileTransfer::makeFileList(char *pszPath, FileInfo *pFI, bool bDirOnly)
-{
- return false;
-}
-
-bool
-SFileTransfer::deleteIt(char *pszPath)
-{
- return false;
-}
-
-bool
-SFileTransfer::renameIt(char *pszOldPath, char *pszNewPath)
-{
- return false;
-}
-
-bool
-SFileTransfer::createDir(char *pszPath)
-{
- return false;
-}
-
-bool
-SFileTransfer::getDirSize(char *pszName, unsigned short *pHighSize16,
- unsigned int *pLowSize32)
-{
- return false;
-}
-
-bool
-SFileTransfer::initDownloadCallback()
-{
- return false;
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- SFileTransfer.h
-
-#ifndef __RFB_SFILETRANSFER_H__
-#define __RFB_SFILETRANSFER_H__
-
-#include <network/Socket.h>
-#include <rfb/SFTMsgReader.h>
-#include <rfb/SFTMsgWriter.h>
-#include <rfb/FileWriter.h>
-#include <rfb/FileReader.h>
-#include <rfb/FileInfo.h>
-#include <rfb/fttypes.h>
-
-namespace rfb {
- class SFileTransfer
- {
- public:
- SFileTransfer(network::Socket *sock);
- virtual ~SFileTransfer();
-
- bool processMessages(int type);
- bool sendFileDownloadPortion();
-
- protected:
- bool processFileListRequest();
- bool processFileDownloadRequest();
- bool processFileUploadRequest();
- bool processFileUploadData();
- bool processFileDownloadCancel();
- bool processFileUploadFailed();
- bool processFileCreateDirRequest();
- bool processFileDirSizeRequest();
- bool processFileRenameRequest();
- bool processFileDeleteRequest();
-
- virtual bool initDownloadCallback();
- virtual bool makeFileList(char *pszPath, FileInfo *pFI, bool bDirOnly);
- virtual bool convertPathFromNet(char *pszPath);
-
- 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);
-
- bool m_bUploadStarted;
- bool m_bDownloadStarted;
-
- private:
- SFTMsgReader m_reader;
- SFTMsgWriter m_writer;
-
- FileWriter m_fileWriter;
- FileReader m_fileReader;
-
- network::Socket *m_pSocket;
- };
-}
-
-#endif // __RFB_SFILETRANSFER_H__
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- SFileTransferManager.cxx
-
-#include <rfb/SFileTransferManager.h>
-
-using namespace rfb;
-
-SFileTransferManager::SFileTransferManager()
-{
-
-}
-
-SFileTransferManager::~SFileTransferManager()
-{
- destroy();
-}
-
-void
-SFileTransferManager::destroyObject(SFileTransfer *pFT)
-{
- if (pFT == NULL) return;
-
- m_lstFTObjects.remove(pFT);
-
- delete pFT;
-}
-
-void
-SFileTransferManager::destroy()
-{
- while(!m_lstFTObjects.empty())
- delete m_lstFTObjects.front();
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- SFileTransferManager.h
-
-#ifndef __RFB_SFILETRANSFERMANAGER_H__
-#define __RFB_SFILETRANSFERMANAGER_H__
-
-#include <list>
-
-#include <rfb/SFileTransfer.h>
-#include <network/Socket.h>
-
-namespace rfb {
- class SFileTransferManager
- {
- public:
- SFileTransferManager();
- virtual ~SFileTransferManager();
-
- virtual SFileTransfer *createObject(network::Socket *sock) = 0;
- void destroyObject(SFileTransfer *pFT);
-
- protected:
- std::list<SFileTransfer*> m_lstFTObjects;
-
- void destroy();
- };
-}
-
-#endif // __RFB_SFILETRANSFERMANAGER_H__
// specially for this purpose.
virtual void supportsLocalCursor();
- virtual bool processFTMsg(int type) = 0;
-
ConnParams cp;
};
}
case msgTypePointerEvent: readPointerEvent(); break;
case msgTypeClientCutText: readClientCutText(); break;
- case msgTypeFileListRequest:
- case msgTypeFileDownloadRequest:
- case msgTypeFileUploadRequest:
- case msgTypeFileUploadData:
- case msgTypeFileDownloadCancel:
- case msgTypeFileUploadFailed:
- case msgTypeFileCreateDirRequest:
- case msgTypeFileDirSizeRequest:
- case msgTypeFileRenameRequest:
- case msgTypeFileDeleteRequest: handler->processFTMsg(msgType); break;
-
default:
fprintf(stderr, "unknown message type %d\n", msgType);
throw Exception("unknown message type");
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- TransferQueue.
-
-#include <rfb/TransferQueue.h>
-
-using namespace rfb;
-
-TransferQueue::TransferQueue()
-{
- m_numEntries = 0;
- m_pEntries = NULL;
-}
-
-TransferQueue::~TransferQueue()
-{
- free();
-}
-
-void
-TransferQueue::add(TransferQueue *pTQ)
-{
- for (unsigned int i = 0; i < pTQ->getNumEntries(); i++) {
- add(pTQ->getLocPathAt(i), pTQ->getRemPathAt(i), pTQ->getLocNameAt(i),
- pTQ->getRemNameAt(i), pTQ->getSizeAt(i), pTQ->getDataAt(i), pTQ->getFlagsAt(i));
- }
-}
-
-void
-TransferQueue::add(char *pLocPath, char *pRemPath, FileInfo *pFI, unsigned int flags)
-{
- char locPath[FT_FILENAME_SIZE];
- char remPath[FT_FILENAME_SIZE];
- strcpy(locPath, pLocPath);
- strcpy(remPath, pRemPath);
-
- for (unsigned int i = 0; i < pFI->getNumEntries(); i++) {
- add(locPath, remPath, pFI->getNameAt(i), pFI->getNameAt(i),
- pFI->getSizeAt(i), pFI->getDataAt(i), (pFI->getFlagsAt(i) | flags));
- }
-}
-
-void
-TransferQueue::add(char *pLocPath, char *pRemPath, char *pLocName, char *pRemName,
- unsigned int size, unsigned int data, unsigned int flags)
-{
- FILEINFOEX *pTemporary = new FILEINFOEX[m_numEntries + 1];
- if (m_numEntries != 0)
- memcpy(pTemporary, m_pEntries, m_numEntries * sizeof(FILEINFOEX));
-
- strcpy(pTemporary[m_numEntries].locPath, pLocPath);
- strcpy(pTemporary[m_numEntries].locName, pLocName);
- strcpy(pTemporary[m_numEntries].remPath, pRemPath);
- strcpy(pTemporary[m_numEntries].remName, pRemName);
-
- pTemporary[m_numEntries].info.size = size;
- pTemporary[m_numEntries].info.data = data;
- pTemporary[m_numEntries].info.flags = flags;
-
- if (m_pEntries != NULL) {
- delete [] m_pEntries;
- m_pEntries = NULL;
- }
-
- m_pEntries = pTemporary;
- pTemporary = NULL;
- m_numEntries++;
-}
-
-char *
-TransferQueue::getLocPathAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].locPath;
- }
- return NULL;
-}
-
-char *
-TransferQueue::getLocNameAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].locName;
- }
- return NULL;
-}
-
-char *
-TransferQueue::getRemPathAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].remPath;
- }
- return NULL;
-}
-
-char *
-TransferQueue::getRemNameAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].remName;
- }
- return NULL;
-}
-
-char *
-TransferQueue::getFullLocPathAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- sprintf(m_szFullLocPath, "%s\\%s", getLocPathAt(number), getLocNameAt(number));
- return m_szFullLocPath;
- }
- return NULL;
-}
-
-char *
-TransferQueue::getFullRemPathAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- sprintf(m_szFullRemPath, "%s\\%s", getRemPathAt(number), getRemNameAt(number));
- return m_szFullRemPath;
- }
- return NULL;
-}
-
-SIZEDATAFLAGSINFO *
-TransferQueue::getSizeDataFlagsAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return &m_pEntries[number].info;
- }
- return NULL;
-}
-
-bool
-TransferQueue::setLocPathAt(unsigned int number, char *pName)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- strcpy(m_pEntries[number].locPath, pName);
- return true;
- }
- return false;
-}
-
-bool
-TransferQueue::setLocNameAt(unsigned int number, char *pName)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- strcpy(m_pEntries[number].locName, pName);
- return true;
- }
- return false;
-}
-
-bool
-TransferQueue::setRemPathAt(unsigned int number, char *pName)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- strcpy(m_pEntries[number].remPath, pName);
- return true;
- }
- return false;
-}
-
-bool
-TransferQueue::setRemNameAt(unsigned int number, char *pName)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- strcpy(m_pEntries[number].remName, pName);
- return true;
- }
- return false;
-}
-
-unsigned int
-TransferQueue::getSizeAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].info.size;
- }
- return 0;
-}
-
-unsigned int
-TransferQueue::getDataAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].info.data;
- }
- return 0;
-}
-
-unsigned int
-TransferQueue::getFlagsAt(unsigned int number)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- return m_pEntries[number].info.flags;
- }
- return 0;
-}
-
-bool
-TransferQueue::setSizeAt(unsigned int number, unsigned int value)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- m_pEntries[number].info.size = value;
- return true;
- }
- return false;
-}
-
-bool
-TransferQueue::setDataAt(unsigned int number, unsigned int value)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- m_pEntries[number].info.data = value;
- return true;
- }
- return false;
-}
-
-bool
-TransferQueue::setFlagsAt(unsigned int number, unsigned int value)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- m_pEntries[number].info.flags = m_pEntries[number].info.flags | value;
- return true;
- }
- return false;
-}
-
-bool
-TransferQueue::clearFlagAt(unsigned int number, unsigned int value)
-{
- if ((number >= 0) && (number < m_numEntries)) {
- m_pEntries[number].info.flags = (m_pEntries[number].info.flags & (value ^ 0xFFFFFFFF));
- return true;
- }
- return false;
-}
-
-bool
-TransferQueue::setFlagToAll(unsigned int flag)
-{
- for (unsigned int i = 0; i < m_numEntries; i++) {
- setFlagsAt(i, flag);
- }
- return true;
-}
-
-bool
-TransferQueue::deleteAt(unsigned int number)
-{
- if ((number >= m_numEntries) || (number < 0)) return false;
-
- FILEINFOEX *pTemporary = new FILEINFOEX[m_numEntries - 1];
-
- if (number == 0) {
- memcpy(pTemporary, &m_pEntries[1], (m_numEntries - 1) * sizeof(FILEINFOEX));
- } else {
- memcpy(pTemporary, m_pEntries, number * sizeof(FILEINFOEX));
- if (number != (m_numEntries - 1))
- memcpy(&pTemporary[number], &m_pEntries[number + 1], (m_numEntries - number - 1) * sizeof(FILEINFOEX));
- }
-
- if (m_pEntries != NULL) {
- delete [] m_pEntries;
- m_pEntries = NULL;
- }
- m_pEntries = pTemporary;
- pTemporary = NULL;
- m_numEntries--;
- return true;
-}
-
-unsigned int
-TransferQueue::getNumEntries()
-{
- return m_numEntries;
-}
-
-void
-TransferQueue::free()
-{
- if (m_pEntries != NULL) {
- delete [] m_pEntries;
- m_pEntries = NULL;
- }
- m_numEntries = 0;
-}
+++ /dev/null
-/* 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.
- *
- *
- *
- */
-
-// -=- TransferQueue.
-
-#ifndef __RFB_TRANSFERQUEUE_H__
-#define __RFB_TRANSFERQUEUE_H__
-
-#include <stdlib.h>
-
-#include <rfb/FileInfo.h>
-#include <rfb/fttypes.h>
-
-namespace rfb {
- class TransferQueue
- {
- public:
- TransferQueue();
- ~TransferQueue();
-
- void add(TransferQueue *pTQ);
- void add(char *pLocPath, char*pRemPath, FileInfo *pFI, unsigned int flags);
- void add(char *pLocPath, char *pRemPath, char *pLocName, char *pRemName,
- unsigned int size, unsigned int data, unsigned int flags);
-
- char *getLocPathAt(unsigned int number);
- char *getLocNameAt(unsigned int number);
- char *getRemPathAt(unsigned int number);
- char *getRemNameAt(unsigned int number);
-
- char *getFullLocPathAt(unsigned int number);
- char *getFullRemPathAt(unsigned int number);
-
- bool setLocPathAt(unsigned int number, char *pName);
- bool setLocNameAt(unsigned int number, char *pName);
- bool setRemPathAt(unsigned int number, char *pName);
- bool setRemNameAt(unsigned int number, char *pName);
-
- unsigned int getSizeAt(unsigned int number);
- unsigned int getDataAt(unsigned int number);
- unsigned int getFlagsAt(unsigned int number);
-
- SIZEDATAFLAGSINFO * getSizeDataFlagsAt(unsigned int number);
-
-
- bool setSizeAt(unsigned int number, unsigned int value);
- bool setDataAt(unsigned int number, unsigned int value);
- bool setFlagsAt(unsigned int number, unsigned int value);
- bool clearFlagAt(unsigned int number, unsigned int value);
- bool setFlagToAll(unsigned int flag);
-
- bool deleteAt(unsigned int number);
-
- unsigned int getNumEntries();
-
- void free();
-
- private:
- FILEINFOEX *m_pEntries;
- unsigned int m_numEntries;
-
- char m_szFullLocPath[FT_FILENAME_SIZE];
- char m_szFullRemPath[FT_FILENAME_SIZE];
- };
-}
-
-#endif // __RFB_TRANSFERQUEUE_H__
updates(false), image_getter(server->useEconomicTranslate),
drawRenderedCursor(false), removeRenderedCursor(false),
pointerEventTime(0), accessRights(AccessDefault),
- startTime(time(0)), m_pFileTransfer(0)
+ startTime(time(0))
{
setStreams(&sock->inStream(), &sock->outStream());
peerEndpoint.buf = sock->getPeerEndpoint();
setSocketTimeouts();
lastEventTime = time(0);
- // Add this client to the VNCServerST
- if (server->m_pFTManager != NULL) {
- SFileTransfer *pFT = server->m_pFTManager->createObject(sock);
- if (pFT != NULL) {
- m_pFileTransfer = pFT;
- }
- }
-
server->clients.push_front(this);
}
if (server->pointerClient == this)
server->pointerClient = 0;
- if (m_pFileTransfer)
- server->m_pFTManager->destroyObject(m_pFileTransfer);
-
// Remove this client from the server
server->clients.remove(this);
return 4;
}
-bool VNCSConnectionST::processFTMsg(int type)
-{
- if (m_pFileTransfer != NULL)
- return m_pFileTransfer->processMessages(type);
- else
- return false;
-}
#include <rfb/SMsgWriter.h>
#include <rfb/TransImageGetter.h>
#include <rfb/VNCServerST.h>
-#include <rfb/SFileTransfer.h>
namespace rfb {
class VNCSConnectionST : public SConnection,
void setStatus(int status);
int getStatus();
- bool processFTMsg(int type);
-
private:
// SConnection callbacks
CharArray closeReason;
time_t startTime;
-
- SFileTransfer *m_pFileTransfer;
};
}
#endif
// otherwise blacklisted connections might be "forgotten".
+#include <stdlib.h>
+
#include <rfb/ServerCore.h>
#include <rfb/VNCServerST.h>
#include <rfb/VNCSConnectionST.h>
VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_,
SSecurityFactory* sf)
: blHosts(&blacklist), desktop(desktop_), desktopStarted(false), pb(0),
- m_pFTManager(0), name(strDup(name_)), pointerClient(0), comparer(0),
+ name(strDup(name_)), pointerClient(0), comparer(0),
renderedCursorInvalid(false),
securityFactory(sf ? sf : &defaultSecurityFactory),
queryConnectionHandler(0), keyRemapper(&KeyRemapper::defInstance),
#include <rfb/Cursor.h>
#include <network/Socket.h>
#include <rfb/ListConnInfo.h>
-#include <rfb/SFileTransferManager.h>
namespace rfb {
bool getDisable() { return disableclients;};
void setDisable(bool disable) { disableclients = disable;};
- void setFTManager(rfb::SFileTransferManager *pFTManager) { m_pFTManager = pFTManager; };
-
protected:
friend class VNCSConnectionST;
bool desktopStarted;
PixelBuffer* pb;
- SFileTransferManager *m_pFTManager;
-
CharArray name;
std::list<VNCSConnectionST*> clients;
const int msgTypeBell = 2;
const int msgTypeServerCutText = 3;
- const int msgTypeFileListData = 130;
- const int msgTypeFileDownloadData = 131;
- const int msgTypeFileUploadCancel = 132;
- const int msgTypeFileDownloadFailed = 133;
- const int msgTypeFileDirSizeData = 134;
- const int msgTypeFileLastRequestFailed = 135;
-
const int msgTypeEndOfContinuousUpdates = 150;
// client to server
const int msgTypePointerEvent = 5;
const int msgTypeClientCutText = 6;
- const int msgTypeFileListRequest = 130;
- const int msgTypeFileDownloadRequest = 131;
- const int msgTypeFileUploadRequest = 132;
- const int msgTypeFileUploadData = 133;
- const int msgTypeFileDownloadCancel = 134;
- const int msgTypeFileUploadFailed = 135;
- const int msgTypeFileCreateDirRequest = 136;
- const int msgTypeFileDirSizeRequest = 137;
- const int msgTypeFileRenameRequest = 138;
- const int msgTypeFileDeleteRequest = 139;
-
const int msgTypeEnableContinuousUpdates = 150;
}
#endif
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\CFTMsgReader.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\CFTMsgWriter.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\CMsgHandler.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\FileInfo.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FileManager.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FileReader.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FileWriter.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\HextileDecoder.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\SFileTransfer.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\SFileTransferManager.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\SFTMsgReader.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\SFTMsgWriter.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\SMsgHandler.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\TransferQueue.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\TransImageGetter.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\CFTMsgReader.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\CFTMsgWriter.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\CMsgHandler.h\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\DirManager.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\Encoder.h\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\FileInfo.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FileManager.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FileReader.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FileWriter.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\hextileConstants.h\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\SFileTransfer.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\SFileTransferManager.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\SFTMsgReader.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\SFTMsgWriter.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\SMsgHandler.h\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\TransferQueue.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\TransImageGetter.h\r
# End Source File\r
# Begin Source File\r
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-/* 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__
DIBSectionBuffer.h \
DynamicFn.h \
EventManager.h \
- FolderManager.h \
Handle.h \
IconInfo.h \
IntervalTimer.h \
SDisplay.h \
Security.h \
Service.h \
- SFileTransferManagerWin32.h \
- SFileTransferWin32.h \
SInput.h \
SocketManager.h \
TCharArray.h \
DIBSectionBuffer.cxx \
DynamicFn.cxx \
EventManager.cxx \
- FolderManager.cxx \
LaunchProcess.cxx \
ListViewControl.cxx \
LowLevelKeyEvents.cxx \
SDisplay.cxx \
Security.cxx \
Service.cxx \
- SFileTransferManagerWin32.cxx \
- SFileTransferWin32.cxx \
SInput.cxx \
SocketManager.cxx \
TCharArray.cxx \
+++ /dev/null
-/* 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;
- }
- }
- }
-}
+++ /dev/null
-/* 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__
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-/* 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__
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\FolderManager.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\LaunchProcess.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\SFileTransferManagerWin32.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\SFileTransferWin32.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\SInput.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\FolderManager.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\Handle.h\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\SFileTransferManagerWin32.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\SFileTransferWin32.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\SInput.h\r
# End Source File\r
# Begin Source File\r
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;
reverseConnection = reverse;
initialiseProtocol();
- m_fileTransfer.initialize(&s->inStream(), &s->outStream());
-
return true;
}
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;
};
if (password) options.setPassword(*password);
}
-bool CConn::processFTMsg(int type) {
- return m_fileTransfer.processFTMsg(type);
-}
#include <vncviewer/OptionsDialog.h>
#include <vncviewer/CConnOptions.h>
#include <vncviewer/DesktopWindow.h>
-#include <vncviewer/FileTransfer.h>
#include <list>
// 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);
std::list<Rect> debugRects;
CharArray closeReason_;
bool isClosed_;
-
- FileTransfer m_fileTransfer;
};
};
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-/* 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__
+++ /dev/null
-/* 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);
-}
+++ /dev/null
-/* 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__
+++ /dev/null
-/* 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);
-}
+++ /dev/null
-/* 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__
+++ /dev/null
-/* 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);
-}
+++ /dev/null
-/* 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__
+++ /dev/null
-/* 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);
-}
+++ /dev/null
-/* 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__
ConnectingDialog.h \
ConnectionDialog.h \
DesktopWindow.h \
- FileTransfer.h \
- FTBrowseDlg.h \
- FTDialog.h \
- FTListView.h \
- FTProgress.h \
InfoDialog.h \
ListenServer.h \
ListenTrayIcon.h \
ConnectingDialog.cxx \
ConnectionDialog.cxx \
DesktopWindow.cxx \
- FileTransfer.cxx \
- FTBrowseDlg.cxx \
- FTDialog.cxx \
- FTListView.cxx \
- FTProgress.cxx \
InfoDialog.cxx \
OptionsDialog.cxx \
UserPasswdDialog.cxx \
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);
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;
#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
#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
#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
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\FileTransfer.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTBrowseDlg.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTDialog.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTListView.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTProgress.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\InfoDialog.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\FileTransfer.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTBrowseDlg.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTDialog.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTListView.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTProgress.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\InfoDialog.h\r
# End Source File\r
# Begin Source File\r
// 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
/////////////////////////////////////////////////////////////////////////////
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
-
/////////////////////////////////////////////////////////////////////////////
//
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
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
-
/////////////////////////////////////////////////////////////////////////////
//
#include <rfb/SSecurityFactoryStandard.h>
#include <rfb/Hostname.h>
#include <rfb/LogWriter.h>
-#include <rfb_win32/SFileTransferWin32.h>
using namespace rfb;
using namespace win32;
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);
// Register the queued command event to be handled
sockMgr.addEvent(commandEvent, this);
-
- vncServer.setFTManager((rfb::SFileTransferManager *)&m_FTManager);
}
VNCServerWin32::~VNCServerWin32() {
throw rdr::SystemException("getMessage", GetLastError());
if (!isServiceProcess() && (result == 0))
break;
- if (msg.message == VNCM_FT_DOWNLOAD)
- m_FTManager.processDownloadMsg(msg);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
#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>
//rfb::SSecurityFactoryStandard securityFactory;
QueryConnectDialog* queryConnectDialog;
- rfb::win32::SFileTransferManagerWin32 m_FTManager;
};
};