diff options
author | deva <deva> | 2008-07-30 12:58:13 +0000 |
---|---|---|
committer | deva <deva> | 2008-07-30 12:58:13 +0000 |
commit | 6c9a544e63e73c8aa3e990e9370ca9c582612f49 (patch) | |
tree | 76c2cdd65500116dc5b1539ef1baa0eedeacc01f /server/src | |
parent | 0da554ba6a55bbc195a30afa8f154af2ec2107a7 (diff) |
Reenabled support for upload server. Currently only tested against local print-to-screen version.
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/macroparser.cc | 38 | ||||
-rw-r--r-- | server/src/macroparser.h | 6 | ||||
-rw-r--r-- | server/src/server.cc | 44 | ||||
-rw-r--r-- | server/src/template.h | 4 | ||||
-rw-r--r-- | server/src/templateparser.cc | 13 | ||||
-rw-r--r-- | server/src/templateparser.h | 2 |
6 files changed, 42 insertions, 65 deletions
diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc index 9175c07..356de1f 100644 --- a/server/src/macroparser.cc +++ b/server/src/macroparser.cc @@ -68,7 +68,7 @@ MacroParser::MacroParser(std::string macro) state = UNDEFINED; m = NULL; current_map = NULL; - current_luaprogram = NULL; + current_script = NULL; file = XML"/macros/" + macro + ".xml"; @@ -91,9 +91,9 @@ void MacroParser::characterData(std::string &data) current_map->attributes["lua"].append(data); } - if(state == LUAPROGRAM) { - assert(current_luaprogram); // No lua program present! - current_luaprogram->attributes["lua"].append(data); + if(state == SCRIPT) { + assert(current_script); // No script present! + current_script->attributes["code"].append(data); } } @@ -161,10 +161,10 @@ void MacroParser::startTag(std::string name, std::map< std::string, std::string> return; } - // Enable LUA Program parsing - if(name == "luaprograms") { - if(state != MACRO) error("luaprograms found outside macro."); - state = LUAPROGRAMS; + // Enable script parsing + if(name == "scripts") { + if(state != MACRO) error("scripts found outside macro."); + state = SCRIPTS; assert(m); // No macro is currently available, cannot create maps! @@ -172,16 +172,16 @@ void MacroParser::startTag(std::string name, std::map< std::string, std::string> } // Create Query - if(name == "luaprogram") { - if(state != LUAPROGRAMS) error("lua program found outside maps."); - state = LUAPROGRAM; + if(name == "script") { + if(state != SCRIPTS) error("script found outside scripts."); + state = SCRIPT; assert(m); // No macro is currently available, cannot create map! - LUAProgram l; - l.attributes = attributes; - m->luaprograms.push_back(l); - current_luaprogram = &(m->luaprograms.back()); + Script s; + s.attributes = attributes; + m->scripts.push_back(s); + current_script = &(m->scripts.back()); return; } @@ -243,10 +243,10 @@ void MacroParser::endTag(std::string name) current_map = NULL; state = MAPS; } - if(name == "luaprograms") state = MACRO; - if(name == "luaprogram") { - current_luaprogram = NULL; - state = LUAPROGRAMS; + if(name == "scripts") state = MACRO; + if(name == "script") { + current_script = NULL; + state = SCRIPTS; } if(name == "window") state = MACRO; diff --git a/server/src/macroparser.h b/server/src/macroparser.h index 0b755f0..cbd36ba 100644 --- a/server/src/macroparser.h +++ b/server/src/macroparser.h @@ -39,8 +39,8 @@ class MacroParser : public SAXParser { MAPS, MAP, WINDOW, - LUAPROGRAMS, - LUAPROGRAM + SCRIPTS, + SCRIPT } ParserState; public: @@ -66,7 +66,7 @@ private: ParserState state; Macro *m; Map *current_map; - LUAProgram *current_luaprogram; + Script *current_script; std::vector< Widget* > widgetstack; // Error callback function. diff --git a/server/src/server.cc b/server/src/server.cc index 1bd0ccf..65fd782 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -83,28 +83,18 @@ static void connection(TCPSocket &socket) while(i != transaction.commits.end()) { Commit &commit = *i; - /* - Macro macro; - MacroParser parser(commit.macro, macro); - parser.parse(); - */ - - Macro macro; - macro.attributes["name"] = commit.macro; - macro.attributes["version"] = "1.0";//commit.version; - - db.commit(transaction.user, transaction.cpr, macro, commit.fields); + MacroParser mp(commit.macro); + mp.parse(); + Macro *macro = mp.getMacro(); + + db.commit(transaction.user, transaction.cpr, *macro, commit.fields); - /* - std::string resume = resume_parser(macro.format.c_str(), commit); + std::string resume = resume_parser(macro->attributes["resume"].c_str(), commit); - std::string journal_commit_addr = config()->lookup("journal_commit_addr"); - int journal_commit_port = config()->lookup("journal_commit_port"); - - journal_commit(transaction.cpr.c_str(), transaction.user.c_str(), - journal_commit_addr.c_str(), journal_commit_port, - resume.c_str(), resume.length()); - */ + 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()); + i++; } } @@ -175,20 +165,22 @@ static void connection(TCPSocket &socket) answer += " <macro name=\"" + macro.attributes["name"] + "\" completed="; if(db.checkMacro(transaction.cpr, macro.attributes["name"])) answer += "\"true\""; else answer += "\"false\""; + // answer += " resume=\"" + macro.attributes["resume"] + "\""; answer += ">\n"; if(macro.attributes["name"] == request.macro) { // Handle lua programs - if(m->luaprograms.size()) { + if(m->scripts.size()) { answer += " <scripts>\n"; - std::vector< LUAProgram >::iterator lpi = m->luaprograms.begin(); - while(lpi != m->luaprograms.end()) { - answer += " <script language=\"lua\" name=\"" + lpi->attributes["name"] + "\">\n"; - answer += xml_encode(lpi->attributes["lua"]); + std::vector< Script >::iterator spi = m->scripts.begin(); + while(spi != m->scripts.end()) { + answer += " <script language=\"" + spi->attributes["language"] + + "\" name=\"" + spi->attributes["name"] + "\">\n"; + answer += xml_encode(spi->attributes["code"]); answer += "\n </script>\n"; - lpi++; + spi++; } answer += " </scripts>\n"; } diff --git a/server/src/template.h b/server/src/template.h index f19746a..d047712 100644 --- a/server/src/template.h +++ b/server/src/template.h @@ -36,7 +36,7 @@ public: std::map< std::string, std::string > attributes; }; -class LUAProgram { +class Script { public: std::map< std::string, std::string > attributes; }; @@ -55,7 +55,7 @@ class Macro { public: std::vector< Query > queries; std::vector< Map > maps; - std::vector< LUAProgram > luaprograms; + std::vector< Script > scripts; Widget window; std::map< std::string, std::string > attributes; }; diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index 1fecc20..8874b74 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -68,8 +68,6 @@ TemplateParser::TemplateParser(std::string course) state = UNDEFINED; t = new Template(); current_macro = NULL; - current_map = NULL; - current_luaprogram = NULL; file = XML"/templates/" + course + ".xml"; @@ -87,17 +85,6 @@ TemplateParser::~TemplateParser() void TemplateParser::characterData(std::string &data) { - /* - if(state == MAP) { - assert(current_map); // No map present! - current_map->attributes["lua"].append(data); - } - - if(state == LUAPROGRAM) { - assert(current_luaprogram); // No lua program present! - current_luaprogram->attributes["lua"].append(data); - } - */ } void TemplateParser::startTag(std::string name, std::map< std::string, std::string> attributes) diff --git a/server/src/templateparser.h b/server/src/templateparser.h index 596bf27..f69009a 100644 --- a/server/src/templateparser.h +++ b/server/src/templateparser.h @@ -67,8 +67,6 @@ private: ParserState state; Template *t; Macro *current_macro; - Map *current_map; - LUAProgram *current_luaprogram; std::vector< Widget* > widgetstack; // Error callback function. |