PageRenderTime 20ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

C++ Header | 99 lines | 32 code | 16 blank | 51 comment | 0 complexity | e8c83c19cb6d9bd8e3e00eac5479373f MD5 | raw file
 2//  GTMNSWorkspace+Running.h
 4//  Copyright 2007-2008 Google Inc.
 6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
 7//  use this file except in compliance with the License.  You may obtain a copy
 8//  of the License at
12//  Unless required by applicable law or agreed to in writing, software
13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
15//  License for the specific language governing permissions and limitations under
16//  the License.
19#import <AppKit/AppKit.h>
20#import "GTMDefines.h"
22// Process Dictionary keys
24// NOTE: According to ProcessInformationCopyDictionary, the following may not be
25// in the dictionary depending on the type of process:
26//   kGTMWorkspaceRunningParentPSN, kGTMWorkspaceRunningFileType,
27//   kGTMWorkspaceRunningFileCreator, kGTMWorkspaceRunningPID,
28//   kGTMWorkspaceRunningBundlePath, kGTMWorkspaceRunningBundleIdentifier,
29//   kGTMWorkspaceRunningBundleName, kGTMWorkspaceRunningBundleExecutable,
30// And experience says the follow might also not be there:
31//   kGTMWorkspaceRunningIsHidden
33// Make sure to use numberToProcessSerialNumber: on the return values
34// of these keys to get valid PSNs on both Leopard and Tiger.
35// Numeric types come back as a NSNumber.
36GTM_EXTERN NSString *const kGTMWorkspaceRunningPSN;  // long long
37GTM_EXTERN NSString *const kGTMWorkspaceRunningParentPSN;  // long long
39GTM_EXTERN NSString *const kGTMWorkspaceRunningFlavor;  // SInt32
40GTM_EXTERN NSString *const kGTMWorkspaceRunningAttributes;  // SInt32
41GTM_EXTERN NSString *const kGTMWorkspaceRunningFileType;  // NSString
42GTM_EXTERN NSString *const kGTMWorkspaceRunningFileCreator;  // NSString
43GTM_EXTERN NSString *const kGTMWorkspaceRunningPID;  // long
44GTM_EXTERN NSString *const kGTMWorkspaceRunningLSBackgroundOnly;  // bool
45GTM_EXTERN NSString *const kGTMWorkspaceRunningLSUIElement;  // bool
46GTM_EXTERN NSString *const kGTMWorkspaceRunningIsHidden;  // bool
47GTM_EXTERN NSString *const kGTMWorkspaceRunningCheckedIn;  // bool
48GTM_EXTERN NSString *const kGTMWorkspaceRunningLSUIPresentationMode;  // Short
49GTM_EXTERN NSString *const kGTMWorkspaceRunningBundlePath;  // NSString
50GTM_EXTERN NSString *const kGTMWorkspaceRunningBundleVersion;  // NSString
51// The docs for ProcessInformationCopyDictionary say we should use the constants
52// instead of the raw string values, so map our values to those keys.
53#define kGTMWorkspaceRunningBundleIdentifier  (NSString*)kCFBundleIdentifierKey // NSString
54#define kGTMWorkspaceRunningBundleName        (NSString*)kCFBundleNameKey // NSString
55#define kGTMWorkspaceRunningBundleExecutable  (NSString*)kCFBundleExecutableKey // NSString
57// A category for getting information about other running processes
58@interface NSWorkspace (GTMWorkspaceRunningAdditions)
60// Returns a YES/NO if a process w/ the given identifier is running
61- (BOOL)gtm_isAppWithIdentifierRunning:(NSString *)identifier;
63// Returns a dictionary with info for our process. 
64//See Process Dictionary Keys above for values
65- (NSDictionary *)gtm_processInfoDictionary;
67// Returns a dictionary with info for the active process. 
68// See Process Dictionary Keys above for values
69- (NSDictionary *)gtm_processInfoDictionaryForActiveApp;
71// Returns a dictionary with info for the process. 
72//See Process Dictionary Keys above for values
73- (NSDictionary *)gtm_processInfoDictionaryForPID:(pid_t)pid;
75// Returns a dictionary with info for the process. 
76// See Process Dictionary Keys above for values
77- (NSDictionary *)gtm_processInfoDictionaryForPSN:(const ProcessSerialNumberPtr)psn;
79// Returns true if we were launched as a login item.
80- (BOOL)gtm_wasLaunchedAsLoginItem;
82// Returns true if we were launched by a given bundleid
83- (BOOL)gtm_wasLaunchedByProcess:(NSString*)bundleid;
85// Returns true if the PSN was found for the running app with bundleID
86- (BOOL)gtm_processSerialNumber:(ProcessSerialNumber*)outPSN 
87                   withBundleID:(NSString*)bundleID;
89// Converts PSNs stored in NSNumbers to real PSNs
90- (ProcessSerialNumber)gtm_numberToProcessSerialNumber:(NSNumber*)number;
92// Returns a dictionary of launched applications like
93// -[NSWorkspace launchedApplications], but does it much faster than the current
94// version in Leopard which appears to regenerate the dictionary from scratch
95// each time you request it. 
96// NB The main runloop has to run for this to stay up to date.
97- (NSArray *)gtm_launchedApplications;