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.cc46
1 files changed, 35 insertions, 11 deletions
diff --git a/server/src/server.cc b/server/src/server.cc
index 83d9157..ad7065e 100644
--- a/server/src/server.cc
+++ b/server/src/server.cc
@@ -97,10 +97,15 @@ static std::string handleTransaction(Transaction &transaction)
std::string resume = resume_parser(macro->attributes["resume"].c_str(), commit);
- journal_commit(transaction.cpr.c_str(), transaction.user.c_str(),
- Conf::journal_commit_addr.c_str(), Conf::journal_commit_port,
- resume.c_str(), resume.length());
-
+ // if(resume != "") {
+ journal_commit(transaction.cpr.c_str(), transaction.user.c_str(),
+ Conf::journal_commit_addr.c_str(), Conf::journal_commit_port,
+ resume.c_str(), resume.length());
+
+ db.putJournal(transaction.user, transaction.cpr,
+ *macro, resume, time(NULL));
+ // }
+
i++;
}
}
@@ -131,19 +136,31 @@ static std::string handleTransaction(Transaction &transaction)
std::vector< Macro >::iterator mi2 = templ->course.macroes.begin();
while(mi2 != templ->course.macroes.end()) {
Macro &macro = (*mi2);
+
+ bool completed = db.checkMacro(transaction.cpr, macro.attributes["name"]);
- answer += " <macro name=\"" + macro.attributes["name"] + "\" completed=";
- if(db.checkMacro(transaction.cpr, macro.attributes["name"])) answer += "\"true\"";
+ answer += " <macro completed=";
+ if(completed) answer += "\"true\"";
else answer += "\"false\"";
-
- if(macro.attributes["name"] == request.macro) {
- answer += ">\n";
+ std::map< std::string, std::string >::iterator ai = macro.attributes.begin();
+ while(ai != macro.attributes.end()) {
+ std::string name = ai->first;
+ std::string value = ai->second;
+ answer += " "+name+"=\"" + value + "\"";
+ ai++;
+ }
+
+ if(macro.attributes["name"] == request.macro ||
+ (macro.attributes.find("static") != macro.attributes.end() && macro.attributes["static"] == "true")
+ ) {
foundmacro = true;
- MacroParser mp(request.macro);
+ MacroParser mp(macro.attributes["name"]);
mp.parse();
Macro *m = mp.getMacro();
+ answer += " caption=\"" + m->window.attributes["caption"] + "\"";
+ answer += ">\n";
LUAQueryMapper lqm;
@@ -197,10 +214,17 @@ static std::string handleTransaction(Transaction &transaction)
MacroParser mp(macro.attributes["name"]);
mp.parse();
Macro *m = mp.getMacro();
- answer += "caption=\"" + m->window.attributes["caption"] + "\"";
+ answer += " caption=\"" + m->window.attributes["caption"] + "\"";
answer += ">\n";
}
+
+ if(completed) {
+ answer += " <resume>";
+ answer += db.getResume(transaction.cpr, macro.attributes["name"], time(NULL) - Conf::db_max_ttl);
+ answer += " </resume>\n";
+ }
+
answer += " </macro>\n";
mi2++;