]> git.saurik.com Git - wxWidgets.git/blame - include/wx/protocol/protocol.h
add GetControlWidget() accessor to the generic wxCollapsiblePane
[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
65571936 9// Licence: wxWindows licence
f4ada568 10/////////////////////////////////////////////////////////////////////////////
8e907a13 11
f4ada568
GL
12#ifndef _WX_PROTOCOL_PROTOCOL_H
13#define _WX_PROTOCOL_PROTOCOL_H
14
e3e717ec
VZ
15#include "wx/defs.h"
16
a5d46b73
VZ
17#if wxUSE_PROTOCOL
18
f4ada568
GL
19#include "wx/object.h"
20#include "wx/string.h"
21#include "wx/stream.h"
8a4df159
RR
22
23#if wxUSE_SOCKETS
8e907a13 24 #include "wx/socket.h"
8a4df159 25#endif
f4ada568 26
8e907a13
VZ
27// ----------------------------------------------------------------------------
28// constants
29// ----------------------------------------------------------------------------
f4ada568 30
8e907a13
VZ
31typedef enum
32{
33 wxPROTO_NOERR = 0,
34 wxPROTO_NETERR,
35 wxPROTO_PROTERR,
36 wxPROTO_CONNERR,
37 wxPROTO_INVVAL,
38 wxPROTO_NOHNDLR,
39 wxPROTO_NOFILE,
40 wxPROTO_ABRT,
41 wxPROTO_RCNCT,
42 wxPROTO_STREAMING
43} wxProtocolError;
f4ada568 44
8e907a13
VZ
45// ----------------------------------------------------------------------------
46// wxProtocol: abstract base class for all protocols
47// ----------------------------------------------------------------------------
f4ada568 48
7c4728f6 49class WXDLLIMPEXP_NET wxProtocol
8a4df159 50#if wxUSE_SOCKETS
8e907a13 51 : public wxSocketClient
8a4df159 52#else
8e907a13 53 : public wxObject
8a4df159 54#endif
8e907a13 55{
f4ada568 56public:
8e907a13 57 wxProtocol();
f4ada568 58
8a4df159 59#if wxUSE_SOCKETS
8e907a13 60 bool Reconnect();
730b772b
FM
61 virtual bool Connect( const wxString& WXUNUSED(host) ) { return false; }
62 virtual bool Connect( const wxSockAddress& addr, bool WXUNUSED(wait) = true)
ddc7f0c9 63 { return wxSocketClient::Connect(addr); }
8e907a13
VZ
64
65 // read a '\r\n' terminated line from the given socket and put it in
66 // result (without the terminators)
67 static wxProtocolError ReadLine(wxSocketBase *socket, wxString& result);
68
69 // read a line from this socket - this one can be overridden in the
70 // derived classes if different line termination convention is to be used
71 virtual wxProtocolError ReadLine(wxString& result);
72#endif // wxUSE_SOCKETS
f4ada568 73
8e907a13
VZ
74 virtual bool Abort() = 0;
75 virtual wxInputStream *GetInputStream(const wxString& path) = 0;
730b772b
FM
76 virtual wxString GetContentType() const = 0;
77
78 // the error code
79 virtual wxProtocolError GetError() const { return m_lastError; }
80
81 void SetUser(const wxString& user) { m_username = user; }
82 void SetPassword(const wxString& passwd) { m_password = passwd; }
83
84 virtual void SetDefaultTimeout(wxUint32 Value);
85
86 // override wxSocketBase::SetTimeout function to avoid that the internal
87 // m_uiDefaultTimeout goes out-of-sync:
88 virtual void SetTimeout(long seconds)
89 { SetDefaultTimeout(seconds); }
90
91
92protected:
93 // the timeout associated with the protocol:
94 wxUint32 m_uiDefaultTimeout;
95
96 wxString m_username;
97 wxString m_password;
98
99 // this must be always updated by the derived classes!
100 wxProtocolError m_lastError;
8e907a13
VZ
101
102private:
fc7a2a60 103 DECLARE_DYNAMIC_CLASS_NO_COPY(wxProtocol)
f4ada568
GL
104};
105
8e907a13
VZ
106// ----------------------------------------------------------------------------
107// macros for protocol classes
108// ----------------------------------------------------------------------------
109
110#define DECLARE_PROTOCOL(class) \
111public: \
112 static wxProtoInfo g_proto_##class;
113
114#define IMPLEMENT_PROTOCOL(class, name, serv, host) \
f92f546c
VS
115wxProtoInfo class::g_proto_##class(name, serv, host, CLASSINFO(class)); \
116bool wxProtocolUse##class = TRUE;
117
118#define USE_PROTOCOL(class) \
119 extern bool wxProtocolUse##class ; \
120 static struct wxProtocolUserFor##class \
121 { \
122 wxProtocolUserFor##class() { wxProtocolUse##class = TRUE; } \
123 } wxProtocolDoUse##class;
8e907a13 124
7c4728f6 125class WXDLLIMPEXP_NET wxProtoInfo : public wxObject
8e907a13
VZ
126{
127public:
128 wxProtoInfo(const wxChar *name,
129 const wxChar *serv_name,
130 const bool need_host1,
131 wxClassInfo *info);
132
133protected:
134 wxProtoInfo *next;
135 wxString m_protoname;
136 wxString prefix;
137 wxString m_servname;
138 wxClassInfo *m_cinfo;
139 bool m_needhost;
140
141 friend class wxURL;
142
143 DECLARE_DYNAMIC_CLASS(wxProtoInfo)
22f3361e 144 DECLARE_NO_COPY_CLASS(wxProtoInfo)
8e907a13
VZ
145};
146
a5d46b73
VZ
147#endif // wxUSE_PROTOCOL
148
e3e717ec 149#endif // _WX_PROTOCOL_PROTOCOL_H