]> git.vomp.tv Git - vompclient.git/commitdiff
Select list upgrade, gui and backend support to move recordings
authorChris Tallon <chris@vomp.tv>
Mon, 15 May 2006 22:07:31 +0000 (22:07 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 15 May 2006 22:07:31 +0000 (22:07 +0000)
between directories

28 files changed:
Makefile
command.cc
event.cc
event.h
message.h
recman.cc
recman.h
rectimer.cc
rectimer.h
vchannellist.cc
vdr.cc
vdr.h
vepg.cc
viewman.cc
vlivebanner.cc
vrecmove.cc [new file with mode: 0644]
vrecmove.h [new file with mode: 0644]
vrecordinglist.cc
vrecordinglist.h
vrecordingmenu.cc
vrecordingmenu.h
vserverselect.cc
vtimerlist.cc
vwelcome.cc
wselectlist.cc
wselectlist.h
wsymbol.cc
wsymbol.h

index 4213a86c3cc8d1813f2f0c7b80a36add5021e66e..2086636a9d3249e4cbae8aeb64c5805b05eafa65 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ OBJECTS1 = main.o command.o log.o tcp.o dsock.o thread.o timers.o i18n.o
            vinfo.o vwallpaper.o vvolume.o vrecordinglist.o vlivebanner.o vmute.o       \
            vtimerlist.o vtimeredit.o voptionsmenu.o vrecordingmenu.o vquestion.o       \
            vchannellist.o vwelcome.o vvideolive.o vvideorec.o vepgsettimer.o           \
-           vchannelselect.o vserverselect.o vconnect.o voptions.o vepg.o               \
+           vchannelselect.o vserverselect.o vconnect.o voptions.o vepg.o vrecmove.o    \
            widget.o wselectlist.o wjpeg.o wsymbol.o wbutton.o woptionbox.o wtextbox.o  \
            fonts/helvB24.o fonts/helvB18.o                                             \
            remote.o led.o mtd.o video.o audio.o osd.o surface.o
index 38560baa0cb870d985ce9af2db9c65ac4cd761e6..6a9ac67c173cef3a067501f5fd5298c5be2e8961 100644 (file)
@@ -683,5 +683,10 @@ void Command::doJustConnected(VConnect* vconnect)
 //    handleCommand(Remote::SKIPFORWARD);
 //    handleCommand(Remote::OK);
 //    handleCommand(Remote::PLAY);
+//    handleCommand(Remote::OK);
+//    handleCommand(Remote::DOWN);
+//    handleCommand(Remote::DOWN);
+//    handleCommand(Remote::DOWN);
+//    handleCommand(Remote::OK);
   }
 }
index e37a0f638b513645460b6bb8484fd46c6a388a01..b08a784f085ef34322b2f363a550bdcb915faed2 100644 (file)
--- a/event.cc
+++ b/event.cc
@@ -29,8 +29,6 @@ Event::Event()
   title = NULL;
   subtitle = NULL;
   description = NULL;
-
-  index = -1;
 }
 
 Event::~Event()
diff --git a/event.h b/event.h
index 63ab88f23593a6b1d4f680fff7b57c2578f26be0..05b6d4750e822934a210e5a94a46f8802a7bf82a 100644 (file)
--- a/event.h
+++ b/event.h
@@ -43,9 +43,6 @@ class Event
     char* title;
     char* subtitle;
     char* description;
-
-    int index;
-
 };
 
 class EventSorter
index f16262eaeca7e8055f9d201f90396ed06b50fd94..c1a9f0e0f32e84132932860ec9ce024058a4b088 100644 (file)
--- a/message.h
+++ b/message.h
@@ -62,6 +62,7 @@ class Message
     const static ULONG EPG_CLOSE = 17;
     const static ULONG CHANGED_OPTIONS = 18;
     const static ULONG CONNECTION_LOST = 19;
+    const static ULONG MOVE_RECORDING = 20;
 };
 
 #endif
index e8c9d1506d77f209373918c0ba27afa292005419..1850ffe1fd68d918480ae5973233b0c6fdbf52ef 100644 (file)
--- a/recman.cc
+++ b/recman.cc
@@ -148,6 +148,43 @@ int RecMan::deleteRecording(Recording* rec)
   return success;
 }
 
+void RecMan::constructPath(char* target, Directory* dir)
+{
+  if (dir->parent)
+  {
+    constructPath(target, dir->parent);
+    strcat(target, dir->name);
+    strcat(target, "/");
+  }
+}
+
+int RecMan::moveRecording(Recording* toMove, Directory* toDir)
+{
+  char newPath[PATH_MAX];
+  strcpy(newPath, "/");
+  constructPath(&newPath[1], toDir);
+  int success = 0;
+
+  for(RecordingList::iterator i = currentDir->recList.begin(); i != currentDir->recList.end(); i++)
+  {
+    if (*i == toMove)
+    {
+      success = VDR::getInstance()->moveRecording(toMove->getFileName(), newPath);
+      //success = 1;
+      if (success == 1)
+      {
+        currentDir->recList.erase(i);
+        toDir->recList.push_back(toMove);
+        toDir->sort();
+      }
+      break;
+    }
+  }
+
+
+  return success;
+}
+
 bool RecMan::isSubDir()
 {
   return (currentDir != rootDir);
@@ -207,3 +244,8 @@ RecordingList* RecMan::getRecordings()
 {
   return &currentDir->recList;
 }
+
+Directory* RecMan::getRootDir()
+{
+  return rootDir;
+}
index 915cb1d1b2113630058cbc4d5a22932d1054fda6..81a01d702b4f121af0c0b5ea56ac67e3fd6cae68 100644 (file)
--- a/recman.h
+++ b/recman.h
@@ -35,6 +35,9 @@ class RecMan
     void setStats(ULONG totalSpace, ULONG freeSpace, ULONG usedPercent);
     void addEntry(ULONG startTime, char* name, char* filename); // modifies name
     int deleteRecording(Recording* rec);
+    int moveRecording(Recording* toMove, Directory* toDir);
+
+    Directory* getRootDir();
 
     // State functions
     bool isSubDir();
@@ -55,6 +58,8 @@ class RecMan
 
     Directory* rootDir;
     Directory* currentDir;
+
+    void constructPath(char* target, Directory* dir) ;
 };
 
 #endif
index 34843df29ec80dbfa2e10c0e7b60ad85eaf88b17..b550e10e84ba06e25b82aec3f4599d7e26f7a014 100644 (file)
@@ -33,7 +33,7 @@ RecTimer::RecTimer()
 
   file = NULL;
 
-  index = -1;
+//  index = -1;
   directory = NULL;
   name = NULL;
 }
index fa53e210027df93712270fa201e2c586de5b0a58..cb5cfcd4d70fdbc91071f8e2d37b14a19d8c3812 100644 (file)
@@ -46,7 +46,7 @@ class RecTimer
     ULONG startTime;
     ULONG stopTime;
 
-    int index;
+//    int index;
 
     bool operator< (const RecTimer& op2);
 
index eca6ae12882360ec2a7f53fa3fa14a06ecb9be1a..9da042d13f936ddd779a73ef27520f5e176eab28 100644 (file)
@@ -82,7 +82,7 @@ void VChannelList::setList(ChannelList* tlist)
     {
       chan = (*chanList)[i];
       sprintf(str, "%lu\t%s", chan->number, chan->name);
-      chan->index = sl.addOption(str, first);
+      chan->index = sl.addOption(str, (ULONG)chan, first);
       first = 0;
     }
   }
@@ -193,17 +193,7 @@ int VChannelList::handleCommand(int command)
     case Remote::PLAY:
     {
       Channel* chan = NULL;
-      if (chanList)
-      {
-        int currentOption = sl.getCurrentOption();
-
-        for (UINT i = 0; i < chanList->size(); i++)
-        {
-          chan = (*chanList)[i];
-          if (currentOption == chan->index) break;
-        }
-      }
-
+      if (chanList) chan = (Channel*)sl.getCurrentOptionData();
       if (chan == NULL) return 2;
 
       VVideoLive* v = new VVideoLive(chanList, chan->type, this);
diff --git a/vdr.cc b/vdr.cc
index 7ec9857251df2f39caf1e109350a78ba826035d8..b89e58d76a0999530c98d84d56f25f0c0c17c44f 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -410,6 +410,42 @@ int VDR::deleteRecording(char* fileName)
   return toReturn;
 }
 
+int VDR::moveRecording(char* fileName, char* newPath)
+{
+  unsigned long totalLength = 8 + strlen(fileName) + 1 + strlen(newPath) + 1;
+  UCHAR* buffer = new UCHAR[totalLength];
+
+  *(unsigned long*)&buffer[0] = htonl(totalLength - 4);
+  *(unsigned long*)&buffer[4] = htonl(VDR_MOVERECORDING);
+  strcpy((char*)&buffer[8], fileName);
+  strcpy((char*)&buffer[8 + strlen(fileName) + 1], newPath);
+
+  MUTEX_LOCK(&mutex);
+  if (!connected) { MUTEX_UNLOCK(&mutex); return 0; }
+
+  unsigned int a = tcp->sendPacket(buffer, totalLength);
+  delete []buffer;
+
+  if (a != totalLength)
+  {
+    disconnect();
+    MUTEX_UNLOCK(&mutex);
+    return 0;
+  }
+
+  if (!getPacket())
+  {
+    MUTEX_UNLOCK(&mutex);
+    return 0;
+  }
+
+  int toReturn = (int)extractULONG();
+  freePacket();
+  MUTEX_UNLOCK(&mutex);
+
+  return toReturn;
+}
+
 char* VDR::getRecordingSummary(char* fileName)
 {
   unsigned long totalLength = 8 + strlen(fileName) + 1;
diff --git a/vdr.h b/vdr.h
index 228acdc737031c38d06c4a3cbb6758dd76cb07d2..c1aa880b82b6dc7604a92f3b1edfbe76a50c4e07 100644 (file)
--- a/vdr.h
+++ b/vdr.h
@@ -116,6 +116,7 @@ class VDR
     bool       getRecordingsList(RecMan* recman);
     char*      getRecordingSummary(char* fileName);
     int        deleteRecording(char* fileName);
+    int        moveRecording(char* fileName, char* newPath);
     ULLONG     streamRecording(char* fileName);
     ULLONG     rescanRecording();
     ULLONG     positionFromFrameNumber(ULONG frameNumber);
@@ -175,6 +176,7 @@ class VDR
     const static ULONG VDR_SETTIMER            = 15;
     const static ULONG VDR_POSFROMFRAME        = 16;
     const static ULONG VDR_FRAMEFROMPOS        = 17;
+    const static ULONG VDR_MOVERECORDING       = 18;
 
     int  getPacket();
     void freePacket();
diff --git a/vepg.cc b/vepg.cc
index afeb6d33fffc0b5a32ea345a7c3f03fc62080513..94ad220b71baeac1830fc38dcfa1cbece3badb5b 100644 (file)
--- a/vepg.cc
+++ b/vepg.cc
@@ -127,7 +127,7 @@ VEpg::VEpg(VVideoLive* v, UINT currentChannel)
       chan = (*chanList)[i];\r
       if (i == currentChannel)\r
         first = 1;\r
-      chan->index = chanListbox.addOption(chan->name, first);\r
+      chan->index = chanListbox.addOption(chan->name, 0, first);\r
       first = 0;\r
     }\r
     chanName.setText((*chanList)[chanListbox.getCurrentOption()]->name);
index cd6cc3738cbef64a3a7d3f64aed188ecc23e51ea..8ac891e0c13f43ccc425420d7dba1424d013cc37 100644 (file)
@@ -406,7 +406,7 @@ void ViewMan::processMessage(Message* m)
     {
       if (views[i] == m->to)
       {
-        Log::getInstance()->log("ViewMan", Log::DEBUG, "sending message to view %p %p %lu", m->from, m->to, m->message);
+        Log::getInstance()->log("ViewMan", Log::DEBUG, "sending message from view %p to view %p %lu", m->from, m->to, m->message);
         views[i]->processMessage(m);
         return;
       }
index 63d9a221561f2eecf085e1024c5c7a7faf2e6141..fe2269d8684c47cfa510e8b100c5602ac71000bf 100644 (file)
@@ -100,7 +100,7 @@ void VLiveBanner::setChannel(Channel* tChannel)
 
   if (!eventList)
   {
-    sl.addOption(tr("No channel data available"), 1);
+    sl.addOption(tr("No channel data available"), 0, 1);
   }
   else
   {
@@ -123,7 +123,7 @@ void VLiveBanner::setChannel(Channel* tChannel)
     strftime(tempString2, 299, "%H:%M ", btime);
 #endif
       SNPRINTF(tempString, 299, "%s %s", tempString2, event->title);
-      event->index = sl.addOption(tempString, first);
+      sl.addOption(tempString, (ULONG)event, first);
       first = 0;
     }
   }
@@ -207,42 +207,32 @@ int VLiveBanner::handleCommand(int command)
     case Remote::MENU:
     {
       if (!eventList) return 2;
-      Event* event;
-      int eventListSize = eventList->size();
-      for(int i = 0; i < eventListSize; i++)
+      Event* event = (Event*)sl.getCurrentOptionData();
+      Log::getInstance()->log("VLiveBanner", Log::DEBUG, "Found the option you pointed at. %s", event->title);
+      // First, cancel my delete timer
+      Timers::getInstance()->cancelTimer(this, 1); // if it exists
+
+      VInfo* vi = new VInfo();
+      vi->setTitleText(event->title);
+      vi->setBorderOn(1);
+      vi->setExitable();
+      if (event->description) vi->setMainText(event->description);
+      else vi->setMainText(tr("Summary unavailable"));
+      if (Video::getInstance()->getFormat() == Video::PAL)
+      {
+        vi->setScreenPos(120, 130);
+      }
+      else
       {
-        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
-          Timers::getInstance()->cancelTimer(this, 1); // if it exists
-
-          VInfo* vi = new VInfo();
-          vi->setTitleText(event->title);
-          vi->setBorderOn(1);
-          vi->setExitable();
-          if (event->description) vi->setMainText(event->description);
-          else vi->setMainText(tr("Summary unavailable"));
-          if (Video::getInstance()->getFormat() == Video::PAL)
-          {
-            vi->setScreenPos(120, 130);
-          }
-          else
-          {
-            vi->setScreenPos(110, 90);
-          }
-          vi->create(510, 270);
-          vi->draw();
-
-          ViewMan::getInstance()->add(vi);
-          ViewMan::getInstance()->updateView(vi);
-
-          return 2;
-
-        }
+        vi->setScreenPos(110, 90);
       }
-      return 2; // should not get here
+      vi->create(510, 270);
+      vi->draw();
+
+      ViewMan::getInstance()->add(vi);
+      ViewMan::getInstance()->updateView(vi);
+
+      return 2;
     }
     case Remote::GUIDE:
     case Remote::RED:
diff --git a/vrecmove.cc b/vrecmove.cc
new file mode 100644 (file)
index 0000000..b34322a
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+    Copyright 2006 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 "vrecmove.h"
+
+VRecMove::VRecMove(RecMan* trecman)
+{
+  recman = trecman;
+
+  create(260, 210);
+  if (Video::getInstance()->getFormat() == Video::PAL)
+  {
+    setScreenPos(220, 160);
+  }
+  else
+  {
+    setScreenPos(210, 130);
+  }
+
+  setBackgroundColour(Colour::VIEWBACKGROUND);
+  setTitleBarOn(1);
+  setBorderOn(1);
+  setTitleText(tr("Move recording"));
+  setTitleBarColour(Colour::TITLEBARBACKGROUND);
+
+  sl.setSurface(surface);
+  sl.setSurfaceOffset(10, 30 + 5);
+  sl.setDimensions(area.w - 40, area.h - 30 - 15);
+
+  Directory* dir = recman->getRootDir();
+  sl.addOption("/", (ULONG)dir, 1);
+  addDirs(dir, "");
+}
+
+VRecMove::~VRecMove()
+{
+}
+
+void VRecMove::setParent(View* tparent)
+{
+  parent = tparent;
+}
+
+void VRecMove::addDirs(Directory* dir, char* prefix)
+{
+  Directory* currentDir;
+  for(DirectoryList::iterator i = dir->dirList.begin(); i != dir->dirList.end(); i++)
+  {
+    currentDir = *i;
+    char* title = new char[strlen(prefix) + strlen(currentDir->name) + 2]; // one for the null, one for '/'
+    sprintf(title, "%s%s", prefix, currentDir->name);
+    sl.addOption(title, (ULONG)currentDir, 0);
+
+    strcat(title, "/");
+    addDirs(*i, title);
+    delete[] title;
+  }
+}
+
+void VRecMove::draw()
+{
+  View::draw();
+  sl.draw();
+
+  rectangle(area.w - 30, 30 + 5, 20, area.h - 30 - 15, Colour::VIEWBACKGROUND);
+  WSymbol w;
+  w.setSurface(surface);
+
+  w.nextSymbol = WSymbol::SMALLUP;
+  w.setSurfaceOffset(area.w - 28, 30 + 7);
+  w.draw();
+
+  w.nextSymbol = WSymbol::SMALLDOWN;
+  w.setSurfaceOffset(area.w - 28, area.h - 26);
+  w.draw();
+}
+
+int VRecMove::handleCommand(int command)
+{
+  switch(command)
+  {
+    case Remote::DF_UP:
+    case Remote::UP:
+    {
+      sl.up();
+      sl.draw();
+      ViewMan::getInstance()->updateView(this);
+      return 2;
+    }
+    case Remote::DF_DOWN:
+    case Remote::DOWN:
+    {
+      sl.down();
+      sl.draw();
+      ViewMan::getInstance()->updateView(this);
+      return 2;
+    }
+    case Remote::OK:
+    {
+      Message* m = new Message();
+      m->message = Message::MOVE_RECORDING;
+      m->to = parent;
+      m->parameter = sl.getCurrentOptionData();
+      ViewMan::getInstance()->postMessage(m);
+
+      return 4;
+    }
+    case Remote::BACK:
+    {
+      return 4;
+    }
+  }
+  // stop command getting to any more views
+  return 1;
+}
diff --git a/vrecmove.h b/vrecmove.h
new file mode 100644 (file)
index 0000000..816522a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+    Copyright 2006 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 VRECMOVE_H
+#define VRECMOVE_H
+
+#include <stdio.h>
+#include <string.h>
+
+#include "defines.h"
+#include "view.h"
+#include "recording.h"
+#include "wselectlist.h"
+#include "remote.h"
+#include "vinfo.h"
+#include "colour.h"
+#include "video.h"
+#include "i18n.h"
+#include "command.h"
+#include "directory.h"
+#include "message.h"
+#include "viewman.h"
+
+class VRecMove : public View
+{
+  public:
+    VRecMove(RecMan* recman);
+    ~VRecMove();
+    void setParent(View* parent);
+
+    int handleCommand(int command);
+    void draw();
+
+  private:
+    View* parent;
+    RecMan* recman;
+    WSelectList sl;
+    void addDirs(Directory* dir, char* prefix);
+};
+
+#endif
index ed1c04310cd3c88871fbc548f2523a45484a899f..dd6ae8d2e9e8570aabdb727b59784b5388ca4e76 100644 (file)
@@ -72,7 +72,7 @@ void VRecordingList::drawData(bool doIndexPop)
   {
     currentSubDir = *i;
     SNPRINTF(tempA, 299, tr("<dir> %lu\t%s"), currentSubDir->getNumRecordings(), currentSubDir->name);
-    currentSubDir->index = sl.addOption(tempA, first);
+    currentSubDir->index = sl.addOption(tempA, 0, first);
     first = 0;
   }
 
@@ -92,7 +92,7 @@ void VRecordingList::drawData(bool doIndexPop)
     strftime(tempA, 299, "%d/%m %H:%M ", btime);
 #endif
     sprintf(tempB, "%s\t%s", tempA, currentRec->getProgName());
-    currentRec->index = sl.addOption(tempB, first);
+    currentRec->index = sl.addOption(tempB, 0, first);
     first = 0;
   }
 
@@ -193,6 +193,13 @@ void VRecordingList::processMessage(Message* m)
     return;
   }
 
+  if (m->message == Message::MOVE_RECORDING)
+  {
+    Log::getInstance()->log("VRecordingList", Log::DEBUG, "Doing move recording");
+    doMoveRecording((Directory*)m->parameter);
+    return;
+  }
+
   if (m->message == Message::PLAY_SELECTED_RECORDING)
   {
     doPlay();
@@ -210,39 +217,77 @@ void VRecordingList::doDeleteSelected()
 {
   Recording* toDelete = getCurrentOptionRecording();
 
-  if (toDelete)
+  if (!toDelete) return;
+
+  Log::getInstance()->log("VRecordingList", Log::DEBUG, "FOUND: %i %s %s", toDelete->index, toDelete->getProgName(), toDelete->getFileName());
+
+  int success = recman->deleteRecording(toDelete);
+  if (!VDR::getInstance()->isConnected())
   {
-    Log::getInstance()->log("VRecordingList", Log::DEBUG, "FOUND: %i %s %s", toDelete->index, toDelete->getProgName(), toDelete->getFileName());
+    Command::getInstance()->connectionLost();
+    return;
+  }
 
-    int success = recman->deleteRecording(toDelete);
-    if (!VDR::getInstance()->isConnected())
-    {
-      Command::getInstance()->connectionLost();
-      return;
-    }
+  if (success != 1)
+  {
+    VInfo* vi = new VInfo();
+    vi->create(360, 200);
+    if (Video::getInstance()->getFormat() == Video::PAL)
+      vi->setScreenPos(190, 170);
+    else
+      vi->setScreenPos(180, 120);
+    vi->setOneLiner(tr("Failed to delete recording"));
+    vi->setExitable();
+    vi->setBorderOn(1);
+    vi->setTitleBarColour(Colour::DANGER);
+    vi->okButton();
+    vi->draw();
+    viewman->add(vi);
+    viewman->updateView(vi);
+  }
+  else
+  {
+    draw();
+    viewman->updateView(this);
+  }
 
-    if (success != 1)
-    {
-      VInfo* vi = new VInfo();
-      vi->create(360, 200);
-      if (Video::getInstance()->getFormat() == Video::PAL)
-        vi->setScreenPos(190, 170);
-      else
-        vi->setScreenPos(180, 120);
-      vi->setOneLiner(tr("Failed to delete recording"));
-      vi->setExitable();
-      vi->setBorderOn(1);
-      vi->setTitleBarColour(Colour::DANGER);
-      vi->okButton();
-      vi->draw();
-      viewman->add(vi);
-      viewman->updateView(vi);
-    }
+}
+
+void VRecordingList::doMoveRecording(Directory* toDir)
+{
+  Recording* toMove = getCurrentOptionRecording();
+  if (!toMove || !toDir) return;
+
+  Log::getInstance()->log("VRecordingList", Log::DEBUG, "MOVE: %s %s", toMove->getProgName(), toDir->name);
+
+  int success = recman->moveRecording(toMove, toDir);
+  if (!VDR::getInstance()->isConnected())
+  {
+    Command::getInstance()->connectionLost();
+    return;
+  }
+
+  if (success != 1)
+  {
+    VInfo* vi = new VInfo();
+    vi->create(360, 200);
+    if (Video::getInstance()->getFormat() == Video::PAL)
+      vi->setScreenPos(190, 170);
     else
-    {
-      draw();
-      viewman->updateView(this);
-    }
+      vi->setScreenPos(180, 120);
+    vi->setOneLiner(tr("Failed to move recording"));
+    vi->setExitable();
+    vi->setBorderOn(1);
+    vi->setTitleBarColour(Colour::DANGER);
+    vi->okButton();
+    vi->draw();
+    viewman->add(vi);
+    viewman->updateView(vi);
+  }
+  else
+  {
+    draw();
+    viewman->updateView(this);
   }
 }
 
@@ -373,7 +418,7 @@ int VRecordingList::handleCommand(int command)
       {
         Log::getInstance()->log("VRecordingList", Log::DEBUG, "Found the option you pointed at. %s %s", current->getProgName(), current->getFileName());
 
-        VRecordingMenu* v = new VRecordingMenu();
+        VRecordingMenu* v = new VRecordingMenu(recman);
         v->setParent(this);
         v->setRecording(current);
         v->draw();
index 45d920eceb97eeba9a0fd27456c1ec215667f55c..7f3bdebc3452babee4b8a3281f0dadefbf97b242 100644 (file)
@@ -68,6 +68,7 @@ class VRecordingList : public View
     void doDeleteSelected();
     int doPlay();
     int doResume();
+    void doMoveRecording(Directory* toDir);
     Recording* getCurrentOptionRecording();
 
     stack<int> slIndexStack;
index 22533aad8bd581127227dbf3aba90464ea5755aa..9f3ad61f8121308cda887bd967296e696c57f1af 100644 (file)
 
 #include "vrecordingmenu.h"
 
-VRecordingMenu::VRecordingMenu()
+VRecordingMenu::VRecordingMenu(RecMan* trecman)
 {
   rec = NULL;
+  recman = trecman;
 
-  create(200, 140);
+  create(200, 164);
   if (Video::getInstance()->getFormat() == Video::PAL)
   {
     setScreenPos(260, 190);
@@ -43,10 +44,11 @@ VRecordingMenu::VRecordingMenu()
   sl.setSurface(surface);
   sl.setSurfaceOffset(10, 30 + 5);
   sl.setDimensions(area.w - 20, area.h - 30 - 15);
-  sl.addOption(tr("Play"), 1);
-  sl.addOption(tr("Resume"), 0);
-  sl.addOption(tr("Summary"), 0);
-  sl.addOption(tr("Delete"), 0);
+  sl.addOption(tr("Play"), 1, 1);
+  sl.addOption(tr("Resume"), 2, 0);
+  sl.addOption(tr("Summary"), 3, 0);
+  sl.addOption(tr("Move"), 4, 0);
+  sl.addOption(tr("Delete"), 5, 0);
 }
 
 VRecordingMenu::~VRecordingMenu()
@@ -91,7 +93,7 @@ int VRecordingMenu::handleCommand(int command)
     }
     case Remote::OK:
     {
-      if (sl.getCurrentOption() == 0)
+      if (sl.getCurrentOptionData() == 1)
       {
         Message* m = new Message(); // Must be done after this view deleted
         m->from = this;
@@ -101,7 +103,7 @@ int VRecordingMenu::handleCommand(int command)
         return 4;
       }
 
-      if (sl.getCurrentOption() == 1)
+      if (sl.getCurrentOptionData() == 2)
       {
         Message* m = new Message(); // Must be done after this view deleted
         m->from = this;
@@ -111,7 +113,7 @@ int VRecordingMenu::handleCommand(int command)
         return 4;
       }
 
-      if (sl.getCurrentOption() == 2)
+      if (sl.getCurrentOptionData() == 3)
       {
         char* summary = VDR::getInstance()->getRecordingSummary(rec->getFileName());
         if (!summary && !VDR::getInstance()->isConnected())
@@ -143,7 +145,18 @@ int VRecordingMenu::handleCommand(int command)
 
         return 2;
       }
-      else if (sl.getCurrentOption() == 3)
+
+      if (sl.getCurrentOptionData() == 4)
+      {
+        VRecMove* vrm = new VRecMove(recman);
+        vrm->setParent(this);
+        vrm->draw();
+        ViewMan::getInstance()->add(vrm);
+        ViewMan::getInstance()->updateView(vrm);
+        return 2;
+      }
+
+      if (sl.getCurrentOptionData() == 5)
       {
         VQuestion* v = new VQuestion(this);
         v->create(260, 180);
@@ -197,4 +210,19 @@ void VRecordingMenu::processMessage(Message* m)
       ViewMan::getInstance()->postMessage(m2);
     }
   }
+  else if (m->message == Message::MOVE_RECORDING)
+  {
+    Message* m2 = new Message(); // Delete self
+    m2->from = this;
+    m2->to = ViewMan::getInstance();
+    m2->message = Message::CLOSE_ME;
+    ViewMan::getInstance()->postMessage(m2);
+
+    m2 = new Message();
+    m2->from = this;
+    m2->to = vRecList;
+    m2->message = Message::MOVE_RECORDING;
+    m2->parameter = m->parameter;
+    ViewMan::getInstance()->postMessage(m2);
+  }
 }
index a72e2b06a6040fe519adc47967cf47caa84f848b..54c5fa1d77d3cd51e3888a1c50c5643753cb2a77 100644 (file)
 #include "video.h"
 #include "i18n.h"
 #include "command.h"
+#include "vrecmove.h"
 
 class VRecordingList;
 
 class VRecordingMenu : public View
 {
   public:
-    VRecordingMenu();
+    VRecordingMenu(RecMan* recman);
     ~VRecordingMenu();
     void setParent(VRecordingList* tvRecList);
     void setRecording(Recording* rec);
@@ -53,7 +54,7 @@ class VRecordingMenu : public View
     void draw();
 
   private:
-
+    RecMan* recman;
     WSelectList sl;
     VRecordingList* vRecList;
     Recording* rec;
index f6bfb5cb9dd340ab332e70cf22a897b238ceda44..f5bae8179dd24e3921d18c57276cda7008228f5d 100644 (file)
@@ -46,10 +46,10 @@ VServerSelect::VServerSelect(vector<VDRServer>& servers, void* treplyTo)
   sl.setSurfaceOffset(10, 30 + 5);
   sl.setDimensions(area.w - 20, area.h - 30 - 15);
 
-  sl.addOption(servers[0].name, 1);
+  sl.addOption(servers[0].name, 0, 1);
   for(UINT k = 1; k < servers.size(); k++)
   {
-    sl.addOption(servers[k].name, 0);
+    sl.addOption(servers[k].name, 0, 0);
   }
 
   replyTo = treplyTo;
index 4d46d97e2a204b219df632d405882edf65066caf..c1e25572c7ba6be23f81e0fa6f30a78ac5126cd7 100644 (file)
@@ -126,7 +126,7 @@ void VTimerList::insertData()
     btime = localtime((time_t*)&recTimer->startTime);
     strftime(strA, 299, "%d/%m %H:%M ", btime);
     SNPRINTF(strB, 299, "%s\t%s", strA, recTimer->getName());
-    recTimer->index = sl.addOption(strB, first);
+    sl.addOption(strB, (ULONG)recTimer, first);
     first = 0;
   }
 }
@@ -258,16 +258,16 @@ int VTimerList::handleCommand(int command)
     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 (recTimerList) recTimer = (RecTimer*)sl.getCurrentOptionData();
+//      {
+//        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;
 
index fe41d73cce58a64fd294c9fcb971625a63fb3f63..60d322be97fbcd53e2c4eccd9b9bb5e9551ae1ca 100644 (file)
@@ -72,12 +72,12 @@ void VWelcome::setup()
 {
   sl.clear();
   setTitleText(tr("Welcome"));
-  sl.addOption(tr("1. Live TV"), 1);
-  sl.addOption(tr("2. Radio"), 0);
-  sl.addOption(tr("3. Recordings"), 0);
-  sl.addOption(tr("4. Timers"), 0);
-  sl.addOption(tr("5. Options"), 0);
-  sl.addOption(tr("6. Reboot"), 0);
+  sl.addOption(tr("1. Live TV"), 1, 1);
+  sl.addOption(tr("2. Radio"), 2, 0);
+  sl.addOption(tr("3. Recordings"), 3, 0);
+  sl.addOption(tr("4. Timers"), 4, 0);
+  sl.addOption(tr("5. Options"), 5, 0);
+  sl.addOption(tr("6. Reboot"), 6, 0);
 }
 
 void VWelcome::draw()
@@ -166,33 +166,33 @@ int VWelcome::handleCommand(int command)
     }
     case Remote::OK:
     {
-      int option = sl.getCurrentOption();
-      if (option == 0)
+      ULONG option = sl.getCurrentOptionData();
+      if (option == 1)
       {
         doChannelsList();
         return 2;
       }
-      else if (option == 1)
+      else if (option == 2)
       {
         doRadioList();
         return 2;
       }
-      else if (option == 2)
+      else if (option == 3)
       {
         doRecordingsList();
         return 2;
       }
-      else if (option == 3)
+      else if (option == 4)
       {
         doTimersList();
         return 2;
       }
-      else if (option == 4)
+      else if (option == 5)
       {
         doOptions();
         return 2;
       }
-      else if (option == 5)
+      else if (option == 6)
       {
         Command::getInstance()->doReboot();
         return 2;
index ec535b0dbaeba42b787c694c4c626f7ac90303a2..e27593c9cb88c625db3c2cf2aaa43064c4c47803 100644 (file)
@@ -40,7 +40,7 @@ void WSelectList::clear()
   int vsize = options.size();
   for (int i = 0; i < vsize; i++)
   {
-    delete[] options[i];
+    delete[] options[i].text;
   }
   options.clear();
 
@@ -66,12 +66,15 @@ void WSelectList::hintSetTop(int idx)
   topOption = idx;
 }
 
-int WSelectList::addOption(char* text, int selected)
+int WSelectList::addOption(char* text, ULONG data, int selected)
 {
   int thisNewOption = options.size();
-  int length = strlen(text);
-  options.push_back(new char[length + 1]);
-  strcpy(options[thisNewOption], text);
+
+  wsloption wslo;
+  wslo.text = new char[strlen(text) + 1];
+  strcpy(wslo.text, text);
+  wslo.data = data;
+  options.push_back(wslo);
   if (selected) selectedOption = thisNewOption;
   return thisNewOption;
 }
@@ -106,11 +109,11 @@ void WSelectList::draw()
     if (i == selectedOption)
     {
       rectangle(0, ypos, area.w, fontHeight, Colour::SELECTHIGHLIGHT);
-      drawOptionLine(options[i], 5, ypos, Colour::DARKTEXT);
+      drawOptionLine(options[i].text, 5, ypos, Colour::DARKTEXT);
     }
     else
     {
-      drawOptionLine(options[i], 5, ypos, Colour::LIGHTTEXT);
+      drawOptionLine(options[i].text, 5, ypos, Colour::LIGHTTEXT);
     }
     ypos += ySeperation;
   }
@@ -213,3 +216,8 @@ int WSelectList::getCurrentOption()
 {
   return selectedOption;
 }
+
+ULONG WSelectList::getCurrentOptionData()
+{
+  return options[selectedOption].data;
+}
index a556af8484264588cb0be2f1ff629434a79571e6..06ed6d9c89a5d5cb2cbdaf1cef41aa445eafaa53 100644 (file)
 
 using namespace std;
 
+typedef struct
+{
+  char* text;
+  ULONG data;
+} wsloption;
+
 class WSelectList : public Widget
 {
   public:
@@ -41,7 +47,7 @@ class WSelectList : public Widget
     void addColumn(int x);
 
     void setNoLoop();
-    int addOption(char* text, int selected);
+    int addOption(char* text, ULONG data, int selected);
     void draw();
 
     void down();
@@ -53,6 +59,7 @@ class WSelectList : public Widget
     int getNumOptions();
     int getBottomOption();     // actually returns bottom + 1 i.e. the one just past display ?!
     int getCurrentOption();
+    ULONG getCurrentOptionData();
 
     void hintSetCurrent(int index);
     void hintSetTop(int index);
@@ -60,7 +67,7 @@ class WSelectList : public Widget
   private:
     void drawOptionLine(char* text, int xpos, int ypos, Colour& colour);
 
-    vector<char*> options;
+    vector<wsloption> options;
     UINT selectedOption;
     int topOption;
     UINT numOptionsDisplayable;
index 8de9f14441176825760339a1356e202fa150d5cc..81171d608b9eee1c6a7621d5fb087d51aff12a02 100644 (file)
@@ -20,8 +20,8 @@
 
 #include "wsymbol.h"
 
-UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2, 3, 5, 5, 4, 4};
-UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16, 18, 18, 18, 16, 16};
+UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2, 3, 5, 5, 4, 4, 2, 2};
+UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16, 18, 18, 18, 16, 16, 8, 8};
 
 UCHAR WSymbol::symbols[] = {
 
@@ -794,6 +794,46 @@ UCHAR WSymbol::symbols[] = {
 0xF0, 0x00, 0xF0, 0x00,
 0xC0, 0x00, 0xC0, 0x00,
 
+/*
+00000001 10000000
+00000011 11000000
+00000110 01100000
+00001100 00110000
+00011000 00011000
+00110000 00001100
+01100000 00000110
+11000000 00000011
+*/
+
+0x01, 0x80,
+0x03, 0xC0,
+0x06, 0x60,
+0x0C, 0x30,
+0x18, 0x18,
+0x30, 0x0C,
+0x60, 0x06,
+0xC0, 0x03,
+
+/*
+11000000 00000011
+01100000 00000110
+00110000 00001100
+00011000 00011000
+00001100 00110000
+00000110 01100000
+00000011 11000000
+00000001 10000000
+*/
+
+0xC0, 0x03,
+0x60, 0x06,
+0x30, 0x0C,
+0x18, 0x18,
+0x0C, 0x30,
+0x06, 0x60,
+0x03, 0xC0,
+0x01, 0x80,
+
 };
 
 WSymbol::WSymbol()
index bffb69d3f516bfea48f02a7e0e1e2419fdbe2074..c0be54975fc83c8e9cfbc7950fb681f068bf0543 100644 (file)
--- a/wsymbol.h
+++ b/wsymbol.h
@@ -54,6 +54,8 @@ class WSymbol : public Widget
     const static UCHAR SKIPFORWARD2 = 17;
     const static UCHAR FBWD = 18;
     const static UCHAR FFWD = 19;
+    const static UCHAR SMALLUP = 20;
+    const static UCHAR SMALLDOWN = 21;
 
   private:
     static UCHAR symbols[];