Ticket #3497: fix-autostart-detection.diff

File fix-autostart-detection.diff, 2.6 KB (added by matt.doran@…, 17 years ago)
  • scheduler.h

     
    103103                             bool &blockShutdown);
    104104    void ShutdownServer(int prerollseconds);
    105105
     106    bool WasStartedAutomatically();
     107
    106108    void FillRecordingDir(ProgramInfo *pginfo, RecList& reclist);
    107109    void FillDirectoryInfoCache(bool force = false);
    108110
  • scheduler.cpp

     
    13471347                QString startupParam = "user";
    13481348               
    13491349                // have we been started automatically?
    1350                 if ((startIter != reclist.end()) &&
    1351                     ((curtime.secsTo((*startIter)->startts) - prerollseconds)
    1352                         < (idleWaitForRecordingTime * 60)))
     1350                if (WasStartedAutomatically() ||
     1351                    ((startIter != reclist.end()) &&
     1352                     ((curtime.secsTo((*startIter)->startts) - prerollseconds)
     1353                        < (idleWaitForRecordingTime * 60))))
    13531354                {
    1354                     VERBOSE(VB_IMPORTANT,
    1355                             "Recording starts soon, AUTO-Startup assumed");
     1355                    VERBOSE(VB_IMPORTANT, "AUTO-Startup assumed");
    13561356                    startupParam = "auto";
    13571357           
    13581358                    // Since we've started automatically, don't wait for
     
    31423142    fsInfoCacheFillTime = QDateTime::currentDateTime();
    31433143}
    31443144
     3145bool Scheduler::WasStartedAutomatically() {
     3146    /* Determines if the system was started automatically by the auto-wakeup process */
     3147
     3148    bool autoStart = false;
     3149
     3150    QDateTime startupTime = QDateTime();
     3151    QString s = gContext->GetSetting("MythShutdownWakeupTime", "");
     3152    if (s != "")
     3153        startupTime = QDateTime::fromString(s, Qt::ISODate);
     3154
     3155    // if we don't have a valid startup time assume we were started manually
     3156    if (startupTime.isValid())
     3157    {
     3158        // if we started within 15mins of the saved wakeup time assume we started
     3159        // automatically to record or for a daily wakeup/shutdown period
     3160
     3161        int delta = startupTime.secsTo(QDateTime::currentDateTime());
     3162        if (delta < 0)
     3163            delta = -delta;
     3164
     3165        if (delta < 15 * 60)
     3166        {
     3167            VERBOSE(VB_SCHEDULE, "Close to auto-start time, AUTO-Startup assumed");
     3168            autoStart = true;
     3169        }
     3170    }
     3171
     3172    return autoStart;
     3173}
     3174
    31453175/* vim: set expandtab tabstop=4 shiftwidth=4: */