summaryrefslogtreecommitdiff
path: root/server/src/server.cc
diff options
context:
space:
mode:
authordeva <deva>2008-09-22 12:17:51 +0000
committerdeva <deva>2008-09-22 12:17:51 +0000
commit1b9cf53926a6627b9f8ed00a8dc1f4a784e6f295 (patch)
tree1a82a8e8ff50cc9d71e04867ca942e187605a1d9 /server/src/server.cc
parent8352be99474fbbeed5795e8610b3d9a23e38b1cd (diff)
Added resume storing to the db, and made the outputted xml use it. Added captions to the macro tags from the window-tag caption attribute. Made all template attributes fall through to the client.
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++;