Debian Codegraph @

Framework/Pantomime/CWPOP3Message.m

raw
1 /*
2 ** CWPOP3Message.m
3 **
4 ** Copyright (c) 2001-2006 Ludovic Marcotte
5 ** 2018 Riccardo Mottola
6 **
7 ** Author: Ludovic Marcotte <[email protected]>
8 **
9 ** This library is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU Lesser General Public
11 ** License as published by the Free Software Foundation; either
12 ** version 2.1 of the License, or (at your option) any later version.
13 **
14 ** This library is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ** Lesser General Public License for more details.
18 **
19 ** You should have received a copy of the GNU General Public License
20 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #import <Pantomime/CWPOP3Message.h>
24
25 #import <Pantomime/CWConstants.h>
26 #import <Pantomime/CWFlags.h>
27 #import <Pantomime/CWPOP3Folder.h>
28 #import <Pantomime/CWPOP3Store.h>
29
30 @implementation CWPOP3Message
31
32 - (id) init
33 {
34 self = [super init];
35 if (self)
36 {
37 [self setUID: nil];
38 }
39 return self;
40 }
41
42
43 //
44 //
45 //
46 - (void) dealloc
47 {
48 RELEASE(_UID);
49 [super dealloc];
50 }
51
52
53 //
54 // NSCoding protocol
55 //
56 - (void) encodeWithCoder: (NSCoder *) theCoder
57 {
58 // Must also encode Message's superclass
59 [super encodeWithCoder: theCoder];
60 [theCoder encodeObject: [self UID]];
61 }
62
63
64 //
65 //
66 //
67 - (id) initWithCoder: (NSCoder *) theCoder
68 {
69 // Must also decode Message's superclass
70 self = [super initWithCoder: theCoder];
71 if (self)
72 {
73 [self setUID: [theCoder decodeObject]];
74 }
75 return self;
76 }
77
78
79 //
80 //
81 //
82 - (NSString *) UID
83 {
84 return _UID;
85 }
86
87
88 //
89 //
90 //
91 - (void) setUID: (NSString *) theUID
92 {
93 ASSIGN(_UID, theUID);
94 }
95
96
97 //
98 //
99 //
100 - (NSData *) rawSource
101 {
102 if (!_rawSource)
103 {
104 [[[self folder] store] sendCommand: POP3_RETR arguments: @"RETR %d", [self messageNumber]];
105 }
106
107 return _rawSource;
108 }
109
110
111 //
112 //
113 //
114 - (void) setInitialized: (BOOL) theBOOL
115 {
116 [super setInitialized: theBOOL];
117
118 if (!theBOOL)
119 {
120 DESTROY(_content);
121 return;
122 }
123
124 if (!_content)
125 {
126 [[[self folder] store] sendCommand: POP3_RETR_AND_INITIALIZE arguments: @"RETR %d", [self messageNumber]];
127 [super setInitialized: NO];
128 }
129 }
130
131
132 //
133 //
134 //
135 - (void) setFlags: (CWFlags *) theFlags
136 {
137 if ([theFlags contain: PantomimeDeleted])
138 {
139 [[[self folder] store] sendCommand: POP3_DELE arguments: @"DELE %d", [self messageNumber]];
140 }
141
142 [super setFlags: theFlags];
143 }
144
145 @end