MLFile.h 5.15 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*****************************************************************************
 * MLFile.h
 * Lunettes
 *****************************************************************************
 * Copyright (C) 2010 Pierre d'Herbemont
 * Copyright (C) 2010-2013 VLC authors and VideoLAN
 * $Id$
 *
 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
10
 *          Felix Paul Kühne <fkuehne # videolan.org>
11
 *          Tobias Conradi <videolan # tobias-conradi.de>
12
 *
13 14 15
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
16 17 18 19
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
22
 *
23 24 25
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26
 *****************************************************************************/
Pierre's avatar
Pierre committed
27 28

#import <CoreData/CoreData.h>
29
#if TARGET_OS_IPHONE
Felix Paul Kühne's avatar
Felix Paul Kühne committed
30
#ifndef MLKIT_READONLY_TARGET
31
#import <CoreSpotlight/CoreSpotlight.h>
32
#endif
Felix Paul Kühne's avatar
Felix Paul Kühne committed
33
#endif
Pierre's avatar
Pierre committed
34

Pierre's avatar
Pierre committed
35
@class MLShowEpisode;
36
@class MLAlbumTrack;
Pierre's avatar
Pierre committed
37

Pierre's avatar
Pierre committed
38 39 40
extern NSString *kMLFileTypeMovie;
extern NSString *kMLFileTypeClip;
extern NSString *kMLFileTypeTVShowEpisode;
41
extern NSString *kMLFileTypeAudio;
Pierre's avatar
Pierre committed
42

43 44
extern NSString *const MLFileThumbnailWasUpdated;

Pierre's avatar
Pierre committed
45
@interface MLFile :  NSManagedObject
Pierre's avatar
Pierre committed
46

Pierre's avatar
Pierre committed
47
+ (NSArray *)allFiles;
48
+ (NSArray *)fileForURL:(NSURL *)url;
Pierre's avatar
Pierre committed
49

50 51
+ (instancetype)fileForURIRepresentation:(NSURL *)uriRepresentation;

Pierre's avatar
Pierre committed
52 53 54 55
- (BOOL)isKindOfType:(NSString *)type;
- (BOOL)isMovie;
- (BOOL)isClip;
- (BOOL)isShowEpisode;
56 57
- (BOOL)isAlbumTrack;
- (BOOL)isSupportedAudioFile;
Pierre's avatar
Pierre committed
58

59 60 61 62 63 64 65 66
@property (nonatomic, strong) NSNumber *seasonNumber;
@property (nonatomic, strong) NSNumber *remainingTime;
@property (nonatomic, strong) NSString *releaseYear;
@property (nonatomic, strong) NSNumber *lastPosition;
@property (nonatomic, strong) NSNumber *lastSubtitleTrack;
@property (nonatomic, strong) NSNumber *lastAudioTrack;
@property (nonatomic, strong) NSNumber *playCount;
@property (nonatomic, strong) NSString *artworkURL;
67 68 69
// on iOS the path relative to documents folder on OS X full path
// if you want to set path maybe set url instead which does the right thing depending on the OS
@property (nonatomic, strong) NSString *path;
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
@property (nonatomic, strong) NSString *type;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *shortSummary;
@property (nonatomic, strong) NSNumber *currentlyWatching;
@property (nonatomic, strong) NSNumber *episodeNumber;
@property (nonatomic, strong) NSNumber *unread;
@property (nonatomic, strong) NSNumber *hasFetchedInfo;
@property (nonatomic, strong) NSNumber *noOnlineMetaData;
@property (nonatomic, strong) MLShowEpisode *showEpisode;
@property (nonatomic, strong) NSSet *labels;
@property (nonatomic, strong) NSSet *tracks;
@property (nonatomic, strong) NSNumber *isOnDisk;
@property (nonatomic, strong) NSNumber *duration;
@property (nonatomic, strong) NSString *artist;
@property (nonatomic, strong) NSString *album;
@property (nonatomic, strong) NSNumber *albumTrackNumber;
@property (nonatomic, strong) NSNumber *folderTrackNumber;
@property (nonatomic, strong) NSString *genre;
@property (nonatomic, strong) MLAlbumTrack *albumTrack;
89
@property (nonatomic, strong) NSString *thumbnailName;
Pierre's avatar
Pierre committed
90

91
- (void)setComputedThumbnailScaledForDevice:(UIImage *)thumbnail;
92
@property (nonatomic, strong) UIImage *computedThumbnail;
93 94
@property (nonatomic, assign) BOOL isSafe;
@property (nonatomic, assign) BOOL isBeingParsed;
Pierre's avatar
Pierre committed
95
@property (nonatomic, assign) BOOL thumbnailTimeouted;
96

97 98 99 100 101
// always full URL, derived from path
// on Mac directly path as URL
// on iOS combined path appended MLMediaLibrary documentsFolder
@property (nonatomic, strong) NSURL *url;

102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
/**
 * the data in this object are about to be put on screen
 *
 * If multiple MLFile object are processed, this
 * increase the priority of the processing for this MLFile.
 */
- (void)willDisplay;

/**
 * We don't display the data of this object on screen.
 *
 * This put back the eventually increased priority for this MLFile,
 * to a default one.
 * \see willDisplay
 */
- (void)didHide;
118

119 120 121 122
/**
 * do not rely on this path unless you are a MLKit object */
- (NSString *)thumbnailPath;

123 124 125 126 127 128 129
/**
 * Shortcuts to the videoTracks.
 */
- (NSManagedObject *)videoTrack;

- (size_t)fileSizeInBytes;

130
#if TARGET_OS_IPHONE
Felix Paul Kühne's avatar
Felix Paul Kühne committed
131
#ifndef MLKIT_READONLY_TARGET
132 133
- (CSSearchableItemAttributeSet *)coreSpotlightAttributeSet;
- (void)updateCoreSpotlightEntry;
134
#endif
Felix Paul Kühne's avatar
Felix Paul Kühne committed
135
#endif
136

Pierre's avatar
Pierre committed
137 138 139
@end


Pierre's avatar
Pierre committed
140
@interface MLFile (CoreDataGeneratedAccessors)
Pierre's avatar
Pierre committed
141 142 143 144 145
- (void)addLabelsObject:(NSManagedObject *)value;
- (void)removeLabelsObject:(NSManagedObject *)value;
- (void)addLabels:(NSSet *)value;
- (void)removeLabels:(NSSet *)value;

146 147 148 149
- (void)addTracksObject:(NSManagedObject *)value;
- (void)removeTracksObject:(NSManagedObject *)value;
- (void)addTracks:(NSSet *)value;
- (void)removeTracks:(NSSet *)value;
Pierre's avatar
Pierre committed
150 151
@end