]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/bcomm/dircomm.cpp
Did not intend to leave those debugging lines there.
[bacula/bacula] / bacula / src / qt-console / bcomm / dircomm.cpp
index 0fdcfb79338edbe0065ac60940cf9c0e6033d9bd..86f52651a3e0293447c07c7e5c3433db458401c7 100644 (file)
@@ -42,9 +42,7 @@
 
 static int tls_pem_callback(char *buf, int size, const void *userdata);
 
-DirComm::DirComm(Console *parent, int conn):
-m_notifier(NULL),
-m_api_set(false)
+DirComm::DirComm(Console *parent, int conn):  m_notifier(NULL),  m_api_set(false)
 {
    m_console = parent;
    m_sock = NULL;
@@ -67,6 +65,8 @@ void DirComm::terminate()
          delete m_notifier;
          m_notifier = NULL;
       }
+      if (mainWin->m_connDebug)
+         Pmsg2(000, "DirComm %i terminating connections %s\n", m_conn, m_console->m_dir->name());
       m_sock->close();
       m_sock = NULL;
    }
@@ -89,7 +89,7 @@ bool DirComm::connect_dir()
       m_console->display_textf(_("Already connected\"%s\".\n"),
             m_console->m_dir->name());
       if (mainWin->m_connDebug)
-         Pmsg1(000, "DirComm %i BAILING already connected\n", m_conn);
+         Pmsg2(000, "DirComm %i BAILING already connected %s\n", m_conn, m_console->m_dir->name());
       goto bail_out;
    }
 
@@ -124,7 +124,7 @@ bool DirComm::connect_dir()
          m_console->display_textf(_("Failed to initialize TLS context for Console \"%s\".\n"),
             m_console->m_dir->name());
          if (mainWin->m_connDebug)
-            Pmsg1(000, "DirComm %i BAILING Failed to initialize TLS context for Console \n", m_conn);
+            Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Console %s\n", m_conn, m_console->m_dir->name());
          goto bail_out;
       }
    }
@@ -147,7 +147,7 @@ bool DirComm::connect_dir()
             m_console->m_dir->name());
          mainWin->set_status("Connection failed");
          if (mainWin->m_connDebug)
-            Pmsg1(000, "DirComm %i BAILING Failed to initialize TLS context for Director \n", m_conn);
+            Pmsg2(000, "DirComm %i BAILING Failed to initialize TLS context for Director %s\n", m_conn, m_console->m_dir->name());
          goto bail_out;
       }
    }
@@ -166,7 +166,7 @@ bool DirComm::connect_dir()
    if (m_sock == NULL) {
       mainWin->set_status("Connection failed");
       if (mainWin->m_connDebug)
-         Pmsg1(000, "DirComm %i BAILING Connection failed\n", m_conn);
+         Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name());
       goto bail_out;
    } else {
       /* Update page selector to green to indicate that Console is connected */
@@ -181,7 +181,7 @@ bool DirComm::connect_dir()
    if (!authenticate_director(jcr, m_console->m_dir, cons, buf, sizeof(buf))) {
       m_console->display_text(buf);
       if (mainWin->m_connDebug)
-         Pmsg1(000, "DirComm %i BAILING Connection failed\n", m_conn);
+         Pmsg2(000, "DirComm %i BAILING Connection failed %s\n", m_conn, m_console->m_dir->name());
       goto bail_out;
    }
 
@@ -209,12 +209,12 @@ bool DirComm::connect_dir()
    mainWin->set_status(_("Connected"));
 
    if (mainWin->m_connDebug)
-      Pmsg1(000, "Returning TRUE from DirComm->connect_dir : %i\n", m_conn);
+      Pmsg2(000, "Returning TRUE from DirComm->connect_dir : %i %s\n", m_conn, m_console->m_dir->name());
    return true;
 
 bail_out:
    if (mainWin->m_connDebug)
-      Pmsg1(000, "Returning FALSE from DirComm->connect_dir : %i\n", m_conn);
+      Pmsg2(000, "Returning FALSE from DirComm->connect_dir : %i %s\n", m_conn, m_console->m_dir->name());
    delete jcr;
    return false;
 }
@@ -265,19 +265,27 @@ int DirComm::sock_read()
  */
 int DirComm::read()
 {
-   int stat = 0;
+   int stat = -1;
+
+   if (!m_sock) {
+      return -1;
+   }
    while (m_sock) {
       for (;;) {
+         if (!m_sock) break;
          stat = m_sock->wait_data_intr(0, 50000);
          if (stat > 0) {
             break;
          } 
          app->processEvents();
          if (m_api_set && m_console->is_messagesPending() && is_notify_enabled() && m_console->hasFocus()) {
-            m_console->write_dir(m_conn, ".messages");
+            m_console->write_dir(m_conn, ".messages", false);
             m_console->messagesPending(false);
          }
       }
+      if (!m_sock) {
+         return -1;
+      }
       m_sock->msg[0] = 0;
       stat = sock_read();
       if (stat >= 0) {
@@ -292,7 +300,7 @@ int DirComm::read()
       case BNET_MSGS_PENDING :
          if (is_notify_enabled() && m_console->hasFocus()) {
             if (mainWin->m_commDebug) Pmsg1(000, "conn %i MSGS PENDING\n", m_conn);
-            m_console->write_dir(m_conn, ".messages");
+            m_console->write_dir(m_conn, ".messages", false);
             m_console->displayToPrompt(m_conn);
             m_console->messagesPending(false);
          }
@@ -322,36 +330,32 @@ int DirComm::read()
          m_at_prompt = true;
          m_at_main_prompt = true;
          mainWin->set_status(_("At main prompt waiting for input ..."));
-         QApplication::restoreOverrideCursor();
          break;
       case BNET_PROMPT:
          if (mainWin->m_commDebug) Pmsg1(000, "conn %i PROMPT\n", m_conn);
          m_at_prompt = true;
          m_at_main_prompt = false;
          mainWin->set_status(_("At prompt waiting for input ..."));
-         QApplication::restoreOverrideCursor();
          break;
       case BNET_CMD_FAILED:
          if (mainWin->m_commDebug) Pmsg1(000, "CMD FAILED\n", m_conn);
          if (--m_in_command < 0) {
-//          Pmsg0(000, "m_in_command < 0\n");
             m_in_command = 0;
          }
          mainWin->set_status(_("Command failed."));
-         QApplication::restoreOverrideCursor();
          break;
       /* We should not get this one */
       case BNET_EOD:
          if (mainWin->m_commDebug) Pmsg1(000, "conn %i EOD\n", m_conn);
          mainWin->set_status_ready();
-         QApplication::restoreOverrideCursor();
          if (!m_api_set) {
             break;
          }
          continue;
       case BNET_START_SELECT:
+         notify(false);
          if (mainWin->m_commDebug) Pmsg1(000, "conn %i START SELECT\n", m_conn);
-         new selectDialog(m_console);
+         new selectDialog(m_console, m_conn);
          break;
       case BNET_YESNO:
          if (mainWin->m_commDebug) Pmsg1(000, "conn %i YESNO\n", m_conn);
@@ -377,8 +381,7 @@ int DirComm::read()
       case BNET_WARNING_MSG:
          if (mainWin->m_commDebug) Pmsg1(000, "conn %i WARNING MSG\n", m_conn);
          stat = sock_read();          /* get the message */
-         m_console->display_text(msg());
-         QMessageBox::critical(m_console, "Warning", msg(), QMessageBox::Ok);
+         /* QMessageBox::critical(m_console, "Warning", msg(), QMessageBox::Ok); */
          break;
       case BNET_INFO_MSG:
          if (mainWin->m_commDebug) Pmsg1(000, "conn %i INFO MSG\n", m_conn);
@@ -402,7 +405,7 @@ int DirComm::read()
             m_notifier = NULL;
          }
          mainWin->set_status(_("Director disconnected."));
-         QApplication::restoreOverrideCursor();
+//         QApplication::restoreOverrideCursor();
          stat = BNET_HARDEOF;
       }
       break;
@@ -435,13 +438,14 @@ bool DirComm::notify(bool enable)
    if (m_notifier) {
       prev_enabled = m_notifier->isEnabled();   
       m_notifier->setEnabled(enable);
-      if (mainWin->m_connDebug)
+      if (mainWin->m_connDebug) {
          if (prev_enabled && !enable)
-            Pmsg1(000, "m_notifier Disabling notifier: %i\n", m_conn);
+            Pmsg2(000, "m_notifier Disabling notifier: %i %s\n", m_conn, m_console->m_dir->name());
          else if (!prev_enabled && enable)
-            Pmsg1(000, "m_notifier Enabling notifier: %i\n", m_conn); 
-    } else if (mainWin->m_connDebug)
-       Pmsg1(000, "m_notifier does not exist: %i\n", m_conn);
+            Pmsg2(000, "m_notifier Enabling notifier: %i %s\n", m_conn, m_console->m_dir->name());
+      }
+   } else if (mainWin->m_connDebug)
+      Pmsg2(000, "m_notifier does not exist: %i %s\n", m_conn, m_console->m_dir->name());
    return prev_enabled;
 }