]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix "bug" #448, thanks to "over" for the idea.
authorNicolas Boichat <nicolas@boichat.ch>
Tue, 18 Oct 2005 16:30:36 +0000 (16:30 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Tue, 18 Oct 2005 16:30:36 +0000 (16:30 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2463 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/console_thread.cpp
bacula/src/wx-console/csprint.h
bacula/src/wx-console/wxbmainframe.cpp
bacula/src/wx-console/wxbrestorepanel.cpp

index b7b7271b7bdfa0a39f9a2bd9a13961a909939a9b..3f2e908420fd886a4de7b726d2714ed6a4f1bf7a 100644 (file)
@@ -427,13 +427,30 @@ void* console_thread::Entry() {
    
    csprint(NULL, CS_CONNECTED);
    
+   Write("autodisplay on\n");
    Write(".messages\n");
 
    int stat;
 
+   int last_is_eod = 0; /* Last packet received is BNET_EOD */
+   int do_not_forward_eod = 0; /* Last packet received/sent is .messages, so don't forward EOD. (so wx-console don't show the prompt again) */
+
    /* main loop */
    while(!TestDestroy()) {   /* Tests if thread has been ended */
+      stat = bnet_wait_data(UA_sock, 10);
+      if (stat == 0) {
+         if (last_is_eod) {
+            Write(".messages\n");
+            do_not_forward_eod = 1;
+         }
+         continue;
+      }
+      
+      last_is_eod = 0;
       if ((stat = bnet_recv(UA_sock)) >= 0) {
+         if (do_not_forward_eod) { /* .messages got data: remove the prompt */
+            csprint(NULL, CS_REMOVEPROMPT);
+         }
          csprint(UA_sock->msg);
       }
       else if (stat == BNET_SIGNAL) {
@@ -441,7 +458,9 @@ void* console_thread::Entry() {
             csprint(NULL, CS_PROMPT);
          }
          else if (UA_sock->msglen == BNET_EOD) {
-            csprint(NULL, CS_END);
+            last_is_eod = 1;
+            if (!do_not_forward_eod)
+               csprint(NULL, CS_END);
          }
          else if (UA_sock->msglen == BNET_HEARTBEAT) {
             bnet_sig(UA_sock, BNET_HB_RESPONSE);
@@ -462,6 +481,8 @@ void* console_thread::Entry() {
          csprint(NULL, CS_END);
          break;            /* error or term */
       }
+      
+      do_not_forward_eod = 0;
    }
    
    csprint(NULL, CS_DISCONNECTED);
@@ -482,9 +503,9 @@ void* console_thread::Entry() {
 void console_thread::Write(const char* str) 
 {
    if (UA_sock) {
-       UA_sock->msglen = (int32_t)strlen(str);
-       pm_strcpy(&UA_sock->msg, str);
-       bnet_send(UA_sock);
+      UA_sock->msglen = (int32_t)strlen(str);
+      pm_strcpy(&UA_sock->msg, str);
+      bnet_send(UA_sock);
    } else if (choosingdirector) {
 //      wxString number = str;
 //      number.RemoveLast(); /* Removes \n */
index c5ff664ab14b28629a7fdb486ea1cb4b8f776e94..d8fd95139da8ebff1e7dc28957f0ac36fdd33aad 100644 (file)
@@ -34,6 +34,9 @@
 #define CS_PROMPT        3 /* prompt signal received */
 #define CS_CONNECTED     4 /* the socket is now connected */
 #define CS_DISCONNECTED  5 /* the socket is now disconnected */
+
+#define CS_REMOVEPROMPT  6 /* remove the prompt (#), when automatic messages are comming */
+
 #define CS_DEBUG        10 /* used to print debug messages */
 #define CS_TERMINATED   99 /* used to signal that the thread is terminated */
 
index f74beb67b2933d35a3d489103235abd29a1452db..3e8623c58c8487f63f4f66f812b2fe445065af4e 100644 (file)
@@ -568,6 +568,13 @@ void wxbMainFrame::Print(wxString str, int status)
       EnableConsole(false);
    }
    
+   if (status == CS_REMOVEPROMPT) {
+      if (consoleCtrl->GetLastPosition() > 0) {
+         consoleCtrl->Remove(consoleCtrl->GetLastPosition()-1, consoleCtrl->GetLastPosition()+1);
+      }
+      return;
+   }
+   
    if (status == CS_TERMINATED) {
       consoleCtrl->AppendText(consoleBuffer);
       consoleBuffer = wxT("");
@@ -716,7 +723,7 @@ void wxbMainFrame::Print(wxString str, int status)
       if (lockedbyconsole) {
          EnableConsole(true);
       }
-      //consoleBuffer << "<P>";
+      //consoleBuffer << wxT("<P>");
    }
    
    if ((status == CS_END) || (status == CS_PROMPT) || (str.Find(wxT("\n")) > -1)) {
index 68c9351d45b39ee7e1e07240f828007c34d46c3c..1c8eb647a238c69da3c9093080cdbbc758b1aa42 100644 (file)
@@ -888,7 +888,8 @@ void wxbRestorePanel::CmdStart() {
       char status = '?';
 
       wxStopWatch sw;
-           
+      
+      wxbUtils::WaitForEnd(wxT("autodisplay off\n"));
       while (true) {
          tableparser = wxbUtils::CreateAndWaitForParser(cmd);
          ended = false;
@@ -965,7 +966,7 @@ void wxbRestorePanel::CmdStart() {
          }
          delete tableparser;
          
-         dt = wxbUtils::WaitForEnd(wxT(".messages\n"), true);
+         dt = wxbUtils::WaitForEnd(wxT("messages\n"), true);
                   
          for (unsigned int i = 0; i < dt->GetCount(); i++) {
             wxStringTokenizer tkz((*dt)[i], wxT(" "), wxTOKEN_STRTOK);
@@ -1013,7 +1014,7 @@ void wxbRestorePanel::CmdStart() {
             break;
          }
       }
-
+      wxbUtils::WaitForEnd(wxT("autodisplay on\n"));
       wxbUtils::WaitForEnd(wxT(".messages\n"));
 
       gauge->SetValue(totfilemessages);