X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-text-utils.c;h=59f5cac3c0121ef33896849f6bf78c17503d1717;hp=9619c8d032c1966f5efc3d78f94af178b806d607;hb=0fbbf474b218d00f517fae83561a05f6919679e7;hpb=5052d923fe6b1ab99eb502b4421006d9334196b5 diff --git a/src/modest-text-utils.c b/src/modest-text-utils.c index 9619c8d..59f5cac 100644 --- a/src/modest-text-utils.c +++ b/src/modest-text-utils.c @@ -109,14 +109,14 @@ struct _url_match_t { /* note: match MARK_AMP_URI_STR as well, because after txt->html, a '&' will look like $(MARK_AMP_URI_STR)"amp;" */ #define MAIL_VIEWER_URL_MATCH_PATTERNS { \ - { "(file|rtsp|http|ftp|https|mms|mmsh|rtsp|rdp|lastfm)://[-a-z0-9_$.+!*(),;:@%=?/~#" MARK_AMP_URI_STR \ + { "(file|rtsp|http|ftp|https|mms|mmsh|webcal|feed|rtsp|rdp|lastfm)://[-a-z0-9_$.+!*(),;:@%=?/~#" MARK_AMP_URI_STR \ "]+[-a-z0-9_$%" MARK_AMP_URI_STR "=?/~#]", \ NULL, NULL },\ { "www\\.[-a-z0-9_$.+!*(),;:@%=?/~#" MARK_AMP_URI_STR "]+[-a-z0-9_$%" MARK_AMP_URI_STR "=?/~#]",\ NULL, "http://" }, \ { "ftp\\.[-a-z0-9_$.+!*(),;:@%=?/~#" MARK_AMP_URI_STR "]+[-a-z0-9_$%" MARK_AMP_URI_STR "=?/~#]",\ NULL, "ftp://" },\ - { "(jabberto|voipto|sipto|sip|chatto|xmpp):[-_a-z@0-9.+]+", \ + { "(jabberto|voipto|sipto|sip|chatto|skype|xmpp):[-_a-z@0-9.+]+", \ NULL, NULL}, \ { "mailto:[-_a-z0-9.\\+]+@[-_a-z0-9.]+", \ NULL, NULL},\ @@ -213,14 +213,17 @@ modest_text_utils_cite (const gchar *text, g_return_val_if_fail (text, NULL); g_return_val_if_fail (content_type, NULL); - if (!signature) - retval = g_strdup (""); - else if (strcmp(content_type, "text/html") == 0) { - tmp_sig = g_strconcat ("\n", SIGNATURE_MARKER,"\n", signature, NULL); - retval = modest_text_utils_convert_to_html_body(tmp_sig, -1, TRUE); + if (!signature) { + tmp_sig = g_strdup (text); + } else { + tmp_sig = g_strconcat (text, "\n", SIGNATURE_MARKER, "\n", signature, NULL); + } + + if (strcmp (content_type, "text/html") == 0) { + retval = modest_text_utils_convert_to_html_body (tmp_sig, -1, TRUE); g_free (tmp_sig); } else { - retval = g_strconcat (text, "\n", SIGNATURE_MARKER, "\n", signature, NULL); + retval = tmp_sig; } return retval; @@ -906,6 +909,7 @@ modest_text_utils_quote_body (GString *output, const gchar *text, iter = text; len = strlen(text); + remaining = g_string_new (""); do { l = get_next_line (text, len, iter); iter = iter + l->len + 1; @@ -1004,13 +1008,17 @@ modest_text_utils_quote_html (const gchar *text, "\n
\n"); if (text || cite || signature) { + GString *quoted_text; g_string_append (result_string, "
\n");
 		if (signature) {
 			quote_html_add_to_gstring (result_string, SIGNATURE_MARKER);
 			quote_html_add_to_gstring (result_string, signature);
 		}
 		quote_html_add_to_gstring (result_string, cite);
-		quote_html_add_to_gstring (result_string, text);
+		quoted_text = g_string_new ("");
+		quoted_text = modest_text_utils_quote_body (quoted_text, text, ">", limit);
+		quote_html_add_to_gstring (result_string, quoted_text->str);
+		g_string_free (quoted_text, TRUE);
 		if (attachments) {
 			gchar *attachments_string = quoted_attachments (attachments);
 			quote_html_add_to_gstring (result_string, attachments_string);
@@ -1242,14 +1250,16 @@ modest_text_utils_get_display_address (gchar *address)
 		
 	for (i = 0; address[i]; ++i) {
 		if (address[i] == '<') {
-			if (G_UNLIKELY(i == 0))
-				return; /* there's nothing else, leave it */
-			else {
+			if (G_UNLIKELY(i == 0)) {
+				break; /* there's nothing else, leave it */
+			}else {
 				address[i] = '\0'; /* terminate the string here */
-				return;
+				break;
 			}
 		}
 	}
+
+	g_strchomp (address);
 }
 
 
@@ -1650,18 +1660,20 @@ modest_text_utils_get_display_size (guint64 size)
 	const guint MB=1024 * KB;
 	const guint GB=1024 * MB;
 
+	if (size == 0)
+		return g_strdup_printf (_FM("sfil_li_size_kb"), (int) 0);
 	if (0 <= size && size < KB)
-		return g_strdup_printf (_FM("sfil_li_size_kb"), 1);
+		return g_strdup_printf (_FM("sfil_li_size_1kb_99kb"), (int) 1);
 	else if (KB <= size && size < 100 * KB)
-		return g_strdup_printf (_FM("sfil_li_size_1kb_99kb"), size / KB);
+		return g_strdup_printf (_FM("sfil_li_size_1kb_99kb"), (int) size / KB);
 	else if (100*KB <= size && size < MB)
 		return g_strdup_printf (_FM("sfil_li_size_100kb_1mb"), (float) size / MB);
 	else if (MB <= size && size < 10*MB)
 		return g_strdup_printf (_FM("sfil_li_size_1mb_10mb"), (float) size / MB);
 	else if (10*MB <= size && size < GB)
-		return g_strdup_printf (_FM("sfil_li_size_10mb_1gb"), size / MB);
+		return g_strdup_printf (_FM("sfil_li_size_10mb_1gb"), (int) size / MB);
 	else
-		return g_strdup_printf (_FM("sfil_li_size_1gb_or_greater"), (float) size / GB);	
+		return g_strdup_printf (_FM("sfil_li_size_1gb_or_greater"), (float) size / GB);
 }
 
 static gchar *
@@ -1678,11 +1690,11 @@ get_email_from_address (const gchar * address)
 		return g_strndup (left_limit + 1, (right_limit - left_limit) - 1);
 }
 
-gchar *      
+gchar *
 modest_text_utils_get_color_string (GdkColor *color)
 {
 	g_return_val_if_fail (color, NULL);
-	
+
 	return g_strdup_printf ("#%x%x%x%x%x%x%x%x%x%x%x%x",
 				(color->red >> 12)   & 0xf, (color->red >> 8)   & 0xf,
 				(color->red >>  4)   & 0xf, (color->red)        & 0xf,