WinInterface.h 27 KB

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