Ticket #3842: 3842-isnew-fixes-v1.patch

File 3842-isnew-fixes-v1.patch, 7.0 KB (added by danielk, 18 years ago)

Adds code to handle the new "new" XML tag in DD for 0.20-fixes

  • libs/libmythtv/datadirect.h

     
    9696    QDateTime time;
    9797    QTime     duration;
    9898    bool      repeat;
     99    bool      isnew;
    99100    bool      stereo;
    100101    bool      subtitled;
    101102    bool      hdtv;
     
    213214class DDStructureParser: public QXmlDefaultHandler
    214215{
    215216  public:
    216     DDStructureParser(DataDirectProcessor& _ddparent): parent(_ddparent) {}
     217    DDStructureParser(DataDirectProcessor& _ddparent) :
     218        parent(_ddparent), saw_repeat(false), saw_new(false) {}
    217219
    218220    bool startElement(const QString &pnamespaceuri, const QString &plocalname,
    219221                      const QString &pqname, const QXmlAttributes &pxmlatts);
     
    238240    DataDirectProductionCrew curr_productioncrew;
    239241    DataDirectGenre          curr_genre;
    240242    QString                  lastprogramid;
     243    bool                     saw_repeat;
     244    bool                     saw_new;
    241245};
    242246
     247
    243248typedef QMap<QString,DataDirectStation>    DDStationList; // stationid ->
    244249typedef vector<DataDirectLineup>           DDLineupList;
    245250typedef vector<DataDirectLineupMap>        DDLineupChannels;
  • libs/libmythtv/datadirect.cpp

     
    6868DataDirectSchedule::DataDirectSchedule() :
    6969    programid(""),              stationid(""),
    7070    time(QDateTime()),          duration(QTime()),
    71     repeat(false),              stereo(false),
    72     subtitled(false),           hdtv(false),
    73     closecaptioned(false),      tvrating(""),
     71    repeat(false),              isnew(false),
     72    stereo(false),              subtitled(false),
     73    hdtv(false),                closecaptioned(false),
     74    tvrating(""),
    7475    partnumber(0),              parttotal(0)
    7576{
    7677}
     
    167168        curr_schedule.duration = QTime(durstr.mid(2, 2).toInt(),
    168169                                       durstr.mid(5, 2).toInt(), 0, 0);
    169170
    170         curr_schedule.repeat = (pxmlatts.value("repeat") == "true");
     171        QString isrepeat = pxmlatts.value("repeat");
     172        curr_schedule.repeat = (isrepeat == "true");
     173        saw_repeat |= !isrepeat.isEmpty();
     174
     175        QString isnew = pxmlatts.value("new");
     176        curr_schedule.isnew = (isnew == "true");
     177        saw_new |= !isnew.isEmpty();
     178
    171179        curr_schedule.stereo = (pxmlatts.value("stereo") == "true");
    172180        curr_schedule.subtitled = (pxmlatts.value("subtitled") == "true");
    173181        curr_schedule.hdtv = (pxmlatts.value("hdtv") == "true");
     
    278286            "       duration,   isrepeat,    stereo,         "
    279287            "       subtitled,  hdtv,        closecaptioned, "
    280288            "       tvrating,   partnumber,  parttotal,      "
    281             "       endtime) "
     289            "       endtime,    isnew) "
    282290            "VALUES "
    283291            "     (:PROGRAMID, :STATIONID,  :TIME,           "
    284292            "      :DURATION,  :ISREPEAT,   :STEREO,         "
    285293            "      :SUBTITLED, :HDTV,       :CAPTIONED,      "
    286294            "      :TVRATING,  :PARTNUMBER, :PARTTOTAL,      "
    287             "      :ENDTIME)");
     295            "      :ENDTIME,   :ISNEW)");
    288296
    289297        query.bindValue(":PROGRAMID",   curr_schedule.programid);
    290298        query.bindValue(":STATIONID",   curr_schedule.stationid);
     
    299307        query.bindValue(":PARTNUMBER",  curr_schedule.partnumber);
    300308        query.bindValue(":PARTTOTAL",   curr_schedule.parttotal);
    301309        query.bindValue(":ENDTIME",     endtime);
     310        query.bindValue(":ISNEW",       curr_schedule.isnew);
    302311
    303312        if (!query.exec())
    304313            MythContext::DBError("Inserting into dd_schedule", query);
     
    411420
    412421bool DDStructureParser::endDocument()
    413422{
     423    MSqlQuery query(MSqlQuery::DDCon());
     424    query.prepare(
     425        "INSERT INTO dd_state (sawrepeat, sawnew) "
     426        "VALUES (:SAWREPEAT, :SAWNEW)");
     427    query.bindValue(":SAWREPEAT", saw_repeat);
     428    query.bindValue(":SAWNEW",    saw_new);
     429
     430    if (!query.exec())
     431        MythContext::DBError("Inserting into dd_state", query);
     432
    414433    return true;
    415434}
    416435 
     
    597616void DataDirectProcessor::UpdateProgramViewTable(uint sourceid)
    598617{
    599618    MSqlQuery query(MSqlQuery::DDCon());
    600    
     619
     620    query.prepare(
     621        "SELECT sawrepeat, sawnew "
     622        "FROM dd_state");
     623
     624    if (!query.exec())
     625    {
     626        MythContext::DBError("Querying into dd_state", query);
     627        return;
     628    }
     629
     630    if (!query.next())
     631    {
     632        VERBOSE(VB_IMPORTANT, LOC_ERR + "UpdateProgramViewTable no dd_state!");
     633        return;
     634    }
     635
     636    bool saw_repeat = query.value(0).toUInt(); (void) saw_repeat;
     637    bool saw_new    = query.value(1).toUInt(); (void) saw_new;
     638
     639//    VERBOSE(VB_GENERAL, LOC + QString("Saw new: %1, saw repeat: %2")
     640//            .arg(saw_new).arg(saw_repeat));
     641
    601642    if (!query.exec("TRUNCATE TABLE dd_v_program;"))
    602643        MythContext::DBError("Truncating temporary table dd_v_program", query);
    603644
    604     query.prepare(
     645    QString qstr =
    605646        "INSERT INTO dd_v_program "
    606647        "     ( chanid,         starttime,       endtime,         "
    607648        "       title,          subtitle,        description,     "
     
    613654        "       tvrating,       mpaarating,      programid )      "
    614655        "SELECT chanid,         scheduletime,    endtime,         "
    615656        "       title,          subtitle,        description,     "
    616         "       year,           stars,           isrepeat,        "
     657        "       year,           stars,           %1,              "
    617658        "       stereo,         subtitled,       hdtv,            "
    618659        "       closecaptioned, partnumber,      parttotal,       "
    619660        "       seriesid,       originalairdate, showtype,        "
     
    622663        "FROM channel, dd_schedule, dd_program "
    623664        "WHERE ((dd_schedule.programid = dd_program.programid)  AND "
    624665        "       (channel.xmltvid       = dd_schedule.stationid) AND "
    625         "       (channel.sourceid      = :SOURCEID))");
     666        "       (channel.sourceid      = :SOURCEID))";
    626667
     668    query.prepare(qstr.arg((saw_new) ? "not isnew" : "isrepeat"));
     669
    627670    query.bindValue(":SOURCEID", sourceid);
    628671
    629672    if (!query.exec())
     
    11431186{
    11441187    QMap<QString,QString> dd_tables;
    11451188
     1189    dd_tables["dd_state"] =
     1190        "( sawrepeat bool,               sawnew bool )";
     1191
    11461192    dd_tables["dd_station"] =
    11471193        "( stationid char(12),           callsign char(10),     "
    11481194        "  stationname varchar(40),      affiliate varchar(25), "
     
    11711217        "  subtitled bool,               hdtv bool,          "
    11721218        "  closecaptioned bool,          tvrating char(5),   "
    11731219        "  partnumber int,               parttotal int,      "
    1174         "  endtime datetime, "
     1220        "  endtime datetime,             isnew bool,         "
    11751221        "INDEX progidx (programid) )";
    11761222
    11771223    dd_tables["dd_program"] =