2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 Bacula® is a registered trademark of Kern Sibbald.
18 * Run Command Dialog class
20 * This is called when a Run Command signal is received from the
21 * Director. We parse the Director's output and throw up a
22 * dialog box. This happens, for example, after the user finishes
23 * selecting files to be restored. The Director will then submit a
24 * run command, that causes this page to be popped up.
26 * Kern Sibbald, March MMVII
34 * Setup all the combo boxes and display the dialog
36 runCmdPage::runCmdPage(int conn) : Pages()
38 m_name = tr("Restore Run");
41 QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
42 thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/restore.png")));
44 m_console->notify(conn, false);
48 connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
49 connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
56 void runCmdPage::fill()
60 QRegExp rx("^.*:\\s*(\\S.*$)"); /* Regex to get value */
62 clientCombo->addItems(m_console->client_list);
63 filesetCombo->addItems(m_console->fileset_list);
64 replaceCombo->addItems(QStringList() << tr("never") << tr("always") << tr("ifnewer")
66 replaceCombo->setCurrentIndex(replaceCombo->findText(tr("never"), Qt::MatchExactly));
67 storageCombo->addItems(m_console->storage_list);
68 dateTimeEdit->setDisplayFormat(mainWin->m_dtformat);
70 m_console->read(m_conn);
71 item = m_console->msg(m_conn);
72 items = item.split("\n");
73 foreach(item, items) {
76 Dmsg1(100, "Item=%s\n", item.toUtf8().data());
77 Dmsg1(100, "Value=%s\n", val.toUtf8().data());
79 if (item.startsWith("Title:")) {
82 if (item.startsWith("JobName:")) {
83 jobCombo->addItem(val);
86 if (item.startsWith("Bootstrap:")) {
87 bootstrap->setText(val);
90 if (item.startsWith("Backup Client:")) {
91 clientCombo->setCurrentIndex(clientCombo->findText(val, Qt::MatchExactly));
94 if (item.startsWith("Storage:")) {
95 storageCombo->setCurrentIndex(storageCombo->findText(val, Qt::MatchExactly));
98 if (item.startsWith("Where:")) {
102 if (item.startsWith("When:")) {
103 dateTimeEdit->setDateTime(QDateTime::fromString(val,mainWin->m_dtformat));
106 if (item.startsWith("Catalog:")) {
107 catalogCombo->addItem(val);
110 if (item.startsWith("FileSet:")) {
111 filesetCombo->setCurrentIndex(filesetCombo->findText(val, Qt::MatchExactly));
114 if (item.startsWith("Priority:")) {
116 int pri = val.toInt(&okay, 10);
118 prioritySpin->setValue(pri);
121 if (item.startsWith("Replace:")) {
122 int replaceIndex = replaceCombo->findText(val, Qt::MatchExactly);
123 if (replaceIndex >= 0)
124 replaceCombo->setCurrentIndex(replaceIndex);
130 void runCmdPage::okButtonPushed()
133 cmd += " restoreclient=\"" + clientCombo->currentText() + "\"";
134 cmd += " fileset=\"" + filesetCombo->currentText() + "\"";
135 cmd += " storage=\"" + storageCombo->currentText() + "\"";
136 cmd += " replace=\"" + replaceCombo->currentText() + "\"";
137 cmd += " when=\"" + dateTimeEdit->dateTime().toString(mainWin->m_dtformat) + "\"";
138 cmd += " bootstrap=\"" + bootstrap->text() + "\"";
139 cmd += " where=\"" + where->text() + "\"";
141 QTextStream(&pri) << " priority=\"" << prioritySpin->value() << "\"";
146 QString displayhtml("<font color=\"blue\">");
147 displayhtml += cmd + "</font>\n";
148 m_console->display_html(displayhtml);
149 m_console->display_text("\n");
150 m_console->write_dir(m_conn, cmd.toUtf8().data());
151 m_console->displayToPrompt(m_conn);
152 // consoleCommand(cmd); ***FIXME set back to consoleCommand when connection issue is resolved
154 m_console->notify(m_conn, true);
159 void runCmdPage::cancelButtonPushed()
162 m_console->write_dir(m_conn, "no");
163 m_console->displayToPrompt(m_conn);
164 m_console->notify(m_conn, true);
165 mainWin->set_status(tr(" Canceled"));
167 mainWin->resetFocus();