Go to the documentation of this file.
2 #include <QApplication>
17 #define LOC QString("MythSystemEventHandler: ")
45 void run(
void)
override
52 QString(
"Finished '%1' result %2")
59 QString(
"SYSTEM_EVENT_RESULT %1 SENDER %2 RESULT %3")
77 setObjectName(
"MythSystemEventHandler");
107 if (command.isEmpty())
110 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"SubstituteMatches: BEFORE: %1")
114 QDateTime recstartts;
116 QStringList::const_iterator it = tokens.begin();
118 command.replace(QString(
"%EVENTNAME%"), *it);
121 while (it != tokens.end())
129 if ((*it ==
"CARDID") ||
130 (*it ==
"COMMAND") ||
131 (*it ==
"RECSTATUS") ||
132 (*it ==
"HOSTNAME") ||
136 (*it ==
"VIDEODEVICE") ||
137 (*it ==
"VBIDEVICE"))
141 if (++it == tokens.end())
146 command.replace(QString(
"%" "%1" "%").
arg(token), *it);
157 if (++it == tokens.end())
160 chanid = (*it).toUInt();
167 if (*it ==
"STARTTIME")
169 if (++it == tokens.end())
182 command.replace(QString(
"%ARGS%"),
args);
193 RecordingInfo recinfo2(chanid, recstartts,
false, 0h, &status);
199 command.replace(QString(
"%CHANID%"), QString::number(chanid));
200 command.replace(QString(
"%STARTTIME%"),
203 command.replace(QString(
"%STARTTIMEISO%"),
208 command.replace(QString(
"%VERBOSELEVEL%"), QString(
"%1").
arg(
verboseMask));
211 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"SubstituteMatches: AFTER : %1")
226 QString result(
"EventCmd");
227 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
228 QStringList parts = name.toLower().split(
'_', QString::SkipEmptyParts);
230 QStringList parts = name.toLower().split(
'_', Qt::SkipEmptyParts);
233 for (
const auto & part : qAsConst(parts))
235 result += part.at(0).toUpper();
236 result += part.midRef(1);
264 QString msg = me->
Message().simplified();
266 if (msg ==
"CLEAR_SETTINGS_CACHE")
267 msg =
"SYSTEM_EVENT SETTINGS_CACHE_CLEARED";
271 if (msg.startsWith(
"GLOBAL_SYSTEM_EVENT "))
278 if ((!msg.startsWith(
"SYSTEM_EVENT ")) &&
279 (!msg.startsWith(
"LOCAL_SYSTEM_EVENT ")))
282 #if QT_VERSION < QT_VERSION_CHECK(5,14,0)
283 QStringList tokens = msg.split(
' ', QString::SkipEmptyParts);
285 QStringList tokens = msg.split(
' ', Qt::SkipEmptyParts);
289 if ((tokens.size() >= 4) &&
290 (tokens[2] ==
"HOST") &&
304 eventThread,
"SystemEvent");
313 LOG(VB_GENERAL, LOG_INFO,
LOC +
314 QString(
"Starting thread for command '%1'").
arg(cmd));
318 eventThread,
"SystemEvent");
337 QString(
"%1 CARDID %2 CHANID %3 STARTTIME %4 RECSTATUS %5 "
338 "VIDEODEVICE %6 VBIDEVICE %7")
348 LOG(VB_GENERAL, LOG_ERR,
LOC +
349 "SendMythSystemRecEvent() called with empty RecordingInfo");
364 QString(
"%1 HOSTNAME %2 CHANID %3 STARTTIME %4")
371 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SendMythSystemPlayEvent() called with "
372 "empty ProgramInfo");
393 m_title = tr(
"System Event Command Editor");
399 tr(
"Recording pending");
401 tr(
"Recording about to fail");
403 tr(
"Recording failing");
405 tr(
"Recording started");
407 tr(
"Recording started writing");
409 tr(
"Recording finished");
411 tr(
"Recording deleted");
413 tr(
"Recording expired");
415 tr(
"LiveTV started");
419 tr(
"Playback started");
421 tr(
"Playback stopped");
423 tr(
"Playback paused");
425 tr(
"Playback unpaused");
427 tr(
"Playback program changed");
429 tr(
"Tuning signal waiting");
431 tr(
"Master backend started");
433 tr(
"Master backend shutdown");
435 tr(
"Client connected to master backend");
437 tr(
"Client disconnected from master backend");
439 tr(
"Slave backend connected to master");
441 tr(
"Slave backend disconnected from master");
443 tr(
"Network Control client connected");
445 tr(
"Network Control client disconnected");
447 tr(
"mythfilldatabase ran");
451 tr(
"Settings cache cleared");
453 tr(
"Screen created or destroyed");
455 tr(
"Keystroke event #1");
457 tr(
"Keystroke event #2");
459 tr(
"Keystroke event #3");
461 tr(
"Keystroke event #4");
463 tr(
"Keystroke event #5");
465 tr(
"Keystroke event #6");
467 tr(
"Keystroke event #7");
469 tr(
"Keystroke event #8");
471 tr(
"Keystroke event #9");
473 tr(
"Keystroke event #10");
475 tr(
"CEC command received");
MythSystemEventHandler()
Null Constructor.
void SendMessage(const QString &message)
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
static Type MythEventMessage
#define GENERIC_EXIT_OK
Exited with no error.
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
Holds information on a TV Program one might wish to record.
This class is used as a container for messages.
An editor screen that allows manipulation of raw settings values.
arg(title).arg(filename).arg(doDelete))
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
static void SubstituteMatches(const QStringList &tokens, QString &command)
Substitutes MATCH% variables in given command line.
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
void startReserved(QRunnable *runnable, const QString &debugName, std::chrono::milliseconds waitForAvailMS=0ms)
const QString & Message() const
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
QRunnable class for running MythSystemEvent handler commands.
void addListener(QObject *listener)
Add a listener to the observable.
static QString EventNameToSetting(const QString &name)
Convert an MythSystemEvent name to a database setting name.
RecStatus::Type GetRecordingStatus(void) const
@ kFilename
Default UTC, "yyyyMMddhhmmss".
void SendSystemEvent(const QString &msg)
SystemEventThread(QString cmd, QString eventName="")
Constructor for creating a SystemEventThread.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.
uint GetInputID(void) const
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
void SubstituteMatches(QString &str) override
Replace MATCH% vars in the specified string.
Holds information on recordings and videos.
QMap< QString, QString > m_settings
void SendMythSystemPlayEvent(const QString &msg, const ProgramInfo *pginfo)
void customEvent(QEvent *e) override
Custom Event handler for receiving and processing System Events.
MythSystemEventEditor(MythScreenStack *parent, const char *name=nullptr)
Constructor for the MythSystemEvent settings editor.
static QString GetVBIDevice(uint inputid)
void SendMythSystemRecEvent(const QString &msg, const RecordingInfo *pginfo)
QString GetHostName(void)
void run(void) override
Runs the System Event handler command.
~MythSystemEventHandler() override
Destructor.
static MThreadPool * globalInstance(void)
void removeListener(QObject *listener)
Remove a listener to the observable.
static QString GetVideoDevice(uint inputid)
QString GetSetting(const QString &key, const QString &defaultval="")