1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
//
// LiFileStore.h
// Liaison
//
// Created by Brian Cully on Sat May 24 2003.
// Copyright (c) 2003 Brian Cully. All rights reserved.
//
// Notification names.
//
// When the file store list changes.
#define LiFileStoresChangedNotification @"LiFileStoresChangedNotification"
// When a file gets changed.
#define LiFileChangedNotification @"LiFileChangedNotification"
// Keys in the userInfo for LiFileStoresChangedNotification
#define LiFileStoreAdded @"LiFileStoreAdded"
#define LiFileStoreRemoved @"LiFileStoreRemoved"
// Keys in the userInfo for LiFileChangedNotification.
#define LiFilesAdded @"LiFilesAdded"
#define LiFilesChanged @"LiFilesChanged"
#define LiFilesRemoved @"LiFilesRemoved"
// For LiFilesChanged and LiFilesRemoved.
#define LiFileOldAttributes @"LiFilesOldAttributes"
// The keys we supply for every file.
#define LiFileHandleAttribute @"LiFileHandleAttribute"
#define LiDirectoryAttribute @"LiDirectoryAttribute"
#define LiFilenameAttribute @"LiFilenameAttribute"
#define LiTypeAttribute @"LiTypeAttribute"
#define LiLastModifiedDateAttribute @"LiLastModifiedDateAttribute"
#define LiCreationDateAttribute @"LiCreationDateAttribute"
#define LiFileSizeAttribute @"LiFileSizeAttribute"
#define LiGroupsAttribute @"LiGroupsAttribute"
#define LiHFSCreatorAttribute @"LiHFSCreatorAttribute"
#define LiHFSTypeAttribute @"LiHFSTypeAttribute"
#define LiApplicationAttribute @"LiApplicationAttribute"
#define LiIsEditableAttribute @"LiIsEditableAttribute"
@class LiFileHandle;
@class LiFileStore;
@class LiFilter;
@protocol LiFileStoreDelegate <NSObject>
// Sync the file store database to permanent storage.
- (BOOL)synchronizeFileStore;
// Sync the file handle to disk.
- (void)synchronizeFileHandle: (LiFileHandle *)aFileHandle
withNewAttributes: (NSMutableDictionary *)someAttributes;
// Update a file handle from permanent storage.
- (BOOL)shouldUpdateFileHandle: (LiFileHandle *)aFileHandle;
- (void)updateFileHandle: (LiFileHandle *)aFileHandle;
// Open a file handle. Since a file must be on local storage to
// open it, if the file doesn't exist there, delegates must first
// create the file before opening it.
- (void)openFileHandle: (LiFileHandle *)aFileHandle;
// Attempt to add a file, specified by a URL, to the library.
// Returns a non-nil LiFileHandle that matches the newly added file
// on success, nil on failure.
- (LiFileHandle *)addURL: (NSURL *)anURL
toFileStore: (LiFileStore *)aFileStore;
// Return a standard URL for a file. This can be anything you want,
// but it should always point to the file in some way.
- (NSURL *)urlForFileHandle: (LiFileHandle *)aFileHandle;
// Used to fill in default values for a particular attribute.
// For instance, you can return a set of groups for LiGroupsAttribute.
- (NSArray *)defaultValuesForAttribute: (NSString *)anAttribute;
// For messing with the default attributes for a plugin.
- (BOOL)addDefaultAttribute: (NSDictionary *)anAttribute toFileStore: (LiFileStore *)aFileStore;
- (BOOL)changeDefaultValueForAttribute: (NSDictionary *)anAttribute toValue: (id)aValue inFileStore: (LiFileStore *)aFileStore;
- (BOOL)removeDefaultAttribute: (NSDictionary *)anAttribute fromFileStore: (LiFileStore *)aFileStore;
@end
@interface LiFileStore : NSObject <NSCopying, NSCoding>
{
id theStoreID;
id <LiFileStoreDelegate>theDelegate;
BOOL theStoreIsEditable;
NSImage *theIcon;
NSString *theName;
NSMutableDictionary *theFiles;
NSMutableDictionary *theIndexes;
NSMutableSet *theAddedFiles, *theChangedFiles, *theRemovedFiles;
unsigned long nextHandle;
}
// Look up stores via ID.
+ (NSArray *)allFileStores;
+ (NSEnumerator *)fileStoreEnumerator;
+ (LiFileStore *)fileStoreWithID: (id)aStoreID;
+ (void)removeStoreWithID: (id)aStoreID;
// Create an auto-released file store.
+ (LiFileStore *)fileStoreWithName: (NSString *)aName;
- (LiFileStore *)initWithName: (NSString *)aName;
// Use the following methods to control how to manage store indexes.
- (void)addIndexForAttribute: (NSString *)anAttribute;
- (NSMutableDictionary *)indexForAttribute: (NSString *)anAttribute;
- (void)removeIndexForAttribute: (NSString *)anAttribute;
- (id)fileIDWithAttributes: (NSDictionary *)someAttributes;
- (void)updateFileID: (id)aFileID
withAttributes: (NSDictionary *)someAttributes;
- (void)removeFileID: (id)aFileID;
- (NSDictionary *)attributesForFileID: (id)aFileID;
- (NSArray *)allFileIDs;
- (NSArray *)fileIDsMatchingFilter: (LiFilter *)aFilter;
// Test attribute dictionaries against a filter.
- (BOOL)attributes: (NSDictionary *)someAttributes
matchFilter: (LiFilter *)aFilter;
// Return all the values in the library for an attribute.
- (NSArray *)allValuesForAttribute: (NSString *)anAttribute;
@property unsigned long nextHandle;
@property (retain,getter=name) NSString *theName;
@property (retain,getter=icon) NSImage *theIcon;
@property (retain) NSMutableDictionary *theIndexes;
@property (retain,getter=storeID) id theStoreID;
@property (retain,getter=delegate) id <LiFileStoreDelegate>theDelegate;
@property (getter=isEditable,setter=setEditable:) BOOL theStoreIsEditable;
@property (retain) NSMutableDictionary *theFiles;
@end
@interface LiFileStore (CommonAccessors)
- (void)synchronize;
- (LiFileHandle *)addURL: (NSURL *)anURL;
@end
@interface LiFileStore (Accessors)
- (id)storeID;
- (void)setStoreID: (id)anID;
- (id <LiFileStoreDelegate>)delegate;
- (void)setDelegate: (id <LiFileStoreDelegate>)aDelegate;
- (BOOL)isEditable;
- (void)setEditable: (BOOL)editable;
- (NSString *)name;
- (void)setName: (NSString *)aName;
- (NSImage *)icon;
- (void)setIcon: (NSImage *)anIcon;
- (NSMutableSet *)addedFiles;
- (void)setAddedFiles: (NSMutableSet *)aSet;
- (NSMutableSet *)changedFiles;
- (void)setChangedFiles: (NSMutableSet *)aSet;
- (NSMutableSet *)removedFiles;
- (void)setRemovedFiles: (NSMutableSet *)aSet;
@end
@interface LiFileStore (Scripting)
- (NSScriptObjectSpecifier *)objectSpecifier;
@end
|