POOL_DBR pr;
vol_list_t *vl, *vol_list = NULL;
MEDIA_DBR mr;
+ char ed1[50], ed2[50], ed3[50];
char *slot_list;
int max_slots;
int drive;
int i=1;
/* output format */
- const char *slot_api_empty_format="%i|||||\n";
- const char *slot_api_full_format="%i|%i|%s|%s|%s|%s|\n";
+ const char *slot_api_empty_format="%i||||||||\n";
+ const char *slot_api_full_format="%i|%i|%s|%s|%s|%s|%s|%s|%s\n";
const char *slot_hformat=" %4i%c| %16s | %9s | %20s | %18s |\n";
if (!open_client_db(ua)) {
mr.VolumeName, mr.VolStatus, mr.MediaType, pr.Name);
} else {
ua->send_msg(slot_api_full_format,
- vl->Slot, mr.Slot, mr.VolumeName, mr.VolStatus,
- mr.MediaType, pr.Name);
+ vl->Slot, mr.Slot, mr.VolumeName,
+ edit_uint64(mr.VolBytes, ed1),
+ mr.VolStatus, mr.MediaType, pr.Name,
+ edit_uint64(mr.LastWritten, ed2),
+ edit_uint64(mr.LastWritten+mr.VolRetention, ed3));
}
db_unlock(ua->db);
continue;
} else { /* TODO: get information from catalog */
- ua->send_msg(slot_hformat,
- vl->Slot, '*',
- mr.VolumeName, "?", "?", "?");
+ if (!ua->api) {
+ ua->send_msg(slot_hformat,
+ vl->Slot, '*',
+ mr.VolumeName, "?", "?", "?");
+ } else {
+ ua->send_msg(slot_api_empty_format, vl->Slot);
+ }
}
db_unlock(ua->db);
}
FORMS += clients/clients.ui storage/storage.ui fileset/fileset.ui
FORMS += joblog/joblog.ui jobs/jobs.ui job/job.ui
FORMS += help/help.ui mediainfo/mediainfo.ui
-FORMS += status/dirstat.ui
+FORMS += status/dirstat.ui storage/content.ui
FORMS += status/clientstat.ui
FORMS += status/storstat.ui
qwt {
HEADERS += storage/storage.h
SOURCES += storage/storage.cpp
+## Storage content
+HEADERS += storage/content.h
+SOURCES += storage/content.cpp
+
## Fileset
HEADERS += fileset/fileset.h
SOURCES += fileset/fileset.cpp
--- /dev/null
+/*
+ Bacula® - The Network Backup Solution
+
+ Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
+
+ The main author of Bacula is Kern Sibbald, with contributions from
+ many others, a complete list can be found in the file AUTHORS.
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version two of the GNU General Public
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Bacula® is a registered trademark of Kern Sibbald.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
+
+#include "bat.h"
+#include <QAbstractEventDispatcher>
+#include <QMenu>
+#include "content.h"
+#include "label/label.h"
+#include "mount/mount.h"
+#include "util/fmtwidgetitem.h"
+#include "status/storstat.h"
+
+Content::Content(QString storage)
+{
+ setupUi(this);
+ pgInitialize(tr("Storage Content"));
+ QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
+ thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/package-x-generic.png")));
+
+ m_populated = false;
+ m_firstpopulation = true;
+ m_checkcurwidget = true;
+ m_closeable = true;
+ m_currentStorage = storage;
+
+ populateContent();
+
+ dockPage();
+ setCurrent();
+}
+
+/*
+ * The main meat of the class!! The function that querries the director and
+ * creates the widgets with appropriate values.
+ */
+void Content::populateContent()
+{
+ char buf[200];
+ time_t t;
+ struct tm tm;
+
+ m_populated = true;
+ m_firstpopulation = false;
+ Freeze frz(*tableContent); /* disable updating*/
+ tableContent->clearContents();
+
+ QStringList results_all;
+ QString cmd("status slots drive=0 storage=\"" + m_currentStorage + "\"");
+
+ m_console->dir_cmd(cmd, results_all);
+ // skip non list messages
+ QStringList results = results_all.filter(QRegExp("[0-9]+\\|"));
+ Pmsg1(0, "count=%i\n", results.size());
+ tableContent->setRowCount(results.size());
+ int row = results.size();
+
+// tableContent->setColumnCount(8);
+ int col, i;
+ foreach (QString resultline, results){
+ QStringList fieldlist = resultline.split("|");
+ col=0;
+ i=0;
+
+ if (fieldlist.size() < 9)
+ continue; /* some fields missing, ignore row */
+
+ Pmsg2(0, "row=%i line=%s\n", row, resultline.toUtf8().data());
+
+ TableItemFormatter slotitem(*tableContent, row--);
+
+ slotitem.setNumericFld(col++, fieldlist[i++]); // Slot
+
+ if (fieldlist[i++] != "") { // skip "Real Slot"
+ slotitem.setTextFld(col++, fieldlist[i++]); // Volume
+ slotitem.setBytesFld(col++, fieldlist[i++]); // Bytes
+ slotitem.setVolStatusFld(col++, fieldlist[i++]); // Status
+ slotitem.setTextFld(col++, fieldlist[i++]); // MediaType
+ slotitem.setTextFld(col++, fieldlist[i++]); // Pool
+
+ if (fieldlist[i].toInt() > 0) {
+ t = fieldlist[i++].toInt();
+ localtime_r(&t, &tm);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
+ slotitem.setTextFld(col++, QString(buf)); // LastWritten
+
+ t = fieldlist[i++].toInt();
+ localtime_r(&t, &tm);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
+ slotitem.setTextFld(col++, QString(buf)); // Expire
+ }
+ }
+ }
+
+ tableContent->resizeColumnsToContents();
+ tableContent->verticalHeader()->hide();
+
+ tableContent->sortByColumn(0, Qt::AscendingOrder);
+ tableContent->setSortingEnabled(true);
+
+ int rcnt = tableContent->rowCount();
+ int ccnt = tableContent->columnCount();
+ for(int r=0; r < rcnt; r++) {
+ for(int c=0; c < ccnt; c++) {
+ QTableWidgetItem* item = tableContent->item(r, c);
+ if (item) {
+ item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
+ }
+ }
+ }
+
+ tableTray->verticalHeader()->hide();
+ tableDrive->verticalHeader()->hide();
+}
+
+/*
+ * Virtual function which is called when this page is visible on the stack
+ */
+void Content::currentStackItem()
+{
+ if(!m_populated) {
+ populateContent();
+ }
+}
+
+/*
+ * Functions to respond to local context sensitive menu sending console
+ * commands If I could figure out how to make these one function passing a
+ * string, Yaaaaaa
+ */
+void Content::consoleStatusStorage()
+{
+ QString cmd("status storage=");
+ cmd += m_currentStorage;
+ consoleCommand(cmd);
+}
+
+/* Label Media populating current storage by default */
+void Content::consoleLabelStorage()
+{
+ new labelPage(m_currentStorage);
+}
+
+void Content::treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)
+{
+
+}
+
+/* Mount currently selected storage */
+void Content::consoleMountStorage()
+{
+ if (m_currentAutoChanger == 0){
+ /* no autochanger, just execute the command in the console */
+ QString cmd("mount storage=");
+ cmd += m_currentStorage;
+ consoleCommand(cmd);
+ } else {
+ setConsoleCurrent();
+ /* if this storage is an autochanger, lets ask for the slot */
+ new mountDialog(m_console, m_currentStorage);
+ }
+}
+
+/* Unmount Currently selected storage */
+void Content::consoleUnMountStorage()
+{
+ QString cmd("umount storage=");
+ cmd += m_currentStorage;
+ consoleCommand(cmd);
+}
+
+/* Update Slots */
+void Content::consoleUpdateSlots()
+{
+ QString cmd("update slots storage=");
+ cmd += m_currentStorage;
+ consoleCommand(cmd);
+}
+
+/* Update Slots Scan*/
+void Content::consoleUpdateSlotsScan()
+{
+ QString cmd("update slots scan storage=");
+ cmd += m_currentStorage;
+ consoleCommand(cmd);
+}
+
+/* Release a tape in the drive */
+void Content::consoleRelease()
+{
+ QString cmd("release storage=");
+ cmd += m_currentStorage;
+ consoleCommand(cmd);
+}
+
+/*
+ * Open a status storage window
+ */
+void Content::statusStorageWindow()
+{
+ /* if one exists, then just set it current */
+ bool found = false;
+ foreach(Pages *page, mainWin->m_pagehash) {
+ if (mainWin->currentConsole() == page->console()) {
+ if (page->name() == tr("Storage Status %1").arg(m_currentStorage)) {
+ found = true;
+ page->setCurrent();
+ }
+ }
+ }
+ if (!found) {
+ QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
+ new StorStat(m_currentStorage, parentItem);
+ }
+}
--- /dev/null
+#ifndef _CONTENT_H_
+#define _CONTENT_H_
+/*
+ Bacula® - The Network Backup Solution
+
+ Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
+
+ The main author of Bacula is Kern Sibbald, with contributions from
+ many others, a complete list can be found in the file AUTHORS.
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version two of the GNU General Public
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Bacula® is a registered trademark of Kern Sibbald.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
+
+#include <QtGui>
+#include "ui_content.h"
+#include "console.h"
+#include "pages.h"
+
+class Content : public Pages, public Ui::ContentForm
+{
+ Q_OBJECT
+
+public:
+ Content(QString storage);
+// virtual void PgSeltreeWidgetClicked();
+ virtual void currentStackItem();
+ void consoleUnMountStorage();
+ void consoleUpdateSlots();
+ void consoleUpdateSlotsScan();
+ void consoleLabelStorage();
+ void consoleStatusStorage();
+ void consoleMountStorage();
+ void statusStorageWindow();
+ void consoleRelease();
+
+public slots:
+ void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
+
+private slots:
+ void populateContent();
+
+private:
+ bool m_currentAutoChanger;
+ bool m_populated;
+ bool m_firstpopulation;
+ bool m_checkcurwidget;
+ QString m_currentStorage;
+};
+
+#endif /* _STORAGE_H_ */
--- /dev/null
+<ui version="4.0" >
+ <class>ContentForm</class>
+ <widget class="QWidget" name="ContentForm" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>949</width>
+ <height>695</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" >
+ <item>
+ <layout class="QVBoxLayout" >
+ <item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>240</width>
+ <height>110</height>
+ </size>
+ </property>
+ <property name="title" >
+ <string>Actions</string>
+ </property>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QPushButton" name="pbUpdate" >
+ <property name="text" >
+ <string>Update</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="../main.qrc" >:/images/view-refresh.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QPushButton" name="pbLabel" >
+ <property name="text" >
+ <string>Label</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="../main.qrc" >:/images/label.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QPushButton" name="pbMoveToTray" >
+ <property name="text" >
+ <string>Move to tray</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="../main.qrc" >:/images/extern.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QPushButton" name="pbEmptyTray" >
+ <property name="text" >
+ <string>Empty tray</string>
+ </property>
+ <property name="icon" >
+ <iconset resource="../main.qrc" >:/images/intern.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QPushButton" name="pushButton" >
+ <property name="text" >
+ <string>Mount</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QPushButton" name="pushButton_2" >
+ <property name="text" >
+ <string>Unmount</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>241</width>
+ <height>221</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>241</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="title" >
+ <string>Drives</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <item>
+ <widget class="QTableWidget" name="tableDrive" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>220</width>
+ <height>192</height>
+ </size>
+ </property>
+ <property name="selectionBehavior" >
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <row>
+ <property name="text" >
+ <string>LTO1</string>
+ </property>
+ </row>
+ <row>
+ <property name="text" >
+ <string>New Row</string>
+ </property>
+ </row>
+ <column>
+ <property name="text" >
+ <string>Drive</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Volume</string>
+ </property>
+ </column>
+ <item row="0" column="0" >
+ <property name="text" >
+ <string>LTO1</string>
+ </property>
+ </item>
+ <item row="0" column="1" >
+ <property name="text" >
+ <string>VOL1</string>
+ </property>
+ </item>
+ <item row="1" column="0" >
+ <property name="text" >
+ <string>LTO2</string>
+ </property>
+ </item>
+ <item row="1" column="1" >
+ <property name="text" >
+ <string>VOL2</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_4" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>240</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="title" >
+ <string>Tray slots</string>
+ </property>
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="QTableWidget" name="tableTray" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="selectionBehavior" >
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="sortingEnabled" >
+ <bool>false</bool>
+ </property>
+ <column>
+ <property name="text" >
+ <string>Slot</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Volume</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2" >
+ <property name="title" >
+ <string>Content</string>
+ </property>
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="QTableWidget" name="tableContent" >
+ <property name="alternatingRowColors" >
+ <bool>true</bool>
+ </property>
+ <property name="selectionMode" >
+ <enum>QAbstractItemView::ExtendedSelection</enum>
+ </property>
+ <property name="selectionBehavior" >
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="sortingEnabled" >
+ <bool>true</bool>
+ </property>
+ <property name="rowCount" >
+ <number>0</number>
+ </property>
+ <column>
+ <property name="text" >
+ <string> Slot </string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string> Volume </string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string> Bytes </string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string> Status </string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string> Media Type </string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string> Pool </string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string> Last Written </string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string> When expire? </string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="../main.qrc" />
+ </resources>
+ <connections/>
+</ui>
#include <QAbstractEventDispatcher>
#include <QMenu>
#include "storage.h"
+#include "content.h"
#include "label/label.h"
#include "mount/mount.h"
#include "status/storstat.h"
SLOT(consoleRelease()));
connect(actionStatusStorageWindow, SIGNAL(triggered()), this,
SLOT(statusStorageWindow()));
+ connect(mp_treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
+ this, SLOT(contentWindow()));
+
+}
+
+void Storage::contentWindow()
+{
+ new Content(m_currentStorage);
}
/*
void consoleUpdateSlotsScan();
void consoleRelease();
void statusStorageWindow();
+ void contentWindow();
private:
void createContextMenu();