From a57ccc979f3b14a06918c20b64f5235b0fb29b54 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Tue, 18 Oct 2005 16:30:36 +0000 Subject: [PATCH] Fix "bug" #448, thanks to "over" for the idea. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2463 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/wx-console/console_thread.cpp | 29 +++++++++++++++++++---- bacula/src/wx-console/csprint.h | 3 +++ bacula/src/wx-console/wxbmainframe.cpp | 9 ++++++- bacula/src/wx-console/wxbrestorepanel.cpp | 7 +++--- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/bacula/src/wx-console/console_thread.cpp b/bacula/src/wx-console/console_thread.cpp index b7b7271b7b..3f2e908420 100644 --- a/bacula/src/wx-console/console_thread.cpp +++ b/bacula/src/wx-console/console_thread.cpp @@ -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 */ diff --git a/bacula/src/wx-console/csprint.h b/bacula/src/wx-console/csprint.h index c5ff664ab1..d8fd95139d 100644 --- a/bacula/src/wx-console/csprint.h +++ b/bacula/src/wx-console/csprint.h @@ -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 */ diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index f74beb67b2..3e8623c58c 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -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 << "

"; + //consoleBuffer << wxT("

"); } if ((status == CS_END) || (status == CS_PROMPT) || (str.Find(wxT("\n")) > -1)) { diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index 68c9351d45..1c8eb647a2 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -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); -- 2.39.5