Index: mythtv/libs/libmyth/lcddevice.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/lcddevice.cpp,v
retrieving revision 1.37
diff -u -r1.37 lcddevice.cpp
--- mythtv/libs/libmyth/lcddevice.cpp	9 Feb 2005 13:49:12 -0000	1.37
+++ mythtv/libs/libmyth/lcddevice.cpp	20 Apr 2005 18:35:50 -0000
@@ -17,9 +17,19 @@
 #include <qapplication.h>
 #include <qregexp.h>
 
-//#define LCD_DEVICE_DEBUG
+/*
+  LCD_DEVICE_DEBUG control how much debug info we get
+  0 = none
+  1 = LCDd info 
+  2 = screen switchinfo info
+  10 = every command sent and error received
+ */
+#define LCD_DEVICE_DEBUG 0
 #define LCD_START_COL 3
 
+#define LCD_VERSION_4 1
+#define LCD_VERSION_5 2
+
 LCD::LCD()
    :QObject(NULL, "LCD")
 {
@@ -28,7 +38,7 @@
     // Note that this does *not* include opening the socket and initiating 
     // communications with the LDCd daemon.
 
-#ifdef LCD_DEVICE_DEBUG
+#if LCD_DEVICE_DEBUG > 0
     cout << "lcddevice: An LCD object now exists (LCD() was called)" << endl ;
 #endif
 
@@ -106,6 +116,31 @@
     return m_lcd;
 }
 
+void LCD::SetupLCD (void) {
+    QString lcd_host;
+    int lcd_port;
+
+    if (m_lcd) {
+        delete m_lcd;
+        m_lcd = NULL;
+        m_server_unavailable = false;
+    }
+
+    lcd_host = gContext->GetSetting("LCDHost", "localhost");
+    lcd_port = gContext->GetNumSetting("LCDPort", 13666);
+
+    if (lcd_host.length() > 0 && lcd_port > 1024)
+    {
+        class LCD * lcd = LCD::Get();
+        if (lcd->connectToHost(lcd_host, lcd_port) == false) {
+            delete m_lcd;
+            m_lcd = NULL;
+            m_server_unavailable = false;
+        }
+    }
+  
+}
+
 bool LCD::connectToHost(const QString &lhostname, unsigned int lport)
 {
     // Open communications
@@ -193,7 +228,7 @@
  
     if (connected)
     {
-#ifdef LCD_DEVICE_DEBUG
+#if LCD_DEVICE_DEBUG > 9
         cout << "lcddevice: Sending to Server: " << someText << endl ;
 #endif
         // Just stream the text out the socket
@@ -209,6 +244,55 @@
     }
 }
 
+void LCD::setPriority(const QString &screen, PRIORITY priority)
+{
+    QString aString;
+
+    aString = "screen_set ";
+    aString += screen;
+    aString += " priority ";
+
+    switch (priority) {
+    case TOP: 
+      aString += QString::number (prioTop);
+      break;
+    case URGENT: 
+      aString += QString::number (prioUrgent);
+      break;
+    case HIGH:
+      aString += QString::number (prioHigh);
+      break;
+    case MEDIUM: 
+      aString += QString::number (prioMedium);
+      break;
+    case LOW:
+      aString += QString::number (prioLow);
+      break;
+    }
+
+    sendToServer (aString);
+}
+
+void LCD::setHeartbeat (const QString &screen, bool onoff) {
+    QString msg;
+    if (onoff) {
+        if (pVersion == LCD_VERSION_4) {
+            msg = "widget_add " + screen + " heartbeat";
+	}
+	if (pVersion == LCD_VERSION_5) {
+            msg = "screen_set " + screen + " heartbeat on";
+	}
+    } else {
+        if (pVersion == LCD_VERSION_4) {
+	    msg = "widget_del " + screen + " heartbeat";
+	}
+	if (pVersion == LCD_VERSION_5) {
+            msg = "screen_set " + screen + " heartbeat off";
+	}
+    }
+    sendToServer (msg);
+}
+
 void LCD::restartConnection()
 {
     // Reset the flag
@@ -240,7 +324,7 @@
     {
         lineFromServer = socket->readLine();
 
-#ifdef LCD_DEVICE_DEBUG        
+#if LCD_DEVICE_DEBUG > 9
         // Make debugging be less noisy
         if (lineFromServer != "success\n")
             cout << "lcddevice: Received from server: " << lineFromServer ;
@@ -263,14 +347,33 @@
             }
             
             // Skip through some stuff
-            
             it++; // server version
+            QString server_version = *it;
             it++; // the string "protocol"
             it++; // protocol version
+            QString protocol_version = *it;
+	    setVersion (server_version, protocol_version);
             it++; // the string "lcd"
             it++; // the string "wid";
             it++; // Ah, the LCD width
             
+            // default priorities
+            prioTop = 64;
+            prioUrgent = 128;
+            prioHigh = 240;
+            prioMedium = 248;
+            prioLow = 252;
+            if (protocolVersion == "0.3") {
+                if (serverVersion.startsWith ("CVS-current")) {
+                    // Latest CVS versions of LCDd has priorities switched
+                    prioTop = 252;
+                    prioUrgent = 248;
+                    prioHigh = 240;
+                    prioMedium = 128;
+                    prioLow = 64;
+                }
+            }
+
             tempString = *it;
             setWidth(tempString.toInt());
 
@@ -295,9 +398,7 @@
 
             init();
 
-#ifdef LCD_DEVICE_DEBUG
             describeServer();    
-#endif
         }
 
         if (aList.first() == "huh?")
@@ -337,17 +438,19 @@
     retryTimer->stop();
 
     QString aString;
-    int i;
 
     timeformat = gContext->GetSetting("TimeFormat", "h:mm AP");
-    
+   
+    // Get LCD settings
     lcd_showmusic=(gContext->GetSetting("LCDShowMusic", "1")=="1");
+    lcd_showmusic_items=(gContext->GetSetting("LCDShowMusicItems", "ArtistAlbumTitle")); 
     lcd_showtime=(gContext->GetSetting("LCDShowTime", "1")=="1");
     lcd_showchannel=(gContext->GetSetting("LCDShowChannel", "1")=="1");
     lcd_showgeneric=(gContext->GetSetting("LCDShowGeneric", "1")=="1");
     lcd_showvolume=(gContext->GetSetting("LCDShowVolume", "1")=="1");
     lcd_showmenu=(gContext->GetSetting("LCDShowMenu", "1")=="1");
     lcd_backlighton=(gContext->GetSetting("LCDBacklightOn", "1")=="1");
+    lcd_heartbeaton=(gContext->GetSetting("LCDHeartBeatOn", "1")=="1");
     aString = gContext->GetSetting("LCDPopupTime", "5");
     lcd_popuptime = aString.toInt() * 1000;
 
@@ -364,8 +467,8 @@
     // "current one")
 
     sendToServer("screen_add Time");
-    sendToServer("widget_del Time heartbeat");
-    sendToServer("screen_set Time priority 255");
+    setHeartbeat ("Time", lcd_heartbeaton);
+    setPriority("Time", LOW);
     if (lcd_backlighton)
         sendToServer("screen_set Time backlight on");
     else
@@ -378,39 +481,43 @@
     // the ghetto way
 
     sendToServer("screen_add Menu");
-    sendToServer("widget_del Menu heartbeat");
-    sendToServer("screen_set Menu priority 255");
+    setHeartbeat ("Menu", lcd_heartbeaton);
+    setPriority("Menu", LOW);
     sendToServer("screen_set Menu backlight on");
     sendToServer("widget_add Menu topWidget string");
-    sendToServer("widget_add Menu menuWidget1 string");
-    sendToServer("widget_add Menu menuWidget2 string");
-    sendToServer("widget_add Menu menuWidget3 string");
-    sendToServer("widget_add Menu menuWidget4 string");
-    sendToServer("widget_add Menu menuWidget5 string");
+    for (unsigned int i = 1; i < lcdHeight; i++) {
+         aString = "widget_add Menu menuWidget";
+         aString += QString::number (i);
+         aString += " string";
+         sendToServer(aString);
+    }
 
     // The Music Screen
 
     sendToServer("screen_add Music");
-    sendToServer("widget_del Music heartbeat");
-    sendToServer("screen_set Music priority 255");
+    setHeartbeat ("Music", lcd_heartbeaton);
+    setPriority("Music", LOW);
     sendToServer("screen_set Music backlight on");
     sendToServer("widget_add Music topWidget string");
-    
+    sendToServer("widget_add Music timeWidget string");
+    sendToServer("widget_add Music progressBar hbar");
+
+#if 0
     // Have to put in 10 bars for equalizer
-    
-    for (i = 0; i < 10; i++)
+    for (int i = 0; i < 10; i++)
     {
         aString = "widget_add Music vbar";
         aString += QString::number(i);
         aString += " vbar";
         sendToServer(aString);
     }
+#endif
 
     // The Channel Screen
     
     sendToServer("screen_add Channel");
-    sendToServer("widget_del Channel heartbeat");
-    sendToServer("screen_set Channel priority 255");
+    setHeartbeat ("Channel", lcd_heartbeaton);
+    setPriority("Channel", LOW);
     sendToServer("screen_set Channel backlight on");
     sendToServer("widget_add Channel topWidget string");
     sendToServer("widget_add Channel botWidget string");
@@ -419,8 +526,8 @@
     // The Generic Screen
 
     sendToServer("screen_add Generic");
-    sendToServer("widget_del Generic heartbeat");
-    sendToServer("screen_set Generic priority 255");
+    setHeartbeat ("Generic", lcd_heartbeaton);
+    setPriority("Generic", LOW);
     sendToServer("screen_set Generic backlight on");
     sendToServer("widget_add Generic textWidget1 string");
     sendToServer("widget_add Generic textWidget2 string");
@@ -430,8 +537,8 @@
     // The Volume Screen
 
     sendToServer("screen_add Volume");
-    sendToServer("widget_del Volume heartbeat");
-    sendToServer("screen_set Volume priority 255");
+    setHeartbeat ("Volume", lcd_heartbeaton);
+    setPriority("Volume", LOW);
     sendToServer("screen_set Volume backlight on");
     sendToServer("widget_add Volume topWidget string");
     sendToServer("widget_add Volume botWidget string");
@@ -482,10 +589,51 @@
         cellHeight = x;
 }
 
+void LCD::setVersion(const QString &sversion, const QString &pversion)
+{
+    protocolVersion = pversion;
+    serverVersion = sversion;
+
+    // the pVersion number is used internally to designate which protocol
+    // version LCDd is using:
+    if (protocolVersion.find(QRegExp("0[.]4"), 0) != -1) {
+	pVersion = LCD_VERSION_4;
+        prioTop = 64;
+        prioUrgent = 128;
+        prioHigh = 240;
+        prioMedium = 248;
+        prioLow = 252;
+    } else {
+        pVersion = LCD_VERSION_5;
+        prioTop = 252;
+        prioUrgent = 248;
+        prioHigh = 240;
+        prioMedium = 128;
+        prioLow = 64;
+    }
+}
+
 void LCD::describeServer()
 {
+#if LCD_DEVICE_DEBUG > 0
     VERBOSE(VB_GENERAL, QString("lcddevice: The server is %1x%2 with each cell being %3x%4." )
                         .arg(lcdWidth).arg(lcdHeight).arg(cellWidth).arg(cellHeight));
+    VERBOSE(VB_GENERAL, QString("lcddevice: LCDd version %1, protocol version %2.")
+            .arg(serverVersion).arg(protocolVersion));
+#endif
+#if LCD_DEVICE_DEBUG > 1
+    VERBOSE(VB_GENERAL, QString("lcddevice: MythTV LCD settings:"));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - showmusic      : %1").arg(lcd_showmusic));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - showmusicitems : %1").arg(lcd_showmusic_items));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - showtime       : %1").arg(lcd_showtime));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - showchannel    : %1").arg(lcd_showchannel));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - showgeneric    : %1").arg(lcd_showgeneric));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - showvolume     : %1").arg(lcd_showvolume));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - showmenu       : %1").arg(lcd_showmenu));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - backlighton    : %1").arg(lcd_backlighton));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - heartbeaton    : %1").arg(lcd_heartbeaton));
+    VERBOSE(VB_GENERAL, QString("lcddevice: - popuptime      : %1").arg(lcd_popuptime));
+#endif
 }
 
 void LCD::veryBadThings(int anError)
@@ -533,13 +681,16 @@
     // The usual reason things would get this far and then lcd_ready being 
     // false is the connection died and we're trying to re-establish the 
     // connection
+#if LCD_DEVICE_DEBUG > 1
+    cout << "lcddevice: stopAll " << endl ;
+#endif
     if (lcd_ready)
     {
-        sendToServer("screen_set Music priority 255");
-        sendToServer("screen_set Channel priority 255");
-        sendToServer("screen_set Generic priority 255");
-        sendToServer("screen_set Volume priority 255");
-        sendToServer("screen_set Menu priority 255");
+        setPriority("Music", LOW);
+        setPriority("Channel", LOW);
+        setPriority("Generic", LOW);
+        setPriority("Volume", LOW);
+        setPriority("Menu", LOW);
     }
 
     preScrollTimer->stop();
@@ -555,7 +706,7 @@
 
 void LCD::startTime()
 {
-    sendToServer("screen_set Time priority 128");
+    setPriority("Time", MEDIUM);
     timeTimer->start(1000, FALSE);
     outputTime();
     theMode = 0;    
@@ -579,6 +730,7 @@
     {
         ++it;
         num.setNum(curItem->getRow());
+
         if (curItem->getScroll())
             assignScrollingText(curItem->getText(), "textWidget" + num, 
                                 curItem->getRow());
@@ -626,7 +778,7 @@
     aString += " ";
     aString += QString::number(row);
     aString += " \"";
-    aString += theText;
+    aString += theText.replace ('"', "\"");
     aString += "\"";
     sendToServer(aString);
 }
@@ -640,7 +792,7 @@
     aString += " " + widget + " 1 ";
     aString += QString::number(row);
     aString += " \"";
-    aString += theText;
+    aString += theText.replace ('"', "\"");
     aString += "\"";
     sendToServer(aString);
 }
@@ -660,7 +812,7 @@
     aString += " ";
     aString += QString::number(row);
     aString += " \"";
-    aString += theText;
+    aString += theText.replace ('"', "\"");
     aString += "\"";
     sendToServer(aString);
 }
@@ -712,14 +864,20 @@
     }
 }
 
-void LCD::startMusic(QString artist, QString track)
+void LCD::startMusic(QString artist, QString album, QString track)
 {
     QString aString;
     if (lcd_showmusic)
-      sendToServer("screen_set Music priority 64");
+      setPriority("Music", HIGH);
     musicTimer->start(100, FALSE);
     aString = artist;
-    aString += " - ";
+    if (lcd_showmusic_items == "ArtistAlbumTitle") {
+        aString += " [";
+        aString += album;
+        aString += "] ";
+    } else {
+        aString += " - ";
+    } 
     aString += track;
     theMode = 1;
     assignScrollingText(aString);
@@ -729,7 +887,7 @@
 {
     QString aString;
     if (lcd_showchannel)
-      sendToServer("screen_set Channel priority 64");
+      setPriority("Channel", HIGH);
     aString = channum;
     theMode = 2;
     assignScrollingText(aString, "topWidget", 1);
@@ -756,7 +914,7 @@
     QString aString;
 
     if (lcd_showgeneric)
-      sendToServer("screen_set Generic priority 64");
+      setPriority("Generic", HIGH);
 
     // Clear out the LCD.  Do this before checking if its empty incase the user
     //  wants to just clear the lcd
@@ -803,7 +961,7 @@
 
     // Menu is higher priority than volume
     if (lcd_showmenu) 
-        sendToServer("screen_set Menu priority 15");
+        setPriority("Menu", URGENT);
 
     // Write out the app name
     outputCenteredText("Menu", app_name, "topWidget", 1);
@@ -903,21 +1061,25 @@
     counter = 1;
     curItem = it.toFirst();
 
-    // Move the iterator to selectedItem -1
-    if (selectedItem != 1 && it.count() >= lcdHeight)
+    // Move the iterator to selectedItem lcdHeight/2, if > 1, -1.
+    unsigned int midPoint = (lcdHeight/2) - 1;
+    if (selectedItem > midPoint && it.count() >= lcdHeight-1)
     {
         while (counter != selectedItem)
         {
             ++it;
             ++counter;
         }
-        --it;
+        it -= midPoint;
+        counter -= midPoint;
     }
 
-    // Back up one if were at the end so the last item shows up at the bottom 
+    // Back up one if we're at the end so the last item shows up at the bottom 
     // of the display
-    if (counter == it.count() && counter != 1)
-        --it;
+    if (counter + midPoint > it.count() - midPoint && counter > midPoint)
+    {
+        it -= (counter+(lcdHeight/2)- 1) - (it.count () - midPoint);
+    }
 
     counter = 1;
     while ((curItem = it.current()) != 0)
@@ -1192,9 +1354,10 @@
 void LCD::startVolume(QString app_name)
 {
     if (lcd_showvolume)
-      sendToServer("screen_set Volume priority 32");
+      setPriority("Volume", TOP);
     outputCenteredText("Volume", "Myth " + app_name + " Volume");
     volume_level = 0.0;
+
     outputVolume();
 }
 
@@ -1202,7 +1365,7 @@
 {
     // Stop the scrolling timer
     menuScrollTimer->stop();
-    sendToServer("screen_set Menu priority 255");
+    setPriority("Menu", LOW);
 }
 
 void LCD::setLevels(int numbLevels, float *values)
@@ -1255,6 +1418,22 @@
     outputGeneric();
 }
 
+void LCD::setMusicProgress(QString time, float value)
+{
+    if (!lcd_ready)
+        return;
+
+    music_progress = value;
+    music_time = time;
+
+    if (music_progress < 0.0)
+        music_progress = 0.0;
+    else if (music_progress > 1.0)
+        music_progress = 1.0;
+
+    outputMusic();
+}
+
 void LCD::setVolumeLevel(float value)
 {
     if (!lcd_ready)
@@ -1317,6 +1496,18 @@
 {
     QString aString;
 
+    if (lcdHeight > 2) {
+      outputCenteredText("Music", music_time, "timeWidget", 2);
+    }
+
+    aString = "widget_set Music progressBar 1 ";
+    aString += QString::number(lcdHeight);
+    aString += " ";
+    aString += QString::number((int)rint(music_progress * lcdWidth * 
+                               cellWidth));
+    sendToServer(aString);
+
+#if 0
     for(int i = 0; i < 10; i++)
     {
         aString = "widget_set Music vbar";
@@ -1330,6 +1521,7 @@
                                    (cellHeight -1)));
         sendToServer(aString);
     }
+#endif
 }
 
 void LCD::outputChannel()
@@ -1371,18 +1563,22 @@
 {
     if (!lcd_ready)
         return;
-
     stopAll();
+#if LCD_DEVICE_DEBUG > 1
+    cout << "lcddevice: switchToTime " << endl ;
+#endif
     startTime();
 }
 
-void LCD::switchToMusic(const QString &artist, const QString &track)
+void LCD::switchToMusic(const QString &artist, const QString &album, const QString &track)
 {
     if (!lcd_ready)
         return;
-
     stopAll();
-    startMusic(artist, track);
+#if LCD_DEVICE_DEBUG > 1
+    cout << "lcddevice: switchToMusic " << endl ;
+#endif
+    startMusic(artist, album, track);
 }
 
 void LCD::switchToChannel(QString channum, QString title, QString subtitle)
@@ -1391,6 +1587,9 @@
         return;
 
     stopAll();
+#if LCD_DEVICE_DEBUG > 1
+    cout << "lcddevice: switchToChannel " << endl ;
+#endif
     startChannel(channum, title, subtitle);
 }
 
@@ -1399,8 +1598,10 @@
 {
     if (!lcd_ready)
         return;
-
-    stopAll();
+    //stopAll();
+#if LCD_DEVICE_DEBUG > 1
+    cout << "lcddevice: switchToMenu " << endl ;
+#endif
     startMenu(menuItems, app_name, popMenu);
 }
 
@@ -1408,8 +1609,10 @@
 {
     if (!lcd_ready)
         return;
-
     stopAll();
+#if LCD_DEVICE_DEBUG > 1
+    cout << "lcddevice: switchToGeneric " << endl ;
+#endif
     startGeneric(textItems);
 }
 
@@ -1419,6 +1622,9 @@
         return;
 
     stopAll();
+#if LCD_DEVICE_DEBUG > 1
+    cout << "lcddevice: switchToVolume " << endl ;
+#endif
     startVolume(app_name);
 }
 
@@ -1426,12 +1632,17 @@
 {
     if (!lcd_ready)
         return;
-
     stopAll();
+#if LCD_DEVICE_DEBUG > 1
+    cout << "lcddevice: switchToNothing " << endl ;
+#endif
 }
 
 void LCD::shutdown()
 {
+#if LCD_DEVICE_DEBUG > 1
+    cout << "lcddevice: shutdown " << endl ;
+#endif
     stopAll();
 
     //  Remove all the widgets and screens for a clean exit from the server
@@ -1457,12 +1668,16 @@
     sendToServer("screen_del Menu menuWidget4");
     sendToServer("screen_del Menu menuWidget5");
 
+#if 0
     QString aString;
     for (int i = 0 ; i < 10; i++)
     {
         aString = QString("widget_del Music vbar%1").arg(i);
         sendToServer(aString);
     }
+#endif
+    sendToServer("widget_del Music progressBar");
+    sendToServer("widget_del Music timeWidget");
     sendToServer("widget_del Music topWidget");
     sendToServer("screen_del Music");
     
@@ -1480,7 +1695,7 @@
 {
     m_lcd = NULL;
 
-#ifdef LCD_DEVICE_DEBUG
+#if LCD_DEVICE_DEBUG > 0
     cout << "lcddevice: An LCD device is being snuffed out of existence "
             "(~LCD() was called)" << endl ;
 #endif
Index: mythtv/libs/libmyth/lcddevice.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/lcddevice.h,v
retrieving revision 1.18
diff -u -r1.18 lcddevice.h
--- mythtv/libs/libmyth/lcddevice.h	5 Feb 2005 07:52:26 -0000	1.18
+++ mythtv/libs/libmyth/lcddevice.h	20 Apr 2005 18:35:50 -0000
@@ -112,6 +112,7 @@
    ~LCD();
 
     static class LCD * Get(void);
+    static void SetupLCD (void);
 
     // Used to actually connect to an LCD device       
     bool connectToHost(const QString &hostname, unsigned int port);
@@ -124,7 +125,7 @@
     // Note: the use of switchToMusic and setLevels is discouraged, because it 
     // has become obvious that most LCD devices cannot handle communications 
     // fast enough to make them useful.
-    void switchToMusic(const QString &artist, const QString &track);
+    void switchToMusic(const QString &artist, const QString &album, const QString &track);
 
     // You can set 10 (or less) equalizer values here (between 0.0 and 1.0)
     void setLevels(int numbLevels, float *values);
@@ -156,6 +157,9 @@
     // Do a progress bar with the generic level between 0 and 1.0
     void setGenericProgress(float generic_progress);
 
+    // Do a music progress bar with the generic level between 0 and 1.0
+    void setMusicProgress(QString time, float generic_progress);
+
     // Show the Volume Level top_text scrolls
     void switchToVolume(QString app_name);
 
@@ -210,12 +214,18 @@
                          QString widget = "topWidget", int row = 1);
    
     void sendToServer(const QString &someText);
+
+    enum PRIORITY {TOP, URGENT, HIGH, MEDIUM, LOW};
+    void setPriority(const QString &screen, PRIORITY priority);
+
+    void setHeartbeat (const QString &screen, bool onoff);
+
     void init();
     void assignScrollingText(QString theText, QString theWidget = "topWidget", 
                              int theRox = 1);
 
     void startTime();
-    void startMusic(QString artist, QString track);
+    void startMusic(QString artist, QString album, QString track);
     void startChannel(QString channum, QString title, QString subtitle);
     void startGeneric(QPtrList<LCDTextItem> * textItems);
     void startMenu(QPtrList<LCDMenuItem> *menuItems, QString app_name,
@@ -243,18 +253,32 @@
     void setHeight(unsigned int);
     void setCellWidth(unsigned int);
     void setCellHeight(unsigned int);
+    void setVersion(const QString &, const QString &);
     void describeServer();
+    
+    unsigned int prioTop;
+    unsigned int prioUrgent;
+    unsigned int prioHigh;
+    unsigned int prioMedium;
+    unsigned int prioLow;
 
     unsigned int lcdWidth;
     unsigned int lcdHeight;
     unsigned int cellWidth;
     unsigned int cellHeight;
+
+    QString serverVersion;
+    QString protocolVersion;
+    int pVersion;
         
     float EQlevels[10];
     float progress;
     float generic_progress;
     float volume_level;
 
+    float music_progress;
+    QString music_time;
+
     QString scrollingText;
     QString scrollWidget;
     int scrollRow;
@@ -281,7 +305,9 @@
     bool lcd_showchannel;
     bool lcd_showvolume;
     bool lcd_backlighton;
-    int  lcd_popuptime;
+    bool lcd_heartbeaton;
+    int  lcd_popuptime;    
+    QString lcd_showmusic_items;
 
     int (*GetLEDMask)(void);
 };
Index: mythtv/libs/libmyth/mythdialogs.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythdialogs.cpp,v
retrieving revision 1.108
diff -u -r1.108 mythdialogs.cpp
--- mythtv/libs/libmyth/mythdialogs.cpp	19 Apr 2005 02:01:14 -0000	1.108
+++ mythtv/libs/libmyth/mythdialogs.cpp	20 Apr 2005 18:35:50 -0000
@@ -1426,6 +1426,7 @@
     progress->setBackgroundOrigin(ParentOrigin);
     progress->setProgress(0);
 
+    tsteps = totalSteps;
     steps = totalSteps / 1000;
     if (steps == 0)
         steps = 1;
@@ -1463,7 +1464,7 @@
 
 void MythProgressDialog::setProgress(int curprogress)
 {
-    float fProgress = (float)curprogress / (steps * 1000.0);
+    float fProgress = (float)curprogress / tsteps;
     if (class LCD * lcddev = LCD::Get())
         lcddev->setGenericProgress(fProgress);
     progress->setProgress(curprogress);
Index: mythtv/libs/libmyth/mythdialogs.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythdialogs.h,v
retrieving revision 1.47
diff -u -r1.47 mythdialogs.h
--- mythtv/libs/libmyth/mythdialogs.h	29 Dec 2004 21:00:45 -0000	1.47
+++ mythtv/libs/libmyth/mythdialogs.h	20 Apr 2005 18:35:50 -0000
@@ -232,7 +232,7 @@
 
   private:
     QProgressBar *progress;
-    int steps;
+    int steps, tsteps;
 
     QPtrList<class LCDTextItem> * textItems;
 };
Index: mythtv/libs/libmyth/uitypes.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/uitypes.cpp,v
retrieving revision 1.97
diff -u -r1.97 uitypes.cpp
--- mythtv/libs/libmyth/uitypes.cpp  2005-04-20 11:42:56.000000000 -0700
+++ mythtv/libs/libmyth/uitypes.cpp 2005-04-22 21:51:27.629746104 -0700
@@ -2647,9 +2647,7 @@
     //  Put something on the LCD device (if one exists)
     //
 
-    class LCD *lcddev = LCD::Get();
- 
-    if (lcddev)
+    if (class LCD *lcddev = LCD::Get())
     {
         QString msg = current_node->getString();
         GenericTree *parent = current_node->getParent();
@@ -2685,8 +2683,10 @@
  
             QString title;
             title = (parent->getParent()) ? "<< " : "   ";
+            title += (current_node->childCount () > 0) ? " >> " : "  ";
             if (!menuItems.isEmpty())
             {
+                printf ("managedtree::draw\n");
                 lcddev->switchToMenu(&menuItems, title);
             }
         }
Index: mythtv/programs/mythfrontend/globalsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/globalsettings.cpp,v
retrieving revision 1.239
diff -u -r1.239 globalsettings.cpp
--- mythtv/programs/mythfrontend/globalsettings.cpp	13 Apr 2005 18:57:11 -0000	1.239
+++ mythtv/programs/mythfrontend/globalsettings.cpp	20 Apr 2005 18:35:52 -0000
@@ -2364,8 +2364,7 @@
 {
     HostCheckBox *gc = new HostCheckBox("LCDShowTime");
     gc->setLabel(QObject::tr("LCD Displays Time"));
-    gc->setHelpText(QObject::tr("Display current time on idle LCD display. "
-                    "Need to restart mythfrontend to (de)activate it."));
+    gc->setHelpText(QObject::tr("Display current time on idle LCD display. "));
     gc->setValue(true);
     return gc;
 }
@@ -2374,8 +2373,7 @@
 {
     HostCheckBox *gc = new HostCheckBox("LCDShowMenu");
     gc->setLabel(QObject::tr("LCD Displays Menus"));
-    gc->setHelpText(QObject::tr("Display selected menu on LCD display. "
-                    "Need to restart mythfrontend to (de)activate it."));
+    gc->setHelpText(QObject::tr("Display selected menu on LCD display. "));
     gc->setValue(true);
     return gc;
 }
@@ -2395,18 +2393,26 @@
     HostCheckBox *gc = new HostCheckBox("LCDShowMusic");
     gc->setLabel(QObject::tr("LCD Displays Music Artist and Title"));
     gc->setHelpText(QObject::tr("Display playing artist and song title in "
-                    "MythMusic. Need to restart mythfrontend to (de)activate "
-                    "it."));
+                    "MythMusic."));
     gc->setValue(true);
     return gc;
 }
 
+static HostComboBox *LCDShowMusicItems()
+{
+    HostComboBox *gc = new HostComboBox("LCDShowMusicItems");
+    gc->setLabel(QObject::tr("Items"));
+    gc->addSelection(QObject::tr("Artist - Title"), "ArtistTitle");
+    gc->addSelection(QObject::tr("Artist [Album] Title"), "ArtistAlbumTitle");
+    gc->setHelpText(QObject::tr("Which items to show when playing music."));
+    return gc;
+}
+
 static HostCheckBox *LCDShowChannel()
 {
     HostCheckBox *gc = new HostCheckBox("LCDShowChannel");
     gc->setLabel(QObject::tr("LCD Displays Channel Information"));
-    gc->setHelpText(QObject::tr("Display tuned channel information. Need to "
-                    "restart mythfrontend to (de)activate it."));
+    gc->setHelpText(QObject::tr("Display tuned channel information."));
     gc->setValue(true);
     return gc;
 }
@@ -2415,8 +2421,7 @@
 {
     HostCheckBox *gc = new HostCheckBox("LCDShowVolume");
     gc->setLabel(QObject::tr("LCD Displays Volume Information"));
-    gc->setHelpText(QObject::tr("Display volume level information. Need to "
-                    "restart mythfrontend to (de)activate it."));
+    gc->setHelpText(QObject::tr("Display volume level information."));
     gc->setValue(true);
     return gc;
 }
@@ -2425,8 +2430,7 @@
 {
     HostCheckBox *gc = new HostCheckBox("LCDShowGeneric");
     gc->setLabel(QObject::tr("LCD Displays Generic Information"));
-    gc->setHelpText(QObject::tr("Display generic information. Need to "
-                    "restart mythfrontend to (de)activate it."));
+    gc->setHelpText(QObject::tr("Display generic information."));
     gc->setValue(true);
     return gc;
 }
@@ -2435,19 +2439,26 @@
 {
     HostCheckBox *gc = new HostCheckBox("LCDBacklightOn");
     gc->setLabel(QObject::tr("LCD Backlight Always On"));
-    gc->setHelpText(QObject::tr("Turn on the backlight permanently. Need to "
-                    "restart mythfrontend to (de)activate it."));
+    gc->setHelpText(QObject::tr("Turn on the backlight permanently."));
     gc->setValue(true);
     return gc;
 }
 
+static HostCheckBox *LCDHeartBeatOn()
+{
+    HostCheckBox *gc = new HostCheckBox("LCDHeartBeatOn");
+    gc->setLabel(QObject::tr("LCD HeartBeat Always On"));
+    gc->setHelpText(QObject::tr("Turn on the LCD heartbeat"));
+    gc->setValue(false);
+    return gc;
+}
+
 static HostCheckBox *LCDEnable()
 {
     HostCheckBox *gc = new HostCheckBox("LCDEnable");
     gc->setLabel(QObject::tr("Enable LCD device"));
     gc->setHelpText(QObject::tr("Use an LCD display to view MythTV status "
-                    "information. Need to restart mythfrontend to "
-                    "(de)activate it."));
+                    "information."));
     gc->setValue(false);
     return gc;
 }
@@ -2469,13 +2480,16 @@
          ConfigurationGroup* setHoriz = new HorizontalConfigurationGroup(false);
          ConfigurationGroup* setLeft  = new VerticalConfigurationGroup(false);
          ConfigurationGroup* setRight = new VerticalConfigurationGroup(false);
+
          setLeft->addChild(LCDShowTime());
          setLeft->addChild(LCDShowMenu());
          setLeft->addChild(LCDShowMusic());
+         setLeft->addChild(LCDShowMusicItems());
          setLeft->addChild(LCDShowChannel());
          setRight->addChild(LCDShowVolume());
          setRight->addChild(LCDShowGeneric());
          setRight->addChild(LCDBacklightOn());
+         setRight->addChild(LCDHeartBeatOn());
          setHoriz->addChild(setLeft);
          setHoriz->addChild(setRight);
          settings->addChild(setHoriz);
Index: mythtv/programs/mythfrontend/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/main.cpp,v
retrieving revision 1.190
diff -u -r1.190 main.cpp
--- mythtv/programs/mythfrontend/main.cpp	7 Apr 2005 02:24:14 -0000	1.190
+++ mythtv/programs/mythfrontend/main.cpp	20 Apr 2005 18:35:52 -0000
@@ -395,6 +395,11 @@
         gContext->GetMainWindow()->Init();
         gContext->UpdateImageCache();
         menu->ReloadTheme();
+
+        LCD::SetupLCD ();
+        if(class LCD * lcd = LCD::Get()) {
+            lcd->setupLEDs(RemoteGetRecordingMask);
+        }
     } 
     else if (sel == "settings recording") 
     {
@@ -711,8 +716,6 @@
    
 int main(int argc, char **argv)
 {
-    QString lcd_host;
-    int lcd_port;
     QString geometry = "";
 #ifdef Q_WS_X11
     // Remember any -geometry argument which QApplication init will remove
@@ -986,14 +989,8 @@
 
     VERBOSE(VB_ALL, QString("Enabled verbose msgs :%1").arg(verboseString));
 
-    lcd_host = gContext->GetSetting("LCDHost", "localhost");
-    lcd_port = gContext->GetNumSetting("LCDPort", 13666);
-    if (lcd_host.length() > 0 && lcd_port > 1024)
-    {
-        class LCD * lcd = LCD::Get();
-        if (lcd->connectToHost(lcd_host, lcd_port) == false)
-            delete lcd;
-        else
+    LCD::SetupLCD ();
+    if (class LCD *lcd = LCD::Get ()) {
             lcd->setupLEDs(RemoteGetRecordingMask);
     }
 
@@ -1051,7 +1048,7 @@
             qApp->unlock();
             return 0;
         }
-        else
+        else 
         {
             pluginname = "myth" + pluginname;
             if (pmanager->run_plugin(pluginname))
Index: mythtv/programs/mythlcd/mythlcd.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythlcd/mythlcd.cpp,v
retrieving revision 1.8
diff -u -r1.8 mythlcd.cpp
--- mythtv/programs/mythlcd/mythlcd.cpp	23 Oct 2004 20:00:04 -0000	1.8
+++ mythtv/programs/mythlcd/mythlcd.cpp	20 Apr 2005 18:35:52 -0000
@@ -120,19 +120,19 @@
     switch (rand() % 5)
     {
         case 0:
-            lcddev->switchToMusic("2U", "1-1/4");
+            lcddev->switchToMusic("2U", "", "1-1/4");
             break;
         case 1:
-            lcddev->switchToMusic("Bernie", "Concrete Ducky");
+            lcddev->switchToMusic("Bernie", "", "Concrete Ducky");
             break;
         case 2:
-            lcddev->switchToMusic("Vid Sicous", "Their Way");
+            lcddev->switchToMusic("Vid Sicous", "", "Their Way");
             break;
         case 3:
-            lcddev->switchToMusic("Idle Eric", "Edward the Quarter Bee");
+            lcddev->switchToMusic("Idle Eric", "", "Edward the Quarter Bee");
             break;
         case 4 :
-            lcddev->switchToMusic("Dave Brebuck", "Take Half a Dozen");
+            lcddev->switchToMusic("Dave Brebuck", "", "Take Half a Dozen");
             break;
     }
     
Index: mythplugins/mythmusic/mythmusic/playbackbox.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythplugins/mythmusic/mythmusic/playbackbox.cpp,v
retrieving revision 1.85
diff -u -r1.85 playbackbox.cpp
--- mythplugins/mythmusic/mythmusic/playbackbox.cpp	11 Apr 2005 01:49:27 -0000	1.85
+++ mythplugins/mythmusic/mythmusic/playbackbox.cpp	20 Apr 2005 18:35:52 -0000
@@ -129,7 +129,7 @@
         // Set please wait on the LCD
         QPtrList<LCDTextItem> textItems;
         textItems.setAutoDelete(true);
-
+        
         textItems.append(new LCDTextItem(1, ALIGN_CENTERED, "Please Wait", 
                          "Generic"));
         lcd->switchToGeneric(&textItems);
@@ -184,6 +184,11 @@
     // Ready to go. Let's update the foreground just to be safe.
 
     updateForeground();
+
+    if (class LCD * lcd = LCD::Get())
+    {
+        lcd->switchToTime();
+    }
 }
 
 PlaybackBoxMusic::~PlaybackBoxMusic(void)
@@ -205,6 +210,8 @@
         gContext->SaveSetting("RepeatMode", "all");
     else
         gContext->SaveSetting("RepeatMode", "none");
+    if (class LCD * lcd = LCD::Get())
+        lcd->switchToTime();
 }
 
 void PlaybackBoxMusic::keyPressEvent(QKeyEvent *e)
@@ -658,19 +665,16 @@
             updateForeground();
             mainvisual->setVisual(visual_mode);
             
-            if(curMeta)
+            if (curMeta) 
             {
-                if ( class LCD *lcd = LCD::Get())
+                if (class LCD * lcd = LCD::Get()) 
                 {
-                    //Show the artist stuff on the LCD
+                    // Set track info on the LCD
                     QPtrList<LCDTextItem> textItems;
                     textItems.setAutoDelete(true);
-
-                    textItems.append(new LCDTextItem(1, ALIGN_CENTERED,
-                                    curMeta->Artist() +" [" + 
-                                    curMeta->Album() + "] " +
-                                    curMeta->Title(), "Generic", true));
-                    lcd->switchToGeneric(&textItems);
+                    lcd->switchToMusic(curMeta->Artist (), 
+                                       curMeta->Album (), 
+                                       curMeta->Title ());
                 }
             }
         }    
@@ -744,15 +748,9 @@
                         if (class LCD * lcd = LCD::Get())
                         {
                             //Show the artist stuff on the LCD
-                            QPtrList<LCDTextItem> textItems;
-                            textItems.setAutoDelete(true);
-
-                            textItems.append(new LCDTextItem(1, ALIGN_CENTERED,
-                                             curMeta->FormatArtist() +" [" + 
-                                             curMeta->Album() + "] " +
-                                             curMeta->FormatTitle(), "Generic", true));
-
-                            lcd->switchToGeneric(&textItems);
+                            lcd->switchToMusic(curMeta->Artist (), 
+                                               curMeta->Album (), 
+                                               curMeta->Title ());
                             lcd_volume_visible = false;
                         }
                     }
@@ -1062,11 +1060,15 @@
         // and down the tree.
         if (music_tree_list->nextActive(true, show_whole_tree))
             music_tree_list->activate();
+        else 
+            end();
     }
     else
     {
         if (music_tree_list->nextActive(false, show_whole_tree))
-            music_tree_list->activate();
+            music_tree_list->activate(); 
+        else 
+            end();
     }
      
     if (visualizer_status > 0 && cycle_visualizer)
@@ -1330,6 +1332,14 @@
     {
         case OutputEvent::Playing:
         {
+            if (class LCD * lcd = LCD::Get()) {
+                // Set track info on the LCD
+                QPtrList<LCDTextItem> textItems;
+                textItems.setAutoDelete(true);
+                lcd->switchToMusic(curMeta->Artist (), 
+                                   curMeta->Album (), 
+                                   curMeta->Title ());
+            }
             statusString = tr("Playing stream.");
             break;
         }
@@ -1376,17 +1386,7 @@
                 {
                     float percent_heard = ((float)rs / 
                                            (float)curMeta->Length()) * 1000.0;
-                    // Changed to use the Channel stuff as it allows us to
-                    // display Artist, Album, and Title, as well as a progress bar
-                    lcd->setGenericProgress(percent_heard);
-
-                    QPtrList<LCDTextItem> textItems;
-                    textItems.setAutoDelete(true);
-
-                    textItems.append(new LCDTextItem(3, ALIGN_RIGHT,
-                                                     time_string, "Generic"));
-
-                    lcd->outputText(&textItems);
+                    lcd->setMusicProgress(time_string, percent_heard);
                 }
             }
 
@@ -1511,14 +1511,9 @@
         if (class LCD * lcd = LCD::Get())
         {
             // Set the Artist and Tract on the LCD
-            QPtrList<LCDTextItem> textItems;
-            textItems.setAutoDelete(true);
-
-            textItems.append(new LCDTextItem(1, ALIGN_CENTERED,
-                             curMeta->FormatArtist() + " [" + curMeta->Album() + "] " +
-                             curMeta->FormatTitle(), "Generic", true));
-
-            lcd->outputText(&textItems);
+            lcd->switchToMusic(curMeta->Artist (), 
+                               curMeta->Album (), 
+                               curMeta->Title ());
         }
 
         maxTime = curMeta->Length() / 1000;
@@ -1604,6 +1599,12 @@
     }
 }
 
+void PlaybackBoxMusic::end()
+{
+    if (class LCD * lcd = LCD::Get ()) 
+        lcd->switchToTime ();
+}
+
 void PlaybackBoxMusic::wireUpTheme()
 {
     // The self managed music tree list
Index: mythplugins/mythmusic/mythmusic/playbackbox.h
===================================================================
RCS file: /var/lib/mythcvs/mythplugins/mythmusic/mythmusic/playbackbox.h,v
retrieving revision 1.35
diff -u -r1.35 playbackbox.h
--- mythplugins/mythmusic/mythmusic/playbackbox.h	6 Feb 2005 06:53:58 -0000	1.35
+++ mythplugins/mythmusic/mythmusic/playbackbox.h	20 Apr 2005 18:35:52 -0000
@@ -71,6 +71,7 @@
     void showVolume(bool on_or_off);
     void wipeTrackInfo();
     void toggleFullBlankVisualizer();
+    void end();
 
     // popup menu
     void showMenu();
