Main Page | Modules | Alphabetical List | Data Structures | Directories | 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  record
 An individual hit. More...
struct  query

Defines

#define TAB_UPDATE_TIME   5
 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 record record_t
 An individual hit.

Enumerations

enum  results_set_magic_t { RESULTS_SET_MAGIC = 0xa44eb853U }
enum  record_magic_t { RECORD_MAGIC = 0x3fb9c04e }
enum  gui_color {
  GUI_COLOR_DEFAULT, GUI_COLOR_DOWNLOADING, GUI_COLOR_HOSTILE, GUI_COLOR_IGNORED,
  GUI_COLOR_MARKED, GUI_COLOR_MAYBE_SPAM, GUI_COLOR_SPAM, GUI_COLOR_UNREQUESTED,
  NUM_GUI_COLORS
}

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 record_check (const record_t *const rc)
void results_set_check (const results_set_t *const rs)
void gui_color_init (GtkWidget *widget)
GdkColor * gui_color_get (enum gui_color id)
void gui_color_set (const enum gui_color id, GdkColor *color)
void gui_search_get_colors (search_t *sch, GdkColor **mark_color, GdkColor **ignore_color)
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_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.
guint search_gui_hash_func (gconstpointer key)
gint search_gui_hash_key_compare (gconstpointer a, gconstpointer b)
const gchar * search_gui_get_route (const struct results_set *rs)
search_t * search_gui_find (gnet_search_t sh)
const 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.
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_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, gboolean force)
 Periodic timer to flush the accumulated hits during the period and dispatch them to the GUI.
querysearch_gui_handle_query (const gchar *query_str, flag_t flags, const gchar **error_str)
 Handles a query string as entered by the user.
void search_gui_query_free (struct query **query_ptr)
 Frees a "struct query" and nullifies the given pointer.
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, const gnet_host_vec_t *proxies, guint32 flags)
 Create a new "browse host" type search.
void search_gui_add_targetted_search (gpointer data, gpointer unused_udata)
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.
gboolean search_gui_handle_magnet (const gchar *url, const gchar **error_str)
gboolean search_gui_handle_url (const gchar *url, const gchar **error_str)
gboolean search_gui_handle_urn (const gchar *url, const gchar **error_str)
gboolean search_gui_insert_query (const gchar *text)
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)
void on_spinbutton_search_reissue_timeout_activate (GtkEditable *editable, gpointer user_data)
gboolean on_spinbutton_search_reissue_timeout_focus_out_event (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
void on_spinbutton_search_reissue_timeout_changed (GtkEditable *editable, gpointer unused_udata)
gint search_gui_cmp_sha1s (const struct sha1 *a, const struct sha1 *b)
void search_gui_duplicate_search (search_t *search)
void search_gui_restart_search (search_t *search)
 Restart a search from scratch, clearing all existing content.
void search_gui_resume_search (search_t *search)
void search_gui_stop_search (search_t *search)
void on_popup_search_download_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_drop_name_activate (GtkMenuItem *menuitem, gpointer user_data)
 For all selected results, create a filter based on name.
void on_popup_search_drop_sha1_activate (GtkMenuItem *menuitem, gpointer user_data)
 For all selected results, create a filter based on sha1.
void on_popup_search_drop_host_activate (GtkMenuItem *menuitem, gpointer user_data)
 For all selected results, create a filter based on host.
void on_popup_search_drop_name_global_activate (GtkMenuItem *menuitem, gpointer user_data)
 For all selected results, create a global filter based on name.
void on_popup_search_drop_sha1_global_activate (GtkMenuItem *menuitem, gpointer user_data)
 For all selected results, create a global filter based on sha1.
void on_popup_search_drop_host_global_activate (GtkMenuItem *menuitem, gpointer user_data)
 For all selected results, create a global filter based on host.
void on_popup_search_edit_filter_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_clear_results_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_close_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_duplicate_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_restart_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_resume_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_stop_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_config_cols_activate (GtkMenuItem *menuitem, gpointer user_data)
 Please add comment.
void on_popup_search_expand_all_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_collapse_all_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_metadata_activate (GtkMenuItem *menuitem, gpointer user_data)
 Queue a bitzi queries from the search context menu.
void on_popup_search_copy_magnet_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_list_clear_results_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_list_close_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_list_duplicate_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_list_restart_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_list_resume_activate (GtkMenuItem *menuitem, gpointer user_data)
void on_popup_search_list_stop_activate (GtkMenuItem *menuitem, gpointer user_data)
gboolean on_search_list_button_press_event (GtkWidget *unused_widget, GdkEventButton *event, gpointer unused_udata)
GSList * search_gui_get_selected_searches (void)
gboolean search_gui_has_selected_item (search_t *search)
void search_gui_refresh_popup (void)
void search_gui_search_list_clicked (GtkWidget *widget, GdkEventButton *event)
void search_gui_flush_queues (void)
const gchar * search_gui_query (const search_t *search)
gboolean search_gui_is_browse (const search_t *search)
gboolean search_gui_is_enabled (const search_t *search)
gboolean search_gui_is_local (const search_t *search)
gboolean search_gui_is_passive (const search_t *search)
void search_gui_download (record_t *rc)
const gchar * search_gui_nice_size (const record_t *rc)
const gchar * search_gui_get_vendor (const struct results_set *rs)
void search_gui_set_details (const record_t *rc)
gchar * gnet_host_vec_to_string (const gnet_host_vec_t *hvec)
void search_gui_clear_details (void)
void search_gui_append_detail (const gchar *title, const gchar *value)


Define Documentation

#define TAB_UPDATE_TIME   5
 

Update search tabs after 5 seconds.


Typedef Documentation

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 gui_color
 

Enumeration values:
GUI_COLOR_DEFAULT 
GUI_COLOR_DOWNLOADING 
GUI_COLOR_HOSTILE 
GUI_COLOR_IGNORED 
GUI_COLOR_MARKED 
GUI_COLOR_MAYBE_SPAM 
GUI_COLOR_SPAM 
GUI_COLOR_UNREQUESTED 
NUM_GUI_COLORS 

enum record_magic_t
 

Enumeration values:
RECORD_MAGIC 

enum results_set_magic_t
 

Enumeration values:
RESULTS_SET_MAGIC 


Function Documentation

gchar* gnet_host_vec_to_string const gnet_host_vec_t hvec  ) 
 

GdkColor* gui_color_get enum gui_color  id  ) 
 

void gui_color_init GtkWidget *  widget  ) 
 

void gui_color_set const enum gui_color  id,
GdkColor *  color
 

void gui_search_get_colors search_t *  sch,
GdkColor **  mark_color,
GdkColor **  ignore_color
 

void on_option_menu_search_changed GtkOptionMenu *  option_menu,
gpointer  unused_udata
 

void on_popup_search_clear_results_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_close_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_collapse_all_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_config_cols_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

Please add comment.

void on_popup_search_copy_magnet_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_download_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_drop_host_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

For all selected results, create a filter based on host.

void on_popup_search_drop_host_global_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

For all selected results, create a global filter based on host.

void on_popup_search_drop_name_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

For all selected results, create a filter based on name.

void on_popup_search_drop_name_global_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

For all selected results, create a global filter based on name.

void on_popup_search_drop_sha1_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

For all selected results, create a filter based on sha1.

void on_popup_search_drop_sha1_global_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

For all selected results, create a global filter based on sha1.

void on_popup_search_duplicate_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_edit_filter_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_expand_all_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_list_clear_results_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_list_close_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_list_duplicate_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_list_restart_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_list_resume_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_list_stop_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_metadata_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

Queue a bitzi queries from the search context menu.

void on_popup_search_restart_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_resume_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

void on_popup_search_stop_activate GtkMenuItem *  menuitem,
gpointer  user_data
 

gboolean on_search_list_button_press_event GtkWidget *  unused_widget,
GdkEventButton *  event,
gpointer  unused_udata
 

void on_spinbutton_search_reissue_timeout_activate GtkEditable *  editable,
gpointer  user_data
 

void on_spinbutton_search_reissue_timeout_changed GtkEditable *  editable,
gpointer  unused_udata
 

gboolean on_spinbutton_search_reissue_timeout_focus_out_event GtkWidget *  widget,
GdkEventFocus *  event,
gpointer  user_data
 

void record_check const record_t *const   rc  )  [inline, static]
 

void results_set_check const results_set_t *const   rs  )  [inline, static]
 

void search_add_got_results_listener search_got_results_listener_t  l  ) 
 

void search_gui_add_targetted_search gpointer  data,
gpointer  unused_udata
 

void search_gui_append_detail const gchar *  title,
const gchar *  value
 

void search_gui_browse_selected void   ) 
 

Request host browsing for the selected entries.

void search_gui_clear_details void   ) 
 

gint search_gui_cmp_sha1s const struct sha1 a,
const struct sha1 b
 

void search_gui_common_init void   ) 
 

Initialize common structures.

void search_gui_common_shutdown void   ) 
 

Destroy common structures.

void search_gui_current_search search_t *  sch  ) 
 

void search_gui_download record_t rc  ) 
 

void search_gui_duplicate_search search_t *  search  ) 
 

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  now,
gboolean  force
 

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

void search_gui_flush_queues void   ) 
 

void search_gui_forget_current_search void   ) 
 

search_t* search_gui_get_current_search void   ) 
 

const 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.

const gchar* search_gui_get_route const struct results_set rs  ) 
 

Returns:
a string showing the route information for the given result record. The return string uses a static buffer.
Note:
If the result is from a local search or browse host, NULL is returned.

GSList* search_gui_get_selected_searches void   ) 
 

const gchar* search_gui_get_vendor const struct results_set rs  ) 
 

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'.

gboolean search_gui_handle_magnet const gchar *  url,
const gchar **  error_str
 

struct query* search_gui_handle_query const gchar *  query_str,
flag_t  flags,
const gchar **  error_str
 

Handles a query string as entered by the user.

This does also handle magnets and special search strings. These will be handled immediately which means that multiple searches and downloads might have been initiated when the functions returns.

Parameters:
query_str must point to the query string.
flags Diverse SEARCH_F_* flags.
error_str Will be set to NULL on success or point to an error message for the user on failure.
Returns:
NULL if no search should be created. This is not necessarily a failure condition, check error_str instead. If a search should be created, an initialized "struct query" is returned.

gboolean search_gui_handle_url const gchar *  url,
const gchar **  error_str
 

gboolean search_gui_handle_urn const gchar *  url,
const gchar **  error_str
 

gboolean search_gui_has_selected_item search_t *  search  ) 
 

guint search_gui_hash_func gconstpointer  key  ) 
 

gint search_gui_hash_key_compare gconstpointer  a,
gconstpointer  b
 

gboolean search_gui_insert_query const gchar *  text  ) 
 

gboolean search_gui_is_browse const search_t *  search  ) 
 

gboolean search_gui_is_enabled const search_t *  search  ) 
 

gboolean search_gui_is_expired const struct search sch  ) 
 

gboolean search_gui_is_local const search_t *  search  ) 
 

gboolean search_gui_is_passive const search_t *  search  ) 
 

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

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
proxies vector holding known push-proxies
flags connection flags like SOCK_F_PUSH, SOCK_F_TLS etc.
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.

const gchar* search_gui_nice_size const record_t rc  ) 
 

void search_gui_option_menu_searches_select const search_t *  sch  ) 
 

void search_gui_option_menu_searches_update void   ) 
 

const gchar* search_gui_query const search_t *  search  ) 
 

void search_gui_query_free struct query **  query_ptr  ) 
 

Frees a "struct query" and nullifies the given pointer.

void search_gui_ref_record record_t rc  ) 
 

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

void search_gui_refresh_popup void   ) 
 

void search_gui_restart_search search_t *  search  ) 
 

Restart a search from scratch, clearing all existing content.

void search_gui_resume_search search_t *  search  ) 
 

void search_gui_retrieve_searches void   ) 
 

Retrieve searches from disk.

void search_gui_search_list_clicked GtkWidget *  widget,
GdkEventButton *  event
 

void search_gui_set_current_search search_t *  sch  ) 
 

void search_gui_set_details const record_t rc  ) 
 

void search_gui_set_sort_defaults void   ) 
 

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

void search_gui_stop_search search_t *  search  ) 
 

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_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 Sat Jun 30 17:53:30 2007 for gtk-gnutella by  doxygen 1.3.9.1