-/*
- *
- * Bacula UA authentication. Provides authentication with
- * the Director.
- *
- * Kern Sibbald, June MMI
- *
- * This routine runs as a thread and must be thread reentrant.
- *
- * Basic tasks done here:
- *
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2007 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.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Bacula UA authentication. Provides authentication with
+ * the Director.
+ *
+ * Kern Sibbald, June MMI
+ *
+ * This routine runs as a thread and must be thread reentrant.
+ *
+ * Basic tasks done here:
+ *
+ */
#include "bacula.h"
#include "console_conf.h"
-/*
- *
- * Bacula Console interface to the Director
- *
- * Kern Sibbald, September MM
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2007 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.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Bacula Console interface to the Director
+ *
+ * Kern Sibbald, September MM
+ *
+ * Version $Id$
+ */
#include "bacula.h"
#include "console_conf.h"
/* Initialize TLS context:
* Args: CA certfile, CA certdir, Certfile, Keyfile,
- * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
+ * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer
+ */
cons->tls_ctx = new_tls_context(cons->tls_ca_certfile,
cons->tls_ca_certdir, cons->tls_certfile,
cons->tls_keyfile, tls_pem_callback, &buf, NULL, true);
read_and_process_input(stdin, UA_sock);
if (UA_sock) {
- bnet_sig(UA_sock, BNET_TERMINATE); /* send EOF */
- bnet_close(UA_sock);
+ UA_sock->signal(BNET_TERMINATE); /* send EOF */
+ UA_sock->close();
}
terminate_console(0);
void find_storage_resource(UAContext *ua, RESTORE_CTX &rx, char *Storage, char *MediaType);
/* ua_server.c */
-void bsendmsg(void *sock, const char *fmt, ...);
+void bsendmsg(void *ua_ctx, const char *fmt, ...);
+void berrormsg(void *ua_ctx, const char *fmt, ...);
+void bwarningmsg(void *ua_ctx, const char *fmt, ...);
+void binfomsg(void *ua_ctx, const char *fmt, ...);
UAContext *new_ua_context(JCR *jcr);
JCR *new_control_jcr(const char *base_name, int job_type);
void free_ua_context(UAContext *ua);
#ifndef __UA_H_
#define __UA_H_ 1
-struct UAContext {
+class UAContext {
+public:
BSOCK *UA_sock;
BSOCK *sd;
JCR *jcr;
uint32_t pint32_val; /* positive integer */
int32_t int32_val; /* positive/negative */
int64_t int64_val; /* big int */
+
+ void signal(int sig) { UA_sock->signal(sig); };
+
+ /* The below are in ua_output.c */
+ void send_msg(const char *fmt, ...);
+ void error_msg(const char *fmt, ...);
+ void warning_msg(const char *fmt, ...);
+ void info_msg(const char *fmt, ...);
};
/* Context for insert_tree_handler() */
*/
static bool api_cmd(UAContext *ua, const char *cmd)
{
- /* Eventually we will probably have several levels or
- * capabilities enabled by this.
- */
- ua->api = 1;
+ if (ua->argc == 2) {
+ ua->api = atoi(ua->argk[1]);
+ } else {
+ ua->api = 1;
+ }
return true;
}
/*
* Return the backups for this client
+ *
+ * .backups client=xxx fileset=yyy
+ *
*/
static bool backupscmd(UAContext *ua, const char *cmd)
{
if (!open_client_db(ua)) {
return true;
}
- if (ua->argc != 3 || strcmp(ua->argk[1], "client") != 0 || strcmp(ua->argk[2], "fileset") != 0) {
+ if (ua->argc != 3 || strcmp(ua->argk[1], "client") != 0 ||
+ strcmp(ua->argk[2], "fileset") != 0) {
return true;
}
if (!acl_access_ok(ua, Client_ACL, ua->argv[1]) ||
return true;
}
if (!is_a_number(ua->cmd)) {
- bsendmsg(ua, _("Expected a positive integer, got: %s\n"), ua->cmd);
+ ua->warning_msg(_("Expected a positive integer, got: %s\n"), ua->cmd);
continue;
}
errno = 0;
dval = strtod(ua->cmd, NULL);
if (errno != 0 || dval < 0) {
- bsendmsg(ua, _("Expected a positive integer, got: %s\n"), ua->cmd);
+ ua->warning_msg(_("Expected a positive integer, got: %s\n"), ua->cmd);
continue;
}
ua->pint32_val = (uint32_t)dval;
ua->pint32_val = ret;
return true;
}
- bsendmsg(ua, _("Invalid response. You must answer yes or no.\n"));
+ ua->warning_msg(_("Invalid response. You must answer yes or no.\n"));
}
}
Enabled = atoi(val);
}
if (Enabled < 0 || Enabled > 2) {
- bsendmsg(ua, _("Invalid Enabled value, it must be yes, no, archived, 0, 1, or 2\n"));
+ ua->error_msg(_("Invalid Enabled value, it must be yes, no, archived, 0, 1, or 2\n"));
return -1;
}
return Enabled;
* agent, so we are being called from Bacula core. In
* that case direct the messages to the Job.
*/
-void bsendmsg(void *ctx, const char *fmt, ...)
+void bmsg(UAContext *ua, const char *fmt, va_list arg_ptr)
{
- va_list arg_ptr;
- UAContext *ua = (UAContext *)ctx;
BSOCK *bs = ua->UA_sock;
int maxlen, len;
POOLMEM *msg;
again:
maxlen = sizeof_pool_memory(msg) - 1;
- va_start(arg_ptr, fmt);
len = bvsnprintf(msg, maxlen, fmt, arg_ptr);
- va_end(arg_ptr);
if (len < 0 || len >= maxlen) {
msg = realloc_pool_memory(msg, maxlen + maxlen/2);
goto again;
}
}
+
+void bsendmsg(void *ctx, const char *fmt, ...)
+{
+ va_list arg_ptr;
+ va_start(arg_ptr, fmt);
+ bmsg((UAContext *)ctx, fmt, arg_ptr);
+ va_end(arg_ptr);
+}
+
+/*
+ * The following UA methods are mainly intended for GUI
+ * programs
+ */
+/*
+ * This is a message that should be displayed on the user's
+ * console.
+ */
+void UAContext::send_msg(const char *fmt, ...)
+{
+ va_list arg_ptr;
+ va_start(arg_ptr, fmt);
+ bmsg(this, fmt, arg_ptr);
+ va_end(arg_ptr);
+}
+
+
+/*
+ * This is an error condition with a command. The gui should put
+ * up an error or critical dialog box. The command is aborted.
+ */
+void UAContext::error_msg(const char *fmt, ...)
+{
+ BSOCK *bs = UA_sock;
+ va_list arg_ptr;
+ va_start(arg_ptr, fmt);
+ if (bs && api) bs->signal(BNET_ERROR_MSG);
+ bmsg(this, fmt, arg_ptr);
+ va_end(arg_ptr);
+}
+
+/*
+ * This is a warning message, that should bring up a warning
+ * dialog box on the GUI. The command is not aborted, but something
+ * went wrong.
+ */
+void UAContext::warning_msg(const char *fmt, ...)
+{
+ BSOCK *bs = UA_sock;
+ va_list arg_ptr;
+ va_start(arg_ptr, fmt);
+ if (bs && api) bs->signal(BNET_WARNING_MSG);
+ bmsg(this, fmt, arg_ptr);
+ va_end(arg_ptr);
+}
+
+/*
+ * This is an information message that should probably be put
+ * into the status line of a GUI program.
+ */
+void UAContext::info_msg(const char *fmt, ...)
+{
+ BSOCK *bs = UA_sock;
+ va_list arg_ptr;
+ va_start(arg_ptr, fmt);
+ if (bs && api) bs->signal(BNET_INFO_MSG);
+ bmsg(this, fmt, arg_ptr);
+ va_end(arg_ptr);
+}
if (i >= 0) {
rx.where = ua->argv[i];
if (!acl_access_ok(ua, Where_ACL, rx.where)) {
- bsendmsg(ua, _("Forbidden \"where\" specified.\n"));
+ ua->error_msg(_("\"where\" specification not authorized.\n"));
goto bail_out;
}
}
}
UnlockRes();
if (!rx.restore_jobs) {
- bsendmsg(ua, _(
+ ua->error_msg(_(
"No Restore Job Resource found in bacula-dir.conf.\n"
"You must create at least one before running this command.\n"));
goto bail_out;
goto bail_out;
case 1: /* selected by jobid */
if (!build_directory_tree(ua, &rx)) {
- bsendmsg(ua, _("Restore not done.\n"));
+ ua->send_msg(_("Restore not done.\n"));
goto bail_out;
}
break;
uint32_t selected_files;
char ed1[50];
if (!complete_bsr(ua, rx.bsr)) { /* find Vol, SessId, SessTime from JobIds */
- bsendmsg(ua, _("Unable to construct a valid BSR. Cannot continue.\n"));
+ ua->error_msg(_("Unable to construct a valid BSR. Cannot continue.\n"));
goto bail_out;
}
if (!(selected_files = write_bsr_file(ua, rx))) {
- bsendmsg(ua, _("No files selected to be restored.\n"));
+ ua->warning_msg(_("No files selected to be restored.\n"));
goto bail_out;
}
/* If no count of files, use bsr generated value (often wrong) */
rx.selected_files = selected_files;
}
if (rx.selected_files==1) {
- bsendmsg(ua, _("\n1 file selected to be restored.\n\n"));
+ ua->info_msg(_("\n1 file selected to be restored.\n\n"));
}
else {
- bsendmsg(ua, _("\n%s files selected to be restored.\n\n"),
+ ua->info_msg(_("\n%s files selected to be restored.\n\n"),
edit_uint64_with_commas(rx.selected_files, ed1));
}
} else {
- bsendmsg(ua, _("No files selected to be restored.\n"));
+ ua->warning_msg(_("No files selected to be restored.\n"));
goto bail_out;
}
get_client_name(ua, &rx);
if (!rx.ClientName) {
- bsendmsg(ua, _("No Client resource found!\n"));
+ ua->error_msg(_("No Client resource found!\n"));
goto bail_out;
}
/* Build run command */
if (rx.where) {
if (!acl_access_ok(ua, Where_ACL, rx.where)) {
- bsendmsg(ua, _("Forbidden \"where\" specified.\n"));
+ ua->error_msg(_("\"where\" specification not authorized.\n"));
goto bail_out;
}
static bool has_value(UAContext *ua, int i)
{
if (!ua->argv[i]) {
- bsendmsg(ua, _("Missing value for keyword: %s\n"), ua->argk[i]);
+ ua->error_msg(_("Missing value for keyword: %s\n"), ua->argk[i]);
return false;
}
return true;
}
}
if (!found_kw) {
- bsendmsg(ua, _("Unknown keyword: %s\n"), ua->argk[i]);
+ ua->error_msg(_("Unknown keyword: %s\n"), ua->argk[i]);
return 0;
}
/* Found keyword in kw[] list, process it */
return 0;
}
if (str_to_utime(ua->argv[i]) == 0) {
- bsendmsg(ua, _("Improper date format: %s\n"), ua->argv[i]);
+ ua->error_msg(_("Improper date format: %s\n"), ua->argv[i]);
return 0;
}
bstrncpy(date, ua->argv[i], sizeof(date));
}
rx->pool = (POOL *)GetResWithName(R_POOL, ua->argv[i]);
if (!rx->pool) {
- bsendmsg(ua, _("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]);
+ ua->error_msg(_("Error: Pool resource \"%s\" does not exist.\n"), ua->argv[i]);
return 0;
}
if (!acl_access_ok(ua, Pool_ACL, ua->argv[i])) {
rx->pool = NULL;
- bsendmsg(ua, _("Error: Pool resource \"%s\" access not allowed.\n"), ua->argv[i]);
+ ua->error_msg(_("Error: Pool resource \"%s\" access not allowed.\n"), ua->argv[i]);
return 0;
}
break;
}
if (!done) {
- bsendmsg(ua, _("\nFirst you select one or more JobIds that contain files\n"
+ ua->send_msg(_("\nFirst you select one or more JobIds that contain files\n"
"to be restored. You will be presented several methods\n"
"of specifying the JobIds. Then you will be allowed to\n"
"select which files from those JobIds are to be restored.\n\n"));
return 0;
case 0: /* list last 20 Jobs run */
if (!acl_access_ok(ua, Command_ACL, NT_("sqlquery"), 8)) {
- bsendmsg(ua, _("SQL query not authorized.\n"));
+ ua->error_msg(_("SQL query not authorized.\n"));
return 0;
}
gui_save = ua->jcr->gui;
break;
case 3: /* Enter an SQL list command */
if (!acl_access_ok(ua, Command_ACL, NT_("sqlquery"), 8)) {
- bsendmsg(ua, _("SQL query not authorized.\n"));
+ ua->error_msg(_("SQL query not authorized.\n"));
return 0;
}
if (!get_cmd(ua, _("Enter SQL list command: "))) {
if (!get_client_name(ua, rx)) {
return 0;
}
- bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n"
+ ua->send_msg(_("Enter file names with paths, or < to enter a filename\n"
"containing a list of file names with paths, and terminate\n"
"them with a blank line.\n"));
for ( ;; ) {
if (!get_client_name(ua, rx)) {
return 0;
}
- bsendmsg(ua, _("Enter file names with paths, or < to enter a filename\n"
+ ua->send_msg(_("Enter file names with paths, or < to enter a filename\n"
"containing a list of file names with paths, and terminate\n"
"them with a blank line.\n"));
for ( ;; ) {
case 10: /* Enter directories */
if (*rx->JobIds != 0) {
- bsendmsg(ua, _("You have already seleted the following JobIds: %s\n"),
+ ua->send_msg(_("You have already selected the following JobIds: %s\n"),
rx->JobIds);
} else if (get_cmd(ua, _("Enter JobId(s), comma separated, to restore: "))) {
if (*rx->JobIds != 0 && *ua->cmd) {
if (!get_client_name(ua, rx)) {
return 0;
}
- bsendmsg(ua, _("Enter full directory names or start the name\n"
+ ua->send_msg(_("Enter full directory names or start the name\n"
"with a < to indicate it is a filename containing a list\n"
"of directories and terminate them with a blank line.\n"));
for ( ;; ) {
char ed1[50];
int stat = get_next_jobid_from_list(&p, &JobId);
if (stat < 0) {
- bsendmsg(ua, _("Invalid JobId in list.\n"));
+ ua->error_msg(_("Invalid JobId in list.\n"));
free_pool_memory(JobIds);
return 0;
}
memset(&jr, 0, sizeof(JOB_DBR));
jr.JobId = JobId;
if (!db_get_job_record(ua->jcr, ua->db, &jr)) {
- bsendmsg(ua, _("Unable to get Job record for JobId=%s: ERR=%s\n"),
+ ua->error_msg(_("Unable to get Job record for JobId=%s: ERR=%s\n"),
edit_int64(JobId, ed1), db_strerror(ua->db));
free_pool_memory(JobIds);
return 0;
}
if (!acl_access_ok(ua, Job_ACL, jr.Name)) {
- bsendmsg(ua, _("No authorization for JobId=%s (Job \"%s\"). Not selected.\n"),
+ ua->error_msg(_("Access to JobId=%s (Job \"%s\") not authorized. Not selected.\n"),
edit_int64(JobId, ed1), jr.Name);
continue;
}
free_pool_memory(rx->JobIds);
rx->JobIds = JobIds; /* Set ACL filtered list */
if (*rx->JobIds == 0) {
- bsendmsg(ua, _("No Jobs selected.\n"));
+ ua->warning_msg(_("No Jobs selected.\n"));
return 0;
}
if (strchr(rx->JobIds,',')) {
- bsendmsg(ua, _("You have selected the following JobIds: %s\n"), rx->JobIds);
+ ua->info_msg(_("You have selected the following JobIds: %s\n"), rx->JobIds);
} else {
- bsendmsg(ua, _("You have selected the following JobId: %s\n"), rx->JobIds);
+ ua->info_msg(_("You have selected the following JobId: %s\n"), rx->JobIds);
}
return 1;
}
*/
static int get_date(UAContext *ua, char *date, int date_len)
{
- bsendmsg(ua, _("The restored files will the most current backup\n"
+ ua->send_msg(_("The restored files will the most current backup\n"
"BEFORE the date you specify below.\n\n"));
for ( ;; ) {
if (!get_cmd(ua, _("Enter date as YYYY-MM-DD HH:MM:SS :"))) {
if (str_to_utime(ua->cmd) != 0) {
break;
}
- bsendmsg(ua, _("Improper date format.\n"));
+ ua->error_msg(_("Improper date format.\n"));
}
bstrncpy(date, ua->cmd, date_len);
return 1;
p++;
if ((ffd = fopen(p, "rb")) == NULL) {
berrno be;
- bsendmsg(ua, _("Cannot open file %s: ERR=%s\n"),
+ ua->error_msg(_("Cannot open file %s: ERR=%s\n"),
p, be.strerror());
break;
}
line++;
if (dir) {
if (!insert_dir_into_findex_list(ua, rx, file, date)) {
- bsendmsg(ua, _("Error occurred on line %d of %s\n"), line, p);
+ ua->error_msg(_("Error occurred on line %d of file \"%s\"\n"), line, p);
}
} else {
if (!insert_file_into_findex_list(ua, rx, file, date)) {
- bsendmsg(ua, _("Error occurred on line %d of %s\n"), line, p);
+ ua->error_msg(_("Error occurred on line %d of file \"%s\"\n"), line, p);
}
}
}
rx->found = false;
/* Find and insert jobid and File Index */
if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) {
- bsendmsg(ua, _("Query failed: %s. ERR=%s\n"),
+ ua->error_msg(_("Query failed: %s. ERR=%s\n"),
rx->query, db_strerror(ua->db));
}
if (!rx->found) {
- bsendmsg(ua, _("No database record found for: %s\n"), file);
+ ua->error_msg(_("No database record found for: %s\n"), file);
return true;
}
return true;
{
strip_trailing_junk(dir);
if (*rx->JobIds == 0) {
- bsendmsg(ua, _("No JobId specified cannot continue.\n"));
+ ua->error_msg(_("No JobId specified cannot continue.\n"));
return false;
} else {
Mmsg(rx->query, uar_jobid_fileindex_from_dir, rx->JobIds,
rx->found = false;
/* Find and insert jobid and File Index */
if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) {
- bsendmsg(ua, _("Query failed: %s. ERR=%s\n"),
+ ua->error_msg(_("Query failed: %s. ERR=%s\n"),
rx->query, db_strerror(ua->db));
}
if (!rx->found) {
- bsendmsg(ua, _("No database record found for: %s\n"), dir);
+ ua->error_msg(_("No database record found for: %s\n"), dir);
return true;
}
return true;
rx->found = false;
/* Find and insert jobid and File Index */
if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) {
- bsendmsg(ua, _("Query failed: %s. ERR=%s\n"),
+ ua->error_msg(_("Query failed: %s. ERR=%s\n"),
rx->query, db_strerror(ua->db));
}
if (!rx->found) {
- bsendmsg(ua, _("No table found: %s\n"), table);
+ ua->error_msg(_("No table found: %s\n"), table);
return true;
}
return true;
/* Use first JobId as estimate of the number of files to restore */
Mmsg(rx->query, uar_count_files, edit_int64(JobId, ed1));
if (!db_sql_query(ua->db, rx->query, count_handler, (void *)rx)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->error_msg("%s\n", db_strerror(ua->db));
}
if (rx->found) {
/* Add about 25% more than this job for over estimate */
continue; /* eliminate duplicate JobIds */
}
last_JobId = JobId;
- bsendmsg(ua, _("\nBuilding directory tree for JobId %s ... "),
+ ua->info_msg(_("\nBuilding directory tree for JobId %s ... "),
edit_int64(JobId, ed1));
items++;
/*
*/
Mmsg(rx->query, uar_sel_files, edit_int64(JobId, ed1));
if (!db_sql_query(ua->db, rx->query, insert_tree_handler, (void *)&tree)) {
- bsendmsg(ua, "%s", db_strerror(ua->db));
+ ua->error_msg("%s", db_strerror(ua->db));
}
}
if (tree.FileCount == 0) {
- bsendmsg(ua, _("\nThere were no files inserted into the tree, so file selection\n"
+ ua->send_msg(_("\nThere were no files inserted into the tree, so file selection\n"
"is not possible.Most likely your retention policy pruned the files\n"));
if (!get_yesno(ua, _("\nDo you want to restore all the files? (yes|no): "))) {
OK = false;
char ec1[50];
if (items==1) {
if (tree.all) {
- bsendmsg(ua, _("\n1 Job, %s files inserted into the tree and marked for extraction.\n"),
+ ua->info_msg(_("\n1 Job, %s files inserted into the tree and marked for extraction.\n"),
edit_uint64_with_commas(tree.FileCount, ec1));
}
else {
- bsendmsg(ua, _("\n1 Job, %s files inserted into the tree.\n"),
+ ua->info_msg(_("\n1 Job, %s files inserted into the tree.\n"),
edit_uint64_with_commas(tree.FileCount, ec1));
}
}
else {
if (tree.all) {
- bsendmsg(ua, _("\n%d Jobs, %s files inserted into the tree and marked for extraction.\n"),
+ ua->info_msg(_("\n%d Jobs, %s files inserted into the tree and marked for extraction.\n"),
items, edit_uint64_with_commas(tree.FileCount, ec1));
}
else {
- bsendmsg(ua, _("\n%d Jobs, %s files inserted into the tree.\n"),
+ ua->info_msg(_("\n%d Jobs, %s files inserted into the tree.\n"),
items, edit_uint64_with_commas(tree.FileCount, ec1));
}
}
db_sql_query(ua->db, uar_del_temp, NULL, NULL);
db_sql_query(ua->db, uar_del_temp1, NULL, NULL);
if (!db_sql_query(ua->db, uar_create_temp, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->error_msg("%s\n", db_strerror(ua->db));
}
if (!db_sql_query(ua->db, uar_create_temp1, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->error_msg("%s\n", db_strerror(ua->db));
}
/*
* Select Client from the Catalog
if (i >= 0) {
bstrncpy(fsr.FileSet, ua->argv[i], sizeof(fsr.FileSet));
if (!db_get_fileset_record(ua->jcr, ua->db, &fsr)) {
- bsendmsg(ua, _("Error getting FileSet \"%s\": ERR=%s\n"), fsr.FileSet,
+ ua->error_msg(_("Error getting FileSet \"%s\": ERR=%s\n"), fsr.FileSet,
db_strerror(ua->db));
i = -1;
}
Mmsg(rx->query, uar_sel_fileset, ed1, ed1);
start_prompt(ua, _("The defined FileSet resources are:\n"));
if (!db_sql_query(ua->db, rx->query, fileset_handler, (void *)ua)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->error_msg("%s\n", db_strerror(ua->db));
}
if (do_prompt(ua, _("FileSet"), _("Select FileSet resource"),
fileset_name, sizeof(fileset_name)) < 0) {
- bsendmsg(ua, _("No FileSet found for client \"%s\".\n"), cr.Name);
+ ua->error_msg(_("No FileSet found for client \"%s\".\n"), cr.Name);
goto bail_out;
}
bstrncpy(fsr.FileSet, fileset_name, sizeof(fsr.FileSet));
if (!db_get_fileset_record(ua->jcr, ua->db, &fsr)) {
- bsendmsg(ua, _("Error getting FileSet record: %s\n"), db_strerror(ua->db));
- bsendmsg(ua, _("This probably means you modified the FileSet.\n"
+ ua->warning_msg(_("Error getting FileSet record: %s\n"), db_strerror(ua->db));
+ ua->send_msg(_("This probably means you modified the FileSet.\n"
"Continuing anyway.\n"));
}
}
bsnprintf(pool_select, sizeof(pool_select), "AND Media.PoolId=%s ",
edit_int64(pr.PoolId, ed1));
} else {
- bsendmsg(ua, _("Pool \"%s\" not found, using any pool.\n"), pr.Name);
+ ua->warning_msg(_("Pool \"%s\" not found, using any pool.\n"), pr.Name);
}
}
Mmsg(rx->query, uar_last_full, ed1, ed1, date, fsr.FileSet,
pool_select);
if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->error_msg("%s\n", db_strerror(ua->db));
goto bail_out;
}
/* Find all Volumes used by that JobId */
if (!db_sql_query(ua->db, uar_full, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->error_msg("%s\n", db_strerror(ua->db));
goto bail_out;
}
/* Note, this is needed because I don't seem to get the callback
*/
rx->JobTDate = 0;
if (!db_sql_query(ua->db, uar_sel_all_temp1, last_full_handler, (void *)rx)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->warning_msg("%s\n", db_strerror(ua->db));
}
if (rx->JobTDate == 0) {
- bsendmsg(ua, _("No Full backup before %s found.\n"), date);
+ ua->error_msg(_("No Full backup before %s found.\n"), date);
goto bail_out;
}
Mmsg(rx->query, uar_dif, edit_uint64(rx->JobTDate, ed1), date,
edit_int64(cr.ClientId, ed2), fsr.FileSet, pool_select);
if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->warning_msg("%s\n", db_strerror(ua->db));
}
/* Now update JobTDate to lock onto Differental, if any */
rx->JobTDate = 0;
if (!db_sql_query(ua->db, uar_sel_all_temp, last_full_handler, (void *)rx)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->warning_msg("%s\n", db_strerror(ua->db));
}
if (rx->JobTDate == 0) {
- bsendmsg(ua, _("No Full backup before %s found.\n"), date);
+ ua->error_msg(_("No Full backup before %s found.\n"), date);
goto bail_out;
}
Mmsg(rx->query, uar_inc, edit_uint64(rx->JobTDate, ed1), date,
edit_int64(cr.ClientId, ed2), fsr.FileSet, pool_select);
if (!db_sql_query(ua->db, rx->query, NULL, NULL)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->warning_msg("%s\n", db_strerror(ua->db));
}
/* Get the JobIds from that list */
rx->JobIds[0] = 0;
rx->last_jobid[0] = 0;
if (!db_sql_query(ua->db, uar_sel_jobid_temp, jobid_handler, (void *)rx)) {
- bsendmsg(ua, "%s\n", db_strerror(ua->db));
+ ua->warning_msg("%s\n", db_strerror(ua->db));
}
if (rx->JobIds[0] != 0) {
db_list_sql_query(ua->jcr, ua->db, uar_list_temp, prtit, ua, 1, HORZ_LIST);
ok = true;
} else {
- bsendmsg(ua, _("No jobs found.\n"));
+ ua->warning_msg(_("No jobs found.\n"));
}
bail_out:
}
}
if (store && (store != rx.store)) {
- bsendmsg(ua, _("Warning default storage overridden by \"%s\" on command line.\n"),
+ ua->info_msg(_("Warning default storage overridden by \"%s\" on command line.\n"),
store->name());
rx.store = store;
Dmsg1(200, "Set store=%s\n", rx.store->name());
if (acl_access_ok(ua, Storage_ACL, store->name())) {
rx.store = store;
Dmsg1(200, "Set store=%s\n", rx.store->name());
- bsendmsg(ua, _("Storage \"%s\" not found, using Storage \"%s\" from MediaType \"%s\".\n"),
+ ua->warning_msg(_("Storage \"%s\" not found, using Storage \"%s\" from MediaType \"%s\".\n"),
Storage, store->name(), MediaType);
}
UnlockRes();
}
}
UnlockRes();
- bsendmsg(ua, _("\nUnable to find Storage resource for\n"
+ ua->warning_msg(_("\nUnable to find Storage resource for\n"
"MediaType \"%s\", needed by the Jobs you selected.\n"), MediaType);
}
if (strcasecmp(ua->argk[i], kw[j]) == 0) {
/* Note, yes and run have no value, so do not fail */
if (!ua->argv[i] && j != YES_POS /*yes*/) {
- bsendmsg(ua, _("Value missing for keyword %s\n"), ua->argk[i]);
+ ua->send_msg(_("Value missing for keyword %s\n"), ua->argk[i]);
return 1;
}
Dmsg1(800, "Got keyword=%s\n", NPRT(kw[j]));
switch (j) {
case 0: /* job */
if (job_name) {
- bsendmsg(ua, _("Job name specified twice.\n"));
+ ua->send_msg(_("Job name specified twice.\n"));
return 0;
}
job_name = ua->argv[i];
break;
case 1: /* JobId */
if (jid) {
- bsendmsg(ua, _("JobId specified twice.\n"));
+ ua->send_msg(_("JobId specified twice.\n"));
return 0;
}
jid = ua->argv[i];
case 2: /* client */
case 3: /* fd */
if (client_name) {
- bsendmsg(ua, _("Client specified twice.\n"));
+ ua->send_msg(_("Client specified twice.\n"));
return 0;
}
client_name = ua->argv[i];
break;
case 4: /* fileset */
if (fileset_name) {
- bsendmsg(ua, _("FileSet specified twice.\n"));
+ ua->send_msg(_("FileSet specified twice.\n"));
return 0;
}
fileset_name = ua->argv[i];
break;
case 5: /* level */
if (level_name) {
- bsendmsg(ua, _("Level specified twice.\n"));
+ ua->send_msg(_("Level specified twice.\n"));
return 0;
}
level_name = ua->argv[i];
case 6: /* storage */
case 7: /* sd */
if (store_name) {
- bsendmsg(ua, _("Storage specified twice.\n"));
+ ua->send_msg(_("Storage specified twice.\n"));
return 0;
}
store_name = ua->argv[i];
break;
case 8: /* pool */
if (pool_name) {
- bsendmsg(ua, _("Pool specified twice.\n"));
+ ua->send_msg(_("Pool specified twice.\n"));
return 0;
}
pool_name = ua->argv[i];
break;
case 9: /* where */
if (where) {
- bsendmsg(ua, _("Where specified twice.\n"));
+ ua->send_msg(_("Where specified twice.\n"));
return 0;
}
where = ua->argv[i];
if (!acl_access_ok(ua, Where_ACL, where)) {
- bsendmsg(ua, _("Forbidden \"where\" specified.\n"));
+ ua->send_msg(_("Forbidden \"where\" specified.\n"));
return 0;
}
kw_ok = true;
break;
case 10: /* bootstrap */
if (bootstrap) {
- bsendmsg(ua, _("Bootstrap specified twice.\n"));
+ ua->send_msg(_("Bootstrap specified twice.\n"));
return 0;
}
bootstrap = ua->argv[i];
break;
case 11: /* replace */
if (replace) {
- bsendmsg(ua, _("Replace specified twice.\n"));
+ ua->send_msg(_("Replace specified twice.\n"));
return 0;
}
replace = ua->argv[i];
break;
case 12: /* When */
if (when) {
- bsendmsg(ua, _("When specified twice.\n"));
+ ua->send_msg(_("When specified twice.\n"));
return 0;
}
when = ua->argv[i];
break;
case 13: /* Priority */
if (Priority) {
- bsendmsg(ua, _("Priority specified twice.\n"));
+ ua->send_msg(_("Priority specified twice.\n"));
return 0;
}
Priority = atoi(ua->argv[i]);
if (Priority <= 0) {
- bsendmsg(ua, _("Priority must be positive nonzero setting it to 10.\n"));
+ ua->send_msg(_("Priority must be positive nonzero setting it to 10.\n"));
Priority = 10;
}
kw_ok = true;
break;
case 15: /* Verify Job */
if (verify_job_name) {
- bsendmsg(ua, _("Verify Job specified twice.\n"));
+ ua->send_msg(_("Verify Job specified twice.\n"));
return 0;
}
verify_job_name = ua->argv[i];
break;
case 21: /* Migration Job */
if (previous_job_name) {
- bsendmsg(ua, _("Migration Job specified twice.\n"));
+ ua->send_msg(_("Migration Job specified twice.\n"));
return 0;
}
previous_job_name = ua->argv[i];
job_name = ua->argk[i]; /* use keyword as job name */
Dmsg1(800, "Set jobname=%s\n", job_name);
} else {
- bsendmsg(ua, _("Invalid keyword: %s\n"), ua->argk[i]);
+ ua->send_msg(_("Invalid keyword: %s\n"), ua->argk[i]);
return 0;
}
}
if (catalog_name != NULL) {
catalog = (CAT *)GetResWithName(R_CATALOG, catalog_name);
if (catalog == NULL) {
- bsendmsg(ua, _("Catalog \"%s\" not found\n"), catalog_name);
+ ua->error_msg(_("Catalog \"%s\" not found\n"), catalog_name);
return 0;
}
if (!acl_access_ok(ua, Catalog_ACL, catalog->name())) {
- bsendmsg(ua, _("No authorization. Catalog \"%s\".\n"), catalog->name());
+ ua->error_msg(_("No authorization. Catalog \"%s\".\n"), catalog->name());
return 0;
}
}
job = (JOB *)GetResWithName(R_JOB, job_name);
if (!job) {
if (*job_name != 0) {
- bsendmsg(ua, _("Job \"%s\" not found\n"), job_name);
+ ua->send_msg(_("Job \"%s\" not found\n"), job_name);
}
job = select_job_resource(ua);
} else {
Dmsg1(800, "Found job=%s\n", job_name);
}
} else {
- bsendmsg(ua, _("A job name must be specified.\n"));
+ ua->send_msg(_("A job name must be specified.\n"));
job = select_job_resource(ua);
}
if (!job) {
return 0;
} else if (!acl_access_ok(ua, Job_ACL, job->name())) {
- bsendmsg(ua, _("No authorization. Job \"%s\".\n"),
+ ua->error_msg( _("No authorization. Job \"%s\".\n"),
job->name());
return 0;
}
pool = (POOL *)GetResWithName(R_POOL, pool_name);
if (!pool) {
if (*pool_name != 0) {
- bsendmsg(ua, _("Pool \"%s\" not found.\n"), pool_name);
+ ua->warning_msg(_("Pool \"%s\" not found.\n"), pool_name);
}
pool = select_pool_resource(ua);
}
if (!pool) {
return 0;
} else if (!acl_access_ok(ua, Pool_ACL, pool->name())) {
- bsendmsg(ua, _("No authorization. Pool \"%s\".\n"),
+ ua->error_msg(_("No authorization. Pool \"%s\".\n"),
pool->name());
return 0;
}
pm_strcpy(store.store_source, _("command line"));
if (!store.store) {
if (*store_name != 0) {
- bsendmsg(ua, _("Storage \"%s\" not found.\n"), store_name);
+ ua->warning_msg(_("Storage \"%s\" not found.\n"), store_name);
}
store.store = select_storage_resource(ua);
pm_strcpy(store.store_source, _("user selection"));
get_job_storage(&store, job, NULL); /* use default */
}
if (!store.store) {
- bsendmsg(ua, _("No storage specified.\n"));
+ ua->error_msg(_("No storage specified.\n"));
return 1;
} else if (!acl_access_ok(ua, Storage_ACL, store.store->name())) {
- bsendmsg(ua, _("No authorization. Storage \"%s\".\n"),
+ ua->error_msg(_("No authorization. Storage \"%s\".\n"),
store.store->name());
return 0;
}
client = (CLIENT *)GetResWithName(R_CLIENT, client_name);
if (!client) {
if (*client_name != 0) {
- bsendmsg(ua, _("Client \"%s\" not found.\n"), client_name);
+ ua->warning_msg(_("Client \"%s\" not found.\n"), client_name);
}
client = select_client_resource(ua);
}
if (!client) {
return 0;
} else if (!acl_access_ok(ua, Client_ACL, client->name())) {
- bsendmsg(ua, _("No authorization. Client \"%s\".\n"),
+ ua->error_msg(_("No authorization. Client \"%s\".\n"),
client->name());
return 0;
}
if (fileset_name) {
fileset = (FILESET *)GetResWithName(R_FILESET, fileset_name);
if (!fileset) {
- bsendmsg(ua, _("FileSet \"%s\" not found.\n"), fileset_name);
+ ua->send_msg(_("FileSet \"%s\" not found.\n"), fileset_name);
fileset = select_fileset_resource(ua);
}
} else {
if (!fileset) {
return 0;
} else if (!acl_access_ok(ua, FileSet_ACL, fileset->name())) {
- bsendmsg(ua, _("No authorization. FileSet \"%s\".\n"),
+ ua->send_msg(_("No authorization. FileSet \"%s\".\n"),
fileset->name());
return 0;
}
if (verify_job_name) {
verify_job = (JOB *)GetResWithName(R_JOB, verify_job_name);
if (!verify_job) {
- bsendmsg(ua, _("Verify Job \"%s\" not found.\n"), verify_job_name);
+ ua->send_msg(_("Verify Job \"%s\" not found.\n"), verify_job_name);
verify_job = select_job_resource(ua);
}
} else {
if (previous_job_name) {
previous_job = (JOB *)GetResWithName(R_JOB, previous_job_name);
if (!previous_job) {
- bsendmsg(ua, _("Migration Job \"%s\" not found.\n"), previous_job_name);
+ ua->send_msg(_("Migration Job \"%s\" not found.\n"), previous_job_name);
previous_job = select_job_resource(ua);
}
} else {
if (when) {
jcr->sched_time = str_to_utime(when);
if (jcr->sched_time == 0) {
- bsendmsg(ua, _("Invalid time, using current time.\n"));
+ ua->send_msg(_("Invalid time, using current time.\n"));
jcr->sched_time = time(NULL);
}
}
}
}
if (!jcr->replace) {
- bsendmsg(ua, _("Invalid replace option: %s\n"), replace);
+ ua->send_msg(_("Invalid replace option: %s\n"), replace);
goto bail_out;
}
} else if (job->replace) {
}
if (level_name) {
if (!get_level_from_name(jcr, level_name)) {
- bsendmsg(ua, _("Level %s not valid.\n"), level_name);
+ ua->send_msg(_("Level %s not valid.\n"), level_name);
goto bail_out;
}
}
} else {
jcr->sched_time = str_to_utime(ua->cmd);
if (jcr->sched_time == 0) {
- bsendmsg(ua, _("Invalid time, using current time.\n"));
+ ua->send_msg(_("Invalid time, using current time.\n"));
jcr->sched_time = time(NULL);
}
}
break;
}
if (ua->pint32_val == 0) {
- bsendmsg(ua, _("Priority must be a positive integer.\n"));
+ ua->send_msg(_("Priority must be a positive integer.\n"));
} else {
jcr->JobPriority = ua->pint32_val;
}
jcr->RestoreBootstrap = bstrdup(ua->cmd);
fd = fopen(jcr->RestoreBootstrap, "rb");
if (!fd) {
- bsendmsg(ua, _("Warning cannot open %s: ERR=%s\n"),
+ ua->send_msg(_("Warning cannot open %s: ERR=%s\n"),
jcr->RestoreBootstrap, strerror(errno));
free(jcr->RestoreBootstrap);
jcr->RestoreBootstrap = NULL;
jid = NULL; /* force reprompt */
jcr->RestoreJobId = 0;
if (jcr->RestoreBootstrap) {
- bsendmsg(ua, _("You must set the bootstrap file to NULL to be able to specify a JobId.\n"));
+ ua->send_msg(_("You must set the bootstrap file to NULL to be able to specify a JobId.\n"));
}
goto try_again;
case -1: /* error or cancel */
Dmsg1(100, "Using pool %s\n", jcr->pool->name());
JobId = run_job(jcr);
#if 0
- bsendmsg(ua, "<job director=\"console\" time=\"%u\" status=\"%c\" type=\"%c\" "
+ ua->send_msg("<job director=\"console\" time=\"%u\" status=\"%c\" type=\"%c\" "
"jobid=\"%u\" job=\"%s\" level=\"%c\" finished=\"false\" priority=\"%u\"/>\n",
time(NULL), jcr->JobStatus, jcr->JobType, jcr->JobId,
jcr->Job, jcr->JobLevel, jcr->JobPriority);
#endif
free_jcr(jcr); /* release jcr */
if (JobId == 0) {
- bsendmsg(ua, _("Job failed.\n"));
+ ua->error_msg(_("Job failed.\n"));
} else {
char ed1[50];
- bsendmsg(ua, _("Job queued. JobId=%s\n"), edit_int64(JobId,ed1));
+ ua->send_msg(_("Job queued. JobId=%s\n"), edit_int64(JobId,ed1));
}
return JobId;
}
bail_out:
- bsendmsg(ua, _("Job not run.\n"));
+ ua->send_msg(_("Job not run.\n"));
free_jcr(jcr);
return 0; /* do not run */
}
break;
}
} else {
- bsendmsg(ua, _("Level not appropriate for this Job. Cannot be changed.\n"));
+ ua->warning_msg(_("Level not appropriate for this Job. Cannot be changed.\n"));
}
return;
}
char ec1[30];
char dt[MAX_TIME_LENGTH];
case JT_ADMIN:
- bsendmsg(ua, _("Run %s job\n"
- "JobName: %s\n"
- "FileSet: %s\n"
- "Client: %s\n"
- "Storage: %s\n"
- "When: %s\n"
- "Priority: %d\n"),
+ if (ua->api) ua->signal(BNET_RUN_CMD);
+ ua->send_msg(_("Run %s job\n"
+ "JobName: %s\n"
+ "FileSet: %s\n"
+ "Client: %s\n"
+ "Storage: %s\n"
+ "When: %s\n"
+ "Priority: %d\n"),
_("Admin"),
job->name(),
jcr->fileset->name(),
case JT_BACKUP:
case JT_VERIFY:
if (jcr->JobType == JT_BACKUP) {
- bsendmsg(ua, _("Run %s job\n"
+ if (ua->api) ua->signal(BNET_RUN_CMD);
+ ua->send_msg(_("Run %s job\n"
"JobName: %s\n"
"Level: %s\n"
"Client: %s\n"
if (!verify_list) {
verify_list = "";
}
- bsendmsg(ua, _("Run %s job\n"
+ if (ua->api) ua->signal(BNET_RUN_CMD);
+ ua->send_msg(_("Run %s job\n"
"JobName: %s\n"
"Level: %s\n"
"Client: %s\n"
jcr->JobLevel = L_FULL; /* default level */
Dmsg1(800, "JobId to restore=%d\n", jcr->RestoreJobId);
if (jcr->RestoreJobId == 0) {
- bsendmsg(ua, _("Run Restore job\n"
+ if (ua->api) ua->signal(BNET_RUN_CMD);
+ ua->send_msg(_("Run Restore job\n"
"JobName: %s\n"
"Bootstrap: %s\n"
"Where: %s\n"
jcr->catalog->name(),
jcr->JobPriority);
} else {
- bsendmsg(ua, _("Run Restore job\n"
+ if (ua->api) ua->signal(BNET_RUN_CMD);
+ ua->send_msg(_("Run Restore job\n"
"JobName: %s\n"
"Bootstrap: %s\n"
"Where: %s\n"
break;
case JT_MIGRATE:
jcr->JobLevel = L_FULL; /* default level */
- bsendmsg(ua, _("Run Migration job\n"
+ if (ua->api) ua->signal(BNET_RUN_CMD);
+ ua->send_msg(_("Run Migration job\n"
"JobName: %s\n"
"Bootstrap: %s\n"
"Client: %s\n"
jcr->JobPriority);
break;
default:
- bsendmsg(ua, _("Unknown Job Type=%d\n"), jcr->JobType);
+ ua->error_msg(_("Unknown Job Type=%d\n"), jcr->JobType);
return false;
}
return true;
}
while (!ua->quit) {
+ if (ua->api) user->signal(BNET_PROMPT);
stat = user->recv();
if (stat >= 0) {
pm_strcpy(ua->cmd, ua->UA_sock->msg);
ua->user_notified_msg_pending = false;
} else if (!ua->gui && !ua->user_notified_msg_pending && console_msg_pending) {
if (ua->api) {
- user->signal(BNET_MESSAGES_PENDING);
+ user->signal(BNET_MSGS_PENDING);
} else {
bsendmsg(ua, _("You have messages.\n"));
}
/* Get a new context so we don't destroy restore command args */
UAContext *ua = new_ua_context(tree->ua->jcr);
ua->UA_sock = tree->ua->UA_sock; /* patch in UA socket */
+ ua->api = tree->ua->api; /* keep API flag too */
BSOCK *user = ua->UA_sock;
bsendmsg(tree->ua, _(
char ec1[50];
if (ua->argc < 2 || !tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("No files marked.\n"));
+ ua->send_msg(_("No files marked.\n"));
return 1;
}
for (int i=1; i < ua->argc; i++) {
}
}
if (count == 0) {
- bsendmsg(ua, _("No files marked.\n"));
+ ua->send_msg(_("No files marked.\n"));
} else if (count == 1) {
- bsendmsg(ua, _("1 file marked.\n"));
+ ua->send_msg(_("1 file marked.\n"));
} else {
- bsendmsg(ua, _("%s files marked.\n"),
+ ua->send_msg(_("%s files marked.\n"),
edit_uint64_with_commas(count, ec1));
}
return 1;
char ec1[50];
if (ua->argc < 2 || !tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("No files marked.\n"));
+ ua->send_msg(_("No files marked.\n"));
return 1;
}
for (int i=1; i < ua->argc; i++) {
}
}
if (count == 0) {
- bsendmsg(ua, _("No directories marked.\n"));
+ ua->send_msg(_("No directories marked.\n"));
} else if (count == 1) {
- bsendmsg(ua, _("1 directory marked.\n"));
+ ua->send_msg(_("1 directory marked.\n"));
} else {
- bsendmsg(ua, _("%s directories marked.\n"),
+ ua->send_msg(_("%s directories marked.\n"),
edit_uint64_with_commas(count, ec1));
}
return 1;
}
}
}
- bsendmsg(ua, _("%s total files/dirs. %s marked to be restored.\n"),
+ ua->send_msg(_("%s total files/dirs. %s marked to be restored.\n"),
edit_uint64_with_commas(total, ec1),
edit_uint64_with_commas(num_extract, ec2));
return 1;
char cwd[2000];
if (ua->argc == 1) {
- bsendmsg(ua, _("No file specification given.\n"));
+ ua->send_msg(_("No file specification given.\n"));
return 1; /* make it non-fatal */
}
} else {
tag = "";
}
- bsendmsg(ua, "%s%s\n", tag, cwd);
+ ua->send_msg("%s%s\n", tag, cwd);
}
}
}
} else {
tag = "";
}
- bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
+ ua->send_msg("%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
}
}
return 1;
} else {
tag = "";
}
- bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
+ ua->send_msg("%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
if (tree_node_has_child(node)) {
rlsmark(ua, node);
}
char cwd[1100], *pcwd;
if (!tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("Node %s has no children.\n"), tree->node->fname);
+ ua->send_msg(_("Node %s has no children.\n"), tree->node->fname);
return 1;
}
memset(&statp, 0, sizeof(statp));
}
ls_output(buf, cwd, tag, &statp, dot_cmd);
- bsendmsg(ua, "%s\n", buf);
+ ua->send_msg("%s\n", buf);
}
}
return 1;
}
}
}
- bsendmsg(ua, _("%d total files; %d marked to be restored; %s bytes.\n"),
+ ua->send_msg(_("%d total files; %d marked to be restored; %s bytes.\n"),
total, num_extract, edit_uint64_with_commas(total_bytes, ec1));
return 1;
}
{
unsigned int i;
- bsendmsg(ua, _(" Command Description\n ======= ===========\n"));
+ ua->send_msg(_(" Command Description\n ======= ===========\n"));
for (i=0; i<comsize; i++) {
/* List only non-dot commands */
if (commands[i].key[0] != '.') {
- bsendmsg(ua, " %-10s %s\n", _(commands[i].key), _(commands[i].help));
+ ua->send_msg(" %-10s %s\n", _(commands[i].key), _(commands[i].help));
}
}
- bsendmsg(ua, "\n");
+ ua->send_msg("\n");
return 1;
}
if (ua->argc != 2) {
- bsendmsg(ua, _("Too few or too many arguments. Try using double quotes.\n"));
+ ua->error_msg(_("Too few or too many arguments. Try using double quotes.\n"));
return 1;
}
node = tree_cwd(ua->argk[1], tree->root, tree->node);
node = tree_cwd(cwd, tree->root, tree->node);
}
if (!node) {
- bsendmsg(ua, _("Invalid path given.\n"));
+ ua->warning_msg(_("Invalid path given.\n"));
} else {
tree->node = node;
}
char cwd[2000];
tree_getpath(tree->node, cwd, sizeof(cwd));
if (ua->api) {
- bsendmsg(ua, "%s", cwd);
+ ua->send_msg("%s", cwd);
} else {
- bsendmsg(ua, _("cwd is: %s\n"), cwd);
+ ua->send_msg(_("cwd is: %s\n"), cwd);
}
return 1;
}
{
char cwd[2000];
tree_getpath(tree->node, cwd, sizeof(cwd));
- bsendmsg(ua, _("%s"), cwd);
+ ua->send_msg("%s", cwd);
return 1;
}
int count = 0;
if (ua->argc < 2 || !tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("No files unmarked.\n"));
+ ua->send_msg(_("No files unmarked.\n"));
return 1;
}
for (int i=1; i < ua->argc; i++) {
}
}
if (count == 0) {
- bsendmsg(ua, _("No files unmarked.\n"));
+ ua->send_msg(_("No files unmarked.\n"));
} else if (count == 1) {
- bsendmsg(ua, _("1 file unmarked.\n"));
+ ua->send_msg(_("1 file unmarked.\n"));
} else {
char ed1[50];
- bsendmsg(ua, _("%s files unmarked.\n"), edit_uint64_with_commas(count, ed1));
+ ua->send_msg(_("%s files unmarked.\n"), edit_uint64_with_commas(count, ed1));
}
return 1;
}
int count = 0;
if (ua->argc < 2 || !tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("No directories unmarked.\n"));
+ ua->send_msg(_("No directories unmarked.\n"));
return 1;
}
}
if (count == 0) {
- bsendmsg(ua, _("No directories unmarked.\n"));
+ ua->send_msg(_("No directories unmarked.\n"));
} else if (count == 1) {
- bsendmsg(ua, _("1 directory unmarked.\n"));
+ ua->send_msg(_("1 directory unmarked.\n"));
} else {
- bsendmsg(ua, _("%d directories unmarked.\n"), count);
+ ua->send_msg(_("%d directories unmarked.\n"), count);
}
return 1;
}
/*
* Signal definitions for use in bnet_sig()
- * Note! These must be negative
+ * Note! These must be negative. There are signals that are generated
+ * by the software ...
*/
enum {
- BNET_EOD = -1, /* End of data stream, new data may follow */
- BNET_EOD_POLL = -2, /* End of data and poll all in one */
- BNET_STATUS = -3, /* Send full status */
- BNET_TERMINATE = -4, /* Conversation terminated, doing close() */
- BNET_POLL = -5, /* Poll request, I'm hanging on a read */
- BNET_HEARTBEAT = -6, /* Heartbeat Response requested */
- BNET_HB_RESPONSE = -7, /* Only response permited to HB */
- BNET_PROMPT = -8, /* Prompt for UA */
- BNET_BTIME = -9, /* Send UTC btime */
- BNET_BREAK = -10, /* Stop current command -- ctl-c */
- BNET_START_SELECT = -11, /* Start of a selection list */
- BNET_END_SELECT = -12, /* End of a select list */
- BNET_INVALID_CMD = -13, /* Invalid command sent */
- BNET_CMD_FAILED = -14, /* Command failed */
- BNET_CMD_OK = -15, /* Command succeeded */
- BNET_CMD_BEGIN = -16, /* Start command execution */
- BNET_MESSAGES_PENDING = -17, /* Messages pending */
- BNET_SERVER_READY = -18, /* Server ready and waiting */
- BNET_SELECT_INPUT = -19 /* Return selection input */
+ BNET_EOD = -1, /* End of data stream, new data may follow */
+ BNET_EOD_POLL = -2, /* End of data and poll all in one */
+ BNET_STATUS = -3, /* Send full status */
+ BNET_TERMINATE = -4, /* Conversation terminated, doing close() */
+ BNET_POLL = -5, /* Poll request, I'm hanging on a read */
+ BNET_HEARTBEAT = -6, /* Heartbeat Response requested */
+ BNET_HB_RESPONSE = -7, /* Only response permited to HB */
+ BNET_PROMPT = -8, /* Prompt for UA */
+ BNET_BTIME = -9, /* Send UTC btime */
+ BNET_BREAK = -10, /* Stop current command -- ctl-c */
+ BNET_START_SELECT = -11, /* Start of a selection list */
+ BNET_END_SELECT = -12, /* End of a select list */
+ BNET_INVALID_CMD = -13, /* Invalid command sent */
+ BNET_CMD_FAILED = -14, /* Command failed */
+ BNET_CMD_OK = -15, /* Command succeeded */
+ BNET_CMD_BEGIN = -16, /* Start command execution */
+ BNET_MSGS_PENDING = -17, /* Messages pending */
+ BNET_SERVER_READY = -18, /* Server ready and waiting */
+ BNET_SELECT_INPUT = -19, /* Return selection input */
+ BNET_WARNING_MSG = -20, /* Warning message */
+ BNET_ERROR_MSG = -21, /* Error message -- command failed */
+ BNET_INFO_MSG = -22, /* Info message -- status line */
+ BNET_RUN_CMD = -23 /* Run command follows */
};
#define BNET_SETBUF_READ 1 /* Arg for bnet_set_buffer_size */
#define BNET_SETBUF_WRITE 2 /* Arg for bnet_set_buffer_size */
-/* Return status from bnet_recv() */
+/*
+ * Return status from bnet_recv()
+ * Note, the HARDEOF and ERROR refer to comm status/problems
+ * rather than the BNET_xxx above, which are software signals.
+ */
enum {
BNET_SIGNAL = -1,
BNET_HARDEOF = -2,
-/*
- * Miscellaneous Bacula memory and thread safe routines
- * Generally, these are interfaces to system or standard
- * library routines.
- *
- * Bacula utility functions are in util.c
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2007 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.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
-
+/*
+ * Miscellaneous Bacula memory and thread safe routines
+ * Generally, these are interfaces to system or standard
+ * library routines.
+ *
+ * Bacula utility functions are in util.c
+ *
+ * Version $Id$
+ */
#include "bacula.h"
#ifdef HAVE_PWD_H
#endif
}
-
-
-
void *brealloc (void *buf, size_t size)
{
buf = realloc(buf, size);
return escaped_path;
}
-
#############################################################################
# Makefile for building: bat
-# Generated by qmake (2.01a) (Qt 4.2.1) on: Fri Mar 9 09:22:17 2007
+# Generated by qmake (2.01a) (Qt 4.2.1) on: Sat Mar 10 21:24:05 2007
# Project: bat.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile bat.pro
restore/brestore.cpp \
label/label.cpp \
run/run.cpp \
+ run/runcmd.cpp \
select/select.cpp moc/moc_mainwin.cpp \
moc/moc_console.cpp \
moc/moc_restore.cpp \
obj/brestore.o \
obj/label.o \
obj/run.o \
+ obj/runcmd.o \
obj/select.o \
obj/moc_mainwin.o \
obj/moc_console.o \
all: Makefile $(TARGET)
-$(TARGET): ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h ui_select.h $(OBJECTS)
+$(TARGET): ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h ui_runcmd.h ui_select.h $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
Makefile: bat.pro /usr/share/qt4/mkspecs/default/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \
dist:
@$(CHK_DIR_EXISTS) obj/bat1.0.0 || $(MKDIR) obj/bat1.0.0
- $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/bat1.0.0/ && $(COPY_FILE) --parents mainwin.h bat.h bat_conf.h qstd.h console/console.h restore/restore.h label/label.h run/run.h select/select.h obj/bat1.0.0/ && $(COPY_FILE) --parents main.qrc obj/bat1.0.0/ && $(COPY_FILE) --parents main.cpp bat_conf.cpp mainwin.cpp qstd.cpp console/authenticate.cpp console/console.cpp restore/prerestore.cpp restore/restore.cpp restore/brestore.cpp label/label.cpp run/run.cpp select/select.cpp obj/bat1.0.0/ && $(COPY_FILE) --parents main.ui label/label.ui console/console.ui restore/restore.ui restore/prerestore.ui restore/brestore.ui run/run.ui select/select.ui obj/bat1.0.0/ && (cd `dirname obj/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname obj/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r obj/bat1.0.0
+ $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/bat1.0.0/ && $(COPY_FILE) --parents mainwin.h bat.h bat_conf.h qstd.h console/console.h restore/restore.h label/label.h run/run.h select/select.h obj/bat1.0.0/ && $(COPY_FILE) --parents main.qrc obj/bat1.0.0/ && $(COPY_FILE) --parents main.cpp bat_conf.cpp mainwin.cpp qstd.cpp console/authenticate.cpp console/console.cpp restore/prerestore.cpp restore/restore.cpp restore/brestore.cpp label/label.cpp run/run.cpp run/runcmd.cpp select/select.cpp obj/bat1.0.0/ && $(COPY_FILE) --parents main.ui label/label.ui console/console.ui restore/restore.ui restore/prerestore.ui restore/brestore.ui run/run.ui run/runcmd.ui select/select.ui obj/bat1.0.0/ && (cd `dirname obj/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname obj/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r obj/bat1.0.0
yaccclean:
-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
-compiler_uic_make_all: ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h ui_select.h
+compiler_uic_make_all: ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h ui_runcmd.h ui_select.h
compiler_uic_clean:
- -$(DEL_FILE) ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h ui_select.h
+ -$(DEL_FILE) ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h ui_runcmd.h ui_select.h
ui_main.h: main.ui
/usr/bin/uic main.ui -o ui_main.h
ui_run.h: run/run.ui
/usr/bin/uic run/run.ui -o ui_run.h
+ui_runcmd.h: run/runcmd.ui
+ /usr/bin/uic run/runcmd.ui -o ui_runcmd.h
+
ui_select.h: select/select.ui
/usr/bin/uic select/select.ui -o ui_select.h
qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/run.o run/run.cpp
+obj/runcmd.o: run/runcmd.cpp bat.h \
+ mainwin.h \
+ ui_main.h \
+ label/label.h \
+ ui_label.h \
+ run/run.h \
+ ui_run.h \
+ restore/restore.h \
+ ui_brestore.h \
+ ui_restore.h \
+ ui_prerestore.h \
+ bat_conf.h \
+ qstd.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/runcmd.o run/runcmd.cpp
+
obj/select.o: select/select.cpp bat.h \
mainwin.h \
ui_main.h \
FORMS += label/label.ui
FORMS += console/console.ui
FORMS += restore/restore.ui restore/prerestore.ui restore/brestore.ui
-FORMS += run/run.ui
+FORMS += run/run.ui run/runcmd.ui
FORMS += select/select.ui
# Run dialog
HEADERS += run/run.h
-SOURCES += run/run.cpp
+SOURCES += run/run.cpp run/runcmd.cpp
# Select dialgo
HEADERS += select/select.h
m_notifier = new QSocketNotifier(m_sock->fd, QSocketNotifier::Read, 0);
QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(read_dir(int)));
- write(".api");
+ write(".api 1");
discardToPrompt();
beginNewCommand();
QStringList list;
int stat;
- setEnabled(false);
+ notify(false);
write(cmd);
while ((stat = read()) > 0) {
strip_trailing_junk(msg());
list << msg();
}
- setEnabled(true);
-// list.sort();
+ notify(true);
return list;
}
int stat;
char *def;
- setEnabled(false);
+ notify(false);
beginNewCommand();
scmd = QString(".defaults job=\"%1\"").arg(job_defs.job_name);
write(scmd);
job_defs.catalog_name.toUtf8().data(), job_defs.enabled);
#endif
- setEnabled(true);
+ notify(true);
return true;
bail_out:
- setEnabled(true);
+ notify(true);
return false;
}
mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png")));
QBrush redBrush(Qt::red);
m_consoleItem->setForeground(0, redBrush);
+ m_at_prompt = false;
}
}
{
int stat;
if (commDebug) Pmsg0(000, "DisplaytoPrompt\n");
- m_notifier->setEnabled(false);
- while ((stat = read()) > 0) {
- display_text(msg());
+ while (!m_at_prompt) {
+ if ((stat=read()) > 0) {
+ display_text(msg());
+ }
}
if (commDebug) Pmsg1(000, "endDisplaytoPrompt=%d\n", stat);
- m_notifier->setEnabled(true);
}
void Console::discardToPrompt()
{
int stat;
if (commDebug) Pmsg0(000, "discardToPrompt\n");
- m_notifier->setEnabled(false);
- while ((stat = read()) > 0) {
+ while (!m_at_prompt) {
+ stat = read();
}
if (commDebug) Pmsg1(000, "endDisplayToPrompt=%d\n", stat);
- m_notifier->setEnabled(true);
}
*/
int Console::read()
{
- int stat = BNET_HARDEOF;
+ int stat = 0;
while (m_sock) {
for (;;) {
stat = bnet_wait_data_intr(m_sock, 1);
break;
}
app->processEvents();
-// if (m_api_set && m_messages_pending) {
-// write_dir(".messages");
-// m_messages_pending = false;
-// }
+ if (m_api_set && m_messages_pending) {
+ write_dir(".messages");
+ m_messages_pending = false;
+ }
}
stat = m_sock->recv();
if (stat >= 0) {
m_at_prompt = false;
}
if (commDebug) Pmsg1(000, "got: %s", m_sock->msg);
-
}
switch (m_sock->msglen) {
case BNET_SERVER_READY:
-// if (m_api_set && m_messages_pending) {
-// write_dir(".messages");
-// m_messages_pending = false;
-// }
+ if (m_api_set && m_messages_pending) {
+ write_dir(".messages");
+ m_messages_pending = false;
+ }
m_at_prompt = true;
continue;
- case BNET_MESSAGES_PENDING:
+ case BNET_MSGS_PENDING:
+ if (commDebug) Pmsg0(000, "MSGS PENDING\n");
m_messages_pending = true;
continue;
+ case BNET_CMD_OK:
+ if (commDebug) Pmsg0(000, "CMD OK\n");
+ m_at_prompt = false;
+ continue;
case BNET_CMD_BEGIN:
+ if (commDebug) Pmsg0(000, "CMD BEGIN\n");
m_at_prompt = false;
continue;
case BNET_PROMPT:
- case BNET_CMD_OK:
- if (commDebug) Pmsg0(000, "CMD OK/PROMPT\n");
+ if (commDebug) Pmsg0(000, "PROMPT\n");
m_at_prompt = true;
mainWin->set_status(_("At prompt waiting for input ..."));
update_cursor();
break;
case BNET_CMD_FAILED:
if (commDebug) Pmsg0(000, "CMD FAIL\n");
- m_at_prompt = true;
mainWin->set_status(_("Command failed. At prompt waiting for input ..."));
update_cursor();
QApplication::restoreOverrideCursor();
break;
+ /* We should not get this one */
case BNET_EOD:
if (commDebug) Pmsg0(000, "EOD\n");
mainWin->set_status_ready();
case BNET_START_SELECT:
new selectDialog(this);
break;
+ case BNET_RUN_CMD:
+ new runCmdDialog(this);
+ break;
+ case BNET_ERROR_MSG:
+ m_sock->recv(); /* get the message */
+ display_text(msg());
+ QMessageBox::critical(this, "Error", msg(), QMessageBox::Ok);
+ break;
+ case BNET_WARNING_MSG:
+ m_sock->recv(); /* get the message */
+ display_text(msg());
+ QMessageBox::critical(this, "Warning", msg(), QMessageBox::Ok);
+ break;
+ case BNET_INFO_MSG:
+ m_sock->recv(); /* get the message */
+ display_text(msg());
+ mainWin->set_status(msg());
+ break;
}
if (is_bnet_stop(m_sock)) { /* error or term request */
m_sock->close();
m_notifier = NULL;
mainWin->set_status(_("Director disconnected."));
QApplication::restoreOverrideCursor();
+ stat = BNET_HARDEOF;
}
break;
}
}
}
-void Console::setEnabled(bool enable)
+/*
+ * When the notifier is enabled, read_dir() will automatically be
+ * called by the Qt event loop when ever there is any output
+ * from the Directory, and read_dir() will then display it on
+ * the console.
+ *
+ * When we are in a bat dialog, we want to control *all* output
+ * from the Directory, so we set notify to off.
+ * m_console->notifiy(false);
+ */
+void Console::notify(bool enable)
{
m_notifier->setEnabled(enable);
}
void writeSettings();
void readSettings();
char *msg();
- void setEnabled(bool enable);
+ void notify(bool enable);
QStringList get_list(char *cmd);
bool get_job_defaults(struct job_defaults &);
void terminate();
labelDialog::labelDialog(Console *console)
{
m_console = console;
+ m_console->notify(false);
setupUi(this);
storageCombo->addItems(console->storage_list);
poolCombo->addItems(console->pool_list);
.arg(poolCombo->currentText()).arg(slotSpin->value());
m_console->write_dir(scmd.toUtf8().data());
m_console->displayToPrompt();
+ m_console->notify(true);
delete this;
mainWin->resetFocus();
}
this->hide();
delete this;
mainWin->resetFocus();
+ m_console->notify(true);
}
<class>labelForm</class>
<widget class="QDialog" name="labelForm" >
<property name="windowModality" >
- <enum>Qt::ApplicationModal</enum>
+ <enum>Qt::WindowModal</enum>
</property>
<property name="geometry" >
<rect>
#include <QApplication>
#include "bat.h"
+bool commDebug = false;
+MainWin *mainWin;
+QApplication *app;
+
/* Forward referenced functions */
void terminate_console(int sig);
/* Static variables */
static char *configfile = NULL;
-MainWin *mainWin;
-QApplication *app;
-bool commDebug = false;
-
-
int main(int argc, char *argv[])
{
void MainWin::about()
{
QMessageBox::about(this, tr("About bat"),
- tr("<br><h2>bat 0.1</h2>"
+ tr("<br><h2>bat 0.2, by Kern Sibbald</h2>"
"<p>Copyright © " BYEAR " Free Software Foundation Europe e.V."
"<p>The <b>bat</b> is an administrative console"
" interface to the Director."));
prerestoreDialog::prerestoreDialog(Console *console)
{
m_console = console; /* keep compiler quiet */
+ m_console->notify(false);
setupUi(this);
jobCombo->addItems(console->job_list);
filesetCombo->addItems(console->fileset_list);
m_console->write(cmd);
m_console->display_text(cmd);
+ /* Note, do not turn notifier back on here ... */
new restoreDialog(m_console);
delete this;
}
{
mainWin->set_status("Canceled");
this->hide();
+ m_console->notify(true);
delete this;
}
<class>prerestoreForm</class>
<widget class="QDialog" name="prerestoreForm" >
<property name="windowModality" >
- <enum>Qt::ApplicationModal</enum>
+ <enum>Qt::WindowModal</enum>
</property>
<property name="geometry" >
<rect>
restoreDialog::restoreDialog(Console *console)
{
QStringList titles;
+
m_console = console;
-
- m_console->setEnabled(false);
+ m_console->notify(false); /* this should already be off */
+
setupUi(this);
connect(fileWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
this, SLOT(fileDoubleClicked(QTreeWidgetItem *, int)));
this->hide();
m_console->write("done");
delete this;
- m_console->setEnabled(true);
+ m_console->notify(true);
mainWin->resetFocus();
}
m_console->write("quit");
mainWin->set_status("Canceled");
delete this;
- m_console->setEnabled(true);
+ m_console->notify(true);
mainWin->resetFocus();
}
bsnprintf(cd_cmd, sizeof(cd_cmd), "cd \"%s\"", dir);
Dmsg2(100, "dir=%s cmd=%s\n", dir, cd_cmd);
m_console->write_dir(cd_cmd);
+ lineEdit->clear();
if ((stat = m_console->read()) > 0) {
m_cwd = m_console->msg();
- Dmsg2(100, "cwd=%s msg=%s\n", m_cwd.toUtf8().data(), m_console->msg());
+ lineEdit->insert(m_cwd);
+ Dmsg2(000, "cwd=%s msg=%s\n", m_cwd.toUtf8().data(), m_console->msg());
} else {
Dmsg1(000, "stat=%d\n", stat);
+ QMessageBox::critical(this, "Error", "cd command failed", QMessageBox::Ok);
}
m_console->discardToPrompt();
- lineEdit->clear();
- lineEdit->insert(m_cwd);
return true; /* ***FIXME*** return real status */
}
Dmsg2(100, "cwd=%s msg=%s\n", m_cwd.toUtf8().data(), m_console->msg());
} else {
Dmsg1(000, "stat=%d\n", stat);
+ QMessageBox::critical(this, "Error", ".pwd command failed", QMessageBox::Ok);
+ Dmsg1(000, "stat=%d\n", stat);
}
- m_console->displayToPrompt();
+ m_console->discardToPrompt();
return m_cwd.toUtf8().data();
}
<class>restoreForm</class>
<widget class="QDialog" name="restoreForm" >
<property name="windowModality" >
- <enum>Qt::ApplicationModal</enum>
+ <enum>Qt::WindowModal</enum>
</property>
<property name="geometry" >
<rect>
QDateTime dt;
m_console = console;
+ m_console->notify(false);
setupUi(this);
m_console->beginNewCommand();
jobCombo->addItems(console->job_list);
m_console->write_dir(cmd);
m_console->display_text(cmd);
m_console->displayToPrompt();
+ m_console->notify(true);
delete this;
mainWin->resetFocus();
}
{
mainWin->set_status(" Canceled");
this->hide();
+ m_console->notify(true);
delete this;
mainWin->resetFocus();
}
};
+class runCmdDialog : public QDialog, public Ui::runForm
+{
+ Q_OBJECT
+
+public:
+ runCmdDialog(Console *console);
+
+public slots:
+ void accept();
+ void reject();
+
+private:
+ Console *m_console;
+
+};
+
+
#endif /* _RUN_H_ */
<class>runForm</class>
<widget class="QDialog" name="runForm" >
<property name="windowModality" >
- <enum>Qt::ApplicationModal</enum>
+ <enum>Qt::WindowModal</enum>
</property>
<property name="geometry" >
<rect>
--- /dev/null
+/*
+ Bacula® - The Network Backup Solution
+
+ Copyright (C) 2007-2007 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.
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version two of the GNU General Public
+ License as published by the Free Software Foundation plus additions
+ that are listed in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ 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
+ 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.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
+
+/*
+ * Run Command Dialog class
+ *
+ * Kern Sibbald, March MMVII
+ *
+ * $Id: $
+ */
+
+#include "bat.h"
+#include "run.h"
+
+/*
+ * Setup all the combo boxes and display the dialog
+ */
+runCmdDialog::runCmdDialog(Console *console)
+{
+ QDateTime dt;
+
+ m_console = console;
+ m_console->notify(false);
+ setupUi(this);
+ this->show();
+}
+
+void runCmdDialog::accept()
+{
+
+ this->hide();
+
+ m_console->write_dir("yes");
+ m_console->displayToPrompt();
+ m_console->notify(true);
+ delete this;
+ mainWin->resetFocus();
+}
+
+
+void runCmdDialog::reject()
+{
+ mainWin->set_status(" Canceled");
+ this->hide();
+ m_console->notify(true);
+ delete this;
+ mainWin->resetFocus();
+}
--- /dev/null
+<ui version="4.0" >
+ <class>runCmdForm</class>
+ <widget class="QDialog" name="runCmdForm" >
+ <property name="windowModality" >
+ <enum>Qt::NonModal</enum>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>590</width>
+ <height>395</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Run Job Command</string>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>9</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="4" column="0" >
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Maximum</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>572</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Maximum</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>572</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0" >
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="6" column="1" >
+ <widget class="QDateTimeEdit" name="dateTimeEdit" >
+ <property name="dateTime" >
+ <datetime>
+ <hour>0</hour>
+ <minute>2</minute>
+ <second>0</second>
+ <year>2000</year>
+ <month>1</month>
+ <day>1</day>
+ </datetime>
+ </property>
+ <property name="displayFormat" >
+ <string>yyyy-mm-dd hh:mm:ss</string>
+ </property>
+ <property name="calendarPopup" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>When:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>dateTimeEdit</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0" >
+ <widget class="QLabel" name="label_5" >
+ <property name="text" >
+ <string>Bootstrap:</string>
+ </property>
+ <property name="openExternalLinks" >
+ <bool>true</bool>
+ </property>
+ <property name="buddy" >
+ <cstring>where</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0" >
+ <widget class="QLabel" name="label_12" >
+ <property name="text" >
+ <string>Where:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>bootstrap</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QComboBox" name="clientCombo" />
+ </item>
+ <item row="4" column="1" >
+ <widget class="QComboBox" name="catalogCombo" />
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_6" >
+ <property name="text" >
+ <string>Job:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>jobCombo</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="1" >
+ <widget class="QLineEdit" name="where" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="readOnly" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Storage:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>storageCombo</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_9" >
+ <property name="text" >
+ <string>FileSet:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>filesetCombo</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1" >
+ <widget class="QLineEdit" name="bootstrap" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="readOnly" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QComboBox" name="filesetCombo" />
+ </item>
+ <item row="3" column="1" >
+ <widget class="QComboBox" name="storageCombo" />
+ </item>
+ <item row="0" column="1" >
+ <widget class="QComboBox" name="jobCombo" />
+ </item>
+ <item row="5" column="0" >
+ <widget class="QLabel" name="label_13" >
+ <property name="text" >
+ <string>Replace:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1" >
+ <widget class="QComboBox" name="replaceCombo" />
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_8" >
+ <property name="text" >
+ <string>Client:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>clientCombo</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" >
+ <widget class="QLabel" name="label_10" >
+ <property name="text" >
+ <string>Catalog:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>catalogCombo</cstring>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="1" column="1" >
+ <widget class="QSpinBox" name="prioritySpin" >
+ <property name="maximum" >
+ <number>10000</number>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ <property name="value" >
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QComboBox" name="typeCombo" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>150</width>
+ <height>0</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>Priority:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>prioritySpin</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_7" >
+ <property name="text" >
+ <string>Type:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>typeCombo</cstring>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>171</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0" >
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>131</width>
+ <height>25</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="run" >
+ <property name="maximumSize" >
+ <size>
+ <width>16777215</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>runCmdForm</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>258</x>
+ <y>480</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>runCmdForm</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>326</x>
+ <y>480</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
*/
#undef VERSION
-#define VERSION "2.1.4"
-#define BDATE "06 March 2007"
-#define LSMDATE "06Mar07"
+#define VERSION "2.1.5"
+#define BDATE "10 March 2007"
+#define LSMDATE "10Mar07"
#define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n"
#define BYEAR "2007" /* year for copyright messages in progs */
Technical notes on version 2.1
General:
+10Mar07
+kes Extend new GUI API.
+kes Make the ua structure a class, and implement send_msg(),
+ error_msg(), warning_msg(), and info_msg().
08Mar07
kes Apply fix from for building wx-console on the Mac from
bug #798.