]> git.sur5r.net Git - bacula/bacula/commitdiff
Make bat run dialog present only allowed levels
authorKern Sibbald <kern@sibbald.com>
Sat, 6 Aug 2011 19:28:09 +0000 (21:28 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:59 +0000 (14:49 +0200)
bacula/src/dird/ua_dotcmds.c
bacula/src/qt-console/run/run.cpp

index 9959298bbc64f61409a9e4ab8099da879d40fece..086409e2f7a65d666deafea08cd058c137f7c557 100644 (file)
@@ -43,6 +43,8 @@
 #include "findlib/find.h"
 
 /* Imported variables */
+extern struct s_jl joblevels[];
+extern struct s_jt jobtypes[];
 
 /* Imported functions */
 extern void do_messages(UAContext *ua, const char *cmd);
@@ -1004,14 +1006,30 @@ static bool locationscmd(UAContext *ua, const char *cmd)
 
 static bool levelscmd(UAContext *ua, const char *cmd)
 {
-   ua->send_msg("Incremental\n");
-   ua->send_msg("Full\n");
-   ua->send_msg("Differential\n");
-   ua->send_msg("VirtualFull\n");
-   ua->send_msg("Catalog\n");
-   ua->send_msg("InitCatalog\n");
-   ua->send_msg("VolumeToCatalog\n");
-   ua->send_msg("Base\n");
+   int i;
+   /* Note some levels are blank, which means none is needed */
+   if (ua->argc == 1) {
+      for (i=0; joblevels[i].level_name; i++) {
+         if (joblevels[i].level_name[0] != ' ') {
+            ua->send_msg("%s\n", joblevels[i].level_name);
+         }
+      }
+   } else if (ua->argc == 2) {
+      int jobtype = 0;
+      /* Assume that first argument is the Job Type */
+      for (i=0; jobtypes[i].type_name; i++) {
+         if (strcasecmp(ua->argk[1], jobtypes[i].type_name) == 0) {
+            jobtype = jobtypes[i].job_type;
+            break;
+         }
+      }
+      for (i=0; joblevels[i].level_name; i++) {
+         if ((joblevels[i].job_type == jobtype) && (joblevels[i].level_name[0] != ' ')) {
+            ua->send_msg("%s\n", joblevels[i].level_name);
+         }
+      }
+   }
+
    return true;
 }
 
index 58f6ec51b8cb9ccb028cdc6c81e99d92f2c0f15e..e586c3d77125f2bac482298676e543c2a0c38061 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
+   Copyright (C) 2007-2011 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.
@@ -177,6 +177,7 @@ void runPage::job_name_change(int index)
    (void)index;
    job_defs.job_name = jobCombo->currentText();
    if (m_console->get_job_defaults(job_defs)) {
+      QString cmd;
       typeLabel->setText("<H3>"+job_defs.type+"</H3>");
       filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
       levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
@@ -184,5 +185,11 @@ void runPage::job_name_change(int index)
       poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
       storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
       messagesCombo->setCurrentIndex(messagesCombo->findText(job_defs.messages_name, Qt::MatchExactly));
+      m_console->level_list.clear();
+      cmd = ".levels " + job_defs.type;
+      m_console->dir_cmd(cmd, m_console->level_list);
+      levelCombo->clear();
+      levelCombo->addItems(m_console->level_list);
+      levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, 0 /*Qt::MatchExactly*/));
    }
 }