Changeset 206

Show
Ignore:
Timestamp:
09/06/07 21:27:30 (1 year ago)
Author:
gbooker
Message:

Added the rest of the notifications. This should mostly complete the tv browser

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SapphireTVDirectory.h

    r203 r206  
    1414} 
    1515- (void)processFile:(SapphireFileMetaData *)file; 
     16- (void)removeFile:(SapphireFileMetaData *)file; 
    1617@end 
    1718 
  • trunk/SapphireTVDirectory.m

    r205 r206  
    6161{ 
    6262} 
     63 
     64- (void)removeFile:(SapphireFileMetaData *)file 
     65{ 
     66} 
    6367@end 
    6468 
     
    7175         
    7276        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileAdded:) name:META_DATA_FILE_ADDED_NOTIFICATION object:nil]; 
     77        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileRemoved:) name:META_DATA_FILE_REMOVED_NOTIFICATION object:nil]; 
     78        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileInfoHasChanged:) name:META_DATA_FILE_INFO_HAS_CHANGED_NOTIFICATION object:nil]; 
     79        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileInfoWillChanged:) name:META_DATA_FILE_INFO_WILL_CHANGE_NOTIFICATION object:nil]; 
    7380         
    7481        return self; 
     
    7986        SapphireFileMetaData *file = [notification object]; 
    8087        [self processFile:file]; 
     88} 
     89 
     90- (void)fileRemoved:(NSNotification *)notification 
     91{ 
     92        SapphireFileMetaData *file = [notification object]; 
     93        [self removeFile:file]; 
     94} 
     95 
     96- (void)fileInfoHasChanged:(NSNotification *)notification 
     97{ 
     98        NSDictionary *info = [notification userInfo]; 
     99        if(![[info objectForKey:META_DATA_FILE_INFO_KIND] isEqualToString:META_TVRAGE_IMPORT_KEY]) 
     100                return; 
     101        SapphireFileMetaData *file = [notification object]; 
     102        [self processFile:file]; 
     103} 
     104 
     105- (void)fileInfoWillChanged:(NSNotification *)notification 
     106{ 
     107        NSDictionary *info = [notification userInfo]; 
     108        if(![[info objectForKey:META_DATA_FILE_INFO_KIND] isEqualToString:META_TVRAGE_IMPORT_KEY]) 
     109                return; 
     110        SapphireFileMetaData *file = [notification object]; 
     111        [self removeFile:file]; 
    81112} 
    82113 
     
    105136        [showInfo processFile:file]; 
    106137} 
     138 
     139- (void)removeFile:(SapphireFileMetaData *)file 
     140{ 
     141        NSString *show = [file showName]; 
     142        if(show == nil) 
     143                return; 
     144        SapphireShowDirectory *showInfo = [directory objectForKey:show]; 
     145        if(showInfo != nil) 
     146        { 
     147                [showInfo removeFile:file]; 
     148                if([[showInfo directories] count] == 0) 
     149                { 
     150                        [directory removeObjectForKey:show]; 
     151                        [self setReloadTimer]; 
     152                } 
     153        } 
     154} 
    107155@end 
    108156 
     
    132180        } 
    133181        [seasonInfo processFile:file]; 
     182} 
     183 
     184- (void)removeFile:(SapphireFileMetaData *)file 
     185{ 
     186        int seasonNum = [file seasonNumber]; 
     187        if(seasonNum == 0) 
     188                return; 
     189        NSString *season = [NSString stringWithFormat:BRLocalizedString(@"Season %d", @"Season name"), seasonNum]; 
     190        SapphireSeasonDirectory *seasonInfo = [directory objectForKey:season]; 
     191        if(seasonInfo == nil) 
     192        { 
     193                [seasonInfo removeFile:file]; 
     194                if([[seasonInfo directories] count] == 0) 
     195                { 
     196                        [directory removeObjectForKey:season]; 
     197                        [self setReloadTimer]; 
     198                } 
     199        } 
    134200} 
    135201@end 
     
    165231        [self setReloadTimer]; 
    166232} 
    167 @end 
     233 
     234- (void)removeFile:(SapphireFileMetaData *)file 
     235
     236        int epNum = [file episodeNumber]; 
     237        if(epNum == 0) 
     238                return; 
     239        NSString *ep = [NSString stringWithFormat:BRLocalizedString(@"Episode %d", @"Episode name"), epNum]; 
     240        [directory removeObjectForKey:ep]; 
     241        [self setReloadTimer]; 
     242
     243@end