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