Ticket #3842: 3842-fixes-v2.patch

File 3842-fixes-v2.patch, 15.8 KB (added by danielk, 17 years ago)

Untested patch which adds program id updates to 0.20-fixes patch

  • libs/libmythtv/videosource.h

     
    1111class SignalTimeout;
    1212class ChannelTimeout;
    1313class UseEIT;
     14class VideoSource;
    1415
    15 class VideoSource;
     16static inline bool is_grabber_external(const QString &grabber)
     17{
     18    return !(grabber == "datadirect" ||
     19             grabber == "eitonly" ||
     20             grabber == "schedulesdirect1" ||
     21             grabber == "/bin/true");
     22}
     23
     24static inline bool is_grabber_datadirect(const QString &grabber)
     25{
     26    return (grabber == "datadirect") || (grabber == "schedulesdirect1");
     27}
     28
     29static inline bool is_grabber_labs(const QString &grabber)
     30{
     31    return grabber == "datadirect";
     32}
     33
    1634class VSSetting: public SimpleDBStorage {
    1735protected:
    1836    VSSetting(const VideoSource& _parent, QString name):
     
    6280{
    6381    Q_OBJECT
    6482  public:
    65     DataDirect_config(const VideoSource& _parent, int _source = DD_ZAP2IT);
     83    DataDirect_config(const VideoSource& _parent, int _ddsource);
    6684
    6785    virtual void load(void);
    6886
  • libs/libmythtv/dbcheck.cpp

     
    88
    99#include "mythcontext.h"
    1010#include "mythdbcon.h"
     11#include "datadirect.h" // for DataDirectProcessor::FixProgramIDs
    1112
    1213/// This is the DB schema version expected by the running MythTV instance.
    1314const QString currentDatabaseVersion = "1160";
     
    464465
    465466    bool ret = doUpgradeTVDatabaseSchema();
    466467
     468    if (!gContext->GetNumSetting("MythFillFixProgramIDsHasRunOnce", 0))
     469        DataDirectProcessor::FixProgramIDs();
     470
    467471    if (ret)
    468472        VERBOSE(VB_IMPORTANT, "Database Schema upgrade complete, unlocking.");
    469473    else
  • libs/libmythtv/datadirect.h

     
    1111
    1212enum DD_PROVIDERS
    1313{
    14     DD_ZAP2IT = 0,
    15     DD_PROVIDER_COUNT,
     14    DD_ZAP2IT           = 0,
     15    DD_SCHEDULES_DIRECT = 1,
     16    DD_PROVIDER_COUNT   = 2,
    1617};
    1718
    1819class DataDirectURLs
     
    315316    static int  UpdateChannelsSafe(uint sourceid, bool insert_channels);
    316317    static bool UpdateChannelsUnsafe(uint sourceid);
    317318
     319    // static command, makes Labs and Schedules Direct ProgramIDs compatible.
     320    static void FixProgramIDs(void);
     321
    318322  private:
    319323    void CreateTempTables(void);
    320324    void CreateATempTable(const QString &ptablename,
  • libs/libmythtv/datadirect.cpp

     
    542542        "http://datadirect.webservices.zap2it.com/tvlistings/xtvdService",
    543543        "http://labs.zap2it.com",
    544544        "/ztvws/ztvws_login/1,1059,TMS01-1,00.html");
     545    DataDirectURLs urls1(
     546        "Schedules Direct",
     547        "http://webservices.schedulesdirect.tmsdatadirect.com"
     548        "/schedulesdirect/tvlistings/xtvdService",
     549        "http://schedulesdirect.org",
     550        "/login/index.php");
    545551    providers.push_back(urls0);
     552    providers.push_back(urls1);
    546553
    547554    QString tmpDir = "/tmp";
    548555    tmpPostFile   = makeTempFile(tmpDir + "/mythtv_post_XXXXXX");
     
    723730    return true;
    724731}
    725732
     733void DataDirectProcessor::FixProgramIDs(void)
     734{
     735    VERBOSE(VB_GENERAL, "DataDirectProcessor::FixProgramIDs() -- begin");
     736
     737    MSqlQuery query(MSqlQuery::DDCon());
     738    query.prepare(
     739        "UPDATE recorded "
     740        "SET programid=CONCAT(SUBSTRING(programid, 1, 2), "
     741        "                     '00', SUBSTRING(programid, 3)) "
     742        "WHERE length(programid) = 12");
     743
     744    if (!query.exec())
     745    {
     746        MythContext::DBError("Fixing program ids in recorded", query);
     747        return;
     748    }
     749
     750    query.prepare(
     751        "UPDATE oldrecorded "
     752        "SET programid=CONCAT(SUBSTRING(programid, 1, 2), "
     753        "                     '00', SUBSTRING(programid, 3)) "
     754        "WHERE length(programid) = 12");
     755
     756    if (!query.exec())
     757    {
     758        MythContext::DBError("Fixing program ids in oldrecorded", query);
     759        return;
     760    }
     761
     762    gContext->SetSetting("MythFillFixProgramIDsHasRunOnce", "1");
     763
     764    VERBOSE(VB_GENERAL, "DataDirectProcessor::FixProgramIDs() -- end");
     765}
     766
    726767FILE *DataDirectProcessor::DDPost(
    727768    QString    ddurl,
    728769    QString    postFilename, QString    inputFile,
     
    10181059        "  channelMinor char(3) )";
    10191060
    10201061    dd_tables["dd_schedule"] =
    1021         "( programid char(12),           stationid char(12), "
     1062        "( programid char(40),           stationid char(12), "
    10221063        "  scheduletime datetime,        duration time,      "
    10231064        "  isrepeat bool,                stereo bool,        "
    10241065        "  subtitled bool,               hdtv bool,          "
     
    10281069        "INDEX progidx (programid) )";
    10291070
    10301071    dd_tables["dd_program"] =
    1031         "( programid char(12) NOT NULL,  seriesid char(12),     "
     1072        "( programid char(40) NOT NULL,  seriesid char(12),     "
    10321073        "  title varchar(120),           subtitle varchar(150), "
    10331074        "  description text,             mpaarating char(5),    "
    10341075        "  starrating char(5),           runtime time,          "
     
    10501091        "  partnumber int,               parttotal int,               "
    10511092        "  seriesid char(12),            originalairdate date,        "
    10521093        "  showtype varchar(30),         colorcode varchar(20),       "
    1053         "  syndicatedepisodenumber varchar(20), programid char(12),   "
     1094        "  syndicatedepisodenumber varchar(20), programid char(40),   "
    10541095        "  tvrating char(5),             mpaarating char(5),          "
    10551096        "INDEX progidx (programid))";
    10561097
    10571098    dd_tables["dd_productioncrew"] =
    1058         "( programid char(12),           role char(30),    "
     1099        "( programid char(40),           role char(30),    "
    10591100        "  givenname char(20),           surname char(20), "
    10601101        "  fullname char(41), "
    10611102        "INDEX progidx (programid), "
    10621103        "INDEX nameidx (fullname))";
    10631104
    10641105    dd_tables["dd_genre"] =
    1065         "( programid char(12) NOT NULL,  class char(30), "
     1106        "( programid char(40) NOT NULL,  class char(30), "
    10661107        "  relevance char(1), "
    10671108        "INDEX progidx (programid))";
    10681109
  • libs/libmythtv/videosource.cpp

     
    1919#include <qmap.h>
    2020#include <qdir.h>
    2121#include <qprocess.h>
     22#include <qdatetime.h>
    2223
    2324// MythTV headers
    2425#include "mythconfig.h"
     
    148149class DataDirectPassword: public LineEditSetting, public VSSetting {
    149150  public:
    150151    DataDirectPassword(const VideoSource& parent):
    151         VSSetting(parent, "password") {
     152        VSSetting(parent, "password")
     153    {
     154        SetPasswordEcho(true);
    152155        setLabel(QObject::tr("Password"));
    153156    };
    154157};
     
    159162{
    160163    (void) uid;
    161164    (void) pwd;
    162     (void) _source;
    163165#ifdef USING_BACKEND
    164166    if (uid.isEmpty() || pwd.isEmpty())
    165167        return;
     
    200202void DataDirect_config::load()
    201203{
    202204    VerticalConfigurationGroup::load();
    203     if ((userid->getValue() != lastloadeduserid) ||
    204         (password->getValue() != lastloadedpassword))
     205    bool is_sd_userid = userid->getValue().contains("@") > 0;
     206    bool match = ((is_sd_userid  && (source == DD_SCHEDULES_DIRECT)) ||
     207                  (!is_sd_userid && (source == DD_ZAP2IT)));
     208    if (((userid->getValue() != lastloadeduserid) ||
     209         (password->getValue() != lastloadedpassword)) && match)
    205210    {
    206211        lineupselector->fillSelections(userid->getValue(),
    207212                                       password->getValue(),
     
    296301        "instead of just 'mythfilldatabase'.\nYour grabber does not provide "
    297302        "channel numbers, so you have to set them manually.");
    298303
    299     if (grabber != "datadirect" && grabber != "eitonly" &&
    300         grabber != "/bin/true")
     304    if (is_grabber_external(grabber))
    301305    {
    302306        VERBOSE(VB_IMPORTANT, "\n" << err_msg);
    303307        MythPopupBox::showOkPopup(
     
    365369    // only save settings for the selected grabber
    366370    setSaveAll(false);
    367371
    368     addTarget("datadirect", new DataDirect_config(parent));
    369     grabber->addSelection("North America (DataDirect) (Internal)", "datadirect");
     372    addTarget("schedulesdirect1",
     373              new DataDirect_config(parent, DD_SCHEDULES_DIRECT));
     374    grabber->addSelection("North America (SchedulesDirect.org) "
     375                          "(Internal)", "schedulesdirect1");
    370376
     377#if 1
     378    addTarget("datadirect", new DataDirect_config(parent, DD_ZAP2IT));
     379    grabber->addSelection(
     380        "North America (TMS Labs) (Internal)", "datadirect");
     381#endif
     382
    371383    addTarget("eitonly", new EITOnly_config(parent));
    372384    grabber->addSelection("Transmitted guide only (EIT)", "eitonly");
    373385
  • libs/libmyth/settings.cpp

     
    494494        connect(edit, SIGNAL(changeHelpText(QString)), cg,
    495495                SIGNAL(changeHelpText(QString)));
    496496
    497     edit->setRW(rw);
     497    setRW(rw);
     498    SetPasswordEcho(password_echo);
    498499
    499500    return widget;
    500501}
     
    519520    }
    520521}
    521522
     523void LineEditSetting::SetPasswordEcho(bool b)
     524{
     525    password_echo = b;
     526    if (edit)
     527        edit->setEchoMode(b ? QLineEdit::Password : QLineEdit::Normal);
     528}
     529
    522530QWidget* SliderSetting::configWidget(ConfigurationGroup *cg, QWidget* parent,
    523531                                     const char* widgetName) {
    524532    QHBox* widget;
  • libs/libmyth/mythcontext.h

     
    224224
    225225/// Update this whenever the plug-in API changes.
    226226/// Including changes in the libmythtv class methods used by plug-ins.
    227 #define MYTH_BINARY_VERSION "0.20.20060828-4"
     227#define MYTH_BINARY_VERSION "0.20.20070818-1"
    228228
    229229/** \brief Increment this whenever the MythTV network protocol changes.
    230230 *
  • libs/libmyth/settings.h

     
    276276
    277277class LineEditSetting: virtual public Setting {
    278278protected:
    279     LineEditSetting(bool readwrite = true) : edit(NULL) { rw = readwrite; };
     279    LineEditSetting(bool readwrite = true) :
     280        edit(NULL), rw(readwrite),  password_echo(false) { }
    280281public:
    281282    virtual QWidget* configWidget(ConfigurationGroup *cg, QWidget* parent,
    282283                                  const char* widgetName = 0);
     
    292293
    293294    virtual void setEnabled(bool b);
    294295    virtual void setVisible(bool b);
     296    virtual void SetPasswordEcho(bool b);
    295297
    296298private:
    297299    MythLineEdit* edit;
    298300    bool rw;
     301    bool password_echo;
    299302};
    300303
    301304// TODO: set things up so that setting the value as a string emits
  • programs/mythfilldatabase/filldata.cpp

     
    4040#include "cardutil.h"
    4141#include "sourceutil.h"
    4242#include "remoteutil.h"
     43#include "videosource.h" // for is_grabber..
    4344
    4445using namespace std;
    4546
     
    852853        UpdateSourceIcons(source.id);
    853854
    854855    // Unselect channels not in users lineup for DVB, HDTV
    855     if (!insert_channels && (new_channels > 0))
     856    if (!insert_channels && (new_channels > 0) &&
     857        is_grabber_labs(source.xmltvgrabber))
    856858    {
    857859        bool ok0 = (logged_in == source.userid);
    858860        bool ok1 = (raw_lineup == source.id);
     
    877879
    878880bool DataDirectUpdateChannels(Source source)
    879881{
     882    if (!is_grabber_labs(source.xmltvgrabber))
     883    {
     884        VERBOSE(VB_IMPORTANT, "FillData: We only support "
     885                "DataDirectUpdateChannels with TMS Labs channel editor");
     886        return false;
     887    }
     888
    880889    ddprocessor.SetListingsProvider(DD_ZAP2IT);
    881890    ddprocessor.SetUserID(source.userid);
    882891    ddprocessor.SetPassword(source.password);
     
    25312540
    25322541    if (xmltv_grabber == "datadirect")
    25332542        return grabDDData(source, offset, *qCurrentDate, DD_ZAP2IT);
     2543    else if (xmltv_grabber == "schedulesdirect1")
     2544        return grabDDData(source, offset, *qCurrentDate, DD_SCHEDULES_DIRECT);
    25342545    else if (xmltv_grabber == "technovera")
    25352546    {
    25362547        VERBOSE(VB_ALL, "This grabber is no longer supported");
     
    28572868                                  .arg((*it).xmltvgrabber));
    28582869
    28592870        QString xmltv_grabber = (*it).xmltvgrabber;
    2860         need_post_grab_proc |= (xmltv_grabber != "datadirect");
     2871        need_post_grab_proc |= !is_grabber_datadirect(xmltv_grabber);
    28612872
    28622873        if (xmltv_grabber == "tv_grab_uk" || xmltv_grabber == "tv_grab_uk_rt" ||
    28632874            xmltv_grabber == "tv_grab_fi" || xmltv_grabber == "tv_grab_es" ||
     
    28722883            if (!grabData(*it, 0))
    28732884                ++failures;
    28742885        }
    2875         else if ((xmltv_grabber == "datadirect") && dd_grab_all)
     2886        else if (is_grabber_labs(xmltv_grabber) && dd_grab_all)
    28762887        {
    28772888            if (only_update_channels)
    28782889                DataDirectUpdateChannels(*it);
     
    28822893                grabData(*it, 0, &qCurrentDate);
    28832894            }
    28842895        }
    2885         else if (xmltv_grabber == "datadirect" ||
     2896        else if (is_grabber_datadirect(xmltv_grabber) ||
    28862897                 xmltv_grabber == "tv_grab_se_swedb" ||
    28872898                 xmltv_grabber == "tv_grab_no" ||
    28882899                 xmltv_grabber == "tv_grab_de_tvtoday" ||
     
    29062917            // often decided by the person maintaining the grabbers.
    29072918            if (maxDays > 0) // passed with --max-days
    29082919                grabdays = maxDays;
    2909             else if (xmltv_grabber == "datadirect")
     2920            else if (is_grabber_datadirect(xmltv_grabber))
    29102921                grabdays = 14;
    29112922            else if (xmltv_grabber == "tv_grab_se_swedb")
    29122923                grabdays = 10;
     
    29222933            if (grabdays == 1)
    29232934                refresh_today = true;
    29242935
    2925             if ((xmltv_grabber == "datadirect") && only_update_channels)
     2936            if (is_grabber_labs(xmltv_grabber) && only_update_channels)
    29262937            {
    29272938                DataDirectUpdateChannels(*it);
    29282939                grabdays = 0;
     
    33303341    int fromxawfile_id = 1;
    33313342    QString fromxawfile_name;
    33323343
    3333     bool usingDataDirect = false;
     3344    bool usingDataDirect = false, usingDataDirectLabs = false;
    33343345    bool grab_data = true;
    33353346
    33363347    bool export_iconmap = false;
     
    38603871                       newsource.lineupid = sourcequery.value(5).toString();
    38613872
    38623873                       sourcelist.append(newsource);
    3863                        if (newsource.xmltvgrabber == "datadirect")
    3864                            usingDataDirect = true;
     3874                       usingDataDirect |=
     3875                           is_grabber_datadirect(newsource.xmltvgrabber);
     3876                       usingDataDirectLabs |=
     3877                           is_grabber_labs(newsource.xmltvgrabber);
    38653878                  }
    38663879             }
    38673880             else
     
    40954108        ddprocessor.GrabNextSuggestedTime();
    40964109    }
    40974110
     4111    if (usingDataDirectLabs ||
     4112        !gContext->GetNumSetting("MythFillFixProgramIDsHasRunOnce", 0))
     4113    {
     4114        DataDirectProcessor::FixProgramIDs();
     4115    }
     4116
    40984117    VERBOSE(VB_IMPORTANT, "\n"
    40994118            "===============================================================\n"
    41004119            "| Attempting to contact the master backend for rescheduling.  |\n"