diff options
author | thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-02-26 01:38:00 +0000 |
---|---|---|
committer | thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-02-26 01:38:00 +0000 |
commit | 037f9b9e4216078b9a7b667c25c8b825bea23219 (patch) | |
tree | b407e1491769875da80292de54f5cda1c91b8c51 /AppKit | |
parent | 4c2218dc038a6cca3c972a153e3f73c5730fc876 (diff) |
some updates for keys that aren't always there
Diffstat (limited to 'AppKit')
-rw-r--r-- | AppKit/GTMNSWorkspace+Running.h | 16 | ||||
-rw-r--r-- | AppKit/GTMNSWorkspace+Running.m | 3 | ||||
-rw-r--r-- | AppKit/GTMNSWorkspace+RunningTest.m | 14 |
3 files changed, 20 insertions, 13 deletions
diff --git a/AppKit/GTMNSWorkspace+Running.h b/AppKit/GTMNSWorkspace+Running.h index 7e9dc6d..d45b321 100644 --- a/AppKit/GTMNSWorkspace+Running.h +++ b/AppKit/GTMNSWorkspace+Running.h @@ -20,6 +20,14 @@ #import "GTMDefines.h" // Process Dictionary keys +// +// NOTE: According to ProcessInformationCopyDictionary, the following may not be +// in the dictionary depending on the type of process: +// kGTMWorkspaceRunningParentPSN, kGTMWorkspaceRunningFileType, +// kGTMWorkspaceRunningFileCreator, kGTMWorkspaceRunningPID, +// kGTMWorkspaceRunningBundlePath, kGTMWorkspaceRunningBundleIdentifier, +// kGTMWorkspaceRunningBundleName, kGTMWorkspaceRunningBundleExecutable, + // Make sure to use numberToProcessSerialNumber: on the return values // of these keys to get valid PSNs on both Leopard and Tiger. // Numeric types come back as a NSNumber. @@ -37,10 +45,12 @@ GTM_EXTERN NSString *const kGTMWorkspaceRunningIsHidden; // bool GTM_EXTERN NSString *const kGTMWorkspaceRunningCheckedIn; // bool GTM_EXTERN NSString *const kGTMWorkspaceRunningLSUIPresentationMode; // Short GTM_EXTERN NSString *const kGTMWorkspaceRunningBundlePath; // NSString -GTM_EXTERN NSString *const kGTMWorkspaceRunningBundleExecutable; // NSString -GTM_EXTERN NSString *const kGTMWorkspaceRunningBundleName; // NSString -GTM_EXTERN NSString *const kGTMWorkspaceRunningBundleIdentifier; // NSString GTM_EXTERN NSString *const kGTMWorkspaceRunningBundleVersion; // NSString +// The docs for ProcessInformationCopyDictionary say we should use the constants +// instead of the raw string values, so map our values to those keys. +#define kGTMWorkspaceRunningBundleIdentifier (NSString*)kCFBundleIdentifierKey // NSString +#define kGTMWorkspaceRunningBundleName (NSString*)kCFBundleNameKey // NSString +#define kGTMWorkspaceRunningBundleExecutable (NSString*)kCFBundleExecutableKey // NSString // A category for getting information about other running processes @interface NSWorkspace (GTMWorkspaceRunningAdditions) diff --git a/AppKit/GTMNSWorkspace+Running.m b/AppKit/GTMNSWorkspace+Running.m index a031043..3c31e6b 100644 --- a/AppKit/GTMNSWorkspace+Running.m +++ b/AppKit/GTMNSWorkspace+Running.m @@ -36,9 +36,6 @@ NSString *const kGTMWorkspaceRunningCheckedIn = @"IsCheckedInAttr"; NSString *const kGTMWorkspaceRunningLSUIPresentationMode = @"LSUIPresentationMode"; NSString *const kGTMWorkspaceRunningBundlePath = @"BundlePath"; -NSString *const kGTMWorkspaceRunningBundleExecutable = @"CFBundleExecutable"; -NSString *const kGTMWorkspaceRunningBundleName = @"CFBundleName"; -NSString *const kGTMWorkspaceRunningBundleIdentifier = @"CFBundleIdentifier"; NSString *const kGTMWorkspaceRunningBundleVersion = @"CFBundleVersion"; @implementation NSWorkspace (GTMWorkspaceRunningAdditions) diff --git a/AppKit/GTMNSWorkspace+RunningTest.m b/AppKit/GTMNSWorkspace+RunningTest.m index abd20a6..6e8ff33 100644 --- a/AppKit/GTMNSWorkspace+RunningTest.m +++ b/AppKit/GTMNSWorkspace+RunningTest.m @@ -57,16 +57,16 @@ processInfo = [ws gtm_processInfoDictionaryForActiveApp]; STAssertNotNil(processInfo, nil); + // Only check the keys that have to be there NSString *const keys[] = { - kGTMWorkspaceRunningPSN, kGTMWorkspaceRunningParentPSN, + kGTMWorkspaceRunningPSN, kGTMWorkspaceRunningFlavor, kGTMWorkspaceRunningAttributes, - kGTMWorkspaceRunningFileType, kGTMWorkspaceRunningFileCreator, - kGTMWorkspaceRunningPID, kGTMWorkspaceRunningLSBackgroundOnly, + kGTMWorkspaceRunningLSBackgroundOnly, kGTMWorkspaceRunningLSUIElement, kGTMWorkspaceRunningIsHidden, - kGTMWorkspaceRunningCheckedIn, kGTMWorkspaceRunningBundleIdentifier, - kGTMWorkspaceRunningBundleVersion, kGTMWorkspaceRunningBundleName, - kGTMWorkspaceRunningLSUIPresentationMode, kGTMWorkspaceRunningBundlePath, - kGTMWorkspaceRunningBundleExecutable + kGTMWorkspaceRunningCheckedIn, + kGTMWorkspaceRunningBundleVersion, + kGTMWorkspaceRunningLSUIPresentationMode, + }; for (size_t i = 0; i < sizeof(keys) / sizeof(NSString *); ++i) { NSString *const key = keys[i]; |