From 534d9d66fcd65e4b9a1d330238eb252aa4d8ecfc Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 28 Feb 2005 20:16:42 +0000 Subject: [PATCH] Fetch the list of auxilliary screens. --- bigscreen/Makefile | 2 +- bigscreen/ccbs_bigscreen.cpp | 8 ++++++++ bigscreen/fetch_auxilliary_screens.cpp | 13 +++++++++++++ bigscreen/fetch_auxilliary_screens.h | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 bigscreen/fetch_auxilliary_screens.cpp create mode 100644 bigscreen/fetch_auxilliary_screens.h diff --git a/bigscreen/Makefile b/bigscreen/Makefile index ddb0f55..2621456 100644 --- a/bigscreen/Makefile +++ b/bigscreen/Makefile @@ -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 diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index fb53775..8180724 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -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 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::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 index 0000000..d889dc5 --- /dev/null +++ b/bigscreen/fetch_auxilliary_screens.cpp @@ -0,0 +1,13 @@ +#include "fetch_auxilliary_screens.h" + +FetchAuxilliaryScreens::FetchAuxilliaryScreens(std::vector *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 index 0000000..7aff0b6 --- /dev/null +++ b/bigscreen/fetch_auxilliary_screens.h @@ -0,0 +1,18 @@ +#ifndef _FETCH_AUXILLIARY_SCREENS_H +#define _FETCH_AUXILLIARY_SCREENS_H 1 + +#include +#include +#include "widestring.h" + +/* A transactor that fetches the current list of active groups. */ +class FetchAuxilliaryScreens : public pqxx::transactor<> { +private: + std::vector *screens; + +public: + FetchAuxilliaryScreens(std::vector *screens); + void operator() (pqxx::transaction<> &t); +}; + +#endif /* !defined(_FETCH_AUXILLIARY_SCREENS_H) */ -- 2.39.2