summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyncEvolution Nightly Testing <syncevolution@syncevolution.org>2016-08-26 11:50:05 -0700
committerSyncEvolution Nightly Testing <syncevolution@syncevolution.org>2016-08-26 11:50:05 -0700
commitb954754bad89d46ffebbfad6b27ce966ed71684e (patch)
tree51fe21ebb3dfc59345936873ee566ca4606b5a30
parent3974869e398afe53e3f8f2a654e688e6b1892944 (diff)
parent0f05614a62066175a88376255791e906a6710ad9 (diff)
WIP on nightly: 3974869 syncsession.h: fix TDevInfResultsCommand::shrinkCommand()master-next
-rw-r--r--src/platform_adapters/linux/platform_timezones.cpp52
1 files changed, 47 insertions, 5 deletions
diff --git a/src/platform_adapters/linux/platform_timezones.cpp b/src/platform_adapters/linux/platform_timezones.cpp
index 792a4e2..9344fcf 100644
--- a/src/platform_adapters/linux/platform_timezones.cpp
+++ b/src/platform_adapters/linux/platform_timezones.cpp
@@ -58,6 +58,7 @@ static struct {
void *(* icalarray_element_at_p)(icalarray *array, unsigned index);
icalcomponent *(* icaltimezone_get_component_p)(icaltimezone *zone);
char *(* icalcomponent_as_ical_string_p)(icalcomponent *comp);
+ void (* icaltzutil_set_exact_vtimezones_support)(int on);
bool must_free_strings;
} icalcontext;
@@ -86,6 +87,8 @@ static icalarray *ICALTIMEZONE_GET_BUILTIN_TIMEZONES()
(typeof(icalcontext.icalcomponent_as_ical_string_p))dlsym(RTLD_DEFAULT, "icalcomponent_as_ical_string");
icalcontext.must_free_strings = dlsym(RTLD_DEFAULT, "ical_memfixes") != NULL;
}
+ icaltzutil_set_exact_vtimezones_support =
+ (typeof(icalcontext.icaltzutil_set_exact_vtimezones_support))dlsym(RTLD_DEFAULT, "icaltzutil_set_exact_vtimezones_support");
return icalcontext.icaltimezone_get_builtin_timezones_p ?
icalcontext.icaltimezone_get_builtin_timezones_p() :
@@ -99,6 +102,31 @@ static void *ICALARRAY_ELEMENT_AT(icalarray *array, unsigned index)
NULL;
}
+static size_t ICALARRAY_NUM_ELEMENTS(icalarray *array)
+{
+ struct icalarray_traditional {
+ unsigned int element_size;
+ unsigned int increment_size;
+ unsigned int num_elements;
+ unsigned int space_allocated;
+ void *data;
+ };
+ // libical v2 changed to size_t
+ struct icalarray_v2 {
+ size_t element_size;
+ size_t increment_size;
+ size_t num_elements;
+ size_t space_allocated;
+ void **chunks;
+ };
+ // distinguish between v2 and older based on
+ // icaltzutil_set_exact_vtimezones_support, which was introduced in
+ // v2
+ return icalcontext.icaltzutil_set_exact_vtimezones_support ?
+ static_cast<icalarray_v2 *>(array)->num_elements :
+ static_cast<icalarray_traditional *>(array)->num_elements;
+}
+
static icalcomponent *ICALTIMEZONE_GET_COMPONENT(icaltimezone *zone)
{
return icalcontext.icaltimezone_get_component_p ?
@@ -119,10 +147,17 @@ static void ICAL_FREE(char *str)
free(str);
}
+static void ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT(int on)
+{
+ if (icalcontext.icaltzutil_set_exact_vtimezones_support)
+ icaltzutil_set_exact_vtimezones_support(on);
+}
+
#else
// call functions directly
# define ICALTIMEZONE_GET_BUILTIN_TIMEZONES icaltimezone_get_builtin_timezones
# define ICALARRAY_ELEMENT_AT icalarray_element_at
+# define ICALARRAY_NUM_ELEMENTS(_array) (size_t)((_array)->num_elements)
# define ICALTIMEZONE_GET_COMPONENT icaltimezone_get_component
# if defined(HAVE_LIBICAL) && !defined(HAVE_LIBECAL)
@@ -169,12 +204,19 @@ void finalizeSystemZoneDefinitions(GZones* aGZones)
icalarray *builtin = ICALTIMEZONE_GET_BUILTIN_TIMEZONES();
#ifdef EVOLUTION_COMPATIBILITY
PLOGDEBUGPRINTFX(aGZones->getDbgLogger, DBG_PARSE+DBG_EXOTIC,
- ("runtime check: libical %s",
- icalcontext.icaltimezone_get_builtin_timezones_p ? "available" : "unavailable"))
-#elif defined(USE_ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT)
+ ("runtime check: libical %s, %s icaltzutil_set_exact_vtimezones_support",
+ icalcontext.icaltimezone_get_builtin_timezones_p ? "available" : "unavailable",
+ icalcontext.icaltzutil_set_exact_vtimezones_support ? "with" : "without"));
+ // If we end up using the libical code (and not some replacement
+ // provided by SyncEvolution, which is the solution for distros with
+ // a libical that doesn't have the API), then enable timezones in the
+ // format more useful for us.
+ //
// We want interoperable timezones with one entry for summer time and one for winter time.
// That's what libsynthesis and other devices can handle, and not the exact definitions
// with the full set of transitions.
+ ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT(0);
+#elif defined(USE_ICALTZUTIL_SET_EXACT_VTIMEZONES_SUPPORT)
icaltzutil_set_exact_vtimezones_support(0);
#endif
if (!builtin) {
@@ -183,8 +225,8 @@ void finalizeSystemZoneDefinitions(GZones* aGZones)
return;
}
PLOGDEBUGPRINTFX(aGZones->getDbgLogger, DBG_PARSE+DBG_EXOTIC,
- ("%d time zones from libical", builtin->num_elements));
- for (unsigned i = 0; builtin && i < builtin->num_elements; i++) {
+ ("%lu time zones from libical", (unsigned long)ICALARRAY_NUM_ELEMENTS(builtin)));
+ for (size_t i = 0; builtin && i < ICALARRAY_NUM_ELEMENTS(builtin); i++) {
icaltimezone *zone = (icaltimezone *)ICALARRAY_ELEMENT_AT(builtin, i);
if (!zone)
continue;