source: branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireDirectory.h @ 610

Revision 610, 8.9 KB checked in by gbooker, 6 years ago (diff)

Check to make sure the metadata isn't deleted before asking for information about the directory

Line 
1/*
2 * SapphireDirectory.h
3 * Sapphire
4 *
5 * Created by Graham Booker on Apr. 9, 2008.
6 * Copyright 2008 Sapphire Development Team and/or www.nanopi.net
7 * All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
10 * General Public License as published by the Free Software Foundation; either version 3 of the License,
11 * or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
14 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15 * Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with this program; if not,
18 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 */
20
21//Sapphire Virtual Directory Movie Folders
22extern NSString *VIRTUAL_DIR_ROOT_KEY;
23extern NSString *VIRTUAL_DIR_ALL_KEY;
24//extern NSString *VIRTUAL_DIR_PREMIER_KEY;
25extern NSString *VIRTUAL_DIR_CAST_KEY;
26extern NSString *VIRTUAL_DIR_DIRECTOR_KEY;
27extern NSString *VIRTUAL_DIR_GENRE_KEY;
28extern NSString *VIRTUAL_DIR_TOP250_KEY;
29//extern NSString *VIRTUAL_DIR_IMDB_RATING_KEY;
30extern NSString *VIRTUAL_DIR_OSCAR_KEY;
31
32@class SapphireFileMetaData;
33
34/*!
35 * @brief A protocol for the SapphireMetaData to inform its delegate of updates to data
36 *
37 * This protocol provides a method by which metadata can send changes back to its delegate.
38 */
39@protocol SapphireMetaDataDelegate <NSObject>
40
41/*!
42 * @brief The import on a file completed
43 *
44 * If a import of metadata was progressing in the background, the delegate is informed when the process has completed for a file.
45 *
46 * @param file Filename to the file which completed
47 */
48- (void)updateCompleteForFile:(NSString *)file;
49
50/*!
51 * @brief The directory contents changed, update display
52 *
53 * A background import can add or remove files from a directory.  The delegate is informed that this has happened so it can update its UI or some other action
54 */
55- (void)directoryContentsChanged;
56@end
57
58/*!
59 * @brief A protocol for the SapphireMetaDataScanner to request more data of its delegate
60 *
61 * Since the SapphireMetaDataScanner runs with the event loop, it needs a method to report back its progress and results.  It also provides a means for the scanner to know it should cancel its process.
62 */
63@protocol SapphireMetaDataScannerDelegate <NSObject>
64
65/*!
66 * @brief Finished scanning the dir
67 *
68 * The SapphireMetaDataScanner has finished scanning a directory and is ready to return its results.
69 *
70 * @param subs The subfiles found by the scanner
71 */
72- (void)gotSubFiles:(NSArray *)subs;
73
74/*!
75 * @brief Started Scanning a directory
76 *
77 * The SapphireMetaDataScanner has started scanning a directory.
78 *
79 * @param dir The current directory it is scanning
80 */
81- (void)scanningDir:(NSString *)dir;
82
83/*!
84 * @brief Check to see if the scan should be canceled
85 *
86 * If a delegate wishes to cancel the scan of a directory, then simply return YES to this function, and the scan will cease.
87 *
88 * @return YES if the scan should be canceled
89 */
90- (BOOL)getSubFilesCanceled;
91@end
92
93/*!
94 * @brief The importer Backgrounding protocol
95 *
96 * This protocol is designed for use with distributed objects.
97 */
98@protocol SapphireImporterBackgroundProtocol <NSObject>
99/*!
100 * @brief Tells the importer of a background import
101 *
102 * This is for use with distributed objects
103 */
104- (oneway void)informComplete:(BOOL)updated;
105@end
106
107@protocol SapphireMetaDataProtocol;
108
109/*!
110 * @brief A protocol for a directory
111 *
112 * This protocol provides a method by which metadata directories can be used without regard as to whether they are real or virtual
113 */
114@protocol SapphireDirectory <SapphireMetaDataProtocol>
115
116/*!
117 * @brief Get the delegate for the metadata
118 *
119 * @return The current delegate
120 */
121- (id <SapphireMetaDataDelegate>)delegate;
122
123/*!
124 * @brief Sets the delegate for the metadata
125 *
126 * @param newDelegate The new delegate
127 */
128- (void)setDelegate:(id <SapphireMetaDataDelegate>)newDelegate;
129
130/*!
131 * @brief Reloads the directory contents
132 *
133 * This function examines the directory on the disk and reloads the objects contents from what it finds there.
134 */
135- (void)reloadDirectoryContents;
136
137/*!
138 * @brief Returns the path of the current metadata
139 *
140 * All metadata has a path associated with it; this function returns the path for this one.
141 *
142 * @return The path
143 */
144- (NSString *)path;
145
146/*!
147 * @brief Retrieve a list of all file names
148 *
149 * @return An NSArray of all file names
150 */
151- (NSArray *)files;
152
153/*!
154 * @brief Retrieve a list of all directory names
155 *
156 * @return An NSArray of all directory names
157 */
158- (NSArray *)directories;
159
160/*!
161 * @brief Get the metadata object for a file.
162 *
163 * @param file The file within this dir
164 * @return The file's metadata, nil if one doesn't exist
165 */
166- (SapphireFileMetaData *)metaDataForFile:(NSString *)file;
167
168/*!
169 * @brief Get the metadata object for a directory.
170 *
171 * @param dir The directory within this dir
172 * @return The directory's metadata, nil if one doesn't exist
173 */
174- (id <SapphireDirectory>)metaDataForDirectory:(NSString *)directory;
175
176/*!
177 * @brief Check to see if any filtered files match the predicate
178 *
179 * @param pred The predicate to check
180 */
181- (BOOL)containsFileMatchingPredicate:(NSPredicate *)pred;
182
183/*!
184 * @brief Checks to see if directory contains any files with filter
185 *
186 * @param filter The filter predicate to test
187 */
188- (BOOL)containsFileMatchingFilterPredicate:(NSPredicate *)pred;
189
190/*!
191 * @brief Invoke a command on all files contained within this directory within filter
192 *
193 * @param fileInv The invokation to invoke
194 */
195- (void)invokeOnAllFiles:(NSInvocation *)fileInv;
196
197/*!
198 * @brief Gets the filter predicate in use for filtering in this directory
199 *
200 * @return The predict in use
201 */
202- (NSPredicate *)filterPredicate;
203
204/*!
205 * @brief Sets the filter predicate to use for filtering in this directory
206 *
207 * @param predicate The predict to use
208 */
209- (void)setFilterPredicate:(NSPredicate *)predicate;
210
211/*!
212 * @brief Resume the import process
213 */
214- (void)resumeImport;
215
216/*!
217 * @brief Cancel the import process
218 */
219- (void)cancelImport;
220
221/*!
222 * @brief Get the metadata for all the files contained within this directory tree
223 *
224 * @param subDelegate The delegate to inform when scan is complete
225 * @param skip A set of directories to skip.  Note, this set is modified
226 */
227- (void)getSubFileMetasWithDelegate:(id <SapphireMetaDataScannerDelegate>)subDelegate skipDirectories:(NSMutableSet *)skip;
228
229/*!
230 * @brief Scan for all files contained within this directory tree
231 *
232 * @param subDelegate The delegate to inform when scan is complete
233 * @param skip A set of directories to skip.  Note, this set is modified
234 */
235- (void)scanForNewFilesWithDelegate:(id <SapphireMetaDataScannerDelegate>)subDelegate skipDirectories:(NSMutableSet *)skip;
236
237/*!
238 * @brief Get the cover art Path
239 *
240 * Returns the cover art path for this show
241 *
242 * @return The path for the cover art, nil if none found
243 */
244- (NSString *)coverArtPath;
245
246/*!
247 * @brief Clear the watched/favorite cache for this dir and its parents
248 *
249 * The watched and favorite values for all dirs is cached for speed reasons.  If this value changes, the cache needs to be invalidated
250 */
251- (void)clearPredicateCache;
252
253/*!
254 * @brief The managed object context
255 *
256 * @return The managed object context for the metadata
257 */
258- (NSManagedObjectContext *)managedObjectContext;
259
260/*!
261 * @brief Returns whether the managed object is deleted
262 *
263 * @return YES if the current directory is deleted, NO otherwise
264 */
265- (BOOL)isDeleted;
266
267@end
268
269@protocol SapphireSortableDirectory <SapphireDirectory>
270
271/*!
272 * @brief Gets the available file sorters, default first
273 *
274 * @return The available file sorters, default first
275 */
276- (NSArray *)fileSorters;
277
278/*!
279 * @brief Gets the sort method used
280 *
281 * @return The sort method used
282 */
283- (int)sortMethodValue;
284
285/*!
286 * @brief Sets the sort method to use
287 *
288 * @param value_ The sort method to use
289 */
290- (void)setSortMethodValue:(int)value_;
291
292@end
293
294
295/*!
296 * @brief Set subtree to watched or unwatched with restriction as to predicate.  Does not follow symlinks
297 *
298 * @param dir The subtree
299 * @param watched YES if watched, NO otherwise
300 */
301void setSubtreeToWatched(id <SapphireDirectory> dir, BOOL watched);
302
303/*!
304 * @brief Set subtree to favorite or not favorite with restriction as to predicate.  Does not follow symlinks
305 *
306 * @param dir The subtree
307 * @param favorite YES if favorite, NO otherwise
308 */
309void setSubtreeToFavorite(id <SapphireDirectory> dir, BOOL favorite);
310
311/*!
312 * @brief Set subtree to re-import from the specified source with restriction as to predicate.  Does not follow symlinks
313 *
314 * @param dir The subtree
315 * @param mask The source(s) on which to re-import
316 */
317void setSubtreeToReimportFromMask(id <SapphireDirectory> dir, int mask);
318
319/*!
320 * @brief Clear metadata for an entire subtree with restriction as to predicate.  Does not follow symlinks
321 */
322void setSubtreeToClearMetaData(id <SapphireDirectory> dir);
Note: See TracBrowser for help on using the repository browser.