]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/wx-console/wxbrestorepanel.cpp
Some Win32 fixes
[bacula/bacula] / bacula / src / wx-console / wxbrestorepanel.cpp
index 96f72f0aff4a66ef1bb9984ddeb1a43512b99576..51da80753ea5d8d4c4613ce3c1244e640ef37550 100644 (file)
@@ -2,7 +2,7 @@
  *
  *   wxbPanel for restoring files
  *
- *    Nicolas Boichat, April-May 2004
+ *    Nicolas Boichat, April-July 2004
  *
  */
 /*
@@ -814,20 +814,27 @@ void wxbRestorePanel::CmdStart() {
          
          wxDateTime jobtime;
          
-         if (jobname == (*tableparser)[tableparser->GetCount()-1][1]) {
-            wxStringTokenizer jtkz((*tableparser)[tableparser->GetCount()-1][2], " ", wxTOKEN_STRTOK);
-            if ((jobtime.ParseDate(jtkz.GetNextToken()) != NULL) && // Date
-                  (jobtime.ParseTime(jtkz.GetNextToken()) != NULL)) { // Time
-               if (jobtime.IsLaterThan(currenttime)) {
-                  jobid = (*tableparser)[tableparser->GetCount()-1][0];
-                  cmd << jobid << "\n";
-                  delete tableparser;
-                  cancel->Enable(true);
-                  break;
+         for (i = 0; i < tableparser->GetCount(); i++) {
+            if (jobname == (*tableparser)[i][1]) {
+               wxStringTokenizer jtkz((*tableparser)[i][2], " ", wxTOKEN_STRTOK);
+               if ((jobtime.ParseDate(jtkz.GetNextToken()) != NULL) && // Date
+                     (jobtime.ParseTime(jtkz.GetNextToken()) != NULL)) { // Time
+                  if (jobtime.IsLaterThan(currenttime)) {
+                     jobid = (*tableparser)[i][0];
+                     cmd << jobid << "\n";
+                     delete tableparser;
+                     tableparser = NULL;
+                     cancel->Enable(true);
+                     break;
+                  }
                }
             }
          }
    
+         if (tableparser == NULL) { //The job was found
+            break;
+         }
+         
          delete tableparser;
          
          wxStopWatch sw2;
@@ -1110,7 +1117,36 @@ 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 (unsigned int i = 0; i < dt->Count(); i++) {
+            if ((*dt)[i].Find("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;
+            }
+            else if (((*dt)[i].Find("ERROR") > -1) || ((*dt)[i].Find("Query failed") > -1)) {
+               configPanel->AddRowChoice("Before", "Cannot get previous backups list, see console.");
+               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 +1161,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.
    }
 }
 
@@ -1378,9 +1415,11 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool re
 
 /* Parse dir command results. */
 wxString* wxbRestorePanel::ParseList(wxString line) {
-   //drwx------  11 1003    42949672      0  2001-07-30 16:45:14 *filename
-   //+ 10    ++ 4++   10   ++   8  ++   8  + +      19         + *+ ->
-   //0       10  14         24      32       42                  62
+   /* See ls_output in dird/ua_tree.c */
+  
+   //drwxrwxrwx   1 root     root           0  2004-04-03 14:35:21  f:/tocd/NVSU 1.00.00/
+   //+ 10     +  ++ +   8  + +   8  ++   8  +  +      19         + *+ ->
+   //0           12 15       24      32        42                  62
 
    if (line.Length() < 63)
       return NULL;
@@ -1388,8 +1427,8 @@ wxString* wxbRestorePanel::ParseList(wxString line) {
    wxString* ret = new wxString[9];
 
    ret[0] = line.Mid(0, 10).Trim();
-   ret[1] = line.Mid(10, 4).Trim();
-   ret[2] = line.Mid(14, 10).Trim();
+   ret[1] = line.Mid(12, 2).Trim();
+   ret[2] = line.Mid(15, 8).Trim();
    ret[3] = line.Mid(24, 8).Trim();
    ret[4] = line.Mid(32, 8).Trim();
    ret[5] = line.Mid(42, 19).Trim();