[evolution/gnome-3-2] Bug #661549 - Avoid fetching from backend when calculating summary



commit ca84e1012daa1a4bf16a273c29b547aa4a276d01
Author: Milan Crha <mcrha redhat com>
Date:   Tue Oct 18 13:12:15 2011 +0200

    Bug #661549 - Avoid fetching from backend when calculating summary

 calendar/gui/e-calendar-view.c |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)
---
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 82bbea2..8e9d151 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -2102,23 +2102,31 @@ e_calendar_view_get_icalcomponent_summary (ECalClient *client,
 
 	if (icalcomp_contains_category (icalcomp, _("Birthday")) ||
 	    icalcomp_contains_category (icalcomp, _("Anniversary"))) {
-		struct icaltimetype dtstart, dtnow;
-		icalcomponent *item_icalcomp = NULL;
-
-		if (e_cal_client_get_object_sync (client,
-				      icalcomponent_get_uid (icalcomp),
-				      icalcomponent_get_relcalid (icalcomp),
-				      &item_icalcomp,
-				      NULL, NULL)) {
-			dtstart = icalcomponent_get_dtstart (item_icalcomp);
-			dtnow = icalcomponent_get_dtstart (icalcomp);
-
-			if (dtnow.year - dtstart.year > 0) {
-				summary = g_strdup_printf ("%s (%d)", summary ? summary : "", dtnow.year - dtstart.year);
-				*free_text = summary != NULL;
-			}
+		icalproperty *xprop;
+
+		for (xprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
+		     xprop;
+		     xprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY)) {
+			const gchar *xname = icalproperty_get_x_name (xprop);
+
+			if (xname && g_ascii_strcasecmp (xname, "X-EVOLUTION-SINCE-YEAR") == 0) {
+				struct icaltimetype dtnow;
+				gint since_year;
+				gchar *str;
+
+				str = icalproperty_get_value_as_string_r (xprop);
+				since_year = str ? atoi (str) : 0;
+				g_free (str);
 
-			icalcomponent_free (item_icalcomp);
+				dtnow = icalcomponent_get_dtstart (icalcomp);
+
+				if (since_year > 0 && dtnow.year - since_year > 0) {
+					summary = g_strdup_printf ("%s (%d)", summary ? summary : "", dtnow.year - since_year);
+					*free_text = summary != NULL;
+				}
+
+				break;
+			}
 		}
 	}
 



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