[evolution-ews] Fetch CompleteDate property of the Task



commit 3eb242a018a94b01be6c2cb1af2f312c09300360
Author: Pavel Ocheretny <pocheretny src gnome org>
Date:   Tue Jul 5 12:40:32 2011 +0300

    Fetch CompleteDate property of the Task

 src/calendar/e-cal-backend-ews.c |   11 ++++++++++-
 src/server/e-ews-item.c          |   30 ++++++++++++++++++++++++++++++
 src/server/e-ews-item.h          |    4 ++++
 3 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index d5e0b3a..fb18027 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -2269,7 +2269,7 @@ add_item_to_cache (ECalBackendEws *cbews, EEwsItem *item, gchar *uid)
 
 	if (e_ews_item_get_item_type (item) == E_EWS_ITEM_TYPE_TASK){
 		icalproperty *icalprop;
-		icaltimetype due_date, start_date;
+		icaltimetype due_date, start_date, complete_date;
 		icalproperty_status status  = ICAL_STATUS_NONE;
 		icalproperty_class class = ICAL_CLASS_NONE;
 		const char *ews_task_status, *sensitivity;
@@ -2317,6 +2317,15 @@ add_item_to_cache (ECalBackendEws *cbews, EEwsItem *item, gchar *uid)
 			icalcomponent_add_property (icalcomp, icalprop);
 		}
 
+		/*complete date*/
+		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);
+		}
 		/*priority*/
 		item_importance = e_ews_item_get_importance (item);
 		if (item_importance == EWS_ITEM_HIGH)
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index df05ec6..0e0d4f5 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -131,8 +131,10 @@ struct _EEwsTaskFields {
 	gchar *owner;
 	time_t due_date;
 	time_t start_date;
+	time_t complete_date;
 	gboolean has_due_date;
 	gboolean has_start_date;
+	gboolean has_complete_date;
 };
 
 struct _EEwsItemPrivate {
@@ -778,6 +780,12 @@ parse_task_field (EEwsItem *item, const gchar *name, ESoapParameter *subparam)
 		priv->task_fields->start_date = ews_item_parse_date (value);
 		g_free (value);
 		priv->task_fields->has_start_date = TRUE;
+	}
+	else if (!g_ascii_strcasecmp (name, "CompleteDate")) {
+		value = e_soap_parameter_get_string_value (subparam);
+		priv->task_fields->complete_date = ews_item_parse_date (value);
+		g_free (value);
+		priv->task_fields->has_complete_date = TRUE;
 	} else if (!g_ascii_strcasecmp (name, "Sensitivity")) {
 		priv->task_fields->sensitivity = e_soap_parameter_get_string_value (subparam);
 	} else if (!g_ascii_strcasecmp (name, "Body")) {
@@ -825,6 +833,7 @@ e_ews_item_set_from_soap_parameter (EEwsItem *item, ESoapParameter *param)
 		priv->task_fields = g_new0 (struct _EEwsTaskFields, 1);
 		priv->task_fields->has_due_date = FALSE;
 		priv->task_fields->has_start_date = FALSE;
+		priv->task_fields->has_complete_date = FALSE;
 	}
 	else if ((node = e_soap_parameter_get_first_child_by_name (param, "Item")))
 		priv->item_type = E_EWS_ITEM_TYPE_GENERIC_ITEM;
@@ -1543,6 +1552,7 @@ e_ews_item_get_due_date (EEwsItem *item)
 
 	return item->priv->task_fields->due_date;
 }
+
 time_t
 e_ews_item_get_start_date (EEwsItem *item)
 {
@@ -1552,6 +1562,15 @@ e_ews_item_get_start_date (EEwsItem *item)
 	return item->priv->task_fields->start_date;
 }
 
+time_t
+e_ews_item_get_complete_date (EEwsItem *item)
+{
+	g_return_val_if_fail (E_IS_EWS_ITEM(item), -1);
+	g_return_val_if_fail (item->priv->task_fields != NULL, -1);
+
+	return item->priv->task_fields->complete_date;
+}
+
 const gchar *
 e_ews_item_get_sensitivity (EEwsItem *item)
 {
@@ -1599,4 +1618,15 @@ e_ews_item_task_has_due_date (EEwsItem *item,  gboolean *has_date)
 	*has_date =  item->priv->task_fields->has_due_date;
 
 	return TRUE;
+}
+
+gboolean
+e_ews_item_task_has_complete_date (EEwsItem *item,  gboolean *has_date)
+{
+	g_return_val_if_fail (E_IS_EWS_ITEM(item), FALSE);
+	g_return_val_if_fail (item->priv->task_fields != NULL, FALSE);
+
+	*has_date =  item->priv->task_fields->has_complete_date;
+
+	return TRUE;
 }
\ No newline at end of file
diff --git a/src/server/e-ews-item.h b/src/server/e-ews-item.h
index 21d7dfd..0d766a5 100644
--- a/src/server/e-ews-item.h
+++ b/src/server/e-ews-item.h
@@ -196,10 +196,14 @@ const gchar *	e_ews_item_get_body		(EEwsItem *item);
 const gchar *	e_ews_item_get_owner		(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);
 gboolean	e_ews_item_task_has_start_date	(EEwsItem *item,
 						 gboolean *has_date);
 gboolean	e_ews_item_task_has_due_date	(EEwsItem *item,
 						 gboolean *has_date);
+gboolean	e_ews_item_task_has_complete_date
+						(EEwsItem* item,
+						 gboolean* has_date);
 
 G_END_DECLS
 



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