if (is_bnet_stop(UA_sock)) {
break; /* error or term */
} else if (stat == BNET_SIGNAL) {
- if (UA_sock->msglen == BNET_PROMPT) {
+ if (UA_sock->msglen == BNET_SUB_PROMPT) {
at_prompt = true;
}
Dmsg1(100, "Got poll %s\n", bnet_sig_to_ascii(UA_sock));
int update_pool_references(JCR *jcr, B_DB *db, POOL *pool);
/* ua_input.c */
-int get_cmd(UAContext *ua, const char *prompt);
+int get_cmd(UAContext *ua, const char *prompt, bool subprompt=false);
bool get_pint(UAContext *ua, const char *prompt);
bool get_yesno(UAContext *ua, const char *prompt);
bool is_yesno(char *val, int *ret);
/* Exported functions */
-int get_cmd(UAContext *ua, const char *prompt)
+/*
+ * If subprompt is set, we send a BNET_SUB_PROMPT signal otherwise
+ * send a BNET_TEXT_INPUT signal.
+ */
+int get_cmd(UAContext *ua, const char *prompt, bool subprompt)
{
BSOCK *sock = ua->UA_sock;
int stat;
if (!sock || ua->batch) { /* No UA or batch mode */
return 0;
}
+ if (!subprompt) {
+ sock->signal(BNET_TEXT_INPUT);
+ }
sock->fsend("%s", prompt);
- sock->signal(BNET_PROMPT); /* request more input */
+ if (subprompt) {
+ sock->signal(BNET_SUB_PROMPT);
+ }
for ( ;; ) {
stat = sock->recv();
if (stat == BNET_SIGNAL) {
ua->send_msg(_("cwd is: %s\n"), cwd);
for ( ;; ) {
int found, len, i;
- if (!get_cmd(ua, "$ ")) {
+ if (!get_cmd(ua, "$ ", true)) {
break;
}
if (ua->api) user->signal(BNET_CMD_BEGIN);
return "BNET_HEARTBEAT";
case BNET_HB_RESPONSE:
return "BNET_HB_RESPONSE";
- case BNET_PROMPT:
- return "BNET_PROMPT";
+ case BNET_SUB_PROMPT:
+ return "BNET_SUB_PROMPT";
+ case BNET_TEXT_INPUT:
+ return "BNET_TEXT_INPUT";
default:
sprintf(buf, _("Unknown sig %d"), (int)bs->msglen);
return buf;
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 subcommand */
+ BNET_xxxxxxPROMPT = -8, /* No longer used -- Prompt for subcommand */
BNET_BTIME = -9, /* Send UTC btime */
BNET_BREAK = -10, /* Stop current command -- ctl-c */
BNET_START_SELECT = -11, /* Start of a selection list */
BNET_RUN_CMD = -23, /* Run command follows */
BNET_YESNO = -24, /* Request yes no response */
BNET_START_RTREE = -25, /* Start restore tree mode */
- BNET_END_RTREE = -26 /* End restore tree mode */
+ BNET_END_RTREE = -26, /* End restore tree mode */
+ BNET_SUB_PROMPT = -27, /* Indicate we are at a subprompt */
+ BNET_TEXT_INPUT = -28 /* Get text input from user */
};
#define BNET_SETBUF_READ 1 /* Arg for bnet_set_buffer_size */
goto bail_out;
}
- if (mainWin->m_connDebug) {
- Pmsg2(000, "DirComm %i connecting %s\n", m_conn, m_console->m_dir->name());
- }
+ if (mainWin->m_connDebug)Pmsg2(000, "DirComm %i connecting %s\n", m_conn, m_console->m_dir->name());
memset(jcr, 0, sizeof(JCR));
mainWin->set_statusf(_("Connecting to Director %s:%d"), m_console->m_dir->address, m_console->m_dir->DIRport);
if (!cons->tls_ctx) {
m_console->display_textf(_("Failed to initialize TLS context for Console \"%s\".\n"),
m_console->m_dir->name());
- if (mainWin->m_connDebug)
+ if (mainWin->m_connDebug) {
Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Console %s\n", m_conn, m_console->m_dir->name());
+ }
goto bail_out;
}
}
m_console->display_textf(_("Failed to initialize TLS context for Director \"%s\".\n"),
m_console->m_dir->name());
mainWin->set_status("Connection failed");
- if (mainWin->m_connDebug)
+ if (mainWin->m_connDebug) {
Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Director %s\n", m_conn, m_console->m_dir->name());
+ }
goto bail_out;
}
}
NULL, m_console->m_dir->DIRport, 0);
if (m_sock == NULL) {
mainWin->set_status("Connection failed");
- if (mainWin->m_connDebug)
+ if (mainWin->m_connDebug) {
Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name());
+ }
goto bail_out;
} else {
/* Update page selector to green to indicate that Console is connected */
if (!authenticate_director(jcr, m_console->m_dir, cons, buf, sizeof(buf))) {
m_console->display_text(buf);
- if (mainWin->m_connDebug)
+ if (mainWin->m_connDebug) {
Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name());
+ }
goto bail_out;
}
* Set up input notifier
*/
m_notifier = new QSocketNotifier(m_sock->m_fd, QSocketNotifier::Read, 0);
- QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(read_dir(int)));
- m_notifier->setEnabled(false);
+ QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(notify_read_dir(int)));
+ m_notifier->setEnabled(true);
write(".api 1");
m_api_set = true;
mainWin->set_status(_("At main prompt waiting for input ..."));
}
break;
- case BNET_PROMPT:
- if (mainWin->m_commDebug) Pmsg2(000, "conn %i PROMPT m_in_select %i\n", m_conn, m_in_select);
+ case BNET_SUB_PROMPT:
+ if (mainWin->m_commDebug) Pmsg2(000, "conn %i SUB_PROMPT m_in_select=%d\n", m_conn, m_in_select);
m_at_prompt = true;
m_at_main_prompt = false;
mainWin->set_status(_("At prompt waiting for input ..."));
- /***** FIXME *****/
- /* commented out until the prompt communication issue with the director is resolved
- * This is where I call a new text input dialog class to prevent the connection issues
- * when a text input is requited.
- * if (!m_in_select) {
- * new textInputDialog(m_console, m_conn);
- * }
- */
+ break;
+ case BNET_TEXT_INPUT:
+ if (mainWin->m_commDebug) Pmsg4(000, "conn %i TEXT_INPUT at_prompt=%d m_in_select=%d notify=%d\n",
+ m_conn, m_at_prompt, m_in_select, is_notify_enabled());
+ if (!m_in_select && is_notify_enabled()) {
+ mainWin->waitExit();
+ new textInputDialog(m_console, m_conn);
+ } else {
+ if (mainWin->m_commDebug) Pmsg0(000, "!m_in_select && is_notify_enabled\n");
+ m_at_prompt = true;
+ m_at_main_prompt = false;
+ mainWin->set_status(_("At prompt waiting for input ..."));
+ }
break;
case BNET_CMD_FAILED:
if (mainWin->m_commDebug) Pmsg1(000, "CMD FAILED\n", m_conn);
mainWin->set_status(msg());
break;
}
+
+ if (!m_sock) {
+ stat = BNET_HARDEOF;
+ return stat;
+ }
if (is_bnet_stop(m_sock)) { /* error or term request */
if (mainWin->m_commDebug) Pmsg1(000, "conn %i BNET STOP\n", m_conn);
m_console->stopTimer();
}
/* Called by signal when the Director has output for us */
-void DirComm::read_dir(int /* fd */)
+void DirComm::notify_read_dir(int /* fd */)
{
int stat;
+ if (!mainWin->m_notify) {
+ return;
+ }
if (mainWin->m_commDebug) Pmsg1(000, "enter read_dir conn %i read_dir\n", m_conn);
stat = m_sock->wait_data(0, 5000);
if (stat > 0) {
bool DirComm::notify(bool enable)
{
bool prev_enabled = false;
+ /* Set global flag */
+ mainWin->m_notify = enable;
if (m_notifier) {
prev_enabled = m_notifier->isEnabled();
- m_notifier->setEnabled(enable);
- if (mainWin->m_connDebug) {
- Pmsg3(000, "conn=%i notify=%d prev=%d\n", m_conn, enable, prev_enabled);
+ if (prev_enabled != enable) {
+ m_notifier->setEnabled(enable);
}
- } else if (mainWin->m_connDebug)
+ if (mainWin->m_connDebug) Pmsg3(000, "conn=%i notify=%d prev=%d\n", m_conn, enable, prev_enabled);
+ } else if (mainWin->m_connDebug) {
Pmsg2(000, "m_notifier does not exist: %i %s\n", m_conn, m_console->m_dir->name());
+ }
return prev_enabled;
}
bool DirComm::is_notify_enabled() const
{
- bool enabled = false;
- if (m_notifier) {
- enabled = m_notifier->isEnabled();
- }
- return enabled;
+ return mainWin->m_notify;
}
/*
int write(QString msg);
public slots:
- void read_dir(int fd);
+ void notify_read_dir(int fd);
private:
BSOCK *m_sock;
{
int conn;
+ /* Do not poll if notifier off */
+ if (!mainWin->m_notify) {
+ return;
+ }
+
/*
* Note if we call getDirComm here, we continuously consume
* file descriptors.
{
int conn;
if (!getDirComm(conn)) {
- if (mainWin->m_connDebug) {
- Pmsg0(000, "call newDirComm\n");
- }
+ if (mainWin->m_connDebug) Pmsg0(000, "call newDirComm\n");
if (!newDirComm(conn)) {
Emsg1(M_ABORT, 0, "Failed to connect to %s for populateLists.\n", m_dir->name());
return;
mainWin->waitEnter();
DirComm *dircomm = m_dircommHash.value(conn);
int stat;
+ bool prev_notify = mainWin->m_notify;
if (mainWin->m_connDebug) {
QString dbgmsg = QString("dir_cmd conn %1 %2 %3\n").arg(conn).arg(m_dir->name()).arg(cmd);
results << dircomm->msg();
}
if (stat > 0 && mainWin->m_displayAll) display_text(dircomm->msg());
- notify(conn, true);
+ if (prev_notify) {
+ notify(conn, true); /* turn it back on */
+ }
discardToPrompt(conn);
mainWin->waitExit();
- return true; /* ***FIXME*** return any command error */
+ return true; /* ***FIXME*** return any command error */
}
/*
DirComm *dircomm = m_dircommHash.value(conn);
int stat;
POOL_MEM cmd(PM_MESSAGE);
+ bool prev_notify = mainWin->m_notify;
if (!is_connectedGui()) {
return false;
}
first = false;
}
- if (donotify) {
+ if (donotify && prev_notify) {
dircomm->notify(true);
}
discardToPrompt(conn);
QString scmd;
int stat;
char *def;
+ bool prev_notify = mainWin->m_notify;
+ bool rtn = false;
- if (donotify)
+ if (donotify) {
conn = notifyOff();
+ }
beginNewCommand(conn);
DirComm *dircomm = m_dircommHash.value(conn);
bool prevWaitState = mainWin->getWaitState();
continue;
}
}
-
- if (donotify)
- notify(conn, true);
- if (!prevWaitState)
- mainWin->waitExit();
- return true;
-
+ rtn = true;
+ /* Fall through wanted */
bail_out:
- if (donotify)
+ if (donotify && prev_notify) {
notify(conn, true);
- if (!prevWaitState)
+ }
+ if (!prevWaitState) {
mainWin->waitExit();
- return false;
+ }
+ return rtn;
}
int stat = 0;
text = "";
+ dircomm->read();
+ text += dircomm->msg();
if (mainWin->m_commDebug) Pmsg1(000, "returnFromPrompt %s\n", m_dir->name());
while (!dircomm->m_at_prompt) {
if ((stat=dircomm->read()) > 0) {
if (findDirComm(conn)) {
return true;
}
- if (mainWin->m_connDebug) {
- Pmsg0(000, "call newDirComm\n");
- }
+ if (mainWin->m_connDebug) Pmsg0(000, "call newDirComm\n");
return newDirComm(conn);
}
foreach(Console *console, m_consoleHash) {
console->connect_dir();
}
+ /*
+ * Note, the notifier is now a global flag, although each notifier
+ * can be individually turned on and off at a socket level. Once
+ * the notifier is turned off, we don't accept anything from anyone
+ * this prevents unwanted messages from getting into the input
+ * dialogs such as restore that read from the director and "know"
+ * what to expect.
+ */
+ m_notify = true;
m_currentConsole = (Console*)getFromHash(m_firstItem);
QTimer::singleShot(2000, this, SLOT(popLists()));
if (m_miscDebug) {
*/
void MainWin::waitEnter()
{
- if (m_waitState){
- if (mainWin->m_connDebug)
- Pmsg0(000, "Should Never Get Here DANGER DANGER, for now I'll return\n");
+ if (m_waitState || m_isClosing) {
return;
}
m_waitState = true;
if (!m_waitState || m_isClosing) {
return;
}
- m_waitState = false;
if (mainWin->m_connDebug) Pmsg0(000, "Exiting Wait State\n");
if (m_waitTreeItem && (m_waitTreeItem != treeWidget->currentItem())) {
treeWidget->setCurrentItem(m_waitTreeItem);
connectConsoleSignals();
}
app->restoreOverrideCursor();
+ m_waitState = false;
}
void MainWin::connectConsoleSignals()
bool m_openPlot;
bool m_openDirStat;
+ /* Global */
+ bool m_notify; /* global flag to turn on/off all notifiers */
+
public slots:
void input_line();
void about();
*/
/*
- * Version $Id$
- *
* preRestore -> dialog put up to determine the restore type
*
* Kern Sibbald, February MMVII
this->hide();
+
cmd = QString("restore");
cmd += " fileset=\"" + filesetCombo->currentText() + "\"";
cmd += " client=\"" + clientCombo->currentText() + "\"";
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-2010 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.
*
* Kern Sibbald, March MMVII
*
- * $Id$
*/
#include "bat.h"
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-2010 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.
*
* Kern Sibbald, March MMVII
*
- * $Id: select.cpp 8775 2009-04-30 16:57:18Z bartleyd2 $
*/
#include "bat.h"
QDateTime dt;
m_console = console;
+ m_console->notify(m_conn, false);
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
- labelWidget->setText(m_console->returnFromPrompt(m_conn));
+ m_console->read(m_conn); /* get title */
+ labelWidget->setText(m_console->msg(m_conn));
this->show();
}
{
this->hide();
m_console->write_dir(m_conn, lineEdit->text().toUtf8().data());
- m_console->displayToPrompt(m_conn);
+ /* Do not displayToPrompt because there may be another Text Input required */
+ this->close();
mainWin->resetFocus();
- m_console->displayToPrompt(m_conn);
m_console->notify(m_conn, true);
- this->close();
}
{
this->hide();
mainWin->set_status(tr(" Canceled"));
+ m_console->write_dir(m_conn, ".");
+ this->close();
mainWin->resetFocus();
m_console->beginNewCommand(m_conn);
m_console->notify(m_conn, true);
- this->close();
}
-