]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/run/run.cpp
Default to never in overwrite in replace of runcmd.
[bacula/bacula] / bacula / src / qt-console / run / run.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 Dialog class
31  *
32  *   Kern Sibbald, February MMVII
33  *
34  *  $Id$
35  */ 
36
37 #include "bat.h"
38 #include "run.h"
39
40 /*
41  * Setup all the combo boxes and display the dialog
42  */
43 runPage::runPage()
44 {
45    QDateTime dt;
46
47    m_name = "Run";
48    pgInitialize();
49    setupUi(this);
50    m_console->notify(false);
51
52    m_console->beginNewCommand();
53    jobCombo->addItems(m_console->job_list);
54    filesetCombo->addItems(m_console->fileset_list);
55    levelCombo->addItems(m_console->level_list);
56    clientCombo->addItems(m_console->client_list);
57    poolCombo->addItems(m_console->pool_list);
58    storageCombo->addItems(m_console->storage_list);
59    dateTimeEdit->setDisplayFormat(mainWin->m_dtformat);
60    dateTimeEdit->setDateTime(dt.currentDateTime());
61    /*printf("listing messages resources");  ***FIME ***
62    foreach(QString mes, m_console->messages_list) {
63       printf("%s\n", mes.toUtf8().data());
64    }*/
65    messagesCombo->addItems(m_console->messages_list);
66    job_name_change(0);
67    connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int)));
68    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
69    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
70
71    dockPage();
72    setCurrent();
73    this->show();
74 }
75
76 void runPage::okButtonPushed()
77 {
78    this->hide();
79    QString cmd;
80    QTextStream(&cmd) << "run" << 
81       " job=\"" << jobCombo->currentText() << "\"" <<
82       " fileset=\"" << filesetCombo->currentText() << "\"" <<
83       " level=\"" << levelCombo->currentText() << "\"" <<
84       " client=\"" << clientCombo->currentText() << "\"" <<
85       " pool=\"" << poolCombo->currentText() << "\"" <<
86       " storage=\"" << storageCombo->currentText() << "\"" <<
87       " priority=\"" << prioritySpin->value() << "\""
88       " when=\"" << dateTimeEdit->dateTime().toString(mainWin->m_dtformat) << "\"";
89    if (bootstrap->text() != "") {
90       cmd += " bootstrap=\"" + bootstrap->text() + "\""; 
91    }
92    cmd += " yes";
93 //  messagesCombo->currentText().toUtf8().data(); FIXME messages not working
94
95    if (mainWin->m_commandDebug) {
96       Pmsg1(000, "command : %s\n", cmd.toUtf8().data());
97    }
98
99    m_console->write_dir(cmd.toUtf8().data());
100    m_console->display_text(cmd);
101    m_console->displayToPrompt();
102    m_console->notify(true);
103    closeStackPage();
104    mainWin->resetFocus();
105 }
106
107
108 void runPage::cancelButtonPushed()
109 {
110    mainWin->set_status(" Canceled");
111    this->hide();
112    m_console->notify(true);
113    closeStackPage();
114    mainWin->resetFocus();
115 }
116
117 /*
118  * Called here when the jobname combo box is changed.
119  *  We load the default values for the new job in the
120  *  other combo boxes.
121  */
122 void runPage::job_name_change(int index)
123 {
124    job_defaults job_defs;
125
126    (void)index;
127    job_defs.job_name = jobCombo->currentText();
128    if (m_console->get_job_defaults(job_defs)) {
129       filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
130       levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
131       clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
132       poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
133       storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
134       messagesCombo->setCurrentIndex(messagesCombo->findText(job_defs.messages_name, Qt::MatchExactly));
135    }
136 }