From 8425eca0828e0a0175fa1dd749bfacc1c011924b Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 25 Sep 2021 16:42:47 +0100 Subject: [PATCH] Restructure messages to go direct to target rather than through BoxStack --- GNUmakefile | 10 ++-- boxstack.cc | 52 ++++++++------------ boxstack.h | 6 +-- control.cc | 52 +++++++------------- control.h | 3 +- input.cc | 2 +- input.h | 4 +- message.h | 4 +- messagequeue.cc | 101 ++++++++++++++++++++++++++++++++++++++- messagequeue.h | 39 +++++++++++++-- playerradiolive.cc | 2 +- playerradiolive.h | 5 +- playerradiorec.cc | 2 +- playerradiorec.h | 5 +- playervideolive.cc | 2 +- playervideolive.h | 5 +- playervideorec.cc | 2 +- playervideorec.h | 5 +- teletextdecodervbiebu.cc | 4 +- vaudioselector.cc | 16 +++++-- vaudioselector.h | 9 ++-- vchannellist.cc | 9 +++- vchannellist.h | 4 +- vchannelselect.cc | 2 +- vchannelselect.h | 6 ++- vcolourtuner.cc | 4 +- vcolourtuner.h | 3 +- vconnect.cc | 2 +- vconnect.h | 4 +- vepg.cc | 11 +++-- vepg.h | 8 ++-- vepglistadvanced.cc | 11 +++-- vepglistadvanced.h | 8 ++-- vepgsettimer.cc | 9 ++-- vepgsettimer.h | 4 +- vepgsummary.cc | 7 +-- vepgsummary.h | 7 +-- vinfo.cc | 5 +- vinfo.h | 5 +- vmedialist.cc | 6 ++- vmedialist.h | 4 +- vmediaview.cc | 4 +- vmediaview.h | 4 +- vopts.cc | 8 +++- vopts.h | 4 +- vpicturebanner.cc | 5 +- vpicturebanner.h | 3 +- vquestion.cc | 16 +++---- vquestion.h | 11 +++-- vradiorec.cc | 5 +- vradiorec.h | 4 +- vrecmove.cc | 8 ++-- vrecmove.h | 8 ++-- vrecording.cc | 9 ++-- vrecording.h | 9 ++-- vrecordinglist.cc | 7 +-- vrecordinglist.h | 4 +- vrecordingmenu.cc | 10 ++-- vrecordingmenu.h | 9 ++-- vserverselect.cc | 7 ++- vserverselect.h | 9 ++-- vteletextview.cc | 3 ++ vteletextview.h | 4 +- vtimeredit.cc | 7 +-- vtimeredit.h | 9 ++-- vtimerlist.cc | 8 +++- vtimerlist.h | 5 +- vvideolivetv.cc | 3 ++ vvideolivetv.h | 3 +- vvideomedia.cc | 6 ++- vvideomedia.h | 7 +-- vvideorec.h | 4 +- vwelcome.cc | 5 +- vwelcome.h | 4 +- 74 files changed, 414 insertions(+), 247 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index c5cf6ab..37c7ae2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -15,6 +15,8 @@ vomp_platform=$(shell ./select-platform) $(info Build system selected: $(vomp_platform)) +ALL_THE_WARNINGS_OFF=0 + CROSSROOT=/pi-root # uncomment the line below if you want to build vomp application without a reboot option, automatically set for windows! @@ -101,10 +103,12 @@ CXXFLAGS_EXTRA = $(SYSROOT) -Wno-psabi -mtune=cortex-a7 -mfloat-abi=hard -fopenm endif - - +ifeq ($(ALL_THE_WARNINGS_OFF),1) +CXXFLAGS_DEV = $(DEFINES) -DDEV -g -O0 -std=c++14 -Wno-deprecated $(CXXFLAGS_EXTRA) $(INCLUDES) +else CXXFLAGS_DEV = $(DEFINES) -DDEV -g -O0 -Wall -Wextra -Wshadow -Werror=return-type -Wmissing-format-attribute -Wdisabled-optimization -Wmissing-declarations -Wmissing-noreturn -Winit-self -Woverloaded-virtual -Wold-style-cast -Wconversion -std=c++14 $(CXXFLAGS_EXTRA) $(INCLUDES) -#CXXFLAGS_DEV = $(DEFINES) -DDEV -g -O0 -std=c++14 $(CXXFLAGS_EXTRA) $(INCLUDES) +endif + CXXFLAGS_REL = $(DEFINES) -O3 -Wall -Werror -std=c++14 $(CXXFLAGS_EXTRA) $(INCLUDES) .PHONY: clean fresh all install strip diff --git a/boxstack.cc b/boxstack.cc index c5d6d9c..415fb4b 100644 --- a/boxstack.cc +++ b/boxstack.cc @@ -496,6 +496,8 @@ int BoxStack::handleCommand(int command) int retVal2 = 0; int i; + LogNT::getInstance()->debug(TAG, "handle command {}", command); + if (command != Input::NA_NONE) { // handle command return values @@ -506,7 +508,7 @@ int BoxStack::handleCommand(int command) for (i=numBoxes-1; i>=0; i--) { - // LogNT::getInstance()->debug(TAG, "Giving command to i={}", i); + LogNT::getInstance()->debug(TAG, "Giving command to i={}", i); retVal = boxes[i]->handleCommand(command); if (retVal == 1) { @@ -540,44 +542,30 @@ int BoxStack::handleCommand(int command) void BoxStack::processMessage(Message* m) { - if ((m->p_to != Message::BOXSTACK) && (m->to != this)) - { - for (int i = numBoxes-1; i >= 0; i--) - { - if (boxes[i] == m->to) - { - LogNT::getInstance()->debug(TAG, "sending message {} from {} to {}", m->message, (void*)m->from, (void*)m->to); - boxes[i]->processMessage(m); - return; - } - } - return; - } - - // Handle mouse events - // They just need to be delivered to top box if (m->p_to == Message::MOUSE_RECEIVER) { + // Handle mouse events + // They just need to be delivered to top box if (numBoxes > 1) boxes[numBoxes-1]->processMessage(m); return; } - - LogNT::getInstance()->debug(TAG, "it's for meeee!"); - - switch(m->message) + else if (m->p_to == Message::BOXSTACK) { - case Message::CLOSE_ME: + switch(m->message) { - remove(static_cast(m->from)); - break; - } - case Message::ADD_VIEW: - { - Boxx* toAdd = reinterpret_cast(m->data); - add(toAdd); - toAdd->draw(); - update(toAdd); - break; + case Message::CLOSE_ME: + { + remove(static_cast(m->from)); + break; + } + case Message::ADD_VIEW: + { + Boxx* toAdd = reinterpret_cast(m->data); + add(toAdd); + toAdd->draw(); + update(toAdd); + break; + } } } } diff --git a/boxstack.h b/boxstack.h index fae2fd0..e930c1d 100644 --- a/boxstack.h +++ b/boxstack.h @@ -28,15 +28,13 @@ #include "boxx.h" #include "region.h" -#include "message.h" +#include "messagequeue.h" #include "video.h" - - typedef std::list RegionList; typedef std::stack > VideoDisplayStack; -class BoxStack +class BoxStack : public MessageReceiver { public: BoxStack(); diff --git a/control.cc b/control.cc index 5bc2888..c5ea164 100644 --- a/control.cc +++ b/control.cc @@ -385,7 +385,6 @@ void Control::doWallpaper() void Control::run() { if (!initted) return; - irun = true; // just in case Video::getInstance()->signalOn(); @@ -404,30 +403,10 @@ void Control::run() vconnect->run(); } - std::unique_lock lockWrapper(messageQueueMutex); // locks. unlocks on out-of-scope - inputMan->start(); - while(irun) - { - messageQueueCond.wait(lockWrapper, [&] { return !irun || !messages.empty(); }); - logger->debug(TAG, "woke"); - - if (!irun) break; - - while(!messages.empty()) - { - Message* m = messages.front(); - messages.pop_front(); - - lockWrapper.unlock(); - - processMessage(m); - delete m; - - lockWrapper.lock(); - } - } + messageLoopRun = true; + messageLoop(); inputMan->stop(); @@ -436,7 +415,7 @@ void Control::run() delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL; } -void Control::processMessage(Message* m) +void Control::dispatchMessage(Message* m) { logger->debug(TAG, "processing message {}", m->message); @@ -446,7 +425,7 @@ void Control::processMessage(Message* m) { case Message::SHUTDOWN: { - irun = false; + messageLoopRun = false; break; } case Message::STOP_PLAYBACK: @@ -523,19 +502,22 @@ void Control::processMessage(Message* m) } } } - else + else if (m->p_to == Message::BOXSTACK) { - /* FIXME - - Instead of sending through the boxstack, implement a more generic MessageReceiver interface - and have potential receivers register with something - When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message - This could all be done using the existing big control mutex to keep it simple - */ - - logger->debug(TAG, "Sending message to boxstack"); boxstack->processMessage(m); } + else if (m->p_to == Message::MOUSE_RECEIVER) + { + logger->debug(TAG, "Sending mouse message to boxstack for dispatch"); + boxstack->processMessage(m); + } + + else + { + m->to->processMessage(m); + } + + logger->debug(TAG, "done processing message {}", m->message); } void Control::handleCommand(int button) diff --git a/control.h b/control.h index 6bb6cae..68ca368 100644 --- a/control.h +++ b/control.h @@ -102,7 +102,6 @@ class Control : public MessageQueue LogNT* logger; bool initted{}; - bool irun{}; bool isStandby{}; bool firstBoot{true}; Boxx* wallpaper{}; @@ -113,7 +112,7 @@ class Control : public MessageQueue bool advMenus{}; ASLPrefList langcodes; - void processMessage(Message* m); + void dispatchMessage(Message* m); }; #endif diff --git a/input.cc b/input.cc index dcc4413..92ea2cd 100644 --- a/input.cc +++ b/input.cc @@ -150,7 +150,7 @@ void Input::sendInputKey(int key) Message* m = new Message(); m->message = Message::INPUT_EVENT; m->p_to = Message::CONTROL; - m->from = this; + m->from = NULL; m->parameter = key; MessageQueue::getInstance()->postMessage(m); } diff --git a/input.h b/input.h index 5b53613..74942fd 100644 --- a/input.h +++ b/input.h @@ -49,6 +49,8 @@ class Input: public AbstractOption virtual bool loadOptionsFromServer(VDR* vdr); virtual bool saveOptionstoServer(); + static void sendInputKey(int key); + void setHWCtoCommand(HWC_TYPE hcw, UCHAR command); void unsetHWC(HWC_TYPE hcw); void LoadKeysConfig(VDR* vdr, const char* keynum); @@ -146,8 +148,6 @@ class Input: public AbstractOption virtual UCHAR TranslateHWCFixed(HWC_TYPE code) = 0; UCHAR TranslateHWCList(HWC_TYPE code); UCHAR TranslateHWC(HWC_TYPE code); - - void sendInputKey(int key); }; #endif diff --git a/message.h b/message.h index 1b13703..4abaeb7 100644 --- a/message.h +++ b/message.h @@ -24,6 +24,8 @@ #include "defines.h" +class MessageReceiver; + class Message { public: @@ -42,7 +44,7 @@ class Message void* from{}; PreDefinedTarget p_to{NA}; // If this is set 'to' is ignored - void* to{}; + MessageReceiver* to{}; int message{}; ULONG parameter{}; ULONG tag{}; // use this for identifying which object / question is being replied to diff --git a/messagequeue.cc b/messagequeue.cc index 6bad8b4..51d67f2 100644 --- a/messagequeue.cc +++ b/messagequeue.cc @@ -17,6 +17,8 @@ along with VOMP. If not, see . */ +#include + #include "messagequeue.h" #include "message.h" @@ -26,7 +28,11 @@ static const char* TAG = "MessageQueue"; MessageQueue* MessageQueue::instance{}; -MessageQueue::MessageQueue() { instance = this; } +MessageQueue::MessageQueue() +{ + instance = this; + logger = LogNT::getInstance(); +} MessageQueue::~MessageQueue() { instance = NULL; } @@ -49,3 +55,96 @@ void MessageQueue::flushMessageQueue() for (auto m : messages) delete m; messages.clear(); } + +bool MessageQueue::receiverExists(MessageReceiver* mr) // call with lock.. +{ + ReceiversI ri = std::find(receivers.begin(), receivers.end(), mr); + return (ri != receivers.end()); +} + +void MessageQueue::addReceiver(MessageReceiver* newMR) +{ + std::lock_guard lg(messageQueueMutex); + + if (std::find(receivers.begin(), receivers.end(), newMR) == receivers.end()) + { + logger->debug(TAG, "addReceiver: not found, adding {}", (void*)newMR); + receivers.push_back(newMR); + } +} + +void MessageQueue::removeReceiver(MessageReceiver* toRemove) +{ + std::unique_lock ul(messageQueueMutex); + + // Ignore the issue of the pre-defined targets + // They outlive the message queue processing loop and therefore always exist + // So just check message->to + + while(1) + { + logger->debug(TAG, "Attempt remove receiver {}", (void*)toRemove); + + if (messageBeingProcessed && (messageBeingProcessed->to == toRemove)) + { + // The message currently being processed by Control is with the receiver we're trying to remove + // Release mutex, delay and retry + logger->info(TAG, "Remove delay! Does this ever happen? {}", (void*)toRemove); + + ul.unlock(); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + continue; + } + else + { + ReceiversI toRemoveI = std::find(receivers.begin(), receivers.end(), toRemove); + if (toRemoveI == receivers.end()) + { + logger->error(TAG, "Remove error 1 {}", (void*)toRemove); + return; + } + + receivers.erase(toRemoveI); + logger->debug(TAG, "Removed receiver {}", (void*)toRemove); + break; + } + } +} + +void MessageQueue::messageLoop() +{ + std::unique_lock lockWrapper(messageQueueMutex); // locks. unlocks on out-of-scope + + while(messageLoopRun) + { + messageQueueCond.wait(lockWrapper, [&] { return !messageLoopRun || !messages.empty(); }); + // locked + logger->debug(TAG, "woke"); + + if (!messageLoopRun) break; + + while(!messages.empty()) + { + messageBeingProcessed = messages.front(); + messages.pop_front(); + + if (!messageBeingProcessed->p_to && !receiverExists(messageBeingProcessed->to)) + { + // Receiver for this message has been deleted already + logger->debug(TAG, "Dropping message {} for non-existent receiver {}", (void*)messageBeingProcessed, (void*)messageBeingProcessed->to); + delete messageBeingProcessed; + messageBeingProcessed = NULL; + continue; + } + + logger->debug(TAG, "Dispatching message {} to {}", (void*)messageBeingProcessed, (void*)messageBeingProcessed->to); + + lockWrapper.unlock(); + dispatchMessage(messageBeingProcessed); + lockWrapper.lock(); + + delete messageBeingProcessed; + messageBeingProcessed = NULL; + } + } +} diff --git a/messagequeue.h b/messagequeue.h index 837d2a9..426244b 100644 --- a/messagequeue.h +++ b/messagequeue.h @@ -21,34 +21,63 @@ #define MESSAGEQUEUE_H #include +#include #include #include -class Message; +#include "message.h" // Allow user classes just to include messagequeue.h + +class LogNT; typedef std::deque MQueue; typedef std::deque::iterator MQueueI; +// Implement this in any class wanting to receive Messages +class MessageReceiver +{ + public: + virtual void processMessage(Message* m)=0; + // The implementing class must not call MessageQueue::removeReceiver() from within processMessage() + // Also, implementing class must be aware of not causing itself to be deleted during processMessage + // such as generating an input event which causes BoxStack to remove/delete the object + // This will cause the object's destructor to call removeReceiver() + // If in doubt, generate an input that goes in the MessageQueue, e.g. Input::sendInputKey(). +}; + +typedef std::list Receivers; +typedef std::list::iterator ReceiversI; + class MessageQueue { public: MessageQueue(); virtual ~MessageQueue(); - static MessageQueue* getInstance(); + void addReceiver(MessageReceiver* newReceiver); + void removeReceiver(MessageReceiver* toRemove); + virtual void postMessage(Message* m); protected: + void messageLoop(); + bool messageLoopRun{}; virtual void flushMessageQueue(); - virtual void processMessage(Message* m)=0; + virtual void dispatchMessage(Message* m)=0; // User class must implement and handle the message + + bool receiverExists(MessageReceiver*); MQueue messages; - std::mutex messageQueueMutex; - std::condition_variable messageQueueCond; + Receivers receivers; + + std::mutex messageQueueMutex; private: static MessageQueue* instance; + LogNT* logger{}; + + Message* messageBeingProcessed{}; + std::condition_variable messageQueueCond; }; #endif diff --git a/playerradiolive.cc b/playerradiolive.cc index f0cf33c..af92f72 100644 --- a/playerradiolive.cc +++ b/playerradiolive.cc @@ -40,7 +40,7 @@ static const char* TAG = "PlayerRadioLive"; // ----------------------------------- Called from outside, one offs or info funcs -PlayerRadioLive::PlayerRadioLive(MessageQueue* tmessageQueue, void* tmessageReceiver, ChannelList* tchanList) +PlayerRadioLive::PlayerRadioLive(MessageQueue* tmessageQueue, MessageReceiver* tmessageReceiver, ChannelList* tchanList) : messageQueue(tmessageQueue), messageReceiver(tmessageReceiver), afeed(this), chanList(tchanList) { audio = Audio::getInstance(); diff --git a/playerradiolive.h b/playerradiolive.h index 6d38e42..b2fa6e5 100644 --- a/playerradiolive.h +++ b/playerradiolive.h @@ -34,6 +34,7 @@ #include "vdr.h" class MessageQueue; +class MessageReceiver; class Audio; class LogNT; class DemuxerTS; @@ -41,7 +42,7 @@ class DemuxerTS; class PlayerRadioLive : public PlayerLive, public Callback, public StreamReceiver { public: - PlayerRadioLive(MessageQueue* messageQueue, void* messageReceiver, ChannelList* chanList); + PlayerRadioLive(MessageQueue* messageQueue, MessageReceiver* messageReceiver, ChannelList* chanList); virtual ~PlayerRadioLive(); virtual int init(); @@ -76,7 +77,7 @@ class PlayerRadioLive : public PlayerLive, public Callback, public StreamReceive private: MessageQueue* messageQueue; - void* messageReceiver; + MessageReceiver* messageReceiver; LogNT* logger; Audio* audio; DemuxerTS* demuxer; diff --git a/playerradiorec.cc b/playerradiorec.cc index 905f8aa..a4f881b 100644 --- a/playerradiorec.cc +++ b/playerradiorec.cc @@ -40,7 +40,7 @@ static const char* TAG = "PlayerRadioRec"; // ----------------------------------- Called from outside, one offs or info funcs -PlayerRadioRec::PlayerRadioRec(MessageQueue* tmessageQueue, void* tmessageReceiver) +PlayerRadioRec::PlayerRadioRec(MessageQueue* tmessageQueue, MessageReceiver* tmessageReceiver) : messageQueue(tmessageQueue), messageReceiver(tmessageReceiver), afeed(this) { audio = Audio::getInstance(); diff --git a/playerradiorec.h b/playerradiorec.h index 460290f..53d3fd7 100644 --- a/playerradiorec.h +++ b/playerradiorec.h @@ -34,6 +34,7 @@ class Video; class Demuxer; class VDR; class MessageQueue; +class MessageReceiver; /* * Frames... @@ -45,7 +46,7 @@ class MessageQueue; class PlayerRadioRec : public Callback { public: - PlayerRadioRec(MessageQueue* messageQueue, void* messageReceiver); + PlayerRadioRec(MessageQueue* messageQueue, MessageReceiver* messageReceiver); virtual ~PlayerRadioRec(); bool init(ULLONG lengthBytes, ULONG lengthFrames, bool IsPesRecording); @@ -87,7 +88,7 @@ class PlayerRadioRec : public Callback bool setLengthSeconds(); MessageQueue* messageQueue; - void* messageReceiver; + MessageReceiver* messageReceiver; LogNT* logger; Audio* audio; Demuxer* demuxer; diff --git a/playervideolive.cc b/playervideolive.cc index 0667fee..3a2e10e 100644 --- a/playervideolive.cc +++ b/playervideolive.cc @@ -44,7 +44,7 @@ static const char* TAG = "PlayerVideoLive"; // ----------------------------------- Called from outside, one offs or info funcs -PlayerVideoLive::PlayerVideoLive(MessageQueue* tmessageQueue, void* tmessageReceiver, OSDReceiver* tosdReceiver, ChannelList* tchanList) +PlayerVideoLive::PlayerVideoLive(MessageQueue* tmessageQueue, MessageReceiver* tmessageReceiver, OSDReceiver* tosdReceiver, ChannelList* tchanList) : vfeed(this), afeed(this), tfeed(this), messageQueue(tmessageQueue), messageReceiver(tmessageReceiver), osdReceiver(tosdReceiver), chanList(tchanList) { diff --git a/playervideolive.h b/playervideolive.h index 5b91f48..e2ada19 100644 --- a/playervideolive.h +++ b/playervideolive.h @@ -38,6 +38,7 @@ #include "teletextdecodervbiebu.h" class MessageQueue; +class MessageReceiver; class Audio; class Video; class LogNT; @@ -48,7 +49,7 @@ class DVBSubtitles; class PlayerVideoLive : public PlayerLive, public Callback, public StreamReceiver { public: - PlayerVideoLive(MessageQueue* messageQueue, void* messageReceiver, OSDReceiver* tosdReceiver, ChannelList* chanList); + PlayerVideoLive(MessageQueue* messageQueue, MessageReceiver* messageReceiver, OSDReceiver* tosdReceiver, ChannelList* chanList); virtual ~PlayerVideoLive(); virtual int init(); @@ -92,7 +93,7 @@ class PlayerVideoLive : public PlayerLive, public Callback, public StreamReceive AFeed afeed; TFeed tfeed; MessageQueue* messageQueue; - void* messageReceiver; + MessageReceiver* messageReceiver; OSDReceiver* osdReceiver; ChannelList* chanList; LogNT* logger; diff --git a/playervideorec.cc b/playervideorec.cc index 12ace22..afcdac0 100644 --- a/playervideorec.cc +++ b/playervideorec.cc @@ -40,7 +40,7 @@ static const char* TAG = "PlayerVideoRec"; // ----------------------------------- Called from outside, one offs or info funcs -PlayerVideoRec::PlayerVideoRec(MessageQueue* tmessageQueue, void* tmessageReceiver, OSDReceiver* tosdReceiver) +PlayerVideoRec::PlayerVideoRec(MessageQueue* tmessageQueue, MessageReceiver* tmessageReceiver, OSDReceiver* tosdReceiver) : vfeed(this), afeed(this), tfeed(this), osdReceiver(tosdReceiver), messageQueue(tmessageQueue), messageReceiver(tmessageReceiver) { diff --git a/playervideorec.h b/playervideorec.h index 5687ab5..100da8c 100644 --- a/playervideorec.h +++ b/playervideorec.h @@ -40,6 +40,7 @@ #include "teletextdecodervbiebu.h" class MessageQueue; +class MessageReceiver; class Audio; class Video; class VDR; @@ -52,7 +53,7 @@ class Channel; class PlayerVideoRec : public Callback { public: - PlayerVideoRec(MessageQueue* messageQueue, void* messageReceiver, OSDReceiver* osdReceiver); + PlayerVideoRec(MessageQueue* messageQueue, MessageReceiver* messageReceiver, OSDReceiver* osdReceiver); virtual ~PlayerVideoRec(); int init(bool p_isPesRecording,double framespersec); @@ -137,7 +138,7 @@ class PlayerVideoRec : public Callback TFeed tfeed; OSDReceiver* osdReceiver; MessageQueue* messageQueue; - void* messageReceiver; + MessageReceiver* messageReceiver; LogNT* logger; Audio* audio; Video* video; diff --git a/teletextdecodervbiebu.cc b/teletextdecodervbiebu.cc index 5a91d51..7d35b1f 100644 --- a/teletextdecodervbiebu.cc +++ b/teletextdecodervbiebu.cc @@ -821,14 +821,14 @@ void TeletextDecoderVBIEBU::RenderTeletextCode(bool renderfirstlineonly) { if ( !renderfirstlineonly) { Message* m= new Message(); m->message = Message::TELETEXTUPDATE; - m->to = txtview; + m->to = (MessageReceiver*)txtview; m->from = this; m->parameter = 0; MessageQueue::getInstance()->postMessage(m); } else if (firstlineupdate==10) { Message* m= new Message(); m->message = Message::TELETEXTUPDATEFIRSTLINE; - m->to = txtview; + m->to = (MessageReceiver*)txtview; m->from = this; m->parameter = 0; MessageQueue::getInstance()->postMessage(m); diff --git a/vaudioselector.cc b/vaudioselector.cc index 81e86a7..f4bae22 100644 --- a/vaudioselector.cc +++ b/vaudioselector.cc @@ -35,7 +35,7 @@ #include "vaudioselector.h" -VAudioSelector::VAudioSelector(void* tparent, bool* availableMpegAudioChannels, +VAudioSelector::VAudioSelector(MessageReceiver* tparent, bool* availableMpegAudioChannels, bool* availableAc3AudioChannels, int currentAudioChannel, bool* availableSubtitleChannels, int* ttxtpages, int currentSubtitleChannel, int currentSubtitleType, RecInfo* recInfo) : parent(tparent), liveMode(false) @@ -265,9 +265,11 @@ VAudioSelector::VAudioSelector(void* tparent, bool* availableMpegAudioChannels, } } } + + MessageQueue::getInstance()->addReceiver(this); } -VAudioSelector::VAudioSelector(void* tparent, Channel* channel, int currentAudioChannel, int currentSubtitletype, int currentSubtitleChannel, int* ttxtpages) +VAudioSelector::VAudioSelector(MessageReceiver* tparent, Channel* channel, int currentAudioChannel, int currentSubtitletype, int currentSubtitleChannel, int* ttxtpages) : parent(tparent), liveMode(true) { UINT i; @@ -382,10 +384,14 @@ VAudioSelector::VAudioSelector(void* tparent, Channel* channel, int currentAudio ssl.addOption(sc.name.c_str(), &sc, selected); } } + + MessageQueue::getInstance()->addReceiver(this); } VAudioSelector::~VAudioSelector() { + MessageQueue::getInstance()->removeReceiver(this); + Message* m = new Message(); m->from = this; m->to = parent; @@ -591,7 +597,7 @@ void VAudioSelector::processMessage(Message* m) asl.setDarkSelOption(false); asl.draw(); ssl.draw(); - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (ssl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { @@ -600,7 +606,7 @@ void VAudioSelector::processMessage(Message* m) asl.setDarkSelOption(true); asl.draw(); ssl.draw(); - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else { @@ -610,7 +616,7 @@ void VAudioSelector::processMessage(Message* m) if (x < 0 || y < 0 || x > static_cast(getWidth()) || y > static_cast(getHeight())) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } } diff --git a/vaudioselector.h b/vaudioselector.h index 8131190..4c9e8c1 100644 --- a/vaudioselector.h +++ b/vaudioselector.h @@ -24,6 +24,7 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wselectlist.h" class RecInfo; @@ -47,17 +48,17 @@ class AudioSubtitleChannel typedef std::vector AudioSubtitleChannelList; -class VAudioSelector : public TBBoxx +class VAudioSelector : public TBBoxx, public MessageReceiver { public: - VAudioSelector(void* parent, bool* availableMpegAudioChannels, // Recording mode + VAudioSelector(MessageReceiver* parent, bool* availableMpegAudioChannels, // Recording mode bool* availableAc3AudioChannels, int currentAudioChannel, bool* availableSubtitleChannels, int* ttxtpages, int currentSubtitleChannel, int currentSubtitleType, RecInfo* recInfo); - VAudioSelector(void* tparent, Channel* channel, int currentAudioChannel, + VAudioSelector(MessageReceiver* tparent, Channel* channel, int currentAudioChannel, int currentSubtitleChannel, int currentSubtitletype, int* ttxtpages); // Live mode virtual ~VAudioSelector(); @@ -70,7 +71,7 @@ class VAudioSelector : public TBBoxx WSelectList asl; WSelectList ssl; - void* parent; + MessageReceiver* parent; bool liveMode; bool subtitles{}; bool editsubtitles{}; diff --git a/vchannellist.cc b/vchannellist.cc index a47ba45..ff504f4 100644 --- a/vchannellist.cc +++ b/vchannellist.cc @@ -32,6 +32,8 @@ #include "vchannelselect.h" #include "staticartwork.h" +static const char* TAG = "VChannelList"; + VChannelList::VChannelList(ULONG ttype) { boxstack = BoxStack::getInstance(); @@ -69,10 +71,12 @@ VChannelList::VChannelList(ULONG ttype) sl.setPosition(10, 30 + 5); sl.setSize(area.w - 20, area.h - 30 - 15 - 30); add(&sl); + MessageQueue::getInstance()->addReceiver(this); } VChannelList::~VChannelList() { + MessageQueue::getInstance()->removeReceiver(this); if (chanList) { @@ -290,15 +294,16 @@ void VChannelList::processMessage(Message* m) { if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - boxstack->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (coordsOutsideBox(m)) { - boxstack->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } else if (m->message == Message::CHANNEL_CHANGE) { + LogNT::getInstance()->debug(TAG, "Channel change {}", m->parameter); Channel* chan = NULL; for (UINT i = 0; i < chanList->size(); i++) { diff --git a/vchannellist.h b/vchannellist.h index cb54db3..c3a82b2 100644 --- a/vchannellist.h +++ b/vchannellist.h @@ -26,15 +26,15 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "defines.h" #include "vdr.h" #include "wselectlist.h" class Channel; class BoxStack; -class Message; -class VChannelList : public TBBoxx +class VChannelList : public TBBoxx, public MessageReceiver { public: VChannelList(ULONG type); diff --git a/vchannelselect.cc b/vchannelselect.cc index 50bb59b..5a51ed1 100644 --- a/vchannelselect.cc +++ b/vchannelselect.cc @@ -29,7 +29,7 @@ // this class only works as it does because the remote command // values for the numbers are the numbers themselves ! -VChannelSelect::VChannelSelect(Boxx* v) +VChannelSelect::VChannelSelect(MessageReceiver* v) { parent = v; numGot = 0; diff --git a/vchannelselect.h b/vchannelselect.h index 00b84a6..b04237f 100644 --- a/vchannelselect.h +++ b/vchannelselect.h @@ -26,10 +26,12 @@ #include "boxx.h" #include "timers.h" +class MessageReceiver; + class VChannelSelect : public Boxx, public TimerReceiver { public: - VChannelSelect(Boxx* v); + VChannelSelect(MessageReceiver* v); ~VChannelSelect(); void draw(); @@ -37,7 +39,7 @@ class VChannelSelect : public Boxx, public TimerReceiver void timercall(int clientReference); private: - Boxx* parent; + MessageReceiver* parent; int input[10]; int numGot; diff --git a/vcolourtuner.cc b/vcolourtuner.cc index 2f3b0b0..2bfd378 100644 --- a/vcolourtuner.cc +++ b/vcolourtuner.cc @@ -51,10 +51,12 @@ VColourTuner::VColourTuner() vgfactor=gfactor; hasChanged=false; Log::getInstance()->log("VColourTuner",Log::DEBUG,"created %p",this); + MessageQueue::getInstance()->addReceiver(this); } VColourTuner::~VColourTuner() { + MessageQueue::getInstance()->removeReceiver(this); Log::getInstance()->log("VColourTuner",Log::DEBUG,"deleted %p",this); } @@ -221,7 +223,7 @@ void VColourTuner::processMessage(Message* m) { if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } else if (y>=(int)area.h-24 && y<=(int)area.h-6) { diff --git a/vcolourtuner.h b/vcolourtuner.h index 4a8c261..939416a 100644 --- a/vcolourtuner.h +++ b/vcolourtuner.h @@ -27,10 +27,11 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wjpeg.h" -class VColourTuner : public TBBoxx +class VColourTuner : public TBBoxx, public MessageReceiver { public: VColourTuner(); diff --git a/vconnect.cc b/vconnect.cc index 2621760..fc5018f 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -207,7 +207,7 @@ void VConnect::threadMethod() // Now numServers > 1 - VServerSelect* vs = new VServerSelect(vdpc, this); // deleted by handleCommand returning 4 + VServerSelect* vs = new VServerSelect(vdpc, this); // deleted by handleCommand returning BoxStack::DELETE_ME vs->draw(); boxstack->add(vs); boxstack->update(vs); diff --git a/vconnect.h b/vconnect.h index dfa6b8c..39cc41e 100644 --- a/vconnect.h +++ b/vconnect.h @@ -25,11 +25,11 @@ #include #include "vinfo.h" +#include "messagequeue.h" #include "vdpc.h" class LogNT; class BoxStack; -class Message; class VDRServer; class VConnect : public VInfo @@ -39,7 +39,7 @@ class VConnect : public VInfo ~VConnect(); int handleCommand(int command); - void processMessage(Message* m); + void processMessage(Message* m); // override void draw(); void run(); diff --git a/vepg.cc b/vepg.cc index a72f071..149d894 100644 --- a/vepg.cc +++ b/vepg.cc @@ -50,7 +50,7 @@ static const char* TAG = "VEpg"; VEpg* VEpg::instance = NULL; -VEpg::VEpg(void* tparent, UINT tcurrentChannelIndex, ChannelList* tchanList) +VEpg::VEpg(MessageReceiver* tparent, UINT tcurrentChannelIndex, ChannelList* tchanList) { instance = this; currentChannelIndex = tcurrentChannelIndex; @@ -181,6 +181,8 @@ VEpg::VEpg(void* tparent, UINT tcurrentChannelIndex, ChannelList* tchanList) vdisplay.y=10; vdisplay.width=Video::getInstance()->getScreenWidth()/2; vdisplay.height=Video::getInstance()->getScreenHeight()/2; + + MessageQueue::getInstance()->addReceiver(this); } void VEpg::preDelete() @@ -190,6 +192,7 @@ void VEpg::preDelete() VEpg::~VEpg() { + MessageQueue::getInstance()->removeReceiver(this); instance = NULL; @@ -771,7 +774,7 @@ void VEpg::processMessage(Message* m) { if (chanListbox.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - boxstack->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else { @@ -783,7 +786,7 @@ void VEpg::processMessage(Message* m) if (x<0 || y <0 || x>(int)getWidth() || y>(int)getHeight()) { - boxstack->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } else if (x>=(keyx+72) && y>=(keyy+4) &&x<=(keyx+72+104) &&y<=(keyy+4+getFontHeight() + 2)) { @@ -803,7 +806,7 @@ void VEpg::processMessage(Message* m) } else if (x>=(keyx+290) && y>=(keyy+4) &&x<=(keyx+180+290) &&y<=(keyy+4+getFontHeight() + 2)) { - boxstack->handleCommand(Input::BACK); + Input::sendInputKey(Input::BACK); } else if (x>=(keyx+290) && y>=(keyy+ getFontHeight() + 8) &&x<=(keyx+290+180) &&y<=(keyy+8+2*getFontHeight() + 2)) { diff --git a/vepg.h b/vepg.h index 098e5d5..c11c716 100644 --- a/vepg.h +++ b/vepg.h @@ -23,6 +23,7 @@ #include #include "boxx.h" +#include "messagequeue.h" #include "defines.h" #include "timers.h" #include "wtextbox.h" @@ -30,7 +31,6 @@ #include "wselectlist.h" #include "event.h" -class Message; class VVideoLive; class BoxStack; @@ -39,10 +39,10 @@ class BoxStack; class VVideoLive; -class VEpg : public Boxx, public TimerReceiver +class VEpg : public Boxx, public MessageReceiver, public TimerReceiver { public: - VEpg(void* parent, UINT currentChannel, ChannelList* tchanList); + VEpg(MessageReceiver* parent, UINT currentChannel, ChannelList* tchanList); ~VEpg(); static VEpg* getInstance(); @@ -80,7 +80,7 @@ class VEpg : public Boxx, public TimerReceiver void updateEventList(); void paintCell(Event* event, int yOffset, const DrawStyle& bg, const DrawStyle& fg); time_t prevHour(time_t* t); - void* parent; + MessageReceiver* parent; BoxStack* boxstack; UINT gridRows; UINT currentChannelIndex; diff --git a/vepglistadvanced.cc b/vepglistadvanced.cc index ab558d0..e09c7fb 100644 --- a/vepglistadvanced.cc +++ b/vepglistadvanced.cc @@ -42,7 +42,7 @@ static const char* TAG = "VEpgListAdvanced"; -VEpgListAdvanced::VEpgListAdvanced(VVideoLiveTV* tvideolive, ChannelList* tchanList, ULONG initialChannelNumber) +VEpgListAdvanced::VEpgListAdvanced(MessageReceiver* tvideolive, ChannelList* tchanList, ULONG initialChannelNumber) { channelNumber = initialChannelNumber; chanList = tchanList; @@ -122,10 +122,13 @@ VEpgListAdvanced::VEpgListAdvanced(VVideoLiveTV* tvideolive, ChannelList* tchanL setButtonText(); updateEpgDataChannel(); + + MessageQueue::getInstance()->addReceiver(this); } VEpgListAdvanced::~VEpgListAdvanced() { + MessageQueue::getInstance()->removeReceiver(this); clearEventList(); } @@ -934,7 +937,7 @@ void VEpgListAdvanced::processMessage(Message* m) int y = m->tag - getScreenY(); if (sl.mouseLBDOWN(x, y)) { - boxstack->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (boxRed.mouseLBDOWN(x, y)) { @@ -942,7 +945,7 @@ void VEpgListAdvanced::processMessage(Message* m) } else if (boxGreen.mouseLBDOWN(x, y)) { - boxstack->handleCommand(Input::GREEN); // FIXME all these green? is this right? + boxstack->handleCommand(Input::GREEN); // FIXME FIXME FIXME all these green? is this right? } else if (boxYellow.mouseLBDOWN(x, y)) { @@ -956,7 +959,7 @@ void VEpgListAdvanced::processMessage(Message* m) { if (coordsOutsideBox(m)) { - boxstack->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } } diff --git a/vepglistadvanced.h b/vepglistadvanced.h index 9f9ed5d..534a1b0 100644 --- a/vepglistadvanced.h +++ b/vepglistadvanced.h @@ -23,17 +23,17 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wtextbox.h" #include "wselectlist.h" #include "wtvmedia.h" class BoxStack; -class VVideoLiveTV; -class VEpgListAdvanced : public TBBoxx +class VEpgListAdvanced : public TBBoxx, public MessageReceiver { public: - VEpgListAdvanced(VVideoLiveTV* tvideolive, ChannelList* tchanList, ULONG initialChannelNumber); + VEpgListAdvanced(MessageReceiver* tvideolive, ChannelList* tchanList, ULONG initialChannelNumber); virtual ~VEpgListAdvanced(); void draw() { draw(false); } @@ -92,7 +92,7 @@ class VEpgListAdvanced : public TBBoxx ChannelList* chanList; ULONG channelNumber; - VVideoLiveTV* videolive; + MessageReceiver* videolive; Boxx boxRed; Boxx boxGreen; diff --git a/vepgsettimer.cc b/vepgsettimer.cc index edac8a8..15ffa4f 100644 --- a/vepgsettimer.cc +++ b/vepgsettimer.cc @@ -76,10 +76,13 @@ VEpgSetTimer::VEpgSetTimer(Event* tevent, Channel* tchannel) logger->debug(TAG, "Time: {}", event->time); logger->debug(TAG, "Duration: {}", event->duration); logger->debug(TAG, "Channel: {}", channel->number); + + MessageQueue::getInstance()->addReceiver(this); } VEpgSetTimer::~VEpgSetTimer() { + MessageQueue::getInstance()->removeReceiver(this); } char* VEpgSetTimer::genTimerString() @@ -307,15 +310,15 @@ void VEpgSetTimer::processMessage(Message* m) { if (buttonYes.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - boxstack->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (buttonNo.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - boxstack->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (coordsOutsideBox(m)) { - boxstack->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } } diff --git a/vepgsettimer.h b/vepgsettimer.h index 3cf7fff..2079b44 100644 --- a/vepgsettimer.h +++ b/vepgsettimer.h @@ -21,16 +21,16 @@ #define VEPGSETTIMER_H #include "tbboxx.h" +#include "messagequeue.h" #include "wbutton.h" class Event; class Channel; class LogNT; class VDR; -class Message; class BoxStack; -class VEpgSetTimer : public TBBoxx +class VEpgSetTimer : public TBBoxx, public MessageReceiver { public: VEpgSetTimer(Event* event, Channel* channel); diff --git a/vepgsummary.cc b/vepgsummary.cc index a78ce88..6d61eec 100644 --- a/vepgsummary.cc +++ b/vepgsummary.cc @@ -152,13 +152,14 @@ VEpgSummary::VEpgSummary(Event *tevent, Channel* tchannel) epgTVmedia.setVisible(false); } - - tabbar.activateFocus(true); + + MessageQueue::getInstance()->addReceiver(this); } VEpgSummary::~VEpgSummary() { + MessageQueue::getInstance()->removeReceiver(this); } @@ -232,7 +233,7 @@ void VEpgSummary::processMessage(Message* m) { if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } } diff --git a/vepgsummary.h b/vepgsummary.h index e7145b0..1484d17 100644 --- a/vepgsummary.h +++ b/vepgsummary.h @@ -24,25 +24,22 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wtvmedia.h" #include "wtextbox.h" #include "wtabbar.h" #include "movieinfo.h" #include "seriesinfo.h" -class VRecordingList; class Event; -class Message; class Channel; -class VEpgSummary : public TBBoxx +class VEpgSummary : public TBBoxx, public MessageReceiver { public: VEpgSummary(Event* event, Channel* tchannel); ~VEpgSummary(); - - int handleCommand(int command); void processMessage(Message* m); diff --git a/vinfo.cc b/vinfo.cc index 791b820..262b023 100644 --- a/vinfo.cc +++ b/vinfo.cc @@ -33,10 +33,13 @@ VInfo::VInfo() setTitleBarOn(1); setTitleBarColour(DrawStyle::TITLEBARBACKGROUND); + + MessageQueue::getInstance()->addReceiver(this); } VInfo::~VInfo() { + MessageQueue::getInstance()->removeReceiver(this); if (mainText) delete[] mainText; } @@ -115,6 +118,6 @@ void VInfo::processMessage(Message* m) { if (m->message == Message::MOUSE_LBDOWN) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } } diff --git a/vinfo.h b/vinfo.h index efbf621..a13e7c7 100644 --- a/vinfo.h +++ b/vinfo.h @@ -25,10 +25,11 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "defines.h" #include "wbutton.h" -class VInfo : public TBBoxx +class VInfo : public TBBoxx, public MessageReceiver { public: VInfo(); @@ -41,7 +42,7 @@ class VInfo : public TBBoxx void okButton(); virtual int handleCommand(int command); - void processMessage(Message* m); + virtual void processMessage(Message* m); void draw(); protected: diff --git a/vmedialist.cc b/vmedialist.cc index 360433d..6f46ffb 100644 --- a/vmedialist.cc +++ b/vmedialist.cc @@ -351,11 +351,13 @@ VMediaList::VMediaList() #ifndef WIN32 LocalMediaFile::init(); #endif + MessageQueue::getInstance()->addReceiver(this); } VMediaList::~VMediaList() { + MessageQueue::getInstance()->removeReceiver(this); Log::getInstance()->log("VMediaList::~VMediaList", Log::DEBUG, "start"); Timers::getInstance()->cancelTimer(this,1); Timers::getInstance()->cancelTimer(this,2); @@ -1077,11 +1079,11 @@ void VMediaList::processMessage(Message* m) if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { updateSelection(); - boxstack->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (coordsOutsideBox(m)) { - boxstack->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } else if (m->message == Message::PLAYER_EVENT) { diff --git a/vmedialist.h b/vmedialist.h index 0707547..9af61b1 100644 --- a/vmedialist.h +++ b/vmedialist.h @@ -26,11 +26,11 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wselectlist.h" #include "timers.h" class DirList; -class Message; class BoxStack; class Media; class MediaList; @@ -38,7 +38,7 @@ class MediaURI; class VMediaView; class MediaListHolder; -class VMediaList : public TBBoxx , public TimerReceiver +class VMediaList : public TBBoxx , public TimerReceiver, public MessageReceiver { public: VMediaList(); diff --git a/vmediaview.cc b/vmediaview.cc index 79036a5..31c5301 100644 --- a/vmediaview.cc +++ b/vmediaview.cc @@ -295,10 +295,12 @@ VMediaView::VMediaView(VMediaList *p) retriggerAudioInfo=false; audioBanner=NULL; drawingThread=new DrawingThread(this); + MessageQueue::getInstance()->addReceiver(this); } VMediaView::~VMediaView() { + MessageQueue::getInstance()->removeReceiver(this); Log::getInstance()->log("VMediaView::~VMediaView", Log::DEBUG, "p=%p,secondSfc=%s", this,(secondSurface()?"true":"false")); destroyPictureBanner(); if (currentPicture) delete currentPicture; @@ -704,7 +706,7 @@ void VMediaView::processMessage(Message* m) { if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } else if (m->message = Message::PLAYER_EVENT) { diff --git a/vmediaview.h b/vmediaview.h index 7d0bf63..9009e36 100644 --- a/vmediaview.h +++ b/vmediaview.h @@ -21,6 +21,7 @@ #define VMEDIAVIEW_H #include "boxx.h" +#include "messagequeue.h" #include "timers.h" #include "vmedialist.h" #include "colour.h" @@ -29,7 +30,6 @@ #include "imagereader.h" #define TESTCOLOURS -class Message; class VInfo; class AudioPlayer; class DrawingThread; @@ -43,7 +43,7 @@ class VPictureBanner; class MediaOptions; class VPreader; -class VMediaView : public Boxx, public TimerReceiver +class VMediaView : public Boxx, public TimerReceiver, public MessageReceiver { friend class VPReader; public: diff --git a/vopts.cc b/vopts.cc index 9890ce1..f396694 100644 --- a/vopts.cc +++ b/vopts.cc @@ -268,11 +268,15 @@ VOpts::VOpts() InputMan::getInstance()->addOptionsToPanes(2,&options,wop); Video::getInstance()->addOptionsToPanes(2,&options,wop); Audio::getInstance()->addOptionsToPanes(2,&options,wop); + + MessageQueue::getInstance()->addReceiver(this); } VOpts::~VOpts() { - // for (int i = 0; i < numPanes; i++) delete panes[i]; //Move to TabBar, Marten + MessageQueue::getInstance()->removeReceiver(this); + + // for (int i = 0; i < numPanes; i++) delete panes[i]; //Move to TabBar, Marten delete[] panes; for(std::vector::iterator j = options.begin(); j != options.end(); j++) delete *j; @@ -508,7 +512,7 @@ void VOpts::processMessage(Message* m) } else if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } } diff --git a/vopts.h b/vopts.h index af1269c..e260055 100644 --- a/vopts.h +++ b/vopts.h @@ -23,14 +23,14 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wtabbar.h" #include "i18n.h" #include "option.h" class Boxx; -class Message; -class VOpts : public TBBoxx +class VOpts : public TBBoxx, public MessageReceiver { public: VOpts(); diff --git a/vpicturebanner.cc b/vpicturebanner.cc index cf88c09..e266ab3 100644 --- a/vpicturebanner.cc +++ b/vpicturebanner.cc @@ -43,10 +43,13 @@ VPictureBanner::VPictureBanner(bool ld, bool sl) //TODO compute sizes from text rotsize=70; infsize=50; + + MessageQueue::getInstance()->addReceiver(this); } VPictureBanner::~VPictureBanner() { + MessageQueue::getInstance()->removeReceiver(this); LogNT::getInstance()->debug("VPictureBanner", "deleted {}", (void*)this); } @@ -109,7 +112,7 @@ void VPictureBanner::processMessage(Message* m) if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } else if (y >= (static_cast(area.h) - 24) && y <= static_cast(area.h) - 6) { diff --git a/vpicturebanner.h b/vpicturebanner.h index 27709ff..66fc98b 100644 --- a/vpicturebanner.h +++ b/vpicturebanner.h @@ -27,10 +27,11 @@ #include #include "tbboxx.h" +#include "messagequeue.h" class VPicture; -class VPictureBanner : public TBBoxx +class VPictureBanner : public TBBoxx, public MessageReceiver { public: VPictureBanner(bool shortInfo, bool slideshow); diff --git a/vquestion.cc b/vquestion.cc index fb8a3d3..f566aef 100644 --- a/vquestion.cc +++ b/vquestion.cc @@ -25,12 +25,9 @@ #include "i18n.h" #include "messagequeue.h" -VQuestion::VQuestion(void* treplyTo) +VQuestion::VQuestion(MessageReceiver* treplyTo) +: replyTo(treplyTo) { - replyTo = treplyTo; - mainText = NULL; - selectedOption = NO; - buttonYes.setPosition(40, 130); buttonNo.setPosition(140, 130); @@ -40,10 +37,13 @@ VQuestion::VQuestion(void* treplyTo) add(&buttonYes); add(&buttonNo); + + MessageQueue::getInstance()->addReceiver(this); } VQuestion::~VQuestion() { + MessageQueue::getInstance()->removeReceiver(this); if (mainText) delete[] mainText; } @@ -143,15 +143,15 @@ void VQuestion::processMessage(Message* m) { if (buttonYes.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (buttonNo.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } } diff --git a/vquestion.h b/vquestion.h index d061a55..5f8916a 100644 --- a/vquestion.h +++ b/vquestion.h @@ -24,12 +24,13 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wbutton.h" -class VQuestion : public TBBoxx +class VQuestion : public TBBoxx, public MessageReceiver { public: - VQuestion(void* replyTo); + VQuestion(MessageReceiver* replyTo); ~VQuestion(); void setDefault(UCHAR option); void setMainText(const char* title); @@ -42,12 +43,12 @@ class VQuestion : public TBBoxx const static UCHAR YES = 1; private: - void* replyTo; - char* mainText; + MessageReceiver* replyTo; + char* mainText{}; void swap(); - UCHAR selectedOption; + UCHAR selectedOption{NO}; WButton buttonYes; WButton buttonNo; diff --git a/vradiorec.cc b/vradiorec.cc index 8a6ada0..eae14e4 100644 --- a/vradiorec.cc +++ b/vradiorec.cc @@ -93,6 +93,8 @@ VRadioRec::VRadioRec(Recording* rec) barBlue.set(0, 0, 0, 128); barShowing = false; + + MessageQueue::getInstance()->addReceiver(this); } void VRadioRec::preDelete() @@ -103,8 +105,9 @@ void VRadioRec::preDelete() VRadioRec::~VRadioRec() { - if (playing) stopPlay(); + MessageQueue::getInstance()->removeReceiver(this); + if (playing) stopPlay(); // kill recInfo in case resumePoint has changed (likely) myRec->dropRecInfo(); diff --git a/vradiorec.h b/vradiorec.h index 278da93..fac271a 100644 --- a/vradiorec.h +++ b/vradiorec.h @@ -21,19 +21,19 @@ #define VRADIOREC_H #include "boxx.h" +#include "messagequeue.h" #include "timers.h" #include "defines.h" #include "colour.h" #include "region.h" class Recording; -class Message; class VDR; class Video; class PlayerRadioRec; class BoxStack; -class VRadioRec : public Boxx, public TimerReceiver +class VRadioRec : public Boxx, public MessageReceiver, public TimerReceiver { public: VRadioRec(Recording* rec); diff --git a/vrecmove.cc b/vrecmove.cc index 66e7720..8596143 100644 --- a/vrecmove.cc +++ b/vrecmove.cc @@ -61,13 +61,15 @@ VRecMove::VRecMove(RecMan* trecman) Directory* dir = recman->getRootDir(); sl.addOption("/", dir, 1); addDirs(dir, ""); + MessageQueue::getInstance()->addReceiver(this); } VRecMove::~VRecMove() { + MessageQueue::getInstance()->removeReceiver(this); } -void VRecMove::setParent(void* tparent) +void VRecMove::setParent(MessageReceiver* tparent) { parent = tparent; } @@ -156,11 +158,11 @@ void VRecMove::processMessage(Message* m) { if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } } diff --git a/vrecmove.h b/vrecmove.h index 1c6fa93..e67ac0d 100644 --- a/vrecmove.h +++ b/vrecmove.h @@ -25,25 +25,25 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wselectlist.h" class RecMan; class Directory; -class Message; -class VRecMove : public TBBoxx +class VRecMove : public TBBoxx, public MessageReceiver { public: VRecMove(RecMan* recman); ~VRecMove(); - void setParent(void* parent); + void setParent(MessageReceiver* parent); int handleCommand(int command); void draw(); void processMessage(Message* m); private: - void* parent; + MessageReceiver* parent; RecMan* recman; WSelectList sl; void addDirs(Directory* dir,const char* prefix); diff --git a/vrecording.cc b/vrecording.cc index 1fdca58..366fff8 100644 --- a/vrecording.cc +++ b/vrecording.cc @@ -144,13 +144,16 @@ VRecording::VRecording(RecMan* trecman, Recording* trec) button[selected].setActive(1); tabbar.activateFocus(false); + + MessageQueue::getInstance()->addReceiver(this); } VRecording::~VRecording() { + MessageQueue::getInstance()->removeReceiver(this); } -void VRecording::setParent(VRecordingList* tvRecList) +void VRecording::setParent(MessageReceiver* tvRecList) { vRecList = tvRecList; } @@ -409,7 +412,7 @@ void VRecording::processMessage(Message* m) { if (button[i].mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); buttons = true; cancel = false; break; @@ -427,7 +430,7 @@ void VRecording::processMessage(Message* m) { if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } } diff --git a/vrecording.h b/vrecording.h index 9cab393..6bd4682 100644 --- a/vrecording.h +++ b/vrecording.h @@ -25,21 +25,20 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wbutton.h" #include "wtextbox.h" #include "wtabbar.h" -class VRecordingList; class RecMan; class Recording; -class Message; -class VRecording : public TBBoxx +class VRecording : public TBBoxx, public MessageReceiver { public: VRecording(RecMan* recman, Recording* rec); ~VRecording(); - void setParent(VRecordingList* tvRecList); + void setParent(MessageReceiver* tvRecList); void draw(); @@ -48,7 +47,7 @@ class VRecording : public TBBoxx private: RecMan* recman; - VRecordingList* vRecList; + MessageReceiver* vRecList; Recording* rec; WTabBar tabbar; WTextbox* epgSummaryTextBox; diff --git a/vrecordinglist.cc b/vrecordinglist.cc index 86a83bb..39bb912 100644 --- a/vrecordinglist.cc +++ b/vrecordinglist.cc @@ -44,11 +44,12 @@ VRecordingList::VRecordingList() boxstack = BoxStack::getInstance(); recman = NULL; loading = true; - + MessageQueue::getInstance()->addReceiver(this); } VRecordingList::~VRecordingList() { + MessageQueue::getInstance()->removeReceiver(this); delete recman; } @@ -68,11 +69,11 @@ void VRecordingList::processMessage(Message* m) { if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - boxstack->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (coordsOutsideBox(m)) { - boxstack->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } else if (m->message == Message::DELETE_SELECTED_RECORDING) diff --git a/vrecordinglist.h b/vrecordinglist.h index 21411e9..c3dc7c5 100644 --- a/vrecordinglist.h +++ b/vrecordinglist.h @@ -28,15 +28,15 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wselectlist.h" -class Message; class BoxStack; class RecMan; class Directory; class Recording; -class VRecordingList : public TBBoxx +class VRecordingList : public TBBoxx, public MessageReceiver { public: VRecordingList(); diff --git a/vrecordingmenu.cc b/vrecordingmenu.cc index 73c78a9..b5c8c84 100644 --- a/vrecordingmenu.cc +++ b/vrecordingmenu.cc @@ -31,7 +31,6 @@ #include "vrecmove.h" #include "boxstack.h" #include "recman.h" -#include "vrecordinglist.h" #include "recording.h" #include "message.h" @@ -64,13 +63,16 @@ VRecordingMenu::VRecordingMenu(RecMan* trecman) sl.addOption(tr("Move"), reinterpret_cast(4), 0); sl.addOption(tr("Delete"), reinterpret_cast(5), 0); add(&sl); + + MessageQueue::getInstance()->addReceiver(this); } VRecordingMenu::~VRecordingMenu() { + MessageQueue::getInstance()->removeReceiver(this); } -void VRecordingMenu::setParent(VRecordingList* tvRecList) +void VRecordingMenu::setParent(MessageReceiver* tvRecList) { vRecList = tvRecList; } @@ -208,11 +210,11 @@ void VRecordingMenu::processMessage(Message* m) { if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } else if (m->message == Message::QUESTION_YES) diff --git a/vrecordingmenu.h b/vrecordingmenu.h index c67729b..2ac0b3a 100644 --- a/vrecordingmenu.h +++ b/vrecordingmenu.h @@ -24,19 +24,18 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wselectlist.h" -class VRecordingList; class RecMan; class Recording; -class Message; -class VRecordingMenu : public TBBoxx +class VRecordingMenu : public TBBoxx, public MessageReceiver { public: VRecordingMenu(RecMan* recman); ~VRecordingMenu(); - void setParent(VRecordingList* tvRecList); + void setParent(MessageReceiver* tvRecList); void setRecording(Recording* rec); int handleCommand(int command); @@ -45,7 +44,7 @@ class VRecordingMenu : public TBBoxx private: RecMan* recman; WSelectList sl; - VRecordingList* vRecList; + MessageReceiver* vRecList; Recording* rec; }; diff --git a/vserverselect.cc b/vserverselect.cc index 26d22b4..38f5c4c 100644 --- a/vserverselect.cc +++ b/vserverselect.cc @@ -27,7 +27,7 @@ #include "vserverselect.h" -VServerSelect::VServerSelect(const VDPC& servers, void* treplyTo) +VServerSelect::VServerSelect(const VDPC& servers, MessageReceiver* treplyTo) { setSize(300, 200); createBuffer(); @@ -55,10 +55,12 @@ VServerSelect::VServerSelect(const VDPC& servers, void* treplyTo) } replyTo = treplyTo; + MessageQueue::getInstance()->addReceiver(this); } VServerSelect::~VServerSelect() { + MessageQueue::getInstance()->removeReceiver(this); } void VServerSelect::draw() @@ -112,7 +114,8 @@ void VServerSelect::processMessage(Message* m) { if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + // FIXME - this probably also breaks + Input::sendInputKey(Input::OK); } } } diff --git a/vserverselect.h b/vserverselect.h index 650a751..c3834ed 100644 --- a/vserverselect.h +++ b/vserverselect.h @@ -21,15 +21,14 @@ #define VSERVERSELECT_H #include "tbboxx.h" +#include "messagequeue.h" #include "vdpc.h" #include "wselectlist.h" -class Message; - -class VServerSelect : public TBBoxx +class VServerSelect : public TBBoxx, public MessageReceiver { public: - VServerSelect(const VDPC&, void* replyTo); + VServerSelect(const VDPC&, MessageReceiver* replyTo); ~VServerSelect(); int handleCommand(int command); @@ -38,7 +37,7 @@ class VServerSelect : public TBBoxx private: WSelectList sl; - void* replyTo; + MessageReceiver* replyTo; }; #endif diff --git a/vteletextview.cc b/vteletextview.cc index d969228..e8238d4 100644 --- a/vteletextview.cc +++ b/vteletextview.cc @@ -49,10 +49,13 @@ VTeletextView::VTeletextView(TeletextDecoderVBIEBU* TTdecoder, Boxx* playerview, createBuffer(); keyindigit = 1; page = 0x100; + + MessageQueue::getInstance()->addReceiver(this); } VTeletextView::~VTeletextView() { + MessageQueue::getInstance()->removeReceiver(this); LogNT::getInstance()->debug("VTeletextView", "destruct"); pv->draw(); BoxStack::getInstance()->update(pv); diff --git a/vteletextview.h b/vteletextview.h index 819ebb0..da02a59 100644 --- a/vteletextview.h +++ b/vteletextview.h @@ -21,12 +21,12 @@ #define VTELETEXTVIEW_H #include "boxx.h" - +#include "messagequeue.h" #include "teletextdecodervbiebu.h" class PlayerVideoLive; -class VTeletextView : public Boxx +class VTeletextView : public Boxx, public MessageReceiver { public: VTeletextView(TeletextDecoderVBIEBU* TTdecoder, Boxx* playerview, PlayerVideoLive* palyerObj); diff --git a/vtimeredit.cc b/vtimeredit.cc index 291d1b4..c11c282 100644 --- a/vtimeredit.cc +++ b/vtimeredit.cc @@ -1,4 +1,3 @@ - /* Copyright 2004-2005 Chris Tallon @@ -60,13 +59,15 @@ VTimerEdit::VTimerEdit(RecTimer* trt) TVMediaInfo *info= new TVMediaInfo(); info->setStaticArtwork(sa_timers); setTitleBarIcon(info); + MessageQueue::getInstance()->addReceiver(this); } VTimerEdit::~VTimerEdit() { + MessageQueue::getInstance()->removeReceiver(this); } -void VTimerEdit::setParent(VTimerList* tvTimerList) +void VTimerEdit::setParent(MessageReceiver* tvTimerList) { vTimerList = tvTimerList; } @@ -253,7 +254,7 @@ void VTimerEdit::processMessage(Message* m) } else if (m->message == Message::MOUSE_LBDOWN) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (m->message == Message::QUESTION_YES) { diff --git a/vtimeredit.h b/vtimeredit.h index 9f230aa..f07ebef 100644 --- a/vtimeredit.h +++ b/vtimeredit.h @@ -24,13 +24,12 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "wbutton.h" -class VTimerList; class RecTimer; -class Message; -class VTimerEdit : public TBBoxx +class VTimerEdit : public TBBoxx, public MessageReceiver { public: VTimerEdit(RecTimer* rt); @@ -39,12 +38,12 @@ class VTimerEdit : public TBBoxx void draw(); int handleCommand(int command); void processMessage(Message* m); - void setParent(VTimerList* tvTimerList); + void setParent(MessageReceiver* tvTimerList); private: void swap(); RecTimer* recTimer; - VTimerList* vTimerList; + MessageReceiver* vTimerList; WButton buttonBack; WButton buttonDelete; UINT selectedButton; diff --git a/vtimerlist.cc b/vtimerlist.cc index 058835c..f588620 100644 --- a/vtimerlist.cc +++ b/vtimerlist.cc @@ -73,6 +73,8 @@ VTimerList::VTimerList() sl.setPosition(30, 30 + 5); sl.setSize(area.w - 40, area.h - 30 - 15 - 30); add(&sl); + + MessageQueue::getInstance()->addReceiver(this); } void VTimerList::preDelete() @@ -82,6 +84,8 @@ void VTimerList::preDelete() VTimerList::~VTimerList() { + MessageQueue::getInstance()->removeReceiver(this); + if (recTimerList) { for (UINT i = 0; i < recTimerList->size(); i++) @@ -329,11 +333,11 @@ void VTimerList::processMessage(Message* m) { if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } else if (coordsOutsideBox(m)) { - BoxStack::getInstance()->handleCommand(Input::BACK); //simulate cancel press + Input::sendInputKey(Input::BACK); } } else if (m->message == Message::DELETE_SELECTED_TIMER) diff --git a/vtimerlist.h b/vtimerlist.h index 966ac37..0666d21 100644 --- a/vtimerlist.h +++ b/vtimerlist.h @@ -23,12 +23,11 @@ #include "vdr.h" #include "tbboxx.h" #include "timers.h" +#include "messagequeue.h" #include "wselectlist.h" #include "region.h" -class Message; - -class VTimerList : public TBBoxx, public TimerReceiver +class VTimerList : public TBBoxx, public TimerReceiver, public MessageReceiver { public: VTimerList(); diff --git a/vvideolivetv.cc b/vvideolivetv.cc index 2c0b622..66dd4ba 100644 --- a/vvideolivetv.cc +++ b/vvideolivetv.cc @@ -273,6 +273,8 @@ VVideoLiveTV::VVideoLiveTV(ChannelList* tchanList, ULONG initialChannelNumber, V vdisplay.y = 0; vdisplay.width = 0; vdisplay.height = 0; + + MessageQueue::getInstance()->addReceiver(this); } void VVideoLiveTV::preDelete() @@ -282,6 +284,7 @@ void VVideoLiveTV::preDelete() VVideoLiveTV::~VVideoLiveTV() { + MessageQueue::getInstance()->removeReceiver(this); delete player; video->setDefaultAspect(); delData(); diff --git a/vvideolivetv.h b/vvideolivetv.h index 7d083c2..baa4d76 100644 --- a/vvideolivetv.h +++ b/vvideolivetv.h @@ -25,6 +25,7 @@ #include #include +#include "messagequeue.h" #include "boxx.h" #include "region.h" #include "vdr.h" @@ -45,7 +46,7 @@ class PlayerLive; class VAudioSelector; class Bitmap; -class VVideoLiveTV : public Boxx, public TimerReceiver, public OSDReceiver +class VVideoLiveTV : public Boxx, public MessageReceiver, public TimerReceiver, public OSDReceiver { public: VVideoLiveTV(ChannelList* chanList, ULONG initialChannelNumber, VChannelList* vchannelList); diff --git a/vvideomedia.cc b/vvideomedia.cc index c2aa626..e56068e 100644 --- a/vvideomedia.cc +++ b/vvideomedia.cc @@ -106,10 +106,12 @@ VVideoMedia::VVideoMedia(Media* media, VMediaList *p) wssRegion.w = video->getScreenWidth(); wssRegion.h = 300; } + MessageQueue::getInstance()->addReceiver(this); } VVideoMedia::~VVideoMedia() { + MessageQueue::getInstance()->removeReceiver(this); Log::getInstance()->log("VVideoMedia", Log::DEBUG, "Entering destructor"); if (vas) @@ -337,7 +339,7 @@ void VVideoMedia::processMessage(Message* m) if (!barShowing) { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate rok press + Input::sendInputKey(Input::OK); } else if (barRegion.x<=x && barRegion.y<=y && (barRegion.x+barRegion.w)>=x && (barRegion.y+barRegion.h)>=y) { @@ -358,7 +360,7 @@ void VVideoMedia::processMessage(Message* m) } else { - BoxStack::getInstance()->handleCommand(Input::OK); //simulate rok press + Input::sendInputKey(Input::OK); } } else if (m->message == Message::PLAYER_EVENT) diff --git a/vvideomedia.h b/vvideomedia.h index dbf7a53..8f0c738 100644 --- a/vvideomedia.h +++ b/vvideomedia.h @@ -24,6 +24,7 @@ #include #include "boxx.h" +#include "messagequeue.h" #include "timers.h" #include "wwss.h" #include "region.h" @@ -33,14 +34,12 @@ class PlayerMedia; class Recording; class VAudioSelector; -class Message; class BoxStack; class VInfo; class Media; class VMediaList; - -class VVideoMedia : public Boxx, public TimerReceiver +class VVideoMedia : public Boxx, public TimerReceiver, public MessageReceiver { public: VVideoMedia(Media* myMedia,VMediaList *lparent); //media has to contain URI @@ -51,8 +50,6 @@ class VVideoMedia : public Boxx, public TimerReceiver void timercall(int clientReference); void processMessage(Message* m); - - private: BoxStack* boxstack; Video* video; diff --git a/vvideorec.h b/vvideorec.h index b041e08..ef6ea28 100644 --- a/vvideorec.h +++ b/vvideorec.h @@ -23,6 +23,7 @@ #include #include "boxx.h" +#include "messagequeue.h" #include "timers.h" #include "region.h" #include "colour.h" @@ -34,7 +35,6 @@ class VDR; class PlayerVideoRec; class Recording; class VAudioSelector; -class Message; class BoxStack; class VInfo; class Bitmap; @@ -42,7 +42,7 @@ class Bitmap; //#include "vepg.h" // for testing EPG in NTSC with a NTSC test video -class VVideoRec : public Boxx, public TimerReceiver, public OSDReceiver +class VVideoRec : public Boxx, public MessageReceiver, public TimerReceiver, public OSDReceiver { public: VVideoRec(Recording* rec, bool ish264); diff --git a/vwelcome.cc b/vwelcome.cc index e80349b..e9468c1 100644 --- a/vwelcome.cc +++ b/vwelcome.cc @@ -132,7 +132,7 @@ VWelcome::VWelcome() sl.addOption(tr("7. Exit"), reinterpret_cast(7), 0,info); #endif - + MessageQueue::getInstance()->addReceiver(this); } void VWelcome::preDelete() @@ -142,6 +142,7 @@ void VWelcome::preDelete() VWelcome::~VWelcome() { + MessageQueue::getInstance()->removeReceiver(this); } void VWelcome::draw() @@ -405,7 +406,7 @@ void VWelcome::processMessage(Message* m) { if (sl.mouseLBDOWN(m->parameter - getScreenX(), m->tag - getScreenY())) { - boxstack->handleCommand(Input::OK); //simulate OK press + Input::sendInputKey(Input::OK); } } } diff --git a/vwelcome.h b/vwelcome.h index a0dfecc..a68741f 100644 --- a/vwelcome.h +++ b/vwelcome.h @@ -25,6 +25,7 @@ #include #include "tbboxx.h" +#include "messagequeue.h" #include "timers.h" #include "wselectlist.h" #ifndef GRADIENT_DRAWING @@ -36,10 +37,9 @@ #include "region.h" #include "defines.h" -class Message; class BoxStack; -class VWelcome : public TBBoxx, public TimerReceiver +class VWelcome : public TBBoxx, public TimerReceiver, public MessageReceiver { public: VWelcome(); -- 2.39.5