]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/protocol/protocol.h
Document wxHTTP::SetPostBuffer().
[wxWidgets.git] / interface / wx / protocol / protocol.h
CommitLineData
23324ae1 1/////////////////////////////////////////////////////////////////////////////
0576cd9e 2// Name: wx/protocol/protocol.h
e54c96f1 3// Purpose: interface of wxProtocol
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
a30b5ab9
FM
9/**
10 Error values returned by wxProtocol.
11*/
12enum wxProtocolError
13{
14 wxPROTO_NOERR = 0, //!< No error.
15 wxPROTO_NETERR, //!< A generic network error occurred.
16 wxPROTO_PROTERR, //!< An error occurred during negotiation.
17 wxPROTO_CONNERR, //!< The client failed to connect the server.
18 wxPROTO_INVVAL, //!< Invalid value.
19 wxPROTO_NOHNDLR, //!< Not currently used.
20 wxPROTO_NOFILE, //!< The remote file doesn't exist.
21 wxPROTO_ABRT, //!< Last action aborted.
22 wxPROTO_RCNCT, //!< An error occurred during reconnection.
23 wxPROTO_STREAMING //!< Someone tried to send a command during a transfer.
24};
25
23324ae1
FM
26/**
27 @class wxProtocol
7c913512 28
a30b5ab9 29 Represents a protocol for use with wxURL.
7c913512 30
730b772b
FM
31 Note that you may want to change the default time-out for HTTP/FTP connections
32 and network operations (using SetDefaultTimeout()) since the default time-out
33 value is quite long (60 seconds).
34
23324ae1 35 @library{wxnet}
a30b5ab9 36 @category{net}
7c913512 37
e54c96f1 38 @see wxSocketBase, wxURL
23324ae1
FM
39*/
40class wxProtocol : public wxSocketClient
41{
42public:
43 /**
44 Abort the current stream.
a30b5ab9
FM
45
46 @warning
47 It is advised to destroy the input stream instead of aborting the stream
48 this way.
49
d29a9a8a 50 @return Returns @true, if successful, else @false.
23324ae1 51 */
da1ed74c 52 virtual bool Abort() = 0;
23324ae1
FM
53
54 /**
55 Returns the type of the content of the last opened stream. It is a mime-type.
730b772b 56 May be an empty string if the content-type is unknown.
23324ae1 57 */
730b772b 58 virtual wxString GetContentType() const;
23324ae1
FM
59
60 /**
61 Returns the last occurred error.
a30b5ab9
FM
62
63 @see wxProtocolError
23324ae1 64 */
730b772b 65 virtual wxProtocolError GetError() const;
23324ae1
FM
66
67 /**
a30b5ab9
FM
68 Creates a new input stream on the specified path.
69
70 You can use all but seek() functionality of wxStream.
71 Seek() isn't available on all streams. For example, HTTP or FTP streams
72 don't deal with it. Other functions like StreamSize() and Tell() aren't
73 available for the moment for this sort of stream.
23324ae1 74 You will be notified when the EOF is reached by an error.
a30b5ab9 75
d29a9a8a 76 @return Returns the initialized stream. You will have to delete it
4cc4bfaf
FM
77 yourself once you don't use it anymore. The destructor
78 closes the network connection.
a30b5ab9 79
4cc4bfaf 80 @see wxInputStream
23324ae1 81 */
da1ed74c 82 virtual wxInputStream* GetInputStream(const wxString& path) = 0;
23324ae1
FM
83
84 /**
85 Tries to reestablish a previous opened connection (close and renegotiate
86 connection).
a30b5ab9 87
d29a9a8a 88 @return @true, if the connection is established, else @false.
23324ae1
FM
89 */
90 bool Reconnect();
91
92 /**
730b772b 93 Sets the authentication password.
23324ae1 94 */
adaaa686 95 virtual void SetPassword(const wxString& user);
23324ae1
FM
96
97 /**
730b772b 98 Sets the authentication user.
23324ae1 99 */
adaaa686 100 virtual void SetUser(const wxString& user);
730b772b
FM
101
102 /**
103 Sets a new default timeout for the network operations.
104
105 The default timeout is 60 seconds.
106
107 @see wxSocketBase::SetTimeout
108 */
109 void SetDefaultTimeout(wxUint32 Value);
0576cd9e
VZ
110
111 /**
112 @name Logging support.
113
114 Each wxProtocol object may have the associated logger (by default there
115 is none) which is used to log network requests and responses.
116
117 @see wxProtocolLog
118 */
119 //@{
120
121 /**
122 Set the logger, deleting the old one and taking ownership of this one.
123
124 @param log
125 New logger allocated on the heap or @NULL.
126 */
127 void SetLog(wxProtocolLog *log);
128
129 /**
130 Return the current logger, may be @NULL.
131 */
132 wxProtocolLog *GetLog() const { return m_log; }
133
134 /**
135 Detach the existing logger without deleting it.
136
137 The caller is responsible for deleting the returned pointer if it's
138 non-@c NULL.
139 */
140 wxProtocolLog *DetachLog();
141
142 /**
143 Call wxProtocolLog::LogRequest() if we have a valid logger or do
144 nothing otherwise.
145 */
146 void LogRequest(const wxString& str);
147
148 /**
149 Call wxProtocolLog::LogResponse() if we have a valid logger or do
150 nothing otherwise.
151 */
152 void LogResponse(const wxString& str);
153
154 //@}
23324ae1 155};
e54c96f1 156