1
0

Interface.h 6.7 KB

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