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")
61 QString::number(result)));
78 setObjectName(
"MythSystemEventHandler");
108 if (command.isEmpty())
111 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"SubstituteMatches: BEFORE: %1")
115 QDateTime recstartts;
117 QStringList::const_iterator it = tokens.begin();
119 command.replace(QString(
"%EVENTNAME%"), *it);
122 while (it != tokens.end())
130 if ((*it ==
"CARDID") ||
131 (*it ==
"COMMAND") ||
132 (*it ==
"RECSTATUS") ||
133 (*it ==
"HOSTNAME") ||
137 (*it ==
"VIDEODEVICE") ||
138 (*it ==
"VBIDEVICE"))
142 if (++it == tokens.end())
147 command.replace(QString(
"%" "%1" "%").arg(token), *it);
158 if (++it == tokens.end())
161 chanid = (*it).toUInt();
168 if (*it ==
"STARTTIME")
170 if (++it == tokens.end())
183 command.replace(QString(
"%ARGS%"),
args);
196 RecordingInfo recinfo2(chanid, recstartts,
false, 0h, &status);
204 command.replace(QString(
"%CHANID%"), QString::number(chanid));
205 command.replace(QString(
"%STARTTIME%"),
208 command.replace(QString(
"%STARTTIMEISO%"),
213 command.replace(QString(
"%VERBOSELEVEL%"), QString(
"%1").arg(
verboseMask));
216 LOG(VB_FILE, LOG_DEBUG,
LOC + QString(
"SubstituteMatches: AFTER : %1")
231 QString result(
"EventCmd");
232 QStringList parts = name.toLower().split(
'_', Qt::SkipEmptyParts);
233 for (
const auto & part : std::as_const(parts))
235 result += part.at(0).toUpper();
236 result += part.mid(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 QStringList tokens = msg.split(
' ', Qt::SkipEmptyParts);
285 if ((tokens.size() >= 4) &&
286 (tokens[2] ==
"HOST") &&
300 eventThread,
"SystemEvent");
309 LOG(VB_GENERAL, LOG_INFO,
LOC +
310 QString(
"Starting thread for command '%1'").arg(cmd));
314 eventThread,
"SystemEvent");
333 QString(
"%1 CARDID %2 CHANID %3 STARTTIME %4 RECSTATUS %5 "
334 "VIDEODEVICE %6 VBIDEVICE %7")
335 .arg(msg).arg(cardid)
344 LOG(VB_GENERAL, LOG_ERR,
LOC +
345 "SendMythSystemRecEvent() called with empty RecordingInfo");
360 QString(
"%1 HOSTNAME %2 CHANID %3 STARTTIME %4")
367 LOG(VB_GENERAL, LOG_ERR,
LOC +
"SendMythSystemPlayEvent() called with "
368 "empty ProgramInfo");
389 m_title = tr(
"System Event Command Editor");
398 settings[
"EventCmdRecPending"] =
399 tr(
"Recording pending");
400 settings[
"EventCmdRecPreFail"] =
401 tr(
"Recording about to fail");
402 settings[
"EventCmdRecFailing"] =
403 tr(
"Recording failing");
404 settings[
"EventCmdRecStarted"] =
405 tr(
"Recording started");
406 settings[
"EventCmdRecStartedWriting"] =
407 tr(
"Recording started writing");
408 settings[
"EventCmdRecFinished"] =
409 tr(
"Recording finished");
410 settings[
"EventCmdRecDeleted"] =
411 tr(
"Recording deleted");
412 settings[
"EventCmdRecExpired"] =
413 tr(
"Recording expired");
414 settings[
"EventCmdLivetvStarted"] =
415 tr(
"LiveTV started");
416 settings[
"EventCmdLivetvEnded"] =
418 settings[
"EventCmdPlayStarted"] =
419 tr(
"Playback started");
420 settings[
"EventCmdPlayStopped"] =
421 tr(
"Playback stopped");
422 settings[
"EventCmdPlayPaused"] =
423 tr(
"Playback paused");
424 settings[
"EventCmdPlayUnpaused"] =
425 tr(
"Playback unpaused");
426 settings[
"EventCmdPlayChanged"] =
427 tr(
"Playback program changed");
428 settings[
"EventCmdTuningSignalTimeout"] =
429 tr(
"Tuning signal waiting");
430 settings[
"EventCmdMasterStarted"] =
431 tr(
"Master backend started");
432 settings[
"EventCmdMasterShutdown"] =
433 tr(
"Master backend shutdown");
434 settings[
"EventCmdClientConnected"] =
435 tr(
"Client connected to master backend");
436 settings[
"EventCmdClientDisconnected"] =
437 tr(
"Client disconnected from master backend");
438 settings[
"EventCmdSlaveConnected"] =
439 tr(
"Slave backend connected to master");
440 settings[
"EventCmdSlaveDisconnected"] =
441 tr(
"Slave backend disconnected from master");
442 settings[
"EventCmdNetCtrlConnected"] =
443 tr(
"Network Control client connected");
444 settings[
"EventCmdNetCtrlDisconnected"] =
445 tr(
"Network Control client disconnected");
446 settings[
"EventCmdMythfilldatabaseRan"] =
447 tr(
"mythfilldatabase ran");
448 settings[
"EventCmdSchedulerRan"] =
450 settings[
"EventCmdSettingsCacheCleared"] =
451 tr(
"Settings cache cleared");
452 settings[
"EventCmdScreenType"] =
453 tr(
"Screen created or destroyed");
454 settings[
"EventCmdKey01"] =
455 tr(
"Keystroke event #1");
456 settings[
"EventCmdKey02"] =
457 tr(
"Keystroke event #2");
458 settings[
"EventCmdKey03"] =
459 tr(
"Keystroke event #3");
460 settings[
"EventCmdKey04"] =
461 tr(
"Keystroke event #4");
462 settings[
"EventCmdKey05"] =
463 tr(
"Keystroke event #5");
464 settings[
"EventCmdKey06"] =
465 tr(
"Keystroke event #6");
466 settings[
"EventCmdKey07"] =
467 tr(
"Keystroke event #7");
468 settings[
"EventCmdKey08"] =
469 tr(
"Keystroke event #8");
470 settings[
"EventCmdKey09"] =
471 tr(
"Keystroke event #9");
472 settings[
"EventCmdKey10"] =
473 tr(
"Keystroke event #10");
474 settings[
"EventCmdCecCommandReceived"] =
475 tr(
"CEC command received");
476 settings[
"EventCmdAll"] =
480#include "moc_mythsystemevent.cpp"
static QString GetVideoDevice(uint inputid)
static QString GetVBIDevice(uint inputid)
void startReserved(QRunnable *runnable, const QString &debugName, std::chrono::milliseconds waitForAvailMS=0ms)
static MThreadPool * globalInstance(void)
QString GetHostName(void)
QString GetSetting(const QString &key, const QString &defaultval="")
void SendSystemEvent(const QString &msg)
void SendMessage(const QString &message)
This class is used as a container for messages.
const QString & Message() const
static const Type kMythEventMessage
void addListener(QObject *listener)
Add a listener to the observable.
void removeListener(QObject *listener)
Remove a listener to the observable.
static void createSettingList(QMap< QString, QString > &settings)
MythSystemEventEditor(MythScreenStack *parent, const char *name=nullptr)
Constructor for the MythSystemEvent settings editor.
~MythSystemEventHandler() override
Destructor.
void customEvent(QEvent *e) override
Custom Event handler for receiving and processing System Events.
static void SubstituteMatches(const QStringList &tokens, QString &command)
Substitutes MATCH% variables in given command line.
static QString EventNameToSetting(const QString &name)
Convert an MythSystemEvent name to a database setting name.
MythSystemEventHandler()
Null Constructor.
Holds information on recordings and videos.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
QDateTime GetRecordingStartTime(void) const
Approximate time the recording started.
uint GetInputID(void) const
RecStatus::Type GetRecordingStatus(void) const
An editor screen that allows manipulation of raw settings values.
QMap< QString, QString > m_settings
Holds information on a TV Program one might wish to record.
void SubstituteMatches(QString &str) override
Replace MATCH% vars in the specified string.
QRunnable class for running MythSystemEvent handler commands.
SystemEventThread(QString cmd, QString eventName="")
Constructor for creating a SystemEventThread.
void run(void) override
Runs the System Event handler command.
@ GENERIC_EXIT_OK
Exited with no error.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
void SendMythSystemRecEvent(const QString &msg, const RecordingInfo *pginfo)
void SendMythSystemPlayEvent(const QString &msg, const ProgramInfo *pginfo)
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
QString toString(const QDateTime &raw_dt, uint format)
Returns formatted string representing the time.
@ kFilename
Default UTC, "yyyyMMddhhmmss".
QDateTime fromString(const QString &dtstr)
Converts kFilename && kISODate formats to QDateTime.