00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00037
00038 typedef guint32 gnet_search_t;
00039
00040
00041
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
00051
00052 typedef struct gnet_host_vec {
00053 gnet_host_t *hvec;
00054 gint hvcnt;
00055 } gnet_host_vec_t;
00056
00057
00058
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
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
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
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
00150
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
00177 #endif
00178
00179