Interface.h 6.7 KB

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