Other/Adium Spotlight Importer/GetMetadataForFile.m
author Thijs Alkemade <me@thijsalkema.de>
Wed, 30 Oct 2013 18:34:07 +0100
branchadium-1.5.9
changeset 5749 1521cab508bf
parent 5722 4ae85ad012cd
child 5750 dad5f3048dc3
permissions -rw-r--r--
Fix Adium not storing timestamps with messages. Setting NSDateFormatterBehavior10_4 was not the solution, all included time format strings are now 10.4 style.

Message styles can still contain old style format strings, causing _NSDateFormatter_Log_New_Methods_On_Old_Formatters to be hit. We probably need to update the included ones and deprecate their usage in Adium.
3679
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
     1
/* 
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
     2
 * Adium is the legal property of its developers, whose names are listed in the copyright file included
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
     3
 * with this source distribution.
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
     4
 * 
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
     6
 * General Public License as published by the Free Software Foundation; either version 2 of the License,
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
     7
 * or (at your option) any later version.
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
     8
 * 
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
     9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
    10
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
    11
 * Public License for more details.
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
    12
 * 
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
    13
 * You should have received a copy of the GNU General Public License along with this program; if not,
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
    14
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
f4294bb53b0f Bring consistency to file headings, this is not exhaustive. Evan and the rest.
Frank Dowsett <wixardy@adium.im>
parents: 2780
diff changeset
    15
 */
2093
d470a05e220b I see no reason to not use #import for everything. Apple's compiler supports it fine in .c files, and it doesn't seem to have any downsides vs #include unless you're playing silly multiple inclusion tricks
David Smith <catfish.man@gmail.com>
parents: 1797
diff changeset
    16
#import <CoreFoundation/CoreFoundation.h>
d470a05e220b I see no reason to not use #import for everything. Apple's compiler supports it fine in .c files, and it doesn't seem to have any downsides vs #include unless you're playing silly multiple inclusion tricks
David Smith <catfish.man@gmail.com>
parents: 1797
diff changeset
    17
#import <CoreServices/CoreServices.h> 
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    18
#import "GetMetadataForHTMLLog.h"
1797
a67fab403797 Build fix
David Smith <catfish.man@gmail.com>
parents: 1634
diff changeset
    19
#import "NSCalendarDate+ISO8601Parsing.h"
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    20
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    21
/*
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    22
 Relevant keys from MDItem.h we use or may want to use:
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    23
 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    24
 @constant kMDItemContentCreationDate
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    25
 This is the date that the contents of the file were created,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    26
 has an application specific semantic.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    27
 Type is a CFDate.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    28
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    29
 @constant kMDItemTextContent
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    30
 Contains the text content of the document. Type is a CFString.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    31
 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    32
 @constant kMDItemDisplayName
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    33
 This is the localized version of the LaunchServices call
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    34
 LSCopyDisplayNameForURL()/LSCopyDisplayNameForRef().
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    35
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    36
 @const  kMDItemInstantMessageAddresses
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    37
 Instant message addresses for this item. Type is an Array of CFStrings.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    38
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    39
 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    40
/* -----------------------------------------------------------------------------
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    41
Get metadata attributes from file
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    42
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    43
This function's job is to extract useful information your file format supports
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    44
and return it as a dictionary
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    45
----------------------------------------------------------------------------- */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    46
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    47
Boolean GetMetadataForXMLLog(NSMutableDictionary *attributes, NSString *pathToFile);
3842
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    48
NSString *CopyTextContentForXMLLogData(NSData *logData);
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    49
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    50
Boolean GetMetadataForFile(void* thisInterface, 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    51
						   CFMutableDictionaryRef attributes, 
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    52
						   CFStringRef contentTypeUTI,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    53
						   CFStringRef pathToFile)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    54
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    55
    /* Pull any available metadata from the file at the specified path */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    56
    /* Return the attribute keys and attribute values in the dict */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    57
    /* Return TRUE if successful, FALSE if there was no data provided */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    58
    
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    59
	Boolean				success = FALSE;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    60
	NSAutoreleasePool	*pool;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    61
	pool = [[NSAutoreleasePool alloc] init];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    62
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    63
	if (CFStringCompare(contentTypeUTI, (CFStringRef)@"com.adiumx.htmllog", kCFCompareBackwards) == kCFCompareEqualTo) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    64
		success = GetMetadataForHTMLLog((NSMutableDictionary *)attributes, (NSString *)pathToFile);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    65
	} else if (CFStringCompare(contentTypeUTI, (CFStringRef)@"com.adiumx.xmllog", kCFCompareBackwards) == kCFCompareEqualTo) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    66
		success = GetMetadataForXMLLog((NSMutableDictionary *)attributes, (NSString *)pathToFile);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    67
	} else {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    68
		NSLog(@"We were passed %@, of type %@, which is an unknown type",pathToFile,contentTypeUTI);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    69
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    70
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    71
	[pool release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    72
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    73
    return success;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    74
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
    75
3842
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    76
static CFStringRef ResolveUTI(CFStringRef contentTypeUTI, NSURL *urlToFile) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    77
    //Deteremine the UTI type if we weren't passed one
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    78
    CFStringRef pathExtension = (CFStringRef)[urlToFile pathExtension];
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    79
	if (contentTypeUTI == NULL) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    80
		if (CFStringCompare(pathExtension, CFSTR("chatLog"), (kCFCompareBackwards | kCFCompareCaseInsensitive)) == kCFCompareEqualTo) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    81
			contentTypeUTI = CFSTR("com.adiumx.xmllog");
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    82
		} else if (CFStringCompare(pathExtension, CFSTR("AdiumXMLLog"), (kCFCompareBackwards | kCFCompareCaseInsensitive)) == kCFCompareEqualTo) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    83
			contentTypeUTI = CFSTR("com.adiumx.xmllog");
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    84
		} else {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    85
			//Treat all other log extensions as HTML logs (plaintext will come out fine this way, too)
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    86
			contentTypeUTI = CFSTR("com.adiumx.htmllog");
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    87
		}
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    88
	}
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    89
    return contentTypeUTI;
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    90
}
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    91
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    92
NSData *CopyDataForURL(CFStringRef contentTypeUTI, NSURL *urlToFile) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    93
    NSAutoreleasePool	*pool = [[NSAutoreleasePool alloc] init];
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    94
	NSData			*content;
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    95
	contentTypeUTI = ResolveUTI(contentTypeUTI, urlToFile);
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    96
    
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    97
	if (CFEqual(contentTypeUTI, CFSTR("com.adiumx.htmllog"))) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    98
		content = [[NSData alloc] initWithContentsOfURL:urlToFile options:NSDataReadingUncached error:NULL];
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
    99
	} else if (CFEqual(contentTypeUTI, CFSTR("com.adiumx.xmllog"))) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   100
		BOOL isDir;
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   101
        NSString *path = [urlToFile path];
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   102
		if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir]) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   103
            if (isDir) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   104
                /* If we have a chatLog bundle, we want to get the text content for the xml file inside */
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   105
                urlToFile = [NSURL fileURLWithPath:[path stringByAppendingPathComponent:[[[path lastPathComponent] stringByDeletingPathExtension] stringByAppendingPathExtension:@"xml"]]];
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   106
            }
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   107
			
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   108
			content = [[NSData alloc] initWithContentsOfURL:urlToFile options:NSUncachedRead error:NULL];
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   109
            
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   110
		} else {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   111
			content = nil;
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   112
		}
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   113
		
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   114
	} else {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   115
		content = nil;
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   116
		NSLog(@"We were passed %@, of type %@, which is an unknown type", urlToFile, contentTypeUTI);
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   117
	}
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   118
    
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   119
	[pool release];
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   120
	
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   121
	return content;
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   122
}
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   123
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   124
NSData *CopyDataForFile(CFStringRef contentTypeUTI, CFStringRef pathToFile) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   125
    return CopyDataForURL(contentTypeUTI, [NSURL fileURLWithPath:(NSString *)pathToFile]);
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   126
}
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   127
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   128
CFStringRef CopyTextContentForFileData(CFStringRef contentTypeUTI, NSURL *urlToFile, NSData *fileData) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   129
    if (!fileData) return NULL;
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   130
        
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   131
    contentTypeUTI = ResolveUTI(contentTypeUTI, urlToFile);
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   132
    
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   133
    NSString *result = nil;
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   134
    
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   135
    if (CFEqual(contentTypeUTI,CFSTR("com.adiumx.htmllog"))) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   136
        result = CopyTextContentForHTMLLogData(fileData);
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   137
	} else if (CFEqual(contentTypeUTI, CFSTR("com.adiumx.xmllog"))) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   138
        result = CopyTextContentForXMLLogData(fileData);
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   139
    }
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   140
    return (CFStringRef)result;
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   141
}
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   142
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   143
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   144
 * @brief Copy the text content for a file
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   145
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   146
 * This is the text which would be the kMDItemTextContent for the file in Spotlight.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   147
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   148
 * @param contentTypeUTI The UTI type. If NULL, the extension of pathToFile will be used
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   149
 * @param pathToFile The full path to the file
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   150
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   151
 * @result The kMDItemTextContent. Follows the Copy rule.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   152
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   153
CFStringRef CopyTextContentForFile(CFStringRef contentTypeUTI,
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   154
								   CFStringRef pathToFile)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   155
{
3842
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   156
	NSAutoreleasePool	*pool = [[NSAutoreleasePool alloc] init];
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   157
    NSData *logData = CopyDataForFile(contentTypeUTI, pathToFile);
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   158
	CFStringRef	textContent = CopyTextContentForFileData(contentTypeUTI, [NSURL fileURLWithPath:(NSString *)pathToFile], logData);
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   159
	[pool release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   160
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   161
	return textContent;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   162
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   163
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   164
/*!
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   165
 * @brief get metadata for an XML file
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   166
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   167
 * This function gets the metadata contained within a universal chat log format file
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   168
 * @param attributes The dictionary in which to store the metadata
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   169
 * @param pathToFile The path to the file to index
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   170
 *
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   171
 * @result true if successful, false if not
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   172
 */
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   173
Boolean GetMetadataForXMLLog(NSMutableDictionary *attributes, NSString *pathToFile)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   174
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   175
	Boolean ret = YES;
2707
91f8ba5821d4 Initialize the xmlDoc variables to nil, so that we don't crash in cases where we fail to create an NSXMLDocument to assign here.
Peter Hosey <hg@boredzo.org>
parents: 2705
diff changeset
   176
	NSXMLDocument *xmlDoc = nil;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   177
	NSError *err=nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   178
	NSURL *furl = [NSURL fileURLWithPath:(NSString *)pathToFile];
2704
94ffd2caa8d1 Adding spotlight grease.
Stephen Holt <sholt@adium.im>
parents: 2093
diff changeset
   179
	NSData *data = [NSData dataWithContentsOfURL:furl options:NSUncachedRead error:&err];
94ffd2caa8d1 Adding spotlight grease.
Stephen Holt <sholt@adium.im>
parents: 2093
diff changeset
   180
	if (data) {
94ffd2caa8d1 Adding spotlight grease.
Stephen Holt <sholt@adium.im>
parents: 2093
diff changeset
   181
		xmlDoc = [[NSXMLDocument alloc] initWithData:data options:NSXMLNodePreserveCDATA error:&err];
94ffd2caa8d1 Adding spotlight grease.
Stephen Holt <sholt@adium.im>
parents: 2093
diff changeset
   182
	}
94ffd2caa8d1 Adding spotlight grease.
Stephen Holt <sholt@adium.im>
parents: 2093
diff changeset
   183
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   184
	if (xmlDoc)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   185
	{   
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   186
		NSArray *senderNodes = [xmlDoc nodesForXPath:@"//message/@sender"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   187
												error:&err];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   188
		NSSet *duplicatesRemover = [NSSet setWithArray: senderNodes];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   189
		// XPath returns an array of NSXMLNodes. Must convert them to strings containing just the attribute value.
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   190
		NSMutableArray *authorsArray = [NSMutableArray arrayWithCapacity:[duplicatesRemover count]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   191
		NSXMLNode *senderNode = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   192
		
75
eb2d4c6c53c6 Preliminary conversion to using fast enumeration; caveats: variable declarations were not moved into loop headers. In *most* cases it should be safe to move them, but make sure the variable is not needed later on in the method. Also, AIContactController was not converted, because the conversion tool freaked out
David Smith
parents: 0
diff changeset
   193
		for( senderNode in duplicatesRemover ) {
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   194
			[authorsArray addObject:[senderNode objectValue]];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   195
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   196
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   197
		[(NSMutableDictionary *)attributes setObject:authorsArray
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   198
											  forKey:(NSString *)kMDItemAuthors];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   199
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   200
		[(NSMutableDictionary *)attributes setObject:authorsArray
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   201
											  forKey:(NSString *)kMDItemInstantMessageAddresses];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   202
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   203
		NSArray *contentArray = [xmlDoc nodesForXPath:@"//message//text()"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   204
												error:&err];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   205
		NSString *contentString = [contentArray componentsJoinedByString:@" "];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   206
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   207
		[attributes setObject:contentString
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   208
					   forKey:(NSString *)kMDItemTextContent];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   209
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   210
		NSString *serviceString = [[[xmlDoc rootElement] attributeForName:@"service"] objectValue];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   211
		if(serviceString != nil)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   212
			[attributes setObject:serviceString
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   213
						   forKey:@"com_adiumX_service"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   214
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   215
		NSArray			*children = [[xmlDoc rootElement] children];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   216
		NSCalendarDate	*startDate = nil, *endDate = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   217
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   218
		if ([children count]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   219
			NSString		*dateStr;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   220
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   221
			dateStr = [[(NSXMLElement *)[children objectAtIndex:0] attributeForName:@"time"] objectValue];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   222
			startDate = (dateStr ? [NSCalendarDate calendarDateWithString:dateStr] : nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   223
			if (startDate)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   224
				[(NSMutableDictionary *)attributes setObject:startDate
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   225
													  forKey:(NSString *)kMDItemContentCreationDate];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   226
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   227
			dateStr = [[(NSXMLElement *)[children lastObject] attributeForName:@"time"] objectValue];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   228
			endDate = (dateStr ? [NSCalendarDate calendarDateWithString:dateStr] : nil);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   229
			if (endDate)
2780
25eb9c078e5c Set kMDItemDurationSeconds to a double, not an int. Fixes a warning.
Peter Hosey <hg@boredzo.org>
parents: 2707
diff changeset
   230
				[(NSMutableDictionary *)attributes setObject:[NSNumber numberWithDouble:[endDate timeIntervalSinceDate:startDate]]
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   231
													  forKey:(NSString *)kMDItemDurationSeconds];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   232
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   233
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   234
		NSString *accountString = [[[xmlDoc rootElement] attributeForName:@"account"] objectValue];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   235
		if (accountString) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   236
			[attributes setObject:accountString
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   237
						   forKey:@"com_adiumX_chatSource"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   238
			NSMutableArray *otherAuthors = [authorsArray mutableCopy];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   239
			[otherAuthors removeObject:accountString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   240
			[attributes setObject:otherAuthors
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   241
						   forKey:@"com_adiumX_chatDestinations"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   242
			//pick the first author for this.  likely a bad idea
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   243
			if (startDate && [otherAuthors count]) {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   244
				NSString *toUID = [otherAuthors objectAtIndex:0];
5749
1521cab508bf Fix Adium not storing timestamps with messages. Setting NSDateFormatterBehavior10_4 was not the solution, all included time format strings are now 10.4 style.
Thijs Alkemade <me@thijsalkema.de>
parents: 5722
diff changeset
   245
				NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
1521cab508bf Fix Adium not storing timestamps with messages. Setting NSDateFormatterBehavior10_4 was not the solution, all included time format strings are now 10.4 style.
Thijs Alkemade <me@thijsalkema.de>
parents: 5722
diff changeset
   246
				dateFormatter.dateFormat = @"yyyy'-'MM'-'dd";
4879
b552a65ccb58 It is recommended to use a NSDateFormatter instead of -descriptionWithCalendarFormat:.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4878
diff changeset
   247
				
b552a65ccb58 It is recommended to use a NSDateFormatter instead of -descriptionWithCalendarFormat:.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4878
diff changeset
   248
				[attributes setObject:[NSString stringWithFormat:@"%@ on %@",toUID,[dateFormatter stringFromDate:startDate]]
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   249
							   forKey:(NSString *)kMDItemDisplayName];
4879
b552a65ccb58 It is recommended to use a NSDateFormatter instead of -descriptionWithCalendarFormat:.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4878
diff changeset
   250
				
b552a65ccb58 It is recommended to use a NSDateFormatter instead of -descriptionWithCalendarFormat:.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 4878
diff changeset
   251
				[dateFormatter release];
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   252
			}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   253
			[otherAuthors release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   254
			
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   255
		}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   256
		[attributes setObject:@"Chat log"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   257
					   forKey:(NSString *)kMDItemKind];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   258
		[attributes setObject:@"Adium"
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   259
					   forKey:(NSString *)kMDItemCreator];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   260
		
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   261
		[xmlDoc release];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   262
	}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   263
	else
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   264
		ret = NO;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   265
	
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   266
	return ret;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   267
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   268
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   269
NSString *killXMLTags(NSString *inString)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   270
{
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   271
    NSScanner *scan = [NSScanner scannerWithString:inString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   272
    NSString *tempString = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   273
    NSMutableString *ret = [NSMutableString string];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   274
    NSRange rng;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   275
    
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   276
    while(![scan isAtEnd]){
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   277
        tempString = nil;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   278
        [scan scanUpToString:@"<" intoString:&tempString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   279
        if(tempString != nil)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   280
            [ret appendFormat:@"%@ ", tempString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   281
        [scan scanString:@"<" intoString:nil];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   282
        [scan scanUpToString:@">" intoString:&tempString];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   283
        if([tempString hasPrefix:@"br"])
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   284
            [ret appendString:@"\n"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   285
        [scan scanString:@">" intoString:nil];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   286
    }
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   287
    rng.location = -1;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   288
    do {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   289
        NSRange searchRange = NSMakeRange(rng.location+1, [ret length]-rng.location-1);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   290
        rng = [ret rangeOfString:@"&lt;" options:0 range:searchRange];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   291
        if (rng.length > 0)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   292
            [ret replaceCharactersInRange: rng withString: @"<"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   293
    } while (rng.length > 0);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   294
    rng.location = -1;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   295
    do {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   296
        NSRange searchRange = NSMakeRange(rng.location+1, [ret length]-rng.location-1);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   297
        rng = [ret rangeOfString:@"&gt;" options:0 range:searchRange];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   298
        if (rng.length > 0)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   299
            [ret replaceCharactersInRange: rng withString: @">"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   300
    } while (rng.length > 0);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   301
    rng.location = -1;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   302
    do {
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   303
        NSRange searchRange = NSMakeRange(rng.location+1, [ret length]-rng.location-1);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   304
        rng = [ret rangeOfString:@"&amp;" options:0 range:searchRange];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   305
        if (rng.length > 0)
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   306
            [ret replaceCharactersInRange: rng withString: @"&"];
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   307
    } while (rng.length > 0);
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   308
    return ret;
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   309
}
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   310
3842
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   311
NSString *CopyTextContentForXMLLogData(NSData *data) {
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   312
    NSString *contentString = nil;
4878
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   313
	NSError *err;
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   314
    NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:data options:NSXMLNodePreserveCDATA error:&err];
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   315
	
3842
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   316
    if (xmlDoc) {
4878
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   317
		NSArray *children = [[xmlDoc rootElement] children];
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   318
		NSMutableArray *messages = [NSMutableArray array];
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   319
		
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   320
		for (NSXMLNode *child in children) {
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   321
			if ([child.name isEqualToString:@"message"]) {
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   322
				[messages addObject:child.stringValue];
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   323
			}
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   324
		}
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   325
		
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   326
		if (messages.count) contentString = [messages componentsJoinedByString:@" "];
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   327
		
3842
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   328
        [xmlDoc release];
4878
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   329
    } else {
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   330
#ifdef AILogWithSignature
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   331
		AILogWithSignature(@"Parsing log failed: %@", err);
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   332
#endif
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   333
	}
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   334
	
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   335
	[contentString retain];
bf3a2a2ee96e Make sure everything in GetMetadataForFile follows the copy-rule. Replace the XPath selector with a manual iteration over the children, probably faster.
Thijs Alkemade <thijsalkemade@gmail.com>
parents: 3842
diff changeset
   336
	
3842
c6a0c0da810e Pipeline reading from disk and file parsing. Save a few file IOs and allow for more efficient disk reads.
Stephen Holt <sholt@adium.im>
parents: 3813
diff changeset
   337
    return contentString;
0
e22ad6bc8b46 svn 1.5 merge tracking is terrible. This is a manual merge of the Sparkle 1.5 branch into trunk
David Smith
parents:
diff changeset
   338
}