From: Kern Sibbald Date: Fri, 30 Oct 2009 19:28:37 +0000 (+0100) Subject: Rework bat so that Win32 version works better X-Git-Tag: Release-5.0.0~281^2~20 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=663ec629af2a162b4ab88cd14795af277c2c2d69;p=bacula%2Fbacula Rework bat so that Win32 version works better --- diff --git a/bacula/src/qt-console/README.mingw32 b/bacula/src/qt-console/README.mingw32 index 5112954ff2..0422c1ffca 100644 --- a/bacula/src/qt-console/README.mingw32 +++ b/bacula/src/qt-console/README.mingw32 @@ -78,6 +78,8 @@ Compile bat ----------- $ cd bacula/src/qt-console +$ export DEPKGS="directory above cross-tools and depkgs" +$ ./make-win32 clean $ ./make-win32 Cleanup diff --git a/bacula/src/qt-console/bcomm/dircomm.cpp b/bacula/src/qt-console/bcomm/dircomm.cpp index 5a36583313..52ca833c6b 100644 --- a/bacula/src/qt-console/bcomm/dircomm.cpp +++ b/bacula/src/qt-console/bcomm/dircomm.cpp @@ -198,11 +198,12 @@ bool DirComm::connect_dir() mainWin->set_status(_("Initializing ...")); -#ifndef HAVE_WIN32 - /* Set up input notifier */ + /* + * Set up input notifier + */ m_notifier = new QSocketNotifier(m_sock->m_fd, QSocketNotifier::Read, 0); QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(read_dir(int))); -#endif + m_notifier->setEnabled(false); write(".api 1"); m_api_set = true; @@ -314,9 +315,7 @@ int DirComm::read() if (mainWin->m_commDebug) Pmsg1(000, "conn %i CMD OK\n", m_conn); m_at_prompt = false; m_at_main_prompt = false; -// Pmsg1(000, "before dec m_in_command=%d\n", m_in_command); if (--m_in_command < 0) { -// Pmsg0(000, "m_in_command < 0\n"); m_in_command = 0; } mainWin->set_status(_("Command completed ...")); @@ -326,7 +325,6 @@ int DirComm::read() m_at_prompt = false; m_at_main_prompt = false; m_in_command++; -// Pmsg1(000, "after inc m_in_command=%d\n", m_in_command); mainWin->set_status(_("Processing command ...")); continue; case BNET_MAIN_PROMPT: @@ -340,12 +338,14 @@ int DirComm::read() m_at_prompt = true; m_at_main_prompt = false; mainWin->set_status(_("At prompt waiting for input ...")); + /***** FIXME *****/ /* 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); - } */ + * 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); @@ -419,7 +419,6 @@ int DirComm::read() m_notifier = NULL; } mainWin->set_status(_("Director disconnected.")); -// QApplication::restoreOverrideCursor(); stat = BNET_HARDEOF; } break; @@ -430,10 +429,16 @@ int DirComm::read() /* Called by signal when the Director has output for us */ void DirComm::read_dir(int /* fd */) { - if (mainWin->m_commDebug) Pmsg1(000, "conn %i read_dir\n", m_conn); - while (read() >= 0) { - m_console->display_text(msg()); + int stat; + if (mainWin->m_commDebug) Pmsg1(000, "enter read_dir conn %i read_dir\n", m_conn); + stat = m_sock->wait_data(0, 5000); + if (stat > 0) { + if (mainWin->m_commDebug) Pmsg2(000, "read_dir conn %i stat=%d\n", m_conn, stat); + while (read() >= 0) { + m_console->display_text(msg()); + } } + if (mainWin->m_commDebug) Pmsg2(000, "exit read_dir conn %i stat=%d\n", m_conn, stat); } /* @@ -451,9 +456,7 @@ bool DirComm::notify(bool enable) bool prev_enabled = false; if (m_notifier) { prev_enabled = m_notifier->isEnabled(); - if (prev_enabled != enable) { - m_notifier->setEnabled(enable); - } + m_notifier->setEnabled(enable); if (mainWin->m_connDebug) { if (prev_enabled && !enable) Pmsg2(000, "m_notifier Disabling notifier: %i %s\n", m_conn, m_console->m_dir->name()); @@ -468,16 +471,9 @@ bool DirComm::notify(bool enable) bool DirComm::is_notify_enabled() const { bool enabled = false; - if (m_notifier) + if (m_notifier) { enabled = m_notifier->isEnabled(); - -/* TODO: Windows doesn't support notifier without some kludge - * This cheat seems to work, waiting for a cleaner solution. - */ -#ifdef HAVE_WIN32 - enabled = true; -#endif - + } return enabled; } @@ -491,7 +487,6 @@ static int tls_pem_callback(char *buf, int size, const void *userdata) (void)size; (void)userdata; #ifdef HAVE_TLS - const char *prompt = (const char *)userdata; # if defined(HAVE_WIN32) //sendit(prompt); if (win32_cgets(buf, size) == NULL) { @@ -501,6 +496,7 @@ static int tls_pem_callback(char *buf, int size, const void *userdata) return strlen(buf); } # else + const char *prompt = (const char *)userdata; char *passwd; passwd = getpass(prompt); diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 7f56dd9aef..f9972ddba5 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -139,19 +139,12 @@ void Console::connect_dir() * A function created to separate out the population of the lists * from the Console::connect_dir function */ -void Console::populateLists(bool forcenew) +void Console::populateLists(bool /*forcenew*/) { int conn; - if (forcenew) { - if (!newDirComm(conn)) { - Pmsg1(000, "newDirComm Seems to Failed to create a connection for populateLists %s\n", m_dir->name()); - return; - } - } else { - if (!availableDirComm(conn)) { - Pmsg1(000, "availableDirComm Seems to Failed to find a connection for populateListsi %s\n", m_dir->name()); - return; - } + if (!availableDirComm(conn) && !newDirComm(conn)) { + Pmsg1(000, "newDirComm Seems to Failed to create a connection for populateLists %s\n", m_dir->name()); + return; } populateLists(conn); } diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 67d1a07a1b..13640735fd 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -104,16 +104,17 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) m_currentConsole->getDirResName(directoryResourceName); Pmsg1(100, "Setting initial window to %s\n", directoryResourceName.toUtf8().data()); } + app->restoreOverrideCursor(); } void MainWin::popLists() { foreach(Console *console, m_consoleHash) console->populateLists(true); - app->restoreOverrideCursor(); m_doConnect = true; connectConsoleSignals(); connectSignals(); + app->restoreOverrideCursor(); m_currentConsole->setCurrent(); } @@ -324,13 +325,13 @@ void MainWin::waitExit() { m_waitState = false; if (mainWin->m_connDebug) Pmsg0(000, "Exiting Wait State\n"); - app->restoreOverrideCursor(); if (m_waitTreeItem != treeWidget->currentItem()) treeWidget->setCurrentItem(m_waitTreeItem); if (m_doConnect) { connectSignals(); connectConsoleSignals(); } + app->restoreOverrideCursor(); } void MainWin::connectConsoleSignals() diff --git a/bacula/src/qt-console/restore/prerestore.cpp b/bacula/src/qt-console/restore/prerestore.cpp index 81e7d88171..ef7baf5881 100644 --- a/bacula/src/qt-console/restore/prerestore.cpp +++ b/bacula/src/qt-console/restore/prerestore.cpp @@ -132,8 +132,9 @@ void prerestorePage::buildPage() void prerestorePage::okButtonPushed() { if (!selectJobRadio->isChecked()) { - if (!checkJobIdList()) + if (!checkJobIdList()) { return; + } } QString cmd; diff --git a/bacula/src/qt-console/restore/restore.cpp b/bacula/src/qt-console/restore/restore.cpp index 8f30997c93..b820f6b642 100644 --- a/bacula/src/qt-console/restore/restore.cpp +++ b/bacula/src/qt-console/restore/restore.cpp @@ -292,7 +292,7 @@ void restorePage::directoryItemChanged(QTreeWidgetItem *currentitem, { QString fullpath = m_dirTreeItems.value(currentitem); statusLine->setText(""); - if (fullpath != ""){ + if (fullpath != "") { cwd(fullpath.toUtf8().data()); fillDirectory(); } diff --git a/bacula/src/qt-console/run/estimate.cpp b/bacula/src/qt-console/run/estimate.cpp index 413c4b5ac2..417c9f1cd3 100644 --- a/bacula/src/qt-console/run/estimate.cpp +++ b/bacula/src/qt-console/run/estimate.cpp @@ -55,7 +55,6 @@ estimatePage::estimatePage() levelCombo->addItems(m_console->level_list); clientCombo->addItems(m_console->client_list); job_name_change(0); - Pmsg1(100, "connecting estimate buttons : %i\n", m_conn); connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int))); connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed())); connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));