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
diff --git a/vncviewer/FTDialog.cxx b/vncviewer/FTDialog.cxx
index 11f24a0..64c8f3a 100644
--- a/vncviewer/FTDialog.cxx
+++ b/vncviewer/FTDialog.cxx
@@ -42,6 +42,7 @@
   m_pRemoteLV = NULL;
   m_pProgress = NULL;
   m_pCancelingDlg = NULL;
+  m_pCreateFolderDlg = NULL;
 
   m_hwndFTDialog = NULL;
   m_hwndLocalPath = NULL;
@@ -54,6 +55,7 @@
   m_szRemotePath[0] = '\0';
   m_szLocalPathTmp[0] = '\0';
   m_szRemotePathTmp[0] = '\0';
+  m_szCreateFolderName[0] = '\0';
 }
 
 FTDialog::~FTDialog()
@@ -471,16 +473,46 @@
   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 @@
   }
   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 ed3afa9..e362f95 100644
--- a/vncviewer/FTDialog.h
+++ b/vncviewer/FTDialog.h
@@ -94,6 +94,7 @@
       void onLocalRButton();
       void onRemoteRButton();
 
+      bool getCreateFolderName();
       void onLocalCreateFolder();
       void onRemoteCreateFolder();
 
@@ -143,6 +144,7 @@
       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 @@
         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 5d074f3..3747506 100644
--- a/vncviewer/FileTransfer.cxx
+++ b/vncviewer/FileTransfer.cxx
@@ -361,6 +361,17 @@
   }
 }
 
+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 13908d3..eccdcd6 100644
--- a/vncviewer/FileTransfer.h
+++ b/vncviewer/FileTransfer.h
@@ -64,6 +64,8 @@
 
       void uploadFilePortion();
 
+      void createRemoteFolder(char *pPath, char *pName);
+
       bool m_bCancel;
 
     private:
diff --git a/vncviewer/vncviewer.rc b/vncviewer/vncviewer.rc
index 5335294..90171ba 100644
--- a/vncviewer/vncviewer.rc
+++ b/vncviewer/vncviewer.rc
@@ -366,10 +366,10 @@
 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