Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
805 | - | 1 | // /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright (C) 2010, Frank Blumenberg |
||
3 | // |
||
4 | // See License.txt for complete licensing and attribution information. |
||
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
||
6 | // of this software and associated documentation files (the "Software"), to deal |
||
7 | // in the Software without restriction, including without limitation the rights |
||
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||
9 | // copies of the Software, and to permit persons to whom the Software is |
||
10 | // furnished to do so, subject to the following conditions: |
||
11 | // |
||
12 | // The above copyright notice and this permission notice shall be included in all |
||
13 | // copies or substantial portions of the Software. |
||
14 | // |
||
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||
21 | // THE SOFTWARE. |
||
22 | // |
||
23 | // /////////////////////////////////////////////////////////////////////////////// |
||
24 | |||
25 | #import "MKHost.h" |
||
26 | |||
27 | #define kNameKey @"name" |
||
28 | #define kAddressKey @"address" |
||
29 | #define kPortKey @"port" |
||
30 | #define kConnectionClassKey @"connectionClass" |
||
31 | |||
32 | @implementation MKHost |
||
33 | |||
34 | @synthesize name=_name; |
||
35 | @synthesize address=_address; |
||
36 | @synthesize port=_port; |
||
37 | @synthesize connectionClass=_connectionClass; |
||
38 | |||
39 | - (id) init |
||
40 | { |
||
41 | self = [super init]; |
||
42 | if (self != nil) { |
||
43 | self.name = NSLocalizedString(@"New host",@"Default host name"); |
||
44 | } |
||
45 | return self; |
||
46 | } |
||
47 | |||
48 | - (void) dealloc |
||
49 | { |
||
50 | self.name=nil; |
||
51 | self.address=nil; |
||
52 | self.connectionClass=nil; |
||
53 | |||
54 | [super dealloc]; |
||
55 | } |
||
56 | |||
57 | -(NSString*) description { |
||
58 | return self.name; |
||
59 | } |
||
60 | |||
61 | #pragma mark NSCoding |
||
62 | - (void)encodeWithCoder:(NSCoder *)encoder { |
||
63 | [encoder encodeObject:_name forKey:kNameKey]; |
||
64 | [encoder encodeObject:_address forKey:kAddressKey]; |
||
65 | [encoder encodeInteger:_port forKey:kPortKey]; |
||
66 | [encoder encodeObject:_connectionClass forKey:kConnectionClassKey]; |
||
67 | } |
||
68 | - (id)initWithCoder:(NSCoder *)decoder { |
||
69 | if (self = [super init]) { |
||
70 | self.name = [decoder decodeObjectForKey:kNameKey]; |
||
71 | self.address = [decoder decodeObjectForKey:kAddressKey]; |
||
72 | self.port = [decoder decodeIntegerForKey:kPortKey]; |
||
73 | self.connectionClass = [decoder decodeObjectForKey:kConnectionClassKey]; |
||
74 | } |
||
75 | return self; |
||
76 | } |
||
77 | #pragma mark - |
||
78 | #pragma mark NSCopying |
||
79 | - (id)copyWithZone:(NSZone *)zone { |
||
80 | MKHost *copy = [[[self class] allocWithZone: zone] init]; |
||
81 | copy.name = [[self.name copyWithZone:zone] autorelease]; |
||
82 | copy.address = [[self.address copyWithZone:zone] autorelease]; |
||
83 | copy.port = self.port; |
||
84 | copy.connectionClass = [[self.connectionClass copyWithZone:zone] autorelease]; |
||
85 | |||
86 | return copy; |
||
87 | } |
||
88 | |||
89 | |||
90 | @end |