Ticket #12499: 12499-v1.patch
File 12499-v1.patch, 9.8 KB (added by , 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( 1737 1737 inputs.clear(); 1738 1738 if (IsSingleInputType(inputtype)) 1739 1739 inputs += "MPEG2TS"; 1740 else if ("DVB" != inputtype) 1740 else if (inputtype == "DVB") 1741 inputs += "DVBInput"; 1742 else 1741 1743 inputs += ProbeV4LVideoInputs(device); 1742 1743 #ifdef USING_DVB1744 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 inputs1754 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 inputs1761 InputNames::const_iterator it;1762 for (it = list.begin(); it != list.end(); ++it)1763 {1764 inputs += *it;1765 }1766 }1767 #endif // USING_DVB1768 1744 } 1769 1745 1770 1746 int CardUtil::CreateCaptureCard(const QString &videodevice, … … bool CardUtil::DeleteCard(uint inputid) 1868 1844 if (!inputid) 1869 1845 return true; 1870 1846 1871 // delete any DiSEqC device tree1872 1847 DiSEqCDevTree tree; 1873 1848 tree.Load(inputid); 1874 if (!tree.Root())1875 {1876 tree.SetRoot(NULL);1877 tree.Store(inputid);1878 }1879 1849 1880 1850 // delete any clones 1881 1851 QString rawtype = GetRawInputType(inputid); … … bool CardUtil::DeleteCard(uint inputid) 1885 1855 query.prepare( 1886 1856 "SELECT cardid " 1887 1857 "FROM capturecard " 1888 "WHERE videodevice = :DEVICE AND " 1889 " cardid > :INPUTID"); 1890 query.bindValue(":DEVICE", videodevice); 1858 "WHERE parentid = :INPUTID"); 1891 1859 query.bindValue(":INPUTID", inputid); 1892 1860 1893 1861 if (!query.exec()) … … bool CardUtil::DeleteCard(uint inputid) 1903 1871 return false; 1904 1872 } 1905 1873 1906 // delete input1907 1874 ok &= CardUtil::DeleteInput(inputid); 1908 1875 1909 1876 if (!ok) … … bool CardUtil::DeleteCard(uint inputid) 1921 1888 1922 1889 if (ok) 1923 1890 { 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 1924 1908 // delete any unused input groups 1925 1909 UnlinkInputGroup(0,0); 1926 1910 } -
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() 323 323 delete m_root; 324 324 } 325 325 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 */ 331 bool 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 326 358 /** \fn DiSEqCDevTree::Load(uint) 327 359 * \brief Loads the device tree from the database. 328 360 * \param cardid Capture card id. … … bool DiSEqCDevTree::Exists(int cardid) 394 426 return false; 395 427 } 396 428 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 */ 434 bool 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) 398 494 * \brief Stores the device tree to the database. 399 495 * \param cardid Capture card id. 400 496 * \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 78 78 DiSEqCDevTree(); 79 79 ~DiSEqCDevTree(); 80 80 81 bool Load(const QString &device); 81 82 bool Load(uint cardid); 83 bool Store(const QString &device); 82 84 bool Store(uint cardid); 83 85 bool Execute(const DiSEqCDevSettings &settings, 84 86 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 2960 2960 ComboBoxSetting(this), CardInputDBStorage(this, parent, "inputname") 2961 2961 { 2962 2962 setLabel(QObject::tr("Input name")); 2963 addSelection(QObject::tr("(None)"), "None");2964 2963 }; 2965 2964 2966 2965 virtual void Load(void) … … void CardInputEditor::Load(void) 3940 3939 QString videodevice = query.value(1).toString(); 3941 3940 QString cardtype = query.value(2).toString(); 3942 3941 QString inputname = query.value(3).toString(); 3943 if (inputname.isEmpty())3944 inputname = QObject::tr("(None)");3945 3942 3946 CardInput *cardinput = new CardInput(cardtype, false, cardid);3943 CardInput *cardinput = new CardInput(cardtype, true, cardid); 3947 3944 cardinput->loadByID(cardid); 3948 3945 QString inputlabel = QString("%1 (%2) -> %3") 3949 3946 .arg(CardUtil::GetDeviceLabel(cardtype, videodevice)) … … static QString remove_chaff(const QString &name) 3997 3994 } 3998 3995 #endif // USING_DVB 3999 3996 3997 void DVBConfigurationGroup::reloadDiseqcTree(const QString &videodevice) 3998 { 3999 if (diseqc_tree) 4000 diseqc_tree->Load(videodevice); 4001 } 4002 4000 4003 void DVBConfigurationGroup::probeCard(const QString &videodevice) 4001 4004 { 4002 4005 if (videodevice.isEmpty()) … … DVBConfigurationGroup::DVBConfigurationGroup(CaptureCard& a_parent) : 4230 4233 4231 4234 connect(cardnum, SIGNAL(valueChanged(const QString&)), 4232 4235 this, SLOT( probeCard (const QString&))); 4236 connect(cardnum, SIGNAL(valueChanged(const QString&)), 4237 this, SLOT( reloadDiseqcTree(const QString&))); 4233 4238 connect(diseqc_btn, SIGNAL(pressed()), 4234 4239 this, SLOT( DiSEqCPanel())); 4235 4240 connect(buttonRecOpt, SIGNAL(pressed()), … … void DVBConfigurationGroup::DiSEqCPanel() 4256 4261 void DVBConfigurationGroup::Load(void) 4257 4262 { 4258 4263 VerticalConfigurationGroup::Load(); 4259 diseqc_tree->Load(parent.getCardID());4264 reloadDiseqcTree(cardnum->getValue()); 4260 4265 if (cardtype->getValue() == "DVB-S" || 4261 4266 cardtype->getValue() == "DVB-S2" || 4262 4267 DiSEqCDevTree::Exists(parent.getCardID())) … … void DVBConfigurationGroup::Load(void) 4268 4273 void DVBConfigurationGroup::Save(void) 4269 4274 { 4270 4275 VerticalConfigurationGroup::Save(); 4271 diseqc_tree->Store( parent.getCardID());4276 diseqc_tree->Store(cardnum->getValue()); 4272 4277 DiSEqCDev trees; 4273 4278 trees.InvalidateTrees(); 4274 4279 } -
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 623 623 624 624 public slots: 625 625 void probeCard(const QString& cardNumber); 626 void reloadDiseqcTree(const QString &device); 626 627 void DiSEqCPanel(void); 627 628 void DVBExtraPanel(void); 628 629