From 2b6897c9b0523c95d2d96e5073ef5cd2a5e11772 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Mon, 29 Oct 2007 21:38:54 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1205 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 14 ++++ SOPE/GDLContentStore/ChangeLog | 5 ++ SOPE/GDLContentStore/GCSFolder.m | 27 +++++++ SoObjects/Mailer/SOGoMailBodyPart.m | 22 +++--- UI/MailerUI/English.lproj/Localizable.strings | 7 +- UI/MailerUI/French.lproj/Localizable.strings | 5 +- UI/MailerUI/German.lproj/Localizable.strings | 1 + UI/MailerUI/UIxMailListView.m | 79 +++++++++++++------ UI/Templates/MailerUI/UIxMailListView.wox | 3 + UI/WebServerResources/MailerUI.js | 6 +- 10 files changed, 129 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index e91bb16d..3d8206ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-10-29 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoMailBodyPart.m ([SOGoMailBodyPart + -davContentType]): ignore any possible parameter taken from the + mime-info of the body part. + + * UI/MailerUI/UIxMailListView.m ([UIxMailListView + -lastFirstMessageNumber]): new accessor that returns the first + message number of the last series of messages. + ([UIxMailListView -fetchKeys]): request the bodystructure for each + listed message. + ([UIxMailListView -hasMessageAttachment]): extract the attachment + information from the message bodystructure. + 2007-10-26 Wolfgang Sourdeau * SoObjects/Mailer/SOGoMailBodyPart.m ([SOGoMailBodyPart diff --git a/SOPE/GDLContentStore/ChangeLog b/SOPE/GDLContentStore/ChangeLog index dae4f0dc..a1072b1a 100644 --- a/SOPE/GDLContentStore/ChangeLog +++ b/SOPE/GDLContentStore/ChangeLog @@ -1,3 +1,8 @@ +2007-10-29 Wolfgang Sourdeau + + * GCSFolder.m ([GCSFolder -writeContent:toName:baseVersion:]): + purge the record if previously marked as deleted. + 2007-10-24 Wolfgang Sourdeau * GCSFolderManager.m ([GCSFolderManager -baseTableNameWithUID:]): diff --git a/SOPE/GDLContentStore/GCSFolder.m b/SOPE/GDLContentStore/GCSFolder.m index be7f22c5..c423d5f4 100644 --- a/SOPE/GDLContentStore/GCSFolder.m +++ b/SOPE/GDLContentStore/GCSFolder.m @@ -303,6 +303,10 @@ static GCSStringFormatter *stringFormatter = nil; return [self _fetchValueOfColumn:@"c_version" inContentWithName:_name]; } +- (NSNumber *)deletionOfContentWithName:(NSString *)_name { + return [self _fetchValueOfColumn:@"c_deleted" inContentWithName:_name]; +} + - (NSString *)fetchContentWithName:(NSString *)_name { return [self _fetchValueOfColumn:@"c_content" inContentWithName:_name]; } @@ -525,6 +529,21 @@ static GCSStringFormatter *stringFormatter = nil; return AUTORELEASE(qualifier); } +- (void) _purgeRecordWithName: (NSString *) recordName +{ + NSString *delSql, *table; + EOAdaptorChannel *channel; + + channel = [self acquireStoreChannel]; + + table = [self storeTableName]; + delSql = [NSString stringWithFormat: @"DELETE FROM %@" + @" WHERE c_name = %@", table, + [self _formatRowValue: recordName]]; + [channel evaluateExpressionX: delSql]; + [self releaseChannel: channel]; +} + - (NSException *)writeContent:(NSString *)_content toName:(NSString *)_name baseVersion:(unsigned int)_baseVersion { @@ -561,6 +580,14 @@ static GCSStringFormatter *stringFormatter = nil; if (doLogStore) [self logWithFormat:@" version: %@", storedVersion]; isNewRecord = [storedVersion isNotNull] ? NO : YES; + if (!isNewRecord) + { + if ([[self deletionOfContentWithName:_name] isNotNull]) + { + [self _purgeRecordWithName: _name]; + isNewRecord = YES; + } + } /* check whether sequence matches */ if (_baseVersion != 0 /* use 0 to override check */) { diff --git a/SoObjects/Mailer/SOGoMailBodyPart.m b/SoObjects/Mailer/SOGoMailBodyPart.m index d1a1f42f..550fc04a 100644 --- a/SoObjects/Mailer/SOGoMailBodyPart.m +++ b/SoObjects/Mailer/SOGoMailBodyPart.m @@ -236,20 +236,24 @@ static BOOL debugOn = NO; return @"application/octet-stream"; } -- (NSString *)davContentType { +- (NSString *) davContentType +{ // TODO: what about the content-type and other headers? // => we could pass them in as the extension? (eg generate 1.gif!) - NSString *pe; + NSString *parts, *contentType, *extension; /* try type from body structure info */ - if ((pe = [self contentTypeForBodyPartInfo:[self partInfo]]) != nil) - return pe; - - /* construct type */ - - pe = [[self nameInContainer] pathExtension]; - return [self contentTypeForPathExtension:pe]; + parts = [self contentTypeForBodyPartInfo: [self partInfo]]; + contentType = [[parts componentsSeparatedByString: @";"] objectAtIndex: 0]; + + if (![contentType length]) + { + extension = [[self nameInContainer] pathExtension]; + contentType = [self contentTypeForPathExtension: extension]; + } + + return contentType; } /* actions */ diff --git a/UI/MailerUI/English.lproj/Localizable.strings b/UI/MailerUI/English.lproj/Localizable.strings index 2574e487..5bf7abab 100644 --- a/UI/MailerUI/English.lproj/Localizable.strings +++ b/UI/MailerUI/English.lproj/Localizable.strings @@ -116,9 +116,10 @@ "Unread" = "Unread"; "messages" = "messages"; -"first" = "first"; -"previous" = "prev"; -"next" = "next"; +"first" = "First"; +"previous" = "Previous"; +"next" = "Next"; +"last" = "Last"; "msgnumber_to" = "to"; "msgnumber_of" = "of"; diff --git a/UI/MailerUI/French.lproj/Localizable.strings b/UI/MailerUI/French.lproj/Localizable.strings index 6c805eaa..6f9acb86 100644 --- a/UI/MailerUI/French.lproj/Localizable.strings +++ b/UI/MailerUI/French.lproj/Localizable.strings @@ -118,8 +118,9 @@ "messages" = "message(s)"; "first" = "Premier"; -"previous" = "précédent"; -"next" = "suivant"; +"previous" = "Précédent"; +"next" = "Suivant"; +"last" = "Dernier"; "Mark Unread" = "Marquer comme non lu"; "Mark Read" = "Marquer comme lu"; diff --git a/UI/MailerUI/German.lproj/Localizable.strings b/UI/MailerUI/German.lproj/Localizable.strings index 40d826d2..4f5f9890 100644 --- a/UI/MailerUI/German.lproj/Localizable.strings +++ b/UI/MailerUI/German.lproj/Localizable.strings @@ -103,6 +103,7 @@ "first" = "Erste"; "previous" = "Vorherige"; "next" = "Nächste"; +"last" = "Letzter"; "Mark Unread" = "Als ungelesen markieren"; "Mark Read" = "Als gelesen markieren"; diff --git a/UI/MailerUI/UIxMailListView.m b/UI/MailerUI/UIxMailListView.m index 16251421..6f7767d4 100644 --- a/UI/MailerUI/UIxMailListView.m +++ b/UI/MailerUI/UIxMailListView.m @@ -40,13 +40,13 @@ #import #import +#import #import #import #import "UIxMailListView.h" #define messagesPerPage 50 -static int attachmentFlagSize = 8096; @implementation UIxMailListView @@ -80,7 +80,7 @@ static int attachmentFlagSize = 8096; - (void) setMessage: (id) _msg { - ASSIGN(message, _msg); + ASSIGN (message, _msg); } - (id) message @@ -203,11 +203,25 @@ static int attachmentFlagSize = 8096; - (BOOL) hasMessageAttachment { - /* we detect attachments by size ... */ - unsigned size; - - size = [[[self message] valueForKey:@"size"] intValue]; - return size > attachmentFlagSize; + NSArray *parts; + NSEnumerator *dispositions; + NSDictionary *currentDisp; + BOOL hasAttachment; + + parts = [[message objectForKey: @"body"] objectForKey: @"parts"]; + if ([parts count] > 1) + { + dispositions + = [[parts objectsForKey: @"disposition"] objectEnumerator]; + while (!hasAttachment + && (currentDisp = [dispositions nextObject])) + hasAttachment = ([[currentDisp objectForKey: @"type"] + isEqualToString: @"ATTACHMENT"]); + } + else + hasAttachment = NO; + + return hasAttachment; } /* fetching messages */ @@ -216,10 +230,12 @@ static int attachmentFlagSize = 8096; { /* Note: see SOGoMailManager.m for allowed IMAP4 keys */ static NSArray *keys = nil; - if (keys == nil) { + + if (!keys) keys = [[NSArray alloc] initWithObjects: @"UID", - @"FLAGS", @"ENVELOPE", @"RFC822.SIZE", nil]; - } + @"FLAGS", @"ENVELOPE", @"RFC822.SIZE", + @"BODYSTRUCTURE", nil]; + return keys; } @@ -263,6 +279,7 @@ static int attachmentFlagSize = 8096; - (NSArray *) sortedUIDs { EOQualifier *fetchQualifier, *notDeleted; + if (!sortedUIDs) { notDeleted = [EOQualifier qualifierWithQualifierFormat: @@ -354,6 +371,21 @@ static int attachmentFlagSize = 8096; return [self firstMessageNumber] + [self fetchRange].length; } +- (unsigned int) lastFirstMessageNumber +{ + unsigned int max, modulo; + + if (!sortedUIDs) + [self sortedUIDs]; + + max = [sortedUIDs count]; + modulo = (max % messagesPerPage); + if (modulo == 0) + modulo = messagesPerPage; + + return (max + 1 - modulo); +} + - (unsigned int) prevFirstMessageNumber { NSRange r; @@ -368,22 +400,23 @@ static int attachmentFlagSize = 8096; - (NSArray *) messages { - NSArray *uids; - NSArray *msgs; - NSRange r; + NSArray *uids; + NSDictionary *msgs; + NSRange r; unsigned len; - if (messages != nil) - return messages; - - r = [self fetchBlock]; - uids = [self sortedUIDs]; - if ((len = [uids count]) > r.length) - /* only need to restrict if we have a lot */ - uids = [uids subarrayWithRange:r]; + if (!messages) + { + r = [self fetchBlock]; + uids = [self sortedUIDs]; + len = [uids count]; + if (len > r.length) + /* only need to restrict if we have a lot */ + uids = [uids subarrayWithRange: r]; - msgs = [[self clientObject] fetchUIDs: uids parts: [self fetchKeys]]; - messages = [[msgs valueForKey: @"fetch"] retain]; + msgs = [[self clientObject] fetchUIDs: uids parts: [self fetchKeys]]; + messages = [[msgs objectForKey: @"fetch"] retain]; + } return messages; } diff --git a/UI/Templates/MailerUI/UIxMailListView.wox b/UI/Templates/MailerUI/UIxMailListView.wox index cae21ceb..31d5ed63 100644 --- a/UI/Templates/MailerUI/UIxMailListView.wox +++ b/UI/Templates/MailerUI/UIxMailListView.wox @@ -48,6 +48,9 @@ >| + |