]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/pythondir.c
Tweak Windows tray monitor build
[bacula/bacula] / bacula / src / dird / pythondir.c
index 241e79a3d3f9a0e30116c928b94fdc66ee4e4c8d..8b383a829b3f5b0f6b5920ea1e11ffafe53affb9 100644 (file)
@@ -6,7 +6,7 @@
    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 two of the GNU General Public
+   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.
 
    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 General Public License
+   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.
 
-   Bacula® is a registered trademark of John Walker.
+   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.
 #undef _POSIX_C_SOURCE
 #include <Python.h>
 
-extern char *configfile;
-extern struct s_jl joblevels[];
-extern JCR *get_jcr_from_PyObject(PyObject *self);
-extern PyObject *find_method(PyObject *eventsObject, PyObject *method, 
-         const char *name);
+#include <lib/pythonlib.h>
 
+extern struct s_jl joblevels[];
 
 static PyObject *set_job_events(PyObject *self, PyObject *arg);
 static PyObject *job_run(PyObject *self, PyObject *arg);
@@ -64,7 +61,6 @@ PyMethodDef JobMethods[] = {
     {NULL, NULL, 0, NULL}             /* last item */
 };
  
-
 struct s_vars {
    const char *name;
    const char *fmt;
@@ -140,9 +136,9 @@ PyObject *job_getattr(PyObject *self, char *attrname)
    case 0:                            /* Job */
       return Py_BuildValue((char *)getvars[i].fmt, jcr->job->hdr.name);
    case 1:                            /* level */
-      return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->JobLevel));
+      return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->getJobLevel()));
    case 2:                            /* type */
-      return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->JobType));
+      return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->getJobType()));
    case 3:                            /* JobId */
       return Py_BuildValue((char *)getvars[i].fmt, jcr->JobId);
    case 4:                            /* Client */
@@ -206,7 +202,7 @@ PyObject *job_getattr(PyObject *self, char *attrname)
       buf[1] = 0;
       buf[0] = jcr->FDJobStatus;
       return Py_BuildValue((char *)getvars[i].fmt, buf);
-   case 29:                           /* SDJobStatus */
+   case 20:                           /* SDJobStatus */
       buf[1] = 0;
       buf[0] = jcr->SDJobStatus;
       return Py_BuildValue((char *)getvars[i].fmt, buf);
@@ -294,12 +290,14 @@ int job_setattr(PyObject *self, char *attrname, PyObject *value)
          PyErr_SetString(PyExc_RuntimeError, _("Job Level can be set only during JobInit"));
          return -1;
       }
-      for (i=0; joblevels[i].level_name; i++) {
-         if (strcmp(strval, joblevels[i].level_name) == 0) {
-            if (joblevels[i].job_type == jcr->JobType) {
-               jcr->JobLevel = joblevels[i].level;
-               jcr->jr.JobLevel = jcr->JobLevel;
-               return 0;
+      if (strval != NULL) {
+         for (i=0; joblevels[i].level_name; i++) {
+            if (strcmp(strval, joblevels[i].level_name) == 0) {
+               if (joblevels[i].job_type == jcr->getJobType()) {
+                  jcr->set_JobLevel(joblevels[i].level);
+                  jcr->jr.JobLevel = jcr->getJobLevel();
+                  return 0;
+               }
             }
          }
       }