aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-02-27 08:01:09 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-02-27 08:01:09 +0800
commit22ac1344f7dff17a6761e2c2826baa37dad864fd (patch)
tree72fdf2b1022a2dba2463f17dc4a0cd26794b62e5
parent9001aaa2f36f58125c46ccedaad4043213c5767a (diff)
downloadgsoc2013-evolution-22ac1344f7dff17a6761e2c2826baa37dad864fd.tar.gz
gsoc2013-evolution-22ac1344f7dff17a6761e2c2826baa37dad864fd.tar.zst
gsoc2013-evolution-22ac1344f7dff17a6761e2c2826baa37dad864fd.zip
Get the Content-Base if the header exists and use gtk_html_set_base to set
2002-02-26 Jeffrey Stedfast <fejj@ximian.com> * mail-format.c (handle_text_html): Get the Content-Base if the header exists and use gtk_html_set_base to set this base url. * mail-display.c (on_link_clicked): No longer need to calculate the full url. This is now handled by GtkHTML. (on_set_base): Removed. (on_url_requested): No longer need to calculate the full url. (mail_display_initialize_gtkhtml): Don't connect to the set_base signal anymore. We don't care. * mail-display.h: No longer need base_url (it was broken anyway). svn path=/trunk/; revision=15850
-rw-r--r--mail/ChangeLog14
-rw-r--r--mail/mail-display.c42
-rw-r--r--mail/mail-display.h2
-rw-r--r--mail/mail-format.c19
4 files changed, 33 insertions, 44 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 45d3f63c91..7103ef39b7 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,17 @@
+2002-02-26 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-format.c (handle_text_html): Get the Content-Base if the
+ header exists and use gtk_html_set_base to set this base url.
+
+ * mail-display.c (on_link_clicked): No longer need to calculate
+ the full url. This is now handled by GtkHTML.
+ (on_set_base): Removed.
+ (on_url_requested): No longer need to calculate the full url.
+ (mail_display_initialize_gtkhtml): Don't connect to the set_base
+ signal anymore. We don't care.
+
+ * mail-display.h: No longer need base_url (it was broken anyway).
+
2002-02-26 Not Zed <NotZed@Ximian.com>
* mail-display.c (on_url_requested): If a related part is
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 81a9fce492..1a1f454828 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -219,16 +219,6 @@ mail_display_jump_to_anchor (MailDisplay *md, const char *url)
static void
on_link_clicked (GtkHTML *html, const char *url, MailDisplay *md)
{
- char *full_url;
-
- if (md->base_url) {
- full_url = alloca (strlen (md->base_url) + strlen (url) + 2);
- sprintf (full_url, "%s%s%s", md->base_url,
- *url == '/' ? "" : "/", url);
-
- url = full_url;
- }
-
if (!g_strncasecmp (url, "news:", 5) ||
!g_strncasecmp (url, "nntp:", 5))
g_warning ("Can't handle news URLs yet.");
@@ -275,7 +265,7 @@ static void
save_cb (GtkWidget *widget, gpointer user_data)
{
CamelMimePart *part = gtk_object_get_data (GTK_OBJECT (user_data), "CamelMimePart");
-
+
save_part (part);
}
@@ -1126,22 +1116,6 @@ ebook_callback (EBook *book, const gchar *addr, ECard *card, gpointer data)
}
static void
-on_set_base (GtkHTML *html, const char *base_url, gpointer user_data)
-{
- MailDisplay *md = user_data;
- size_t len;
-
- g_free (md->base_url);
-
- /* strip the trailing '/' if there is one */
- len = strlen (base_url);
- if (base_url[len - 1] == '/')
- md->base_url = g_strndup (base_url, len - 1);
- else
- md->base_url = g_strdup (base_url);
-}
-
-static void
on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
gpointer user_data)
{
@@ -1149,7 +1123,6 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
GHashTable *urls;
CamelMedium *medium;
GByteArray *ba;
- char *full_url;
urls = g_datalist_get_data (md->data, "part_urls");
g_return_if_fail (urls != NULL);
@@ -1193,14 +1166,6 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
urls = g_datalist_get_data (md->data, "data_urls");
g_return_if_fail (urls != NULL);
- if (md->base_url) {
- full_url = alloca (strlen (md->base_url) + strlen (url) + 2);
- sprintf (full_url, "%s%s%s", md->base_url,
- *url == '/' ? "" : "/", url);
-
- url = full_url;
- }
-
/* See if it's some piece of cached data */
ba = g_hash_table_lookup (urls, url);
if (ba) {
@@ -1608,7 +1573,6 @@ mail_display_init (GtkObject *object)
mail_display->idle_id = 0;
mail_display->selection = NULL;
mail_display->charset = NULL;
- mail_display->base_url = NULL;
mail_display->current_message = NULL;
mail_display->data = NULL;
@@ -1626,7 +1590,6 @@ mail_display_destroy (GtkObject *object)
g_free (mail_display->charset);
g_free (mail_display->selection);
- g_free (mail_display->base_url);
g_datalist_clear (mail_display->data);
g_free (mail_display->data);
@@ -2242,9 +2205,6 @@ mail_display_initialize_gtkhtml (MailDisplay *mail_display, GtkHTML *html)
gtk_html_set_editable (GTK_HTML (html), FALSE);
- gtk_signal_connect (GTK_OBJECT (html), "set_base",
- GTK_SIGNAL_FUNC (on_set_base),
- mail_display);
gtk_signal_connect (GTK_OBJECT (html), "url_requested",
GTK_SIGNAL_FUNC (on_url_requested),
mail_display);
diff --git a/mail/mail-display.h b/mail/mail-display.h
index 015f87d651..afdfe8b59b 100644
--- a/mail/mail-display.h
+++ b/mail/mail-display.h
@@ -36,8 +36,6 @@ struct _MailDisplay {
char *selection;
- char *base_url;
-
CamelMimeMessage *current_message;
GData **data;
diff --git a/mail/mail-format.c b/mail/mail-format.c
index 4b315643b4..a6e8748d0b 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -1629,10 +1629,27 @@ static gboolean
handle_text_html (CamelMimePart *part, const char *mime_type,
MailDisplay *md, GtkHTML *html, GtkHTMLStream *stream)
{
- const char *location;
+ const char *location, *base;
mail_html_write (html, stream, "\n<!-- text/html -->\n");
+ if ((base = camel_medium_get_header (CAMEL_MEDIUM (part), "Content-Base"))) {
+ char *base_url;
+ size_t len;
+
+ len = strlen (base);
+
+ if (*base == '"' && *(base + len - 1) == '"') {
+ len -= 2;
+ base_url = alloca (len + 1);
+ memcpy (base_url, base + 1, len);
+ base_url[len] = '\0';
+ base = base_url;
+ }
+
+ gtk_html_set_base (html, base);
+ }
+
/* FIXME: deal with relative URLs */
location = get_location (part, md);
if (!location)