Ticket #5421: myth-lcdfix-trunk.patch

File myth-lcdfix-trunk.patch, 3.7 KB (added by dburr@…, 16 years ago)

Patch for trunk

  • libs/libmyth/lcddevice.cpp

     
    227227
    228228    last_command = someText;
    229229
    230     if (bConnected)
     230    if (lcd_ready)
    231231    {
    232232#if LCD_DEVICE_DEBUG > 9
    233233        VERBOSE(VB_IMPORTANT, "lcddevice: Sending to Server: " << someText);
     
    277277
    278278    socket->readBlock(data.data(), dataSize);
    279279
    280     lineFromServer = data;
    281     lineFromServer = lineFromServer.replace( QRegExp("\n"), " " );
    282     lineFromServer = lineFromServer.replace( QRegExp("\r"), " " );
    283     lineFromServer.simplifyWhiteSpace();
     280    QStringList responseList = QStringList::split( QRegExp("\r|\n"), data);
    284281
     282    for(uint resp = 0; resp < responseList.count(); resp++) {
     283
     284        lineFromServer = responseList[resp];
     285        lineFromServer.simplifyWhiteSpace();
     286
    285287#if LCD_DEVICE_DEBUG > 4
    286     // Make debugging be less noisy
    287     if (lineFromServer != "OK")
    288         VERBOSE(VB_IMPORTANT, "lcddevice: Received from server: " << lineFromServer);
     288        // Make debugging be less noisy
     289        if (lineFromServer != "OK")
     290            VERBOSE(VB_IMPORTANT, "lcddevice: Received from server: " << lineFromServer);
    289291#endif
    290292
    291     aList = QStringList::split(" ", lineFromServer);
    292     if (aList[0] == "CONNECTED")
    293     {
    294         // We got "CONNECTED", which is a response to "HELLO"
    295         lcd_ready = true;
     293        aList = QStringList::split(" ", lineFromServer);
     294        if (aList[0] == "CONNECTED")
     295        {
     296            // We got "CONNECTED", which is a response to "HELLO"
    296297
    297         // get lcd width & height
    298         if (aList.count() != 3)
    299         {
    300             VERBOSE(VB_IMPORTANT, "lcddevice: received bad no. of arguments "
     298            //done by init()
     299            //lcd_ready = true;
     300
     301            // get lcd width & height
     302            if (aList.count() != 3)
     303            {
     304                VERBOSE(VB_IMPORTANT, "lcddevice: received bad no. of arguments "
    301305                            "in CONNECTED response from LCDServer");
    302         }
     306            }
    303307
    304         bool bOK;
    305         lcd_width = aList[1].toInt(&bOK);
    306         if (!bOK)
    307         {
    308             VERBOSE(VB_IMPORTANT, "lcddevice: received bad int for width"
     308            bool bOK;
     309            lcd_width = aList[1].toInt(&bOK);
     310            if (!bOK)
     311            {
     312                VERBOSE(VB_IMPORTANT, "lcddevice: received bad int for width"
    309313                            "in CONNECTED response from LCDServer");
    310         }
     314            }
    311315
    312         lcd_height = aList[2].toInt(&bOK);
    313         if (!bOK)
    314         {
    315             VERBOSE(VB_IMPORTANT, "lcddevice: received bad int for height"
     316            lcd_height = aList[2].toInt(&bOK);
     317            if (!bOK)
     318            {
     319                VERBOSE(VB_IMPORTANT, "lcddevice: received bad int for height"
    316320                            "in CONNECTED response from LCDServer");
     321            }
     322
     323            init();
    317324        }
    318 
    319         init();
    320     }
    321     else if (aList[0] == "HUH?")
    322     {
    323         VERBOSE(VB_IMPORTANT, "lcddevice: WARNING: Something is getting passed"
     325        else if (aList[0] == "HUH?")
     326        {
     327            VERBOSE(VB_IMPORTANT, "lcddevice: WARNING: Something is getting passed"
    324328                        "to LCDServer that it doesn't understand");
    325         VERBOSE(VB_IMPORTANT, QString("lcddevice: last command: %1").arg( last_command ));
     329            VERBOSE(VB_IMPORTANT, QString("lcddevice: last command: %1").arg( last_command ));
     330        }
     331        else if (aList[0] == "KEY")
     332            handleKeyPress(aList.last().stripWhiteSpace());
    326333    }
    327     else if (aList[0] == "KEY")
    328         handleKeyPress(aList.last().stripWhiteSpace());
    329334}
    330335
    331336void LCD::handleKeyPress(QString key_pressed)