00001 #ifndef __SERVER_H__ 00002 #define __SERVER_H__ 00003 00004 #include <util/string.h> 00005 #include <util/locker.h> 00006 #include <gui/window.h> 00007 #include <map> 00008 00009 #include "transferthread.h" 00010 #include "queuenode.h" 00011 #include "settings.h" 00012 00013 using namespace os; 00014 00015 class AppSettings; 00016 00024 class Server 00025 { 00026 public: 00027 Server( const String& zURL, os::Window* pcTarget, AppSettings* pcSettings ); 00028 virtual ~Server(); 00029 int Close(); 00030 00031 int Lock(); 00032 int Unlock(); 00033 00034 AppSettings* GetSettings() { return( m_pcSettings ); } 00035 00036 String GetServerAddress(); 00037 const char* GetEntryPath(); 00038 00039 int GetDirListing( const String& zPath, Handler* pcTarger ); 00040 int GetRemote( const String& zRemoteSource, const String& zLocalDest ); 00041 int SendLocal( const String& zLocalSource, const String& zRemoteDest ); 00042 int DeleteRemote( const String& zPath ); 00043 int RemoveRemoteDir( const String& zPath ); 00044 int CreateRemoteDir( const String& zPath ); 00045 int MoveRemote( const String& zOldPath, const String& zNewPath ); 00046 00047 /* Methods for controlling active transfers, eg pause, cancel, resume */ 00048 int PauseTransfer( int nNodeID ); 00049 int ResumeTransfer( int nNodeID ); 00050 int CancelTransfer( int nNodeID ); 00051 00052 /* Methods for letting the server know some of it's downloads have updated. */ 00053 Message* CreateUpdateMessage(); 00054 void Updated( int nID ); 00055 00056 /* Methods for manipulating the queue (ie raise/lower priority of a queued transfer) */ 00057 /* TODO */ 00058 00059 private: 00060 /* These methods are only called from TransferThread */ 00061 00062 virtual CURLcode _SetupCurlHandle( CURL* pHandle ); /* Add our settings to the curl handle */ 00063 00064 private: 00065 00066 String m_zURL; 00068 os::Window* m_pcTarget; 00070 TransferThread* m_pcThread; 00072 AppSettings* m_pcSettings; 00080 std::map< int, QueueNode* > m_apcQueue; 00081 00082 00083 int m_nNextID; 00084 Locker* m_pcLock; 00086 const char* m_pzEntryPath; 00088 friend class TransferThread; 00089 friend class InitializationNode; /* For getting the entry path */ 00090 }; 00091 00099 class FTPServer : public Server 00100 { 00101 public: 00102 FTPServer( const String& zURL, Window* pcTarget, AppSettings* pcSettings ); 00103 00104 // int ParseDirListing( const String& zDir, char* pzBuf, size_t nSize, Handler* pcTarget, bool bInitial ); 00105 00106 private: 00107 ~FTPServer(); 00108 // CURLcode _SetupCurlHandle( CURL* pHandle ); 00109 }; 00110 00111 00112 00113 #endif /* __SERVER_H__ */ 00114