diff options
author | Radek Doulik <rodo@helixcode.com> | 2000-11-04 18:11:50 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2000-11-04 18:11:50 +0800 |
commit | 7f7c32f6d202a2b1f9cc413bf361be91bcd47010 (patch) | |
tree | f3d634d30796ce96db4978eafd96db7e31e80c9b /composer/listener.c | |
parent | 1ca157384dd51c016c0631f2fa3ab8526ae5f12a (diff) | |
download | gsoc2013-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
Diffstat (limited to 'composer/listener.c')
-rw-r--r-- | composer/listener.c | 73 |
1 files changed, 60 insertions, 13 deletions
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 * |