diff --git a/ActiveSync/NSData+ActiveSync.m b/ActiveSync/NSData+ActiveSync.m index 451668178..a665cd3ec 100644 --- a/ActiveSync/NSData+ActiveSync.m +++ b/ActiveSync/NSData+ActiveSync.m @@ -25,7 +25,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE #include #include -#define WBXMLDEBUG 0 +#define WBXMLDEBUG 1 @implementation NSData (ActiveSync) diff --git a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m index 91704c569..889b41999 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m +++ b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m @@ -177,10 +177,10 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE withType: (SOGoMicrosoftActiveSyncFolderType) theFolderType inBuffer: (NSMutableString *) theBuffer { - NSArray *additions; + NSMutableDictionary *allValues; NSString *clientId, *serverId; - NSDictionary *allValues; - + NSArray *additions; + id anAddition, sogoObject, o; int i; @@ -193,7 +193,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE anAddition = [additions objectAtIndex: i]; clientId = [[(id)[anAddition getElementsByTagName: @"ClientId"] lastObject] textValue]; - allValues = [[(id)[anAddition getElementsByTagName: @"ApplicationData"] lastObject] applicationData]; + allValues = [NSMutableDictionary dictionaryWithDictionary: [[(id)[anAddition getElementsByTagName: @"ApplicationData"] lastObject] applicationData]]; switch (theFolderType) { @@ -210,6 +210,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE serverId = [NSString stringWithFormat: @"%@.ics", [theCollection globallyUniqueObjectId]]; sogoObject = [[SOGoAppointmentObject alloc] initWithName: serverId inContainer: theCollection]; + [allValues setObject: [[[context activeUser] userDefaults] timeZone] forKey: @"SOGoUserTimeZone"]; o = [sogoObject component: YES secure: NO]; } break; @@ -218,6 +219,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE serverId = [NSString stringWithFormat: @"%@.ics", [theCollection globallyUniqueObjectId]]; sogoObject = [[SOGoTaskObject alloc] initWithName: serverId inContainer: theCollection]; + [allValues setObject: [[[context activeUser] userDefaults] timeZone] forKey: @"SOGoUserTimeZone"]; o = [sogoObject component: YES secure: NO]; } break; diff --git a/ActiveSync/iCalEvent+ActiveSync.m b/ActiveSync/iCalEvent+ActiveSync.m index f54c94628..afb6d9fe8 100644 --- a/ActiveSync/iCalEvent+ActiveSync.m +++ b/ActiveSync/iCalEvent+ActiveSync.m @@ -19,9 +19,13 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE */ #import "iCalEvent+ActiveSync.h" +#import +#import #import #import +#import +#import #import #include "iCalTimeZone+ActiveSync.h" @@ -84,7 +88,13 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE // - (void) takeActiveSyncValues: (NSDictionary *) theValues { + iCalDateTime *start, *end; + NSTimeZone *userTimeZone; + iCalTimeZone *tz; id o; + + NSInteger tzOffset; + BOOL isAllDay; if ((o = [theValues objectForKey: @"UID"])) [self setUid: o]; @@ -92,11 +102,56 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE if ((o = [theValues objectForKey: @"Subject"])) [self setSummary: o]; + isAllDay = NO; if ([[theValues objectForKey: @"AllDayEvent"] intValue]) { - + isAllDay = YES; } + // + // 0- free, 1- tentative, 2- busy and 3- out of office + // + if ((o = [theValues objectForKey: @"BusyStatus"])) + { + [o intValue]; + } + + // + // + // + if ((o = [theValues objectForKey: @"MeetingStatus"])) + { + [o intValue]; + } + + // + // 0- normal, 1- personal, 2- private and 3-confidential + // + if ((o = [theValues objectForKey: @"Sensitivy"])) + { + switch ([o intValue]) + { + case 2: + [self setAccessClass: @"PRIVATE"]; + break; + case 3: + [self setAccessClass: @"CONFIDENTIAL"]; + break; + case 0: + case 1: + default: + [self setAccessClass: @"PUBLIC"]; + } + } + + if ((o = [theValues objectForKey: @"TimeZone"])) + { + // Ugh, we ignore it for now. + userTimeZone = [theValues objectForKey: @"SOGoUserTimeZone"]; + tz = [iCalTimeZone timeZoneForName: [userTimeZone name]]; + [(iCalCalendar *) parent addTimeZone: tz]; + } + if ((o = [[theValues objectForKey: @"Body"] objectForKey: @"Data"])) [self setComment: o]; @@ -104,10 +159,46 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE [self setLocation: o]; if ((o = [theValues objectForKey: @"StartTime"])) - [self setStartDate: [o calendarDate]]; + { + o = [o calendarDate]; + start = (iCalDateTime *) [self uniqueChildWithTag: @"dtstart"]; + [start setTimeZone: tz]; + + if (isAllDay) + { + [start setDate: o]; + [start setTimeZone: nil]; + } + else + { + tzOffset = [userTimeZone secondsFromGMTForDate: o]; + o = [o dateByAddingYears: 0 months: 0 days: 0 + hours: 0 minutes: 0 + seconds: tzOffset]; + [start setDateTime: o]; + } + } if ((o = [theValues objectForKey: @"EndTime"])) - [self setEndDate: [o calendarDate]]; + { + o = [o calendarDate]; + end = (iCalDateTime *) [self uniqueChildWithTag: @"dtend"]; + [end setTimeZone: tz]; + + if (isAllDay) + { + [end setDate: o]; + [end setTimeZone: nil]; + } + else + { + tzOffset = [userTimeZone secondsFromGMTForDate: o]; + o = [o dateByAddingYears: 0 months: 0 days: 0 + hours: 0 minutes: 0 + seconds: tzOffset]; + [end setDateTime: o]; + } + } } @end