summaryrefslogtreecommitdiff
path: root/server/src/transactionhandler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/transactionhandler.cc')
-rw-r--r--server/src/transactionhandler.cc57
1 files changed, 28 insertions, 29 deletions
diff --git a/server/src/transactionhandler.cc b/server/src/transactionhandler.cc
index bcdd638..4b4e7ca 100644
--- a/server/src/transactionhandler.cc
+++ b/server/src/transactionhandler.cc
@@ -107,11 +107,8 @@ static std::string handleRequest(Transaction &transaction, Environment &env,
Template *templ = tp.getTemplate();
- answer += " <template name=\"";
- answer += templ->attributes["name"];
- answer += "\" title=\"";
- answer += templ->attributes["title"];
- answer += "\">\n";
+ answer += " <template name=\"" + templ->name + "\" title=\"" +
+ templ->title + "\">\n";
bool foundmacro = false;
@@ -121,37 +118,42 @@ static std::string handleRequest(Transaction &transaction, Environment &env,
Macro &macro = (*mi2);
if(macro.isHeader) {
- answer += " <header caption=\"" + macro.attributes["caption"] +
- "\"/>\n";
+ answer += " <header caption=\"" + macro.caption + "\"/>\n";
mi2++;
continue;
}
- bool completed = db->checkMacro(transaction.cpr,
- macro.attributes["name"],
- session.id(),
- time(NULL)-Conf::db_max_ttl);
+ size_t oldest = time(NULL) - Conf::db_max_ttl;
+ if(macro.ttl != "") oldest = time(NULL) - atoi(macro.ttl.c_str());
+
+ bool completed =
+ db->checkMacro(transaction.cpr, macro.name, session.id(), oldest);
answer += " <macro uid=\"42\" completed=";
if(completed) answer += "\"true\"";
else answer += "\"false\"";
- std::map< std::string, std::string >::iterator ai =
- macro.attributes.begin();
- while(ai != macro.attributes.end()) {
+ attributes_t attr;
+ attr["name"] = macro.name;
+ attr["version"] = macro.version;
+ if(macro.caption != "") attr["caption"] = macro.caption;
+ if(macro.requires != "") attr["requires"] = macro.requires;
+ attr["static"] = macro.isStatic?"true":"false";
+ attr["compact"] = macro.isCompact?"true":"false";
+ attr["important"] = macro.isImportant?"true":"false";
+
+ attributes_t::iterator ai = attr.begin();
+ while(ai != attr.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")
- ) {
+ if(macro.name == request.macro || macro.isStatic) {
foundmacro = true;
- MacroParser mp(env.macrolist.getLatestVersion(macro.attributes["name"]));
+ MacroParser mp(env.macrolist.getLatestVersion(macro.name));
mp.parse();
Macro *m = mp.getMacro();
answer += " caption=\"" + m->widgets.attributes["caption"] + "\"";
@@ -225,11 +227,11 @@ static std::string handleRequest(Transaction &transaction, Environment &env,
answer += " </scripts>\n";
}
- answer += widgetgenerator(transaction.cpr, session.id(),
- *m, lqm, *db);
+ answer += widgetgenerator(transaction.cpr, session.id(), *m, lqm,
+ *db, oldest);
} else {
// only find macro title
- MacroParser mp(env.macrolist.getLatestVersion(macro.attributes["name"]));
+ MacroParser mp(env.macrolist.getLatestVersion(macro.name));
mp.parse();
Macro *m = mp.getMacro();
answer += " caption=\"" + m->widgets.attributes["caption"] + "\"";
@@ -238,15 +240,12 @@ static std::string handleRequest(Transaction &transaction, Environment &env,
}
if(completed) {
- std::string jresume =
- session.journal()->getEntry(macro.attributes["name"]);
+ std::string jresume = session.journal()->getEntry(macro.name);
std::string state = "old";
- std::string resume = db->getResume(transaction.cpr,
- macro,
- time(NULL) - Conf::db_max_ttl,
+ std::string resume = db->getResume(transaction.cpr, macro, oldest,
session.id());
- if(session.journal()->dirty(macro.attributes["name"])) {
+ if(session.journal()->dirty(macro.name)) {
state = "dirty";
} else {
if(resume == jresume) {
@@ -254,7 +253,7 @@ static std::string handleRequest(Transaction &transaction, Environment &env,
} else {
if(jresume != "") {
state = "dirty";
- session.journal()->setDirty(macro.attributes["name"]);
+ session.journal()->setDirty(macro.name);
} else {
state = "old";
}