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")
330 QChar mykey = keyPressed.at(0);
342 key = Qt::Key_Escape;
344 QCoreApplication::postEvent(
345 (QObject *)(QApplication::activeWindow()),
385 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"stopAll");
486 emit
sendToServer(QString(
"SET_GENERIC_PROGRESS 0 %1").arg(value));
504 QString().setNum(value));
512 emit
sendToServer(QString(
"SET_MUSIC_PLAYER_PROP SHUFFLE %1").arg(shuffle));
520 emit
sendToServer(QString(
"SET_MUSIC_PLAYER_PROP REPEAT %1").arg(repeat));
530 else if (value > 1.0F)
534 emit
sendToServer(
"SET_VOLUME_LEVEL " + QString().setNum(value));
556 aString =
"UPDATE_LEDS ";
557 aString += QString::number(mask);
567 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToTime");
577 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToMusic");
585 const QString &subtitle)
590 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToChannel");
603 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToMenu");
605 if (menuItems.isEmpty())
608 QString s =
"SWITCH_TO_MENU ";
611 s +=
' ' + QString(popMenu ?
"TRUE" :
"FALSE");
614 QListIterator<LCDMenuItem> it(menuItems);
626 s +=
" NOTCHECKABLE";
628 s +=
' ' + QString(curItem->
isSelected() ?
"TRUE" :
"FALSE");
629 s +=
' ' + QString(curItem->
Scroll() ?
"TRUE" :
"FALSE");
643 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToGeneric");
645 if (textItems.isEmpty())
648 QString s =
"SWITCH_TO_GENERIC";
650 QListIterator<LCDTextItem> it(textItems);
657 sRow.setNum(curItem->
getRow());
665 s +=
" ALIGN_CENTERED";
669 s +=
' ' + QString(curItem->
getScroll() ?
"TRUE" :
"FALSE");
680 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToVolume");
690 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToNothing");
699 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"shutdown");
715 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"RESET");
724 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"An LCD device is being snuffed out of "
725 "existence (~LCD() was called)");
737 QString sRes = string;
738 sRes.replace(QString(
"\""), QString(
"\"\""));
739 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
static eu8 clamp(eu8 value, eu8 low, eu8 high)
void sendToServerSlot(const QString &someText)
QString getScreen() const
@ kMSRunShell
run process through shell
@ GENERIC_EXIT_RUNNING
Process is running.
@ 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)
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)