From 5ccfce7cdcf58227771b7e34c384800601af2bed Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 6 Nov 2007 17:12:37 +0000 Subject: [PATCH 01/12] Monotone-Parent: d20b6efa6a8c415c1db8ca849c311e740a312646 Monotone-Revision: 1dda8463cbff42910b1cacd540a640120d4d4939 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-11-06T17:12:37 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++++ SoObjects/SOGo/SOGoUser.m | 76 +++++++++++++++++++++++---------------- 2 files changed, 51 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54838b558..5e1697b8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-11-06 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoUser.m ([SOGoUser -mailAccounts]): we now + fetch the accounts from the user defaults and create default + values if missing. + 2007-11-05 Wolfgang Sourdeau * UI/MailPartViewers/UIxMailPartTextViewer.m diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 708ed4f96..64671657c 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -368,44 +368,58 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek"; } /* mail */ -- (NSArray *) mailAccounts +- (void) _prepareDefaultMailAccounts { -#warning should be implemented with the user defaults interfaces NSMutableDictionary *mailAccount, *identity; NSMutableArray *identities; NSString *name, *fullName; + NSArray *mails; + unsigned int count, max; + + mailAccount = [NSMutableDictionary dictionary]; + name = [NSString stringWithFormat: @"%@@%@", + login, fallbackIMAP4Server]; + [mailAccount setObject: login forKey: @"userName"]; + [mailAccount setObject: fallbackIMAP4Server forKey: @"serverName"]; + [mailAccount setObject: name forKey: @"name"]; + + identities = [NSMutableArray array]; + mails = [self allEmails]; + + max = [mails count]; + if (max > 1) + max--; + for (count = 0; count < max; count++) + { + identity = [NSMutableDictionary dictionary]; + fullName = [self cn]; + if (![fullName length]) + fullName = login; + [identity setObject: fullName forKey: @"fullName"]; + [identity setObject: [mails objectAtIndex: count] forKey: @"email"]; + [identities addObject: identity]; + } + [[identities objectAtIndex: 0] setObject: [NSNumber numberWithBool: YES] + forKey: @"isDefault"]; + + [mailAccount setObject: identities forKey: @"identities"]; + + mailAccounts = [NSMutableArray new]; + [mailAccounts addObject: mailAccount]; +} + +- (NSArray *) mailAccounts +{ + NSUserDefaults *ud; if (!mailAccounts) { - NSArray *mails; - int i; - - mailAccount = [NSMutableDictionary dictionary]; - name = [NSString stringWithFormat: @"%@@%@", login, fallbackIMAP4Server]; - [mailAccount setObject: login forKey: @"userName"]; - [mailAccount setObject: fallbackIMAP4Server forKey: @"serverName"]; - [mailAccount setObject: name forKey: @"name"]; - - identities = [NSMutableArray array]; - mails = [self allEmails]; - - for (i = 0; i < [mails count]; i++) - { - identity = [NSMutableDictionary dictionary]; - fullName = [self cn]; - if (![fullName length]) - fullName = login; - [identity setObject: fullName forKey: @"fullName"]; - [identity setObject: [mails objectAtIndex: i] forKey: @"email"]; - - if (i == 0) [identity setObject: [NSNumber numberWithBool: YES] forKey: @"isDefault"]; - [identities addObject: identity]; - } - - [mailAccount setObject: identities forKey: @"identities"]; - - mailAccounts = [NSMutableArray new]; - [mailAccounts addObject: mailAccount]; + ud = [self userDefaults]; + mailAccounts = [ud objectForKey: @"MailAccounts"]; + if (mailAccounts) + [mailAccounts retain]; + else + [self _prepareDefaultMailAccounts]; } return mailAccounts; From 533da99dcc958f9521ca640347423a7b0738d658 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 6 Nov 2007 17:13:03 +0000 Subject: [PATCH 02/12] Monotone-Parent: 1dda8463cbff42910b1cacd540a640120d4d4939 Monotone-Revision: 56e8fb42c60b615f9c931f4b5e80a51560db4269 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-11-06T17:13:03 Monotone-Branch: ca.inverse.sogo --- UI/PreferencesUI/UIxJSONPreferences.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UI/PreferencesUI/UIxJSONPreferences.m b/UI/PreferencesUI/UIxJSONPreferences.m index 0b18a97b8..de9055939 100644 --- a/UI/PreferencesUI/UIxJSONPreferences.m +++ b/UI/PreferencesUI/UIxJSONPreferences.m @@ -33,14 +33,14 @@ @implementation UIxJSONPreferences -- (WOResponse *) _makeResponse: (NSString *) jsonText +- (WOResponse *) _makeResponse: (NSUserDefaults *) defaults { WOResponse *response; response = [context response]; [response setHeader: @"text/plain; charset=utf-8" forKey: @"content-type"]; - [response appendContentString: jsonText]; + [response appendContentString: [defaults jsonRepresentation]]; return response; } @@ -51,7 +51,7 @@ defaults = [[context activeUser] userDefaults]; - return [self _makeResponse: [defaults jsonRepresentation]]; + return [self _makeResponse: defaults]; } - (WOResponse *) jsonSettingsAction @@ -60,7 +60,7 @@ settings = [[context activeUser] userSettings]; - return [self _makeResponse: [settings jsonRepresentation]]; + return [self _makeResponse: settings]; } @end From 4cf8731681471c114274afaa7804c34851d4d70a Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 6 Nov 2007 17:13:15 +0000 Subject: [PATCH 03/12] Monotone-Parent: 56e8fb42c60b615f9c931f4b5e80a51560db4269 Monotone-Revision: d25dc292baa2e15a7f6d397c032c8cb30ccdafb2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-11-06T17:13:15 Monotone-Branch: ca.inverse.sogo --- .../English.lproj/Localizable.strings | 3 ++ .../French.lproj/Localizable.strings | 3 ++ UI/PreferencesUI/GNUmakefile | 1 + .../German.lproj/Localizable.strings | 3 ++ UI/PreferencesUI/UIxPreferences.h | 2 +- UI/PreferencesUI/UIxPreferences.m | 30 +++++++++++++++++++ UI/PreferencesUI/product.plist | 4 +++ 7 files changed, 45 insertions(+), 1 deletion(-) diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index d216c0fe6..d9b2679cb 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -82,6 +82,9 @@ "messageforward_inline" = "Inline"; "messageforward_attached" = "As Attachment"; +"Default identity:" = "Default identity:"; +"Manage identities..." = "Manage identities..."; + /* password */ "New password:" = "New password:"; "Confirmation:" = "Confirmation:"; diff --git a/UI/PreferencesUI/French.lproj/Localizable.strings b/UI/PreferencesUI/French.lproj/Localizable.strings index 99d333873..d41dd6d1d 100644 --- a/UI/PreferencesUI/French.lproj/Localizable.strings +++ b/UI/PreferencesUI/French.lproj/Localizable.strings @@ -79,6 +79,9 @@ "messageforward_inline" = "intégrés"; "messageforward_attached" = "en pièces jointes"; +"Default identity:" = "Identité par défaut :"; +"Manage identities..." = "Gérer les identitiés..."; + /* password */ "New password:" = "Nouveau mot de passe :"; "Confirmation:" = "Confirmation :"; diff --git a/UI/PreferencesUI/GNUmakefile b/UI/PreferencesUI/GNUmakefile index 2b34be9b5..496a1eda3 100644 --- a/UI/PreferencesUI/GNUmakefile +++ b/UI/PreferencesUI/GNUmakefile @@ -11,6 +11,7 @@ PreferencesUI_LANGUAGES = English French German PreferencesUI_OBJC_FILES = \ PreferencesUIProduct.m \ \ + UIxIdentities.m \ UIxJSONPreferences.m \ UIxPreferences.m diff --git a/UI/PreferencesUI/German.lproj/Localizable.strings b/UI/PreferencesUI/German.lproj/Localizable.strings index e25c85fb0..55db9ef65 100644 --- a/UI/PreferencesUI/German.lproj/Localizable.strings +++ b/UI/PreferencesUI/German.lproj/Localizable.strings @@ -79,6 +79,9 @@ "messageforward_inline" = "Eingebunden"; "messageforward_attached" = "Als Anhang"; +"Default identity:" = "Default identity:"; +"Manage identities..." = "Manage identities..."; + /* password */ "New password:" = "Neues Passwort:"; "Confirmation:" = "Bestätigung:"; diff --git a/UI/PreferencesUI/UIxPreferences.h b/UI/PreferencesUI/UIxPreferences.h index 5570fbc7e..c97889248 100644 --- a/UI/PreferencesUI/UIxPreferences.h +++ b/UI/PreferencesUI/UIxPreferences.h @@ -32,7 +32,7 @@ @interface UIxPreferences : UIxComponent { - NSString *item; + id item; SOGoUser *user; NSUserDefaults *userDefaults; NSCalendarDate *today; diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index 0a6c33ef1..958675336 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -28,6 +28,7 @@ #import #import +#import #import #import "UIxPreferences.h" @@ -466,6 +467,35 @@ static BOOL shouldDisplayPasswordChange = NO; [userDefaults setObject: newMessageForwarding forKey: @"MessageForwarding"]; } +// +- (NSArray *) identitiesList +{ + return [user allIdentities]; +} + +- (NSString *) itemIdentityText +{ + return [item keysWithFormat: @"%{fullName} <%{email}>"]; +} + +- (NSDictionary *) defaultIdentity +{ + NSDictionary *currentIdentity, *defaultIdentity; + NSEnumerator *identities; + + defaultIdentity = nil; + + identities = [[user allIdentities] objectEnumerator]; + while (!defaultIdentity + && (currentIdentity = [identities nextObject])) + if ([[currentIdentity objectForKey: @"isDefault"] boolValue]) + defaultIdentity = currentIdentity; + + return defaultIdentity; +} + - (id ) defaultAction { id results; diff --git a/UI/PreferencesUI/product.plist b/UI/PreferencesUI/product.plist index de4a1d90d..2891bffa1 100644 --- a/UI/PreferencesUI/product.plist +++ b/UI/PreferencesUI/product.plist @@ -20,6 +20,10 @@ protectedBy = "View"; pageName = "UIxPreferences"; }; + identities = { + protectedBy = "View"; + pageName = "UIxIdentities"; + }; jsonDefaults = { protectedBy = "View"; actionClass = "UIxJSONPreferences"; From 58aeee0393c0c65afb61d1190fdbe0fb5f604fab Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 6 Nov 2007 17:13:19 +0000 Subject: [PATCH 04/12] Monotone-Parent: d25dc292baa2e15a7f6d397c032c8cb30ccdafb2 Monotone-Revision: 8c2a059d02106d28fe1332f9ecd1d7d5b75cfaeb Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-11-06T17:13:19 Monotone-Branch: ca.inverse.sogo --- UI/WebServerResources/UIxPreferences.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/UI/WebServerResources/UIxPreferences.js b/UI/WebServerResources/UIxPreferences.js index 8549871bc..4a08999d7 100644 --- a/UI/WebServerResources/UIxPreferences.js +++ b/UI/WebServerResources/UIxPreferences.js @@ -3,3 +3,21 @@ function savePreferences(sender) { return false; } + +function initPreferences() { + var identitiesBtn = $("manageIdentitiesBtn"); + Event.observe(identitiesBtn, "click", + popupIdentitiesWindow.bindAsEventListener(identitiesBtn)); +} + +function popupIdentitiesWindow(event) { + var urlstr = UserFolderURL + "identities"; + var w = window.open(urlstr, "identities", + "width=430,height=250,resizable=0,scrollbars=0,location=0"); + w.opener = window; + w.focus(); + + preventDefault(event); +} + +addEvent(window, 'load', initPreferences); From f2b6271cefd62deb1d3360bb53723ed1e683cef5 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 6 Nov 2007 17:13:23 +0000 Subject: [PATCH 05/12] Monotone-Parent: 8c2a059d02106d28fe1332f9ecd1d7d5b75cfaeb Monotone-Revision: 166aef5ba4c5699c0bde50ef5dddb543641e5c67 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-11-06T17:13:23 Monotone-Branch: ca.inverse.sogo --- UI/Templates/PreferencesUI/UIxPreferences.wox | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index dd0ca1af2..7857d13ff 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -80,6 +80,12 @@
+ + +