]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/run/runcmd.cpp
kes Implement bconsole memory command that prints current memory
[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.  This happens, for example, after the user finishes
35  *    selecting files to be restored. The Director will then submit a
36  *    run command, that causes this page to be popped up.
37  *
38  *   Kern Sibbald, March MMVII
39  *
40  *  $Id: $
41  */ 
42
43 #include "bat.h"
44 #include "run.h"
45
46 /*
47  * Setup all the combo boxes and display the dialog
48  */
49 runCmdPage::runCmdPage()
50 {
51    m_name = "Restore Run";
52    pgInitialize();
53    setupUi(this);
54    m_console->notify(false);
55
56    fill();
57    m_console->discardToPrompt();
58
59    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
60    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
61    dockPage();
62    setCurrent();
63    this->show();
64 }
65
66 void runCmdPage::fill()
67 {
68    QString item, val;
69    QStringList items;
70    QRegExp rx("^.*:\\s*(\\S.*$)");   /* Regex to get value */
71
72    m_console->read();
73    item = m_console->msg();
74    items = item.split("\n");
75    label->setText(items[0]);
76    Dmsg1(200, "Title=%s\n", items[0].toUtf8().data());
77    items.removeFirst();               /* remove title */
78    foreach(item, items) {
79       rx.indexIn(item);
80       val = rx.cap(1);
81       Dmsg1(200, "Item=%s\n", item.toUtf8().data());
82       Dmsg1(200, "Value=%s\n", val.toUtf8().data());
83
84       if (item.startsWith("JobName:")) {
85          jobCombo->addItem(val);
86          continue;
87       }
88       if (item.startsWith("Bootstrap:")) {
89          bootstrap->setText(val);
90          continue;
91       }
92       if (item.startsWith("Backup Client:")) {
93          clientCombo->addItem(val);
94          continue;
95       }
96       if (item.startsWith("Storage:")) {
97          storageCombo->addItem(val);
98          continue;
99       }
100       if (item.startsWith("Where:")) {
101          where->setText(val);
102          continue;
103       }
104       if (item.startsWith("When:")) {
105          continue;
106       }
107       if (item.startsWith("Catalog:")) {
108          catalogCombo->addItem(val);
109          continue;
110       }
111       if (item.startsWith("Fileset:")) {
112          filesetCombo->addItem(val);
113          continue;
114       }
115       if (item.startsWith("Priority:")) {
116 //       prioritySpin->setValue(atoi(val));
117          continue;
118       }
119    }
120 }
121
122 void runCmdPage::okButtonPushed()
123 {
124
125    this->hide();
126    
127    m_console->write_dir("yes");
128    m_console->displayToPrompt();
129    m_console->notify(true);
130    closeStackPage();
131    mainWin->resetFocus();
132 }
133
134
135 void runCmdPage::cancelButtonPushed()
136 {
137    m_console->displayToPrompt();
138    mainWin->set_status(" Canceled");
139    this->hide();
140    m_console->notify(true);
141    closeStackPage();
142    mainWin->resetFocus();
143 }