X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fwx-console%2Fwxbrestorepanel.cpp;h=962b8e30e8b35b4b81264e14aa565663b845984f;hb=868f47c0d7668bfd8ded135f4bbac0e0e9f23d11;hp=51da80753ea5d8d4c4613ce3c1244e640ef37550;hpb=a1be568d254e022a85a40c8f0bf65ec9c000f497;p=bacula%2Fbacula diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index 51da80753e..962b8e30e8 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -4,24 +4,23 @@ * * Nicolas Boichat, April-July 2004 * + * Version $Id$ */ /* - Copyright (C) 2004 Kern Sibbald and John Walker + Copyright (C) 2004-2005 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + /* Note concerning "done" output (modifiable marked with +) Run Restore job +JobName: RestoreFiles @@ -79,18 +78,14 @@ WX_DEFINE_LIST(wxbEventList); class wxbTreeItemData : public wxTreeItemData { public: wxbTreeItemData(wxString path, wxString name, int marked, long listid = -1); - wxbTreeItemData(wxString path, wxString name, wxString marked, long listid = -1); ~wxbTreeItemData(); wxString GetPath(); wxString GetName(); int GetMarked(); void SetMarked(int marked); - void SetMarked(wxString marked); long GetListId(); - - static int GetMarkedStatus(wxString file); private: wxString* path; /* Full path */ wxString* name; /* File name */ @@ -105,13 +100,6 @@ wxbTreeItemData::wxbTreeItemData(wxString path, wxString name, int marked, long this->listid = listid; } -wxbTreeItemData::wxbTreeItemData(wxString path, wxString name, wxString marked, long listid): wxTreeItemData() { - this->path = new wxString(path); - this->name = new wxString(name); - SetMarked(marked); - this->listid = listid; -} - wxbTreeItemData::~wxbTreeItemData() { delete path; delete name; @@ -121,18 +109,6 @@ int wxbTreeItemData::GetMarked() { return marked; } -void wxbTreeItemData::SetMarked(wxString marked) { - if (marked == "*") { - this->marked = 1; - } - else if (marked == "+") { - this->marked = 2; - } - else { - this->marked = 0; - } -} - void wxbTreeItemData::SetMarked(int marked) { this->marked = marked; } @@ -149,25 +125,6 @@ wxString wxbTreeItemData::GetName() { return *name; } -/*wxbTreeItemData* wxbTreeItemData::GetChild(wxString dirname) { - int marked = GetMarkedStatus(dirname); - return new wxbTreeItemData(path + (marked ? dirname.Mid(1) : dirname), marked); -}*/ - -int wxbTreeItemData::GetMarkedStatus(wxString file) { - if (file.Length() == 0) - return 0; - - switch (file.GetChar(0)) { - case '*': - return 1; - case '+': - return 2; - default: - return 0; - } -} - // ---------------------------------------------------------------------------- // event tables and other macros for wxWindows // ---------------------------------------------------------------------------- @@ -256,10 +213,10 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) { firstSizer->AddGrowableCol(0); firstSizer->AddGrowableRow(0); - start = new wxButton(this, RestoreStart, "Enter restore mode", wxDefaultPosition, wxSize(150, 30)); + start = new wxButton(this, RestoreStart, _("Enter restore mode"), wxDefaultPosition, wxSize(150, 30)); firstSizer->Add(start, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 10); - cancel = new wxButton(this, RestoreCancel, "Cancel restore", wxDefaultPosition, wxSize(150, 30)); + cancel = new wxButton(this, RestoreCancel, _("Cancel restore"), wxDefaultPosition, wxSize(150, 30)); firstSizer->Add(cancel, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_RIGHT, 10); wxString elist[1]; @@ -285,11 +242,11 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) { treeSizer->Add(tree, 1, wxEXPAND, 0); wxBoxSizer *treeCtrlSizer = new wxBoxSizer(wxHORIZONTAL); - treeadd = new wxButton(treePanel, TreeAdd, "Add", wxDefaultPosition, wxSize(60, 25)); + treeadd = new wxButton(treePanel, TreeAdd, _("Add"), wxDefaultPosition, wxSize(60, 25)); treeCtrlSizer->Add(treeadd, 0, wxLEFT | wxRIGHT, 3); - treeremove = new wxButton(treePanel, TreeRemove, "Remove", wxDefaultPosition, wxSize(60, 25)); + treeremove = new wxButton(treePanel, TreeRemove, _("Remove"), wxDefaultPosition, wxSize(60, 25)); treeCtrlSizer->Add(treeremove, 0, wxLEFT | wxRIGHT, 3); - treerefresh = new wxButton(treePanel, TreeRefresh, "Refresh", wxDefaultPosition, wxSize(60, 25)); + treerefresh = new wxButton(treePanel, TreeRefresh, _("Refresh"), wxDefaultPosition, wxSize(60, 25)); treeCtrlSizer->Add(treerefresh, 0, wxLEFT | wxRIGHT, 3); treeSizer->Add(treeCtrlSizer, 1, wxALIGN_CENTER_HORIZONTAL, 0); @@ -308,42 +265,42 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) { wxListItem info; info.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_FORMAT); - info.SetText("M"); + info.SetText(_("M")); info.SetAlign(wxLIST_FORMAT_CENTER); list->InsertColumn(0, info); - info.SetText("Filename"); + info.SetText(_("Filename")); info.SetAlign(wxLIST_FORMAT_LEFT); list->InsertColumn(1, info); - info.SetText("Size"); + info.SetText(_("Size")); info.SetAlign(wxLIST_FORMAT_RIGHT); list->InsertColumn(2, info); - info.SetText("Date"); + info.SetText(_("Date")); info.SetAlign(wxLIST_FORMAT_LEFT); list->InsertColumn(3, info); - info.SetText("Perm."); + info.SetText(_("Perm.")); info.SetAlign(wxLIST_FORMAT_LEFT); list->InsertColumn(4, info); - info.SetText("User"); + info.SetText(_("User")); info.SetAlign(wxLIST_FORMAT_RIGHT); list->InsertColumn(5, info); - info.SetText("Group"); + info.SetText(_("Group")); info.SetAlign(wxLIST_FORMAT_RIGHT); list->InsertColumn(6, info); listSizer->Add(list, 1, wxEXPAND, 0); wxBoxSizer *listCtrlSizer = new wxBoxSizer(wxHORIZONTAL); - listadd = new wxButton(listPanel, ListAdd, "Add", wxDefaultPosition, wxSize(60, 25)); + listadd = new wxButton(listPanel, ListAdd, _("Add"), wxDefaultPosition, wxSize(60, 25)); listCtrlSizer->Add(listadd, 0, wxLEFT | wxRIGHT, 5); - listremove = new wxButton(listPanel, ListRemove, "Remove", wxDefaultPosition, wxSize(60, 25)); + listremove = new wxButton(listPanel, ListRemove, _("Remove"), wxDefaultPosition, wxSize(60, 25)); listCtrlSizer->Add(listremove, 0, wxLEFT | wxRIGHT, 5); - listrefresh = new wxButton(listPanel, ListRefresh, "Refresh", wxDefaultPosition, wxSize(60, 25)); + listrefresh = new wxButton(listPanel, ListRefresh, _("Refresh"), wxDefaultPosition, wxSize(60, 25)); listCtrlSizer->Add(listrefresh, 0, wxLEFT | wxRIGHT, 5); listSizer->Add(listCtrlSizer, 1, wxALIGN_CENTER_HORIZONTAL, 0); @@ -357,31 +314,31 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) { treelistPanel->Show(false); wxbConfig* config = new wxbConfig(); - config->Add(new wxbConfigParam("Job Name", ConfigJobName, choice, 0, elist)); - config->Add(new wxbConfigParam("Client", ConfigClient, choice, 0, elist)); - config->Add(new wxbConfigParam("Fileset", ConfigFileset, choice, 0, elist)); - config->Add(new wxbConfigParam("Pool", ConfigPool, choice, 0, elist)); - config->Add(new wxbConfigParam("Storage", ConfigStorage, choice, 0, elist)); - config->Add(new wxbConfigParam("Before", ConfigWhen, choice, 0, elist)); + config->Add(new wxbConfigParam(_("Job Name"), ConfigJobName, choice, 0, elist)); + config->Add(new wxbConfigParam(_("Client"), ConfigClient, choice, 0, elist)); + config->Add(new wxbConfigParam(_("Fileset"), ConfigFileset, choice, 0, elist)); + config->Add(new wxbConfigParam(_("Pool"), ConfigPool, choice, 0, elist)); + config->Add(new wxbConfigParam(_("Storage"), ConfigStorage, choice, 0, elist)); + config->Add(new wxbConfigParam(_("Before"), ConfigWhen, choice, 0, elist)); - configPanel = new wxbConfigPanel(this, config, "Please configure parameters concerning files to restore :", RestoreStart, RestoreCancel, -1); + configPanel = new wxbConfigPanel(this, config, _("Please configure parameters concerning files to restore :"), RestoreStart, RestoreCancel, -1); configPanel->Show(true); configPanel->Enable(false); config = new wxbConfig(); - config->Add(new wxbConfigParam("Job Name", -1, text, "")); - config->Add(new wxbConfigParam("Bootstrap", -1, text, "")); - config->Add(new wxbConfigParam("Where", ConfigWhere, modifiableText, "")); - wxString erlist[] = {"always", "if newer", "if older", "never"}; - config->Add(new wxbConfigParam("Replace", ConfigReplace, choice, 4, erlist)); - config->Add(new wxbConfigParam("Fileset", ConfigFileset, choice, 0, erlist)); - config->Add(new wxbConfigParam("Client", ConfigClient, choice, 0, erlist)); - config->Add(new wxbConfigParam("Storage", ConfigStorage, choice, 0, erlist)); - config->Add(new wxbConfigParam("When", ConfigWhen, modifiableText, "")); - config->Add(new wxbConfigParam("Priority", ConfigPriority, modifiableText, "")); - - restorePanel = new wxbConfigPanel(this, config, "Please configure parameters concerning files restoration :", ConfigOk, ConfigCancel, ConfigApply); + config->Add(new wxbConfigParam(_("Job Name"), -1, text, wxT(""))); + config->Add(new wxbConfigParam(_("Bootstrap"), -1, text, wxT(""))); + config->Add(new wxbConfigParam(_("Where"), ConfigWhere, modifiableText, wxT(""))); + wxString erlist[] = {_("always"), _("if newer"), _("if older"), _("never")}; + config->Add(new wxbConfigParam(_("Replace"), ConfigReplace, choice, 4, erlist)); + config->Add(new wxbConfigParam(_("Fileset"), ConfigFileset, choice, 0, erlist)); + config->Add(new wxbConfigParam(_("Client"), ConfigClient, choice, 0, erlist)); + config->Add(new wxbConfigParam(_("Storage"), ConfigStorage, choice, 0, erlist)); + config->Add(new wxbConfigParam(_("When"), ConfigWhen, modifiableText, wxT(""))); + config->Add(new wxbConfigParam(_("Priority"), ConfigPriority, modifiableText, wxT(""))); + + restorePanel = new wxbConfigPanel(this, config, _("Please configure parameters concerning files restoration :"), ConfigOk, ConfigCancel, ConfigApply); restorePanel->Show(false); @@ -407,7 +364,7 @@ wxbRestorePanel::wxbRestorePanel(wxWindow* parent): wxbPanel(parent) { SetCursor(*wxSTANDARD_CURSOR); - markWhenListingDone = false; + markWhenCommandDone = false; cancelled = 0; } @@ -424,7 +381,7 @@ wxbRestorePanel::~wxbRestorePanel() { ----------------------------------------------------------------------------*/ wxString wxbRestorePanel::GetTitle() { - return "Restore"; + return _("Restore"); } void wxbRestorePanel::EnablePanel(bool enable) { @@ -446,23 +403,23 @@ void wxbRestorePanel::EnablePanel(bool enable) { void wxbRestorePanel::CmdStart() { unsigned int i; if (status == activable) { - wxbMainFrame::GetInstance()->SetStatusText("Getting parameters list."); - wxbDataTokenizer* dt = wxbUtils::WaitForEnd(".clients\n", true, false); + wxbMainFrame::GetInstance()->SetStatusText(_("Getting parameters list.")); + wxbDataTokenizer* dt = wxbUtils::WaitForEnd(wxT(".clients\n"), true, false); wxString str; - configPanel->ClearRowChoices("Client"); - restorePanel->ClearRowChoices("Client"); + configPanel->ClearRowChoices(_("Client")); + restorePanel->ClearRowChoices(_("Client")); if (dt->GetCount() == 0) { - wxbMainFrame::GetInstance()->SetStatusText("Error : no clients returned by the director."); + wxbMainFrame::GetInstance()->SetStatusText(_("Error : no clients returned by the director.")); return; } for (i = 0; i < dt->GetCount(); i++) { str = (*dt)[i]; str.RemoveLast(); - configPanel->AddRowChoice("Client", str); - restorePanel->AddRowChoice("Client", str); + configPanel->AddRowChoice(_("Client"), str); + restorePanel->AddRowChoice(_("Client"), str); } delete dt; @@ -472,21 +429,21 @@ void wxbRestorePanel::CmdStart() { return; } - dt = wxbUtils::WaitForEnd(".filesets\n", true, false); + dt = wxbUtils::WaitForEnd(wxT(".filesets\n"), true, false); - configPanel->ClearRowChoices("Fileset"); - restorePanel->ClearRowChoices("Fileset"); + configPanel->ClearRowChoices(_("Fileset")); + restorePanel->ClearRowChoices(_("Fileset")); if (dt->GetCount() == 0) { - wxbMainFrame::GetInstance()->SetStatusText("Error : no filesets returned by the director."); + wxbMainFrame::GetInstance()->SetStatusText(_("Error : no filesets returned by the director.")); return; } for (i = 0; i < dt->GetCount(); i++) { str = (*dt)[i]; str.RemoveLast(); - configPanel->AddRowChoice("Fileset", str); - restorePanel->AddRowChoice("Fileset", str); + configPanel->AddRowChoice(_("Fileset"), str); + restorePanel->AddRowChoice(_("Fileset"), str); } delete dt; @@ -496,21 +453,21 @@ void wxbRestorePanel::CmdStart() { return; } - dt = wxbUtils::WaitForEnd(".storage\n", true, false); + dt = wxbUtils::WaitForEnd(wxT(".storage\n"), true, false); - configPanel->ClearRowChoices("Storage"); - restorePanel->ClearRowChoices("Storage"); + configPanel->ClearRowChoices(_("Storage")); + restorePanel->ClearRowChoices(_("Storage")); if (dt->GetCount() == 0) { - wxbMainFrame::GetInstance()->SetStatusText("Error : no storage returned by the director."); + wxbMainFrame::GetInstance()->SetStatusText(_("Error : no storage returned by the director.")); return; } for (i = 0; i < dt->GetCount(); i++) { str = (*dt)[i]; str.RemoveLast(); - configPanel->AddRowChoice("Storage", str); - restorePanel->AddRowChoice("Storage", str); + configPanel->AddRowChoice(_("Storage"), str); + restorePanel->AddRowChoice(_("Storage"), str); } delete dt; @@ -520,22 +477,22 @@ void wxbRestorePanel::CmdStart() { return; } - dt = wxbUtils::WaitForEnd(".jobs\n", true, false); + dt = wxbUtils::WaitForEnd(wxT(".jobs\n"), true, false); - configPanel->ClearRowChoices("Job Name"); + configPanel->ClearRowChoices(_("Job Name")); if (dt->GetCount() == 0) { - wxbMainFrame::GetInstance()->SetStatusText("Error : no jobs returned by the director."); + wxbMainFrame::GetInstance()->SetStatusText(_("Error : no jobs returned by the director.")); return; } for (i = 0; i < dt->GetCount(); i++) { str = (*dt)[i]; str.RemoveLast(); - configPanel->AddRowChoice("Job Name", str); + configPanel->AddRowChoice(_("Job Name"), str); } - configPanel->SetRowString("Job Name", "RestoreFiles"); + configPanel->SetRowString(_("Job Name"), _("RestoreFiles")); delete dt; @@ -544,19 +501,19 @@ void wxbRestorePanel::CmdStart() { return; } - dt = wxbUtils::WaitForEnd(".pools\n", true, false); + dt = wxbUtils::WaitForEnd(wxT(".pools\n"), true, false); - configPanel->ClearRowChoices("Pool"); + configPanel->ClearRowChoices(_("Pool")); if (dt->GetCount() == 0) { - wxbMainFrame::GetInstance()->SetStatusText("Error : no jobs returned by the director."); + wxbMainFrame::GetInstance()->SetStatusText(_("Error : no jobs returned by the director.")); return; } for (i = 0; i < dt->GetCount(); i++) { str = (*dt)[i]; str.RemoveLast(); - configPanel->AddRowChoice("Pool", str); + configPanel->AddRowChoice(_("Pool"), str); } delete dt; @@ -570,55 +527,61 @@ void wxbRestorePanel::CmdStart() { UpdateFirstConfig(); - wxbMainFrame::GetInstance()->SetStatusText("Please configure your restore parameters."); + wxbMainFrame::GetInstance()->SetStatusText(_("Please configure your restore parameters.")); } else if (status == entered) { /* if (clientChoice->GetStringSelection().Length() < 1) { - wxbMainFrame::GetInstance()->SetStatusText("Please select a client."); + wxbMainFrame::GetInstance()->SetStatusText(_("Please select a client.")); return; } if (jobChoice->GetStringSelection().Length() < 1) { - wxbMainFrame::GetInstance()->SetStatusText("Please select a restore date."); + wxbMainFrame::GetInstance()->SetStatusText(_("Please select a restore date.")); return; }*/ - wxbMainFrame::GetInstance()->SetStatusText("Building restore tree..."); + wxbMainFrame::GetInstance()->SetStatusText(_("Building restore tree...")); SetStatus(choosing); - wxbUtils::WaitForPrompt(wxString("restore") << - " client=\"" << configPanel->GetRowString("Client") << - "\" fileset=\"" << configPanel->GetRowString("Fileset") << - "\" pool=\"" << configPanel->GetRowString("Pool") << - "\" storage=\"" << configPanel->GetRowString("Storage") << "\"\n"); - wxbUtils::WaitForPrompt("6\n"); + wxbTableParser* tableparser = new wxbTableParser(); + wxbDataTokenizer* dt = new wxbDataTokenizer(false); + +/* + * The following line was removed from ::GetInstance below because + * it does not work with multiple pools -- KES 5Oct05 see bug #433 + * wxT("\" pool=\"") << configPanel->GetRowString(wxT("Pool")) << + */ + wxbMainFrame::GetInstance()->Send(wxString(wxT("restore")) << + wxT(" client=\"") << configPanel->GetRowString(wxT("Client")) << + wxT("\" fileset=\"") << configPanel->GetRowString(wxT("Fileset")) << + wxT("\" storage=\"") << configPanel->GetRowString(wxT("Storage")) << + wxT("\" before=\"") << configPanel->GetRowString(wxT("Before")) << + wxT("\" select\n")); + //wxbUtils::WaitForPrompt("6\n"); //WaitForEnd(); - /*wxbPromptParser *pp = wxbUtils::WaitForPrompt(wxString() << configPanel->GetRowString("Before") << "\n", true); - int client = pp->getChoices()->Index(configPanel->GetRowString("Client")); + /*wxbPromptParser *pp = wxbUtils::WaitForPrompt(wxString() << configPanel->GetRowString(wxT("Before")) << "\n", true); + int client = pp->getChoices()->Index(configPanel->GetRowString(wxT("Client"))); if (client == wxNOT_FOUND) { wxbMainFrame::GetInstance()->SetStatusText("Failed to find the selected client."); return; } delete pp;*/ - wxbTableParser* tableparser = new wxbTableParser(); - wxbDataTokenizer* dt = new wxbDataTokenizer(true); - - wxbMainFrame::GetInstance()->Send(wxString() << configPanel->GetRowString("Before") << "\n"); + //wxbMainFrame::GetInstance()->Send(wxString() << configPanel->GetRowString(wxT("Before")) << "\n"); while (!tableparser->hasFinished() && !dt->hasFinished()) { wxTheApp->Yield(true); - ::wxUsleep(100); + wxbUtils::MilliSleep(100); } wxString str; if (dt->hasFinished() && !tableparser->hasFinished()) { - str = ""; + str = wxT(""); if (dt->GetCount() > 1) { str = (*dt)[dt->GetCount()-2]; str.RemoveLast(); } - wxbMainFrame::GetInstance()->SetStatusText(wxString("Error while starting restore: ") << str); + wxbMainFrame::GetInstance()->SetStatusText(wxString(_("Error while starting restore: ")) << str); delete dt; delete tableparser; SetStatus(finished); @@ -630,7 +593,7 @@ void wxbRestorePanel::CmdStart() { for (i = 0; i < tableparser->GetCount(); i++) { str = (*tableparser)[i][2]; - str.Replace(",", ""); + str.Replace(wxT(","), wxT("")); if (str.ToLong(&l)) { tot += l; } @@ -650,48 +613,44 @@ void wxbRestorePanel::CmdStart() { int var = 0; - while (!dt->hasFinished()) { + int i1, i2; + + while (true) { newdate = wxDateTime::Now(); if (newdate.Subtract(base).GetMilliseconds() > 10 ) { base = newdate; for (; lastindex < dt->GetCount(); lastindex++) { - if (((*dt)[lastindex].Find("Building directory tree for JobId ") == 0) && - ((i = (*dt)[lastindex].Find(" ...")) > 0)) { - str = (*dt)[lastindex].Mid(34, i-34); + if (((i1 = (*dt)[lastindex].Find(wxT("Building directory tree for JobId "))) >= 0) && + ((i2 = (*dt)[lastindex].Find(wxT(" ..."))) > 0)) { + str = (*dt)[lastindex].Mid(i1+34, i2-(i1+34)); for (i = 0; i < tableparser->GetCount(); i++) { if (str == (*tableparser)[i][0]) { str = (*tableparser)[i][2]; - str.Replace(",", ""); + str.Replace(wxT(","), wxT("")); if (str.ToLong(&l)) { done += willdo; willdo += l; - var = (willdo-done)/3; + var = (willdo-done)/50; + gauge->SetValue(done); + wxTheApp->Yield(true); } break; } } } + else if ((*dt)[lastindex] == wxT("+")) { + gauge->SetValue(gauge->GetValue()+var); + wxTheApp->Yield(true); + } } - if (gauge->GetValue() <= done) { - gauge->SetValue(done); - if (var < 0) - var = -var; - } - else if (gauge->GetValue() >= willdo) { - gauge->SetValue(willdo); - if (var > 0) - var = -var; + + if (dt->hasFinished()) { + break; } - - gauge->SetValue(gauge->GetValue()+var); - - /*wxbMainFrame::GetInstance()->Print( - wxString("[") << gauge->GetValue() << "/" << done - << "-" << willdo << "]", CS_DEBUG);*/ } wxTheApp->Yield(true); - ::wxUsleep(1); + wxbUtils::MilliSleep(1); } gauge->SetValue(tot); @@ -706,13 +665,13 @@ void wxbRestorePanel::CmdStart() { return; } - wxbUtils::WaitForEnd("unmark *\n"); - wxTreeItemId root = tree->AddRoot(configPanel->GetRowString("Client"), -1, -1, new wxbTreeItemData("/", configPanel->GetRowString("Client"), 0)); + wxbUtils::WaitForEnd(wxT("unmark *\n")); + wxTreeItemId root = tree->AddRoot(configPanel->GetRowString(_("Client")), -1, -1, new wxbTreeItemData(wxT("/"), configPanel->GetRowString(_("Client")), 0)); currentTreeItem = root; tree->Refresh(); tree->SelectItem(root); CmdList(root); - wxbMainFrame::GetInstance()->SetStatusText("Right click on a file or on a directory, or double-click on its mark to add it to the restore list."); + wxbMainFrame::GetInstance()->SetStatusText(_("Right click on a file or on a directory, or double-click on its mark to add it to the restore list.")); tree->Expand(root); } else if (status == choosing) { @@ -724,25 +683,77 @@ void wxbRestorePanel::CmdStart() { int j; dt = new wxbDataTokenizer(true); - wxbUtils::WaitForPrompt("done\n"); + wxbPromptParser* promptparser = wxbUtils::WaitForPrompt(wxT("done\n"), true); + + while (!promptparser->getChoices() || (promptparser->getChoices()->Index(wxT("mod")) < 0)) { + wxbMainFrame::GetInstance()->Print(_("Unexpected question has been received.\n"), CS_DEBUG); + + wxString message; + if (promptparser->getIntroString() != wxT("")) { + message << promptparser->getIntroString() << wxT("\n"); + } + message << promptparser->getQuestionString(); + + if (promptparser->getChoices()) { + wxString *choices = new wxString[promptparser->getChoices()->GetCount()]; + int *numbers = new int[promptparser->getChoices()->GetCount()]; + int n = 0; + + for (unsigned int i = 0; i < promptparser->getChoices()->GetCount(); i++) { + if ((*promptparser->getChoices())[i] != wxT("")) { + choices[n] = (*promptparser->getChoices())[i]; + numbers[n] = i; + n++; + } + } + + int res = ::wxGetSingleChoiceIndex(message, + _("wx-console: unexpected restore question."), n, choices, this); + if (res == -1) { + delete promptparser; + promptparser = wxbUtils::WaitForPrompt(wxT(".\n"), true); + } + else { + if (promptparser->isNumericalChoice()) { + delete promptparser; + promptparser = wxbUtils::WaitForPrompt(wxString() << numbers[res] << wxT("\n"), true); + } + else { + delete promptparser; + promptparser = wxbUtils::WaitForPrompt(wxString() << choices[res] << wxT("\n"), true); + } + } + delete[] choices; + delete[] numbers; + } + else { + delete promptparser; + + promptparser = wxbUtils::WaitForPrompt(::wxGetTextFromUser(message, + _("wx-console: unexpected restore question."), + wxT(""), this) + wxT("\n")); + } + } + printf("promptparser->getChoices()=%ld", (long)promptparser->getChoices()); + + delete promptparser; SetStatus(configuring); for (i = 0; i < dt->GetCount(); i++) { - if ((j = (*dt)[i].Find(" files selected to be restored.")) > -1) { + if ((j = (*dt)[i].Find(_(" files selected to be restored."))) > -1) { (*dt)[i].Mid(0, j).ToLong(&totfilemessages); break; } - if ((j = (*dt)[i].Find(" file selected to be restored.")) > -1) { + if ((j = (*dt)[i].Find(_(" file selected to be restored."))) > -1) { (*dt)[i].Mid(0, j).ToLong(&totfilemessages); break; } } wxbMainFrame::GetInstance()->SetStatusText( - wxString("Please configure your restore (") - << totfilemessages << " files selected to be restored)..."); + wxString::Format(_("Please configure your restore (%ld files selected to be restored)..."), totfilemessages)); UpdateSecondConfig(dt); @@ -752,31 +763,53 @@ void wxbRestorePanel::CmdStart() { restorePanel->EnableApply(false); if (totfilemessages == 0) { - wxbMainFrame::GetInstance()->Print("Restore failed : no file selected.\n", CS_DEBUG); - wxbMainFrame::GetInstance()->SetStatusText("Restore failed : no file selected."); + wxbMainFrame::GetInstance()->Print(_("Restore failed : no file selected.\n"), CS_DEBUG); + wxbMainFrame::GetInstance()->SetStatusText(_("Restore failed : no file selected.")); SetStatus(finished); return; } } else if (status == configuring) { cancel->Enable(false); - jobid = ""; + jobid = wxT(""); EnableConfig(false); - wxbMainFrame::GetInstance()->SetStatusText("Restoring, please wait..."); + wxbMainFrame::GetInstance()->SetStatusText(_("Restoring, please wait...")); wxbDataTokenizer* dt; SetStatus(restoring); - wxbUtils::WaitForEnd("yes\n"); + dt = wxbUtils::WaitForEnd(wxT("yes\n"), true); gauge->SetValue(0); gauge->SetRange(totfilemessages); + int j; + + for (i = 0; i < dt->GetCount(); i++) { + if ((j = (*dt)[i].Find(_("Job started. JobId="))) > -1) { + jobid = (*dt)[i].Mid(j+19); + wxbMainFrame::GetInstance()->SetStatusText(_("Restore started, jobid=") + jobid); + break; + } + + if ((j = (*dt)[i].Find(_("Job failed."))) > -1) { + wxbMainFrame::GetInstance()->Print(_("Restore failed, please look at messages.\n"), CS_DEBUG); + wxbMainFrame::GetInstance()->SetStatusText(_("Restore failed, please look at messages in console.")); + return; + } + } + + if (jobid == wxT("")) { + wxbMainFrame::GetInstance()->Print(_("Failed to retrieve jobid.\n"), CS_DEBUG); + wxbMainFrame::GetInstance()->SetStatusText(_("Failed to retrieve jobid.\n")); + return; + } + wxDateTime currenttime; - dt = wxbUtils::WaitForEnd("time\n", true); - wxStringTokenizer ttkz((*dt)[0], " ", wxTOKEN_STRTOK); + dt = wxbUtils::WaitForEnd(wxT("time\n"), true); + wxStringTokenizer ttkz((*dt)[0], wxT(" "), wxTOKEN_STRTOK); if ((currenttime.ParseDate(ttkz.GetNextToken()) == NULL) || // Date (currenttime.ParseTime(ttkz.GetNextToken()) == NULL)) { // Time currenttime.SetYear(1990); // If parsing fails, set currenttime to a dummy date @@ -787,7 +820,7 @@ void wxbRestorePanel::CmdStart() { delete dt; wxDateTime scheduledtime; - wxStringTokenizer stkz(restorePanel->GetRowString("When"), " ", wxTOKEN_STRTOK); + wxStringTokenizer stkz(restorePanel->GetRowString(_("When")), wxT(" "), wxTOKEN_STRTOK); if ((scheduledtime.ParseDate(stkz.GetNextToken()) == NULL) || // Date (scheduledtime.ParseTime(stkz.GetNextToken()) == NULL)) { // Time @@ -795,75 +828,106 @@ void wxbRestorePanel::CmdStart() { } if (scheduledtime.Subtract(currenttime).IsLongerThan(wxTimeSpan::Seconds(150))) { - wxbMainFrame::GetInstance()->Print("Restore is scheduled in more than two minutes, wx-console will not wait for its completion.\n", CS_DEBUG); - wxbMainFrame::GetInstance()->SetStatusText("Restore is scheduled in more than two minutes, wx-console will not wait for its completion."); + wxbMainFrame::GetInstance()->Print(_("Restore is scheduled in more than two minutes, wx-console will not wait for its completion.\n"), CS_DEBUG); + wxbMainFrame::GetInstance()->SetStatusText(_("Restore is scheduled in more than two minutes, wx-console will not wait for its completion.")); SetStatus(finished); return; } - wxString cmd = "list jobid="; - - wxString jobname = restorePanel->GetRowString("Job Name"); - - wxStopWatch sw; + wxString cmd = wxString(wxT("list jobid=")) + jobid; wxbTableParser* tableparser; - - while (true) { - tableparser = wxbUtils::CreateAndWaitForParser("list jobs\n"); - - wxDateTime jobtime; - - for (i = 0; i < tableparser->GetCount(); i++) { - if (jobname == (*tableparser)[i][1]) { - wxStringTokenizer jtkz((*tableparser)[i][2], " ", wxTOKEN_STRTOK); - if ((jobtime.ParseDate(jtkz.GetNextToken()) != NULL) && // Date - (jobtime.ParseTime(jtkz.GetNextToken()) != NULL)) { // Time - if (jobtime.IsLaterThan(currenttime)) { - jobid = (*tableparser)[i][0]; - cmd << jobid << "\n"; - delete tableparser; - tableparser = NULL; - cancel->Enable(true); - break; - } - } - } - } - - if (tableparser == NULL) { //The job was found - break; - } - - delete tableparser; - - wxStopWatch sw2; - while (sw2.Time() < 2000) { - wxTheApp->Yield(true); - ::wxUsleep(100); - } - if (sw.Time() > 60000) { - wxbMainFrame::GetInstance()->Print("The restore job has not been created within one minute, wx-console will not wait for its completion anymore.\n", CS_DEBUG); - wxbMainFrame::GetInstance()->SetStatusText("The restore job has not been created within one minute, wx-console will not wait for its completion anymore."); - SetStatus(finished); - cancel->Enable(true); - return; - } - } long filemessages = 0; + + bool ended = false; + bool waitforever = false; + + char status = '?'; + wxStopWatch sw; + + wxbUtils::WaitForEnd(wxT("autodisplay off\n")); while (true) { tableparser = wxbUtils::CreateAndWaitForParser(cmd); - if ((*tableparser)[0][7] != "C") { + ended = false; + status = (*tableparser)[0][7].GetChar(0); + switch (status) { + case JS_Created: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job created, but not yet running.")); + waitforever = false; + break; + case JS_Running: + wxbMainFrame::GetInstance()->SetStatusText( + wxString::Format(_("Restore job running, please wait (%ld of %ld files restored)..."), filemessages, totfilemessages)); + waitforever = true; + break; + case JS_Terminated: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job terminated successfully.")); + wxbMainFrame::GetInstance()->Print(_("Restore job terminated successfully.\n"), CS_DEBUG); + waitforever = false; + ended = true; + break; + case JS_ErrorTerminated: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job terminated in error, see messages in console.")); + wxbMainFrame::GetInstance()->Print(_("Restore job terminated in error, see messages.\n"), CS_DEBUG); + waitforever = false; + ended = true; + break; + case JS_Error: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job reported a non-fatal error.")); + waitforever = false; + break; + case JS_FatalError: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job reported a fatal error.")); + waitforever = false; + ended = true; + break; + case JS_Canceled: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job cancelled by user.")); + wxbMainFrame::GetInstance()->Print(_("Restore job cancelled by user.\n"), CS_DEBUG); + waitforever = false; + ended = true; + break; + case JS_WaitFD: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job is waiting on File daemon.")); + waitforever = false; + break; + case JS_WaitMedia: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job is waiting for new media.")); + waitforever = false; + break; + case JS_WaitStoreRes: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job is waiting for storage resource.")); + waitforever = false; + break; + case JS_WaitJobRes: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job is waiting for job resource.")); + waitforever = false; + break; + case JS_WaitClientRes: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job is waiting for Client resource.")); + waitforever = false; + break; + case JS_WaitMaxJobs: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job is waiting for maximum jobs.")); + waitforever = false; + break; + case JS_WaitStartTime: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job is waiting for start time.")); + waitforever = false; + break; + case JS_WaitPriority: + wxbMainFrame::GetInstance()->SetStatusText(_("Restore job is waiting for higher priority jobs to finish.")); + waitforever = false; break; } delete tableparser; - - dt = wxbUtils::WaitForEnd("messages\n", true); + dt = wxbUtils::WaitForEnd(wxT("messages\n"), true); + for (unsigned int i = 0; i < dt->GetCount(); i++) { - wxStringTokenizer tkz((*dt)[i], " ", wxTOKEN_STRTOK); + wxStringTokenizer tkz((*dt)[i], wxT(" "), wxTOKEN_STRTOK); wxDateTime datetime; @@ -891,29 +955,32 @@ void wxbRestorePanel::CmdStart() { } delete dt; - - wxbMainFrame::GetInstance()->SetStatusText(wxString("Restoring, please wait (") << filemessages << " of " << totfilemessages << " files done)..."); - + wxStopWatch sw2; while (sw2.Time() < 10000) { wxTheApp->Yield(true); - ::wxUsleep(100); + wxbUtils::MilliSleep(100); + } + + if (ended) { + break; + } + + if ((!waitforever) && (sw.Time() > 60000)) { + wxbMainFrame::GetInstance()->Print(_("The restore job has not been started within one minute, wx-console will not wait for its completion anymore.\n"), CS_DEBUG); + wxbMainFrame::GetInstance()->SetStatusText(_("The restore job has not been started within one minute, wx-console will not wait for its completion anymore.")); + break; } } - - wxbUtils::WaitForEnd("messages\n"); + wxbUtils::WaitForEnd(wxT("autodisplay on\n")); + wxbUtils::WaitForEnd(wxT(".messages\n")); gauge->SetValue(totfilemessages); - if ((*tableparser)[0][7] == "T") { - wxbMainFrame::GetInstance()->Print("Restore done successfully.\n", CS_DEBUG); - wxbMainFrame::GetInstance()->SetStatusText("Restore done successfully."); - } - else { - wxbMainFrame::GetInstance()->Print("Restore failed, please look at messages.\n", CS_DEBUG); - wxbMainFrame::GetInstance()->SetStatusText("Restore failed, please look at messages in console."); + if (status == JS_Terminated) { + wxbMainFrame::GetInstance()->Print(_("Restore done successfully.\n"), CS_DEBUG); + wxbMainFrame::GetInstance()->SetStatusText(_("Restore done successfully.")); } - delete tableparser; SetStatus(finished); } } @@ -923,8 +990,8 @@ void wxbRestorePanel::CmdCancel() { cancelled = 1; if (status == restoring) { - if (jobid != "") { - wxbMainFrame::GetInstance()->Send(wxString("cancel job=") << jobid << "\n"); + if (jobid != wxT("")) { + wxbMainFrame::GetInstance()->Send(wxString(wxT("cancel job=")) << jobid << wxT("\n")); } cancel->Enable(true); return; @@ -933,34 +1000,34 @@ void wxbRestorePanel::CmdCancel() { wxStopWatch sw; while ((IsWorking()) && (cancelled != 2)) { wxTheApp->Yield(true); - ::wxUsleep(100); + wxbUtils::MilliSleep(100); if (sw.Time() > 30000) { /* 30 seconds timeout */ if (status == choosing) { - wxbMainFrame::GetInstance()->Send("quit\n"); + wxbMainFrame::GetInstance()->Send(wxT("quit\n")); } else if (status == configuring) { - wxbMainFrame::GetInstance()->Send("no\n"); + wxbMainFrame::GetInstance()->Send(wxT("no\n")); } else if (status == restoring) { } SetStatus(finished); - ::wxUsleep(1000); + wxbUtils::MilliSleep(1000); return; } } switch (status) { case choosing: - wxbMainFrame::GetInstance()->Send("quit\n"); + wxbMainFrame::GetInstance()->Send(wxT("quit\n")); break; case configuring: - wxbMainFrame::GetInstance()->Send("no\n"); + wxbMainFrame::GetInstance()->Send(wxT("no\n")); break; default: break; } - ::wxUsleep(1000); + wxbUtils::MilliSleep(1000); SetStatus(finished); } @@ -983,7 +1050,7 @@ void wxbRestorePanel::CmdCancel() { void wxbRestorePanel::CmdConfigApply() { if (cfgUpdated == 0) return; - wxbMainFrame::GetInstance()->SetStatusText("Applying restore configuration changes..."); + wxbMainFrame::GetInstance()->SetStatusText(_("Applying restore configuration changes...")); EnableConfig(false); @@ -998,81 +1065,81 @@ void wxbRestorePanel::CmdConfigApply() { } wxString def; //String to send if can't use our data if ((cfgUpdated >> ConfigWhere) & 1) { - wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */ - wxbUtils::WaitForPrompt("9\n"); + wxbUtils::WaitForPrompt(wxT("mod\n")); /* TODO: check results */ + wxbUtils::WaitForPrompt(wxT("9\n")); dt = new wxbDataTokenizer(true); - wxbUtils::WaitForPrompt(restorePanel->GetRowString("Where") + "\n"); - def = "/tmp"; + wxbUtils::WaitForPrompt(restorePanel->GetRowString(_("Where")) + wxT("\n")); + def = wxT("/tmp"); cfgUpdated = cfgUpdated & (~(1 << ConfigWhere)); } else if ((cfgUpdated >> ConfigReplace) & 1) { - wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */ - wxbUtils::WaitForPrompt("10\n"); + wxbUtils::WaitForPrompt(wxT("mod\n")); /* TODO: check results */ + wxbUtils::WaitForPrompt(wxT("10\n")); dt = new wxbDataTokenizer(true); - wxbUtils::WaitForPrompt(wxString() << (restorePanel->GetRowSelection("Replace")+1) << "\n"); - def = "1"; + wxbUtils::WaitForPrompt(wxString() << (restorePanel->GetRowSelection(_("Replace"))+1) << wxT("\n")); + def = wxT("1"); cfgUpdated = cfgUpdated & (~(1 << ConfigReplace)); } else if ((cfgUpdated >> ConfigWhen) & 1) { - wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */ - wxbUtils::WaitForPrompt("6\n"); + wxbUtils::WaitForPrompt(wxT("mod\n")); /* TODO: check results */ + wxbUtils::WaitForPrompt(wxT("6\n")); dt = new wxbDataTokenizer(true); - wxbUtils::WaitForPrompt(restorePanel->GetRowString("When") + "\n"); - def = ""; + wxbUtils::WaitForPrompt(restorePanel->GetRowString(wxT("When")) + wxT("\n")); + def = wxT(""); cfgUpdated = cfgUpdated & (~(1 << ConfigWhen)); } else if ((cfgUpdated >> ConfigPriority) & 1) { - wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */ - wxbUtils::WaitForPrompt("7\n"); + wxbUtils::WaitForPrompt(wxT("mod\n")); /* TODO: check results */ + wxbUtils::WaitForPrompt(wxT("7\n")); dt = new wxbDataTokenizer(true); - wxbUtils::WaitForPrompt(restorePanel->GetRowString("Priority") + "\n"); - def = "10"; + wxbUtils::WaitForPrompt(restorePanel->GetRowString(_("Priority")) + wxT("\n")); + def = wxT("10"); cfgUpdated = cfgUpdated & (~(1 << ConfigPriority)); } else if ((cfgUpdated >> ConfigClient) & 1) { - wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */ - wxbPromptParser *pp = wxbUtils::WaitForPrompt("5\n", true); - int client = pp->getChoices()->Index(restorePanel->GetRowString("Client")); + wxbUtils::WaitForPrompt(wxT("mod\n")); /* TODO: check results */ + wxbPromptParser *pp = wxbUtils::WaitForPrompt(wxT("5\n"), true); + int client = pp->getChoices()->Index(restorePanel->GetRowString(_("Client"))); if (client == wxNOT_FOUND) { - wxbMainFrame::GetInstance()->SetStatusText("Failed to find the selected client."); + wxbMainFrame::GetInstance()->SetStatusText(_("Failed to find the selected client.")); failed = true; client = 1; } delete pp; dt = new wxbDataTokenizer(true); - wxbUtils::WaitForPrompt(wxString() << client << "\n"); - def = "1"; + wxbUtils::WaitForPrompt(wxString() << client << wxT("\n")); + def = wxT("1"); cfgUpdated = cfgUpdated & (~(1 << ConfigClient)); } else if ((cfgUpdated >> ConfigFileset) & 1) { - wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */ - wxbPromptParser *pp = wxbUtils::WaitForPrompt("4\n", true); - int fileset = pp->getChoices()->Index(restorePanel->GetRowString("Fileset")); + wxbUtils::WaitForPrompt(wxT("mod\n")); /* TODO: check results */ + wxbPromptParser *pp = wxbUtils::WaitForPrompt(wxT("4\n"), true); + int fileset = pp->getChoices()->Index(restorePanel->GetRowString(_("Fileset"))); if (fileset == wxNOT_FOUND) { - wxbMainFrame::GetInstance()->SetStatusText("Failed to find the selected fileset."); + wxbMainFrame::GetInstance()->SetStatusText(_("Failed to find the selected fileset.")); failed = true; fileset = 1; } delete pp; dt = new wxbDataTokenizer(true); - wxbUtils::WaitForPrompt(wxString() << fileset << "\n"); - def = "1"; + wxbUtils::WaitForPrompt(wxString() << fileset << wxT("\n")); + def = wxT("1"); cfgUpdated = cfgUpdated & (~(1 << ConfigFileset)); } else if ((cfgUpdated >> ConfigStorage) & 1) { - wxbUtils::WaitForPrompt("mod\n"); /* TODO: check results */ - wxbPromptParser *pp = wxbUtils::WaitForPrompt("2\n", true); - int fileset = pp->getChoices()->Index(restorePanel->GetRowString("Storage")); + wxbUtils::WaitForPrompt(wxT("mod\n")); /* TODO: check results */ + wxbPromptParser *pp = wxbUtils::WaitForPrompt(wxT("2\n"), true); + int fileset = pp->getChoices()->Index(restorePanel->GetRowString(_("Storage"))); if (fileset == wxNOT_FOUND) { - wxbMainFrame::GetInstance()->SetStatusText("Failed to find the selected storage."); + wxbMainFrame::GetInstance()->SetStatusText(_("Failed to find the selected storage.")); failed = true; fileset = 1; } delete pp; dt = new wxbDataTokenizer(true); - wxbUtils::WaitForPrompt(wxString() << fileset << "\n"); - def = "1"; - cfgUpdated = cfgUpdated & (~(1 << ConfigFileset)); + wxbUtils::WaitForPrompt(wxString() << fileset << wxT("\n")); + def = wxT("1"); + cfgUpdated = cfgUpdated & (~(1 << ConfigStorage)); } else { cfgUpdated = 0; @@ -1081,14 +1148,14 @@ void wxbRestorePanel::CmdConfigApply() { unsigned int i; for (i = 0; i < dt->GetCount(); i++) { - if ((*dt)[i].Find("Run Restore job") == 0) { + if ((*dt)[i].Find(_("Run Restore job")) == 0) { break; } } if (i == dt->GetCount()) { delete dt; - dt = wxbUtils::WaitForEnd(def + "\n", true); + dt = wxbUtils::WaitForEnd(def + wxT("\n"), true); failed = true; } } @@ -1097,7 +1164,7 @@ void wxbRestorePanel::CmdConfigApply() { EnableConfig(true); if (!failed) { - wxbMainFrame::GetInstance()->SetStatusText("Restore configuration changes were applied."); + wxbMainFrame::GetInstance()->SetStatusText(_("Restore configuration changes were applied.")); } delete dt; @@ -1105,34 +1172,44 @@ void wxbRestorePanel::CmdConfigApply() { /* Cancel restore */ void wxbRestorePanel::CmdConfigCancel() { - wxbUtils::WaitForEnd("no\n"); - wxbMainFrame::GetInstance()->Print("Restore cancelled.\n", CS_DEBUG); - wxbMainFrame::GetInstance()->SetStatusText("Restore cancelled."); + wxbUtils::WaitForEnd(wxT("no\n")); + wxbMainFrame::GetInstance()->Print(_("Restore cancelled.\n"), CS_DEBUG); + wxbMainFrame::GetInstance()->SetStatusText(_("Restore cancelled.")); SetStatus(finished); } -/* List jobs for a specified client */ +/* List jobs for a specified client and fileset */ void wxbRestorePanel::CmdListJobs() { if (status == entered) { - configPanel->ClearRowChoices("Before"); - wxbUtils::WaitForPrompt("query\n"); - wxbUtils::WaitForPrompt("6\n"); - wxbTableParser* tableparser = new wxbTableParser(); - wxbDataTokenizer* dt = wxbUtils::WaitForEnd(configPanel->GetRowString("Client") + "\n", true); + configPanel->ClearRowChoices(_("Before")); + /*wxbUtils::WaitForPrompt("query\n"); + wxbUtils::WaitForPrompt("6\n");*/ + wxbTableParser* tableparser = new wxbTableParser(false); + wxbDataTokenizer* dt = wxbUtils::WaitForEnd( + wxString(wxT(".backups client=\"")) + configPanel->GetRowString(_("Client")) + + wxT("\" fileset=\"") + configPanel->GetRowString(_("Fileset")) + wxT("\"\n"), true); - if (!tableparser->hasFinished()) { + while (!tableparser->hasFinished()) { + wxTheApp->Yield(true); + wxbUtils::MilliSleep(100); + } + + if (!tableparser->GetCount() == 0) { for (unsigned int i = 0; i < dt->Count(); i++) { - if ((*dt)[i].Find("No results to list.") == 0) { - configPanel->AddRowChoice("Before", "No backup found for this client."); - configPanel->SetRowSelection("Before", 0); + if ((*dt)[i].Find(_("No results to list.")) == 0) { + configPanel->AddRowChoice(_("Before"), + _("No backup found for this client.")); + configPanel->SetRowSelection(_("Before"), 0); configPanel->EnableApply(true); // Enabling the not existing apply button disables the ok button. delete tableparser; delete dt; return; } - else if (((*dt)[i].Find("ERROR") > -1) || ((*dt)[i].Find("Query failed") > -1)) { - configPanel->AddRowChoice("Before", "Cannot get previous backups list, see console."); - configPanel->SetRowSelection("Before", 0); + else if (((*dt)[i].Find(_("ERROR")) > -1) || + ((*dt)[i].Find(_("Query failed")) > -1)) { + configPanel->AddRowChoice(_("Before"), + _("Cannot get previous backups list, see console.")); + configPanel->SetRowSelection(_("Before"), 0); configPanel->EnableApply(true); // Enabling the not existing apply button disables the ok button. delete tableparser; delete dt; @@ -1141,30 +1218,24 @@ void wxbRestorePanel::CmdListJobs() { } } - while (!tableparser->hasFinished()) { - wxTheApp->Yield(true); - ::wxUsleep(100); - } - delete dt; + wxDateTime lastdatetime = (time_t) 0; for (int i = tableparser->GetCount()-1; i > -1; i--) { wxString str = (*tableparser)[i][3]; wxDateTime datetime; - const char* chr; - if ( ( (chr = datetime.ParseDate(str.GetData()) ) != NULL ) && ( datetime.ParseTime(++chr) != NULL ) ) { + const wxChar* chr; + if ( ( (chr = datetime.ParseDate(str.GetData()) ) != NULL ) && ( datetime.ParseTime(++chr) != NULL ) && ! lastdatetime.IsEqualTo(datetime) ) { + lastdatetime = datetime; datetime += wxTimeSpan::Seconds(1); - //wxbMainFrame::GetInstance()->Print(wxString("-") << datetime.Format("%Y-%m-%d %H:%M:%S"), CS_DEBUG); - configPanel->AddRowChoice("Before", datetime.Format("%Y-%m-%d %H:%M:%S")); + configPanel->AddRowChoice(_("Before"), + datetime.Format(wxT("%Y-%m-%d %H:%M:%S"))); } - /*else { - jobChoice->Append("Invalid"); - }*/ } delete tableparser; - configPanel->SetRowSelection("Before", 0); + configPanel->SetRowSelection(_("Before"), 0); configPanel->EnableApply(false); // Disabling the not existing apply button enables the ok button. } } @@ -1211,7 +1282,7 @@ void wxbRestorePanel::CmdMark(wxTreeItemId treeitem, long* listitems, int listsi } if (listitems != NULL) { - for (int i = 0; i < listsize; i++) { + for (int i = 0; i < itemdatasize; i++) { itemdata[i] = (wxbTreeItemData*)list->GetItemData(listitems[i]); } } @@ -1231,7 +1302,7 @@ void wxbRestorePanel::CmdMark(wxTreeItemId treeitem, long* listitems, int listsi wxString dir = itemdata[0]->GetPath(); wxString file; - if (dir != "/") { + if (dir != wxT("/")) { if (dir.GetChar(dir.Length()-1) == '/') { dir.RemoveLast(); } @@ -1239,7 +1310,7 @@ void wxbRestorePanel::CmdMark(wxTreeItemId treeitem, long* listitems, int listsi int i = dir.Find('/', TRUE); if (i == -1) { file = dir; - dir = "/"; + dir = wxT("/"); } else { /* first dir below root */ file = dir.Mid(i+1); @@ -1247,8 +1318,8 @@ void wxbRestorePanel::CmdMark(wxTreeItemId treeitem, long* listitems, int listsi } } else { - dir = "/"; - file = "*"; + dir = wxT("/"); + file = wxT("*"); } if (state == -1) { @@ -1286,8 +1357,8 @@ void wxbRestorePanel::CmdMark(wxTreeItemId treeitem, long* listitems, int listsi } } - wxbUtils::WaitForEnd(wxString("cd \"") << dir << "\"\n"); - wxbUtils::WaitForEnd(wxString((state==1) ? "mark" : "unmark") << " \"" << file << "\"\n"); + wxbUtils::WaitForEnd(wxString(wxT("cd \"")) << dir << wxT("\"\n")); + wxbUtils::WaitForEnd(wxString((state==1) ? wxT("mark") : wxT("unmark")) << wxT(" \"") << file << wxT("\"\n")); /* TODO: Check commands results */ @@ -1302,9 +1373,11 @@ void wxbRestorePanel::CmdMark(wxTreeItemId treeitem, long* listitems, int listsi treeitem = tree->GetItemParent(treeitem);*/ } else { - for (int i = 0; i < listsize; i++) { + for (int i = 0; i < itemdatasize; i++) { SetListItemState(listitems[i], state); } + listadd->Enable(state == 0); + listremove->Enable(state == 1); /*UpdateTree(treeitem, (tree->GetSelection() == treeitem)); treeitem = tree->GetItemParent(treeitem);*/ } @@ -1327,9 +1400,9 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool re // this->updatelist = updatelist; wxbDataTokenizer* dt; - dt = wxbUtils::WaitForEnd(wxString("cd \"") << + dt = wxbUtils::WaitForEnd(wxString(wxT("cd \"")) << static_cast(tree->GetItemData(item)) - ->GetPath() << "\"\n", false); + ->GetPath() << wxT("\"\n"), false); /* TODO: check command result */ @@ -1339,42 +1412,46 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool re if (updatelist) list->DeleteAllItems(); - dt = wxbUtils::WaitForEnd("dir\n", true); + dt = wxbUtils::WaitForEnd(wxT(".dir\n"), true); wxString str; for (unsigned int i = 0; i < dt->GetCount(); i++) { str = (*dt)[i]; - if (str.Find("cwd is:") == 0) { // Sometimes cd command result "infiltrate" into listings. + if (str.Find(wxT("cwd is:")) == 0) { // Sometimes cd command result "infiltrate" into listings. break; } str.RemoveLast(); - wxString* file = ParseList(str); + wxbDirEntry entry; - if (file == NULL) + if (!ParseList(str, &entry)) break; wxTreeItemId treeid; - if (file[8].GetChar(file[8].Length()-1) == '/') { + if (entry.fullname.GetChar(entry.fullname.Length()-1) == '/') { wxString itemStr; +#if wxCHECK_VERSION(2, 6, 0) + wxTreeItemIdValue cookie; +#else long cookie; +#endif + treeid = tree->GetFirstChild(item, cookie); bool updated = false; while (treeid.IsOk()) { - itemStr = tree->GetItemText(treeid); - if (file[8] == itemStr) { - int stat = wxbTreeItemData::GetMarkedStatus(file[6]); - if (static_cast(tree->GetItemData(treeid))->GetMarked() != stat) { - tree->SetItemImage(treeid, stat, wxTreeItemIcon_Normal); - tree->SetItemImage(treeid, stat, wxTreeItemIcon_Selected); - static_cast(tree->GetItemData(treeid))->SetMarked(file[6]); + itemStr = ((wxbTreeItemData*)tree->GetItemData(treeid))->GetName(); + if (entry.filename == itemStr) { + if (static_cast(tree->GetItemData(treeid))->GetMarked() != entry.marked) { + tree->SetItemImage(treeid, entry.marked, wxTreeItemIcon_Normal); + tree->SetItemImage(treeid, entry.marked, wxTreeItemIcon_Selected); + static_cast(tree->GetItemData(treeid))->SetMarked(entry.marked); } if ((recurse) && (tree->IsExpanded(treeid))) { UpdateTreeItem(treeid, false, true); @@ -1386,25 +1463,22 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool re } if (!updated) { - int img = wxbTreeItemData::GetMarkedStatus(file[6]); - treeid = tree->AppendItem(item, file[8], img, img, new wxbTreeItemData(file[7], file[8], file[6])); + treeid = tree->AppendItem(item, wxbUtils::ConvertToPrintable(entry.filename), entry.marked, entry.marked, new wxbTreeItemData(entry.fullname, entry.filename, entry.marked)); } } if (updatelist) { - long ind = list->InsertItem(list->GetItemCount(), wxbTreeItemData::GetMarkedStatus(file[6])); - wxbTreeItemData* data = new wxbTreeItemData(file[7], file[8], file[6], ind); + long ind = list->InsertItem(list->GetItemCount(), entry.marked); + wxbTreeItemData* data = new wxbTreeItemData(entry.fullname, entry.filename, entry.marked, ind); data->SetId(treeid); list->SetItemData(ind, (long)data); - list->SetItem(ind, 1, file[8]); // filename - list->SetItem(ind, 2, file[4]); //Size - list->SetItem(ind, 3, file[5]); //date - list->SetItem(ind, 4, file[0]); //perm - list->SetItem(ind, 5, file[2]); //user - list->SetItem(ind, 6, file[3]); //grp + list->SetItem(ind, 1, wxbUtils::ConvertToPrintable(entry.filename)); + list->SetItem(ind, 2, entry.size); + list->SetItem(ind, 3, entry.date); + list->SetItem(ind, 4, entry.perm); + list->SetItem(ind, 5, entry.user); + list->SetItem(ind, 6, entry.group); } - - delete[] file; } delete dt; @@ -1413,40 +1487,65 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool re status = choosing; } -/* Parse dir command results. */ -wxString* wxbRestorePanel::ParseList(wxString line) { +/* Parse .dir command results, returns true if the result has been stored in entry, false otherwise. */ +int wxbRestorePanel::ParseList(wxString line, wxbDirEntry* entry) { /* See ls_output in dird/ua_tree.c */ - - //drwxrwxrwx 1 root root 0 2004-04-03 14:35:21 f:/tocd/NVSU 1.00.00/ - //+ 10 + ++ + 8 + + 8 ++ 8 + + 19 + *+ -> - //0 12 15 24 32 42 62 + //-rw-r-----,1,root,root,41575,2005-10-18 18:21:36, ,/usr/var/bacula/working/bacula.sql - if (line.Length() < 63) - return NULL; - - wxString* ret = new wxString[9]; - - ret[0] = line.Mid(0, 10).Trim(); - ret[1] = line.Mid(12, 2).Trim(); - ret[2] = line.Mid(15, 8).Trim(); - ret[3] = line.Mid(24, 8).Trim(); - ret[4] = line.Mid(32, 8).Trim(); - ret[5] = line.Mid(42, 19).Trim(); - ret[6] = line.Mid(62, 1); - ret[7] = line.Mid(63).Trim(); - - if (ret[6] == " ") ret[6] = ""; - - if (ret[7].GetChar(ret[7].Length()-1) == '/') { - ret[8] = ret[7]; - ret[8].RemoveLast(); - ret[8] = ret[7].Mid(ret[8].Find('/', true)+1); + wxStringTokenizer tkz(line, wxT(",")); + + if (!tkz.HasMoreTokens()) + return false; + entry->perm = tkz.GetNextToken(); + + if (!tkz.HasMoreTokens()) + return false; + entry->nlink = tkz.GetNextToken(); + + if (!tkz.HasMoreTokens()) + return false; + entry->user = tkz.GetNextToken(); + + if (!tkz.HasMoreTokens()) + return false; + entry->group = tkz.GetNextToken(); + + if (!tkz.HasMoreTokens()) + return false; + entry->size = tkz.GetNextToken(); + + if (!tkz.HasMoreTokens()) + return false; + entry->date = tkz.GetNextToken(); + + if (!tkz.HasMoreTokens()) + return false; + wxString marked = tkz.GetNextToken(); + if (marked == wxT("*")) { + entry->marked = 1; + } + else if (marked == wxT("+")) { + entry->marked = 2; + } + else { + entry->marked = 0; + } + + if (!tkz.HasMoreTokens()) + return false; + entry->fullname = tkz.GetNextToken(); + + /* Get only the filename (cut path by finding the last '/') */ + if (entry->fullname.GetChar(entry->fullname.Length()-1) == '/') { + wxString tmp = entry->fullname; + tmp.RemoveLast(); + entry->filename = entry->fullname.Mid(tmp.Find('/', true)+1); } else { - ret[8] = ret[7].Mid(ret[7].Find('/', true)+1); + entry->filename = entry->fullname.Mid(entry->fullname.Find('/', true)+1); } - return ret; + return true; } /* Sets a list item state, and update its parents and children if it is a directory */ @@ -1469,7 +1568,11 @@ void wxbRestorePanel::SetListItemState(long listitem, int newstate) { /* Sets a tree item state, and update its children, parents and list (if necessary) */ void wxbRestorePanel::SetTreeItemState(wxTreeItemId item, int newstate) { +#if wxCHECK_VERSION(2, 6, 0) + wxTreeItemIdValue cookie; +#else long cookie; +#endif wxTreeItemId currentChild = tree->GetFirstChild(item, cookie); wxbTreeItemData* itemdata; @@ -1511,7 +1614,11 @@ void wxbRestorePanel::UpdateTreeItemState(wxTreeItemId item) { int state = 0; +#if wxCHECK_VERSION(2, 6, 0) + wxTreeItemIdValue cookie; +#else long cookie; +#endif wxTreeItemId currentChild = tree->GetFirstChild(item, cookie); bool onechildmarked = false; @@ -1613,13 +1720,17 @@ void wxbRestorePanel::RefreshTree() { bool match; for (int i = current.Count()-1; i >= 0; i--) { +#if wxCHECK_VERSION(2, 6, 0) + wxTreeItemIdValue cookie; +#else long cookie; +#endif wxTreeItemId currentChild = tree->GetFirstChild(item, cookie); match = false; while (currentChild.IsOk()) { - if (tree->GetItemText(currentChild) == current[i]) { + if (((wxbTreeItemData*)tree->GetItemData(currentChild))->GetName() == current[i]) { item = currentChild; match = true; break; @@ -1645,7 +1756,7 @@ void wxbRestorePanel::RefreshList() { /* Update first config, adapting settings to the job name selected */ void wxbRestorePanel::UpdateFirstConfig() { configPanel->Enable(false); - wxbDataTokenizer* dt = wxbUtils::WaitForEnd(wxString(".defaults job=") + configPanel->GetRowString("Job Name") + "\n", true, false); + wxbDataTokenizer* dt = wxbUtils::WaitForEnd(wxString(wxT(".defaults job=")) + configPanel->GetRowString(_("Job Name")) + wxT("\n"), true, false); /* job=RestoreFiles * pool=Default * messages=Standard @@ -1654,7 +1765,8 @@ void wxbRestorePanel::UpdateFirstConfig() { * where=/tmp/bacula-restores * level=0 * type=Restore - * fileset=Full Set */ + * fileset=*** + */ wxString name, str; unsigned int i; @@ -1666,21 +1778,27 @@ void wxbRestorePanel::UpdateFirstConfig() { str = (*dt)[i]; if ((j = str.Find('=')) > -1) { name = str.Mid(0, j); - if (name == "pool") { - configPanel->SetRowString("Pool", str.Mid(j+1)); + if (name == wxT("pool")) { + configPanel->SetRowString(_("Pool"), str.Mid(j+1)); } - else if (name == "client") { + else if (name == wxT("client")) { str = str.Mid(j+1); - if ((str != configPanel->GetRowString("Client")) || (configPanel->GetRowString("Before") == "")) { - configPanel->SetRowString("Client", str); + if ((str != configPanel->GetRowString(_("Client"))) || + (configPanel->GetRowString(_("Before"))) == wxT("")) { + configPanel->SetRowString(_("Client"), str); dolistjobs = true; } } - else if (name == "storage") { - configPanel->SetRowString("Storage", str.Mid(j+1)); + else if (name == wxT("storage")) { + configPanel->SetRowString(_("Storage"), str.Mid(j+1)); } - else if (name == "fileset") { - configPanel->SetRowString("Fileset", str.Mid(j+1)); + else if (name == wxT("fileset")) { + str = str.Mid(j+1); + if ((str != configPanel->GetRowString(_("Fileset"))) || + (configPanel->GetRowString(_("Before"))) == wxT("")) { + configPanel->SetRowString(_("Fileset"), str); + dolistjobs = true; + } } } } @@ -1713,7 +1831,7 @@ void wxbRestorePanel::UpdateFirstConfig() { bool wxbRestorePanel::UpdateSecondConfig(wxbDataTokenizer* dt) { unsigned int i; for (i = 0; i < dt->GetCount(); i++) { - if ((*dt)[i].Find("Run Restore job") == 0) + if ((*dt)[i].Find(_("Run Restore job")) == 0) break; } @@ -1723,31 +1841,31 @@ bool wxbRestorePanel::UpdateSecondConfig(wxbDataTokenizer* dt) { int k; - if ((k = (*dt)[++i].Find("JobName:")) != 0) return false; - restorePanel->SetRowString("Job Name", (*dt)[i].Mid(10).Trim(false).RemoveLast()); - if ((k = (*dt)[++i].Find("Bootstrap:")) != 0) return false; - restorePanel->SetRowString("Bootstrap", (*dt)[i].Mid(10).Trim(false).RemoveLast()); - if ((k = (*dt)[++i].Find("Where:")) != 0) return false; - restorePanel->SetRowString("Where", (*dt)[i].Mid(10).Trim(false).RemoveLast()); + if ((k = (*dt)[++i].Find(_("JobName:"))) != 0) return false; + restorePanel->SetRowString(_("Job Name"), (*dt)[i].Mid(10).Trim(false).RemoveLast()); + if ((k = (*dt)[++i].Find(_("Bootstrap:"))) != 0) return false; + restorePanel->SetRowString(_("Bootstrap"), (*dt)[i].Mid(10).Trim(false).RemoveLast()); + if ((k = (*dt)[++i].Find(_("Where:"))) != 0) return false; + restorePanel->SetRowString(_("Where"), (*dt)[i].Mid(10).Trim(false).RemoveLast()); - if ((k = (*dt)[++i].Find("Replace:")) != 0) return false; + if ((k = (*dt)[++i].Find(_("Replace:"))) != 0) return false; wxString str = (*dt)[i].Mid(10).Trim(false).RemoveLast(); - if (str == "always") restorePanel->SetRowSelection("Replace", 0); - else if (str == "ifnewer") restorePanel->SetRowSelection("Replace", 1); - else if (str == "ifolder") restorePanel->SetRowSelection("Replace", 2); - else if (str == "never") restorePanel->SetRowSelection("Replace", 3); - else restorePanel->SetRowSelection("Replace", 0); - - if ((k = (*dt)[++i].Find("FileSet:")) != 0) return false; - restorePanel->SetRowString("Fileset", (*dt)[i].Mid(10).Trim(false).RemoveLast()); - if ((k = (*dt)[++i].Find("Client:")) != 0) return false; - restorePanel->SetRowString("Client", (*dt)[i].Mid(10).Trim(false).RemoveLast()); - if ((k = (*dt)[++i].Find("Storage:")) != 0) return false; - restorePanel->SetRowString("Storage", (*dt)[i].Mid(10).Trim(false).RemoveLast()); - if ((k = (*dt)[++i].Find("When:")) != 0) return false; - restorePanel->SetRowString("When", (*dt)[i].Mid(10).Trim(false).RemoveLast()); - if ((k = (*dt)[++i].Find("Priority:")) != 0) return false; - restorePanel->SetRowString("Priority", (*dt)[i].Mid(10).Trim(false).RemoveLast()); + if (str == _("always")) restorePanel->SetRowSelection(_("Replace"), 0); + else if (str == _("ifnewer")) restorePanel->SetRowSelection(_("Replace"), 1); + else if (str == _("ifolder")) restorePanel->SetRowSelection(_("Replace"), 2); + else if (str == _("never")) restorePanel->SetRowSelection(_("Replace"), 3); + else restorePanel->SetRowSelection(_("Replace"), 0); + + if ((k = (*dt)[++i].Find(_("FileSet:"))) != 0) return false; + restorePanel->SetRowString(_("Fileset"), (*dt)[i].Mid(10).Trim(false).RemoveLast()); + if ((k = (*dt)[++i].Find(_("Client:"))) != 0) return false; + restorePanel->SetRowString(_("Client"), (*dt)[i].Mid(10).Trim(false).RemoveLast()); + if ((k = (*dt)[++i].Find(_("Storage:"))) != 0) return false; + restorePanel->SetRowString(_("Storage"), (*dt)[i].Mid(10).Trim(false).RemoveLast()); + if ((k = (*dt)[++i].Find(_("When:"))) != 0) return false; + restorePanel->SetRowString(_("When"), (*dt)[i].Mid(10).Trim(false).RemoveLast()); + if ((k = (*dt)[++i].Find(_("Priority:"))) != 0) return false; + restorePanel->SetRowString(_("Priority"), (*dt)[i].Mid(10).Trim(false).RemoveLast()); cfgUpdated = 0; restorePanel->Layout(); @@ -1773,7 +1891,7 @@ void wxbRestorePanel::SetStatus(status_enum newstatus) { configPanel->Layout(); centerSizer->Layout(); this->Layout(); - start->SetLabel("Enter restore mode"); + start->SetLabel(_("Enter restore mode")); start->Enable(false); configPanel->Enable(false); tree->Enable(false); @@ -1796,13 +1914,13 @@ void wxbRestorePanel::SetStatus(status_enum newstatus) { this->Layout(); tree->DeleteAllItems(); list->DeleteAllItems(); - configPanel->ClearRowChoices("Client"); - configPanel->ClearRowChoices("Before"); + configPanel->ClearRowChoices(_("Client")); + configPanel->ClearRowChoices(_("Before")); wxbMainFrame::GetInstance()->EnablePanels(); newstatus = activable; case activable: cancelled = 0; - start->SetLabel("Enter restore mode"); + start->SetLabel(_("Enter restore mode")); start->Enable(true); configPanel->Enable(false); tree->Enable(false); @@ -1815,7 +1933,7 @@ void wxbRestorePanel::SetStatus(status_enum newstatus) { wxbMainFrame::GetInstance()->DisablePanels(this); gauge->SetValue(0); start->Enable(false); - //start->SetLabel("Choose files to restore"); + //start->SetLabel(_("Choose files to restore")); configPanel->Enable(true); tree->Enable(false); list->Enable(false); @@ -1827,7 +1945,7 @@ void wxbRestorePanel::SetStatus(status_enum newstatus) { break; case choosing: start->Enable(true); - start->SetLabel("Restore"); + start->SetLabel(_("Restore")); centerSizer->Remove(configPanel); configPanel->Show(false); centerSizer->Add(treelistPanel, 1, wxEXPAND); @@ -1854,7 +1972,7 @@ void wxbRestorePanel::SetStatus(status_enum newstatus) { restorePanel->EnableApply(false); break; case restoring: - start->SetLabel("Restoring..."); + start->SetLabel(_("Restoring...")); gauge->Enable(true); gauge->SetValue(0); start->Enable(false); @@ -1933,7 +2051,6 @@ void wxbRestorePanel::OnCancel(wxCommandEvent& event) { void wxbRestorePanel::OnStart(wxCommandEvent& event) { if (IsWorking()) { - AddPendingEvent(event); return; } SetWorking(true); @@ -1943,14 +2060,12 @@ void wxbRestorePanel::OnStart(wxCommandEvent& event) { void wxbRestorePanel::OnTreeChanging(wxTreeEvent& event) { if (IsWorking()) { - AddPendingEvent(event); event.Veto(); } } void wxbRestorePanel::OnTreeExpanding(wxTreeEvent& event) { if (IsWorking()) { - AddPendingEvent(event); event.Veto(); return; } @@ -1964,7 +2079,6 @@ void wxbRestorePanel::OnTreeExpanding(wxTreeEvent& event) { void wxbRestorePanel::OnTreeChanged(wxTreeEvent& event) { if (IsWorking()) { - AddPendingEvent(event); return; } if (currentTreeItem == event.GetItem()) { @@ -1973,11 +2087,11 @@ void wxbRestorePanel::OnTreeChanged(wxTreeEvent& event) { treeadd->Enable(false); treeremove->Enable(false); treerefresh->Enable(false); - markWhenListingDone = false; + markWhenCommandDone = false; SetWorking(true); currentTreeItem = event.GetItem(); CmdList(event.GetItem()); - if (markWhenListingDone) { + if (markWhenCommandDone) { CmdMark(event.GetItem(), NULL, 0); tree->Refresh(); } @@ -1991,17 +2105,19 @@ void wxbRestorePanel::OnTreeChanged(wxTreeEvent& event) { } void wxbRestorePanel::OnTreeMarked(wxbTreeMarkedEvent& event) { - csprint("Tree marked", CS_DEBUG); if (IsWorking()) { if (tree->GetSelection() == event.GetItem()) { - markWhenListingDone = !markWhenListingDone; + markWhenCommandDone = !markWhenCommandDone; } - AddPendingEvent(event); return; } SetWorking(true); + markWhenCommandDone = false; CmdMark(event.GetItem(), NULL, 0); - //event.Skip(); + if (markWhenCommandDone) { + CmdMark(event.GetItem(), NULL, 0); + tree->Refresh(); + } tree->Refresh(); SetWorking(false); if (event.GetItem().IsOk()) { @@ -2013,7 +2129,6 @@ void wxbRestorePanel::OnTreeMarked(wxbTreeMarkedEvent& event) { void wxbRestorePanel::OnTreeAdd(wxCommandEvent& event) { if (IsWorking()) { - AddPendingEvent(event); return; } @@ -2029,7 +2144,6 @@ void wxbRestorePanel::OnTreeAdd(wxCommandEvent& event) { void wxbRestorePanel::OnTreeRemove(wxCommandEvent& event) { if (IsWorking()) { - AddPendingEvent(event); return; } @@ -2045,7 +2159,6 @@ void wxbRestorePanel::OnTreeRemove(wxCommandEvent& event) { void wxbRestorePanel::OnTreeRefresh(wxCommandEvent& event) { if (IsWorking()) { - AddPendingEvent(event); return; } @@ -2056,8 +2169,6 @@ void wxbRestorePanel::OnTreeRefresh(wxCommandEvent& event) { void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) { if (IsWorking()) { - AddPendingEvent(event); - //event.Skip(); return; } @@ -2077,7 +2188,7 @@ void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) { num++; item = list->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); } - + CmdMark(wxTreeItemId(), items, num); delete[] items; @@ -2093,8 +2204,6 @@ void wxbRestorePanel::OnListMarked(wxbListMarkedEvent& event) { void wxbRestorePanel::OnListActivated(wxListEvent& event) { if (IsWorking()) { - AddPendingEvent(event); - //event.Skip(); return; } SetWorking(true); @@ -2107,13 +2216,17 @@ void wxbRestorePanel::OnListActivated(wxListEvent& event) { wxString itemStr; +#if wxCHECK_VERSION(2, 6, 0) + wxTreeItemIdValue cookie; +#else long cookie; +#endif if (name.GetChar(name.Length()-1) == '/') { wxTreeItemId currentChild = tree->GetFirstChild(currentTreeItem, cookie); while (currentChild.IsOk()) { - wxString name2 = tree->GetItemText(currentChild); + wxString name2 = ((wxbTreeItemData*)tree->GetItemData(currentChild))->GetName(); if (name2 == name) { //tree->UnselectAll(); SetWorking(false); @@ -2131,7 +2244,6 @@ void wxbRestorePanel::OnListActivated(wxListEvent& event) { void wxbRestorePanel::OnListChanged(wxListEvent& event) { if (IsWorking()) { - AddPendingEvent(event); return; } @@ -2168,7 +2280,6 @@ void wxbRestorePanel::OnListChanged(wxListEvent& event) { void wxbRestorePanel::OnListAdd(wxCommandEvent& event) { if (IsWorking()) { - AddPendingEvent(event); return; } @@ -2198,7 +2309,6 @@ void wxbRestorePanel::OnListAdd(wxCommandEvent& event) { void wxbRestorePanel::OnListRemove(wxCommandEvent& event) { if (IsWorking()) { - AddPendingEvent(event); return; } @@ -2228,7 +2338,6 @@ void wxbRestorePanel::OnListRemove(wxCommandEvent& event) { void wxbRestorePanel::OnListRefresh(wxCommandEvent& event) { if (IsWorking()) { - AddPendingEvent(event); return; } @@ -2247,7 +2356,7 @@ void wxbRestorePanel::OnConfigUpdated(wxCommandEvent& event) { UpdateFirstConfig(); SetWorking(false); } - else if (event.GetId() == ConfigClient) { + else if ((event.GetId() == ConfigClient) || (event.GetId() == ConfigFileset)) { if (IsWorking()) { return; } @@ -2297,4 +2406,3 @@ void wxbRestorePanel::OnConfigCancel(wxCommandEvent& WXUNUSED(event)) { CmdConfigCancel(); SetWorking(false); } -