Added FileTransfer::createFileTransfer.
Code improvements.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@383 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/FTDialog.cxx b/vncviewer/FTDialog.cxx
index f4f8220..e4d1830 100644
--- a/vncviewer/FTDialog.cxx
+++ b/vncviewer/FTDialog.cxx
@@ -39,6 +39,8 @@
   m_pLocalLV = NULL;
   m_pRemoteLV = NULL;
   m_pProgress = NULL;
+
+  m_hwndFTDialog = false;
 }
 
 FTDialog::~FTDialog()
@@ -49,6 +51,8 @@
 bool
 FTDialog::createFTDialog()
 {
+  if (m_hwndFTDialog != NULL) return true;
+
   m_hwndFTDialog = CreateDialogParam(m_hInstance, 
                                      MAKEINTRESOURCE(IDD_FILETRANSFER_DLG),
                                      NULL, 
@@ -66,21 +70,29 @@
     destroyFTDialog();
     return false;
   }
+
+  initFTDialog();
   
-  m_pLocalLV->initialize(m_hInstance);
-  m_pRemoteLV->initialize(m_hInstance);
-  
-  ShowWindow(m_hwndFTDialog, SW_SHOW);
-  UpdateWindow(m_hwndFTDialog);
-  m_bDlgShown = true;
-  
-  return true;
+  if (ShowWindow(m_hwndFTDialog, SW_SHOW) == 0) {
+    UpdateWindow(m_hwndFTDialog);
+    m_bDlgShown = true;
+    return true;
+  } else {
+    destroyFTDialog();
+    m_bDlgShown = false;
+    return false;
+  } 
 }
 
 bool
 FTDialog::initFTDialog()
 {
-  return false;
+  m_pLocalLV->initialize(m_hInstance);
+  m_pRemoteLV->initialize(m_hInstance);
+
+  m_pProgress->initialize(0,0);
+
+  return true;
 }
 
 bool
diff --git a/vncviewer/FTDialog.h b/vncviewer/FTDialog.h
index 5bd165c..a019910 100644
--- a/vncviewer/FTDialog.h
+++ b/vncviewer/FTDialog.h
@@ -28,13 +28,15 @@
 #include <commctrl.h>
 
 #include <rfb/FileInfo.h>
+#include <vncviewer/FileTransfer.h>
 #include <vncviewer/FTListView.h>
 #include <vncviewer/FTProgress.h>
-#include <vncviewer/FileTransfer.h>
 #include <vncviewer/resource.h>
 
 namespace rfb {
   namespace win32 {
+    class FileTransfer;
+
     class FTDialog
     {
     public:
diff --git a/vncviewer/FTProgress.cxx b/vncviewer/FTProgress.cxx
index b4c461a..46316f0 100644
--- a/vncviewer/FTProgress.cxx
+++ b/vncviewer/FTProgress.cxx
@@ -54,6 +54,8 @@
 
   if (!initProgressControls(totalMaxValue, maxValue)) return false;
 
+  setProgressText();
+
   m_bInitialized = true;
   return true;
 }
diff --git a/vncviewer/FileTransfer.cxx b/vncviewer/FileTransfer.cxx
index b439aa9..39c387a 100644
--- a/vncviewer/FileTransfer.cxx
+++ b/vncviewer/FileTransfer.cxx
@@ -28,10 +28,20 @@
 
 FileTransfer::FileTransfer()
 {
-
+  m_bFTDlgShown = false;
+  m_pFTDialog = new FTDialog(GetModuleHandle(0), this);
 }
 
 FileTransfer::~FileTransfer()
 {
+  if (m_pFTDialog != NULL) {
+    delete m_pFTDialog;
+    m_pFTDialog = NULL;
+  }
+}
 
+void 
+FileTransfer::createFileTransfer()
+{
+  m_bFTDlgShown = m_pFTDialog->createFTDialog();
 }
diff --git a/vncviewer/FileTransfer.h b/vncviewer/FileTransfer.h
index 4a4e725..0d385e3 100644
--- a/vncviewer/FileTransfer.h
+++ b/vncviewer/FileTransfer.h
@@ -24,13 +24,24 @@
 #ifndef __RFB_WIN32_FILETRANSFER_H__
 #define __RFB_WIN32_FILETRANSFER_H__
 
+#include <vncviewer/FTDialog.h>
+
 namespace rfb {
   namespace win32 {
+    class FTDialog;
+
     class FileTransfer
     {
     public:
       FileTransfer();
       ~FileTransfer();
+
+      void createFileTransfer();
+
+    private:
+      bool m_bFTDlgShown;
+
+      FTDialog *m_pFTDialog;
       
     };
   }