2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
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
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.
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
22 #include "SOGoMailObject.h"
23 #include "SOGoMailFolder.h"
24 #include "SOGoMailAccount.h"
25 #include "SOGoMailManager.h"
26 #include "SOGoMailBodyPart.h"
27 #include <NGImap4/NGImap4Envelope.h>
28 #include <NGImap4/NGImap4EnvelopeAddress.h>
29 #include <NGMail/NGMimeMessageParser.h>
32 @implementation SOGoMailObject
34 static NSArray *coreInfoKeys = nil;
35 static NSString *mailETag = nil;
36 static BOOL heavyDebug = NO;
37 static BOOL fetchHeader = YES;
38 static BOOL debugOn = NO;
39 static BOOL debugBodyStructure = NO;
40 static BOOL debugSoParts = NO;
43 return [super version] + 0 /* v1 */;
47 NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
49 NSAssert2([super version] == 1,
50 @"invalid superclass (%@) version %i !",
51 NSStringFromClass([self superclass]), [super version]);
53 if ((fetchHeader = ([ud boolForKey:@"SOGoDoNotFetchMailHeader"] ? NO : YES)))
54 NSLog(@"Note: fetching full mail header.");
56 NSLog(@"Note: not fetching full mail header: 'SOGoDoNotFetchMailHeader'");
58 /* Note: see SOGoMailManager.m for allowed IMAP4 keys */
59 /* Note: "BODY" actually returns the structure! */
61 coreInfoKeys = [[NSArray alloc] initWithObjects:
62 @"FLAGS", @"ENVELOPE", @"BODY",
65 // not yet supported: @"INTERNALDATE",
69 coreInfoKeys = [[NSArray alloc] initWithObjects:
70 @"FLAGS", @"ENVELOPE", @"BODY",
72 // not yet supported: @"INTERNALDATE",
76 if (![[ud objectForKey:@"SOGoMailDisableETag"] boolValue]) {
77 mailETag = [[NSString alloc] initWithFormat:@"\"imap4url_%d_%d_%03d\"",
78 UIX_MAILER_MAJOR_VERSION,
79 UIX_MAILER_MINOR_VERSION,
80 UIX_MAILER_SUBMINOR_VERSION];
81 NSLog(@"Note(SOGoMailObject): using constant etag for mail parts: '%@'",
85 NSLog(@"Note(SOGoMailObject): etag caching disabled!");
89 [self->headers release];
90 [self->headerPart release];
91 [self->coreInfos release];
97 - (NSString *)relativeImap4Name {
98 return [[self nameInContainer] stringByDeletingPathExtension];
103 - (SOGoMailObject *)mailObject {
109 - (NSString *)keyExtensionForPart:(id)_partInfo {
112 if (_partInfo == nil)
115 mt = [_partInfo valueForKey:@"type"];
116 st = [[_partInfo valueForKey:@"subtype"] lowercaseString];
117 if ([mt isEqualToString:@"text"]) {
118 if ([st isEqualToString:@"plain"]) return @".txt";
119 if ([st isEqualToString:@"html"]) return @".html";
120 if ([st isEqualToString:@"calendar"]) return @".ics";
121 if ([st isEqualToString:@"x-vcard"]) return @".vcf";
123 else if ([mt isEqualToString:@"image"])
124 return [@"." stringByAppendingString:st];
125 else if ([mt isEqualToString:@"application"]) {
126 if ([st isEqualToString:@"pgp-signature"])
133 - (NSArray *)relationshipKeysWithParts:(BOOL)_withParts {
134 /* should return non-multipart children */
139 parts = [[self bodyStructure] valueForKey:@"parts"];
140 if (![parts isNotNull])
142 if ((count = [parts count]) == 0)
145 for (i = 0, ma = nil; i < count; i++) {
150 part = [parts objectAtIndex:i];
151 hasParts = [part valueForKey:@"parts"] != nil ? YES:NO;
152 if ((hasParts && !_withParts) || (_withParts && !hasParts))
156 ma = [NSMutableArray arrayWithCapacity:count - i];
158 ext = [self keyExtensionForPart:part];
159 key = [[NSString alloc] initWithFormat:@"%d%@", i + 1, ext?ext:@""];
166 - (NSArray *)toOneRelationshipKeys {
167 return [self relationshipKeysWithParts:NO];
169 - (NSArray *)toManyRelationshipKeys {
170 return [self relationshipKeysWithParts:YES];
175 - (id)fetchParts:(NSArray *)_parts {
176 // TODO: explain what it does
178 Called by -fetchPlainTextParts:
180 return [[self imap4Connection] fetchURL:[self imap4URL] parts:_parts];
185 - (BOOL)doesMailExist {
186 static NSArray *existsKey = nil;
189 if (self->coreInfos != nil) /* if we have coreinfos, we can use them */
190 return [self->coreInfos isNotNull];
192 /* otherwise fetch something really simple */
194 if (existsKey == nil) /* we use size, other suggestions? */
195 existsKey = [[NSArray alloc] initWithObjects:@"RFC822.SIZE", nil];
197 msgs = [self fetchParts:existsKey]; // returns dict
198 msgs = [msgs valueForKey:@"fetch"];
199 return [msgs count] > 0 ? YES : NO;
202 - (id)fetchCoreInfos {
205 if (self->coreInfos != nil)
206 return [self->coreInfos isNotNull] ? self->coreInfos : nil;
208 #if 0 // TODO: old code, why was it using clientObject??
209 msgs = [[self clientObject] fetchParts:coreInfoKeys]; // returns dict
211 msgs = [self fetchParts:coreInfoKeys]; // returns dict
213 if (heavyDebug) [self logWithFormat:@"M: %@", msgs];
214 msgs = [msgs valueForKey:@"fetch"];
215 if ([msgs count] == 0)
218 self->coreInfos = [[msgs objectAtIndex:0] retain];
219 return self->coreInfos;
222 - (id)bodyStructure {
225 body = [[self fetchCoreInfos] valueForKey:@"body"];
226 if (debugBodyStructure)
227 [self logWithFormat:@"BODY: %@", body];
231 - (NGImap4Envelope *)envelope {
232 return [[self fetchCoreInfos] valueForKey:@"envelope"];
234 - (NSString *)subject {
235 return [[self envelope] subject];
237 - (NSCalendarDate *)date {
238 return [[self envelope] date];
240 - (NSArray *)fromEnvelopeAddresses {
241 return [[self envelope] from];
243 - (NSArray *)toEnvelopeAddresses {
244 return [[self envelope] to];
246 - (NSArray *)ccEnvelopeAddresses {
247 return [[self envelope] cc];
250 - (NSData *)mailHeaderData {
251 return [[self fetchCoreInfos] valueForKey:@"header"];
253 - (BOOL)hasMailHeaderInCoreInfos {
254 return [[self mailHeaderData] length] > 0 ? YES : NO;
257 - (id)mailHeaderPart {
258 NGMimeMessageParser *parser;
261 if (self->headerPart != nil)
262 return [self->headerPart isNotNull] ? self->headerPart : nil;
264 if ([(data = [self mailHeaderData]) length] == 0)
267 // TODO: do we need to set some delegate method which stops parsing the body?
268 parser = [[NGMimeMessageParser alloc] init];
269 self->headerPart = [[parser parsePartFromData:data] retain];
270 [parser release]; parser = nil;
272 if (self->headerPart == nil) {
273 self->headerPart = [[NSNull null] retain];
276 return self->headerPart;
278 - (NSDictionary *)mailHeaders {
279 if (self->headers == nil)
280 self->headers = [[[self mailHeaderPart] headers] copy];
281 return self->headers;
284 - (id)lookupInfoForBodyPart:(id)_path {
289 if (![_path isNotNull])
292 if ((info = [self bodyStructure]) == nil) {
293 [self errorWithFormat:@"got no body part structure!"];
297 /* ensure array argument */
299 if ([_path isKindOfClass:[NSString class]]) {
300 if ([_path length] == 0)
303 _path = [_path componentsSeparatedByString:@"."];
307 For each path component, eg 1,1,3
309 Remember that we need special processing for message/rfc822 which maps the
310 namespace of multiparts directly into the main namespace.
312 TODO(hh): no I don't remember, please explain in more detail!
314 pe = [_path objectEnumerator];
315 while ((p = [pe nextObject]) != nil && [info isNotNull]) {
320 [self debugWithFormat:@"check PATH: %@", p];
321 idx = [p intValue] - 1;
323 parts = [info valueForKey:@"parts"];
324 mt = [[info valueForKey:@"type"] lowercaseString];
325 if ([mt isEqualToString:@"message"]) {
326 /* we have special behaviour for message types */
329 if ((body = [info valueForKey:@"body"]) != nil) {
330 mt = [body valueForKey:@"type"];
331 if ([mt isEqualToString:@"multipart"])
332 parts = [body valueForKey:@"parts"];
334 parts = [NSArray arrayWithObject:body];
338 if (idx >= [parts count]) {
339 [self errorWithFormat:
340 @"body part index out of bounds(idx=%d vs count=%d): %@",
341 (idx + 1), [parts count], info];
344 info = [parts objectAtIndex:idx];
346 return [info isNotNull] ? info : nil;
351 - (NSData *)content {
353 id result, fullResult;
355 fullResult = [self fetchParts:[NSArray arrayWithObject:@"RFC822"]];
356 if (fullResult == nil)
359 if ([fullResult isKindOfClass:[NSException class]])
362 /* extract fetch result */
364 result = [fullResult valueForKey:@"fetch"];
365 if (![result isKindOfClass:[NSArray class]]) {
367 @"ERROR: unexpected IMAP4 result (missing 'fetch'): %@",
369 return [NSException exceptionWithHTTPStatus:500 /* server error */
370 reason:@"unexpected IMAP4 result"];
372 if ([result count] == 0)
375 result = [result objectAtIndex:0];
377 /* extract message */
379 if ((content = [result valueForKey:@"message"]) == nil) {
381 @"ERROR: unexpected IMAP4 result (missing 'message'): %@",
383 return [NSException exceptionWithHTTPStatus:500 /* server error */
384 reason:@"unexpected IMAP4 result"];
387 return [[content copy] autorelease];
390 - (NSString *)contentAsString {
394 if ((content = [self content]) == nil)
396 if ([content isKindOfClass:[NSException class]])
399 s = [[NSString alloc] initWithData:content
400 encoding:NSISOLatin1StringEncoding];
403 @"ERROR: could not convert data of length %d to string",
407 return [s autorelease];
410 /* bulk fetching of plain/text content */
412 - (BOOL)shouldFetchPartOfType:(NSString *)_type subtype:(NSString *)_subtype {
414 This method decides which parts are 'prefetched' for display. Those are
415 usually text parts (the set is currently hardcoded in this method ...).
417 _type = [_type lowercaseString];
418 _subtype = [_subtype lowercaseString];
420 if ([_type isEqualToString:@"text"]) {
421 if ([_subtype isEqualToString:@"plain"])
424 if ([_subtype isEqualToString:@"calendar"]) /* we also fetch calendars */
428 if ([_type isEqualToString:@"application"]) {
429 if ([_subtype isEqualToString:@"pgp-signature"])
431 if ([_subtype hasPrefix:@"x-vnd.kolab."])
438 - (void)addRequiredKeysOfStructure:(id)_info path:(NSString *)_p
439 toArray:(NSMutableArray *)_keys
440 recurse:(BOOL)_recurse
443 This is used to collect the set of IMAP4 fetch-keys required to fetch
444 the basic parts of the body structure. That is, to fetch all parts which
445 are displayed 'inline' in a single IMAP4 fetch.
447 The method calls itself recursively to walk the body structure.
454 /* Note: if the part itself doesn't qualify, we still check subparts */
455 fetchPart = [self shouldFetchPartOfType:[_info valueForKey:@"type"]
456 subtype:[_info valueForKey:@"subtype"]];
460 if ([_p length] > 0) {
461 k = [[@"body[" stringByAppendingString:_p] stringByAppendingString:@"]"];
465 for some reason we need to add ".TEXT" for plain text stuff on root
467 TODO: check with HTML
479 parts = [(NSDictionary *)_info objectForKey:@"parts"];
480 for (i = 0, count = [parts count]; i < count; i++) {
484 sp = ([_p length] > 0)
485 ? [_p stringByAppendingFormat:@".%d", i + 1]
486 : [NSString stringWithFormat:@"%d", i + 1];
488 childInfo = [parts objectAtIndex:i];
490 [self addRequiredKeysOfStructure:childInfo path:sp toArray:_keys
496 if ((body = [(NSDictionary *)_info objectForKey:@"body"]) != nil) {
499 sp = [[body valueForKey:@"type"] lowercaseString];
500 if ([sp isEqualToString:@"multipart"])
503 sp = [_p length] > 0 ? [_p stringByAppendingString:@".1"] : @"1";
504 [self addRequiredKeysOfStructure:body path:sp toArray:_keys
509 - (NSArray *)plainTextContentFetchKeys {
511 The name is not 100% correct. The method returns all body structure fetch
512 keys which are marked by the -shouldFetchPartOfType:subtype: method.
516 ma = [NSMutableArray arrayWithCapacity:4];
517 [self addRequiredKeysOfStructure:[[self clientObject] bodyStructure]
518 path:@"" toArray:ma recurse:YES];
522 - (NSDictionary *)fetchPlainTextParts:(NSArray *)_fetchKeys {
523 // TODO: is the name correct or does it also fetch other parts?
524 NSMutableDictionary *flatContents;
528 [self debugWithFormat:@"fetch keys: %@", _fetchKeys];
530 result = [self fetchParts:_fetchKeys];
531 result = [result valueForKey:@"RawResponse"]; // hackish
533 // Note: -valueForKey: doesn't work!
534 result = [(NSDictionary *)result objectForKey:@"fetch"];
536 count = [_fetchKeys count];
537 flatContents = [NSMutableDictionary dictionaryWithCapacity:count];
538 for (i = 0; i < count; i++) {
542 key = [_fetchKeys objectAtIndex:i];
543 data = [(NSDictionary *)[(NSDictionary *)result objectForKey:key]
544 objectForKey:@"data"];
546 if (![data isNotNull]) {
547 [self errorWithFormat:@"got no data for key: %@", key];
551 if ([key isEqualToString:@"body[text]"])
552 key = @""; // see key collector for explanation (TODO: where?)
553 else if ([key hasPrefix:@"body["]) {
556 key = [key substringFromIndex:5];
557 r = [key rangeOfString:@"]"];
559 key = [key substringToIndex:r.location];
561 [flatContents setObject:data forKey:key];
566 - (NSDictionary *)fetchPlainTextParts {
567 return [self fetchPlainTextParts:[self plainTextContentFetchKeys]];
570 /* convert parts to strings */
572 - (NSString *)stringForData:(NSData *)_data partInfo:(NSDictionary *)_info {
576 if (![_data isNotNull])
581 charset = [[_info valueForKey:@"parameterList"] valueForKey:@"charset"];
582 if ([charset isNotNull] && [charset length] > 0)
583 s = [NSString stringWithData:_data usingEncodingNamed:charset];
585 if (s == nil) { /* no charset provided, fall back to UTF-8 */
586 s = [[NSString alloc] initWithData:_data encoding:NSUTF8StringEncoding];
593 - (NSDictionary *)stringifyTextParts:(NSDictionary *)_datas {
594 NSMutableDictionary *md;
598 md = [NSMutableDictionary dictionaryWithCapacity:4];
599 keys = [_datas keyEnumerator];
600 while ((key = [keys nextObject]) != nil) {
604 info = [self lookupInfoForBodyPart:key];
605 if ((s = [self stringForData:[_datas objectForKey:key] partInfo:info]))
606 [md setObject:s forKey:key];
610 - (NSDictionary *)fetchPlainTextStrings:(NSArray *)_fetchKeys {
612 The fetched parts are NSData objects, this method converts them into
613 NSString objects based on the information inside the bodystructure.
615 The fetch-keys are body fetch-keys like: body[text] or body[1.2.3].
616 The keys in the result dictionary are "" for 'text' and 1.2.3 for parts.
620 if ((datas = [self fetchPlainTextParts:_fetchKeys]) == nil)
622 if ([datas isKindOfClass:[NSException class]])
625 return [self stringifyTextParts:datas];
630 - (NSException *)addFlags:(id)_flags {
631 return [[self imap4Connection] addFlags:_flags toURL:[self imap4URL]];
633 - (NSException *)removeFlags:(id)_flags {
634 return [[self imap4Connection] removeFlags:_flags toURL:[self imap4URL]];
639 - (BOOL)isDeletionAllowed {
640 return [[self container] isDeleteAndExpungeAllowed];
645 - (id)lookupImap4BodyPartKey:(NSString *)_key inContext:(id)_ctx {
646 // TODO: we might want to check for existence prior controller creation
649 clazz = [SOGoMailBodyPart bodyPartClassForKey:_key inContext:_ctx];
650 return [[[clazz alloc] initWithName:_key inContainer:self] autorelease];
653 - (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
656 /* first check attributes directly bound to the application */
657 if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]) != nil)
660 /* lookup body part */
662 if ([self isBodyPartKey:_key inContext:_ctx]) {
663 if ((obj = [self lookupImap4BodyPartKey:_key inContext:_ctx]) != nil) {
665 [self logWithFormat:@"mail looked up part %@: %@", _key, obj];
670 /* return 404 to stop acquisition */
671 return [NSException exceptionWithHTTPStatus:404 /* Not Found */
672 reason:@"Did not find mail method or part-reference!"];
677 - (BOOL)davIsCollection {
678 /* while a mail has child objects, it should appear as a file in WebDAV */
682 - (id)davContentLength {
683 return [[self fetchCoreInfos] valueForKey:@"size"];
686 - (NSDate *)davCreationDate {
687 // TODO: use INTERNALDATE once NGImap4 supports that
690 - (NSDate *)davLastModified {
691 return [self davCreationDate];
694 - (NSException *)davMoveToTargetObject:(id)_target newName:(NSString *)_name
697 [self logWithFormat:@"TODO: should move mail as '%@' to: %@",
699 return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
700 reason:@"not implemented"];
703 - (NSException *)davCopyToTargetObject:(id)_target newName:(NSString *)_name
707 Note: this is special because we create SOGoMailObject's even if they do
708 not exist (for performance reasons).
710 Also: we cannot really take a target resource, the ID will be assigned by
712 We even cannot return a 'location' header instead because IMAP4
713 doesn't tell us the new ID.
717 destImap4URL = ([_name length] == 0)
718 ? [[_target container] imap4URL]
719 : [_target imap4URL];
721 return [[self mailManager] copyMailURL:[self imap4URL]
722 toFolderURL:destImap4URL
723 password:[self imap4Password]];
728 - (id)GETAction:(id)_ctx {
733 if ((error = [self matchesRequestConditionInContext:_ctx]) != nil) {
734 /* check whether the mail still exists */
735 if (![self doesMailExist]) {
736 return [NSException exceptionWithHTTPStatus:404 /* Not Found */
737 reason:@"mail was deleted"];
739 return error; /* return 304 or 416 */
742 content = [self content];
743 if ([content isKindOfClass:[NSException class]])
745 if (content == nil) {
746 return [NSException exceptionWithHTTPStatus:404 /* Not Found */
747 reason:@"did not find IMAP4 message"];
750 r = [(WOContext *)_ctx response];
751 [r setHeader:@"message/rfc822" forKey:@"content-type"];
752 [r setContent:content];
758 - (NSException *)trashInContext:(id)_ctx {
760 Trashing is three actions:
761 a) copy to trash folder
762 b) mark mail as deleted
765 In case b) or c) fails, we can't do anything because IMAP4 doesn't tell us
766 the ID used in the trash folder.
768 SOGoMailFolder *trashFolder;
771 // TODO: check for safe HTTP method
773 trashFolder = [[self mailAccountFolder] trashFolderInContext:_ctx];
774 if ([trashFolder isKindOfClass:[NSException class]])
775 return (NSException *)trashFolder;
776 if (![trashFolder isNotNull]) {
777 return [NSException exceptionWithHTTPStatus:500 /* Server Error */
778 reason:@"Did not find Trash folder!"];
780 [trashFolder flushMailCaches];
784 error = [self davCopyToTargetObject:trashFolder
785 newName:@"fakeNewUnusedByIMAP4" /* autoassigned */
787 if (error != nil) return error;
789 /* b) mark deleted */
791 error = [[self imap4Connection] markURLDeleted:[self imap4URL]];
792 if (error != nil) return error;
796 error = [[self imap4Connection] expungeAtURL:[[self container] imap4URL]];
797 if (error != nil) return error; // TODO: unflag as deleted?
798 [self flushMailCaches];
803 - (NSException *)delete {
805 Note: delete is different to DELETEAction: for mails! The 'delete' runs
806 either flags a message as deleted or moves it to the Trash while
807 the DELETEAction: really deletes a message (by flagging it as
808 deleted _AND_ performing an expunge).
810 // TODO: copy to Trash folder
813 // TODO: check for safe HTTP method
815 error = [[self imap4Connection] markURLDeleted:[self imap4URL]];
818 - (id)DELETEAction:(id)_ctx {
821 // TODO: ensure safe HTTP method
823 error = [[self imap4Connection] markURLDeleted:[self imap4URL]];
824 if (error != nil) return error;
826 error = [[self imap4Connection] expungeAtURL:[[self container] imap4URL]];
827 if (error != nil) return error; // TODO: unflag as deleted?
829 return [NSNumber numberWithBool:YES]; /* delete was successful */
832 /* some mail classification */
834 - (BOOL)isKolabObject {
837 if ((h = [self mailHeaders]) != nil)
838 return [[h objectForKey:@"x-kolab-type"] isNotEmpty];
840 // TODO: we could check the body structure?
845 - (BOOL)isMailingListMail {
848 if ((h = [self mailHeaders]) == nil)
851 return [[h objectForKey:@"list-id"] isNotEmpty];
854 - (BOOL)isVirusScanned {
857 if ((h = [self mailHeaders]) == nil)
860 if (![[h objectForKey:@"x-virus-status"] isNotEmpty]) return NO;
861 if (![[h objectForKey:@"x-virus-scanned"] isNotEmpty]) return NO;
865 - (NSString *)scanListHeaderValue:(id)_value
866 forFieldWithPrefix:(NSString *)_prefix
868 /* Note: not very tolerant on embedded commands and <> */
869 // TODO: does not really belong here, should be a header-field-parser
872 if (![_value isNotEmpty])
875 if ([_value isKindOfClass:[NSArray class]]) {
879 e = [_value objectEnumerator];
880 while ((value = [e nextObject]) != nil) {
881 value = [self scanListHeaderValue:value forFieldWithPrefix:_prefix];
882 if (value != nil) return value;
887 if (![_value isKindOfClass:[NSString class]])
890 /* check for commas in string values */
891 r = [_value rangeOfString:@","];
893 return [self scanListHeaderValue:[_value componentsSeparatedByString:@","]
894 forFieldWithPrefix:_prefix];
897 /* value qualifies */
898 if (![(NSString *)_value hasPrefix:_prefix])
902 if ([_value characterAtIndex:0] == '<') {
903 r = [_value rangeOfString:@">"];
904 _value = (r.length == 0)
905 ? [_value substringFromIndex:1]
906 : [_value substringWithRange:NSMakeRange(1, r.location - 2)];
912 - (NSString *)mailingListArchiveURL {
913 return [self scanListHeaderValue:
914 [[self mailHeaders] objectForKey:@"list-archive"]
915 forFieldWithPrefix:@"<http://"];
917 - (NSString *)mailingListSubscribeURL {
918 return [self scanListHeaderValue:
919 [[self mailHeaders] objectForKey:@"list-subscribe"]
920 forFieldWithPrefix:@"<http://"];
922 - (NSString *)mailingListUnsubscribeURL {
923 return [self scanListHeaderValue:
924 [[self mailHeaders] objectForKey:@"list-unsubscribe"]
925 forFieldWithPrefix:@"<http://"];
932 Note: There is one thing which *can* change for an existing message,
933 those are the IMAP4 flags (and annotations, which we do not use).
934 Since we don't render the flags, it should be OK, if this changes
935 we must embed the flagging into the etag.
939 - (int)zlGenerationCount {
940 return 0; /* mails never change */
943 /* Outlook mail tagging */
945 - (NSString *)outlookMessageClass {
948 if ((type = [[self mailHeaders] objectForKey:@"x-kolab-type"]) != nil) {
949 if ([type isEqualToString:@"application/x-vnd.kolab.contact"])
950 return @"IPM.Contact";
951 if ([type isEqualToString:@"application/x-vnd.kolab.task"])
953 if ([type isEqualToString:@"application/x-vnd.kolab.event"])
954 return @"IPM.Appointment";
955 if ([type isEqualToString:@"application/x-vnd.kolab.note"])
957 if ([type isEqualToString:@"application/x-vnd.kolab.journal"])
958 return @"IPM.Journal";
961 return @"IPM.Message"; /* email, default class */
966 - (BOOL)isDebuggingEnabled {
970 @end /* SOGoMailObject */