/*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-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.
 
    bool found, quit;
    JCR *jcr;
    BSOCK *dir = (BSOCK *)dirp;
+   const char jobname[12] = "*Director*";
 
    jcr = new_jcr(sizeof(JCR), filed_free_jcr); /* create JCR */
    jcr->dir_bsock = dir;
    jcr->last_fname[0] = 0;
    jcr->client_name = get_memory(strlen(my_name) + 1);
    pm_strcpy(jcr->client_name, my_name);
+   bstrncpy(jcr->Job, jobname, sizeof(jobname));  /* dummy */
    jcr->crypto.pki_sign = me->pki_sign;
    jcr->crypto.pki_encrypt = me->pki_encrypt;
    jcr->crypto.pki_keypair = me->pki_keypair;
          } else {
             type = M_INFO;
          }
-         Jmsg(jcr, type, 0, _("DIR and FD clocks differ by %d seconds, FD automatically compensating.\n"), adj);
+         Jmsg(jcr, type, 0, _("DIR and FD clocks differ by %lld seconds, FD automatically compensating.\n"), adj);
       }
       dir->signal(BNET_EOD);
 
-      Dmsg2(100, "adj = %d since_time=%lld\n", (int)adj, since_time);
+      Dmsg2(100, "adj=%lld since_time=%lld\n", adj, since_time);
       jcr->incremental = 1;           /* set incremental or decremental backup */
       jcr->mtime = since_time;        /* set since time */
       generate_plugin_event(jcr, bEventSince, (void *)(time_t)jcr->mtime);
 
                 if (jcr && jcr->dir_bsock && !jcr->dir_bsock->errors) {
                    bnet_fsend(jcr->dir_bsock, "Jmsg Job=%s type=%d level=%lld %s",
                       jcr->Job, type, mtime, msg);
+                } else {
+                   Dmsg1(000, "no jcr for following msg: %s", msg);
                 }
                 break;
              case MD_STDOUT:
 
    }
 
    /* Timeout Hello after 15 secs */
-// Temp turn this off until we workout how to make sigusr2 work with Qt
-//   dir->start_timer(15);
+   dir->start_timer(15);
    dir->fsend(hello, bashed_name);
 
    /* respond to Dir challenge */
 
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
+   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.
          foreach (QString resultline, results) {
             QStringList fieldlist = resultline.split("\t");
 
-           TableItemFormatter item(*tableWidget, row);
+            TableItemFormatter item(*tableWidget, row);
 
-           /* Iterate through fields in the record */
-           QStringListIterator fld(fieldlist);
-           int col = 0;
+            /* Iterate through fields in the record */
+            QStringListIterator fld(fieldlist);
+            int col = 0;
 
-           /* name */
-           item.setTextFld(col++, fld.next());
+            /* name */
+            item.setTextFld(col++, fld.next());
 
-           /* file retention */
-           item.setDurationFld(col++, fld.next());
+            /* file retention */
+            item.setDurationFld(col++, fld.next());
 
-           /* job retention */
-           item.setDurationFld(col++, fld.next());
+            /* job retention */
+            item.setDurationFld(col++, fld.next());
 
-           /* autoprune */
-           item.setBoolFld(col++, fld.next());
+            /* autoprune */
+            item.setBoolFld(col++, fld.next());
 
-           /* client id */
-           item.setNumericFld(col++, fld.next());
+            /* client id */
+            item.setNumericFld(col++, fld.next());
 
-           /* uname */
-           item.setTextFld(col++, fld.next());
+            /* uname */
+            item.setTextFld(col++, fld.next());
 
             row++;
          }
    for(int r=0; r < rcnt; r++) {
       for(int c=0; c < ccnt; c++) {
          QTableWidgetItem* item = tableWidget->item(r, c);
-         item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
+         if (item) {
+            item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
+         }
       }
    }
 }
 " you are doing.\n\n"
 " Is there any way I can get you to click Cancel here?  You really don't want to do"
 " this\n\n"
-        "Press OK to proceed with the purge operation?").arg(m_currentlyselected),
-        QMessageBox::Ok | QMessageBox::Cancel,
-        QMessageBox::Cancel)
+         "Press OK to proceed with the purge operation?").arg(m_currentlyselected),
+         QMessageBox::Ok | QMessageBox::Cancel,
+         QMessageBox::Cancel)
       == QMessageBox::Cancel) { return; }
 
    QString cmd("purge jobs client=");
    QTreeWidgetItem *parentItem = mainWin->getFromHash(this);
    new ClientStat(m_currentlyselected, parentItem);
 }
-
 
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
+   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.
          foreach (QString resultline, results) {
             fieldlist = resultline.split("\t");
 
-           TableItemFormatter item(*tableWidget, row);
+            TableItemFormatter item(*tableWidget, row);
   
-           /* Iterate through fields in the record */
-           QStringListIterator fld(fieldlist);
-           int col = 0;
+            /* Iterate through fields in the record */
+            QStringListIterator fld(fieldlist);
+            int col = 0;
 
-           /* name */
-           item.setTextFld(col++, fld.next());
+            /* name */
+            item.setTextFld(col++, fld.next());
 
-           /* id */
-           item.setNumericFld(col++, fld.next());
+            /* id */
+            item.setNumericFld(col++, fld.next());
 
-           /* creation time */
-           item.setTextFld(col++, fld.next());
+            /* creation time */
+            item.setTextFld(col++, fld.next());
 
             row++;
          }
    for(int r=0; r < rcnt; r++) {
       for(int c=0; c < ccnt; c++) {
          QTableWidgetItem* item = tableWidget->item(r, c);
-         item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
+         if (item) {
+            item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
+         }
       }
    }
 }
 
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
+   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.
       foreach (resultline, results) {
          fieldlist = resultline.split("\t");
          if (fieldlist.size() < 12)
-           continue; /* some fields missing, ignore row */
+            continue; /* some fields missing, ignore row */
 
-        TableItemFormatter jobitem(*mp_tableWidget, row);
+         TableItemFormatter jobitem(*mp_tableWidget, row);
   
          /* Iterate through fields in the record */
-        QStringListIterator fld(fieldlist);
+         QStringListIterator fld(fieldlist);
          int col = 0;
 
-        /* job id */
+         /* job id */
          jobitem.setNumericFld(col++, fld.next());
 
-        /* job name */
+         /* job name */
          jobitem.setTextFld(col++, fld.next());
 
-        /* client */
+         /* client */
          jobitem.setTextFld(col++, fld.next());
 
-        /* job starttime */
+         /* job starttime */
          jobitem.setTextFld(col++, fld.next(), true);
 
-        /* job type */
+         /* job type */
          jobitem.setJobTypeFld(col++, fld.next());
 
-        /* job level */
+         /* job level */
          jobitem.setJobLevelFld(col++, fld.next());
 
-        /* job files */
+         /* job files */
          jobitem.setNumericFld(col++, fld.next());
 
-        /* job bytes */
+         /* job bytes */
          jobitem.setBytesFld(col++, fld.next());
 
-        /* job status */
+         /* job status */
          jobitem.setJobStatusFld(col++, fld.next());
 
-        /* purged */
-        jobitem.setBoolFld(col++, fld.next());
+         /* purged */
+         jobitem.setBoolFld(col++, fld.next());
 
-        /* fileset */
+         /* fileset */
          jobitem.setTextFld(col++, fld.next());
 
          row++;
    for(int r=0; r < rcnt; r++) {
       for(int c=0; c < ccnt; c++) {
          QTableWidgetItem* item = mp_tableWidget->item(r, c);
-         item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
+         if (item) {
+            item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
+         }
       }
    }
 }
 
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
+   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.
       job_defaults job_defs;
       job_defs.job_name = jobName;
       if (m_console->get_job_defaults(job_defs)) {
-        int col = 0;
-        TableItemFormatter jobsItem(*tableWidget, row);
-        jobsItem.setTextFld(col++, jobName); 
-        jobsItem.setTextFld(col++, job_defs.pool_name);
-        jobsItem.setTextFld(col++, job_defs.messages_name);
-        jobsItem.setTextFld(col++, job_defs.client_name);
-        jobsItem.setTextFld(col++, job_defs.store_name);
-        jobsItem.setTextFld(col++, job_defs.level);
-        jobsItem.setTextFld(col++, job_defs.type);
-        jobsItem.setTextFld(col++, job_defs.fileset_name);
-        jobsItem.setTextFld(col++, job_defs.catalog_name);
-        jobsItem.setBoolFld(col++, job_defs.enabled);
-        jobsItem.setTextFld(col++, job_defs.where);
+         int col = 0;
+         TableItemFormatter jobsItem(*tableWidget, row);
+         jobsItem.setTextFld(col++, jobName); 
+         jobsItem.setTextFld(col++, job_defs.pool_name);
+         jobsItem.setTextFld(col++, job_defs.messages_name);
+         jobsItem.setTextFld(col++, job_defs.client_name);
+         jobsItem.setTextFld(col++, job_defs.store_name);
+         jobsItem.setTextFld(col++, job_defs.level);
+         jobsItem.setTextFld(col++, job_defs.type);
+         jobsItem.setTextFld(col++, job_defs.fileset_name);
+         jobsItem.setTextFld(col++, job_defs.catalog_name);
+         jobsItem.setBoolFld(col++, job_defs.enabled);
+         jobsItem.setTextFld(col++, job_defs.where);
 
       }
       row++;
    for(int r=0; r < rcnt; r++) {
       for(int c=0; c < ccnt; c++) {
          QTableWidgetItem* item = tableWidget->item(r, c);
-         item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
+         if (item) {
+            item->setFlags(Qt::ItemFlags(item->flags() & (~Qt::ItemIsEditable)));
+         }
       }
    }
    mainWin->waitExit();
 
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
+   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.