Skip to content

Commit

Permalink
Add ability to send notifications via frontend telnet interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jyavenard committed Jul 2, 2013
1 parent 5316e59 commit 79b5778
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions mythtv/programs/mythfrontend/networkcontrol.cpp
Expand Up @@ -24,6 +24,7 @@
// libmythui
#include "mythmainwindow.h"
#include "mythuihelper.h"
#include "mythuinotificationcenter.h"

#define LOC QString("NetworkControl: ")
#define LOC_ERR QString("NetworkControl Error: ")
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions mythtv/programs/mythfrontend/networkcontrol.h
Expand Up @@ -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);
Expand Down

0 comments on commit 79b5778

Please sign in to comment.