summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIago Toral Quiroga <itoral@igalia.com>2011-06-02 13:15:57 +0200
committerJuan A. Suarez Romero <jasuarez@igalia.com>2011-06-03 06:45:44 +0000
commit58aa511cd3c95b5778fc7f0f77cd1d1c31bfd615 (patch)
treefaa5e6b16536ac58610b7cf280696fd447df46e1
parent9eaac7bd8ae2824eeb8e0616cb7414f293a7a76b (diff)
downloadgrilo-plugins-58aa511cd3c95b5778fc7f0f77cd1d1c31bfd615.tar.gz
podcasts: Make cache time configurable
-rw-r--r--src/media/podcasts/grl-podcasts.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/media/podcasts/grl-podcasts.c b/src/media/podcasts/grl-podcasts.c
index ecb6c87..253fa74 100644
--- a/src/media/podcasts/grl-podcasts.c
+++ b/src/media/podcasts/grl-podcasts.c
@@ -140,7 +140,7 @@ GRL_LOG_DOMAIN_STATIC(podcasts_log_domain);
/* --- Other --- */
-#define CACHE_DURATION (24 * 60 * 60)
+#define DEFAULT_CACHE_TIME (24 * 60 * 60)
/* --- Plugin information --- */
@@ -199,6 +199,7 @@ struct _GrlPodcastsPrivate {
sqlite3 *db;
GrlNetWc *wc;
gboolean notify_changes;
+ gint cache_time;
};
typedef struct {
@@ -255,6 +256,10 @@ grl_podcasts_plugin_init (GrlPluginRegistry *registry,
const GrlPluginInfo *plugin,
GList *configs)
{
+ GrlConfig *config;
+ gint config_count;
+ gint cache_time;
+
GRL_LOG_DOMAIN_INIT (podcasts_log_domain, "podcasts");
GRL_DEBUG ("podcasts_plugin_init");
@@ -264,6 +269,30 @@ grl_podcasts_plugin_init (GrlPluginRegistry *registry,
plugin,
GRL_MEDIA_PLUGIN (source),
NULL);
+
+ source->priv->cache_time = DEFAULT_CACHE_TIME;
+ if (!configs || !configs->data) {
+ return TRUE;
+ }
+
+ config_count = g_list_length (configs);
+ if (config_count > 1) {
+ GRL_INFO ("Provided %d configs, but will only use one", config_count);
+ }
+
+ config = GRL_CONFIG (configs->data);
+
+ cache_time = grl_config_get_int (config, "cache-time");
+ if (cache_time <= 0) {
+ /* Disable cache */
+ source->priv->cache_time = 0;
+ GRL_INFO ("Disabling cache");
+ } else {
+ /* Cache time in seconds */
+ source->priv->cache_time = cache_time;
+ GRL_INFO ("Setting cache time to %d seconds", cache_time);
+ }
+
return TRUE;
}
@@ -1328,7 +1357,7 @@ produce_podcast_contents (OperationSpec *os)
GRL_DEBUG ("Podcast last-refreshed: '%s'", lr_str);
g_time_val_from_iso8601 (lr_str ? lr_str : "", &lr);
g_get_current_time (&now);
- now.tv_sec -= CACHE_DURATION;
+ now.tv_sec -= GRL_PODCASTS_SOURCE (os->source)->priv->cache_time;
if (now.tv_sec >= lr.tv_sec) {
/* We have to read the podcast feed again */
GRL_DEBUG ("Refreshing podcast '%s'...", os->media_id);