]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/label/label.cpp
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / bacula / src / qt-console / label / label.cpp
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2016 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is 
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19  
20 /*
21  *  Label Page class
22  *
23  *   Kern Sibbald, February MMVII
24  *
25  */ 
26
27 #include "bat.h"
28 #include "label.h"
29 #include <QMessageBox>
30
31 labelPage::labelPage() : Pages()
32 {
33    QString deflt("");
34    m_closeable = false;
35    showPage(deflt);
36 }
37
38 /*
39  * An overload of the constructor to have a default storage show in the
40  * combobox on start.  Used from context sensitive in storage class.
41  */
42 labelPage::labelPage(QString &defString) : Pages()
43 {
44    showPage(defString);
45 }
46
47 /*
48  * moved the constructor code here for the overload.
49  */
50 void labelPage::showPage(QString &defString)
51 {
52    m_name = "Label";
53    pgInitialize();
54    setupUi(this);
55    m_conn = m_console->notifyOff();
56    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
57    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/label.png")));
58
59    storageCombo->addItems(m_console->storage_list);
60    int index = storageCombo->findText(defString, Qt::MatchExactly);
61    if (index != -1) {
62       storageCombo->setCurrentIndex(index);
63    }
64    poolCombo->addItems(m_console->pool_list);
65    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
66    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
67    connect(automountOnButton, SIGNAL(pressed()), this, SLOT(automountOnButtonPushed()));
68    connect(automountOffButton, SIGNAL(pressed()), this, SLOT(automountOffButtonPushed()));
69    dockPage();
70    setCurrent();
71    this->show();
72 }
73
74
75 void labelPage::okButtonPushed()
76 {
77    QString scmd;
78    if (volumeName->text().toUtf8().data()[0] == 0) {
79       QMessageBox::warning(this, "No Volume name", "No Volume name given",
80                            QMessageBox::Ok, QMessageBox::Ok);
81       return;
82    }
83    this->hide();
84    scmd = QString("label volume=\"%1\" pool=\"%2\" storage=\"%3\" slot=%4\n")
85                   .arg(volumeName->text())
86                   .arg(poolCombo->currentText())
87                   .arg(storageCombo->currentText()) 
88                   .arg(slotSpin->value());
89    if (mainWin->m_commandDebug) {
90       Pmsg1(000, "sending command : %s\n", scmd.toUtf8().data());
91    }
92    if (m_console) {
93       m_console->write_dir(scmd.toUtf8().data());
94       m_console->displayToPrompt(m_conn);
95       m_console->notify(m_conn, true);
96    } else {
97       Pmsg0(000, "m_console==NULL !!!!!!\n");
98    }
99    closeStackPage();
100    mainWin->resetFocus();
101 }
102
103 void labelPage::cancelButtonPushed()
104 {
105    this->hide();
106    if (m_console) {
107       m_console->notify(m_conn, true);
108    } else {
109       Pmsg0(000, "m_console==NULL !!!!!!\n");
110    }
111    closeStackPage();
112    mainWin->resetFocus();
113 }
114
115 /* turn automount on */
116 void labelPage::automountOnButtonPushed()
117 {
118    QString cmd("automount on");
119    consoleCommand(cmd);
120 }
121
122 /* turn automount off */
123 void labelPage::automountOffButtonPushed()
124 {
125    QString cmd("automount off");
126    consoleCommand(cmd);
127 }