From 158915fafe286df69a68374032187ae283eb4ded Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 23 May 2008 14:55:39 +0000 Subject: Did a lot of work on the database class. --- server/configure.in | 18 ++++- server/src/Makefile.am | 21 +++--- server/src/configuration.cc | 6 +- server/src/database.cc | 133 ++++++++++++++++++++++++++++++---- server/src/database.h | 18 +++-- server/src/server.cc | 4 +- server/src/tcpsocket.cc | 10 +-- server/src/tostring.cc | 161 ------------------------------------------ server/src/tostring.h | 112 ----------------------------- server/src/uid.cc | 63 ----------------- server/src/uid.h | 49 ------------- server/src/widgetgenerator.cc | 13 ++-- server/src/widgetgenerator.h | 4 +- 13 files changed, 185 insertions(+), 427 deletions(-) delete mode 100644 server/src/tostring.cc delete mode 100644 server/src/tostring.h delete mode 100644 server/src/uid.cc delete mode 100644 server/src/uid.h diff --git a/server/configure.in b/server/configure.in index 8cfb673..01afcad 100644 --- a/server/configure.in +++ b/server/configure.in @@ -6,7 +6,7 @@ AM_INIT_AUTOMAKE( pracrod, 0.0.1 ) dnl ====================== dnl Compile with debug options dnl ====================== -AC_ARG_WITH(debug, [ --with-debug build with debug support]) +AC_ARG_WITH(debug, [ --with-debug build with debug support]) if test x$with_debug == xyes; then AC_MSG_WARN([*** Building with debug support!]) CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector -Wall -Werror -g -O0" @@ -36,7 +36,7 @@ dnl ====================== dnl Use efence in linking and includes dnl ====================== AC_ARG_ENABLE(efence, - [ --enable-efence enable efence - for debugging only (no)], + [ --enable-efence enable efence - for debugging only (no)], [], [ enable_efence=no]) if test "x$enable_efence" = xno; then enable_efence=no @@ -46,6 +46,20 @@ else AC_DEFINE_UNQUOTED(USE_EFENCE, , [Use the efence includes]) fi +dnl ====================== +dnl Use duma in linking and includes +dnl ====================== +AC_ARG_ENABLE(duma, + [ --enable-duma enable duma - for debugging only (no)], + [], [ enable_duma=no]) +if test "x$enable_duma" = xno; then + enable_duma=no +else + LD_EFENCE="-lduma" + AC_SUBST(LD_DUMA) + AC_DEFINE_UNQUOTED(USE_DUMA, , [Use the duma includes]) +fi + dnl ====================== dnl Check for lua dnl ====================== diff --git a/server/src/Makefile.am b/server/src/Makefile.am index 52eade2..c21b814 100644 --- a/server/src/Makefile.am +++ b/server/src/Makefile.am @@ -22,8 +22,6 @@ pracrod_SOURCES = \ templateparser.cc \ transactionparser.cc \ tcpsocket.cc \ - tostring.cc \ - uid.cc \ widgetgenerator.cc EXTRA_DIST = \ @@ -43,8 +41,6 @@ EXTRA_DIST = \ templateparser.h \ transactionparser.h \ tcpsocket.h \ - tostring.h \ - uid.h \ widgetgenerator.h TESTFILES = \ @@ -52,7 +48,8 @@ TESTFILES = \ test_queryparser \ test_luaquerymapper \ test_templateparser \ - test_server + test_server \ + test_database TESTLOGS = `for F in ${TESTFILES}; do echo $$F.log; done` @@ -63,19 +60,23 @@ test_clean: rm -f $(TESTFILES) test_queryhandler: queryhandler.cc - @../../tools/test queryhandler.cc tcpsocket.cc exception.cc tostring.cc uid.cc log.cc + @../../tools/test queryhandler.cc tcpsocket.cc exception.cc uid.cc log.cc test_queryparser: queryparser.cc - @../../tools/test queryparser.cc queryhandler.cc tcpsocket.cc exception.cc tostring.cc uid.cc log.cc saxparser.cc -lexpat + @../../tools/test queryparser.cc queryhandler.cc tcpsocket.cc exception.cc uid.cc log.cc saxparser.cc -lexpat test_luaquerymapper: luaquerymapper.cc - @../../tools/test luaquerymapper.cc queryparser.cc queryhandler.cc tcpsocket.cc exception.cc tostring.cc uid.cc log.cc saxparser.cc -lexpat $(LUA_LIBS) + @../../tools/test luaquerymapper.cc queryparser.cc queryhandler.cc tcpsocket.cc exception.cc uid.cc log.cc saxparser.cc -lexpat $(LUA_LIBS) test_templateparser: templateparser.cc @../../tools/test templateparser.cc saxparser.cc -lexpat -DXML="\"../xml\"" test_server: server.cc - @../../tools/test server.cc templateparser.cc saxparser.cc queryparser.cc queryhandler.cc luaquerymapper.cc tcpsocket.cc exception.cc log.cc configuration.cc tostring.cc transactionparser.cc widgetgenerator.cc -lexpat $(LUA_LIBS) $(CONFIG_LIBS) -DXML="\"../xml\"" - killall -9 test_server + @../../tools/test server.cc templateparser.cc saxparser.cc queryparser.cc queryhandler.cc luaquerymapper.cc tcpsocket.cc exception.cc log.cc configuration.cc transactionparser.cc widgetgenerator.cc -lexpat $(LUA_LIBS) $(CONFIG_LIBS) -DXML="\"../xml\"" + +#killall -9 test_server + +test_database: database.cc + @../../tools/test database.cc $(PQXX_LIBS) $(PQXX_CXXFLAGS) CLEANFILES = $(TESTFILES) $(TESTLOGS) *~ diff --git a/server/src/configuration.cc b/server/src/configuration.cc index 3b59c93..3f8e9d6 100644 --- a/server/src/configuration.cc +++ b/server/src/configuration.cc @@ -28,8 +28,6 @@ #include "debug.h" -#include "tostring.h" - Configuration::Configuration(std::string filename) { this->filename = filename; @@ -45,8 +43,10 @@ void Configuration::reload() } catch(libconfig::FileIOException) { throw ConfigurationException("Could not read config file: File does not exist."); } catch(libconfig::ParseException &e) { + char lineno[32]; + sprintf(lineno, "%d", e.getLine()); throw ConfigurationException(std::string("Error when parsing the config file in line ") - + toString(e.getLine()) + ": " + e.getError()); + + lineno + ": " + e.getError()); } } diff --git a/server/src/database.cc b/server/src/database.cc index 8f28443..fc87339 100644 --- a/server/src/database.cc +++ b/server/src/database.cc @@ -26,14 +26,8 @@ */ #include "database.h" -//#include "tostring.h" -#include "uid.h" - Database::Database(std::string hostname, std::string user, std::string password) - : c("host=" + hostname + - " user=" + user + - " password=" + password + - " dbname=pracro") + : c("host=" + hostname + " user=" + user + " password=" + password + " dbname=pracro") { } @@ -41,11 +35,56 @@ Database::~Database() { } -int Database::post(std::string &user, std::string &cpr, time_t now, Commit &commit) +void Database::commit(std::string user, + std::string cpr, + Macro &_macro, + Fields &values, + time_t now) { + // / Create transaction ID (transaction OID?) + // { + // \ Commit transaction data + + // Commit all field values using transaction ID. + + // INSERT INTO transactions VALUES('cpr', 'macro', 'version', 'timestamp', 'user') + // Returns INSERT oid count + // count == 1, oid is oid of newly inserted transaction. + + // INSERT INTO fields VALUES('oid', 'field', 'value') + + std::string version = _macro.attributes["version"]; + std::string macro = _macro.attributes["name"]; + std::stringstream timestamp; timestamp << now; + + pqxx::work W(c); + + std::string ts = + "INSERT INTO transactions" + " VALUES('"+cpr+"', '"+macro+"', '"+version+"', '"+timestamp.str()+"', '"+user+"')"; + + pqxx::result R = W.exec(ts); + + std::stringstream oid; oid << R.inserted_oid(); + + std::map< std::string, std::string >::iterator i = values.begin(); + while(i != values.end()) { + + std::string fs = + "INSERT INTO fields" + " VALUES('"+oid.str()+"', '"+i->first+"', '"+i->second+"')"; + + W.exec(fs); + + i++; + } + + W.commit(); + +#if 0 char timestamp[32]; sprintf(timestamp, "%u", (unsigned int)now); - UID uid; + // UID uid; try { pqxx::work W(c); @@ -85,9 +124,39 @@ int Database::post(std::string &user, std::string &cpr, time_t now, Commit &comm } catch(const std::exception &e) { // throw PostgreSQLException(e.what()); } +#endif/*0*/ +} + + +Fields Database::getValues(std::string cpr, + std::vector< std::string > &fields, + time_t oldest) +{ + Fields v; + pqxx::work W(c); + + std::vector< std::string >::iterator i = fields.begin(); + while(i != fields.end()) { + + // TODO: Return only results that are recent enough (use oldest in statement) + std::string query = "SELECT name, value FROM fields WHERE name='" + (*i) + "'"; + pqxx::result R = W.exec(query); + + pqxx::result::const_iterator ri = R.begin(); + while(ri != R.end()) { + pqxx::result::tuple t = *ri; + + v[t[0].c_str()] = t[1].c_str(); - return 0; + ri++; + } + + i++; + } + + return v; } + /* int Database::getTransaction(cpr, transid) { @@ -115,32 +184,40 @@ int Database::getMakro(cpr, macro) // # createdb -U postgres -h localhost pracro /* +DROP DATABASE pracro; + CREATE DATABASE pracro WITH OWNER = pracro ENCODING = 'UNICODE' TABLESPACE = pg_default; +DROP TABLE transactions; + CREATE TABLE transactions ( "cpr" varchar(11), - "transaction" text, "makro" text, "version" text, "timestamp" bigint, "user" text -) +) WITH OIDS; ALTER TABLE transactions OWNER TO pracro; +DROP TABLE fields; + CREATE TABLE fields ( - "transaction" text, + "transaction" oid, "name" text, "value" text ) WITH OIDS; ALTER TABLE fields OWNER TO pracro; + +primary key(oid) ?? + // Get all matching fields SELECT transactions.timestamp, transactions.transaction, fields.name, fields.value FROM transactions, fields @@ -167,3 +244,33 @@ SELECT transactions.timestamp, transactions.transaction, fields.name, fields.val FROM Employees, Orders WHERE Employees.Employee_ID=Orders.Employee_ID */ + +#ifdef TEST_DATABASE + +int main() +{ + Database db; + + Macro macro; + macro.attributes["name"] = "testmacro"; + macro.attributes["version"] = "1.0"; + + Fields fields; + fields["themeaning"] = "42"; + fields["microsoft"] = "waste of money"; + + db.commit("testuser", "1505050505", macro, fields); + + std::vector< std::string > fieldnames; + fieldnames.push_back("microsoft"); + fieldnames.push_back("themeaning"); + + Fields results = db.getValues("1505050505", fieldnames); + Fields::iterator i = results.begin(); + while(i != results.end()) { + printf("%s -> %s\n", i->first.c_str(), i->second.c_str()); + i++; + } +} + +#endif/*TEST_DATABASE*/ diff --git a/server/src/database.h b/server/src/database.h index 157cf6d..51c0f1a 100644 --- a/server/src/database.h +++ b/server/src/database.h @@ -28,10 +28,16 @@ #define __PRACRO_DATABASE_H__ #include + #include #include "transaction.h" +#include "template.h" #include +#include + +typedef std::map< std::string, std::string > Fields; + class Database { public: Database(std::string hostname = "localhost", @@ -39,13 +45,17 @@ public: std::string password = "pracro"); ~Database(); - int post(std::string &user, std::string &cpr, time_t now, Commit &commit); - // Make a commit to the db - void commit() {} + void commit(std::string user, + std::string cpr, + Macro ¯o, + Fields &fields, + time_t now = time(NULL)); // Get a list of values from the db - void getValues() {} + Fields getValues(std::string cpr, + std::vector< std::string > &fieldnames, + time_t oldest = 0); // Connect to the db void connect() {} diff --git a/server/src/server.cc b/server/src/server.cc index b5631f0..77b3a6f 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -56,6 +56,8 @@ static void connection(TCPSocket &socket) socket.write("\n"); socket.write("\n"); + Database db; + /* // // Handle commits @@ -145,7 +147,7 @@ static void connection(TCPSocket &socket) socket.write("\">\n"); if(macro.attributes["name"] == request.macro) { - widgetgenerator(socket, macro, lqm); + widgetgenerator(socket, macro, lqm, db); } socket.write(" \n"); diff --git a/server/src/tcpsocket.cc b/server/src/tcpsocket.cc index d361b7b..4bb7a4b 100644 --- a/server/src/tcpsocket.cc +++ b/server/src/tcpsocket.cc @@ -28,8 +28,6 @@ #include "debug.h" -#include "tostring.h" - // for gethostbyname #include @@ -170,7 +168,9 @@ void TCPSocket::connect(std::string addr, unsigned short int port) struct hostent *he; he = gethostbyname(addr.c_str()); if(!he || !he->h_length) { - throw TCPConnectException(addr, toString(port), + char portno[32]; + sprintf(portno, "%d", port); + throw TCPConnectException(addr, portno, std::string("host lookup failed: ") + hstrerror(h_errno)); } @@ -188,7 +188,9 @@ void TCPSocket::connect(std::string addr, unsigned short int port) socketaddr.sin_addr.s_addr = inet_addr(ip); if(_connect(sock, (struct sockaddr*)&socketaddr, sizeof(socketaddr))) { - throw TCPConnectException(addr, toString(port), hstrerror(h_errno)); + char portno[32]; + sprintf(portno, "%d", port); + throw TCPConnectException(addr, portno, hstrerror(h_errno)); } isconnected = true; diff --git a/server/src/tostring.cc b/server/src/tostring.cc deleted file mode 100644 index 3179e00..0000000 --- a/server/src/tostring.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * tostring.cc - * - * Thu Mar 29 13:16:13 CEST 2007 - * Copyright 2006 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Artefact. - * - * Artefact is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Artefact is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Artefact; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include "tostring.h" - -#include "debug.h" - -#include - -std::string toString(std::string s) -{ - return s; -} - -std::string toString(char c) -{ - char buf[32]; - sprintf(buf, "%c", c); - std::string out = buf; - return buf; -} - -std::string toString(unsigned char c) -{ - char buf[32]; - sprintf(buf, "%c", c); - std::string out = buf; - return buf; -} - -std::string toString(short int si) -{ - char buf[32]; - sprintf(buf, "%d", si); - std::string out = buf; - return buf; -} - -std::string toString(short unsigned int su) -{ - char buf[32]; - sprintf(buf, "%u", su); - std::string out = buf; - return buf; -} - -std::string toString(int li) -{ - char buf[32]; - sprintf(buf, "%ld", (long int)li); - std::string out = buf; - return buf; -} - -std::string toString(unsigned int lu) -{ - char buf[32]; - sprintf(buf, "%lu", (long unsigned int)lu); - std::string out = buf; - return buf; -} - -std::string toString(bool b) -{ - if(b) return "true"; - else return "false"; -} - -std::string toString(float f, unsigned int precision) -{ - char buf[100]; - char format[12]; - sprintf(format, "%%.%uf", precision); - sprintf(buf, format, f); - std::string out = buf; - return buf; - return ""; -} - -std::string toString(double d, unsigned int precision) -{ - char buf[100]; - char format[12]; - sprintf(format, "%%.%uf", precision); - sprintf(buf, format, d); - std::string out = buf; - return buf; -} - -std::string toString(long double ld, unsigned int precision) -{ - char buf[100]; - char format[12]; - sprintf(format, "%%.%uLg", precision); - sprintf(buf, format, ld); - std::string out = buf; - return buf; -} - -#ifdef TEST_TOSTRING -/* Compile: - * c++ -DTEST_TOSTRING tostring.cc -o test_tostring - */ -using namespace Pentominos; - -int main() -{ - std::string s = "string"; - char c = -4; - unsigned char uc = 'a'; - short int si = 0x8000; - short unsigned int su = 0xffff; - long int li = 0x80000000L; - long unsigned int lu = 0xffffffffL; - bool b = true; - float f = 0.1; - double d = 0.1; - long double ld = 0.1; - -std::string str = - "[" + toString(s) - + "] [" + toString(c) - + "] [" + toString(uc) - + "] [" + toString(si) - + "] [" + toString(su) - // + "] [" + toString(li) - // + "] [" + toString(lu) - + "] [" + toString(b) - + "] [" + toString(f, 10) - + "] [" + toString(d, 18) - + "] [" + toString(ld, 36) - + "]"; - - printf("%s\n", str.c_str()); - - return 0; -} -#endif/*TEST_TOSTRING*/ diff --git a/server/src/tostring.h b/server/src/tostring.h deleted file mode 100644 index 137969f..0000000 --- a/server/src/tostring.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * tostring.h - * - * Thu Mar 29 13:16:13 CEST 2007 - * Copyright 2006 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Artefact. - * - * Artefact is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Artefact is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Artefact; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#ifndef __ARTEFACT_TOSTRING_H__ -#define __ARTEFACT_TOSTRING_H__ - -#include - -/** - * toString converts a nonstring variable into an STL string. - * @param s A string, converted into a... string... - * @return The STL string containing the converted value. - */ -std::string toString(std::string s); - -/** - * toString converts a nonstring variable into an STL string. - * @param c A char, converted into a string. - * @return The STL string containing the converted value. - */ -std::string toString(char c); - -/** - * toString converts a nonstring variable into an STL string. - * @param c A unsigned char, converted into a string. - * @return The STL string containing the converted value. - */ -std::string toString(unsigned char c); - -/** - * toString converts a nonstring variable into an STL string. - * @param si A short integer, converted into a string. - * @return The STL string containing the converted value. - */ -std::string toString(short int si); - -/** - * toString converts a nonstring variable into an STL string. - * @param su An unsigned short integer, converted into a string. - * @return The STL string containing the converted value. - */ -std::string toString(short unsigned int su); - -/** - * toString converts a nonstring variable into an STL string. - * @param li A long integer, converted into a string. - * @return The STL string containing the converted value. - */ -std::string toString(int li); - -/** - * toString converts a nonstring variable into an STL string. - * @param lu An unsigned long integer, converted into a string. - * @return The STL string containing the converted value. - */ -std::string toString(unsigned int lu); - -/** - * toString converts a nonstring variable into an STL string. - * @param b A boolean value, converted into a string (true/false). - * @return The STL string containing the converted value. - */ -std::string toString(bool b); - -/** - * toString converts a nonstring variable into an STL string. - * @param f A floating point value, converted into a string. - * @param precision The precision to use when converting. - * @return The STL string containing the converted value. - */ -std::string toString(float f, unsigned int precision = 8); - -/** - * toString converts a nonstring variable into an STL string. - * @param d A double precision floating point value, converted into a string. - * @param precision The precision to use when converting. - * @return The STL string containing the converted value. - */ -std::string toString(double d, unsigned int precision = 16); - -/** - * toString converts a nonstring variable into an STL string. - * @param ld A long double precision floating point value, converted into a string. - * @param precision The precision to use when converting. - * @return The STL string containing the converted value. - */ -std::string toString(long double ld, unsigned int precision = 32); - -#endif/*__ARTEFACT_TOSTRING_H__*/ diff --git a/server/src/uid.cc b/server/src/uid.cc deleted file mode 100644 index 47f7cac..0000000 --- a/server/src/uid.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * uid.cc - * - * Mon Sep 17 14:43:02 CEST 2007 - * Copyright 2007 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Pracro is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Pracro; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#include "uid.h" - -static time_t gettime() -{ - return time(NULL); -} - -UID::UID() -{ - this->time = gettime(); - this->pid = getpid(); - this->cnt = 0; -} - -void UID::operator++(int) -{ - cnt++; -} - -/* -std::string UID::operator(std::string)() -{ - // time_t now = time(NULL); - // std::string transidbase = toString((unsigned int)now) + "-" - // + toString((unsigned int)getpid()) + "-"; // Here we put the commit index - - return std::string("ding"); -} -*/ - -std::string UID::toString() -{ - // std::string uid; - char buf[256]; - sprintf(buf, "%08x%04x%02x", (unsigned int)time, pid, cnt); - return buf; -} diff --git a/server/src/uid.h b/server/src/uid.h deleted file mode 100644 index 6feaa5e..0000000 --- a/server/src/uid.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - * uid.h - * - * Mon Sep 17 14:43:02 CEST 2007 - * Copyright 2007 Bent Bisballe Nyeng - * deva@aasimon.org - ****************************************************************************/ - -/* - * This file is part of Pracro. - * - * Pracro is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Pracro is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Pracro; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ -#ifndef __PRACRO_UID_H__ -#define __PRACRO_UID_H__ - -#include -#include -#include -#include - -class UID { -public: - UID(); - void operator++(int); - // std::string operator(std::string)(); - - std::string toString(); - -private: - time_t time; - pid_t pid; - unsigned int cnt; -}; - -#endif/*__PRACRO_UID_H__*/ diff --git a/server/src/widgetgenerator.cc b/server/src/widgetgenerator.cc index 1aaca97..5211188 100644 --- a/server/src/widgetgenerator.cc +++ b/server/src/widgetgenerator.cc @@ -26,7 +26,12 @@ */ #include "widgetgenerator.h" -static void send_macro_widget(Macro ¯o, Widget &widget, TCPSocket &socket, std::string tabs, LUAQueryMapper &mapper) +static void send_macro_widget(Macro ¯o, + Widget &widget, + TCPSocket &socket, + std::string tabs, + LUAQueryMapper &mapper, + Database &db) { socket.write(tabs + "<" + widget.attributes["type"]); std::map< std::string, std::string >::iterator p = widget.attributes.begin(); @@ -65,13 +70,13 @@ static void send_macro_widget(Macro ¯o, Widget &widget, TCPSocket &socket, s std::vector< Widget >::iterator w = widget.widgets.begin(); while(w != widget.widgets.end()) { - send_macro_widget(macro, *w, socket, tabs + " ", mapper); + send_macro_widget(macro, *w, socket, tabs + " ", mapper, db); w++; } socket.write(tabs + "\n"); } -void widgetgenerator(TCPSocket &socket, Macro ¯o, LUAQueryMapper &mapper) +void widgetgenerator(TCPSocket &socket, Macro ¯o, LUAQueryMapper &mapper, Database &db) { - send_macro_widget(macro, macro.window, socket, " ", mapper); + send_macro_widget(macro, macro.window, socket, " ", mapper, db); } diff --git a/server/src/widgetgenerator.h b/server/src/widgetgenerator.h index 8d6c57b..2ed77df 100644 --- a/server/src/widgetgenerator.h +++ b/server/src/widgetgenerator.h @@ -32,9 +32,11 @@ #include "tcpsocket.h" #include "template.h" #include "luaquerymapper.h" +#include "database.h" void widgetgenerator(TCPSocket &socket, Macro ¯o, - LUAQueryMapper &mapper); + LUAQueryMapper &mapper, + Database &db); #endif/*__PRACRO_WIDGETGENERATOR_H__*/ -- cgit v1.2.3