Commit 2037ca1f authored by Lucian Langa's avatar Lucian Langa Committed by Lucian Langa
Browse files

prefetch website data

2009-04-14  Lucian Langa  <lucilanga@gnome.org>

* src/rss.c (mycall), (org_gnome_rss_browser), (pfree),
(finish_website):
* src/rss.h: prefetch website data

svn path=/trunk/; revision=501
parent 39de15f4
......@@ -4,6 +4,11 @@
(finish_website):
* src/rss.h: prefetch website data
2009-04-09 Fridrich Strba <fridrich.strba@bluewin.ch>
* configure.ac: check for evolution-shell
* src/Makefile.am: u_int32_t -> uint32_t
2009-04-09 Lucian Langa <lucilanga@gnome.org>
* src/rss.c (org_gnome_cooly_format_rss): fix coments updates
......
......@@ -60,3 +60,5 @@
* check s&r progress bar on Complete.
* support https proxy
* support list of ignored hosts
* store feed in an alternate file to serve images from
* migrate fetch_blocking -> fetch_unblocking
......@@ -62,6 +62,7 @@ PKG_CHECK_MODULES(EVOLUTION_RSS_EPLUGIN,
gtk+-2.0 >= $LIBGTK_REQUIRED dnl
libsoup$SOUP >= $LIBSOUP_REQUIRED dnl
evolution-plugin$EVOLUTION_BASE_VERSION_S >= $EVOLUTION_REQUIRED dnl
evolution-shell$EVOLUTION_BASE_VERSION_S >= $EVOLUTION_REQUIRED dnl
libglade-2.0 dnl
])
......
......@@ -144,6 +144,7 @@ EXTRA_DIST = \
rss-config-factory.h \
rss-icon-factory.c \
rss-icon-factory.h \
strptime.c \
evolution-import-rss.c \
evolution-rss.schemas.in \
org-gnome-evolution-rss.eplug.xml \
......
......@@ -399,6 +399,7 @@ EXTRA_DIST = \
rss-config-factory.h \
rss-icon-factory.c \
rss-icon-factory.h \
strptime.c \
evolution-import-rss.c \
evolution-rss.schemas.in \
org-gnome-evolution-rss.eplug.xml \
......
......@@ -36,6 +36,7 @@ typedef struct {
NetStatusCallback user_cb;
gpointer user_data;
int current, total;
gchar *chunk;
} CallbackInfo;
static void
......@@ -97,10 +98,13 @@ got_chunk_cb(SoupMessage *msg, SoupBuffer *chunk, CallbackInfo *info) {
#else
info->current += chunk->length;
#endif
info->chunk = chunk->data;
progress = g_new0(NetStatusProgress, 1);
progress->current = info->current;
progress->total = info->total;
progress->chunk = chunk->data;
progress->chunksize = chunk->length;
info->user_cb(NET_STATUS_PROGRESS, progress, info->user_data);
g_free(progress);
}
......@@ -567,9 +571,11 @@ soup_message_add_header_handler (msg,
#endif
g_free(agstr);
if (info)
if (info) {
g_signal_connect(G_OBJECT(msg), "got_chunk",
G_CALLBACK(got_chunk_cb), info); //FIXME Find a way to free this maybe weak_ref
g_print("connected for %s\n", url);
}
soup_session_queue_message (soup_sess, msg,
cb2, cbdata2);
......
......@@ -106,6 +106,8 @@ typedef enum {
typedef struct {
guint32 current;
guint32 total;
gchar *chunk;
gchar *chunksize;
} NetStatusProgress;
typedef void (*NetStatusCallback)(NetStatusType status,
......
......@@ -189,6 +189,7 @@ gchar *commstatus = "";
guint32 frame_colour;
guint32 content_colour;
guint32 text_colour;
gboolean browser_fetching = 0; //mycall event could be triggered many times in first step (fetching)
gboolean setup_feed(add_feed *feed);
gchar *display_doc (RDF *r);
......@@ -487,6 +488,39 @@ statuscb(NetStatusType status, gpointer statusdata, gpointer data)
}
}
static void
browserwrite(gchar *string, gint length)
{
gchar *str = string;
gint len = length;
while (len > 0) {
if (len > 4096) {
gtk_moz_embed_append_data(GTK_MOZ_EMBED(rf->mozembed),
str, 4096);
str+=4096;
}
else
gtk_moz_embed_append_data(GTK_MOZ_EMBED(rf->mozembed),
str, len);
len-=4096;
}
}
static void
browsercb(NetStatusType status, gpointer statusdata, gpointer data)
{
NetStatusProgress *progress = (NetStatusProgress*)statusdata;
switch (status) {
case NET_STATUS_PROGRESS:
// g_print("chunk:%s\n", progress->chunk);
g_print("\n\n\nchunk write %d - %s - chunk write\n\n\n", progress->chunksize, progress->chunk);
browserwrite(progress->chunk, progress->chunksize);
break;
default:
g_warning("unhandled network status %d\n", status);
}
}
static void
textcb(NetStatusType status, gpointer statusdata, gpointer data)
{
......@@ -1447,19 +1481,20 @@ mycall (GtkWidget *widget, GtkAllocation *event, gpointer data)
if (po->mozembedwindow && rf->mozembed)
if(GTK_IS_WIDGET(po->mozembedwindow) && height > 0)
{
GString *content=g_string_new(NULL);
//GString *content = fetch_blocking(po->website, NULL, NULL, textcb, NULL, NULL);
fetch_unblocking(
po->website,
NULL,
NULL,
(gpointer)finish_website,
po->website, // we need to dupe key here
1,
NULL);
/* gtk_moz_embed_open_stream(GTK_MOZ_EMBED(rf->mozembed),
"file://", "text/html");
gchar *str = content->str;
gtk_moz_embed_open_stream(GTK_MOZ_EMBED(rf->mozembed),
po->website, "text/html");
if (!browser_fetching) {
browser_fetching=1;
fetch_unblocking(
po->website,
browsercb,
1,
(gpointer)finish_website,
po->website, // we need to dupe key here
1,
NULL);
}
/* gchar *str = content->str;
gint len = strlen(content->str);
while (len > 0) {
if (len > 4096) {
......@@ -1474,7 +1509,6 @@ mycall (GtkWidget *widget, GtkAllocation *event, gpointer data)
}
gtk_moz_embed_close_stream(GTK_MOZ_EMBED(rf->mozembed));*/
gtk_widget_set_size_request((GtkWidget *)po->mozembedwindow, width, height);
gtk_widget_show(po->mozembedwindow);
// apparently resizing gtkmozembed widget won't redraw if using xulrunner
// there is no point in reload for the rest
/*#if defined(HAVE_XULRUNNER)
......@@ -1591,9 +1625,9 @@ org_gnome_rss_browser (EMFormatHTML *efh, void *eb, EMFormatHTMLPObject *pobject
// gtk_container_set_resize_mode(w, GTK_RESIZE_PARENT);
// gtk_scrolled_window_set_policy(w, GTK_POLICY_NEVER, GTK_POLICY_NEVER);
////// gtk_widget_show_all(moz);
gtk_widget_show_all(moz);
gtk_container_add ((GtkContainer *) eb, moz);
////// gtk_container_check_resize ((GtkContainer *) eb);
gtk_container_check_resize ((GtkContainer *) eb);
// gtk_widget_set_size_request((GtkWidget *)rf->mozembed, 330, 330);
// gtk_container_add ((GtkContainer *) eb, rf->mozembed);
EMFormat *myf = (EMFormat *)efh;
......@@ -1736,6 +1770,7 @@ pfree(EMFormatHTMLPObject *o)
}*/
gtk_widget_destroy(po->container);
g_free(po->website);
browser_fetching = 0;
}
EMFormat *fom;
......@@ -1837,6 +1872,7 @@ void org_gnome_cooly_format_rss(void *ep, EMFormatHookTarget *t) //camelmimepart
goto out;
}
#endif
//replace with unblocking
content = fetch_blocking(addr, NULL, NULL, textcb, NULL, &err);
if (err)
{
......@@ -2723,7 +2759,7 @@ finish_website (SoupSession *soup_sess, SoupMessage *msg, gpointer user_data)
#endif
{
GString *response = g_string_new_len(msg->response_body->data, msg->response_body->length);
gtk_moz_embed_open_stream(GTK_MOZ_EMBED(rf->mozembed),
/* gtk_moz_embed_open_stream(GTK_MOZ_EMBED(rf->mozembed),
user_data, "text/html");
gchar *str = response->str;
gint len = strlen(response->str);
......@@ -2737,7 +2773,7 @@ finish_website (SoupSession *soup_sess, SoupMessage *msg, gpointer user_data)
gtk_moz_embed_append_data(GTK_MOZ_EMBED(rf->mozembed),
str, len);
len-=4096;
}
}*/
gtk_moz_embed_close_stream(GTK_MOZ_EMBED(rf->mozembed));
gtk_widget_show(rf->mozembed);
}
......@@ -3967,6 +4003,10 @@ free_filter_uids (gpointer user_data, GObject *ex_msg)
g_print("weak unref called on filter_uids\n");
}
#ifdef _WIN32
#include "strptime.c"
#endif
void
create_mail(create_feed *CF)
{
......@@ -4398,8 +4438,8 @@ fetch_image(gchar *url, gchar *link)
void
migrate_crc_md5(const char *name, gchar *url)
{
u_int32_t crc = gen_crc(name);
u_int32_t crc2 = gen_crc(url);
uint32_t crc = gen_crc(name);
uint32_t crc2 = gen_crc(url);
gchar *md5 = gen_md5(url);
gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
......
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