summaryrefsloggenerated by cgit v1.2.1 (git 2.21.0) at 2024-12-29 00:11:15 +0000 8160626f9dc00c3d74a3'>diffstats
path: root/perl-install/standalone/drakxtv
blob: 345c7534999ba302f0154e017a77cc3e2dbc149b (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
#!/usr/bin/perl
# DrakxTV
# $Id$

# Copyright (C) 2002-2004 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.

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

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

use interactive;
use detect_devices;
use lang;
use log;

my $in = 'interactive'->vnew;

sub scan4channels() {
    # xawtv has been installed by DrakX when/if it's detected a tv
    # card.

    $in->do_pkgs->ensure_binary_is_installed('xawtv', 'scantv');

	   my ($ftable_id, $norm);
        #   this table must be checked on each xawtv release:
	   my %freqtables = 
          ("us-bcast" => N("USA (broadcast)"), "us-cable" => N("USA (cable)"), "us-cable-hrc" => N("USA (cable-hrc)"), "canada-cable" => N("Canada (cable)"),
           "japan-bcast" => N("Japan (broadcast)"), "japan-cable" => N("Japan (cable)"), "china-bcast" => N("China (broadcast)"),
           "europe-west" => N("West Europe"), "europe-east" => N("East Europe"), "italy" => N("Italy"), "ireland" => N("Ireland"), "france" => N("France [SECAM]"),
           "newzealand" => N("Newzealand"), "australia" => N("Australia"),
           "southafrica" => N("South Africa"),
           "argentina" => N("Argentina"),
           "australia-optus" => N("Australian Optus cable TV"),
           -1 => N("All")
          );
        #   Info: HRC means "Harmonically Related Carrier"

        my %countries =
          (
           "AR" => [ "argentina" ],
           "AU" => [ "australia" ],
           "FR" => [ "france", "SECAM" ],
           "CA" => [ "canada-cable", "NTSC" ],
           "IE" => [ "ireland" ],
           "IT" => [ "italy" ],
           "JP" => [ "japan-bcast", "NTSC-JP" ],
           "NZ" => [ "newzealand" ],
           "AT|BE|CH|DE|ES|GB|SE" => [ "europe-west" ],
           "US" => [ "us-bcast", "NTSC" ],
           "ZA" => [ "southafrica" ],
           "CN|TW" => [ "china-bcast" ]
          );

        my $tbl;
        my $locale = lang::read($>);
        $locale->{country} =~ /$_/ and $tbl = $countries{$_} foreach keys %countries;
        if ($tbl) {
            $ftable_id = $tbl->[0];
            $norm = $tbl->[1] if $tbl->[1];
        }
        # default to pal since most people use that
        $norm ||= "PAL";
        log::l("[drakxtv] guess country=>$locale->{country}, norm=>$norm, area=>$ftable_id");
        my %users = map { $_->[6] || $_->[0] => $_->[7] } grep { $_->[2] == 0 || 500 <= $_->[2] } list_passwd();
        my $user;

	   if ($in->ask_from("TVdrake", N("Please,\ntype in your tv norm and country"),
                          [
                           { label => N("TV norm:"), val => \$norm, list => [ "NTSC", "NTSC-JP", "PAL", "PAL-M", "PAL-N", "PAL-NC", "SECAM" ], type => 'combo' },
					  { label => N("Area:"), val => \$ftable_id, list => [keys %freqtables], format => sub { $freqtables{$_[0]} }, sort => 1 },
					  { label => N("User:"), val => \$user, list => [ keys %users ], sort => 1 },
					  ]
					 )) {
            my $_wait = $in->wait_message(N("Please wait"),
								 N("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 = $users{$user}; #ENV{HOME};
		  my $is_bttv_loaded = cat_("/proc/modules");
            # workaround non loaded bttv
		  run_program::run('/sbin/modprobe', 'bttv') if $< == 0 && $is_bttv_loaded !~ /bttv/;
		  my $i = system(($use_X ? "xvt -T '" . N("Scanning for TV channels") . " ...' -e " : "") . 
                           "scantv -n $norm -C /dev/v4l/vbi$::i -c /dev/v4l/video$::i -f $ftable_id -o $home/.xawtv" .
                           ($use_X ? "" : " &>$home/tmp/scantv.log;"));
		  if ($i) {
			 $in->ask_warn(N("Error"), N("There was an error while scanning for TV channels"));
            } else {
			 log::explanations("created file $home/.xawtv");
                $in->ask_warn(N("Have a nice day!"),
                              N("Now, you can run xawtv (under X Window!) !\n")) unless $use_X;
            }
	   }
}

my @devices = detect_devices::getTVcards();
push @devices, { driver => 'bttv', description => 'dummy' } if $::testing && !@devices;
if (@devices) {
    my $not_canceled = 1;
    my $modules_conf;
    # TODO: That need some work for multiples TV cards
    each_index {
	   if (($< == 0 || $::testing) && (grep { detect_devices::isTVcard($_) } @devices)) {
		  require harddrake::v4l;
		  require modules;

		  $modules_conf ||= modules::any_conf->read;
		  $not_canceled &&= harddrake::v4l::config($in, $modules_conf, $_->{driver});
		  $modules_conf->write;
	   }
	   scan4channels() if $not_canceled;
    } @devices
} else {
    $in->ask_warn(N("No TV Card detected!"), formatAlaTeX(
                                                          #-PO: keep the double empty lines between sections, this is formatted a la LaTeX
                                                          N("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")));
}
$in->exit(0) if defined $in;


# 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