diff --git a/ChangeLog b/ChangeLog index 2f00edb37..ed8c5bedd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2012-03-30 Wolfgang Sourdeau + * OpenChange/MAPIStoreTasksMessage.m (-save): do not reset fields + that have not been passed in the properties array, since only + RopDeleteProperties should remove them. + + * OpenChange/MAPIStoreObject.m (-addPropertiesFromRow:): dates are + now all converted to the user's timezone, even though it just + inverts the problem we currently have. + * OpenChange/MAPIApplication.m (-init): utcTZ is now initialized here. diff --git a/OpenChange/MAPIStoreCalendarMessage.m b/OpenChange/MAPIStoreCalendarMessage.m index 6890fe172..70aa0b64a 100644 --- a/OpenChange/MAPIStoreCalendarMessage.m +++ b/OpenChange/MAPIStoreCalendarMessage.m @@ -770,6 +770,8 @@ tz = [iCalTimeZone timeZoneForName: tzName]; [vCalendar addTimeZone: tz]; } + else + tz = nil; // start value = [properties objectForKey: MAPIPropertyKey (PR_START_DATE)]; @@ -779,18 +781,18 @@ if (value) { start = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtstart"]; + [start setTimeZone: tz]; if (isAllDay) + { + [start setDate: value]; + [start setTimeZone: nil]; + } + else { tzOffset = [[value timeZone] secondsFromGMTForDate: value]; value = [value dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 - seconds: -tzOffset]; - [start setTimeZone: nil]; - [start setDate: value]; - } - else - { - [start setTimeZone: tz]; + seconds: tzOffset]; [start setDateTime: value]; } } @@ -802,18 +804,18 @@ if (value) { end = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtend"]; + [end setTimeZone: tz]; if (isAllDay) + { + [end setDate: value]; + [end setTimeZone: nil]; + } + else { tzOffset = [[value timeZone] secondsFromGMTForDate: value]; value = [value dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 - seconds: -tzOffset]; - [end setTimeZone: nil]; - [end setDate: value]; - } - else - { - [end setTimeZone: tz]; + seconds: tzOffset]; [end setDateTime: value]; } } diff --git a/OpenChange/MAPIStoreMailVolatileMessage.m b/OpenChange/MAPIStoreMailVolatileMessage.m index 2d5a937e5..3a3d66be3 100644 --- a/OpenChange/MAPIStoreMailVolatileMessage.m +++ b/OpenChange/MAPIStoreMailVolatileMessage.m @@ -29,6 +29,7 @@ #import #import #import +#import #import #import #import @@ -495,7 +496,11 @@ FillMessageHeadersFromProperties (NGMutableHashMap *headers, date = [mailProperties objectForKey: MAPIPropertyKey (PR_CLIENT_SUBMIT_TIME)]; if (date) - [headers addObject: [date rfc822DateString] forKey: @"date"]; + { + date = [date addYear: 0 month: 0 day: 0 + hour: 0 minute: 0 second: [[date timeZone] secondsFromGMT]]; + [headers addObject: [date rfc822DateString] forKey: @"date"]; + } [headers addObject: @"1.0" forKey: @"MIME-Version"]; } diff --git a/OpenChange/MAPIStoreObject.m b/OpenChange/MAPIStoreObject.m index f2f8d0ebe..fd727e180 100644 --- a/OpenChange/MAPIStoreObject.m +++ b/OpenChange/MAPIStoreObject.m @@ -20,7 +20,9 @@ * Boston, MA 02111-1307, USA. */ +#import #import +#import #import #import #import @@ -432,16 +434,37 @@ static Class NSExceptionK, MAPIStoreFolderK; struct SPropValue *cValue; NSUInteger counter; NSMutableDictionary *newProperties; + NSTimeZone *tz; + NSInteger tzOffset; + id value; + + tz = nil; newProperties = [NSMutableDictionary dictionaryWithCapacity: aRow->cValues]; for (counter = 0; counter < aRow->cValues; counter++) { cValue = aRow->lpProps + counter; - if ((cValue->ulPropTag & 0xfff) == PT_STRING8) - [self warnWithFormat: - @"attempting to set string property as PR_STRING8: %.8x", - cValue->ulPropTag]; - [newProperties setObject: NSObjectFromSPropValue (cValue) + value = NSObjectFromSPropValue (cValue); + switch (cValue->ulPropTag & 0xffff) + { + case PT_STRING8: + case PT_MV_STRING8: + [self warnWithFormat: + @"attempting to set string property as PR_STRING8: %.8x", + cValue->ulPropTag]; + break; + case PT_SYSTIME: + if (!tz) + { + tz = [[self userContext] timeZone]; + tzOffset = -[tz secondsFromGMT]; + } + value = [value addYear: 0 month: 0 day: 0 + hour: 0 minute: 0 second: tzOffset]; + [value setTimeZone: tz]; + break; + } + [newProperties setObject: value forKey: MAPIPropertyKey (cValue->ulPropTag)]; } diff --git a/OpenChange/MAPIStoreTasksMessage.m b/OpenChange/MAPIStoreTasksMessage.m index 963c04a0b..cad848f76 100644 --- a/OpenChange/MAPIStoreTasksMessage.m +++ b/OpenChange/MAPIStoreTasksMessage.m @@ -329,7 +329,8 @@ iCalToDo *vToDo; id value; iCalDateTime *date; - NSString *status, *priority; + iCalTimeZone *tz; + NSString *status, *priority, *tzName; NSCalendarDate *now; NSInteger tzOffset; double doubleValue; @@ -338,6 +339,10 @@ vCalendar = [vToDo parent]; [vCalendar setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"]; + tzName = [[[self userContext] timeZone] name]; + tz = [iCalTimeZone timeZoneForName: tzName]; + [vCalendar addTimeZone: tz]; + // summary value = [properties objectForKey: MAPIPropertyKey (PR_NORMALIZED_SUBJECT_UNICODE)]; @@ -358,12 +363,12 @@ value = [value htmlToText]; } } - if (value && [value length] == 0) - value = nil; - [vToDo setComment: value]; - if (value) - [vToDo setComment: value]; + { + if ([value length] == 0) + value = nil; + [vToDo setComment: value]; + } // location value = [properties objectForKey: MAPIPropertyKey (PidLidLocation)]; @@ -388,31 +393,17 @@ if (value) { date = (iCalDateTime *) [vToDo uniqueChildWithTag: @"dtstart"]; - tzOffset = [[value timeZone] secondsFromGMTForDate: value]; - value = [value dateByAddingYears: 0 months: 0 days: 0 - hours: 0 minutes: 0 - seconds: -tzOffset]; - [date setDate: value]; + [date setTimeZone: tz]; + [date setDateTime: value]; } - else - { - [vToDo setStartDate: nil]; - } - + // due value = [properties objectForKey: MAPIPropertyKey (PidLidTaskDueDate)]; if (value) { date = (iCalDateTime *) [vToDo uniqueChildWithTag: @"due"]; - tzOffset = [[value timeZone] secondsFromGMTForDate: value]; - value = [value dateByAddingYears: 0 months: 0 days: 0 - hours: 0 minutes: 0 - seconds: -tzOffset]; - [date setDate: value]; - } - else - { - [vToDo setDue: nil]; + [date setTimeZone: tz]; + [date setDateTime: value]; } // completed @@ -426,10 +417,6 @@ seconds: -tzOffset]; [date setDate: value]; } - else - { - [vToDo setCompleted: nil]; - } // status value = [properties objectForKey: MAPIPropertyKey (PidLidTaskStatus)]; @@ -459,10 +446,8 @@ default: // IMPORTANCE_NORMAL priority = @"5"; } + [vToDo setPriority: priority]; } - else - priority = @"0"; // None - [vToDo setPriority: priority]; // percent complete // NOTE: this does not seem to work on Outlook 2003. PidLidPercentComplete's value