]> git.sur5r.net Git - bacula/bacula/commitdiff
This is the change that may be used in the future to resolve the issue with text...
authorDirk H Bartley <dbartley@schupan.com>
Sun, 19 Jul 2009 20:03:39 +0000 (20:03 +0000)
committerDirk H Bartley <dbartley@schupan.com>
Sun, 19 Jul 2009 20:03:39 +0000 (20:03 +0000)
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
bacula/src/qt-console/bcomm/dircomm.cpp
bacula/src/qt-console/bcomm/dircomm.h
bacula/src/qt-console/console/console.cpp
bacula/src/qt-console/console/console.h
bacula/src/qt-console/select/textinput.cpp [new file with mode: 0644]
bacula/src/qt-console/select/textinput.h [new file with mode: 0644]
bacula/src/qt-console/select/textinput.ui [new file with mode: 0644]

index e8dba7612fa7b4b7be809f0a02e60aa76ea7034a..6fc22b7ff024ac8ef454730ae013f17e798499ac 100644 (file)
@@ -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
index 42b9bc238ef0469a79c692c10ed4f0126a64d6ca..d710ea86a720768384a196cee860ea1ac9b720d1 100644 (file)
@@ -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);
index a8e66aa6d09d80d1501725745aaa405a9f59f9b7..c26279f57ac5e0b80d1a20a4639c1d0ece894348 100644 (file)
@@ -82,6 +82,7 @@ private:
    QSocketNotifier *m_notifier;
    bool m_api_set;
    int m_conn;
+   bool m_in_select;
 };
 
 #endif /* _DIRCOMM_H_ */
index dacbd97e458a23d610beec609a782b6f31196554..4285dec11134e61c2ff80244adbd351e1cb2b01d 100644 (file)
@@ -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 
index 3b2896eff76bb87d940f237d7282b824778dc897..ab07401b24e02cd8cfb409f907ae099d47c44191 100644 (file)
@@ -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 (file)
index 0000000..17090d6
--- /dev/null
@@ -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 (file)
index 0000000..602121a
--- /dev/null
@@ -0,0 +1,25 @@
+
+#ifndef _TEXTENTRY_H_
+#define _TEXTENTRY_H_
+
+#include <QtGui>
+#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 (file)
index 0000000..a72fc8a
--- /dev/null
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>textInputForm</class>
+ <widget class="QDialog" name="textInputForm">
+  <property name="windowModality">
+   <enum>Qt::ApplicationModal</enum>
+  </property>
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>430</width>
+    <height>132</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Selection dialog</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="labelWidget">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>TextLabel</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="QLineEdit" name="lineEdit"/>
+   </item>
+   <item row="3" column="1">
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons">
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>textInputForm</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>textInputForm</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>