]>
Commit | Line | Data |
---|---|---|
f4ada568 GL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: url.h | |
3 | // Purpose: URL parser | |
4 | // Author: Guilhem Lavaux | |
b60b2ec8 | 5 | // Modified by: Ryan Norton |
f4ada568 GL |
6 | // Created: 20/07/1997 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1997, 1998 Guilhem Lavaux | |
65571936 | 9 | // Licence: wxWindows licence |
f4ada568 | 10 | ///////////////////////////////////////////////////////////////////////////// |
f6bcfd97 | 11 | |
f4ada568 GL |
12 | #ifndef _WX_URL_H |
13 | #define _WX_URL_H | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
af49c4b8 | 16 | #pragma interface "url.h" |
f4ada568 GL |
17 | #endif |
18 | ||
a5d46b73 VZ |
19 | #include "wx/defs.h" |
20 | ||
21 | #if wxUSE_URL | |
f4ada568 | 22 | |
b60b2ec8 | 23 | #include "wx/uri.h" |
f4ada568 | 24 | #include "wx/protocol/protocol.h" |
8a4df159 | 25 | |
a5d46b73 | 26 | #if wxUSE_PROTOCOL_HTTP |
8a4df159 RR |
27 | #include "wx/protocol/http.h" |
28 | #endif | |
f4ada568 GL |
29 | |
30 | typedef enum { | |
31 | wxURL_NOERR = 0, | |
32 | wxURL_SNTXERR, | |
33 | wxURL_NOPROTO, | |
34 | wxURL_NOHOST, | |
35 | wxURL_NOPATH, | |
36 | wxURL_CONNERR, | |
37 | wxURL_PROTOERR | |
38 | } wxURLError; | |
a5d46b73 | 39 | |
25959b95 VZ |
40 | #if wxUSE_URL_NATIVE |
41 | class WXDLLIMPEXP_NET wxURL; | |
42 | ||
43 | class WXDLLIMPEXP_NET wxURLNativeImp : public wxObject | |
44 | { | |
45 | public: | |
46 | virtual ~wxURLNativeImp() { } | |
47 | virtual wxInputStream *GetInputStream(wxURL *owner) = 0; | |
48 | }; | |
49 | #endif // wxUSE_URL_NATIVE | |
50 | ||
b60b2ec8 | 51 | class WXDLLIMPEXP_NET wxURL : public wxURI |
b2b35524 | 52 | { |
f4ada568 | 53 | public: |
b60b2ec8 RN |
54 | wxURL(const wxString& sUrl); |
55 | wxURL(const wxURI& url); | |
b2b35524 VZ |
56 | virtual ~wxURL(); |
57 | ||
b60b2ec8 RN |
58 | wxURL& operator = (const wxString& url); |
59 | wxURL& operator = (const wxURI& url); | |
60 | ||
61 | wxString GetProtocolName() const { return m_scheme; } | |
62 | wxString GetHostName() const { return m_server; } | |
f6bcfd97 BP |
63 | wxString GetURL() const { return m_url; } |
64 | wxProtocol& GetProtocol() { return *m_protocol; } | |
65 | wxURLError GetError() const { return m_error; } | |
66 | wxString GetPath() const { return m_path; } | |
f4ada568 | 67 | |
b2b35524 | 68 | wxInputStream *GetInputStream(); |
f4ada568 | 69 | |
b2b35524 VZ |
70 | #if wxUSE_SOCKETS |
71 | static void SetDefaultProxy(const wxString& url_proxy); | |
72 | void SetProxy(const wxString& url_proxy); | |
73 | #endif // wxUSE_SOCKETS | |
f4ada568 | 74 | |
86470d43 RN |
75 | #if WXWIN_COMPATIBILITY_2_4 |
76 | //Use wxURI instead - delims is ignored | |
f6bcfd97 BP |
77 | static wxString ConvertToValidURI( |
78 | const wxString& uri, | |
79 | const wxChar* delims = wxT(";/?:@&=+$,") | |
80 | ); | |
86470d43 RN |
81 | |
82 | //Use wxURI::Unescape instead | |
b2b35524 | 83 | static wxString ConvertFromURI(const wxString& uri); |
86470d43 | 84 | #endif |
b2b35524 VZ |
85 | |
86 | protected: | |
87 | static wxProtoInfo *ms_protocols; | |
f4ada568 | 88 | |
8a4df159 | 89 | #if wxUSE_SOCKETS |
b2b35524 VZ |
90 | static wxHTTP *ms_proxyDefault; |
91 | static bool ms_useDefaultProxy; | |
92 | wxHTTP *m_proxy; | |
93 | #endif // wxUSE_SOCKETS | |
94 | ||
25959b95 VZ |
95 | #if wxUSE_URL_NATIVE |
96 | friend class wxURLNativeImp; | |
97 | // pointer to a native URL implementation object | |
98 | wxURLNativeImp *m_nativeImp; | |
cb719f2e | 99 | // Creates on the heap and returns a native |
25959b95 VZ |
100 | // implementation object for the current platform. |
101 | static wxURLNativeImp *CreateNativeImpObject(); | |
102 | #endif | |
b2b35524 VZ |
103 | wxProtoInfo *m_protoinfo; |
104 | wxProtocol *m_protocol; | |
105 | ||
106 | wxURLError m_error; | |
b60b2ec8 | 107 | wxString m_url; |
b2b35524 VZ |
108 | bool m_useProxy; |
109 | ||
b60b2ec8 | 110 | void Init(const wxString&); |
b2b35524 VZ |
111 | bool ParseURL(); |
112 | void CleanData(); | |
113 | bool FetchProtocol(); | |
114 | ||
115 | friend class wxProtoInfo; | |
116 | friend class wxURLModule; | |
117 | ||
118 | private: | |
b2b35524 | 119 | DECLARE_DYNAMIC_CLASS(wxURL) |
f4ada568 GL |
120 | }; |
121 | ||
a5d46b73 VZ |
122 | #endif // wxUSE_URL |
123 | ||
124 | #endif // _WX_URL_H | |
125 |