ftptrans.h

00001 #ifndef FTPTRANS_H
00002 #define FTPTRANS_H
00003 
00004 #include <vector>
00005 #include <defs.h>
00006 #include <swbuf.h>
00007 
00008 //SWORD_NAMESPACE_START
00009 
00010 
00011 // move this include to cpp once struct ftpparse isn't exposed anymore
00012 extern "C" {
00013 #include <ftpparse.h>
00014 }
00015 
00016 SWORD_NAMESPACE_START
00017 
00020 class SWDLLEXPORT StatusReporter {
00021 public:
00022         virtual ~StatusReporter() {};
00024         virtual void preStatus(long totalBytes, long completedBytes, const char *message);
00025         
00027         virtual void statusUpdate(double dtTotal, double dlNow);
00028 };
00029 
00030 
00034 class SWDLLEXPORT FTPTransport {
00035 
00036 protected:
00037         StatusReporter *statusReporter;
00038         bool passive;
00039         bool term;
00040         SWBuf host;
00041         
00042 public:
00043         FTPTransport(const char *host, StatusReporter *statusReporter = 0);
00044         virtual ~FTPTransport();
00045 
00046         /***********
00047          * override this method in your real impl
00048          * 
00049          * if destBuf then write to buffer instead of file
00050          */
00051         virtual char getURL(const char *destPath, const char *sourceURL, SWBuf *destBuf = 0);
00052 
00053 
00054         int copyDirectory(const char *urlPrefix, const char *dir, const char *dest, const char *suffix);
00055 
00056         virtual std::vector<struct DirEntry> getDirList(const char *dirURL);
00057         void setPassive(bool passive) { this->passive = passive; }
00058         void terminate() { term = true; }
00059 };
00060 
00061 
00062 SWORD_NAMESPACE_END
00063 
00064 #endif