Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

search_common.h File Reference

#include "if/core/search.h"
#include "if/ui/gtk/search.h"
#include "search.h"

Go to the source code of this file.

Data Structures

struct  results_set
 A results_set structure factorizes the common information from a Query Hit packet, and then has a list of individual records, one for each hit. More...

struct  host_vec
 Host vector held in query hits. More...

struct  record
 An individual hit. More...


Defines

#define TAB_UPDATE_TIME   5 /**< Update search tabs after 5 seconds */
 Update search tabs after 5 seconds.


Typedefs

typedef results_set results_set_t
 A results_set structure factorizes the common information from a Query Hit packet, and then has a list of individual records, one for each hit.

typedef host_vec host_vec_t
 Host vector held in query hits.

typedef record record_t
 An individual hit.


Enumerations

enum  record_magic_t { RECORD_MAGIC = 0x3fb9c04e }

Functions

void search_add_got_results_listener (search_got_results_listener_t l)
void search_remove_got_results_listener (search_got_results_listener_t l)
void search_matched (search_t *sch, results_set_t *rs)
 Called to dispatch results to the search window.

void search_gui_common_init (void)
 Initialize common structures.

void search_gui_common_shutdown (void)
 Destroy common structures.

search_t * search_gui_get_current_search (void)
void search_gui_set_current_search (search_t *sch)
void search_gui_forget_current_search (void)
void search_gui_current_search (search_t *sch)
void search_gui_free_alt_locs (record_t *rc)
 Free the alternate locations held within a file record.

void search_gui_host_vec_free (gnet_host_vec_t *v)
 Free the cloned vector of host.

gnet_host_vec_tsearch_gui_proxies_clone (gnet_host_vec_t *v)
 Clone the proxies list given by the core.

void search_gui_free_proxies (results_set_t *rs)
 Free the push proxies held within a result set.

void search_gui_clean_r_set (results_set_t *rs)
 This routine must be called when the results_set has been dispatched to all the opened searches.

void search_gui_free_r_set (results_set_t *rs)
 Free one results_set.

void search_gui_dispose_results (results_set_t *rs)
 Dispose of an empty search results, whose records have all been unreferenced by the searches.

void search_gui_ref_record (record_t *rc)
 Add a reference to the record but don't dare to redeem it!

void search_gui_unref_record (record_t *rc)
 Remove one reference to a file record.

void search_gui_free_r_sets (search_t *sch)
guint search_gui_hash_func (gconstpointer key)
gint search_gui_hash_key_compare (gconstpointer a, gconstpointer b)
void search_gui_remove_r_set (search_t *sch, results_set_t *rs)
 Remove reference to results in our search.

gboolean search_gui_result_is_dup (search_t *sch, record_t *rc)
 Check to see whether we already have a record for this file.

search_t * search_gui_find (gnet_search_t sh)
gchar * search_gui_get_filename_extension (const gchar *filename_utf8)
 Extract the filename extensions - if any - from the given UTF-8 encoded filename and convert it to lowercase.

record_tsearch_gui_create_record (results_set_t *rs, gnet_record_t *r)
 Create a new GUI record within `rs' from a Gnutella record.

void search_gui_check_alt_locs (results_set_t *rs, record_t *rc)
 Check for alternate locations in the result set, and enqueue the downloads if there are any.

void search_gui_set_sort_defaults (void)
 Makes the sort column and order of the current search the default settings.

void search_gui_store_searches (void)
 Persist searches to disk.

void search_gui_retrieve_searches (void)
 Retrieve searches from disk.

void search_gui_restart_search (search_t *sch)
 Restart a search from scratch, clearing all existing content.

void search_gui_got_results (GSList *schl, const gnet_results_set_t *r_set)
 Called when the core has finished parsing the result set, and the results need to be dispatched to the searches listed in `schl'.

void search_gui_flush (time_t)
 Periodic timer to flush the accumulated hits during the period and dispatch them to the GUI.

const gchar * search_gui_parse_query (const gchar *querystr, GList **rules, const gchar **error)
 Parses a query string as entered by the user.

void search_gui_filter_new (search_t *sch, GList *rules)
 Initializes a new filter for the search ``sch'' and adds the rules from the rule list ``rules'' (if any).

gboolean search_gui_new_browse_host (const gchar *hostname, host_addr_t addr, guint16 port, const gchar *guid, gboolean push, const gnet_host_vec_t *proxies)
 Create a new "browse host" type search.

void search_gui_add_targetted_search (gpointer data, gpointer unused_udata)
 Creates a new search based on the filename found and adds a filter to it based on the sha1 hash if it has one or the exact filename if it hasn't.

void search_gui_update_items (const struct search *)
 Update the label string showing search stats.

gboolean search_gui_update_expiry (const struct search *sch)
gboolean search_gui_is_expired (const struct search *sch)
void search_gui_new_search_entered (void)
 Create a new search from a query entered by the user.

void search_gui_option_menu_searches_update (void)
void search_gui_option_menu_searches_select (const search_t *sch)
void search_gui_browse_selected (void)
 Request host browsing for the selected entries.

gchar * search_xml_indent (const gchar *s)
 Adds some indendation to XML-like text.

void on_option_menu_search_changed (GtkOptionMenu *option_menu, gpointer unused_udata)


Define Documentation

#define TAB_UPDATE_TIME   5 /**< Update search tabs after 5 seconds */
 

Update search tabs after 5 seconds.


Typedef Documentation

typedef struct host_vec host_vec_t
 

Host vector held in query hits.

typedef struct record record_t
 

An individual hit.

It referes to a file entry on the remote servent, as identified by the parent results_set structure that contains this hit.

When a record is kept in a search window for display, it is put into a hash table and its `refcount' is incremented: since the parent structure can be dispatched to various searches, each record can be inserted in so many different hash tables (one per search).

typedef struct results_set results_set_t
 

A results_set structure factorizes the common information from a Query Hit packet, and then has a list of individual records, one for each hit.

A single structure is created for each Query Hit packet we receive, but then it can be dispatched for displaying some of its records to the various searches in presence. Each time the structure is dispatched, the `refcount' is incremented, so that we don't free it and its content until it has been "forgotten" that many times.

Attention:
NB: we reuse the pure data structure gnet_host_vec_t from the core. It is purely descriptive anyway.


Enumeration Type Documentation

enum record_magic_t
 

Enumeration values:
RECORD_MAGIC 


Function Documentation

void on_option_menu_search_changed GtkOptionMenu *  option_menu,
gpointer  unused_udata
 

void search_add_got_results_listener search_got_results_listener_t  l  ) 
 

void search_gui_add_targetted_search gpointer  data,
gpointer  unused_udata
 

Creates a new search based on the filename found and adds a filter to it based on the sha1 hash if it has one or the exact filename if it hasn't.

Author:
Andrew Meredith <andrew@anvil.org>

void search_gui_browse_selected void   ) 
 

Request host browsing for the selected entries.

void search_gui_check_alt_locs results_set_t rs,
record_t rc
 

Check for alternate locations in the result set, and enqueue the downloads if there are any.

Then free the alternate location from the record.

void search_gui_clean_r_set results_set_t rs  ) 
 

This routine must be called when the results_set has been dispatched to all the opened searches.

All the records that have not been used by a search are removed.

void search_gui_common_init void   ) 
 

Initialize common structures.

void search_gui_common_shutdown void   ) 
 

Destroy common structures.

record_t* search_gui_create_record results_set_t rs,
gnet_record_t r
 

Create a new GUI record within `rs' from a Gnutella record.

void search_gui_current_search search_t *  sch  ) 
 

void search_gui_dispose_results results_set_t rs  ) 
 

Dispose of an empty search results, whose records have all been unreferenced by the searches.

The results_set is therefore an empty shell, useless.

void search_gui_filter_new search_t *  sch,
GList *  rules
 

Initializes a new filter for the search ``sch'' and adds the rules from the rule list ``rules'' (if any).

Parameters:
sch a new search
rules a GList with items of type (rule_t *). ``rules'' may be NULL.

search_t* search_gui_find gnet_search_t  sh  ) 
 

Returns:
a pointer to gui_search_t from gui_searches which has sh as search_handle. If none is found, return NULL.

void search_gui_flush time_t   ) 
 

Periodic timer to flush the accumulated hits during the period and dispatch them to the GUI.

void search_gui_forget_current_search void   ) 
 

void search_gui_free_alt_locs record_t rc  ) 
 

Free the alternate locations held within a file record.

void search_gui_free_proxies results_set_t rs  ) 
 

Free the push proxies held within a result set.

void search_gui_free_r_set results_set_t rs  ) 
 

Free one results_set.

Those records may be shared between several searches. So while the refcount is positive, we just decrement it and return without doing anything.

void search_gui_free_r_sets search_t *  sch  ) 
 

search_t* search_gui_get_current_search void   ) 
 

gchar* search_gui_get_filename_extension const gchar *  filename_utf8  ) 
 

Extract the filename extensions - if any - from the given UTF-8 encoded filename and convert it to lowercase.

If the extension exceeds a certain length, it is assumed that it's no extension but just a non-specific dot inside a filename.

Returns:
NULL if there's no filename extension, otherwise a pointer to a static string holding the lowercased extension.

void search_gui_got_results GSList *  schl,
const gnet_results_set_t r_set
 

Called when the core has finished parsing the result set, and the results need to be dispatched to the searches listed in `schl'.

guint search_gui_hash_func gconstpointer  key  ) 
 

gint search_gui_hash_key_compare gconstpointer  a,
gconstpointer  b
 

void search_gui_host_vec_free gnet_host_vec_t v  ) 
 

Free the cloned vector of host.

gboolean search_gui_is_expired const struct search sch  ) 
 

gboolean search_gui_new_browse_host const gchar *  hostname,
host_addr_t  addr,
guint16  port,
const gchar *  guid,
gboolean  push,
const gnet_host_vec_t proxies
 

Create a new "browse host" type search.

Parameters:
hostname the DNS name of the host, or NULL if none known
addr the IP address of the host to browse
port the port to contact
guid the GUID of the remote host
push whether a PUSH request is neeed to reach remote host
proxies vector holding known push-proxies
Returns:
whether the browse host request could be launched.

void search_gui_new_search_entered void   ) 
 

Create a new search from a query entered by the user.

void search_gui_option_menu_searches_select const search_t *  sch  ) 
 

void search_gui_option_menu_searches_update void   ) 
 

const gchar* search_gui_parse_query const gchar *  querystr,
GList **  rules,
const gchar **  error
 

Parses a query string as entered by the user.

Parameters:
querystr must point to the query string.
**rules 
*error will point to an descriptive error message on failure.
Returns:
NULL if the query was not valid. Otherwise, the decoded query is returned.

gnet_host_vec_t* search_gui_proxies_clone gnet_host_vec_t v  ) 
 

Clone the proxies list given by the core.

void search_gui_ref_record record_t rc  ) 
 

Add a reference to the record but don't dare to redeem it!

void search_gui_remove_r_set search_t *  sch,
results_set_t rs
 

Remove reference to results in our search.

Last one to remove it will trigger a free.

void search_gui_restart_search search_t *  sch  ) 
 

Restart a search from scratch, clearing all existing content.

gboolean search_gui_result_is_dup search_t *  sch,
record_t rc
 

Check to see whether we already have a record for this file.

If we do, make sure that the index is still accurate, otherwise inform the interested parties about the change.

Returns:
true if the record is a duplicate.

void search_gui_retrieve_searches void   ) 
 

Retrieve searches from disk.

void search_gui_set_current_search search_t *  sch  ) 
 

void search_gui_set_sort_defaults void   ) 
 

Makes the sort column and order of the current search the default settings.

void search_gui_store_searches void   ) 
 

Persist searches to disk.

void search_gui_unref_record record_t rc  ) 
 

Remove one reference to a file record.

If the record has no more references, remove it from its parent result set and free the record physically.

gboolean search_gui_update_expiry const struct search sch  ) 
 

void search_gui_update_items const struct search  ) 
 

Update the label string showing search stats.

void search_matched search_t *  sch,
results_set_t rs
 

Called to dispatch results to the search window.

void search_remove_got_results_listener search_got_results_listener_t  l  ) 
 

gchar* search_xml_indent const gchar *  s  ) 
 

Adds some indendation to XML-like text.

The input text is assumed to be "flat" and well-formed. If these assumptions fail, the output might look worse than the input.

Parameters:
s the string to format.
Returns:
a newly allocated string.


Generated on Sun Feb 12 10:50:07 2006 for Gtk-Gnutella by doxygen 1.3.6