Ticket #1044: 1044.patch
File 1044.patch, 4.5 KB (added by , 19 years ago) |
---|
-
libs/libmyth/lcddevice.cpp
31 31 #define LCD_DEVICE_DEBUG 0 32 32 33 33 LCD::LCD() 34 :QObject(NULL, "LCD") 34 : QObject(NULL, "LCD"), 35 socket(new QSocket(this)), socketLock(true), 36 hostname("localhost"), port(6545), 37 connected(false), 38 39 retryTimer(new QTimer(this)), LEDTimer(new QTimer(this)), 40 41 send_buffer(""), last_command(QString::null), 42 43 lcd_width(0), lcd_height(0), 44 45 lcd_ready(false), lcd_showtime(false), 46 lcd_showmenu(false), lcd_showgeneric(false), 47 lcd_showmusic(false), lcd_showchannel(false), 48 lcd_showvolume(false), lcd_showrecstatus(false), 49 lcd_backlighton(false), lcd_heartbeaton(false), 50 51 lcd_popuptime(0), 52 53 lcd_showmusic_items(QString::null), 54 lcd_keystring(QString::null), 55 56 GetLEDMask(NULL) 35 57 { 36 58 // Constructor for LCD 37 59 // … … 39 61 // communications with the LDCd daemon. 40 62 41 63 #if LCD_DEVICE_DEBUG > 0 42 VERBOSE(VB_IMPORTANT, "lcddevice: An LCD object now exists (LCD() was called)"); 64 VERBOSE(VB_IMPORTANT, "lcddevice: An LCD object now exists " 65 "(LCD() was called)"); 43 66 #endif 44 67 45 GetLEDMask = NULL; 46 47 socket = new QSocket(this); 48 connect(socket, SIGNAL(error(int)), this, SLOT(veryBadThings(int))); 49 connect(socket, SIGNAL(readyRead()), this, SLOT(serverSendingData())); 50 51 lcd_ready = false; 52 53 hostname = "localhost"; 54 port = 6545; 55 56 connected = false; 57 send_buffer = ""; 58 59 retryTimer = new QTimer(this); 60 connect(retryTimer, SIGNAL(timeout()), this, SLOT(restartConnection())); 61 62 LEDTimer = new QTimer(this); 63 connect(LEDTimer, SIGNAL(timeout()), this, SLOT(outputLEDs())); 68 connect(socket, SIGNAL(error(int)), this, SLOT(veryBadThings(int))); 69 connect(socket, SIGNAL(readyRead()), this, SLOT(serverSendingData())); 70 connect(retryTimer, SIGNAL(timeout()), this, SLOT(restartConnection())); 71 connect(LEDTimer, SIGNAL(timeout()), this, SLOT(outputLEDs())); 64 72 } 65 73 66 74 bool LCD::m_server_unavailable = false; … … 102 110 103 111 bool LCD::connectToHost(const QString &lhostname, unsigned int lport) 104 112 { 105 #if LCD_DEVICE_DEBUG > 0 113 QMutexLocker locker(&socketLock); 114 115 #if LCD_DEVICE_DEBUG > 0 106 116 VERBOSE(VB_IMPORTANT, "lcddevice: connecting to host: " 107 117 << lhostname << " - port: " << lport); 108 118 #endif … … 185 195 186 196 void LCD::sendToServer(const QString &someText) 187 197 { 198 QMutexLocker locker(&socketLock); 199 188 200 // Check the socket, make sure the connection is still up 189 201 if (socket->state() == QSocket::Idle) 190 202 { … … 236 248 237 249 void LCD::serverSendingData() 238 250 { 251 QMutexLocker locker(&socketLock); 252 239 253 QString lineFromServer, tempString; 240 254 QStringList aList; 241 255 QStringList::Iterator it; … … 354 368 355 369 void LCD::veryBadThings(int anError) 356 370 { 371 QMutexLocker locker(&socketLock); 372 357 373 // Deal with failures to connect and inabilities to communicate 358 374 359 375 QString err; … … 616 632 617 633 void LCD::shutdown() 618 634 { 635 QMutexLocker locker(&socketLock); 636 619 637 #if LCD_DEVICE_DEBUG > 1 620 638 VERBOSE(VB_IMPORTANT, "lcddevice: shutdown"); 621 639 #endif … … 628 646 629 647 void LCD::resetServer() 630 648 { 649 QMutexLocker locker(&socketLock); 650 631 651 if (!lcd_ready) 632 652 return; 633 653 -
libs/libmyth/lcddevice.h
2 2 #define LCDDEVICE_H_ 3 3 4 4 #include <iostream> 5 using namespace std; 6 5 7 #include <qobject.h> 6 8 #include <qstringlist.h> 7 9 #include <qvaluevector.h> 8 10 #include <qsocket.h> 9 11 #include <qtimer.h> 10 12 #include <qdatetime.h> 13 #include <qmutex.h> 11 14 12 using namespace std;13 14 15 enum CHECKED_STATE {CHECKED = 0, UNCHECKED, NOTCHECKABLE }; 15 16 16 17 class LCDMenuItem … … 225 226 void init(); 226 227 void handleKeyPress(QString key); 227 228 QString quotedString(const QString &s); 229 void describeServer(); 228 230 229 231 QSocket *socket; 232 QMutex socketLock; 233 QString hostname; 234 uint port; 235 bool connected; 236 230 237 QTimer *retryTimer; 231 238 QTimer *LEDTimer; 232 239 233 void describeServer();234 235 bool connected;236 237 240 QString send_buffer; 238 241 QString last_command; 239 QString hostname;240 unsigned int port;241 242 242 243 int lcd_width; 243 244 int lcd_height;