]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/run/runcmd.cpp
Make restore job yes/mod/no print in one command so GUI works.
[bacula/bacula] / bacula / src / qt-console / run / runcmd.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
5
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.
12
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.
17
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
21    02110-1301, USA.
22
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.
27 */
28  
29 /*
30  *  Run Command Dialog class
31  *
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.
35  *
36  *   Kern Sibbald, March MMVII
37  *
38  *  $Id: $
39  */ 
40
41 #include "bat.h"
42 #include "run.h"
43
44 /*
45  * Setup all the combo boxes and display the dialog
46  */
47 runCmdDialog::runCmdDialog(Console *console)
48 {
49    m_console = console;
50    m_console->notify(false);
51    setupUi(this);
52    fillRunDialog();
53    this->show();
54    m_console->discardToPrompt();
55 }
56
57 void runCmdDialog::fillRunDialog()
58 {
59    QString item, val;
60    QStringList items;
61    QRegExp rx("^.*:\\s*(\\S.*$)");   /* Regex to get value */
62
63    m_console->read();
64    item = m_console->msg();
65    items = item.split("\n");
66    label->setText(items[0]);
67    Dmsg1(000, "Title=%s\n", items[0].toUtf8().data());
68    items.removeFirst();               /* remove title */
69    foreach(item, items) {
70       rx.indexIn(item);
71       val = rx.cap(1);
72       Dmsg1(000, "Item=%s\n", item.toUtf8().data());
73       Dmsg1(000, "Value=%s\n", val.toUtf8().data());
74
75       if (item.startsWith("JobName:")) {
76          jobCombo->addItem(val);
77          continue;
78       }
79       if (item.startsWith("Bootstrap:")) {
80          bootstrap->setText(val);
81          continue;
82       }
83       if (item.startsWith("Backup Client:")) {
84          clientCombo->addItem(val);
85          continue;
86       }
87       if (item.startsWith("Storage:")) {
88          storageCombo->addItem(val);
89          continue;
90       }
91       if (item.startsWith("Where:")) {
92          where->setText(val);
93          continue;
94       }
95       if (item.startsWith("When:")) {
96          continue;
97       }
98       if (item.startsWith("Catalog:")) {
99          catalogCombo->addItem(val);
100          continue;
101       }
102       if (item.startsWith("Fileset:")) {
103          filesetCombo->addItem(val);
104          continue;
105       }
106       if (item.startsWith("Priority:")) {
107 //       prioritySpin->setValue(atoi(val));
108          continue;
109       }
110    }
111 }
112
113 void runCmdDialog::accept()
114 {
115
116    this->hide();
117    
118    m_console->write_dir("yes");
119    m_console->displayToPrompt();
120    m_console->notify(true);
121    delete this;
122    mainWin->resetFocus();
123 }
124
125
126 void runCmdDialog::reject()
127 {
128    mainWin->set_status(" Canceled");
129    this->hide();
130    m_console->notify(true);
131    delete this;
132    mainWin->resetFocus();
133 }