summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakconnect
blob: 5a9e897d840ae836c428bc18d34eea574b8f8ff9 (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
#!/usr/bin/perl

# DrakConnect

# Copyright (C) 1999-2002 MandrakeSoft (damien@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 lib qw(/usr/lib/libDrakX);

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

use interactive;
use common;
use network::netconnect;
use network::ethernet;
use network::tools;
use network;
use c;
use MDK::Common;
use any;
use network::isdn;
use network::adsl;
use MDK::Common::Globals "network", qw($in $prefix $disconnect_file $connect_prog $connect_file $disconnect_file);

my $xpm_path = "/usr/share/libDrakX/pixmaps";
local $_ = join '', @ARGV;
$::isWizard = /--wizard/;

my $netcnx = {};
my $netc = {};
my $intf = {};
my @conx_type = ('modem', 'isdn_internal', 'isdn_external', 'adsl', 'cable', 'lan');

#$::wizard_xpm = "/usr/share/pixmaps/internet.xpm";

my $in = 'interactive'->vnew('su', 'network');
!$::isEmbedded && $in->isa('interactive::gtk') and $::isWizard = 1;
$::Wizard_pix_up = "wiz_drakconnect.png";
$::Wizard_title = "Network & Internet Configuration";

MDK::Common::Globals::init(
	      in => $in,
	      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"
	     );

$::isEmbedded && ref($in) =~ /gtk/ or goto dd;
require Gtk;
init Gtk;
require my_gtk;
import my_gtk qw(:helpers :wrappers);
my $expert_mode = 0;
network::netconnect::read_net_conf('', $netcnx, $netc);
any::load_category_no_message('net', undef);
my @all_cards = network::ethernet::conf_network_card_backend ($netc, $intf, undef, undef, undef, undef);
network::netconnect::load_conf($netcnx, $netc, $intf);

my $window1 = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel;
$window1->signal_connect (delete_event => sub { Gtk->exit(0) });
$window1->set_position(1);
$window1->set_title(N("Network configuration (%d adapters)", @all_cards));
$window1->border_width(10);
$::isEmbedded or $window1->set_usize(500, 400);
my $vbox1 = new Gtk::VBox(0,10);
$window1->add($vbox1);
my $hbox1 = new Gtk::HBox(0,0);
$vbox1->pack_start($hbox1,0,0,0);
$hbox1->pack_start(new Gtk::Label(N("Profile: ")),0,0,0);

my $combo1 = new Gtk::Combo;
$combo1->set_popdown_strings (network::netconnect::get_profiles());
my $old_profile = $netcnx->{PROFILE};
$combo1->entry->set_text($netcnx->{PROFILE} ? $netcnx->{PROFILE} : "default");
$combo1->entry->set_editable(0);
$hbox1->pack_start($combo1,0,0,0);
my $button_del = new Gtk::Button(N("Del profile..."));
$button_del->signal_connect(clicked => sub {
				 my $dialog = new Gtk::Dialog();
				 $dialog->set_position(1);
				 $dialog->vbox->set_border_width(10);
				 $dialog->signal_connect (delete_event => sub { Gtk->main_quit() });
				 $dialog->vbox->pack_start(new Gtk::Label(N("Profile to delete:")),1,1,0);
 				 my $combo_dialog = new Gtk::Combo;
				 $combo_dialog->set_popdown_strings (grep { ! /default/ } network::netconnect::get_profiles());
				 $combo_dialog->entry->set_editable(0);
				 $dialog->vbox->pack_start($combo_dialog,1,1,0);
				 my $bbox_dialog = new Gtk::HButtonBox;
				 $dialog->action_area->add($bbox_dialog);
				 $bbox_dialog->set_layout(-end);
				 my $button_ok = new Gtk::Button N("OK");
				 $button_ok->signal_connect (clicked => sub {
								  network::netconnect::del_profile($netcnx, $combo_dialog->entry->get_text());
								  $netcnx->{PROFILE} eq $combo_dialog->entry->get_text() and $netcnx->{PROFILE} = "default";
								  Gtk->main_quit();
							      });
				 $bbox_dialog->add($button_ok);
				 my $button_cancel = new Gtk::Button N("Cancel");
				 $button_cancel->signal_connect (clicked => sub { Gtk->main_quit() });
				 $bbox_dialog->add($button_cancel);
				 $dialog->show_all;
				 $dialog->set_modal(1);
				 Gtk->main();
				 $dialog->destroy;
				 $combo1->entry->set_text((-e "/etc/sysconfig/network-scripts/drakconnect_conf." . $combo1->entry->get_text) ? $combo1->entry->get_text : "default");
				 $combo1->set_popdown_strings(network::netconnect::get_profiles());
				 apply();
			     });
$hbox1->pack_start($button_del,0,0,5);
$button_del->set_sensitive(network::netconnect::get_profiles() > 1);
my $button_new = new Gtk::Button(N("New profile..."));
$button_new->signal_connect(clicked => sub {
				 my $dialog = new Gtk::Dialog();
				 $dialog->set_position(1);
				 $dialog->vbox->set_border_width(10);
				 $dialog->signal_connect (delete_event => sub { Gtk->main_quit() });
				 $dialog->vbox->pack_start(new Gtk::Label(N("Name of the profile to create (the new profile is created as a copy of the current one) :")),1,1,0);
				 my $entry_dialog = new Gtk::Entry;
				 $dialog->vbox->pack_start($entry_dialog,1,1,0);
				 my $bbox_dialog = new Gtk::HButtonBox;
				 $dialog->action_area->add($bbox_dialog);
				 $bbox_dialog->set_layout(-end);
				 my $button_ok = new Gtk::Button N("OK");
				 $button_ok->signal_connect (clicked => sub {
								  network::netconnect::add_profile($netcnx, $entry_dialog->get_text());
								  $netcnx->{PROFILE} = $entry_dialog->get_text();
								  Gtk->main_quit();
							      });
				 $bbox_dialog->add($button_ok);
				 my $button_cancel = new Gtk::Button N("Cancel");
				 $button_cancel->signal_connect (clicked => sub { Gtk->main_quit() });
				 $bbox_dialog->add($button_cancel);
				 $dialog->show_all;
				 $dialog->set_modal(1);
				 Gtk->main();
				 $dialog->destroy;
				 $combo1->entry->set_text((-e "/etc/sysconfig/network-scripts/drakconnect_conf." . $netcnx->{PROFILE}) ? $netcnx->{PROFILE} : "default");
				 $combo1->set_popdown_strings(network::netconnect::get_profiles());
});
$hbox1->pack_start($button_new,0,0,5);
my $hbox2 = new Gtk::HBox(0,0);
$vbox1->pack_start($hbox2,0,0,0);
$hbox2->pack_start(new Gtk::Label(N("Hostname: ")),0,0,0);
my $hostname = chomp_(`hostname`);
my $label_host = new Gtk::Label($hostname);
$hbox2->pack_start($label_host,0,0,0);

#$vbox1->pack_start(new Gtk::HSeparator,1,1,5);

my $frame1 = new Gtk::Frame (N("Internet access"));
$vbox1->pack_start($frame1,1,1,0);
my $vbox_frame1 = new Gtk::VBox(0,0);
$vbox_frame1->set_border_width(5);
$frame1->add($vbox_frame1);
my $table1 = new Gtk::Table (3,3, 0);
$table1->set_border_width(5);
$table1->set_row_spacings(5);
$table1->set_col_spacings(5);
#$table1->border_width(10);
$vbox_frame1->pack_start($table1,1,1,0);
#attach (table, child, left_attach, right_attach, top_attach, bottom_attach, xoptions, yoptions, xpadding, ypadding)
#$table->attach($button[0], 0, 1, 0, 1, {expand=>1,fill=>1}, {expand=>1,fill=>1},0,0);
$table1->attach(new Gtk::Label(N("Type:")), 0, 1, 0, 1, 'fill', 'fill',0,0);
my $label4 = new Gtk::Label($netcnx->{type});
$table1->attach($label4, 1, 2, 0, 1, 'fill', 'fill',0,0);
my $label5 = new Gtk::Label($netcnx->{type} eq 'lan' ? N("Gateway:") : N("Interface:"));
$table1->attach($label5, 0, 1, 1, 2, 'fill', 'fill',0,0);
my $label6 = new Gtk::Label($netcnx->{type} eq 'lan' ? $netc->{GATEWAY} : $netcnx->{NET_INTERFACE});
$table1->attach($label6, 1, 2, 1, 2, 'fill', 'fill',0,0);
my $isconnected = -1;
#-sub connected_local {
#-    print "in connected local\n";
#-    my $w = $in->wait_message('', N("Testing your connection..."), 1);
#-    Gtk->main_iteration while Gtk->events_pending;
#-    $isconnected = connected();
#-}
my $label7 = new Gtk::Label(N("Status:"));
$table1->attach($label7, 0, 1, 2, 3, 'fill', 'fill',0,0);
my $label8 = new Gtk::Label(N("Testing your connection..."));
$table1->attach($label8, 1, 2, 2, 3, 'fill', 'fill',0,0);

my $warning_label1 = new Gtk::Label("");
$vbox_frame1->pack_start($warning_label1,0,0,0);
my $button2 = new Gtk::Button(N("Wait please"));
$button2->set_sensitive(0);
$button2->signal_connect(clicked => sub {
			     if (!$isconnected && cat_($connect_prog) =~ m|/usr/bin/kppp| && -e '/usr/bin/kppp') {
				 run_program::rooted($prefix, "/usr/bin/kppp &");
			     } elsif (!$isconnected) {
				 connect_backend();
			     } else {
				 disconnect_backend();
			     }
			     update2();
			 });

$table1->attach($button2, 2, 3, 2, 3, 'fill', 'fill',0,0);

#$table1->attach($button1, 2, 3, 1, 2, 'fill', 'fill',0,0);

my $hbox_frame1_button = new Gtk::HBox(0,0);
my $button1 = new Gtk::Button(N("Configure Internet Access..."));
$button1->signal_connect(clicked => [ \&configure_net, '', $netcnx, $netc, $intf]);
$hbox_frame1_button->pack_start($button1, 0, 0, 0);
$vbox_frame1->pack_start($hbox_frame1_button,0,0,0);

#$vbox1->pack_start(new Gtk::HSeparator,1,1,5);

my $frame2 = new Gtk::Frame (N("LAN configuration"));
$vbox1->pack_start($frame2,1,1,0);
my $vbox2 = new Gtk::VBox(0,0);
$vbox2->set_border_width(5);
$frame2->add($vbox2);
my $clist1 = new_with_titles Gtk::CList("", N("Interface"), N("IP address"), N("Protocol"), N("Driver"), N("State"));
$clist1->set_column_auto_resize($_,1) foreach (0..4);
$clist1->column_titles_passive();
$clist1->set_shadow_type('etched_out');
$vbox2->pack_start($clist1, 0, 0, 5);
#$scrolled1->add_with_viewport($table2);

my $ip_regexp = qr/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;

build_clist();

my $hbox3 = new Gtk::HBox(0,0);
my $button3 = new Gtk::Button(N("Configure Local Area Network..."));
$button3->signal_connect(clicked => [ \&configure_lan, '', $netcnx, $netc, $intf]);
$hbox3->pack_start($button3, 0, 0, 0);
$vbox2->pack_start($hbox3, 0, 0, 0);

#$vbox1->pack_start(new Gtk::HSeparator,0,0,5);

my $bbox0 = new Gtk::HButtonBox;
$vbox1->pack_start($bbox0,0,0,0);
$bbox0->set_layout(-end);


$bbox0->add(new Gtk::Label(N("Click here to launch the wizard ->")));
my $button_wizard = new Gtk::Button N("Wizard...");
$button_wizard->signal_connect(clicked => sub {
				     $::isWizard = 1;
				     system("drakconnect --wizard");
# netconnect::intro('', $netcnx, $in);
				     $combo1->entry->set_text((-e "/etc/sysconfig/network-scripts/drakconnect_conf." . $combo1->entry->get_text) ? $combo1->entry->get_text : "default");
				     network::netconnect::load_conf($netcnx, $netc, $intf);
				     update();
				 });
$bbox0->add($button_wizard);

$vbox1->pack_start(new Gtk::HSeparator,0,0,5);

my $bbox1 = new Gtk::HButtonBox;
$vbox1->pack_start($bbox1,0,0,0);
$bbox1->set_layout(-end);
#$bbox1->set_border_width(5);

my $button_expert = new Gtk::Button N("Expert Mode");
$button_expert->signal_connect (clicked => sub {
				     foreach ($button1, $button3) { $expert_mode ? $_->hide() : $_->show() }
				     $button_expert->child->set($expert_mode ? N("Expert Mode") : N("Normal Mode"));
				     $expert_mode = !$expert_mode;
				 });
$bbox1->add($button_expert);

my $button_apply = new Gtk::Button N("Apply");
$button_apply->signal_connect (clicked => sub {
				 apply();
			     });
$button_apply->set_sensitive(0);
$bbox1->add($button_apply);

my $button_cancel = new Gtk::Button N("Cancel");
$button_cancel->signal_connect (clicked => sub {
				     $combo1->entry->set_text($old_profile);
				     update();
				     quit_global();
				 });
$bbox1->add($button_cancel);
my $button_ok = new Gtk::Button N("OK");
$button_ok->signal_connect (clicked => sub {
				 my $dialog = new Gtk::Dialog();
				 $dialog->set_position(1);
				 $dialog->vbox->set_border_width(10);
				 my $label = new Gtk::Label(N("Please Wait... Applying the configuration"));
				 $dialog->signal_connect (delete_event => sub { Gtk->main_quit() });
				 $dialog->vbox->pack_start($label,1,1,20);
				 $dialog->show_all;
				 Gtk->main_iteration while Gtk->events_pending;
				 apply();
				 $dialog->destroy;
				 update();
				 quit_global();
			     });
$bbox1->add($button_ok);
$combo1->entry->signal_connect('changed', sub {
#				    connected() and disconnect_backend();
				    network::netconnect::set_profile($netcnx, $combo1->entry->get_text());
				    network::netconnect::load_conf($netcnx, $netc, $intf);
				    $netcnx->{$_} = $netc->{$_} foreach qw(NET_DEVICE NET_INTERFACE);
				    network::netconnect::set_net_conf($netcnx, $netc);
				    update();
				    $button_apply->set_sensitive(1);
				});

$window1->show_all();
$_->hide foreach ($button1, $button3);
Gtk->main_iteration while Gtk->events_pending;
$::isEmbedded and kill 'USR2', $::CCPID;
my $tag = Gtk->timeout_add(4000, \&update2);
Gtk->main;
Gtk->exit(0);

dd:
network::netconnect::intro('', $netcnx, $in);
$in->exit(0);

sub build_clist {
    foreach my $i (0..$#all_cards) {
	my $ip;
	if (-e "/sbin/ifconfig") {
	    local $_ = `LC_ALL=C LANG=C LANGUAGE=C LC_MESSAGES=C /sbin/ifconfig "eth$i"`;
	    /inet addr\:$ip_regexp/; $ip = if_($1 && $2 && $3, "$1.$2.$3.$4");
	    $_ = `LC_ALL=C LANG=C LANGUAGE=C LC_MESSAGES=C /sbin/ifconfig`;
	    $state = /eth$i/ ? "up" : "down";
	} else { $ip = $intf->{"eth$_"}{IPADDR}; $state = "n/a" }
	$clist1->append("", "eth$i", $ip , $intf->{"eth$i"}{BOOTPROTO}, $all_cards[$i]->[1], $state);
	$clist1->set_pixmap ($i, 0, gtkcreate_png("eth_card_mini2.png"));

	$clist1->set_selectable($i, 0);
    }
}

sub apply {
    $old_profile = $netcnx->{PROFILE} ? $netcnx->{PROFILE} : "default";
    network::netconnect::save_conf($netcnx, $netc, $intf);

    $netcnx->{type} eq 'modem' and any::pppConfig($in, $netcnx->{$netcnx->{type}}, '');
    $netcnx->{type} eq 'isdn_internal' and network::isdn::isdn_write_config_backend($netcnx->{$netcnx->{type}}, 1, $netc, $netcnx); #$light
    $netcnx->{type} eq 'isdn_external' and any::pppConfig($in, $netcnx->{$netcnx->{type}}, '');
    my $a = $netcnx->{type};
    $a =~ s/adsl_//;
    $netcnx->{type} =~ 'adsl' and network::adsl::adsl_conf_backend($netcnx->{$netcnx->{type}}, $netc, $a, $netcnx);

    $netcnx->{dhcp_client} and $netc->{dhcp_client} = $netcnx->{dhcp_client};
    network::configureNetwork2($in, $prefix, $netc, $intf);
    $netcnx->{type} =~ /adsl/ or system("/sbin/chkconfig --del adsl 2> /dev/null");
    $netcnx->{type} !~ /adsl_p/ and system("$prefix/etc/rc.d/init.d/network restart");
    $button_apply->set_sensitive(0);
}

sub ethisup { `LC_ALL=C LANG=C LANGUAGE=C LC_MESSAGES=C /sbin/ifconfig` =~ /eth$_[0]/ }

my $to_update;
sub update {
    my $h = chomp_(`hostname`);
    $label_host->set ($h);
    $label4->set($netcnx->{type});
    $label5->set($netcnx->{type} eq 'lan' ? N("Gateway:") : N("Interface:"));
    $label6->set($netcnx->{type} eq 'lan' ? $netc->{GATEWAY} : $netcnx->{NET_INTERFACE});
    $clist1->freeze();
    $clist1->clear();
    build_clist();
    $clist1->thaw();
    $button_del->set_sensitive(network::netconnect::get_profiles() > 1);
    $isconnected !=-1 or return 1;
    $label8->set($isconnected ? N("Connected") : N("Not connected"));
    $button2->child->set($isconnected ? N("Disconnect...") : N("Connect..."));
    $button2->set_sensitive(1);
    1;
}

sub in_ifconfig {
    my ($intf) = @_;
    -e '/sbin/ifconfig' or return 1;
    $intf eq '' and return 1;
    `/sbin/ifconfig` =~ /$intf/;
}

sub update2 {
    undef $to_update;
    connected_bg(\$to_update);
    if (defined $to_update) {
        $isconnected = $to_update;
        if ($isconnected != -1) {
            if ($isconnected && !in_ifconfig($netcnx->{NET_INTERFACE})) {
                $warning_label1->set(N("Warning, another Internet connection has been detected, maybe using your network"));
                $isconnected = 0;
            } else { $warning_label1->set("") }
            $label8->set($isconnected ? N("Connected") : N("Not connected"));
            $button2->child->set($isconnected ? N("Disconnect...") : N("Connect..."));
            $button2->set_sensitive(1);
        }
    }
    update();
    1;
}

sub quit_global {
    $::isEmbedded ? kill('USR1', $::CCPID) : Gtk->exit(0);
}

sub configure_lan {
    my (undef, $prefix, $netcnx, $netc, $intf) = @_;
    my $window = new Gtk::Window -toplevel;

    my @card_tab;

    if (@all_cards < 1) {
	my $dialog = new Gtk::Dialog();
	$dialog->set_position(1);
	$dialog->vbox->set_border_width(10);
	$dialog->signal_connect (delete_event => sub { Gtk->main_quit() });
	$dialog->vbox->pack_start(new Gtk::Label(N("You don't have any configured interface.
Configure them first by clicking on 'Configure'")),1,1,0);
	my $bbox_dialog = new Gtk::HButtonBox;
	$dialog->action_area->add($bbox_dialog);
	$bbox_dialog->set_layout(-end);
	my $button_ok = new Gtk::Button N("OK");
	$button_ok->signal_connect (clicked => sub { Gtk->main_quit() });
	$bbox_dialog->add($button_ok);
	$dialog->show_all;
	$dialog->set_modal(1);
	Gtk->main();
	$dialog->destroy;
	return;
    }

    $window->set_policy (1, 1, 1);
    $window->signal_connect (delete_event => sub { Gtk->main_quit });
    $window->set_position(1);
    $window->set_title(N("LAN configuration"));
    $window->border_width(10);
    my $vbox1 = new Gtk::VBox(0,0);
    $window->add($vbox1);
    $vbox1->pack_start(new Gtk::Label(N("LAN Configuration")),0,1,0);
    my $notebook = new Gtk::Notebook;
    $vbox1->pack_start($notebook,0,1,0);
    my @eth_data;
    foreach (0..$#all_cards) {
	my @infos;
	my @conf_data;
	$card_tab[2*$_] = \@infos;
	$card_tab[2*$_+1] = \@conf_data;
	my $vbox_local = new Gtk::VBox(0,0);
	$vbox_local->set_border_width(10);
	$vbox_local->pack_start(new Gtk::Label(N("Adapter %s: %s", $_+1 , "eth$_")),1,1,0);
	#	Eth${_}Hostname = $netc->{HOSTNAME}
	#       Eth${_}HostAlias = " . do { $netc->{HOSTNAME} =~ /([^\.]*)\./; $1 } . "
	#	Eth${_}Driver = $all_cards[$_]->[1]
        @conf_data = ([N("IP address"), \$intf->{"eth$_"}{IPADDR}],
			 [N("Netmask"), \$intf->{"eth$_"}{NETMASK}],
			 [N("Boot Protocol"), \$intf->{"eth$_"}{BOOTPROTO}, ["static", "dhcp", "bootp"]],
			 [N("Started on boot"), \$intf->{"eth$_"}{ONBOOT} , ["yes", "no"]],
			 [N("DHCP client"), \$netcnx->{dhcp_client}]
			);
	my $i = 0;
	foreach my $j (@conf_data) {
	    $infos[2*$i] = new Gtk::HBox(0,0);
	    my $l = new Gtk::Label($j->[0]);
	    $l->set_justify('left');
	    $infos[2*$i]->pack_start($l,1,1,0);
	    $vbox_local->pack_start($infos[2*$i],0,0,0);
	    if (defined $j->[2]) {
		my $c = new Gtk::Combo();
		$c->set_popdown_strings(@{$j->[2]});
		$infos[2*$i+1] = $c->entry;
		$infos[2*$i+1]->set_editable(0);
		$infos[2*$i]->pack_start($c,0,0,0);
	    } else {
		$infos[2*$i+1] = new Gtk::Entry();
		$infos[2*$i]->pack_start($infos[2*$i+1],0,0,0);
	    }
	    $infos[2*$i+1]->set_text(${$j->[1]});
	    $i++;
	}
	my $c = $_;
	my $widget_temp;
	if (-e "$prefix/etc/sysconfig/network-scripts/ifcfg-eth$c") {
	    $widget_temp = gtksignal_connect(new Gtk::Button(ethisup($c) ? N("deactivate now") : N("activate now")),
					     clicked => sub {
						 system("/sbin/if".(ethisup($c)?"down" : "up")." eth$c");
						 gtkbuttonset($_[0], ethisup($c)? N("deactivate now") : N("activate now"));
					     });
	} else {
	    $widget_temp = N("This interface has not been configured yet.\nLaunch the configuration wizard in the main window");
	}
	$vbox_local->pack_start(gtkpack__(new Gtk::HBox(0,0),
					  $widget_temp
					 ),0,0,0);
	#	$clist1->append($_+1, "eth$_", $intf->{"eth$_"}{IPADDR}, $intf->{"eth$_"}{BOOTPROTO}, $all_cards[$_]->[1]);
	#	$clist1->set_selectable($_, 0);
#	require Data::Dumper;
#	print "------------\n" . Data::Dumper->Dump([$b],['b']) . "\n";
	my $hbox_local = new Gtk::HBox(0,0);
	my $pix = gtkpng("/usr/share/libDrakX/pixmaps/eth_card_mini.png");
	$hbox_local->pack_start($pix,0,0,0);
	$hbox_local->pack_start(new Gtk::Label("eth$_"),0,0,0);
	$hbox_local->show_all;
	$notebook->append_page($vbox_local, $hbox_local);
    }
    my $bbox1 = new Gtk::HButtonBox;
    $vbox1->pack_start($bbox1,0,0,10);
    $bbox1->set_layout(-end);
    my $button_ok = new Gtk::Button(N("OK"));
    $button_ok->signal_connect (clicked => sub {
				     foreach (0..$#all_cards) {
					 my $i = 0;
					 my @infos = @{$card_tab[2*$_]};
					 my @conf_data = @{$card_tab[2*$_+1]};
					 foreach my $j (@conf_data) {
					     ${$j->[1]} = $infos[2*$i+1]->get_text();
					     $i++;
					 }
				     }
				     update();
				     $button_apply->set_sensitive(1);
				     $window->destroy(); Gtk->main_quit;
				 });
    $bbox1->add($button_ok);
    my $button_cancel = new Gtk::Button(N("Cancel"));
    $button_cancel->signal_connect (clicked => sub { $window->destroy(); Gtk->main_quit });
    $bbox1->add($button_cancel);

    $window->set_modal(1);
    $window->show_all();
    foreach (0..$#all_cards) {
	my @infos = @{$card_tab[2*$_]};
	$intf->{"eth$_"}{BOOTPROTO} eq "dhcp" or $infos[8]->hide;
    }
    $window->set_position('center_always');
    Gtk->main;
}


sub configure_net {
    my (undef, $prefix, $netcnx, $netc, $intf) = @_;
    if (!$netcnx->{type}) {
	my $dialog = new Gtk::Dialog();
	$dialog->set_position(1);
	$dialog->vbox->set_border_width(10);
	$dialog->signal_connect (delete_event => sub { Gtk->main_quit() });
	$dialog->vbox->pack_start(new Gtk::Label(N("You don't have any internet connection.
Create one first by clicking on 'Configure'")),1,1,0);
	my $bbox_dialog = new Gtk::HButtonBox;
	$dialog->action_area->add($bbox_dialog);
	$bbox_dialog->set_layout(-end);
	my $button_ok = new Gtk::Button N("OK");
	$button_ok->signal_connect (clicked => sub {
					 Gtk->main_quit();
				     });
	$bbox_dialog->add($button_ok);
	$dialog->show_all;
	$dialog->set_modal(1);
	Gtk->main();
	$dialog->destroy;
	return;
    }
    my $cnx = {};
    my @infos;
    $cnx = $netcnx->{$netcnx->{type}};
    my $auto_detect = {};
    my $window = new Gtk::Window -toplevel;
    $window->set_policy (1, 1, 1);
    $window->signal_connect (delete_event => sub { Gtk->main_quit });
    $window->set_position(1);
    $window->set_title(N("Internet connection configuration"));
    $window->border_width(10);
    my $vbox1 = new Gtk::VBox(0,0);
    $window->add($vbox1);
    $vbox1->pack_start(new Gtk::Label(N("Internet Connection Configuration")),0,1,0);

    $vbox1->pack_start(new Gtk::HSeparator,0,0,5);
    my $table1 = new Gtk::Table (2, 4, 0);
    $table1->set_row_spacings(5);
    $table1->set_col_spacings(5);
    $vbox1->pack_start($table1,0,0,0);
    $table1->attach(new Gtk::Label(N("Profile: ")), 0, 1, 0, 1, 'fill', 'fill',0,0);
    $table1->attach(new Gtk::Label(translate($netcnx->{PROFILE})), 1, 2, 0, 1, 'fill', 'fill',0,0);
    $table1->attach(new Gtk::Label(N("Connection type: ")), 0, 1, 1, 2, 'fill', 'fill',0,0);
    $table1->attach(new Gtk::Label(translate($netcnx->{type})), 1, 2, 1, 2, 'fill', 'fill',0,0);
#    my $button1 = new Gtk::Button(N("Reconfigure using wizard..."));
#    $table1->attach($button1, 2, 4, 0, 2, 'fill', 'fill',0,0);
    $vbox1->pack_start(new Gtk::HSeparator,0,0,5);

    my $frame1 = new Gtk::Frame (N("Parameters"));
    $vbox1->pack_start($frame1,1,1,0);
    my $vbox2 = new Gtk::VBox(0,0);
    $frame1->add($vbox2);
    my $i = 0;
    my @conf_data = ([N("Card IRQ"), \$cnx->{irq} ],
		     [N("Card mem (DMA)"), \$cnx->{mem} ],
		     [N("Card IO"), \$cnx->{io} ],
		     [N("Card IO_0"), \$cnx->{io0} ],
		     [N("Card IO_1"), \$cnx->{io1} ],
		     [N("Your personal phone number"), \$cnx->{phone_in} ],
		     [N("Provider name (ex provider.net)"), \$netc->{DOMAINNAME2}],
		     [N("Provider phone number"), \$cnx->{phone_out} ],
		     [N("Provider dns 1 (optional)"), \$netc->{dnsServer2}],
		     [N("Provider dns 2 (optional)"), \$netc->{dnsServer3}],
		     [N("Account Login (user name)"), \$cnx->{login} ],
		     [N("Account Password"), \$cnx->{passwd} ],
		     [N("Dialing mode"), \$cnx->{dialing_mode}, [ "auto", "manual"] ],
		     [N("Gateway"), \$netc->{GATEWAY}],
		     [N("Connection name"), \$cnx->{connection} ],
		     [N("Phone number"), \$cnx->{phone} ],
		     [N("Login ID"), \$cnx->{login} ],
		     [N("Password"), \$cnx->{passwd} ],
		     [N("Authentication"), \$cnx->{auth}, [ N("PAP"), N("Terminal-based"), N("Script-based"), N_("CHAP") ] ],
		     [N("Domain name"), \$cnx->{domain} ],
		     [N("First DNS Server (optional)"), \$cnx->{dns1} ],
		     [N("Second DNS Server (optional)"), \$cnx->{dns2} ],
		     [N("Ethernet Card"), \$netc->{NET_DEVICE}, [ 'eth0', 'eth1', 'eth2', 'eth3', 'eth4', 'eth5','eth6', 'eth7', 'eth8', 'eth9' ]],
		     [N("DHCP Client"), \$netcnx->{dhcp_client}, ["dhcpcd", "dhcpxd", "dhcp-client"] ],
		     [N("Connection speed"), \$cnx->{speed}, ["64 Kb/s", "128 Kb/s"]],
		     [N("Connection timeout (in sec)"), \$cnx->{huptimeout} ]
);
    foreach (@conf_data) {
	$infos[2*$i] = new Gtk::HBox(0,0);
	my $l = new Gtk::Label($_->[0]);
	$l->set_justify('left');
	$infos[2*$i]->pack_start($l,1,1,0);
	$vbox2->pack_start($infos[2*$i],0,0,0);
  	if (defined $_->[2]) {
	    my $c = new Gtk::Combo();
	    $c->set_popdown_strings(@{$_->[2]});
	    $infos[2*$i+1] = $c->entry;
	    $infos[2*$i]->pack_start($c,0,0,0);
	} else {
	    $infos[2*$i+1] = new Gtk::Entry();
	    $infos[2*$i]->pack_start($infos[2*$i+1],0,0,0);
	    #hide password if Entry Password
	    if ($_->[0] eq N("Account Password") || $_->[0] eq N("Password")) { $infos[2*$i+1]->set_visibility(0) };
	}
	$infos[2*$i+1]->set_text(${$_->[1]});
  	$i++;
    }
    my @mask;
@mask = (0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0) if $netcnx->{type} eq 'lan';
@mask = (0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1) if $netcnx->{type} eq'isdn_internal'&& defined $cnx->{vendor} && defined $cnx->{id};
@mask = (1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1) if $netcnx->{type} eq'isdn_internal'&&(!defined $cnx->{vendor}||!defined $cnx->{id});
@mask = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0) if ($netcnx->{type} eq 'modem'||$netcnx->{type} eq 'isdn_external');
@mask = (0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0) if $netcnx->{type} =~ 'adsl';
@mask = (0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0) if $netcnx->{type} eq 'cable';
    $vbox1->pack_start(new Gtk::HSeparator,0,0,5);


    my $bbox1 = new Gtk::HButtonBox;
    $vbox1->pack_start($bbox1,0,0,0);
    $bbox1->set_layout(-end);
    my $button_ok = new Gtk::Button N("OK");
    $button_ok->signal_connect (clicked => sub {
				     $i = 0;
				     foreach (@mask) {
					    ${$conf_data[$i]->[1]} = $infos[2*$i+1]->get_text() if ($_);
					    $i++;
				     }
				     update();
				     $button_apply->set_sensitive(1);
				     $window->destroy(); Gtk->main_quit;
				 });
    $bbox1->add($button_ok);
    my $button_cancel = new Gtk::Button N("Cancel");
    $button_cancel->signal_connect (clicked => sub { $window->destroy(); Gtk->main_quit });
    $bbox1->add($button_cancel);

    $window->set_modal(1);
    $window->show_all();
    $i = 0;
    foreach (@mask) {
	if ($_) { $infos[2*$i]->show }
	else { $infos[2*$i]->hide }
	$i++;
    }
    $window->set_position('center_always');
    Gtk->main;
}