[evolution-rss] add option to limit max enclosures size



commit af7c141fcd39b403e990de6bbbe0a9329e3a57b8
Author: Lucian Langa <lucilanga gnome org>
Date:   Sun Jan 16 00:29:21 2011 +0200

    add option to limit max enclosures size

 src/evolution-rss.schemas.in.in |   46 ++++-
 src/network-soup.c              |    8 +-
 src/network-soup.h              |    2 +-
 src/parser.c                    |   33 ++--
 src/rss-config-factory.c        |   91 ++++++++-
 src/rss-main.ui                 |  445 +++++++++++++++++++++++++++++++++++----
 src/rss.c                       |   48 ++++-
 src/rss.h                       |    4 +
 8 files changed, 601 insertions(+), 76 deletions(-)
---
diff --git a/src/evolution-rss.schemas.in.in b/src/evolution-rss.schemas.in.in
index 8ad8f3c..cef852d 100644
--- a/src/evolution-rss.schemas.in.in
+++ b/src/evolution-rss.schemas.in.in
@@ -185,7 +185,7 @@
 	</locale>
     </schema>
 
-    <schema>
+<schema>
 	<key>/schemas/apps/evolution/evolution-rss/search_rss</key>
 	<applyto>/apps/evolution/evolution-rss/search_rss</applyto>
 	<owner>evolution-rss</owner>
@@ -197,7 +197,49 @@
 			Evolution RSS will scan web pages for rss content
 		</long>
 	</locale>
-    </schema>
+</schema>
+
+<schema>
+	<key>/schemas/apps/evolution/evolution-rss/download_enclosures</key>
+	<applyto>/apps/evolution/evolution-rss/download_enclosures</applyto>
+	<owner>evolution-rss</owner>
+	<type>bool</type>
+	<default>true</default>
+	<locale name="C">
+		<short>Download enclosures</short>
+		<long>
+			Evolution will download all feed enclosures a feed article may contain.
+		</long>
+	</locale>
+</schema>
+
+<schema>
+	<key>/schemas/apps/evolution/evolution-rss/enclosure_limit</key>
+	<applyto>/apps/evolution/evolution-rss/enclosure_limit</applyto>
+	<owner>evolution-rss</owner>
+	<type>bool</type>
+	<default>false</default>
+	<locale name="C">
+		<short>Limit enclosure size</short>
+		<long>
+			Limit maximum enclosure size evolution will download.
+		</long>
+	</locale>
+</schema>
+
+<schema>
+	<key>/schemas/apps/evolution/evolution-rss/enclosure_size</key>
+	<applyto>/apps/evolution/evolution-rss/enclosure_size</applyto>
+	<owner>evolution-rss</owner>
+	<type>float</type>
+	<default>1024</default>
+	<locale name="C">
+		<short>Max enclosure size</short>
+		<long>
+			Limit maximum enclosure size evolution will download.
+		</long>
+	</locale>
+</schema>
 
     <schema>
       <key>/schemas/apps/evolution/evolution-rss/status_icon</key>
diff --git a/src/network-soup.c b/src/network-soup.c
index 8419db6..7498f00 100644
--- a/src/network-soup.c
+++ b/src/network-soup.c
@@ -667,7 +667,6 @@ net_get_unblocking(gchar *url,
 	return TRUE;
 }
 
-
 // same stuff as net_get_* but without accumulating headers
 // push all donwloads to a customizable length queue
 gboolean
@@ -754,7 +753,8 @@ download_unblocking(
 	stnet->cbdata2 = cbdata2;
 	stnet->url = g_strdup(url);
 	g_queue_push_tail (rf->stqueue, stnet);
-	rf->enclist = g_list_append (rf->enclist, g_strdup(url));
+	rf->enclist = g_list_append (rf->enclist, url);
+
 	if (!net_qid)
 		net_qid = g_idle_add((GSourceFunc)net_queue_dispatcher, NULL);
 
@@ -909,7 +909,7 @@ out:
 }
 
 gboolean
-cancel_soup_sess(gpointer key, gpointer value, gpointer user_data)
+abort_soup_sess(gpointer key, gpointer value, gpointer user_data)
 {
 	if (key && SOUP_IS_SESSION(key)) {
 		soup_session_abort(key);
@@ -938,7 +938,7 @@ abort_all_soup(void)
 		g_hash_table_foreach(rf->abort_session, remove_weak, NULL);
 		if (g_hash_table_size(rf->abort_session))
 			g_hash_table_foreach_remove(
-				rf->abort_session, cancel_soup_sess, NULL);
+				rf->abort_session, abort_soup_sess, NULL);
 		g_hash_table_destroy(rf->session);
 		rf->session = g_hash_table_new(
 				g_direct_hash, g_direct_equal);
diff --git a/src/network-soup.h b/src/network-soup.h
index 09df863..d64d963 100644
--- a/src/network-soup.h
+++ b/src/network-soup.h
@@ -24,7 +24,7 @@
 #endif
 
 void abort_all_soup(void);
-gboolean cancel_soup_sess(
+gboolean abort_soup_sess(
 	gpointer key,
 	gpointer value,
 	gpointer user_data);
diff --git a/src/parser.c b/src/parser.c
index 20efad5..90c3827 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -44,6 +44,8 @@ extern int rss_verbose_debug;
 #include "misc.h"
 #include "network-soup.h"
 
+extern GConfClient *rss_gconf;
+
 /************ RDF Parser *******************/
 
 guint rsserror = FALSE;
@@ -1255,21 +1257,26 @@ update_channel(RDF *r)
 			gtk_main_iteration ();
 
 		ftotal++;
-		if (CF->encl) {
-			process_enclosure(CF);
-		} else if (g_list_length(CF->attachments)) {
-			process_attachments(CF);
-		} else {
-			if (!freeze) {
-				camel_folder_freeze(mail_folder);
-				freeze = TRUE;
+		if (gconf_client_get_bool(rss_gconf, GCONF_KEY_DOWNLOAD_ENCLOSURES, NULL)) {
+			if (CF->encl) {
+				process_enclosure(CF);
+				goto done;
+			} else if (g_list_length(CF->attachments)) {
+				process_attachments(CF);
+				goto done;
 			}
-			create_mail(CF);
-			write_feed_status_line(
-				CF->feed_fname, CF->feed_uri);
-			free_cf(CF);
 		}
-		farticle++;
+
+		if (!freeze) {
+			camel_folder_freeze(mail_folder);
+			freeze = TRUE;
+		}
+		create_mail(CF);
+		write_feed_status_line(
+			CF->feed_fname, CF->feed_uri);
+		free_cf(CF);
+
+done:		farticle++;
 		d("put success()\n");
 		update_status_icon(chn_name, subj);
 		g_free(subj);
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index d429b90..ea6e8ff 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -110,8 +110,11 @@ typedef struct _setupfeed {
 		*check2,
 		*check3,
 		*check4,
-		*check5;
+		*check5,
+		*check6,
+		*check7;
 	GtkWidget *spin;
+	GtkWidget *enclsize;
 	GtkWidget *use_proxy;
 	GtkWidget *host_proxy;
 	GtkWidget *port_proxy;
@@ -261,7 +264,7 @@ rep_check_cb (GtkWidget *widget, gpointer data)
 	//if we already have a timeout set destroy it first
 	if (rf->rc_id && !active)
 		g_source_remove(rf->rc_id);
-		if (active) {
+	if (active) {
 			gtk_spin_button_update((GtkSpinButton *)data);
 			//we have to make sure we have a timeout value
 			if (!gconf_client_get_float(rss_gconf, GCONF_KEY_REP_CHECK_TIMEOUT, NULL))
@@ -275,7 +278,36 @@ rep_check_cb (GtkWidget *widget, gpointer data)
 				60 * 1000 * gtk_spin_button_get_value((GtkSpinButton *)data),
 				(GSourceFunc) update_articles,
 				(gpointer)1);
-		}
+	}
+}
+
+static void
+enclosure_limit_cb (GtkWidget *widget, gpointer data)
+{
+	gboolean active =
+		gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+	/* Save the new setting to gconf */
+	gconf_client_set_bool (rss_gconf,
+		GCONF_KEY_ENCLOSURE_LIMIT,
+		active,
+		NULL);
+	if (active) {
+		//we have to make sure we have a timeout value
+		if (!gconf_client_get_float(rss_gconf, GCONF_KEY_ENCLOSURE_SIZE, NULL))
+				gconf_client_set_float (rss_gconf,
+					GCONF_KEY_ENCLOSURE_SIZE,
+					gtk_spin_button_get_value((GtkSpinButton *)data),
+					NULL);
+	}
+}
+
+static void
+enclosure_size_cb (GtkWidget *widget, gpointer data)
+{
+	gconf_client_set_float (rss_gconf,
+		GCONF_KEY_ENCLOSURE_SIZE,
+		gtk_spin_button_get_value((GtkSpinButton*)widget),
+		NULL);
 }
 
 static void
@@ -3547,6 +3579,7 @@ rss_config_control_new (void)
 {
 	GtkWidget *control_widget;
 	GtkWidget *button1, *button2, *button3;
+	GtkWidget *tmpwidget;
 	gchar *uifile;
 	setupfeed *sf;
 	GtkListStore  *store;
@@ -3555,7 +3588,7 @@ rss_config_control_new (void)
 	GtkTreeView *treeview;
 	GtkTreeSelection *selection;
 	GtkTreeViewColumn *column;
-	gdouble adj;
+	gdouble adj, size;
 	GError* error = NULL;
 
 	d("rf->%p\n", rf);
@@ -3719,7 +3752,17 @@ rss_config_control_new (void)
 			gtk_builder_get_object(
 				sf->gui,
 				"checkbutton5"));
+	sf->check6 = GTK_WIDGET (
+			gtk_builder_get_object(
+				sf->gui,
+				"checkbuttonS6"));
+	sf->check7 = GTK_WIDGET (
+			gtk_builder_get_object(
+				sf->gui,
+				"checkbutton9"));
 	sf->spin = GTK_WIDGET (gtk_builder_get_object(sf->gui, "spinbutton1"));
+	sf->enclsize = GTK_WIDGET (gtk_builder_get_object(sf->gui, "adjustment6"));
+	tmpwidget = GTK_WIDGET (gtk_builder_get_object(sf->gui, "spinbutton2"));
 
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sf->check1),
 		gconf_client_get_bool(rss_gconf, GCONF_KEY_REP_CHECK, NULL));
@@ -3742,6 +3785,26 @@ rss_config_control_new (void)
 		"value-changed",
 		G_CALLBACK(rep_check_timeout_cb),
 		sf->check1);
+
+	size = gconf_client_get_float(rss_gconf, GCONF_KEY_ENCLOSURE_SIZE, NULL);
+	if (size)
+		gtk_spin_button_set_value((GtkSpinButton *)tmpwidget, size);
+	g_signal_connect(
+		sf->check7,
+		"clicked",
+		G_CALLBACK(enclosure_limit_cb),
+		sf->enclsize);
+	g_signal_connect(
+		tmpwidget,
+		"changed",
+		G_CALLBACK(enclosure_size_cb),
+		sf->check7);
+	g_signal_connect(
+		tmpwidget,
+		"value-changed",
+		G_CALLBACK(enclosure_size_cb),
+		sf->check7);
+
 	gtk_toggle_button_set_active (
 		GTK_TOGGLE_BUTTON (sf->check2),
 		gconf_client_get_bool(
@@ -3782,6 +3845,26 @@ rss_config_control_new (void)
 		"clicked",
 		G_CALLBACK(start_check_cb),
 		(gpointer)GCONF_KEY_SEARCH_RSS);
+	gtk_toggle_button_set_active (
+		GTK_TOGGLE_BUTTON (sf->check6),
+		gconf_client_get_bool(
+			rss_gconf,
+			GCONF_KEY_DOWNLOAD_ENCLOSURES,
+			NULL));
+	g_signal_connect(sf->check6,
+		"clicked",
+		G_CALLBACK(start_check_cb),
+		(gpointer)GCONF_KEY_DOWNLOAD_ENCLOSURES);
+	gtk_toggle_button_set_active (
+		GTK_TOGGLE_BUTTON (sf->check7),
+		gconf_client_get_bool(
+			rss_gconf,
+			GCONF_KEY_ENCLOSURE_LIMIT,
+			NULL));
+	g_signal_connect(sf->check7,
+		"clicked",
+		G_CALLBACK(start_check_cb),
+		(gpointer)GCONF_KEY_ENCLOSURE_LIMIT);
 
 	sf->import = GTK_WIDGET (gtk_builder_get_object(sf->gui, "import"));
 	sf->export = GTK_WIDGET (gtk_builder_get_object(sf->gui, "export"));
diff --git a/src/rss-main.ui b/src/rss-main.ui
index 1b0d8be..5ee958c 100644
--- a/src/rss-main.ui
+++ b/src/rss-main.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <!-- interface-requires gtk+ 2.12 -->
+  <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkImage" id="image_imp">
     <property name="visible">True</property>
@@ -128,6 +128,7 @@
                               </object>
                               <packing>
                                 <property name="expand">False</property>
+                                <property name="fill">True</property>
                                 <property name="position">0</property>
                               </packing>
                             </child>
@@ -139,6 +140,8 @@
                                 <property name="single_line_mode">True</property>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">1</property>
                               </packing>
                             </child>
@@ -203,6 +206,7 @@
                               </object>
                               <packing>
                                 <property name="expand">False</property>
+                                <property name="fill">True</property>
                                 <property name="position">0</property>
                               </packing>
                             </child>
@@ -217,6 +221,7 @@
                               </object>
                               <packing>
                                 <property name="expand">False</property>
+                                <property name="fill">True</property>
                                 <property name="position">1</property>
                               </packing>
                             </child>
@@ -231,6 +236,7 @@
                               </object>
                               <packing>
                                 <property name="expand">False</property>
+                                <property name="fill">True</property>
                                 <property name="position">2</property>
                               </packing>
                             </child>
@@ -261,6 +267,7 @@
                               </object>
                               <packing>
                                 <property name="expand">False</property>
+                                <property name="fill">True</property>
                                 <property name="position">0</property>
                               </packing>
                             </child>
@@ -279,6 +286,7 @@
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
+                                    <property name="fill">True</property>
                                     <property name="position">0</property>
                                   </packing>
                                 </child>
@@ -292,6 +300,7 @@
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
+                                    <property name="fill">True</property>
                                     <property name="position">1</property>
                                   </packing>
                                 </child>
@@ -309,12 +318,14 @@
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
+                                    <property name="fill">True</property>
                                     <property name="position">2</property>
                                   </packing>
                                 </child>
                               </object>
                               <packing>
                                 <property name="expand">False</property>
+                                <property name="fill">True</property>
                                 <property name="position">1</property>
                               </packing>
                             </child>
@@ -330,6 +341,7 @@
                               </object>
                               <packing>
                                 <property name="expand">False</property>
+                                <property name="fill">True</property>
                                 <property name="position">2</property>
                               </packing>
                             </child>
@@ -363,6 +375,8 @@
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">0</property>
                               </packing>
                             </child>
@@ -382,6 +396,7 @@
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
+                                    <property name="fill">True</property>
                                     <property name="position">0</property>
                                   </packing>
                                 </child>
@@ -395,6 +410,7 @@
                                   </object>
                                   <packing>
                                     <property name="expand">False</property>
+                                    <property name="fill">True</property>
                                     <property name="position">1</property>
                                   </packing>
                                 </child>
@@ -475,6 +491,8 @@
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">3</property>
                               </packing>
                             </child>
@@ -488,6 +506,8 @@
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">4</property>
                               </packing>
                             </child>
@@ -519,6 +539,7 @@
                                 <property name="draw_indicator">True</property>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
                                 <property name="fill">False</property>
                                 <property name="padding">2</property>
                                 <property name="position">0</property>
@@ -583,6 +604,8 @@
                                 </child>
                               </object>
                               <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
                                 <property name="position">1</property>
                               </packing>
                             </child>
@@ -614,6 +637,8 @@
                 </child>
               </object>
               <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
                 <property name="position">1</property>
               </packing>
             </child>
@@ -637,6 +662,7 @@
           </object>
           <packing>
             <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="pack_type">end</property>
             <property name="position">0</property>
           </packing>
@@ -696,6 +722,7 @@
           </object>
           <packing>
             <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="pack_type">end</property>
             <property name="position">0</property>
           </packing>
@@ -722,6 +749,7 @@
                 <property name="label" translatable="yes">label92</property>
               </object>
               <packing>
+                <property name="expand">True</property>
                 <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
@@ -743,6 +771,8 @@
             </child>
           </object>
           <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
             <property name="position">2</property>
           </packing>
         </child>
@@ -783,6 +813,7 @@
           </object>
           <packing>
             <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="pack_type">end</property>
             <property name="position">0</property>
           </packing>
@@ -843,6 +874,7 @@
           </object>
           <packing>
             <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="pack_type">end</property>
             <property name="position">0</property>
           </packing>
@@ -937,11 +969,15 @@
                 </child>
               </object>
               <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
                 <property name="position">1</property>
               </packing>
             </child>
           </object>
           <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
             <property name="position">2</property>
           </packing>
         </child>
@@ -982,6 +1018,7 @@
           </object>
           <packing>
             <property name="expand">False</property>
+            <property name="fill">True</property>
             <property name="pack_type">end</property>
             <property name="position">0</property>
           </packing>
@@ -1028,6 +1065,8 @@
                     </child>
                   </object>
                   <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
                     <property name="position">0</property>
                   </packing>
                 </child>
@@ -1184,11 +1223,14 @@
                   </object>
                   <packing>
                     <property name="expand">False</property>
+                    <property name="fill">True</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
               </object>
               <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -1246,6 +1288,7 @@
                       </object>
                       <packing>
                         <property name="expand">False</property>
+                        <property name="fill">True</property>
                         <property name="position">0</property>
                       </packing>
                     </child>
@@ -1269,6 +1312,7 @@
                       </object>
                       <packing>
                         <property name="expand">False</property>
+                        <property name="fill">True</property>
                         <property name="position">1</property>
                       </packing>
                     </child>
@@ -1298,11 +1342,15 @@
                     </child>
                   </object>
                   <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
               </object>
               <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -1321,40 +1369,38 @@
           </packing>
         </child>
         <child>
-          <object class="GtkVBox" id="vbox12">
+          <object class="GtkVBox" id="vbox_SETUP">
             <property name="visible">True</property>
             <property name="border_width">12</property>
             <property name="spacing">12</property>
             <child>
-              <object class="GtkVBox" id="vbox13">
+              <object class="GtkVBox" id="vboxS1">
                 <property name="visible">True</property>
-                <property name="spacing">6</property>
+                <property name="spacing">12</property>
                 <child>
-                  <object class="GtkLabel" id="label80">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;span weight="bold"&gt;Settings&lt;/span&gt;</property>
-                    <property name="use_markup">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkVBox" id="vbox14">
+                  <object class="GtkVBox" id="vboxS2">
                     <property name="visible">True</property>
                     <child>
-                      <object class="GtkHBox" id="hbox15">
+                      <object class="GtkLabel" id="label80">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="yalign">0</property>
+                        <property name="label" translatable="yes">&lt;span weight="bold"&gt;Start up&lt;/span&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="hboxS1">
                         <property name="visible">True</property>
+                        <property name="spacing">12</property>
                         <child>
-                          <object class="GtkCheckButton" id="checkbutton1">
-                            <property name="label" translatable="yes">Check for new articles every</property>
+                          <object class="GtkLabel" id="label1">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_underline">True</property>
-                            <property name="draw_indicator">True</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
@@ -1363,29 +1409,141 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkSpinButton" id="spinbutton1">
+                          <object class="GtkHBox" id="hbox15">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="adjustment">adjustment5</property>
-                            <property name="climb_rate">1</property>
-                            <property name="numeric">True</property>
+                            <property name="spacing">4</property>
+                            <child>
+                              <object class="GtkCheckButton" id="checkbutton1">
+                                <property name="label" translatable="yes">Check for new articles every</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="spinbutton1">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">â??</property>
+                                <property name="invisible_char_set">True</property>
+                                <property name="adjustment">adjustment5</property>
+                                <property name="climb_rate">1</property>
+                                <property name="numeric">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label78">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes" comments="to translators: label part of Check for new articles every X minutes&quot; message">minutes</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
+                            <property name="fill">False</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="hboxS4">
+                        <property name="visible">True</property>
+                        <property name="spacing">12</property>
                         <child>
-                          <object class="GtkLabel" id="label78">
+                          <object class="GtkLabel" id="label4">
                             <property name="visible">True</property>
-                            <property name="label" translatable="yes" comments="to translators: label part of Check for new articles every X minutes&quot; message">minutes</property>
                           </object>
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">False</property>
-                            <property name="position">2</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkCheckButton" id="checkbutton2">
+                            <property name="label" translatable="yes">Check for new articles at startup</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vbox5">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkLabel" id="label7">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="yalign">0</property>
+                    <property name="label" translatable="yes">&lt;span weight="bold"&gt;Feed display&lt;/span&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hboxS7">
+                    <property name="visible">True</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <object class="GtkLabel" id="label8">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="yalign">0</property>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -1394,8 +1552,8 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkCheckButton" id="checkbutton2">
-                        <property name="label" translatable="yes">Check for new articles at startup</property>
+                      <object class="GtkCheckButton" id="checkbutton3">
+                        <property name="label" translatable="yes">By default show article summary instead of webpage</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
@@ -1408,19 +1566,86 @@
                         <property name="position">1</property>
                       </packing>
                     </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hbox3">
+                    <property name="visible">True</property>
+                    <property name="spacing">12</property>
                     <child>
-                      <object class="GtkCheckButton" id="checkbutton3">
-                        <property name="label" translatable="yes">By default show article summary instead of webpage</property>
+                      <object class="GtkLabel" id="label3">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="yalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="checkbutton5">
+                        <property name="label" translatable="yes">Scan for feed inside webpages</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
                       </object>
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
-                        <property name="position">2</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="vboxS3">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkLabel" id="label5">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="yalign">0</property>
+                    <property name="label" translatable="yes">&lt;span weight="bold"&gt;Feed enclosures&lt;/span&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hbox5">
+                    <property name="visible">True</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <object class="GtkLabel" id="label6">
+                        <property name="visible">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
                       </packing>
                     </child>
                     <child>
@@ -1434,31 +1659,155 @@
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
-                        <property name="position">3</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hboxS2">
+                    <property name="visible">True</property>
+                    <property name="spacing">12</property>
                     <child>
-                      <object class="GtkCheckButton" id="checkbutton5">
-                        <property name="label" translatable="yes">Scan for feed inside webpages</property>
+                      <object class="GtkLabel" id="labelS2">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="yalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="checkbuttonS6">
+                        <property name="label" translatable="yes">Download feed enclosures</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
+                        <property name="use_action_appearance">False</property>
                         <property name="draw_indicator">True</property>
                       </object>
                       <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hboxS8">
+                    <property name="visible">True</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <object class="GtkLabel" id="labelS9">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="yalign">0</property>
+                      </object>
+                      <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
-                        <property name="position">4</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="hboxS11">
+                        <property name="visible">True</property>
+                        <property name="spacing">12</property>
+                        <child>
+                          <object class="GtkLabel" id="labelS10">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="yalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkHBox" id="hboxS12">
+                            <property name="visible">True</property>
+                            <property name="spacing">4</property>
+                            <child>
+                              <object class="GtkCheckButton" id="checkbutton9">
+                                <property name="label" translatable="yes">Do not download enclosures that exceeds</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkSpinButton" id="spinbutton2">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">â??</property>
+                                <property name="adjustment">adjustment6</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="labelS11">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">KB</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="position">1</property>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">3</property>
                   </packing>
                 </child>
               </object>
               <packing>
-                <property name="position">0</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
@@ -1605,12 +1954,15 @@
                     </child>
                   </object>
                   <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
               </object>
               <packing>
                 <property name="expand">False</property>
+                <property name="fill">True</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -1648,4 +2000,9 @@
       </row>
     </data>
   </object>
+  <object class="GtkAdjustment" id="adjustment6">
+    <property name="upper">100000</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
 </interface>
diff --git a/src/rss.c b/src/rss.c
index bec92d0..828bc6d 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -306,12 +306,24 @@ void error_response(GtkObject *o, int button, void *data)
 
 
 void
+abort_active_op(gpointer key)
+{
+	gpointer key_session = g_hash_table_lookup(rf->key_session, key);
+	gpointer value = g_hash_table_lookup(rf->session, key_session);
+	if (value) {
+		abort_soup_sess(key_session, value, NULL);
+	}
+}
+
+void
 cancel_active_op(gpointer key)
 {
 	gpointer key_session = g_hash_table_lookup(rf->key_session, key);
 	gpointer value = g_hash_table_lookup(rf->session, key_session);
-	if (value)
-		cancel_soup_sess(key_session, value, NULL);
+	if (value) {
+		soup_session_cancel_message (key_session, value,
+			SOUP_STATUS_CANCELLED);
+	}
 }
 
 static void
@@ -562,6 +574,12 @@ download_chunk(
 	case NET_STATUS_PROGRESS:
 		progress = (NetStatusProgress*)statusdata;
 		if (progress->current > 0 && progress->total > 0) {
+			guint encl_max_size = (gint)gconf_client_get_float(
+				rss_gconf, GCONF_KEY_ENCLOSURE_SIZE, NULL);
+			if (progress->total > encl_max_size * 1024) { //TOLERANCE!!!
+				cancel_active_op((gpointer)data);
+				return;
+			}
 			//fraction = (float)progress->current / progress->total;
 			fwrite(progress->chunk, 1, progress->chunksize, (FILE *)data);
 		}
@@ -5322,6 +5340,7 @@ free_cf(create_feed *CF)
 
 typedef struct CFL {
 	gchar *url;
+	gchar *name;
 	FILE *file;
 	create_feed *CF;
 } cfl;
@@ -5364,9 +5383,10 @@ process_attachments(create_feed *CF)
 		CFL = g_new0(cfl, 1);
 		CFL->url = l->data;
 		CFL->CF = CF;
-		d("enclosure file:%s\n", name)
+		d("attachment file:%s\n", name)
 		CF->attachedfiles = g_list_append(CF->attachedfiles, name);
 		CF->attachmentsqueue++;
+		CFL->name = name;
 		CFL->file = fopen(name, "w");
 		if (!CFL->file) return;
 		download_unblocking(
@@ -5375,7 +5395,7 @@ process_attachments(create_feed *CF)
 			CFL->file,
 			(gpointer)finish_attachment,
 			CFL,
-			0,
+			1,
 			NULL);
 	} while ((l = l->next));
 }
@@ -5393,6 +5413,13 @@ finish_attachment (SoupSession *soup_sess,
 		cfl *user_data)
 #endif
 {
+	if (msg->status_code == SOUP_STATUS_CANCELLED) {
+		user_data->CF->attachedfiles =
+			g_list_remove(user_data->CF->attachedfiles,
+				user_data->name);
+		goto out;
+	}
+
 #if LIBSOUP_VERSION < 2003000
 	fwrite(msg->response.body,
 		msg->response.length,
@@ -5404,7 +5431,7 @@ finish_attachment (SoupSession *soup_sess,
 		1,
 		user_data->file);
 #endif
-	fclose(user_data->file);
+out:	fclose(user_data->file);
 
 	rf->enclist = g_list_remove(rf->enclist, user_data->url);
 	//g_free(msg->response_body->data);
@@ -5436,8 +5463,9 @@ process_enclosure(create_feed *CF)
 	gchar *tmpdir, *name;
 
 	if (g_list_find_custom(rf->enclist, CF->encl,
-			(GCompareFunc)strcmp))
+			(GCompareFunc)strcmp)) {
 		return;
+	}
 	tmpdir = e_mkdtemp("evo-rss-XXXXXX");
 	if ( tmpdir == NULL)
 		return;
@@ -5456,7 +5484,7 @@ process_enclosure(create_feed *CF)
 		CF->efile,
 		(gpointer)finish_enclosure,
 		CF,
-		0,
+		1,
 		NULL);
 }
 
@@ -5470,6 +5498,10 @@ finish_enclosure (SoupSession *soup_sess,
 		create_feed *user_data)
 #endif
 {
+	if (msg->status_code == SOUP_STATUS_CANCELLED) {
+		user_data->encl = NULL;
+		goto out;
+	}
 #if LIBSOUP_VERSION < 2003000
 	fwrite(msg->response.body,
 		msg->response.length,
@@ -5481,7 +5513,7 @@ finish_enclosure (SoupSession *soup_sess,
 		1,
 		user_data->efile);
 #endif
-	fclose(user_data->efile);
+out:	fclose(user_data->efile);
 
 	if (!feed_is_new(user_data->feed_fname, user_data->feed_uri)) {
 		create_mail(user_data);
diff --git a/src/rss.h b/src/rss.h
index 5a510d1..64c62f2 100644
--- a/src/rss.h
+++ b/src/rss.h
@@ -185,6 +185,9 @@ typedef struct _rssfeed {
 #define GCONF_KEY_REP_CHECK "/apps/evolution/evolution-rss/rep_check"
 #define GCONF_KEY_REP_CHECK_TIMEOUT "/apps/evolution/evolution-rss/rep_check_timeout"
 #define GCONF_KEY_SHOW_COMMENTS "/apps/evolution/evolution-rss/show_comments"
+#define GCONF_KEY_DOWNLOAD_ENCLOSURES "/apps/evolution/evolution-rss/download_enclosures"
+#define GCONF_KEY_ENCLOSURE_LIMIT "/apps/evolution/evolution-rss/enclosure_limit"
+#define GCONF_KEY_ENCLOSURE_SIZE "/apps/evolution/evolution-rss/enclosure_size"
 #define GCONF_KEY_REMOVE_FOLDER "/apps/evolution/evolution-rss/remove_folder"
 #define GCONF_KEY_HTML_RENDER "/apps/evolution/evolution-rss/html_render"
 #define GCONF_KEY_HTML_JS "/apps/evolution/evolution-rss/html_js"
@@ -346,6 +349,7 @@ void error_response(
 	GtkObject *o,
 	int button,
 	void *data);
+void abort_active_op(gpointer key);
 void cancel_active_op(gpointer key);
 void browser_write(
 	gchar *string,



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