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  {
177  s = s + c;
178  }
179  }
180 
181  tokens.append(s);
182 
183  return tokens;
184 }
185 
186 void LCDServer::parseTokens(const QStringList &tokens, QTcpSocket *socket)
187 {
188  //
189  // parse commands coming in from the socket
190  //
191 
192  if (tokens[0] == "HALT" ||
193  tokens[0] == "QUIT" ||
194  tokens[0] == "SHUTDOWN")
195  {
196  shutDown();
197  }
198  else if (tokens[0] == "HELLO")
199  {
200  sendConnected(socket);
201  }
202  else if (tokens[0] == "SWITCH_TO_TIME")
203  {
204  switchToTime(socket);
205  }
206  else if (tokens[0] == "SWITCH_TO_MUSIC")
207  {
208  switchToMusic(tokens, socket);
209  }
210  else if (tokens[0] == "SWITCH_TO_VOLUME")
211  {
212  switchToVolume(tokens, socket);
213  }
214  else if (tokens[0] == "SWITCH_TO_GENERIC")
215  {
216  switchToGeneric(tokens, socket);
217  }
218  else if (tokens[0] == "SWITCH_TO_MENU")
219  {
220  switchToMenu(tokens, socket);
221  }
222  else if (tokens[0] == "SWITCH_TO_CHANNEL")
223  {
224  switchToChannel(tokens, socket);
225  }
226  else if (tokens[0] == "SWITCH_TO_NOTHING")
227  {
228  switchToNothing(socket);
229  }
230  else if (tokens[0] == "SET_VOLUME_LEVEL")
231  {
232  setVolumeLevel(tokens, socket);
233  }
234  else if (tokens[0] == "SET_GENERIC_PROGRESS")
235  {
236  setGenericProgress(tokens, socket);
237  }
238  else if (tokens[0] == "SET_MUSIC_PROGRESS")
239  {
240  setMusicProgress(tokens, socket);
241  }
242  else if (tokens[0] == "SET_MUSIC_PLAYER_PROP")
243  {
244  setMusicProp(tokens, socket);
245  }
246  else if (tokens[0] == "SET_CHANNEL_PROGRESS")
247  {
248  setChannelProgress(tokens, socket);
249  }
250  else if (tokens[0] == "UPDATE_LEDS")
251  {
252  updateLEDs(tokens, socket);
253  }
254  else if (tokens[0] == "STOP_ALL")
255  {
256  if (m_lcd)
257  m_lcd->stopAll();
258  }
259  else if (tokens[0] == "RESET")
260  {
261  // reset lcd & reload settings
262  if (m_lcd)
263  m_lcd->reset();
264  }
265  else
266  {
267  QString did_not_parse = tokens.join(" ");
268 
269  if (debug_level > 0)
270  LOG(VB_GENERAL, LOG_ERR, "LCDServer::failed to parse this: " +
271  did_not_parse);
272 
273  sendMessage(socket, "HUH?");
274  }
275 }
276 
278 {
279  if (debug_level > 0)
280  LOG(VB_GENERAL, LOG_INFO, "LCDServer:: shuting down");
281 
282  m_serverPool->disconnect();
283  m_serverPool->close();
284  delete m_serverPool;
285  m_serverPool = nullptr;
286 
287  exit(0);
288 }
289 
290 void LCDServer::sendMessage(QTcpSocket *where, const QString &what)
291 {
292  QString message = what;
293  message.append("\n");
294  QByteArray tmp = message.toUtf8();
295  where->write(tmp.constData(), tmp.length());
296 }
297 
298 void LCDServer::sendKeyPress(const QString& key_pressed)
299 {
300  if (debug_level > 0)
301  LOG(VB_GENERAL, LOG_INFO, "LCDServer:: send key press: " + key_pressed);
302 
303  // send key press to last client that sent us a message
304  if (m_lastSocket)
305  sendMessage(m_lastSocket, "KEY " + key_pressed);
306 }
307 
308 void LCDServer::sendConnected(QTcpSocket *socket)
309 {
310  QString sWidth;
311  QString sHeight;
312  int nWidth = 0;
313  int nHeight = 0;
314 
315  if (m_lcd)
316  {
317  nWidth = m_lcd->getLCDWidth();
318  nHeight = m_lcd->getLCDHeight();
319  }
320 
321  sWidth = sWidth.setNum(nWidth);
322  sHeight = sHeight.setNum(nHeight);
323 
324  sendMessage(socket, "CONNECTED " + sWidth + " " + sHeight);
325 }
326 
327 void LCDServer::switchToTime(QTcpSocket *socket)
328 {
329  if (debug_level > 0)
330  LOG(VB_GENERAL, LOG_INFO, "LCDServer:: SWITCH_TO_TIME");
331 
332  if (m_lcd)
333  m_lcd->switchToTime();
334 
335  sendMessage(socket, "OK");
336 }
337 
338 void LCDServer::switchToMusic(const QStringList &tokens, QTcpSocket *socket)
339 {
340  if (debug_level > 0)
341  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_MUSIC");
342 
343  QString flat = tokens.join(" ");
344 
345  if (tokens.count() != 4)
346  {
347  LOG(VB_GENERAL, LOG_ERR,
348  "LCDServer: bad SWITCH_TO_MUSIC command: " + flat);
349  sendMessage(socket, "HUH?");
350  return;
351  }
352 
353  if (m_lcd)
354  m_lcd->switchToMusic(tokens[1], tokens[2], tokens[3]);
355 
356  sendMessage(socket, "OK");
357 }
358 
359 void LCDServer::switchToGeneric(const QStringList &tokens, QTcpSocket *socket)
360 {
361  if (debug_level > 0)
362  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_GENERIC");
363 
364  QString flat = tokens.join(" ");
365 
366  if ((tokens.count() - 1) % 5 != 0)
367  {
368  LOG(VB_GENERAL, LOG_ERR,
369  "LCDServer: bad no. of args SWITCH_TO_GENERIC command: " + flat);
370  sendMessage(socket, "HUH?");
371  return;
372  }
373 
374  QList<LCDTextItem> items;
375 
376  for (int x = 1; x < tokens.count(); x += 5)
377  {
378  bool bOK = false;
379  int row = tokens[x].toInt(&bOK);
380  if (!bOK)
381  {
382  LOG(VB_GENERAL, LOG_ERR,
383  "LCDServer: bad row no. in SWITCH_TO_GENERIC "
384  "command: " + tokens[x]);
385  sendMessage(socket, "HUH?");
386  return;
387  }
388 
389  TEXT_ALIGNMENT align = ALIGN_LEFT;
390  if (tokens[x + 1] == "ALIGN_LEFT")
391  align = ALIGN_LEFT;
392  else if (tokens[x + 1] == "ALIGN_RIGHT")
393  align = ALIGN_RIGHT;
394  else if (tokens[x + 1] == "ALIGN_CENTERED")
395  align = ALIGN_CENTERED;
396  else
397  {
398  LOG(VB_GENERAL, LOG_ERR,
399  "LCDServer: bad align in SWITCH_TO_GENERIC command: " +
400  tokens[x + 1]);
401  sendMessage(socket, "HUH?");
402  return;
403  }
404 
405  const QString& text = tokens[x + 2];
406  const QString& screen = tokens[x + 3];
407  bool scrollable = false;
408  if (tokens[x + 4] == "TRUE")
409  scrollable = true;
410  else if (tokens[x + 4] == "FALSE")
411  scrollable = false;
412  else
413  {
414  LOG(VB_GENERAL, LOG_ERR,
415  "LCDServer: bad scrollable bool in SWITCH_TO_GENERIC "
416  "command: " + tokens[x + 4]);
417  sendMessage(socket, "HUH?");
418  return;
419  }
420 
421  items.append(LCDTextItem(row, align, text, screen, scrollable));
422  }
423 
424  if (m_lcd)
425  m_lcd->switchToGeneric(&items);
426 
427  sendMessage(socket, "OK");
428 }
429 
430 void LCDServer::switchToChannel(const QStringList &tokens, QTcpSocket *socket)
431 {
432  if (debug_level > 0)
433  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_CHANNEL");
434 
435  QString flat = tokens.join(" ");
436 
437  if (tokens.count() != 4)
438  {
439  LOG(VB_GENERAL, LOG_ERR,
440  "LCDServer: bad SWITCH_TO_CHANNEL command: " + flat);
441  sendMessage(socket, "HUH?");
442  return;
443  }
444 
445  if (m_lcd)
446  m_lcd->switchToChannel(tokens[1], tokens[2], tokens[3]);
447 
448  sendMessage(socket, "OK");
449 }
450 
451 void LCDServer::switchToVolume(const QStringList &tokens, QTcpSocket *socket)
452 {
453  if (debug_level > 0)
454  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_VOLUME");
455 
456  QString flat = tokens.join(" ");
457 
458  if (tokens.count() != 2)
459  {
460  LOG(VB_GENERAL, LOG_ERR,
461  "LCDServer: bad SWITCH_TO_VOLUME command: " + flat);
462  sendMessage(socket, "HUH?");
463  return;
464  }
465 
466  if (m_lcd)
467  m_lcd->switchToVolume(tokens[1]);
468 
469  sendMessage(socket, "OK");
470 }
471 
472 void LCDServer::switchToNothing(QTcpSocket *socket)
473 {
474  if (debug_level > 0)
475  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_NOTHING");
476 
477  if (m_lcd)
479 
480  sendMessage(socket, "OK");
481 }
482 
483 void LCDServer::switchToMenu(const QStringList &tokens, QTcpSocket *socket)
484 {
485  if (debug_level > 0)
486  LOG(VB_GENERAL, LOG_INFO,
487  QString("LCDServer: SWITCH_TO_MENU: %1").arg(tokens.count()));
488 
489  QString flat = tokens.join(" ");
490 
491  if ((tokens.count() - 3) % 5 != 0)
492  {
493  LOG(VB_GENERAL, LOG_ERR,
494  "LCDServer: bad no. of args SWITCH_TO_MENU command: " + flat);
495  sendMessage(socket, "HUH?");
496  return;
497  }
498 
499  const QString& appName = tokens[1];
500 
501  bool bPopup = false;
502  if (tokens[2] == "TRUE")
503  bPopup = true;
504  else if (tokens[2] == "FALSE")
505  bPopup = false;
506  else
507  {
508  LOG(VB_GENERAL, LOG_ERR,
509  "LCDServer: bad popup bool in SWITCH_TO_MENU command: " +
510  tokens[2]);
511  sendMessage(socket, "HUH?");
512  return;
513  }
514 
515  QList<LCDMenuItem> items;
516 
517  for (int x = 3; x < tokens.count(); x += 5)
518  {
519  const QString& text = tokens[x];
520 
521  CHECKED_STATE checked = CHECKED;
522  if (tokens[x + 1] == "CHECKED")
523  checked = CHECKED;
524  else if (tokens[x + 1] == "UNCHECKED")
525  checked = UNCHECKED;
526  else if (tokens[x + 1] == "NOTCHECKABLE")
527  checked = NOTCHECKABLE;
528  else
529  {
530  LOG(VB_GENERAL, LOG_ERR,
531  "LCDServer: bad checked state in SWITCH_TO_MENU command: " +
532  tokens[x + 1]);
533  sendMessage(socket, "HUH?");
534  return;
535  }
536 
537  bool selected = false;
538  if (tokens[x + 2] == "TRUE")
539  selected = true;
540  else if (tokens[x + 2] == "FALSE")
541  selected = false;
542  else
543  {
544  LOG(VB_GENERAL, LOG_ERR,
545  "LCDServer: bad selected state in SWITCH_TO_MENU command: " +
546  tokens[x + 2]);
547  sendMessage(socket, "HUH?");
548  return;
549  }
550 
551  bool scrollable = false;
552  if (tokens[x + 3] == "TRUE")
553  scrollable = true;
554  else if (tokens[x + 3] == "FALSE")
555  scrollable = false;
556  else
557  {
558  LOG(VB_GENERAL, LOG_ERR,
559  "LCDServer: bad scrollable bool in SWITCH_TO_MENU command: " +
560  tokens[x + 3]);
561  sendMessage(socket, "HUH?");
562  return;
563  }
564 
565  bool bOK = false;
566  int indent = tokens[x + 4].toInt(&bOK);
567  if (!bOK)
568  {
569  LOG(VB_GENERAL, LOG_ERR,
570  "LCDServer: bad indent in SWITCH_TO_MENU command: " +
571  tokens[x + 4]);
572  sendMessage(socket, "HUH?");
573  return;
574  }
575 
576  items.append(LCDMenuItem(selected, checked, text, indent, scrollable));
577  }
578 
579  if (m_lcd)
580  m_lcd->switchToMenu(&items, appName, bPopup);
581 
582  sendMessage(socket, "OK");
583 }
584 
585 void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket)
586 {
587  if (debug_level > 0)
588  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_CHANNEL_PROGRESS");
589 
590  QString flat = tokens.join(" ");
591 
592  if (tokens.count() != 3)
593  {
594  LOG(VB_GENERAL, LOG_ERR,
595  "LCDServer: bad SET_CHANNEL_PROGRESS command: " + flat);
596  sendMessage(socket, "HUH?");
597  return;
598  }
599 
600  bool bOK = false;
601  float progress = tokens[2].toFloat(&bOK);
602  if (!bOK)
603  {
604  LOG(VB_GENERAL, LOG_ERR,
605  QString("LCDServer: bad float value in SET_CHANNEL_PROGRESS "
606  "command: %1").arg(tokens[2]));
607  sendMessage(socket, "HUH?");
608  return;
609  }
610 
611  if (m_lcd)
612  m_lcd->setChannelProgress(tokens[1], progress);
613 
614  sendMessage(socket, "OK");
615 }
616 
617 void LCDServer::setGenericProgress(const QStringList &tokens, QTcpSocket *socket)
618 {
619  if (debug_level > 0)
620  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_GENERIC_PROGRESS");
621 
622  QString flat = tokens.join(" ");
623 
624  if (tokens.count() != 3)
625  {
626  LOG(VB_GENERAL, LOG_ERR,
627  "LCDServer: bad SET_GENERIC_PROGRESS command: " + flat);
628  sendMessage(socket, "HUH?");
629  return;
630  }
631 
632  bool bOK = false;
633  bool busy = tokens[1].toInt(&bOK) != 0;
634  if (!bOK)
635  {
636  LOG(VB_GENERAL, LOG_ERR,
637  QString("LCDServer: bad bool value in SET_GENERIC_PROGRESS "
638  "command: %1 %2").arg(tokens[1], tokens[2]));
639  sendMessage(socket, "HUH?");
640  return;
641  }
642  float progress = tokens[2].toFloat(&bOK);
643  if (!bOK)
644  {
645  LOG(VB_GENERAL, LOG_ERR,
646  QString("LCDServer: bad float value in SET_GENERIC_PROGRESS "
647  "command: %1").arg(tokens[2]));
648  sendMessage(socket, "HUH?");
649  return;
650  }
651 
652  if (m_lcd)
654 
655  sendMessage(socket, "OK");
656 }
657 
658 void LCDServer::setMusicProgress(const QStringList &tokens, QTcpSocket *socket)
659 {
660  if (debug_level > 0)
661  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_MUSIC_PROGRESS");
662 
663  QString flat = tokens.join(" ");
664 
665  if (tokens.count() != 3)
666  {
667  LOG(VB_GENERAL, LOG_ERR,
668  "LCDServer: bad SET_MUSIC_PROGRESS command: " + flat);
669  sendMessage(socket, "HUH?");
670  return;
671  }
672 
673  bool bOK = false;
674  float progress = tokens[2].toFloat(&bOK);
675  if (!bOK)
676  {
677  LOG(VB_GENERAL, LOG_ERR,
678  "LCDServer: bad float value in SET_MUSIC_PROGRESS command: " +
679  tokens[2]);
680  sendMessage(socket, "HUH?");
681  return;
682  }
683 
684  if (m_lcd)
685  m_lcd->setMusicProgress(tokens[1], progress);
686 
687  sendMessage(socket, "OK");
688 }
689 
690 void LCDServer::setMusicProp(const QStringList &tokens, QTcpSocket *socket)
691 {
692  if (debug_level > 0)
693  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_MUSIC_PROP");
694 
695  QString flat = tokens.join(" ");
696 
697  if (tokens.count() < 3)
698  {
699  LOG(VB_GENERAL, LOG_ERR,
700  "LCDServer: bad SET_MUSIC_PROP command: " + flat);
701  sendMessage(socket, "HUH?");
702  return;
703  }
704 
705  if (tokens[1] == "SHUFFLE")
706  {
707  if (tokens.count () != 3)
708  {
709  LOG(VB_GENERAL, LOG_ERR,
710  "LCDServer: missing argument for SET_MUSIC_PROP SHUFFLE "
711  "command: " + flat);
712  sendMessage(socket, "HUH?");
713  return;
714  }
715  bool bOk = false;
716  int state = tokens[2].toInt (&bOk);
717  if (!bOk)
718  {
719  LOG(VB_GENERAL, LOG_ERR,
720  "LCDServer: bad argument for SET_MUSIC_PROP SHUFFLE "
721  "command: " + tokens[2]);
722  sendMessage(socket, "HUH?");
723  return;
724  }
725  if (m_lcd)
726  m_lcd->setMusicShuffle (state);
727  }
728  else if (tokens[1] == "REPEAT")
729  {
730  if (tokens.count () != 3)
731  {
732  LOG(VB_GENERAL, LOG_ERR,
733  "LCDServer: missing argument for SET_MUSIC_PROP REPEAT "
734  "command: " + flat);
735  sendMessage(socket, "HUH?");
736  return;
737  }
738  bool bOk = false;
739  int state = tokens[2].toInt (&bOk);
740  if (!bOk)
741  {
742  LOG(VB_GENERAL, LOG_ERR,
743  "LCDServer: bad argument for SET_MUSIC_PROP REPEAT command: " +
744  tokens[2]);
745  sendMessage(socket, "HUH?");
746  return;
747  }
748  if (m_lcd)
749  m_lcd->setMusicRepeat (state);
750  }
751  else
752  {
753  LOG(VB_GENERAL, LOG_ERR,
754  "LCDServer: bad argument for SET_MUSIC_PROP command: " + tokens[1]);
755  sendMessage(socket, "HUH?");
756  return;
757  }
758 
759  sendMessage(socket, "OK");
760 }
761 
762 void LCDServer::setVolumeLevel(const QStringList &tokens, QTcpSocket *socket)
763 {
764  if (debug_level > 0)
765  LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_VOLUME_LEVEL");
766 
767  QString flat = tokens.join(" ");
768 
769  if (tokens.count() != 2)
770  {
771  LOG(VB_GENERAL, LOG_ERR,
772  "LCDServer: bad SET_VOLUME_LEVEL command: " + flat);
773  sendMessage(socket, "HUH?");
774  return;
775  }
776 
777  bool bOK = false;
778  float progress = tokens[1].toFloat(&bOK);
779  if (!bOK)
780  {
781  LOG(VB_GENERAL, LOG_ERR,
782  "LCDServer: bad float value in SET_VOLUME_LEVEL command: " +
783  tokens[1]);
784  sendMessage(socket, "HUH?");
785  return;
786  }
787 
788  if (m_lcd)
790 
791  sendMessage(socket, "OK");
792 }
793 
794 void LCDServer::updateLEDs(const QStringList &tokens, QTcpSocket *socket)
795 {
796  if (debug_level > 0)
797  LOG(VB_GENERAL, LOG_INFO, "LCDServer: UPDATE_LEDS");
798 
799  QString flat = tokens.join(" ");
800 
801  if (tokens.count() != 2)
802  {
803  LOG(VB_GENERAL, LOG_ERR, "LCDServer: bad UPDATE_LEDs command: " + flat);
804  sendMessage(socket, "HUH?");
805  return;
806  }
807 
808  bool bOK = false;
809  int mask = tokens[1].toInt(&bOK);
810  if (!bOK)
811  {
812  LOG(VB_GENERAL, LOG_ERR,
813  "LCDServer: bad mask in UPDATE_LEDS command: " + tokens[1]);
814  sendMessage(socket, "HUH?");
815  return;
816  }
817 
818  if (m_lcd)
819  m_lcd->updateLEDs(mask);
820 
821  sendMessage(socket, "OK");
822 }
LCDServer::shutDown
void shutDown()
Definition: lcdserver.cpp:277
LCDProcClient::setMusicShuffle
void setMusicShuffle(int shuffle)
Definition: lcdprocclient.cpp:1720
LCDProcClient::setVolumeLevel
void setVolumeLevel(float value)
Definition: lcdprocclient.cpp:1730
LCDServer::setMusicProp
void setMusicProp(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:690
LCDServer::m_lastSocket
QTcpSocket * m_lastSocket
Definition: lcdserver.h:68
LCDServer::sendKeyPress
void sendKeyPress(const QString &key_pressed)
Definition: lcdserver.cpp:298
ServerPool::close
void close(void)
Definition: serverpool.cpp:374
UNCHECKED
@ UNCHECKED
Definition: lcddevice.h:17
ALIGN_CENTERED
@ ALIGN_CENTERED
Definition: lcddevice.h:57
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:794
LCDServer::setChannelProgress
void setChannelProgress(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:585
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:186
CHECKED
@ CHECKED
Definition: lcddevice.h:17
ServerPool::newConnection
void newConnection(QTcpSocket *)
LCDServer::sendConnected
void sendConnected(QTcpSocket *socket)
Definition: lcdserver.cpp:308
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:2270
mythdate.h
LCDProcClient::setStartupMessage
void setStartupMessage(QString msg, std::chrono::seconds messagetime)
Definition: lcdprocclient.cpp:626
LCDServer::switchToNothing
void switchToNothing(QTcpSocket *socket)
Definition: lcdserver.cpp:472
LCDProcClient::switchToTime
void switchToTime()
Definition: lcdprocclient.cpp:2219
LCDServer::readSocket
void readSocket()
Definition: lcdserver.cpp:137
LCDServer::setVolumeLevel
void setVolumeLevel(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:762
LCDServer::switchToGeneric
void switchToGeneric(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:359
LCDProcClient::switchToNothing
void switchToNothing()
Definition: lcdprocclient.cpp:2295
LCDServer::switchToChannel
void switchToChannel(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:430
ALIGN_RIGHT
@ ALIGN_RIGHT
Definition: lcddevice.h:57
LCDServer::switchToMusic
void switchToMusic(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:338
LCDProcClient::setChannelProgress
void setChannelProgress(const QString &time, float value)
Definition: lcdprocclient.cpp:1643
CHECKED_STATE
CHECKED_STATE
Definition: lcddevice.h:17
LCDProcClient::setMusicRepeat
void setMusicRepeat(int repeat)
Definition: lcdprocclient.cpp:1710
LCDProcClient::switchToChannel
void switchToChannel(const QString &channum="", const QString &title="", const QString &subtitle="")
Definition: lcdprocclient.cpp:2245
LCDProcClient::stopAll
void stopAll(void)
Definition: lcdprocclient.cpp:769
LCDServer::m_serverPool
ServerPool * m_serverPool
Definition: lcdserver.h:67
ALIGN_LEFT
@ ALIGN_LEFT
Definition: lcddevice.h:57
NOTCHECKABLE
@ NOTCHECKABLE
Definition: lcddevice.h:17
LCDProcClient::switchToMusic
void switchToMusic(const QString &artist, const QString &album, const QString &track)
Definition: lcdprocclient.cpp:2232
LCDProcClient::setGenericProgress
void setGenericProgress(bool busy, float value)
Definition: lcdprocclient.cpp:1659
LCDMenuItem
Definition: lcddevice.h:21
LCDServer::setMusicProgress
void setMusicProgress(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:658
LCDProcClient
Definition: lcdprocclient.h:20
LCDServer::endConnection
void endConnection(void)
Definition: lcdserver.cpp:122
LCDProcClient::getLCDHeight
int getLCDHeight(void) const
Definition: lcdprocclient.h:64
LCDServer::switchToMenu
void switchToMenu(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:483
LCDProcClient::updateLEDs
void updateLEDs(int mask)
Definition: lcdprocclient.cpp:1742
lcdserver.h
LCDServer::switchToVolume
void switchToVolume(const QStringList &tokens, QTcpSocket *socket)
Definition: lcdserver.cpp:451
LCDServer::switchToTime
void switchToTime(QTcpSocket *socket)
Definition: lcdserver.cpp:327
LCDProcClient::switchToVolume
void switchToVolume(const QString &app_name)
Definition: lcdprocclient.cpp:2282
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:617
ServerPool::listen
bool listen(QList< QHostAddress > addrs, quint16 port, bool requireall=true, PoolServerType type=kTCPServer)
Definition: serverpool.cpp:395
TEXT_ALIGNMENT
TEXT_ALIGNMENT
Definition: lcddevice.h:57
LCDProcClient::switchToMenu
void switchToMenu(QList< LCDMenuItem > *menuItems, const QString &app_name="", bool popMenu=true)
Definition: lcdprocclient.cpp:2258
lcddevice.h
LCDServer::sendMessage
static void sendMessage(QTcpSocket *where, const QString &what)
Definition: lcdserver.cpp:290
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:122
LCDServer::newConnection
void newConnection(QTcpSocket *socket)
Definition: lcdserver.cpp:108
LCDProcClient::setMusicProgress
void setMusicProgress(QString time, float value)
Definition: lcdprocclient.cpp:1694
LCDProcClient::reset
void reset(void)
Definition: lcdprocclient.cpp:1750