Merged the changes from branch/merge-with-vnc-4.1.1, revisions 520:558.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@559 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/FTMsgReader.cxx b/rfb/CFTMsgReader.cxx
similarity index 76%
rename from vncviewer/FTMsgReader.cxx
rename to rfb/CFTMsgReader.cxx
index d2d118b..66adbf5 100644
--- a/vncviewer/FTMsgReader.cxx
+++ b/rfb/CFTMsgReader.cxx
@@ -1,164 +1,162 @@
-/* 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 <vncviewer/FTMsgReader.h>
-
-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;
- }
-}
-
+/* 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 <rfb/CFTMsgReader.h>
+
+using namespace rfb;
+
+CFTMsgReader::CFTMsgReader(rdr::InStream *pIS)
+{
+ m_pInStream = pIS;
+}
+
+CFTMsgReader::~CFTMsgReader()
+{
+
+}
+
+int
+CFTMsgReader::readFileListData(FileInfo *pFileInfo)
+{
+ unsigned char flags = m_pInStream->readU8();
+ int numFiles = m_pInStream->readU16();
+ int dataSize = m_pInStream->readU16();
+ int compressedSize = m_pInStream->readU16();
+
+ if (flags & 0x80) {
+ return -1;
+ } else {
+ if (numFiles > 0) {
+ char *pFilenames = new char[compressedSize];
+ SIZEDATAINFO *pSDI = new SIZEDATAINFO[numFiles];
+ for (int i = 0; i < numFiles; i++) {
+ pSDI[i].size = m_pInStream->readU32();
+ pSDI[i].data = m_pInStream->readU32();
+ }
+ m_pInStream->readBytes((void *)pFilenames, compressedSize);
+ createFileInfo(numFiles, pFileInfo, pSDI, pFilenames);
+ delete [] pSDI;
+ delete [] pFilenames;
+ }
+ }
+ return numFiles;
+}
+
+void *
+CFTMsgReader::readFileDownloadData(unsigned int *pSize, unsigned int *pModTime)
+{
+ unsigned char compressLevel = m_pInStream->readU8();
+ int realSize = m_pInStream->readU16();
+ int compressedSize = m_pInStream->readU16();
+
+ if ((realSize == 0) && (compressedSize == 0)) {
+ *pSize = 0;
+ *pModTime = m_pInStream->readU32();
+ return NULL;
+ } else {
+ char *pFile = new char [compressedSize];
+ if (pFile == NULL) {
+ m_pInStream->skip(compressedSize);
+ *pModTime = 0;
+ return NULL;
+ } else {
+ m_pInStream->readBytes(pFile, compressedSize);
+ *pSize = compressedSize;
+ return pFile;
+ }
+ }
+}
+
+char *
+CFTMsgReader::readFileUploadCancel(unsigned int *pReasonSize)
+{
+ m_pInStream->skip(1);
+ return readReasonMsg(pReasonSize);
+}
+
+char *
+CFTMsgReader::readFileDownloadFailed(unsigned int *pReasonSize)
+{
+ m_pInStream->skip(1);
+ return readReasonMsg(pReasonSize);
+}
+
+int
+CFTMsgReader::readFileDirSizeData(unsigned short *pDirSizeLow16,
+ unsigned int *pDirSizeHigh32)
+{
+ m_pInStream->skip(1);
+ *pDirSizeLow16 = m_pInStream->readU16();
+ *pDirSizeHigh32 = m_pInStream->readU32();
+ return 1;
+}
+
+char *
+CFTMsgReader::readFileLastRqstFailed(int *pTypeOfRequest, unsigned int *pReasonSize)
+{
+ *pTypeOfRequest = m_pInStream->readU8();
+ return readReasonMsg(pReasonSize);
+}
+
+bool
+CFTMsgReader::createFileInfo(unsigned int numFiles, FileInfo *fi,
+ SIZEDATAINFO *pSDInfo, char *pFilenames)
+{
+ int pos = 0;
+ int size = 0;
+ for (unsigned int i = 0; i < numFiles; i++) {
+ size = pSDInfo[i].size;
+ if (size == FT_NET_ATTR_DIR) {
+ fi->add((pFilenames + pos), size, pSDInfo[i].data, FT_ATTR_DIR);
+ } else {
+ fi->add((pFilenames + pos), size, pSDInfo[i].data, FT_ATTR_FILE);
+ }
+ pos += strlen(pFilenames + pos) + 1;
+ }
+ return true;
+}
+
+char *
+CFTMsgReader::readReasonMsg(unsigned int *pReasonSize)
+{
+ int reasonLen = m_pInStream->readU16();
+ int _reasonLen = reasonLen + 1;
+ char *pReason;
+ if (reasonLen == 0) {
+ *pReasonSize = 0;
+ return NULL;
+ } else {
+ pReason = new char [_reasonLen];
+ if (pReason == NULL) {
+ m_pInStream->skip(reasonLen);
+ *pReasonSize = 0;
+ return NULL;
+ }
+ m_pInStream->readBytes(pReason, reasonLen);
+ memset(((char *)pReason+reasonLen), '\0', 1);
+ return pReason;
+ }
+}
+
diff --git a/rfb/CFTMsgReader.h b/rfb/CFTMsgReader.h
new file mode 100644
index 0000000..b0e2c7a
--- /dev/null
+++ b/rfb/CFTMsgReader.h
@@ -0,0 +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 <rdr/InStream.h>
+#include <rfb/FileInfo.h>
+
+namespace rfb {
+ class CFTMsgReader
+ {
+ public:
+ CFTMsgReader(rdr::InStream *pIS);
+ ~CFTMsgReader();
+
+ int readFileListData(FileInfo *pFileInfo);
+ int readFileDirSizeData(unsigned short *pDirSizeLow16, unsigned int *pDirSizeHigh32);
+
+ char *readFileUploadCancel(unsigned int *pReasonSize);
+ char *readFileDownloadFailed(unsigned int *pReasonSize);
+ char *readFileLastRqstFailed(int *pTypeOfRequest, unsigned int *pReasonSize);
+ void *readFileDownloadData(unsigned int *pSize, unsigned int *pModTime);
+
+ private:
+ rdr::InStream *m_pInStream;
+
+ bool createFileInfo(unsigned int numFiles, FileInfo *fi,
+ SIZEDATAINFO *pSDInfo, char *pFilenames);
+ char *readReasonMsg(unsigned int *pReasonSize);
+ };
+}
+
+#endif // __RFB_CFTMSGREADER_H__
diff --git a/rfb/CFTMsgWriter.cxx b/rfb/CFTMsgWriter.cxx
new file mode 100644
index 0000000..278cf80
--- /dev/null
+++ b/rfb/CFTMsgWriter.cxx
@@ -0,0 +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 <rfb/CFTMsgWriter.h>
+
+using namespace rfb;
+
+CFTMsgWriter::CFTMsgWriter(rdr::OutStream *pOS)
+{
+ m_pOutStream = pOS;
+}
+
+CFTMsgWriter::~CFTMsgWriter()
+{
+}
+
+bool
+CFTMsgWriter::writeFileListRqst(unsigned short dirnameLen, char *pDirName,
+ bool bDirOnly)
+{
+ if (dirnameLen >= FT_FILENAME_SIZE) return false;
+
+ unsigned char flags = 0;
+ if (bDirOnly) flags = 0x10;
+
+ m_pOutStream->writeU8(msgTypeFileListRequest);
+ m_pOutStream->writeU8(flags);
+ m_pOutStream->writeU16(dirnameLen);
+ m_pOutStream->writeBytes((void *)pDirName, dirnameLen);
+ m_pOutStream->flush();
+
+ return true;
+}
+
+
+bool
+CFTMsgWriter::writeFileDownloadCancel(unsigned short reasonLen, char *pReason)
+{
+ m_pOutStream->writeU8(msgTypeFileDownloadCancel);
+ return writeU8U16StringMsg(reasonLen, pReason);
+}
+
+bool
+CFTMsgWriter::writeFileDownloadRqst(unsigned short filenameLen, char *pFilename,
+ unsigned int position)
+{
+ if (filenameLen >= FT_FILENAME_SIZE) return false;
+
+ m_pOutStream->writeU8(msgTypeFileDownloadRequest);
+ m_pOutStream->writeU8(0);
+ m_pOutStream->writeU16(filenameLen);
+ m_pOutStream->writeU32(position);
+ m_pOutStream->writeBytes(pFilename, filenameLen);
+ m_pOutStream->flush();
+
+ return true;
+}
+
+bool
+CFTMsgWriter::writeFileUploadData(unsigned short dataSize, char *pData)
+{
+ m_pOutStream->writeU8(msgTypeFileUploadData);
+ m_pOutStream->writeU8(0);
+ m_pOutStream->writeU16(dataSize);
+ m_pOutStream->writeU16(dataSize);
+ m_pOutStream->writeBytes(pData, dataSize);
+ m_pOutStream->flush();
+
+ return true;
+}
+
+bool
+CFTMsgWriter::writeFileUploadData(unsigned int modTime)
+{
+ m_pOutStream->writeU8(msgTypeFileUploadData);
+ m_pOutStream->writeU8(0);
+ m_pOutStream->writeU16(0);
+ m_pOutStream->writeU16(0);
+ m_pOutStream->writeU32(modTime);
+ m_pOutStream->flush();
+
+ return true;
+}
+
+bool
+CFTMsgWriter::writeFileUploadFailed(unsigned short reasonLen, char *pReason)
+{
+ m_pOutStream->writeU8(msgTypeFileUploadFailed);
+ return writeU8U16StringMsg(reasonLen, pReason);
+}
+
+bool
+CFTMsgWriter::writeFileUploadRqst(unsigned short filenameLen, char *pFilename,
+ unsigned int position)
+{
+ if (filenameLen >= FT_FILENAME_SIZE) return false;
+
+ m_pOutStream->writeU8(msgTypeFileUploadRequest);
+ m_pOutStream->writeU8(0);
+ m_pOutStream->writeU16(filenameLen);
+ m_pOutStream->writeU32(position);
+ m_pOutStream->writeBytes((void *)pFilename, filenameLen);
+ m_pOutStream->flush();
+
+ return true;
+}
+
+bool
+CFTMsgWriter::writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName)
+{
+ if (dirNameLen >= FT_FILENAME_SIZE) return false;
+
+ m_pOutStream->writeU8(msgTypeFileCreateDirRequest);
+ return writeU8U16StringMsg(dirNameLen, pDirName);
+}
+
+bool
+CFTMsgWriter::writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName)
+{
+ if (dirNameLen >= FT_FILENAME_SIZE) return false;
+
+ m_pOutStream->writeU8(msgTypeFileDirSizeRequest);
+ return writeU8U16StringMsg(dirNameLen, pDirName);
+}
+
+bool
+CFTMsgWriter::writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen,
+ char *pOldName, char *pNewName)
+{
+ if ((oldNameLen >= FT_FILENAME_SIZE) || (newNameLen >= FT_FILENAME_SIZE)) return false;
+
+ m_pOutStream->writeU8(msgTypeFileRenameRequest);
+ m_pOutStream->writeU8(0);
+ m_pOutStream->writeU16(oldNameLen);
+ m_pOutStream->writeU16(newNameLen);
+ m_pOutStream->writeBytes(pOldName, oldNameLen);
+ m_pOutStream->writeBytes(pNewName, newNameLen);
+ m_pOutStream->flush();
+
+ return true;
+}
+
+bool
+CFTMsgWriter::writeFileDeleteRqst(unsigned short nameLen, char *pName)
+{
+ if (nameLen >= FT_FILENAME_SIZE) return false;
+
+ m_pOutStream->writeU8(msgTypeFileDeleteRequest);
+ return writeU8U16StringMsg(nameLen, pName);
+}
+
+bool
+CFTMsgWriter::writeU8U16StringMsg(unsigned short strLength, char *pString)
+{
+ m_pOutStream->writeU8(0);
+ m_pOutStream->writeU16(strLength);
+ m_pOutStream->writeBytes(pString, strLength);
+ m_pOutStream->flush();
+ return true;
+}
diff --git a/rfb/CFTMsgWriter.h b/rfb/CFTMsgWriter.h
new file mode 100644
index 0000000..c49c2aa
--- /dev/null
+++ b/rfb/CFTMsgWriter.h
@@ -0,0 +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 <rdr/types.h>
+#include <rdr/OutStream.h>
+#include <rfb/msgTypes.h>
+#include <rfb/fttypes.h>
+
+namespace rfb {
+ class CFTMsgWriter
+ {
+ public:
+ CFTMsgWriter(rdr::OutStream *pOS);
+ ~CFTMsgWriter();
+
+ bool writeFileListRqst(unsigned short dirnameLen, char *pDirName, bool bDirOnly);
+
+ bool writeFileDownloadCancel(unsigned short reasonLen, char *pReason);
+ bool writeFileDownloadRqst(unsigned short filenameLen, char *pFilename,
+ unsigned int position);
+
+ bool writeFileUploadData(unsigned short dataSize, char *pData);
+ bool writeFileUploadData(unsigned int modTime);
+ bool writeFileUploadFailed(unsigned short reasonLen, char *pReason);
+ bool writeFileUploadRqst(unsigned short filenameLen, char *pFilename,
+ unsigned int position);
+
+ bool writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName);
+ bool writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName);
+
+ bool writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen,
+ char *pOldName, char *pNewName);
+ bool writeFileDeleteRqst(unsigned short nameLen, char *pName);
+
+ private:
+ rdr::OutStream *m_pOutStream;
+
+ bool writeU8U16StringMsg(unsigned short strLength, char *pString);
+ };
+}
+
+#endif // __RFB_CFTMSGWRITER_H__
diff --git a/rfb/DirManager.h b/rfb/DirManager.h
index d59ffde..c820f64 100644
--- a/rfb/DirManager.h
+++ b/rfb/DirManager.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/FileInfo.cxx b/rfb/FileInfo.cxx
index 34074f7..e97e0ad 100644
--- a/rfb/FileInfo.cxx
+++ b/rfb/FileInfo.cxx
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/FileInfo.h b/rfb/FileInfo.h
index 4dccc95..270eeee 100644
--- a/rfb/FileInfo.h
+++ b/rfb/FileInfo.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/FileManager.cxx b/rfb/FileManager.cxx
index c0403a7..74cbd45 100644
--- a/rfb/FileManager.cxx
+++ b/rfb/FileManager.cxx
@@ -1,4 +1,6 @@
/* 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
@@ -71,3 +73,9 @@
{
if (m_pFile != NULL) return true; else return false;
}
+
+char *
+FileManager::getFilename()
+{
+ return m_szFilename;
+}
diff --git a/rfb/FileManager.h b/rfb/FileManager.h
index a673f4d..4fd736f 100644
--- a/rfb/FileManager.h
+++ b/rfb/FileManager.h
@@ -1,4 +1,6 @@
/* 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
@@ -37,6 +39,8 @@
bool isCreated();
+ char *getFilename();
+
protected:
FILE *m_pFile;
char m_szMode[4];
diff --git a/rfb/FileReader.cxx b/rfb/FileReader.cxx
index 063b742..a8cd272 100644
--- a/rfb/FileReader.cxx
+++ b/rfb/FileReader.cxx
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/FileReader.h b/rfb/FileReader.h
index 12cdfa1..0c985d8 100644
--- a/rfb/FileReader.h
+++ b/rfb/FileReader.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/FileWriter.cxx b/rfb/FileWriter.cxx
index 9c06c37..2bed576 100644
--- a/rfb/FileWriter.cxx
+++ b/rfb/FileWriter.cxx
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/FileWriter.h b/rfb/FileWriter.h
index e522ae1..73094a7 100644
--- a/rfb/FileWriter.h
+++ b/rfb/FileWriter.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/SFTMsgReader.cxx b/rfb/SFTMsgReader.cxx
index 3d9aeb2..b88467b 100644
--- a/rfb/SFTMsgReader.cxx
+++ b/rfb/SFTMsgReader.cxx
@@ -1,4 +1,6 @@
/* 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
@@ -106,10 +108,40 @@
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
diff --git a/rfb/SFTMsgReader.h b/rfb/SFTMsgReader.h
index 8eaf429..dff06a4 100644
--- a/rfb/SFTMsgReader.h
+++ b/rfb/SFTMsgReader.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/SFTMsgWriter.cxx b/rfb/SFTMsgWriter.cxx
index 4edfc46..fa6a82f 100644
--- a/rfb/SFTMsgWriter.cxx
+++ b/rfb/SFTMsgWriter.cxx
@@ -1,4 +1,6 @@
/* 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
@@ -60,9 +62,13 @@
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));
}
diff --git a/rfb/SFTMsgWriter.h b/rfb/SFTMsgWriter.h
index dcf2e2d..f6bea9f 100644
--- a/rfb/SFTMsgWriter.h
+++ b/rfb/SFTMsgWriter.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/SFileTransfer.cxx b/rfb/SFileTransfer.cxx
new file mode 100644
index 0000000..e947a74
--- /dev/null
+++ b/rfb/SFileTransfer.cxx
@@ -0,0 +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 <rfb/msgTypes.h>
+#include <rfb/SFileTransfer.h>
+
+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
new file mode 100644
index 0000000..9328ead
--- /dev/null
+++ b/rfb/SFileTransfer.h
@@ -0,0 +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 <network/Socket.h>
+#include <rfb/SFTMsgReader.h>
+#include <rfb/SFTMsgWriter.h>
+#include <rfb/FileWriter.h>
+#include <rfb/FileReader.h>
+#include <rfb/FileInfo.h>
+#include <rfb/fttypes.h>
+
+namespace rfb {
+ class SFileTransfer
+ {
+ public:
+ SFileTransfer(network::Socket *sock);
+ ~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
new file mode 100644
index 0000000..c13e0c1
--- /dev/null
+++ b/rfb/SFileTransferManager.cxx
@@ -0,0 +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 <rfb/SFileTransferManager.h>
+
+using namespace rfb;
+
+SFileTransferManager::SFileTransferManager()
+{
+
+}
+
+SFileTransferManager::~SFileTransferManager()
+{
+ destroy();
+}
+
+void
+SFileTransferManager::destroyObject(SFileTransfer *pFT)
+{
+ if (pFT == NULL) return;
+
+ m_lstFTObjects.remove(pFT);
+
+ delete pFT;
+}
+
+void
+SFileTransferManager::destroy()
+{
+ while(!m_lstFTObjects.empty())
+ delete m_lstFTObjects.front();
+}
\ No newline at end of file
diff --git a/rfb/SFileTransferManager.h b/rfb/SFileTransferManager.h
new file mode 100644
index 0000000..107d144
--- /dev/null
+++ b/rfb/SFileTransferManager.h
@@ -0,0 +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 <list>
+
+#include <rfb/SFileTransfer.h>
+#include <network/Socket.h>
+
+namespace rfb {
+ class SFileTransferManager
+ {
+ public:
+ SFileTransferManager();
+ ~SFileTransferManager();
+
+ virtual SFileTransfer *createObject(network::Socket *sock) = 0;
+ void destroyObject(SFileTransfer *pFT);
+
+ protected:
+ std::list<SFileTransfer*> m_lstFTObjects;
+
+ void destroy();
+ };
+}
+
+#endif // __RFB_SFILETRANSFERMANAGER_H__
diff --git a/rfb/TransferQueue.cxx b/rfb/TransferQueue.cxx
index 58b9273..0180752 100644
--- a/rfb/TransferQueue.cxx
+++ b/rfb/TransferQueue.cxx
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/TransferQueue.h b/rfb/TransferQueue.h
index 02a043d..ba748e0 100644
--- a/rfb/TransferQueue.h
+++ b/rfb/TransferQueue.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb/VNCSConnectionST.cxx b/rfb/VNCSConnectionST.cxx
index 37fb744..fe60e43 100644
--- a/rfb/VNCSConnectionST.cxx
+++ b/rfb/VNCSConnectionST.cxx
@@ -36,7 +36,7 @@
updates(false), image_getter(server->useEconomicTranslate),
drawRenderedCursor(false), removeRenderedCursor(false),
pointerEventTime(0), accessRights(AccessDefault),
- startTime(time(0))
+ startTime(time(0)), m_pFileTransfer(0)
{
setStreams(&sock->inStream(), &sock->outStream());
peerEndpoint.buf = sock->getPeerEndpoint();
@@ -47,6 +47,13 @@
lastEventTime = time(0);
// Add this client to the VNCServerST
+ if (server->m_pFTManager != NULL) {
+ SFileTransfer *pFT = server->m_pFTManager->createObject(sock);
+ if (pFT != NULL) {
+ m_pFileTransfer = pFT;
+ }
+ }
+
server->clients.push_front(this);
}
@@ -65,8 +72,12 @@
if (server->pointerClient == this)
server->pointerClient = 0;
+ if (m_pFileTransfer)
+ server->m_pFTManager->destroyObject(m_pFileTransfer);
+
// Remove this client from the server
server->clients.remove(this);
+
}
@@ -663,16 +674,13 @@
char* VNCSConnectionST::getStartTime()
{
- // FIXME: Using ctime() is not thread-safe.
- // Also, it's not good to return the pointer instead of copying.
char* result = ctime(&startTime);
result[24] = '\0';
- return result;
+ return result;
}
void VNCSConnectionST::setStatus(int status)
{
- // FIXME: What do numbers mean?
switch (status) {
case 0:
accessRights = accessRights | AccessPtrEvents | AccessKeyEvents | AccessView;
@@ -686,10 +694,8 @@
}
framebufferUpdateRequest(server->pb->getRect(), false);
}
-
int VNCSConnectionST::getStatus()
{
- // FIXME: What do numbers mean?
if ((accessRights & (AccessPtrEvents | AccessKeyEvents | AccessView)) == 0x0007)
return 0;
if ((accessRights & (AccessPtrEvents | AccessKeyEvents | AccessView)) == 0x0001)
@@ -701,5 +707,8 @@
bool VNCSConnectionST::processFTMsg(int type)
{
- return false;
+ if (m_pFileTransfer != NULL)
+ return m_pFileTransfer->processMessages(type);
+ else
+ return false;
}
diff --git a/rfb/VNCSConnectionST.h b/rfb/VNCSConnectionST.h
index a9a356c..a04296d 100644
--- a/rfb/VNCSConnectionST.h
+++ b/rfb/VNCSConnectionST.h
@@ -31,6 +31,7 @@
#include <rfb/SMsgWriter.h>
#include <rfb/TransImageGetter.h>
#include <rfb/VNCServerST.h>
+#include <rfb/SFileTransfer.h>
namespace rfb {
class VNCSConnectionST : public SConnection,
@@ -168,6 +169,8 @@
CharArray closeReason;
time_t startTime;
+
+ SFileTransfer *m_pFileTransfer;
};
}
#endif
diff --git a/rfb/VNCServerST.h b/rfb/VNCServerST.h
index 162fa9a..bc15b7f 100644
--- a/rfb/VNCServerST.h
+++ b/rfb/VNCServerST.h
@@ -33,6 +33,7 @@
#include <rfb/Cursor.h>
#include <network/Socket.h>
#include <rfb/ListConnInfo.h>
+#include <rfb/SFileTransferManager.h>
namespace rfb {
@@ -184,8 +185,10 @@
void getConnInfo(ListConnInfo * listConn);
void setConnStatus(ListConnInfo* listConn);
- bool getDisable() { return disableclients; }
- void setDisable(bool disable) { disableclients = disable; }
+ bool getDisable() { return disableclients;};
+ void setDisable(bool disable) { disableclients = disable;};
+
+ void setFTManager(rfb::SFileTransferManager *pFTManager) { m_pFTManager = pFTManager; };
protected:
@@ -201,6 +204,8 @@
bool desktopStarted;
PixelBuffer* pb;
+ SFileTransferManager *m_pFTManager;
+
CharArray name;
std::list<VNCSConnectionST*> clients;
diff --git a/rfb/fttypes.h b/rfb/fttypes.h
index 1e9f601..4404508 100644
--- a/rfb/fttypes.h
+++ b/rfb/fttypes.h
@@ -1,4 +1,6 @@
/* 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
@@ -32,6 +34,8 @@
#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
diff --git a/rfb/rfb.dsp b/rfb/rfb.dsp
index 7107258..561703f 100644
--- a/rfb/rfb.dsp
+++ b/rfb/rfb.dsp
@@ -118,6 +118,14 @@
# End Source File
# Begin Source File
+SOURCE=.\CFTMsgReader.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\CFTMsgWriter.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\CMsgHandler.cxx
# End Source File
# Begin Source File
@@ -270,6 +278,14 @@
# End Source File
# Begin Source File
+SOURCE=.\SFileTransfer.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\SFileTransferManager.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\SFTMsgReader.cxx
# End Source File
# Begin Source File
@@ -364,6 +380,14 @@
# End Source File
# Begin Source File
+SOURCE=.\CFTMsgReader.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\CFTMsgWriter.h
+# End Source File
+# Begin Source File
+
SOURCE=.\CMsgHandler.h
# End Source File
# Begin Source File
@@ -604,6 +628,14 @@
# End Source File
# Begin Source File
+SOURCE=.\SFileTransfer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SFileTransferManager.h
+# End Source File
+# Begin Source File
+
SOURCE=.\SFTMsgReader.h
# End Source File
# Begin Source File
diff --git a/rfb_win32/FolderManager.cxx b/rfb_win32/FolderManager.cxx
index 349e0f7..a2fa08d 100644
--- a/rfb_win32/FolderManager.cxx
+++ b/rfb_win32/FolderManager.cxx
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb_win32/FolderManager.h b/rfb_win32/FolderManager.h
index 97a6538..24923dd 100644
--- a/rfb_win32/FolderManager.h
+++ b/rfb_win32/FolderManager.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/rfb_win32/SFileTransferManagerWin32.cxx b/rfb_win32/SFileTransferManagerWin32.cxx
new file mode 100644
index 0000000..000b372
--- /dev/null
+++ b/rfb_win32/SFileTransferManagerWin32.cxx
@@ -0,0 +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 <rfb_win32/SFileTransferManagerWin32.h>
+
+using namespace rfb;
+using namespace win32;
+
+SFileTransferManagerWin32::SFileTransferManagerWin32()
+{
+
+}
+
+SFileTransferManagerWin32::~SFileTransferManagerWin32()
+{
+
+}
+
+SFileTransfer *
+SFileTransferManagerWin32::createObject(network::Socket *sock)
+{
+ rfb::SFileTransfer *pFT = 0;
+ rfb::win32::SFileTransferWin32 *pFTWin32 = 0;
+
+ pFTWin32 = new SFileTransferWin32(sock);
+ if (pFTWin32 == NULL) return NULL;
+
+ pFT = (SFileTransfer *) pFTWin32;
+
+ m_lstFTObjects.push_front(pFT);
+
+ return pFT;
+}
+
+void
+SFileTransferManagerWin32::processDownloadMsg(MSG msg)
+{
+ SFileTransfer *pFT = (SFileTransfer *)msg.lParam;
+
+ if (pFT != NULL) {
+ std::list<SFileTransfer*>::iterator i;
+ for (i=m_lstFTObjects.begin(); i!=m_lstFTObjects.end(); i++) {
+ if ((*i) == pFT) {
+ (*i)->sendFileDownloadPortion();
+ return;
+ }
+ }
+ }
+}
diff --git a/rfb_win32/SFileTransferManagerWin32.h b/rfb_win32/SFileTransferManagerWin32.h
new file mode 100644
index 0000000..6014f38
--- /dev/null
+++ b/rfb_win32/SFileTransferManagerWin32.h
@@ -0,0 +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 <rfb/SFileTransfer.h>
+#include <rfb/SFileTransferManager.h>
+#include <rfb_win32/SFileTransferWin32.h>
+
+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
new file mode 100644
index 0000000..5a33a43
--- /dev/null
+++ b/rfb_win32/SFileTransferWin32.cxx
@@ -0,0 +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 <rfb/msgTypes.h>
+#include <rfb_win32/FolderManager.h>
+#include <rfb_win32/SFileTransferWin32.h>
+
+using namespace rfb;
+using namespace rfb::win32;
+
+SFileTransferWin32::SFileTransferWin32(network::Socket *sock) : SFileTransfer(sock)
+{
+}
+
+SFileTransferWin32::~SFileTransferWin32()
+{
+}
+
+bool
+SFileTransferWin32::initDownloadCallback()
+{
+ PostThreadMessage(GetCurrentThreadId(), VNCM_FT_DOWNLOAD, (WPARAM) 0, (LPARAM) this);
+ return true;
+}
+
+bool
+SFileTransferWin32::processDownloadCallback()
+{
+ return sendFileDownloadPortion();
+}
+
+bool
+SFileTransferWin32::convertPathFromNet(char *pszPath)
+{
+ int len = strlen(pszPath);
+ if (pszPath[0] == '/') {
+ if (len == 1) {
+ pszPath[0] = '\0';
+ return true;
+ }
+ } else {
+ return false;
+ }
+
+ for(int i = 0; i < (len - 1); i++) {
+ if(pszPath[i+1] == '/') pszPath[i+1] = '\\';
+ pszPath[i] = pszPath[i+1];
+ }
+
+ pszPath[len-1] = '\0';
+ return true;
+}
+
+bool
+SFileTransferWin32::makeFileList(char *pszPath, FileInfo *pFI, bool bDirOnly)
+{
+ FolderManager fm;
+ if (fm.getDirInfo(pszPath, pFI, bDirOnly))
+ return true;
+ else
+ return false;
+}
+
+bool
+SFileTransferWin32::deleteIt(char *pszPath)
+{
+ FolderManager fm;
+
+ return fm.deleteIt(pszPath);
+}
+
+bool
+SFileTransferWin32::renameIt(char *pszOldPath, char *pszNewPath)
+{
+ FolderManager fm;
+
+ return fm.renameIt(pszOldPath, pszNewPath);
+}
+
+bool
+SFileTransferWin32::createDir(char *pszPath)
+{
+ FolderManager fm;
+
+ return fm.createDir(pszPath);
+}
+
+bool
+SFileTransferWin32::getDirSize(char *pszName, unsigned short *pHighSize16,
+ unsigned int *pLowSize32)
+{
+ FolderManager fm;
+ DWORD64 dw64DirSize = 0;
+
+ if (!fm.getDirSize(pszName, &dw64DirSize)) return false;
+
+ if (dw64DirSize & 0xFFFF000000000000) return false;
+
+ *pHighSize16 = ((dw64DirSize & 0x0000FFFF00000000) >> 32);
+ *pLowSize32 = (dw64DirSize & 0x00000000FFFFFFFF);
+
+ return true;
+}
diff --git a/rfb_win32/SFileTransferWin32.h b/rfb_win32/SFileTransferWin32.h
new file mode 100644
index 0000000..b2a5c57
--- /dev/null
+++ b/rfb_win32/SFileTransferWin32.h
@@ -0,0 +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 <windows.h>
+
+#include <rfb/SFileTransfer.h>
+
+const UINT VNCM_FT_DOWNLOAD = WM_USER + 2;
+
+namespace rfb {
+ namespace win32 {
+ class SFileTransferWin32 : public rfb::SFileTransfer
+ {
+ public:
+ SFileTransferWin32(network::Socket *sock);
+ ~SFileTransferWin32();
+
+ bool processDownloadCallback();
+ virtual bool initDownloadCallback();
+
+ virtual bool convertPathFromNet(char *pszPath);
+ virtual bool makeFileList(char *pszPath, FileInfo *pFI, bool bDirOnly);
+
+ virtual bool deleteIt(char *pszPath);
+ virtual bool renameIt(char *pszOldPath, char *pszNewPath);
+ virtual bool createDir(char *pszPath);
+
+ virtual bool getDirSize(char *pszName, unsigned short *pHighSize16, unsigned int *pLowSize32);
+
+ };
+ };
+}
+
+#endif // __RFB_SFILETRANSFERWIN32_H__
diff --git a/rfb_win32/rfb_win32.dsp b/rfb_win32/rfb_win32.dsp
index 2df2951..664e396 100644
--- a/rfb_win32/rfb_win32.dsp
+++ b/rfb_win32/rfb_win32.dsp
@@ -222,6 +222,14 @@
# End Source File
# Begin Source File
+SOURCE=.\SFileTransferManagerWin32.cxx
+# End Source File
+# Begin Source File
+
+SOURCE=.\SFileTransferWin32.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\SInput.cxx
# End Source File
# Begin Source File
@@ -438,6 +446,14 @@
# End Source File
# Begin Source File
+SOURCE=.\SFileTransferManagerWin32.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SFileTransferWin32.h
+# End Source File
+# Begin Source File
+
SOURCE=.\SInput.h
# End Source File
# Begin Source File
diff --git a/vncviewer/FTBrowseDlg.cxx b/vncviewer/FTBrowseDlg.cxx
index 7c88ff6..1b6dfb6 100644
--- a/vncviewer/FTBrowseDlg.cxx
+++ b/vncviewer/FTBrowseDlg.cxx
@@ -1,4 +1,6 @@
/* 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
@@ -68,9 +70,7 @@
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++)
{
@@ -132,6 +132,14 @@
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)
{
@@ -166,11 +174,13 @@
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));
}
}
diff --git a/vncviewer/FTBrowseDlg.h b/vncviewer/FTBrowseDlg.h
index 1a5e663..5c9ba35 100644
--- a/vncviewer/FTBrowseDlg.h
+++ b/vncviewer/FTBrowseDlg.h
@@ -1,4 +1,6 @@
/* 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
@@ -49,6 +51,8 @@
void addItems(FileInfo *pFI);
char *getPath();
+ void deleteChildItems();
+
private:
HWND m_hwndDlg;
HWND m_hwndTree;
diff --git a/vncviewer/FTDialog.cxx b/vncviewer/FTDialog.cxx
index b4c669d..409d3b1 100644
--- a/vncviewer/FTDialog.cxx
+++ b/vncviewer/FTDialog.cxx
@@ -1,4 +1,6 @@
/* 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
@@ -376,7 +378,6 @@
showRemoteLVItems();
}
}
-
delete m_pBrowseDlg;
m_pBrowseDlg = NULL;
}
@@ -514,6 +515,8 @@
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;
@@ -549,6 +552,8 @@
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;
diff --git a/vncviewer/FTDialog.h b/vncviewer/FTDialog.h
index 36cb669..a4b5546 100644
--- a/vncviewer/FTDialog.h
+++ b/vncviewer/FTDialog.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/vncviewer/FTListView.cxx b/vncviewer/FTListView.cxx
index ab43cbd..8f41abf 100644
--- a/vncviewer/FTListView.cxx
+++ b/vncviewer/FTListView.cxx
@@ -1,23 +1,25 @@
/* 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
diff --git a/vncviewer/FTListView.h b/vncviewer/FTListView.h
index 5f4fd64..c920fa0 100644
--- a/vncviewer/FTListView.h
+++ b/vncviewer/FTListView.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/vncviewer/FTMsgReader.h b/vncviewer/FTMsgReader.h
deleted file mode 100644
index 00706f7..0000000
--- 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 <windows.h>
-
-#include <rdr/InStream.h>
-#include <rfb/FileInfo.h>
-
-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 a8fd6e1..0000000
--- 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 <vncviewer/FTMsgWriter.h>
-
-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 42e9a93..0000000
--- 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 <rdr/types.h>
-#include <rdr/OutStream.h>
-#include <rfb/msgTypes.h>
-#include <rfb/fttypes.h>
-
-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__
diff --git a/vncviewer/FTProgress.cxx b/vncviewer/FTProgress.cxx
index e43132f..e6cc952 100644
--- a/vncviewer/FTProgress.cxx
+++ b/vncviewer/FTProgress.cxx
@@ -1,4 +1,6 @@
/* 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
@@ -132,13 +134,18 @@
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
diff --git a/vncviewer/FTProgress.h b/vncviewer/FTProgress.h
index c36c079..caad779 100644
--- a/vncviewer/FTProgress.h
+++ b/vncviewer/FTProgress.h
@@ -1,4 +1,6 @@
/* 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
diff --git a/vncviewer/FileTransfer.cxx b/vncviewer/FileTransfer.cxx
index 01aae56..46d4799 100644
--- a/vncviewer/FileTransfer.cxx
+++ b/vncviewer/FileTransfer.cxx
@@ -1,4 +1,6 @@
/* 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
@@ -32,6 +34,7 @@
m_bInitialized = false;
m_bResized = false;
m_bCancel = false;
+ m_bOverwriteAll = false;
m_pFTDialog = new FTDialog(GetModuleHandle(0), this);
@@ -67,8 +70,8 @@
{
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();
@@ -144,12 +147,12 @@
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 {
@@ -191,7 +194,7 @@
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) {
@@ -248,12 +251,12 @@
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 {
@@ -280,7 +283,7 @@
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;
}
}
@@ -304,8 +307,8 @@
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();
}
}
@@ -323,8 +326,8 @@
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;
}
@@ -378,9 +381,9 @@
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
@@ -392,10 +395,10 @@
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
@@ -540,7 +543,13 @@
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();
@@ -650,7 +659,7 @@
{
m_queueFileListRqst.add(pPath, 0, 0, dest);
- m_pWriter->writeFileListRqst(strlen(pPath), pPath, bDirOnly);
+ writeFileListRqst(strlen(pPath), pPath, bDirOnly);
}
int
@@ -698,3 +707,99 @@
m_DeleteQueue.free();
m_queueFileListRqst.free();
}
+
+int
+FileTransfer::convertToUnixPath(char *path)
+{
+ int len = strlen(path);
+ if (len >= FT_FILENAME_SIZE) return -1;
+ if (len == 0) {strcpy(path, "/"); return 1;}
+ for (int i = (len - 1); i >= 0; i--) {
+ if (path[i] == '\\') path[i] = '/';
+ path[i+1] = path[i];
+ }
+ path[len + 1] = '\0';
+ path[0] = '/';
+ return strlen(path);
+}
+
+bool
+FileTransfer::writeFileListRqst(unsigned short dirnameLen, char *pDirName, bool bDirOnly)
+{
+ char dirName[FT_FILENAME_SIZE];
+ strcpy(dirName, pDirName);
+ int len = convertToUnixPath(dirName);
+ if (len <= 0) return false;
+
+ return m_pWriter->writeFileListRqst(len, dirName, bDirOnly);
+}
+
+bool
+FileTransfer::writeFileDownloadRqst(unsigned short filenameLen, char *pFilename,
+ unsigned int position)
+{
+ char filename[FT_FILENAME_SIZE];
+ strcpy(filename, pFilename);
+ unsigned short len = (unsigned short) convertToUnixPath(filename);
+ if (len <= 0) return false;
+
+ return m_pWriter->writeFileDownloadRqst(len, filename, position);
+}
+
+bool
+FileTransfer::writeFileUploadRqst(unsigned short filenameLen, char *pFilename,
+ unsigned int position)
+{
+ char filename[FT_FILENAME_SIZE];
+ strcpy(filename, pFilename);
+ unsigned short len = (unsigned short) convertToUnixPath(filename);
+ if (len <= 0) return false;
+
+ return m_pWriter->writeFileUploadRqst(len, filename, position);
+}
+
+bool
+FileTransfer::writeFileCreateDirRqst(unsigned short dirNameLen, char *pDirName)
+{
+ char path[FT_FILENAME_SIZE];
+ strcpy(path, pDirName);
+ int nameLen = convertToUnixPath(path);
+
+ return m_pWriter->writeFileCreateDirRqst(nameLen, path);
+}
+
+bool
+FileTransfer::writeFileDirSizeRqst(unsigned short dirNameLen, char *pDirName)
+{
+ char path[FT_FILENAME_SIZE];
+ strcpy(path, pDirName);
+ int nameLen = convertToUnixPath(path);
+
+ return m_pWriter->writeFileDirSizeRqst(nameLen, path);
+}
+
+bool
+FileTransfer::writeFileRenameRqst(unsigned short oldNameLen, unsigned short newNameLen,
+ char *pOldName, char *pNewName)
+{
+ char oldName[FT_FILENAME_SIZE];
+ char newName[FT_FILENAME_SIZE];
+
+ strcpy(oldName, pOldName);
+ strcpy(newName, pNewName);
+
+ int _oldNameLen = convertToUnixPath(oldName);
+ int _newNameLen = convertToUnixPath(newName);
+
+ return m_pWriter->writeFileRenameRqst(_oldNameLen, _newNameLen, oldName, newName);
+}
+
+bool
+FileTransfer::writeFileDeleteRqst(unsigned short nameLen, char *pName)
+{
+ char path[FT_FILENAME_SIZE];
+ strcpy(path, pName);
+ int _nameLen = convertToUnixPath(path);
+
+ return m_pWriter->writeFileDeleteRqst(_nameLen, path);
+}
diff --git a/vncviewer/FileTransfer.h b/vncviewer/FileTransfer.h
index f62c2f9..1bfded2 100644
--- a/vncviewer/FileTransfer.h
+++ b/vncviewer/FileTransfer.h
@@ -1,4 +1,6 @@
/* 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
@@ -31,9 +33,9 @@
#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 {
@@ -74,11 +76,12 @@
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;
@@ -111,6 +114,19 @@
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;
};
diff --git a/vncviewer/vncviewer.dsp b/vncviewer/vncviewer.dsp
index 3c96f00..49a17cc 100644
--- a/vncviewer/vncviewer.dsp
+++ b/vncviewer/vncviewer.dsp
@@ -174,14 +174,6 @@
# End Source File
# Begin Source File
-SOURCE=.\FTMsgReader.cxx
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTMsgWriter.cxx
-# End Source File
-# Begin Source File
-
SOURCE=.\FTProgress.cxx
# End Source File
# Begin Source File
@@ -254,14 +246,6 @@
# End Source File
# Begin Source File
-SOURCE=.\FTMsgReader.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\FTMsgWriter.h
-# End Source File
-# Begin Source File
-
SOURCE=.\FTProgress.h
# End Source File
# Begin Source File
diff --git a/winvnc/VNCServerWin32.cxx b/winvnc/VNCServerWin32.cxx
index 8d681c2..3b0e1a0 100644
--- a/winvnc/VNCServerWin32.cxx
+++ b/winvnc/VNCServerWin32.cxx
@@ -27,6 +27,7 @@
#include <rfb/SSecurityFactoryStandard.h>
#include <rfb/Hostname.h>
#include <rfb/LogWriter.h>
+#include <rfb_win32/SFileTransferWin32.h>
using namespace rfb;
using namespace win32;
@@ -38,6 +39,9 @@
const TCHAR* winvnc::VNCServerWin32::RegConfigPath = _T("Software\\TightVNC\\WinVNC4");
+// FIXME: Move into an .h file?
+extern const UINT VNCM_FT_DOWNLOAD;
+
static IntParameter http_port("HTTPPortNumber",
"TCP/IP port on which the server will serve the Java applet VNC Viewer ", 5800);
@@ -71,6 +75,8 @@
// Register the queued command event to be handled
sockMgr.addEvent(commandEvent, this);
+
+ vncServer.setFTManager((rfb::SFileTransferManager *)&m_FTManager);
}
VNCServerWin32::~VNCServerWin32() {
@@ -177,6 +183,8 @@
throw rdr::SystemException("getMessage", GetLastError());
if (!isServiceProcess() && (result == 0))
break;
+ if (msg.message == VNCM_FT_DOWNLOAD)
+ m_FTManager.processDownloadMsg(msg);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
diff --git a/winvnc/VNCServerWin32.h b/winvnc/VNCServerWin32.h
index f05f2c7..579a6a0 100644
--- a/winvnc/VNCServerWin32.h
+++ b/winvnc/VNCServerWin32.h
@@ -26,6 +26,7 @@
#include <rfb_win32/SDisplay.h>
#include <rfb_win32/SocketManager.h>
#include <rfb_win32/TCharArray.h>
+#include <rfb_win32/SFileTransferManagerWin32.h>
#include <winvnc/QueryConnectDialog.h>
#include <winvnc/JavaViewer.h>
#include <winvnc/ManagedListener.h>
@@ -121,6 +122,7 @@
//rfb::SSecurityFactoryStandard securityFactory;
QueryConnectDialog* queryConnectDialog;
+ rfb::win32::SFileTransferManagerWin32 m_FTManager;
};
};