From: wolfgang Date: Wed, 7 Nov 2007 17:42:18 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1243 d1b88da0-ebda-0310... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9f7ff993d2511b607fe867954de2609e7b3d2e5;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1243 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/ChangeLog b/ChangeLog index a379bb64..3e2a6bc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2007-11-07 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoParentFolder.m: no longer a subclass of + SOGoObject, but of SOGoFolder instead. + + * SoObjects/SOGo/SOGoUserFolder.m: no longer a subclass of + SOGoGCSFolder, but of SOGoFolder instead. + + * SoObjects/Appointments/SOGoAppointmentFolder.m + ([SOGoAppointmentFolder -lookupCalendarFolderForUID:uid]): fixed + to take the new SOGoParentFolder class into account. Also, create + the personal folder if it doesn't exist. + + * SoObjects/SOGo/SOGoFolder.[hm]: new class module implementing + the parent of all SOGo containers. + + * SoObjects/SOGo/SOGoGCSFolder.[hm]: SOGoFolder class renamed to + SOGoGCSFolder. + 2007-11-06 Wolfgang Sourdeau * UI/MailerUI/UIxMailToSelection.m ([UIxMailToSelection diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.h b/SoObjects/Appointments/SOGoAppointmentFolder.h index 5f5ee41d..27a24c9a 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -36,7 +36,7 @@ create two different vevent-files with the same uid in the store. */ -#import "SOGo/SOGoFolder.h" +#import "SOGo/SOGoGCSFolder.h" @class NSArray; @class NSCalendarDate; @@ -47,7 +47,7 @@ @class GCSFolder; #import -@interface SOGoAppointmentFolder : SOGoFolder +@interface SOGoAppointmentFolder : SOGoGCSFolder { NSTimeZone *timeZone; NSMutableDictionary *uidToFilename; diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index a2306fba..395d92e8 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -52,6 +52,7 @@ #import #import "SOGoAppointmentObject.h" +#import "SOGoAppointmentFolders.h" #import "SOGoTaskObject.h" #import "SOGoAppointmentFolder.h" @@ -1001,20 +1002,29 @@ static NSNumber *sharedYes = nil; - (SOGoAppointmentFolder *) lookupCalendarFolderForUID: (NSString *) uid { - SOGoFolder *upperContainer; - SOGoUserFolder *userFolder; - SOGoAppointmentFolder *calendarFolder; - - upperContainer = [[self container] container]; - userFolder = [SOGoUserFolder objectWithName: uid - inContainer: upperContainer]; - calendarFolder = [SOGoAppointmentFolder objectWithName: @"Calendar" - inContainer: userFolder]; - [calendarFolder - setOCSPath: [NSString stringWithFormat: @"/Users/%@/Calendar/personal", uid]]; - [calendarFolder setOwner: uid]; - - return calendarFolder; + SOGoFolder *currentContainer; + SOGoAppointmentFolders *parent; + NSException *error; + + currentContainer = [[container container] container]; + currentContainer = [currentContainer lookupName: uid + inContext: context + acquire: NO]; + parent = [currentContainer lookupName: @"Calendar" inContext: context + acquire: NO]; + currentContainer = [parent lookupName: @"personal" inContext: context + acquire: NO]; + if (!currentContainer) + { + error = [parent newFolderWithName: [parent defaultFolderName] + andNameInContainer: @"personal"]; + if (!error) + currentContainer = [parent lookupName: @"personal" + inContext: context + acquire: NO]; + } + + return (SOGoAppointmentFolder *) currentContainer; } - (NSArray *) lookupCalendarFoldersForUIDs: (NSArray *) _uids @@ -1041,8 +1051,9 @@ static NSNumber *sharedYes = nil; if (![folder isNotNull]) [self logWithFormat:@"Note: did not find folder for uid: '%@'", uid]; } - - [folders addObject: folder]; + + if (folder) + [folders addObject: folder]; } return folders; diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index c4c94371..59f96d69 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -147,30 +147,33 @@ return allErrors; } -- (NSException *)deleteInUIDs:(NSArray *)_uids { +- (NSException *) deleteInUIDs: (NSArray *) _uids +{ NSEnumerator *e; id folder; NSException *allErrors = nil; + NSException *error; + SOGoAppointmentObject *apt; e = [[container lookupCalendarFoldersForUIDs:_uids inContext: context] objectEnumerator]; - while ((folder = [e nextObject])) { - NSException *error; - SOGoAppointmentObject *apt; - - apt = [folder lookupName:[self nameInContainer] inContext: context - acquire:NO]; - if ([apt isKindOfClass: [NSException class]]) { - [self logWithFormat: @"%@", [(NSException *) apt reason]]; - continue; - } + while ((folder = [e nextObject])) + { + apt = [folder lookupName: [self nameInContainer] + inContext: context + acquire:NO]; + if ([apt isKindOfClass: [NSException class]]) { + [self logWithFormat: @"%@", [(NSException *) apt reason]]; + continue; + } - if ((error = [apt primaryDelete]) != nil) { - [self logWithFormat:@"Note: failed to delete in folder: %@", folder]; - // TODO: make compound - allErrors = error; + if ((error = [apt primaryDelete]) != nil) { + [self logWithFormat:@"Note: failed to delete in folder: %@", folder]; + // TODO: make compound + allErrors = error; + } } - } + return allErrors; } diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index f61b756f..805de427 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -375,8 +375,8 @@ static BOOL sendEMailNotifications = NO; recipient = email; language = [[context activeUser] language]; -#warning this could be optimized in a class hierarchy common with the \ - SOGoObject's acl notification mechanism +#warning this could be optimized in a class hierarchy common with the \ + SOGoObject acl notification mechanism /* create page name */ // TODO: select user's default language? pageName = [NSString stringWithFormat: @"SOGoAptMail%@%@", diff --git a/SoObjects/Appointments/SOGoFreeBusyObject.h b/SoObjects/Appointments/SOGoFreeBusyObject.h index 4b83b9dd..c76a2b49 100644 --- a/SoObjects/Appointments/SOGoFreeBusyObject.h +++ b/SoObjects/Appointments/SOGoFreeBusyObject.h @@ -24,7 +24,7 @@ #ifndef __Appointments_SOGoFreeBusyObject_H_ #define __Appointments_SOGoFreeBusyObject_H_ -#include +#include /* SOGoFreeBusyObject @@ -34,7 +34,7 @@ @class NSArray, NSCalendarDate; -@interface SOGoFreeBusyObject : SOGoContentObject +@interface SOGoFreeBusyObject : SOGoObject { } diff --git a/SoObjects/Appointments/SOGoFreeBusyObject.m b/SoObjects/Appointments/SOGoFreeBusyObject.m index ef40274d..80390a73 100644 --- a/SoObjects/Appointments/SOGoFreeBusyObject.m +++ b/SoObjects/Appointments/SOGoFreeBusyObject.m @@ -47,12 +47,6 @@ @implementation SOGoFreeBusyObject -- (NSString *) iCalString -{ - // for UI-X appointment viewer - return [self contentAsString]; -} - - (NSString *) contentAsString { NSCalendarDate *today, *startDate, *endDate; @@ -103,6 +97,12 @@ return infos; } +- (NSString *) iCalString +{ + // for UI-X appointment viewer + return [self contentAsString]; +} + /* Private API */ - (iCalFreeBusyType) _fbTypeForEventStatus: (NSNumber *) eventStatus { @@ -194,7 +194,8 @@ WOResponse *r; NSData *contentData; - contentData = [[self contentAsString] dataUsingEncoding: NSUTF8StringEncoding]; + contentData = [[self contentAsString] + dataUsingEncoding: NSUTF8StringEncoding]; r = [(WOContext *) _ctx response]; [r setHeader: @"text/calendar" forKey: @"content-type"]; @@ -209,4 +210,9 @@ return @"text/calendar"; } +- (NSArray *) aclsForUser: (NSString *) uid +{ + return nil; +} + @end diff --git a/SoObjects/Appointments/product.plist b/SoObjects/Appointments/product.plist index 1fdd67e8..f2a5b7fe 100644 --- a/SoObjects/Appointments/product.plist +++ b/SoObjects/Appointments/product.plist @@ -12,7 +12,7 @@ superclass = "SOGoParentFolder"; }; SOGoAppointmentFolder = { - superclass = "SOGoFolder"; + superclass = "SOGoGCSFolder"; defaultRoles = { /* "FreeBusyLookup" = ( "Owner", "FreeBusy", "AuthorizedSubscriber" ); */ "ViewWholePublicRecords" = ( "Owner", "PublicResponder", "PublicModifier", "PublicViewer" ); diff --git a/SoObjects/Contacts/NSObject+CardDAV.m b/SoObjects/Contacts/NSObject+CardDAV.m index 1a1df88b..2fed99dc 100644 --- a/SoObjects/Contacts/NSObject+CardDAV.m +++ b/SoObjects/Contacts/NSObject+CardDAV.m @@ -20,17 +20,18 @@ * Boston, MA 02111-1307, USA. */ -#import "SOGoContactFolder.h" -#import "SOGoContactGCSEntry.h" - -#import #import -#import -#import -#import + #import #import #import +#import +#import +#import +#import + +#import "SOGoContactFolder.h" +#import "SOGoContactGCSEntry.h" @implementation NSObject (CardDAV) @@ -42,7 +43,7 @@ NSDictionary *currentFilter, *contact; NSEnumerator *contacts; NSString *baseURL; - id o; + SOGoObject *o; o = (id)self; baseURL = [o baseURLInContext: context]; diff --git a/SoObjects/Contacts/SOGoContactGCSFolder.h b/SoObjects/Contacts/SOGoContactGCSFolder.h index 9ac8fb1f..a6f6f0ee 100644 --- a/SoObjects/Contacts/SOGoContactGCSFolder.h +++ b/SoObjects/Contacts/SOGoContactGCSFolder.h @@ -22,7 +22,7 @@ #ifndef __Contacts_SOGoContactGCSFolder_H__ #define __Contacts_SOGoContactGCSFolder_H__ -#import +#import #import "SOGoContactFolder.h" #import "NSObject+CardDAV.h" @@ -30,7 +30,7 @@ @class NSArray; @class NSString; -@interface SOGoContactGCSFolder : SOGoFolder +@interface SOGoContactGCSFolder : SOGoGCSFolder @end diff --git a/SoObjects/Contacts/SOGoContactLDAPFolder.m b/SoObjects/Contacts/SOGoContactLDAPFolder.m index 13772500..65e4d11c 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.m +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.m @@ -43,8 +43,6 @@ @class WOContext; - - @implementation SOGoContactLDAPFolder - (void) appendObject: (NSDictionary *) object @@ -59,7 +57,8 @@ componentClass = [SOGoContactLDIFEntry class]; - component = [componentClass contactEntryWithName: name withLDIFEntry: object inContainer: self]; + component = [componentClass contactEntryWithName: name + withLDIFEntry: object inContainer: self]; [r appendContentString: @" \r\n"]; [r appendContentString: @" "]; diff --git a/SoObjects/Contacts/product.plist b/SoObjects/Contacts/product.plist index e1557d61..f3035902 100644 --- a/SoObjects/Contacts/product.plist +++ b/SoObjects/Contacts/product.plist @@ -12,13 +12,13 @@ superclass = "SOGoParentFolder"; }; SOGoContactGCSFolder = { - superclass = "SOGoFolder"; + superclass = "SOGoGCSFolder"; }; SOGoContactGCSEntry = { superclass = "SOGoContentObject"; }; SOGoContactLDAPFolder = { - superclass = "SOGoFolder"; + superclass = "SOGoGCSFolder"; protectedBy = "Access Contents Information"; defaultRoles = { "Access Contents Information" = ( "Authenticated" ); diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index f702e21f..4f2f5911 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -479,14 +479,16 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default s = [self nameInContainer]; r = [s rangeOfString:@"@"]; - if (r.length > 0) { - login = [s substringToIndex:r.location]; - host = [s substringFromIndex:(r.location + r.length)]; - } - else { - login = nil; - host = s; - } + if (r.length > 0) + { + login = [s substringToIndex:r.location]; + host = [s substringFromIndex:(r.location + r.length)]; + } + else + { + login = nil; + host = s; + } r = [host rangeOfString:@"."]; if (r.length > 0) diff --git a/SoObjects/Mailer/SOGoMailAccounts.h b/SoObjects/Mailer/SOGoMailAccounts.h index 96475f7a..623ffcb2 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.h +++ b/SoObjects/Mailer/SOGoMailAccounts.h @@ -22,7 +22,7 @@ #ifndef __Mailer_SOGoMailAccounts_H__ #define __Mailer_SOGoMailAccounts_H__ -#import +#import /* SOGoMailAccounts @@ -39,7 +39,7 @@ @class NSArray; -@interface SOGoMailAccounts : SOGoObject +@interface SOGoMailAccounts : SOGoFolder @end diff --git a/SoObjects/Mailer/SOGoMailAccounts.m b/SoObjects/Mailer/SOGoMailAccounts.m index 66e2948b..b09e9092 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SoObjects/Mailer/SOGoMailAccounts.m @@ -127,24 +127,4 @@ static NSString *AgenorShareLoginMarker = @".-."; return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; } -/* WebDAV */ - -- (BOOL) davIsCollection -{ - return YES; -} - -- (NSString *) davContentType -{ - return @"httpd/unix-directory"; -} - -/* acls */ - -- (NSArray *) aclsForUser: (NSString *) uid -{ - return nil; -} - - @end /* SOGoMailAccounts */ diff --git a/SoObjects/Mailer/product.plist b/SoObjects/Mailer/product.plist index 9e202f3e..2a93d2b7 100644 --- a/SoObjects/Mailer/product.plist +++ b/SoObjects/Mailer/product.plist @@ -12,7 +12,7 @@ superclass = "SOGoObject"; }; SOGoMailAccounts = { - superclass = "SOGoMailBaseObject"; + superclass = "SOGoFolder"; defaultRoles = { "View" = ( "Owner", "AuthorizedSubscriber" ); "Access Contents Information" = ( "Owner", "AuthorizedSubscriber" ); diff --git a/SoObjects/SOGo/GNUmakefile b/SoObjects/SOGo/GNUmakefile index 7d15b89f..46c94b95 100644 --- a/SoObjects/SOGo/GNUmakefile +++ b/SoObjects/SOGo/GNUmakefile @@ -53,6 +53,7 @@ libSOGo_OBJC_FILES = \ SOGoObject.m \ SOGoContentObject.m \ SOGoFolder.m \ + SOGoGCSFolder.m \ SOGoParentFolder.m \ SOGoUserFolder.m \ SOGoGroupsFolder.m \ diff --git a/SoObjects/SOGo/SOGoContentObject.m b/SoObjects/SOGo/SOGoContentObject.m index 00ed0779..44251366 100644 --- a/SoObjects/SOGo/SOGoContentObject.m +++ b/SoObjects/SOGo/SOGoContentObject.m @@ -29,7 +29,7 @@ #import #import -#import "SOGoFolder.h" +#import "SOGoGCSFolder.h" #import "SOGoUser.h" #import "SOGoPermissions.h" #import "SOGoContentObject.h" diff --git a/SoObjects/SOGo/SOGoFolder.h b/SoObjects/SOGo/SOGoFolder.h index c0b492e9..ee5de48e 100644 --- a/SoObjects/SOGo/SOGoFolder.h +++ b/SoObjects/SOGo/SOGoFolder.h @@ -1,108 +1,46 @@ -/* - Copyright (C) 2004-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -#ifndef __SOGo_SOGoFolder_H__ -#define __SOGo_SOGoFolder_H__ +/* SOGoFolder.h - this file is part of SOGo + * + * Copyright (C) 2007 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef SOGOFOLDER_H +#define SOGOFOLDER_H #import "SOGoObject.h" -@class NSArray; -@class NSDictionary; -@class NSMutableDictionary; -@class NSString; - -@class GCSFolder; - -/* - SOGoFolder - - A common superclass for folders stored in GCS. Already deals with all GCS - folder specific things. - - Important: folders should NOT retain the context! Otherwise you might get - cyclic references. -*/ - @interface SOGoFolder : SOGoObject { NSMutableString *displayName; - NSString *ocsPath; - GCSFolder *ocsFolder; - NSMutableDictionary *aclCache; } -+ (id) folderWithSubscriptionReference: (NSString *) reference - inContainer: (id) aContainer; - -/* accessors */ - - (void) setDisplayName: (NSString *) newDisplayName; - (NSString *) displayName; -- (void) setOCSPath: (NSString *)_Path; -- (NSString *) ocsPath; - -- (GCSFolder *) ocsFolderForPath: (NSString *)_path; -- (GCSFolder *) ocsFolder; - -/* lower level fetches */ -- (BOOL) nameExistsInFolder: (NSString *) objectName; - -- (void) deleteEntriesWithIds: (NSArray *) ids; - -- (NSArray *) fetchContentObjectNames; -- (NSDictionary *) fetchContentStringsAndNamesOfAllObjects; - -/* folder type */ - -- (NSString *) outlookFolderClass; - -- (BOOL) folderIsMandatory; - (NSString *) folderType; -/* sorting */ -- (NSComparisonResult) compare: (SOGoFolder *) otherFolder; - -- (BOOL) create; -- (NSException *) delete; -- (void) renameTo: (NSString *) newName; /* dav */ - (NSArray *) davNamespaces; -/* acls as a container */ -- (NSArray *) aclUsersForObjectAtPath: (NSArray *) objectPathArray; -- (NSArray *) aclsForUser: (NSString *) uid - forObjectAtPath: (NSArray *) objectPathArray; -- (void) setRoles: (NSArray *) roles - forUser: (NSString *) uid - forObjectAtPath: (NSArray *) objectPathArray; -- (void) removeAclsForUsers: (NSArray *) users - forObjectAtPath: (NSArray *) objectPathArray; - -@end - -@interface SOGoFolder (GroupDAVExtensions) - -- (NSString *) groupDavResourceType; +/* outlook */ +- (NSString *) outlookFolderClass; @end -#endif /* __SOGo_SOGoFolder_H__ */ +#endif /* SOGOFOLDER_H */ diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index 3ff95dae..af83275e 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -1,214 +1,51 @@ -/* - Copyright (C) 2004-2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ +/* SOGoFolder.m - this file is part of SOGo + * + * Copyright (C) 2007 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ #import -#import -#import -#import -#import +#import #import -#import -#import -#import #import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import -#import "NSArray+Utilities.h" #import "NSString+Utilities.h" -#import "SOGoContentObject.h" -#import "SOGoPermissions.h" -#import "SOGoUser.h" - #import "SOGoFolder.h" -static NSString *defaultUserID = @""; - @implementation SOGoFolder -+ (int) version -{ - return [super version] + 0 /* v0 */; -} - -+ (void) initialize -{ - NSAssert2([super version] == 0, - @"invalid superclass (%@) version %i !", - NSStringFromClass([self superclass]), [super version]); -} - -+ (id) folderWithSubscriptionReference: (NSString *) reference - inContainer: (id) aContainer -{ - id newFolder; - NSArray *elements, *pathElements; - NSString *ocsPath, *objectPath, *owner, *ocsName, *folderName; - - elements = [reference componentsSeparatedByString: @":"]; - owner = [elements objectAtIndex: 0]; - objectPath = [elements objectAtIndex: 1]; - pathElements = [objectPath componentsSeparatedByString: @"/"]; - if ([pathElements count] > 1) - ocsName = [pathElements objectAtIndex: 1]; - else - ocsName = @"personal"; - - ocsPath = [NSString stringWithFormat: @"/Users/%@/%@/%@", - owner, [pathElements objectAtIndex: 0], ocsName]; - folderName = [NSString stringWithFormat: @"%@_%@", owner, ocsName]; - newFolder = [[self alloc] initWithName: folderName - inContainer: aContainer]; - [newFolder setOCSPath: ocsPath]; - [newFolder setOwner: owner]; - - return newFolder; -} - - (id) init { if ((self = [super init])) - { - displayName = nil; - ocsPath = nil; - ocsFolder = nil; - aclCache = [NSMutableDictionary new]; - } + displayName = nil; return self; } - (void) dealloc { - [ocsFolder release]; - [ocsPath release]; - [aclCache release]; [displayName release]; [super dealloc]; } -/* accessors */ - -- (BOOL) isFolderish -{ - return YES; -} - -- (void) setOCSPath: (NSString *) _path -{ - if (![ocsPath isEqualToString:_path]) - { - if (ocsPath) - [self warnWithFormat: @"GCS path is already set! '%@'", _path]; - ASSIGN (ocsPath, _path); - } -} - -- (NSString *) ocsPath -{ - return ocsPath; -} - -- (GCSFolderManager *) folderManager -{ - static GCSFolderManager *folderManager = nil; - - if (!folderManager) - folderManager = [GCSFolderManager defaultFolderManager]; - - return folderManager; -} - -- (GCSFolder *) ocsFolderForPath: (NSString *) _path -{ - return [[self folderManager] folderAtPath: _path]; -} - -- (BOOL) folderIsMandatory -{ - return [nameInContainer isEqualToString: @"personal"]; -} - -- (void) _setDisplayNameFromRow: (NSDictionary *) row -{ - NSString *currentLogin, *ownerLogin; - NSDictionary *ownerIdentity; - - displayName - = [NSMutableString stringWithString: [row objectForKey: @"c_foldername"]]; - currentLogin = [[context activeUser] login]; - ownerLogin = [self ownerInContext: context]; - if (![currentLogin isEqualToString: ownerLogin]) - { - ownerIdentity = [[SOGoUser userWithLogin: ownerLogin roles: nil] - primaryIdentity]; - [displayName appendFormat: @" (%@ <%@>)", - [ownerIdentity objectForKey: @"fullName"], - [ownerIdentity objectForKey: @"email"]]; - } - [displayName retain]; -} - -- (void) _fetchDisplayName -{ - GCSChannelManager *cm; - EOAdaptorChannel *fc; - NSURL *folderLocation; - NSString *sql; - NSArray *attrs; - NSDictionary *row; - - cm = [GCSChannelManager defaultChannelManager]; - folderLocation - = [[GCSFolderManager defaultFolderManager] folderInfoLocation]; - fc = [cm acquireOpenChannelForURL: folderLocation]; - if (fc) - { - sql - = [NSString stringWithFormat: (@"SELECT c_foldername FROM %@" - @" WHERE c_path = '%@'"), - [folderLocation gcsTableName], ocsPath]; - [fc evaluateExpressionX: sql]; - attrs = [fc describeResults: NO]; - row = [fc fetchAttributes: attrs withZone: NULL]; - if (row) - [self _setDisplayNameFromRow: row]; - [fc cancelFetch]; - [cm releaseChannel: fc]; - } -} - - (void) setDisplayName: (NSString *) newDisplayName { ASSIGN (displayName, newDisplayName); @@ -216,468 +53,16 @@ static NSString *defaultUserID = @""; - (NSString *) displayName { - if (!displayName) - [self _fetchDisplayName]; - - return displayName; -} - -- (NSString *) davDisplayName -{ - return [self displayName]; -} - -- (GCSFolder *) ocsFolder -{ - GCSFolder *folder; - NSString *userLogin; - - if (!ocsFolder) - { - ocsFolder = [self ocsFolderForPath: [self ocsPath]]; - userLogin = [[context activeUser] login]; - if (!ocsFolder -/* && [userLogin isEqualToString: [self ownerInContext: context]] */ - && [self folderIsMandatory] - && [self create]) - ocsFolder = [self ocsFolderForPath: [self ocsPath]]; - [ocsFolder retain]; - } - - if ([ocsFolder isNotNull]) - folder = ocsFolder; - else - folder = nil; - - return folder; + return ((displayName) ? displayName : nameInContainer); } - (NSString *) folderType { - return @""; -} - -- (void) sendFolderAdvisoryTemplate: (NSString *) template -{ - NSString *pageName; - SOGoUser *user; - SOGoFolderAdvisory *page; - - user = [context activeUser]; - pageName = [NSString stringWithFormat: @"SOGoFolder%@%@Advisory", - [user language], template]; - - page = [[WOApplication application] pageWithName: pageName - inContext: context]; - [page setFolderObject: self]; - [page setRecipientUID: [user login]]; - [page send]; -} - - -// if (!result) [self sendFolderAdvisoryTemplate: @"Addition"]; - -- (BOOL) create -{ - NSException *result; - - result = [[self folderManager] createFolderOfType: [self folderType] - withName: displayName - atPath: ocsPath]; - - return (result == nil); -} - -- (NSException *) delete -{ - NSException *error; - - // We just fetch our displayName since our table will use it! - [self displayName]; - - if ([nameInContainer isEqualToString: @"personal"]) - error = [NSException exceptionWithHTTPStatus: 403 - reason: @"folder 'personal' cannot be deleted"]; - else - error = [[self folderManager] deleteFolderAtPath: ocsPath]; - - return error; -} - -// if (!error) [self sendFolderAdvisoryTemplate: @"Removal"]; - -- (void) renameTo: (NSString *) newName -{ - GCSChannelManager *cm; - EOAdaptorChannel *fc; - NSURL *folderLocation; - NSString *sql; - - [displayName release]; - displayName = nil; - - cm = [GCSChannelManager defaultChannelManager]; - folderLocation - = [[GCSFolderManager defaultFolderManager] folderInfoLocation]; - fc = [cm acquireOpenChannelForURL: folderLocation]; - if (fc) - { - sql - = [NSString stringWithFormat: (@"UPDATE %@ SET c_foldername = '%@'" - @" WHERE c_path = '%@'"), - [folderLocation gcsTableName], newName, ocsPath]; - [fc evaluateExpressionX: sql]; - [cm releaseChannel: fc]; -// sql = [sql stringByAppendingFormat:@" WHERE %@ = '%@'", -// uidColumnName, [self uid]]; - } -} - -- (NSArray *) fetchContentObjectNames -{ - NSArray *fields, *records; - - fields = [NSArray arrayWithObject: @"c_name"]; - records = [[self ocsFolder] fetchFields:fields matchingQualifier:nil]; - if (![records isNotNull]) - { - [self errorWithFormat: @"(%s): fetch failed!", __PRETTY_FUNCTION__]; - return nil; - } - if ([records isKindOfClass: [NSException class]]) - return records; - return [records objectsForKey: @"c_name"]; -} - -- (BOOL) nameExistsInFolder: (NSString *) objectName -{ - NSArray *fields, *records; - EOQualifier *qualifier; - - qualifier - = [EOQualifier qualifierWithQualifierFormat: - [NSString stringWithFormat: @"c_name='%@'", objectName]]; - - fields = [NSArray arrayWithObject: @"c_name"]; - records = [[self ocsFolder] fetchFields: fields - matchingQualifier: qualifier]; - return (records - && ![records isKindOfClass:[NSException class]] - && [records count] > 0); -} - -- (void) deleteEntriesWithIds: (NSArray *) ids -{ - unsigned int count, max; - NSString *currentID; - SOGoContentObject *deleteObject; - - max = [ids count]; - for (count = 0; count < max; count++) - { - currentID = [ids objectAtIndex: count]; - deleteObject = [self lookupName: currentID - inContext: context acquire: NO]; - if (![deleteObject isKindOfClass: [NSException class]]) - [deleteObject delete]; - } -} - -- (NSDictionary *) fetchContentStringsAndNamesOfAllObjects -{ - NSDictionary *files; - - files = [[self ocsFolder] fetchContentsOfAllFiles]; - if (![files isNotNull]) - { - [self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__]; - return nil; - } - if ([files isKindOfClass:[NSException class]]) - return files; - return files; -} - -/* reflection */ + [self subclassResponsibility: _cmd]; -- (NSString *) defaultFilenameExtension -{ - /* - Override to add an extension to a filename - - Note: be careful with that, needs to be consistent with object lookup! - */ return nil; } -- (NSArray *) davResourceType -{ - NSArray *rType, *groupDavCollection; - - if ([self respondsToSelector: @selector (groupDavResourceType)]) - { - groupDavCollection - = [NSArray arrayWithObjects: [self groupDavResourceType], - XMLNS_GROUPDAV, nil]; - rType = [NSArray arrayWithObjects: @"collection", groupDavCollection, - nil]; - } - else - rType = [NSArray arrayWithObject: @"collection"]; - - return rType; -} - -- (NSString *) davContentType -{ - return @"httpd/unix-directory"; -} - -- (NSArray *) toOneRelationshipKeys -{ - /* toOneRelationshipKeys are the 'files' contained in a folder */ - NSMutableArray *ma; - NSArray *names; - NSString *name, *ext; - unsigned i, count; - NSRange r; - - names = [self fetchContentObjectNames]; - count = [names count]; - ext = [self defaultFilenameExtension]; - if (count && [ext length] > 0) - { - ma = [NSMutableArray arrayWithCapacity: count]; - for (i = 0; i < count; i++) - { - name = [names objectAtIndex: i]; - r = [name rangeOfString: @"."]; - if (r.length == 0) - name = [NSMutableString stringWithFormat: @"%@.%@", name, ext]; - [ma addObject: name]; - } - - names = ma; - } - - return names; -} - -/* acls as a container */ - -- (NSArray *) aclUsersForObjectAtPath: (NSArray *) objectPathArray; -{ - EOQualifier *qualifier; - NSString *qs; - NSArray *records; - - qs = [NSString stringWithFormat: @"c_object = '/%@'", - [objectPathArray componentsJoinedByString: @"/"]]; - qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; - records = [[self ocsFolder] fetchAclMatchingQualifier: qualifier]; - - return [records valueForKey: @"c_uid"]; -} - -- (NSArray *) _fetchAclsForUser: (NSString *) uid - forObjectAtPath: (NSString *) objectPath -{ - EOQualifier *qualifier; - NSArray *records; - NSMutableArray *acls; - NSString *qs; - - qs = [NSString stringWithFormat: @"(c_object = '/%@') AND (c_uid = '%@')", - objectPath, uid]; - qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; - records = [[self ocsFolder] fetchAclMatchingQualifier: qualifier]; - - acls = [NSMutableArray array]; - if ([records count] > 0) - { - [acls addObject: SOGoRole_AuthorizedSubscriber]; - [acls addObjectsFromArray: [records valueForKey: @"c_role"]]; - } - - return acls; -} - -- (void) _cacheRoles: (NSArray *) roles - forUser: (NSString *) uid - forObjectAtPath: (NSString *) objectPath -{ - NSMutableDictionary *aclsForObject; - - aclsForObject = [aclCache objectForKey: objectPath]; - if (!aclsForObject) - { - aclsForObject = [NSMutableDictionary dictionary]; - [aclCache setObject: aclsForObject - forKey: objectPath]; - } - if (roles) - [aclsForObject setObject: roles forKey: uid]; - else - [aclsForObject removeObjectForKey: uid]; -} - -- (NSArray *) aclsForUser: (NSString *) uid - forObjectAtPath: (NSArray *) objectPathArray -{ - NSArray *acls; - NSString *objectPath; - NSDictionary *aclsForObject; - - objectPath = [objectPathArray componentsJoinedByString: @"/"]; - aclsForObject = [aclCache objectForKey: objectPath]; - if (aclsForObject) - acls = [aclsForObject objectForKey: uid]; - else - acls = nil; - if (!acls) - { - acls = [self _fetchAclsForUser: uid forObjectAtPath: objectPath]; - [self _cacheRoles: acls forUser: uid forObjectAtPath: objectPath]; - } - - if (!([acls count] || [uid isEqualToString: defaultUserID])) - acls = [self aclsForUser: defaultUserID - forObjectAtPath: objectPathArray]; - - return acls; -} - -- (void) removeAclsForUsers: (NSArray *) users - forObjectAtPath: (NSArray *) objectPathArray -{ - EOQualifier *qualifier; - NSString *uids, *qs, *objectPath; - NSMutableDictionary *aclsForObject; - - if ([users count] > 0) - { - objectPath = [objectPathArray componentsJoinedByString: @"/"]; - aclsForObject = [aclCache objectForKey: objectPath]; - if (aclsForObject) - [aclsForObject removeObjectsForKeys: users]; - uids = [users componentsJoinedByString: @"') OR (c_uid = '"]; - qs = [NSString - stringWithFormat: @"(c_object = '/%@') AND ((c_uid = '%@'))", - objectPath, uids]; - qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; - [[self ocsFolder] deleteAclMatchingQualifier: qualifier]; - } -} - -- (void) _commitRoles: (NSArray *) roles - forUID: (NSString *) uid - forObject: (NSString *) objectPath -{ - EOAdaptorChannel *channel; - GCSFolder *folder; - NSEnumerator *userRoles; - NSString *SQL, *currentRole; - - folder = [self ocsFolder]; - channel = [folder acquireAclChannel]; - userRoles = [roles objectEnumerator]; - currentRole = [userRoles nextObject]; - while (currentRole) - { - SQL = [NSString stringWithFormat: @"INSERT INTO %@" - @" (c_object, c_uid, c_role)" - @" VALUES ('/%@', '%@', '%@')", - [folder aclTableName], - objectPath, uid, currentRole]; - [channel evaluateExpressionX: SQL]; - currentRole = [userRoles nextObject]; - } - - [folder releaseChannel: channel]; -} - -- (void) setRoles: (NSArray *) roles - forUser: (NSString *) uid - forObjectAtPath: (NSArray *) objectPathArray -{ - NSString *objectPath; - NSMutableArray *newRoles; - - [self removeAclsForUsers: [NSArray arrayWithObject: uid] - forObjectAtPath: objectPathArray]; - - newRoles = [NSMutableArray arrayWithArray: roles]; - [newRoles removeObject: SOGoRole_AuthorizedSubscriber]; - [newRoles removeObject: SOGoRole_None]; - objectPath = [objectPathArray componentsJoinedByString: @"/"]; - [self _cacheRoles: newRoles forUser: uid - forObjectAtPath: objectPath]; - if (![newRoles count]) - [newRoles addObject: SOGoRole_None]; - - [self _commitRoles: newRoles forUID: uid forObject: objectPath]; -} - -/* acls */ -- (NSArray *) aclUsers -{ - return [self aclUsersForObjectAtPath: [self pathArrayToSOGoObject]]; -} - -- (NSArray *) aclsForUser: (NSString *) uid -{ - NSMutableArray *acls; - NSArray *ownAcls, *containerAcls; - - acls = [NSMutableArray array]; - ownAcls = [self aclsForUser: uid - forObjectAtPath: [self pathArrayToSOGoObject]]; - [acls addObjectsFromArray: ownAcls]; - if ([container respondsToSelector: @selector (aclsForUser:)]) - { - containerAcls = [container aclsForUser: uid]; - if ([containerAcls count] > 0) - { - if ([containerAcls containsObject: SOGoRole_ObjectReader]) - [acls addObject: SOGoRole_ObjectViewer]; -#warning this should be checked - if ([containerAcls containsObject: SOGoRole_ObjectEraser]) - [acls addObject: SOGoRole_ObjectEraser]; - } - } - - return acls; -} - -- (void) setRoles: (NSArray *) roles - forUser: (NSString *) uid -{ - return [self setRoles: roles - forUser: uid - forObjectAtPath: [self pathArrayToSOGoObject]]; -} - -- (void) removeAclsForUsers: (NSArray *) users -{ - return [self removeAclsForUsers: users - forObjectAtPath: [self pathArrayToSOGoObject]]; -} - -- (NSString *) defaultUserID -{ - return defaultUserID; -} - -- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid -{ - return [[self soURL] absoluteString]; -} - -- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid -{ - return [[self davURL] absoluteString]; -} - - (id) lookupName: (NSString *) lookupName inContext: (id) localContext acquire: (BOOL) acquire @@ -713,75 +98,19 @@ static NSString *defaultUserID = @""; return obj; } -- (NSComparisonResult) _compareByOrigin: (SOGoFolder *) otherFolder +- (BOOL) isFolderish { - 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; + return YES; } -- (NSComparisonResult) _compareByNameInContainer: (SOGoFolder *) otherFolder +- (NSString *) httpURLForAdvisoryToUser: (NSString *) uid { - 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; + return [[self soURL] absoluteString]; } -- (NSComparisonResult) compare: (SOGoFolder *) otherFolder +- (NSString *) resourceURLForAdvisoryToUser: (NSString *) uid { - NSComparisonResult comparison; - - comparison = [self _compareByOrigin: otherFolder]; - if (comparison == NSOrderedSame) - { - comparison = [self _compareByNameInContainer: otherFolder]; - if (comparison == NSOrderedSame) - comparison - = [[self displayName] - localizedCaseInsensitiveCompare: [otherFolder displayName]]; - } - - return comparison; + return [[self davURL] absoluteString]; } /* WebDAV */ @@ -796,6 +125,11 @@ static NSString *defaultUserID = @""; return [self isFolderish]; } +- (NSString *) davContentType +{ + return @"httpd/unix-directory"; +} + /* folder type */ - (NSString *) outlookFolderClass @@ -805,20 +139,11 @@ static NSString *defaultUserID = @""; return nil; } -/* description */ - -- (void) appendAttributesToDescription: (NSMutableString *) _ms -{ - [super appendAttributesToDescription:_ms]; - - [_ms appendFormat:@" ocs=%@", [self ocsPath]]; -} +/* acls */ -- (NSString *) loggingPrefix +- (NSArray *) aclsForUser: (NSString *) uid { - return [NSString stringWithFormat:@"<0x%08X[%@]:%@>", - self, NSStringFromClass([self class]), - [self nameInContainer]]; + return nil; } -@end /* SOGoFolder */ +@end diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index abb9acb1..18aec401 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -1017,4 +1017,11 @@ static BOOL kontactGroupDAV = YES; return ms; } +- (NSString *) loggingPrefix +{ + return [NSString stringWithFormat:@"<0x%08X[%@]:%@>", + self, NSStringFromClass([self class]), + [self nameInContainer]]; +} + @end /* SOGoObject */ diff --git a/SoObjects/SOGo/SOGoParentFolder.h b/SoObjects/SOGo/SOGoParentFolder.h index c54d08f8..3001e6b3 100644 --- a/SoObjects/SOGo/SOGoParentFolder.h +++ b/SoObjects/SOGo/SOGoParentFolder.h @@ -23,13 +23,13 @@ #ifndef SOGOPARENTFOLDERS_H #define SOGOPARENTFOLDERS_H -#import "SOGoObject.h" +#import "SOGoFolder.h" @class NSMutableDictionary; @class NSString; @class WOResponse; -@interface SOGoParentFolder : SOGoObject +@interface SOGoParentFolder : SOGoFolder { NSMutableDictionary *subFolders; NSString *OCSPath; @@ -39,10 +39,14 @@ + (NSString *) gcsFolderType; + (Class) subFolderClass; +- (NSString *) defaultFolderName; + - (void) setBaseOCSPath: (NSString *) newOCSPath; - (NSArray *) subFolders; +- (NSException *) newFolderWithName: (NSString *) name + andNameInContainer: (NSString *) newNameInContainer; - (NSException *) newFolderWithName: (NSString *) name nameInContainer: (NSString **) newNameInContainer; diff --git a/SoObjects/SOGo/SOGoParentFolder.m b/SoObjects/SOGo/SOGoParentFolder.m index 224fffba..a06e39c9 100644 --- a/SoObjects/SOGo/SOGoParentFolder.m +++ b/SoObjects/SOGo/SOGoParentFolder.m @@ -31,7 +31,7 @@ #import #import -#import "SOGoFolder.h" +#import "SOGoGCSFolder.h" #import "SOGoUser.h" #import "SOGoParentFolder.h" @@ -86,9 +86,9 @@ { NSArray *attrs; NSDictionary *row; - SOGoFolder *folder; + SOGoGCSFolder *folder; BOOL hasPersonal; - NSString *key, *path, *personalName; + NSString *key; if (!subFolderClass) subFolderClass = [[self class] subFolderClass]; @@ -111,17 +111,17 @@ row = [fc fetchAttributes: attrs withZone: NULL]; } - if (!hasPersonal) - { - folder = [subFolderClass objectWithName: @"personal" inContainer: self]; - personalName = [self labelForKey: [self defaultFolderName]]; - [folder setDisplayName: personalName]; - path = [NSString stringWithFormat: @"/Users/%@/%@/personal", - [self ownerInContext: context], - nameInContainer]; - [folder setOCSPath: path]; - [subFolders setObject: folder forKey: @"personal"]; - } +// if (!hasPersonal) +// { +// folder = [subFolderClass objectWithName: @"personal" inContainer: self]; +// personalName = [self labelForKey: [self defaultFolderName]]; +// [folder setDisplayName: personalName]; +// path = [NSString stringWithFormat: @"/Users/%@/%@/personal", +// [self ownerInContext: context], +// nameInContainer]; +// [folder setOCSPath: path]; +// [subFolders setObject: folder forKey: @"personal"]; +// } } - (void) appendPersonalSources @@ -163,7 +163,7 @@ NSUserDefaults *settings; NSEnumerator *allKeys; NSString *currentKey; - SOGoFolder *subscribedFolder; + SOGoGCSFolder *subscribedFolder; settings = [[context activeUser] userSettings]; subscribedReferences = [[settings objectForKey: nameInContainer] @@ -185,17 +185,15 @@ } - (NSException *) newFolderWithName: (NSString *) name - nameInContainer: (NSString **) newNameInContainer + andNameInContainer: (NSString *) newNameInContainer { NSString *newFolderID; - SOGoFolder *newFolder; + SOGoGCSFolder *newFolder; NSException *error; if (!subFolderClass) subFolderClass = [[self class] subFolderClass]; - *newNameInContainer = nil; - newFolderID = [self globallyUniqueObjectId]; newFolder = [subFolderClass objectWithName: newFolderID inContainer: self]; if ([newFolder isKindOfClass: [NSException class]]) error = (NSException *) newFolder; @@ -205,10 +203,7 @@ [newFolder setOCSPath: [NSString stringWithFormat: @"%@/%@", OCSPath, newFolderID]]; if ([newFolder create]) - { - error = nil; - *newNameInContainer = newFolderID; - } + error = nil; else error = [NSException exceptionWithHTTPStatus: 400 reason: @"The new folder could not be created"]; @@ -217,6 +212,23 @@ return error; } +- (NSException *) newFolderWithName: (NSString *) name + nameInContainer: (NSString **) newNameInContainer +{ + NSString *newFolderID; + NSException *error; + + newFolderID = [self globallyUniqueObjectId]; + error = [self newFolderWithName: name + andNameInContainer: newFolderID]; + if (error) + *newNameInContainer = nil; + else + *newNameInContainer = newFolderID; + + return error; +} + - (void) initSubFolders { NSString *login; @@ -268,20 +280,4 @@ sortedArrayUsingSelector: @selector (compare:)]; } -/* acls */ -- (NSArray *) aclsForUser: (NSString *) uid -{ - return nil; -} - -- (BOOL) davIsCollection -{ - return YES; -} - -- (NSString *) davContentType -{ - return @"httpd/unix-directory"; -} - @end diff --git a/SoObjects/SOGo/SOGoUserFolder.h b/SoObjects/SOGo/SOGoUserFolder.h index 7f52d41f..970f5e84 100644 --- a/SoObjects/SOGo/SOGoUserFolder.h +++ b/SoObjects/SOGo/SOGoUserFolder.h @@ -49,11 +49,6 @@ - (NSString *) ownerInContext: (WOContext *) _ctx; -/* pathes */ - -- (NSString *) ocsUserPath; -- (NSString *) ocsPrivateCalendarPath; - /* TODO: not implemented, bad bad */ // - (id)lookupFreeBusyObject; diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index 84297af2..5003c54d 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -68,7 +68,8 @@ if (!children) children = [[NSArray alloc] initWithObjects: - @"Calendar", @"Contacts", @"Mail", nil]; + @"Calendar", @"Contacts", @"Mail", + @"Preferences", nil]; return children; } @@ -92,39 +93,6 @@ // return [self lookupName: @"Groups" inContext: nil acquire: NO]; // } -/* pathes */ - -- (void) setOCSPath: (NSString *) _path -{ - [self warnWithFormat: - @"rejected attempt to reset user-folder path: '%@'", _path]; -} - -- (NSString *) ocsPath -{ - return [NSString stringWithFormat: @"/Users/%@", nameInContainer]; -} - -- (NSString *) ocsUserPath -{ - return [self ocsPath]; -} - -- (BOOL) folderIsMandatory -{ - return NO; -} - -- (NSString *) ocsPrivateCalendarPath -{ - return [[self ocsUserPath] stringByAppendingString:@"/Calendar"]; -} - -- (NSString *) ocsPrivateContactsPath -{ - return [[self ocsUserPath] stringByAppendingString:@"/Contacts"]; -} - /* name lookup */ // - (NSString *) permissionForKey: (NSString *) key @@ -140,7 +108,8 @@ SOGoAppointmentFolders *calendars; calendars = [$(@"SOGoAppointmentFolders") objectWithName: _key inContainer: self]; - [calendars setBaseOCSPath: [self ocsPrivateCalendarPath]]; + [calendars setBaseOCSPath: [NSString stringWithFormat: @"/Users/%@/Calendar", + nameInContainer]]; return calendars; } @@ -151,7 +120,8 @@ SOGoContactFolders *contacts; contacts = [$(@"SOGoContactFolders") objectWithName:_key inContainer: self]; - [contacts setBaseOCSPath: [self ocsPrivateContactsPath]]; + [contacts setBaseOCSPath: [NSString stringWithFormat: @"/Users/%@/Contacts", + nameInContainer]]; return contacts; } @@ -195,6 +165,9 @@ // obj = [self groupsFolder: _key inContext: _ctx]; else if ([_key isEqualToString: @"Mail"]) obj = [self mailAccountsFolder: _key inContext: _ctx]; + else if ([_key isEqualToString: @"Preferences"]) + obj = [$(@"SOGoPreferencesFolder") objectWithName: _key + inContainer: self]; else if ([_key isEqualToString: @"freebusy.ifb"]) obj = [self freeBusyObject:_key inContext: _ctx]; else diff --git a/UI/Common/UIxFolderActions.h b/UI/Common/UIxFolderActions.h index 8794bbea..96b6cbc1 100644 --- a/UI/Common/UIxFolderActions.h +++ b/UI/Common/UIxFolderActions.h @@ -31,11 +31,11 @@ @class NSMutableDictionary; @class LDAPUserManager; -@class SOGoFolder; +@class SOGoGCSFolder; @interface UIxFolderActions : WODirectAction { - SOGoFolder *clientObject; + SOGoGCSFolder *clientObject; LDAPUserManager *um; NSUserDefaults *ud; NSString *owner; diff --git a/UI/Common/UIxFolderActions.m b/UI/Common/UIxFolderActions.m index 1c2d59b0..44d21f6d 100644 --- a/UI/Common/UIxFolderActions.m +++ b/UI/Common/UIxFolderActions.m @@ -35,9 +35,9 @@ #import #import -#import -#import +#import #import +#import #import "WODirectAction+SOGo.h" diff --git a/UI/Common/product.plist b/UI/Common/product.plist index b9b6d7e7..157e7ace 100644 --- a/UI/Common/product.plist +++ b/UI/Common/product.plist @@ -71,7 +71,7 @@ }; }; }; - SOGoFolder = { + SOGoGCSFolder = { methods = { subscribe = { protectedBy = ""; diff --git a/UI/Contacts/UIxContactEditor.m b/UI/Contacts/UIxContactEditor.m index 6f395411..40842b64 100644 --- a/UI/Contacts/UIxContactEditor.m +++ b/UI/Contacts/UIxContactEditor.m @@ -581,7 +581,7 @@ Update: remember that there are group folders as well. */ NSString *uri, *objectId, *nextMethod; - id co; + SOGoObject *co; co = [self clientObject]; if ([co respondsToSelector: @selector (globallyUniqueObjectId)]) diff --git a/UI/Contacts/UIxContactFoldersView.m b/UI/Contacts/UIxContactFoldersView.m index fa43d810..8adba727 100644 --- a/UI/Contacts/UIxContactFoldersView.m +++ b/UI/Contacts/UIxContactFoldersView.m @@ -177,7 +177,7 @@ { NSMutableArray *folders; NSEnumerator *subfolders; - SOGoFolder *currentFolder; + SOGoGCSFolder *currentFolder; NSString *folderName; NSMutableDictionary *currentDictionary; SoSecurityManager *securityManager; diff --git a/UI/Contacts/product.plist b/UI/Contacts/product.plist index 3602be7a..1168ddcf 100644 --- a/UI/Contacts/product.plist +++ b/UI/Contacts/product.plist @@ -136,7 +136,7 @@ actionName = "delete"; }; edit = { - protectedBy = "Change Images And Files"; + protectedBy = "Access Contents Information"; pageName = "UIxContactEditor"; }; save = { @@ -158,16 +158,16 @@ protectedBy = ""; pageName = "UIxContactView"; }; - delete = { +/* delete = { protectedBy = "View"; pageName = "UIxContactView"; actionName = "delete"; - }; + }; */ edit = { - protectedBy = "View"; + protectedBy = "Access Contents Information"; pageName = "UIxContactEditor"; }; - save = { +/* save = { protectedBy = "View"; pageName = "UIxContactEditor"; actionName = "save"; @@ -176,7 +176,7 @@ protectedBy = "View"; pageName = "UIxContactEditor"; actionName = "write"; - }; + }; */ }; }; }; diff --git a/UI/MainUI/product.plist b/UI/MainUI/product.plist index 9c0bba20..664e4cf5 100644 --- a/UI/MainUI/product.plist +++ b/UI/MainUI/product.plist @@ -49,7 +49,7 @@ }; }; SOGoParentFolder = { - superclass = "SOGoObject"; + superclass = "SOGoFolder"; protectedBy = "Access Contents Information"; defaultRoles = { "Access Contents Information" = ( "Authenticated" ); diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index d216c0fe..b9f0e761 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -6,6 +6,7 @@ "General" = "General"; "Calendar Options" = "Calendar Options"; "Mail Options" = "Mail Options"; +"Identities" = "Identities"; "Password" = "Password"; /* ooo */ @@ -82,6 +83,9 @@ "messageforward_inline" = "Inline"; "messageforward_attached" = "As Attachment"; +"Default identity:" = "Default identity:"; +"Manage identities..." = "Manage identities..."; + /* password */ "New password:" = "New password:"; "Confirmation:" = "Confirmation:"; diff --git a/UI/PreferencesUI/French.lproj/Localizable.strings b/UI/PreferencesUI/French.lproj/Localizable.strings index 99d33387..4fe9850e 100644 --- a/UI/PreferencesUI/French.lproj/Localizable.strings +++ b/UI/PreferencesUI/French.lproj/Localizable.strings @@ -6,6 +6,7 @@ "General" = "Général"; "Calendar Options" = "Calendrier"; "Mail Options" = "Courrier"; +"Identities" = "Identités"; "Password" = "Mot de passe"; /* ooo */ @@ -79,6 +80,10 @@ "messageforward_inline" = "intégrés"; "messageforward_attached" = "en pièces jointes"; +/* Identities */ +"Default identity:" = "Identité par défaut :"; +"Manage identities..." = "Gérer les identitiés..."; + /* password */ "New password:" = "Nouveau mot de passe :"; "Confirmation:" = "Confirmation :"; diff --git a/UI/PreferencesUI/German.lproj/Localizable.strings b/UI/PreferencesUI/German.lproj/Localizable.strings index e25c85fb..63da5cd6 100644 --- a/UI/PreferencesUI/German.lproj/Localizable.strings +++ b/UI/PreferencesUI/German.lproj/Localizable.strings @@ -6,6 +6,7 @@ "General" = "Allgemein"; "Calendar Options" = "Kalender"; "Mail Options" = "E-Mail"; +"Identities" = "Identities"; "Password" = "Passwort"; /* ooo */ @@ -79,6 +80,9 @@ "messageforward_inline" = "Eingebunden"; "messageforward_attached" = "Als Anhang"; +"Default identity:" = "Default identity:"; +"Manage identities..." = "Manage identities..."; + /* password */ "New password:" = "Neues Passwort:"; "Confirmation:" = "Bestätigung:"; diff --git a/UI/PreferencesUI/UIxJSONPreferences.m b/UI/PreferencesUI/UIxJSONPreferences.m index 0b18a97b..de905593 100644 --- a/UI/PreferencesUI/UIxJSONPreferences.m +++ b/UI/PreferencesUI/UIxJSONPreferences.m @@ -33,14 +33,14 @@ @implementation UIxJSONPreferences -- (WOResponse *) _makeResponse: (NSString *) jsonText +- (WOResponse *) _makeResponse: (NSUserDefaults *) defaults { WOResponse *response; response = [context response]; [response setHeader: @"text/plain; charset=utf-8" forKey: @"content-type"]; - [response appendContentString: jsonText]; + [response appendContentString: [defaults jsonRepresentation]]; return response; } @@ -51,7 +51,7 @@ defaults = [[context activeUser] userDefaults]; - return [self _makeResponse: [defaults jsonRepresentation]]; + return [self _makeResponse: defaults]; } - (WOResponse *) jsonSettingsAction @@ -60,7 +60,7 @@ settings = [[context activeUser] userSettings]; - return [self _makeResponse: [settings jsonRepresentation]]; + return [self _makeResponse: settings]; } @end diff --git a/UI/PreferencesUI/UIxPreferences.h b/UI/PreferencesUI/UIxPreferences.h index 5570fbc7..c9788924 100644 --- a/UI/PreferencesUI/UIxPreferences.h +++ b/UI/PreferencesUI/UIxPreferences.h @@ -32,7 +32,7 @@ @interface UIxPreferences : UIxComponent { - NSString *item; + id item; SOGoUser *user; NSUserDefaults *userDefaults; NSCalendarDate *today; diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index 0a6c33ef..95867533 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -28,6 +28,7 @@ #import #import +#import #import #import "UIxPreferences.h" @@ -466,6 +467,35 @@ static BOOL shouldDisplayPasswordChange = NO; [userDefaults setObject: newMessageForwarding forKey: @"MessageForwarding"]; } +// +- (NSArray *) identitiesList +{ + return [user allIdentities]; +} + +- (NSString *) itemIdentityText +{ + return [item keysWithFormat: @"%{fullName} <%{email}>"]; +} + +- (NSDictionary *) defaultIdentity +{ + NSDictionary *currentIdentity, *defaultIdentity; + NSEnumerator *identities; + + defaultIdentity = nil; + + identities = [[user allIdentities] objectEnumerator]; + while (!defaultIdentity + && (currentIdentity = [identities nextObject])) + if ([[currentIdentity objectForKey: @"isDefault"] boolValue]) + defaultIdentity = currentIdentity; + + return defaultIdentity; +} + - (id ) defaultAction { id results; diff --git a/UI/PreferencesUI/product.plist b/UI/PreferencesUI/product.plist index de4a1d90..2891bffa 100644 --- a/UI/PreferencesUI/product.plist +++ b/UI/PreferencesUI/product.plist @@ -20,6 +20,10 @@ protectedBy = "View"; pageName = "UIxPreferences"; }; + identities = { + protectedBy = "View"; + pageName = "UIxIdentities"; + }; jsonDefaults = { protectedBy = "View"; actionClass = "UIxJSONPreferences"; diff --git a/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox b/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox index 8f771ded..046ae859 100644 --- a/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox +++ b/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox @@ -5,6 +5,9 @@ xmlns:const="http://www.skyrix.com/od/constant" xmlns:label="OGo:label" > + + +