From 1200a1f8c5324a41a34ad76bbf94fdfe92d8e607 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 14 Dec 2005 22:18:02 +0000 Subject: [PATCH] Big code cleanup Less messages used now because master mutex exists Fixed okmenu text display in vreclist Cleaned up how vreclist works Stopped the mad redrawing and selection line moving in vreclist --- CREDITS | 4 ++ box.cc | 5 -- box.h | 1 - command.cc | 9 +-- message.h | 24 ++++--- playervideo.cc | 2 +- timers.cc | 4 +- timers.h | 2 - vchannelselect.cc | 14 ++-- vconnect.cc | 5 +- vepg.cc | 39 ++++------- view.cc | 9 --- view.h | 11 +-- vlivebanner.cc | 24 ++----- vlivebanner.h | 7 +- vmute.cc | 2 +- voptions.cc | 8 +-- voptions.h | 5 +- vquestion.cc | 7 +- vquestion.h | 3 +- vrecordinglist.cc | 166 ++++++++++++++++------------------------------ vrecordinglist.h | 9 ++- vrecordingmenu.cc | 11 ++- vserverselect.cc | 8 ++- vserverselect.h | 3 +- vvideolive.cc | 46 +++++-------- vvideolive.h | 1 + vvolume.cc | 2 +- vwelcome.cc | 39 +++-------- vwelcome.h | 4 +- 30 files changed, 171 insertions(+), 303 deletions(-) diff --git a/CREDITS b/CREDITS index 73e5821..34fcd58 100644 --- a/CREDITS +++ b/CREDITS @@ -6,6 +6,10 @@ Chris Tallon Thanks to the following people for their contributions to VOMP: +Mark Calderbank + Demuxer + GUI box splitting algorithm + Dave Pickles VDR 1.3 compatibility Options view code cleanup diff --git a/box.cc b/box.cc index f110d62..96c085c 100644 --- a/box.cc +++ b/box.cc @@ -67,11 +67,6 @@ void Box::setGap(UINT tgap) gap = tgap; } -void Box::show() -{ - blt(area); -} - void Box::blt(Region& r) { Log::getInstance()->log("Box", Log::DEBUG, "Show region %p %u %u %u %u", surface, r.x, r.y, r.w, r.h); diff --git a/box.h b/box.h index 4d9feb8..bf34622 100644 --- a/box.h +++ b/box.h @@ -39,7 +39,6 @@ class Box void setSurfaceOffset(UINT x, UINT y); void setGap(UINT gap); - void show(); // Obselete void blt(Region& r); // For use only by ViewMan virtual void draw(); diff --git a/command.cc b/command.cc index a21a097..23e3323 100644 --- a/command.cc +++ b/command.cc @@ -197,12 +197,7 @@ void Command::processMessage(Message* m) } case Message::STREAM_END: { - // post a message to ViewMan and then run the viewman message queue - Message* m2 = new Message(); - m2->message = Message::STREAM_END; - m2->to = VVideoLive::getInstance(); - viewman->postMessage(m2); - handleCommand(Remote::NA_NONE); + VVideoLive::getInstance()->streamEnd(); break; } case Message::VDR_CONNECTED: @@ -269,7 +264,7 @@ void Command::handleCommand(int button) void Command::sig1() { #ifdef DEV - Message* m = new Message(); + Message* m = new Message(); // break into master mutex m->message = Message::SCREENSHOT; m->to = this; postMessage(m); diff --git a/message.h b/message.h index 7c0f478..3fe32a2 100644 --- a/message.h +++ b/message.h @@ -24,7 +24,13 @@ #include #include "defines.h" -class View; +// Usage of messages is more dubious now that the single master mutex lock +// protects all gui actions. Reason(s) for usage: +// 1. View A wants something to be done by View B *after* View A has been deleted +// 2. A thread wants its object/view deleting *after* the thread has exited + +// Put a justification line after call to Message* m = new Message() line +// So that the sources can be grepped for proper message useage class Message { @@ -48,16 +54,12 @@ class Message const static ULONG STOP_PLAYBACK = 9; const static ULONG SERVER_SELECTED = 10; const static ULONG VDR_CONNECTED = 11; - const static ULONG REDRAW_DATA = 12; - const static ULONG ADD_VIEW = 13; - const static ULONG CHANNEL_UP = 14; - const static ULONG CHANNEL_DOWN = 15; - const static ULONG STREAM_END = 16; - const static ULONG CHILD_CLOSE = 17; - const static ULONG REDRAW_LANG = 18; - const static ULONG TIMER = 19; - const static ULONG EPG = 20; - const static ULONG EPG_CLOSE = 21; + const static ULONG ADD_VIEW = 12; + const static ULONG STREAM_END = 13; + const static ULONG REDRAW_LANG = 14; + const static ULONG TIMER = 15; + const static ULONG EPG = 16; + const static ULONG EPG_CLOSE = 17; }; #endif diff --git a/playervideo.cc b/playervideo.cc index 5ef741e..a0e572a 100644 --- a/playervideo.cc +++ b/playervideo.cc @@ -635,7 +635,7 @@ void PlayerVideo::threadMethod() // end of recording Log::getInstance()->log("Player", Log::DEBUG, "Recording playback ends"); - Message* m = new Message(); + Message* m = new Message(); // Must be done after this thread finishes, and must break into master mutex if (streamLength) m->message = Message::STOP_PLAYBACK; // recording else m->message = Message::STREAM_END; // live Log::getInstance()->log("Player", Log::DEBUG, "Posting message to %p...", commandMessageQueue); diff --git a/timers.cc b/timers.cc index 280cc73..5b5b79f 100755 --- a/timers.cc +++ b/timers.cc @@ -250,7 +250,7 @@ void Timers::threadMethod() //logger->log("Timers", Log::DEBUG, "about to un-LOCK -TIMERS- MUTEX (1)"); - threadWaitForSignalTimed(&nextTime); // FIXME does this work if the time is in the past? + threadWaitForSignalTimed(&nextTime); //logger->log("Timers", Log::DEBUG, "LOCKED -TIMERS- MUTEX 5"); // unlocks in the wait @@ -280,7 +280,7 @@ void Timers::threadMethod() // send this timer to the timer receiver, via the command message queue // so that the gui mutex is locked when it happens - Message* m = new Message(); + Message* m = new Message(); // Timer call, must be injected into master mutex (this is generated outside the mutex) m->from = this; m->to = nextTimer->client; m->message = Message::TIMER; diff --git a/timers.h b/timers.h index c9e20ec..1044b1f 100755 --- a/timers.h +++ b/timers.h @@ -31,8 +31,6 @@ #include "command.h" #include "timerreceiver.h" -// FIXME - ensure all objects that call settimer call cancel timer if they are being deleted - /* Timers documentation diff --git a/vchannelselect.cc b/vchannelselect.cc index bd77315..37a0a4b 100644 --- a/vchannelselect.cc +++ b/vchannelselect.cc @@ -115,22 +115,18 @@ int VChannelSelect::handleCommand(int command) if (numGot == 3) { - Message* m = new Message(); - m->from = this; - m->to = ViewMan::getInstance(); - m->message = Message::CLOSE_ME; - ViewMan::getInstance()->postMessage(m); - // Is there valid data? if ((first > 0) || (second > 0) || (third > 0)) { - m = new Message(); + Message* m = new Message(); m->from = this; m->to = videoLive; m->message = Message::CHANNEL_CHANGE; m->parameter = (first * 100) + (second * 10) + third; ViewMan::getInstance()->postMessage(m); } + + return 4; } return 2; @@ -146,7 +142,7 @@ void VChannelSelect::timercall(int clientReference) Log::getInstance()->log("VChannelSelect", Log::DEBUG, "Timer call"); // Close me - Message* m = new Message(); + Message* m = new Message(); // Delete self m->from = this; m->to = ViewMan::getInstance(); m->message = Message::CLOSE_ME; @@ -168,7 +164,7 @@ void VChannelSelect::timercall(int clientReference) newChannel += third; } - m = new Message(); + m = new Message(); // Must be done after this view deleted m->from = this; m->to = videoLive; m->message = Message::CHANNEL_CHANGE; diff --git a/vconnect.cc b/vconnect.cc index eab08b1..c86a5f3 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -91,8 +91,7 @@ void VConnect::threadMethod() else { selectedServer = -1; - VServerSelect* vs = new VServerSelect(&serverIPs); - vs->setParent(this); + VServerSelect* vs = new VServerSelect(&serverIPs, this); vs->draw(); viewman->add(vs); // FIXME - do this better - perhaps post message to Command // Otherwise it will be using ViewMan without the Command mutex locked @@ -153,7 +152,7 @@ void VConnect::threadMethod() } while(!success); - Message* m = new Message(); + Message* m = new Message(); // Must be done after this thread ends m->from = this; m->message = Message::VDR_CONNECTED; Command::getInstance()->postMessage(m); diff --git a/vepg.cc b/vepg.cc index 4b65cb1..2559fee 100644 --- a/vepg.cc +++ b/vepg.cc @@ -348,12 +348,8 @@ int VEpg::handleCommand(int command) case Remote::GO: case Remote::OK: { // select programme and display menu TODO currently just changes to selected channel - Message* m = new Message(); - m->from = this; - m->to = videoLive; - m->message = Message::CHANNEL_CHANGE; - m->parameter = (*chanList)[chanListbox.getCurrentOption()]->number; - ViewMan::getInstance()->postMessage(m); + videoLive->channelChange(VVideoLive::NUMBER, (*chanList)[chanListbox.getCurrentOption()]->number); + if(command == Remote::GO) return 2; // GO just changes channel in preview, PLAY changes channel and returns to normal TV @@ -364,7 +360,7 @@ int VEpg::handleCommand(int command) // return to normal TV mode if (videoLive) // ptr check done in case being tested from videorec { - Message* m = new Message(); + Message* m = new Message(); // Must be done after this view deleted m->from = this; m->to = videoLive; m->message = Message::EPG_CLOSE; @@ -372,25 +368,16 @@ int VEpg::handleCommand(int command) } return 4; } - case Remote::CHANNELUP: - { - // change up channel on live TV - Message* m = new Message(); - m->from = this; - m->to = videoLive; - m->message = Message::CHANNEL_UP; - ViewMan::getInstance()->postMessage(m); - return 2; - } - case Remote::CHANNELDOWN: - { // change down channel on live TV - Message* m = new Message(); - m->from = this; - m->to = videoLive; - m->message = Message::CHANNEL_DOWN; - ViewMan::getInstance()->postMessage(m); - return 2; - } + case Remote::CHANNELUP: + { + videoLive->channelChange(VVideoLive::OFFSET, VVideoLive::UP); + return 2; + } + case Remote::CHANNELDOWN: + { + videoLive->channelChange(VVideoLive::OFFSET, VVideoLive::DOWN); + return 2; + } } // stop command getting to any more views return 1; diff --git a/view.cc b/view.cc index c0e348d..b589910 100644 --- a/view.cc +++ b/view.cc @@ -24,10 +24,6 @@ char View::numViews = 0; View::View() { - delSec = 0; - delNSec = 0; - seconds = 0; - titleBarOn = 0; borderOn = 0; @@ -113,8 +109,3 @@ void View::setBorderOn(UCHAR on) { borderOn = on; } - -void View::setParent(View* tParent) -{ - parent = tParent; -} diff --git a/view.h b/view.h index ce97743..1a9d710 100644 --- a/view.h +++ b/view.h @@ -38,21 +38,13 @@ class View : public Box virtual void draw(); virtual int handleCommand(int command); + virtual void processMessage(Message* m); void setBorderOn(UCHAR on); void setTitleBarOn(UCHAR on); void setTitleText(char* title); void setBackgroundColour(Colour& colour); void setTitleBarColour(Colour& colour); - void setParent(View* parent); - - // For use by ViewMan - long delSec; - long delNSec; - int seconds; - // - - virtual void processMessage(Message* m); private: static char numViews; @@ -65,7 +57,6 @@ class View : public Box protected: Colour titleBarColour; - View* parent; }; #endif diff --git a/vlivebanner.cc b/vlivebanner.cc index e1770b4..9323b74 100644 --- a/vlivebanner.cc +++ b/vlivebanner.cc @@ -22,11 +22,11 @@ VLiveBanner* VLiveBanner::instance = NULL; -VLiveBanner::VLiveBanner(View* tparent, Channel* channel, bool bannerTakesCommands) +VLiveBanner::VLiveBanner(VVideoLive* tvvideoLive, Channel* channel, bool bannerTakesCommands) { instance = this; eventList = NULL; - parent = tparent; + vvideoLive = tvvideoLive; takeCommands = bannerTakesCommands; clockRegion.x = 440; @@ -192,24 +192,14 @@ int VLiveBanner::handleCommand(int command) { // cancel timer so this view is still here later Timers::getInstance()->cancelTimer(this, 1); // if it exists - - Message* m = new Message(); - m->from = this; - m->to = parent; - m->message = Message::CHANNEL_UP; - ViewMan::getInstance()->postMessage(m); + vvideoLive->channelChange(VVideoLive::OFFSET, VVideoLive::UP); return 2; } case Remote::CHANNELDOWN: { // cancel timer so this view is still here later Timers::getInstance()->cancelTimer(this, 1); // if it exists - - Message* m = new Message(); - m->from = this; - m->to = parent; - m->message = Message::CHANNEL_DOWN; - ViewMan::getInstance()->postMessage(m); + vvideoLive->channelChange(VVideoLive::OFFSET, VVideoLive::DOWN); return 2; } case Remote::GREEN: @@ -258,9 +248,9 @@ int VLiveBanner::handleCommand(int command) { // full epg Timers::getInstance()->cancelTimer(this, 1); // if it exists - Message* m = new Message(); + Message* m = new Message(); // Must be done after this view deleted m->message = Message::EPG; - m->to = parent; + m->to = vvideoLive; m->from = this; ViewMan::getInstance()->postMessage(m); return 4; @@ -275,7 +265,7 @@ void VLiveBanner::timercall(int clientReference) if (clientReference == 1) { // delete me! - Message* m = new Message(); + Message* m = new Message(); // Delete self m->message = Message::CLOSE_ME; m->to = ViewMan::getInstance(); m->from = this; diff --git a/vlivebanner.h b/vlivebanner.h index 05f2f78..5ea6f38 100644 --- a/vlivebanner.h +++ b/vlivebanner.h @@ -38,11 +38,14 @@ #include "i18n.h" #include "timerreceiver.h" #include "timers.h" +//#include "vvideolive.h" + +class VVideoLive; class VLiveBanner : public View, public TimerReceiver { public: - VLiveBanner(View* parent, Channel* channel, bool bannerTakesCommands); + VLiveBanner(VVideoLive* tvvideoLive, Channel* channel, bool bannerTakesCommands); ~VLiveBanner(); static VLiveBanner* getInstance(); void delData(); @@ -55,7 +58,7 @@ class VLiveBanner : public View, public TimerReceiver private: static VLiveBanner* instance; - View* parent; + VVideoLive* vvideoLive; WSelectList sl; Channel* currentChannel; EventList* eventList; diff --git a/vmute.cc b/vmute.cc index d4444b3..292914a 100644 --- a/vmute.cc +++ b/vmute.cc @@ -60,7 +60,7 @@ void VMute::draw() void VMute::timercall(int clientReference) { // delete me! - Message* m = new Message(); + Message* m = new Message(); // Delete self m->message = Message::CLOSE_ME; m->to = ViewMan::getInstance(); m->from = this; diff --git a/voptions.cc b/voptions.cc index ca26fd4..caf5b2f 100644 --- a/voptions.cc +++ b/voptions.cc @@ -20,8 +20,9 @@ #include "voptions.h" -VOptions::VOptions() +VOptions::VOptions(VWelcome* tvwelcome) { + vwelcome = tvwelcome; viewman = ViewMan::getInstance(); create(530, 85+(NUM_OPTIONS*30)); @@ -220,10 +221,7 @@ void VOptions::doSave() if (result[1] != optionsAtStart[1]) { I18n::initialize(); - Message *m = new Message(); - m->to = VWelcome::getInstance(); - m->message = Message::REDRAW_LANG; - viewman->postMessage(m); + vwelcome->redrawLang(); } if (result[2] != optionsAtStart[2]) diff --git a/voptions.h b/voptions.h index 918d4c2..790ac38 100644 --- a/voptions.h +++ b/voptions.h @@ -63,10 +63,12 @@ const static OPTIONDATA optionData[NUM_OPTIONS] = {"VDR-Pri 0=OK !See forums!","General", "Live priority", 21, 0, options6 } }; +class VWelcome; + class VOptions : public View { public: - VOptions(); + VOptions(VWelcome* tvwelcome); ~VOptions(); int handleCommand(int command); @@ -81,6 +83,7 @@ class VOptions : public View VDR* vdr; int* optionsAtStart; ViewMan* viewman; + VWelcome* vwelcome; }; #endif diff --git a/vquestion.cc b/vquestion.cc index 2b792ec..b14509c 100644 --- a/vquestion.cc +++ b/vquestion.cc @@ -20,8 +20,9 @@ #include "vquestion.h" -VQuestion::VQuestion() +VQuestion::VQuestion(void* treplyTo) { + replyTo = treplyTo; mainText = NULL; selectedOption = NO; @@ -101,9 +102,9 @@ int VQuestion::handleCommand(int command) { if (selectedOption != YES) return 4; - Message* m = new Message(); + Message* m = new Message(); // Question/answer mech m->from = this; - m->to = parent; + m->to = replyTo; m->message = Message::QUESTION_YES; ViewMan::getInstance()->postMessage(m); diff --git a/vquestion.h b/vquestion.h index 5a96d2d..d69f8fb 100644 --- a/vquestion.h +++ b/vquestion.h @@ -34,7 +34,7 @@ class VQuestion : public View { public: - VQuestion(); + VQuestion(void* replyTo); ~VQuestion(); void setDefault(UCHAR option); void setMainText(char* title); @@ -46,6 +46,7 @@ class VQuestion : public View const static UCHAR YES = 1; private: + void* replyTo; char* mainText; void swap(); diff --git a/vrecordinglist.cc b/vrecordinglist.cc index ce14abe..f7bc485 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -20,11 +20,11 @@ #include "vrecordinglist.h" -VRecordingList::VRecordingList(VRecordingList* tparent) +VRecordingList::VRecordingList(VRecordingList* tparent, Directory* tdir) { myParent = tparent; - dataInvalid = 0; viewman = ViewMan::getInstance(); + recDir = tdir; create(570, 420); if (Video::getInstance()->getFormat() == Video::PAL) @@ -47,42 +47,43 @@ VRecordingList::VRecordingList(VRecordingList* tparent) VRecordingList::~VRecordingList() { - // if this is a child window, inform the parent of our destruct if (myParent) { - Message* m = new Message(); - m->to = myParent; - m->message = Message::CHILD_CLOSE; - viewman->postMessage(m); + // if this is a sub, there can only be recordings. if there are none left, get this dir deleted by parent + if (recDir->getNumRecordings() == 0) myParent->zeroCheck(); + // recDir is now deleted if it was empty } - - // only delete the list if this is not a sub dir window - if (recDir->isRoot) + else { + // only delete the list if this is not a sub dir window delete recDir; } } -void VRecordingList::setDir(Directory* tdir) +void VRecordingList::zeroCheck() { - recDir = tdir; - - drawData(); - - char title[300]; - if (!recDir->isRoot) - { - snprintf(title, 299, tr("Recordings - %s"), recDir->name); - setTitleText(title); - } - else + // go through to delete 1 empty dir if necessary (there will only ever be 1) + Directory* dir; + DirectoryList::iterator i; + for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++) { - setTitleText(tr("Recordings")); + dir = *i; + if (dir->getNumRecordings() == 0) + { + delete dir; + recDir->dirList.erase(i); + break; + } } + drawData(); + viewman->updateView(this); } void VRecordingList::drawData() { + int saveIndex = sl.getCurrentOption(); + int saveTop = sl.getTopOption(); + sl.clear(); sl.addColumn(0); sl.addColumn(110); @@ -95,26 +96,6 @@ void VRecordingList::drawData() Directory* dir; DirectoryList::iterator i; - - if (dataInvalid == 2) // special case, a child list has closed, check for 0 dir entries - { - - // First go through to delete 1 empty dir if necessary - - for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++) - { - dir = *i; - if (dir->getNumRecordings() == 0) - { - delete dir; - recDir->dirList.erase(i); - break; - } - } - } - - // Then go through again to draw data. Don't merge these two loops! - for (i = recDir->dirList.begin(); i != recDir->dirList.end(); i++) { dir = *i; @@ -125,7 +106,6 @@ void VRecordingList::drawData() // FIXME convert the whole program to time_t's - Recording* rec; for (UINT j = 0; j < recDir->recList.size(); j++) { @@ -137,18 +117,32 @@ void VRecordingList::drawData() first = 0; } - dataInvalid = 0; + sl.hintSetCurrent(saveIndex); + sl.hintSetTop(saveTop); + sl.draw(); } void VRecordingList::draw() { - View::draw(); + char title[300]; + if (myParent) + { + snprintf(title, 299, tr("Recordings - %s"), recDir->name); + setTitleText(title); + } + else + { + setTitleText(tr("Recordings")); + } - if (dataInvalid) drawData(); + View::draw(); - sl.draw(); + char freeSpace[50]; + int gigFree = Directory::freeSpace / 1024; + snprintf(freeSpace, 49, tr("%lu%% used, %iGB free"), Directory::usedPercent, gigFree); + drawTextRJ(freeSpace, 560, 5, Colour::LIGHTTEXT); - // Put the status stuff at the bottom + // Symbols WSymbol w; w.setSurface(surface); @@ -173,15 +167,13 @@ void VRecordingList::draw() w.setSurfaceOffset(150, 385); w.draw(); - // FIXME Right justify this! - drawText(tr("[ok] = menu"), 450, 385, Colour::LIGHTTEXT); + drawTextRJ("[ok] = menu", 560, 385, Colour::LIGHTTEXT); - doShowingBar(); + // All static stuff done - char freeSpace[50]; - int gigFree = Directory::freeSpace / 1024; - snprintf(freeSpace, 49, tr("%lu%% used, %iGB free"), Directory::usedPercent, gigFree); - drawTextRJ(freeSpace, 560, 5, Colour::LIGHTTEXT); + drawData(); + sl.draw(); + doShowingBar(); } void VRecordingList::doShowingBar() @@ -189,21 +181,12 @@ void VRecordingList::doShowingBar() int topOption = sl.getTopOption() + 1; if (sl.getNumOptions() == 0) topOption = 0; + rectangle(220, 385, 180, 25, Colour::VIEWBACKGROUND); char showing[200]; sprintf(showing, tr("%i to %i of %i"), topOption, sl.getBottomOption(), sl.getNumOptions()); - -// Box b; -// b.setSurfaceOffset(220, 385); -// b.setDimensions(160, 25); -// b.fillColour(Colour::VIEWBACKGROUND); -// b.drawText(showing, 0, 0, Colour::LIGHTTEXT); - - rectangle(220, 385, 220+160, 385+25, Colour::VIEWBACKGROUND); drawText(showing, 220, 385, Colour::LIGHTTEXT); } - - void VRecordingList::processMessage(Message* m) { Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message); @@ -225,34 +208,15 @@ void VRecordingList::processMessage(Message* m) doResume(); return; } - - if (m->message == Message::REDRAW_DATA) - { - dataInvalid = 1; - draw(); - return; - } - - if (m->message == Message::CHILD_CLOSE) - { - dataInvalid = 2; - draw(); - show(); - return; - } } void VRecordingList::doDeleteSelected() { + Log::getInstance()->log("VRecordingList", Log::DEBUG, "Parent = %p, isRoot = %i", myParent, recDir->isRoot); Recording* toDelete = getCurrentOptionRecording(); - int saveIndex; - int saveTop; - if (toDelete) { - saveIndex = toDelete->index; - saveTop = sl.getTopOption(); Log::getInstance()->log("VRecordingList", Log::DEBUG, "FOUND: %i %s %s", toDelete->index, toDelete->getProgName(), toDelete->fileName); VDR* vdr = VDR::getInstance(); @@ -269,22 +233,13 @@ void VRecordingList::doDeleteSelected() } } - sl.clear(); - setDir(recDir); - sl.hintSetCurrent(saveIndex); - sl.hintSetTop(saveTop); - draw(); - } + drawData(); + viewman->updateView(this); - if (myParent) // if this is not root send a message to parent to say redraw data - { // FIXME not really necessary any more ? - Message* m1 = new Message(); - m1->to = myParent; - m1->message = Message::REDRAW_DATA; - viewman->postMessage(m1); + if (myParent) myParent->drawData(); // if this is not root get parent to redraw data } - show(); + Log::getInstance()->log("VRecordingList", Log::DEBUG, "Parent = %p, isRoot = %i", myParent, recDir->isRoot); } int VRecordingList::doPlay() @@ -385,13 +340,10 @@ int VRecordingList::handleCommand(int command) curDir = recDir->dirList[i]; if (curDir->index == sl.getCurrentOption()) { - VRecordingList* sub = new VRecordingList(this); - sub->setDir(curDir); - viewman->add(sub); - + VRecordingList* sub = new VRecordingList(this, curDir); sub->draw(); - sub->show(); - + viewman->add(sub); + viewman->updateView(sub); return 2; } } @@ -405,9 +357,9 @@ int VRecordingList::handleCommand(int command) VRecordingMenu* v = new VRecordingMenu(); v->setParent(this); v->setRecording(current); - viewman->add(v); v->draw(); - v->show(); + viewman->add(v); + viewman->updateView(v); return 2; } // should not get to here diff --git a/vrecordinglist.h b/vrecordinglist.h index f3a39d9..306704f 100644 --- a/vrecordinglist.h +++ b/vrecordinglist.h @@ -42,23 +42,22 @@ class VRecordingList : public View { public: - VRecordingList(VRecordingList* parent); + VRecordingList(VRecordingList* parent, Directory* dir); ~VRecordingList(); - void setDir(Directory* dir); - void drawData(); - int handleCommand(int command); void processMessage(Message* m); void draw(); + void drawData(); + void zeroCheck(); + private: VRecordingList* myParent; Directory* recDir; ViewMan* viewman; WSelectList sl; - int dataInvalid; void doShowingBar(); void doDeleteSelected(); diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index 23494fc..eaa8879 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -94,7 +94,7 @@ int VRecordingMenu::handleCommand(int command) { if (sl.getCurrentOption() == 0) { - Message* m = new Message(); + Message* m = new Message(); // Must be done after this view deleted m->from = this; m->to = vRecList; m->message = Message::PLAY_SELECTED_RECORDING; @@ -104,7 +104,7 @@ int VRecordingMenu::handleCommand(int command) if (sl.getCurrentOption() == 1) { - Message* m = new Message(); + Message* m = new Message(); // Must be done after this view deleted m->from = this; m->to = vRecList; m->message = Message::RESUME_SELECTED_RECORDING; @@ -141,9 +141,8 @@ int VRecordingMenu::handleCommand(int command) } else if (sl.getCurrentOption() == 3) { - VQuestion* v = new VQuestion(); + VQuestion* v = new VQuestion(this); v->create(260, 180); - v->setParent(this); v->setBackgroundColour(Colour::VIEWBACKGROUND); v->setTitleBarColour(Colour::DANGER); v->setTitleBarOn(1); @@ -181,13 +180,13 @@ void VRecordingMenu::processMessage(Message* m) { if (sl.getCurrentOption() == 3) { - Message* m2 = new Message(); + 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 = new Message(); // OK. Want this to delete before this message does its job m2->from = this; m2->to = vRecList; m2->message = Message::DELETE_SELECTED_RECORDING; diff --git a/vserverselect.cc b/vserverselect.cc index d0dc172..4718f60 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -20,7 +20,7 @@ #include "vserverselect.h" -VServerSelect::VServerSelect(std::vector* serverIPs) +VServerSelect::VServerSelect(std::vector* serverIPs, void* treplyTo) { // I tried the whole passing using a reference here, but // the program segfaulted when settitletext tried to new @@ -51,6 +51,8 @@ VServerSelect::VServerSelect(std::vector* serverIPs) { sl.addOption((*serverIPs)[k], 0); } + + replyTo = treplyTo; } VServerSelect::~VServerSelect() @@ -85,8 +87,8 @@ int VServerSelect::handleCommand(int command) } case Remote::OK: { - Message* m = new Message(); - m->to = parent; + Message* m = new Message(); // Question/Answer mech. Better being messages + m->to = replyTo; m->message = Message::SERVER_SELECTED; m->parameter = sl.getCurrentOption(); ViewMan::getInstance()->postMessage(m); diff --git a/vserverselect.h b/vserverselect.h index 2a9ecd2..c01c144 100644 --- a/vserverselect.h +++ b/vserverselect.h @@ -37,7 +37,7 @@ class VServerSelect : public View { public: - VServerSelect(std::vector* tserverIPs); + VServerSelect(std::vector* tserverIPs, void* replyTo); ~VServerSelect(); int handleCommand(int command); @@ -45,6 +45,7 @@ class VServerSelect : public View private: WSelectList sl; + void* replyTo; }; #endif diff --git a/vvideolive.cc b/vvideolive.cc index 1c10622..74554f1 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -187,45 +187,31 @@ void VVideoLive::channelChange(UCHAR changeType, UINT newData) VEpg* vepg = VEpg::getInstance(); if(vepg) vepg->setCurrentChannel((*chanList)[currentChannel]->name); + + VLiveBanner* vlb = VLiveBanner::getInstance(); + if (vlb) + { + vlb->setChannel((*chanList)[currentChannel]); + vlb->draw(); + viewman->updateView(vlb); + } + play(); } +void VVideoLive::streamEnd() +{ + Log::getInstance()->log("VVideoLive", Log::DEBUG, "streamEnd"); + stop(); + showUnavailable(1); +} + void VVideoLive::processMessage(Message* m) { if (m->message == Message::CHANNEL_CHANGE) { channelChange(NUMBER, m->parameter); } - else if (m->message == Message::CHANNEL_UP) - { - // this message is from vlivebanner - channelChange(OFFSET, UP); - if(!VEpg::getInstance()) - { - VLiveBanner* vlb = VLiveBanner::getInstance(); // guaranteed to be one - vlb->setChannel((*chanList)[currentChannel]); - vlb->draw(); - viewman->updateView(vlb); - } - } - else if (m->message == Message::CHANNEL_DOWN) - { - // this message is from vlivebanner - channelChange(OFFSET, DOWN); - if(!VEpg::getInstance()) - { - VLiveBanner* vlb = VLiveBanner::getInstance(); // guaranteed to be one - vlb->setChannel((*chanList)[currentChannel]); - vlb->draw(); - viewman->updateView(vlb); - } - } - else if (m->message == Message::STREAM_END) - { - Log::getInstance()->log("VVideoLive", Log::DEBUG, "streamEnd"); - stop(); - showUnavailable(1); - } else if (m->message == Message::EPG) { Log::getInstance()->log("VVideoLive", Log::DEBUG, "EPG requested from live banner"); diff --git a/vvideolive.h b/vvideolive.h index 75cf275..1cc8bb8 100644 --- a/vvideolive.h +++ b/vvideolive.h @@ -53,6 +53,7 @@ class VVideoLive : public View void draw(); int handleCommand(int command); void processMessage(Message* m); + void streamEnd(); // from command void channelChange(UCHAR changeType, UINT newData); // changeType = INDEX = (newData is a channel index in the list) diff --git a/vvolume.cc b/vvolume.cc index b67039e..b423722 100644 --- a/vvolume.cc +++ b/vvolume.cc @@ -75,7 +75,7 @@ void VVolume::draw() void VVolume::timercall(int clientReference) { // delete me! - Message* m = new Message(); + Message* m = new Message(); // Delete self m->message = Message::CLOSE_ME; m->to = ViewMan::getInstance(); m->from = this; diff --git a/vwelcome.cc b/vwelcome.cc index d18a0ce..a065206 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -20,11 +20,8 @@ #include "vwelcome.h" -VWelcome* VWelcome::instance = NULL; - VWelcome::VWelcome() { - instance = this; viewman = ViewMan::getInstance(); clockRegion.x = 400; @@ -59,12 +56,6 @@ VWelcome::VWelcome() VWelcome::~VWelcome() { Timers::getInstance()->cancelTimer(this, 1); - instance = NULL; -} - -VWelcome* VWelcome::getInstance() -{ - return instance; } void VWelcome::setup() @@ -156,7 +147,7 @@ int VWelcome::handleCommand(int command) } case Remote::FIVE: { - Message* m = new Message(); + Message* m = new Message(); // Must be done after this view deleted m->message = Message::STANDBY; Command::getInstance()->postMessage(m); return 4; @@ -190,7 +181,7 @@ int VWelcome::handleCommand(int command) } else if (option == 4) { - Message* m = new Message(); + Message* m = new Message(); // Must be done after this view deleted m->message = Message::STANDBY; Command::getInstance()->postMessage(m); return 4; @@ -207,7 +198,6 @@ int VWelcome::handleCommand(int command) return 1; } - void VWelcome::doChannelsList() { ChannelList* chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO); @@ -220,14 +210,6 @@ void VWelcome::doChannelsList() vchan->draw(); viewman->add(vchan); viewman->updateView(vchan); - - -// Message* m = new Message(); -// m->from = this; -// m->to = ViewMan::getInstance(); -// m->message = Message::SWAP_ME_FOR; -// m->parameter = (ULONG)vchan; -// ViewMan::getInstance()->postMessage(m); } } @@ -268,8 +250,7 @@ void VWelcome::doRecordingsList() if (recDir) { - VRecordingList* vrec = new VRecordingList(NULL); - vrec->setDir(recDir); + VRecordingList* vrec = new VRecordingList(NULL, recDir); vrec->draw(); viewman->add(vrec); @@ -283,19 +264,15 @@ void VWelcome::doRecordingsList() void VWelcome::doOptions() { - VOptions* voptions = new VOptions(); + VOptions* voptions = new VOptions(this); voptions->draw(); viewman->add(voptions); viewman->updateView(voptions); } -void VWelcome::processMessage(Message* m) +void VWelcome::redrawLang() { - if (m->message == Message::REDRAW_LANG) - { - Log::getInstance()->log("VWelcome", Log::DEBUG, "Got redraw lang message"); - setup(); - draw(); - viewman->updateView(this); - } + Log::getInstance()->log("VWelcome", Log::DEBUG, "Got redraw lang message"); + setup(); + draw(); } diff --git a/vwelcome.h b/vwelcome.h index 97d0b2c..06440b5 100644 --- a/vwelcome.h +++ b/vwelcome.h @@ -45,16 +45,14 @@ class VWelcome : public View, public TimerReceiver public: VWelcome(); ~VWelcome(); - static VWelcome* getInstance(); void setup(); int handleCommand(int command); - void processMessage(Message* m); void draw(); void timercall(int clientReference); + void redrawLang(); private: - static VWelcome* instance; WSelectList sl; WJpeg jpeg; -- 2.39.5