Ticket #3788: expire_not_delete.2.diff

File expire_not_delete.2.diff, 13.8 KB (added by skamithi, 17 years ago)
  • mythplugins/mythweb/modules/_shared/lang/English.lang

     
    171171"Delete and allow rerecord: $1"
    172172"Delete and rerecord $1"
    173173"DELETE this Saved Playlist"
     174"Undelete"
    174175"description"
    175176"Description"
    176177"Destination"
  • mythplugins/mythweb/modules/tv/tmpl/default/recorded.php

     
    341341        <a onclick="javascript:confirm_delete(<?php echo $row ?>, true)"
    342342            title="<?php echo html_entities(t('Delete and allow rerecord: $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
    343343            ><?php echo t('Delete + Rerecord') ?></a>
     344
     345<?php       if ($show->recgroup == 'Deleted') {
     346                echo '<a href="', root, 'tv/recorded?undelete=yes&chanid=', $show->chanid,
     347                    '&starttime=', $show->starttime, '" ' ?>
     348                title="<?php echo html_entities(t('Undelete: $1', preg_replace('/: $/', '', $show->title.': '.$show->subtitle))) ?>"
     349                <?php echo '>' , t('Undelete') ?></a>
     350<?php       } ?>
    344351<?php   } ?>
    345352        </td>
    346353</tr><tr id="statusrow_<?php echo $row ?>" class="recorded">
  • mythplugins/mythweb/modules/tv/recorded.php

     
    1919// Load the sorting routines
    2020    require_once 'includes/sorting.php';
    2121
    22 // Delete a program?
     22// Delete or undelete a program?
    2323    isset($_GET['forget_old']) or $_GET['forget_old'] = $_POST['forget_old'];
    2424    isset($_GET['delete'])     or $_GET['delete']     = $_POST['delete'];
    2525    isset($_GET['file'])       or $_GET['file']       = $_POST['file'];
    26     if ($_GET['delete']) {
     26    if ($_GET['delete'] || $_GET['undelete']) {
     27        if ($_GET['delete'])
     28          $backendstr = 'DELETE_RECORDING';
     29        else
     30          $backendstr = 'UNDELETE_RECORDING';
    2731    // Keep a previous-row counter to return to after deleting
    2832        $prev_row = -2;
    2933    // We need to scan through the available recordings to get at the additional information required by the DELETE_RECORDING query
     
    3539            if ($row[4] != $_GET['chanid'] || $row[26] != $_GET['starttime'])
    3640                continue;
    3741        // Delete the recording
    38             backend_command(array('FORCE_DELETE_RECORDING', implode(backend_sep, $row), '0'));
     42            backend_command(array($backendstr, implode(backend_sep, $row), '0'));
    3943        // Forget all knowledge of old recordings?
    4044            if (isset($_GET['forget_old'])) {
    4145                backend_command(array('FORGET_RECORDING', implode(backend_sep, $row), '0'));
     
    105109        // keep track of their names and how many episodes we have recorded
    106110            $Total_Programs++;
    107111            $Groups[$record[30]]++;
    108         // Hide LiveTV recordings from the title list
    109             if (($_GET['recgroup'] && $_GET['recgroup'] == $record[30]) || (!$_GET['recgroup'] && $record[30] != 'LiveTV'))
     112        // Hide LiveTV  and Deleted recordings from the title list
     113            if (($_GET['recgroup'] && $_GET['recgroup'] == $record[30]) || (!$_GET['recgroup'] && $record[30] != 'LiveTV' && $record[30] != 'Deleted'))
    110114                $Program_Titles[$record[0]]++;
    111115        // Skip files with no chanid
    112116            if (!$record[4])
     
    116120                continue;
    117121            if ($_GET['recgroup'] && $_GET['recgroup'] != $record[30])
    118122                continue;
    119         // Hide livetv recordings from the default view
    120             if (empty($_GET['recgroup']) && $record[30] == 'LiveTV')
     123        // Hide LiveTV recordings from the default view
     124            if (empty($_GET['recgroup']) && ($record[30] == 'LiveTV' || $record[30] == 'Deleted'))
    121125                continue;
    122126        // Make sure that everything we're dealing with is an array
    123127            if (!is_array($Programs[$record[0]]))
  • mythtv/libs/libmythtv/remoteutil.h

     
    3939bool RemoteDeleteRecording(ProgramInfo *pginfo, bool forgetHistory,
    4040                           bool forceMetadataDelete = false);
    4141MPUBLIC
     42bool RemoteUndeleteRecording(ProgramInfo *pginfo);
     43MPUBLIC
    4244void RemoteGetAllScheduledRecordings(vector<ProgramInfo *> &scheduledlist);
    4345MPUBLIC
    4446void RemoteGetAllExpiringRecordings(vector<ProgramInfo *> &expiringlist);
  • mythtv/libs/libmythtv/tv.h

     
    5050    kState_ChangingState,
    5151} TVState;
    5252
    53 const int kLiveTVAutoExpire = 10000;
    54 
    5553QString StateToString(TVState state);
    5654
    5755typedef enum PictureAdjustType
  • mythtv/libs/libmythtv/programinfo.h

     
    118118    wlExpireOff = -1
    119119};
    120120
     121enum AutoExpireType {
     122    kDisableAutoExpire = 0,
     123    kNormalAutoExpire  = 1,
     124    kDeletedAutoExpire = 9999,
     125    kLiveTVAutoExpire = 10000
     126};
     127
    121128class ScheduledRecording;
    122129class QGridLayout;
    123130
  • mythtv/libs/libmythtv/remoteutil.cpp

     
    164164    return result;
    165165}
    166166
     167bool RemoteUndeleteRecording(ProgramInfo *pginfo)
     168{
     169    bool result = false;
     170
     171    bool undelete_possible =
     172            gContext->GetNumSetting("AutoExpireInsteadOfDelete", 0);
     173
     174    if (!undelete_possible)
     175        return result;
     176
     177    QStringList strlist;
     178
     179    strlist = QString("UNDELETE_RECORDING");
     180    pginfo->ToStringList(strlist);
     181
     182    gContext->SendReceiveStringList(strlist);
     183
     184    if (strlist[0].toInt() == 0)
     185        result = true;
     186
     187    return result;
     188}
     189
    167190void RemoteGetAllScheduledRecordings(vector<ProgramInfo *> &scheduledlist)
    168191{
    169192    QStringList strList = QString("QUERY_GETALLSCHEDULED");
  • mythtv/programs/mythfrontend/playbackbox.cpp

     
    16641664            p = *i;
    16651665            if ((((p->recgroup == recGroup) ||
    16661666                  ((recGroup == "All Programs") &&
     1667                   (p->recgroup != "Deleted") &&
    16671668                   (p->recgroup != "LiveTV" || LiveTVInAllPrograms))) &&
    16681669                 (recGroupPassword == curGroupPassword)) ||
    16691670                ((recGroupType[recGroup] == "category") &&
     
    23012302    if (!curitem)
    23022303        return;
    23032304
    2304     if ((curitem->availableStatus != asPendingDelete) &&
     2305    bool undelete_possible =
     2306            gContext->GetNumSetting("AutoExpireInsteadOfDelete", 0);
     2307
     2308    if (curitem->recgroup != "Deleted" && undelete_possible)
     2309        doRemove(curitem, false, false);
     2310    else if ((curitem->availableStatus != asPendingDelete) &&
    23052311        (REC_CAN_BE_DELETED(curitem)))
    23062312        remove(curitem);
    23072313    else
     
    31713177    popup->addButton(tr("Job Options"), this, SLOT(showJobPopup()));
    31723178
    31733179    if (!(m_player && m_player->IsSameProgram(curitem)))
    3174         popup->addButton(tr("Delete"), this, SLOT(askDelete()));
     3180    {
     3181        if (curitem->recgroup == "Deleted")
     3182        {
     3183            popup->addButton(tr("Undelete"), this,
     3184                        SLOT(doUndelete()));
     3185            popup->addButton(tr("Delete"), this,
     3186                        SLOT(doDelete()));
     3187        }
     3188        else
     3189        {
     3190            bool can_undelete =
     3191                    gContext->GetNumSetting("AutoExpireInsteadOfDelete", 0);
     3192            if (can_undelete)
     3193            {
     3194                popup->addButton(tr("Mark for Deletion"), this,
     3195                                    SLOT(doDelete()));
     3196            }
     3197            else
     3198            {
     3199                popup->addButton(tr("Delete"), this,
     3200                                SLOT(askDelete()));
     3201            }
     3202        }
     3203    }
    31753204
    31763205    popup->ShowPopup(this, SLOT(doCancel()));
    31773206
     
    35173546    playList.clear();
    35183547}
    35193548
     3549void PlaybackBox::doUndelete(void)
     3550{
     3551    if (!expectingPopup)
     3552    {
     3553        previewSuspend = false;
     3554        return;
     3555    }
     3556
     3557    cancelPopup();
     3558    RemoteUndeleteRecording(curitem);
     3559}
     3560
    35203561void PlaybackBox::doDelete(void)
    35213562{
    35223563    if (!expectingPopup)
  • mythtv/programs/mythfrontend/globalsettings.cpp

     
    576576    return bs;
    577577};
    578578
     579static GlobalCheckBox *AutoExpireInsteadOfDelete()
     580{
     581    GlobalCheckBox *cb = new GlobalCheckBox("AutoExpireInsteadOfDelete", 0);
     582    cb->setLabel(QObject::tr("Auto Expire Instead of Delete Recording"));
     583    cb->setValue(false);
     584    cb->setHelpText(QObject::tr("Instead of deleting a recording, "
     585                                "move recording to the 'Deleted' recgroup "
     586                                "and turn on autoexpire."));
     587    return cb;
     588}
     589
    579590static GlobalComboBox *AutoExpireMethod()
    580591{
    581592    GlobalComboBox *bc = new GlobalComboBox("AutoExpireMethod");
     
    37673778    autoexp->addChild(AutoExpireLiveTVMaxAge());
    37683779    autoexp->addChild(RerecordWatched());
    37693780    autoexp->addChild(AutoExpireExtraSpace());
     3781    autoexp->addChild(AutoExpireInsteadOfDelete());
    37703782    addChild(autoexp);
    37713783
    37723784    VerticalConfigurationGroup* jobs = new VerticalConfigurationGroup(false);
  • mythtv/programs/mythfrontend/playbackbox.h

     
    160160    void doEditScheduled();
    161161
    162162    void askDelete();
     163    void doUndelete();
    163164    void doDelete();
    164165    void doDeleteForgetHistory();
    165166    void doForceDelete();
  • mythtv/programs/mythbackend/mainserver.h

     
    8080                               bool forceMetadataDelete);
    8181    void DoHandleDeleteRecording(ProgramInfo *pginfo, PlaybackSock *pbs,
    8282                                 bool forceMetadataDelete);
     83    void HandleUndeleteRecording(QStringList &slist, PlaybackSock *pbs);
     84    void DoHandleUndeleteRecording(ProgramInfo *pginfo, PlaybackSock *pbs);
    8385    void HandleForgetRecording(QStringList &slist, PlaybackSock *pbs);
    8486    void HandleRescheduleRecordings(int recordid, PlaybackSock *pbs);
    8587    void HandleQueryFreeSpace(PlaybackSock *pbs, bool allBackends);
  • mythtv/programs/mythbackend/mainserver.cpp

     
    396396    {
    397397        HandleDeleteRecording(listline, pbs, true);
    398398    }
     399    else if (command == "UNDELETE_RECORDING")
     400    {
     401        HandleUndeleteRecording(listline, pbs);
     402    }
    399403    else if (command == "RESCHEDULE_RECORDINGS")
    400404    {
    401405        if (tokens.size() != 2)
     
    19161920    if (pbs)
    19171921        pbssock = pbs->getSocket();
    19181922
     1923    bool justexpire =
     1924            (gContext->GetNumSetting("AutoExpireInsteadOfDelete", 0) &&
     1925            (pginfo->recgroup != "Deleted") && (pginfo->recgroup != "LiveTV"));
     1926
     1927    if (justexpire && !forceMetadataDelete)
     1928    {
     1929        pginfo->ApplyRecordRecGroupChange("Deleted");
     1930        pginfo->SetAutoExpire(kDeletedAutoExpire);
     1931        if (pginfo->recstatus == rsRecording)
     1932            DoHandleStopRecording(pginfo, pbs);
     1933        else
     1934            delete pginfo;
     1935        QStringList outputlist = QString::number(0);
     1936        SendResponse(pbssock, outputlist);
     1937        MythEvent me("RECORDING_LIST_CHANGE");
     1938        gContext->dispatch(me);
     1939        return;
     1940    }
     1941
    19191942    QString filename = pginfo->GetPlaybackURL();
    19201943
    19211944    // If this recording was made by a another recorder, and that
     
    20382061    delete pginfo;
    20392062}
    20402063
     2064void MainServer::HandleUndeleteRecording(QStringList &slist, PlaybackSock *pbs)
     2065{
     2066    ProgramInfo *pginfo  = new ProgramInfo();
     2067    pginfo->FromStringList(slist, 1);
     2068
     2069    DoHandleUndeleteRecording(pginfo, pbs);
     2070}
     2071
     2072void MainServer::DoHandleUndeleteRecording(ProgramInfo *pginfo, PlaybackSock *pbs)
     2073{
     2074    bool ret = -1;
     2075    bool undelete_possible =
     2076            gContext->GetNumSetting("AutoExpireInsteadOfDelete", 0);
     2077    MythSocket *pbssock = NULL;
     2078    if (pbs)
     2079        pbssock = pbs->getSocket();
     2080
     2081    if (undelete_possible)
     2082    {
     2083        pginfo->ApplyRecordRecGroupChange("Default");
     2084        pginfo->UpdateLastDelete(false);
     2085        pginfo->SetAutoExpire(kDisableAutoExpire);
     2086        delete pginfo;
     2087        ret = 0;
     2088        MythEvent me("RECORDING_LIST_CHANGE");
     2089        gContext->dispatch(me);
     2090    }
     2091
     2092    QStringList outputlist = QString::number(ret);
     2093    SendResponse(pbssock, outputlist);
     2094}
     2095
    20412096void MainServer::HandleRescheduleRecordings(int recordid, PlaybackSock *pbs)
    20422097{
    20432098    QStringList result;