ulxr_protocol.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                     ulxr_protocol.h  -  rpc prootocol
00003                              -------------------
00004     begin                : Mon May 3 2004
00005     copyright            : (C) 2002-2007 by Ewald Arnold
00006     email                : ulxmlrpcpp@ewald-arnold.de
00007 
00008     $Id: ulxr_protocol.h 940 2006-12-30 18:22:05Z ewald-arnold $
00009 
00010  ***************************************************************************/
00011 
00012 /**************************************************************************
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as
00016  * published by the Free Software Foundation; either version 2 of the License,
00017  * or (at your option) any later version.
00018  *
00019  * This program is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00027  *
00028  ***************************************************************************/
00029 
00030 #ifndef ULXR_PROTOCOL_H
00031 #define ULXR_PROTOCOL_H
00032 
00033 #include <ulxmlrpcpp/ulxmlrpcpp.h>  // always first header
00034 
00035 #include <vector>
00036 
00037 
00038 namespace ulxr {
00039 
00040 
00045 class MethodCall;
00046 class MethodResponse;
00047 class Connection;
00048 
00052 class ULXR_API_DECL0 Protocol
00053 {
00054  public:
00055 
00059    Protocol(Connection *conn);
00060 
00063    virtual ~Protocol();
00064 
00069    void writeRaw(char const *buff, long len);
00070 
00076    long readRaw(char *buff, long len);
00077 
00080    virtual void open();
00081 
00087    bool accept(int timeout = 0) ;
00088 
00092    bool isOpen() const;
00093 
00100    virtual void shutdown(int mode) = 0;
00101 
00104    virtual void close();
00105 
00109    virtual bool hasBytesToRead() const = 0;
00110 
00116    virtual void resetConnection();
00117 
00123    virtual void sendRpcCall(const MethodCall &call, const CppString &resource, bool wbxml_mode);
00124 
00129    virtual void sendRpcResponse(const MethodResponse &resp, bool wbxml_mode);
00130 
00143    void setPersistent(bool pers);
00144 
00148    bool isPersistent() const;
00149 
00154    virtual bool responseStatus(CppString &phrase) const = 0;
00155 
00158    typedef enum
00159    {
00160      ConnStart,                 // 0 start and reset
00161      ConnPendingCR,             // 1 just found CR, wait for LF or fold whitespace
00162      ConnPendingHeaderLine,     // 2 new line started, may be folded
00163      ConnHeaderLine,            // 3 collection chars for current header line
00164      ConnSwitchToBody,          // 4 header completely read ==> analyse header fields
00165      ConnBody,                  // 5 in body, do nothing. Never reached if there is no body!
00166      ConnError,                 // 6 error occured, set status accordingly
00167      ConnLast                   // 7 last item for continuation
00168    }
00169    State;
00170 
00171 
00184    virtual State connectionMachine(char * &buffer, long &len);
00185 
00191    void addAuthentication(const CppString &user, const CppString &pass,
00192                           const CppString &realm);
00193 
00200    virtual void setMessageAuthentication(const CppString &user, const CppString &pass);
00201 
00209    virtual bool checkAuthentication(const CppString &realm) const;
00210 
00215    virtual void rejectAuthentication(const CppString &realm);
00216 
00219    virtual void setTransmitOnly();
00220 
00224    virtual bool isTransmitOnly();
00225 
00229    Connection * getConnection() const;
00230 
00235    virtual Protocol *detach() = 0;
00236 
00237  protected:
00238 
00243    void setConnection(Connection *conn);
00244 
00248    void setConnectionState(State state);
00249 
00253    State getConnectionState() const;
00254 
00259    void setRemainingContentLength(long len);
00260 
00268    long getRemainingContentLength() const;
00269 
00274    long getContentLength() const;
00275 
00279    void setContentLength(long len);
00280 
00286    virtual bool getUserPass(CppString &user, CppString &pass) const;
00287 
00290    virtual void determineContentLength() = 0;
00291 
00295    virtual CppString getProtocolName() = 0;
00296 
00297  private:
00298 
00301    void init();
00302 
00303  private:
00304 
00305    struct AuthData;
00306    struct PImpl;
00307    PImpl *pimpl;
00308 
00309  protected:
00310 
00311   Protocol(const Protocol&);
00312 
00313  private:
00314 
00315    Protocol& operator=(const Protocol&); // empty!
00316 };
00317 
00318 
00319 }  // namespace ulxr
00320 
00321 
00322 #endif // ULXR_PROTOCOL_H
00323 

Generated on Sun Aug 19 20:08:57 2007 for ulxmlrpcpp by  doxygen 1.5.1