2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 1, or (at your option)
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 @interface Process ( PrivateAPI
)
26 - (void)_setName
:(NSString
*)name
;
27 - (void)_setVersion
:(NSString
*)version
;
28 - (void)_setIcon
:(NSImage
*)icon
;
29 - (void)_setPID
:(pid_t
)pid
;
34 @implementation Process
37 - (id)initWithName
:(NSString
*)name version
:(NSString
*)version icon
:(NSImage
*)icon pid
:(pid_t
)pid
39 if ( self = [super init
] ) {
41 [self _setVersion
:version
];
48 - (id)initWithName
:(NSString
*)name version
:(NSString
*)version icon
:(NSImage
*)icon
50 return [self initWithName
:name version
:version icon
:icon pid
:0];
53 - (id)initWithName
:(NSString
*)name version
:(NSString
*)version
55 return [self initWithName
:name version
:version icon
:nil pid
:0];
60 // release local objects
69 // #############################################################################
71 // #############################################################################
73 - (id)copyWithZone
:(NSZone
*)zone
75 return [[Process allocWithZone
:zone
] initWithName
:_name version
:_version icon
:_icon pid
:_pid
];
79 // #############################################################################
81 // #############################################################################
83 - (id)initWithCoder
:(NSCoder
*)coder
85 if ( self = [super init
] )
87 [self _setName
:[coder decodeObject
]];
88 [self _setVersion
:[coder decodeObject
]];
89 //[self setIcon:[coder decodeObject]];
90 [coder decodeValueOfObjCType
:@encode(pid_t
) at
:&_pid
];
95 - (void)encodeWithCoder
:(NSCoder
*)coder
97 [coder encodeObject
:_name
];
98 [coder encodeObject
:_version
];
99 //[coder encodeObject:_icon];
100 [coder encodeValueOfObjCType
:@encode(pid_t
) at
:&_pid
];
104 #pragma mark NSObject Override
106 - (BOOL)isEqual
:(id)anObject
108 if ( [_name isEqualToString
:[(Process
*)anObject name
]] &&
109 [_version isEqualToString
:[(Process
*)anObject version
]] &&
110 _pid
== [(Process
*)anObject pid
] ) {
111 // they are the same process
119 return [[NSString stringWithFormat
:@
"%@%@%u", _name
, _version
, _pid
] hash
];
123 - (BOOL)sameApplicationAs
:(id)anObject
125 if ( [_name isEqualToString
:[(Process
*)anObject name
]] &&
126 [_version isEqualToString
:[(Process
*)anObject version
]] ) {
127 // they are the same application
134 #pragma mark Accessors
141 - (NSString
*)version
157 - (void)_setName
:(NSString
*)name
160 name
= [NSString stringWithString
:@
"Unknown Process"];
167 - (void)_setVersion
:(NSString
*)version
170 version
= [NSString stringWithString
:@
"Unknown Version"];
177 - (void)_setIcon
:(NSImage
*)icon
184 [_icon setScalesWhenResized
:YES
];
185 [_icon setSize
:NSMakeSize(16,16)];
188 - (void)_setPID
:(pid_t
)pid