diff options
Diffstat (limited to 'server/src/server.cc')
-rw-r--r-- | server/src/server.cc | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/server/src/server.cc b/server/src/server.cc index 9229f28..9708f9f 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -39,6 +39,7 @@ #include "transaction.h" #include "transactionparser.h" #include "templateparser.h" +#include "macroparser.h" #include "queryhandler.h" #include "queryparser.h" #include "luaquerymapper.h" @@ -49,17 +50,15 @@ static std::string error_box(std::string message) { - std::string errorbox; - - errorbox += " <course name=\"error\">\n"; - errorbox += " <macro name=\"error\">\n"; - errorbox += " <window caption=\"ERROR!\" height=\"240\" layout=\"vbox\" name=\"err\" width=\"320\">\n"; - errorbox += " <textedit name=\"errorlabel\" value=\"" + message + "\"/>\n"; - errorbox += " <button action=\"cancel\" caption=\"Luk\" name=\"cancel\"/>\n"; - errorbox += " </window>\n"; - errorbox += " </macro>\n"; - errorbox += " </course>\n"; - + std::string errorbox = + " <course name=\"error\">\n" + " <macro name=\"error\">\n" + " <window caption=\"ERROR!\" height=\"240\" layout=\"vbox\" name=\"error\" width=\"320\">\n" + " <textedit name=\"errorlabel\" value=\"" + message + "\"/>\n" + " <button action=\"cancel\" caption=\"Luk\" name=\"cancel\"/>\n" + " </window>\n" + " </macro>\n" + " </course>\n"; return errorbox; } @@ -115,6 +114,10 @@ static void connection(TCPSocket &socket) Requests::iterator i = transaction.requests.begin(); while(i != transaction.requests.end()) { Request &request = *i; + + MacroParser mp(request.macro); + mp.parse(); + Macro *m = mp.getMacro(); printf("Handling request - macro: %s, course: %s\n", request.macro.c_str(), request.course.c_str()); @@ -133,13 +136,14 @@ static void connection(TCPSocket &socket) while(mi != templ->course.macroes.end()) { Macro ¯o = (*mi); if(macro.attributes["name"] == request.macro) { - std::vector< Query >::iterator qi = macro.queries.begin(); - while(qi != macro.queries.end()) { + + std::vector< Query >::iterator qi = m->queries.begin(); + while(qi != m->queries.end()) { qh.addQuery(*qi); - qi++; + qi++; } } - mi++; + mi++; } std::string result = qh.exec(); @@ -166,12 +170,13 @@ static void connection(TCPSocket &socket) socket.write("\">\n"); if(macro.attributes["name"] == request.macro) { + // Handle lua programs - if(macro.luaprograms.size()) { + if(m->luaprograms.size()) { socket.write(" <luaprograms>\n"); - std::vector< LUAProgram >::iterator lpi = macro.luaprograms.begin(); - while(lpi != macro.luaprograms.end()) { + std::vector< LUAProgram >::iterator lpi = m->luaprograms.begin(); + while(lpi != m->luaprograms.end()) { socket.write(" <luaprogram name=\""); socket.write(lpi->attributes["name"]); socket.write("\">\n"); @@ -186,7 +191,7 @@ static void connection(TCPSocket &socket) socket.write(" </luaprograms>\n"); } - widgetgenerator(socket, macro, lqm, db); + widgetgenerator(socket, *m, lqm, db); } socket.write(" </macro>\n"); @@ -208,7 +213,6 @@ static void connection(TCPSocket &socket) void server() { - int PauseMode = 1; int port; try { port = config()->lookup("port"); @@ -246,7 +250,6 @@ void server() delete socket; socket = new TCPSocket(); socket->listen(port); - PauseMode = 0; } } |