Debian Codegraph @

Framework/Pantomime/CWPOP3CacheObject.m

raw
1 /*
2 ** CWPOP3CacheObject.m
3 **
4 ** Copyright (c) 2001-2004 Ludovic Marcotte
5 **
6 ** Author: Ludovic Marcotte <[email protected]>
7 **
8 ** This library is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU Lesser General Public
10 ** License as published by the Free Software Foundation; either
11 ** version 2.1 of the License, or (at your option) any later version.
12 **
13 ** This library is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ** Lesser General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #import <Pantomime/CWPOP3CacheObject.h>
23
24 #import <Pantomime/CWConstants.h>
25
26 static int currentPOP3CacheObjectVersion = 1;
27
28
29 //
30 //
31 //
32 @implementation CWPOP3CacheObject
33
34 - (id) init
35 {
36 self = [super init];
37 if (self)
38 {
39 [CWPOP3CacheObject setVersion: currentPOP3CacheObjectVersion];
40 }
41 return self;
42 }
43
44
45 //
46 //
47 //
48 - (id) initWithUID: (NSString *) theUID
49 date: (NSCalendarDate *) theDate
50 {
51 self = [self init];
52 if (self)
53 {
54 [self setUID: theUID];
55 [self setDate: theDate];
56 }
57
58 return self;
59 }
60
61
62 //
63 //
64 //
65 - (void) dealloc
66 {
67 RELEASE(_date);
68 RELEASE(_UID);
69
70 [super dealloc];
71 }
72
73
74 //
75 //
76 //
77 - (void) encodeWithCoder: (NSCoder *) theCoder
78 {
79 [CWPOP3CacheObject setVersion: currentPOP3CacheObjectVersion];
80 [theCoder encodeObject: _UID];
81 [theCoder encodeObject: _date];
82 }
83
84
85 //
86 //
87 //
88 - (id) initWithCoder: (NSCoder *) theCoder
89 {
90 int version;
91
92 version = [theCoder versionForClassName: NSStringFromClass([self class])];
93
94 self = [super init];
95
96 // Initial version of the serialized POP3 cache object
97 if (version == 0)
98 {
99 [self setUID: [theCoder decodeObject]];
100 [self setDate: [NSCalendarDate calendarDate]];
101 }
102 else
103 {
104 [self setUID: [theCoder decodeObject]];
105 [self setDate: [theCoder decodeObject]];
106 }
107
108 return self;
109 }
110
111
112 //
113 //
114 //
115 - (NSCalendarDate *) date
116 {
117 return _date;
118 }
119
120 - (void) setDate: (NSCalendarDate *) theDate
121 {
122 ASSIGN(_date, theDate);
123 }
124
125 - (NSString *) UID
126 {
127 return _UID;
128 }
129
130
131 - (void) setUID: (NSString *) theUID
132 {
133 ASSIGN(_UID, theUID);
134 }
135 @end