[evolution-rss] try to use feed credentials in feed comments too fallback to feed url otherwise



commit 4dd6232c7cd650cbdc968f7b5cd0b10550ec4300
Author: Lucian Langa <lucilanga gnome org>
Date:   Sun Jan 2 18:54:38 2011 +0200

    try to use feed credentials in feed comments too
    fallback to feed url otherwise

 src/network-soup.c |   16 +++++++++++++---
 src/rss.c          |   19 +++++++++++++------
 2 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/src/network-soup.c b/src/network-soup.c
index bdeb362..8419db6 100644
--- a/src/network-soup.c
+++ b/src/network-soup.c
@@ -410,7 +410,7 @@ authenticate (SoupSession *session,
 	RSS_AUTH *auth_info = g_new0(RSS_AUTH, 1);
 
 	if (msg->status_code == SOUP_STATUS_PROXY_UNAUTHORIZED) {
-		g_print("proxy:%d\n", soup_auth_is_for_proxy(auth));
+		d("proxy:%d\n", soup_auth_is_for_proxy(auth));
 	g_object_get (G_OBJECT(session),
 				"proxy-uri", &proxy_uri,
 				NULL);
@@ -585,6 +585,8 @@ net_get_unblocking(gchar *url,
 	CallbackInfo *info = NULL;
 	SoupSession *soup_sess;
 	gchar *agstr;
+	gchar *mainurl = NULL;
+	gchar **res;
 
 	soup_sess = soup_session_async_new();
 
@@ -606,12 +608,20 @@ net_get_unblocking(gchar *url,
 		info->current = 0;
 		info->total = 0;
 	}
+	/*try to find upstream url to supply a password*/
+	if (data) {
+		res = g_strsplit(data, ";COMMENT-", 0);
+		if (res[0] && g_str_has_prefix(res[0], "RSS-")) {
+			mainurl = g_strdup(res[0]+4);
+			g_strfreev(res);
+		}
+	}
 
 	g_signal_connect (soup_sess, "authenticate",
-		G_CALLBACK (authenticate), (gpointer)url);
+		G_CALLBACK (authenticate), (gpointer)mainurl?mainurl:url);
 #if LIBSOUP_VERSION < 2003000
 	g_signal_connect (soup_sess, "reauthenticate",
-		G_CALLBACK (reauthenticate), (gpointer)url);
+		G_CALLBACK (reauthenticate), (gpointer)mainurl?mainurl:url);
 #endif
 
 	/* Queue an async HTTP request */
diff --git a/src/rss.c b/src/rss.c
index 508b027..bec92d0 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -248,7 +248,7 @@ 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, EMFormatHTML *stream);
+void fetch_comments(gchar *url, gchar *mainurl, EMFormatHTML *stream);
 
 guint fallback_engine(void);
 
@@ -686,8 +686,8 @@ create_user_pass_dialog(RSS_AUTH *auth)
 	widget = gtk_label_new (NULL);
 	gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
 
-	markup = g_markup_printf_escaped (
-			_("Enter your username and password for:\n '%s'"),
+	markup = g_markup_printf_escaped ("%s '%s'\n",
+			_("Enter your username and password for:"),
 			auth->url);
 	gtk_label_set_markup (GTK_LABEL (widget), markup);
 	g_free (markup);
@@ -2528,7 +2528,9 @@ render_body:	if (category)
 				g_free(rfrclsid);
 				commstream = NULL;
 			} else {
-				fetch_comments(comments, (EMFormatHTML *)t->format);
+				gchar *uri =  g_strdup(g_hash_table_lookup(
+						rf->hr, g_strstrip(feedid)));
+				fetch_comments(comments, g_strdup(uri), (EMFormatHTML *)t->format);
 			}
 			camel_stream_printf (fstream, "</div>");
 		}
@@ -3756,14 +3758,19 @@ print_comments(gchar *url, gchar *stream, EMFormatHTML *format)
 
 
 void
-fetch_comments(gchar *url, EMFormatHTML *stream)
+fetch_comments(gchar *url, gchar *mainurl, EMFormatHTML *stream)
 {
 	GError *err = NULL;
 	SoupSession *comm_sess = NULL;
 	gchar *uniqcomm;
 
 	d("\nFetching comments from: %s\n", url);
-	uniqcomm = g_strdup_printf("COMMENT-%s", url);
+	/* we use uniqcomm to get back comment soup session*/
+	if (mainurl) {
+		uniqcomm = g_strdup_printf("RSS-%s;COMMENT-%s", mainurl, url);
+		g_free(mainurl);
+	} else
+		uniqcomm = g_strdup_printf("COMMENT-%s", url);
 
 	fetch_unblocking(
 			url,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]