SessionInfo.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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, TPromptKind Kind,
  54. AnsiString Name, AnsiString Instructions, TStrings * Prompts,
  55. TStrings * Results) = 0;
  56. virtual void __fastcall DisplayBanner(const AnsiString & Banner) = 0;
  57. virtual void __fastcall ShowExtendedException(Exception * E) = 0;
  58. virtual void __fastcall Closed() = 0;
  59. };
  60. //---------------------------------------------------------------------------
  61. // Duplicated in LogMemo.h for design-time-only purposes
  62. enum TLogLineType { llOutput, llInput, llStdError, llMessage, llException };
  63. //---------------------------------------------------------------------------
  64. typedef void __fastcall (__closure *TCaptureOutputEvent)(
  65. const AnsiString & Str, bool StdError);
  66. typedef void __fastcall (__closure *TCalculatedChecksumEvent)(
  67. const AnsiString & FileName, const AnsiString & Alg, const AnsiString & Hash);
  68. //---------------------------------------------------------------------------
  69. class TCriticalSection;
  70. //---------------------------------------------------------------------------
  71. class TSessionLog : protected TStringList
  72. {
  73. public:
  74. __fastcall TSessionLog(TSessionUI* UI, TSessionData * SessionData,
  75. TConfiguration * Configuration);
  76. __fastcall ~TSessionLog();
  77. HIDESBASE void __fastcall Add(TLogLineType Type, const AnsiString & Line);
  78. void __fastcall AddStartupInfo();
  79. void __fastcall AddException(Exception * E);
  80. void __fastcall AddSeparator();
  81. virtual void __fastcall Clear();
  82. void __fastcall ReflectSettings();
  83. void __fastcall Lock();
  84. void __fastcall Unlock();
  85. __property TSessionLog * Parent = { read = FParent, write = SetParent };
  86. __property bool Logging = { read = FLogging };
  87. __property int BottomIndex = { read = GetBottomIndex };
  88. __property AnsiString Line[int Index] = { read=GetLine };
  89. __property TLogLineType Type[int Index] = { read=GetType };
  90. __property OnChange;
  91. __property AnsiString CurrentFileName = { read = FCurrentFileName };
  92. __property bool LoggingToFile = { read = GetLoggingToFile };
  93. __property int TopIndex = { read = FTopIndex };
  94. __property AnsiString SessionName = { read = GetSessionName };
  95. __property AnsiString Name = { read = FName, write = FName };
  96. __property Count;
  97. protected:
  98. void __fastcall CloseLogFile();
  99. bool __fastcall LogToFile();
  100. private:
  101. TConfiguration * FConfiguration;
  102. TSessionLog * FParent;
  103. TCriticalSection * FCriticalSection;
  104. bool FLogging;
  105. void * FFile;
  106. AnsiString FCurrentLogFileName;
  107. AnsiString FCurrentFileName;
  108. int FLoggedLines;
  109. int FTopIndex;
  110. TSessionUI * FUI;
  111. TSessionData * FSessionData;
  112. AnsiString FName;
  113. AnsiString __fastcall GetLine(int Index);
  114. TLogLineType __fastcall GetType(int Index);
  115. void DeleteUnnecessary();
  116. void OpenLogFile();
  117. int __fastcall GetBottomIndex();
  118. AnsiString __fastcall GetLogFileName();
  119. bool __fastcall GetLoggingToFile();
  120. void __fastcall SetParent(TSessionLog * value);
  121. AnsiString __fastcall GetSessionName();
  122. void __fastcall DoAdd(TLogLineType Type, AnsiString Line,
  123. void __fastcall (__closure *f)(TLogLineType Type, const AnsiString & Line));
  124. void __fastcall DoAddToParent(TLogLineType aType, const AnsiString & aLine);
  125. void __fastcall DoAddToSelf(TLogLineType aType, const AnsiString & aLine);
  126. void __fastcall DoAddStartupInfo(TSessionData * Data);
  127. };
  128. //---------------------------------------------------------------------------
  129. #endif