]> git.saurik.com Git - wxWidgets.git/blob - include/wx/protocol/protocol.h
Removed unnecessary code from utilsunx.cpp
[wxWidgets.git] / include / wx / protocol / protocol.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: protocol.h
3 // Purpose: Protocol base class
4 // Author: Guilhem Lavaux
5 // Modified by:
6 // Created: 10/07/1997
7 // RCS-ID: $Id$
8 // Copyright: (c) 1997, 1998 Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_PROTOCOL_PROTOCOL_H
12 #define _WX_PROTOCOL_PROTOCOL_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include "wx/defs.h"
19
20
21 #include "wx/object.h"
22 #include "wx/string.h"
23 #include "wx/stream.h"
24
25 #if wxUSE_SOCKETS
26 #include "wx/socket.h"
27 #endif
28
29 typedef enum {
30 wxPROTO_NOERR = 0,
31 wxPROTO_NETERR,
32 wxPROTO_PROTERR,
33 wxPROTO_CONNERR,
34 wxPROTO_INVVAL,
35 wxPROTO_NOHNDLR,
36 wxPROTO_NOFILE,
37 wxPROTO_ABRT,
38 wxPROTO_RCNCT,
39 wxPROTO_STREAMING
40 } wxProtocolError;
41
42 // For protocols
43 #define DECLARE_PROTOCOL(class) \
44 public: \
45 static wxProtoInfo g_proto_##class;
46
47 #define IMPLEMENT_PROTOCOL(class, name, serv, host) \
48 wxProtoInfo class::g_proto_##class(name, serv, host, CLASSINFO(class));
49
50 class WXDLLEXPORT wxProtoInfo : public wxObject {
51 DECLARE_DYNAMIC_CLASS(wxProtoInfo)
52 protected:
53 wxProtoInfo *next;
54 wxString m_protoname;
55 wxString prefix;
56 wxString m_servname;
57 wxClassInfo *m_cinfo;
58 bool m_needhost;
59
60 friend class wxURL;
61 public:
62 wxProtoInfo(const wxChar *name, const wxChar *serv_name, const bool need_host1,
63 wxClassInfo *info);
64 };
65
66 class WXDLLEXPORT wxProtocol
67 #if wxUSE_SOCKETS
68 : public wxSocketClient {
69 #else
70 : public wxObject {
71 #endif
72 DECLARE_ABSTRACT_CLASS(wxProtocol)
73 public:
74 wxProtocol();
75
76 #if wxUSE_SOCKETS
77 bool Reconnect();
78 virtual bool Connect( const wxString& WXUNUSED(host) ) { return FALSE; }
79 virtual bool Connect( wxSockAddress& addr, bool WXUNUSED(wait) = TRUE) { return wxSocketClient::Connect(addr); }
80 #endif
81
82 virtual bool Abort() = 0;
83 virtual wxInputStream *GetInputStream(const wxString& path) = 0;
84 virtual wxProtocolError GetError() = 0;
85 virtual wxString GetContentType() { return wxEmptyString; }
86 virtual void SetUser(const wxString& WXUNUSED(user)) {}
87 virtual void SetPassword(const wxString& WXUNUSED(passwd) ) {}
88 };
89
90 #if wxUSE_SOCKETS
91 wxProtocolError WXDLLEXPORT GetLine(wxSocketBase *sock, wxString& result);
92 #endif
93
94 #endif // _WX_PROTOCOL_PROTOCOL_H