diff options
author | Milan Crha <mcrha@redhat.com> | 2014-04-29 20:48:30 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2014-04-29 20:49:59 +0800 |
commit | 3c497e278d5af861d09db0d57758f0612ea4baf1 (patch) | |
tree | cc5c7fe2e53872050d32409f5360136efdd4a31e /e-util | |
parent | 1ed59cadaae04a119bbffcc6fcfc41f7b269c5e5 (diff) | |
download | gsoc2013-evolution-3c497e278d5af861d09db0d57758f0612ea4baf1.tar gsoc2013-evolution-3c497e278d5af861d09db0d57758f0612ea4baf1.tar.gz gsoc2013-evolution-3c497e278d5af861d09db0d57758f0612ea4baf1.tar.bz2 gsoc2013-evolution-3c497e278d5af861d09db0d57758f0612ea4baf1.tar.lz gsoc2013-evolution-3c497e278d5af861d09db0d57758f0612ea4baf1.tar.xz gsoc2013-evolution-3c497e278d5af861d09db0d57758f0612ea4baf1.tar.zst gsoc2013-evolution-3c497e278d5af861d09db0d57758f0612ea4baf1.zip |
Bug #685323 - Provide SIP field for contacts
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-html-utils.c | 40 | ||||
-rw-r--r-- | e-util/e-html-utils.h | 3 |
2 files changed, 37 insertions, 6 deletions
diff --git a/e-util/e-html-utils.c b/e-util/e-html-utils.c index 4c49315c3d..260e26bdc0 100644 --- a/e-util/e-html-utils.c +++ b/e-util/e-html-utils.c @@ -75,13 +75,18 @@ static gint special_chars[] = { static gchar * url_extract (const guchar **text, - gboolean full_url) + gboolean full_url, + gboolean use_whole_text) { const guchar *end = *text, *p; gchar *out; - while (*end && is_url_char (*end)) - end++; + if (use_whole_text) { + end = (*text) + strlen ((const gchar *) (*text)); + } else { + while (*end && is_url_char (*end)) + end++; + } /* Back up if we probably went too far. */ while (end > *text && is_trailing_garbage (*(end - 1))) @@ -221,6 +226,13 @@ is_citation (const guchar *c, * - E_TEXT_TO_HTML_CITE: quote the text with "> " at the start of each * line. * + * - E_TEXT_TO_HTML_HIDE_URL_SCHEME: hides scheme part of the URL in + * the display part of the generated text (thus, instead of "http://www.example.com", + * user will only see "www.example.com") + * + * - E_TEXT_TO_HTML_URL_IS_WHOLE_TEXT: set when the whole @input text + * represents a URL + * * Returns: a newly-allocated string containing HTML **/ gchar * @@ -291,14 +303,30 @@ e_text_to_html_full (const gchar *input, !g_ascii_strncasecmp ((gchar *) cur, "h323:", 5) || !g_ascii_strncasecmp ((gchar *) cur, "sip:", 4) || !g_ascii_strncasecmp ((gchar *) cur, "webcal:", 7)) { - tmpurl = url_extract (&cur, TRUE); + tmpurl = url_extract (&cur, TRUE, (flags & E_TEXT_TO_HTML_URL_IS_WHOLE_TEXT) != 0); if (tmpurl) { refurl = e_text_to_html (tmpurl, 0); - dispurl = g_strdup (refurl); + if ((flags & E_TEXT_TO_HTML_HIDE_URL_SCHEME) != 0) { + const gchar *str; + + str = strchr (refurl, ':'); + if (str) { + str++; + if (g_ascii_strncasecmp (str, "//", 2) == 0) { + str += 2; + } + + dispurl = g_strdup (str); + } else { + dispurl = g_strdup (refurl); + } + } else { + dispurl = g_strdup (refurl); + } } } else if (!g_ascii_strncasecmp ((gchar *) cur, "www.", 4) && is_url_char (*(cur + 4))) { - tmpurl = url_extract (&cur, FALSE); + tmpurl = url_extract (&cur, FALSE, (flags & E_TEXT_TO_HTML_URL_IS_WHOLE_TEXT) != 0); if (tmpurl) { dispurl = e_text_to_html (tmpurl, 0); refurl = g_strdup_printf ( diff --git a/e-util/e-html-utils.h b/e-util/e-html-utils.h index 6ff93d7e65..ea48fbd890 100644 --- a/e-util/e-html-utils.h +++ b/e-util/e-html-utils.h @@ -36,6 +36,9 @@ #define E_TEXT_TO_HTML_CONVERT_ADDRESSES (1 << 5) #define E_TEXT_TO_HTML_ESCAPE_8BIT (1 << 6) #define E_TEXT_TO_HTML_CITE (1 << 7) +#define E_TEXT_TO_HTML_HIDE_URL_SCHEME (1 << 8) +#define E_TEXT_TO_HTML_URL_IS_WHOLE_TEXT (1 << 9) +#define E_TEXT_TO_HTML_LAST_FLAG (1 << 10) gchar *e_text_to_html_full (const gchar *input, guint flags, guint32 color); gchar *e_text_to_html (const gchar *input, guint flags); |