root/branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireMetaDataSupport.h @ 820

Revision 820, 3.7 KB (checked in by gbooker, 17 months ago)

Use a separate thread for rescanning a directory and send changes back to main thread. Tricky, but it works.

Line 
1/*
2 * SapphireMetaDataSupport.h
3 * Sapphire
4 *
5 * Created by Graham Booker on Apr. 16, 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@class SapphireMetaDataUpgrading;
22
23NSString *searchCoverArtExtForPath(NSString *path);
24
25/*!
26 * @brief The basic support class
27 *
28 * This class contains many of the support functions necessary for operation.
29 */
30@interface SapphireMetaDataSupport : NSObject {
31        NSManagedObjectContext  *mainMoc;                       /*!< @brief The main context*/
32        NSTimer                                 *writeTimer;            /*!< @brief The timer to agregate writes*/
33        NSTimeInterval                  interval;                       /*!< @brief The write interval*/
34        BOOL                                    locked;                         /*!< @brief Was the DB locked during the last save*/
35}
36
37/*!
38 * @brief Prune unused parts of the metadata
39 *
40 * This function first prunes movies with no files, then any cast, genres, and directors with no movies.
41 * Then, it does the same with Episodes, followed by Seasons and TV Shows
42 *
43 * @param moc The context to prune
44 */
45+ (void)pruneMetaData:(NSManagedObjectContext *)moc;
46
47/*!
48 * @brief Save the context
49 *
50 * @param context The context to save
51 * @return YES if the save succeeded, NO otherwise
52 */
53+ (BOOL)save:(NSManagedObjectContext *)context;
54
55/*!
56 * @brief Save changes in a context in the main context
57 *
58 * @param context The context with changes to save
59 */
60+ (void)applyChangesFromContext:(NSManagedObjectContext *)context;
61
62/*!
63 * @brief Sets the main context
64 *
65 * @param moc the main context
66 */
67+ (void)setMainContext:(NSManagedObjectContext *)moc;
68
69/*!
70 * @brief Was the DB locked in last save?
71 *
72 * @return YES if it was locked, NO otherwise
73 */
74+ (BOOL)wasLocked;
75
76/*!
77 * @brief Import the old plist into the context
78 *
79 * @param v1Context The context to use for old objects
80 * @param context The context to use for new objects
81 * @param display The display for UI feedback
82 */
83+ (void)importV1Store:(NSManagedObjectContext *)v1Context intoContext:(NSManagedObjectContext *)context withDisplay:(SapphireMetaDataUpgrading *)display;
84
85/*!
86 * @brief Import the old plist into the context
87 *
88 * @param configDir The directory containing old configuration files
89 * @param context The context to use for new objects
90 * @param display The display for UI feedback
91 */
92+ (void)importPlist:(NSString *)configDir intoContext:(NSManagedObjectContext *)context withDisplay:(SapphireMetaDataUpgrading *)display;
93
94/*!
95 * @brief Get the path for the collection art
96 *
97 * @return The base collection art path
98 */
99+ (NSString *)collectionArtPath;
100
101/*!
102 * @brief Get a dictionary describing all the changes in the context for sending to another location
103 *
104 * @param moc The context with changes
105 * @return The dictionary with the changes
106 */
107+ (NSDictionary *)changesDictionaryForContext:(NSManagedObjectContext *)moc;
108
109/*!
110 * @brief Apply a dictionary containing changes to the context
111 *
112 * @param changes The dictionary with the changes
113 * @param moc The to apply context with changes
114 */
115+ (void)applyChanges:(NSDictionary *)changes toContext:(NSManagedObjectContext *)moc;
116@end
Note: See TracBrowser for help on using the browser.