Interface.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 __fastcall AppendExceptionStackTraceAndForget(TStrings *& MoreMessages);
  42. void __fastcall IgnoreException(const std::type_info & ExceptionType);
  43. UnicodeString __fastcall GetExceptionDebugInfo();
  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. void Assign(const TQueryParams & Source);
  107. const TQueryButtonAlias * Aliases;
  108. unsigned int AliasesCount;
  109. unsigned int Params;
  110. unsigned int Timer;
  111. TQueryParamsTimerEvent TimerEvent;
  112. UnicodeString TimerMessage;
  113. unsigned int TimerAnswers;
  114. TQueryType TimerQueryType;
  115. unsigned int Timeout;
  116. unsigned int TimeoutAnswer;
  117. unsigned int TimeoutResponse;
  118. unsigned int NoBatchAnswers;
  119. UnicodeString HelpKeyword;
  120. };
  121. enum TPromptKind
  122. {
  123. pkPrompt,
  124. pkFileName,
  125. pkUserName,
  126. pkPassphrase,
  127. pkTIS,
  128. pkCryptoCard,
  129. pkKeybInteractive,
  130. pkPassword,
  131. pkNewPassword,
  132. pkProxyAuth
  133. };
  134. enum TPromptUserParam { pupEcho = 0x01, pupRemember = 0x02 };
  135. bool __fastcall IsAuthenticationPrompt(TPromptKind Kind);
  136. bool __fastcall IsPasswordOrPassphrasePrompt(TPromptKind Kind, TStrings * Prompts);
  137. bool __fastcall IsPasswordPrompt(TPromptKind Kind, TStrings * Prompts);
  138. void __fastcall AnswerNameAndCaption(unsigned int Answer, UnicodeString & Name, UnicodeString & Caption);
  139. //---------------------------------------------------------------------------
  140. typedef void __fastcall (__closure *TFileFoundEvent)
  141. (TTerminal * Terminal, const UnicodeString FileName, const TRemoteFile * File,
  142. bool & Cancel);
  143. typedef void __fastcall (__closure *TFindingFileEvent)
  144. (TTerminal * Terminal, const UnicodeString Directory, bool & Cancel);
  145. //---------------------------------------------------------------------------
  146. class TOperationVisualizer
  147. {
  148. public:
  149. __fastcall TOperationVisualizer(bool UseBusyCursor = true);
  150. __fastcall ~TOperationVisualizer();
  151. private:
  152. bool FUseBusyCursor;
  153. void * FToken;
  154. };
  155. //---------------------------------------------------------------------------
  156. class TInstantOperationVisualizer : public TOperationVisualizer
  157. {
  158. public:
  159. __fastcall TInstantOperationVisualizer();
  160. __fastcall ~TInstantOperationVisualizer();
  161. private:
  162. TDateTime FStart;
  163. };
  164. //---------------------------------------------------------------------------
  165. struct TClipboardHandler
  166. {
  167. UnicodeString Text;
  168. void __fastcall Copy(TObject * /*Sender*/, unsigned int & /*Answer*/)
  169. {
  170. TInstantOperationVisualizer Visualizer;
  171. CopyToClipboard(Text);
  172. }
  173. };
  174. //---------------------------------------------------------------------------
  175. #endif