Main Page | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

DAApplication Class Reference

#import <DAApplication.h>

List of all members.


Detailed Description

Object representing a Mac OS X application.

DownAndOut[tm] cares about applications insofar as it can make them quit; in an orderly fashion if possible, by killing them if necessary.

Definition at line 31 of file DAApplication.h.

Public Member Functions

(id) - initWithName:
 Designated initializer: Given the name of an application, initialize a DAApplication.
(id) - initWithIndex:
 Given an index initialize a DAApplication with the index'th application.
(NSString *) - name
 Getter accessor for the application-name property.
(NSString *) - fileName
 The name of the application file (without any .app suffix).
(int) - processID
 The process serial number for the application instance.
(NSString *) - bundleID
 The bundle identifier of the application.
(BOOL) - isRunning
 Whether the application is running.
(void) - quitWithoutSaving
 Quit the application via AppleScript.
(BOOL) - kill:
 Send a BSD signal to the application.
(BOOL) - killObj:
 Object-parameter wrapper for kill:.
(void) - dealloc [implementation]
 Ordinary deallocator.
(NSString *) - description [implementation]
 Report self by class, address, and name.
(BOOL) - isEqualToString: [implementation]
 Equality of application name with a given string.
(NSDictionary *) - recordInApplicationList [implementation]
 Return the entry for this application in NSWorkspace's launchedApplications list.

Static Public Member Functions

(int) + countApplications
 How many applications the current user has running.
(NSMutableArray *) + launchedApplications
 An array of DAApplications representing all applications the current user is running.
(NSMutableArray *) + quitApplicationNames
 Singleton array of the names of all applications DownAndOut[tm] has quit.
(NSMutableArray *) + killedApplicationNames
 Singleton array of the names of all applications DownAndOut[tm] has killed.

Protected Attributes

NSString * name
 User name of this application.


Member Function Documentation

- (NSString *) bundleID  
 

The bundle identifier of the application.

The NSWorkspace -reported application list is consulted for the CFBundleIdentifier of the application bundle. This is a reverse-domain-style string that uniquely distinguishes the application from any other bundle.

Return values:
NSString the bundle identifier.

Definition at line 171 of file DAApplication.m.

References recordInApplicationList.

+ (int) countApplications  
 

How many applications the current user has running.

This is a count of the array returned by -[NSWorkspace launchedApplications].

Return values:
int the number of applications still running.

Definition at line 27 of file DAApplication.m.

Referenced by DownAndOutView::animateOneFrame.

- (NSString *) description   [implementation]
 

Report self by class, address, and name.

This method augments the standard description method by adding the only instance variable (name) to the information provided in the description.

Return values:
NSString A string in the form <DAApplication @addr, name=appName>.

Definition at line 101 of file DAApplication.m.

- (NSString *) fileName  
 

The name of the application file (without any .app suffix).

The NSWorkspace -reported application list is consulted for the file or package that launched this application. The last path component, with any .app suffix removed, is reported. This may be different from name, which may be the CFBundleName. This is the string AppleScript expects to see when naming an application.

Return values:
NSString the base name of the application bundle.

Definition at line 180 of file DAApplication.m.

References recordInApplicationList.

Referenced by quitWithoutSaving.

- (id) initWithIndex: (int)  index  
 

Given an index initialize a DAApplication with the index'th application.

The method takes index to be a zero-based index into the -[NSWorkspace launchedApplications] list, draws the application name from there, and hands off to initWithName:.

Parameters:
index int, the zero-based index of the desired application.
Return values:
self if index represents an application.
nil if index < 0 or index >= the count of applications.

Definition at line 74 of file DAApplication.m.

References initWithName:.

- (id) initWithName: (NSString *)  inName  
 

Designated initializer: Given the name of an application, initialize a DAApplication.

Parameters:
[in] inName the name of the application as reported by -[NSWorkspace launchedApplications]
Return values:
self 

Definition at line 68 of file DAApplication.m.

References name.

Referenced by initWithIndex:.

- (BOOL) isEqualToString: (NSString *)  aString   [implementation]
 

Equality of application name with a given string.

The method returns YES if the receiver's name is equal to the string parameter.

Parameters:
aString NSString, the string to compare to.
Return values:
BOOL whether aString is lexically the same as the name of the receiver.

Definition at line 110 of file DAApplication.m.

References name.

Referenced by recordInApplicationList.

- (BOOL) isRunning  
 

Whether the application is running.

This is determined by whether the application appears in the list of running applications reported by -[NSWorkspace launchedApplications].

Return values:
YES if the application is running.
NO if the application is not running.

Definition at line 157 of file DAApplication.m.

References recordInApplicationList.

- (BOOL) kill: (int)  signal  
 

Send a BSD signal to the application.

In DownAndOut[tm], this method is used to send signal 9 (SIGTERM) to processes that still run after quitWithoutSaving has been tried.

The name of the receiver is added to the killedApplicationNames list.

Parameters:
signal the signal to send, usually 9 (SIGTERM).
Return values:
YES if the call to kill(2) succeeded.
NO if the application was not running, or kill(2) returned an error.

Definition at line 195 of file DAApplication.m.

References killedApplicationNames, name, and processID.

Referenced by killObj:.

+ (NSMutableArray *) killedApplicationNames  
 

Singleton array of the names of all applications DownAndOut[tm] has killed.

See also:
- kill:

Definition at line 60 of file DAApplication.m.

Referenced by kill:.

- (BOOL) killObj: (id)  hasIntValue  
 

Object-parameter wrapper for kill:.

This version of kill: is provided so that kills can be enquued with makeObjectsPerformSelector:... . The parameter should respond to intValue. This method is equivalent to [self kill: [hasIntValue intValue]].

Parameters:
hasIntValue an object that should respond to intValue; typically [NSNumber numberWithInt: 9]
Return values:
YES if the underlying call to kill(2) succeeded.
NO if hasIntValue does not respond to intValue, or the underlying kill: message returns NO.

Definition at line 209 of file DAApplication.m.

References kill:.

+ (NSMutableArray *) launchedApplications  
 

An array of DAApplications representing all applications the current user is running.

The method starts with the application names returned by -[NSWorkspace launchedApplications], and allocates a DAApplication for each, accumulating them into the returned array.

Return values:
NSMutableArray the applications the user has running.

Definition at line 33 of file DAApplication.m.

- (NSString *) name  
 

Getter accessor for the application-name property.

This method returns the receiver's storage for the user-visible application name. This would be the user's idea of the application's name, but not necessarily AppleScript's; see fileName.

Return values:
NSString the application name.

Referenced by initWithName:, quitWithoutSaving, and recordInApplicationList.

- (int) processID  
 

The process serial number for the application instance.

The NSWorkspace -reported application list is consulted for the process ID of the application launch.

Return values:
int the process ID of the application process.

Definition at line 162 of file DAApplication.m.

References recordInApplicationList.

Referenced by kill:.

+ (NSMutableArray *) quitApplicationNames  
 

Singleton array of the names of all applications DownAndOut[tm] has quit.

See also:
- quitWithoutSaving

Definition at line 51 of file DAApplication.m.

Referenced by quitWithoutSaving.

- (void) quitWithoutSaving  
 

Quit the application via AppleScript.

The script sent is

	ignoring application responses
		quit application "<i>[self fileName]</i>" saving no
	end ignoring

For most well-behaved applications, this should effect a rapid, but orderly, exit. The name of the receiver is added to the quitApplicationNames list if the script executes cleanly.

Definition at line 117 of file DAApplication.m.

References fileName, name, and quitApplicationNames.

- (NSDictionary *) recordInApplicationList   [implementation]
 

Return the entry for this application in NSWorkspace's launchedApplications list.

Iterates through the list looking for the dictionary whose NSApplicationName key brings back the same name as the receiver's. Returns that dictionary, which contains things like the launch path, process ID, bundle ID, etc. See the documentation for -[NSWorkspace launchedApplications] and the associated constants for more information.

Return values:
NSDictionary the entry in the running application list for the receiver's application.
nil if the receiver's application is not in the list (presumably not running).

Definition at line 143 of file DAApplication.m.

References isEqualToString:, and name.

Referenced by bundleID, fileName, isRunning, and processID.


The documentation for this class was generated from the following files:
Generated on Wed Jan 25 12:04:27 2006 for DownAndOut by  doxygen 1.4.4