]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix bug #437
authorNicolas Boichat <nicolas@boichat.ch>
Sat, 15 Oct 2005 17:30:32 +0000 (17:30 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Sat, 15 Oct 2005 17:30:32 +0000 (17:30 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2445 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/wxbmainframe.cpp
bacula/src/wx-console/wxbrestorepanel.cpp

index dba00827658a5d3d32306e4ad6b4806856f567b3..733f8dd142545b05bdb016cd7d45dad94bca4ce1 100644 (file)
@@ -679,6 +679,8 @@ void wxbMainFrame::Print(wxString str, int status)
                   Send(wxString() << choices[res] << wxT("\n"));
                }
             }
+            delete choices;
+            delete numbers;
          }
          else {
             Send(::wxGetTextFromUser(message,
index 7a15d1531569e2370889cf1ba7757c944ee468ed..48d20906f7528b0d10248c7803b42eb81cf2f900 100644 (file)
@@ -725,7 +725,60 @@ void wxbRestorePanel::CmdStart() {
       int j;
       
       dt = new wxbDataTokenizer(true);
-      wxbUtils::WaitForPrompt(wxT("done\n"));
+      wxbPromptParser* promptparser = wxbUtils::WaitForPrompt(wxT("done\n"), true);
+
+      while (!promptparser->getChoices() || (promptparser->getChoices()->Index(wxT("mod")) < 0)) {
+         wxbMainFrame::GetInstance()->Print(_("Unexpected question has been received.\n"), CS_DEBUG);
+         
+         wxString message;
+         if (promptparser->getIntroString() != wxT("")) {
+            message << promptparser->getIntroString() << wxT("\n");
+         }
+         message << promptparser->getQuestionString();
+         
+         if (promptparser->getChoices()) {
+            wxString *choices = new wxString[promptparser->getChoices()->GetCount()];
+            int *numbers = new int[promptparser->getChoices()->GetCount()];
+            int n = 0;
+            
+            for (unsigned int i = 0; i < promptparser->getChoices()->GetCount(); i++) {
+               if ((*promptparser->getChoices())[i] != wxT("")) {
+                  choices[n] = (*promptparser->getChoices())[i];
+                  numbers[n] = i;
+                  n++;
+               }
+            }
+            
+            int res = ::wxGetSingleChoiceIndex(message,
+               _("wx-console: unexpected restore question."), n, choices, this);
+            if (res == -1) {
+               delete promptparser;
+               promptparser = wxbUtils::WaitForPrompt(wxT(".\n"), true);
+            }
+            else {
+               if (promptparser->isNumericalChoice()) {
+                  delete promptparser;
+                  promptparser = wxbUtils::WaitForPrompt(wxString() << numbers[res] << wxT("\n"), true);
+               }
+               else {
+                  delete promptparser;
+                  promptparser = wxbUtils::WaitForPrompt(wxString() << choices[res] << wxT("\n"), true);
+               }
+            }
+            delete choices;
+            delete numbers;
+         }
+         else {
+            delete promptparser;
+            
+            promptparser = wxbUtils::WaitForPrompt(::wxGetTextFromUser(message,
+               _("wx-console: unexpected restore question."),
+               wxT(""), this) + wxT("\n"));
+         }
+      }
+      printf("promptparser->getChoices()=%ld", (long)promptparser->getChoices());
+      
+      delete promptparser;
 
       SetStatus(configuring);