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_PROMPT = -8, /* 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_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_MAIN_PROMPT = -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 */
setupUi(this);
m_sock = NULL;
m_at_prompt = false;
+ m_at_main_prompt = false;
m_textEdit = textEdit; /* our console screen */
m_cursor = new QTextCursor(m_textEdit->document());
mainWin->actionConnect->setIcon(QIcon(":images/disconnected.png"));
/* Check for messages every 5 seconds */
-// m_timer = new QTimer(this);
-// QWidget::connect(m_timer, SIGNAL(timeout()), this, SLOT(poll_messages()));
-// m_timer->start(5000);
+ m_timer = new QTimer(this);
+ QWidget::connect(m_timer, SIGNAL(timeout()), this, SLOT(poll_messages()));
+ m_timer->start(5000);
}
Console::~Console()
void Console::poll_messages()
{
m_messages_pending = true;
+ if (m_at_main_prompt) {
+ write(".messages");
+ displayToPrompt();
+ }
}
/* Terminate any open socket */
m_sock->close();
m_sock = NULL;
}
-// m_timer->stop();
+ m_timer->stop();
}
/*
notify(false);
write(cmd);
while ((stat = read()) > 0) {
+ if (g_displayAll) display_text(msg());
strip_trailing_junk(msg());
results << msg();
}
pm_strcat(cmd, "\"");
write(cmd.c_str());
while ((stat = read()) > 0) {
+ if (g_displayAll) display_text(msg());
strip_trailing_junk(msg());
results << msg();
}
scmd = QString(".defaults job=\"%1\"").arg(job_defs.job_name);
write(scmd);
while ((stat = read()) > 0) {
+ if (g_displayAll) display_text(msg());
def = strchr(msg(), '=');
if (!def) {
continue;
QTreeWidgetItem *item = mainWin->getFromHash(this);
item->setForeground(0, redBrush);
m_at_prompt = false;
+ m_at_main_prompt = false;
}
}
{
m_sock->msglen = pm_strcpy(m_sock->msg, msg);
m_at_prompt = false;
- if (commDebug) Pmsg1(000, "send: %s\n", msg);
+ m_at_main_prompt = false;
+ if (g_commDebug) Pmsg1(000, "send: %s\n", msg);
return m_sock->send();
}
{
write(".\n");
while (read() > 0) {
+ if (g_displayAll) display_text(msg());
}
write(".\n");
while (read() > 0) {
+ if (g_displayAll) display_text(msg());
}
write(".\n");
while (read() > 0) {
+ if (g_displayAll) display_text(msg());
}
display_text("\n");
}
void Console::displayToPrompt()
{
int stat;
- if (commDebug) Pmsg0(000, "DisplaytoPrompt\n");
+ if (g_commDebug) Pmsg0(000, "DisplaytoPrompt\n");
while (!m_at_prompt) {
if ((stat=read()) > 0) {
display_text(msg());
}
}
- if (commDebug) Pmsg1(000, "endDisplaytoPrompt=%d\n", stat);
+ if (g_commDebug) Pmsg1(000, "endDisplaytoPrompt=%d\n", stat);
}
void Console::discardToPrompt()
{
int stat;
- if (commDebug) Pmsg0(000, "discardToPrompt\n");
+ if (g_commDebug) Pmsg0(000, "discardToPrompt\n");
while (!m_at_prompt) {
- stat = read();
+ if ((stat=read()) > 0) {
+ if (g_displayAll) display_text(msg());
+ }
}
- if (commDebug) Pmsg1(000, "endDisplayToPrompt=%d\n", stat);
+ if (g_commDebug) Pmsg1(000, "endDisplayToPrompt=%d\n", stat);
}
if (m_at_prompt) {
display_text("\n");
m_at_prompt = false;
+ m_at_main_prompt = false;
}
- if (commDebug) Pmsg1(000, "got: %s", m_sock->msg);
+ if (g_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;
- }
- m_at_prompt = true;
- continue;
case BNET_MSGS_PENDING:
- if (commDebug) Pmsg0(000, "MSGS PENDING\n");
- m_messages_pending = true;
+ if (g_commDebug) Pmsg0(000, "MSGS PENDING\n");
+ write_dir(".messages");
+ displayToPrompt();
+ m_messages_pending = false;
continue;
case BNET_CMD_OK:
- if (commDebug) Pmsg0(000, "CMD OK\n");
+ if (g_commDebug) Pmsg0(000, "CMD OK\n");
m_at_prompt = false;
+ m_at_main_prompt = false;
continue;
case BNET_CMD_BEGIN:
- if (commDebug) Pmsg0(000, "CMD BEGIN\n");
+ if (g_commDebug) Pmsg0(000, "CMD BEGIN\n");
m_at_prompt = false;
+ m_at_main_prompt = false;
continue;
+ case BNET_MAIN_PROMPT:
+ if (g_commDebug) Pmsg0(000, "PROMPT\n");
+ m_at_prompt = true;
+ m_at_main_prompt = true;
+ mainWin->set_status(_("At prompt waiting for input ..."));
+ update_cursor();
+ QApplication::restoreOverrideCursor();
+ break;
case BNET_PROMPT:
- if (commDebug) Pmsg0(000, "PROMPT\n");
+ if (g_commDebug) Pmsg0(000, "PROMPT\n");
m_at_prompt = true;
+ m_at_main_prompt = false;
mainWin->set_status(_("At prompt waiting for input ..."));
update_cursor();
QApplication::restoreOverrideCursor();
break;
case BNET_CMD_FAILED:
- if (commDebug) Pmsg0(000, "CMD FAIL\n");
+ if (g_commDebug) Pmsg0(000, "CMD FAIL\n");
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");
+ if (g_commDebug) Pmsg0(000, "EOD\n");
mainWin->set_status_ready();
update_cursor();
QApplication::restoreOverrideCursor();
int stat;
(void)fd;
- if (commDebug) Pmsg0(000, "read_dir\n");
+ if (g_commDebug) Pmsg0(000, "read_dir\n");
while ((stat = read()) >= 0) {
display_text(msg());
}