]> git.saurik.com Git - wxWidgets.git/blob - include/wx/url.h
HTTP_PROXY bug (freeze on program startup) should be fixed
[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 license
10 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_URL_H
12 #define _WX_URL_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 // wxWindows header
19 #include "wx/object.h"
20
21 // wxSocket headers
22 #include "wx/protocol/protocol.h"
23
24 #if wxUSE_SOCKETS
25 #include "wx/protocol/http.h"
26 #endif
27
28 typedef enum {
29 wxURL_NOERR = 0,
30 wxURL_SNTXERR,
31 wxURL_NOPROTO,
32 wxURL_NOHOST,
33 wxURL_NOPATH,
34 wxURL_CONNERR,
35 wxURL_PROTOERR
36 } wxURLError;
37
38 class WXDLLEXPORT wxURL : public wxObject
39 {
40 public:
41 wxURL(const wxString& url);
42 virtual ~wxURL();
43
44 wxString GetProtocolName() const { return m_protoinfo->m_protoname; }
45 wxString GetHostName() const { return m_hostname; }
46 wxString GetURL() const { return m_url; }
47 wxProtocol& GetProtocol() { return *m_protocol; }
48 wxURLError GetError() const { return m_error; }
49 wxString GetPath() const { return m_path; }
50
51 wxInputStream *GetInputStream();
52
53 #if wxUSE_SOCKETS
54 static void SetDefaultProxy(const wxString& url_proxy);
55 void SetProxy(const wxString& url_proxy);
56 #endif // wxUSE_SOCKETS
57
58 static wxString ConvertToValidURI(const wxString& uri);
59 static wxString ConvertFromURI(const wxString& uri);
60
61 protected:
62 static wxProtoInfo *ms_protocols;
63
64 #if wxUSE_SOCKETS
65 static wxHTTP *ms_proxyDefault;
66 static bool ms_useDefaultProxy;
67 wxHTTP *m_proxy;
68 #endif // wxUSE_SOCKETS
69
70 wxProtoInfo *m_protoinfo;
71 wxProtocol *m_protocol;
72
73 wxURLError m_error;
74 wxString m_protoname, m_hostname, m_servname, m_path, m_url;
75 wxString m_user, m_password;
76 bool m_useProxy;
77
78 bool PrepProto(wxString& url);
79 bool PrepHost(wxString& url);
80 bool PrepPath(wxString& url);
81 bool ParseURL();
82 void CleanData();
83 bool FetchProtocol();
84
85 friend class wxProtoInfo;
86 friend class wxURLModule;
87
88 private:
89 // VZ: can't use default copy ctor for this class, should write a correct
90 // one! (TODO)
91 DECLARE_NO_COPY_CLASS(wxURL);
92
93 DECLARE_DYNAMIC_CLASS(wxURL)
94 };
95
96 #endif