aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-01-16 05:38:50 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-01-16 05:38:50 +0800
commite9db6d2a074757e8fddee1adc8c0db4c56e00adc (patch)
tree5d9a067e3c0b40a608bc9101c12467633eacba34 /mail
parentb238693b64aa877efe1d0d09aa8129748be095ed (diff)
downloadgsoc2013-evolution-e9db6d2a074757e8fddee1adc8c0db4c56e00adc.tar
gsoc2013-evolution-e9db6d2a074757e8fddee1adc8c0db4c56e00adc.tar.gz
gsoc2013-evolution-e9db6d2a074757e8fddee1adc8c0db4c56e00adc.tar.bz2
gsoc2013-evolution-e9db6d2a074757e8fddee1adc8c0db4c56e00adc.tar.lz
gsoc2013-evolution-e9db6d2a074757e8fddee1adc8c0db4c56e00adc.tar.xz
gsoc2013-evolution-e9db6d2a074757e8fddee1adc8c0db4c56e00adc.tar.zst
gsoc2013-evolution-e9db6d2a074757e8fddee1adc8c0db4c56e00adc.zip
New callback to handle the set_base signal. (on_url_requested): If the
2002-01-15 Jeffrey Stedfast <fejj@ximian.com> * mail-display.c (on_set_base): New callback to handle the set_base signal. (on_url_requested): If the base_url is set, prepend it to the data url (we don't want to do this for cid urls or part urls tho). (mail_display_init): Initialize md->base_url to NULL. (mail_display_destroy): Free the base_url. (mail_display_initialize_gtkhtml): Connect to the set_base signal. (on_link_clicked): If the base_url is set, prepend it to the url string passed to us from gtkhtml. svn path=/trunk/; revision=15329
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog12
-rw-r--r--mail/mail-display.c51
-rw-r--r--mail/mail-display.h2
3 files changed, 60 insertions, 5 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 83498f3902..5ce8ae9218 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,15 @@
+2002-01-15 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-display.c (on_set_base): New callback to handle the
+ set_base signal.
+ (on_url_requested): If the base_url is set, prepend it to the data
+ url (we don't want to do this for cid urls or part urls tho).
+ (mail_display_init): Initialize md->base_url to NULL.
+ (mail_display_destroy): Free the base_url.
+ (mail_display_initialize_gtkhtml): Connect to the set_base signal.
+ (on_link_clicked): If the base_url is set, prepend it to the url
+ string passed to us from gtkhtml.
+
2002-01-10 Jeffrey Stedfast <fejj@ximian.com>
* mail-callbacks.c (do_edit_messages): Don't remove any
diff --git a/mail/mail-display.c b/mail/mail-display.c
index 323a77175a..15cd27809c 100644
--- a/mail/mail-display.c
+++ b/mail/mail-display.c
@@ -213,6 +213,16 @@ 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.");
@@ -1031,6 +1041,22 @@ 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)
{
@@ -1038,6 +1064,7 @@ 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);
@@ -1074,10 +1101,18 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
gtk_html_end (html, handle, GTK_HTML_STREAM_OK);
return;
}
-
+
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) {
@@ -1090,7 +1125,7 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
gtk_html_end (html, handle, GTK_HTML_STREAM_OK);
return;
}
-
+
/* See if it's something we can load. */
if (strncmp (url, "http:", 5) == 0) {
if (mail_config_get_http_mode () == MAIL_CONFIG_HTTP_ALWAYS ||
@@ -1103,10 +1138,10 @@ on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle,
!g_datalist_get_data (md->data, "checking_from")) {
const CamelInternetAddress *from = camel_mime_message_get_from (md->current_message);
const char *name, *addr;
-
+
g_datalist_set_data (md->data, "checking_from",
GINT_TO_POINTER (1));
-
+
/* Make sure we aren't deal w/ some sort of a pathological message w/o a From: header */
if (from != NULL && camel_internet_address_get (from, 0, &name, &addr))
e_book_query_address_locally (addr, ebook_callback, md);
@@ -1484,9 +1519,11 @@ mail_display_init (GtkObject *object)
mail_display->last_active = NULL;
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;
-
+
mail_display->invisible = gtk_invisible_new ();
mail_display->display_style = mail_config_get_message_display_style ();
@@ -1501,6 +1538,7 @@ 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);
@@ -2116,6 +2154,9 @@ 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 0d6d855105..ea87d2cada 100644
--- a/mail/mail-display.h
+++ b/mail/mail-display.h
@@ -36,6 +36,8 @@ struct _MailDisplay {
char *selection;
+ char *base_url;
+
CamelMimeMessage *current_message;
GData **data;