From ff9a42b0605354c93127568328ebfd2840b67bfd Mon Sep 17 00:00:00 2001 From: upstream svn Date: Sun, 26 Sep 2010 11:31:35 +0000 Subject: [PATCH] Enable "Reset Log" button in the Remote GUI --- .svn-revision | 2 +- src/ExternalConn.cpp | 12 ++++++++++++ src/ExternalConn.h | 1 + src/Logger.cpp | 8 ++++++++ src/Logger.h | 4 ++++ src/amule-remote-gui.cpp | 7 ++++++- src/amule.cpp | 1 + 7 files changed, 33 insertions(+), 2 deletions(-) diff --git a/.svn-revision b/.svn-revision index 3254f8a8..589d3ee4 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -10293 +10294 diff --git a/src/ExternalConn.cpp b/src/ExternalConn.cpp index 0f0b039b..fc27ebb9 100644 --- a/src/ExternalConn.cpp +++ b/src/ExternalConn.cpp @@ -203,6 +203,8 @@ public: virtual void OnLost(); virtual void WriteDoneAndQueueEmpty(); + + void ResetLog() { m_LoggerAccess.Reset(); } private: ECNotifier *m_ec_notifier; @@ -374,6 +376,16 @@ void ExternalConn::KillAllSockets() } +void ExternalConn::ResetAllLogs() +{ + SocketSet::iterator it = socket_list.begin(); + while (it != socket_list.end()) { + CECServerSocket *s = *(it++); + s->ResetLog(); + } +} + + void ExternalConn::OnServerEvent(wxSocketEvent& WXUNUSED(event)) { CECServerSocket *sock = new CECServerSocket(m_ec_notifier); diff --git a/src/ExternalConn.h b/src/ExternalConn.h index 6e8936df..fd2f19dc 100644 --- a/src/ExternalConn.h +++ b/src/ExternalConn.h @@ -96,6 +96,7 @@ public: void AddSocket(CECServerSocket *s); void RemoveSocket(CECServerSocket *s); void KillAllSockets(); + void ResetAllLogs(); private: // event handlers (these functions should _not_ be virtual) diff --git a/src/Logger.cpp b/src/Logger.cpp index 7787b7b0..03e87087 100644 --- a/src/Logger.cpp +++ b/src/Logger.cpp @@ -338,6 +338,14 @@ CLoggerAccess::CLoggerAccess() { m_bufferlen = 4096; m_buffer = new wxCharBuffer(m_bufferlen); + m_logfile = NULL; + Reset(); +} + + +void CLoggerAccess::Reset() +{ + delete m_logfile; m_logfile = new wxFFileInputStream(theLogger.GetLogfileName()); m_pos = 0; m_ready = false; diff --git a/src/Logger.h b/src/Logger.h index 490a7ad2..391b20f9 100644 --- a/src/Logger.h +++ b/src/Logger.h @@ -388,6 +388,10 @@ public: CLoggerAccess(); ~CLoggerAccess(); // + // Reset (used when logfile is cleared) + // + void Reset(); + // // get a String (if there is one) // bool GetString(wxString & s); diff --git a/src/amule-remote-gui.cpp b/src/amule-remote-gui.cpp index 3ad6609d..dcff6d43 100644 --- a/src/amule-remote-gui.cpp +++ b/src/amule-remote-gui.cpp @@ -411,8 +411,13 @@ uint32 CamuleRemoteGuiApp::GetPublicIP() } -wxString CamuleRemoteGuiApp::GetLog(bool) +wxString CamuleRemoteGuiApp::GetLog(bool reset) { + if (reset) { + amuledlg->ResetLog(ID_LOGVIEW); + CECPacket req(EC_OP_RESET_LOG); + m_connect->SendPacket(&req); + } return wxEmptyString; } diff --git a/src/amule.cpp b/src/amule.cpp index 78e394f8..e4186219 100644 --- a/src/amule.cpp +++ b/src/amule.cpp @@ -1511,6 +1511,7 @@ wxString CamuleApp::GetLog(bool reset) if (theLogger.OpenLogfile(ConfigDir + wxT("logfile"))) { AddLogLineN(_("Log has been reset")); } + ECServerHandler->ResetAllLogs(); } return str; } -- 2.11.4.GIT