]> git.sesse.net Git - ccbs/commitdiff
Fetch the list of auxilliary screens.
authorSteinar H. Gunderson <sesse@samfundet.no>
Mon, 28 Feb 2005 20:16:42 +0000 (20:16 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Mon, 28 Feb 2005 20:16:42 +0000 (20:16 +0000)
bigscreen/Makefile
bigscreen/ccbs_bigscreen.cpp
bigscreen/fetch_auxilliary_screens.cpp [new file with mode: 0644]
bigscreen/fetch_auxilliary_screens.h [new file with mode: 0644]

index ddb0f55df71461a308b96d9f48acab27922ee1bf..26214567ad1a16d566ed3912165aeee188af2a45 100644 (file)
@@ -4,7 +4,7 @@ CPPFLAGS=-I/usr/include/postgresql $(shell freetype-config --cflags) -Itinyptc/
 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
 
index fb53775f64e9d35ef194fc2e8554610eeac4df10..8180724c33bbb8f20231048fce44046f9357baa2 100644 (file)
@@ -9,6 +9,7 @@
 #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"
@@ -22,6 +23,8 @@ unsigned char framebuf[800 * 600 * 4], screenbuf[800 * 600 * 4];
 
 void init(pqxx::connection &conn)
 {
+       std::vector<widestring> aux_screens;
+               
        if (screens.size() == 0 || mainscreen != screens[0])
                delete mainscreen;
        
@@ -51,6 +54,11 @@ void init(pqxx::connection &conn)
                }
        }
 
+       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);
diff --git a/bigscreen/fetch_auxilliary_screens.cpp b/bigscreen/fetch_auxilliary_screens.cpp
new file mode 100644 (file)
index 0000000..d889dc5
--- /dev/null
@@ -0,0 +1,13 @@
+#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()) );
+       }
+}
diff --git a/bigscreen/fetch_auxilliary_screens.h b/bigscreen/fetch_auxilliary_screens.h
new file mode 100644 (file)
index 0000000..7aff0b6
--- /dev/null
@@ -0,0 +1,18 @@
+#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) */