aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Doulik <rodo@helixcode.com>2000-11-04 18:11:50 +0800
committerRadek Doulik <rodo@src.gnome.org>2000-11-04 18:11:50 +0800
commit7f7c32f6d202a2b1f9cc413bf361be91bcd47010 (patch)
treef3d634d30796ce96db4978eafd96db7e31e80c9b
parent1ca157384dd51c016c0631f2fa3ab8526ae5f12a (diff)
downloadgsoc2013-evolution-7f7c32f6d202a2b1f9cc413bf361be91bcd47010.tar.gz
gsoc2013-evolution-7f7c32f6d202a2b1f9cc413bf361be91bcd47010.tar.zst
gsoc2013-evolution-7f7c32f6d202a2b1f9cc413bf361be91bcd47010.zip
use inline images hash table
2000-11-04 Radek Doulik <rodo@helixcode.com> * listener.c (resolve_image_url): use inline images hash table * e-msg-composer.c (init): create inlined images hash table (destroy): destroy it (clear_inline_images): helper function, used from g_hash_table_foreach_remove to destroy one inline image record * e-msg-composer.h: added hash table with inlined images url -> cid info 2000-11-03 Radek Doulik <rodo@helixcode.com> * listener.c (impl_event): updated for API changed implemented image_url event (resolve_image_url): new helper function, attaches image to mail and returns new (resolved) url pointing to mime component * e-msg-composer-attachment.c (e_msg_composer_attachment_new): added conponent_id parameter * e-msg-composer-attachment-bar.c (e_msg_composer_attachment_bar_attach): added parameter content_id (add_from_file): likewise svn path=/trunk/; revision=6390
-rw-r--r--composer/ChangeLog26
-rw-r--r--composer/HTMLEditor.idl56
-rw-r--r--composer/Makefile.am13
-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.c12
-rw-r--r--composer/e-msg-composer-attachment.h2
-rw-r--r--composer/e-msg-composer.c16
-rw-r--r--composer/e-msg-composer.h1
-rw-r--r--composer/listener.c73
10 files changed, 126 insertions, 85 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index c3a8c4bd57..edb13ea3b5 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,29 @@
+2000-11-04 Radek Doulik <rodo@helixcode.com>
+
+ * listener.c (resolve_image_url): use inline images hash table
+
+ * e-msg-composer.c (init): create inlined images hash table
+ (destroy): destroy it
+ (clear_inline_images): helper function, used from
+ g_hash_table_foreach_remove to destroy one inline image record
+
+ * e-msg-composer.h: added hash table with inlined images url ->
+ cid info
+
+2000-11-03 Radek Doulik <rodo@helixcode.com>
+
+ * listener.c (impl_event): updated for API changed
+ implemented image_url event
+ (resolve_image_url): new helper function, attaches image to mail
+ and returns new (resolved) url pointing to mime component
+
+ * e-msg-composer-attachment.c (e_msg_composer_attachment_new):
+ added conponent_id parameter
+
+ * e-msg-composer-attachment-bar.c
+ (e_msg_composer_attachment_bar_attach): added parameter content_id
+ (add_from_file): likewise
+
2000-11-03 Jeffrey Stedfast <fejj@helixcode.com>
* e-msg-composer-attachment.c (e_msg_composer_attachment_new):
diff --git a/composer/HTMLEditor.idl b/composer/HTMLEditor.idl
deleted file mode 100644
index ec1e971f22..0000000000
--- a/composer/HTMLEditor.idl
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Interface for the HTML Editor.
- *
- * Authors:
- * Larry Ewing <lewing@helixcode.com>
- * Radek Doulik <rodo@helixcode.com>
- *
- * Copyright (C) 2000 Helix Code, Inc.
- */
-
-#include <Bonobo.idl>
-
-module HTMLEditor {
- interface Resolver : Bonobo::Unknown {
- exception NotFound {};
-
- void loadURL (in Bonobo::ProgressiveDataSink sink, in string url) raises (NotFound);
- };
-
- struct Arg {
- any value;
- };
- typedef sequence<Arg> ListenerArgs;
-
- interface Listener : Bonobo::Unknown {
- void event (in string name, in ListenerArgs args);
- };
-
- interface Engine : Bonobo::Unknown {
- attribute Listener listener;
-
- /*
- * return data of current paragraph
- */
- any get_paragraph_data (in string key);
-
- /*
- * sets data on current paragraph
- */
- void set_paragraph_data (in string key, in any value);
-
- /*
- * set data which are set to objects of given type while inserting
- * we will use that to mark original text paragraph(s) in composer
- * and use that data later in editing to implement better reply
- * editing
- */
- void set_object_data_by_type (in string type_name, in string key, in any data);
-
- /*
- * execute editor command
- */
- void command (in string command);
- };
-};
diff --git a/composer/Makefile.am b/composer/Makefile.am
index e005697b9d..144c3f85a8 100644
--- a/composer/Makefile.am
+++ b/composer/Makefile.am
@@ -2,14 +2,15 @@
IDLS = \
Evolution-Composer.idl \
- Composer.idl \
- HTMLEditor.idl
+ Composer.idl
IDL_GENERATED = \
Composer.h \
Composer-common.c \
Composer-skels.c \
- Composer-stubs.c \
+ Composer-stubs.c
+
+HTML_EDITOR_GENERATED = \
HTMLEditor.h \
HTMLEditor-common.c \
HTMLEditor-skels.c \
@@ -20,8 +21,9 @@ selectnamesdir = $(top_srcdir)/addressbook/gui/component/select-names
$(IDL_GENERATED): $(IDLS) $(selectnamesdir)/Evolution-Addressbook-SelectNames.idl
$(ORBIT_IDL) -I $(datadir)/idl `$(GNOME_CONFIG) --cflags idl` \
-I $(selectnamesdir) -I . $(srcdir)/Composer.idl
- $(ORBIT_IDL) -I $(datadir)/idl `$(GNOME_CONFIG) --cflags idl` \
- -I $(selectnamesdir) -I . $(srcdir)/HTMLEditor.idl
+
+$(HTML_EDITOR_GENERATED): $(GTK_HTML_EDITOR_IDL)
+ $(ORBIT_IDL) `$(GNOME_CONFIG) --cflags idl` $(GTK_HTML_EDITOR_IDL)
##
@@ -58,6 +60,7 @@ INCLUDES = \
libcomposer_la_SOURCES = \
$(IDL_GENERATED) \
+ $(HTML_EDITOR_GENERATED) \
e-msg-composer-attachment-bar.c \
e-msg-composer-attachment-bar.h \
e-msg-composer-attachment.c \
diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c
index 93aaf30900..6653fa238f 100644
--- a/composer/e-msg-composer-attachment-bar.c
+++ b/composer/e-msg-composer-attachment-bar.c
@@ -157,9 +157,9 @@ add_from_mime_part (EMsgComposerAttachmentBar *bar,
static void
add_from_file (EMsgComposerAttachmentBar *bar,
- const gchar *file_name)
+ const gchar *file_name, const gchar *content_id)
{
- add_common (bar, e_msg_composer_attachment_new (file_name));
+ add_common (bar, e_msg_composer_attachment_new (file_name, content_id));
}
static void
@@ -395,7 +395,7 @@ add_from_user (EMsgComposerAttachmentBar *bar)
file_name = e_msg_composer_select_file (composer, _("Attach a file"));
- add_from_file (bar, file_name);
+ add_from_file (bar, file_name, NULL);
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 *file_name, const gchar *content_id)
{
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);
+ add_from_file (bar, file_name, content_id);
}
void
diff --git a/composer/e-msg-composer-attachment-bar.h b/composer/e-msg-composer-attachment-bar.h
index 17d717cc10..31a59cc149 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);
+void e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const gchar *file_name, const gchar *content_id);
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 b42631cda6..2ec141064b 100644
--- a/composer/e-msg-composer-attachment.c
+++ b/composer/e-msg-composer-attachment.c
@@ -165,7 +165,7 @@ e_msg_composer_attachment_get_type (void)
* Return value:
**/
EMsgComposerAttachment *
-e_msg_composer_attachment_new (const gchar *file_name)
+e_msg_composer_attachment_new (const gchar *file_name, const gchar *content_id)
{
EMsgComposerAttachment *new;
CamelMimePart *part;
@@ -199,7 +199,15 @@ e_msg_composer_attachment_new (const gchar *file_name)
part = camel_mime_part_new ();
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);
diff --git a/composer/e-msg-composer-attachment.h b/composer/e-msg-composer-attachment.h
index 47bc85ece0..f3d8922276 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);
+EMsgComposerAttachment *e_msg_composer_attachment_new (const gchar *file_name, const gchar *content_id);
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 dbf37ac0bb..6fd10d578c 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -707,7 +707,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
@@ -987,6 +987,15 @@ 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)
{
@@ -1034,6 +1043,7 @@ 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);
@@ -1084,7 +1094,7 @@ drag_data_received (EMsgComposer *composer,
e_msg_composer_attachment_bar_attach
(E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar),
- filename);
+ filename, NULL);
g_free (filename);
}
@@ -1142,7 +1152,9 @@ init (EMsgComposer *composer)
composer->persist_file_interface = CORBA_OBJECT_NIL;
composer->persist_stream_interface = CORBA_OBJECT_NIL;
+
composer->editor_engine = CORBA_OBJECT_NIL;
+ composer->inline_images = g_hash_table_new (g_str_hash, g_str_equal);
composer->attachment_bar_visible = FALSE;
composer->send_html = FALSE;
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 0f0a290760..08d7da9906 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -67,6 +67,7 @@ struct _EMsgComposer {
Bonobo_PersistStream persist_stream_interface;
HTMLEditor_Engine editor_engine;
BonoboObject *editor_listener;
+ GHashTable *inline_images;
char *sig_file;
diff --git a/composer/listener.c b/composer/listener.c
index d97dd02df9..3b90e7200f 100644
--- a/composer/listener.c
+++ b/composer/listener.c
@@ -34,26 +34,73 @@ html_editor_listener_from_servant (PortableServer_Servant servant)
return HTML_EDITOR_LISTENER (bonobo_object_from_servant (servant));
}
-static void
-impl_event (PortableServer_Servant _servant, const CORBA_char * name,
- const HTMLEditor_ListenerArgs * args,
- CORBA_Environment * ev)
+static CORBA_any *
+get_any_null ()
+{
+ CORBA_any *rv;
+
+ rv = CORBA_any__alloc ();
+ rv->_type = TC_null;
+
+ return rv;
+}
+
+static gchar *
+resolve_image_url (HTMLEditorListener *l, gchar *url)
+{
+ gchar *cid = NULL;
+
+ if (!strncmp (url, "file:", 5)) {
+ gchar *id;
+
+ 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);
+ }
+
+ return cid;
+}
+
+static CORBA_any *
+impl_event (PortableServer_Servant _servant,
+ const CORBA_char * name, const CORBA_any * arg,
+ CORBA_Environment * ev)
{
HTMLEditorListener *l = html_editor_listener_from_servant (_servant);
- BonoboArg *arg;
+ BonoboArg *data;
+ CORBA_any *rv = NULL;
/* printf ("impl_event\n"); */
- arg = HTMLEditor_Engine_get_paragraph_data (l->composer->editor_engine, "orig", ev);
- if (ev->_major == CORBA_NO_EXCEPTION && arg) {
- if (CORBA_TypeCode_equal (arg->_type, TC_boolean, ev) && BONOBO_ARG_GET_BOOLEAN (arg)) {
- HTMLEditor_Engine_command (l->composer->editor_engine, "style-normal", ev);
- HTMLEditor_Engine_command (l->composer->editor_engine, "indent-zero", ev);
- HTMLEditor_Engine_command (l->composer->editor_engine, "italic-off", ev);
+ if (!strcmp (name, "command")) {
+ /* FIXME check for insert-paragraph command */
+ data = HTMLEditor_Engine_get_paragraph_data (l->composer->editor_engine, "orig", ev);
+ if (ev->_major == CORBA_NO_EXCEPTION && data) {
+ if (CORBA_TypeCode_equal (data->_type, TC_boolean, ev) && BONOBO_ARG_GET_BOOLEAN (data)) {
+ HTMLEditor_Engine_command (l->composer->editor_engine, "style-normal", ev);
+ HTMLEditor_Engine_command (l->composer->editor_engine, "indent-zero", ev);
+ HTMLEditor_Engine_command (l->composer->editor_engine, "italic-off", ev);
+ }
+ BONOBO_ARG_SET_BOOLEAN (data, CORBA_FALSE);
+ HTMLEditor_Engine_set_paragraph_data (l->composer->editor_engine, "orig", data, ev);
+ }
+ } else if (!strcmp (name, "image_url")) {
+ gchar *url;
+
+ if ((url = resolve_image_url (l, BONOBO_ARG_GET_STRING (arg)))) {
+ rv = bonobo_arg_new (TC_string);
+ BONOBO_ARG_SET_STRING (rv, url);
+ printf ("new url: %s\n", url);
+ g_free (url);
}
- BONOBO_ARG_SET_BOOLEAN (arg, CORBA_FALSE);
- HTMLEditor_Engine_set_paragraph_data (l->composer->editor_engine, "orig", arg, ev);
}
+
+ return rv ? rv : get_any_null ();
}
POA_HTMLEditor_Listener__epv *