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