diff --git a/ChangeLog b/ChangeLog index 3e2a6bc81..9142242ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2007-11-07 Wolfgang Sourdeau + * 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/Contacts/GNUmakefile b/SoObjects/Contacts/GNUmakefile index 37c9ad23f..3f08626cf 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 709e4ae62..0b6f4a6ce 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 2d75c8f0c..234e24af3 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 a6f6f0eed..06690a022 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 f248f5146..e917d40cc 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 7cddf7e60..a9fdac909 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 65e4d11c8..dd1bfd3c2 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.m +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.m @@ -45,20 +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: @" "]; @@ -163,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 d87dff40f..056f5c418 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 2fed99dcb..18b739de2 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++)