From d5810542148c9ce4c2e743786b91b7f793c7c7f2 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 10 Apr 2015 09:44:30 -0400 Subject: [PATCH] (fix) fixed default values for many prefs --- SoObjects/SOGo/SOGoDefaults.plist | 8 +- SoObjects/SOGo/SOGoUserProfile.h | 4 +- SoObjects/SOGo/SOGoUserProfile.m | 7 +- UI/Common/WODirectAction+SOGo.h | 4 +- UI/Common/WODirectAction+SOGo.m | 4 +- UI/PreferencesUI/UIxJSONPreferences.m | 101 +++++++++++++++--- UI/PreferencesUI/UIxPreferences.m | 41 ++++--- UI/Templates/PreferencesUI/UIxPreferences.wox | 2 +- .../js/Preferences/preferences-model.js | 7 ++ 9 files changed, 138 insertions(+), 40 deletions(-) diff --git a/SoObjects/SOGo/SOGoDefaults.plist b/SoObjects/SOGo/SOGoDefaults.plist index d0557c666..c4e879310 100644 --- a/SoObjects/SOGo/SOGoDefaults.plist +++ b/SoObjects/SOGo/SOGoDefaults.plist @@ -51,6 +51,8 @@ SOGoTimeFormat = "%H:%M"; SOGoFirstDayOfWeek = 0; SOGoFirstWeekOfYear = "January1"; + SOGoShortDateFormat = "default"; + SOGoLongDateFormat = "default"; SOGoIMAPServer = "localhost"; SOGoMailDomain = "localhost"; @@ -67,6 +69,8 @@ SOGoSentFolderName = "Sent"; SOGoDraftsFolderName = "Drafts"; SOGoTrashFolderName = "Trash"; + SOGoMailComposeMessageType = "html"; + SOGoMailDisplayRemoteInlineImages = "never"; SOGoMailAutoSave = "5"; @@ -74,9 +78,11 @@ SOGoCalendarEventsDefaultClassification = "PUBLIC"; SOGoCalendarTasksDefaultClassification = "PUBLIC"; SOGoCalendarDefaultReminder = "NONE"; - + SOGoDefaultCalendar = "selected"; SOGoFreeBusyDefaultInterval = ( 7, 7 ); + SOGoSelectedAddressBook = "personal"; + SOGoSearchMinimumWordLength = 2; SOGoMailLabelsColors = { diff --git a/SoObjects/SOGo/SOGoUserProfile.h b/SoObjects/SOGo/SOGoUserProfile.h index d0248dc8f..c792a7c27 100644 --- a/SoObjects/SOGo/SOGoUserProfile.h +++ b/SoObjects/SOGo/SOGoUserProfile.h @@ -1,6 +1,5 @@ /* - Copyright (C) 2008-2009 Inverse inc. - Copyright (C) 2005 SKYRIX Software AG + Copyright (C) 2008-2015 Inverse inc. This file is part of SOGo. @@ -81,6 +80,7 @@ typedef enum _SOGoUserProfileType { /* saving changes */ +- (BOOL) dirty; - (BOOL) synchronize; @end diff --git a/SoObjects/SOGo/SOGoUserProfile.m b/SoObjects/SOGo/SOGoUserProfile.m index 87d0b2c2c..02d911f6a 100644 --- a/SoObjects/SOGo/SOGoUserProfile.m +++ b/SoObjects/SOGo/SOGoUserProfile.m @@ -1,6 +1,5 @@ /* - Copyright (C) 2008-2009 Inverse inc. - Copyright (C) 2005 SKYRIX Software AG + Copyright (C) 2008-2015 Inverse inc. This file is part of SOGo. @@ -323,6 +322,10 @@ } /* saving changes */ +- (BOOL) dirty +{ + return defFlags.modified; +} - (BOOL) synchronize { diff --git a/UI/Common/WODirectAction+SOGo.h b/UI/Common/WODirectAction+SOGo.h index e08de93c7..aa4e5094c 100644 --- a/UI/Common/WODirectAction+SOGo.h +++ b/UI/Common/WODirectAction+SOGo.h @@ -1,8 +1,6 @@ /* WODirectAction+SOGo.h - this file is part of SOGo * - * Copyright (C) 2007 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-2015 Inverse inc. * * 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 diff --git a/UI/Common/WODirectAction+SOGo.m b/UI/Common/WODirectAction+SOGo.m index bd8ae3461..9b9675d3a 100644 --- a/UI/Common/WODirectAction+SOGo.m +++ b/UI/Common/WODirectAction+SOGo.m @@ -1,8 +1,6 @@ /* WODirectAction+SOGo.m - this file is part of SOGo * - * Copyright (C) 2007-2012 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-2015 Inverse inc. * * 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 diff --git a/UI/PreferencesUI/UIxJSONPreferences.m b/UI/PreferencesUI/UIxJSONPreferences.m index 610a712f1..55764218b 100644 --- a/UI/PreferencesUI/UIxJSONPreferences.m +++ b/UI/PreferencesUI/UIxJSONPreferences.m @@ -20,6 +20,7 @@ #import +#import #import #import #import @@ -37,6 +38,8 @@ #import "UIxJSONPreferences.h" +static SoProduct *preferencesProduct = nil; + @implementation UIxJSONPreferences - (WOResponse *) _makeResponse: (NSDictionary *) values @@ -55,39 +58,87 @@ { NSMutableDictionary *values; SOGoUserDefaults *defaults; + NSMutableArray *accounts; NSArray *categoryLabels; BOOL dirty; - defaults = [[context activeUser] userDefaults]; - dirty = NO; + if (!preferencesProduct) + { + preferencesProduct = [[SoProduct alloc] initWithBundle: + [NSBundle bundleForClass: NSClassFromString(@"PreferencesUIProduct")]]; + } + defaults = [[context activeUser] userDefaults]; + + // + // Default General preferences + // + if (![[defaults source] objectForKey: @"SOGoLanguage"]) + [[defaults source] setObject: [defaults language] forKey: @"SOGoLanguage"]; + + if (![[defaults source] objectForKey: @"SOGoTimeZone"]) + [[defaults source] setObject: [defaults timeZoneName] forKey: @"SOGoTimeZone"]; + if (![[defaults source] objectForKey: @"SOGoShortDateFormat"]) - [[defaults source] setObject: @"default" forKey: @"SOGoShortDateFormat"]; + [[defaults source] setObject: [defaults shortDateFormat] forKey: @"SOGoShortDateFormat"]; if (![[defaults source] objectForKey: @"SOGoLongDateFormat"]) - [[defaults source] setObject: @"default" forKey: @"SOGoLongDateFormat"]; + [[defaults source] setObject: [defaults longDateFormat] forKey: @"SOGoLongDateFormat"]; + if (![[defaults source] objectForKey: @"SOGoTimeFormat"]) + [[defaults source] setObject: [defaults timeFormat] forKey: @"SOGoTimeFormat"]; + + if (![[defaults source] objectForKey: @"SOGoLoginModule"]) + [[defaults source] setObject: [defaults loginModule] forKey: @"SOGoLoginModule"]; + + if (![[defaults source] objectForKey: @"SOGoRefreshViewCheck"]) + [[defaults source] setObject: [defaults refreshViewCheck] forKey: @"SOGoRefreshViewCheck"]; + + // + // Default Calendar preferences + // + if (![[defaults source] objectForKey: @"SOGoFirstDayOfWeek"]) + [[defaults source] setObject: [NSNumber numberWithInt: [defaults firstDayOfWeek]] forKey: @"SOGoFirstDayOfWeek"]; + + if (![[defaults source] objectForKey: @"SOGoDayStartTime"]) + [[defaults source] setObject: [NSString stringWithFormat: @"%02d:00", [defaults dayStartHour]] forKey: @"SOGoDayStartTime"]; + + if (![[defaults source] objectForKey: @"SOGoDayEndTime"]) + [[defaults source] setObject: [NSString stringWithFormat: @"%02d:00", [defaults dayEndHour]] forKey: @"SOGoDayEndTime"]; + if (![[defaults source] objectForKey: @"SOGoFirstWeekOfYear"]) [[defaults source] setObject: [defaults firstWeekOfYear] forKey: @"SOGoFirstWeekOfYear"]; + + if (![[defaults source] objectForKey: @"SOGoDefaultCalendar"]) + [[defaults source] setObject: [defaults defaultCalendar] forKey: @"SOGoDefaultCalendar"]; + + if (![[defaults source] objectForKey: @"SOGoCalendarEventsDefaultClassification"]) + [[defaults source] setObject: [defaults calendarEventsDefaultClassification] forKey: @"SOGoCalendarEventsDefaultClassification"]; - if (![[defaults source] objectForKey: @"SOGoSelectedAddressBook"]) - [[defaults source] setObject: @"personal" forKey: @"SOGoSelectedAddressBook"]; + if (![[defaults source] objectForKey: @"SOGoCalendarTasksDefaultClassification"]) + [[defaults source] setObject: [defaults calendarTasksDefaultClassification] forKey: @"SOGoCalendarTasksDefaultClassification"]; + + if (![[defaults source] objectForKey: @"SOGoCalendarDefaultReminder"]) + [[defaults source] setObject: [defaults calendarDefaultReminder] forKey: @"SOGoCalendarDefaultReminder"]; // Populate default calendar categories, based on the user's preferred language if (![defaults calendarCategories]) { - categoryLabels = [[[self labelForKey: @"calendar_category_labels"] + categoryLabels = [[[self labelForKey: @"calendar_category_labels" withResourceManager: [preferencesProduct resourceManager]] componentsSeparatedByString: @","] sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)]; [defaults setCalendarCategories: categoryLabels]; - dirty = YES; } + // + // Default Contacts preferences + // // Populate default contact categories, based on the user's preferred language + // if (![defaults contactsCategories]) { - categoryLabels = [[[self labelForKey: @"contacts_category_labels"] + categoryLabels = [[[self labelForKey: @"contacts_category_labels" withResourceManager: [preferencesProduct resourceManager]] componentsSeparatedByString: @","] sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)]; @@ -95,8 +146,28 @@ categoryLabels = [NSArray array]; [defaults setContactsCategories: categoryLabels]; - dirty = YES; } + + // + // Default Mail preferences + // + if (![[defaults source] objectForKey: @"SOGoSelectedAddressBook"]) + [[defaults source] setObject: [defaults selectedAddressBook] forKey: @"SOGoSelectedAddressBook"]; + + if (![[defaults source] objectForKey: @"SOGoMailMessageForwarding"]) + [[defaults source] setObject: [defaults mailMessageForwarding] forKey: @"SOGoMailMessageForwarding"]; + + if (![[defaults source] objectForKey: @"SOGoMailReplyPlacement"]) + [[defaults source] setObject: [defaults mailReplyPlacement] forKey: @"SOGoMailReplyPlacement"]; + + if (![[defaults source] objectForKey: @"SOGoMailSignaturePlacement"]) + [[defaults source] setObject: [defaults mailSignaturePlacement] forKey: @"SOGoMailSignaturePlacement"]; + + if (![[defaults source] objectForKey: @"SOGoMailComposeMessageType"]) + [[defaults source] setObject: [defaults mailComposeMessageType] forKey: @"SOGoMailComposeMessageType"]; + + if (![[defaults source] objectForKey: @"SOGoMailDisplayRemoteInlineImages"]) + [[defaults source] setObject: [defaults mailDisplayRemoteInlineImages] forKey: @"SOGoMailDisplayRemoteInlineImages"]; // Populate default mail lablels, based on the user's preferred language if (![[defaults source] objectForKey: @"SOGoMailLabelsColors"]) @@ -119,17 +190,19 @@ } [defaults setMailLabelsColors: v]; - dirty = YES; } - if (dirty) + if ([[defaults source] dirty]) [defaults synchronize]; // We inject our default mail account, something we don't want to do before we // call -synchronize on our defaults. values = [[[[defaults source] values] mutableCopy] autorelease]; - [[values objectForKey: @"AuxiliaryMailAccounts"] insertObject: [[[context activeUser] mailAccounts] objectAtIndex: 0] - atIndex: 0]; + + accounts = [NSMutableArray arrayWithArray: [values objectForKey: @"AuxiliaryMailAccounts"]]; + [accounts insertObject: [[[context activeUser] mailAccounts] objectAtIndex: 0] + atIndex: 0]; + [values setObject: accounts forKey: @"AuxiliaryMailAccounts"]; return [self _makeResponse: values]; } diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index 67c344bf5..a0be42acd 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -67,7 +67,8 @@ static NSArray *reminderValues = nil; if (!reminderItems && !reminderValues) { reminderItems = [NSArray arrayWithObjects: - @"5_MINUTES_BEFORE", + @"NONE", + @"5_MINUTES_BEFORE", @"10_MINUTES_BEFORE", @"15_MINUTES_BEFORE", @"30_MINUTES_BEFORE", @@ -83,7 +84,8 @@ static NSArray *reminderValues = nil; @"1_WEEK_BEFORE", nil]; reminderValues = [NSArray arrayWithObjects: - @"-PT5M", + @"NONE", + @"-PT5M", @"-PT10M", @"-PT15M", @"-PT30M", @@ -575,9 +577,9 @@ static NSArray *reminderValues = nil; // // Used by wox template // -- (NSArray *) reminderList +- (NSArray *) reminderValues { - return reminderItems; + return reminderValues; } // @@ -587,10 +589,19 @@ static NSArray *reminderValues = nil; { NSString *text; - if ([item isEqualToString: @"-"]) - text = item; + if ([item isEqualToString: @""]) + text = @"-"; else - text = [self labelForKey: [NSString stringWithFormat: @"reminder_%@", item]]; + { + NSUInteger index; + + index = [reminderValues indexOfObject: item]; + + if (index != NSNotFound) + text = [self labelForKey: [NSString stringWithFormat: @"reminder_%@", [reminderItems objectAtIndex: index]]]; + else + text = @"NONE"; + } return text; } @@ -2087,12 +2098,17 @@ static NSArray *reminderValues = nil; NSArray *allKeys, *accounts, *addresses; NSMutableDictionary *sanitizedLabels; NSDictionary *newLabels; - NSString *name; + NSString *name, *reminder; + + NSUInteger index; int i; // We convert our object into a mutable one v = [[v mutableCopy] autorelease]; - + + // + // We sanitize mail labels + // newLabels = [v objectForKey: @"SOGoMailLabelsColors"]; if (newLabels && [newLabels isKindOfClass: [NSDictionary class]]) { @@ -2116,12 +2132,9 @@ static NSArray *reminderValues = nil; [v setObject: sanitizedLabels forKey: @"SOGoMailLabelsColors"]; } - // We sanitize our autoreply email addresses - addresses = [NSArray arrayWithArray: [[[[v objectForKey: @"Vacation"] objectForKey: @"autoReplyEmailAddresses"] - componentsSeparatedByString: @","] trimmedComponents]]; - [[v objectForKey: @"Vacation"] setObject: addresses forKey: @"autoReplyEmailAddresses"]; - + // // We sanitize our auxilary mail accounts + // accounts = [v objectForKey: @"AuxiliaryMailAccounts"]; if (accounts && [accounts isKindOfClass: [NSArray class]]) { diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index 89b07ef66..3f43dec70 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -386,7 +386,7 @@
- + diff --git a/UI/WebServerResources/js/Preferences/preferences-model.js b/UI/WebServerResources/js/Preferences/preferences-model.js index 6ff38a2b4..d4efdbb35 100644 --- a/UI/WebServerResources/js/Preferences/preferences-model.js +++ b/UI/WebServerResources/js/Preferences/preferences-model.js @@ -26,6 +26,10 @@ })); data.SOGoMailLabelsColors = labels; + + // We convert our list of autoReplyEmailAddresses into a string. + if (data.Vacation && data.Vacation.autoReplyEmailAddresses) + data.Vacation.autoReplyEmailAddresses = data.Vacation.autoReplyEmailAddresses.join(","); angular.extend(_this.defaults, data); }); @@ -105,6 +109,9 @@ preferences.defaults.SOGoMailLabelsColors = labels; + if (preferences.defaults.Vacation && preferences.defaults.Vacation.autoReplyEmailAddresses) + preferences.defaults.Vacation.autoReplyEmailAddresses = preferences.defaults.Vacation.autoReplyEmailAddresses.split(","); + return preferences; };