Go to the documentation of this file.
19 #include <QApplication>
20 #include <QTextStream>
22 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
23 #include <QStringConverter>
42 #define LOC QString("LCDdevice: ")
45 : m_retryTimer(new QTimer(this)), m_ledTimer(new QTimer(this))
57 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
58 "An LCD object now exists (LCD() was called)");
87 lcd_host =
GetMythDB()->GetSetting(
"LCDServerHost",
"localhost");
88 int lcd_port =
GetMythDB()->GetNumSetting(
"LCDServerPort", 6545);
92 if (lcd_host ==
"localhost")
93 lcd_host =
"127.0.0.1";
95 if (
m_enabled && lcd_host.length() > 0 && lcd_port > 1024)
111 LOG(VB_NETWORK, LOG_DEBUG,
LOC +
112 QString(
"connecting to host: %1 - port: %2")
113 .arg(lhostname).arg(lport));
131 if (
myth_system(
"ps ch -C mythlcdserver -o pid > /dev/null", flags) == 1)
134 LOG(VB_GENERAL, LOG_NOTICE,
"Starting mythlcdserver");
138 LOG(VB_GENERAL, LOG_ERR,
"Failed start MythTV LCD Server");
152 LOG(VB_GENERAL, LOG_INFO, QString(
"Connecting to lcd server: "
159 QObject::connect(
m_socket, &QIODevice::readyRead,
161 QObject::connect(
m_socket, &QAbstractSocket::disconnected,
195 if (
m_socket->thread() != QThread::currentThread())
197 LOG(VB_GENERAL, LOG_ERR,
198 "Sending to LCDServer from wrong thread.");
203 if (QAbstractSocket::ConnectedState !=
m_socket->state())
211 LOG(VB_GENERAL, LOG_ERR,
212 "Connection to LCDServer died unexpectedly. "
213 "Trying to reconnect every 10 seconds...");
220 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
221 os.setCodec(QTextCodec::codecForName(
"ISO 8859-1"));
223 os.setEncoding(QStringConverter::Latin1);
230 LOG(VB_NETWORK, LOG_DEBUG,
LOC +
231 QString(
"Sending to Server: %1").arg(someText));
234 os << someText <<
"\n";
263 QString lineFromServer;
272 int dataSize =
static_cast<int>(
m_socket->bytesAvailable() + 1);
273 QByteArray data(dataSize + 1, 0);
275 m_socket->read(data.data(), dataSize);
277 lineFromServer = data;
278 lineFromServer = lineFromServer.simplified();
281 if (lineFromServer !=
"OK")
282 LOG(VB_NETWORK, LOG_DEBUG,
LOC + QString(
"Received from server: %1")
283 .arg(lineFromServer));
285 aList = lineFromServer.split(
' ');
286 if (aList[0] ==
"CONNECTED")
290 if (aList.count() != 3)
292 LOG(VB_GENERAL, LOG_ERR,
LOC +
"received bad no. of arguments in "
293 "CONNECTED response from LCDServer");
300 LOG(VB_GENERAL, LOG_ERR,
LOC +
"received bad int for width in "
301 "CONNECTED response from LCDServer");
307 LOG(VB_GENERAL, LOG_ERR,
LOC +
"received bad int for height in "
308 "CONNECTED response from LCDServer");
313 else if (aList[0] ==
"HUH?")
315 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Something is getting passed to "
316 "LCDServer that it does not understand");
317 LOG(VB_GENERAL, LOG_WARNING,
LOC +
320 else if (aList[0] ==
"KEY")
328 QChar mykey = keyPressed.at(0);
340 key = Qt::Key_Escape;
342 QCoreApplication::postEvent(
343 (QObject *)(QApplication::activeWindow()),
383 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"stopAll");
473 value = std::min(std::max(0.0F, value), 1.0F);
483 value = std::min(std::max(0.0F, value), 1.0F);
484 emit
sendToServer(QString(
"SET_GENERIC_PROGRESS 0 %1").arg(value));
500 value = std::min(std::max(0.0F, value), 1.0F);
502 QString().setNum(value));
510 emit
sendToServer(QString(
"SET_MUSIC_PLAYER_PROP SHUFFLE %1").arg(shuffle));
518 emit
sendToServer(QString(
"SET_MUSIC_PLAYER_PROP REPEAT %1").arg(repeat));
528 else if (value > 1.0F)
532 emit
sendToServer(
"SET_VOLUME_LEVEL " + QString().setNum(value));
554 aString =
"UPDATE_LEDS ";
555 aString += QString::number(mask);
565 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToTime");
575 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToMusic");
583 const QString &subtitle)
588 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToChannel");
601 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToMenu");
603 if (menuItems.isEmpty())
606 QString s =
"SWITCH_TO_MENU ";
609 s +=
' ' + QString(popMenu ?
"TRUE" :
"FALSE");
612 QListIterator<LCDMenuItem> it(menuItems);
624 s +=
" NOTCHECKABLE";
626 s +=
' ' + QString(curItem->
isSelected() ?
"TRUE" :
"FALSE");
627 s +=
' ' + QString(curItem->
Scroll() ?
"TRUE" :
"FALSE");
641 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToGeneric");
643 if (textItems.isEmpty())
646 QString s =
"SWITCH_TO_GENERIC";
648 QListIterator<LCDTextItem> it(textItems);
655 sRow.setNum(curItem->
getRow());
663 s +=
" ALIGN_CENTERED";
667 s +=
' ' + QString(curItem->
getScroll() ?
"TRUE" :
"FALSE");
678 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToVolume");
688 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToNothing");
697 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"shutdown");
713 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"RESET");
722 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"An LCD device is being snuffed out of "
723 "existence (~LCD() was called)");
735 QString sRes = string;
736 sRes.replace(QString(
"\""), QString(
"\"\""));
737 sRes =
"\"" + sRes +
"\"";
void switchToChannel(const QString &channum="", const QString &title="", const QString &subtitle="")
void handleKeyPress(const QString &keyPressed)
void setTunerLEDs(enum LCDTunerSet tuner, bool on)
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
void setGenericBusy()
Update the generic screen to display a busy spinner.
void setSpeakerLEDs(enum LCDSpeakerSet speaker, bool on)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
void sendToServer(const QString &someText)
void setMusicShuffle(int shuffle)
Set music player's shuffle properties.
QRecursiveMutex m_socketLock
void setVideoFormatLEDs(enum LCDVideoFormatSet vcodec, bool on)
int(* m_getLEDMask)(void)
void switchToGeneric(QList< LCDTextItem > &textItems)
TEXT_ALIGNMENT getAlignment() const
void sendToServerSlot(const QString &someText)
QString getScreen() const
@ kMSRunShell
run process through shell
@ kMSRunBackground
run child in the background
static QString quotedString(const QString &string)
bool connectToHost(const QString &hostname, unsigned int port)
void setMusicRepeat(int repeat)
Set music player's repeat properties.
void setGenericProgress(float value)
Update the generic progress bar.
static void SetupLCD(void)
void setVideoSrcLEDs(enum LCDVideoSourceSet vsrc, bool on)
void switchToVolume(const QString &app_name)
void setupLEDs(int(*LedMaskFunc)(void))
QString GetAppBinDir(void)
void setVolumeLevel(float value)
void switchToMusic(const QString &artist, const QString &album, const QString &track)
void setFunctionLEDs(enum LCDFunctionSet func, bool on)
void setVariousLEDs(enum LCDVariousFlags various, bool on)
@ kMSDontDisableDrawing
avoid disabling UI drawing
static bool m_serverUnavailable
QString m_lcdShowMusicItems
void setMusicProgress(const QString &time, float value)
@ GENERIC_EXIT_RUNNING
Process is running.
unsigned int getRow() const
void setChannelProgress(const QString &time, float value)
void setAudioFormatLEDs(enum LCDAudioFormatSet acodec, bool on)
void switchToMenu(QList< LCDMenuItem > &menuItems, const QString &app_name="", bool popMenu=true)
static bool startLCDServer(void)