diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2003-02-06 04:16:44 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2003-02-06 04:16:44 +0800 |
commit | 999cf94d612e7fc5462dfddeb8669eae06eb0192 (patch) | |
tree | 647493606218ae5cacdd504ace835fb3a9dcdb3e /composer/e-msg-composer.c | |
parent | 7cb7f846d41b61393bce45b92096589d0161b22e (diff) | |
download | gsoc2013-evolution-999cf94d612e7fc5462dfddeb8669eae06eb0192.tar gsoc2013-evolution-999cf94d612e7fc5462dfddeb8669eae06eb0192.tar.gz gsoc2013-evolution-999cf94d612e7fc5462dfddeb8669eae06eb0192.tar.bz2 gsoc2013-evolution-999cf94d612e7fc5462dfddeb8669eae06eb0192.tar.lz gsoc2013-evolution-999cf94d612e7fc5462dfddeb8669eae06eb0192.tar.xz gsoc2013-evolution-999cf94d612e7fc5462dfddeb8669eae06eb0192.tar.zst gsoc2013-evolution-999cf94d612e7fc5462dfddeb8669eae06eb0192.zip |
Split out the mailto handling code from here so we can use it in the
2003-02-05 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer.c (e_msg_composer_new_from_url): Split out the
mailto handling code from here so we can use it in the drag-n-drop
code too.
(drag_data_received): If we find a mailto: url in the
text/uri-list drop, pass that off to handle_mailto() so it can
fill in the fields for us.
svn path=/trunk/; revision=19768
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r-- | composer/e-msg-composer.c | 87 |
1 files changed, 51 insertions, 36 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index a6ff4c39bc..107b631d3b 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -41,8 +41,7 @@ #include <config.h> #endif -#include <errno.h> -#include <ctype.h> +#include <string.h> #include <stdlib.h> #include <dirent.h> #include <sys/time.h> @@ -50,6 +49,8 @@ #include <sys/stat.h> #include <sys/wait.h> #include <unistd.h> +#include <errno.h> +#include <ctype.h> #include <glib/gunicode.h> @@ -142,6 +143,8 @@ static GSList *all_composers = NULL; /* local prototypes */ static GList *add_recipients (GList *list, const char *recips, gboolean decode); +static void handle_mailto (EMsgComposer *composer, const char *mailto); + static void message_rfc822_dnd (EMsgComposer *composer, CamelStream *stream); /* used by e_msg_composer_add_message_attachments() */ @@ -181,7 +184,7 @@ get_text (Bonobo_PersistStream persist, char *format) stream_mem = BONOBO_STREAM_MEM (stream); text = g_byte_array_new (); g_byte_array_append (text, stream_mem->buffer, stream_mem->pos); - bonobo_object_unref (BONOBO_OBJECT(stream)); + bonobo_object_unref (BONOBO_OBJECT (stream)); return text; } @@ -2458,7 +2461,7 @@ drag_data_received (EMsgComposer *composer, GdkDragContext *context, int x, int y, GtkSelectionData *selection, guint info, guint time) { - char *tmp, *filename, **filenames; + char *tmp, *str, *filename, **urls; CamelMimePart *mime_part; CamelStream *stream; CamelURL *url; @@ -2478,26 +2481,31 @@ drag_data_received (EMsgComposer *composer, GdkDragContext *context, case DND_TYPE_TEXT_URI_LIST: d(printf ("dropping a text/uri-list\n")); tmp = g_strndup (selection->data, selection->length); - filenames = g_strsplit (tmp, "\n", 0); + urls = g_strsplit (tmp, "\n", 0); g_free (tmp); - for (i = 0; filenames[i] != NULL; i++) { - filename = g_strstrip (filenames[i]); + for (i = 0; urls[i] != NULL; i++) { + str = g_strstrip (urls[i]); - url = camel_url_new (filename, NULL); - g_free (filename); - filename = url->path; - url->path = NULL; - camel_url_free (url); - - e_msg_composer_attachment_bar_attach - (E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar), - filename); - - g_free (filename); + if (!strncasecmp (str, "mailto:", 7)) { + handle_mailto (composer, str); + g_free (str); + } else { + url = camel_url_new (str, NULL); + g_free (str); + filename = url->path; + url->path = NULL; + camel_url_free (url); + + e_msg_composer_attachment_bar_attach + (E_MSG_COMPOSER_ATTACHMENT_BAR (composer->attachment_bar), + filename); + + g_free (filename); + } } - g_free (filenames); + g_free (urls); break; case DND_TYPE_TEXT_VCARD: d(printf ("dropping a text/x-vcard\n")); @@ -3642,17 +3650,9 @@ add_recipients (GList *list, const char *recips, gboolean decode) return list; } -/** - * e_msg_composer_new_from_url: - * @url: a mailto URL - * - * Create a new message composer widget, and fill in fields as - * defined by the provided URL. - **/ -EMsgComposer * -e_msg_composer_new_from_url (const char *url_in) +static void +handle_mailto (EMsgComposer *composer, const char *mailto) { - EMsgComposer *composer; EMsgComposerHdrs *hdrs; GList *to = NULL, *cc = NULL, *bcc = NULL; EDestination **tov, **ccv, **bccv; @@ -3662,14 +3662,8 @@ e_msg_composer_new_from_url (const char *url_in) char *content; int len, clen; - g_return_val_if_fail (strncasecmp (url_in, "mailto:", 7) == 0, NULL); - - composer = e_msg_composer_new (); - if (!composer) - return NULL; - /* Parse recipients (everything after ':' until '?' or eos). */ - p = url_in + 7; + p = mailto + 7; len = strcspn (p, "?"); if (len) { content = g_strndup (p, len); @@ -3777,6 +3771,27 @@ e_msg_composer_new_from_url (const char *url_in) set_editor_text (composer, htmlbody); g_free (htmlbody); } +} + +/** + * e_msg_composer_new_from_url: + * @url: a mailto URL + * + * Create a new message composer widget, and fill in fields as + * defined by the provided URL. + **/ +EMsgComposer * +e_msg_composer_new_from_url (const char *url) +{ + EMsgComposer *composer; + + g_return_val_if_fail (strncasecmp (url, "mailto:", 7) == 0, NULL); + + composer = e_msg_composer_new (); + if (!composer) + return NULL; + + handle_mailto (composer, url); return composer; } |