MythTV  master
lcdserver.cpp
Go to the documentation of this file.
1 /*
2  lcdserver.cpp
3 
4  Methods for the core lcdserver object
5 */
6 
7 
8 /*
9  Command list
10 
11  SWITCH_TO_TIME
12  SWITCH_TO_MUSIC "Artist" "Album" "Track"
13  SWITCH_TO_VOLUME "AppName"
14  SWITCH_TO_CHANNEL "ChanNum" "Title" "SubTitle"
15  SWITCH_TO_NOTHING
16  SWITCH_TO_MENU AppName popup ["Text" Checked Selected Scroll Indent ...]
17  AppName is a string
18  Popup can be TRUE or FALSE
19  Text is a string
20  Checked can be CHECKED, UNCHECKED, NOTCHECKABLE
21  Selected can be TRUE or FALSE
22  Scroll can be TRUE or FALSE
23  Indent is an integer
24  ... repeat as required
25 
26  SWITCH_TO_GENERIC RowNo Align "Text" "Screen" Scrollable ...
27  RowNo is an integer
28  Align can be ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTERED
29  Scrollable can be TRUE or FALSE
30  ... repeat as required
31 
32  SET_VOLUME_LEVEL <level>
33  level is a float between 0.0 and 1.0
34 
35  SET_CHANNEL_PROGRESS <progress>
36  progress is a float between 0.0 and 1.0
37 
38  SET_MUSIC_PROGRESS "Time" <progress>
39  time is a string
40  progress is a float between 0.0 and 1.0
41 
42  SET_MUSIC_PLAYER_PROP <field> <val>
43  field is a string, currently SHUFFLE or REPEAT
44  val depends on field, currently integer
45 
46  SET_GENERIC_PROGRESS <busy> <progress>
47  busy is 0 for busy spinner, 0 for normal progess bar
48  progress is a float between 0.0 and 1.0
49 
50  UPDATE_LEDS
51 
52  STOP_ALL
53 
54  RESET
55 
56 */
57 
58 // c/c++
59 #include <cstdlib>
60 #include <utility>
61 
62 //qt
63 #include <QCoreApplication>
64 #include <QDir>
65 #include <QList>
66 #include <QStringList>
67 
68 // mythtv
69 #include "libmyth/mythcontext.h"
70 #include "libmythbase/lcddevice.h"
71 #include "libmythbase/mythdate.h"
72 
73 // mythlcdserver
74 #include "lcdserver.h"
75 
76 int debug_level = 0;
77 
78 #define LOC QString("LCDServer: ")
79 #define LOC_WARN QString("LCDServer, Warning: ")
80 #define LOC_ERR QString("LCDServer, Error: ")
81 
82 LCDServer::LCDServer(int port, QString message, std::chrono::seconds messageTime)
83  : m_lcd(new LCDProcClient(this)),
84  m_serverPool(new ServerPool())
85 {
86  if (!m_lcd->SetupLCD())
87  {
88  delete m_lcd;
89  m_lcd = nullptr;
90  }
91 
94 
95  if (!m_serverPool->listen(port))
96  {
97  LOG(VB_GENERAL, LOG_ERR, "There is probably a copy of mythlcdserver "
98  "already running. You can verify this by running: \n"
99  "'ps ax | grep mythlcdserver'");
100  delete m_serverPool;
101  return;
102  }
103 
104  if (m_lcd)
105  m_lcd->setStartupMessage(std::move(message), messageTime);
106 }
107 
108 void LCDServer::newConnection(QTcpSocket *socket)
109 {
110  connect(socket, &QIODevice::readyRead,
111  this, &LCDServer::readSocket);
112  connect(socket, &QAbstractSocket::disconnected,
113  this, &LCDServer::endConnection);
114 
115  if (debug_level > 0)
116  LOG(VB_NETWORK, LOG_INFO, "LCDServer: new connection");
117 
118  if (m_lcd)
119  m_lcd->switchToTime();
120 }
121 
123 {
124  auto *socket = qobject_cast<QTcpSocket*>(sender());
125  if (socket)
126  {
127  socket->close();
128  socket->deleteLater();
129  if (debug_level > 0)
130  LOG(VB_NETWORK, LOG_INFO, "LCDServer: close connection");
131  }
132 
133  if (m_lastSocket == socket)
134  m_lastSocket = nullptr;
135 }
136 
138 {
139  auto *socket = qobject_cast<QTcpSocket*>(sender());
140  if (socket)
141  {
142  m_lastSocket = socket;
143 
144  while(socket->canReadLine())
145  {
146  QString incoming_data = socket->readLine();
147  incoming_data = incoming_data.remove("\n");
148  incoming_data = incoming_data.remove("\r");
149  incoming_data = incoming_data.simplified();
150  QStringList tokens = parseCommand(incoming_data);
151  parseTokens(tokens, socket);
152  }
153  }
154 }
155 
156 QStringList LCDServer::parseCommand(QString &command)
157 {
158  QStringList tokens;
159  QString s = "";
160  QChar c;
161  bool bInString = false;
162 
163  for (auto && x : std::as_const(command))
164  {
165  c = x;
166  if (!bInString && c == '"')
167  bInString = true;
168  else if (bInString && c == '"')
169  bInString = false;
170  else if (!bInString && c == ' ')
171  {
172  tokens.append(s);
173  s = "";
174  }
175  else
176  s = s + c;
177  }
178 
179  tokens.append(s);
180 
181  return tokens;
182 }
183 
184 void LCDServer::parseTokens(const QStringList &tokens, QTcpSocket *socket)
185 {
186  //
187  // parse commands coming in from the socket
188  //
189 
190  if (tokens[0] == "HALT" ||
191  tokens[0] == "QUIT" ||
192  tokens[0] == "SHUTDOWN")
193  {
194  shutDown();
195  }
196  else if (tokens[0] == "HELLO")
197  {
198  sendConnected(socket);
199  }
200  else if (tokens[0] == "SWITCH_TO_TIME")
201  {
202  switchToTime(socket);
203  }
204  else if (tokens[0] == "SWITCH_TO_MUSIC")
205  {
206  switchToMusic(tokens, socket);
207  }
208  else if (tokens[0] == "SWITCH_TO_VOLUME")
209  {
210  switchToVolume(tokens, socket);
211  }
212  else if (tokens[0] == "SWITCH_TO_GENERIC")
213  {
214  switchToGeneric(tokens, socket);
215  }
216  else if (tokens[0] == "SWITCH_TO_MENU")
217  {
218  switchToMenu(tokens, socket);
219  }
220  else if (tokens[0] == "SWITCH_TO_CHANNEL")
221  {
222  switchToChannel(tokens, socket);
223  }
224  else if (tokens[0] == "SWITCH_TO_NOTHING")
225  {
226  switchToNothing(socket);
227  }
228  else if (tokens[0] == "SET_VOLUME_LEVEL")
229  {
230  setVolumeLevel(tokens, socket);
231  }
232  else if (tokens[0] == "SET_GENERIC_PROGRESS")
233  {
234  setGenericProgress(tokens, socket);
235  }
236  else if (tokens[0] == "SET_MUSIC_PROGRESS")
237  {
238  setMusicProgress(tokens, socket);
239  }
240  else if (tokens[0] == "SET_MUSIC_PLAYER_PROP")
241  {
242  setMusicProp(tokens, socket);
243  }
244  else if (tokens[0] == "SET_CHANNEL_PROGRESS")
245  {
246  setChannelProgress(tokens, socket);
247  }
248  else if (tokens[0] == "UPDATE_LEDS")
249  {
250  updateLEDs(tokens, socket);
251  }
252  else if (tokens[0] == "STOP_ALL")
253  {
254  if (m_lcd)
255  m_lcd->stopAll();
256  }
257  else if (tokens[0] == "RESET")
258  {
259  // reset lcd & reload settings
260  if (m_lcd)
261  m_lcd->reset();
262  }
263  else
264  {
265  QString did_not_parse = tokens.join(" ");
266 
267  if (debug_level > 0)
268  LOG(VB_GENERAL, LOG_ERR, "LCDServer::failed to parse this: " +
269  did_not_parse);
270 
271  sendMessage(socket, "HUH?");
272  }
273 }
274 
276 {
277  if (debug_level > 0)
278  LOG(VB_GENERAL, LOG_INFO, "LCDServer:: shuting down");
279 
280  m_serverPool->disconnect();
281  m_serverPool->close();
282  delete m_serverPool;
283  m_serverPool = nullptr;
284 
285  exit(0);
286 }
287 
288 void LCDServer::sendMessage(QTcpSocket *where, const QString &what)
289 {
290  QString message = what;
291  message.append("\n");
292  QByteArray tmp = message.toUtf8();
293  where->write(tmp.constData(), tmp.length());
294 }
295 
296 void LCDServer::sendKeyPress(const QString& key_pressed)
297 {
298  if (debug_level > 0)
299  LOG(VB_GENERAL, LOG_INFO, "LCDServer:: send key press: " + key_pressed);
300 
301  // send key press to last client that sent us a message
302  if (m_lastSocket)
303  sendMessage(m_lastSocket, "KEY " + key_pressed);
304 }
305 
306 void LCDServer::sendConnected(QTcpSocket *socket)
307 {
308  QString sWidth;
309  QString sHeight;
310  int nWidth = 0;
311  int nHeight = 0;
312 
313  if (m_lcd)
314  {
315  nWidth = m_lcd->getLCDWidth();
316  nHeight = m_lcd->getLCDHeight();
317  }
318 
319  sWidth = sWidth.setNum(nWidth);
320  sHeight = sHeight.setNum(nHeight);
321 
322  sendMessage(socket, "CONNECTED " + sWidth + " " + sHeight);
323 }
324 
325 void LCDServer::switchToTime(QTcpSocket *socket)
326 {
327  if (debug_level > 0)
328  LOG(VB_GENERAL, LOG_INFO, "LCDServer:: SWITCH_TO_TIME");
329 
330  if (m_lcd)
331  m_lcd->switchToTime();
332 
333  sendMessage(socket, "OK");
334 }
335 
336 void LCDServer::switchToMusic(const QStringList &tokens, QTcpSocket *socket)
337 {
338  if (debug_level > 0)
339  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_MUSIC");
340 
341  QString flat = tokens.join(" ");
342 
343  if (tokens.count() != 4)
344  {
345  LOG(VB_GENERAL, LOG_ERR,
346  "LCDServer: bad SWITCH_TO_MUSIC command: " + flat);
347  sendMessage(socket, "HUH?");
348  return;
349  }
350 
351  if (m_lcd)
352  m_lcd->switchToMusic(tokens[1], tokens[2], tokens[3]);
353 
354  sendMessage(socket, "OK");
355 }
356 
357 void LCDServer::switchToGeneric(const QStringList &tokens, QTcpSocket *socket)
358 {
359  if (debug_level > 0)
360  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_GENERIC");
361 
362  QString flat = tokens.join(" ");
363 
364  if ((tokens.count() - 1) % 5 != 0)
365  {
366  LOG(VB_GENERAL, LOG_ERR,
367  "LCDServer: bad no. of args SWITCH_TO_GENERIC command: " + flat);
368  sendMessage(socket, "HUH?");
369  return;
370  }
371 
372  QList<LCDTextItem> items;
373 
374  for (int x = 1; x < tokens.count(); x += 5)
375  {
376  bool bOK = false;
377  int row = tokens[x].toInt(&bOK);
378  if (!bOK)
379  {
380  LOG(VB_GENERAL, LOG_ERR,
381  "LCDServer: bad row no. in SWITCH_TO_GENERIC "
382  "command: " + tokens[x]);
383  sendMessage(socket, "HUH?");
384  return;
385  }
386 
387  TEXT_ALIGNMENT align = ALIGN_LEFT;
388  if (tokens[x + 1] == "ALIGN_LEFT")
389  align = ALIGN_LEFT;
390  else if (tokens[x + 1] == "ALIGN_RIGHT")
391  align = ALIGN_RIGHT;
392  else if (tokens[x + 1] == "ALIGN_CENTERED")
393  align = ALIGN_CENTERED;
394  else
395  {
396  LOG(VB_GENERAL, LOG_ERR,
397  "LCDServer: bad align in SWITCH_TO_GENERIC command: " +
398  tokens[x + 1]);
399  sendMessage(socket, "HUH?");
400  return;
401  }
402 
403  const QString& text = tokens[x + 2];
404  const QString& screen = tokens[x + 3];
405  bool scrollable = false;
406  if (tokens[x + 4] == "TRUE")
407  scrollable = true;
408  else if (tokens[x + 4] == "FALSE")
409  scrollable = false;
410  else
411  {
412  LOG(VB_GENERAL, LOG_ERR,
413  "LCDServer: bad scrollable bool in SWITCH_TO_GENERIC "
414  "command: " + tokens[x + 4]);
415  sendMessage(socket, "HUH?");
416  return;
417  }
418 
419  items.append(LCDTextItem(row, align, text, screen, scrollable));
420  }
421 
422  if (m_lcd)
423  m_lcd->switchToGeneric(&items);
424 
425  sendMessage(socket, "OK");
426 }
427 
428 void LCDServer::switchToChannel(const QStringList &tokens, QTcpSocket *socket)
429 {
430  if (debug_level > 0)
431  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_CHANNEL");
432 
433  QString flat = tokens.join(" ");
434 
435  if (tokens.count() != 4)
436  {
437  LOG(VB_GENERAL, LOG_ERR,
438  "LCDServer: bad SWITCH_TO_CHANNEL command: " + flat);
439  sendMessage(socket, "HUH?");
440  return;
441  }
442 
443  if (m_lcd)
444  m_lcd->switchToChannel(tokens[1], tokens[2], tokens[3]);
445 
446  sendMessage(socket, "OK");
447 }
448 
449 void LCDServer::switchToVolume(const QStringList &tokens, QTcpSocket *socket)
450 {
451  if (debug_level > 0)
452  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_VOLUME");
453 
454  QString flat = tokens.join(" ");
455 
456  if (tokens.count() != 2)
457  {
458  LOG(VB_GENERAL, LOG_ERR,
459  "LCDServer: bad SWITCH_TO_VOLUME command: " + flat);
460  sendMessage(socket, "HUH?");
461  return;
462  }
463 
464  if (m_lcd)
465  m_lcd->switchToVolume(tokens[1]);
466 
467  sendMessage(socket, "OK");
468 }
469 
470 void LCDServer::switchToNothing(QTcpSocket *socket)
471 {
472  if (debug_level > 0)
473  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_NOTHING");
474 
475  if (m_lcd)
477 
478  sendMessage(socket, "OK");
479 }
480 
481 void LCDServer::switchToMenu(const QStringList &tokens, QTcpSocket *socket)
482 {
483  if (debug_level > 0)
484  LOG(VB_GENERAL, LOG_INFO,
485  QString("LCDServer: SWITCH_TO_MENU: %1").arg(tokens.count()));
486 
487  QString flat = tokens.join(" ");
488 
489  if ((tokens.count() - 3) % 5 != 0)
490  {
491  LOG(VB_GENERAL, LOG_ERR,
492  "LCDServer: bad no. of args SWITCH_TO_MENU command: " + flat);
493  sendMessage(socket, "HUH?");
494  return;
495  }
496 
497  const QString& appName = tokens[1];
498 
499  bool bPopup = false;
500  if (tokens[2] == "TRUE")
501  bPopup = true;
502  else if (tokens[2] == "FALSE")
503  bPopup = false;
504  else
505  {
506  LOG(VB_GENERAL, LOG_ERR,
507  "LCDServer: bad popup bool in SWITCH_TO_MENU command: " +
508  tokens[2]);
509  sendMessage(socket, "HUH?");
510  return;
511  }
512 
513  QList<LCDMenuItem> items;
514 
515  for (int x = 3; x < tokens.count(); x += 5)
516  {
517  const QString& text = tokens[x];
518 
519  CHECKED_STATE checked = CHECKED;
520  if (tokens[x + 1] == "CHECKED")
521  checked = CHECKED;
522  else if (tokens[x + 1] == "UNCHECKED")
523  checked = UNCHECKED;
524  else if (tokens[x + 1] == "NOTCHECKABLE")
525  checked = NOTCHECKABLE;
526  else
527  {
528  LOG(VB_GENERAL, LOG_ERR,
529  "LCDServer: bad checked state in SWITCH_TO_MENU command: " +
530  tokens[x + 1]);
531  sendMessage(socket, "HUH?");
532  return;
533  }
534 
535  bool selected = false;
536  if (tokens[x + 2] == "TRUE")
537  selected = true;
538  else if (tokens[x + 2] == "FALSE")
539  selected = false;
540  else
541  {
542  LOG(VB_GENERAL, LOG_ERR,
543  "LCDServer: bad selected state in SWITCH_TO_MENU command: " +
544  tokens[x + 2]);
545  sendMessage(socket, "HUH?");
546  return;
547  }
548 
549  bool scrollable = false;
550  if (tokens[x + 3] == "TRUE")
551  scrollable = true;
552  else if (tokens[x + 3] == "FALSE")
553  scrollable = false;
554  else
555  {
556  LOG(VB_GENERAL, LOG_ERR,
557  "LCDServer: bad scrollable bool in SWITCH_TO_MENU command: " +
558  tokens[x + 3]);
559  sendMessage(socket, "HUH?");
560  return;
561  }
562 
563  bool bOK = false;
564  int indent = tokens[x + 4].toInt(&bOK);
565  if (!bOK)
566  {
567  LOG(VB_GENERAL, LOG_ERR,
568  "LCDServer: bad indent in SWITCH_TO_MENU command: " +
569  tokens[x + 4]);
570  sendMessage(socket, "HUH?");
571  return;
572  }
573 
574  items.append(LCDMenuItem(selected, checked, text, indent, scrollable));
575  }
576 
577  if (m_lcd)
578  m_lcd->switchToMenu(&items, appName, bPopup);
579 
580  sendMessage(socket, "OK");
581 }
582 
583 void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket)
584 {
585  if (debug_level > 0)
586  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_CHANNEL_PROGRESS");
587 
588  QString flat = tokens.join(" ");
589 
590  if (tokens.count() != 3)
591  {
592  LOG(VB_GENERAL, LOG_ERR,
593  "LCDServer: bad SET_CHANNEL_PROGRESS command: " + flat);
594  sendMessage(socket, "HUH?");
595  return;
596  }
597 
598  bool bOK = false;
599  float progress = tokens[2].toFloat(&bOK);
600  if (!bOK)
601  {
602  LOG(VB_GENERAL, LOG_ERR,
603  QString("LCDServer: bad float value in SET_CHANNEL_PROGRESS "
604  "command: %1").arg(tokens[2]));
605  sendMessage(socket, "HUH?");
606  return;
607  }
608 
609  if (m_lcd)
610  m_lcd->setChannelProgress(tokens[1], progress);
611 
612  sendMessage(socket, "OK");
613 }
614 
615 void LCDServer::setGenericProgress(const QStringList &tokens, QTcpSocket *socket)
616 {
617  if (debug_level > 0)
618  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_GENERIC_PROGRESS");
619 
620  QString flat = tokens.join(" ");
621 
622  if (tokens.count() != 3)
623  {
624  LOG(VB_GENERAL, LOG_ERR,
625  "LCDServer: bad SET_GENERIC_PROGRESS command: " + flat);
626  sendMessage(socket, "HUH?");
627  return;
628  }
629 
630  bool bOK = false;
631  bool busy = tokens[1].toInt(&bOK) != 0;
632  if (!bOK)
633  {
634  LOG(VB_GENERAL, LOG_ERR,
635  QString("LCDServer: bad bool value in SET_GENERIC_PROGRESS "
636  "command: %1 %2").arg(tokens[1], tokens[2]));
637  sendMessage(socket, "HUH?");
638  return;
639  }
640  float progress = tokens[2].toFloat(&bOK);
641  if (!bOK)
642  {
643  LOG(VB_GENERAL, LOG_ERR,
644  QString("LCDServer: bad float value in SET_GENERIC_PROGRESS "
645  "command: %1").arg(tokens[2]));
646  sendMessage(socket, "HUH?");
647  return;
648  }
649 
650  if (m_lcd)
652 
653  sendMessage(socket, "OK");
654 }
655 
656 void LCDServer::setMusicProgress(const QStringList &tokens, QTcpSocket *socket)
657 {
658  if (debug_level > 0)
659  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_MUSIC_PROGRESS");
660 
661  QString flat = tokens.join(" ");
662 
663  if (tokens.count() != 3)
664  {
665  LOG(VB_GENERAL, LOG_ERR,
666  "LCDServer: bad SET_MUSIC_PROGRESS command: " + flat);
667  sendMessage(socket, "HUH?");
668  return;
669  }
670 
671  bool bOK = false;
672  float progress = tokens[2].toFloat(&bOK);
673  if (!bOK)
674  {
675  LOG(VB_GENERAL, LOG_ERR,
676  "LCDServer: bad float value in SET_MUSIC_PROGRESS command: " +
677  tokens[2]);
678  sendMessage(socket, "HUH?");
679  return;
680  }
681 
682  if (m_lcd)
683  m_lcd->setMusicProgress(tokens[1], progress);
684 
685  sendMessage(socket, "OK");
686 }
687 
688 void LCDServer::setMusicProp(const QStringList &tokens, QTcpSocket *socket)
689 {
690  if (debug_level > 0)
691  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_MUSIC_PROP");
692 
693  QString flat = tokens.join(" ");
694 
695  if (tokens.count() < 3)
696  {
697  LOG(VB_GENERAL, LOG_ERR,
698  "LCDServer: bad SET_MUSIC_PROP command: " + flat);
699  sendMessage(socket, "HUH?");
700  return;
701  }
702 
703  if (tokens[1] == "SHUFFLE")
704  {
705  if (tokens.count () != 3)
706  {
707  LOG(VB_GENERAL, LOG_ERR,
708  "LCDServer: missing argument for SET_MUSIC_PROP SHUFFLE "
709  "command: " + flat);
710  sendMessage(socket, "HUH?");
711  return;
712  }
713  bool bOk = false;
714  int state = tokens[2].toInt (&bOk);
715  if (!bOk)
716  {
717  LOG(VB_GENERAL, LOG_ERR,
718  "LCDServer: bad argument for SET_MUSIC_PROP SHUFFLE "
719  "command: " + tokens[2]);
720  sendMessage(socket, "HUH?");
721  return;
722  }
723  if (m_lcd)
724  m_lcd->setMusicShuffle (state);
725  }
726  else if (tokens[1] == "REPEAT")
727  {
728  if (tokens.count () != 3)
729  {
730  LOG(VB_GENERAL, LOG_ERR,
731  "LCDServer: missing argument for SET_MUSIC_PROP REPEAT "
732  "command: " + flat);
733  sendMessage(socket, "HUH?");
734  return;
735  }
736  bool bOk = false;
737  int state = tokens[2].toInt (&bOk);
738  if (!bOk)
739  {
740  LOG(VB_GENERAL, LOG_ERR,
741  "LCDServer: bad argument for SET_MUSIC_PROP REPEAT command: " +
742  tokens[2]);
743  sendMessage(socket, "HUH?");
744  return;
745  }
746  if (m_lcd)
747  m_lcd->setMusicRepeat (state);
748  }
749  else
750  {
751  LOG(VB_GENERAL, LOG_ERR,
752  "LCDServer: bad argument for SET_MUSIC_PROP command: " + tokens[1]);
753  sendMessage(socket, "HUH?");
754  return;
755  }
756 
757  sendMessage(socket, "OK");
758 }
759 
760 void LCDServer::setVolumeLevel(const QStringList &tokens, QTcpSocket *socket)
761 {
762  if (debug_level > 0)
763  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_VOLUME_LEVEL");
764 
765  QString flat = tokens.join(" ");
766 
767  if (tokens.count() != 2)
768  {
769  LOG(VB_GENERAL, LOG_ERR,
770  "LCDServer: bad SET_VOLUME_LEVEL command: " + flat);
771  sendMessage(socket, "HUH?");
772  return;
773  }
774 
775  bool bOK = false;
776  float progress = tokens[1].toFloat(&bOK);
777  if (!bOK)
778  {
779  LOG(VB_GENERAL, LOG_ERR,
780  "LCDServer: bad float value in SET_VOLUME_LEVEL command: " +
781  tokens[1]);
782  sendMessage(socket, "HUH?");
783  return;
784  }
785 
786  if (m_lcd)
788 
789  sendMessage(socket, "OK");
790 }
791 
792 void LCDServer::updateLEDs(const QStringList &tokens, QTcpSocket *socket)
793 {
794  if (debug_level > 0)
795  LOG(VB_GENERAL, LOG_INFO, "LCDServer: UPDATE_LEDS");
796 
797  QString flat = tokens.join(" ");
798 
799  if (tokens.count() != 2)
800  {
801  LOG(VB_GENERAL, LOG_ERR, "LCDServer: bad UPDATE_LEDs command: " + flat);
802  sendMessage(socket, "HUH?");
803  return;
804  }
805 
806  bool bOK = false;
807  int mask = tokens[1].toInt(&bOK);
808  if (!bOK)
809  {
810  LOG(VB_GENERAL, LOG_ERR,
811  "LCDServer: bad mask in UPDATE_LEDS command: " + tokens[1]);
812  sendMessage(socket, "HUH?");
813  return;
814  }
815 
816  if (m_lcd)
817  m_lcd->updateLEDs(mask);
818 
819  sendMessage(socket, "OK");
820 }
LCDServer::shutDown
void shutDown()
Definition: lcdserver.cpp:275
LCDProcClient::setMusicShuffle
void setMusicShuffle(int shuffle)
Definition: lcdprocclient.cpp:1712
LCDProcClient::setVolumeLevel
void setVolumeLevel(float value)
Definition: lcdprocclient.cpp:1722
LCDServer::setMusicProp
void setMusicProp(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:688
LCDServer::m_lastSocket
QTcpSocket * m_lastSocket
Definition: lcdserver.h:68
LCDServer::sendKeyPress
void sendKeyPress(const QString &key_pressed)
Definition: lcdserver.cpp:296
ServerPool::close
void close(void)
Definition: serverpool.cpp:370
progress
bool progress
Definition: mythcommflag.cpp:69
ServerPool
Manages a collection of sockets listening on different ports.
Definition: serverpool.h:59
LCDProcClient::getLCDWidth
int getLCDWidth(void) const
Definition: lcdprocclient.h:63
LCDServer::updateLEDs
void updateLEDs(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:792
LCDServer::setChannelProgress
void setChannelProgress(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:583
LCDServer::parseCommand
static QStringList parseCommand(QString &command)
Definition: lcdserver.cpp:156
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
LCDServer::parseTokens
void parseTokens(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:184
UNCHECKED
@ UNCHECKED
Definition: lcddevice.h:17
ServerPool::newConnection
void newConnection(QTcpSocket *)
LCDServer::sendConnected
void sendConnected(QTcpSocket *socket)
Definition: lcdserver.cpp:306
LCDServer::LCDServer
LCDServer(int port, QString message, std::chrono::seconds messageTime)
Definition: lcdserver.cpp:82
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
LCDProcClient::switchToGeneric
void switchToGeneric(QList< LCDTextItem > *textItems)
Definition: lcdprocclient.cpp:2252
mythdate.h
LCDProcClient::setStartupMessage
void setStartupMessage(QString msg, std::chrono::seconds messagetime)
Definition: lcdprocclient.cpp:625
LCDServer::switchToNothing
void switchToNothing(QTcpSocket *socket)
Definition: lcdserver.cpp:470
LCDProcClient::switchToTime
void switchToTime()
Definition: lcdprocclient.cpp:2201
LCDServer::readSocket
void readSocket()
Definition: lcdserver.cpp:137
LCDServer::setVolumeLevel
void setVolumeLevel(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:760
LCDServer::switchToGeneric
void switchToGeneric(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:357
LCDProcClient::switchToNothing
void switchToNothing()
Definition: lcdprocclient.cpp:2277
LCDServer::switchToChannel
void switchToChannel(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:428
LCDServer::switchToMusic
void switchToMusic(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:336
LCDProcClient::setChannelProgress
void setChannelProgress(const QString &time, float value)
Definition: lcdprocclient.cpp:1635
LCDProcClient::setMusicRepeat
void setMusicRepeat(int repeat)
Definition: lcdprocclient.cpp:1702
LCDProcClient::switchToChannel
void switchToChannel(const QString &channum="", const QString &title="", const QString &subtitle="")
Definition: lcdprocclient.cpp:2227
LCDProcClient::stopAll
void stopAll(void)
Definition: lcdprocclient.cpp:768
LCDServer::m_serverPool
ServerPool * m_serverPool
Definition: lcdserver.h:67
ALIGN_CENTERED
@ ALIGN_CENTERED
Definition: lcddevice.h:57
LCDProcClient::switchToMusic
void switchToMusic(const QString &artist, const QString &album, const QString &track)
Definition: lcdprocclient.cpp:2214
LCDProcClient::setGenericProgress
void setGenericProgress(bool busy, float value)
Definition: lcdprocclient.cpp:1651
ALIGN_LEFT
@ ALIGN_LEFT
Definition: lcddevice.h:57
LCDMenuItem
Definition: lcddevice.h:21
TEXT_ALIGNMENT
TEXT_ALIGNMENT
Definition: lcddevice.h:57
LCDServer::setMusicProgress
void setMusicProgress(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:656
LCDProcClient
Definition: lcdprocclient.h:20
LCDServer::endConnection
void endConnection(void)
Definition: lcdserver.cpp:122
CHECKED_STATE
CHECKED_STATE
Definition: lcddevice.h:17
LCDProcClient::getLCDHeight
int getLCDHeight(void) const
Definition: lcdprocclient.h:64
ALIGN_RIGHT
@ ALIGN_RIGHT
Definition: lcddevice.h:57
LCDServer::switchToMenu
void switchToMenu(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:481
LCDProcClient::updateLEDs
void updateLEDs(int mask)
Definition: lcdprocclient.cpp:1737
lcdserver.h
NOTCHECKABLE
@ NOTCHECKABLE
Definition: lcddevice.h:17
LCDServer::switchToVolume
void switchToVolume(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:449
LCDServer::switchToTime
void switchToTime(QTcpSocket *socket)
Definition: lcdserver.cpp:325
LCDProcClient::switchToVolume
void switchToVolume(const QString &app_name)
Definition: lcdprocclient.cpp:2264
mythcontext.h
debug_level
int debug_level
Definition: lcdserver.cpp:76
LCDTextItem
Definition: lcddevice.h:59
LCDServer::setGenericProgress
void setGenericProgress(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:615
ServerPool::listen
bool listen(QList< QHostAddress > addrs, quint16 port, bool requireall=true, PoolServerType type=kTCPServer)
Definition: serverpool.cpp:391
CHECKED
@ CHECKED
Definition: lcddevice.h:17
LCDProcClient::switchToMenu
void switchToMenu(QList< LCDMenuItem > *menuItems, const QString &app_name="", bool popMenu=true)
Definition: lcdprocclient.cpp:2240
lcddevice.h
LCDServer::sendMessage
static void sendMessage(QTcpSocket *where, const QString &what)
Definition: lcdserver.cpp:288
LCDServer::m_lcd
LCDProcClient * m_lcd
Definition: lcdserver.h:66
indent
static QString indent(uint level)
Definition: mythsettings.cpp:21
LCDProcClient::SetupLCD
bool SetupLCD(void)
Definition: lcdprocclient.cpp:121
LCDServer::newConnection
void newConnection(QTcpSocket *socket)
Definition: lcdserver.cpp:108
LCDProcClient::setMusicProgress
void setMusicProgress(QString time, float value)
Definition: lcdprocclient.cpp:1686
LCDProcClient::reset
void reset(void)
Definition: lcdprocclient.cpp:1745