X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3f2bcf34371665165e8232c7fdf3776cfff11892..7bccea09a71ae668dc07f6d7c340160c15c33fce:/include/wx/protocol/ftp.h?ds=sidebyside diff --git a/include/wx/protocol/ftp.h b/include/wx/protocol/ftp.h index d687b59e41..9223a90350 100644 --- a/include/wx/protocol/ftp.h +++ b/include/wx/protocol/ftp.h @@ -3,26 +3,29 @@ // Purpose: FTP protocol // Author: Vadim Zeitlin // Modified by: Mark Johnson, wxWindows@mj10777.de -// 20000917 : RmDir, GetLastResult, GetList +// 20000917 : RmDir, GetLastResult, GetList // Created: 07/07/1997 // RCS-ID: $Id$ // Copyright: (c) 1997, 1998 Guilhem Lavaux -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __WX_FTP_H__ #define __WX_FTP_H__ -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "ftp.h" #endif -#include "wx/object.h" +#include "wx/defs.h" + +#if wxUSE_PROTOCOL_FTP + #include "wx/sckaddr.h" #include "wx/protocol/protocol.h" #include "wx/url.h" -class WXDLLEXPORT wxFTP : public wxProtocol +class WXDLLIMPEXP_NET wxFTP : public wxProtocol { public: enum TransferMode @@ -39,7 +42,7 @@ public: void SetUser(const wxString& user) { m_user = user; } void SetPassword(const wxString& passwd) { m_passwd = passwd; } - bool Connect(wxSockAddress& addr, bool wait = TRUE); + bool Connect(wxSockAddress& addr, bool wait = true); bool Connect(const wxString& host); // disconnect @@ -48,6 +51,8 @@ public: // Parameters set up // set transfer mode now + void SetPassive(bool pasv) { m_bPassive = pasv; }; + void SetDefaultTimeout(wxUint32 Value); bool SetBinary() { return SetTransferMode(BINARY); } bool SetAscii() { return SetTransferMode(ASCII); } bool SetTransferMode(TransferMode mode); @@ -101,7 +106,7 @@ public: bool GetFilesList(wxArrayString& files, const wxString& wildcard = wxEmptyString) { - return GetList(files, wildcard, FALSE); + return GetList(files, wildcard, false); } // get a directory list in server dependent format - this can be shown @@ -109,33 +114,40 @@ public: bool GetDirList(wxArrayString& files, const wxString& wildcard = wxEmptyString) { - return GetList(files, wildcard, TRUE); + return GetList(files, wildcard, true); } // equivalent to either GetFilesList() (default) or GetDirList() bool GetList(wxArrayString& files, const wxString& wildcard = wxEmptyString, - bool details = FALSE); - -#ifdef WXWIN_COMPATIBILITY_2 - // deprecated - wxList *GetList(const wxString& wildcard, bool details = FALSE); -#endif // WXWIN_COMPATIBILITY_2 + bool details = false); protected: // this executes a simple ftp command with the given argument and returns - // TRUE if it its return code starts with '2' + // true if it its return code starts with '2' bool DoSimpleCommand(const wxChar *command, const wxString& arg = wxEmptyString); // get the server reply, return the first character of the reply code, - // '1'..'5' for normal FTP replies, 0 (*not* '0') if an error occured + // '1'..'5' for normal FTP replies, 0 (*not* '0') if an error occurred char GetResult(); // check that the result is equal to expected value bool CheckResult(char ch) { return GetResult() == ch; } - wxSocketClient *GetPort(); + // return the socket to be used, Passive/Active versions are used only by + // GetPort() + wxSocketBase *GetPort(); + wxSocketBase *GetPassivePort(); + wxSocketBase *GetActivePort(); + + // helper for GetPort() + wxString GetPortCmdArgument(wxIPV4address Local, wxIPV4address New); + + // accept connection from server in active mode, returns the same socket as + // passed in in passive mode + wxSocketBase *AcceptIfActive(wxSocketBase *sock); + wxString m_user, m_passwd; @@ -153,7 +165,15 @@ protected: friend class wxInputFTPStream; friend class wxOutputFTPStream; - DECLARE_DYNAMIC_CLASS(wxFTP) + bool m_bPassive; + wxUint32 m_uiDefaultTimeout; + + // following is true when a read or write times out, we then assume + // the connection is dead and abort. we avoid additional delays this way + bool m_bEncounteredError; + + + DECLARE_DYNAMIC_CLASS_NO_COPY(wxFTP) DECLARE_PROTOCOL(wxFTP) }; @@ -161,4 +181,6 @@ protected: // wxLog::AddTraceMask(FTP_TRACE_MASK) to see them in output #define FTP_TRACE_MASK _T("ftp") +#endif // wxUSE_PROTOCOL_FTP + #endif // __WX_FTP_H__