X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fdird%2Fua_select.c;h=89b3f178ce6d51dd6c5079906b729acd4c423c50;hb=071c7e2ce332234d5c9c4818ae4ede670bcde8c1;hp=598ec5a630348e0bac474736159cd75fa590faf1;hpb=879b78dfad3000b14b4ab62bc91a187d67a339bd;p=bacula%2Fbacula diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 598ec5a630..89b3f178ce 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2007 Free Software Foundation Europe e.V. + Copyright (C) 2001-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. @@ -20,7 +20,7 @@ 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. @@ -31,7 +31,6 @@ * * Kern Sibbald, October MMI * - * Version $Id$ */ #include "bacula.h" @@ -244,6 +243,33 @@ CAT *get_catalog_resource(UAContext *ua) } +/* + * Select a job to enable or disable + */ +JOB *select_enable_disable_job_resource(UAContext *ua, bool enable) +{ + char name[MAX_NAME_LENGTH]; + JOB *job; + + LockRes(); + start_prompt(ua, _("The defined Job resources are:\n")); + foreach_res(job, R_JOB) { + if (!acl_access_ok(ua, Job_ACL, job->name())) { + continue; + } + if (job->enabled == enable) { /* Already enabled/disabled? */ + continue; /* yes, skip */ + } + add_prompt(ua, job->name()); + } + UnlockRes(); + if (do_prompt(ua, _("Job"), _("Select Job resource"), name, sizeof(name)) < 0) { + return NULL; + } + job = (JOB *)GetResWithName(R_JOB, name); + return job; +} + /* * Select a Job resource from prompt list */ @@ -570,11 +596,11 @@ int select_media_dbr(UAContext *ua, MEDIA_DBR *mr) } mr->PoolId = pr.PoolId; db_list_media_records(ua->jcr, ua->db, mr, prtit, ua, HORZ_LIST); - if (!get_cmd(ua, _("Enter MediaId or Volume name: "))) { + if (!get_cmd(ua, _("Enter *MediaId or Volume name: "))) { return 0; } - if (is_a_number(ua->cmd)) { - mr->MediaId = str_to_int64(ua->cmd); + if (ua->cmd[0] == '*' && is_a_number(ua->cmd+1)) { + mr->MediaId = str_to_int64(ua->cmd+1); } else { bstrncpy(mr->VolumeName, ua->cmd, sizeof(mr->VolumeName)); } @@ -762,7 +788,13 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg, } /* If running non-interactive, bail out */ if (ua->batch) { - ua->send_msg(_("Cannot select %s in batch mode.\n"), automsg); + /* First print the choices he wanted to make */ + ua->send_msg(ua->prompt[0]); + for (i=1; i < ua->num_prompts; i++) { + ua->send_msg("%6d: %s\n", i, ua->prompt[i]); + } + /* Now print error message */ + ua->send_msg(_("Your request has multiple choices for \"%s\". Selection is not possible in batch mode.\n"), automsg); item = -1; goto done; } @@ -1013,7 +1045,7 @@ bool get_level_from_name(JCR *jcr, const char *level_name) bool found = false; for (int i=0; joblevels[i].level_name; i++) { if (strcasecmp(level_name, joblevels[i].level_name) == 0) { - jcr->JobLevel = joblevels[i].level; + jcr->set_JobLevel(joblevels[i].level); found = true; break; }