From: Constantin Kaplinsky Date: Fri, 19 May 2006 10:09:44 +0000 (+0000) Subject: Fixed svn:eol-style properties. X-Git-Tag: v0.0.90~384^2~310 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4a1f695cc14ce387eaceb6dbcb5ddfbfcbf045d6;p=tigervnc.git Fixed svn:eol-style properties. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@561 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/rfb/CFTMsgReader.cxx b/rfb/CFTMsgReader.cxx index 66adbf50..5a17fc25 100644 --- a/rfb/CFTMsgReader.cxx +++ b/rfb/CFTMsgReader.cxx @@ -1,162 +1,162 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- CFTMsgReader.cxx - -#include - -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; - } -} - +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- CFTMsgReader.cxx + +#include + +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; + } +} + diff --git a/rfb/CFTMsgReader.h b/rfb/CFTMsgReader.h index b0e2c7a7..aece3e78 100644 --- a/rfb/CFTMsgReader.h +++ b/rfb/CFTMsgReader.h @@ -1,56 +1,56 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- CFTMsgReader.h - -#ifndef __RFB_CFTMSGREADER_H__ -#define __RFB_CFTMSGREADER_H__ - -#include -#include - -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__ +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- CFTMsgReader.h + +#ifndef __RFB_CFTMSGREADER_H__ +#define __RFB_CFTMSGREADER_H__ + +#include +#include + +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__ diff --git a/rfb/CFTMsgWriter.cxx b/rfb/CFTMsgWriter.cxx index 278cf800..5e6854ed 100644 --- a/rfb/CFTMsgWriter.cxx +++ b/rfb/CFTMsgWriter.cxx @@ -1,182 +1,182 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- CFTMsgWriter.cxx - -#include - -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; -} +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- CFTMsgWriter.cxx + +#include + +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; +} diff --git a/rfb/CFTMsgWriter.h b/rfb/CFTMsgWriter.h index c49c2aae..e4cdc0bd 100644 --- a/rfb/CFTMsgWriter.h +++ b/rfb/CFTMsgWriter.h @@ -1,67 +1,67 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- CFTMsgWriter.h - -#ifndef __RFB_CFTMSGWRITER_H__ -#define __RFB_CFTMSGWRITER_H__ - -#include -#include -#include -#include - -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__ +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- CFTMsgWriter.h + +#ifndef __RFB_CFTMSGWRITER_H__ +#define __RFB_CFTMSGWRITER_H__ + +#include +#include +#include +#include + +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__ diff --git a/rfb/SFileTransfer.cxx b/rfb/SFileTransfer.cxx index e947a742..9161fff7 100644 --- a/rfb/SFileTransfer.cxx +++ b/rfb/SFileTransfer.cxx @@ -1,334 +1,334 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- SFileTransfer.cxx - -#include -#include - -using namespace rfb; - -SFileTransfer::SFileTransfer(network::Socket *sock) : - m_pSocket(sock), m_reader(&sock->inStream()), m_writer(&sock->outStream()), - m_bUploadStarted(false), m_bDownloadStarted(false) -{ -} - -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)) return false; - - 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; - - void *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; -} +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- SFileTransfer.cxx + +#include +#include + +using namespace rfb; + +SFileTransfer::SFileTransfer(network::Socket *sock) : + m_pSocket(sock), m_reader(&sock->inStream()), m_writer(&sock->outStream()), + m_bUploadStarted(false), m_bDownloadStarted(false) +{ +} + +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)) return false; + + 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; + + void *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; +} diff --git a/rfb/SFileTransfer.h b/rfb/SFileTransfer.h index 9328ead8..62bed406 100644 --- a/rfb/SFileTransfer.h +++ b/rfb/SFileTransfer.h @@ -1,83 +1,83 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- SFileTransfer.h - -#ifndef __RFB_SFILETRANSFER_H__ -#define __RFB_SFILETRANSFER_H__ - -#include -#include -#include -#include -#include -#include -#include - -namespace rfb { - class SFileTransfer - { - public: - SFileTransfer(network::Socket *sock); - ~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__ +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- SFileTransfer.h + +#ifndef __RFB_SFILETRANSFER_H__ +#define __RFB_SFILETRANSFER_H__ + +#include +#include +#include +#include +#include +#include +#include + +namespace rfb { + class SFileTransfer + { + public: + SFileTransfer(network::Socket *sock); + ~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__ diff --git a/rfb/SFileTransferManager.cxx b/rfb/SFileTransferManager.cxx index c13e0c17..d8b231af 100644 --- a/rfb/SFileTransferManager.cxx +++ b/rfb/SFileTransferManager.cxx @@ -1,55 +1,55 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- SFileTransferManager.cxx - -#include - -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(); +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- SFileTransferManager.cxx + +#include + +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(); } \ No newline at end of file diff --git a/rfb/SFileTransferManager.h b/rfb/SFileTransferManager.h index 107d1445..4ee1406e 100644 --- a/rfb/SFileTransferManager.h +++ b/rfb/SFileTransferManager.h @@ -1,51 +1,51 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- SFileTransferManager.h - -#ifndef __RFB_SFILETRANSFERMANAGER_H__ -#define __RFB_SFILETRANSFERMANAGER_H__ - -#include - -#include -#include - -namespace rfb { - class SFileTransferManager - { - public: - SFileTransferManager(); - ~SFileTransferManager(); - - virtual SFileTransfer *createObject(network::Socket *sock) = 0; - void destroyObject(SFileTransfer *pFT); - - protected: - std::list m_lstFTObjects; - - void destroy(); - }; -} - -#endif // __RFB_SFILETRANSFERMANAGER_H__ +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- SFileTransferManager.h + +#ifndef __RFB_SFILETRANSFERMANAGER_H__ +#define __RFB_SFILETRANSFERMANAGER_H__ + +#include + +#include +#include + +namespace rfb { + class SFileTransferManager + { + public: + SFileTransferManager(); + ~SFileTransferManager(); + + virtual SFileTransfer *createObject(network::Socket *sock) = 0; + void destroyObject(SFileTransfer *pFT); + + protected: + std::list m_lstFTObjects; + + void destroy(); + }; +} + +#endif // __RFB_SFILETRANSFERMANAGER_H__ diff --git a/rfb_win32/SFileTransferManagerWin32.cxx b/rfb_win32/SFileTransferManagerWin32.cxx index 000b372b..edc898be 100644 --- a/rfb_win32/SFileTransferManagerWin32.cxx +++ b/rfb_win32/SFileTransferManagerWin32.cxx @@ -1,71 +1,71 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- SFileTransferManagerWin32.cxx - -#include - -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::iterator i; - for (i=m_lstFTObjects.begin(); i!=m_lstFTObjects.end(); i++) { - if ((*i) == pFT) { - (*i)->sendFileDownloadPortion(); - return; - } - } - } -} +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- SFileTransferManagerWin32.cxx + +#include + +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::iterator i; + for (i=m_lstFTObjects.begin(); i!=m_lstFTObjects.end(); i++) { + if ((*i) == pFT) { + (*i)->sendFileDownloadPortion(); + return; + } + } + } +} diff --git a/rfb_win32/SFileTransferManagerWin32.h b/rfb_win32/SFileTransferManagerWin32.h index 6014f389..b98de4f0 100644 --- a/rfb_win32/SFileTransferManagerWin32.h +++ b/rfb_win32/SFileTransferManagerWin32.h @@ -1,48 +1,48 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- SFileTransferManagerWin32.h - -#ifndef __RFB_WIN32_SFILETRANSFERMANAGERWIN32_H__ -#define __RFB_WIN32_SFILETRANSFERMANAGERWIN32_H__ - -#include -#include -#include - -namespace rfb { - namespace win32 { - class SFileTransferManagerWin32 : public rfb::SFileTransferManager - { - public: - SFileTransferManagerWin32(); - ~SFileTransferManagerWin32(); - - void processDownloadMsg(MSG msg); - - virtual SFileTransfer *createObject(network::Socket *sock); - }; - }; -} - -#endif // __RFB_WIN32_SFILETRANSFERMANAGERWIN32_H__ +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- SFileTransferManagerWin32.h + +#ifndef __RFB_WIN32_SFILETRANSFERMANAGERWIN32_H__ +#define __RFB_WIN32_SFILETRANSFERMANAGERWIN32_H__ + +#include +#include +#include + +namespace rfb { + namespace win32 { + class SFileTransferManagerWin32 : public rfb::SFileTransferManager + { + public: + SFileTransferManagerWin32(); + ~SFileTransferManagerWin32(); + + void processDownloadMsg(MSG msg); + + virtual SFileTransfer *createObject(network::Socket *sock); + }; + }; +} + +#endif // __RFB_WIN32_SFILETRANSFERMANAGERWIN32_H__ diff --git a/rfb_win32/SFileTransferWin32.cxx b/rfb_win32/SFileTransferWin32.cxx index 5a33a43c..5aea4126 100644 --- a/rfb_win32/SFileTransferWin32.cxx +++ b/rfb_win32/SFileTransferWin32.cxx @@ -1,125 +1,125 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- SFileTransferWin32.cxx - -#include -#include -#include - -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 & 0xFFFF000000000000) return false; - - *pHighSize16 = ((dw64DirSize & 0x0000FFFF00000000) >> 32); - *pLowSize32 = (dw64DirSize & 0x00000000FFFFFFFF); - - return true; -} +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- SFileTransferWin32.cxx + +#include +#include +#include + +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 & 0xFFFF000000000000) return false; + + *pHighSize16 = ((dw64DirSize & 0x0000FFFF00000000) >> 32); + *pLowSize32 = (dw64DirSize & 0x00000000FFFFFFFF); + + return true; +} diff --git a/rfb_win32/SFileTransferWin32.h b/rfb_win32/SFileTransferWin32.h index b2a5c579..f4c87ea8 100644 --- a/rfb_win32/SFileTransferWin32.h +++ b/rfb_win32/SFileTransferWin32.h @@ -1,59 +1,59 @@ -/* 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. - * - * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ - * - */ - -// -=- SFileTransferWin32.h - -#ifndef __RFB_SFILETRANSFERWIN32_H__ -#define __RFB_SFILETRANSFERWIN32_H__ - -#include - -#include - -const UINT VNCM_FT_DOWNLOAD = WM_USER + 2; - -namespace rfb { - namespace win32 { - class SFileTransferWin32 : public rfb::SFileTransfer - { - public: - SFileTransferWin32(network::Socket *sock); - ~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__ +/* 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. + * + * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ + * + */ + +// -=- SFileTransferWin32.h + +#ifndef __RFB_SFILETRANSFERWIN32_H__ +#define __RFB_SFILETRANSFERWIN32_H__ + +#include + +#include + +const UINT VNCM_FT_DOWNLOAD = WM_USER + 2; + +namespace rfb { + namespace win32 { + class SFileTransferWin32 : public rfb::SFileTransfer + { + public: + SFileTransferWin32(network::Socket *sock); + ~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__