From a2c8f2119135741cf58cadc440a38152f5afb3e4 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sat, 15 Oct 2005 17:30:32 +0000 Subject: [PATCH] Fix bug #437 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2445 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/wx-console/wxbmainframe.cpp | 2 + bacula/src/wx-console/wxbrestorepanel.cpp | 55 ++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index dba0082765..733f8dd142 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -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, diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index 7a15d15315..48d20906f7 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -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); -- 2.39.5