[evolution-rss] fix authentication for private feeds



commit e2e4c9be6661bbd96de8b6ab33b9b4ce0fb9a620
Author: Lucian Langa <lucilanga gnome org>
Date:   Fri Jun 12 08:41:33 2009 +0300

    fix authentication for private feeds

 TODO                     |    4 +-
 src/network-soup.c       |   11 +++--
 src/rss-config-factory.c |    9 ++++
 src/rss-ui.glade         |  110 ++++++++++++++++++++++++++++------------------
 src/rss.c                |   10 ++++-
 src/rss.h                |    2 +-
 6 files changed, 95 insertions(+), 51 deletions(-)
---
diff --git a/TODO b/TODO
index 67fcc95..c6a92de 100644
--- a/TODO
+++ b/TODO
@@ -25,7 +25,7 @@
 	* add handling parser error to setup_feed (check HIG for error msg)
 	* handle slash categories
 	* use combo popup for moving and placement of feed folders
-	* trigger resync after folder rename and initial folder creation
+	* trigger resync after folder rename and initial folder creation (cmeta update!)
 	* check webbuttons for webkit
 	* cancel operation should cancel fetching feed components
 	* perhaps make quoted text fancier
@@ -34,7 +34,7 @@
 	* disable filters on setup_feed()
 	* store feed in an alternate file to serve images from
 	* migrate fetch_blocking -> fetch_unblocking
-	* grey stop button on complete load
+	* grey browser stop button on complete load
 	* grey out disabled folders (feeds)
 	* feed check runtime validation
 	* wrong send and receive count of articles after import
diff --git a/src/network-soup.c b/src/network-soup.c
index ee1a300..94adff6 100644
--- a/src/network-soup.c
+++ b/src/network-soup.c
@@ -257,10 +257,14 @@ guint
 read_up(gpointer data)
 {
 	char rfeed[512];
+	guint res = 0;
+	
+	if (NULL != g_hash_table_lookup(rf->hruser, data))
+		return 1;
+
 	gchar *tmp = gen_md5(data);
 	gchar *buf = g_strconcat(tmp, ".rec", NULL);
 	g_free(tmp);
-	guint res = 0;
 
 	gchar *feed_dir = rss_component_peek_base_directory(mail_component_peek());
 	if (!g_file_test(feed_dir, G_FILE_TEST_EXISTS))
@@ -349,7 +353,6 @@ authenticate (SoupSession *session,
 	gpointer data)
 #endif
 {
-
 	if (msg->status_code == SOUP_STATUS_PROXY_UNAUTHORIZED) {
 		g_print("proxy:%d\n", soup_auth_is_for_proxy(auth));
 	SoupURI *proxy_uri;
@@ -601,10 +604,10 @@ net_post_blocking(gchar *url, GSList *headers, GString *post,
 
 
 	g_signal_connect (soup_sess, "authenticate",
-            G_CALLBACK (authenticate), soup_sess);
+            G_CALLBACK (authenticate), (gpointer)url);
 #if LIBSOUP_VERSION < 2003000
 	g_signal_connect (soup_sess, "reauthenticate",
-            G_CALLBACK (reauthenticate), soup_sess);
+            G_CALLBACK (reauthenticate), (gpointer)url);
 #endif
 
 	req = soup_message_new(SOUP_METHOD_GET, url);
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index 65a4dc7..3252a6e 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -492,6 +492,15 @@ build_dialog_add(gchar *url, gchar *feed_text)
 		break;
 	}
 
+	GtkWidget *authuser = (GtkWidget *)glade_xml_get_widget (gui, "auth_user");
+	GtkWidget *authpass = (GtkWidget *)glade_xml_get_widget (gui, "auth_pass");
+
+	if (url) {
+		read_up(url);
+		gtk_entry_set_text(GTK_ENTRY(authuser), g_hash_table_lookup(rf->hruser, url));
+		gtk_entry_set_text(GTK_ENTRY(authpass), g_hash_table_lookup(rf->hrpass, url));
+	}
+
 	GtkWidget *ok = (GtkWidget *)glade_xml_get_widget (gui, "ok_button");
 	gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), ok, GTK_RESPONSE_OK);
 	GTK_WIDGET_SET_FLAGS (ok, GTK_CAN_DEFAULT);
diff --git a/src/rss-ui.glade b/src/rss-ui.glade
index 8752210..942fc1f 100644
--- a/src/rss-ui.glade
+++ b/src/rss-ui.glade
@@ -948,8 +948,8 @@
     <property name="destroy_with_parent">True</property>
     <property name="type_hint">dialog</property>
     <property name="local_only">False</property>
-    <property name="show_hidden">True</property>
     <property name="action">save</property>
+    <property name="show_hidden">True</property>
     <child internal-child="vbox">
       <widget class="GtkVBox" id="vbox26">
         <property name="visible">True</property>
@@ -1475,60 +1475,84 @@ days</property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkTable" id="table4">
+                          <widget class="GtkVBox" id="vbox3">
                             <property name="visible">True</property>
-                            <property name="border_width">15</property>
-                            <property name="n_rows">2</property>
-                            <property name="n_columns">2</property>
-                            <child>
-                              <widget class="GtkLabel" id="label189">
-                                <property name="visible">True</property>
-                                <property name="xalign">0</property>
-                                <property name="label" translatable="yes">Username:</property>
-                              </widget>
-                              <packing>
-                                <property name="x_options"></property>
-                                <property name="y_options"></property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkLabel" id="label190">
-                                <property name="visible">True</property>
-                                <property name="xalign">0</property>
-                                <property name="label" translatable="yes">Password: </property>
-                              </widget>
-                              <packing>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                                <property name="x_options"></property>
-                                <property name="y_options"></property>
-                              </packing>
-                            </child>
+                            <property name="orientation">vertical</property>
                             <child>
-                              <widget class="GtkEntry" id="proxy_user">
+                              <widget class="GtkCheckButton" id="proxy_auth">
+                                <property name="label" translatable="yes">Use authentication</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
-                                <property name="invisible_char">&#x25CF;</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
                               </widget>
                               <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="y_options"></property>
+                                <property name="fill">False</property>
+                                <property name="padding">2</property>
+                                <property name="position">0</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkEntry" id="proxy_pass">
+                              <widget class="GtkTable" id="table4">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="visibility">False</property>
-                                <property name="invisible_char">&#x25CF;</property>
+                                <property name="border_width">15</property>
+                                <property name="n_rows">2</property>
+                                <property name="n_columns">2</property>
+                                <child>
+                                  <widget class="GtkLabel" id="label189">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Username:</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="x_options"></property>
+                                    <property name="y_options"></property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkEntry" id="auth_user">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="invisible_char">&#x25CF;</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="y_options"></property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkEntry" id="auth_pass">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="visibility">False</property>
+                                    <property name="invisible_char">&#x25CF;</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="y_options"></property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkLabel" id="label190">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Password: </property>
+                                  </widget>
+                                  <packing>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options"></property>
+                                    <property name="y_options"></property>
+                                  </packing>
+                                </child>
                               </widget>
                               <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                                <property name="y_options"></property>
+                                <property name="position">1</property>
                               </packing>
                             </child>
                           </widget>
diff --git a/src/rss.c b/src/rss.c
index 244c41c..f8a124b 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -654,6 +654,8 @@ create_user_pass_dialog(RSS_AUTH *auth)
                 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
 	if (auth->user)
 		gtk_entry_set_text (GTK_ENTRY (username), auth->user);
+	auth->username = username;
+
 
         widget = gtk_label_new (NULL);
         gtk_label_set_markup (GTK_LABEL (widget), _("Password: "));
@@ -674,6 +676,7 @@ create_user_pass_dialog(RSS_AUTH *auth)
                 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
 	if (auth->pass)
 		gtk_entry_set_text (GTK_ENTRY (password), auth->pass);
+	auth->password = password;
 
         /* Caps Lock Label */
         widget = gtk_label_new (NULL);
@@ -700,7 +703,7 @@ create_user_pass_dialog(RSS_AUTH *auth)
     //            if (msg->flags & E_PASSWORDS_DISABLE_REMEMBER)
        //                 gtk_widget_set_sensitive (widget, FALSE);
 	gtk_widget_show (checkbutton1);
-      //          msg->check = widget;
+	auth->rememberpass = checkbutton1;
 
 	gtk_table_attach (
                         GTK_TABLE (container), checkbutton1,
@@ -723,18 +726,23 @@ web_auth_dialog(gchar *url)
 	RSS_AUTH *auth_info = g_new0(RSS_AUTH, 1);
 	auth_info->user = g_hash_table_lookup(rf->hruser, url);
 	auth_info->pass = g_hash_table_lookup(rf->hruser, url);
+	auth_info->url = url;
 	dialog = create_user_pass_dialog(auth_info);
 	gint result = gtk_dialog_run(GTK_DIALOG(dialog));
 	switch (result) {
 	case GTK_RESPONSE_OK:
         	if (auth_info->user)
         	    g_hash_table_remove(rf->hruser, url);
+
         	g_hash_table_insert(rf->hruser, url, 
 			g_strdup(gtk_entry_get_text (GTK_ENTRY (auth_info->username))));
+
         	if (auth_info->pass)
             		g_hash_table_remove(rf->hrpass, url);
+
         	g_hash_table_insert(rf->hrpass, url, 
 			g_strdup(gtk_entry_get_text (GTK_ENTRY (auth_info->password))));
+
 		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (auth_info->rememberpass)))
 			save_up(url);
 		else
diff --git a/src/rss.h b/src/rss.h
index 87fba66..618e69b 100644
--- a/src/rss.h
+++ b/src/rss.h
@@ -99,7 +99,7 @@ typedef struct _rssfeed {
         GHashTable      *hrt;   		//feeds name hash
         GHashTable      *hrh;   		//fetch html flag
         GHashTable      *hruser;   		//auth user hash
-        GHashTable      *hrpass;   		//auth user hash
+        GHashTable      *hrpass;   		//auth pass hash
 	gboolean	soup_auth_retry;	//wether to retry auth after an unsucessful auth
         GHashTable      *hrdel_feed;   		//option to delete messages in current feed
         GHashTable      *hrdel_days;   		//option to delete messages older then days



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