2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation plus additions
11 that are listed in the file LICENSE.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of John Walker.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
30 * Run Command Dialog class
32 * This is called when a Run Command signal is received from the
33 * Director. We parse the Director's output and throw up a
34 * dialog box. This happens, for example, after the user finishes
35 * selecting files to be restored. The Director will then submit a
36 * run command, that causes this page to be popped up.
38 * Kern Sibbald, March MMVII
47 * Setup all the combo boxes and display the dialog
49 runCmdPage::runCmdPage()
51 m_dtformat = "yyyy-MM-dd HH:mm:ss";
52 m_name = "Restore Run";
55 m_console->notify(false);
58 m_console->discardToPrompt();
60 connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
61 connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
68 void runCmdPage::fill()
72 QRegExp rx("^.*:\\s*(\\S.*$)"); /* Regex to get value */
74 clientCombo->addItems(m_console->client_list);
75 filesetCombo->addItems(m_console->fileset_list);
76 replaceCombo->addItems(QStringList() << "never" << "always" << "ifnewer" << "ifolder");
77 storageCombo->addItems(m_console->storage_list);
78 dateTimeEdit->setDisplayFormat(m_dtformat);
81 item = m_console->msg();
82 items = item.split("\n");
83 label->setText(items[0]);
84 Dmsg1(200, "Title=%s\n", items[0].toUtf8().data());
85 items.removeFirst(); /* remove title */
86 foreach(item, items) {
89 Dmsg1(200, "Item=%s\n", item.toUtf8().data());
90 Dmsg1(200, "Value=%s\n", val.toUtf8().data());
92 if (item.startsWith("JobName:")) {
93 jobCombo->addItem(val);
96 if (item.startsWith("Bootstrap:")) {
97 bootstrap->setText(val);
100 if (item.startsWith("Backup Client:")) {
101 clientCombo->setCurrentIndex(clientCombo->findText(val, Qt::MatchExactly));
104 if (item.startsWith("Storage:")) {
105 storageCombo->setCurrentIndex(storageCombo->findText(val, Qt::MatchExactly));
108 if (item.startsWith("Where:")) {
112 if (item.startsWith("When:")) {
113 dateTimeEdit->setDateTime(QDateTime::fromString(val,m_dtformat));
116 if (item.startsWith("Catalog:")) {
117 catalogCombo->addItem(val);
120 if (item.startsWith("FileSet:")) {
121 filesetCombo->setCurrentIndex(filesetCombo->findText(val, Qt::MatchExactly));
124 if (item.startsWith("Priority:")) {
126 int pri = val.toInt(&okay, 10);
128 prioritySpin->setValue(pri);
131 if (item.startsWith("Replace:")) {
132 replaceCombo->setCurrentIndex(replaceCombo->findText(val, Qt::MatchExactly));
138 void runCmdPage::okButtonPushed()
141 cmd += " restoreclient=\"" + clientCombo->currentText() + "\"";
142 cmd += " fileset=\"" + filesetCombo->currentText() + "\"";
143 cmd += " storage=\"" + storageCombo->currentText() + "\"";
144 cmd += " replace=\"" + replaceCombo->currentText() + "\"";
145 cmd += " when=\"" + dateTimeEdit->dateTime().toString(m_dtformat) + "\"";
146 cmd += " bootstrap=\"" + bootstrap->text() + "\"";
147 cmd += " where=\"" + where->text() + "\"";
149 QTextStream(&pri) << " priority=\"" << prioritySpin->value() << "\"";
154 QString displayhtml("<font color=\"blue\">");
155 displayhtml += cmd + "</font>\n";
156 m_console->display_html(displayhtml);
157 m_console->display_text("\n");
158 m_console->write_dir(cmd.toUtf8().data());
159 m_console->displayToPrompt();
160 // consoleCommand(cmd); ***FIXME set back to consoleCommand when connection issue is resolved
162 m_console->notify(true);
167 void runCmdPage::cancelButtonPushed()
169 m_console->displayToPrompt();
170 m_console->write_dir(".");
171 m_console->displayToPrompt();
172 mainWin->set_status(" Canceled");
174 m_console->notify(true);
176 mainWin->resetFocus();