1
0

Interface.h 6.4 KB

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