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