Ticket #13136: 20170929_startup.patch

File 20170929_startup.patch, 11.9 KB (added by Peter Bennett, 4 years ago)

Patch to implement this feature

  • mythtv/libs/libmyth/guistartup.cpp

    diff --git a/mythtv/libs/libmyth/guistartup.cpp b/mythtv/libs/libmyth/guistartup.cpp
    index d0636b8..1d7eea0 100644
    a b void GUIStartup::setTotal(int total) 
    157157    m_Retry = false;
    158158}
    159159
     160void GUIStartup::setRetryButtonText(const QString text)
     161{
     162    m_retryButton->SetText(text);
     163}
     164
    160165// return = true if time is up
    161 bool GUIStartup::updateProgress(bool finished)
     166bool GUIStartup::updateProgress(bool finished, bool reset)
    162167{
    163168    if (m_progressTimer)
    164169    {
    bool GUIStartup::updateProgress(bool finished) 
    167172            elapsed = m_total;
    168173        else
    169174            elapsed = m_progressTimer->elapsed();
    170         m_progressBar->SetUsed(elapsed);
     175        if (reset)
     176            m_progressBar->SetUsed(0);
     177        else
     178            m_progressBar->SetUsed(elapsed);
    171179        if (elapsed >= m_total)
    172180        {
    173181            m_timer.stop();
  • mythtv/libs/libmyth/guistartup.h

    diff --git a/mythtv/libs/libmyth/guistartup.h b/mythtv/libs/libmyth/guistartup.h
    index 27baa26..46e05fb 100644
    a b class MPUBLIC GUIStartup : public MythScreenType 
    6262    bool setStatusState(const QString &name);
    6363    bool setMessageState(const QString &name);
    6464    void setTotal(int total);
     65    void setRetryButtonText(const QString text);
    6566
    6667  public slots:
    67     bool updateProgress(bool finished = false);
     68    bool updateProgress(bool finished = false, bool reset = false);
    6869
    6970  private slots:
    7071    void Retry(void);
  • mythtv/libs/libmyth/mythcontext.cpp

    diff --git a/mythtv/libs/libmyth/mythcontext.cpp b/mythtv/libs/libmyth/mythcontext.cpp
    index 4b6680a..d4ccbdd 100644
    a b class MythContextPrivate : public QObject 
    7070
    7171    bool Init        (const bool gui,
    7272                      const bool prompt, const bool noPrompt,
    73                       const bool ignoreDB);
     73                      const bool ignoreDB,
     74                      const bool bWaitBeforeConnect);
    7475    bool FindDatabase(const bool prompt, const bool noPrompt);
    7576
    7677    void TempMainWindow(bool languagePrompt = true);
    class MythContextPrivate : public QObject 
    128129    QEventLoop *m_loop;
    129130    bool needsBackend;
    130131    bool m_settingsCacheDirty;
     132    bool m_bWaitBeforeConnect;
    131133
    132134  private:
    133135    MythConfirmationDialog *MBEversionPopup;
    MythContextPrivate::MythContextPrivate(MythContext *lparent) 
    243245      m_guiStartup(0),
    244246      needsBackend(false),
    245247      m_settingsCacheDirty(false),
     248      m_bWaitBeforeConnect(false),
    246249      MBEversionPopup(NULL),
    247250      m_registration(-1),
    248251      m_socket(0)
    bool MythContextPrivate::checkPort(QString &host, int port, int timeLimit) 
    343346bool MythContextPrivate::Init(const bool gui,
    344347                              const bool promptForBackend,
    345348                              const bool noPrompt,
    346                               const bool ignoreDB)
     349                              const bool ignoreDB,
     350                              const bool bWaitBeforeConnect)
    347351{
    348352    gCoreContext->GetDB()->IgnoreDatabase(ignoreDB);
    349353    m_gui = gui;
     354    m_bWaitBeforeConnect = bWaitBeforeConnect;
    350355
    351356    if (gCoreContext->IsFrontend())
    352357        needsBackend = true;
    QString MythContextPrivate::TestDBconnection(bool prompt) 
    797802        st_dbConnects = 3,
    798803        st_beWOL = 4,
    799804        st_beAwake = 5,
    800         st_success = 6
     805        st_success = 6,
     806        st_wait = 7
    801807    } startupState = st_start;
    802808
    803     static const QString guiStatuses[7] =
     809    static const QString guiStatuses[8] =
    804810        {"start","dbAwake","dbStarted","dbConnects","beWOL","beAwake",
    805             "success" };
     811            "success","wait" };
     812
     813    bool waitForUser = m_bWaitBeforeConnect;
    806814
    807815    do
    808816    {
    809         host = m_DBparams.dbHostName;
     817        if (m_DBparams.dbHostName.isEmpty() && m_DBhostCp.length())
     818            host = m_DBhostCp;
     819        else
     820            host = m_DBparams.dbHostName;
    810821        port = m_DBparams.dbPort;
    811822        if (port == 0)
    812823            port = 3306;
    813824        int wakeupTime = 3;
    814825        int attempts = 11;
    815         if (m_DBparams.wolEnabled) {
    816             wakeupTime = m_DBparams.wolReconnect;
    817             attempts = m_DBparams.wolRetry + 1;
    818             startupState = st_start;
     826        if (waitForUser)
     827        {
     828            startupState = st_wait;
     829            ShowGuiStartup();
     830            if (m_guiStartup)
     831                //: Text for Start button - to start connecting to backend
     832                m_guiStartup->setRetryButtonText(QObject::tr("Start"));
    819833        }
    820834        else
    821             startupState = st_dbAwake;
     835        {
     836            if (m_guiStartup)
     837                //: Text for Retry button - to try again connecting to backend
     838                m_guiStartup->setRetryButtonText(QObject::tr("Retry"));
     839            if (m_DBparams.wolEnabled) {
     840                wakeupTime = m_DBparams.wolReconnect;
     841                attempts = m_DBparams.wolRetry + 1;
     842                startupState = st_start;
     843            }
     844            else
     845                startupState = st_dbAwake;
     846        }
    822847        if (attempts < 6)
    823848            attempts = 6;
    824849        if (!prompt)
    QString MythContextPrivate::TestDBconnection(bool prompt) 
    837862        QString masterserver;
    838863
    839864        for (int attempt = 0;
    840             attempt < attempts && startupState != st_success;
     865            attempt < attempts && startupState != st_success
     866                && startupState != st_wait;
    841867            ++attempt)
    842868        {
    843869            // The first time do everything with minimum timeout and
    QString MythContextPrivate::TestDBconnection(bool prompt) 
    962988            break;
    963989
    964990        QString stateMsg = guiStatuses[startupState];
    965         stateMsg.append("Fail");
    966         LOG(VB_GENERAL, LOG_INFO,
    967              QString("Start up failure. host %1, status %2")
    968                   .arg(host).arg(stateMsg));
    969 
     991        if (startupState != st_wait)
     992        {
     993            stateMsg.append("Fail");
     994            LOG(VB_GENERAL, LOG_INFO,
     995                 QString("Start up failure. host %1, status %2")
     996                      .arg(host).arg(stateMsg));
     997        }
    970998        if (m_guiStartup
    971999          && !m_guiStartup->m_Exit
    9721000          && !m_guiStartup->m_Setup
    9731001          && !m_guiStartup->m_Search
    9741002          && !m_guiStartup->m_Retry)
    9751003        {
    976             m_guiStartup->updateProgress(true);
     1004            m_guiStartup->updateProgress(true, waitForUser);
    9771005            m_guiStartup->setStatusState(stateMsg);
    9781006            m_guiStartup->setMessageState("makeselection");
    9791007            m_loop->exec();
     1008            waitForUser = false;
    9801009        }
    9811010    }
    9821011    while (m_guiStartup && m_guiStartup->m_Retry);
    QString MythContextPrivate::TestDBconnection(bool prompt) 
    10021031        return QObject::tr("Cannot connect to backend", "Backend Setup");
    10031032    }
    10041033
     1034    if (startupState == st_wait)
     1035    {
     1036        return QObject::tr("User requested exit", "Backend Setup");
     1037    }
     1038
     1039
    10051040    // Current DB connection may have been silenced (invalid):
    10061041    EnableDBerrors();
    10071042    ResetDatabase();
    void MythContextPrivate::ShowVersionMismatchPopup(uint remote_version) 
    14071442// return true if progress is 100%
    14081443void MythContextPrivate::processEvents(void)
    14091444{
    1410 //    bool ret = false;
    1411 //    if (m_guiStartup)
    1412 //        ret = m_guiStartup->updateProgress();
    14131445    qApp->processEvents(QEventLoop::AllEvents, 250);
    14141446    qApp->processEvents(QEventLoop::AllEvents, 250);
    1415 //    return ret;
    14161447}
    14171448
    14181449// cache some settings in cache/contextcache.xml
    MythContext::MythContext(const QString &binversion, bool needsBackend) 
    15171548bool MythContext::Init(const bool gui,
    15181549                       const bool promptForBackend,
    15191550                       const bool disableAutoDiscovery,
    1520                        const bool ignoreDB)
     1551                       const bool ignoreDB,
     1552                       const bool bWaitBeforeConnect)
    15211553{
    15221554    SetDisableEventPopup(true);
    15231555
    bool MythContext::Init(const bool gui, 
    15821614        return false;
    15831615    }
    15841616
    1585     if (!d->Init(gui, promptForBackend, disableAutoDiscovery, ignoreDB))
     1617    if (!d->Init(gui, promptForBackend, disableAutoDiscovery, ignoreDB, bWaitBeforeConnect))
    15861618    {
    15871619        return false;
    15881620    }
  • mythtv/libs/libmyth/mythcontext.h

    diff --git a/mythtv/libs/libmyth/mythcontext.h b/mythtv/libs/libmyth/mythcontext.h
    index 8bc4f86..7cf9e83 100644
    a b class MPUBLIC MythContext 
    4848    bool Init(const bool gui = true,
    4949              const bool promptForBackend = false,
    5050              const bool bypassAutoDiscovery = false,
    51               const bool ignoreDB = false);
     51              const bool ignoreDB = false,
     52              const bool bWaitBeforeConnect = false);
    5253
    5354    DatabaseParams GetDatabaseParams(void);
    5455    bool SaveDatabaseParams(const DatabaseParams &params);
  • mythtv/programs/mythfrontend/commandlineparser.cpp

    diff --git a/mythtv/programs/mythfrontend/commandlineparser.cpp b/mythtv/programs/mythfrontend/commandlineparser.cpp
    index 0173ed0..f4aaa2c 100644
    a b void MythFrontendCommandLineParser::LoadArguments(void) 
    2727        "noautodiscovery", false,
    2828        "Prevent frontend from using UPnP autodiscovery.", "");
    2929
     30    add("--wait", "wait", "",
     31            "Wait at the Welcome screen for the user before connecting.",
     32            "Stop at the welcome screen before connecting to "
     33            "database or backend.\nWait for the user to select "
     34            "the Startup button to start frontend.")
     35            ->SetGroup("Startup Behavior");
    3036    add("--jumppoint", "jumppoint", "",
    3137        "Start the frontend at specified jump point.", "")
    3238            ->SetGroup("Startup Behavior");
  • mythtv/programs/mythfrontend/main.cpp

    diff --git a/mythtv/programs/mythfrontend/main.cpp b/mythtv/programs/mythfrontend/main.cpp
    index f3b1741..9eee926 100644
    a b int main(int argc, char **argv) 
    17661766{
    17671767    bool bPromptForBackend    = false;
    17681768    bool bBypassAutoDiscovery = false;
     1769    bool bWaitBeforeConnect = false;
    17691770
    17701771#if CONFIG_OMX_RPI
    17711772    setenv("QT_XCB_GL_INTEGRATION","none",0);
    int main(int argc, char **argv) 
    18551856        bPromptForBackend = true;
    18561857    if (cmdline.toBool("noautodiscovery"))
    18571858        bBypassAutoDiscovery = true;
     1859    if (cmdline.toBool("wait"))
     1860        bWaitBeforeConnect = true;
    18581861
    18591862    if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
    18601863        cerr << "Unable to ignore SIGPIPE\n";
    int main(int argc, char **argv) 
    18721875    gContext = new MythContext(MYTH_BINARY_VERSION, true);
    18731876    gCoreContext->SetAsFrontend(true);
    18741877
    1875     if (!gContext->Init(true, bPromptForBackend, bBypassAutoDiscovery))
     1878    if (!gContext->Init(true, bPromptForBackend, bBypassAutoDiscovery, false, bWaitBeforeConnect))
    18761879    {
    18771880        LOG(VB_GENERAL, LOG_ERR, "Failed to init MythContext, exiting.");
    18781881        return GENERIC_EXIT_NO_MYTHCONTEXT;
  • mythtv/themes/default/config-ui.xml

    diff --git a/mythtv/themes/default/config-ui.xml b/mythtv/themes/default/config-ui.xml
    index 61b4589..8b183a1 100644
    a b  
    897897                    <value>Unable to connect to master backend.</value>
    898898                </textarea>
    899899            </state>
     900            <state name="wait" from="start">
     901                <textarea name="status">
     902                    <value>Select Start to open MythFrontend.</value>
     903                </textarea>
     904            </state>
    900905        </statetype>
    901906
    902907        <statetype name="messagestate">
     
    945950        <button name="retry" from="basebutton">
    946951            <position>5%,88%</position>
    947952            <value>Retry</value>
    948             <helptext>Try again to establish connections.</helptext>
     953            <helptext>Establish connections and continue to startup.</helptext>
    949954        </button>
    950955
    951956        <button name="search" from="retry">