]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_select.c
Cleanup new timeout code for bconsole
[bacula/bacula] / bacula / src / dird / ua_select.c
index aabc4c51eaf3a427c5e2eb9001e14681bbdf96f3..aebdaa0b8be6ec3b4b0d66ce38bc8cff86f1635c 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2001-2008 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.
@@ -244,6 +244,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
  */
@@ -762,7 +789,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;
    }