FileZillaIntf.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. //---------------------------------------------------------------------------
  2. #ifndef FileZillaIntfH
  3. #define FileZillaIntfH
  4. //---------------------------------------------------------------------------
  5. #include <time.h>
  6. #include <FileZillaOpt.h>
  7. //---------------------------------------------------------------------------
  8. class CFileZillaApi;
  9. class TFileZillaIntern;
  10. //---------------------------------------------------------------------------
  11. struct TListDataEntry
  12. {
  13. const char * Name;
  14. const char * Permissions;
  15. const char * OwnerGroup;
  16. __int64 Size;
  17. bool Dir;
  18. bool Link;
  19. int Year;
  20. int Month;
  21. int Day;
  22. int Hour;
  23. int Minute;
  24. bool HasTime;
  25. bool HasDate;
  26. const char * LinkTarget;
  27. };
  28. //---------------------------------------------------------------------------
  29. struct TFtpsCertificateData
  30. {
  31. struct TContact
  32. {
  33. const char * Organization;
  34. const char * Unit;
  35. const char * CommonName;
  36. const char * Mail;
  37. const char * Country;
  38. const char * StateProvince;
  39. const char * Town;
  40. const char * Other;
  41. };
  42. TContact Subject;
  43. TContact Issuer;
  44. struct TValidityTime
  45. {
  46. int Year;
  47. int Month;
  48. int Day;
  49. int Hour;
  50. int Min;
  51. int Sec;
  52. };
  53. TValidityTime ValidFrom;
  54. TValidityTime ValidUntil;
  55. const unsigned char * Hash;
  56. static const size_t HashLen = 20;
  57. int VerificationResult;
  58. int VerificationDepth;
  59. };
  60. //---------------------------------------------------------------------------
  61. class t_server;
  62. //---------------------------------------------------------------------------
  63. class TFileZillaIntf
  64. {
  65. friend class TFileZillaIntern;
  66. public:
  67. enum TLogLevel
  68. {
  69. LOG_STATUS = 0,
  70. LOG_ERROR = 1,
  71. LOG_COMMAND = 2,
  72. LOG_REPLY = 3,
  73. LOG_LIST = 4,
  74. LOG_APIERROR = 5,
  75. LOG_WARNING = 6,
  76. LOG_INFO = 7,
  77. LOG_DEBUG = 8
  78. };
  79. enum TMessageType
  80. {
  81. MSG_OTHER = 0,
  82. MSG_TRANSFERSTATUS = 1
  83. };
  84. enum
  85. {
  86. FILEEXISTS_OVERWRITE = 0,
  87. FILEEXISTS_OVERWRITEIFNEWER = 1,
  88. FILEEXISTS_RESUME = 2,
  89. FILEEXISTS_RENAME = 3,
  90. FILEEXISTS_SKIP = 4,
  91. };
  92. enum
  93. {
  94. REPLY_OK = 0x0001,
  95. REPLY_WOULDBLOCK = 0x0002,
  96. REPLY_ERROR = 0x0004,
  97. REPLY_OWNERNOTSET = 0x0008,
  98. REPLY_INVALIDPARAM = 0x0010,
  99. REPLY_NOTCONNECTED = 0x0020,
  100. REPLY_ALREADYCONNECTED = 0x0040,
  101. REPLY_BUSY = 0x0080,
  102. REPLY_IDLE = 0x0100,
  103. REPLY_NOTINITIALIZED = 0x0200,
  104. REPLY_ALREADYINIZIALIZED = 0x0400,
  105. REPLY_CANCEL = 0x0800,
  106. REPLY_DISCONNECTED = 0x1000, // Always sent when disconnected from server
  107. REPLY_CRITICALERROR = 0x2000, // Used for FileTransfers only
  108. REPLY_ABORTED = 0x4000, // Used for FileTransfers only
  109. REPLY_NOTSUPPORTED = 0x8000 // Command is not supported for the current server
  110. };
  111. enum
  112. {
  113. SERVER_FTP = 0x1000,
  114. SERVER_FTP_SSL_IMPLICIT = 0x1100,
  115. SERVER_FTP_SSL_EXPLICIT = 0x1200,
  116. SERVER_FTP_TLS_EXPLICIT = 0x1400
  117. };
  118. static void __fastcall Initialize();
  119. static void __fastcall Finalize();
  120. static void __fastcall SetResourceModule(void * ResourceHandle);
  121. __fastcall TFileZillaIntf();
  122. __fastcall ~TFileZillaIntf();
  123. bool __fastcall Init();
  124. void __fastcall Destroying();
  125. bool __fastcall SetCurrentPath(const char * Path);
  126. bool __fastcall GetCurrentPath(char * Path, size_t MaxLen);
  127. bool __fastcall Cancel();
  128. bool __fastcall Connect(const char * Host, int Port, const char * User,
  129. const char * Pass, const char * Account, bool FwByPass,
  130. const char * Path, int ServerType, int Pasv, int TimeZoneOffset, int UTF8,
  131. int iForcePasvIp);
  132. bool __fastcall Close();
  133. bool __fastcall List();
  134. bool __fastcall List(const char * Path);
  135. bool __fastcall CustomCommand(const char * Command);
  136. bool __fastcall MakeDir(const char* Path);
  137. bool __fastcall Chmod(int Value, const char* FileName, const char* Path);
  138. bool __fastcall Delete(const char* FileName, const char* Path);
  139. bool __fastcall RemoveDir(const char* FileName, const char* Path);
  140. bool __fastcall Rename(const char* OldName, const char* NewName,
  141. const char* Path, const char* NewPath);
  142. bool __fastcall FileTransfer(const char * LocalFile, const char * RemoteFile,
  143. const char * RemotePath, bool Get, __int64 Size, int Type, void * UserData);
  144. virtual const char * __fastcall Option(int OptionID) const = 0;
  145. virtual int __fastcall OptionVal(int OptionID) const = 0;
  146. void __fastcall SetDebugLevel(TLogLevel Level);
  147. bool __fastcall HandleMessage(WPARAM wParam, LPARAM lParam);
  148. protected:
  149. bool __fastcall PostMessage(WPARAM wParam, LPARAM lParam);
  150. virtual bool __fastcall DoPostMessage(TMessageType Type, WPARAM wParam, LPARAM lParam) = 0;
  151. virtual bool __fastcall HandleStatus(const char * Status, int Type) = 0;
  152. virtual bool __fastcall HandleAsynchRequestOverwrite(
  153. char * FileName1, size_t FileName1Len, const char * FileName2,
  154. const char * Path1, const char * Path2,
  155. __int64 Size1, __int64 Size2, time_t Time1, time_t Time2,
  156. bool HasTime1, bool HasTime2, void * UserData, int & RequestResult) = 0;
  157. virtual bool __fastcall HandleAsynchRequestVerifyCertificate(
  158. const TFtpsCertificateData & Data, int & RequestResult) = 0;
  159. virtual bool __fastcall HandleListData(const char * Path, const TListDataEntry * Entries,
  160. unsigned int Count) = 0;
  161. virtual bool __fastcall HandleTransferStatus(bool Valid, __int64 TransferSize,
  162. __int64 Bytes, int Percent, int TimeElapsed, int TimeLeft, int TransferRate,
  163. bool FileTransfer) = 0;
  164. virtual bool __fastcall HandleReply(int Command, unsigned int Reply) = 0;
  165. virtual bool __fastcall HandleCapabilities(bool Mfmt) = 0;
  166. virtual bool __fastcall CheckError(int ReturnCode, const char * Context);
  167. inline bool __fastcall Check(int ReturnCode, const char * Context, int Expected = -1);
  168. private:
  169. CFileZillaApi * FFileZillaApi;
  170. TFileZillaIntern * FIntern;
  171. t_server * FServer;
  172. };
  173. //---------------------------------------------------------------------------
  174. #endif // FileZillaIntfH