summaryrefslogtreecommitdiffstats
path: root/lib/network/drakvpn.pm
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2007-05-25 15:39:46 +0000
committerOlivier Blin <oblin@mandriva.com>2007-05-25 15:39:46 +0000
commit1d37bfdbbe874abd6dcb5563eea19f531de09e1c (patch)
tree74845e43ed8fa59c7aaafd1a87efaa6b0c83c228 /lib/network/drakvpn.pm
parentc6ba983db7d5a82ee63599e775be0f8211447c72 (diff)
downloaddrakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.gz
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.bz2
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.tar.xz
drakx-net-1d37bfdbbe874abd6dcb5563eea19f531de09e1c.zip
sync with 2007.1 (because of SVN loss)2007.1
Diffstat (limited to 'lib/network/drakvpn.pm')
-rw-r--r--lib/network/drakvpn.pm120
1 files changed, 120 insertions, 0 deletions
diff --git a/lib/network/drakvpn.pm b/lib/network/drakvpn.pm
new file mode 100644
index 0000000..158b40c
--- /dev/null
+++ b/lib/network/drakvpn.pm
@@ -0,0 +1,120 @@
+package network::drakvpn;
+
+=head1 NAME
+
+network::drakvpn - Interactive VPN configuration
+
+=head1 SYNOPSIS
+
+ use interactive;
+ use network::drakvpn;
+
+ my $in = 'interactive'->vnew('su');
+ network::drakvpn::create_connection($in);
+
+=cut
+
+use strict;
+use common;
+
+use network::vpn;
+
+sub create_connection {
+ my ($in) = @_;
+ my $vpn_type;
+ my $vpn_connection;
+ my $new_name;
+ require wizards;
+ my $wiz = wizards->new({
+ defaultimage => "drakvpn",
+ name => N("VPN configuration"),
+ pages => {
+ welcome => {
+ if_(!$::isInstall, no_back => 1),
+ name => N("Choose the VPN type"),
+ data => [ {
+ val => \$vpn_type, type => 'list',
+ list => [ sort { $a->get_description cmp $b->get_description } network::vpn::list_types ],
+ format => sub { $_[0] && $_[0]->get_description },
+ allow_empty_list => 1,
+ } ],
+ complete => sub {
+ $vpn_type or return 1;
+ my @packages = $vpn_type->get_packages;
+ if (@packages && !$in->do_pkgs->install(@packages)) {
+ $in->ask_warn(N("Error"), N("Could not install the packages (%s)!", join(', ', @packages)));
+ return 1;
+ }
+ if ($vpn_type->can('prepare')) {
+ my $wait = $in->wait_message('', N("Initializing tools and detecting devices for %s...", $vpn_type->get_type));
+ if (!$vpn_type->prepare) {
+ undef $wait;
+ $in->ask_warn(N("Error"), N("Unable to initialize %s connection type!", $vpn_type->get_type));
+ return 1;
+ }
+ }
+ },
+ next => "vpn_name",
+ },
+ vpn_name => {
+ name => N("Please select an existing VPN connection or enter a new name."),
+ data => sub { [
+ { label => N("VPN connection"), val => \$vpn_connection, type => 'list',
+ list => [ $vpn_type->get_configured_connections, '' ],
+ format => sub { $_[0] ? $_[0]{name} : N("Configure a new connection...") },
+ gtk => { use_boxradio => 1 } },
+ { label => N("New name"), val => \$new_name, disabled => sub { $vpn_connection } },
+ ] },
+ complete => sub {
+ if (!$vpn_connection && !$new_name) {
+ $in->ask_warn(N("Warning"), N("You must select an existing connection or enter a new name."));
+ 1;
+ }
+ },
+ post => sub {
+ $vpn_connection ||= $vpn_type->new($new_name);
+ $vpn_connection->read_config;
+ $vpn_connection->can('get_key_settings') ? "vpn_key_settings" : "vpn_settings";
+ },
+ },
+ vpn_key_settings => {
+ name => N("Please enter the required key(s)"),
+ data => sub { $vpn_connection->get_key_settings },
+ next => "vpn_settings",
+ },
+ vpn_settings => {
+ name => N("Please enter the settings of your VPN connection"),
+ data => sub { $vpn_connection->get_settings },
+ post => sub {
+ $vpn_connection->write_config;
+ "connect";
+ },
+ },
+ connect => {
+ name => N("Do you want to start the connection now?"),
+ type => "yesorno",
+ post => sub {
+ my ($connect) = @_;
+ if ($connect) {
+ $vpn_connection->is_started and $vpn_connection->stop;
+ $vpn_connection->start($in) or $in->ask_warn(N("Warning"), N("Connection failed."));
+ }
+ require network::network;
+ network::network::reload_net_applet();
+ "end";
+ },
+ },
+ end => {
+ name => N("The VPN connection is now configured.
+
+This VPN connection can be automatically started together with a network connection.
+It can be done by reconfiguring the network connection and selecting this VPN connection.
+"),
+ end => 1,
+ },
+ },
+ });
+ $wiz->process($in);
+}
+
+1;