From abf606b977aefdbde52ff976652266118b3f14dd Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 1 Jun 2008 14:07:08 +0000 Subject: [PATCH] Code cleanup, fixed a few connection lost issues --- command.cc | 24 ++++++++++++------------ message.h | 2 -- messagequeue.cc | 12 ++++++++++++ messagequeue.h | 3 +-- vdr.cc | 18 +++++++++--------- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/command.cc b/command.cc index ded44e9..241f538 100644 --- a/command.cc +++ b/command.cc @@ -352,24 +352,12 @@ void Command::processMessage(Message* m) { switch(m->message) { - case Message::STANDBY: - { - doStandby(); - break; - } - - // << FIXME OBSELETE case Message::STOP_PLAYBACK: { handleCommand(Remote::STOP); // an odd way of doing it, but so simple break; } - case Message::STREAM_END: - { - // Obselete. If you're using this, something is wrong. - break; - } // Also connection_lost comes from player - anywhere else? // FIXME OBSELETE >> @@ -524,6 +512,12 @@ void Command::doFromTheTop(bool which) { if (which) { + if (connLost) + { + logger->log("Command", Log::NOTICE, "Connection lost dialog already present"); + return; + } + logger->log("Command", Log::NOTICE, "Doing connection lost dialog"); connLost = new VInfo(); connLost->setSize(360, 200); @@ -548,6 +542,12 @@ void Command::doFromTheTop(bool which) boxstack->removeAll(); boxstack->update(wallpaper); connLost = NULL; + + flushMessageQueue(); + remote->clearBuffer(); + + // at this point, everything should be reset to first-go + VConnect* vconnect = new VConnect(server); boxstack->add(vconnect); vconnect->run(); diff --git a/message.h b/message.h index 9b2b3ef..0c50be4 100644 --- a/message.h +++ b/message.h @@ -50,12 +50,10 @@ class Message const static ULONG SCREENSHOT = 5; const static ULONG CHANNEL_CHANGE = 6; const static ULONG RESUME_SELECTED_RECORDING = 7; - const static ULONG STANDBY = 8; const static ULONG STOP_PLAYBACK = 9; const static ULONG SERVER_SELECTED = 10; const static ULONG VDR_CONNECTED = 11; const static ULONG ADD_VIEW = 12; - const static ULONG STREAM_END = 13; const static ULONG REDRAW_LANG = 14; const static ULONG EPG = 16; const static ULONG EPG_CLOSE = 17; diff --git a/messagequeue.cc b/messagequeue.cc index 20c8da8..0a0a906 100644 --- a/messagequeue.cc +++ b/messagequeue.cc @@ -41,3 +41,15 @@ void MessageQueue::processMessageQueue() delete m; } } + +void MessageQueue::flushMessageQueue() +{ + Message *m; + while(messages.size()) + { + m = messages.front(); + messages.pop(); + delete m; + } +} + diff --git a/messagequeue.h b/messagequeue.h index 13e9c79..9544645 100644 --- a/messagequeue.h +++ b/messagequeue.h @@ -39,11 +39,10 @@ class MessageQueue virtual void postMessageFromOuterSpace(Message* m)=0; protected: + virtual void flushMessageQueue(); virtual void processMessageQueue(); virtual void processMessage(Message* m)=0; - - private: MQueue messages; diff --git a/vdr.cc b/vdr.cc index d01e7e3..0ca6a88 100644 --- a/vdr.cc +++ b/vdr.cc @@ -234,7 +234,7 @@ void VDR::threadMethod() if (!tcp->isConnected()) { connectionDied(); return; } // return to stop this thread - timeoutCount = 0; // disable it for now + // timeoutCount = 0; // disable it for now if (timeoutCount >= 3) // x2 for seconds { @@ -244,13 +244,13 @@ void VDR::threadMethod() if (lastKAsent == 0) { - logger->log("VDR", Log::DEBUG, "(Not actually) Sending KA packet"); -// if (!sendKA(timeNow)) -// { -// logger->log("VDR", Log::DEBUG, "Could not send KA, calling connectionDied"); -// connectionDied(); -// return; -// } + logger->log("VDR", Log::DEBUG, "Sending KA packet"); + if (!sendKA(timeNow)) + { + logger->log("VDR", Log::DEBUG, "Could not send KA, calling connectionDied"); + connectionDied(); + return; + } lastKAsent = timeNow; continue; } @@ -336,7 +336,7 @@ void VDR::threadMethod() { lastKAsent = 0; timeoutCount = 0; - logger->log("VDR", Log::ERR, "Rxd correct KA reply"); + logger->log("VDR", Log::DEBUG, "Rxd correct KA reply"); } } else -- 2.39.5