Ticket #12960: idlescreen.patch
File idlescreen.patch, 8.5 KB (added by , 7 years ago) |
---|
-
mythtv/libs/libmythbase/mythcorecontext.cpp
a b 323 323 324 324 // Connects to master server safely (i.e. by taking m_sockLock) 325 325 bool MythCoreContext::SafeConnectToMasterServer(bool blockingClient, 326 bool openEventSocket) 326 bool openEventSocket, 327 bool disableWOL) 327 328 { 328 329 QMutexLocker locker(&d->m_sockLock); 329 bool success = ConnectToMasterServer(blockingClient, openEventSocket );330 bool success = ConnectToMasterServer(blockingClient, openEventSocket, disableWOL); 330 331 331 332 return success; 332 333 } … … 334 335 // Assumes that either m_sockLock is held, or the app is still single 335 336 // threaded (i.e. during startup). 336 337 bool MythCoreContext::ConnectToMasterServer(bool blockingClient, 337 bool openEventSocket) 338 bool openEventSocket, 339 bool disableWOL) 338 340 { 339 341 if (IsMasterBackend()) 340 342 { … … 362 364 .arg(type) 363 365 .arg(d->m_localHostname).arg(false); 364 366 d->m_serverSock = ConnectCommandSocket( 365 server, port, ann, &proto_mismatch );367 server, port, ann, &proto_mismatch,true,-1,-1,disableWOL); 366 368 } 367 369 368 370 if (!d->m_serverSock) … … 401 403 402 404 MythSocket *MythCoreContext::ConnectCommandSocket( 403 405 const QString &hostname, int port, const QString &announce, 404 bool *p_proto_mismatch, bool gui, int maxConnTry, int setup_timeout) 406 bool *p_proto_mismatch, bool gui, int maxConnTry, int setup_timeout, 407 bool disableWOL) 405 408 { 406 409 MythSocket *serverSock = NULL; 407 410 … … 410 413 d->WaitForWOL(); 411 414 } 412 415 413 QString WOLcmd = GetSetting("WOLbackendCommand", "");416 QString WOLcmd = disableWOL?"":GetSetting("WOLbackendCommand", ""); 414 417 415 418 if (maxConnTry < 1) 416 419 maxConnTry = max(GetNumSetting("BackendConnectRetry", 1), 1); -
mythtv/libs/libmythbase/mythcorecontext.h
a b 64 64 void SetScheduler(MythScheduler *sched); 65 65 66 66 bool SafeConnectToMasterServer(bool blockingClient = true, 67 bool openEventSocket = true); 67 bool openEventSocket = true, 68 bool disableWOL = false); 68 69 bool ConnectToMasterServer(bool blockingClient = true, 69 bool openEventSocket = true); 70 bool openEventSocket = true, 71 bool disableWOL = false); 70 72 71 73 MythSocket *ConnectCommandSocket(const QString &hostname, int port, 72 74 const QString &announcement, 73 75 bool *proto_mismatch = NULL, 74 76 bool gui = true, int maxConnTry = -1, 75 int setup_timeout = -1); 77 int setup_timeout = -1, 78 bool disableWOL = false); 76 79 77 80 MythSocket *ConnectEventSocket(const QString &hostname, int port); 78 81 -
mythtv/programs/mythfrontend/backendconnectionmanager.cpp
a b 22 22 23 23 class Reconnect : public QRunnable 24 24 { 25 private: 26 bool m_disableWOL; 27 25 28 public: 26 Reconnect( )29 Reconnect(bool disableWOL = false) 27 30 { 28 31 setAutoDelete(false); 32 m_disableWOL = disableWOL; 29 33 } 30 34 31 35 virtual void run(void) 32 36 { 33 if (!gCoreContext->SafeConnectToMasterServer(gCoreContext->IsBlockingClient() ))37 if (!gCoreContext->SafeConnectToMasterServer(gCoreContext->IsBlockingClient(),true,m_disableWOL)) 34 38 gCoreContext->dispatch(MythEvent(QString("RECONNECT_FAILURE"))); 35 39 else 36 40 gCoreContext->dispatch(MythEvent(QString("RECONNECT_SUCCESS"))); … … 69 73 MythEvent *me = (MythEvent *)event; 70 74 QString message = me->Message(); 71 75 76 if (message == "IDLE_SCREEN_LOADED") 77 { 78 m_frontend_idle = true; 79 LOG(VB_SOCKET, LOG_INFO, "IDLE_SCREEN_LOADED"); 80 } 81 82 if (message == "IDLE_SCREEN_DESTROYED") 83 { 84 m_frontend_idle = false; 85 LOG(VB_SOCKET, LOG_INFO, "IDLE_SCREEN_DESTROYED"); 86 } 87 88 if (message == "SHUTDOWN_NOW") 89 { 90 // m_shutdown_now is restored to false when a successful connection is made. 91 m_shutdown_now = true; 92 LOG(VB_SOCKET, LOG_INFO, "SHUTDOWN_NOW"); 93 } 72 94 if (message == "BACKEND_SOCKETS_CLOSED") 73 95 { 74 96 LOG(VB_SOCKET, LOG_INFO, "Got BACKEND_SOCKETS_CLOSED message"); … … 100 122 } 101 123 reconnect = m_reconnect_again; 102 124 m_reconnect_again = message == "RECONNECT_FAILURE"; 125 if (message == "RECONNECT_SUCCESS" && m_shutdown_now) 126 { 127 // Backend has restarted after a shutdown 128 LOG(VB_SOCKET, LOG_INFO, "RECONNECT_SUCCESS after SHUTDOWN_NOW"); 129 m_shutdown_now = false; 130 } 103 131 } 104 132 } 105 133 … … 118 146 119 147 void BackendConnectionManager::ReconnectToBackend(void) 120 148 { 121 LOG(VB_SOCKET, LOG_INFO, "Reconnecting"); 122 m_reconnecting = new Reconnect(); 149 bool disableWOL = (m_frontend_idle && m_shutdown_now); 150 if (disableWOL) 151 LOG(VB_SOCKET, LOG_INFO, "Reconnecting with WOL disabled"); 152 else 153 LOG(VB_SOCKET, LOG_INFO, "Reconnecting"); 154 m_reconnecting = new Reconnect(disableWOL); 123 155 MThreadPool::globalInstance()->start(m_reconnecting, "Reconnect"); 124 156 } -
mythtv/programs/mythfrontend/backendconnectionmanager.h
a b 21 21 Reconnect *m_reconnecting; 22 22 QTimer *m_reconnect_timer; 23 23 bool m_reconnect_again; 24 bool m_frontend_idle; 25 bool m_shutdown_now; 24 26 }; -
mythtv/programs/mythfrontend/idlescreen.cpp
a b 26 26 m_conflictWarning(NULL), 27 27 m_secondsToShutdown(-1), 28 28 m_pendingSchedUpdate(false), 29 m_hasConflicts(false) 29 m_hasConflicts(false), 30 m_disableWOL(false) 30 31 { 31 32 gCoreContext->addListener(this); 32 33 GetMythMainWindow()->EnterStandby(); … … 34 35 connect(m_updateScreenTimer, SIGNAL(timeout()), 35 36 this, SLOT(UpdateScreen())); 36 37 m_updateScreenTimer->start(UPDATE_INTERVAL); 38 gCoreContext->dispatch(MythEvent(QString("IDLE_SCREEN_LOADED"))); 39 gContext->SetDisableEventPopup(true); 37 40 } 38 41 39 42 IdleScreen::~IdleScreen() 40 43 { 44 gContext->SetDisableEventPopup(false); 45 gCoreContext->dispatch(MythEvent(QString("IDLE_SCREEN_DESTROYED"))); 41 46 GetMythMainWindow()->ExitStandby(); 42 47 gCoreContext->removeListener(this); 43 48 … … 95 100 bRes = true; 96 101 else 97 102 { 98 if (gCoreContext->SafeConnectToMasterServer(false ))103 if (gCoreContext->SafeConnectToMasterServer(false,true,m_disableWOL)) 99 104 bRes = true; 100 105 } 101 106 … … 255 260 { 256 261 MythEvent *me = static_cast<MythEvent *>(event); 257 262 263 if (me->Message().startsWith("RECONNECT_SUCCESS")) 264 m_disableWOL = false; 265 258 266 if (me->Message().startsWith("RECONNECT_")) 259 267 { 260 268 m_secondsToShutdown = -1; … … 268 276 } 269 277 else if (me->Message().startsWith("SHUTDOWN_NOW")) 270 278 { 279 m_disableWOL = true; 271 280 if (gCoreContext->IsFrontendOnly()) 272 281 { 273 282 // does the user want to shutdown this frontend only machine -
mythtv/programs/mythfrontend/idlescreen.h
a b 50 50 bool m_pendingSchedUpdate; 51 51 ProgramList m_scheduledList; 52 52 bool m_hasConflicts; 53 bool m_disableWOL; 53 54 }; 54 55 55 56 #endif