From 5a043df3d69677d02d4499b6ae6e40d798f2c9d3 Mon Sep 17 00:00:00 2001 From: damien Date: Fri, 4 Jan 2002 18:48:11 +0000 Subject: corrected minor bugs in network (among others bug "modifying read only values") recode upNetwork and downNetwork (it might work, at least if you are lucky); --- perl-install/install_steps.pm | 53 ++++++++++++++++++++------------------ perl-install/my_gtk.pm | 22 +++++++--------- perl-install/network/adsl.pm | 2 +- perl-install/network/netconnect.pm | 30 ++++++++++++++++----- perl-install/network/tools.pm | 2 +- 5 files changed, 63 insertions(+), 46 deletions(-) (limited to 'perl-install') diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 3819e495d..991b4f8c6 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -939,30 +939,30 @@ sub exitInstall { #------------------------------------------------------------------------------ sub hasNetwork { my ($o) = @_; - - $o->{intf} && $o->{netc}{NETWORKING} ne 'no' || $o->{netcnx}{modem}; + $o->{netcnx}{internet_cnx_choice} && $o->{netc}{NETWORKING} ne 'no' } #------------------------------------------------------------------------------ sub upNetwork { my ($o, $pppAvoided) = @_; - foreach (qw(resolv.conf protocols services)) { - symlinkf("$o->{prefix}/etc/$_", "/etc/$_"); - } + symlinkf("$o->{prefix}/etc/$_", "/etc/$_") foreach (qw(resolv.conf protocols services)); modules::write_conf($o->{prefix}); - if ($o->{intf} && $o->{netc}{NETWORKING} ne 'no') { - network::up_it($o->{prefix}, $o->{intf}); - } elsif (!$pppAvoided && $o->{netcnx}{modem} && !$o->{netcnx}{modem}{isUp}) { - eval { modules::load_multi(qw(serial ppp bsd_comp ppp_deflate)) }; - run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "start"); - run_program::rooted($o->{prefix}, "ifup", "ppp0"); - $o->{netcnx}{modem}{isUp} = 1; - } else { - $::testing or return; + if (hasNetwork($o)) { + if ($o->{netc}{internet_cnx_choice} =~ /adsl|network|cable/) { + require network::netconnect; + network::netconnect::start_internet($o); + return 1; + } elsif (!$pppAvoided) { + eval { modules::load_multi(qw(serial ppp bsd_comp ppp_deflate)) }; + run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "start"); + require network::netconnect; + network::netconnect::start_internet($o); + return 1; + } } - 1; + $::testing; } #------------------------------------------------------------------------------ @@ -970,17 +970,20 @@ sub downNetwork { my ($o, $pppOnly) = @_; modules::write_conf($o->{prefix}); - if (!$pppOnly && $o->{intf} && $o->{netc}{NETWORKING} ne 'no') { - network::down_it($o->{prefix}, $o->{intf}); - } elsif ($o->{netcnx}{modem} && $o->{netcnx}{modem}{isUp}) { - run_program::rooted($o->{prefix}, "ifdown", "ppp0"); - run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "stop"); - eval { modules::unload($_) foreach qw(ppp_deflate bsd_comp ppp serial) }; - $o->{netcnx}{modem}{isUp} = 0; - } else { - $::testing or return; + if (hasNetwork($o)) { + if (!$pppOnly && $o->{netc}{internet_cnx_choice} =~ /adsl|network|cable/) { + require network::netconnect; + network::netconnect::stop_internet($o); + return 1; + } else { + require network::netconnect; + network::netconnect::stop_internet($o); + run_program::rooted($o->{prefix}, "/etc/rc.d/init.d/syslog", "stop"); + eval { modules::unload($_) foreach qw(ppp_deflate bsd_comp ppp serial) }; + return 1; + } } - 1; + $::testing; } #------------------------------------------------------------------------------ diff --git a/perl-install/my_gtk.pm b/perl-install/my_gtk.pm index 1b169a796..df5ea2f7d 100644 --- a/perl-install/my_gtk.pm +++ b/perl-install/my_gtk.pm @@ -381,7 +381,7 @@ sub create_pix_text { elsif ($background =~ /#(\d+)#(\d+)#(\d+)/) { $color_background = gtkcolor(map{$_*65535/255}($1, $2, $3)) } elsif (ref($background) eq 'Gtk::Gdk::Pixmap' && $x_back && $y_back) { $backpix = 1 } my $style= new Gtk::Style; - if(ref($font) eq 'Gtk::Gdk::Font') { + if (ref($font) eq 'Gtk::Gdk::Font') { $style->font($font); } else { $font ||= _("-adobe-utopia-medium-r-normal-*-12-*-*-*-p-*-iso8859-*,*-r-*"); @@ -406,8 +406,6 @@ sub create_pix_text { my $i = 0; foreach (@{$lines}) { $pix->draw_string($style->font, $gc_text, ${$widths}[$i], ${$heights}[$i], $_); -# $pix->draw_string($style->font, $gc_text, ${$widths}[$i], ${$ascents}[$i] + ${$heights}[$i], $_); -# $pix->draw_string($style->font, $gc_text, ${$widths}[$i], ${$ascents}[$i] + ${$descents}[$i], $_); $i++; } ($pix, $width, $height); @@ -423,12 +421,10 @@ sub get_text_coord { my @lines; my @widths; my @heights; - my $ascent = $style->font->ascent; - my $descent = $style->font->descent; - print "ascent : $ascent | descent : $descent\n"; + my $height_elem = $style->font->ascent + $style->font->descent; $heights[0] = 0; my $max_width2 = $max_width; - my $height = $heights[0] = $ascent + $descent; + my $height = $heights[0] = $height_elem; my $width = 0; my $flag = 1; my @t = split(' ', $text); @@ -436,7 +432,7 @@ sub get_text_coord { my $l = $style->font->string_width($_ . if_(!$flag, " ")); if ($width + $l > $max_width2 && !$flag) { $flag = 1; - $height += $ascent + $descent + 1; + $height += $height_elem + 1; $heights[$idx+1] = $height; $widths[$idx] = $centeredx && !$can_be_smaller ? (max($max_width2-$width, 0))/2 : 0; $width = 0; @@ -448,7 +444,7 @@ sub get_text_coord { $l <= $max_width2 or $max_width2 = $l; $width <= $real_width or $real_width = $width; } - $height += $ascent + $descent; + $height += $height_elem; $height < $real_height or $real_height = $height; $width = $max_width; @@ -457,8 +453,8 @@ sub get_text_coord { $real_width > $max_width && $can_be_greater and $width = $real_width; $real_height < $max_height && $can_be_smaller and $height = $real_height; $real_height > $max_height && $can_be_greater and $height = $real_height; - if($centeredy) { - my $dh = ($height-$real_height)/2 + ($ascent+$descent)/2; + if ($centeredy) { + my $dh = ($height-$real_height)/2 + ($height_elem)/2; @heights = map { $_ + $dh } @heights; } ($width, $height, \@lines, \@widths, \@heights) @@ -469,7 +465,7 @@ sub fill_tiled { my ($x2, $y2) = (0, 0); while (1) { $x2 = 0; - while(1) { + while (1) { $pix->draw_pixmap($w->style->bg_gc('normal'), $bitmap, 0, 0, $x2, $y2, $x_back, $y_back); $x2 += $x_back; @@ -506,7 +502,6 @@ sub gtkicons_labels_widget { ($dx, $dy) = (max($width, $x_round), $y_round + $height); $darea->set_usize($dx, $dy); $dbl_area = new Gtk::Gdk::Pixmap($darea->window, max($width, $x_round), $y_round + $height); - #$dbl_area->draw_rectangle($darea->style->black_gc, 1, 0, 0, 500, 500); fill_tiled($darea, $dbl_area, $background, $x_back2, $y_back2, $dx, $dy); print " coord : $dx - $icon_width\n"; $dbl_area->draw_pixmap($darea->style->bg_gc('normal'), @@ -531,6 +526,7 @@ sub gtkicons_labels_widget { $fixed->signal_connect( size_allocate => sub { my ($dx, $dy) = ($fixed->allocation->[2], $fixed->allocation->[3]); foreach (@tab) { + $fixed->move(); } }); $fixed->signal_connect( realize => sub { $fixed->window->set_back_pixmap($background, 0) }); diff --git a/perl-install/network/adsl.pm b/perl-install/network/adsl.pm index 10bf80ec2..cb761dff4 100644 --- a/perl-install/network/adsl.pm +++ b/perl-install/network/adsl.pm @@ -7,7 +7,7 @@ use network::ethernet; use modules; use vars qw(@ISA @EXPORT); -use MDK::Common::Globals "network", qw($in $prefix $connect_file $disconnect_file); +use MDK::Common::Globals "network", qw($in $prefix); @ISA = qw(Exporter); @EXPORT = qw(adsl_ask_info adsl_detect adsl_conf adsl_conf_backend); diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm index ea8c1574b..0c7d8fef8 100644 --- a/perl-install/network/netconnect.pm +++ b/perl-install/network/netconnect.pm @@ -17,6 +17,7 @@ use network; use network::tools; use MDK::Common::Globals "network", qw($in $prefix $connect_file $disconnect_file $connect_prog); +@EXPORT = qw(start_internet stop_internet); #- intro is called only in standalone. sub intro { @@ -107,14 +108,19 @@ sub pre_func { undef $::Wizard_no_previous; } +sub init_globals { + my ($in, $prefix) = @_; + MDK::Common::Globals::init( + in => $in, + prefix => $prefix, + connect_file => "/etc/sysconfig/network-scripts/net_cnx_up", + disconnect_file => "/etc/sysconfig/network-scripts/net_cnx_down", + connect_prog => "/etc/sysconfig/network-scripts/net_cnx_pg" ); +} + sub main { my ($prefix, $netcnx, $netc, $mouse, $in, $intf, $first_time, $direct_fr, $noauto) = @_; - MDK::Common::Globals::init( - in => $in, - prefix => $prefix, - connect_file => "/etc/sysconfig/network-scripts/net_cnx_up", - disconnect_file => "/etc/sysconfig/network-scripts/net_cnx_down", - connect_prog => "/etc/sysconfig/network-scripts/net_cnx_pg" ); + init_globals ($in, $prefix); $netc->{minus_one}=0; #When one configure an eth in dhcp without gateway $::isInstall and $in->set_help('configureNetwork'); $::isStandalone and read_net_conf($prefix, $netcnx, $netc); # REDONDANCE with intro. FIXME @@ -589,6 +595,18 @@ sub set_net_conf { setVarsInShMode("$prefix/etc/sysconfig/draknet.netc", 0600, $netc); #- doesn't work, don't know why } +sub start_internet { + my ($o) = @_; + init_globals ($o, $o->{prefix}); + run_program::rooted($prefix, $connect_file); +} + +sub stop_internet { + my ($o) = @_; + init_globals ($o, $o->{prefix}); + run_program::rooted($prefix, $disconnect_file); +} + #--------------------------------------------- # WONDERFULL pad #--------------------------------------------- diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm index 0657e46be..e5ba822b7 100644 --- a/perl-install/network/tools.pm +++ b/perl-install/network/tools.pm @@ -4,7 +4,7 @@ use common; use run_program; use c; use vars qw(@ISA @EXPORT); -use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_prog $connect_file $disconnect_file); +use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_prog $connect_file); @ISA = qw(Exporter); @EXPORT = qw(write_cnx_script write_secret_backend write_initscript ask_connect_now connect_backend disconnect_backend read_providers_backend ask_info2 type2interface connected connected_bg connected2 disconnected); -- cgit v1.2.1