2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "SOGoFolder.h"
24 #include <GDLContentStore/GCSFolderManager.h>
25 #include <GDLContentStore/GCSFolder.h>
27 @implementation SOGoFolder
30 [self->ocsFolder release];
31 [self->ocsPath release];
41 - (void)setOCSPath:(NSString *)_path {
42 if ([self->ocsPath isEqualToString:_path])
46 [self warnWithFormat:@"GCS path is already set! '%@'", _path];
48 ASSIGNCOPY(self->ocsPath, _path);
50 - (NSString *)ocsPath {
54 - (GCSFolderManager *)folderManager {
55 return [GCSFolderManager defaultFolderManager];
57 - (GCSFolder *)ocsFolderForPath:(NSString *)_path {
58 return [[self folderManager] folderAtPath:_path];
60 - (GCSFolder *)ocsFolder {
61 if (self->ocsFolder != nil)
62 return [self->ocsFolder isNotNull] ? self->ocsFolder : nil;
64 self->ocsFolder = [[self ocsFolderForPath:[self ocsPath]] retain];
65 return self->ocsFolder;
68 - (NSArray *)fetchContentObjectNames {
69 NSArray *fields, *records;
71 fields = [NSArray arrayWithObject:@"c_name"];
72 records = [[self ocsFolder] fetchFields:fields matchingQualifier:nil];
73 if (![records isNotNull]) {
74 [self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__];
77 if ([records isKindOfClass:[NSException class]])
79 return [records valueForKey:@"c_name"];
81 - (NSDictionary *)fetchContentStringsAndNamesOfAllObjects {
84 files = [[self ocsFolder] fetchContentsOfAllFiles];
85 if (![files isNotNull]) {
86 [self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__];
89 if ([files isKindOfClass:[NSException class]])
96 - (NSString *)defaultFilenameExtension {
98 Override to add an extension to a filename
100 Note: be careful with that, needs to be consistent with object lookup!
105 - (NSArray *)toOneRelationshipKeys {
106 /* toOneRelationshipKeys are the 'files' contained in a folder */
112 if ((names = [self fetchContentObjectNames]) == nil)
115 if ((count = [names count]) == 0)
118 if ((ext = [self defaultFilenameExtension]) == nil)
121 ma = [NSMutableArray arrayWithCapacity:count];
122 for (i = 0; i < count; i++) {
126 name = [names objectAtIndex:i];
127 r = [name rangeOfString:@"."];
129 name = [[name stringByAppendingString:@"."] stringByAppendingString:ext];
138 - (BOOL)davIsCollection {
139 return [self isFolderish];
144 - (NSString *)outlookFolderClass {
150 - (void)appendAttributesToDescription:(NSMutableString *)_ms {
151 [super appendAttributesToDescription:_ms];
153 [_ms appendFormat:@" ocs=%@", [self ocsPath]];
156 - (NSString *)loggingPrefix {
157 return [NSString stringWithFormat:@"<0x%08X[%@]:%@>",
158 self, NSStringFromClass([self class]),
159 [self nameInContainer]];
162 @end /* SOGoFolder */