[evolution-ews] Check if Task has start date and due date



commit 8ceb0b17776776cef11bf6bcbdd3623dc629596e
Author: Pavel Ocheretny <pocheretny src gnome org>
Date:   Tue Jul 5 11:33:49 2011 +0300

    Check if Task has start date and due date

 src/calendar/e-cal-backend-ews.c |   20 +++++++++++++-----
 src/server/e-ews-item.c          |   40 ++++++++++++++++++++++++++++++++-----
 src/server/e-ews-item.h          |    4 +++
 3 files changed, 52 insertions(+), 12 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 69c895b..d5e0b3a 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -2275,6 +2275,7 @@ add_item_to_cache (ECalBackendEws *cbews, EEwsItem *item, gchar *uid)
 		const char *ews_task_status, *sensitivity;
 		EwsImportance item_importance;
 		int priority = 5;
+		gboolean has_this_date = FALSE;
 
 		vcomp = icalcomponent_new (ICAL_VCALENDAR_COMPONENT);
 		/*subject*/
@@ -2300,14 +2301,21 @@ add_item_to_cache (ECalBackendEws *cbews, EEwsItem *item, gchar *uid)
 		icalcomponent_add_property (icalcomp, icalprop);
 
 		/*due date*/
-		due_date = icaltime_from_timet_with_zone (e_ews_item_get_due_date (item), 0, priv->default_zone);
-		icalprop = icalproperty_new_due (due_date);
-		icalcomponent_add_property (icalcomp, icalprop);
+		e_ews_item_task_has_due_date (item, &has_this_date);
+		if (has_this_date) {
+			due_date = icaltime_from_timet_with_zone (e_ews_item_get_due_date (item), 0, priv->default_zone);
+			icalprop = icalproperty_new_due (due_date);
+			icalcomponent_add_property (icalcomp, icalprop);
+		}
 
 		/*start date*/
-		start_date = icaltime_from_timet_with_zone (e_ews_item_get_start_date (item), 0, priv->default_zone);
-		icalprop = icalproperty_new_dtstart (start_date);
-		icalcomponent_add_property (icalcomp, icalprop);
+		has_this_date = FALSE;
+		e_ews_item_task_has_start_date (item, &has_this_date);
+		if (has_this_date) {
+			start_date = icaltime_from_timet_with_zone (e_ews_item_get_start_date (item), 0, priv->default_zone);
+			icalprop = icalproperty_new_dtstart (start_date);
+			icalcomponent_add_property (icalcomp, icalprop);
+		}
 
 		/*priority*/
 		item_importance = e_ews_item_get_importance (item);
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index 2b853fc..a724597 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -131,6 +131,8 @@ struct _EEwsTaskFields {
 	gchar *owner;
 	time_t due_date;
 	time_t start_date;
+	gboolean has_due_date;
+	gboolean has_start_date;
 };
 
 struct _EEwsItemPrivate {
@@ -767,13 +769,15 @@ parse_task_field (EEwsItem *item, const gchar *name, ESoapParameter *subparam)
 	} else if (!g_ascii_strcasecmp (name, "PercentComplete")) {
 		priv->task_fields->percent_complete = e_soap_parameter_get_string_value (subparam);
 	} else if (!g_ascii_strcasecmp (name, "DueDate")) {
-			value = e_soap_parameter_get_string_value (subparam);
-			priv->task_fields->due_date = ews_item_parse_date (value);
-			g_free (value);
+		value = e_soap_parameter_get_string_value (subparam);
+		priv->task_fields->due_date = ews_item_parse_date (value);
+		g_free (value);
+		priv->task_fields->has_due_date = TRUE;
 	} else if (!g_ascii_strcasecmp (name, "StartDate")) {
-			value = e_soap_parameter_get_string_value (subparam);
-			priv->task_fields->start_date = ews_item_parse_date (value);
-			g_free (value);
+		value = e_soap_parameter_get_string_value (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, "Sensitivity")) {
 		priv->task_fields->sensitivity = e_soap_parameter_get_string_value (subparam);
 	} else if (!g_ascii_strcasecmp (name, "Body")) {
@@ -816,6 +820,8 @@ e_ews_item_set_from_soap_parameter (EEwsItem *item, ESoapParameter *param)
 		task = TRUE;
 		priv->item_type = E_EWS_ITEM_TYPE_TASK;
 		priv->task_fields = g_new0 (struct _EEwsTaskFields, 1);
+		priv->task_fields->has_due_date = FALSE;
+		priv->task_fields->has_start_date = FALSE;
 	}
 	else if ((node = e_soap_parameter_get_first_child_by_name (param, "Item")))
 		priv->item_type = E_EWS_ITEM_TYPE_GENERIC_ITEM;
@@ -1568,4 +1574,26 @@ e_ews_item_get_owner (EEwsItem *item)
 	g_return_val_if_fail (item->priv->task_fields != NULL, NULL);
 
 	return item->priv->task_fields->owner;
+}
+
+gboolean
+e_ews_item_task_has_start_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_start_date;
+
+	return TRUE;
+}
+
+gboolean
+e_ews_item_task_has_due_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_due_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 f407bf2..21d7dfd 100644
--- a/src/server/e-ews-item.h
+++ b/src/server/e-ews-item.h
@@ -196,6 +196,10 @@ 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);
+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);
 
 G_END_DECLS
 



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