2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
22 * Run Command Dialog class
24 * This is called when a Run Command signal is received from the
25 * Director. We parse the Director's output and throw up a
26 * dialog box. This happens, for example, after the user finishes
27 * selecting files to be restored. The Director will then submit a
28 * run command, that causes this page to be popped up.
30 * Kern Sibbald, March MMVII
38 * Setup all the combo boxes and display the dialog
40 runCmdPage::runCmdPage(int conn) : Pages()
42 m_name = tr("Restore Run");
45 QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
46 thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/restore.png")));
48 m_console->notify(conn, false);
52 connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
53 connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
60 void runCmdPage::fill()
64 QRegExp rx("^.*:\\s*(\\S.*$)"); /* Regex to get value */
66 clientCombo->addItems(m_console->client_list);
67 filesetCombo->addItems(m_console->fileset_list);
68 replaceCombo->addItems(QStringList() << tr("never") << tr("always") << tr("ifnewer")
70 replaceCombo->setCurrentIndex(replaceCombo->findText(tr("never"), Qt::MatchExactly));
71 storageCombo->addItems(m_console->storage_list);
72 dateTimeEdit->setDisplayFormat(mainWin->m_dtformat);
74 m_console->read(m_conn);
75 item = m_console->msg(m_conn);
76 items = item.split("\n");
77 foreach(item, items) {
80 Dmsg1(100, "Item=%s\n", item.toUtf8().data());
81 Dmsg1(100, "Value=%s\n", val.toUtf8().data());
83 if (item.startsWith("Title:")) {
86 if (item.startsWith("JobName:")) {
87 jobCombo->addItem(val);
90 if (item.startsWith("Bootstrap:")) {
91 bootstrap->setText(val);
94 if (item.startsWith("Backup Client:")) {
95 clientCombo->setCurrentIndex(clientCombo->findText(val, Qt::MatchExactly));
98 if (item.startsWith("Storage:")) {
99 storageCombo->setCurrentIndex(storageCombo->findText(val, Qt::MatchExactly));
102 if (item.startsWith("Where:")) {
106 if (item.startsWith("When:")) {
107 dateTimeEdit->setDateTime(QDateTime::fromString(val,mainWin->m_dtformat));
110 if (item.startsWith("Catalog:")) {
111 catalogCombo->addItem(val);
114 if (item.startsWith("FileSet:")) {
115 filesetCombo->setCurrentIndex(filesetCombo->findText(val, Qt::MatchExactly));
118 if (item.startsWith("Priority:")) {
120 int pri = val.toInt(&okay, 10);
122 prioritySpin->setValue(pri);
125 if (item.startsWith("Replace:")) {
126 int replaceIndex = replaceCombo->findText(val, Qt::MatchExactly);
127 if (replaceIndex >= 0)
128 replaceCombo->setCurrentIndex(replaceIndex);
134 void runCmdPage::okButtonPushed()
137 cmd += " restoreclient=\"" + clientCombo->currentText() + "\"";
138 cmd += " fileset=\"" + filesetCombo->currentText() + "\"";
139 cmd += " storage=\"" + storageCombo->currentText() + "\"";
140 cmd += " replace=\"" + replaceCombo->currentText() + "\"";
141 cmd += " when=\"" + dateTimeEdit->dateTime().toString(mainWin->m_dtformat) + "\"";
142 cmd += " bootstrap=\"" + bootstrap->text() + "\"";
143 cmd += " where=\"" + where->text() + "\"";
145 QTextStream(&pri) << " priority=\"" << prioritySpin->value() << "\"";
150 QString displayhtml("<font color=\"blue\">");
151 displayhtml += cmd + "</font>\n";
152 m_console->display_html(displayhtml);
153 m_console->display_text("\n");
154 m_console->write_dir(m_conn, cmd.toUtf8().data());
155 m_console->displayToPrompt(m_conn);
156 // consoleCommand(cmd); ***FIXME set back to consoleCommand when connection issue is resolved
158 m_console->notify(m_conn, true);
163 void runCmdPage::cancelButtonPushed()
166 m_console->write_dir(m_conn, "no");
167 m_console->displayToPrompt(m_conn);
168 m_console->notify(m_conn, true);
169 mainWin->set_status(tr(" Canceled"));
171 mainWin->resetFocus();