CXXFLAGS=-g -Wall
LDFLAGS=-L/usr/X11R6/lib
LIBS=$(shell freetype-config --libs) $(shell libpq3-config) -lpqxx tinyptc/libtinyptc.a -lX11 -lXext
-CCBS_BIGSCREEN_OBJS=ccbs_bigscreen.o flagtrigger.o widestring.o fetch_current_tournament.o fetch_list_of_active_groups.o fetch_max_score_for_songs.o fetch_max_score_for_players.o fetch_group.o fetch_needs_update.o fetch_highscore.o fonts.o groupscreen.o splitscreen.o rotatescreen.o screen.o
+CCBS_BIGSCREEN_OBJS=ccbs_bigscreen.o flagtrigger.o widestring.o fetch_current_tournament.o fetch_list_of_active_groups.o fetch_max_score_for_songs.o fetch_max_score_for_players.o fetch_group.o fetch_needs_update.o fetch_highscore.o fetch_auxilliary_screens.o fonts.o groupscreen.o splitscreen.o rotatescreen.o screen.o
all: ccbs-bigscreen
#include "fetch_current_tournament.h"
#include "fetch_list_of_active_groups.h"
#include "fetch_group.h"
+#include "fetch_auxilliary_screens.h"
#include "fonts.h"
#include "groupscreen.h"
#include "splitscreen.h"
void init(pqxx::connection &conn)
{
+ std::vector<widestring> aux_screens;
+
if (screens.size() == 0 || mainscreen != screens[0])
delete mainscreen;
}
}
+ conn.perform(FetchAuxilliaryScreens(&aux_screens));
+ for (std::vector<widestring>::const_iterator i = aux_screens.begin(); i != aux_screens.end(); ++i) {
+// std::fprintf(stderr, "Auxilliary screen '%s'\n", i->c_str());
+ }
+
// hack
screens.push_back(NULL);
screens.push_back(NULL);
--- /dev/null
+#include "fetch_auxilliary_screens.h"
+
+FetchAuxilliaryScreens::FetchAuxilliaryScreens(std::vector<widestring> *screens) : screens(screens) {}
+void FetchAuxilliaryScreens::operator() (pqxx::transaction<> &t)
+{
+ // make sure we start with an empty list
+ screens->erase(screens->begin(), screens->end());
+
+ pqxx::result res( t.exec("SELECT * FROM bigscreen.active_screens") );
+ for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
+ screens->push_back( i["id"].as(widestring()) );
+ }
+}
--- /dev/null
+#ifndef _FETCH_AUXILLIARY_SCREENS_H
+#define _FETCH_AUXILLIARY_SCREENS_H 1
+
+#include <pqxx/transactor>
+#include <vector>
+#include "widestring.h"
+
+/* A transactor that fetches the current list of active groups. */
+class FetchAuxilliaryScreens : public pqxx::transactor<> {
+private:
+ std::vector<widestring> *screens;
+
+public:
+ FetchAuxilliaryScreens(std::vector<widestring> *screens);
+ void operator() (pqxx::transaction<> &t);
+};
+
+#endif /* !defined(_FETCH_AUXILLIARY_SCREENS_H) */