More filter stuff added

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@17058 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2003-06-28 06:46:14 +00:00
parent baeae6ea50
commit 17d4b32bba
8 changed files with 276 additions and 184 deletions

View file

@ -1,3 +1,11 @@
2003-06-28 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/make_services.m: Alter format of filter info.
* Tools/example.m: Added an example filter.
* Tools/md5Digest.m: Example filter user.
* Source/GSServicesManager.m: tweak for filters.
* Source/NSPasteboard.m: more documentation
2003-06-27 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSPasteboard.m: Documented all methods, fixed minor bugs

View file

@ -1330,18 +1330,23 @@ GSPerformService(NSString *serviceItem, NSPasteboard *pboard, BOOL isFilter)
if (isFilter == YES)
{
service = [[manager filters] objectForKey: serviceItem];
if (service == nil)
{
NSLog(@"No service matching '%@'", serviceItem);
return NO; /* No matching service. */
}
}
else
{
service = [[manager menuServices] objectForKey: serviceItem];
}
if (service == nil)
{
NSRunAlertPanel(nil,
@"No service matching '%@'",
@"Continue", nil, nil,
serviceItem);
return NO; /* No matching service. */
if (service == nil)
{
NSRunAlertPanel(nil,
@"No service matching '%@'",
@"Continue", nil, nil,
serviceItem);
return NO; /* No matching service. */
}
}
port = [service objectForKey: @"NSPortName"];
@ -1358,6 +1363,10 @@ GSPerformService(NSString *serviceItem, NSPasteboard *pboard, BOOL isFilter)
appPath = [service objectForKey: @"ServicePath"];
userData = [service objectForKey: @"NSUserData"];
message = [service objectForKey: @"NSMessage"];
if (isFilter == YES && [message length] == 0)
{
message = [service objectForKey: @"NSFilter"];
}
selName = [message stringByAppendingString: @":userData:error:"];
/*
@ -1367,10 +1376,17 @@ GSPerformService(NSString *serviceItem, NSPasteboard *pboard, BOOL isFilter)
provider = GSContactApplication(appPath, port, finishBy);
if (provider == nil)
{
NSRunAlertPanel(nil,
@"Failed to contact service provider for '%@'",
@"Continue", nil, nil,
serviceItem);
if (isFilter == YES)
{
NSLog(@"Failed to contact service provider for '%@'", serviceItem);
}
else
{
NSRunAlertPanel(nil,
@"Failed to contact service provider for '%@'",
@"Continue", nil, nil,
serviceItem);
}
return NO;
}
@ -1406,10 +1422,18 @@ GSPerformService(NSString *serviceItem, NSPasteboard *pboard, BOOL isFilter)
if (error != nil)
{
NSRunAlertPanel(nil,
@"Failed to contact service provider for '%@': %@",
@"Continue", nil, nil,
serviceItem, error);
if (isFilter == YES)
{
NSLog(@"Failed to contact service provider for '%@': %@",
serviceItem, error);
}
else
{
NSRunAlertPanel(nil,
@"Failed to contact service provider for '%@': %@",
@"Continue", nil, nil,
serviceItem, error);
}
return NO;
}

View file

@ -971,7 +971,10 @@ static NSMapTable *mimeMap = NULL;
* pasteboard server using the -setData:forType: method.
* </p>
* <p>Data written using this method can be read by -propertyListForType:
* or, of it was a simple string, by -stringForType:
* or, if it was a simple string, by -stringForType:
* </p>
* <p>If the data is retrieved using -dataForType: then it needs to be
* deserialized into a property list.
* </p>
*/
- (BOOL) setPropertyList: (id)propertyList
@ -989,6 +992,9 @@ static NSMapTable *mimeMap = NULL;
* <p>The data may subsequently be read from the reciver using the
* -stringForType: or -propertyListForType: method.
* </p>
* <p>If the data is retrieved using -dataForType: then it needs to be
* deserialized into a property list.
* </p>
*/
- (BOOL) setString: (NSString*)string
forType: (NSString*)dataType
@ -1006,6 +1012,9 @@ static NSMapTable *mimeMap = NULL;
* <p>Data written to a pasteboard by this method should be read using
* the -readFileContentsType:toFile: or -readFileWrapper method.
* </p>
* <p>If the data is retrieved using -dataForType: then it needs to be
* deserialized by the NSFileWrapper class.
* </p>
*/
- (BOOL) writeFileContents: (NSString*)filename
{
@ -1062,6 +1071,9 @@ static NSMapTable *mimeMap = NULL;
* <p>Data written to a pasteboard by this method should be read using
* the -readFileContentsType:toFile: or -readFileWrapper method.
* </p>
* <p>If the data is retrieved using -dataForType: then it needs to be
* deserialized by the NSFileWrapper class.
* </p>
*/
- (BOOL) writeFileWrapper: (NSFileWrapper *)wrapper
{

View file

@ -29,10 +29,13 @@ include ../config.make
include ../Version
SUBPROJECTS = $(BUILD_GSND)
APP_NAME = md5Digest
TOOL_NAME = make_services set_show_service gopen
SERVICE_NAME = example GSspell
# The source files to be compiled
md5Digest_OBJC_FILES = md5Digest.m
gopen_OBJC_FILES = gopen.m
make_services_OBJC_FILES = make_services.m
@ -49,6 +52,7 @@ include GNUmakefile.preamble
GNUSTEP_MAKE_SERVICES=./$(GNUSTEP_OBJ_DIR)/make_services
include $(GNUSTEP_MAKEFILES)/application.make
include $(GNUSTEP_MAKEFILES)/tool.make
include $(GNUSTEP_MAKEFILES)/service.make
include $(GNUSTEP_MAKEFILES)/aggregate.make

View file

@ -1,7 +1,7 @@
NSServices = (
{
NSPortName = ExampleServices;
NSFilter = "md5";
NSFilter = md5;
NSSendTypes = (
NSStringPboardType
);

View file

@ -38,8 +38,7 @@
int
main(int argc, char** argv, char **env_c)
{
NSAutoreleasePool *pool;
NSArray *arguments = nil;
CREATE_AUTORELEASE_POOL(pool);
NSEnumerator *argEnumerator = nil;
NSWorkspace *workspace = nil;
NSFileManager *fm = nil;
@ -56,14 +55,15 @@ main(int argc, char** argv, char **env_c)
#ifdef GS_PASS_ARGUMENTS
[NSProcessInfo initializeWithArguments:argv count:argc environment:env_c];
#endif
pool = [NSAutoreleasePool new];
argEnumerator = [[[NSProcessInfo processInfo] arguments] objectEnumerator];
workspace = [NSWorkspace sharedWorkspace];
fm = [NSFileManager defaultManager];
// Default applications for opening unregistered file types....
editor = [[NSUserDefaults standardUserDefaults] stringForKey: @"GSDefaultEditor"];
terminal = [[NSUserDefaults standardUserDefaults] stringForKey: @"GSDefaultTerminal"];
editor = [[NSUserDefaults standardUserDefaults]
stringForKey: @"GSDefaultEditor"];
terminal = [[NSUserDefaults standardUserDefaults]
stringForKey: @"GSDefaultTerminal"];
// Process options...
application = [[NSUserDefaults standardUserDefaults] stringForKey: @"a"];
@ -71,32 +71,34 @@ main(int argc, char** argv, char **env_c)
filetoprint = [[NSUserDefaults standardUserDefaults] stringForKey: @"p"];
nxhost = [[NSUserDefaults standardUserDefaults] stringForKey: @"NXHost"];
if(application)
if (application)
{
[workspace launchApplication: application];
}
if(filetoopen)
if (filetoopen)
{
[workspace openFile: filetoopen];
}
if(filetoprint)
if (filetoprint)
{
puts("Not implemented");
}
if(nxhost)
if (nxhost)
{
puts("Not implemented");
}
if(argc == 1)
if (argc == 1)
{
NSFileHandle *fh = [NSFileHandle fileHandleWithStandardInput];
NSData *data = [fh readDataToEndOfFile];
NSString *tempFile = [NSTemporaryDirectory() stringByAppendingPathComponent: @"openfiletmp"];
NSNumber *processId = [NSNumber numberWithInt: [[NSProcessInfo processInfo] processIdentifier]];
NSString *tempFile = [NSTemporaryDirectory()
stringByAppendingPathComponent: @"openfiletmp"];
NSNumber *processId = [NSNumber numberWithInt:
[[NSProcessInfo processInfo] processIdentifier]];
tempFile = [tempFile stringByAppendingString: [processId stringValue]];
tempFile = [tempFile stringByAppendingString: @".txt"];
@ -105,27 +107,26 @@ main(int argc, char** argv, char **env_c)
}
[argEnumerator nextObject]; // skip the first element, which is empty.
while((arg = [argEnumerator nextObject]) != nil)
while ((arg = [argEnumerator nextObject]) != nil)
{
NSString *ext = [arg pathExtension];
NSString *appName = nil;
if( [arg isEqualToString: @"-a"] )
if ([arg isEqualToString: @"-a"])
{
// skip since this is handled above...
arg = [argEnumerator nextObject];
}
else if( [arg isEqualToString: @"-o"] )
else if ([arg isEqualToString: @"-o"])
{
// skip since this is handled above...
arg = [argEnumerator nextObject];
}
else if( [arg isEqualToString: @"-p"] )
else if ([arg isEqualToString: @"-p"])
{
// skip since this is handled above...
arg = [argEnumerator nextObject];
}
else if( [arg isEqualToString: @"-NXHost"] )
else if ([arg isEqualToString: @"-NXHost"])
{
// skip since this is handled above...
arg = [argEnumerator nextObject];
@ -133,54 +134,59 @@ main(int argc, char** argv, char **env_c)
else // no option specified
{
NS_DURING
BOOL isDir = NO, exists = NO;
{
BOOL isDir = NO, exists = NO;
exists = [fm fileExistsAtPath: arg isDirectory: &isDir];
if( exists && !isDir && [fm isExecutableFileAtPath: arg] )
{
[workspace openFile: arg withApplication: terminal];
}
else // no argument specified
{
// First check to see if it's an application
if( [ext isEqualToString: @"app"] ||
[ext isEqualToString: @"debug"] ||
[ext isEqualToString: @"profile"] )
{
NSString *appName =
[[arg lastPathComponent] stringByDeletingPathExtension];
NSString *executable =
[arg stringByAppendingPathComponent: appName];
NSTask *task = nil;
if([fm fileExistsAtPath: arg])
{
if ([NSTask launchedTaskWithLaunchPath: executable
arguments: nil] == nil)
{
NSLog(@"Unable to launch: %@",arg);
}
}
else
{
[workspace launchApplication: arg];
}
}
else
if( ![workspace openFile: arg] )
exists = [fm fileExistsAtPath: arg isDirectory: &isDir];
if (exists && !isDir && [fm isExecutableFileAtPath: arg])
{
[workspace openFile: arg withApplication: terminal];
}
else // no argument specified
{
// First check to see if it's an application
if ([ext isEqualToString: @"app"] ||
[ext isEqualToString: @"debug"] ||
[ext isEqualToString: @"profile"])
{
// no recognized extension,
// run application indicated by environment var.
NSLog(@"Opening %@ with %@",arg,editor);
[workspace openFile: arg withApplication: editor];
NSString *appName =
[[arg lastPathComponent] stringByDeletingPathExtension];
NSString *executable =
[arg stringByAppendingPathComponent: appName];
if ([fm fileExistsAtPath: arg])
{
if ([NSTask launchedTaskWithLaunchPath: executable
arguments: nil] == nil)
{
NSLog(@"Unable to launch: %@",arg);
}
}
else
{
[workspace launchApplication: arg];
}
}
}
NS_HANDLER
else
{
if (![workspace openFile: arg])
{
// no recognized extension,
// run application indicated by environment var.
NSLog(@"Opening %@ with %@",arg,editor);
[workspace openFile: arg withApplication: editor];
}
}
}
}
NS_HANDLER
{
NSLog(@"Exception while attempting open file %@ - %@: %@",
arg, [localException name], [localException reason]);
NS_ENDHANDLER
}
}
NS_ENDHANDLER
}
}
[pool release];
RELEASE(pool);
exit(EXIT_SUCCESS);
}

View file

@ -86,7 +86,7 @@ main(int argc, char** argv, char **env_c)
proc = [NSProcessInfo processInfo];
if (proc == nil)
{
NSLog(@"unable to get process information!\n");
NSLog(@"unable to get process information!");
[pool release];
exit(EXIT_SUCCESS);
}
@ -141,12 +141,12 @@ main(int argc, char** argv, char **env_c)
}
else
{
NSLog(@"bad info - %@\n", file);
NSLog(@"bad info - %@", file);
}
}
else
{
NSLog(@"bad info - %@\n", file);
NSLog(@"bad info - %@", file);
}
}
exit(EXIT_SUCCESS);
@ -196,7 +196,7 @@ main(int argc, char** argv, char **env_c)
{
if ([mgr createDirectoryAtPath: usrRoot attributes: nil] == NO)
{
NSLog(@"couldn't create %@\n", usrRoot);
NSLog(@"couldn't create %@", usrRoot);
[pool release];
exit(EXIT_FAILURE);
}
@ -209,7 +209,7 @@ main(int argc, char** argv, char **env_c)
{
if ([mgr createDirectoryAtPath: usrRoot attributes: nil] == NO)
{
NSLog(@"couldn't create %@\n", usrRoot);
NSLog(@"couldn't create %@", usrRoot);
[pool release];
exit(EXIT_FAILURE);
}
@ -306,7 +306,7 @@ main(int argc, char** argv, char **env_c)
data = [NSSerializer serializePropertyList: fullMap];
if ([data writeToFile: str atomically: YES] == NO)
{
NSLog(@"couldn't write %@\n", str);
NSLog(@"couldn't write %@", str);
[pool release];
exit(EXIT_FAILURE);
}
@ -329,7 +329,7 @@ main(int argc, char** argv, char **env_c)
data = [NSSerializer serializePropertyList: applicationMap];
if ([data writeToFile: str atomically: YES] == NO)
{
NSLog(@"couldn't write %@\n", str);
NSLog(@"couldn't write %@", str);
[pool release];
exit(EXIT_FAILURE);
}
@ -358,7 +358,7 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
{
if ([o0 isKindOfClass: aClass] == NO)
{
NSLog(@"bad app NSTypes (not an array) - %@\n", app);
NSLog(@"bad app NSTypes (not an array) - %@", app);
return;
}
a0 = (NSArray*)o0;
@ -372,7 +372,7 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
if ([o1 isKindOfClass: dClass] == NO)
{
NSLog(@"bad app NSTypes (type not a dictionary) - %@\n", app);
NSLog(@"bad app NSTypes (type not a dictionary) - %@", app);
return;
}
/*
@ -386,7 +386,7 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
}
if ([o1 isKindOfClass: aClass] == NO)
{
NSLog(@"bad app NSType (extensions not an array) - %@\n", app);
NSLog(@"bad app NSType (extensions not an array) - %@", app);
return;
}
a1 = (NSArray*)o1;
@ -399,7 +399,7 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
e = [[a1 objectAtIndex: j] lowercaseString];
if ([e length] == 0)
{
NSLog(@"Illegal (nul) extension ignored for - %@\n", app);
NSLog(@"Illegal (nul) extension ignored for - %@", app);
return;
}
d = [extensionsMap objectForKey: e];
@ -426,7 +426,7 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
}
if ([o0 isKindOfClass: dClass] == NO)
{
NSLog(@"bad app NSExtensions (not a dictionary) - %@\n", app);
NSLog(@"bad app NSExtensions (not a dictionary) - %@", app);
return;
}
extensions = (NSDictionary *) o0;
@ -440,7 +440,8 @@ static void addExtensionsForApplication(NSDictionary *info, NSString *app)
if ([tmp isKindOfClass: dClass] == NO)
{
NSLog(@"bad app NSExtensions (value isn't a dictionary) - %@\n", app);
NSLog(@"bad app NSExtensions (value isn't a dictionary) - %@",
app);
continue;
}
name = [[a0 objectAtIndex: i] lowercaseString];
@ -496,7 +497,7 @@ scanDirectory(NSMutableDictionary *services, NSString *path)
* this name, we skip this one - the first one takes
* precedence.
*/
NSLog(@"duplicate app (%@) at '%@' and '%@'\n",
NSLog(@"duplicate app (%@) at '%@' and '%@'",
name, oldPath, newPath);
continue;
}
@ -526,12 +527,12 @@ scanDirectory(NSMutableDictionary *services, NSString *path)
}
else
{
NSLog(@"bad app info - %@\n", newPath);
NSLog(@"bad app info - %@", newPath);
}
}
else
{
NSLog(@"bad application - %@\n", newPath);
NSLog(@"bad application - %@", newPath);
}
}
else if (ext != nil && [ext isEqualToString: @"service"])
@ -560,17 +561,17 @@ scanDirectory(NSMutableDictionary *services, NSString *path)
}
else
{
NSLog(@"missing info - %@\n", newPath);
NSLog(@"missing info - %@", newPath);
}
}
else
{
NSLog(@"bad service info - %@\n", newPath);
NSLog(@"bad service info - %@", newPath);
}
}
else
{
NSLog(@"bad services bundle - %@\n", newPath);
NSLog(@"bad services bundle - %@", newPath);
}
}
else
@ -631,7 +632,7 @@ scanDynamic(NSMutableDictionary *services, NSString *path)
}
else
{
NSLog(@"bad app info - %@\n", infPath);
NSLog(@"bad app info - %@", infPath);
}
}
[arp release];
@ -646,7 +647,7 @@ validateEntry(id svcs, NSString *path)
if ([svcs isKindOfClass: aClass] == NO)
{
NSLog(@"NSServices entry not an array - %@\n", path);
NSLog(@"NSServices entry not an array - %@", path);
return nil;
}
@ -670,7 +671,7 @@ validateEntry(id svcs, NSString *path)
}
else
{
NSLog(@"NSServices entry %u not a dictionary - %@\n",
NSLog(@"NSServices entry %u not a dictionary - %@",
pos, path);
}
}
@ -722,7 +723,7 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
if (type == nil)
{
NSLog(@"NSServices entry %u spurious field (%@)- %@\n", pos, k, path);
NSLog(@"NSServices entry %u spurious field (%@)- %@", pos, k, path);
}
else
{
@ -732,7 +733,7 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
if ([obj isKindOfClass: sClass] == NO)
{
NSLog(@"NSServices entry %u field %@ is not a string "
@"- %@\n", pos, k, path);
@"- %@", pos, k, path);
return nil;
}
[result setObject: obj forKey: k];
@ -744,14 +745,14 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
if ([obj isKindOfClass: aClass] == NO)
{
NSLog(@"NSServices entry %u field %@ is not an array "
@"- %@\n", pos, k, path);
@"- %@", pos, k, path);
return nil;
}
a = (NSArray*)obj;
if ([a count] == 0)
{
NSLog(@"NSServices entry %u field %@ is an empty array "
@"- %@\n", pos, k, path);
@"- %@", pos, k, path);
}
else
{
@ -762,7 +763,7 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
if ([[a objectAtIndex: i] isKindOfClass: sClass] == NO)
{
NSLog(@"NSServices entry %u field %@ element %u is "
@"not a string - %@\n", pos, k, i, path);
@"not a string - %@", pos, k, i, path);
return nil;
}
}
@ -776,14 +777,14 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
if ([obj isKindOfClass: dClass] == NO)
{
NSLog(@"NSServices entry %u field %@ is not a dictionary "
@"- %@\n", pos, k, path);
@"- %@", pos, k, path);
return nil;
}
d = (NSDictionary*)obj;
if ([d objectForKey: @"default"] == nil)
{
NSLog(@"NSServices entry %u field %@ has no default value "
@"- %@\n", pos, k, path);
@"- %@", pos, k, path);
}
else
{
@ -794,7 +795,7 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
if ([obj isKindOfClass: sClass] == NO)
{
NSLog(@"NSServices entry %u field %@ contains "
@"non-string value - %@\n", pos, k, path);
@"non-string value - %@", pos, k, path);
return nil;
}
}
@ -812,7 +813,53 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
/*
* Now check that we have the required fields for the service.
*/
if ((obj = [result objectForKey: @"NSMessage"]) != nil)
if ((obj = [result objectForKey: @"NSFilter"]) != nil)
{
NSDictionary *inf;
NSString *str;
NSArray *snd;
NSArray *ret;
str = [result objectForKey: @"NSInputMechanism"];
if (str)
{
if ([str isEqualToString: @"NSUnixStdio"] == NO
&& [str isEqualToString: @"NSMapFile"] == NO
&& [str isEqualToString: @"NSIdentity"] == NO)
{
NSLog(@"NSServices entry %u bad input mechanism - %@", pos, path);
return nil;
}
}
else
{
if ([result objectForKey: @"NSPortName"] == nil)
{
NSLog(@"NSServices entry %u NSPortName missing - %@", pos, path);
return nil;
}
}
snd = [result objectForKey: @"NSSendTypes"];
ret = [result objectForKey: @"NSReturnTypes"];
if (snd == nil || ret == nil)
{
NSLog(@"NSServices entry %u types missing - %@", pos, path);
return nil;
}
inf = [filterMap objectForKey: obj];
if (inf != nil)
{
if (verbose)
{
NSLog(@"Ignoring duplicate %u in %@ -\n%@", pos, path, result);
}
return nil;
}
[filterMap setObject: result forKey: obj];
}
else if ((obj = [result objectForKey: @"NSMessage"]) != nil)
{
NSDictionary *item;
NSEnumerator *e;
@ -821,18 +868,18 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
if ([result objectForKey: @"NSPortName"] == nil)
{
NSLog(@"NSServices entry %u NSPortName missing - %@\n", pos, path);
NSLog(@"NSServices entry %u NSPortName missing - %@", pos, path);
return nil;
}
if ([result objectForKey: @"NSSendTypes"] == nil &&
[result objectForKey: @"NSReturnTypes"] == nil)
{
NSLog(@"NSServices entry %u types missing - %@\n", pos, path);
NSLog(@"NSServices entry %u types missing - %@", pos, path);
return nil;
}
if ((item = [result objectForKey: @"NSMenuItem"]) == nil)
{
NSLog(@"NSServices entry %u NSMenuItem missing - %@\n", pos, path);
NSLog(@"NSServices entry %u NSMenuItem missing - %@", pos, path);
return nil;
}
@ -862,76 +909,11 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
{
if (verbose)
{
NSLog(@"Ignoring entry %u in %@ -\n%@\n", pos, path, result);
NSLog(@"Ignoring entry %u in %@ -\n%@", pos, path, result);
}
return nil; /* Ignore - already got service with this name */
}
}
else if ((obj = [result objectForKey: @"NSFilter"]) != nil)
{
NSString *str;
NSArray *snd;
NSArray *ret;
unsigned spos;
BOOL used = NO;
str = [result objectForKey: @"NSInputMechanism"];
if (str)
{
if ([str isEqualToString: @"NSUnixStdio"] == NO &&
[str isEqualToString: @"NSMapFile"] == NO &&
[str isEqualToString: @"NSIdentity"] == NO)
{
NSLog(@"NSServices entry %u bad input mechanism - %@\n", pos, path);
return nil;
}
}
snd = [result objectForKey: @"NSSendTypes"];
ret = [result objectForKey: @"NSReturnTypes"];
if (snd == nil || ret == nil)
{
NSLog(@"NSServices entry %u types missing - %@\n", pos, path);
return nil;
}
/*
* For each send-type/return-type combination, see if we
* already have a filter - if so - ignore this one.
*/
spos = [snd count];
while (spos-- > 0)
{
NSString *stype = [snd objectAtIndex: spos];
NSMutableDictionary *sdict = [filterMap objectForKey: stype];
unsigned rpos;
if (sdict == nil)
{
sdict = [NSMutableDictionary dictionaryWithCapacity: [snd count]];
[filterMap setObject: sdict forKey: stype];
}
rpos = [ret count];
while (rpos-- > 0)
{
NSString *rtype = [ret objectAtIndex: rpos];
if ([sdict objectForKey: rtype] == nil)
{
[sdict setObject: result forKey: rtype];
used = YES;
}
}
}
if (used == NO)
{
if (verbose)
{
NSLog(@"Ignoring entry %u in %@ -\n%@\n", pos, path, result);
}
return nil; /* Ignore - already got filter for types. */
}
}
else if ((obj = [result objectForKey: @"NSPrintFilter"]) != nil)
{
NSDictionary *item;
@ -941,7 +923,7 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
if ((item = [result objectForKey: @"NSMenuItem"]) == nil)
{
NSLog(@"NSServices entry %u NSMenuItem missing - %@\n", pos, path);
NSLog(@"NSServices entry %u NSMenuItem missing - %@", pos, path);
return nil;
}
/*
@ -970,7 +952,7 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
{
if (verbose)
{
NSLog(@"Ignoring entry %u in %@ -\n%@\n", pos, path, result);
NSLog(@"Ignoring entry %u in %@ -\n%@", pos, path, result);
}
return nil; /* Ignore - already got filter with this name */
}
@ -983,7 +965,7 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
if ((item = [result objectForKey: @"NSLanguages"]) == nil)
{
NSLog(@"NSServices entry %u NSLanguages missing - %@\n", pos, path);
NSLog(@"NSServices entry %u NSLanguages missing - %@", pos, path);
return nil;
}
/*
@ -1005,14 +987,14 @@ validateService(NSDictionary *service, NSString *path, unsigned pos)
{
if (verbose)
{
NSLog(@"Ignoring entry %u in %@ -\n%@\n", pos, path, result);
NSLog(@"Ignoring entry %u in %@ -\n%@", pos, path, result);
}
return nil; /* Ignore - already got speller with language. */
}
}
else
{
NSLog(@"NSServices entry %u unknown service/filter - %@\n", pos, path);
NSLog(@"NSServices entry %u unknown service/filter - %@", pos, path);
return nil;
}

56
Tools/md5Digest.m Normal file
View file

@ -0,0 +1,56 @@
/* This tool creates an md5 digest using the example filter
based on what type of file is being accessed.
Copyright (C) 2003 Free Software Foundation, Inc.
Written by: Rrichard Frith-Macdonald <rfm@gnu.org>
Created: June 2003
This file is part of the GNUstep Project
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
You should have received a copy of the GNU General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSData.h>
#include <Foundation/NSFileHandle.h>
#include <Foundation/NSProcessInfo.h>
#include <Foundation/NSString.h>
#include <AppKit/NSPasteboard.h>
int
main(int argc, char** argv, char **env_c)
{
CREATE_AUTORELEASE_POOL(pool);
NSFileHandle *fh;
NSData *data;
NSString *string;
NSPasteboard *pb;
#ifdef GS_PASS_ARGUMENTS
[NSProcessInfo initializeWithArguments:argv count:argc environment:env_c];
#endif
fh = [NSFileHandle fileHandleWithStandardInput];
data = [fh readDataToEndOfFile];
string = [[NSString alloc] initWithData: data
encoding: NSUTF8StringEncoding];
data = [NSSerializer serializePropertyList: string];
pb = [NSPasteboard pasteboardByFilteringData: data
ofType: NSStringPboardType];
NSLog(@"Types: %@", [pb types]);
data = [pb dataForType: @"md5Digest"];
NSLog(@"Got %@", data);
RELEASE(pool);
exit(EXIT_SUCCESS);
}