Ticket #541: videosource.2.patch
File videosource.2.patch, 9.3 KB (added by , 18 years ago) |
---|
-
videosource.h
16 16 17 17 class SignalTimeout; 18 18 class ChannelTimeout; 19 class UseEIT; 19 20 20 21 typedef QMap<int,QString> InputNames; 21 22 … … 105 106 const VideoSource& parent; 106 107 }; 107 108 108 class RegionSelector: public ComboBoxSetting, public TransientStorage {109 Q_OBJECT110 public:111 RegionSelector() {112 setLabel(QObject::tr("Region"));113 fillSelections();114 };115 116 public slots:117 void fillSelections();118 };119 120 class ProviderSelector: public ComboBoxSetting, public TransientStorage {121 Q_OBJECT122 public:123 ProviderSelector(const QString& _grabber) :124 grabber(_grabber) { setLabel(QObject::tr("Provider")); };125 126 public slots:127 void fillSelections(const QString& location);128 129 protected:130 QString grabber;131 };132 133 109 class FreqTableSelector: public ComboBoxSetting, public VSSetting { 134 110 Q_OBJECT 135 111 public: … … 185 161 int source; 186 162 }; 187 163 188 class XMLTV_uk_config: public VerticalConfigurationGroup { 164 class XMLTV_generic_config: public VerticalConfigurationGroup 165 { 189 166 public: 190 XMLTV_ uk_config(const VideoSource& _parent);167 XMLTV_generic_config(const VideoSource& _parent, QString _grabber); 191 168 192 169 virtual void save(); 193 170 194 171 protected: 195 172 const VideoSource& parent; 196 RegionSelector* region; 197 ProviderSelector* provider; 173 QString grabber; 198 174 }; 199 175 200 class XMLTV_generic_config: public LabelSetting { 176 class EITOnly_config: public VerticalConfigurationGroup 177 { 201 178 public: 202 XMLTV_generic_config(const VideoSource& _parent, QString _grabber); 203 204 virtual void load() {}; 179 EITOnly_config(const VideoSource& _parent); 205 180 virtual void save(); 206 207 181 protected: 208 const VideoSource& parent; 209 QString grabber; 182 UseEIT *useeit; 210 183 }; 211 184 212 class EITOnly_config: public LabelSetting213 {214 public:215 EITOnly_config();216 217 virtual void load() {};218 virtual void save() {};219 };220 221 185 class XMLTVConfig: public VerticalConfigurationGroup, 222 186 public TriggeredConfigurationGroup { 223 187 public: -
videosource.cpp
696 696 addChild(lp); 697 697 698 698 addChild(lineupselector = new DataDirectLineupSelector(parent)); 699 addChild(new UseEIT(parent)); 699 700 700 701 connect(button, SIGNAL(pressed()), 701 702 this, SLOT(fillDataDirectLineupSelector())); … … 707 708 userid->getValue(), password->getValue(), source); 708 709 } 709 710 710 void RegionSelector::fillSelections()711 {712 clearSelections();713 714 QString command = QString("tv_grab_uk --configure --list-regions");715 FILE* fp = popen(command.ascii(), "r");716 717 if (fp == NULL)718 {719 perror(command.ascii());720 return;721 }722 723 QFile f;724 f.open(IO_ReadOnly, fp);725 for (QString line ; f.readLine(line, 1024) > 0 ; )726 {727 addSelection(line.stripWhiteSpace());728 }729 730 f.close();731 fclose(fp);732 }733 734 void ProviderSelector::fillSelections(const QString& location)735 {736 QString waitMsg = QString("Fetching providers for %1... Please be patient.")737 .arg(location);738 VERBOSE(VB_GENERAL, waitMsg);739 740 MythProgressDialog pdlg(waitMsg, 2);741 742 clearSelections();743 744 // First let the final character show up...745 qApp->processEvents();746 747 // Now show our progress dialog.748 pdlg.show();749 750 QString command = QString("%1 --configure --postalcode %2 --list-providers")751 .arg(grabber)752 .arg(location);753 754 FILE* fp = popen(command.ascii(), "r");755 756 if (fp == NULL)757 {758 pdlg.Close();759 VERBOSE(VB_GENERAL, "Failed to retrieve provider list");760 761 MythPopupBox::showOkPopup(gContext->GetMainWindow(),762 QObject::tr("Failed to retrieve provider list"),763 QObject::tr("You probably need to update XMLTV."));764 qApp->processEvents();765 766 perror(command.ascii());767 return;768 }769 770 // Update our progress771 pdlg.setProgress(1);772 773 QFile f;774 f.open(IO_ReadOnly, fp);775 for (QString line ; f.readLine(line, 1024) > 0 ; )776 {777 QStringList fields = QStringList::split(":", line.stripWhiteSpace());778 addSelection(fields.last(), fields.first());779 }780 781 pdlg.setProgress( 2 );782 pdlg.Close();783 784 f.close();785 fclose(fp);786 }787 788 XMLTV_uk_config::XMLTV_uk_config(const VideoSource& _parent)789 : VerticalConfigurationGroup(false, false), parent(_parent)790 {791 setLabel(QObject::tr("tv_grab_uk configuration"));792 region = new RegionSelector();793 addChild(region);794 795 provider = new ProviderSelector("tv_grab_uk");796 addChild(provider);797 798 connect(region, SIGNAL(valueChanged(const QString&)),799 provider, SLOT(fillSelections(const QString&)));800 }801 802 void XMLTV_uk_config::save()803 {804 QString waitMsg(QObject::tr("Please wait while MythTV retrieves the "805 "list of available channels\n. You "806 "might want to check the output as it\n"807 "runs by switching to the terminal from "808 "which you started\nthis program."));809 MythProgressDialog pdlg( waitMsg, 2 );810 VERBOSE(VB_GENERAL, QString("Please wait while MythTV retrieves the "811 "list of available channels"));812 pdlg.show();813 814 QString filename = QString("%1/%2.xmltv")815 .arg(MythContext::GetConfDir()).arg(parent.getSourceName());816 QString command = QString(817 "tv_grab_uk --config-file '%1' --configure --retry-limit %2 "818 "--retry-delay %3 --postalcode %4 --provider %5 "819 "--auto-new-channels add")820 .arg(filename)821 .arg(2)822 .arg(30)823 .arg(region->getValue())824 .arg(provider->getValue());825 826 pdlg.setProgress(1);827 828 int ret = system(command);829 if (ret != 0)830 {831 VERBOSE(VB_GENERAL, command);832 VERBOSE(VB_GENERAL, QString("exited with status %1").arg(ret));833 MythPopupBox::showOkPopup(gContext->GetMainWindow(),834 QObject::tr("Failed to retrieve channel "835 "information."),836 QObject::tr("MythTV was unable to retrieve "837 "channel information for your "838 "provider.\nPlease check the "839 "terminal window for more "840 "information"));841 }842 843 pdlg.setProgress( 2 );844 pdlg.Close();845 }846 847 711 XMLTV_generic_config::XMLTV_generic_config(const VideoSource& _parent, 848 712 QString _grabber) 849 713 : parent(_parent), grabber(_grabber) 850 714 { 851 setLabel(grabber); 852 setValue(QObject::tr("Configuration will run in the terminal window")); 715 setUseLabel(false); 716 setUseFrame(false); 717 718 TransLabelSetting *label = new TransLabelSetting(); 719 label->setLabel(grabber); 720 label->setValue(QObject::tr("Configuration will run in the terminal window")); 721 addChild(label); 722 addChild(new UseEIT(parent)); 853 723 } 854 724 855 725 void XMLTV_generic_config::save() 856 726 { 727 VerticalConfigurationGroup::save(); 857 728 QString waitMsg(QObject::tr("Please wait while MythTV retrieves the " 858 729 "list of available channels.\nYou " 859 730 "might want to check the output as it\n" … … 918 789 pdlg.Close(); 919 790 } 920 791 921 EITOnly_config::EITOnly_config( )792 EITOnly_config::EITOnly_config(const VideoSource& _parent) 922 793 { 923 setLabel(tr("Use only the transmitted guide data.")); 924 setValue(tr("This will usually only work with ATSC or DVB channels, " 925 "and generally provides data only for the next few days.")); 794 setUseLabel(false); 795 setUseFrame(false); 796 797 useeit = new UseEIT(_parent); 798 useeit->setValue(true); 799 useeit->setVisible(false); 800 addChild(useeit); 801 802 TransLabelSetting *label; 803 label=new TransLabelSetting(); 804 label->setValue(tr("Use only the transmitted guide data.")); 805 addChild(label); 806 label=new TransLabelSetting(); 807 label->setValue(tr("This will usually only work with ATSC or DVB " 808 "channels,")); 809 addChild(label); 810 label=new TransLabelSetting(); 811 label->setValue(tr("and generally provides data only for the next " 812 "few days.")); 813 addChild(label); 926 814 } 927 815 816 void EITOnly_config::save() 817 { 818 // Force this value on 819 useeit->setValue(true); 820 useeit->save(); 821 } 822 928 823 XMLTVConfig::XMLTVConfig(const VideoSource& parent) 929 824 { 930 825 setUseLabel(false); … … 943 838 grabber->addSelection("LxM (United States)", "technovera"); 944 839 945 840 #ifdef USING_DVB_EIT 946 addTarget("eitonly", new EITOnly_config( ));841 addTarget("eitonly", new EITOnly_config(parent)); 947 842 grabber->addSelection("Transmitted guide only (EIT)", "eitonly"); 948 843 #endif 949 844 … … 1009 904 group->addChild(name = new Name(*this)); 1010 905 group->addChild(new XMLTVConfig(*this)); 1011 906 group->addChild(new FreqTableSelector(*this)); 1012 group->addChild(new UseEIT(*this));1013 907 addChild(group); 1014 908 } 1015 909