[evolution-patches] 65058 again, 3rd time lucky




Ok this is a simpler patch which fixes the test cases in 65058 and seems to fix the other test cases too, at least as well as the last patch did.

I could have added a new argument to add_puri() to tell it the parent needed a uri, but I didn't, since it was too much code to change (all the callers).

This is probably more suitable for 2.0.1 than the last patch (apart from the fact it actually works :), although for 2.1 i might use some combination of these two patches since that might fix some other issues - maybe.  The camel part of the last patch should go in though.

--
Michael Zucchi <notzed ximian com>
"born to die, live to work, it's all downhill from here"
Novell's Evolution and Free Software Developer
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3444.2.9
diff -u -3 -r1.3444.2.9 ChangeLog
--- mail/ChangeLog	22 Sep 2004 01:31:16 -0000	1.3444.2.9
+++ mail/ChangeLog	23 Sep 2004 08:12:42 -0000
@@ -1,3 +1,13 @@
+2004-09-23  Not Zed  <NotZed Ximian com>
+
+	** See bug #65058 (again again).
+
+	* em-format-html.c (efh_text_html): calculate our location uri
+	ourselves (content id).
+
+	* em-format.c (em_format_add_puri): if we have no content-location
+	key, don't fallback to any container's location.
+
 2004-09-03  Not Zed  <NotZed Ximian com>
 
 	** See bug #65058.
Index: mail/em-format-html.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format-html.c,v
retrieving revision 1.63.4.1
diff -u -3 -r1.63.4.1 em-format-html.c
--- mail/em-format-html.c	22 Sep 2004 01:31:16 -0000	1.63.4.1
+++ mail/em-format-html.c	23 Sep 2004 08:12:44 -0000
@@ -797,8 +797,9 @@
 static void
 efh_text_html(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
 {
-	const char *location, *base;
+	const char *location, *base, *tmp;
 	EMFormatPURI *puri;
+	char *cid = NULL;
 
 	camel_stream_printf (stream,
 			     "<table bgcolor=\"#%06x\" cellspacing=0 cellpadding=1 width=100%%><tr><td>\n"
@@ -823,14 +824,36 @@
 		gtk_html_set_base(efh->html, base);
 	}
 
-	puri = em_format_add_puri((EMFormat *)efh, sizeof(EMFormatPURI), NULL, part, efh_write_text_html);
-	location = puri->uri?puri->uri:puri->cid;
-	d(printf("adding iframe, location %s\n", location));
+	/* calculate our own location string so add_puri doesn't do it
+	   for us. our iframes are special cases, we need to use the
+	   proper base url to access them, but other children parts
+	   shouldn't blindly inherit the container's location. */
+	tmp = camel_mime_part_get_content_location(part);
+	if (tmp == NULL) {
+		if (((EMFormat *)efh)->base)
+			cid = camel_url_to_string(((EMFormat *)efh)->base, 0);
+		else
+			cid = g_strdup(((EMFormat *)efh)->part_id->str);
+	} else {
+		if (strchr(tmp, ':') == NULL && ((EMFormat *)efh)->base != NULL) {
+			CamelURL *uri;
+			
+			uri = camel_url_new_with_base(((EMFormat *)efh)->base, tmp);
+			cid = camel_url_to_string(uri, 0);
+			camel_url_free(uri);
+		} else {
+			cid = g_strdup(tmp);
+		}
+	}
+
+	puri = em_format_add_puri((EMFormat *)efh, sizeof(EMFormatPURI), cid, part, efh_write_text_html);
+	d(printf("adding iframe, location %s\n", cid));
 	camel_stream_printf(stream,
 			    "<iframe src=\"%s\" frameborder=0 scrolling=no>could not get %s</iframe>\n"
 			    "</td></tr></table>\n"
 			    "</td></tr></table>\n",
-			    location, location);
+			    cid, cid);
+	g_free(cid);
 }
 
 /* This is a lot of code for something useless ... */
Index: mail/em-format.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format.c,v
retrieving revision 1.38.8.1
diff -u -3 -r1.38.8.1 em-format.c
--- mail/em-format.c	7 Sep 2004 14:22:12 -0000	1.38.8.1
+++ mail/em-format.c	23 Sep 2004 08:12:45 -0000
@@ -339,8 +339,7 @@
 		tmp = camel_mime_part_get_content_location(part);
 		puri->uri = NULL;
 		if (tmp == NULL) {
-			if (emf->base)
-				puri->uri = camel_url_to_string(emf->base, 0);
+			/* no location, don't set a uri at all, html parts do this themselves */
 		} else {
 			if (strchr(tmp, ':') == NULL && emf->base != NULL) {
 				CamelURL *uri;


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