3 * wxbDataParser, class that receives and analyses data
4 * wxbPanel, main frame's notebook panels
6 * Nicolas Boichat, April-July 2004
11 Bacula® - The Network Backup Solution
13 Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
15 The main author of Bacula is Kern Sibbald, with contributions from
16 many others, a complete list can be found in the file AUTHORS.
17 This program is Free Software; you can redistribute it and/or
18 modify it under the terms of version two of the GNU General Public
19 License as published by the Free Software Foundation and included
22 This program is distributed in the hope that it will be useful, but
23 WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 Bacula® is a registered trademark of John Walker.
33 The licensor of Bacula is the Free Software Foundation Europe
34 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
35 Switzerland, email:ftf@fsfeurope.org.
41 #include "wx/wxprec.h"
49 class wxbDataTokenizer;
50 class wxbPromptParser;
64 /* Parse a table in tableParser */
65 static wxbTableParser* CreateAndWaitForParser(wxString cmd);
67 /* Run a command, and waits until result is fully received,
68 * if keepresults is true, returns a valid pointer to a wxbDataTokenizer
69 * containing the data. */
70 static wxbDataTokenizer* WaitForEnd(wxString cmd, bool keepresults = false, bool linebyline = true);
72 /* Run a command, and waits until prompt result is fully received,
73 * if keepresults is true, returns a valid pointer to a wxbPromptParser
74 * containing the data. */
75 static wxbPromptParser* WaitForPrompt(wxString cmd, bool keepresults = false);
77 /* Sleeps during milliseconds (wrapper for wxUsleep (2.4) or wxMilliSleep (2.6)) */
78 static void MilliSleep(unsigned long milliseconds);
80 static wxString ConvertToPrintable(wxString& str);
87 * abstract class that can receive director information.
92 /* Creates a new wxbDataParser, and register it in wxbMainFrame
93 * lineanalysis : indicate if date is to be analysed line by line (true)
94 * or packet by packet (false).
96 wxbDataParser(bool lineanalysis);
98 /* Destroy a wxbDataParser, and unregister it in wxbMainFrame */
99 virtual ~wxbDataParser();
102 * Receives director information, forwarded by wxbMainFrame, and sends it
103 * line by line to the virtual function Analyse.
105 * Returns true if status == CS_PROMPT and the message has been parsed
108 bool Print(wxString str, int status);
111 * Receives data to analyse.
113 virtual bool Analyse(wxString str, int status) = 0;
120 * abstract panel that can receive director information.
122 class wxbPanel : public wxPanel
125 wxbPanel(wxWindow* parent) : wxPanel(parent) {}
128 * Tab title in the notebook.
130 virtual wxString GetTitle() = 0;
133 * Enable or disable this panel
135 virtual void EnablePanel(bool enable = true) = 0;
139 * Receives director information, and splits it by line.
141 * datatokenizer[0] retrieves first line
143 class wxbDataTokenizer: public wxbDataParser, public wxArrayString
146 /* Creates a new wxbDataTokenizer */
147 wxbDataTokenizer(bool linebyline);
149 /* Destroy a wxbDataTokenizer */
150 virtual ~wxbDataTokenizer();
153 * Receives data to analyse.
155 virtual bool Analyse(wxString str, int status);
157 /* Returns true if the last signal received was an end signal,
158 * indicating that no more data is available */
166 * Receives director information, and check if the last messages are questions.
168 class wxbPromptParser: public wxbDataParser
171 /* Creates a new wxbDataTokenizer */
174 /* Destroy a wxbDataTokenizer */
175 virtual ~wxbPromptParser();
178 * Receives data to analyse.
180 virtual bool Analyse(wxString str, int status);
182 /* Returns true if the last signal received was an prompt signal,
183 * or an end signal */
186 /* Returns true if the last message received is a prompt message */
189 /* Returns multiple choice question's introduction */
190 wxString getIntroString();
192 /* Returns question string */
193 wxString getQuestionString();
195 /* Returns a wxArrayString containing the indexed choices we have
196 * to answer the question, or NULL if this question is not a multiple
198 wxArrayString* getChoices();
200 /* Returns true if the expected answer to the choice list is a number,
201 * false if it is a string (for example yes/mod/no). */
202 bool isNumericalChoice();
209 wxArrayString* choices;
210 wxString questionStr;