oc-calendar: Use the calendar's time zone if it is present

If the event was created by the MAPI client, the client's time zone (if
present) is assigned to the event's calendar in iCalEvent+MAPIStore.
This way, we can use it to deliver the event's properties correctly.
This commit is contained in:
Juan Vallés
2015-12-16 18:49:09 +01:00
parent 4ae5feb131
commit 376e717f45
9 changed files with 73 additions and 119 deletions
+2 -3
View File
@@ -24,6 +24,7 @@
#define MAPISTORECALENDARWRAPPER_H #define MAPISTORECALENDARWRAPPER_H
#import <NGCards/iCalPerson.h> #import <NGCards/iCalPerson.h>
#import <NGCards/iCalTimeZone.h>
#import <Appointments/iCalEntityObject+SOGo.h> #import <Appointments/iCalEntityObject+SOGo.h>
#import "MAPIStoreObjectProxy.h" #import "MAPIStoreObjectProxy.h"
@@ -42,7 +43,7 @@
iCalCalendar *calendar; iCalCalendar *calendar;
iCalEvent *firstEvent; iCalEvent *firstEvent;
iCalEvent *event; iCalEvent *event;
NSTimeZone *timeZone; iCalTimeZone *timeZone;
SOGoUser *user; SOGoUser *user;
NSString *senderEmail; NSString *senderEmail;
NSData *globalObjectId; NSData *globalObjectId;
@@ -57,12 +58,10 @@
+ (id) wrapperWithICalEvent: (iCalEvent *) newEvent + (id) wrapperWithICalEvent: (iCalEvent *) newEvent
andUser: (SOGoUser *) newUser andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo; withConnectionInfo: (struct mapistore_connection_info *) newConnInfo;
- (id) initWithICalEvent: (iCalEvent *) newEvent - (id) initWithICalEvent: (iCalEvent *) newEvent
andUser: (SOGoUser *) newUser andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo; withConnectionInfo: (struct mapistore_connection_info *) newConnInfo;
/* getters */ /* getters */
+46 -103
View File
@@ -37,7 +37,9 @@
#import <NGCards/iCalEventChanges.h> #import <NGCards/iCalEventChanges.h>
#import <NGCards/iCalPerson.h> #import <NGCards/iCalPerson.h>
#import <NGCards/iCalTrigger.h> #import <NGCards/iCalTrigger.h>
#import <NGCards/iCalTimeZonePeriod.h>
#import <NGCards/NSString+NGCards.h> #import <NGCards/NSString+NGCards.h>
#import <SOGo/SOGoDomainDefaults.h>
#import <SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserManager.h> #import <SOGo/SOGoUserManager.h>
@@ -80,7 +82,6 @@ static NSCharacterSet *hexCharacterSet = nil;
+ (id) wrapperWithICalEvent: (iCalEvent *) newEvent + (id) wrapperWithICalEvent: (iCalEvent *) newEvent
andUser: (SOGoUser *) newUser andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
{ {
MAPIStoreAppointmentWrapper *wrapper; MAPIStoreAppointmentWrapper *wrapper;
@@ -88,7 +89,6 @@ static NSCharacterSet *hexCharacterSet = nil;
wrapper = [[self alloc] initWithICalEvent: newEvent wrapper = [[self alloc] initWithICalEvent: newEvent
andUser: newUser andUser: newUser
andSenderEmail: newSenderEmail andSenderEmail: newSenderEmail
inTimeZone: newTimeZone
withConnectionInfo: newConnInfo]; withConnectionInfo: newConnInfo];
[wrapper autorelease]; [wrapper autorelease];
@@ -182,10 +182,10 @@ static NSCharacterSet *hexCharacterSet = nil;
- (id) initWithICalEvent: (iCalEvent *) newEvent - (id) initWithICalEvent: (iCalEvent *) newEvent
andUser: (SOGoUser *) newUser andUser: (SOGoUser *) newUser
andSenderEmail: (NSString *) newSenderEmail andSenderEmail: (NSString *) newSenderEmail
inTimeZone: (NSTimeZone *) newTimeZone
withConnectionInfo: (struct mapistore_connection_info *) newConnInfo withConnectionInfo: (struct mapistore_connection_info *) newConnInfo
{ {
NSArray *events; NSArray *events;
iCalTimeZone *tz;
if ((self = [self init])) if ((self = [self init]))
{ {
@@ -194,9 +194,20 @@ static NSCharacterSet *hexCharacterSet = nil;
event = newEvent; event = newEvent;
events = [calendar events]; events = [calendar events];
firstEvent = [events objectAtIndex: 0]; firstEvent = [events objectAtIndex: 0];
ASSIGN (timeZone, newTimeZone);
ASSIGN (user, newUser); ASSIGN (user, newUser);
ASSIGN (senderEmail, newSenderEmail); ASSIGN (senderEmail, newSenderEmail);
/* If newEvent comes from the client, we set its time zone in
updateFromMAPIProperties. If it is not present, we use the
time zone of the user */
tz = (iCalTimeZone *) [calendar firstChildWithTag: @"vtimezone"];
if (!tz)
{
tz = [iCalTimeZone timeZoneForName: [[[user userDefaults] timeZone] name]];
if (!tz)
[self logWithFormat: @"no time zone could be set"];
}
ASSIGN (timeZone, tz);
[self _setupITIPContext]; [self _setupITIPContext];
} }
@@ -721,22 +732,15 @@ static NSCharacterSet *hexCharacterSet = nil;
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
NSCalendarDate *dateValue; NSCalendarDate *dateValue;
NSInteger offset;
// if ([event isRecurrent]) // if ([event isRecurrent])
// dateValue = [event firstRecurrenceStartDate]; // dateValue = [event firstRecurrenceStartDate];
// else // else
dateValue = [event startDate]; dateValue = [event startDate];
if ([event isAllDay]) if ([event isAllDay])
{ dateValue = [timeZone shiftedCalendarDateForDate: dateValue];
offset = -[timeZone secondsFromGMTForDate: dateValue];
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0
seconds: offset];
}
[dateValue setTimeZone: utcTZ];
*data = [dateValue asFileTimeInMemCtx: memCtx]; *data = [dateValue asFileTimeInMemCtx: memCtx];
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
@@ -749,22 +753,14 @@ static NSCharacterSet *hexCharacterSet = nil;
exceptions, where it is the normal start date for the day of the exceptions, where it is the normal start date for the day of the
exception. */ exception. */
NSCalendarDate *dateValue; NSCalendarDate *dateValue;
NSInteger offset;
dateValue = [event recurrenceId]; dateValue = [event recurrenceId];
if (!dateValue) if (!dateValue)
dateValue = [event startDate]; dateValue = [event startDate];
[dateValue setTimeZone: timeZone];
if ([event isAllDay]) if ([event isAllDay])
{ dateValue = [timeZone shiftedCalendarDateForDate: dateValue];
offset = -[timeZone secondsFromGMTForDate: dateValue];
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0
seconds: offset];
}
[dateValue setTimeZone: utcTZ];
*data = [dateValue asFileTimeInMemCtx: memCtx]; *data = [dateValue asFileTimeInMemCtx: memCtx];
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
@@ -772,19 +768,12 @@ static NSCharacterSet *hexCharacterSet = nil;
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
NSCalendarDate *dateValue; NSCalendarDate *dateValue;
NSInteger offset;
dateValue = [firstEvent startDate]; dateValue = [firstEvent startDate];
if ([firstEvent isAllDay]) if ([firstEvent isAllDay])
{ dateValue = [timeZone shiftedCalendarDateForDate: dateValue];
offset = -[timeZone secondsFromGMTForDate: dateValue];
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0
seconds: offset];
}
[dateValue setTimeZone: utcTZ];
*data = [dateValue asFileTimeInMemCtx: memCtx]; *data = [dateValue asFileTimeInMemCtx: memCtx];
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
@@ -804,8 +793,8 @@ static NSCharacterSet *hexCharacterSet = nil;
month: [start monthOfYear] month: [start monthOfYear]
day: [start dayOfMonth] day: [start dayOfMonth]
hour: 0 minute: 0 second: 0 hour: 0 minute: 0 second: 0
timeZone: timeZone]; timeZone: utcTZ];
[dateValue setTimeZone: utcTZ]; dateValue = [timeZone shiftedCalendarDateForDate: dateValue];
*data = [dateValue asFileTimeInMemCtx: memCtx]; *data = [dateValue asFileTimeInMemCtx: memCtx];
rc = MAPISTORE_SUCCESS; rc = MAPISTORE_SUCCESS;
} }
@@ -829,7 +818,7 @@ static NSCharacterSet *hexCharacterSet = nil;
dateValue = [event startDate]; dateValue = [event startDate];
offset = [event durationAsTimeInterval]; offset = [event durationAsTimeInterval];
if ([event isAllDay]) if ([event isAllDay])
offset -= [timeZone secondsFromGMTForDate: dateValue]; offset -= [[timeZone periodForDate: dateValue] secondsOffsetFromGMT];
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0 dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0 hours: 0 minutes: 0
seconds: offset]; seconds: offset];
@@ -847,15 +836,14 @@ static NSCharacterSet *hexCharacterSet = nil;
dateValue = [event recurrenceId]; dateValue = [event recurrenceId];
if (!dateValue) if (!dateValue)
dateValue = [event startDate]; dateValue = [event startDate];
[dateValue setTimeZone: timeZone];
offset = [firstEvent durationAsTimeInterval]; offset = [firstEvent durationAsTimeInterval];
if ([firstEvent isAllDay]) if ([firstEvent isAllDay])
offset -= [timeZone secondsFromGMTForDate: dateValue]; offset -= [[timeZone periodForDate: dateValue] secondsOffsetFromGMT];
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0 dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0 hours: 0 minutes: 0
seconds: offset]; seconds: offset];
*data = [dateValue asFileTimeInMemCtx: memCtx]; *data = [dateValue asFileTimeInMemCtx: memCtx];
return MAPISTORE_SUCCESS; return MAPISTORE_SUCCESS;
} }
@@ -871,7 +859,7 @@ static NSCharacterSet *hexCharacterSet = nil;
dateValue = [firstEvent startDate]; dateValue = [firstEvent startDate];
offset = [firstEvent durationAsTimeInterval]; offset = [firstEvent durationAsTimeInterval];
if ([event isAllDay]) if ([event isAllDay])
offset -= [timeZone secondsFromGMTForDate: dateValue]; offset -= [[timeZone periodForDate: dateValue] secondsOffsetFromGMT];
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0 dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0 hours: 0 minutes: 0
seconds: offset]; seconds: offset];
@@ -885,23 +873,14 @@ static NSCharacterSet *hexCharacterSet = nil;
{ {
enum mapistore_error rc; enum mapistore_error rc;
NSCalendarDate *dateValue; NSCalendarDate *dateValue;
NSInteger offset;
iCalRecurrenceRule *rrule; iCalRecurrenceRule *rrule;
if ([event isRecurrent]) if ([event isRecurrent])
{ {
rrule = [[event recurrenceRules] objectAtIndex: 0]; rrule = [[event recurrenceRules] objectAtIndex: 0];
dateValue = [rrule untilDate]; dateValue = [rrule untilDate];
if (dateValue) if (dateValue && [event isAllDay])
{ dateValue = [timeZone shiftedCalendarDateForDate: dateValue];
if ([event isAllDay])
offset = -[timeZone secondsFromGMTForDate: dateValue];
else
offset = 0;
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0
seconds: offset];
}
else else
dateValue = [NSCalendarDate dateWithYear: 4500 month: 8 day: 31 dateValue = [NSCalendarDate dateWithYear: 4500 month: 8 day: 31
hour: 23 minute: 59 second: 00 hour: 23 minute: 59 second: 00
@@ -1338,21 +1317,14 @@ static NSCharacterSet *hexCharacterSet = nil;
{ {
enum mapistore_error rc; enum mapistore_error rc;
NSCalendarDate *dateValue; NSCalendarDate *dateValue;
NSInteger offset;
dateValue = [event recurrenceId]; dateValue = [event recurrenceId];
if (dateValue) if (dateValue)
{ {
rc = MAPISTORE_SUCCESS; rc = MAPISTORE_SUCCESS;
if ([event isAllDay]) if ([event isAllDay])
{ dateValue = [timeZone shiftedCalendarDateForDate: dateValue];
offset = -[timeZone secondsFromGMTForDate: dateValue];
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0
seconds: offset];
}
[dateValue setTimeZone: utcTZ];
*data = [dateValue asFileTimeInMemCtx: memCtx]; *data = [dateValue asFileTimeInMemCtx: memCtx];
} }
else else
@@ -1377,7 +1349,6 @@ static NSCharacterSet *hexCharacterSet = nil;
iCalEventChanges *changes; iCalEventChanges *changes;
NSArray *changedProperties; NSArray *changedProperties;
NSCalendarDate *dateValue; NSCalendarDate *dateValue;
NSInteger offset;
changes = [iCalEventChanges changesFromEvent: event toEvent: exceptionEvent]; changes = [iCalEventChanges changesFromEvent: event toEvent: exceptionEvent];
@@ -1385,28 +1356,17 @@ static NSCharacterSet *hexCharacterSet = nil;
memset (extendedException, 0, sizeof (struct ExtendedException)); memset (extendedException, 0, sizeof (struct ExtendedException));
extendedException->ChangeHighlight.Size = sizeof (uint32_t); extendedException->ChangeHighlight.Size = sizeof (uint32_t);
dateValue = [exceptionEvent startDate]; dateValue = [timeZone computedDateForDate: [exceptionEvent startDate]];
offset = [timeZone secondsFromGMTForDate: dateValue];
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0
seconds: offset];
exceptionInfo->StartDateTime = [dateValue asMinutesSince1601]; exceptionInfo->StartDateTime = [dateValue asMinutesSince1601];
extendedException->ChangeHighlight.Value = BIT_CH_START; extendedException->ChangeHighlight.Value = BIT_CH_START;
extendedException->StartDateTime = exceptionInfo->StartDateTime; extendedException->StartDateTime = exceptionInfo->StartDateTime;
dateValue = [exceptionEvent endDate]; dateValue = [timeZone computedDateForDate: [exceptionEvent endDate]];
offset = [timeZone secondsFromGMTForDate: dateValue];
dateValue = [dateValue dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0
seconds: offset];
exceptionInfo->EndDateTime = [dateValue asMinutesSince1601]; exceptionInfo->EndDateTime = [dateValue asMinutesSince1601];
extendedException->ChangeHighlight.Value |= BIT_CH_END; extendedException->ChangeHighlight.Value |= BIT_CH_END;
extendedException->EndDateTime = exceptionInfo->EndDateTime; extendedException->EndDateTime = exceptionInfo->EndDateTime;
dateValue = [[exceptionEvent recurrenceId] dateValue = [timeZone computedDateForDate: [exceptionEvent recurrenceId]];
dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 0
seconds: offset];
exceptionInfo->OriginalStartDate = [dateValue asMinutesSince1601]; exceptionInfo->OriginalStartDate = [dateValue asMinutesSince1601];
extendedException->OriginalStartDate = exceptionInfo->OriginalStartDate; extendedException->OriginalStartDate = exceptionInfo->OriginalStartDate;
@@ -1464,7 +1424,6 @@ static NSCharacterSet *hexCharacterSet = nil;
arp = talloc_zero (NULL, struct AppointmentRecurrencePattern); arp = talloc_zero (NULL, struct AppointmentRecurrencePattern);
[rule fillRecurrencePattern: &arp->RecurrencePattern [rule fillRecurrencePattern: &arp->RecurrencePattern
withEvent: event withEvent: event
inTimeZone: timeZone
inMemCtx: arp]; inMemCtx: arp];
arp->ReaderVersion2 = 0x00003006; arp->ReaderVersion2 = 0x00003006;
arp->WriterVersion2 = 0x00003008; /* 0x3008 for compatibility with arp->WriterVersion2 = 0x00003008; /* 0x3008 for compatibility with
@@ -1475,7 +1434,7 @@ static NSCharacterSet *hexCharacterSet = nil;
fields are relative to midnight of those days ([MS-OXOCAL] 2.2.1.44.5), fields are relative to midnight of those days ([MS-OXOCAL] 2.2.1.44.5),
so no time zone adjustment is needed */ so no time zone adjustment is needed */
if (![event isAllDay]) if (![event isAllDay])
[firstStartDate setTimeZone: timeZone]; firstStartDate = [timeZone computedDateForDate: firstStartDate];
startMinutes = ([firstStartDate hourOfDay] * 60 startMinutes = ([firstStartDate hourOfDay] * 60
+ [firstStartDate minuteOfHour]); + [firstStartDate minuteOfHour]);
arp->StartTimeOffset = startMinutes; arp->StartTimeOffset = startMinutes;
@@ -1701,15 +1660,16 @@ ReservedBlockEE2Size: 00 00 00 00
fromDate: (NSCalendarDate *) instanceDate; fromDate: (NSCalendarDate *) instanceDate;
{ {
uint16_t year; uint16_t year;
NSCalendarDate *dateValue;
if (instanceDate) if (instanceDate)
{ {
[instanceDate setTimeZone: timeZone]; dateValue = [timeZone computedDateForDate: instanceDate];
year = [instanceDate yearOfCommonEra]; year = [dateValue yearOfCommonEra];
newGlobalId->YH = year >> 8; newGlobalId->YH = year >> 8;
newGlobalId->YL = year & 0xff; newGlobalId->YL = year & 0xff;
newGlobalId->Month = [instanceDate monthOfYear]; newGlobalId->Month = [dateValue monthOfYear];
newGlobalId->D = [instanceDate dayOfMonth]; newGlobalId->D = [dateValue dayOfMonth];
} }
} }
@@ -1974,7 +1934,6 @@ ReservedBlockEE2Size: 00 00 00 00
if (alarm) if (alarm)
{ {
alarmDate = [alarm nextAlarmDate]; alarmDate = [alarm nextAlarmDate];
[alarmDate setTimeZone: utcTZ];
*data = [alarmDate asFileTimeInMemCtx: memCtx]; *data = [alarmDate asFileTimeInMemCtx: memCtx];
} }
else else
@@ -2036,8 +1995,7 @@ ReservedBlockEE2Size: 00 00 00 00
enum mapistore_error rc; enum mapistore_error rc;
NSString *tzid; NSString *tzid;
tzid = [(iCalDateTime *) [event firstChildWithTag: @"dtstart"] tzid = [timeZone tzId];
value: 0 ofAttribute: @"tzid"];
if ([tzid length] > 0) if ([tzid length] > 0)
{ {
*data = [tzid asUnicodeInMemCtx: memCtx]; *data = [tzid asUnicodeInMemCtx: memCtx];
@@ -2053,16 +2011,9 @@ ReservedBlockEE2Size: 00 00 00 00
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
enum mapistore_error rc; enum mapistore_error rc;
iCalTimeZone *icalTZ;
icalTZ = [(iCalDateTime *) [event firstChildWithTag: @"dtstart"] timeZone]; *data = [timeZone asTimeZoneStructInMemCtx: memCtx];
if (icalTZ) rc = MAPISTORE_SUCCESS;
{
*data = [icalTZ asTimeZoneStructInMemCtx: memCtx];
rc = MAPISTORE_SUCCESS;
}
else
rc = MAPISTORE_ERR_NOT_FOUND;
return rc; return rc;
} }
@@ -2071,24 +2022,16 @@ ReservedBlockEE2Size: 00 00 00 00
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
enum mapistore_error rc; enum mapistore_error rc;
iCalTimeZone *icalTZ;
/* [MS-OXOCAL] 3.1.5.5.1: This property is used in floating (all-day) events, /* [MS-OXOCAL] 3.1.5.5.1: This property is used in floating (all-day) events,
specified in floating time, to convert the start date from UTC to the user's specified in floating time, to convert the start date from UTC to the user's
time zone */ time zone */
if ([event isAllDay]) if ([event isAllDay] | [event isRecurrent])
icalTZ = [iCalTimeZone timeZoneForName: [timeZone timeZoneName]];
else if ([event isRecurrent])
icalTZ = [(iCalDateTime *) [event firstChildWithTag: @"dtstart"] timeZone];
else
icalTZ = nil;
if (icalTZ)
{ {
/* [MS-OXOCAL] 2.2.1.42: This property can only have the E flag set in the /* [MS-OXOCAL] 2.2.1.42: This property can only have the E flag set in the
TimeZoneDefinition struct */ TimeZoneDefinition struct */
*data = [icalTZ asZoneTimeDefinitionWithFlags: TZRULE_FLAG_EFFECTIVE_TZREG *data = [timeZone asZoneTimeDefinitionWithFlags: TZRULE_FLAG_EFFECTIVE_TZREG
inMemCtx: memCtx]; inMemCtx: memCtx];
rc = MAPISTORE_SUCCESS; rc = MAPISTORE_SUCCESS;
} }
else else
@@ -58,7 +58,6 @@
wrapperWithICalEvent: [newContainer event] wrapperWithICalEvent: [newContainer event]
andUser: [userContext sogoUser] andUser: [userContext sogoUser]
andSenderEmail: nil andSenderEmail: nil
inTimeZone: [userContext timeZone]
withConnectionInfo: [context connectionInfo]]; withConnectionInfo: [context connectionInfo]];
[self addProxy: appointmentWrapper]; [self addProxy: appointmentWrapper];
} }
-1
View File
@@ -197,7 +197,6 @@ static Class NSArrayK, MAPIStoreAppointmentWrapperK;
= [MAPIStoreAppointmentWrapper wrapperWithICalEvent: masterEvent = [MAPIStoreAppointmentWrapper wrapperWithICalEvent: masterEvent
andUser: [userContext sogoUser] andUser: [userContext sogoUser]
andSenderEmail: nil andSenderEmail: nil
inTimeZone: [userContext timeZone]
withConnectionInfo: [context connectionInfo]]; withConnectionInfo: [context connectionInfo]];
[self addProxy: appointmentWrapper]; [self addProxy: appointmentWrapper];
} }
-1
View File
@@ -340,7 +340,6 @@ _compareBodyKeysByPriority (id entry1, id entry2, void *data)
wrapperWithICalEvent: event wrapperWithICalEvent: event
andUser: [context activeUser] andUser: [context activeUser]
andSenderEmail: senderEmail andSenderEmail: senderEmail
inTimeZone: [[self userContext] timeZone]
withConnectionInfo: [context connectionInfo]]; withConnectionInfo: [context connectionInfo]];
[appointmentWrapper retain]; [appointmentWrapper retain];
} }
-5
View File
@@ -25,14 +25,10 @@
#include <talloc.h> #include <talloc.h>
#import <Foundation/NSTimeZone.h>
#import <NGCards/iCalCalendar.h> #import <NGCards/iCalCalendar.h>
#import <NGCards/iCalRecurrenceRule.h> #import <NGCards/iCalRecurrenceRule.h>
#import <NGCards/iCalTimeZone.h> #import <NGCards/iCalTimeZone.h>
@class NSTimeZone;
@class iCalEvent; @class iCalEvent;
@class iCalRepeatableEntityObject; @class iCalRepeatableEntityObject;
@class iCalRecurrenceRule; @class iCalRecurrenceRule;
@@ -55,7 +51,6 @@
- (void) fillRecurrencePattern: (struct RecurrencePattern *) rp - (void) fillRecurrencePattern: (struct RecurrencePattern *) rp
withEvent: (iCalEvent *) event withEvent: (iCalEvent *) event
inTimeZone: (NSTimeZone *) timeZone
inMemCtx: (TALLOC_CTX *) memCtx; inMemCtx: (TALLOC_CTX *) memCtx;
@end @end
+1 -5
View File
@@ -24,7 +24,6 @@
#import <Foundation/NSCalendarDate.h> #import <Foundation/NSCalendarDate.h>
#import <Foundation/NSSet.h> #import <Foundation/NSSet.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
#import <Foundation/NSTimeZone.h>
#import <NGExtensions/NSCalendarDate+misc.h> #import <NGExtensions/NSCalendarDate+misc.h>
#import <NGExtensions/NSObject+Logs.h> #import <NGExtensions/NSObject+Logs.h>
@@ -265,7 +264,6 @@
- (void) fillRecurrencePattern: (struct RecurrencePattern *) rp - (void) fillRecurrencePattern: (struct RecurrencePattern *) rp
withEvent: (iCalEvent *) event withEvent: (iCalEvent *) event
inTimeZone: (NSTimeZone *) timeZone
inMemCtx: (TALLOC_CTX *) memCtx inMemCtx: (TALLOC_CTX *) memCtx
{ {
iCalRecurrenceFrequency freq; iCalRecurrenceFrequency freq;
@@ -281,10 +279,8 @@
NSMutableArray *deletedDates, *modifiedDates; NSMutableArray *deletedDates, *modifiedDates;
startDate = [event firstRecurrenceStartDate]; startDate = [event firstRecurrenceStartDate];
[startDate setTimeZone: timeZone];
endDate = [event lastPossibleRecurrenceStartDate]; endDate = [event lastPossibleRecurrenceStartDate];
[endDate setTimeZone: timeZone];
rp->ReaderVersion = 0x3004; rp->ReaderVersion = 0x3004;
rp->WriterVersion = 0x3004; rp->WriterVersion = 0x3004;
+2
View File
@@ -33,6 +33,8 @@
- (iCalTimeZone *) iCalTimeZoneFromDefinition: (NSData *) value - (iCalTimeZone *) iCalTimeZoneFromDefinition: (NSData *) value
withDescription: (NSString *) description withDescription: (NSString *) description
inMemCtx: (TALLOC_CTX *) memCtx; inMemCtx: (TALLOC_CTX *) memCtx;
- (NSCalendarDate *) shiftedCalendarDateForDate: (NSCalendarDate *) date;
@end @end
+22
View File
@@ -40,6 +40,7 @@
#include <libmapi/libmapi.h> #include <libmapi/libmapi.h>
#import "iCalTimeZone+MAPIStore.h" #import "iCalTimeZone+MAPIStore.h"
#import "MAPIStoreTypes.h"
@interface iCalTimeZonePeriod (MAPIStorePropertiesPrivate) @interface iCalTimeZonePeriod (MAPIStorePropertiesPrivate)
@@ -352,4 +353,25 @@ end:
return tz; return tz;
} }
/**
* Adjust a date in this vTimeZone to its representation in UTC
* Example: Timezone is +0001, the date is 2015-12-15 00:00:00 +0000
* it returns 2015-12-14 23:00:00 +0000
* @param date the date to adjust to the timezone.
* @return a new GMT date adjusted with the offset of the timezone.
*/
- (NSCalendarDate *) shiftedCalendarDateForDate: (NSCalendarDate *) date
{
NSCalendarDate *tmpDate;
tmpDate = [date copy];
[tmpDate autorelease];
[tmpDate setTimeZone: utcTZ];
return [tmpDate addYear: 0 month: 0 day: 0
hour: 0 minute: 0
second: -[[self periodForDate: tmpDate] secondsOffsetFromGMT]];
}
@end @end