]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbrestorepanel.h
- Added a locking function in wxbPanel.
[bacula/bacula] / bacula / src / wx-console / wxbrestorepanel.h
1 /*
2    Copyright (C) 2004 Kern Sibbald and John Walker
3
4    This program is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public License
6    as published by the Free Software Foundation; either version 2
7    of the License, or (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 #ifndef WXBRESTOREPANEL_H
20 #define WXBRESTOREPANEL_H
21
22 #include "wx/wxprec.h"
23
24 #ifndef WX_PRECOMP
25    #include "wx/wx.h"
26 #endif
27
28 #include "wxbtableparser.h"
29
30 #include <wx/thread.h>
31 #include <wx/listctrl.h>
32 #include <wx/treectrl.h>
33 #include <wx/gauge.h>
34
35 #include "wxbpanel.h"
36
37 #include "wxbtreectrl.h"
38 #include "wxblistctrl.h"
39
40 /*
41  * wxbPanel for restoring files
42  */
43 class wxbRestorePanel : public wxbPanel
44 {
45    public:
46       wxbRestorePanel(wxWindow* parent);
47       ~wxbRestorePanel();
48
49       /* wxbPanel overloadings */
50       virtual wxString GetTitle();
51       virtual void Print(wxString str, int status);
52       virtual void EnablePanel(bool enable = true);
53
54    private:
55 /* Commands called by events handler */
56
57       /* The main button has been clicked */
58       void CmdStart();
59
60        /* List jobs for a specified client */
61       void CmdListJobs();
62
63       /* List files and directories for a specified tree item */
64       void CmdList(wxTreeItemId item);
65
66       /* Mark a treeitem (directory) or a listitem (file or directory) */
67       void CmdMark(wxTreeItemId treeitem, long listitem);
68
69 /* General functions and variables */
70       bool ended; /* The last command send has finished */
71
72       long filemessages; /* When restoring, number of files restored */
73       long totfilemessages; /* When restoring, number of files to be restored */
74
75       /* When listing a directory, sets if file list must be updated
76        * (otherwise only the tree structure is updated)
77        */
78       bool updatelist;
79
80       wxbTableParser* tableParser; /* Used to parse tables */
81
82       /* Parse a table in tableParser */
83       void CreateAndWaitForParser(wxString cmd);
84
85       /* Run a command, and waits until result is fully received. */
86       void WaitForEnd(wxString cmd);
87
88       /* Run a dir command, and waits until result is fully received. */
89       void WaitForList(wxTreeItemId item, bool updatelist);
90
91       /* Parse dir command results. */
92       wxString* ParseList(wxString line);
93
94       /* Sets a list item state, and update its parents and children if it is a directory */
95       void SetListItemState(long listitem, int newstate);
96
97       /* Sets a tree item state, and update its children, parents and list (if necessary) */
98       void SetTreeItemState(wxTreeItemId item, int newstate);
99       
100       /* Update a tree item parents' state */
101       void UpdateTreeItemState(wxTreeItemId item);
102
103       /* Refresh a tree item, and all its children. */
104       void RefreshTree(wxTreeItemId item);
105
106 /* Status related */
107       enum status_enum
108       {
109          disabled,  // The panel is not activatable
110          activable, // The panel is activable, but not activated
111          entered,   // The panel is activated
112          choosing,  // The user is choosing files to restore
113          listing,   // Dir listing is in progress
114          restoring, // Bacula is restoring files
115          finished   // Retore done (state will change in activable)
116       };
117
118       status_enum status;
119
120       /* Set current status by enabling/disabling components */
121       void SetStatus(status_enum newstatus);
122
123 /* UI related */
124       bool working; // A command is running, discard GUI events
125       wxTreeItemId currentTreeItem; // Currently selected tree item
126
127 /* Event handling */
128       void OnStart(wxEvent& WXUNUSED(event));
129       void OnTreeChanging(wxTreeEvent& event);
130       void OnTreeExpanding(wxTreeEvent& event);
131       void OnTreeChanged(wxTreeEvent& event);
132       void OnTreeMarked(wxbTreeMarkedEvent& event);
133       void OnListMarked(wxbListMarkedEvent& event);
134       void OnListActivated(wxListEvent& event);
135       void OnClientChoiceChanged(wxCommandEvent& event);
136
137 /* Components */
138       wxImageList* imagelist; //image list for tree and list
139
140       wxButton* start;
141       wxChoice* clientChoice;
142       wxChoice* jobChoice;
143       wxbTreeCtrl* tree;
144       wxbListCtrl* list;
145       wxGauge* gauge;
146
147       DECLARE_EVENT_TABLE();
148 };
149
150 #endif // WXBRESTOREPANEL_H
151