#include "gui.h"
#include "search.h"
#include "settings.h"
#include "gtk-missing.h"
#include "search_xml.h"
#include <libxml/parser.h>
#include "gtk/statusbar.h"
#include "if/gui_property_priv.h"
#include "if/gnet_property.h"
#include "if/core/downloads.h"
#include "if/core/guid.h"
#include "if/core/sockets.h"
#include "if/bridge/ui2c.h"
#include "lib/atoms.h"
#include "lib/base32.h"
#include "lib/fuzzy.h"
#include "lib/file.h"
#include "lib/glib-missing.h"
#include "lib/vendors.h"
#include "lib/tm.h"
#include "lib/urn.h"
#include "lib/utf8.h"
#include "lib/zalloc.h"
#include "lib/walloc.h"
#include "lib/override.h"
Data Structures | |
struct | query |
Functions | |
RCSID ("$Id:search_common.c, v 1.74 2006/02/01 23:13:21 cbiere Exp $") | |
search_t * | search_gui_get_current_search (void) |
void | search_gui_forget_current_search (void) |
void | on_option_menu_menu_item_activate (GtkMenuItem *unused_item, gpointer udata) |
void | search_gui_option_menu_searches_update (void) |
void | search_gui_option_menu_searches_select (const search_t *sch) |
void | search_gui_current_search (search_t *sch) |
gboolean | search_gui_new_search (const gchar *query, flag_t flags, search_t **search) |
Create a new search and start it. | |
void | search_gui_free_alt_locs (record_t *rc) |
Free the alternate locations held within a file record. | |
gnet_host_vec_t * | search_gui_proxies_clone (gnet_host_vec_t *v) |
Clone the proxies list given by the core. | |
void | search_gui_host_vec_free (gnet_host_vec_t *v) |
Free the cloned vector of host. | |
void | search_gui_free_proxies (results_set_t *rs) |
Free the push proxies held within a result set. | |
void | search_gui_free_record (record_t *rc) |
Free one file record. | |
const gchar * | search_gui_extract_ext (const gchar *filename) |
Tries to extract the extenstion of a file from the filename. | |
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 | free_r_sets_helper (gpointer data, gpointer unused_udata) |
Free all the results_set's of a search. | |
void | search_gui_free_r_sets (search_t *sch) |
guint | search_gui_hash_func (gconstpointer p) |
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_t * | search_gui_create_record (results_set_t *rs, gnet_record_t *r) |
Create a new GUI record within `rs' from a Gnutella record. | |
results_set_t * | search_gui_create_results_set (GSList *schl, const gnet_results_set_t *r_set) |
Create a new GUI result set from a Gnutella one. | |
void | on_search_entry_activate (GtkWidget *unused_widget, gpointer unused_udata) |
void | on_option_menu_search_changed (GtkOptionMenu *option_menu, gpointer unused_udata) |
void | search_gui_common_init (void) |
Initialize common structures. | |
void | search_gui_common_shutdown (void) |
Destroy common structures. | |
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_matched (search_t *sch, results_set_t *rs) |
Called to dispatch results to the search window. | |
void | search_gui_update_items (const struct search *sch) |
Update the label string showing search stats. | |
gboolean | search_gui_is_expired (const struct search *sch) |
gboolean | search_gui_update_expiry (const struct search *sch) |
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 now) |
Periodic timer to flush the accumulated hits during the period and dispatch them to the GUI. | |
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_restart_search (search_t *sch) |
Restart a search from scratch, clearing all existing content. | |
void | search_gui_parse_text_query (const gchar *s, struct query *query) |
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). | |
gchar * | search_xml_indent (const gchar *s) |
Adds some indendation to XML-like text. | |
void | search_gui_history_add (const gchar *s) |
Adds a search string to the search history combo. | |
void | search_gui_new_search_entered (void) |
Create a new search from a query entered by the user. | |
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. | |
Variables | |
search_t * | current_search = NULL |
The search currently displayed. | |
zone_t * | rs_zone |
Allocation of results_set. | |
zone_t * | rc_zone |
Allocation of record. | |
const gchar | search_file [] = "searches" |
"old" file to searches | |
GSList * | accumulated_rs = NULL |
GList * | list_search_history = NULL |
GtkLabel * | label_items_found = NULL |
GtkLabel * | label_search_expiry = NULL |
struct { | |
guint32 flag | |
const gchar * status | |
} | open_flags [] |
Human readable translation of servent trailer open flags. |
|
Free all the results_set's of a search.
|
|
|
|
|
|
|
|
|
|
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.
|
|
Check for alternate locations in the result set, and enqueue the downloads if there are any. Then free the alternate location from the record. |
|
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. |
|
Initialize common structures.
|
|
Destroy common structures.
|
|
Create a new GUI record within `rs' from a Gnutella record.
|
|
Create a new GUI result set from a Gnutella one.
|
|
|
|
Dispose of an empty search results, whose records have all been unreferenced by the searches. The results_set is therefore an empty shell, useless. |
|
Tries to extract the extenstion of a file from the filename. The return value is only valid until the function is called again. |
|
Initializes a new filter for the search ``sch'' and adds the rules from the rule list ``rules'' (if any).
|
|
|
|
Periodic timer to flush the accumulated hits during the period and dispatch them to the GUI.
|
|
|
|
Free the alternate locations held within a file record.
|
|
Free the push proxies held within a result set.
|
|
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. |
|
|
|
Free one file record. Those records may be inserted into some `dups' tables, at which time they have their refcount increased. They may later be removed from those tables and they will have their refcount decreased. To ensure some level of sanity, we ask our callers to explicitely check for a refcount to be zero before calling us. |
|
|
|
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.
|
|
Called when the core has finished parsing the result set, and the results need to be dispatched to the searches listed in `schl'.
|
|
|
|
|
|
Adds a search string to the search history combo. Makes sure we do not get more than 10 entries in the history. Also makes sure we don't get duplicate history entries. If a string is already in history and it's added again, it's moved to the beginning of the history list. |
|
Free the cloned vector of host.
|
|
|
|
Create a new "browse host" type search.
|
|
Create a new search and start it. Use default reissue timeout. |
|
Create a new search from a query entered by the user.
|
|
|
|
|
|
Parses a query string as entered by the user.
|
|
|
|
Clone the proxies list given by the core.
|
|
Add a reference to the record but don't dare to redeem it!
|
|
Remove reference to results in our search. Last one to remove it will trigger a free. |
|
Restart a search from scratch, clearing all existing content.
|
|
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.
|
|
Retrieve searches from disk.
|
|
Makes the sort column and order of the current search the default settings.
|
|
Persist searches to disk.
|
|
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. |
|
|
|
Update the label string showing search stats.
|
|
Called to dispatch results to the search window.
|
|
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.
|
|
|
|
The search currently displayed.
|
|
|
|
|
|
|
|
|
|
Human readable translation of servent trailer open flags. Decompiled flags are listed in the order of the table. |
|
Allocation of record.
|
|
Allocation of results_set.
|
|
"old" file to searches
|
|
|