1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        wx/protocol/protocol.h 
   3 // Purpose:     Protocol base class 
   4 // Author:      Guilhem Lavaux 
   8 // Copyright:   (c) 1997, 1998 Guilhem Lavaux 
   9 // Licence:     wxWindows license 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 #ifndef _WX_PROTOCOL_PROTOCOL_H 
  13 #define _WX_PROTOCOL_PROTOCOL_H 
  21 #include "wx/object.h" 
  22 #include "wx/string.h" 
  23 #include "wx/stream.h" 
  26     #include "wx/socket.h" 
  29 // ---------------------------------------------------------------------------- 
  31 // ---------------------------------------------------------------------------- 
  47 // ---------------------------------------------------------------------------- 
  48 // wxProtocol: abstract base class for all protocols 
  49 // ---------------------------------------------------------------------------- 
  51 class WXDLLEXPORT wxProtocol
 
  53  : public wxSocketClient
 
  63     virtual bool Connect( const wxString
& WXUNUSED(host
) ) { return FALSE
; } 
  64     virtual bool Connect( wxSockAddress
& addr
, bool WXUNUSED(wait
) = TRUE
) { return wxSocketClient::Connect(addr
); } 
  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
); 
  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 
  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
) ) {} 
  83     DECLARE_ABSTRACT_CLASS(wxProtocol
) 
  87 wxProtocolError WXDLLEXPORT 
GetLine(wxSocketBase 
*sock
, wxString
& result
); 
  90 // ---------------------------------------------------------------------------- 
  91 // macros for protocol classes 
  92 // ---------------------------------------------------------------------------- 
  94 #define DECLARE_PROTOCOL(class) \ 
  96   static wxProtoInfo g_proto_##class; 
  98 #define IMPLEMENT_PROTOCOL(class, name, serv, host) \ 
  99 wxProtoInfo class::g_proto_##class(name, serv, host, CLASSINFO(class)); 
 101 class WXDLLEXPORT wxProtoInfo 
: public wxObject
 
 104     wxProtoInfo(const wxChar 
*name
, 
 105                 const wxChar 
*serv_name
, 
 106                 const bool need_host1
, 
 111     wxString m_protoname
; 
 114     wxClassInfo 
*m_cinfo
; 
 119     DECLARE_DYNAMIC_CLASS(wxProtoInfo
) 
 122 #endif // _WX_PROTOCOL_PROTOCOL_H