2007-11-07 Wolfgang Sourdeau <wsourdeau@inverse.ca>
+ * 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.
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#ifndef __Appointments_SOGoFreeBusyObject_H_
Contacts_PRINCIPAL_CLASS = SOGoContactsProduct
Contacts_OBJC_FILES = \
- NSObject+CardDAV.m \
Product.m \
+ SOGoFolder+CardDAV.m \
SOGoContactFolders.m \
SOGoContactGCSEntry.m \
SOGoContactGCSFolder.m \
#import <Foundation/NSObject.h>
-@class NSString, NSArray;
-@class SOGoContactObject;
-@class SOGoObject;
-@class WOResponse;
-
-@protocol SOGoContactObject;
-
#import <SoObjects/SOGo/SOGoFolder.h>
+@class NSArray;
+@class NSDictionary;
+@class NSString;
+@class WOResponse;
+
@protocol SOGoContactFolder <NSObject>
- (void) appendObject: (NSDictionary *) object
{
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];
}
}
#import <SoObjects/SOGo/SOGoGCSFolder.h>
#import "SOGoContactFolder.h"
-#import "NSObject+CardDAV.h"
+#import "SOGoFolder+CardDAV.h"
@class NSArray;
@class NSString;
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: @" <D:response>\r\n"];
[r appendContentString: @" <D:href>"];
#define SOGOCONTACTLDAPFOLDER_H
#import "SOGoContactFolder.h"
-#import "NSObject+CardDAV.h"
+#import "SOGoFolder+CardDAV.h"
@class NSMutableDictionary;
@class LDAPSource;
-@interface SOGoContactLDAPFolder : SOGoObject <SOGoContactFolder>
+@interface SOGoContactLDAPFolder : SOGoFolder <SOGoContactFolder>
{
NSString *displayName;
LDAPSource *ldapSource;
@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: @" <D:response>\r\n"];
[r appendContentString: @" <D:href>"];
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;
#ifndef __Contacts_NSObject_CardDAV_H__
#define __Contacts_NSObject_CardDAV_H__
-@interface NSObject (CardDAV)
+#import "SOGoContactFolder.h"
+
+@interface SOGoFolder (CardDAV) <SOGoContactFolder>
- (id) davAddressbookQuery: (id) queryContext;
#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;
SOGoObject <SOGoContactFolder> *o;
o = (id<SOGoContactFolder>)self;
- baseURL = [o baseURLInContext: context];
+ baseURL = [o baseURLInContext: localContext];
max = [filters count];
for (count = 0; count < max; count++)
- (NSString *) folderType;
+/* sorting */
+- (NSComparisonResult) compare: (id) otherFolder;
+
/* dav */
- (NSArray *) davNamespaces;
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
- (BOOL) folderIsMandatory;
-/* sorting */
-- (NSComparisonResult) compare: (SOGoGCSFolder *) otherFolder;
-
- (BOOL) create;
- (NSException *) delete;
- (void) renameTo: (NSString *) newName;
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