]>
Commit | Line | Data |
---|---|---|
f4ada568 GL |
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 | ||
e3e717ec VZ |
18 | #include "wx/defs.h" |
19 | ||
20 | #if wxUSE_SOCKETS | |
21 | ||
f4ada568 GL |
22 | #include "wx/object.h" |
23 | #include "wx/string.h" | |
24 | #include "wx/stream.h" | |
25 | #include "wx/socket.h" | |
26 | ||
27 | typedef enum { | |
28 | wxPROTO_NOERR = 0, | |
29 | wxPROTO_NETERR, | |
30 | wxPROTO_PROTERR, | |
31 | wxPROTO_CONNERR, | |
32 | wxPROTO_INVVAL, | |
33 | wxPROTO_NOHNDLR, | |
34 | wxPROTO_NOFILE, | |
35 | wxPROTO_ABRT, | |
36 | wxPROTO_RCNCT, | |
e3e717ec | 37 | wxPROTO_STREAMING |
f4ada568 GL |
38 | } wxProtocolError; |
39 | ||
40 | // For protocols | |
41 | #define DECLARE_PROTOCOL(class) \ | |
42 | public: \ | |
43 | static wxProtoInfo g_proto_##class; | |
44 | ||
45 | #define IMPLEMENT_PROTOCOL(class, name, serv, host) \ | |
46 | wxProtoInfo class::g_proto_##class(name, serv, host, CLASSINFO(class)); | |
47 | ||
48 | class WXDLLEXPORT wxProtoInfo : public wxObject { | |
49 | DECLARE_DYNAMIC_CLASS(wxProtoInfo) | |
50 | protected: | |
51 | wxProtoInfo *next; | |
52 | wxString m_protoname; | |
53 | wxString prefix; | |
54 | wxString m_servname; | |
55 | wxClassInfo *m_cinfo; | |
56 | bool m_needhost; | |
57 | ||
58 | friend class wxURL; | |
59 | public: | |
8bec6d4a | 60 | wxProtoInfo(const wxChar *name, const wxChar *serv_name, const bool need_host1, |
f4ada568 GL |
61 | wxClassInfo *info); |
62 | }; | |
63 | ||
64 | class WXDLLEXPORT wxProtocol : public wxSocketClient { | |
65 | DECLARE_ABSTRACT_CLASS(wxProtocol) | |
66 | public: | |
67 | wxProtocol(); | |
68 | ||
69 | bool Reconnect(); | |
8a2c6ef8 JS |
70 | virtual bool Connect( const wxString& WXUNUSED(host) ) { return FALSE; } |
71 | virtual bool Connect( wxSockAddress& addr, bool WXUNUSED(wait) = TRUE) { return wxSocketClient::Connect(addr); } | |
f4ada568 GL |
72 | |
73 | virtual bool Abort() = 0; | |
74 | virtual wxInputStream *GetInputStream(const wxString& path) = 0; | |
75 | virtual wxProtocolError GetError() = 0; | |
ce3ed50d | 76 | virtual wxString GetContentType() { return wxEmptyString; } |
c058d771 RR |
77 | virtual void SetUser(const wxString& WXUNUSED(user)) {} |
78 | virtual void SetPassword(const wxString& WXUNUSED(passwd) ) {} | |
f4ada568 GL |
79 | }; |
80 | ||
81 | wxProtocolError WXDLLEXPORT GetLine(wxSocketBase *sock, wxString& result); | |
82 | ||
e3e717ec VZ |
83 | #endif // wxUSE_SOCKETS |
84 | ||
85 | #endif // _WX_PROTOCOL_PROTOCOL_H |