MCPcopy Create free account
hub / github.com/amule-project/amule / StartNewSearch

Method StartNewSearch

src/SearchList.cpp:309–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307
308
309wxString CSearchList::StartNewSearch(uint32* searchID, SearchType type, CSearchParams& params)
310{
311 // Check that we can actually perform the specified desired search.
312 if ((type == KadSearch) && !Kademlia::CKademlia::IsRunning()) {
313 return _("Kad search can't be done if Kad is not running");
314 } else if ((type != KadSearch) && !theApp->IsConnectedED2K()) {
315 return _("eD2k search can't be done if eD2k is not connected");
316 }
317
318 if (params.typeText != ED2KFTSTR_PROGRAM) {
319 if (params.typeText.CmpNoCase("Any")) {
320 m_resultType = params.typeText;
321 } else {
322 m_resultType.Clear();
323 }
324 } else {
325 // No check is to be made on returned results if the
326 // type is 'Programs', since this returns multiple types.
327 m_resultType.Clear();
328 }
329
330 if (type == KadSearch) {
331 Kademlia::WordList words;
332 Kademlia::CSearchManager::GetWords(params.searchString, &words);
333 if (!words.empty()) {
334 params.strKeyword = words.front();
335 } else {
336 return _("No keyword for Kad search - aborting");
337 }
338 }
339
340 bool supports64bit = type == KadSearch ? true : theApp->serverconnect->GetCurrentServer() != NULL && (theApp->serverconnect->GetCurrentServer()->GetTCPFlags() & SRV_TCPFLG_LARGEFILES);
341 bool packetUsing64bit;
342
343 // This MemFile is automatically free'd
344 CMemFilePtr data = CreateSearchData(params, type, supports64bit, packetUsing64bit);
345
346 if (data.get() == NULL) {
347 wxASSERT(_astrParserErrors.GetCount());
348 wxString error;
349
350 for (unsigned int i = 0; i < _astrParserErrors.GetCount(); ++i) {
351 error += _astrParserErrors[i] + "\n";
352 }
353
354 return error;
355 }
356
357 m_searchType = type;
358 if (type == KadSearch) {
359 try {
360 if (*searchID == 0xffffffff) {
361 Kademlia::CSearchManager::StopSearch(0xffffffff, false);
362 }
363
364 // searchstring will get tokenized there
365 // The tab must be created with the Kad search ID, so searchID is updated.
366 Kademlia::CSearch* search = Kademlia::CSearchManager::PrepareFindKeywords(params.strKeyword, data->GetLength(), data->GetRawBuffer(), *searchID);

Callers

nothing calls this directly

Calls 13

GetTCPFlagsMethod · 0.80
GetRawBufferMethod · 0.80
GetPacketSizeMethod · 0.80
SetOpCodeMethod · 0.80
IsConnectedED2KMethod · 0.45
ClearMethod · 0.45
emptyMethod · 0.45
GetCurrentServerMethod · 0.45
getMethod · 0.45
GetCountMethod · 0.45
GetLengthMethod · 0.45
GetSearchIDMethod · 0.45

Tested by

no test coverage detected