diff --git a/ChangeLog b/ChangeLog index 0e2cb181e..a46e22173 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-08-06 Wolfgang Sourdeau + * UI/MailerUI/UIxMailFolderActions.m (_setFolderPurpose:): we now + use the corresponding methods on the SOGoUserDefaults instance + rather than in the user settings (old bug) when setting folders + for the main account. Additionally, we now handle the entries from + auxiliary accounts. + * UI/MailerUI/UIxMailEditor.m (-fromEmails): the list of identities is now taken from the corresponding mail account dict. diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index f04d3283f..60ef5deea 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -32,11 +32,13 @@ #import #import -#import -#import #import +#import #import +#import + #import +#import #import #import #import @@ -351,26 +353,94 @@ return response; } +- (void) _setFolderPurposeOnMainAccount: (NSString *) purpose + inUserDefaults: (SOGoUserDefaults *) ud + to: (NSString *) value +{ + NSString *selName; + SEL setter; + + selName = [NSString stringWithFormat: @"set%@FolderName:", purpose]; + setter = NSSelectorFromString (selName); + [ud performSelector: setter withObject: value]; +} + +- (WOResponse *) _setFolderPurpose: (NSString *) purpose + onAuxAccount: (int) accountIdx + inUserDefaults: (SOGoUserDefaults *) ud + to: (NSString *) value +{ + NSArray *accounts; + int realIdx; + NSMutableDictionary *account, *mailboxes; + WOResponse *response; + + if (accountIdx > 0) + { + realIdx = accountIdx - 1; + accounts = [ud auxiliaryMailAccounts]; + if ([accounts count] > realIdx) + { + account = [accounts objectAtIndex: realIdx]; + mailboxes = [account objectForKey: @"mailboxes"]; + if (!mailboxes) + { + mailboxes = [NSMutableDictionary new]; + [account setObject: mailboxes forKey: @"mailboxes"]; + [mailboxes release]; + } + [mailboxes setObject: value forKey: purpose]; + [ud setAuxiliaryMailAccounts: accounts]; + response = [self responseWith204]; + } + else + response + = [self responseWithStatus: 500 + andString: @"You reached an impossible end."]; + } + else + response + = [self responseWithStatus: 500 + andString: @"You reached an impossible end."]; + + return response; +} + - (WOResponse *) _setFolderPurpose: (NSString *) purpose { SOGoMailFolder *co; WOResponse *response; - SOGoUserSettings *us; - NSMutableDictionary *mailSettings; + SOGoUser *owner; + SOGoUserDefaults *ud; + NSString *accountIdx, *traversal; co = [self clientObject]; - if ([NSStringFromClass ([co class]) isEqualToString: @"SOGoMailFolder"]) + if ([co isKindOfClass: [SOGoMailFolder class]]) { - us = [[context activeUser] userSettings]; - mailSettings = [us objectForKey: @"Mail"]; - if (!mailSettings) - mailSettings = [NSMutableDictionary dictionary]; - [us setObject: mailSettings forKey: @"Mail"]; - [mailSettings setObject: [co traversalFromMailAccount] - forKey: [NSString stringWithFormat: @"%@Folder", - purpose]]; - [us synchronize]; - response = [self responseWith204]; + accountIdx = [[co mailAccountFolder] nameInContainer]; + owner = [SOGoUser userWithLogin: [co ownerInContext: nil]]; + ud = [owner userDefaults]; + traversal = [co traversalFromMailAccount]; + if ([accountIdx isEqualToString: @"0"]) + { + /* default account: we directly set the corresponding pref in the ud + */ + [self _setFolderPurposeOnMainAccount: purpose + inUserDefaults: ud + to: traversal]; + response = [self responseWith204]; + } + else if ([[owner domainDefaults] mailAuxiliaryUserAccountsEnabled]) + response = [self _setFolderPurpose: purpose + onAuxAccount: [accountIdx intValue] + inUserDefaults: ud + to: traversal]; + else + response + = [self responseWithStatus: 500 + andString: @"You reached an impossible end."]; + if ([response status] == 204) + [ud synchronize]; } else {