Commit fbb9dde9 authored by Lucian Langa's avatar Lucian Langa Committed by Lucian Langa
Browse files

- add support for feed checking setup by hours and days

2009-03-30  Lucian Langa  <lucilanga@gnome.org>

* src/rss-config_factory.c: (create_dialog_add) - add support for
feed checking setup by hours and days

svn path=/trunk/; revision=486
parent e0b2eb85
2009-03-30 Lucian Langa <lucilanga@gnome.org>
* src/rss-config_factory.c: (create_dialog_add) - add support for
feed checking setup by hours and days
2009-03-29 Lucian Langa <lucilanga@gnome.org>
* src/misc.c: (sanitize_url) - extra sanitize input string (imported
......
......@@ -45,7 +45,6 @@
name=<value optimized out>, error=<value optimized out>,
emsg=<value optimized out>) at rss.c:273
* implement right-click in browser
* category posted under
* coments updatable
* slow delete operation on large folders
* check operation cancel button
......@@ -54,13 +53,11 @@
* handle slash categories
* hook update in the properties of folder
* use combo popup for moving and placement of feed folders
* trigger resync after folder rename
* trigger resync after folder rename and initial folder creation
* check webbuttons for webkit
* cancel operation should cancel fetching feed components
* see whether we need to allow higher ttl update interval
* fetch_image() handle 404 <-
* count comments |
* perhaps make quoted text fancier |
* if immage cannto be server from cache try to fetch it ---|
* disable filters on setup_feed()
* allow interval of minutes configurable by days/years
......@@ -102,7 +102,7 @@ my_xml_perror_handler (void *ctx, const char *msg, ...)
{
rsserror = TRUE;
// rssstrerror
g_print("!!ERROR:%s!!", msg);
g_print("xml_parse_sux(): ERROR:%s\n", msg);
}
static void
......
......@@ -256,6 +256,13 @@ construct_list(gpointer key, gpointer value, gpointer user_data)
g_free(name);
}
static void
ttl_multiply_cb (GtkWidget *widget, add_feed *data)
{
guint active = gtk_combo_box_get_active((GtkComboBox*)widget);
data->ttl_multiply = active;
}
static void
ttl_cb (GtkWidget *widget, add_feed *data)
{
......@@ -340,6 +347,9 @@ create_dialog_add(gchar *text, gchar *feed_text)
feed->ttl = GPOINTER_TO_INT(
g_hash_table_lookup(rf->hrttl,
lookup_key(feed_text)));
feed->ttl_multiply = GPOINTER_TO_INT(
g_hash_table_lookup(rf->hrttl_multiply,
lookup_key(feed_text)));
}
gboolean validate = 1;
......@@ -354,6 +364,9 @@ create_dialog_add(gchar *text, gchar *feed_text)
else
gtk_label_set_text(GTK_LABEL(entry2), flabel);
GtkWidget *combobox1 = (GtkWidget *)glade_xml_get_widget (gui, "combobox1");
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox1), 0);
GtkWidget *checkbutton1 = (GtkWidget *)glade_xml_get_widget (gui, "html_check");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton1), 1-fhtml);
......@@ -404,6 +417,10 @@ create_dialog_add(gchar *text, gchar *feed_text)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(ttl_value), feed->ttl);
g_signal_connect(ttl_value, "changed", G_CALLBACK(ttl_cb), feed);
gtk_combo_box_set_active(GTK_COMBO_BOX(combobox1), feed->ttl_multiply);
g_signal_connect(combobox1, "changed", G_CALLBACK(ttl_multiply_cb), feed);
switch (feed->update)
{
case 2:
......@@ -642,6 +659,7 @@ save_feed_hash(gpointer name)
saved_feed->hrdel_unread = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrdel_unread, lookup_key(name)));
saved_feed->hrupdate = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrupdate, lookup_key(name)));
saved_feed->hrttl = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrttl, lookup_key(name)));
saved_feed->hrttl_multiply = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrttl_multiply, lookup_key(name)));
return saved_feed;
}
......@@ -664,6 +682,7 @@ restore_feed_hash(gpointer name, hrfeed *s)
g_hash_table_insert(rf->hrdel_unread, g_strdup(lookup_key(name)), GINT_TO_POINTER(s->hrdel_unread));
g_hash_table_insert(rf->hrupdate, g_strdup(lookup_key(name)), GINT_TO_POINTER(s->hrupdate));
g_hash_table_insert(rf->hrttl, g_strdup(lookup_key(name)), GINT_TO_POINTER(s->hrttl));
g_hash_table_insert(rf->hrttl_multiply, g_strdup(lookup_key(name)), GINT_TO_POINTER(s->hrttl_multiply));
g_free(s);
}
......@@ -683,6 +702,7 @@ remove_feed_hash(gpointer name)
g_hash_table_remove(rf->hrdel_unread, lookup_key(name));
g_hash_table_remove(rf->hrupdate, lookup_key(name));
g_hash_table_remove(rf->hrttl, lookup_key(name));
g_hash_table_remove(rf->hrttl_multiply, lookup_key(name));
g_hash_table_remove(rf->hrname_r, lookup_key(name));
g_hash_table_remove(rf->hrname, name);
rf->pending = FALSE;
......@@ -940,6 +960,9 @@ feeds_dialog_edit(GtkDialog *d, gpointer data)
g_hash_table_replace(rf->hrttl,
g_strdup(key),
GINT_TO_POINTER(feed->ttl));
g_hash_table_replace(rf->hrttl_multiply,
g_strdup(key),
GINT_TO_POINTER(feed->ttl_multiply));
custom_feed_timeout();
}
if (feed->update == 3)
......
This diff is collapsed.
......@@ -861,6 +861,9 @@ feed_to_xml(gchar *key)
ctmp = g_strdup_printf("%d", g_hash_table_lookup(rf->hrttl, lookup_key(key)));
xmlSetProp (src, "value", ctmp);
g_free(ctmp);
ctmp = g_strdup_printf("%d", g_hash_table_lookup(rf->hrttl_multiply, lookup_key(key)));
xmlSetProp (src, "factor", ctmp);
g_free(ctmp);
xmlDocDumpMemory (doc, &xmlbuf, &n);
xmlFreeDoc (doc);
......@@ -1119,6 +1122,7 @@ feed_new_from_xml(char *xml)
guint del_messages=0;
guint del_unread=0;
guint ttl=0;
guint ttl_multiply=0;
guint update=0;
gchar *ctmp = NULL;
......@@ -1159,6 +1163,9 @@ feed_new_from_xml(char *xml)
update = atoi(ctmp);
xml_set_prop (node, "value", &ctmp);
ttl = atoi(ctmp);
xml_set_prop (node, "factor", &ctmp);
if (ctmp)
ttl_multiply = atoi(ctmp);
if (ctmp) g_free(ctmp);
}
......@@ -1192,6 +1199,9 @@ feed_new_from_xml(char *xml)
g_hash_table_insert(rf->hrttl,
g_strdup(uid),
GINT_TO_POINTER(ttl));
g_hash_table_insert(rf->hrttl_multiply,
g_strdup(uid),
GINT_TO_POINTER(ttl_multiply));
}
char *
......@@ -1309,6 +1319,7 @@ read_feeds(rssfeed *rf)
rf->hrdel_unread = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
rf->hrupdate = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
rf->hrttl = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
rf->hrttl_multiply = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
if (g_file_test(feed_file, G_FILE_TEST_EXISTS))
migrate_old_config(feed_file);
......@@ -2078,6 +2089,7 @@ setup_feed(add_feed *feed)
CamelException ex;
guint ret = 0;
guint ttl;
guint ttl_multiply = 0;
RDF *r = NULL;
GString *post;
GError *err = NULL;
......@@ -2155,6 +2167,11 @@ setup_feed(add_feed *feed)
g_str_equal,
g_free,
NULL);
if (rf->hrttl_multiply == NULL)
rf->hrttl_multiply = g_hash_table_new_full(g_str_hash,
g_str_equal,
g_free,
NULL);
if (rf->hrupdate == NULL)
rf->hrupdate = g_hash_table_new_full(g_str_hash,
g_str_equal,
......@@ -2237,6 +2254,9 @@ add:
g_hash_table_insert(rf->hrttl,
g_strdup(crc_feed),
GINT_TO_POINTER(ttl));
g_hash_table_insert(rf->hrttl_multiply,
g_strdup(crc_feed),
GINT_TO_POINTER(feed->ttl_multiply));
custom_feed_timeout();
g_hash_table_insert(rf->hrupdate,
g_strdup(crc_feed),
......@@ -3146,6 +3166,7 @@ custom_fetch_feed(gpointer key, gpointer value, gpointer user_data)
{
d(g_print("custom key:%s\n", key));
guint ttl = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrttl, lookup_key(key)));
guint ttl_multiply = GPOINTER_TO_INT(g_hash_table_lookup(rf->hrttl_multiply, lookup_key(key)));
if (ttl) {
CDATA *cdata = g_new0(CDATA, 1);
cdata->key = key;
......@@ -3155,7 +3176,18 @@ custom_fetch_feed(gpointer key, gpointer value, gpointer user_data)
lookup_key(key)));
if (time_id)
g_source_remove(time_id);
time_id = g_timeout_add (4*60*1000, //ttl * 60 * 1000,
switch (ttl_multiply) {
case 1:
ttl_multiply = 60;
break;
case 2:
ttl_multiply = 1440;
break;
default:
ttl_multiply = 1;
break;
}
time_id = g_timeout_add (ttl * 60 * 1000 * ttl_multiply,
(GtkFunction) custom_update_articles,
cdata);
g_hash_table_replace(custom_timeout,
......
......@@ -77,6 +77,7 @@ typedef struct _hrfeed {
guint hrdel_unread;
guint hrupdate;
guint hrttl;
guint hrttl_multiply;
} hrfeed;
typedef struct _rssfeed {
......@@ -95,7 +96,8 @@ typedef struct _rssfeed {
GHashTable *hrdel_days; //option to delete messages older then days
GHashTable *hrdel_messages; //option to keep last messages
GHashTable *hrdel_unread; //option to delete unread messages too
GHashTable *hrttl; //feeds name hash
GHashTable *hrttl;
GHashTable *hrttl_multiply;
GHashTable *hrupdate; //feeds update method
GtkWidget *feed_dialog;
GtkWidget *progress_dialog;
......@@ -181,6 +183,7 @@ typedef struct ADD_FEED {
guint del_messages; // delete all messages but the last del_messages
gboolean del_unread; // delete unread messages too
guint ttl; // recommended update time
guint ttl_multiply; // how much we multiyply ttl value (minutes)
guint update; // feed update method global; ttl; disabled
} add_feed;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment