From 8728c65a88ca905b37c79b9fa04a210e6442a2ce Mon Sep 17 00:00:00 2001 From: wolfgang Date: Wed, 7 Nov 2007 23:36:41 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1246 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 19 +++++ SoObjects/Appointments/SOGoFreeBusyObject.h | 1 - SoObjects/Contacts/GNUmakefile | 2 +- SoObjects/Contacts/SOGoContactFolder.h | 12 ++-- SoObjects/Contacts/SOGoContactFolders.m | 9 ++- SoObjects/Contacts/SOGoContactGCSFolder.h | 2 +- SoObjects/Contacts/SOGoContactGCSFolder.m | 6 +- SoObjects/Contacts/SOGoContactLDAPFolder.h | 4 +- SoObjects/Contacts/SOGoContactLDAPFolder.m | 38 +--------- ...SObject+CardDAV.h => SOGoFolder+CardDAV.h} | 4 +- ...SObject+CardDAV.m => SOGoFolder+CardDAV.m} | 6 +- SoObjects/SOGo/SOGoFolder.h | 3 + SoObjects/SOGo/SOGoFolder.m | 72 +++++++++++++++++++ SoObjects/SOGo/SOGoGCSFolder.h | 3 - SoObjects/SOGo/SOGoGCSFolder.m | 71 ------------------ 15 files changed, 117 insertions(+), 135 deletions(-) rename SoObjects/Contacts/{NSObject+CardDAV.h => SOGoFolder+CardDAV.h} (92%) rename SoObjects/Contacts/{NSObject+CardDAV.m => SOGoFolder+CardDAV.m} (97%) diff --git a/ChangeLog b/ChangeLog index 3e2a6bc8..392b9c75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,24 @@ 2007-11-07 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoGCSFolder.m ([-compare:otherFolder]): method + moved into the SOGoFolder class. + + * SoObjects/Appointments/SOGoAppointmentObject.m + ([SOGoAppointmentObject -saveContentString:_iCalinUIDs:_uids]): + simplified method by directly building a similar appointment + object with the current folder as container. + + * SoObjects/Contacts/SOGoContactLDAPFolder.m + ([SOGoContactLDAPFolder + -appendObject:objectwithBaseURL:baseURLtoREPORTResponse:r]): + take the content of an object returned by + lookupName:inContext:acquire: instead of the dictionary passed as + parameter since it represents a flattened entry return by + lookupContactsWithFilter... + + * SoObjects/Contacts/SOGoFolder+CardDAV.m: NSObject+CardDAV + category renamed to SOGoFolder+CardDAV. + * SoObjects/SOGo/SOGoParentFolder.m: no longer a subclass of SOGoObject, but of SOGoFolder instead. diff --git a/SoObjects/Appointments/SOGoFreeBusyObject.h b/SoObjects/Appointments/SOGoFreeBusyObject.h index c76a2b49..174e5dac 100644 --- a/SoObjects/Appointments/SOGoFreeBusyObject.h +++ b/SoObjects/Appointments/SOGoFreeBusyObject.h @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __Appointments_SOGoFreeBusyObject_H_ diff --git a/SoObjects/Contacts/GNUmakefile b/SoObjects/Contacts/GNUmakefile index 37c9ad23..3f08626c 100644 --- a/SoObjects/Contacts/GNUmakefile +++ b/SoObjects/Contacts/GNUmakefile @@ -8,8 +8,8 @@ BUNDLE_NAME = Contacts Contacts_PRINCIPAL_CLASS = SOGoContactsProduct Contacts_OBJC_FILES = \ - NSObject+CardDAV.m \ Product.m \ + SOGoFolder+CardDAV.m \ SOGoContactFolders.m \ SOGoContactGCSEntry.m \ SOGoContactGCSFolder.m \ diff --git a/SoObjects/Contacts/SOGoContactFolder.h b/SoObjects/Contacts/SOGoContactFolder.h index 709e4ae6..0b6f4a6c 100644 --- a/SoObjects/Contacts/SOGoContactFolder.h +++ b/SoObjects/Contacts/SOGoContactFolder.h @@ -33,15 +33,13 @@ #import -@class NSString, NSArray; -@class SOGoContactObject; -@class SOGoObject; -@class WOResponse; - -@protocol SOGoContactObject; - #import +@class NSArray; +@class NSDictionary; +@class NSString; +@class WOResponse; + @protocol SOGoContactFolder - (void) appendObject: (NSDictionary *) object diff --git a/SoObjects/Contacts/SOGoContactFolders.m b/SoObjects/Contacts/SOGoContactFolders.m index 2d75c8f0..234e24af 100644 --- a/SoObjects/Contacts/SOGoContactFolders.m +++ b/SoObjects/Contacts/SOGoContactFolders.m @@ -53,21 +53,20 @@ { LDAPUserManager *um; NSEnumerator *sourceIDs; - NSString *currentSourceID, *displayName; + NSString *currentSourceID, *srcDisplayName; SOGoContactLDAPFolder *currentFolder; um = [LDAPUserManager sharedUserManager]; sourceIDs = [[um addressBookSourceIDs] objectEnumerator]; currentSourceID = [sourceIDs nextObject]; - while (currentSourceID) + while ((currentSourceID = [sourceIDs nextObject])) { - displayName = [um displayNameForSourceWithID: currentSourceID]; + srcDisplayName = [um displayNameForSourceWithID: currentSourceID]; currentFolder = [SOGoContactLDAPFolder folderWithName: currentSourceID - andDisplayName: displayName + andDisplayName: srcDisplayName inContainer: self]; [currentFolder setLDAPSource: [um sourceWithID: currentSourceID]]; [subFolders setObject: currentFolder forKey: currentSourceID]; - currentSourceID = [sourceIDs nextObject]; } } diff --git a/SoObjects/Contacts/SOGoContactGCSFolder.h b/SoObjects/Contacts/SOGoContactGCSFolder.h index a6f6f0ee..06690a02 100644 --- a/SoObjects/Contacts/SOGoContactGCSFolder.h +++ b/SoObjects/Contacts/SOGoContactGCSFolder.h @@ -25,7 +25,7 @@ #import #import "SOGoContactFolder.h" -#import "NSObject+CardDAV.h" +#import "SOGoFolder+CardDAV.h" @class NSArray; @class NSString; diff --git a/SoObjects/Contacts/SOGoContactGCSFolder.m b/SoObjects/Contacts/SOGoContactGCSFolder.m index f248f514..e917d40c 100644 --- a/SoObjects/Contacts/SOGoContactGCSFolder.m +++ b/SoObjects/Contacts/SOGoContactGCSFolder.m @@ -205,18 +205,16 @@ return records; } +#warning this should be unified within SOGoFolder - (void) appendObject: (NSDictionary *) object withBaseURL: (NSString *) baseURL toREPORTResponse: (WOResponse *) r { SOGoContactGCSEntry *component; - Class componentClass; NSString *name, *etagLine, *contactString; name = [object objectForKey: @"c_name"]; - componentClass = [SOGoContactGCSEntry class]; - - component = [componentClass objectWithName: name inContainer: self]; + component = [self lookupName: name inContext: context acquire: NO]; [r appendContentString: @" \r\n"]; [r appendContentString: @" "]; diff --git a/SoObjects/Contacts/SOGoContactLDAPFolder.h b/SoObjects/Contacts/SOGoContactLDAPFolder.h index 7cddf7e6..a9fdac90 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.h +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.h @@ -24,13 +24,13 @@ #define SOGOCONTACTLDAPFOLDER_H #import "SOGoContactFolder.h" -#import "NSObject+CardDAV.h" +#import "SOGoFolder+CardDAV.h" @class NSMutableDictionary; @class LDAPSource; -@interface SOGoContactLDAPFolder : SOGoObject +@interface SOGoContactLDAPFolder : SOGoFolder { NSString *displayName; LDAPSource *ldapSource; diff --git a/SoObjects/Contacts/SOGoContactLDAPFolder.m b/SoObjects/Contacts/SOGoContactLDAPFolder.m index bc684ca3..dd1bfd3c 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.m +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.m @@ -45,19 +45,16 @@ @implementation SOGoContactLDAPFolder +#warning this should be unified within SOGoFolder - (void) appendObject: (NSDictionary *) object withBaseURL: (NSString *) baseURL toREPORTResponse: (WOResponse *) r { SOGoContactLDIFEntry *component; - Class componentClass; NSString *name, *etagLine, *contactString; name = [object objectForKey: @"c_name"]; - componentClass = [SOGoContactLDIFEntry class]; - - component = [componentClass contactEntryWithName: name - withLDIFEntry: object inContainer: self]; + component = [self lookupName: name inContext: context acquire: NO]; [r appendContentString: @" \r\n"]; [r appendContentString: @" "]; @@ -162,42 +159,11 @@ if (!obj) { ldifEntry = [ldapSource lookupContactEntry: objectName]; -#if 0 obj = ((ldifEntry) ? [SOGoContactLDIFEntry contactEntryWithName: objectName withLDIFEntry: ldifEntry inContainer: self] : [NSException exceptionWithHTTPStatus: 404]); -#else - if (ldifEntry) - obj = [SOGoContactLDIFEntry contactEntryWithName: objectName - withLDIFEntry: ldifEntry - inContainer: self]; - else - { - NSArray *davNamespaces; - NSDictionary *davInvocation; - NSString *objcMethod; - - davNamespaces = [self davNamespaces]; - if ([davNamespaces count] > 0) - { - davInvocation = [objectName asDavInvocation]; - if (davInvocation - && [davNamespaces - containsObject: [davInvocation objectForKey: @"ns"]]) - { - objcMethod = [[davInvocation objectForKey: @"method"] - davMethodToObjC]; - obj = [[SoSelectorInvocation alloc] - initWithSelectorNamed: - [NSString stringWithFormat: @"%@:", objcMethod] - addContextParameter: YES]; - [obj autorelease]; - } - } - } -#endif } return obj; diff --git a/SoObjects/Contacts/NSObject+CardDAV.h b/SoObjects/Contacts/SOGoFolder+CardDAV.h similarity index 92% rename from SoObjects/Contacts/NSObject+CardDAV.h rename to SoObjects/Contacts/SOGoFolder+CardDAV.h index d87dff40..056f5c41 100644 --- a/SoObjects/Contacts/NSObject+CardDAV.h +++ b/SoObjects/Contacts/SOGoFolder+CardDAV.h @@ -23,7 +23,9 @@ #ifndef __Contacts_NSObject_CardDAV_H__ #define __Contacts_NSObject_CardDAV_H__ -@interface NSObject (CardDAV) +#import "SOGoContactFolder.h" + +@interface SOGoFolder (CardDAV) - (id) davAddressbookQuery: (id) queryContext; diff --git a/SoObjects/Contacts/NSObject+CardDAV.m b/SoObjects/Contacts/SOGoFolder+CardDAV.m similarity index 97% rename from SoObjects/Contacts/NSObject+CardDAV.m rename to SoObjects/Contacts/SOGoFolder+CardDAV.m index 2fed99dc..18b739de 100644 --- a/SoObjects/Contacts/NSObject+CardDAV.m +++ b/SoObjects/Contacts/SOGoFolder+CardDAV.m @@ -33,11 +33,11 @@ #import "SOGoContactFolder.h" #import "SOGoContactGCSEntry.h" -@implementation NSObject (CardDAV) +@implementation SOGoFolder (CardDAV) - (void) _appendComponentsMatchingFilters: (NSArray *) filters toResponse: (WOResponse *) response - context: (id) context + context: (id) localContext { unsigned int count, max; NSDictionary *currentFilter, *contact; @@ -46,7 +46,7 @@ SOGoObject *o; o = (id)self; - baseURL = [o baseURLInContext: context]; + baseURL = [o baseURLInContext: localContext]; max = [filters count]; for (count = 0; count < max; count++) diff --git a/SoObjects/SOGo/SOGoFolder.h b/SoObjects/SOGo/SOGoFolder.h index ee5de48e..1292b96e 100644 --- a/SoObjects/SOGo/SOGoFolder.h +++ b/SoObjects/SOGo/SOGoFolder.h @@ -35,6 +35,9 @@ - (NSString *) folderType; +/* sorting */ +- (NSComparisonResult) compare: (id) otherFolder; + /* dav */ - (NSArray *) davNamespaces; diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index af83275e..3f49d254 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -113,6 +113,78 @@ return [[self davURL] absoluteString]; } +/* sorting */ +- (NSComparisonResult) _compareByOrigin: (SOGoFolder *) otherFolder +{ + NSArray *thisElements, *otherElements; + unsigned thisCount, otherCount; + NSComparisonResult comparison; + + thisElements = [nameInContainer componentsSeparatedByString: @"_"]; + otherElements = [[otherFolder nameInContainer] + componentsSeparatedByString: @"_"]; + thisCount = [thisElements count]; + otherCount = [otherElements count]; + if (thisCount == otherCount) + { + if (thisCount == 1) + comparison = NSOrderedSame; + else + comparison = [[thisElements objectAtIndex: 0] + compare: [otherElements objectAtIndex: 0]]; + } + else + { + if (thisCount > otherCount) + comparison = NSOrderedDescending; + else + comparison = NSOrderedAscending; + } + + return comparison; +} + +- (NSComparisonResult) _compareByNameInContainer: (SOGoFolder *) otherFolder +{ + NSString *otherName; + NSComparisonResult comparison; + + otherName = [otherFolder nameInContainer]; + if ([nameInContainer hasSuffix: @"personal"]) + { + if ([otherName hasSuffix: @"personal"]) + comparison = [nameInContainer compare: otherName]; + else + comparison = NSOrderedAscending; + } + else + { + if ([otherName hasSuffix: @"personal"]) + comparison = NSOrderedDescending; + else + comparison = NSOrderedSame; + } + + return comparison; +} + +- (NSComparisonResult) compare: (id) otherFolder +{ + NSComparisonResult comparison; + + comparison = [self _compareByOrigin: otherFolder]; + if (comparison == NSOrderedSame) + { + comparison = [self _compareByNameInContainer: otherFolder]; + if (comparison == NSOrderedSame) + comparison + = [[self displayName] + localizedCaseInsensitiveCompare: [otherFolder displayName]]; + } + + return comparison; +} + /* WebDAV */ - (NSArray *) davNamespaces diff --git a/SoObjects/SOGo/SOGoGCSFolder.h b/SoObjects/SOGo/SOGoGCSFolder.h index 9e331452..21fb8934 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.h +++ b/SoObjects/SOGo/SOGoGCSFolder.h @@ -71,9 +71,6 @@ - (BOOL) folderIsMandatory; -/* sorting */ -- (NSComparisonResult) compare: (SOGoGCSFolder *) otherFolder; - - (BOOL) create; - (NSException *) delete; - (void) renameTo: (NSString *) newName; diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 2caaa687..42c5974a 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -635,77 +635,6 @@ static NSString *defaultUserID = @""; return defaultUserID; } -- (NSComparisonResult) _compareByOrigin: (SOGoFolder *) otherFolder -{ - NSArray *thisElements, *otherElements; - unsigned thisCount, otherCount; - NSComparisonResult comparison; - - thisElements = [nameInContainer componentsSeparatedByString: @"_"]; - otherElements = [[otherFolder nameInContainer] - componentsSeparatedByString: @"_"]; - thisCount = [thisElements count]; - otherCount = [otherElements count]; - if (thisCount == otherCount) - { - if (thisCount == 1) - comparison = NSOrderedSame; - else - comparison = [[thisElements objectAtIndex: 0] - compare: [otherElements objectAtIndex: 0]]; - } - else - { - if (thisCount > otherCount) - comparison = NSOrderedDescending; - else - comparison = NSOrderedAscending; - } - - return comparison; -} - -- (NSComparisonResult) _compareByNameInContainer: (SOGoFolder *) otherFolder -{ - NSString *otherName; - NSComparisonResult comparison; - - otherName = [otherFolder nameInContainer]; - if ([nameInContainer hasSuffix: @"personal"]) - { - if ([otherName hasSuffix: @"personal"]) - comparison = [nameInContainer compare: otherName]; - else - comparison = NSOrderedAscending; - } - else - { - if ([otherName hasSuffix: @"personal"]) - comparison = NSOrderedDescending; - else - comparison = NSOrderedSame; - } - - return comparison; -} - -- (NSComparisonResult) compare: (SOGoGCSFolder *) otherFolder -{ - NSComparisonResult comparison; - - comparison = [self _compareByOrigin: otherFolder]; - if (comparison == NSOrderedSame) - { - comparison = [self _compareByNameInContainer: otherFolder]; - if (comparison == NSOrderedSame) - comparison - = [[self displayName] - localizedCaseInsensitiveCompare: [otherFolder displayName]]; - } - - return comparison; -} - /* description */ - (void) appendAttributesToDescription: (NSMutableString *) _ms -- 2.39.5