[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bacula-devel] patch: bat small tweak and fixes plus translation changes


Hello all,
this patch makes some changes to bat:
- fixes the storage popup menu, broken for autochangers by a previous
(mine) translation patch
- fixes some ambiguous if/else
- tweaks the buffered displayToPrompt() to discharge after a few ticks.
This makes the display more responsive when reporting in progress
operations (e.g. sd tape mount/umount/scan).
- small refactoring for pages
- many translation changes, including two new library functions to aggregate job and volume status translations. The job status translation is an brutal hack, but is the least invasive change I found. Having a single job status translation function instead of three would be much better.
With this patch bat should be almost completely translatable.

Ciao,
Riccardo

Index: bacula/src/qt-console/pages.cpp
===================================================================
--- bacula/src/qt-console/pages.cpp	(revision 7187)
+++ bacula/src/qt-console/pages.cpp	(working copy)
@@ -50,7 +50,6 @@
    return toret;
 }
 
-
 /*
  * dockPage
  * This function is intended to be called from within the Pages class to pull
@@ -187,11 +186,19 @@
  */
 void Pages::pgInitialize()
 {
-   pgInitialize(NULL);
+   pgInitialize(QString(), NULL);
 }
 
-void Pages::pgInitialize(QTreeWidgetItem *parentTreeWidgetItem)
+void Pages::pgInitialize(const QString &name)
 {
+   pgInitialize(name, NULL);
+}
+
+void Pages::pgInitialize(const QString &tname, QTreeWidgetItem *parentTreeWidgetItem)
+{
+   if (tname.size()) {
+      m_name = tname;
+   }
    m_parent = mainWin->stackedWidget;
    m_console = mainWin->currentConsole();
 
Index: bacula/src/qt-console/status/storstat.cpp
===================================================================
--- bacula/src/qt-console/status/storstat.cpp	(revision 7187)
+++ bacula/src/qt-console/status/storstat.cpp	(working copy)
@@ -58,9 +58,8 @@
 {
    m_storage = storage;
    setupUi(this);
-   m_name = tr("Storage Status %1").arg(m_storage);
    m_closeable = true;
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize(tr("Storage Status %1").arg(m_storage), parentTreeWidgetItem);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/status.png")));
    m_cursor = new QTextCursor(textEditHeader->document());
@@ -259,11 +258,12 @@
             p_tableitem->setFlags(0);
             if (flaglist[column].contains("R"))
                p_tableitem->setTextAlignment(Qt::AlignRight);
-            if (flaglist[column].contains("C"))
+            if (flaglist[column].contains("C")) {
                if (field == "OK")
                   p_tableitem->setBackground(Qt::green);
                else
                   p_tableitem->setBackground(Qt::red);
+	    }
             terminatedTable->setItem(row, column, p_tableitem);
             column += 1;
          }
Index: bacula/src/qt-console/status/clientstat.cpp
===================================================================
--- bacula/src/qt-console/status/clientstat.cpp	(revision 7187)
+++ bacula/src/qt-console/status/clientstat.cpp	(working copy)
@@ -43,9 +43,8 @@
 {
    m_client = client;
    setupUi(this);
-   m_name = tr("Client Status %1").arg(m_client);
    m_closeable = true;
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize(tr("Client Status %1").arg(m_client), parentTreeWidgetItem);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/status.png")));
    m_cursor = new QTextCursor(textEditHeader->document());
@@ -166,11 +165,12 @@
             p_tableitem->setFlags(0);
             if (flaglist[column].contains("R"))
                p_tableitem->setTextAlignment(Qt::AlignRight);
-            if (flaglist[column].contains("C"))
+            if (flaglist[column].contains("C")) {
                if (field == "OK")
                   p_tableitem->setBackground(Qt::green);
                else
-                  p_tableitem->setBackground(Qt::red);
+		 p_tableitem->setBackground(Qt::red);
+	    }
             terminatedTable->setItem(results.size() - row - 1, column, p_tableitem);
             column += 1;
          }
Index: bacula/src/qt-console/status/dirstat.cpp
===================================================================
--- bacula/src/qt-console/status/dirstat.cpp	(revision 7187)
+++ bacula/src/qt-console/status/dirstat.cpp	(working copy)
@@ -166,11 +166,12 @@
             p_tableitem->setFlags(0);
             if (flaglist[column].contains("R"))
                p_tableitem->setTextAlignment(Qt::AlignRight);
-            if (flaglist[column].contains("C"))
+            if (flaglist[column].contains("C")) {
                if (field == "OK")
                   p_tableitem->setBackground(Qt::green);
                else
                   p_tableitem->setBackground(Qt::red);
+	    }
             terminatedTable->setItem(results.size() - row - 1, column, p_tableitem);
             column += 1;
          }
Index: bacula/src/qt-console/bcomm/dircomm.cpp
===================================================================
--- bacula/src/qt-console/bcomm/dircomm.cpp	(revision 7187)
+++ bacula/src/qt-console/bcomm/dircomm.cpp	(working copy)
@@ -337,12 +337,19 @@
 void DirComm::displayToPrompt()
 { 
    int stat = 0;
+   QString buf;
    if (mainWin->m_commDebug) Pmsg0(000, "DisplaytoPrompt\n");
    while (!m_at_prompt) {
       if ((stat=read()) > 0) {
-         m_console->display_text(msg());
+	buf += msg();
+	if (buf.size() >= 8196 || m_messages_pending) {
+	   m_console->display_text(buf);
+	   buf.clear();
+	   m_messages_pending = false;
+	}
       }
    }
+   m_console->display_text(buf);
    if (mainWin->m_commDebug) Pmsg1(000, "endDisplaytoPrompt=%d\n", stat);
 }
 
Index: bacula/src/qt-console/storage/storage.cpp
===================================================================
--- bacula/src/qt-console/storage/storage.cpp	(revision 7187)
+++ bacula/src/qt-console/storage/storage.cpp	(working copy)
@@ -47,8 +47,7 @@
 Storage::Storage()
 {
    setupUi(this);
-   m_name = tr("Storage");
-   pgInitialize();
+   pgInitialize(tr("Storage"));
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/package-x-generic.png")));
 
@@ -245,7 +244,7 @@
          /* set a hold variable to the storage name in case the context sensitive
           * menu is used */
          m_currentStorage = currentwidgetitem->text(0);
-         m_currentAutoChanger = currentwidgetitem->text(2).toInt();
+         m_currentAutoChanger = currentwidgetitem->text(2) == tr("Yes");
          mp_treeWidget->addAction(actionStatusStorageInConsole);
          mp_treeWidget->addAction(actionStatusStorageWindow);
          mp_treeWidget->addAction(actionLabelStorage);
@@ -253,24 +252,23 @@
          mp_treeWidget->addAction(actionUnMountStorage);
          mp_treeWidget->addAction(actionRelease);
          QString text;
-         text = "Status Storage \"" + m_currentStorage + "\"";
+         text = tr("Status Storage \"%1\"").arg(m_currentStorage);;
          actionStatusStorageInConsole->setText(text);
-         text = "Status Storage \"" + m_currentStorage + "\" in Window";
+         text = tr("Status Storage \"%1\" in Window").arg(m_currentStorage);;
          actionStatusStorageWindow->setText(text);
-         text = "Label media in Storage \"" + m_currentStorage + "\"";
+         text = tr("Label media in Storage \"%1\"").arg(m_currentStorage);
          actionLabelStorage->setText(text);
-         text = "Mount media in Storage \"" + m_currentStorage + "\"";
+         text = tr("Mount media in Storage \"%1\"").arg(m_currentStorage);
          actionMountStorage->setText(text);
-         text = "\"UN\" Mount media in Storage \"" + m_currentStorage + "\"";
-         actionUnMountStorage->setText(text);
-         text = "Release media in Storage \"" + m_currentStorage + "\"";
+         text = tr("\"UN\" Mount media in Storage \"%1\"").arg(m_currentStorage);
+         text = tr("Release media in Storage \"%1\"").arg(m_currentStorage);
          actionRelease->setText(text);
-         if (m_currentAutoChanger != 0) {
+         if (m_currentAutoChanger) {
             mp_treeWidget->addAction(actionUpdateSlots);
             mp_treeWidget->addAction(actionUpdateSlotsScan);
-            text = "Barcode Scan media in Storage \"" + m_currentStorage + "\"";
+            text = tr("Barcode Scan media in Storage \"%1\"").arg(m_currentStorage);
             actionUpdateSlots->setText(text);
-            text = "Mount and read scan media in Storage \"" + m_currentStorage + "\"";
+            text = tr("Read scan media in Storage \"%1\"").arg( m_currentStorage);
             actionUpdateSlotsScan->setText(text);
          }
       }
Index: bacula/src/qt-console/storage/storage.h
===================================================================
--- bacula/src/qt-console/storage/storage.h	(revision 7187)
+++ bacula/src/qt-console/storage/storage.h	(working copy)
@@ -66,7 +66,7 @@
    void createContextMenu();
    void mediaList(QTreeWidgetItem *parent, const QString &storageID);
    QString m_currentStorage;
-   int m_currentAutoChanger;
+   bool m_currentAutoChanger;
    bool m_populated;
    bool m_checkcurwidget;
    void writeExpandedSettings();
Index: bacula/src/qt-console/joblog/joblog.cpp
===================================================================
--- bacula/src/qt-console/joblog/joblog.cpp	(revision 7187)
+++ bacula/src/qt-console/joblog/joblog.cpp	(working copy)
@@ -41,9 +41,8 @@
 JobLog::JobLog(QString &jobId, QTreeWidgetItem *parentTreeWidgetItem)
 {
    setupUi(this);
-   m_name = tr("JobLog");
    m_closeable = true;
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize(tr("JobLog"), parentTreeWidgetItem);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/joblog.png")));
    m_cursor = new QTextCursor(textEdit->document());
Index: bacula/src/qt-console/jobgraphs/jobplot.cpp
===================================================================
--- bacula/src/qt-console/jobgraphs/jobplot.cpp	(revision 7187)
+++ bacula/src/qt-console/jobgraphs/jobplot.cpp	(working copy)
@@ -77,8 +77,7 @@
 JobPlot::JobPlot(QTreeWidgetItem *parentTreeWidgetItem, JobPlotPass &passVals)
 {
    setupUserInterface();
-   m_name = tr("JobPlot");
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize(tr("JobPlot"), parentTreeWidgetItem);
    readSplitterSettings();
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/applications-graphics.png")));
Index: bacula/src/qt-console/restore/restoretree.cpp
===================================================================
--- bacula/src/qt-console/restore/restoretree.cpp	(revision 7187)
+++ bacula/src/qt-console/restore/restoretree.cpp	(working copy)
@@ -360,12 +360,13 @@
    }
 
    for (int k=0; k<pathAfter.count(); k++) {
-      if (addDirectory(pathAfter[k], dirAfter[k]))
+      if (addDirectory(pathAfter[k], dirAfter[k])) {
          if ((mainWin->m_miscDebug) && (m_debugTrap))
             Pmsg2(000, "Adding After %s %s\n", pathAfter[k].toUtf8().data(), dirAfter[k].toUtf8().data());
-      else
+      } else {
          if ((mainWin->m_miscDebug) && (m_debugTrap))
             Pmsg2(000, "Error Adding %s %s\n", pathAfter[k].toUtf8().data(), dirAfter[k].toUtf8().data());
+      }
    }
 }
 
@@ -1122,7 +1123,7 @@
       m_versionExceptionHash.remove(fullPath);
    } else if (prevState != curState) {
       if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "  THE STATE OF THE version Check has changed, Setting StateList[%i] to %i\n", row, curState);
-      if ((curState == Qt::Checked) || (curState == Qt::PartiallyChecked) && (row != 0)) {
+      if ((curState == Qt::Checked) || (curState == Qt::PartiallyChecked && row != 0)) {
          if (mainWin->m_rtVerTabICDebug) Pmsg2(000, "Inserting into m_versionExceptionHash %s, %i\n", fullPath.toUtf8().data(), thisJobNum);
          m_versionExceptionHash.insert(fullPath, thisJobNum);
          if (fileState != Qt::Checked) {
Index: bacula/src/qt-console/mediaedit/mediaedit.cpp
===================================================================
--- bacula/src/qt-console/mediaedit/mediaedit.cpp	(revision 7187)
+++ bacula/src/qt-console/mediaedit/mediaedit.cpp	(working copy)
@@ -44,8 +44,7 @@
 MediaEdit::MediaEdit(QTreeWidgetItem *parentWidget, QString &mediaId)
 {
    setupUi(this);
-   m_name = tr("Media Edit");
-   pgInitialize(parentWidget);
+   pgInitialize(tr("Media Edit"), parentWidget);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/cartridge-edit.png")));
    m_closeable = true;
Index: bacula/src/qt-console/pages.h
===================================================================
--- bacula/src/qt-console/pages.h	(revision 7187)
+++ bacula/src/qt-console/pages.h	(working copy)
@@ -79,7 +79,8 @@
 
 protected:
    void pgInitialize();
-   void pgInitialize(QTreeWidgetItem *);
+   void pgInitialize(const QString &);
+   void pgInitialize(const QString &, QTreeWidgetItem *);
    virtual void treeWidgetName(QString &);
    virtual void changeEvent(QEvent *event);
    void setConsoleCurrent();
Index: bacula/src/qt-console/console/console.cpp
===================================================================
--- bacula/src/qt-console/console/console.cpp	(revision 7187)
+++ bacula/src/qt-console/console/console.cpp	(working copy)
@@ -590,9 +590,10 @@
    while (!m_at_prompt) {
       if ((stat=read()) > 0) {
 	buf += msg();
-	if (buf.size() >= 8196) {
+	if (buf.size() >= 8196 || m_messages_pending) {
 	   display_text(buf);
 	   buf.clear();
+	   m_messages_pending = false;
 	}
       }
    }
Index: bacula/src/qt-console/joblist/joblist.cpp
===================================================================
--- bacula/src/qt-console/joblist/joblist.cpp	(revision 7187)
+++ bacula/src/qt-console/joblist/joblist.cpp	(working copy)
@@ -56,7 +56,7 @@
    m_jobName = jobName;
    m_filesetName = filesetName;
    m_filesetName = filesetName;
-   pgInitialize(parentTreeWidgetItem);
+   pgInitialize("", parentTreeWidgetItem);
    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/emblem-system.png")));
 
@@ -192,9 +192,7 @@
          jobitem.setBytesFld(col++, fld.next());
 
 	 /* job status */
-	 QString shortstatus(fld.next());
-	 QString longstatus(fld.next());
-         jobitem.setJobStatusFld(col++, shortstatus, longstatus);
+         jobitem.setJobStatusFld(col++, fld.next());
 
 	 /* purged */
 	 jobitem.setBoolFld(col++, fld.next());
@@ -247,10 +245,7 @@
       fileSetComboBox->addItems(m_console->fileset_list);
       comboSel(fileSetComboBox, m_filesetName);
 
-      QStringList statusLongList;
-      m_console->getStatusList(statusLongList);
-      statusComboBox->addItem(tr("Any"));
-      statusComboBox->addItems(statusLongList);
+      jobStatusComboFill(statusComboBox);
    }
 }
 
@@ -266,12 +261,10 @@
             " Client.Name AS Client,"
             " Job.Starttime AS JobStart, Job.Type AS JobType,"
             " Job.Level AS BackupLevel, Job.Jobfiles AS FileCount,"
-            " Job.JobBytes AS Bytes,"
-            " Job.JobStatus AS Status, Status.JobStatusLong AS StatusLong,"
+            " Job.JobBytes AS Bytes, Job.JobStatus AS Status,"
             " Job.PurgedFiles AS Purged, FileSet.FileSet"
             " FROM Job"
             " JOIN Client ON (Client.ClientId=Job.ClientId)"
-            " JOIN Status ON (Job.JobStatus=Status.JobStatus)"
             " LEFT OUTER JOIN FileSet ON (FileSet.FileSetId=Job.FileSetId) ";
    QStringList conditions;
    if (m_mediaName != tr("Any")) {
@@ -283,7 +276,7 @@
    comboCond(conditions, clientComboBox, "Client.Name");
    comboCond(conditions, jobComboBox, "Job.Name");
    levelComboCond(conditions, levelComboBox, "Job.Level");
-   comboCond(conditions, statusComboBox, "Status.JobStatusLong");
+   jobStatusComboCond(conditions, statusComboBox, "Job.JobStatus");
    boolComboCond(conditions, purgedComboBox, "Job.PurgedFiles");
    comboCond(conditions, fileSetComboBox, "FileSet.FileSet");
 
Index: bacula/src/qt-console/util/fmtwidgetitem.h
===================================================================
--- bacula/src/qt-console/util/fmtwidgetitem.h	(revision 7187)
+++ bacula/src/qt-console/util/fmtwidgetitem.h	(working copy)
@@ -39,7 +39,15 @@
 class QString;
 class QBrush;
 
+
 /*
+ * common conversion routines
+ *
+ */
+QString convertJobStatus(const QString &sts);
+
+
+/*
  * base class for formatters
  *
  */
@@ -79,8 +87,7 @@
    void setVolStatusFld(int index, const QString &fld, bool center = true);
   
    /* fld value interpreted as job status. Colored accordingly */
-   void setJobStatusFld(int index, const QString &shortStatus, const QString &longstatus, 
-			bool center = true);
+   void setJobStatusFld(int index, const QString &status, bool center = true);
   
    /* fld value interpreted as job type. */
    void setJobTypeFld(int index, const QString &fld, bool center = false);
Index: bacula/src/qt-console/util/comboutil.h
===================================================================
--- bacula/src/qt-console/util/comboutil.h	(revision 7187)
+++ bacula/src/qt-console/util/comboutil.h	(working copy)
@@ -59,4 +59,8 @@
 void levelComboFill(QComboBox *combo);
 void levelComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname);
 
+/* job status combo */
+void jobStatusComboFill(QComboBox *combo);
+void jobStatusComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname);
+
 #endif /* _COMBOUTIL_H_ */
Index: bacula/src/qt-console/util/fmtwidgetitem.cpp
===================================================================
--- bacula/src/qt-console/util/fmtwidgetitem.cpp	(revision 7187)
+++ bacula/src/qt-console/util/fmtwidgetitem.cpp	(working copy)
@@ -42,11 +42,29 @@
 #include <QString>
 #include <QStringList>
 #include <math.h>
-#include "bacula.h"
+#include "bat.h"
 #include "fmtwidgetitem.h"
 
 /***********************************************
  *
+ * common helpers
+ *
+ ***********************************************/
+
+QString convertJobStatus(const QString &sts)
+{
+   QString code( sts.trimmed() );
+   if ( code.size() != 1) {
+      return QObject::tr("Invalid job status %1").arg(sts);
+   }
+
+   char buf[256];
+   jobstatus_to_ascii_gui( code[0].toAscii(), buf, sizeof(buf));
+   return QString(buf);
+}
+
+/***********************************************
+ *
  * ItemFormatterBase static members
  *
  ***********************************************/
@@ -263,28 +281,30 @@
 
 void ItemFormatterBase::setVolStatusFld(int index, const QString &fld, bool center)
 {
-   setTextFld(index, fld, center);
+  QString mp(fld.trimmed());
+   setTextFld(index, volume_status_to_str(mp.toUtf8()), center);
 
-   if (fld == "Append" ) {
+   if (mp == "Append" ) {
       setBackground(index, Qt::green);
-   } else if (fld == "Error") {
+   } else if (mp == "Error") {
       setBackground(index, Qt::red);
-   } else if (fld == "Used" || fld == "Full"){
+   } else if (mp == "Used" || mp == "Full"){
       setBackground(index, Qt::yellow);
+   } else if (mp == "Read-only" || mp == "Disabled"){
+      setBackground(index, Qt::lightGray);
    }
 }
 
-void ItemFormatterBase::setJobStatusFld(int index, const QString &shortstatus, 
-					const QString &longstatus, bool center)
+void ItemFormatterBase::setJobStatusFld(int index, const QString &status, bool center)
 {
    /* C (created, not yet running) uses the default background */
    static QString greenchars("TR");
    static QString redchars("BEf");
    static QString yellowchars("eDAFSMmsjdctp");
 
-   setTextFld(index, longstatus, center);
+   setTextFld(index, convertJobStatus(status), center);
 
-   QString st(shortstatus.trimmed());
+   QString st(status.trimmed());
    if (greenchars.contains(st, Qt::CaseSensitive)) {
       setBackground(index, Qt::green);
    } else if (redchars.contains(st, Qt::CaseSensitive)) {
Index: bacula/src/qt-console/util/comboutil.cpp
===================================================================
--- bacula/src/qt-console/util/comboutil.cpp	(revision 7187)
+++ bacula/src/qt-console/util/comboutil.cpp	(working copy)
@@ -25,7 +25,7 @@
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@xxxxxxxxxxxxxx
 */
- 
+
 /*
  *   Version $Id$
  *
@@ -33,12 +33,13 @@
  *
  *   Riccardo Ghetta, May 2008
  *
- */ 
+ */
 
 #include <QComboBox>
 #include <QString>
 #include <QStringList>
 #include "bat.h"
+#include "fmtwidgetitem.h"
 #include "comboutil.h"
 
 static const QString QS_ANY(QObject::tr("Any"));
@@ -94,7 +95,7 @@
    combo->addItem(job_level_to_str(L_VERIFY_VOLUME_TO_CATALOG), L_VERIFY_VOLUME_TO_CATALOG);
    combo->addItem(job_level_to_str(L_VERIFY_DISK_TO_CATALOG), L_VERIFY_DISK_TO_CATALOG);
    combo->addItem(job_level_to_str(L_VERIFY_DATA), L_VERIFY_DATA);
-   /* combo->addItem(job_level_to_str(L_BASE), L_BASE);  base jobs ignored */ 
+   /* combo->addItem(job_level_to_str(L_BASE), L_BASE);  base jobs ignored */
 }
 
 void levelComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
@@ -106,3 +107,48 @@
    }
 }
 
+/* job status combo */
+void jobStatusComboFill(QComboBox *combo)
+{
+   static const char js[] = {
+		      JS_Terminated,
+                      JS_Created,
+		      JS_Running,
+		      JS_Blocked,
+		      JS_ErrorTerminated,
+		      JS_Error,
+		      JS_FatalError,
+		      JS_Differences,
+		      JS_Canceled,
+		      JS_WaitFD,
+		      JS_WaitSD,
+		      JS_WaitMedia,
+		      JS_WaitMount,
+		      JS_WaitStoreRes,
+		      JS_WaitJobRes,
+		      JS_WaitClientRes,
+		      JS_WaitMaxJobs,
+		      JS_WaitStartTime,
+		      JS_WaitPriority,
+		      JS_AttrDespooling,
+		      JS_AttrInserting,
+		      JS_DataDespooling,
+		      JS_DataCommitting,
+		      '\0'};
+
+   int pos;
+
+   combo->addItem(QS_ANY);
+   for (pos = 0 ; js[pos] != '\0' ; ++pos) {
+     combo->addItem(convertJobStatus( QString(js[pos]) ), js[pos]);
+   }
+}
+
+void jobStatusComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
+{
+   int index = combo->currentIndex();
+   if (index != -1 && combo->itemText(index) != QS_ANY ) {
+      QString cnd = combo->itemData(index).toChar();
+      cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
+   }
+}
Index: bacula/src/lib/util.c
===================================================================
--- bacula/src/lib/util.c	(revision 7187)
+++ bacula/src/lib/util.c	(working copy)
@@ -256,6 +256,53 @@
 }
 
 /*
+ * Convert a JobStatus code into a human readable form - gui version
+ */
+void jobstatus_to_ascii_gui(int JobStatus, char *msg, int maxlen)
+{
+   const char *cnv = NULL;
+   switch (JobStatus) {
+   case JS_Terminated:
+      cnv = _("Completed successfully");
+      break;
+   case JS_ErrorTerminated:
+      cnv = _("Terminated with errors");
+      break;
+   case JS_FatalError:
+      cnv = _("Fatal error");
+      break;
+   case JS_Created:
+      cnv = _("Created, not yet running");
+      break;
+   case JS_Canceled:
+      cnv = _("Canceled by user");
+      break;
+   case JS_Differences:
+      cnv = _("Verify found differences");
+      break;
+   case JS_WaitFD:
+      cnv = _("Waiting for File daemon");
+      break;
+   case JS_WaitSD:
+      cnv = _("Waiting for Storage daemon");
+      break;
+   case JS_WaitPriority:
+      cnv = _("Waiting for higher priority jobs");
+      break;
+   case JS_AttrInserting:
+      cnv = _("Batch inserting file records");
+      break;
+   };
+
+   if (cnv) {
+      bstrncpy(msg, cnv, maxlen);
+   } else {
+     jobstatus_to_ascii( JobStatus, msg, maxlen);
+   }
+}
+
+
+/*
  * Convert Job Termination Status into a string
  */
 const char *job_status_to_str(int stat)
@@ -376,7 +423,33 @@
    return str;
 }
 
+const char *volume_status_to_str(const char *status)
+{
+   int pos;
+   const char *vs[] = {
+      NT_("Append"),    _("Append"),
+      NT_("Archive"),   _("Archive"),
+      NT_("Disabled"),  _("Disabled"),
+      NT_("Full"),      _("Full"),
+      NT_("Used"),      _("Used"),
+      NT_("Cleaning"),  _("Cleaning"),
+      NT_("Recycle"),   _("Recycle"),
+      NT_("Read-Only"), _("Read-Only"),
+      NT_("Error"),     _("Error"),
+      NULL,             NULL};
 
+   if (status) {
+     for (pos = 0 ; vs[pos] ; pos += 2) {
+       if ( !strcmp(vs[pos],status) ) {
+	 return vs[pos+1];
+       }
+     }
+   }
+
+   return _("Invalid volume status");
+}
+
+
 /***********************************************************************
  * Encode the mode bits into a 10 character string like LS does
  ***********************************************************************/
Index: bacula/src/lib/protos.h
===================================================================
--- bacula/src/lib/protos.h	(revision 7187)
+++ bacula/src/lib/protos.h	(working copy)
@@ -318,11 +318,13 @@
 char *           encode_mode             (mode_t mode, char *buf);
 int              do_shell_expansion      (char *name, int name_len);
 void             jobstatus_to_ascii      (int JobStatus, char *msg, int maxlen);
+void             jobstatus_to_ascii_gui  (int JobStatus, char *msg, int maxlen);
 int              run_program             (char *prog, int wait, POOLMEM *&results);
 int              run_program_full_output (char *prog, int wait, POOLMEM *&results);
 const char *     job_type_to_str         (int type);
 const char *     job_status_to_str       (int stat);
 const char *     job_level_to_str        (int level);
+const char *     volume_status_to_str    (const char *status);
 void             make_session_key        (char *key, char *seed, int mode);
 void             encode_session_key      (char *encode, char *session, char *key, int maxlen);
 void             decode_session_key      (char *decode, char *session, char *key, int maxlen);
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bacula-devel mailing list
Bacula-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/bacula-devel


This mailing list archive is a service of Copilotco.