From: Nicolas Boichat Date: Thu, 15 Jul 2004 21:17:56 +0000 (+0000) Subject: - wxbMainFrame : When an unexpected question is in this format (***? (yes/mod/no... X-Git-Tag: Release-1.35.1~66 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ef254f04b27d5f17c6f22025fb8a228124a8f52e;p=bacula%2Fbacula - wxbMainFrame : When an unexpected question is in this format (***? (yes/mod/no):), a list is shown to choose one of these possibilities. - wxbRestorePanel : Fixed crash when there is no backup available (fresh install) git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1468 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index 9a56cfcf4a..f07925b9ff 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -1,4 +1,9 @@ 15-07-2004 : + - wxbMainFrame : When an unexpected question is in this format + (***? (yes/mod/no):), a list is shown to choose one of these + possibilities. + - wxbRestorePanel : Fixed crash when there is no backup available + (fresh install) - wxbHistoryTextCtrl : Created a new text control that keep an history of typed commands. diff --git a/bacula/src/wx-console/TODO b/bacula/src/wx-console/TODO index 3d907a8c7e..4804a7b95c 100644 --- a/bacula/src/wx-console/TODO +++ b/bacula/src/wx-console/TODO @@ -1,8 +1,6 @@ general : Show nice messages boxes when errors occurs. -wxbRestorePanel : Crashing when there is no backup to show (fresh install) - -GTK2 : The console control is not scrolled correctly +GTK2 : The console control is not scrolled correctly (wxGTK bug) Win32 : Crash when quitting while trying to connect @@ -20,7 +18,8 @@ wxbRestorePanel : disable controls when working or (better) queue events (see commented out code in wxbrestorepanel (marked with EVTQUEUE)) wxbMainFrame : When exiting using menu, a messagebox is shown to ask the - user if he want to quit because the connection is lost. + user if he want to quit because the connection is lost. (doesn't + happen on Linux) wxbUtils : add clients, jobs, filesets, pools... list, merge patch file (wxbnewutils.patch) @@ -28,9 +27,6 @@ general : add a tab containing messages wxbMainFrame : Implement command completion (tab) -wxbMainFrame : When an unexpected question is in this format (***? (yes/mod/no):), - show a list to choose one of these possibilities. - wxbConfigFileEditor : create a more precise editor, with something like a tree structure @@ -63,7 +59,7 @@ wxblistctrl/wxbtreectrl : Find why events are not forwarded correctly to parent' parent, and correct bad actual implementation. (remove handler parameter in wxTreeCtrl/wxListCtrl constructor) -general : find out why I had to modify string.cpp and string.h +Win32 : find out why I had to modify string.cpp and string.h + In include/wx/string.h, replace line 195 by #if defined(__VISUALC__) // && defined(_MT) && !defined(_DLL) + In src/common/string.cpp, replace line 167 by diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index 13a29fb4c3..39c79295c9 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -620,7 +620,12 @@ void wxbMainFrame::Print(wxString str, int status) Send("\n"); } else { - Send(wxString() << numbers[res] << "\n"); + if (promptparser->isNumericalChoice()) { + Send(wxString() << numbers[res] << "\n"); + } + else { + Send(wxString() << choices[res] << "\n"); + } } } else { diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index e058f5918d..d4f2388b5f 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -2,7 +2,7 @@ * * wxbPanel for restoring files * - * Nicolas Boichat, April-May 2004 + * Nicolas Boichat, April-July 2004 * */ /* @@ -1110,7 +1110,28 @@ void wxbRestorePanel::CmdListJobs() { configPanel->ClearRowChoices("Before"); wxbUtils::WaitForPrompt("query\n"); wxbUtils::WaitForPrompt("6\n"); - wxbTableParser* tableparser = wxbUtils::CreateAndWaitForParser(configPanel->GetRowString("Client") + "\n"); + wxbTableParser* tableparser = new wxbTableParser(); + wxbDataTokenizer* dt = wxbUtils::WaitForEnd(configPanel->GetRowString("Client") + "\n", true); + + if (!tableparser->hasFinished()) { + for (int i = 0; i < dt->Count(); i++) { + if ((*dt)[i].Index("No results to list.") == 0) { + configPanel->AddRowChoice("Before", "No backup found for this client."); + configPanel->SetRowSelection("Before", 0); + configPanel->EnableApply(true); // Enabling the not existing apply button disables the ok button. + delete tableparser; + delete dt; + return; + } + } + } + + while (!tableparser->hasFinished()) { + wxTheApp->Yield(true); + ::wxUsleep(100); + } + + delete dt; for (int i = tableparser->GetCount()-1; i > -1; i--) { wxString str = (*tableparser)[i][3]; @@ -1125,10 +1146,11 @@ void wxbRestorePanel::CmdListJobs() { jobChoice->Append("Invalid"); }*/ } - + delete tableparser; configPanel->SetRowSelection("Before", 0); + configPanel->EnableApply(false); // Disabling the not existing apply button enables the ok button. } } diff --git a/bacula/src/wx-console/wxbutils.cpp b/bacula/src/wx-console/wxbutils.cpp index 4c914a341c..7e93bb6cf9 100644 --- a/bacula/src/wx-console/wxbutils.cpp +++ b/bacula/src/wx-console/wxbutils.cpp @@ -2,7 +2,7 @@ * * wxbDataParser, class that receives and analyses data * - * Nicolas Boichat, April 2004 + * Nicolas Boichat, April-July 2004 * */ /* @@ -216,6 +216,7 @@ wxbPromptParser::wxbPromptParser(): wxbDataParser(false) { prompt = false; introStr = ""; choices = NULL; + numerical = false; questionStr = ""; } @@ -237,6 +238,7 @@ bool wxbPromptParser::Analyse(wxString str, int status) { if (choices) { delete choices; choices = NULL; + numerical = false; } questionStr = ""; introStr = ""; @@ -248,12 +250,14 @@ bool wxbPromptParser::Analyse(wxString str, int status) { if (!choices) { choices = new wxArrayString(); choices->Add(""); /* index 0 is never used by multiple choice questions */ + numerical = true; } if ((long)choices->GetCount() != num) { /* new choice has begun */ delete choices; - choices = new wxArrayString(num); + choices = new wxArrayString(); choices->Add("", num); /* fill until this number */ + numerical = true; } choices->Add(str.Mid(i+2).RemoveLast()); @@ -270,19 +274,29 @@ bool wxbPromptParser::Analyse(wxString str, int status) { else { finished = ((status == CS_PROMPT) || (status == CS_END) || (status == CS_DISCONNECTED)); if (prompt = ((status == CS_PROMPT) && (questionStr != "$ "))) { // && (str.Find(": ") == str.Length()) + if (introStr.Last() == '\n') { + introStr.RemoveLast(); + } if ((introStr != "") && (questionStr == "")) { questionStr = introStr; introStr = ""; } - if (introStr.Last() == '\n') { - introStr.RemoveLast(); + + if ((!choices) && (questionStr.Find("(yes/mod/no)") > -1)) { + choices = new wxArrayString(); + choices->Add("yes"); + choices->Add("mod"); + choices->Add("no"); + numerical = false; } + return true; } else { /* ended or (dis)connected */ if (choices) { delete choices; choices = NULL; + numerical = false; } questionStr = ""; introStr = ""; @@ -312,9 +326,16 @@ wxString wxbPromptParser::getQuestionString() { return questionStr; } -/* Return a wxArrayString containing the indexed choices we have +/* Returns a wxArrayString containing the indexed choices we have * to answer the question, or NULL if this question is not a multiple * choice one. */ wxArrayString* wxbPromptParser::getChoices() { return choices; } + +/* Returns true if the expected answer to the choice list is a number, + * false if it is a string (for example yes/mod/no). */ +bool wxbPromptParser::isNumericalChoice() { + return numerical; +} + diff --git a/bacula/src/wx-console/wxbutils.h b/bacula/src/wx-console/wxbutils.h index 9c4ed6893e..ea1b9126cd 100644 --- a/bacula/src/wx-console/wxbutils.h +++ b/bacula/src/wx-console/wxbutils.h @@ -3,7 +3,7 @@ * wxbDataParser, class that receives and analyses data * wxbPanel, main frame's notebook panels * - * Nicolas Boichat, April 2004 + * Nicolas Boichat, April-July 2004 * */ /* @@ -176,16 +176,19 @@ class wxbPromptParser: public wxbDataParser /* Returns question string */ wxString getQuestionString(); - /* Return a wxArrayString containing the indexed choices we have + /* Returns a wxArrayString containing the indexed choices we have * to answer the question, or NULL if this question is not a multiple * choice one. */ wxArrayString* getChoices(); - + /* Returns true if the expected answer to the choice list is a number, + * false if it is a string (for example yes/mod/no). */ + bool isNumericalChoice(); private: bool finished; bool prompt; + bool numerical; wxString introStr; wxArrayString* choices; wxString questionStr;