From fceec37a7b93b527ae91d52f28ba55e49abda2f7 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 2 Jul 2014 16:22:02 -0300 Subject: [PATCH 2/3] EDS: Store timezone display name into the cache list. It is safe to store the timezone display name instead of tzid, because the tzid value could contains the timezone prefix that will be hard to compare. --- src/backends/evolution/EvolutionCalendarSource.cpp | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/backends/evolution/EvolutionCalendarSource.cpp b/src/backends/evolution/EvolutionCalendarSource.cpp index 2bccde4..94cdc1e 100644 --- a/src/backends/evolution/EvolutionCalendarSource.cpp +++ b/src/backends/evolution/EvolutionCalendarSource.cpp @@ -545,29 +545,27 @@ EvolutionCalendarSource::InsertItemResult EvolutionCalendarSource::insertItem(co GErrorCXX gerror; const char *tzid = icaltimezone_get_tzid(zone); - //we are receiving two similar timezones names we will remove the prefix to make easy to compare - string timeZoneName(tzid); - std::size_t found = timeZoneName.find("/freeassociation.sourceforge.net/Tzfile/"); - if (found != std::string::npos) { - timeZoneName.replace(timeZoneName.begin(), timeZoneName.begin() + 40, ""); // 40 == strlen("/freeassociation.sourceforge.net/Tzfile/") - } - if (!tzid || !tzid[0]) { // cannot add a VTIMEZONE without TZID SE_LOG_DEBUG(getDisplayName(), "skipping VTIMEZONE without TZID"); - } else if (find(m_knownTimezones.begin(), m_knownTimezones.end(), timeZoneName) == m_knownTimezones.end()) { - gboolean success = + } else { + string timeZoneName(icaltimezone_get_display_name(zone)); + // check if the timezone was already registered in EDS + // Keeping a cache of already registered timezones will avoid some dbus call of "e_cal_client_add_timezone_sync" + if (find(m_knownTimezones.begin(), m_knownTimezones.end(), timeZoneName) == m_knownTimezones.end()) { + gboolean success = #ifdef USE_EDS_CLIENT - e_cal_client_add_timezone_sync(m_calendar, zone, NULL, gerror) + e_cal_client_add_timezone_sync(m_calendar, zone, NULL, gerror) #else - e_cal_add_timezone(m_calendar, zone, gerror) + e_cal_add_timezone(m_calendar, zone, gerror) #endif - ; - if (!success) { - throwError(SE_HERE, string("error adding VTIMEZONE ") + tzid, - gerror); - } else { - m_knownTimezones.push_back(timeZoneName); + ; + if (!success) { + throwError(SE_HERE, string("error adding VTIMEZONE ") + tzid, + gerror); + } else { + m_knownTimezones.push_back(timeZoneName); + } } } } -- 2.0.0