]>
Commit | Line | Data |
---|---|---|
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(__APPLE__) | |
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 | class WXDLLIMPEXP_BASE wxURL : public wxObject | |
41 | { | |
42 | public: | |
43 | wxURL(const wxString& url); | |
44 | virtual ~wxURL(); | |
45 | ||
46 | wxString GetProtocolName() const { return m_protoinfo->m_protoname; } | |
47 | wxString GetHostName() const { return m_hostname; } | |
48 | wxString GetURL() const { return m_url; } | |
49 | wxProtocol& GetProtocol() { return *m_protocol; } | |
50 | wxURLError GetError() const { return m_error; } | |
51 | wxString GetPath() const { return m_path; } | |
52 | ||
53 | wxInputStream *GetInputStream(); | |
54 | ||
55 | #if wxUSE_SOCKETS | |
56 | static void SetDefaultProxy(const wxString& url_proxy); | |
57 | void SetProxy(const wxString& url_proxy); | |
58 | #endif // wxUSE_SOCKETS | |
59 | ||
60 | static wxString ConvertToValidURI( | |
61 | const wxString& uri, | |
62 | const wxChar* delims = wxT(";/?:@&=+$,") | |
63 | ); | |
64 | static wxString ConvertFromURI(const wxString& uri); | |
65 | ||
66 | protected: | |
67 | static wxProtoInfo *ms_protocols; | |
68 | ||
69 | #if wxUSE_SOCKETS | |
70 | static wxHTTP *ms_proxyDefault; | |
71 | static bool ms_useDefaultProxy; | |
72 | wxHTTP *m_proxy; | |
73 | #endif // wxUSE_SOCKETS | |
74 | ||
75 | wxProtoInfo *m_protoinfo; | |
76 | wxProtocol *m_protocol; | |
77 | ||
78 | wxURLError m_error; | |
79 | wxString m_protoname, m_hostname, m_servname, m_path, m_url; | |
80 | wxString m_user, m_password; | |
81 | bool m_useProxy; | |
82 | ||
83 | bool PrepProto(wxString& url); | |
84 | bool PrepHost(wxString& url); | |
85 | bool PrepPath(wxString& url); | |
86 | bool ParseURL(); | |
87 | void CleanData(); | |
88 | bool FetchProtocol(); | |
89 | ||
90 | friend class wxProtoInfo; | |
91 | friend class wxURLModule; | |
92 | ||
93 | private: | |
94 | // VZ: can't use default copy ctor for this class, should write a correct | |
95 | // one! (TODO) | |
96 | DECLARE_NO_COPY_CLASS(wxURL) | |
97 | ||
98 | DECLARE_DYNAMIC_CLASS(wxURL) | |
99 | }; | |
100 | ||
101 | #endif // wxUSE_URL | |
102 | ||
103 | #endif // _WX_URL_H | |
104 |