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