2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many 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 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
21 * Run Command Dialog class
23 * This is called when a Run Command signal is received from the
24 * Director. We parse the Director's output and throw up a
25 * dialog box. This happens, for example, after the user finishes
26 * selecting files to be restored. The Director will then submit a
27 * run command, that causes this page to be popped up.
29 * Kern Sibbald, March MMVII
37 * Setup all the combo boxes and display the dialog
39 runCmdPage::runCmdPage(int conn) : Pages()
41 m_name = tr("Restore Run");
44 QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
45 thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/restore.png")));
47 m_console->notify(conn, false);
51 connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
52 connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
59 void runCmdPage::fill()
63 QRegExp rx("^.*:\\s*(\\S.*$)"); /* Regex to get value */
65 clientCombo->addItems(m_console->client_list);
66 filesetCombo->addItems(m_console->fileset_list);
67 replaceCombo->addItems(QStringList() << tr("never") << tr("always") << tr("ifnewer")
69 replaceCombo->setCurrentIndex(replaceCombo->findText(tr("never"), Qt::MatchExactly));
70 storageCombo->addItems(m_console->storage_list);
71 dateTimeEdit->setDisplayFormat(mainWin->m_dtformat);
73 m_console->read(m_conn);
74 item = m_console->msg(m_conn);
75 items = item.split("\n");
76 foreach(item, items) {
79 Dmsg1(100, "Item=%s\n", item.toUtf8().data());
80 Dmsg1(100, "Value=%s\n", val.toUtf8().data());
82 if (item.startsWith("Title:")) {
85 if (item.startsWith("JobName:")) {
86 jobCombo->addItem(val);
89 if (item.startsWith("Bootstrap:")) {
90 bootstrap->setText(val);
93 if (item.startsWith("Backup Client:")) {
94 clientCombo->setCurrentIndex(clientCombo->findText(val, Qt::MatchExactly));
97 if (item.startsWith("Storage:")) {
98 storageCombo->setCurrentIndex(storageCombo->findText(val, Qt::MatchExactly));
101 if (item.startsWith("Where:")) {
105 if (item.startsWith("When:")) {
106 dateTimeEdit->setDateTime(QDateTime::fromString(val,mainWin->m_dtformat));
109 if (item.startsWith("Catalog:")) {
110 catalogCombo->addItem(val);
113 if (item.startsWith("FileSet:")) {
114 filesetCombo->setCurrentIndex(filesetCombo->findText(val, Qt::MatchExactly));
117 if (item.startsWith("Priority:")) {
119 int pri = val.toInt(&okay, 10);
121 prioritySpin->setValue(pri);
124 if (item.startsWith("Replace:")) {
125 int replaceIndex = replaceCombo->findText(val, Qt::MatchExactly);
126 if (replaceIndex >= 0)
127 replaceCombo->setCurrentIndex(replaceIndex);
133 void runCmdPage::okButtonPushed()
136 cmd += " restoreclient=\"" + clientCombo->currentText() + "\"";
137 cmd += " fileset=\"" + filesetCombo->currentText() + "\"";
138 cmd += " storage=\"" + storageCombo->currentText() + "\"";
139 cmd += " replace=\"" + replaceCombo->currentText() + "\"";
140 cmd += " when=\"" + dateTimeEdit->dateTime().toString(mainWin->m_dtformat) + "\"";
141 cmd += " bootstrap=\"" + bootstrap->text() + "\"";
142 cmd += " where=\"" + where->text() + "\"";
144 QTextStream(&pri) << " priority=\"" << prioritySpin->value() << "\"";
149 QString displayhtml("<font color=\"blue\">");
150 displayhtml += cmd + "</font>\n";
151 m_console->display_html(displayhtml);
152 m_console->display_text("\n");
153 m_console->write_dir(m_conn, cmd.toUtf8().data());
154 m_console->displayToPrompt(m_conn);
155 // consoleCommand(cmd); ***FIXME set back to consoleCommand when connection issue is resolved
157 m_console->notify(m_conn, true);
162 void runCmdPage::cancelButtonPushed()
165 m_console->write_dir(m_conn, "no");
166 m_console->displayToPrompt(m_conn);
167 m_console->notify(m_conn, true);
168 mainWin->set_status(tr(" Canceled"));
170 mainWin->resetFocus();