Public Member Functions | |
void | AddResult (SearchResult result) |
Add a search result to the results list. | |
void | ClearResults () |
Clear all results from the results list. | |
void | RemoveResult (SearchResult result) |
Remove a search result from the results list. | |
delegate void | ResultAddedEventHandler (SearchResults s_results, SearchResult result) |
Prototype for the Result Added Event Handler. | |
delegate void | ResultsChangedEventHandler (SearchResults s_results, int num_results) |
Prototype for the Results Changed Event Handler (soon to be deprecated). | |
delegate void | ResultsClearedEventHandler (SearchResults s_results) |
Prototype for the Results Cleared Event Handler. | |
SearchResults () | |
SearchResults Constructor. | |
Public Attributes | |
event ResultAddedEventHandler | ResultAdded |
Event handler that gets called when a result was added the search results list. | |
event ResultsChangedEventHandler | ResultsChanged |
Event handler that gets called when the search results list was changed. | |
event ResultsClearedEventHandler | ResultsCleared |
Event handler that gets called when the search results were cleared. | |
Protected Attributes | |
bool | discard_old_results = false |
List< SearchResult > | results = new List<SearchResult>() |
Object | results_lock = new Object() |
the SearchResults lock to make this class thread safe | |
string | search_term = "" |
Properties | |
bool | DiscardOldResults [get, set] |
Set this to TRUE to automatically discard old search results received after starting a new search (TODO check if tth sources of others downloads wont be skipped too). | |
List< SearchResult > | Results [get] |
A list of search results (TODO to be deprecated and replaced with an enumerator). | |
string | SearchTerm [get, set] |
Get/Set the term to search for. | |
Private Attributes | |
string[] | search_terms |
array of search terms (space seperated words of the orignal search term) | |
Classes | |
class | SearchResult |
A class to hold the values read from a search result line orignating from a hub or was received via udp. More... |
Definition at line 12 of file SearchResults.cs.
DCPlusPlus.SearchResults.SearchResults | ( | ) |
void DCPlusPlus.SearchResults.AddResult | ( | SearchResult | result | ) |
Add a search result to the results list.
result | the result to be added |
Definition at line 494 of file SearchResults.cs.
References DCPlusPlus.SearchResults.SearchResult.Directory, DCPlusPlus.SearchResults.discard_old_results, DCPlusPlus.SearchResults.SearchResult.Filename, DCPlusPlus.SearchResults.SearchResult.IsDirectory, DCPlusPlus.SearchResults.SearchResult.IsFile, DCPlusPlus.SearchResults.ResultAdded, DCPlusPlus.SearchResults.results, DCPlusPlus.SearchResults.results_lock, DCPlusPlus.SearchResults.ResultsChanged, DCPlusPlus.SearchResults.search_term, and DCPlusPlus.SearchResults.search_terms.
Referenced by DCPlusPlus.Client.InterpretReceivedSearchResult().
00495 { 00496 00497 //discard old results if desired 00498 if (discard_old_results) 00499 { 00500 if (string.IsNullOrEmpty(search_term)) return; 00501 string path = ""; 00502 if (result.IsFile) 00503 path = result.Filename; 00504 else if (result.IsDirectory) 00505 path = result.Directory; 00506 00507 if (!string.IsNullOrEmpty(path)) 00508 { 00509 //check if search terms whitespace seperated match the path+filename in the result 00510 //if not discard result (return) 00511 bool all_terms_included = true; 00512 foreach (string term in search_terms) 00513 { 00514 if (!path.Contains(term)) 00515 all_terms_included = false; 00516 } 00517 if (!all_terms_included) 00518 return; 00519 00520 } 00521 } 00522 lock (results_lock) 00523 { 00524 results.Add(result); 00525 } 00526 try 00527 { 00528 if (ResultAdded != null) 00529 ResultAdded(this, result); 00530 00531 if (ResultsChanged != null) 00532 ResultsChanged(this, results.Count); 00533 } 00534 catch (Exception ex) 00535 { 00536 Console.WriteLine("Exception in event handler: " + ex.Message); 00537 } 00538 00539 }
Here is the caller graph for this function:
void DCPlusPlus.SearchResults.ClearResults | ( | ) |
Clear all results from the results list.
Definition at line 564 of file SearchResults.cs.
References DCPlusPlus.SearchResults.results, DCPlusPlus.SearchResults.results_lock, DCPlusPlus.SearchResults.ResultsChanged, DCPlusPlus.SearchResults.ResultsCleared, and DCPlusPlus.SearchResults.search_term.
00565 { 00566 search_term = ""; 00567 lock (results_lock) 00568 { 00569 results.Clear(); 00570 } 00571 try 00572 { 00573 if (ResultsCleared != null) 00574 ResultsCleared(this); 00575 00576 if (ResultsChanged != null) 00577 ResultsChanged(this, 0); 00578 } 00579 catch (Exception ex) 00580 { 00581 Console.WriteLine("Exception in event handler: " + ex.Message); 00582 } 00583 00584 }
void DCPlusPlus.SearchResults.RemoveResult | ( | SearchResult | result | ) |
Remove a search result from the results list.
result | the search result to remove |
Definition at line 544 of file SearchResults.cs.
References DCPlusPlus.SearchResults.results, DCPlusPlus.SearchResults.results_lock, and DCPlusPlus.SearchResults.ResultsChanged.
00545 { 00546 lock (results_lock) 00547 { 00548 results.Remove(result); 00549 } 00550 try 00551 { 00552 if (ResultsChanged != null) 00553 ResultsChanged(this, 0); 00554 } 00555 catch (Exception ex) 00556 { 00557 Console.WriteLine("Exception in event handler: " + ex.Message); 00558 } 00559 00560 }
delegate void DCPlusPlus.SearchResults.ResultAddedEventHandler | ( | SearchResults | s_results, | |
SearchResult | result | |||
) |
Prototype for the Result Added Event Handler.
s_results | the search results to which a result was added | |
result | the added search result |
delegate void DCPlusPlus.SearchResults.ResultsChangedEventHandler | ( | SearchResults | s_results, | |
int | num_results | |||
) |
Prototype for the Results Changed Event Handler (soon to be deprecated).
s_results | the search results that were changed | |
num_results | number of results in the search results list |
delegate void DCPlusPlus.SearchResults.ResultsClearedEventHandler | ( | SearchResults | s_results | ) |
Prototype for the Results Cleared Event Handler.
s_results | the search results that were cleared |
bool DCPlusPlus.SearchResults.discard_old_results = false [protected] |
event ResultAddedEventHandler DCPlusPlus.SearchResults.ResultAdded |
Event handler that gets called when a result was added the search results list.
Definition at line 47 of file SearchResults.cs.
Referenced by DCPlusPlus.SearchResults.AddResult().
List<SearchResult> DCPlusPlus.SearchResults.results = new List<SearchResult>() [protected] |
Definition at line 478 of file SearchResults.cs.
Referenced by DCPlusPlus.SearchResults.AddResult(), DCPlusPlus.SearchResults.ClearResults(), and DCPlusPlus.SearchResults.RemoveResult().
Object DCPlusPlus.SearchResults.results_lock = new Object() [protected] |
the SearchResults lock to make this class thread safe
Definition at line 466 of file SearchResults.cs.
Referenced by DCPlusPlus.SearchResults.AddResult(), DCPlusPlus.SearchResults.ClearResults(), and DCPlusPlus.SearchResults.RemoveResult().
event ResultsChangedEventHandler DCPlusPlus.SearchResults.ResultsChanged |
Event handler that gets called when the search results list was changed.
Definition at line 26 of file SearchResults.cs.
Referenced by DCPlusPlus.SearchResults.AddResult(), DCPlusPlus.SearchResults.ClearResults(), and DCPlusPlus.SearchResults.RemoveResult().
event ResultsClearedEventHandler DCPlusPlus.SearchResults.ResultsCleared |
Event handler that gets called when the search results were cleared.
Definition at line 36 of file SearchResults.cs.
Referenced by DCPlusPlus.SearchResults.ClearResults().
string DCPlusPlus.SearchResults.search_term = "" [protected] |
Definition at line 53 of file SearchResults.cs.
Referenced by DCPlusPlus.SearchResults.AddResult(), and DCPlusPlus.SearchResults.ClearResults().
string [] DCPlusPlus.SearchResults.search_terms [private] |
array of search terms (space seperated words of the orignal search term)
Definition at line 51 of file SearchResults.cs.
Referenced by DCPlusPlus.SearchResults.AddResult().
bool DCPlusPlus.SearchResults.DiscardOldResults [get, set] |
Set this to TRUE to automatically discard old search results received after starting a new search (TODO check if tth sources of others downloads wont be skipped too).
Definition at line 79 of file SearchResults.cs.
Referenced by DCPlusPlus.Client.Client().
List<SearchResult> DCPlusPlus.SearchResults.Results [get] |
A list of search results (TODO to be deprecated and replaced with an enumerator).
Definition at line 484 of file SearchResults.cs.
string DCPlusPlus.SearchResults.SearchTerm [get, set] |
Get/Set the term to search for.
Definition at line 58 of file SearchResults.cs.
Referenced by DCPlusPlus.Client.Search().