[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts Dialog.pm, 1.1, 1.2 Setup.pm.in, 1.1, 1.2

Richard Allen Megginson (rmeggins) fedora-directory-commits at redhat.com
Tue Jun 12 21:08:22 UTC 2007


Author: rmeggins

Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30745/ldapserver/ldap/admin/src/scripts

Modified Files:
	Dialog.pm Setup.pm.in 
Log Message:
Resolves: bug 237356
Description: Move DS Admin Code into Admin Server
Fix Description: 1) Need to have $SILENT be greater than $CUSTOM so that dialog hiding works properly.
2) Need to have the ability to hide or show individual prompts in a dialog e.g. if using TLS/SSL, need to ask for the CA certificate filename, otherwise, not.
3) Need the ability to call a function to get the default yes or no answer for DialogYesNo
4) DialogYesNo should match answer case insensitively



Index: Dialog.pm
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Dialog.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Dialog.pm	8 Jun 2007 01:09:16 -0000	1.1
+++ Dialog.pm	12 Jun 2007 21:08:20 -0000	1.2
@@ -107,12 +107,18 @@
 }
 
 # each prompt looks like this:
-# [ 'resource key', is pwd ]
+# [ 'resource key', is pwd, hide ]
 # The resource key is the string key of the resource
 # is pwd is optional - if present, the prompt is for a password
 # and should not echo the answer
+# hide is optional - if present and true, the prompt will not be displayed - this
+# is useful in cases where you may want to display or hide a subprompt depending
+# on the response to a main prompt
 # e.g.
 # ['RESOURCE_USERNAME'], ['RESOURCE_PASSWORD', 1], ['RESOURCE_PASSWORD_AGAIN', 1]
+# e.g.
+# ['USE_SECURITY'], ['CA_CERTIFICATE', 0, 0]
+# you can set the 0 to a 1 if the user has chosen to use security
 sub run {
     my $self = shift;
     my $resp = $DialogManager::SAME;
@@ -129,7 +135,7 @@
         my $prompt = $prompts[$index];
         my $defaultans = $self->{defaultAns}($self, $index);
         my $ans;
-        if ($self->isDisplayed()) {
+        if ($self->isDisplayed() && !$promtpt->[2]) {
             $ans = $self->{manager}->showPrompt($prompt->[0], $defaultans, $prompt->[1]);
         } else {
             $ans = $defaultans;
@@ -201,7 +207,13 @@
         return $self->{ans};
     }
     if (!exists($self->{default})) {
-        if ($self->{defaultIsYes}) {
+        my $isyes;
+        if (ref($self->{defaultIsYes}) eq 'CODE') {
+            $isyes = &{$self->{defaultIsYes}}($self);
+        } else {
+            $isyes = $self->{defaultIsYes};
+        }
+        if ($isyes) {
             $self->{default} = $self->{"manager"}->getText("yes");
         } else {
             $self->{default} = $self->{"manager"}->getText("no");
@@ -223,10 +235,10 @@
     my $nno = $self->{"manager"}->getText("no");
 
     # the regexp allows us to use y or ye or yes for "yes"
-    if ($nno =~ /^$ans/) {
+    if ($nno =~ /^$ans/i) {
         $resp = $DialogManager::NEXT;
         $self->{ans} = $nno;
-    } elsif ($yes =~ /^$ans/) {
+    } elsif ($yes =~ /^$ans/i) {
         $resp = $DialogManager::NEXT;
         $self->{ans} = $yes;
     } else {


Index: Setup.pm.in
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Setup.pm.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Setup.pm.in	8 Jun 2007 01:09:16 -0000	1.1
+++ Setup.pm.in	12 Jun 2007 21:08:20 -0000	1.2
@@ -71,10 +71,10 @@
 use SetupLog;
 
 # the setup types
-$SILENT = 0;
 $EXPRESS = 1;
 $TYPICAL = 2;
 $CUSTOM = 3;
+$SILENT = 4;
 
 # process command line options
 Getopt::Long::Configure(qw(bundling)); # bundling allows -ddddd




More information about the Fedora-directory-commits mailing list