]> git.sur5r.net Git - bacula/bacula/commitdiff
- wxbMainFrame : When an unexpected question is in this format (***? (yes/mod/no...
authorNicolas Boichat <nicolas@boichat.ch>
Thu, 15 Jul 2004 21:17:56 +0000 (21:17 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Thu, 15 Jul 2004 21:17:56 +0000 (21:17 +0000)
- 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

bacula/src/wx-console/CHANGELOG
bacula/src/wx-console/TODO
bacula/src/wx-console/wxbmainframe.cpp
bacula/src/wx-console/wxbrestorepanel.cpp
bacula/src/wx-console/wxbutils.cpp
bacula/src/wx-console/wxbutils.h

index 9a56cfcf4a2b7dcfd0058178bd1128c37adc1daa..f07925b9fff729d06be6028878ce4a8588de1b1d 100644 (file)
@@ -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.
 
index 3d907a8c7e2a814f0816abee5ef3a7aa6970caa6..4804a7b95cd592cc51c33a5c706f30213dff5699 100644 (file)
@@ -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
index 13a29fb4c3bd29061fa95124bb0b47efb1fd6f1b..39c79295c9d79b6c0b8e1e892bc99e78a0cb561c 100644 (file)
@@ -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 {
index e058f5918d1cc2fdfa99960a900328563b5a7248..d4f2388b5f6a9951ca166158170d51ab319384bb 100644 (file)
@@ -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.
    }
 }
 
index 4c914a341cebc4ff379ad4f11ba0a0ee985fb064..7e93bb6cf9d27389d90e0193045098d1a6013ea1 100644 (file)
@@ -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;
+}
+
index 9c4ed6893efd6d31a8363a47f3c75305be214b8e..ea1b9126cdfef4e2f1961fe1d8be1a8631b55b8d 100644 (file)
@@ -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;