Added window messages to FTDialog
for operating upload, download and transfer queue.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@420 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/FTDialog.cxx b/vncviewer/FTDialog.cxx
index 164de96..8acebd4 100644
--- a/vncviewer/FTDialog.cxx
+++ b/vncviewer/FTDialog.cxx
@@ -26,6 +26,10 @@
using namespace rfb;
using namespace rfb::win32;
+const char FTDialog::szCheckTransferQueueText[] = "TightVNC.Viewer.CheckTransferQueue.Msg";
+const char FTDialog::szDownloadFilePortionText[] = "TightVNC.Viewer.DownloadFilePortion.Msg";
+const char FTDialog::szUploadFilePortionText[] = "TightVNC.Viewer.UploadFilePortion.Msg";
+
FTDialog::FTDialog(HINSTANCE hInst, FileTransfer *pFT)
{
m_pFileTransfer = pFT;
@@ -69,6 +73,8 @@
(LONG) this);
if (m_hwndFTDialog == NULL) return false;
+
+ if (!initFTWndMsgs()) return false;
HWND hwndLocalList = GetDlgItem(m_hwndFTDialog, IDC_FTLOCALLIST);
HWND hwndRemoteList = GetDlgItem(m_hwndFTDialog, IDC_FTREMOTELIST);
@@ -117,6 +123,20 @@
}
bool
+FTDialog::initFTWndMsgs()
+{
+ m_msgCheckTransferQueue = RegisterWindowMessage(szCheckTransferQueueText);
+ m_msgUploadFilePortion = RegisterWindowMessage(szUploadFilePortionText);
+ m_msgDownloadFilePortion = RegisterWindowMessage(szDownloadFilePortionText);
+
+ if ((m_msgCheckTransferQueue) &&
+ (m_msgUploadFilePortion) &&
+ (m_msgDownloadFilePortion)) return true;
+
+ return false;
+}
+
+bool
FTDialog::closeFTDialog()
{
ShowWindow(m_hwndFTDialog, SW_HIDE);
@@ -257,6 +277,16 @@
_this->closeFTDialog();
return FALSE;
}
+
+ if (uMsg == _this->m_msgCheckTransferQueue)
+ _this->m_pFileTransfer->checkTransferQueue();
+
+ if (uMsg == _this->m_msgDownloadFilePortion)
+ _this->m_pFileTransfer->downloadFilePortion();
+
+ if (uMsg == _this->m_msgUploadFilePortion)
+ _this->m_pFileTransfer->uploadFilePortion();
+
return FALSE;
}
@@ -366,7 +396,11 @@
void
FTDialog::onUpload()
{
- MessageBox(NULL, "onUpload", "FTDialog", MB_OK);
+ FileInfo fi;
+ TransferQueue tq;
+ if (m_pLocalLV->getSelectedItems(&fi) > 0) {
+ m_pFileTransfer->addTransferQueue(m_szLocalPath, m_szRemotePath, &fi, FT_ATTR_COPY_UPLOAD);
+ }
}
void
@@ -630,3 +664,21 @@
int nSize = _vsnprintf(text, sizeof(text), format, args);
SetDlgItemText(m_hwndFTDialog, IDC_FTSTATUS, text);
}
+
+void
+FTDialog::postCheckTransferQueueMsg()
+{
+ PostMessage(m_hwndFTDialog, m_msgCheckTransferQueue, 0, 0);
+}
+
+void
+FTDialog::postUploadFilePortionMsg()
+{
+ PostMessage(m_hwndFTDialog, m_msgUploadFilePortion, 0, 0);
+}
+
+void
+FTDialog::postDownloadFilePortionMsg()
+{
+ PostMessage(m_hwndFTDialog, m_msgDownloadFilePortion, 0, 0);
+}
diff --git a/vncviewer/FTDialog.h b/vncviewer/FTDialog.h
index 2e70db3..82e7536 100644
--- a/vncviewer/FTDialog.h
+++ b/vncviewer/FTDialog.h
@@ -56,6 +56,10 @@
HWND getWndHandle() { return m_hwndFTDialog; }
+ void postCheckTransferQueueMsg();
+ void postUploadFilePortionMsg();
+ void postDownloadFilePortionMsg();
+
FTProgress *m_pProgress;
private:
@@ -95,6 +99,7 @@
void setIcon(int dest, int idIcon);
bool initFTDialog();
+ bool initFTWndMsgs();
void onLocalOneUpFolder();
void onRemoteOneUpFolder();
@@ -105,6 +110,10 @@
bool m_bDlgShown;
+ UINT m_msgCheckTransferQueue;
+ UINT m_msgUploadFilePortion;
+ UINT m_msgDownloadFilePortion;
+
FTListView *m_pLocalLV;
FTListView *m_pRemoteLV;
@@ -115,6 +124,10 @@
char m_szLocalPathTmp[FT_FILENAME_SIZE];
char m_szRemotePathTmp[FT_FILENAME_SIZE];
+ static const char szCheckTransferQueueText[];
+ static const char szUploadFilePortionText[];
+ static const char szDownloadFilePortionText[];
+
typedef struct tagFTBUTTONSSTATE
{
bool uploadBtn;
diff --git a/vncviewer/FileTransfer.cxx b/vncviewer/FileTransfer.cxx
index 5b01334..0a3009a 100644
--- a/vncviewer/FileTransfer.cxx
+++ b/vncviewer/FileTransfer.cxx
@@ -102,29 +102,46 @@
}
void
-FileTransfer::upload(TransferQueue *pTransQueue)
+FileTransfer::addTransferQueue(char *pLocalPath, char *pRemotePath,
+ FileInfo *pFI, unsigned int flags)
{
if ((m_bFTDlgShown) && (!isTransferEnable())) m_pFTDialog->setStatusText("Starting Copy Operation");
- pTransQueue->setFlagToAll(FT_ATTR_RESIZE_NEEDED);
-
- m_TransferQueue.add(pTransQueue);
-
- resizeSending();
+ m_TransferQueue.add(pLocalPath, pRemotePath, pFI, (flags | FT_ATTR_RESIZE_NEEDED));
checkTransferQueue();
}
-void
-FileTransfer::download(TransferQueue *pTransQueue)
-{
-
-}
-
-void
+bool
FileTransfer::resizeSending()
{
-
+ for (unsigned int i = 0; i < m_TransferQueue.getNumEntries(); i++) {
+ unsigned int flags = m_TransferQueue.getFlagsAt(i);
+ if (flags & FT_ATTR_RESIZE_NEEDED) {
+ if (flags & FT_ATTR_FILE) {
+ m_dw64SizeSending += m_TransferQueue.getSizeAt(i);
+ m_TransferQueue.clearFlagAt(i, FT_ATTR_RESIZE_NEEDED);
+ } else {
+ if (flags & FT_ATTR_DIR) {
+ if (flags & FT_ATTR_COPY_DOWNLOAD) {
+ char *pPath = m_TransferQueue.getFullRemPathAt(i);
+ m_dirSizeRqstNum = i;
+ m_pWriter->writeFileDirSizeRqst(strlen(pPath), pPath);
+ return false;
+ } else {
+ if (flags & FT_ATTR_COPY_UPLOAD) {
+ FolderManager fm;
+ DWORD64 dw64Size;
+ fm.getDirSize(m_TransferQueue.getFullLocPathAt(i), &dw64Size);
+ m_dw64SizeSending += dw64Size;
+ m_TransferQueue.clearFlagAt(i, FT_ATTR_RESIZE_NEEDED);
+ }
+ } // if (flags & FT_ATTR_COPY_DOWNLOAD)
+ } // if (flags & FT_ATTR_FOLDER)
+ } // if (flags & FT_ATTR_FILE)
+ } // if (flags & FT_ATTR_NEEDED_RESIZE)
+ } // for (unsigned int i = 0; i < m_TransferQueue.getNumEntries(); i++)
+ return true;
}
void
@@ -138,35 +155,10 @@
return;
}
} else {
- for (unsigned int i = 0; i < m_TransferQueue.getNumEntries(); i++) {
- unsigned int flags = m_TransferQueue.getFlagsAt(i);
- if (flags & FT_ATTR_RESIZE_NEEDED) {
- if (flags & FT_ATTR_FILE) {
- m_dw64SizeSending += m_TransferQueue.getSizeAt(i);
- m_TransferQueue.clearFlagAt(i, FT_ATTR_RESIZE_NEEDED);
- } else {
- if (flags & FT_ATTR_DIR) {
- if (flags & FT_ATTR_COPY_DOWNLOAD) {
- char *pPath = m_TransferQueue.getFullRemPathAt(i);
- m_dirSizeRqstNum = i;
- m_pWriter->writeFileDirSizeRqst(strlen(pPath), pPath);
- return;
- } else {
- if (flags & FT_ATTR_COPY_UPLOAD) {
- FolderManager fm;
- DWORD64 dw64Size;
- fm.getDirSize(m_TransferQueue.getFullLocPathAt(i), &dw64Size);
- m_dw64SizeSending += dw64Size;
- m_TransferQueue.clearFlagAt(i, FT_ATTR_RESIZE_NEEDED);
- }
- } // if (flags & FT_ATTR_COPY_DOWNLOAD)
- } // if (flags & FT_ATTR_FOLDER)
- } // if (flags & FT_ATTR_FILE)
- } // if (flags & FT_ATTR_NEEDED_RESIZE)
- } // for (unsigned int i = 0; i < m_TransferQueue.getNumEntries(); i++)
+ if (!resizeSending()) return;
unsigned int flag0 = m_TransferQueue.getFlagsAt(0);
-
+
if (flag0 & FT_ATTR_COPY_UPLOAD) {
if (flag0 & FT_ATTR_FILE) {
uploadFile();
@@ -208,6 +200,18 @@
return false;
}
+void
+FileTransfer::uploadFilePortion()
+{
+
+}
+
+void
+FileTransfer::downloadFilePortion()
+{
+
+}
+
bool
FileTransfer::procFileListDataMsg()
{
@@ -271,6 +275,7 @@
DWORD64 dw64DirSize = 0;
m_pReader->readFileDirSizeData(&dw64DirSize);
m_TransferQueue.clearFlagAt(m_dirSizeRqstNum, FT_ATTR_RESIZE_NEEDED);
+ checkTransferQueue();
return true;
}
diff --git a/vncviewer/FileTransfer.h b/vncviewer/FileTransfer.h
index 53ebbb7..a81a2ef 100644
--- a/vncviewer/FileTransfer.h
+++ b/vncviewer/FileTransfer.h
@@ -49,11 +49,13 @@
void requestFileList(char *pPath, int dest, bool bDirOnly);
- void upload(TransferQueue *pTransQueue);
- void download(TransferQueue *pTransQueue);
+ void addTransferQueue(char *pLocalPath, char *pRemotePath,
+ FileInfo *pFI, unsigned int flags);
bool isTransferEnable();
- void resizeSending();
+ void checkTransferQueue();
+ void uploadFilePortion();
+ void downloadFilePortion();
private:
bool m_bFTDlgShown;
@@ -64,11 +66,14 @@
FTMsgReader *m_pReader;
FTMsgWriter *m_pWriter;
+ FileReader m_fileReader;
+ FileWriter m_fileWriter;
+
FileInfo m_queueFileListRqst;
TransferQueue m_TransferQueue;
- void checkTransferQueue();
+ bool resizeSending();
bool uploadFile();
bool downloadFile();
@@ -88,7 +93,7 @@
DWORD64 m_dw64SizeSending;
unsigned int m_dirSizeRqstNum;
-
+
};
}
}