X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-text-utils.c;h=f01e706c83f09c5894fc921e9781a51d9fa4f739;hp=df9b846f6837fb495eb7b2582fb2a9358ecdcb10;hb=193d70ae22fc51b52d327e63791a025d5a4dcba8;hpb=3e8ecec4aa187f222e95e305f70b5f67ee60d4ce
diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c
index df9b846..f01e706 100644
--- a/src/modest-text-utils.c
+++ b/src/modest-text-utils.c
@@ -51,6 +51,14 @@
#define EMPTY_STRING ""
/*
+ * do the hyperlinkification only for texts < 50 Kb,
+ * as it's quite slow. Without this, e.g. mail with
+ * an uuencoded part (which is not recognized as attachment,
+ * will hang modest
+ */
+#define HYPERLINKIFY_MAX_LENGTH (1024*50)
+
+/*
* we need these regexps to find URLs in plain text e-mails
*/
typedef struct _url_match_pattern_t url_match_pattern_t;
@@ -71,7 +79,7 @@ struct _url_match_t {
{ "(file|rtsp|http|ftp|https)://[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]+[-A-Za-z0-9_$%&=?/~#]",\
NULL, NULL },\
{ "www\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]}\\),?!;:\"]?)?",\
- NULL, "http://" },\
+ NULL, "http://" }, \
{ "ftp\\.[-a-z0-9.]+[-a-z0-9](:[0-9]*)?(/[-A-Za-z0-9_$.+!*(),;:@%&=?/~#]*[^]}\\),?!;:\"]?)?",\
NULL, "ftp://" },\
{ "(voipto|callto|chatto|jabberto|xmpp):[-_a-z@0-9.\\+]+", \
@@ -86,7 +94,6 @@ struct _url_match_t {
static gchar* cite (const time_t sent_date, const gchar *from);
static void hyperlinkify_plain_text (GString *txt);
static gint cmp_offsets_reverse (const url_match_t *match1, const url_match_t *match2);
-static void chk_partial_match (const url_match_t *match, guint* offset);
static GSList* get_url_matches (GString *txt);
static GString* get_next_line (const char *b, const gsize blen, const gchar * iter);
@@ -140,7 +147,7 @@ modest_text_utils_quote (const gchar *text,
retval = modest_text_utils_quote_plain_text (text, cited, signature, attachments, limit);
g_free (cited);
-
+
return retval;
}
@@ -159,19 +166,32 @@ modest_text_utils_cite (const gchar *text,
g_return_val_if_fail (content_type, NULL);
if (!signature)
- tmp_sig = g_strdup ("");
+ retval = g_strdup ("");
else if (!strcmp(content_type, "text/html")) {
- tmp_sig = modest_text_utils_convert_to_html_body(signature);
+ tmp_sig = g_strconcat ("\n", signature, NULL);
+ retval = modest_text_utils_convert_to_html_body(tmp_sig);
+ g_free (tmp_sig);
} else {
- tmp_sig = g_strdup (signature);
+ retval = g_strconcat ("\n", signature, NULL);
}
- retval = g_strdup_printf ("\n%s\n", tmp_sig);
- g_free (tmp_sig);
-
return retval;
}
+static gchar *
+forward_cite (const gchar *from,
+ const gchar *sent,
+ const gchar *to,
+ const gchar *subject)
+{
+ return g_strdup_printf ("%s\n%s %s\n%s %s\n%s %s\n%s %s\n",
+ FORWARD_STRING,
+ FROM_STRING, (from)?from:"",
+ SENT_STRING, sent,
+ TO_STRING, (to)?to:"",
+ SUBJECT_STRING, (subject)?subject:"");
+}
+
gchar *
modest_text_utils_inline (const gchar *text,
const gchar *content_type,
@@ -182,47 +202,23 @@ modest_text_utils_inline (const gchar *text,
const gchar *subject)
{
gchar sent_str[101];
- gchar *formatted_signature;
- const gchar *plain_format = "%s%s\n%s %s\n%s %s\n%s %s\n%s %s\n\n%s";
- const gchar *html_format = \
- "%s%s
\n
%s | %s |
%s | %s |
%s | %s |
%s | %s |