From 18da990b3ba3ee8ec37fa4f9605eff5c747cee05 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 29 Aug 2005 19:19:16 +0000 Subject: [PATCH] Channel schedules in live banner Programme information from live banner Channel up/down buttons fixed on new remote Converted data structures to STL --- Makefile | 8 +- box.cc | 4 +- box.h | 2 +- colour.cc | 2 + colour.h | 2 + command.cc | 4 +- command.h | 1 - directory.cc | 31 ++-- directory.h | 10 +- node.cc => event.cc | 31 ++-- queue.h => event.h | 40 +++-- list.cc | 170 -------------------- list.h | 66 -------- message.h | 2 + messagequeue.cc | 6 +- messagequeue.h | 7 +- node.h | 37 ----- playervideo.cc | 9 +- queue.cc | 79 --------- surface.cc | 14 +- thread.cc | 6 + thread.h | 1 + vchannellist.cc | 27 ++-- vchannellist.h | 6 +- vchannelselect.cc | 2 +- vconnect.cc | 4 +- vdr.cc | 384 ++++++++++++++++++++++++++------------------ vdr.h | 29 +++- view.cc | 2 +- viewman.cc | 2 +- vlivebanner.cc | 138 ++++++++++++++-- vlivebanner.h | 12 +- voptions.cc | 8 +- vradiolive.cc | 46 +++--- vradiolive.h | 11 +- vrecordinglist.cc | 67 ++++---- vrecordinglist.h | 2 +- vrecordingmenu.cc | 8 +- vserverselect.cc | 6 +- vvideolive.cc | 105 ++++++------ vvideolive.h | 19 +-- vvideorec.cc | 2 +- vvolume.cc | 2 +- vwallpaper.cc | 2 +- vwelcome.cc | 10 +- wbutton.cc | 2 +- wjpeg.cc | 2 +- wselectlist.cc | 14 +- wselectlist.h | 4 +- 49 files changed, 662 insertions(+), 786 deletions(-) rename node.cc => event.cc (74%) rename queue.h => event.h (69%) delete mode 100644 list.cc delete mode 100644 list.h delete mode 100644 node.h delete mode 100644 queue.cc diff --git a/Makefile b/Makefile index 82c4fff..bba406e 100644 --- a/Makefile +++ b/Makefile @@ -3,16 +3,16 @@ STRIP = /opt/crosstool/powerpc-405-linux-gnu/gcc-2.95.3-glibc-2.2.5/bin/powerpc- CXX = $(CC) INCLUDES = -I../jpeg-6b -CXXFLAGS = -Wall -Woverloaded-virtual -Werror $(INCLUDES) +CXXFLAGS = -g -O0 -Wall -Woverloaded-virtual -Werror $(INCLUDES) LDFLAGS = -Wall -static LIBPATHS = LIBS = -lpthread -lrt 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 \ +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 \ - list.o queue.o node.o recording.o channel.o message.o playervideo.o playerradio.o messagequeue.o \ + recording.o channel.o message.o playervideo.o playerradio.o messagequeue.o \ view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \ vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o vradiolive.o \ vchannelselect.o vserverselect.o colour.o vconnect.o voptions.o \ @@ -26,7 +26,7 @@ fresh: clean all all: vompclient clean: - rm -f *.o deps vompclient test *~ fonts/*.o fonts/*~ + rm -f *.o deps vompclient *~ fonts/*.o fonts/*~ vompclient: $(OBJECTS) $(CC) $(LDFLAGS) $(LIBPATHS) -o vompclient $(OBJECTS) $(CROSSLIBS) $(LIBS) diff --git a/box.cc b/box.cc index 9bd6c6e..30b24b6 100644 --- a/box.cc +++ b/box.cc @@ -45,10 +45,10 @@ void Box::draw() { } -void Box::setDimensions(int h, int w) +void Box::setDimensions(int w, int h) { - height = h; width = w; + height = h; } void Box::setScreenPos(int x, int y) diff --git a/box.h b/box.h index c9af906..93f8b31 100644 --- a/box.h +++ b/box.h @@ -35,7 +35,7 @@ class Box virtual ~Box(); void setScreenPos(int x, int y); - void setDimensions(int h, int w); + void setDimensions(int w, int h); void show(); virtual void draw(); diff --git a/colour.cc b/colour.cc index c11377b..4472229 100644 --- a/colour.cc +++ b/colour.cc @@ -23,6 +23,8 @@ /* Real colours */ +Colour Colour::BLACK(0, 0, 0); +Colour Colour::RED(255, 0, 0); Colour Colour::VIDEOBLUE(0, 0, 150); Colour Colour::VIEWBACKGROUND(0, 0, 100); Colour Colour::TITLEBARBACKGROUND(0, 0, 200); diff --git a/colour.h b/colour.h index f9b914b..3abb27f 100644 --- a/colour.h +++ b/colour.h @@ -39,6 +39,8 @@ class Colour int blue; int alpha; + static Colour BLACK; + static Colour RED; static Colour VIDEOBLUE; static Colour VIEWBACKGROUND; static Colour TITLEBARBACKGROUND; diff --git a/command.cc b/command.cc index 22cf675..136b04f 100644 --- a/command.cc +++ b/command.cc @@ -68,7 +68,7 @@ int Command::shutdown() void Command::stop() { - VDR::getInstance()->cancelFindingServer(); +// VDR::getInstance()->cancelFindingServer(); irun = 0; } @@ -91,7 +91,7 @@ void Command::run() // Blue background View* v = new View(); - v->setDimensions(video->getScreenHeight(), video->getScreenWidth()); + v->setDimensions(video->getScreenWidth(), video->getScreenHeight()); v->setBackgroundColour(Colour::VIDEOBLUE); v->draw(); v->show(); diff --git a/command.h b/command.h index 29155d8..a63dc46 100644 --- a/command.h +++ b/command.h @@ -36,7 +36,6 @@ #include "video.h" #include "remote.h" #include "vdr.h" -#include "list.h" #include "message.h" #include "messagequeue.h" #include "box.h" diff --git a/directory.cc b/directory.cc index b73b982..20bd284 100644 --- a/directory.cc +++ b/directory.cc @@ -27,8 +27,6 @@ ULONG Directory::usedPercent = 0; Directory::Directory() { name = NULL; - dirList = new List(); - recList = new List(); isRoot = 0; index = -1; @@ -39,27 +37,17 @@ Directory::~Directory() if (name) delete[] name; index = -1; // just in case - if (dirList) + for (UINT i = 0; i < dirList.size(); i++) { - while (!dirList->isEmpty()) - { - dirList->reset(); - delete (Directory*)dirList->remove(); - } - - delete dirList; + delete dirList[i]; } + dirList.clear(); - if (recList) + for (UINT i = 0; i < recList.size(); i++) { - while (!recList->isEmpty()) - { - recList->reset(); - delete (Recording*)recList->remove(); - } - - delete recList; + delete recList[i]; } + recList.clear(); } void Directory::setName(char* newName) @@ -70,17 +58,16 @@ void Directory::setName(char* newName) Directory* Directory::getDirByName(char* dirName) { - Directory* currentDir; - for(dirList->reset(); (currentDir = (Directory*)dirList->getCurrent()); dirList->next()) + for(UINT i = 0; i < dirList.size(); i++) { - if (!strcmp(dirName, currentDir->name)) return currentDir; + if (!strcmp(dirName, dirList[i]->name)) return dirList[i]; } return NULL; } ULONG Directory::getNumRecordings() { - return recList->getNumElements(); + return recList.size(); } // FIXME make an add function in here that adds recs to the end of the list diff --git a/directory.h b/directory.h index f9d0d3c..4e4c55a 100644 --- a/directory.h +++ b/directory.h @@ -22,11 +22,15 @@ #define DIRECTORY_H #include +#include #include "defines.h" -#include "list.h" #include "recording.h" +class Directory; +typedef vector DirectoryList; +typedef vector RecordingList; + class Directory { public: @@ -43,8 +47,8 @@ class Directory int index; - List* dirList; - List* recList; + DirectoryList dirList; + RecordingList recList; static ULONG totalSpace; static ULONG freeSpace; diff --git a/node.cc b/event.cc similarity index 74% rename from node.cc rename to event.cc index c99db45..614eaa1 100644 --- a/node.cc +++ b/event.cc @@ -18,29 +18,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "node.h" +#include "event.h" -Node::Node(void *newData, Node *ptr) +Event::Event() { - myData = newData; - ptrNext = ptr; -} + id = 0; + time = 0; + duration = 0; -Node::~Node() -{ -} + title = NULL; + subtitle = NULL; + description = NULL; -void *Node::getData(void) -{ - return myData; -} - -Node *Node::getPtr(void) -{ - return ptrNext; + index = -1; } -void Node::setPtr(Node *newPtr) +Event::~Event() { - ptrNext = newPtr; + if (title) delete[] title; + if (subtitle) delete[] subtitle; + if (description) delete[] description; } diff --git a/queue.h b/event.h similarity index 69% rename from queue.h rename to event.h index 29cdd85..3d595bc 100644 --- a/queue.h +++ b/event.h @@ -18,28 +18,38 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef QUEUE_H -#define QUEUE_H +#ifndef EVENT_H +#define EVENT_H #include -#include "node.h" +#include "defines.h" -class Queue +class Event { public: - Queue(); - ~Queue(); - void store(void *); - void *retrieve(void); - short isEmpty(void) const; - void *peekNext(void); - - private: - Node *start; - Node *end; + Event(); + ~Event(); + + ULONG id; + ULONG time; + ULONG duration; + + char* title; + char* subtitle; + char* description; + + int index; + }; -/* The destructor deletes any remaining QNodes but not stored objects. */ +class EventSorter +{ + public: + bool operator()(const Event* e1, const Event* e2) + { + return e1->time < e2->time; + } +}; #endif diff --git a/list.cc b/list.cc deleted file mode 100644 index 39a049d..0000000 --- a/list.cc +++ /dev/null @@ -1,170 +0,0 @@ -/* - 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 "list.h" - -// ------ Constructor add delete get methods ------------------------------------- - -List::List(void) -{ - start = NULL; - current = NULL; - prev = NULL; - numElements = 0; -} - -List::~List() -{ - while (!isEmpty()) - { - reset(); - remove(); - } - numElements = 0; -} - -void List::add(void *newData) -{ - Node *temp = new Node(newData, current); - current = temp; - if (prev == 0) - start = current; - else - prev->setPtr(current); - ++numElements; -} - -void *List::getCurrent(void) const -{ - if (current == 0) return 0; - else return current->getData(); -} - -void *List::remove(void) -{ - if (current == 0) return 0; - Node *dN; - - if (prev == 0) - start = current->getPtr(); - else - prev->setPtr(current->getPtr()); - dN = current; - current = current->getPtr(); - - // saved a reference to the Node in dN and current points to where it should - // that's dN out of the list but it still needs to be deleted, and what it - // points to - - void *returnObject; - returnObject = dN->getData(); - delete dN; - --numElements; - return returnObject; -} - -void List::remove(void *removeThis) -{ - reset(); - while((!eol()) && (current->getData() != removeThis)) next(); - // Now use method above to actually remove the node and get the object - remove(); -} - -unsigned long int List::getNumElements() -{ - return numElements; -} - -// ------ Pointer shift methods ----------------------------------------------- - -void List::reset(void) -{ - current = start; - prev = 0; -} - -void List::next(void) -{ - if (current == 0) return; - prev = current; - current = current->getPtr(); -} - -// ------ Boolean methods ----------------------------------------------------- - -short List::isEmpty(void) const -{ - return (start == 0); -} - -short List::eol(void) const -{ - return (current == 0); -} - -// ------ Save / load methods method -------------------------------------------- - -void List::save(char *fileName, long int objectLength) -{ - FILE *f = fopen(fileName, "w"); - fwrite(&objectLength, sizeof(long int), 1, f); - - void *v; - reset(); - while(!eol()) - { - v = getCurrent(); - fwrite(v, objectLength, 1, f); - next(); - } - fclose(f); -} - -int List::load(char *fileName) -{ -int temp1 = 0; - - int readIn = 0; - long int objectLength = 0; - FILE *f = fopen(fileName, "r"); - if (!f) return readIn; - - if (fread(&objectLength, sizeof(long int), 1, f) != 1) - { - fclose(f); - return 0; - } - - void *temp = 0; - - while(1) - { - temp = malloc(objectLength); - if ((temp1=fread(temp, objectLength, 1, f)) < 1) break; - readIn++; - add(temp); - } - - // We allocated temp but then fread failed - free(temp); - fclose(f); - return readIn; -} diff --git a/list.h b/list.h deleted file mode 100644 index e1a6451..0000000 --- a/list.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - 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 LIST_H -#define LIST_H - -#include -#include -#include "node.h" - -class List -{ - public: - List(); - ~List(); - void add(void *); - void *getCurrent(void) const; - void *remove(void); // Removes node from current position from list - // and passes it back to be deleted - void remove(void *); // Removes node passed in from list, does not delete it - void reset(void); - void next(void); - short isEmpty(void) const; - short eol(void) const; - void save(char *, long int); - int load(char *); - unsigned long int getNumElements(); - - private: - Node *start; - Node *current; - Node *prev; - unsigned long int numElements; -}; - -/* The list class can not delete the object stored in the node object because - it does not know the length of it. All the node has is a void *. This is why - List always passes back the actual stored object to the calling method. -*/ - -/* Fixed memory hole, when delete List, it deletes any remaining Nodes but not - stored objects. That's just tuff. -*/ - -/* The new saving code will work as long as the objects don't contain any - pointers to other areas of memory. Only for use with self-contained objects! -*/ - -#endif diff --git a/message.h b/message.h index a8783cf..190cfc4 100644 --- a/message.h +++ b/message.h @@ -51,6 +51,8 @@ class Message const static ULONG VDR_CONNECTED = 12; const static ULONG REDRAW_DATA = 13; const static ULONG ADD_VIEW = 14; + const static ULONG CHANNEL_UP = 15; + const static ULONG CHANNEL_DOWN = 16; }; #endif diff --git a/messagequeue.cc b/messagequeue.cc index 5c4bbd9..d88d6ed 100644 --- a/messagequeue.cc +++ b/messagequeue.cc @@ -22,15 +22,17 @@ void MessageQueue::postMessage(Message* m) { - messages.store(m); + messages.push(m); Log::getInstance()->log("MessageQueue", Log::DEBUG, "have stored message in queue"); } void MessageQueue::processMessageQueue() { Message *m; - while((m = (Message*)messages.retrieve())) + while(messages.size()) { + m = messages.front(); + messages.pop(); Log::getInstance()->log("MessageQueue", Log::DEBUG, "retrieved message from queue"); processMessage(m); delete m; diff --git a/messagequeue.h b/messagequeue.h index 6e36a9b..421460a 100644 --- a/messagequeue.h +++ b/messagequeue.h @@ -21,10 +21,13 @@ #ifndef MESSAGEQUEUE_H #define MESSAGEQUEUE_H -#include "queue.h" +#include + #include "message.h" #include "log.h" +typedef queue MQueue; + class MessageQueue { public: @@ -37,9 +40,9 @@ class MessageQueue virtual void processMessageQueue(); virtual void processMessage(Message* m)=0; - Queue messages; private: + MQueue messages; }; diff --git a/node.h b/node.h deleted file mode 100644 index 50788dc..0000000 --- a/node.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - 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 NODE_H -#define NODE_H - -class Node -{ - public: - Node(void *, Node *); - ~Node(); - void *getData(void); - Node *getPtr(void); - void setPtr(Node *); - private: - void *myData; - Node *ptrNext; -}; - -#endif diff --git a/playervideo.cc b/playervideo.cc index 4ad52fe..78620ae 100644 --- a/playervideo.cc +++ b/playervideo.cc @@ -47,7 +47,7 @@ int PlayerVideo::init() video = Video::getInstance(); - if (demuxer.init()) // inverted + if (!demuxer.init()) { Log::getInstance()->log("Player", Log::ERR, "Demuxer failed to init"); shutdown(); @@ -87,6 +87,7 @@ int PlayerVideo::shutdown() demuxer.reset(); feedPosition = 0; } + Log::getInstance()->log("Player", Log::DEBUG, "Player shutdown done"); return 1; } @@ -257,7 +258,9 @@ void PlayerVideo::test() /* // video->test(); +*/ +/* static int flipflop = 0; int a; @@ -274,7 +277,7 @@ void PlayerVideo::test2() { Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST"); - video->test2(); +// video->test2(); } void PlayerVideo::setPosition(ULLONG position) @@ -601,8 +604,6 @@ void PlayerVideo::threadMethod() Log::getInstance()->log("Player", Log::DEBUG, "Posting message..."); commandMessageQueue->postMessage(m); Log::getInstance()->log("Player", Log::DEBUG, "Message posted..."); - - } void PlayerVideo::threadPostStopCleanup() diff --git a/queue.cc b/queue.cc deleted file mode 100644 index d33fa03..0000000 --- a/queue.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - 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 "queue.h" - -// ------ Constructor add delete get methods ------------------------------------- - -Queue::Queue(void) -{ - start = NULL; - end = NULL; -} - -Queue::~Queue() -{ - while(!isEmpty()) retrieve(); -} - -void Queue::store(void *newData) -{ - Node *temp = new Node(newData, NULL); - if (temp == NULL) - { - // oh dear. - } - if (start == NULL) // add to empty queue - { - start = temp; - end = temp; - } - else // add to non-empty queue - { - end->setPtr(temp); - end = temp; - } -} - -void *Queue::retrieve(void) -{ - if (start == NULL) { return NULL; } // there was an exit EXIT here bug?!!?!? - if (start == end) // then we are removing the last node so set end to 0 - { - end = NULL; - } - void *toReturn = start->getData(); - Node *next = start->getPtr(); - delete start; - start = next; - return toReturn; -} - -void *Queue::peekNext(void) -{ - return start->getData(); -} - -// ------ Boolean methods ----------------------------------------------------- - -short Queue::isEmpty(void) const -{ - return (start == NULL); -} diff --git a/surface.cc b/surface.cc index d550b30..20a5143 100644 --- a/surface.cc +++ b/surface.cc @@ -79,8 +79,8 @@ int Surface::create(int height, int width) surface.sfc.unknown = -1; - r = ioctl(fdOsd, GFX_FB_SET_OSD, &displayNumber); - if (r) return 0; +// r = ioctl(fdOsd, GFX_FB_SET_OSD, &displayNumber); +// if (r) return 0; r = ioctl(fdOsd, GFX_FB_OSD_SURFACE, &displayNumber); if (r) return 0; @@ -101,12 +101,12 @@ int Surface::create(int height, int width) surface.base[2] = (unsigned char *)mmap(NULL, surface.map.map[2].size, PROT_READ|PROT_WRITE, MAP_SHARED, fdOsd, surface.map.map[2].addr); if (surface.base[2] == MAP_FAILED) return 0; - surface.display.num = displayNumber; - r = ioctl(fdOsd, GFX_FB_MOVE_DISPLAY, &surface.display); - if (r) return 0; +// surface.display.num = displayNumber; +// r = ioctl(fdOsd, GFX_FB_MOVE_DISPLAY, &surface.display); +// if (r) return 0; - r = ioctl(fdOsd, GFX_FB_SET_DISPLAY, &surface.display); - if (r) return 0; +// r = ioctl(fdOsd, GFX_FB_SET_DISPLAY, &surface.display); +// if (r) return 0; return 1; } diff --git a/thread.cc b/thread.cc index b6cc8ff..13cc674 100644 --- a/thread.cc +++ b/thread.cc @@ -92,3 +92,9 @@ void Thread::threadWaitForSignal() pthread_cond_wait(&threadCond, &threadCondMutex); pthread_mutex_unlock(&threadCondMutex); } + +void Thread::threadSetKillable() +{ + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); +} diff --git a/thread.h b/thread.h index 111ede4..eddaf71 100644 --- a/thread.h +++ b/thread.h @@ -42,6 +42,7 @@ class Thread char threadIsActive(); // returns 1 if thread has been started but not stop() or cancel() 'd // Methods to use from inside the thread + void threadSetKillable(); // allows threadCancel() to work void threadCheckExit(); // terminates thread if threadStop() has been called void threadWaitForSignal(); // pauses thread until threadSignal() is called diff --git a/vchannellist.cc b/vchannellist.cc index 81159f4..f8d196b 100644 --- a/vchannellist.cc +++ b/vchannellist.cc @@ -31,7 +31,7 @@ VChannelList::VChannelList(ULONG type) setScreenPos(70, 35); } - setDimensions(420, 570); + setDimensions(570, 420); setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); @@ -47,29 +47,29 @@ VChannelList::VChannelList(ULONG type) setTitleBarColour(Colour::TITLEBARBACKGROUND); sl.setScreenPos(screenX + 10, screenY + 30 + 5); - sl.setDimensions(height - 30 - 15 - 30, width - 20); + sl.setDimensions(width - 20, height - 30 - 15 - 30); } VChannelList::~VChannelList() { if (chanList) { - while (!chanList->isEmpty()) + for (UINT i = 0; i < chanList->size(); i++) { - chanList->reset(); - delete (Channel*)chanList->remove(); + delete (*chanList)[i]; } + chanList->clear(); delete chanList; } } -void VChannelList::setList(List* tlist) +void VChannelList::setList(ChannelList* tlist) { char str[500]; sl.addColumn(0); - sl.addColumn(50); + sl.addColumn(60); chanList = tlist; @@ -77,14 +77,12 @@ void VChannelList::setList(List* tlist) int first = 1; if (chanList) { - chanList->reset(); - - while((chan = (Channel*)chanList->getCurrent())) + for (UINT i = 0; i < chanList->size(); i++) { + chan = (*chanList)[i]; sprintf(str, "%lu\t%s", chan->number, chan->name); chan->index = sl.addOption(str, first); first = 0; - chanList->next(); } } } @@ -130,7 +128,7 @@ void VChannelList::doShowingBar() sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions()); Box b; b.setScreenPos(screenX + 220, screenY + 385); - b.setDimensions(25, 160); + b.setDimensions(160, 25); b.fillColour(Colour::VIEWBACKGROUND); b.drawText(showing, 0, 0, Colour::LIGHTTEXT); } @@ -184,12 +182,11 @@ int VChannelList::handleCommand(int command) if (chanList) { int currentOption = sl.getCurrentOption(); - chanList->reset(); - while((chan = (Channel*)chanList->getCurrent())) + for (UINT i = 0; i < chanList->size(); i++) { + chan = (*chanList)[i]; if (currentOption == chan->index) break; - chanList->next(); } } diff --git a/vchannellist.h b/vchannellist.h index 69fd479..9fcb669 100644 --- a/vchannellist.h +++ b/vchannellist.h @@ -23,9 +23,9 @@ #include #include +#include #include "view.h" -#include "list.h" #include "wselectlist.h" #include "remote.h" #include "wsymbol.h" @@ -43,13 +43,13 @@ class VChannelList : public View VChannelList(ULONG type); ~VChannelList(); - void setList(List* chanList); + void setList(ChannelList* chanList); int handleCommand(int command); void draw(); private: - List* chanList; + ChannelList* chanList; ULONG type; WSelectList sl; diff --git a/vchannelselect.cc b/vchannelselect.cc index b0711e9..fb93a2a 100644 --- a/vchannelselect.cc +++ b/vchannelselect.cc @@ -25,7 +25,7 @@ VChannelSelect::VChannelSelect(VVideoLive* v, int command) { - setDimensions(30, 53); + setDimensions(53, 30); setScreenPos(80, 60); setBackgroundColour(Colour::VIEWBACKGROUND); diff --git a/vconnect.cc b/vconnect.cc index 0a31bf8..e8eaeff 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -25,7 +25,7 @@ VConnect::VConnect() vdr = VDR::getInstance(); logger = Log::getInstance(); - setDimensions(200, 400); + setDimensions(400, 200); if (Video::getInstance()->getFormat() == Video::PAL) { setScreenPos(170, 200); @@ -43,7 +43,7 @@ VConnect::~VConnect() { irun = 0; vdr->cancelFindingServer(); - threadStop(); + threadCancel(); } void VConnect::draw() diff --git a/vdr.cc b/vdr.cc index d951f45..45e2d98 100644 --- a/vdr.cc +++ b/vdr.cc @@ -30,6 +30,9 @@ VDR::VDR() findingServer = 0; tcp = NULL; pthread_mutex_init(&mutex, NULL); + packetLength = 0; + packetPos = 0; + packet = NULL; } VDR::~VDR() @@ -60,7 +63,7 @@ int VDR::shutdown() return 1; } -void VDR::findServers(std::vector& serverIPs) +void VDR::findServers(vector& serverIPs) { findingServer = 1; char* message = "VOMP CLIENT"; @@ -126,54 +129,65 @@ void VDR::disconnect() Log::getInstance()->log("VDR", Log::DEBUG, "Disconnect"); } -long VDR::getSimpleReply() -{ - unsigned char* p = (unsigned char*)tcp->receivePacket(); - if (!p) return -1; - - Log::getInstance()->log("VDR", Log::DEBUG, "tcp data length = %i", tcp->getDataLength()); - - if (tcp->getDataLength() != 4) - { - free(p); - return -1; - } - - ULONG reply = ntohl(*(ULONG*)p); - - Log::getInstance()->log("VDR", Log::DEBUG, "VDR said %li", reply); - - free(p); +/////////////////////////////////////////////////////// - return reply; +int VDR::getPacket() +{ + packet = (UCHAR*)tcp->receivePacket(); + if (!packet) return 0; + packetLength = tcp->getDataLength(); + return 1; } -char* VDR::getStringReply() +void VDR::freePacket() { - unsigned char* p = (unsigned char*)tcp->receivePacket(); - if (!p) return NULL; - - int dataLength = tcp->getDataLength(); - -// Log::getInstance()->log("VDR", Log::DEBUG, "GSR Data length %u", dataLength); + // Must be called if getPacket return 1, except in getBlock + packetLength = 0; + packetPos = 0; + free(packet); + packet = NULL; +} - if ((dataLength == 4) && (p[0] == '\0')) - { - Log::getInstance()->log("VDR", Log::DEBUG, "GSR returning null no string returned"); - free(p); - return NULL; // no string returned - } +int VDR::serverError() +{ + if ((packetPos == 0) && (packetLength == 4) && !ntohl(*(ULONG*)packet)) return 1; + else return 0; +} - char* returnText; - int tLength; +char* VDR::extractString() +{ + if (serverError()) return NULL; + + int length = strlen((char*)&packet[packetPos]); + if ((packetPos + length) > packetLength) return NULL; + char* str = new char[length + 1]; + strcpy(str, (char*)&packet[packetPos]); + packetPos += length + 1; + return str; +} - tLength = strlen((char*)p); - returnText = new char[tLength + 1]; - strcpy(returnText, (char*)p); +ULONG VDR::extractULONG() +{ + if ((packetPos + sizeof(ULONG)) > packetLength) return 0; + ULONG ul = ntohl(*(ULONG*)&packet[packetPos]); + packetPos += sizeof(ULONG); + return ul; +} - free(p); +ULLONG VDR::extractULLONG() +{ + if ((packetPos + sizeof(ULLONG)) > packetLength) return 0; + ULLONG ull = ntohll(*(ULLONG*)&packet[packetPos]); + packetPos += sizeof(ULLONG); + return ull; +} - return returnText; +long VDR::extractLONG() +{ + if ((packetPos + sizeof(long)) > packetLength) return 0; + long l = ntohl(*(long*)&packet[packetPos]); + packetPos += sizeof(long); + return l; } ///////////////////////////////////////////////////////////////////////////// @@ -195,27 +209,29 @@ int VDR::doLogin() // reply - UCHAR* p = tcp->receivePacket(); - pthread_mutex_unlock(&mutex); - if (!p) return 0; + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return 0; + } + + ULONG vdrTime = extractULONG(); + logger->log("VDR", Log::DEBUG, "vdrtime = %lu", vdrTime); + long vdrTimeOffset = extractLONG(); + logger->log("VDR", Log::DEBUG, "offset = %i", vdrTimeOffset); - int count = 0; + freePacket(); + pthread_mutex_unlock(&mutex); - unsigned long vdrTime = ntohl(*(unsigned long*)&p[count]); - count += sizeof(unsigned long); - Log::getInstance()->log("VDR", Log::DEBUG, "vdrtime = %lu", vdrTime); struct timespec currentTime; currentTime.tv_sec = vdrTime; currentTime.tv_nsec = 0; int b = clock_settime(CLOCK_REALTIME, ¤tTime); - Log::getInstance()->log("VDR", Log::DEBUG, "set clock = %u", b); + logger->log("VDR", Log::DEBUG, "set clock = %u", b); // now make a TZ variable and set it - signed int vdrTimeOffset = ntohl(*(signed int*)&p[count]); - Log::getInstance()->log("VDR", Log::DEBUG, "offset = %i", vdrTimeOffset); - char sign; int hours; int minutes; @@ -227,19 +243,18 @@ int VDR::doLogin() hours = (int)vdrTimeOffset / 3600; minutes = vdrTimeOffset % 3600; - Log::getInstance()->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes); + logger->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes); minutes = (int)minutes / 60; - Log::getInstance()->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes); + logger->log("VDR", Log::DEBUG, "%c %i %i", sign, hours, minutes); char newTZ[30]; sprintf(newTZ, "MVP%c%i:%i", sign, hours, minutes); setenv("TZ", newTZ, 1); - Log::getInstance()->log("VDR", Log::DEBUG, "Timezone data: %s", newTZ); + logger->log("VDR", Log::DEBUG, "Timezone data: %s", newTZ); - free(p); return 1; } @@ -260,46 +275,33 @@ Directory* VDR::getRecordingsList() // reply - unsigned char* p = (unsigned char*)tcp->receivePacket(); - pthread_mutex_unlock(&mutex); - if (!p) return 0; + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return NULL; + } Directory* recDir = new Directory(); recDir->setName("/"); recDir->isRoot = 1; - int dataLength = tcp->getDataLength(); - - Log::getInstance()->log("VDR", Log::DEBUG, "Data length %u", dataLength); - - int count = 0; + Directory::totalSpace = extractULONG(); + Directory::freeSpace = extractULONG(); + Directory::usedPercent = extractULONG(); - Directory::totalSpace = (*(ULONG*)&p[count]); - count += sizeof(ULONG); - Directory::freeSpace = (*(ULONG*)&p[count]); - count += sizeof(ULONG); - Directory::usedPercent = (*(ULONG*)&p[count]); - count += sizeof(ULONG); + char* string; - int tLength; - - while (count < dataLength) + while (packetPos < packetLength) { Recording* rec = new Recording(); - rec->start = ntohl(*(unsigned long*)&p[count]); - count += 4; - tLength = strlen((char*)&p[count]); - rec->setName((char*)&p[count]); + rec->start = extractULONG(); -// rec->name = new char[tLength + 1]; -// strcpy(rec->name, (char*)&p[count]); - count += tLength + 1; + string = extractString(); + rec->setName(string); + delete[] string; - tLength = strlen((char*)&p[count]); - rec->fileName = new char[tLength + 1]; - strcpy(rec->fileName, (char*)&p[count]); - count += tLength + 1; + rec->fileName = extractString(); if(rec->isInDir()) { @@ -311,22 +313,21 @@ Directory* VDR::getRecordingsList() d = new Directory(); d->setName(dirName); Log::getInstance()->log("VDR", Log::DEBUG, "Added a new directory = %s", d->name); - recDir->dirList->add(d); + recDir->dirList.push_back(d); } - d->recList->add(rec); - d->recList->next(); + d->recList.push_back(rec); } else { - recDir->recList->add(rec); - recDir->recList->next(); + recDir->recList.push_back(rec); } Log::getInstance()->log("VDR", Log::DEBUG, "Have added a recording to list. %lu %s", rec->start, rec->getProgName()); } - free(p); + freePacket(); + pthread_mutex_unlock(&mutex); return recDir; } @@ -348,9 +349,16 @@ int VDR::deleteRecording(char* fileName) return 0; } - int toReturn = getSimpleReply(); - if (toReturn == -1) toReturn = 0; // error is same as 0=bad in this case + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return 0; + } + + int toReturn = (int)extractULONG(); + freePacket(); pthread_mutex_unlock(&mutex); + return toReturn; } @@ -371,12 +379,19 @@ char* VDR::getRecordingSummary(char* fileName) return NULL; } - char* toReturn = getStringReply(); + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return NULL; + } + char* toReturn = extractString(); + freePacket(); pthread_mutex_unlock(&mutex); + return toReturn; } -List* VDR::getChannelsList(ULONG type) +ChannelList* VDR::getChannelsList(ULONG type) { UCHAR buffer[8]; @@ -393,37 +408,24 @@ List* VDR::getChannelsList(ULONG type) // reply - unsigned char* p = (unsigned char*)tcp->receivePacket(); - pthread_mutex_unlock(&mutex); - if (!p) return NULL; - - List* chanList = new List(); - - int dataLength = tcp->getDataLength(); - - Log::getInstance()->log("VDR", Log::DEBUG, "Data length %u", dataLength); - - int count = 0; + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return NULL; + } - int tLength; + ChannelList* chanList = new ChannelList(); - while (count < dataLength) + while (packetPos < packetLength) { Channel* chan = new Channel(); - chan->number = ntohl(*(unsigned long*)&p[count]); - count += 4; - chan->type = ntohl(*(unsigned long*)&p[count]); - count += 4; - - tLength = strlen((char*)&p[count]); - chan->name = new char[tLength + 1]; - strcpy(chan->name, (char*)&p[count]); - count += tLength + 1; + chan->number = extractULONG(); + chan->type = extractULONG(); + chan->name = extractString(); if (chan->type == type) { - chanList->add(chan); - chanList->next(); + chanList->push_back(chan); Log::getInstance()->log("VDR", Log::DEBUG, "Have added a channel to list. %lu %lu %s", chan->number, chan->type, chan->name); } else @@ -432,7 +434,8 @@ List* VDR::getChannelsList(ULONG type) } } - free(p); + freePacket(); + pthread_mutex_unlock(&mutex); return chanList; } @@ -454,9 +457,16 @@ int VDR::streamChannel(ULONG number) return 0; } - int toReturn = getSimpleReply(); - if (toReturn == -1) toReturn = 0; // change error to bad + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return 0; + } + + int toReturn = (int)extractULONG(); + freePacket(); pthread_mutex_unlock(&mutex); + return toReturn; } @@ -476,9 +486,16 @@ int VDR::stopStreaming() return 0; } - int toReturn = getSimpleReply(); - if (toReturn == -1) toReturn = 0; // change error to bad + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return 0; + } + + int toReturn = (int)extractULONG(); + freePacket(); pthread_mutex_unlock(&mutex); + return toReturn; } @@ -499,11 +516,21 @@ UCHAR* VDR::getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived) return NULL; } - unsigned char* p = (unsigned char*)tcp->receivePacket(); + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return NULL; + } + + UCHAR* toReturn = packet; + *amountReceived = packetLength; + // Manually clean up instead of running freePacket to keep the block + packet = NULL; + packetLength = 0; + packetPos = 0; pthread_mutex_unlock(&mutex); - if (!p) return NULL; - *amountReceived = tcp->getDataLength(); - return p; + + return toReturn; } ULLONG VDR::streamRecording(Recording* rec) @@ -523,20 +550,17 @@ ULLONG VDR::streamRecording(Recording* rec) return 0; } - unsigned char* p = (unsigned char*)tcp->receivePacket(); - pthread_mutex_unlock(&mutex); - if (!p) return 0; - - if (tcp->getDataLength() != 8) + if (!getPacket()) { - free(p); + pthread_mutex_unlock(&mutex); return 0; } - ULLONG recordingLength = ntohll(*(ULLONG*)p); + ULLONG recordingLength = extractULLONG(); + freePacket(); + pthread_mutex_unlock(&mutex); Log::getInstance()->log("VDR", Log::DEBUG, "VDR said length is: %llu", recordingLength); - free(p); return recordingLength; } @@ -557,25 +581,22 @@ ULLONG VDR::rescanRecording() return 0; } - unsigned char* p = (unsigned char*)tcp->receivePacket(); - pthread_mutex_unlock(&mutex); - if (!p) return 0; - - if (tcp->getDataLength() != 8) + if (!getPacket()) { - free(p); + pthread_mutex_unlock(&mutex); return 0; } - ULLONG recordingLength = ntohll(*(ULLONG*)p); + ULLONG recordingLength = extractULLONG(); + freePacket(); + pthread_mutex_unlock(&mutex); Log::getInstance()->log("VDR", Log::DEBUG, "VDR said length is: %llu", recordingLength); - free(p); return recordingLength; } -int VDR::getChannelSchedule(ULONG number) +EventList* VDR::getChannelSchedule(ULONG number) { UCHAR buffer[12]; @@ -589,27 +610,60 @@ int VDR::getChannelSchedule(ULONG number) if (a != 12) { pthread_mutex_unlock(&mutex); - return -1; + return NULL; } - unsigned char* p = (unsigned char*)tcp->receivePacket(); - pthread_mutex_unlock(&mutex); - if (!p) return -1; + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return NULL; + } + + if (serverError()) + { + freePacket(); + pthread_mutex_unlock(&mutex); + return NULL; + } - int dataLength = tcp->getDataLength(); - if (dataLength != 4) + EventList* eventList = new EventList(); + + while (packetPos < packetLength) { - free(p); - return -1; + Event* event = new Event(); + event->id = extractULONG(); + event->time = extractULONG(); + event->duration = extractULONG(); + event->title = extractString(); + event->subtitle = extractString(); + event->description = extractString(); + eventList->push_back(event); +// eventList->next(); } - ULONG data = ntohl(*(ULONG*)p); - free(p); + freePacket(); + pthread_mutex_unlock(&mutex); + + Log::getInstance()->log("VDR", Log::DEBUG, "Success got to end of getChannelSchedule"); + + + // debug +/* + Log* l = Log::getInstance(); + - Log::getInstance()->log("VDR", Log::DEBUG, "Success got to end of getChannelSchedule %lu", data); + l->log("VDR", Log::DEBUG, "datalength = %i count = %i", dataLength, count); - return data; + Event* currentEvent; + for(eventList->reset(); !eventList->eol(); eventList->next()) + { + currentEvent = (Event*)eventList->getCurrent(); + l->log("VDR", Log::DEBUG, "%lu %lu %lu %s %s %s", currentEvent->id, currentEvent->time, currentEvent->duration, currentEvent->title, currentEvent->subtitle, currentEvent->description); + } +*/ + + return eventList; } ULLONG VDR::getResumePoint(char* fileName) @@ -645,9 +699,16 @@ int VDR::configSave(char* section, char* key, char* value) return 0; } - int toReturn = getSimpleReply(); - if (toReturn == -1) toReturn = 0; // change error to bad + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return 0; + } + + int toReturn = (int)extractULONG(); + freePacket(); pthread_mutex_unlock(&mutex); + return toReturn; } @@ -672,7 +733,14 @@ char* VDR::configLoad(char* section, char* key) return NULL; } - char* toReturn = getStringReply(); + if (!getPacket()) + { + pthread_mutex_unlock(&mutex); + return NULL; + } + char* toReturn = extractString(); + freePacket(); pthread_mutex_unlock(&mutex); + return toReturn; } diff --git a/vdr.h b/vdr.h index bef6566..2767b43 100644 --- a/vdr.h +++ b/vdr.h @@ -30,15 +30,21 @@ #include "log.h" #include "dsock.h" #include "tcp.h" -#include "list.h" #include "directory.h" #include "recording.h" #include "channel.h" +#include "event.h" + +using namespace std; // FIXME do some tcp connection error checking and kill it! +typedef vector EventList; +typedef vector ChannelList; + class VDR { + public: VDR(); ~VDR(); @@ -47,7 +53,7 @@ class VDR int init(int port); int shutdown(); - void findServers(std::vector& serverIPs); + void findServers(vector& serverIPs); void cancelFindingServer(); void setServerIP(char*); int connect(); @@ -64,12 +70,12 @@ class VDR ULLONG streamRecording(Recording* rec); ULLONG rescanRecording(); - List* getChannelsList(ULONG type); - int streamChannel(ULONG number); + ChannelList* getChannelsList(ULONG type); + int streamChannel(ULONG number); UCHAR* getBlock(ULLONG position, UINT maxAmount, UINT* amountReceived); int stopStreaming(); - int getChannelSchedule(ULONG number); + EventList* getChannelSchedule(ULONG number); int configSave(char* section, char* key, char* value); char* configLoad(char* section, char* key); @@ -88,6 +94,10 @@ class VDR char serverIP[16]; pthread_mutex_t mutex; + UCHAR* packet; + ULONG packetLength; + ULONG packetPos; + const static ULONG VDR_LOGIN = 1; const static ULONG VDR_GETRECORDINGLIST = 2; const static ULONG VDR_DELETERECORDING = 3; @@ -102,8 +112,13 @@ class VDR const static ULONG VDR_CONFIGLOAD = 12; const static ULONG VDR_RESCANRECORDING = 13; - long getSimpleReply(); - char* getStringReply(); + int getPacket(); + void freePacket(); + int serverError(); + char* extractString(); + ULONG extractULONG(); + ULLONG extractULLONG(); + long extractLONG(); }; #endif diff --git a/view.cc b/view.cc index 2030c5f..8c7831c 100644 --- a/view.cc +++ b/view.cc @@ -24,8 +24,8 @@ char View::numViews = 0; View::View() { - height = 0; width = 0; + height = 0; screenX = 0; screenY = 0; diff --git a/viewman.cc b/viewman.cc index 1f4e592..7748681 100644 --- a/viewman.cc +++ b/viewman.cc @@ -137,7 +137,7 @@ int ViewMan::removeView(View* toDelete, int noLock, int noShow) if (i == 0) { // not a View we have! - pthread_mutex_unlock(&viewManLock); + if (!noLock) pthread_mutex_unlock(&viewManLock); return 0; } } diff --git a/vlivebanner.cc b/vlivebanner.cc index 6d830e5..39c4ef7 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -20,53 +20,104 @@ #include "vlivebanner.h" -VLiveBanner::VLiveBanner(Channel* channel) +VLiveBanner::VLiveBanner(View* tparent, Channel* channel) { - currentChannel = channel; + eventList = NULL; + parent = tparent; if (Video::getInstance()->getFormat() == Video::PAL) { - setScreenPos(130, 370); + setScreenPos(125, 410); } else { - setScreenPos(120, 320); + setScreenPos(115, 320); } - setDimensions(120, 500); + setDimensions(500, 120); setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); - setTitleText(currentChannel->name); setTitleBarColour(Colour::TITLEBARBACKGROUND); sl.setScreenPos(screenX, screenY + 30); - sl.setDimensions(height - 60, width); + sl.setDimensions(width, height - 60); + sl.setNoLoop(); + + setChannel(channel); } VLiveBanner::~VLiveBanner() { + delData(); } -void VLiveBanner::draw() +void VLiveBanner::delData() { -//int success = VDR::getInstance()->getChannelSchedule(1); -int success = 0; + if (eventList) + { + int eventListSize = eventList->size(); + for(int i = 0; i < eventListSize; i++) + { + delete (*eventList)[i]; + } + eventList->clear(); + delete eventList; - if (!success) + } + sl.clear(); +} + +void VLiveBanner::setChannel(Channel* tChannel) +{ + delData(); + currentChannel = tChannel; + // get the data + + setTitleText(currentChannel->name); + eventList = VDR::getInstance()->getChannelSchedule(currentChannel->number); + + if (!eventList) { sl.addOption("No channel data available", 1); } else { - sl.addOption("This Programme", 1); - sl.addOption("The Next Programme", 0); - sl.addOption("The Programme after that", 0); + // sort the list + Log::getInstance()->log("Banner", Log::DEBUG, "Start sort"); + sort(eventList->begin(), eventList->end(), EventSorter()); + Log::getInstance()->log("Banner", Log::DEBUG, "End sort"); + + char tempString[300]; + char tempString2[300]; + struct tm* btime; + Event* event; + int first = 1; + int eventListSize = eventList->size(); + for(int i = 0; i < eventListSize; i++) + { + event = (*eventList)[i]; + + btime = localtime((time_t*)&event->time); + strftime(tempString2, 299, "%0H:%0M ", btime); + snprintf(tempString, 299, "%s %s", tempString2, event->title); + event->index = sl.addOption(tempString, first); + first = 0; + } + + // Reset the timer as it probably took 1-2 seconds to change the channel + ViewMan::getInstance()->timedDelete(this, 4, 0); } +} +void VLiveBanner::draw() +{ View::draw(); sl.draw(); rectangle(0, height - 30, width, 30, titleBarColour); + + rectangle(7, height - 24, 18, 16, Colour::RED); + drawText("info", 32, height - 25, Colour::LIGHTTEXT); } int VLiveBanner::handleCommand(int command) @@ -96,6 +147,65 @@ int VLiveBanner::handleCommand(int command) show(); return 2; } + case Remote::CHANNELUP: + { + Message* m = new Message(); + m->from = this; + m->to = parent; + m->message = Message::CHANNEL_UP; + ViewMan::getInstance()->postMessage(m); + return 2; + } + case Remote::CHANNELDOWN: + { + Message* m = new Message(); + m->from = this; + m->to = parent; + m->message = Message::CHANNEL_DOWN; + ViewMan::getInstance()->postMessage(m); + return 2; + } + case Remote::RED: + case Remote::MENU: + { + if (!eventList) return 2; + Event* event; + int eventListSize = eventList->size(); + for(int i = 0; i < eventListSize; i++) + { + event = (*eventList)[i]; + if (event->index == sl.getCurrentOption()) + { + Log::getInstance()->log("VLiveBanner", Log::DEBUG, "Found the option you pointed at. %s", event->title); + // First, cancel my delete timer + ViewMan::getInstance()->timedDelete(this, 0, 0); + + VInfo* vi = new VInfo(); + vi->setTitleText(event->title); + vi->setBorderOn(1); + vi->setExitable(); + if (event->description) vi->setMainText(event->description); + else vi->setMainText("Summary unavailable"); + if (Video::getInstance()->getFormat() == Video::PAL) + { + vi->setScreenPos(120, 130); + } + else + { + vi->setScreenPos(110, 90); + } + vi->setDimensions(510, 270); + + ViewMan::getInstance()->addNoLock(vi); + vi->draw(); + vi->show(); + + return 2; + + } + } + return 2; // should not get here + } } return 1; diff --git a/vlivebanner.h b/vlivebanner.h index 3427468..993db1a 100644 --- a/vlivebanner.h +++ b/vlivebanner.h @@ -23,6 +23,8 @@ #include #include +#include +#include #include "view.h" #include "remote.h" @@ -30,19 +32,27 @@ #include "wselectlist.h" #include "colour.h" #include "video.h" +#include "event.h" +#include "vinfo.h" +#include "viewman.h" class VLiveBanner : public View { public: - VLiveBanner(Channel* channel); + VLiveBanner(View* parent, Channel* channel); ~VLiveBanner(); + void delData(); + + void setChannel(Channel* channel); int handleCommand(int command); void draw(); private: + View* parent; WSelectList sl; Channel* currentChannel; + EventList* eventList; }; diff --git a/voptions.cc b/voptions.cc index 9c80dde..7c5d79c 100644 --- a/voptions.cc +++ b/voptions.cc @@ -22,7 +22,7 @@ VOptions::VOptions() { - setDimensions(190, 460); + setDimensions(460, 190); if (Video::getInstance()->getFormat() == Video::PAL) { @@ -41,17 +41,17 @@ VOptions::VOptions() int fontHeight = surface->getFontHeight(); optionBox[0].setScreenPos(screenX + 290, screenY + 45); - optionBox[0].setDimensions(fontHeight, 150); + optionBox[0].setDimensions(150, fontHeight); optionBox[0].addOption("Old"); optionBox[0].addOption("New"); optionBox[1].setScreenPos(screenX + 290, screenY + 75); - optionBox[1].setDimensions(fontHeight, 150); + optionBox[1].setDimensions(150, fontHeight); optionBox[1].addOption("RGB+composite"); optionBox[1].addOption("S-Video"); optionBox[2].setScreenPos(screenX + 290, screenY + 105); - optionBox[2].setDimensions(fontHeight, 150); + optionBox[2].setDimensions(150, fontHeight); optionBox[2].addOption("On"); optionBox[2].addOption("Off"); optionBox[2].addOption("Last state"); diff --git a/vradiolive.cc b/vradiolive.cc index c0e57ef..57f17e3 100644 --- a/vradiolive.cc +++ b/vradiolive.cc @@ -20,7 +20,7 @@ #include "vradiolive.h" -VRadioLive::VRadioLive(List* tchanList) +VRadioLive::VRadioLive(ChannelList* tchanList) { player = new PlayerRadio(); player->init(); @@ -60,7 +60,7 @@ int VRadioLive::handleCommand(int command) player->stop(); vdr->stopStreaming(); upChannel(); - vdr->streamChannel(currentChannel); + vdr->streamChannel((*chanList)[currentChannel]->number); player->play(); return 2; } @@ -70,7 +70,7 @@ int VRadioLive::handleCommand(int command) player->stop(); vdr->stopStreaming(); downChannel(); - vdr->streamChannel(currentChannel); + vdr->streamChannel((*chanList)[currentChannel]->number); player->play(); return 2; } @@ -79,39 +79,33 @@ int VRadioLive::handleCommand(int command) return 1; } -void VRadioLive::setChannel(int number) +void VRadioLive::setChannel(UINT number) { - currentChannel = number; - vdr->streamChannel(currentChannel); + currentChannel = channelIndexFromNumber(number); + vdr->streamChannel((*chanList)[currentChannel]->number); player->play(); } void VRadioLive::upChannel() { - Channel* channel; - for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next()) - { - if (channel->number == currentChannel) - { - chanList->next(); - channel = (Channel*)chanList->getCurrent(); - if (!channel) return; - currentChannel = channel->number; - } - } + if (currentChannel == (chanList->size() - 1)) return; // at the end + + ++currentChannel; } void VRadioLive::downChannel() { - Channel* channel; - Channel* prevChannel = NULL; - for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next()) + if (currentChannel == 0) return; // at the start + + --currentChannel; +} + +UINT VRadioLive::channelIndexFromNumber(int number) +{ + for(UINT i = 0; i < chanList->size(); i++) { - if (channel->number == currentChannel) - { - if (!prevChannel) return; - currentChannel = prevChannel->number; - } - prevChannel = channel; + if ((*chanList)[i]->number == (UINT)number) return i; } + return 0; } + diff --git a/vradiolive.h b/vradiolive.h index 2b31e1e..8457082 100644 --- a/vradiolive.h +++ b/vradiolive.h @@ -22,11 +22,11 @@ #define VRADIOLIVE_H #include +#include #include "view.h" #include "playerradio.h" #include "vdr.h" -#include "list.h" #include "channel.h" #include "viewman.h" #include "remote.h" @@ -35,21 +35,22 @@ class VRadioLive : public View { public: - VRadioLive(List* chanList); + VRadioLive(ChannelList* chanList); ~VRadioLive(); void draw(); int handleCommand(int command); - void setChannel(int number); + void setChannel(UINT number); private: VDR* vdr; PlayerRadio* player; - List* chanList; - ULONG currentChannel; + ChannelList* chanList; + UINT currentChannel; void upChannel(); void downChannel(); + UINT channelIndexFromNumber(int number); }; #endif diff --git a/vrecordinglist.cc b/vrecordinglist.cc index c8bd1e3..b483ed0 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -34,14 +34,14 @@ VRecordingList::VRecordingList(VRecordingList* parent) setScreenPos(70, 35); } - setDimensions(420, 570); + setDimensions(570, 420); setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleBarColour(Colour::TITLEBARBACKGROUND); sl.setScreenPos(screenX + 10, screenY + 30 + 5); - sl.setDimensions(height - 30 - 15 - 30, width - 20); + sl.setDimensions(width - 20, height - 30 - 15 - 30); } VRecordingList::~VRecordingList() @@ -81,12 +81,12 @@ void VRecordingList::drawData() struct tm* btime; Directory* dir; - recDir->dirList->reset(); - while((dir = (Directory*)recDir->dirList->getCurrent())) + for (DirectoryList::iterator i = recDir->dirList.begin(); i != recDir->dirList.end(); i++) { + dir = *i; if (dir->getNumRecordings() == 0) { - recDir->dirList->remove(dir); + recDir->dirList.erase(i); continue; } @@ -94,26 +94,20 @@ void VRecordingList::drawData() dir->index = sl.addOption(tempA, first); first = 0; - - recDir->dirList->next(); } - // temp FIXME - List* recList = recDir->recList; - // FIXME convert the whole program to time_t's Recording* rec; - recList->reset(); - while((rec = (Recording*)recList->getCurrent())) + for (UINT i = 0; i < recDir->recList.size(); i++) { + rec = recDir->recList[i]; btime = localtime((time_t*)&rec->start); strftime(tempA, 299, "%0d/%0m %0H:%0M ", btime); sprintf(tempB, "%s\t%s", tempA, rec->getProgName()); rec->index = sl.addOption(tempB, first); first = 0; - recList->next(); } dataInvalid = 0; @@ -158,7 +152,7 @@ void VRecordingList::draw() char freeSpace[50]; int gigFree = Directory::freeSpace / 1024; - snprintf(freeSpace, 49, "%lu%%, %iGB free", Directory::usedPercent, gigFree); + snprintf(freeSpace, 49, "%lu%% used, %iGB free", Directory::usedPercent, gigFree); drawTextRJ(freeSpace, 560, 5, Colour::LIGHTTEXT); } @@ -171,7 +165,7 @@ void VRecordingList::doShowingBar() sprintf(showing, "%i to %i of %i", topOption, sl.getBottomOption(), sl.getNumOptions()); Box b; b.setScreenPos(screenX + 220, screenY + 385); - b.setDimensions(25, 160); + b.setDimensions(160, 25); b.fillColour(Colour::VIEWBACKGROUND); b.drawText(showing, 0, 0, Colour::LIGHTTEXT); } @@ -219,8 +213,16 @@ void VRecordingList::doDeleteSelected() saveIndex = toDelete->index; saveTop = sl.getTopOption(); Log::getInstance()->log("VRecordingList", Log::DEBUG, "FOUND: %i %s %s\n", toDelete->index, toDelete->getProgName(), toDelete->fileName); - recDir->recList->remove(toDelete); - Log::getInstance()->log("VRecordingList", Log::DEBUG, "I have removed: %s %s\n", toDelete->getProgName(), toDelete->fileName); + + for(RecordingList::iterator i = recDir->recList.begin(); i != recDir->recList.end(); i++) + { + if (*i == toDelete) + { + recDir->recList.erase(i); + Log::getInstance()->log("VRecordingList", Log::DEBUG, "Removed from vector: %s %s\n", toDelete->getProgName(), toDelete->fileName); + break; + } + } VDR* vdr = VDR::getInstance(); vdr->deleteRecording(toDelete->fileName); @@ -286,8 +288,9 @@ int VRecordingList::doResume() Recording* VRecordingList::getCurrentOptionRecording() { Recording* current; - for(recDir->recList->reset(); (current = (Recording*)recDir->recList->getCurrent()); recDir->recList->next()) + for (UINT i = 0; i < recDir->recList.size(); i++) { + current = recDir->recList[i]; if (current->index == sl.getCurrentOption()) return current; } return NULL; @@ -341,8 +344,9 @@ int VRecordingList::handleCommand(int command) // Check to see if it is a sub directory Directory* curDir; - for(recDir->dirList->reset(); (curDir = (Directory*)recDir->dirList->getCurrent()); recDir->dirList->next()) + for(UINT i = 0; i < recDir->dirList.size(); i++) { + curDir = recDir->dirList[i]; if (curDir->index == sl.getCurrentOption()) { VRecordingList* sub = new VRecordingList(this); @@ -357,21 +361,18 @@ int VRecordingList::handleCommand(int command) } // check to see if it's a recording - Recording* current; - for(recDir->recList->reset(); (current = (Recording*)recDir->recList->getCurrent()); recDir->recList->next()) + Recording* current = getCurrentOptionRecording(); + if (current) { - if (current->index == sl.getCurrentOption()) - { - Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->fileName); - - VRecordingMenu* v = new VRecordingMenu(); - v->setParent(this); - v->setRecording(current); - ViewMan::getInstance()->addNoLock(v); - v->draw(); - v->show(); - return 2; - } + Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->fileName); + + VRecordingMenu* v = new VRecordingMenu(); + v->setParent(this); + v->setRecording(current); + ViewMan::getInstance()->addNoLock(v); + v->draw(); + v->show(); + return 2; } // should not get to here return 1; diff --git a/vrecordinglist.h b/vrecordinglist.h index 8e932ac..18a8f5e 100644 --- a/vrecordinglist.h +++ b/vrecordinglist.h @@ -23,9 +23,9 @@ #include #include +#include #include "view.h" -#include "list.h" #include "directory.h" #include "recording.h" #include "wselectlist.h" diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index bdf3af7..96caaf4 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -33,7 +33,7 @@ VRecordingMenu::VRecordingMenu() setScreenPos(250, 160); } - setDimensions(140, 200); + setDimensions(200, 140); setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); @@ -42,7 +42,7 @@ VRecordingMenu::VRecordingMenu() setTitleBarColour(Colour::TITLEBARBACKGROUND); sl.setScreenPos(screenX + 10, screenY + 30 + 5); - sl.setDimensions(height - 30 - 15, width - 20); + sl.setDimensions(width - 20, height - 30 - 15); sl.addOption("Play", 1); sl.addOption("Resume", 0); sl.addOption("Summary", 0); @@ -129,7 +129,7 @@ int VRecordingMenu::handleCommand(int command) { vi->setScreenPos(110, 90); } - vi->setDimensions(300, 490); + vi->setDimensions(490, 300); ViewMan::getInstance()->addNoLock(vi); vi->draw(); @@ -158,7 +158,7 @@ int VRecordingMenu::handleCommand(int command) { v->setScreenPos(220, 140); } - v->setDimensions(180, 260); + v->setDimensions(260, 180); ViewMan::getInstance()->addNoLock(v); v->draw(); diff --git a/vserverselect.cc b/vserverselect.cc index 9dd91a3..3f62912 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -35,14 +35,14 @@ VServerSelect::VServerSelect(std::vector* serverIPs) { setScreenPos(210, 150); } - setDimensions(200, 300); + setDimensions(300, 200); setBackgroundColour(Colour::VIEWBACKGROUND); setTitleBarOn(1); setTitleBarColour(Colour::TITLEBARBACKGROUND); setTitleText("Choose a VDR server"); - sl.setScreenPos(screenX + 10, screenY + 30 + 5); - sl.setDimensions(height - 30 - 15, width - 20); + sl.setScreenPos(screenY + 30 + 5, screenX + 10); + sl.setDimensions(width - 20, height - 30 - 15); sl.addOption((*serverIPs)[0], 1); for(UINT k = 1; k < serverIPs->size(); k++) diff --git a/vvideolive.cc b/vvideolive.cc index e1d1a67..1e5f43b 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -20,12 +20,12 @@ #include "vvideolive.h" -VVideoLive::VVideoLive(List* tchanList, ULONG tstreamType) +VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType) { vdr = VDR::getInstance(); viewman = ViewMan::getInstance(); chanList = tchanList; - currentChannel = NULL; + currentChannel = 0; unavailable = 0; unavailableView = NULL; streamType = tstreamType; @@ -40,7 +40,7 @@ VVideoLive::VVideoLive(List* tchanList, ULONG tstreamType) player->init(); Video* video = Video::getInstance(); - setDimensions(video->getScreenHeight(), video->getScreenWidth()); + setDimensions(video->getScreenWidth(), video->getScreenHeight()); Colour transparent(0, 0, 0, 0); setBackgroundColour(transparent); } @@ -74,7 +74,7 @@ int VVideoLive::handleCommand(int command) return 4; } case Remote::DF_UP: - case Remote::UP: + case Remote::CHANNELUP: { if (unavailable) showUnavailable(0); else stop(); @@ -83,7 +83,7 @@ int VVideoLive::handleCommand(int command) return 2; } case Remote::DF_DOWN: - case Remote::DOWN: + case Remote::CHANNELDOWN: { if (unavailable) showUnavailable(0); else stop(); @@ -93,7 +93,7 @@ int VVideoLive::handleCommand(int command) } case Remote::OK: { - if (!unavailable) doBanner(); + doBanner(); return 2; } @@ -115,24 +115,46 @@ void VVideoLive::processMessage(Message* m) if (m->message == Message::CHANNEL_CHANGE) { // check channel number is valid - currentChannel = channelFromNumber(m->parameter); - if (!currentChannel) return; // this should never happen + currentChannel = channelIndexFromNumber(m->parameter); if (unavailable) showUnavailable(0); else stop(); play(); } + else if (m->message == Message::CHANNEL_UP) + { + // from vlivebanner + if (unavailable) showUnavailable(0); + else stop(1); + upChannel(); + play(1); + vlb->setChannel((*chanList)[currentChannel]); + vlb->draw(); + vlb->show(); + } + else if (m->message == Message::CHANNEL_DOWN) + { + // from vlivebanner + if (unavailable) showUnavailable(0); + else stop(1); + downChannel(); + play(1); + vlb->setChannel((*chanList)[currentChannel]); + vlb->draw(); + vlb->show(); + } + } void VVideoLive::doBanner() { - VLiveBanner* v = new VLiveBanner(currentChannel); - viewman->timedDelete(v, 4, 0); + vlb = new VLiveBanner(this, (*chanList)[currentChannel]); + viewman->timedDelete(vlb, 4, 0); Message* m = new Message(); m->from = this; m->to = viewman; m->message = Message::ADD_VIEW; - m->parameter = (ULONG)v; + m->parameter = (ULONG)vlb; viewman->postMessage(m); } @@ -146,7 +168,7 @@ void VVideoLive::showUnavailable(int active) unavailable = 1; unavailableView = new VInfo(); - unavailableView->setDimensions(200, 400); + unavailableView->setDimensions(400, 200); if (Video::getInstance()->getFormat() == Video::PAL) { unavailableView->setScreenPos(170, 200); @@ -155,7 +177,7 @@ void VVideoLive::showUnavailable(int active) { unavailableView->setScreenPos(160, 150); } - unavailableView->setTitleText(currentChannel->name); + unavailableView->setTitleText((*chanList)[currentChannel]->name); unavailableView->setMainText("\n Channel unavailable"); unavailableView->setDropThrough(); @@ -177,72 +199,59 @@ void VVideoLive::showUnavailable(int active) void VVideoLive::setChannel(int number) { - currentChannel = channelFromNumber(number); - if (!currentChannel) return; // should never happen + currentChannel = channelIndexFromNumber(number); play(); } -void VVideoLive::play() +void VVideoLive::play(int noShowVLB) { showUnavailable(0); - int available = vdr->streamChannel(currentChannel->number); + int available = vdr->streamChannel((*chanList)[currentChannel]->number); if (!available) { showUnavailable(1); + if (!noShowVLB) doBanner(); } else { - doBanner(); + if (!noShowVLB) doBanner(); player->play(); } } -void VVideoLive::stop() +void VVideoLive::stop(int noRemoveVLB) { if (unavailable) return; + if (!noRemoveVLB) viewman->removeView(vlb, 1, 1); // if live banner is present, remove it. won't cause damage if its not present + player->stop(); vdr->stopStreaming(); } -void VVideoLive::upChannel() +int VVideoLive::upChannel() { - Channel* channel; - for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next()) - { - if (channel == currentChannel) - { - chanList->next(); - channel = (Channel*)chanList->getCurrent(); - if (!channel) return; - currentChannel = channel; - } - } + if (currentChannel == (chanList->size() - 1)) return 0; // at the end + + ++currentChannel; + return 1; } -void VVideoLive::downChannel() +int VVideoLive::downChannel() { - Channel* channel; - Channel* prevChannel = NULL; - for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next()) - { - if (channel == currentChannel) - { - if (!prevChannel) return; - currentChannel = prevChannel; - } - prevChannel = channel; - } + if (currentChannel == 0) return 0; // at the start + + --currentChannel; + return 1; } -Channel* VVideoLive::channelFromNumber(int number) +UINT VVideoLive::channelIndexFromNumber(int number) { - Channel* channel; - for(chanList->reset(); (channel = (Channel*)chanList->getCurrent()); chanList->next()) + for(UINT i = 0; i < chanList->size(); i++) { - if (channel->number == (UINT)number) return channel; + if ((*chanList)[i]->number == (UINT)number) return i; } - return NULL; + return 0; } diff --git a/vvideolive.h b/vvideolive.h index ad75714..6925fe8 100644 --- a/vvideolive.h +++ b/vvideolive.h @@ -22,12 +22,12 @@ #define VVIDEOLIVE_H #include +#include #include "view.h" #include "playervideo.h" #include "playerradio.h" #include "vdr.h" -#include "list.h" #include "channel.h" #include "vlivebanner.h" #include "viewman.h" @@ -39,7 +39,7 @@ class VVideoLive : public View { public: - VVideoLive(List* chanList, ULONG streamType); + VVideoLive(ChannelList* chanList, ULONG streamType); ~VVideoLive(); void draw(); int handleCommand(int command); @@ -47,24 +47,25 @@ class VVideoLive : public View void setChannel(int number); - void play(); - void stop(); + void play(int noShowVLB = 0); + void stop(int noRemoveVLB = 0); private: ViewMan* viewman; VDR* vdr; Player* player; - List* chanList; - Channel* currentChannel; + ChannelList* chanList; + UINT currentChannel; int unavailable; VInfo* unavailableView; ULONG streamType; + VLiveBanner* vlb; - void upChannel(); - void downChannel(); + int upChannel(); + int downChannel(); void doBanner(); void showUnavailable(int active); - Channel* channelFromNumber(int number); + UINT channelIndexFromNumber(int number); }; #endif diff --git a/vvideorec.cc b/vvideorec.cc index 5325dbc..2d3d3f4 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -29,7 +29,7 @@ VVideoRec::VVideoRec(Recording* rec) myRec = rec; Video* video = Video::getInstance(); - setDimensions(video->getScreenHeight(), video->getScreenWidth()); + setDimensions(video->getScreenWidth(), video->getScreenHeight()); Colour transparent(0, 0, 0, 0); setBackgroundColour(transparent); } diff --git a/vvolume.cc b/vvolume.cc index 0ad0825..9ee1879 100644 --- a/vvolume.cc +++ b/vvolume.cc @@ -33,7 +33,7 @@ VVolume::VVolume() setScreenPos(90, 400); } - setDimensions(31, 227); + setDimensions(227, 31); setBackgroundColour(Colour::VIEWBACKGROUND); } diff --git a/vwallpaper.cc b/vwallpaper.cc index 101bc15..69de4df 100644 --- a/vwallpaper.cc +++ b/vwallpaper.cc @@ -35,7 +35,7 @@ void VWallpaper::init(char* name) jpeg.init(name); Video* video = Video::getInstance(); - setDimensions(video->getScreenHeight(), video->getScreenWidth()); + setDimensions(video->getScreenWidth(), video->getScreenHeight()); // Now override the surface pointer found in Box to a seperate wallpaper surface // but only for the wjpeg, not for this object diff --git a/vwelcome.cc b/vwelcome.cc index 1e840de..f27b6a7 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -22,7 +22,7 @@ VWelcome::VWelcome() { - setDimensions(200, 460); + setDimensions(460, 200); if (Video::getInstance()->getFormat() == Video::PAL) { @@ -39,7 +39,7 @@ VWelcome::VWelcome() setTitleText("Welcome"); sl.setScreenPos(screenX + 20, screenY + 40); - sl.setDimensions(140, 170); + sl.setDimensions(170, 140); sl.addOption("1. Live TV", 1); sl.addOption("2. Radio", 0); @@ -169,7 +169,7 @@ int VWelcome::handleCommand(int command) void VWelcome::doChannelsList() { - List* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO); + ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO); if (chanList) { @@ -191,7 +191,7 @@ void VWelcome::doChannelsList() void VWelcome::doRadioList() { - List* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO); + ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::RADIO); if (chanList) { @@ -209,7 +209,7 @@ void VWelcome::doRecordingsList() ViewMan* viewman = ViewMan::getInstance(); VInfo* viewWait = new VInfo(); - viewWait->setDimensions(190, 460); + viewWait->setDimensions(460, 190); if (Video::getInstance()->getFormat() == Video::PAL) { viewWait->setScreenPos(140, 170); diff --git a/wbutton.cc b/wbutton.cc index e8395a5..f66548c 100644 --- a/wbutton.cc +++ b/wbutton.cc @@ -23,7 +23,7 @@ WButton::WButton() { int fontHeight = surface->getFontHeight(); - setDimensions(fontHeight, 70); + setDimensions(70, fontHeight); mytext = NULL; active = 0; diff --git a/wjpeg.cc b/wjpeg.cc index 47d6d1e..b99489c 100644 --- a/wjpeg.cc +++ b/wjpeg.cc @@ -54,7 +54,7 @@ void WJpeg::draw() logger->log("BJpeg", Log::DEBUG, "JPEG startup done"); // Init the surface - setDimensions(cinfo.output_height, cinfo.output_width); + setDimensions(cinfo.output_width, cinfo.output_height); // MAKE THE 2D ARRAY diff --git a/wselectlist.cc b/wselectlist.cc index a0734f9..2e3fc6c 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -26,6 +26,7 @@ WSelectList::WSelectList() topOption = 0; numOptionsDisplayable = 0; numColumns = 0; + noLoop = 0; } WSelectList::~WSelectList() @@ -48,6 +49,11 @@ void WSelectList::clear() numColumns = 0; } +void WSelectList::setNoLoop() +{ + noLoop = 1; +} + void WSelectList::hintSetCurrent(int index) { selectedOption = index; @@ -77,9 +83,9 @@ void WSelectList::draw() numOptionsDisplayable = (height - 5) / ySeperation; if (selectedOption == (topOption + numOptionsDisplayable)) topOption++; - if (selectedOption == (topOption - 1)) topOption--; + if (selectedOption == ((UINT)topOption - 1)) topOption--; // if still not visible... - if ((selectedOption < topOption) || (selectedOption > (topOption + numOptionsDisplayable))) + if ((selectedOption < (UINT)topOption) || (selectedOption > (topOption + numOptionsDisplayable))) { topOption = selectedOption - (numOptionsDisplayable / 2); } @@ -148,7 +154,7 @@ void WSelectList::up() } else { - selectedOption = options.size() - 1; + if (!noLoop) selectedOption = options.size() - 1; } } @@ -160,7 +166,7 @@ void WSelectList::down() } else { - selectedOption = 0; + if (!noLoop) selectedOption = 0; } } diff --git a/wselectlist.h b/wselectlist.h index 7c48e6a..473e813 100644 --- a/wselectlist.h +++ b/wselectlist.h @@ -40,6 +40,7 @@ class WSelectList : public Box void clear(); void addColumn(int x); + void setNoLoop(); int addOption(char* text, int selected); void draw(); @@ -61,10 +62,11 @@ class WSelectList : public Box vector options; UINT selectedOption; - UINT topOption; + int topOption; UINT numOptionsDisplayable; int columns[10]; int numColumns; + int noLoop; }; -- 2.39.5