diff --git a/ChangeLog b/ChangeLog index 9cec3647b..9e05548a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,14 @@ don't escape the / character as it's generating invalid JSON output on newer versions of PostgreSQL. + * Dropped all references to "SOGoMailCheckAllUnseenCounts". We + now check all folders for which filters are defined with a + "fileinto" action - even if they are disable. + + * UI/MailerUI/UIxMailAccountActions.m (_jsonFolders:) - we + use a local autorelease pool in the tight loop to avoid consuming + too many LDAP connections during its execution. + 2011-12-23 Francis Lachapelle * UI/Scheduler/UIxAppointmentEditor.m (-viewAction): the end diff --git a/NEWS b/NEWS index a2b419631..9c47c6c0d 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ --------------------- New Features - show end time in bubble box of events + - we now check for new mails in folders for which + sieve rules are defined to file messages into Enhancements - updated Ukrainian translation diff --git a/SoObjects/SOGo/SOGoDomainDefaults.h b/SoObjects/SOGo/SOGoDomainDefaults.h index 02cc332f9..1175039dd 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.h +++ b/SoObjects/SOGo/SOGoDomainDefaults.h @@ -64,7 +64,6 @@ - (NSArray *) calendarDefaultRoles; - (NSArray *) contactsDefaultRoles; - (NSArray *) mailPollingIntervals; -- (BOOL) mailCheckAllUnseenCounts; - (NSString *) calendarDefaultCategoryColor; diff --git a/SoObjects/SOGo/SOGoDomainDefaults.m b/SoObjects/SOGo/SOGoDomainDefaults.m index 6acc35978..8cd5eebd7 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.m +++ b/SoObjects/SOGo/SOGoDomainDefaults.m @@ -208,11 +208,6 @@ return [self arrayForKey: @"SOGoMailPollingIntervals"]; } -- (BOOL) mailCheckAllUnseenCounts -{ - return [self boolForKey: @"SOGoMailCheckAllUnseenCounts"]; -} - - (NSString *) smtpServer { return [self stringForKey: @"SOGoSMTPServer"]; diff --git a/UI/MailerUI/UIxMailAccountActions.m b/UI/MailerUI/UIxMailAccountActions.m index 60adae168..0a9327135 100644 --- a/UI/MailerUI/UIxMailAccountActions.m +++ b/UI/MailerUI/UIxMailAccountActions.m @@ -3,6 +3,7 @@ * Copyright (C) 2007-2011 Inverse inc. * * Author: Wolfgang Sourdeau + * Ludovic Marcotte * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +22,7 @@ */ #import +#import #import #import #import @@ -122,10 +124,16 @@ SOGoUserManager *userManager; NSDictionary *folderData; NSMutableArray *folders; + NSAutoreleasePool *pool; folders = [NSMutableArray array]; while ((currentFolder = [rawFolders nextObject])) { + // Using a local pool to avoid using too many file descriptors. This could + // happen with tons of mailboxes under "Other Users" as LDAP connections + // are never reused and "autoreleased" at the end. This loop would consume + // lots of LDAP connections during its execution. + pool = [[NSAutoreleasePool alloc] init]; currentFolderType = [self _folderType: currentFolder]; // We translate the "Other Users" and "Shared Folders" namespaces. @@ -169,6 +177,7 @@ currentDisplayName, @"displayName", nil]; [folders addObject: folderData]; + [pool release]; } return folders; diff --git a/UI/MailerUI/UIxMailMainFrame.h b/UI/MailerUI/UIxMailMainFrame.h index 177e3fd5e..a7d5ecf49 100644 --- a/UI/MailerUI/UIxMailMainFrame.h +++ b/UI/MailerUI/UIxMailMainFrame.h @@ -1,6 +1,6 @@ /* UIxMailMainFrame.h - this file is part of SOGo * - * Copyright (C) 2006 Inverse inc. + * Copyright (C) 2006-2011 Inverse inc. * * Author: Wolfgang Sourdeau * diff --git a/UI/MailerUI/UIxMailMainFrame.m b/UI/MailerUI/UIxMailMainFrame.m index 8183089e9..746196fe1 100644 --- a/UI/MailerUI/UIxMailMainFrame.m +++ b/UI/MailerUI/UIxMailMainFrame.m @@ -2,6 +2,9 @@ Copyright (C) 2007-2011 Inverse inc. Copyright (C) 2004-2005 SKYRIX Software AG + Author: Wolfgang Sourdeau + Ludovic Marcotte + This file is part of SOGo. SOGo is free software; you can redistribute it and/or modify it under @@ -626,14 +629,55 @@ return [self labelForKey: [currentColumn objectForKey: @"value"]]; } -- (NSString *) getUnseenCountForAllFolders +- (NSString *) unseenCountFolders { - SOGoDomainDefaults *dd; + NSArray *pathComponents, *filters, *actions; + NSDictionary *d, *action; + NSMutableArray *folders; + NSMutableString *path; + SOGoUserDefaults *ud; + NSString *s; + int i, j, k; - dd = [[context activeUser] domainDefaults]; + ud = [[context activeUser] userDefaults]; + folders = [NSMutableArray array]; - return ([dd mailCheckAllUnseenCounts] ? @"true" : @"false"); + filters = [ud sieveFilters]; + + for (i = 0; i < [filters count]; i++) + { + d = [filters objectAtIndex: i]; + actions = [d objectForKey: @"actions"]; + + for (j = 0; j < [actions count]; j++) + { + action = [actions objectAtIndex: j]; + + if ([[action objectForKey: @"method"] caseInsensitiveCompare: @"fileinto"] == NSOrderedSame) + { + s = [action objectForKey: @"argument"]; + + // We format the result string so that MailerUI.js can simply consume that information + // without doing anything special on its side + if (s) + { + pathComponents = [s componentsSeparatedByString: @"/"]; + path = [NSMutableString string]; + + for (k = 0; k < [pathComponents count]; k++) + { + [path appendFormat: @"folder%@", [[pathComponents objectAtIndex: k] asCSSIdentifier]]; + if (k < [pathComponents count] - 1) + [path appendString: @"/"]; + } + + [folders addObject: [NSString stringWithFormat: @"/0/%@", path]]; + } + } + } + } + + return [folders jsonRepresentation]; } @end /* UIxMailMainFrame */ - diff --git a/UI/Templates/MailerUI/UIxMailMainFrame.wox b/UI/Templates/MailerUI/UIxMailMainFrame.wox index 65086f0d5..5d5a0991b 100644 --- a/UI/Templates/MailerUI/UIxMailMainFrame.wox +++ b/UI/Templates/MailerUI/UIxMailMainFrame.wox @@ -13,7 +13,7 @@