aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Doulik <rodo@helixcode.com>2000-11-08 21:06:58 +0800
committerRadek Doulik <rodo@src.gnome.org>2000-11-08 21:06:58 +0800
commitf3ec28d123a08e6e3b6b5667665dfb4bcb700346 (patch)
treec84f99f204d24615ebd01ba107c815a66ecbf1a0
parent413284362ffbc5185e72dd2e246ba88f912ffbdb (diff)
downloadgsoc2013-evolution-f3ec28d123a08e6e3b6b5667665dfb4bcb700346.tar
gsoc2013-evolution-f3ec28d123a08e6e3b6b5667665dfb4bcb700346.tar.gz
gsoc2013-evolution-f3ec28d123a08e6e3b6b5667665dfb4bcb700346.tar.bz2
gsoc2013-evolution-f3ec28d123a08e6e3b6b5667665dfb4bcb700346.tar.lz
gsoc2013-evolution-f3ec28d123a08e6e3b6b5667665dfb4bcb700346.tar.xz
gsoc2013-evolution-f3ec28d123a08e6e3b6b5667665dfb4bcb700346.tar.zst
gsoc2013-evolution-f3ec28d123a08e6e3b6b5667665dfb4bcb700346.zip
new function (destroy): use e_msg_composer_clear_inlined_table, destroy
2000-11-08 Radek Doulik <rodo@helixcode.com> * e-msg-composer.c (e_msg_composer_clear_inlined_table): new function (destroy): use e_msg_composer_clear_inlined_table, destroy inlined_images hash table * listener.c (resolve_image_url): don't add inlined images to attachement bar * e-msg-composer.c (add_inlined_images): new function, adds inlined images to multipart (add_inlined_image): helper function, adds one image to multipart (build_message): store HTML messages with inlined images to multipart/related * e-msg-composer-attachment-bar.c (add_from_file): removed content_id arg (e_msg_composer_attachment_bar_attach): likewise * e-msg-composer-attachment.c (e_msg_composer_attachment_new): removed content_id arg svn path=/trunk/; revision=6507
-rw-r--r--composer/ChangeLog23
-rw-r--r--composer/e-msg-composer-attachment-bar.c10
-rw-r--r--composer/e-msg-composer-attachment-bar.h2
-rw-r--r--composer/e-msg-composer-attachment.c36
-rw-r--r--composer/e-msg-composer-attachment.h2
-rw-r--r--composer/e-msg-composer.c101
-rw-r--r--composer/e-msg-composer.h60
-rw-r--r--composer/listener.c2
8 files changed, 149 insertions, 87 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index eedd5040ac..9661b929a9 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,26 @@
+2000-11-08 Radek Doulik <rodo@helixcode.com>
+
+ * e-msg-composer.c (e_msg_composer_clear_inlined_table): new
+ function
+ (destroy): use e_msg_composer_clear_inlined_table, destroy
+ inlined_images hash table
+
+ * listener.c (resolve_image_url): don't add inlined images to
+ attachement bar
+
+ * e-msg-composer.c (add_inlined_images): new function, adds
+ inlined images to multipart
+ (add_inlined_image): helper function, adds one image to multipart
+ (build_message): store HTML messages with inlined images to
+ multipart/related
+
+ * e-msg-composer-attachment-bar.c (add_from_file): removed
+ content_id arg
+ (e_msg_composer_attachment_bar_attach): likewise
+
+ * e-msg-composer-attachment.c (e_msg_composer_attachment_new):
+ removed content_id arg
+
2000-11-06 Not Zed <NotZed@HelixCode.com>
* e-msg-composer-hdrs.c (e_msg_composer_hdrs_to_message): Changed
diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c
index 1b6d2232a4..85a1d4ca81 100644
--- a/composer/e-msg-composer-attachment-bar.c
+++ b/composer/e-msg-composer-attachment-bar.c
@@ -158,9 +158,9 @@ add_from_mime_part (EMsgComposerAttachmentBar *bar,
static void
add_from_file (EMsgComposerAttachmentBar *bar,
- const gchar *file_name, const gchar *content_id)
+ const gchar *file_name)
{
- add_common (bar, e_msg_composer_attachment_new (file_name, content_id));
+ add_common (bar, e_msg_composer_attachment_new (file_name));
}
static void
@@ -396,7 +396,7 @@ add_from_user (EMsgComposerAttachmentBar *bar)
file_name = e_msg_composer_select_file (composer, _("Attach a file"));
- add_from_file (bar, file_name, NULL);
+ add_from_file (bar, file_name);
g_free (file_name);
}
@@ -758,14 +758,14 @@ e_msg_composer_attachment_bar_get_num_attachments (EMsgComposerAttachmentBar *ba
void
e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar,
- const gchar *file_name, const gchar *content_id)
+ const gchar *file_name)
{
g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar));
if (file_name == NULL)
add_from_user (bar);
else
- add_from_file (bar, file_name, content_id);
+ add_from_file (bar, file_name);
}
void
diff --git a/composer/e-msg-composer-attachment-bar.h b/composer/e-msg-composer-attachment-bar.h
index 31a59cc149..17d717cc10 100644
--- a/composer/e-msg-composer-attachment-bar.h
+++ b/composer/e-msg-composer-attachment-bar.h
@@ -66,7 +66,7 @@ GtkType e_msg_composer_attachment_bar_get_type (void);
GtkWidget *e_msg_composer_attachment_bar_new (GtkAdjustment *adj);
void e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar, CamelMultipart *multipart);
guint e_msg_composer_attachment_bar_get_num_attachments (EMsgComposerAttachmentBar *bar);
-void e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const gchar *file_name, const gchar *content_id);
+void e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const gchar *file_name);
void e_msg_composer_attachment_bar_attach_mime_part (EMsgComposerAttachmentBar *bar, CamelMimePart *part);
#ifdef __cplusplus
diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c
index 537774d109..8fd06f2afa 100644
--- a/composer/e-msg-composer-attachment.c
+++ b/composer/e-msg-composer-attachment.c
@@ -32,7 +32,6 @@
#include <gnome.h>
#include <camel/camel.h>
#include <gal/widgets/e-unicode.h>
-#include <libgnomevfs/gnome-vfs.h>
#include "e-msg-composer-attachment.h"
@@ -46,27 +45,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
static GtkObjectClass *parent_class = NULL;
-/* Utility functions. */
-
-static gchar *
-get_mime_type (const gchar *file_name)
-{
- GnomeVFSFileInfo info;
- GnomeVFSResult result;
-
- result = gnome_vfs_get_file_info (file_name, &info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
- GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- if (result == GNOME_VFS_OK) {
- gchar *type;
-
- type = g_strdup (gnome_vfs_file_info_get_mime_type (&info));
- gnome_vfs_file_info_unref (&info);
- return type;
- } else
- return NULL;
-}
-
static void
changed (EMsgComposerAttachment *attachment)
{
@@ -165,7 +143,7 @@ e_msg_composer_attachment_get_type (void)
* Return value:
**/
EMsgComposerAttachment *
-e_msg_composer_attachment_new (const gchar *file_name, const gchar *content_id)
+e_msg_composer_attachment_new (const gchar *file_name)
{
EMsgComposerAttachment *new;
CamelMimePart *part;
@@ -189,7 +167,7 @@ e_msg_composer_attachment_new (const gchar *file_name, const gchar *content_id)
wrapper = camel_data_wrapper_new ();
camel_data_wrapper_construct_from_stream (wrapper, stream);
camel_object_unref (CAMEL_OBJECT (stream));
- mime_type = get_mime_type (file_name);
+ mime_type = mime_guess_type_from_file_name (file_name);
if (mime_type) {
camel_data_wrapper_set_mime_type (wrapper, mime_type);
g_free (mime_type);
@@ -200,14 +178,6 @@ e_msg_composer_attachment_new (const gchar *file_name, const gchar *content_id)
camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper);
camel_object_unref (CAMEL_OBJECT (wrapper));
- if (content_id) {
- gchar *id;
-
- id = g_strconcat ("<", content_id, ">", NULL);
- camel_mime_part_set_content_id (part, id);
- g_free (id);
- }
-
camel_mime_part_set_disposition (part, "attachment");
if (strchr (file_name, '/'))
camel_mime_part_set_filename (part, strrchr (file_name, '/') + 1);
@@ -281,7 +251,7 @@ update_mime_type (DialogData *data)
return;
file_name = e_utf8_gtk_entry_get_text (data->file_name_entry);
- mime_type = get_mime_type (file_name);
+ mime_type = mime_guess_type_from_file_name (file_name);
g_free (file_name);
e_utf8_gtk_entry_set_text (data->mime_type_entry, mime_type);
diff --git a/composer/e-msg-composer-attachment.h b/composer/e-msg-composer-attachment.h
index f3d8922276..47bc85ece0 100644
--- a/composer/e-msg-composer-attachment.h
+++ b/composer/e-msg-composer-attachment.h
@@ -63,7 +63,7 @@ struct _EMsgComposerAttachmentClass {
GtkType e_msg_composer_attachment_get_type (void);
-EMsgComposerAttachment *e_msg_composer_attachment_new (const gchar *file_name, const gchar *content_id);
+EMsgComposerAttachment *e_msg_composer_attachment_new (const gchar *file_name);
EMsgComposerAttachment *e_msg_composer_attachment_new_from_mime_part (CamelMimePart *part);
void e_msg_composer_attachment_edit (EMsgComposerAttachment *attachment,
GtkWidget *parent);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 456b8a54f9..2b3e8f9376 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -166,6 +166,68 @@ best_content (gchar *plain)
return result;
}
+static gboolean
+clear_inline_images (gpointer key, gpointer value, gpointer user_data)
+{
+ g_free (key);
+ g_free (value);
+
+ return TRUE;
+}
+
+void
+e_msg_composer_clear_inlined_table (EMsgComposer *composer)
+{
+ g_hash_table_foreach_remove (composer->inline_images, clear_inline_images, NULL);
+}
+
+static void
+add_inlined_image (gpointer key, gpointer value, gpointer data)
+{
+ gchar *file_name = (gchar *) key;
+ gchar *cid = (gchar *) value;
+ gchar *id, *mime_type;
+ CamelMultipart *multipart = (CamelMultipart *) data;
+ CamelStream *stream;
+ CamelDataWrapper *wrapper;
+ CamelMimePart *part;
+ struct stat statbuf;
+
+ /* check for regular file */
+ if (stat (file_name, &statbuf) < 0 || !S_ISREG (statbuf.st_mode))
+ return;
+
+ if (!(stream = camel_stream_fs_new_with_name (file_name, O_RDONLY, 0)))
+ return;
+
+ wrapper = camel_data_wrapper_new ();
+ camel_data_wrapper_construct_from_stream (wrapper, stream);
+ camel_object_unref (CAMEL_OBJECT (stream));
+
+ mime_type = mime_guess_type_from_file_name (file_name);
+ camel_data_wrapper_set_mime_type (wrapper, mime_type ? mime_type : "application/octet-stream");
+ g_free (mime_type);
+
+ part = camel_mime_part_new ();
+ camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper);
+ camel_object_unref (CAMEL_OBJECT (wrapper));
+
+ id = g_strconcat ("<", cid, ">", NULL);
+ camel_mime_part_set_content_id (part, id);
+ g_free (id);
+ camel_mime_part_set_filename (part, strchr (file_name, '/') ? strrchr (file_name, '/') + 1 : file_name);
+ camel_mime_part_set_encoding (part, CAMEL_MIME_PART_ENCODING_BASE64);
+
+ camel_multipart_add_part (multipart, part);
+ camel_object_unref (CAMEL_OBJECT (part));
+}
+
+static void
+add_inlined_images (EMsgComposer *composer, CamelMultipart *multipart)
+{
+ g_hash_table_foreach (composer->inline_images, add_inlined_image, multipart);
+}
+
/* This functions builds a CamelMimeMessage for the message that the user has
composed in `composer'. */
static CamelMimeMessage *
@@ -226,6 +288,7 @@ build_message (EMsgComposer *composer)
content_type = best_content (plain);
if (type != MSG_FORMAT_PLAIN) {
+ e_msg_composer_clear_inlined_table (composer);
html = get_text (composer->persist_stream_interface, "text/html");
/* the component has probably died */
@@ -255,7 +318,26 @@ build_message (EMsgComposer *composer)
camel_object_unref (CAMEL_OBJECT (part));
part = camel_mime_part_new ();
- camel_mime_part_set_content (part, html, strlen (html), "text/html");
+ if (g_hash_table_size (composer->inline_images)) {
+ CamelMultipart *html_with_images;
+ CamelMimePart *text_html;
+
+ html_with_images = camel_multipart_new ();
+ camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (html_with_images),
+ "multipart/related");
+ camel_multipart_set_boundary (html_with_images, NULL);
+
+ text_html = camel_mime_part_new ();
+ camel_mime_part_set_content (text_html, html, strlen (html), "text/html");
+ camel_multipart_add_part (html_with_images, text_html);
+ camel_object_unref (CAMEL_OBJECT (text_html));
+
+ add_inlined_images (composer, html_with_images);
+ camel_medium_set_content_object (CAMEL_MEDIUM (part),
+ CAMEL_DATA_WRAPPER (html_with_images));
+ } else
+ camel_mime_part_set_content (part, html, strlen (html), "text/html");
+
g_free (html);
camel_multipart_add_part (body, part);
camel_object_unref (CAMEL_OBJECT (part));
@@ -737,7 +819,7 @@ menu_file_add_attachment_cb (BonoboUIComponent *uic,
e_msg_composer_attachment_bar_attach
(E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar),
- NULL, NULL);
+ NULL);
}
static void
@@ -1017,15 +1099,6 @@ attachment_bar_changed_cb (EMsgComposerAttachmentBar *bar,
/* GtkObject methods. */
-static gboolean
-clear_inline_images (gpointer key, gpointer value, gpointer user_data)
-{
- g_free (key);
- g_free (value);
-
- return TRUE;
-}
-
static void
destroy (GtkObject *object)
{
@@ -1056,6 +1129,9 @@ destroy (GtkObject *object)
g_ptr_array_free (composer->extra_hdr_names, TRUE);
g_ptr_array_free (composer->extra_hdr_values, TRUE);
}
+
+ e_msg_composer_clear_inlined_table (composer);
+ g_hash_table_destroy (composer->inline_images);
CORBA_exception_init (&ev);
@@ -1073,7 +1149,6 @@ destroy (GtkObject *object)
Bonobo_Unknown_unref (composer->editor_engine, &ev);
CORBA_Object_release (composer->editor_engine, &ev);
}
- g_hash_table_foreach_remove (composer->inline_images, clear_inline_images, NULL);
CORBA_exception_free (&ev);
@@ -1124,7 +1199,7 @@ drag_data_received (EMsgComposer *composer,
e_msg_composer_attachment_bar_attach
(E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar),
- filename, NULL);
+ filename);
g_free (filename);
}
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 08d7da9906..77ba51c944 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -83,38 +83,34 @@ struct _EMsgComposerClass {
};
-GtkType e_msg_composer_get_type (void);
-
-void e_msg_composer_construct (EMsgComposer *composer);
-EMsgComposer *e_msg_composer_new (void);
-EMsgComposer *e_msg_composer_new_with_sig_file (const char *sig_file);
-EMsgComposer *e_msg_composer_new_with_message (CamelMimeMessage *msg);
-EMsgComposer *e_msg_composer_new_from_url (const char *url);
-void e_msg_composer_show_attachments (EMsgComposer *composer,
- gboolean show);
-
-void e_msg_composer_set_headers (EMsgComposer *composer,
- const GList *to,
- const GList *cc,
- const GList *bcc,
- const char *subject);
-void e_msg_composer_set_body_text (EMsgComposer *composer,
- const char *text);
-void e_msg_composer_add_header (EMsgComposer *composer,
- const char *name,
- const char *value);
-void e_msg_composer_attach (EMsgComposer *composer,
- CamelMimePart *attachment);
-
-CamelMimeMessage *e_msg_composer_get_message (EMsgComposer *composer);
-
-void e_msg_composer_set_sig_file (EMsgComposer *composer,
- const char *sig_file);
-const char *e_msg_composer_get_sig_file (EMsgComposer *composer);
-
-void e_msg_composer_set_send_html (EMsgComposer *composer,
- gboolean send_html);
-gboolean e_msg_composer_get_send_html (EMsgComposer *composer);
+GtkType e_msg_composer_get_type (void);
+void e_msg_composer_construct (EMsgComposer *composer);
+EMsgComposer *e_msg_composer_new (void);
+EMsgComposer *e_msg_composer_new_with_sig_file (const char *sig_file);
+EMsgComposer *e_msg_composer_new_with_message (CamelMimeMessage *msg);
+EMsgComposer *e_msg_composer_new_from_url (const char *url);
+void e_msg_composer_show_attachments (EMsgComposer *composer,
+ gboolean show);
+void e_msg_composer_set_headers (EMsgComposer *composer,
+ const GList *to,
+ const GList *cc,
+ const GList *bcc,
+ const char *subject);
+void e_msg_composer_set_body_text (EMsgComposer *composer,
+ const char *text);
+void e_msg_composer_add_header (EMsgComposer *composer,
+ const char *name,
+ const char *value);
+void e_msg_composer_attach (EMsgComposer *composer,
+ CamelMimePart *attachment);
+CamelMimeMessage *e_msg_composer_get_message (EMsgComposer *composer);
+void e_msg_composer_set_sig_file (EMsgComposer *composer,
+ const char *sig_file);
+const char *e_msg_composer_get_sig_file (EMsgComposer *composer);
+void e_msg_composer_set_send_html (EMsgComposer *composer,
+ gboolean send_html);
+gboolean e_msg_composer_get_send_html (EMsgComposer *composer);
+void e_msg_composer_clear_inlined_table (EMsgComposer *composer);
#ifdef __cplusplus
}
diff --git a/composer/listener.c b/composer/listener.c
index 3b90e7200f..6d62d49476 100644
--- a/composer/listener.c
+++ b/composer/listener.c
@@ -56,8 +56,6 @@ resolve_image_url (HTMLEditorListener *l, gchar *url)
id = (gchar *) g_hash_table_lookup (l->composer->inline_images, url + 5);
if (!id) {
id = header_msgid_generate ();
- e_msg_composer_attachment_bar_attach (E_MSG_COMPOSER_ATTACHMENT_BAR (l->composer->attachment_bar),
- url + 5, id);
g_hash_table_insert (l->composer->inline_images, g_strdup (url + 5), id);
}
cid = g_strconcat ("cid:", id, NULL);