From c4374f24d1f810b39f7b4957f008786697194fc5 Mon Sep 17 00:00:00 2001 From: upstream svn Date: Sat, 6 Nov 2010 19:35:06 +0000 Subject: [PATCH] Add ability to stop Kad search from aMuleGUI --- .svn-revision | 2 +- src/ExternalConn.cpp | 2 +- src/SearchDlg.cpp | 3 +-- src/SearchList.cpp | 14 ++++---------- src/SearchList.h | 7 ++----- src/SearchListCtrl.cpp | 2 +- src/ServerConnect.cpp | 2 +- src/amule-remote-gui.cpp | 8 +------- src/amule-remote-gui.h | 3 +-- 9 files changed, 13 insertions(+), 30 deletions(-) diff --git a/.svn-revision b/.svn-revision index b6e080bb..9fd4b340 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -10363 +10364 diff --git a/src/ExternalConn.cpp b/src/ExternalConn.cpp index ef8298c3..c9153760 100644 --- a/src/ExternalConn.cpp +++ b/src/ExternalConn.cpp @@ -955,7 +955,7 @@ static CECPacket *Get_EC_Response_Search_Results_Download(const CECPacket *reque static CECPacket *Get_EC_Response_Search_Stop(const CECPacket *WXUNUSED(request)) { CECPacket *reply = new CECPacket(EC_OP_MISC_DATA); - theApp->searchlist->StopGlobalSearch(); + theApp->searchlist->StopSearch(); return reply; } diff --git a/src/SearchDlg.cpp b/src/SearchDlg.cpp index 4ffd16f3..4951964f 100644 --- a/src/SearchDlg.cpp +++ b/src/SearchDlg.cpp @@ -413,8 +413,7 @@ void CSearchDlg::CreateNewTab(const wxString& searchString, wxUIntPtr nSearchID) void CSearchDlg::OnBnClickedStop(wxCommandEvent& WXUNUSED(evt)) { - theApp->searchlist->StopGlobalSearch(); - theApp->searchlist->StopKadSearch(); + theApp->searchlist->StopSearch(); ResetControls(); } diff --git a/src/SearchList.cpp b/src/SearchList.cpp index 2f0b6ada..571e6052 100644 --- a/src/SearchList.cpp +++ b/src/SearchList.cpp @@ -259,7 +259,7 @@ CSearchList::CSearchList() CSearchList::~CSearchList() { - StopGlobalSearch(); + StopSearch(); while (!m_results.empty()) { RemoveResults(m_results.begin()->first); @@ -466,7 +466,7 @@ void CSearchList::OnGlobalSearchTimer(CTimerEvent& WXUNUSED(evt)) } } // No more servers left to ask. - StopGlobalSearch(); + StopSearch(true); } @@ -614,7 +614,7 @@ void CSearchList::AddFileToDownloadByHash(const CMD4Hash& hash, uint8 cat) } -void CSearchList::StopGlobalSearch() +void CSearchList::StopSearch(bool globalOnly) { if (m_searchType == GlobalSearch) { m_currentSearch = -1; @@ -628,13 +628,7 @@ void CSearchList::StopGlobalSearch() m_searchTimer.Stop(); CoreNotify_Search_Update_Progress(0xffff); - } -} - - -void CSearchList::StopKadSearch() -{ - if (m_searchType == KadSearch) { + } else if (m_searchType == KadSearch && !globalOnly) { Kademlia::CSearchManager::StopSearch(m_currentSearch, false); m_currentSearch = -1; } diff --git a/src/SearchList.h b/src/SearchList.h index 97650bfe..b24e2a4b 100644 --- a/src/SearchList.h +++ b/src/SearchList.h @@ -92,11 +92,8 @@ public: */ wxString StartNewSearch(uint32* searchID, SearchType type, const CSearchParams& params); - /** Stops the current global search, if any is in progress. */ - void StopGlobalSearch(); - - /** Stops the current Kad search, if any is in progress. */ - void StopKadSearch(); + /** Stops the current search (global or Kad), if any is in progress. */ + void StopSearch(bool globalOnly = false); /** Returns the completion percentage of the current search. */ uint32 GetSearchProgress() const; diff --git a/src/SearchListCtrl.cpp b/src/SearchListCtrl.cpp index db06f7de..09fddfd6 100644 --- a/src/SearchListCtrl.cpp +++ b/src/SearchListCtrl.cpp @@ -663,7 +663,7 @@ void CSearchListCtrl::OnRelatedSearch( wxCommandEvent& WXUNUSED(event) ) } CSearchFile* file = (CSearchFile*)GetItemData( item ); - theApp->searchlist->StopGlobalSearch(); + theApp->searchlist->StopSearch(true); theApp->amuledlg->m_searchwnd->ResetControls(); CastByID( IDC_SEARCHNAME, theApp->amuledlg->m_searchwnd, wxTextCtrl )-> SetValue(wxT("related::") + file->GetFileHash().Encode()); diff --git a/src/ServerConnect.cpp b/src/ServerConnect.cpp index 49b0807c..54965786 100644 --- a/src/ServerConnect.cpp +++ b/src/ServerConnect.cpp @@ -402,7 +402,7 @@ void CServerConnect::ConnectionFailed(CServerSocket* sender) connectedsocket->Close(); } connectedsocket = NULL; - theApp->searchlist->StopGlobalSearch(); + theApp->searchlist->StopSearch(true); Notify_SearchCancel(); theStats::GetServerConnectTimer()->StopTimer(); if (thePrefs::Reconnect() && !connecting){ diff --git a/src/amule-remote-gui.cpp b/src/amule-remote-gui.cpp index 72952dff..4a9f67d7 100644 --- a/src/amule-remote-gui.cpp +++ b/src/amule-remote-gui.cpp @@ -1703,7 +1703,7 @@ wxString CSearchListRem::StartNewSearch( } -void CSearchListRem::StopGlobalSearch() +void CSearchListRem::StopSearch(bool) { if (m_curr_search != -1) { CECPacket search_req(EC_OP_SEARCH_STOP); @@ -1712,12 +1712,6 @@ void CSearchListRem::StopGlobalSearch() } -void CSearchListRem::StopKadSearch() -{ -// FIXME implementation needed -} - - void CSearchListRem::HandlePacket(const CECPacket *packet) { if ( packet->GetOpCode() == EC_OP_SEARCH_PROGRESS ) { diff --git a/src/amule-remote-gui.h b/src/amule-remote-gui.h index d5531d3d..184da361 100644 --- a/src/amule-remote-gui.h +++ b/src/amule-remote-gui.h @@ -570,8 +570,7 @@ public: wxString StartNewSearch(uint32* nSearchID, SearchType search_type, const CSearchList::CSearchParams& params); - void StopGlobalSearch(); - void StopKadSearch(); + void StopSearch(bool globalOnly = false); // // template -- 2.11.4.GIT