FileZillaIntf.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. class t_server;
  30. //---------------------------------------------------------------------------
  31. class TFileZillaIntf
  32. {
  33. friend class TFileZillaIntern;
  34. public:
  35. enum TLogLevel
  36. {
  37. LOG_STATUS = 0,
  38. LOG_ERROR = 1,
  39. LOG_COMMAND = 2,
  40. LOG_REPLY = 3,
  41. LOG_LIST = 4,
  42. LOG_APIERROR = 5,
  43. LOG_WARNING = 6,
  44. LOG_INFO = 7,
  45. LOG_DEBUG = 8
  46. };
  47. enum
  48. {
  49. FILEEXISTS_OVERWRITE = 0,
  50. FILEEXISTS_OVERWRITEIFNEWER = 1,
  51. FILEEXISTS_RESUME = 2,
  52. FILEEXISTS_RENAME = 3,
  53. FILEEXISTS_SKIP = 4,
  54. };
  55. enum
  56. {
  57. REPLY_OK = 0x0001,
  58. REPLY_WOULDBLOCK = 0x0002,
  59. REPLY_ERROR = 0x0004,
  60. REPLY_OWNERNOTSET = 0x0008,
  61. REPLY_INVALIDPARAM = 0x0010,
  62. REPLY_NOTCONNECTED = 0x0020,
  63. REPLY_ALREADYCONNECTED = 0x0040,
  64. REPLY_BUSY = 0x0080,
  65. REPLY_IDLE = 0x0100,
  66. REPLY_NOTINITIALIZED = 0x0200,
  67. REPLY_ALREADYINIZIALIZED = 0x0400,
  68. REPLY_CANCEL = 0x0800,
  69. REPLY_DISCONNECTED = 0x1000, // Always sent when disconnected from server
  70. REPLY_CRITICALERROR = 0x2000, // Used for FileTransfers only
  71. REPLY_ABORTED = 0x4000, // Used for FileTransfers only
  72. REPLY_NOTSUPPORTED = 0x8000 // Command is not supported for the current server
  73. };
  74. static void __fastcall Initialize();
  75. static void __fastcall Finalize();
  76. static void __fastcall SetResourceModule(void * ResourceHandle);
  77. __fastcall TFileZillaIntf();
  78. __fastcall ~TFileZillaIntf();
  79. bool __fastcall Init();
  80. void __fastcall Destroying();
  81. bool __fastcall SetCurrentPath(const char * Path);
  82. bool __fastcall GetCurrentPath(char * Path, size_t MaxLen);
  83. bool __fastcall Cancel();
  84. bool __fastcall Connect(const char * Host, int Port, const char * User,
  85. const char * Pass, const char * Account, bool FwByPass,
  86. const char * Path, int ServerType, int Pasv, int TimeZoneOffset, int UTF8);
  87. bool __fastcall Close();
  88. bool __fastcall List();
  89. bool __fastcall List(const char * Path);
  90. bool __fastcall CustomCommand(const char * Command);
  91. bool __fastcall MakeDir(const char* Path);
  92. bool __fastcall Chmod(int Value, const char* FileName, const char* Path);
  93. bool __fastcall Delete(const char* FileName, const char* Path);
  94. bool __fastcall RemoveDir(const char* FileName, const char* Path);
  95. bool __fastcall Rename(const char* OldName, const char* NewName,
  96. const char* Path, const char* NewPath);
  97. bool __fastcall FileTransfer(const char * LocalFile, const char * RemoteFile,
  98. const char * RemotePath, bool Get, __int64 Size, int Type, void * UserData);
  99. virtual const char * __fastcall Option(int OptionID) const = 0;
  100. virtual int __fastcall OptionVal(int OptionID) const = 0;
  101. void __fastcall SetDebugLevel(TLogLevel Level);
  102. bool __fastcall HandleMessage(WPARAM wParam, LPARAM lParam);
  103. protected:
  104. bool __fastcall PostMessage(WPARAM wParam, LPARAM lParam);
  105. virtual bool __fastcall DoPostMessage(WPARAM wParam, LPARAM lParam) = 0;
  106. virtual bool __fastcall HandleStatus(const char * Status, int Type) = 0;
  107. virtual bool __fastcall HandleAsynchRequestOverwrite(
  108. char * FileName1, size_t FileName1Len, const char * FileName2,
  109. const char * Path1, const char * Path2,
  110. __int64 Size1, __int64 Size2, time_t Time1, time_t Time2,
  111. bool HasTime1, bool HasTime2, void * UserData, int & RequestResult) = 0;
  112. virtual bool __fastcall HandleListData(const char * Path, const TListDataEntry * Entries,
  113. unsigned int Count) = 0;
  114. virtual bool __fastcall HandleTransferStatus(bool Valid, __int64 TransferSize,
  115. __int64 Bytes, int Percent, int TimeElapsed, int TimeLeft, int TransferRate,
  116. bool FileTransfer) = 0;
  117. virtual bool __fastcall HandleReply(int Command, unsigned int Reply) = 0;
  118. virtual bool __fastcall CheckError(int ReturnCode, const char * Context);
  119. inline bool __fastcall Check(int ReturnCode, const char * Context, int Expected = -1);
  120. private:
  121. CFileZillaApi * FFileZillaApi;
  122. TFileZillaIntern * FIntern;
  123. t_server * FServer;
  124. };
  125. //---------------------------------------------------------------------------
  126. #endif // FileZillaIntfH