WinInterface.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. //---------------------------------------------------------------------------
  2. #ifndef WinInterfaceH
  3. #define WinInterfaceH
  4. //---------------------------------------------------------------------------
  5. #include <Classes.hpp>
  6. #include <Buttons.hpp>
  7. #include <Interface.h>
  8. #include <WinConfiguration.h>
  9. #include <Terminal.h>
  10. #include <SynchronizeController.h>
  11. #include <Script.h>
  12. #ifdef LOCALINTERFACE
  13. #include <LocalInterface.h>
  14. #endif
  15. #define SITE_ICON 1
  16. #define SITE_FOLDER_ICON 2
  17. #define WORKSPACE_ICON 3
  18. class TStoredSessionList;
  19. class TConfiguration;
  20. class TTerminal;
  21. const int mpNeverAskAgainCheck = 0x01;
  22. const int mpAllowContinueOnError = 0x02;
  23. #define UPLOAD_IF_ANY_SWITCH L"UploadIfAny"
  24. #define UPLOAD_SWITCH L"Upload"
  25. #define SYNCHRONIZE_SWITCH L"Synchronize"
  26. #define KEEP_UP_TO_DATE_SWITCH L"KeepUpToDate"
  27. #define JUMPLIST_SWITCH L"JumpList"
  28. #define DESKTOP_SWITCH L"Desktop"
  29. #define SEND_TO_HOOK_SWITCH L"SendToHook"
  30. #define UNSAFE_SWITCH L"Unsafe"
  31. #define DEFAULTS_SWITCH L"Defaults"
  32. #define NEWINSTANCE_SWICH L"NewInstance"
  33. #define KEYGEN_SWITCH L"KeyGen"
  34. #define KEYGEN_OUTPUT_SWITCH L"Output"
  35. #define KEYGEN_COMMENT_SWITCH L"Comment"
  36. #define KEYGEN_CHANGE_PASSPHRASE_SWITCH L"ChangePassphrase"
  37. #define LOG_SWITCH L"Log"
  38. #define LOGSIZE_SWITCH L"LogSize"
  39. #define LOGSIZE_SEPARATOR L"*"
  40. #define INI_SWITCH L"Ini"
  41. #define RAW_CONFIG_SWITCH L"RawConfig"
  42. #define FINGERPRINTSCAN_SWITCH L"FingerprintScan"
  43. #define DUMPCALLSTACK_SWITCH L"DumpCallstack"
  44. #define INFO_SWITCH L"Info"
  45. #define COMREGISTRATION_SWITCH L"ComRegistration"
  46. #define BROWSE_SWITCH L"Browse"
  47. #define NOINTERACTIVEINPUT_SWITCH L"NoInteractiveInput"
  48. #define STDOUT_SWITCH L"StdOut"
  49. #define STDIN_SWITCH L"StdIn"
  50. #define DUMPCALLSTACK_EVENT L"WinSCPCallstack%d"
  51. struct TMessageParams
  52. {
  53. TMessageParams(unsigned int AParams = 0);
  54. TMessageParams(const TQueryParams * AParams);
  55. const TQueryButtonAlias * Aliases;
  56. unsigned int AliasesCount;
  57. unsigned int Params;
  58. unsigned int Timer;
  59. TQueryParamsTimerEvent TimerEvent;
  60. UnicodeString TimerMessage;
  61. unsigned int TimerAnswers;
  62. TQueryType TimerQueryType;
  63. unsigned int Timeout;
  64. unsigned int TimeoutAnswer;
  65. UnicodeString NeverAskAgainTitle;
  66. unsigned int NeverAskAgainAnswer;
  67. bool NeverAskAgainCheckedInitially;
  68. bool AllowHelp;
  69. UnicodeString ImageName;
  70. UnicodeString MoreMessagesUrl;
  71. TSize MoreMessagesSize;
  72. UnicodeString CustomCaption;
  73. private:
  74. inline void Reset();
  75. };
  76. class TCustomScpExplorerForm;
  77. TCustomScpExplorerForm * __fastcall CreateScpExplorer();
  78. void __fastcall ConfigureInterface();
  79. void __fastcall DoProductLicense();
  80. extern const UnicodeString AppName;
  81. void __fastcall SetOnForeground(bool OnForeground);
  82. void __fastcall FlashOnBackground();
  83. void __fastcall TerminateApplication();
  84. void __fastcall ShowExtendedExceptionEx(TTerminal * Terminal, Exception * E);
  85. void __fastcall FormHelp(TCustomForm * Form);
  86. void __fastcall SearchHelp(const UnicodeString & Message);
  87. void __fastcall MessageWithNoHelp(const UnicodeString & Message);
  88. class TProgramParams;
  89. bool __fastcall CheckSafe(TProgramParams * Params);
  90. void __fastcall CheckLogParam(TProgramParams * Params);
  91. bool __fastcall CheckXmlLogParam(TProgramParams * Params);
  92. UnicodeString __fastcall GetToolbarKey(const UnicodeString & ToolbarName);
  93. UnicodeString __fastcall GetToolbarsLayoutStr(TControl * OwnerControl);
  94. void __fastcall LoadToolbarsLayoutStr(TControl * OwnerControl, UnicodeString LayoutStr);
  95. namespace Tb2item { class TTBCustomItem; }
  96. namespace Tbx { class TTBXSeparatorItem; }
  97. Tbx::TTBXSeparatorItem * __fastcall AddMenuSeparator(Tb2item::TTBCustomItem * Menu);
  98. void __fastcall AddMenuLabel(Tb2item::TTBCustomItem * Menu, const UnicodeString & Label);
  99. void __fastcall ClickToolbarItem(Tb2item::TTBCustomItem * Item, bool PositionCursor);
  100. void InitiateDialogTimeout(TForm * Dialog, unsigned int Timeout, TButton * Button);
  101. // windows\WinHelp.cpp
  102. void __fastcall InitializeWinHelp();
  103. void __fastcall FinalizeWinHelp();
  104. // windows\WinInterface.cpp
  105. unsigned int __fastcall MessageDialog(const UnicodeString Msg, TQueryType Type,
  106. unsigned int Answers, UnicodeString HelpKeyword = HELP_NONE, const TMessageParams * Params = NULL);
  107. unsigned int __fastcall MessageDialog(int Ident, TQueryType Type,
  108. unsigned int Answers, UnicodeString HelpKeyword = HELP_NONE, const TMessageParams * Params = NULL);
  109. unsigned int __fastcall SimpleErrorDialog(const UnicodeString Msg, const UnicodeString MoreMessages = L"");
  110. unsigned int __fastcall MoreMessageDialog(const UnicodeString Message,
  111. TStrings * MoreMessages, TQueryType Type, unsigned int Answers,
  112. UnicodeString HelpKeyword, const TMessageParams * Params = NULL);
  113. unsigned int __fastcall ExceptionMessageDialog(Exception * E, TQueryType Type,
  114. const UnicodeString MessageFormat = L"", unsigned int Answers = qaOK,
  115. UnicodeString HelpKeyword = HELP_NONE, const TMessageParams * Params = NULL);
  116. unsigned int __fastcall FatalExceptionMessageDialog(Exception * E, TQueryType Type,
  117. int SessionReopenTimeout, const UnicodeString MessageFormat = L"", unsigned int Answers = qaOK,
  118. UnicodeString HelpKeyword = HELP_NONE, const TMessageParams * Params = NULL);
  119. // forms\Custom.cpp
  120. TSessionData * __fastcall DoSaveSession(TSessionData * SessionData,
  121. TSessionData * OriginalSession, bool ForceDialog,
  122. TStrings * AdditionalFolders);
  123. void __fastcall SessionNameValidate(const UnicodeString & Text,
  124. const UnicodeString & OriginalName);
  125. bool __fastcall DoSaveWorkspaceDialog(UnicodeString & WorkspaceName,
  126. bool * SavePasswords, bool NotRecommendedSavingPasswords,
  127. bool & CreateShortcut, bool & EnableAutoSave);
  128. class TShortCuts;
  129. bool __fastcall DoShortCutDialog(TShortCut & ShortCut,
  130. const TShortCuts & ShortCuts, UnicodeString HelpKeyword);
  131. bool __fastcall DoCustomCommandOptionsDialog(
  132. const TCustomCommandType * Command, TStrings * CustomCommandOptions, TShortCut * ShortCut, unsigned int Flags,
  133. TCustomCommand * CustomCommandForOptions, const UnicodeString & Site, const TShortCuts * ShortCuts);
  134. void __fastcall DoUsageStatisticsDialog();
  135. void __fastcall DoSiteRawDialog(TSessionData * Data);
  136. // windows\UserInterface.cpp
  137. bool __fastcall DoMasterPasswordDialog();
  138. bool __fastcall DoChangeMasterPasswordDialog(UnicodeString & NewPassword);
  139. // windows\WinMain.cpp
  140. int __fastcall Execute();
  141. void __fastcall GetLoginData(UnicodeString SessionName, TOptions * Options,
  142. TObjectList * DataList, UnicodeString & DownloadFile, bool NeedSession, TForm * LinkedForm, int Flags = 0);
  143. // forms\InputDlg.cpp
  144. struct TInputDialogData
  145. {
  146. TCustomEdit * Edit;
  147. };
  148. typedef void __fastcall (__closure *TInputDialogInitialize)
  149. (TObject * Sender, TInputDialogData * Data);
  150. bool __fastcall InputDialog(const UnicodeString ACaption,
  151. const UnicodeString APrompt, UnicodeString & Value, UnicodeString HelpKeyword = HELP_NONE,
  152. TStrings * History = NULL, bool PathInput = false,
  153. TInputDialogInitialize OnInitialize = NULL, bool Echo = true);
  154. // forms\About.cpp
  155. struct TRegistration
  156. {
  157. bool Registered;
  158. UnicodeString Subject;
  159. int Licenses;
  160. UnicodeString ProductId;
  161. bool NeverExpires;
  162. TDateTime Expiration;
  163. bool EduLicense;
  164. TNotifyEvent OnRegistrationLink;
  165. };
  166. void __fastcall DoAboutDialog(TConfiguration * Configuration,
  167. bool AllowLicense, TRegistration * Registration);
  168. void __fastcall DoAboutDialog(TConfiguration *Configuration);
  169. // forms\Cleanup.cpp
  170. bool __fastcall DoCleanupDialog();
  171. void __fastcall DoCleanupDialogIfAnyDataAndWanted();
  172. // forms\Console.cpp
  173. void __fastcall DoConsoleDialog(TTerminal * Terminal,
  174. const UnicodeString Command = L"", const TStrings * Log = NULL);
  175. // forms\Copy.cpp
  176. const coTemp = 0x001;
  177. const coDisableQueue = 0x002;
  178. const coDisableDirectory = 0x008; // not used anymore
  179. const coDoNotShowAgain = 0x020;
  180. const coDisableSaveSettings = 0x040; // not used anymore
  181. const coDoNotUsePresets = 0x080; // not used anymore
  182. const coAllowRemoteTransfer = 0x100;
  183. const coNoQueue = 0x200;
  184. const coShortCutHint = 0x800;
  185. const coAllFiles = 0x1000;
  186. const cooDoNotShowAgain = 0x01;
  187. const cooRemoteTransfer = 0x02;
  188. const cooSaveSettings = 0x04;
  189. bool __fastcall DoCopyDialog(
  190. bool ToRemote, bool Move, TStrings * FileList, UnicodeString & TargetDirectory,
  191. TGUICopyParamType * Params, int Options, int CopyParamAttrs,
  192. TSessionData * SessionData, int * OutputOptions, int AutoSubmit);
  193. // forms\CreateDirectory.cpp
  194. bool __fastcall DoCreateDirectoryDialog(UnicodeString & Directory,
  195. TRemoteProperties * Properties, int AllowedChanges, bool & SaveSettings);
  196. // forms\ImportSessions.cpp
  197. bool __fastcall DoImportSessionsDialog(TList * Imported);
  198. // forms\License.cpp
  199. enum TLicense { lcNoLicense = -1, lcWinScp, lcExpat };
  200. void __fastcall DoLicenseDialog(TLicense License);
  201. bool __fastcall DoLoginDialog(TList * DataList, TForm * LinkedForm);
  202. // forms\SiteAdvanced.cpp
  203. bool __fastcall DoSiteAdvancedDialog(TSessionData * SessionData);
  204. // forms\OpenDirectory.cpp
  205. enum TOpenDirectoryMode { odBrowse, odAddBookmark };
  206. bool __fastcall DoOpenDirectoryDialog(TOpenDirectoryMode Mode, TOperationSide Side,
  207. UnicodeString & Directory, TStrings * Directories, TTerminal * Terminal,
  208. bool AllowSwitch);
  209. // forms\LocatinoProfiles.cpp
  210. bool __fastcall LocationProfilesDialog(TOpenDirectoryMode Mode,
  211. TOperationSide Side, UnicodeString & LocalDirectory, UnicodeString & RemoteDirectory,
  212. TStrings * LocalDirectories, TStrings * RemoteDirectories, TTerminal * Terminal);
  213. // forms\Preferences.cpp
  214. enum TPreferencesMode { pmDefault, pmEditor, pmCustomCommands,
  215. pmQueue, pmLogging, pmUpdates, pmPresets, pmEditors, pmCommander,
  216. pmEditorInternal, pmFileColors };
  217. class TCopyParamRuleData;
  218. struct TPreferencesDialogData
  219. {
  220. TCopyParamRuleData * CopyParamRuleData;
  221. };
  222. bool __fastcall DoPreferencesDialog(TPreferencesMode APreferencesMode,
  223. TPreferencesDialogData * DialogData = NULL);
  224. // forms\CustomCommand.cpp
  225. class TCustomCommandList;
  226. class TCustomCommandType;
  227. class TShortCuts;
  228. enum TCustomCommandsMode { ccmAdd, ccmEdit, ccmAdHoc };
  229. const ccoDisableRemote = 0x01;
  230. const ccoDisableRemoteFiles = 0x02;
  231. typedef void __fastcall (__closure *TCustomCommandValidate)
  232. (const TCustomCommandType & Command);
  233. bool __fastcall DoCustomCommandDialog(TCustomCommandType & Command,
  234. const TCustomCommandList * CustomCommandList,
  235. TCustomCommandsMode Mode, int Options, TCustomCommandValidate OnValidate,
  236. const TShortCuts * ShortCuts);
  237. // forms\CopyParamPreset.cpp
  238. class TCopyParamList;
  239. enum TCopyParamPresetMode { cpmAdd, cpmAddCurrent, cpmEdit, cpmDuplicate };
  240. bool __fastcall DoCopyParamPresetDialog(TCopyParamList * CopyParamList,
  241. int & Index, TCopyParamPresetMode Mode, TCopyParamRuleData * CurrentRuleData,
  242. const TCopyParamType & DefaultCopyParams);
  243. // forms\CopyParamCsutom.cpp
  244. bool __fastcall DoCopyParamCustomDialog(TCopyParamType & CopyParam,
  245. int CopyParamAttrs);
  246. // forms\Properties.cpp
  247. class TRemoteProperties;
  248. class TRemoteTokenList;
  249. struct TCalculateSizeStats;
  250. const cpMode = 0x01;
  251. const cpOwner = 0x02;
  252. const cpGroup = 0x04;
  253. typedef void __fastcall (__closure *TCalculateSizeEvent)
  254. (TStrings * FileList, __int64 & Size, TCalculateSizeStats & Stats,
  255. bool & Close);
  256. typedef void __fastcall (__closure *TCalculatedChecksumCallbackEvent)(
  257. const UnicodeString & FileName, const UnicodeString & Alg, const UnicodeString & Hash);
  258. typedef void __fastcall (__closure *TCalculateChecksumEvent)
  259. (const UnicodeString & Alg, TStrings * FileList,
  260. TCalculatedChecksumCallbackEvent OnCalculatedChecksum, bool & Close);
  261. bool __fastcall DoPropertiesDialog(TStrings * FileList,
  262. const UnicodeString Directory, const TRemoteTokenList * GroupList,
  263. const TRemoteTokenList * UserList, TStrings * ChecksumAlgs,
  264. TRemoteProperties * Properties,
  265. int AllowedChanges, bool UserGroupByID, TCalculateSizeEvent OnCalculateSize,
  266. TCalculateChecksumEvent OnCalculateChecksum);
  267. bool __fastcall DoRemoteMoveDialog(bool Multi, UnicodeString & Target, UnicodeString & FileMask);
  268. enum TDirectRemoteCopy { drcDisallow, drcAllow, drcConfirmCommandSession };
  269. bool __fastcall DoRemoteCopyDialog(TStrings * Sessions, TStrings * Directories,
  270. TDirectRemoteCopy AllowDirectCopy, bool Multi, void *& Session,
  271. UnicodeString & Target, UnicodeString & FileMask, bool & DirectCopy, void * CurrentSession);
  272. // forms\SelectMask.cpp
  273. bool __fastcall DoSelectMaskDialog(TControl * Parent, bool Select, TFileFilter & Filter);
  274. bool __fastcall DoFilterMaskDialog(TControl * Parent, UnicodeString & Mask);
  275. bool __fastcall DoFileColorDialog(TFileColorData & FileColorData);
  276. // forms\EditMask.cpp
  277. bool __fastcall DoEditMaskDialog(TFileMasks & Mask);
  278. // forms\Synchronize.cpp
  279. const soDoNotUsePresets = 0x01;
  280. const soNoMinimize = 0x02;
  281. const soAllowSelectedOnly = 0x04;
  282. typedef void __fastcall (__closure *TGetSynchronizeOptionsEvent)
  283. (int Params, TSynchronizeOptions & Options);
  284. typedef void __fastcall (__closure *TSynchronizeSessionLog)
  285. (const UnicodeString & Message);
  286. typedef void __fastcall (__closure *TFeedSynchronizeError)
  287. (const UnicodeString & Message, TStrings * MoreMessages, TQueryType Type,
  288. const UnicodeString & HelpKeyword);
  289. typedef void __fastcall (__closure *TSynchronizeInNewWindow)
  290. (const TSynchronizeParamType & Params, const TCopyParamType * CopyParams);
  291. bool __fastcall DoSynchronizeDialog(TSynchronizeParamType & Params,
  292. const TCopyParamType * CopyParams, TSynchronizeStartStopEvent OnStartStop,
  293. bool & SaveSettings, int Options, int CopyParamAttrs,
  294. TGetSynchronizeOptionsEvent OnGetOptions,
  295. TSynchronizeSessionLog OnSynchronizeSessionLog,
  296. TFeedSynchronizeError & OnFeedSynchronizeError,
  297. TSynchronizeInNewWindow OnSynchronizeInNewWindow,
  298. int AutoSubmit);
  299. // forms\FullSynchronize.cpp
  300. struct TUsableCopyParamAttrs;
  301. enum TSynchronizeMode { smRemote, smLocal, smBoth };
  302. const fsoDisableTimestamp = 0x01;
  303. const fsoDoNotUsePresets = 0x02;
  304. const fsoAllowSelectedOnly = 0x04;
  305. typedef void __fastcall (__closure *TFullSynchronizeInNewWindow)
  306. (TSynchronizeMode Mode, int Params, const UnicodeString & LocalDirectory, const UnicodeString & RemoteDirectory,
  307. const TCopyParamType * CopyParams);
  308. bool __fastcall DoFullSynchronizeDialog(TSynchronizeMode & Mode, int & Params,
  309. UnicodeString & LocalDirectory, UnicodeString & RemoteDirectory,
  310. TCopyParamType * CopyParams, bool & SaveSettings, bool & SaveMode,
  311. int Options, const TUsableCopyParamAttrs & CopyParamAttrs,
  312. TFullSynchronizeInNewWindow OnFullSynchronizeInNewWindow, int AutoSubmit);
  313. // forms\SynchronizeChecklist.cpp
  314. class TSynchronizeChecklist;
  315. typedef void __fastcall (__closure *TCustomCommandMenuEvent)
  316. (TAction * Action, TStrings * LocalFileList, TStrings * RemoteFileList);
  317. typedef void __fastcall (__closure *TFullSynchronizeEvent)(
  318. void * Token, TProcessedSynchronizationChecklistItem OnProcessedItem,
  319. TUpdatedSynchronizationChecklistItems OnUpdatedSynchronizationChecklistItems);
  320. typedef void __fastcall (__closure *TSynchronizeChecklistCalculateSize)
  321. (TSynchronizeChecklist * Checklist, const TSynchronizeChecklist::TItemList & Items, void * Token);
  322. typedef void __fastcall (__closure *TSynchronizeMoveEvent)(
  323. TOperationSide Side, const UnicodeString & FileName, const UnicodeString & NewFileName, TRemoteFile * RemoteFile);
  324. typedef void __fastcall (__closure *TSynchronizeBrowseEvent)(
  325. TOperationSide Side, TSynchronizeChecklist::TAction Action, const TSynchronizeChecklist::TItem * Item);
  326. bool __fastcall DoSynchronizeChecklistDialog(TSynchronizeChecklist * Checklist,
  327. TSynchronizeMode Mode, int Params,
  328. const UnicodeString LocalDirectory, const UnicodeString RemoteDirectory,
  329. TCustomCommandMenuEvent OnCustomCommandMenu, TFullSynchronizeEvent OnSynchronize,
  330. TSynchronizeChecklistCalculateSize OnSynchronizeChecklistCalculateSize, TSynchronizeMoveEvent OnSynchronizeMove,
  331. TSynchronizeBrowseEvent OnSynchronizeBrowse, void * Token);
  332. // forms\Editor.cpp
  333. typedef void __fastcall (__closure *TFileClosedEvent)
  334. (TObject * Sender, bool Forced);
  335. typedef void __fastcall (__closure *TAnyModifiedEvent)
  336. (TObject * Sender, bool & Modified);
  337. TForm * __fastcall ShowEditorForm(const UnicodeString FileName, TForm * ParentForm,
  338. TNotifyEvent OnFileChanged, TNotifyEvent OnFileReload, TFileClosedEvent OnClose,
  339. TNotifyEvent OnSaveAll, TAnyModifiedEvent OnAnyModified,
  340. const UnicodeString Caption, bool StandaloneEditor, TColor Color, int InternalEditorEncodingOverride,
  341. bool NewFile);
  342. void __fastcall ReconfigureEditorForm(TForm * Form);
  343. void __fastcall EditorFormFileUploadComplete(TForm * Form);
  344. void __fastcall EditorFormFileSave(TForm * Form);
  345. bool __fastcall IsEditorFormModified(TForm * Form);
  346. bool __fastcall DoSymlinkDialog(UnicodeString & FileName, UnicodeString & PointTo,
  347. TOperationSide Side, bool & SymbolicLink, bool Edit, bool AllowSymbolic);
  348. // forms\FileSystemInfo.cpp
  349. struct TSpaceAvailable;
  350. struct TFileSystemInfo;
  351. struct TSessionInfo;
  352. typedef void __fastcall (__closure *TGetSpaceAvailable)
  353. (const UnicodeString Path, TSpaceAvailable & ASpaceAvailable, bool & Close);
  354. void __fastcall DoFileSystemInfoDialog(
  355. const TSessionInfo & SessionInfo, const TFileSystemInfo & FileSystemInfo,
  356. UnicodeString SpaceAvailablePath, TGetSpaceAvailable OnGetSpaceAvailable);
  357. // forms\MessageDlg.cpp
  358. void __fastcall AnswerNameAndCaption(
  359. unsigned int Answer, UnicodeString & Name, UnicodeString & Caption);
  360. TForm * __fastcall CreateMoreMessageDialog(const UnicodeString & Msg,
  361. TStrings * MoreMessages, TMsgDlgType DlgType, unsigned int Answers,
  362. const TQueryButtonAlias * Aliases, unsigned int AliasesCount,
  363. unsigned int TimeoutAnswer, TButton ** TimeoutButton,
  364. const UnicodeString & ImageName, const UnicodeString & NeverAskAgainCaption,
  365. const UnicodeString & MoreMessagesUrl, TSize MoreMessagesSize,
  366. const UnicodeString & CustomCaption);
  367. TForm * __fastcall CreateMoreMessageDialogEx(const UnicodeString Message, TStrings * MoreMessages,
  368. TQueryType Type, unsigned int Answers, UnicodeString HelpKeyword, const TMessageParams * Params);
  369. unsigned int __fastcall ExecuteMessageDialog(TForm * Dialog, unsigned int Answers, const TMessageParams * Params);
  370. void __fastcall InsertPanelToMessageDialog(TCustomForm * Form, TPanel * Panel);
  371. int __fastcall GetMessageDialogContentWidth(TCustomForm * Form);
  372. void __fastcall NavigateMessageDialogToUrl(TCustomForm * Form, const UnicodeString & Url);
  373. extern const UnicodeString MessagePanelName;
  374. extern const UnicodeString MainMessageLabelName;
  375. extern const UnicodeString MessageLabelName;
  376. extern const UnicodeString YesButtonName;
  377. extern const UnicodeString OKButtonName;
  378. // windows\Console.cpp
  379. enum TConsoleMode
  380. {
  381. cmNone, cmScripting, cmHelp, cmBatchSettings, cmKeyGen, cmFingerprintScan, cmDumpCallstack, cmInfo, cmComRegistration,
  382. };
  383. int __fastcall Console(TConsoleMode Mode);
  384. // forms\EditorPreferences.cpp
  385. enum TEditorPreferencesMode { epmAdd, epmEdit, epmAdHoc };
  386. class TEditorData;
  387. bool __fastcall DoEditorPreferencesDialog(TEditorData * Editor,
  388. bool & Remember, TEditorPreferencesMode Mode, bool MayRemote);
  389. // forms\Find.cpp
  390. typedef void __fastcall (__closure *TFindEvent)
  391. (TTerminal * Terminal, UnicodeString Directory, const TFileMasks & FileMask,
  392. TFileFoundEvent OnFileFound, TFindingFileEvent OnFindingFile);
  393. typedef void __fastcall (__closure *TFocusFileEvent)
  394. (TTerminal * Terminal, const UnicodeString & Path);
  395. typedef void __fastcall (__closure *TFileOperationFinishedEvent)
  396. (const UnicodeString & FileName, bool Success);
  397. typedef void __fastcall (__closure *TFileListOperationEvent)
  398. (TTerminal * Terminal, TStrings * FileList, TFileOperationFinishedEvent OnFileOperationFinished);
  399. void __fastcall ShowFileFindDialog(
  400. TTerminal * Terminal, UnicodeString Directory, TFindEvent OnFind, TFocusFileEvent OnFocusFile,
  401. TFileListOperationEvent OnDeleteFiles, TFileListOperationEvent OnDownloadFiles,
  402. TFileListOperationEvent OnEditFiles);
  403. void __fastcall HideFileFindDialog();
  404. // forms\GenerateUrl.cpp
  405. void __fastcall DoGenerateUrlDialog(TSessionData * Data, TStrings * Paths);
  406. enum TFilesSelected { fsList, fsAll };
  407. void __fastcall DoGenerateTransferCodeDialog(
  408. bool ToRemote, bool Move, int CopyParamAttrs, TSessionData * Data, TFilesSelected FilesSelected,
  409. TStrings * FileList, const UnicodeString & Path, const TCopyParamType & CopyParam);
  410. void __fastcall CopyParamListButton(TButton * Button);
  411. const int cplNone = 0x00;
  412. const int cplCustomizeDefault = 0x02;
  413. const int cplSaveSettings = 0x04;
  414. const int cplGenerateCode = 0x08;
  415. void __fastcall CopyParamListPopup(TRect R, TPopupMenu * Menu,
  416. const TCopyParamType & Param, UnicodeString Preset, TNotifyEvent OnClick,
  417. int Options, int CopyParamAttrs, bool SaveSettings = false);
  418. int __fastcall CopyParamListPopupClick(TObject * Sender,
  419. TCopyParamType & Param, UnicodeString & Preset, int CopyParamAttrs,
  420. bool * SaveSettings = NULL);
  421. void __fastcall MenuPopup(TPopupMenu * Menu, TRect Rect, TComponent * PopupComponent);
  422. void __fastcall MenuPopup(TPopupMenu * Menu, TButton * Button);
  423. void __fastcall MenuPopup(TObject * Sender, const TPoint & MousePos, bool & Handled);
  424. void __fastcall MenuButton(TButton * Button);
  425. TComponent * __fastcall GetPopupComponent(TObject * Sender);
  426. TRect __fastcall CalculatePopupRect(TButton * Button);
  427. TRect __fastcall CalculatePopupRect(TControl * Control, TPoint MousePos);
  428. typedef void __fastcall (__closure *TColorChangeEvent)
  429. (TColor Color);
  430. TPopupMenu * __fastcall CreateSessionColorPopupMenu(TColor Color,
  431. TColorChangeEvent OnColorChange);
  432. void __fastcall CreateSessionColorMenu(TComponent * AOwner, TColor Color,
  433. TColorChangeEvent OnColorChange);
  434. void __fastcall CreateEditorBackgroundColorMenu(TComponent * AOwner, TColor Color,
  435. TColorChangeEvent OnColorChange);
  436. TPopupMenu * __fastcall CreateColorPopupMenu(TColor Color,
  437. TColorChangeEvent OnColorChange);
  438. TColor __fastcall RestoreColor(const UnicodeString & CStr);
  439. UnicodeString __fastcall StoreColor(TColor Color);
  440. void __fastcall FixButtonImage(TButton * Button);
  441. void __fastcall CenterButtonImage(TButton * Button);
  442. void __fastcall UpgradeSpeedButton(TSpeedButton * Button);
  443. int __fastcall AdjustLocaleFlag(const UnicodeString & S, TLocaleFlagOverride LocaleFlagOverride, bool Recommended, int On, int Off);
  444. void __fastcall SetGlobalMinimizeHandler(TCustomForm * Form, TNotifyEvent OnMinimize);
  445. void __fastcall ClearGlobalMinimizeHandler(TNotifyEvent OnMinimize);
  446. void __fastcall CallGlobalMinimizeHandler(TObject * Sender);
  447. bool __fastcall IsApplicationMinimized();
  448. void __fastcall ApplicationMinimize();
  449. void __fastcall ApplicationRestore();
  450. bool __fastcall HandleMinimizeSysCommand(TMessage & Message);
  451. void __fastcall WinInitialize();
  452. void __fastcall WinFinalize();
  453. void __fastcall ShowNotification(TTerminal * Terminal, const UnicodeString & Str,
  454. TQueryType Type);
  455. void __fastcall InitializeShortCutCombo(TComboBox * ComboBox,
  456. const TShortCuts & ShortCuts);
  457. void __fastcall SetShortCutCombo(TComboBox * ComboBox, TShortCut Value);
  458. TShortCut __fastcall GetShortCutCombo(TComboBox * ComboBox);
  459. bool __fastcall IsCustomShortCut(TShortCut ShortCut);
  460. TShortCut __fastcall NormalizeCustomShortCut(TShortCut ShortCut);
  461. UnicodeString DumpCallstackEventName(int ProcessId);
  462. UnicodeString DumpCallstackFileName(int ProcessId);
  463. void CheckConfigurationForceSave();
  464. //---------------------------------------------------------------------------
  465. #define HIDDEN_WINDOW_NAME L"WinSCPHiddenWindow3"
  466. //---------------------------------------------------------------------------
  467. struct TCopyDataMessage
  468. {
  469. enum { CommandCanCommandLine, CommandCommandLine, MainWindowCheck, RefreshPanel };
  470. static const unsigned int Version1 = 1;
  471. unsigned int Version;
  472. unsigned int Command;
  473. union
  474. {
  475. wchar_t CommandLine[10240];
  476. struct
  477. {
  478. wchar_t Session[1024];
  479. wchar_t Path[1024];
  480. } Refresh;
  481. };
  482. TCopyDataMessage()
  483. {
  484. Version = TCopyDataMessage::Version1;
  485. Command = static_cast<unsigned int>(-1);
  486. }
  487. };
  488. //---------------------------------------------------------------------------
  489. class TWinInteractiveCustomCommand : public TInteractiveCustomCommand
  490. {
  491. public:
  492. TWinInteractiveCustomCommand(
  493. TCustomCommand * ChildCustomCommand, const UnicodeString CustomCommandName, const UnicodeString HelpKeyword);
  494. protected:
  495. virtual void __fastcall Prompt(int Index, const UnicodeString & Prompt,
  496. UnicodeString & Value);
  497. virtual void __fastcall Execute(const UnicodeString & Command,
  498. UnicodeString & Value);
  499. virtual void __fastcall PatternHint(int Index, const UnicodeString & Pattern);
  500. private:
  501. UnicodeString FCustomCommandName;
  502. std::map<int, size_t> FIndexes;
  503. TUnicodeStringVector FPrompts;
  504. TUnicodeStringVector FDefaults;
  505. TUnicodeStringVector FValues;
  506. UnicodeString FHelpKeyword;
  507. };
  508. //---------------------------------------------------------------------------
  509. class TTrayIcon
  510. {
  511. public:
  512. __fastcall TTrayIcon(unsigned int Id);
  513. __fastcall ~TTrayIcon();
  514. void __fastcall PopupBalloon(UnicodeString Title, const UnicodeString & Str,
  515. TQueryType QueryType, unsigned int Timeout, TNotifyEvent OnBalloonClick,
  516. TObject * BalloonUserData);
  517. void __fastcall CancelBalloon();
  518. __property bool Visible = { read = FVisible, write = SetVisible };
  519. __property TNotifyEvent OnClick = { read = FOnClick, write = FOnClick };
  520. __property UnicodeString Hint = { read = GetHint, write = SetHint };
  521. protected:
  522. void __fastcall Update();
  523. bool __fastcall Notify(unsigned int Message);
  524. private:
  525. bool FVisible;
  526. NOTIFYICONDATA * FTrayIcon;
  527. TNotifyEvent FOnClick;
  528. TNotifyEvent FOnBalloonClick;
  529. TObject * FBalloonUserData;
  530. UINT FTaskbarCreatedMsg;
  531. void __fastcall WndProc(TMessage & Message);
  532. void __fastcall SetVisible(bool value);
  533. UnicodeString __fastcall GetHint();
  534. void __fastcall SetHint(UnicodeString value);
  535. void __fastcall BalloonCancelled();
  536. };
  537. //---------------------------------------------------------------------------
  538. enum TConsoleFlag
  539. {
  540. cfLimitedOutput,
  541. cfLiveOutput,
  542. cfNoInteractiveInput,
  543. cfInteractive,
  544. cfCommandLineOnly,
  545. cfWantsProgress,
  546. cfStdOut,
  547. cfStdIn
  548. };
  549. //---------------------------------------------------------------------------
  550. class TConsole
  551. {
  552. public:
  553. virtual __fastcall ~TConsole() {};
  554. virtual void __fastcall Print(UnicodeString Str, bool FromBeginning = false, bool Error = false) = 0;
  555. void __fastcall PrintLine(const UnicodeString & Str = UnicodeString(), bool Error = false);
  556. virtual bool __fastcall Input(UnicodeString & Str, bool Echo, unsigned int Timer) = 0;
  557. virtual int __fastcall Choice(
  558. UnicodeString Options, int Cancel, int Break, int Continue, int Timeouted, bool Timeouting, unsigned int Timer,
  559. UnicodeString Message) = 0;
  560. virtual bool __fastcall HasFlag(TConsoleFlag Flag) const = 0;
  561. virtual bool __fastcall PendingAbort() = 0;
  562. virtual void __fastcall SetTitle(UnicodeString Title) = 0;
  563. virtual void __fastcall WaitBeforeExit() = 0;
  564. virtual void __fastcall Progress(TScriptProgress & Progress) = 0;
  565. virtual void __fastcall TransferOut(const unsigned char * Data, size_t Len) = 0;
  566. virtual size_t __fastcall TransferIn(unsigned char * Data, size_t Len) = 0;
  567. virtual UnicodeString __fastcall FinalLogMessage() = 0;
  568. };
  569. //---------------------------------------------------------------------------
  570. int __fastcall HandleException(TConsole * Console, Exception & E);
  571. //---------------------------------------------------------------------------
  572. enum { RESULT_SUCCESS = 0, RESULT_ANY_ERROR = 1 };
  573. //---------------------------------------------------------------------------
  574. #endif // WinInterfaceH