3 * wxbPanel for restoring files
5 * Nicolas Boichat, April-May 2004
10 Copyright (C) 2004 Kern Sibbald and John Walker
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.
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.
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.
27 #ifndef WXBRESTOREPANEL_H
28 #define WXBRESTOREPANEL_H
30 #include "wx/wxprec.h"
36 #include "wxbtableparser.h"
38 #include <wx/thread.h>
39 #include <wx/listctrl.h>
40 #include <wx/treectrl.h>
42 #include <wx/stattext.h>
43 #include <wx/splitter.h>
47 #include "wxbconfigpanel.h"
48 #include "wxbtreectrl.h"
49 #include "wxblistctrl.h"
51 WX_DECLARE_LIST(wxEvent, wxbEventList);
53 /* Class for storing directory entries (results from dir commands). */
62 int marked; /* 0 - Not Marked, 1 - Marked, 2 - Some file under is marked */
63 wxString fullname; /* full name with path */
64 wxString filename; /* only filename, no path */
68 * wxbPanel for restoring files
70 class wxbRestorePanel : public wxbPanel
73 wxbRestorePanel(wxWindow* parent);
76 /* wxbPanel overloadings */
77 virtual wxString GetTitle();
78 virtual void EnablePanel(bool enable = true);
81 /* Commands called by events handler */
83 /* The main button has been clicked */
86 /* The cancel button has been clicked */
89 /* Apply configuration changes */
90 void CmdConfigApply();
93 void CmdConfigCancel();
95 /* List jobs for a specified client */
98 /* List files and directories for a specified tree item */
99 void CmdList(wxTreeItemId item);
101 /* Mark a treeitem (directory) or several listitems (file or directory),
102 * state defines if it should mark (1), unmark (0), or switch state (-1) */
103 void CmdMark(wxTreeItemId treeitem, long* listitems, int listsize, int state = -1);
105 /* General functions and variables */
106 //bool ended; /* The last command send has finished */
108 //long filemessages; /* When restoring, number of files restored */
109 long totfilemessages; /* When restoring, number of files to be restored */
112 /* Run a dir command, and waits until result is fully received.
113 * If recurse is true, update the children too. */
114 void UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse);
116 /* Parse dir command results. */
117 int ParseList(wxString line, wxbDirEntry* entry);
119 /* Sets a list item state, and update its parents and children if it is a directory */
120 void SetListItemState(long listitem, int newstate);
122 /* Sets a tree item state, and update its children, parents and list (if necessary) */
123 void SetTreeItemState(wxTreeItemId item, int newstate);
125 /* Update a tree item parents' state */
126 void UpdateTreeItemState(wxTreeItemId item);
128 /* Refresh the whole tree. */
131 /* Refresh file list */
134 /* Update first config, adapting settings to the job name selected */
135 void UpdateFirstConfig();
137 /* Update second config */
138 bool UpdateSecondConfig(wxbDataTokenizer* dt);
143 disabled, // The panel is not activatable
144 activable, // The panel is activable, but not activated
145 entered, // The panel is activated
146 choosing, // The user is choosing files to restore
147 listing, // Dir listing is in progress
148 configuring, // The user is configuring restore process
149 restoring, // Bacula is restoring files
150 finished // Retore done (state will change in activable)
155 /* Cancelled status :
157 * - 1 - will be cancelled
158 * - 2 - has been cancelled */
161 /* Set current status by enabling/disabling components */
162 void SetStatus(status_enum newstatus);
165 bool working; // A command is running, discard GUI events
166 void SetWorking(bool working);
168 bool markWhenCommandDone; //If an item should be (un)marked after the current listing/marking is done
169 wxTreeItemId currentTreeItem; // Currently selected tree item
171 /* Enable or disable config controls status */
172 void EnableConfig(bool enable);
175 // wxbEventList* pendingEvents; /* Stores event sent while working */ //EVTQUEUE
176 // bool processing; /* True if pendingEvents is being processed */ //EVTQUEUE
178 // virtual void AddPendingEvent(wxEvent& event);
179 // virtual bool ProcessEvent(wxEvent& event); //EVTQUEUE
181 void OnStart(wxCommandEvent& event);
182 void OnCancel(wxCommandEvent& event);
184 void OnTreeChanging(wxTreeEvent& event);
185 void OnTreeExpanding(wxTreeEvent& event);
186 void OnTreeChanged(wxTreeEvent& event);
187 void OnTreeMarked(wxbTreeMarkedEvent& event);
188 void OnTreeAdd(wxCommandEvent& event);
189 void OnTreeRemove(wxCommandEvent& event);
190 void OnTreeRefresh(wxCommandEvent& event);
192 void OnListMarked(wxbListMarkedEvent& event);
193 void OnListActivated(wxListEvent& event);
194 void OnListChanged(wxListEvent& event);
195 void OnListAdd(wxCommandEvent& event);
196 void OnListRemove(wxCommandEvent& event);
197 void OnListRefresh(wxCommandEvent& event);
199 void OnConfigUpdated(wxCommandEvent& event);
200 void OnConfigOk(wxCommandEvent& WXUNUSED(event));
201 void OnConfigApply(wxCommandEvent& WXUNUSED(event));
202 void OnConfigCancel(wxCommandEvent& WXUNUSED(event));
205 wxBoxSizer *centerSizer; /* Center sizer */
206 wxSplitterWindow *treelistPanel; /* Panel which contains tree and list */
207 wxbConfigPanel *configPanel; /* Panel which contains initial restore options */
208 wxbConfigPanel *restorePanel; /* Panel which contains final restore options */
210 wxImageList* imagelist; //image list for tree and list
217 wxButton* treeremove;
218 wxButton* treerefresh;
222 wxButton* listremove;
223 wxButton* listrefresh;
227 long cfgUpdated; //keeps which config fields have been updated
229 friend class wxbSplitterWindow;
231 DECLARE_EVENT_TABLE();
234 #endif // WXBRESTOREPANEL_H