]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbrestorepanel.h
3e1fdcd2e549baee2f7d6444013841b3932106f5
[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
39 /*
40  * wxbPanel for restoring files
41  */
42 class wxbRestorePanel : public wxbPanel
43 {
44    public:
45       wxbRestorePanel(wxWindow* parent);
46       ~wxbRestorePanel();
47
48       /* wxbPanel overloadings */
49       virtual wxString GetTitle();
50       virtual void Print(wxString str, int status);
51
52    private:
53 /* Commands called by events handler */
54
55       /* The main button has been clicked */
56       void CmdStart();
57
58        /* List jobs for a specified client */
59       void CmdListJobs();
60
61       /* List files and directories for a specified tree item */
62       void CmdList(wxTreeItemId item);
63
64       /* Mark a treeitem (directory) or a listitem (file or directory) */
65       void CmdMark(wxTreeItemId treeitem, long listitem);
66
67 /* General functions and variables */
68       bool ended; /* The last command send has finished */
69
70       long filemessages; /* When restoring, number of files restored */
71       long totfilemessages; /* When restoring, number of files to be restored */
72
73       /* When listing a directory, sets if file list must be updated
74        * (otherwise only the tree structure is updated)
75        */
76       bool updatelist;
77
78       wxbTableParser* tableParser; /* Used to parse tables */
79
80       /* Parse a table in tableParser */
81       void CreateAndWaitForParser(wxString cmd);
82
83       /* Run a command, and waits until result is fully received. */
84       void WaitForEnd(wxString cmd);
85
86       /* Run a dir command, and waits until result is fully received. */
87       void WaitForList(wxTreeItemId item, bool updatelist);
88
89       /* Parse dir command results. */
90       wxString* ParseList(wxString line);
91
92       /* Sets a list item state, and update its parents and children if it is a directory */
93       void SetListItemState(long listitem, int newstate);
94
95       /* Sets a tree item state, and update its children, parents and list (if necessary) */
96       void SetTreeItemState(wxTreeItemId item, int newstate);
97       
98       /* Update a tree item parents' state */
99       void UpdateTreeItemState(wxTreeItemId item);
100
101       /* Refresh a tree item, and all its children. */
102       void RefreshTree(wxTreeItemId item);
103
104 /* Status related */
105       enum status_enum
106       {
107          disabled,  // The panel is not activated
108          entered,   // The panel is activated
109          choosing,  // The user is choosing files to restore
110          listing,   // Dir listing is in progress
111          restoring, // Bacula is restoring files
112          finished   // Retore done
113       };
114
115       status_enum status;
116
117       /* Set current status by enabling/disabling components */
118       void setStatus(status_enum newstatus);
119
120 /* UI related */
121       bool working; // A command is running, discard GUI events
122       wxTreeItemId currentTreeItem; // Currently selected tree item
123
124 /* Event handling */
125       void OnStart(wxEvent& WXUNUSED(event));
126       void OnTreeChanging(wxTreeEvent& event);
127       void OnTreeExpanding(wxTreeEvent& event);
128       void OnTreeChanged(wxTreeEvent& event);
129       void OnTreeMarked(wxbTreeMarkedEvent& event);
130       void OnListRightClicked(wxListEvent& event);
131       void OnListActivated(wxListEvent& event);
132       void OnClientChoiceChanged(wxCommandEvent& event);
133
134 /* Components */
135       wxImageList* imagelist; //image list for tree and list
136
137       wxButton* start;
138       wxChoice* clientChoice;
139       wxChoice* jobChoice;
140       wxbTreeCtrl* tree;
141       wxListCtrl* list;
142       wxGauge* gauge;
143
144       DECLARE_EVENT_TABLE();
145 };
146
147 #endif // WXBRESTOREPANEL_H
148