[evolution-rss] Bug #561874 - add initial support for cookies; correctly update favicons; cleanup favicons on delete
- From: Lucian Langa <lucilanga src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-rss] Bug #561874 - add initial support for cookies; correctly update favicons; cleanup favicons on delete
- Date: Thu, 25 Jun 2009 18:53:53 +0000 (UTC)
commit 8837d38011f248df9d15f35c1591a18a8d4e931a
Author: Lucian Langa <lucilanga gnome org>
Date: Thu Jun 25 21:52:38 2009 +0300
Bug #561874 - add initial support for cookies; correctly update favicons; cleanup favicons on delete
TODO | 7 +-
src/network-soup.c | 27 ++++--
src/network-soup.h | 1 +
src/parser.c | 4 -
src/rss-config-factory.c | 213 +++++++++++++++++++++++++++++++++++++++++-
src/rss-config-factory.h | 2 +
src/rss-html-rendering.glade | 4 +-
src/rss.c | 92 ++++++++++++------
src/rss.h | 3 +-
9 files changed, 302 insertions(+), 51 deletions(-)
---
diff --git a/TODO b/TODO
index 492dcbf..b328a1c 100644
--- a/TODO
+++ b/TODO
@@ -25,7 +25,6 @@
* add handling parser error to setup_feed (check HIG for error msg)
* handle slash categories
* use combo popup for moving and placement of feed folders
- * trigger resync after folder rename and initial folder creation (cmeta update!)
* check webbuttons for webkit
* cancel operation should cancel fetching feed components
* perhaps make quoted text fancier
@@ -40,5 +39,9 @@
* 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
+ * folder creation/articles not fetched after adding feed
+ * favicon is not displayed after it is fetched
+ * cancel fetching comments when summary display is changed
+ * detect duplicate items by content not by feedid
+ * sometimes adding feeds is interrupted by rf->cancel signal
diff --git a/src/network-soup.c b/src/network-soup.c
index 2d37384..afc5d87 100644
--- a/src/network-soup.c
+++ b/src/network-soup.c
@@ -712,6 +712,7 @@ abort_all_soup(void)
rf->b_session = NULL;
rf->b_msg_session = NULL;
}
+ rf->cancel = 0;
rf->cancel_all = 0;
}
@@ -719,14 +720,22 @@ void
rss_soup_init(void)
{
#if LIBSOUP_VERSION > 2026002 && defined(HAVE_LIBSOUP_GNOME)
- gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
- gchar *cookie_path = g_build_path("/", feed_dir, "rss-cookies.sqlite", NULL);
- gchar *moz_cookie_path = g_build_path("/", feed_dir, "mozembed-rss", "cookies.sqlite", NULL);
- if (!g_file_test(moz_cookie_path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_SYMLINK))
- symlink(cookie_path, moz_cookie_path);
-
- rss_soup_jar =
- soup_cookie_jar_sqlite_new (cookie_path, FALSE);
- g_free(cookie_path);
+ if (gconf_client_get_bool (rss_gconf, GCONF_KEY_ACCEPT_COOKIES, NULL)) {
+ gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
+ gchar *cookie_path = g_build_path("/", feed_dir, "rss-cookies.sqlite", NULL);
+ gchar *moz_cookie_path = g_build_path("/", feed_dir, "mozembed-rss", "cookies.sqlite", NULL);
+ if (!g_file_test(moz_cookie_path, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_SYMLINK)) {
+
+ //this currently sux as firefox 3.5b will open
+ //cookie database file exclusively, that means import will fail
+ //even fetch will fail - we should copy this file separately for
+ //gecko renderer
+ symlink(cookie_path, moz_cookie_path);
+ }
+
+ rss_soup_jar =
+ soup_cookie_jar_sqlite_new (cookie_path, FALSE);
+ g_free(cookie_path);
+ }
#endif
}
diff --git a/src/network-soup.h b/src/network-soup.h
index 0407b32..f9405d6 100644
--- a/src/network-soup.h
+++ b/src/network-soup.h
@@ -43,3 +43,4 @@ guint save_up(gpointer data);
guint del_up(gpointer data);
void rss_soup_init(void);
EProxy *proxy_init(void);
+guint read_up(gpointer data);
diff --git a/src/parser.c b/src/parser.c
index 68b02d8..fecabca 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1002,7 +1002,6 @@ update_channel(RDF *r)
xmlNodePtr el;
gchar *subj;
create_feed *CF;
- CamelFolder *mail_folder;
gchar *chn_name = r->title;
gchar *url = r->uri;
gchar *main_date = r->maindate;
@@ -1029,9 +1028,6 @@ update_channel(RDF *r)
FILE *fw = fopen(feed_name, "a+");
//int fw = g_open (feed_name, O_WRONLY | O_CREAT| O_APPEND | O_BINARY, 0666);
- mail_folder = check_feed_folder(chn_name);
- camel_object_unref(mail_folder);
-
for (i=0; NULL != (el = g_array_index(item, xmlNodePtr, i)); i++) {
update_sr_message();
if (rf->cancel) goto out;
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index 15f7691..d2c76f9 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -39,15 +39,23 @@
#include <e-util/e-error.h>
#include <bonobo/bonobo-shlib-factory.h>
+#ifdef HAVE_LIBSOUP_GNOME
+#include <libsoup/soup-gnome.h>
+#include <libsoup/soup-gnome-features.h>
+#endif
+
#include "rss.h"
#include "misc.h"
#include "parser.h"
+#include "rss-config-factory.h"
+#include "network-soup.h"
#define d(x)
static guint feed_enabled = 0;
static guint feed_validate = 0;
static guint feed_html = 0;
+guint ccurrent = 0, ctotal = 0;
extern rssfeed *rf;
extern guint upgrade;
@@ -56,6 +64,7 @@ extern gchar *buffer;
extern GSList *rss_list;
extern GConfClient *rss_gconf;
extern GHashTable *icons;
+extern SoupCookieJar *rss_soup_jar;
#define RSS_CONTROL_ID "OAFIID:GNOME_Evolution_RSS:" EVOLUTION_VERSION_STRING
#define FACTORY_ID "OAFIID:GNOME_Evolution_RSS_Factory:" EVOLUTION_VERSION_STRING
@@ -71,6 +80,8 @@ typedef struct {
GtkWidget *check3;
GtkWidget *check4;
GtkWidget *check5;
+ GtkWidget *check6;
+ GtkWidget *import;
} UIData;
typedef struct _setupfeed {
@@ -95,6 +106,7 @@ typedef struct _setupfeed {
} setupfeed;
static void feeds_dialog_edit(GtkDialog *d, gpointer data);
+void decorate_import_cookies_fs (gpointer data);
static void
set_sensitive (GtkCellLayout *cell_layout,
@@ -158,13 +170,23 @@ render_engine_changed (GtkComboBox *dropdown, GCallback *user_data)
}
static void
-start_check_cb (GtkWidget *widget, gpointer data)
+start_check_cb(GtkWidget *widget, gpointer data)
{
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
/* Save the new setting to gconf */
gconf_client_set_bool (rss_gconf, data, active, NULL);
}
+void
+accept_cookies_cb(GtkWidget *widget, GtkWidget *data)
+{
+ gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+ /* Save the new setting to gconf */
+ gconf_client_set_bool (rss_gconf, GCONF_KEY_ACCEPT_COOKIES, active, NULL);
+ gtk_widget_set_sensitive(data, active);
+
+}
+
static void
enable_toggle_cb(GtkCellRendererToggle *cell,
gchar *path_str,
@@ -337,8 +359,6 @@ build_dialog_add(gchar *url, gchar *feed_text)
gboolean fhtml = FALSE;
gboolean del_unread = FALSE;
guint del_feed = 0;
- gchar *iconfile = NULL, *deffile = NULL;
- GdkPixbuf *folder_icon = NULL;
gpointer key = NULL;
GtkAccelGroup *accel_group = gtk_accel_group_new ();
@@ -1436,7 +1456,7 @@ create_export_dialog (void)
"local-only", FALSE,
NULL);
gtk_window_set_modal (GTK_WINDOW (export_file_select), TRUE);
- gtk_window_set_resizable (GTK_WINDOW (export_file_select), FALSE);
+ gtk_window_set_resizable (GTK_WINDOW (export_file_select), TRUE);
gtk_window_set_destroy_with_parent (GTK_WINDOW (export_file_select), TRUE);
gtk_window_set_type_hint (GTK_WINDOW (export_file_select), GDK_WINDOW_TYPE_HINT_DIALOG);
@@ -1461,6 +1481,54 @@ create_export_dialog (void)
return export_file_select;
}
+GtkWidget*
+create_import_cookies_dialog (void)
+{
+ GtkWidget *import_file_select;
+ GtkWidget *vbox26;
+ GtkWidget *hbuttonbox1;
+ GtkWidget *button3;
+ GtkWidget *button4;
+
+ import_file_select = gtk_file_chooser_dialog_new (_("Select file to import"),
+ NULL, GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL);
+ gtk_window_set_keep_above(GTK_WINDOW(import_file_select), TRUE);
+ g_object_set (import_file_select,
+ "local-only", FALSE,
+ NULL);
+ gtk_window_set_modal (GTK_WINDOW (import_file_select), FALSE);
+ gtk_window_set_resizable (GTK_WINDOW (import_file_select), TRUE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (import_file_select), TRUE);
+ gtk_window_set_type_hint (GTK_WINDOW (import_file_select), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+ vbox26 = GTK_DIALOG (import_file_select)->vbox;
+ gtk_widget_show (vbox26);
+
+ hbuttonbox1 = GTK_DIALOG (import_file_select)->action_area;
+ gtk_widget_show (hbuttonbox1);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_END);
+
+ button3 = gtk_button_new_from_stock ("gtk-cancel");
+ gtk_widget_show (button3);
+ gtk_dialog_add_action_widget (GTK_DIALOG (import_file_select), button3, GTK_RESPONSE_CANCEL);
+ GTK_WIDGET_SET_FLAGS (button3, GTK_CAN_DEFAULT);
+
+ button4 = gtk_button_new_from_stock ("gtk-save");
+ gtk_widget_show (button4);
+ gtk_dialog_add_action_widget (GTK_DIALOG (import_file_select), button4, GTK_RESPONSE_OK);
+ GTK_WIDGET_SET_FLAGS (button4, GTK_CAN_DEFAULT);
+
+ gtk_widget_grab_default (button4);
+ return import_file_select;
+}
+static void
+import_cookies_cb (GtkWidget *widget, gpointer data)
+{
+ GtkWidget *import = create_import_cookies_dialog();
+ decorate_import_cookies_fs(import);
+ gtk_widget_show(import);
+}
+
static void
import_cb (GtkWidget *widget, gpointer data)
{
@@ -1565,6 +1633,74 @@ out: g_free(opml);
}
+SoupCookieJar *
+import_cookies(gchar *file)
+{
+ SoupCookieJar *jar = NULL;
+ gchar header[16];
+ memset(header, 0, 16);
+ g_print("import cookies from %s\n", file);
+ FILE *f = fopen(file, "r");
+ if (f) {
+ fgets(header, 16, f);
+ fclose(f);
+ if (!g_ascii_strncasecmp(header, SQLITE_MAGIC, sizeof(SQLITE_MAGIC))) {
+#if LIBSOUP_VERSION > 2026002 && defined(HAVE_LIBSOUP_GNOME)
+ jar = soup_cookie_jar_sqlite_new(file, TRUE);
+#endif
+ } else
+ jar = soup_cookie_jar_text_new(file, TRUE);
+ }
+ return jar;
+}
+
+void
+inject_cookie(SoupCookie *cookie, GtkProgressBar *progress)
+{
+ gchar *text;
+ ccurrent++;
+ if (!rf->cancel) {
+ float fr = ((ccurrent*100)/ctotal);
+ gtk_progress_bar_set_fraction(progress, fr/100);
+ text = g_strdup_printf(_("%2.0f%% done"), fr);
+ gtk_progress_bar_set_text(progress, text);
+ g_free(text);
+ soup_cookie_jar_add_cookie(rss_soup_jar, cookie);
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+ }
+}
+
+void
+process_cookies(SoupCookieJar *jar)
+{
+ ccurrent = 0;
+ ctotal = 0;
+ GSList *list = soup_cookie_jar_all_cookies(jar);
+ gchar *msg = g_strdup(_("Importing cookies..."));
+ GtkWidget *import_dialog = e_error_new(NULL, "shell:importing", msg, NULL);
+ gtk_window_set_keep_above(GTK_WINDOW(import_dialog), TRUE);
+ g_signal_connect(import_dialog, "response", G_CALLBACK(import_dialog_response), NULL);
+ GtkWidget *import_label = gtk_label_new(_("Please wait"));
+ GtkWidget *import_progress = gtk_progress_bar_new();
+ gtk_box_pack_start(GTK_BOX(((GtkDialog *)import_dialog)->vbox),
+ import_label,
+ FALSE,
+ FALSE,
+ 0);
+ gtk_box_pack_start(GTK_BOX(((GtkDialog *)import_dialog)->vbox),
+ import_progress,
+ FALSE,
+ FALSE,
+ 0);
+ gtk_widget_show_all(import_dialog);
+ ctotal = g_slist_length(list);
+ g_slist_foreach(list, (GFunc)inject_cookie, import_progress);
+ //reset cancel signal
+ rf->cancel = 0;
+ gtk_widget_destroy(import_dialog);
+}
+
static void
select_export_response(GtkWidget *selector, guint response, gpointer user_data)
{
@@ -1583,6 +1719,26 @@ select_export_response(GtkWidget *selector, guint response, gpointer user_data)
}
static void
+select_import_cookies_response(GtkWidget *selector, guint response, gpointer user_data)
+{
+ SoupCookieJar *jar;
+
+ if (response == GTK_RESPONSE_OK) {
+ char *name;
+
+ name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector));
+ if (name) {
+ gtk_widget_destroy(selector);
+ if ((jar = import_cookies(name)))
+ process_cookies(jar);
+ g_free(name);
+ }
+ } else
+ gtk_widget_destroy(selector);
+
+}
+
+static void
decorate_export_fs (gpointer data)
{
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (data), TRUE);
@@ -1619,6 +1775,42 @@ decorate_export_fs (gpointer data)
g_signal_connect(data, "destroy", G_CALLBACK(gtk_widget_destroy), data);
}
+void
+decorate_import_cookies_fs (gpointer data)
+{
+ gtk_dialog_set_default_response (GTK_DIALOG (data), GTK_RESPONSE_OK);
+ gtk_file_chooser_set_local_only (data, FALSE);
+
+ GtkFileFilter *file_filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pattern (GTK_FILE_FILTER(file_filter), "*");
+ gtk_file_filter_set_name (GTK_FILE_FILTER(file_filter), _("All Files"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (data),
+ GTK_FILE_FILTER(file_filter));
+
+ file_filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pattern (GTK_FILE_FILTER(file_filter), "*.txt");
+ gtk_file_filter_set_name (GTK_FILE_FILTER(file_filter), _("Mozilla/Netscape Format"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (data),
+ GTK_FILE_FILTER(file_filter));
+
+ file_filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pattern (GTK_FILE_FILTER(file_filter), "*.sqlite");
+ gtk_file_filter_set_name (GTK_FILE_FILTER(file_filter), _("Firefox new Format"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (data),
+ GTK_FILE_FILTER(file_filter));
+
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (data),
+ GTK_FILE_FILTER(file_filter));
+
+
+ GtkFileFilter *filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pattern (filter, "*.txt");
+ gtk_file_filter_add_pattern (filter, "*.sqilte");
+ gtk_file_chooser_set_filter(data, filter);
+ g_signal_connect(data, "response", G_CALLBACK(select_import_cookies_response), data);
+ g_signal_connect(data, "destroy", G_CALLBACK(gtk_widget_destroy), data);
+}
+
static void
export_cb (GtkWidget *widget, gpointer data)
{
@@ -1747,6 +1939,19 @@ e_plugin_lib_get_configure_widget (EPlugin *epl)
G_CALLBACK(start_check_cb),
GCONF_KEY_HTML_JS);
+ ui->check6 = glade_xml_get_widget(ui->xml, "accept_cookies");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ui->check6),
+ gconf_client_get_bool(rss_gconf, GCONF_KEY_ACCEPT_COOKIES, NULL));
+
+ ui->import = glade_xml_get_widget(ui->xml, "import_cookies");
+ //we have to have ui->import looked up
+ g_signal_connect(ui->check6,
+ "clicked",
+ G_CALLBACK(accept_cookies_cb),
+ ui->import);
+
+ g_signal_connect(ui->import, "clicked", G_CALLBACK(import_cookies_cb), ui->import);
+
ui->nettimeout = glade_xml_get_widget(ui->xml, "nettimeout");
gdouble adj = gconf_client_get_float(rss_gconf, GCONF_KEY_NETWORK_TIMEOUT, NULL);
if (adj < NETWORK_MIN_TIMEOUT) {
diff --git a/src/rss-config-factory.h b/src/rss-config-factory.h
index 30d3ba9..722368f 100644
--- a/src/rss-config-factory.h
+++ b/src/rss-config-factory.h
@@ -19,6 +19,8 @@
#ifndef __RSS_CONFIG_FACTORY_H_
#define __RSS_CONFIG_FACTORY_H_
+#define SQLITE_MAGIC "SQLite format 3"
+
void store_redraw(GtkTreeView *data);
void import_dialog_response(GtkWidget *selector, guint response, gpointer user_data);
void del_days_cb (GtkWidget *widget, add_feed *data);
diff --git a/src/rss-html-rendering.glade b/src/rss-html-rendering.glade
index 4103ac0..a92c821 100644
--- a/src/rss-html-rendering.glade
+++ b/src/rss-html-rendering.glade
@@ -92,7 +92,7 @@
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<child>
- <widget class="GtkCheckButton" id="checkbutton2">
+ <widget class="GtkCheckButton" id="accept_cookies">
<property name="label" translatable="yes">Accept cookies from sites</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -104,7 +104,7 @@
</packing>
</child>
<child>
- <widget class="GtkButton" id="button1">
+ <widget class="GtkButton" id="import_cookies">
<property name="label" translatable="yes">Import Cookies</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/src/rss.c b/src/rss.c
index 0db92dd..6fc5a00 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -207,6 +207,8 @@ gboolean browser_fetching = 0; //mycall event could be triggered many times in f
gint browser_fill = 0; //how much data currently written to browser
gboolean setup_feed(add_feed *feed);
+gchar *process_feed(RDF *r);
+void display_feed(RDF *r);
gchar *display_doc (RDF *r);
gchar *display_comments (RDF *r);
void check_folders(void);
@@ -2206,7 +2208,7 @@ void org_gnome_cooly_folder_icon(void *ep, EMEventTargetCustomIcon *t)
if (gconf_client_get_bool (rss_gconf, GCONF_KEY_FEED_ICON, NULL)) {
gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
gchar *feed_file = g_strdup_printf("%s/%s.img", feed_dir, key);
- if (g_file_test(feed_file, G_FILE_TEST_EXISTS)) {
+// if (g_file_test(feed_file, G_FILE_TEST_EXISTS)) {
// unfortunately e_icon_factory_get_icon return broken image in case of error
// we use gdk_pixbuf_new_from_file to test the validity of the image file
pixbuf = gdk_pixbuf_new_from_file(feed_file, NULL);
@@ -2229,7 +2231,7 @@ void org_gnome_cooly_folder_icon(void *ep, EMEventTargetCustomIcon *t)
g_object_unref(pixbuf);
goto out;
}
- }
+// }
}
} else {
#if (EVOLUTION_VERSION >= 22703)
@@ -2363,10 +2365,9 @@ setup_feed(add_feed *feed)
guint ret = 0;
guint ttl;
RDF *r = NULL;
- GString *post = NULL;
+ GString *post = NULL, *content = NULL;
GError *err = NULL;
- GString *content = NULL;
- gchar *chn_name = NULL;
+ gchar *chn_name = NULL, *tmp_chn_name = NULL;
check_folders();
@@ -2476,7 +2477,12 @@ top: d(g_print("adding feed->feed_url:%s\n", feed->feed_url));
r->uri = feed->feed_url;
r->progress = feed->progress;
- chn_name = display_doc (r);
+ //chn_name = display_doc (r);
+ //we preprocess feed first in order to get name, icon, etc
+ //and later display the actual feed (once rf-> structure is
+ //properly populated
+ chn_name = process_feed(r);
+ g_print("add chn_name:%s\n", chn_name);
add:
//feed name can only come from an import so we rather prefer
//resulted channel name instead of supplied one
@@ -2487,7 +2493,7 @@ add:
chn_name = g_strdup (_(DEFAULT_NO_CHANNEL));
//FIXME g_free
gchar *tmp = sanitize_folder(chn_name);
- g_free(chn_name);
+ tmp_chn_name = chn_name;
chn_name = tmp;
chn_name = generate_safe_chn_name(chn_name);
@@ -2545,7 +2551,13 @@ add:
g_hash_table_insert(rf->hrh,
g_strdup(crc_feed),
GINT_TO_POINTER(feed->fetch_html));
+
+
+ display_feed(r);
+
+ g_free(tmp_chn_name);
g_free(chn_name);
+
if (r->cache)
xmlFreeDoc(r->cache);
if (r->type)
@@ -3138,9 +3150,11 @@ finish_update_feed_image (SoupSession *soup_sess, SoupMessage *msg, gpointer use
xmlChar *icon = NULL;
gchar *icon_url = NULL;
gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
- gchar *feed_file = g_strdup_printf("%s/%s.img", feed_dir, (gchar *)user_data);
+ gchar *url = (gchar *)user_data;
+ gchar *key = gen_md5(url);
+ gchar *feed_file = g_strdup_printf("%s/%s.img", feed_dir, key);
+ g_free(key);
g_free(feed_dir);
- gchar *url = g_hash_table_lookup(rf->hr, user_data);
gchar *urldir = g_path_get_dirname(url);
gchar *server = get_server_from_uri(url);
rfMessage *rfmsg = g_new0(rfMessage, 1);
@@ -3210,6 +3224,7 @@ finish_update_feed_image (SoupSession *soup_sess, SoupMessage *msg, gpointer use
g_free(icon_url);
g_free(server);
g_free(urldir);
+ g_free(user_data);
}
gboolean
@@ -3234,8 +3249,7 @@ check_update_feed_image(gchar *key)
goto out;
}
if ((f = fopen(fav_file, "r"))) {
- while (fgets(rfeed, 50, f) != NULL) {
- }
+ fgets(rfeed, 50, f);
fclose(f);
remain = start.tv_sec - strtoul((const char *)&rfeed, NULL, 10);
if (FEED_IMAGE_TTL <= remain) {
@@ -3251,12 +3265,13 @@ out: g_free(fav_file);
}
void
-update_feed_image(gchar *image, gchar *key)
+update_feed_image(RDF *r)
{
GError *err = NULL;
- gchar *url = NULL;
+ gchar *key = gen_md5(r->uri);
+ gchar *image = r->image;
if (!check_update_feed_image(key))
- return;
+ goto out;
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);
@@ -3276,23 +3291,22 @@ update_feed_image(gchar *image, gchar *key)
if (err) {
g_print("ERR:%s\n", err->message);
g_free(feed_file);
- return;
+ goto out;
}
} else {
- url = g_hash_table_lookup(rf->hr, key);
- if (!url)
- return;
- gchar *server = get_server_from_uri(url);
+ gchar *server = get_server_from_uri(r->uri);
fetch_unblocking(
server,
textcb,
NULL,
(gpointer)finish_update_feed_image,
- key, // we need to dupe key here
+ g_strdup(r->uri), // we need to dupe key here
0,
- &err); // because we might lose it if
+ &err); // because we might loose it if
+ // feeds get deleted
}
}
+out: g_free(key);
}
void
@@ -3400,6 +3414,7 @@ void
rss_delete_feed(gchar *name, gboolean folder)
{
CamelException ex;
+ gchar *tmp;
CamelStore *store = mail_component_peek_local_store(NULL);
gchar *full_path = g_strdup_printf("%s/%s",
lookup_main_folder(),
@@ -3424,6 +3439,12 @@ rss_delete_feed(gchar *name, gboolean folder)
g_free(feed_dir);
g_free(buf);
unlink(feed_name);
+ tmp = g_strdup_printf("%s.img", feed_name);
+ unlink(tmp);
+ g_free(tmp);
+ tmp = g_strdup_printf("%s.fav", feed_name);
+ unlink(tmp);
+ g_free(tmp);
if (folder)
remove_feed_hash(name);
save_gconf_feed();
@@ -4669,23 +4690,36 @@ display_comments (RDF *r)
return NULL;
}
-
gchar *
-display_doc (RDF *r)
+process_feed(RDF *r)
{
xmlNodePtr root = xmlDocGetRootElement (r->cache);
if (tree_walk (root, r)) {
- update_feed_image(r->image, gen_md5(r->uri));
- r->feedid = update_channel(r);
- if (r->maindate)
- g_free(r->maindate);
- g_array_free(r->item, TRUE);
- g_free(r->feedid);
+ update_feed_image(r);
return r->title;
}
return NULL;
}
+void
+display_feed(RDF *r)
+{
+ r->feedid = update_channel(r);
+ if (r->maindate)
+ g_free(r->maindate);
+ g_array_free(r->item, TRUE);
+ g_free(r->feedid);
+}
+
+gchar *
+display_doc (RDF *r)
+{
+ gchar *title = NULL;
+ if ((title = process_feed(r)))
+ display_feed(r);
+ return title;
+}
+
static void
delete_oldest_article(CamelFolder *folder, guint unread)
{
diff --git a/src/rss.h b/src/rss.h
index 896056d..051f0f4 100644
--- a/src/rss.h
+++ b/src/rss.h
@@ -173,6 +173,7 @@ typedef struct _rssfeed {
#define GCONF_KEY_STATUS_ICON "/apps/evolution/evolution-rss/status_icon"
#define GCONF_KEY_BLINK_ICON "/apps/evolution/evolution-rss/blink_icon"
#define GCONF_KEY_FEED_ICON "/apps/evolution/evolution-rss/feed_icon"
+#define GCONF_KEY_ACCEPT_COOKIES "/apps/evolution/evolution-rss/accept_cookies"
enum {
RSS_FEED,
@@ -311,7 +312,7 @@ void migrate_crc_md5(const char *name, gchar *url);
void free_cf(create_feed *CF);
gchar *generate_safe_chn_name(gchar *chn_name);
void update_sr_message(void);
-void update_feed_image(gchar *image, gchar *key);
+void update_feed_image(RDF *r);
void update_status_icon(const char *channel, gchar *title);
void
#if LIBSOUP_VERSION < 2003000
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]