![]() |
![]() |
![]() |
Grilo Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <grilo.h> struct GrlNetWc; struct GrlNetWcClass; enum GrlNetWcError; #define GRL_NET_WC_ERROR GrlNetWc * grl_net_wc_new (void
); GQuark grl_net_wc_error_quark (void
); void grl_net_wc_flush_delayed_requests (GrlNetWc *self
); void grl_net_wc_request_async (GrlNetWc *self
,const char *uri
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gboolean grl_net_wc_request_finish (GrlNetWc *self
,GAsyncResult *result
,gchar **content
,gsize *length
,GError **error
); void grl_net_wc_request_with_headers_async (GrlNetWc *self
,const char *uri
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
,...
); void grl_net_wc_request_with_headers_hash_async (GrlNetWc *self
,const char *uri
,GHashTable *headers
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); void grl_net_wc_set_cache (GrlNetWc *self
,gboolean use_cache
); void grl_net_wc_set_cache_size (GrlNetWc *self
,guint cache_size
); void grl_net_wc_set_log_level (GrlNetWc *self
,guint log_level
); void grl_net_wc_set_throttling (GrlNetWc *self
,guint throttling
);
Most of the Grilo's sources need to access to web resources. The purpose of this utility class is to provide a thin and lean mechanism for those plugins to interact with those resources.
struct GrlNetWcClass { GObjectClass parent_class; };
Grilo web client helper class.
It's a simple and thin web client to be used by the sources to download content from Internet.
typedef enum { GRL_NET_WC_ERROR_UNAVAILABLE = 1, GRL_NET_WC_ERROR_PROTOCOL_ERROR, GRL_NET_WC_ERROR_AUTHENTICATION_REQUIRED, GRL_NET_WC_ERROR_NOT_FOUND, GRL_NET_WC_ERROR_CONFLICT, GRL_NET_WC_ERROR_FORBIDDEN, GRL_NET_WC_ERROR_NETWORK_ERROR, GRL_NET_WC_ERROR_PROXY_ERROR, GRL_NET_WC_ERROR_CANCELLED } GrlNetWcError;
These constants identify all the available errors managed by the web client.
TBD | |
Invalid URI or header | |
Required authentication | |
Request resource not found | |
The entry has been modified since is was downloaded | |
TBD | |
Cannot connect to the server | |
Cannot connect to the proxy server | |
The operation has been cancelled (see GCancellable) |
GrlNetWc * grl_net_wc_new (void
);
Creates a new GrlNetWc.
Returns : |
a new allocated instance of GrlNetWc. Do g_object_unref() after
use it. |
void grl_net_wc_flush_delayed_requests (GrlNetWc *self
);
This method will flush all the pending request in the queue.
|
a GrlNetWc instance |
void grl_net_wc_request_async (GrlNetWc *self
,const char *uri
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Request the fetching of a web resource given the uri
. This request is
asynchronous, thus the result will be returned within the callback
.
|
a GrlNetWc instance |
|
The URI of the resource to request |
|
a GCancellable instance or NULL to ignore. [allow-none]
|
|
The callback when the result is ready |
|
User data set for the callback
|
gboolean grl_net_wc_request_finish (GrlNetWc *self
,GAsyncResult *result
,gchar **content
,gsize *length
,GError **error
);
Finishes an asynchronous load of the file's contents. The contents are placed in contents, and length is set to the size of the contents string.
The content address will be invalidated at the next request. So if you want to keep it, please copy it into another address.
|
a GrlNetWc instance |
|
The result of the request |
|
The contents of the resource |
|
The length of the contents or NULL if it is not
needed. [allow-none]
|
|
return location for a GError, or NULL
|
Returns : |
TRUE if the request was successfull. If FALSE an error occurred. |
void grl_net_wc_request_with_headers_async (GrlNetWc *self
,const char *uri
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
,...
);
Request the fetching of a web resource given the uri
. This request is
asynchronous, thus the result will be returned within the callback
.
|
a GrlNetWc instance |
|
The URI of the resource to request |
|
a GCancellable instance or NULL to ignore. [allow-none]
|
|
The callback when the result is ready |
|
User data set for the callback
|
|
List of tuples of header name and header value, terminated by
NULL . |
Since 0.2.2
void grl_net_wc_request_with_headers_hash_async (GrlNetWc *self
,const char *uri
,GHashTable *headers
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Request the fetching of a web resource given the uri
. This request is
asynchronous, thus the result will be returned within the callback
.
|
a GrlNetWc instance |
|
The URI of the resource to request |
|
a set of additional HTTP
headers for this request or NULL to ignore. [allow-none][element-type utf8 utf8]
|
|
a GCancellable instance or NULL to ignore. [allow-none]
|
|
The callback when the result is ready |
|
User data set for the callback
|
Since 0.2.2
void grl_net_wc_set_cache (GrlNetWc *self
,gboolean use_cache
);
Sets if cache must be used. Note that this will only work if caching is
supporting. If sets TRUE
, a new cache will be created. If sets to FALSE
,
current cache is clean and removed.
|
a GrlNetWc instance |
|
if cache must be used or not |
Since 0.1.12
void grl_net_wc_set_cache_size (GrlNetWc *self
,guint cache_size
);
Sets the new maximum size of cache, in Megabytes. Default value is 10. Using 0 means no cache will be done.
|
a GrlNetWc instance |
|
size of cache (in Mb) |
Since 0.1.12
void grl_net_wc_set_log_level (GrlNetWc *self
,guint log_level
);
Setting the log level the logger feature is added into the libsoup session.
|
a GrlNetWc instance |
|
the libsoup log level to set [0,3] |
void grl_net_wc_set_throttling (GrlNetWc *self
,guint throttling
);
Setting this property, the GrlNetWc will queue all the requests and will dispatch them with a pause between them of this value.
|
a GrlNetWc instance |
|
the number of seconds to wait between requests |