2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
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.
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.
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
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.
29 * Version $Id: batstack.h 4230 2007-02-21 20:07:37Z kerns $
31 * Dirk Bartley, March 2007
34 #include <QAbstractEventDispatcher>
35 #include <QTableWidgetItem>
36 #include <QMessageBox>
38 #include "mediaedit.h"
43 MediaEdit::MediaEdit(Console *console, QString &mediaId)
46 m_console->notify(false);
53 if (!m_console->preventInUseConnect())
56 /* The media's pool */
57 poolCombo->addItems(console->pool_list);
59 /* The media's Status */
60 QStringList statusList = (QStringList() << "Full" << "Used" << "Append" << "Error" << "Purged" << "Recycled");
61 statusCombo->addItems(statusList);
63 /* Set up the query for the default values */
64 QStringList FieldList = (QStringList()
65 << "Media.VolumeName" << "Pool.Name" << "Media.VolStatus" << "Media.Slot" );
66 QStringList AsList = (QStringList()
67 << "VolumeName" << "PoolName" << "Status" << "Slot" );
69 QString query("SELECT ");
70 foreach (QString field, FieldList) {
74 query += field + " AS " + AsList[i];
77 query += " FROM Media, Pool WHERE Media.PoolId=Pool.PoolId";
78 query += " AND Media.MediaId='" + mediaId + "'";
79 query += " ORDER BY Pool.Name";
81 /* FIXME Make this a user configurable logging action and dont use printf */
82 //printf("MediaList query cmd : %s\n",query.toUtf8().data());
84 if (m_console->sql_cmd(query, results)) {
86 QStringList fieldlist;
88 /* Iterate through the lines of results, there should only be one. */
89 foreach (QString resultline, results) {
90 fieldlist = resultline.split("\t");
93 /* Iterate through fields in the record */
94 foreach (field, fieldlist) {
95 field = field.trimmed(); /* strip leading & trailing spaces */
98 volumeLabel->setText(QString("Volume : %1").arg(m_mediaName));
105 m_slot = field.toInt(&ok, 10);
106 if (!ok){ m_slot = 0; }
109 } /* foreach field */
110 } /* foreach resultline */
111 } /* if results from query */
113 if (m_mediaName != "") {
115 /* default value for pool */
116 index = poolCombo->findText(m_pool, Qt::MatchExactly);
118 poolCombo->setCurrentIndex(index);
121 /* default value for status */
122 index = statusCombo->findText(m_status, Qt::MatchExactly);
124 statusCombo->setCurrentIndex(index);
126 slotSpin->setValue(m_slot);
130 QMessageBox::warning(this, "No Volume name", "No Volume name given",
131 QMessageBox::Ok, QMessageBox::Ok);
138 * Function to handle updating the record
140 void MediaEdit::accept()
145 scmd = QString("update volume=\"%1\"")
147 if (m_pool != poolCombo->currentText()) {
148 scmd += " pool=\"" + poolCombo->currentText() + "\"";
151 if (m_status != statusCombo->currentText()) {
152 scmd += " volstatus=\"" + statusCombo->currentText() + "\"";
155 if (m_slot != slotSpin->value()) {
156 scmd += " slot=" + QString().setNum(slotSpin->value());
160 /* FIXME Make this a user configurable logging action and dont use printf */
161 //printf("sending command : %s\n",scmd.toUtf8().data());
162 m_console->write_dir(scmd.toUtf8().data());
163 m_console->displayToPrompt();
164 m_console->notify(true);
167 mainWin->resetFocus();
170 void MediaEdit::reject()
173 m_console->notify(true);
175 mainWin->resetFocus();