Ticket #12499: 12499-v1.patch

File 12499-v1.patch, 9.8 KB (added by gigem, 9 years ago)
  • mythtv/libs/libmythtv/cardutil.cpp

    diff --git a/mythtv/libs/libmythtv/cardutil.cpp b/mythtv/libs/libmythtv/cardutil.cpp
    index 363aa9c..97ea302 100644
    a b void CardUtil::GetDeviceInputNames( 
    17371737    inputs.clear();
    17381738    if (IsSingleInputType(inputtype))
    17391739        inputs += "MPEG2TS";
    1740     else if ("DVB" != inputtype)
     1740    else if (inputtype == "DVB")
     1741        inputs += "DVBInput";
     1742    else
    17411743        inputs += ProbeV4LVideoInputs(device);
    1742 
    1743 #ifdef USING_DVB
    1744     if ("DVB" == inputtype)
    1745     {
    1746         bool needs_conf = IsInNeedOfExternalInputConf(inputid);
    1747         InputNames list = GetConfiguredDVBInputs(device);
    1748         if (!needs_conf && list.empty())
    1749         {
    1750             inputs += "DVBInput";
    1751         }
    1752 
    1753         // Always list the 1 through n+1 inputs
    1754         if (needs_conf)
    1755         {
    1756             for (int i = 0; i <= list.size(); ++i)
    1757                 inputs += QString("DVBInput #%1").arg(i+1);
    1758         }
    1759 
    1760         // Always list the existing inputs
    1761         InputNames::const_iterator it;
    1762         for (it = list.begin(); it != list.end(); ++it)
    1763         {
    1764             inputs += *it;
    1765         }
    1766     }
    1767 #endif // USING_DVB
    17681744}
    17691745
    17701746int CardUtil::CreateCaptureCard(const QString &videodevice,
    bool CardUtil::DeleteCard(uint inputid) 
    18681844    if (!inputid)
    18691845        return true;
    18701846
    1871     // delete any DiSEqC device tree
    18721847    DiSEqCDevTree tree;
    18731848    tree.Load(inputid);
    1874     if (!tree.Root())
    1875     {
    1876         tree.SetRoot(NULL);
    1877         tree.Store(inputid);
    1878     }
    18791849
    18801850    // delete any clones
    18811851    QString rawtype     = GetRawInputType(inputid);
    bool CardUtil::DeleteCard(uint inputid) 
    18851855        query.prepare(
    18861856            "SELECT cardid "
    18871857            "FROM capturecard "
    1888             "WHERE videodevice = :DEVICE AND "
    1889             "      cardid      > :INPUTID");
    1890         query.bindValue(":DEVICE", videodevice);
     1858            "WHERE parentid = :INPUTID");
    18911859        query.bindValue(":INPUTID", inputid);
    18921860
    18931861        if (!query.exec())
    bool CardUtil::DeleteCard(uint inputid) 
    19031871            return false;
    19041872    }
    19051873
    1906     // delete input
    19071874    ok &= CardUtil::DeleteInput(inputid);
    19081875
    19091876    if (!ok)
    bool CardUtil::DeleteCard(uint inputid) 
    19211888
    19221889    if (ok)
    19231890    {
     1891        // Delete the diseqc tree if no more inputs reference it.
     1892        if (tree.Root())
     1893        {
     1894            query.prepare("SELECT cardid FROM capturecard "
     1895                          "WHERE diseqcid = :DISEQCID LIMIT 1");
     1896            query.bindValue(":DISEQCID", tree.Root()->GetDeviceID());
     1897            if (!query.exec())
     1898            {
     1899                MythDB::DBError("DeleteCard -- find diseqc tree", query);
     1900            }
     1901            else if (!query.next())
     1902            {
     1903                tree.SetRoot(NULL);
     1904                tree.Store(inputid);
     1905            }
     1906        }
     1907
    19241908        // delete any unused input groups
    19251909        UnlinkInputGroup(0,0);
    19261910    }
  • mythtv/libs/libmythtv/diseqc.cpp

    diff --git a/mythtv/libs/libmythtv/diseqc.cpp b/mythtv/libs/libmythtv/diseqc.cpp
    index 24da65e..3e266a9 100644
    a b DiSEqCDevTree::~DiSEqCDevTree() 
    323323    delete m_root;
    324324}
    325325
     326/** \fn DiSEqCDevTree::Load(const QString&, const QString&)
     327 *  \brief Loads the device tree from the database.
     328 *  \param device recording input uses.
     329 *  \return True if successful.
     330 */
     331bool DiSEqCDevTree::Load(const QString &device)
     332{
     333    // lookup configuration for this card
     334    MSqlQuery query(MSqlQuery::InitCon());
     335    query.prepare(
     336        "SELECT cardid "
     337        "FROM capturecard "
     338        "WHERE hostname = :HOSTNAME AND "
     339        "      videodevice = :VIDEODEVICE "
     340        "LIMIT 1");
     341    query.bindValue(":HOSTNAME", gCoreContext->GetHostName());
     342    query.bindValue(":VIDEODEVICE", device);
     343
     344    uint cardid = 0;
     345
     346    if (!query.exec())
     347    {
     348        MythDB::DBError("DiSEqCDevTree::Load", query);
     349    }
     350    else if (query.next())
     351    {
     352        cardid = query.value(0).toUInt();
     353    }
     354
     355    return Load(cardid);
     356}
     357
    326358/** \fn DiSEqCDevTree::Load(uint)
    327359 *  \brief Loads the device tree from the database.
    328360 *  \param cardid Capture card id.
    bool DiSEqCDevTree::Exists(int cardid) 
    394426    return false;
    395427}
    396428
    397 /** \fn DiSEqCDevTree::Store(uint)
     429/** \fn DiSEqCDevTree::Store(QString)
     430 *  \brief Stores the device tree to the database.
     431 *  \param device.
     432 *  \return True if successful.
     433 */
     434bool DiSEqCDevTree::Store(const QString &device)
     435{
     436    MSqlQuery query0(MSqlQuery::InitCon());
     437
     438    // apply pending node deletions
     439    if (!m_delete.empty())
     440    {
     441        MSqlQuery query1(MSqlQuery::InitCon());
     442
     443        query0.prepare(
     444            "DELETE FROM diseqc_tree "
     445            "WHERE diseqcid = :DEVID");
     446        query1.prepare(
     447            "DELETE FROM diseqc_config "
     448            "WHERE diseqcid = :DEVID");
     449
     450        vector<uint>::const_iterator it = m_delete.begin();
     451        for (; it != m_delete.end(); ++it)
     452        {
     453            query0.bindValue(":DEVID", *it);
     454            if (!query0.exec())
     455                MythDB::DBError("DiSEqCDevTree::Store 1", query0);
     456
     457            query1.bindValue(":DEVID", *it);
     458            if (!query1.exec())
     459                MythDB::DBError("DiSEqCDevTree::Store 2", query1);
     460
     461        }
     462        m_delete.clear();
     463    }
     464
     465    // store changed and new nodes
     466    uint devid = 0;
     467    if (m_root && m_root->Store())
     468        devid = m_root->GetDeviceID();
     469    else if (m_root)
     470    {
     471        LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to save DiSEqC tree.");
     472        return false;
     473    }
     474
     475    // update capture card to point to tree, or 0 if there is no tree
     476    query0.prepare(
     477        "UPDATE capturecard "
     478        "SET diseqcid = :DEVID "
     479        "WHERE hostname = :HOSTNAME AND "
     480        "      videodevice = :VIDEODEVICE");
     481    query0.bindValue(":DEVID",  devid);
     482    query0.bindValue(":HOSTNAME", gCoreContext->GetHostName());
     483    query0.bindValue(":VIDEODEVICE", device);
     484    if (!query0.exec())
     485    {
     486        MythDB::DBError("DiSEqCDevTree::Store 3", query0);
     487        return false;
     488    }
     489
     490    return true;
     491}
     492
     493/** \fn DiSEqCDevTree::Store(QString)
    398494 *  \brief Stores the device tree to the database.
    399495 *  \param cardid Capture card id.
    400496 *  \return True if successful.
  • mythtv/libs/libmythtv/diseqc.h

    diff --git a/mythtv/libs/libmythtv/diseqc.h b/mythtv/libs/libmythtv/diseqc.h
    index dd7abae..248873b 100644
    a b class DiSEqCDevTree 
    7878    DiSEqCDevTree();
    7979    ~DiSEqCDevTree();
    8080
     81    bool Load(const QString &device);
    8182    bool Load(uint cardid);
     83    bool Store(const QString &device);
    8284    bool Store(uint cardid);
    8385    bool Execute(const DiSEqCDevSettings &settings,
    8486                 const DTVMultiplex &tuning);
  • mythtv/libs/libmythtv/videosource.cpp

    diff --git a/mythtv/libs/libmythtv/videosource.cpp b/mythtv/libs/libmythtv/videosource.cpp
    index 35ed7f1..1c42759 100644
    a b class InputName : public ComboBoxSetting, public CardInputDBStorage 
    29602960        ComboBoxSetting(this), CardInputDBStorage(this, parent, "inputname")
    29612961    {
    29622962        setLabel(QObject::tr("Input name"));
    2963         addSelection(QObject::tr("(None)"), "None");
    29642963    };
    29652964
    29662965    virtual void Load(void)
    void CardInputEditor::Load(void) 
    39403939        QString videodevice = query.value(1).toString();
    39413940        QString cardtype    = query.value(2).toString();
    39423941        QString inputname   = query.value(3).toString();
    3943         if (inputname.isEmpty())
    3944             inputname = QObject::tr("(None)");
    39453942
    3946         CardInput *cardinput = new CardInput(cardtype, false, cardid);
     3943        CardInput *cardinput = new CardInput(cardtype, true, cardid);
    39473944        cardinput->loadByID(cardid);
    39483945        QString inputlabel = QString("%1 (%2) -> %3")
    39493946            .arg(CardUtil::GetDeviceLabel(cardtype, videodevice))
    static QString remove_chaff(const QString &name) 
    39973994}
    39983995#endif // USING_DVB
    39993996
     3997void DVBConfigurationGroup::reloadDiseqcTree(const QString &videodevice)
     3998{
     3999    if (diseqc_tree)
     4000        diseqc_tree->Load(videodevice);
     4001}
     4002
    40004003void DVBConfigurationGroup::probeCard(const QString &videodevice)
    40014004{
    40024005    if (videodevice.isEmpty())
    DVBConfigurationGroup::DVBConfigurationGroup(CaptureCard& a_parent) : 
    42304233
    42314234    connect(cardnum,      SIGNAL(valueChanged(const QString&)),
    42324235            this,         SLOT(  probeCard   (const QString&)));
     4236    connect(cardnum,      SIGNAL(valueChanged(const QString&)),
     4237            this,         SLOT(  reloadDiseqcTree(const QString&)));
    42334238    connect(diseqc_btn,   SIGNAL(pressed()),
    42344239            this,         SLOT(  DiSEqCPanel()));
    42354240    connect(buttonRecOpt, SIGNAL(pressed()),
    void DVBConfigurationGroup::DiSEqCPanel() 
    42564261void DVBConfigurationGroup::Load(void)
    42574262{
    42584263    VerticalConfigurationGroup::Load();
    4259     diseqc_tree->Load(parent.getCardID());
     4264    reloadDiseqcTree(cardnum->getValue());
    42604265    if (cardtype->getValue() == "DVB-S" ||
    42614266        cardtype->getValue() == "DVB-S2" ||
    42624267        DiSEqCDevTree::Exists(parent.getCardID()))
    void DVBConfigurationGroup::Load(void) 
    42684273void DVBConfigurationGroup::Save(void)
    42694274{
    42704275    VerticalConfigurationGroup::Save();
    4271     diseqc_tree->Store(parent.getCardID());
     4276    diseqc_tree->Store(cardnum->getValue());
    42724277    DiSEqCDev trees;
    42734278    trees.InvalidateTrees();
    42744279}
  • mythtv/libs/libmythtv/videosource.h

    diff --git a/mythtv/libs/libmythtv/videosource.h b/mythtv/libs/libmythtv/videosource.h
    index c6029b0..e3de3af 100644
    a b class DVBConfigurationGroup : public VerticalConfigurationGroup 
    623623
    624624  public slots:
    625625    void probeCard(const QString& cardNumber);
     626    void reloadDiseqcTree(const QString &device);
    626627    void DiSEqCPanel(void);
    627628    void DVBExtraPanel(void);
    628629