Main Page   Class Hierarchy   Compound List   File List   Compound Members  

xrserver.h

00001 /*
00002 
00003 qutexrlib QT-based XML-RPC library
00004 Copyright (C) 2003  P. Oscar Boykin <boykin@pobox.com>
00005 
00006 This program is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU General Public License
00008 as published by the Free Software Foundation; either version 2
00009 of the License, or (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019    
00020  */
00021 
00022 #ifndef xrserver
00023 #define xrserver
00024 
00025 #include <qserversocket.h>
00026 #include <qtextstream.h>
00027 #include <qsocket.h>
00028 #include <qstring.h>
00029 #include <qvaluelist.h>
00030 #include <qvariant.h>
00031 #include <qregexp.h>
00032 #include <qcstring.h>
00033 #include <qdom.h>
00034 #include <qmap.h>
00035 #include <qhttp.h>
00036 
00037 #include <xrmethodcall.h>
00038 #include <xrmethodresponse.h>
00039 #include <xrfaultcodes.h>
00040 
00041 
00059 class XRServer : public QServerSocket {
00060 
00061     //Macro for QObject subclasses:
00062     Q_OBJECT
00063     public:
00068         XRServer(Q_UINT16 port=8080,
00069                  int backlog = 1,
00070                  QObject * parent = 0,
00071                  const char * name = 0 );
00077         ~XRServer();
00086         QHostAddress getPeerForRequest(int req) const;
00087     
00088     signals:
00105         void methodCall(int req,
00106                         const QString& methodname,
00107                         const QValueList<QVariant>& params,
00108                         bool& handled);
00109     public slots:
00126         void sendMethodResponse(int req, const QVariant& result);
00141         void sendFault(int req,
00142                        int fault_code,
00143                        const QString& fault_string);
00144         
00145     protected slots:
00149         void readFromClient();
00154         void deleteClient();
00155 
00156     protected:
00161         void newConnection(int socket);
00166         void parseContentAndEmit(QSocket* s);
00167 
00172         void sendHttpError(QSocket* s,
00173                             int status_code,
00174                             const QString& reason,
00175                             QString resp);
00183         void sendHttpResponse(QSocket* s,
00184                             int status_code,
00185                             const QString& reason,
00186                             QHttpHeader& headers,
00187                             QString resp);
00188 
00198         QMap<QSocket*, QString> _header_strings;
00206         QMap<QSocket*, QHttpRequestHeader> _headers;
00214         QMap<QSocket*,bool> _open_sockets;
00215 
00219         QMap<int,QSocket*> _req_to_socket;
00223         int _last_req;
00224 };
00225 
00226 #endif

Generated on Tue Feb 25 18:38:57 2003 for qutexr by doxygen1.2.15