From 1b9cf53926a6627b9f8ed00a8dc1f4a784e6f295 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 22 Sep 2008 12:17:51 +0000 Subject: 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. --- server/src/server.cc | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'server/src/server.cc') 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 ¯o = (*mi2); + + bool completed = db.checkMacro(transaction.cpr, macro.attributes["name"]); - answer += " ::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 += " "; + answer += db.getResume(transaction.cpr, macro.attributes["name"], time(NULL) - Conf::db_max_ttl); + answer += " \n"; + } + answer += " \n"; mi2++; -- cgit v1.2.3