]> git.saurik.com Git - wxWidgets.git/blob - include/wx/url.h
don't use m_useProxy if !wxUSE_PROTOCOL_HTTP (see #10815)
[wxWidgets.git] / include / wx / url.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: url.h
3 // Purpose: URL parser
4 // Author: Guilhem Lavaux
5 // Modified by: Ryan Norton
6 // Created: 20/07/1997
7 // RCS-ID: $Id$
8 // Copyright: (c) 1997, 1998 Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_URL_H
13 #define _WX_URL_H
14
15 #include "wx/defs.h"
16
17 #if wxUSE_URL
18
19 #include "wx/uri.h"
20 #include "wx/protocol/protocol.h"
21
22 #if wxUSE_PROTOCOL_HTTP
23 #include "wx/protocol/http.h"
24 #endif
25
26 typedef enum {
27 wxURL_NOERR = 0,
28 wxURL_SNTXERR,
29 wxURL_NOPROTO,
30 wxURL_NOHOST,
31 wxURL_NOPATH,
32 wxURL_CONNERR,
33 wxURL_PROTOERR
34 } wxURLError;
35
36 #if wxUSE_URL_NATIVE
37 class WXDLLIMPEXP_FWD_NET wxURL;
38
39 class WXDLLIMPEXP_NET wxURLNativeImp : public wxObject
40 {
41 public:
42 virtual ~wxURLNativeImp() { }
43 virtual wxInputStream *GetInputStream(wxURL *owner) = 0;
44 };
45 #endif // wxUSE_URL_NATIVE
46
47 class WXDLLIMPEXP_NET wxURL : public wxURI
48 {
49 public:
50 wxURL(const wxString& sUrl = wxEmptyString);
51 wxURL(const wxURI& url);
52 virtual ~wxURL();
53
54 wxURL& operator = (const wxString& url);
55 wxURL& operator = (const wxURI& url);
56
57 wxProtocol& GetProtocol() { return *m_protocol; }
58 wxURLError GetError() const { return m_error; }
59 wxString GetURL() const { return m_url; }
60
61 wxURLError SetURL(const wxString &url)
62 { *this = url; return m_error; }
63
64 bool IsOk() const
65 { return m_error == wxURL_NOERR; }
66
67 wxInputStream *GetInputStream();
68
69 #if wxUSE_PROTOCOL_HTTP
70 static void SetDefaultProxy(const wxString& url_proxy);
71 void SetProxy(const wxString& url_proxy);
72 #endif // wxUSE_PROTOCOL_HTTP
73
74 protected:
75 static wxProtoInfo *ms_protocols;
76
77 #if wxUSE_PROTOCOL_HTTP
78 static wxHTTP *ms_proxyDefault;
79 static bool ms_useDefaultProxy;
80 wxHTTP *m_proxy;
81 bool m_useProxy;
82 #endif // wxUSE_PROTOCOL_HTTP
83
84 #if wxUSE_URL_NATIVE
85 friend class wxURLNativeImp;
86 // pointer to a native URL implementation object
87 wxURLNativeImp *m_nativeImp;
88 // Creates on the heap and returns a native
89 // implementation object for the current platform.
90 static wxURLNativeImp *CreateNativeImpObject();
91 #endif // wxUSE_URL_NATIVE
92
93 wxProtoInfo *m_protoinfo;
94 wxProtocol *m_protocol;
95
96 wxURLError m_error;
97 wxString m_url;
98
99 void Init(const wxString&);
100 bool ParseURL();
101 void CleanData();
102 bool FetchProtocol();
103
104 friend class wxProtoInfo;
105 friend class wxURLModule;
106
107 private:
108 DECLARE_DYNAMIC_CLASS(wxURL)
109 };
110
111 #endif // wxUSE_URL
112
113 #endif // _WX_URL_H
114