#ifndef __OGoContentStore_OCSFolderType_H__
#define __OGoContentStore_OCSFolderType_H__
+/*
+ OCSFolderType
+
+ This is the "model" of a folder, it specifies what quick attributes are
+ available, in which tables it is stored and how it is retrieved.
+
+ For now, we only support one 'quick' table (we might want to have multiple
+ ones in the future).
+*/
+
#import <Foundation/NSObject.h>
+@class NSString, NSDictionary;
+@class EOQualifier;
+@class OCSFolder;
+
@interface OCSFolderType : NSObject
{
+ NSString *blobTablePattern; // eg 'SOGo_$folderId$_blob
+ NSString *quickTablePattern; // eg 'SOGo_$folderId$_quick
+ NSDictionary *fields;
+ EOQualifier *folderQualifier; // to further limit the table set
}
+/* operations */
+
+- (NSString *)blobTableNameForFolder:(OCSFolder *)_folder;
+- (NSString *)quickTableNameForFolder:(OCSFolder *)_folder;
+
@end
#endif /* __OGoContentStore_OCSFolderType_H__ */
// $Id$
#include "OCSFolderType.h"
+#include "OCSFolder.h"
#include "common.h"
+#include <EOControl/EOKeyValueCoding.h>
@implementation OCSFolderType
- (void)dealloc {
+ [self->blobTablePattern release];
+ [self->quickTablePattern release];
+ [self->fields release];
+ [self->folderQualifier release];
[super dealloc];
}
+/* operations */
+
+- (NSString *)blobTableNameForFolder:(OCSFolder *)_folder {
+ return [self->blobTablePattern
+ stringByReplacingVariablesWithBindings:_folder];
+}
+- (NSString *)quickTableNameForFolder:(OCSFolder *)_folder {
+ return [self->quickTablePattern
+ stringByReplacingVariablesWithBindings:_folder];
+}
+
+- (EOQualifier *)qualifierForFolder:(OCSFolder *)_folder {
+ NSArray *keys;
+ NSDictionary *bindings;
+
+ keys = [[self->folderQualifier allQualifierKeys] allObjects];
+ if ([keys count] == 0)
+ return self->folderQualifier;
+
+ bindings = [_folder valuesForKeys:keys];
+ return [self->folderQualifier qualifierWithBindings:bindings
+ requiresAllVariables:NO];
+}
+
+/* description */
+
+- (NSString *)description {
+ NSMutableString *ms;
+
+ ms = [NSMutableString stringWithCapacity:256];
+ [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+
+ [ms appendFormat:@" blobtable='%@'", self->blobTablePattern];
+ [ms appendFormat:@" quicktable='%@'", self->quickTablePattern];
+ [ms appendFormat:@" fields=%@", self->fields];
+
+ if (self->folderQualifier)
+ [ms appendFormat:@" qualifier=%@", self->folderQualifier];
+
+ [ms appendString:@">"];
+ return ms;
+}
+
@end /* OCSFolderType */