Go to the documentation of this file.
19 #include <QApplication>
20 #include <QTextStream>
38 #define LOC QString("LCDdevice: ")
41 : m_retryTimer(new QTimer(this)), m_ledTimer(new QTimer(this))
53 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
54 "An LCD object now exists (LCD() was called)");
83 lcd_host =
GetMythDB()->GetSetting(
"LCDServerHost",
"localhost");
84 int lcd_port =
GetMythDB()->GetNumSetting(
"LCDServerPort", 6545);
88 if (lcd_host ==
"localhost")
89 lcd_host =
"127.0.0.1";
91 if (
m_enabled && lcd_host.length() > 0 && lcd_port > 1024)
107 LOG(VB_NETWORK, LOG_DEBUG,
LOC +
108 QString(
"connecting to host: %1 - port: %2")
109 .
arg(lhostname).
arg(lport));
126 if (
myth_system(
"ps ch -C mythlcdserver -o pid > /dev/null", flags) == 1)
129 LOG(VB_GENERAL, LOG_NOTICE,
"Starting mythlcdserver");
133 LOG(VB_GENERAL, LOG_ERR,
"Failed start MythTV LCD Server");
147 LOG(VB_GENERAL, LOG_INFO, QString(
"Connecting to lcd server: "
154 QObject::connect(
m_socket, &QIODevice::readyRead,
156 QObject::connect(
m_socket, &QAbstractSocket::disconnected,
190 if (
m_socket->thread() != QThread::currentThread())
192 LOG(VB_GENERAL, LOG_ERR,
193 "Sending to LCDServer from wrong thread.");
198 if (QAbstractSocket::ConnectedState !=
m_socket->state())
206 LOG(VB_GENERAL, LOG_ERR,
207 "Connection to LCDServer died unexpectedly. "
208 "Trying to reconnect every 10 seconds...");
215 os.setCodec(QTextCodec::codecForName(
"ISO 8859-1"));
221 LOG(VB_NETWORK, LOG_DEBUG,
LOC +
222 QString(
"Sending to Server: %1").
arg(someText));
225 os << someText <<
"\n";
254 QString lineFromServer;
263 int dataSize =
static_cast<int>(
m_socket->bytesAvailable() + 1);
264 QByteArray data(dataSize + 1, 0);
266 m_socket->read(data.data(), dataSize);
268 lineFromServer = data;
269 lineFromServer = lineFromServer.simplified();
272 if (lineFromServer !=
"OK")
273 LOG(VB_NETWORK, LOG_DEBUG,
LOC + QString(
"Received from server: %1")
274 .
arg(lineFromServer));
276 aList = lineFromServer.split(
' ');
277 if (aList[0] ==
"CONNECTED")
281 if (aList.count() != 3)
283 LOG(VB_GENERAL, LOG_ERR,
LOC +
"received bad no. of arguments in "
284 "CONNECTED response from LCDServer");
291 LOG(VB_GENERAL, LOG_ERR,
LOC +
"received bad int for width in "
292 "CONNECTED response from LCDServer");
298 LOG(VB_GENERAL, LOG_ERR,
LOC +
"received bad int for height in "
299 "CONNECTED response from LCDServer");
304 else if (aList[0] ==
"HUH?")
306 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Something is getting passed to "
307 "LCDServer that it does not understand");
308 LOG(VB_GENERAL, LOG_WARNING,
LOC +
311 else if (aList[0] ==
"KEY")
319 QChar mykey = keyPressed.at(0);
331 key = Qt::Key_Escape;
333 QCoreApplication::postEvent(
334 (QObject *)(QApplication::activeWindow()),
374 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"stopAll");
464 value = std::min(std::max(0.0F, value), 1.0F);
474 value = std::min(std::max(0.0F, value), 1.0F);
491 value = std::min(std::max(0.0F, value), 1.0F);
493 QString().setNum(value));
501 emit
sendToServer(QString(
"SET_MUSIC_PLAYER_PROP SHUFFLE %1").
arg(shuffle));
509 emit
sendToServer(QString(
"SET_MUSIC_PLAYER_PROP REPEAT %1").
arg(repeat));
519 else if (value > 1.0F)
523 emit
sendToServer(
"SET_VOLUME_LEVEL " + QString().setNum(value));
545 aString =
"UPDATE_LEDS ";
546 aString += QString::number(mask);
556 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToTime");
566 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToMusic");
574 const QString &subtitle)
579 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToChannel");
592 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToMenu");
594 if (menuItems.isEmpty())
597 QString s =
"SWITCH_TO_MENU ";
600 s +=
' ' + QString(popMenu ?
"TRUE" :
"FALSE");
603 QListIterator<LCDMenuItem> it(menuItems);
615 s +=
" NOTCHECKABLE";
617 s +=
' ' + QString(curItem->
isSelected() ?
"TRUE" :
"FALSE");
618 s +=
' ' + QString(curItem->
Scroll() ?
"TRUE" :
"FALSE");
632 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToGeneric");
634 if (textItems.isEmpty())
637 QString s =
"SWITCH_TO_GENERIC";
639 QListIterator<LCDTextItem> it(textItems);
646 sRow.setNum(curItem->
getRow());
654 s +=
" ALIGN_CENTERED";
658 s +=
' ' + QString(curItem->
getScroll() ?
"TRUE" :
"FALSE");
669 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToVolume");
679 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"switchToNothing");
688 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"shutdown");
704 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"RESET");
713 LOG(VB_GENERAL, LOG_DEBUG,
LOC +
"An LCD device is being snuffed out of "
714 "existence (~LCD() was called)");
726 QString sRes = string;
727 sRes.replace(QString(
"\""), QString(
"\"\""));
728 sRes =
"\"" + sRes +
"\"";
uint myth_system(const QString &command, uint flags, uint timeout)
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)
arg(title).arg(filename).arg(doDelete))
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void sendToServer(const QString &someText)
void setMusicShuffle(int shuffle)
Set music player's shuffle properties.
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)
#define GENERIC_EXIT_RUNNING
Process is running.
@ 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)