2
* $Id: search_gui_common.h,v 1.13 2004/01/04 04:03:49 wyldfire Exp $
4
* Copyright (c) 2003, Raphael Manfredi
6
*----------------------------------------------------------------------
7
* This file is part of gtk-gnutella.
9
* gtk-gnutella is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* gtk-gnutella is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with gtk-gnutella; if not, write to the Free Software
22
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
*----------------------------------------------------------------------
26
#ifndef _search_gui_common_h_
27
#define _search_gui_common_h_
34
#define TAB_UPDATE_TIME 5 /* Update search tabs after 5 seconds */
37
* A results_set structure factorizes the common information from a Query Hit
38
* packet, and then has a list of individual records, one for each hit.
40
* A single structure is created for each Query Hit packet we receive, but
41
* then it can be dispatched for displaying some of its records to the
42
* various searches in presence. Each time the structure is dispatched,
43
* the `refcount' is incremented, so that we don't free it and its content
44
* until it has been "forgotten" that many times.
46
* NB: we reuse the pure data structure gnet_host_vec_t from the core. It
47
* is purely descriptive anyway.
49
typedef struct results_set {
50
gint refcount; /* Number of "struct search" this belongs to */
52
gchar *guid; /* Servent's GUID (atom) */
55
guint16 status; /* Parsed status bits from trailer */
57
time_t stamp; /* Reception time of the hit */
58
guchar vendor[4]; /* Vendor code */
59
gchar *version; /* Version information (atom) */
60
gnet_host_vec_t *proxies; /* Optional: known push proxies */
61
gchar *hostname; /* Optional: server's hostname */
77
* Host vector held in query hits.
79
typedef struct host_vec {
80
host_t *hvec; /* Vector of alternate locations */
81
gint hvcnt; /* Amount of hosts in vector */
85
* An individual hit. It referes to a file entry on the remote servent,
86
* as identified by the parent results_set structure that contains this hit.
88
* When a record is kept in a search window for display, it is put into
89
* a hash table and its `refcount' is incremented: since the parent structure
90
* can be dispatched to various searches, each record can be inserted in so
91
* many different hash tables (one per search).
93
typedef struct record {
94
results_set_t *results_set; /* Parent, containing record */
95
gint refcount; /* Number of hash tables it has been put to */
97
gchar *name; /* File name */
98
guint32 size; /* Size of file, in bytes */
99
guint32 index; /* Index for GET command */
100
guint32 count; /* Number of children */
101
gchar *sha1; /* SHA1 URN (binary form, atom) */
102
gchar *tag; /* Optional tag data string (atom) */
103
gchar *info; /* Short version of tag (atom) */
104
gnet_host_vec_t *alt_locs; /* Optional alternate locations for record */
105
flag_t flags; /* same flags as in gnet_record_t */
112
typedef struct search search_t;
114
void search_matched(search_t *sch, results_set_t *rs);
116
void search_gui_common_init(void);
117
void search_gui_common_shutdown(void);
119
search_t *search_gui_get_current_search(void);
120
void search_gui_set_current_search(search_t *sch);
121
void search_gui_forget_current_search();
122
void search_gui_current_search(search_t *sch);
124
void search_gui_free_alt_locs(record_t *rc);
125
void search_gui_free_proxies(results_set_t *rs);
126
void search_gui_free_record(record_t *rc);
127
void search_gui_clean_r_set(results_set_t *rs);
128
void search_gui_free_r_set(results_set_t *rs);
129
void search_gui_dispose_results(results_set_t *rs);
130
void search_gui_ref_record(record_t *rc);
131
void search_gui_unref_record(record_t *rc);
132
void search_gui_free_r_sets(search_t *sch);
133
guint search_gui_hash_func(const record_t *key);
134
gint search_gui_hash_key_compare(const record_t *a, const record_t *b);
135
void search_gui_remove_r_set(search_t *sch, results_set_t *rs);
136
gboolean search_gui_result_is_dup(search_t *sch, record_t *rc);
137
search_t *search_gui_find(gnet_search_t sh);
138
record_t *search_gui_create_record(results_set_t *rs, gnet_record_t *r) ;
139
void search_gui_check_alt_locs(results_set_t *rs, record_t *rc);
140
void search_gui_store_searches(void);
141
void search_gui_retrieve_searches(void);
142
void search_gui_got_results(GSList *schl, const gnet_results_set_t *r_set);
143
void search_gui_flush(time_t);
145
#endif /* _search_gui_common_h_ */