[evolution-rss] cancel fetching comments when article or summary changed
- From: Lucian Langa <lucilanga src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-rss] cancel fetching comments when article or summary changed
- Date: Fri, 14 Aug 2009 14:54:37 +0000 (UTC)
commit 3e54991112fc37fa7f2a0e88e2668b6eefd6ffa9
Author: Lucian Langa <lucilanga gnome org>
Date: Fri Aug 14 17:54:26 2009 +0300
cancel fetching comments when article or summary changed
TODO | 3 ---
src/fetch.c | 5 +++--
src/fetch.h | 3 ++-
src/network-soup.c | 6 +++---
src/network-soup.h | 2 +-
src/rss-config-factory.c | 2 +-
src/rss.c | 43 ++++++++++++++++++++++++++++++++-----------
7 files changed, 42 insertions(+), 22 deletions(-)
---
diff --git a/TODO b/TODO
index 9620d37..a23d6a4 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,6 @@
* maybe implement md5 for uniqueing articles (for broken feeds)
* check webkit area sizing when using zoom in/out
- * failback to old handler when formatting error
* jump to folder when adding through d-bus
* implement other engines besides soup
* implement USM (universal subscription mechanism)
@@ -26,7 +25,6 @@
* perhaps make quoted text fancier
* if immage cannto be served from cache try to fetch it ( add 3 times retry for fetching an image)
* disable filters on setup_feed()
- * store feed in an alternate file to serve images from
* migrate fetch_blocking -> fetch_unblocking
* grey out disabled folders (feeds)
* feed check runtime validation
@@ -36,7 +34,6 @@
* gtkhtml does not handle 
 construct
* switch webkit -> gecko leads to crash on pfree()
* show feed icons in send & receive dialog
- * cancel fetching comments when summary display is changed
* detect duplicate items by content not by feedid
* make gtkhtml rendering non-blocking
* use ellipsize in web auth dialog
diff --git a/src/fetch.c b/src/fetch.c
index 6d2bd5f..8c3debe 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -66,7 +66,7 @@ error:
//fetch feed
//FIXME gio callback hardcoded
-gboolean
+SoupSession*
fetch_unblocking(gchar *url, NetStatusCallback cb, gpointer data,
gpointer cb2, gpointer cbdata2,
guint track,
@@ -81,13 +81,14 @@ fetch_unblocking(gchar *url, NetStatusCallback cb, gpointer data,
if (!g_ascii_strcasecmp(scheme, "file")) {
g_free(scheme);
- return file_get_unblocking(url,
+ file_get_unblocking(url,
NULL, // add status here //
NULL,
gio_finish_feed,
cbdata2,
0,
err);
+ return NULL;
} else {
g_free(scheme);
return net_get_unblocking(url,
diff --git a/src/fetch.h b/src/fetch.h
index 89e5f9e..8bc41f8 100644
--- a/src/fetch.h
+++ b/src/fetch.h
@@ -21,13 +21,14 @@
#ifndef _FETCH_H_
#define _FETCH_H_ 1
+#include <libsoup/soup-gnome.h>
#include "network.h"
GString *fetch_blocking(gchar *url, GSList *headers, GString *post,
NetStatusCallback cb, gpointer data,
GError **err);
-gboolean fetch_unblocking(gchar *url, NetStatusCallback cb, gpointer data,
+SoupSession *fetch_unblocking(gchar *url, NetStatusCallback cb, gpointer data,
gpointer cb2, gpointer cbdata2,
guint track,
GError **err);
diff --git a/src/network-soup.c b/src/network-soup.c
index 86b236a..6cd964f 100644
--- a/src/network-soup.c
+++ b/src/network-soup.c
@@ -497,7 +497,7 @@ out:
return response;
}
-gboolean
+SoupSession*
net_get_unblocking(gchar *url,
NetStatusCallback cb, gpointer data,
gpointer cb2, gpointer cbdata2,
@@ -544,7 +544,7 @@ net_get_unblocking(gchar *url,
if (!msg) {
g_set_error(err, NET_ERROR, NET_ERROR_GENERIC,
soup_status_get_phrase(2)); //invalid url
- return -1;
+ return (SoupSession *)-1;
}
if (track) {
@@ -579,7 +579,7 @@ net_get_unblocking(gchar *url,
// g_object_weak_ref (G_OBJECT(soup_sess), unblock_free, soup_sess);
// GMainLoop *mainloop = g_main_loop_new (g_main_context_default (), FALSE);
// g_timeout_add (10 * 1000, &conn_mainloop_quit, mainloop);
- return 1;
+ return soup_sess;
}
GString*
diff --git a/src/network-soup.h b/src/network-soup.h
index 9cc3dfb..2e4ec0c 100644
--- a/src/network-soup.h
+++ b/src/network-soup.h
@@ -23,7 +23,7 @@
void abort_all_soup(void);
gboolean cancel_soup_sess(gpointer key, gpointer value, gpointer user_data);
-gboolean net_get_unblocking(gchar *url,
+SoupSession *net_get_unblocking(gchar *url,
NetStatusCallback cb, gpointer data,
gpointer cb2, gpointer cbdata2,
guint track,
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index da31d76..06557e1 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -2156,7 +2156,7 @@ struct _EConfigTargetRSS
void rss_folder_factory_abort (EPlugin *epl, EConfigTarget *target)
{
- g_print("abort");
+ d(g_print("abort"));
}
void rss_folder_factory_commit (EPlugin *epl, EConfigTarget *target)
diff --git a/src/rss.c b/src/rss.c
index b14e91b..27ef3f0 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -193,6 +193,7 @@ gboolean delete_op = FALSE; //delete in progress
gchar *commstream = NULL; //global comments stream
guint commcnt = 0; //global number of comments
gchar *commstatus = "";
+GSList *comments_session = NULL; //comments to be fetched queue
guint32 frame_colour;
guint32 content_colour;
guint32 text_colour;
@@ -543,12 +544,14 @@ browsercb(NetStatusType status, gpointer statusdata, gpointer data)
NetStatusProgress *progress = (NetStatusProgress*)statusdata;
switch (status) {
case NET_STATUS_PROGRESS:
+#if 0
// g_print("chunk:%s\n", progress->chunk);
g_print("total:%d\n", progress->total);
g_print("curent:%d\n", progress->current);
g_print("-------------- chunk: %d =============\n", GPOINTER_TO_INT(progress->chunksize));
//browser_write(progress->chunk, progress->chunksize, data);
// browser_fill+=progress->chunksize;
+#endif
break;
default:
g_warning("unhandled network status %d\n", status);
@@ -1379,7 +1382,9 @@ mycall (GtkWidget *widget, GtkAllocation *event, gpointer data)
int height = widget->allocation.height - 16 - k;
d(g_print("resize webkit :width:%d, height: %d\n", width, height));
if (po->mozembedwindow && rf->mozembed)
- if(GTK_IS_WIDGET(po->mozembedwindow) && height > 0) {
+ if(GTK_IS_WIDGET(po->mozembedwindow)
+ && GTK_WIDGET_REALIZED(rf->mozembed)
+ && height > 0) {
if (!browser_fetching) {
gchar *msg = g_strdup(_("Formatting..."));
browser_write(msg, strlen(msg), "file:///");
@@ -1837,6 +1842,13 @@ org_gnome_rss_controls (EMFormatHTML *efh, void *eb, EMFormatHTMLPObject *pobjec
}
void
+cancel_comments_session(SoupSession *sess)
+{
+ g_print("comment session to cancel:%p\n", sess);
+ soup_session_abort(sess);
+}
+
+void
free_rss_controls(EMFormatHTMLPObject *o)
{
struct _org_gnome_rss_controls_pobject *po =
@@ -1845,7 +1857,10 @@ free_rss_controls(EMFormatHTMLPObject *o)
g_free(po->mem);
if (po->website)
g_free(po->website);
- gtk_widget_destroy(po->html);
+ //gtk_widget_destroy(po->html);
+ g_slist_foreach(comments_session, (GFunc)cancel_comments_session, NULL);
+ g_slist_free(comments_session);
+ comments_session = NULL;
}
void
@@ -1854,7 +1869,7 @@ free_rss_browser(EMFormatHTMLPObject *o)
struct _org_gnome_rss_controls_pobject *po =
(struct _org_gnome_rss_controls_pobject *) o;
gpointer key = g_hash_table_lookup(rf->key_session, po->website);
- g_print("key sess:%p\n", key);
+ d(g_print("key sess:%p\n", key));
if (key) {
g_hash_table_remove(rf->key_session, po->website);
soup_session_abort(key);
@@ -3002,8 +3017,8 @@ finish_website (SoupSession *soup_sess, SoupMessage *msg, gpointer user_data)
{
g_return_if_fail(rf->mozembed);
GString *response = g_string_new_len(msg->response_body->data, msg->response_body->length);
- g_print("browser full:%d\n", (int)response->len);
- g_print("browser fill:%d\n", (int)browser_fill);
+ d(g_print("browser full:%d\n", (int)response->len));
+ d(g_print("browser fill:%d\n", (int)browser_fill));
if (!response->len) {
gchar *msg = g_strdup(_("Formatting error."));
browser_write(msg, strlen(msg), "file://");
@@ -3026,8 +3041,11 @@ finish_comments (SoupMessage *msg, EMFormatHTML *user_data)
finish_comments (SoupSession *soup_sess, SoupMessage *msg, EMFormatHTML *user_data)
#endif
{
+ g_print("...fetch coments end.\n");
guint reload=0;
+ comments_session = g_slist_remove(comments_session, soup_sess);
+
// if (!msg->length)
// goto out;
@@ -3042,7 +3060,7 @@ finish_comments (SoupSession *soup_sess, SoupMessage *msg, EMFormatHTML *user_da
commstream = response->str;
g_string_free(response, 0);
- if (reload) {
+ if (reload && !rf->cur_format) {
em_format_redraw((EMFormat *)user_data);
}
@@ -3086,17 +3104,20 @@ void
fetch_comments(gchar *url, EMFormatHTML *stream)
{
GError *err = NULL;
- d(g_print("\nFetching comments from: %s\n",
- url));
-
- fetch_unblocking(
+ SoupSession *comm_sess = NULL;
+ g_print("\nFetching comments from: %s\n", url);
+
+ comm_sess = fetch_unblocking(
url,
NULL,
NULL,
(gpointer)finish_comments,
stream, // we need to dupe key here
1,
- &err);
+ &err);
+
+ comments_session = g_slist_append(comments_session, comm_sess);
+
if (err) {
gchar *msg = g_strdup_printf("\n%s\n%s",
url, err->message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]