3 * wxbPanel for restoring files
5 * Nicolas Boichat, April-May 2004
10 Bacula® - The Network Backup Solution
12 Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
14 The main author of Bacula is Kern Sibbald, with contributions from
15 many others, a complete list can be found in the file AUTHORS.
16 This program is Free Software; you can redistribute it and/or
17 modify it under the terms of version two of the GNU General Public
18 License as published by the Free Software Foundation plus additions
19 that are listed in the file LICENSE.
21 This program is distributed in the hope that it will be useful, but
22 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31 Bacula® is a registered trademark of John Walker.
32 The licensor of Bacula is the Free Software Foundation Europe
33 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
34 Switzerland, email:ftf@fsfeurope.org.
37 #ifndef WXBRESTOREPANEL_H
38 #define WXBRESTOREPANEL_H
40 #include "wx/wxprec.h"
46 #include "wxbtableparser.h"
48 #include <wx/thread.h>
49 #include <wx/listctrl.h>
50 #include <wx/treectrl.h>
52 #include <wx/stattext.h>
53 #include <wx/splitter.h>
57 #include "wxbconfigpanel.h"
58 #include "wxbtreectrl.h"
59 #include "wxblistctrl.h"
61 WX_DECLARE_LIST(wxEvent, wxbEventList);
63 /* Class for storing directory entries (results from dir commands). */
72 int marked; /* 0 - Not Marked, 1 - Marked, 2 - Some file under is marked */
73 wxString fullname; /* full name with path */
74 wxString filename; /* only filename, no path */
78 * wxbPanel for restoring files
80 class wxbRestorePanel : public wxbPanel
83 wxbRestorePanel(wxWindow* parent);
86 /* wxbPanel overloadings */
87 virtual wxString GetTitle();
88 virtual void EnablePanel(bool enable = true);
91 /* Commands called by events handler */
93 /* The main button has been clicked */
96 /* The cancel button has been clicked */
99 /* Apply configuration changes */
100 void CmdConfigApply();
103 void CmdConfigCancel();
105 /* List jobs for a specified client */
108 /* List files and directories for a specified tree item */
109 void CmdList(wxTreeItemId item);
111 /* Mark a treeitem (directory) or several listitems (file or directory),
112 * state defines if it should mark (1), unmark (0), or switch state (-1) */
113 void CmdMark(wxTreeItemId treeitem, long* listitems, int listsize, int state = -1);
115 /* General functions and variables */
116 //bool ended; /* The last command send has finished */
118 //long filemessages; /* When restoring, number of files restored */
119 long totfilemessages; /* When restoring, number of files to be restored */
122 /* Run a dir command, and waits until result is fully received.
123 * If recurse is true, update the children too. */
124 void UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse);
126 /* Parse dir command results. */
127 int ParseList(wxString line, wxbDirEntry* entry);
129 /* Sets a list item state, and update its parents and children if it is a directory */
130 void SetListItemState(long listitem, int newstate);
132 /* Sets a tree item state, and update its children, parents and list (if necessary) */
133 void SetTreeItemState(wxTreeItemId item, int newstate);
135 /* Update a tree item parents' state */
136 void UpdateTreeItemState(wxTreeItemId item);
138 /* Refresh the whole tree. */
141 /* Refresh file list */
144 /* Update first config, adapting settings to the job name selected */
145 void UpdateFirstConfig();
147 /* Update second config */
148 bool UpdateSecondConfig(wxbDataTokenizer* dt);
153 disabled, // The panel is not activatable
154 activable, // The panel is activable, but not activated
155 entered, // The panel is activated
156 choosing, // The user is choosing files to restore
157 listing, // Dir listing is in progress
158 configuring, // The user is configuring restore process
159 restoring, // Bacula is restoring files
160 finished // Retore done (state will change in activable)
165 /* Cancelled status :
167 * - 1 - will be cancelled
168 * - 2 - has been cancelled */
171 /* Set current status by enabling/disabling components */
172 void SetStatus(status_enum newstatus);
175 bool working; // A command is running, discard GUI events
176 void SetWorking(bool working);
178 bool markWhenCommandDone; //If an item should be (un)marked after the current listing/marking is done
179 wxTreeItemId currentTreeItem; // Currently selected tree item
181 /* Enable or disable config controls status */
182 void EnableConfig(bool enable);
185 // wxbEventList* pendingEvents; /* Stores event sent while working */ //EVTQUEUE
186 // bool processing; /* True if pendingEvents is being processed */ //EVTQUEUE
188 // virtual void AddPendingEvent(wxEvent& event);
189 // virtual bool ProcessEvent(wxEvent& event); //EVTQUEUE
191 void OnStart(wxCommandEvent& event);
192 void OnCancel(wxCommandEvent& event);
194 void OnTreeChanging(wxTreeEvent& event);
195 void OnTreeExpanding(wxTreeEvent& event);
196 void OnTreeChanged(wxTreeEvent& event);
197 void OnTreeMarked(wxbTreeMarkedEvent& event);
198 void OnTreeAdd(wxCommandEvent& event);
199 void OnTreeRemove(wxCommandEvent& event);
200 void OnTreeRefresh(wxCommandEvent& event);
202 void OnListMarked(wxbListMarkedEvent& event);
203 void OnListActivated(wxListEvent& event);
204 void OnListChanged(wxListEvent& event);
205 void OnListAdd(wxCommandEvent& event);
206 void OnListRemove(wxCommandEvent& event);
207 void OnListRefresh(wxCommandEvent& event);
209 void OnConfigUpdated(wxCommandEvent& event);
210 void OnConfigOk(wxCommandEvent& WXUNUSED(event));
211 void OnConfigApply(wxCommandEvent& WXUNUSED(event));
212 void OnConfigCancel(wxCommandEvent& WXUNUSED(event));
215 wxBoxSizer *centerSizer; /* Center sizer */
216 wxSplitterWindow *treelistPanel; /* Panel which contains tree and list */
217 wxbConfigPanel *configPanel; /* Panel which contains initial restore options */
218 wxbConfigPanel *restorePanel; /* Panel which contains final restore options */
220 wxImageList* imagelist; //image list for tree and list
227 wxButton* treeremove;
228 wxButton* treerefresh;
232 wxButton* listremove;
233 wxButton* listrefresh;
237 long cfgUpdated; //keeps which config fields have been updated
239 friend class wxbSplitterWindow;
241 DECLARE_EVENT_TABLE();
244 #endif // WXBRESTOREPANEL_H