18"<mythmessage version=\"1\">\n"
19" <text>%message_text%</text>\n"
20" <timeout>%timeout%</timeout>\n"
24"<mythnotification version=\"1\">\n"
25" <text>%message_text%</text>\n"
26" <origin>%origin%</origin>\n"
27" <description>%description%</description>\n"
28" <error>%error%</error>\n"
29" <timeout>%timeout%</timeout>\n"
30" <image>%image%</image>\n"
31" <extra>%extra%</extra>\n"
32" <progress_text>%progress_text%</progress_text>\n"
33" <progress>%progress%</progress>\n"
34" <fullscreen>%fullscreen%</fullscreen>\n"
35" <visibility>%visibility%</visibility>\n"
36" <type>%type%</type>\n"
41 std::cerr <<
kMessage.toLocal8Bit().constData() <<
'\n';
53 QHostAddress address = QHostAddress::Broadcast;
54 unsigned short port = 6948;
59 QString origin =
"MythUtils";
60 QString description =
"";
62 QString progress_text =
"";
64 QString fullscreen =
"false";
65 QString
error =
"false";
66 QString visibility =
"0";
67 QString
type =
"normal";
77 message.replace(
"%message_text%", text);
80 message.replace(
"%timeout%",
timeout);
85 message.replace(
"%image%", image);
88 message.replace(
"%origin%", origin);
91 message.replace(
"%description%", description);
94 message.replace(
"%extra%", extra);
97 message.replace(
"%progress_text%", progress_text);
100 message.replace(
"%progress%",
progress);
103 message.replace(
"%fullscreen%", fullscreen);
106 message.replace(
"%error%",
error);
109 message.replace(
"%visibility%", visibility);
112 message.replace(
"%type%",
type);
118 QMap<QString,QString>::const_iterator i;
120 for (i = extras.cbegin(); i != extras.cend(); ++i)
122 QString kv_name = i.key();
123 const QString& kv_value = i.value();
125 kv_name.replace(
"--",
"");
126 std::cerr <<
"name: " << kv_name.toLocal8Bit().constData()
127 <<
" -- value: " << kv_value.toLocal8Bit().constData() <<
'\n';
130 kv_name.prepend(
"%");
131 message.replace(kv_name, kv_value);
134 std::cout <<
"output:\n" << message.toLocal8Bit().constData() <<
'\n';
136 auto *sock =
new QUdpSocket();
137 QByteArray utf8 = message.toUtf8();
140 if (sock->writeDatagram(utf8, address, port) < 0)
142 std::cout <<
"Failed to send UDP/XML packet\n";
147 std::cout <<
"Sent UDP/XML packet to IP "
148 << address.toString().toLocal8Bit().constData()
149 <<
" and port: " << port <<
'\n';
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
QMap< QString, QString > GetExtra(void) const
Return map of additional key/value pairs provided on the command line independent of any registered a...
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
uint toUInt(const QString &key) const
Returns stored QVariant as an unsigned integer, falling to default if not provided.
@ GENERIC_EXIT_OK
Exited with no error.
@ GENERIC_EXIT_NOT_OK
Exited with error.
static int PrintMTemplate(const MythUtilCommandLineParser &)
static int SendMessage(const MythUtilCommandLineParser &cmdline)
void registerMessageUtils(UtilMap &utilMap)
static int PrintNTemplate(const MythUtilCommandLineParser &)
const QString kNotification
QMap< QString, UtilFunc > UtilMap
MythCommFlagCommandLineParser cmdline