]> git.saurik.com Git - wxWidgets.git/blob - include/wx/url.h
wxCocoa: Added (mostly) stubs for wxGLCanvas and friends.
[wxWidgets.git] / include / wx / url.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: url.h
3 // Purpose: URL parser
4 // Author: Guilhem Lavaux
5 // Modified by:
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/object.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 wxObject
52 {
53 public:
54 wxURL(const wxString& url);
55 virtual ~wxURL();
56
57 wxString GetProtocolName() const { return m_protoinfo->m_protoname; }
58 wxString GetHostName() const { return m_hostname; }
59 wxString GetURL() const { return m_url; }
60 wxProtocol& GetProtocol() { return *m_protocol; }
61 wxURLError GetError() const { return m_error; }
62 wxString GetPath() const { return m_path; }
63
64 wxInputStream *GetInputStream();
65
66 #if wxUSE_SOCKETS
67 static void SetDefaultProxy(const wxString& url_proxy);
68 void SetProxy(const wxString& url_proxy);
69 #endif // wxUSE_SOCKETS
70
71 static wxString ConvertToValidURI(
72 const wxString& uri,
73 const wxChar* delims = wxT(";/?:@&=+$,")
74 );
75 static wxString ConvertFromURI(const wxString& uri);
76
77 protected:
78 static wxProtoInfo *ms_protocols;
79
80 #if wxUSE_SOCKETS
81 static wxHTTP *ms_proxyDefault;
82 static bool ms_useDefaultProxy;
83 wxHTTP *m_proxy;
84 #endif // wxUSE_SOCKETS
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
94 wxProtoInfo *m_protoinfo;
95 wxProtocol *m_protocol;
96
97 wxURLError m_error;
98 wxString m_protoname, m_hostname, m_servname, m_path, m_url;
99 wxString m_user, m_password;
100 bool m_useProxy;
101
102 bool PrepProto(wxString& url);
103 bool PrepHost(wxString& url);
104 bool PrepPath(wxString& url);
105 bool ParseURL();
106 void CleanData();
107 bool FetchProtocol();
108
109 friend class wxProtoInfo;
110 friend class wxURLModule;
111
112 private:
113 // VZ: can't use default copy ctor for this class, should write a correct
114 // one! (TODO)
115 DECLARE_NO_COPY_CLASS(wxURL)
116
117 DECLARE_DYNAMIC_CLASS(wxURL)
118 };
119
120 #endif // wxUSE_URL
121
122 #endif // _WX_URL_H
123