summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakxtv
blob: e7d35c227169e1b36d19052957e7b88f1bfe293c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'>56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
#!/usr/bin/perl
# DrakxTV
# $Id$

# Copyright (C) 2002 MandrakeSoft (tvignaud@mandrakesoft.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# If we ever want to autoconf the tv card at install time, we should
# make a package out of this.
# Maybe we'll have to for harddrake2
#
#package tvdrake;

use lib qw(/usr/lib/libDrakX);

use standalone;     #- warning, standalone must be loaded very first, for 'explanations'

use interactive;
use strict;
use detect_devices;
use lang;
use log;
use common;

/-h/ and die "usage: drakxtv [-h] [--help] [--no-guess]\n";

$::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\w+) (\w+)/;
my $in = 'interactive'->vnew();

sub scan4channels {
#    xawtv has been installed by DrakX when/if it's detected a
#    tv card.
#    In the future, we might try to install xawtv if it'sn't there
#    as we're just a, xawtv wraper
#    -x "/usr/bin/scantv" or $in->do_pkgs->install('xawtv');
#    -x "/usr/bin/scantv" or { 
#{	   exec {'consolehelper'} $0, ("urpmi", "xawtv") or die _("consolehelper missing");
#    };
    if (! -x "/usr/bin/scantv") {
#	standalone::explanations("package xawtv isn't installed");
	   $in->ask_warn("XawTV isn't installed!", 
				  formatAlaTeX(_("XawTV isn't installed!


If you do have a TV card but DrakX has neither detected it (no bttv
module in \"/etc/modules\") nor installed xawtv, please send the
results of \"lspcidrake -v -f\" to \"install\@mandrakesoft.com\"
with subject \"undetected TV card\".


You can install it by typing \"urpmi xawtv\" as root, in a console.")));
	   
    } else {
	   my ($ftable_id, $norm);

#   my %freqtables = map {$i=$_;$i =~ s/ (.*)/-\1/;_($_) => $i} (...)
#   this table must be checked on each xawtv release :
	   my %freqtables = 
		  ("us-bcast" => _("USA (broadcast)"), "us-cable" => _("USA (cable)"), "us-cable-hrc" => _("USA (cable-hrc)"), "canada-cable" => _("Canada (cable)"),
		   "japan-bcast" => _("Japan (broadcast)"), "japan-cable" => _("Japan (cable)"), "china-bcast" => _("China (broadcast)"),
		   "europe-west" => _("West Europe"), "europe-east" => _("East Europe"), "italy" => _("Italy"), "ireland" => _("Ireland"), "france" => _("France [SECAM]"),
		   "newzealand" => _("Newzealand"), "australia" => _("Australia"),
		   "southafrica" => _("South Africa"),
		   "argentina" => _("Argentina"),
		   -1 =>_("All")
		   );
#   Info: HRC means "Harmonically Related Carrier"

	   # default to pal since most people use that
	   $norm = "PAL";

	   if(! /--no-guess/) {
		  my %countries =
			 (
			  "ar" => [ "argentina" ],
			  "au" => [ "australia" ],
			  "(br|fr)" => ["france", "SECAM"],
			  "ca" => [ "canada-cable" ],
			  "(ga|ie)" => [ "ireland" ],
			  "it" => [ "italy" ],
			  "jp" => [ "japan-bcast", "NTSC-JP"],
			  "nz" => [ "newzealand" ],
			  "(at|be|ch|de|eu|gb|se)" => [ "europe-west" ],
			  "us" => [ "us-bcast", "NTSC" ],
			  "za" => [ "southafrica" ],
			  "(zh|TW|Big5|CN.GB2312|CN)" => [ "china-bcast" ]
			  );

		  ($_) = lang::read('', $>);
		  foreach my $i (keys %countries) {
			 if (/($i|$i.UTF-8)$/i) {
				my $tbl = $countries{$i};
				$ftable_id = $tbl->[0];
				$norm = $tbl->[1] if ($tbl->[1]);
			 }
		  }
		  log::l("[drakxtv] guess lang=>$_, norm=>$norm, area=>$ftable_id");
	   }

	   if ($in->ask_from("TVdrake", _("Please,\ntype in your tv norm and country"),
					 [
					  { label => _("TV norm :"), val => \$norm, list => ["NTSC", "NTSC-JP","PAL", "PAL-M", "PAL-N", "PAL-NC", "SECAM"], type => 'combo'},
					  { label => _("Area :"), val => \$ftable_id, list => [keys %freqtables], format => sub { $freqtables{$_[0]} }, sort => 1},
					  ]
					 ))
	   {   my $wait = $in->wait_message(_('Please wait'),
								 _("Scanning for TV channels in progress ..."));
#       we provide scantv a bogus table (france) which will
#       will be ignored since "All" is selected (because of -a)
		  $ftable_id = "france -a " if ($ftable_id eq -1);
		  # Note that this'll be broken if/when we implement interactive_qt
		  my $use_X =$in->isa('interactive_gtk') && -x "/usr/X11R6/bin/xvt";
		  my $home = $ENV{HOME};
		  my $i=system ( (($use_X ) ?
					   "xvt -T '"._("Scanning for TV channels")." ...' -e ":"")
					  . "scantv -n $norm -f $ftable_id -o $home/.xawtv".(($use_X )?"":" &>$home/tmp/scantv.log;"));
		  if ($i) {
			 $in->ask_warn(_("There was an error while scanning for TV channels"),
						_("XawTV isn't installed!")); }
		  else {
			 standalone::explanations("created file $home/.xawtv");
			   $in->ask_warn(_("Have a nice day!"),
						  _("Now, you can run xawtv (under X Window!) !\n")) if (! $use_X);
		    };
		  
	   };
    }
}


if ( grep { $_->{media_type} eq 'MULTIMEDIA_VIDEO' } detect_devices::probeall(1)) {
    scan4channels();
    $in->exit(0);
} else {
    $in->ask_warn(_("No TV Card detected!"), formatAlaTeX(
											   _("No TV Card has been detected on your machine. Please verify that a Linux-supported Video/TV Card is correctly plugged in.


You can visit our hardware database at:


http://www.linux-mandrake.com/en/hardware.php3")));
}


# TODO :
# - offer to sort channels after
# - use Video-Capture-V4l-0.221 ?
# - configure kwintv and zapping ? => they've already wizards :-(
# - install xawtv if needed through consolhelper