Constantin Kaplinsky | 729598c | 2006-05-25 05:12:25 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2005 TightVNC Team. All Rights Reserved. |
| 2 | * |
| 3 | * Developed by Dennis Syrovatsky |
| 4 | * |
| 5 | * This is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This software is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this software; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 18 | * USA. |
| 19 | * |
Peter Åstrand | 7877cd6 | 2009-02-25 16:15:48 +0000 | [diff] [blame] | 20 | * |
Constantin Kaplinsky | 729598c | 2006-05-25 05:12:25 +0000 | [diff] [blame] | 21 | * |
| 22 | */ |
| 23 | |
| 24 | // -=- FTDialog.h |
| 25 | |
| 26 | #ifndef __RFB_WIN32_FTDIALOG_H__ |
| 27 | #define __RFB_WIN32_FTDIALOG_H__ |
| 28 | |
| 29 | #include <windows.h> |
| 30 | #include <commctrl.h> |
| 31 | |
| 32 | #include <rfb/FileInfo.h> |
| 33 | #include <rfb_win32/Dialog.h> |
| 34 | #include <vncviewer/FileTransfer.h> |
| 35 | #include <vncviewer/FTListView.h> |
| 36 | #include <vncviewer/FTProgress.h> |
| 37 | #include <vncviewer/FTBrowseDlg.h> |
| 38 | #include <vncviewer/resource.h> |
| 39 | |
| 40 | namespace rfb { |
| 41 | namespace win32 { |
| 42 | class FileTransfer; |
| 43 | class FTBrowseDlg; |
| 44 | |
| 45 | class FTDialog |
| 46 | { |
| 47 | public: |
| 48 | FTDialog(HINSTANCE hInst, FileTransfer *pFT); |
| 49 | ~FTDialog(); |
| 50 | |
| 51 | bool createFTDialog(HWND hwndParent); |
| 52 | bool closeFTDialog(); |
| 53 | void destroyFTDialog(); |
| 54 | |
| 55 | void processDlgMsgs(); |
| 56 | |
| 57 | void cancelTransfer(bool bResult); |
| 58 | void afterCancelTransfer(); |
| 59 | |
| 60 | static BOOL CALLBACK FTDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 61 | |
| 62 | void addRemoteLVItems(FileInfo *pFI); |
| 63 | void reqFolderUnavailable(); |
| 64 | |
| 65 | void onEndBrowseDlg(bool bResult); |
| 66 | void getBrowseItems(char *pPath); |
| 67 | void addBrowseItems(FileInfo *pFI); |
| 68 | |
| 69 | void setStatusText(LPCSTR format,...); |
| 70 | |
| 71 | HWND getWndHandle() { return m_hwndFTDialog; } |
| 72 | |
| 73 | void postCheckDeleteQueueMsg(); |
| 74 | void postCheckTransferQueueMsg(); |
| 75 | void postUploadFilePortionMsg(); |
| 76 | void postDownloadFilePortionMsg(); |
| 77 | |
| 78 | char *getLocalPath() { return m_szLocalPath; } |
| 79 | char *getRemotePath() { return m_szRemotePath; } |
| 80 | |
| 81 | FTProgress *m_pProgress; |
| 82 | FileTransfer *m_pFileTransfer; |
| 83 | |
| 84 | private: |
| 85 | HWND m_hwndFTDialog; |
| 86 | HWND m_hwndLocalPath; |
| 87 | HWND m_hwndRemotePath; |
| 88 | HINSTANCE m_hInstance; |
| 89 | |
| 90 | void showLocalLVItems(); |
| 91 | void showRemoteLVItems(); |
| 92 | |
| 93 | void onClose(); |
| 94 | |
| 95 | void onLocalItemActivate(LPNMITEMACTIVATE lpnmia); |
| 96 | void onRemoteItemActivate(LPNMITEMACTIVATE lpnmia); |
| 97 | |
| 98 | void onLocalBrowse(); |
| 99 | void onRemoteBrowse(); |
| 100 | |
| 101 | void onLocalReload(); |
| 102 | void onRemoteReload(); |
| 103 | |
| 104 | void onLocalRButton(); |
| 105 | void onRemoteRButton(); |
| 106 | |
| 107 | bool getCreateFolderName(); |
| 108 | void onLocalCreateFolder(); |
| 109 | void onRemoteCreateFolder(); |
| 110 | |
| 111 | void showFTMenu(bool copyBtnState, bool createFldBtnState, |
| 112 | bool renameBtnState, bool deleteBtnState, |
| 113 | bool cancelBtnState); |
| 114 | void onFTMenuCommand(int command); |
| 115 | |
| 116 | void onUpload(); |
| 117 | void onDownload(); |
| 118 | |
| 119 | void onLocalRename(); |
| 120 | void onRemoteRename(); |
| 121 | |
| 122 | void onLocalDelete(); |
| 123 | void onRemoteDelete(); |
| 124 | |
| 125 | void onFTCancel(); |
| 126 | |
| 127 | void setIcon(int dest, int idIcon); |
| 128 | bool initFTDialog(); |
| 129 | bool initFTWndMsgs(); |
| 130 | |
| 131 | void onLocalOneUpFolder(); |
| 132 | void onRemoteOneUpFolder(); |
| 133 | int makeOneUpFolder(char *pPath); |
| 134 | |
| 135 | void refreshBtnState(); |
| 136 | void setButtonsState(); |
| 137 | |
| 138 | bool m_bDlgShown; |
| 139 | bool m_bLocalBrowsing; |
| 140 | bool m_bCloseDlgAfterCancel; |
| 141 | |
| 142 | UINT m_msgCheckDeleteQueue; |
| 143 | UINT m_msgCheckTransferQueue; |
| 144 | UINT m_msgUploadFilePortion; |
| 145 | UINT m_msgDownloadFilePortion; |
| 146 | |
| 147 | DWORD m_dwNumStatusStrings; |
| 148 | |
| 149 | FTListView *m_pLocalLV; |
| 150 | FTListView *m_pRemoteLV; |
| 151 | |
| 152 | FTBrowseDlg *m_pBrowseDlg; |
| 153 | |
| 154 | int m_FTMenuSource; |
| 155 | |
| 156 | char m_szLocalPath[FT_FILENAME_SIZE]; |
| 157 | char m_szRemotePath[FT_FILENAME_SIZE]; |
| 158 | char m_szLocalPathTmp[FT_FILENAME_SIZE]; |
| 159 | char m_szRemotePathTmp[FT_FILENAME_SIZE]; |
| 160 | char m_szCreateFolderName[FT_FILENAME_SIZE]; |
| 161 | |
| 162 | static const char szCheckDeleteQueueText[]; |
| 163 | static const char szCheckTransferQueueText[]; |
| 164 | static const char szUploadFilePortionText[]; |
| 165 | |
| 166 | typedef struct tagFTBUTTONSSTATE |
| 167 | { |
| 168 | bool uploadBtn; |
| 169 | bool downloadBtn; |
| 170 | bool createLocalFldBtn; |
| 171 | bool createRemoteFldBtn; |
| 172 | bool renameLocalBtn; |
| 173 | bool renameRemoteBtn; |
| 174 | bool deleteLocalBtn; |
| 175 | bool deleteRemoteBtn; |
| 176 | bool cancelBtn; |
| 177 | } FTBUTTONSSTATE; |
| 178 | |
| 179 | FTBUTTONSSTATE m_BtnState; |
| 180 | |
| 181 | public: |
| 182 | class CancelingDlg |
| 183 | { |
| 184 | public: |
| 185 | CancelingDlg(FTDialog *pFTDlg); |
| 186 | ~CancelingDlg(); |
| 187 | |
| 188 | static BOOL CALLBACK cancelingDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
| 189 | |
| 190 | bool create(); |
| 191 | bool destroy(); |
| 192 | |
| 193 | private: |
| 194 | FTDialog *m_pFTDlg; |
| 195 | HWND m_hwndDlg; |
| 196 | |
| 197 | bool close(bool bResult); |
| 198 | }; |
| 199 | |
| 200 | private: |
| 201 | CancelingDlg *m_pCancelingDlg; |
| 202 | |
| 203 | public: |
| 204 | class CreateFolderDlg : public Dialog |
| 205 | { |
| 206 | public: |
| 207 | CreateFolderDlg(FTDialog *pFTDlg); |
| 208 | ~CreateFolderDlg(); |
| 209 | |
| 210 | bool onOk(); |
| 211 | bool create(); |
| 212 | char *getFolderName() { return m_szFolderName; } |
| 213 | |
| 214 | protected: |
| 215 | FTDialog *m_pFTDlg; |
| 216 | char m_szFolderName[FT_FILENAME_SIZE]; |
| 217 | }; |
| 218 | |
| 219 | private: |
| 220 | CreateFolderDlg *m_pCreateFolderDlg; |
| 221 | |
| 222 | public: |
| 223 | class RenameDlg : public CreateFolderDlg |
| 224 | { |
| 225 | public: |
| 226 | RenameDlg(FTDialog *pFTDlg); |
| 227 | ~RenameDlg(); |
| 228 | |
| 229 | bool create(char *pFilename, bool bFolder); |
| 230 | void initDialog(); |
| 231 | |
| 232 | private: |
| 233 | bool m_bFolder; |
| 234 | char m_szFilename[FT_FILENAME_SIZE]; |
| 235 | }; |
| 236 | |
| 237 | private: |
| 238 | RenameDlg *m_pRenameDlg; |
| 239 | }; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | #endif // __RFB_WIN32_FTDIALOG_H__ |