#include <Iguana/WebFramework/interface/IgWebService.h>
Public Types | |
typedef std::map< std::string, std::string > | ArgumentsMap |
typedef lat::Callback1 < Arguments * > | WebServiceCallback |
Public Member Functions | |
virtual WebServiceCallback | callback (const std::string &label) |
IgFileManager * | getFileManager () const |
void | getPic (Arguments *arguments) |
void | getScript (Arguments *arguments) |
IgWebService (IgState *state) | |
IgState * | state () const |
virtual | ~IgWebService (void) |
Static Public Member Functions | |
static void | sendBinary (QIODevice *socket, QByteArray &tmpBuffer, std::string mimeType) |
static void | sendDone (QIODevice *socket) |
static void | sendError (QIODevice *socket) |
static void | sendXML (QIODevice *socket, std::string xmlString) |
Protected Member Functions | |
void | registerCallback (const std::string &label, const WebServiceCallback &cb) |
Private Attributes | |
QByteArray | m_bodyData |
std::map< std::string, WebServiceCallback > | m_callbackMap |
IgFileManager * | m_fileManager |
IgState * | m_state |
Classes | |
class | Arguments |
Definition at line 25 of file IgWebService.h.
typedef std::map<std::string, std::string> IgWebService::ArgumentsMap |
Definition at line 28 of file IgWebService.h.
Definition at line 51 of file IgWebService.h.
IgWebService::IgWebService | ( | IgState * | state | ) |
Definition at line 18 of file IgWebService.cc.
References IgFileManager::addPaths(), IgFileManager::addSearchPath(), lat::CreateCallback(), DBSPlugin::get(), IgEnvsElement::getEnv(), getFileManager(), getPic(), getScript(), m_fileManager, and registerCallback().
00019 : m_state(state) 00020 { 00021 m_fileManager = new IgFileManager (new IgState(state)); 00022 IgEnvsElement* envs = IgEnvsElement::get(state); 00023 std::string wedDirectory(""); 00024 if (envs->getEnv ("IG_WEB_STUDIO_DIRECTORY", wedDirectory)) 00025 m_fileManager->addSearchPath (wedDirectory); 00026 00027 00028 getFileManager ()->addPaths ("/share/images/", true); 00029 getFileManager ()->addPaths ("/src/", true); 00030 00031 registerCallback ("getScript", lat::CreateCallback (this, &IgWebService::getScript)); 00032 registerCallback ("getPic", lat::CreateCallback (this, &IgWebService::getPic)); 00033 }
IgWebService::~IgWebService | ( | void | ) | [virtual] |
IgWebService::WebServiceCallback IgWebService::callback | ( | const std::string & | label | ) | [virtual] |
Definition at line 94 of file IgWebService.cc.
References m_callbackMap.
Referenced by IgWebServiceRegistry::executeURL().
00095 { 00096 return m_callbackMap[label]; 00097 }
IgFileManager * IgWebService::getFileManager | ( | ) | const |
Definition at line 44 of file IgWebService.cc.
References m_fileManager.
Referenced by IgStudioWebService::IgStudioWebService(), and IgWebService().
00045 { return m_fileManager; }
Definition at line 71 of file IgWebService.cc.
References IgWebService::Arguments::args(), aod_PYTHIA_cfg::fileName, IgFileManager::lookup(), m_fileManager, IgWebService::Arguments::outputDevice(), and sendBinary().
Referenced by IgWebService().
00072 { 00073 QIODevice *outputDevice = arguments->outputDevice (); 00074 ArgumentsMap &args = *(arguments->args ()); 00075 QByteArray writeBuffer; 00076 00077 if (args.find ("name") == args.end ()) 00078 return; 00079 00080 std::string fileName = args["name"]; 00081 00082 writeBuffer = m_fileManager->lookup (fileName); 00083 00084 std::string type = "png"; 00085 if (args.find ("type") != args.end ()) 00086 { 00087 type = args["type"]; 00088 } 00089 00090 this->sendBinary (outputDevice, writeBuffer, "image/" + type); 00091 }
Definition at line 48 of file IgWebService.cc.
References IgWebService::Arguments::args(), aod_PYTHIA_cfg::fileName, IgFileManager::lookup(), m_fileManager, IgWebService::Arguments::outputDevice(), and sendBinary().
Referenced by IgWebService().
00049 { 00050 QIODevice *outputDevice = arguments->outputDevice (); 00051 ArgumentsMap &args = *(arguments->args ()); 00052 QByteArray writeBuffer; 00053 00054 if (args.find ("name") == args.end ()) 00055 return; 00056 00057 std::string fileName = args["name"]; 00058 00059 writeBuffer = m_fileManager->lookup (fileName); 00060 00061 std::string type = "text/html"; 00062 if (args.find ("type") != args.end ()) 00063 { 00064 type = args["type"]; 00065 } 00066 00067 this->sendBinary (outputDevice, writeBuffer, type); 00068 }
void IgWebService::registerCallback | ( | const std::string & | label, | |
const WebServiceCallback & | cb | |||
) | [protected] |
Definition at line 101 of file IgWebService.cc.
References m_callbackMap.
Referenced by IgStudioWebService::IgStudioWebService(), IgWeb2DService::IgWeb2DService(), IgWeb3DService::IgWeb3DService(), IgWebLegoService::IgWebLegoService(), IgWebRPhiService::IgWebRPhiService(), IgWebRZService::IgWebRZService(), IgWebService(), IgWebTreeService::IgWebTreeService(), VisWebFrameworkService::VisWebFrameworkService(), and VisWebRootService::VisWebRootService().
00103 { 00104 m_callbackMap.insert (std::pair<std::string, WebServiceCallback > (label, cb)); 00105 }
void IgWebService::sendBinary | ( | QIODevice * | socket, | |
QByteArray & | tmpBuffer, | |||
std::string | mimeType | |||
) | [static] |
Definition at line 157 of file IgWebService.cc.
Referenced by VisWebRootService::browse(), getPic(), getScript(), and IgServerSocket::ping().
00160 { 00161 QTextStream os (socket); 00162 os << "HTTP/1.0 200 Ok\r\n" 00163 "Content-Type: " + mimeType + ";\r\n" 00164 "\r\n"; 00165 00166 socket->writeBlock (tmpBuffer.data (), 00167 tmpBuffer.size ()); 00168 00169 os << "\r\n"; 00170 }
void IgWebService::sendDone | ( | QIODevice * | socket | ) | [static] |
Definition at line 122 of file IgWebService.cc.
Referenced by IgWebRPhiService::create(), IgWebRZService::create(), IgWeb3DService::create(), IgWebLegoService::create(), and VisWebFrameworkService::nextEvent().
00123 { 00124 QTextStream os (socket); 00125 os << "HTTP/1.1 200 Ok\r\n" 00126 "content-type: text/xml; charset=UTF-8\r\n" 00127 "\r\n" 00128 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" 00129 "<done/>\r\n"; 00130 }
void IgWebService::sendError | ( | QIODevice * | socket | ) | [static] |
Definition at line 134 of file IgWebService.cc.
Referenced by IgWebTreeService::browse(), IgWebTreeService::getRepID(), and VisWebFrameworkService::reconfigure().
00135 { 00136 QTextStream os (socket); 00137 os << "HTTP/1.1 200 Ok\r\n" 00138 "content-type: text/xml; charset=UTF-8\r\n" 00139 "\r\n" 00140 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" 00141 "<error/>\r\n"; 00142 }
void IgWebService::sendXML | ( | QIODevice * | socket, | |
std::string | xmlString | |||
) | [static] |
Definition at line 146 of file IgWebService.cc.
Referenced by IgWebTreeService::twigMenu().
00147 { 00148 QTextStream os (socket); 00149 os << "HTTP/1.1 200 Ok\r\n" 00150 "content-type: text/xml; charset=UTF-8\r\n" 00151 "\r\n" 00152 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" 00153 "" + xmlString + "\r\n"; 00154 }
Definition at line 40 of file IgWebService.cc.
References m_state.
Referenced by IgWebRZService::browse(), IgWebLegoService::browse(), IgWebTreeService::browse(), VisWebRootService::browse(), IgWebRPhiService::browse(), IgWeb2DService::browse(), IgWeb3DService::browse(), VisWebRootService::create(), IgWebRPhiService::create(), IgWebRZService::create(), IgWeb2DService::create(), IgWeb3DService::create(), IgWebLegoService::create(), IgWebTreeService::getRepID(), IgStudioWebService::login(), VisWebFrameworkService::nextEvent(), and VisWebFrameworkService::reconfigure().
00041 { return m_state; }
QByteArray IgWebService::m_bodyData [private] |
Definition at line 81 of file IgWebService.h.
std::map<std::string, WebServiceCallback> IgWebService::m_callbackMap [private] |
IgFileManager* IgWebService::m_fileManager [private] |
Definition at line 79 of file IgWebService.h.
Referenced by getFileManager(), getPic(), getScript(), and IgWebService().
IgState* IgWebService::m_state [private] |
Reimplemented in IgWebLegoService, IgWebRPhiService, IgWebRZService, and IgWebTreeService.
Definition at line 78 of file IgWebService.h.
Referenced by state().