1*ac937ea6SAndrew Rist/************************************************************** 2cdf0e10cSrcweir * 3*ac937ea6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ac937ea6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ac937ea6SAndrew Rist * distributed with this work for additional information 6*ac937ea6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ac937ea6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ac937ea6SAndrew Rist * "License"); you may not use this file except in compliance 9*ac937ea6SAndrew Rist * with the License. You may obtain a copy of the License at 10*ac937ea6SAndrew Rist * 11*ac937ea6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ac937ea6SAndrew Rist * 13*ac937ea6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ac937ea6SAndrew Rist * software distributed under the License is distributed on an 15*ac937ea6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ac937ea6SAndrew Rist * KIND, either express or implied. See the License for the 17*ac937ea6SAndrew Rist * specific language governing permissions and limitations 18*ac937ea6SAndrew Rist * under the License. 19*ac937ea6SAndrew Rist * 20*ac937ea6SAndrew Rist *************************************************************/ 21*ac937ea6SAndrew Rist 22*ac937ea6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir#include <CoreFoundation/CoreFoundation.h> 25cdf0e10cSrcweir#include <CoreServices/CoreServices.h> 26cdf0e10cSrcweir#include <Foundation/Foundation.h> 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29cdf0e10cSrcweir#import "OOoSpotlightImporter.h" 30cdf0e10cSrcweir 31cdf0e10cSrcweir 32cdf0e10cSrcweir/* ----------------------------------------------------------------------------- 33cdf0e10cSrcweir Get metadata attributes from file 34cdf0e10cSrcweir 35cdf0e10cSrcweir This function's job is to extract useful information your file format supports 36cdf0e10cSrcweir and return it as a dictionary 37cdf0e10cSrcweir ----------------------------------------------------------------------------- */ 38cdf0e10cSrcweir 39cdf0e10cSrcweirBoolean GetMetadataForFile(void* thisInterface, 40cdf0e10cSrcweir CFMutableDictionaryRef attributes, 41cdf0e10cSrcweir CFStringRef contentTypeUTI, 42cdf0e10cSrcweir CFStringRef pathToFile) 43cdf0e10cSrcweir{ 44cdf0e10cSrcweir /* Pull any available metadata from the file at the specified path */ 45cdf0e10cSrcweir /* Return the attribute keys and attribute values in the dict */ 46cdf0e10cSrcweir /* Return TRUE if successful, FALSE if there was no data provided */ 47cdf0e10cSrcweir NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 48cdf0e10cSrcweir 49cdf0e10cSrcweir OOoSpotlightImporter *importer = [OOoSpotlightImporter new]; 50cdf0e10cSrcweir 51cdf0e10cSrcweir Boolean importOK = NO; 52cdf0e10cSrcweir @try { 53cdf0e10cSrcweir importOK = [importer importDocument:(NSString*)pathToFile 54cdf0e10cSrcweir contentType:(NSString*)contentTypeUTI 55cdf0e10cSrcweir attributes:(NSMutableDictionary*)attributes]; 56cdf0e10cSrcweir } 57cdf0e10cSrcweir @catch (NSException *exception) { 58cdf0e10cSrcweir NSLog(@"main: Caught %@: %@", [exception name], [exception reason]); 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir [importer release]; 62cdf0e10cSrcweir 63cdf0e10cSrcweir [pool release]; 64cdf0e10cSrcweir 65cdf0e10cSrcweir return importOK; 66cdf0e10cSrcweir} 67