Interface.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. //---------------------------------------------------------------------------
  2. #ifndef InterfaceH
  3. #define InterfaceH
  4. //---------------------------------------------------------------------------
  5. #include "Configuration.h"
  6. #include "SessionData.h"
  7. #include <typeinfo>
  8. #define HELP_NONE ""
  9. #define SCRIPT_SWITCH "script"
  10. #define COMMAND_SWITCH L"Command"
  11. #define SESSIONNAME_SWICH L"SessionName"
  12. #define NEWPASSWORD_SWITCH L"newpassword"
  13. #define INI_NUL L"nul"
  14. #define PRESERVETIME_SWITCH L"preservetime"
  15. #define PRESERVETIMEDIRS_SWITCH_VALUE L"all"
  16. #define NOPRESERVETIME_SWITCH L"nopreservetime"
  17. #define PERMISSIONS_SWITCH L"permissions"
  18. #define NOPERMISSIONS_SWITCH L"nopermissions"
  19. #define SPEED_SWITCH L"speed"
  20. #define TRANSFER_SWITCH L"transfer"
  21. #define FILEMASK_SWITCH L"filemask"
  22. #define RESUMESUPPORT_SWITCH L"resumesupport"
  23. #define NEWERONLY_SWICH L"neweronly"
  24. #define NONEWERONLY_SWICH L"noneweronly"
  25. #define DELETE_SWITCH L"delete"
  26. #define REFRESH_SWITCH L"refresh"
  27. extern const wchar_t * TransferModeNames[];
  28. extern const int TransferModeNamesCount;
  29. extern const wchar_t * ToggleNames[];
  30. enum TToggle { ToggleOff, ToggleOn };
  31. //---------------------------------------------------------------------------
  32. TConfiguration * __fastcall CreateConfiguration();
  33. class TOptions;
  34. TOptions * __fastcall GetGlobalOptions();
  35. void __fastcall ShowExtendedException(Exception * E);
  36. bool __fastcall AppendExceptionStackTraceAndForget(TStrings *& MoreMessages);
  37. void __fastcall IgnoreException(const std::type_info & ExceptionType);
  38. UnicodeString __fastcall GetExceptionDebugInfo();
  39. UnicodeString __fastcall GetCompanyRegistryKey();
  40. UnicodeString __fastcall GetRegistryKey();
  41. void * __fastcall BusyStart();
  42. void __fastcall BusyEnd(void * Token);
  43. const unsigned int GUIUpdateInterval = 100;
  44. void __fastcall SetNoGUI();
  45. bool __fastcall ProcessGUI(bool Force = false);
  46. UnicodeString __fastcall AppNameString();
  47. UnicodeString __fastcall SshVersionString();
  48. void __fastcall CopyToClipboard(UnicodeString Text);
  49. int __fastcall StartThread(void * SecurityAttributes, unsigned StackSize,
  50. TThreadFunc ThreadFunc, void * Parameter, unsigned CreationFlags,
  51. TThreadID & ThreadId);
  52. bool __fastcall TextFromClipboard(UnicodeString & Text, bool Trim);
  53. // Order of the values also define order of the buttons/answers on the prompts
  54. // MessageDlg relies on these to be <= 0x0000FFFF
  55. const unsigned int qaYes = 0x00000001;
  56. // MessageDlg relies that answer do not conflict with mrCancel (=0x2)
  57. const unsigned int qaNo = 0x00000004;
  58. const unsigned int qaOK = 0x00000008;
  59. const unsigned int qaCancel = 0x00000010;
  60. const unsigned int qaYesToAll = 0x00000020;
  61. const unsigned int qaNoToAll = 0x00000040;
  62. const unsigned int qaAbort = 0x00000080;
  63. const unsigned int qaRetry = 0x00000100;
  64. const unsigned int qaIgnore = 0x00000200;
  65. const unsigned int qaSkip = 0x00000400;
  66. const unsigned int qaAll = 0x00000800;
  67. const unsigned int qaHelp = 0x00001000;
  68. const unsigned int qaReport = 0x00002000;
  69. const unsigned int qaFirst = qaYes;
  70. const unsigned int qaLast = qaReport;
  71. const unsigned int qaNeverAskAgain = 0x00010000;
  72. const int qpFatalAbort = 0x01;
  73. const int qpNeverAskAgainCheck = 0x02;
  74. const int qpAllowContinueOnError = 0x04;
  75. const int qpIgnoreAbort = 0x08;
  76. const int qpWaitInBatch = 0x10;
  77. typedef void __fastcall (__closure *TButtonSubmitEvent)(TObject * Sender, unsigned int & Answer);
  78. struct TQueryButtonAlias
  79. {
  80. TQueryButtonAlias();
  81. unsigned int Button;
  82. UnicodeString Alias;
  83. TButtonSubmitEvent OnSubmit;
  84. int GroupWith;
  85. TShiftState GrouppedShiftState;
  86. bool ElevationRequired;
  87. bool MenuButton;
  88. UnicodeString ActionAlias;
  89. static TQueryButtonAlias CreateYesToAllGrouppedWithYes();
  90. static TQueryButtonAlias CreateNoToAllGrouppedWithNo();
  91. static TQueryButtonAlias CreateAllAsYesToNewerGrouppedWithYes();
  92. static TQueryButtonAlias CreateIgnoreAsRenameGrouppedWithNo();
  93. };
  94. typedef void __fastcall (__closure *TQueryParamsTimerEvent)(unsigned int & Result);
  95. enum TQueryType { qtConfirmation, qtWarning, qtError, qtInformation };
  96. struct TQueryParams
  97. {
  98. TQueryParams(unsigned int AParams = 0, UnicodeString AHelpKeyword = HELP_NONE);
  99. TQueryParams(const TQueryParams & Source);
  100. void Assign(const TQueryParams & Source);
  101. const TQueryButtonAlias * Aliases;
  102. unsigned int AliasesCount;
  103. unsigned int Params;
  104. unsigned int Timer;
  105. TQueryParamsTimerEvent TimerEvent;
  106. UnicodeString TimerMessage;
  107. unsigned int TimerAnswers;
  108. TQueryType TimerQueryType;
  109. unsigned int Timeout;
  110. unsigned int TimeoutAnswer;
  111. unsigned int NoBatchAnswers;
  112. UnicodeString HelpKeyword;
  113. };
  114. enum TPromptKind
  115. {
  116. pkPrompt,
  117. pkFileName,
  118. pkUserName,
  119. pkPassphrase,
  120. pkTIS,
  121. pkCryptoCard,
  122. pkKeybInteractive,
  123. pkPassword,
  124. pkNewPassword
  125. };
  126. enum TPromptUserParam { pupEcho = 0x01, pupRemember = 0x02 };
  127. bool __fastcall IsAuthenticationPrompt(TPromptKind Kind);
  128. bool __fastcall IsPasswordOrPassphrasePrompt(TPromptKind Kind, TStrings * Prompts);
  129. bool __fastcall IsPasswordPrompt(TPromptKind Kind, TStrings * Prompts);
  130. //---------------------------------------------------------------------------
  131. typedef void __fastcall (__closure *TFileFoundEvent)
  132. (TTerminal * Terminal, const UnicodeString FileName, const TRemoteFile * File,
  133. bool & Cancel);
  134. typedef void __fastcall (__closure *TFindingFileEvent)
  135. (TTerminal * Terminal, const UnicodeString Directory, bool & Cancel);
  136. //---------------------------------------------------------------------------
  137. class TOperationVisualizer
  138. {
  139. public:
  140. __fastcall TOperationVisualizer(bool UseBusyCursor = true);
  141. __fastcall ~TOperationVisualizer();
  142. private:
  143. bool FUseBusyCursor;
  144. void * FToken;
  145. };
  146. //---------------------------------------------------------------------------
  147. class TInstantOperationVisualizer : public TOperationVisualizer
  148. {
  149. public:
  150. __fastcall TInstantOperationVisualizer();
  151. __fastcall ~TInstantOperationVisualizer();
  152. private:
  153. TDateTime FStart;
  154. };
  155. //---------------------------------------------------------------------------
  156. struct TClipboardHandler
  157. {
  158. UnicodeString Text;
  159. void __fastcall Copy(TObject * /*Sender*/, unsigned int & /*Answer*/)
  160. {
  161. TInstantOperationVisualizer Visualizer;
  162. CopyToClipboard(Text);
  163. }
  164. };
  165. //---------------------------------------------------------------------------
  166. #endif