Added code for download operation
to the FileTransfer::CheckDownloadQueue() method.
Code improvements.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@438 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/FTDialog.cxx b/vncviewer/FTDialog.cxx
index 5d69108..8e18d03 100644
--- a/vncviewer/FTDialog.cxx
+++ b/vncviewer/FTDialog.cxx
@@ -406,7 +406,6 @@
FTDialog::onUpload()
{
FileInfo fi;
- TransferQueue tq;
if (m_pLocalLV->getSelectedItems(&fi) > 0) {
m_pFileTransfer->addTransferQueue(m_szLocalPath, m_szRemotePath, &fi, FT_ATTR_COPY_UPLOAD);
}
@@ -415,8 +414,10 @@
void
FTDialog::onDownload()
{
- MessageBox(NULL, "onDownload", "FTDialog", MB_OK);
-
+ FileInfo fi;
+ if (m_pRemoteLV->getSelectedItems(&fi) > 0) {
+ m_pFileTransfer->addTransferQueue(m_szLocalPath, m_szRemotePath, &fi, FT_ATTR_COPY_DOWNLOAD);
+ }
}
void
diff --git a/vncviewer/FileTransfer.cxx b/vncviewer/FileTransfer.cxx
index 6a4e4b7..81de7b5 100644
--- a/vncviewer/FileTransfer.cxx
+++ b/vncviewer/FileTransfer.cxx
@@ -223,13 +223,34 @@
} else {
if (flag0 & FT_ATTR_COPY_DOWNLOAD) {
if (flag0 & FT_ATTR_FILE) {
+ downloadFile();
+ return;
}
if (flag0 & FT_ATTR_DIR) {
+ FolderManager fm;
+ char *pLocPath = m_TransferQueue.getFullLocPathAt(0);
+ if (m_bFTDlgShown) m_pFTDialog->setStatusText("Creating Local Folder. %s", pLocPath);
+
+ if (!fm.createDir(pLocPath)) {
+ if (m_bFTDlgShown) m_pFTDialog->setStatusText("Creating Local Folder Failed.");
+ m_TransferQueue.deleteAt(0);
+ m_pFTDialog->postCheckTransferQueueMsg();
+ return;
+ } else {
+ if ((m_bFTDlgShown) && (strcmp(m_TransferQueue.getLocPathAt(0), m_pFTDialog->getLocalPath()) == 0))
+ PostMessage(m_pFTDialog->getWndHandle(), WM_COMMAND, MAKEWPARAM(IDC_FTLOCALRELOAD, 0), 0);
+
+ m_TransferQueue.setFlagsAt(0, (m_TransferQueue.getFlagsAt(0) | FT_ATTR_FLR_DOWNLOAD_ADD));
+ char *pRemPath = m_TransferQueue.getFullRemPathAt(0);
+ m_queueFileListRqst.add(pRemPath, 0, 0, FT_FLR_DEST_DOWNLOAD);
+ m_pWriter->writeFileListRqst(strlen(pRemPath), pRemPath, 0);
+ m_TransferQueue.deleteAt(0);
+ return;
+ }
}
}
}
if (m_bFTDlgShown) m_pFTDialog->setStatusText("File Transfer Operation Failed. Unknown data in the transfer queue");
-
} // if (!isTransferEnable())
}