aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--embed/ephy-favicon-cache.c28
-rw-r--r--embed/ephy-history.c28
3 files changed, 24 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index ebb1ea5c6..a414ca512 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-01-03 Diego Escalante Urrelo <diegoe@svn.gnome.org>
+
+ * embed/ephy-favicon-cache.c: (icon_is_obsolete),
+ (remove_obsolete_icons):
+ * embed/ephy-history.c: (page_is_obsolete),
+ (remove_obsolete_pages):
+
+ Avoid use of localtime by computing expiry in seconds instead of days.
+ Patch by Chris Wilson.
+
2007-01-03 Diego Escalante Urrelo <diegoe@svn.gnome.org>
* embed/ephy-favicon-cache.c: (ephy_favicon_cache_init):
diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c
index 2892fb496..36a5c8144 100644
--- a/embed/ephy-favicon-cache.c
+++ b/embed/ephy-favicon-cache.c
@@ -47,6 +47,7 @@
#define EPHY_FAVICON_CACHE_XML_VERSION (const xmlChar *)"1.1"
#define EPHY_FAVICON_CACHE_OBSOLETE_DAYS 30
+#define SECS_PER_DAY (60*60*24)
/* how often to save the cache, in seconds */
#define CACHE_SAVE_INTERVAL (10 * 60) /* seconds */
@@ -90,7 +91,7 @@ typedef struct
guint load_failed : 1;
} PixbufCacheEntry;
-typedef gboolean (* FilterFunc) (EphyNode*, GDate *);
+typedef gboolean (* FilterFunc) (EphyNode*, time_t);
enum
{
@@ -189,23 +190,13 @@ pixbuf_cache_entry_free (PixbufCacheEntry *entry)
}
static gboolean
-icon_is_obsolete (EphyNode *node, GDate *now)
+icon_is_obsolete (EphyNode *node, time_t now)
{
int last_visit;
- GDate date;
last_visit = ephy_node_get_property_int
(node, EPHY_NODE_FAVICON_PROP_LAST_USED);
-
- g_date_clear (&date, 1);
-#if GLIB_CHECK_VERSION (2,9,0)
- g_date_set_time_t (&date, last_visit);
-#else
- g_date_set_time (&date, last_visit);
-#endif
-
- return (g_date_days_between (&date, now) >=
- EPHY_FAVICON_CACHE_OBSOLETE_DAYS);
+ return now - last_visit >= EPHY_FAVICON_CACHE_OBSOLETE_DAYS*SECS_PER_DAY;
}
static void
@@ -239,14 +230,9 @@ remove_obsolete_icons (EphyFaviconCache *cache,
EphyFaviconCachePrivate *priv = cache->priv;
GPtrArray *children;
int i;
- GDate current_date;
+ time_t now;
- g_date_clear (&current_date, 1);
-#if GLIB_CHECK_VERSION (2,9,0)
- g_date_set_time_t (&current_date, time (NULL));
-#else
- g_date_set_time (&current_date, time (NULL));
-#endif
+ now = time (NULL);
children = ephy_node_get_children (priv->icons);
for (i = (int) children->len - 1; i >= 0; i--)
@@ -255,7 +241,7 @@ remove_obsolete_icons (EphyFaviconCache *cache,
kid = g_ptr_array_index (children, i);
- if (!filter || filter (kid, &current_date))
+ if (!filter || filter (kid, now))
{
const char *filename;
char *path;
diff --git a/embed/ephy-history.c b/embed/ephy-history.c
index 4b2876665..3d6e9897c 100644
--- a/embed/ephy-history.c
+++ b/embed/ephy-history.c
@@ -45,6 +45,9 @@
/* if you change this remember to change also the user interface description */
#define HISTORY_PAGE_OBSOLETE_DAYS 10
+/* the number of seconds in a day */
+#define SECS_PER_DAY (60*60*24)
+
#define EPHY_HISTORY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_HISTORY, EphyHistoryPrivate))
struct _EphyHistoryPrivate
@@ -240,23 +243,13 @@ ephy_history_class_init (EphyHistoryClass *klass)
}
static gboolean
-page_is_obsolete (EphyNode *node, GDate *now)
+page_is_obsolete (EphyNode *node, time_t now)
{
int last_visit;
- GDate date;
last_visit = ephy_node_get_property_int
(node, EPHY_NODE_PAGE_PROP_LAST_VISIT);
-
- g_date_clear (&date, 1);
-#if GLIB_CHECK_VERSION (2,9,0)
- g_date_set_time_t (&date, last_visit);
-#else
- g_date_set_time (&date, last_visit);
-#endif
-
- return (g_date_days_between (&date, now) >=
- HISTORY_PAGE_OBSOLETE_DAYS);
+ return now - last_visit >= HISTORY_PAGE_OBSOLETE_DAYS*SECS_PER_DAY;
}
static void
@@ -264,16 +257,9 @@ remove_obsolete_pages (EphyHistory *eb)
{
GPtrArray *children;
int i;
- GTime now;
- GDate current_date;
+ time_t now;
now = time (NULL);
- g_date_clear (&current_date, 1);
-#if GLIB_CHECK_VERSION (2,9,0)
- g_date_set_time_t (&current_date, time (NULL));
-#else
- g_date_set_time (&current_date, time (NULL));
-#endif
children = ephy_node_get_children (eb->priv->pages);
for (i = (int) children->len - 1; i >= 0; i--)
@@ -282,7 +268,7 @@ remove_obsolete_pages (EphyHistory *eb)
kid = g_ptr_array_index (children, i);
- if (page_is_obsolete (kid, &current_date))
+ if (page_is_obsolete (kid, now))
{
ephy_node_unref (kid);
}