Ticket #6138: hdhr.config.ui.1.patch
File hdhr.config.ui.1.patch, 18.8 KB (added by , 15 years ago) |
---|
-
mythtv/libs/libmythtv/cardutil.cpp
diff -p -r -u -N -X /tmp/diff.exclude.12740 -x myth.20757.0629a -x myth.20757.0629b myth.20757.0629a/mythtv/libs/libmythtv/cardutil.cpp myth.20757.0629b/mythtv/libs/libmythtv/cardutil.cpp
QStringVec CardUtil::ProbeVideoDevices(c 233 233 return devs; 234 234 } 235 235 236 if (result == 20)236 if (result == 50) 237 237 { 238 238 VERBOSE(VB_IMPORTANT, "CardUtil::ProbeVideoDevices: " 239 "Warning: may be > 20 HDHomerun devices");239 "Warning: may be > 50 HDHomerun devices"); 240 240 } 241 241 242 // TODO FIXME -- figure out some way to return ip address as well242 // Return "deviceid ipaddress" pairs 243 243 for (int i = 0; i < result; i++) 244 244 { 245 QString did = QString("%1").arg(result_list[i].device_id, 0, 16); 246 did = did.toUpper(); 245 QString id = QString("%1").arg(result_list[i].device_id, 0, 16); 246 QString ip = QString("%1.%2.%3.%4") 247 .arg((result_list[i].ip_addr>>24) & 0xFF) 248 .arg((result_list[i].ip_addr>>16) & 0xFF) 249 .arg((result_list[i].ip_addr>> 8) & 0xFF) 250 .arg((result_list[i].ip_addr>> 0) & 0xFF); 247 251 248 devs.push_back(did + "-0"); 249 devs.push_back(did + "-1"); 252 QString hdhrdev = id.toUpper() + " " + ip; 253 254 devs.push_back(hdhrdev); 250 255 } 251 256 } 252 257 #endif // USING_HDHOMERUN -
mythtv/libs/libmythtv/videosource.cpp
diff -p -r -u -N -X /tmp/diff.exclude.12740 -x myth.20757.0629a -x myth.20757.0629b myth.20757.0629a/mythtv/libs/libmythtv/videosource.cpp myth.20757.0629b/mythtv/libs/libmythtv/videosource.cpp
class DBOX2ConfigurationGroup : public V 1411 1411 CaptureCard &parent; 1412 1412 }; 1413 1413 1414 class HDHomeRunIP : public TransLabelSetting 1414 // ----------------------- 1415 // HDHomeRun Configuration 1416 // ----------------------- 1417 1418 HDHomeRunIP::HDHomeRunIP() 1419 { 1420 setLabel(QObject::tr("IP Address")); 1421 setEnabled(false); 1422 connect(this, SIGNAL(valueChanged(const QString&)), 1423 this, SLOT(updateDevices(const QString&))); 1424 _oldValue=""; 1425 }; 1426 1427 void HDHomeRunIP::setEnabled(bool e) 1428 { 1429 TransLineEditSetting::setEnabled(e); 1430 if (e) { 1431 if (_oldValue != "") 1432 setValue(_oldValue); 1433 emit hasNewIP(getValue()); 1434 } 1435 else 1436 _oldValue = getValue(); 1437 } 1438 1439 void HDHomeRunIP::updateDevices(const QString& v) 1415 1440 { 1416 public: 1417 HDHomeRunIP() 1418 { 1419 setLabel(QObject::tr("IP Address")); 1420 }; 1441 if (isEnabled()) 1442 { 1443 VERBOSE(VB_IMPORTANT, QString("Emitting hasNewIP(%1)").arg(v)); 1444 emit hasNewIP(v); 1445 } 1446 } 1447 1448 HDHomeRunTunerIndex::HDHomeRunTunerIndex() 1449 { 1450 setLabel(QObject::tr("Tuner")); 1451 setEnabled(false); 1452 addSelection("0"); 1453 addSelection("1"); 1454 connect(this, SIGNAL(valueChanged(const QString&)), 1455 this, SLOT(updateDevices(const QString&))); 1456 _oldValue=""; 1421 1457 }; 1422 1458 1423 class HDHomeRunTuner : public TransLabelSetting 1459 void HDHomeRunTunerIndex::setEnabled(bool e) 1424 1460 { 1425 public: 1426 HDHomeRunTuner() 1427 { 1428 setLabel(QObject::tr("Tuner")); 1429 }; 1461 TransComboBoxSetting::setEnabled(e); 1462 if (e) { 1463 if (_oldValue != "") 1464 setValue(_oldValue); 1465 emit hasNewTuner(getValue()); 1466 } 1467 else 1468 _oldValue = getValue(); 1469 } 1470 1471 void HDHomeRunTunerIndex::updateDevices(const QString& v) 1472 { 1473 if (isEnabled()) 1474 { 1475 VERBOSE(VB_IMPORTANT, QString("Emitting hasNewTuner(%1)").arg(v)); 1476 emit hasNewTuner(v); 1477 } 1478 } 1479 1480 HDHomeRunDeviceID::HDHomeRunDeviceID(const CaptureCard &parent) : 1481 LabelSetting(this), 1482 CaptureCardDBStorage(this, parent, "videodevice") 1483 { 1484 setLabel(QObject::tr("Mythtv Device ID")); 1485 setHelpText( 1486 QObject::tr( 1487 "DevicedID and Tuner Number of available HDHomeRun devices.")); 1488 } 1489 1490 void HDHomeRunDeviceID::SetIP(const QString& ip) 1491 { 1492 VERBOSE(VB_IMPORTANT, QString("Setting IP to %1").arg(ip)); 1493 _ip = ip; 1494 setValue(QString("%1-%2").arg(_ip).arg(_tuner)); 1495 VERBOSE(VB_IMPORTANT, QString("Done Setting IP to %1").arg(ip)); 1496 } 1497 1498 void HDHomeRunDeviceID::SetTuner(const QString& tuner) 1499 { 1500 VERBOSE(VB_IMPORTANT, QString("Setting Tuner to %1").arg(tuner)); 1501 _tuner = tuner; 1502 setValue(QString("%1-%2").arg(_ip).arg(_tuner)); 1503 VERBOSE(VB_IMPORTANT, QString("Done Setting Tuner to %1").arg(tuner)); 1504 } 1505 1506 HDHomeRunDeviceIDList::HDHomeRunDeviceIDList(HDHomeRunDeviceID *deviceid, 1507 HDHomeRunIP *cardip, 1508 HDHomeRunTunerIndex *cardtuner, 1509 HDHomeRunDeviceList *devicelist) : 1510 _deviceid(deviceid), 1511 _cardip(cardip), 1512 _cardtuner(cardtuner), 1513 _devicelist(devicelist) 1514 { 1515 setLabel(QObject::tr("Available Devices")); 1516 setHelpText( 1517 QObject::tr( 1518 "DevicedID and Tuner Number of available HDHomeRun devices.")); 1519 1520 connect(this, SIGNAL(valueChanged(const QString&)), 1521 this, SLOT(updateDevices(const QString&))); 1522 _oldValue=""; 1430 1523 }; 1431 1524 1432 class HDHomeRunDeviceID : public ComboBoxSetting, public CaptureCardDBStorage 1525 /// \brief Adds all available device-tuner combinations to list 1526 /// If current is >= 0 it will be considered available even 1527 /// if no device exists for it on the network 1528 void HDHomeRunDeviceIDList::fillSelections(QString current) 1433 1529 { 1434 public: 1435 HDHomeRunDeviceID(const CaptureCard &parent) : 1436 ComboBoxSetting(this), 1437 CaptureCardDBStorage(this, parent, "videodevice") 1438 { 1439 setLabel(QObject::tr("Device ID")); 1440 setHelpText( 1441 QObject::tr( 1442 "DevicedID and Tuner Number of available HDHomeRun devices.")); 1443 fillSelections(""); 1444 }; 1530 clearSelections(); 1445 1531 1446 /// \brief Adds all available device-tuner combinations to list 1447 /// If current is >= 0 it will be considered available even 1448 /// if no device exists for it on the network 1449 void fillSelections(QString current) 1450 { 1451 clearSelections(); 1532 vector<QString> devs; 1533 QMap<QString, bool> in_use; 1452 1534 1453 // Get network visible devices 1454 vector<QString> devs = CardUtil::ProbeVideoDevices("HDHOMERUN"); 1535 HDHomeRunDeviceList::iterator it; 1455 1536 1456 // Add current if needed 1457 if ((current != "") && 1458 (find(devs.begin(), devs.end(), current) == devs.end())) 1537 VERBOSE(VB_IMPORTANT, QString("Filling List, current = '%1'").arg(current)); 1538 for (it = _devicelist->begin(); it != _devicelist->end(); it++) 1539 { 1540 if (it.value().discovered) 1459 1541 { 1460 devs.push_back( current);1461 stable_sort(devs.begin(), devs.end());1542 devs.push_back(it.key()); 1543 in_use[it.key()] = it.value().inuse; 1462 1544 } 1545 } 1463 1546 1464 vector<QString> db = CardUtil::GetVideoDevices("HDHOMERUN");1547 devs.push_back("Manually Enter IP Address"); 1465 1548 1466 QMap<QString, bool> in_use; 1467 QString sel = current; 1468 for (uint i = 0; i < devs.size(); i++) 1469 { 1470 const QString dev = devs[i]; 1471 in_use[devs[i]] = find(db.begin(), db.end(), dev) != db.end(); 1472 if (sel == "" && !in_use[devs[i]]) 1473 sel = dev; 1474 } 1549 QString sel = "Manually Enter IP Address"; 1550 for (uint i = 0; i < devs.size(); i++) 1551 { 1552 const QString dev = devs[i]; 1553 if (current == dev) 1554 sel = dev; 1555 } 1475 1556 1476 if (sel == "" && devs.size())1477 sel = devs[0];1557 QString usestr = QString(" -- "); 1558 usestr += QObject::tr("Warning: already in use"); 1478 1559 1479 QString usestr = QString(" -- "); 1480 usestr += QObject::tr("Warning: already in use"); 1481 1482 for (uint i = 0; i < devs.size(); i++) 1483 { 1484 const QString dev = devs[i]; 1485 QString desc = dev + (in_use[devs[i]] ? usestr : ""); 1486 desc = (current == devs[i]) ? dev : desc; 1487 addSelection(desc, dev, dev == sel); 1488 } 1560 for (uint i = 0; i < devs.size(); i++) 1561 { 1562 const QString dev = devs[i]; 1563 QString desc = dev + (in_use[devs[i]] ? usestr : ""); 1564 desc = (current == devs[i]) ? dev : desc; 1565 addSelection(desc, dev, dev == sel); 1489 1566 } 1490 1567 1491 virtual void Load(void)1568 if (sel == "Manually Enter IP Address" && current != "") 1492 1569 { 1493 clearSelections(); 1494 addSelection(""); 1570 // Populate the proper values for IP address and tuner 1571 QStringList selection = current.split("-"); 1572 1573 _cardip->setOldValue(selection.first()); 1574 _cardtuner->setOldValue(selection.last()); 1575 1576 _cardip->setValue(selection.first()); 1577 _cardtuner->setValue(selection.last()); 1578 } 1579 } 1580 1581 void HDHomeRunDeviceIDList::Load(void) 1582 { 1583 clearSelections(); 1584 1585 fillSelections(_deviceid->getValue()); 1586 } 1495 1587 1496 CaptureCardDBStorage::Load(); 1588 void HDHomeRunDeviceIDList::updateDevices(const QString& v) 1589 { 1590 VERBOSE(VB_IMPORTANT, QString("Got signal with %1").arg(v)); 1591 if (v == "Manually Enter IP Address") 1592 { 1593 _cardip->setEnabled(true); 1594 _cardtuner->setEnabled(true); 1595 VERBOSE(VB_IMPORTANT, "Done"); 1596 } else if (v != "") { 1597 if (_oldValue == "Manually Enter IP Address") 1598 { 1599 _cardip->setEnabled(false); 1600 _cardtuner->setEnabled(false); 1601 } 1602 _deviceid->setValue(v); 1603 // Update _cardip && cardtuner 1497 1604 1498 fillSelections(getValue()); 1605 _cardip->setValue((*_devicelist)[v].cardip); 1606 _cardtuner->setValue(QString("%1").arg((*_devicelist)[v].cardtuner)); 1499 1607 } 1608 _oldValue = v; 1500 1609 }; 1610 1501 1611 1502 1612 class IPTVHost : public LineEditSetting, public CaptureCardDBStorage 1503 1613 { … … HDHomeRunConfigurationGroup::HDHomeRunCo 1561 1671 parent(a_parent) 1562 1672 { 1563 1673 setUseLabel(false); 1674 1675 // Fill Device list 1676 fillDeviceList(); 1677 1564 1678 deviceid = new HDHomeRunDeviceID(parent); 1565 addChild(deviceid);1566 1679 cardip = new HDHomeRunIP(); 1567 cardtuner = new HDHomeRunTuner(); 1680 cardtuner = new HDHomeRunTunerIndex(); 1681 deviceidlist = new HDHomeRunDeviceIDList(deviceid, cardip, cardtuner, &devicelist); 1568 1682 1683 addChild(deviceidlist); 1684 addChild(deviceid); 1569 1685 addChild(cardip); 1570 1686 addChild(cardtuner); 1571 1687 … … HDHomeRunConfigurationGroup::HDHomeRunCo 1578 1694 addChild(buttonRecOpt); 1579 1695 1580 1696 // Wish we could use something like editingFinished() here... 1581 connect(deviceid, SIGNAL(valueChanged(const QString&)),1582 this, SLOT( probeCard (const QString&)));1697 //connect(deviceid, SIGNAL(valueChanged(const QString&)), 1698 // this, SLOT( probeCard (const QString&))); 1583 1699 connect(buttonRecOpt, SIGNAL(pressed()), 1584 1700 this, SLOT( HDHomeRunExtraPanel())); 1585 1701 1586 // addChild(desc); 1702 connect(cardip, SIGNAL(hasNewIP(const QString&)), 1703 deviceid, SLOT(SetIP(const QString&))); 1704 connect(cardtuner, SIGNAL(hasNewTuner(const QString&)), 1705 deviceid, SLOT(SetTuner(const QString&))); 1706 1587 1707 }; 1588 1708 1589 void HDHomeRunConfigurationGroup::probeCard(const QString &deviceid) 1709 void HDHomeRunConfigurationGroup::fillDeviceList() 1710 { 1711 devicelist.clear(); 1712 1713 // Find physical devices first 1714 // ProbeVideoDevices returns "deviceid ip" pairs 1715 vector<QString> devs = CardUtil::ProbeVideoDevices("HDHOMERUN"); 1716 1717 vector<QString>::iterator it; 1718 1719 for (it = devs.begin(); it != devs.end(); ++it) 1720 { 1721 QString dev = *it; 1722 QStringList devinfo = dev.split(" "); 1723 QString devid = devinfo.first(); 1724 QString devip = devinfo.last(); 1725 1726 HDHomeRunDevice tmpdevice; 1727 tmpdevice.deviceid=devid; 1728 tmpdevice.cardip=devip; 1729 tmpdevice.inuse=false; 1730 tmpdevice.discovered=true; 1731 1732 tmpdevice.cardtuner = "0"; 1733 tmpdevice.mythdeviceid = tmpdevice.deviceid + "-" + tmpdevice.cardtuner; 1734 devicelist.insert(tmpdevice.mythdeviceid, tmpdevice); 1735 1736 tmpdevice.cardtuner = "1"; 1737 tmpdevice.mythdeviceid = tmpdevice.deviceid + "-" + tmpdevice.cardtuner; 1738 devicelist.insert(tmpdevice.mythdeviceid, tmpdevice); 1739 } 1740 1741 // Now find configured devices 1742 1743 // returns "xxxxxxxx-n" or "ip.ip.ip.ip-n" values 1744 vector<QString> db = CardUtil::GetVideoDevices("HDHOMERUN"); 1745 1746 for (it = db.begin(); it != db.end(); ++it) 1747 { 1748 1749 QMap<QString, HDHomeRunDevice>::iterator dit; 1750 1751 dit = devicelist.find(*it); 1752 if (dit == devicelist.end()) 1753 { 1754 HDHomeRunDevice tmpdevice; 1755 tmpdevice.mythdeviceid = *it; 1756 tmpdevice.inuse=true; 1757 tmpdevice.discovered=false; 1758 1759 if (probeCard(tmpdevice)) 1760 devicelist.insert(tmpdevice.mythdeviceid, tmpdevice); 1761 } 1762 else 1763 dit.value().inuse = true; 1764 } 1765 1766 // Debug dump of cards 1767 QMap<QString, HDHomeRunDevice>::iterator debugit; 1768 for (debugit = devicelist.begin(); debugit != devicelist.end(); debugit++) 1769 { 1770 VERBOSE(VB_IMPORTANT, QString("%1: %2 %3 %4 %5 %6 %7") 1771 .arg(debugit.key()) 1772 .arg(debugit.value().mythdeviceid) 1773 .arg(debugit.value().deviceid) 1774 .arg(debugit.value().cardip) 1775 .arg(debugit.value().cardtuner) 1776 .arg(debugit.value().inuse) 1777 .arg(debugit.value().discovered)); 1778 } 1779 } 1780 1781 bool HDHomeRunConfigurationGroup::probeCard(HDHomeRunDevice& tmpdevice) 1590 1782 { 1591 1783 #ifdef USING_HDHOMERUN 1592 1784 hdhomerun_device_t *thisdevice = 1593 hdhomerun_device_create_from_str( deviceid.toLocal8Bit().constData());1785 hdhomerun_device_create_from_str(tmpdevice.mythdeviceid.toLocal8Bit().constData()); 1594 1786 1595 1787 if (thisdevice) 1596 1788 { 1789 uint device_id = hdhomerun_device_get_device_id(thisdevice); 1597 1790 uint device_ip = hdhomerun_device_get_device_ip(thisdevice); 1598 1791 uint tuner = hdhomerun_device_get_tuner(thisdevice); 1599 1792 hdhomerun_device_destroy(thisdevice); 1600 1793 1601 QString ip = QString("%1.%2.%3.%4") 1602 .arg((device_ip>>24) & 0xFF).arg((device_ip>>16) & 0xFF) 1603 .arg((device_ip>> 8) & 0xFF).arg((device_ip>> 0) & 0xFF); 1794 if (device_id == 0) 1795 tmpdevice.deviceid = "NOTFOUND"; 1796 else 1797 tmpdevice.deviceid = QString("%1").arg(device_id, 8, 16); 1798 1799 tmpdevice.deviceid = tmpdevice.deviceid.toUpper(); 1800 1801 tmpdevice.cardip = QString("%1.%2.%3.%4") 1802 .arg((device_ip>>24) & 0xFF).arg((device_ip>>16) & 0xFF) 1803 .arg((device_ip>> 8) & 0xFF).arg((device_ip>> 0) & 0xFF); 1604 1804 1605 cardip->setValue(ip); 1606 cardtuner->setValue(QString("%1").arg(tuner)); 1607 } 1608 else 1609 { 1610 cardip->setValue("Unknown"); 1611 cardtuner->setValue("Unknown"); 1805 tmpdevice.cardtuner = QString("%1").arg(tuner); 1806 return true; 1612 1807 } 1613 1808 #endif // USING_HDHOMERUN 1809 return false; 1614 1810 } 1615 1811 1616 1812 void HDHomeRunConfigurationGroup::HDHomeRunExtraPanel(void) -
mythtv/libs/libmythtv/videosource.h
diff -p -r -u -N -X /tmp/diff.exclude.12740 -x myth.20757.0629a -x myth.20757.0629b myth.20757.0629a/mythtv/libs/libmythtv/videosource.h myth.20757.0629b/mythtv/libs/libmythtv/videosource.h
public: 442 442 static void fillSelections(SelectSetting* setting); 443 443 }; 444 444 445 446 class HDHomeRunDevice 447 { 448 public: 449 QString mythdeviceid; 450 QString deviceid; 451 QString cardip; 452 QString cardtuner; 453 bool inuse; 454 bool discovered; 455 }; 456 457 typedef QMap<QString, HDHomeRunDevice> HDHomeRunDeviceList; 458 459 class HDHomeRunDeviceIDList; 445 460 class HDHomeRunDeviceID; 446 461 class HDHomeRunIP; 447 class HDHomeRunTuner ;462 class HDHomeRunTunerIndex; 448 463 class HDHomeRunConfigurationGroup : public VerticalConfigurationGroup 449 464 { 450 465 Q_OBJECT … … class HDHomeRunConfigurationGroup : publ 455 470 HDHomeRunConfigurationGroup(CaptureCard &parent); 456 471 457 472 public slots: 458 void probeCard(const QString &device);459 473 void HDHomeRunExtraPanel(void); 460 474 461 475 private: 462 HDHomeRunDeviceID *deviceid; 463 HDHomeRunIP *cardip; 464 HDHomeRunTuner *cardtuner; 476 HDHomeRunDeviceIDList *deviceidlist; 477 HDHomeRunDeviceID *deviceid; 478 HDHomeRunIP *cardip; 479 HDHomeRunTunerIndex *cardtuner; 465 480 466 481 CaptureCard &parent; 467 482 TransLabelSetting *desc; 483 484 void fillDeviceList(); 485 bool probeCard(HDHomeRunDevice&); 486 HDHomeRunDeviceList devicelist; 487 468 488 }; 469 489 470 490 class V4LConfigurationGroup : public VerticalConfigurationGroup … … class CardInput : public QObject, public 788 808 InputGroup *inputgrp1; 789 809 }; 790 810 811 class HDHomeRunDeviceID; 812 class HDHomeRunTunerIndex; 813 814 class HDHomeRunIP : public TransLineEditSetting 815 { 816 Q_OBJECT 817 public: 818 HDHomeRunIP(); 819 820 virtual void setEnabled(bool e); 821 void setOldValue(QString s) { _oldValue = s; }; 822 823 signals: 824 void hasNewIP(const QString & v); 825 826 public slots: 827 void updateDevices(const QString& v); 828 829 private: 830 QString _oldValue; 831 }; 832 833 class HDHomeRunTunerIndex : public TransComboBoxSetting 834 { 835 Q_OBJECT 836 public: 837 HDHomeRunTunerIndex(); 838 839 virtual void setEnabled(bool e); 840 void setOldValue(QString s) { _oldValue = s; }; 841 842 signals: 843 void hasNewTuner(const QString & v); 844 845 public slots: 846 void updateDevices(const QString& v); 847 848 private: 849 QString _oldValue; 850 }; 851 852 853 class HDHomeRunDeviceIDList : public TransComboBoxSetting 854 { 855 Q_OBJECT 856 public: 857 HDHomeRunDeviceIDList(HDHomeRunDeviceID *deviceid, 858 HDHomeRunIP *cardip, 859 HDHomeRunTunerIndex *cardtuner, 860 HDHomeRunDeviceList *devicelist); 861 862 void fillSelections(QString current); 863 864 virtual void Load(void); 865 866 public slots: 867 void updateDevices(const QString& v); 868 869 private: 870 HDHomeRunDeviceID *_deviceid; 871 HDHomeRunIP *_cardip; 872 HDHomeRunTunerIndex *_cardtuner; 873 HDHomeRunDeviceList *_devicelist; 874 875 QString _oldValue; 876 }; 877 878 class HDHomeRunDeviceID : public LabelSetting, public CaptureCardDBStorage 879 { 880 Q_OBJECT 881 public: 882 HDHomeRunDeviceID(const CaptureCard &parent); 883 884 public slots: 885 void SetIP(const QString & ip); 886 void SetTuner(const QString & tuner); 887 888 private: 889 QString _ip; 890 QString _tuner; 891 }; 892 893 894 791 895 #endif