Subject: | Default login entry values |
Supply default logins and passwords by host.
Subject: | RemoteFileSelect.diff |
--- RemoteFileSelect.pm Tue Aug 21 15:31:18 2007
+++ RemoteFileSelect.pm Tue Aug 21 16:37:19 2007
@@ -117,6 +117,43 @@
The initial value of the remote user ID.
+=item Name: B<useridvariable>
+
+=item Switch: B<-useridvariable>
+
+Variable to return the userid entered.
+
+=item Name: B<passwordvariable>
+
+=item Switch: B<-passwordvariable>
+
+Variable to return the password entered.
+
+=item Name: B<ftpvariable>
+
+=item Switch: B<-ftpvariable>
+
+Variable to return the ftp connection object.
+
+=item Name: B<hostdefaults>
+
+=item Switch: B<-hostdefaults>
+
+Hash reference of default userid's and passwords by host in the form:
+
+ $host_defaults = {
+ host1 => {
+ userid => "UserName1",
+ password => "Password1",
+ },
+ host2 => {
+ userid => "UserName2",
+ password => "Password2",
+ },
+ };
+
+Either key (userid, password) is optional.
+
=item Name: B<dirlistlabel>
=item Switch: B<-dirlistlabel>
@@ -283,6 +320,14 @@
$transcript = $cw -> cget( '-transcript' );
$cw -> configure( -hostname => $hostid,
-transcript => $transcript );
+ if ( my $hosts = $cw -> cget( '-hostdefaults' ) ) {
+ if ( my $host_defaults = $hosts->{$hostid} ) {
+ my $user_var = $cw -> cget( '-useridvariable' );
+ $$user_var = $host_defaults->{userid};
+ my $passwd_var = $cw -> cget( '-passwordvariable' );
+ $$passwd_var = $host_defaults->{password};
+ }
+ }
my $logindlg = $cw -> Subwidget('logindialog');
return if ( ($resp = $logindlg -> Show ) =~ /Cancel/);
$cw -> configure( -userid => ($logindlg -> Subwidget( 'uidentry' ) -> get),
@@ -575,6 +620,12 @@
-> pack( -anchor => 'w' );
# login user/password dialog
+ my $user_ref = exists( $args->{-useridvariable} )
+ ? $args->{-useridvariable}
+ : \my $tmp_user;
+ my $password_ref = exists( $args->{-passwordvariable} )
+ ? $args->{-passworddvariable}
+ : \my $tmp_passwd;
my $l = $w -> Component(
DialogBox => 'logindialog',
-title => 'Log in.',
@@ -583,11 +634,13 @@
-text => 'Please enter your user name and password.'
) -> pack( -expand => '1', -fill => 'x' );
$l -> Component ( LabEntry => 'uidentry',
- -labelVariable => \$w -> {'Configure'}{'-uidlabel'} )
+ -labelVariable => \$w -> {'Configure'}{'-uidlabel'},
+ -textvariable => $user_ref )
-> pack( -anchor => 'w', -expand => '1', -fill => 'x',
-padx => 5, -pady => 5);
$l -> Component( LabEntry => 'pwdentry',
-labelVariable => \$w -> {'Configure'}{'-pwdlabel'},
+ -textvariable => $password_ref,
-show => '*' )
-> pack( -anchor => 'w', -expand => '1', -fill => 'x',
-padx => 5, -pady => 5);
@@ -632,6 +685,7 @@
-ftpvariable => ['PASSIVE', undef, undef, '' ],
-useridvariable => ['PASSIVE', undef, undef, '' ],
-passwordvariable => ['PASSIVE', undef, undef, ''],
+ -hostdefaults => ['PASSIVE', undef, undef, ''],
DEFAULT => [ 'file_list' ],
);
$w->Delegates(DEFAULT => 'file_list');