]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Options menu rearrangement, set timer from EPG
authorChris Tallon <chris@vomp.tv>
Sun, 26 Feb 2006 01:39:30 +0000 (01:39 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 26 Feb 2006 01:39:30 +0000 (01:39 +0000)
13 files changed:
Makefile
command.cc
vdr.cc
vdr.h
vepg.cc
vepg.h
vepgsettimer.cc [new file with mode: 0644]
vepgsettimer.h [new file with mode: 0644]
view.h
vinfo.cc
voptionsmenu.cc [new file with mode: 0644]
voptionsmenu.h [new file with mode: 0644]
vrecordinglist.h

index b2c3dc6458685717ff3742a476eefb7f4a1dcbff..f825f836962e5e92cc29246dfbdbaa3c006dd96e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ OBJECTS = main.o command.o log.o remote.o led.o mtd.o video.o audio.o tcp.o dire
           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 rectimer.o vtimeredit.o voptionsmenu.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 \
+          vrecordingmenu.o vquestion.o vchannellist.o vwelcome.o vvideolive.o vvideorec.o vepgsettimer.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 \
           fonts/helvB24.o fonts/helvB18.o
index 815309abcea916b46a0d3b18cdd64a665a4d1d63..7ece424d9f4add8dfe03fdef2e8552d8ae2b56d7 100644 (file)
@@ -557,4 +557,6 @@ void Command::doJustConnected(VConnect* vconnect)
   vw->draw();
   viewman->add(vw);
   viewman->updateView(vw);
+
+  // Enter pre-keys here
 }
diff --git a/vdr.cc b/vdr.cc
index 1b3b7aa9c9555db9a49cc61ac6a7dde858ec79e1..3f8c7e72010e9a048547cff42c92960e7e6d89c6 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -892,3 +892,35 @@ RecTimerList* VDR::getRecTimersList()
 
   return recTimerList;
 }
+
+ULONG VDR::setEventTimer(char* timerString)
+{
+  if (!connected) return false;
+
+  unsigned long totalLength = 8 + strlen(timerString) + 1;
+  UCHAR buffer[totalLength];
+
+  *(unsigned long*)&buffer[0] = htonl(totalLength - 4);
+  *(unsigned long*)&buffer[4] = htonl(VDR_SETTIMER);
+  strcpy((char*)&buffer[8], timerString);
+
+  pthread_mutex_lock(&mutex);
+  unsigned int a = tcp->sendPacket(buffer, totalLength);
+  if (a != totalLength)
+  {
+    pthread_mutex_unlock(&mutex);
+    return 0;
+  }
+
+  if (!getPacket())
+  {
+    pthread_mutex_unlock(&mutex);
+    return 0;
+  }
+
+  ULONG toReturn = extractULONG();
+  freePacket();
+  pthread_mutex_unlock(&mutex);
+
+  return toReturn;
+}
diff --git a/vdr.h b/vdr.h
index 4e362450c7d35ec695ccc1f9696e5a02a8e7e18c..5622fd0a1a6283c9c2efac99bde2c92aa12511f6 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -127,6 +127,7 @@ class VDR
     EventList* getChannelSchedule(ULONG number, time_t start, ULONG duration);
     int        configSave(char* section, char* key, const char* value);
     char*      configLoad(char* section, char* key);
+    ULONG      setEventTimer(char* timerString);
 
     RecTimerList* getRecTimersList();
 
@@ -164,6 +165,7 @@ class VDR
     const static ULONG VDR_CONFIGLOAD          = 12;
     const static ULONG VDR_RESCANRECORDING     = 13;
     const static ULONG VDR_GETTIMERS           = 14;
+    const static ULONG VDR_SETTIMER            = 15;
 
     int  getPacket();
     void freePacket();
diff --git a/vepg.cc b/vepg.cc
index e00bc3f49f56e69732663789a0c22423ff0b20d1..0f7ae5ac9797a9dfdbf677515b02a9d3a43faf1a 100644 (file)
--- a/vepg.cc
+++ b/vepg.cc
@@ -163,7 +163,7 @@ void VEpg::setInfo(Event* event)
 {\r
   time_t t;\r
   struct tm* btime; // to hold programme start and end time\r
-  char* timeString = new char[9]; // to hold programme start and end time\r
+  char timeString[9]; // to hold programme start and end time\r
   int length = strlen(event->title); // calculate length of programme title string\r
   char* title = new char[length + 15]; // create string to hold start time, end time and programme title\r
   btime = localtime((time_t*)&event->time); //get programme start time\r
@@ -180,9 +180,8 @@ void VEpg::setInfo(Event* event)
   strcpy(info, event->description);\r
   progInfo.setText(info); // show programme detail string\r
 // destroy dynamically allocated memory\r
-  delete info;\r
-  delete title;\r
-  delete timeString;\r
+  delete[] info;\r
+  delete[] title;\r
 }\r
 \r
 void VEpg::draw()\r
@@ -233,8 +232,8 @@ void VEpg::draw()
   drawText(tr("Guide / Back: Close"), keyx + 292 , keyy + 5, Colour::LIGHTTEXT);\r
 \r
   surface->fillblt(keyx + 290, keyy + Surface::getFontHeight() + 8, 180, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255));\r
-//  Colour red = Colour(130, 0, 0);\r
-//  drawText(tr("Rec: Set timer"), keyx + 292, keyy + Surface::getFontHeight() + 9, red);\r
+  Colour red = Colour(130, 0, 0);\r
+  drawText(tr("Rec: Set timer"), keyx + 292, keyy + Surface::getFontHeight() + 9, red);\r
 \r
   surface->fillblt(keyx + 474, keyy + 4, 128, Surface::getFontHeight() + 2, surface->rgba( 180, 180, 180, 255));\r
   w.nextSymbol = WSymbol::PLAY;\r
@@ -341,9 +340,11 @@ int VEpg::handleCommand(int command)
     }\r
     case Remote::RECORD:\r
     {\r
-      Log::getInstance()->log("VEPG", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s\n", thisEvent.id, thisEvent.time, thisEvent.duration, thisEvent.title);
-
-      //TODO FIXME\r
+      Log::getInstance()->log("VEPG", Log::DEBUG, "ID %lu TIME %lu DURATION %lu TITLE %s", thisEvent.id, thisEvent.time, thisEvent.duration, thisEvent.title);
+      VEpgSetTimer* vs = new VEpgSetTimer(&thisEvent, (*chanList)[chanListbox.getCurrentOption()]);
+      vs->draw();
+      viewman->add(vs);
+      viewman->updateView(vs);
       return 2;\r
     }\r
     case Remote::PLAY:\r
diff --git a/vepg.h b/vepg.h
index 4d48c503bbb99035a8a4d716e7adc3e5d70bd68b..a00da97d42dfdc746ef214080c0efe9b68814a94 100644 (file)
--- a/vepg.h
+++ b/vepg.h
@@ -39,6 +39,7 @@
 #include "event.h"\r
 #include "message.h"\r
 #include "vvideolive.h"\r
+#include "vepgsettimer.h"\r
 \r
 class VVideoLive;\r
 \r
diff --git a/vepgsettimer.cc b/vepgsettimer.cc
new file mode 100644 (file)
index 0000000..7fdf590
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+    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 "vepgsettimer.h"
+
+VEpgSetTimer::VEpgSetTimer(Event* tevent, Channel* tchannel)
+{
+  viewman = ViewMan::getInstance();
+  vdr = VDR::getInstance();
+  logger = Log::getInstance();
+
+  event = tevent;
+  channel = tchannel;
+
+  create(400, 240);
+  if (Video::getInstance()->getFormat() == Video::PAL)
+  {
+    setScreenPos(150, 170);
+  }
+  else
+  {
+    setScreenPos(140, 140);
+  }
+
+  setBackgroundColour(Colour::VIEWBACKGROUND);
+  setTitleBarOn(1);
+  setTitleBarColour(Colour::TITLEBARBACKGROUND);
+  setBorderOn(true);
+  setTitleText(tr("Set Timer"));
+
+  buttonYes.setSurface(surface);
+  buttonNo.setSurface(surface);
+  buttonYes.setSurfaceOffset(80, 40 + (7 * surface->getFontHeight()));
+  buttonNo.setSurfaceOffset(220, 40 + (7 * surface->getFontHeight()));
+
+  buttonYes.setText(tr("Yes"));
+  buttonNo.setText(tr("No"));
+  buttonYes.setActive(1);
+  selectedOption = YES;
+
+  logger->log("VEPGST", Log::DEBUG, "Title: %s", event->title);
+  logger->log("VEPGST", Log::DEBUG, "Time: %lu", event->time);
+  logger->log("VEPGST", Log::DEBUG, "Duration: %lu", event->duration);
+  logger->log("VEPGST", Log::DEBUG, "Channel: %i", channel->number);
+}
+
+VEpgSetTimer::~VEpgSetTimer()
+{
+}
+
+char* VEpgSetTimer::genTimerString()
+{
+  // Allocate to return
+  char* timerString = new char[1024];
+
+  // Other
+  struct tm* btime;
+  int flags;
+  char dateString[20];
+  char startMargin[10];
+  time_t startTime;
+  char startString[10];
+  char endMargin[10];
+  time_t endTime;
+  char endString[10];
+  char priority[10];
+  char lifetime[10];
+  char* eventTitle;
+
+  flags = 1; // hard coded active timer flag
+
+  btime = localtime((time_t*)&event->time);
+  strftime(dateString, 19, "%Y-%m-%d", btime);
+
+  char* startMarginConfig = vdr->configLoad("Timers", "Start margin");
+  if (startMarginConfig)
+  {
+    strncpy(startMargin, startMarginConfig, 9);
+    delete[] startMarginConfig;
+  }
+  else strcpy(startMargin, "5");
+
+  startTime = event->time - (atoi(startMargin) * 60);
+  btime = localtime(&startTime);
+  strftime(startString, 9, "%H%M", btime);
+
+  char* endMarginConfig = vdr->configLoad("Timers", "End margin");
+  if (endMarginConfig)
+  {
+    strncpy(endMargin, endMarginConfig, 9);
+    delete[] endMarginConfig;
+  }
+  else strcpy(endMargin, "5");
+
+  endTime = event->time + event->duration + (atoi(endMargin) * 60);
+  btime = localtime(&endTime);
+  strftime(endString, 9, "%H%M", btime);
+
+  char* priorityConfig = vdr->configLoad("Timers", "Priority");
+  if (priorityConfig)
+  {
+    strncpy(priority, priorityConfig, 9);
+    delete[] priorityConfig;
+  }
+  else strcpy(priority, "99");
+
+  char* lifetimeConfig = vdr->configLoad("Timers", "Lifetime");
+  if (lifetimeConfig)
+  {
+    strncpy(lifetime, lifetimeConfig, 9);
+    delete[] lifetimeConfig;
+  }
+  else strcpy(lifetime, "99");
+
+  eventTitle = new char[strlen(event->title) + 1];
+  strcpy(eventTitle, event->title);
+  for(UINT i=0; i < strlen(eventTitle); i++) if (eventTitle[i] == ':') eventTitle[i] = '|';
+
+  snprintf(timerString, 1023, "%i:%lu:%s:%s:%s:%s:%s:%s:",
+    flags, channel->number, dateString,
+    startString, endString,
+    priority, lifetime, eventTitle);
+
+  delete[] eventTitle;
+
+  return timerString;
+}
+
+void VEpgSetTimer::swap()
+{
+  if (selectedOption == NO)
+  {
+    selectedOption = YES;
+    buttonYes.setActive(1);
+    buttonNo.setActive(0);
+  }
+  else if (selectedOption == YES)
+  {
+    selectedOption = NO;
+    buttonYes.setActive(0);
+    buttonNo.setActive(1);
+  }
+}
+
+void VEpgSetTimer::draw()
+{
+  View::draw();
+  drawPara(event->title, 10, 40, Colour::LIGHTTEXT);
+  drawText(channel->name, 10, 40 + (2 * surface->getFontHeight()), Colour::LIGHTTEXT);
+
+  char fullString[20];
+  time_t t;
+  struct tm* btime;
+  char timeString[10];
+  btime = localtime((time_t*)&event->time);
+  strftime(timeString, 9, "%0H:%0M - ", btime); // and format it as hh:mm -
+  strcpy(fullString, timeString); // put it in our buffer
+  t = event->time + event->duration; //get programme end time
+  btime = localtime(&t);
+  strftime(timeString, 9, "%0H:%0M", btime); // and format it as hh:mm -
+  strcat(fullString, timeString); // put it in our buffer
+
+  drawText(fullString, 10, 40 + (3 * surface->getFontHeight()), Colour::LIGHTTEXT);
+  drawText(tr("Create this timer?"), 10, 40 + (5 * surface->getFontHeight()), Colour::LIGHTTEXT);
+
+  buttonYes.draw();
+  buttonNo.draw();
+}
+
+int VEpgSetTimer::handleCommand(int command)
+{
+  switch(command)
+  {
+    case Remote::DF_LEFT:
+    case Remote::LEFT:
+    {
+      swap();
+      draw();
+      ViewMan::getInstance()->updateView(this);
+      return 2;
+    }
+    case Remote::DF_RIGHT:
+    case Remote::RIGHT:
+    {
+      swap();
+      draw();
+      ViewMan::getInstance()->updateView(this);
+      return 2;
+    }
+    case Remote::BACK:
+    {
+      return 4;
+    }
+    case Remote::OK:
+    {
+      if (selectedOption != YES) return 4;
+      doit();
+      return 4;
+    }
+  }
+
+  return 1;
+}
+
+
+void VEpgSetTimer::doit()
+{
+  char* timerString = genTimerString();
+  logger->log("VEPGST", Log::DEBUG, "%s", timerString);
+
+  ULONG ret = vdr->setEventTimer(timerString);
+  delete[] timerString;
+
+  if (ret == 0) logger->log("VEPGST", Log::DEBUG, "Success");
+  else if (ret == 1) logger->log("VEPGST", Log::DEBUG, "Fail: Timer already set for this event");
+  else if (ret == 2) logger->log("VEPGST", Log::DEBUG, "Fail: General failure setting timer");
+
+  VInfo* vi = new VInfo();
+  vi->create(400, 150);
+  vi->setExitable();
+  vi->setBorderOn(1);
+  vi->setTitleBarOn(0);
+
+  if (Video::getInstance()->getFormat() == Video::PAL)
+    vi->setScreenPos(170, 200);
+  else
+    vi->setScreenPos(160, 150);
+
+  if (ret == 0) vi->setOneLiner(tr("Timer set successfully"));
+  else if (ret == 1) vi->setOneLiner(tr("There is already a timer for this event"));
+  else if (ret == 2) vi->setOneLiner(tr("Failure setting timer"));
+  vi->draw();
+
+  Message* m = new Message();
+  m->message = Message::ADD_VIEW;
+  m->to = viewman;
+  m->parameter = (ULONG)vi;
+
+  viewman->postMessage(m);
+}
diff --git a/vepgsettimer.h b/vepgsettimer.h
new file mode 100644 (file)
index 0000000..01f05d4
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+    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 VEPGSETTIMER_H
+#define VEPGSETTIMER_H
+
+#include <time.h>
+#include "video.h"
+#include "view.h"
+#include "remote.h"
+#include "viewman.h"
+#include "vdr.h"
+#include "event.h"
+#include "channel.h"
+#include "i18n.h"
+#include "wbutton.h"
+#include "vinfo.h"
+#include "message.h"
+
+class VEpgSetTimer : public View
+{
+  public:
+    VEpgSetTimer(Event* event, Channel* channel);
+    ~VEpgSetTimer();
+
+    int handleCommand(int command);
+    void draw();
+
+  private:
+    Log* logger;
+    ViewMan* viewman;
+    VDR* vdr;
+
+    Event* event;
+    Channel* channel;
+
+    // This lot is borrowed from VQuestion
+    // A shame not to use it, but this view will probably get
+    // a whole load more controls on it some day
+    const static UCHAR NO = 0;
+    const static UCHAR YES = 1;
+
+    UCHAR selectedOption;
+
+    WButton buttonYes;
+    WButton buttonNo;
+
+    char* genTimerString();
+    void swap();
+    void doit();
+};
+
+#endif
diff --git a/view.h b/view.h
index 34bdca6b3aa62bdab82e27583beeb69073701f00..4da134f682eb3a6da2680998f436b9ebc27e2ebb 100644 (file)
--- a/view.h
+++ b/view.h
@@ -52,11 +52,11 @@ class View : public Box
     Colour backgroundColour;
 
     char* titleText;
-    UCHAR titleBarOn;
     UCHAR borderOn;
 
   protected:
     Colour titleBarColour;
+    UCHAR titleBarOn;
 };
 
 #endif
index a687c739a295582556171002af67ca2cfcebaa20..3760da736228fbf3ef303524ddcd8be23d2c9ebd 100644 (file)
--- a/vinfo.cc
+++ b/vinfo.cc
@@ -75,7 +75,8 @@ void VInfo::draw()
 
     if (mainTextType == ONELINER)
     {
-      drawTextCentre(mainText, area.w / 2, 75, Colour::LIGHTTEXT);
+      if (titleBarOn) drawTextCentre(mainText, area.w / 2, 75, Colour::LIGHTTEXT);
+      else drawTextCentre(mainText, area.w / 2, 55, Colour::LIGHTTEXT);
     }
   }
 }
diff --git a/voptionsmenu.cc b/voptionsmenu.cc
new file mode 100644 (file)
index 0000000..f0ef93b
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+    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 "voptionsmenu.h"
+
+VOptionsMenu::VOptionsMenu()
+{
+  viewman = ViewMan::getInstance();
+
+  create(460, 190);
+  if (Video::getInstance()->getFormat() == Video::PAL)
+  {
+    setScreenPos(140, 170);
+  }
+  else
+  {
+    setScreenPos(130, 140);
+  }
+
+  setBackgroundColour(Colour::VIEWBACKGROUND);
+  setTitleBarOn(1);
+  setTitleBarColour(Colour::TITLEBARBACKGROUND);
+  setTitleText(tr("Options"));
+
+  int fontHeight = surface->getFontHeight();
+
+  // Build gui
+  WButton* wb;
+
+  wb = new WButton();
+  wb->setText("General");
+  wb->setSurface(surface);
+  wb->setSurfaceOffset(160, 70);
+  wb->setDimensions(140, fontHeight);
+  wb->setTag(1);
+  buttons.push_back(wb);
+
+  wb = new WButton();
+  wb->setText("Timers");
+  wb->setSurface(surface);
+  wb->setSurfaceOffset(160, 110);
+  wb->setDimensions(140, fontHeight);
+  wb->setTag(2);
+  buttons.push_back(wb);
+
+  selectedButton = buttons.begin();
+  (*selectedButton)->setActive(1);
+}
+
+VOptionsMenu::~VOptionsMenu()
+{
+  while (!buttons.empty())
+  {
+    delete buttons.back();
+    buttons.pop_back();
+  }
+}
+
+void VOptionsMenu::draw()
+{
+  View::draw();
+
+  vector<WButton*>::iterator i;
+  for(i = buttons.begin(); i != buttons.end(); i++)
+  {
+    (*i)->draw();
+  }
+}
+
+int VOptionsMenu::handleCommand(int command)
+{
+  switch(command)
+  {
+    case Remote::DF_UP:
+    case Remote::UP:
+    {
+      if (selectedButton == buttons.begin()) return 2;
+      (*selectedButton)->setActive(0);
+      selectedButton--;
+      (*selectedButton)->setActive(1);
+      draw(); // fixme - just draw buttons
+      viewman->updateView(this);
+      return 2;
+    }
+    case Remote::DF_DOWN:
+    case Remote::DOWN:
+    {
+      if (selectedButton == (buttons.end() - 1)) return 2;
+      (*selectedButton)->setActive(0);
+      selectedButton++;
+      (*selectedButton)->setActive(1);
+      draw(); // fixme - just draw buttons
+      viewman->updateView(this);
+      return 2;
+    }
+    case Remote::BACK:
+    {
+      return 4;
+    }
+    case Remote::OK:
+    {
+      switch((*selectedButton)->getTag())
+      {
+        case 1: doGeneral();   break;
+        case 2: doTimers();    break;
+      }
+      return 2;
+    }
+  }
+
+  return 1;
+}
+
+void VOptionsMenu::processMessage(Message* m)
+{
+  if (m->message == Message::CHANGED_OPTIONS)
+  {
+    doApplyChanges((map<int,int>*)m->parameter);
+    viewman->removeView(this);
+  }
+}
+
+void VOptionsMenu::doApplyChanges(map<int,int>* changedOptions)
+{
+  Video* video = Video::getInstance();
+  map<int,int>::iterator i;
+
+  for(i = changedOptions->begin(); i != changedOptions->end(); i++)
+  {
+    printf("I FIRST = %i SECOND = %i\n", i->first, i->second);
+
+    switch(i->first)
+    {
+      case 1:
+      {
+        if (i->second == 1)
+        {
+          Log::getInstance()->log("Options", Log::DEBUG, "Setting New Remote");
+          Remote::getInstance()->setRemoteType(Remote::NEWREMOTE);
+        }
+        else
+        {
+          Log::getInstance()->log("Options", Log::DEBUG, "Setting Old Remote");
+          Remote::getInstance()->setRemoteType(Remote::OLDREMOTE);
+        }
+        break;
+      }
+      case 2:
+      {
+        I18n::initialize();
+        VWelcome::getInstance()->redrawLang();
+        break;
+      }
+      case 3:
+      {
+        if (i->second == 1)
+        {
+          Log::getInstance()->log("Options", Log::DEBUG, "Setting S-Video");
+          video->setConnection(Video::SVIDEO);
+        }
+        else
+        {
+          Log::getInstance()->log("Options", Log::DEBUG, "Setting RGB/Composite");
+          video->setConnection(Video::COMPOSITERGB);
+        }
+        break;
+      }
+      case 4:
+      {
+        if (i->second == 1)
+        {
+          Log::getInstance()->log("Options", Log::DEBUG, "Setting 16:9 TV");
+          video->setTVsize(Video::ASPECT16X9);
+        }
+        else
+        {
+          Log::getInstance()->log("Options", Log::DEBUG, "Setting 4:3 TV");
+          video->setTVsize(Video::ASPECT4X3);
+        }
+        break;
+      }
+      case 5:
+      {
+        if (i->second == 1)
+        {
+          Log::getInstance()->log("Options", Log::DEBUG, "Setting letterbox");
+          video->setMode(Video::LETTERBOX);
+        }
+        else
+        {
+          Log::getInstance()->log("Options", Log::DEBUG, "Setting chop-sides");
+          video->setMode(Video::NORMAL);
+        }
+        break;
+      }
+    }
+  }
+
+  delete changedOptions;
+
+}
+
+void VOptionsMenu::doGeneral()
+{
+  static const int numOptions = 8;
+
+  static const char* options1[] = {"Old", "New"};
+  static const char* options3[] = {"RGB+composite", "S-Video"};
+  static const char* options4[] = {"4:3", "16:9"};
+  static const char* options5[] = {"Chop sides", "Letterbox"};
+  static const char* options6[] = {"On", "Off", "Last state"};
+  static const char* options7[] = {"All", "FTA only"};
+
+  const static OPTIONDATA optionData[numOptions] =
+  {
+    {1, "Remote control type",      "General", "Remote type",      OPTIONTYPE_TEXT, 2, 0, 0, options1 },
+    {2, "Language",                 "General", "Language",         OPTIONTYPE_TEXT, I18n::NumLanguages, 0, 0, I18n::Languages },
+    {3, "TV connection type",       "TV",      "Connection",       OPTIONTYPE_TEXT, 2, 0, 0, options3 },
+    {4, "TV aspect ratio",          "TV",      "Aspect",           OPTIONTYPE_TEXT, 2, 0, 0, options4 },
+    {5, "16:9 on 4:3 display mode", "TV",      "Widemode",         OPTIONTYPE_TEXT, 2, 0, 0, options5 },
+    {6, "Power state after bootup", "General", "Power After Boot", OPTIONTYPE_TEXT, 3, 0, 0, options6 },
+    {7, "Display channels",         "General", "Channels",         OPTIONTYPE_TEXT, 2, 0, 0, options7 },
+    {8, "VDR-Pri 0=OK !See forums!","General", "Live priority",    OPTIONTYPE_INT,  100, 0, 0, NULL }
+  };
+
+  // As all the above data is const static, it can be sent to the new View, this stack frame can
+  // quit and the pointers will all still be valid. I think. (Hope).
+
+  VOptions* v = new VOptions(this, "General Options", optionData, numOptions);
+  v->draw();
+  viewman->add(v);
+  viewman->updateView(v);
+}
+
+
+void VOptionsMenu::doTimers()
+{
+  static const int numOptions = 4;
+
+  const static OPTIONDATA optionData[numOptions] =
+  {
+    {9, "Default start margin (minutes)", "Timers", "Start margin",  OPTIONTYPE_INT, 20, 5, 0, NULL },
+    {10, "Default end margin (minutes)",   "Timers", "End margin",    OPTIONTYPE_INT, 20, 5, 0, NULL },
+    {11, "Default priority",               "Timers", "Priority",      OPTIONTYPE_INT, 100, 99, 0, NULL },
+    {12, "Default lifetime",               "Timers", "Lifetime",      OPTIONTYPE_INT, 100, 99, 0, NULL }
+  };
+
+  // As all the above data is const static, it can be sent to the new View, this stack frame can
+  // quit and the pointers will all still be valid. I think. (Hope).
+
+  VOptions* v = new VOptions(this, "Timer Options", optionData, numOptions);
+  v->draw();
+  viewman->add(v);
+  viewman->updateView(v);
+}
diff --git a/voptionsmenu.h b/voptionsmenu.h
new file mode 100644 (file)
index 0000000..fb1cf08
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+    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 VOPTIONSMENU_H
+#define VOPTIONSMENU_H
+
+#include <vector>
+#include <map>
+#include "view.h"
+#include "remote.h"
+#include "viewman.h"
+#include "vdr.h"
+#include "colour.h"
+#include "video.h"
+#include "wbutton.h"
+#include "i18n.h"
+#include "vwelcome.h"
+#include "voptions.h"
+
+class VOptionsMenu : public View
+{
+  public:
+    VOptionsMenu();
+    ~VOptionsMenu();
+
+    int handleCommand(int command);
+    void processMessage(Message* m);
+    void draw();
+
+  private:
+    void doGeneral();
+    void doTimers();
+    void doApplyChanges(map<int,int>* changedOptions);
+
+    VDR* vdr;
+    ViewMan* viewman;
+
+    vector<WButton*> buttons;
+    vector<WButton*>::iterator selectedButton;
+};
+
+#endif
index 306704fa33f884546a32fcc0153db3647976d017..ac7c823d3d6d8c46dc818fae4ec56bbd7aeef988 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <time.h>
 #include <vector>
 
 #include "view.h"