Permalink
Browse files

Add support to send user notification via the UDP listener interface

  • Loading branch information...
jyavenard committed Jul 2, 2013
1 parent 98c828b commit 5316e59f81414c6830143befa4da20f09644483a
Showing with 26 additions and 9 deletions.
  1. +26 −9 mythtv/libs/libmythui/mythudplistener.cpp
@@ -8,6 +8,7 @@
#include "mythlogging.h"
#include "mythmainwindow.h"
#include "mythudplistener.h"
#include "mythuinotificationcenter.h"
#define LOC QString("UDPListener: ")
@@ -77,15 +78,22 @@ void MythUDPListener::Process(const QByteArray &buf, QHostAddress sender,
}
QDomElement docElem = doc.documentElement();
bool notification = false;
if (!docElem.isNull())
{
if (docElem.tagName() != "mythmessage")
if (docElem.tagName() != "mythmessage" &&
docElem.tagName() != "mythnotification")
{
LOG(VB_GENERAL, LOG_ERR, LOC +
"Unknown UDP packet (not <mythmessage> XML)");
return;
}
if (docElem.tagName() == "mythnotification")
{
notification = true;
}
QString version = docElem.attribute("version", "");
if (version.isEmpty())
{
@@ -120,14 +128,23 @@ void MythUDPListener::Process(const QByteArray &buf, QHostAddress sender,
if (!msg.isEmpty())
{
LOG(VB_GENERAL, LOG_INFO, QString("Received %1 '%2', timeout %3")
.arg(notification ? "notification" : "message").arg(msg).arg(timeout));
if (timeout > 1000)
timeout = 0;
LOG(VB_GENERAL, LOG_INFO, QString("Received message '%1', timeout %2")
.arg(msg).arg(timeout));
QStringList args;
args << QString::number(timeout);
MythMainWindow *window = GetMythMainWindow();
MythEvent* me = new MythEvent(MythEvent::MythUserMessage, msg, args);
qApp->postEvent(window, me);
timeout = notification ? 5 : 0;
if (notification)
{
MythNotification n(msg, tr("UDP Listener"));
n.SetDuration(timeout);
MythUINotificationCenter::GetInstance()->Queue(n);
}
else
{
QStringList args;
args << QString::number(timeout);
MythMainWindow *window = GetMythMainWindow();
MythEvent* me = new MythEvent(MythEvent::MythUserMessage, msg, args);
qApp->postEvent(window, me);
}
}
}

0 comments on commit 5316e59

Please sign in to comment.