[evolution-ews] Fetch assigned tasks properties. The task owner according to Exchange is current user, even that the



commit a11b77dba9d50b74cb1ed84f28a507c74c742cca
Author: Pavel Ocheretny <pocheretny src gnome org>
Date:   Wed Jul 6 10:52:00 2011 +0300

    Fetch assigned tasks properties.
    The task owner according to Exchange is current user, even that the task was assigned by
    someone else. I'm making the current user attendee and task delegator will be a task organizer

 src/calendar/e-cal-backend-ews.c |   44 +++++++++++++++++++++++++++++++++++++-
 src/server/e-ews-item.c          |   13 +++++++++++
 src/server/e-ews-item.h          |    1 +
 3 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 60649ae..72ef632 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -2321,7 +2321,6 @@ add_item_to_cache (ECalBackendEws *cbews, EEwsItem *item, gchar *uid)
 		has_this_date = FALSE;
 		e_ews_item_task_has_complete_date (item, &has_this_date);
 		if (has_this_date) {
-			g_warning ("Task with compleete date");
 			complete_date = icaltime_from_timet_with_zone (e_ews_item_get_complete_date (item), 0, priv->default_zone);
 			icalprop = icalproperty_new_completed (complete_date);
 			icalcomponent_add_property (icalcomp, icalprop);
@@ -2351,6 +2350,49 @@ add_item_to_cache (ECalBackendEws *cbews, EEwsItem *item, gchar *uid)
 		icalprop = icalproperty_new_description (e_ews_item_get_body (item));
 		icalcomponent_add_property (icalcomp, icalprop);
 
+		/*task assaingments*/
+		if (!(e_ews_item_get_delegator (item)== NULL)) {
+			const char *task_owner = e_ews_item_get_delegator (item);
+			GSList *mailboxes = NULL, *l;
+			GError *error = NULL;
+			gboolean includes_last_item;
+			char *mailtoname;
+			icalparameter *param;
+
+			/*The task owner according to Exchange is current user, even that the task was assigned by
+			 *someone else. I'm making the current user attendee and task delegator will be a task organizer */
+
+			mailtoname = g_strdup_printf ("mailto:%s";, priv->user_email);
+			icalprop = icalproperty_new_attendee (mailtoname);
+			g_free(mailtoname);
+
+			param = icalparameter_new_cn (e_ews_item_get_owner (item));
+			icalproperty_add_parameter (icalprop, param);
+			icalcomponent_add_property (icalcomp, icalprop);
+
+			/* get delegator mail box*/
+			e_ews_connection_resolve_names	(priv->cnc, EWS_PRIORITY_MEDIUM, task_owner,
+						 EWS_SEARCH_AD, NULL, FALSE, &mailboxes, NULL,
+						 &includes_last_item, NULL, &error);
+
+			for (l = mailboxes; l != NULL; l = g_slist_next (l)) {
+				EwsMailbox *mb = l->data;
+
+				mailtoname = g_strdup_printf ("mailto:%s";, mb->email);
+				icalprop = icalproperty_new_organizer (mailtoname);
+				param = icalparameter_new_cn (mb->name);
+				icalproperty_add_parameter (icalprop, param);
+				icalcomponent_add_property (icalcomp, icalprop);
+
+				g_free (mailtoname);
+				g_free (mb->email);
+				g_free (mb->name);
+				g_free (mb);
+			}
+			g_slist_free (mailboxes);
+		}
+
+
 		icalcomponent_add_component (vcomp,icalcomp);
 	} else {
 		mime_content = e_ews_item_get_mime_content (item);
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index 0e0d4f5..c49376f 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -129,6 +129,7 @@ struct _EEwsTaskFields {
 	gchar *body;
 	gchar *sensitivity;
 	gchar *owner;
+	gchar *delegator;
 	time_t due_date;
 	time_t start_date;
 	time_t complete_date;
@@ -797,7 +798,10 @@ parse_task_field (EEwsItem *item, const gchar *name, ESoapParameter *subparam)
 			priv->task_fields->body = e_soap_parameter_get_string_value (subparam);
 	} else if (!g_ascii_strcasecmp (name, "Owner")) {
 		priv->task_fields->owner = e_soap_parameter_get_string_value (subparam);
+	} else if (!g_ascii_strcasecmp (name, "Delegator")) {
+		priv->task_fields->delegator = e_soap_parameter_get_string_value (subparam);
 	}
+
 }
 
 static gboolean
@@ -1598,6 +1602,15 @@ e_ews_item_get_owner (EEwsItem *item)
 	return item->priv->task_fields->owner;
 }
 
+const gchar *
+e_ews_item_get_delegator (EEwsItem *item)
+{
+	g_return_val_if_fail (E_IS_EWS_ITEM(item), NULL);
+	g_return_val_if_fail (item->priv->task_fields != NULL, NULL);
+
+	return item->priv->task_fields->delegator;
+}
+
 gboolean
 e_ews_item_task_has_start_date (EEwsItem *item, gboolean *has_date)
 {
diff --git a/src/server/e-ews-item.h b/src/server/e-ews-item.h
index 0d766a5..736aa63 100644
--- a/src/server/e-ews-item.h
+++ b/src/server/e-ews-item.h
@@ -194,6 +194,7 @@ const gchar *	e_ews_item_get_percent_complete (EEwsItem *item);
 const gchar *	e_ews_item_get_sensitivity	(EEwsItem *item);
 const gchar *	e_ews_item_get_body		(EEwsItem *item);
 const gchar *	e_ews_item_get_owner		(EEwsItem *item);
+const gchar *	e_ews_item_get_delegator	(EEwsItem *item);
 time_t		e_ews_item_get_due_date		(EEwsItem *item);
 time_t		e_ews_item_get_start_date	(EEwsItem *item);
 time_t		e_ews_item_get_complete_date	(EEwsItem *item);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]