[evolution-rss] add option to delete articles that are no loger present in the feed
- From: Lucian Langa <lucilanga src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-rss] add option to delete articles that are no loger present in the feed
- Date: Sun, 7 Jun 2009 12:56:38 -0400 (EDT)
commit 2ce4dc367a1faff0db414277a34945f1c383aa4e
Author: Lucian Langa <lucilanga gnome org>
Date: Sun Jun 7 19:55:57 2009 +0300
add option to delete articles that are no loger present in the feed
---
src/parser.c | 7 +-
src/rss-config-factory.c | 62 ++++++------
src/rss-ui.glade | 228 ++++++++++++++++++++++++++++++++++++----------
src/rss.c | 58 +++++++++---
src/rss.h | 1 +
5 files changed, 262 insertions(+), 94 deletions(-)
diff --git a/src/parser.c b/src/parser.c
index 750d1d3..36faf3f 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -982,7 +982,7 @@ parse_channel_line(xmlNode *top, gchar *feed_name, char *main_date)
CF->encl = g_strdup(encl);
CF->comments = g_strdup(comments);
CF->feed_fname = g_strdup(feed_name); //feed file name
- CF->feed_uri = g_strdup(feed); //feed file url
+ CF->feed_uri = g_strdup(feed); //feed uri (uid!)
CF->category = category; //list of category feed is posted under
g_free(p);
if (q) g_free(q);
@@ -1045,6 +1045,11 @@ update_channel(RDF *r)
}
CF = parse_channel_line(el->children, feed_name, main_date);
+ if (!r->uids) {
+ r->uids = g_array_new(TRUE, TRUE, sizeof(gpointer));
+ }
+ gchar *uid = g_strdup(CF->feed_uri);
+ g_array_append_val(r->uids, uid);
CF->feedid = g_strdup(buf);
CF->sender = g_strdup(sender);
CF->full_path = g_strdup(chn_name);
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index baac5ac..57f1ff2 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -210,8 +210,7 @@ rep_check_cb (GtkWidget *widget, gpointer data)
//if we already have a timeout set destroy it first
if (rf->rc_id && !active)
g_source_remove(rf->rc_id);
- if (active)
- {
+ if (active) {
gtk_spin_button_update((GtkSpinButton *)data);
//we have to make sure we have a timeout value
if (!gconf_client_get_float(rss_gconf, GCONF_KEY_REP_CHECK_TIMEOUT, NULL))
@@ -232,8 +231,7 @@ rep_check_timeout_cb (GtkWidget *widget, gpointer data)
gtk_spin_button_update((GtkSpinButton *)widget);
gconf_client_set_float (rss_gconf, GCONF_KEY_REP_CHECK_TIMEOUT,
gtk_spin_button_get_value((GtkSpinButton*)widget), NULL);
- if (active)
- {
+ if (active) {
if (rf->rc_id)
g_source_remove(rf->rc_id);
rf->rc_id = g_timeout_add (60 * 1000 * gtk_spin_button_get_value((GtkSpinButton *)widget),
@@ -392,9 +390,9 @@ build_dialog_add(gchar *url, gchar *feed_text)
GtkWidget *entry2 = (GtkWidget *)glade_xml_get_widget (gui, "entry2");
if (url != NULL) {
- flabel = g_markup_printf_escaped("%s: <b>%s</b>", _("Folder"),
- lookup_feed_folder(feed_text));
- gtk_label_set_text(GTK_LABEL(entry2), flabel);
+// flabel = g_markup_printf_escaped("%s: <b>%s</b>", _("Folder"),
+ // lookup_feed_folder(feed_text));
+ gtk_label_set_text(GTK_LABEL(entry2), lookup_feed_folder(feed_text));
gtk_label_set_use_markup(GTK_LABEL(entry2), 1);
} else
gtk_label_set_text(GTK_LABEL(entry2), flabel);
@@ -422,6 +420,7 @@ build_dialog_add(gchar *url, gchar *feed_text)
GtkWidget *radiobutton1 = (GtkWidget *)glade_xml_get_widget (gui, "storage_rb1");
GtkWidget *radiobutton2 = (GtkWidget *)glade_xml_get_widget (gui, "storage_rb2");
GtkWidget *radiobutton3 = (GtkWidget *)glade_xml_get_widget (gui, "storage_rb3");
+ GtkWidget *radiobutton7 = (GtkWidget *)glade_xml_get_widget (gui, "storage_rb4");
GtkWidget *radiobutton4 = (GtkWidget *)glade_xml_get_widget (gui, "ttl_global");
GtkWidget *radiobutton5 = (GtkWidget *)glade_xml_get_widget (gui, "ttl");
GtkWidget *radiobutton6 = (GtkWidget *)glade_xml_get_widget (gui, "ttl_disabled");
@@ -446,6 +445,10 @@ build_dialog_add(gchar *url, gchar *feed_text)
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(radiobutton3), 1);
break;
+ case 3: //articles not present in feed
+ gtk_toggle_button_set_active(
+ GTK_TOGGLE_BUTTON(radiobutton7), 1);
+ break;
default:
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(radiobutton1), 1);
@@ -496,8 +499,8 @@ build_dialog_add(gchar *url, gchar *feed_text)
feed->dialog = dialog1;
feed->child = child;
feed->gui = gui;
- if (flabel)
- g_free(flabel);
+// if (flabel)
+ // g_free(flabel);
return feed;
}
@@ -512,6 +515,7 @@ actions_dialog_add(add_feed *feed, gchar *url)
GtkWidget *radiobutton1 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb1");
GtkWidget *radiobutton2 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb2");
GtkWidget *radiobutton3 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb3");
+ GtkWidget *radiobutton7 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb4");
GtkWidget *radiobutton4 = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl_global");
GtkWidget *radiobutton5 = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl");
GtkWidget *radiobutton6 = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl_disabled");
@@ -533,7 +537,7 @@ actions_dialog_add(add_feed *feed, gchar *url)
feed->validate = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(checkbutton3));
guint i=0;
- while (i<3) {
+ while (i<4) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton1)))
break;
i++;
@@ -542,6 +546,9 @@ actions_dialog_add(add_feed *feed, gchar *url)
i++;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton3)))
break;
+ i++;
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton7)))
+ break;
}
feed->del_feed = i;
feed->del_unread = gtk_toggle_button_get_active(
@@ -944,7 +951,6 @@ process_dialog_edit(add_feed *feed, gchar *url, gchar *feed_name)
_("Feed already exists!"));
goto out;
}
- g_print("feed_name:%s\n", feed_name);
hrfeed *saved_feed = save_feed_hash(feed_name);
remove_feed_hash(feed_name);
gpointer md5 = gen_md5(feed->feed_url);
@@ -1227,8 +1233,7 @@ select_file_response(GtkWidget *selector, guint response, gpointer user_data)
import_opml(name);
g_free(name);
}
- }
- else
+ } else
gtk_widget_destroy(selector);
}
@@ -1410,8 +1415,7 @@ create_export_dialog (void)
static void
import_cb (GtkWidget *widget, gpointer data)
{
- if (!rf->import)
- {
+ if (!rf->import) {
GtkWidget *import = create_import_dialog();
decorate_import_fs(import);
gtk_widget_show(import);
@@ -1498,13 +1502,10 @@ export_opml(gchar *file)
goto out;
over: f = fopen(file, "w+");
- if (f)
- {
+ if (f) {
fwrite(opml, strlen(opml), 1, f);
fclose(f);
- }
- else
- {
+ } else {
e_error_run(NULL,
"org-gnome-evolution-rss:feederr",
_("Error exporting feeds!"),
@@ -1522,14 +1523,12 @@ select_export_response(GtkWidget *selector, guint response, gpointer user_data)
char *name;
name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector));
- if (name)
- {
+ if (name) {
gtk_widget_destroy(selector);
export_opml(name);
g_free(name);
}
- }
- else
+ } else
gtk_widget_destroy(selector);
}
@@ -1574,13 +1573,11 @@ decorate_export_fs (gpointer data)
static void
export_cb (GtkWidget *widget, gpointer data)
{
- if (!rf->import)
- {
+ if (!rf->import) {
GtkWidget *export = create_export_dialog();
decorate_export_fs(export);
gtk_dialog_set_default_response (GTK_DIALOG (export), GTK_RESPONSE_OK);
- if (g_hash_table_size(rf->hrname)<1)
- {
+ if (g_hash_table_size(rf->hrname)<1) {
e_error_run(NULL,
"org-gnome-evolution-rss:generr",
_("No RSS feeds configured!\nUnable to export."),
@@ -1773,6 +1770,7 @@ void rss_folder_factory_commit (EPlugin *epl, EConfigTarget *target)
GtkWidget *radiobutton1 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb1");
GtkWidget *radiobutton2 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb2");
GtkWidget *radiobutton3 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb3");
+ GtkWidget *radiobutton7 = (GtkWidget *)glade_xml_get_widget (feed->gui, "storage_rb4");
GtkWidget *radiobutton4 = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl_global");
GtkWidget *radiobutton5 = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl");
GtkWidget *radiobutton6 = (GtkWidget *)glade_xml_get_widget (feed->gui, "ttl_disabled");
@@ -1791,7 +1789,7 @@ void rss_folder_factory_commit (EPlugin *epl, EConfigTarget *target)
feed->validate = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(checkbutton3));
guint i=0;
- while (i<3) {
+ while (i<4) {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton1)))
break;
i++;
@@ -1800,6 +1798,9 @@ void rss_folder_factory_commit (EPlugin *epl, EConfigTarget *target)
i++;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton3)))
break;
+ i++;
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton7)))
+ break;
}
feed->del_feed=i;
feed->del_unread = gtk_toggle_button_get_active(
@@ -2040,8 +2041,7 @@ rss_config_control_new (void)
GCONF_KEY_HTML_RENDER,
NULL));
- switch (render)
- {
+ switch (render) {
case 10:
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
break;
diff --git a/src/rss-ui.glade b/src/rss-ui.glade
index b3fda12..2e572d2 100644
--- a/src/rss-ui.glade
+++ b/src/rss-ui.glade
@@ -947,9 +947,9 @@
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
- <property name="action">save</property>
<property name="local_only">False</property>
<property name="show_hidden">True</property>
+ <property name="action">save</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="vbox26">
<property name="visible">True</property>
@@ -1017,41 +1017,90 @@
<property name="visible">True</property>
<property name="spacing">20</property>
<child>
- <widget class="GtkHBox" id="hbox14">
+ <widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<child>
- <widget class="GtkLabel" id="label18">
+ <widget class="GtkTable" id="table1">
<property name="visible">True</property>
- <property name="label" translatable="yes"><b>Feed URL:</b></property>
- <property name="use_markup">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkEntry" id="url_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="folder_box">
- <property name="visible">True</property>
- <property name="spacing">8</property>
- <child>
- <widget class="GtkImage" id="image1">
- <property name="stock">gtk-missing-image</property>
- <property name="icon-size">6</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">1</property>
+ <property name="row_spacing">2</property>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Name: </b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="entry1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="url_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label18">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>URL:</b></property>
+ <property name="use_markup">True</property>
+ <property name="justify">right</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="stock">gtk-missing-image</property>
+ <property name="icon-size">1</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="entry2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">label</property>
+ <property name="wrap">True</property>
+ <property name="single_line_mode">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -1059,21 +1108,11 @@
<property name="position">0</property>
</packing>
</child>
- <child>
- <widget class="GtkLabel" id="entry2">
- <property name="visible">True</property>
- <property name="label" translatable="yes">label</property>
- <property name="wrap">True</property>
- <property name="single_line_mode">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
</widget>
<packing>
- <property name="position">1</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
@@ -1091,6 +1130,7 @@
<widget class="GtkVBox" id="vbox7">
<property name="visible">True</property>
<property name="border_width">10</property>
+ <property name="orientation">vertical</property>
<child>
<widget class="GtkCheckButton" id="enabled_check">
<property name="label" translatable="yes">Enabled</property>
@@ -1149,6 +1189,7 @@
<widget class="GtkVBox" id="vbox8">
<property name="visible">True</property>
<property name="border_width">10</property>
+ <property name="orientation">vertical</property>
<child>
<widget class="GtkRadioButton" id="ttl_global">
<property name="label" translatable="yes">Use global update interval</property>
@@ -1186,6 +1227,7 @@
<widget class="GtkSpinButton" id="ttl_value">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
<property name="adjustment">0 0 100 1 10 10</property>
<property name="climb_rate">1</property>
</widget>
@@ -1220,7 +1262,6 @@ days</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
- <property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">ttl_global</property>
</widget>
@@ -1267,6 +1308,7 @@ days</property>
<child>
<widget class="GtkHBox" id="hbox8">
<property name="visible">True</property>
+ <property name="spacing">5</property>
<child>
<widget class="GtkRadioButton" id="storage_rb2">
<property name="label" translatable="yes">Delete all but the last</property>
@@ -1278,6 +1320,7 @@ days</property>
<property name="group">storage_rb1</property>
</widget>
<packing>
+ <property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
@@ -1290,6 +1333,7 @@ days</property>
<property name="climb_rate">1</property>
</widget>
<packing>
+ <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -1299,17 +1343,22 @@ days</property>
<property name="label" translatable="yes" comments="To translators: this label is part of the following message: "Delete all but the last X messages.">messages</property>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox11">
<property name="visible">True</property>
+ <property name="spacing">5</property>
<child>
<widget class="GtkRadioButton" id="storage_rb3">
<property name="label" translatable="yes">Delete articles older than</property>
@@ -1321,6 +1370,8 @@ days</property>
<property name="group">storage_rb1</property>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
@@ -1333,6 +1384,8 @@ days</property>
<property name="climb_rate">1</property>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -1342,11 +1395,15 @@ days</property>
<property name="label" translatable="yes" comments="for translators: this label is part of the "Delete articles older than X days" message.">days</property>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
@@ -1356,11 +1413,11 @@ days</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">storage_rb1</property>
</widget>
<packing>
+ <property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
@@ -1393,6 +1450,79 @@ days</property>
<property name="type">tab</property>
</packing>
</child>
+ <child>
+ <widget class="GtkTable" id="table4">
+ <property name="visible">True</property>
+ <property name="border_width">15</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <child>
+ <widget class="GtkLabel" id="label189">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Username:</property>
+ </widget>
+ <packing>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label190">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Password: </property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="proxy_user">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="proxy_pass">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="visibility">False</property>
+ <property name="invisible_char">●</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Authentication</property>
+ </widget>
+ <packing>
+ <property name="position">3</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
</widget>
</child>
<child>
@@ -1409,7 +1539,7 @@ days</property>
</child>
</widget>
<packing>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
</widget>
diff --git a/src/rss.c b/src/rss.c
index 0835160..9ef2e30 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -211,7 +211,7 @@ void check_folders(void);
CamelMimePart *file_to_message(const char *name);
void save_gconf_feed(void);
void check_feed_age(void);
-void get_feed_age(gpointer key, gpointer value);
+void get_feed_age(RDF *r, gpointer name);
static void
#if LIBSOUP_VERSION < 2003000
finish_image (SoupMessage *msg, CamelStream *user_data);
@@ -1513,6 +1513,7 @@ webkit_over_link(WebKitWebView *web_view,
g_free(msg);
} else
taskbar_pop_message();
+ return TRUE;
}
@@ -1831,7 +1832,6 @@ void org_gnome_cooly_format_rss(void *ep, EMFormatHookTarget *t) //camelmimepart
GError *err = NULL;
GString *content;
xmlChar *buff = NULL;
- int size = 0;
CamelContentType *type;
gchar *feedid = NULL;
gchar *comments = NULL;
@@ -2752,6 +2752,8 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
update_ttl(md5, r->ttl);
user_data = chn_name;
}
+ if (g_hash_table_lookup(rf->hrdel_feed, lookup_key(user_data)))
+ get_feed_age(r, user_data);
}
if (r->cache)
xmlFreeDoc(r->cache);
@@ -2765,10 +2767,6 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
g_free(r);
g_string_free(response, 1);
- if (!deleted) {
- if (g_hash_table_lookup(rf->hrdel_feed, lookup_key(user_data)))
- get_feed_age(user_data, lookup_key(user_data));
- }
//tout:
#ifdef EVOLUTION_2_12
@@ -4707,29 +4705,63 @@ out: camel_message_info_free(info);
}
void
-get_feed_age(gpointer key, gpointer value)
+get_feed_age(RDF *r, gpointer name)
{
CamelMessageInfo *info;
CamelFolder *folder;
CamelStore *store = mail_component_peek_local_store(NULL);
GPtrArray *uids;
time_t date, now;
- guint i,total;
+ guint i,j,total;
guint32 flags;
+ gpointer key = lookup_key(name);
+ gchar *el, *feedid;
+ gboolean match;
- gchar *real_folder = lookup_feed_folder(key);
+ gchar *real_folder = lookup_feed_folder(name);
d(g_print("Cleaning folder: %s\n", real_folder));
+
gchar *real_name = g_strdup_printf("%s/%s", lookup_main_folder(), real_folder);
if (!(folder = camel_store_get_folder (store, real_name, 0, NULL)))
goto fail;
time (&now);
- guint del_unread = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrdel_unread, value));
- guint del_feed = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrdel_feed, value));
+ guint del_unread = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrdel_unread, key));
+ guint del_feed = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrdel_feed, key));
inhibit_read = 1;
+ if (del_feed == 3) {
+ uids = camel_folder_get_uids (folder);
+ camel_folder_freeze(folder);
+ for (i = 0; i < uids->len; i++) {
+ el = NULL;
+ match = FALSE;
+ feedid = (gchar *)camel_medium_get_header (
+ CAMEL_MEDIUM(camel_folder_get_message(
+ folder,
+ uids->pdata[i],
+ NULL)),
+ "X-Evolution-Rss-Feed-id");
+ for (j=0; NULL != (el = g_array_index(r->uids, gpointer, j)); j++) {
+ if (!g_ascii_strcasecmp(g_strstrip(feedid), g_strstrip(el)))
+ match = TRUE;
+ }
+ if (!match) {
+ info = camel_folder_get_message_info(folder, uids->pdata[i]);
+ flags = camel_message_info_flags(info);
+ if ((del_unread) && !(flags & CAMEL_MESSAGE_FLAGGED)) {
+ camel_folder_delete_message(folder, uids->pdata[i]);
+ }
+ camel_folder_free_message_info(folder, info);
+ }
+ }
+ camel_folder_free_uids (folder, uids);
+ camel_folder_sync (folder, TRUE, NULL);
+ camel_folder_thaw(folder);
+ camel_folder_expunge (folder, NULL);
+ }
if (del_feed == 2) {
- guint del_days = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrdel_days, value));
+ guint del_days = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrdel_days, key));
uids = camel_folder_get_uids (folder);
camel_folder_freeze(folder);
for (i = 0; i < uids->len; i++) {
@@ -4758,7 +4790,7 @@ get_feed_age(gpointer key, gpointer value)
camel_folder_expunge (folder, NULL);
}
if (del_feed == 1) {
- guint del_messages = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrdel_messages, value));
+ guint del_messages = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrdel_messages, key));
guint total = camel_folder_get_message_count(folder);
i=1;
while (del_messages < camel_folder_get_message_count(folder)
diff --git a/src/rss.h b/src/rss.h
index a5b60a0..3101ddd 100644
--- a/src/rss.h
+++ b/src/rss.h
@@ -67,6 +67,7 @@ typedef struct _RDF {
SoupMessage *message;
guint error; //invalid feed
char *strerror; //error msg
+ GArray *uids;
} RDF;
//we keep these values of a feed to be deleted in order
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]