From 66caa5056aa344381e0aebac3e6c39fc5d795783 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 14 Apr 2020 21:22:42 +0100 Subject: [PATCH] Message predefined targets. Converted all m->to=Command::getInstance calls --- boxstack.cc | 3 +-- command.cc | 2 +- input.cc | 3 +-- message.h | 12 +++++++++++- osdopenvg.cc | 6 +++--- osdwinvector.cc | 11 ++++------- vconnect.cc | 2 +- vopts.cc | 16 +++++++--------- vopts.h | 8 +++----- vradiorec.cc | 4 ++-- vsleeptimer.cc | 4 ++-- vvideomedia.cc | 3 +-- vvideorec.cc | 4 ++-- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/boxstack.cc b/boxstack.cc index f145525..f5c3c68 100644 --- a/boxstack.cc +++ b/boxstack.cc @@ -19,7 +19,6 @@ #include "boxstack.h" -#include "command.h" #include "messagequeue.h" #include "input.h" #include "log.h" @@ -166,7 +165,7 @@ int BoxStack::remove(Boxx* toDelete) if (numBoxes == 1) { Message* m = new Message(); - m->to = Command::getInstance(); + m->p_to = Message::CONTROL; m->message = Message::LAST_VIEW_CLOSE; MessageQueue::getInstance()->postMessage(m); } diff --git a/command.cc b/command.cc index 4dcb98b..34bc1e6 100644 --- a/command.cc +++ b/command.cc @@ -231,7 +231,7 @@ void Command::processMessage(Message* m) logger->log("Command", Log::DEBUG, "processing message %i", m->message); - if (m->to == this) + if ((m->p_to == Message::CONTROL) || (m->to == this)) { switch(m->message) { diff --git a/input.cc b/input.cc index 67b7298..030ac76 100644 --- a/input.cc +++ b/input.cc @@ -24,7 +24,6 @@ #include "wtabbar.h" #include "message.h" #include "messagequeue.h" -#include "command.h" // FIXME - get rid after predefined message targets #include "inputman.h" #include "input.h" @@ -148,7 +147,7 @@ void Input::sendInputKey(int key) { Message* m = new Message(); m->message = Message::INPUT_EVENT; - m->to = Command::getInstance(); + m->p_to = Message::CONTROL; m->from = this; m->parameter = key; MessageQueue::getInstance()->postMessage(m); diff --git a/message.h b/message.h index 91e20f5..c709b80 100644 --- a/message.h +++ b/message.h @@ -31,14 +31,23 @@ // 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 +// So that the sources can be grepped for proper message usage class Message { public: + + enum PreDefinedTarget + { + NA = 0, + CONTROL, + BOXSTACK + }; + Message(); void* from{}; + PreDefinedTarget p_to{NA}; // If this is set 'to' is ignored void* to{}; ULONG message{}; ULONG parameter{}; @@ -80,6 +89,7 @@ class Message const static ULONG NEW_PICTURE_STATIC = 37; const static ULONG REDRAW = 38; const static ULONG SHUTDOWN = 39; + }; #endif diff --git a/osdopenvg.cc b/osdopenvg.cc index 7bb56e3..51119cf 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -27,7 +27,7 @@ #include "videoomx.h" #include "surface.h" #include "message.h" -#include "command.h" +#include "messagequeue.h" #include "teletxt/txtfont.h" #include "osdopenvg.h" @@ -1219,7 +1219,7 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) Message* m = new Message(); // We have a pictures! send a message to ourself, to switch to gui thread m->from=this; - m->to=Command::getInstance(); + m->p_to = Message::CONTROL; m->data = reinterpret_cast(handle); if (!static_image) { m->message=Message::NEW_PICTURE; @@ -1258,7 +1258,7 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) if (info->lindex & 0xffffffff) static_image=false; Message* m = new Message(); m->from=this; - m->to=Command::getInstance(); + m->p_to = Message::CONTROL; m->data = reinterpret_cast(info->handle); if (!static_image) { m->message=Message::NEW_PICTURE; diff --git a/osdwinvector.cc b/osdwinvector.cc index d6c7b34..5e86c4a 100644 --- a/osdwinvector.cc +++ b/osdwinvector.cc @@ -17,24 +17,21 @@ along with VOMP. If not, see . */ +#include -#include "osdwinvector.h" #include "videowin.h" #include "surfacewin.h" - - #include "message.h" #include "messagequeue.h" - #include "teletxt/txtfont.h" -#include - #define OSD_BUFFER_WIDTH 1280 #define OSD_BUFFER_HEIGHT 720 #include "staticartwork.h" +#include "osdwinvector.h" + #define EXTERNALPICTURE(name, fname, fileextension) #name, char *ext_pict_name[] { @@ -1239,7 +1236,7 @@ void OsdWinVector::createPicture(struct PictureInfo& pict_inf) Message* m = new Message(); // We have a pictures! send a message to ourself, to switch to gui thread m->from = this; - m->to = Command::getInstance(); + m->p_to = Message::CONTROL; m->data = pict_inf.reference; if (!static_image) { m->message = Message::NEW_PICTURE; diff --git a/vconnect.cc b/vconnect.cc index 3786bca..a13d903 100644 --- a/vconnect.cc +++ b/vconnect.cc @@ -193,7 +193,7 @@ void VConnect::threadMethod() logger->log("VConnect", Log::INFO, "Send VDR connected message"); Message* m = new Message(); // Must be done after this thread ends m->from = this; - m->to = Command::getInstance(); + m->p_to = Message::CONTROL; m->message = Message::VDR_CONNECTED; MessageQueue::getInstance()->postMessage(m); } diff --git a/vopts.cc b/vopts.cc index 1482353..20b9be9 100644 --- a/vopts.cc +++ b/vopts.cc @@ -14,12 +14,10 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ -#include "vopts.h" - +#include "defines.h" #include "colour.h" #include "video.h" #include "osd.h" @@ -32,15 +30,16 @@ #include "log.h" #include "option.h" #include "vdr.h" +#include "messagequeue.h" +#include "message.h" #include "command.h" #include "staticartwork.h" #ifdef VOMP_PLATTFORM_MVP #include "mediaoptions.h" #endif -//#include "vdr.h" -#include "command.h" -#include "messagequeue.h" + +#include "vopts.h" VOpts::VOpts() { @@ -51,7 +50,6 @@ VOpts::VOpts() info->setStaticArtwork(sa_properties); setTitleBarIcon(info); - setSize(520, 360); createBuffer(); if (Video::getInstance()->getFormat() == Video::PAL) @@ -366,7 +364,7 @@ void VOpts::doSave() { Message* m = new Message(); m->message = Message::CHANGE_LANGUAGE; - m->to = Command::getInstance(); + m->p_to = Message::CONTROL; MessageQueue::getInstance()->postMessage(m); break; } diff --git a/vopts.h b/vopts.h index e2e2da3..af1269c 100644 --- a/vopts.h +++ b/vopts.h @@ -14,23 +14,21 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with VOMP; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + along with VOMP. If not, see . */ #ifndef VOPTS_H #define VOPTS_H +#include #include "tbboxx.h" -#include "defines.h" #include "wtabbar.h" #include "i18n.h" #include "option.h" -#include class Boxx; - +class Message; class VOpts : public TBBoxx { diff --git a/vradiorec.cc b/vradiorec.cc index dec56c2..0e6bc68 100644 --- a/vradiorec.cc +++ b/vradiorec.cc @@ -315,7 +315,7 @@ void VRadioRec::processMessage(Message* m) { // I can't handle this, send it to command Message* m2 = new Message(); - m2->to = Command::getInstance(); + m2->p_to = Message::CONTROL; m2->message = Message::CONNECTION_LOST; MessageQueue::getInstance()->postMessage(m2); break; @@ -324,7 +324,7 @@ void VRadioRec::processMessage(Message* m) { // FIXME Obselete ish - improve this Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex - m2->to = Command::getInstance(); + m2->p_to = Message::CONTROL; m2->message = Message::STOP_PLAYBACK; MessageQueue::getInstance()->postMessage(m2); break; diff --git a/vsleeptimer.cc b/vsleeptimer.cc index 9ba949f..5acb22d 100644 --- a/vsleeptimer.cc +++ b/vsleeptimer.cc @@ -24,7 +24,7 @@ #include "colour.h" #include "video.h" #include "boxstack.h" -#include "command.h" +#include "message.h" #include "messagequeue.h" Sleeptimer* Sleeptimer::instance = NULL; @@ -169,7 +169,7 @@ void Sleeptimer::threadMethod() { Message* m2 = new Message(); m2->message = Message::INPUT_EVENT; - m2->to = Command::getInstance(); + m2->p_to = Message::CONTROL; m2->from = this; m2->parameter = Input::POWER; MessageQueue::getInstance()->postMessage(m2); diff --git a/vvideomedia.cc b/vvideomedia.cc index b2f26c8..8393920 100644 --- a/vvideomedia.cc +++ b/vvideomedia.cc @@ -22,7 +22,6 @@ #include "media.h" #include "mediaplayer.h" -#include "command.h" #include "osd.h" #include "wsymbol.h" #include "audio.h" @@ -371,7 +370,7 @@ void VVideoMedia::processMessage(Message* m) { // I can't handle this, send it to command Message* m2 = new Message(); - m2->to = Command::getInstance(); + m2->p_to = Message::CONTROL; m2->message = Message::CONNECTION_LOST; MessageQueue::getInstance()->postMessage(m2); break; diff --git a/vvideorec.cc b/vvideorec.cc index b428cea..7fe5c86 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -522,7 +522,7 @@ void VVideoRec::processMessage(Message* m) { // I can't handle this, send it to command Message* m2 = new Message(); - m2->to = Command::getInstance(); + m2->p_to = Message::CONTROL; m2->message = Message::CONNECTION_LOST; MessageQueue::getInstance()->postMessage(m2); break; @@ -531,7 +531,7 @@ void VVideoRec::processMessage(Message* m) { // FIXME Obselete ish - improve this Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex - m2->to = Command::getInstance(); + m2->p_to = Message::CONTROL; m2->message = Message::STOP_PLAYBACK; MessageQueue::getInstance()->postMessage(m2); break; -- 2.39.5