From f109ff66a6322284b3ed526445e9012ec80960a0 Mon Sep 17 00:00:00 2001 From: wolfgang Date: Tue, 6 Nov 2007 21:25:28 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1241 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 10 +++ SOPE/GDLContentStore/gcs_mkdir.m | 4 +- SOPE/NGCards/iCalRepeatableEntityObject.h | 2 +- SoObjects/Mailer/NSData+Mail.h | 1 + SoObjects/Mailer/NSString+Mail.h | 1 - SoObjects/Mailer/SOGoMailObject.m | 1 + SoObjects/Mailer/SOGoMailReply.m | 1 + SoObjects/SOGo/SOGoUser.m | 76 ++++++++++++++--------- UI/MailerUI/UIxMailToSelection.m | 30 +++++++-- UI/SOGoUI/UIxComponent.m | 6 +- 10 files changed, 91 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 54838b55..a379bb64 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 fc3b3547..9e62ee87 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 08f19f81..fa475a01 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 45e033f7..d2231782 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 72bc984a..3b34491c 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 934f1c61..87a86fa2 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 d2e939d9..f1758ed6 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 708ed4f9..64671657 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 ef5c141b..cdcc83bf 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/SOGoUI/UIxComponent.m b/UI/SOGoUI/UIxComponent.m index 273d3e20..efbe22c9 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; -- 2.39.5