1 /*
2   Copyright (C) 2004-2005 SKYRIX Software AG
3 
4   This file is part of OpenGroupware.org.
5 
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10 
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15 
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 
22 #ifndef __Mailer_SOGoMailObject_H__
23 #define __Mailer_SOGoMailObject_H__
24 
25 #import <Mailer/SOGoMailBaseObject.h>
26 
27 /*
28   SOGoMailObject
29     Parent object: the SOGoMailFolder
30     Child objects: SOGoMailBodyPart's
31 
32   Represents a single mail as retrieved using NGImap4. Since IMAP4 can parse
33   MIME structures on the server side, which we map into child objects of the
34   message.
35   The child objects are accessed using integer IDs, eg:
36     /INBOX/12345/1/2/3
37   would address the MIME part 1.2.3 of the mail 12345 in the folder INBOX.
38 */
39 
40 @class NSArray;
41 @class NSCalendarDate;
42 @class NSData;
43 @class NSDictionary;
44 @class NSException;
45 @class NSMutableArray;
46 @class NSString;
47 
48 @class NGImap4Envelope;
49 @class NGImap4EnvelopeAddress;
50 
51 NSArray *SOGoMailCoreInfoKeys;
52 
53 @interface SOGoMailObject : SOGoMailBaseObject
54 {
55   id coreInfos;
56   id headerPart;
57   NSDictionary *headers;
58 }
59 
60 /* message */
61 
62 - (id)fetchParts:(NSArray *)_parts; /* Note: 'parts' are fetch keys here */
63 
64 /* core infos */
65 
66 - (BOOL) doesMailExist;
67 - (id) fetchCoreInfos; // TODO: what does it do?
68 - (void) setCoreInfos: (NSDictionary *) newCoreInfos;
69 
70 - (NGImap4Envelope *) envelope;
71 - (NSString *) subject;
72 - (NSString *) decodedSubject;
73 - (NSCalendarDate *) date;
74 - (NSArray *) fromEnvelopeAddresses;
75 - (NSArray *) replyToEnvelopeAddresses;
76 - (NSArray *) toEnvelopeAddresses;
77 - (NSArray *) ccEnvelopeAddresses;
78 - (NSArray *) bccEnvelopeAddresses;
79 
80 - (NSDictionary *) mailHeaders;
81 
82 - (id) bodyStructure;
83 - (id) lookupInfoForBodyPart:(id)_path;
84 - (id) lookupImap4BodyPartKey: (NSString *) _key
85 		    inContext: (id) _ctx;
86 
87 /* content */
88 
89 - (NSData *) content;
90 - (NSString *) contentAsString;
91 - (NSString *) davContentLength;
92 
93 - (NSString *) to;
94 - (NSString *) cc;
95 - (NSString *) from;
96 - (NSString *) inReplyTo;
97 - (NSString *) messageId;
98 - (NSString *) received;
99 
100 /* bulk fetching of plain/text content */
101 
102 - (NSArray *) plainTextContentFetchKeys;
103 - (NSDictionary *) fetchPlainTextParts:(NSArray *)_fetchKeys;
104 - (NSDictionary *) fetchPlainTextParts;
105 - (NSDictionary *) fetchPlainTextStrings:(NSArray *)_fetchKeys;
106 
107 - (BOOL) hasAttachment;
108 - (NSDictionary *) fetchFileAttachmentIds;
109 - (NSArray *) fetchFileAttachmentKeys;
110 
111 /* flags */
112 
113 - (NSException *) addFlags:(id)_f;
114 - (NSException *) removeFlags:(id)_f;
115 
116 - (BOOL) isNewMail;  /* \Recent */
117 - (BOOL) flagged;    /* \Flagged */
118 - (BOOL) read;       /* \Unseen */
119 - (BOOL) replied;    /* \Answered */
120 - (BOOL) forwarded;  /* $forwarded */
121 - (BOOL) deleted;    /* \Deleted */
122 
123 /* deletion */
124 
125 - (BOOL) isDeletionAllowed;
126 - (NSException *) copyToFolderNamed: (NSString *) folderName
127                           inContext: (id)_ctx;
128 - (NSException *) moveToFolderNamed: (NSString *) folderName
129                           inContext: (id)_ctx;
130 
131 - (void) addRequiredKeysOfStructure: (NSDictionary *) info
132                                path: (NSString *) p
133                             toArray: (NSMutableArray *) keys
134                       acceptedTypes: (NSArray *) types
135                            withPeek: (BOOL) withPeek;
136 
137 @end
138 
139 #endif /* __Mailer_SOGoMailObject_H__ */
140