From 1db7523e1186cf198360d8d59411497aa070ce06 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 17 Jun 2009 15:19:19 +0000 Subject: [PATCH 1/5] Monotone-Parent: 9995223a0452fd05c8a2bc29a4e75bddaa07438b Monotone-Revision: e41f59857cafb636d38404bf829a9113c529ffd6 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-06-17T15:19:19 Monotone-Branch: ca.inverse.sogo --- SoObjects/SOGo/SOGoObject.m | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index f38c0b7f6..27544ceb5 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -544,7 +544,7 @@ SEL SOGoSelectorForPropertySetter (NSString *property) NSDictionary *currentGrant, *userHREF; NSString *principalURL; - currentAce = [NSMutableArray new]; + currentAce = [NSMutableArray array]; roles = [[SOGoUser userWithLogin: currentUID roles: nil] rolesForObject: self inContext: context]; @@ -562,7 +562,6 @@ SEL SOGoSelectorForPropertySetter (NSString *property) [currentAce addObject: currentGrant]; [aces addObject: davElementWithContent (@"ace", @"DAV:", currentAce)]; } - [currentAce release]; } - (void) _fillAcesWithRolesForPseudoPrincipals: (NSMutableArray *) aces @@ -644,7 +643,7 @@ SEL SOGoSelectorForPropertySetter (NSString *property) NSMutableArray *responses; NSArray *responseElements; - responses = [NSMutableArray new]; + responses = [NSMutableArray array]; hrefList = [hrefs objectEnumerator]; while ((currentHref = [hrefList nextObject])) @@ -660,7 +659,6 @@ SEL SOGoSelectorForPropertySetter (NSString *property) } multiStatus = davElementWithContent (@"multistatus", @"DAV:", responses); - [responses release]; return multiStatus; } @@ -697,11 +695,10 @@ SEL SOGoSelectorForPropertySetter (NSString *property) NSMutableArray *hrefs; NSDictionary *response; - hrefs = [NSMutableArray new]; + hrefs = [NSMutableArray array]; [self _fillArrayWithPrincipalsOwnedBySelf: hrefs]; response = [self _formalizePrincipalMatchResponse: hrefs]; - [hrefs release]; return response; } From fd86551b7ca194b89659ef53edcefaf06538e049 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 17 Jun 2009 15:19:33 +0000 Subject: [PATCH 2/5] Monotone-Parent: e41f59857cafb636d38404bf829a9113c529ffd6 Monotone-Revision: 9206c6ee4874fb4fa96b7e7571eb10c5832e1f29 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-06-17T15:19:33 Monotone-Branch: ca.inverse.sogo --- SoObjects/Appointments/SOGoAppointmentFolder.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 69ef36604..c05431067 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -462,7 +462,8 @@ static NSArray *reducedReportQueryFields = nil; [self initializeQuickTablesAclsInContext: context]; grantedClasses = [NSMutableArray arrayWithCapacity: 3]; deniedClasses = [NSMutableArray arrayWithCapacity: 3]; - for (currentClass = 0; currentClass < iCalAccessClassCount; currentClass++) + for (currentClass = 0; + currentClass < iCalAccessClassCount; currentClass++) { classNumber = [NSNumber numberWithInt: currentClass]; if (userCanAccessObjectsClassifiedAs[currentClass]) @@ -477,10 +478,14 @@ static NSArray *reducedReportQueryFields = nil; privacySqlString = [NSString stringWithFormat: @"c_classification != %@", [deniedClasses objectAtIndex: 0]]; - else + else if (grantedCount == 1) privacySqlString = [NSString stringWithFormat: @"c_classification == %@", [grantedClasses objectAtIndex: 0]]; + else + /* We prevent any event/task from being listed. There must be a better + way... */ + privacySqlString = @"0 == 1"; } return privacySqlString; From fdca4383309948f9810ee83bc637f8201176fe5e Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 17 Jun 2009 15:26:54 +0000 Subject: [PATCH 3/5] Monotone-Parent: 9206c6ee4874fb4fa96b7e7571eb10c5832e1f29 Monotone-Revision: c9ad04cf940b51e28fe7c5aaea670fb0da5e3456 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-06-17T15:26:54 Monotone-Branch: ca.inverse.sogo --- SoObjects/Appointments/SOGoAppointmentFolder.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index c05431067..fa3626b1e 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1415,6 +1415,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir return filterData; } +/* TODO: This method should be generalized to all SOGoGCSFolder-based + classes. */ - (NSDictionary *) _parseRequestedProperties: (id ) parentNode { NSMutableDictionary *properties; From 6a58d17252f415a3becadb8683dab79ca4821c11 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 17 Jun 2009 15:55:35 +0000 Subject: [PATCH 4/5] Monotone-Parent: c9ad04cf940b51e28fe7c5aaea670fb0da5e3456 Monotone-Revision: 796c6bb92f7f6f97be354aeb3b35c39751605e50 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-06-17T15:55:35 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 +++ SoObjects/Appointments/SOGoAppointmentFolder.m | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9b642fa3..351521547 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2009-06-17 Wolfgang Sourdeau + * SoObjects/Appointments/SOGoAppointmentFolder.m + (-fetchFields:...): don't use the privacySqlString twice. + * UI/MailPartViewers/UIxMailPartICalViewer.m (-storedEventObject): use the new "storedEventFetched" bool ivar to specify whether we already attempted to fetch the event from the user calendars. diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index fa3626b1e..79a898acb 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -480,12 +480,12 @@ static NSArray *reducedReportQueryFields = nil; [deniedClasses objectAtIndex: 0]]; else if (grantedCount == 1) privacySqlString - = [NSString stringWithFormat: @"c_classification == %@", + = [NSString stringWithFormat: @"c_classification = %@", [grantedClasses objectAtIndex: 0]]; else /* We prevent any event/task from being listed. There must be a better way... */ - privacySqlString = @"0 == 1"; + privacySqlString = @"c_classification = 255"; } return privacySqlString; @@ -1027,8 +1027,8 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir /* fetch recurrent apts now. we do NOT consider events with no cycle end. */ if (_endDate || filters) { - sql = [NSString stringWithFormat: @"(c_iscycle = 1) %@ %@ %@ %@", titleSqlString, - componentSqlString, privacySqlString, filterSqlString]; + sql = [NSString stringWithFormat: @"(c_iscycle = 1) %@ %@ %@", titleSqlString, + componentSqlString, filterSqlString]; qualifier = [EOQualifier qualifierWithQualifierFormat: sql]; From 71fe9f878bb18ba7afe1f0ec7ac7d997d98313bc Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 17 Jun 2009 18:07:23 +0000 Subject: [PATCH 5/5] Monotone-Parent: 796c6bb92f7f6f97be354aeb3b35c39751605e50 Monotone-Revision: 3b018c57691598e10f6e73b0f7fc31137f869040 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-06-17T18:07:23 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 + .../Appointments/SOGoAppointmentFolder.m | 98 +++++++------------ 2 files changed, 41 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index 351521547..e2080f784 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ * SoObjects/Appointments/SOGoAppointmentFolder.m (-fetchFields:...): don't use the privacySqlString twice. + The component parameter MUST be a NSString from now on. Fixed a + syntax problem in the where clause occuring when vtodo components + were requested. * UI/MailPartViewers/UIxMailPartICalViewer.m (-storedEventObject): use the new "storedEventFetched" bool ivar to specify whether we diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 79a898acb..67a20726e 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -389,28 +389,6 @@ static NSArray *reducedReportQueryFields = nil; /* fetching */ -- (NSString *) _sqlStringForComponent: (id) _component -{ - NSString *sqlString; - NSArray *components; - - if (_component) - { - if ([_component isKindOfClass: [NSArray class]]) - components = _component; - else - components = [NSArray arrayWithObject: _component]; - - sqlString - = [NSString stringWithFormat: @"AND (c_component = '%@')", - [components componentsJoinedByString: @"' OR c_component = '"]]; - } - else - sqlString = @""; - - return sqlString; -} - - (NSString *) _sqlStringRangeFrom: (NSCalendarDate *) _startDate to: (NSCalendarDate *) _endDate { @@ -495,7 +473,7 @@ static NSArray *reducedReportQueryFields = nil; from: (NSCalendarDate *) startDate to: (NSCalendarDate *) endDate title: (NSString *) title - component: (id) component + component: (NSString *) component additionalFilters: (NSString *) filters { EOQualifier *qualifier; @@ -516,7 +494,11 @@ static NSArray *reducedReportQueryFields = nil; else titleSqlString = @""; - componentSqlString = [self _sqlStringForComponent: component]; + if (component) + componentSqlString = [NSString stringWithFormat: @"AND c_component = '%@'", + component]; + else + componentSqlString = @""; filterSqlString = [NSMutableString string]; if ([filters length]) [filterSqlString appendFormat: @"AND (%@)", filters]; @@ -934,16 +916,16 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir { EOQualifier *qualifier; GCSFolder *folder; - NSMutableArray *fields, *ma = nil; + NSMutableArray *fields, *ma; NSArray *records; - NSString *sql, *dateSqlString, *titleSqlString, *componentSqlString, - *privacySqlString, *currentLogin; - NSMutableString *filterSqlString; + NSMutableString *baseWhere; + NSString *where, *dateSqlString, *privacySqlString, *currentLogin; NSCalendarDate *endDate; NGCalendarDateRange *r; - BOOL rememberRecords; + BOOL rememberRecords, canCycle; rememberRecords = [self _checkIfWeCanRememberRecords: _fields]; + canCycle = [_component isEqualToString: @"vevent"]; // if (rememberRecords) // NSLog (@"we will remember those records!"); @@ -955,6 +937,12 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir return nil; } + if (_component) + baseWhere = [NSMutableString stringWithFormat: @"AND c_component = '%@'", + _component]; + else + baseWhere = [NSMutableString string]; + if (_startDate) { if (_endDate) @@ -971,22 +959,16 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir dateSqlString = @""; } - if ([title length]) - titleSqlString = [NSString stringWithFormat: @"AND (c_title" - @" isCaseInsensitiveLike: '%%%@%%')", - [title stringByReplacingString: @"'" withString: @"\\'\\'"]]; - else - titleSqlString = @""; - - componentSqlString = [self _sqlStringForComponent: _component]; - - filterSqlString = [NSMutableString string]; - if ([filters length]) - [filterSqlString appendFormat: @"AND (%@)", filters]; - privacySqlString = [self _privacySqlString]; if ([privacySqlString length]) - [filterSqlString appendFormat: @"AND (%@)", privacySqlString]; + [baseWhere appendFormat: @"AND %@", privacySqlString]; + + if ([title length]) + [baseWhere appendFormat: @"AND c_title isCaseInsensitiveLike: '%%%@%%'", + [title stringByReplacingString: @"'" withString: @"\\'\\'"]]; + + if ([filters length]) + [baseWhere appendFormat: @"AND (%@)", filters]; /* prepare mandatory fields */ @@ -1000,19 +982,15 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir if (logger) [self debugWithFormat:@"should fetch (%@=>%@) ...", _startDate, endDate]; - // We treat recurrent tasks as normal components - if ([_component caseInsensitiveCompare: @"vtodo"] == NSOrderedSame) - sql = @""; + if (canCycle) + where = [NSString stringWithFormat: @"%@ %@ AND c_iscycle = 0", + baseWhere, dateSqlString]; else - sql = @"(c_iscycle = 0) "; - - sql = [sql stringByAppendingFormat: @"%@ %@ %@ %@", - dateSqlString, titleSqlString, componentSqlString, - filterSqlString]; - - /* fetch non-recurrent apts first */ - qualifier = [EOQualifier qualifierWithQualifierFormat: sql]; + where = baseWhere; + /* fetch non-recurrent apts first */ + qualifier = [EOQualifier qualifierWithQualifierFormat: + [where substringFromIndex: 4]]; records = [folder fetchFields: fields matchingQualifier: qualifier]; if (records) { @@ -1023,15 +1001,15 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir [records count], records]; ma = [NSMutableArray arrayWithArray: records]; } + else + ma = nil; /* fetch recurrent apts now. we do NOT consider events with no cycle end. */ - if (_endDate || filters) +// || _endDate || filters) + if (canCycle) { - sql = [NSString stringWithFormat: @"(c_iscycle = 1) %@ %@ %@", titleSqlString, - componentSqlString, filterSqlString]; - - qualifier = [EOQualifier qualifierWithQualifierFormat: sql]; - + where = [NSString stringWithFormat: @"%@ AND c_iscycle = 1", baseWhere]; + qualifier = [EOQualifier qualifierWithQualifierFormat: [where substringFromIndex: 4]]; records = [folder fetchFields: fields matchingQualifier: qualifier]; if (records) {