]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/storage/storage.cpp
Backport from Bacula Enterprise
[bacula/bacula] / bacula / src / qt-console / storage / storage.cpp
index da61da696485be8af46714caff3701009ca0d0ac..9f5dc226cbca9009c186b9c08913220dde69bfdc 100644 (file)
@@ -1,26 +1,30 @@
 /*
-   Bacula® - The Network Backup Solution
+   Bacula(R) - The Network Backup Solution
 
+   Copyright (C) 2000-2015 Kern Sibbald
    Copyright (C) 2007-2010 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.
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
 
    You may use this file and others of this release according to the
    license defined in the LICENSE file, which includes the Affero General
    Public License, v3.0 ("AGPLv3") and some additional permissions and
    terms pursuant to its AGPLv3 Section 7.
 
-   Bacula® is a registered trademark of Kern Sibbald.
-*/
+   This notice must be preserved when any source code is 
+   conveyed and/or propagated.
 
+   Bacula(R) is a registered trademark of Kern Sibbald.
+*/
 /*
  *
  *  Storage Class
  *
  *   Dirk Bartley, March 2007
  *
- */
+ */ 
 
 #include "bat.h"
 #include <QAbstractEventDispatcher>
@@ -57,7 +61,7 @@ Storage::~Storage()
 }
 
 /*
- * The main meat of the class!!  The function that querries the director and
+ * The main meat of the class!!  The function that querries the director and 
  * creates the widgets with appropriate values.
  */
 void Storage::populateTree()
@@ -73,7 +77,7 @@ void Storage::populateTree()
    m_checkcurwidget = true;
 
    QStringList headerlist = (QStringList() << tr("Name") << tr("Id")
-        << tr("Changer") << tr("Slot") << tr("Status") << tr("Enabled") << tr("Pool")
+        << tr("Changer") << tr("Slot") << tr("Status") << tr("Enabled") << tr("Pool") 
         << tr("Media Type") );
 
    m_topItem = new QTreeWidgetItem(mp_treeWidget);
@@ -119,6 +123,10 @@ void Storage::populateTree()
          QStringList fieldlist;
          foreach (QString resultline, results) {
             fieldlist = resultline.split("\t");
+            if (fieldlist.size() != 3) {
+               Pmsg1(000, "Unexpected line %s", resultline.toUtf8().data());
+               continue;
+            }
             storageName = fieldlist.takeFirst();
             if (m_firstpopulation) {
                settingsOpenStatus(storageName);
@@ -132,9 +140,9 @@ void Storage::populateTree()
 
             int index = 1;
             QStringListIterator fld(fieldlist);
-
             /* storage id */
-            storageItem.setNumericFld(index++, fld.next());
+            storageItem.setNumericFld(index++, fld.next() );
 
             /* changer */
             QString changer = fld.next();
@@ -159,7 +167,7 @@ void Storage::mediaList(QTreeWidgetItem *parent, const QString &storageID)
 {
    QString query("SELECT Media.VolumeName AS Media, Media.Slot AS Slot,"
                  " Media.VolStatus AS VolStatus, Media.Enabled AS Enabled,"
-                 " Pool.Name AS MediaPool, Media.MediaType AS MediaType"
+                 " Pool.Name AS MediaPool, Media.MediaType AS MediaType" 
                  " From Media"
                  " JOIN Pool ON (Media.PoolId=Pool.PoolId)"
                  " WHERE Media.StorageId='" + storageID + "'"
@@ -175,11 +183,11 @@ void Storage::mediaList(QTreeWidgetItem *parent, const QString &storageID)
       QString resultline;
       QString field;
       QStringList fieldlist;
-
       foreach (resultline, results) {
          fieldlist = resultline.split("\t");
          if (fieldlist.size() < 6)
-             continue;
+             continue; 
 
          /* Iterate through fields in the record */
          QStringListIterator fld(fieldlist);
@@ -187,8 +195,8 @@ void Storage::mediaList(QTreeWidgetItem *parent, const QString &storageID)
          TreeItemFormatter fmt(*parent, 2);
 
          /* volname */
-         fmt.setTextFld(index++, fld.next());
-
+         fmt.setTextFld(index++, fld.next()); 
          /* skip the next two columns, unused by media */
          index += 2;
 
@@ -199,13 +207,13 @@ void Storage::mediaList(QTreeWidgetItem *parent, const QString &storageID)
          fmt.setVolStatusFld(index++, fld.next());
 
          /* enabled */
-         fmt.setBoolFld(index++, fld.next());
+         fmt.setBoolFld(index++, fld.next()); 
 
          /* pool */
-         fmt.setTextFld(index++, fld.next());
+         fmt.setTextFld(index++, fld.next()); 
 
          /* media type */
-         fmt.setTextFld(index++, fld.next());
+         fmt.setTextFld(index++, fld.next()); 
 
       }
    }
@@ -285,8 +293,8 @@ void Storage::treeItemChanged(QTreeWidgetItem *currentwidgetitem, QTreeWidgetIte
    }
 }
 
-/*
- * Setup a context menu
+/* 
+ * Setup a context menu 
  * Made separate from populate so that it would not create context menu over and
  * over as the tree is repopulated.
  */
@@ -323,7 +331,7 @@ void Storage::createContextMenu()
 
 void Storage::contentWindow()
 {
-   if (m_currentStorage != "" && m_currentAutoChanger) {
+   if (m_currentStorage != "" && m_currentAutoChanger) { 
       QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
       new Content(m_currentStorage, parentItem);
    }