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/urn.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) |
| void | xml_free_null (gchar **ptr) |
| Use this to free strings returned by xml_get_string(). | |
| 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 (struct http_async *unused_handle, gchar *data, gint len) |
| Populate callback: more data available. | |
| void | bitzi_host_error_ind (struct http_async *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 attributes 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. | |
| void | bitzi_failure (const struct sha1 *sha1, filesize_t filesize, bitzi_fj_t error) |
| void | bitzi_request_free (bitzi_request_t **ptr) |
| 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_query_cache_by_sha1 (const struct sha1 *sha1) |
| gboolean | bitzi_has_cached_ticket (const struct sha1 *sha1) |
| Query the bitzi cache for this given SHA-1. | |
| bitzi_data_t * | bitzi_query_by_sha1 (const struct sha1 *sha1, filesize_t filesize) |
| 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_load_cache (void) |
| void | bitzi_init (void) |
| Initialise any bitzi specific stuff we want to here. | |
| void | bitzi_close (void) |
Variables | |
| const gchar | bitzi_url_fmt [] = "http://ticket.bitzi.com/rdf/urn:sha1:%s" |
| GSList * | bitzi_rq |
| bitzi_request_t * | current_bitzi_request |
| gpointer | current_bitzi_request_handle |
| guint | bitzi_heartbeat_id |
| 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.
|
|
|
|
|
||||||||||||||||
|
|
|
|
Query the bitzi cache for this given SHA-1.
|
|
|
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. |
|
|
|
|
|
|
|
|
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 attributes will not be there in which case xmlGetProp will return a null. TRANSLATORS: This describes video parameters; The first part is used as <width>x<height> (resolution). fps stands for "frames per second". kbps stands for "kilobit per second" (metric kilo). |
|
|
|
|
|
Use this to free strings returned by xml_get_string().
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Initial value: {
{ "Unknown", BITZI_FJ_UNKNOWN },
{ "Bitzi lookup failure", BITZI_FJ_FAILURE },
{ "Filesize mismatch", BITZI_FJ_WRONG_FILESIZE },
{ "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 }
}
|
1.3.9.1