aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--composer/ChangeLog23
-rw-r--r--composer/e-msg-composer-attachment-bar.c58
-rw-r--r--composer/e-msg-composer-attachment-bar.h4
-rw-r--r--composer/e-msg-composer-attachment.c1
-rw-r--r--composer/e-msg-composer.c36
-rw-r--r--composer/listener.c40
6 files changed, 103 insertions, 59 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 236068c0da..1d780fd234 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,26 @@
+2001-10-05 Larry Ewing <lewing@ximian.com>
+
+ * e-msg-composer-attachment.c (e_msg_composer_attachment_new):
+ remove unused variable.
+
+ * e-msg-composer-attachment-bar.c
+ (e_msg_composer_attachment_bar_find_message): generalize this to
+ lookup content locations as well.
+
+ * e-msg-composer-attachment-bar.h: change prototype to match the
+ new function.
+
+ * listener.c (impl_event): handle the url_requested event, look up
+ parts in the attachment part and feed them down the stream if it
+ is found.
+
+ * e-msg-composer.c (handle_multipart_alternative): delay setting
+ the body text.
+ (handle_multipart): delay setting body text
+ (e_msg_composer_new_with_message): set the body text from the
+ object data. Doing this ensures that we will have the attachments
+ processed before we try to look them up.
+
2001-10-04 Larry Ewing <lewing@ximian.com>
* e-msg-composer-attachment-bar.c
diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c
index ed79beb77d..5cb8ed0244 100644
--- a/composer/e-msg-composer-attachment-bar.c
+++ b/composer/e-msg-composer-attachment-bar.c
@@ -820,62 +820,40 @@ e_msg_composer_attachment_bar_attach_mime_part (EMsgComposerAttachmentBar *bar,
}
CamelMimePart *
-e_msg_composer_attachment_bar_find_content_id (EMsgComposerAttachmentBar *bar, char *content_id)
+e_msg_composer_attachment_bar_find_message (EMsgComposerAttachmentBar *bar, char *url)
{
EMsgComposerAttachmentBarPrivate *priv;
GList *p;
+ char *content_id = NULL;
g_return_val_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar), NULL);
- g_return_val_if_fail (content_id != NULL, NULL);
+ g_return_val_if_fail (url != NULL, NULL);
+ if (!strncmp ("cid:", url, 4))
+ content_id = url + 4;
+
priv = bar->priv;
for (p = priv->attachments; p != NULL; p = p->next) {
- EMsgComposerAttachment *attachment;
+ CamelMimePart *part;
const char *part_id;
-
- attachment = p->data;
- part_id = camel_mime_part_get_content_id (attachment->body);
-
- g_warning ("content_id: %s, part_id: %s\n", content_id, part_id);
- if (part_id && !strcmp (part_id, content_id))
- return attachment->body;
- }
+ const char *part_location;
- return NULL;
-}
+ part = E_MSG_COMPOSER_ATTACHMENT (p->data)->body;
-#if 0
-EMsgComposerAttachment *
-e_msg_composer_attachment_bar_find_content_id (EMsgComposerAttachmentBar *bar, char *content_id)
-{
- EMsgComposerAttachmentBarPrivate *priv;
- GList *p;
+ part_id = camel_mime_part_get_content_id (part);
+ g_warning ("content_id: %s, part_id: %s\n", content_id, part_id);
- g_return_val_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar), NULL);
- g_return_val_if_fail (content_id != NULL, NULL);
+ if (content_id && part_id && !strcmp (part_id, content_id))
+ return part;
- priv = bar->priv;
-
- if (priv->attachments)
- g_warning ("NO ATTACHMENTS");
-
- for (p = priv->attachments; p != NULL; p = p->next) {
- EMsgComposerAttachment *attachment;
- const char *part_id;
-
- attachment = p->data;
- part_id = camel_mime_part_get_content_id (attachment->body);
+ part_location = camel_mime_part_get_content_location (part);
+ g_warning ("url: %s, part_id: %s\n", url, part_id);
- g_warning ("content_id: %s, part_id: %s\n", content_id, part_id);
- if (part_id && !strcmp (part_id, content_id))
- return attachment;
+ if (part_id && !strcmp (part_location, url))
+ return part;
+
}
return NULL;
}
-#endif
-
-
-
-
diff --git a/composer/e-msg-composer-attachment-bar.h b/composer/e-msg-composer-attachment-bar.h
index 658e29108d..3dfe87ad80 100644
--- a/composer/e-msg-composer-attachment-bar.h
+++ b/composer/e-msg-composer-attachment-bar.h
@@ -68,8 +68,8 @@ void e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar,
guint e_msg_composer_attachment_bar_get_num_attachments (EMsgComposerAttachmentBar *bar);
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);
-CamelMimePart *e_msg_composer_attachment_bar_find_content_id (EMsgComposerAttachmentBar *bar,
- char *content_id);
+CamelMimePart *e_msg_composer_attachment_bar_find_message (EMsgComposerAttachmentBar *bar,
+ char *url);
#ifdef __cplusplus
}
diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c
index b6085b6d17..49af8bc122 100644
--- a/composer/e-msg-composer-attachment.c
+++ b/composer/e-msg-composer-attachment.c
@@ -156,7 +156,6 @@ e_msg_composer_attachment_new (const gchar *file_name,
CamelStream *stream;
struct stat statbuf;
gchar *mime_type;
- char *content_id;
char *filename;
g_return_val_if_fail (file_name != NULL, NULL);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index fda86508ed..f06fe695d5 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -2453,10 +2453,9 @@ handle_multipart_alternative (EMsgComposer *composer, CamelMultipart *multipart)
contents = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
text = mail_get_message_body (contents, FALSE, FALSE);
- if (text) {
- e_msg_composer_set_body_text (composer, text);
- g_free (text);
- }
+
+ if (text)
+ gtk_object_set_data (GTK_OBJECT (composer), "body:text", text);
return;
}
@@ -2502,10 +2501,9 @@ handle_multipart (EMsgComposer *composer, CamelMultipart *multipart, int depth)
contents = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
text = mail_get_message_body (contents, FALSE, FALSE);
- if (text) {
- e_msg_composer_set_body_text (composer, text);
- g_free (text);
- }
+
+ if (text)
+ gtk_object_set_data (GTK_OBJECT (composer), "body:text", text);
} else {
/* this is a leaf of the tree, so attach it */
e_msg_composer_attach (composer, mime_part);
@@ -2559,7 +2557,8 @@ is_special_header (const char *hdr_name)
/**
* e_msg_composer_new_with_message:
- *
+ * @msg: The message to use as the source
+ *
* Create a new message composer widget.
*
* Return value: A pointer to the newly created widget
@@ -2571,6 +2570,7 @@ e_msg_composer_new_with_message (CamelMimeMessage *msg)
GList *To = NULL, *Cc = NULL, *Bcc = NULL;
EDestination **Tov, **Ccv, **Bccv;
const char *format, *subject, *account_name;
+ char *body;
CamelContentType *content_type;
struct _header_raw *headers;
EMsgComposer *new;
@@ -2698,12 +2698,20 @@ e_msg_composer_new_with_message (CamelMimeMessage *msg)
contents = camel_medium_get_content_object (CAMEL_MEDIUM (msg));
text = mail_get_message_body (contents, FALSE, FALSE);
- if (text) {
- e_msg_composer_set_body_text (new, text);
- g_free (text);
- }
+
+ if (text)
+ gtk_object_set_data (GTK_OBJECT (new), "body:text", text);
}
+ /* We wait until now to set the body text because we need to ensure that
+ * the attachment bar has all the attachments, before we request them.
+ */
+ body = gtk_object_get_data (GTK_OBJECT (new), "body:text");
+ if (body) {
+ e_msg_composer_set_body_text (new, body);
+ gtk_object_set_data (GTK_OBJECT (new), "body:text", NULL);
+ g_free (body);
+ }
return new;
}
@@ -2967,7 +2975,7 @@ void
e_msg_composer_attach (EMsgComposer *composer, CamelMimePart *attachment)
{
EMsgComposerAttachmentBar *bar;
-
+
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
g_return_if_fail (CAMEL_IS_MIME_PART (attachment));
diff --git a/composer/listener.c b/composer/listener.c
index d9141befaf..341852806e 100644
--- a/composer/listener.c
+++ b/composer/listener.c
@@ -26,8 +26,10 @@
#include <bonobo/bonobo-arg.h>
#include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-stream-client.h>
#include "listener.h"
+#include "e-msg-composer-attachment-bar.h"
static BonoboObjectClass *listener_parent_class;
static POA_GNOME_GtkHTML_Editor_Listener__vepv listener_vepv;
@@ -113,7 +115,7 @@ impl_event (PortableServer_Servant _servant,
EditorListener *l = listener_from_servant (_servant);
CORBA_any *rv = NULL;
- /* printf ("impl_event\n"); */
+ printf ("impl_event = %s\n", name);
if (!strcmp (name, "command")) {
if (!l->composer->in_signature_insert) {
@@ -142,7 +144,7 @@ impl_event (PortableServer_Servant _servant,
}
} else if (!strcmp (name, "delete")) {
CORBA_char *orig;
-
+
if (GNOME_GtkHTML_Editor_Engine_isParagraphEmpty (l->composer->editor_engine, ev)) {
orig = GNOME_GtkHTML_Editor_Engine_getParagraphData (l->composer->editor_engine, "orig", ev);
if (ev->_major == CORBA_NO_EXCEPTION) {
@@ -158,6 +160,40 @@ impl_event (PortableServer_Servant _servant,
}
}
}
+ } else if (!strcmp (name, "url_requested")) {
+ GNOME_GtkHTML_Editor_URLRequestEvent *e;
+ CORBA_long len = 0;
+ CamelMimePart *part = NULL;
+
+ e = (GNOME_GtkHTML_Editor_URLRequestEvent *)arg->_value;
+ g_warning ("url_requested = \"%s\"", e->url);
+
+ if (e->url) {
+ part = e_msg_composer_attachment_bar_find_message (
+ E_MSG_COMPOSER_ATTACHMENT_BAR (l->composer->attachment_bar), e->url);
+ }
+
+ if (!part)
+ printf ("url_requested: no part found\n");
+ else
+ printf ("url_requested: FOUND PART\n");
+
+ if (part && e->stream != CORBA_OBJECT_NIL) {
+ GByteArray *ba;
+ CamelStream *cstream;
+ CamelDataWrapper *wrapper;
+
+ /* Write the data to a CamelStreamMem... */
+ ba = g_byte_array_new ();
+ cstream = camel_stream_mem_new_with_byte_array (ba);
+ wrapper = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+ camel_data_wrapper_write_to_stream (wrapper, cstream);
+
+ bonobo_stream_client_write (e->stream, ba->data, ba->len, ev);
+
+ camel_object_unref (CAMEL_OBJECT (cstream));
+ }
+
}
return rv ? rv : get_any_null ();