]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/protocol/protocol.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/protocol/protocol.h
3 // Purpose: interface of wxProtocol
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 Error values returned by wxProtocol.
13 wxPROTO_NOERR
= 0, //!< No error.
14 wxPROTO_NETERR
, //!< A generic network error occurred.
15 wxPROTO_PROTERR
, //!< An error occurred during negotiation.
16 wxPROTO_CONNERR
, //!< The client failed to connect the server.
17 wxPROTO_INVVAL
, //!< Invalid value.
18 wxPROTO_NOHNDLR
, //!< Not currently used.
19 wxPROTO_NOFILE
, //!< The remote file doesn't exist.
20 wxPROTO_ABRT
, //!< Last action aborted.
21 wxPROTO_RCNCT
, //!< An error occurred during reconnection.
22 wxPROTO_STREAMING
//!< Someone tried to send a command during a transfer.
28 Represents a protocol for use with wxURL.
30 Note that you may want to change the default time-out for HTTP/FTP connections
31 and network operations (using SetDefaultTimeout()) since the default time-out
32 value is quite long (60 seconds).
37 @see wxSocketBase, wxURL
39 class wxProtocol
: public wxSocketClient
43 Abort the current stream.
46 It is advised to destroy the input stream instead of aborting the stream
49 @return Returns @true, if successful, else @false.
51 virtual bool Abort() = 0;
54 Returns the type of the content of the last opened stream. It is a mime-type.
55 May be an empty string if the content-type is unknown.
57 virtual wxString
GetContentType() const;
60 Returns the last occurred error.
64 virtual wxProtocolError
GetError() const;
67 Creates a new input stream on the specified path.
69 You can use all but seek() functionality of wxStream.
70 Seek() isn't available on all streams. For example, HTTP or FTP streams
71 don't deal with it. Other functions like StreamSize() and Tell() aren't
72 available for the moment for this sort of stream.
73 You will be notified when the EOF is reached by an error.
75 @return Returns the initialized stream. You will have to delete it
76 yourself once you don't use it anymore. The destructor
77 closes the network connection.
81 virtual wxInputStream
* GetInputStream(const wxString
& path
) = 0;
84 Tries to reestablish a previous opened connection (close and renegotiate
87 @return @true, if the connection is established, else @false.
92 Sets the authentication password.
94 virtual void SetPassword(const wxString
& user
);
97 Sets the authentication user.
99 virtual void SetUser(const wxString
& user
);
102 Sets a new default timeout for the network operations.
104 The default timeout is 60 seconds.
106 @see wxSocketBase::SetTimeout
108 void SetDefaultTimeout(wxUint32 Value
);
111 @name Logging support.
113 Each wxProtocol object may have the associated logger (by default there
114 is none) which is used to log network requests and responses.
121 Set the logger, deleting the old one and taking ownership of this one.
124 New logger allocated on the heap or @NULL.
126 void SetLog(wxProtocolLog
*log
);
129 Return the current logger, may be @NULL.
131 wxProtocolLog
*GetLog() const { return m_log
; }
134 Detach the existing logger without deleting it.
136 The caller is responsible for deleting the returned pointer if it's
139 wxProtocolLog
*DetachLog();
142 Call wxProtocolLog::LogRequest() if we have a valid logger or do
145 void LogRequest(const wxString
& str
);
148 Call wxProtocolLog::LogResponse() if we have a valid logger or do
151 void LogResponse(const wxString
& str
);