+2007-11-06 Wolfgang Sourdeau <wsourdeau@inverse.ca>
+
+ * 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 <wsourdeau@inverse.ca>
* UI/MailPartViewers/UIxMailPartTextViewer.m
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;
- (void)removeAllRecurrenceRules;
- (void)addToRecurrenceRules:(id)_rrule;
-- (void)setRecurrenceRules:(id)_rrule;
+- (void)setRecurrenceRules:(NSArray *)_rrule;
- (BOOL)hasRecurrenceRules;
- (NSArray *)recurrenceRules;
@interface NSData (SOGoMailUtilities)
- (NSData *) bodyDataFromEncoding: (NSString *) encoding;
+- (NSString *) decodedSubject;
@end
@interface NSString (SOGoExtension)
- (NSString *) htmlToText;
-
- (NSString *) decodedSubject;
@end
#import <SoObjects/SOGo/SOGoPermissions.h>
#import <SoObjects/SOGo/SOGoUser.h>
+#import "NSString+Mail.h"
#import "NSData+Mail.h"
#import "SOGoMailFolder.h"
#import "SOGoMailAccount.h"
*/
#import <NGObjWeb/WOContext+SoObjects.h>
+#import <NGExtensions/NSString+misc.h>
#import <SoObjects/SOGo/SOGoDateFormatter.h>
#import <SoObjects/SOGo/SOGoUser.h>
}
/* 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;
/* 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];
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];
}
}
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSPathUtilities.h>
+
#import <NGObjWeb/SoHTTPAuthenticator.h>
#import <NGObjWeb/SoObjects.h>
#import <NGObjWeb/WOResourceManager.h>
#import <NGObjWeb/WORequest.h>
+#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSString+misc.h>
#import <NGExtensions/NSURL+misc.h>
+
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoObject.h>
#import <SoObjects/SOGo/SOGoCustomGroupFolder.h>
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
-#import "UIxComponent.h"
#import "UIxJSClose.h"
+#import "UIxComponent.h"
+
@interface UIxComponent (PrivateAPI)
- (void)_parseQueryString:(NSString *)_s;
- (NSMutableDictionary *)_queryParameters;