]> git.sur5r.net Git - bacula/bacula/commitdiff
continue storage content panel
authorEric Bollengier <eric@eb.homelinux.org>
Sun, 9 Aug 2009 20:11:05 +0000 (22:11 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Sun, 9 Aug 2009 20:11:05 +0000 (22:11 +0200)
bacula/src/dird/ua_label.c
bacula/src/qt-console/bat.pro.in
bacula/src/qt-console/storage/content.cpp [new file with mode: 0644]
bacula/src/qt-console/storage/content.h [new file with mode: 0644]
bacula/src/qt-console/storage/content.ui
bacula/src/qt-console/storage/storage.cpp
bacula/src/qt-console/storage/storage.h

index b464be19c986d2431d10cf76f4aae26ef0e96d96..50b8b4ac1fe62492d13f3097c03525012ad34f4e 100644 (file)
@@ -1026,13 +1026,14 @@ void status_slots(UAContext *ua, STORE *store_r)
    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)) {
@@ -1124,16 +1125,23 @@ void status_slots(UAContext *ua, STORE *store_r)
                          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);
    }
index 45b4d555057b32bf902b0f9a9e644263d8a81578..7e3b8ebacf3e017e53c420d45cd8e42585a6d13c 100644 (file)
@@ -52,7 +52,7 @@ FORMS += medialist/medialist.ui mediaedit/mediaedit.ui joblist/joblist.ui
 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 {
@@ -115,6 +115,10 @@ SOURCES += clients/clients.cpp
 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
diff --git a/bacula/src/qt-console/storage/content.cpp b/bacula/src/qt-console/storage/content.cpp
new file mode 100644 (file)
index 0000000..8536556
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+   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;
+
+   populate();
+
+   dockPage();
+   setCurrent();
+}
+
+/*
+ * The main meat of the class!!  The function that querries the director and 
+ * creates the widgets with appropriate values.
+ */
+void Content::populate()
+{
+   m_populated = true;
+   m_firstpopulation = false;
+   Freeze frz(*tableContent); /* disable updating*/
+   int row = 0;
+   QStringList results;
+   QString cmd("status slots drive=0 storage=\"" + m_currentStorage + "\"");
+   m_console->dir_cmd(cmd, results);
+   foreach (QString resultline, results){
+      Pmsg1(0, "s=%s\n", resultline.toUtf8().data());
+      QStringList fieldlist = resultline.split("|");
+      QStringListIterator fld(fieldlist);
+      if (fieldlist.size() < 9)
+         continue; /* some fields missing, ignore row */
+      Pmsg1(0, "s=%s\n", resultline.toUtf8().data());
+      TableItemFormatter jobitem(*tableContent, row);
+      int col=0;
+      jobitem.setNumericFld(col++, fld.next()); 
+      fld.next();
+      jobitem.setTextFld(col++, fld.next());
+      jobitem.setNumericFld(col++, fld.next());
+      jobitem.setVolStatusFld(col++, fld.next());
+      jobitem.setTextFld(col++, fld.next());
+      jobitem.setTextFld(col++, fld.next());
+      jobitem.setTextFld(col++, fld.next());
+      jobitem.setTextFld(col++, fld.next());
+
+      row++;
+   }
+}
+
+/*
+ * Virtual function which is called when this page is visible on the stack
+ */
+void Content::currentStackItem()
+{
+   if(!m_populated) {
+      populate();
+   }
+}
+
+/*
+ *  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);
+   }
+}
diff --git a/bacula/src/qt-console/storage/content.h b/bacula/src/qt-console/storage/content.h
new file mode 100644 (file)
index 0000000..6525427
--- /dev/null
@@ -0,0 +1,67 @@
+#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 populate();
+
+private:
+   bool m_currentAutoChanger;
+   bool m_populated;
+   bool m_firstpopulation;
+   bool m_checkcurwidget;
+   QString m_currentStorage;
+};
+
+#endif /* _STORAGE_H_ */
index 4109b2708e941a52f1e16ef625054a396a28cd97..6793daa6c06205c8a0338c66a96ab2784539b6b2 100644 (file)
 <ui version="4.0" >
- <class>Form</class>
- <widget class="QWidget" name="Form" >
+ <class>ContentForm</class>
+ <widget class="QWidget" name="ContentForm" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>899</width>
-    <height>610</height>
+    <width>851</width>
+    <height>642</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <string>Form</string>
   </property>
-  <widget class="QTableWidget" name="tableContent" >
-   <property name="geometry" >
-    <rect>
-     <x>9</x>
-     <y>308</y>
-     <width>881</width>
-     <height>293</height>
-    </rect>
-   </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>
-  <widget class="QTableWidget" name="tableWidget_2" >
-   <property name="geometry" >
-    <rect>
-     <x>630</x>
-     <y>10</y>
-     <width>211</width>
-     <height>171</height>
-    </rect>
-   </property>
-   <column>
-    <property name="text" >
-     <string>Drive</string>
-    </property>
-   </column>
-   <column>
-    <property name="text" >
-     <string>Volume</string>
-    </property>
-   </column>
-  </widget>
-  <widget class="QPushButton" name="pushButton" >
-   <property name="geometry" >
-    <rect>
-     <x>12</x>
-     <y>12</y>
-     <width>80</width>
-     <height>30</height>
-    </rect>
-   </property>
-   <property name="text" >
-    <string>Update</string>
-   </property>
-  </widget>
-  <widget class="QPushButton" name="pushButton_2" >
-   <property name="geometry" >
-    <rect>
-     <x>102</x>
-     <y>12</y>
-     <width>80</width>
-     <height>30</height>
-    </rect>
-   </property>
-   <property name="text" >
-    <string>Label</string>
-   </property>
-  </widget>
-  <widget class="QPushButton" name="pushButton_3" >
-   <property name="geometry" >
-    <rect>
-     <x>192</x>
-     <y>12</y>
-     <width>89</width>
-     <height>30</height>
-    </rect>
-   </property>
-   <property name="text" >
-    <string>Move to tray</string>
-   </property>
-  </widget>
-  <widget class="QPushButton" name="pushButton_4" >
-   <property name="geometry" >
-    <rect>
-     <x>290</x>
-     <y>10</y>
-     <width>83</width>
-     <height>30</height>
-    </rect>
-   </property>
-   <property name="text" >
-    <string>Empty tray</string>
-   </property>
-  </widget>
+  <layout class="QVBoxLayout" >
+   <item>
+    <layout class="QHBoxLayout" >
+     <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>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>392</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QGroupBox" name="groupBox_3" >
+       <property name="title" >
+        <string>Drives</string>
+       </property>
+       <layout class="QVBoxLayout" >
+        <item>
+         <widget class="QTableWidget" name="tableDrive" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="minimumSize" >
+           <size>
+            <width>220</width>
+            <height>100</height>
+           </size>
+          </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>
+    </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" >
+        <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" />
index 7141787c7942242fb17f66038a6fbee3c610471e..3fce0c04551767ce5881430a1569907c2f6f2fbf 100644 (file)
@@ -39,6 +39,7 @@
 #include <QAbstractEventDispatcher>
 #include <QMenu>
 #include "storage.h"
+#include "content.h"
 #include "label/label.h"
 #include "mount/mount.h"
 #include "status/storstat.h"
@@ -326,6 +327,14 @@ void Storage::createContextMenu()
                 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);
 }
 
 /*
index 8f3f416d5aa9ba423ca0f5751b19b226ac2dc8ae..7facc1ad3e1a825226fb74ac76bafd7f21a87ff8 100644 (file)
@@ -61,6 +61,7 @@ private slots:
    void consoleUpdateSlotsScan();
    void consoleRelease();
    void statusStorageWindow();
+   void contentWindow();
 
 private:
    void createContextMenu();