Ticket #12960: 20170701_idle.patch

File 20170701_idle.patch, 6.6 KB (added by Peter Bennett, 3 years ago)

Peter's version of patch

  • mythtv/libs/libmyth/mythcontext.cpp

    diff --git a/mythtv/libs/libmyth/mythcontext.cpp b/mythtv/libs/libmyth/mythcontext.cpp
    index 28c0eb5..5e169a3 100644
    a b void MythContextPrivate::ShowConnectionFailurePopup(bool persistent) 
    13411341    if (m_lastCheck.isValid() && now < m_lastCheck)
    13421342        return;
    13431343
     1344    // When WOL is disallowed, standy mode,
     1345    // we should not show connection failures.
     1346    if (!gCoreContext->IsWOLAllowed())
     1347        return;
     1348
    13441349    m_lastCheck = now.addMSecs(5000); // don't refresh notification more than every 5s
    13451350
    13461351    QString description = (persistent) ?
  • mythtv/libs/libmythbase/mythcorecontext.cpp

    diff --git a/mythtv/libs/libmythbase/mythcorecontext.cpp b/mythtv/libs/libmythbase/mythcorecontext.cpp
    index 26926a0..bbcd468 100644
    a b class MythCoreContextPrivate : public QObject 
    8282    QMutex         m_WOLInProgressLock;
    8383    QWaitCondition m_WOLInProgressWaitCondition;
    8484    bool           m_WOLInProgress;
     85    bool           m_IsWOLAllowed;
    8586
    8687    bool m_backend;
    8788    bool m_frontend;
    MythCoreContextPrivate::MythCoreContextPrivate(MythCoreContext *lparent, 
    128129      m_sockLock(QMutex::NonRecursive),
    129130      m_serverSock(NULL), m_eventSock(NULL),
    130131      m_WOLInProgress(false),
     132      m_IsWOLAllowed(true),
    131133      m_backend(false),
    132134      m_frontend(false),
    133135      m_database(GetMythDB()),
    MythSocket *MythCoreContext::ConnectCommandSocket( 
    416418        d->WaitForWOL();
    417419    }
    418420
    419     QString WOLcmd = GetSetting("WOLbackendCommand", "");
     421    QString WOLcmd;
     422    if (IsWOLAllowed())
     423        WOLcmd = GetSetting("WOLbackendCommand", "");
    420424
    421425    if (maxConnTry < 1)
    422426        maxConnTry = max(GetNumSetting("BackendConnectRetry", 1), 1);
    bool MythCoreContext::IsBlockingClient(void) const 
    604608    return d->m_blockingClient;
    605609}
    606610
     611void MythCoreContext::SetWOLAllowed(bool allow)
     612{
     613    d->m_IsWOLAllowed = allow;
     614}
     615
     616bool MythCoreContext::IsWOLAllowed() const
     617{
     618    return d->m_IsWOLAllowed;
     619}
     620
    607621void MythCoreContext::SetAsBackend(bool backend)
    608622{
    609623    d->m_backend = backend;
  • mythtv/libs/libmythbase/mythcorecontext.h

    diff --git a/mythtv/libs/libmythbase/mythcorecontext.h b/mythtv/libs/libmythbase/mythcorecontext.h
    index 4ca77e2..6fb6adc 100644
    a b class MBASE_PUBLIC MythCoreContext : public QObject, public MythObservable, publ 
    115115    void AllowShutdown(void);
    116116    bool IsBlockingClient(void) const; ///< is this client blocking shutdown
    117117
     118    void SetWOLAllowed(bool allow);
     119    bool IsWOLAllowed() const;
     120
    118121    bool SendReceiveStringList(QStringList &strlist, bool quickTimeout = false,
    119122                               bool block = true);
    120123    void SendMessage(const QString &message);
  • mythtv/libs/libmythbase/mythdbcon.cpp

    diff --git a/mythtv/libs/libmythbase/mythdbcon.cpp b/mythtv/libs/libmythbase/mythdbcon.cpp
    index 18a30d7..cb406fc 100644
    a b bool MSqlDatabase::OpenDatabase(bool skipdb) 
    164164            m_dbparms.dbHostName == "127.0.0.1")
    165165            m_db.setHostName("localhost");
    166166
     167        // Default read timeout is 10 mins - set a better value 20 seconds
     168        m_db.setConnectOptions(QString("MYSQL_OPT_READ_TIMEOUT=20"));
     169
    167170        connected = m_db.open();
    168171
    169         if (!connected && m_dbparms.wolEnabled)
     172        if (!connected && m_dbparms.wolEnabled
     173            && gCoreContext->IsWOLAllowed())
    170174        {
    171175            int trycount = 0;
    172176
  • mythtv/libs/libmythbase/mythsocket.cpp

    diff --git a/mythtv/libs/libmythbase/mythsocket.cpp b/mythtv/libs/libmythbase/mythsocket.cpp
    index 25210b8..63f10b5 100644
    a b void MythSocket::ConnectToHostReal(QHostAddress _addr, quint16 port, bool *ret) 
    682682    if (ok)
    683683    {
    684684        m_tcpSocket->connectToHost(addr, port, QAbstractSocket::ReadWrite);
    685         ok = m_tcpSocket->waitForConnected();
     685        ok = m_tcpSocket->waitForConnected(5000);
    686686    }
    687687
    688688    if (ok)
  • mythtv/libs/libmythui/mythmainwindow.cpp

    diff --git a/mythtv/libs/libmythui/mythmainwindow.cpp b/mythtv/libs/libmythui/mythmainwindow.cpp
    index 7c2917a..8170e24 100644
    a b void MythMainWindow::EnterStandby(bool manual) 
    30133013        GetMythDB()->GetSetting("menutheme", "defaultmenu"));
    30143014    state.insert("currentlocation", GetMythUI()->GetCurrentLocation());
    30153015    MythUIStateTracker::SetState(state);
     3016
     3017    // Cache WOL settings in case DB goes down
     3018    QString masterserver = gCoreContext->GetSetting
     3019                    ("MasterServerName");
     3020    gCoreContext->GetSettingOnHost
     3021                    ("BackendServerAddr", masterserver);
     3022    gCoreContext->GetMasterServerPort();
     3023    gCoreContext->GetSetting("WOLbackendCommand", "");
     3024
     3025    // While in standby do not attempt to wake the backend
     3026    gCoreContext->SetWOLAllowed(false);
    30163027}
    30173028
    30183029void MythMainWindow::ExitStandby(bool manual)
    void MythMainWindow::ExitStandby(bool manual) 
    30313042    LOG(VB_GENERAL, LOG_NOTICE, "Leaving standby mode");
    30323043
    30333044    d->standby = false;
     3045
     3046    // We may attempt to wake the backend
     3047    gCoreContext->SetWOLAllowed(true);
     3048
    30343049    gCoreContext->BlockShutdown();
    30353050
    30363051    QVariantMap state;
  • mythtv/programs/mythfrontend/globalsettings.cpp

    diff --git a/mythtv/programs/mythfrontend/globalsettings.cpp b/mythtv/programs/mythfrontend/globalsettings.cpp
    index f7d51e5..49ba805 100644
    a b static HostCheckBoxSetting *UseVirtualKeyboard() 
    17611761
    17621762static HostSpinBoxSetting *FrontendIdleTimeout()
    17631763{
    1764     HostSpinBoxSetting *gs = new HostSpinBoxSetting("FrontendIdleTimeout", 0, 360, 15);
     1764    HostSpinBoxSetting *gs = new HostSpinBoxSetting("FrontendIdleTimeout", 0, 360, 5);
    17651765
    17661766    gs->setLabel(MainGeneralSettings::tr("Idle time before entering standby "
    17671767                                         "mode (minutes)"));
  • mythtv/programs/mythtv-setup/backendsettings.cpp

    diff --git a/mythtv/programs/mythtv-setup/backendsettings.cpp b/mythtv/programs/mythtv-setup/backendsettings.cpp
    index 7ea4880..6de0bae 100644
    a b static GlobalTextEditSetting *WOLbackendCommand() 
    418418    gc->setLabel(QObject::tr("Wake command"));
    419419    gc->setValue("");
    420420    gc->setHelpText(QObject::tr("The command used to wake up your master "
    421             "backend server (e.g. sudo /etc/init.d/mythtv-backend restart)."));
     421            "backend server (e.g. wakeonlan 00:00:00:00:00:00)."));
    422422    return gc;
    423423};
    424424