From 29c77f0ffb53f5045f3c49451898bb502e6f3d0a Mon Sep 17 00:00:00 2001 From: C Robert Date: Mon, 20 Jul 2009 18:20:44 +0000 Subject: [PATCH 1/2] iPhone + CalDAV fixed Monotone-Parent: 3c522ae41fe50f5ebe60bb22d26f407dc4c942d4 Monotone-Revision: 0bc72fc660e8d843466e5428a65d7ea595d8f88e Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-07-20T18:20:44 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 ++++ .../Appointments/SOGoAppointmentFolder.m | 40 +++++++++++-------- SoObjects/SOGo/WORequest+SOGo.h | 1 + SoObjects/SOGo/WORequest+SOGo.m | 19 +++++++++ 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 051daa279..f1e41d577 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-07-20 Cyril Robert + + * SoObjects/Appointments/SOGoAppointmentFolder.m (davResourceType): Removed + a few things for the iPhone calDAV sync (schedule-inbox, schedule-outbox, + vevent-collection, vtodo-collection). + * SoObjects/SOGo/WORequest+SOGo.m (isIPhone): Added new method to detect + iPhone's DAV client. + 2009-07-20 Francis Lachapelle * SoObjects/Appointments/SOGoAppointmentFolder.m diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index aa5f28ce2..3891da764 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -2216,29 +2216,37 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir NSMutableArray *colType; NSArray *gdRT, *gdVEventCol, *gdVTodoCol; NSString *login; + WORequest *request; colType = [NSMutableArray arrayWithCapacity: 10]; [colType addObject: @"collection"]; [colType addObject: [NSArray arrayWithObjects: @"calendar", XMLNS_CALDAV, nil]]; - gdRT = [self groupDavResourceType]; - gdVEventCol = [NSArray arrayWithObjects: [gdRT objectAtIndex: 0], - XMLNS_GROUPDAV, nil]; - [colType addObject: gdVEventCol]; - gdVTodoCol = [NSArray arrayWithObjects: [gdRT objectAtIndex: 1], - XMLNS_GROUPDAV, nil]; - [colType addObject: gdVTodoCol]; - if ([nameInContainer isEqualToString: @"personal"]) + // WARNING + // don't touch unless you're going to re-test caldav sync + // with an iPhone AND lightning + request = [context request]; + if (![request isIPhone]) { - login = [[context activeUser] login]; - if ([login isEqualToString: [self ownerInContext: self]]) + gdRT = [self groupDavResourceType]; + gdVEventCol = [NSArray arrayWithObjects: [gdRT objectAtIndex: 0], + XMLNS_GROUPDAV, nil]; + [colType addObject: gdVEventCol]; + gdVTodoCol = [NSArray arrayWithObjects: [gdRT objectAtIndex: 1], + XMLNS_GROUPDAV, nil]; + [colType addObject: gdVTodoCol]; + if ([nameInContainer isEqualToString: @"personal"]) { -// [colType addObject: [NSArray arrayWithObjects: @"schedule-calendar", -// XMLNS_CALDAV, nil]]; - [colType addObject: [NSArray arrayWithObjects: @"schedule-inbox", - XMLNS_CALDAV, nil]]; - [colType addObject: [NSArray arrayWithObjects: @"schedule-outbox", - XMLNS_CALDAV, nil]]; + login = [[context activeUser] login]; + if ([login isEqualToString: [self ownerInContext: self]]) + { + // [colType addObject: [NSArray arrayWithObjects: @"schedule-calendar", + // XMLNS_CALDAV, nil]]; + [colType addObject: [NSArray arrayWithObjects: @"schedule-inbox", + XMLNS_CALDAV, nil]]; + [colType addObject: [NSArray arrayWithObjects: @"schedule-outbox", + XMLNS_CALDAV, nil]]; + } } } diff --git a/SoObjects/SOGo/WORequest+SOGo.h b/SoObjects/SOGo/WORequest+SOGo.h index 67c872637..b480f63a0 100644 --- a/SoObjects/SOGo/WORequest+SOGo.h +++ b/SoObjects/SOGo/WORequest+SOGo.h @@ -29,6 +29,7 @@ - (BOOL) handledByDefaultHandler; - (NSDictionary *) davPatchedPropertiesWithTopTag: (NSString *) topTag; +- (BOOL) isIPhone; @end diff --git a/SoObjects/SOGo/WORequest+SOGo.m b/SoObjects/SOGo/WORequest+SOGo.m index 46264e12c..e05b9fc9e 100644 --- a/SoObjects/SOGo/WORequest+SOGo.m +++ b/SoObjects/SOGo/WORequest+SOGo.m @@ -25,6 +25,7 @@ #import #import +#import #import @@ -102,4 +103,22 @@ return patchedProperties; } +- (BOOL) isIPhone +{ + WEClientCapabilities *cc; + BOOL rc; + + rc = NO; + cc = [self clientCapabilities]; + if ([[cc userAgentType] isEqualToString: @"AppleDAVAccess"]) + { + NSRange r = [[cc userAgent] rangeOfString: @"iPhone"]; + if (r.location != NSNotFound) + rc = YES; + } + + return rc; +} + + @end From 86a694e5e1e320fb339808b8d1e0dc17a3050258 Mon Sep 17 00:00:00 2001 From: C Robert Date: Mon, 20 Jul 2009 18:23:44 +0000 Subject: [PATCH 2/2] Added scary comments Monotone-Parent: 0bc72fc660e8d843466e5428a65d7ea595d8f88e Monotone-Revision: ff4ded519351216e33ec0fa734612c05b21917d1 Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-07-20T18:23:44 Monotone-Branch: ca.inverse.sogo --- SOPE/NGCards/iCalPerson.m | 3 +++ SoObjects/Appointments/SOGoAppointmentFolder.m | 6 ++++++ SoObjects/Appointments/SOGoFreeBusyObject.m | 3 +++ 3 files changed, 12 insertions(+) diff --git a/SOPE/NGCards/iCalPerson.m b/SOPE/NGCards/iCalPerson.m index 77df8b154..58a48dfd0 100644 --- a/SOPE/NGCards/iCalPerson.m +++ b/SOPE/NGCards/iCalPerson.m @@ -55,6 +55,9 @@ - (void) setEmail: (NSString *)_s { + // WARNING + // don't touch unless you're going to re-test caldav sync + // with an iPhone AND lightning [self setValue: 0 to: [NSString stringWithFormat: @"mailto:%@", _s]]; } diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 3891da764..5936df5a5 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1999,6 +1999,9 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir content = [NSMutableArray array]; + // WARNING + // don't touch unless you're going to re-test caldav sync + // with an iPhone AND lightning [content addObject: davElementWithContent (@"recipient", XMLNS_CALDAV, recipient)]; if (user) { @@ -2122,6 +2125,9 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir response = [context response]; if (tags) { + // WARNING + // don't touch unless you're going to re-test caldav sync + // with an iPhone AND lightning [response setStatus: 200]; [response appendContentString: @""]; diff --git a/SoObjects/Appointments/SOGoFreeBusyObject.m b/SoObjects/Appointments/SOGoFreeBusyObject.m index d2b43b790..509f807ae 100644 --- a/SoObjects/Appointments/SOGoFreeBusyObject.m +++ b/SoObjects/Appointments/SOGoFreeBusyObject.m @@ -80,6 +80,9 @@ static unsigned int freebusyRangeEnd = 0; um = [LDAPUserManager sharedUserManager]; contactInfos = [um contactInfosForUserWithUIDorEmail: uid]; + // WARNING + // don't touch unless you're going to re-test caldav sync + // with an iPhone AND lightning person = [iCalPerson new]; [person autorelease]; [person setEmail: [contactInfos objectForKey: @"c_email"]];