Ticket #3788: expire_not_delete.diff

File expire_not_delete.diff, 11.9 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/remoteutil.cpp

     
    164164    return result;
    165165}
    166166
     167bool RemoteUndeleteRecording(ProgramInfo *pginfo)
     168{
     169    bool result = false;
     170
     171    bool undelete_possible = gContext->GetNumSetting("AutoExpireInsteadOfDelete");
     172    if (!undelete_possible)
     173        return result;
     174
     175    QStringList strlist;
     176
     177    strlist = QString("UNDELETE_RECORDING");
     178    pginfo->ToStringList(strlist);
     179
     180    gContext->SendReceiveStringList(strlist);
     181
     182    if (strlist[0].toInt() == 0)
     183        result = true;
     184
     185    return result;
     186}
     187
    167188void RemoteGetAllScheduledRecordings(vector<ProgramInfo *> &scheduledlist)
    168189{
    169190    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 != "LiveTV" || LiveTVInAllPrograms))) &&
     1667                   ((p->recgroup != "LiveTV" && p->recgroup != "Deleted")
     1668                    || LiveTVInAllPrograms))) &&
    16681669                 (recGroupPassword == curGroupPassword)) ||
    16691670                ((recGroupType[recGroup] == "category") &&
    16701671                 ((p->category == recGroup ) ||
     
    31593160        popup->addButton(tr("Stop Recording"), this, SLOT(askStop()));
    31603161    }
    31613162
     3163    if (program->recgroup == "Deleted")
     3164        popup->addButton(tr("Undelete"), this,
     3165                        SLOT(doUndelete()));
     3166
    31623167    if (curitem->programflags & FL_WATCHED)
    31633168        popup->addButton(tr("Mark as Unwatched"), this,
    31643169                                    SLOT(setUnwatched()));
     
    35173522    playList.clear();
    35183523}
    35193524
     3525void PlaybackBox::doUndelete(void)
     3526{
     3527    if (!expectingPopup)
     3528    {
     3529        previewSuspend = false;
     3530        return;
     3531    }
     3532
     3533    cancelPopup();
     3534    RemoteUndeleteRecording(curitem);
     3535}
     3536
    35203537void PlaybackBox::doDelete(void)
    35213538{
    35223539    if (!expectingPopup)
  • mythtv/programs/mythfrontend/globalsettings.cpp

     
    576576    return bs;
    577577};
    578578
     579static GlobalCheckBox *AutoExpireInsteadOfDelete()
     580{
     581    GlobalCheckBox *cb = new GlobalCheckBox("AutoExpireInsteadOfDelete");
     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");
     
    37363747    autoexp->addChild(AutoExpireLiveTVMaxAge());
    37373748    autoexp->addChild(RerecordWatched());
    37383749    autoexp->addChild(AutoExpireExtraSpace());
     3750    autoexp->addChild(AutoExpireInsteadOfDelete());
    37393751    addChild(autoexp);
    37403752
    37413753    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") &&
     1925            (pginfo->recgroup != "Deleted") && (pginfo->recgroup != "LiveTV"));
     1926
     1927    if (justexpire && !forceMetadataDelete)
     1928    {
     1929        pginfo->ApplyRecordRecGroupChange("Deleted");
     1930        pginfo->SetAutoExpire(1);
     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 = gContext->GetNumSetting("AutoExpireInsteadOfDelete");
     2076    MythSocket *pbssock = NULL;
     2077    if (pbs)
     2078        pbssock = pbs->getSocket();
     2079
     2080    if (undelete_possible)
     2081    {
     2082        pginfo->ApplyRecordRecGroupChange("Default");
     2083        pginfo->UpdateLastDelete(false);
     2084        delete pginfo;
     2085        ret = 0;
     2086        MythEvent me("RECORDING_LIST_CHANGE");
     2087        gContext->dispatch(me);
     2088    }
     2089
     2090    QStringList outputlist = QString::number(ret);
     2091    SendResponse(pbssock, outputlist);
     2092}
     2093
    20412094void MainServer::HandleRescheduleRecordings(int recordid, PlaybackSock *pbs)
    20422095{
    20432096    QStringList result;