Go to the documentation of this file.
2 #include <QApplication>
18 #define LOC QString("MythSystemEventHandler: ")
46 void run(
void)
override
53 QString(
"Finished '%1' result %2")
60 QString(
"SYSTEM_EVENT_RESULT %1 SENDER %2 RESULT %3")
62 QString::number(result)));
79 setObjectName(
"MythSystemEventHandler");
109 if (command.isEmpty())
112 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"SubstituteMatches: BEFORE: %1")
116 QDateTime recstartts;
118 QStringList::const_iterator it = tokens.begin();
120 command.replace(QString(
"%EVENTNAME%"), *it);
123 while (it != tokens.end())
131 if ((*it ==
"CARDID") ||
132 (*it ==
"COMMAND") ||
133 (*it ==
"RECSTATUS") ||
134 (*it ==
"HOSTNAME") ||
138 (*it ==
"VIDEODEVICE") ||
139 (*it ==
"VBIDEVICE"))
143 if (++it == tokens.end())
148 command.replace(QString(
"%" "%1" "%").arg(token), *it);
159 if (++it == tokens.end())
162 chanid = (*it).toUInt();
169 if (*it ==
"STARTTIME")
171 if (++it == tokens.end())
184 command.replace(QString(
"%ARGS%"),
args);
195 RecordingInfo recinfo2(chanid, recstartts,
false, 0h, &status);
201 command.replace(QString(
"%CHANID%"), QString::number(chanid));
202 command.replace(QString(
"%STARTTIME%"),
205 command.replace(QString(
"%STARTTIMEISO%"),
210 command.replace(QString(
"%VERBOSELEVEL%"), QString(
"%1").arg(
verboseMask));
213 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"SubstituteMatches: AFTER : %1")
228 QString result(
"EventCmd");
229 QStringList parts = name.toLower().split(
'_', Qt::SkipEmptyParts);
230 for (
const auto & part : std::as_const(parts))
232 result += part.at(0).toUpper();
233 result += part.mid(1);
261 QString msg = me->
Message().simplified();
263 if (msg ==
"CLEAR_SETTINGS_CACHE")
264 msg =
"SYSTEM_EVENT SETTINGS_CACHE_CLEARED";
268 if (msg.startsWith(
"GLOBAL_SYSTEM_EVENT "))
275 if ((!msg.startsWith(
"SYSTEM_EVENT ")) &&
276 (!msg.startsWith(
"LOCAL_SYSTEM_EVENT ")))
279 QStringList tokens = msg.split(
' ', Qt::SkipEmptyParts);
282 if ((tokens.size() >= 4) &&
283 (tokens[2] ==
"HOST") &&
297 eventThread,
"SystemEvent");
306 LOG(VB_GENERAL, LOG_INFO,
LOC +
307 QString(
"Starting thread for command '%1'").arg(cmd));
311 eventThread,
"SystemEvent");
330 QString(
"%1 CARDID %2 CHANID %3 STARTTIME %4 RECSTATUS %5 "
331 "VIDEODEVICE %6 VBIDEVICE %7")
332 .arg(msg).arg(cardid)
341 LOG(VB_GENERAL, LOG_ERR,
LOC +
342 "SendMythSystemRecEvent() called with empty RecordingInfo");
357 QString(
"%1 HOSTNAME %2 CHANID %3 STARTTIME %4")
364 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SendMythSystemPlayEvent() called with "
365 "empty ProgramInfo");
386 m_title = tr(
"System Event Command Editor");
395 settings[
"EventCmdRecPending"] =
396 tr(
"Recording pending");
397 settings[
"EventCmdRecPreFail"] =
398 tr(
"Recording about to fail");
399 settings[
"EventCmdRecFailing"] =
400 tr(
"Recording failing");
401 settings[
"EventCmdRecStarted"] =
402 tr(
"Recording started");
403 settings[
"EventCmdRecStartedWriting"] =
404 tr(
"Recording started writing");
405 settings[
"EventCmdRecFinished"] =
406 tr(
"Recording finished");
407 settings[
"EventCmdRecDeleted"] =
408 tr(
"Recording deleted");
409 settings[
"EventCmdRecExpired"] =
410 tr(
"Recording expired");
411 settings[
"EventCmdLivetvStarted"] =
412 tr(
"LiveTV started");
413 settings[
"EventCmdLivetvEnded"] =
415 settings[
"EventCmdPlayStarted"] =
416 tr(
"Playback started");
417 settings[
"EventCmdPlayStopped"] =
418 tr(
"Playback stopped");
419 settings[
"EventCmdPlayPaused"] =
420 tr(
"Playback paused");
421 settings[
"EventCmdPlayUnpaused"] =
422 tr(
"Playback unpaused");
423 settings[
"EventCmdPlayChanged"] =
424 tr(
"Playback program changed");
425 settings[
"EventCmdTuningSignalTimeout"] =
426 tr(
"Tuning signal waiting");
427 settings[
"EventCmdMasterStarted"] =
428 tr(
"Master backend started");
429 settings[
"EventCmdMasterShutdown"] =
430 tr(
"Master backend shutdown");
431 settings[
"EventCmdClientConnected"] =
432 tr(
"Client connected to master backend");
433 settings[
"EventCmdClientDisconnected"] =
434 tr(
"Client disconnected from master backend");
435 settings[
"EventCmdSlaveConnected"] =
436 tr(
"Slave backend connected to master");
437 settings[
"EventCmdSlaveDisconnected"] =
438 tr(
"Slave backend disconnected from master");
439 settings[
"EventCmdNetCtrlConnected"] =
440 tr(
"Network Control client connected");
441 settings[
"EventCmdNetCtrlDisconnected"] =
442 tr(
"Network Control client disconnected");
443 settings[
"EventCmdMythfilldatabaseRan"] =
444 tr(
"mythfilldatabase ran");
445 settings[
"EventCmdSchedulerRan"] =
447 settings[
"EventCmdSettingsCacheCleared"] =
448 tr(
"Settings cache cleared");
449 settings[
"EventCmdScreenType"] =
450 tr(
"Screen created or destroyed");
451 settings[
"EventCmdKey01"] =
452 tr(
"Keystroke event #1");
453 settings[
"EventCmdKey02"] =
454 tr(
"Keystroke event #2");
455 settings[
"EventCmdKey03"] =
456 tr(
"Keystroke event #3");
457 settings[
"EventCmdKey04"] =
458 tr(
"Keystroke event #4");
459 settings[
"EventCmdKey05"] =
460 tr(
"Keystroke event #5");
461 settings[
"EventCmdKey06"] =
462 tr(
"Keystroke event #6");
463 settings[
"EventCmdKey07"] =
464 tr(
"Keystroke event #7");
465 settings[
"EventCmdKey08"] =
466 tr(
"Keystroke event #8");
467 settings[
"EventCmdKey09"] =
468 tr(
"Keystroke event #9");
469 settings[
"EventCmdKey10"] =
470 tr(
"Keystroke event #10");
471 settings[
"EventCmdCecCommandReceived"] =
472 tr(
"CEC command received");
473 settings[
"EventCmdAll"] =
MythSystemEventHandler()
Null Constructor.
void SendMessage(const QString &message)
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
static const Type kMythEventMessage
@ 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.
#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.
@ GENERIC_EXIT_OK
Exited with no error.
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 void createSettingList(QMap< QString, QString > &settings)
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="")