21"<mythmessage version=\"1\">\n"
22" <text>%message_text%</text>\n"
23" <timeout>%timeout%</timeout>\n"
27"<mythnotification version=\"1\">\n"
28" <text>%message_text%</text>\n"
29" <origin>%origin%</origin>\n"
30" <description>%description%</description>\n"
31" <error>%error%</error>\n"
32" <timeout>%timeout%</timeout>\n"
33" <image>%image%</image>\n"
34" <extra>%extra%</extra>\n"
35" <progress_text>%progress_text%</progress_text>\n"
36" <progress>%progress%</progress>\n"
37" <fullscreen>%fullscreen%</fullscreen>\n"
38" <visibility>%visibility%</visibility>\n"
39" <type>%type%</type>\n"
44 cerr <<
kMessage.toLocal8Bit().constData() << endl;
56 QHostAddress address = QHostAddress::Broadcast;
57 unsigned short port = 6948;
62 QString origin =
"MythUtils";
63 QString description =
"";
65 QString progress_text =
"";
67 QString fullscreen =
"false";
68 QString
error =
"false";
69 QString visibility =
"0";
70 QString
type =
"normal";
80 message.replace(
"%message_text%", text);
83 message.replace(
"%timeout%",
timeout);
88 message.replace(
"%image%", image);
91 message.replace(
"%origin%", origin);
94 message.replace(
"%description%", description);
97 message.replace(
"%extra%", extra);
100 message.replace(
"%progress_text%", progress_text);
103 message.replace(
"%progress%",
progress);
106 message.replace(
"%fullscreen%", fullscreen);
109 message.replace(
"%error%",
error);
112 message.replace(
"%visibility%", visibility);
115 message.replace(
"%type%",
type);
121 QMap<QString,QString>::const_iterator i;
123 for (i = extras.cbegin(); i != extras.cend(); ++i)
125 QString kv_name = i.key();
126 const QString& kv_value = i.value();
128 kv_name.replace(
"--",
"");
129 cerr <<
"name: " << kv_name.toLocal8Bit().constData()
130 <<
" -- value: " << kv_value.toLocal8Bit().constData() << endl;
133 kv_name.prepend(
"%");
134 message.replace(kv_name, kv_value);
137 cout <<
"output:\n" << message.toLocal8Bit().constData() << endl;
139 auto *sock =
new QUdpSocket();
140 QByteArray utf8 = message.toUtf8();
143 if (sock->writeDatagram(utf8, address, port) < 0)
145 cout <<
"Failed to send UDP/XML packet" << endl;
150 cout <<
"Sent UDP/XML packet to IP "
151 << address.toString().toLocal8Bit().constData()
152 <<
" and port: " << port << endl;
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