From 2cfb364d4726deb3550be71f25bf5b945e4594d1 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 3 Jan 2006 18:00:05 +0000 Subject: [PATCH] Recording timer list --- Makefile | 4 +- playervideo.cc | 2 +- rectimer.cc | 44 +++++++++++ rectimer.h | 50 +++++++++++++ vdr.cc | 56 ++++++++++++++ vdr.h | 5 ++ vtimerlist.cc | 197 +++++++++++++++++++++++++++++++++++++++++++++++++ vtimerlist.h | 56 ++++++++++++++ vwelcome.cc | 21 ++++++ vwelcome.h | 2 + 10 files changed, 434 insertions(+), 3 deletions(-) create mode 100644 rectimer.cc create mode 100644 rectimer.h create mode 100644 vtimerlist.cc create mode 100644 vtimerlist.h diff --git a/Makefile b/Makefile index 67e569b..276a265 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,8 @@ CROSSLIBS = ../jpeg-6b/libjpeg.a OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o directory.o thread.o event.o \ player.o demuxer.o stream.o vfeed.o afeed.o afeedr.o osd.o surface.o viewman.o vdr.o dsock.o box.o \ - recording.o channel.o message.o playervideo.o messagequeue.o \ - view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \ + recording.o channel.o message.o playervideo.o messagequeue.o rectimer.o \ + view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o vtimerlist.o \ vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o \ vchannelselect.o vserverselect.o colour.o vconnect.o voptions.o vepg.o region.o \ widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o wtextbox.o i18n.o timers.o \ diff --git a/playervideo.cc b/playervideo.cc index 72f2609..ef72f09 100644 --- a/playervideo.cc +++ b/playervideo.cc @@ -1,4 +1,4 @@ -/* +#/* Copyright 2004-2005 Chris Tallon This file is part of VOMP. diff --git a/rectimer.cc b/rectimer.cc new file mode 100644 index 0000000..9211fd7 --- /dev/null +++ b/rectimer.cc @@ -0,0 +1,44 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "rectimer.h" + +RecTimer::RecTimer() +{ + active = 0; + recording = 0; + pending = 0; + priority = 0; + lifeTime = 0; + channelNumber = 0; + startTime = 0; + stopTime = 0; + + file = NULL; + summary = NULL; + + index = -1; +} + +RecTimer::~RecTimer() +{ + if (file) delete[] file; + if (summary) delete[] summary; +} diff --git a/rectimer.h b/rectimer.h new file mode 100644 index 0000000..55a8944 --- /dev/null +++ b/rectimer.h @@ -0,0 +1,50 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef RECTIMER_H +#define RECTIMER_H + +#include + +#include "defines.h" + +class RecTimer +{ + public: + RecTimer(); + ~RecTimer(); + + ULONG active; + ULONG recording; + ULONG pending; + ULONG priority; + ULONG lifeTime; + ULONG channelNumber; + ULONG startTime; + ULONG stopTime; + + char* file; + char* summary; + + + int index; +}; + +#endif diff --git a/vdr.cc b/vdr.cc index b5d1fac..9eb4106 100644 --- a/vdr.cc +++ b/vdr.cc @@ -799,3 +799,59 @@ char* VDR::configLoad(char* section, char* key) return toReturn; } + +RecTimerList* VDR::getRecTimersList() +{ + if (!connected) return NULL; + + UCHAR buffer[8]; + + *(unsigned long*)&buffer[0] = htonl(4); + *(unsigned long*)&buffer[4] = htonl(VDR_GETTIMERS); + + pthread_mutex_lock(&mutex); + int a = tcp->sendPacket(buffer, 8); + if (a != 8) + { + pthread_mutex_unlock(&mutex); + return NULL; + } + + // reply + + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return NULL; + } + + RecTimerList* recTimerList = new RecTimerList(); + + RecTimer* newRecTimer; + + while (packetPos < packetLength) + { + newRecTimer = new RecTimer(); + newRecTimer->active = extractULONG(); + newRecTimer->recording = extractULONG(); + newRecTimer->pending = extractULONG(); + newRecTimer->priority = extractULONG(); + newRecTimer->lifeTime = extractULONG(); + newRecTimer->channelNumber = extractULONG(); + newRecTimer->startTime = extractULONG(); + newRecTimer->stopTime = extractULONG(); + + newRecTimer->file = extractString(); + newRecTimer->summary = extractString(); + + recTimerList->push_back(newRecTimer); + Log::getInstance()->log("VDR", Log::DEBUG, "TL: %lu %lu %lu %lu %lu %lu %lu %lu %s", + newRecTimer->active, newRecTimer->recording, newRecTimer->pending, newRecTimer->priority, newRecTimer->lifeTime, + newRecTimer->channelNumber, newRecTimer->startTime, newRecTimer->stopTime, newRecTimer->file); + } + + freePacket(); + pthread_mutex_unlock(&mutex); + + return recTimerList; +} diff --git a/vdr.h b/vdr.h index 48c4c6e..21c4b8e 100644 --- a/vdr.h +++ b/vdr.h @@ -34,6 +34,7 @@ #include "recording.h" #include "channel.h" #include "event.h" +#include "rectimer.h" using namespace std; @@ -41,6 +42,7 @@ using namespace std; typedef vector EventList; typedef vector ChannelList; +typedef vector RecTimerList; class VDR { @@ -80,6 +82,8 @@ class VDR int configSave(char* section, char* key, const char* value); char* configLoad(char* section, char* key); + RecTimerList* getRecTimersList(); + // end const static ULONG VIDEO = 1; @@ -113,6 +117,7 @@ class VDR const static ULONG VDR_CONFIGSAVE = 11; const static ULONG VDR_CONFIGLOAD = 12; const static ULONG VDR_RESCANRECORDING = 13; + const static ULONG VDR_GETTIMERS = 14; int getPacket(); void freePacket(); diff --git a/vtimerlist.cc b/vtimerlist.cc new file mode 100644 index 0000000..2798bd7 --- /dev/null +++ b/vtimerlist.cc @@ -0,0 +1,197 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "vtimerlist.h" + +VTimerList::VTimerList(RecTimerList* trtl) +{ + recTimerList = trtl; + + create(570, 420); + if (Video::getInstance()->getFormat() == Video::PAL) + { + setScreenPos(80, 70); + } + else + { + setScreenPos(70, 35); + } + + + setBackgroundColour(Colour::VIEWBACKGROUND); + setTitleBarOn(1); + setTitleText(tr("Timers")); + setTitleBarColour(Colour::TITLEBARBACKGROUND); + + sl.setSurface(surface); + sl.setSurfaceOffset(10, 30 + 5); + sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30); + + drawData(); +} + +VTimerList::~VTimerList() +{ + if (recTimerList) + { + for (UINT i = 0; i < recTimerList->size(); i++) + { + delete (*recTimerList)[i]; + } + + recTimerList->clear(); + delete recTimerList; + } +} + +void VTimerList::drawData() +{ + char str[500]; + + sl.addColumn(0); + sl.addColumn(60); + + RecTimer* recTimer; + int first = 1; + + for (UINT i = 0; i < recTimerList->size(); i++) + { + recTimer = (*recTimerList)[i]; + sprintf(str, "%u\t%s", i, recTimer->file); + recTimer->index = sl.addOption(str, first); + first = 0; + } +} + +void VTimerList::draw() +{ + View::draw(); + sl.draw(); + + // Put the status stuff at the bottom + + WSymbol w; + w.setSurface(surface); + + w.nextSymbol = WSymbol::UP; + w.setSurfaceOffset(20, 385); + w.draw(); + + w.nextSymbol = WSymbol::DOWN; + w.setSurfaceOffset(50, 385); + w.draw(); + + w.nextSymbol = WSymbol::SKIPBACK; + w.setSurfaceOffset(85, 385); + w.draw(); + + w.nextSymbol = WSymbol::SKIPFORWARD; + w.setSurfaceOffset(115, 385); + w.draw(); + +// w.nextSymbol = WSymbol::PLAY; +// w.setSurfaceOffset(150, 385); +// w.draw(); + + doShowingBar(); +} + +void VTimerList::doShowingBar() +{ + int topOption = sl.getTopOption() + 1; + if (sl.getNumOptions() == 0) topOption = 0; + + char showing[200]; + sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions()); + + rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND); + drawText(showing, 220, 385, Colour::LIGHTTEXT); +} + +int VTimerList::handleCommand(int command) +{ + switch(command) + { + case Remote::DF_UP: + case Remote::UP: + { + sl.up(); + sl.draw(); + + doShowingBar(); + ViewMan::getInstance()->updateView(this); + return 2; + } + case Remote::DF_DOWN: + case Remote::DOWN: + { + sl.down(); + sl.draw(); + + doShowingBar(); + ViewMan::getInstance()->updateView(this); + return 2; + } + case Remote::SKIPBACK: + { + sl.pageUp(); + sl.draw(); + + doShowingBar(); + ViewMan::getInstance()->updateView(this); + return 2; + } + case Remote::SKIPFORWARD: + { + sl.pageDown(); + sl.draw(); + + doShowingBar(); + ViewMan::getInstance()->updateView(this); + return 2; + } + case Remote::OK: + { + RecTimer* recTimer = NULL; + if (recTimerList) + { + int currentOption = sl.getCurrentOption(); + + for (UINT i = 0; i < recTimerList->size(); i++) + { + recTimer = (*recTimerList)[i]; + if (currentOption == recTimer->index) break; + } + } + + if (recTimer == NULL) return 2; + + // recTimer is the one you want FIXME + + return 2; + } + case Remote::BACK: + { + return 4; + } + } + // stop command getting to any more views + return 1; +} diff --git a/vtimerlist.h b/vtimerlist.h new file mode 100644 index 0000000..57dae9d --- /dev/null +++ b/vtimerlist.h @@ -0,0 +1,56 @@ +/* + Copyright 2004-2005 Chris Tallon + + This file is part of VOMP. + + VOMP 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. + + VOMP 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 VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef VTIMERLIST_H +#define VTIMERLIST_H + +#include +#include +#include + +#include "view.h" +#include "wselectlist.h" +#include "remote.h" +#include "wsymbol.h" +#include "viewman.h" +#include "vdr.h" +#include "colour.h" +#include "video.h" +#include "i18n.h" + +class VTimerList : public View +{ + public: + VTimerList(RecTimerList* rtl); + ~VTimerList(); + + int handleCommand(int command); + void draw(); + + private: + RecTimerList* recTimerList; + + WSelectList sl; + + void doShowingBar(); + void drawData(); +}; + +#endif diff --git a/vwelcome.cc b/vwelcome.cc index 5208f61..65b4a17 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -193,6 +193,13 @@ int VWelcome::handleCommand(int command) } return 2; // never gets here } +#ifdef DEV + case Remote::NINE: + { + doTimersList(); + return 2; + } +#endif } return 1; @@ -262,6 +269,20 @@ void VWelcome::doRecordingsList() Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay end"); } +void VWelcome::doTimersList() +{ + RecTimerList* recTimerList = VDR::getInstance()->getRecTimersList(); + + if (recTimerList) + { + VTimerList* vtl = new VTimerList(recTimerList); + + vtl->draw(); + viewman->add(vtl); + viewman->updateView(vtl); + } +} + void VWelcome::doOptions() { VOptions* voptions = new VOptions(this); diff --git a/vwelcome.h b/vwelcome.h index 06440b5..8192dc3 100644 --- a/vwelcome.h +++ b/vwelcome.h @@ -33,6 +33,7 @@ #include "directory.h" #include "vchannellist.h" #include "vrecordinglist.h" +#include "vtimerlist.h" #include "command.h" #include "message.h" #include "colour.h" @@ -61,6 +62,7 @@ class VWelcome : public View, public TimerReceiver void doChannelsList(); void doRadioList(); void doRecordingsList(); + void doTimersList(); void doOptions(); void drawClock(); -- 2.39.5