From f092894791045ba5c05143fe09f35768865d7849 Mon Sep 17 00:00:00 2001 From: Dennis Syrovatsky Date: Wed, 14 Dec 2005 15:12:45 +0000 Subject: [PATCH] Added create folder possibility. Now the user can create folders on the local and remote sides. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@448 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- vncviewer/FTDialog.cxx | 60 ++++++++++++++++++++++++++++++++++++-- vncviewer/FTDialog.h | 9 ++++++ vncviewer/FileTransfer.cxx | 11 +++++++ vncviewer/FileTransfer.h | 2 ++ vncviewer/vncviewer.rc | 2 +- 5 files changed, 81 insertions(+), 3 deletions(-) diff --git a/vncviewer/FTDialog.cxx b/vncviewer/FTDialog.cxx index 11f24a0f..64c8f3ab 100644 --- a/vncviewer/FTDialog.cxx +++ b/vncviewer/FTDialog.cxx @@ -42,6 +42,7 @@ FTDialog::FTDialog(HINSTANCE hInst, FileTransfer *pFT) m_pRemoteLV = NULL; m_pProgress = NULL; m_pCancelingDlg = NULL; + m_pCreateFolderDlg = NULL; m_hwndFTDialog = NULL; m_hwndLocalPath = NULL; @@ -54,6 +55,7 @@ FTDialog::FTDialog(HINSTANCE hInst, FileTransfer *pFT) m_szRemotePath[0] = '\0'; m_szLocalPathTmp[0] = '\0'; m_szRemotePathTmp[0] = '\0'; + m_szCreateFolderName[0] = '\0'; } FTDialog::~FTDialog() @@ -471,16 +473,46 @@ FTDialog::onRemoteDelete() setButtonsState(); } +bool +FTDialog::getCreateFolderName() +{ + if (m_pCreateFolderDlg != NULL) return false; + + bool bResult = false; + + m_pCreateFolderDlg = new FTDialog::CreateFolderDlg(this); + m_pCreateFolderDlg->create(); + if (strlen(m_pCreateFolderDlg->getFolderName()) != 0) { + strcpy(m_szCreateFolderName, m_pCreateFolderDlg->getFolderName()); + bResult = true; + } else { + m_szCreateFolderName[0] = '\0'; + bResult = false; + } + delete m_pCreateFolderDlg; + m_pCreateFolderDlg = NULL; + + return bResult; +} + void FTDialog::onLocalCreateFolder() { - + if (getCreateFolderName()) { + char path[FT_FILENAME_SIZE]; + sprintf(path, "%s\\%s", m_szLocalPath, m_szCreateFolderName); + setStatusText("Creating Local Folder: %s", path); + FolderManager fm; + if (fm.createDir(path)) showLocalLVItems(); + } } void FTDialog::onRemoteCreateFolder() { - + if (getCreateFolderName()) { + m_pFileTransfer->createRemoteFolder(m_szRemotePath, m_szCreateFolderName); + } } void @@ -882,3 +914,27 @@ FTDialog::CancelingDlg::cancelingDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP } return FALSE; } + +FTDialog::CreateFolderDlg::CreateFolderDlg(FTDialog *pFTDlg) : Dialog(GetModuleHandle(0)) +{ + m_pFTDlg = pFTDlg; + m_szFolderName[0] = '\0'; +} + +FTDialog::CreateFolderDlg::~CreateFolderDlg() +{ + +} + +bool +FTDialog::CreateFolderDlg::create() +{ + return showDialog(MAKEINTRESOURCE(IDD_FTCREATEFOLDER), m_pFTDlg->getWndHandle()); +} + +bool +FTDialog::CreateFolderDlg::onOk() +{ + strcpy(m_szFolderName, getItemString(IDC_FTFOLDERNAME)); + return true; +} diff --git a/vncviewer/FTDialog.h b/vncviewer/FTDialog.h index ed3afa97..e362f95d 100644 --- a/vncviewer/FTDialog.h +++ b/vncviewer/FTDialog.h @@ -94,6 +94,7 @@ namespace rfb { void onLocalRButton(); void onRemoteRButton(); + bool getCreateFolderName(); void onLocalCreateFolder(); void onRemoteCreateFolder(); @@ -143,6 +144,7 @@ namespace rfb { char m_szRemotePath[FT_FILENAME_SIZE]; char m_szLocalPathTmp[FT_FILENAME_SIZE]; char m_szRemotePathTmp[FT_FILENAME_SIZE]; + char m_szCreateFolderName[FT_FILENAME_SIZE]; static const char szCheckDeleteQueueText[]; static const char szCheckTransferQueueText[]; @@ -192,6 +194,13 @@ namespace rfb { CreateFolderDlg(FTDialog *pFTDlg); ~CreateFolderDlg(); + bool onOk(); + bool create(); + char *getFolderName() { return m_szFolderName; } + + private: + FTDialog *m_pFTDlg; + char m_szFolderName[FT_FILENAME_SIZE]; }; private: diff --git a/vncviewer/FileTransfer.cxx b/vncviewer/FileTransfer.cxx index 5d074f3a..37475060 100644 --- a/vncviewer/FileTransfer.cxx +++ b/vncviewer/FileTransfer.cxx @@ -361,6 +361,17 @@ FileTransfer::uploadFilePortion() } } +void +FileTransfer::createRemoteFolder(char *pPath, char *pName) +{ + 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); + m_queueFileListRqst.add(pPath, 0, 0, FT_FLR_DEST_MAIN); + m_pWriter->writeFileListRqst(strlen(pPath), pPath, false); +} + bool FileTransfer::procFileListDataMsg() { diff --git a/vncviewer/FileTransfer.h b/vncviewer/FileTransfer.h index 13908d39..eccdcd6e 100644 --- a/vncviewer/FileTransfer.h +++ b/vncviewer/FileTransfer.h @@ -64,6 +64,8 @@ namespace rfb { void uploadFilePortion(); + void createRemoteFolder(char *pPath, char *pName); + bool m_bCancel; private: diff --git a/vncviewer/vncviewer.rc b/vncviewer/vncviewer.rc index 53352942..90171bad 100644 --- a/vncviewer/vncviewer.rc +++ b/vncviewer/vncviewer.rc @@ -366,10 +366,10 @@ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Create a New Folder" FONT 8, "MS Sans Serif" BEGIN + EDITTEXT IDC_FTFOLDERNAME,7,19,179,14,ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,80,42,50,14 PUSHBUTTON "Cancel",IDCANCEL,136,42,50,14 LTEXT "New Folder Name",IDC_STATIC,7,7,179,8 - EDITTEXT IDC_FTFOLDERNAME,7,19,179,14,ES_AUTOHSCROLL END -- 2.39.5