[mythtv] tv_grab_uk graphical setup (patch)

Matthew Burnham mythtv-dev@snowman.net
Sun Jan 5 23:18:50 EST 2003


This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C2B510.CF8C0740
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

(I finally figured my lack-of-video problem - esd had grabbed /dev/dsp
without me noticing, grrrrr)

Anyway, I've had a play and added graphical support for Adam Allen's new
tv_grab_uk. Available regions are currently hard coded, though I think
some sort of --list-regions option should be added to tv_grab_uk. It
relies on Adam's patch to mythfilldatabase to actually fetch any data,
as I've only touched the GUI setup stuff. Patch attached.

-- 
Mat Burnham
 

------=_NextPart_000_0007_01C2B510.CF8C0740
Content-Type: application/octet-stream;
	name="tv_grab_uk-setup.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="tv_grab_uk-setup.diff"

Index: libs/libmythtv/videosource.cpp=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /var/lib/cvs/MC/libs/libmythtv/videosource.cpp,v=0A=
retrieving revision 1.9=0A=
diff -u -r1.9 videosource.cpp=0A=
--- libs/libmythtv/videosource.cpp	5 Jan 2003 05:10:09 -0000	1.9=0A=
+++ libs/libmythtv/videosource.cpp	5 Jan 2003 22:41:57 -0000=0A=
@@ -46,13 +46,58 @@=0A=
         .arg(getValue());=0A=
 }=0A=
 =0A=
+void RegionSelector::fillSelections() {=0A=
+    clearSelections();=0A=
+=0A=
+    /*QString command =3D QString("tv_grab_uk --configure =
--list-regions")=0A=
+        .arg(zipcode);=0A=
+    FILE* fp =3D popen(command.ascii(), "r");=0A=
+=0A=
+    if (fp =3D=3D NULL) {=0A=
+        perror("open");=0A=
+        return;=0A=
+    }=0A=
+=0A=
+    QFile f;=0A=
+    f.open(IO_ReadOnly, fp);=0A=
+    for(QString line ; f.readLine(line, 1024) > 0 ; ) {=0A=
+        QStringList fields =3D QStringList::split(":", =
line.stripWhiteSpace());=0A=
+        addSelection(fields.last(), fields.first());=0A=
+    }=0A=
+=0A=
+    f.close();=0A=
+    fclose(fp);*/=0A=
+=0A=
+    // this would be better read in from tv_grab_uk, moreorless, as =
above=0A=
+    addSelection("Anglia");=0A=
+    addSelection("Border");=0A=
+    addSelection("Border North");=0A=
+    addSelection("Carlton");=0A=
+    addSelection("Central");=0A=
+    addSelection("Channel");=0A=
+    addSelection("East Midlands");=0A=
+    addSelection("Grampian");=0A=
+    addSelection("Granada");=0A=
+    addSelection("HTV Wales");=0A=
+    addSelection("HTV West");=0A=
+    addSelection("London");=0A=
+    addSelection("Meridian");=0A=
+    addSelection("Scottish");=0A=
+    addSelection("South East");=0A=
+    addSelection("Tyne Tees");=0A=
+    addSelection("Ulster");=0A=
+    addSelection("Westcountry");=0A=
+    addSelection("Yorkshire");=0A=
+}=0A=
+=0A=
 void ProviderSelector::fillSelections(const QString& zipcode) {=0A=
-    if (zipcode.length() < 5)=0A=
+    if (grabber =3D=3D "tv_grab_na" && zipcode.length() < 5)=0A=
         return;=0A=
 =0A=
     clearSelections();=0A=
 =0A=
-    QString command =3D QString("tv_grab_na --configure --postalcode %1 =
--list-providers")=0A=
+    QString command =3D QString("%1 --configure --postalcode %2 =
--list-providers")=0A=
+        .arg(grabber)=0A=
         .arg(zipcode);=0A=
     FILE* fp =3D popen(command.ascii(), "r");=0A=
 =0A=
@@ -89,6 +134,23 @@=0A=
         cout << command << endl << "exited with status " << ret << endl;=0A=
 }=0A=
 =0A=
+void XMLTV_uk_config::save(QSqlDatabase* db) {=0A=
+    (void)db;=0A=
+=0A=
+    QString filename =3D QString("%1/.mythtv/%2.xmltv")=0A=
+        .arg(getenv("HOME")).arg(parent.getSourceName());=0A=
+    QString command =3D QString("tv_grab_uk --config-file %1 =
--configure --retry-limit %2 --retry-delay %3 --postalcode %4 --provider =
%5 --auto-new-channels add")=0A=
+        .arg(filename)=0A=
+        .arg(2)=0A=
+        .arg(30)=0A=
+        .arg(region->getValue())=0A=
+        .arg(provider->getValue());=0A=
+=0A=
+    int ret =3D system(command);=0A=
+    if (ret !=3D 0)=0A=
+        cout << command << endl << "exited with status " << ret << endl;=0A=
+}=0A=
+=0A=
 void XMLTV_generic_config::save(QSqlDatabase* db) {=0A=
     (void)db;=0A=
 =0A=
@@ -107,8 +169,7 @@=0A=
     if (ret !=3D 0)=0A=
         cout << command << endl << "exited with status " << ret << endl;=0A=
 =0A=
-    if (grabber =3D=3D "tv_grab_uk" || grabber =3D=3D "tv_grab_de" ||=0A=
-        grabber =3D=3D "tv_grab_sn") {=0A=
+    if (grabber =3D=3D "tv_grab_de" || grabber =3D=3D "tv_grab_sn") {=0A=
         cout << "You _MUST_ run 'mythfilldatabase --manual the first =
time, "=0A=
              << "instead\n";=0A=
         cout << "of just 'mythfilldatabase'.  Your grabber does not =
provide\n";=0A=
Index: libs/libmythtv/videosource.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /var/lib/cvs/MC/libs/libmythtv/videosource.h,v=0A=
retrieving revision 1.13=0A=
diff -u -r1.13 videosource.h=0A=
--- libs/libmythtv/videosource.h	5 Jan 2003 05:10:09 -0000	1.13=0A=
+++ libs/libmythtv/videosource.h	5 Jan 2003 22:41:59 -0000=0A=
@@ -34,13 +34,29 @@=0A=
 public: PostalCode() { setLabel("ZIP/postal code"); };=0A=
 };=0A=
 =0A=
+class RegionSelector: public ComboBoxSetting, public TransientStorage {=0A=
+    Q_OBJECT=0A=
+public:=0A=
+    RegionSelector() {=0A=
+        setLabel("Region");=0A=
+        fillSelections();=0A=
+    };=0A=
+=0A=
+public slots:=0A=
+    void fillSelections();=0A=
+};=0A=
+=0A=
 class ProviderSelector: public ComboBoxSetting, public TransientStorage =
{=0A=
     Q_OBJECT=0A=
 public:=0A=
-    ProviderSelector() { setLabel("Provider"); };=0A=
+    ProviderSelector(const QString& _grabber) :=0A=
+        grabber(_grabber) { setLabel("Provider"); };=0A=
 =0A=
 public slots:=0A=
     void fillSelections(const QString& zipcode);=0A=
+=0A=
+protected:=0A=
+    QString grabber;=0A=
 };=0A=
 =0A=
 class XMLTV_na_config: public VerticalConfigurationGroup {=0A=
@@ -50,7 +66,7 @@=0A=
         postalcode =3D new PostalCode();=0A=
         addChild(postalcode);=0A=
 =0A=
-        provider =3D new ProviderSelector();=0A=
+        provider =3D new ProviderSelector("tv_grab_na");=0A=
         addChild(provider);=0A=
 =0A=
         connect(postalcode, SIGNAL(valueChanged(const QString&)),=0A=
@@ -65,6 +81,28 @@=0A=
     ProviderSelector* provider;=0A=
 };=0A=
 =0A=
+class XMLTV_uk_config: public VerticalConfigurationGroup {=0A=
+public:=0A=
+    XMLTV_uk_config(const VideoSource& _parent): parent(_parent) {=0A=
+        setLabel("tv_grab_uk configuration");=0A=
+        region =3D new RegionSelector();=0A=
+        addChild(region);=0A=
+=0A=
+        provider =3D new ProviderSelector("tv_grab_uk");=0A=
+        addChild(provider);=0A=
+=0A=
+        connect(region, SIGNAL(valueChanged(const QString&)),=0A=
+                provider, SLOT(fillSelections(const QString&)));=0A=
+    };=0A=
+=0A=
+    virtual void save(QSqlDatabase* db);=0A=
+=0A=
+protected:=0A=
+    const VideoSource& parent;=0A=
+    RegionSelector* region;=0A=
+    ProviderSelector* provider;=0A=
+};=0A=
+=0A=
 class XMLTV_generic_config: public LabelSetting {=0A=
 public:=0A=
     XMLTV_generic_config(const VideoSource& _parent, QString _grabber):=0A=
@@ -101,7 +139,7 @@=0A=
         addTarget("tv_grab_sn", new XMLTV_generic_config(parent, =
"tv_grab_sn"));=0A=
         grabber->addSelection("tv_grab_sn");=0A=
 =0A=
-        addTarget("tv_grab_uk", new XMLTV_generic_config(parent, =
"tv_grab_uk"));=0A=
+        addTarget("tv_grab_uk", new XMLTV_uk_config(parent));=0A=
         grabber->addSelection("tv_grab_uk");=0A=
 =0A=
         addTarget("tv_grab_uk_rt", new XMLTV_generic_config(parent, =
"tv_grab_uk_rt"));=0A=

------=_NextPart_000_0007_01C2B510.CF8C0740--




More information about the mythtv-dev mailing list