#include <regex.h>
#include <modest-tny-platform-factory.h>
#include <modest-text-utils.h>
+#include <modest-account-mgr-helpers.h>
#include <modest-runtime.h>
#include <ctype.h>
const gchar *from,
time_t sent_date)
{
- gchar *retval;
- gchar *tmp_sig;
-
+ gchar *retval, *tmp;
+
g_return_val_if_fail (text, NULL);
g_return_val_if_fail (content_type, NULL);
-
- if (!signature) {
- tmp_sig = g_strdup (text);
- } else {
- tmp_sig = g_strconcat (text, "\n", MODEST_TEXT_UTILS_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);
+ tmp = modest_text_utils_convert_to_html_body (text, -1, TRUE);
+ if (signature) {
+ gchar *colored_signature = modest_text_utils_create_colored_signature (signature);
+ retval = g_strconcat (tmp, colored_signature, NULL);
+ g_free (colored_signature);
+ g_free (tmp);
+ } else {
+ retval = tmp;
+ }
} else {
- retval = tmp_sig;
+ if (signature)
+ retval = g_strconcat (text, "\n", MODEST_TEXT_UTILS_SIGNATURE_MARKER, "\n", signature, NULL);
+ else
+ retval = g_strdup (text);
}
return retval;
{
GString *result_string;
- result_string =
+ result_string =
g_string_new ( \
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" \
"<html>\n" \
- "<body>\n<br/>\n");
+ "<body>\n");
if (text || cite || signature) {
GString *quoted_text;
g_string_append (result_string, "<pre>\n");
if (signature) {
- quote_html_add_to_gstring (result_string, MODEST_TEXT_UTILS_SIGNATURE_MARKER);
- quote_html_add_to_gstring (result_string, signature);
+ gchar *colored_signature = modest_text_utils_create_colored_signature (signature);
+ g_string_append_printf (result_string, "%s<br/>", colored_signature);
+ g_free (colored_signature);
}
quote_html_add_to_gstring (result_string, cite);
quoted_text = g_string_new ("");
return retval;
}
+
+gchar *
+modest_text_utils_create_colored_signature (const gchar *signature)
+{
+ gchar *gray_color_markup = NULL, *retval;
+ GdkColor color;
+ GtkWidget *widget;
+
+ /* Get color from widgets */
+ widget = (GtkWidget *) modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ());
+ if (widget && gtk_style_lookup_color (gtk_widget_get_style (widget), "SecondaryTextColor", &color))
+ gray_color_markup = modest_text_utils_get_color_string (&color);
+
+ retval = g_strdup_printf ("<br/>\n<font color=\"%s\">%s<br/>\n%s<br/>\n</font>",
+ (gray_color_markup) ? gray_color_markup : "#babababababa",
+ MODEST_TEXT_UTILS_SIGNATURE_MARKER,
+ signature);
+
+ if (gray_color_markup)
+ g_free (gray_color_markup);
+
+ return retval;
+}
TnyMsg *msg = NULL;
TnyAccount *account = NULL;
TnyFolder *folder = NULL;
- gchar *from_str = NULL, *signature = NULL, *body = NULL;
- gchar *recipient = NULL;
+ gchar *from_str = NULL, *signature = NULL, *body = NULL, *recipient = NULL, *tmp = NULL;
gboolean use_signature = FALSE;
ModestWindow *msg_win = NULL;
ModestAccountMgr *mgr = modest_runtime_get_account_mgr();
goto cleanup;
}
+
recipient = modest_text_utils_get_email_address (from_str);
- signature = modest_account_mgr_get_signature_from_recipient (mgr, recipient, &use_signature);
+ tmp = modest_account_mgr_get_signature_from_recipient (modest_runtime_get_account_mgr (),
+ recipient,
+ &use_signature);
+ signature = modest_text_utils_create_colored_signature (tmp);
+ g_free (tmp);
g_free (recipient);
- if (body_str != NULL) {
- body = use_signature ? g_strconcat(body_str, "\n",
- MODEST_TEXT_UTILS_SIGNATURE_MARKER,
- "\n", signature, NULL) : g_strdup(body_str);
- } else {
-
- gchar *gray_color_markup = NULL, *color_begin = NULL, *color_end = NULL;
- GdkColor color;
- if (win && gtk_style_lookup_color (gtk_widget_get_style ((GtkWidget *) win),
- "SecondaryTextColor", &color))
- gray_color_markup = modest_text_utils_get_color_string (&color);
- if (!gray_color_markup)
- gray_color_markup = g_strdup ("#babababababa");
-
- color_begin = g_strdup_printf ("<font color=\"%s\">", gray_color_markup);
- color_end = "</font>";
-
- body = use_signature ? g_strconcat("<br/>\n", color_begin,
- MODEST_TEXT_UTILS_SIGNATURE_MARKER, "<br/>\n",
- signature, color_end, NULL) : g_strdup("");
-
- g_free (gray_color_markup);
- g_free (color_begin);
- }
+ body = use_signature ? g_strconcat ((body_str) ? body_str : "", signature, NULL) :
+ g_strdup(body_str);
msg = modest_tny_msg_new_html_plain (to_str, from_str, cc_str, bcc_str, subject_str,
NULL, NULL, body, NULL, NULL, NULL, NULL, NULL);
gchar *from = NULL;
TnyAccount *account = NULL;
ModestWindowMgr *mgr = NULL;
- gchar *signature = NULL;
+ gchar *signature = NULL, *recipient = NULL;
gboolean use_signature;
- gchar *recipient;
/* If there was any error. The mail operation could be NULL,
this means that we already have the message downloaded and
from = modest_account_mgr_get_from_string (modest_runtime_get_account_mgr(),
rf_helper->account_name, rf_helper->mailbox);
+
recipient = modest_text_utils_get_email_address (from);
- signature = modest_account_mgr_get_signature_from_recipient (modest_runtime_get_account_mgr(),
- recipient,
+ signature = modest_account_mgr_get_signature_from_recipient (modest_runtime_get_account_mgr (),
+ recipient,
&use_signature);
g_free (recipient);