]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/run/runcmd.cpp
Moved dialogs to be pages on the stack. label, run and runcmd.
[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 runCmdPage::runCmdPage()
48 {
49    m_name = "Restore Run";
50    pgInitialize();
51    setupUi(this);
52    m_console->notify(false);
53
54    fill();
55    m_console->discardToPrompt();
56
57    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
58    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
59    dockPage();
60    setCurrent();
61    this->show();
62 }
63
64 void runCmdPage::fill()
65 {
66    QString item, val;
67    QStringList items;
68    QRegExp rx("^.*:\\s*(\\S.*$)");   /* Regex to get value */
69
70    m_console->read();
71    item = m_console->msg();
72    items = item.split("\n");
73    label->setText(items[0]);
74    Dmsg1(200, "Title=%s\n", items[0].toUtf8().data());
75    items.removeFirst();               /* remove title */
76    foreach(item, items) {
77       rx.indexIn(item);
78       val = rx.cap(1);
79       Dmsg1(200, "Item=%s\n", item.toUtf8().data());
80       Dmsg1(200, "Value=%s\n", val.toUtf8().data());
81
82       if (item.startsWith("JobName:")) {
83          jobCombo->addItem(val);
84          continue;
85       }
86       if (item.startsWith("Bootstrap:")) {
87          bootstrap->setText(val);
88          continue;
89       }
90       if (item.startsWith("Backup Client:")) {
91          clientCombo->addItem(val);
92          continue;
93       }
94       if (item.startsWith("Storage:")) {
95          storageCombo->addItem(val);
96          continue;
97       }
98       if (item.startsWith("Where:")) {
99          where->setText(val);
100          continue;
101       }
102       if (item.startsWith("When:")) {
103          continue;
104       }
105       if (item.startsWith("Catalog:")) {
106          catalogCombo->addItem(val);
107          continue;
108       }
109       if (item.startsWith("Fileset:")) {
110          filesetCombo->addItem(val);
111          continue;
112       }
113       if (item.startsWith("Priority:")) {
114 //       prioritySpin->setValue(atoi(val));
115          continue;
116       }
117    }
118 }
119
120 void runCmdPage::okButtonPushed()
121 {
122
123    this->hide();
124    
125    m_console->write_dir("yes");
126    m_console->displayToPrompt();
127    m_console->notify(true);
128    delete this;
129    mainWin->resetFocus();
130 }
131
132
133 void runCmdPage::cancelButtonPushed()
134 {
135    mainWin->set_status(" Canceled");
136    this->hide();
137    m_console->notify(true);
138    delete this;
139    mainWin->resetFocus();
140 }