From 60c0cefea69a70299d02f88526bb362479b9feb8 Mon Sep 17 00:00:00 2001 From: helge Date: Fri, 22 Jul 2005 13:00:03 +0000 Subject: [PATCH] improved handling of from-popup git-svn-id: http://svn.opengroupware.org/SOGo/trunk@897 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/MailerUI/ChangeLog | 10 +++++++ SOGo/UI/MailerUI/UIxMailEditor.m | 41 ++++++++++++++++++++++++-- SOGo/UI/MailerUI/UIxMailEditorAction.m | 14 +++++++-- SOGo/UI/MailerUI/Version | 2 +- 4 files changed, 62 insertions(+), 5 deletions(-) diff --git a/SOGo/UI/MailerUI/ChangeLog b/SOGo/UI/MailerUI/ChangeLog index 85e633a8..07804f53 100644 --- a/SOGo/UI/MailerUI/ChangeLog +++ b/SOGo/UI/MailerUI/ChangeLog @@ -1,3 +1,13 @@ +2005-07-22 Helge Hess + + * v0.9.170 + + * UIxMailEditor.m: the mail editor now presets the proper 'from' based + on the 'account' query parameter + + * UIxMailEditorAction.m: the compose action now adds the current + account as a query parameter when calling the compose panel + 2005-07-22 Marcus Mueller * English.lproj/Localizable.strings: added error labels for JavaScript diff --git a/SOGo/UI/MailerUI/UIxMailEditor.m b/SOGo/UI/MailerUI/UIxMailEditor.m index 35d55769..49f7a552 100644 --- a/SOGo/UI/MailerUI/UIxMailEditor.m +++ b/SOGo/UI/MailerUI/UIxMailEditor.m @@ -118,7 +118,7 @@ static NSArray *infoKeys = nil; ASSIGNCOPY(self->from, _value); } - (NSString *)from { - if (![self->from isNotNull]) + if (![self->from isNotEmpty]) return [[[self context] activeUser] email]; return self->from; } @@ -274,13 +274,49 @@ static NSArray *infoKeys = nil; return ((self->sentFolder = [folder retain])); } +- (void)_presetFromBasedOnAccountsQueryParameter { + /* preset the from field to the primary identity of the given account */ + /* Note: The compose action sets the 'accounts' query parameter */ + NSString *accountID; + SOGoMailAccounts *accounts; + SOGoMailAccount *account; + SOGoMailIdentity *identity; + + if (useLocationBasedSentFolder) /* from will be based on location */ + return; + + if ([self->from isNotEmpty]) /* a from is already set */ + return; + + accountID = [[[self context] request] formValueForKey:@"account"]; + if (![accountID isNotEmpty]) + return; + + accounts = [[self clientObject] mailAccountsFolder]; + if ([accounts isExceptionOrNull]) + return; /* we don't treat this as an error but are tolerant */ + + account = [accounts lookupName:accountID inContext:[self context] + acquire:NO]; + if ([account isExceptionOrNull]) + return; /* we don't treat this as an error but are tolerant */ + + identity = [account valueForKey:@"preferredIdentity"]; + if (![identity isNotNull]) { + [self warnWithFormat:@"Account has no preferred identity: %@", account]; + return; + } + + [self setFrom:[identity email]]; +} + - (SOGoMailIdentity *)selectedMailIdentity { SOGoMailAccounts *accounts; NSEnumerator *e; SOGoMailIdentity *identity; accounts = [[self clientObject] mailAccountsFolder]; - if ([accounts isKindOfClass:[NSException class]]) return (id)accounts; + if ([accounts isExceptionOrNull]) return (id)accounts; // TODO: This is still a hack because we detect the identity based on the // from. In Agenor all of the identities have unique emails, but this @@ -432,6 +468,7 @@ static NSArray *infoKeys = nil; #endif [self loadInfo:[[self clientObject] fetchInfo]]; + [self _presetFromBasedOnAccountsQueryParameter]; return self; } diff --git a/SOGo/UI/MailerUI/UIxMailEditorAction.m b/SOGo/UI/MailerUI/UIxMailEditorAction.m index 5d1c7470..eabab259 100644 --- a/SOGo/UI/MailerUI/UIxMailEditorAction.m +++ b/SOGo/UI/MailerUI/UIxMailEditorAction.m @@ -78,6 +78,7 @@ SOGoDraftsFolder *drafts; WOResponse *r; NSString *url; + id accountFolder; drafts = [self draftsFolder]; if (![drafts isNotNull]) @@ -92,8 +93,17 @@ if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; url = [url stringByAppendingString:@"edit"]; - // TODO: debug log - [self logWithFormat:@"compose on %@: %@", drafts, url]; + /* attach mail-account info */ + + accountFolder = [[self clientObject] valueForKey:@"mailAccountFolder"]; + if (![accountFolder isExceptionOrNull]) { + url = [url stringByAppendingString:@"?account="]; + url = [url stringByAppendingString:[accountFolder nameInContainer]]; + } + + /* perform redirect */ + + [self debugWithFormat:@"compose on %@: %@", drafts, url]; r = [[self context] response]; [r setStatus:302 /* moved */]; diff --git a/SOGo/UI/MailerUI/Version b/SOGo/UI/MailerUI/Version index 40704a1f..d781c774 100644 --- a/SOGo/UI/MailerUI/Version +++ b/SOGo/UI/MailerUI/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=169 +SUBMINOR_VERSION:=170 # v0.9.140 requires SoObjects/Mailer v0.9.100 # v0.9.134 requires libSOGo v0.9.41 -- 2.39.5