]> git.saurik.com Git - wxWidgets.git/blame - include/wx/protocol/protocol.h
Removed redundant member variable.
[wxWidgets.git] / include / wx / protocol / protocol.h
CommitLineData
f4ada568 1/////////////////////////////////////////////////////////////////////////////
8e907a13 2// Name: wx/protocol/protocol.h
f4ada568
GL
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/////////////////////////////////////////////////////////////////////////////
8e907a13 11
f4ada568
GL
12#ifndef _WX_PROTOCOL_PROTOCOL_H
13#define _WX_PROTOCOL_PROTOCOL_H
14
15#ifdef __GNUG__
16#pragma interface
17#endif
18
e3e717ec
VZ
19#include "wx/defs.h"
20
f4ada568
GL
21#include "wx/object.h"
22#include "wx/string.h"
23#include "wx/stream.h"
8a4df159
RR
24
25#if wxUSE_SOCKETS
8e907a13 26 #include "wx/socket.h"
8a4df159 27#endif
f4ada568 28
8e907a13
VZ
29// ----------------------------------------------------------------------------
30// constants
31// ----------------------------------------------------------------------------
f4ada568 32
8e907a13
VZ
33typedef enum
34{
35 wxPROTO_NOERR = 0,
36 wxPROTO_NETERR,
37 wxPROTO_PROTERR,
38 wxPROTO_CONNERR,
39 wxPROTO_INVVAL,
40 wxPROTO_NOHNDLR,
41 wxPROTO_NOFILE,
42 wxPROTO_ABRT,
43 wxPROTO_RCNCT,
44 wxPROTO_STREAMING
45} wxProtocolError;
f4ada568 46
8e907a13
VZ
47// ----------------------------------------------------------------------------
48// wxProtocol: abstract base class for all protocols
49// ----------------------------------------------------------------------------
f4ada568 50
8a4df159
RR
51class WXDLLEXPORT wxProtocol
52#if wxUSE_SOCKETS
8e907a13 53 : public wxSocketClient
8a4df159 54#else
8e907a13 55 : public wxObject
8a4df159 56#endif
8e907a13 57{
f4ada568 58public:
8e907a13 59 wxProtocol();
f4ada568 60
8a4df159 61#if wxUSE_SOCKETS
8e907a13
VZ
62 bool Reconnect();
63 virtual bool Connect( const wxString& WXUNUSED(host) ) { return FALSE; }
64 virtual bool Connect( wxSockAddress& addr, bool WXUNUSED(wait) = TRUE) { return wxSocketClient::Connect(addr); }
65
66 // read a '\r\n' terminated line from the given socket and put it in
67 // result (without the terminators)
68 static wxProtocolError ReadLine(wxSocketBase *socket, wxString& result);
69
70 // read a line from this socket - this one can be overridden in the
71 // derived classes if different line termination convention is to be used
72 virtual wxProtocolError ReadLine(wxString& result);
73#endif // wxUSE_SOCKETS
f4ada568 74
8e907a13
VZ
75 virtual bool Abort() = 0;
76 virtual wxInputStream *GetInputStream(const wxString& path) = 0;
77 virtual wxProtocolError GetError() = 0;
78 virtual wxString GetContentType() { return wxEmptyString; }
79 virtual void SetUser(const wxString& WXUNUSED(user)) {}
80 virtual void SetPassword(const wxString& WXUNUSED(passwd) ) {}
81
82private:
83 DECLARE_ABSTRACT_CLASS(wxProtocol)
f4ada568
GL
84};
85
8a4df159 86#if wxUSE_SOCKETS
f4ada568 87wxProtocolError WXDLLEXPORT GetLine(wxSocketBase *sock, wxString& result);
8a4df159 88#endif
e3e717ec 89
8e907a13
VZ
90// ----------------------------------------------------------------------------
91// macros for protocol classes
92// ----------------------------------------------------------------------------
93
94#define DECLARE_PROTOCOL(class) \
95public: \
96 static wxProtoInfo g_proto_##class;
97
98#define IMPLEMENT_PROTOCOL(class, name, serv, host) \
99wxProtoInfo class::g_proto_##class(name, serv, host, CLASSINFO(class));
100
101class WXDLLEXPORT wxProtoInfo : public wxObject
102{
103public:
104 wxProtoInfo(const wxChar *name,
105 const wxChar *serv_name,
106 const bool need_host1,
107 wxClassInfo *info);
108
109protected:
110 wxProtoInfo *next;
111 wxString m_protoname;
112 wxString prefix;
113 wxString m_servname;
114 wxClassInfo *m_cinfo;
115 bool m_needhost;
116
117 friend class wxURL;
118
119 DECLARE_DYNAMIC_CLASS(wxProtoInfo)
120};
121
e3e717ec 122#endif // _WX_PROTOCOL_PROTOCOL_H