3 * wxbPanel for restoring files
5 * Nicolas Boichat, April-May 2004
10 Copyright (C) 2004-2005 Kern Sibbald
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 version 2 as amended with additional clauses defined in the
15 file LICENSE in the main source directory.
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 the file LICENSE for additional details.
24 #ifndef WXBRESTOREPANEL_H
25 #define WXBRESTOREPANEL_H
27 #include "wx/wxprec.h"
33 #include "wxbtableparser.h"
35 #include <wx/thread.h>
36 #include <wx/listctrl.h>
37 #include <wx/treectrl.h>
39 #include <wx/stattext.h>
40 #include <wx/splitter.h>
44 #include "wxbconfigpanel.h"
45 #include "wxbtreectrl.h"
46 #include "wxblistctrl.h"
48 WX_DECLARE_LIST(wxEvent, wxbEventList);
50 /* Class for storing directory entries (results from dir commands). */
59 int marked; /* 0 - Not Marked, 1 - Marked, 2 - Some file under is marked */
60 wxString fullname; /* full name with path */
61 wxString filename; /* only filename, no path */
65 * wxbPanel for restoring files
67 class wxbRestorePanel : public wxbPanel
70 wxbRestorePanel(wxWindow* parent);
73 /* wxbPanel overloadings */
74 virtual wxString GetTitle();
75 virtual void EnablePanel(bool enable = true);
78 /* Commands called by events handler */
80 /* The main button has been clicked */
83 /* The cancel button has been clicked */
86 /* Apply configuration changes */
87 void CmdConfigApply();
90 void CmdConfigCancel();
92 /* List jobs for a specified client */
95 /* List files and directories for a specified tree item */
96 void CmdList(wxTreeItemId item);
98 /* Mark a treeitem (directory) or several listitems (file or directory),
99 * state defines if it should mark (1), unmark (0), or switch state (-1) */
100 void CmdMark(wxTreeItemId treeitem, long* listitems, int listsize, int state = -1);
102 /* General functions and variables */
103 //bool ended; /* The last command send has finished */
105 //long filemessages; /* When restoring, number of files restored */
106 long totfilemessages; /* When restoring, number of files to be restored */
109 /* Run a dir command, and waits until result is fully received.
110 * If recurse is true, update the children too. */
111 void UpdateTreeItem(wxTreeItemId item, bool updatelist, bool recurse);
113 /* Parse dir command results. */
114 int ParseList(wxString line, wxbDirEntry* entry);
116 /* Sets a list item state, and update its parents and children if it is a directory */
117 void SetListItemState(long listitem, int newstate);
119 /* Sets a tree item state, and update its children, parents and list (if necessary) */
120 void SetTreeItemState(wxTreeItemId item, int newstate);
122 /* Update a tree item parents' state */
123 void UpdateTreeItemState(wxTreeItemId item);
125 /* Refresh the whole tree. */
128 /* Refresh file list */
131 /* Update first config, adapting settings to the job name selected */
132 void UpdateFirstConfig();
134 /* Update second config */
135 bool UpdateSecondConfig(wxbDataTokenizer* dt);
140 disabled, // The panel is not activatable
141 activable, // The panel is activable, but not activated
142 entered, // The panel is activated
143 choosing, // The user is choosing files to restore
144 listing, // Dir listing is in progress
145 configuring, // The user is configuring restore process
146 restoring, // Bacula is restoring files
147 finished // Retore done (state will change in activable)
152 /* Cancelled status :
154 * - 1 - will be cancelled
155 * - 2 - has been cancelled */
158 /* Set current status by enabling/disabling components */
159 void SetStatus(status_enum newstatus);
162 bool working; // A command is running, discard GUI events
163 void SetWorking(bool working);
165 bool markWhenCommandDone; //If an item should be (un)marked after the current listing/marking is done
166 wxTreeItemId currentTreeItem; // Currently selected tree item
168 /* Enable or disable config controls status */
169 void EnableConfig(bool enable);
172 // wxbEventList* pendingEvents; /* Stores event sent while working */ //EVTQUEUE
173 // bool processing; /* True if pendingEvents is being processed */ //EVTQUEUE
175 // virtual void AddPendingEvent(wxEvent& event);
176 // virtual bool ProcessEvent(wxEvent& event); //EVTQUEUE
178 void OnStart(wxCommandEvent& event);
179 void OnCancel(wxCommandEvent& event);
181 void OnTreeChanging(wxTreeEvent& event);
182 void OnTreeExpanding(wxTreeEvent& event);
183 void OnTreeChanged(wxTreeEvent& event);
184 void OnTreeMarked(wxbTreeMarkedEvent& event);
185 void OnTreeAdd(wxCommandEvent& event);
186 void OnTreeRemove(wxCommandEvent& event);
187 void OnTreeRefresh(wxCommandEvent& event);
189 void OnListMarked(wxbListMarkedEvent& event);
190 void OnListActivated(wxListEvent& event);
191 void OnListChanged(wxListEvent& event);
192 void OnListAdd(wxCommandEvent& event);
193 void OnListRemove(wxCommandEvent& event);
194 void OnListRefresh(wxCommandEvent& event);
196 void OnConfigUpdated(wxCommandEvent& event);
197 void OnConfigOk(wxCommandEvent& WXUNUSED(event));
198 void OnConfigApply(wxCommandEvent& WXUNUSED(event));
199 void OnConfigCancel(wxCommandEvent& WXUNUSED(event));
202 wxBoxSizer *centerSizer; /* Center sizer */
203 wxSplitterWindow *treelistPanel; /* Panel which contains tree and list */
204 wxbConfigPanel *configPanel; /* Panel which contains initial restore options */
205 wxbConfigPanel *restorePanel; /* Panel which contains final restore options */
207 wxImageList* imagelist; //image list for tree and list
214 wxButton* treeremove;
215 wxButton* treerefresh;
219 wxButton* listremove;
220 wxButton* listrefresh;
224 long cfgUpdated; //keeps which config fields have been updated
226 friend class wxbSplitterWindow;
228 DECLARE_EVENT_TABLE();
231 #endif // WXBRESTOREPANEL_H