From c97ceee14e7c68770e0a0c45ea70235e56f445b9 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 15 May 2006 22:07:31 +0000 Subject: [PATCH] Select list upgrade, gui and backend support to move recordings between directories --- Makefile | 2 +- command.cc | 5 ++ event.cc | 2 - event.h | 3 -- message.h | 1 + recman.cc | 42 +++++++++++++++ recman.h | 5 ++ rectimer.cc | 2 +- rectimer.h | 2 +- vchannellist.cc | 14 +---- vdr.cc | 36 +++++++++++++ vdr.h | 2 + vepg.cc | 2 +- viewman.cc | 2 +- vlivebanner.cc | 62 +++++++++------------- vrecmove.cc | 132 ++++++++++++++++++++++++++++++++++++++++++++++ vrecmove.h | 58 ++++++++++++++++++++ vrecordinglist.cc | 109 +++++++++++++++++++++++++++----------- vrecordinglist.h | 1 + vrecordingmenu.cc | 48 +++++++++++++---- vrecordingmenu.h | 5 +- vserverselect.cc | 4 +- vtimerlist.cc | 22 ++++---- vwelcome.cc | 26 ++++----- wselectlist.cc | 22 +++++--- wselectlist.h | 11 +++- wsymbol.cc | 44 +++++++++++++++- wsymbol.h | 2 + 28 files changed, 527 insertions(+), 139 deletions(-) create mode 100644 vrecmove.cc create mode 100644 vrecmove.h diff --git a/Makefile b/Makefile index 4213a86..2086636 100644 --- 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 diff --git a/command.cc b/command.cc index 38560ba..6a9ac67 100644 --- a/command.cc +++ b/command.cc @@ -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); } } diff --git a/event.cc b/event.cc index e37a0f6..b08a784 100644 --- 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 63ab88f..05b6d47 100644 --- a/event.h +++ b/event.h @@ -43,9 +43,6 @@ class Event char* title; char* subtitle; char* description; - - int index; - }; class EventSorter diff --git a/message.h b/message.h index f16262e..c1a9f0e 100644 --- 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 diff --git a/recman.cc b/recman.cc index e8c9d15..1850ffe 100644 --- 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 ¤tDir->recList; } + +Directory* RecMan::getRootDir() +{ + return rootDir; +} diff --git a/recman.h b/recman.h index 915cb1d..81a01d7 100644 --- 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 diff --git a/rectimer.cc b/rectimer.cc index 34843df..b550e10 100644 --- a/rectimer.cc +++ b/rectimer.cc @@ -33,7 +33,7 @@ RecTimer::RecTimer() file = NULL; - index = -1; +// index = -1; directory = NULL; name = NULL; } diff --git a/rectimer.h b/rectimer.h index fa53e21..cb5cfcd 100644 --- a/rectimer.h +++ b/rectimer.h @@ -46,7 +46,7 @@ class RecTimer ULONG startTime; ULONG stopTime; - int index; +// int index; bool operator< (const RecTimer& op2); diff --git a/vchannellist.cc b/vchannellist.cc index eca6ae1..9da042d 100644 --- a/vchannellist.cc +++ b/vchannellist.cc @@ -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 7ec9857..b89e58d 100644 --- 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 228acdc..c1aa880 100644 --- 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 afeb6d3..94ad220 100644 --- a/vepg.cc +++ b/vepg.cc @@ -127,7 +127,7 @@ VEpg::VEpg(VVideoLive* v, UINT currentChannel) chan = (*chanList)[i]; if (i == currentChannel) first = 1; - chan->index = chanListbox.addOption(chan->name, first); + chan->index = chanListbox.addOption(chan->name, 0, first); first = 0; } chanName.setText((*chanList)[chanListbox.getCurrentOption()]->name); diff --git a/viewman.cc b/viewman.cc index cd6cc37..8ac891e 100644 --- a/viewman.cc +++ b/viewman.cc @@ -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; } diff --git a/vlivebanner.cc b/vlivebanner.cc index 63d9a22..fe2269d 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -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 index 0000000..b34322a --- /dev/null +++ b/vrecmove.cc @@ -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 index 0000000..816522a --- /dev/null +++ b/vrecmove.h @@ -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 +#include + +#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 diff --git a/vrecordinglist.cc b/vrecordinglist.cc index ed1c043..dd6ae8d 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -72,7 +72,7 @@ void VRecordingList::drawData(bool doIndexPop) { currentSubDir = *i; SNPRINTF(tempA, 299, tr(" %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(); diff --git a/vrecordinglist.h b/vrecordinglist.h index 45d920e..7f3bdeb 100644 --- a/vrecordinglist.h +++ b/vrecordinglist.h @@ -68,6 +68,7 @@ class VRecordingList : public View void doDeleteSelected(); int doPlay(); int doResume(); + void doMoveRecording(Directory* toDir); Recording* getCurrentOptionRecording(); stack slIndexStack; diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index 22533aa..9f3ad61 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -20,11 +20,12 @@ #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); + } } diff --git a/vrecordingmenu.h b/vrecordingmenu.h index a72e2b0..54c5fa1 100644 --- a/vrecordingmenu.h +++ b/vrecordingmenu.h @@ -37,13 +37,14 @@ #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; diff --git a/vserverselect.cc b/vserverselect.cc index f6bfb5c..f5bae81 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -46,10 +46,10 @@ VServerSelect::VServerSelect(vector& 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; diff --git a/vtimerlist.cc b/vtimerlist.cc index 4d46d97..c1e2557 100644 --- a/vtimerlist.cc +++ b/vtimerlist.cc @@ -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; diff --git a/vwelcome.cc b/vwelcome.cc index fe41d73..60d322b 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -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; diff --git a/wselectlist.cc b/wselectlist.cc index ec535b0..e27593c 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -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; +} diff --git a/wselectlist.h b/wselectlist.h index a556af8..06ed6d9 100644 --- a/wselectlist.h +++ b/wselectlist.h @@ -32,6 +32,12 @@ 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 options; + vector options; UINT selectedOption; int topOption; UINT numOptionsDisplayable; diff --git a/wsymbol.cc b/wsymbol.cc index 8de9f14..81171d6 100644 --- a/wsymbol.cc +++ b/wsymbol.cc @@ -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() diff --git a/wsymbol.h b/wsymbol.h index bffb69d..c0be549 100644 --- 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[]; -- 2.39.2