Interface.h 6.7 KB

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