Interface.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. #define RAWTRANSFERSETTINGS_SWITCH L"rawtransfersettings"
  28. #define USERNAME_SWITCH L"username"
  29. #define PASSWORD_SWITCH L"password"
  30. #define PRIVATEKEY_SWITCH L"privatekey"
  31. #define PASSWORDSFROMFILES_SWITCH L"passwordsfromfiles"
  32. extern const wchar_t * TransferModeNames[];
  33. extern const int TransferModeNamesCount;
  34. extern const wchar_t * ToggleNames[];
  35. enum TToggle { ToggleOff, ToggleOn };
  36. //---------------------------------------------------------------------------
  37. TConfiguration * __fastcall CreateConfiguration();
  38. class TOptions;
  39. TOptions * __fastcall GetGlobalOptions();
  40. void __fastcall ShowExtendedException(Exception * E);
  41. bool AppendExceptionStackTrace(Exception * E, TStrings *& MoreMessages);
  42. void __fastcall IgnoreException(const std::type_info & ExceptionType);
  43. UnicodeString GetExceptionDebugInfo(Exception * E);
  44. UnicodeString __fastcall GetCompanyRegistryKey();
  45. UnicodeString __fastcall GetRegistryKey();
  46. void * __fastcall BusyStart();
  47. void __fastcall BusyEnd(void * Token);
  48. const unsigned int GUIUpdateInterval = 100;
  49. void __fastcall SetNoGUI();
  50. bool __fastcall ProcessGUI(bool Force = false);
  51. void SystemRequired();
  52. UnicodeString __fastcall AppNameString();
  53. UnicodeString __fastcall SshVersionString();
  54. void __fastcall CopyToClipboard(UnicodeString Text);
  55. int __fastcall StartThread(void * SecurityAttributes, unsigned StackSize,
  56. TThreadFunc ThreadFunc, void * Parameter, unsigned CreationFlags,
  57. TThreadID & ThreadId);
  58. bool __fastcall TextFromClipboard(UnicodeString & Text, bool Trim);
  59. // Order of the values also define order of the buttons/answers on the prompts
  60. // MessageDlg relies on these to be <= 0x0000FFFF
  61. const unsigned int qaYes = 0x00000001;
  62. // MessageDlg relies that answer do not conflict with mrCancel (=0x2)
  63. const unsigned int qaNo = 0x00000004;
  64. const unsigned int qaOK = 0x00000008;
  65. const unsigned int qaCancel = 0x00000010;
  66. const unsigned int qaYesToAll = 0x00000020;
  67. const unsigned int qaNoToAll = 0x00000040;
  68. const unsigned int qaAbort = 0x00000080;
  69. const unsigned int qaRetry = 0x00000100;
  70. const unsigned int qaIgnore = 0x00000200;
  71. const unsigned int qaSkip = 0x00000400;
  72. const unsigned int qaAll = 0x00000800;
  73. const unsigned int qaHelp = 0x00001000;
  74. const unsigned int qaReport = 0x00002000;
  75. const unsigned int qaFirst = qaYes;
  76. const unsigned int qaLast = qaReport;
  77. const unsigned int qaNeverAskAgain = 0x00010000;
  78. const int qpFatalAbort = 0x01;
  79. const int qpNeverAskAgainCheck = 0x02;
  80. const int qpAllowContinueOnError = 0x04;
  81. const int qpIgnoreAbort = 0x08;
  82. const int qpWaitInBatch = 0x10;
  83. typedef void __fastcall (__closure *TButtonSubmitEvent)(TObject * Sender, unsigned int & Answer);
  84. struct TQueryButtonAlias
  85. {
  86. TQueryButtonAlias();
  87. unsigned int Button;
  88. UnicodeString Alias;
  89. TButtonSubmitEvent OnSubmit;
  90. int GroupWith;
  91. TShiftState GrouppedShiftState;
  92. bool ElevationRequired;
  93. bool MenuButton;
  94. UnicodeString ActionAlias;
  95. static TQueryButtonAlias CreateYesToAllGrouppedWithYes();
  96. static TQueryButtonAlias CreateNoToAllGrouppedWithNo();
  97. static TQueryButtonAlias CreateAllAsYesToNewerGrouppedWithYes();
  98. static TQueryButtonAlias CreateIgnoreAsRenameGrouppedWithNo();
  99. };
  100. typedef void __fastcall (__closure *TQueryParamsTimerEvent)(unsigned int & Result);
  101. enum TQueryType { qtConfirmation, qtWarning, qtError, qtInformation };
  102. struct TQueryParams
  103. {
  104. TQueryParams(unsigned int AParams = 0, UnicodeString AHelpKeyword = HELP_NONE);
  105. TQueryParams(const TQueryParams & Source);
  106. TQueryParams & operator =(const TQueryParams &) = default;
  107. void Assign(const TQueryParams & Source);
  108. const TQueryButtonAlias * Aliases;
  109. unsigned int AliasesCount;
  110. unsigned int Params;
  111. unsigned int Timer;
  112. TQueryParamsTimerEvent TimerEvent;
  113. UnicodeString TimerMessage;
  114. unsigned int TimerAnswers;
  115. TQueryType TimerQueryType;
  116. unsigned int Timeout;
  117. unsigned int TimeoutAnswer;
  118. unsigned int TimeoutResponse;
  119. unsigned int NoBatchAnswers;
  120. UnicodeString HelpKeyword;
  121. };
  122. enum TPromptKind
  123. {
  124. pkPrompt,
  125. pkFileName,
  126. pkUserName,
  127. pkPassphrase,
  128. pkTIS,
  129. pkCryptoCard,
  130. pkKeybInteractive,
  131. pkPassword,
  132. pkNewPassword,
  133. pkProxyAuth
  134. };
  135. enum TPromptUserParam { pupEcho = 0x01, pupRemember = 0x02 };
  136. bool __fastcall IsAuthenticationPrompt(TPromptKind Kind);
  137. bool __fastcall IsPasswordOrPassphrasePrompt(TPromptKind Kind, TStrings * Prompts);
  138. bool __fastcall IsPasswordPrompt(TPromptKind Kind, TStrings * Prompts);
  139. void __fastcall AnswerNameAndCaption(unsigned int Answer, UnicodeString & Name, UnicodeString & Caption);
  140. //---------------------------------------------------------------------------
  141. typedef void __fastcall (__closure *TFileFoundEvent)
  142. (TTerminal * Terminal, const UnicodeString FileName, const TRemoteFile * File,
  143. bool & Cancel);
  144. typedef void __fastcall (__closure *TFindingFileEvent)
  145. (TTerminal * Terminal, const UnicodeString Directory, bool & Cancel);
  146. //---------------------------------------------------------------------------
  147. class TOperationVisualizer
  148. {
  149. public:
  150. __fastcall TOperationVisualizer(bool UseBusyCursor = true);
  151. __fastcall ~TOperationVisualizer();
  152. private:
  153. bool FUseBusyCursor;
  154. void * FToken;
  155. };
  156. //---------------------------------------------------------------------------
  157. class TInstantOperationVisualizer : public TOperationVisualizer
  158. {
  159. public:
  160. __fastcall TInstantOperationVisualizer();
  161. __fastcall ~TInstantOperationVisualizer();
  162. private:
  163. TDateTime FStart;
  164. };
  165. //---------------------------------------------------------------------------
  166. struct TClipboardHandler
  167. {
  168. UnicodeString Text;
  169. void __fastcall Copy(TObject * /*Sender*/, unsigned int & /*Answer*/)
  170. {
  171. TInstantOperationVisualizer Visualizer;
  172. CopyToClipboard(Text);
  173. }
  174. };
  175. //---------------------------------------------------------------------------
  176. #endif