]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbutils.h
- wxbMainFrame : the user is now prompted when an
[bacula/bacula] / bacula / src / wx-console / wxbutils.h
1 /*
2  *
3  *   wxbDataParser, class that receives and analyses data
4  *   wxbPanel, main frame's notebook panels
5  *
6  *    Nicolas Boichat, April 2004
7  *
8  */
9 /*
10    Copyright (C) 2004 Kern Sibbald and John Walker
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License
14    as published by the Free Software Foundation; either version 2
15    of the License, or (at your option) any later version.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20    GNU General Public License for more details.
21
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifndef WXBPANEL_H
28 #define WXBPANEL_H
29
30 #include "wx/wxprec.h"
31
32 #ifndef WX_PRECOMP
33    #include "wx/wx.h"
34 #endif
35
36 /*
37  *  abstract class that can receive director information.
38  */
39 class wxbDataParser
40 {
41    public:
42       /* Creates a new wxbDataParser, and register it in wxbMainFrame
43        * lineanalysis : indicate if date is to be analysed line by line (true)
44        * or packet by packet (false).
45        */
46       wxbDataParser(bool lineanalysis);
47
48       /* Destroy a wxbDataParser, and unregister it in wxbMainFrame */
49       virtual ~wxbDataParser();
50
51       /*
52        * Receives director information, forwarded by wxbMainFrame, and sends it
53        * line by line to the virtual function Analyse.
54        * 
55        * Returns true if status == CS_PROMPT and the message has been parsed
56        * correctly.
57        */
58       bool Print(wxString str, int status);
59
60       /*
61        *   Receives data to analyse.
62        */
63       virtual bool Analyse(wxString str, int status) = 0;
64    private:
65       bool lineanalysis;
66       wxString buffer;
67 };
68
69 /*
70  *  abstract panel that can receive director information.
71  */
72 class wxbPanel : public wxPanel
73 {
74    public:
75       wxbPanel(wxWindow* parent) : wxPanel(parent) {}
76
77       /*
78        *   Tab title in the notebook.
79        */
80       virtual wxString GetTitle() = 0;
81       
82       /*
83        *   Enable or disable this panel
84        */
85       virtual void EnablePanel(bool enable = true) = 0;
86 };
87
88 /*
89  *  Receives director information, and splits it by line.
90  * 
91  * datatokenizer[0] retrieves first line
92  */
93 class wxbDataTokenizer: public wxbDataParser, public wxArrayString
94 {
95    public:
96       /* Creates a new wxbDataTokenizer */
97       wxbDataTokenizer(bool linebyline);
98
99       /* Destroy a wxbDataTokenizer */
100       virtual ~wxbDataTokenizer();
101
102       /*
103        *   Receives data to analyse.
104        */
105       virtual bool Analyse(wxString str, int status);
106       
107       /* Returns true if the last signal received was an end signal, 
108        * indicating that no more data is available */
109       bool hasFinished();
110       
111    private:
112       bool finished;
113 };
114
115 /*
116  *  Receives director information, and check if the last messages are questions.
117  */
118 class wxbPromptParser: public wxbDataParser
119 {
120    public:
121       /* Creates a new wxbDataTokenizer */
122       wxbPromptParser();
123
124       /* Destroy a wxbDataTokenizer */
125       virtual ~wxbPromptParser();
126
127       /*
128        *   Receives data to analyse.
129        */
130       virtual bool Analyse(wxString str, int status);
131       
132       /* Returns true if the last signal received was an prompt signal, 
133        * or an end signal */
134       bool hasFinished();
135       
136       /* Returns true if the last message received is a prompt message */
137       bool isPrompt();
138
139       /* Returns multiple choice question's introduction */
140       wxString getIntroString();
141
142       /* Returns question string */
143       wxString getQuestionString();
144       
145       /* Return a wxArrayString containing the indexed choices we have
146        * to answer the question, or NULL if this question is not a multiple
147        * choice one. */
148       wxArrayString* getChoices();
149       
150       
151       
152    private:
153       bool finished;
154       bool prompt;
155       wxString introStr;
156       wxArrayString* choices;
157       wxString questionStr;
158 };
159
160 #endif // WXBPANEL_H
161