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);
47 m_console->discardToPrompt(m_conn);
49 connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
50 connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
57 void runCmdPage::fill()
61 QRegExp rx("^.*:\\s*(\\S.*$)"); /* Regex to get value */
63 clientCombo->addItems(m_console->client_list);
64 filesetCombo->addItems(m_console->fileset_list);
65 replaceCombo->addItems(QStringList() << tr("never") << tr("always") << tr("ifnewer")
67 replaceCombo->setCurrentIndex(replaceCombo->findText(tr("never"), Qt::MatchExactly));
68 storageCombo->addItems(m_console->storage_list);
69 dateTimeEdit->setDisplayFormat(mainWin->m_dtformat);
71 m_console->read(m_conn);
72 item = m_console->msg(m_conn);
73 items = item.split("\n");
74 foreach(item, items) {
77 Dmsg1(100, "Item=%s\n", item.toUtf8().data());
78 Dmsg1(100, "Value=%s\n", val.toUtf8().data());
80 if (item.startsWith("Title:")) {
83 if (item.startsWith("JobName:")) {
84 jobCombo->addItem(val);
87 if (item.startsWith("Bootstrap:")) {
88 bootstrap->setText(val);
91 if (item.startsWith("Backup Client:")) {
92 clientCombo->setCurrentIndex(clientCombo->findText(val, Qt::MatchExactly));
95 if (item.startsWith("Storage:")) {
96 storageCombo->setCurrentIndex(storageCombo->findText(val, Qt::MatchExactly));
99 if (item.startsWith("Where:")) {
103 if (item.startsWith("When:")) {
104 dateTimeEdit->setDateTime(QDateTime::fromString(val,mainWin->m_dtformat));
107 if (item.startsWith("Catalog:")) {
108 catalogCombo->addItem(val);
111 if (item.startsWith("FileSet:")) {
112 filesetCombo->setCurrentIndex(filesetCombo->findText(val, Qt::MatchExactly));
115 if (item.startsWith("Priority:")) {
117 int pri = val.toInt(&okay, 10);
119 prioritySpin->setValue(pri);
122 if (item.startsWith("Replace:")) {
123 int replaceIndex = replaceCombo->findText(val, Qt::MatchExactly);
124 if (replaceIndex >= 0)
125 replaceCombo->setCurrentIndex(replaceIndex);
131 void runCmdPage::okButtonPushed()
134 cmd += " restoreclient=\"" + clientCombo->currentText() + "\"";
135 cmd += " fileset=\"" + filesetCombo->currentText() + "\"";
136 cmd += " storage=\"" + storageCombo->currentText() + "\"";
137 cmd += " replace=\"" + replaceCombo->currentText() + "\"";
138 cmd += " when=\"" + dateTimeEdit->dateTime().toString(mainWin->m_dtformat) + "\"";
139 cmd += " bootstrap=\"" + bootstrap->text() + "\"";
140 cmd += " where=\"" + where->text() + "\"";
142 QTextStream(&pri) << " priority=\"" << prioritySpin->value() << "\"";
147 QString displayhtml("<font color=\"blue\">");
148 displayhtml += cmd + "</font>\n";
149 m_console->display_html(displayhtml);
150 m_console->display_text("\n");
151 m_console->write_dir(m_conn, cmd.toUtf8().data());
152 m_console->displayToPrompt(m_conn);
153 // consoleCommand(cmd); ***FIXME set back to consoleCommand when connection issue is resolved
155 m_console->notify(m_conn, true);
160 void runCmdPage::cancelButtonPushed()
162 m_console->displayToPrompt(m_conn);
163 m_console->write_dir(".");
164 m_console->displayToPrompt(m_conn);
165 mainWin->set_status(tr(" Canceled"));
167 m_console->notify(m_conn, true);
169 mainWin->resetFocus();