* SoObjects/SOGo/SOGoUser.m ([SOGoUser -mailAccounts]): if the
loginname for the default mail account contains an "@", it should
be url-escaped to avoid confusing NSURL.
+ ([SOGoUser -accountWithName:accountName]): new method that wanders
+ the accounts list and returns the one that matches the name passed
+ as parameter, if found.
* SoObjects/SOGo/SOGoUserFolder.m ([-login]): removed useless
method.
return [creds objectAtIndex:0]; /* the user */
}
+- (NSString *) urlHostString
+{
+ NSDictionary *mailAccount;
+ NSString *username, *escUsername, hostString;
+
+ mailAccount = [[context activeUser] accountWithName: nameInContainer];
+ if (mailAccount)
+ {
+ username = [mailAccount objectForKey: @"userName"];
+ escUsername
+ = [[username stringByReplacingString: @"@" withString: @"%40"]
+ stringByEscapingURL];
+ hostString = [NSString stringWithFormat: @"%@@%@", escUsername,
+ [mailAccount objectForKey: @"serverName"]];
+ }
+ else
+ hostString = @"localhost";
+
+ return hostString;
+}
+
- (NSMutableString *) imap4URLString
{
/* private, overridden by SOGoSharedMailAccount */
else
[urlString appendString: @"imap://"];
- host = [self nameInContainer];
+ host = [self urlHostString];
if (![host rangeOfString: @"@"].length)
[urlString appendFormat: @"%@@", [self imap4LoginFromHTTP]];
[urlString appendFormat: @"%@/", host];
// return [NSException exceptionWithHTTPStatus:403 /* Forbidden */
// reason:@"Tried to access the mail of another user"];
// }
-
/* first check attributes directly bound to the application */
obj = [super lookupName:_key inContext:_ctx acquire:NO];
- (NSTimeZone *) serverTimeZone;
- (NSArray *) mailAccounts;
+- (NSDictinary *) accountWithName: (NSString *) accountName;
- (NSArray *) allIdentities;
- (NSDictionary *) primaryIdentity;
- (NSMutableDictionary *) defaultIdentity;
{
NSMutableDictionary *mailAccount, *identity;
NSMutableArray *identities;
- NSString *name, *fullName, *userName;
+ NSString *name, *fullName;
NSArray *mails;
unsigned int count, max;
mailAccount = [NSMutableDictionary dictionary];
- userName = [[login stringByReplacingString: @"@" withString: @"%40"]
- stringByEscapingURL];
name = [NSString stringWithFormat: @"%@@%@",
- userName, fallbackIMAP4Server];
- [mailAccount setObject: userName forKey: @"userName"];
+ login, fallbackIMAP4Server];
+ [mailAccount setObject: login forKey: @"userName"];
[mailAccount setObject: fallbackIMAP4Server forKey: @"serverName"];
[mailAccount setObject: name forKey: @"name"];
return mailAccounts;
}
+- (NSDictinary *) accountWithName: (NSString *) accountName
+{
+ NSEnumerator *accounts;
+ NSDictionary *mailAccount, *currentAccount;
+
+ mailAccount = nil;
+
+ accounts = [[self mailAccounts] objectEnumerator];
+ while (!mailAccount
+ && ((currentAccount = [accounts nextObject])))
+ if ([[currentAccount objectForKey: @"name"]
+ isEqualToString: nameInContainer])
+ mailAccount = currentAccount;
+
+ return mailAccount;
+}
+
/*
@interface SOGoMailIdentity : NSObject
{