From: Dennis Syrovatsky Date: Mon, 17 Apr 2006 11:46:09 +0000 (+0000) Subject: Deleted the FTMsgReader(.cxx, .h) and the FTMsgWriter(.cxx, .h) files from the vncvie... X-Git-Tag: v0.0.90~384^2~314 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5722bf4e7132266457a873b1b5bff7f843e48b9b;p=tigervnc.git Deleted the FTMsgReader(.cxx, .h) and the FTMsgWriter(.cxx, .h) files from the vncviewer project. Classes FTMsgReader and FTMsgWriter was renamed to CFTMsgReader and CFTMsgWriter and moved to rfb project with minor changes for cross-platform compatibility. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@533 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/vncviewer/FTMsgReader.cxx b/vncviewer/FTMsgReader.cxx deleted file mode 100644 index d2d118bf..00000000 --- a/vncviewer/FTMsgReader.cxx +++ /dev/null @@ -1,164 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * 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/ - * - */ - -// -=- FTMsgReader.cxx - -#include - -using namespace rfb; -using namespace rfb::win32; - -FTMsgReader::FTMsgReader(rdr::InStream *pIS) -{ - m_pInStream = pIS; -} - -FTMsgReader::~FTMsgReader() -{ - -} - -int -FTMsgReader::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 * -FTMsgReader::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 * -FTMsgReader::readFileUploadCancel(unsigned int *pReasonSize) -{ - m_pInStream->skip(1); - return readReasonMsg(pReasonSize); -} - -char * -FTMsgReader::readFileDownloadFailed(unsigned int *pReasonSize) -{ - m_pInStream->skip(1); - return readReasonMsg(pReasonSize); -} - -int -FTMsgReader::readFileDirSizeData(DWORD64 *pdw64DirSize) -{ - m_pInStream->skip(1); - unsigned short size16 = m_pInStream->readU16(); - unsigned int size32 = m_pInStream->readU32(); - DWORD64 dw64Size = 0; - dw64Size = size16; - dw64Size = (dw64Size << 32) + size32; - *pdw64DirSize = dw64Size; - return 1; -} - -char * -FTMsgReader::readFileLastRqstFailed(int *pTypeOfRequest, unsigned int *pReasonSize) -{ - *pTypeOfRequest = m_pInStream->readU8(); - return readReasonMsg(pReasonSize); -} - -bool -FTMsgReader::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 == -1) { - 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 * -FTMsgReader::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/vncviewer/FTMsgReader.h b/vncviewer/FTMsgReader.h deleted file mode 100644 index 00706f71..00000000 --- a/vncviewer/FTMsgReader.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * 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/ - * - */ - -// -=- FTMsgReader.h - -#ifndef __RFB_WIN32_FTMSGREADER_H__ -#define __RFB_WIN32_FTMSGREADER_H__ - -#include - -#include -#include - -namespace rfb { - namespace win32 { - class FTMsgReader - { - public: - FTMsgReader(rdr::InStream *pIS); - ~FTMsgReader(); - - int readFileListData(FileInfo *pFileInfo); - int readFileDirSizeData(DWORD64 *pdw64DirSize); - - 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_WIN32_FTMSGREADER_H__ diff --git a/vncviewer/FTMsgWriter.cxx b/vncviewer/FTMsgWriter.cxx deleted file mode 100644 index a8fd6e13..00000000 --- a/vncviewer/FTMsgWriter.cxx +++ /dev/null @@ -1,232 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * 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/ - * - */ - -// -=- FTMsgWriter.cxx - -#include - -using namespace rfb; -using namespace rfb::win32; - -FTMsgWriter::FTMsgWriter(rdr::OutStream *pOS) -{ - m_pOutStream = pOS; -} - -FTMsgWriter::~FTMsgWriter() -{ -} - -bool -FTMsgWriter::writeFileListRqst(unsigned short dirnameLen, char *pDirName, - bool bDirOnly) -{ - if (dirnameLen >= FT_FILENAME_SIZE) return false; - - char dirName[FT_FILENAME_SIZE]; - strcpy(dirName, pDirName); - int len = convertToUnixPath(dirName); - if (len <= 0) return false; - - unsigned char flags = 0; - if (bDirOnly) flags = 0x10; - - m_pOutStream->writeU8(msgTypeFileListRequest); - m_pOutStream->writeU8(flags); - m_pOutStream->writeU16(len); - m_pOutStream->writeBytes((void *)dirName, len); - m_pOutStream->flush(); - - return true; -} - - -bool -FTMsgWriter::writeFileDownloadCancel(unsigned short reasonLen, char *pReason) -{ - m_pOutStream->writeU8(msgTypeFileDownloadCancel); - return writeU8U16StringMsg(reasonLen, pReason); -} - -bool -FTMsgWriter::writeFileDownloadRqst(unsigned short filenameLen, char *pFilename, - unsigned int position) -{ - if (filenameLen >= FT_FILENAME_SIZE) return false; - - char filename[FT_FILENAME_SIZE]; - strcpy(filename, pFilename); - unsigned short len = (unsigned short) convertToUnixPath(filename); - if (len <= 0) return false; - - m_pOutStream->writeU8(msgTypeFileDownloadRequest); - m_pOutStream->writeU8(0); - m_pOutStream->writeU16(len); - m_pOutStream->writeU32(position); - m_pOutStream->writeBytes(filename, len); - m_pOutStream->flush(); - - return true; -} - -bool -FTMsgWriter::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 -FTMsgWriter::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 -FTMsgWriter::writeFileUploadFailed(unsigned short reasonLen, char *pReason) -{ - m_pOutStream->writeU8(msgTypeFileUploadFailed); - return writeU8U16StringMsg(reasonLen, pReason); -} - -bool -FTMsgWriter::writeFileUploadRqst(unsigned short filenameLen, char *pFilename, - unsigned int position) -{ - if (filenameLen >= FT_FILENAME_SIZE) return false; - - char filename[FT_FILENAME_SIZE]; - strcpy(filename, pFilename); - unsigned short len = (unsigned short) convertToUnixPath(filename); - if (len <= 0) return false; - - m_pOutStream->writeU8(msgTypeFileUploadRequest); - m_pOutStream->writeU8(0); - m_pOutStream->writeU16(len); - m_pOutStream->writeU32(position); - m_pOutStream->writeBytes(filename, len); - m_pOutStream->flush(); - - return true; -} - -bool -FTMsgWriter::writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName) -{ - if (dirNameLen >= FT_FILENAME_SIZE) return false; - - char path[FT_FILENAME_SIZE]; - strcpy(path, pDirName); - int nameLen = convertToUnixPath(path); - - m_pOutStream->writeU8(msgTypeFileCreateDirRequest); - return writeU8U16StringMsg(nameLen, path); -} - -bool -FTMsgWriter::writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName) -{ - if (dirNameLen >= FT_FILENAME_SIZE) return false; - - char path[FT_FILENAME_SIZE]; - strcpy(path, pDirName); - int nameLen = convertToUnixPath(path); - - m_pOutStream->writeU8(msgTypeFileDirSizeRequest); - return writeU8U16StringMsg(nameLen, path); -} - -bool -FTMsgWriter::writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen, - char *pOldName, char *pNewName) -{ - if ((oldNameLen >= FT_FILENAME_SIZE) || (newNameLen >= FT_FILENAME_SIZE)) return false; - - char oldName[FT_FILENAME_SIZE]; - char newName[FT_FILENAME_SIZE]; - - strcpy(oldName, pOldName); - strcpy(newName, pNewName); - - int _oldNameLen = convertToUnixPath(oldName); - int _newNameLen = convertToUnixPath(newName); - - m_pOutStream->writeU8(msgTypeFileRenameRequest); - m_pOutStream->writeU8(0); - m_pOutStream->writeU16(_oldNameLen); - m_pOutStream->writeU16(_newNameLen); - m_pOutStream->writeBytes(oldName, _oldNameLen); - m_pOutStream->writeBytes(newName, _newNameLen); - m_pOutStream->flush(); - - return true; -} - -bool -FTMsgWriter::writeFileDeleteRqst(unsigned short nameLen, char *pName) -{ - if (nameLen >= FT_FILENAME_SIZE) return false; - - char path[FT_FILENAME_SIZE]; - strcpy(path, pName); - int _nameLen = convertToUnixPath(path); - - m_pOutStream->writeU8(msgTypeFileDeleteRequest); - return writeU8U16StringMsg(_nameLen, path); -} - -bool -FTMsgWriter::writeU8U16StringMsg(unsigned short strLength, char *pString) -{ - m_pOutStream->writeU8(0); - m_pOutStream->writeU16(strLength); - m_pOutStream->writeBytes(pString, strLength); - m_pOutStream->flush(); - return true; -} - -int -FTMsgWriter::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); -} diff --git a/vncviewer/FTMsgWriter.h b/vncviewer/FTMsgWriter.h deleted file mode 100644 index 42e9a93d..00000000 --- a/vncviewer/FTMsgWriter.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2005 TightVNC Team. All Rights Reserved. - * - * 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/ - * - */ - -// -=- FTMsgWriter.h - -#ifndef __RFB_WIN32_FTMSGWRITER_H__ -#define __RFB_WIN32_FTMSGWRITER_H__ - -#include -#include -#include -#include - -namespace rfb { - namespace win32 { - class FTMsgWriter - { - public: - FTMsgWriter(rdr::OutStream *pOS); - ~FTMsgWriter(); - - 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; - - int convertToUnixPath(char *path); - - bool writeU8U16StringMsg(unsigned short strLength, char *pString); - }; - } -} - -#endif // __RFB_WIN32_FTMSGWRITER_H__