diff options
author | Milan Crha <mcrha@redhat.com> | 2011-10-18 19:08:51 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-10-19 05:11:23 +0800 |
commit | c3d83e74a902cb21da840a2f959f67f3c529034c (patch) | |
tree | 8391dc2d51b83d847bd4d237ef962449fea32d5e | |
parent | 2737df7a379792860e6746c591820b063a5a3020 (diff) | |
download | gsoc2013-evolution-c3d83e74a902cb21da840a2f959f67f3c529034c.tar gsoc2013-evolution-c3d83e74a902cb21da840a2f959f67f3c529034c.tar.gz gsoc2013-evolution-c3d83e74a902cb21da840a2f959f67f3c529034c.tar.bz2 gsoc2013-evolution-c3d83e74a902cb21da840a2f959f67f3c529034c.tar.lz gsoc2013-evolution-c3d83e74a902cb21da840a2f959f67f3c529034c.tar.xz gsoc2013-evolution-c3d83e74a902cb21da840a2f959f67f3c529034c.tar.zst gsoc2013-evolution-c3d83e74a902cb21da840a2f959f67f3c529034c.zip |
Bug #661549 - Avoid fetching from backend when calculating summary
-rw-r--r-- | 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 2a762e411d..ebaede4257 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -2066,23 +2066,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; + } } } |