From 8414c7bfec99649af39e3123334efaa30c7c18a4 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Fri, 9 Oct 2009 20:30:42 +0000 Subject: [PATCH] Added web elements to set an auto-reply message and forward address in the preferences window. Monotone-Parent: 3862a22ce756fbd4c559e0d9a9a211821d9c597b Monotone-Revision: baa7bc0bc74871932c7f4e4d759f25a216d0c939 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2009-10-09T20:30:42 Monotone-Branch: ca.inverse.sogo --- .../English.lproj/Localizable.strings | 24 +- .../French.lproj/Localizable.strings | 24 +- UI/PreferencesUI/UIxPreferences.h | 3 +- UI/PreferencesUI/UIxPreferences.m | 214 +++++++++++++++--- UI/Templates/PreferencesUI/UIxPreferences.wox | 96 ++++++-- UI/WebServerResources/UIxPreferences.css | 14 +- UI/WebServerResources/UIxPreferences.js | 15 ++ 7 files changed, 325 insertions(+), 65 deletions(-) diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index e6dae4541..9d0a91a69 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -6,6 +6,9 @@ "General" = "General"; "Calendar Options" = "Calendar Options"; "Mail Options" = "Mail Options"; +"Signature" = "Signature"; +"Vacation" = "Vacation"; +"Forward" = "Forward"; "Identities" = "Identities"; "Password" = "Password"; "Categories" = "Categories"; @@ -14,11 +17,21 @@ "Add" = "Add"; "Delete" = "Delete"; -/* ooo */ -"I'm currently in the office" = "I'm currently in the office"; -"I'm currently out of the office" = "I'm currently out of the office"; -"AutoReply only once to each sender with the following text :" -= "AutoReply only once to each sender with the following text :"; +/* vacation (auto-reply) */ +"Enable vacation auto reply" = "Enable vacation auto reply"; +"Auto reply message :" = "Auto reply message :"; +"Email addresses (separated by commas) :" = "Email addresses (separated by commas) :"; +"Days between responses :" = "Days between responses :"; +"Do not send responses to mailing lists" = "Do not send responses to mailing lists"; +"Please specify your message and your email addresses for which you want to enable auto reply." += "Please specify your message and your email addresses for which you want to enable auto reply."; + +/* forward messages */ +"Forward incoming messages" = "Forward incoming messages"; +"Forward to address :" = "Forward to address :"; +"Keep a copy" = "Keep a copy"; +"Please specify an address to which you want to forward your messages." += "Please specify an address to which you want to forward your messages."; /* d & t */ "Current Time Zone :" = "Current Time Zone :"; @@ -108,7 +121,6 @@ /* Identities */ "Default identity:" = "Default identity:"; "Manage identities..." = "Manage identities..."; -"Signature" = "Signature"; "replyplacement_above" = "Start my reply above the quote"; "replyplacement_below" = "Start my reply below the quote"; "And place my signature" = "And place my signature"; diff --git a/UI/PreferencesUI/French.lproj/Localizable.strings b/UI/PreferencesUI/French.lproj/Localizable.strings index d32781dad..d4a24d5df 100644 --- a/UI/PreferencesUI/French.lproj/Localizable.strings +++ b/UI/PreferencesUI/French.lproj/Localizable.strings @@ -6,6 +6,8 @@ "General" = "Général"; "Calendar Options" = "Calendrier"; "Mail Options" = "Courrier"; +"Vacation" = "Absence prolongée"; +"Forward" = "Transfert"; "Identities" = "Identités"; "Password" = "Mot de passe"; "Categories" = "Catégories"; @@ -14,11 +16,21 @@ "Add" = "Ajouter"; "Delete" = "Supprimer"; -/* ooo */ -"I'm currently in the office" = "Je suis présent"; -"I'm currently out of the office" = "Je suis absent"; -"AutoReply only once to each sender with the following text :" -= "Répondre automatiquement avec le texte suivant, une seule fois par expéditeur :"; +/* vacation (auto-reply) */ +"Enable vacation auto reply" = "Enable vacation auto reply"; +"Auto reply message :" = "Auto reply message :"; +"Email addresses (separated by commas) :" = "Email addresses (separated by commas) :"; +"Days between responses :" = "Days between responses :"; +"Do not send responses to mailing lists" = "Do not send responses to mailing lists"; +"Please specify your message and your email addresses for which you want to enable auto reply." += "Veuillez définir un message et vos adresses pour lesquelles pour désirez activer une réponse automatique."; + +/* forward messages */ +"Forward incoming messages" = "Forward incoming messages"; +"Forward to address :" = "Forward to address :"; +"Keep a copy" = "Keep a copy"; +"Please specify an address to which you want to forward your messages." += "Veuillez définir une adresse à laquelle vous désirez transférer automatiquement vos nouveaux messages."; /* d & t */ "Current Time Zone :" = "Fuseau horaire en cours :"; @@ -26,6 +38,8 @@ "Long Date Format :" = "Style de date longue :"; "Time Format :" = "Style de l'heure :"; +"default" = "Défaut"; + "shortDateFmt_0" = "%d-%b-%y"; "shortDateFmt_1" = "%d-%m-%y"; diff --git a/UI/PreferencesUI/UIxPreferences.h b/UI/PreferencesUI/UIxPreferences.h index fa37317ae..20190bf54 100644 --- a/UI/PreferencesUI/UIxPreferences.h +++ b/UI/PreferencesUI/UIxPreferences.h @@ -38,7 +38,8 @@ NSUserDefaults *userDefaults; NSCalendarDate *today; NSMutableArray *hours; - NSArray *daysOfWeek; + NSArray *daysOfWeek, *daysBetweenResponsesList; + NSMutableDictionary *vacationOptions, *forwardOptions; BOOL hasChanged, composeMessageTypeHasChanged; } diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index dc41c87f2..6a143ea11 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -25,6 +25,7 @@ #import #import #import +#import #import #import @@ -48,6 +49,8 @@ static BOOL defaultsRead = NO; static BOOL shouldDisplayPasswordChange = NO; static BOOL shouldDisplayAdditionalPreferences = NO; static BOOL defaultShowSubscribedFoldersOnly = NO; +static BOOL vacationEnabled = NO; +static BOOL forwardEnabled = NO; @implementation UIxPreferences @@ -64,6 +67,10 @@ static BOOL defaultShowSubscribedFoldersOnly = NO; = [ud boolForKey: @"SOGoUIxAdditionalPreferences"]; defaultShowSubscribedFoldersOnly = [ud boolForKey: @"SOGoMailShowSubscribedFoldersOnly"]; + vacationEnabled + = [ud boolForKey: @"SOGoVacationEnabled"]; + forwardEnabled + = [ud boolForKey: @"SOGoForwardEnabled"]; defaultsRead = YES; } } @@ -88,6 +95,25 @@ static BOOL defaultShowSubscribedFoldersOnly = NO; [locale objectForKey: NSWeekDayNameArray]); hasChanged = NO; composeMessageTypeHasChanged = NO; + + if (vacationEnabled) + { + vacationOptions = [userDefaults objectForKey: @"Vacation"]; + if (!vacationOptions) + { + vacationOptions = [NSMutableDictionary dictionary]; + [userDefaults setObject: vacationOptions forKey: @"Vacation"]; + } + } + if (forwardEnabled) + { + forwardOptions = [userDefaults objectForKey: @"Forward"]; + if (!forwardOptions) + { + forwardOptions = [NSMutableDictionary dictionary]; + [userDefaults setObject: forwardOptions forKey: @"Forward"]; + } + } } return self; @@ -125,31 +151,6 @@ static BOOL defaultShowSubscribedFoldersOnly = NO; return item; } -- (NSString *) inTheOffice -{ - NSString *inTheOffice; - - inTheOffice = [userDefaults objectForKey: @"InTheOffice"]; - - return ((!inTheOffice || [inTheOffice boolValue]) - ? @"YES" : @"NO"); -} - -- (void) setInTheOffice: (NSString *) newValue -{ - [userDefaults setObject: newValue forKey: @"InTheOffice"]; -} - -- (void) setAutoReplyText: (NSString *) newAutoReplyText -{ - [userDefaults setObject: newAutoReplyText forKey: @"AutoReplyText"]; -} - -- (NSString *) autoReplyText -{ - return [userDefaults objectForKey: @"AutoReplyText"]; -} - - (NSArray *) timeZonesList { return [[NSTimeZone knownTimeZoneNames] @@ -504,10 +505,7 @@ static BOOL defaultShowSubscribedFoldersOnly = NO; /* Mailer */ - (void) setShowSubscribedFoldersOnly: (BOOL) showSubscribedFoldersOnly { - if (showSubscribedFoldersOnly) - [userDefaults setBool: YES forKey: @"showSubscribedFoldersOnly"]; - else - [userDefaults setBool: NO forKey: @"showSubscribedFoldersOnly"]; + [userDefaults setBool: showSubscribedFoldersOnly forKey: @"showSubscribedFoldersOnly"]; // should be capitalized .. } - (BOOL) showSubscribedFoldersOnly @@ -696,12 +694,168 @@ static BOOL defaultShowSubscribedFoldersOnly = NO; } } - - (void) setUserSignaturePlacement: (NSString *) newSignaturePlacement { [userDefaults setObject: newSignaturePlacement forKey: @"SignaturePlacement"]; } +/* mail autoreply (vacation) */ + +- (BOOL) isVacationEnabled +{ + return vacationEnabled; +} + +- (void) setEnableVacation: (BOOL) enableVacation +{ + [vacationOptions setObject: [NSNumber numberWithBool: enableVacation] + forKey: @"enabled"]; +} + +- (BOOL) enableVacation +{ + return [[vacationOptions objectForKey: @"enabled"] boolValue]; +} + +- (void) setAutoReplyText: (NSString *) theText +{ + [vacationOptions setObject: theText + forKey: @"autoReplyText"]; +} + +- (NSString *) autoReplyText +{ + return [vacationOptions objectForKey: @"autoReplyText"]; +} + +- (void) setAutoReplyEmailAddresses: (NSString *) theAddresses +{ + NSArray *addresses; + + addresses = [[theAddresses componentsSeparatedByString: @","] trimmedComponents]; + + [vacationOptions setObject: addresses + forKey: @"autoReplyEmailAddresses"]; +} + +- (NSString *) autoReplyEmailAddresses +{ + NSArray *addressesList; + NSMutableArray *newAddressesList; + NSString *address; + unsigned int i; + + addressesList = [vacationOptions objectForKey: @"autoReplyEmailAddresses"]; + if (!addressesList) + { + newAddressesList = [NSMutableArray new]; + [newAddressesList autorelease]; + addressesList = [NSMutableArray arrayWithArray: [user allEmails]]; + for (i = 0; i < [addressesList count]; i++) + { + address = [addressesList objectAtIndex: i]; + if (![newAddressesList containsObject: address]) + [newAddressesList addObject: address]; + } + addressesList = newAddressesList; + } + + return [addressesList componentsJoinedByString: @", "]; +} + +- (NSArray *) daysBetweenResponsesList +{ + static NSArray* daysBetweenResponses = nil; + + if (!daysBetweenResponses) + { + daysBetweenResponses = [NSArray arrayWithObjects: @"1", @"2", @"3", @"5", @"7", @"14", @"21", @"30", nil]; + [daysBetweenResponses retain]; + } + + return daysBetweenResponses; +} + +- (void) setDaysBetweenResponses: (NSNumber *) theDays +{ + [vacationOptions setObject: theDays + forKey: @"daysBetweenResponse"]; +} + +- (NSString *) daysBetweenResponses +{ + NSString *days; + + days = [vacationOptions objectForKey: @"daysBetweenResponse"]; + if (!days) + days = @"7"; // defaults to 7 days + + return days; +} + +- (void) setIgnoreLists: (BOOL) ignoreLists +{ + [vacationOptions setObject: [NSNumber numberWithBool: ignoreLists] + forKey: @"ignoreLists"]; +} + +- (BOOL) ignoreLists +{ + NSNumber *obj; + BOOL ignore; + + obj = [vacationOptions objectForKey: @"ignoreLists"]; + + if (obj == nil) + ignore = YES; // defaults to true + else + ignore = [obj boolValue]; + + return ignore; +} + +/* mail forward */ + +- (BOOL) isForwardEnabled +{ + return forwardEnabled; +} + +- (void) setEnableForward: (BOOL) enableForward +{ + [forwardOptions setObject: [NSNumber numberWithBool: enableForward] + forKey: @"enabled"]; +} + +- (BOOL) enableForward +{ + return [[forwardOptions objectForKey: @"enabled"] boolValue]; +} + +- (void) setForwardAddress: (NSString *) forwardAddress +{ + [forwardOptions setObject: forwardAddress + forKey: @"forwardAddress"]; +} + +- (NSString *) forwardAddress +{ + return [forwardOptions objectForKey: @"forwardAddress"]; +} + +- (void) setForwardKeepCopy: (BOOL) keepCopy +{ + [forwardOptions setObject: [NSNumber numberWithBool: keepCopy] + forKey: @"keepCopy"]; +} + +- (BOOL) forwardKeepCopy +{ + return [[forwardOptions objectForKey: @"keepCopy"] boolValue]; +} + +/* main */ + - (NSArray *) availableModules { NSMutableArray *rc, *modules; diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index 1928b2a13..d4592a75d 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -26,6 +26,10 @@ label:value="Mail Options"/>
  • +
  • +
  • @@ -35,16 +39,16 @@
    -
    +

    +