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