]> git.saurik.com Git - wxWidgets.git/blob - include/wx/url.h
Extract PipeIOHandler class into a header and rename to wxWakeUpPipe.
[wxWidgets.git] / include / wx / url.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/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& uri);
52 wxURL(const wxURL& url);
53 virtual ~wxURL();
54
55 wxURL& operator = (const wxString& url);
56 wxURL& operator = (const wxURI& uri);
57 wxURL& operator = (const wxURL& url);
58
59 wxProtocol& GetProtocol() { return *m_protocol; }
60 wxURLError GetError() const { return m_error; }
61 wxString GetURL() const { return m_url; }
62
63 wxURLError SetURL(const wxString &url)
64 { *this = url; return m_error; }
65
66 bool IsOk() const
67 { return m_error == wxURL_NOERR; }
68
69 wxInputStream *GetInputStream();
70
71 #if wxUSE_PROTOCOL_HTTP
72 static void SetDefaultProxy(const wxString& url_proxy);
73 void SetProxy(const wxString& url_proxy);
74 #endif // wxUSE_PROTOCOL_HTTP
75
76 protected:
77 static wxProtoInfo *ms_protocols;
78
79 #if wxUSE_PROTOCOL_HTTP
80 static wxHTTP *ms_proxyDefault;
81 static bool ms_useDefaultProxy;
82 wxHTTP *m_proxy;
83 bool m_useProxy;
84 #endif // wxUSE_PROTOCOL_HTTP
85
86 #if wxUSE_URL_NATIVE
87 friend class wxURLNativeImp;
88 // pointer to a native URL implementation object
89 wxURLNativeImp *m_nativeImp;
90 // Creates on the heap and returns a native
91 // implementation object for the current platform.
92 static wxURLNativeImp *CreateNativeImpObject();
93 #endif // wxUSE_URL_NATIVE
94
95 wxProtoInfo *m_protoinfo;
96 wxProtocol *m_protocol;
97
98 wxURLError m_error;
99 wxString m_url;
100
101 void Init(const wxString&);
102 bool ParseURL();
103 void CleanData();
104 void Free();
105 bool FetchProtocol();
106
107 friend class wxProtoInfo;
108 friend class wxURLModule;
109
110 private:
111 DECLARE_DYNAMIC_CLASS(wxURL)
112 };
113
114 #endif // wxUSE_URL
115
116 #endif // _WX_URL_H
117