]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Recording timer list
authorChris Tallon <chris@vomp.tv>
Tue, 3 Jan 2006 18:00:05 +0000 (18:00 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 3 Jan 2006 18:00:05 +0000 (18:00 +0000)
Makefile
playervideo.cc
rectimer.cc [new file with mode: 0644]
rectimer.h [new file with mode: 0644]
vdr.cc
vdr.h
vtimerlist.cc [new file with mode: 0644]
vtimerlist.h [new file with mode: 0644]
vwelcome.cc
vwelcome.h

index 67e569bc3989a1a3f22cec9fbfacbe8db0baadb6..276a265ba261ebc71b1e70e2ea75868f2e22ff22 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,8 @@ CROSSLIBS = ../jpeg-6b/libjpeg.a
 
 OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o directory.o thread.o event.o \
           player.o demuxer.o stream.o vfeed.o afeed.o afeedr.o osd.o surface.o viewman.o vdr.o dsock.o box.o \
-          recording.o channel.o message.o playervideo.o messagequeue.o \
-          view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o \
+          recording.o channel.o message.o playervideo.o messagequeue.o rectimer.o \
+          view.o vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o vtimerlist.o \
           vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o \
           vchannelselect.o vserverselect.o colour.o vconnect.o voptions.o vepg.o region.o \
           widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o wtextbox.o i18n.o timers.o \
index 72f2609720ae67adec17f820a55e59827b4dcdef..ef72f099d731ea2be81788276533dc7dc2bdd4c0 100644 (file)
@@ -1,4 +1,4 @@
-/*
+#/*
     Copyright 2004-2005 Chris Tallon
 
     This file is part of VOMP.
diff --git a/rectimer.cc b/rectimer.cc
new file mode 100644 (file)
index 0000000..9211fd7
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+    Copyright 2004-2005 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include "rectimer.h"
+
+RecTimer::RecTimer()
+{
+  active = 0;
+  recording = 0;
+  pending = 0;
+  priority = 0;
+  lifeTime = 0;
+  channelNumber = 0;
+  startTime = 0;
+  stopTime = 0;
+
+  file = NULL;
+  summary = NULL;
+
+  index = -1;
+}
+
+RecTimer::~RecTimer()
+{
+  if (file) delete[] file;
+  if (summary) delete[] summary;
+}
diff --git a/rectimer.h b/rectimer.h
new file mode 100644 (file)
index 0000000..55a8944
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+    Copyright 2004-2005 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef RECTIMER_H
+#define RECTIMER_H
+
+#include <stdio.h>
+
+#include "defines.h"
+
+class RecTimer
+{
+  public:
+    RecTimer();
+    ~RecTimer();
+
+    ULONG active;
+    ULONG recording;
+    ULONG pending;
+    ULONG priority;
+    ULONG lifeTime;
+    ULONG channelNumber;
+    ULONG startTime;
+    ULONG stopTime;
+
+    char* file;
+    char* summary;
+
+
+    int index;
+};
+
+#endif
diff --git a/vdr.cc b/vdr.cc
index b5d1fac7a10adf71049a6393ff3e1555898042b5..9eb4106823aa62ac917a1b76d4d652078ab5aaba 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -799,3 +799,59 @@ char* VDR::configLoad(char* section, char* key)
 
   return toReturn;
 }
+
+RecTimerList* VDR::getRecTimersList()
+{
+  if (!connected) return NULL;
+
+  UCHAR buffer[8];
+
+  *(unsigned long*)&buffer[0] = htonl(4);
+  *(unsigned long*)&buffer[4] = htonl(VDR_GETTIMERS);
+
+  pthread_mutex_lock(&mutex);
+  int a = tcp->sendPacket(buffer, 8);
+  if (a != 8)
+  {
+    pthread_mutex_unlock(&mutex);
+    return NULL;
+  }
+
+  // reply
+
+  if (!getPacket())
+  {
+    pthread_mutex_unlock(&mutex);
+    return NULL;
+  }
+
+  RecTimerList* recTimerList = new RecTimerList();
+
+  RecTimer* newRecTimer;
+
+  while (packetPos < packetLength)
+  {
+    newRecTimer = new RecTimer();
+    newRecTimer->active = extractULONG();
+    newRecTimer->recording = extractULONG();
+    newRecTimer->pending = extractULONG();
+    newRecTimer->priority = extractULONG();
+    newRecTimer->lifeTime = extractULONG();
+    newRecTimer->channelNumber = extractULONG();
+    newRecTimer->startTime = extractULONG();
+    newRecTimer->stopTime = extractULONG();
+
+    newRecTimer->file = extractString();
+    newRecTimer->summary = extractString();
+
+    recTimerList->push_back(newRecTimer);
+    Log::getInstance()->log("VDR", Log::DEBUG, "TL: %lu %lu %lu %lu %lu %lu %lu %lu %s",
+      newRecTimer->active, newRecTimer->recording, newRecTimer->pending, newRecTimer->priority, newRecTimer->lifeTime,
+      newRecTimer->channelNumber, newRecTimer->startTime, newRecTimer->stopTime, newRecTimer->file);
+  }
+
+  freePacket();
+  pthread_mutex_unlock(&mutex);
+
+  return recTimerList;
+}
diff --git a/vdr.h b/vdr.h
index 48c4c6eb300f8ff071c3f6cd8f6d94db719cc6e8..21c4b8eeccefb18fb41439d703d323fe640098f7 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -34,6 +34,7 @@
 #include "recording.h"
 #include "channel.h"
 #include "event.h"
+#include "rectimer.h"
 
 using namespace std;
 
@@ -41,6 +42,7 @@ using namespace std;
 
 typedef vector<Event*> EventList;
 typedef vector<Channel*> ChannelList;
+typedef vector<RecTimer*> RecTimerList;
 
 class VDR
 {
@@ -80,6 +82,8 @@ class VDR
     int        configSave(char* section, char* key, const char* value);
     char*      configLoad(char* section, char* key);
 
+    RecTimerList* getRecTimersList();
+
     // end
 
     const static ULONG VIDEO = 1;
@@ -113,6 +117,7 @@ class VDR
     const static ULONG VDR_CONFIGSAVE          = 11;
     const static ULONG VDR_CONFIGLOAD          = 12;
     const static ULONG VDR_RESCANRECORDING     = 13;
+    const static ULONG VDR_GETTIMERS           = 14;
 
     int  getPacket();
     void freePacket();
diff --git a/vtimerlist.cc b/vtimerlist.cc
new file mode 100644 (file)
index 0000000..2798bd7
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+    Copyright 2004-2005 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#include "vtimerlist.h"
+
+VTimerList::VTimerList(RecTimerList* trtl)
+{
+  recTimerList = trtl;
+
+  create(570, 420);
+  if (Video::getInstance()->getFormat() == Video::PAL)
+  {
+    setScreenPos(80, 70);
+  }
+  else
+  {
+    setScreenPos(70, 35);
+  }
+
+
+  setBackgroundColour(Colour::VIEWBACKGROUND);
+  setTitleBarOn(1);
+  setTitleText(tr("Timers"));
+  setTitleBarColour(Colour::TITLEBARBACKGROUND);
+
+  sl.setSurface(surface);
+  sl.setSurfaceOffset(10, 30 + 5);
+  sl.setDimensions(area.w - 20, area.h - 30 - 15 - 30);
+
+  drawData();
+}
+
+VTimerList::~VTimerList()
+{
+  if (recTimerList)
+  {
+    for (UINT i = 0; i < recTimerList->size(); i++)
+    {
+      delete (*recTimerList)[i];
+    }
+
+    recTimerList->clear();
+    delete recTimerList;
+  }
+}
+
+void VTimerList::drawData()
+{
+  char str[500];
+
+  sl.addColumn(0);
+  sl.addColumn(60);
+
+  RecTimer* recTimer;
+  int first = 1;
+
+  for (UINT i = 0; i < recTimerList->size(); i++)
+  {
+    recTimer = (*recTimerList)[i];
+    sprintf(str, "%u\t%s", i, recTimer->file);
+    recTimer->index = sl.addOption(str, first);
+    first = 0;
+  }
+}
+
+void VTimerList::draw()
+{
+  View::draw();
+  sl.draw();
+
+  // Put the status stuff at the bottom
+
+  WSymbol w;
+  w.setSurface(surface);
+
+  w.nextSymbol = WSymbol::UP;
+  w.setSurfaceOffset(20, 385);
+  w.draw();
+
+  w.nextSymbol = WSymbol::DOWN;
+  w.setSurfaceOffset(50, 385);
+  w.draw();
+
+  w.nextSymbol = WSymbol::SKIPBACK;
+  w.setSurfaceOffset(85, 385);
+  w.draw();
+
+  w.nextSymbol = WSymbol::SKIPFORWARD;
+  w.setSurfaceOffset(115, 385);
+  w.draw();
+
+//  w.nextSymbol = WSymbol::PLAY;
+//  w.setSurfaceOffset(150, 385);
+//  w.draw();
+
+  doShowingBar();
+}
+
+void VTimerList::doShowingBar()
+{
+  int topOption = sl.getTopOption() + 1;
+  if (sl.getNumOptions() == 0) topOption = 0;
+
+  char showing[200];
+  sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions());
+
+  rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND);
+  drawText(showing, 220, 385, Colour::LIGHTTEXT);
+}
+
+int VTimerList::handleCommand(int command)
+{
+  switch(command)
+  {
+    case Remote::DF_UP:
+    case Remote::UP:
+    {
+      sl.up();
+      sl.draw();
+
+      doShowingBar();
+      ViewMan::getInstance()->updateView(this);
+      return 2;
+    }
+    case Remote::DF_DOWN:
+    case Remote::DOWN:
+    {
+      sl.down();
+      sl.draw();
+
+      doShowingBar();
+      ViewMan::getInstance()->updateView(this);
+      return 2;
+    }
+    case Remote::SKIPBACK:
+    {
+      sl.pageUp();
+      sl.draw();
+
+      doShowingBar();
+      ViewMan::getInstance()->updateView(this);
+      return 2;
+    }
+    case Remote::SKIPFORWARD:
+    {
+      sl.pageDown();
+      sl.draw();
+
+      doShowingBar();
+      ViewMan::getInstance()->updateView(this);
+      return 2;
+    }
+    case Remote::OK:
+    {
+      RecTimer* recTimer = NULL;
+      if (recTimerList)
+      {
+        int currentOption = sl.getCurrentOption();
+
+        for (UINT i = 0; i < recTimerList->size(); i++)
+        {
+          recTimer = (*recTimerList)[i];
+          if (currentOption == recTimer->index) break;
+        }
+      }
+
+      if (recTimer == NULL) return 2;
+
+      // recTimer is the one you want FIXME
+
+      return 2;
+    }
+    case Remote::BACK:
+    {
+      return 4;
+    }
+  }
+  // stop command getting to any more views
+  return 1;
+}
diff --git a/vtimerlist.h b/vtimerlist.h
new file mode 100644 (file)
index 0000000..57dae9d
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+    Copyright 2004-2005 Chris Tallon
+
+    This file is part of VOMP.
+
+    VOMP is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    VOMP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with VOMP; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef VTIMERLIST_H
+#define VTIMERLIST_H
+
+#include <stdio.h>
+#include <string.h>
+#include <vector>
+
+#include "view.h"
+#include "wselectlist.h"
+#include "remote.h"
+#include "wsymbol.h"
+#include "viewman.h"
+#include "vdr.h"
+#include "colour.h"
+#include "video.h"
+#include "i18n.h"
+
+class VTimerList : public View
+{
+  public:
+    VTimerList(RecTimerList* rtl);
+    ~VTimerList();
+
+    int handleCommand(int command);
+    void draw();
+
+  private:
+    RecTimerList* recTimerList;
+
+    WSelectList sl;
+
+    void doShowingBar();
+    void drawData();
+};
+
+#endif
index 5208f61d19d2c7461a87e944aab4ba3cf29cf5ab..65b4a1711f1ea0c6707d81fac5831d1f21ac8852 100644 (file)
@@ -193,6 +193,13 @@ int VWelcome::handleCommand(int command)
       }
       return 2; // never gets here
     }
+#ifdef DEV
+    case Remote::NINE:
+    {
+      doTimersList();
+      return 2;
+    }
+#endif
   }
 
   return 1;
@@ -262,6 +269,20 @@ void VWelcome::doRecordingsList()
   Log::getInstance()->log("VWelcome", Log::DEBUG, "possible delay end");
 }
 
+void VWelcome::doTimersList()
+{
+  RecTimerList* recTimerList = VDR::getInstance()->getRecTimersList();
+
+  if (recTimerList)
+  {
+    VTimerList* vtl = new VTimerList(recTimerList);
+
+    vtl->draw();
+    viewman->add(vtl);
+    viewman->updateView(vtl);
+  }
+}
+
 void VWelcome::doOptions()
 {
   VOptions* voptions = new VOptions(this);
index 06440b5f2b06ddb63c35a8bd217db5ff05b051fc..8192dc301af3e2deefcc3f3450b1bdd35d6464a9 100644 (file)
@@ -33,6 +33,7 @@
 #include "directory.h"
 #include "vchannellist.h"
 #include "vrecordinglist.h"
+#include "vtimerlist.h"
 #include "command.h"
 #include "message.h"
 #include "colour.h"
@@ -61,6 +62,7 @@ class VWelcome : public View, public TimerReceiver
     void doChannelsList();
     void doRadioList();
     void doRecordingsList();
+    void doTimersList();
     void doOptions();
     void drawClock();