}
app->processEvents();
if (m_api_set && m_console->is_messagesPending() && is_notify_enabled() && m_console->hasFocus()) {
- m_console->write_dir(m_conn, ".messages");
+ m_console->write_dir(m_conn, ".messages", false);
m_console->messagesPending(false);
}
}
case BNET_MSGS_PENDING :
if (is_notify_enabled() && m_console->hasFocus()) {
if (mainWin->m_commDebug) Pmsg1(000, "conn %i MSGS PENDING\n", m_conn);
- m_console->write_dir(m_conn, ".messages");
+ m_console->write_dir(m_conn, ".messages", false);
m_console->displayToPrompt(m_conn);
m_console->messagesPending(false);
}
return;
DirComm *dircomm = m_dircommHash.value(conn);
- if (mainWin->m_checkMessages && dircomm->m_at_main_prompt && hasFocus()){
+ if (mainWin->m_checkMessages && dircomm->m_at_main_prompt && hasFocus() && !mainWin->getWaitState()){
messagesPending(true);
dircomm->write(".messages");
displayToPrompt(conn);
return true; /* ***FIXME*** return any command error */
}
-/* Send a command to the Director */
+/*
+ * Overloads for
+ * Sending a command to the Director
+ */
int Console::write_dir(const char *msg)
{
int conn;
return conn;
}
-/* Send a command to the Director */
+int Console::write_dir(const char *msg, bool dowait)
+{
+ int conn;
+ if (availableDirComm(conn))
+ write_dir(conn, msg, dowait);
+ return conn;
+}
+
void Console::write_dir(int conn, const char *msg)
+{
+ write_dir(conn, msg, true);
+}
+
+/*
+ * Send a command to the Director
+ */
+void Console::write_dir(int conn, const char *msg, bool dowait)
{
DirComm *dircomm = m_dircommHash.value(conn);
if (dircomm->m_sock) {
mainWin->set_status(_("Processing command ..."));
- mainWin->waitEnter();
+ if (dowait)
+ mainWin->waitEnter();
dircomm->write(msg);
- mainWin->waitExit();
+ if (dowait)
+ mainWin->waitExit();
} else {
mainWin->set_status( tr(" Director not connected. Click on connect button."));
mainWin->actionConnect->setIcon(QIcon(":images/disconnected.png"));
/* Position cursor to end of screen */
void Console::update_cursor()
{
-// QApplication::restoreOverrideCursor();
m_textEdit->moveCursor(QTextCursor::End);
m_textEdit->ensureCursorVisible();
}
bool sql_cmd(int &conn, QString &cmd, QStringList &results);
bool sql_cmd(int &conn, const char *cmd, QStringList &results, bool donotify);
int write_dir(const char *buf);
+ int write_dir(const char *buf, bool dowait);
void write_dir(int conn, const char *buf);
+ void write_dir(int conn, const char *buf, bool dowait);
void getDirResName(QString &);
void setDirRes(DIRRES *dir);
void writeSettings();
*/
void MainWin::waitEnter()
{
+ if (m_waitState){
+ if (mainWin->m_connDebug)
+ Pmsg0(000, "Should Never Get Here DANGER DANGER, for now I'll return\n");
+ return;
+ }
m_waitState = true;
if (mainWin->m_connDebug)
Pmsg0(000, "Entering Wait State\n");
QString cmdStr = lineEdit->text(); /* Get the text */
lineEdit->clear(); /* clear the lineEdit box */
if (m_currentConsole->is_connected()) {
- /* Use consoleInput to allow typing anything */
- m_currentConsole->consoleInput(cmdStr);
+ /* Use consoleCommand to allow typing anything */
+ m_currentConsole->consoleCommand(cmdStr);
} else {
set_status(tr("Director not connected. Click on connect button."));
}
*/
void Pages::consoleCommand(QString &command)
{
- consoleInput(command);
+ int conn;
+ if (m_console->availableDirComm(conn)) {
+ consoleCommand(command, conn);
+ }
}
-
-/*
- * Function to simplify executing a console command, but does not
- * check for the connection in use. We need this so that we can
- * *always* enter command from the command line.
- */
-void Pages::consoleInput(QString &command)
+void Pages::consoleCommand(QString &command, int conn)
{
- int conn;
/* Bring this director's console to the front of the stack */
setConsoleCurrent();
QString displayhtml("<font color=\"blue\">");
displayhtml += command + "</font>\n";
m_console->display_html(displayhtml);
m_console->display_text("\n");
- conn = m_console->write_dir(command.toUtf8().data());
+ mainWin->waitEnter();
+ m_console->write_dir(conn, command.toUtf8().data(), false);
m_console->displayToPrompt(conn);
+ mainWin->waitExit();
}
/*
void setContextMenuDockText();
void setTreeWidgetItemDockColor();
void consoleCommand(QString &);
- void consoleInput(QString &);
+ void consoleCommand(QString &, int conn);
QString &name() { return m_name; };
void getVolumeList(QStringList &);
void getStatusList(QStringList &);
if (selectFilesRadio->isChecked()) {
setConsoleCurrent();
closeStackPage();
+ /* wait will be exited in the restore page constructor */
+ mainWin->waitEnter();
} else {
closeStackPage();
mainWin->resetFocus();
get_cwd();
readSettings();
+ /* wait was entered from pre-restore
+ * will exit, but will reenter in fillDirectory */
+ mainWin->waitExit();
fillDirectory();
dockPage();
setCurrent();
*/
void restorePage::fillDirectory()
{
+ mainWin->waitEnter();
char modes[20], user[20], group[20], size[20], date[30];
char marked[10];
int pnl, fnl;
POOLMEM *path = get_pool_memory(PM_FNAME);
fileWidget->clear();
- m_console->write_dir(m_conn, "dir");
+ m_console->write_dir(m_conn, "dir", false);
QList<QTreeWidgetItem *> treeItemList;
QStringList item;
while (m_console->read(m_conn) > 0) {
free_pool_memory(file);
free_pool_memory(path);
+ mainWin->waitExit();
}
/*
void restorePage::okButtonPushed()
{
-// printf("In restorePage::okButtonPushed\n");
this->hide();
m_console->write(m_conn, "done");
m_console->notify(m_conn, true);
char cmd[1000];
statusLine->setText("");
if (column == 0) { /* mark/unmark */
+ mainWin->waitEnter();
if (item->data(0, Qt::UserRole).toBool()) {
bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
item->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
item->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
item->setData(0, Qt::UserRole, true);
}
- m_console->write_dir(m_conn, cmd);
+ m_console->write_dir(m_conn, cmd, false);
if (m_console->read(m_conn) > 0) {
strip_trailing_junk(m_console->msg(m_conn));
statusLine->setText(m_console->msg(m_conn));
}
m_console->displayToPrompt(m_conn);
+ mainWin->waitExit();
return;
}
/*
*/
void restorePage::markButtonPushed()
{
+ mainWin->waitEnter();
QList<QTreeWidgetItem *> treeItemList = fileWidget->selectedItems();
QTreeWidgetItem *item;
char cmd[1000];
count++;
bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
item->setIcon(0, QIcon(QString::fromUtf8(":images/check.png")));
- m_console->write_dir(m_conn, cmd);
+ m_console->write_dir(m_conn, cmd, false);
if (m_console->read(m_conn) > 0) {
strip_trailing_junk(m_console->msg(m_conn));
statusLine->setText(m_console->msg(m_conn));
mainWin->set_status("Nothing selected, nothing done");
statusLine->setText("Nothing selected, nothing done");
}
-
+ mainWin->waitExit();
}
/*
*/
void restorePage::unmarkButtonPushed()
{
+ mainWin->waitEnter();
QList<QTreeWidgetItem *> treeItemList = fileWidget->selectedItems();
QTreeWidgetItem *item;
char cmd[1000];
count++;
bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
item->setIcon(0, QIcon(QString::fromUtf8(":images/unchecked.png")));
- m_console->write_dir(m_conn, cmd);
+ m_console->write_dir(m_conn, cmd, false);
if (m_console->read(m_conn) > 0) {
strip_trailing_junk(m_console->msg(m_conn));
statusLine->setText(m_console->msg(m_conn));
mainWin->set_status(tr("Nothing selected, nothing done"));
statusLine->setText(tr("Nothing selected, nothing done"));
}
-
+ mainWin->waitExit();
}
/*
int stat;
char cd_cmd[MAXSTRING];
+ mainWin->waitEnter();
statusLine->setText("");
bsnprintf(cd_cmd, sizeof(cd_cmd), "cd \"%s\"", dir);
Dmsg2(dbglvl, "dir=%s cmd=%s\n", dir, cd_cmd);
- m_console->write_dir(m_conn, cd_cmd);
+ m_console->write_dir(m_conn, cd_cmd, false);
lineEdit->clear();
if ((stat = m_console->read(m_conn)) > 0) {
m_cwd = m_console->msg(m_conn);
QMessageBox::critical(this, "Error", tr("cd command failed"), QMessageBox::Ok);
}
m_console->discardToPrompt(m_conn);
+ mainWin->waitExit();
return true; /* ***FIXME*** return real status */
}
char *restorePage::get_cwd()
{
int stat;
- m_console->write_dir(m_conn, ".pwd");
+ mainWin->waitEnter();
+ m_console->write_dir(m_conn, ".pwd", false);
Dmsg0(dbglvl, "send: .pwd\n");
if ((stat = m_console->read(m_conn)) > 0) {
m_cwd = m_console->msg(m_conn);
QMessageBox::critical(this, "Error", tr(".pwd command failed"), QMessageBox::Ok);
}
m_console->discardToPrompt(m_conn);
+ mainWin->waitExit();
return m_cwd.toUtf8().data();
}
levelCombo->addItems(m_console->level_list);
clientCombo->addItems(m_console->client_list);
job_name_change(0);
+ Pmsg1(000, "connecting estimate buttons : %i\n", m_conn);
connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int)));
connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
dockPage();
setCurrent();
this->show();
+ m_aButtonPushed = false;
}
void estimatePage::okButtonPushed()
{
+ if (m_aButtonPushed) return;
+ m_aButtonPushed = true;
this->hide();
QString cmd;
QTextStream(&cmd) << "estimate" <<
Pmsg1(000, "command : %s\n", cmd.toUtf8().data());
}
- consoleCommand(cmd);
+ consoleCommand(cmd, m_conn);
m_console->notify(m_conn, true);
closeStackPage();
mainWin->resetFocus();
void estimatePage::cancelButtonPushed()
{
+ if (m_aButtonPushed) return;
+ m_aButtonPushed = true;
mainWin->set_status(" Canceled");
this->hide();
m_console->notify(m_conn, true);
(void)index;
job_defs.job_name = jobCombo->currentText();
- if (m_console->get_job_defaults(job_defs)) {
+ if (m_console->get_job_defaults(m_conn, job_defs)) {
filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
private:
int m_conn;
+ bool m_aButtonPushed;
};
class prunePage : public Pages, public Ui::pruneForm