00001 #ifndef IGUANA_WEB_FRAMEWORK_IG_WEB_SERVICE_H
00002 # define IGUANA_WEB_FRAMEWORK_IG_WEB_SERVICE_H
00003
00004
00005
00006 # include "Iguana/WebFramework/interface/config.h"
00007 # include <map>
00008 # include <string>
00009 # include <classlib/utils/Callback.h>
00010 # include <qcstring.h>
00011 # include <qtextstream.h>
00012
00013
00014
00015
00016
00017 class IgState;
00018 class QIODevice;
00019 class IgFileManager;
00020
00021
00022
00023
00024
00025 class IGUANA_WEB_FRAMEWORK_API IgWebService
00026 {
00027 public:
00028 typedef std::map<std::string, std::string> ArgumentsMap;
00029
00030 class Arguments
00031 {
00032 public:
00033 Arguments (IgState *state,
00034 QIODevice *socket,
00035 ArgumentsMap *args,
00036 const std::string idCookie,
00037 QByteArray bodyData);
00038 IgState * state (void);
00039 QIODevice * outputDevice (void);
00040 ArgumentsMap * args (void);
00041 std::string idCookie (void);
00042 QByteArray bodyData (void);
00043 private:
00044 IgState * m_state;
00045 QIODevice * m_outputDevice;
00046 ArgumentsMap * m_args;
00047 std::string m_idCookie;
00048 QByteArray m_bodyData;
00049 };
00050
00051 typedef lat::Callback1<Arguments *> WebServiceCallback;
00052
00053 IgWebService (IgState *state);
00054 virtual ~IgWebService (void);
00055
00056
00057
00058
00059
00060 IgState* state () const;
00061 IgFileManager* getFileManager() const;
00062 void getScript (Arguments *arguments);
00063 void getPic (Arguments *arguments);
00064
00065 virtual WebServiceCallback callback (const std::string &label);
00066
00067
00068 static void sendDone (QIODevice *socket);
00069 static void sendError (QIODevice *socket);
00070 static void sendXML (QIODevice *socket, std::string xmlString);
00071 static void sendBinary (QIODevice *socket,
00072 QByteArray &tmpBuffer,
00073 std::string mimeType);
00074 protected:
00075 void registerCallback (const std::string &label,
00076 const WebServiceCallback &cb);
00077 private:
00078 IgState* m_state;
00079 IgFileManager* m_fileManager;
00080 std::map <std::string, WebServiceCallback> m_callbackMap;
00081 QByteArray m_bodyData;
00082 };
00083
00084
00085
00086
00087 #endif // IGUANA_WEB_FRAMEWORK_IG_WEB_SERVICE_H