]> git.sur5r.net Git - bacula/bacula/commitdiff
- wxbUtils : Created this class, containing general functions like WaitForEnd
authorNicolas Boichat <nicolas@boichat.ch>
Sat, 22 May 2004 10:06:04 +0000 (10:06 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Sat, 22 May 2004 10:06:04 +0000 (10:06 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1368 91ce42f0-d328-0410-95d8-f526ca767f89

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

index 331b4cca3f0747e08ed9c62b605326c4d8d95eba..2bc918afb7dd184637a908de84d129680f95f814 100644 (file)
@@ -1,3 +1,7 @@
+22-05-2004 :
+ - wxbUtils : Created this class, containing general functions like
+    WaitForEnd
+
 21-05-2004 :
  - wxbRestorePanel : Added functions to get/set working status
 
index 0be86d9d694c1c803eeb7f42ef1a389eac09056e..ec7c76df72b0af60644076dc24afec91fd0af358 100644 (file)
@@ -18,6 +18,8 @@ wxbRestorePanel : disable controls when working or (better) queue events
 wxbMainFrame : When exiting using menu, a messagebox is shown to ask the
   user if he want to quit because the connection is lost.
 
+wxbUtils : add clients, jobs, filesets, pools... list
+
 [postponed to July:]
 
 wxbConfigFileEditor : create a more precise editor, with something like
@@ -30,9 +32,6 @@ wxbRestorePanel : Add a way to cancel restore when building tree
 
 wxbMainFrame : set focus to type control when clicking on console
 
-global : create a general class which keeps clients, jobs, 
-       filesets, pools... list, and with functions like WaitForEnd.
-
 wxbConfigPanel : Create a dialog for selecting dates and paths.
 
 wxbMainFrame : use more often status text
index 524844522774dcf7ea143ea5cc72c1c3293b9c25..96f72f0aff4a66ef1bb9984ddeb1a43512b99576 100644 (file)
@@ -447,7 +447,7 @@ void wxbRestorePanel::CmdStart() {
    unsigned int i;
    if (status == activable) {
       wxbMainFrame::GetInstance()->SetStatusText("Getting parameters list.");
-      wxbDataTokenizer* dt = WaitForEnd(".clients\n", true, false);
+      wxbDataTokenizer* dt = wxbUtils::WaitForEnd(".clients\n", true, false);
       wxString str;
 
       configPanel->ClearRowChoices("Client");
@@ -472,7 +472,7 @@ void wxbRestorePanel::CmdStart() {
          return;
       }
       
-      dt = WaitForEnd(".filesets\n", true, false);
+      dt = wxbUtils::WaitForEnd(".filesets\n", true, false);
       
       configPanel->ClearRowChoices("Fileset");
       restorePanel->ClearRowChoices("Fileset");
@@ -496,7 +496,7 @@ void wxbRestorePanel::CmdStart() {
          return;
       }
       
-      dt = WaitForEnd(".storage\n", true, false);
+      dt = wxbUtils::WaitForEnd(".storage\n", true, false);
     
       configPanel->ClearRowChoices("Storage");
       restorePanel->ClearRowChoices("Storage");
@@ -520,7 +520,7 @@ void wxbRestorePanel::CmdStart() {
          return;
       }
       
-      dt = WaitForEnd(".jobs\n", true, false);
+      dt = wxbUtils::WaitForEnd(".jobs\n", true, false);
     
       configPanel->ClearRowChoices("Job Name");
     
@@ -544,7 +544,7 @@ void wxbRestorePanel::CmdStart() {
          return;
       }
       
-      dt = WaitForEnd(".pools\n", true, false);
+      dt = wxbUtils::WaitForEnd(".pools\n", true, false);
     
       configPanel->ClearRowChoices("Pool");
     
@@ -585,14 +585,14 @@ void wxbRestorePanel::CmdStart() {
       
       SetStatus(choosing);
       
-      WaitForPrompt(wxString("restore") <<
+      wxbUtils::WaitForPrompt(wxString("restore") <<
          " client=\"" << configPanel->GetRowString("Client") <<
          "\" fileset=\"" << configPanel->GetRowString("Fileset") <<
          "\" pool=\"" << configPanel->GetRowString("Pool") <<
          "\" storage=\"" << configPanel->GetRowString("Storage") << "\"\n");
-      WaitForPrompt("6\n");
+      wxbUtils::WaitForPrompt("6\n");
       //WaitForEnd();
-      /*wxbPromptParser *pp = WaitForPrompt(wxString() << configPanel->GetRowString("Before") << "\n", true);
+      /*wxbPromptParser *pp = wxbUtils::WaitForPrompt(wxString() << configPanel->GetRowString("Before") << "\n", true);
       int client = pp->getChoices()->Index(configPanel->GetRowString("Client"));
       if (client == wxNOT_FOUND) {
          wxbMainFrame::GetInstance()->SetStatusText("Failed to find the selected client.");
@@ -706,7 +706,7 @@ void wxbRestorePanel::CmdStart() {
          return;
       }
 
-      WaitForEnd("unmark *\n");
+      wxbUtils::WaitForEnd("unmark *\n");
       wxTreeItemId root = tree->AddRoot(configPanel->GetRowString("Client"), -1, -1, new wxbTreeItemData("/", configPanel->GetRowString("Client"), 0));
       currentTreeItem = root;
       tree->Refresh();
@@ -724,7 +724,7 @@ void wxbRestorePanel::CmdStart() {
       int j;
       
       dt = new wxbDataTokenizer(true);
-      WaitForPrompt("done\n");
+      wxbUtils::WaitForPrompt("done\n");
 
       SetStatus(configuring);
 
@@ -768,14 +768,14 @@ void wxbRestorePanel::CmdStart() {
       wxbDataTokenizer* dt;
     
       SetStatus(restoring);
-      WaitForEnd("yes\n");
+      wxbUtils::WaitForEnd("yes\n");
 
       gauge->SetValue(0);
       gauge->SetRange(totfilemessages);
 
       wxDateTime currenttime;
       
-      dt = WaitForEnd("time\n", true);
+      dt = wxbUtils::WaitForEnd("time\n", true);
       wxStringTokenizer ttkz((*dt)[0], " ", wxTOKEN_STRTOK);
       if ((currenttime.ParseDate(ttkz.GetNextToken()) == NULL) || // Date
            (currenttime.ParseTime(ttkz.GetNextToken()) == NULL)) { // Time
@@ -810,7 +810,7 @@ void wxbRestorePanel::CmdStart() {
       wxbTableParser* tableparser;
 
       while (true) {
-         tableparser = CreateAndWaitForParser("list jobs\n");
+         tableparser = wxbUtils::CreateAndWaitForParser("list jobs\n");
          
          wxDateTime jobtime;
          
@@ -847,13 +847,13 @@ void wxbRestorePanel::CmdStart() {
       long filemessages = 0;
 
       while (true) {
-         tableparser = CreateAndWaitForParser(cmd);
+         tableparser = wxbUtils::CreateAndWaitForParser(cmd);
          if ((*tableparser)[0][7] != "C") {
             break;
          }
          delete tableparser;
 
-         dt = WaitForEnd("messages\n", true);
+         dt = wxbUtils::WaitForEnd("messages\n", true);
          
          for (unsigned int i = 0; i < dt->GetCount(); i++) {
             wxStringTokenizer tkz((*dt)[i], " ", wxTOKEN_STRTOK);
@@ -894,7 +894,7 @@ void wxbRestorePanel::CmdStart() {
          }
       }
 
-      WaitForEnd("messages\n");
+      wxbUtils::WaitForEnd("messages\n");
 
       gauge->SetValue(totfilemessages);
 
@@ -991,40 +991,40 @@ void wxbRestorePanel::CmdConfigApply() {
       }
       wxString def; //String to send if can't use our data
       if ((cfgUpdated >> ConfigWhere) & 1) {
-         WaitForPrompt("mod\n"); /* TODO: check results */
-         WaitForPrompt("9\n");
+         wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */
+         wxbUtils::WaitForPrompt("9\n");
          dt = new wxbDataTokenizer(true);
-         WaitForPrompt(restorePanel->GetRowString("Where") + "\n");
+         wxbUtils::WaitForPrompt(restorePanel->GetRowString("Where") + "\n");
          def = "/tmp";
          cfgUpdated = cfgUpdated & (~(1 << ConfigWhere));
       }
       else if ((cfgUpdated >> ConfigReplace) & 1) {
-         WaitForPrompt("mod\n"); /* TODO: check results */
-         WaitForPrompt("10\n");
+         wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */
+         wxbUtils::WaitForPrompt("10\n");
          dt = new wxbDataTokenizer(true);
-         WaitForPrompt(wxString() << (restorePanel->GetRowSelection("Replace")+1) << "\n");
+         wxbUtils::WaitForPrompt(wxString() << (restorePanel->GetRowSelection("Replace")+1) << "\n");
          def = "1";
          cfgUpdated = cfgUpdated & (~(1 << ConfigReplace));
       }
       else if ((cfgUpdated >> ConfigWhen) & 1) {
-         WaitForPrompt("mod\n"); /* TODO: check results */
-         WaitForPrompt("6\n");
+         wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */
+         wxbUtils::WaitForPrompt("6\n");
          dt = new wxbDataTokenizer(true);
-         WaitForPrompt(restorePanel->GetRowString("When") + "\n");
+         wxbUtils::WaitForPrompt(restorePanel->GetRowString("When") + "\n");
          def = "";
          cfgUpdated = cfgUpdated & (~(1 << ConfigWhen));
       }
       else if ((cfgUpdated >> ConfigPriority) & 1) {
-         WaitForPrompt("mod\n"); /* TODO: check results */
-         WaitForPrompt("7\n");
+         wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */
+         wxbUtils::WaitForPrompt("7\n");
          dt = new wxbDataTokenizer(true);
-         WaitForPrompt(restorePanel->GetRowString("Priority") + "\n");
+         wxbUtils::WaitForPrompt(restorePanel->GetRowString("Priority") + "\n");
          def = "10";
          cfgUpdated = cfgUpdated & (~(1 << ConfigPriority));
       }
       else if ((cfgUpdated >> ConfigClient) & 1) {
-         WaitForPrompt("mod\n"); /* TODO: check results */
-         wxbPromptParser *pp = WaitForPrompt("5\n", true);
+         wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */
+         wxbPromptParser *pp = wxbUtils::WaitForPrompt("5\n", true);
          int client = pp->getChoices()->Index(restorePanel->GetRowString("Client"));
          if (client == wxNOT_FOUND) {
             wxbMainFrame::GetInstance()->SetStatusText("Failed to find the selected client.");
@@ -1033,13 +1033,13 @@ void wxbRestorePanel::CmdConfigApply() {
          }
          delete pp;
          dt = new wxbDataTokenizer(true);
-         WaitForPrompt(wxString() << client << "\n");
+         wxbUtils::WaitForPrompt(wxString() << client << "\n");
          def = "1";
          cfgUpdated = cfgUpdated & (~(1 << ConfigClient));
       }
       else if ((cfgUpdated >> ConfigFileset) & 1) {
-         WaitForPrompt("mod\n"); /* TODO: check results */
-         wxbPromptParser *pp = WaitForPrompt("4\n", true);
+         wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */
+         wxbPromptParser *pp = wxbUtils::WaitForPrompt("4\n", true);
          int fileset = pp->getChoices()->Index(restorePanel->GetRowString("Fileset"));
          if (fileset == wxNOT_FOUND) {
             wxbMainFrame::GetInstance()->SetStatusText("Failed to find the selected fileset.");
@@ -1048,13 +1048,13 @@ void wxbRestorePanel::CmdConfigApply() {
          }
          delete pp;
          dt = new wxbDataTokenizer(true);
-         WaitForPrompt(wxString() << fileset << "\n");
+         wxbUtils::WaitForPrompt(wxString() << fileset << "\n");
          def = "1";
          cfgUpdated = cfgUpdated & (~(1 << ConfigFileset));
       }
       else if ((cfgUpdated >> ConfigStorage) & 1) {
-         WaitForPrompt("mod\n"); /* TODO: check results */
-         wxbPromptParser *pp = WaitForPrompt("2\n", true);
+         wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */
+         wxbPromptParser *pp = wxbUtils::WaitForPrompt("2\n", true);
          int fileset = pp->getChoices()->Index(restorePanel->GetRowString("Storage"));
          if (fileset == wxNOT_FOUND) {
             wxbMainFrame::GetInstance()->SetStatusText("Failed to find the selected storage.");
@@ -1063,7 +1063,7 @@ void wxbRestorePanel::CmdConfigApply() {
          }
          delete pp;
          dt = new wxbDataTokenizer(true);
-         WaitForPrompt(wxString() << fileset << "\n");
+         wxbUtils::WaitForPrompt(wxString() << fileset << "\n");
          def = "1";
          cfgUpdated = cfgUpdated & (~(1 << ConfigFileset));
       }
@@ -1081,7 +1081,7 @@ void wxbRestorePanel::CmdConfigApply() {
       
       if (i == dt->GetCount()) {
          delete dt;   
-         dt = WaitForEnd(def + "\n", true);
+         dt = wxbUtils::WaitForEnd(def + "\n", true);
          failed = true;
       }
    }
@@ -1098,7 +1098,7 @@ void wxbRestorePanel::CmdConfigApply() {
 
 /* Cancel restore */
 void wxbRestorePanel::CmdConfigCancel() {
-   WaitForEnd("no\n");
+   wxbUtils::WaitForEnd("no\n");
    wxbMainFrame::GetInstance()->Print("Restore cancelled.\n", CS_DEBUG);
    wxbMainFrame::GetInstance()->SetStatusText("Restore cancelled.");
    SetStatus(finished);
@@ -1108,9 +1108,9 @@ void wxbRestorePanel::CmdConfigCancel() {
 void wxbRestorePanel::CmdListJobs() {
    if (status == entered) {
       configPanel->ClearRowChoices("Before");
-      WaitForPrompt("query\n");
-      WaitForPrompt("6\n");
-      wxbTableParser* tableparser = CreateAndWaitForParser(configPanel->GetRowString("Client") + "\n");
+      wxbUtils::WaitForPrompt("query\n");
+      wxbUtils::WaitForPrompt("6\n");
+      wxbTableParser* tableparser = wxbUtils::CreateAndWaitForParser(configPanel->GetRowString("Client") + "\n");
 
       for (int i = tableparser->GetCount()-1; i > -1; i--) {
          wxString str = (*tableparser)[i][3];
@@ -1249,8 +1249,8 @@ void wxbRestorePanel::CmdMark(wxTreeItemId treeitem, long* listitems, int listsi
          }
       }
 
-      WaitForEnd(wxString("cd \"") << dir << "\"\n");
-      WaitForEnd(wxString((state==1) ? "mark" : "unmark") << " \"" << file << "\"\n");
+      wxbUtils::WaitForEnd(wxString("cd \"") << dir << "\"\n");
+      wxbUtils::WaitForEnd(wxString((state==1) ? "mark" : "unmark") << " \"" << file << "\"\n");
 
       /* TODO: Check commands results */
 
@@ -1285,80 +1285,12 @@ void wxbRestorePanel::CmdMark(wxTreeItemId treeitem, long* listitems, int listsi
    General functions
   ----------------------------------------------------------------------------*/
 
-/* Parse a table in tableParser */
-wxbTableParser* wxbRestorePanel::CreateAndWaitForParser(wxString cmd) {
-   wxbTableParser* tableParser = new wxbTableParser();
-
-   wxbMainFrame::GetInstance()->Send(cmd);
-
-   //time_t base = wxDateTime::Now().GetTicks();
-   while (!tableParser->hasFinished()) {
-      //innerThread->Yield();
-      wxTheApp->Yield(true);
-      ::wxUsleep(100);
-      //if (base+15 < wxDateTime::Now().GetTicks()) break;
-   }
-   return tableParser;
-}
-
-/* Run a command, and waits until prompt result is fully received,
- * if keepresults is true, returns a valid pointer to a wxbPromptParser
- * containing the data. */
-wxbPromptParser* wxbRestorePanel::WaitForPrompt(wxString cmd, bool keepresults) {
-   wxbPromptParser* promptParser = new wxbPromptParser();
-   
-   wxbMainFrame::GetInstance()->Send(cmd);
-    
-   //time_t base = wxDateTime::Now().GetTicks();
-   while (!promptParser->hasFinished()) {
-      //innerThread->Yield();
-      wxTheApp->Yield(true);
-      ::wxUsleep(100);
-      //if (base+15 < wxDateTime::Now().GetTicks()) break;
-   }
-     
-   if (keepresults) {
-      return promptParser;
-   }
-   else {
-      delete promptParser;
-      return NULL;
-   }  
-}
-
-/* Run a command, and waits until result is fully received. */
-wxbDataTokenizer* wxbRestorePanel::WaitForEnd(wxString cmd, bool keepresults, bool linebyline) {
-   wxbDataTokenizer* datatokenizer = new wxbDataTokenizer(linebyline);
-
-   wxbMainFrame::GetInstance()->Send(cmd);
-   
-   //wxbMainFrame::GetInstance()->Print("(<WFE)", CS_DEBUG);
-   
-   //time_t base = wxDateTime::Now().GetTicks();
-   while (!datatokenizer->hasFinished()) {
-      //innerThread->Yield();
-      wxTheApp->Yield(true);
-      ::wxUsleep(100);
-      //if (base+15 < wxDateTime::Now().GetTicks()) break;
-   }
-   
-   //wxbMainFrame::GetInstance()->Print("(>WFE)", CS_DEBUG);
-   
-   if (keepresults) {
-      return datatokenizer;
-   }
-   else {
-      delete datatokenizer;
-      return NULL;
-   }
-}
-
 /* Run a dir command, and waits until result is fully received. */
 void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse) {
 //   this->updatelist = updatelist;
    wxbDataTokenizer* dt;
 
-   dt = WaitForEnd(wxString("cd \"") << 
+   dt = wxbUtils::WaitForEnd(wxString("cd \"") << 
       static_cast<wxbTreeItemData*>(tree->GetItemData(item))
          ->GetPath() << "\"\n", false);
 
@@ -1370,7 +1302,7 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool re
 
    if (updatelist)
       list->DeleteAllItems();
-   dt = WaitForEnd("dir\n", true);
+   dt = wxbUtils::WaitForEnd("dir\n", true);
    
    wxString str;
    
@@ -1674,7 +1606,7 @@ void wxbRestorePanel::RefreshList() {
 /* Update first config, adapting settings to the job name selected */
 void wxbRestorePanel::UpdateFirstConfig() {
    configPanel->Enable(false);
-   wxbDataTokenizer* dt = WaitForEnd(wxString(".defaults job=") + configPanel->GetRowString("Job Name") + "\n", true, false);
+   wxbDataTokenizer* dt = wxbUtils::WaitForEnd(wxString(".defaults job=") + configPanel->GetRowString("Job Name") + "\n", true, false);
    /* job=RestoreFiles
     * pool=Default
     * messages=Standard
index 62e5d480ec98d02dfa7c387db705dec4099b11f5..b735e47ad92f11edb443234e95e5551ee1c2b1d5 100644 (file)
@@ -94,19 +94,6 @@ class wxbRestorePanel : public wxbPanel
       long totfilemessages; /* When restoring, number of files to be restored */
       wxString jobid;
 
-      /* Parse a table in tableParser */
-      wxbTableParser* CreateAndWaitForParser(wxString cmd);
-
-      /* Run a command, and waits until result is fully received,
-       * if keepresults is true, returns a valid pointer to a wxbDataTokenizer
-       * containing the data. */
-      wxbDataTokenizer* WaitForEnd(wxString cmd, bool keepresults = false, bool linebyline = true);
-
-      /* Run a command, and waits until prompt result is fully received,
-       * if keepresults is true, returns a valid pointer to a wxbPromptParser
-       * containing the data. */
-      wxbPromptParser* WaitForPrompt(wxString cmd, bool keepresults = false);
-
       /* Run a dir command, and waits until result is fully received.
        * If recurse is true, update the children too. */
       void UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse);
index ab69ad2cafa58abb6d93ae4e9e4f50dad827d84d..d30954ecc73492084414aadf3d78ab6c851279ef 100644 (file)
 
 #include "csprint.h"
 
+#include "wxbtableparser.h"
+
+
+bool wxbUtils::inited = false;
+
+/* Initialization */
+void wxbUtils::Init() {
+   inited = true;
+}
+
+/* Reset state */
+void wxbUtils::Reset() {
+   inited = false;
+}
+
+/* Parse a table in tableParser */
+wxbTableParser* wxbUtils::CreateAndWaitForParser(wxString cmd) {
+   wxbTableParser* tableParser = new wxbTableParser();
+
+   wxbMainFrame::GetInstance()->Send(cmd);
+
+   //time_t base = wxDateTime::Now().GetTicks();
+   while (!tableParser->hasFinished()) {
+      //innerThread->Yield();
+      wxTheApp->Yield(true);
+      ::wxUsleep(100);
+      //if (base+15 < wxDateTime::Now().GetTicks()) break;
+   }
+   return tableParser;
+}
+
+/* Run a command, and waits until prompt result is fully received,
+ * if keepresults is true, returns a valid pointer to a wxbPromptParser
+ * containing the data. */
+wxbPromptParser* wxbUtils::WaitForPrompt(wxString cmd, bool keepresults) {
+   wxbPromptParser* promptParser = new wxbPromptParser();
+   
+   wxbMainFrame::GetInstance()->Send(cmd);
+    
+   //time_t base = wxDateTime::Now().GetTicks();
+   while (!promptParser->hasFinished()) {
+      //innerThread->Yield();
+      wxTheApp->Yield(true);
+      ::wxUsleep(100);
+      //if (base+15 < wxDateTime::Now().GetTicks()) break;
+   }
+     
+   if (keepresults) {
+      return promptParser;
+   }
+   else {
+      delete promptParser;
+      return NULL;
+   }  
+}
+
+/* Run a command, and waits until result is fully received. */
+wxbDataTokenizer* wxbUtils::WaitForEnd(wxString cmd, bool keepresults, bool linebyline) {
+   wxbDataTokenizer* datatokenizer = new wxbDataTokenizer(linebyline);
+
+   wxbMainFrame::GetInstance()->Send(cmd);
+   
+   //wxbMainFrame::GetInstance()->Print("(<WFE)", CS_DEBUG);
+   
+   //time_t base = wxDateTime::Now().GetTicks();
+   while (!datatokenizer->hasFinished()) {
+      //innerThread->Yield();
+      wxTheApp->Yield(true);
+      ::wxUsleep(100);
+      //if (base+15 < wxDateTime::Now().GetTicks()) break;
+   }
+   
+   //wxbMainFrame::GetInstance()->Print("(>WFE)", CS_DEBUG);
+   
+   if (keepresults) {
+      return datatokenizer;
+   }
+   else {
+      delete datatokenizer;
+      return NULL;
+   }
+}
+
+
 /* Creates a new wxbDataParser, and register it in wxbMainFrame */
 wxbDataParser::wxbDataParser(bool lineanalysis) {
    wxbMainFrame::GetInstance()->Register(this);
@@ -63,7 +147,7 @@ bool wxbDataParser::Print(wxString str, int status) {
       }
       else {
          wxStringTokenizer tkz(str, "\n", 
-            wxTOKEN_RET_DELIMS | wxTOKEN_RET_EMPTY | wxTOKEN_RET_EMPTY_ALL);
+            (wxStringTokenizerMode)(wxTOKEN_RET_DELIMS | wxTOKEN_RET_EMPTY | wxTOKEN_RET_EMPTY_ALL));
    
          while ( tkz.HasMoreTokens() ) {
             buffer << tkz.GetNextToken();
index d2a0df4946bcec6b8fc3319b2d110444d26ba1c2..9c4ed6893efd6d31a8363a47f3c75305be214b8e 100644 (file)
@@ -24,8 +24,8 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
-#ifndef WXBPANEL_H
-#define WXBPANEL_H
+#ifndef WXBUTILS_H
+#define WXBUTILS_H
 
 #include "wx/wxprec.h"
 
    #include "wx/wx.h"
 #endif
 
+class wxbTableParser;
+class wxbDataParser;
+class wxbDataTokenizer;
+class wxbPromptParser;
+
+/*
+ *  General functions
+ */
+class wxbUtils
+{
+   public:
+      /* Initialization */
+      static void Init();
+      
+      /* Reset state */
+      static void Reset();
+   
+      /* Parse a table in tableParser */
+      static wxbTableParser* CreateAndWaitForParser(wxString cmd);
+
+      /* Run a command, and waits until result is fully received,
+       * if keepresults is true, returns a valid pointer to a wxbDataTokenizer
+       * containing the data. */
+      static wxbDataTokenizer* WaitForEnd(wxString cmd, bool keepresults = false, bool linebyline = true);
+
+      /* Run a command, and waits until prompt result is fully received,
+       * if keepresults is true, returns a valid pointer to a wxbPromptParser
+       * containing the data. */
+      static wxbPromptParser* WaitForPrompt(wxString cmd, bool keepresults = false);
+
+   private:
+      static bool inited;
+};
+
 /*
  *  abstract class that can receive director information.
  */
@@ -157,5 +191,4 @@ class wxbPromptParser: public wxbDataParser
       wxString questionStr;
 };
 
-#endif // WXBPANEL_H
-
+#endif // WXBUTILS_H