PageRenderTime 25ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/core/externals/google-toolbox-for-mac/AppKit/GTMNSWorkspace+Running.h

http://macfuse.googlecode.com/
C++ Header | 99 lines | 32 code | 16 blank | 51 comment | 0 complexity | e8c83c19cb6d9bd8e3e00eac5479373f MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-2.0
  1. //
  2. // GTMNSWorkspace+Running.h
  3. //
  4. // Copyright 2007-2008 Google Inc.
  5. //
  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
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  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.
  17. //
  18. #import <AppKit/AppKit.h>
  19. #import "GTMDefines.h"
  20. // Process Dictionary keys
  21. //
  22. // NOTE: According to ProcessInformationCopyDictionary, the following may not be
  23. // in the dictionary depending on the type of process:
  24. // kGTMWorkspaceRunningParentPSN, kGTMWorkspaceRunningFileType,
  25. // kGTMWorkspaceRunningFileCreator, kGTMWorkspaceRunningPID,
  26. // kGTMWorkspaceRunningBundlePath, kGTMWorkspaceRunningBundleIdentifier,
  27. // kGTMWorkspaceRunningBundleName, kGTMWorkspaceRunningBundleExecutable,
  28. // And experience says the follow might also not be there:
  29. // kGTMWorkspaceRunningIsHidden
  30. // Make sure to use numberToProcessSerialNumber: on the return values
  31. // of these keys to get valid PSNs on both Leopard and Tiger.
  32. // Numeric types come back as a NSNumber.
  33. GTM_EXTERN NSString *const kGTMWorkspaceRunningPSN; // long long
  34. GTM_EXTERN NSString *const kGTMWorkspaceRunningParentPSN; // long long
  35. GTM_EXTERN NSString *const kGTMWorkspaceRunningFlavor; // SInt32
  36. GTM_EXTERN NSString *const kGTMWorkspaceRunningAttributes; // SInt32
  37. GTM_EXTERN NSString *const kGTMWorkspaceRunningFileType; // NSString
  38. GTM_EXTERN NSString *const kGTMWorkspaceRunningFileCreator; // NSString
  39. GTM_EXTERN NSString *const kGTMWorkspaceRunningPID; // long
  40. GTM_EXTERN NSString *const kGTMWorkspaceRunningLSBackgroundOnly; // bool
  41. GTM_EXTERN NSString *const kGTMWorkspaceRunningLSUIElement; // bool
  42. GTM_EXTERN NSString *const kGTMWorkspaceRunningIsHidden; // bool
  43. GTM_EXTERN NSString *const kGTMWorkspaceRunningCheckedIn; // bool
  44. GTM_EXTERN NSString *const kGTMWorkspaceRunningLSUIPresentationMode; // Short
  45. GTM_EXTERN NSString *const kGTMWorkspaceRunningBundlePath; // NSString
  46. GTM_EXTERN NSString *const kGTMWorkspaceRunningBundleVersion; // NSString
  47. // The docs for ProcessInformationCopyDictionary say we should use the constants
  48. // instead of the raw string values, so map our values to those keys.
  49. #define kGTMWorkspaceRunningBundleIdentifier (NSString*)kCFBundleIdentifierKey // NSString
  50. #define kGTMWorkspaceRunningBundleName (NSString*)kCFBundleNameKey // NSString
  51. #define kGTMWorkspaceRunningBundleExecutable (NSString*)kCFBundleExecutableKey // NSString
  52. // A category for getting information about other running processes
  53. @interface NSWorkspace (GTMWorkspaceRunningAdditions)
  54. // Returns a YES/NO if a process w/ the given identifier is running
  55. - (BOOL)gtm_isAppWithIdentifierRunning:(NSString *)identifier;
  56. // Returns a dictionary with info for our process.
  57. //See Process Dictionary Keys above for values
  58. - (NSDictionary *)gtm_processInfoDictionary;
  59. // Returns a dictionary with info for the active process.
  60. // See Process Dictionary Keys above for values
  61. - (NSDictionary *)gtm_processInfoDictionaryForActiveApp;
  62. // Returns a dictionary with info for the process.
  63. //See Process Dictionary Keys above for values
  64. - (NSDictionary *)gtm_processInfoDictionaryForPID:(pid_t)pid;
  65. // Returns a dictionary with info for the process.
  66. // See Process Dictionary Keys above for values
  67. - (NSDictionary *)gtm_processInfoDictionaryForPSN:(const ProcessSerialNumberPtr)psn;
  68. // Returns true if we were launched as a login item.
  69. - (BOOL)gtm_wasLaunchedAsLoginItem;
  70. // Returns true if we were launched by a given bundleid
  71. - (BOOL)gtm_wasLaunchedByProcess:(NSString*)bundleid;
  72. // Returns true if the PSN was found for the running app with bundleID
  73. - (BOOL)gtm_processSerialNumber:(ProcessSerialNumber*)outPSN
  74. withBundleID:(NSString*)bundleID;
  75. // Converts PSNs stored in NSNumbers to real PSNs
  76. - (ProcessSerialNumber)gtm_numberToProcessSerialNumber:(NSNumber*)number;
  77. // Returns a dictionary of launched applications like
  78. // -[NSWorkspace launchedApplications], but does it much faster than the current
  79. // version in Leopard which appears to regenerate the dictionary from scratch
  80. // each time you request it.
  81. // NB The main runloop has to run for this to stay up to date.
  82. - (NSArray *)gtm_launchedApplications;
  83. @end