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.
#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_t * | bitzi_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_t * | bitzi_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_t * | current_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 [] |
|
|
|
|
|
|
|
|
|
Add the data entry to the cache and in expiry sorted date order to the linked list.
|
|
|
|
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. |
|
Populate callback: more data available. When called with 0 it stops the parsing of the document tree and processes the ticket. |
|
HTTP request is being stopped.
|
|
Initialise any bitzi specific stuff we want to here.
|
|
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. |
|
Query the bitzi cache for this given urnsha1, return NULL if nothing otherwise we return the.
|
|
Send a meta-data query. Called directly when a request launched or via the bitzi_heartbeat tick. |
|
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. |
|
Walk the parsed document tree and free up the 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 } } |