From 96f12ed02f3da66d6e3433f2f6f9b30e74e452cf Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sun, 19 Jul 2009 20:03:39 +0000 Subject: [PATCH] This is the change that may be used in the future to resolve the issue with text input required during a console communication. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@9075 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/bat.pro.in | 6 +- bacula/src/qt-console/bcomm/dircomm.cpp | 12 ++- bacula/src/qt-console/bcomm/dircomm.h | 1 + bacula/src/qt-console/console/console.cpp | 17 ++++ bacula/src/qt-console/console/console.h | 1 + bacula/src/qt-console/select/textinput.cpp | 76 ++++++++++++++++ bacula/src/qt-console/select/textinput.h | 25 +++++ bacula/src/qt-console/select/textinput.ui | 101 +++++++++++++++++++++ 8 files changed, 235 insertions(+), 4 deletions(-) create mode 100644 bacula/src/qt-console/select/textinput.cpp create mode 100644 bacula/src/qt-console/select/textinput.h create mode 100644 bacula/src/qt-console/select/textinput.ui diff --git a/bacula/src/qt-console/bat.pro.in b/bacula/src/qt-console/bat.pro.in index e8dba7612f..6fc22b7ff0 100644 --- a/bacula/src/qt-console/bat.pro.in +++ b/bacula/src/qt-console/bat.pro.in @@ -47,7 +47,7 @@ FORMS += console/console.ui FORMS += restore/restore.ui restore/prerestore.ui restore/brestore.ui FORMS += restore/restoretree.ui FORMS += run/run.ui run/runcmd.ui run/estimate.ui run/prune.ui -FORMS += select/select.ui +FORMS += select/select.ui select/textinput.ui FORMS += medialist/medialist.ui mediaedit/mediaedit.ui joblist/joblist.ui FORMS += clients/clients.ui storage/storage.ui fileset/fileset.ui FORMS += joblog/joblog.ui jobs/jobs.ui @@ -92,8 +92,8 @@ HEADERS += run/run.h SOURCES += run/run.cpp run/runcmd.cpp run/estimate.cpp run/prune.cpp # Select dialog -HEADERS += select/select.h -SOURCES += select/select.cpp +HEADERS += select/select.h select/textinput.h +SOURCES += select/select.cpp select/textinput.cpp ## MediaList HEADERS += medialist/medialist.h diff --git a/bacula/src/qt-console/bcomm/dircomm.cpp b/bacula/src/qt-console/bcomm/dircomm.cpp index 42b9bc238e..d710ea86a7 100644 --- a/bacula/src/qt-console/bcomm/dircomm.cpp +++ b/bacula/src/qt-console/bcomm/dircomm.cpp @@ -38,6 +38,7 @@ #include "console.h" #include "restore.h" #include "select.h" +#include "textinput.h" #include "run/run.h" static int tls_pem_callback(char *buf, int size, const void *userdata); @@ -50,6 +51,7 @@ DirComm::DirComm(Console *parent, int conn): m_notifier(NULL), m_api_set(false m_at_main_prompt = false; m_conn = conn; m_in_command = 0; + m_in_select = false; } DirComm::~DirComm() @@ -334,10 +336,16 @@ int DirComm::read() mainWin->set_status(_("At main prompt waiting for input ...")); break; case BNET_PROMPT: - if (mainWin->m_commDebug) Pmsg1(000, "conn %i PROMPT\n", m_conn); + if (mainWin->m_commDebug) Pmsg2(000, "conn %i PROMPT m_in_select %i\n", m_conn, m_in_select); m_at_prompt = true; m_at_main_prompt = false; mainWin->set_status(_("At prompt waiting for input ...")); + /* commented out until the prompt communication issue with the director is resolved + This is where I call a new text input dialog class to prevent the connection issues + when a text input is requited. + if (! m_in_select) { + new textInputDialog(m_console, m_conn); + } */ break; case BNET_CMD_FAILED: if (mainWin->m_commDebug) Pmsg1(000, "CMD FAILED\n", m_conn); @@ -357,7 +365,9 @@ int DirComm::read() case BNET_START_SELECT: notify(false); if (mainWin->m_commDebug) Pmsg1(000, "conn %i START SELECT\n", m_conn); + m_in_select = true; new selectDialog(m_console, m_conn); + m_in_select = false; break; case BNET_YESNO: if (mainWin->m_commDebug) Pmsg1(000, "conn %i YESNO\n", m_conn); diff --git a/bacula/src/qt-console/bcomm/dircomm.h b/bacula/src/qt-console/bcomm/dircomm.h index a8e66aa6d0..c26279f57a 100644 --- a/bacula/src/qt-console/bcomm/dircomm.h +++ b/bacula/src/qt-console/bcomm/dircomm.h @@ -82,6 +82,7 @@ private: QSocketNotifier *m_notifier; bool m_api_set; int m_conn; + bool m_in_select; }; #endif /* _DIRCOMM_H_ */ diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index dacbd97e45..4285dec111 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -636,6 +636,23 @@ void Console::discardToPrompt(int conn) if (mainWin->m_commDebug) Pmsg2(000, "endDiscardToPrompt=%d %s\n", stat, m_dir->name()); } +QString Console::returnFromPrompt(int conn) +{ + DirComm *dircomm = m_dircommHash.value(conn); + QString text(""); + + int stat = 0; + text = ""; + if (mainWin->m_commDebug) Pmsg1(000, "returnFromPrompt %s\n", m_dir->name()); + while (!dircomm->m_at_prompt) { + if ((stat=dircomm->read()) > 0) { + text += dircomm->msg(); + } + } + if (mainWin->m_commDebug) Pmsg2(000, "endreturnFromPrompt=%d %s\n", stat, m_dir->name()); + return text; +} + /* * When the notifier is enabled, read_dir() will automatically be * called by the Qt event loop when ever there is any output diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 3b2896eff7..ab07401b24 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -83,6 +83,7 @@ public: bool availableDirComm(int &conn); bool currentDirComm(int &conn); void displayToPrompt(int conn); + QString returnFromPrompt(int conn); bool dir_cmd(int conn, const char *cmd, QStringList &results); bool dir_cmd(const char *cmd, QStringList &results); diff --git a/bacula/src/qt-console/select/textinput.cpp b/bacula/src/qt-console/select/textinput.cpp new file mode 100644 index 0000000000..17090d6146 --- /dev/null +++ b/bacula/src/qt-console/select/textinput.cpp @@ -0,0 +1,76 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2009 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of Kern Sibbald. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ + +/* + * Select dialog class + * + * Kern Sibbald, March MMVII + * + * $Id: select.cpp 8775 2009-04-30 16:57:18Z bartleyd2 $ + */ + +#include "bat.h" +#include "textinput.h" + +/* + * Read input text box + */ +textInputDialog::textInputDialog(Console *console, int conn) +{ + m_conn = conn; + QDateTime dt; + + m_console = console; + setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + labelWidget->setText(m_console->returnFromPrompt(m_conn)); + this->show(); +} + +void textInputDialog::accept() +{ + this->hide(); + m_console->write_dir(m_conn, lineEdit->text().toUtf8().data()); + m_console->displayToPrompt(m_conn); + mainWin->resetFocus(); + m_console->displayToPrompt(m_conn); + m_console->notify(m_conn, true); + this->close(); +} + + +void textInputDialog::reject() +{ + this->hide(); + mainWin->set_status(tr(" Canceled")); + mainWin->resetFocus(); + m_console->beginNewCommand(m_conn); + m_console->notify(m_conn, true); + this->close(); +} + diff --git a/bacula/src/qt-console/select/textinput.h b/bacula/src/qt-console/select/textinput.h new file mode 100644 index 0000000000..602121a8d3 --- /dev/null +++ b/bacula/src/qt-console/select/textinput.h @@ -0,0 +1,25 @@ + +#ifndef _TEXTENTRY_H_ +#define _TEXTENTRY_H_ + +#include +#include "ui_textinput.h" +#include "console.h" + +class textInputDialog : public QDialog, public Ui::textInputForm +{ + Q_OBJECT + +public: + textInputDialog(Console *console, int conn); + +public slots: + void accept(); + void reject(); + +private: + Console *m_console; + int m_conn; +}; + +#endif /* _TEXTENTRY_H_ */ diff --git a/bacula/src/qt-console/select/textinput.ui b/bacula/src/qt-console/select/textinput.ui new file mode 100644 index 0000000000..a72fc8a201 --- /dev/null +++ b/bacula/src/qt-console/select/textinput.ui @@ -0,0 +1,101 @@ + + + textInputForm + + + Qt::ApplicationModal + + + + 0 + 0 + 430 + 132 + + + + Selection dialog + + + + + + + + + + + + + TextLabel + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + textInputForm + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + textInputForm + reject() + + + 316 + 260 + + + 286 + 274 + + + + + -- 2.39.5