#include <Iguana/WebFramework/interface/IgStudioWebService.h>
Public Member Functions | |
IgStudioWebService (IgState *state) | |
void | initSession (Arguments *arguments) |
void | launch (Arguments *arguments) |
void | login (Arguments *arguments) |
void | logout (Arguments *arguments) |
Static Public Member Functions | |
static const char * | catalogLabel (void) |
Private Attributes | |
std::string | m_sessionUrl |
Definition at line 20 of file IgStudioWebService.h.
IgStudioWebService::IgStudioWebService | ( | IgState * | state | ) |
Definition at line 48 of file IgStudioWebService.cc.
References IgFileManager::addPaths(), lat::CreateCallback(), IgWebService::getFileManager(), initSession(), launch(), login(), logout(), and IgWebService::registerCallback().
00049 : IgWebService (state) 00050 { 00051 //added in reverse order as we are prepending these paths 00052 getFileManager ()->addPaths ("/share/htdocs/Ig_Modules/IgWebStudio/html/", 00053 true); 00054 getFileManager ()->addPaths ("/src/Ig_Modules/IgWebStudio/images/", true); 00055 getFileManager ()->addPaths ("/src/Ig_Modules/IgWebStudio/html/", true); 00056 00057 registerCallback ("initSession", lat::CreateCallback (this, &IgStudioWebService::initSession)); 00058 registerCallback ("login", lat::CreateCallback (this, &IgStudioWebService::login)); 00059 registerCallback ("logout", lat::CreateCallback (this, &IgStudioWebService::logout)); 00060 registerCallback ("launch", lat::CreateCallback (this, &IgStudioWebService::launch)); 00061 }
const char * IgStudioWebService::catalogLabel | ( | void | ) | [static] |
Definition at line 128 of file IgStudioWebService.cc.
References IgPluginFactory< I >::begin(), IgServerSocket::cmdLineProxy(), IgPluginFactory< I >::end(), lat::endl(), IgWebServiceDB::get(), i, IgWebService::Arguments::idCookie(), j, LOG, m_sessionUrl, IgWebService::Arguments::outputDevice(), IgServerSocket::redirect(), socket, split, GsfMatrixTools::trace(), and IgSocket::userAgent().
Referenced by IgStudioWebService().
00129 { 00130 QIODevice *outputDevice = arguments->outputDevice (); 00131 QTextStream os (outputDevice); 00132 LOG (0, trace, LFstudioWeb, "Cookie: " 00133 << arguments->idCookie () << std::endl); 00134 00135 if (! m_sessionUrl.empty ()) 00136 { 00137 os << IgServerSocket::redirect(m_sessionUrl, "", ""); 00138 return; 00139 } 00140 00141 IgSocket *socket = dynamic_cast<IgSocket *>(outputDevice); 00142 bool validUserAgent = true; 00143 std::string userAgent (""); 00144 if(socket) 00145 { 00146 userAgent = socket->userAgent(); 00147 QStringList agents = QStringList::split (QRegExp ("[ \n\r][ \n\r]*"), 00148 userAgent.c_str()); 00149 for(int i=0; i<agents.size();i++) 00150 { 00151 if(agents[i]=="MSIE") 00152 { 00153 validUserAgent=false; 00154 break; 00155 } 00156 } 00157 } 00158 00159 IgWebServiceDB *wsdb = IgWebServiceDB::get (); 00160 std::string proxy = IgServerSocket::cmdLineProxy (); 00161 00162 os << "HTTP/1.0 200 Ok\r\n" 00163 "Content-Type: text/html; charset=\"utf-8\"\r\n" 00164 "\r\n"; 00165 00166 os << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n" 00167 "\"https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" 00168 "<html xmlns=\"https://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n" 00169 "<head>\n" 00170 "<title>IGUANA WEB STUDIO</title>" 00171 "<link rel=\"stylesheet\" type=\"text/css\" href=\""+proxy+"/Studio/getScript?name=main.css&type=text/css\"/>\n" 00172 "</head><body>\n" 00173 "<div style=\"display: none;\">Welcome user " + arguments->idCookie () + "</div>" 00174 "<div class=\"main\"><div align=right><a href=\""<<proxy<<"/Studio/logout\">Logout</a></div>" 00175 "<div class=\"title\">IGUANA WEB INTERFACE</div><table><tr>"; 00176 int j = 0; 00177 00178 for (IgWebServiceDB::Iterator i = wsdb->begin (); 00179 i != wsdb->end (); 00180 i++) 00181 { 00182 if (j > 4) 00183 { 00184 j = 0; 00185 os << "</tr><tr>"; 00186 } 00187 00188 using namespace lat; 00189 std::map <std::string, std::string> pluginOpts; 00190 00191 StringList pluginInfo = StringOps::split ((*i)->name (), "?"); 00192 if (pluginInfo.size () == 2) 00193 { 00194 StringList keyValues = StringOps::split (pluginInfo [1], "&"); 00195 for (StringList::iterator i = keyValues.begin (); 00196 i != keyValues.end (); 00197 i++) 00198 { 00199 StringList keyValue = StringOps::split ((*i), "="); 00200 if (keyValue.size () == 2) 00201 { 00202 typedef std::pair <std::string, std::string> MapPair; 00203 pluginOpts.insert (MapPair (keyValue[0], keyValue [1])); 00204 } 00205 } 00206 00207 if (pluginOpts.find ("app") != pluginOpts.end ()) 00208 { 00209 os << "<td><a href=\""<<proxy<< "/Studio/launch?script=" <<proxy<< pluginOpts["url"] << "\">" 00210 "<img src=\"" + pluginOpts["img"] + "\" alt=\"No Image\"/><br/>" 00211 + pluginOpts["name"] + "</a></td>"; 00212 j++; 00213 } 00214 } 00215 } 00216 os << "</tr></table>"; 00217 if(!validUserAgent) 00218 { 00219 os <<"<br><div class=\"warning\"><center><b>IGUANA Server Warning:</b></center>" 00220 "We are sorry but IGUANA server might not work properly for your broswer \"" + userAgent + "\".</div>\n"; 00221 } 00222 os << "</div></body></html>\r\n"; 00223 }
Definition at line 109 of file IgStudioWebService.cc.
References IgWebService::Arguments::args(), IgServerSocket::cmdLineProxy(), m_sessionUrl, IgWebService::Arguments::outputDevice(), and IgServerSocket::redirect().
Referenced by IgStudioWebService().
00110 { 00111 QIODevice *outputDevice = arguments->outputDevice (); 00112 ArgumentsMap &args = *(arguments->args ()); 00113 QTextStream os (outputDevice); 00114 00115 if (args.find ("script") == args.end ()) 00116 { 00117 os << IgServerSocket::redirect (IgServerSocket::cmdLineProxy() + "/Studio/login", "", ""); 00118 return; 00119 } 00120 00121 if (m_sessionUrl.empty ()) 00122 m_sessionUrl = args["script"]; 00123 00124 os << IgServerSocket::redirect (m_sessionUrl, "", ""); 00125 }
Definition at line 64 of file IgStudioWebService.cc.
References IgServerSocket::cmdLineProxy(), lat::endl(), DBSPlugin::get(), IgWebService::Arguments::idCookie(), LOG, IgWebService::Arguments::outputDevice(), IgServerSocket::redirect(), IgWebService::state(), IgWebService::Arguments::state(), and GsfMatrixTools::trace().
Referenced by IgStudioWebService().
00065 { 00066 QIODevice *outputDevice = arguments->outputDevice (); 00067 IgState *state = arguments->state (); 00068 QTextStream os (outputDevice); 00069 LOG (0, trace, LFstudioWeb, "Cookie: " 00070 << arguments->idCookie () << std::endl); 00071 00072 IgArgsElement *args = IgArgsElement::get (state); 00073 if (args->exists ("--demo")) 00074 { 00075 os << "HTTP/1.1 200 Ok\r\n" 00076 << "Content-Type: text/html; charset=\"utf-8\"\r\n\r\n" 00077 << "<html>" 00078 << "<head><title>DEMO IN PROGRESS</title></head>" 00079 << "<body><H1>DEMO IN PROGRESS</H1>In order to avoid " 00080 << "interference with the demo, external users cannot login " 00081 << "to the IGUANA server.<br/><br/>" 00082 << "You are kindly requested to look at the speaker.</body>" 00083 << "</html>\r\n"; 00084 } 00085 else 00086 os << IgServerSocket::redirect (IgServerSocket::cmdLineProxy() + "/Studio/initSession", "", ""); 00087 }
Definition at line 90 of file IgStudioWebService.cc.
References IgServerSocket::cmdLineProxy(), lat::endl(), cmsRelvalreport::exit, IgWebService::Arguments::idCookie(), LOG, IgWebService::Arguments::outputDevice(), and GsfMatrixTools::trace().
Referenced by IgStudioWebService().
00091 { 00092 QIODevice *outputDevice = arguments->outputDevice (); 00093 QTextStream os (outputDevice); 00094 LOG (0, trace, LFstudioWeb, "Cookie: " 00095 << arguments->idCookie () << std::endl); 00096 00097 os << "HTTP/1.1 200 Ok\r\n" 00098 << "Content-Type: text/html; charset=\"utf-8\"\r\n\r\n" 00099 << "<html><head><title>IGUANA Web Server</title></head><body>" 00100 <<"<H2>IGUANA Server Logout</H2>Thanks a lot for using IGUANA Web Server. " 00101 <<"Please do visit <A HREF=\""<<IgServerSocket::cmdLineProxy()<<"\"> IGUANA server</A> again.<br/><br/>" 00102 <<"<b>--IGUANA Team</b></body></html>\r\n"; 00103 outputDevice->close(); 00104 outputDevice->flush(); 00105 exit (0); 00106 }
std::string IgStudioWebService::m_sessionUrl [private] |