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

search.h

Go to the documentation of this file.
00001 /*
00002  * $Id: search.h,v 1.20 2006/02/01 23:13:21 cbiere Exp $
00003  *
00004  * Copyright (c) 2001-2003, Raphael Manfredi, Richard Eckart
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *----------------------------------------------------------------------
00024  */
00025 
00026 #ifndef _if_core_search_h_
00027 #define _if_core_search_h_
00028 
00029 #include "common.h"
00030 
00031 #include "lib/misc.h"
00032 #include "lib/vendors.h"
00033 #include "if/core/nodes.h"
00034 
00035 /***
00036  *** Searches
00037  ***/
00038 typedef guint32 gnet_search_t;
00039 
00040 /*
00041  * Flags for search_new()
00042  */
00043 enum {
00044     SEARCH_F_PASSIVE    = 1 << 0,   
00045     SEARCH_F_ENABLED    = 1 << 1,   
00046     SEARCH_F_BROWSE     = 1 << 2    
00047 };
00048 
00049 /*
00050  * Host vectors held in query hits.
00051  */
00052 typedef struct gnet_host_vec {
00053     gnet_host_t *hvec;      
00054     gint hvcnt;             
00055 } gnet_host_vec_t;
00056 
00057 /*
00058  * Result sets `status' flags.
00059  */
00060 #define ST_TLS              (1 << 10)   
00061 #define ST_BH               (1 << 9)    
00062 #define ST_KNOWN_VENDOR     (1 << 8)    
00063 #define ST_PARSED_TRAILER   (1 << 7)    
00064 #define ST_UDP              (1 << 6)    
00065 #define ST_BOGUS            (1 << 5)    
00066 #define ST_PUSH_PROXY       (1 << 4)    
00067 #define ST_GGEP             (1 << 3)    
00068 #define ST_UPLOADED         (1 << 2)    
00069 #define ST_BUSY             (1 << 1)    
00070 #define ST_FIREWALL         (1 << 0)    
00072 /*
00073  * Processing of ignored files.
00074  */
00075 #define SEARCH_IGN_DISPLAY_AS_IS    0   
00076 #define SEARCH_IGN_DISPLAY_MARKED   1   
00077 #define SEARCH_IGN_NO_DISPLAY       2   
00087 typedef struct gnet_results_set {
00088     gchar *guid;                
00089     host_addr_t addr;
00090     guint16 port;
00091     guint16 status;             
00092     guint32 speed;
00093     time_t  stamp;              
00094     union vendor_code vcode;    
00095     gchar *version;             
00096     gint country;               
00097     flag_t  flags;
00098     gnet_host_vec_t *proxies;   
00099     gchar *hostname;            
00100     host_addr_t udp_addr;       
00101     host_addr_t last_hop;       
00103     GSList *records;
00104     guint32 num_recs;
00105 } gnet_results_set_t;
00106 
00107 /*
00108  * Result record flags
00109  */
00110 #define SR_DOWNLOADED   0x0001
00111 #define SR_IGNORED      0x0002
00112 #define SR_DONT_SHOW    0x0004
00113 
00118 typedef struct gnet_record {
00119     gchar  *name;               
00120     filesize_t size;            
00121     guint32 index;              
00122     gchar  *sha1;               
00123     gchar  *tag;                
00124     gchar  *xml;                
00125     gnet_host_vec_t *alt_locs;  
00126     flag_t  flags;
00127 } gnet_record_t;
00128 
00129 
00133 typedef void (*search_got_results_listener_t)
00134     (GSList *, const gnet_results_set_t *);
00135 
00136 /*
00137  * Search public interface, visible only from the bridge.
00138  */
00139 
00140 #ifdef CORE_SOURCES
00141 
00142 gnet_search_t search_new(const gchar *, time_t create_time, guint lifetime,
00143         guint32 timeout, flag_t flags);
00144 void search_close(gnet_search_t sh);
00145 
00146 void search_start(gnet_search_t sh);
00147 void search_stop(gnet_search_t sh);
00148 
00149 /*  search_is_stopped doesn't exist yet!
00150 gboolean search_is_stopped(gnet_search_t sh);
00151 */
00152 
00153 void search_reissue(gnet_search_t sh);
00154 void search_add_kept(gnet_search_t sh, guint32 kept);
00155 
00156 gboolean search_is_passive(gnet_search_t sh);
00157 gboolean search_is_active(gnet_search_t sh);
00158 gboolean search_is_frozen(gnet_search_t sh);
00159 gboolean search_is_expired(gnet_search_t sh);
00160 
00161 void search_set_reissue_timeout(gnet_search_t sh, guint32 timeout);
00162 guint32 search_get_reissue_timeout(gnet_search_t sh);
00163 guint search_get_lifetime(gnet_search_t sh);
00164 time_t search_get_create_time(gnet_search_t sh);
00165 void search_set_create_time(gnet_search_t sh, time_t t);
00166 
00167 void search_free_alt_locs(gnet_record_t *rc);
00168 void search_free_proxies(gnet_results_set_t *rs);
00169 
00170 void search_update_items(gnet_search_t sh, guint32 items);
00171 
00172 gboolean search_browse(gnet_search_t sh,
00173     const gchar *hostname, host_addr_t addr, guint16 port,
00174     const gchar *guid, gboolean push, const gnet_host_vec_t *proxies);
00175 
00176 #endif /* CORE_SOURCES */
00177 #endif /* _if_core_search_h_ */
00178 
00179 /* vi: set ts=4 sw=4 cindent: */

Generated on Sun Feb 12 10:49:57 2006 for Gtk-Gnutella by doxygen 1.3.6