From: Dirk H Bartley Date: Tue, 31 Mar 2009 03:11:25 +0000 (+0000) Subject: After much effort, I think I've got it. Was having a heck of a time X-Git-Tag: Release-7.0.0~3195 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e7b8010c6b0e188759e133209420ad9e7128f7e6;p=bacula%2Fbacula After much effort, I think I've got it. Was having a heck of a time getting the estimate to work consistently when I finally saw what was causing my difficulty. consoleCommand needed to be able to take the connection number. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8660 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/bcomm/dircomm.cpp b/bacula/src/qt-console/bcomm/dircomm.cpp index cd1b706d00..700d53dc15 100644 --- a/bacula/src/qt-console/bcomm/dircomm.cpp +++ b/bacula/src/qt-console/bcomm/dircomm.cpp @@ -279,7 +279,7 @@ int DirComm::read() } 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); } } @@ -300,7 +300,7 @@ int DirComm::read() 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); } diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index bc36a8550f..a3b6ee6115 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -96,7 +96,7 @@ void Console::poll_messages() 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); @@ -302,7 +302,10 @@ bool Console::sql_cmd(int &conn, const char *query, QStringList &results, bool d 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; @@ -311,16 +314,33 @@ int Console::write_dir(const char *msg) 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")); @@ -547,7 +567,6 @@ void Console::display_html(const QString buf) /* Position cursor to end of screen */ void Console::update_cursor() { -// QApplication::restoreOverrideCursor(); m_textEdit->moveCursor(QTextCursor::End); m_textEdit->ensureCursorVisible(); } diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 949689702c..72d1e5d3b5 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -91,7 +91,9 @@ public: 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(); diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 1b81f4efa7..a1352c7429 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -298,6 +298,11 @@ void MainWin::disconnectSignals() */ 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"); @@ -566,8 +571,8 @@ void MainWin::input_line() 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.")); } diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index f938eabbb3..7ff8686e5c 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -230,25 +230,23 @@ void Pages::treeWidgetName(QString &name) */ 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(""); displayhtml += command + "\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(); } /* diff --git a/bacula/src/qt-console/pages.h b/bacula/src/qt-console/pages.h index 14a409270c..1af475f2bf 100644 --- a/bacula/src/qt-console/pages.h +++ b/bacula/src/qt-console/pages.h @@ -70,7 +70,7 @@ public: 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 &); diff --git a/bacula/src/qt-console/restore/prerestore.cpp b/bacula/src/qt-console/restore/prerestore.cpp index e78dd5dedd..7fe8107c05 100644 --- a/bacula/src/qt-console/restore/prerestore.cpp +++ b/bacula/src/qt-console/restore/prerestore.cpp @@ -173,6 +173,8 @@ void prerestorePage::okButtonPushed() if (selectFilesRadio->isChecked()) { setConsoleCurrent(); closeStackPage(); + /* wait will be exited in the restore page constructor */ + mainWin->waitEnter(); } else { closeStackPage(); mainWin->resetFocus(); diff --git a/bacula/src/qt-console/restore/restore.cpp b/bacula/src/qt-console/restore/restore.cpp index 7b946f1419..d1d15d98d0 100644 --- a/bacula/src/qt-console/restore/restore.cpp +++ b/bacula/src/qt-console/restore/restore.cpp @@ -82,6 +82,9 @@ restorePage::restorePage(int conn) get_cwd(); readSettings(); + /* wait was entered from pre-restore + * will exit, but will reenter in fillDirectory */ + mainWin->waitExit(); fillDirectory(); dockPage(); setCurrent(); @@ -98,6 +101,7 @@ restorePage::~restorePage() */ void restorePage::fillDirectory() { + mainWin->waitEnter(); char modes[20], user[20], group[20], size[20], date[30]; char marked[10]; int pnl, fnl; @@ -105,7 +109,7 @@ void restorePage::fillDirectory() 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 treeItemList; QStringList item; while (m_console->read(m_conn) > 0) { @@ -176,6 +180,7 @@ void restorePage::fillDirectory() free_pool_memory(file); free_pool_memory(path); + mainWin->waitExit(); } /* @@ -291,7 +296,6 @@ void restorePage::directoryItemChanged(QTreeWidgetItem *currentitem, void restorePage::okButtonPushed() { -// printf("In restorePage::okButtonPushed\n"); this->hide(); m_console->write(m_conn, "done"); m_console->notify(m_conn, true); @@ -317,6 +321,7 @@ void restorePage::fileDoubleClicked(QTreeWidgetItem *item, int column) 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"))); @@ -326,12 +331,13 @@ void restorePage::fileDoubleClicked(QTreeWidgetItem *item, int column) 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; } /* @@ -371,6 +377,7 @@ void restorePage::upButtonPushed() */ void restorePage::markButtonPushed() { + mainWin->waitEnter(); QList treeItemList = fileWidget->selectedItems(); QTreeWidgetItem *item; char cmd[1000]; @@ -380,7 +387,7 @@ void restorePage::markButtonPushed() 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)); @@ -392,7 +399,7 @@ void restorePage::markButtonPushed() mainWin->set_status("Nothing selected, nothing done"); statusLine->setText("Nothing selected, nothing done"); } - + mainWin->waitExit(); } /* @@ -400,6 +407,7 @@ void restorePage::markButtonPushed() */ void restorePage::unmarkButtonPushed() { + mainWin->waitEnter(); QList treeItemList = fileWidget->selectedItems(); QTreeWidgetItem *item; char cmd[1000]; @@ -409,7 +417,7 @@ void restorePage::unmarkButtonPushed() 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)); @@ -421,7 +429,7 @@ void restorePage::unmarkButtonPushed() mainWin->set_status(tr("Nothing selected, nothing done")); statusLine->setText(tr("Nothing selected, nothing done")); } - + mainWin->waitExit(); } /* @@ -432,10 +440,11 @@ bool restorePage::cwd(const char *dir) 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); @@ -446,6 +455,7 @@ bool restorePage::cwd(const char *dir) QMessageBox::critical(this, "Error", tr("cd command failed"), QMessageBox::Ok); } m_console->discardToPrompt(m_conn); + mainWin->waitExit(); return true; /* ***FIXME*** return real status */ } @@ -455,7 +465,8 @@ bool restorePage::cwd(const char *dir) 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); @@ -465,6 +476,7 @@ char *restorePage::get_cwd() QMessageBox::critical(this, "Error", tr(".pwd command failed"), QMessageBox::Ok); } m_console->discardToPrompt(m_conn); + mainWin->waitExit(); return m_cwd.toUtf8().data(); } diff --git a/bacula/src/qt-console/run/estimate.cpp b/bacula/src/qt-console/run/estimate.cpp index 4d900faa9c..32b8fcb125 100644 --- a/bacula/src/qt-console/run/estimate.cpp +++ b/bacula/src/qt-console/run/estimate.cpp @@ -55,6 +55,7 @@ estimatePage::estimatePage() 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())); @@ -64,10 +65,13 @@ estimatePage::estimatePage() dockPage(); setCurrent(); this->show(); + m_aButtonPushed = false; } void estimatePage::okButtonPushed() { + if (m_aButtonPushed) return; + m_aButtonPushed = true; this->hide(); QString cmd; QTextStream(&cmd) << "estimate" << @@ -83,7 +87,7 @@ void estimatePage::okButtonPushed() Pmsg1(000, "command : %s\n", cmd.toUtf8().data()); } - consoleCommand(cmd); + consoleCommand(cmd, m_conn); m_console->notify(m_conn, true); closeStackPage(); mainWin->resetFocus(); @@ -92,6 +96,8 @@ void estimatePage::okButtonPushed() void estimatePage::cancelButtonPushed() { + if (m_aButtonPushed) return; + m_aButtonPushed = true; mainWin->set_status(" Canceled"); this->hide(); m_console->notify(m_conn, true); @@ -110,7 +116,7 @@ void estimatePage::job_name_change(int index) (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)); diff --git a/bacula/src/qt-console/run/run.h b/bacula/src/qt-console/run/run.h index 70693f473f..e505e6809d 100644 --- a/bacula/src/qt-console/run/run.h +++ b/bacula/src/qt-console/run/run.h @@ -55,6 +55,7 @@ public slots: private: int m_conn; + bool m_aButtonPushed; }; class prunePage : public Pages, public Ui::pruneForm