Changeset 2575

Show
Ignore:
Timestamp:
04/30/05 02:56:17 (4 years ago)
Author:
timothy
Message:

Tweaks to the Tiger Metadata Importer (Spotlight).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Colloquy.xcode/project.pbxproj

    r2572 r2575  
    24502450                                1CF4D76607E6AD4400DB421A, 
    24512451                                0A5B683F0810EC9700398D5A, 
    2452                                 CBF685370820190D00F498FB, 
    2453                                 CBF685380820190D00F498FB, 
    2454                                 CBF6853A0820190D00F498FB, 
    2455                                 CBF6853C0820190D00F498FB, 
    24562452                        ); 
    24572453                        isa = PBXResourcesBuildPhase; 
     
    29372933                                1CE3C4F807E13F4C004931E6, 
    29382934                                1C70377F07E49F25005CEA40, 
    2939                                 CBF685390820190D00F498FB, 
    2940                                 CBF6853B0820190D00F498FB, 
    29412935                        ); 
    29422936                        isa = PBXSourcesBuildPhase; 
     
    51575151                CBF684F00820174000F498FB = { 
    51585152                        children = ( 
     5153                                CBF685320820190D00F498FB, 
     5154                                CBF685340820190D00F498FB, 
    51595155                                CBF6852C0820190D00F498FB, 
     5156                                CBF685330820190D00F498FB, 
    51605157                                CBF685310820190D00F498FB, 
    5161                                 CBF685320820190D00F498FB, 
    5162                                 CBF685330820190D00F498FB, 
    5163                                 CBF685340820190D00F498FB, 
    51645158                        ); 
    51655159                        isa = PBXGroup; 
    5166                         name = Importer
     5160                        name = "Metadata Importer"
    51675161                        refType = 4; 
    51685162                        sourceTree = "<group>"; 
     
    52255219                        ); 
    52265220                        isa = PBXNativeTarget; 
    5227                         name = Colloquy
     5221                        name = "Colloquy (Metadata Importer)"
    52285222                        productName = Importer; 
    52295223                        productReference = CBF685150820186F00F498FB; 
     
    53435337                        refType = 4; 
    53445338                        sourceTree = "<group>"; 
    5345                 }; 
    5346                 CBF685370820190D00F498FB = { 
    5347                         fileRef = CBF6852D0820190D00F498FB; 
    5348                         isa = PBXBuildFile; 
    5349                         settings = { 
    5350                         }; 
    5351                 }; 
    5352                 CBF685380820190D00F498FB = { 
    5353                         fileRef = CBF6852F0820190D00F498FB; 
    5354                         isa = PBXBuildFile; 
    5355                         settings = { 
    5356                         }; 
    5357                 }; 
    5358                 CBF685390820190D00F498FB = { 
    5359                         fileRef = CBF685310820190D00F498FB; 
    5360                         isa = PBXBuildFile; 
    5361                         settings = { 
    5362                         }; 
    5363                 }; 
    5364                 CBF6853A0820190D00F498FB = { 
    5365                         fileRef = CBF685320820190D00F498FB; 
    5366                         isa = PBXBuildFile; 
    5367                         settings = { 
    5368                         }; 
    5369                 }; 
    5370                 CBF6853B0820190D00F498FB = { 
    5371                         fileRef = CBF685330820190D00F498FB; 
    5372                         isa = PBXBuildFile; 
    5373                         settings = { 
    5374                         }; 
    5375                 }; 
    5376                 CBF6853C0820190D00F498FB = { 
    5377                         fileRef = CBF685340820190D00F498FB; 
    5378                         isa = PBXBuildFile; 
    5379                         settings = { 
    5380                         }; 
    53815339                }; 
    53825340                CBF6855D08201B7300F498FB = { 
  • trunk/Importer/English.lproj/InfoPlist.strings

    r2574 r2575  
    11/* Localized versions of Info.plist keys */ 
    22 
    3 CFBundleName = "Colloquy"; 
    4 CFBundleShortVersionString = "1.0"; 
    5 CFBundleGetInfoString = "ColloquyImporter version 1.0, Copyright (c) 2005 Karl Adam."; 
    6 NSHumanReadableCopyright = "Copyright (c) 2005 Karl Adam."; 
     3CFBundleGetInfoString = "Colloquy Metadata Importer 1.0; Copyright � 2005, Karl Adam"; 
     4NSHumanReadableCopyright = "Copyright � 2005, Karl Adam"; 
  • trunk/Importer/English.lproj/schema.strings

    r2572 r2575  
    1         /* Localized DisplayNames for your custom metadata attributes */ 
    2         /* The form is:  "myMetadataKey" = "My Metadata Key";    */ 
    3         /* The name on the left is the name defined in schema.xml */ 
    4         /* The name on the right is what the user will see */ 
    51com_internet_messaging_Service = "Service"; 
    6          
    7         /* Localized Description of you custom metadata attributes */ 
    8         /* The form is: "myMetadataKey.Description" = "stuff"; 
    9         /* com_Foo_YourAttrName should be definded in the schema.xml file  */ 
    10         /* The value on the right will be displayed by the Finder etc.. */ 
    112com_internet_messaging_Service.Description = "The network protocol over which this transcript was recorded"; 
  • trunk/Importer/GetMetadataForFile.c

    r2573 r2575  
    33#include <Foundation/Foundation.h> 
    44 
    5 /* ----------------------------------------------------------------------------- 
    6    Step 1 
    7    Set the UTI types the importer supports 
    8    
    9    Modify the CFBundleDocumentTypes entry in Info.plist to contain 
    10    an array of Uniform Type Identifiers (UTI) for the LSItemContentTypes  
    11    that your importer can handle 
    12    
    13    ----------------------------------------------------------------------------- */ 
     5Boolean GetMetadataForFile( void *thisInterface, CFMutableDictionaryRef attributes, CFStringRef contentTypeUTI, CFStringRef pathToFile ) { 
     6        NSMutableDictionary *returnDict = (NSMutableDictionary *) attributes; 
     7        NSURL *file = [NSURL fileURLWithPath:(NSString *) pathToFile]; 
    148 
    15 /* ----------------------------------------------------------------------------- 
    16    Step 2  
    17    Implement the GetMetadataForFile function 
    18    
    19    Implement the GetMetadataForFile function below to scrape the relevant 
    20    metadata from your document and return it as a CFDictionary using standard keys 
    21    (defined in MDItem.h) whenever possible. 
    22    ----------------------------------------------------------------------------- */ 
     9        NSError *error = nil; 
     10    NSXMLDocument *transcript = [[[NSXMLDocument alloc] initWithContentsOfURL:file options:NSXMLDocumentTidyXML error:&error] autorelease]; 
    2311 
    24 /* ----------------------------------------------------------------------------- 
    25    Step 3 (optional)  
    26    If you have defined new attributes, update the schema.xml file 
    27    
    28    Edit the schema.xml file to include the metadata keys that your importer returns. 
    29    Add them to the <allattrs> and <displayattrs> elements. 
    30    
    31    Add any custom types that your importer requires to the <attributes> element 
    32    
    33    <attribute name="com_mycompany_metadatakey" type="CFString" multivalued="true"/> 
    34    
    35    ----------------------------------------------------------------------------- */ 
     12        // Get date started 
     13        NSArray *dateArray = [transcript nodesForXPath:@"/log[1]/@began" error:&error]; 
     14    NSDate *dateStarted = [NSDate dateWithString:[[dateArray objectAtIndex:0] stringValue]]; 
     15        [returnDict setObject:dateStarted forKey:(NSString *) kMDItemContentCreationDate]; 
    3616 
    37  
    38  
    39 /* ----------------------------------------------------------------------------- 
    40     Get metadata attributes from file 
    41     
    42    This function's job is to extract useful information your file format supports 
    43    and return it as a dictionary 
    44    ----------------------------------------------------------------------------- */ 
    45  
    46 Boolean GetMetadataForFile(void* thisInterface,  
    47                            CFMutableDictionaryRef attributes,  
    48                            CFStringRef contentTypeUTI, 
    49                            CFStringRef pathToFile) { 
    50     /* Pull any available metadata from the file at the specified path */ 
    51     /* Return the attribute keys and attribute values in the dict */ 
    52     /* Return TRUE if successful, FALSE if there was no data provided */ 
    53         NSMutableDictionary *returnDict = (NSMutableDictionary *)attributes; 
    54         NSError *error; 
    55         NSMutableArray *participants = [[NSMutableArray alloc] init]; 
    56     NSXMLDocument *transcriptDOM = [[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:(NSString *)pathToFile]  
    57                                                                                                                                                 options:NSXMLDocumentTidyXML 
    58                                                                                                                                                   error:&error]; 
    59          
    60         // Get date started 
    61         NSArray *dateArray = [transcriptDOM nodesForXPath:@"/log[1]/@began" error:&error]; 
    62     NSDate *dateStarted = [NSDate dateWithString:[[dateArray objectAtIndex:0] stringValue]]; 
    63         [returnDict setObject:dateStarted forKey:(NSString *)kMDItemContentCreationDate]; 
    64          
    6517        // Get date of last message 
    66         NSArray *xpathResult = [transcriptDOM nodesForXPath:@"/log[1]/envelope[last()]/message[last()]/@received" error:&error]; 
     18        NSArray *xpathResult = [transcript nodesForXPath:@"/log[1]/envelope[last()]/message[last()]/@received" error:&error]; 
    6719        NSDate *lastMessageDate = [NSDate dateWithString:[[xpathResult objectAtIndex:0] stringValue]]; 
    6820        NSTimeInterval logDuration = [lastMessageDate timeIntervalSinceDate:dateStarted]; 
    69          
     21 
    7022        // Set Duration 
    71         [returnDict setObject:[NSNumber numberWithInt:logDuration] forKey:(NSString *)kMDItemDurationSeconds]; 
    72          
     23        [returnDict setObject:[NSNumber numberWithInt:logDuration] forKey:(NSString *) kMDItemDurationSeconds]; 
     24 
    7325        // Get WhereFroms 
    74         xpathResult = [transcriptDOM nodesForXPath:@"/log[1]@source" error:&error]; 
     26        xpathResult = [transcript nodesForXPath:@"/log[1]@source" error:&error]; 
    7527        NSString *fromURL = nil; 
    76         if ( [xpathResult count] ) { 
     28        if( [xpathResult count] ) { 
    7729                fromURL = [[xpathResult objectAtIndex:0] stringValue]; 
    78                 [returnDict setObject:fromURL forKey:(NSString *)kMDItemWhereFroms]; 
     30                [returnDict setObject:fromURL forKey:(NSString *) kMDItemWhereFroms]; 
    7931        } 
    80          
     32 
    8133        // Set Title and Coverage 
    8234        NSDateFormatter *formatter = [[NSDateFormatter alloc] initWithDateFormat:@"%A, the %d of %B at %I:%M" allowNaturalLanguage:NO]; 
    8335        NSString *coverageWording = nil; 
    84          
     36 
    8537        // Set Coverage 
    86         if ( fromURL ) { 
     38        if( fromURL ) { 
    8739                coverageWording = [NSString stringWithFormat:@"Conversation from %@ to %@ in %@", [formatter stringFromDate:dateStarted], 
    8840                                                                                                                                                                                        [formatter stringFromDate:lastMessageDate], 
    89                                                                                                                                                                                        fromURL]; 
     41                                                                                                                                                                                fromURL]; 
    9042        } else { 
    9143                coverageWording = [NSString stringWithFormat:@"Conversation from %@ to %@", [formatter stringFromDate:dateStarted], 
    9244                                                                                                                                                                        [formatter stringFromDate:lastMessageDate]]; 
    9345        } 
    94         [returnDict setObject:coverageWording forKey:(NSString *)kMDItemCoverage]; 
    95         [returnDict setObject:coverageWording forKey:(NSString *)kMDItemTitle]; 
    96          
     46 
     47        [returnDict setObject:coverageWording forKey:(NSString *) kMDItemCoverage]; 
     48        [returnDict setObject:coverageWording forKey:(NSString *) kMDItemTitle]; 
     49 
    9750        // Get Participants 
    98         NSArray *participantsArray = [transcriptDOM nodesForXPath:@"/log[1]/envelope/sender" error:&error]; 
    99         NSEnumerator *pEnum = [participantsArray objectEnumerator]; 
    100         NSXMLNode *participantName = nil
    101          
    102         while ( participantName = [pEnum nextObject] ) { 
    103                NSString *userNick = [participantName stringValue]; 
    104                  
    105                 if ( ! [participants containsObject:userNick] ) 
    106                         [participants addObject:[participantName stringValue]]; 
     51        NSMutableArray *participants = [NSMutableArray array]; 
     52        NSArray *participantNodes = [transcript nodesForXPath:@"/log[1]/envelope/sender" error:&error]; 
     53        NSEnumerator *enumerator = [participantNodes objectEnumerator]
     54        NSXMLNode *participantNode = nil; 
     55 
     56        while( ( participantNode = [enumerator nextObject] ) ) { 
     57                NSString *nickname = [participantNode stringValue]; 
     58                if( ! [participants containsObject:nickname] ) 
     59                        [participants addObject:nickname]; 
    10760        } 
    108         [returnDict setObject:participants forKey:(NSString *)kMDItemContributors]; 
    109          
     61 
     62        [returnDict setObject:participants forKey:(NSString *) kMDItemContributors]; 
     63 
    11064        // Now the stuff that doesn't change 
    111         [returnDict setObject:[NSArray arrayWithObject:@"Colloquy"] forKey:(NSString *)kMDItemEncodingApplications]; 
    112          
     65        [returnDict setObject:[NSArray arrayWithObject:@"Colloquy"] forKey:(NSString *) kMDItemCreator]; 
    11366 
    11467    return TRUE; 
  • trunk/Importer/Info.plist

    r2572 r2575  
    33<plist version="1.0"> 
    44<dict> 
    5  
    6         <!-- 
    7         If your application does not already define a UTI, you may want to declare it 
    8         here, so that your documents are recognized by systems which do not have your 
    9         application installed. 
    10  
    11         To export this declaration, fill in the fields with your application's  
    12         information, and uncomment the block of XML. 
    13         --> 
    14          
    15         <!-- 
    16         <key>UTExportedTypeDeclarations</key> 
    17         <array> 
    18                 <dict> 
    19                         <key>UTTypeIdentifier</key> 
    20                         <string>cc.javelin.colloquy.colloquytranscript</string> 
    21                         <key>UTTypeReferenceURL</key> 
    22                         <string>http://www.colloquy.info/</string> 
    23                         <key>UTTypeDescription</key> 
    24                         <string>Your Document Kind String</string> 
    25                         <key>UTTypeConformsTo</key> 
    26                         <array> 
    27                                 <string>public.data</string> 
    28                                 <string>public.content</string> 
    29                         </array> 
    30                         <key>UTTypeTagSpecification</key> 
    31                         <dict> 
    32                                 <key>public.filename-extension</key> 
    33                                 <array> 
    34                                         <string>colloquyTranscript</string> 
    35                                 </array> 
    36                         </dict> 
    37                 </dict> 
    38         </array> 
    39         --> 
    40  
    415        <key>CFBundleDevelopmentRegion</key> 
    426        <string>English</string> 
     
    5216                </dict> 
    5317        </array> 
     18        <key>CFBundleName</key> 
     19        <string>Colloquy Metadata Importer</string> 
    5420        <key>CFBundleExecutable</key> 
    5521        <string>Colloquy</string> 
  • trunk/Importer/main.c

    r2572 r2575  
    1 // 
    2 //  main.c 
    3 //  ColloquyImporter 
    4 // 
    5 //  Created by Karl Adam on 4/27/05. 
    6 //  Copyright (c) 2005 __MyCompanyName__. All rights reserved. 
    7 // 
    8  
    9  
    10  
    11  
    12  
    13 //============================================================================== 
    14 // 
    15 //      DO NO MODIFY THE CONTENT OF THIS FILE 
    16 // 
    17 //      This file contains the generic CFPlug-in code necessary for your importer 
    18 //      To complete your importer implement the function in GetMetadataForFile.c 
    19 // 
    20 //============================================================================== 
    21  
    22  
    23  
    24  
    25  
    26  
    271#include <CoreFoundation/CoreFoundation.h> 
    282#include <CoreFoundation/CFPlugInCOM.h> 
    293#include <CoreServices/CoreServices.h> 
    304 
    31 // ----------------------------------------------------------------------------- 
    32 //      constants 
    33 // ----------------------------------------------------------------------------- 
    34  
    35  
    365#define PLUGIN_ID "04A856E0-880E-41BA-ABFA-35F147710AFC" 
    37  
    38 // 
    39 // Below is the generic glue code for all plug-ins. 
    40 // 
    41 // You should not have to modify this code aside from changing 
    42 // names if you decide to change the names defined in the Info.plist 
    43 // 
    44  
    45  
    46 // ----------------------------------------------------------------------------- 
    47 //      typedefs 
    48 // ----------------------------------------------------------------------------- 
    496 
    507// The import function to be implemented in GetMetadataForFile.c 
     
    5714typedef struct __MetadataImporterPluginType 
    5815{ 
    59     MDImporterInterfaceStruct *conduitInterface; 
    60     CFUUIDRef                 factoryID; 
    61     UInt32                    refCount; 
     16       MDImporterInterfaceStruct *conduitInterface; 
     17       CFUUIDRef                 factoryID; 
     18       UInt32                    refCount; 
    6219} MetadataImporterPluginType; 
    6320 
    64 // ----------------------------------------------------------------------------- 
    65 //      prototypes 
    66 // ----------------------------------------------------------------------------- 
    67 //      Forward declaration for the IUnknown implementation. 
    68 // 
    6921 
    7022MetadataImporterPluginType  *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID); 
     
    7426ULONG                     MetadataImporterPluginAddRef(void *thisInstance); 
    7527ULONG                     MetadataImporterPluginRelease(void *thisInstance); 
    76 // ----------------------------------------------------------------------------- 
    77 //      testInterfaceFtbl       definition 
    78 // ----------------------------------------------------------------------------- 
    79 //      The TestInterface function table. 
    80 // 
    8128 
    8229static MDImporterInterfaceStruct testInterfaceFtbl = { 
    83     NULL, 
    84     MetadataImporterQueryInterface, 
    85     MetadataImporterPluginAddRef, 
    86     MetadataImporterPluginRelease, 
    87     GetMetadataForFile 
     30       NULL, 
     31       MetadataImporterQueryInterface, 
     32       MetadataImporterPluginAddRef, 
     33       MetadataImporterPluginRelease, 
     34       GetMetadataForFile 
    8835}; 
    8936 
    90  
    91 // ----------------------------------------------------------------------------- 
    92 //      AllocMetadataImporterPluginType 
    93 // ----------------------------------------------------------------------------- 
    94 //      Utility function that allocates a new instance. 
    95 //      You can do some initial setup for the importer here if you wish 
    96 //      like allocating globals etc... 
    97 // 
    9837MetadataImporterPluginType *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID) 
    9938{ 
    100     MetadataImporterPluginType *theNewInstance; 
     39       MetadataImporterPluginType *theNewInstance; 
    10140 
    102     theNewInstance = (MetadataImporterPluginType *)malloc(sizeof(MetadataImporterPluginType)); 
    103     memset(theNewInstance,0,sizeof(MetadataImporterPluginType)); 
     41       theNewInstance = (MetadataImporterPluginType *)malloc(sizeof(MetadataImporterPluginType)); 
     42       memset(theNewInstance,0,sizeof(MetadataImporterPluginType)); 
    10443 
    105         /* Point to the function table */ 
    106     theNewInstance->conduitInterface = &testInterfaceFtbl; 
     44               /* Point to the function table */ 
     45       theNewInstance->conduitInterface = &testInterfaceFtbl; 
    10746 
    108         /*  Retain and keep an open instance refcount for each factory. */ 
    109     theNewInstance->factoryID = CFRetain(inFactoryID); 
    110     CFPlugInAddInstanceForFactory(inFactoryID); 
     47               /*  Retain and keep an open instance refcount for each factory. */ 
     48       theNewInstance->factoryID = CFRetain(inFactoryID); 
     49       CFPlugInAddInstanceForFactory(inFactoryID); 
    11150 
    112         /* This function returns the IUnknown interface so set the refCount to one. */ 
    113     theNewInstance->refCount = 1; 
    114     return theNewInstance; 
     51               /* This function returns the IUnknown interface so set the refCount to one. */ 
     52       theNewInstance->refCount = 1; 
     53       return theNewInstance; 
    11554} 
    11655 
    117 // ----------------------------------------------------------------------------- 
    118 //      DeallocColloquyImporterMDImporterPluginType 
    119 // ----------------------------------------------------------------------------- 
    120 //      Utility function that deallocates the instance when 
    121 //      the refCount goes to zero. 
    122 //      In the current implementation importer interfaces are never deallocated 
    123 //      but implement this as this might change in the future 
    124 // 
    12556void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance) 
    12657{ 
    127     CFUUIDRef theFactoryID; 
     58       CFUUIDRef theFactoryID; 
    12859 
    129     theFactoryID = thisInstance->factoryID; 
    130     free(thisInstance); 
    131     if (theFactoryID){ 
    132         CFPlugInRemoveInstanceForFactory(theFactoryID); 
    133         CFRelease(theFactoryID); 
    134    
     60       theFactoryID = thisInstance->factoryID; 
     61       free(thisInstance); 
     62       if (theFactoryID){ 
     63               CFPlugInRemoveInstanceForFactory(theFactoryID); 
     64               CFRelease(theFactoryID); 
     65       
    13566} 
    13667 
    137 // ----------------------------------------------------------------------------- 
    138 //      MetadataImporterQueryInterface 
    139 // ----------------------------------------------------------------------------- 
    140 //      Implementation of the IUnknown QueryInterface function. 
    141 // 
    14268HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) 
    14369{ 
    144     CFUUIDRef interfaceID; 
     70       CFUUIDRef interfaceID; 
    14571 
    146     interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); 
     72       interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); 
    14773 
    148     if (CFEqual(interfaceID,kMDImporterInterfaceID)){ 
    149             /* If the Right interface was requested, bump the ref count, 
    150             * set the ppv parameter equal to the instance, and 
    151             * return good status. 
    152             */ 
    153         ((MetadataImporterPluginType*)thisInstance)->conduitInterface->AddRef(thisInstance); 
    154         *ppv = thisInstance; 
    155         CFRelease(interfaceID); 
    156         return S_OK; 
    157     }else{ 
    158         if (CFEqual(interfaceID,IUnknownUUID)){ 
    159                 /* If the IUnknown interface was requested, same as above. */ 
    160             ((MetadataImporterPluginType*)thisInstance )->conduitInterface->AddRef(thisInstance); 
    161             *ppv = thisInstance; 
    162             CFRelease(interfaceID); 
    163             return S_OK; 
    164         }else{ 
    165                 /* Requested interface unknown, bail with error. */ 
    166             *ppv = NULL; 
    167             CFRelease(interfaceID); 
    168             return E_NOINTERFACE; 
    169        
    170    
     74       if (CFEqual(interfaceID,kMDImporterInterfaceID)){ 
     75                       /* If the Right interface was requested, bump the ref count, 
     76                        * set the ppv parameter equal to the instance, and 
     77                        * return good status. 
     78                        */ 
     79               ((MetadataImporterPluginType*)thisInstance)->conduitInterface->AddRef(thisInstance); 
     80               *ppv = thisInstance; 
     81               CFRelease(interfaceID); 
     82               return S_OK; 
     83       }else{ 
     84               if (CFEqual(interfaceID,IUnknownUUID)){ 
     85                               /* If the IUnknown interface was requested, same as above. */ 
     86                       ((MetadataImporterPluginType*)thisInstance )->conduitInterface->AddRef(thisInstance); 
     87                       *ppv = thisInstance; 
     88                       CFRelease(interfaceID); 
     89                       return S_OK; 
     90               }else{ 
     91                               /* Requested interface unknown, bail with error. */ 
     92                       *ppv = NULL; 
     93                       CFRelease(interfaceID); 
     94                       return E_NOINTERFACE; 
     95               
     96       
    17197} 
    17298 
    173 // ----------------------------------------------------------------------------- 
    174 //      MetadataImporterPluginAddRef 
    175 // ----------------------------------------------------------------------------- 
    176 //      Implementation of reference counting for this type. Whenever an interface 
    177 //      is requested, bump the refCount for the instance. NOTE: returning the 
    178 //      refcount is a convention but is not required so don't rely on it. 
    179 // 
    18099ULONG MetadataImporterPluginAddRef(void *thisInstance) 
    181100{ 
    182     ((MetadataImporterPluginType *)thisInstance )->refCount += 1; 
    183     return ((MetadataImporterPluginType*) thisInstance)->refCount; 
     101       ((MetadataImporterPluginType *)thisInstance )->refCount += 1; 
     102       return ((MetadataImporterPluginType*) thisInstance)->refCount; 
    184103} 
    185104 
    186 // ----------------------------------------------------------------------------- 
    187 // SampleCMPluginRelease 
    188 // ----------------------------------------------------------------------------- 
    189 //      When an interface is released, decrement the refCount. 
    190 //      If the refCount goes to zero, deallocate the instance. 
    191 // 
    192105ULONG MetadataImporterPluginRelease(void *thisInstance) 
    193106{ 
    194     ((MetadataImporterPluginType*)thisInstance)->refCount -= 1; 
    195     if (((MetadataImporterPluginType*)thisInstance)->refCount == 0){ 
    196         DeallocMetadataImporterPluginType((MetadataImporterPluginType*)thisInstance ); 
    197         return 0; 
    198     }else{ 
    199         return ((MetadataImporterPluginType*) thisInstance )->refCount; 
    200    
     107       ((MetadataImporterPluginType*)thisInstance)->refCount -= 1; 
     108       if (((MetadataImporterPluginType*)thisInstance)->refCount == 0){ 
     109               DeallocMetadataImporterPluginType((MetadataImporterPluginType*)thisInstance ); 
     110               return 0; 
     111       }else{ 
     112               return ((MetadataImporterPluginType*) thisInstance )->refCount; 
     113       
    201114} 
    202115 
    203 // ----------------------------------------------------------------------------- 
    204 //      ColloquyImporterMDImporterPluginFactory 
    205 // ----------------------------------------------------------------------------- 
    206 //      Implementation of the factory function for this type. 
    207 // 
    208116void *MetadataImporterPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID) 
    209117{ 
    210     MetadataImporterPluginType *result; 
    211     CFUUIDRef                 uuid; 
     118       MetadataImporterPluginType *result; 
     119       CFUUIDRef                 uuid; 
    212120 
    213         /* If correct type is being requested, allocate an 
    214         * instance of TestType and return the IUnknown interface. 
    215         */ 
    216     if (CFEqual(typeID,kMDImporterTypeID)){ 
    217         uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); 
    218         result = AllocMetadataImporterPluginType(uuid); 
    219         CFRelease(uuid); 
    220         return result; 
    221    
    222         /* If the requested type is incorrect, return NULL. */ 
    223     return NULL; 
     121               /* If correct type is being requested, allocate an 
     122                * instance of TestType and return the IUnknown interface. 
     123                */ 
     124       if (CFEqual(typeID,kMDImporterTypeID)){ 
     125               uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); 
     126               result = AllocMetadataImporterPluginType(uuid); 
     127               CFRelease(uuid); 
     128               return result; 
     129       
     130               /* If the requested type is incorrect, return NULL. */ 
     131       return NULL; 
    224132} 
    225  
  • trunk/Importer/schema.xml

    r2572 r2575  
    11<?xml version="1.0" encoding="UTF-8"?> 
    2   
    3 <schema version="1.0" xmlns="http://www.apple.com/metadata" 
    4                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    5                       xsi:schemaLocation="http://www.apple.com/metadata file:///System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Resources/MetadataSchema.xsd"> 
    6     <note> 
    7         Custom attributes that this metadata importer supports.  Below 
     2<schema version="1.0" xmlns="http://www.apple.com/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.apple.com/metadata file:///System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Resources/MetadataSchema.xsd"> 
     3        <note> 
     4        Custom attributes that this metadata importer supports.  Below 
    85        is an example of a multivalued string attribute.  Other types 
    96        are CFNumber, CFDate, CFBoolean and CFData.                    
    10     </note> 
    11     <attributes> 
    12         <attribute name="com_internet_messaging_Service" multivalued="true" type="CFString"/> 
    13     </attributes> 
     7        </note> 
    148 
    15     <types> 
    16         <type name="cc.javelin.colloquy.colloquytranscript"> 
    17             <note> 
    18                 The keys that this metadata importer handles. 
    19             </note> 
    20             <allattrs> 
     9        <attributes> 
     10                <attribute name="com_internet_messaging_Service" multivalued="true" type="CFString"/> 
     11        </attributes> 
     12 
     13        <types> 
     14                <type name="cc.javelin.colloquy.colloquytranscript"> 
     15                        <note>The keys that this metadata importer handles.</note> 
     16                        <allattrs> 
    2117                        kMDItemTitle 
    2218                        kMDItemContributors 
     
    2420                        kMDItemDurationSeconds 
    2521                        kMDItemWhereFroms 
    26                         kMDItemEncodingApplications 
     22                        kMDItemCreator 
    2723                        com_internet_messaging_Service 
    28             </allattrs> 
    29             <displayattrs> 
     24                       </allattrs> 
     25                       <displayattrs> 
    3026                        kMDItemTitle 
    3127                        kMDItemContributors 
     
    3329                        kMDItemDurationSeconds 
    3430                        kMDItemWhereFroms 
    35                         kMDItemEncodingApplications 
     31                        kMDItemCreator 
    3632                        com_internet_messaging_Service 
    37             </displayattrs> 
    38         </type> 
    39     </types> 
     33                       </displayattrs> 
     34               </type> 
     35       </types> 
    4036</schema> 
    41