| 1 | /* |
|---|
| 2 | * SapphireSettings.m |
|---|
| 3 | * Sapphire |
|---|
| 4 | * |
|---|
| 5 | * Created by pnmerrill on Jun. 23, 2007. |
|---|
| 6 | * Copyright 2007 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 | |
|---|
| 22 | #import <BackRow/BackRow.h> |
|---|
| 23 | #import "SapphireApplianceController.h" |
|---|
| 24 | #import "SapphireSettings.h" |
|---|
| 25 | #import "SapphireTheme.h" |
|---|
| 26 | #import "SapphireMediaPreview.h" |
|---|
| 27 | #import "SapphireAllFileDataImporter.h" |
|---|
| 28 | #import "SapphireTVShowImporter.h" |
|---|
| 29 | #import "SapphireMovieImporter.h" |
|---|
| 30 | #import "SapphirePosterChooser.h" |
|---|
| 31 | #import "SapphireCollectionSettings.h" |
|---|
| 32 | #import "SapphireFileMetaData.h" |
|---|
| 33 | #import "SapphireCollectionDirectory.h" |
|---|
| 34 | #import "SapphireDirectoryMetaData.h" |
|---|
| 35 | #import "SapphireMetaDataSupport.h" |
|---|
| 36 | #import "SapphireTVShow.h" |
|---|
| 37 | #import "SapphireConfirmPrompt.h" |
|---|
| 38 | #import "CoreDataSupportFunctions.h" |
|---|
| 39 | #import "SapphireErrorDisplayController.h" |
|---|
| 40 | #import "SapphireWaitDisplay.h" |
|---|
| 41 | |
|---|
| 42 | #import <SapphireCompatClasses/SapphireFrontRowCompat.h> |
|---|
| 43 | #import "NSString-Extensions.h" |
|---|
| 44 | #import "NSFileManager-Extensions.h" |
|---|
| 45 | |
|---|
| 46 | static SapphireSettings *sharedInstance = nil; |
|---|
| 47 | |
|---|
| 48 | @implementation SapphireSettings |
|---|
| 49 | |
|---|
| 50 | NSString *HIDE_FAVORITE_KEY = @"HideFavorites"; |
|---|
| 51 | NSString *HIDE_TOP_SHOWS_KEY = @"HideTopShows"; |
|---|
| 52 | NSString *HIDE_UNWATCHED_KEY = @"HideUnwatched"; |
|---|
| 53 | NSString *HIDE_SPOILERS_KEY = @"HideSpoilers"; |
|---|
| 54 | NSString *HIDE_AUDIO_KEY = @"HideAudio"; |
|---|
| 55 | NSString *HIDE_VIDEO_KEY = @"HideVideo"; |
|---|
| 56 | NSString *HIDE_POSTER_CHOOSER_KEY = @"PosterChooserOptOut"; |
|---|
| 57 | NSString *HIDE_UI_QUIT_KEY = @"HideUIQuit"; |
|---|
| 58 | NSString *ENABLE_FAST_SWITCHING_KEY = @"EnableFastSwitching"; |
|---|
| 59 | NSString *USE_AC3_PASSTHROUGH = @"EnableAC3Passthrough"; |
|---|
| 60 | NSString *ENABLE_DIR_LOOKUP = @"EnableDirLookup"; |
|---|
| 61 | NSString *ENABLE_AUTO_SELECTION = @"EnableAutoSelection"; |
|---|
| 62 | NSString *DISABLE_ANON_KEY = @"DisableAnonymousReporting"; |
|---|
| 63 | NSString *LAST_PREDICATE = @"LastPredicate"; |
|---|
| 64 | |
|---|
| 65 | NSString *SETTING_NAME = @"Name"; |
|---|
| 66 | NSString *SETTING_DESCRIPTION = @"Description"; |
|---|
| 67 | NSString *SETTING_KEY = @"Key"; |
|---|
| 68 | NSString *SETTING_GEM = @"Gem"; |
|---|
| 69 | NSString *SETTING_COMMAND = @"Command"; |
|---|
| 70 | |
|---|
| 71 | typedef enum { |
|---|
| 72 | COMMAND_NONE, |
|---|
| 73 | COMMAND_IMPORT_FILE_DATA, |
|---|
| 74 | COMMAND_IMPORT_TV_DATA, |
|---|
| 75 | COMMAND_IMPORT_MOVIE_DATA, |
|---|
| 76 | COMMAND_IMPORT_TV_AUTOSORT_CALCULATE, |
|---|
| 77 | COMMAND_IMPORT_UPDATE_SCRAPERS, |
|---|
| 78 | COMMAND_IMPORT_HIDE_POSTER_CHOOSER, |
|---|
| 79 | COMMAND_IMPORT_USE_DIR_NAME, |
|---|
| 80 | COMMAND_IMPORT_HIDE_ALL_CHOOSERS, |
|---|
| 81 | |
|---|
| 82 | COMMAND_COLLECTIONS_HIDE, |
|---|
| 83 | COMMAND_COLLECTIONS_DONT_IMPORT, |
|---|
| 84 | COMMAND_COLLECTIONS_DELETE, |
|---|
| 85 | |
|---|
| 86 | COMMAND_FILTERS_SKIP_FAVORITE, |
|---|
| 87 | COMMAND_FILTERS_SKIP_UNWATCHED, |
|---|
| 88 | |
|---|
| 89 | COMMAND_METADATA_HIDE_SPOILERS, |
|---|
| 90 | COMMAND_METADATA_HIDE_AUDIO, |
|---|
| 91 | COMMAND_METADATA_HIDE_VIDEO, |
|---|
| 92 | |
|---|
| 93 | COMMAND_AUDIO_ENABLE_AC3, |
|---|
| 94 | |
|---|
| 95 | COMMAND_GENERAL_HIDE_UI_QUIT, |
|---|
| 96 | COMMAND_GENERAL_FAST_DIRECTORY_SWITCHING, |
|---|
| 97 | COMMAND_GENERAL_DONT_ANON_REPORT, |
|---|
| 98 | } SettingsCommand; |
|---|
| 99 | |
|---|
| 100 | + (SapphireSettings *)sharedSettings |
|---|
| 101 | { |
|---|
| 102 | return sharedInstance; |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | + (void)relinquishSettings |
|---|
| 106 | { |
|---|
| 107 | [sharedInstance release]; |
|---|
| 108 | sharedInstance = nil; |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | - (id) initWithScene: (BRRenderScene *) scene settingsPath:(NSString *)dictionaryPath context:(NSManagedObjectContext *)context; |
|---|
| 112 | { |
|---|
| 113 | if(sharedInstance != nil) |
|---|
| 114 | { |
|---|
| 115 | [self autorelease]; |
|---|
| 116 | return [sharedInstance retain]; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | self = [super initWithScene:scene]; |
|---|
| 120 | |
|---|
| 121 | lastCommand = COMMAND_NONE; |
|---|
| 122 | /*Setup display*/ |
|---|
| 123 | moc = [context retain]; |
|---|
| 124 | |
|---|
| 125 | SapphireTheme *theme = [SapphireTheme sharedTheme]; |
|---|
| 126 | settings = [[NSArray alloc] initWithObjects: |
|---|
| 127 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 128 | BRLocalizedString(@" Populate File Data", @"Populate File Data menu item"), SETTING_NAME, |
|---|
| 129 | BRLocalizedString(@"Tells Sapphire to examine all files, and remember the file size, length and other information that can be gathered from the file itself.", @"Populate File Data description"), SETTING_DESCRIPTION, |
|---|
| 130 | [theme gem:IMPORT_GEM_KEY], SETTING_GEM, |
|---|
| 131 | [NSNumber numberWithInt:COMMAND_IMPORT_FILE_DATA], SETTING_COMMAND, |
|---|
| 132 | nil], |
|---|
| 133 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 134 | BRLocalizedString(@" Fetch TV Show Data", @"Fetch TV Show Data menu item"), SETTING_NAME, |
|---|
| 135 | BRLocalizedString(@"Tells Sapphire that for every TV episode, gather more information about this episode from the internet.", @"Fetch TV Show Data description"), SETTING_DESCRIPTION, |
|---|
| 136 | [theme gem:TVR_GEM_KEY], SETTING_GEM, |
|---|
| 137 | [NSNumber numberWithInt:COMMAND_IMPORT_TV_DATA], SETTING_COMMAND, |
|---|
| 138 | nil], |
|---|
| 139 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 140 | BRLocalizedString(@" Fetch Movie Data", @"Fetch Movie Data menu item"), SETTING_NAME, |
|---|
| 141 | BRLocalizedString(@"Tells Sapphire that for every Movie, gather more information from the internet.", @"Fetch Movie Data description"), SETTING_DESCRIPTION, |
|---|
| 142 | [theme gem:IMDB_GEM_KEY], SETTING_GEM, |
|---|
| 143 | [NSNumber numberWithInt:COMMAND_IMPORT_MOVIE_DATA], SETTING_COMMAND, |
|---|
| 144 | nil], |
|---|
| 145 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 146 | BRLocalizedString(@" Calculate TV Directories", @"Calculate TV Dirs menu item"), SETTING_NAME, |
|---|
| 147 | BRLocalizedString(@"Tells Sapphire to calculate directories where each TV show is stored.", @"Calculate TV Dirs description"), SETTING_DESCRIPTION, |
|---|
| 148 | [theme gem:TVR_GEM_KEY], SETTING_GEM, |
|---|
| 149 | [NSNumber numberWithInt:COMMAND_IMPORT_TV_AUTOSORT_CALCULATE], SETTING_COMMAND, |
|---|
| 150 | nil], |
|---|
| 151 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 152 | BRLocalizedString(@" Update Scrapers", @"Update Scrapers menu item"), SETTING_NAME, |
|---|
| 153 | BRLocalizedString(@"Tells Sapphire to download latest scrapers from the website.", @"Update Scrapers description"), SETTING_DESCRIPTION, |
|---|
| 154 | [theme gem:CONE_GEM_KEY], SETTING_GEM, |
|---|
| 155 | [NSNumber numberWithInt:COMMAND_IMPORT_UPDATE_SCRAPERS], SETTING_COMMAND, |
|---|
| 156 | nil], |
|---|
| 157 | /* [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 158 | BRLocalizedString(@" Choose Movie Posters", @"Start Poster Chooser menu item"), SETTING_NAME, |
|---|
| 159 | BRLocalizedString(@"Choose Movie Posters", @"Start Poster Chooser description"), SETTING_DESCRIPTION, |
|---|
| 160 | [theme gem:GREEN_GEM_KEY], SETTING_GEM, |
|---|
| 161 | [NSNumber numberWithInt:COMMAND_IMPORT_MOVIE_POSTERS], SETTING_COMMAND, |
|---|
| 162 | nil],*/ |
|---|
| 163 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 164 | BRLocalizedString(@" Hide Collections", @"Hide Collections menu item"), SETTING_NAME, |
|---|
| 165 | BRLocalizedString(@"Allows the user to specify which collections should be hidden from Sapphire's main menu.", @"Hide Collections description"), SETTING_DESCRIPTION, |
|---|
| 166 | [theme gem:FILE_GEM_KEY], SETTING_GEM, |
|---|
| 167 | [NSNumber numberWithInt:COMMAND_COLLECTIONS_HIDE], SETTING_COMMAND, |
|---|
| 168 | nil], |
|---|
| 169 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 170 | BRLocalizedString(@" Don't Import Collections", @"Don't Import Collections menu item"), SETTING_NAME, |
|---|
| 171 | BRLocalizedString(@"Allows the user to specify which collections should be skipped when importing meta data.", @"Don't Import Collections description"), SETTING_DESCRIPTION, |
|---|
| 172 | [theme gem:FILE_GEM_KEY], SETTING_GEM, |
|---|
| 173 | [NSNumber numberWithInt:COMMAND_COLLECTIONS_DONT_IMPORT], SETTING_COMMAND, |
|---|
| 174 | nil], |
|---|
| 175 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 176 | BRLocalizedString(@" Delete Collections", @"Delete Collections menu item"), SETTING_NAME, |
|---|
| 177 | BRLocalizedString(@"Allows the user to specify which collections should be delete along with its data. Use this for collections which will never be used again.", @"Delete Collections description"), SETTING_DESCRIPTION, |
|---|
| 178 | [theme gem:FILE_GEM_KEY], SETTING_GEM, |
|---|
| 179 | [NSNumber numberWithInt:COMMAND_COLLECTIONS_DELETE], SETTING_COMMAND, |
|---|
| 180 | nil], |
|---|
| 181 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 182 | BRLocalizedString(@" Skip \"Favorite Shows\" filter", @"Skip Favorite shows menu item"), SETTING_NAME, |
|---|
| 183 | BRLocalizedString(@"Tells Sapphire that when changing filter settings, skip over the favorite shows filter.", @"Skip Favorite shows description"), SETTING_DESCRIPTION, |
|---|
| 184 | HIDE_FAVORITE_KEY, SETTING_KEY, |
|---|
| 185 | [theme gem:YELLOW_GEM_KEY], SETTING_GEM, |
|---|
| 186 | [NSNumber numberWithInt:COMMAND_FILTERS_SKIP_FAVORITE], SETTING_COMMAND, |
|---|
| 187 | nil], |
|---|
| 188 | /* [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 189 | BRLocalizedString(@" Skip \"Top Shows\" filter", @"Skip Top shows menu item"), SETTING_NAME, |
|---|
| 190 | BRLocalizedString(@"Skip \"Top Shows\" filter", @"Skip Top shows description"), SETTING_DESCRIPTION, |
|---|
| 191 | HIDE_TOP_SHOWS_KEY, SETTING_KEY, |
|---|
| 192 | [theme gem:GREEN_GEM_KEY], SETTING_GEM, |
|---|
| 193 | [NSNumber numberWithInt:COMMAND_FILTERS_SKIP_TOP_SHOWS], SETTING_COMMAND, |
|---|
| 194 | nil],*/ |
|---|
| 195 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 196 | BRLocalizedString(@" Skip \"Unwatched Shows\" filter", @"Skip Unwatched shows menu item"), SETTING_NAME, |
|---|
| 197 | BRLocalizedString(@"Tells Sapphire that when changing filter settings, skip over the unwatched shows filter.", @"Skip Unwatched shows description"), SETTING_DESCRIPTION, |
|---|
| 198 | HIDE_UNWATCHED_KEY, SETTING_KEY, |
|---|
| 199 | [theme gem:BLUE_GEM_KEY], SETTING_GEM, |
|---|
| 200 | [NSNumber numberWithInt:COMMAND_FILTERS_SKIP_UNWATCHED], SETTING_COMMAND, |
|---|
| 201 | nil], |
|---|
| 202 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 203 | BRLocalizedString(@" Hide Show Spoilers", @"Hide show summary menu item"), SETTING_NAME, |
|---|
| 204 | BRLocalizedString(@"Tells Sapphire to disable the display of the show's synopsis.", @"Hide show summary description"), SETTING_DESCRIPTION, |
|---|
| 205 | HIDE_SPOILERS_KEY, SETTING_KEY, |
|---|
| 206 | [theme gem:NOTE_GEM_KEY], SETTING_GEM, |
|---|
| 207 | [NSNumber numberWithInt:COMMAND_METADATA_HIDE_SPOILERS], SETTING_COMMAND, |
|---|
| 208 | nil], |
|---|
| 209 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 210 | BRLocalizedString(@" Hide Audio Info", @"Hide perian audio info menu item"), SETTING_NAME, |
|---|
| 211 | BRLocalizedString(@"Tells Sapphire to disable the display of audio codec and sample rate information.", @"Hide perian audio info description"), SETTING_DESCRIPTION, |
|---|
| 212 | HIDE_AUDIO_KEY, SETTING_KEY, |
|---|
| 213 | [theme gem:AUDIO_GEM_KEY], SETTING_GEM, |
|---|
| 214 | [NSNumber numberWithInt:COMMAND_METADATA_HIDE_AUDIO], SETTING_COMMAND, |
|---|
| 215 | nil], |
|---|
| 216 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 217 | BRLocalizedString(@" Hide Video Info", @"Hide perian video info menu item"), SETTING_NAME, |
|---|
| 218 | BRLocalizedString(@"Tells Sapphire to disable the display of video codec, resolution, and color depth information.", @"Hide perian video info description"), SETTING_DESCRIPTION, |
|---|
| 219 | HIDE_VIDEO_KEY, SETTING_KEY, |
|---|
| 220 | [theme gem:VIDEO_GEM_KEY], SETTING_GEM, |
|---|
| 221 | [NSNumber numberWithInt:COMMAND_METADATA_HIDE_VIDEO], SETTING_COMMAND, |
|---|
| 222 | nil], |
|---|
| 223 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 224 | BRLocalizedString(@" Hide Poster Chooser", @"Hide poster chooser menu item"), SETTING_NAME, |
|---|
| 225 | BRLocalizedString(@"Tells Sapphire to automatically choose posters for movies instead of asking the user to choose one.", @"Hide poster chooser description"), SETTING_DESCRIPTION, |
|---|
| 226 | HIDE_POSTER_CHOOSER_KEY, SETTING_KEY, |
|---|
| 227 | [theme gem:IMPORT_GEM_KEY], SETTING_GEM, |
|---|
| 228 | [NSNumber numberWithInt:COMMAND_IMPORT_HIDE_POSTER_CHOOSER], SETTING_COMMAND, |
|---|
| 229 | nil], |
|---|
| 230 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 231 | BRLocalizedString(@" Hide UI Quit", @"Hide the ui quitter menu item"), SETTING_NAME, |
|---|
| 232 | BRLocalizedString(@"Tells Sapphire to hide the main menu element forcing FrontRow to quit.", @"Hide the ui quitter description"), SETTING_DESCRIPTION, |
|---|
| 233 | HIDE_UI_QUIT_KEY, SETTING_KEY, |
|---|
| 234 | [theme gem:FRONTROW_GEM_KEY], SETTING_GEM, |
|---|
| 235 | [NSNumber numberWithInt:COMMAND_GENERAL_HIDE_UI_QUIT], SETTING_COMMAND, |
|---|
| 236 | nil], |
|---|
| 237 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 238 | BRLocalizedString(@" Fast Directory Switching", @"Don't rescan directories upon entry and used cached data"), SETTING_NAME, |
|---|
| 239 | BRLocalizedString(@"Tells Sapphire that when using a filter, use the cached data to setup directories rather than scanning the directories themselves for new files.", @"Fast Directory Switching description"), SETTING_DESCRIPTION, |
|---|
| 240 | ENABLE_FAST_SWITCHING_KEY, SETTING_KEY, |
|---|
| 241 | [theme gem:FAST_GEM_KEY], SETTING_GEM, |
|---|
| 242 | [NSNumber numberWithInt:COMMAND_GENERAL_FAST_DIRECTORY_SWITCHING], SETTING_COMMAND, |
|---|
| 243 | nil], |
|---|
| 244 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 245 | BRLocalizedString(@" Enable AC3 Passthrough", @"Enable AC3 Passthrough menu item"), SETTING_NAME, |
|---|
| 246 | BRLocalizedString(@"Tells Sapphire that you have an AC3 decoder and to enable passthrough of the full audio information to the decoder. This is how you get 5.1 and DTS output.", @"Enable AC3 Passthrough description"), SETTING_DESCRIPTION, |
|---|
| 247 | USE_AC3_PASSTHROUGH, SETTING_KEY, |
|---|
| 248 | [theme gem:AC3_GEM_KEY], SETTING_GEM, |
|---|
| 249 | [NSNumber numberWithInt:COMMAND_AUDIO_ENABLE_AC3], SETTING_COMMAND, |
|---|
| 250 | nil], |
|---|
| 251 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 252 | BRLocalizedString(@" Use Directory Lookup", @"Use directory names instead of filenames for movie lookup"), SETTING_NAME, |
|---|
| 253 | BRLocalizedString(@"Tells Sapphire that you want to use directory names instead of file names for identifying movies.", @"Enable Directory lookup description"), SETTING_DESCRIPTION, |
|---|
| 254 | ENABLE_DIR_LOOKUP, SETTING_KEY, |
|---|
| 255 | [theme gem:IMDB_GEM_KEY], SETTING_GEM, |
|---|
| 256 | [NSNumber numberWithInt:COMMAND_IMPORT_USE_DIR_NAME], SETTING_COMMAND, |
|---|
| 257 | nil], |
|---|
| 258 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 259 | BRLocalizedString(@" Auto-Select Movies/Shows", @"Hide movie/show chooser menu item"), SETTING_NAME, |
|---|
| 260 | BRLocalizedString(@"Tells Sapphire skip the TV Show and Movie choosers when importing and make selections automatically.", @"Enable movie/show chooser description"), SETTING_DESCRIPTION, |
|---|
| 261 | ENABLE_AUTO_SELECTION, SETTING_KEY, |
|---|
| 262 | [theme gem:IMPORT_GEM_KEY], SETTING_GEM, |
|---|
| 263 | [NSNumber numberWithInt:COMMAND_IMPORT_HIDE_ALL_CHOOSERS], SETTING_COMMAND, |
|---|
| 264 | nil], |
|---|
| 265 | [NSDictionary dictionaryWithObjectsAndKeys: |
|---|
| 266 | BRLocalizedString(@" Disable Anonymous Reporting", @"Disable the anonymous reporting for aid in future features"), SETTING_NAME, |
|---|
| 267 | BRLocalizedString(@"Tells Sapphire to not report any anonymous information on how you use Sapphire. Anonymous reporting enables us to improve the plugin for future use.", @"Disable the anonymous reporting description"), SETTING_DESCRIPTION, |
|---|
| 268 | DISABLE_ANON_KEY, SETTING_KEY, |
|---|
| 269 | [theme gem:REPORT_GEM_KEY], SETTING_GEM, |
|---|
| 270 | [NSNumber numberWithInt:COMMAND_GENERAL_DONT_ANON_REPORT], SETTING_COMMAND, |
|---|
| 271 | nil], |
|---|
| 272 | nil]; |
|---|
| 273 | |
|---|
| 274 | path = [dictionaryPath retain]; |
|---|
| 275 | options = [[NSDictionary dictionaryWithContentsOfFile:dictionaryPath] mutableCopy]; |
|---|
| 276 | /*Set deaults*/ |
|---|
| 277 | defaults = [[NSDictionary alloc] initWithObjectsAndKeys: |
|---|
| 278 | [NSNumber numberWithBool:NO], HIDE_FAVORITE_KEY, |
|---|
| 279 | [NSNumber numberWithBool:YES], HIDE_TOP_SHOWS_KEY, |
|---|
| 280 | [NSNumber numberWithBool:NO], HIDE_UNWATCHED_KEY, |
|---|
| 281 | [NSNumber numberWithBool:NO], HIDE_SPOILERS_KEY, |
|---|
| 282 | [NSNumber numberWithBool:NO], HIDE_AUDIO_KEY, |
|---|
| 283 | [NSNumber numberWithBool:NO], HIDE_VIDEO_KEY, |
|---|
| 284 | [NSNumber numberWithBool:NO], HIDE_POSTER_CHOOSER_KEY, |
|---|
| 285 | [NSNumber numberWithBool:YES], HIDE_UI_QUIT_KEY, |
|---|
| 286 | [NSNumber numberWithBool:YES], ENABLE_FAST_SWITCHING_KEY, |
|---|
| 287 | [NSNumber numberWithBool:NO], USE_AC3_PASSTHROUGH, |
|---|
| 288 | [NSNumber numberWithBool:NO], ENABLE_DIR_LOOKUP, |
|---|
| 289 | [NSNumber numberWithBool:NO], ENABLE_AUTO_SELECTION, |
|---|
| 290 | [NSNumber numberWithBool:NO], DISABLE_ANON_KEY, |
|---|
| 291 | [NSNumber numberWithInt:NSNotFound], LAST_PREDICATE, |
|---|
| 292 | nil]; |
|---|
| 293 | if(options == nil) |
|---|
| 294 | options = [[NSMutableDictionary alloc] init]; |
|---|
| 295 | |
|---|
| 296 | /*display*/ |
|---|
| 297 | BRListControl *list = [self list]; |
|---|
| 298 | [list setDatasource:self]; |
|---|
| 299 | [SapphireFrontRowCompat addDividerAtIndex:6 toList:list]; |
|---|
| 300 | /*Save our instance*/ |
|---|
| 301 | sharedInstance = [self retain]; |
|---|
| 302 | |
|---|
| 303 | return self; |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | /*! |
|---|
| 307 | * @brief Writes settings to disk |
|---|
| 308 | */ |
|---|
| 309 | - (void)writeSettings |
|---|
| 310 | { |
|---|
| 311 | [options writeToFile:path atomically:YES]; |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | - (void)dealloc |
|---|
| 315 | { |
|---|
| 316 | [settings release]; |
|---|
| 317 | [options release]; |
|---|
| 318 | [path release]; |
|---|
| 319 | [defaults release]; |
|---|
| 320 | [moc release]; |
|---|
| 321 | [displayOnlyPlot release]; |
|---|
| 322 | [super dealloc]; |
|---|
| 323 | } |
|---|
| 324 | |
|---|
| 325 | /*! |
|---|
| 326 | * @brief Get a setting |
|---|
| 327 | * |
|---|
| 328 | * @param key The setting to retrieve |
|---|
| 329 | * @return The setting in an NSNumber |
|---|
| 330 | */ |
|---|
| 331 | - (NSNumber *)numberForKey:(NSString *)key |
|---|
| 332 | { |
|---|
| 333 | /*Check the user's setting*/ |
|---|
| 334 | NSNumber *num = [options objectForKey:key]; |
|---|
| 335 | if(!num) |
|---|
| 336 | /*User hasn't set yet, use default then*/ |
|---|
| 337 | num = [defaults objectForKey:key]; |
|---|
| 338 | return num; |
|---|
| 339 | } |
|---|
| 340 | |
|---|
| 341 | /*! |
|---|
| 342 | * @brief Get a setting |
|---|
| 343 | * |
|---|
| 344 | * @param key The setting to retrieve |
|---|
| 345 | * @return YES if set, NO otherwise |
|---|
| 346 | */ |
|---|
| 347 | - (BOOL)boolForKey:(NSString *)key |
|---|
| 348 | { |
|---|
| 349 | /*Check the user's setting*/ |
|---|
| 350 | NSNumber *num = [options objectForKey:key]; |
|---|
| 351 | if(!num) |
|---|
| 352 | /*User hasn't set yet, use default then*/ |
|---|
| 353 | num = [defaults objectForKey:key]; |
|---|
| 354 | return [num boolValue]; |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | - (BOOL)displayUnwatched |
|---|
| 358 | { |
|---|
| 359 | return ![self boolForKey:HIDE_UNWATCHED_KEY]; |
|---|
| 360 | } |
|---|
| 361 | |
|---|
| 362 | - (BOOL)displayFavorites |
|---|
| 363 | { |
|---|
| 364 | return ![self boolForKey:HIDE_FAVORITE_KEY]; |
|---|
| 365 | } |
|---|
| 366 | |
|---|
| 367 | - (BOOL)displayTopShows |
|---|
| 368 | { |
|---|
| 369 | return ![self boolForKey:HIDE_TOP_SHOWS_KEY]; |
|---|
| 370 | } |
|---|
| 371 | |
|---|
| 372 | - (BOOL)displaySpoilers |
|---|
| 373 | { |
|---|
| 374 | return ![self boolForKey:HIDE_SPOILERS_KEY]; |
|---|
| 375 | } |
|---|
| 376 | |
|---|
| 377 | - (BOOL)displayAudio |
|---|
| 378 | { |
|---|
| 379 | return ![self boolForKey:HIDE_AUDIO_KEY]; |
|---|
| 380 | } |
|---|
| 381 | |
|---|
| 382 | - (BOOL)displayVideo |
|---|
| 383 | { |
|---|
| 384 | return ![self boolForKey:HIDE_VIDEO_KEY]; |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | - (BOOL)displayPosterChooser |
|---|
| 388 | { |
|---|
| 389 | return ![self boolForKey:HIDE_POSTER_CHOOSER_KEY]; |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | - (BOOL)disableUIQuit |
|---|
| 393 | { |
|---|
| 394 | return [self boolForKey:HIDE_UI_QUIT_KEY]; |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | - (BOOL)disableAnonymousReporting; |
|---|
| 398 | { |
|---|
| 399 | return [self boolForKey:DISABLE_ANON_KEY]; |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | - (BOOL)useAC3Passthrough |
|---|
| 403 | { |
|---|
| 404 | return [self boolForKey:USE_AC3_PASSTHROUGH]; |
|---|
| 405 | } |
|---|
| 406 | |
|---|
| 407 | - (BOOL)fastSwitching |
|---|
| 408 | { |
|---|
| 409 | return [self boolForKey:ENABLE_FAST_SWITCHING_KEY]; |
|---|
| 410 | |
|---|
| 411 | } |
|---|
| 412 | |
|---|
| 413 | - (BOOL)dirLookup |
|---|
| 414 | { |
|---|
| 415 | return [self boolForKey:ENABLE_DIR_LOOKUP]; |
|---|
| 416 | } |
|---|
| 417 | |
|---|
| 418 | - (BOOL)autoSelection |
|---|
| 419 | { |
|---|
| 420 | return [self boolForKey:ENABLE_AUTO_SELECTION]; |
|---|
| 421 | } |
|---|
| 422 | |
|---|
| 423 | - (int)indexOfLastPredicate |
|---|
| 424 | { |
|---|
| 425 | return [[self numberForKey:LAST_PREDICATE] intValue]; |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | - (void)setIndexOfLastPredicate:(int)index |
|---|
| 429 | { |
|---|
| 430 | [options setObject:[NSNumber numberWithInt:index] forKey:LAST_PREDICATE]; |
|---|
| 431 | /*Save our settings*/ |
|---|
| 432 | [self writeSettings]; |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | - (void)setDisplayOnlyPlotUntil:(NSDate *)plotOnlyTime |
|---|
| 436 | { |
|---|
| 437 | [displayOnlyPlot release]; |
|---|
| 438 | displayOnlyPlot = [plotOnlyTime retain]; |
|---|
| 439 | } |
|---|
| 440 | |
|---|
| 441 | - (BOOL)displayOnlyPlot |
|---|
| 442 | { |
|---|
| 443 | return [displayOnlyPlot compare:[NSDate date]] == NSOrderedDescending; |
|---|
| 444 | } |
|---|
| 445 | |
|---|
| 446 | - (SapphireConfirmPrompt *)nextAutoSortPathConfirm:(NSArray *)shows |
|---|
| 447 | { |
|---|
| 448 | int i, count = [shows count]; |
|---|
| 449 | SapphireTVShow *show; |
|---|
| 450 | NSString *calcAutoPath = nil; |
|---|
| 451 | NSString *autoPath; |
|---|
| 452 | for(i=0; i<count; i++) |
|---|
| 453 | { |
|---|
| 454 | show = [shows objectAtIndex:i]; |
|---|
| 455 | calcAutoPath = [show calculateAutoSortPath]; |
|---|
| 456 | autoPath = [show autoSortPath]; |
|---|
| 457 | if(autoPath == nil && calcAutoPath == nil) |
|---|
| 458 | continue; |
|---|
| 459 | if(autoPath == nil || calcAutoPath == nil) |
|---|
| 460 | //Only one of them is nil |
|---|
| 461 | break; |
|---|
| 462 | if(![autoPath isEqualToString:calcAutoPath]) |
|---|
| 463 | break; |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | if(i == count) |
|---|
| 467 | return nil; |
|---|
| 468 | |
|---|
| 469 | NSArray *newArray = [shows subarrayWithRange:NSMakeRange(i+1, count-i-1)]; |
|---|
| 470 | NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:@selector(promptResult:forShow:remaining:)]]; |
|---|
| 471 | [invoke setTarget:self]; |
|---|
| 472 | [invoke setSelector:@selector(promptResult:forShow:remaining:)]; |
|---|
| 473 | [invoke setArgument:&show atIndex:3]; |
|---|
| 474 | [invoke setArgument:&newArray atIndex:4]; |
|---|
| 475 | [invoke retainArguments]; |
|---|
| 476 | |
|---|
| 477 | NSString *question; |
|---|
| 478 | if(calcAutoPath != nil) |
|---|
| 479 | question = [NSString stringWithFormat:BRLocalizedString(@"Do you want to set the show path for %@ to %@?", @"Prompt for setting a show's path, arguments are show name and path"), [show name], calcAutoPath]; |
|---|
| 480 | else |
|---|
| 481 | question = [NSString stringWithFormat:BRLocalizedString(@"Do you want to delete the show path for %@?", @"Prompt for deleting a show's path, argument is show name"), [show name]]; |
|---|
| 482 | |
|---|
| 483 | SapphireConfirmPrompt *prompt = [[SapphireConfirmPrompt alloc] initWithScene:[self scene] title:BRLocalizedString(@"Show Path", @"Show Path") subtitle:question invocation:invoke]; |
|---|
| 484 | return [prompt autorelease]; |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | - (BRLayerController *)promptResult:(SapphireConfirmPromptResult)result forShow:(SapphireTVShow *)show remaining:(NSArray *)remain |
|---|
| 488 | { |
|---|
| 489 | if(result == SapphireConfirmPromptResultAbort) |
|---|
| 490 | return nil; |
|---|
| 491 | |
|---|
| 492 | if(result == SapphireConfirmPromptResultOK) |
|---|
| 493 | { |
|---|
| 494 | [show setAutoSortPath:[show calculateAutoSortPath]]; |
|---|
| 495 | [SapphireMetaDataSupport save:moc]; |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | return [self nextAutoSortPathConfirm:remain]; |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | - (BRLayerController *)waitForDownloads |
|---|
| 502 | { |
|---|
| 503 | SapphireURLLoader *loader = [SapphireApplianceController urlLoader]; |
|---|
| 504 | while([loader loadingURLCount] != 0) |
|---|
| 505 | usleep(100000); |
|---|
| 506 | |
|---|
| 507 | SapphireErrorDisplayController *error = [[SapphireErrorDisplayController alloc] initWithScene:[self scene] error:BRLocalizedString(@"Restart Needed", @"Restart Needed") longError:BRLocalizedString(@"You must exist Frontrow for new scrapers to take effect", @"You must exist Frontrow for new scrapers to take effect")]; |
|---|
| 508 | return [error autorelease]; |
|---|
| 509 | } |
|---|
| 510 | |
|---|
| 511 | - (void)wasExhumed |
|---|
| 512 | { |
|---|
| 513 | // handle being revealed when the user presses Menu |
|---|
| 514 | |
|---|
| 515 | if(lastCommand == COMMAND_COLLECTIONS_DELETE) |
|---|
| 516 | { |
|---|
| 517 | NSArray *collections = [SapphireCollectionDirectory allCollectionsInContext:moc]; |
|---|
| 518 | NSEnumerator *colEnum = [collections objectEnumerator]; |
|---|
| 519 | SapphireCollectionDirectory *collection; |
|---|
| 520 | BOOL change = NO; |
|---|
| 521 | while((collection = [colEnum nextObject]) != nil) |
|---|
| 522 | { |
|---|
| 523 | if([collection deleteValue]) |
|---|
| 524 | { |
|---|
| 525 | change = YES; |
|---|
| 526 | SapphireDirectoryMetaData *dir = [collection directory]; |
|---|
| 527 | [moc deleteObject:dir]; |
|---|
| 528 | } |
|---|
| 529 | } |
|---|
| 530 | if(change) |
|---|
| 531 | [SapphireMetaDataSupport save:moc]; |
|---|
| 532 | } |
|---|
| 533 | |
|---|
| 534 | // always call super |
|---|
| 535 | [super wasExhumed]; |
|---|
| 536 | } |
|---|
| 537 | |
|---|
| 538 | - (long) itemCount |
|---|
| 539 | { |
|---|
| 540 | // return the number of items in your menu list here |
|---|
| 541 | return [settings count]; |
|---|
| 542 | } |
|---|
| 543 | |
|---|
| 544 | - (id<BRMenuItemLayer>) itemForRow: (long) row |
|---|
| 545 | { |
|---|
| 546 | /* |
|---|
| 547 | // build a BRTextMenuItemLayer or a BRAdornedMenuItemLayer, etc. here |
|---|
| 548 | // return that object, it will be used to display the list item. |
|---|
| 549 | return ( nil ); |
|---|
| 550 | */ |
|---|
| 551 | if( row >= [settings count] ) return ( nil ) ; |
|---|
| 552 | |
|---|
| 553 | BRAdornedMenuItemLayer * result = nil; |
|---|
| 554 | NSDictionary *setting = [settings objectAtIndex:row]; |
|---|
| 555 | NSString *name = [setting objectForKey:SETTING_NAME]; |
|---|
| 556 | result = [SapphireFrontRowCompat textMenuItemForScene:[self scene] folder:NO]; |
|---|
| 557 | |
|---|
| 558 | NSString *key = [setting objectForKey:SETTING_KEY]; |
|---|
| 559 | if(key != nil && [self boolForKey:key]) |
|---|
| 560 | { |
|---|
| 561 | [SapphireFrontRowCompat setLeftIcon:[SapphireFrontRowCompat selectedSettingImageForScene:[self scene]] forMenu:result]; |
|---|
| 562 | } |
|---|
| 563 | [SapphireFrontRowCompat setRightIcon:[setting objectForKey:SETTING_GEM] forMenu:result]; |
|---|
| 564 | |
|---|
| 565 | // add text |
|---|
| 566 | [SapphireFrontRowCompat setTitle:name forMenu:result]; |
|---|
| 567 | |
|---|
| 568 | return result; |
|---|
| 569 | } |
|---|
| 570 | |
|---|
| 571 | - (NSString *) titleForRow: (long) row |
|---|
| 572 | { |
|---|
| 573 | |
|---|
| 574 | if (row >= [settings count]) |
|---|
| 575 | return nil; |
|---|
| 576 | |
|---|
| 577 | NSString *result = [[settings objectAtIndex:row] objectForKey:SETTING_NAME]; |
|---|
| 578 | return result; |
|---|
| 579 | /* |
|---|
| 580 | // return the title for the list item at the given index here |
|---|
| 581 | return ( @"Sapphire" ); |
|---|
| 582 | */ |
|---|
| 583 | } |
|---|
| 584 | |
|---|
| 585 | - (long) rowForTitle: (NSString *) title |
|---|
| 586 | { |
|---|
| 587 | long result = -1; |
|---|
| 588 | long i, count = [self itemCount]; |
|---|
| 589 | for ( i = 0; i < count; i++ ) |
|---|
| 590 | { |
|---|
| 591 | if ( [title isEqualToString: [self titleForRow: i]] ) |
|---|
| 592 | { |
|---|
| 593 | result = i; |
|---|
| 594 | break; |
|---|
| 595 | } |
|---|
| 596 | } |
|---|
| 597 | |
|---|
| 598 | return ( result ); |
|---|
| 599 | } |
|---|
| 600 | |
|---|
| 601 | - (void) itemSelected: (long) row |
|---|
| 602 | { |
|---|
| 603 | // This is called when the user changed a setting |
|---|
| 604 | NSDictionary *setting = [settings objectAtIndex:row]; |
|---|
| 605 | |
|---|
| 606 | lastCommand = [[setting objectForKey:SETTING_COMMAND] intValue]; |
|---|
| 607 | switch (lastCommand) { |
|---|
| 608 | case COMMAND_IMPORT_FILE_DATA: |
|---|
| 609 | { |
|---|
| 610 | SapphireAllFileDataImporter *importer = [[SapphireAllFileDataImporter alloc] init]; |
|---|
| 611 | SapphireImporterDataMenu *menu = [[SapphireImporterDataMenu alloc] initWithScene:[self scene] context:moc importer:importer]; |
|---|
| 612 | [[self stack] pushController:menu]; |
|---|
| 613 | [menu release]; |
|---|
| 614 | [importer release]; |
|---|
| 615 | break; |
|---|
| 616 | } |
|---|
| 617 | case COMMAND_IMPORT_TV_DATA: |
|---|
| 618 | { |
|---|
| 619 | SapphireTVShowImporter *importer = [[SapphireTVShowImporter alloc] init]; |
|---|
| 620 | SapphireImporterDataMenu *menu = [[SapphireImporterDataMenu alloc] initWithScene:[self scene] context:moc importer:importer]; |
|---|
| 621 | [[self stack] pushController:menu]; |
|---|
| 622 | [menu release]; |
|---|
| 623 | [importer release]; |
|---|
| 624 | break; |
|---|
| 625 | } |
|---|
| 626 | case COMMAND_IMPORT_MOVIE_DATA: |
|---|
| 627 | { |
|---|
| 628 | SapphireMovieImporter *importer = [[SapphireMovieImporter alloc] init]; |
|---|
| 629 | SapphireImporterDataMenu *menu = [[SapphireImporterDataMenu alloc] initWithScene:[self scene] context:moc importer:importer]; |
|---|
| 630 | [[self stack] pushController:menu]; |
|---|
| 631 | [menu release]; |
|---|
| 632 | [importer release]; |
|---|
| 633 | break; |
|---|
| 634 | } |
|---|
| 635 | case COMMAND_IMPORT_TV_AUTOSORT_CALCULATE: |
|---|
| 636 | { |
|---|
| 637 | NSArray *shows = doFetchRequest(SapphireTVShowName, moc, nil); |
|---|
| 638 | SapphireConfirmPrompt *confirm = [self nextAutoSortPathConfirm:shows]; |
|---|
| 639 | if(confirm != nil) |
|---|
| 640 | [[self stack] pushController:confirm]; |
|---|
| 641 | else |
|---|
| 642 | { |
|---|
| 643 | SapphireErrorDisplayController *error = [[SapphireErrorDisplayController alloc] initWithScene:[self scene] error:BRLocalizedString(@"No Changes", @"No Changes") longError:BRLocalizedString(@"Sapphire didn't detect any changes to show paths", @"Display info for no show path changes detected")]; |
|---|
| 644 | [[self stack] pushController:error]; |
|---|
| 645 | [error release]; |
|---|
| 646 | } |
|---|
| 647 | break; |
|---|
| 648 | } |
|---|
| 649 | case COMMAND_IMPORT_UPDATE_SCRAPERS: |
|---|
| 650 | { |
|---|
| 651 | SapphireURLLoader *loader = [SapphireApplianceController urlLoader]; |
|---|
| 652 | NSFileManager *fm = [NSFileManager defaultManager]; |
|---|
| 653 | [fm constructPath:[applicationSupportDir() stringByAppendingPathComponent:@"scrapers/common"]]; |
|---|
| 654 | NSArray *loads = [NSArray arrayWithObjects:@"tvrage.xml", @"imdb.xml", @"/common/dtrailer.xml", @"common/imdb.xml", @"common/impa.xml", @"common/movieposterdb.xml", @"common/tmdb.xml", nil]; |
|---|
| 655 | NSString *dest = [applicationSupportDir() stringByAppendingPathComponent:@"scrapers"]; |
|---|
| 656 | NSEnumerator *loadEnum = [loads objectEnumerator]; |
|---|
| 657 | NSString *load; |
|---|
| 658 | while((load = [loadEnum nextObject]) != nil) |
|---|
| 659 | [loader saveDataAtURL:[@"http://appletv.nanopi.net/svn/trunk/SapphireFrappliance/MetaDataImporting/Scrapers/" stringByAppendingString:load] toFile:[dest stringByAppendingPathComponent:load]]; |
|---|
| 660 | NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:@selector(waitForDownloads)]]; |
|---|
| 661 | [invoke setTarget:self]; |
|---|
| 662 | [invoke setSelector:@selector(waitForDownloads)]; |
|---|
| 663 | SapphireWaitDisplay *wait = [[SapphireWaitDisplay alloc] initWithScene:[self scene] title:BRLocalizedString(@"Downloading", @"Downloading") invocation:invoke]; |
|---|
| 664 | [[self stack] pushController:wait]; |
|---|
| 665 | [wait release]; |
|---|
| 666 | break; |
|---|
| 667 | } |
|---|
| 668 | /* case COMMAND_IMPORT_MOVIE_POSTERS: |
|---|
| 669 | { |
|---|
| 670 | SapphirePosterBrowse *chooser = [[SapphirePosterChooser alloc] initWithScene:[self scene] metaDataPath:[[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"movieData.plist"]]; |
|---|
| 671 | [[self stack] pushController:chooser]; |
|---|
| 672 | [chooser release]; |
|---|
| 673 | break; |
|---|
| 674 | }*/ |
|---|
| 675 | case COMMAND_COLLECTIONS_HIDE: |
|---|
| 676 | { |
|---|
| 677 | SapphireCollectionSettings *colSettings = [[SapphireCollectionSettings alloc] initWithScene:[self scene] context:moc]; |
|---|
| 678 | [colSettings setGettingSelector:@selector(hiddenValue)]; |
|---|
| 679 | [colSettings setSettingSelector:@selector(setHiddenValue:)]; |
|---|
| 680 | [colSettings setListTitle:BRLocalizedString(@"Hide Collections", @"Hide Collections Menu Title")] ; |
|---|
| 681 | [[self stack] pushController:colSettings]; |
|---|
| 682 | [colSettings release]; |
|---|
| 683 | break; |
|---|
| 684 | } |
|---|
| 685 | case COMMAND_COLLECTIONS_DONT_IMPORT: |
|---|
| 686 | { |
|---|
| 687 | SapphireCollectionSettings *colSettings = [[SapphireCollectionSettings alloc] initWithScene:[self scene] context:moc]; |
|---|
| 688 | [colSettings setGettingSelector:@selector(skipValue)]; |
|---|
| 689 | [colSettings setSettingSelector:@selector(setSkipValue:)]; |
|---|
| 690 | [colSettings setListTitle:BRLocalizedString(@"Skip Collections", @"Skip Collections Menu Title")] ; |
|---|
| 691 | [[self stack] pushController:colSettings]; |
|---|
| 692 | [colSettings release]; |
|---|
| 693 | break; |
|---|
| 694 | } |
|---|
| 695 | case COMMAND_COLLECTIONS_DELETE: |
|---|
| 696 | { |
|---|
| 697 | SapphireCollectionSettings *colSettings = [[SapphireCollectionSettings alloc] initWithScene:[self scene] context:moc]; |
|---|
| 698 | [colSettings setGettingSelector:@selector(deleteValue)]; |
|---|
| 699 | [colSettings setSettingSelector:@selector(setDeleteValue:)]; |
|---|
| 700 | [colSettings setListTitle:BRLocalizedString(@"Delete Collections", @"Delete Collections Menu Title")]; |
|---|
| 701 | [[self stack] pushController:colSettings]; |
|---|
| 702 | [colSettings release]; |
|---|
| 703 | break; |
|---|
| 704 | } |
|---|
| 705 | default: |
|---|
| 706 | { |
|---|
| 707 | NSString *key = [setting objectForKey:SETTING_KEY]; |
|---|
| 708 | if(key == nil) |
|---|
| 709 | break; |
|---|
| 710 | BOOL setting = [self boolForKey:key]; |
|---|
| 711 | [options setObject:[NSNumber numberWithBool:!setting] forKey:key]; |
|---|
| 712 | } |
|---|
| 713 | } |
|---|
| 714 | |
|---|
| 715 | /*Save our settings*/ |
|---|
| 716 | [self writeSettings]; |
|---|
| 717 | |
|---|
| 718 | /*Redraw*/ |
|---|
| 719 | [[self list] reload] ; |
|---|
| 720 | [SapphireFrontRowCompat renderScene:[self scene]]; |
|---|
| 721 | |
|---|
| 722 | } |
|---|
| 723 | |
|---|
| 724 | - (id<BRMediaPreviewController>) previewControlForItem: (long) row |
|---|
| 725 | { |
|---|
| 726 | return [self previewControllerForItem:row]; |
|---|
| 727 | } |
|---|
| 728 | |
|---|
| 729 | - (id<BRMediaPreviewController>) previewControllerForItem: (long) item |
|---|
| 730 | { |
|---|
| 731 | if(item >= [settings count]) |
|---|
| 732 | return nil; |
|---|
| 733 | |
|---|
| 734 | NSDictionary *setting = [settings objectAtIndex:item]; |
|---|
| 735 | |
|---|
| 736 | /* Get setting name & kill the gem cushion */ |
|---|
| 737 | NSString *settingName = [[setting objectForKey:SETTING_NAME] substringFromIndex:2]; |
|---|
| 738 | NSString *settingDescription=[setting objectForKey:SETTING_DESCRIPTION]; |
|---|
| 739 | /* Construct a gerneric metadata asset for display */ |
|---|
| 740 | NSMutableDictionary *settingMeta=[[NSMutableDictionary alloc] init]; |
|---|
| 741 | [settingMeta setObject:settingName forKey:META_TITLE_KEY]; |
|---|
| 742 | [settingMeta setObject:[NSNumber numberWithInt:FILE_CLASS_UTILITY] forKey:FILE_CLASS_KEY]; |
|---|
| 743 | [settingMeta setObject:settingDescription forKey:META_DESCRIPTION_KEY]; |
|---|
| 744 | SapphireMediaPreview *preview = [[SapphireMediaPreview alloc] initWithScene:[self scene]]; |
|---|
| 745 | [preview setUtilityData:settingMeta]; |
|---|
| 746 | [settingMeta release]; |
|---|
| 747 | [preview setShowsMetadataImmediately:YES]; |
|---|
| 748 | /*And go*/ |
|---|
| 749 | return [preview autorelease]; |
|---|
| 750 | } |
|---|
| 751 | |
|---|
| 752 | @end |
|---|
| 753 | |
|---|