]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Channel schedules in live banner
authorChris Tallon <chris@vomp.tv>
Mon, 29 Aug 2005 19:19:16 +0000 (19:19 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 29 Aug 2005 19:19:16 +0000 (19:19 +0000)
Programme information from live banner
Channel up/down buttons fixed on new remote
Converted data structures to STL

51 files changed:
Makefile
box.cc
box.h
colour.cc
colour.h
command.cc
command.h
directory.cc
directory.h
event.cc [new file with mode: 0644]
event.h [new file with mode: 0644]
list.cc [deleted file]
list.h [deleted file]
message.h
messagequeue.cc
messagequeue.h
node.cc [deleted file]
node.h [deleted file]
playervideo.cc
queue.cc [deleted file]
queue.h [deleted file]
surface.cc
thread.cc
thread.h
vchannellist.cc
vchannellist.h
vchannelselect.cc
vconnect.cc
vdr.cc
vdr.h
view.cc
viewman.cc
vlivebanner.cc
vlivebanner.h
voptions.cc
vradiolive.cc
vradiolive.h
vrecordinglist.cc
vrecordinglist.h
vrecordingmenu.cc
vserverselect.cc
vvideolive.cc
vvideolive.h
vvideorec.cc
vvolume.cc
vwallpaper.cc
vwelcome.cc
wbutton.cc
wjpeg.cc
wselectlist.cc
wselectlist.h

index 82c4fff039dd3e8690f7a0f3d6724a8b829230ef..bba406efa84e444a1b9f44dc47c576c35e96e024 100644 (file)
--- 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 9bd6c6ed7d64222490024230bb9fb66ae6054739..30b24b6f33b81d71c8f160a213bd6cb430750419 100644 (file)
--- 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 c9af906ca661e40324ac809f5bf62d71b2de53e9..93f8b318ef4cebc322c82ed80acbbc2e91bbb6fe 100644 (file)
--- 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();
index c11377bd810f572bd098110d36398a53bce4bedd..44722293b18b4c104d5a5bfd0dd75646adda442d 100644 (file)
--- 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);
index f9b914bcda51bf591b9a8f03f75c604e0437fc7a..3abb27fcd800fea4c8a988b37ecbcbbc7bd5c6f7 100644 (file)
--- 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;
index 22cf675c6a2b67fc9e666d295c8e48f293de2f35..136b04fc2747ec7398535e849591a6412758a24e 100644 (file)
@@ -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();
index 29155d887d24aabf2c2ebc9ceea2a992073b23b9..a63dc4619469a468656c12cd0800da735cf9c9d3 100644 (file)
--- 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"
index b73b982b41a06a023787bf72374080ec6153cfda..20bd2847b81b562f0e01d7d4235bb3ecbb20b587 100644 (file)
@@ -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
index f9d0d3c3c8741fcd0ebaa3c6600e47399687aba7..4e4c55abd25abbf4beaca4c19549404cf34ad2a8 100644 (file)
 #define DIRECTORY_H
 
 #include <stdio.h>
+#include <vector>
 
 #include "defines.h"
-#include "list.h"
 #include "recording.h"
 
+class Directory;
+typedef vector<Directory*> DirectoryList;
+typedef vector<Recording*> 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/event.cc b/event.cc
new file mode 100644 (file)
index 0000000..614eaa1
--- /dev/null
+++ b/event.cc
@@ -0,0 +1,41 @@
+/*
+    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 "event.h"
+
+Event::Event()
+{
+  id = 0;
+  time = 0;
+  duration = 0;
+
+  title = NULL;
+  subtitle = NULL;
+  description = NULL;
+
+  index = -1;
+}
+
+Event::~Event()
+{
+  if (title) delete[] title;
+  if (subtitle) delete[] subtitle;
+  if (description) delete[] description;
+}
diff --git a/event.h b/event.h
new file mode 100644 (file)
index 0000000..3d595bc
--- /dev/null
+++ b/event.h
@@ -0,0 +1,55 @@
+/*
+    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 EVENT_H
+#define EVENT_H
+
+#include <stdio.h>
+
+#include "defines.h"
+
+class Event
+{
+  public:
+    Event();
+    ~Event();
+
+    ULONG id;
+    ULONG time;
+    ULONG duration;
+
+    char* title;
+    char* subtitle;
+    char* description;
+
+    int index;
+
+};
+
+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 (file)
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 (file)
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 <stdio.h>
-#include <malloc.h>
-#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
index a8783cfea5bc2d7359fd40268e198e96e74259f0..190cfc48917a142e8e0003200e576ec84517bf0a 100644 (file)
--- 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
index 5c4bbd97f23bb68a6a8783700f87087eb56beb88..d88d6edb7ff995d20d8e8c899f59629138c376dd 100644 (file)
 
 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;
index 6e36a9b977bab3bed2eb8a1103caa58d70bf5327..421460a57f3e3f0002a062c6be385bc240b3ab1f 100644 (file)
 #ifndef MESSAGEQUEUE_H
 #define MESSAGEQUEUE_H
 
-#include "queue.h"
+#include <queue>
+
 #include "message.h"
 #include "log.h"
 
+typedef queue<Message*> 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.cc b/node.cc
deleted file mode 100644 (file)
index c99db45..0000000
--- a/node.cc
+++ /dev/null
@@ -1,46 +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 "node.h"
-
-Node::Node(void *newData, Node *ptr)
-{
-  myData = newData;
-  ptrNext = ptr;
-}
-
-Node::~Node()
-{
-}
-
-void *Node::getData(void)
-{
-  return myData;
-}
-
-Node *Node::getPtr(void)
-{
-  return ptrNext;
-}
-
-void Node::setPtr(Node *newPtr)
-{
-  ptrNext = newPtr;
-}
diff --git a/node.h b/node.h
deleted file mode 100644 (file)
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
index 4ad52fee0b5ac46aafcc5481c0a7c164a222c527..78620aed4fb7e295a30fa2668335071c42f8ddd6 100644 (file)
@@ -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 (file)
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/queue.h b/queue.h
deleted file mode 100644 (file)
index 29cdd85..0000000
--- a/queue.h
+++ /dev/null
@@ -1,45 +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 QUEUE_H
-#define QUEUE_H
-
-#include <stdio.h>
-
-#include "node.h"
-
-class Queue
-{
-  public:
-    Queue();
-    ~Queue();
-    void store(void *);
-    void *retrieve(void);
-    short isEmpty(void) const;
-    void *peekNext(void);
-
-  private:
-    Node *start;
-    Node *end;
-};
-
-/* The destructor deletes any remaining QNodes but not stored objects. */
-
-#endif
index d550b30fcb08dfed5cc7f8b11d347e22de508bc4..20a514301d51d15ff2817945fdd24013e1fc2f34 100644 (file)
@@ -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;
 }
index b6cc8ffa1544c7c2a18dd4bd924cca513b6a0fae..13cc674de24ba99e0e249aec3d8b0f756d8d49b1 100644 (file)
--- 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);
+}
index 111ede4de2bb8a0a1c4c953604c059968520fe54..eddaf7141dbec51470ca3f9e727f9933cb5ddd96 100644 (file)
--- 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
 
index 81159f4c64357ff37b7fa16b65efdb3b2421f6bb..f8d196ba18c27a0667fcf135cb1ff8ca62bc6d69 100644 (file)
@@ -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();
         }
       }
 
index 69fd479111983a1eee9676ae518817d02cc978e9..9fcb669fc34e22a98277e73629de5ed00f5ed415 100644 (file)
@@ -23,9 +23,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <vector>
 
 #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;
index b0711e9cac0d912ee3590b6758d6d2570da0c073..fb93a2a3049e58d3726fadf89f26871f23a60c06 100644 (file)
@@ -25,7 +25,7 @@
 
 VChannelSelect::VChannelSelect(VVideoLive* v, int command)
 {
-  setDimensions(30, 53);
+  setDimensions(53, 30);
   setScreenPos(80, 60);
 
   setBackgroundColour(Colour::VIEWBACKGROUND);
index 0a31bf8db9ade01121b8f78dfc75094c391a281b..e8eaeff61ae4b0246e31cba4c6c630e9a6e35adb 100644 (file)
@@ -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 d951f45b725b81de50abf7a8caeae24fd5ab82f1..45e2d9864626606c829d44575cf69f0ba79a425f 100644 (file)
--- 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<char*>& serverIPs)
+void VDR::findServers(vector<char*>& 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, &currentTime);
 
-  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 bef6566009d8def6a5edd7d59d8edc0128409ce4..2767b43bef8cc2ecec21588c000374bd2f180768 100644 (file)
--- a/vdr.h
+++ b/vdr.h
 #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<Event*> EventList;
+typedef vector<Channel*> ChannelList;
+
 class VDR
 {
+
   public:
     VDR();
     ~VDR();
@@ -47,7 +53,7 @@ class VDR
     int init(int port);
     int shutdown();
 
-    void findServers(std::vector<char*>& serverIPs);
+    void findServers(vector<char*>& 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 2030c5fdc1939ceb566c58f48b78e82fa277e6a1..8c7831c8720098f07bc5a9b516b7ece7ef4d3e07 100644 (file)
--- 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;
 
index 1f4e5921ee6c3bbf6ab0a4730efb8d2c1231a86b..7748681b91d8bdbaf73c85c16d64a89bc1005ea6 100644 (file)
@@ -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;
     }
   }
index 6d830e57e105084a5d338346d7e8aaa340bec2c8..39c4ef7f649ccb6dee731c35a8102839b3d9cc63 100644 (file)
 
 #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;
index 3427468b453b3bbe570e1e554213c05c3d50eb58..993db1a0c432480405af7c55d7b739f800760c73 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <vector>
+#include <algorithm>
 
 #include "view.h"
 #include "remote.h"
 #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;
 
 };
 
index 9c80ddead009e69319d87beac75aa881159983fa..7c5d79ce1e62c9b2ac261f7457ce5b17d130a9e8 100644 (file)
@@ -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");
index c0e57ef5fead8079e16b6dbcdc00be2132a965d2..57f17e3c79083439687a25a7cf90e54cfeed8177 100644 (file)
@@ -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;
 }
+
index 2b31e1e7b725046b727c53bfdc7d53e7cf6b30cf..84570820fb1e99f0556a82b3a8c8b13d54e56a7a 100644 (file)
 #define VRADIOLIVE_H
 
 #include <stdio.h>
+#include <vector>
 
 #include "view.h"
 #include "playerradio.h"
 #include "vdr.h"
-#include "list.h"
 #include "channel.h"
 #include "viewman.h"
 #include "remote.h"
 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
index c8bd1e3b438c9f52b52347dbd6864d1ab89e3bd2..b483ed079e220b9ebe3bf748ca8182febfc9b672 100644 (file)
@@ -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;
index 8e932acca8d5ddba4d0bee687e9f9c6dacbc734d..18a8f5ef6bc2087fd3b8d25f4112435578e2a51d 100644 (file)
@@ -23,9 +23,9 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <vector>
 
 #include "view.h"
-#include "list.h"
 #include "directory.h"
 #include "recording.h"
 #include "wselectlist.h"
index bdf3af701b1bb3282d8d398c2f9ec16b3e1a75ee..96caaf4f640689f53939edd7677de90ace90cc00 100644 (file)
@@ -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();
index 9dd91a39bee718c4c992f30f87bc49b852b1aa8f..3f629122c09a95ffd1325aa9ff354160117dee54 100644 (file)
@@ -35,14 +35,14 @@ VServerSelect::VServerSelect(std::vector<char*>* 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++)
index e1d1a67eb71f7ba36c3395ea969ac3f65d62e7f2..1e5f43b3750fe8e33cd4e492fe5f6f07290af066 100644 (file)
 
 #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;
 }
 
index ad75714cb1fa96ba6d108b11d337985d81044603..6925fe8571b0483f742d94214297400569ed5b32 100644 (file)
 #define VVIDEOLIVE_H
 
 #include <stdio.h>
+#include <vector>
 
 #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
index 5325dbc6b5c80521f9eafa5e8644206f9ea1844d..2d3d3f41168f81b577329a6e95a1f0e4ecf0a9a9 100644 (file)
@@ -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);
 }
index 0ad082569e38b2524dac489c7fee157c1a990a29..9ee1879760e548a6a916d85ab2365964c67478bc 100644 (file)
@@ -33,7 +33,7 @@ VVolume::VVolume()
     setScreenPos(90, 400);
   }
 
-  setDimensions(31, 227);
+  setDimensions(227, 31);
 
   setBackgroundColour(Colour::VIEWBACKGROUND);
 }
index 101bc153845981d48d0383d030a5c0855d5d4db0..69de4df17ef68fe2922e66684233ddc74fc17536 100644 (file)
@@ -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
index 1e840defadc9a98214d645d50cd2c6c27094269d..f27b6a7bea4226ac68be599a256d5b04f1985ced 100644 (file)
@@ -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);
index e8395a5b3b842b2e71e24e92679ce96e7eab950b..f66548c000b4c5d71c403856f49642bd5dd8ffbf 100644 (file)
@@ -23,7 +23,7 @@
 WButton::WButton()
 {
   int fontHeight = surface->getFontHeight();
-  setDimensions(fontHeight, 70);
+  setDimensions(70, fontHeight);
 
   mytext = NULL;
   active = 0;
index 47d6d1ea9a8fa72d56c15a6073ec4d8c920f5e1b..b99489ce1bb0df1c11e82e83b36bbc9515146e7e 100644 (file)
--- 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
index a0734f9108e5bb1ec9a836870499bad23ca60faa..2e3fc6cc3df580c8bf34eebf217f2debc8538630 100644 (file)
@@ -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;
   }
 }
 
index 7c48e6a601faf0bf7bfd10416b5b7fe67b5a0d07..473e813eec3bf929908dde0622a40f54e1cef22c 100644 (file)
@@ -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<char*> options;
     UINT selectedOption;
-    UINT topOption;
+    int topOption;
     UINT numOptionsDisplayable;
     int columns[10];
     int numColumns;
+    int noLoop;
 
 };