diff options
author | deva <deva> | 2009-06-22 09:07:24 +0000 |
---|---|---|
committer | deva <deva> | 2009-06-22 09:07:24 +0000 |
commit | 3bfeec0bfb4afb3fbd443d724007ade4683c2acf (patch) | |
tree | c4e85b079ba5fdc74ef080f2fa6a33d1a0204cbe /server | |
parent | f6506e34a84256f0620ee97559bf415c27b9974c (diff) |
Added some debug output in widget generation.
Diffstat (limited to 'server')
-rw-r--r-- | server/src/widgetgenerator.cc | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/server/src/widgetgenerator.cc b/server/src/widgetgenerator.cc index 90d2b9e..df1dcfb 100644 --- a/server/src/widgetgenerator.cc +++ b/server/src/widgetgenerator.cc @@ -72,10 +72,20 @@ static std::string send_macro_widget(Macro ¯o, std::string prefilled; time_t timestamp = 0; - + time_t now = time(NULL); + result = tabs + "<" + widget.attributes["tagname"]; std::map< std::string, std::string >::iterator p = widget.attributes.begin(); + PRACRO_DEBUG(prefill, "%s: %s\n", + widget.attributes["tagname"].c_str(), + widget.attributes["name"].c_str()); + + PRACRO_DEBUG(prefill, "0: (%s, %s, %d)\n", + prefilled.c_str(), + widget.attributes["value"].c_str(), + (int)timestamp); + // Check if the field has a map, and fill in the value if it has... if(widget.attributes.find("map") != widget.attributes.end()) { std::string luamap; @@ -98,27 +108,51 @@ static std::string send_macro_widget(Macro ¯o, if(luamap != "") { Value value = mapper.map(luamap); - if(value.timestamp > time(NULL) - Conf::pentominos_max_ttl) { + if(value.timestamp > now - Conf::pentominos_max_ttl) { widget.attributes["value"] = xml_encode(value.value); timestamp = value.timestamp; prefilled = xml_encode(value.source); } + + PRACRO_DEBUG(prefill, "map: (%s, %d)\n", + value.value.c_str(), + (int)value.timestamp); + } + // widget.attributes.erase(widget.attributes.find("map")); } + PRACRO_DEBUG(prefill, "1: (%s, %s, %d)\n", + prefilled.c_str(), + widget.attributes["value"].c_str(), + (int)timestamp); + // Check if there is a previously stored value in the db... - if(values.find(widget.attributes["name"]) != values.end() && - (prefilled == "" || values[widget.attributes["name"]].timestamp > timestamp)) { - if(values[widget.attributes["name"]].timestamp > time(NULL) - Conf::db_max_ttl) { - widget.attributes["value"] = xml_encode(values[widget.attributes["name"]].value); - prefilled = "pracro"; + if(values.find(widget.attributes["name"]) != values.end()) { + + PRACRO_DEBUG(prefill, "db: (%s, %d)\n", + values[widget.attributes["name"]].value.c_str(), + (int)values[widget.attributes["name"]].timestamp); + + if(prefilled == "" || values[widget.attributes["name"]].timestamp > timestamp) { + if(values[widget.attributes["name"]].timestamp > now - Conf::db_max_ttl) { + widget.attributes["value"] = xml_encode(values[widget.attributes["name"]].value); + timestamp = values[widget.attributes["name"]].timestamp; + prefilled = "pracro"; + } } } + PRACRO_DEBUG(prefill, "2: (%s, %s, %d)\n", + prefilled.c_str(), + widget.attributes["value"].c_str(), + (int)timestamp); + while(p != widget.attributes.end()) { if(p->first != "tagname" && p->first != "map") { - if( ! (p->first == "name" && p->second == "") ) result += " " + p->first + "=\"" + p->second + "\""; + if( ! (p->first == "name" && p->second == "") ) + result += " " + p->first + "=\"" + p->second + "\""; } p++; } |