diff --git a/ChangeLog b/ChangeLog index 54838b558..a379bb64b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-11-06 Wolfgang Sourdeau + + * UI/MailerUI/UIxMailToSelection.m ([UIxMailToSelection + -getAddressesFromFormValues:_dict]): take NSString and NSArray + values. Ignore addresses with a length of 0. + + * 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/SOPE/GDLContentStore/gcs_mkdir.m b/SOPE/GDLContentStore/gcs_mkdir.m index fc3b35473..9e62ee878 100644 --- a/SOPE/GDLContentStore/gcs_mkdir.m +++ b/SOPE/GDLContentStore/gcs_mkdir.m @@ -66,7 +66,9 @@ return 1; } - if ((error = [self->folderManager createFolderOfType:_type atPath:_path])) { + if ((error = [self->folderManager createFolderOfType:_type + withName: @"testFolder" + atPath:_path])) { [self logWithFormat:@"creation of folder %@ at %@ failed: %@", _type, _path, error]; return 1; diff --git a/SOPE/NGCards/iCalRepeatableEntityObject.h b/SOPE/NGCards/iCalRepeatableEntityObject.h index 08f19f819..fa475a01c 100644 --- a/SOPE/NGCards/iCalRepeatableEntityObject.h +++ b/SOPE/NGCards/iCalRepeatableEntityObject.h @@ -43,7 +43,7 @@ - (void)removeAllRecurrenceRules; - (void)addToRecurrenceRules:(id)_rrule; -- (void)setRecurrenceRules:(id)_rrule; +- (void)setRecurrenceRules:(NSArray *)_rrule; - (BOOL)hasRecurrenceRules; - (NSArray *)recurrenceRules; diff --git a/SoObjects/Mailer/NSData+Mail.h b/SoObjects/Mailer/NSData+Mail.h index 45e033f74..d22317820 100644 --- a/SoObjects/Mailer/NSData+Mail.h +++ b/SoObjects/Mailer/NSData+Mail.h @@ -30,6 +30,7 @@ @interface NSData (SOGoMailUtilities) - (NSData *) bodyDataFromEncoding: (NSString *) encoding; +- (NSString *) decodedSubject; @end diff --git a/SoObjects/Mailer/NSString+Mail.h b/SoObjects/Mailer/NSString+Mail.h index 72bc984a9..3b34491cb 100644 --- a/SoObjects/Mailer/NSString+Mail.h +++ b/SoObjects/Mailer/NSString+Mail.h @@ -28,7 +28,6 @@ @interface NSString (SOGoExtension) - (NSString *) htmlToText; - - (NSString *) decodedSubject; @end diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index 934f1c61c..87a86fa29 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -44,6 +44,7 @@ #import #import +#import "NSString+Mail.h" #import "NSData+Mail.h" #import "SOGoMailFolder.h" #import "SOGoMailAccount.h" diff --git a/SoObjects/Mailer/SOGoMailReply.m b/SoObjects/Mailer/SOGoMailReply.m index d2e939d94..f1758ed6a 100644 --- a/SoObjects/Mailer/SOGoMailReply.m +++ b/SoObjects/Mailer/SOGoMailReply.m @@ -21,6 +21,7 @@ */ #import +#import #import #import 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; diff --git a/UI/MailerUI/UIxMailToSelection.m b/UI/MailerUI/UIxMailToSelection.m index ef5c141bc..cdcc83bf0 100644 --- a/UI/MailerUI/UIxMailToSelection.m +++ b/UI/MailerUI/UIxMailToSelection.m @@ -285,11 +285,31 @@ static NSArray *headers = nil; /* handling requests */ +- (void) _fillAddresses: (NSMutableArray *) addresses + withObject: (id) object +{ + NSEnumerator *list; + NSString *currentAddress; + + if ([object isKindOfClass: [NSString class]]) + [addresses addObject: object]; + else if ([object isKindOfClass: [NSArray class]]) + { + list = [object objectEnumerator]; + while ((currentAddress + = [[list nextObject] stringByTrimmingSpaces])) + if ([currentAddress length]) + [addresses addObject: currentAddress]; + } +} + - (void) getAddressesFromFormValues: (NSDictionary *) _dict { NSMutableArray *rawTo, *rawCc, *rawBcc; + NSString *idx, *popupKey, *popupValue; NSArray *keys; unsigned i, count; + id addr; rawTo = [NSMutableArray arrayWithCapacity:4]; rawCc = [NSMutableArray arrayWithCapacity:4]; @@ -304,18 +324,16 @@ static NSArray *headers = nil; key = [keys objectAtIndex:i]; if ([key hasPrefix:@"addr_"]) { - NSString *idx, *addr, *popupKey, *popupValue; - - addr = [[_dict objectForKey:key] lastObject]; + addr = [_dict objectForKey:key]; idx = [self getIndexFromIdentifier:key]; popupKey = [NSString stringWithFormat:@"popup_%@", idx]; popupValue = [[_dict objectForKey:popupKey] lastObject]; if([popupValue isEqualToString:@"0"]) - [rawTo addObject:addr]; + [self _fillAddresses: rawTo withObject: addr]; else if([popupValue isEqualToString:@"1"]) - [rawCc addObject:addr]; + [self _fillAddresses: rawCc withObject: addr]; else - [rawBcc addObject:addr]; + [self _fillAddresses: rawBcc withObject: addr]; } } 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/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 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"; diff --git a/UI/SOGoUI/UIxComponent.m b/UI/SOGoUI/UIxComponent.m index 273d3e20b..efbe22c91 100644 --- a/UI/SOGoUI/UIxComponent.m +++ b/UI/SOGoUI/UIxComponent.m @@ -24,23 +24,27 @@ #import #import #import + #import #import #import #import +#import #import #import #import #import + #import #import #import #import #import -#import "UIxComponent.h" #import "UIxJSClose.h" +#import "UIxComponent.h" + @interface UIxComponent (PrivateAPI) - (void)_parseQueryString:(NSString *)_s; - (NSMutableDictionary *)_queryParameters; 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 @@
+ + +