]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/job/job.cpp
Backport from BEE
[bacula/bacula] / bacula / src / qt-console / job / job.cpp
index 245ed7e72e65ecaa050bfd212c66eaaa6d60d845..ca27d00b053d124bd243628812510f443d7c2d26 100644 (file)
@@ -1,31 +1,19 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
+   Copyright (C) 2007-2014 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 three of the GNU Affero General Public
-   License as published by the Free Software Foundation and included
-   in the file LICENSE.
+   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 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 Affero 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.
+   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.
-   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 "job.h"
 #include "util/fmtwidgetitem.h"
@@ -143,7 +131,7 @@ void Job::populateText()
    if (mainWin->m_sqlDebug) {
       Pmsg1(000, "Log query cmd : %s\n", query.toUtf8().data());
    }
-  
+
    QStringList results;
    if (m_console->sql_cmd(query, results)) {
 
@@ -153,13 +141,13 @@ void Job::populateText()
                "It is possible you may need to add \"catalog = all\" "
                "to the Messages resource for this job.\n"), QMessageBox::Ok);
          return;
-      } 
+      }
 
       QString jobstr("JobId "); /* FIXME: should this be translated ? */
       jobstr += m_jobId;
 
       QString htmlbuf("<html><body><pre>");
-  
+
       /* Iterate through the lines of results. */
       QString field;
       QStringList fieldlist;
@@ -167,7 +155,7 @@ void Job::populateText()
       QString lastSvc;
       foreach (QString resultline, results) {
          fieldlist = resultline.split("\t");
-         
+
          if (fieldlist.size() < 2)
             continue;
 
@@ -176,12 +164,12 @@ void Job::populateText()
          field = fieldlist[1].trimmed();
          int colon = field.indexOf(":");
          if (colon > 0) {
-            /* string is like <service> <jobId xxxx>: ..." 
-             * we split at ':' then remove the jobId xxxx string (always the same) */ 
+            /* string is like <service> <jobId xxxx>: ..."
+             * we split at ':' then remove the jobId xxxx string (always the same) */
             QString curSvc(field.left(colon).replace(jobstr,"").trimmed());
             if (curSvc == lastSvc  && curTime == lastTime) {
                curTime.clear();
-               curSvc.clear(); 
+               curSvc.clear();
             } else {
                lastTime = curTime;
                lastSvc = curSvc;
@@ -208,7 +196,7 @@ void Job::populateText()
 //          htmlbuf += "<td>" + curTime + "</td>";
             htmlbuf += "\n" + field ;
          }
-  
+
       } /* foreach resultline */
 
       htmlbuf += "</pre></body></html>";
@@ -216,11 +204,11 @@ void Job::populateText()
       /* full text ready. Here a custom sheet is used to align columns */
       QString logSheet(".err {color:#FF0000;}");
       textJobLog->document()->setDefaultStyleSheet(logSheet);
-      textJobLog->document()->setHtml(htmlbuf); 
+      textJobLog->document()->setHtml(htmlbuf);
       textJobLog->moveCursor(QTextCursor::Start);
 
    } /* if results from query */
-  
+
 }
 
 
@@ -253,10 +241,10 @@ void Job::updateRunInfo()
    QRegExp oldline("Files=([\\d,]+) Bytes=([\\d,]+) Bytes/sec=([\\d,]+) Errors=([\\d,]+)");
    QString com(",");
    QString empty("");
-   
+
    if (m_console->dir_cmd(cmd, results)) {
       foreach (QString mline, results) {
-         foreach (QString line, mline.split("\n")) { 
+         foreach (QString line, mline.split("\n")) {
             line = line.trimmed();
             if (oldline.indexIn(line) >= 0) {
                if (parseit) {
@@ -277,12 +265,12 @@ void Job::updateRunInfo()
                lst.removeFirst();
 
             } else {
-               if (mainWin->m_miscDebug) 
+               if (mainWin->m_miscDebug)
                   Pmsg1(0, "bad line=%s\n", line.toUtf8().data());
                continue;
             }
             if (lst.count() < 2) {
-               if (mainWin->m_miscDebug) 
+               if (mainWin->m_miscDebug)
                   Pmsg2(0, "bad line=%s count=%d\n", line.toUtf8().data(), lst.count());
             }
             if (lst[0] == "JobId") {
@@ -295,11 +283,11 @@ void Job::updateRunInfo()
             if (!parseit) {
                continue;
             }
-            
+
 //         } else if (lst[0] == "Job") {
 //            grpRun->setTitle(lst[1]);
-            
-//               
+
+//
 //         } else if (lst[0] == "VSS") {
 
 //         } else if (lst[0] == "Level") {
@@ -312,19 +300,19 @@ void Job::updateRunInfo()
 
             if (lst[0] == "Errors") {
                label_JobErrors->setText(lst[1]);
-               
+
             } else if (lst[0] == "Bytes/sec") {
                label_Speed->setText(convertBytesSI(lst[1].toULongLong())+"/s");
-               
+
             } else if (lst[0] == "Files") {
                label_JobFiles->setText(lst[1]);
-               
+
             } else if (lst[0] == "Bytes") {
                label_JobBytes->setText(convertBytesSI(lst[1].toULongLong()));
-               
+
             } else if (lst[0] == "Files Examined") {
                label_FilesExamined->setText(lst[1]);
-               
+
             } else if (lst[0] == "Processing file") {
                label_CurrentFile->setText(lst[1]);
             }
@@ -340,14 +328,14 @@ void Job::populateForm()
 {
    QString stat, err;
    char buf[256];
-   QString query = 
+   QString query =
       "SELECT JobId, Job.Name, Level, Client.Name, Pool.Name, FileSet,"
       "SchedTime, StartTime, EndTime, EndTime-StartTime AS Duration, "
       "JobBytes, JobFiles, JobErrors, JobStatus, PurgedFiles "
       "FROM Job JOIN Client USING (ClientId) "
         "LEFT JOIN Pool ON (Job.PoolId = Pool.PoolId) "
         "LEFT JOIN FileSet ON (Job.FileSetId = FileSet.FileSetId)"
-      "WHERE JobId=" + m_jobId; 
+      "WHERE JobId=" + m_jobId;
    QStringList results;
    if (m_console->sql_cmd(query, results)) {
       QString resultline, duration;
@@ -358,7 +346,7 @@ void Job::populateForm()
          QStringListIterator fld(fieldlist);
          label_JobId->setText(fld.next());
          label_Name->setText(fld.next());
-         
+
          label_Level->setText(job_level_to_str(fld.next()[0].toAscii()));
 
          m_client = fld.next();
@@ -369,9 +357,9 @@ void Job::populateForm()
          label_StartTime->setText(fld.next());
          label_EndTime->setText(fld.next());
          duration = fld.next();
-         /* 
+         /*
           * Note: if we have a negative duration, it is because the EndTime
-          *  is zero (i.e. the Job is still running).  We should use 
+          *  is zero (i.e. the Job is still running).  We should use
           *  duration = StartTime - current_time
           */
          if (duration.left(1) == "-") {
@@ -417,16 +405,16 @@ void Job::populateForm()
       }
    }
 }
-  
+
 void Job::populateVolumes()
 {
 
-   QString query = 
+   QString query =
       "SELECT DISTINCT VolumeName, InChanger, Slot "
       "FROM Job JOIN JobMedia USING (JobId) JOIN Media USING (MediaId) "
-      "WHERE JobId=" + m_jobId + " ORDER BY VolumeName "; 
+      "WHERE JobId=" + m_jobId + " ORDER BY VolumeName ";
    if (mainWin->m_sqlDebug) Pmsg1(0, "Query cmd : %s\n",query.toUtf8().data());
-         
+
 
    QStringList results;
    if (m_console->sql_cmd(query, results)) {
@@ -436,7 +424,7 @@ void Job::populateVolumes()
       foreach (resultline, results) { // should have only one result
          fieldlist = resultline.split("\t");
          QStringListIterator fld(fieldlist);
-//         QListWidgetItem(QIcon(":/images/inchanger" + fld.next() + ".png"), 
+//         QListWidgetItem(QIcon(":/images/inchanger" + fld.next() + ".png"),
 //                         fld.next(), list_Volume);
          list_Volume->addItem(fld.next());
       }