9 #include <QHostAddress>
22 "<mythmessage version=\"1\">\n"
23 " <text>%message_text%</text>\n"
24 " <timeout>%timeout%</timeout>\n"
28 "<mythnotification version=\"1\">\n"
29 " <text>%message_text%</text>\n"
30 " <origin>%origin%</origin>\n"
31 " <description>%description%</description>\n"
32 " <error>%error%</error>\n"
33 " <timeout>%timeout%</timeout>\n"
34 " <image>%image%</image>\n"
35 " <extra>%extra%</extra>\n"
36 " <progress_text>%progress_text%</progress_text>\n"
37 " <progress>%progress%</progress>\n"
38 " <fullscreen>%fullscreen%</fullscreen>\n"
39 " <visibility>%visibility%</visibility>\n"
40 " <type>%type%</type>\n"
41 "</mythnotification>";
45 cerr <<
kMessage.toLocal8Bit().constData() << endl;
57 QHostAddress address = QHostAddress::Broadcast;
58 unsigned short port = 6948;
63 QString origin =
"MythUtils";
64 QString description =
"";
66 QString progress_text =
"";
68 QString fullscreen =
"false";
69 QString
error =
"false";
70 QString visibility =
"0";
71 QString
type =
"normal";
81 message.replace(
"%message_text%", text);
84 message.replace(
"%timeout%",
timeout);
89 message.replace(
"%image%", image);
92 message.replace(
"%origin%", origin);
95 message.replace(
"%description%", description);
98 message.replace(
"%extra%", extra);
101 message.replace(
"%progress_text%", progress_text);
104 message.replace(
"%progress%",
progress);
107 message.replace(
"%fullscreen%", fullscreen);
110 message.replace(
"%error%",
error);
113 message.replace(
"%visibility%", visibility);
116 message.replace(
"%type%",
type);
122 QMap<QString,QString>::const_iterator i;
124 for (i = extras.cbegin(); i != extras.cend(); ++i)
126 QString kv_name = i.key();
127 const QString& kv_value = i.value();
129 kv_name.replace(
"--",
"");
130 cerr <<
"name: " << kv_name.toLocal8Bit().constData()
131 <<
" -- value: " << kv_value.toLocal8Bit().constData() << endl;
134 kv_name.prepend(
"%");
135 message.replace(kv_name, kv_value);
138 cout <<
"output:\n" << message.toLocal8Bit().constData() << endl;
140 auto *sock =
new QUdpSocket();
141 QByteArray utf8 = message.toUtf8();
144 if (sock->writeDatagram(utf8, address, port) < 0)
146 cout <<
"Failed to send UDP/XML packet" << endl;
151 cout <<
"Sent UDP/XML packet to IP "
152 << address.toString().toLocal8Bit().constData()
153 <<
" and port: " << port << endl;