Adium

Changeset 23984

Show
Ignore:
Timestamp:
06/14/2008 07:47:50 PM (6 months ago)
Author:
evands
Message:
  • Renamed -[AIChatLog path] to -[AIChatLog relativePath]. This reflects its true nature.
  • Renamed -[AILogToGroup path] to -[AILogToGroup relativePath]. This reflects its true nature.
  • Used relativePath calls instead of reconstruction of the path from service, from UID, and to UID when trashing logs. This makes trashing work correctly even if we converted the service, e.g. from Jabber to Google Talk. Fixes #10022
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/AIAbstractLogViewerWindowController.m

    r23972 r23984  
    290290                                if ((currentTo = [currentToGroup to])) { 
    291291                                        //Store currentToGroup on a key in the form "SERVICE.ACCOUNT_NAME/TARGET_CONTACT" 
    292                                         [logToGroupDict setObject:currentToGroup forKey:[currentToGroup path]]; 
     292                                        [logToGroupDict setObject:currentToGroup forKey:[currentToGroup relativePath]]; 
    293293                                } 
    294294                        } 
     
    718718                } 
    719719                 
    720                 if ([[theLog path] hasSuffix:@".AdiumHTMLLog"] || [[theLog path] hasSuffix:@".html"] || [[theLog path] hasSuffix:@".html.bak"]) { 
     720                if ([[theLog relativePath] hasSuffix:@".AdiumHTMLLog"] || [[theLog relativePath] hasSuffix:@".html"] || [[theLog relativePath] hasSuffix:@".html.bak"]) { 
    721721                        //HTML log 
    722                         NSString                   *logFileText = [NSString stringWithContentsOfFile:[logBasePath stringByAppendingPathComponent:[theLog path]]]; 
     722                        NSString                   *logFileText = [NSString stringWithContentsOfFile:[logBasePath stringByAppendingPathComponent:[theLog relativePath]]]; 
    723723                        NSAttributedString *attributedLogFileText = [AIHTMLDecoder decodeHTML:logFileText]; 
    724724 
     
    736736                        } 
    737737 
    738                 } else if ([[theLog path] hasSuffix:@".chatlog"]){ 
     738                } else if ([[theLog relativePath] hasSuffix:@".chatlog"]){ 
    739739                        //XML log 
    740                         NSString *logFullPath = [logBasePath stringByAppendingPathComponent:[theLog path]]; 
     740                        NSString *logFullPath = [logBasePath stringByAppendingPathComponent:[theLog relativePath]]; 
    741741                         
    742742                        BOOL isDir; 
     
    761761                } else { 
    762762                        //Fallback: Plain text log 
    763                         NSString *logFileText = [NSString stringWithContentsOfFile:[logBasePath stringByAppendingPathComponent:[theLog path]]]; 
     763                        NSString *logFileText = [NSString stringWithContentsOfFile:[logBasePath stringByAppendingPathComponent:[theLog relativePath]]]; 
    764764                        if (logFileText) { 
    765765                                AITextAttributes *textAttributes = [AITextAttributes textAttributesWithFontFamily:@"Helvetica" traits:0 size:12]; 
     
    13701370                        [pathComponents objectAtIndex:numPathComponents-3], 
    13711371                        [pathComponents objectAtIndex:numPathComponents-2]]; 
    1372                 NSString                *path = [NSString stringWithFormat:@"%@/%@",toPath,[pathComponents objectAtIndex:numPathComponents-1]]; 
     1372                NSString                *relativePath = [NSString stringWithFormat:@"%@/%@",toPath,[pathComponents objectAtIndex:numPathComponents-1]]; 
    13731373                AIChatLog               *theLog; 
    13741374                 
    1375                 theLog = [[logToGroupDict objectForKey:toPath] logAtPath:path]; 
     1375                theLog = [[logToGroupDict objectForKey:toPath] logAtPath:relativePath]; 
    13761376                 
    13771377                shouldDisplayDocument = [self chatLogMatchesDateFilter:theLog]; 
     
    24202420        enumerator = [deletedLogs objectEnumerator]; 
    24212421        while ((aLog = [enumerator nextObject])) { 
    2422                 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog path]]; 
     2422                NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog relativePath]]; 
    24232423                 
    24242424                [fileManager createDirectoriesForPath:[logPath stringByDeletingLastPathComponent]]; 
     
    24482448                enumerator = [selectedLogs objectEnumerator]; 
    24492449                while ((aLog = [enumerator nextObject])) { 
    2450                         NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog path]]; 
     2450                        NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog relativePath]]; 
    24512451                         
    24522452                        [[adium notificationCenter] postNotificationName:ChatLog_WillDelete object:aLog userInfo:nil]; 
    2453                         AILogToGroup    *logToGroup = [logToGroupDict objectForKey:[NSString stringWithFormat:@"%@.%@/%@",[aLog serviceClass],[aLog from],[aLog to]]]; 
     2453                        AILogToGroup    *logToGroup = [logToGroupDict objectForKey:[[aLog relativePath] stringByDeletingLastPathComponent]]; 
    24542454 
    24552455                        // Success will be unused in deployment builds as AILog turns to nothing 
    24562456#ifdef DEBUG_BUILD 
    24572457                        BOOL success = [logToGroup trashLog:aLog]; 
    2458                         AILog(@"Trashing %@: %i",[aLog path], success); 
     2458                        AILog(@"Trashing %@: %i",[aLog relativePath], success); 
    24592459#else 
    24602460                        [logToGroup trashLog:aLog]; 
     
    24622462                        //Clear the to group out if it no longer has anything of interest 
    24632463                        if ([logToGroup logCount] == 0) { 
    2464                                 AILogFromGroup  *logFromGroup = [logFromGroupDict objectForKey:[NSString stringWithFormat:@"%@.%@",[aLog serviceClass],[aLog from]]]; 
     2464                                AILogFromGroup  *logFromGroup = [logFromGroupDict objectForKey:[[[aLog relativePath] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent]]; 
    24652465                                [logFromGroup removeToGroup:logToGroup]; 
    24662466                        } 
    2467                          
     2467 
    24682468                        [logPaths addObject:logPath]; 
    24692469                        [currentSearchResults removeObjectIdenticalTo:aLog]; 
     
    25612561        enumerator = [toGroups objectEnumerator]; 
    25622562        while ((toGroup = [enumerator nextObject])) { 
    2563                 NSString *toGroupPath = [logBasePath stringByAppendingPathComponent:[toGroup path]]; 
     2563                NSString *toGroupPath = [logBasePath stringByAppendingPathComponent:[toGroup relativePath]]; 
    25642564 
    25652565                [fileManager createDirectoriesForPath:[toGroupPath stringByDeletingLastPathComponent]]; 
     
    25782578         
    25792579                while ((aLog = [logEnumerator nextObject])) { 
    2580                         [plugin markLogDirtyAtPath:[logBasePath stringByAppendingPathComponent:[aLog path]]]; 
     2580                        [plugin markLogDirtyAtPath:[logBasePath stringByAppendingPathComponent:[aLog relativePath]]]; 
    25812581                } 
    25822582        } 
     
    26002600                        logEnumerator = [logToGroup logEnumerator]; 
    26012601                        while ((aLog = [logEnumerator nextObject])) { 
    2602                                 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog path]]; 
     2602                                NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog relativePath]]; 
    26032603                                [logPaths addObject:logPath]; 
    26042604                        } 
  • trunk/Source/AIChatLog.h

    r23817 r23984  
    1818 
    1919@interface AIChatLog : NSObject { 
    20     NSString        *path; 
     20    NSString        *relativePath; 
    2121    NSString        *from; 
    2222    NSString        *to; 
     
    3131 
    3232//Accessors 
    33 - (NSString *)path; 
     33- (NSString *)relativePath; 
    3434- (NSString *)from; 
    3535- (NSString *)to; 
  • trunk/Source/AIChatLog.m

    r23817 r23984  
    3131{ 
    3232    if ((self = [super init])) { 
    33                 path = [inPath retain]; 
     33                relativePath = [inPath retain]; 
    3434                from = [inFrom retain]; 
    3535                to = [inTo retain]; 
     
    4343- (id)initWithPath:(NSString *)inPath 
    4444{ 
    45         NSString *parentPath = [path stringByDeletingLastPathComponent]; 
     45        NSString *parentPath = [inPath stringByDeletingLastPathComponent]; 
    4646        NSString *toUID = [parentPath lastPathComponent]; 
    4747        NSString *serviceAndFromUID = [[parentPath stringByDeletingLastPathComponent] lastPathComponent]; 
     
    7373- (void)dealloc 
    7474{ 
    75     [path release]; 
     75    [relativePath release]; 
    7676    [from release]; 
    7777    [to release]; 
     
    8282} 
    8383 
    84 - (NSString *)path{ 
    85     return path; 
     84- (NSString *)relativePath{ 
     85    return relativePath; 
    8686} 
    8787- (NSString *)from{ 
     
    9797        //Determine the date of this log lazily 
    9898        if (!date) { 
    99                 date = [dateFromFileName([path lastPathComponent]) retain]; 
     99                date = [dateFromFileName([relativePath lastPathComponent]) retain]; 
    100100 
    101101                if (!date) { 
    102102                        //Sometimes the filename doesn't have a date (e.g., “jdoe ((null)).chatlog”). In such cases, if it's a chatlog, parse it and get the date from the first element that has one. 
    103103                        //We don't do this first because NSXMLParser uses +[NSData dataWithContentsOfURL:], which is painful for large log files. 
    104                         if ([[path pathExtension] isEqualToString:@"chatlog"]) { 
    105                                 NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[[[[AIObject sharedAdiumInstance] loginController] userDirectory] stringByAppendingPathComponent:PATH_LOGS] stringByAppendingPathComponent:path]]]; 
     104                        if ([[relativePath pathExtension] isEqualToString:@"chatlog"]) { 
     105                                NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[[[[AIObject sharedAdiumInstance] loginController] userDirectory] stringByAppendingPathComponent:PATH_LOGS] stringByAppendingPathComponent:relativePath]]]; 
    106106                                [parser setDelegate:self]; 
    107107                                [parser parse]; 
  • trunk/Source/AILogFromGroup.m

    r16703 r23984  
    9595- (void)removeToGroup:(AILogToGroup *)toGroup 
    9696{ 
    97         [[NSFileManager defaultManager] trashFileAtPath:[[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[toGroup path]]]; 
     97        [[NSFileManager defaultManager] trashFileAtPath:[[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[toGroup relativePath]]]; 
    9898 
    9999        [toGroupArray removeObjectIdenticalTo:toGroup]; 
  • trunk/Source/AILoggerPlugin.m

    r23660 r23984  
    557557         
    558558        if (appender) { 
    559                 if ([[appender path] hasSuffix:[chatLog path]]) { 
     559                if ([[appender path] hasSuffix:[chatLog relativePath]]) { 
    560560                        [NSObject cancelPreviousPerformRequestsWithTarget:self 
    561561                                                                                                         selector:@selector(finishClosingAppender:)  
     
    11591159                                [dirtyLogLock lock]; 
    11601160                                if (theLog != nil) { 
    1161                                         [dirtyLogArray addObject:[logBasePath stringByAppendingPathComponent:[theLog path]]]; 
     1161                                        [dirtyLogArray addObject:[logBasePath stringByAppendingPathComponent:[theLog relativePath]]]; 
    11621162                                } 
    11631163                                [dirtyLogLock unlock]; 
  • trunk/Source/AILogToGroup.h

    r19050 r23984  
    1818 
    1919@interface AILogToGroup : NSObject { 
    20     NSString                    *path; 
     20    NSString                    *relativePath; 
    2121    NSString                    *to; 
    2222    NSString                    *from; 
    2323        NSString                        *serviceClass; 
    24          
     24 
    2525        NSMutableDictionary     *logDict; 
    2626        NSMutableDictionary     *partialLogDict; 
     
    3232- (NSEnumerator *)logEnumerator; 
    3333- (int)logCount; 
    34 - (NSString *)path; 
     34- (NSString *)relativePath; 
    3535- (NSString *)from; 
    3636- (NSString *)to; 
  • trunk/Source/AILogToGroup.m

    r23540 r23984  
    3333    if ((self = [super init])) 
    3434        { 
    35                 path = [inPath retain]; 
     35                relativePath = [inPath retain]; 
    3636                from = [inFrom retain]; 
    3737                to = [inTo retain]; 
     
    4949- (void)dealloc 
    5050{ 
    51     [path release]; 
     51    [relativePath release]; 
    5252    [to release]; 
    5353    [from release]; 
     
    7272} 
    7373 
    74 - (NSString *)path 
    75 { 
    76         return path; 
     74- (NSString *)relativePath 
     75{ 
     76        return relativePath; 
    7777} 
    7878 
     
    110110                         
    111111                        logBasePath = [AILoggerPlugin logBasePath]; 
    112                         fullPath = [logBasePath stringByAppendingPathComponent:path]; 
     112                        fullPath = [logBasePath stringByAppendingPathComponent:relativePath]; 
    113113                        enumerator = [[defaultManager directoryContentsAtPath:fullPath] objectEnumerator]; 
    114114                        while ((fileName = [enumerator nextObject])) {                   
    115115                                if (![fileName hasPrefix:@"."]) { 
    116                                         NSString        *relativeLogPath = [path stringByAppendingPathComponent:fileName]; 
     116                                        NSString        *relativeLogPath = [relativePath stringByAppendingPathComponent:fileName]; 
    117117                                         
    118118                                        if (![logDict objectForKey:relativeLogPath]) { 
     
    183183- (BOOL)trashLog:(AIChatLog *)aLog 
    184184{ 
    185         NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog path]]; 
     185        NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog relativePath]]; 
    186186        BOOL     success; 
    187187        success = [[NSFileManager defaultManager] trashFileAtPath:logPath]; 
    188188 
    189189        //Remove from our dictionaries so we don't reference the removed log 
    190         [logDict removeObjectForKey:[aLog path]]; 
    191         [partialLogDict removeObjectForKey:[aLog path]]; 
     190        [logDict removeObjectForKey:[aLog relativePath]]; 
     191        [partialLogDict removeObjectForKey:[aLog relativePath]]; 
    192192         
    193193        return success;