]> git.saurik.com Git - wxWidgets.git/blame - include/wx/protocol/protocol.h
wxMGL compilation fix that I forgot to chekc in
[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) \
f92f546c
VS
99wxProtoInfo class::g_proto_##class(name, serv, host, CLASSINFO(class)); \
100bool wxProtocolUse##class = TRUE;
101
102#define USE_PROTOCOL(class) \
103 extern bool wxProtocolUse##class ; \
104 static struct wxProtocolUserFor##class \
105 { \
106 wxProtocolUserFor##class() { wxProtocolUse##class = TRUE; } \
107 } wxProtocolDoUse##class;
8e907a13
VZ
108
109class WXDLLEXPORT wxProtoInfo : public wxObject
110{
111public:
112 wxProtoInfo(const wxChar *name,
113 const wxChar *serv_name,
114 const bool need_host1,
115 wxClassInfo *info);
116
117protected:
118 wxProtoInfo *next;
119 wxString m_protoname;
120 wxString prefix;
121 wxString m_servname;
122 wxClassInfo *m_cinfo;
123 bool m_needhost;
124
125 friend class wxURL;
126
127 DECLARE_DYNAMIC_CLASS(wxProtoInfo)
128};
129
e3e717ec 130#endif // _WX_PROTOCOL_PROTOCOL_H