[evolution-rss] fix for bug #586273 - sending way too many HTTP requests
- From: Lucian Langa <lucilanga src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-rss] fix for bug #586273 - sending way too many HTTP requests
- Date: Mon, 22 Jun 2009 17:30:52 -0400 (EDT)
commit aa00634adbfaf0190d203ccfc9d173863780eb95
Author: Lucian Langa <lucilanga gnome org>
Date: Tue Jun 23 00:23:12 2009 +0300
fix for bug #586273 - sending way too many HTTP requests
TODO | 3 +-
src/network-soup.c | 3 +-
src/rss.c | 66 ++++++++++++++++++++++++++++++++++-----------------
src/rss.h | 1 +
4 files changed, 49 insertions(+), 24 deletions(-)
---
diff --git a/TODO b/TODO
index b8f1f6e..492dcbf 100644
--- a/TODO
+++ b/TODO
@@ -30,7 +30,6 @@
* cancel operation should cancel fetching feed components
* perhaps make quoted text fancier
* if immage cannto be served from cache try to fetch it ( add 3 times retry for fetching an image)
- * perform feeds images update weekly
* disable filters on setup_feed()
* store feed in an alternate file to serve images from
* migrate fetch_blocking -> fetch_unblocking
@@ -41,3 +40,5 @@
* gtkhtml does not handle script properly
* gtkhtml does not handle 
 construct
* switch webkit -> gecko leeds to crash on pfree()
+ * import/export window resizable
+ * show feed icons in send & receive dialog
diff --git a/src/network-soup.c b/src/network-soup.c
index 94adff6..2d37384 100644
--- a/src/network-soup.c
+++ b/src/network-soup.c
@@ -238,7 +238,8 @@ proxify_session(EProxy *proxy, SoupSession *session, gchar *uri)
case 2:
if (e_proxy_require_proxy_for_uri (proxy, uri)) {
proxy_uri = e_proxy_peek_uri_for (proxy, uri);
- g_print("proxified %s with %s:%d\n", uri, proxy_uri->host, proxy_uri->port);
+ if (proxy_uri)
+ g_print("proxified %s with %s:%d\n", uri, proxy_uri->host, proxy_uri->port);
} else
g_print("no PROXY-%s\n", uri);
g_object_set (G_OBJECT (session), SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
diff --git a/src/rss.c b/src/rss.c
index ce427e8..0db92dd 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -125,6 +125,7 @@ int rss_verbose_debug = 0;
#include <libsoup/soup-message-queue.h>
#endif
+#include <sys/time.h>
#ifdef _WIN32
#include "strptime.c"
#endif
@@ -1273,8 +1274,10 @@ back_cb (GtkWidget *button, EMFormatHTMLPObject *pobject)
gtk_moz_embed_go_back(GTK_MOZ_EMBED(rf->mozembed));
#endif
#if HAVE_WEBKIT
- if (engine == 1)
+ if (engine == 1) {
+ g_print("going back\n");
webkit_web_view_go_back (WEBKIT_WEB_VIEW(rf->mozembed));
+ }
#endif
}
@@ -3209,14 +3212,51 @@ finish_update_feed_image (SoupSession *soup_sess, SoupMessage *msg, gpointer use
g_free(urldir);
}
+gboolean
+check_update_feed_image(gchar *key)
+{
+ gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
+ gchar *fav_file = g_strdup_printf("%s/%s.fav", feed_dir, key);
+ struct timeval start;
+ FILE *f = NULL;
+ gboolean ret = TRUE;
+ unsigned long int remain;
+ gchar rfeed[80];
+ memset(rfeed, 0, 79);
+ gettimeofday(&start, NULL);
+ g_free(feed_dir);
+ if (!g_file_test(fav_file, G_FILE_TEST_EXISTS)) {
+ if ((f = fopen(fav_file, "w"))) {
+ fprintf(f, "%lu", start.tv_sec);
+ fclose(f);
+ }
+ ret = TRUE;
+ goto out;
+ }
+ if ((f = fopen(fav_file, "r"))) {
+ while (fgets(rfeed, 50, f) != NULL) {
+ }
+ fclose(f);
+ remain = start.tv_sec - strtoul((const char *)&rfeed, NULL, 10);
+ if (FEED_IMAGE_TTL <= remain) {
+ ret = TRUE;
+ goto out;
+ } else {
+ d(g_print("next favicon will be fetched in %lu seconds\n", FEED_IMAGE_TTL - remain));
+ ret = FALSE;
+ }
+ }
+out: g_free(fav_file);
+ return ret;
+}
+
void
update_feed_image(gchar *image, gchar *key)
{
GError *err = NULL;
gchar *url = NULL;
-// if (!image)
-// return;
- // g_return_if_fail (image != NULL);
+ if (!check_update_feed_image(key))
+ return;
gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
if (!g_file_test(feed_dir, G_FILE_TEST_EXISTS))
g_mkdir_with_parents (feed_dir, 0755);
@@ -3401,7 +3441,6 @@ static void
store_folder_renamed(CamelObject *o, void *event_data, void *data)
{
CamelRenameInfo *info = event_data;
- CamelIndex *idx;
gchar *main_folder = lookup_main_folder();
if (!g_ascii_strncasecmp(info->old_base, main_folder, strlen(main_folder))
@@ -3413,23 +3452,6 @@ store_folder_renamed(CamelObject *o, void *event_data, void *data)
else
update_feed_folder(info->old_base, info->new->full_name);
}
- gchar *path = (gchar *)mail_component_peek_base_directory (mail_component_peek());
-
- CamelStore *store = mail_component_peek_local_store(NULL);
- CamelFolder *mail_folder;
- mail_folder = camel_store_get_folder (store, info->new->full_name, 0, NULL);
- d(g_print("mail_folder:%s\n", info->new->uri));
- d(g_print("mail_folder:%s\n", info->old_base));
-
- gchar *idxname = g_strconcat(path, "/local/", info->new->full_name, ".ibex", NULL);
- /*gchar *oldname = g_strconcat(path, "/local/", info->old_base, ".ibex", NULL);
- g_print("idx:%s\n", idxname);*/
- idx = (CamelIndex *)camel_text_index_new(idxname, O_TRUNC|O_CREAT|O_RDWR);
-// camel_text_index_rename(oldname, idxname);
- //camel_index_delete(idx);
-// camel_index_sync(idx);
- camel_object_unref((CamelObject *)idx);
- g_free(idxname);
}
typedef struct custom_fetch_data {
diff --git a/src/rss.h b/src/rss.h
index 1254368..896056d 100644
--- a/src/rss.h
+++ b/src/rss.h
@@ -38,6 +38,7 @@
#define OLD_FEEDS_FOLDER "News&Blogs"
#define DEFAULT_NO_CHANNEL N_("Untitled channel")
#define DEFAULT_TTL 1800
+#define FEED_IMAGE_TTL 604800 /*ohne week*/
/* ms between status updates to the gui */
#ifndef _WIN32
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]