From: Dirk H Bartley Date: Thu, 26 Apr 2007 02:07:15 +0000 (+0000) Subject: This is a first commit at attempting to prevent connecting to a director which X-Git-Tag: Release-7.0.0~6492 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ebf539b7f1804b4f492caa2e14437d83bc3d6332;p=bacula%2Fbacula This is a first commit at attempting to prevent connecting to a director which has a closed connection. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4636 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 0637e84435..474c626a4c 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -201,6 +201,8 @@ bool Console::sql_cmd(QString &query, QStringList &results) */ bool Console::sql_cmd(const char *query, QStringList &results) { + if (!is_connectedGui()) + return false; int stat; POOL_MEM cmd(PM_MESSAGE); @@ -640,3 +642,17 @@ void Console::getDirResName(QString &name_returned) { name_returned = m_dir->name(); } + +bool Console::is_connectedGui() +{ + if (is_connected()) { + return true; + } else { + QString message("Director "); + message += m_dir->name(); + message += " is curerntly disconnected\n Please reconnect!!"; + QMessageBox::warning(this, tr("Bat"), + tr(message.toUtf8().data()), QMessageBox::Ok ); + return false; + } +} diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 6a38782dfe..9866831812 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -83,6 +83,7 @@ public: bool sql_cmd(QString &cmd, QStringList &results); bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons); bool is_connected() { return m_sock != NULL; }; + bool is_connectedGui(); const QFont get_font(); void writeSettings(); void readSettings(); diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 0f94ba6e79..feab8359f2 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -344,7 +344,7 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre /* let the next page BE the console */ nextPage = nextConsole; } else { - printf("Should never get here\n"); + /* Should never get here */ nextPage = NULL; nextConsole = NULL; } @@ -383,7 +383,7 @@ void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *pre } } - /* now process the next item */ + /* process the current (next) item */ if ((nextPage) || (nextConsole)) { if (nextConsole != previousConsole) { diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index 1ef945f892..801200f611 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -213,6 +213,8 @@ void Pages::treeWidgetName(QString &name) */ void Pages::consoleCommand(QString &command) { + if (!m_console->is_connectedGui()) + return; m_console->display_text("Context sensitive command :\n\n"); m_console->display_text("**** "); m_console->display_text(command + " ****\n");