[evolution-ews] Fetch and use Task AllProperties, fix some white spaces. still have to fix the priority issue



commit 409700baf2d66f38dfb8994c1713365a9a276a84
Author: Pavel Ocheretny <pocheretny src gnome org>
Date:   Thu Jun 30 10:34:19 2011 +0300

    Fetch and use Task AllProperties, fix some white spaces.
    still have to fix the priority issue

 src/calendar/e-cal-backend-ews.c |   67 +++++++++++++++++++++++++++-----------
 src/server/e-ews-item.c          |   43 +++++++++++++++++++++++-
 src/server/e-ews-item.h          |    3 ++
 3 files changed, 93 insertions(+), 20 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index b756b15..f330616 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -2206,45 +2206,74 @@ add_item_to_cache (ECalBackendEws *cbews, EEwsItem *item, gchar *uid)
 	kind = e_cal_backend_get_kind ((ECalBackend *) cbews);
 	priv = cbews->priv;
 
-	if (e_ews_item_get_item_type(item)==E_EWS_ITEM_TYPE_TASK){
+	if (e_ews_item_get_item_type (item) == E_EWS_ITEM_TYPE_TASK){
 		icalproperty *icalprop;
 		icaltimetype due_date, start_date;
 		icalproperty_status status  = ICAL_STATUS_NONE;
-		const char *ews_task_status;
-		vcomp = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
+		icalproperty_class class = ICAL_CLASS_NONE;
+		const char *ews_task_status, *sensitivity;
+		EwsImportance item_importance;
+		int priority = 2;
+
+		vcomp = icalcomponent_new (ICAL_VCALENDAR_COMPONENT);
 		/*subject*/
-		icalcomp = icalcomponent_new(ICAL_VTODO_COMPONENT);
-		icalprop = icalproperty_new_summary(e_ews_item_get_subject(item));
-		icalcomponent_add_property(icalcomp, icalprop);
+		icalcomp = icalcomponent_new (ICAL_VTODO_COMPONENT);
+		icalprop = icalproperty_new_summary (e_ews_item_get_subject (item));
+		icalcomponent_add_property (icalcomp, icalprop);
 		/*status*/
 		ews_task_status = e_ews_item_get_status (item);
 		if (!g_strcmp0(ews_task_status, "NotStarted") == 0) {
 			if (g_strcmp0 (ews_task_status, "Completed") == 0)
 				status = ICAL_STATUS_COMPLETED;
-			else if (g_strcmp0(ews_task_status, "InProgress") == 0)
+			else if (g_strcmp0 (ews_task_status, "InProgress") == 0)
 				status = ICAL_STATUS_INPROCESS;
-			else if (g_strcmp0(ews_task_status, "WaitingOnOthers") == 0)
+			else if (g_strcmp0 (ews_task_status, "WaitingOnOthers") == 0)
 				status = ICAL_STATUS_NEEDSACTION;
-			else if (g_strcmp0(ews_task_status, "Deferred") == 0)
+			else if (g_strcmp0 (ews_task_status, "Deferred") == 0)
 				status = ICAL_STATUS_CANCELLED;
-			icalprop = icalproperty_new_status(status);
-			icalcomponent_add_property(icalcomp, icalprop);
+			icalprop = icalproperty_new_status (status);
+			icalcomponent_add_property (icalcomp, icalprop);
 			}
 		/*precent complete*/
-		icalprop  = icalproperty_new_percentcomplete (atoi(e_ews_item_get_percent_complete(item)));
-		icalcomponent_add_property(icalcomp, icalprop);
+		icalprop  = icalproperty_new_percentcomplete (atoi (e_ews_item_get_percent_complete (item)));
+		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);
+		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);
+		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);
+		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);
+		icalcomponent_add_property (icalcomp, icalprop);
+
+		/*priority*/
+		item_importance = e_ews_item_get_importance (item);
+		if (item_importance == EWS_ITEM_HIGH)
+			priority = 3;
+		else if (item_importance == EWS_ITEM_LOW)
+			priority = 1;
+		icalprop = icalproperty_new_priority (priority);
+		icalcomponent_add_property (icalcomp, icalprop);
+
+		/*sensitivity*/
+		sensitivity = e_ews_item_get_sensitivity (item);
+		if (g_strcmp0 (sensitivity, "Normal") == 0)
+			class = ICAL_CLASS_PUBLIC;
+		else if (g_strcmp0 (sensitivity, "Private") == 0)
+			class = ICAL_CLASS_PRIVATE;
+		else if ((g_strcmp0 (sensitivity, "Confidential") == 0) ||
+			 (g_strcmp0 (sensitivity, "Personal") == 0))
+			class = ICAL_CLASS_CONFIDENTIAL;
+		icalprop = icalproperty_new_class (class);
+		icalcomponent_add_property (icalcomp, icalprop);
+
+		/*description*/
+		icalprop = icalproperty_new_description (e_ews_item_get_body (item));
+		icalcomponent_add_property (icalcomp, icalprop);
 
-		icalcomponent_add_component(vcomp,icalcomp);
+		icalcomponent_add_component (vcomp,icalcomp);
 	} else {
 		mime_content = e_ews_item_get_mime_content (item);
 		vcomp = icalparser_parse_string (mime_content);
@@ -2589,7 +2618,7 @@ ews_cal_sync_items_ready_cb (GObject *obj, GAsyncResult *res, gpointer user_data
 	if (task_item_ids)
 		e_ews_connection_get_items_start (g_object_ref (cnc), EWS_PRIORITY_MEDIUM,
 						  task_item_ids,
-						  "Default",
+						  "AllProperties",
 						  NULL,
 						  FALSE,
 						  NULL,
diff --git a/src/server/e-ews-item.c b/src/server/e-ews-item.c
index c7ea1fb..4a195d8 100644
--- a/src/server/e-ews-item.c
+++ b/src/server/e-ews-item.c
@@ -126,6 +126,9 @@ struct _EEwsContactFields {
 struct _EEwsTaskFields {
 	gchar *percent_complete;
 	gchar *status;
+	gchar *body;
+	gchar *sensitivity;
+	gchar *owner;
 	time_t due_date;
 	time_t start_date;
 };
@@ -273,7 +276,12 @@ e_ews_item_dispose (GObject *object)
 		priv->task_fields->percent_complete = NULL;
 		g_free (priv->task_fields->status);
 		priv->task_fields->status = NULL;
-		g_free (priv->task_fields->status);
+		g_free (priv->task_fields->body);
+		priv->task_fields->body = NULL;
+		g_free (priv->task_fields->sensitivity);
+		priv->task_fields->sensitivity = NULL;
+		g_free (priv->task_fields->owner);
+		priv->task_fields->owner = NULL;
 		g_free (priv->task_fields);
 	}
 
@@ -747,6 +755,12 @@ parse_task_field (EEwsItem *item, const gchar *name, ESoapParameter *subparam)
 			value = e_soap_parameter_get_string_value (subparam);
 			priv->task_fields->start_date = ews_item_parse_date (value);
 			g_free (value);
+	} 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")) {
+		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);
 	}
 }
 
@@ -1507,3 +1521,30 @@ e_ews_item_get_start_date (EEwsItem *item)
 
 	return item->priv->task_fields->start_date;
 }
+
+const gchar *
+e_ews_item_get_sensitivity (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->sensitivity;
+}
+
+const gchar *
+e_ews_item_get_body (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->body;
+}
+
+const gchar *
+e_ews_item_get_owner (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->owner;
+}
\ No newline at end of file
diff --git a/src/server/e-ews-item.h b/src/server/e-ews-item.h
index 482940b..f407bf2 100644
--- a/src/server/e-ews-item.h
+++ b/src/server/e-ews-item.h
@@ -191,6 +191,9 @@ const gchar *	e_ews_item_get_surname		(EEwsItem *item);
 /*Task fields*/
 const gchar *	e_ews_item_get_status		(EEwsItem *item);
 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);
 time_t		e_ews_item_get_due_date		(EEwsItem *item);
 time_t		e_ews_item_get_start_date	(EEwsItem *item);
 



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