From fa4d2d3141aaf09e59d9ecc6b6f5edbb8f5a53aa Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 20 Apr 2012 13:27:21 +0000 Subject: [PATCH] Monotone-Parent: f90d169fbc251326ea6c8a2f620e125a8a7b4168 Monotone-Revision: 7786f49f6724383b92e91ba7998b99cfb52ceec3 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-04-20T13:27:21 --- ChangeLog | 13 +++ SoObjects/Mailer/SOGoDraftObject.m | 14 ++- SoObjects/SOGo/SOGoUser.m | 10 +- SoObjects/SOGo/SOGoUserDefaults.h | 3 + SoObjects/SOGo/SOGoUserDefaults.m | 12 +++ UI/MailerUI/UIxMailEditor.m | 10 ++ .../English.lproj/Localizable.strings | 1 + UI/PreferencesUI/UIxPreferences.m | 99 ++++++++++--------- UI/Templates/PreferencesUI/UIxPreferences.wox | 2 + UI/WebServerResources/HTMLElement.js | 13 +++ UI/WebServerResources/UIxPreferences.js | 16 +-- UI/WebServerResources/generic.js | 7 +- 12 files changed, 135 insertions(+), 65 deletions(-) diff --git a/ChangeLog b/ChangeLog index a45532c7f..a8696870c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2012-04-20 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoDraftObject.m + (-mimeHeaderMapWithHeaders:excluding:) take the new "replyTo" + header into account. + + * SoObjects/SOGo/SOGoUser.m (-_appendSystemMailAccount): specify + the value of "SOGoMailReplyTo" in the "replyTo" field of each + identity, if present. + + * SoObjects/SOGo/SOGoUserDefaults.m (-setMailReplyTo:) + (-mailReplyTo:): accessors for the "SOGoMailReplyTo" user default. + 2012-04-19 Francis Lachapelle * SoObjects/Appointments/SOGoAppointmentFolder.m diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index 4d5cad45d..93fc7e590 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -269,7 +269,7 @@ static NSString *userAgent = nil; { id headerValue; unsigned int count; - NSString *messageID, *priority, *pureSender; + NSString *messageID, *priority, *pureSender,*replyTo; for (count = 0; count < 8; count++) { @@ -310,6 +310,13 @@ static NSString *userAgent = nil; [headers setObject: @"5 (Lowest)" forKey: @"X-Priority"]; } + replyTo = [headers objectForKey: @"replyTo"]; + if ([replyTo length] > 0) + { + [headers setObject: replyTo forKey: @"reply-to"]; + [headers removeObjectForKey: @"replyTo"]; + } + if ([[newHeaders objectForKey: @"receipt"] isEqualToString: @"true"]) { pureSender = [[newHeaders objectForKey: @"from"] pureEMailAddress]; @@ -1361,7 +1368,7 @@ static NSString *userAgent = nil; NSString *s, *dateString; NGMutableHashMap *map; NSArray *emails; - id from; + id from, replyTo; map = [[[NGMutableHashMap alloc] initWithCapacity:16] autorelease]; @@ -1383,6 +1390,9 @@ static NSString *userAgent = nil; [map setObject: [self _quoteSpecials: from] forKey: @"from"]; } + if (replyTo = [headers objectForKey: @"reply-to"]) + [map setObject: replyTo forKey: @"reply-to"]; + if (inReplyTo) [map setObject: inReplyTo forKey: @"in-reply-to"]; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 2fd123e70..6fb78c66e 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -576,8 +576,8 @@ - (void) _appendSystemMailAccount { - NSString *fullName, *imapLogin, *imapServer, *signature, *encryption, - *scheme, *action, *query; + NSString *fullName, *replyTo, *imapLogin, *imapServer, *signature, + *encryption, *scheme, *action, *query; NSMutableDictionary *mailAccount, *identity, *mailboxes, *receipts; NSNumber *port; NSMutableArray *identities; @@ -642,6 +642,8 @@ mails = [self allEmails]; [mailAccount setObject: [mails objectAtIndex: 0] forKey: @"name"]; + replyTo = [_defaults mailReplyTo]; + max = [mails count]; if (max > 1) max--; @@ -653,6 +655,10 @@ fullName = login; [identity setObject: fullName forKey: @"fullName"]; [identity setObject: [mails objectAtIndex: count] forKey: @"email"]; + + if ([replyTo length] > 0) + [identity setObject: replyTo forKey: @"replyTo"]; + signature = [_defaults mailSignature]; if (signature) [identity setObject: signature forKey: @"signature"]; diff --git a/SoObjects/SOGo/SOGoUserDefaults.h b/SoObjects/SOGo/SOGoUserDefaults.h index 2ac120a64..2d86d3d10 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.h +++ b/SoObjects/SOGo/SOGoUserDefaults.h @@ -130,6 +130,9 @@ extern NSString *SOGoWeekStartFirstFullWeek; - (void) setMailSignaturePlacement: (NSString *) newValue; - (NSString *) mailSignaturePlacement; +- (void) setMailReplyTo: (NSString *) newValue; +- (NSString *) mailReplyTo; + - (void) setAllowUserReceipt: (BOOL) allow; - (BOOL) allowUserReceipt; - (void) setUserReceiptNonRecipientAction: (NSString *) action; diff --git a/SoObjects/SOGo/SOGoUserDefaults.m b/SoObjects/SOGo/SOGoUserDefaults.m index 8b595e83c..34fba52f4 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.m +++ b/SoObjects/SOGo/SOGoUserDefaults.m @@ -531,6 +531,18 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; return signaturePlacement; } +- (void) setMailReplyTo: (NSString *) newValue +{ + if ([newValue length] == 0) + newValue = nil; + [self setObject: newValue forKey: @"SOGoMailReplyTo"]; +} + +- (NSString *) mailReplyTo +{ + return [self stringForKey: @"SOGoMailReplyTo"]; +} + - (void) setAllowUserReceipt: (BOOL) allow { [self setBool: allow forKey: @"SOGoMailReceiptAllow"]; diff --git a/UI/MailerUI/UIxMailEditor.m b/UI/MailerUI/UIxMailEditor.m index 0d1f52597..aa32a7a59 100644 --- a/UI/MailerUI/UIxMailEditor.m +++ b/UI/MailerUI/UIxMailEditor.m @@ -104,6 +104,7 @@ static NSArray *infoKeys = nil; infoKeys = [[NSArray alloc] initWithObjects: @"subject", @"to", @"cc", @"bcc", @"from", @"inReplyTo", + @"replyTo", @"priority", @"receipt", nil]; } @@ -255,6 +256,15 @@ static NSArray *infoKeys = nil; return from; } +- (NSString *) replyTo +{ + SOGoUserDefaults *ud; + + ud = [[context activeUser] userDefaults]; + + return [ud mailReplyTo]; +} + - (void) setSubject: (NSString *) newSubject { ASSIGN (subject, newSubject); diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index d16d9f572..921eb83a5 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -160,6 +160,7 @@ "Full Name:" = "Full Name:"; "Email:" = "Email:"; +"Reply To Email:" = "Reply To Email:"; "Signature:" = "Signature:"; "(Click to create)" = "(Click to create)"; diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index c3b915af4..f49b40779 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -1273,33 +1273,21 @@ return [[user domainDefaults] mailAuxiliaryUserAccountsEnabled]; } -- (void) _extractMainSignature: (NSDictionary *) account +- (void) _extractMainIdentity: (NSDictionary *) identity { /* We perform some validation here as we have no guaranty on the input validity. */ - NSString *signature; - NSArray *identities; - NSDictionary *identity; + NSString *value; - if ([account isKindOfClass: [NSDictionary class]]) + if ([identity isKindOfClass: [NSDictionary class]]) { - identities = [account objectForKey: @"identities"]; - if ([identities isKindOfClass: [NSArray class]]) - { - signature = nil; - - if ([identities count] > 0) - { - identity = [identities objectAtIndex: 0]; - if ([identity isKindOfClass: [NSDictionary class]]) - { - signature = [identity objectForKey: @"signature"]; - if (!signature) - signature = @""; - [userDefaults setMailSignature: signature]; - } - } - } + value = [identity objectForKey: @"signature"]; + if (!value) + value = @""; + [userDefaults setMailSignature: value]; + value = [[identity objectForKey: @"replyTo"] + stringByTrimmingSpaces]; + [userDefaults setMailReplyTo: value]; } } @@ -1311,37 +1299,40 @@ || [action isEqualToString: @"ask"])); } -- (void) _extractMainReceiptsPreferences: (NSDictionary *) account +- (void) _extractMainReceiptsPreferences: (NSDictionary *) receipts { /* We perform some validation here as we have no guaranty on the input validity. */ - NSDictionary *receipts; NSString *action; - if ([account isKindOfClass: [NSDictionary class]]) + if ([receipts isKindOfClass: [NSDictionary class]]) { - receipts = [account objectForKey: @"receipts"]; - if ([receipts isKindOfClass: [NSDictionary class]]) - { - action = [receipts objectForKey: @"receiptAction"]; - [userDefaults - setAllowUserReceipt: [action isEqualToString: @"allow"]]; + action = [receipts objectForKey: @"receiptAction"]; + [userDefaults + setAllowUserReceipt: [action isEqualToString: @"allow"]]; + + action = [receipts objectForKey: @"receiptNonRecipientAction"]; + if ([self _validateReceiptAction: action]) + [userDefaults setUserReceiptNonRecipientAction: action]; - action = [receipts objectForKey: @"receiptNonRecipientAction"]; - if ([self _validateReceiptAction: action]) - [userDefaults setUserReceiptNonRecipientAction: action]; - - action = [receipts objectForKey: @"receiptOutsideDomainAction"]; - if ([self _validateReceiptAction: action]) - [userDefaults setUserReceiptOutsideDomainAction: action]; - - action = [receipts objectForKey: @"receiptAnyAction"]; - if ([self _validateReceiptAction: action]) - [userDefaults setUserReceiptAnyAction: action]; - } + action = [receipts objectForKey: @"receiptOutsideDomainAction"]; + if ([self _validateReceiptAction: action]) + [userDefaults setUserReceiptOutsideDomainAction: action]; + + action = [receipts objectForKey: @"receiptAnyAction"]; + if ([self _validateReceiptAction: action]) + [userDefaults setUserReceiptAnyAction: action]; } } +- (void) _extractMainCustomFrom: (NSDictionary *) account +{ +} + +- (void) _extractMainReplyTo: (NSDictionary *) account +{ +} + - (BOOL) _validateAccountIdentities: (NSArray *) identities { static NSString *identityKeys[] = { @"fullName", @"email", nil }; @@ -1355,7 +1346,7 @@ if (!knownKeys) { knownKeys = [NSArray arrayWithObjects: @"fullName", @"email", - @"signature", nil]; + @"signature", @"replyTo", nil]; [knownKeys retain]; } @@ -1407,7 +1398,7 @@ if (!knownKeys) { knownKeys = [NSArray arrayWithObjects: @"name", @"serverName", @"port", - @"userName", @"password", @"encryption", + @"userName", @"password", @"encryption", @"replyTo", @"identities", @"mailboxes", @"receipts", nil]; @@ -1449,6 +1440,20 @@ return valid; } +- (void) _extractMainAccountSettings: (NSDictionary *) account +{ + NSArray *identities; + + if ([account isKindOfClass: [NSDictionary class]]) + { + identities = [account objectForKey: @"identities"]; + if ([identities isKindOfClass: [NSArray class]] + && [identities count] > 0) + [self _extractMainIdentity: [identities objectAtIndex: 0]]; + [self _extractMainReceiptsPreferences: [account objectForKey: @"receipts"]]; + } +} + - (void) _extractAuxiliaryAccounts: (NSArray *) accounts { int count, max, oldMax; @@ -1499,9 +1504,7 @@ max = [accounts count]; if (max > 0) { - [self _extractMainSignature: [accounts objectAtIndex: 0]]; - [self _extractMainReceiptsPreferences: [accounts objectAtIndex: 0]]; - + [self _extractMainAccountSettings: [accounts objectAtIndex: 0]]; if ([self mailAuxiliaryUserAccountsEnabled]) [self _extractAuxiliaryAccounts: accounts]; } diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index bb56c6c51..c7c863c91 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -324,6 +324,8 @@ />

+
diff --git a/UI/WebServerResources/HTMLElement.js b/UI/WebServerResources/HTMLElement.js index 7e96f4084..518657123 100644 --- a/UI/WebServerResources/HTMLElement.js +++ b/UI/WebServerResources/HTMLElement.js @@ -1,5 +1,18 @@ /* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +if (NodeList) { + var _each = NodeList.prototype.forEach; + if (!_each) { + _each = function NodeList_each(iterator, context) { + for (var i = 0, length = this.length >>> 0; i < length; i++) { + if (i in this) iterator.call(context, this[i], i, this); + } + }; + } + NodeList.prototype._each = _each; + Object.extend(NodeList.prototype, Enumerable); +} + /* custom extensions to the DOM api */ Element.addMethods({ addInterface: function(element, objectInterface) { diff --git a/UI/WebServerResources/UIxPreferences.js b/UI/WebServerResources/UIxPreferences.js index a07b2fd25..e10738934 100644 --- a/UI/WebServerResources/UIxPreferences.js +++ b/UI/WebServerResources/UIxPreferences.js @@ -657,16 +657,15 @@ function onMailAccountEntryClick(event) { function displayMailAccount(mailAccount, readOnly) { var fieldSet = $("accountInfo"); - var inputs = fieldSet.getElementsByTagName("input"); - for (var i = 0; i < inputs.length; i++) { - inputs[i].disabled = readOnly; - inputs[i].mailAccount = mailAccount; - } + var inputs = $(fieldSet.getElementsByTagName("input")); + inputs.each(function (i) { i.disabled = readOnly; + i.mailAccount = mailAccount; }); + fieldSet = $("identityInfo"); - inputs = fieldSet.getElementsByTagName("input"); - for (var i = 0; i < inputs.length; i++) { + inputs = $(fieldSet.getElementsByTagName("input")); + inputs.each(function (i) { i.mailAccount = mailAccount; }); + for (var i = 0; i < 2; i++) { inputs[i].disabled = readOnly; - inputs[i].mailAccount = mailAccount; } var form = $("mainForm"); @@ -701,6 +700,7 @@ function displayMailAccount(mailAccount, readOnly) { : {} ); $("fullName").value = identity["fullName"] || ""; $("email").value = identity["email"] || ""; + $("replyTo").value = identity["replyTo"] || ""; displayAccountSignature(mailAccount); diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 88ff066ec..ec4479a16 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -1681,13 +1681,10 @@ function onPreferencesClick(event) { } else { var w = window.open(urlstr, "SOGoPreferences", - "width=580,height=450,resizable=1,scrollbars=0,location=0"); + "width=580,height=476,resizable=1,scrollbars=0,location=0"); w.opener = window; w.focus(); } - - preventDefault(event); - return false; } function configureLinkBanner() { @@ -1704,7 +1701,7 @@ function configureLinkBanner() { link = $("preferencesBannerLink"); if (link) { link.observe("mousedown", listRowMouseDownHandler); - link.observe("click", onPreferencesClick); + link.observe("click", clickEventWrapper(onPreferencesClick)); } link = $("consoleBannerLink"); if (link) {