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

bitzi.c File Reference


Detailed Description

Bitzi Core search code.

This code makes searches to the Bitzi (bitzi.com) meta-data service. It is independent from any GUI functions and part of the core of GTKG.

Note:
The code requires libxml to parse the XML responses.
Author:
Alex Bennee <alex@bennee.com>
Date:
2004

#include "common.h"
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "http.h"
#include "bitzi.h"
#include "settings.h"
#include "if/bridge/c2ui.h"
#include "if/gnet_property_priv.h"
#include "lib/atoms.h"
#include "lib/getdate.h"
#include "lib/glib-missing.h"
#include "lib/tm.h"
#include "lib/walloc.h"
#include "lib/override.h"

Data Structures

struct  bitzi_request_t
 The bitzi_request_t structure ties together each Bitzi request which are stored in the request queue. More...

struct  efj_t
 Parse (and eventually fill in) the bitzi specific data. More...


Functions

gboolean do_metadata_query (bitzi_request_t *req)
 Send a meta-data query.

void process_meta_data (bitzi_request_t *req)
 Walk the parsed document tree and free up the data.

gboolean bitzi_cache_add (bitzi_data_t *data)
void bitzi_cache_remove (bitzi_data_t *data)
void bitzi_cache_clean (void)
gchar * xml_get_string (xmlNode *node, const gchar *id)
const xmlChar * string_to_xmlChar (const gchar *s)
const gchar * xmlChar_to_gchar (const xmlChar *s)
bitzi_data_tbitzi_create (void)
void bitzi_destroy (bitzi_data_t *data)
void bitzi_host_data_ind (gpointer unused_handle, gchar *data, gint len)
 Populate callback: more data available.

void bitzi_host_error_ind (gpointer handle, http_errtype_t unused_type, gpointer unused_v)
 HTTP request is being stopped.

void process_rdf_description (xmlNode *node, bitzi_data_t *data)
 Read all the attributes we may want from the rdf ticket, some atributes will not be there in which case xmlGetProp will return a null.

void process_bitzi_ticket (xmlNode *a_node, bitzi_data_t *data)
 Iterates through the XML/RDF ticket calling various process functions to read the data into the bitzi_data_t.

gint bitzi_date_compare (gconstpointer p, gconstpointer q)
 Add the data entry to the cache and in expiry sorted date order to the linked list.

gboolean bitzi_heartbeat (gpointer unused_data)
 The heartbeat function is a repeating glib timeout that is used to pace queries to the bitzi metadata service.

bitzi_data_tbitzi_querycache_byurnsha1 (const gchar *urnsha1)
 Query the bitzi cache for this given urnsha1, return NULL if nothing otherwise we return the.

gpointer bitzi_query_byurnsha1 (const gchar *urnsha1)
 A GUI/Bitzi API passes a pointer to the search type (currently only urn:sha1), a pointer to a callback function and a user data pointer.

void bitzi_init (void)
 Initialise any bitzi specific stuff we want to here.


Variables

const gchar bitzi_url_fmt [] = "http://ticket.bitzi.com/rdf/urn:sha1:%s"
GSList * bitzi_rq = NULL
bitzi_request_tcurrent_bitzi_request = NULL
gpointer current_bitzi_request_handle
GHashTable * bitzi_cache_ht
GList * bitzi_cache
FILE * bitzi_cache_file
const struct efj_t enum_fj_table []


Function Documentation

gboolean bitzi_cache_add bitzi_data_t data  )  [static]
 

void bitzi_cache_clean void   )  [static]
 

void bitzi_cache_remove bitzi_data_t data  )  [static]
 

bitzi_data_t* bitzi_create void   )  [static]
 

gint bitzi_date_compare gconstpointer  p,
gconstpointer  q
[static]
 

Add the data entry to the cache and in expiry sorted date order to the linked list.

void bitzi_destroy bitzi_data_t data  )  [static]
 

gboolean bitzi_heartbeat gpointer  unused_data  )  [static]
 

The heartbeat function is a repeating glib timeout that is used to pace queries to the bitzi metadata service.

It also periodically runs the bitzi_cache_clean routine to clean the cache.

void bitzi_host_data_ind gpointer  unused_handle,
gchar *  data,
gint  len
[static]
 

Populate callback: more data available.

When called with 0 it stops the parsing of the document tree and processes the ticket.

void bitzi_host_error_ind gpointer  handle,
http_errtype_t  unused_type,
gpointer  unused_v
[static]
 

HTTP request is being stopped.

void bitzi_init void   ) 
 

Initialise any bitzi specific stuff we want to here.

gpointer bitzi_query_byurnsha1 const gchar *  urnsha1  ) 
 

A GUI/Bitzi API passes a pointer to the search type (currently only urn:sha1), a pointer to a callback function and a user data pointer.

If no query succeds then the call back is never made, however we should always get some sort of data back from the service.

bitzi_data_t* bitzi_querycache_byurnsha1 const gchar *  urnsha1  ) 
 

Query the bitzi cache for this given urnsha1, return NULL if nothing otherwise we return the.

gboolean do_metadata_query bitzi_request_t req  )  [static]
 

Send a meta-data query.

Called directly when a request launched or via the bitzi_heartbeat tick.

void process_bitzi_ticket xmlNode *  a_node,
bitzi_data_t data
[static]
 

Iterates through the XML/RDF ticket calling various process functions to read the data into the bitzi_data_t.

This function is recursive, if the element is not explicity know we just recurse down a level.

void process_meta_data bitzi_request_t request  )  [static]
 

Walk the parsed document tree and free up the data.

void process_rdf_description xmlNode *  node,
bitzi_data_t data
[static]
 

Read all the attributes we may want from the rdf ticket, some atributes will not be there in which case xmlGetProp will return a null.

const xmlChar* string_to_xmlChar const gchar *  s  )  [inline, static]
 

gchar* xml_get_string xmlNode *  node,
const gchar *  id
[inline, static]
 

const gchar* xmlChar_to_gchar const xmlChar *  s  )  [inline, static]
 


Variable Documentation

GList* bitzi_cache [static]
 

FILE* bitzi_cache_file [static]
 

GHashTable* bitzi_cache_ht [static]
 

GSList* bitzi_rq = NULL [static]
 

const gchar bitzi_url_fmt[] = "http://ticket.bitzi.com/rdf/urn:sha1:%s" [static]
 

bitzi_request_t* current_bitzi_request = NULL [static]
 

gpointer current_bitzi_request_handle [static]
 

const struct efj_t enum_fj_table[] [static]
 

Initial value:

 {
    { "Unknown",                BITZI_FJ_UNKNOWN },
    { "Dangerous/Misleading",   BITZI_FJ_DANGEROUS_MISLEADING },
    { "Incomplete/Damaged",     BITZI_FJ_INCOMPLETE_DAMAGED },
    { "Substandard",            BITZI_FJ_SUBSTANDARD },
    { "Overrated",              BITZI_FJ_OVERRATED },
    { "Normal",                 BITZI_FJ_NORMAL },
    { "Underrated",             BITZI_FJ_UNDERRATED },
    { "Complete",               BITZI_FJ_COMPLETE },
    { "Recommended",            BITZI_FJ_RECOMMENDED },
    { "Best Version",           BITZI_FJ_BEST_VERSION }
}


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