[evolution-rss] bring back feeds comments
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-rss] bring back feeds comments
- Date: Thu, 12 Mar 2015 09:23:12 +0000 (UTC)
commit 8102f579ca9efdc89ac51ae07ed30d0752e3f006
Author: Lucian Langa <lucilanga gnome org>
Date: Tue Mar 3 10:28:35 2015 +0100
bring back feeds comments
src/e-mail-formatter-evolution-rss.c | 35 +++++++++++++++++++++++++++++-
src/misc.c | 6 +++++
src/misc.h | 1 +
src/rss.c | 39 ++++++++++++++++++++--------------
src/rss.h | 11 +++++++++
5 files changed, 75 insertions(+), 17 deletions(-)
---
diff --git a/src/e-mail-formatter-evolution-rss.c b/src/e-mail-formatter-evolution-rss.c
index ece76ad..b3eb77a 100644
--- a/src/e-mail-formatter-evolution-rss.c
+++ b/src/e-mail-formatter-evolution-rss.c
@@ -36,6 +36,7 @@
#include "rss-formatter.h"
#include "e-mail-part-rss.h"
+extern gchar *commstream;
typedef EMailFormatterExtension EMailFormatterRSS;
typedef EMailFormatterExtensionClass EMailFormatterRSSClass;
@@ -116,7 +117,6 @@ emfe_evolution_rss_format (EMailFormatterExtension *extension,
gchar *feed_dir, *tmp_file, *tmp_path, *iconfile;
GdkPixbuf *pixbuf;
-
CamelContentType *ct = camel_mime_part_get_content_type (message);
if (ct) {
if (!camel_content_type_is (ct, "x-evolution", "evolution-rss-feed"))
@@ -245,6 +245,39 @@ emfe_evolution_rss_format (EMailFormatterExtension *extension,
G_MEMORY_OUTPUT_STREAM (decoded_stream));
src = rss_process_feed((gchar *)data, len);
#endif
+#if EVOLUTION_VERSION < 30304
+ GConfClient *client = gconf_client_get_default();
+#else
+ GSettings *rss_settings = g_settings_new(RSS_CONF_SCHEMA);
+#endif
+#if EVOLUTION_VERSION < 30304
+ if (comments && gconf_client_get_bool (client, GCONF_KEY_SHOW_COMMENTS, NULL)) {
+#else
+ if (comments && g_settings_get_boolean (rss_settings, CONF_SHOW_COMMENTS)) {
+#endif
+ if (commstream) {
+ gchar *result = print_comments(comments, commstream, formatter);
+ g_free(commstream);
+ if (result && strlen(result)) {
+ gchar *fstr;
+ gchar *tmp = g_strdup_printf (
+ "<div style=\"border: solid #%06x 0px; background-color:
#%06x; padding: 10px; color: #%06x;\">%s</div>",
+ frame_col & 0xffffff,
+ cont_col & 0xffffff,
+ text_col & 0xffffff,
+ result);
+ g_free(result);
+ fstr = g_strconcat(src, tmp, NULL);
+ g_free (tmp);
+ g_free (src);
+ src = fstr;
+ }
+ commstream = NULL;
+ } else {
+ gchar *uri = get_feed_url_by_feed_id(feedid);
+ fetch_comments(comments, g_strdup(uri), rss_get_display());
+ }
+ }
#if EVOLUTION_VERSION < 31191
camel_stream_write_string(stream, src, cancellable, NULL);
diff --git a/src/misc.c b/src/misc.c
index 732a6c6..2c434c7 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -168,6 +168,12 @@ strextr(gchar *text, const gchar *substr)
return string;
}
+gchar *
+get_feed_url_by_feed_id(gchar *feedid)
+{
+ return g_hash_table_lookup(rf->hr, g_strstrip(feedid));
+}
+
//prefixes uri with http:// if it's misssing
//resulting text should be freed when no longer needed
gchar *
diff --git a/src/misc.h b/src/misc.h
index 965b6f9..964c64f 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -39,6 +39,7 @@ gchar *get_url_basename(gchar *url);
gboolean is_rfc822(char *in);
gchar *extract_main_folder(gchar *folder);
gchar *strextr(gchar *text, const gchar *substr);
+gchar *get_feed_url_by_feed_id(gchar *feedid);
gchar *sanitize_url(gchar *text);
gchar *sanitize_folder(gchar *text);
void header_decode_lwsp(const char **in);
diff --git a/src/rss.c b/src/rss.c
index 73ba7e6..47ac17d 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -311,13 +311,9 @@ gboolean display_feed_async(gpointer key);
gboolean fetch_one_feed(gpointer key, gpointer value, gpointer user_data);
gboolean fetch_feed(gpointer key, gpointer value, gpointer user_data);
gboolean custom_fetch_feed(gpointer key, gpointer value, gpointer user_data);
-//void fetch_comments(gchar *url, gchar *mainurl, EMFormatHTML *stream);
-void fetch_comments(gchar *url, gchar *mainurl, EMailFormatter *stream);
guint fallback_engine(void);
-//gchar *print_comments(gchar *url, gchar *stream, EMFormatHTML *format);
-gchar *print_comments(gchar *url, gchar *stream, EMailFormatter *format);
//static void refresh_cb (GtkWidget *button, EMFormatHTMLPObject *pobject);
@@ -2551,11 +2547,15 @@ finish_comments (SoupSession *soup_sess, SoupMessage *msg, EMailFormatter *user_
g_string_free(response, 0);
if (reload && !rf->cur_format) {
+#if EVOLUTION_VERSION >= 30501
+ e_web_view_reload(user_data);
+#else
#if EVOLUTION_VERSION >= 23190
- //em_format_queue_redraw((EMFormat *)user_data);
+ em_format_queue_redraw((EMFormat *)user_data);
#else
em_format_redraw((EMFormat *)user_data);
#endif
+#endif
}
}
@@ -4541,35 +4541,42 @@ out: if (CFL->file)
NULL);
}
-gchar *update_comments(RDF *r);
+gchar *update_comments(RDF *r, EMailFormatter *format);
gchar *
-update_comments(RDF *r)
+update_comments(RDF *r, EMailFormatter *format)
{
guint i;
create_feed *CF;
xmlNodePtr el;
gchar *scomments;
GString *comments = g_string_new(NULL);
+ guint32 frame_col, cont_col, text_col;
+ frame_col = e_rgba_to_value (
+ e_mail_formatter_get_color (format, E_MAIL_FORMATTER_COLOR_FRAME));
+ cont_col = e_rgba_to_value (
+ e_mail_formatter_get_color (format, E_MAIL_FORMATTER_COLOR_CONTENT));
+ text_col = e_rgba_to_value (
+ e_mail_formatter_get_color (format, E_MAIL_FORMATTER_COLOR_TEXT));
for (i=0; NULL != (el = g_array_index(r->item, xmlNodePtr, i)); i++) {
CF = parse_channel_line(el->children, NULL, NULL, NULL);
g_string_append_printf (comments,
"<div style=\"border: solid #%06x 1px; background-color: #%06x; padding: 0px; color:
#%06x;\">",
- frame_colour & 0xffffff,
- content_colour & 0xEDECEB & 0xffffff,
- text_colour & 0xffffff);
+ frame_col & 0xffffff,
+ cont_col & 0xEDECEB & 0xffffff,
+ text_col & 0xffffff);
g_string_append_printf (comments,
"<div style=\"border: solid 0px; background-color: #%06x; padding: 2px; color:
#%06x;\">"
"<a href=%s><b>%s</b></a> on %s</div>",
- content_colour & 0xEDECEB & 0xffffff,
- text_colour & 0xffffff,
+ cont_col & 0xEDECEB & 0xffffff,
+ text_col & 0xffffff,
CF->website, CF->subj, CF->date);
g_string_append_printf (comments,
"<div style=\"border: solid #%06x 0px; background-color: #%06x; padding: 10px; color:
#%06x;\">"
"%s</div>",
- frame_colour & 0xffffff,
- content_colour & 0xffffff,
- text_colour & 0xffffff,
+ frame_col & 0xffffff,
+ cont_col & 0xffffff,
+ text_col & 0xffffff,
CF->body);
g_string_append_printf(comments, "</div> ");
free_cf(CF);
@@ -4586,7 +4593,7 @@ display_comments (RDF *r, EMailFormatter *format)
gchar *tmp;
xmlNodePtr root = xmlDocGetRootElement (r->cache);
if (tree_walk (root, r)) {
- gchar *comments = update_comments(r);
+ gchar *comments = update_comments(r, format);
tmp = process_images(comments, r->uri, TRUE, format);
g_free(comments);
if (r->maindate)
diff --git a/src/rss.h b/src/rss.h
index 7b9ff42..f31919a 100644
--- a/src/rss.h
+++ b/src/rss.h
@@ -44,6 +44,15 @@
#endif
#include <mail/em-event.h>
+#if (EVOLUTION_VERSION > 30501)
+#include <em-format/e-mail-formatter.h>
+#else
+#include <mail/em-format-html.h>
+#if EVOLUTION_VERSION >= 30400
+#include <mail/em-format-hook.h>
+#endif
+#endif
+
#ifdef HAVE_WEBKIT
#include <webkit/webkitwebview.h>
#endif
@@ -457,6 +466,8 @@ gchar *generate_safe_chn_name(gchar *chn_name);
void update_sr_message(void);
void update_progress_text(gchar *title);
void update_feed_image(RDF *r);
+void fetch_comments(gchar *url, gchar *mainurl, EMailFormatter *stream);
+gchar *print_comments(gchar *url, gchar *stream, EMailFormatter *format);
void cancel_comments_session(SoupSession *sess);
gchar *search_rss(char *buffer, int len);
void prepare_hashes(void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]