aboutsummaryrefslogtreecommitdiffstats
path: root/composer
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-04-28 03:01:58 +0800
committerDan Winship <danw@src.gnome.org>2000-04-28 03:01:58 +0800
commitb9d26cb85f496552e4eb6cbd9834cf33e29e9e95 (patch)
treec31743d22fb4079c73f4473071ba3eb15c868077 /composer
parentaef27503fb2115e096b78acf6111000803c2905b (diff)
downloadgsoc2013-evolution-b9d26cb85f496552e4eb6cbd9834cf33e29e9e95.tar.gz
gsoc2013-evolution-b9d26cb85f496552e4eb6cbd9834cf33e29e9e95.tar.zst
gsoc2013-evolution-b9d26cb85f496552e4eb6cbd9834cf33e29e9e95.zip
New routine, to process mailto URLs.
* e-msg-composer.c (e_msg_composer_new_from_url): New routine, to process mailto URLs. svn path=/trunk/; revision=2663
Diffstat (limited to 'composer')
-rw-r--r--composer/ChangeLog5
-rw-r--r--composer/e-msg-composer.c125
-rw-r--r--composer/e-msg-composer.h1
3 files changed, 131 insertions, 0 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 8e0cd2ee0d..87229237fd 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,8 @@
+2000-04-27 Dan Winship <danw@helixcode.com>
+
+ * e-msg-composer.c (e_msg_composer_new_from_url): New routine, to
+ process mailto URLs.
+
2000-04-26 Dan Winship <danw@helixcode.com>
* e-msg-composer.c (build_message): Only generate a multipart
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index a4866711e3..edc77d28c4 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -38,6 +38,7 @@
#include <libgnorba/gnorba.h>
#include <bonobo.h>
#include <bonobo/bonobo-stream-memory.h>
+#include "e-util/e-html-utils.h"
#include <glade/glade.h>
@@ -663,6 +664,130 @@ e_msg_composer_new (void)
return new;
}
+
+static GList *
+add_recipients (GList *list, const char *recips, gboolean decode)
+{
+ int len;
+ char *addr;
+
+ while (*recips) {
+ len = strcspn (recips, ",");
+ if (len) {
+ addr = g_strndup (recips, len);
+ if (decode)
+ camel_url_decode (addr);
+ list = g_list_append (list, addr);
+ }
+ recips += len;
+ if (*recips == ',')
+ recips++;
+ }
+
+ return list;
+}
+
+static void
+free_recipients (GList *list)
+{
+ GList *l;
+
+ for (l = list; l; l = l->next)
+ g_free (l->data);
+ g_list_free (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.
+ **/
+GtkWidget *
+e_msg_composer_new_from_url (const char *url)
+{
+ EMsgComposer *composer;
+ EMsgComposerHdrs *hdrs;
+ GList *to = NULL, *cc = NULL, *bcc = NULL;
+ char *subject = NULL, *body = NULL;
+ const char *p, *header;
+ int len, clen;
+ char *content;
+
+ g_return_val_if_fail (strncasecmp (url, "mailto:", 7) == 0, NULL);
+
+ /* Parse recipients (everything after ':' until '?' or eos. */
+ p = url + 7;
+ len = strcspn (p, "?,");
+ if (len) {
+ content = g_strndup (p, len);
+ to = add_recipients (to, content, TRUE);
+ g_free (content);
+ }
+
+ p += len;
+ if (*p == '?') {
+ p++;
+
+ while (*p) {
+ len = strcspn (p, "=&");
+
+ /* If it's malformed, give up. */
+ if (p[len] != '=')
+ break;
+
+ header = p;
+ p += len + 1;
+
+ clen = strcspn (p, "&");
+ content = g_strndup (p, clen);
+ camel_url_decode (content);
+
+ if (!strncasecmp (header, "to", len))
+ to = add_recipients (to, content, FALSE);
+ else if (!strncasecmp (header, "cc", len))
+ cc = add_recipients (cc, content, FALSE);
+ else if (!strncasecmp (header, "bcc", len))
+ bcc = add_recipients (bcc, content, FALSE);
+ else if (!strncasecmp (header, "subject", len))
+ subject = g_strdup (content);
+ else if (!strncasecmp (header, "body", len))
+ body = g_strdup (content);
+
+ g_free (content);
+ p += clen;
+ if (*p == '&') {
+ p++;
+ if (!strcmp (p, "amp;"))
+ p += 4;
+ }
+ }
+ }
+
+ composer = E_MSG_COMPOSER (e_msg_composer_new ());
+ hdrs = E_MSG_COMPOSER_HDRS (composer->hdrs);
+ e_msg_composer_hdrs_set_to (hdrs, to);
+ free_recipients (to);
+ e_msg_composer_hdrs_set_cc (hdrs, cc);
+ free_recipients (cc);
+ e_msg_composer_hdrs_set_bcc (hdrs, bcc);
+ free_recipients (bcc);
+ if (subject) {
+ e_msg_composer_hdrs_set_subject (hdrs, subject);
+ g_free (subject);
+ }
+
+ if (body) {
+ char *htmlbody = e_text_to_html (body, E_TEXT_TO_HTML_PRE);
+ set_editor_text (BONOBO_WIDGET (composer->editor), htmlbody);
+ g_free (htmlbody);
+ }
+
+ return GTK_WIDGET (composer);
+}
+
+
/**
* e_msg_composer_show_attachments:
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 778e1c23f7..cc3826ab67 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -76,6 +76,7 @@ GtkType e_msg_composer_get_type (void);
void e_msg_composer_construct (EMsgComposer *composer);
GtkWidget *e_msg_composer_new (void);
+GtkWidget *e_msg_composer_new_from_url (const char *url);
void e_msg_composer_show_attachments (EMsgComposer *composer,
gboolean show);
b1fe3260c96293db765950d5327cdcd'>Bump PORTREVISION after DESKTOP_ENTRIES updatemakc2013-01-231-1/+1 | * - Update DESKTOP_ENTRIES:makc2013-01-231-2/+2 | | | | | | | | | | * rephrase Comment field or use port ${COMMENT} if appropriate * adjust Icon field according to the Desktop Entry Specification * update Categories field: remove deprecated category Application; set main category if missing - Remove indefinite article from COMMENT Approved by: maintainers * - update png to 1.5.10dinoex2012-06-011-1/+1 | * - Update devel/sdl12 to 1.2.15mva2012-02-181-1/+1 | | | | | | | | | | | | | - Update audio/sdl_mixer to 1.2.15 - Update graphics/sdl_image to 1.2.12 - Update graphics/sdl_ttf to 2.0.11 - Update graphics/sdl_gfx to 2.0.23 - Update net/sdl_net to 1.2.8 - Bump PORTREVISIONs on ports that depend on one or more packages due to ABI and shared library version changes - Update Mk/bsd.sdl.mk accordingly for the new shared library versions Tested by: exp-run by pav * -remove MD5ohauer2011-07-031-1/+0 | * - update to 1.4.1dinoex2010-03-281-1/+1 | | | | | Reviewed by: exp8 run on pointyhat Supported by: miwi * - update to jpeg-8dinoex2010-02-051-1/+1 | * - Update devel/sdl12 to version 1.2.14.mva2010-01-301-1/+1 | | | | | | | | | | | | - Update audio/sdl_mixer to version 1.2.11. - Update graphics/sdl_gfx to version 2.0.20. - Update graphics/sdl_image to version 1.2.10. - Bump portrevisions for all ports depending on audio/sdl_mixer and graphics/sdl_image. - Update Mk/bsd.sdl.mk accordingly for the new shared lib versions. PR: ports/142147 ports/142248 ports/142249 Approved by: miwi (mentor implicit) * - Switch SourceForge ports to the new File Release System: categories ↵amdmi32009-08-221-1/+1 | | | | starting with G * - bump all port that indirectly depends on libjpeg and have not yet been ↵dinoex2009-07-311-1/+1 | | | | | | bumped or updated Requested by: edwin * - Remove duplicates from MAKE_ENV after inclusion of CC and CXX in default ↵pav2008-07-251-2/+0 | | | | MAKE_ENV * Update my email address in 132 ports.amdmi32008-06-201-1/+1 | | | | Approved by: miwi (mentor) * - Remove unneeded dependency from gtk12/gtk20 [1]miwi2008-04-201-3/+3 | | | | | | | | | | | | | | | - Remove USE_XLIB/USE_X_PREFIX/USE_XPM in favor of USE_XORG - Remove X11BASE support in favor of LOCALBASE or PREFIX - Use USE_LDCONFIG instead of INSTALLS_SHLIB - Remove unneeded USE_GCC 3.4+ Thanks to all Helpers: Dmitry Marakasov, Chess Griffin, beech@, dinoex, rafan, gahr, ehaupt, nox, itetcu, flz, pav PR: 116263 Tested on: pointyhat Approved by: portmgr (pav) * - Get rid of USE_X_PREFIX.miwi2008-03-211-4/+2 | | | | | | - Use SF macro Submitted by: Dmitry Marakasov <amdmi3@amdmi3.ru> (maintainer) * - Chase devel/sdl12 shlib version bumpmiwi2008-03-131-1/+1 | * - Welcome X.org 7.2 \o/.flz2007-05-201-1/+1 | | | | | - Set X11BASE to ${LOCALBASE} for recent ${OSVERSION}. - Bump PORTREVISION for ports intalling files in ${X11BASE}. * [MAINTAINER] update my email address in 76 ports + mirror some distfilesedwin2006-12-221-2/+2 | | | | | | | | | I've got a brand new hosting, so change my email to the new one. Also, now I can mirror some distfiles, so update MASTER_SITES for some ports. PR: ports/107038 Submitted by: Dmitry Marakasov <amdmi3@mail.ru> * - Update devel/sdl12 to version 1.2.11. Now we employ stock SDL directorystas2006-09-201-1/+1 | | | | | | | | | | | | | | | | structure (i.e. include/SDL for includes and sdl-config for configuration binary) - Update graphics/sdl_ttf to version 2.0.8 - Update graphics/sdl_image to version 1.2.5 - Update audio/sdl_mixer to version 1.2.7 - Update net/sdl_net to version 1.2.6 - Update Mk/bsd.sdl.mk accordingly - Fix dependent ports to fit the new directory structure and avoid several API breakages - Bump up portrevisions for all dependent ports to allow them to be upgraded by portupgrade/portmaster etc tools Approved by: kris (portmgr), sem (mentor) * Remove USE_REINPLACE for categories starting with a Gedwin2006-05-081-1/+0 | * - Update to 0.1.1barner2006-02-063-9/+10 | | | | | Submitted by: Dmitry Marakasov <amdmi3@mail.ru> (maintainer) PR: ports/92847 * Add a desktop entry.jylefort2006-01-201-0/+8 | | | | | | PR: ports/92024 Submitted by: jylefort Approved by: maintainer