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