--- /dev/null
+/* Copyright (C) 2005 TightVNC Team. All Rights Reserved.\r
+ *\r
+ * Developed by Dennis Syrovatsky.\r
+ * \r
+ * This is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * This software is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this software; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\r
+ * USA.\r
+ *\r
+ * TightVNC distribution homepage on the Web: http://www.tightvnc.com/\r
+ *\r
+ */\r
+\r
+// -=- CFTMsgReader.cxx\r
+\r
+#include <rfb/CFTMsgReader.h>\r
+\r
+using namespace rfb;\r
+\r
+CFTMsgReader::CFTMsgReader(rdr::InStream *pIS)\r
+{\r
+ m_pInStream = pIS;\r
+}\r
+\r
+CFTMsgReader::~CFTMsgReader()\r
+{\r
+\r
+}\r
+\r
+int \r
+CFTMsgReader::readFileListData(FileInfo *pFileInfo)\r
+{\r
+ unsigned char flags = m_pInStream->readU8();\r
+ int numFiles = m_pInStream->readU16();\r
+ int dataSize = m_pInStream->readU16();\r
+ int compressedSize = m_pInStream->readU16();\r
+ \r
+ if (flags & 0x80) {\r
+ return -1;\r
+ } else {\r
+ if (numFiles > 0) {\r
+ char *pFilenames = new char[compressedSize];\r
+ SIZEDATAINFO *pSDI = new SIZEDATAINFO[numFiles];\r
+ for (int i = 0; i < numFiles; i++) {\r
+ pSDI[i].size = m_pInStream->readU32();\r
+ pSDI[i].data = m_pInStream->readU32();\r
+ }\r
+ m_pInStream->readBytes((void *)pFilenames, compressedSize);\r
+ createFileInfo(numFiles, pFileInfo, pSDI, pFilenames);\r
+ delete [] pSDI;\r
+ delete [] pFilenames;\r
+ }\r
+ }\r
+ return numFiles;\r
+}\r
+\r
+void * \r
+CFTMsgReader::readFileDownloadData(unsigned int *pSize, unsigned int *pModTime)\r
+{\r
+ unsigned char compressLevel = m_pInStream->readU8();\r
+ int realSize = m_pInStream->readU16();\r
+ int compressedSize = m_pInStream->readU16();\r
+\r
+ if ((realSize == 0) && (compressedSize == 0)) {\r
+ *pSize = 0;\r
+ *pModTime = m_pInStream->readU32();\r
+ return NULL;\r
+ } else {\r
+ char *pFile = new char [compressedSize];\r
+ if (pFile == NULL) {\r
+ m_pInStream->skip(compressedSize);\r
+ *pModTime = 0;\r
+ return NULL;\r
+ } else {\r
+ m_pInStream->readBytes(pFile, compressedSize);\r
+ *pSize = compressedSize;\r
+ return pFile;\r
+ }\r
+ }\r
+}\r
+\r
+char * \r
+CFTMsgReader::readFileUploadCancel(unsigned int *pReasonSize)\r
+{\r
+ m_pInStream->skip(1);\r
+ return readReasonMsg(pReasonSize);\r
+}\r
+\r
+char * \r
+CFTMsgReader::readFileDownloadFailed(unsigned int *pReasonSize)\r
+{\r
+ m_pInStream->skip(1);\r
+ return readReasonMsg(pReasonSize);\r
+}\r
+\r
+int \r
+CFTMsgReader::readFileDirSizeData(unsigned short *pDirSizeLow16, \r
+ unsigned int *pDirSizeHigh32)\r
+{\r
+ m_pInStream->skip(1);\r
+ *pDirSizeLow16 = m_pInStream->readU16();\r
+ *pDirSizeHigh32 = m_pInStream->readU32();\r
+ return 1;\r
+}\r
+\r
+char * \r
+CFTMsgReader::readFileLastRqstFailed(int *pTypeOfRequest, unsigned int *pReasonSize)\r
+{\r
+ *pTypeOfRequest = m_pInStream->readU8();\r
+ return readReasonMsg(pReasonSize);\r
+}\r
+\r
+bool \r
+CFTMsgReader::createFileInfo(unsigned int numFiles, FileInfo *fi, \r
+ SIZEDATAINFO *pSDInfo, char *pFilenames)\r
+{\r
+ int pos = 0;\r
+ int size = 0;\r
+ for (unsigned int i = 0; i < numFiles; i++) {\r
+ size = pSDInfo[i].size;\r
+ if (size == FT_NET_ATTR_DIR) {\r
+ fi->add((pFilenames + pos), size, pSDInfo[i].data, FT_ATTR_DIR);\r
+ } else {\r
+ fi->add((pFilenames + pos), size, pSDInfo[i].data, FT_ATTR_FILE);\r
+ }\r
+ pos += strlen(pFilenames + pos) + 1;\r
+ }\r
+ return true;\r
+}\r
+\r
+char * \r
+CFTMsgReader::readReasonMsg(unsigned int *pReasonSize)\r
+{\r
+ int reasonLen = m_pInStream->readU16();\r
+ int _reasonLen = reasonLen + 1;\r
+ char *pReason;\r
+ if (reasonLen == 0) {\r
+ *pReasonSize = 0;\r
+ return NULL;\r
+ } else {\r
+ pReason = new char [_reasonLen];\r
+ if (pReason == NULL) {\r
+ m_pInStream->skip(reasonLen);\r
+ *pReasonSize = 0;\r
+ return NULL;\r
+ }\r
+ m_pInStream->readBytes(pReason, reasonLen);\r
+ memset(((char *)pReason+reasonLen), '\0', 1);\r
+ return pReason;\r
+ }\r
+}\r
+\r
--- /dev/null
+/* Copyright (C) 2005 TightVNC Team. All Rights Reserved.\r
+ *\r
+ * Developed by Dennis Syrovatsky.\r
+ * \r
+ * This is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * This software is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this software; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\r
+ * USA.\r
+ *\r
+ * TightVNC distribution homepage on the Web: http://www.tightvnc.com/\r
+ *\r
+ */\r
+\r
+// -=- CFTMsgReader.h\r
+\r
+#ifndef __RFB_CFTMSGREADER_H__\r
+#define __RFB_CFTMSGREADER_H__\r
+\r
+#include <rdr/InStream.h>\r
+#include <rfb/FileInfo.h>\r
+\r
+namespace rfb {\r
+ class CFTMsgReader\r
+ {\r
+ public:\r
+ CFTMsgReader(rdr::InStream *pIS);\r
+ ~CFTMsgReader();\r
+ \r
+ int readFileListData(FileInfo *pFileInfo);\r
+ int readFileDirSizeData(unsigned short *pDirSizeLow16, unsigned int *pDirSizeHigh32);\r
+ \r
+ char *readFileUploadCancel(unsigned int *pReasonSize);\r
+ char *readFileDownloadFailed(unsigned int *pReasonSize);\r
+ char *readFileLastRqstFailed(int *pTypeOfRequest, unsigned int *pReasonSize);\r
+ void *readFileDownloadData(unsigned int *pSize, unsigned int *pModTime);\r
+ \r
+ private:\r
+ rdr::InStream *m_pInStream;\r
+ \r
+ bool createFileInfo(unsigned int numFiles, FileInfo *fi, \r
+ SIZEDATAINFO *pSDInfo, char *pFilenames);\r
+ char *readReasonMsg(unsigned int *pReasonSize);\r
+ };\r
+}\r
+\r
+#endif // __RFB_CFTMSGREADER_H__\r
--- /dev/null
+/* Copyright (C) 2005 TightVNC Team. All Rights Reserved.\r
+ *\r
+ * Developed by Dennis Syrovatsky.\r
+ * \r
+ * This is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * This software is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this software; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\r
+ * USA.\r
+ *\r
+ * TightVNC distribution homepage on the Web: http://www.tightvnc.com/\r
+ *\r
+ */\r
+\r
+// -=- CFTMsgWriter.cxx\r
+\r
+#include <rfb/CFTMsgWriter.h>\r
+\r
+using namespace rfb;\r
+\r
+CFTMsgWriter::CFTMsgWriter(rdr::OutStream *pOS)\r
+{\r
+ m_pOutStream = pOS;\r
+}\r
+\r
+CFTMsgWriter::~CFTMsgWriter()\r
+{\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileListRqst(unsigned short dirnameLen, char *pDirName, \r
+ bool bDirOnly)\r
+{\r
+ if (dirnameLen >= FT_FILENAME_SIZE) return false;\r
+\r
+ unsigned char flags = 0;\r
+ if (bDirOnly) flags = 0x10;\r
+\r
+ m_pOutStream->writeU8(msgTypeFileListRequest);\r
+ m_pOutStream->writeU8(flags);\r
+ m_pOutStream->writeU16(dirnameLen);\r
+ m_pOutStream->writeBytes((void *)pDirName, dirnameLen);\r
+ m_pOutStream->flush();\r
+\r
+ return true;\r
+}\r
+\r
+\r
+bool \r
+CFTMsgWriter::writeFileDownloadCancel(unsigned short reasonLen, char *pReason)\r
+{\r
+ m_pOutStream->writeU8(msgTypeFileDownloadCancel);\r
+ return writeU8U16StringMsg(reasonLen, pReason);\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileDownloadRqst(unsigned short filenameLen, char *pFilename, \r
+ unsigned int position)\r
+{\r
+ if (filenameLen >= FT_FILENAME_SIZE) return false;\r
+\r
+ m_pOutStream->writeU8(msgTypeFileDownloadRequest);\r
+ m_pOutStream->writeU8(0);\r
+ m_pOutStream->writeU16(filenameLen);\r
+ m_pOutStream->writeU32(position);\r
+ m_pOutStream->writeBytes(pFilename, filenameLen);\r
+ m_pOutStream->flush();\r
+\r
+ return true;\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileUploadData(unsigned short dataSize, char *pData)\r
+{\r
+ m_pOutStream->writeU8(msgTypeFileUploadData);\r
+ m_pOutStream->writeU8(0);\r
+ m_pOutStream->writeU16(dataSize);\r
+ m_pOutStream->writeU16(dataSize);\r
+ m_pOutStream->writeBytes(pData, dataSize);\r
+ m_pOutStream->flush();\r
+\r
+ return true;\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileUploadData(unsigned int modTime)\r
+{\r
+ m_pOutStream->writeU8(msgTypeFileUploadData);\r
+ m_pOutStream->writeU8(0);\r
+ m_pOutStream->writeU16(0);\r
+ m_pOutStream->writeU16(0);\r
+ m_pOutStream->writeU32(modTime);\r
+ m_pOutStream->flush();\r
+\r
+ return true;\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileUploadFailed(unsigned short reasonLen, char *pReason)\r
+{\r
+ m_pOutStream->writeU8(msgTypeFileUploadFailed);\r
+ return writeU8U16StringMsg(reasonLen, pReason);\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileUploadRqst(unsigned short filenameLen, char *pFilename, \r
+ unsigned int position)\r
+{\r
+ if (filenameLen >= FT_FILENAME_SIZE) return false;\r
+\r
+ m_pOutStream->writeU8(msgTypeFileUploadRequest);\r
+ m_pOutStream->writeU8(0);\r
+ m_pOutStream->writeU16(filenameLen);\r
+ m_pOutStream->writeU32(position);\r
+ m_pOutStream->writeBytes((void *)pFilename, filenameLen);\r
+ m_pOutStream->flush();\r
+\r
+ return true;\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName)\r
+{\r
+ if (dirNameLen >= FT_FILENAME_SIZE) return false;\r
+\r
+ m_pOutStream->writeU8(msgTypeFileCreateDirRequest);\r
+ return writeU8U16StringMsg(dirNameLen, pDirName);\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName)\r
+{\r
+ if (dirNameLen >= FT_FILENAME_SIZE) return false;\r
+\r
+ m_pOutStream->writeU8(msgTypeFileDirSizeRequest);\r
+ return writeU8U16StringMsg(dirNameLen, pDirName);\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen,\r
+ char *pOldName, char *pNewName)\r
+{\r
+ if ((oldNameLen >= FT_FILENAME_SIZE) || (newNameLen >= FT_FILENAME_SIZE)) return false;\r
+\r
+ m_pOutStream->writeU8(msgTypeFileRenameRequest);\r
+ m_pOutStream->writeU8(0);\r
+ m_pOutStream->writeU16(oldNameLen);\r
+ m_pOutStream->writeU16(newNameLen);\r
+ m_pOutStream->writeBytes(pOldName, oldNameLen);\r
+ m_pOutStream->writeBytes(pNewName, newNameLen);\r
+ m_pOutStream->flush();\r
+ \r
+ return true;\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeFileDeleteRqst(unsigned short nameLen, char *pName)\r
+{\r
+ if (nameLen >= FT_FILENAME_SIZE) return false;\r
+\r
+ m_pOutStream->writeU8(msgTypeFileDeleteRequest);\r
+ return writeU8U16StringMsg(nameLen, pName);\r
+}\r
+\r
+bool \r
+CFTMsgWriter::writeU8U16StringMsg(unsigned short strLength, char *pString)\r
+{\r
+ m_pOutStream->writeU8(0);\r
+ m_pOutStream->writeU16(strLength);\r
+ m_pOutStream->writeBytes(pString, strLength);\r
+ m_pOutStream->flush();\r
+ return true;\r
+}\r
--- /dev/null
+/* Copyright (C) 2005 TightVNC Team. All Rights Reserved.\r
+ *\r
+ * Developed by Dennis Syrovatsky.\r
+ * \r
+ * This is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ * \r
+ * This software is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this software; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,\r
+ * USA.\r
+ *\r
+ * TightVNC distribution homepage on the Web: http://www.tightvnc.com/\r
+ *\r
+ */\r
+\r
+// -=- CFTMsgWriter.h\r
+\r
+#ifndef __RFB_CFTMSGWRITER_H__\r
+#define __RFB_CFTMSGWRITER_H__\r
+\r
+#include <rdr/types.h>\r
+#include <rdr/OutStream.h>\r
+#include <rfb/msgTypes.h>\r
+#include <rfb/fttypes.h>\r
+\r
+namespace rfb {\r
+ class CFTMsgWriter\r
+ {\r
+ public:\r
+ CFTMsgWriter(rdr::OutStream *pOS);\r
+ ~CFTMsgWriter();\r
+ \r
+ bool writeFileListRqst(unsigned short dirnameLen, char *pDirName, bool bDirOnly);\r
+ \r
+ bool writeFileDownloadCancel(unsigned short reasonLen, char *pReason);\r
+ bool writeFileDownloadRqst(unsigned short filenameLen, char *pFilename, \r
+ unsigned int position);\r
+ \r
+ bool writeFileUploadData(unsigned short dataSize, char *pData);\r
+ bool writeFileUploadData(unsigned int modTime);\r
+ bool writeFileUploadFailed(unsigned short reasonLen, char *pReason);\r
+ bool writeFileUploadRqst(unsigned short filenameLen, char *pFilename, \r
+ unsigned int position);\r
+ \r
+ bool writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName);\r
+ bool writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName);\r
+ \r
+ bool writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen,\r
+ char *pOldName, char *pNewName);\r
+ bool writeFileDeleteRqst(unsigned short nameLen, char *pName);\r
+ \r
+ private:\r
+ rdr::OutStream *m_pOutStream;\r
+ \r
+ bool writeU8U16StringMsg(unsigned short strLength, char *pString);\r
+ };\r
+}\r
+\r
+#endif // __RFB_CFTMSGWRITER_H__\r
/* 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
/* 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
/* 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
/* 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
/* 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
/* 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
/* 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
/* 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
/* 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
return readU8U16StringMsg(pNameSize, pName);
}
-bool readFileRenameRqst(unsigned int *pOldNameSize, unsigned int *pNewNameSize,
- char *pOldName, char *pNewName)
+bool
+SFTMsgReader::readFileRenameRqst(unsigned int *pOldNameSize,
+ unsigned int *pNewNameSize,
+ char *pOldName, char *pNewName)
{
- return false;
+ 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
unsigned int len = strlen(pName);
memcpy((void *)&pFilenames[pos], pName, len + 1);
- pos += len + 2;
+ pos += (len + 1);
- m_pOS->writeU32(pFileInfo->getSizeAt(i));
+ 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));
}
/* 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
/* 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
#define FT_MAX_SENDING_SIZE 8192
+#define FT_NET_ATTR_DIR ((unsigned int)-1)
+
#define FT_ATTR_UNKNOWN 0x00000000
#define FT_ATTR_FILE 0x00000001
#define FT_ATTR_DIR 0x00000002
# 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=.\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
/* Copyright (C) 2005 TightVNC Team. All Rights Reserved.
*
- * Developed by Dennis Syrovatsky
+ * 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
/* 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
/* 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
TVITEM tvi;
TVINSERTSTRUCT tvins;
- while (TreeView_GetChild(m_hwndTree, m_hParentItem) != NULL) {
- TreeView_DeleteItem(m_hwndTree, TreeView_GetChild(m_hwndTree, m_hParentItem));
- }
+ if (pFI->getNumEntries() <= 0) return;
for (unsigned int i = 0; i < pFI->getNumEntries(); i++)
{
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)
{
case TVN_SELCHANGED:
SetDlgItemText(hwnd, IDC_FTBROWSEPATH, _this->getTVPath(((NMTREEVIEW *) lParam)->itemNew.hItem));
return FALSE;
- case TVN_ITEMEXPANDING:
+// 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));
}
}
/* 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
void addItems(FileInfo *pFI);
char *getPath();
+ void deleteChildItems();
+
private:
HWND m_hwndDlg;
HWND m_hwndTree;
/* 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
showRemoteLVItems();
}
}
-
delete m_pBrowseDlg;
m_pBrowseDlg = NULL;
}
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;
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;
/* 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
/* 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/
-*
-*/
+ *
+ * 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/
+ *
+ */
// -=- FTListView.cxx
/* 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
void
FTProgress::setProgressText()
{
- char buf[16];
-
- int percent = m_pSingleProgress->getCurrentPercent();
- sprintf(buf, "%d%%", percent);
- SetWindowText(m_hwndSinglePercent, buf);
-
- percent = m_pGeneralProgress->getCurrentPercent();
- sprintf(buf, "%d%%", percent);
- SetWindowText(m_hwndGeneralPercent, buf);
+ 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);
}
\ No newline at end of file
/* 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
/* 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
m_bInitialized = false;
m_bResized = false;
m_bCancel = false;
+ m_bOverwriteAll = false;
m_pFTDialog = new FTDialog(GetModuleHandle(0), this);
{
if (m_bInitialized) return false;
- m_pReader = new FTMsgReader(pIS);
- m_pWriter = new FTMsgWriter(pOS);
+ m_pReader = new CFTMsgReader(pIS);
+ m_pWriter = new CFTMsgWriter(pOS);
freeQueues();
m_pFTDialog->postCheckDeleteQueueMsg();
} else {
if (m_DeleteQueue.getFlagsAt(0) & FT_ATTR_DELETE_REMOTE) {
- m_pWriter->writeFileDeleteRqst(strlen(m_DeleteQueue.getFullLocPathAt(0)),
- m_DeleteQueue.getFullLocPathAt(0));
+ 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);
- m_pWriter->writeFileListRqst(strlen(pPath), pPath, false);
+ writeFileListRqst(strlen(pPath), pPath, false);
}
}
} else {
m_bResized = true;
char *pPath = m_TransferQueue.getFullRemPathAt(i);
m_dirSizeRqstNum = i;
- m_pWriter->writeFileDirSizeRqst(strlen(pPath), pPath);
+ writeFileDirSizeRqst(strlen(pPath), pPath);
return false;
} else {
if (flags & FT_ATTR_COPY_UPLOAD) {
if (flag0 & FT_ATTR_DIR) {
char *pFullPath = m_TransferQueue.getFullRemPathAt(0);
if (m_bFTDlgShown) m_pFTDialog->setStatusText("Creating Remote Folder. %s", pFullPath);
- m_pWriter->writeFileCreateDirRqst(strlen(pFullPath), 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);
- m_pWriter->writeFileListRqst(strlen(pPath), pPath, false);
+ writeFileListRqst(strlen(pPath), pPath, false);
return;
}
} else {
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);
- m_pWriter->writeFileListRqst(strlen(pRemPath), pRemPath, 0);
+ writeFileListRqst(strlen(pRemPath), pRemPath, 0);
return;
}
}
m_pFTDialog->m_pProgress->clearAndInitSingle(m_TransferQueue.getSizeAt(0), 0);
}
- m_pWriter->writeFileUploadRqst(strlen(m_TransferQueue.getFullRemPathAt(0)),
- m_TransferQueue.getFullRemPathAt(0), 0);
+ writeFileUploadRqst(strlen(m_TransferQueue.getFullRemPathAt(0)),
+ m_TransferQueue.getFullRemPathAt(0), 0);
uploadFilePortion();
}
}
m_TransferQueue.getFullLocPathAt(0));
m_pFTDialog->m_pProgress->clearAndInitSingle(m_TransferQueue.getSizeAt(0), 0);
}
- m_pWriter->writeFileDownloadRqst(strlen(m_TransferQueue.getFullRemPathAt(0)),
- m_TransferQueue.getFullRemPathAt(0), 0);
+ writeFileDownloadRqst(strlen(m_TransferQueue.getFullRemPathAt(0)),
+ m_TransferQueue.getFullRemPathAt(0), 0);
return true;
} else return false;
}
char fullPath[FT_FILENAME_SIZE];
sprintf(fullPath, "%s\\%s", pPath, pName);
m_pFTDialog->setStatusText("Creating Remote Folder: %s", fullPath);
- m_pWriter->writeFileCreateDirRqst(strlen(fullPath), fullPath);
+ writeFileCreateDirRqst(strlen(fullPath), fullPath);
m_queueFileListRqst.add(pPath, 0, 0, FT_FLR_DEST_MAIN);
- m_pWriter->writeFileListRqst(strlen(pPath), pPath, false);
+ writeFileListRqst(strlen(pPath), pPath, false);
}
void
sprintf(fullOldName, "%s\\%s", pPath, pOldName);
sprintf(fullNewName, "%s\\%s", pPath, pNewName);
- m_pWriter->writeFileRenameRqst(strlen(fullOldName), strlen(fullNewName),
- fullOldName, fullNewName);
+ writeFileRenameRqst(strlen(fullOldName), strlen(fullNewName),
+ fullOldName, fullNewName);
m_queueFileListRqst.add(pPath, 0, 0, FT_FLR_DEST_MAIN);
- m_pWriter->writeFileListRqst(strlen(pPath), pPath, false);
+ writeFileListRqst(strlen(pPath), pPath, false);
}
bool
FileTransfer::procFileDirSizeDataMsg()
{
DWORD64 dw64DirSize = 0;
- m_pReader->readFileDirSizeData(&dw64DirSize);
+ 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();
{
m_queueFileListRqst.add(pPath, 0, 0, dest);
- m_pWriter->writeFileListRqst(strlen(pPath), pPath, bDirOnly);
+ writeFileListRqst(strlen(pPath), pPath, bDirOnly);
}
int
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);
+}
/* 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
#include <rfb/FileReader.h>
#include <rfb/FileWriter.h>
#include <rfb/TransferQueue.h>
+#include <rfb/CFTMsgReader.h>
+#include <rfb/CFTMsgWriter.h>
#include <vncviewer/FTDialog.h>
-#include <vncviewer/FTMsgReader.h>
-#include <vncviewer/FTMsgWriter.h>
namespace rfb {
namespace win32 {
bool m_bInitialized;
bool m_bResized;
bool m_bTransferSuccess;
+ bool m_bOverwriteAll;
FTDialog *m_pFTDialog;
- FTMsgReader *m_pReader;
- FTMsgWriter *m_pWriter;
+ rfb::CFTMsgReader *m_pReader;
+ rfb::CFTMsgWriter *m_pWriter;
FileReader m_fileReader;
FileWriter m_fileWriter;
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;
};
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\FTMsgReader.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTMsgWriter.cxx\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\FTProgress.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\FTMsgReader.h\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\FTMsgWriter.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\FTProgress.h\r
# End Source File\r
# Begin Source File\r