00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #include <cstdlib>
00059
00060 #include <QCoreApplication>
00061 #include <QStringList>
00062 #include <QRegExp>
00063 #include <QDir>
00064 #include <QList>
00065
00066 #include "mythmiscutil.h"
00067 #include "mythcontext.h"
00068 #include "lcddevice.h"
00069
00070 #include "lcdserver.h"
00071
00072 int debug_level = 0;
00073
00074 #define LOC QString("LCDServer: ")
00075 #define LOC_WARN QString("LCDServer, Warning: ")
00076 #define LOC_ERR QString("LCDServer, Error: ")
00077
00078 LCDServer::LCDServer(int port, QString message, int messageTime)
00079 :QObject()
00080 {
00081 m_lcd = new LCDProcClient(this);
00082 if (!m_lcd->SetupLCD())
00083 {
00084 delete m_lcd;
00085 m_lcd = NULL;
00086 }
00087
00088 m_serverPool = new ServerPool();
00089 connect(m_serverPool, SIGNAL(newConnection(QTcpSocket*)),
00090 this, SLOT(newConnection(QTcpSocket*)));
00091
00092 if (!m_serverPool->listen(port))
00093 {
00094 LOG(VB_GENERAL, LOG_ERR, "There is probably a copy of mythlcdserver "
00095 "already running. You can verify this by running: \n"
00096 "'ps ax | grep mythlcdserver'");
00097 delete m_serverPool;
00098 return;
00099 }
00100 m_lastSocket = NULL;
00101
00102 if (m_lcd)
00103 m_lcd->setStartupMessage(message, messageTime);
00104 }
00105
00106 void LCDServer::newConnection(QTcpSocket *socket)
00107 {
00108 connect(socket, SIGNAL(readyRead()),
00109 this, SLOT( readSocket()));
00110 connect(socket, SIGNAL(disconnected()),
00111 this, SLOT( endConnection()));
00112
00113 if (debug_level > 0)
00114 LOG(VB_NETWORK, LOG_INFO, "LCDServer: new connection");
00115
00116 if (m_lcd)
00117 m_lcd->switchToTime();
00118 }
00119
00120 void LCDServer::endConnection(void)
00121 {
00122 QTcpSocket *socket = dynamic_cast<QTcpSocket*>(sender());
00123 if (socket)
00124 {
00125 socket->close();
00126 socket->deleteLater();
00127 if (debug_level > 0)
00128 LOG(VB_NETWORK, LOG_INFO, "LCDServer: close connection");
00129 }
00130
00131 if (m_lastSocket == socket)
00132 m_lastSocket = NULL;
00133 }
00134
00135 void LCDServer::readSocket()
00136 {
00137 QTcpSocket *socket = dynamic_cast<QTcpSocket*>(sender());
00138 m_lastSocket = socket;
00139
00140 while(socket->canReadLine())
00141 {
00142 QString incoming_data = socket->readLine();
00143 incoming_data = incoming_data.replace( QRegExp("\n"), "" );
00144 incoming_data = incoming_data.replace( QRegExp("\r"), "" );
00145 incoming_data.simplified();
00146 QStringList tokens = parseCommand(incoming_data);
00147 parseTokens(tokens, socket);
00148 }
00149 }
00150
00151 QStringList LCDServer::parseCommand(QString &command)
00152 {
00153 QStringList tokens;
00154 QString s = "";
00155 QChar c;
00156 bool bInString = false;
00157
00158 for (int x = 0; x < command.length(); x++)
00159 {
00160 c = command[x];
00161 if (!bInString && c == '"')
00162 bInString = true;
00163 else if (bInString && c == '"')
00164 bInString = false;
00165 else if (!bInString && c == ' ')
00166 {
00167 tokens.append(s);
00168 s = "";
00169 }
00170 else
00171 s = s + c;
00172 }
00173
00174 tokens.append(s);
00175
00176 return tokens;
00177 }
00178
00179 void LCDServer::parseTokens(const QStringList &tokens, QTcpSocket *socket)
00180 {
00181
00182
00183
00184
00185 if (tokens[0] == "HALT" ||
00186 tokens[0] == "QUIT" ||
00187 tokens[0] == "SHUTDOWN")
00188 {
00189 shutDown();
00190 }
00191 else if (tokens[0] == "HELLO")
00192 {
00193 sendConnected(socket);
00194 }
00195 else if (tokens[0] == "SWITCH_TO_TIME")
00196 {
00197 switchToTime(socket);
00198 }
00199 else if (tokens[0] == "SWITCH_TO_MUSIC")
00200 {
00201 switchToMusic(tokens, socket);
00202 }
00203 else if (tokens[0] == "SWITCH_TO_VOLUME")
00204 {
00205 switchToVolume(tokens, socket);
00206 }
00207 else if (tokens[0] == "SWITCH_TO_GENERIC")
00208 {
00209 switchToGeneric(tokens, socket);
00210 }
00211 else if (tokens[0] == "SWITCH_TO_MENU")
00212 {
00213 switchToMenu(tokens, socket);
00214 }
00215 else if (tokens[0] == "SWITCH_TO_CHANNEL")
00216 {
00217 switchToChannel(tokens, socket);
00218 }
00219 else if (tokens[0] == "SWITCH_TO_NOTHING")
00220 {
00221 switchToNothing(socket);
00222 }
00223 else if (tokens[0] == "SET_VOLUME_LEVEL")
00224 {
00225 setVolumeLevel(tokens, socket);
00226 }
00227 else if (tokens[0] == "SET_GENERIC_PROGRESS")
00228 {
00229 setGenericProgress(tokens, socket);
00230 }
00231 else if (tokens[0] == "SET_MUSIC_PROGRESS")
00232 {
00233 setMusicProgress(tokens, socket);
00234 }
00235 else if (tokens[0] == "SET_MUSIC_PLAYER_PROP")
00236 {
00237 setMusicProp(tokens, socket);
00238 }
00239 else if (tokens[0] == "SET_CHANNEL_PROGRESS")
00240 {
00241 setChannelProgress(tokens, socket);
00242 }
00243 else if (tokens[0] == "UPDATE_LEDS")
00244 {
00245 updateLEDs(tokens, socket);
00246 }
00247 else if (tokens[0] == "STOP_ALL")
00248 {
00249 if (m_lcd)
00250 m_lcd->stopAll();
00251 }
00252 else if (tokens[0] == "RESET")
00253 {
00254
00255 if (m_lcd)
00256 m_lcd->reset();
00257 }
00258 else
00259 {
00260 QString did_not_parse = tokens.join(" ");
00261
00262 if (debug_level > 0)
00263 LOG(VB_GENERAL, LOG_ERR, "LCDServer::failed to parse this: " +
00264 did_not_parse);
00265
00266 sendMessage(socket, "HUH?");
00267 }
00268 }
00269
00270 void LCDServer::shutDown()
00271 {
00272 if (debug_level > 0)
00273 LOG(VB_GENERAL, LOG_INFO, "LCDServer:: shuting down");
00274
00275 m_serverPool->disconnect();
00276 m_serverPool->close();
00277 delete m_serverPool;
00278 m_serverPool = NULL;
00279
00280 exit(0);
00281 }
00282
00283 void LCDServer::sendMessage(QTcpSocket *where, const QString &what)
00284 {
00285 QString message = what;
00286 message.append("\n");
00287 QByteArray tmp = message.toUtf8();
00288 where->write(tmp.constData(), tmp.length());
00289 }
00290
00291 void LCDServer::sendKeyPress(QString key_pressed)
00292 {
00293 if (debug_level > 0)
00294 LOG(VB_GENERAL, LOG_INFO, "LCDServer:: send key press: " + key_pressed);
00295
00296
00297 if (m_lastSocket)
00298 sendMessage(m_lastSocket, "KEY " + key_pressed);
00299 }
00300
00301 void LCDServer::sendConnected(QTcpSocket *socket)
00302 {
00303 QString sWidth, sHeight;
00304 int nWidth = 0, nHeight = 0;
00305
00306 if (m_lcd)
00307 {
00308 nWidth = m_lcd->getLCDWidth();
00309 nHeight = m_lcd->getLCDHeight();
00310 }
00311
00312 sWidth = sWidth.setNum(nWidth);
00313 sHeight = sHeight.setNum(nHeight);
00314
00315 sendMessage(socket, "CONNECTED " + sWidth + " " + sHeight);
00316 }
00317
00318 void LCDServer::switchToTime(QTcpSocket *socket)
00319 {
00320 if (debug_level > 0)
00321 LOG(VB_GENERAL, LOG_INFO, "LCDServer:: SWITCH_TO_TIME");
00322
00323 if (m_lcd)
00324 m_lcd->switchToTime();
00325
00326 sendMessage(socket, "OK");
00327 }
00328
00329 void LCDServer::switchToMusic(const QStringList &tokens, QTcpSocket *socket)
00330 {
00331 if (debug_level > 0)
00332 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_MUSIC");
00333
00334 QString flat = tokens.join(" ");
00335
00336 if (tokens.count() != 4)
00337 {
00338 LOG(VB_GENERAL, LOG_ERR,
00339 "LCDServer: bad SWITCH_TO_MUSIC command: " + flat);
00340 sendMessage(socket, "HUH?");
00341 return;
00342 }
00343
00344 if (m_lcd)
00345 m_lcd->switchToMusic(tokens[1], tokens[2], tokens[3]);
00346
00347 sendMessage(socket, "OK");
00348 }
00349
00350 void LCDServer::switchToGeneric(const QStringList &tokens, QTcpSocket *socket)
00351 {
00352 if (debug_level > 0)
00353 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_GENERIC");
00354
00355 QString flat = tokens.join(" ");
00356
00357 if ((tokens.count() - 1) % 5 != 0)
00358 {
00359 LOG(VB_GENERAL, LOG_ERR,
00360 "LCDServer: bad no. of args SWITCH_TO_GENERIC command: " + flat);
00361 sendMessage(socket, "HUH?");
00362 return;
00363 }
00364
00365 QList<LCDTextItem> items;
00366
00367 for (int x = 1; x < tokens.count(); x += 5)
00368 {
00369 bool bOK;
00370 int row = tokens[x].toInt(&bOK);
00371 if (!bOK)
00372 {
00373 LOG(VB_GENERAL, LOG_ERR,
00374 "LCDServer: bad row no. in SWITCH_TO_GENERIC "
00375 "command: " + tokens[x]);
00376 sendMessage(socket, "HUH?");
00377 return;
00378 }
00379
00380 TEXT_ALIGNMENT align;
00381 if (tokens[x + 1] == "ALIGN_LEFT")
00382 align = ALIGN_LEFT;
00383 else if (tokens[x + 1] == "ALIGN_RIGHT")
00384 align = ALIGN_RIGHT;
00385 else if (tokens[x + 1] == "ALIGN_CENTERED")
00386 align = ALIGN_CENTERED;
00387 else
00388 {
00389 LOG(VB_GENERAL, LOG_ERR,
00390 "LCDServer: bad align in SWITCH_TO_GENERIC command: " +
00391 tokens[x + 1]);
00392 sendMessage(socket, "HUH?");
00393 return;
00394 }
00395
00396 QString text = tokens[x + 2];
00397 QString screen = tokens[x + 3];
00398 bool scrollable;
00399 if (tokens[x + 4] == "TRUE")
00400 scrollable = true;
00401 else if (tokens[x + 4] == "FALSE")
00402 scrollable = false;
00403 else
00404 {
00405 LOG(VB_GENERAL, LOG_ERR,
00406 "LCDServer: bad scrollable bool in SWITCH_TO_GENERIC "
00407 "command: " + tokens[x + 4]);
00408 sendMessage(socket, "HUH?");
00409 return;
00410 }
00411
00412 items.append(LCDTextItem(row, align, text, screen, scrollable));
00413 }
00414
00415 if (m_lcd)
00416 m_lcd->switchToGeneric(&items);
00417
00418 sendMessage(socket, "OK");
00419 }
00420
00421 void LCDServer::switchToChannel(const QStringList &tokens, QTcpSocket *socket)
00422 {
00423 if (debug_level > 0)
00424 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_CHANNEL");
00425
00426 QString flat = tokens.join(" ");
00427
00428 if (tokens.count() != 4)
00429 {
00430 LOG(VB_GENERAL, LOG_ERR,
00431 "LCDServer: bad SWITCH_TO_CHANNEL command: " + flat);
00432 sendMessage(socket, "HUH?");
00433 return;
00434 }
00435
00436 if (m_lcd)
00437 m_lcd->switchToChannel(tokens[1], tokens[2], tokens[3]);
00438
00439 sendMessage(socket, "OK");
00440 }
00441
00442 void LCDServer::switchToVolume(const QStringList &tokens, QTcpSocket *socket)
00443 {
00444 if (debug_level > 0)
00445 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_VOLUME");
00446
00447 QString flat = tokens.join(" ");
00448
00449 if (tokens.count() != 2)
00450 {
00451 LOG(VB_GENERAL, LOG_ERR,
00452 "LCDServer: bad SWITCH_TO_VOLUME command: " + flat);
00453 sendMessage(socket, "HUH?");
00454 return;
00455 }
00456
00457 if (m_lcd)
00458 m_lcd->switchToVolume(tokens[1]);
00459
00460 sendMessage(socket, "OK");
00461 }
00462
00463 void LCDServer::switchToNothing(QTcpSocket *socket)
00464 {
00465 if (debug_level > 0)
00466 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SWITCH_TO_NOTHING");
00467
00468 if (m_lcd)
00469 m_lcd->switchToNothing();
00470
00471 sendMessage(socket, "OK");
00472 }
00473
00474 void LCDServer::switchToMenu(const QStringList &tokens, QTcpSocket *socket)
00475 {
00476 if (debug_level > 0)
00477 LOG(VB_GENERAL, LOG_INFO,
00478 QString("LCDServer: SWITCH_TO_MENU: %1").arg(tokens.count()));
00479
00480 QString flat = tokens.join(" ");
00481
00482 if ((tokens.count() - 3) % 5 != 0)
00483 {
00484 LOG(VB_GENERAL, LOG_ERR,
00485 "LCDServer: bad no. of args SWITCH_TO_MENU command: " + flat);
00486 sendMessage(socket, "HUH?");
00487 return;
00488 }
00489
00490 QString appName = tokens[1];
00491
00492 bool bPopup;
00493 if (tokens[2] == "TRUE")
00494 bPopup = true;
00495 else if (tokens[2] == "FALSE")
00496 bPopup = false;
00497 else
00498 {
00499 LOG(VB_GENERAL, LOG_ERR,
00500 "LCDServer: bad popup bool in SWITCH_TO_MENU command: " +
00501 tokens[2]);
00502 sendMessage(socket, "HUH?");
00503 return;
00504 }
00505
00506 QList<LCDMenuItem> items;
00507
00508 for (int x = 3; x < tokens.count(); x += 5)
00509 {
00510 QString text = tokens[x];
00511
00512 CHECKED_STATE checked;
00513 if (tokens[x + 1] == "CHECKED")
00514 checked = CHECKED;
00515 else if (tokens[x + 1] == "UNCHECKED")
00516 checked = UNCHECKED;
00517 else if (tokens[x + 1] == "NOTCHECKABLE")
00518 checked = NOTCHECKABLE;
00519 else
00520 {
00521 LOG(VB_GENERAL, LOG_ERR,
00522 "LCDServer: bad checked state in SWITCH_TO_MENU command: " +
00523 tokens[x + 1]);
00524 sendMessage(socket, "HUH?");
00525 return;
00526 }
00527
00528 bool selected;
00529 if (tokens[x + 2] == "TRUE")
00530 selected = true;
00531 else if (tokens[x + 2] == "FALSE")
00532 selected = false;
00533 else
00534 {
00535 LOG(VB_GENERAL, LOG_ERR,
00536 "LCDServer: bad selected state in SWITCH_TO_MENU command: " +
00537 tokens[x + 2]);
00538 sendMessage(socket, "HUH?");
00539 return;
00540 }
00541
00542 bool scrollable;
00543 if (tokens[x + 3] == "TRUE")
00544 scrollable = true;
00545 else if (tokens[x + 3] == "FALSE")
00546 scrollable = false;
00547 else
00548 {
00549 LOG(VB_GENERAL, LOG_ERR,
00550 "LCDServer: bad scrollable bool in SWITCH_TO_MENU command: " +
00551 tokens[x + 3]);
00552 sendMessage(socket, "HUH?");
00553 return;
00554 }
00555
00556 bool bOK;
00557 int indent = tokens[x + 4].toInt(&bOK);
00558 if (!bOK)
00559 {
00560 LOG(VB_GENERAL, LOG_ERR,
00561 "LCDServer: bad indent in SWITCH_TO_MENU command: " +
00562 tokens[x + 4]);
00563 sendMessage(socket, "HUH?");
00564 return;
00565 }
00566
00567 items.append(LCDMenuItem(selected, checked, text, indent, scrollable));
00568 }
00569
00570 if (m_lcd)
00571 m_lcd->switchToMenu(&items, appName, bPopup);
00572
00573 sendMessage(socket, "OK");
00574 }
00575
00576 void LCDServer::setChannelProgress(const QStringList &tokens, QTcpSocket *socket)
00577 {
00578 if (debug_level > 0)
00579 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_CHANNEL_PROGRESS");
00580
00581 QString flat = tokens.join(" ");
00582
00583 if (tokens.count() != 3)
00584 {
00585 LOG(VB_GENERAL, LOG_ERR,
00586 "LCDServer: bad SET_CHANNEL_PROGRESS command: " + flat);
00587 sendMessage(socket, "HUH?");
00588 return;
00589 }
00590
00591 bool bOK;
00592 float progress = tokens[2].toFloat(&bOK);
00593 if (!bOK)
00594 {
00595 LOG(VB_GENERAL, LOG_ERR,
00596 QString("LCDServer: bad float value in SET_CHANNEL_PROGRESS "
00597 "command: %1").arg(tokens[2]));
00598 sendMessage(socket, "HUH?");
00599 return;
00600 }
00601
00602 if (m_lcd)
00603 m_lcd->setChannelProgress(tokens[1], progress);
00604
00605 sendMessage(socket, "OK");
00606 }
00607
00608 void LCDServer::setGenericProgress(const QStringList &tokens, QTcpSocket *socket)
00609 {
00610 if (debug_level > 0)
00611 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_GENERIC_PROGRESS");
00612
00613 QString flat = tokens.join(" ");
00614
00615 if (tokens.count() != 3)
00616 {
00617 LOG(VB_GENERAL, LOG_ERR,
00618 "LCDServer: bad SET_GENERIC_PROGRESS command: " + flat);
00619 sendMessage(socket, "HUH?");
00620 return;
00621 }
00622
00623 bool bOK;
00624 bool busy = tokens[1].toInt(&bOK);
00625 if (!bOK)
00626 {
00627 LOG(VB_GENERAL, LOG_ERR,
00628 QString("LCDServer: bad bool value in SET_GENERIC_PROGRESS "
00629 "command: %1 %2").arg(tokens[1]).arg(tokens[2]));
00630 sendMessage(socket, "HUH?");
00631 return;
00632 }
00633 float progress = tokens[2].toFloat(&bOK);
00634 if (!bOK)
00635 {
00636 LOG(VB_GENERAL, LOG_ERR,
00637 QString("LCDServer: bad float value in SET_GENERIC_PROGRESS "
00638 "command: %1").arg(tokens[2]));
00639 sendMessage(socket, "HUH?");
00640 return;
00641 }
00642
00643 if (m_lcd)
00644 m_lcd->setGenericProgress(busy, progress);
00645
00646 sendMessage(socket, "OK");
00647 }
00648
00649 void LCDServer::setMusicProgress(const QStringList &tokens, QTcpSocket *socket)
00650 {
00651 if (debug_level > 0)
00652 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_MUSIC_PROGRESS");
00653
00654 QString flat = tokens.join(" ");
00655
00656 if (tokens.count() != 3)
00657 {
00658 LOG(VB_GENERAL, LOG_ERR,
00659 "LCDServer: bad SET_MUSIC_PROGRESS command: " + flat);
00660 sendMessage(socket, "HUH?");
00661 return;
00662 }
00663
00664 bool bOK;
00665 float progress = tokens[2].toFloat(&bOK);
00666 if (!bOK)
00667 {
00668 LOG(VB_GENERAL, LOG_ERR,
00669 "LCDServer: bad float value in SET_MUSIC_PROGRESS command: " +
00670 tokens[2]);
00671 sendMessage(socket, "HUH?");
00672 return;
00673 }
00674
00675 if (m_lcd)
00676 m_lcd->setMusicProgress(tokens[1], progress);
00677
00678 sendMessage(socket, "OK");
00679 }
00680
00681 void LCDServer::setMusicProp(const QStringList &tokens, QTcpSocket *socket)
00682 {
00683 if (debug_level > 0)
00684 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_MUSIC_PROP");
00685
00686 QString flat = tokens.join(" ");
00687
00688 if (tokens.count() < 3)
00689 {
00690 LOG(VB_GENERAL, LOG_ERR,
00691 "LCDServer: bad SET_MUSIC_PROP command: " + flat);
00692 sendMessage(socket, "HUH?");
00693 return;
00694 }
00695
00696 if (tokens[1] == "SHUFFLE")
00697 {
00698 if (tokens.count () != 3)
00699 {
00700 LOG(VB_GENERAL, LOG_ERR,
00701 "LCDServer: missing argument for SET_MUSIC_PROP SHUFFLE "
00702 "command: " + flat);
00703 sendMessage(socket, "HUH?");
00704 return;
00705 }
00706 bool bOk;
00707 int state = tokens[2].toInt (&bOk);
00708 if (!bOk)
00709 {
00710 LOG(VB_GENERAL, LOG_ERR,
00711 "LCDServer: bad argument for SET_MUSIC_PROP SHUFFLE "
00712 "command: " + tokens[2]);
00713 sendMessage(socket, "HUH?");
00714 return;
00715 }
00716 if (m_lcd)
00717 m_lcd->setMusicShuffle (state);
00718 }
00719 else if (tokens[1] == "REPEAT")
00720 {
00721 if (tokens.count () != 3)
00722 {
00723 LOG(VB_GENERAL, LOG_ERR,
00724 "LCDServer: missing argument for SET_MUSIC_PROP REPEAT "
00725 "command: " + flat);
00726 sendMessage(socket, "HUH?");
00727 return;
00728 }
00729 bool bOk;
00730 int state = tokens[2].toInt (&bOk);
00731 if (!bOk)
00732 {
00733 LOG(VB_GENERAL, LOG_ERR,
00734 "LCDServer: bad argument for SET_MUSIC_PROP REPEAT command: " +
00735 tokens[2]);
00736 sendMessage(socket, "HUH?");
00737 return;
00738 }
00739 if (m_lcd)
00740 m_lcd->setMusicRepeat (state);
00741 }
00742 else
00743 {
00744 LOG(VB_GENERAL, LOG_ERR,
00745 "LCDServer: bad argument for SET_MUSIC_PROP command: " + tokens[1]);
00746 sendMessage(socket, "HUH?");
00747 return;
00748 }
00749
00750 sendMessage(socket, "OK");
00751 }
00752
00753 void LCDServer::setVolumeLevel(const QStringList &tokens, QTcpSocket *socket)
00754 {
00755 if (debug_level > 0)
00756 LOG(VB_GENERAL, LOG_INFO, "LCDServer: SET_VOLUME_LEVEL");
00757
00758 QString flat = tokens.join(" ");
00759
00760 if (tokens.count() != 2)
00761 {
00762 LOG(VB_GENERAL, LOG_ERR,
00763 "LCDServer: bad SET_VOLUME_LEVEL command: " + flat);
00764 sendMessage(socket, "HUH?");
00765 return;
00766 }
00767
00768 bool bOK;
00769 float progress = tokens[1].toFloat(&bOK);
00770 if (!bOK)
00771 {
00772 LOG(VB_GENERAL, LOG_ERR,
00773 "LCDServer: bad float value in SET_VOLUME_LEVEL command: " +
00774 tokens[1]);
00775 sendMessage(socket, "HUH?");
00776 return;
00777 }
00778
00779 if (m_lcd)
00780 m_lcd->setVolumeLevel(progress);
00781
00782 sendMessage(socket, "OK");
00783 }
00784
00785 void LCDServer::updateLEDs(const QStringList &tokens, QTcpSocket *socket)
00786 {
00787 if (debug_level > 0)
00788 LOG(VB_GENERAL, LOG_INFO, "LCDServer: UPDATE_LEDS");
00789
00790 QString flat = tokens.join(" ");
00791
00792 if (tokens.count() != 2)
00793 {
00794 LOG(VB_GENERAL, LOG_ERR, "LCDServer: bad UPDATE_LEDs command: " + flat);
00795 sendMessage(socket, "HUH?");
00796 return;
00797 }
00798
00799 bool bOK;
00800 int mask = tokens[1].toInt(&bOK);
00801 if (!bOK)
00802 {
00803 LOG(VB_GENERAL, LOG_ERR,
00804 "LCDServer: bad mask in UPDATE_LEDS command: " + tokens[1]);
00805 sendMessage(socket, "HUH?");
00806 return;
00807 }
00808
00809 if (m_lcd)
00810 m_lcd->updateLEDs(mask);
00811
00812 sendMessage(socket, "OK");
00813 }