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);
bstrncpy(msg, jobstat, maxlen);
}
+/*
+ * 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
*/
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
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);
}
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;
}
}
}
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")));
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")));
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());
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);
}
}
" 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")) {
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");
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());
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;
return toret;
}
-
/*
* dockPage
* This function is intended to be called from within the Pages class to pull
*/
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();
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();
}
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());
+ }
}
}
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) {
{
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());
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;
}
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;
}
{
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());
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;
}
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")));
/* 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);
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);
}
}
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();
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
-
+
/*
* Version $Id$
*
*
* 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"));
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)
}
}
+/* 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) );
+ }
+}
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_ */
#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
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)) {
class QString;
class QBrush;
+
+/*
+ * common conversion routines
+ *
+ */
+QString convertJobStatus(const QString &sts);
+
+
/*
* base class for formatters
*
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);