summaryrefslogtreecommitdiff
path: root/server/src/server.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/server.cc')
-rw-r--r--server/src/server.cc63
1 files changed, 29 insertions, 34 deletions
diff --git a/server/src/server.cc b/server/src/server.cc
index 6f875b8..353708f 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -123,39 +123,6 @@ static void connection(TCPSocket &socket)
Template *templ = tp.getTemplate();
-#ifndef WITHOUT_PENTOMINOS
- // Send the queries to Pentominos (if any)
- TCPSocket s;
- s.connect(Conf::pentominos_addr, Conf::pentominos_port);
- QueryHandler qh(&s, transaction.cpr);
-
- std::vector< Macro >::iterator mi = templ->course.macroes.begin();
- while(mi != templ->course.macroes.end()) {
- Macro &macro = (*mi);
- if(macro.attributes["name"] == request.macro) {
-
- std::vector< Query >::iterator qi = m->queries.begin();
- while(qi != m->queries.end()) {
- qh.addQuery(*qi);
- qi++;
- }
- }
- mi++;
- }
- std::string result = qh.exec();
-
- printf("Got result: [%s]\n", result.c_str());
-#else
- std::string result = "";
-#endif/*WITHOUT_PENTOMINOS*/
-
- // Parse the result from the queries to pentominos
- QueryParser qp(result);
- qp.parse();
-
- // Map the results
- LUAQueryMapper lqm(qp.result);
-
answer += " <course name=\"";
answer += templ->course.attributes["name"];
answer += "\">\n";
@@ -172,6 +139,15 @@ static void connection(TCPSocket &socket)
else answer += "\"false\"";
answer += ">\n";
+ ///////////////////////////////
+ // Send the queries to Pentominos (if any)
+ TCPSocket s;
+#ifndef WITHOUT_PENTOMINOS
+ s.connect(Conf::pentominos_addr, Conf::pentominos_port);
+#endif/*WITHOUT_PENTOMINOS*/
+ QueryHandler qh(&s, transaction.cpr);
+ ///////////////////////////////
+
if(macro.attributes["name"] == request.macro) {
foundmacro = true;
@@ -180,7 +156,17 @@ static void connection(TCPSocket &socket)
mp.parse();
Macro *m = mp.getMacro();
- // Handle lua programs
+ ////////////////////////
+ std::vector< Query >::iterator qi = m->queries.begin();
+ while(qi != m->queries.end()) {
+ qh.addQuery(*qi);
+ qi++;
+ }
+ std::string result = qh.exec();
+ printf("Got result: [%s]\n", result.c_str());
+ /////////////////////////
+
+ // Handle scripts
if(m->scripts.size()) {
answer += " <scripts>\n";
@@ -194,6 +180,15 @@ static void connection(TCPSocket &socket)
}
answer += " </scripts>\n";
}
+
+ /////////////////////////
+ // Parse the result from the queries to pentominos
+ QueryParser qp(result);
+ qp.parse();
+ // Map the results
+ LUAQueryMapper lqm(qp.result);
+ ////////////////////////
+
answer += widgetgenerator(*m, lqm, db);
}
answer += " </macro>\n";