final wxURI API changes. Changed Get to BuildURI to better reflect what its doing...
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "url.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #if wxUSE_URL
22
23 #include "wx/uri.h"
24 #include "wx/protocol/protocol.h"
25
26 #if wxUSE_PROTOCOL_HTTP
27 #include "wx/protocol/http.h"
28 #endif
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;
39
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
51 class WXDLLIMPEXP_NET wxURL : public wxURI
52 {
53 public:
54 wxURL(const wxString& sUrl);
55 wxURL(const wxURI& url);
56 virtual ~wxURL();
57
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; }
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; }
67
68 wxInputStream *GetInputStream();
69
70 #if wxUSE_SOCKETS
71 static void SetDefaultProxy(const wxString& url_proxy);
72 void SetProxy(const wxString& url_proxy);
73 #endif // wxUSE_SOCKETS
74
75 #if WXWIN_COMPATIBILITY_2_4
76 //Use wxURI instead - delims is ignored
77 static wxString ConvertToValidURI(
78 const wxString& uri,
79 const wxChar* delims = wxT(";/?:@&=+$,")
80 );
81
82 //Use wxURI::Unescape instead
83 static wxString ConvertFromURI(const wxString& uri);
84 #endif
85
86 protected:
87 static wxProtoInfo *ms_protocols;
88
89 #if wxUSE_SOCKETS
90 static wxHTTP *ms_proxyDefault;
91 static bool ms_useDefaultProxy;
92 wxHTTP *m_proxy;
93 #endif // wxUSE_SOCKETS
94
95 #if wxUSE_URL_NATIVE
96 friend class wxURLNativeImp;
97 // pointer to a native URL implementation object
98 wxURLNativeImp *m_nativeImp;
99 // Creates on the heap and returns a native
100 // implementation object for the current platform.
101 static wxURLNativeImp *CreateNativeImpObject();
102 #endif
103 wxProtoInfo *m_protoinfo;
104 wxProtocol *m_protocol;
105
106 wxURLError m_error;
107 wxString m_url;
108 bool m_useProxy;
109
110 void Init(const wxString&);
111 bool ParseURL();
112 void CleanData();
113 bool FetchProtocol();
114
115 friend class wxProtoInfo;
116 friend class wxURLModule;
117
118 private:
119 DECLARE_DYNAMIC_CLASS(wxURL)
120 };
121
122 #endif // wxUSE_URL
123
124 #endif // _WX_URL_H
125