Skip to content

Commit

Permalink
Extend mythutil to support sending multi-line events.
Browse files Browse the repository at this point in the history
Use extra --event arguments to add more lines to the event.
  • Loading branch information
gigem committed Apr 11, 2012
1 parent fe24dce commit 4621e13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
27 changes: 12 additions & 15 deletions mythtv/programs/mythutil/backendutils.cpp
Expand Up @@ -3,18 +3,21 @@
#include "mythcorecontext.h"
#include "mythlogging.h"
#include "remoteutil.h"
#include "scheduledrecording.h"

// local headers
#include "backendutils.h"

static int RawSendEvent(const QString &eventString)
static int RawSendEvent(const QStringList &eventStringList)
{
if (eventString.isEmpty())
if (eventStringList.isEmpty() || eventStringList[0].isEmpty())
return GENERIC_EXIT_INVALID_CMDLINE;

if (gCoreContext->ConnectToMasterServer(false, false))
{
gCoreContext->SendMessage(eventString);
QStringList message("MESSAGE");
message << eventStringList;
gCoreContext->SendReceiveStringList(message);
return GENERIC_EXIT_OK;
}
return GENERIC_EXIT_CONNECT_ERROR;
Expand All @@ -36,28 +39,22 @@ static int ClearSettingsCache(const MythUtilCommandLineParser &cmdline)

static int SendEvent(const MythUtilCommandLineParser &cmdline)
{
return RawSendEvent(cmdline.toString("event"));
return RawSendEvent(cmdline.toStringList("event"));
}

static int SendSystemEvent(const MythUtilCommandLineParser &cmdline)
{
return RawSendEvent(QString("SYSTEM_EVENT %1 SENDER %2")
.arg(cmdline.toString("systemevent"))
.arg(gCoreContext->GetHostName()));
return RawSendEvent(QStringList(QString("SYSTEM_EVENT %1 SENDER %2")
.arg(cmdline.toString("systemevent"))
.arg(gCoreContext->GetHostName())));
}

static int Reschedule(const MythUtilCommandLineParser &cmdline)
{
if (gCoreContext->ConnectToMasterServer(false, false))
{
QStringList slist("RESCHEDULE_RECORDINGS -1");
if (gCoreContext->SendReceiveStringList(slist))
{
LOG(VB_GENERAL, LOG_ERR,
"Error sending reschedule command to master backend");
return GENERIC_EXIT_CONNECT_ERROR;
}

ScheduledRecording::RescheduleMatch(0, 0, 0, QDateTime(),
"MythUtilCommand");
LOG(VB_GENERAL, LOG_INFO, "Reschedule command sent to master");
return GENERIC_EXIT_OK;
}
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythutil/commandlineparser.cpp
Expand Up @@ -83,7 +83,8 @@ void MythUtilCommandLineParser::LoadArguments(void)
"access those files to do so. If enabled, this will also "
"trigger the bulk metadata scanner upon completion.")
->SetGroup("Backend")
<< add("--event", "event", "", "Send a backend event test message.", "")
<< add("--event", "event", QVariant::StringList,
"Send a backend event test message.", "")
->SetGroup("Backend")
<< add("--systemevent", "systemevent", "",
"Send a backend SYSTEM_EVENT test message.", "")
Expand Down

0 comments on commit 4621e13

Please sign in to comment.