Changeset 23984
- Timestamp:
- 06/14/2008 07:47:50 PM (6 months ago)
- Files:
-
- trunk/Source/AIAbstractLogViewerWindowController.m (modified) (11 diffs)
- trunk/Source/AIChatLog.h (modified) (2 diffs)
- trunk/Source/AIChatLog.m (modified) (5 diffs)
- trunk/Source/AILogFromGroup.m (modified) (1 diff)
- trunk/Source/AILoggerPlugin.m (modified) (2 diffs)
- trunk/Source/AILogToGroup.h (modified) (2 diffs)
- trunk/Source/AILogToGroup.m (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Source/AIAbstractLogViewerWindowController.m
r23972 r23984 290 290 if ((currentTo = [currentToGroup to])) { 291 291 //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]]; 293 293 } 294 294 } … … 718 718 } 719 719 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"]) { 721 721 //HTML log 722 NSString *logFileText = [NSString stringWithContentsOfFile:[logBasePath stringByAppendingPathComponent:[theLog path]]];722 NSString *logFileText = [NSString stringWithContentsOfFile:[logBasePath stringByAppendingPathComponent:[theLog relativePath]]]; 723 723 NSAttributedString *attributedLogFileText = [AIHTMLDecoder decodeHTML:logFileText]; 724 724 … … 736 736 } 737 737 738 } else if ([[theLog path] hasSuffix:@".chatlog"]){738 } else if ([[theLog relativePath] hasSuffix:@".chatlog"]){ 739 739 //XML log 740 NSString *logFullPath = [logBasePath stringByAppendingPathComponent:[theLog path]];740 NSString *logFullPath = [logBasePath stringByAppendingPathComponent:[theLog relativePath]]; 741 741 742 742 BOOL isDir; … … 761 761 } else { 762 762 //Fallback: Plain text log 763 NSString *logFileText = [NSString stringWithContentsOfFile:[logBasePath stringByAppendingPathComponent:[theLog path]]];763 NSString *logFileText = [NSString stringWithContentsOfFile:[logBasePath stringByAppendingPathComponent:[theLog relativePath]]]; 764 764 if (logFileText) { 765 765 AITextAttributes *textAttributes = [AITextAttributes textAttributesWithFontFamily:@"Helvetica" traits:0 size:12]; … … 1370 1370 [pathComponents objectAtIndex:numPathComponents-3], 1371 1371 [pathComponents objectAtIndex:numPathComponents-2]]; 1372 NSString * path = [NSString stringWithFormat:@"%@/%@",toPath,[pathComponents objectAtIndex:numPathComponents-1]];1372 NSString *relativePath = [NSString stringWithFormat:@"%@/%@",toPath,[pathComponents objectAtIndex:numPathComponents-1]]; 1373 1373 AIChatLog *theLog; 1374 1374 1375 theLog = [[logToGroupDict objectForKey:toPath] logAtPath: path];1375 theLog = [[logToGroupDict objectForKey:toPath] logAtPath:relativePath]; 1376 1376 1377 1377 shouldDisplayDocument = [self chatLogMatchesDateFilter:theLog]; … … 2420 2420 enumerator = [deletedLogs objectEnumerator]; 2421 2421 while ((aLog = [enumerator nextObject])) { 2422 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog path]];2422 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog relativePath]]; 2423 2423 2424 2424 [fileManager createDirectoriesForPath:[logPath stringByDeletingLastPathComponent]]; … … 2448 2448 enumerator = [selectedLogs objectEnumerator]; 2449 2449 while ((aLog = [enumerator nextObject])) { 2450 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog path]];2450 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog relativePath]]; 2451 2451 2452 2452 [[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]]; 2454 2454 2455 2455 // Success will be unused in deployment builds as AILog turns to nothing 2456 2456 #ifdef DEBUG_BUILD 2457 2457 BOOL success = [logToGroup trashLog:aLog]; 2458 AILog(@"Trashing %@: %i",[aLog path], success);2458 AILog(@"Trashing %@: %i",[aLog relativePath], success); 2459 2459 #else 2460 2460 [logToGroup trashLog:aLog]; … … 2462 2462 //Clear the to group out if it no longer has anything of interest 2463 2463 if ([logToGroup logCount] == 0) { 2464 AILogFromGroup *logFromGroup = [logFromGroupDict objectForKey:[ NSString stringWithFormat:@"%@.%@",[aLog serviceClass],[aLog from]]];2464 AILogFromGroup *logFromGroup = [logFromGroupDict objectForKey:[[[aLog relativePath] stringByDeletingLastPathComponent] stringByDeletingLastPathComponent]]; 2465 2465 [logFromGroup removeToGroup:logToGroup]; 2466 2466 } 2467 2467 2468 2468 [logPaths addObject:logPath]; 2469 2469 [currentSearchResults removeObjectIdenticalTo:aLog]; … … 2561 2561 enumerator = [toGroups objectEnumerator]; 2562 2562 while ((toGroup = [enumerator nextObject])) { 2563 NSString *toGroupPath = [logBasePath stringByAppendingPathComponent:[toGroup path]];2563 NSString *toGroupPath = [logBasePath stringByAppendingPathComponent:[toGroup relativePath]]; 2564 2564 2565 2565 [fileManager createDirectoriesForPath:[toGroupPath stringByDeletingLastPathComponent]]; … … 2578 2578 2579 2579 while ((aLog = [logEnumerator nextObject])) { 2580 [plugin markLogDirtyAtPath:[logBasePath stringByAppendingPathComponent:[aLog path]]];2580 [plugin markLogDirtyAtPath:[logBasePath stringByAppendingPathComponent:[aLog relativePath]]]; 2581 2581 } 2582 2582 } … … 2600 2600 logEnumerator = [logToGroup logEnumerator]; 2601 2601 while ((aLog = [logEnumerator nextObject])) { 2602 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog path]];2602 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog relativePath]]; 2603 2603 [logPaths addObject:logPath]; 2604 2604 } trunk/Source/AIChatLog.h
r23817 r23984 18 18 19 19 @interface AIChatLog : NSObject { 20 NSString * path;20 NSString *relativePath; 21 21 NSString *from; 22 22 NSString *to; … … 31 31 32 32 //Accessors 33 - (NSString *) path;33 - (NSString *)relativePath; 34 34 - (NSString *)from; 35 35 - (NSString *)to; trunk/Source/AIChatLog.m
r23817 r23984 31 31 { 32 32 if ((self = [super init])) { 33 path = [inPath retain];33 relativePath = [inPath retain]; 34 34 from = [inFrom retain]; 35 35 to = [inTo retain]; … … 43 43 - (id)initWithPath:(NSString *)inPath 44 44 { 45 NSString *parentPath = [ path stringByDeletingLastPathComponent];45 NSString *parentPath = [inPath stringByDeletingLastPathComponent]; 46 46 NSString *toUID = [parentPath lastPathComponent]; 47 47 NSString *serviceAndFromUID = [[parentPath stringByDeletingLastPathComponent] lastPathComponent]; … … 73 73 - (void)dealloc 74 74 { 75 [ path release];75 [relativePath release]; 76 76 [from release]; 77 77 [to release]; … … 82 82 } 83 83 84 - (NSString *) path{85 return path;84 - (NSString *)relativePath{ 85 return relativePath; 86 86 } 87 87 - (NSString *)from{ … … 97 97 //Determine the date of this log lazily 98 98 if (!date) { 99 date = [dateFromFileName([ path lastPathComponent]) retain];99 date = [dateFromFileName([relativePath lastPathComponent]) retain]; 100 100 101 101 if (!date) { 102 102 //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. 103 103 //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]]]; 106 106 [parser setDelegate:self]; 107 107 [parser parse]; trunk/Source/AILogFromGroup.m
r16703 r23984 95 95 - (void)removeToGroup:(AILogToGroup *)toGroup 96 96 { 97 [[NSFileManager defaultManager] trashFileAtPath:[[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[toGroup path]]];97 [[NSFileManager defaultManager] trashFileAtPath:[[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[toGroup relativePath]]]; 98 98 99 99 [toGroupArray removeObjectIdenticalTo:toGroup]; trunk/Source/AILoggerPlugin.m
r23660 r23984 557 557 558 558 if (appender) { 559 if ([[appender path] hasSuffix:[chatLog path]]) {559 if ([[appender path] hasSuffix:[chatLog relativePath]]) { 560 560 [NSObject cancelPreviousPerformRequestsWithTarget:self 561 561 selector:@selector(finishClosingAppender:) … … 1159 1159 [dirtyLogLock lock]; 1160 1160 if (theLog != nil) { 1161 [dirtyLogArray addObject:[logBasePath stringByAppendingPathComponent:[theLog path]]];1161 [dirtyLogArray addObject:[logBasePath stringByAppendingPathComponent:[theLog relativePath]]]; 1162 1162 } 1163 1163 [dirtyLogLock unlock]; trunk/Source/AILogToGroup.h
r19050 r23984 18 18 19 19 @interface AILogToGroup : NSObject { 20 NSString * path;20 NSString *relativePath; 21 21 NSString *to; 22 22 NSString *from; 23 23 NSString *serviceClass; 24 24 25 25 NSMutableDictionary *logDict; 26 26 NSMutableDictionary *partialLogDict; … … 32 32 - (NSEnumerator *)logEnumerator; 33 33 - (int)logCount; 34 - (NSString *) path;34 - (NSString *)relativePath; 35 35 - (NSString *)from; 36 36 - (NSString *)to; trunk/Source/AILogToGroup.m
r23540 r23984 33 33 if ((self = [super init])) 34 34 { 35 path = [inPath retain];35 relativePath = [inPath retain]; 36 36 from = [inFrom retain]; 37 37 to = [inTo retain]; … … 49 49 - (void)dealloc 50 50 { 51 [ path release];51 [relativePath release]; 52 52 [to release]; 53 53 [from release]; … … 72 72 } 73 73 74 - (NSString *) path75 { 76 return path;74 - (NSString *)relativePath 75 { 76 return relativePath; 77 77 } 78 78 … … 110 110 111 111 logBasePath = [AILoggerPlugin logBasePath]; 112 fullPath = [logBasePath stringByAppendingPathComponent: path];112 fullPath = [logBasePath stringByAppendingPathComponent:relativePath]; 113 113 enumerator = [[defaultManager directoryContentsAtPath:fullPath] objectEnumerator]; 114 114 while ((fileName = [enumerator nextObject])) { 115 115 if (![fileName hasPrefix:@"."]) { 116 NSString *relativeLogPath = [ path stringByAppendingPathComponent:fileName];116 NSString *relativeLogPath = [relativePath stringByAppendingPathComponent:fileName]; 117 117 118 118 if (![logDict objectForKey:relativeLogPath]) { … … 183 183 - (BOOL)trashLog:(AIChatLog *)aLog 184 184 { 185 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog path]];185 NSString *logPath = [[AILoggerPlugin logBasePath] stringByAppendingPathComponent:[aLog relativePath]]; 186 186 BOOL success; 187 187 success = [[NSFileManager defaultManager] trashFileAtPath:logPath]; 188 188 189 189 //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]]; 192 192 193 193 return success;