Permalink
Browse files

Add ability to send notifications via frontend telnet interface

  • Loading branch information...
jyavenard committed Jul 2, 2013
1 parent 5316e59 commit 79b57780746ced1b870dc1c1c78c7f1d61f42a28
Showing with 22 additions and 0 deletions.
  1. +21 −0 mythtv/programs/mythfrontend/networkcontrol.cpp
  2. +1 −0 mythtv/programs/mythfrontend/networkcontrol.h
@@ -24,6 +24,7 @@
// libmythui
#include "mythmainwindow.h"
#include "mythuihelper.h"
#include "mythuinotificationcenter.h"
#define LOC QString("NetworkControl: ")
#define LOC_ERR QString("NetworkControl Error: ")
@@ -287,6 +288,8 @@ void NetworkControl::processNetworkControlCommand(NetworkCommand *nc)
result = processHelp(nc);
else if (is_abbrev("message", nc->getArg(0)))
result = processMessage(nc);
else if (is_abbrev("notification", nc->getArg(0)))
result = processNotification(nc);
else if ((nc->getArg(0).toLower() == "exit") || (nc->getArg(0).toLower() == "quit"))
QCoreApplication::postEvent(this,
new NetworkControlCloseEvent(nc->getClient()));
@@ -1180,6 +1183,11 @@ QString NetworkControl::processHelp(NetworkCommand *nc)
helpText +=
"message - Displays a simple text message popup\r\n";
}
else if ((is_abbrev("notification", command)))
{
helpText +=
"notification - Displays a simple text message notification\r\n";
}
if (!helpText.isEmpty())
return helpText;
@@ -1197,6 +1205,7 @@ QString NetworkControl::processHelp(NetworkCommand *nc)
"set - Changes\r\n"
"screenshot - Capture screenshot\r\n"
"message - Display a simple text message\r\n"
"notification - Display a simple text notification\r\n"
"exit - Exit Network Control\r\n"
"\r\n"
"Type 'help COMMANDNAME' for help on any specific command.\r\n";
@@ -1217,6 +1226,18 @@ QString NetworkControl::processMessage(NetworkCommand *nc)
return QString("OK");
}
QString NetworkControl::processNotification(NetworkCommand *nc)
{
if (nc->getArgCount() < 2)
return QString("ERROR: See 'help %1' for usage information")
.arg(nc->getArg(0));
QString message = nc->getCommand().remove(0, 12).trimmed();
MythNotification n(message, tr("Network Control"));
MythUINotificationCenter::GetInstance()->Queue(n);
return QString("OK");
}
void NetworkControl::notifyDataAvailable(void)
{
QCoreApplication::postEvent(
@@ -113,6 +113,7 @@ class NetworkControl : public ServerPool, public QRunnable
QString processQuery(NetworkCommand *nc);
QString processSet(NetworkCommand *nc);
QString processMessage(NetworkCommand *nc);
QString processNotification(NetworkCommand *nc);
QString processHelp(NetworkCommand *nc);
void notifyDataAvailable(void);

0 comments on commit 79b5778

Please sign in to comment.