Fix saving preferences with no Sieve requirements

Fixes #2746
pull/37/merge
Francis Lachapelle 2014-05-01 14:07:25 -04:00
parent 4e42a6a689
commit 0b9afec635
2 changed files with 30 additions and 29 deletions

5
NEWS
View File

@ -2,12 +2,13 @@
------------------ ------------------
Enhancements Enhancements
- now able to emails to address book on send (#1496) - now able to save unknown recipient emails to address book on send (#1496)
- Sieve folder encoding is now configurable (#2622) - Sieve folder encoding is now configurable (#2622)
- SOGo version is now displayed in preferences window (#2612) - SOGo version is now displayed in preferences window (#2612)
- report Sieve error when saving preferences (#1046)
- added the SOGoMaximumSyncWindowSize system default to overwrite the - added the SOGoMaximumSyncWindowSize system default to overwrite the
maximum number of items returned during an ActiveSync sync operation maximum number of items returned during an ActiveSync sync operation
- updated datepicker - updated datepicker
Bug fixes Bug fixes
- fixed saved HTML content of draft when attaching a file - fixed saved HTML content of draft when attaching a file

View File

@ -114,7 +114,7 @@ static NSArray *reminderValues = nil;
- (id) init - (id) init
{ {
SOGoDomainDefaults *dd; SOGoDomainDefaults *dd;
if ((self = [super init])) if ((self = [super init]))
{ {
item = nil; item = nil;
@ -131,7 +131,7 @@ static NSArray *reminderValues = nil;
label = nil; label = nil;
mailLabels = nil; mailLabels = nil;
ASSIGN (daysOfWeek, [locale objectForKey: NSWeekDayNameArray]); ASSIGN (daysOfWeek, [locale objectForKey: NSWeekDayNameArray]);
dd = [user domainDefaults]; dd = [user domainDefaults];
@ -227,7 +227,7 @@ static NSArray *reminderValues = nil;
NSEnumerator *zones; NSEnumerator *zones;
BOOL found; BOOL found;
unsigned int offset; unsigned int offset;
found = NO; found = NO;
now = [NSCalendarDate calendarDate]; now = [NSCalendarDate calendarDate];
offset = [[userDefaults timeZone] secondsFromGMTForDate: now]; offset = [[userDefaults timeZone] secondsFromGMTForDate: now];
@ -345,7 +345,7 @@ static NSArray *reminderValues = nil;
if (![longDateFormatsList containsObject: [self userLongDateFormat]]) if (![longDateFormatsList containsObject: [self userLongDateFormat]])
[longDateFormatsList addObject: [self userLongDateFormat]]; [longDateFormatsList addObject: [self userLongDateFormat]];
return longDateFormatsList; return longDateFormatsList;
} }
@ -371,7 +371,7 @@ static NSArray *reminderValues = nil;
- (NSString *) userLongDateFormat - (NSString *) userLongDateFormat
{ {
NSString *longDateFormat; NSString *longDateFormat;
longDateFormat = [userDefaults longDateFormat]; longDateFormat = [userDefaults longDateFormat];
if (!longDateFormat) if (!longDateFormat)
longDateFormat = @"default"; longDateFormat = @"default";
@ -563,7 +563,7 @@ static NSArray *reminderValues = nil;
index = NSNotFound; index = NSNotFound;
value = @"NONE"; value = @"NONE";
if (theReminder && [theReminder caseInsensitiveCompare: @"-"] != NSOrderedSame) if (theReminder && [theReminder caseInsensitiveCompare: @"-"] != NSOrderedSame)
index = [reminderItems indexOfObject: theReminder]; index = [reminderItems indexOfObject: theReminder];
@ -586,7 +586,7 @@ static NSArray *reminderValues = nil;
if (index != NSNotFound) if (index != NSNotFound)
return [reminderItems objectAtIndex: index]; return [reminderItems objectAtIndex: index];
} }
return @"NONE"; return @"NONE";
} }
@ -702,31 +702,31 @@ static NSArray *reminderValues = nil;
int i, count; int i, count;
BOOL collectedAlreadyExist; BOOL collectedAlreadyExist;
contactFolders = [[[context activeUser] homeFolderInContext: context] contactFolders = [[[context activeUser] homeFolderInContext: context]
lookupName: @"Contacts" lookupName: @"Contacts"
inContext: context inContext: context
acquire: NO]; acquire: NO];
folders = [NSMutableArray arrayWithArray: [contactFolders subFolders]]; folders = [NSMutableArray arrayWithArray: [contactFolders subFolders]];
count = [folders count]-1; count = [folders count]-1;
// Inside this loop we remove all the public or shared addressbooks // Inside this loop we remove all the public or shared addressbooks
for (; count >= 0; count--) for (; count >= 0; count--)
{ {
if (![[folders objectAtIndex: count] isKindOfClass: [SOGoContactGCSFolder class]]) if (![[folders objectAtIndex: count] isKindOfClass: [SOGoContactGCSFolder class]])
[folders removeObjectAtIndex: count]; [folders removeObjectAtIndex: count];
} }
// Parse the objects in order to have only the displayName of the addressbooks to be displayed on the preferences interface // Parse the objects in order to have only the displayName of the addressbooks to be displayed on the preferences interface
availableAddressBooksID = [NSMutableArray arrayWithCapacity: [folders count]]; availableAddressBooksID = [NSMutableArray arrayWithCapacity: [folders count]];
availableAddressBooksName = [NSMutableArray arrayWithCapacity: [folders count]]; availableAddressBooksName = [NSMutableArray arrayWithCapacity: [folders count]];
count = [folders count]-1; count = [folders count]-1;
collectedAlreadyExist = NO; collectedAlreadyExist = NO;
for (i = 0; i <= count ; i++) { for (i = 0; i <= count ; i++) {
[availableAddressBooksID addObject:[[folders objectAtIndex:i] realNameInContainer]]; [availableAddressBooksID addObject:[[folders objectAtIndex:i] realNameInContainer]];
[availableAddressBooksName addObject:[[folders objectAtIndex:i] displayName]]; [availableAddressBooksName addObject:[[folders objectAtIndex:i] displayName]];
if ([[availableAddressBooksID objectAtIndex:i] isEqualToString: @"collected"]) if ([[availableAddressBooksID objectAtIndex:i] isEqualToString: @"collected"])
collectedAlreadyExist = YES; collectedAlreadyExist = YES;
} }
@ -739,7 +739,7 @@ static NSArray *reminderValues = nil;
[availableAddressBooksID addObject: @"collected"]; [availableAddressBooksID addObject: @"collected"];
[addressBooksIDWithDisplayName setObject: [self labelForKey: @"Collected Address Book"] forKey: @"collected"]; [addressBooksIDWithDisplayName setObject: [self labelForKey: @"Collected Address Book"] forKey: @"collected"];
} }
return availableAddressBooksID; return availableAddressBooksID;
} }
- (NSString *) itemAddressBookText - (NSString *) itemAddressBookText
@ -1010,7 +1010,7 @@ static NSArray *reminderValues = nil;
- (NSString *) autoReplyEmailAddresses - (NSString *) autoReplyEmailAddresses
{ {
NSArray *addressesList; NSArray *addressesList;
addressesList = [vacationOptions objectForKey: @"autoReplyEmailAddresses"]; addressesList = [vacationOptions objectForKey: @"autoReplyEmailAddresses"];
return (addressesList return (addressesList
@ -1089,7 +1089,7 @@ static NSArray *reminderValues = nil;
- (void) setVacationEndDate: (NSCalendarDate *) endDate - (void) setVacationEndDate: (NSCalendarDate *) endDate
{ {
NSNumber *time; NSNumber *time;
time = [NSNumber numberWithInt: [endDate timeIntervalSince1970]]; time = [NSNumber numberWithInt: [endDate timeIntervalSince1970]];
[vacationOptions setObject: time forKey: @"endDate"]; [vacationOptions setObject: time forKey: @"endDate"];
@ -1218,7 +1218,7 @@ static NSArray *reminderValues = nil;
SOGoMailAccount *account; SOGoMailAccount *account;
SOGoMailAccounts *folder; SOGoMailAccounts *folder;
SOGoSieveManager *manager; SOGoSieveManager *manager;
if (!client) if (!client)
{ {
folder = [[self clientObject] mailAccountsFolder: @"Mail" inContext: context]; folder = [[self clientObject] mailAccountsFolder: @"Mail" inContext: context];
@ -1226,7 +1226,7 @@ static NSArray *reminderValues = nil;
manager = [SOGoSieveManager sieveManagerForUser: [context activeUser]]; manager = [SOGoSieveManager sieveManagerForUser: [context activeUser]];
client = [[manager clientForAccount: account] retain]; client = [[manager clientForAccount: account] retain];
} }
return client; return client;
} }
@ -1244,7 +1244,7 @@ static NSArray *reminderValues = nil;
SOGoMailAccount *account; SOGoMailAccount *account;
SOGoMailAccounts *folder; SOGoMailAccounts *folder;
WORequest *request; WORequest *request;
request = [context request]; request = [context request];
if ([[request method] isEqualToString: @"POST"]) if ([[request method] isEqualToString: @"POST"])
{ {
@ -1255,18 +1255,18 @@ static NSArray *reminderValues = nil;
[userDefaults setVacationOptions: vacationOptions]; [userDefaults setVacationOptions: vacationOptions];
if ([dd forwardEnabled]) if ([dd forwardEnabled])
[userDefaults setForwardOptions: forwardOptions]; [userDefaults setForwardOptions: forwardOptions];
if ([self isSieveServerAvailable]) if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled]) || [self isSieveServerAvailable])
{ {
[userDefaults synchronize]; [userDefaults synchronize];
folder = [[self clientObject] mailAccountsFolder: @"Mail" folder = [[self clientObject] mailAccountsFolder: @"Mail"
inContext: context]; inContext: context];
account = [folder lookupName: @"0" inContext: context acquire: NO]; account = [folder lookupName: @"0" inContext: context acquire: NO];
if ([account updateFilters]) if ([account updateFilters])
results = [self responseWithStatus: 200 results = [self responseWithStatus: 200
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:hasChanged], @"hasChanged", nil]]; andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:hasChanged], @"hasChanged", nil]];
else else
results = [self responseWithStatus: 502 results = [self responseWithStatus: 502
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Connection error", @"textStatus", nil]]; andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Connection error", @"textStatus", nil]];
@ -1353,11 +1353,11 @@ static NSArray *reminderValues = nil;
if (!mailLabels) if (!mailLabels)
{ {
NSDictionary *v; NSDictionary *v;
v = [[[context activeUser] userDefaults] mailLabelsColors]; v = [[[context activeUser] userDefaults] mailLabelsColors];
ASSIGN(mailLabels, [SOGoMailLabel labelsFromDefaults: v component: self]); ASSIGN(mailLabels, [SOGoMailLabel labelsFromDefaults: v component: self]);
} }
return mailLabels; return mailLabels;
} }
@ -1456,7 +1456,7 @@ static NSArray *reminderValues = nil;
componentsSeparatedByString: @","]; componentsSeparatedByString: @","];
if (!categoryLabels) if (!categoryLabels)
categoryLabels = [NSArray array]; categoryLabels = [NSArray array];
return [categoryLabels trimmedComponents]; return [categoryLabels trimmedComponents];
} }
@ -1572,7 +1572,7 @@ static NSArray *reminderValues = nil;
action = [receipts objectForKey: @"receiptAction"]; action = [receipts objectForKey: @"receiptAction"];
[userDefaults [userDefaults
setAllowUserReceipt: [action isEqualToString: @"allow"]]; setAllowUserReceipt: [action isEqualToString: @"allow"]];
action = [receipts objectForKey: @"receiptNonRecipientAction"]; action = [receipts objectForKey: @"receiptNonRecipientAction"];
if ([self _validateReceiptAction: action]) if ([self _validateReceiptAction: action])
[userDefaults setUserReceiptNonRecipientAction: action]; [userDefaults setUserReceiptNonRecipientAction: action];
@ -1580,7 +1580,7 @@ static NSArray *reminderValues = nil;
action = [receipts objectForKey: @"receiptOutsideDomainAction"]; action = [receipts objectForKey: @"receiptOutsideDomainAction"];
if ([self _validateReceiptAction: action]) if ([self _validateReceiptAction: action])
[userDefaults setUserReceiptOutsideDomainAction: action]; [userDefaults setUserReceiptOutsideDomainAction: action];
action = [receipts objectForKey: @"receiptAnyAction"]; action = [receipts objectForKey: @"receiptAnyAction"];
if ([self _validateReceiptAction: action]) if ([self _validateReceiptAction: action])
[userDefaults setUserReceiptAnyAction: action]; [userDefaults setUserReceiptAnyAction: action];