From 96189b568542594475d00a22d5208e7e59c880e1 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 18 Jul 2008 12:49:32 +0000 Subject: [PATCH] Attempt to implement a kludge to make Qt work with bat on Win32. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7397 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/console/console.cpp | 51 +++++++++++++++-------- bacula/src/qt-console/console/console.h | 3 +- bacula/technotes-2.5 | 2 + 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 5f3d0ebc2a..8dfb282615 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -316,7 +316,7 @@ bool Console::sql_cmd(const char *query, QStringList &results) while ((stat = read()) > 0) { if (mainWin->m_displayAll) { display_text(msg()); - display_text("\n"); + display_text("\n"); } strip_trailing_junk(msg()); results << msg(); @@ -589,12 +589,12 @@ void Console::displayToPrompt() if (mainWin->m_commDebug) Pmsg0(000, "DisplaytoPrompt\n"); while (!m_at_prompt) { if ((stat=read()) > 0) { - buf += msg(); - if (buf.size() >= 8196 || m_messages_pending) { - display_text(buf); - buf.clear(); - m_messages_pending = false; - } + buf += msg(); + if (buf.size() >= 8196 || m_messages_pending) { + display_text(buf); + buf.clear(); + m_messages_pending = false; + } } } display_text(buf); @@ -609,12 +609,29 @@ void Console::discardToPrompt() displayToPrompt(); } else { while (!m_at_prompt) { - stat=read(); + stat=read(); } } if (mainWin->m_commDebug) Pmsg1(000, "endDiscardToPrompt=%d\n", stat); } +int Console::sock_read() +{ + int stat; +#ifdef HAVE_WIN32 + bool isEnabled = m_notifier->isEnabled(); + if (isEnabled) { + m_notifier->setEnabled(false); + } + stat = m_sock->recv(); + if (isEnabled) { + m_notifier->setEnabled(true); + } +#else + stat = m_sock->recv(); +#endif + return stat; +} /* * Blocking read from director @@ -635,7 +652,7 @@ int Console::read() } } m_sock->msg[0] = 0; - stat = m_sock->recv(); + stat = sock_read(); if (stat >= 0) { if (mainWin->m_commDebug) Pmsg1(000, "got: %s\n", m_sock->msg); if (m_at_prompt) { @@ -715,19 +732,19 @@ int Console::read() break; case BNET_ERROR_MSG: if (mainWin->m_commDebug) Pmsg0(000, "ERROR MSG\n"); - m_sock->recv(); /* get the message */ + stat = sock_read(); /* get the message */ display_text(msg()); QMessageBox::critical(this, "Error", msg(), QMessageBox::Ok); break; case BNET_WARNING_MSG: if (mainWin->m_commDebug) Pmsg0(000, "WARNING MSG\n"); - m_sock->recv(); /* get the message */ + stat = sock_read(); /* get the message */ display_text(msg()); QMessageBox::critical(this, "Warning", msg(), QMessageBox::Ok); break; case BNET_INFO_MSG: if (mainWin->m_commDebug) Pmsg0(000, "INFO MSG\n"); - m_sock->recv(); /* get the message */ + stat = sock_read(); /* get the message */ display_text(msg()); mainWin->set_status(msg()); break; @@ -814,19 +831,19 @@ bool Console::preventInUseConnect() { if (!is_connected()) { QString message = tr("Director %1 is currently disconnected\n" - "Please reconnect!").arg(m_dir->name()); + "Please reconnect!").arg(m_dir->name()); QMessageBox::warning(this, "Bat", message, QMessageBox::Ok ); return false; } else if (!m_at_main_prompt){ QString message = tr("Director %1 is currently busy\n Please complete " - "restore or other operation! This is a limitation " - "that will be resolved before a beta release. " - "This is currently an alpha release.").arg(m_dir->name()); + "restore or other operation! This is a limitation " + "that will be resolved before a beta release. " + "This is currently an alpha release.").arg(m_dir->name()); QMessageBox::warning(this, "Bat", message, QMessageBox::Ok ); return false; } else if (!m_at_prompt){ QString message = tr("Director %1 is currently not at a prompt\n" - " Please try again!").arg(m_dir->name()); + " Please try again!").arg(m_dir->name()); QMessageBox::warning(this, "Bat", message, QMessageBox::Ok ); return false; } else { diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 31d6d8064c..18fcb1cd76 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -3,7 +3,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + Copyright (C) 2007-2008 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. @@ -76,6 +76,7 @@ public: void display_html(const QString buf); void update_cursor(void); void write_dir(const char *buf); + int sock_read(); bool dir_cmd(const char *cmd, QStringList &results); bool dir_cmd(QString &cmd, QStringList &results); bool sql_cmd(const char *cmd, QStringList &results); diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index fd53b3d8dc..8dd27b83ee 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -31,6 +31,8 @@ vtape driver General: 18Jul08 +kes Attempt to implement a kludge to make Qt work with bat + on Win32. kes Setup rstorage correctly. Virtual backups are working. 17Jul08 kes Move setting JobLevel and JobType into a method, which should -- 2.39.5