aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-10-15 22:27:20 +0800
committerMilan Crha <mcrha@redhat.com>2009-10-15 22:27:20 +0800
commitc27b8cbd6313db5c8ad56f199b46d31987064693 (patch)
tree60dfd5385fbdc77e9855b554bd981315362384fe
parent37cd058adf025c4164bc88926b2608df40a0f5b9 (diff)
downloadgsoc2013-evolution-c27b8cbd6313db5c8ad56f199b46d31987064693.tar.gz
gsoc2013-evolution-c27b8cbd6313db5c8ad56f199b46d31987064693.tar.zst
gsoc2013-evolution-c27b8cbd6313db5c8ad56f199b46d31987064693.zip
Bug #523335 - [mail-to-task] Enhancements
-rw-r--r--plugins/mail-to-task/mail-to-task.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c
index 406aae642f..1c8be4538a 100644
--- a/plugins/mail-to-task/mail-to-task.c
+++ b/plugins/mail-to-task/mail-to-task.c
@@ -162,6 +162,37 @@ set_attendees (ECalComponent *comp, CamelMimeMessage *message, const gchar *orga
g_slist_free (attendees);
}
+static const gchar *
+prepend_from (CamelMimeMessage *message, gchar **text)
+{
+ gchar *res, *tmp, *addr = NULL;
+ const gchar *name = NULL, *eml = NULL;
+ const CamelInternetAddress *from = NULL;
+
+ g_return_val_if_fail (message != NULL, NULL);
+ g_return_val_if_fail (text != NULL, NULL);
+
+ if (message->reply_to)
+ from = message->reply_to;
+ else if (message->from)
+ from = message->from;
+
+ if (from && camel_internet_address_get (from, 0, &name, &eml))
+ addr = camel_internet_address_format_address (name, eml);
+
+ /* To Translators: The full sentence looks like: "Created from a mail by John Doe <john.doe@myco.example>" */
+ tmp = g_strdup_printf (_("Created from a mail by %s"), addr ? addr : "");
+
+ res = g_strconcat (tmp, "\n", *text, NULL);
+
+ g_free (tmp);
+ g_free (*text);
+
+ *text = res;
+
+ return res;
+}
+
static void
set_description (ECalComponent *comp, CamelMimeMessage *message)
{
@@ -182,8 +213,7 @@ set_description (ECalComponent *comp, CamelMimeMessage *message)
/*
* Get non-multipart content from multipart message.
*/
- while (CAMEL_IS_MULTIPART (content) && count > 0)
- {
+ while (CAMEL_IS_MULTIPART (content) && count > 0) {
mime_part = camel_multipart_get_part (CAMEL_MULTIPART (content), 0);
content = camel_medium_get_content_object (CAMEL_MEDIUM (mime_part));
count--;
@@ -203,17 +233,16 @@ set_description (ECalComponent *comp, CamelMimeMessage *message)
camel_object_unref (mem);
/* convert to UTF-8 string */
- if (str && content->mime_type->params && content->mime_type->params->value)
- {
+ if (str && content->mime_type->params && content->mime_type->params->value) {
convert_str = g_convert (str, strlen (str),
"UTF-8", content->mime_type->params->value,
&bytes_read, &bytes_written, NULL);
}
if (convert_str)
- text.value = convert_str;
+ text.value = prepend_from (message, &convert_str);
else
- text.value = str;
+ text.value = prepend_from (message, &str);
text.altrep = NULL;
sl.next = NULL;
sl.data = &text;
@@ -309,6 +338,22 @@ set_attachments (ECal *client, ECalComponent *comp, CamelMimeMessage *message)
e_cal_component_set_attachment_list (comp, list);
}
+static void
+set_priority (ECalComponent *comp, CamelMimePart *part)
+{
+ const gchar *prio;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (part != NULL);
+
+ prio = camel_header_raw_find (& (part->headers), "X-Priority", NULL);
+ if (prio && atoi (prio) > 0) {
+ gint priority = 1;
+
+ e_cal_component_set_priority (comp, &priority);
+ }
+}
+
struct _report_error
{
gchar *format;
@@ -726,6 +771,9 @@ do_mail_to_event (AsyncData *data)
/* set attachment files */
set_attachments (client, comp, message);
+ /* priority */
+ set_priority (comp, CAMEL_MIME_PART (message));
+
/* no need to increment a sequence number, this is a new component */
e_cal_component_abort_sequence (comp);