From 7a2bceee16a085f3b7031185108c75159f3d03e5 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 6 Aug 2011 21:28:09 +0200 Subject: [PATCH] Make bat run dialog present only allowed levels --- bacula/src/dird/ua_dotcmds.c | 34 +++++++++++++++++++++++-------- bacula/src/qt-console/run/run.cpp | 9 +++++++- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index 9959298bbc..086409e2f7 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -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; } diff --git a/bacula/src/qt-console/run/run.cpp b/bacula/src/qt-console/run/run.cpp index 58f6ec51b8..e586c3d771 100644 --- a/bacula/src/qt-console/run/run.cpp +++ b/bacula/src/qt-console/run/run.cpp @@ -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("

"+job_defs.type+"

"); 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*/)); } } -- 2.39.5