]> err.no Git - sope/blob - sope-appserver/SoOFS/OFSFactoryContext.m
added strict OSX bundle dependencies
[sope] / sope-appserver / SoOFS / OFSFactoryContext.m
1 /*
2   Copyright (C) 2002-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE 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
9   later version.
10
11   SOPE 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.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #include "OFSFactoryContext.h"
23 #include "OFSFolder.h"
24 #include "common.h"
25
26 @implementation OFSFactoryContext
27
28 + (OFSFactoryContext *)contextForChild:(NSString *)_name
29   storagePath:(NSString *)_sp
30   ofFolder:(OFSFolder *)_folder
31 {
32   OFSFactoryContext *ctx;
33   
34   ctx = [[self alloc] init];
35   ctx->fileManager = [[_folder fileManager] retain];
36   ctx->storagePath = [_sp copy];
37   ctx->container   = [_folder retain];
38   ctx->name        = [_name copy];
39   return [ctx autorelease];
40 }
41 + (OFSFactoryContext *)contextForNewChild:(NSString *)_name
42   storagePath:(NSString *)_sp
43   ofFolder:(OFSFolder *)_folder
44 {
45   OFSFactoryContext *ctx;
46   
47   if ((ctx = [self contextForChild:_name storagePath:_sp ofFolder:_folder])) {
48     ctx->isNewObject = YES;
49   }
50   return ctx;
51 }
52
53 + (OFSFactoryContext *)contextWithFileManager:(id<NSObject,NGFileManager>)_fm
54   storagePath:(NSString *)_sp
55 {
56   OFSFactoryContext *ctx;
57   
58   ctx = [[self alloc] init];
59   ctx->fileManager = [_fm retain];
60   ctx->storagePath = [_sp copy];
61   return [ctx autorelease];
62 }
63
64 - (void)dealloc {
65   [self->fileType    release];
66   [self->mimeType    release];
67   [self->fileManager release];
68   [self->container   release];
69   [self->name        release];
70   [self->storagePath release];
71   [super dealloc];
72 }
73
74 /* accessors */
75
76 - (id<NSObject,NGFileManager>)fileManager {
77   return self->fileManager;
78 }
79 - (NSString *)storagePath {
80   return self->storagePath;
81 }
82 - (id)container {
83   return self->container;
84 }
85 - (NSString *)nameInContainer {
86   return self->name;
87 }
88
89 - (NSString *)fileType {
90   return self->fileType;
91 }
92 - (NSString *)mimeType {
93   return self->mimeType;
94 }
95
96 - (BOOL)isNewObject {
97   return self->isNewObject;
98 }
99
100 /* description */
101
102 - (NSString *)description {
103   NSMutableString *ms;
104   
105   ms = [NSMutableString stringWithCapacity:64];
106   [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
107   
108   if (self->isNewObject)
109     [ms appendString:@" NEW"];
110   if (self->name)        [ms appendFormat:@" create=%@", self->name];
111   if (self->container)   [ms appendFormat:@" in=%@",   self->container];
112   if (self->fileType)    [ms appendFormat:@" type=%@", self->fileType];
113   if (self->mimeType)    [ms appendFormat:@" mime=%@", self->mimeType];
114   if (self->storagePath) [ms appendFormat:@" path=%@", self->storagePath];
115   
116   [ms appendString:@">"];
117   return ms;
118 }
119
120 @end /* OFSFactoryContext */