diff options
author | Rodrigo Moya <rodrigo@novell.com> | 2004-10-22 02:12:22 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2004-10-22 02:12:22 +0800 |
commit | 58431fb115969b527e04db2a8cdae7af94113a01 (patch) | |
tree | d6977e5c08fb9bc18e58596b8f11c543be08c45c /plugins/mail-to-task | |
parent | a32a1d4ab6591d68109a4d5f2642ef4efb37814b (diff) | |
download | gsoc2013-evolution-58431fb115969b527e04db2a8cdae7af94113a01.tar.gz gsoc2013-evolution-58431fb115969b527e04db2a8cdae7af94113a01.tar.zst gsoc2013-evolution-58431fb115969b527e04db2a8cdae7af94113a01.zip |
new functions. (do_mail_to_task): set attendees and organizer on the task
2004-10-21 Rodrigo Moya <rodrigo@novell.com>
* mail-to-task.c (set_attendees, set_organizer): new functions.
(do_mail_to_task): set attendees and organizer on the task from the
recipients in the mail message.
svn path=/trunk/; revision=27686
Diffstat (limited to 'plugins/mail-to-task')
-rw-r--r-- | plugins/mail-to-task/ChangeLog | 4 | ||||
-rw-r--r-- | plugins/mail-to-task/mail-to-task.c | 60 |
2 files changed, 63 insertions, 1 deletions
diff --git a/plugins/mail-to-task/ChangeLog b/plugins/mail-to-task/ChangeLog index f0d90529f1..e7ee058e13 100644 --- a/plugins/mail-to-task/ChangeLog +++ b/plugins/mail-to-task/ChangeLog @@ -1,5 +1,9 @@ 2004-10-21 Rodrigo Moya <rodrigo@novell.com> + * mail-to-task.c (set_attendees, set_organizer): new functions. + (do_mail_to_task): set attendees and organizer on the task from the + recipients in the mail message. + * org-gnome-mail-to-task.eplug.in: use correct icon. 2004-10-21 Rodrigo Moya <rodrigo@novell.com> diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index c4b51fd9de..595d64d974 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -23,6 +23,59 @@ #include "mail/em-popup.h" static void +add_attendee_cb (gpointer key, gpointer value, gpointer user_data) +{ + ECalComponentAttendee *ca; + const char *str, *name; + GList **attendees = user_data; + + if (!camel_internet_address_get (value, 0, &name, &str)) + return; + + ca = g_new0 (ECalComponentAttendee, 1); + ca->value = str; + ca->cn = name; + /* FIXME: missing many fields */ + + *attendees = g_slist_append (*attendees, ca); +} + +static void +set_attendees (ECalComponent *comp, CamelMimeMessage *message) +{ + GSList *attendees = NULL, *l; + + g_hash_table_foreach (message->recipients, (GHFunc) add_attendee_cb, &attendees); + e_cal_component_set_attendee_list (comp, attendees); + + for (l = attendees; l != NULL; l = l->next) + g_free (l->data); + g_slist_free (attendees); +} + +static void +set_organizer (ECalComponent *comp, CamelMimeMessage *message) +{ + const CamelInternetAddress *address; + const char *str, *name; + ECalComponentOrganizer organizer = {NULL, NULL, NULL, NULL}; + + if (message->reply_to) + address = message->reply_to; + else if (message->from) + address = message->from; + else + return; + + if (!camel_internet_address_get (address, 0, &name, &str)) + return; + + organizer.value = str; + organizer.cn = name; + e_cal_component_set_organizer (comp, &organizer); +} + +static void do_mail_to_task (EMPopupTargetSelect *t, ESource *tasks_source) { ECal *client; @@ -36,8 +89,8 @@ do_mail_to_task (EMPopupTargetSelect *t, ESource *tasks_source) CamelMimeMessage *message; ECalComponent *comp; ECalComponentText text; - char *str; GSList sl; + char *str; /* retrieve the message from the CamelFolder */ message = camel_folder_get_message (t->folder, g_ptr_array_index (t->uids, i), NULL); @@ -48,6 +101,7 @@ do_mail_to_task (EMPopupTargetSelect *t, ESource *tasks_source) e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO); e_cal_component_set_uid (comp, camel_mime_message_get_message_id (message)); + /* set the task's summary */ text.value = camel_mime_message_get_subject (message); text.altrep = NULL; e_cal_component_set_summary (comp, &text); @@ -61,6 +115,10 @@ do_mail_to_task (EMPopupTargetSelect *t, ESource *tasks_source) g_free (str); + /* set the organizer, and the attendees */ + set_organizer (comp, message); + set_attendees (comp, message); + /* save the task to the selected source */ e_cal_create_object (client, e_cal_component_get_icalcomponent (comp), NULL, NULL); |