From: Dirk H Bartley Date: Fri, 18 May 2007 01:31:30 +0000 (+0000) Subject: Prevent connecting with the Console::m_at_main_prompt member. X-Git-Tag: Release-7.0.0~6317 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=75c1fc5aec883a67e1fcf5ef2a9c33889f0261a1;p=bacula%2Fbacula Prevent connecting with the Console::m_at_main_prompt member. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4825 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/TODO b/bacula/src/qt-console/TODO index 44e12ddf68..f46b6838d1 100644 --- a/bacula/src/qt-console/TODO +++ b/bacula/src/qt-console/TODO @@ -26,7 +26,7 @@ Purging not working from console or from context sensitive. (Kern) Human readable in joblist for purged, joblevel and job type. Possibly a stack of past screens so that when you open a window from another, -closing would brint the previous one back. +closing would bring the previous one back. Is there a way to query the director/database for whether a storage is currently mounted so I am not presenting both mount and unmount to the user?? diff --git a/bacula/src/qt-console/clients/clients.cpp b/bacula/src/qt-console/clients/clients.cpp index 8aa2ed5fe8..77c646baca 100644 --- a/bacula/src/qt-console/clients/clients.cpp +++ b/bacula/src/qt-console/clients/clients.cpp @@ -64,6 +64,8 @@ void Clients::populateTree() { QTreeWidgetItem *clientItem, *topItem; + if (!m_console->preventInUseConnect()) + return; m_checkcurwidget = false; mp_treeWidget->clear(); m_checkcurwidget = true; diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 09ca2cb915..04f50c8331 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -690,11 +690,44 @@ bool Console::is_connectedGui() if (is_connected()) { return true; } else { + QString message("Director "); + message += " is curerntly disconnected\n Please reconnect!!"; + QMessageBox::warning(this, tr("Bat"), + tr(message.toUtf8().data()), QMessageBox::Ok ); + return false; + } +} + +/* + * A temporary function to prevent connecting to the director if the director + * is busy with a restore. + */ +bool Console::preventInUseConnect() +{ + if (!is_connected()) { 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; + } else if (!m_at_main_prompt){ + QString message("Director "); + message += m_dir->name(); + message += " is curerntly busy\n Please complete restore or other " +" operation !! This is a limitation that will be resolved before a beta" +" release. This is currently an alpa release."; + QMessageBox::warning(this, tr("Bat"), + tr(message.toUtf8().data()), QMessageBox::Ok ); + return false; + } else if (!m_at_prompt){ + QString message("Director "); + message += m_dir->name(); + message += " is curerntly not at a prompt\n Please try again!!"; + QMessageBox::warning(this, tr("Bat"), + tr(message.toUtf8().data()), QMessageBox::Ok ); + return false; + } else { + return true; } } diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index b36c095618..ec54da8a9b 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -83,6 +83,7 @@ public: bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons); bool is_connected() { return m_sock != NULL; }; bool is_connectedGui(); + bool preventInUseConnect(); const QFont get_font(); void writeSettings(); void readSettings(); diff --git a/bacula/src/qt-console/fileset/fileset.cpp b/bacula/src/qt-console/fileset/fileset.cpp index bf4513ce56..b8f8aaba53 100644 --- a/bacula/src/qt-console/fileset/fileset.cpp +++ b/bacula/src/qt-console/fileset/fileset.cpp @@ -64,6 +64,8 @@ void FileSet::populateTree() { QTreeWidgetItem *filesetItem, *topItem; + if (!m_console->preventInUseConnect()) + return; m_checkcurwidget = false; mp_treeWidget->clear(); diff --git a/bacula/src/qt-console/joblist/joblist.cpp b/bacula/src/qt-console/joblist/joblist.cpp index 89ec394333..cf3fb97a94 100644 --- a/bacula/src/qt-console/joblist/joblist.cpp +++ b/bacula/src/qt-console/joblist/joblist.cpp @@ -75,6 +75,9 @@ void JobList::populateTable() QString resultline; QBrush blackBrush(Qt::black); + if (!m_console->preventInUseConnect()) + return; + /* Can't do this in constructor because not neccesarily conected in constructor */ if (!m_populated) { clientsComboBox->addItem("Any"); diff --git a/bacula/src/qt-console/joblog/joblog.cpp b/bacula/src/qt-console/joblog/joblog.cpp index a042ced364..f9b6539f30 100644 --- a/bacula/src/qt-console/joblog/joblog.cpp +++ b/bacula/src/qt-console/joblog/joblog.cpp @@ -77,6 +77,9 @@ void JobLog::populateText() QString heading("Log records for job "); heading += m_jobId + "\n"; textEdit->insertHtml(heading); + + if (!m_console->preventInUseConnect()) + return; QString query(""); query = "SELECT Time, LogText FROM Log WHERE JobId='" + m_jobId + "'"; diff --git a/bacula/src/qt-console/mediaedit/mediaedit.cpp b/bacula/src/qt-console/mediaedit/mediaedit.cpp index a8a099f2a2..ee0bdb987c 100644 --- a/bacula/src/qt-console/mediaedit/mediaedit.cpp +++ b/bacula/src/qt-console/mediaedit/mediaedit.cpp @@ -48,9 +48,11 @@ MediaEdit::MediaEdit(Console *console, QString &mediaId) m_status = ""; m_slot = 0; - setupUi(this); + if (!m_console->preventInUseConnect()) + return; + /* The media's pool */ poolCombo->addItems(console->pool_list); diff --git a/bacula/src/qt-console/medialist/medialist.cpp b/bacula/src/qt-console/medialist/medialist.cpp index 0f6c54aaa9..894c937dc4 100644 --- a/bacula/src/qt-console/medialist/medialist.cpp +++ b/bacula/src/qt-console/medialist/medialist.cpp @@ -67,6 +67,9 @@ void MediaList::populateTree() { QTreeWidgetItem *mediatreeitem, *pooltreeitem, *topItem; + if (!m_console->preventInUseConnect()) + return; + QStringList headerlist = (QStringList() << "Volume Name" << "Id" << "Status" << "Enabled" << "Bytes" << "Files" << "Jobs" << "Retention" diff --git a/bacula/src/qt-console/pages.cpp b/bacula/src/qt-console/pages.cpp index ebdd8b06fc..1b1201548f 100644 --- a/bacula/src/qt-console/pages.cpp +++ b/bacula/src/qt-console/pages.cpp @@ -205,9 +205,10 @@ void Pages::treeWidgetName(QString &name) */ void Pages::consoleCommand(QString &command) { - if (!m_console->is_connectedGui()) { + /*if (!m_console->is_connectedGui()) + return;*/ + if (!m_console->preventInUseConnect()) return; - } /* Bring this directors console to the front of the stack */ setConsoleCurrent(); QString displayhtml(""); diff --git a/bacula/src/qt-console/restore/prerestore.cpp b/bacula/src/qt-console/restore/prerestore.cpp index bca6c1e6c1..d07ab66312 100644 --- a/bacula/src/qt-console/restore/prerestore.cpp +++ b/bacula/src/qt-console/restore/prerestore.cpp @@ -66,6 +66,9 @@ void prerestorePage::buildPage() m_console->notify(false); m_closeable = true; + if (!m_console->preventInUseConnect()) + return; + jobCombo->addItems(m_console->job_list); filesetCombo->addItems(m_console->fileset_list); clientCombo->addItems(m_console->client_list); diff --git a/bacula/src/qt-console/run/runcmd.cpp b/bacula/src/qt-console/run/runcmd.cpp index 02f8cbea55..25346ea719 100644 --- a/bacula/src/qt-console/run/runcmd.cpp +++ b/bacula/src/qt-console/run/runcmd.cpp @@ -150,7 +150,15 @@ void runCmdPage::okButtonPushed() cmd += pri; cmd += " yes\n"; - consoleCommand(cmd); + setConsoleCurrent(); + QString displayhtml(""); + displayhtml += cmd + "\n"; + m_console->display_html(displayhtml); + m_console->display_text("\n"); + m_console->write_dir(cmd.toUtf8().data()); + m_console->displayToPrompt(); +// consoleCommand(cmd); ***FIXME set back to consoleCommand when connection issue is resolved + m_console->notify(true); closeStackPage(); } diff --git a/bacula/src/qt-console/storage/storage.cpp b/bacula/src/qt-console/storage/storage.cpp index 7d63e15cf8..4a5e32ac48 100644 --- a/bacula/src/qt-console/storage/storage.cpp +++ b/bacula/src/qt-console/storage/storage.cpp @@ -67,6 +67,9 @@ void Storage::populateTree() { QTreeWidgetItem *storageItem, *topItem; + if (!m_console->preventInUseConnect()) + return; + m_checkcurwidget = false; mp_treeWidget->clear(); m_checkcurwidget = true;