summaryrefslogtreecommitdiff
path: root/server/src/widgetgenerator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/widgetgenerator.cc')
-rw-r--r--server/src/widgetgenerator.cc35
1 files changed, 19 insertions, 16 deletions
diff --git a/server/src/widgetgenerator.cc b/server/src/widgetgenerator.cc
index 6234513..43b202f 100644
--- a/server/src/widgetgenerator.cc
+++ b/server/src/widgetgenerator.cc
@@ -26,17 +26,18 @@
*/
#include "widgetgenerator.h"
-static void send_macro_widget(Macro &macro,
- Widget &widget,
- TCPSocket &socket,
- std::string tabs,
- LUAQueryMapper &mapper,
- Values &values)
+static std::string send_macro_widget(Macro &macro,
+ Widget &widget,
+ std::string tabs,
+ LUAQueryMapper &mapper,
+ Values &values)
{
+ std::string result;
+
std::string prefilled;
time_t timestamp = 0;
- socket.write(tabs + "<" + widget.attributes["type"]);
+ result = tabs + "<" + widget.attributes["type"];
std::map< std::string, std::string >::iterator p = widget.attributes.begin();
// Check if the field has a map, and fill in the value if it has...
@@ -72,26 +73,28 @@ static void send_macro_widget(Macro &macro,
while(p != widget.attributes.end()) {
if(p->first != "type" && p->first != "map") {
- socket.write(" " + p->first + "=\"" + p->second + "\"");
+ result += " " + p->first + "=\"" + p->second + "\"";
}
p++;
}
- if(prefilled != "") socket.write(" prefilled=\"" + prefilled + "\"");
+ if(prefilled != "") result += " prefilled=\"" + prefilled + "\"";
if(widget.widgets.size() == 0) { // If node is empty, use short tag form
- socket.write("/>\n");
- return;
+ result += "/>\n";
+ return result;
}
- socket.write(">\n");
+ result += ">\n";
std::vector< Widget >::iterator w = widget.widgets.begin();
while(w != widget.widgets.end()) {
- send_macro_widget(macro, *w, socket, tabs + " ", mapper, values);
+ result += send_macro_widget(macro, *w, tabs + " ", mapper, values);
w++;
}
- socket.write(tabs + "</" + widget.attributes["type"] + ">\n");
+ result += tabs + "</" + widget.attributes["type"] + ">\n";
+
+ return result;
}
static void get_fields(Widget &widget, Fieldnames &fields)
@@ -107,12 +110,12 @@ static void get_fields(Widget &widget, Fieldnames &fields)
}
}
-void widgetgenerator(TCPSocket &socket, Macro &macro, LUAQueryMapper &mapper, Database &db)
+std::string widgetgenerator(Macro &macro, LUAQueryMapper &mapper, Database &db)
{
Fieldnames fields;
get_fields(macro.window, fields);
Values values = db.getValues("2003791613", fields);
- send_macro_widget(macro, macro.window, socket, " ", mapper, values);
+ return send_macro_widget(macro, macro.window, " ", mapper, values);
}