SessionInfo.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //---------------------------------------------------------------------------
  2. #ifndef SessionInfoH
  3. #define SessionInfoH
  4. #include "SessionData.h"
  5. #include "Interface.h"
  6. //---------------------------------------------------------------------------
  7. enum TSessionStatus { ssClosed, ssOpening, ssOpened };
  8. //---------------------------------------------------------------------------
  9. struct TSessionInfo
  10. {
  11. TSessionInfo();
  12. TDateTime LoginTime;
  13. AnsiString ProtocolBaseName;
  14. AnsiString ProtocolName;
  15. AnsiString SecurityProtocolName;
  16. AnsiString CSCipher;
  17. AnsiString CSCompression;
  18. AnsiString SCCipher;
  19. AnsiString SCCompression;
  20. AnsiString SshVersionString;
  21. AnsiString SshImplementation;
  22. AnsiString HostKeyFingerprint;
  23. };
  24. //---------------------------------------------------------------------------
  25. enum TFSCapability { fcUserGroupListing, fcModeChanging, fcGroupChanging,
  26. fcOwnerChanging, fcAnyCommand, fcHardLink, fcSymbolicLink, fcResolveSymlink,
  27. fcTextMode, fcRename, fcNativeTextMode, fcNewerOnlyUpload, fcRemoteCopy,
  28. fcTimestampChanging, fcRemoteMove, fcLoadingAdditionalProperties,
  29. fcCheckingSpaceAvailable, fcIgnorePermErrors, fcCalculatingChecksum,
  30. fcModeChangingUpload, fcPreservingTimestampUpload, fcShellAnyCommand,
  31. fcSecondaryShell, fcCount };
  32. //---------------------------------------------------------------------------
  33. struct TFileSystemInfo
  34. {
  35. TFileSystemInfo();
  36. AnsiString ProtocolBaseName;
  37. AnsiString ProtocolName;
  38. AnsiString RemoteSystem;
  39. AnsiString AdditionalInfo;
  40. bool IsCapable[fcCount];
  41. };
  42. //---------------------------------------------------------------------------
  43. class TSessionUI
  44. {
  45. public:
  46. virtual void __fastcall Information(const AnsiString & Str, bool Status) = 0;
  47. virtual int __fastcall QueryUser(const AnsiString Query,
  48. TStrings * MoreMessages, int Answers, const TQueryParams * Params,
  49. TQueryType QueryType = qtConfirmation) = 0;
  50. virtual int __fastcall QueryUserException(const AnsiString Query,
  51. Exception * E, int Answers, const TQueryParams * Params,
  52. TQueryType QueryType = qtConfirmation) = 0;
  53. virtual bool __fastcall PromptUser(TSessionData * Data, AnsiString Prompt,
  54. TPromptKind Kind, AnsiString & Response) = 0;
  55. virtual void __fastcall DisplayBanner(const AnsiString & Banner) = 0;
  56. virtual void __fastcall ShowExtendedException(Exception * E) = 0;
  57. virtual void __fastcall Closed() = 0;
  58. };
  59. //---------------------------------------------------------------------------
  60. // Duplicated in LogMemo.h for design-time-only purposes
  61. enum TLogLineType { llOutput, llInput, llStdError, llMessage, llException };
  62. //---------------------------------------------------------------------------
  63. typedef void __fastcall (__closure *TCaptureOutputEvent)(
  64. const AnsiString & Str, bool StdError);
  65. typedef void __fastcall (__closure *TCalculatedChecksumEvent)(
  66. const AnsiString & FileName, const AnsiString & Alg, const AnsiString & Hash);
  67. //---------------------------------------------------------------------------
  68. class TCriticalSection;
  69. //---------------------------------------------------------------------------
  70. class TSessionLog : protected TStringList
  71. {
  72. public:
  73. __fastcall TSessionLog(TSessionUI* UI, TSessionData * SessionData,
  74. TConfiguration * Configuration);
  75. __fastcall ~TSessionLog();
  76. HIDESBASE void __fastcall Add(TLogLineType Type, const AnsiString & Line);
  77. void __fastcall AddStartupInfo();
  78. void __fastcall AddException(Exception * E);
  79. void __fastcall AddSeparator();
  80. virtual void __fastcall Clear();
  81. void __fastcall ReflectSettings();
  82. void __fastcall Lock();
  83. void __fastcall Unlock();
  84. __property TSessionLog * Parent = { read = FParent, write = SetParent };
  85. __property bool Logging = { read = FLogging };
  86. __property int BottomIndex = { read = GetBottomIndex };
  87. __property AnsiString Line[int Index] = { read=GetLine };
  88. __property TLogLineType Type[int Index] = { read=GetType };
  89. __property OnChange;
  90. __property AnsiString CurrentFileName = { read = FCurrentFileName };
  91. __property bool LoggingToFile = { read = GetLoggingToFile };
  92. __property int TopIndex = { read = FTopIndex };
  93. __property AnsiString SessionName = { read = GetSessionName };
  94. __property AnsiString Name = { read = FName, write = FName };
  95. __property Count;
  96. protected:
  97. void __fastcall CloseLogFile();
  98. bool __fastcall LogToFile();
  99. private:
  100. TConfiguration * FConfiguration;
  101. TSessionLog * FParent;
  102. TCriticalSection * FCriticalSection;
  103. bool FLogging;
  104. void * FFile;
  105. AnsiString FCurrentLogFileName;
  106. AnsiString FCurrentFileName;
  107. int FLoggedLines;
  108. int FTopIndex;
  109. TSessionUI * FUI;
  110. TSessionData * FSessionData;
  111. AnsiString FName;
  112. AnsiString __fastcall GetLine(int Index);
  113. TLogLineType __fastcall GetType(int Index);
  114. void DeleteUnnecessary();
  115. void OpenLogFile();
  116. int __fastcall GetBottomIndex();
  117. AnsiString __fastcall GetLogFileName();
  118. bool __fastcall GetLoggingToFile();
  119. void __fastcall SetParent(TSessionLog * value);
  120. AnsiString __fastcall GetSessionName();
  121. void __fastcall DoAdd(TLogLineType Type, AnsiString Line,
  122. void __fastcall (__closure *f)(TLogLineType Type, const AnsiString & Line));
  123. void __fastcall DoAddToParent(TLogLineType aType, const AnsiString & aLine);
  124. void __fastcall DoAddToSelf(TLogLineType aType, const AnsiString & aLine);
  125. void __fastcall DoAddStartupInfo(TSessionData * Data);
  126. };
  127. //---------------------------------------------------------------------------
  128. #endif